@zapier/zapier-sdk 0.15.10 → 0.15.12
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/dist/index.cjs +520 -257
- package/dist/index.d.mts +184 -39
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +520 -258
- package/dist/plugins/eventEmission/builders.d.ts +3 -2
- package/dist/plugins/eventEmission/builders.d.ts.map +1 -1
- package/dist/plugins/eventEmission/builders.js +32 -0
- package/dist/plugins/eventEmission/index.d.ts +4 -2
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +8 -2
- package/dist/plugins/eventEmission/types.d.ts +10 -0
- package/dist/plugins/eventEmission/types.d.ts.map +1 -1
- package/dist/plugins/fetch/index.d.ts +2 -1
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +39 -11
- package/dist/plugins/findFirstAuthentication/index.d.ts +2 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +7 -4
- package/dist/plugins/findFirstAuthentication/index.test.js +11 -4
- package/dist/plugins/findUniqueAuthentication/index.d.ts +2 -1
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +7 -4
- package/dist/plugins/findUniqueAuthentication/index.test.js +9 -2
- package/dist/plugins/getAction/index.d.ts +3 -1
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +9 -5
- package/dist/plugins/getAction/index.test.js +5 -3
- package/dist/plugins/getAction/schemas.d.ts +14 -0
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/schemas.js +2 -0
- package/dist/plugins/getApp/index.d.ts +2 -1
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +12 -5
- package/dist/plugins/getApp/index.test.js +7 -0
- package/dist/plugins/getAuthentication/index.d.ts +3 -1
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +5 -3
- package/dist/plugins/getAuthentication/index.test.js +10 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +2 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +5 -3
- package/dist/plugins/getInputFieldsSchema/index.test.js +3 -0
- package/dist/plugins/getProfile/index.d.ts +3 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +5 -3
- package/dist/plugins/listActions/index.d.ts +2 -1
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +19 -14
- package/dist/plugins/listActions/index.test.js +7 -0
- package/dist/plugins/listActions/schemas.d.ts +18 -4
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listActions/schemas.js +2 -0
- package/dist/plugins/listApps/index.d.ts +2 -1
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +7 -3
- package/dist/plugins/listApps/index.test.js +7 -0
- package/dist/plugins/listAuthentications/index.d.ts +2 -1
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +7 -3
- package/dist/plugins/listAuthentications/index.test.js +7 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +18 -4
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/schemas.js +2 -0
- package/dist/plugins/listInputFieldChoices/index.d.ts +3 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +7 -3
- package/dist/plugins/listInputFieldChoices/index.test.js +5 -2
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -4
- package/dist/plugins/listInputFields/index.d.ts +3 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +7 -4
- package/dist/plugins/listInputFields/index.test.js +3 -0
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/manifest/index.test.js +10 -1
- package/dist/plugins/request/index.d.ts +3 -1
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +5 -3
- package/dist/plugins/request/index.test.js +10 -1
- package/dist/plugins/request/schemas.d.ts +28 -0
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/request/schemas.js +2 -0
- package/dist/plugins/runAction/index.d.ts +3 -1
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +8 -3
- package/dist/plugins/runAction/index.test.js +20 -8
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +21 -7
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/schemas/apps/index.js +2 -0
- package/dist/types/telemetry-events.d.ts +31 -2
- package/dist/types/telemetry-events.d.ts.map +1 -1
- package/dist/utils/function-utils.d.ts +42 -3
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/function-utils.js +84 -9
- package/dist/utils/string-utils.d.ts +19 -0
- package/dist/utils/string-utils.d.ts.map +1 -1
- package/dist/utils/string-utils.js +21 -0
- package/dist/utils/string-utils.test.js +24 -1
- package/dist/utils/telemetry-utils.d.ts +44 -0
- package/dist/utils/telemetry-utils.d.ts.map +1 -0
- package/dist/utils/telemetry-utils.js +55 -0
- package/dist/utils/telemetry-utils.test.d.ts +2 -0
- package/dist/utils/telemetry-utils.test.d.ts.map +1 -0
- package/dist/utils/telemetry-utils.test.js +94 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -368,24 +368,49 @@ var FetchInitSchema = z.object({
|
|
|
368
368
|
}).optional().describe("Fetch options including authentication");
|
|
369
369
|
|
|
370
370
|
// src/plugins/fetch/index.ts
|
|
371
|
-
var fetchPlugin = ({ sdk }) => {
|
|
371
|
+
var fetchPlugin = ({ sdk, context }) => {
|
|
372
372
|
return {
|
|
373
373
|
fetch: async function fetch2(url, init) {
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
374
|
+
const startTime = Date.now();
|
|
375
|
+
try {
|
|
376
|
+
const {
|
|
377
|
+
authenticationId,
|
|
378
|
+
callbackUrl,
|
|
379
|
+
authenticationTemplate,
|
|
380
|
+
...fetchInit
|
|
381
|
+
} = init || {};
|
|
382
|
+
const result = await sdk.request({
|
|
383
|
+
url: url.toString(),
|
|
384
|
+
method: fetchInit.method,
|
|
385
|
+
body: fetchInit.body,
|
|
386
|
+
headers: fetchInit.headers,
|
|
387
|
+
authenticationId,
|
|
388
|
+
callbackUrl,
|
|
389
|
+
authenticationTemplate,
|
|
390
|
+
_telemetry: { isNested: true }
|
|
391
|
+
});
|
|
392
|
+
context.eventEmission.emitMethodCalled({
|
|
393
|
+
method_name: "fetch",
|
|
394
|
+
execution_duration_ms: Date.now() - startTime,
|
|
395
|
+
success_flag: true,
|
|
396
|
+
error_message: null,
|
|
397
|
+
error_type: null,
|
|
398
|
+
argument_count: init ? 2 : 1,
|
|
399
|
+
is_paginated: false
|
|
400
|
+
});
|
|
401
|
+
return result;
|
|
402
|
+
} catch (error) {
|
|
403
|
+
context.eventEmission.emitMethodCalled({
|
|
404
|
+
method_name: "fetch",
|
|
405
|
+
execution_duration_ms: Date.now() - startTime,
|
|
406
|
+
success_flag: false,
|
|
407
|
+
error_message: error instanceof Error ? error.message : String(error),
|
|
408
|
+
error_type: error instanceof Error ? error.constructor.name : "Unknown",
|
|
409
|
+
argument_count: init ? 2 : 1,
|
|
410
|
+
is_paginated: false
|
|
411
|
+
});
|
|
412
|
+
throw error;
|
|
413
|
+
}
|
|
389
414
|
},
|
|
390
415
|
context: {
|
|
391
416
|
meta: {
|
|
@@ -574,6 +599,11 @@ var validateOptions = (schema, options) => {
|
|
|
574
599
|
};
|
|
575
600
|
|
|
576
601
|
// src/utils/function-utils.ts
|
|
602
|
+
var TelemetryMarkerSchema = z.object({
|
|
603
|
+
_telemetry: z.object({
|
|
604
|
+
isNested: z.boolean().optional()
|
|
605
|
+
}).optional()
|
|
606
|
+
});
|
|
577
607
|
function extractCursor(data) {
|
|
578
608
|
if (!data?.next) {
|
|
579
609
|
return void 0;
|
|
@@ -593,22 +623,64 @@ function normalizeError(error) {
|
|
|
593
623
|
const message = error instanceof Error ? error.message : String(error);
|
|
594
624
|
return new ZapierUnknownError(`Unknown error: ${message}`, { cause: error });
|
|
595
625
|
}
|
|
596
|
-
function createFunction(coreFn, schema) {
|
|
626
|
+
function createFunction(coreFn, schema, telemetry) {
|
|
597
627
|
const functionName = coreFn.name;
|
|
598
628
|
const namedFunctions = {
|
|
599
629
|
[functionName]: async function(options) {
|
|
630
|
+
const startTime = Date.now();
|
|
631
|
+
const normalizedOptions = options ?? {};
|
|
632
|
+
const isNested = normalizedOptions?._telemetry?.isNested === true;
|
|
600
633
|
try {
|
|
601
|
-
const normalizedOptions = options ?? {};
|
|
602
634
|
if (schema) {
|
|
603
635
|
const validatedOptions = validateOptions(schema, normalizedOptions);
|
|
604
|
-
|
|
636
|
+
const result2 = await coreFn({
|
|
605
637
|
...normalizedOptions,
|
|
606
638
|
...validatedOptions
|
|
607
639
|
});
|
|
640
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
641
|
+
const argumentCount = Object.keys(
|
|
642
|
+
normalizedOptions
|
|
643
|
+
).filter((k) => k !== "_telemetry").length;
|
|
644
|
+
telemetry.onMethodCalled({
|
|
645
|
+
methodName: functionName,
|
|
646
|
+
durationMs: Date.now() - startTime,
|
|
647
|
+
success: true,
|
|
648
|
+
argumentCount,
|
|
649
|
+
isPaginated: false
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
return result2;
|
|
653
|
+
}
|
|
654
|
+
const result = await coreFn(normalizedOptions);
|
|
655
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
656
|
+
const argumentCount = Object.keys(normalizedOptions).filter(
|
|
657
|
+
(k) => k !== "_telemetry"
|
|
658
|
+
).length;
|
|
659
|
+
telemetry.onMethodCalled({
|
|
660
|
+
methodName: functionName,
|
|
661
|
+
durationMs: Date.now() - startTime,
|
|
662
|
+
success: true,
|
|
663
|
+
argumentCount,
|
|
664
|
+
isPaginated: false
|
|
665
|
+
});
|
|
608
666
|
}
|
|
609
|
-
return
|
|
667
|
+
return result;
|
|
610
668
|
} catch (error) {
|
|
611
|
-
|
|
669
|
+
const normalizedError = normalizeError(error);
|
|
670
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
671
|
+
const argumentCount = Object.keys(normalizedOptions).filter(
|
|
672
|
+
(k) => k !== "_telemetry"
|
|
673
|
+
).length;
|
|
674
|
+
telemetry.onMethodCalled({
|
|
675
|
+
methodName: functionName,
|
|
676
|
+
durationMs: Date.now() - startTime,
|
|
677
|
+
success: false,
|
|
678
|
+
error: normalizedError,
|
|
679
|
+
argumentCount,
|
|
680
|
+
isPaginated: false
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
throw normalizedError;
|
|
612
684
|
}
|
|
613
685
|
}
|
|
614
686
|
};
|
|
@@ -638,13 +710,15 @@ function createPageFunction(coreFn) {
|
|
|
638
710
|
};
|
|
639
711
|
return namedFunctions[functionName];
|
|
640
712
|
}
|
|
641
|
-
function createPaginatedFunction(coreFn, schema) {
|
|
713
|
+
function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName) {
|
|
642
714
|
const pageFunction = createPageFunction(coreFn);
|
|
643
|
-
const functionName = coreFn.name;
|
|
715
|
+
const functionName = explicitFunctionName || coreFn.name;
|
|
644
716
|
const validator = schema ? createValidator(schema) : null;
|
|
645
717
|
const namedFunctions = {
|
|
646
718
|
[functionName]: function(options) {
|
|
719
|
+
const startTime = Date.now();
|
|
647
720
|
const normalizedOptions = options ?? {};
|
|
721
|
+
const isNested = normalizedOptions?._telemetry?.isNested === true;
|
|
648
722
|
const validatedOptions = {
|
|
649
723
|
...normalizedOptions,
|
|
650
724
|
...validator ? validator(normalizedOptions) : normalizedOptions
|
|
@@ -661,6 +735,32 @@ function createPaginatedFunction(coreFn, schema) {
|
|
|
661
735
|
}
|
|
662
736
|
return result.value;
|
|
663
737
|
});
|
|
738
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
739
|
+
firstPagePromise.then(() => {
|
|
740
|
+
const argumentCount = Object.keys(
|
|
741
|
+
normalizedOptions
|
|
742
|
+
).filter((k) => k !== "_telemetry").length;
|
|
743
|
+
telemetry.onMethodCalled({
|
|
744
|
+
methodName: functionName,
|
|
745
|
+
durationMs: Date.now() - startTime,
|
|
746
|
+
success: true,
|
|
747
|
+
argumentCount,
|
|
748
|
+
isPaginated: true
|
|
749
|
+
});
|
|
750
|
+
}).catch((error) => {
|
|
751
|
+
const argumentCount = Object.keys(
|
|
752
|
+
normalizedOptions
|
|
753
|
+
).filter((k) => k !== "_telemetry").length;
|
|
754
|
+
telemetry.onMethodCalled({
|
|
755
|
+
methodName: functionName,
|
|
756
|
+
durationMs: Date.now() - startTime,
|
|
757
|
+
success: false,
|
|
758
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
759
|
+
argumentCount,
|
|
760
|
+
isPaginated: true
|
|
761
|
+
});
|
|
762
|
+
});
|
|
763
|
+
}
|
|
664
764
|
return Object.assign(firstPagePromise, {
|
|
665
765
|
[Symbol.asyncIterator]: async function* () {
|
|
666
766
|
yield await firstPagePromise;
|
|
@@ -758,7 +858,7 @@ var ListAppsOptionsSchema = z.object({
|
|
|
758
858
|
pageSize: z.number().min(1).optional().describe("Number of apps per page"),
|
|
759
859
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
760
860
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
761
|
-
}).describe("List all available apps with optional filtering");
|
|
861
|
+
}).merge(TelemetryMarkerSchema).describe("List all available apps with optional filtering");
|
|
762
862
|
var AppItemSchema = ImplementationMetaSchema.omit({
|
|
763
863
|
name: true,
|
|
764
864
|
id: true
|
|
@@ -1184,6 +1284,9 @@ function toSnakeCase(input) {
|
|
|
1184
1284
|
}
|
|
1185
1285
|
return result;
|
|
1186
1286
|
}
|
|
1287
|
+
function stripPageSuffix(functionName) {
|
|
1288
|
+
return functionName.replace(/Page$/, "");
|
|
1289
|
+
}
|
|
1187
1290
|
|
|
1188
1291
|
// src/schemas/App.ts
|
|
1189
1292
|
var AppItemSchema2 = withFormatter(
|
|
@@ -1216,9 +1319,26 @@ var AppItemSchema2 = withFormatter(
|
|
|
1216
1319
|
}
|
|
1217
1320
|
);
|
|
1218
1321
|
|
|
1322
|
+
// src/utils/telemetry-utils.ts
|
|
1323
|
+
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
1324
|
+
return {
|
|
1325
|
+
onMethodCalled: (data) => {
|
|
1326
|
+
emitMethodCalled({
|
|
1327
|
+
method_name: methodName,
|
|
1328
|
+
execution_duration_ms: data.durationMs,
|
|
1329
|
+
success_flag: data.success,
|
|
1330
|
+
error_message: data.error?.message ?? null,
|
|
1331
|
+
error_type: data.error?.constructor.name ?? null,
|
|
1332
|
+
argument_count: data.argumentCount,
|
|
1333
|
+
is_paginated: data.isPaginated
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1219
1339
|
// src/plugins/listApps/index.ts
|
|
1220
1340
|
var listAppsPlugin = ({ context }) => {
|
|
1221
|
-
|
|
1341
|
+
async function listAppsPage(options) {
|
|
1222
1342
|
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1223
1343
|
const appKeys = options.appKeys ?? [];
|
|
1224
1344
|
const appLocators = await resolveAppKeys2({
|
|
@@ -1255,9 +1375,16 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1255
1375
|
...options.cursor && { cursor: options.cursor }
|
|
1256
1376
|
}
|
|
1257
1377
|
});
|
|
1258
|
-
}
|
|
1378
|
+
}
|
|
1379
|
+
const methodName = stripPageSuffix(listAppsPage.name);
|
|
1380
|
+
const listAppsDefinition = createPaginatedFunction(
|
|
1381
|
+
listAppsPage,
|
|
1382
|
+
ListAppsOptionsSchema,
|
|
1383
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
1384
|
+
methodName
|
|
1385
|
+
);
|
|
1259
1386
|
return {
|
|
1260
|
-
listApps,
|
|
1387
|
+
listApps: listAppsDefinition,
|
|
1261
1388
|
context: {
|
|
1262
1389
|
meta: {
|
|
1263
1390
|
listApps: {
|
|
@@ -1401,7 +1528,7 @@ var ListActionsSchema = z.object({
|
|
|
1401
1528
|
pageSize: z.number().min(1).optional().describe("Number of actions per page"),
|
|
1402
1529
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
1403
1530
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
1404
|
-
}).describe("List all actions for a specific app");
|
|
1531
|
+
}).merge(TelemetryMarkerSchema).describe("List all actions for a specific app");
|
|
1405
1532
|
var ActionItemSchema = withFormatter(
|
|
1406
1533
|
ActionSchema.omit({ type: true, name: true, selected_api: true }).extend({
|
|
1407
1534
|
app_key: z.string(),
|
|
@@ -1635,7 +1762,18 @@ var inputFieldKeyResolver = {
|
|
|
1635
1762
|
|
|
1636
1763
|
// src/plugins/listActions/index.ts
|
|
1637
1764
|
var listActionsPlugin = ({ context }) => {
|
|
1638
|
-
const
|
|
1765
|
+
const methodMeta = {
|
|
1766
|
+
categories: ["action"],
|
|
1767
|
+
type: "list",
|
|
1768
|
+
itemType: "Action",
|
|
1769
|
+
inputSchema: ListActionsSchema,
|
|
1770
|
+
outputSchema: ActionItemSchema,
|
|
1771
|
+
resolvers: {
|
|
1772
|
+
appKey: appKeyResolver,
|
|
1773
|
+
actionType: actionTypeResolver
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
async function listActionsPage(options) {
|
|
1639
1777
|
const { api, getVersionedImplementationId } = context;
|
|
1640
1778
|
const selectedApi = await getVersionedImplementationId(options.appKey);
|
|
1641
1779
|
if (!selectedApi) {
|
|
@@ -1691,22 +1829,19 @@ var listActionsPlugin = ({ context }) => {
|
|
|
1691
1829
|
data: allActions,
|
|
1692
1830
|
nextCursor: void 0
|
|
1693
1831
|
};
|
|
1694
|
-
}
|
|
1832
|
+
}
|
|
1833
|
+
const methodName = stripPageSuffix(listActionsPage.name);
|
|
1834
|
+
const listActionsDefinition = createPaginatedFunction(
|
|
1835
|
+
listActionsPage,
|
|
1836
|
+
ListActionsSchema,
|
|
1837
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
1838
|
+
methodName
|
|
1839
|
+
);
|
|
1695
1840
|
return {
|
|
1696
|
-
listActions,
|
|
1841
|
+
listActions: listActionsDefinition,
|
|
1697
1842
|
context: {
|
|
1698
1843
|
meta: {
|
|
1699
|
-
listActions:
|
|
1700
|
-
categories: ["action"],
|
|
1701
|
-
type: "list",
|
|
1702
|
-
itemType: "Action",
|
|
1703
|
-
inputSchema: ListActionsSchema,
|
|
1704
|
-
outputSchema: ActionItemSchema,
|
|
1705
|
-
resolvers: {
|
|
1706
|
-
appKey: appKeyResolver,
|
|
1707
|
-
actionType: actionTypeResolver
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1844
|
+
listActions: methodMeta
|
|
1710
1845
|
}
|
|
1711
1846
|
}
|
|
1712
1847
|
};
|
|
@@ -1999,47 +2134,51 @@ function transformNeedsToFields(needs) {
|
|
|
1999
2134
|
return rootFields;
|
|
2000
2135
|
}
|
|
2001
2136
|
var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2137
|
+
async function listInputFieldsPage(options) {
|
|
2138
|
+
const { api, getVersionedImplementationId } = context;
|
|
2139
|
+
const {
|
|
2140
|
+
appKey,
|
|
2141
|
+
actionKey,
|
|
2142
|
+
actionType,
|
|
2143
|
+
authenticationId = null,
|
|
2144
|
+
inputs
|
|
2145
|
+
} = options;
|
|
2146
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
2147
|
+
if (!selectedApi) {
|
|
2148
|
+
throw new ZapierConfigurationError(
|
|
2149
|
+
"No current_implementation_id found for app",
|
|
2150
|
+
{ configType: "current_implementation_id" }
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
const { data: action } = await sdk.getAction({
|
|
2154
|
+
appKey,
|
|
2155
|
+
actionType,
|
|
2156
|
+
actionKey
|
|
2157
|
+
});
|
|
2158
|
+
const needsData = await fetchImplementationNeeds({
|
|
2159
|
+
api,
|
|
2160
|
+
selectedApi,
|
|
2161
|
+
action: action.key,
|
|
2162
|
+
actionType,
|
|
2163
|
+
authenticationId,
|
|
2164
|
+
inputs
|
|
2165
|
+
});
|
|
2166
|
+
const rootFieldset = transformNeedsToFields(needsData.needs || []);
|
|
2167
|
+
return {
|
|
2168
|
+
data: rootFieldset,
|
|
2169
|
+
nextCursor: void 0
|
|
2170
|
+
// No pagination needed since we return all input fields
|
|
2171
|
+
};
|
|
2172
|
+
}
|
|
2173
|
+
const methodName = stripPageSuffix(listInputFieldsPage.name);
|
|
2174
|
+
const listInputFieldsDefinition = createPaginatedFunction(
|
|
2175
|
+
listInputFieldsPage,
|
|
2176
|
+
ListInputFieldsSchema,
|
|
2177
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2178
|
+
methodName
|
|
2040
2179
|
);
|
|
2041
2180
|
return {
|
|
2042
|
-
listInputFields,
|
|
2181
|
+
listInputFields: listInputFieldsDefinition,
|
|
2043
2182
|
context: {
|
|
2044
2183
|
meta: {
|
|
2045
2184
|
listInputFields: {
|
|
@@ -2074,7 +2213,7 @@ var ListAuthenticationsSchema = z.object({
|
|
|
2074
2213
|
pageSize: z.number().min(1).optional().describe("Number of authentications per page"),
|
|
2075
2214
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
2076
2215
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
2077
|
-
}).describe("List available authentications with optional filtering");
|
|
2216
|
+
}).merge(TelemetryMarkerSchema).describe("List available authentications with optional filtering");
|
|
2078
2217
|
var AuthenticationItemSchema = withFormatter(
|
|
2079
2218
|
AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
|
|
2080
2219
|
{
|
|
@@ -2121,74 +2260,78 @@ var AuthenticationItemSchema = withFormatter(
|
|
|
2121
2260
|
|
|
2122
2261
|
// src/plugins/listAuthentications/index.ts
|
|
2123
2262
|
var listAuthenticationsPlugin = ({ context }) => {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
options.appKey
|
|
2131
|
-
);
|
|
2132
|
-
if (implementationId) {
|
|
2133
|
-
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
2134
|
-
searchParams.versionless_selected_api = versionlessSelectedApi;
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
if (options.authenticationIds && options.authenticationIds.length > 0) {
|
|
2138
|
-
searchParams.ids = options.authenticationIds.join(",");
|
|
2139
|
-
}
|
|
2140
|
-
if (options.search) {
|
|
2141
|
-
searchParams.search = options.search;
|
|
2142
|
-
} else if (options.title) {
|
|
2143
|
-
searchParams.search = options.title;
|
|
2144
|
-
}
|
|
2145
|
-
if (options.accountId) {
|
|
2146
|
-
searchParams.account_id = options.accountId;
|
|
2147
|
-
}
|
|
2148
|
-
if (options.owner) {
|
|
2149
|
-
searchParams.owner = options.owner;
|
|
2150
|
-
}
|
|
2151
|
-
searchParams.limit = options.pageSize.toString();
|
|
2152
|
-
if (options.cursor) {
|
|
2153
|
-
searchParams.offset = options.cursor;
|
|
2154
|
-
}
|
|
2155
|
-
const data = await api.get(
|
|
2156
|
-
"/zapier/api/v4/authentications/",
|
|
2157
|
-
{
|
|
2158
|
-
searchParams,
|
|
2159
|
-
customErrorHandler: ({ status }) => {
|
|
2160
|
-
if (status === 401) {
|
|
2161
|
-
return new ZapierAuthenticationError(
|
|
2162
|
-
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
2163
|
-
{ statusCode: status }
|
|
2164
|
-
);
|
|
2165
|
-
}
|
|
2166
|
-
if (status === 403) {
|
|
2167
|
-
return new ZapierAuthenticationError(
|
|
2168
|
-
`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${status})`,
|
|
2169
|
-
{ statusCode: status }
|
|
2170
|
-
);
|
|
2171
|
-
}
|
|
2172
|
-
return void 0;
|
|
2173
|
-
},
|
|
2174
|
-
authRequired: true
|
|
2175
|
-
}
|
|
2176
|
-
);
|
|
2177
|
-
let auths = (data.results || []).map(
|
|
2178
|
-
(auth) => normalizeAuthenticationItem(auth)
|
|
2263
|
+
async function listAuthenticationsPage(options) {
|
|
2264
|
+
const { api, getVersionedImplementationId } = context;
|
|
2265
|
+
const searchParams = {};
|
|
2266
|
+
if (options.appKey) {
|
|
2267
|
+
const implementationId = await getVersionedImplementationId(
|
|
2268
|
+
options.appKey
|
|
2179
2269
|
);
|
|
2180
|
-
if (
|
|
2181
|
-
|
|
2270
|
+
if (implementationId) {
|
|
2271
|
+
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
2272
|
+
searchParams.versionless_selected_api = versionlessSelectedApi;
|
|
2182
2273
|
}
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2274
|
+
}
|
|
2275
|
+
if (options.authenticationIds && options.authenticationIds.length > 0) {
|
|
2276
|
+
searchParams.ids = options.authenticationIds.join(",");
|
|
2277
|
+
}
|
|
2278
|
+
if (options.search) {
|
|
2279
|
+
searchParams.search = options.search;
|
|
2280
|
+
} else if (options.title) {
|
|
2281
|
+
searchParams.search = options.title;
|
|
2282
|
+
}
|
|
2283
|
+
if (options.accountId) {
|
|
2284
|
+
searchParams.account_id = options.accountId;
|
|
2285
|
+
}
|
|
2286
|
+
if (options.owner) {
|
|
2287
|
+
searchParams.owner = options.owner;
|
|
2288
|
+
}
|
|
2289
|
+
searchParams.limit = options.pageSize.toString();
|
|
2290
|
+
if (options.cursor) {
|
|
2291
|
+
searchParams.offset = options.cursor;
|
|
2292
|
+
}
|
|
2293
|
+
const data = await api.get(
|
|
2294
|
+
"/zapier/api/v4/authentications/",
|
|
2295
|
+
{
|
|
2296
|
+
searchParams,
|
|
2297
|
+
customErrorHandler: ({ status }) => {
|
|
2298
|
+
if (status === 401) {
|
|
2299
|
+
return new ZapierAuthenticationError(
|
|
2300
|
+
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
2301
|
+
{ statusCode: status }
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
if (status === 403) {
|
|
2305
|
+
return new ZapierAuthenticationError(
|
|
2306
|
+
`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${status})`,
|
|
2307
|
+
{ statusCode: status }
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
return void 0;
|
|
2311
|
+
},
|
|
2312
|
+
authRequired: true
|
|
2313
|
+
}
|
|
2314
|
+
);
|
|
2315
|
+
let auths = (data.results || []).map(
|
|
2316
|
+
(auth) => normalizeAuthenticationItem(auth)
|
|
2317
|
+
);
|
|
2318
|
+
if (options.title) {
|
|
2319
|
+
auths = auths.filter((auth) => auth.title === options.title);
|
|
2320
|
+
}
|
|
2321
|
+
return {
|
|
2322
|
+
data: auths,
|
|
2323
|
+
nextCursor: extractCursor(data)
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
const methodName = stripPageSuffix(listAuthenticationsPage.name);
|
|
2327
|
+
const listAuthenticationsDefinition = createPaginatedFunction(
|
|
2328
|
+
listAuthenticationsPage,
|
|
2329
|
+
ListAuthenticationsSchema,
|
|
2330
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2331
|
+
methodName
|
|
2189
2332
|
);
|
|
2190
2333
|
return {
|
|
2191
|
-
listAuthentications,
|
|
2334
|
+
listAuthentications: listAuthenticationsDefinition,
|
|
2192
2335
|
context: {
|
|
2193
2336
|
meta: {
|
|
2194
2337
|
listAuthentications: {
|
|
@@ -2212,9 +2355,12 @@ var GetAppSchema = z.object({
|
|
|
2212
2355
|
}).describe("Get detailed information about a specific app");
|
|
2213
2356
|
|
|
2214
2357
|
// src/plugins/getApp/index.ts
|
|
2215
|
-
var getAppPlugin = ({ sdk }) => {
|
|
2216
|
-
|
|
2217
|
-
const appsIterator = sdk.listApps({
|
|
2358
|
+
var getAppPlugin = ({ sdk, context }) => {
|
|
2359
|
+
async function getApp(options) {
|
|
2360
|
+
const appsIterator = sdk.listApps({
|
|
2361
|
+
appKeys: [options.appKey],
|
|
2362
|
+
_telemetry: { isNested: true }
|
|
2363
|
+
}).items();
|
|
2218
2364
|
for await (const app of appsIterator) {
|
|
2219
2365
|
return {
|
|
2220
2366
|
data: app
|
|
@@ -2223,9 +2369,17 @@ var getAppPlugin = ({ sdk }) => {
|
|
|
2223
2369
|
throw new ZapierAppNotFoundError("App not found", {
|
|
2224
2370
|
appKey: options.appKey
|
|
2225
2371
|
});
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2372
|
+
}
|
|
2373
|
+
const getAppDefinition = createFunction(
|
|
2228
2374
|
getApp,
|
|
2375
|
+
GetAppSchema,
|
|
2376
|
+
createTelemetryCallback(
|
|
2377
|
+
context.eventEmission.emitMethodCalled,
|
|
2378
|
+
getApp.name
|
|
2379
|
+
)
|
|
2380
|
+
);
|
|
2381
|
+
return {
|
|
2382
|
+
getApp: getAppDefinition,
|
|
2229
2383
|
context: {
|
|
2230
2384
|
meta: {
|
|
2231
2385
|
getApp: {
|
|
@@ -2246,13 +2400,13 @@ var GetActionSchema = z.object({
|
|
|
2246
2400
|
appKey: AppKeyPropertySchema,
|
|
2247
2401
|
actionType: ActionTypePropertySchema,
|
|
2248
2402
|
actionKey: ActionKeyPropertySchema
|
|
2249
|
-
}).describe("Get detailed information about a specific action");
|
|
2403
|
+
}).merge(TelemetryMarkerSchema).describe("Get detailed information about a specific action");
|
|
2250
2404
|
|
|
2251
2405
|
// src/plugins/getAction/index.ts
|
|
2252
|
-
var getActionPlugin = ({ sdk }) => {
|
|
2253
|
-
|
|
2406
|
+
var getActionPlugin = ({ sdk, context }) => {
|
|
2407
|
+
async function getAction(options) {
|
|
2254
2408
|
const { actionKey, actionType, appKey } = options;
|
|
2255
|
-
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
2409
|
+
for await (const action of sdk.listActions({ appKey, _telemetry: { isNested: true } }).items()) {
|
|
2256
2410
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2257
2411
|
return { data: action };
|
|
2258
2412
|
}
|
|
@@ -2261,9 +2415,17 @@ var getActionPlugin = ({ sdk }) => {
|
|
|
2261
2415
|
`Action not found: ${actionKey} with type ${actionType}`,
|
|
2262
2416
|
{ resourceType: "Action", resourceId: `${actionKey} (${actionType})` }
|
|
2263
2417
|
);
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2418
|
+
}
|
|
2419
|
+
const getActionDefinition = createFunction(
|
|
2266
2420
|
getAction,
|
|
2421
|
+
GetActionSchema,
|
|
2422
|
+
createTelemetryCallback(
|
|
2423
|
+
context.eventEmission.emitMethodCalled,
|
|
2424
|
+
getAction.name
|
|
2425
|
+
)
|
|
2426
|
+
);
|
|
2427
|
+
return {
|
|
2428
|
+
getAction: getActionDefinition,
|
|
2267
2429
|
context: {
|
|
2268
2430
|
meta: {
|
|
2269
2431
|
getAction: {
|
|
@@ -2338,14 +2500,22 @@ z.object({
|
|
|
2338
2500
|
|
|
2339
2501
|
// src/plugins/getAuthentication/index.ts
|
|
2340
2502
|
var getAuthenticationPlugin = ({ context }) => {
|
|
2341
|
-
|
|
2503
|
+
async function getAuthentication(options) {
|
|
2342
2504
|
const { api } = context;
|
|
2343
2505
|
return await api.get(
|
|
2344
2506
|
`/api/v0/authentications/${options.authenticationId}`
|
|
2345
2507
|
);
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2508
|
+
}
|
|
2509
|
+
const getAuthenticationDefinition = createFunction(
|
|
2348
2510
|
getAuthentication,
|
|
2511
|
+
GetAuthenticationOptionsSchema,
|
|
2512
|
+
createTelemetryCallback(
|
|
2513
|
+
context.eventEmission.emitMethodCalled,
|
|
2514
|
+
getAuthentication.name
|
|
2515
|
+
)
|
|
2516
|
+
);
|
|
2517
|
+
return {
|
|
2518
|
+
getAuthentication: getAuthenticationDefinition,
|
|
2349
2519
|
context: {
|
|
2350
2520
|
meta: {
|
|
2351
2521
|
getAuthentication: {
|
|
@@ -2373,27 +2543,33 @@ var FindFirstAuthenticationSchema = z.object({
|
|
|
2373
2543
|
}).describe("Find the first authentication matching the criteria");
|
|
2374
2544
|
|
|
2375
2545
|
// src/plugins/findFirstAuthentication/index.ts
|
|
2376
|
-
var findFirstAuthenticationPlugin = ({ sdk }) => {
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2546
|
+
var findFirstAuthenticationPlugin = ({ sdk, context }) => {
|
|
2547
|
+
async function findFirstAuthentication(options = {}) {
|
|
2548
|
+
const authsResponse = await sdk.listAuthentications({
|
|
2549
|
+
...options,
|
|
2550
|
+
maxItems: 1,
|
|
2551
|
+
_telemetry: { isNested: true }
|
|
2552
|
+
});
|
|
2553
|
+
if (authsResponse.data.length === 0) {
|
|
2554
|
+
throw new ZapierResourceNotFoundError(
|
|
2555
|
+
"No authentication found matching the specified criteria",
|
|
2556
|
+
{ resourceType: "Authentication" }
|
|
2557
|
+
);
|
|
2558
|
+
}
|
|
2559
|
+
return {
|
|
2560
|
+
data: authsResponse.data[0]
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
const findFirstAuthenticationDefinition = createFunction(
|
|
2564
|
+
findFirstAuthentication,
|
|
2565
|
+
FindFirstAuthenticationSchema,
|
|
2566
|
+
createTelemetryCallback(
|
|
2567
|
+
context.eventEmission.emitMethodCalled,
|
|
2568
|
+
findFirstAuthentication.name
|
|
2569
|
+
)
|
|
2394
2570
|
);
|
|
2395
2571
|
return {
|
|
2396
|
-
findFirstAuthentication,
|
|
2572
|
+
findFirstAuthentication: findFirstAuthenticationDefinition,
|
|
2397
2573
|
context: {
|
|
2398
2574
|
meta: {
|
|
2399
2575
|
findFirstAuthentication: {
|
|
@@ -2418,33 +2594,39 @@ var FindUniqueAuthenticationSchema = z.object({
|
|
|
2418
2594
|
}).describe("Find a unique authentication matching the criteria");
|
|
2419
2595
|
|
|
2420
2596
|
// src/plugins/findUniqueAuthentication/index.ts
|
|
2421
|
-
var findUniqueAuthenticationPlugin = ({ sdk }) => {
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2597
|
+
var findUniqueAuthenticationPlugin = ({ sdk, context }) => {
|
|
2598
|
+
async function findUniqueAuthentication(options = {}) {
|
|
2599
|
+
const authsResponse = await sdk.listAuthentications({
|
|
2600
|
+
...options,
|
|
2601
|
+
maxItems: 2,
|
|
2602
|
+
// Get up to 2 to check for uniqueness
|
|
2603
|
+
_telemetry: { isNested: true }
|
|
2604
|
+
});
|
|
2605
|
+
if (authsResponse.data.length === 0) {
|
|
2606
|
+
throw new ZapierResourceNotFoundError(
|
|
2607
|
+
"No authentication found matching the specified criteria",
|
|
2608
|
+
{ resourceType: "Authentication" }
|
|
2609
|
+
);
|
|
2610
|
+
}
|
|
2611
|
+
if (authsResponse.data.length > 1) {
|
|
2612
|
+
throw new ZapierValidationError(
|
|
2613
|
+
"Multiple authentications found matching the specified criteria. Expected exactly one."
|
|
2614
|
+
);
|
|
2615
|
+
}
|
|
2616
|
+
return {
|
|
2617
|
+
data: authsResponse.data[0]
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
const findUniqueAuthenticationDefinition = createFunction(
|
|
2621
|
+
findUniqueAuthentication,
|
|
2622
|
+
FindUniqueAuthenticationSchema,
|
|
2623
|
+
createTelemetryCallback(
|
|
2624
|
+
context.eventEmission.emitMethodCalled,
|
|
2625
|
+
findUniqueAuthentication.name
|
|
2626
|
+
)
|
|
2445
2627
|
);
|
|
2446
2628
|
return {
|
|
2447
|
-
findUniqueAuthentication,
|
|
2629
|
+
findUniqueAuthentication: findUniqueAuthenticationDefinition,
|
|
2448
2630
|
context: {
|
|
2449
2631
|
meta: {
|
|
2450
2632
|
findUniqueAuthentication: {
|
|
@@ -2515,7 +2697,7 @@ async function executeAction(actionOptions) {
|
|
|
2515
2697
|
});
|
|
2516
2698
|
}
|
|
2517
2699
|
var runActionPlugin = ({ sdk, context }) => {
|
|
2518
|
-
|
|
2700
|
+
async function runActionPage(options) {
|
|
2519
2701
|
const { api } = context;
|
|
2520
2702
|
const {
|
|
2521
2703
|
appKey,
|
|
@@ -2527,7 +2709,8 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2527
2709
|
const actionData = await sdk.getAction({
|
|
2528
2710
|
appKey,
|
|
2529
2711
|
actionKey,
|
|
2530
|
-
actionType
|
|
2712
|
+
actionType,
|
|
2713
|
+
_telemetry: { isNested: true }
|
|
2531
2714
|
});
|
|
2532
2715
|
if (actionData.data.action_type !== actionType) {
|
|
2533
2716
|
throw new ZapierValidationError(
|
|
@@ -2560,9 +2743,16 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2560
2743
|
nextCursor: void 0
|
|
2561
2744
|
// No pagination implemented yet
|
|
2562
2745
|
};
|
|
2563
|
-
}
|
|
2746
|
+
}
|
|
2747
|
+
const methodName = stripPageSuffix(runActionPage.name);
|
|
2748
|
+
const runActionDefinition = createPaginatedFunction(
|
|
2749
|
+
runActionPage,
|
|
2750
|
+
RunActionSchema,
|
|
2751
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2752
|
+
methodName
|
|
2753
|
+
);
|
|
2564
2754
|
return {
|
|
2565
|
-
runAction,
|
|
2755
|
+
runAction: runActionDefinition,
|
|
2566
2756
|
context: {
|
|
2567
2757
|
meta: {
|
|
2568
2758
|
runAction: {
|
|
@@ -2599,7 +2789,7 @@ var RelayRequestSchema = z.object({
|
|
|
2599
2789
|
]).optional().describe("Request headers")
|
|
2600
2790
|
}).extend({
|
|
2601
2791
|
relayBaseUrl: z.string().optional().describe("Base URL for Relay service")
|
|
2602
|
-
}).describe("Make authenticated HTTP requests through Zapier's Relay service");
|
|
2792
|
+
}).merge(TelemetryMarkerSchema).describe("Make authenticated HTTP requests through Zapier's Relay service");
|
|
2603
2793
|
var RelayFetchSchema = RelayRequestSchema;
|
|
2604
2794
|
|
|
2605
2795
|
// src/plugins/request/index.ts
|
|
@@ -2609,7 +2799,7 @@ function transformUrlToRelayPath(url) {
|
|
|
2609
2799
|
return relayPath;
|
|
2610
2800
|
}
|
|
2611
2801
|
var requestPlugin = ({ context }) => {
|
|
2612
|
-
|
|
2802
|
+
async function request(options) {
|
|
2613
2803
|
const { api } = context;
|
|
2614
2804
|
const {
|
|
2615
2805
|
url,
|
|
@@ -2642,9 +2832,17 @@ var requestPlugin = ({ context }) => {
|
|
|
2642
2832
|
body,
|
|
2643
2833
|
headers
|
|
2644
2834
|
});
|
|
2645
|
-
}
|
|
2646
|
-
|
|
2835
|
+
}
|
|
2836
|
+
const requestDefinition = createFunction(
|
|
2647
2837
|
request,
|
|
2838
|
+
RelayRequestSchema,
|
|
2839
|
+
createTelemetryCallback(
|
|
2840
|
+
context.eventEmission.emitMethodCalled,
|
|
2841
|
+
request.name
|
|
2842
|
+
)
|
|
2843
|
+
);
|
|
2844
|
+
return {
|
|
2845
|
+
request: requestDefinition,
|
|
2648
2846
|
context: {
|
|
2649
2847
|
meta: {
|
|
2650
2848
|
request: {
|
|
@@ -3147,7 +3345,7 @@ var UserProfileItemSchema = withFormatter(
|
|
|
3147
3345
|
|
|
3148
3346
|
// src/plugins/getProfile/index.ts
|
|
3149
3347
|
var getProfilePlugin = ({ context }) => {
|
|
3150
|
-
|
|
3348
|
+
async function getProfile() {
|
|
3151
3349
|
const profile = await context.api.get(
|
|
3152
3350
|
"/zapier/api/v4/profile/",
|
|
3153
3351
|
{
|
|
@@ -3163,9 +3361,17 @@ var getProfilePlugin = ({ context }) => {
|
|
|
3163
3361
|
// Computed field
|
|
3164
3362
|
}
|
|
3165
3363
|
};
|
|
3166
|
-
}
|
|
3167
|
-
|
|
3364
|
+
}
|
|
3365
|
+
const getProfileDefinition = createFunction(
|
|
3168
3366
|
getProfile,
|
|
3367
|
+
GetProfileSchema,
|
|
3368
|
+
createTelemetryCallback(
|
|
3369
|
+
context.eventEmission.emitMethodCalled,
|
|
3370
|
+
getProfile.name
|
|
3371
|
+
)
|
|
3372
|
+
);
|
|
3373
|
+
return {
|
|
3374
|
+
getProfile: getProfileDefinition,
|
|
3169
3375
|
context: {
|
|
3170
3376
|
meta: {
|
|
3171
3377
|
getProfile: {
|
|
@@ -4408,44 +4614,49 @@ var GetInputFieldsSchemaSchema = z.object({
|
|
|
4408
4614
|
|
|
4409
4615
|
// src/plugins/getInputFieldsSchema/index.ts
|
|
4410
4616
|
var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4617
|
+
async function getInputFieldsSchema(options) {
|
|
4618
|
+
const { api, getVersionedImplementationId } = context;
|
|
4619
|
+
const {
|
|
4620
|
+
appKey,
|
|
4621
|
+
actionKey,
|
|
4622
|
+
actionType,
|
|
4623
|
+
authenticationId = null,
|
|
4624
|
+
inputs
|
|
4625
|
+
} = options;
|
|
4626
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
4627
|
+
if (!selectedApi) {
|
|
4628
|
+
throw new ZapierConfigurationError(
|
|
4629
|
+
"No current_implementation_id found for app",
|
|
4630
|
+
{ configType: "current_implementation_id" }
|
|
4631
|
+
);
|
|
4632
|
+
}
|
|
4633
|
+
const { data: action } = await sdk.getAction({
|
|
4634
|
+
appKey,
|
|
4635
|
+
actionType,
|
|
4636
|
+
actionKey
|
|
4637
|
+
});
|
|
4638
|
+
const needsData = await fetchImplementationNeeds({
|
|
4639
|
+
api,
|
|
4640
|
+
selectedApi,
|
|
4641
|
+
action: action.key,
|
|
4642
|
+
actionType,
|
|
4643
|
+
authenticationId,
|
|
4644
|
+
inputs
|
|
4645
|
+
});
|
|
4646
|
+
return {
|
|
4647
|
+
data: needsData.schema || {}
|
|
4648
|
+
};
|
|
4649
|
+
}
|
|
4650
|
+
const getInputFieldsSchemaDefinition = createFunction(
|
|
4651
|
+
getInputFieldsSchema,
|
|
4652
|
+
GetInputFieldsSchemaSchema,
|
|
4653
|
+
createTelemetryCallback(
|
|
4654
|
+
context.eventEmission.emitMethodCalled,
|
|
4655
|
+
getInputFieldsSchema.name
|
|
4656
|
+
)
|
|
4446
4657
|
);
|
|
4447
4658
|
return {
|
|
4448
|
-
getInputFieldsSchema,
|
|
4659
|
+
getInputFieldsSchema: getInputFieldsSchemaDefinition,
|
|
4449
4660
|
context: {
|
|
4450
4661
|
meta: {
|
|
4451
4662
|
getInputFieldsSchema: {
|
|
@@ -4514,7 +4725,7 @@ function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
|
4514
4725
|
};
|
|
4515
4726
|
}
|
|
4516
4727
|
var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
4517
|
-
|
|
4728
|
+
async function listInputFieldChoicesPage(options) {
|
|
4518
4729
|
const { api, getVersionedImplementationId } = context;
|
|
4519
4730
|
const {
|
|
4520
4731
|
appKey,
|
|
@@ -4592,9 +4803,16 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
4592
4803
|
data: choices,
|
|
4593
4804
|
nextCursor
|
|
4594
4805
|
};
|
|
4595
|
-
}
|
|
4806
|
+
}
|
|
4807
|
+
const methodName = stripPageSuffix(listInputFieldChoicesPage.name);
|
|
4808
|
+
const listInputFieldChoicesDefinition = createPaginatedFunction(
|
|
4809
|
+
listInputFieldChoicesPage,
|
|
4810
|
+
ListInputFieldChoicesSchema,
|
|
4811
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
4812
|
+
methodName
|
|
4813
|
+
);
|
|
4596
4814
|
return {
|
|
4597
|
-
listInputFieldChoices,
|
|
4815
|
+
listInputFieldChoices: listInputFieldChoicesDefinition,
|
|
4598
4816
|
context: {
|
|
4599
4817
|
meta: {
|
|
4600
4818
|
listInputFieldChoices: {
|
|
@@ -4768,7 +4986,7 @@ function getCpuTime() {
|
|
|
4768
4986
|
|
|
4769
4987
|
// package.json
|
|
4770
4988
|
var package_default = {
|
|
4771
|
-
version: "0.15.
|
|
4989
|
+
version: "0.15.12"};
|
|
4772
4990
|
|
|
4773
4991
|
// src/plugins/eventEmission/builders.ts
|
|
4774
4992
|
function createBaseEvent(context = {}) {
|
|
@@ -4836,11 +5054,44 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
4836
5054
|
...data
|
|
4837
5055
|
};
|
|
4838
5056
|
}
|
|
5057
|
+
function buildMethodCalledEvent(data, context = {}) {
|
|
5058
|
+
return {
|
|
5059
|
+
...createBaseEvent(context),
|
|
5060
|
+
method_name: data.method_name ?? null,
|
|
5061
|
+
method_module: data.method_module ?? null,
|
|
5062
|
+
execution_duration_ms: data.execution_duration_ms,
|
|
5063
|
+
success_flag: data.success_flag,
|
|
5064
|
+
error_message: data.error_message ?? null,
|
|
5065
|
+
error_type: data.error_type ?? null,
|
|
5066
|
+
argument_count: data.argument_count,
|
|
5067
|
+
is_paginated: data.is_paginated ?? false,
|
|
5068
|
+
sdk_version: package_default.version,
|
|
5069
|
+
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
5070
|
+
selected_api: context.selected_api ?? null,
|
|
5071
|
+
app_id: context.app_id ?? null,
|
|
5072
|
+
app_version_id: context.app_version_id ?? null,
|
|
5073
|
+
zap_id: context.zap_id ?? null,
|
|
5074
|
+
node_id: context.node_id ?? null,
|
|
5075
|
+
operation_type: null,
|
|
5076
|
+
operation_key: null,
|
|
5077
|
+
call_context: null,
|
|
5078
|
+
is_retry: false,
|
|
5079
|
+
retry_attempt: null,
|
|
5080
|
+
argument_types: null,
|
|
5081
|
+
return_type: null,
|
|
5082
|
+
caller_method: null,
|
|
5083
|
+
call_stack_depth: null,
|
|
5084
|
+
is_synchronous: false,
|
|
5085
|
+
cpu_time_ms: null,
|
|
5086
|
+
memory_usage_bytes: null
|
|
5087
|
+
};
|
|
5088
|
+
}
|
|
4839
5089
|
|
|
4840
5090
|
// src/plugins/eventEmission/index.ts
|
|
4841
5091
|
var TELEMETRY_EMIT_TIMEOUT_MS = 300;
|
|
4842
5092
|
var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
|
|
4843
5093
|
var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
|
|
5094
|
+
var METHOD_CALLED_EVENT_SUBJECT = "platform.sdk.MethodCalledEvent";
|
|
4844
5095
|
var transportStates = /* @__PURE__ */ new WeakMap();
|
|
4845
5096
|
async function silentEmit(transport, subject, event, userContextPromise) {
|
|
4846
5097
|
try {
|
|
@@ -4942,7 +5193,9 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4942
5193
|
identity_id: null,
|
|
4943
5194
|
visitor_id: null,
|
|
4944
5195
|
correlation_id: null
|
|
4945
|
-
})
|
|
5196
|
+
}),
|
|
5197
|
+
emitMethodCalled: () => {
|
|
5198
|
+
}
|
|
4946
5199
|
}
|
|
4947
5200
|
}
|
|
4948
5201
|
};
|
|
@@ -5094,7 +5347,16 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5094
5347
|
emit: (subject, event) => {
|
|
5095
5348
|
silentEmit(transport, subject, event, getUserContext);
|
|
5096
5349
|
},
|
|
5097
|
-
createBaseEvent: createBaseEventHelper
|
|
5350
|
+
createBaseEvent: createBaseEventHelper,
|
|
5351
|
+
emitMethodCalled: (data) => {
|
|
5352
|
+
const event = buildMethodCalledEvent(data);
|
|
5353
|
+
silentEmit(
|
|
5354
|
+
transport,
|
|
5355
|
+
METHOD_CALLED_EVENT_SUBJECT,
|
|
5356
|
+
event,
|
|
5357
|
+
getUserContext
|
|
5358
|
+
);
|
|
5359
|
+
}
|
|
5098
5360
|
}
|
|
5099
5361
|
}
|
|
5100
5362
|
};
|
|
@@ -5155,4 +5417,4 @@ function createZapierSdk(options = {}) {
|
|
|
5155
5417
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
5156
5418
|
}
|
|
5157
5419
|
|
|
5158
|
-
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resolveAuthToken, runActionPlugin, toSnakeCase, toTitleCase };
|
|
5420
|
+
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resolveAuthToken, runActionPlugin, toSnakeCase, toTitleCase };
|