@membranehq/sdk 0.15.4 → 0.15.5
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/bundle.d.ts +23 -2
- package/dist/bundle.js +127 -6
- package/dist/bundle.js.map +1 -1
- package/dist/dts/api-client.d.ts +6 -2
- package/dist/dts/orgs/types.d.ts +10 -0
- package/dist/dts/scenario-templates/index.d.ts +2 -0
- package/dist/dts/workspace-elements/api/action-run-log-records-api.d.ts +4 -0
- package/dist/dts/workspace-elements/api/actions-api.d.ts +9 -0
- package/dist/dts/workspace-elements/api/customers-api.d.ts +1 -1
- package/dist/dts/workspace-elements/base/action-instances/index.d.ts +1 -0
- package/dist/dts/workspace-elements/base/actions/index.d.ts +2 -0
- package/dist/dts/workspace-elements/base/connectors/index.d.ts +2 -0
- package/dist/dts/workspace-elements/base/data-collections/schemas.d.ts +1 -1
- package/dist/dts/workspaces/types.d.ts +33 -1
- package/dist/index.browser.d.mts +97 -33
- package/dist/index.browser.d.ts +97 -33
- package/dist/index.browser.js +70 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +70 -5
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.mts +97 -33
- package/dist/index.node.d.ts +97 -33
- package/dist/index.node.js +70 -5
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +70 -5
- package/dist/index.node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -11,6 +11,20 @@ declare class PaginationResponse<T> {
|
|
|
11
11
|
cursor?: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
declare enum LogRecordType {
|
|
15
|
+
MSG = "message",
|
|
16
|
+
TEXT = "text",
|
|
17
|
+
ERR = "error",
|
|
18
|
+
DATA = "data",
|
|
19
|
+
COMP = "compare",
|
|
20
|
+
API = "api-request"
|
|
21
|
+
}
|
|
22
|
+
interface LogRecord {
|
|
23
|
+
type?: LogRecordType;
|
|
24
|
+
msg?: string;
|
|
25
|
+
data?: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
interface MembraneClientOptions {
|
|
15
29
|
token?: string;
|
|
16
30
|
fetchToken?: () => Promise<string>;
|
|
@@ -25,6 +39,7 @@ declare class MembraneApiClient {
|
|
|
25
39
|
uiUri: string;
|
|
26
40
|
token?: string;
|
|
27
41
|
protected fetchToken?: () => Promise<string>;
|
|
42
|
+
private logs;
|
|
28
43
|
constructor(options?: MembraneClientOptions);
|
|
29
44
|
setCredentials(credentials: any): Promise<any>;
|
|
30
45
|
getToken(): Promise<string>;
|
|
@@ -33,6 +48,7 @@ declare class MembraneApiClient {
|
|
|
33
48
|
put<T = any>(uri: string, data?: any, options?: AxiosRequestConfig): Promise<T>;
|
|
34
49
|
patch<T = any>(uri: string, data?: any, options?: AxiosRequestConfig): Promise<T>;
|
|
35
50
|
delete<T = any>(uri: string, data?: any, options?: AxiosRequestConfig): Promise<T>;
|
|
51
|
+
retrieveLogs(): LogRecord[];
|
|
36
52
|
createEventSource(uri: string, queryParams?: Record<string, any>): Promise<EventSource>;
|
|
37
53
|
getEmbedUri(page: string, pageParams?: Record<string, any>, options?: {
|
|
38
54
|
embedMode: 'isolated-embed' | 'popup-embed';
|
|
@@ -45,6 +61,7 @@ declare class MembraneApiClient {
|
|
|
45
61
|
};
|
|
46
62
|
}>;
|
|
47
63
|
private makeApiRequest;
|
|
64
|
+
private log;
|
|
48
65
|
private handleRequestError;
|
|
49
66
|
}
|
|
50
67
|
|
|
@@ -521,6 +538,7 @@ declare const ActionApiResponse: z.ZodObject<{
|
|
|
521
538
|
isDeactivated: z.ZodOptional<z.ZodBoolean>;
|
|
522
539
|
isCustomized: z.ZodOptional<z.ZodBoolean>;
|
|
523
540
|
universalParentId: z.ZodOptional<z.ZodString>;
|
|
541
|
+
isPublic: z.ZodOptional<z.ZodBoolean>;
|
|
524
542
|
userId: z.ZodOptional<z.ZodString>;
|
|
525
543
|
tenantId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
526
544
|
integration: z.ZodOptional<z.ZodObject<{
|
|
@@ -610,6 +628,7 @@ declare const ActionApiResponse: z.ZodObject<{
|
|
|
610
628
|
isCustomized: z.ZodOptional<z.ZodBoolean>;
|
|
611
629
|
universalParentId: z.ZodOptional<z.ZodString>;
|
|
612
630
|
outputSchema: z.ZodOptional<z.ZodAny>;
|
|
631
|
+
isPublic: z.ZodOptional<z.ZodBoolean>;
|
|
613
632
|
userId: z.ZodOptional<z.ZodString>;
|
|
614
633
|
tenantId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
615
634
|
}, z.core.$strip>>;
|
|
@@ -643,6 +662,7 @@ declare const ActionApiResponse: z.ZodObject<{
|
|
|
643
662
|
isCustomized: z.ZodOptional<z.ZodBoolean>;
|
|
644
663
|
universalParentId: z.ZodOptional<z.ZodString>;
|
|
645
664
|
outputSchema: z.ZodOptional<z.ZodAny>;
|
|
665
|
+
isPublic: z.ZodOptional<z.ZodBoolean>;
|
|
646
666
|
userId: z.ZodOptional<z.ZodString>;
|
|
647
667
|
tenantId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
648
668
|
}, z.core.$strip>;
|
|
@@ -717,6 +737,7 @@ declare const FindActionsQuery: z.ZodObject<{
|
|
|
717
737
|
}>>;
|
|
718
738
|
parentId: z.ZodOptional<z.ZodString>;
|
|
719
739
|
universalParentId: z.ZodOptional<z.ZodString>;
|
|
740
|
+
intent: z.ZodOptional<z.ZodString>;
|
|
720
741
|
}, z.core.$strip>;
|
|
721
742
|
type FindActionsQuery = z.infer<typeof FindActionsQuery>;
|
|
722
743
|
declare const CreateActionRequest: z.ZodObject<{
|
|
@@ -3004,7 +3025,7 @@ declare const DataCollectionDeleteRequest: z.ZodObject<{
|
|
|
3004
3025
|
id: z.ZodString;
|
|
3005
3026
|
}, z.core.$strip>;
|
|
3006
3027
|
type DataCollectionDeleteRequest = z.infer<typeof DataCollectionDeleteRequest>;
|
|
3007
|
-
declare const DataCollectionDeleteResponse: z.
|
|
3028
|
+
declare const DataCollectionDeleteResponse: z.ZodUndefined;
|
|
3008
3029
|
type DataCollectionDeleteResponse = z.infer<typeof DataCollectionDeleteResponse>;
|
|
3009
3030
|
|
|
3010
3031
|
declare enum FlowRunNodeState {
|
|
@@ -5080,7 +5101,7 @@ type ScreenApiResponse = z.infer<typeof ScreenApiResponse>;
|
|
|
5080
5101
|
|
|
5081
5102
|
declare const CreateCustomerRequest: z.ZodObject<{
|
|
5082
5103
|
name: z.ZodString;
|
|
5083
|
-
internalId: z.ZodString
|
|
5104
|
+
internalId: z.ZodOptional<z.ZodString>;
|
|
5084
5105
|
fields: z.ZodOptional<z.ZodAny>;
|
|
5085
5106
|
credentials: z.ZodOptional<z.ZodAny>;
|
|
5086
5107
|
}, z.core.$strip>;
|
package/dist/bundle.js
CHANGED
|
@@ -24815,7 +24815,7 @@
|
|
|
24815
24815
|
*
|
|
24816
24816
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
24817
24817
|
*/
|
|
24818
|
-
const isBlob = kindOfTest('Blob');
|
|
24818
|
+
const isBlob$1 = kindOfTest('Blob');
|
|
24819
24819
|
|
|
24820
24820
|
/**
|
|
24821
24821
|
* Determine if a value is a FileList
|
|
@@ -24833,7 +24833,7 @@
|
|
|
24833
24833
|
*
|
|
24834
24834
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
24835
24835
|
*/
|
|
24836
|
-
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
24836
|
+
const isStream$1 = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
24837
24837
|
|
|
24838
24838
|
/**
|
|
24839
24839
|
* Determine if a value is a FormData
|
|
@@ -25373,10 +25373,10 @@
|
|
|
25373
25373
|
isUndefined,
|
|
25374
25374
|
isDate,
|
|
25375
25375
|
isFile,
|
|
25376
|
-
isBlob,
|
|
25376
|
+
isBlob: isBlob$1,
|
|
25377
25377
|
isRegExp,
|
|
25378
25378
|
isFunction: isFunction$1,
|
|
25379
|
-
isStream,
|
|
25379
|
+
isStream: isStream$1,
|
|
25380
25380
|
isURLSearchParams,
|
|
25381
25381
|
isTypedArray,
|
|
25382
25382
|
isFileList,
|
|
@@ -28761,6 +28761,80 @@
|
|
|
28761
28761
|
LogRecordType["API"] = "api-request";
|
|
28762
28762
|
})(LogRecordType || (LogRecordType = {}));
|
|
28763
28763
|
|
|
28764
|
+
function isStream(obj) {
|
|
28765
|
+
return (obj !== null &&
|
|
28766
|
+
typeof obj === 'object' &&
|
|
28767
|
+
typeof obj.pipe === 'function' &&
|
|
28768
|
+
(typeof obj.readable === 'boolean' || typeof obj.writable === 'boolean'));
|
|
28769
|
+
}
|
|
28770
|
+
function isBlob(value) {
|
|
28771
|
+
var _a;
|
|
28772
|
+
if (value === null || typeof value !== 'object') {
|
|
28773
|
+
return false;
|
|
28774
|
+
}
|
|
28775
|
+
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
28776
|
+
return true;
|
|
28777
|
+
}
|
|
28778
|
+
const obj = value;
|
|
28779
|
+
const hasRequiredProps = typeof obj.size === 'number' && typeof obj.type === 'string' && typeof obj.slice === 'function';
|
|
28780
|
+
if (!hasRequiredProps) {
|
|
28781
|
+
return false;
|
|
28782
|
+
}
|
|
28783
|
+
const hasBlobMethod = typeof obj.stream === 'function' || typeof obj.text === 'function' || typeof obj.arrayBuffer === 'function';
|
|
28784
|
+
if (hasBlobMethod) {
|
|
28785
|
+
return true;
|
|
28786
|
+
}
|
|
28787
|
+
const constructorName = (_a = obj.constructor) === null || _a === void 0 ? void 0 : _a.name;
|
|
28788
|
+
return constructorName === 'Blob' || constructorName === 'File';
|
|
28789
|
+
}
|
|
28790
|
+
function truncateData(data, depth = 0) {
|
|
28791
|
+
const maxArrayItems = 500;
|
|
28792
|
+
const maxObjectKeys = 500;
|
|
28793
|
+
const maxStringLength = 500;
|
|
28794
|
+
const maxDepth = 15;
|
|
28795
|
+
if (depth > maxDepth) {
|
|
28796
|
+
return '<max depth reached>';
|
|
28797
|
+
}
|
|
28798
|
+
if (!data) {
|
|
28799
|
+
return data;
|
|
28800
|
+
}
|
|
28801
|
+
else if (isStream(data)) {
|
|
28802
|
+
return '<stream>';
|
|
28803
|
+
}
|
|
28804
|
+
else if (Array.isArray(data)) {
|
|
28805
|
+
const result = data.slice(0, maxArrayItems).map((item) => truncateData(item, depth + 1));
|
|
28806
|
+
if (data.length > maxArrayItems) {
|
|
28807
|
+
result.push({
|
|
28808
|
+
'...moreItems': data.length - maxArrayItems,
|
|
28809
|
+
});
|
|
28810
|
+
}
|
|
28811
|
+
return result;
|
|
28812
|
+
}
|
|
28813
|
+
else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(data)) {
|
|
28814
|
+
return data.toString('utf-8').slice(0, maxStringLength);
|
|
28815
|
+
}
|
|
28816
|
+
else if (isBlob(data)) {
|
|
28817
|
+
return `<Blob: size=${data.size}, type=${data.type}>`;
|
|
28818
|
+
}
|
|
28819
|
+
else if (typeof data === 'object') {
|
|
28820
|
+
const keys = Object.keys(data);
|
|
28821
|
+
const result = {};
|
|
28822
|
+
for (const key of keys.slice(0, maxObjectKeys)) {
|
|
28823
|
+
result[key] = truncateData(data[key], depth + 1);
|
|
28824
|
+
}
|
|
28825
|
+
if (keys.length > maxObjectKeys) {
|
|
28826
|
+
result['...moreKeys'] = keys.slice(maxObjectKeys).join(', ').slice(0, maxStringLength);
|
|
28827
|
+
}
|
|
28828
|
+
return result;
|
|
28829
|
+
}
|
|
28830
|
+
else if (typeof data === 'string' && data.length > maxStringLength) {
|
|
28831
|
+
return `${data.slice(0, maxStringLength)}...`;
|
|
28832
|
+
}
|
|
28833
|
+
else {
|
|
28834
|
+
return data;
|
|
28835
|
+
}
|
|
28836
|
+
}
|
|
28837
|
+
|
|
28764
28838
|
class DependencyError extends MembraneError {
|
|
28765
28839
|
constructor(arg, workspaceElementReference) {
|
|
28766
28840
|
super(arg);
|
|
@@ -28823,8 +28897,8 @@
|
|
|
28823
28897
|
|
|
28824
28898
|
const axiosGlobal = ((axios$1$1 === null || axios$1$1 === void 0 ? void 0 : axios$1$1.default) || axios$1$1);
|
|
28825
28899
|
const axios = axiosGlobal.create();
|
|
28826
|
-
const DEFAULT_API_URI = 'https://api.
|
|
28827
|
-
const DEFAULT_UI_URI = 'https://
|
|
28900
|
+
const DEFAULT_API_URI = 'https://api.getmembrane.com';
|
|
28901
|
+
const DEFAULT_UI_URI = 'https://console.getmembrane.com';
|
|
28828
28902
|
const membraneClientOptionsSchema = object({
|
|
28829
28903
|
token: string$1().nullish(),
|
|
28830
28904
|
fetchToken: _function().nullish(),
|
|
@@ -28859,6 +28933,7 @@
|
|
|
28859
28933
|
}
|
|
28860
28934
|
class MembraneApiClient {
|
|
28861
28935
|
constructor(options = {}) {
|
|
28936
|
+
this.logs = [];
|
|
28862
28937
|
validateClientOptions(options);
|
|
28863
28938
|
const { uiUri, apiUri, accessToken, token, fetchToken, fetchCredentials, credentials } = options;
|
|
28864
28939
|
this.apiUri = apiUri !== null && apiUri !== void 0 ? apiUri : DEFAULT_API_URI;
|
|
@@ -28914,6 +28989,11 @@
|
|
|
28914
28989
|
async delete(uri, data, options) {
|
|
28915
28990
|
return this.makeApiRequest('DELETE', { ...(options !== null && options !== void 0 ? options : {}), url: uri, data });
|
|
28916
28991
|
}
|
|
28992
|
+
retrieveLogs() {
|
|
28993
|
+
const logs = [...this.logs];
|
|
28994
|
+
this.logs = [];
|
|
28995
|
+
return logs;
|
|
28996
|
+
}
|
|
28917
28997
|
async createEventSource(uri, queryParams) {
|
|
28918
28998
|
const token = await this.getToken();
|
|
28919
28999
|
const allParams = { ...queryParams, token };
|
|
@@ -28957,7 +29037,21 @@
|
|
|
28957
29037
|
};
|
|
28958
29038
|
}
|
|
28959
29039
|
async makeApiRequest(method, params = {}) {
|
|
29040
|
+
var _a, _b, _c, _d;
|
|
28960
29041
|
const token = await this.getToken();
|
|
29042
|
+
const url = (_a = params.url) !== null && _a !== void 0 ? _a : '';
|
|
29043
|
+
const requestWithoutCredentials = {
|
|
29044
|
+
method,
|
|
29045
|
+
url: `${this.apiUri}${url.startsWith('/') ? '' : '/'}${url}`,
|
|
29046
|
+
data: isStream(params.data) ? '<stream>' : truncateData(params.data),
|
|
29047
|
+
};
|
|
29048
|
+
const log = {
|
|
29049
|
+
type: LogRecordType.API,
|
|
29050
|
+
data: {
|
|
29051
|
+
request: requestWithoutCredentials,
|
|
29052
|
+
},
|
|
29053
|
+
};
|
|
29054
|
+
const startTime = new Date();
|
|
28961
29055
|
params.method = method;
|
|
28962
29056
|
params.baseURL = this.apiUri;
|
|
28963
29057
|
params.headers = {
|
|
@@ -28971,10 +29065,37 @@
|
|
|
28971
29065
|
response = await axios.request(params);
|
|
28972
29066
|
}
|
|
28973
29067
|
catch (err) {
|
|
29068
|
+
log.data.timeMs = new Date().getTime() - startTime.getTime();
|
|
29069
|
+
if (err.response) {
|
|
29070
|
+
log.data.response = {
|
|
29071
|
+
status: (_b = err.response) === null || _b === void 0 ? void 0 : _b.status,
|
|
29072
|
+
data: isStream((_c = err.response) === null || _c === void 0 ? void 0 : _c.data) ? '<stream>' : truncateData((_d = err.response) === null || _d === void 0 ? void 0 : _d.data),
|
|
29073
|
+
};
|
|
29074
|
+
}
|
|
29075
|
+
else {
|
|
29076
|
+
log.data.error = {
|
|
29077
|
+
type: typeof err,
|
|
29078
|
+
error: JSON.stringify(err, Object.getOwnPropertyNames(err)),
|
|
29079
|
+
};
|
|
29080
|
+
}
|
|
29081
|
+
this.log(log);
|
|
28974
29082
|
this.handleRequestError(err);
|
|
28975
29083
|
}
|
|
29084
|
+
log.data.response = {
|
|
29085
|
+
status: response.status,
|
|
29086
|
+
data: isStream(response.data) ? '<stream>' : truncateData(response.data),
|
|
29087
|
+
};
|
|
29088
|
+
log.data.timeMs = new Date().getTime() - startTime.getTime();
|
|
29089
|
+
this.log(log);
|
|
28976
29090
|
return response.data;
|
|
28977
29091
|
}
|
|
29092
|
+
log(logRecord) {
|
|
29093
|
+
var _a;
|
|
29094
|
+
this.logs.push(logRecord);
|
|
29095
|
+
if (typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.IS_CUSTOM_CODE_RUNNER)) {
|
|
29096
|
+
console.debug(JSON.stringify(logRecord));
|
|
29097
|
+
}
|
|
29098
|
+
}
|
|
28978
29099
|
handleRequestError(err) {
|
|
28979
29100
|
var _a, _b;
|
|
28980
29101
|
if (axiosGlobal.isAxiosError(err) && ((_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.type)) {
|