Skip to content

Commit 5a76e80

Browse files
committed
[FEATURE] init perses common package
Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com>
1 parent a4de6a6 commit 5a76e80

10 files changed

Lines changed: 158 additions & 1 deletion

File tree

common/.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright The Perses Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
module.exports = require('../.eslintrc.base.js');

common/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Perses Common Package
2+
3+
this [package] This [package](https://www.npmjs.com/package/@perses-dev/common) includes basic types and utilities which are common among other packages.

common/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@perses-dev/common",
3+
"version": "0.54.0-beta.0",
4+
"description": "Common types and utilities of Perses",
5+
"license": "Apache-2.0",
6+
"homepage": "https://github.com/perses/perses/blob/main/README.md",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/perses/perses.git"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/perses/perses/issues"
13+
},
14+
"module": "dist/index.js",
15+
"main": "dist/cjs/index.js",
16+
"types": "dist/index.d.ts",
17+
"scripts": {
18+
"clean": "rimraf dist/",
19+
"build": "concurrently \"npm:build:*\"",
20+
"build:cjs": "swc ./src -d dist/cjs --strip-leading-paths --config-file ../.cjs.swcrc",
21+
"build:esm": "swc ./src -d dist --strip-leading-paths --config-file ../.swcrc",
22+
"build:types": "tsc --project tsconfig.build.json",
23+
"type-check": "tsc --noEmit",
24+
"start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
25+
"test": "cross-env TZ=UTC jest",
26+
"test:watch": "cross-env TZ=UTC jest --watch",
27+
"lint": "eslint src --ext .ts,.tsx",
28+
"lint:fix": "eslint --fix src --ext .ts,.tsx"
29+
},
30+
"files": [
31+
"dist"
32+
]
33+
}

common/src/index.ts

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

common/src/types/crud.ts

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

common/src/types/http.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright The Perses Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
export interface HTTPProxy {
15+
kind: 'HTTPProxy';
16+
spec: HTTPProxySpec;
17+
}
18+
export interface HTTPProxySpec {
19+
// url is the url of the datasource. It is not the url of the proxy.
20+
// The Perses server is the proxy, so it needs to know where to redirect the request.
21+
url: string;
22+
// allowedEndpoints is a list of tuples of http methods and http endpoints that will be accessible.
23+
// Leave it empty if you don't want to restrict the access to the datasource.
24+
allowedEndpoints?: HTTPAllowedEndpoint[];
25+
// headers can be used to provide additional headers that need to be forwarded when requesting the datasource
26+
headers?: RequestHeaders;
27+
// secret is the name of the secret that should be used for the proxy or discovery configuration
28+
// It will contain any sensitive information such as password, token, certificate.
29+
secret?: string;
30+
}
31+
32+
export interface HTTPAllowedEndpoint {
33+
endpointPattern: string;
34+
method: string;
35+
}
36+
37+
export type RequestHeaders = Record<string, string>;
38+
39+
export interface HTTPDatasourceSpec {
40+
directUrl?: string;
41+
proxy?: HTTPProxy;
42+
}

common/src/types/index.ts

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

common/tsconfig.build.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["**/*.stories.*", "**/*.test.*"],
4+
"compilerOptions": {
5+
"emitDeclarationOnly": true,
6+
"declaration": true,
7+
"preserveWatchOutput": true
8+
}
9+
}

common/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"include": ["src"],
4+
"compilerOptions": {
5+
"outDir": "./dist",
6+
"rootDir": "./src",
7+
"paths": {
8+
"@perses-dev/components": ["./src"]
9+
}
10+
}
11+
}
12+

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"components",
1919
"dashboards",
2020
"plugin-system",
21-
"explore"
21+
"explore",
22+
"common"
2223
],
2324
"devDependencies": {
2425
"@emotion/react": "^11.14.0",

0 commit comments

Comments
 (0)