@prisme.ai/sdk 1.0.2 → 2.0.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/README.md +250 -0
- package/dist/index.d.mts +1129 -0
- package/dist/index.d.ts +1129 -7
- package/dist/index.js +1326 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1287 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +50 -12
- package/Readme.md +0 -28
- package/dist/_virtual/_tslib.js +0 -116
- package/dist/lib/ApiError.d.ts +0 -8
- package/dist/lib/ApiError.test.d.ts +0 -1
- package/dist/lib/HTTPError.d.ts +0 -6
- package/dist/lib/HTTPError.test.d.ts +0 -1
- package/dist/lib/ImportProcessing.d.ts +0 -19
- package/dist/lib/WorkspacesEndpoint.d.ts +0 -10
- package/dist/lib/api.d.ts +0 -155
- package/dist/lib/api.test.d.ts +0 -1
- package/dist/lib/endpoints/users.d.ts +0 -13
- package/dist/lib/endpoints/workspaces.d.ts +0 -25
- package/dist/lib/endpoints/workspacesVersions.d.ts +0 -10
- package/dist/lib/events.d.ts +0 -40
- package/dist/lib/events.test.d.ts +0 -1
- package/dist/lib/fetch.d.ts +0 -2
- package/dist/lib/fetcher.d.ts +0 -24
- package/dist/lib/fetcher.test.d.ts +0 -1
- package/dist/lib/interpolate.d.ts +0 -2
- package/dist/lib/interpolate.test.d.ts +0 -1
- package/dist/lib/interpolateVars.d.ts +0 -2
- package/dist/lib/types.d.ts +0 -17
- package/dist/lib/utils.d.ts +0 -4
- package/dist/lib/utils.test.d.ts +0 -1
- package/dist/sdk/index.js +0 -19
- package/dist/sdk/lib/ApiError.js +0 -24
- package/dist/sdk/lib/HTTPError.js +0 -21
- package/dist/sdk/lib/ImportProcessing.js +0 -17
- package/dist/sdk/lib/WorkspacesEndpoint.js +0 -19
- package/dist/sdk/lib/api.js +0 -1018
- package/dist/sdk/lib/endpoints/users.js +0 -94
- package/dist/sdk/lib/endpoints/workspaces.js +0 -144
- package/dist/sdk/lib/endpoints/workspacesVersions.js +0 -40
- package/dist/sdk/lib/events.js +0 -169
- package/dist/sdk/lib/fetch.js +0 -12
- package/dist/sdk/lib/fetcher.js +0 -213
- package/dist/sdk/lib/interpolate.js +0 -26
- package/dist/sdk/lib/interpolateVars.js +0 -26
- package/dist/sdk/lib/utils.js +0 -65
- package/index.ts +0 -7
- package/lib/ApiError.test.ts +0 -13
- package/lib/ApiError.ts +0 -21
- package/lib/HTTPError.test.ts +0 -8
- package/lib/HTTPError.ts +0 -13
- package/lib/ImportProcessing.ts +0 -22
- package/lib/api.test.ts +0 -787
- package/lib/api.ts +0 -949
- package/lib/endpoints/users.ts +0 -58
- package/lib/endpoints/workspaces.ts +0 -121
- package/lib/endpoints/workspacesVersions.ts +0 -38
- package/lib/events.test.ts +0 -89
- package/lib/events.ts +0 -222
- package/lib/fetcher.test.ts +0 -246
- package/lib/fetcher.ts +0 -198
- package/lib/types.ts +0 -21
- package/lib/utils.test.ts +0 -38
- package/lib/utils.ts +0 -51
- package/tsconfig.json +0 -21
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _tslib = require('../../_virtual/_tslib.js');
|
|
6
|
-
|
|
7
|
-
function interpolateString(str, values) {
|
|
8
|
-
if (values === void 0) { values = {}; }
|
|
9
|
-
return str.replace(/\$\{([^}]+)\}/g, function (_, m) { return values[m] || ''; });
|
|
10
|
-
}
|
|
11
|
-
function interpolate(into, values) {
|
|
12
|
-
if (typeof into === 'string') {
|
|
13
|
-
return interpolateString(into, values);
|
|
14
|
-
}
|
|
15
|
-
var isArray = Array.isArray(into);
|
|
16
|
-
var newObject = isArray ? _tslib.__spreadArray([], into) : _tslib.__assign({}, into);
|
|
17
|
-
for (var _i = 0, _a = Object.keys(newObject); _i < _a.length; _i++) {
|
|
18
|
-
var key = _a[_i];
|
|
19
|
-
var value = newObject[key];
|
|
20
|
-
newObject[key] = interpolate(value, values);
|
|
21
|
-
}
|
|
22
|
-
return newObject;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.interpolate = interpolate;
|
|
26
|
-
exports.interpolateString = interpolateString;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _tslib = require('../../_virtual/_tslib.js');
|
|
6
|
-
|
|
7
|
-
function interpolateString(str, values) {
|
|
8
|
-
if (values === void 0) { values = {}; }
|
|
9
|
-
return str.replace(/\$\{([^}]+)\}/g, function (_, m) { return values[m] || ''; });
|
|
10
|
-
}
|
|
11
|
-
function interpolate(into, values) {
|
|
12
|
-
if (typeof into === 'string') {
|
|
13
|
-
return interpolateString(into, values);
|
|
14
|
-
}
|
|
15
|
-
var isArray = Array.isArray(into);
|
|
16
|
-
var newObject = isArray ? _tslib.__spreadArray([], into) : _tslib.__assign({}, into);
|
|
17
|
-
for (var _i = 0, _a = Object.keys(newObject); _i < _a.length; _i++) {
|
|
18
|
-
var key = _a[_i];
|
|
19
|
-
var value = newObject[key];
|
|
20
|
-
newObject[key] = interpolate(value, values);
|
|
21
|
-
}
|
|
22
|
-
return newObject;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.interpolate = interpolate;
|
|
26
|
-
exports.interpolateString = interpolateString;
|
package/dist/sdk/lib/utils.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _tslib = require('../../_virtual/_tslib.js');
|
|
6
|
-
|
|
7
|
-
var removedUndefinedProperties = function (obj, removeEmptyStrings) {
|
|
8
|
-
if (removeEmptyStrings === void 0) { removeEmptyStrings = false; }
|
|
9
|
-
return Object.entries(obj).reduce(function (newObject, _a) {
|
|
10
|
-
var key = _a[0], value = _a[1];
|
|
11
|
-
if (value !== undefined) {
|
|
12
|
-
if (!(removeEmptyStrings && value === '')) {
|
|
13
|
-
newObject[key] = value;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return newObject;
|
|
17
|
-
}, {});
|
|
18
|
-
};
|
|
19
|
-
function dataURItoBlob(dataURI) {
|
|
20
|
-
// convert base64/URLEncoded data component to raw binary data held in a string
|
|
21
|
-
var byteString;
|
|
22
|
-
if (dataURI.split(',')[0].indexOf('base64') >= 0)
|
|
23
|
-
byteString = atob(dataURI.split(',')[1].split(';')[0]);
|
|
24
|
-
else
|
|
25
|
-
byteString = unescape(dataURI.split(',')[1]);
|
|
26
|
-
// separate out the mime component
|
|
27
|
-
var metadata = dataURI
|
|
28
|
-
.split(';')
|
|
29
|
-
.map(function (v) { return v.split(/:/); })
|
|
30
|
-
.filter(function (pair) { return pair.length === 2; });
|
|
31
|
-
var _a = metadata.find(function (_a) {
|
|
32
|
-
var k = _a[0]; _a[1];
|
|
33
|
-
return k === 'data';
|
|
34
|
-
}) || [], _b = _a[1], mimeString = _b === void 0 ? '' : _b;
|
|
35
|
-
var _c = mimeString.split(/\//), ext = _c[1];
|
|
36
|
-
var _d = metadata.find(function (_a) {
|
|
37
|
-
var k = _a[0]; _a[1];
|
|
38
|
-
return k === 'filename';
|
|
39
|
-
}) || [], _e = _d[1], fileName = _e === void 0 ? "file.".concat(ext) : _e;
|
|
40
|
-
var sanitizedFileName = encodeURIComponent(decodeURIComponent(fileName).replace(/[;,\s]/g, '-'));
|
|
41
|
-
// write the bytes of the string to a typed array
|
|
42
|
-
var ia = new Uint8Array(byteString.length);
|
|
43
|
-
for (var i = 0; i < byteString.length; i++) {
|
|
44
|
-
ia[i] = byteString.charCodeAt(i);
|
|
45
|
-
}
|
|
46
|
-
return [new Blob([ia], { type: mimeString }), sanitizedFileName];
|
|
47
|
-
}
|
|
48
|
-
function isDataURL(file) {
|
|
49
|
-
return !!(typeof file === 'string' && file.match(/^data\:/));
|
|
50
|
-
}
|
|
51
|
-
function wait(delay) {
|
|
52
|
-
if (delay === void 0) { delay = 0; }
|
|
53
|
-
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
54
|
-
return _tslib.__generator(this, function (_a) {
|
|
55
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
56
|
-
setTimeout(resolve, delay);
|
|
57
|
-
})];
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
exports.dataURItoBlob = dataURItoBlob;
|
|
63
|
-
exports.isDataURL = isDataURL;
|
|
64
|
-
exports.removedUndefinedProperties = removedUndefinedProperties;
|
|
65
|
-
exports.wait = wait;
|
package/index.ts
DELETED
package/lib/ApiError.test.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import ApiError from './ApiError';
|
|
2
|
-
|
|
3
|
-
it('should construct', () => {
|
|
4
|
-
const apiError = new ApiError(
|
|
5
|
-
{ error: 'foo', message: 'bar', details: [{}] },
|
|
6
|
-
400
|
|
7
|
-
);
|
|
8
|
-
expect(apiError.code).toBe(400);
|
|
9
|
-
expect(apiError.message).toBe('bar');
|
|
10
|
-
expect(apiError.error).toBe('foo');
|
|
11
|
-
expect(apiError.details).toEqual([{}]);
|
|
12
|
-
expect(`${apiError}`).toBe('foo');
|
|
13
|
-
});
|
package/lib/ApiError.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export class ApiError extends Error implements Prismeai.GenericError {
|
|
2
|
-
public code: number;
|
|
3
|
-
public error: Prismeai.GenericError['error'];
|
|
4
|
-
public details: Prismeai.GenericError['details'];
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
7
|
-
{ error, message, details }: Prismeai.GenericError,
|
|
8
|
-
code: number
|
|
9
|
-
) {
|
|
10
|
-
super(message);
|
|
11
|
-
this.code = code;
|
|
12
|
-
this.error = error;
|
|
13
|
-
this.details = details;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
toString() {
|
|
17
|
-
return this.error;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default ApiError;
|
package/lib/HTTPError.test.ts
DELETED
package/lib/HTTPError.ts
DELETED
package/lib/ImportProcessing.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type ImportProcessing = {
|
|
2
|
-
processing?: boolean;
|
|
3
|
-
message?: string;
|
|
4
|
-
};
|
|
5
|
-
export class ImportProcessingError extends Error {
|
|
6
|
-
error: ImportProcessing;
|
|
7
|
-
constructor(error: ImportProcessing) {
|
|
8
|
-
super();
|
|
9
|
-
this.error = error;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export type ImportSuccess = {
|
|
13
|
-
createdWorkspaceIds?: string[];
|
|
14
|
-
updatedWorkspaceIds?: string[];
|
|
15
|
-
imported: string[];
|
|
16
|
-
errors?: {
|
|
17
|
-
[name: string]: any;
|
|
18
|
-
}[];
|
|
19
|
-
workspace?: Prismeai.DSULReadOnly;
|
|
20
|
-
publishedApps?: Prismeai.App[];
|
|
21
|
-
deleted?: string[];
|
|
22
|
-
};
|