@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.mjs
CHANGED
|
@@ -42,6 +42,7 @@ function isPositional(schema) {
|
|
|
42
42
|
// src/constants.ts
|
|
43
43
|
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
44
44
|
var MAX_PAGE_LIMIT = 1e4;
|
|
45
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
45
46
|
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
46
47
|
function parseIntEnvVar(name) {
|
|
47
48
|
const value = process.env[name];
|
|
@@ -75,6 +76,9 @@ var ActionTypePropertySchema = z.enum([
|
|
|
75
76
|
var ActionKeyPropertySchema = z.string().min(1).describe("Action key to execute");
|
|
76
77
|
var ConnectionIdPropertySchema = z.union([z.string(), z.number().int().positive()]).describe("Connection ID to use for this action");
|
|
77
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
|
+
);
|
|
78
82
|
var InputsPropertySchema = z.record(z.string(), z.unknown()).describe("Input parameters for the action");
|
|
79
83
|
var LimitPropertySchema = z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
80
84
|
var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
@@ -249,6 +253,7 @@ HTTP Status: ${error.statusCode}`;
|
|
|
249
253
|
var ActionExecutionInputSchema = z.object({
|
|
250
254
|
inputs: z.record(z.string(), z.unknown()).optional(),
|
|
251
255
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
256
|
+
connection: ConnectionPropertySchema.optional(),
|
|
252
257
|
/** @deprecated Use connectionId instead */
|
|
253
258
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
254
259
|
timeoutMs: ActionTimeoutMsPropertySchema
|
|
@@ -257,9 +262,10 @@ var ActionExecutionInputSchema = z.object({
|
|
|
257
262
|
);
|
|
258
263
|
var AppFactoryInputSchema = z.object({
|
|
259
264
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
265
|
+
connection: ConnectionPropertySchema.optional(),
|
|
260
266
|
/** @deprecated Use connectionId instead */
|
|
261
267
|
authenticationId: AuthenticationIdPropertySchema.optional()
|
|
262
|
-
}).describe("Bind a connection
|
|
268
|
+
}).describe("Bind a connection alias or numeric connectionId to an app");
|
|
263
269
|
function getStringProperty(obj, key) {
|
|
264
270
|
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
265
271
|
const value = obj[key];
|
|
@@ -287,44 +293,80 @@ var ActionResultItemSchema = withFormatter(
|
|
|
287
293
|
);
|
|
288
294
|
|
|
289
295
|
// src/plugins/apps/index.ts
|
|
290
|
-
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) {
|
|
291
326
|
return (actionOptions = {}) => {
|
|
292
327
|
const { sdk } = options;
|
|
293
328
|
const {
|
|
294
329
|
inputs,
|
|
295
330
|
connectionId: providedConnectionId,
|
|
331
|
+
connection: providedConnection,
|
|
296
332
|
authenticationId: providedAuthenticationId,
|
|
297
333
|
timeoutMs
|
|
298
334
|
} = actionOptions;
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
+
});
|
|
305
343
|
return sdk.runAction({
|
|
306
344
|
appKey,
|
|
307
345
|
actionType,
|
|
308
346
|
actionKey,
|
|
309
347
|
inputs,
|
|
310
|
-
connectionId
|
|
348
|
+
connectionId,
|
|
349
|
+
connection,
|
|
311
350
|
timeoutMs
|
|
312
351
|
});
|
|
313
352
|
};
|
|
314
353
|
}
|
|
315
|
-
function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
354
|
+
function createActionTypeProxy(appKey, actionType, options, pinnedAuthId, pinnedConnection) {
|
|
316
355
|
if (actionType === "fetch") {
|
|
317
356
|
return async (url, init) => {
|
|
318
357
|
const { sdk } = options;
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
+
});
|
|
325
366
|
return sdk.fetch(url, {
|
|
326
367
|
...init,
|
|
327
|
-
connectionId
|
|
368
|
+
connectionId,
|
|
369
|
+
connection
|
|
328
370
|
});
|
|
329
371
|
};
|
|
330
372
|
}
|
|
@@ -338,7 +380,8 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
338
380
|
actionType,
|
|
339
381
|
actionKey,
|
|
340
382
|
options,
|
|
341
|
-
pinnedAuthId
|
|
383
|
+
pinnedAuthId,
|
|
384
|
+
pinnedConnection
|
|
342
385
|
);
|
|
343
386
|
}
|
|
344
387
|
return void 0;
|
|
@@ -346,7 +389,7 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
346
389
|
}
|
|
347
390
|
);
|
|
348
391
|
}
|
|
349
|
-
function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
392
|
+
function createPinnedAppProxy(appKey, options, pinnedAuthId, pinnedConnection) {
|
|
350
393
|
return new Proxy(
|
|
351
394
|
{},
|
|
352
395
|
{
|
|
@@ -356,7 +399,8 @@ function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
|
356
399
|
appKey,
|
|
357
400
|
actionType,
|
|
358
401
|
options,
|
|
359
|
-
pinnedAuthId
|
|
402
|
+
pinnedAuthId,
|
|
403
|
+
pinnedConnection
|
|
360
404
|
);
|
|
361
405
|
}
|
|
362
406
|
return void 0;
|
|
@@ -367,12 +411,23 @@ function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
|
367
411
|
function createAppProxy(appKey, options) {
|
|
368
412
|
const appFactory = (factoryOptions) => {
|
|
369
413
|
const resolvedConnectionId = factoryOptions.connectionId ?? factoryOptions.authenticationId;
|
|
370
|
-
|
|
414
|
+
const resolvedConnection = factoryOptions.connection;
|
|
415
|
+
if (resolvedConnectionId != null && resolvedConnection != null) {
|
|
416
|
+
throw new ZapierValidationError(
|
|
417
|
+
"Cannot specify both connectionId/authenticationId and connection. Use connectionId for a direct ID, or connection for an alias or numeric ID."
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
if (resolvedConnectionId == null && resolvedConnection == null) {
|
|
371
421
|
throw new ZapierValidationError(
|
|
372
|
-
`Connection
|
|
422
|
+
`Connection is required. Use sdk.apps.${appKey}({ connectionId: "..." }) or sdk.apps.${appKey}({ connection: "name" })`
|
|
373
423
|
);
|
|
374
424
|
}
|
|
375
|
-
return createPinnedAppProxy(
|
|
425
|
+
return createPinnedAppProxy(
|
|
426
|
+
appKey,
|
|
427
|
+
options,
|
|
428
|
+
resolvedConnectionId,
|
|
429
|
+
resolvedConnection
|
|
430
|
+
);
|
|
376
431
|
};
|
|
377
432
|
return new Proxy(appFactory, {
|
|
378
433
|
get(_, actionType) {
|
|
@@ -435,6 +490,7 @@ var FetchInitSchema = z.object({
|
|
|
435
490
|
"Request body \u2014 plain objects and JSON strings are auto-detected and Content-Type is set accordingly"
|
|
436
491
|
),
|
|
437
492
|
connectionId: ConnectionIdPropertySchema.optional(),
|
|
493
|
+
connection: ConnectionPropertySchema.optional(),
|
|
438
494
|
/** @deprecated Use connectionId instead */
|
|
439
495
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
440
496
|
callbackUrl: z.string().optional().describe("URL to send async response to (makes request async)")
|
|
@@ -442,6 +498,119 @@ var FetchInitSchema = z.object({
|
|
|
442
498
|
"Request options including method, headers, body, and authentication"
|
|
443
499
|
);
|
|
444
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
|
+
|
|
445
614
|
// src/utils/id-utils.ts
|
|
446
615
|
function coerceToNumericId(fieldName, value) {
|
|
447
616
|
if (value === "") {
|
|
@@ -536,8 +705,20 @@ var fetchPlugin = ({ context }) => {
|
|
|
536
705
|
const startTime = Date.now();
|
|
537
706
|
const isNested = isTelemetryNested();
|
|
538
707
|
try {
|
|
539
|
-
const {
|
|
540
|
-
|
|
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
|
+
});
|
|
541
722
|
const relayPath = transformUrlToRelayPath(url);
|
|
542
723
|
const headers = normalizeHeaders(
|
|
543
724
|
fetchInit.headers
|
|
@@ -1022,7 +1203,7 @@ function createPageFunction(coreFn) {
|
|
|
1022
1203
|
};
|
|
1023
1204
|
return namedFunctions[functionName];
|
|
1024
1205
|
}
|
|
1025
|
-
function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName) {
|
|
1206
|
+
function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName, defaultPageSize) {
|
|
1026
1207
|
const pageFunction = createPageFunction(coreFn);
|
|
1027
1208
|
const functionName = explicitFunctionName || coreFn.name;
|
|
1028
1209
|
const validator = schema ? createValidator(schema) : null;
|
|
@@ -1036,7 +1217,7 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
|
|
|
1036
1217
|
...normalizedOptions,
|
|
1037
1218
|
...validator ? validator(normalizedOptions) : normalizedOptions
|
|
1038
1219
|
};
|
|
1039
|
-
const pageSize = validatedOptions.pageSize
|
|
1220
|
+
const pageSize = validatedOptions.pageSize ?? defaultPageSize;
|
|
1040
1221
|
const optimizedOptions = {
|
|
1041
1222
|
...validatedOptions,
|
|
1042
1223
|
pageSize
|
|
@@ -1210,7 +1391,9 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1210
1391
|
searchParams: {
|
|
1211
1392
|
appKeys: implementationIds.join(","),
|
|
1212
1393
|
...options.search && { search: options.search },
|
|
1213
|
-
|
|
1394
|
+
...options.pageSize !== void 0 && {
|
|
1395
|
+
pageSize: options.pageSize.toString()
|
|
1396
|
+
},
|
|
1214
1397
|
...options.cursor && { offset: options.cursor }
|
|
1215
1398
|
}
|
|
1216
1399
|
});
|
|
@@ -1220,7 +1403,8 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1220
1403
|
listAppsPage,
|
|
1221
1404
|
ListAppsSchema,
|
|
1222
1405
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
1223
|
-
methodName
|
|
1406
|
+
methodName,
|
|
1407
|
+
DEFAULT_PAGE_SIZE
|
|
1224
1408
|
);
|
|
1225
1409
|
return {
|
|
1226
1410
|
listApps: listAppsDefinition,
|
|
@@ -1237,88 +1421,6 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1237
1421
|
}
|
|
1238
1422
|
};
|
|
1239
1423
|
};
|
|
1240
|
-
|
|
1241
|
-
// src/utils/domain-utils.ts
|
|
1242
|
-
function splitVersionedKey(versionedKey) {
|
|
1243
|
-
const parts = versionedKey.split("@");
|
|
1244
|
-
if (parts.length >= 2) {
|
|
1245
|
-
const baseKey = parts[0];
|
|
1246
|
-
const version = parts.slice(1).join("@");
|
|
1247
|
-
return [baseKey, version];
|
|
1248
|
-
}
|
|
1249
|
-
return [versionedKey, void 0];
|
|
1250
|
-
}
|
|
1251
|
-
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
1252
|
-
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
1253
|
-
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
1254
|
-
return {
|
|
1255
|
-
...restOfImplementationMeta,
|
|
1256
|
-
title: name,
|
|
1257
|
-
key: selectedApi,
|
|
1258
|
-
implementation_id: id,
|
|
1259
|
-
version: appVersion
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
function normalizeActionItem(action) {
|
|
1263
|
-
const { name, type, selected_api: selectedApi } = action;
|
|
1264
|
-
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
1265
|
-
return {
|
|
1266
|
-
// Only include the fields we want - explicitly list them
|
|
1267
|
-
id: action.id,
|
|
1268
|
-
key: action.key,
|
|
1269
|
-
description: action.description,
|
|
1270
|
-
is_important: action.is_important,
|
|
1271
|
-
is_hidden: action.is_hidden,
|
|
1272
|
-
// Transformed fields
|
|
1273
|
-
app_key: appKey,
|
|
1274
|
-
app_version: appVersion,
|
|
1275
|
-
action_type: type,
|
|
1276
|
-
title: name,
|
|
1277
|
-
// Map name to title
|
|
1278
|
-
type: "action"
|
|
1279
|
-
};
|
|
1280
|
-
}
|
|
1281
|
-
function isSlug(slug) {
|
|
1282
|
-
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
1283
|
-
}
|
|
1284
|
-
function isSnakeCasedSlug(slug) {
|
|
1285
|
-
if (slug.match(/^_[0-9]/)) {
|
|
1286
|
-
slug = slug.slice(1);
|
|
1287
|
-
}
|
|
1288
|
-
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
1289
|
-
}
|
|
1290
|
-
function dashifySnakeCasedSlug(slug) {
|
|
1291
|
-
if (!isSnakeCasedSlug(slug)) {
|
|
1292
|
-
return slug;
|
|
1293
|
-
}
|
|
1294
|
-
if (slug.startsWith("_")) {
|
|
1295
|
-
slug = slug.slice(1);
|
|
1296
|
-
}
|
|
1297
|
-
return slug.replace(/_/g, "-");
|
|
1298
|
-
}
|
|
1299
|
-
function isUuid(appKey) {
|
|
1300
|
-
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
1301
|
-
appKey
|
|
1302
|
-
);
|
|
1303
|
-
}
|
|
1304
|
-
function toAppLocator(appKey) {
|
|
1305
|
-
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
1306
|
-
if (isUuid(appKeyWithoutVersion)) {
|
|
1307
|
-
throw new Error(
|
|
1308
|
-
`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
|
|
1309
|
-
);
|
|
1310
|
-
}
|
|
1311
|
-
const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
|
|
1312
|
-
return {
|
|
1313
|
-
lookupAppKey: appKeyWithoutVersion,
|
|
1314
|
-
slug,
|
|
1315
|
-
implementationName: slug ? void 0 : appKeyWithoutVersion,
|
|
1316
|
-
version
|
|
1317
|
-
};
|
|
1318
|
-
}
|
|
1319
|
-
function isResolvedAppLocator(appLocator) {
|
|
1320
|
-
return !!appLocator.implementationName;
|
|
1321
|
-
}
|
|
1322
1424
|
var ListActionsSchema = z.object({
|
|
1323
1425
|
appKey: AppKeyPropertySchema.describe(
|
|
1324
1426
|
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
@@ -2601,7 +2703,8 @@ var listActionsPlugin = ({ context }) => {
|
|
|
2601
2703
|
listActionsPage,
|
|
2602
2704
|
ListActionsSchema,
|
|
2603
2705
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2604
|
-
methodName
|
|
2706
|
+
methodName,
|
|
2707
|
+
DEFAULT_PAGE_SIZE
|
|
2605
2708
|
);
|
|
2606
2709
|
return {
|
|
2607
2710
|
listActions: listActionsDefinition,
|
|
@@ -2958,7 +3061,8 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
2958
3061
|
listInputFieldsPage,
|
|
2959
3062
|
ListInputFieldsSchema,
|
|
2960
3063
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2961
|
-
methodName
|
|
3064
|
+
methodName,
|
|
3065
|
+
DEFAULT_PAGE_SIZE
|
|
2962
3066
|
);
|
|
2963
3067
|
return {
|
|
2964
3068
|
listInputFields: listInputFieldsDefinition,
|
|
@@ -3044,9 +3148,10 @@ var ConnectionItemSchema = withFormatter(ConnectionItemSchema$1, {
|
|
|
3044
3148
|
var listConnectionsPlugin = ({ context }) => {
|
|
3045
3149
|
async function listConnectionsPage(options) {
|
|
3046
3150
|
const { api, getVersionedImplementationId } = context;
|
|
3047
|
-
const searchParams = {
|
|
3048
|
-
|
|
3049
|
-
|
|
3151
|
+
const searchParams = {};
|
|
3152
|
+
if (options.pageSize !== void 0) {
|
|
3153
|
+
searchParams.page_size = options.pageSize.toString();
|
|
3154
|
+
}
|
|
3050
3155
|
if (options.appKey) {
|
|
3051
3156
|
const implementationId = await getVersionedImplementationId(
|
|
3052
3157
|
options.appKey
|
|
@@ -3110,7 +3215,8 @@ var listConnectionsPlugin = ({ context }) => {
|
|
|
3110
3215
|
listConnectionsPage,
|
|
3111
3216
|
ListConnectionsQuerySchema,
|
|
3112
3217
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
3113
|
-
methodName
|
|
3218
|
+
methodName,
|
|
3219
|
+
DEFAULT_PAGE_SIZE
|
|
3114
3220
|
);
|
|
3115
3221
|
return {
|
|
3116
3222
|
listConnections: listConnectionsDefinition,
|
|
@@ -3188,9 +3294,10 @@ var ClientCredentialsCreatedItemSchema = withFormatter(
|
|
|
3188
3294
|
var listClientCredentialsPlugin = ({ context }) => {
|
|
3189
3295
|
async function listClientCredentialsPage(options) {
|
|
3190
3296
|
const { api } = context;
|
|
3191
|
-
const searchParams = {
|
|
3192
|
-
|
|
3193
|
-
|
|
3297
|
+
const searchParams = {};
|
|
3298
|
+
if (options.pageSize !== void 0) {
|
|
3299
|
+
searchParams.pageSize = options.pageSize.toString();
|
|
3300
|
+
}
|
|
3194
3301
|
if (options.cursor) {
|
|
3195
3302
|
searchParams.offset = options.cursor;
|
|
3196
3303
|
}
|
|
@@ -3224,7 +3331,8 @@ var listClientCredentialsPlugin = ({ context }) => {
|
|
|
3224
3331
|
listClientCredentialsPage,
|
|
3225
3332
|
ListClientCredentialsQuerySchema,
|
|
3226
3333
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
3227
|
-
methodName
|
|
3334
|
+
methodName,
|
|
3335
|
+
DEFAULT_PAGE_SIZE
|
|
3228
3336
|
);
|
|
3229
3337
|
return {
|
|
3230
3338
|
listClientCredentials: listClientCredentialsDefinition,
|
|
@@ -3623,6 +3731,9 @@ var RunActionSchema = z.object({
|
|
|
3623
3731
|
connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
|
|
3624
3732
|
"Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service."
|
|
3625
3733
|
),
|
|
3734
|
+
connection: ConnectionPropertySchema.optional().describe(
|
|
3735
|
+
"Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."
|
|
3736
|
+
),
|
|
3626
3737
|
/** @deprecated Use connectionId instead */
|
|
3627
3738
|
authenticationId: ConnectionIdPropertySchema.nullable().optional(),
|
|
3628
3739
|
inputs: InputsPropertySchema.optional().describe(
|
|
@@ -3643,6 +3754,7 @@ async function executeAction(actionOptions) {
|
|
|
3643
3754
|
actionKey,
|
|
3644
3755
|
actionType,
|
|
3645
3756
|
executionOptions,
|
|
3757
|
+
cursor,
|
|
3646
3758
|
connectionId,
|
|
3647
3759
|
timeoutMs
|
|
3648
3760
|
} = actionOptions;
|
|
@@ -3656,6 +3768,9 @@ async function executeAction(actionOptions) {
|
|
|
3656
3768
|
if (connectionId !== null && connectionId !== void 0) {
|
|
3657
3769
|
runRequestData.authentication_id = connectionId;
|
|
3658
3770
|
}
|
|
3771
|
+
if (cursor) {
|
|
3772
|
+
runRequestData.page = cursor;
|
|
3773
|
+
}
|
|
3659
3774
|
const runRequest = {
|
|
3660
3775
|
data: runRequestData
|
|
3661
3776
|
};
|
|
@@ -3675,19 +3790,52 @@ async function executeAction(actionOptions) {
|
|
|
3675
3790
|
resultExtractor: (result) => result.data
|
|
3676
3791
|
});
|
|
3677
3792
|
}
|
|
3793
|
+
var CONTEXT_CACHE_TTL_MS = 6e4;
|
|
3794
|
+
var CONTEXT_CACHE_MAX_SIZE = 500;
|
|
3678
3795
|
var runActionPlugin = ({ sdk, context }) => {
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3796
|
+
const runActionContextCache = /* @__PURE__ */ new Map();
|
|
3797
|
+
function evictIfNeeded() {
|
|
3798
|
+
if (runActionContextCache.size < CONTEXT_CACHE_MAX_SIZE) return;
|
|
3799
|
+
const now = Date.now();
|
|
3800
|
+
let oldestKey;
|
|
3801
|
+
let oldestExpiry = Infinity;
|
|
3802
|
+
let evictedAny = false;
|
|
3803
|
+
for (const [key, entry] of runActionContextCache) {
|
|
3804
|
+
if (now >= entry.expiresAt) {
|
|
3805
|
+
runActionContextCache.delete(key);
|
|
3806
|
+
evictedAny = true;
|
|
3807
|
+
} else if (entry.expiresAt < oldestExpiry) {
|
|
3808
|
+
oldestExpiry = entry.expiresAt;
|
|
3809
|
+
oldestKey = key;
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
if (!evictedAny && oldestKey) {
|
|
3813
|
+
runActionContextCache.delete(oldestKey);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
function getRunActionContext(options) {
|
|
3817
|
+
const { appKey, actionKey, actionType } = options;
|
|
3818
|
+
const contextKey = `${appKey}:${actionKey}:${actionType}`;
|
|
3819
|
+
const cached = runActionContextCache.get(contextKey);
|
|
3820
|
+
if (cached && Date.now() < cached.expiresAt) {
|
|
3821
|
+
return cached.promise;
|
|
3822
|
+
}
|
|
3823
|
+
const pendingContext = resolveRunActionContext(options).catch((error) => {
|
|
3824
|
+
const current = runActionContextCache.get(contextKey);
|
|
3825
|
+
if (current?.promise === pendingContext) {
|
|
3826
|
+
runActionContextCache.delete(contextKey);
|
|
3827
|
+
}
|
|
3828
|
+
throw error;
|
|
3829
|
+
});
|
|
3830
|
+
evictIfNeeded();
|
|
3831
|
+
runActionContextCache.set(contextKey, {
|
|
3832
|
+
promise: pendingContext,
|
|
3833
|
+
expiresAt: Date.now() + CONTEXT_CACHE_TTL_MS
|
|
3834
|
+
});
|
|
3835
|
+
return pendingContext;
|
|
3836
|
+
}
|
|
3837
|
+
async function resolveRunActionContext(options) {
|
|
3838
|
+
const { appKey, actionKey, actionType } = options;
|
|
3691
3839
|
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
3692
3840
|
if (!selectedApi) {
|
|
3693
3841
|
throw new ZapierConfigurationError(
|
|
@@ -3695,11 +3843,6 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3695
3843
|
{ configType: "current_implementation_id" }
|
|
3696
3844
|
);
|
|
3697
3845
|
}
|
|
3698
|
-
setMethodMetadata({
|
|
3699
|
-
selectedApi,
|
|
3700
|
-
operationType: actionType,
|
|
3701
|
-
operationKey: actionKey
|
|
3702
|
-
});
|
|
3703
3846
|
const actionData = await sdk.getAction({
|
|
3704
3847
|
appKey,
|
|
3705
3848
|
actionKey,
|
|
@@ -3710,7 +3853,33 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3710
3853
|
`Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
|
|
3711
3854
|
);
|
|
3712
3855
|
}
|
|
3713
|
-
|
|
3856
|
+
return { selectedApi, actionId: actionData.data.id };
|
|
3857
|
+
}
|
|
3858
|
+
async function runActionPage(options) {
|
|
3859
|
+
const { api } = context;
|
|
3860
|
+
const {
|
|
3861
|
+
appKey,
|
|
3862
|
+
actionKey,
|
|
3863
|
+
actionType,
|
|
3864
|
+
connectionId,
|
|
3865
|
+
connection,
|
|
3866
|
+
authenticationId,
|
|
3867
|
+
inputs = {},
|
|
3868
|
+
cursor,
|
|
3869
|
+
timeoutMs
|
|
3870
|
+
} = options;
|
|
3871
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
3872
|
+
connectionId,
|
|
3873
|
+
connection,
|
|
3874
|
+
authenticationId,
|
|
3875
|
+
resolveConnection: context.resolveConnection
|
|
3876
|
+
});
|
|
3877
|
+
const { selectedApi, actionId } = await getRunActionContext(options);
|
|
3878
|
+
setMethodMetadata({
|
|
3879
|
+
selectedApi,
|
|
3880
|
+
operationType: actionType,
|
|
3881
|
+
operationKey: actionKey
|
|
3882
|
+
});
|
|
3714
3883
|
const result = await executeAction({
|
|
3715
3884
|
api,
|
|
3716
3885
|
selectedApi,
|
|
@@ -3720,6 +3889,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3720
3889
|
actionKey,
|
|
3721
3890
|
actionType,
|
|
3722
3891
|
executionOptions: { inputs },
|
|
3892
|
+
cursor,
|
|
3723
3893
|
connectionId: resolvedConnectionId,
|
|
3724
3894
|
timeoutMs
|
|
3725
3895
|
});
|
|
@@ -3734,8 +3904,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
3734
3904
|
}
|
|
3735
3905
|
return {
|
|
3736
3906
|
data: result.results || [],
|
|
3737
|
-
nextCursor:
|
|
3738
|
-
// No pagination implemented yet
|
|
3907
|
+
nextCursor: result.next_page
|
|
3739
3908
|
};
|
|
3740
3909
|
}
|
|
3741
3910
|
const methodName = stripPageSuffix(runActionPage.name);
|
|
@@ -3900,6 +4069,12 @@ async function readFile(filePath) {
|
|
|
3900
4069
|
}
|
|
3901
4070
|
throw new Error(`File not found: ${filePath}`);
|
|
3902
4071
|
}
|
|
4072
|
+
var ConnectionEntrySchema = z.object({
|
|
4073
|
+
connectionId: z.number().int().positive().describe("Zapier connection ID for the third-party service.")
|
|
4074
|
+
});
|
|
4075
|
+
var ConnectionsMapSchema = z.record(z.string(), ConnectionEntrySchema);
|
|
4076
|
+
|
|
4077
|
+
// src/plugins/manifest/schemas.ts
|
|
3903
4078
|
var DEFAULT_CONFIG_PATH = ".zapierrc";
|
|
3904
4079
|
var ActionEntrySchema = z.object({
|
|
3905
4080
|
appKey: z.string().describe("App key (slug or implementation name)"),
|
|
@@ -3923,18 +4098,17 @@ var ManifestSchema = z.object({
|
|
|
3923
4098
|
),
|
|
3924
4099
|
version: z.string().describe("Version string (e.g., '1.21.1')")
|
|
3925
4100
|
})
|
|
3926
|
-
),
|
|
3927
|
-
actions: z.record(z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas")
|
|
3928
|
-
|
|
4101
|
+
).optional(),
|
|
4102
|
+
actions: z.record(z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas"),
|
|
4103
|
+
connections: ConnectionsMapSchema.optional().describe(
|
|
4104
|
+
"Named connections map. Keys are connection names, values contain a connectionId."
|
|
4105
|
+
)
|
|
4106
|
+
}).describe(
|
|
4107
|
+
"Manifest for app version locking, action configurations, and named connections"
|
|
4108
|
+
);
|
|
3929
4109
|
z.object({
|
|
3930
4110
|
manifestPath: z.string().optional().describe("Path to manifest file"),
|
|
3931
|
-
manifest:
|
|
3932
|
-
z.string(),
|
|
3933
|
-
z.object({
|
|
3934
|
-
implementationName: z.string(),
|
|
3935
|
-
version: z.string().optional()
|
|
3936
|
-
})
|
|
3937
|
-
).optional().describe("Direct manifest object")
|
|
4111
|
+
manifest: ManifestSchema.optional().describe("Direct manifest object")
|
|
3938
4112
|
});
|
|
3939
4113
|
|
|
3940
4114
|
// src/utils/array-utils.ts
|
|
@@ -3950,13 +4124,14 @@ async function toArrayFromAsync(asyncIterable) {
|
|
|
3950
4124
|
function parseManifestContent(content, source) {
|
|
3951
4125
|
try {
|
|
3952
4126
|
const parsed = JSON.parse(content);
|
|
3953
|
-
if (parsed
|
|
3954
|
-
|
|
3955
|
-
if (result.success) {
|
|
3956
|
-
return result.data;
|
|
3957
|
-
}
|
|
3958
|
-
console.warn(`\u26A0\uFE0F Invalid manifest format in ${source}: ${result.error}`);
|
|
4127
|
+
if (parsed == null || typeof parsed !== "object") {
|
|
4128
|
+
return null;
|
|
3959
4129
|
}
|
|
4130
|
+
const result = ManifestSchema.safeParse(parsed);
|
|
4131
|
+
if (result.success) {
|
|
4132
|
+
return result.data;
|
|
4133
|
+
}
|
|
4134
|
+
console.warn(`\u26A0\uFE0F Invalid manifest format in ${source}: ${result.error}`);
|
|
3960
4135
|
return null;
|
|
3961
4136
|
} catch (error) {
|
|
3962
4137
|
console.warn(`\u26A0\uFE0F Failed to parse manifest from ${source}:`, error);
|
|
@@ -4033,6 +4208,9 @@ function findManifestEntry({
|
|
|
4033
4208
|
appKey,
|
|
4034
4209
|
manifest
|
|
4035
4210
|
}) {
|
|
4211
|
+
if (!manifest.apps) {
|
|
4212
|
+
return null;
|
|
4213
|
+
}
|
|
4036
4214
|
const [appKeyWithoutVersion] = splitVersionedKey(appKey);
|
|
4037
4215
|
if (manifest.apps[appKeyWithoutVersion]) {
|
|
4038
4216
|
return [appKeyWithoutVersion, manifest.apps[appKeyWithoutVersion]];
|
|
@@ -4290,7 +4468,11 @@ var manifestPlugin = (params) => {
|
|
|
4290
4468
|
deleteActionEntry,
|
|
4291
4469
|
hasActionEntry,
|
|
4292
4470
|
findManifestEntry,
|
|
4293
|
-
readManifestFromFile
|
|
4471
|
+
readManifestFromFile,
|
|
4472
|
+
getManifestConnections: async () => {
|
|
4473
|
+
const manifest2 = await getResolvedManifest();
|
|
4474
|
+
return manifest2?.connections ?? null;
|
|
4475
|
+
}
|
|
4294
4476
|
}
|
|
4295
4477
|
};
|
|
4296
4478
|
};
|
|
@@ -5653,6 +5835,29 @@ async function batch(tasks, options = {}) {
|
|
|
5653
5835
|
await Promise.all(workers);
|
|
5654
5836
|
return results;
|
|
5655
5837
|
}
|
|
5838
|
+
|
|
5839
|
+
// src/plugins/connections/index.ts
|
|
5840
|
+
var connectionsPlugin = (params) => {
|
|
5841
|
+
const { context } = params;
|
|
5842
|
+
let cachedMap;
|
|
5843
|
+
async function loadConnectionsMap() {
|
|
5844
|
+
if (cachedMap === void 0) {
|
|
5845
|
+
cachedMap = await context.getManifestConnections() ?? null;
|
|
5846
|
+
}
|
|
5847
|
+
return cachedMap;
|
|
5848
|
+
}
|
|
5849
|
+
return {
|
|
5850
|
+
context: {
|
|
5851
|
+
resolveConnection: async (name) => {
|
|
5852
|
+
const map = await loadConnectionsMap();
|
|
5853
|
+
return map?.[name];
|
|
5854
|
+
},
|
|
5855
|
+
getConnectionsMap: async () => {
|
|
5856
|
+
return loadConnectionsMap();
|
|
5857
|
+
}
|
|
5858
|
+
}
|
|
5859
|
+
};
|
|
5860
|
+
};
|
|
5656
5861
|
var TableApiItemSchema = z.object({
|
|
5657
5862
|
id: z.string(),
|
|
5658
5863
|
name: z.string(),
|
|
@@ -5710,9 +5915,10 @@ function extractNextCursor(links) {
|
|
|
5710
5915
|
var listTablesPlugin = ({ context }) => {
|
|
5711
5916
|
async function listTablesPage(options) {
|
|
5712
5917
|
const { api } = context;
|
|
5713
|
-
const searchParams = {
|
|
5714
|
-
|
|
5715
|
-
|
|
5918
|
+
const searchParams = {};
|
|
5919
|
+
if (options.pageSize !== void 0) {
|
|
5920
|
+
searchParams.limit = options.pageSize.toString();
|
|
5921
|
+
}
|
|
5716
5922
|
if (options?.tableIds && options.tableIds.length > 0) {
|
|
5717
5923
|
searchParams.ids = options.tableIds.join(",");
|
|
5718
5924
|
}
|
|
@@ -5765,7 +5971,8 @@ var listTablesPlugin = ({ context }) => {
|
|
|
5765
5971
|
listTablesPage,
|
|
5766
5972
|
ListTablesOptionsSchema,
|
|
5767
5973
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
5768
|
-
methodName
|
|
5974
|
+
methodName,
|
|
5975
|
+
DEFAULT_PAGE_SIZE
|
|
5769
5976
|
);
|
|
5770
5977
|
return {
|
|
5771
5978
|
listTables: listTablesDefinition,
|
|
@@ -6379,9 +6586,10 @@ var listTableRecordsPlugin = ({ context }) => {
|
|
|
6379
6586
|
tableId: options.tableId,
|
|
6380
6587
|
keyMode: options.keyMode
|
|
6381
6588
|
});
|
|
6382
|
-
const body = {
|
|
6383
|
-
|
|
6384
|
-
|
|
6589
|
+
const body = {};
|
|
6590
|
+
if (options.pageSize !== void 0) {
|
|
6591
|
+
body.limit = options.pageSize;
|
|
6592
|
+
}
|
|
6385
6593
|
if (options.filters) {
|
|
6386
6594
|
body.filters = options.filters.map((f) => ({
|
|
6387
6595
|
key: translator.translateFieldKey(f.fieldKey),
|
|
@@ -6444,7 +6652,8 @@ var listTableRecordsPlugin = ({ context }) => {
|
|
|
6444
6652
|
listTableRecordsPage,
|
|
6445
6653
|
ListTableRecordsOptionsSchema,
|
|
6446
6654
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
6447
|
-
methodName
|
|
6655
|
+
methodName,
|
|
6656
|
+
DEFAULT_PAGE_SIZE
|
|
6448
6657
|
);
|
|
6449
6658
|
return {
|
|
6450
6659
|
listTableRecords: listTableRecordsDefinition,
|
|
@@ -7144,7 +7353,8 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
7144
7353
|
listInputFieldChoicesPage,
|
|
7145
7354
|
ListInputFieldChoicesSchema,
|
|
7146
7355
|
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
7147
|
-
methodName
|
|
7356
|
+
methodName,
|
|
7357
|
+
DEFAULT_PAGE_SIZE
|
|
7148
7358
|
);
|
|
7149
7359
|
return {
|
|
7150
7360
|
listInputFieldChoices: listInputFieldChoicesDefinition,
|
|
@@ -7329,7 +7539,7 @@ function getCpuTime() {
|
|
|
7329
7539
|
}
|
|
7330
7540
|
|
|
7331
7541
|
// src/plugins/eventEmission/builders.ts
|
|
7332
|
-
var SDK_VERSION = "0.
|
|
7542
|
+
var SDK_VERSION = "0.37.0";
|
|
7333
7543
|
function createBaseEvent(context = {}) {
|
|
7334
7544
|
return {
|
|
7335
7545
|
event_id: generateEventId(),
|
|
@@ -7822,7 +8032,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
|
|
|
7822
8032
|
};
|
|
7823
8033
|
}
|
|
7824
8034
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
7825
|
-
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);
|
|
8035
|
+
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);
|
|
7826
8036
|
}
|
|
7827
8037
|
function createZapierSdk(options = {}) {
|
|
7828
8038
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
@@ -7856,4 +8066,4 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
7856
8066
|
// Use credentials instead
|
|
7857
8067
|
});
|
|
7858
8068
|
|
|
7859
|
-
export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, ClientCredentialsObjectSchema, ConnectionIdPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, 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 };
|
|
8069
|
+
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, 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 };
|