@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.cjs
CHANGED
|
@@ -390,24 +390,49 @@ var FetchInitSchema = zod.z.object({
|
|
|
390
390
|
}).optional().describe("Fetch options including authentication");
|
|
391
391
|
|
|
392
392
|
// src/plugins/fetch/index.ts
|
|
393
|
-
var fetchPlugin = ({ sdk }) => {
|
|
393
|
+
var fetchPlugin = ({ sdk, context }) => {
|
|
394
394
|
return {
|
|
395
395
|
fetch: async function fetch2(url, init) {
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
396
|
+
const startTime = Date.now();
|
|
397
|
+
try {
|
|
398
|
+
const {
|
|
399
|
+
authenticationId,
|
|
400
|
+
callbackUrl,
|
|
401
|
+
authenticationTemplate,
|
|
402
|
+
...fetchInit
|
|
403
|
+
} = init || {};
|
|
404
|
+
const result = await sdk.request({
|
|
405
|
+
url: url.toString(),
|
|
406
|
+
method: fetchInit.method,
|
|
407
|
+
body: fetchInit.body,
|
|
408
|
+
headers: fetchInit.headers,
|
|
409
|
+
authenticationId,
|
|
410
|
+
callbackUrl,
|
|
411
|
+
authenticationTemplate,
|
|
412
|
+
_telemetry: { isNested: true }
|
|
413
|
+
});
|
|
414
|
+
context.eventEmission.emitMethodCalled({
|
|
415
|
+
method_name: "fetch",
|
|
416
|
+
execution_duration_ms: Date.now() - startTime,
|
|
417
|
+
success_flag: true,
|
|
418
|
+
error_message: null,
|
|
419
|
+
error_type: null,
|
|
420
|
+
argument_count: init ? 2 : 1,
|
|
421
|
+
is_paginated: false
|
|
422
|
+
});
|
|
423
|
+
return result;
|
|
424
|
+
} catch (error) {
|
|
425
|
+
context.eventEmission.emitMethodCalled({
|
|
426
|
+
method_name: "fetch",
|
|
427
|
+
execution_duration_ms: Date.now() - startTime,
|
|
428
|
+
success_flag: false,
|
|
429
|
+
error_message: error instanceof Error ? error.message : String(error),
|
|
430
|
+
error_type: error instanceof Error ? error.constructor.name : "Unknown",
|
|
431
|
+
argument_count: init ? 2 : 1,
|
|
432
|
+
is_paginated: false
|
|
433
|
+
});
|
|
434
|
+
throw error;
|
|
435
|
+
}
|
|
411
436
|
},
|
|
412
437
|
context: {
|
|
413
438
|
meta: {
|
|
@@ -596,6 +621,11 @@ var validateOptions = (schema, options) => {
|
|
|
596
621
|
};
|
|
597
622
|
|
|
598
623
|
// src/utils/function-utils.ts
|
|
624
|
+
var TelemetryMarkerSchema = zod.z.object({
|
|
625
|
+
_telemetry: zod.z.object({
|
|
626
|
+
isNested: zod.z.boolean().optional()
|
|
627
|
+
}).optional()
|
|
628
|
+
});
|
|
599
629
|
function extractCursor(data) {
|
|
600
630
|
if (!data?.next) {
|
|
601
631
|
return void 0;
|
|
@@ -615,22 +645,64 @@ function normalizeError(error) {
|
|
|
615
645
|
const message = error instanceof Error ? error.message : String(error);
|
|
616
646
|
return new ZapierUnknownError(`Unknown error: ${message}`, { cause: error });
|
|
617
647
|
}
|
|
618
|
-
function createFunction(coreFn, schema) {
|
|
648
|
+
function createFunction(coreFn, schema, telemetry) {
|
|
619
649
|
const functionName = coreFn.name;
|
|
620
650
|
const namedFunctions = {
|
|
621
651
|
[functionName]: async function(options) {
|
|
652
|
+
const startTime = Date.now();
|
|
653
|
+
const normalizedOptions = options ?? {};
|
|
654
|
+
const isNested = normalizedOptions?._telemetry?.isNested === true;
|
|
622
655
|
try {
|
|
623
|
-
const normalizedOptions = options ?? {};
|
|
624
656
|
if (schema) {
|
|
625
657
|
const validatedOptions = validateOptions(schema, normalizedOptions);
|
|
626
|
-
|
|
658
|
+
const result2 = await coreFn({
|
|
627
659
|
...normalizedOptions,
|
|
628
660
|
...validatedOptions
|
|
629
661
|
});
|
|
662
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
663
|
+
const argumentCount = Object.keys(
|
|
664
|
+
normalizedOptions
|
|
665
|
+
).filter((k) => k !== "_telemetry").length;
|
|
666
|
+
telemetry.onMethodCalled({
|
|
667
|
+
methodName: functionName,
|
|
668
|
+
durationMs: Date.now() - startTime,
|
|
669
|
+
success: true,
|
|
670
|
+
argumentCount,
|
|
671
|
+
isPaginated: false
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
return result2;
|
|
675
|
+
}
|
|
676
|
+
const result = await coreFn(normalizedOptions);
|
|
677
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
678
|
+
const argumentCount = Object.keys(normalizedOptions).filter(
|
|
679
|
+
(k) => k !== "_telemetry"
|
|
680
|
+
).length;
|
|
681
|
+
telemetry.onMethodCalled({
|
|
682
|
+
methodName: functionName,
|
|
683
|
+
durationMs: Date.now() - startTime,
|
|
684
|
+
success: true,
|
|
685
|
+
argumentCount,
|
|
686
|
+
isPaginated: false
|
|
687
|
+
});
|
|
630
688
|
}
|
|
631
|
-
return
|
|
689
|
+
return result;
|
|
632
690
|
} catch (error) {
|
|
633
|
-
|
|
691
|
+
const normalizedError = normalizeError(error);
|
|
692
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
693
|
+
const argumentCount = Object.keys(normalizedOptions).filter(
|
|
694
|
+
(k) => k !== "_telemetry"
|
|
695
|
+
).length;
|
|
696
|
+
telemetry.onMethodCalled({
|
|
697
|
+
methodName: functionName,
|
|
698
|
+
durationMs: Date.now() - startTime,
|
|
699
|
+
success: false,
|
|
700
|
+
error: normalizedError,
|
|
701
|
+
argumentCount,
|
|
702
|
+
isPaginated: false
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
throw normalizedError;
|
|
634
706
|
}
|
|
635
707
|
}
|
|
636
708
|
};
|
|
@@ -660,13 +732,15 @@ function createPageFunction(coreFn) {
|
|
|
660
732
|
};
|
|
661
733
|
return namedFunctions[functionName];
|
|
662
734
|
}
|
|
663
|
-
function createPaginatedFunction(coreFn, schema) {
|
|
735
|
+
function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName) {
|
|
664
736
|
const pageFunction = createPageFunction(coreFn);
|
|
665
|
-
const functionName = coreFn.name;
|
|
737
|
+
const functionName = explicitFunctionName || coreFn.name;
|
|
666
738
|
const validator = schema ? createValidator(schema) : null;
|
|
667
739
|
const namedFunctions = {
|
|
668
740
|
[functionName]: function(options) {
|
|
741
|
+
const startTime = Date.now();
|
|
669
742
|
const normalizedOptions = options ?? {};
|
|
743
|
+
const isNested = normalizedOptions?._telemetry?.isNested === true;
|
|
670
744
|
const validatedOptions = {
|
|
671
745
|
...normalizedOptions,
|
|
672
746
|
...validator ? validator(normalizedOptions) : normalizedOptions
|
|
@@ -683,6 +757,32 @@ function createPaginatedFunction(coreFn, schema) {
|
|
|
683
757
|
}
|
|
684
758
|
return result.value;
|
|
685
759
|
});
|
|
760
|
+
if (!isNested && telemetry?.onMethodCalled) {
|
|
761
|
+
firstPagePromise.then(() => {
|
|
762
|
+
const argumentCount = Object.keys(
|
|
763
|
+
normalizedOptions
|
|
764
|
+
).filter((k) => k !== "_telemetry").length;
|
|
765
|
+
telemetry.onMethodCalled({
|
|
766
|
+
methodName: functionName,
|
|
767
|
+
durationMs: Date.now() - startTime,
|
|
768
|
+
success: true,
|
|
769
|
+
argumentCount,
|
|
770
|
+
isPaginated: true
|
|
771
|
+
});
|
|
772
|
+
}).catch((error) => {
|
|
773
|
+
const argumentCount = Object.keys(
|
|
774
|
+
normalizedOptions
|
|
775
|
+
).filter((k) => k !== "_telemetry").length;
|
|
776
|
+
telemetry.onMethodCalled({
|
|
777
|
+
methodName: functionName,
|
|
778
|
+
durationMs: Date.now() - startTime,
|
|
779
|
+
success: false,
|
|
780
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
781
|
+
argumentCount,
|
|
782
|
+
isPaginated: true
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
}
|
|
686
786
|
return Object.assign(firstPagePromise, {
|
|
687
787
|
[Symbol.asyncIterator]: async function* () {
|
|
688
788
|
yield await firstPagePromise;
|
|
@@ -780,7 +880,7 @@ var ListAppsOptionsSchema = zod.z.object({
|
|
|
780
880
|
pageSize: zod.z.number().min(1).optional().describe("Number of apps per page"),
|
|
781
881
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
782
882
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
783
|
-
}).describe("List all available apps with optional filtering");
|
|
883
|
+
}).merge(TelemetryMarkerSchema).describe("List all available apps with optional filtering");
|
|
784
884
|
var AppItemSchema = ImplementationMetaSchema.omit({
|
|
785
885
|
name: true,
|
|
786
886
|
id: true
|
|
@@ -1206,6 +1306,9 @@ function toSnakeCase(input) {
|
|
|
1206
1306
|
}
|
|
1207
1307
|
return result;
|
|
1208
1308
|
}
|
|
1309
|
+
function stripPageSuffix(functionName) {
|
|
1310
|
+
return functionName.replace(/Page$/, "");
|
|
1311
|
+
}
|
|
1209
1312
|
|
|
1210
1313
|
// src/schemas/App.ts
|
|
1211
1314
|
var AppItemSchema2 = withFormatter(
|
|
@@ -1238,9 +1341,26 @@ var AppItemSchema2 = withFormatter(
|
|
|
1238
1341
|
}
|
|
1239
1342
|
);
|
|
1240
1343
|
|
|
1344
|
+
// src/utils/telemetry-utils.ts
|
|
1345
|
+
function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
1346
|
+
return {
|
|
1347
|
+
onMethodCalled: (data) => {
|
|
1348
|
+
emitMethodCalled({
|
|
1349
|
+
method_name: methodName,
|
|
1350
|
+
execution_duration_ms: data.durationMs,
|
|
1351
|
+
success_flag: data.success,
|
|
1352
|
+
error_message: data.error?.message ?? null,
|
|
1353
|
+
error_type: data.error?.constructor.name ?? null,
|
|
1354
|
+
argument_count: data.argumentCount,
|
|
1355
|
+
is_paginated: data.isPaginated
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1241
1361
|
// src/plugins/listApps/index.ts
|
|
1242
1362
|
var listAppsPlugin = ({ context }) => {
|
|
1243
|
-
|
|
1363
|
+
async function listAppsPage(options) {
|
|
1244
1364
|
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1245
1365
|
const appKeys = options.appKeys ?? [];
|
|
1246
1366
|
const appLocators = await resolveAppKeys2({
|
|
@@ -1277,9 +1397,16 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1277
1397
|
...options.cursor && { cursor: options.cursor }
|
|
1278
1398
|
}
|
|
1279
1399
|
});
|
|
1280
|
-
}
|
|
1400
|
+
}
|
|
1401
|
+
const methodName = stripPageSuffix(listAppsPage.name);
|
|
1402
|
+
const listAppsDefinition = createPaginatedFunction(
|
|
1403
|
+
listAppsPage,
|
|
1404
|
+
ListAppsOptionsSchema,
|
|
1405
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
1406
|
+
methodName
|
|
1407
|
+
);
|
|
1281
1408
|
return {
|
|
1282
|
-
listApps,
|
|
1409
|
+
listApps: listAppsDefinition,
|
|
1283
1410
|
context: {
|
|
1284
1411
|
meta: {
|
|
1285
1412
|
listApps: {
|
|
@@ -1423,7 +1550,7 @@ var ListActionsSchema = zod.z.object({
|
|
|
1423
1550
|
pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
|
|
1424
1551
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
1425
1552
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
1426
|
-
}).describe("List all actions for a specific app");
|
|
1553
|
+
}).merge(TelemetryMarkerSchema).describe("List all actions for a specific app");
|
|
1427
1554
|
var ActionItemSchema = withFormatter(
|
|
1428
1555
|
ActionSchema.omit({ type: true, name: true, selected_api: true }).extend({
|
|
1429
1556
|
app_key: zod.z.string(),
|
|
@@ -1657,7 +1784,18 @@ var inputFieldKeyResolver = {
|
|
|
1657
1784
|
|
|
1658
1785
|
// src/plugins/listActions/index.ts
|
|
1659
1786
|
var listActionsPlugin = ({ context }) => {
|
|
1660
|
-
const
|
|
1787
|
+
const methodMeta = {
|
|
1788
|
+
categories: ["action"],
|
|
1789
|
+
type: "list",
|
|
1790
|
+
itemType: "Action",
|
|
1791
|
+
inputSchema: ListActionsSchema,
|
|
1792
|
+
outputSchema: ActionItemSchema,
|
|
1793
|
+
resolvers: {
|
|
1794
|
+
appKey: appKeyResolver,
|
|
1795
|
+
actionType: actionTypeResolver
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
async function listActionsPage(options) {
|
|
1661
1799
|
const { api, getVersionedImplementationId } = context;
|
|
1662
1800
|
const selectedApi = await getVersionedImplementationId(options.appKey);
|
|
1663
1801
|
if (!selectedApi) {
|
|
@@ -1713,22 +1851,19 @@ var listActionsPlugin = ({ context }) => {
|
|
|
1713
1851
|
data: allActions,
|
|
1714
1852
|
nextCursor: void 0
|
|
1715
1853
|
};
|
|
1716
|
-
}
|
|
1854
|
+
}
|
|
1855
|
+
const methodName = stripPageSuffix(listActionsPage.name);
|
|
1856
|
+
const listActionsDefinition = createPaginatedFunction(
|
|
1857
|
+
listActionsPage,
|
|
1858
|
+
ListActionsSchema,
|
|
1859
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
1860
|
+
methodName
|
|
1861
|
+
);
|
|
1717
1862
|
return {
|
|
1718
|
-
listActions,
|
|
1863
|
+
listActions: listActionsDefinition,
|
|
1719
1864
|
context: {
|
|
1720
1865
|
meta: {
|
|
1721
|
-
listActions:
|
|
1722
|
-
categories: ["action"],
|
|
1723
|
-
type: "list",
|
|
1724
|
-
itemType: "Action",
|
|
1725
|
-
inputSchema: ListActionsSchema,
|
|
1726
|
-
outputSchema: ActionItemSchema,
|
|
1727
|
-
resolvers: {
|
|
1728
|
-
appKey: appKeyResolver,
|
|
1729
|
-
actionType: actionTypeResolver
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1866
|
+
listActions: methodMeta
|
|
1732
1867
|
}
|
|
1733
1868
|
}
|
|
1734
1869
|
};
|
|
@@ -2021,47 +2156,51 @@ function transformNeedsToFields(needs) {
|
|
|
2021
2156
|
return rootFields;
|
|
2022
2157
|
}
|
|
2023
2158
|
var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2159
|
+
async function listInputFieldsPage(options) {
|
|
2160
|
+
const { api, getVersionedImplementationId } = context;
|
|
2161
|
+
const {
|
|
2162
|
+
appKey,
|
|
2163
|
+
actionKey,
|
|
2164
|
+
actionType,
|
|
2165
|
+
authenticationId = null,
|
|
2166
|
+
inputs
|
|
2167
|
+
} = options;
|
|
2168
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
2169
|
+
if (!selectedApi) {
|
|
2170
|
+
throw new ZapierConfigurationError(
|
|
2171
|
+
"No current_implementation_id found for app",
|
|
2172
|
+
{ configType: "current_implementation_id" }
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
const { data: action } = await sdk.getAction({
|
|
2176
|
+
appKey,
|
|
2177
|
+
actionType,
|
|
2178
|
+
actionKey
|
|
2179
|
+
});
|
|
2180
|
+
const needsData = await fetchImplementationNeeds({
|
|
2181
|
+
api,
|
|
2182
|
+
selectedApi,
|
|
2183
|
+
action: action.key,
|
|
2184
|
+
actionType,
|
|
2185
|
+
authenticationId,
|
|
2186
|
+
inputs
|
|
2187
|
+
});
|
|
2188
|
+
const rootFieldset = transformNeedsToFields(needsData.needs || []);
|
|
2189
|
+
return {
|
|
2190
|
+
data: rootFieldset,
|
|
2191
|
+
nextCursor: void 0
|
|
2192
|
+
// No pagination needed since we return all input fields
|
|
2193
|
+
};
|
|
2194
|
+
}
|
|
2195
|
+
const methodName = stripPageSuffix(listInputFieldsPage.name);
|
|
2196
|
+
const listInputFieldsDefinition = createPaginatedFunction(
|
|
2197
|
+
listInputFieldsPage,
|
|
2198
|
+
ListInputFieldsSchema,
|
|
2199
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2200
|
+
methodName
|
|
2062
2201
|
);
|
|
2063
2202
|
return {
|
|
2064
|
-
listInputFields,
|
|
2203
|
+
listInputFields: listInputFieldsDefinition,
|
|
2065
2204
|
context: {
|
|
2066
2205
|
meta: {
|
|
2067
2206
|
listInputFields: {
|
|
@@ -2096,7 +2235,7 @@ var ListAuthenticationsSchema = zod.z.object({
|
|
|
2096
2235
|
pageSize: zod.z.number().min(1).optional().describe("Number of authentications per page"),
|
|
2097
2236
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
2098
2237
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
2099
|
-
}).describe("List available authentications with optional filtering");
|
|
2238
|
+
}).merge(TelemetryMarkerSchema).describe("List available authentications with optional filtering");
|
|
2100
2239
|
var AuthenticationItemSchema = withFormatter(
|
|
2101
2240
|
AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
|
|
2102
2241
|
{
|
|
@@ -2143,74 +2282,78 @@ var AuthenticationItemSchema = withFormatter(
|
|
|
2143
2282
|
|
|
2144
2283
|
// src/plugins/listAuthentications/index.ts
|
|
2145
2284
|
var listAuthenticationsPlugin = ({ context }) => {
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
options.appKey
|
|
2153
|
-
);
|
|
2154
|
-
if (implementationId) {
|
|
2155
|
-
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
2156
|
-
searchParams.versionless_selected_api = versionlessSelectedApi;
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
if (options.authenticationIds && options.authenticationIds.length > 0) {
|
|
2160
|
-
searchParams.ids = options.authenticationIds.join(",");
|
|
2161
|
-
}
|
|
2162
|
-
if (options.search) {
|
|
2163
|
-
searchParams.search = options.search;
|
|
2164
|
-
} else if (options.title) {
|
|
2165
|
-
searchParams.search = options.title;
|
|
2166
|
-
}
|
|
2167
|
-
if (options.accountId) {
|
|
2168
|
-
searchParams.account_id = options.accountId;
|
|
2169
|
-
}
|
|
2170
|
-
if (options.owner) {
|
|
2171
|
-
searchParams.owner = options.owner;
|
|
2172
|
-
}
|
|
2173
|
-
searchParams.limit = options.pageSize.toString();
|
|
2174
|
-
if (options.cursor) {
|
|
2175
|
-
searchParams.offset = options.cursor;
|
|
2176
|
-
}
|
|
2177
|
-
const data = await api.get(
|
|
2178
|
-
"/zapier/api/v4/authentications/",
|
|
2179
|
-
{
|
|
2180
|
-
searchParams,
|
|
2181
|
-
customErrorHandler: ({ status }) => {
|
|
2182
|
-
if (status === 401) {
|
|
2183
|
-
return new ZapierAuthenticationError(
|
|
2184
|
-
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
2185
|
-
{ statusCode: status }
|
|
2186
|
-
);
|
|
2187
|
-
}
|
|
2188
|
-
if (status === 403) {
|
|
2189
|
-
return new ZapierAuthenticationError(
|
|
2190
|
-
`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${status})`,
|
|
2191
|
-
{ statusCode: status }
|
|
2192
|
-
);
|
|
2193
|
-
}
|
|
2194
|
-
return void 0;
|
|
2195
|
-
},
|
|
2196
|
-
authRequired: true
|
|
2197
|
-
}
|
|
2198
|
-
);
|
|
2199
|
-
let auths = (data.results || []).map(
|
|
2200
|
-
(auth) => normalizeAuthenticationItem(auth)
|
|
2285
|
+
async function listAuthenticationsPage(options) {
|
|
2286
|
+
const { api, getVersionedImplementationId } = context;
|
|
2287
|
+
const searchParams = {};
|
|
2288
|
+
if (options.appKey) {
|
|
2289
|
+
const implementationId = await getVersionedImplementationId(
|
|
2290
|
+
options.appKey
|
|
2201
2291
|
);
|
|
2202
|
-
if (
|
|
2203
|
-
|
|
2292
|
+
if (implementationId) {
|
|
2293
|
+
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
2294
|
+
searchParams.versionless_selected_api = versionlessSelectedApi;
|
|
2204
2295
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2296
|
+
}
|
|
2297
|
+
if (options.authenticationIds && options.authenticationIds.length > 0) {
|
|
2298
|
+
searchParams.ids = options.authenticationIds.join(",");
|
|
2299
|
+
}
|
|
2300
|
+
if (options.search) {
|
|
2301
|
+
searchParams.search = options.search;
|
|
2302
|
+
} else if (options.title) {
|
|
2303
|
+
searchParams.search = options.title;
|
|
2304
|
+
}
|
|
2305
|
+
if (options.accountId) {
|
|
2306
|
+
searchParams.account_id = options.accountId;
|
|
2307
|
+
}
|
|
2308
|
+
if (options.owner) {
|
|
2309
|
+
searchParams.owner = options.owner;
|
|
2310
|
+
}
|
|
2311
|
+
searchParams.limit = options.pageSize.toString();
|
|
2312
|
+
if (options.cursor) {
|
|
2313
|
+
searchParams.offset = options.cursor;
|
|
2314
|
+
}
|
|
2315
|
+
const data = await api.get(
|
|
2316
|
+
"/zapier/api/v4/authentications/",
|
|
2317
|
+
{
|
|
2318
|
+
searchParams,
|
|
2319
|
+
customErrorHandler: ({ status }) => {
|
|
2320
|
+
if (status === 401) {
|
|
2321
|
+
return new ZapierAuthenticationError(
|
|
2322
|
+
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
2323
|
+
{ statusCode: status }
|
|
2324
|
+
);
|
|
2325
|
+
}
|
|
2326
|
+
if (status === 403) {
|
|
2327
|
+
return new ZapierAuthenticationError(
|
|
2328
|
+
`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${status})`,
|
|
2329
|
+
{ statusCode: status }
|
|
2330
|
+
);
|
|
2331
|
+
}
|
|
2332
|
+
return void 0;
|
|
2333
|
+
},
|
|
2334
|
+
authRequired: true
|
|
2335
|
+
}
|
|
2336
|
+
);
|
|
2337
|
+
let auths = (data.results || []).map(
|
|
2338
|
+
(auth) => normalizeAuthenticationItem(auth)
|
|
2339
|
+
);
|
|
2340
|
+
if (options.title) {
|
|
2341
|
+
auths = auths.filter((auth) => auth.title === options.title);
|
|
2342
|
+
}
|
|
2343
|
+
return {
|
|
2344
|
+
data: auths,
|
|
2345
|
+
nextCursor: extractCursor(data)
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
const methodName = stripPageSuffix(listAuthenticationsPage.name);
|
|
2349
|
+
const listAuthenticationsDefinition = createPaginatedFunction(
|
|
2350
|
+
listAuthenticationsPage,
|
|
2351
|
+
ListAuthenticationsSchema,
|
|
2352
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2353
|
+
methodName
|
|
2211
2354
|
);
|
|
2212
2355
|
return {
|
|
2213
|
-
listAuthentications,
|
|
2356
|
+
listAuthentications: listAuthenticationsDefinition,
|
|
2214
2357
|
context: {
|
|
2215
2358
|
meta: {
|
|
2216
2359
|
listAuthentications: {
|
|
@@ -2234,9 +2377,12 @@ var GetAppSchema = zod.z.object({
|
|
|
2234
2377
|
}).describe("Get detailed information about a specific app");
|
|
2235
2378
|
|
|
2236
2379
|
// src/plugins/getApp/index.ts
|
|
2237
|
-
var getAppPlugin = ({ sdk }) => {
|
|
2238
|
-
|
|
2239
|
-
const appsIterator = sdk.listApps({
|
|
2380
|
+
var getAppPlugin = ({ sdk, context }) => {
|
|
2381
|
+
async function getApp(options) {
|
|
2382
|
+
const appsIterator = sdk.listApps({
|
|
2383
|
+
appKeys: [options.appKey],
|
|
2384
|
+
_telemetry: { isNested: true }
|
|
2385
|
+
}).items();
|
|
2240
2386
|
for await (const app of appsIterator) {
|
|
2241
2387
|
return {
|
|
2242
2388
|
data: app
|
|
@@ -2245,9 +2391,17 @@ var getAppPlugin = ({ sdk }) => {
|
|
|
2245
2391
|
throw new ZapierAppNotFoundError("App not found", {
|
|
2246
2392
|
appKey: options.appKey
|
|
2247
2393
|
});
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2394
|
+
}
|
|
2395
|
+
const getAppDefinition = createFunction(
|
|
2250
2396
|
getApp,
|
|
2397
|
+
GetAppSchema,
|
|
2398
|
+
createTelemetryCallback(
|
|
2399
|
+
context.eventEmission.emitMethodCalled,
|
|
2400
|
+
getApp.name
|
|
2401
|
+
)
|
|
2402
|
+
);
|
|
2403
|
+
return {
|
|
2404
|
+
getApp: getAppDefinition,
|
|
2251
2405
|
context: {
|
|
2252
2406
|
meta: {
|
|
2253
2407
|
getApp: {
|
|
@@ -2268,13 +2422,13 @@ var GetActionSchema = zod.z.object({
|
|
|
2268
2422
|
appKey: AppKeyPropertySchema,
|
|
2269
2423
|
actionType: ActionTypePropertySchema,
|
|
2270
2424
|
actionKey: ActionKeyPropertySchema
|
|
2271
|
-
}).describe("Get detailed information about a specific action");
|
|
2425
|
+
}).merge(TelemetryMarkerSchema).describe("Get detailed information about a specific action");
|
|
2272
2426
|
|
|
2273
2427
|
// src/plugins/getAction/index.ts
|
|
2274
|
-
var getActionPlugin = ({ sdk }) => {
|
|
2275
|
-
|
|
2428
|
+
var getActionPlugin = ({ sdk, context }) => {
|
|
2429
|
+
async function getAction(options) {
|
|
2276
2430
|
const { actionKey, actionType, appKey } = options;
|
|
2277
|
-
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
2431
|
+
for await (const action of sdk.listActions({ appKey, _telemetry: { isNested: true } }).items()) {
|
|
2278
2432
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2279
2433
|
return { data: action };
|
|
2280
2434
|
}
|
|
@@ -2283,9 +2437,17 @@ var getActionPlugin = ({ sdk }) => {
|
|
|
2283
2437
|
`Action not found: ${actionKey} with type ${actionType}`,
|
|
2284
2438
|
{ resourceType: "Action", resourceId: `${actionKey} (${actionType})` }
|
|
2285
2439
|
);
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2440
|
+
}
|
|
2441
|
+
const getActionDefinition = createFunction(
|
|
2288
2442
|
getAction,
|
|
2443
|
+
GetActionSchema,
|
|
2444
|
+
createTelemetryCallback(
|
|
2445
|
+
context.eventEmission.emitMethodCalled,
|
|
2446
|
+
getAction.name
|
|
2447
|
+
)
|
|
2448
|
+
);
|
|
2449
|
+
return {
|
|
2450
|
+
getAction: getActionDefinition,
|
|
2289
2451
|
context: {
|
|
2290
2452
|
meta: {
|
|
2291
2453
|
getAction: {
|
|
@@ -2360,14 +2522,22 @@ zod.z.object({
|
|
|
2360
2522
|
|
|
2361
2523
|
// src/plugins/getAuthentication/index.ts
|
|
2362
2524
|
var getAuthenticationPlugin = ({ context }) => {
|
|
2363
|
-
|
|
2525
|
+
async function getAuthentication(options) {
|
|
2364
2526
|
const { api } = context;
|
|
2365
2527
|
return await api.get(
|
|
2366
2528
|
`/api/v0/authentications/${options.authenticationId}`
|
|
2367
2529
|
);
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2530
|
+
}
|
|
2531
|
+
const getAuthenticationDefinition = createFunction(
|
|
2370
2532
|
getAuthentication,
|
|
2533
|
+
GetAuthenticationOptionsSchema,
|
|
2534
|
+
createTelemetryCallback(
|
|
2535
|
+
context.eventEmission.emitMethodCalled,
|
|
2536
|
+
getAuthentication.name
|
|
2537
|
+
)
|
|
2538
|
+
);
|
|
2539
|
+
return {
|
|
2540
|
+
getAuthentication: getAuthenticationDefinition,
|
|
2371
2541
|
context: {
|
|
2372
2542
|
meta: {
|
|
2373
2543
|
getAuthentication: {
|
|
@@ -2395,27 +2565,33 @@ var FindFirstAuthenticationSchema = zod.z.object({
|
|
|
2395
2565
|
}).describe("Find the first authentication matching the criteria");
|
|
2396
2566
|
|
|
2397
2567
|
// src/plugins/findFirstAuthentication/index.ts
|
|
2398
|
-
var findFirstAuthenticationPlugin = ({ sdk }) => {
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2568
|
+
var findFirstAuthenticationPlugin = ({ sdk, context }) => {
|
|
2569
|
+
async function findFirstAuthentication(options = {}) {
|
|
2570
|
+
const authsResponse = await sdk.listAuthentications({
|
|
2571
|
+
...options,
|
|
2572
|
+
maxItems: 1,
|
|
2573
|
+
_telemetry: { isNested: true }
|
|
2574
|
+
});
|
|
2575
|
+
if (authsResponse.data.length === 0) {
|
|
2576
|
+
throw new ZapierResourceNotFoundError(
|
|
2577
|
+
"No authentication found matching the specified criteria",
|
|
2578
|
+
{ resourceType: "Authentication" }
|
|
2579
|
+
);
|
|
2580
|
+
}
|
|
2581
|
+
return {
|
|
2582
|
+
data: authsResponse.data[0]
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
const findFirstAuthenticationDefinition = createFunction(
|
|
2586
|
+
findFirstAuthentication,
|
|
2587
|
+
FindFirstAuthenticationSchema,
|
|
2588
|
+
createTelemetryCallback(
|
|
2589
|
+
context.eventEmission.emitMethodCalled,
|
|
2590
|
+
findFirstAuthentication.name
|
|
2591
|
+
)
|
|
2416
2592
|
);
|
|
2417
2593
|
return {
|
|
2418
|
-
findFirstAuthentication,
|
|
2594
|
+
findFirstAuthentication: findFirstAuthenticationDefinition,
|
|
2419
2595
|
context: {
|
|
2420
2596
|
meta: {
|
|
2421
2597
|
findFirstAuthentication: {
|
|
@@ -2440,33 +2616,39 @@ var FindUniqueAuthenticationSchema = zod.z.object({
|
|
|
2440
2616
|
}).describe("Find a unique authentication matching the criteria");
|
|
2441
2617
|
|
|
2442
2618
|
// src/plugins/findUniqueAuthentication/index.ts
|
|
2443
|
-
var findUniqueAuthenticationPlugin = ({ sdk }) => {
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2619
|
+
var findUniqueAuthenticationPlugin = ({ sdk, context }) => {
|
|
2620
|
+
async function findUniqueAuthentication(options = {}) {
|
|
2621
|
+
const authsResponse = await sdk.listAuthentications({
|
|
2622
|
+
...options,
|
|
2623
|
+
maxItems: 2,
|
|
2624
|
+
// Get up to 2 to check for uniqueness
|
|
2625
|
+
_telemetry: { isNested: true }
|
|
2626
|
+
});
|
|
2627
|
+
if (authsResponse.data.length === 0) {
|
|
2628
|
+
throw new ZapierResourceNotFoundError(
|
|
2629
|
+
"No authentication found matching the specified criteria",
|
|
2630
|
+
{ resourceType: "Authentication" }
|
|
2631
|
+
);
|
|
2632
|
+
}
|
|
2633
|
+
if (authsResponse.data.length > 1) {
|
|
2634
|
+
throw new ZapierValidationError(
|
|
2635
|
+
"Multiple authentications found matching the specified criteria. Expected exactly one."
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
return {
|
|
2639
|
+
data: authsResponse.data[0]
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
const findUniqueAuthenticationDefinition = createFunction(
|
|
2643
|
+
findUniqueAuthentication,
|
|
2644
|
+
FindUniqueAuthenticationSchema,
|
|
2645
|
+
createTelemetryCallback(
|
|
2646
|
+
context.eventEmission.emitMethodCalled,
|
|
2647
|
+
findUniqueAuthentication.name
|
|
2648
|
+
)
|
|
2467
2649
|
);
|
|
2468
2650
|
return {
|
|
2469
|
-
findUniqueAuthentication,
|
|
2651
|
+
findUniqueAuthentication: findUniqueAuthenticationDefinition,
|
|
2470
2652
|
context: {
|
|
2471
2653
|
meta: {
|
|
2472
2654
|
findUniqueAuthentication: {
|
|
@@ -2537,7 +2719,7 @@ async function executeAction(actionOptions) {
|
|
|
2537
2719
|
});
|
|
2538
2720
|
}
|
|
2539
2721
|
var runActionPlugin = ({ sdk, context }) => {
|
|
2540
|
-
|
|
2722
|
+
async function runActionPage(options) {
|
|
2541
2723
|
const { api } = context;
|
|
2542
2724
|
const {
|
|
2543
2725
|
appKey,
|
|
@@ -2549,7 +2731,8 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2549
2731
|
const actionData = await sdk.getAction({
|
|
2550
2732
|
appKey,
|
|
2551
2733
|
actionKey,
|
|
2552
|
-
actionType
|
|
2734
|
+
actionType,
|
|
2735
|
+
_telemetry: { isNested: true }
|
|
2553
2736
|
});
|
|
2554
2737
|
if (actionData.data.action_type !== actionType) {
|
|
2555
2738
|
throw new ZapierValidationError(
|
|
@@ -2582,9 +2765,16 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2582
2765
|
nextCursor: void 0
|
|
2583
2766
|
// No pagination implemented yet
|
|
2584
2767
|
};
|
|
2585
|
-
}
|
|
2768
|
+
}
|
|
2769
|
+
const methodName = stripPageSuffix(runActionPage.name);
|
|
2770
|
+
const runActionDefinition = createPaginatedFunction(
|
|
2771
|
+
runActionPage,
|
|
2772
|
+
RunActionSchema,
|
|
2773
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
2774
|
+
methodName
|
|
2775
|
+
);
|
|
2586
2776
|
return {
|
|
2587
|
-
runAction,
|
|
2777
|
+
runAction: runActionDefinition,
|
|
2588
2778
|
context: {
|
|
2589
2779
|
meta: {
|
|
2590
2780
|
runAction: {
|
|
@@ -2621,7 +2811,7 @@ var RelayRequestSchema = zod.z.object({
|
|
|
2621
2811
|
]).optional().describe("Request headers")
|
|
2622
2812
|
}).extend({
|
|
2623
2813
|
relayBaseUrl: zod.z.string().optional().describe("Base URL for Relay service")
|
|
2624
|
-
}).describe("Make authenticated HTTP requests through Zapier's Relay service");
|
|
2814
|
+
}).merge(TelemetryMarkerSchema).describe("Make authenticated HTTP requests through Zapier's Relay service");
|
|
2625
2815
|
var RelayFetchSchema = RelayRequestSchema;
|
|
2626
2816
|
|
|
2627
2817
|
// src/plugins/request/index.ts
|
|
@@ -2631,7 +2821,7 @@ function transformUrlToRelayPath(url) {
|
|
|
2631
2821
|
return relayPath;
|
|
2632
2822
|
}
|
|
2633
2823
|
var requestPlugin = ({ context }) => {
|
|
2634
|
-
|
|
2824
|
+
async function request(options) {
|
|
2635
2825
|
const { api } = context;
|
|
2636
2826
|
const {
|
|
2637
2827
|
url,
|
|
@@ -2664,9 +2854,17 @@ var requestPlugin = ({ context }) => {
|
|
|
2664
2854
|
body,
|
|
2665
2855
|
headers
|
|
2666
2856
|
});
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2857
|
+
}
|
|
2858
|
+
const requestDefinition = createFunction(
|
|
2669
2859
|
request,
|
|
2860
|
+
RelayRequestSchema,
|
|
2861
|
+
createTelemetryCallback(
|
|
2862
|
+
context.eventEmission.emitMethodCalled,
|
|
2863
|
+
request.name
|
|
2864
|
+
)
|
|
2865
|
+
);
|
|
2866
|
+
return {
|
|
2867
|
+
request: requestDefinition,
|
|
2670
2868
|
context: {
|
|
2671
2869
|
meta: {
|
|
2672
2870
|
request: {
|
|
@@ -3169,7 +3367,7 @@ var UserProfileItemSchema = withFormatter(
|
|
|
3169
3367
|
|
|
3170
3368
|
// src/plugins/getProfile/index.ts
|
|
3171
3369
|
var getProfilePlugin = ({ context }) => {
|
|
3172
|
-
|
|
3370
|
+
async function getProfile() {
|
|
3173
3371
|
const profile = await context.api.get(
|
|
3174
3372
|
"/zapier/api/v4/profile/",
|
|
3175
3373
|
{
|
|
@@ -3185,9 +3383,17 @@ var getProfilePlugin = ({ context }) => {
|
|
|
3185
3383
|
// Computed field
|
|
3186
3384
|
}
|
|
3187
3385
|
};
|
|
3188
|
-
}
|
|
3189
|
-
|
|
3386
|
+
}
|
|
3387
|
+
const getProfileDefinition = createFunction(
|
|
3190
3388
|
getProfile,
|
|
3389
|
+
GetProfileSchema,
|
|
3390
|
+
createTelemetryCallback(
|
|
3391
|
+
context.eventEmission.emitMethodCalled,
|
|
3392
|
+
getProfile.name
|
|
3393
|
+
)
|
|
3394
|
+
);
|
|
3395
|
+
return {
|
|
3396
|
+
getProfile: getProfileDefinition,
|
|
3191
3397
|
context: {
|
|
3192
3398
|
meta: {
|
|
3193
3399
|
getProfile: {
|
|
@@ -4430,44 +4636,49 @@ var GetInputFieldsSchemaSchema = zod.z.object({
|
|
|
4430
4636
|
|
|
4431
4637
|
// src/plugins/getInputFieldsSchema/index.ts
|
|
4432
4638
|
var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4639
|
+
async function getInputFieldsSchema(options) {
|
|
4640
|
+
const { api, getVersionedImplementationId } = context;
|
|
4641
|
+
const {
|
|
4642
|
+
appKey,
|
|
4643
|
+
actionKey,
|
|
4644
|
+
actionType,
|
|
4645
|
+
authenticationId = null,
|
|
4646
|
+
inputs
|
|
4647
|
+
} = options;
|
|
4648
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
4649
|
+
if (!selectedApi) {
|
|
4650
|
+
throw new ZapierConfigurationError(
|
|
4651
|
+
"No current_implementation_id found for app",
|
|
4652
|
+
{ configType: "current_implementation_id" }
|
|
4653
|
+
);
|
|
4654
|
+
}
|
|
4655
|
+
const { data: action } = await sdk.getAction({
|
|
4656
|
+
appKey,
|
|
4657
|
+
actionType,
|
|
4658
|
+
actionKey
|
|
4659
|
+
});
|
|
4660
|
+
const needsData = await fetchImplementationNeeds({
|
|
4661
|
+
api,
|
|
4662
|
+
selectedApi,
|
|
4663
|
+
action: action.key,
|
|
4664
|
+
actionType,
|
|
4665
|
+
authenticationId,
|
|
4666
|
+
inputs
|
|
4667
|
+
});
|
|
4668
|
+
return {
|
|
4669
|
+
data: needsData.schema || {}
|
|
4670
|
+
};
|
|
4671
|
+
}
|
|
4672
|
+
const getInputFieldsSchemaDefinition = createFunction(
|
|
4673
|
+
getInputFieldsSchema,
|
|
4674
|
+
GetInputFieldsSchemaSchema,
|
|
4675
|
+
createTelemetryCallback(
|
|
4676
|
+
context.eventEmission.emitMethodCalled,
|
|
4677
|
+
getInputFieldsSchema.name
|
|
4678
|
+
)
|
|
4468
4679
|
);
|
|
4469
4680
|
return {
|
|
4470
|
-
getInputFieldsSchema,
|
|
4681
|
+
getInputFieldsSchema: getInputFieldsSchemaDefinition,
|
|
4471
4682
|
context: {
|
|
4472
4683
|
meta: {
|
|
4473
4684
|
getInputFieldsSchema: {
|
|
@@ -4536,7 +4747,7 @@ function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
|
4536
4747
|
};
|
|
4537
4748
|
}
|
|
4538
4749
|
var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
4539
|
-
|
|
4750
|
+
async function listInputFieldChoicesPage(options) {
|
|
4540
4751
|
const { api, getVersionedImplementationId } = context;
|
|
4541
4752
|
const {
|
|
4542
4753
|
appKey,
|
|
@@ -4614,9 +4825,16 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
4614
4825
|
data: choices,
|
|
4615
4826
|
nextCursor
|
|
4616
4827
|
};
|
|
4617
|
-
}
|
|
4828
|
+
}
|
|
4829
|
+
const methodName = stripPageSuffix(listInputFieldChoicesPage.name);
|
|
4830
|
+
const listInputFieldChoicesDefinition = createPaginatedFunction(
|
|
4831
|
+
listInputFieldChoicesPage,
|
|
4832
|
+
ListInputFieldChoicesSchema,
|
|
4833
|
+
createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
|
|
4834
|
+
methodName
|
|
4835
|
+
);
|
|
4618
4836
|
return {
|
|
4619
|
-
listInputFieldChoices,
|
|
4837
|
+
listInputFieldChoices: listInputFieldChoicesDefinition,
|
|
4620
4838
|
context: {
|
|
4621
4839
|
meta: {
|
|
4622
4840
|
listInputFieldChoices: {
|
|
@@ -4790,7 +5008,7 @@ function getCpuTime() {
|
|
|
4790
5008
|
|
|
4791
5009
|
// package.json
|
|
4792
5010
|
var package_default = {
|
|
4793
|
-
version: "0.15.
|
|
5011
|
+
version: "0.15.12"};
|
|
4794
5012
|
|
|
4795
5013
|
// src/plugins/eventEmission/builders.ts
|
|
4796
5014
|
function createBaseEvent(context = {}) {
|
|
@@ -4858,11 +5076,44 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
4858
5076
|
...data
|
|
4859
5077
|
};
|
|
4860
5078
|
}
|
|
5079
|
+
function buildMethodCalledEvent(data, context = {}) {
|
|
5080
|
+
return {
|
|
5081
|
+
...createBaseEvent(context),
|
|
5082
|
+
method_name: data.method_name ?? null,
|
|
5083
|
+
method_module: data.method_module ?? null,
|
|
5084
|
+
execution_duration_ms: data.execution_duration_ms,
|
|
5085
|
+
success_flag: data.success_flag,
|
|
5086
|
+
error_message: data.error_message ?? null,
|
|
5087
|
+
error_type: data.error_type ?? null,
|
|
5088
|
+
argument_count: data.argument_count,
|
|
5089
|
+
is_paginated: data.is_paginated ?? false,
|
|
5090
|
+
sdk_version: package_default.version,
|
|
5091
|
+
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
5092
|
+
selected_api: context.selected_api ?? null,
|
|
5093
|
+
app_id: context.app_id ?? null,
|
|
5094
|
+
app_version_id: context.app_version_id ?? null,
|
|
5095
|
+
zap_id: context.zap_id ?? null,
|
|
5096
|
+
node_id: context.node_id ?? null,
|
|
5097
|
+
operation_type: null,
|
|
5098
|
+
operation_key: null,
|
|
5099
|
+
call_context: null,
|
|
5100
|
+
is_retry: false,
|
|
5101
|
+
retry_attempt: null,
|
|
5102
|
+
argument_types: null,
|
|
5103
|
+
return_type: null,
|
|
5104
|
+
caller_method: null,
|
|
5105
|
+
call_stack_depth: null,
|
|
5106
|
+
is_synchronous: false,
|
|
5107
|
+
cpu_time_ms: null,
|
|
5108
|
+
memory_usage_bytes: null
|
|
5109
|
+
};
|
|
5110
|
+
}
|
|
4861
5111
|
|
|
4862
5112
|
// src/plugins/eventEmission/index.ts
|
|
4863
5113
|
var TELEMETRY_EMIT_TIMEOUT_MS = 300;
|
|
4864
5114
|
var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
|
|
4865
5115
|
var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
|
|
5116
|
+
var METHOD_CALLED_EVENT_SUBJECT = "platform.sdk.MethodCalledEvent";
|
|
4866
5117
|
var transportStates = /* @__PURE__ */ new WeakMap();
|
|
4867
5118
|
async function silentEmit(transport, subject, event, userContextPromise) {
|
|
4868
5119
|
try {
|
|
@@ -4964,7 +5215,9 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4964
5215
|
identity_id: null,
|
|
4965
5216
|
visitor_id: null,
|
|
4966
5217
|
correlation_id: null
|
|
4967
|
-
})
|
|
5218
|
+
}),
|
|
5219
|
+
emitMethodCalled: () => {
|
|
5220
|
+
}
|
|
4968
5221
|
}
|
|
4969
5222
|
}
|
|
4970
5223
|
};
|
|
@@ -5116,7 +5369,16 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5116
5369
|
emit: (subject, event) => {
|
|
5117
5370
|
silentEmit(transport, subject, event, getUserContext);
|
|
5118
5371
|
},
|
|
5119
|
-
createBaseEvent: createBaseEventHelper
|
|
5372
|
+
createBaseEvent: createBaseEventHelper,
|
|
5373
|
+
emitMethodCalled: (data) => {
|
|
5374
|
+
const event = buildMethodCalledEvent(data);
|
|
5375
|
+
silentEmit(
|
|
5376
|
+
transport,
|
|
5377
|
+
METHOD_CALLED_EVENT_SUBJECT,
|
|
5378
|
+
event,
|
|
5379
|
+
getUserContext
|
|
5380
|
+
);
|
|
5381
|
+
}
|
|
5120
5382
|
}
|
|
5121
5383
|
}
|
|
5122
5384
|
};
|
|
@@ -5215,6 +5477,7 @@ exports.batch = batch;
|
|
|
5215
5477
|
exports.buildApplicationLifecycleEvent = buildApplicationLifecycleEvent;
|
|
5216
5478
|
exports.buildErrorEvent = buildErrorEvent;
|
|
5217
5479
|
exports.buildErrorEventWithContext = buildErrorEventWithContext;
|
|
5480
|
+
exports.buildMethodCalledEvent = buildMethodCalledEvent;
|
|
5218
5481
|
exports.createBaseEvent = createBaseEvent;
|
|
5219
5482
|
exports.createFunction = createFunction;
|
|
5220
5483
|
exports.createSdk = createSdk;
|