@qelos/sdk 3.11.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +80 -0
- package/README.md +42 -0
- package/dist/administrator/events.d.ts +7 -1
- package/dist/administrator/events.js +18 -2
- package/dist/administrator/events.js.map +1 -1
- package/dist/base-sdk.js +7 -1
- package/dist/base-sdk.js.map +1 -1
- package/dist/blueprints.d.ts +5 -0
- package/dist/blueprints.js +12 -0
- package/dist/blueprints.js.map +1 -1
- package/package.json +79 -1
- package/src/administrator/events.ts +12 -2
- package/src/base-sdk.ts +11 -4
- package/src/blueprints.ts +15 -0
- package/test/imports.test.ts +29 -0
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# SDK Import Migration Guide
|
|
2
|
+
|
|
3
|
+
The `@qelos/sdk` package now supports cleaner imports while maintaining backward compatibility.
|
|
4
|
+
|
|
5
|
+
## New Clean Imports (Recommended)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// Main SDK
|
|
9
|
+
import QelosSDK from '@qelos/sdk';
|
|
10
|
+
|
|
11
|
+
// Administrator SDK
|
|
12
|
+
import QelosAdministratorSDK from '@qelos/sdk/administrator';
|
|
13
|
+
|
|
14
|
+
// Types
|
|
15
|
+
import { QelosSDKOptions } from '@qelos/sdk/types';
|
|
16
|
+
import { IWorkspace } from '@qelos/sdk/workspaces';
|
|
17
|
+
import { IAppConfiguration } from '@qelos/sdk/configurations';
|
|
18
|
+
|
|
19
|
+
// Administrator submodules
|
|
20
|
+
import { ILayout, LayoutKind } from '@qelos/sdk/administrator/layouts';
|
|
21
|
+
import { ICustomConfiguration } from '@qelos/sdk/administrator/manage-configurations';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Old Imports (Still Supported for Backward Compatibility)
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// These still work but are not recommended
|
|
28
|
+
import QelosAdministratorSDK from '@qelos/sdk/dist/administrator';
|
|
29
|
+
import QelosAdministratorSDK from '@qelos/sdk/src/administrator';
|
|
30
|
+
import { IWorkspace } from '@qelos/sdk/dist/workspaces';
|
|
31
|
+
import { QelosSDKOptions } from '@qelos/sdk/dist/types';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Migration Examples
|
|
35
|
+
|
|
36
|
+
### Before
|
|
37
|
+
```typescript
|
|
38
|
+
import QelosAdministratorSDK from '@qelos/sdk/dist/administrator';
|
|
39
|
+
import { IWorkspace } from '@qelos/sdk/dist/workspaces';
|
|
40
|
+
import { QelosSDKOptions } from '@qelos/sdk/dist/types';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### After
|
|
44
|
+
```typescript
|
|
45
|
+
import QelosAdministratorSDK from '@qelos/sdk/administrator';
|
|
46
|
+
import { IWorkspace } from '@qelos/sdk/workspaces';
|
|
47
|
+
import { QelosSDKOptions } from '@qelos/sdk/types';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Available Exports
|
|
51
|
+
|
|
52
|
+
- `@qelos/sdk` - Main SDK class
|
|
53
|
+
- `@qelos/sdk/administrator` - Administrator SDK
|
|
54
|
+
- `@qelos/sdk/administrator/*` - All administrator submodules (layouts, manage-configurations, etc.)
|
|
55
|
+
- `@qelos/sdk/workspaces` - Workspaces module and types
|
|
56
|
+
- `@qelos/sdk/configurations` - Configurations module and types
|
|
57
|
+
- `@qelos/sdk/types` - SDK types
|
|
58
|
+
- `@qelos/sdk/src/*` - Direct source imports (backward compatibility)
|
|
59
|
+
- `@qelos/sdk/dist/*` - Direct dist imports (backward compatibility)
|
|
60
|
+
|
|
61
|
+
## TypeScript Configuration Requirements
|
|
62
|
+
|
|
63
|
+
To use the clean import paths (without `/dist` or `/src`), your TypeScript configuration must use one of the modern module resolution strategies:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"compilerOptions": {
|
|
68
|
+
"moduleResolution": "node16" // or "nodenext" or "bundler"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If your project uses `"moduleResolution": "node"` (the legacy default), you should continue using the backward-compatible paths (`@qelos/sdk/dist/*`) until you can upgrade your TypeScript configuration.
|
|
74
|
+
|
|
75
|
+
## Benefits
|
|
76
|
+
|
|
77
|
+
1. **Cleaner imports** - No need to specify `/dist` or `/src`
|
|
78
|
+
2. **Better IDE support** - Proper TypeScript resolution
|
|
79
|
+
3. **Backward compatible** - Old imports continue to work
|
|
80
|
+
4. **Future-proof** - Standard package exports pattern
|
package/README.md
CHANGED
|
@@ -12,6 +12,8 @@ npm install @qelos/sdk
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
+
### Main SDK
|
|
16
|
+
|
|
15
17
|
```typescript
|
|
16
18
|
// my-sdk.ts
|
|
17
19
|
import QelosSDK from '@qelos/sdk';
|
|
@@ -19,8 +21,48 @@ import QelosSDK from '@qelos/sdk';
|
|
|
19
21
|
const sdk = new QelosSDK({appUrl: 'https://yourdomain.com', fetch: window.fetch});
|
|
20
22
|
export default sdk;
|
|
21
23
|
```
|
|
24
|
+
|
|
25
|
+
### Administrator SDK
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import QelosAdministratorSDK from '@qelos/sdk/administrator';
|
|
29
|
+
|
|
30
|
+
const adminSdk = new QelosAdministratorSDK({
|
|
31
|
+
appUrl: 'https://yourdomain.com',
|
|
32
|
+
fetch: window.fetch
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Importing Types
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { QelosSDKOptions } from '@qelos/sdk/types';
|
|
40
|
+
import { IWorkspace } from '@qelos/sdk/workspaces';
|
|
41
|
+
import { IAppConfiguration } from '@qelos/sdk/configurations';
|
|
42
|
+
import { ILayout, LayoutKind } from '@qelos/sdk/administrator/layouts';
|
|
43
|
+
```
|
|
44
|
+
|
|
22
45
|
**Note:** You can inject a fetch-like function, such as `node-fetch` or any fetch equivalent.
|
|
23
46
|
|
|
47
|
+
### Available Exports
|
|
48
|
+
|
|
49
|
+
- `@qelos/sdk` - Main SDK class
|
|
50
|
+
- `@qelos/sdk/administrator` - Administrator SDK
|
|
51
|
+
- `@qelos/sdk/administrator/*` - Administrator submodules (layouts, manage-configurations, etc.)
|
|
52
|
+
- `@qelos/sdk/workspaces` - Workspaces module and types
|
|
53
|
+
- `@qelos/sdk/configurations` - Configurations module and types
|
|
54
|
+
- `@qelos/sdk/types` - SDK types
|
|
55
|
+
|
|
56
|
+
### Backward Compatibility
|
|
57
|
+
|
|
58
|
+
For backward compatibility, the following imports still work:
|
|
59
|
+
- `@qelos/sdk/dist/*` - Direct dist imports
|
|
60
|
+
- `@qelos/sdk/src/*` - Direct source imports
|
|
61
|
+
|
|
62
|
+
However, it's recommended to use the clean import paths listed above.
|
|
63
|
+
|
|
64
|
+
**Note:** Clean import paths require TypeScript's `moduleResolution` to be set to `"node16"`, `"nodenext"`, or `"bundler"`. If you're using the legacy `"node"` module resolution, continue using the `/dist` paths.
|
|
65
|
+
|
|
24
66
|
### Basic usage of SDK instance:
|
|
25
67
|
```typescript jsx
|
|
26
68
|
// MyPostsList.tsx
|
|
@@ -13,8 +13,14 @@ export interface IQelosEvent {
|
|
|
13
13
|
export default class QlEvents extends BaseSDK {
|
|
14
14
|
private relativePath;
|
|
15
15
|
constructor(options: QelosSDKOptions);
|
|
16
|
-
getList(
|
|
16
|
+
getList(params?: {
|
|
17
17
|
page?: number;
|
|
18
|
+
kind?: string;
|
|
19
|
+
eventName?: string;
|
|
20
|
+
source?: string;
|
|
21
|
+
user?: string;
|
|
22
|
+
workspace?: string;
|
|
23
|
+
period?: string;
|
|
18
24
|
}): Promise<IQelosEvent[]>;
|
|
19
25
|
getEvent(eventId: string): Promise<IQelosEvent>;
|
|
20
26
|
dispatch(payload: Partial<IQelosEvent>): Promise<void>;
|
|
@@ -4,8 +4,24 @@ export default class QlEvents extends BaseSDK {
|
|
|
4
4
|
constructor(options) {
|
|
5
5
|
super(options);
|
|
6
6
|
}
|
|
7
|
-
getList(
|
|
8
|
-
|
|
7
|
+
getList(params) {
|
|
8
|
+
const queryParams = new URLSearchParams();
|
|
9
|
+
if (params?.page !== undefined)
|
|
10
|
+
queryParams.append('page', params.page.toString());
|
|
11
|
+
if (params?.kind)
|
|
12
|
+
queryParams.append('kind', params.kind);
|
|
13
|
+
if (params?.eventName)
|
|
14
|
+
queryParams.append('eventName', params.eventName);
|
|
15
|
+
if (params?.source)
|
|
16
|
+
queryParams.append('source', params.source);
|
|
17
|
+
if (params?.user)
|
|
18
|
+
queryParams.append('user', params.user);
|
|
19
|
+
if (params?.workspace)
|
|
20
|
+
queryParams.append('workspace', params.workspace);
|
|
21
|
+
if (params?.period)
|
|
22
|
+
queryParams.append('period', params.period);
|
|
23
|
+
const queryString = queryParams.toString();
|
|
24
|
+
return this.callJsonApi(this.relativePath + (queryString ? '?' + queryString : ''));
|
|
9
25
|
}
|
|
10
26
|
getEvent(eventId) {
|
|
11
27
|
return this.callJsonApi(this.relativePath + '/' + eventId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/administrator/events.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,aAAa,CAAC;AAalC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IACnC,YAAY,GAAG,aAAa,CAAC;IAErC,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/administrator/events.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,aAAa,CAAC;AAalC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IACnC,YAAY,GAAG,aAAa,CAAC;IAErC,YAAY,OAAwB;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CAAC,QAAQ,CAAC,OAA6B;QAC1C,MAAM,IAAI,CAAC,OAAO,CAChB,IAAI,CAAC,YAAY,EACjB;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAC,cAAc,EAAE,kBAAkB,EAAC;YAC7C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CACF,CAAA;IACH,CAAC;CACF"}
|
package/dist/base-sdk.js
CHANGED
|
@@ -51,7 +51,13 @@ export default class BaseSDK {
|
|
|
51
51
|
const isJson = contentType.includes('json');
|
|
52
52
|
const body = await (isJson ? res.json() : res.text());
|
|
53
53
|
if (!res.ok) {
|
|
54
|
-
|
|
54
|
+
if (typeof body === 'string') {
|
|
55
|
+
throw new Error(body);
|
|
56
|
+
}
|
|
57
|
+
const message = body?.message || body?.error?.message || body?.error_description || body?.error || 'Request failed';
|
|
58
|
+
const error = new Error(message);
|
|
59
|
+
error.details = body;
|
|
60
|
+
throw error;
|
|
55
61
|
}
|
|
56
62
|
return body;
|
|
57
63
|
}
|
package/dist/base-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-sdk.js","sourceRoot":"","sources":["../src/base-sdk.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG;IACb,aAAa,EAAE,6BAA6B;IAC5C,oBAAoB,EAAE,uCAAuC;IAC7D,uBAAuB,EAAE,iCAAiC;CAC3D,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,OAAO;IAIN;IAHpB,OAAO,CAAS;IAChB,MAAM,CAAY;IAElB,YAAoB,SAA0B;QAA1B,cAAS,GAAT,SAAS,CAAiB;QAC5C,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;Q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,IAAI,CAAC,wBAAwB,EAAE,CAAC;iBACvC;gBAED,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;aAC7C;YAED,OAAO,IAAI,CAAC,aAAa,CAAI,GAAG,CAAC,CAAC;SACnC;QAAC,OAAO,GAAY,EAAE;YACrB,+BAA+B;YAC/B,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,KAAK,MAAM,CAAC,aAAa,EAAE;gBAChE,+CAA+C;gBAC/C,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAEtC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAClD,OAAO,IAAI,CAAC,aAAa,CAAI,GAAG,CAAC,CAAC;aACnC;YAED,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAED,cAAc,CAAC,SAA+B;QAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACxH,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,CAAC;CACF"}
|
package/dist/blueprints.d.ts
CHANGED
|
@@ -10,4 +10,9 @@ export default class QlBlueprints extends BaseSDK {
|
|
|
10
10
|
getBlueprint(key: string): Promise<IBlueprint>;
|
|
11
11
|
getList(): Promise<IBlueprint[]>;
|
|
12
12
|
entitiesOf<T = any>(blueprintKey: string): QlBlueprintEntities<T>;
|
|
13
|
+
getChart(blueprintKey: string, chartType: string, query?: Record<string, any>): Promise<Record<string, any>>;
|
|
14
|
+
getPieChart(blueprintKey: string, query?: Record<string, any>): Promise<Record<string, any>>;
|
|
15
|
+
getCount(blueprintKey: string, query?: Record<string, any>): Promise<{
|
|
16
|
+
count: number;
|
|
17
|
+
}>;
|
|
13
18
|
}
|
package/dist/blueprints.js
CHANGED
|
@@ -20,5 +20,17 @@ export default class QlBlueprints extends BaseSDK {
|
|
|
20
20
|
}
|
|
21
21
|
return this.#entities.get(blueprintKey);
|
|
22
22
|
}
|
|
23
|
+
getChart(blueprintKey, chartType, query) {
|
|
24
|
+
const qs = this.getQueryParams(query);
|
|
25
|
+
return this.callJsonApi(`${this.relativePath}/${blueprintKey}/charts/${chartType}${qs}`);
|
|
26
|
+
}
|
|
27
|
+
getPieChart(blueprintKey, query) {
|
|
28
|
+
const qs = this.getQueryParams(query);
|
|
29
|
+
return this.callJsonApi(`${this.relativePath}/${blueprintKey}/charts/pie${qs}`);
|
|
30
|
+
}
|
|
31
|
+
getCount(blueprintKey, query) {
|
|
32
|
+
const qs = this.getQueryParams(query);
|
|
33
|
+
return this.callJsonApi(`${this.relativePath}/${blueprintKey}/charts/count${qs}`);
|
|
34
|
+
}
|
|
23
35
|
}
|
|
24
36
|
//# sourceMappingURL=blueprints.js.map
|
package/dist/blueprints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../src/blueprints.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAK3B;IAJZ,YAAY,GAAG,iBAAiB,CAAC;IAEzC,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEnD,YAAoB,OAAwB;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QADI,YAAO,GAAP,OAAO,CAAiB;IAE5C,CAAC;IAED,YAAY,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,WAAW,CAAa,GAAG,IAAI,CAAC,YA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,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;SAC1F;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,QAAQ,CAAC,YAAoB,EAAE,SAAiB,EAAE,KAA2B;QAC3E,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,WAAW,CAAsB,GAAG,IAAI,CAAC,YAAY,IAAI,YAAY,WAAW,SAAS,GAAG,EAAE,EAAE,CAAC,CAAC;IAChH,CAAC;IAED,WAAW,CAAC,YAAoB,EAAE,KAA2B;QAC3D,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,WAAW,CAAsB,GAAG,IAAI,CAAC,YAAY,IAAI,YAAY,cAAc,EAAE,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,QAAQ,CAAC,YAAoB,EAAE,KAA2B;QACxD,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,WAAW,CAAoB,GAAG,IAAI,CAAC,YAAY,IAAI,YAAY,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACvG,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,86 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qelos/sdk",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "SDK for Qelos API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"typesVersions": {
|
|
8
|
+
"*": {
|
|
9
|
+
"administrator": [
|
|
10
|
+
"./dist/administrator/index.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"administrator/*": [
|
|
13
|
+
"./dist/administrator/*.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"workspaces": [
|
|
16
|
+
"./dist/workspaces.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"configurations": [
|
|
19
|
+
"./dist/configurations.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"types": [
|
|
22
|
+
"./dist/types.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"*": [
|
|
25
|
+
"./dist/*.d.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"require": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./administrator": {
|
|
37
|
+
"types": "./dist/administrator/index.d.ts",
|
|
38
|
+
"import": "./dist/administrator/index.js",
|
|
39
|
+
"require": "./dist/administrator/index.js",
|
|
40
|
+
"default": "./dist/administrator/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./administrator/*": {
|
|
43
|
+
"types": "./dist/administrator/*.d.ts",
|
|
44
|
+
"import": "./dist/administrator/*.js",
|
|
45
|
+
"require": "./dist/administrator/*.js",
|
|
46
|
+
"default": "./dist/administrator/*.js"
|
|
47
|
+
},
|
|
48
|
+
"./workspaces": {
|
|
49
|
+
"types": "./dist/workspaces.d.ts",
|
|
50
|
+
"import": "./dist/workspaces.js",
|
|
51
|
+
"require": "./dist/workspaces.js",
|
|
52
|
+
"default": "./dist/workspaces.js"
|
|
53
|
+
},
|
|
54
|
+
"./configurations": {
|
|
55
|
+
"types": "./dist/configurations.d.ts",
|
|
56
|
+
"import": "./dist/configurations.js",
|
|
57
|
+
"require": "./dist/configurations.js",
|
|
58
|
+
"default": "./dist/configurations.js"
|
|
59
|
+
},
|
|
60
|
+
"./types": {
|
|
61
|
+
"types": "./dist/types.d.ts",
|
|
62
|
+
"import": "./dist/types.js",
|
|
63
|
+
"require": "./dist/types.js",
|
|
64
|
+
"default": "./dist/types.js"
|
|
65
|
+
},
|
|
66
|
+
"./src": {
|
|
67
|
+
"types": "./src/index.ts",
|
|
68
|
+
"default": "./src/index.ts"
|
|
69
|
+
},
|
|
70
|
+
"./src/*": {
|
|
71
|
+
"types": "./src/*.ts",
|
|
72
|
+
"default": "./src/*.ts"
|
|
73
|
+
},
|
|
74
|
+
"./dist": {
|
|
75
|
+
"types": "./dist/index.d.ts",
|
|
76
|
+
"default": "./dist/index.js"
|
|
77
|
+
},
|
|
78
|
+
"./dist/*": {
|
|
79
|
+
"types": "./dist/*.d.ts",
|
|
80
|
+
"default": "./dist/*.js"
|
|
81
|
+
},
|
|
82
|
+
"./package.json": "./package.json"
|
|
83
|
+
},
|
|
6
84
|
"author": "David Meir-Levy <davidmeirlevy@gmail.com>",
|
|
7
85
|
"license": "MIT",
|
|
8
86
|
"publishConfig": {
|
|
@@ -19,8 +19,18 @@ export default class QlEvents extends BaseSDK {
|
|
|
19
19
|
super(options)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
getList(
|
|
23
|
-
|
|
22
|
+
getList(params?: { page?: number; kind?: string; eventName?: string; source?: string; user?: string; workspace?: string; period?: string }) {
|
|
23
|
+
const queryParams = new URLSearchParams();
|
|
24
|
+
if (params?.page !== undefined) queryParams.append('page', params.page.toString());
|
|
25
|
+
if (params?.kind) queryParams.append('kind', params.kind);
|
|
26
|
+
if (params?.eventName) queryParams.append('eventName', params.eventName);
|
|
27
|
+
if (params?.source) queryParams.append('source', params.source);
|
|
28
|
+
if (params?.user) queryParams.append('user', params.user);
|
|
29
|
+
if (params?.workspace) queryParams.append('workspace', params.workspace);
|
|
30
|
+
if (params?.period) queryParams.append('period', params.period);
|
|
31
|
+
|
|
32
|
+
const queryString = queryParams.toString();
|
|
33
|
+
return this.callJsonApi<IQelosEvent[]>(this.relativePath + (queryString ? '?' + queryString : ''));
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
getEvent(eventId: string) {
|
package/src/base-sdk.ts
CHANGED
|
@@ -54,13 +54,20 @@ export default class BaseSDK {
|
|
|
54
54
|
private async parseResponse<T>(res: Response): Promise<T> {
|
|
55
55
|
const contentType = this.getContentType(res);
|
|
56
56
|
const isJson = contentType.includes('json');
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
const body = await (isJson ? res.json() : res.text());
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
if (!res.ok) {
|
|
61
|
-
|
|
61
|
+
if (typeof body === 'string') {
|
|
62
|
+
throw new Error(body);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const message = body?.message || body?.error?.message || body?.error_description || body?.error || 'Request failed';
|
|
66
|
+
const error = new Error(message);
|
|
67
|
+
(error as Error & { details?: unknown }).details = body;
|
|
68
|
+
throw error;
|
|
62
69
|
}
|
|
63
|
-
|
|
70
|
+
|
|
64
71
|
return body;
|
|
65
72
|
}
|
|
66
73
|
|
package/src/blueprints.ts
CHANGED
|
@@ -26,4 +26,19 @@ export default class QlBlueprints extends BaseSDK {
|
|
|
26
26
|
}
|
|
27
27
|
return this.#entities.get(blueprintKey);
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
getChart(blueprintKey: string, chartType: string, query?: Record<string, any>) {
|
|
31
|
+
const qs = this.getQueryParams(query);
|
|
32
|
+
return this.callJsonApi<Record<string, any>>(`${this.relativePath}/${blueprintKey}/charts/${chartType}${qs}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getPieChart(blueprintKey: string, query?: Record<string, any>) {
|
|
36
|
+
const qs = this.getQueryParams(query);
|
|
37
|
+
return this.callJsonApi<Record<string, any>>(`${this.relativePath}/${blueprintKey}/charts/pie${qs}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getCount(blueprintKey: string, query?: Record<string, any>) {
|
|
41
|
+
const qs = this.getQueryParams(query);
|
|
42
|
+
return this.callJsonApi<{ count: number }>(`${this.relativePath}/${blueprintKey}/charts/count${qs}`);
|
|
43
|
+
}
|
|
29
44
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { test, describe } from 'node:test';
|
|
2
|
+
import * as assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
describe('SDK Import Paths', () => {
|
|
5
|
+
test('should import main SDK without /dist or /src', async () => {
|
|
6
|
+
const QelosSDK = (await import('../dist/index.js')).default;
|
|
7
|
+
assert.ok(QelosSDK, 'Main SDK should be importable');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('should import administrator SDK without /dist or /src', async () => {
|
|
11
|
+
const QelosAdministratorSDK = (await import('../dist/administrator/index.js')).default;
|
|
12
|
+
assert.ok(QelosAdministratorSDK, 'Administrator SDK should be importable');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('should import types without /dist or /src', async () => {
|
|
16
|
+
const types = await import('../dist/types.js');
|
|
17
|
+
assert.ok(types, 'Types should be importable');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('should import workspaces without /dist or /src', async () => {
|
|
21
|
+
const workspaces = await import('../dist/workspaces.js');
|
|
22
|
+
assert.ok(workspaces, 'Workspaces should be importable');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('should import configurations without /dist or /src', async () => {
|
|
26
|
+
const configurations = await import('../dist/configurations.js');
|
|
27
|
+
assert.ok(configurations, 'Configurations should be importable');
|
|
28
|
+
});
|
|
29
|
+
});
|