@vertesia/client 0.69.0 → 0.70.0
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/lib/cjs/AppsApi.js +72 -0
- package/lib/cjs/AppsApi.js.map +1 -0
- package/lib/cjs/ProjectsApi.js +0 -6
- package/lib/cjs/ProjectsApi.js.map +1 -1
- package/lib/cjs/client.js +49 -2
- package/lib/cjs/client.js.map +1 -1
- package/lib/esm/AppsApi.js +69 -0
- package/lib/esm/AppsApi.js.map +1 -0
- package/lib/esm/ProjectsApi.js +0 -6
- package/lib/esm/ProjectsApi.js.map +1 -1
- package/lib/esm/client.js +48 -3
- package/lib/esm/client.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/AppsApi.d.ts +38 -0
- package/lib/types/AppsApi.d.ts.map +1 -0
- package/lib/types/ProjectsApi.d.ts +0 -4
- package/lib/types/ProjectsApi.d.ts.map +1 -1
- package/lib/types/client.d.ts +13 -2
- package/lib/types/client.d.ts.map +1 -1
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +5 -4
- package/src/AppsApi.ts +82 -0
- package/src/ProjectsApi.ts +0 -8
- package/src/client.ts +53 -4
- package/tsconfig.dist.json +20 -0
- package/lib/cjs/PluginsApi.js +0 -27
- package/lib/cjs/PluginsApi.js.map +0 -1
- package/lib/esm/PluginsApi.js +0 -24
- package/lib/esm/PluginsApi.js.map +0 -1
- package/lib/types/PluginsApi.d.ts +0 -12
- package/lib/types/PluginsApi.d.ts.map +0 -1
- package/src/PluginsApi.ts +0 -30
package/src/ProjectsApi.ts
CHANGED
|
@@ -26,14 +26,6 @@ export default class ProjectsApi extends ApiTopic {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
listPlugins(projectId: string): Promise<string[]> {
|
|
30
|
-
return this.get(`/${projectId}/plugins`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
setPlugins(projectId: string, pluginIds: string[]): Promise<{ count: number }> {
|
|
34
|
-
return this.post(`/${projectId}/plugins`, { payload: { plugins: pluginIds } });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
29
|
integrations: IntegrationsConfigurationApi = new IntegrationsConfigurationApi(this);
|
|
38
30
|
|
|
39
31
|
}
|
package/src/client.ts
CHANGED
|
@@ -4,11 +4,11 @@ import AccountApi from "./AccountApi.js";
|
|
|
4
4
|
import AccountsApi from "./AccountsApi.js";
|
|
5
5
|
import AnalyticsApi from "./AnalyticsApi.js";
|
|
6
6
|
import { ApiKeysApi } from "./ApiKeysApi.js";
|
|
7
|
+
import AppsApi from "./AppsApi.js";
|
|
7
8
|
import CommandsApi from "./CommandsApi.js";
|
|
8
9
|
import EnvironmentsApi from "./EnvironmentsApi.js";
|
|
9
10
|
import { IamApi } from "./IamApi.js";
|
|
10
11
|
import InteractionsApi from "./InteractionsApi.js";
|
|
11
|
-
import PluginsApi from "./PluginsApi.js";
|
|
12
12
|
import ProjectsApi from "./ProjectsApi.js";
|
|
13
13
|
import PromptsApi from "./PromptsApi.js";
|
|
14
14
|
import { RefsApi } from "./RefsApi.js";
|
|
@@ -62,6 +62,29 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
|
|
|
62
62
|
*/
|
|
63
63
|
sessionTags?: string | string[];
|
|
64
64
|
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create a client from the given token.
|
|
68
|
+
* If you already have the decoded token you can pass it as the second argument to avoid decodinf it again.
|
|
69
|
+
*
|
|
70
|
+
* @param token the raw JWT token
|
|
71
|
+
* @param payload the decoded JWT token as an AuthTokenPayload - optional
|
|
72
|
+
*/
|
|
73
|
+
static async fromAuthToken(token: string, payload?: AuthTokenPayload) {
|
|
74
|
+
if (!payload) {
|
|
75
|
+
payload = decodeJWT(token);
|
|
76
|
+
}
|
|
77
|
+
const endpoints = decodeEndpoints(payload!.endpoints);
|
|
78
|
+
return await new VertesiaClient({
|
|
79
|
+
serverUrl: endpoints.studio,
|
|
80
|
+
storeUrl: endpoints.store
|
|
81
|
+
}).withApiKey(token);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static decodeEndpoints() {
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
65
88
|
constructor(
|
|
66
89
|
opts: VertesiaClientProps = {
|
|
67
90
|
site: 'api.vertesia.io',
|
|
@@ -218,7 +241,7 @@ export class VertesiaClient extends AbstractFetchClient<VertesiaClient> {
|
|
|
218
241
|
iam = new IamApi(this);
|
|
219
242
|
refs = new RefsApi(this);
|
|
220
243
|
commands = new CommandsApi(this);
|
|
221
|
-
|
|
244
|
+
apps = new AppsApi(this);
|
|
222
245
|
}
|
|
223
246
|
|
|
224
247
|
function isApiKey(apiKey: string) {
|
|
@@ -236,7 +259,7 @@ function isTokenExpired(token: string | null) {
|
|
|
236
259
|
return (currentTime <= exp * 1000 - EXPIRATION_THRESHOLD);
|
|
237
260
|
}
|
|
238
261
|
|
|
239
|
-
function decodeJWT(jwt: string) {
|
|
262
|
+
export function decodeJWT(jwt: string): AuthTokenPayload {
|
|
240
263
|
const payloadBase64 = jwt.split('.')[1];
|
|
241
264
|
const decodedJson = base64UrlDecode(payloadBase64);
|
|
242
265
|
return JSON.parse(decodedJson)
|
|
@@ -260,4 +283,30 @@ function base64UrlDecode(input: string): string {
|
|
|
260
283
|
} else {
|
|
261
284
|
throw new Error('No base64 decoder available');
|
|
262
285
|
}
|
|
263
|
-
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function decodeEndpoints(endpoints: string | Record<string, string> | undefined): Record<string, string> {
|
|
289
|
+
if (!endpoints) {
|
|
290
|
+
return getEndpointsFromDomain("api.vertesia.io")
|
|
291
|
+
}
|
|
292
|
+
if (typeof endpoints === "string") {
|
|
293
|
+
return getEndpointsFromDomain(endpoints);
|
|
294
|
+
} else {
|
|
295
|
+
return endpoints;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function getEndpointsFromDomain(domain: string) {
|
|
300
|
+
if (domain === "local") {
|
|
301
|
+
return {
|
|
302
|
+
studio: `http://localhost:8091`,
|
|
303
|
+
store: `http://localhost:8092`,
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
const url = `https://${domain}`;
|
|
307
|
+
return {
|
|
308
|
+
studio: url,
|
|
309
|
+
store: url,
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"composite": true,
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"jsx": "react-jsx",
|
|
7
|
+
"target": "ES2022",
|
|
8
|
+
"module": "ESNext",
|
|
9
|
+
"moduleResolution": "Bundler",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"outDir": "./lib"
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"exclude": [
|
|
17
|
+
"**/*.test.*",
|
|
18
|
+
"**/*.spec.*"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/lib/cjs/PluginsApi.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const api_fetch_client_1 = require("@vertesia/api-fetch-client");
|
|
4
|
-
class PluginsApi extends api_fetch_client_1.ApiTopic {
|
|
5
|
-
constructor(parent) {
|
|
6
|
-
super(parent, "/api/v1/plugins");
|
|
7
|
-
}
|
|
8
|
-
create(manifest) {
|
|
9
|
-
return this.post('/', { payload: manifest });
|
|
10
|
-
}
|
|
11
|
-
update(manifest) {
|
|
12
|
-
return this.put(`/${manifest.id}`, { payload: manifest });
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @param ids - ids to filter by
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
list(ids) {
|
|
19
|
-
return this.get('/', {
|
|
20
|
-
query: {
|
|
21
|
-
ids: ids ? ids.join(',') : undefined,
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.default = PluginsApi;
|
|
27
|
-
//# sourceMappingURL=PluginsApi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginsApi.js","sourceRoot":"","sources":["../../src/PluginsApi.ts"],"names":[],"mappings":";;AAAA,iEAAkE;AAGlE,MAAqB,UAAW,SAAQ,2BAAQ;IAE5C,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IACpC,CAAC;IAED,MAAM,CAAC,QAAoC;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,QAAwB;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,GAAc;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;YACjB,KAAK,EAAE;gBACH,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;aACvC;SACJ,CAAC,CAAC;IACP,CAAC;CAEJ;AA1BD,6BA0BC"}
|
package/lib/esm/PluginsApi.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ApiTopic } from "@vertesia/api-fetch-client";
|
|
2
|
-
export default class PluginsApi extends ApiTopic {
|
|
3
|
-
constructor(parent) {
|
|
4
|
-
super(parent, "/api/v1/plugins");
|
|
5
|
-
}
|
|
6
|
-
create(manifest) {
|
|
7
|
-
return this.post('/', { payload: manifest });
|
|
8
|
-
}
|
|
9
|
-
update(manifest) {
|
|
10
|
-
return this.put(`/${manifest.id}`, { payload: manifest });
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @param ids - ids to filter by
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
list(ids) {
|
|
17
|
-
return this.get('/', {
|
|
18
|
-
query: {
|
|
19
|
-
ids: ids ? ids.join(',') : undefined,
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=PluginsApi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginsApi.js","sourceRoot":"","sources":["../../src/PluginsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAGlE,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,QAAQ;IAE5C,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IACpC,CAAC;IAED,MAAM,CAAC,QAAoC;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,QAAwB;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,GAAc;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;YACjB,KAAK,EAAE;gBACH,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;aACvC;SACJ,CAAC,CAAC;IACP,CAAC;CAEJ"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
-
import type { PluginManifest } from "@vertesia/common";
|
|
3
|
-
export default class PluginsApi extends ApiTopic {
|
|
4
|
-
constructor(parent: ClientBase);
|
|
5
|
-
create(manifest: Omit<PluginManifest, 'id'>): Promise<PluginManifest>;
|
|
6
|
-
update(manifest: PluginManifest): Promise<any>;
|
|
7
|
-
/**
|
|
8
|
-
* @param ids - ids to filter by
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
list(ids?: string[]): Promise<PluginManifest[]>;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginsApi.d.ts","sourceRoot":"","sources":["../../src/PluginsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,QAAQ;gBAEhC,MAAM,EAAE,UAAU;IAI9B,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAIrE,MAAM,CAAC,QAAQ,EAAE,cAAc;IAI/B;;;OAGG;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAQlD"}
|
package/src/PluginsApi.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
-
import type { PluginManifest } from "@vertesia/common";
|
|
3
|
-
|
|
4
|
-
export default class PluginsApi extends ApiTopic {
|
|
5
|
-
|
|
6
|
-
constructor(parent: ClientBase) {
|
|
7
|
-
super(parent, "/api/v1/plugins")
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
create(manifest: Omit<PluginManifest, 'id'>): Promise<PluginManifest> {
|
|
11
|
-
return this.post('/', { payload: manifest });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
update(manifest: PluginManifest) {
|
|
15
|
-
return this.put(`/${manifest.id}`, { payload: manifest });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param ids - ids to filter by
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
list(ids?: string[]): Promise<PluginManifest[]> {
|
|
23
|
-
return this.get('/', {
|
|
24
|
-
query: {
|
|
25
|
-
ids: ids ? ids.join(',') : undefined,
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|