@zapier/zapier-sdk 0.15.10 → 0.15.11

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.cjs +583 -337
  3. package/dist/index.d.mts +184 -39
  4. package/dist/index.d.ts +3 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index.mjs +583 -338
  8. package/dist/plugins/eventEmission/builders.d.ts +3 -2
  9. package/dist/plugins/eventEmission/builders.d.ts.map +1 -1
  10. package/dist/plugins/eventEmission/builders.js +32 -0
  11. package/dist/plugins/eventEmission/index.d.ts +4 -2
  12. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  13. package/dist/plugins/eventEmission/index.js +8 -2
  14. package/dist/plugins/eventEmission/types.d.ts +10 -0
  15. package/dist/plugins/eventEmission/types.d.ts.map +1 -1
  16. package/dist/plugins/fetch/index.d.ts +2 -1
  17. package/dist/plugins/fetch/index.d.ts.map +1 -1
  18. package/dist/plugins/fetch/index.js +39 -11
  19. package/dist/plugins/findFirstAuthentication/index.d.ts +2 -1
  20. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  21. package/dist/plugins/findFirstAuthentication/index.js +4 -2
  22. package/dist/plugins/findFirstAuthentication/index.test.js +11 -4
  23. package/dist/plugins/findUniqueAuthentication/index.d.ts +2 -1
  24. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  25. package/dist/plugins/findUniqueAuthentication/index.js +4 -2
  26. package/dist/plugins/findUniqueAuthentication/index.test.js +9 -2
  27. package/dist/plugins/getAction/index.d.ts +3 -1
  28. package/dist/plugins/getAction/index.d.ts.map +1 -1
  29. package/dist/plugins/getAction/index.js +6 -3
  30. package/dist/plugins/getAction/index.test.js +5 -3
  31. package/dist/plugins/getAction/schemas.d.ts +14 -0
  32. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  33. package/dist/plugins/getAction/schemas.js +2 -0
  34. package/dist/plugins/getApp/index.d.ts +2 -1
  35. package/dist/plugins/getApp/index.d.ts.map +1 -1
  36. package/dist/plugins/getApp/index.js +9 -3
  37. package/dist/plugins/getApp/index.test.js +7 -0
  38. package/dist/plugins/getAuthentication/index.d.ts +3 -1
  39. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  40. package/dist/plugins/getAuthentication/index.js +2 -1
  41. package/dist/plugins/getAuthentication/index.test.js +10 -1
  42. package/dist/plugins/getInputFieldsSchema/index.d.ts +2 -1
  43. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
  44. package/dist/plugins/getInputFieldsSchema/index.js +2 -1
  45. package/dist/plugins/getInputFieldsSchema/index.test.js +3 -0
  46. package/dist/plugins/getProfile/index.d.ts +3 -1
  47. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  48. package/dist/plugins/getProfile/index.js +2 -1
  49. package/dist/plugins/listActions/index.d.ts +2 -1
  50. package/dist/plugins/listActions/index.d.ts.map +1 -1
  51. package/dist/plugins/listActions/index.js +14 -12
  52. package/dist/plugins/listActions/index.test.js +7 -0
  53. package/dist/plugins/listActions/schemas.d.ts +18 -4
  54. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  55. package/dist/plugins/listActions/schemas.js +2 -0
  56. package/dist/plugins/listApps/index.d.ts +2 -1
  57. package/dist/plugins/listApps/index.d.ts.map +1 -1
  58. package/dist/plugins/listApps/index.js +2 -1
  59. package/dist/plugins/listApps/index.test.js +7 -0
  60. package/dist/plugins/listAuthentications/index.d.ts +2 -1
  61. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  62. package/dist/plugins/listAuthentications/index.js +2 -1
  63. package/dist/plugins/listAuthentications/index.test.js +7 -0
  64. package/dist/plugins/listAuthentications/schemas.d.ts +18 -4
  65. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  66. package/dist/plugins/listAuthentications/schemas.js +2 -0
  67. package/dist/plugins/listInputFieldChoices/index.d.ts +3 -1
  68. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  69. package/dist/plugins/listInputFieldChoices/index.js +2 -1
  70. package/dist/plugins/listInputFieldChoices/index.test.js +5 -2
  71. package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -4
  72. package/dist/plugins/listInputFields/index.d.ts +3 -1
  73. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  74. package/dist/plugins/listInputFields/index.js +2 -1
  75. package/dist/plugins/listInputFields/index.test.js +3 -0
  76. package/dist/plugins/listInputFields/schemas.d.ts +4 -4
  77. package/dist/plugins/manifest/index.test.js +10 -1
  78. package/dist/plugins/request/index.d.ts +3 -1
  79. package/dist/plugins/request/index.d.ts.map +1 -1
  80. package/dist/plugins/request/index.js +2 -1
  81. package/dist/plugins/request/index.test.js +10 -1
  82. package/dist/plugins/request/schemas.d.ts +28 -0
  83. package/dist/plugins/request/schemas.d.ts.map +1 -1
  84. package/dist/plugins/request/schemas.js +2 -0
  85. package/dist/plugins/runAction/index.d.ts +3 -1
  86. package/dist/plugins/runAction/index.d.ts.map +1 -1
  87. package/dist/plugins/runAction/index.js +3 -1
  88. package/dist/plugins/runAction/index.test.js +20 -8
  89. package/dist/plugins/runAction/schemas.d.ts +4 -4
  90. package/dist/temporary-internal-core/schemas/apps/index.d.ts +21 -7
  91. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -1
  92. package/dist/temporary-internal-core/schemas/apps/index.js +2 -0
  93. package/dist/types/telemetry-events.d.ts +31 -2
  94. package/dist/types/telemetry-events.d.ts.map +1 -1
  95. package/dist/utils/function-utils.d.ts +42 -3
  96. package/dist/utils/function-utils.d.ts.map +1 -1
  97. package/dist/utils/function-utils.js +83 -8
  98. package/dist/utils/telemetry-utils.d.ts +32 -0
  99. package/dist/utils/telemetry-utils.d.ts.map +1 -0
  100. package/dist/utils/telemetry-utils.js +43 -0
  101. package/dist/utils/telemetry-utils.test.d.ts +2 -0
  102. package/dist/utils/telemetry-utils.test.d.ts.map +1 -0
  103. package/dist/utils/telemetry-utils.test.js +94 -0
  104. 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
- authenticationId,
376
- callbackUrl,
377
- authenticationTemplate,
378
- ...fetchInit
379
- } = init || {};
380
- return sdk.request({
381
- url: url.toString(),
382
- method: fetchInit.method,
383
- body: fetchInit.body,
384
- headers: fetchInit.headers,
385
- authenticationId,
386
- callbackUrl,
387
- authenticationTemplate
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
- return await coreFn({
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 await coreFn(normalizedOptions);
667
+ return result;
610
668
  } catch (error) {
611
- throw normalizeError(error);
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) {
642
714
  const pageFunction = createPageFunction(coreFn);
643
715
  const functionName = 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
@@ -1216,46 +1316,67 @@ var AppItemSchema2 = withFormatter(
1216
1316
  }
1217
1317
  );
1218
1318
 
1319
+ // src/utils/telemetry-utils.ts
1320
+ function createTelemetryCallback(emitMethodCalled, methodName) {
1321
+ return {
1322
+ onMethodCalled: (data) => {
1323
+ emitMethodCalled({
1324
+ method_name: methodName,
1325
+ execution_duration_ms: data.durationMs,
1326
+ success_flag: data.success,
1327
+ error_message: data.error?.message ?? null,
1328
+ error_type: data.error?.constructor.name ?? null,
1329
+ argument_count: data.argumentCount,
1330
+ is_paginated: data.isPaginated
1331
+ });
1332
+ }
1333
+ };
1334
+ }
1335
+
1219
1336
  // src/plugins/listApps/index.ts
1220
1337
  var listAppsPlugin = ({ context }) => {
1221
- const listApps = createPaginatedFunction(async function listAppsPage(options) {
1222
- const { api, resolveAppKeys: resolveAppKeys2 } = context;
1223
- const appKeys = options.appKeys ?? [];
1224
- const appLocators = await resolveAppKeys2({
1225
- appKeys: [...appKeys]
1226
- });
1227
- const implementationNameToLocator = {};
1228
- for (const locator of appLocators) {
1229
- implementationNameToLocator[locator.implementationName] = [
1230
- ...implementationNameToLocator[locator.implementationName] ?? [],
1231
- locator
1232
- ];
1233
- }
1234
- const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
1235
- if (duplicatedLookupAppKeys.length > 0) {
1236
- throw new Error(
1237
- `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
1238
- );
1239
- }
1240
- if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
1241
- return {
1242
- data: [],
1243
- nextCursor: void 0
1244
- };
1245
- }
1246
- const implementationIds = appLocators.map((locator) => {
1247
- const version = locator.version || "latest";
1248
- return `${locator.implementationName}@${version}`;
1249
- });
1250
- return await api.get("/api/v0/apps", {
1251
- searchParams: {
1252
- implementationIds: implementationIds.join(","),
1253
- ...options.search && { search: options.search },
1254
- pageSize: options.pageSize.toString(),
1255
- ...options.cursor && { cursor: options.cursor }
1338
+ const listApps = createPaginatedFunction(
1339
+ async function listAppsPage(options) {
1340
+ const { api, resolveAppKeys: resolveAppKeys2 } = context;
1341
+ const appKeys = options.appKeys ?? [];
1342
+ const appLocators = await resolveAppKeys2({
1343
+ appKeys: [...appKeys]
1344
+ });
1345
+ const implementationNameToLocator = {};
1346
+ for (const locator of appLocators) {
1347
+ implementationNameToLocator[locator.implementationName] = [
1348
+ ...implementationNameToLocator[locator.implementationName] ?? [],
1349
+ locator
1350
+ ];
1256
1351
  }
1257
- });
1258
- }, ListAppsOptionsSchema);
1352
+ const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
1353
+ if (duplicatedLookupAppKeys.length > 0) {
1354
+ throw new Error(
1355
+ `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
1356
+ );
1357
+ }
1358
+ if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
1359
+ return {
1360
+ data: [],
1361
+ nextCursor: void 0
1362
+ };
1363
+ }
1364
+ const implementationIds = appLocators.map((locator) => {
1365
+ const version = locator.version || "latest";
1366
+ return `${locator.implementationName}@${version}`;
1367
+ });
1368
+ return await api.get("/api/v0/apps", {
1369
+ searchParams: {
1370
+ implementationIds: implementationIds.join(","),
1371
+ ...options.search && { search: options.search },
1372
+ pageSize: options.pageSize.toString(),
1373
+ ...options.cursor && { cursor: options.cursor }
1374
+ }
1375
+ });
1376
+ },
1377
+ ListAppsOptionsSchema,
1378
+ createTelemetryCallback(context.eventEmission.emitMethodCalled, "listApps")
1379
+ );
1259
1380
  return {
1260
1381
  listApps,
1261
1382
  context: {
@@ -1401,7 +1522,7 @@ var ListActionsSchema = z.object({
1401
1522
  pageSize: z.number().min(1).optional().describe("Number of actions per page"),
1402
1523
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
1403
1524
  cursor: z.string().optional().describe("Cursor to start from")
1404
- }).describe("List all actions for a specific app");
1525
+ }).merge(TelemetryMarkerSchema).describe("List all actions for a specific app");
1405
1526
  var ActionItemSchema = withFormatter(
1406
1527
  ActionSchema.omit({ type: true, name: true, selected_api: true }).extend({
1407
1528
  app_key: z.string(),
@@ -1635,78 +1756,86 @@ var inputFieldKeyResolver = {
1635
1756
 
1636
1757
  // src/plugins/listActions/index.ts
1637
1758
  var listActionsPlugin = ({ context }) => {
1638
- const listActions = createPaginatedFunction(async function listActionsPage(options) {
1639
- const { api, getVersionedImplementationId } = context;
1640
- const selectedApi = await getVersionedImplementationId(options.appKey);
1641
- if (!selectedApi) {
1642
- throw new ZapierConfigurationError(
1643
- "No current_implementation_id found for app",
1644
- { configType: "current_implementation_id" }
1645
- );
1759
+ const methodMeta = {
1760
+ categories: ["action"],
1761
+ type: "list",
1762
+ itemType: "Action",
1763
+ inputSchema: ListActionsSchema,
1764
+ outputSchema: ActionItemSchema,
1765
+ resolvers: {
1766
+ appKey: appKeyResolver,
1767
+ actionType: actionTypeResolver
1646
1768
  }
1647
- const searchParams = {
1648
- global: "true",
1649
- public_only: "true",
1650
- selected_apis: selectedApi
1651
- };
1652
- const data = await api.get(
1653
- "/zapier/api/v4/implementations/",
1654
- {
1655
- searchParams,
1656
- customErrorHandler: ({ status }) => {
1657
- if (status === 401) {
1658
- return new ZapierAuthenticationError(
1659
- `Authentication failed. Your token may not have permission to access implementations or may be expired. (HTTP ${status})`,
1660
- { statusCode: status }
1661
- );
1769
+ };
1770
+ const listActions = createPaginatedFunction(
1771
+ async function listActionsPage(options) {
1772
+ const { api, getVersionedImplementationId } = context;
1773
+ const selectedApi = await getVersionedImplementationId(options.appKey);
1774
+ if (!selectedApi) {
1775
+ throw new ZapierConfigurationError(
1776
+ "No current_implementation_id found for app",
1777
+ { configType: "current_implementation_id" }
1778
+ );
1779
+ }
1780
+ const searchParams = {
1781
+ global: "true",
1782
+ public_only: "true",
1783
+ selected_apis: selectedApi
1784
+ };
1785
+ const data = await api.get(
1786
+ "/zapier/api/v4/implementations/",
1787
+ {
1788
+ searchParams,
1789
+ customErrorHandler: ({ status }) => {
1790
+ if (status === 401) {
1791
+ return new ZapierAuthenticationError(
1792
+ `Authentication failed. Your token may not have permission to access implementations or may be expired. (HTTP ${status})`,
1793
+ { statusCode: status }
1794
+ );
1795
+ }
1796
+ if (status === 403) {
1797
+ return new ZapierAuthenticationError(
1798
+ `Access forbidden. Your token may not have the required scopes to list implementations. (HTTP ${status})`,
1799
+ { statusCode: status }
1800
+ );
1801
+ }
1802
+ return void 0;
1662
1803
  }
1663
- if (status === 403) {
1664
- return new ZapierAuthenticationError(
1665
- `Access forbidden. Your token may not have the required scopes to list implementations. (HTTP ${status})`,
1666
- { statusCode: status }
1667
- );
1804
+ }
1805
+ );
1806
+ let allActions = [];
1807
+ for (const implementation of data.results || []) {
1808
+ if (implementation.actions) {
1809
+ for (const action of implementation.actions) {
1810
+ const actionWithContext = {
1811
+ ...action,
1812
+ selected_api: action.selected_api || implementation.selected_api
1813
+ };
1814
+ allActions.push(normalizeActionItem(actionWithContext));
1668
1815
  }
1669
- return void 0;
1670
1816
  }
1671
1817
  }
1672
- );
1673
- let allActions = [];
1674
- for (const implementation of data.results || []) {
1675
- if (implementation.actions) {
1676
- for (const action of implementation.actions) {
1677
- const actionWithContext = {
1678
- ...action,
1679
- selected_api: action.selected_api || implementation.selected_api
1680
- };
1681
- allActions.push(normalizeActionItem(actionWithContext));
1682
- }
1818
+ if (options.actionType) {
1819
+ allActions = allActions.filter(
1820
+ (action) => action.action_type === options.actionType
1821
+ );
1683
1822
  }
1684
- }
1685
- if (options.actionType) {
1686
- allActions = allActions.filter(
1687
- (action) => action.action_type === options.actionType
1688
- );
1689
- }
1690
- return {
1691
- data: allActions,
1692
- nextCursor: void 0
1693
- };
1694
- }, ListActionsSchema);
1823
+ return {
1824
+ data: allActions,
1825
+ nextCursor: void 0
1826
+ };
1827
+ },
1828
+ ListActionsSchema,
1829
+ createTelemetryCallback(
1830
+ context.eventEmission.emitMethodCalled,
1831
+ "listActions"
1832
+ )
1833
+ );
1695
1834
  return {
1696
1835
  listActions,
1697
1836
  context: {
1698
1837
  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
- }
1838
+ listActions: methodMeta
1710
1839
  }
1711
1840
  }
1712
1841
  };
@@ -2036,7 +2165,11 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
2036
2165
  // No pagination needed since we return all input fields
2037
2166
  };
2038
2167
  },
2039
- ListInputFieldsSchema
2168
+ ListInputFieldsSchema,
2169
+ createTelemetryCallback(
2170
+ context.eventEmission.emitMethodCalled,
2171
+ "listInputFields"
2172
+ )
2040
2173
  );
2041
2174
  return {
2042
2175
  listInputFields,
@@ -2074,7 +2207,7 @@ var ListAuthenticationsSchema = z.object({
2074
2207
  pageSize: z.number().min(1).optional().describe("Number of authentications per page"),
2075
2208
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
2076
2209
  cursor: z.string().optional().describe("Cursor to start from")
2077
- }).describe("List available authentications with optional filtering");
2210
+ }).merge(TelemetryMarkerSchema).describe("List available authentications with optional filtering");
2078
2211
  var AuthenticationItemSchema = withFormatter(
2079
2212
  AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
2080
2213
  {
@@ -2185,7 +2318,11 @@ var listAuthenticationsPlugin = ({ context }) => {
2185
2318
  nextCursor: extractCursor(data)
2186
2319
  };
2187
2320
  },
2188
- ListAuthenticationsSchema
2321
+ ListAuthenticationsSchema,
2322
+ createTelemetryCallback(
2323
+ context.eventEmission.emitMethodCalled,
2324
+ "listAuthentications"
2325
+ )
2189
2326
  );
2190
2327
  return {
2191
2328
  listAuthentications,
@@ -2212,18 +2349,25 @@ var GetAppSchema = z.object({
2212
2349
  }).describe("Get detailed information about a specific app");
2213
2350
 
2214
2351
  // src/plugins/getApp/index.ts
2215
- var getAppPlugin = ({ sdk }) => {
2216
- const getApp = createFunction(async function getApp2(options) {
2217
- const appsIterator = sdk.listApps({ appKeys: [options.appKey] }).items();
2218
- for await (const app of appsIterator) {
2219
- return {
2220
- data: app
2221
- };
2222
- }
2223
- throw new ZapierAppNotFoundError("App not found", {
2224
- appKey: options.appKey
2225
- });
2226
- }, GetAppSchema);
2352
+ var getAppPlugin = ({ sdk, context }) => {
2353
+ const getApp = createFunction(
2354
+ async function getApp2(options) {
2355
+ const appsIterator = sdk.listApps({
2356
+ appKeys: [options.appKey],
2357
+ _telemetry: { isNested: true }
2358
+ }).items();
2359
+ for await (const app of appsIterator) {
2360
+ return {
2361
+ data: app
2362
+ };
2363
+ }
2364
+ throw new ZapierAppNotFoundError("App not found", {
2365
+ appKey: options.appKey
2366
+ });
2367
+ },
2368
+ GetAppSchema,
2369
+ createTelemetryCallback(context.eventEmission.emitMethodCalled, "getApp")
2370
+ );
2227
2371
  return {
2228
2372
  getApp,
2229
2373
  context: {
@@ -2246,22 +2390,29 @@ var GetActionSchema = z.object({
2246
2390
  appKey: AppKeyPropertySchema,
2247
2391
  actionType: ActionTypePropertySchema,
2248
2392
  actionKey: ActionKeyPropertySchema
2249
- }).describe("Get detailed information about a specific action");
2393
+ }).merge(TelemetryMarkerSchema).describe("Get detailed information about a specific action");
2250
2394
 
2251
2395
  // src/plugins/getAction/index.ts
2252
- var getActionPlugin = ({ sdk }) => {
2253
- const getAction = createFunction(async function getAction2(options) {
2254
- const { actionKey, actionType, appKey } = options;
2255
- for await (const action of sdk.listActions({ appKey }).items()) {
2256
- if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
2257
- return { data: action };
2396
+ var getActionPlugin = ({ sdk, context }) => {
2397
+ const getAction = createFunction(
2398
+ async function getAction2(options) {
2399
+ const { actionKey, actionType, appKey } = options;
2400
+ for await (const action of sdk.listActions({ appKey, _telemetry: { isNested: true } }).items()) {
2401
+ if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
2402
+ return { data: action };
2403
+ }
2258
2404
  }
2259
- }
2260
- throw new ZapierResourceNotFoundError(
2261
- `Action not found: ${actionKey} with type ${actionType}`,
2262
- { resourceType: "Action", resourceId: `${actionKey} (${actionType})` }
2263
- );
2264
- }, GetActionSchema);
2405
+ throw new ZapierResourceNotFoundError(
2406
+ `Action not found: ${actionKey} with type ${actionType}`,
2407
+ { resourceType: "Action", resourceId: `${actionKey} (${actionType})` }
2408
+ );
2409
+ },
2410
+ GetActionSchema,
2411
+ createTelemetryCallback(
2412
+ context.eventEmission.emitMethodCalled,
2413
+ "getAction"
2414
+ )
2415
+ );
2265
2416
  return {
2266
2417
  getAction,
2267
2418
  context: {
@@ -2338,12 +2489,19 @@ z.object({
2338
2489
 
2339
2490
  // src/plugins/getAuthentication/index.ts
2340
2491
  var getAuthenticationPlugin = ({ context }) => {
2341
- const getAuthentication = createFunction(async function getAuthentication2(options) {
2342
- const { api } = context;
2343
- return await api.get(
2344
- `/api/v0/authentications/${options.authenticationId}`
2345
- );
2346
- }, GetAuthenticationOptionsSchema);
2492
+ const getAuthentication = createFunction(
2493
+ async function getAuthentication2(options) {
2494
+ const { api } = context;
2495
+ return await api.get(
2496
+ `/api/v0/authentications/${options.authenticationId}`
2497
+ );
2498
+ },
2499
+ GetAuthenticationOptionsSchema,
2500
+ createTelemetryCallback(
2501
+ context.eventEmission.emitMethodCalled,
2502
+ "getAuthentication"
2503
+ )
2504
+ );
2347
2505
  return {
2348
2506
  getAuthentication,
2349
2507
  context: {
@@ -2373,12 +2531,13 @@ var FindFirstAuthenticationSchema = z.object({
2373
2531
  }).describe("Find the first authentication matching the criteria");
2374
2532
 
2375
2533
  // src/plugins/findFirstAuthentication/index.ts
2376
- var findFirstAuthenticationPlugin = ({ sdk }) => {
2534
+ var findFirstAuthenticationPlugin = ({ sdk, context }) => {
2377
2535
  const findFirstAuthentication = createFunction(
2378
2536
  async function findFirstAuthentication2(options = {}) {
2379
2537
  const authsResponse = await sdk.listAuthentications({
2380
2538
  ...options,
2381
- maxItems: 1
2539
+ maxItems: 1,
2540
+ _telemetry: { isNested: true }
2382
2541
  });
2383
2542
  if (authsResponse.data.length === 0) {
2384
2543
  throw new ZapierResourceNotFoundError(
@@ -2390,7 +2549,11 @@ var findFirstAuthenticationPlugin = ({ sdk }) => {
2390
2549
  data: authsResponse.data[0]
2391
2550
  };
2392
2551
  },
2393
- FindFirstAuthenticationSchema
2552
+ FindFirstAuthenticationSchema,
2553
+ createTelemetryCallback(
2554
+ context.eventEmission.emitMethodCalled,
2555
+ "findFirstAuthentication"
2556
+ )
2394
2557
  );
2395
2558
  return {
2396
2559
  findFirstAuthentication,
@@ -2418,13 +2581,14 @@ var FindUniqueAuthenticationSchema = z.object({
2418
2581
  }).describe("Find a unique authentication matching the criteria");
2419
2582
 
2420
2583
  // src/plugins/findUniqueAuthentication/index.ts
2421
- var findUniqueAuthenticationPlugin = ({ sdk }) => {
2584
+ var findUniqueAuthenticationPlugin = ({ sdk, context }) => {
2422
2585
  const findUniqueAuthentication = createFunction(
2423
2586
  async function findUniqueAuthentication2(options = {}) {
2424
2587
  const authsResponse = await sdk.listAuthentications({
2425
2588
  ...options,
2426
- maxItems: 2
2589
+ maxItems: 2,
2427
2590
  // Get up to 2 to check for uniqueness
2591
+ _telemetry: { isNested: true }
2428
2592
  });
2429
2593
  if (authsResponse.data.length === 0) {
2430
2594
  throw new ZapierResourceNotFoundError(
@@ -2441,7 +2605,11 @@ var findUniqueAuthenticationPlugin = ({ sdk }) => {
2441
2605
  data: authsResponse.data[0]
2442
2606
  };
2443
2607
  },
2444
- FindUniqueAuthenticationSchema
2608
+ FindUniqueAuthenticationSchema,
2609
+ createTelemetryCallback(
2610
+ context.eventEmission.emitMethodCalled,
2611
+ "findUniqueAuthentication"
2612
+ )
2445
2613
  );
2446
2614
  return {
2447
2615
  findUniqueAuthentication,
@@ -2515,52 +2683,63 @@ async function executeAction(actionOptions) {
2515
2683
  });
2516
2684
  }
2517
2685
  var runActionPlugin = ({ sdk, context }) => {
2518
- const runAction = createPaginatedFunction(async function runActionPage(options) {
2519
- const { api } = context;
2520
- const {
2521
- appKey,
2522
- actionKey,
2523
- actionType,
2524
- authenticationId,
2525
- inputs = {}
2526
- } = options;
2527
- const actionData = await sdk.getAction({
2528
- appKey,
2529
- actionKey,
2530
- actionType
2531
- });
2532
- if (actionData.data.action_type !== actionType) {
2533
- throw new ZapierValidationError(
2534
- `Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
2535
- );
2536
- }
2537
- const actionId = actionData.data.id;
2538
- const result = await executeAction({
2539
- api,
2540
- context,
2541
- appKey,
2542
- // Some actions require the action ID to run them, but technically the ID is not guaranteed to be available when
2543
- // we retrieve actions (probably legacy reasons), so we just pass along all the things!
2544
- actionId,
2545
- actionKey,
2546
- actionType,
2547
- executionOptions: { inputs },
2548
- authenticationId});
2549
- if (result.errors && result.errors.length > 0) {
2550
- const errorMessage = result.errors.map(
2551
- (error) => error.detail || error.title || "Unknown error"
2552
- ).join("; ");
2553
- throw new ZapierActionError(`Action execution failed: ${errorMessage}`, {
2686
+ const runAction = createPaginatedFunction(
2687
+ async function runActionPage(options) {
2688
+ const { api } = context;
2689
+ const {
2554
2690
  appKey,
2555
- actionKey
2691
+ actionKey,
2692
+ actionType,
2693
+ authenticationId,
2694
+ inputs = {}
2695
+ } = options;
2696
+ const actionData = await sdk.getAction({
2697
+ appKey,
2698
+ actionKey,
2699
+ actionType,
2700
+ _telemetry: { isNested: true }
2556
2701
  });
2557
- }
2558
- return {
2559
- data: result.results || [],
2560
- nextCursor: void 0
2561
- // No pagination implemented yet
2562
- };
2563
- }, RunActionSchema);
2702
+ if (actionData.data.action_type !== actionType) {
2703
+ throw new ZapierValidationError(
2704
+ `Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
2705
+ );
2706
+ }
2707
+ const actionId = actionData.data.id;
2708
+ const result = await executeAction({
2709
+ api,
2710
+ context,
2711
+ appKey,
2712
+ // Some actions require the action ID to run them, but technically the ID is not guaranteed to be available when
2713
+ // we retrieve actions (probably legacy reasons), so we just pass along all the things!
2714
+ actionId,
2715
+ actionKey,
2716
+ actionType,
2717
+ executionOptions: { inputs },
2718
+ authenticationId});
2719
+ if (result.errors && result.errors.length > 0) {
2720
+ const errorMessage = result.errors.map(
2721
+ (error) => error.detail || error.title || "Unknown error"
2722
+ ).join("; ");
2723
+ throw new ZapierActionError(
2724
+ `Action execution failed: ${errorMessage}`,
2725
+ {
2726
+ appKey,
2727
+ actionKey
2728
+ }
2729
+ );
2730
+ }
2731
+ return {
2732
+ data: result.results || [],
2733
+ nextCursor: void 0
2734
+ // No pagination implemented yet
2735
+ };
2736
+ },
2737
+ RunActionSchema,
2738
+ createTelemetryCallback(
2739
+ context.eventEmission.emitMethodCalled,
2740
+ "runAction"
2741
+ )
2742
+ );
2564
2743
  return {
2565
2744
  runAction,
2566
2745
  context: {
@@ -2599,7 +2778,7 @@ var RelayRequestSchema = z.object({
2599
2778
  ]).optional().describe("Request headers")
2600
2779
  }).extend({
2601
2780
  relayBaseUrl: z.string().optional().describe("Base URL for Relay service")
2602
- }).describe("Make authenticated HTTP requests through Zapier's Relay service");
2781
+ }).merge(TelemetryMarkerSchema).describe("Make authenticated HTTP requests through Zapier's Relay service");
2603
2782
  var RelayFetchSchema = RelayRequestSchema;
2604
2783
 
2605
2784
  // src/plugins/request/index.ts
@@ -2609,40 +2788,44 @@ function transformUrlToRelayPath(url) {
2609
2788
  return relayPath;
2610
2789
  }
2611
2790
  var requestPlugin = ({ context }) => {
2612
- const request = createFunction(async function request2(options) {
2613
- const { api } = context;
2614
- const {
2615
- url,
2616
- method = "GET",
2617
- body,
2618
- headers: optionsHeaders,
2619
- authenticationId,
2620
- callbackUrl,
2621
- authenticationTemplate
2622
- } = options;
2623
- const relayPath = transformUrlToRelayPath(url);
2624
- const headers = {};
2625
- if (optionsHeaders) {
2626
- const headerEntries = optionsHeaders instanceof Headers ? Array.from(optionsHeaders.entries()) : Array.isArray(optionsHeaders) ? optionsHeaders : Object.entries(optionsHeaders);
2627
- for (const [key, value] of headerEntries) {
2628
- headers[key] = value;
2791
+ const request = createFunction(
2792
+ async function request2(options) {
2793
+ const { api } = context;
2794
+ const {
2795
+ url,
2796
+ method = "GET",
2797
+ body,
2798
+ headers: optionsHeaders,
2799
+ authenticationId,
2800
+ callbackUrl,
2801
+ authenticationTemplate
2802
+ } = options;
2803
+ const relayPath = transformUrlToRelayPath(url);
2804
+ const headers = {};
2805
+ if (optionsHeaders) {
2806
+ const headerEntries = optionsHeaders instanceof Headers ? Array.from(optionsHeaders.entries()) : Array.isArray(optionsHeaders) ? optionsHeaders : Object.entries(optionsHeaders);
2807
+ for (const [key, value] of headerEntries) {
2808
+ headers[key] = value;
2809
+ }
2629
2810
  }
2630
- }
2631
- if (authenticationId) {
2632
- headers["X-Relay-Authentication-Id"] = authenticationId.toString();
2633
- }
2634
- if (callbackUrl) {
2635
- headers["X-Relay-Callback-Url"] = callbackUrl;
2636
- }
2637
- if (authenticationTemplate) {
2638
- headers["X-Authentication-Template"] = authenticationTemplate;
2639
- }
2640
- return await api.fetch(relayPath, {
2641
- method,
2642
- body,
2643
- headers
2644
- });
2645
- }, RelayRequestSchema);
2811
+ if (authenticationId) {
2812
+ headers["X-Relay-Authentication-Id"] = authenticationId.toString();
2813
+ }
2814
+ if (callbackUrl) {
2815
+ headers["X-Relay-Callback-Url"] = callbackUrl;
2816
+ }
2817
+ if (authenticationTemplate) {
2818
+ headers["X-Authentication-Template"] = authenticationTemplate;
2819
+ }
2820
+ return await api.fetch(relayPath, {
2821
+ method,
2822
+ body,
2823
+ headers
2824
+ });
2825
+ },
2826
+ RelayRequestSchema,
2827
+ createTelemetryCallback(context.eventEmission.emitMethodCalled, "request")
2828
+ );
2646
2829
  return {
2647
2830
  request,
2648
2831
  context: {
@@ -3147,23 +3330,30 @@ var UserProfileItemSchema = withFormatter(
3147
3330
 
3148
3331
  // src/plugins/getProfile/index.ts
3149
3332
  var getProfilePlugin = ({ context }) => {
3150
- const getProfile = createFunction(async function getProfile2() {
3151
- const profile = await context.api.get(
3152
- "/zapier/api/v4/profile/",
3153
- {
3154
- authRequired: true
3155
- }
3156
- );
3157
- const { user_id: _unusedUserId, ...data } = profile;
3158
- return {
3159
- data: {
3160
- ...data,
3161
- // Pass through all API response fields
3162
- full_name: `${profile.first_name} ${profile.last_name}`
3163
- // Computed field
3164
- }
3165
- };
3166
- }, GetProfileSchema);
3333
+ const getProfile = createFunction(
3334
+ async function getProfile2() {
3335
+ const profile = await context.api.get(
3336
+ "/zapier/api/v4/profile/",
3337
+ {
3338
+ authRequired: true
3339
+ }
3340
+ );
3341
+ const { user_id: _unusedUserId, ...data } = profile;
3342
+ return {
3343
+ data: {
3344
+ ...data,
3345
+ // Pass through all API response fields
3346
+ full_name: `${profile.first_name} ${profile.last_name}`
3347
+ // Computed field
3348
+ }
3349
+ };
3350
+ },
3351
+ GetProfileSchema,
3352
+ createTelemetryCallback(
3353
+ context.eventEmission.emitMethodCalled,
3354
+ "getProfile"
3355
+ )
3356
+ );
3167
3357
  return {
3168
3358
  getProfile,
3169
3359
  context: {
@@ -4442,7 +4632,11 @@ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
4442
4632
  data: needsData.schema || {}
4443
4633
  };
4444
4634
  },
4445
- GetInputFieldsSchemaSchema
4635
+ GetInputFieldsSchemaSchema,
4636
+ createTelemetryCallback(
4637
+ context.eventEmission.emitMethodCalled,
4638
+ "getInputFieldsSchema"
4639
+ )
4446
4640
  );
4447
4641
  return {
4448
4642
  getInputFieldsSchema,
@@ -4514,85 +4708,92 @@ function transformNeedChoicesToInputFieldChoiceItem(choice) {
4514
4708
  };
4515
4709
  }
4516
4710
  var listInputFieldChoicesPlugin = ({ context, sdk }) => {
4517
- const listInputFieldChoices = createPaginatedFunction(async function listInputFieldChoicesPage(options) {
4518
- const { api, getVersionedImplementationId } = context;
4519
- const {
4520
- appKey,
4521
- actionType,
4522
- actionKey,
4523
- inputFieldKey,
4524
- authenticationId = null,
4525
- inputs,
4526
- page,
4527
- cursor
4528
- } = options;
4529
- const selectedApi = await getVersionedImplementationId(appKey);
4530
- if (!selectedApi) {
4531
- throw new ZapierConfigurationError(
4532
- "No current_implementation_id found for app",
4533
- { configType: "current_implementation_id" }
4711
+ const listInputFieldChoices = createPaginatedFunction(
4712
+ async function listInputFieldChoicesPage(options) {
4713
+ const { api, getVersionedImplementationId } = context;
4714
+ const {
4715
+ appKey,
4716
+ actionType,
4717
+ actionKey,
4718
+ inputFieldKey,
4719
+ authenticationId = null,
4720
+ inputs,
4721
+ page,
4722
+ cursor
4723
+ } = options;
4724
+ const selectedApi = await getVersionedImplementationId(appKey);
4725
+ if (!selectedApi) {
4726
+ throw new ZapierConfigurationError(
4727
+ "No current_implementation_id found for app",
4728
+ { configType: "current_implementation_id" }
4729
+ );
4730
+ }
4731
+ const { data: action } = await sdk.getAction({
4732
+ appKey,
4733
+ actionType,
4734
+ actionKey
4735
+ });
4736
+ const needsData = await fetchImplementationNeeds({
4737
+ api,
4738
+ selectedApi,
4739
+ action: action.key,
4740
+ actionType,
4741
+ authenticationId,
4742
+ inputs
4743
+ });
4744
+ const targetNeed = needsData.needs?.find(
4745
+ (need) => need.key === inputFieldKey
4534
4746
  );
4535
- }
4536
- const { data: action } = await sdk.getAction({
4537
- appKey,
4538
- actionType,
4539
- actionKey
4540
- });
4541
- const needsData = await fetchImplementationNeeds({
4542
- api,
4543
- selectedApi,
4544
- action: action.key,
4545
- actionType,
4546
- authenticationId,
4547
- inputs
4548
- });
4549
- const targetNeed = needsData.needs?.find(
4550
- (need) => need.key === inputFieldKey
4551
- );
4552
- if (targetNeed?.choices && targetNeed.choices.length > 0) {
4553
- return {
4554
- data: targetNeed.choices.map(
4555
- transformNeedChoicesToInputFieldChoiceItem
4556
- ),
4557
- nextCursor: void 0
4558
- };
4559
- }
4560
- if (!action.id) {
4561
- throw new ZapierApiError(
4562
- `Action ${actionKey} does not have an ID - cannot retrieve input field choices`
4747
+ if (targetNeed?.choices && targetNeed.choices.length > 0) {
4748
+ return {
4749
+ data: targetNeed.choices.map(
4750
+ transformNeedChoicesToInputFieldChoiceItem
4751
+ ),
4752
+ nextCursor: void 0
4753
+ };
4754
+ }
4755
+ if (!action.id) {
4756
+ throw new ZapierApiError(
4757
+ `Action ${actionKey} does not have an ID - cannot retrieve input field choices`
4758
+ );
4759
+ }
4760
+ const requestPage = cursor ? parseInt(cursor, 10) : page ?? 0;
4761
+ const choicesData = await fetchImplementationChoices({
4762
+ api,
4763
+ actionId: action.id,
4764
+ inputFieldId: inputFieldKey,
4765
+ authenticationId,
4766
+ inputs,
4767
+ page: requestPage
4768
+ });
4769
+ const choices = (choicesData.choices || []).map(
4770
+ transformNeedChoicesToInputFieldChoiceItem
4563
4771
  );
4564
- }
4565
- const requestPage = cursor ? parseInt(cursor, 10) : page ?? 0;
4566
- const choicesData = await fetchImplementationChoices({
4567
- api,
4568
- actionId: action.id,
4569
- inputFieldId: inputFieldKey,
4570
- authenticationId,
4571
- inputs,
4572
- page: requestPage
4573
- });
4574
- const choices = (choicesData.choices || []).map(
4575
- transformNeedChoicesToInputFieldChoiceItem
4576
- );
4577
- let nextCursor;
4578
- if (choicesData.next_page != null) {
4579
- nextCursor = choicesData.next_page.toString();
4580
- } else if (choicesData.links?.next) {
4581
- try {
4582
- const nextUrl = new URL(choicesData.links.next);
4583
- const nextPage = nextUrl.searchParams.get("page");
4584
- if (nextPage) {
4585
- nextCursor = nextPage;
4772
+ let nextCursor;
4773
+ if (choicesData.next_page != null) {
4774
+ nextCursor = choicesData.next_page.toString();
4775
+ } else if (choicesData.links?.next) {
4776
+ try {
4777
+ const nextUrl = new URL(choicesData.links.next);
4778
+ const nextPage = nextUrl.searchParams.get("page");
4779
+ if (nextPage) {
4780
+ nextCursor = nextPage;
4781
+ }
4782
+ } catch {
4783
+ nextCursor = void 0;
4586
4784
  }
4587
- } catch {
4588
- nextCursor = void 0;
4589
4785
  }
4590
- }
4591
- return {
4592
- data: choices,
4593
- nextCursor
4594
- };
4595
- }, ListInputFieldChoicesSchema);
4786
+ return {
4787
+ data: choices,
4788
+ nextCursor
4789
+ };
4790
+ },
4791
+ ListInputFieldChoicesSchema,
4792
+ createTelemetryCallback(
4793
+ context.eventEmission.emitMethodCalled,
4794
+ "listInputFieldChoices"
4795
+ )
4796
+ );
4596
4797
  return {
4597
4798
  listInputFieldChoices,
4598
4799
  context: {
@@ -4768,7 +4969,7 @@ function getCpuTime() {
4768
4969
 
4769
4970
  // package.json
4770
4971
  var package_default = {
4771
- version: "0.15.10"};
4972
+ version: "0.15.11"};
4772
4973
 
4773
4974
  // src/plugins/eventEmission/builders.ts
4774
4975
  function createBaseEvent(context = {}) {
@@ -4836,11 +5037,44 @@ function buildErrorEventWithContext(data, context = {}) {
4836
5037
  ...data
4837
5038
  };
4838
5039
  }
5040
+ function buildMethodCalledEvent(data, context = {}) {
5041
+ return {
5042
+ ...createBaseEvent(context),
5043
+ method_name: data.method_name ?? null,
5044
+ method_module: data.method_module ?? null,
5045
+ execution_duration_ms: data.execution_duration_ms,
5046
+ success_flag: data.success_flag,
5047
+ error_message: data.error_message ?? null,
5048
+ error_type: data.error_type ?? null,
5049
+ argument_count: data.argument_count,
5050
+ is_paginated: data.is_paginated ?? false,
5051
+ sdk_version: package_default.version,
5052
+ environment: context.environment ?? (process?.env?.NODE_ENV || null),
5053
+ selected_api: context.selected_api ?? null,
5054
+ app_id: context.app_id ?? null,
5055
+ app_version_id: context.app_version_id ?? null,
5056
+ zap_id: context.zap_id ?? null,
5057
+ node_id: context.node_id ?? null,
5058
+ operation_type: null,
5059
+ operation_key: null,
5060
+ call_context: null,
5061
+ is_retry: false,
5062
+ retry_attempt: null,
5063
+ argument_types: null,
5064
+ return_type: null,
5065
+ caller_method: null,
5066
+ call_stack_depth: null,
5067
+ is_synchronous: false,
5068
+ cpu_time_ms: null,
5069
+ memory_usage_bytes: null
5070
+ };
5071
+ }
4839
5072
 
4840
5073
  // src/plugins/eventEmission/index.ts
4841
5074
  var TELEMETRY_EMIT_TIMEOUT_MS = 300;
4842
5075
  var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
4843
5076
  var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
5077
+ var METHOD_CALLED_EVENT_SUBJECT = "platform.sdk.MethodCalledEvent";
4844
5078
  var transportStates = /* @__PURE__ */ new WeakMap();
4845
5079
  async function silentEmit(transport, subject, event, userContextPromise) {
4846
5080
  try {
@@ -4942,7 +5176,9 @@ var eventEmissionPlugin = ({ context }) => {
4942
5176
  identity_id: null,
4943
5177
  visitor_id: null,
4944
5178
  correlation_id: null
4945
- })
5179
+ }),
5180
+ emitMethodCalled: () => {
5181
+ }
4946
5182
  }
4947
5183
  }
4948
5184
  };
@@ -5094,7 +5330,16 @@ var eventEmissionPlugin = ({ context }) => {
5094
5330
  emit: (subject, event) => {
5095
5331
  silentEmit(transport, subject, event, getUserContext);
5096
5332
  },
5097
- createBaseEvent: createBaseEventHelper
5333
+ createBaseEvent: createBaseEventHelper,
5334
+ emitMethodCalled: (data) => {
5335
+ const event = buildMethodCalledEvent(data);
5336
+ silentEmit(
5337
+ transport,
5338
+ METHOD_CALLED_EVENT_SUBJECT,
5339
+ event,
5340
+ getUserContext
5341
+ );
5342
+ }
5098
5343
  }
5099
5344
  }
5100
5345
  };
@@ -5155,4 +5400,4 @@ function createZapierSdk(options = {}) {
5155
5400
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
5156
5401
  }
5157
5402
 
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 };
5403
+ 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 };