Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions common/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

module.exports = require('../.eslintrc.base.js');
3 changes: 3 additions & 0 deletions common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Perses Common Package

this [package] This [package](https://www.npmjs.com/package/@perses-dev/common) includes basic types and utilities which are common among other packages.
33 changes: 33 additions & 0 deletions common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@perses-dev/common",
"version": "0.54.0-beta.0",
"description": "Common types and utilities of Perses",
"license": "Apache-2.0",
"homepage": "https://github.com/perses/perses/blob/main/README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/perses/perses.git"
},
"bugs": {
"url": "https://github.com/perses/perses/issues"
},
"module": "dist/index.js",
"main": "dist/cjs/index.js",
"types": "dist/index.d.ts",
"scripts": {
"clean": "rimraf dist/",
"build": "concurrently \"npm:build:*\"",
"build:cjs": "swc ./src -d dist/cjs --strip-leading-paths --config-file ../.cjs.swcrc",
"build:esm": "swc ./src -d dist --strip-leading-paths --config-file ../.swcrc",
"build:types": "tsc --project tsconfig.build.json",
"type-check": "tsc --noEmit",
"start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
"test": "cross-env TZ=UTC jest",
"test:watch": "cross-env TZ=UTC jest --watch",
"lint": "eslint src --ext .ts,.tsx",
"lint:fix": "eslint --fix src --ext .ts,.tsx"
},
"files": [
"dist"
]
}
14 changes: 14 additions & 0 deletions common/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export * from './types';
14 changes: 14 additions & 0 deletions common/src/types/crud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export type CrudAction = 'create' | 'read' | 'update' | 'delete' | '*';
42 changes: 42 additions & 0 deletions common/src/types/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export interface HTTPProxy {
kind: 'HTTPProxy';
spec: HTTPProxySpec;
}
export interface HTTPProxySpec {
// url is the url of the datasource. It is not the url of the proxy.
// The Perses server is the proxy, so it needs to know where to redirect the request.
url: string;
// allowedEndpoints is a list of tuples of http methods and http endpoints that will be accessible.
// Leave it empty if you don't want to restrict the access to the datasource.
allowedEndpoints?: HTTPAllowedEndpoint[];
// headers can be used to provide additional headers that need to be forwarded when requesting the datasource
headers?: RequestHeaders;
// secret is the name of the secret that should be used for the proxy or discovery configuration
// It will contain any sensitive information such as password, token, certificate.
secret?: string;
}

export interface HTTPAllowedEndpoint {
endpointPattern: string;
method: string;
}

export type RequestHeaders = Record<string, string>;

export interface HTTPDatasourceSpec {
directUrl?: string;
proxy?: HTTPProxy;
}
15 changes: 15 additions & 0 deletions common/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export * from './http';
export * from './crud';
9 changes: 9 additions & 0 deletions common/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"exclude": ["**/*.stories.*", "**/*.test.*"],
"compilerOptions": {
"emitDeclarationOnly": true,
"declaration": true,
"preserveWatchOutput": true
}
}
12 changes: 12 additions & 0 deletions common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"paths": {
"@perses-dev/components": ["./src"]
}
}
}

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"components",
"dashboards",
"plugin-system",
"explore"
"explore",
"common"
],
"devDependencies": {
"@emotion/react": "^11.14.0",
Expand Down
Loading