@prisme.ai/sdk 1.0.1 → 1.0.2
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/dist/_virtual/_tslib.js +17 -8
- package/dist/lib/ImportProcessing.d.ts +19 -0
- package/dist/lib/WorkspacesEndpoint.d.ts +10 -0
- package/dist/lib/api.d.ts +18 -3
- package/dist/lib/endpoints/users.d.ts +6 -2
- package/dist/lib/endpoints/workspaces.d.ts +16 -0
- package/dist/lib/endpoints/workspacesVersions.d.ts +2 -2
- package/dist/lib/events.d.ts +3 -1
- package/dist/lib/fetch.d.ts +2 -0
- package/dist/lib/fetcher.d.ts +2 -1
- package/dist/lib/interpolate.d.ts +2 -0
- package/dist/lib/interpolate.test.d.ts +1 -0
- package/dist/lib/interpolateVars.d.ts +2 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/sdk/lib/ImportProcessing.js +17 -0
- package/dist/sdk/lib/WorkspacesEndpoint.js +19 -0
- package/dist/sdk/lib/api.js +86 -24
- package/dist/sdk/lib/endpoints/users.js +57 -6
- package/dist/sdk/lib/endpoints/workspaces.js +121 -0
- package/dist/sdk/lib/endpoints/workspacesVersions.js +4 -4
- package/dist/sdk/lib/events.js +40 -13
- package/dist/sdk/lib/fetch.js +12 -0
- package/dist/sdk/lib/fetcher.js +74 -36
- package/dist/sdk/lib/interpolate.js +26 -0
- package/dist/sdk/lib/interpolateVars.js +26 -0
- package/dist/sdk/lib/utils.js +48 -1
- package/lib/ImportProcessing.ts +22 -0
- package/lib/api.test.ts +20 -5
- package/lib/api.ts +111 -33
- package/lib/endpoints/users.ts +40 -4
- package/lib/endpoints/workspaces.ts +103 -0
- package/lib/endpoints/workspacesVersions.ts +13 -9
- package/lib/events.ts +54 -12
- package/lib/fetcher.ts +42 -7
- package/lib/utils.ts +39 -0
- package/package.json +2 -1
package/dist/_virtual/_tslib.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
7
7
|
|
|
8
8
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -16,7 +16,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
16
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
18
18
|
***************************************************************************** */
|
|
19
|
-
/* global Reflect, Promise */
|
|
19
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
20
20
|
|
|
21
21
|
var extendStatics = function(d, b) {
|
|
22
22
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -72,7 +72,7 @@ function __generator(thisArg, body) {
|
|
|
72
72
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
73
73
|
function step(op) {
|
|
74
74
|
if (f) throw new TypeError("Generator is already executing.");
|
|
75
|
-
while (_) try {
|
|
75
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
76
76
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
77
77
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
78
78
|
switch (op[0]) {
|
|
@@ -94,11 +94,20 @@ function __generator(thisArg, body) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
function __spreadArray(to, from) {
|
|
98
|
-
for (var i = 0,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
function __spreadArray(to, from, pack) {
|
|
98
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
99
|
+
if (ar || !(i in from)) {
|
|
100
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
101
|
+
ar[i] = from[i];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
108
|
+
var e = new Error(message);
|
|
109
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
110
|
+
};
|
|
102
111
|
|
|
103
112
|
exports.__awaiter = __awaiter;
|
|
104
113
|
exports.__extends = __extends;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ImportProcessing = {
|
|
2
|
+
processing?: boolean;
|
|
3
|
+
message?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare class ImportProcessingError extends Error {
|
|
6
|
+
error: ImportProcessing;
|
|
7
|
+
constructor(error: ImportProcessing);
|
|
8
|
+
}
|
|
9
|
+
export type ImportSuccess = {
|
|
10
|
+
createdWorkspaceIds?: string[];
|
|
11
|
+
updatedWorkspaceIds?: string[];
|
|
12
|
+
imported: string[];
|
|
13
|
+
errors?: {
|
|
14
|
+
[name: string]: any;
|
|
15
|
+
}[];
|
|
16
|
+
workspace?: Prismeai.DSULReadOnly;
|
|
17
|
+
publishedApps?: Prismeai.App[];
|
|
18
|
+
deleted?: string[];
|
|
19
|
+
};
|
package/dist/lib/api.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Event, Workspace } from './types';
|
|
|
3
3
|
import { Events } from './events';
|
|
4
4
|
import WorkspacesEndpoint from './endpoints/workspaces';
|
|
5
5
|
import UsersEndpoint from './endpoints/users';
|
|
6
|
+
import { ImportSuccess } from './ImportProcessing';
|
|
6
7
|
export type UserPermissions = {
|
|
7
8
|
permissions: Prismeai.UserPermissions['permissions'];
|
|
8
9
|
target: {
|
|
@@ -21,6 +22,9 @@ export interface ApiOptions {
|
|
|
21
22
|
clientIdHeader?: string;
|
|
22
23
|
redirectUri: string;
|
|
23
24
|
};
|
|
25
|
+
websockets?: {
|
|
26
|
+
transports?: string[];
|
|
27
|
+
};
|
|
24
28
|
}
|
|
25
29
|
export interface AccessToken {
|
|
26
30
|
access_token: string;
|
|
@@ -73,7 +77,10 @@ export declare class Api extends Fetcher {
|
|
|
73
77
|
getWorkspaceSecurity(id: string): Promise<PrismeaiAPI.GetSecurity.Responses.$200>;
|
|
74
78
|
updateWorkspaceSecurity(workspaceId: string, security: Prismeai.WorkspaceSecurity): Promise<Fetched<PrismeaiAPI.UpdateSecurity.Responses.$200>>;
|
|
75
79
|
getWorkspaceRoles(id: string): Promise<Fetched<PrismeaiAPI.GetRoles.Responses.$200>>;
|
|
76
|
-
|
|
80
|
+
getWorkspaceSecrets(id: string): Promise<Fetched<PrismeaiAPI.GetWorkspaceSecrets.Responses.$200>>;
|
|
81
|
+
updateWorkspaceSecrets(id: string, newSecrets: any): Promise<Workspace>;
|
|
82
|
+
deleteWorkspaceSecrets(id: string, secretName: string): Promise<Workspace>;
|
|
83
|
+
createWorkspace(newWorkspace: Partial<Prismeai.Workspace>): Promise<Workspace>;
|
|
77
84
|
duplicateWorkspace({ id }: {
|
|
78
85
|
id: string;
|
|
79
86
|
}): Promise<Workspace | null>;
|
|
@@ -110,6 +117,9 @@ export declare class Api extends Fetcher {
|
|
|
110
117
|
limit?: PrismeaiAPI.SearchApps.QueryParameters['limit'];
|
|
111
118
|
workspaceId?: PrismeaiAPI.SearchApps.QueryParameters['workspaceId'];
|
|
112
119
|
}): Promise<Fetched<PrismeaiAPI.SearchApps.Responses.$200>>;
|
|
120
|
+
getApp({ slug, }: {
|
|
121
|
+
slug?: PrismeaiAPI.GetApp.PathParameters['appSlug'];
|
|
122
|
+
}): Promise<Fetched<PrismeaiAPI.GetApp.Responses.$200>>;
|
|
113
123
|
installApp(workspaceId: PrismeaiAPI.InstallAppInstance.PathParameters['workspaceId'], body: PrismeaiAPI.InstallAppInstance.RequestBody): Promise<Fetched<PrismeaiAPI.InstallAppInstance.Responses.$200>>;
|
|
114
124
|
updateApp(workspaceId: PrismeaiAPI.ConfigureAppInstance.PathParameters['workspaceId'], slug: PrismeaiAPI.ConfigureAppInstance.PathParameters['slug'], body: PrismeaiAPI.ConfigureAppInstance.RequestBody): Promise<Fetched<PrismeaiAPI.ConfigureAppInstance.Responses.$200>>;
|
|
115
125
|
uninstallApp(workspaceId: PrismeaiAPI.UninstallAppInstance.PathParameters['workspaceId'], slug: PrismeaiAPI.ConfigureAppInstance.PathParameters['slug']): Promise<Fetched<PrismeaiAPI.UninstallAppInstance.Responses.$200>>;
|
|
@@ -119,8 +129,13 @@ export declare class Api extends Fetcher {
|
|
|
119
129
|
updateAppConfig(workspaceId: PrismeaiAPI.UpdateAppInstanceConfig.Parameters.WorkspaceId, slug: PrismeaiAPI.UpdateAppInstanceConfig.Parameters.Slug, config: any): Promise<PrismeaiAPI.UpdateAppInstanceConfig.Responses.$200['config']>;
|
|
120
130
|
getAppInstance(workspaceId: string, slug: string): Promise<Fetched<PrismeaiAPI.GetAppInstance.Responses.$200>>;
|
|
121
131
|
saveAppInstance(workspaceId: PrismeaiAPI.ConfigureAppInstance.Parameters.WorkspaceId, slug: PrismeaiAPI.ConfigureAppInstance.Parameters.Slug, appInstance: PrismeaiAPI.ConfigureAppInstance.RequestBody): Promise<Fetched<PrismeaiAPI.ConfigureAppInstance.Responses.$200>>;
|
|
122
|
-
uploadFiles(files: string | string[], workspaceId: string
|
|
132
|
+
uploadFiles(files: string | string[], workspaceId: string, opts?: {
|
|
133
|
+
expiresAfter?: number;
|
|
134
|
+
public?: boolean;
|
|
135
|
+
shareToken?: boolean;
|
|
136
|
+
}): Promise<PrismeaiAPI.UploadFile.Responses.$200>;
|
|
123
137
|
replaceAllImagesData(original: any, workspaceId: string): Promise<any>;
|
|
138
|
+
getAutomationFromUrl(workspaceId: string, url: string): string | false;
|
|
124
139
|
callAutomation(workspaceId: string, automation: string, params?: any): Promise<Fetched<any>>;
|
|
125
140
|
testAutomation({ workspaceId, automation, payload, }: {
|
|
126
141
|
workspaceId: string;
|
|
@@ -132,7 +147,7 @@ export declare class Api extends Fetcher {
|
|
|
132
147
|
beforeDate?: PrismeaiAPI.WorkspaceUsage.Parameters.BeforeDate;
|
|
133
148
|
details?: PrismeaiAPI.WorkspaceUsage.Parameters.Details;
|
|
134
149
|
}): Promise<Fetched<PrismeaiAPI.WorkspaceUsage.Responses.$200>>;
|
|
135
|
-
importArchive(archive: File): Promise<
|
|
150
|
+
importArchive(archive: File): Promise<ImportSuccess>;
|
|
136
151
|
users(id?: string): UsersEndpoint;
|
|
137
152
|
workspaces(id: string): WorkspacesEndpoint;
|
|
138
153
|
}
|
|
@@ -3,7 +3,11 @@ export declare class UsersEndpoint {
|
|
|
3
3
|
private id;
|
|
4
4
|
private api;
|
|
5
5
|
constructor(id: string, api: Api);
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
update(data: Partial<Prismeai.User>): Promise<PrismeaiAPI.PatchUser.Responses.$200>;
|
|
7
|
+
updatePhoto(photo: string): Promise<PrismeaiAPI.PostUserPhoto.Responses.$200>;
|
|
8
|
+
setMeta(k: string, v: any): Promise<PrismeaiAPI.SetMeta.Responses.$200>;
|
|
9
|
+
deleteMeta(k: string): Promise<PrismeaiAPI.DeleteMeta.Responses.$200>;
|
|
10
|
+
sendDeleteValidation(): Promise<unknown>;
|
|
11
|
+
delete(token?: string): Promise<unknown>;
|
|
8
12
|
}
|
|
9
13
|
export default UsersEndpoint;
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { Api } from '../api';
|
|
2
|
+
import { Fetched } from '../fetcher';
|
|
3
|
+
import { ImportSuccess } from '../ImportProcessing';
|
|
2
4
|
import WorkspacesVersionsEndpoint from './workspacesVersions';
|
|
3
5
|
export declare class WorkspacesEndpoint {
|
|
4
6
|
private id;
|
|
5
7
|
private api;
|
|
6
8
|
constructor(id: string, api: Api);
|
|
7
9
|
get versions(): WorkspacesVersionsEndpoint;
|
|
10
|
+
update(workspace: Prismeai.DSULPatch): Promise<Fetched<PrismeaiAPI.UpdateWorkspace.Responses.$200> | null>;
|
|
11
|
+
delete(): Promise<PrismeaiAPI.DeleteWorkspace.Responses.$200>;
|
|
12
|
+
uploadFiles(files: string | string[], opts?: {
|
|
13
|
+
expiresAfter?: number;
|
|
14
|
+
public?: boolean;
|
|
15
|
+
shareToken?: boolean;
|
|
16
|
+
}): Promise<PrismeaiAPI.UploadFile.Responses.$200>;
|
|
17
|
+
listAppInstances(): Promise<Fetched<PrismeaiAPI.ListAppInstances.Responses.$200>>;
|
|
18
|
+
getUsage({ afterDate, beforeDate, details, }?: {
|
|
19
|
+
afterDate?: PrismeaiAPI.WorkspaceUsage.Parameters.AfterDate;
|
|
20
|
+
beforeDate?: PrismeaiAPI.WorkspaceUsage.Parameters.BeforeDate;
|
|
21
|
+
details?: PrismeaiAPI.WorkspaceUsage.Parameters.Details;
|
|
22
|
+
}): Promise<Fetched<PrismeaiAPI.WorkspaceUsage.Responses.$200>>;
|
|
23
|
+
importArchive(archive: File): Promise<ImportSuccess>;
|
|
8
24
|
}
|
|
9
25
|
export default WorkspacesEndpoint;
|
|
@@ -3,8 +3,8 @@ export declare class WorkspacesVersionsEndpoint {
|
|
|
3
3
|
private workspaceId;
|
|
4
4
|
private api;
|
|
5
5
|
constructor(workspaceId: string, api: Api);
|
|
6
|
-
create(version?: PrismeaiAPI.PublishWorkspaceVersion.RequestBody):
|
|
7
|
-
rollback(versionId: PrismeaiAPI.
|
|
6
|
+
create(version?: PrismeaiAPI.PublishWorkspaceVersion.RequestBody): Promise<unknown>;
|
|
7
|
+
rollback(versionId: PrismeaiAPI.PullWorkspaceVersion.PathParameters['versionId'], opts?: PrismeaiAPI.PullWorkspaceVersion.RequestBody): Promise<unknown>;
|
|
8
8
|
export(version?: PrismeaiAPI.ExportWorkspaceVersion.Parameters.VersionId): Promise<Blob>;
|
|
9
9
|
}
|
|
10
10
|
export default WorkspacesVersionsEndpoint;
|
package/dist/lib/events.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ export declare class Events {
|
|
|
13
13
|
private listenedUserTopics;
|
|
14
14
|
private listeners;
|
|
15
15
|
private lastReceivedEventDate;
|
|
16
|
-
|
|
16
|
+
private socketId?;
|
|
17
|
+
constructor({ workspaceId, token, legacyToken, apiKey, apiHost, filters, api, transports, }: {
|
|
17
18
|
workspaceId: string;
|
|
18
19
|
token: string;
|
|
19
20
|
legacyToken?: string;
|
|
@@ -21,6 +22,7 @@ export declare class Events {
|
|
|
21
22
|
apiHost?: string;
|
|
22
23
|
filters?: Record<string, any>;
|
|
23
24
|
api: Api;
|
|
25
|
+
transports?: string[];
|
|
24
26
|
});
|
|
25
27
|
get socket(): Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
|
|
26
28
|
destroy(): void;
|
package/dist/lib/fetcher.d.ts
CHANGED
|
@@ -8,12 +8,13 @@ export declare class Fetcher {
|
|
|
8
8
|
overwriteClientId?: string;
|
|
9
9
|
private clientIdHeader?;
|
|
10
10
|
protected _apiKey: string | null;
|
|
11
|
+
protected _csrfToken: string | null;
|
|
11
12
|
language: string | undefined;
|
|
12
13
|
lastReceivedHeaders?: Record<string, any>;
|
|
13
14
|
constructor(host: string, clientIdHeader?: string);
|
|
14
15
|
set apiKey(apiKey: string);
|
|
15
16
|
prepareRequest(url: string, options?: RequestInit): Promise<Response>;
|
|
16
|
-
protected _fetch<T>(url: string, options?: RequestInit): Promise<T>;
|
|
17
|
+
protected _fetch<T>(url: string, options?: RequestInit, maxRetries?: number): Promise<T>;
|
|
17
18
|
get<T = any>(url: string): Promise<T>;
|
|
18
19
|
post<T>(url: string, body?: Record<string, any>, opts?: RequestInit): Promise<T>;
|
|
19
20
|
put<T>(url: string, body: Record<string, any>): Promise<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export declare const removedUndefinedProperties: (obj: any, removeEmptyStrings?: boolean) => any;
|
|
2
|
+
export declare function dataURItoBlob(dataURI: string): [Blob, string];
|
|
3
|
+
export declare function isDataURL(file: any): file is string;
|
|
4
|
+
export declare function wait(delay?: number): Promise<unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.js');
|
|
6
|
+
|
|
7
|
+
var ImportProcessingError = /** @class */ (function (_super) {
|
|
8
|
+
_tslib.__extends(ImportProcessingError, _super);
|
|
9
|
+
function ImportProcessingError(error) {
|
|
10
|
+
var _this = _super.call(this) || this;
|
|
11
|
+
_this.error = error;
|
|
12
|
+
return _this;
|
|
13
|
+
}
|
|
14
|
+
return ImportProcessingError;
|
|
15
|
+
}(Error));
|
|
16
|
+
|
|
17
|
+
exports.ImportProcessingError = ImportProcessingError;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var WorkspacesEndpoint = /** @class */ (function () {
|
|
6
|
+
function WorkspacesEndpoint(id, api) {
|
|
7
|
+
this.versions = {
|
|
8
|
+
create: this.versionCreate.bind(this),
|
|
9
|
+
};
|
|
10
|
+
this.id = id;
|
|
11
|
+
this.api = api;
|
|
12
|
+
}
|
|
13
|
+
WorkspacesEndpoint.prototype.versionCreate = function () {
|
|
14
|
+
console.log('créer version pour', this.id, this.api);
|
|
15
|
+
};
|
|
16
|
+
return WorkspacesEndpoint;
|
|
17
|
+
}());
|
|
18
|
+
|
|
19
|
+
exports.WorkspacesEndpoint = WorkspacesEndpoint;
|
package/dist/sdk/lib/api.js
CHANGED
|
@@ -11,6 +11,7 @@ var utils = require('./utils.js');
|
|
|
11
11
|
var workspaces = require('./endpoints/workspaces.js');
|
|
12
12
|
var ApiError = require('./ApiError.js');
|
|
13
13
|
var users = require('./endpoints/users.js');
|
|
14
|
+
var ImportProcessing = require('./ImportProcessing.js');
|
|
14
15
|
|
|
15
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
17
|
|
|
@@ -49,9 +50,9 @@ var Api = /** @class */ (function (_super) {
|
|
|
49
50
|
_tslib.__extends(Api, _super);
|
|
50
51
|
function Api(opts) {
|
|
51
52
|
var _this = this;
|
|
52
|
-
var _a;
|
|
53
|
+
var _a, _b;
|
|
53
54
|
_this = _super.call(this, opts.host, (_a = opts === null || opts === void 0 ? void 0 : opts.oidc) === null || _a === void 0 ? void 0 : _a.clientIdHeader) || this;
|
|
54
|
-
_this.opts = _tslib.__assign(_tslib.__assign({}, opts), { oidc: _tslib.__assign({ url: 'http://studio.local.prisme.ai:3001', clientId: 'local-client-id', redirectUri: 'http://studio.local.prisme.ai:3000/signin' }, opts.oidc) });
|
|
55
|
+
_this.opts = _tslib.__assign(_tslib.__assign({}, opts), { oidc: _tslib.__assign({ url: 'http://studio.local.prisme.ai:3001', clientId: 'local-client-id', redirectUri: 'http://studio.local.prisme.ai:3000/signin' }, opts.oidc), websockets: _tslib.__assign(_tslib.__assign({}, opts.websockets), { transports: ((_b = opts.websockets) === null || _b === void 0 ? void 0 : _b.transports) || ['polling', 'websocket'] }) });
|
|
55
56
|
return _this;
|
|
56
57
|
}
|
|
57
58
|
Object.defineProperty(Api.prototype, "user", {
|
|
@@ -165,9 +166,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
165
166
|
var user;
|
|
166
167
|
return _tslib.__generator(this, function (_a) {
|
|
167
168
|
switch (_a.label) {
|
|
168
|
-
case 0: return [4 /*yield*/, this.post('/login/anonymous'
|
|
169
|
-
credentials: 'omit',
|
|
170
|
-
})];
|
|
169
|
+
case 0: return [4 /*yield*/, this.post('/login/anonymous')];
|
|
171
170
|
case 1:
|
|
172
171
|
user = _a.sent();
|
|
173
172
|
this._user = user;
|
|
@@ -186,6 +185,8 @@ var Api = /** @class */ (function (_super) {
|
|
|
186
185
|
firstName: firstName,
|
|
187
186
|
lastName: lastName,
|
|
188
187
|
language: language,
|
|
188
|
+
}, {
|
|
189
|
+
credentials: 'omit',
|
|
189
190
|
})];
|
|
190
191
|
case 1: return [2 /*return*/, _a.sent()];
|
|
191
192
|
}
|
|
@@ -248,7 +249,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
248
249
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
249
250
|
return _tslib.__generator(this, function (_a) {
|
|
250
251
|
switch (_a.label) {
|
|
251
|
-
case 0: return [4 /*yield*/, this.get('/workspaces?limit=
|
|
252
|
+
case 0: return [4 /*yield*/, this.get('/workspaces?limit=2000')];
|
|
252
253
|
case 1: return [2 /*return*/, _a.sent()];
|
|
253
254
|
}
|
|
254
255
|
});
|
|
@@ -294,11 +295,41 @@ var Api = /** @class */ (function (_super) {
|
|
|
294
295
|
});
|
|
295
296
|
});
|
|
296
297
|
};
|
|
297
|
-
Api.prototype.
|
|
298
|
+
Api.prototype.getWorkspaceSecrets = function (id) {
|
|
299
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
300
|
+
return _tslib.__generator(this, function (_a) {
|
|
301
|
+
switch (_a.label) {
|
|
302
|
+
case 0: return [4 /*yield*/, this.get("/workspaces/".concat(id, "/security/secrets"))];
|
|
303
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
Api.prototype.updateWorkspaceSecrets = function (id, newSecrets) {
|
|
309
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
310
|
+
return _tslib.__generator(this, function (_a) {
|
|
311
|
+
switch (_a.label) {
|
|
312
|
+
case 0: return [4 /*yield*/, this.patch("/workspaces/".concat(id, "/security/secrets"), _tslib.__assign({}, newSecrets))];
|
|
313
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
Api.prototype.deleteWorkspaceSecrets = function (id, secretName) {
|
|
298
319
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
299
320
|
return _tslib.__generator(this, function (_a) {
|
|
300
321
|
switch (_a.label) {
|
|
301
|
-
case 0: return [4 /*yield*/, this.
|
|
322
|
+
case 0: return [4 /*yield*/, this.delete("/workspaces/".concat(id, "/security/secrets/").concat(secretName))];
|
|
323
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
Api.prototype.createWorkspace = function (newWorkspace) {
|
|
329
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
330
|
+
return _tslib.__generator(this, function (_a) {
|
|
331
|
+
switch (_a.label) {
|
|
332
|
+
case 0: return [4 /*yield*/, this.post('/workspaces', newWorkspace)];
|
|
302
333
|
case 1: return [2 /*return*/, _a.sent()];
|
|
303
334
|
}
|
|
304
335
|
});
|
|
@@ -315,6 +346,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
315
346
|
});
|
|
316
347
|
});
|
|
317
348
|
};
|
|
349
|
+
// @deprecated. Use api.workspaces(id).update() instead
|
|
318
350
|
Api.prototype.updateWorkspace = function (workspace) {
|
|
319
351
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
320
352
|
var _a, _b;
|
|
@@ -332,6 +364,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
332
364
|
});
|
|
333
365
|
});
|
|
334
366
|
};
|
|
367
|
+
// @deprecated. Use api.workspaces(id).delete() instead
|
|
335
368
|
Api.prototype.deleteWorkspace = function (workspaceId) {
|
|
336
369
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
337
370
|
return _tslib.__generator(this, function (_a) {
|
|
@@ -400,7 +433,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
400
433
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
401
434
|
return _tslib.__generator(this, function (_a) {
|
|
402
435
|
switch (_a.label) {
|
|
403
|
-
case 0: return [4 /*yield*/, this.get("/workspaces/".concat(workspaceId, "/automations/").concat(automationSlug))];
|
|
436
|
+
case 0: return [4 /*yield*/, this.get("/workspaces/".concat(workspaceId, "/automations/").concat(encodeURIComponent(automationSlug)))];
|
|
404
437
|
case 1: return [2 /*return*/, _a.sent()];
|
|
405
438
|
}
|
|
406
439
|
});
|
|
@@ -423,7 +456,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
423
456
|
switch (_c.label) {
|
|
424
457
|
case 0:
|
|
425
458
|
_a = this.patch;
|
|
426
|
-
_b = ["/workspaces/".concat(workspaceId, "/automations/").concat(slug)];
|
|
459
|
+
_b = ["/workspaces/".concat(workspaceId, "/automations/").concat(encodeURIComponent(slug))];
|
|
427
460
|
return [4 /*yield*/, this.replaceAllImagesData(automation, workspaceId)];
|
|
428
461
|
case 1: return [4 /*yield*/, _a.apply(this, _b.concat([_c.sent()]))];
|
|
429
462
|
case 2: return [2 /*return*/, _c.sent()];
|
|
@@ -435,7 +468,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
435
468
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
436
469
|
return _tslib.__generator(this, function (_a) {
|
|
437
470
|
switch (_a.label) {
|
|
438
|
-
case 0: return [4 /*yield*/, this.delete("/workspaces/".concat(workspaceId, "/automations/").concat(slug))];
|
|
471
|
+
case 0: return [4 /*yield*/, this.delete("/workspaces/".concat(workspaceId, "/automations/").concat(encodeURIComponent(slug)))];
|
|
439
472
|
case 1: return [2 /*return*/, _a.sent()];
|
|
440
473
|
}
|
|
441
474
|
});
|
|
@@ -530,9 +563,11 @@ var Api = /** @class */ (function (_super) {
|
|
|
530
563
|
};
|
|
531
564
|
// Events
|
|
532
565
|
Api.prototype.streamEvents = function (workspaceId, filters) {
|
|
566
|
+
var _a, _b;
|
|
533
567
|
if (filters && filters['source.sessionId'] === true) {
|
|
534
568
|
if (this.sessionId) {
|
|
535
569
|
filters['source.sessionId'] = this.sessionId;
|
|
570
|
+
filters['target.userTopic'] = ''; // We do not want to receive userTopics emitted by ourself for this session listener
|
|
536
571
|
}
|
|
537
572
|
else {
|
|
538
573
|
delete filters['source.sessionId'];
|
|
@@ -546,6 +581,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
546
581
|
apiHost: this.host,
|
|
547
582
|
filters: filters,
|
|
548
583
|
api: this,
|
|
584
|
+
transports: (_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.websockets) === null || _b === void 0 ? void 0 : _b.transports,
|
|
549
585
|
});
|
|
550
586
|
return new Promise(function (resolve, reject) {
|
|
551
587
|
var off = events$1.once('connect_error', function () {
|
|
@@ -658,7 +694,6 @@ var Api = /** @class */ (function (_super) {
|
|
|
658
694
|
throw new ApiError.ApiError({
|
|
659
695
|
error: 'CollaboratorNotFound',
|
|
660
696
|
message: 'This user does not exist',
|
|
661
|
-
details: { email: email },
|
|
662
697
|
}, 404);
|
|
663
698
|
}
|
|
664
699
|
body.target = { id: contacts.contacts[0].id };
|
|
@@ -700,6 +735,17 @@ var Api = /** @class */ (function (_super) {
|
|
|
700
735
|
});
|
|
701
736
|
});
|
|
702
737
|
};
|
|
738
|
+
Api.prototype.getApp = function (_a) {
|
|
739
|
+
var _b = _a.slug, slug = _b === void 0 ? '' : _b;
|
|
740
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
741
|
+
return _tslib.__generator(this, function (_c) {
|
|
742
|
+
switch (_c.label) {
|
|
743
|
+
case 0: return [4 /*yield*/, this.get("/apps/".concat(encodeURIComponent(slug)))];
|
|
744
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
};
|
|
703
749
|
Api.prototype.installApp = function (workspaceId, body) {
|
|
704
750
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
705
751
|
return _tslib.__generator(this, function (_a) {
|
|
@@ -740,6 +786,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
740
786
|
});
|
|
741
787
|
});
|
|
742
788
|
};
|
|
789
|
+
// @deprecated. Use api.workspaces(id).listAppInstances())
|
|
743
790
|
Api.prototype.listAppInstances = function (workspaceId) {
|
|
744
791
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
745
792
|
return _tslib.__generator(this, function (_a) {
|
|
@@ -795,7 +842,8 @@ var Api = /** @class */ (function (_super) {
|
|
|
795
842
|
});
|
|
796
843
|
});
|
|
797
844
|
};
|
|
798
|
-
|
|
845
|
+
// @deprecated. Use api.workspaces(id).uploadFiles()
|
|
846
|
+
Api.prototype.uploadFiles = function (files, workspaceId, opts) {
|
|
799
847
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
800
848
|
var formData;
|
|
801
849
|
return _tslib.__generator(this, function (_a) {
|
|
@@ -808,6 +856,15 @@ var Api = /** @class */ (function (_super) {
|
|
|
808
856
|
}
|
|
809
857
|
catch (_a) { }
|
|
810
858
|
});
|
|
859
|
+
if (opts === null || opts === void 0 ? void 0 : opts.expiresAfter) {
|
|
860
|
+
formData.append('expiresAfter', "".concat(opts === null || opts === void 0 ? void 0 : opts.expiresAfter));
|
|
861
|
+
}
|
|
862
|
+
if (typeof (opts === null || opts === void 0 ? void 0 : opts.public) === 'boolean') {
|
|
863
|
+
formData.append('public', "".concat(opts === null || opts === void 0 ? void 0 : opts.public));
|
|
864
|
+
}
|
|
865
|
+
if (typeof (opts === null || opts === void 0 ? void 0 : opts.shareToken) === 'boolean') {
|
|
866
|
+
formData.append('shareToken', "".concat(opts === null || opts === void 0 ? void 0 : opts.shareToken));
|
|
867
|
+
}
|
|
811
868
|
_a.label = 1;
|
|
812
869
|
case 1:
|
|
813
870
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -848,7 +905,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
848
905
|
case 'object':
|
|
849
906
|
var isArray = Array.isArray(mayHaveImage);
|
|
850
907
|
var withImagesUrl = isArray
|
|
851
|
-
? _tslib.__spreadArray([], mayHaveImage) : _tslib.__assign({}, mayHaveImage);
|
|
908
|
+
? _tslib.__spreadArray([], mayHaveImage, true) : _tslib.__assign({}, mayHaveImage);
|
|
852
909
|
for (var _i = 0, _b = Object.keys(withImagesUrl); _i < _b.length; _i++) {
|
|
853
910
|
var key_1 = _b[_i];
|
|
854
911
|
withImagesUrl[key_1] = searchImages(withImagesUrl[key_1], uploaded);
|
|
@@ -873,6 +930,10 @@ var Api = /** @class */ (function (_super) {
|
|
|
873
930
|
});
|
|
874
931
|
});
|
|
875
932
|
};
|
|
933
|
+
Api.prototype.getAutomationFromUrl = function (workspaceId, url) {
|
|
934
|
+
var match = url.match("".concat(this.host, "/workspaces/").concat(workspaceId, "/webhooks/(.*$)"));
|
|
935
|
+
return match ? match[1] : false;
|
|
936
|
+
};
|
|
876
937
|
Api.prototype.callAutomation = function (workspaceId, automation, params) {
|
|
877
938
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
878
939
|
return _tslib.__generator(this, function (_a) {
|
|
@@ -890,6 +951,7 @@ var Api = /** @class */ (function (_super) {
|
|
|
890
951
|
});
|
|
891
952
|
});
|
|
892
953
|
};
|
|
954
|
+
// @deprecated. Use api.workspaces(id).getUsage())
|
|
893
955
|
Api.prototype.getWorkspaceUsage = function (workspaceId, _a) {
|
|
894
956
|
var _b = _a === void 0 ? {} : _a, afterDate = _b.afterDate, beforeDate = _b.beforeDate, details = _b.details;
|
|
895
957
|
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
@@ -913,20 +975,20 @@ var Api = /** @class */ (function (_super) {
|
|
|
913
975
|
fileReader.addEventListener('load', function (_a) {
|
|
914
976
|
var target = _a.target;
|
|
915
977
|
return _tslib.__awaiter(_this, void 0, void 0, function () {
|
|
916
|
-
var file, formData,
|
|
917
|
-
return _tslib.__generator(this, function (
|
|
918
|
-
switch (
|
|
978
|
+
var file, formData, result;
|
|
979
|
+
return _tslib.__generator(this, function (_b) {
|
|
980
|
+
switch (_b.label) {
|
|
919
981
|
case 0:
|
|
920
982
|
file = target === null || target === void 0 ? void 0 : target.result;
|
|
921
983
|
formData = new FormData();
|
|
922
|
-
formData.append.apply(formData, _tslib.__spreadArray(['archive'], dataURItoBlob(file)));
|
|
923
|
-
|
|
924
|
-
return [4 /*yield*/, this._fetch("/workspaces/import", {
|
|
925
|
-
method: 'POST',
|
|
926
|
-
body: formData,
|
|
927
|
-
})];
|
|
984
|
+
formData.append.apply(formData, _tslib.__spreadArray(['archive'], dataURItoBlob(file), false));
|
|
985
|
+
return [4 /*yield*/, this.post("/workspaces/import", formData)];
|
|
928
986
|
case 1:
|
|
929
|
-
|
|
987
|
+
result = _b.sent();
|
|
988
|
+
if (result.processing) {
|
|
989
|
+
throw new ImportProcessing.ImportProcessingError(result);
|
|
990
|
+
}
|
|
991
|
+
resolve(result);
|
|
930
992
|
return [2 /*return*/];
|
|
931
993
|
}
|
|
932
994
|
});
|