@zapier/zapier-sdk 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +23 -9
  3. package/dist/api/schemas.d.ts +2 -2
  4. package/dist/index.cjs +276 -204
  5. package/dist/index.d.mts +203 -86
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.mjs +270 -205
  10. package/dist/plugins/createClientCredentials/schemas.d.ts +0 -3
  11. package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
  12. package/dist/plugins/createClientCredentials/schemas.js +0 -2
  13. package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -3
  14. package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
  15. package/dist/plugins/deleteClientCredentials/schemas.js +0 -2
  16. package/dist/plugins/fetch/index.d.ts +0 -3
  17. package/dist/plugins/fetch/index.d.ts.map +1 -1
  18. package/dist/plugins/fetch/index.js +59 -53
  19. package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
  20. package/dist/plugins/findFirstConnection/index.js +0 -1
  21. package/dist/plugins/findFirstConnection/schemas.d.ts +1 -1
  22. package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
  23. package/dist/plugins/findFirstConnection/schemas.js +0 -1
  24. package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
  25. package/dist/plugins/findUniqueConnection/index.js +0 -1
  26. package/dist/plugins/findUniqueConnection/schemas.d.ts +1 -1
  27. package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
  28. package/dist/plugins/findUniqueConnection/schemas.js +0 -1
  29. package/dist/plugins/getAction/index.d.ts.map +1 -1
  30. package/dist/plugins/getAction/index.js +1 -3
  31. package/dist/plugins/getAction/schemas.d.ts +0 -3
  32. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  33. package/dist/plugins/getAction/schemas.js +0 -2
  34. package/dist/plugins/getApp/index.d.ts.map +1 -1
  35. package/dist/plugins/getApp/index.js +0 -1
  36. package/dist/plugins/listActions/schemas.d.ts +0 -3
  37. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  38. package/dist/plugins/listActions/schemas.js +0 -2
  39. package/dist/plugins/listApps/schemas.d.ts +0 -3
  40. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  41. package/dist/plugins/listApps/schemas.js +0 -2
  42. package/dist/plugins/listClientCredentials/schemas.d.ts +0 -3
  43. package/dist/plugins/listClientCredentials/schemas.d.ts.map +1 -1
  44. package/dist/plugins/listClientCredentials/schemas.js +0 -2
  45. package/dist/plugins/listConnections/schemas.d.ts +1 -4
  46. package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
  47. package/dist/plugins/listConnections/schemas.js +0 -2
  48. package/dist/plugins/request/index.d.ts.map +1 -1
  49. package/dist/plugins/request/index.js +0 -1
  50. package/dist/plugins/request/schemas.d.ts +0 -6
  51. package/dist/plugins/request/schemas.d.ts.map +1 -1
  52. package/dist/plugins/request/schemas.js +0 -2
  53. package/dist/plugins/runAction/index.d.ts.map +1 -1
  54. package/dist/plugins/runAction/index.js +0 -1
  55. package/dist/schemas/Action.d.ts +2 -2
  56. package/dist/types/credentials.d.ts +137 -17
  57. package/dist/types/credentials.d.ts.map +1 -1
  58. package/dist/types/credentials.js +80 -0
  59. package/dist/types/meta.d.ts +9 -0
  60. package/dist/types/meta.d.ts.map +1 -0
  61. package/dist/types/meta.js +3 -0
  62. package/dist/types/sdk.d.ts +61 -35
  63. package/dist/types/sdk.d.ts.map +1 -1
  64. package/dist/types/sdk.js +55 -1
  65. package/dist/utils/function-utils.d.ts +1 -14
  66. package/dist/utils/function-utils.d.ts.map +1 -1
  67. package/dist/utils/function-utils.js +115 -123
  68. package/dist/utils/function-utils.test.js +79 -1
  69. package/dist/utils/telemetry-context.d.ts +3 -0
  70. package/dist/utils/telemetry-context.d.ts.map +1 -0
  71. package/dist/utils/telemetry-context.js +23 -0
  72. package/dist/utils/telemetry-context.test.d.ts +2 -0
  73. package/dist/utils/telemetry-context.test.d.ts.map +1 -0
  74. package/dist/utils/telemetry-context.test.js +92 -0
  75. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -5,7 +5,12 @@ import { ListClientCredentialsQuerySchema as ListClientCredentialsQuerySchema$1,
5
5
  import { setTimeout as setTimeout$1 } from 'timers/promises';
6
6
  import * as os from 'os';
7
7
 
8
- // src/types/properties.ts
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
9
14
  function withFormatter(schema, formatMeta) {
10
15
  Object.assign(schema._zod.def, {
11
16
  formatMeta
@@ -447,6 +452,24 @@ function isPlainObject(value) {
447
452
  return proto === Object.prototype || proto === null;
448
453
  }
449
454
 
455
+ // src/utils/telemetry-context.ts
456
+ var telemetryStore = null;
457
+ try {
458
+ const mod = __require("async_hooks");
459
+ telemetryStore = new mod.AsyncLocalStorage();
460
+ } catch {
461
+ }
462
+ function isTelemetryNested() {
463
+ if (!telemetryStore) return true;
464
+ const store = telemetryStore.getStore();
465
+ return store !== void 0 && store.depth > 0;
466
+ }
467
+ function runWithTelemetryContext(fn) {
468
+ if (!telemetryStore) return fn();
469
+ const currentDepth = telemetryStore.getStore()?.depth ?? -1;
470
+ return telemetryStore.run({ depth: currentDepth + 1 }, fn);
471
+ }
472
+
450
473
  // src/plugins/fetch/index.ts
451
474
  function transformUrlToRelayPath(url) {
452
475
  const targetUrl = new URL(url);
@@ -487,76 +510,72 @@ function inferContentType(body) {
487
510
  var fetchPlugin = ({ context }) => {
488
511
  return {
489
512
  fetch: async function fetch2(url, init) {
490
- const { api } = context;
491
- const startTime = Date.now();
492
- const isNested = init?._telemetry?.isNested === true;
493
- try {
494
- const {
495
- connectionId,
496
- authenticationId,
497
- callbackUrl,
498
- _telemetry,
499
- ...fetchInit
500
- } = init || {};
501
- const resolvedConnectionId = connectionId ?? authenticationId;
502
- const relayPath = transformUrlToRelayPath(url);
503
- const headers = normalizeHeaders(
504
- fetchInit.headers
505
- );
506
- const hasContentType = Object.keys(headers).some(
507
- (k) => k.toLowerCase() === "content-type"
508
- );
509
- if (fetchInit.body && !hasContentType) {
510
- const inferred = inferContentType(
511
- fetchInit.body
513
+ return runWithTelemetryContext(async () => {
514
+ const { api } = context;
515
+ const startTime = Date.now();
516
+ const isNested = isTelemetryNested();
517
+ try {
518
+ const { connectionId, authenticationId, callbackUrl, ...fetchInit } = init || {};
519
+ const resolvedConnectionId = connectionId ?? authenticationId;
520
+ const relayPath = transformUrlToRelayPath(url);
521
+ const headers = normalizeHeaders(
522
+ fetchInit.headers
523
+ );
524
+ const hasContentType = Object.keys(headers).some(
525
+ (k) => k.toLowerCase() === "content-type"
512
526
  );
513
- if (inferred) {
514
- headers["Content-Type"] = inferred;
527
+ if (fetchInit.body && !hasContentType) {
528
+ const inferred = inferContentType(
529
+ fetchInit.body
530
+ );
531
+ if (inferred) {
532
+ headers["Content-Type"] = inferred;
533
+ }
515
534
  }
516
- }
517
- if (resolvedConnectionId) {
518
- headers["X-Relay-Authentication-Id"] = coerceToNumericId(
519
- "connectionId",
520
- resolvedConnectionId
521
- ).toString();
522
- }
523
- if (callbackUrl) {
524
- headers["X-Relay-Callback-Url"] = callbackUrl;
525
- }
526
- const result = await api.fetch(relayPath, {
527
- method: fetchInit.method ?? "GET",
528
- body: fetchInit.body,
529
- headers,
530
- redirect: fetchInit.redirect,
531
- signal: fetchInit.signal,
532
- authRequired: true
533
- });
534
- if (!isNested) {
535
- context.eventEmission.emitMethodCalled({
536
- method_name: "fetch",
537
- execution_duration_ms: Date.now() - startTime,
538
- success_flag: true,
539
- error_message: null,
540
- error_type: null,
541
- argument_count: init ? 2 : 1,
542
- is_paginated: false
543
- });
544
- }
545
- return result;
546
- } catch (error) {
547
- if (!isNested) {
548
- context.eventEmission.emitMethodCalled({
549
- method_name: "fetch",
550
- execution_duration_ms: Date.now() - startTime,
551
- success_flag: false,
552
- error_message: error instanceof Error ? error.message : String(error),
553
- error_type: error instanceof Error ? error.constructor.name : "Unknown",
554
- argument_count: init ? 2 : 1,
555
- is_paginated: false
535
+ if (resolvedConnectionId) {
536
+ headers["X-Relay-Authentication-Id"] = coerceToNumericId(
537
+ "connectionId",
538
+ resolvedConnectionId
539
+ ).toString();
540
+ }
541
+ if (callbackUrl) {
542
+ headers["X-Relay-Callback-Url"] = callbackUrl;
543
+ }
544
+ const result = await api.fetch(relayPath, {
545
+ method: fetchInit.method ?? "GET",
546
+ body: fetchInit.body,
547
+ headers,
548
+ redirect: fetchInit.redirect,
549
+ signal: fetchInit.signal,
550
+ authRequired: true
556
551
  });
552
+ if (!isNested) {
553
+ context.eventEmission.emitMethodCalled({
554
+ method_name: "fetch",
555
+ execution_duration_ms: Date.now() - startTime,
556
+ success_flag: true,
557
+ error_message: null,
558
+ error_type: null,
559
+ argument_count: init ? 2 : 1,
560
+ is_paginated: false
561
+ });
562
+ }
563
+ return result;
564
+ } catch (error) {
565
+ if (!isNested) {
566
+ context.eventEmission.emitMethodCalled({
567
+ method_name: "fetch",
568
+ execution_duration_ms: Date.now() - startTime,
569
+ success_flag: false,
570
+ error_message: error instanceof Error ? error.message : String(error),
571
+ error_type: error instanceof Error ? error.constructor.name : "Unknown",
572
+ argument_count: init ? 2 : 1,
573
+ is_paginated: false
574
+ });
575
+ }
576
+ throw error;
557
577
  }
558
- throw error;
559
- }
578
+ });
560
579
  },
561
580
  context: {
562
581
  meta: {
@@ -747,11 +766,6 @@ var validateOptions = (schema, options) => {
747
766
  };
748
767
 
749
768
  // src/utils/function-utils.ts
750
- var TelemetryMarkerSchema = z.object({
751
- _telemetry: z.object({
752
- isNested: z.boolean().optional()
753
- }).optional()
754
- });
755
769
  function extractCursor(data) {
756
770
  if (!data?.next) {
757
771
  return void 0;
@@ -781,20 +795,36 @@ function createFunction(coreFn, schema, telemetry) {
781
795
  const functionName = coreFn.name;
782
796
  const namedFunctions = {
783
797
  [functionName]: async function(options) {
784
- const startTime = Date.now();
785
- const normalizedOptions = options ?? {};
786
- const isNested = normalizedOptions?._telemetry?.isNested === true;
787
- try {
788
- if (schema) {
789
- const validatedOptions = validateOptions(schema, normalizedOptions);
790
- const result2 = await coreFn({
791
- ...normalizedOptions,
792
- ...validatedOptions
793
- });
798
+ return runWithTelemetryContext(async () => {
799
+ const startTime = Date.now();
800
+ const normalizedOptions = options ?? {};
801
+ const isNested = isTelemetryNested();
802
+ try {
803
+ if (schema) {
804
+ const validatedOptions = validateOptions(schema, normalizedOptions);
805
+ const result2 = await coreFn({
806
+ ...normalizedOptions,
807
+ ...validatedOptions
808
+ });
809
+ if (!isNested && telemetry?.onMethodCalled) {
810
+ const argumentCount = Object.keys(
811
+ normalizedOptions
812
+ ).length;
813
+ telemetry.onMethodCalled({
814
+ methodName: functionName,
815
+ durationMs: Date.now() - startTime,
816
+ success: true,
817
+ argumentCount,
818
+ isPaginated: false
819
+ });
820
+ }
821
+ return result2;
822
+ }
823
+ const result = await coreFn(normalizedOptions);
794
824
  if (!isNested && telemetry?.onMethodCalled) {
795
825
  const argumentCount = Object.keys(
796
826
  normalizedOptions
797
- ).filter((k) => k !== "_telemetry").length;
827
+ ).length;
798
828
  telemetry.onMethodCalled({
799
829
  methodName: functionName,
800
830
  durationMs: Date.now() - startTime,
@@ -803,39 +833,25 @@ function createFunction(coreFn, schema, telemetry) {
803
833
  isPaginated: false
804
834
  });
805
835
  }
806
- return result2;
807
- }
808
- const result = await coreFn(normalizedOptions);
809
- if (!isNested && telemetry?.onMethodCalled) {
810
- const argumentCount = Object.keys(normalizedOptions).filter(
811
- (k) => k !== "_telemetry"
812
- ).length;
813
- telemetry.onMethodCalled({
814
- methodName: functionName,
815
- durationMs: Date.now() - startTime,
816
- success: true,
817
- argumentCount,
818
- isPaginated: false
819
- });
820
- }
821
- return result;
822
- } catch (error) {
823
- const normalizedError = normalizeError(error);
824
- if (!isNested && telemetry?.onMethodCalled) {
825
- const argumentCount = Object.keys(normalizedOptions).filter(
826
- (k) => k !== "_telemetry"
827
- ).length;
828
- telemetry.onMethodCalled({
829
- methodName: functionName,
830
- durationMs: Date.now() - startTime,
831
- success: false,
832
- error: normalizedError,
833
- argumentCount,
834
- isPaginated: false
835
- });
836
+ return result;
837
+ } catch (error) {
838
+ const normalizedError = normalizeError(error);
839
+ if (!isNested && telemetry?.onMethodCalled) {
840
+ const argumentCount = Object.keys(
841
+ normalizedOptions
842
+ ).length;
843
+ telemetry.onMethodCalled({
844
+ methodName: functionName,
845
+ durationMs: Date.now() - startTime,
846
+ success: false,
847
+ error: normalizedError,
848
+ argumentCount,
849
+ isPaginated: false
850
+ });
851
+ }
852
+ throw normalizedError;
836
853
  }
837
- throw normalizedError;
838
- }
854
+ });
839
855
  }
840
856
  };
841
857
  return namedFunctions[functionName];
@@ -876,73 +892,75 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
876
892
  const validator = schema ? createValidator(schema) : null;
877
893
  const namedFunctions = {
878
894
  [functionName]: function(options) {
879
- const startTime = Date.now();
880
- const normalizedOptions = options ?? {};
881
- const isNested = normalizedOptions?._telemetry?.isNested === true;
882
- const validatedOptions = {
883
- ...normalizedOptions,
884
- ...validator ? validator(normalizedOptions) : normalizedOptions
885
- };
886
- const pageSize = validatedOptions.pageSize || 100;
887
- const optimizedOptions = {
888
- ...validatedOptions,
889
- pageSize
890
- };
891
- const iterator = paginate(pageFunction, optimizedOptions);
892
- const firstPagePromise = iterator.next().then((result) => {
893
- if (result.done) {
894
- throw new Error("Paginate should always iterate at least once");
895
- }
896
- return result.value;
897
- });
898
- if (!isNested && telemetry?.onMethodCalled) {
899
- firstPagePromise.then(() => {
900
- const argumentCount = Object.keys(
901
- normalizedOptions
902
- ).filter((k) => k !== "_telemetry").length;
903
- telemetry.onMethodCalled({
904
- methodName: functionName,
905
- durationMs: Date.now() - startTime,
906
- success: true,
907
- argumentCount,
908
- isPaginated: true
909
- });
910
- }).catch((error) => {
911
- const argumentCount = Object.keys(
912
- normalizedOptions
913
- ).filter((k) => k !== "_telemetry").length;
914
- telemetry.onMethodCalled({
915
- methodName: functionName,
916
- durationMs: Date.now() - startTime,
917
- success: false,
918
- error: error instanceof Error ? error : new Error(String(error)),
919
- argumentCount,
920
- isPaginated: true
921
- });
922
- });
923
- }
924
- return Object.assign(firstPagePromise, {
925
- [Symbol.asyncIterator]: async function* () {
926
- yield await firstPagePromise;
927
- for await (const page of iterator) {
928
- yield page;
895
+ return runWithTelemetryContext(() => {
896
+ const startTime = Date.now();
897
+ const normalizedOptions = options ?? {};
898
+ const isNested = isTelemetryNested();
899
+ const validatedOptions = {
900
+ ...normalizedOptions,
901
+ ...validator ? validator(normalizedOptions) : normalizedOptions
902
+ };
903
+ const pageSize = validatedOptions.pageSize || 100;
904
+ const optimizedOptions = {
905
+ ...validatedOptions,
906
+ pageSize
907
+ };
908
+ const iterator = paginate(pageFunction, optimizedOptions);
909
+ const firstPagePromise = iterator.next().then((result) => {
910
+ if (result.done) {
911
+ throw new Error("Paginate should always iterate at least once");
929
912
  }
930
- },
931
- items: function() {
932
- return {
933
- [Symbol.asyncIterator]: async function* () {
934
- const firstPage = await firstPagePromise;
935
- for (const item of firstPage.data) {
936
- yield item;
937
- }
938
- for await (const page of iterator) {
939
- for (const item of page.data) {
913
+ return result.value;
914
+ });
915
+ if (!isNested && telemetry?.onMethodCalled) {
916
+ firstPagePromise.then(() => {
917
+ const argumentCount = Object.keys(
918
+ normalizedOptions
919
+ ).length;
920
+ telemetry.onMethodCalled({
921
+ methodName: functionName,
922
+ durationMs: Date.now() - startTime,
923
+ success: true,
924
+ argumentCount,
925
+ isPaginated: true
926
+ });
927
+ }).catch((error) => {
928
+ const argumentCount = Object.keys(
929
+ normalizedOptions
930
+ ).length;
931
+ telemetry.onMethodCalled({
932
+ methodName: functionName,
933
+ durationMs: Date.now() - startTime,
934
+ success: false,
935
+ error: error instanceof Error ? error : new Error(String(error)),
936
+ argumentCount,
937
+ isPaginated: true
938
+ });
939
+ });
940
+ }
941
+ return Object.assign(firstPagePromise, {
942
+ [Symbol.asyncIterator]: async function* () {
943
+ yield await firstPagePromise;
944
+ for await (const page of iterator) {
945
+ yield page;
946
+ }
947
+ },
948
+ items: function() {
949
+ return {
950
+ [Symbol.asyncIterator]: async function* () {
951
+ const firstPage = await firstPagePromise;
952
+ for (const item of firstPage.data) {
940
953
  yield item;
941
954
  }
955
+ for await (const page of iterator) {
956
+ for (const item of page.data) {
957
+ yield item;
958
+ }
959
+ }
942
960
  }
943
- }
944
- };
945
- }
961
+ };
962
+ }
963
+ });
946
964
  });
947
965
  }
948
966
  };
@@ -961,7 +979,7 @@ var ListAppsSchema = ListAppsQuerySchema.omit({
961
979
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
962
980
  // SDK specific property for pagination/iterable helpers
963
981
  cursor: z.string().optional().describe("Cursor to start from")
964
- }).merge(TelemetryMarkerSchema).describe("List all available apps with optional filtering");
982
+ }).describe("List all available apps with optional filtering");
965
983
 
966
984
  // src/utils/string-utils.ts
967
985
  function toTitleCase(input) {
@@ -1171,7 +1189,7 @@ var ListActionsSchema = z.object({
1171
1189
  pageSize: z.number().min(1).optional().describe("Number of actions per page"),
1172
1190
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
1173
1191
  cursor: z.string().optional().describe("Cursor to start from")
1174
- }).merge(TelemetryMarkerSchema).describe("List all actions for a specific app");
1192
+ }).describe("List all actions for a specific app");
1175
1193
  var NeedChoicesSchema = z.object({
1176
1194
  key: z.string().optional(),
1177
1195
  label: z.string().optional(),
@@ -2207,7 +2225,7 @@ var ListConnectionsQuerySchema = ListConnectionsQuerySchema$1.omit({
2207
2225
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
2208
2226
  // SDK specific property for pagination/iterable helpers
2209
2227
  cursor: z.string().optional().describe("Cursor to start from")
2210
- }).merge(TelemetryMarkerSchema).describe("List available connections with optional filtering");
2228
+ }).describe("List available connections with optional filtering");
2211
2229
  var ConnectionItemSchema = withFormatter(ConnectionItemSchema$1, {
2212
2230
  format: (item) => {
2213
2231
  const details = [];
@@ -2334,7 +2352,7 @@ var ListClientCredentialsQuerySchema = ListClientCredentialsQuerySchema$1.omit({
2334
2352
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
2335
2353
  // SDK specific property for pagination/iterable helpers
2336
2354
  cursor: z.string().optional().describe("Cursor to start from")
2337
- }).merge(TelemetryMarkerSchema).describe("List client credentials for the authenticated user");
2355
+ }).describe("List client credentials for the authenticated user");
2338
2356
  var ClientCredentialsItemSchema = withFormatter(
2339
2357
  ClientCredentialsItemSchema$1,
2340
2358
  {
@@ -2437,7 +2455,7 @@ var listClientCredentialsPlugin = ({ context }) => {
2437
2455
  };
2438
2456
  var CreateClientCredentialsSchema = CreateClientCredentialsRequestSchema.omit({ allowed_scopes: true }).extend({
2439
2457
  allowedScopes: z.array(z.enum(["credentials", "external"])).default(["external"]).describe("Scopes to allow for these credentials")
2440
- }).merge(TelemetryMarkerSchema).describe("Create new client credentials for the authenticated user");
2458
+ }).describe("Create new client credentials for the authenticated user");
2441
2459
 
2442
2460
  // src/plugins/createClientCredentials/index.ts
2443
2461
  var createClientCredentialsPlugin = ({ context }) => {
@@ -2502,7 +2520,7 @@ var createClientCredentialsPlugin = ({ context }) => {
2502
2520
  };
2503
2521
  var DeleteClientCredentialsSchema = z.object({
2504
2522
  clientId: z.string().describe("The client ID of the client credentials to delete")
2505
- }).merge(TelemetryMarkerSchema).describe("Delete client credentials by client ID");
2523
+ }).describe("Delete client credentials by client ID");
2506
2524
 
2507
2525
  // src/plugins/deleteClientCredentials/index.ts
2508
2526
  var deleteClientCredentialsPlugin = ({ context }) => {
@@ -2566,8 +2584,7 @@ var GetAppSchema = z.object({
2566
2584
  var getAppPlugin = ({ sdk, context }) => {
2567
2585
  async function getApp(options) {
2568
2586
  const appsIterable = sdk.listApps({
2569
- appKeys: [options.appKey],
2570
- _telemetry: { isNested: true }
2587
+ appKeys: [options.appKey]
2571
2588
  }).items();
2572
2589
  for await (const app of appsIterable) {
2573
2590
  return {
@@ -2608,13 +2625,13 @@ var GetActionSchema = z.object({
2608
2625
  appKey: AppKeyPropertySchema,
2609
2626
  actionType: ActionTypePropertySchema,
2610
2627
  actionKey: ActionKeyPropertySchema
2611
- }).merge(TelemetryMarkerSchema).describe("Get detailed information about a specific action");
2628
+ }).describe("Get detailed information about a specific action");
2612
2629
 
2613
2630
  // src/plugins/getAction/index.ts
2614
2631
  var getActionPlugin = ({ sdk, context }) => {
2615
2632
  async function getAction(options) {
2616
2633
  const { actionKey, actionType, appKey } = options;
2617
- for await (const action of sdk.listActions({ appKey, _telemetry: { isNested: true } }).items()) {
2634
+ for await (const action of sdk.listActions({ appKey }).items()) {
2618
2635
  if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
2619
2636
  return { data: action };
2620
2637
  }
@@ -2703,8 +2720,7 @@ var FindFirstConnectionSchema = ListConnectionsQuerySchema.omit({
2703
2720
  connectionIds: true,
2704
2721
  pageSize: true,
2705
2722
  maxItems: true,
2706
- cursor: true,
2707
- _telemetry: true
2723
+ cursor: true
2708
2724
  }).describe("Find the first connection matching the criteria");
2709
2725
 
2710
2726
  // src/plugins/findFirstConnection/index.ts
@@ -2712,8 +2728,7 @@ var findFirstConnectionPlugin = ({ sdk, context }) => {
2712
2728
  async function findFirstConnection(options = {}) {
2713
2729
  const connectionsResponse = await sdk.listConnections({
2714
2730
  ...options,
2715
- maxItems: 1,
2716
- _telemetry: { isNested: true }
2731
+ maxItems: 1
2717
2732
  });
2718
2733
  if (connectionsResponse.data.length === 0) {
2719
2734
  throw new ZapierResourceNotFoundError(
@@ -2755,8 +2770,7 @@ var FindUniqueConnectionSchema = ListConnectionsQuerySchema.omit({
2755
2770
  connectionIds: true,
2756
2771
  pageSize: true,
2757
2772
  maxItems: true,
2758
- cursor: true,
2759
- _telemetry: true
2773
+ cursor: true
2760
2774
  }).describe("Find a unique connection matching the criteria");
2761
2775
 
2762
2776
  // src/plugins/findUniqueConnection/index.ts
@@ -2764,9 +2778,8 @@ var findUniqueConnectionPlugin = ({ sdk, context }) => {
2764
2778
  async function findUniqueConnection(options = {}) {
2765
2779
  const connectionsResponse = await sdk.listConnections({
2766
2780
  ...options,
2767
- maxItems: 2,
2781
+ maxItems: 2
2768
2782
  // Get up to 2 to check for uniqueness
2769
- _telemetry: { isNested: true }
2770
2783
  });
2771
2784
  if (connectionsResponse.data.length === 0) {
2772
2785
  throw new ZapierResourceNotFoundError(
@@ -2888,8 +2901,7 @@ var runActionPlugin = ({ sdk, context }) => {
2888
2901
  const actionData = await sdk.getAction({
2889
2902
  appKey,
2890
2903
  actionKey,
2891
- actionType,
2892
- _telemetry: { isNested: true }
2904
+ actionType
2893
2905
  });
2894
2906
  if (actionData.data.action_type !== actionType) {
2895
2907
  throw new ZapierValidationError(
@@ -2968,7 +2980,7 @@ var RelayRequestSchema = z.object({
2968
2980
  z.instanceof(Headers),
2969
2981
  z.array(z.tuple([z.string(), z.string()]))
2970
2982
  ]).optional().describe("Request headers")
2971
- }).merge(TelemetryMarkerSchema).describe("Make authenticated HTTP requests through Zapier's Relay service");
2983
+ }).describe("Make authenticated HTTP requests through Zapier's Relay service");
2972
2984
  var RelayFetchSchema = RelayRequestSchema;
2973
2985
 
2974
2986
  // src/utils/logging.ts
@@ -3001,8 +3013,7 @@ var requestPlugin = ({ sdk, context }) => {
3001
3013
  body,
3002
3014
  headers,
3003
3015
  connectionId: resolvedConnectionId,
3004
- callbackUrl,
3005
- _telemetry: { isNested: true }
3016
+ callbackUrl
3006
3017
  });
3007
3018
  }
3008
3019
  const requestDefinition = createFunction(
@@ -3886,8 +3897,34 @@ async function pollUntilComplete(options) {
3886
3897
  }
3887
3898
  }
3888
3899
  }
3889
-
3890
- // src/types/credentials.ts
3900
+ var ClientCredentialsObjectSchema = z.object({
3901
+ type: z.enum(["client_credentials"]).optional().meta({ internal: true }),
3902
+ clientId: z.string().describe("OAuth client ID for authentication.").meta({ valueHint: "id" }),
3903
+ clientSecret: z.string().describe("OAuth client secret for authentication.").meta({ valueHint: "secret" }),
3904
+ baseUrl: z.string().optional().describe("Override authentication base URL.").meta({ valueHint: "url" }),
3905
+ scope: z.string().optional().describe("Authentication scope.").meta({ internal: true })
3906
+ });
3907
+ var PkceCredentialsObjectSchema = z.object({
3908
+ type: z.enum(["pkce"]).optional().meta({ internal: true }),
3909
+ clientId: z.string().describe("OAuth client ID for authentication.").meta({ valueHint: "id" }),
3910
+ baseUrl: z.string().optional().describe("Override authentication base URL.").meta({ valueHint: "url" }),
3911
+ scope: z.string().optional().describe("Authentication scope.").meta({ internal: true })
3912
+ });
3913
+ var CredentialsObjectSchema = z.union([
3914
+ ClientCredentialsObjectSchema,
3915
+ PkceCredentialsObjectSchema
3916
+ ]);
3917
+ var ResolvedCredentialsSchema = z.union([
3918
+ z.string().describe("Authentication token.").meta({ valueHint: "token" }),
3919
+ CredentialsObjectSchema
3920
+ ]);
3921
+ var CredentialsFunctionSchema = z.function().input([]).output(
3922
+ z.union([ResolvedCredentialsSchema, z.promise(ResolvedCredentialsSchema)])
3923
+ );
3924
+ var CredentialsSchema = z.union([
3925
+ ResolvedCredentialsSchema,
3926
+ CredentialsFunctionSchema
3927
+ ]);
3891
3928
  function isClientCredentials(credentials) {
3892
3929
  return typeof credentials === "object" && credentials !== null && "clientId" in credentials && "clientSecret" in credentials;
3893
3930
  }
@@ -5369,7 +5406,7 @@ function getCpuTime() {
5369
5406
 
5370
5407
  // package.json
5371
5408
  var package_default = {
5372
- version: "0.29.0"};
5409
+ version: "0.31.0"};
5373
5410
 
5374
5411
  // src/plugins/eventEmission/builders.ts
5375
5412
  function createBaseEvent(context = {}) {
@@ -5828,5 +5865,33 @@ function createZapierSdkWithoutRegistry(options = {}) {
5828
5865
  function createZapierSdk(options = {}) {
5829
5866
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
5830
5867
  }
5868
+ var BaseSdkOptionsSchema = z.object({
5869
+ credentials: CredentialsSchema.optional().describe(
5870
+ "Authentication credentials. Can be a string (token or API key), a client credentials object ({ clientId, clientSecret }), a PKCE object ({ clientId }), or a function returning any of those."
5871
+ ),
5872
+ debug: z.boolean().optional().describe("Enable debug logging."),
5873
+ baseUrl: z.string().optional().describe("Base URL for Zapier API endpoints.").meta({ valueHint: "url" }),
5874
+ trackingBaseUrl: z.string().optional().describe("Base URL for Zapier tracking endpoints.").meta({ valueHint: "url" }),
5875
+ /**
5876
+ * Maximum number of retries for rate-limited requests (429 responses).
5877
+ * Set to 0 to disable retries. Default is 3.
5878
+ */
5879
+ maxNetworkRetries: z.number().optional().describe("Max retries for rate-limited requests (default: 3).").meta({ valueHint: "count" }),
5880
+ /**
5881
+ * Maximum delay in milliseconds to wait for a rate limit retry.
5882
+ * If the server requests a longer delay, the request fails immediately.
5883
+ * Default is 60000 (60 seconds).
5884
+ */
5885
+ maxNetworkRetryDelayMs: z.number().optional().describe("Max delay in ms to wait for retry (default: 60000).").meta({ valueHint: "ms" }),
5886
+ // Internal
5887
+ manifestPath: z.string().optional().describe("Path to a .zapierrc manifest file for app version locking.").meta({ internal: true }),
5888
+ manifest: z.custom().optional().describe("Manifest for app version locking.").meta({ internal: true }),
5889
+ onEvent: z.custom().optional().meta({ internal: true }),
5890
+ fetch: z.custom().optional().meta({ internal: true }),
5891
+ eventEmission: z.custom().optional().meta({ internal: true }),
5892
+ // Deprecated
5893
+ token: z.string().optional().meta({ deprecated: true })
5894
+ // Use credentials instead
5895
+ });
5831
5896
 
5832
- export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, ConnectionIdPropertySchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, ZAPIER_BASE_URL, ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZAPIER_TOKEN, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
5897
+ export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, ClientCredentialsObjectSchema, ConnectionIdPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, ZAPIER_BASE_URL, ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZAPIER_TOKEN, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };