@membranehq/sdk 0.17.1 → 0.17.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 +2 -1
- package/dist/bundle.js +4 -2
- package/dist/bundle.js.map +1 -1
- package/dist/dts/client-tokens/types.d.ts +21 -2
- package/dist/dts/oauth/types.d.ts +2 -2
- package/dist/dts/workspace-elements/api/connected-products-api.d.ts +83 -0
- package/dist/dts/workspace-elements/api/index.d.ts +1 -0
- package/dist/dts/workspace-elements/base/connected-products/index.d.ts +58 -0
- package/dist/dts/workspace-elements/base/connection-requests/index.d.ts +2 -0
- package/dist/dts/workspace-elements/base/index.d.ts +1 -0
- package/dist/dts/workspace-elements/types.d.ts +2 -1
- package/dist/dts/workspaces/compare.d.ts +7 -0
- package/dist/index.browser.d.mts +177 -7
- package/dist/index.browser.d.ts +177 -7
- package/dist/index.browser.js +128 -21
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +99 -22
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.mts +177 -7
- package/dist/index.node.d.ts +177 -7
- package/dist/index.node.js +110 -23
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +99 -23
- package/dist/index.node.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.node.js
CHANGED
|
@@ -8,13 +8,14 @@ var deepEqual = require('fast-deep-equal');
|
|
|
8
8
|
var structuredClonePolyfill = require('@ungap/structured-clone');
|
|
9
9
|
var urljoin = require('url-join');
|
|
10
10
|
var v4 = require('zod-validation-error/v4');
|
|
11
|
+
var diff = require('diff');
|
|
12
|
+
var yaml = require('js-yaml');
|
|
11
13
|
var qs = require('qs');
|
|
12
14
|
var penpal = require('penpal');
|
|
13
15
|
var axiosOriginal = require('axios');
|
|
14
16
|
var zodValidationError = require('zod-validation-error');
|
|
15
17
|
var fs = require('fs');
|
|
16
18
|
var path = require('path');
|
|
17
|
-
var yaml = require('js-yaml');
|
|
18
19
|
|
|
19
20
|
function _interopNamespaceDefault(e) {
|
|
20
21
|
var n = Object.create(null);
|
|
@@ -33,9 +34,9 @@ function _interopNamespaceDefault(e) {
|
|
|
33
34
|
return Object.freeze(n);
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
var yaml__namespace = /*#__PURE__*/_interopNamespaceDefault(yaml);
|
|
36
38
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
37
39
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
38
|
-
var yaml__namespace = /*#__PURE__*/_interopNamespaceDefault(yaml);
|
|
39
40
|
|
|
40
41
|
exports.ErrorType = void 0;
|
|
41
42
|
(function (ErrorType) {
|
|
@@ -3495,6 +3496,7 @@ exports.WorkspaceElementType = void 0;
|
|
|
3495
3496
|
WorkspaceElementType["ExternalEventPull"] = "external-event-pull";
|
|
3496
3497
|
WorkspaceElementType["Screen"] = "screen";
|
|
3497
3498
|
WorkspaceElementType["ActionRunLogRecord"] = "action-run-log-record";
|
|
3499
|
+
WorkspaceElementType["ConnectedProduct"] = "connected-product";
|
|
3498
3500
|
})(exports.WorkspaceElementType || (exports.WorkspaceElementType = {}));
|
|
3499
3501
|
exports.WorkspaceEventType = void 0;
|
|
3500
3502
|
(function (WorkspaceEventType) {
|
|
@@ -3962,6 +3964,7 @@ const CreateConnectionRequestPayload = z.z.object({
|
|
|
3962
3964
|
name: z.z.string().optional(),
|
|
3963
3965
|
allowMultipleConnections: z.z.boolean().optional(),
|
|
3964
3966
|
connectorParameters: z.z.record(z.z.string(), z.z.unknown()).optional(),
|
|
3967
|
+
redirectUri: z.z.string().url().optional(),
|
|
3965
3968
|
});
|
|
3966
3969
|
const ConnectionRequest = z.z.object({
|
|
3967
3970
|
requestId: z.z.string(),
|
|
@@ -3974,6 +3977,7 @@ const ConnectionRequest = z.z.object({
|
|
|
3974
3977
|
name: z.z.string().optional(),
|
|
3975
3978
|
allowMultipleConnections: z.z.boolean().optional(),
|
|
3976
3979
|
connectorParameters: z.z.record(z.z.string(), z.z.unknown()).optional(),
|
|
3980
|
+
redirectUri: z.z.string().url().optional(),
|
|
3977
3981
|
status: z.z.enum(['pending', 'success', 'cancelled', 'error']),
|
|
3978
3982
|
resultConnectionId: z.z.string().optional(),
|
|
3979
3983
|
resultError: ErrorDataSchema.optional(),
|
|
@@ -10142,6 +10146,26 @@ const BaseActionRunLogRecord = ActivityLogRecord.extend({
|
|
|
10142
10146
|
meta: z.z.record(z.z.string(), z.z.any()).optional(),
|
|
10143
10147
|
});
|
|
10144
10148
|
|
|
10149
|
+
const ConnectedProductType = z.z.enum(['ai-agent', 'app']);
|
|
10150
|
+
const ConnectedProductAudience = z.z.enum(['personal', 'customers']);
|
|
10151
|
+
const AiAgentAudience = ConnectedProductAudience;
|
|
10152
|
+
const AiAgentType = z.z.enum(['openclaw', 'claude', 'chatgpt', 'custom']);
|
|
10153
|
+
const AiAgentParameters = z.z.object({
|
|
10154
|
+
agentType: AiAgentType.optional(),
|
|
10155
|
+
});
|
|
10156
|
+
const BaseConnectedProduct = z.z.object({
|
|
10157
|
+
id: z.z.string(),
|
|
10158
|
+
name: z.z.string(),
|
|
10159
|
+
key: z.z.string(),
|
|
10160
|
+
type: ConnectedProductType,
|
|
10161
|
+
audience: ConnectedProductAudience.optional(),
|
|
10162
|
+
parameters: AiAgentParameters.optional(),
|
|
10163
|
+
isConnected: z.z.boolean().optional(),
|
|
10164
|
+
lastApiRequestDate: z.z.string().optional(),
|
|
10165
|
+
createdAt: z.z.string().optional(),
|
|
10166
|
+
archivedAt: z.z.string().optional(),
|
|
10167
|
+
});
|
|
10168
|
+
|
|
10145
10169
|
const ActionApiResponse = BaseAction.extend({
|
|
10146
10170
|
integration: BaseIntegration.optional(),
|
|
10147
10171
|
user: BaseCustomer.optional(),
|
|
@@ -11265,6 +11289,29 @@ const IncomingWebhookApiResponse = z.z.object({
|
|
|
11265
11289
|
subscription: BaseExternalEventSubscription.optional(),
|
|
11266
11290
|
});
|
|
11267
11291
|
|
|
11292
|
+
const CreateConnectedProductRequest = z.z.object({
|
|
11293
|
+
name: z.z.string(),
|
|
11294
|
+
type: ConnectedProductType,
|
|
11295
|
+
audience: ConnectedProductAudience.optional(),
|
|
11296
|
+
parameters: AiAgentParameters.optional(),
|
|
11297
|
+
});
|
|
11298
|
+
const UpdateConnectedProductRequest = z.z.object({
|
|
11299
|
+
name: z.z.string().optional(),
|
|
11300
|
+
type: ConnectedProductType.optional(),
|
|
11301
|
+
audience: ConnectedProductAudience.optional(),
|
|
11302
|
+
parameters: AiAgentParameters.optional(),
|
|
11303
|
+
});
|
|
11304
|
+
const FindConnectedProductsQuery = z.z
|
|
11305
|
+
.object({
|
|
11306
|
+
type: ConnectedProductType.optional(),
|
|
11307
|
+
audience: ConnectedProductAudience.optional(),
|
|
11308
|
+
key: z.z.string().optional(),
|
|
11309
|
+
})
|
|
11310
|
+
.merge(PaginationQuery)
|
|
11311
|
+
.merge(SearchQuery)
|
|
11312
|
+
.merge(IncludeArchivedQuery);
|
|
11313
|
+
const ConnectedProductApiResponse = BaseConnectedProduct;
|
|
11314
|
+
|
|
11268
11315
|
class DependencyError extends MembraneError {
|
|
11269
11316
|
constructor(arg, workspaceElementReference) {
|
|
11270
11317
|
super(arg);
|
|
@@ -11860,6 +11907,13 @@ const WorkspaceElementSpecs = {
|
|
|
11860
11907
|
hasKey: true,
|
|
11861
11908
|
isProOnly: true,
|
|
11862
11909
|
},
|
|
11910
|
+
[exports.WorkspaceElementType.ConnectedProduct]: {
|
|
11911
|
+
type: exports.WorkspaceElementType.ConnectedProduct,
|
|
11912
|
+
apiPath: 'connected-products',
|
|
11913
|
+
name: 'Connected Product',
|
|
11914
|
+
namePlural: 'Connected Products',
|
|
11915
|
+
hasKey: true,
|
|
11916
|
+
},
|
|
11863
11917
|
};
|
|
11864
11918
|
function getEditablePathsForElementType(elementType) {
|
|
11865
11919
|
return getEditablePathsForElementType$1(WorkspaceElementSpecs, elementType);
|
|
@@ -12836,13 +12890,14 @@ exports.WorkspaceElementChangeType = void 0;
|
|
|
12836
12890
|
WorkspaceElementChangeType["DELETE"] = "delete";
|
|
12837
12891
|
})(exports.WorkspaceElementChangeType || (exports.WorkspaceElementChangeType = {}));
|
|
12838
12892
|
function compareWorkspaceExports(baseExport, targetExport, options = { includeDeletions: true }) {
|
|
12839
|
-
const changes =
|
|
12893
|
+
const changes = {};
|
|
12840
12894
|
const comparison = {
|
|
12841
12895
|
[exports.WorkspaceElementChangeType.CREATE]: new Set(),
|
|
12842
12896
|
[exports.WorkspaceElementChangeType.UPDATE]: new Set(),
|
|
12843
12897
|
[exports.WorkspaceElementChangeType.DELETE]: new Set(),
|
|
12844
12898
|
};
|
|
12845
12899
|
const sourceUuidByTargetUuid = new Map();
|
|
12900
|
+
const diffs = [];
|
|
12846
12901
|
const integrationMap = buildIntegrationsMap([
|
|
12847
12902
|
...(baseExport[exports.WorkspaceElementType.Integration] || []),
|
|
12848
12903
|
...(targetExport[exports.WorkspaceElementType.Integration] || []),
|
|
@@ -12857,35 +12912,46 @@ function compareWorkspaceExports(baseExport, targetExport, options = { includeDe
|
|
|
12857
12912
|
for (const element of baseElements) {
|
|
12858
12913
|
const intIdentifier = getIntegrationIdentifier(element, integrationMap);
|
|
12859
12914
|
const selector = getElementSelector(type, element.key, intIdentifier);
|
|
12860
|
-
baseMap.set(selector, element);
|
|
12915
|
+
baseMap.set(selector, { type, element });
|
|
12861
12916
|
allSelectors.add(selector);
|
|
12862
12917
|
}
|
|
12863
12918
|
const targetElements = targetExport[type] || [];
|
|
12864
12919
|
for (const element of targetElements) {
|
|
12865
12920
|
const intIdentifier = getIntegrationIdentifier(element, integrationMap);
|
|
12866
12921
|
const selector = getElementSelector(type, element.key, intIdentifier);
|
|
12867
|
-
targetMap.set(selector, element);
|
|
12922
|
+
targetMap.set(selector, { type, element });
|
|
12868
12923
|
allSelectors.add(selector);
|
|
12869
12924
|
}
|
|
12870
12925
|
}
|
|
12871
12926
|
for (const selector of allSelectors) {
|
|
12872
|
-
const
|
|
12873
|
-
const
|
|
12874
|
-
if (
|
|
12875
|
-
sourceUuidByTargetUuid.set(
|
|
12927
|
+
const base = baseMap.get(selector);
|
|
12928
|
+
const target = targetMap.get(selector);
|
|
12929
|
+
if (base && target && base.element.uuid !== target.element.uuid) {
|
|
12930
|
+
sourceUuidByTargetUuid.set(target.element.uuid, base.element.uuid);
|
|
12876
12931
|
}
|
|
12877
|
-
const change = compareElementExports(
|
|
12932
|
+
const change = compareElementExports(base === null || base === void 0 ? void 0 : base.element, target === null || target === void 0 ? void 0 : target.element);
|
|
12878
12933
|
if (options.includeDeletions === false && (change === null || change === void 0 ? void 0 : change.type) === exports.WorkspaceElementChangeType.DELETE) {
|
|
12879
12934
|
continue;
|
|
12880
12935
|
}
|
|
12881
|
-
if (change) {
|
|
12882
|
-
|
|
12936
|
+
if (!change) {
|
|
12937
|
+
continue;
|
|
12883
12938
|
}
|
|
12884
|
-
|
|
12885
|
-
|
|
12939
|
+
const subject = target || base;
|
|
12940
|
+
const integrationKey = getIntegrationIdentifier(subject.element, integrationMap);
|
|
12941
|
+
const path = getMembraneElementPath(subject.type, subject.element.key, integrationKey);
|
|
12942
|
+
changes[change.uuid] = { elementType: subject.type, path };
|
|
12886
12943
|
comparison[change.type].add(change.uuid);
|
|
12887
|
-
|
|
12888
|
-
|
|
12944
|
+
if (options.includeDiff) {
|
|
12945
|
+
const baseYaml = base ? yaml__namespace.dump(base.element) : '';
|
|
12946
|
+
const targetYaml = target ? yaml__namespace.dump(target.element) : '';
|
|
12947
|
+
diffs.push(diff.createTwoFilesPatch(`a/${path}`, `b/${path}`, baseYaml, targetYaml));
|
|
12948
|
+
}
|
|
12949
|
+
}
|
|
12950
|
+
const result = { comparison, changes, sourceUuidByTargetUuid };
|
|
12951
|
+
if (options.includeDiff) {
|
|
12952
|
+
result.diff = diffs.join('\n').trim();
|
|
12953
|
+
}
|
|
12954
|
+
return result;
|
|
12889
12955
|
}
|
|
12890
12956
|
function compareElementExports(baseElement, targetElement) {
|
|
12891
12957
|
if (baseElement && !targetElement) {
|
|
@@ -14517,6 +14583,7 @@ async function createOrUpdateConnection(options) {
|
|
|
14517
14583
|
const { stopSSE } = createSSEListener({
|
|
14518
14584
|
apiUri: apiUri,
|
|
14519
14585
|
requestId,
|
|
14586
|
+
token,
|
|
14520
14587
|
handler: eventHandler,
|
|
14521
14588
|
});
|
|
14522
14589
|
function cleanup() {
|
|
@@ -14631,8 +14698,8 @@ const createCrossWindowListener = ({ handler }) => {
|
|
|
14631
14698
|
},
|
|
14632
14699
|
};
|
|
14633
14700
|
};
|
|
14634
|
-
const createSSEListener = ({ apiUri, requestId, handler, }) => {
|
|
14635
|
-
const sseUrl = urljoin(apiUri, '/sse/connection-events', requestId)
|
|
14701
|
+
const createSSEListener = ({ apiUri, requestId, token, handler, }) => {
|
|
14702
|
+
const sseUrl = urljoin(apiUri, '/sse/connection-events', requestId) + `?token=${encodeURIComponent(token)}`;
|
|
14636
14703
|
let eventSource = null;
|
|
14637
14704
|
const closeSseConnection = () => {
|
|
14638
14705
|
eventSource === null || eventSource === void 0 ? void 0 : eventSource.close();
|
|
@@ -15168,7 +15235,9 @@ const AgentSession = z.z.object({
|
|
|
15168
15235
|
status: z.z.enum(exports.AgentSessionStatus),
|
|
15169
15236
|
prompt: z.z.string(),
|
|
15170
15237
|
error: ErrorDataSchema.optional(),
|
|
15171
|
-
lastActivityAt: z.z.iso
|
|
15238
|
+
lastActivityAt: z.z.iso
|
|
15239
|
+
.datetime()
|
|
15240
|
+
.describe('Last meaningful session progress timestamp used for inactivity timeout checks.'),
|
|
15172
15241
|
title: z.z.string().optional(),
|
|
15173
15242
|
summary: z.z.string().optional(),
|
|
15174
15243
|
cost: z.z.number().optional(),
|
|
@@ -15195,7 +15264,10 @@ const AgentSessionInputSchema = z.z.object({
|
|
|
15195
15264
|
});
|
|
15196
15265
|
const PatchAgentSessionSchema = z.z.object({
|
|
15197
15266
|
state: z.z.enum(exports.AgentSessionState).optional(),
|
|
15198
|
-
lastActivityAt: z.z.iso
|
|
15267
|
+
lastActivityAt: z.z.iso
|
|
15268
|
+
.datetime()
|
|
15269
|
+
.optional()
|
|
15270
|
+
.describe('Last meaningful session progress timestamp used for inactivity timeout checks.'),
|
|
15199
15271
|
title: z.z.string().optional(),
|
|
15200
15272
|
summary: z.z.string().optional(),
|
|
15201
15273
|
cost: z.z.number().optional(),
|
|
@@ -15272,14 +15344,18 @@ const ClientToken = z.z.object({
|
|
|
15272
15344
|
grantType: ClientTokenGrantType,
|
|
15273
15345
|
grantId: z.z.string().optional(),
|
|
15274
15346
|
grantName: z.z.string().optional(),
|
|
15275
|
-
|
|
15347
|
+
connectedProductId: z.z.string().optional(),
|
|
15276
15348
|
createdAt: z.z.string(),
|
|
15277
15349
|
});
|
|
15350
|
+
const CreateClientTokenResponse = ClientToken.extend({
|
|
15351
|
+
accessToken: z.z.string(),
|
|
15352
|
+
});
|
|
15278
15353
|
const CreateClientTokenRequest = z.z.object({
|
|
15279
15354
|
grantType: ClientTokenGrantType,
|
|
15280
15355
|
grantId: z.z.string(),
|
|
15281
15356
|
grantName: z.z.string(),
|
|
15282
15357
|
tenantId: z.z.string().optional(),
|
|
15358
|
+
productKey: z.z.string().optional(),
|
|
15283
15359
|
});
|
|
15284
15360
|
const ClientTokenListResponse = z.z.object({
|
|
15285
15361
|
items: z.z.array(ClientToken),
|
|
@@ -15294,8 +15370,8 @@ const OAuthTokenResponse = z.z.object({
|
|
|
15294
15370
|
token_type: z.z.string(),
|
|
15295
15371
|
expires_in: z.z.number(),
|
|
15296
15372
|
refresh_token: z.z.string().optional(),
|
|
15297
|
-
|
|
15298
|
-
|
|
15373
|
+
default_workspace_key: z.z.string().optional(),
|
|
15374
|
+
default_tenant_key: z.z.string().optional(),
|
|
15299
15375
|
});
|
|
15300
15376
|
|
|
15301
15377
|
const CONSOLE_ACCOUNT_API_TOKEN_PATH = 'settings/account/api-token';
|
|
@@ -15937,6 +16013,9 @@ exports.ActivityLogRecord = ActivityLogRecord;
|
|
|
15937
16013
|
exports.ActivityStatsQuery = ActivityStatsQuery;
|
|
15938
16014
|
exports.AgentSession = AgentSession;
|
|
15939
16015
|
exports.AgentSessionInputSchema = AgentSessionInputSchema;
|
|
16016
|
+
exports.AiAgentAudience = AiAgentAudience;
|
|
16017
|
+
exports.AiAgentParameters = AiAgentParameters;
|
|
16018
|
+
exports.AiAgentType = AiAgentType;
|
|
15940
16019
|
exports.Alert = Alert;
|
|
15941
16020
|
exports.AlertDeliverySettingsSchema = AlertDeliverySettingsSchema;
|
|
15942
16021
|
exports.AlertSchema = AlertSchema;
|
|
@@ -15972,6 +16051,7 @@ exports.BaseAppDataSchema = BaseAppDataSchema;
|
|
|
15972
16051
|
exports.BaseAppDataSchemaInstance = BaseAppDataSchemaInstance;
|
|
15973
16052
|
exports.BaseAppEventSubscription = BaseAppEventSubscription;
|
|
15974
16053
|
exports.BaseAppEventType = BaseAppEventType;
|
|
16054
|
+
exports.BaseConnectedProduct = BaseConnectedProduct;
|
|
15975
16055
|
exports.BaseConnection = BaseConnection;
|
|
15976
16056
|
exports.BaseConnector = BaseConnector;
|
|
15977
16057
|
exports.BaseCustomer = BaseCustomer;
|
|
@@ -16031,6 +16111,9 @@ exports.ConcurrencyError = ConcurrencyError;
|
|
|
16031
16111
|
exports.ConfigurationError = ConfigurationError;
|
|
16032
16112
|
exports.ConnectPayload = ConnectPayload;
|
|
16033
16113
|
exports.ConnectUIOptions = ConnectUIOptions;
|
|
16114
|
+
exports.ConnectedProductApiResponse = ConnectedProductApiResponse;
|
|
16115
|
+
exports.ConnectedProductAudience = ConnectedProductAudience;
|
|
16116
|
+
exports.ConnectedProductType = ConnectedProductType;
|
|
16034
16117
|
exports.ConnectionAccessor = ConnectionAccessor;
|
|
16035
16118
|
exports.ConnectionApiResponse = ConnectionApiResponse;
|
|
16036
16119
|
exports.ConnectionApiResponseWithSecrets = ConnectionApiResponseWithSecrets;
|
|
@@ -16100,6 +16183,8 @@ exports.CreateActionRequest = CreateActionRequest;
|
|
|
16100
16183
|
exports.CreateAgentSession = CreateAgentSession;
|
|
16101
16184
|
exports.CreateAlert = CreateAlert;
|
|
16102
16185
|
exports.CreateClientTokenRequest = CreateClientTokenRequest;
|
|
16186
|
+
exports.CreateClientTokenResponse = CreateClientTokenResponse;
|
|
16187
|
+
exports.CreateConnectedProductRequest = CreateConnectedProductRequest;
|
|
16103
16188
|
exports.CreateConnectionRequest = CreateConnectionRequest;
|
|
16104
16189
|
exports.CreateConnectionRequestPayload = CreateConnectionRequestPayload;
|
|
16105
16190
|
exports.CreateConnectorRequest = CreateConnectorRequest;
|
|
@@ -16233,6 +16318,7 @@ exports.FindAppDataSchemasQuery = FindAppDataSchemasQuery;
|
|
|
16233
16318
|
exports.FindAppEventSubscriptionsQuery = FindAppEventSubscriptionsQuery;
|
|
16234
16319
|
exports.FindAppEventTypesQuery = FindAppEventTypesQuery;
|
|
16235
16320
|
exports.FindAppEventsQuery = FindAppEventsQuery;
|
|
16321
|
+
exports.FindConnectedProductsQuery = FindConnectedProductsQuery;
|
|
16236
16322
|
exports.FindConnectionsQuery = FindConnectionsQuery;
|
|
16237
16323
|
exports.FindConnectionsResponse = FindConnectionsResponse;
|
|
16238
16324
|
exports.FindCustomersQuery = FindCustomersQuery;
|
|
@@ -16420,6 +16506,7 @@ exports.UNIFIED_DATA_MODELS = UNIFIED_DATA_MODELS;
|
|
|
16420
16506
|
exports.UnitRunError = UnitRunError;
|
|
16421
16507
|
exports.UpdateActionInstanceRequest = UpdateActionInstanceRequest;
|
|
16422
16508
|
exports.UpdateActionRequest = UpdateActionRequest;
|
|
16509
|
+
exports.UpdateConnectedProductRequest = UpdateConnectedProductRequest;
|
|
16423
16510
|
exports.UpdateConnectionRequest = UpdateConnectionRequest;
|
|
16424
16511
|
exports.UpdateConnectorRequest = UpdateConnectorRequest;
|
|
16425
16512
|
exports.UpdateCustomerRequest = UpdateCustomerRequest;
|