@membranehq/sdk 0.28.1 → 0.28.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/bundle.d.ts +47 -4
- package/dist/bundle.js +73 -7
- package/dist/bundle.js.map +1 -1
- package/dist/dts/accessors/actions-accessors.d.ts +1 -0
- package/dist/dts/accessors/connections-accessors.d.ts +2 -0
- package/dist/dts/accessors/integrations-accessors.d.ts +1 -0
- package/dist/dts/agent/session.d.ts +10 -1
- package/dist/dts/ai-gateway/models.d.ts +43 -0
- package/dist/dts/ai-gateway/models.test.d.ts +1 -0
- package/dist/dts/alerts/types.d.ts +7 -0
- package/dist/dts/api-client.d.ts +22 -3
- package/dist/dts/index.browser.d.ts +1 -0
- package/dist/dts/membrane-instances/types.d.ts +19 -35
- package/dist/dts/membrane-instances/types.test.d.ts +1 -0
- package/dist/dts/orgs/types.d.ts +55 -11
- package/dist/dts/webhooks/types.d.ts +3 -2
- package/dist/dts/workspace-elements/api/act-api.d.ts +33 -0
- package/dist/dts/workspace-elements/api/action-run-log-records-api.d.ts +2 -0
- package/dist/dts/workspace-elements/api/actions-api.d.ts +3 -0
- package/dist/dts/workspace-elements/api/connections-api.d.ts +9 -0
- package/dist/dts/workspace-elements/api/data-link-table-instances-api.d.ts +2 -0
- package/dist/dts/workspace-elements/api/data-sources-api.d.ts +4 -0
- package/dist/dts/workspace-elements/api/external-api-logs-api.d.ts +1 -0
- package/dist/dts/workspace-elements/api/external-event-log-records-api.d.ts +1 -0
- package/dist/dts/workspace-elements/api/external-event-pulls-api.d.ts +1 -0
- package/dist/dts/workspace-elements/api/external-event-subscriptions-api.d.ts +4 -1
- package/dist/dts/workspace-elements/api/field-mappings-api.d.ts +4 -0
- package/dist/dts/workspace-elements/api/flow-runs-api.d.ts +2 -0
- package/dist/dts/workspace-elements/api/flows-api.d.ts +3 -0
- package/dist/dts/workspace-elements/api/incoming-webhooks-api.d.ts +1 -0
- package/dist/dts/workspace-elements/api/index.d.ts +1 -0
- package/dist/dts/workspace-elements/api/integrations-api.d.ts +112 -0
- package/dist/dts/workspace-elements/api/packages-api.d.ts +1 -0
- package/dist/dts/workspace-elements/base/connection-requests/index.d.ts +2 -0
- package/dist/dts/workspace-elements/base/connections/index.d.ts +2 -0
- package/dist/dts/workspace-elements/types.d.ts +4 -1
- package/dist/dts/workspaces/api.d.ts +20 -0
- package/dist/dts/workspaces/compare.d.ts +2 -0
- package/dist/dts/workspaces/types.d.ts +29 -0
- package/dist/index.browser.d.mts +403 -55
- package/dist/index.browser.d.ts +403 -55
- package/dist/index.browser.js +230 -25
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +220 -26
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.mts +403 -55
- package/dist/index.node.d.ts +403 -55
- package/dist/index.node.js +230 -25
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +220 -26
- package/dist/index.node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -25,24 +25,42 @@ interface LogRecord {
|
|
|
25
25
|
data?: any;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
interface
|
|
29
|
-
token?: string;
|
|
30
|
-
fetchToken?: () => Promise<string>;
|
|
28
|
+
interface BaseClientOptions {
|
|
31
29
|
credentials?: any;
|
|
32
30
|
fetchCredentials?: () => Promise<any>;
|
|
33
31
|
apiUri?: string;
|
|
34
32
|
uiUri?: string;
|
|
33
|
+
}
|
|
34
|
+
interface TokenBasedClientOptions extends BaseClientOptions {
|
|
35
|
+
token?: string;
|
|
36
|
+
fetchToken?: () => Promise<string>;
|
|
37
|
+
workspaceKey?: never;
|
|
38
|
+
workspaceSecret?: never;
|
|
39
|
+
tenantKey?: never;
|
|
35
40
|
accessToken?: string;
|
|
36
41
|
}
|
|
42
|
+
interface WorkspaceCredentialClientOptions extends BaseClientOptions {
|
|
43
|
+
token?: never;
|
|
44
|
+
fetchToken?: never;
|
|
45
|
+
workspaceKey: string;
|
|
46
|
+
workspaceSecret: string;
|
|
47
|
+
tenantKey: string;
|
|
48
|
+
accessToken?: never;
|
|
49
|
+
}
|
|
50
|
+
type MembraneClientOptions = TokenBasedClientOptions | WorkspaceCredentialClientOptions;
|
|
37
51
|
declare class MembraneApiClient {
|
|
38
52
|
apiUri: string;
|
|
39
53
|
uiUri: string;
|
|
40
54
|
token?: string;
|
|
41
55
|
protected fetchToken?: () => Promise<string>;
|
|
42
56
|
private logs;
|
|
57
|
+
private _workspaceKey?;
|
|
58
|
+
private _workspaceSecret?;
|
|
59
|
+
private _tenantKey?;
|
|
43
60
|
constructor(options?: MembraneClientOptions);
|
|
44
61
|
setCredentials(credentials: any): Promise<any>;
|
|
45
62
|
getToken(): Promise<string>;
|
|
63
|
+
private mintToken;
|
|
46
64
|
get<T = any>(uri: string, queryParams?: Record<string, any>, options?: AxiosRequestConfig): Promise<T>;
|
|
47
65
|
post<T = any>(uri: string, data?: any, options?: AxiosRequestConfig): Promise<T>;
|
|
48
66
|
put<T = any>(uri: string, data?: any, options?: AxiosRequestConfig): Promise<T>;
|
|
@@ -129,7 +147,8 @@ declare enum WorkspaceElementState {
|
|
|
129
147
|
CLIENT_ACTION_REQUIRED = "CLIENT_ACTION_REQUIRED",
|
|
130
148
|
CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
|
|
131
149
|
SETUP_FAILED = "SETUP_FAILED",
|
|
132
|
-
READY = "READY"
|
|
150
|
+
READY = "READY",
|
|
151
|
+
DISCONNECTING = "DISCONNECTING"
|
|
133
152
|
}
|
|
134
153
|
|
|
135
154
|
interface BaseElementInstance {
|
|
@@ -370,6 +389,7 @@ declare const CreateConnectionRequest: z.ZodObject<{
|
|
|
370
389
|
name: z.ZodOptional<z.ZodString>;
|
|
371
390
|
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
372
391
|
authOptionKey: z.ZodOptional<z.ZodString>;
|
|
392
|
+
key: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
373
393
|
integrationId: z.ZodOptional<z.ZodString>;
|
|
374
394
|
integrationUuid: z.ZodOptional<z.ZodString>;
|
|
375
395
|
integrationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -389,6 +409,7 @@ declare const UpdateConnectionRequest: z.ZodObject<{
|
|
|
389
409
|
name: z.ZodOptional<z.ZodString>;
|
|
390
410
|
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
391
411
|
authOptionKey: z.ZodOptional<z.ZodString>;
|
|
412
|
+
key: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
392
413
|
integrationId: z.ZodOptional<z.ZodString>;
|
|
393
414
|
integrationUuid: z.ZodOptional<z.ZodString>;
|
|
394
415
|
integrationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -409,11 +430,13 @@ declare const ConnectionSelector: z.ZodObject<{
|
|
|
409
430
|
integrationKey: z.ZodOptional<z.ZodString>;
|
|
410
431
|
integrationId: z.ZodOptional<z.ZodString>;
|
|
411
432
|
connectionId: z.ZodOptional<z.ZodString>;
|
|
433
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
412
434
|
}, z.core.$strip>;
|
|
413
435
|
type ConnectionSelector = z.infer<typeof ConnectionSelector>;
|
|
414
436
|
declare const ConnectionApiResponse: z.ZodObject<{
|
|
415
437
|
id: z.ZodString;
|
|
416
438
|
name: z.ZodString;
|
|
439
|
+
key: z.ZodOptional<z.ZodString>;
|
|
417
440
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
418
441
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
419
442
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -521,6 +544,7 @@ declare const ConnectPayload: z.ZodObject<{
|
|
|
521
544
|
connectorKey: z.ZodOptional<z.ZodString>;
|
|
522
545
|
connectorVersion: z.ZodOptional<z.ZodString>;
|
|
523
546
|
connectionId: z.ZodOptional<z.ZodString>;
|
|
547
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
524
548
|
name: z.ZodOptional<z.ZodString>;
|
|
525
549
|
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
526
550
|
connectionParameters: z.ZodOptional<z.ZodAny>;
|
|
@@ -539,6 +563,7 @@ declare const ConnectUIOptions: z.ZodObject<{
|
|
|
539
563
|
integrationKey: z.ZodOptional<z.ZodString>;
|
|
540
564
|
name: z.ZodOptional<z.ZodString>;
|
|
541
565
|
intent: z.ZodOptional<z.ZodString>;
|
|
566
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
542
567
|
authOptionKey: z.ZodOptional<z.ZodString>;
|
|
543
568
|
connectorParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
544
569
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
@@ -798,6 +823,7 @@ declare const FindActionsQuery: z.ZodObject<{
|
|
|
798
823
|
integrationKey: z.ZodOptional<z.ZodString>;
|
|
799
824
|
integrationId: z.ZodOptional<z.ZodString>;
|
|
800
825
|
connectionId: z.ZodOptional<z.ZodString>;
|
|
826
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
801
827
|
instanceKey: z.ZodOptional<z.ZodString>;
|
|
802
828
|
search: z.ZodOptional<z.ZodString>;
|
|
803
829
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
@@ -942,6 +968,7 @@ declare class ActionAccessor<RunInput = any, RunOutput = any> extends ElementAcc
|
|
|
942
968
|
run(input?: RunInput, options?: {
|
|
943
969
|
integrationKey?: string;
|
|
944
970
|
connectionId?: string;
|
|
971
|
+
connectionKey?: string;
|
|
945
972
|
}): Promise<ActionRunResponse<RunOutput>>;
|
|
946
973
|
}
|
|
947
974
|
declare class IntegrationLevelActionAccessor extends IntegrationLevelElementAccessor<ActionApiResponse, UpdateActionRequest> {
|
|
@@ -3633,6 +3660,7 @@ declare const FlowRunApiResponse: z.ZodObject<{
|
|
|
3633
3660
|
connection: z.ZodOptional<z.ZodObject<{
|
|
3634
3661
|
id: z.ZodString;
|
|
3635
3662
|
name: z.ZodString;
|
|
3663
|
+
key: z.ZodOptional<z.ZodString>;
|
|
3636
3664
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
3637
3665
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
3638
3666
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -3837,6 +3865,7 @@ declare const FindFlowRunsResponse: z.ZodObject<{
|
|
|
3837
3865
|
connection: z.ZodOptional<z.ZodObject<{
|
|
3838
3866
|
id: z.ZodString;
|
|
3839
3867
|
name: z.ZodString;
|
|
3868
|
+
key: z.ZodOptional<z.ZodString>;
|
|
3840
3869
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
3841
3870
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
3842
3871
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -4191,6 +4220,7 @@ declare const FlowApiResponse: z.ZodObject<{
|
|
|
4191
4220
|
connection: z.ZodOptional<z.ZodObject<{
|
|
4192
4221
|
id: z.ZodString;
|
|
4193
4222
|
name: z.ZodString;
|
|
4223
|
+
key: z.ZodOptional<z.ZodString>;
|
|
4194
4224
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
4195
4225
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
4196
4226
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -4316,6 +4346,7 @@ declare const FindFlowsQuery: z.ZodObject<{
|
|
|
4316
4346
|
integration: "integration";
|
|
4317
4347
|
universal: "universal";
|
|
4318
4348
|
}>>;
|
|
4349
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
4319
4350
|
universalParentId: z.ZodOptional<z.ZodString>;
|
|
4320
4351
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
4321
4352
|
flowId: z.ZodOptional<z.ZodString>;
|
|
@@ -4875,6 +4906,7 @@ declare const DataSourceApiResponse: z.ZodObject<{
|
|
|
4875
4906
|
connection: z.ZodOptional<z.ZodObject<{
|
|
4876
4907
|
id: z.ZodString;
|
|
4877
4908
|
name: z.ZodString;
|
|
4909
|
+
key: z.ZodOptional<z.ZodString>;
|
|
4878
4910
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
4879
4911
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
4880
4912
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -5083,6 +5115,7 @@ declare const FindDataSourcesQuery: z.ZodObject<{
|
|
|
5083
5115
|
integration: "integration";
|
|
5084
5116
|
universal: "universal";
|
|
5085
5117
|
}>>;
|
|
5118
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
5086
5119
|
universalParentId: z.ZodOptional<z.ZodString>;
|
|
5087
5120
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
5088
5121
|
dataSourceId: z.ZodOptional<z.ZodString>;
|
|
@@ -5238,6 +5271,9 @@ declare const UpdateIntegrationRequest: z.ZodObject<{
|
|
|
5238
5271
|
type UpdateIntegrationRequest = z.infer<typeof UpdateIntegrationRequest>;
|
|
5239
5272
|
declare const FindIntegrationsQuery: z.ZodObject<{
|
|
5240
5273
|
appUuid: z.ZodOptional<z.ZodString>;
|
|
5274
|
+
connectors: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
5275
|
+
externalApps: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
5276
|
+
websearch: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
5241
5277
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
5242
5278
|
cursor: z.ZodOptional<z.ZodString>;
|
|
5243
5279
|
search: z.ZodOptional<z.ZodString>;
|
|
@@ -5297,6 +5333,7 @@ declare const IntegrationApiResponse: z.ZodObject<{
|
|
|
5297
5333
|
connection: z.ZodOptional<z.ZodObject<{
|
|
5298
5334
|
id: z.ZodString;
|
|
5299
5335
|
name: z.ZodString;
|
|
5336
|
+
key: z.ZodOptional<z.ZodString>;
|
|
5300
5337
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
5301
5338
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
5302
5339
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -5360,6 +5397,7 @@ declare const FindPackagesQuery: z.ZodObject<{
|
|
|
5360
5397
|
integrationKey: z.ZodOptional<z.ZodString>;
|
|
5361
5398
|
integrationId: z.ZodOptional<z.ZodString>;
|
|
5362
5399
|
connectionId: z.ZodOptional<z.ZodString>;
|
|
5400
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
5363
5401
|
instanceKey: z.ZodOptional<z.ZodString>;
|
|
5364
5402
|
search: z.ZodOptional<z.ZodString>;
|
|
5365
5403
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
@@ -5807,6 +5845,7 @@ declare const FieldMappingApiResponse: z.ZodObject<{
|
|
|
5807
5845
|
connection: z.ZodOptional<z.ZodObject<{
|
|
5808
5846
|
id: z.ZodString;
|
|
5809
5847
|
name: z.ZodString;
|
|
5848
|
+
key: z.ZodOptional<z.ZodString>;
|
|
5810
5849
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
5811
5850
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
5812
5851
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -5913,6 +5952,7 @@ declare const FindFieldMappingsQuery: z.ZodObject<{
|
|
|
5913
5952
|
integration: "integration";
|
|
5914
5953
|
universal: "universal";
|
|
5915
5954
|
}>>;
|
|
5955
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
5916
5956
|
universalParentId: z.ZodOptional<z.ZodString>;
|
|
5917
5957
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
5918
5958
|
fieldMappingId: z.ZodOptional<z.ZodString>;
|
|
@@ -6369,6 +6409,7 @@ declare const ExternalEventSubscriptionApiResponse: z.ZodObject<{
|
|
|
6369
6409
|
connection: z.ZodOptional<z.ZodObject<{
|
|
6370
6410
|
id: z.ZodString;
|
|
6371
6411
|
name: z.ZodString;
|
|
6412
|
+
key: z.ZodOptional<z.ZodString>;
|
|
6372
6413
|
isTest: z.ZodOptional<z.ZodBoolean>;
|
|
6373
6414
|
connected: z.ZodOptional<z.ZodBoolean>;
|
|
6374
6415
|
disconnected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -6620,6 +6661,7 @@ declare class ConnectionAccessor {
|
|
|
6620
6661
|
createdAt: string;
|
|
6621
6662
|
updatedAt: string;
|
|
6622
6663
|
userId: string;
|
|
6664
|
+
key?: string | undefined;
|
|
6623
6665
|
isTest?: boolean | undefined;
|
|
6624
6666
|
connected?: boolean | undefined;
|
|
6625
6667
|
disconnected?: boolean | undefined;
|
|
@@ -6857,6 +6899,7 @@ declare class IntegrationAccessor extends ElementAccessor<IntegrationApiResponse
|
|
|
6857
6899
|
createdAt: string;
|
|
6858
6900
|
updatedAt: string;
|
|
6859
6901
|
userId: string;
|
|
6902
|
+
key?: string | undefined;
|
|
6860
6903
|
isTest?: boolean | undefined;
|
|
6861
6904
|
connected?: boolean | undefined;
|
|
6862
6905
|
disconnected?: boolean | undefined;
|
package/dist/bundle.js
CHANGED
|
@@ -20675,6 +20675,7 @@
|
|
|
20675
20675
|
? {
|
|
20676
20676
|
integrationKey: options.integrationKey,
|
|
20677
20677
|
connectionId: options.connectionId,
|
|
20678
|
+
connectionKey: options.connectionKey,
|
|
20678
20679
|
}
|
|
20679
20680
|
: {};
|
|
20680
20681
|
return this.options.client.post(this.getPath('run'), { input }, { params: queryParams });
|
|
@@ -22259,6 +22260,7 @@
|
|
|
22259
22260
|
WorkspaceElementState["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
|
|
22260
22261
|
WorkspaceElementState["SETUP_FAILED"] = "SETUP_FAILED";
|
|
22261
22262
|
WorkspaceElementState["READY"] = "READY";
|
|
22263
|
+
WorkspaceElementState["DISCONNECTING"] = "DISCONNECTING";
|
|
22262
22264
|
})(WorkspaceElementState || (WorkspaceElementState = {}));
|
|
22263
22265
|
var WorkspaceElementDependencyType;
|
|
22264
22266
|
(function (WorkspaceElementDependencyType) {
|
|
@@ -22377,6 +22379,11 @@
|
|
|
22377
22379
|
filterTitle: 'Connection',
|
|
22378
22380
|
referenceElementType: WorkspaceElementType.Connection,
|
|
22379
22381
|
}),
|
|
22382
|
+
connectionKey: string$1()
|
|
22383
|
+
.optional()
|
|
22384
|
+
.meta({
|
|
22385
|
+
hidden: true,
|
|
22386
|
+
}),
|
|
22380
22387
|
instanceKey: string$1()
|
|
22381
22388
|
.optional()
|
|
22382
22389
|
.meta({
|
|
@@ -22942,7 +22949,7 @@
|
|
|
22942
22949
|
}
|
|
22943
22950
|
}
|
|
22944
22951
|
async function createOrUpdateConnection(options) {
|
|
22945
|
-
const { client, connectionId, integrationKey, integrationId, connectorId, connectorVersion, name, input, connectorParameters, allowMultipleConnections, authOptionKey, connectionRequestId, apiUri, redirectUri, onPopupClosed, } = options !== null && options !== void 0 ? options : {};
|
|
22952
|
+
const { client, connectionId, connectionKey, integrationKey, integrationId, connectorId, connectorVersion, name, input, connectorParameters, allowMultipleConnections, authOptionKey, connectionRequestId, apiUri, redirectUri, onPopupClosed, } = options !== null && options !== void 0 ? options : {};
|
|
22946
22953
|
let connectionType = await detectConnectionType(options);
|
|
22947
22954
|
if (redirectUri) {
|
|
22948
22955
|
connectionType = ConnectionType.REDIRECT;
|
|
@@ -22960,6 +22967,7 @@
|
|
|
22960
22967
|
connectorId,
|
|
22961
22968
|
connectorVersion,
|
|
22962
22969
|
connectionId,
|
|
22970
|
+
connectionKey,
|
|
22963
22971
|
name,
|
|
22964
22972
|
authOptionKey,
|
|
22965
22973
|
allowMultipleConnections,
|
|
@@ -26605,7 +26613,7 @@
|
|
|
26605
26613
|
Response,
|
|
26606
26614
|
}))(utils$1.global);
|
|
26607
26615
|
|
|
26608
|
-
const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
|
|
26616
|
+
const { ReadableStream: ReadableStream$1, TextEncoder: TextEncoder$1 } = utils$1.global;
|
|
26609
26617
|
|
|
26610
26618
|
const test = (fn, ...args) => {
|
|
26611
26619
|
try {
|
|
@@ -26637,11 +26645,11 @@
|
|
|
26637
26645
|
|
|
26638
26646
|
const encodeText =
|
|
26639
26647
|
isFetchSupported &&
|
|
26640
|
-
(typeof TextEncoder === 'function'
|
|
26648
|
+
(typeof TextEncoder$1 === 'function'
|
|
26641
26649
|
? (
|
|
26642
26650
|
(encoder) => (str) =>
|
|
26643
26651
|
encoder.encode(str)
|
|
26644
|
-
)(new TextEncoder())
|
|
26652
|
+
)(new TextEncoder$1())
|
|
26645
26653
|
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
26646
26654
|
|
|
26647
26655
|
const supportsRequestStream =
|
|
@@ -28172,6 +28180,9 @@
|
|
|
28172
28180
|
apiUri: string$1().nullish(),
|
|
28173
28181
|
uiUri: string$1().nullish(),
|
|
28174
28182
|
accessToken: string$1().nullish(),
|
|
28183
|
+
workspaceKey: string$1().nullish(),
|
|
28184
|
+
workspaceSecret: string$1().nullish(),
|
|
28185
|
+
tenantKey: string$1().nullish(),
|
|
28175
28186
|
})
|
|
28176
28187
|
.strict();
|
|
28177
28188
|
function validateClientOptions(options) {
|
|
@@ -28186,6 +28197,8 @@
|
|
|
28186
28197
|
}
|
|
28187
28198
|
}
|
|
28188
28199
|
const REFETCH_EXPIRATION_THRESHOLD = 10 * 1000;
|
|
28200
|
+
const TOKEN_TTL_SECONDS = 3600;
|
|
28201
|
+
const TOKEN_MINT_THRESHOLD_SECONDS = 60;
|
|
28189
28202
|
function decodeToken(token) {
|
|
28190
28203
|
if (token.startsWith('pat-')) {
|
|
28191
28204
|
return null;
|
|
@@ -28200,11 +28213,25 @@
|
|
|
28200
28213
|
constructor(options = {}) {
|
|
28201
28214
|
this.logs = [];
|
|
28202
28215
|
validateClientOptions(options);
|
|
28203
|
-
const { uiUri, apiUri,
|
|
28216
|
+
const { uiUri, apiUri, fetchCredentials, credentials } = options;
|
|
28204
28217
|
this.apiUri = apiUri !== null && apiUri !== void 0 ? apiUri : DEFAULT_API_URI;
|
|
28205
28218
|
this.uiUri = uiUri !== null && uiUri !== void 0 ? uiUri : DEFAULT_UI_URI;
|
|
28206
|
-
|
|
28207
|
-
|
|
28219
|
+
if ('workspaceSecret' in options && options.workspaceSecret) {
|
|
28220
|
+
if (typeof window !== 'undefined') {
|
|
28221
|
+
throw new Error('MembraneClient: workspaceSecret must not be used in browser code. ' +
|
|
28222
|
+
'The workspace secret is a server-side credential that would be exposed to end users if included in a browser bundle.');
|
|
28223
|
+
}
|
|
28224
|
+
this._workspaceKey = options.workspaceKey;
|
|
28225
|
+
this._workspaceSecret = options.workspaceSecret;
|
|
28226
|
+
this._tenantKey = options.tenantKey;
|
|
28227
|
+
}
|
|
28228
|
+
else {
|
|
28229
|
+
const token = 'token' in options ? options.token : undefined;
|
|
28230
|
+
const accessToken = 'accessToken' in options ? options.accessToken : undefined;
|
|
28231
|
+
const fetchToken = 'fetchToken' in options ? options.fetchToken : undefined;
|
|
28232
|
+
this.token = token !== null && token !== void 0 ? token : accessToken;
|
|
28233
|
+
this.fetchToken = fetchToken;
|
|
28234
|
+
}
|
|
28208
28235
|
if (fetchCredentials) {
|
|
28209
28236
|
void fetchCredentials().then((c) => this.setCredentials(c));
|
|
28210
28237
|
}
|
|
@@ -28216,6 +28243,9 @@
|
|
|
28216
28243
|
return this.patch('/self', { credentials });
|
|
28217
28244
|
}
|
|
28218
28245
|
async getToken() {
|
|
28246
|
+
if (this._workspaceSecret) {
|
|
28247
|
+
return this.mintToken();
|
|
28248
|
+
}
|
|
28219
28249
|
if (this.fetchToken) {
|
|
28220
28250
|
if (!this.token) {
|
|
28221
28251
|
this.token = await this.fetchToken();
|
|
@@ -28236,6 +28266,38 @@
|
|
|
28236
28266
|
decodeToken(this.token);
|
|
28237
28267
|
return this.token;
|
|
28238
28268
|
}
|
|
28269
|
+
async mintToken() {
|
|
28270
|
+
if (this.token) {
|
|
28271
|
+
const payload = decodeToken(this.token);
|
|
28272
|
+
if (payload === null || payload === void 0 ? void 0 : payload.exp) {
|
|
28273
|
+
const remainingSeconds = payload.exp - Math.floor(Date.now() / 1000);
|
|
28274
|
+
if (remainingSeconds > TOKEN_MINT_THRESHOLD_SECONDS) {
|
|
28275
|
+
return this.token;
|
|
28276
|
+
}
|
|
28277
|
+
}
|
|
28278
|
+
}
|
|
28279
|
+
const payload = {
|
|
28280
|
+
id: this._tenantKey,
|
|
28281
|
+
iss: this._workspaceKey,
|
|
28282
|
+
exp: Math.floor(Date.now() / 1000) + TOKEN_TTL_SECONDS,
|
|
28283
|
+
};
|
|
28284
|
+
const header = { alg: 'HS256', typ: 'JWT' };
|
|
28285
|
+
const encoder = new TextEncoder();
|
|
28286
|
+
const toB64Url = (bytes) => {
|
|
28287
|
+
let s = '';
|
|
28288
|
+
for (let i = 0; i < bytes.length; i++)
|
|
28289
|
+
s += String.fromCharCode(bytes[i]);
|
|
28290
|
+
return btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
28291
|
+
};
|
|
28292
|
+
const headerB64 = toB64Url(encoder.encode(JSON.stringify(header)));
|
|
28293
|
+
const payloadB64 = toB64Url(encoder.encode(JSON.stringify(payload)));
|
|
28294
|
+
const input = `${headerB64}.${payloadB64}`;
|
|
28295
|
+
const key = await crypto.subtle.importKey('raw', encoder.encode(this._workspaceSecret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
28296
|
+
const signatureBuffer = await crypto.subtle.sign('HMAC', key, encoder.encode(input));
|
|
28297
|
+
const signature = toB64Url(new Uint8Array(signatureBuffer));
|
|
28298
|
+
this.token = `${input}.${signature}`;
|
|
28299
|
+
return this.token;
|
|
28300
|
+
}
|
|
28239
28301
|
async get(uri, queryParams, options) {
|
|
28240
28302
|
if (queryParams) {
|
|
28241
28303
|
uri += `${uri.includes('?') ? '&' : '?'}${new URLSearchParams(omitBy(queryParams, isEmptyValue)).toString()}`;
|
|
@@ -28434,6 +28496,7 @@
|
|
|
28434
28496
|
name: string$1().optional(),
|
|
28435
28497
|
meta: record(string$1(), any()).optional(),
|
|
28436
28498
|
authOptionKey: string$1().optional(),
|
|
28499
|
+
key: string$1().min(1).max(100).optional().nullable(),
|
|
28437
28500
|
integrationId: string$1().optional(),
|
|
28438
28501
|
integrationUuid: string$1().optional(),
|
|
28439
28502
|
integrationKey: string$1().optional(),
|
|
@@ -28456,6 +28519,7 @@
|
|
|
28456
28519
|
const BaseConnection = BaseWorkspaceElement.extend({
|
|
28457
28520
|
...TenantLayerElement.shape,
|
|
28458
28521
|
name: string$1(),
|
|
28522
|
+
key: string$1().optional(),
|
|
28459
28523
|
isTest: boolean$1().optional(),
|
|
28460
28524
|
connected: boolean$1().optional(),
|
|
28461
28525
|
disconnected: boolean$1().optional().describe('[DEPRECATED] Use `connected` instead.'),
|
|
@@ -29613,6 +29677,7 @@
|
|
|
29613
29677
|
integrationKey: string$1().optional(),
|
|
29614
29678
|
integrationId: string$1().optional(),
|
|
29615
29679
|
connectionId: string$1().optional(),
|
|
29680
|
+
connectionKey: string$1().optional(),
|
|
29616
29681
|
});
|
|
29617
29682
|
const ConnectionApiResponse = BaseConnection.extend({
|
|
29618
29683
|
user: BaseCustomer.optional(),
|
|
@@ -29656,6 +29721,7 @@
|
|
|
29656
29721
|
connectorKey: string$1().optional(),
|
|
29657
29722
|
connectorVersion: string$1().optional(),
|
|
29658
29723
|
connectionId: string$1().optional(),
|
|
29724
|
+
connectionKey: string$1().min(1).max(100).optional(),
|
|
29659
29725
|
name: string$1().optional(),
|
|
29660
29726
|
input: record(string$1(), unknown()).optional(),
|
|
29661
29727
|
connectionParameters: any().optional().describe('[INTERNAL] Deprecated: Use input instead'),
|