@zapier/zapier-sdk 0.35.0 → 0.37.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 +91 -32
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/index.cjs +386 -169
- package/dist/index.d.mts +70 -9
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.mjs +380 -170
- 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/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/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +2 -1
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +5 -2
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +6 -4
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +6 -4
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +2 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +2 -1
- package/dist/plugins/manifest/index.d.ts +2 -0
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +14 -6
- package/dist/plugins/manifest/schemas.d.ts +27 -7
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +8 -10
- package/dist/plugins/runAction/index.d.ts +4 -1
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +78 -14
- 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/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +6 -4
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +6 -4
- package/dist/sdk.d.ts +5 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +3 -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.map +1 -1
- 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/function-utils.d.ts +2 -2
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/function-utils.js +2 -3
- package/package.json +6 -1
package/dist/index.cjs
CHANGED
|
@@ -64,6 +64,7 @@ function isPositional(schema) {
|
|
|
64
64
|
// src/constants.ts
|
|
65
65
|
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
66
66
|
var MAX_PAGE_LIMIT = 1e4;
|
|
67
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
67
68
|
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
68
69
|
function parseIntEnvVar(name) {
|
|
69
70
|
const value = process.env[name];
|
|
@@ -97,6 +98,9 @@ var ActionTypePropertySchema = zod.z.enum([
|
|
|
97
98
|
var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
|
|
98
99
|
var ConnectionIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
99
100
|
var AuthenticationIdPropertySchema = ConnectionIdPropertySchema;
|
|
101
|
+
var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
|
|
102
|
+
"Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly."
|
|
103
|
+
);
|
|
100
104
|
var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
|
|
101
105
|
var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
102
106
|
var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
@@ -271,6 +275,7 @@ HTTP Status: ${error.statusCode}`;
|
|
|
271
275
|
var ActionExecutionInputSchema = zod.z.object({
|
|
272
276
|
inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
273
277
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
278
|
+
connection: ConnectionPropertySchema.optional(),
|
|
274
279
|
/** @deprecated Use connectionId instead */
|
|
275
280
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
276
281
|
timeoutMs: ActionTimeoutMsPropertySchema
|
|
@@ -279,9 +284,10 @@ var ActionExecutionInputSchema = zod.z.object({
|
|
|
279
284
|
);
|
|
280
285
|
var AppFactoryInputSchema = zod.z.object({
|
|
281
286
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
287
|
+
connection: ConnectionPropertySchema.optional(),
|
|
282
288
|
/** @deprecated Use connectionId instead */
|
|
283
289
|
authenticationId: AuthenticationIdPropertySchema.optional()
|
|
284
|
-
}).describe("Bind a connection
|
|
290
|
+
}).describe("Bind a connection alias or numeric connectionId to an app");
|
|
285
291
|
function getStringProperty(obj, key) {
|
|
286
292
|
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
287
293
|
const value = obj[key];
|
|
@@ -309,44 +315,80 @@ var ActionResultItemSchema = withFormatter(
|
|
|
309
315
|
);
|
|
310
316
|
|
|
311
317
|
// src/plugins/apps/index.ts
|
|
312
|
-
function
|
|
318
|
+
function resolveProxyConnection({
|
|
319
|
+
providedConnectionId,
|
|
320
|
+
providedConnection,
|
|
321
|
+
providedAuthenticationId,
|
|
322
|
+
pinnedAuthId,
|
|
323
|
+
pinnedConnection,
|
|
324
|
+
errorContext
|
|
325
|
+
}) {
|
|
326
|
+
const hasDirectId = providedConnectionId != null || providedAuthenticationId != null;
|
|
327
|
+
if (hasDirectId && providedConnection != null) {
|
|
328
|
+
throw new ZapierValidationError(
|
|
329
|
+
"Cannot specify both connectionId/authenticationId and connection. Use connectionId for a direct ID, or connection for an alias or numeric ID."
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
const hasPerCall = providedConnectionId != null || providedConnection != null || providedAuthenticationId != null;
|
|
333
|
+
let finalConnectionId;
|
|
334
|
+
let finalConnection;
|
|
335
|
+
if (hasPerCall) {
|
|
336
|
+
finalConnectionId = providedConnectionId ?? providedAuthenticationId;
|
|
337
|
+
finalConnection = finalConnectionId != null ? void 0 : providedConnection;
|
|
338
|
+
} else {
|
|
339
|
+
finalConnectionId = pinnedAuthId;
|
|
340
|
+
finalConnection = pinnedAuthId != null ? void 0 : pinnedConnection;
|
|
341
|
+
}
|
|
342
|
+
if (finalConnectionId == null && finalConnection == null) {
|
|
343
|
+
throw new ZapierValidationError(errorContext);
|
|
344
|
+
}
|
|
345
|
+
return { connectionId: finalConnectionId, connection: finalConnection };
|
|
346
|
+
}
|
|
347
|
+
function createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId, pinnedConnection) {
|
|
313
348
|
return (actionOptions = {}) => {
|
|
314
349
|
const { sdk } = options;
|
|
315
350
|
const {
|
|
316
351
|
inputs,
|
|
317
352
|
connectionId: providedConnectionId,
|
|
353
|
+
connection: providedConnection,
|
|
318
354
|
authenticationId: providedAuthenticationId,
|
|
319
355
|
timeoutMs
|
|
320
356
|
} = actionOptions;
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
357
|
+
const { connectionId, connection } = resolveProxyConnection({
|
|
358
|
+
providedConnectionId,
|
|
359
|
+
providedConnection,
|
|
360
|
+
providedAuthenticationId,
|
|
361
|
+
pinnedAuthId,
|
|
362
|
+
pinnedConnection,
|
|
363
|
+
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.`
|
|
364
|
+
});
|
|
327
365
|
return sdk.runAction({
|
|
328
366
|
appKey,
|
|
329
367
|
actionType,
|
|
330
368
|
actionKey,
|
|
331
369
|
inputs,
|
|
332
|
-
connectionId
|
|
370
|
+
connectionId,
|
|
371
|
+
connection,
|
|
333
372
|
timeoutMs
|
|
334
373
|
});
|
|
335
374
|
};
|
|
336
375
|
}
|
|
337
|
-
function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
376
|
+
function createActionTypeProxy(appKey, actionType, options, pinnedAuthId, pinnedConnection) {
|
|
338
377
|
if (actionType === "fetch") {
|
|
339
378
|
return async (url, init) => {
|
|
340
379
|
const { sdk } = options;
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
380
|
+
const { connectionId, connection } = resolveProxyConnection({
|
|
381
|
+
providedConnectionId: init?.connectionId,
|
|
382
|
+
providedConnection: init?.connection,
|
|
383
|
+
providedAuthenticationId: init?.authenticationId,
|
|
384
|
+
pinnedAuthId,
|
|
385
|
+
pinnedConnection,
|
|
386
|
+
errorContext: `Connection is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }).fetch(...) or provide connectionId/connection in the fetch call.`
|
|
387
|
+
});
|
|
347
388
|
return sdk.fetch(url, {
|
|
348
389
|
...init,
|
|
349
|
-
connectionId
|
|
390
|
+
connectionId,
|
|
391
|
+
connection
|
|
350
392
|
});
|
|
351
393
|
};
|
|
352
394
|
}
|
|
@@ -360,7 +402,8 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
360
402
|
actionType,
|
|
361
403
|
actionKey,
|
|
362
404
|
options,
|
|
363
|
-
pinnedAuthId
|
|
405
|
+
pinnedAuthId,
|
|
406
|
+
pinnedConnection
|
|
364
407
|
);
|
|
365
408
|
}
|
|
366
409
|
return void 0;
|
|
@@ -368,7 +411,7 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
368
411
|
}
|
|
369
412
|
);
|
|
370
413
|
}
|
|
371
|
-
function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
414
|
+
function createPinnedAppProxy(appKey, options, pinnedAuthId, pinnedConnection) {
|
|
372
415
|
return new Proxy(
|
|
373
416
|
{},
|
|
374
417
|
{
|
|
@@ -378,7 +421,8 @@ function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
|
378
421
|
appKey,
|
|
379
422
|
actionType,
|
|
380
423
|
options,
|
|
381
|
-
pinnedAuthId
|
|
424
|
+
pinnedAuthId,
|
|
425
|
+
pinnedConnection
|
|
382
426
|
);
|
|
383
427
|
}
|
|
384
428
|
return void 0;
|
|
@@ -389,12 +433,23 @@ function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
|
389
433
|
function createAppProxy(appKey, options) {
|
|
390
434
|
const appFactory = (factoryOptions) => {
|
|
391
435
|
const resolvedConnectionId = factoryOptions.connectionId ?? factoryOptions.authenticationId;
|
|
392
|
-
|
|
436
|
+
const resolvedConnection = factoryOptions.connection;
|
|
437
|
+
if (resolvedConnectionId != null && resolvedConnection != null) {
|
|
438
|
+
throw new ZapierValidationError(
|
|
439
|
+
"Cannot specify both connectionId/authenticationId and connection. Use connectionId for a direct ID, or connection for an alias or numeric ID."
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
if (resolvedConnectionId == null && resolvedConnection == null) {
|
|
393
443
|
throw new ZapierValidationError(
|
|
394
|
-
`Connection
|
|
444
|
+
`Connection is required. Use sdk.apps.${appKey}({ connectionId: "..." }) or sdk.apps.${appKey}({ connection: "name" })`
|
|
395
445
|
);
|
|
396
446
|
}
|
|
397
|
-
return createPinnedAppProxy(
|
|
447
|
+
return createPinnedAppProxy(
|
|
448
|
+
appKey,
|
|
449
|
+
options,
|
|
450
|
+
resolvedConnectionId,
|
|
451
|
+
resolvedConnection
|
|
452
|
+
);
|
|
398
453
|
};
|
|
399
454
|
return new Proxy(appFactory, {
|
|
400
455
|
get(_, actionType) {
|
|
@@ -457,6 +512,7 @@ var FetchInitSchema = zod.z.object({
|
|
|
457
512
|
"Request body \u2014 plain objects and JSON strings are auto-detected and Content-Type is set accordingly"
|
|
458
513
|
),
|
|
459
514
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
515
|
+
connection: ConnectionPropertySchema.optional(),
|
|
460
516
|
/** @deprecated Use connectionId instead */
|
|
461
517
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
462
518
|
callbackUrl: zod.z.string().optional().describe("URL to send async response to (makes request async)")
|
|
@@ -464,6 +520,119 @@ var FetchInitSchema = zod.z.object({
|
|
|
464
520
|
"Request options including method, headers, body, and authentication"
|
|
465
521
|
);
|
|
466
522
|
|
|
523
|
+
// src/utils/domain-utils.ts
|
|
524
|
+
async function resolveConnectionId({
|
|
525
|
+
connectionId,
|
|
526
|
+
connection,
|
|
527
|
+
authenticationId,
|
|
528
|
+
resolveConnection,
|
|
529
|
+
label
|
|
530
|
+
}) {
|
|
531
|
+
const hasDirectId = connectionId != null || authenticationId != null;
|
|
532
|
+
if (hasDirectId && connection != null) {
|
|
533
|
+
const context = label ? ` for ${label}` : "";
|
|
534
|
+
throw new ZapierValidationError(
|
|
535
|
+
`Cannot specify both connectionId/authenticationId and connection${context}. Use connectionId for a direct ID, or connection for an alias or numeric ID.`
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
let resolvedConnectionId = connectionId ?? authenticationId ?? void 0;
|
|
539
|
+
if (connection != null && resolvedConnectionId == null) {
|
|
540
|
+
if (typeof connection === "number") {
|
|
541
|
+
resolvedConnectionId = connection;
|
|
542
|
+
} else {
|
|
543
|
+
const entry = await resolveConnection(connection);
|
|
544
|
+
if (!entry) {
|
|
545
|
+
throw new ZapierConfigurationError(
|
|
546
|
+
`Connection "${connection}" not found in connections map. Ensure the connection is defined in the manifest connections, or use a numeric connectionId.`,
|
|
547
|
+
{ configType: "connections" }
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
resolvedConnectionId = entry.connectionId;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return resolvedConnectionId;
|
|
554
|
+
}
|
|
555
|
+
function splitVersionedKey(versionedKey) {
|
|
556
|
+
const parts = versionedKey.split("@");
|
|
557
|
+
if (parts.length >= 2) {
|
|
558
|
+
const baseKey = parts[0];
|
|
559
|
+
const version = parts.slice(1).join("@");
|
|
560
|
+
return [baseKey, version];
|
|
561
|
+
}
|
|
562
|
+
return [versionedKey, void 0];
|
|
563
|
+
}
|
|
564
|
+
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
565
|
+
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
566
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
567
|
+
return {
|
|
568
|
+
...restOfImplementationMeta,
|
|
569
|
+
title: name,
|
|
570
|
+
key: selectedApi,
|
|
571
|
+
implementation_id: id,
|
|
572
|
+
version: appVersion
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
function normalizeActionItem(action) {
|
|
576
|
+
const { name, type, selected_api: selectedApi } = action;
|
|
577
|
+
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
578
|
+
return {
|
|
579
|
+
// Only include the fields we want - explicitly list them
|
|
580
|
+
id: action.id,
|
|
581
|
+
key: action.key,
|
|
582
|
+
description: action.description,
|
|
583
|
+
is_important: action.is_important,
|
|
584
|
+
is_hidden: action.is_hidden,
|
|
585
|
+
// Transformed fields
|
|
586
|
+
app_key: appKey,
|
|
587
|
+
app_version: appVersion,
|
|
588
|
+
action_type: type,
|
|
589
|
+
title: name,
|
|
590
|
+
// Map name to title
|
|
591
|
+
type: "action"
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function isSlug(slug) {
|
|
595
|
+
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
596
|
+
}
|
|
597
|
+
function isSnakeCasedSlug(slug) {
|
|
598
|
+
if (slug.match(/^_[0-9]/)) {
|
|
599
|
+
slug = slug.slice(1);
|
|
600
|
+
}
|
|
601
|
+
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
602
|
+
}
|
|
603
|
+
function dashifySnakeCasedSlug(slug) {
|
|
604
|
+
if (!isSnakeCasedSlug(slug)) {
|
|
605
|
+
return slug;
|
|
606
|
+
}
|
|
607
|
+
if (slug.startsWith("_")) {
|
|
608
|
+
slug = slug.slice(1);
|
|
609
|
+
}
|
|
610
|
+
return slug.replace(/_/g, "-");
|
|
611
|
+
}
|
|
612
|
+
function isUuid(appKey) {
|
|
613
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
614
|
+
appKey
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
function toAppLocator(appKey) {
|
|
618
|
+
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
619
|
+
if (isUuid(appKeyWithoutVersion)) {
|
|
620
|
+
throw new Error(
|
|
621
|
+
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
625
|
+
return {
|
|
626
|
+
lookupAppKey: appKeyWithoutVersion,
|
|
627
|
+
slug,
|
|
628
|
+
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
629
|
+
version
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function isResolvedAppLocator(appLocator) {
|
|
633
|
+
return !!appLocator.implementationName;
|
|
634
|
+
}
|
|
635
|
+
|
|
467
636
|
// src/utils/id-utils.ts
|
|
468
637
|
function coerceToNumericId(fieldName, value) {
|
|
469
638
|
if (value === "") {
|
|
@@ -558,8 +727,20 @@ var fetchPlugin = ({ context }) => {
|
|
|
558
727
|
const startTime = Date.now();
|
|
559
728
|
const isNested = isTelemetryNested();
|
|
560
729
|
try {
|
|
561
|
-
const {
|
|
562
|
-
|
|
730
|
+
const {
|
|
731
|
+
connectionId,
|
|
732
|
+
connection,
|
|
733
|
+
authenticationId,
|
|
734
|
+
callbackUrl,
|
|
735
|
+
...fetchInit
|
|
736
|
+
} = init || {};
|
|
737
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
738
|
+
connectionId,
|
|
739
|
+
connection,
|
|
740
|
+
authenticationId,
|
|
741
|
+
resolveConnection: context.resolveConnection,
|
|
742
|
+
label: "fetch"
|
|
743
|
+
});
|
|
563
744
|
const relayPath = transformUrlToRelayPath(url);
|
|
564
745
|
const headers = normalizeHeaders(
|
|
565
746
|
fetchInit.headers
|
|
@@ -1044,7 +1225,7 @@ function createPageFunction(coreFn) {
|
|
|
1044
1225
|
};
|
|
1045
1226
|
return namedFunctions[functionName];
|
|
1046
1227
|
}
|
|
1047
|
-
function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName) {
|
|
1228
|
+
function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName, defaultPageSize) {
|
|
1048
1229
|
const pageFunction = createPageFunction(coreFn);
|
|
1049
1230
|
const functionName = explicitFunctionName || coreFn.name;
|
|
1050
1231
|
const validator = schema ? createValidator(schema) : null;
|
|
@@ -1058,7 +1239,7 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
|
|
|
1058
1239
|
...normalizedOptions,
|
|
1059
1240
|
...validator ? validator(normalizedOptions) : normalizedOptions
|
|
1060
1241
|
};
|
|
1061
|
-
const pageSize = validatedOptions.pageSize
|
|
1242
|
+
const pageSize = validatedOptions.pageSize ?? defaultPageSize;
|
|
1062
1243
|
const optimizedOptions = {
|
|
1063
1244
|
...validatedOptions,
|
|
1064
1245
|
pageSize
|
|
@@ -1232,7 +1413,9 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1232
1413
|
searchParams: {
|
|
1233
1414
|
appKeys: implementationIds.join(","),
|
|
1234
1415
|
...options.search && { search: options.search },
|
|
1235
|
-
|
|
1416
|
+
...options.pageSize !== void 0 && {
|
|
1417
|
+
pageSize: options.pageSize.toString()
|
|
1418
|
+
},
|
|
1236
1419
|
...options.cursor && { offset: options.cursor }
|
|
1237
1420
|
}
|
|
1238
1421
|
});
|
|
@@ -1242,7 +1425,8 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1242
1425
|
listAppsPage,
|
|
1243
1426
|
ListAppsSchema,
|
|
1244
1427
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
1245
|
-
methodName
|
|
1428
|
+
methodName,
|
|
1429
|
+
DEFAULT_PAGE_SIZE
|
|
1246
1430
|
);
|
|
1247
1431
|
return {
|
|
1248
1432
|
listApps: listAppsDefinition,
|
|
@@ -1259,88 +1443,6 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1259
1443
|
}
|
|
1260
1444
|
};
|
|
1261
1445
|
};
|
|
1262
|
-
|
|
1263
|
-
// src/utils/domain-utils.ts
|
|
1264
|
-
function splitVersionedKey(versionedKey) {
|
|
1265
|
-
const parts = versionedKey.split("@");
|
|
1266
|
-
if (parts.length >= 2) {
|
|
1267
|
-
const baseKey = parts[0];
|
|
1268
|
-
const version = parts.slice(1).join("@");
|
|
1269
|
-
return [baseKey, version];
|
|
1270
|
-
}
|
|
1271
|
-
return [versionedKey, void 0];
|
|
1272
|
-
}
|
|
1273
|
-
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
1274
|
-
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
1275
|
-
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
1276
|
-
return {
|
|
1277
|
-
...restOfImplementationMeta,
|
|
1278
|
-
title: name,
|
|
1279
|
-
key: selectedApi,
|
|
1280
|
-
implementation_id: id,
|
|
1281
|
-
version: appVersion
|
|
1282
|
-
};
|
|
1283
|
-
}
|
|
1284
|
-
function normalizeActionItem(action) {
|
|
1285
|
-
const { name, type, selected_api: selectedApi } = action;
|
|
1286
|
-
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
1287
|
-
return {
|
|
1288
|
-
// Only include the fields we want - explicitly list them
|
|
1289
|
-
id: action.id,
|
|
1290
|
-
key: action.key,
|
|
1291
|
-
description: action.description,
|
|
1292
|
-
is_important: action.is_important,
|
|
1293
|
-
is_hidden: action.is_hidden,
|
|
1294
|
-
// Transformed fields
|
|
1295
|
-
app_key: appKey,
|
|
1296
|
-
app_version: appVersion,
|
|
1297
|
-
action_type: type,
|
|
1298
|
-
title: name,
|
|
1299
|
-
// Map name to title
|
|
1300
|
-
type: "action"
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
function isSlug(slug) {
|
|
1304
|
-
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
1305
|
-
}
|
|
1306
|
-
function isSnakeCasedSlug(slug) {
|
|
1307
|
-
if (slug.match(/^_[0-9]/)) {
|
|
1308
|
-
slug = slug.slice(1);
|
|
1309
|
-
}
|
|
1310
|
-
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
1311
|
-
}
|
|
1312
|
-
function dashifySnakeCasedSlug(slug) {
|
|
1313
|
-
if (!isSnakeCasedSlug(slug)) {
|
|
1314
|
-
return slug;
|
|
1315
|
-
}
|
|
1316
|
-
if (slug.startsWith("_")) {
|
|
1317
|
-
slug = slug.slice(1);
|
|
1318
|
-
}
|
|
1319
|
-
return slug.replace(/_/g, "-");
|
|
1320
|
-
}
|
|
1321
|
-
function isUuid(appKey) {
|
|
1322
|
-
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
1323
|
-
appKey
|
|
1324
|
-
);
|
|
1325
|
-
}
|
|
1326
|
-
function toAppLocator(appKey) {
|
|
1327
|
-
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
1328
|
-
if (isUuid(appKeyWithoutVersion)) {
|
|
1329
|
-
throw new Error(
|
|
1330
|
-
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
1331
|
-
);
|
|
1332
|
-
}
|
|
1333
|
-
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
1334
|
-
return {
|
|
1335
|
-
lookupAppKey: appKeyWithoutVersion,
|
|
1336
|
-
slug,
|
|
1337
|
-
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
1338
|
-
version
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
function isResolvedAppLocator(appLocator) {
|
|
1342
|
-
return !!appLocator.implementationName;
|
|
1343
|
-
}
|
|
1344
1446
|
var ListActionsSchema = zod.z.object({
|
|
1345
1447
|
appKey: AppKeyPropertySchema.describe(
|
|
1346
1448
|
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
@@ -2623,7 +2725,8 @@ var listActionsPlugin = ({ context }) => {
|
|
|
2623
2725
|
listActionsPage,
|
|
2624
2726
|
ListActionsSchema,
|
|
2625
2727
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2626
|
-
methodName
|
|
2728
|
+
methodName,
|
|
2729
|
+
DEFAULT_PAGE_SIZE
|
|
2627
2730
|
);
|
|
2628
2731
|
return {
|
|
2629
2732
|
listActions: listActionsDefinition,
|
|
@@ -2980,7 +3083,8 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
2980
3083
|
listInputFieldsPage,
|
|
2981
3084
|
ListInputFieldsSchema,
|
|
2982
3085
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2983
|
-
methodName
|
|
3086
|
+
methodName,
|
|
3087
|
+
DEFAULT_PAGE_SIZE
|
|
2984
3088
|
);
|
|
2985
3089
|
return {
|
|
2986
3090
|
listInputFields: listInputFieldsDefinition,
|
|
@@ -3066,9 +3170,10 @@ var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
|
|
|
3066
3170
|
var listConnectionsPlugin = ({ context }) => {
|
|
3067
3171
|
async function listConnectionsPage(options) {
|
|
3068
3172
|
const { api, getVersionedImplementationId } = context;
|
|
3069
|
-
const searchParams = {
|
|
3070
|
-
|
|
3071
|
-
|
|
3173
|
+
const searchParams = {};
|
|
3174
|
+
if (options.pageSize !== void 0) {
|
|
3175
|
+
searchParams.page_size = options.pageSize.toString();
|
|
3176
|
+
}
|
|
3072
3177
|
if (options.appKey) {
|
|
3073
3178
|
const implementationId = await getVersionedImplementationId(
|
|
3074
3179
|
options.appKey
|
|
@@ -3132,7 +3237,8 @@ var listConnectionsPlugin = ({ context }) => {
|
|
|
3132
3237
|
listConnectionsPage,
|
|
3133
3238
|
ListConnectionsQuerySchema,
|
|
3134
3239
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
3135
|
-
methodName
|
|
3240
|
+
methodName,
|
|
3241
|
+
DEFAULT_PAGE_SIZE
|
|
3136
3242
|
);
|
|
3137
3243
|
return {
|
|
3138
3244
|
listConnections: listConnectionsDefinition,
|
|
@@ -3210,9 +3316,10 @@ var ClientCredentialsCreatedItemSchema = withFormatter(
|
|
|
3210
3316
|
var listClientCredentialsPlugin = ({ context }) => {
|
|
3211
3317
|
async function listClientCredentialsPage(options) {
|
|
3212
3318
|
const { api } = context;
|
|
3213
|
-
const searchParams = {
|
|
3214
|
-
|
|
3215
|
-
|
|
3319
|
+
const searchParams = {};
|
|
3320
|
+
if (options.pageSize !== void 0) {
|
|
3321
|
+
searchParams.pageSize = options.pageSize.toString();
|
|
3322
|
+
}
|
|
3216
3323
|
if (options.cursor) {
|
|
3217
3324
|
searchParams.offset = options.cursor;
|
|
3218
3325
|
}
|
|
@@ -3246,7 +3353,8 @@ var listClientCredentialsPlugin = ({ context }) => {
|
|
|
3246
3353
|
listClientCredentialsPage,
|
|
3247
3354
|
ListClientCredentialsQuerySchema,
|
|
3248
3355
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
3249
|
-
methodName
|
|
3356
|
+
methodName,
|
|
3357
|
+
DEFAULT_PAGE_SIZE
|
|
3250
3358
|
);
|
|
3251
3359
|
return {
|
|
3252
3360
|
listClientCredentials: listClientCredentialsDefinition,
|
|
@@ -3645,6 +3753,9 @@ var RunActionSchema = zod.z.object({
|
|
|
3645
3753
|
connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
|
|
3646
3754
|
"Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service."
|
|
3647
3755
|
),
|
|
3756
|
+
connection: ConnectionPropertySchema.optional().describe(
|
|
3757
|
+
"Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."
|
|
3758
|
+
),
|
|
3648
3759
|
/** @deprecated Use connectionId instead */
|
|
3649
3760
|
authenticationId: ConnectionIdPropertySchema.nullable().optional(),
|
|
3650
3761
|
inputs: InputsPropertySchema.optional().describe(
|
|
@@ -3665,6 +3776,7 @@ async function executeAction(actionOptions) {
|
|
|
3665
3776
|
actionKey,
|
|
3666
3777
|
actionType,
|
|
3667
3778
|
executionOptions,
|
|
3779
|
+
cursor,
|
|
3668
3780
|
connectionId,
|
|
3669
3781
|
timeoutMs
|
|
3670
3782
|
} = actionOptions;
|
|
@@ -3678,6 +3790,9 @@ async function executeAction(actionOptions) {
|
|
|
3678
3790
|
if (connectionId !== null && connectionId !== void 0) {
|
|
3679
3791
|
runRequestData.authentication_id = connectionId;
|
|
3680
3792
|
}
|
|
3793
|
+
if (cursor) {
|
|
3794
|
+
runRequestData.page = cursor;
|
|
3795
|
+
}
|
|
3681
3796
|
const runRequest = {
|
|
3682
3797
|
data: runRequestData
|
|
3683
3798
|
};
|
|
@@ -3697,19 +3812,52 @@ async function executeAction(actionOptions) {
|
|
|
3697
3812
|
resultExtractor: (result) => result.data
|
|
3698
3813
|
});
|
|
3699
3814
|
}
|
|
3815
|
+
var CONTEXT_CACHE_TTL_MS = 6e4;
|
|
3816
|
+
var CONTEXT_CACHE_MAX_SIZE = 500;
|
|
3700
3817
|
var runActionPlugin = ({ sdk, context }) => {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3818
|
+
const runActionContextCache = /* @__PURE__ */ new Map();
|
|
3819
|
+
function evictIfNeeded() {
|
|
3820
|
+
if (runActionContextCache.size < CONTEXT_CACHE_MAX_SIZE) return;
|
|
3821
|
+
const now = Date.now();
|
|
3822
|
+
let oldestKey;
|
|
3823
|
+
let oldestExpiry = Infinity;
|
|
3824
|
+
let evictedAny = false;
|
|
3825
|
+
for (const [key, entry] of runActionContextCache) {
|
|
3826
|
+
if (now >= entry.expiresAt) {
|
|
3827
|
+
runActionContextCache.delete(key);
|
|
3828
|
+
evictedAny = true;
|
|
3829
|
+
} else if (entry.expiresAt < oldestExpiry) {
|
|
3830
|
+
oldestExpiry = entry.expiresAt;
|
|
3831
|
+
oldestKey = key;
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
if (!evictedAny && oldestKey) {
|
|
3835
|
+
runActionContextCache.delete(oldestKey);
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
function getRunActionContext(options) {
|
|
3839
|
+
const { appKey, actionKey, actionType } = options;
|
|
3840
|
+
const contextKey = `${appKey}:${actionKey}:${actionType}`;
|
|
3841
|
+
const cached = runActionContextCache.get(contextKey);
|
|
3842
|
+
if (cached && Date.now() < cached.expiresAt) {
|
|
3843
|
+
return cached.promise;
|
|
3844
|
+
}
|
|
3845
|
+
const pendingContext = resolveRunActionContext(options).catch((error) => {
|
|
3846
|
+
const current = runActionContextCache.get(contextKey);
|
|
3847
|
+
if (current?.promise === pendingContext) {
|
|
3848
|
+
runActionContextCache.delete(contextKey);
|
|
3849
|
+
}
|
|
3850
|
+
throw error;
|
|
3851
|
+
});
|
|
3852
|
+
evictIfNeeded();
|
|
3853
|
+
runActionContextCache.set(contextKey, {
|
|
3854
|
+
promise: pendingContext,
|
|
3855
|
+
expiresAt: Date.now() + CONTEXT_CACHE_TTL_MS
|
|
3856
|
+
});
|
|
3857
|
+
return pendingContext;
|
|
3858
|
+
}
|
|
3859
|
+
async function resolveRunActionContext(options) {
|
|
3860
|
+
const { appKey, actionKey, actionType } = options;
|
|
3713
3861
|
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
3714
3862
|
if (!selectedApi) {
|
|
3715
3863
|
throw new ZapierConfigurationError(
|
|
@@ -3717,11 +3865,6 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3717
3865
|
{ configType: "current_implementation_id" }
|
|
3718
3866
|
);
|
|
3719
3867
|
}
|
|
3720
|
-
setMethodMetadata({
|
|
3721
|
-
selectedApi,
|
|
3722
|
-
operationType: actionType,
|
|
3723
|
-
operationKey: actionKey
|
|
3724
|
-
});
|
|
3725
3868
|
const actionData = await sdk.getAction({
|
|
3726
3869
|
appKey,
|
|
3727
3870
|
actionKey,
|
|
@@ -3732,7 +3875,33 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3732
3875
|
`Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
|
|
3733
3876
|
);
|
|
3734
3877
|
}
|
|
3735
|
-
|
|
3878
|
+
return { selectedApi, actionId: actionData.data.id };
|
|
3879
|
+
}
|
|
3880
|
+
async function runActionPage(options) {
|
|
3881
|
+
const { api } = context;
|
|
3882
|
+
const {
|
|
3883
|
+
appKey,
|
|
3884
|
+
actionKey,
|
|
3885
|
+
actionType,
|
|
3886
|
+
connectionId,
|
|
3887
|
+
connection,
|
|
3888
|
+
authenticationId,
|
|
3889
|
+
inputs = {},
|
|
3890
|
+
cursor,
|
|
3891
|
+
timeoutMs
|
|
3892
|
+
} = options;
|
|
3893
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
3894
|
+
connectionId,
|
|
3895
|
+
connection,
|
|
3896
|
+
authenticationId,
|
|
3897
|
+
resolveConnection: context.resolveConnection
|
|
3898
|
+
});
|
|
3899
|
+
const { selectedApi, actionId } = await getRunActionContext(options);
|
|
3900
|
+
setMethodMetadata({
|
|
3901
|
+
selectedApi,
|
|
3902
|
+
operationType: actionType,
|
|
3903
|
+
operationKey: actionKey
|
|
3904
|
+
});
|
|
3736
3905
|
const result = await executeAction({
|
|
3737
3906
|
api,
|
|
3738
3907
|
selectedApi,
|
|
@@ -3742,6 +3911,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3742
3911
|
actionKey,
|
|
3743
3912
|
actionType,
|
|
3744
3913
|
executionOptions: { inputs },
|
|
3914
|
+
cursor,
|
|
3745
3915
|
connectionId: resolvedConnectionId,
|
|
3746
3916
|
timeoutMs
|
|
3747
3917
|
});
|
|
@@ -3756,8 +3926,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3756
3926
|
}
|
|
3757
3927
|
return {
|
|
3758
3928
|
data: result.results || [],
|
|
3759
|
-
nextCursor:
|
|
3760
|
-
// No pagination implemented yet
|
|
3929
|
+
nextCursor: result.next_page
|
|
3761
3930
|
};
|
|
3762
3931
|
}
|
|
3763
3932
|
const methodName = stripPageSuffix(runActionPage.name);
|
|
@@ -3922,6 +4091,12 @@ async function readFile(filePath) {
|
|
|
3922
4091
|
}
|
|
3923
4092
|
throw new Error(`File not found: ${filePath}`);
|
|
3924
4093
|
}
|
|
4094
|
+
var ConnectionEntrySchema = zod.z.object({
|
|
4095
|
+
connectionId: zod.z.number().int().positive().describe("Zapier connection ID for the third-party service.")
|
|
4096
|
+
});
|
|
4097
|
+
var ConnectionsMapSchema = zod.z.record(zod.z.string(), ConnectionEntrySchema);
|
|
4098
|
+
|
|
4099
|
+
// src/plugins/manifest/schemas.ts
|
|
3925
4100
|
var DEFAULT_CONFIG_PATH = ".zapierrc";
|
|
3926
4101
|
var ActionEntrySchema = zod.z.object({
|
|
3927
4102
|
appKey: zod.z.string().describe("App key (slug or implementation name)"),
|
|
@@ -3945,18 +4120,17 @@ var ManifestSchema = zod.z.object({
|
|
|
3945
4120
|
),
|
|
3946
4121
|
version: zod.z.string().describe("Version string (e.g., '1.21.1')")
|
|
3947
4122
|
})
|
|
3948
|
-
),
|
|
3949
|
-
actions: zod.z.record(zod.z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas")
|
|
3950
|
-
|
|
4123
|
+
).optional(),
|
|
4124
|
+
actions: zod.z.record(zod.z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas"),
|
|
4125
|
+
connections: ConnectionsMapSchema.optional().describe(
|
|
4126
|
+
"Named connections map. Keys are connection names, values contain a connectionId."
|
|
4127
|
+
)
|
|
4128
|
+
}).describe(
|
|
4129
|
+
"Manifest for app version locking, action configurations, and named connections"
|
|
4130
|
+
);
|
|
3951
4131
|
zod.z.object({
|
|
3952
4132
|
manifestPath: zod.z.string().optional().describe("Path to manifest file"),
|
|
3953
|
-
manifest:
|
|
3954
|
-
zod.z.string(),
|
|
3955
|
-
zod.z.object({
|
|
3956
|
-
implementationName: zod.z.string(),
|
|
3957
|
-
version: zod.z.string().optional()
|
|
3958
|
-
})
|
|
3959
|
-
).optional().describe("Direct manifest object")
|
|
4133
|
+
manifest: ManifestSchema.optional().describe("Direct manifest object")
|
|
3960
4134
|
});
|
|
3961
4135
|
|
|
3962
4136
|
// src/utils/array-utils.ts
|
|
@@ -3972,13 +4146,14 @@ async function toArrayFromAsync(asyncIterable) {
|
|
|
3972
4146
|
function parseManifestContent(content, source) {
|
|
3973
4147
|
try {
|
|
3974
4148
|
const parsed = JSON.parse(content);
|
|
3975
|
-
if (parsed
|
|
3976
|
-
|
|
3977
|
-
if (result.success) {
|
|
3978
|
-
return result.data;
|
|
3979
|
-
}
|
|
3980
|
-
console.warn(`\u26A0\uFE0F Invalid manifest format in ${source}: ${result.error}`);
|
|
4149
|
+
if (parsed == null || typeof parsed !== "object") {
|
|
4150
|
+
return null;
|
|
3981
4151
|
}
|
|
4152
|
+
const result = ManifestSchema.safeParse(parsed);
|
|
4153
|
+
if (result.success) {
|
|
4154
|
+
return result.data;
|
|
4155
|
+
}
|
|
4156
|
+
console.warn(`\u26A0\uFE0F Invalid manifest format in ${source}: ${result.error}`);
|
|
3982
4157
|
return null;
|
|
3983
4158
|
} catch (error) {
|
|
3984
4159
|
console.warn(`\u26A0\uFE0F Failed to parse manifest from ${source}:`, error);
|
|
@@ -4055,6 +4230,9 @@ function findManifestEntry({
|
|
|
4055
4230
|
appKey,
|
|
4056
4231
|
manifest
|
|
4057
4232
|
}) {
|
|
4233
|
+
if (!manifest.apps) {
|
|
4234
|
+
return null;
|
|
4235
|
+
}
|
|
4058
4236
|
const [appKeyWithoutVersion] = splitVersionedKey(appKey);
|
|
4059
4237
|
if (manifest.apps[appKeyWithoutVersion]) {
|
|
4060
4238
|
return [appKeyWithoutVersion, manifest.apps[appKeyWithoutVersion]];
|
|
@@ -4312,7 +4490,11 @@ var manifestPlugin = (params) => {
|
|
|
4312
4490
|
deleteActionEntry,
|
|
4313
4491
|
hasActionEntry,
|
|
4314
4492
|
findManifestEntry,
|
|
4315
|
-
readManifestFromFile
|
|
4493
|
+
readManifestFromFile,
|
|
4494
|
+
getManifestConnections: async () => {
|
|
4495
|
+
const manifest2 = await getResolvedManifest();
|
|
4496
|
+
return manifest2?.connections ?? null;
|
|
4497
|
+
}
|
|
4316
4498
|
}
|
|
4317
4499
|
};
|
|
4318
4500
|
};
|
|
@@ -5675,6 +5857,29 @@ async function batch(tasks, options = {}) {
|
|
|
5675
5857
|
await Promise.all(workers);
|
|
5676
5858
|
return results;
|
|
5677
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
|
+
};
|
|
5678
5883
|
var TableApiItemSchema = zod.z.object({
|
|
5679
5884
|
id: zod.z.string(),
|
|
5680
5885
|
name: zod.z.string(),
|
|
@@ -5732,9 +5937,10 @@ function extractNextCursor(links) {
|
|
|
5732
5937
|
var listTablesPlugin = ({ context }) => {
|
|
5733
5938
|
async function listTablesPage(options) {
|
|
5734
5939
|
const { api } = context;
|
|
5735
|
-
const searchParams = {
|
|
5736
|
-
|
|
5737
|
-
|
|
5940
|
+
const searchParams = {};
|
|
5941
|
+
if (options.pageSize !== void 0) {
|
|
5942
|
+
searchParams.limit = options.pageSize.toString();
|
|
5943
|
+
}
|
|
5738
5944
|
if (options?.tableIds && options.tableIds.length > 0) {
|
|
5739
5945
|
searchParams.ids = options.tableIds.join(",");
|
|
5740
5946
|
}
|
|
@@ -5787,7 +5993,8 @@ var listTablesPlugin = ({ context }) => {
|
|
|
5787
5993
|
listTablesPage,
|
|
5788
5994
|
ListTablesOptionsSchema,
|
|
5789
5995
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
5790
|
-
methodName
|
|
5996
|
+
methodName,
|
|
5997
|
+
DEFAULT_PAGE_SIZE
|
|
5791
5998
|
);
|
|
5792
5999
|
return {
|
|
5793
6000
|
listTables: listTablesDefinition,
|
|
@@ -6401,9 +6608,10 @@ var listTableRecordsPlugin = ({ context }) => {
|
|
|
6401
6608
|
tableId: options.tableId,
|
|
6402
6609
|
keyMode: options.keyMode
|
|
6403
6610
|
});
|
|
6404
|
-
const body = {
|
|
6405
|
-
|
|
6406
|
-
|
|
6611
|
+
const body = {};
|
|
6612
|
+
if (options.pageSize !== void 0) {
|
|
6613
|
+
body.limit = options.pageSize;
|
|
6614
|
+
}
|
|
6407
6615
|
if (options.filters) {
|
|
6408
6616
|
body.filters = options.filters.map((f) => ({
|
|
6409
6617
|
key: translator.translateFieldKey(f.fieldKey),
|
|
@@ -6466,7 +6674,8 @@ var listTableRecordsPlugin = ({ context }) => {
|
|
|
6466
6674
|
listTableRecordsPage,
|
|
6467
6675
|
ListTableRecordsOptionsSchema,
|
|
6468
6676
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
6469
|
-
methodName
|
|
6677
|
+
methodName,
|
|
6678
|
+
DEFAULT_PAGE_SIZE
|
|
6470
6679
|
);
|
|
6471
6680
|
return {
|
|
6472
6681
|
listTableRecords: listTableRecordsDefinition,
|
|
@@ -7166,7 +7375,8 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
7166
7375
|
listInputFieldChoicesPage,
|
|
7167
7376
|
ListInputFieldChoicesSchema,
|
|
7168
7377
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
7169
|
-
methodName
|
|
7378
|
+
methodName,
|
|
7379
|
+
DEFAULT_PAGE_SIZE
|
|
7170
7380
|
);
|
|
7171
7381
|
return {
|
|
7172
7382
|
listInputFieldChoices: listInputFieldChoicesDefinition,
|
|
@@ -7351,7 +7561,7 @@ function getCpuTime() {
|
|
|
7351
7561
|
}
|
|
7352
7562
|
|
|
7353
7563
|
// src/plugins/eventEmission/builders.ts
|
|
7354
|
-
var SDK_VERSION = "0.
|
|
7564
|
+
var SDK_VERSION = "0.37.0";
|
|
7355
7565
|
function createBaseEvent(context = {}) {
|
|
7356
7566
|
return {
|
|
7357
7567
|
event_id: generateEventId(),
|
|
@@ -7844,7 +8054,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
|
|
|
7844
8054
|
};
|
|
7845
8055
|
}
|
|
7846
8056
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
7847
|
-
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);
|
|
8057
|
+
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).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);
|
|
7848
8058
|
}
|
|
7849
8059
|
function createZapierSdk(options = {}) {
|
|
7850
8060
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
@@ -7884,13 +8094,19 @@ exports.ActionTypePropertySchema = ActionTypePropertySchema;
|
|
|
7884
8094
|
exports.AppKeyPropertySchema = AppKeyPropertySchema;
|
|
7885
8095
|
exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
|
|
7886
8096
|
exports.BaseSdkOptionsSchema = BaseSdkOptionsSchema;
|
|
8097
|
+
exports.CONTEXT_CACHE_MAX_SIZE = CONTEXT_CACHE_MAX_SIZE;
|
|
8098
|
+
exports.CONTEXT_CACHE_TTL_MS = CONTEXT_CACHE_TTL_MS;
|
|
7887
8099
|
exports.ClientCredentialsObjectSchema = ClientCredentialsObjectSchema;
|
|
8100
|
+
exports.ConnectionEntrySchema = ConnectionEntrySchema;
|
|
7888
8101
|
exports.ConnectionIdPropertySchema = ConnectionIdPropertySchema;
|
|
8102
|
+
exports.ConnectionPropertySchema = ConnectionPropertySchema;
|
|
8103
|
+
exports.ConnectionsMapSchema = ConnectionsMapSchema;
|
|
7889
8104
|
exports.CredentialsFunctionSchema = CredentialsFunctionSchema;
|
|
7890
8105
|
exports.CredentialsObjectSchema = CredentialsObjectSchema;
|
|
7891
8106
|
exports.CredentialsSchema = CredentialsSchema;
|
|
7892
8107
|
exports.DEFAULT_ACTION_TIMEOUT_MS = DEFAULT_ACTION_TIMEOUT_MS;
|
|
7893
8108
|
exports.DEFAULT_CONFIG_PATH = DEFAULT_CONFIG_PATH;
|
|
8109
|
+
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
|
7894
8110
|
exports.DebugPropertySchema = DebugPropertySchema;
|
|
7895
8111
|
exports.InputsPropertySchema = InputsPropertySchema;
|
|
7896
8112
|
exports.LimitPropertySchema = LimitPropertySchema;
|
|
@@ -7936,6 +8152,7 @@ exports.clientCredentialsNameResolver = clientCredentialsNameResolver;
|
|
|
7936
8152
|
exports.clientIdResolver = clientIdResolver;
|
|
7937
8153
|
exports.connectionIdGenericResolver = connectionIdGenericResolver;
|
|
7938
8154
|
exports.connectionIdResolver = connectionIdResolver;
|
|
8155
|
+
exports.connectionsPlugin = connectionsPlugin;
|
|
7939
8156
|
exports.createBaseEvent = createBaseEvent;
|
|
7940
8157
|
exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
|
|
7941
8158
|
exports.createFunction = createFunction;
|