@zapier/zapier-sdk 0.36.0 → 0.38.0
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/CHANGELOG.md +12 -0
- package/CLAUDE.md +50 -0
- package/README.md +147 -81
- package/dist/index.cjs +417 -166
- package/dist/index.d.mts +99 -13
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.mjs +413 -167
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +61 -24
- package/dist/plugins/apps/schemas.d.ts +4 -1
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/apps/schemas.js +4 -2
- package/dist/plugins/capabilities/index.d.ts +22 -0
- package/dist/plugins/capabilities/index.d.ts.map +1 -0
- package/dist/plugins/capabilities/index.js +76 -0
- package/dist/plugins/connections/index.d.ts +11 -0
- package/dist/plugins/connections/index.d.ts.map +1 -0
- package/dist/plugins/connections/index.js +21 -0
- package/dist/plugins/fetch/index.d.ts +4 -1
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +9 -3
- package/dist/plugins/fetch/schemas.d.ts +1 -0
- package/dist/plugins/fetch/schemas.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.js +2 -1
- package/dist/plugins/findFirstConnection/schemas.d.ts +1 -0
- package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/schemas.d.ts +1 -0
- package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.d.ts +2 -1
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +10 -3
- package/dist/plugins/listConnections/schemas.d.ts +1 -0
- package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
- package/dist/plugins/listConnections/schemas.js +5 -0
- package/dist/plugins/manifest/index.d.ts +3 -0
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +15 -6
- package/dist/plugins/manifest/schemas.d.ts +36 -7
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +17 -10
- package/dist/plugins/runAction/index.d.ts +2 -1
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +8 -3
- package/dist/plugins/runAction/schemas.d.ts +1 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/schemas.js +2 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +2 -1
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +1 -0
- package/dist/plugins/tables/listTables/index.d.ts +2 -1
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +14 -6
- package/dist/plugins/tables/listTables/schemas.d.ts +1 -0
- package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/schemas.js +5 -1
- package/dist/resolvers/connectionId.d.ts.map +1 -1
- package/dist/resolvers/connectionId.js +13 -23
- package/dist/resolvers/tableId.d.ts.map +1 -1
- package/dist/resolvers/tableId.js +17 -6
- package/dist/sdk.d.ts +6 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +6 -0
- package/dist/types/connections.d.ts +19 -0
- package/dist/types/connections.d.ts.map +1 -0
- package/dist/types/connections.js +18 -0
- package/dist/types/properties.d.ts +2 -0
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/properties.js +3 -0
- package/dist/types/sdk.d.ts +3 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +9 -0
- package/dist/utils/domain-utils.d.ts +15 -0
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +30 -0
- package/dist/utils/pagination-utils.d.ts +6 -0
- package/dist/utils/pagination-utils.d.ts.map +1 -1
- package/dist/utils/pagination-utils.js +8 -0
- package/dist/utils/schema-utils.d.ts +6 -1
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -76,6 +76,9 @@ var ActionTypePropertySchema = z.enum([
|
|
|
76
76
|
var ActionKeyPropertySchema = z.string().min(1).describe("Action key to execute");
|
|
77
77
|
var ConnectionIdPropertySchema = z.union([z.string(), z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
78
78
|
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema;
|
|
79
|
+
var ConnectionPropertySchema = z.union([z.string(), z.number().int().positive()]).describe(
|
|
80
|
+
"Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly."
|
|
81
|
+
);
|
|
79
82
|
var InputsPropertySchema = z.record(z.string(), z.unknown()).describe("Input parameters for the action");
|
|
80
83
|
var LimitPropertySchema = z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
81
84
|
var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
@@ -250,6 +253,7 @@ HTTP Status: ${error.statusCode}`;
|
|
|
250
253
|
var ActionExecutionInputSchema = z.object({
|
|
251
254
|
inputs: z.record(z.string(), z.unknown()).optional(),
|
|
252
255
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
256
|
+
connection: ConnectionPropertySchema.optional(),
|
|
253
257
|
/** @deprecated Use connectionId instead */
|
|
254
258
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
255
259
|
timeoutMs: ActionTimeoutMsPropertySchema
|
|
@@ -258,9 +262,10 @@ var ActionExecutionInputSchema = z.object({
|
|
|
258
262
|
);
|
|
259
263
|
var AppFactoryInputSchema = z.object({
|
|
260
264
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
265
|
+
connection: ConnectionPropertySchema.optional(),
|
|
261
266
|
/** @deprecated Use connectionId instead */
|
|
262
267
|
authenticationId: AuthenticationIdPropertySchema.optional()
|
|
263
|
-
}).describe("Bind a connection
|
|
268
|
+
}).describe("Bind a connection alias or numeric connectionId to an app");
|
|
264
269
|
function getStringProperty(obj, key) {
|
|
265
270
|
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
266
271
|
const value = obj[key];
|
|
@@ -288,44 +293,80 @@ var ActionResultItemSchema = withFormatter(
|
|
|
288
293
|
);
|
|
289
294
|
|
|
290
295
|
// src/plugins/apps/index.ts
|
|
291
|
-
function
|
|
296
|
+
function resolveProxyConnection({
|
|
297
|
+
providedConnectionId,
|
|
298
|
+
providedConnection,
|
|
299
|
+
providedAuthenticationId,
|
|
300
|
+
pinnedAuthId,
|
|
301
|
+
pinnedConnection,
|
|
302
|
+
errorContext
|
|
303
|
+
}) {
|
|
304
|
+
const hasDirectId = providedConnectionId != null || providedAuthenticationId != null;
|
|
305
|
+
if (hasDirectId && providedConnection != null) {
|
|
306
|
+
throw new ZapierValidationError(
|
|
307
|
+
"Cannot specify both connectionId/authenticationId and connection. Use connectionId for a direct ID, or connection for an alias or numeric ID."
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
const hasPerCall = providedConnectionId != null || providedConnection != null || providedAuthenticationId != null;
|
|
311
|
+
let finalConnectionId;
|
|
312
|
+
let finalConnection;
|
|
313
|
+
if (hasPerCall) {
|
|
314
|
+
finalConnectionId = providedConnectionId ?? providedAuthenticationId;
|
|
315
|
+
finalConnection = finalConnectionId != null ? void 0 : providedConnection;
|
|
316
|
+
} else {
|
|
317
|
+
finalConnectionId = pinnedAuthId;
|
|
318
|
+
finalConnection = pinnedAuthId != null ? void 0 : pinnedConnection;
|
|
319
|
+
}
|
|
320
|
+
if (finalConnectionId == null && finalConnection == null) {
|
|
321
|
+
throw new ZapierValidationError(errorContext);
|
|
322
|
+
}
|
|
323
|
+
return { connectionId: finalConnectionId, connection: finalConnection };
|
|
324
|
+
}
|
|
325
|
+
function createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId, pinnedConnection) {
|
|
292
326
|
return (actionOptions = {}) => {
|
|
293
327
|
const { sdk } = options;
|
|
294
328
|
const {
|
|
295
329
|
inputs,
|
|
296
330
|
connectionId: providedConnectionId,
|
|
331
|
+
connection: providedConnection,
|
|
297
332
|
authenticationId: providedAuthenticationId,
|
|
298
333
|
timeoutMs
|
|
299
334
|
} = actionOptions;
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
335
|
+
const { connectionId, connection } = resolveProxyConnection({
|
|
336
|
+
providedConnectionId,
|
|
337
|
+
providedConnection,
|
|
338
|
+
providedAuthenticationId,
|
|
339
|
+
pinnedAuthId,
|
|
340
|
+
pinnedConnection,
|
|
341
|
+
errorContext: `Connection is required. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }) or sdk.apps.${appKey}({ connection: "name" }), or provide connectionId/connection in the action call.`
|
|
342
|
+
});
|
|
306
343
|
return sdk.runAction({
|
|
307
344
|
appKey,
|
|
308
345
|
actionType,
|
|
309
346
|
actionKey,
|
|
310
347
|
inputs,
|
|
311
|
-
connectionId
|
|
348
|
+
connectionId,
|
|
349
|
+
connection,
|
|
312
350
|
timeoutMs
|
|
313
351
|
});
|
|
314
352
|
};
|
|
315
353
|
}
|
|
316
|
-
function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
354
|
+
function createActionTypeProxy(appKey, actionType, options, pinnedAuthId, pinnedConnection) {
|
|
317
355
|
if (actionType === "fetch") {
|
|
318
356
|
return async (url, init) => {
|
|
319
357
|
const { sdk } = options;
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
358
|
+
const { connectionId, connection } = resolveProxyConnection({
|
|
359
|
+
providedConnectionId: init?.connectionId,
|
|
360
|
+
providedConnection: init?.connection,
|
|
361
|
+
providedAuthenticationId: init?.authenticationId,
|
|
362
|
+
pinnedAuthId,
|
|
363
|
+
pinnedConnection,
|
|
364
|
+
errorContext: `Connection is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }).fetch(...) or provide connectionId/connection in the fetch call.`
|
|
365
|
+
});
|
|
326
366
|
return sdk.fetch(url, {
|
|
327
367
|
...init,
|
|
328
|
-
connectionId
|
|
368
|
+
connectionId,
|
|
369
|
+
connection
|
|
329
370
|
});
|
|
330
371
|
};
|
|
331
372
|
}
|
|
@@ -339,7 +380,8 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
339
380
|
actionType,
|
|
340
381
|
actionKey,
|
|
341
382
|
options,
|
|
342
|
-
pinnedAuthId
|
|
383
|
+
pinnedAuthId,
|
|
384
|
+
pinnedConnection
|
|
343
385
|
);
|
|
344
386
|
}
|
|
345
387
|
return void 0;
|
|
@@ -347,7 +389,7 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
347
389
|
}
|
|
348
390
|
);
|
|
349
391
|
}
|
|
350
|
-
function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
392
|
+
function createPinnedAppProxy(appKey, options, pinnedAuthId, pinnedConnection) {
|
|
351
393
|
return new Proxy(
|
|
352
394
|
{},
|
|
353
395
|
{
|
|
@@ -357,7 +399,8 @@ function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
|
357
399
|
appKey,
|
|
358
400
|
actionType,
|
|
359
401
|
options,
|
|
360
|
-
pinnedAuthId
|
|
402
|
+
pinnedAuthId,
|
|
403
|
+
pinnedConnection
|
|
361
404
|
);
|
|
362
405
|
}
|
|
363
406
|
return void 0;
|
|
@@ -368,12 +411,23 @@ function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
|
368
411
|
function createAppProxy(appKey, options) {
|
|
369
412
|
const appFactory = (factoryOptions) => {
|
|
370
413
|
const resolvedConnectionId = factoryOptions.connectionId ?? factoryOptions.authenticationId;
|
|
371
|
-
|
|
414
|
+
const resolvedConnection = factoryOptions.connection;
|
|
415
|
+
if (resolvedConnectionId != null && resolvedConnection != null) {
|
|
372
416
|
throw new ZapierValidationError(
|
|
373
|
-
|
|
417
|
+
"Cannot specify both connectionId/authenticationId and connection. Use connectionId for a direct ID, or connection for an alias or numeric ID."
|
|
374
418
|
);
|
|
375
419
|
}
|
|
376
|
-
|
|
420
|
+
if (resolvedConnectionId == null && resolvedConnection == null) {
|
|
421
|
+
throw new ZapierValidationError(
|
|
422
|
+
`Connection is required. Use sdk.apps.${appKey}({ connectionId: "..." }) or sdk.apps.${appKey}({ connection: "name" })`
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
return createPinnedAppProxy(
|
|
426
|
+
appKey,
|
|
427
|
+
options,
|
|
428
|
+
resolvedConnectionId,
|
|
429
|
+
resolvedConnection
|
|
430
|
+
);
|
|
377
431
|
};
|
|
378
432
|
return new Proxy(appFactory, {
|
|
379
433
|
get(_, actionType) {
|
|
@@ -436,6 +490,7 @@ var FetchInitSchema = z.object({
|
|
|
436
490
|
"Request body \u2014 plain objects and JSON strings are auto-detected and Content-Type is set accordingly"
|
|
437
491
|
),
|
|
438
492
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
493
|
+
connection: ConnectionPropertySchema.optional(),
|
|
439
494
|
/** @deprecated Use connectionId instead */
|
|
440
495
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
441
496
|
callbackUrl: z.string().optional().describe("URL to send async response to (makes request async)")
|
|
@@ -443,6 +498,119 @@ var FetchInitSchema = z.object({
|
|
|
443
498
|
"Request options including method, headers, body, and authentication"
|
|
444
499
|
);
|
|
445
500
|
|
|
501
|
+
// src/utils/domain-utils.ts
|
|
502
|
+
async function resolveConnectionId({
|
|
503
|
+
connectionId,
|
|
504
|
+
connection,
|
|
505
|
+
authenticationId,
|
|
506
|
+
resolveConnection,
|
|
507
|
+
label
|
|
508
|
+
}) {
|
|
509
|
+
const hasDirectId = connectionId != null || authenticationId != null;
|
|
510
|
+
if (hasDirectId && connection != null) {
|
|
511
|
+
const context = label ? ` for ${label}` : "";
|
|
512
|
+
throw new ZapierValidationError(
|
|
513
|
+
`Cannot specify both connectionId/authenticationId and connection${context}. Use connectionId for a direct ID, or connection for an alias or numeric ID.`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
let resolvedConnectionId = connectionId ?? authenticationId ?? void 0;
|
|
517
|
+
if (connection != null && resolvedConnectionId == null) {
|
|
518
|
+
if (typeof connection === "number") {
|
|
519
|
+
resolvedConnectionId = connection;
|
|
520
|
+
} else {
|
|
521
|
+
const entry = await resolveConnection(connection);
|
|
522
|
+
if (!entry) {
|
|
523
|
+
throw new ZapierConfigurationError(
|
|
524
|
+
`Connection "${connection}" not found in connections map. Ensure the connection is defined in the manifest connections, or use a numeric connectionId.`,
|
|
525
|
+
{ configType: "connections" }
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
resolvedConnectionId = entry.connectionId;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return resolvedConnectionId;
|
|
532
|
+
}
|
|
533
|
+
function splitVersionedKey(versionedKey) {
|
|
534
|
+
const parts = versionedKey.split("@");
|
|
535
|
+
if (parts.length >= 2) {
|
|
536
|
+
const baseKey = parts[0];
|
|
537
|
+
const version = parts.slice(1).join("@");
|
|
538
|
+
return [baseKey, version];
|
|
539
|
+
}
|
|
540
|
+
return [versionedKey, void 0];
|
|
541
|
+
}
|
|
542
|
+
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
543
|
+
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
544
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
545
|
+
return {
|
|
546
|
+
...restOfImplementationMeta,
|
|
547
|
+
title: name,
|
|
548
|
+
key: selectedApi,
|
|
549
|
+
implementation_id: id,
|
|
550
|
+
version: appVersion
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function normalizeActionItem(action) {
|
|
554
|
+
const { name, type, selected_api: selectedApi } = action;
|
|
555
|
+
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
556
|
+
return {
|
|
557
|
+
// Only include the fields we want - explicitly list them
|
|
558
|
+
id: action.id,
|
|
559
|
+
key: action.key,
|
|
560
|
+
description: action.description,
|
|
561
|
+
is_important: action.is_important,
|
|
562
|
+
is_hidden: action.is_hidden,
|
|
563
|
+
// Transformed fields
|
|
564
|
+
app_key: appKey,
|
|
565
|
+
app_version: appVersion,
|
|
566
|
+
action_type: type,
|
|
567
|
+
title: name,
|
|
568
|
+
// Map name to title
|
|
569
|
+
type: "action"
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function isSlug(slug) {
|
|
573
|
+
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
574
|
+
}
|
|
575
|
+
function isSnakeCasedSlug(slug) {
|
|
576
|
+
if (slug.match(/^_[0-9]/)) {
|
|
577
|
+
slug = slug.slice(1);
|
|
578
|
+
}
|
|
579
|
+
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
580
|
+
}
|
|
581
|
+
function dashifySnakeCasedSlug(slug) {
|
|
582
|
+
if (!isSnakeCasedSlug(slug)) {
|
|
583
|
+
return slug;
|
|
584
|
+
}
|
|
585
|
+
if (slug.startsWith("_")) {
|
|
586
|
+
slug = slug.slice(1);
|
|
587
|
+
}
|
|
588
|
+
return slug.replace(/_/g, "-");
|
|
589
|
+
}
|
|
590
|
+
function isUuid(appKey) {
|
|
591
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
592
|
+
appKey
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
function toAppLocator(appKey) {
|
|
596
|
+
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
597
|
+
if (isUuid(appKeyWithoutVersion)) {
|
|
598
|
+
throw new Error(
|
|
599
|
+
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
603
|
+
return {
|
|
604
|
+
lookupAppKey: appKeyWithoutVersion,
|
|
605
|
+
slug,
|
|
606
|
+
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
607
|
+
version
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
function isResolvedAppLocator(appLocator) {
|
|
611
|
+
return !!appLocator.implementationName;
|
|
612
|
+
}
|
|
613
|
+
|
|
446
614
|
// src/utils/id-utils.ts
|
|
447
615
|
function coerceToNumericId(fieldName, value) {
|
|
448
616
|
if (value === "") {
|
|
@@ -537,8 +705,20 @@ var fetchPlugin = ({ context }) => {
|
|
|
537
705
|
const startTime = Date.now();
|
|
538
706
|
const isNested = isTelemetryNested();
|
|
539
707
|
try {
|
|
540
|
-
const {
|
|
541
|
-
|
|
708
|
+
const {
|
|
709
|
+
connectionId,
|
|
710
|
+
connection,
|
|
711
|
+
authenticationId,
|
|
712
|
+
callbackUrl,
|
|
713
|
+
...fetchInit
|
|
714
|
+
} = init || {};
|
|
715
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
716
|
+
connectionId,
|
|
717
|
+
connection,
|
|
718
|
+
authenticationId,
|
|
719
|
+
resolveConnection: context.resolveConnection,
|
|
720
|
+
label: "fetch"
|
|
721
|
+
});
|
|
542
722
|
const relayPath = transformUrlToRelayPath(url);
|
|
543
723
|
const headers = normalizeHeaders(
|
|
544
724
|
fetchInit.headers
|
|
@@ -873,6 +1053,9 @@ function concatPaginated({
|
|
|
873
1053
|
}
|
|
874
1054
|
});
|
|
875
1055
|
}
|
|
1056
|
+
function toIterable(source) {
|
|
1057
|
+
return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
|
|
1058
|
+
}
|
|
876
1059
|
|
|
877
1060
|
// src/utils/validation.ts
|
|
878
1061
|
var validate = (schema, input) => {
|
|
@@ -1241,88 +1424,6 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1241
1424
|
}
|
|
1242
1425
|
};
|
|
1243
1426
|
};
|
|
1244
|
-
|
|
1245
|
-
// src/utils/domain-utils.ts
|
|
1246
|
-
function splitVersionedKey(versionedKey) {
|
|
1247
|
-
const parts = versionedKey.split("@");
|
|
1248
|
-
if (parts.length >= 2) {
|
|
1249
|
-
const baseKey = parts[0];
|
|
1250
|
-
const version = parts.slice(1).join("@");
|
|
1251
|
-
return [baseKey, version];
|
|
1252
|
-
}
|
|
1253
|
-
return [versionedKey, void 0];
|
|
1254
|
-
}
|
|
1255
|
-
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
1256
|
-
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
1257
|
-
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
1258
|
-
return {
|
|
1259
|
-
...restOfImplementationMeta,
|
|
1260
|
-
title: name,
|
|
1261
|
-
key: selectedApi,
|
|
1262
|
-
implementation_id: id,
|
|
1263
|
-
version: appVersion
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
function normalizeActionItem(action) {
|
|
1267
|
-
const { name, type, selected_api: selectedApi } = action;
|
|
1268
|
-
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
1269
|
-
return {
|
|
1270
|
-
// Only include the fields we want - explicitly list them
|
|
1271
|
-
id: action.id,
|
|
1272
|
-
key: action.key,
|
|
1273
|
-
description: action.description,
|
|
1274
|
-
is_important: action.is_important,
|
|
1275
|
-
is_hidden: action.is_hidden,
|
|
1276
|
-
// Transformed fields
|
|
1277
|
-
app_key: appKey,
|
|
1278
|
-
app_version: appVersion,
|
|
1279
|
-
action_type: type,
|
|
1280
|
-
title: name,
|
|
1281
|
-
// Map name to title
|
|
1282
|
-
type: "action"
|
|
1283
|
-
};
|
|
1284
|
-
}
|
|
1285
|
-
function isSlug(slug) {
|
|
1286
|
-
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
1287
|
-
}
|
|
1288
|
-
function isSnakeCasedSlug(slug) {
|
|
1289
|
-
if (slug.match(/^_[0-9]/)) {
|
|
1290
|
-
slug = slug.slice(1);
|
|
1291
|
-
}
|
|
1292
|
-
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
1293
|
-
}
|
|
1294
|
-
function dashifySnakeCasedSlug(slug) {
|
|
1295
|
-
if (!isSnakeCasedSlug(slug)) {
|
|
1296
|
-
return slug;
|
|
1297
|
-
}
|
|
1298
|
-
if (slug.startsWith("_")) {
|
|
1299
|
-
slug = slug.slice(1);
|
|
1300
|
-
}
|
|
1301
|
-
return slug.replace(/_/g, "-");
|
|
1302
|
-
}
|
|
1303
|
-
function isUuid(appKey) {
|
|
1304
|
-
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
1305
|
-
appKey
|
|
1306
|
-
);
|
|
1307
|
-
}
|
|
1308
|
-
function toAppLocator(appKey) {
|
|
1309
|
-
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
1310
|
-
if (isUuid(appKeyWithoutVersion)) {
|
|
1311
|
-
throw new Error(
|
|
1312
|
-
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
|
-
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
1316
|
-
return {
|
|
1317
|
-
lookupAppKey: appKeyWithoutVersion,
|
|
1318
|
-
slug,
|
|
1319
|
-
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
1320
|
-
version
|
|
1321
|
-
};
|
|
1322
|
-
}
|
|
1323
|
-
function isResolvedAppLocator(appLocator) {
|
|
1324
|
-
return !!appLocator.implementationName;
|
|
1325
|
-
}
|
|
1326
1427
|
var ListActionsSchema = z.object({
|
|
1327
1428
|
appKey: AppKeyPropertySchema.describe(
|
|
1328
1429
|
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
@@ -1732,44 +1833,32 @@ var actionKeyResolver = {
|
|
|
1732
1833
|
|
|
1733
1834
|
// src/resolvers/connectionId.ts
|
|
1734
1835
|
async function fetchConnections(sdk, resolvedParams) {
|
|
1735
|
-
const
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
});
|
|
1745
|
-
const allConnections = await sdk.listConnections(listOptions);
|
|
1746
|
-
const otherConnections = allConnections.data.filter(
|
|
1747
|
-
(connection) => !myConnections.data.some(
|
|
1748
|
-
(myConnection) => myConnection.id === connection.id
|
|
1749
|
-
)
|
|
1836
|
+
const context = sdk.getContext();
|
|
1837
|
+
const includeShared = await context.hasCapability?.(
|
|
1838
|
+
"canIncludeSharedConnections"
|
|
1839
|
+
);
|
|
1840
|
+
return toIterable(
|
|
1841
|
+
sdk.listConnections({
|
|
1842
|
+
appKey: resolvedParams.appKey,
|
|
1843
|
+
includeShared: includeShared || void 0
|
|
1844
|
+
})
|
|
1750
1845
|
);
|
|
1751
|
-
return [...myConnections.data, ...otherConnections];
|
|
1752
1846
|
}
|
|
1753
1847
|
function promptForConnection(connections, params) {
|
|
1754
1848
|
return {
|
|
1755
1849
|
type: "list",
|
|
1756
1850
|
name: "connectionId",
|
|
1757
1851
|
message: params.appKey ? `Select connection for ${params.appKey}:` : "Select connection:",
|
|
1758
|
-
choices:
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
})),
|
|
1763
|
-
{
|
|
1764
|
-
name: "-> Skip connection (may fail)",
|
|
1765
|
-
value: null
|
|
1766
|
-
}
|
|
1767
|
-
]
|
|
1852
|
+
choices: connections.map((connection) => ({
|
|
1853
|
+
name: `${connection.title || connection.label || "Connection"} (ID: ${connection.id})`,
|
|
1854
|
+
value: connection.id
|
|
1855
|
+
}))
|
|
1768
1856
|
};
|
|
1769
1857
|
}
|
|
1770
1858
|
var connectionIdResolver = {
|
|
1771
1859
|
type: "dynamic",
|
|
1772
1860
|
depends: ["appKey"],
|
|
1861
|
+
requireCapabilities: ["canIncludeSharedConnections"],
|
|
1773
1862
|
tryResolveWithoutPrompt: async (sdk, params) => {
|
|
1774
1863
|
if (!params.appKey) return null;
|
|
1775
1864
|
try {
|
|
@@ -1787,6 +1876,7 @@ var connectionIdResolver = {
|
|
|
1787
1876
|
var connectionIdGenericResolver = {
|
|
1788
1877
|
type: "dynamic",
|
|
1789
1878
|
depends: [],
|
|
1879
|
+
requireCapabilities: ["canIncludeSharedConnections"],
|
|
1790
1880
|
fetch: fetchConnections,
|
|
1791
1881
|
prompt: promptForConnection
|
|
1792
1882
|
};
|
|
@@ -1910,11 +2000,24 @@ var clientIdResolver = {
|
|
|
1910
2000
|
// src/resolvers/tableId.ts
|
|
1911
2001
|
var tableIdResolver = {
|
|
1912
2002
|
type: "dynamic",
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
2003
|
+
requireCapabilities: ["canIncludeSharedTables"],
|
|
2004
|
+
fetch: async (sdk) => {
|
|
2005
|
+
const context = sdk.getContext();
|
|
2006
|
+
const includeShared = await context.hasCapability?.(
|
|
2007
|
+
"canIncludeSharedTables"
|
|
2008
|
+
);
|
|
2009
|
+
if (includeShared) {
|
|
2010
|
+
return toIterable(
|
|
2011
|
+
concatPaginated({
|
|
2012
|
+
sources: [
|
|
2013
|
+
() => sdk.listTables(),
|
|
2014
|
+
() => sdk.listTables({ includeShared: true })
|
|
2015
|
+
],
|
|
2016
|
+
dedupe: (table) => table.id
|
|
2017
|
+
})
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
return toIterable(sdk.listTables());
|
|
1918
2021
|
},
|
|
1919
2022
|
prompt: (tables) => ({
|
|
1920
2023
|
type: "list",
|
|
@@ -3010,6 +3113,10 @@ var ListConnectionsQuerySchema = ListConnectionsQuerySchema$1.omit({
|
|
|
3010
3113
|
),
|
|
3011
3114
|
// camelCase account ID
|
|
3012
3115
|
accountId: z.string().optional().describe("Account ID to filter by"),
|
|
3116
|
+
// Include shared connections (overrides default owner=me filter)
|
|
3117
|
+
includeShared: z.boolean().optional().describe(
|
|
3118
|
+
"Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections."
|
|
3119
|
+
),
|
|
3013
3120
|
// camelCase isExpired
|
|
3014
3121
|
isExpired: z.boolean().optional().describe("Filter by expired status"),
|
|
3015
3122
|
// Override pageSize to make optional
|
|
@@ -3049,6 +3156,9 @@ var ConnectionItemSchema = withFormatter(ConnectionItemSchema$1, {
|
|
|
3049
3156
|
// src/plugins/listConnections/index.ts
|
|
3050
3157
|
var listConnectionsPlugin = ({ context }) => {
|
|
3051
3158
|
async function listConnectionsPage(options) {
|
|
3159
|
+
if (options.includeShared) {
|
|
3160
|
+
await context.checkCapability("canIncludeSharedConnections");
|
|
3161
|
+
}
|
|
3052
3162
|
const { api, getVersionedImplementationId } = context;
|
|
3053
3163
|
const searchParams = {};
|
|
3054
3164
|
if (options.pageSize !== void 0) {
|
|
@@ -3079,8 +3189,14 @@ var listConnectionsPlugin = ({ context }) => {
|
|
|
3079
3189
|
if (options.accountId) {
|
|
3080
3190
|
searchParams.account_id = options.accountId;
|
|
3081
3191
|
}
|
|
3082
|
-
if (options.owner) {
|
|
3083
|
-
|
|
3192
|
+
if (options.owner && options.owner !== "me" && !options.includeShared) {
|
|
3193
|
+
throw new ZapierValidationError(
|
|
3194
|
+
'The "owner" option requires "includeShared" to be true. Without includeShared, only your own connections are returned.'
|
|
3195
|
+
);
|
|
3196
|
+
}
|
|
3197
|
+
const owner = options.includeShared ? options.owner : "me";
|
|
3198
|
+
if (owner) {
|
|
3199
|
+
searchParams.owner = owner;
|
|
3084
3200
|
}
|
|
3085
3201
|
if (options.isExpired !== void 0) {
|
|
3086
3202
|
searchParams.is_expired = options.isExpired.toString();
|
|
@@ -3633,6 +3749,9 @@ var RunActionSchema = z.object({
|
|
|
3633
3749
|
connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
|
|
3634
3750
|
"Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service."
|
|
3635
3751
|
),
|
|
3752
|
+
connection: ConnectionPropertySchema.optional().describe(
|
|
3753
|
+
"Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."
|
|
3754
|
+
),
|
|
3636
3755
|
/** @deprecated Use connectionId instead */
|
|
3637
3756
|
authenticationId: ConnectionIdPropertySchema.nullable().optional(),
|
|
3638
3757
|
inputs: InputsPropertySchema.optional().describe(
|
|
@@ -3761,12 +3880,18 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3761
3880
|
actionKey,
|
|
3762
3881
|
actionType,
|
|
3763
3882
|
connectionId,
|
|
3883
|
+
connection,
|
|
3764
3884
|
authenticationId,
|
|
3765
3885
|
inputs = {},
|
|
3766
3886
|
cursor,
|
|
3767
3887
|
timeoutMs
|
|
3768
3888
|
} = options;
|
|
3769
|
-
const resolvedConnectionId =
|
|
3889
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
3890
|
+
connectionId,
|
|
3891
|
+
connection,
|
|
3892
|
+
authenticationId,
|
|
3893
|
+
resolveConnection: context.resolveConnection
|
|
3894
|
+
});
|
|
3770
3895
|
const { selectedApi, actionId } = await getRunActionContext(options);
|
|
3771
3896
|
setMethodMetadata({
|
|
3772
3897
|
selectedApi,
|
|
@@ -3962,6 +4087,12 @@ async function readFile(filePath) {
|
|
|
3962
4087
|
}
|
|
3963
4088
|
throw new Error(`File not found: ${filePath}`);
|
|
3964
4089
|
}
|
|
4090
|
+
var ConnectionEntrySchema = z.object({
|
|
4091
|
+
connectionId: z.number().int().positive().describe("Zapier connection ID for the third-party service.")
|
|
4092
|
+
});
|
|
4093
|
+
var ConnectionsMapSchema = z.record(z.string(), ConnectionEntrySchema);
|
|
4094
|
+
|
|
4095
|
+
// src/plugins/manifest/schemas.ts
|
|
3965
4096
|
var DEFAULT_CONFIG_PATH = ".zapierrc";
|
|
3966
4097
|
var ActionEntrySchema = z.object({
|
|
3967
4098
|
appKey: z.string().describe("App key (slug or implementation name)"),
|
|
@@ -3985,18 +4116,20 @@ var ManifestSchema = z.object({
|
|
|
3985
4116
|
),
|
|
3986
4117
|
version: z.string().describe("Version string (e.g., '1.21.1')")
|
|
3987
4118
|
})
|
|
3988
|
-
),
|
|
3989
|
-
actions: z.record(z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas")
|
|
3990
|
-
|
|
4119
|
+
).optional(),
|
|
4120
|
+
actions: z.record(z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas"),
|
|
4121
|
+
canIncludeSharedConnections: z.boolean().optional().describe("Allow listing shared connections"),
|
|
4122
|
+
canIncludeSharedTables: z.boolean().optional().describe("Allow listing shared tables"),
|
|
4123
|
+
canDeleteTables: z.boolean().optional().describe("Allow deleting tables"),
|
|
4124
|
+
connections: ConnectionsMapSchema.optional().describe(
|
|
4125
|
+
"Named connections map. Keys are connection names, values contain a connectionId."
|
|
4126
|
+
)
|
|
4127
|
+
}).describe(
|
|
4128
|
+
"Manifest for app version locking, action configurations, and named connections"
|
|
4129
|
+
);
|
|
3991
4130
|
z.object({
|
|
3992
4131
|
manifestPath: z.string().optional().describe("Path to manifest file"),
|
|
3993
|
-
manifest:
|
|
3994
|
-
z.string(),
|
|
3995
|
-
z.object({
|
|
3996
|
-
implementationName: z.string(),
|
|
3997
|
-
version: z.string().optional()
|
|
3998
|
-
})
|
|
3999
|
-
).optional().describe("Direct manifest object")
|
|
4132
|
+
manifest: ManifestSchema.optional().describe("Direct manifest object")
|
|
4000
4133
|
});
|
|
4001
4134
|
|
|
4002
4135
|
// src/utils/array-utils.ts
|
|
@@ -4012,13 +4145,14 @@ async function toArrayFromAsync(asyncIterable) {
|
|
|
4012
4145
|
function parseManifestContent(content, source) {
|
|
4013
4146
|
try {
|
|
4014
4147
|
const parsed = JSON.parse(content);
|
|
4015
|
-
if (parsed
|
|
4016
|
-
|
|
4017
|
-
if (result.success) {
|
|
4018
|
-
return result.data;
|
|
4019
|
-
}
|
|
4020
|
-
console.warn(`\u26A0\uFE0F Invalid manifest format in ${source}: ${result.error}`);
|
|
4148
|
+
if (parsed == null || typeof parsed !== "object") {
|
|
4149
|
+
return null;
|
|
4021
4150
|
}
|
|
4151
|
+
const result = ManifestSchema.safeParse(parsed);
|
|
4152
|
+
if (result.success) {
|
|
4153
|
+
return result.data;
|
|
4154
|
+
}
|
|
4155
|
+
console.warn(`\u26A0\uFE0F Invalid manifest format in ${source}: ${result.error}`);
|
|
4022
4156
|
return null;
|
|
4023
4157
|
} catch (error) {
|
|
4024
4158
|
console.warn(`\u26A0\uFE0F Failed to parse manifest from ${source}:`, error);
|
|
@@ -4095,6 +4229,9 @@ function findManifestEntry({
|
|
|
4095
4229
|
appKey,
|
|
4096
4230
|
manifest
|
|
4097
4231
|
}) {
|
|
4232
|
+
if (!manifest.apps) {
|
|
4233
|
+
return null;
|
|
4234
|
+
}
|
|
4098
4235
|
const [appKeyWithoutVersion] = splitVersionedKey(appKey);
|
|
4099
4236
|
if (manifest.apps[appKeyWithoutVersion]) {
|
|
4100
4237
|
return [appKeyWithoutVersion, manifest.apps[appKeyWithoutVersion]];
|
|
@@ -4339,6 +4476,7 @@ var manifestPlugin = (params) => {
|
|
|
4339
4476
|
};
|
|
4340
4477
|
return {
|
|
4341
4478
|
context: {
|
|
4479
|
+
getResolvedManifest,
|
|
4342
4480
|
getVersionedImplementationId,
|
|
4343
4481
|
resolveAppKeys: async ({ appKeys }) => resolveAppKeys({
|
|
4344
4482
|
appKeys,
|
|
@@ -4352,7 +4490,11 @@ var manifestPlugin = (params) => {
|
|
|
4352
4490
|
deleteActionEntry,
|
|
4353
4491
|
hasActionEntry,
|
|
4354
4492
|
findManifestEntry,
|
|
4355
|
-
readManifestFromFile
|
|
4493
|
+
readManifestFromFile,
|
|
4494
|
+
getManifestConnections: async () => {
|
|
4495
|
+
const manifest2 = await getResolvedManifest();
|
|
4496
|
+
return manifest2?.connections ?? null;
|
|
4497
|
+
}
|
|
4356
4498
|
}
|
|
4357
4499
|
};
|
|
4358
4500
|
};
|
|
@@ -5715,6 +5857,92 @@ async function batch(tasks, options = {}) {
|
|
|
5715
5857
|
await Promise.all(workers);
|
|
5716
5858
|
return results;
|
|
5717
5859
|
}
|
|
5860
|
+
|
|
5861
|
+
// src/plugins/connections/index.ts
|
|
5862
|
+
var connectionsPlugin = (params) => {
|
|
5863
|
+
const { context } = params;
|
|
5864
|
+
let cachedMap;
|
|
5865
|
+
async function loadConnectionsMap() {
|
|
5866
|
+
if (cachedMap === void 0) {
|
|
5867
|
+
cachedMap = await context.getManifestConnections() ?? null;
|
|
5868
|
+
}
|
|
5869
|
+
return cachedMap;
|
|
5870
|
+
}
|
|
5871
|
+
return {
|
|
5872
|
+
context: {
|
|
5873
|
+
resolveConnection: async (name) => {
|
|
5874
|
+
const map = await loadConnectionsMap();
|
|
5875
|
+
return map?.[name];
|
|
5876
|
+
},
|
|
5877
|
+
getConnectionsMap: async () => {
|
|
5878
|
+
return loadConnectionsMap();
|
|
5879
|
+
}
|
|
5880
|
+
}
|
|
5881
|
+
};
|
|
5882
|
+
};
|
|
5883
|
+
|
|
5884
|
+
// src/plugins/capabilities/index.ts
|
|
5885
|
+
function toDescription(key) {
|
|
5886
|
+
const words = key.replace(/^can/, "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
|
|
5887
|
+
return `To ${words}`;
|
|
5888
|
+
}
|
|
5889
|
+
function toEnvVar(key) {
|
|
5890
|
+
return "ZAPIER_" + key.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
5891
|
+
}
|
|
5892
|
+
function toCliFlag(key) {
|
|
5893
|
+
return "--" + key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
5894
|
+
}
|
|
5895
|
+
function buildCapabilityMessage(key) {
|
|
5896
|
+
return [
|
|
5897
|
+
`${toDescription(key)}, use ${toCliFlag(key)} in the CLI,`,
|
|
5898
|
+
`set ${key}: true in SDK options or .zapierrc,`,
|
|
5899
|
+
`or set ${toEnvVar(key)}=true.`
|
|
5900
|
+
].join(" ");
|
|
5901
|
+
}
|
|
5902
|
+
var GATED_FLAGS = [
|
|
5903
|
+
"canIncludeSharedConnections",
|
|
5904
|
+
"canIncludeSharedTables",
|
|
5905
|
+
"canDeleteTables"
|
|
5906
|
+
];
|
|
5907
|
+
function isEnabledByEnv(key) {
|
|
5908
|
+
if (typeof process === "undefined") return void 0;
|
|
5909
|
+
const value = process.env[toEnvVar(key)];
|
|
5910
|
+
if (value === void 0) return void 0;
|
|
5911
|
+
if (value === "true" || value === "1") return true;
|
|
5912
|
+
if (value === "false" || value === "0") return false;
|
|
5913
|
+
return void 0;
|
|
5914
|
+
}
|
|
5915
|
+
var capabilitiesPlugin = ({ context }) => {
|
|
5916
|
+
const options = context.options ?? {};
|
|
5917
|
+
let cached;
|
|
5918
|
+
async function resolveFlags() {
|
|
5919
|
+
if (cached) return cached;
|
|
5920
|
+
const manifest = await context.getResolvedManifest();
|
|
5921
|
+
cached = {};
|
|
5922
|
+
for (const flag of GATED_FLAGS) {
|
|
5923
|
+
cached[flag] = Boolean(
|
|
5924
|
+
options[flag] ?? isEnabledByEnv(flag) ?? manifest?.[flag]
|
|
5925
|
+
);
|
|
5926
|
+
}
|
|
5927
|
+
return cached;
|
|
5928
|
+
}
|
|
5929
|
+
return {
|
|
5930
|
+
context: {
|
|
5931
|
+
checkCapability: async (key) => {
|
|
5932
|
+
const flags = await resolveFlags();
|
|
5933
|
+
if (flags[key]) return;
|
|
5934
|
+
throw new ZapierConfigurationError(
|
|
5935
|
+
buildCapabilityMessage(key) + " (If you are an AI agent, you MUST NOT retry. Ask the user if they want to enable this.)",
|
|
5936
|
+
{ configType: key }
|
|
5937
|
+
);
|
|
5938
|
+
},
|
|
5939
|
+
hasCapability: async (key) => {
|
|
5940
|
+
const flags = await resolveFlags();
|
|
5941
|
+
return flags[key];
|
|
5942
|
+
}
|
|
5943
|
+
}
|
|
5944
|
+
};
|
|
5945
|
+
};
|
|
5718
5946
|
var TableApiItemSchema = z.object({
|
|
5719
5947
|
id: z.string(),
|
|
5720
5948
|
name: z.string(),
|
|
@@ -5749,7 +5977,10 @@ var ListTablesOptionsSchema = z.object({
|
|
|
5749
5977
|
kind: z.enum(["table", "virtual_table", "both"]).optional().describe("Filter by table type"),
|
|
5750
5978
|
search: z.string().optional().describe("Search term to filter tables by name"),
|
|
5751
5979
|
owner: z.string().optional().describe(
|
|
5752
|
-
'Filter by table owner. Use "me" for the current user, or a numeric user ID.'
|
|
5980
|
+
'Filter by table owner. Use "me" for the current user, or a numeric user ID. Requires includeShared to be true.'
|
|
5981
|
+
),
|
|
5982
|
+
includeShared: z.boolean().optional().describe(
|
|
5983
|
+
"Include tables shared with you. Without this, only your own tables are returned."
|
|
5753
5984
|
),
|
|
5754
5985
|
pageSize: z.number().min(1).optional().describe("Number of tables per page"),
|
|
5755
5986
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
@@ -5771,6 +6002,9 @@ function extractNextCursor(links) {
|
|
|
5771
6002
|
}
|
|
5772
6003
|
var listTablesPlugin = ({ context }) => {
|
|
5773
6004
|
async function listTablesPage(options) {
|
|
6005
|
+
if (options.includeShared) {
|
|
6006
|
+
await context.checkCapability("canIncludeSharedTables");
|
|
6007
|
+
}
|
|
5774
6008
|
const { api } = context;
|
|
5775
6009
|
const searchParams = {};
|
|
5776
6010
|
if (options.pageSize !== void 0) {
|
|
@@ -5785,15 +6019,23 @@ var listTablesPlugin = ({ context }) => {
|
|
|
5785
6019
|
if (options?.search) {
|
|
5786
6020
|
searchParams.q = options.search;
|
|
5787
6021
|
}
|
|
5788
|
-
if (options?.owner) {
|
|
5789
|
-
|
|
5790
|
-
|
|
6022
|
+
if (options?.owner && options.owner !== "me" && !options.includeShared) {
|
|
6023
|
+
throw new ZapierValidationError(
|
|
6024
|
+
'The "owner" option requires "includeShared" to be true. Without includeShared, only your own tables are returned.'
|
|
6025
|
+
);
|
|
6026
|
+
}
|
|
6027
|
+
const owner = options.includeShared ? options.owner : "me";
|
|
6028
|
+
if (owner) {
|
|
6029
|
+
if (owner === "me") {
|
|
5791
6030
|
const profile = await api.get("/zapier/api/v4/profile/", {
|
|
5792
6031
|
authRequired: true
|
|
5793
6032
|
});
|
|
5794
|
-
|
|
6033
|
+
searchParams.owner_customuser_id = String(
|
|
6034
|
+
profile.id
|
|
6035
|
+
);
|
|
6036
|
+
} else {
|
|
6037
|
+
searchParams.owner_customuser_id = owner;
|
|
5795
6038
|
}
|
|
5796
|
-
searchParams.owner_customuser_id = ownerId;
|
|
5797
6039
|
}
|
|
5798
6040
|
if (options.cursor) {
|
|
5799
6041
|
searchParams.offset = options.cursor;
|
|
@@ -5987,6 +6229,7 @@ var DeleteTableOptionsSchema = z.object({
|
|
|
5987
6229
|
// src/plugins/tables/deleteTable/index.ts
|
|
5988
6230
|
var deleteTablePlugin = ({ context }) => {
|
|
5989
6231
|
async function deleteTable(options) {
|
|
6232
|
+
await context.checkCapability("canDeleteTables");
|
|
5990
6233
|
const { api } = context;
|
|
5991
6234
|
await api.delete(`/tables/api/v1/tables/${options.tableId}`, void 0, {
|
|
5992
6235
|
customErrorHandler: ({ status }) => {
|
|
@@ -7396,7 +7639,7 @@ function getCpuTime() {
|
|
|
7396
7639
|
}
|
|
7397
7640
|
|
|
7398
7641
|
// src/plugins/eventEmission/builders.ts
|
|
7399
|
-
var SDK_VERSION = "0.
|
|
7642
|
+
var SDK_VERSION = "0.38.0";
|
|
7400
7643
|
function createBaseEvent(context = {}) {
|
|
7401
7644
|
return {
|
|
7402
7645
|
event_id: generateEventId(),
|
|
@@ -7889,7 +8132,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
|
|
|
7889
8132
|
};
|
|
7890
8133
|
}
|
|
7891
8134
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
7892
|
-
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
8135
|
+
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
7893
8136
|
}
|
|
7894
8137
|
function createZapierSdk(options = {}) {
|
|
7895
8138
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
@@ -7918,9 +8161,12 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
7918
8161
|
onEvent: z.custom().optional().meta({ internal: true }),
|
|
7919
8162
|
fetch: z.custom().optional().meta({ internal: true }),
|
|
7920
8163
|
eventEmission: z.custom().optional().meta({ internal: true }),
|
|
8164
|
+
canIncludeSharedConnections: z.boolean().optional().describe("Allow listing shared connections."),
|
|
8165
|
+
canIncludeSharedTables: z.boolean().optional().describe("Allow listing shared tables."),
|
|
8166
|
+
canDeleteTables: z.boolean().optional().describe("Allow deleting tables."),
|
|
7921
8167
|
// Deprecated
|
|
7922
8168
|
token: z.string().optional().meta({ deprecated: true })
|
|
7923
8169
|
// Use credentials instead
|
|
7924
8170
|
});
|
|
7925
8171
|
|
|
7926
|
-
export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionIdPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_PAGE_SIZE, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
|
8172
|
+
export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_PAGE_SIZE, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|