@zapier/zapier-sdk 0.13.7 → 0.13.9

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 (59) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api/client.js +5 -5
  4. package/dist/api/client.test.d.ts +2 -0
  5. package/dist/api/client.test.d.ts.map +1 -0
  6. package/dist/api/client.test.js +80 -0
  7. package/dist/api/index.d.ts +1 -0
  8. package/dist/api/index.d.ts.map +1 -1
  9. package/dist/api/index.js +3 -1
  10. package/dist/api/polling.d.ts.map +1 -1
  11. package/dist/api/polling.js +1 -11
  12. package/dist/api/schemas.d.ts +20 -20
  13. package/dist/api/types.d.ts +2 -0
  14. package/dist/api/types.d.ts.map +1 -1
  15. package/dist/auth.d.ts +3 -0
  16. package/dist/auth.d.ts.map +1 -1
  17. package/dist/auth.test.d.ts +2 -0
  18. package/dist/auth.test.d.ts.map +1 -0
  19. package/dist/auth.test.js +102 -0
  20. package/dist/constants.d.ts +4 -4
  21. package/dist/constants.d.ts.map +1 -1
  22. package/dist/constants.js +4 -4
  23. package/dist/index.cjs +194 -33
  24. package/dist/index.d.mts +93 -1
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +4 -0
  28. package/dist/index.mjs +192 -34
  29. package/dist/plugins/api/index.d.ts.map +1 -1
  30. package/dist/plugins/api/index.js +4 -1
  31. package/dist/plugins/eventEmission/index.d.ts +2 -0
  32. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  33. package/dist/plugins/eventEmission/index.js +35 -9
  34. package/dist/plugins/eventEmission/index.test.js +100 -0
  35. package/dist/schemas/Action.d.ts +2 -2
  36. package/dist/schemas/Auth.d.ts +4 -4
  37. package/dist/schemas/Field.d.ts +10 -10
  38. package/dist/sdk.test.js +121 -1
  39. package/dist/types/sdk.d.ts +3 -0
  40. package/dist/types/sdk.d.ts.map +1 -1
  41. package/dist/utils/batch-utils.d.ts +72 -0
  42. package/dist/utils/batch-utils.d.ts.map +1 -0
  43. package/dist/utils/batch-utils.js +162 -0
  44. package/dist/utils/batch-utils.test.d.ts +2 -0
  45. package/dist/utils/batch-utils.test.d.ts.map +1 -0
  46. package/dist/utils/batch-utils.test.js +476 -0
  47. package/dist/utils/retry-utils.d.ts +45 -0
  48. package/dist/utils/retry-utils.d.ts.map +1 -0
  49. package/dist/utils/retry-utils.js +51 -0
  50. package/dist/utils/retry-utils.test.d.ts +2 -0
  51. package/dist/utils/retry-utils.test.d.ts.map +1 -0
  52. package/dist/utils/retry-utils.test.js +90 -0
  53. package/dist/utils/url-utils.d.ts +19 -0
  54. package/dist/utils/url-utils.d.ts.map +1 -0
  55. package/dist/utils/url-utils.js +62 -0
  56. package/dist/utils/url-utils.test.d.ts +2 -0
  57. package/dist/utils/url-utils.test.d.ts.map +1 -0
  58. package/dist/utils/url-utils.test.js +103 -0
  59. package/package.json +2 -2
package/dist/constants.js CHANGED
@@ -4,10 +4,10 @@
4
4
  * This module contains shared constants used throughout the SDK.
5
5
  */
6
6
  /**
7
- * Maximum number of items that can be requested per page across all paginated functions
7
+ * Base URL for Zapier API endpoints
8
8
  */
9
- export const MAX_PAGE_LIMIT = 10000;
9
+ export const ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
10
10
  /**
11
- * Default telemetry endpoint for the Tracking API
11
+ * Maximum number of items that can be requested per page across all paginated functions
12
12
  */
13
- export const TRACKING_API_ENDPOINT = "https://zapier.com/api/v4/tracking/event/";
13
+ export const MAX_PAGE_LIMIT = 10000;
package/dist/index.cjs CHANGED
@@ -54,8 +54,8 @@ function isPositional(schema) {
54
54
  }
55
55
 
56
56
  // src/constants.ts
57
+ var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
57
58
  var MAX_PAGE_LIMIT = 1e4;
58
- var TRACKING_API_ENDPOINT = "https://zapier.com/api/v4/tracking/event/";
59
59
 
60
60
  // src/types/properties.ts
61
61
  var AppKeyPropertySchema = withPositional(
@@ -3101,15 +3101,28 @@ function createDebugFetch(options) {
3101
3101
  }
3102
3102
  };
3103
3103
  }
3104
+
3105
+ // src/utils/retry-utils.ts
3106
+ var MAX_CONSECUTIVE_ERRORS = 3;
3107
+ var BASE_ERROR_BACKOFF_MS = 1e3;
3108
+ var JITTER_FACTOR = 0.5;
3109
+ function calculateWaitTime(baseInterval, errorCount) {
3110
+ const jitter = Math.random() * JITTER_FACTOR * baseInterval;
3111
+ const errorBackoff = Math.min(
3112
+ BASE_ERROR_BACKOFF_MS * (errorCount / 2),
3113
+ baseInterval * 2
3114
+ // Cap error backoff at 2x the base interval
3115
+ );
3116
+ return Math.floor(baseInterval + jitter + errorBackoff);
3117
+ }
3118
+
3119
+ // src/api/polling.ts
3104
3120
  var DEFAULT_TIMEOUT_MS = 18e4;
3105
3121
  var DEFAULT_SUCCESS_STATUS = 200;
3106
3122
  var DEFAULT_PENDING_STATUS = 202;
3107
3123
  var DEFAULT_INITIAL_DELAY_MS = 50;
3108
3124
  var DEFAULT_MAX_POLLING_INTERVAL_MS = 1e4;
3109
- var MAX_CONSECUTIVE_ERRORS = 3;
3110
3125
  var MAX_TIMEOUT_BUFFER_MS = 1e4;
3111
- var BASE_ERROR_BACKOFF_MS = 1e3;
3112
- var JITTER_FACTOR = 0.5;
3113
3126
  var DEFAULT_POLLING_STAGES = [
3114
3127
  [125, 125],
3115
3128
  // Up to 125ms: poll every 125ms
@@ -3124,15 +3137,6 @@ var DEFAULT_POLLING_STAGES = [
3124
3137
  [6e4, 5e3]
3125
3138
  // Up to 60s: poll every 5s
3126
3139
  ];
3127
- var calculateWaitTime = (baseInterval, errorCount) => {
3128
- const jitter = Math.random() * JITTER_FACTOR * baseInterval;
3129
- const errorBackoff = Math.min(
3130
- BASE_ERROR_BACKOFF_MS * (errorCount / 2),
3131
- baseInterval * 2
3132
- // Cap error backoff at 2x the base interval
3133
- );
3134
- return Math.floor(baseInterval + jitter + errorBackoff);
3135
- };
3136
3140
  var processResponse = async (response, successStatus, pendingStatus, resultExtractor, errorCount) => {
3137
3141
  if (!response.ok) {
3138
3142
  return {
@@ -3340,7 +3344,10 @@ var ZapierApiClient = class {
3340
3344
  }
3341
3345
  return getTokenFromEnvOrConfig({
3342
3346
  onEvent: this.options.onEvent,
3343
- fetch: this.options.fetch
3347
+ fetch: this.options.fetch,
3348
+ baseUrl: this.options.baseUrl,
3349
+ authBaseUrl: this.options.authBaseUrl,
3350
+ authClientId: this.options.authClientId
3344
3351
  });
3345
3352
  }
3346
3353
  // Helper to handle responses
@@ -3571,23 +3578,13 @@ var ZapierApiClient = class {
3571
3578
  }
3572
3579
  };
3573
3580
  var createZapierApi = (options) => {
3574
- const {
3575
- baseUrl,
3576
- token,
3577
- getToken,
3578
- debug = false,
3579
- fetch: originalFetch = globalThis.fetch,
3580
- onEvent
3581
- } = options;
3581
+ const { debug = false, fetch: originalFetch = globalThis.fetch } = options;
3582
3582
  const debugLog = createDebugLogger(debug);
3583
3583
  const debugFetch = createDebugFetch({ originalFetch, debugLog });
3584
3584
  return new ZapierApiClient({
3585
- baseUrl,
3586
- token,
3587
- getToken,
3585
+ ...options,
3588
3586
  debug,
3589
- fetch: debugFetch,
3590
- onEvent
3587
+ fetch: debugFetch
3591
3588
  });
3592
3589
  };
3593
3590
 
@@ -3595,7 +3592,9 @@ var createZapierApi = (options) => {
3595
3592
  var apiPlugin = (params) => {
3596
3593
  const {
3597
3594
  fetch: customFetch = globalThis.fetch,
3598
- baseUrl = "https://zapier.com",
3595
+ baseUrl = ZAPIER_BASE_URL,
3596
+ authBaseUrl,
3597
+ authClientId,
3599
3598
  token,
3600
3599
  getToken,
3601
3600
  onEvent,
@@ -3603,6 +3602,8 @@ var apiPlugin = (params) => {
3603
3602
  } = params.context.options;
3604
3603
  const api = createZapierApi({
3605
3604
  baseUrl,
3605
+ authBaseUrl,
3606
+ authClientId,
3606
3607
  token,
3607
3608
  getToken,
3608
3609
  debug,
@@ -3616,6 +3617,94 @@ var apiPlugin = (params) => {
3616
3617
  }
3617
3618
  };
3618
3619
  };
3620
+ var DEFAULT_CONCURRENCY = 10;
3621
+ var BATCH_START_DELAY_MS = 25;
3622
+ var DEFAULT_BATCH_TIMEOUT_MS = 18e4;
3623
+ async function batch(tasks, options = {}) {
3624
+ const {
3625
+ concurrency = DEFAULT_CONCURRENCY,
3626
+ retry = true,
3627
+ batchDelay = BATCH_START_DELAY_MS,
3628
+ timeoutMs = DEFAULT_BATCH_TIMEOUT_MS,
3629
+ taskTimeoutMs
3630
+ } = options;
3631
+ if (concurrency <= 0) {
3632
+ throw new Error("Concurrency must be greater than 0");
3633
+ }
3634
+ if (timeoutMs <= 0) {
3635
+ throw new Error("Timeout must be greater than 0");
3636
+ }
3637
+ if (taskTimeoutMs !== void 0 && taskTimeoutMs <= 0) {
3638
+ throw new Error("Task timeout must be greater than 0");
3639
+ }
3640
+ if (tasks.length === 0) {
3641
+ return [];
3642
+ }
3643
+ const startTime = Date.now();
3644
+ const results = new Array(tasks.length);
3645
+ const taskQueue = tasks.map((task, index) => ({
3646
+ index,
3647
+ task,
3648
+ errorCount: 0
3649
+ }));
3650
+ async function executeTask(taskState) {
3651
+ const { index, task, errorCount } = taskState;
3652
+ try {
3653
+ let result;
3654
+ if (taskTimeoutMs !== void 0) {
3655
+ const timeoutPromise = promises.setTimeout(taskTimeoutMs).then(() => {
3656
+ throw new ZapierTimeoutError(
3657
+ `Task timed out after ${taskTimeoutMs}ms`
3658
+ );
3659
+ });
3660
+ result = await Promise.race([task(), timeoutPromise]);
3661
+ } else {
3662
+ result = await task();
3663
+ }
3664
+ results[index] = { status: "fulfilled", value: result };
3665
+ } catch (error) {
3666
+ const newErrorCount = errorCount + 1;
3667
+ const isTimeout = error instanceof ZapierTimeoutError;
3668
+ if (retry && !isTimeout && newErrorCount < MAX_CONSECUTIVE_ERRORS) {
3669
+ const waitTime = calculateWaitTime(1e3, newErrorCount);
3670
+ await promises.setTimeout(waitTime);
3671
+ taskQueue.push({
3672
+ index,
3673
+ task,
3674
+ errorCount: newErrorCount
3675
+ });
3676
+ } else {
3677
+ results[index] = { status: "rejected", reason: error };
3678
+ }
3679
+ }
3680
+ }
3681
+ async function worker() {
3682
+ while (taskQueue.length > 0) {
3683
+ const elapsedTime = Date.now() - startTime;
3684
+ if (elapsedTime >= timeoutMs) {
3685
+ throw new ZapierTimeoutError(
3686
+ `Batch operation timed out after ${Math.floor(elapsedTime / 1e3)}s. ${taskQueue.length} task(s) not completed.`
3687
+ );
3688
+ }
3689
+ const taskState = taskQueue.shift();
3690
+ if (!taskState) break;
3691
+ await executeTask(taskState);
3692
+ if (taskQueue.length > 0 && batchDelay > 0) {
3693
+ await promises.setTimeout(batchDelay);
3694
+ }
3695
+ }
3696
+ }
3697
+ const workerCount = Math.min(concurrency, tasks.length);
3698
+ const workers = [];
3699
+ for (let i = 0; i < workerCount; i++) {
3700
+ workers.push(worker());
3701
+ if (i < workerCount - 1 && batchDelay > 0) {
3702
+ await promises.setTimeout(batchDelay / 10);
3703
+ }
3704
+ }
3705
+ await Promise.all(workers);
3706
+ return results;
3707
+ }
3619
3708
 
3620
3709
  // src/plugins/registry/index.ts
3621
3710
  var registryPlugin = ({ sdk, context }) => {
@@ -4000,7 +4089,7 @@ function getCpuTime() {
4000
4089
 
4001
4090
  // package.json
4002
4091
  var package_default = {
4003
- version: "0.13.7"};
4092
+ version: "0.13.9"};
4004
4093
 
4005
4094
  // src/plugins/eventEmission/builders.ts
4006
4095
  function createBaseEvent(context = {}) {
@@ -4070,17 +4159,80 @@ function buildErrorEventWithContext(data, context = {}) {
4070
4159
  };
4071
4160
  }
4072
4161
 
4162
+ // src/utils/url-utils.ts
4163
+ function getZapierBaseUrl(baseUrl) {
4164
+ if (!baseUrl) {
4165
+ return void 0;
4166
+ }
4167
+ try {
4168
+ const url = new URL(baseUrl);
4169
+ const hostname = url.hostname;
4170
+ const hostParts = hostname.split(".");
4171
+ if (hostParts.length < 2) {
4172
+ return void 0;
4173
+ }
4174
+ const hasZapierPart = hostParts.some(
4175
+ (part) => part === "zapier" || part.startsWith("zapier-")
4176
+ );
4177
+ if (!hasZapierPart) {
4178
+ return void 0;
4179
+ }
4180
+ const rootDomain = hostParts.slice(-2).join(".");
4181
+ return `${url.protocol}//${rootDomain}`;
4182
+ } catch {
4183
+ return void 0;
4184
+ }
4185
+ }
4186
+ function getTrackingBaseUrl({
4187
+ trackingBaseUrl,
4188
+ baseUrl
4189
+ }) {
4190
+ if (trackingBaseUrl) {
4191
+ return trackingBaseUrl;
4192
+ }
4193
+ if (process.env.ZAPIER_TRACKING_BASE_URL) {
4194
+ return process.env.ZAPIER_TRACKING_BASE_URL;
4195
+ }
4196
+ if (baseUrl) {
4197
+ const zapierBaseUrl = getZapierBaseUrl(baseUrl);
4198
+ if (zapierBaseUrl) {
4199
+ return zapierBaseUrl;
4200
+ }
4201
+ }
4202
+ if (baseUrl) {
4203
+ return baseUrl;
4204
+ }
4205
+ return ZAPIER_BASE_URL;
4206
+ }
4207
+
4073
4208
  // src/plugins/eventEmission/index.ts
4074
4209
  var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
4075
4210
  var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
4211
+ var transportStates = /* @__PURE__ */ new WeakMap();
4076
4212
  async function silentEmit(transport, subject, event) {
4077
4213
  try {
4078
- transport.emit(subject, event).catch(() => {
4214
+ let state = transportStates.get(transport);
4215
+ if (!state) {
4216
+ state = { hasWorked: false, hasLoggedFailure: false };
4217
+ transportStates.set(transport, state);
4218
+ }
4219
+ transport.emit(subject, event).then(() => {
4220
+ state.hasWorked = true;
4221
+ }).catch((error) => {
4222
+ if (!state.hasWorked && !state.hasLoggedFailure) {
4223
+ state.hasLoggedFailure = true;
4224
+ console.warn(
4225
+ `[zapier-sdk] Tracking failed: ${error.message || "Unknown error"}`
4226
+ );
4227
+ console.warn(
4228
+ `[zapier-sdk] Hint: Set trackingBaseUrl parameter or ZAPIER_TRACKING_BASE_URL environment variable if using custom domains`
4229
+ );
4230
+ }
4079
4231
  });
4080
4232
  } catch {
4081
4233
  }
4082
4234
  }
4083
- function getTransportConfig() {
4235
+ function getTransportConfig(options) {
4084
4236
  const envTransport = process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT;
4085
4237
  if (envTransport === "noop" || envTransport === "disabled") {
4086
4238
  return { type: "noop" };
@@ -4088,14 +4240,20 @@ function getTransportConfig() {
4088
4240
  if (envTransport === "console") {
4089
4241
  return { type: "console" };
4090
4242
  }
4091
- const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT || TRACKING_API_ENDPOINT;
4243
+ const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT || `${getTrackingBaseUrl({
4244
+ trackingBaseUrl: options?.trackingBaseUrl,
4245
+ baseUrl: options?.baseUrl
4246
+ })}/api/v4/tracking/event/`;
4092
4247
  return {
4093
4248
  type: "http",
4094
4249
  endpoint
4095
4250
  };
4096
4251
  }
4097
4252
  var eventEmissionPlugin = ({ context }) => {
4098
- const defaultTransport = getTransportConfig();
4253
+ const defaultTransport = getTransportConfig({
4254
+ trackingBaseUrl: context.options.trackingBaseUrl,
4255
+ baseUrl: context.options.baseUrl
4256
+ });
4099
4257
  const config = {
4100
4258
  enabled: context.options.eventEmission?.enabled ?? true,
4101
4259
  transport: (
@@ -4307,11 +4465,13 @@ exports.DEFAULT_CONFIG_PATH = DEFAULT_CONFIG_PATH;
4307
4465
  exports.DebugPropertySchema = DebugPropertySchema;
4308
4466
  exports.InputsPropertySchema = InputsPropertySchema;
4309
4467
  exports.LimitPropertySchema = LimitPropertySchema;
4468
+ exports.MAX_PAGE_LIMIT = MAX_PAGE_LIMIT;
4310
4469
  exports.OffsetPropertySchema = OffsetPropertySchema;
4311
4470
  exports.OutputPropertySchema = OutputPropertySchema;
4312
4471
  exports.ParamsPropertySchema = ParamsPropertySchema;
4313
4472
  exports.RelayFetchSchema = RelayFetchSchema;
4314
4473
  exports.RelayRequestSchema = RelayRequestSchema;
4474
+ exports.ZAPIER_BASE_URL = ZAPIER_BASE_URL;
4315
4475
  exports.ZapierActionError = ZapierActionError;
4316
4476
  exports.ZapierApiError = ZapierApiError;
4317
4477
  exports.ZapierAppNotFoundError = ZapierAppNotFoundError;
@@ -4331,6 +4491,7 @@ exports.appKeyResolver = appKeyResolver;
4331
4491
  exports.appsPlugin = appsPlugin;
4332
4492
  exports.authenticationIdGenericResolver = authenticationIdGenericResolver;
4333
4493
  exports.authenticationIdResolver = authenticationIdResolver;
4494
+ exports.batch = batch;
4334
4495
  exports.buildApplicationLifecycleEvent = buildApplicationLifecycleEvent;
4335
4496
  exports.buildErrorEvent = buildErrorEvent;
4336
4497
  exports.buildErrorEventWithContext = buildErrorEventWithContext;
package/dist/index.d.mts CHANGED
@@ -2268,6 +2268,9 @@ interface BaseSdkOptions {
2268
2268
  onEvent?: EventCallback;
2269
2269
  fetch?: typeof fetch;
2270
2270
  baseUrl?: string;
2271
+ authBaseUrl?: string;
2272
+ authClientId?: string;
2273
+ trackingBaseUrl?: string;
2271
2274
  debug?: boolean;
2272
2275
  manifestPath?: string;
2273
2276
  manifest?: Manifest;
@@ -3130,6 +3133,78 @@ declare function toTitleCase(input: string): string;
3130
3133
  */
3131
3134
  declare function toSnakeCase(input: string): string;
3132
3135
 
3136
+ /**
3137
+ * Batch Operation Utilities
3138
+ *
3139
+ * This module provides utilities for executing multiple async operations
3140
+ * with concurrency control and retry logic.
3141
+ */
3142
+ /**
3143
+ * Options for batch execution
3144
+ */
3145
+ interface BatchOptions {
3146
+ /**
3147
+ * Maximum number of concurrent operations (default: 10)
3148
+ * Lower values are more "polite" but slower
3149
+ * Higher values are faster but risk rate limits
3150
+ */
3151
+ concurrency?: number;
3152
+ /**
3153
+ * Whether to retry failed operations (default: true)
3154
+ * When enabled, each operation gets up to MAX_CONSECUTIVE_ERRORS retries
3155
+ */
3156
+ retry?: boolean;
3157
+ /**
3158
+ * Delay in milliseconds between starting batches (default: 100ms)
3159
+ * Adds a small delay between concurrent batches to avoid burst patterns
3160
+ */
3161
+ batchDelay?: number;
3162
+ /**
3163
+ * Overall timeout for the entire batch operation in milliseconds (default: 180000ms / 3 minutes)
3164
+ * When exceeded, throws ZapierTimeoutError and stops processing remaining tasks
3165
+ */
3166
+ timeoutMs?: number;
3167
+ /**
3168
+ * Timeout for individual tasks in milliseconds (default: none)
3169
+ * When set, each task will be cancelled if it exceeds this duration
3170
+ * Tasks that timeout will be marked as rejected in the results
3171
+ */
3172
+ taskTimeoutMs?: number;
3173
+ }
3174
+ /**
3175
+ * Execute multiple async operations with concurrency limiting and retry logic
3176
+ *
3177
+ * This prevents overwhelming APIs by:
3178
+ * 1. Limiting concurrent operations (worker pool pattern)
3179
+ * 2. Adding small delays between batches to avoid burst detection
3180
+ * 3. Retrying failed operations with exponential backoff
3181
+ *
3182
+ * Problem Solved:
3183
+ * - Rate limit prevention: Steady stream instead of burst requests
3184
+ * - Connection pool management: Stays within browser/Node limits (~6-8 per domain)
3185
+ * - Resilience: Transient failures are retried automatically
3186
+ * - Observability: Returns detailed success/failure info for each operation
3187
+ *
3188
+ * Example Usage:
3189
+ * ```typescript
3190
+ * // Instead of Promise.allSettled (fires all at once):
3191
+ * const results = await Promise.allSettled(
3192
+ * actions.map(a => sdk.listInputFields(a))
3193
+ * );
3194
+ *
3195
+ * // Use batch (controlled concurrency):
3196
+ * const results = await batch(
3197
+ * actions.map(a => () => sdk.listInputFields(a)),
3198
+ * { concurrency: 10, retry: true }
3199
+ * );
3200
+ * ```
3201
+ *
3202
+ * @param tasks - Array of functions that return promises (NOT promises themselves!)
3203
+ * @param options - Configuration for concurrency and retry behavior
3204
+ * @returns Promise resolving to array of settled results (same as Promise.allSettled)
3205
+ */
3206
+ declare function batch<T>(tasks: (() => Promise<T>)[], options?: BatchOptions): Promise<PromiseSettledResult<T>[]>;
3207
+
3133
3208
  declare const appKeyResolver: StaticResolver;
3134
3209
 
3135
3210
  interface ActionTypeItem {
@@ -3191,6 +3266,9 @@ declare const inputFieldKeyResolver: DynamicResolver<InputFieldItem$1, {
3191
3266
  interface AuthOptions {
3192
3267
  onEvent?: EventCallback;
3193
3268
  fetch?: typeof globalThis.fetch;
3269
+ baseUrl?: string;
3270
+ authBaseUrl?: string;
3271
+ authClientId?: string;
3194
3272
  }
3195
3273
  /**
3196
3274
  * Gets the ZAPIER_TOKEN from environment variables.
@@ -3213,6 +3291,20 @@ declare function getTokenFromCliLogin(options?: AuthOptions): Promise<string | u
3213
3291
  */
3214
3292
  declare function getTokenFromEnvOrConfig(options?: AuthOptions): Promise<string | undefined>;
3215
3293
 
3294
+ /**
3295
+ * SDK Constants
3296
+ *
3297
+ * This module contains shared constants used throughout the SDK.
3298
+ */
3299
+ /**
3300
+ * Base URL for Zapier API endpoints
3301
+ */
3302
+ declare const ZAPIER_BASE_URL: string;
3303
+ /**
3304
+ * Maximum number of items that can be requested per page across all paginated functions
3305
+ */
3306
+ declare const MAX_PAGE_LIMIT = 10000;
3307
+
3216
3308
  interface ZapierSdkOptions extends BaseSdkOptions {
3217
3309
  }
3218
3310
  declare function createSdk<TCurrentSdk = {}, TCurrentContext extends {
@@ -3326,4 +3418,4 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
3326
3418
  }>;
3327
3419
  declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
3328
3420
 
3329
- export { type Action, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthOptions, type Authentication, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type AuthenticationItem, type AuthenticationsResponse, type BaseEvent, type Choice, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindUniqueAuthenticationPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type UpdateManifestEntryOptions, type UserProfile, type UserProfileItem, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, 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, runActionPlugin, toSnakeCase, toTitleCase };
3421
+ export { type Action, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthOptions, type Authentication, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type AuthenticationItem, type AuthenticationsResponse, type BaseEvent, type BatchOptions, type Choice, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindUniqueAuthenticationPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type UpdateManifestEntryOptions, type UserProfile, type UserProfileItem, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, 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, runActionPlugin, toSnakeCase, toTitleCase };
package/dist/index.d.ts CHANGED
@@ -23,8 +23,11 @@ export { isPositional, PositionalMetadata } from "./utils/schema-utils";
23
23
  export { createFunction } from "./utils/function-utils";
24
24
  export type { FormattedItem, FormatMetadata } from "./utils/schema-utils";
25
25
  export { toSnakeCase, toTitleCase } from "./utils/string-utils";
26
+ export { batch } from "./utils/batch-utils";
27
+ export type { BatchOptions } from "./utils/batch-utils";
26
28
  export * from "./resolvers";
27
29
  export * from "./auth";
30
+ export * from "./constants";
28
31
  export { RelayRequestSchema, RelayFetchSchema, } from "./plugins/request/schemas";
29
32
  export { createZapierSdk, createZapierSdkWithoutRegistry, createSdk, ZapierSdkOptions, } from "./sdk";
30
33
  export type { FunctionRegistryEntry } from "./types/sdk";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAG9B,YAAY,EACV,MAAM,EACN,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAA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d,GAAG,GACJ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,IAAI,EACJ,aAAa,EACb,cAAc,EACd,UAAU,EACV,8BAA8B,EAC9B,0BAA0B,EAC1B,eAAe,EACf,eAAe,GAChB,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -24,10 +24,14 @@ export { isPositional } from "./utils/schema-utils";
24
24
  export { createFunction } from "./utils/function-utils";
25
25
  // Export string utilities
26
26
  export { toSnakeCase, toTitleCase } from "./utils/string-utils";
27
+ // Export batch utilities
28
+ export { batch } from "./utils/batch-utils";
27
29
  // Export resolver utilities for CLI
28
30
  export * from "./resolvers";
29
31
  // Export auth utilities for CLI use
30
32
  export * from "./auth";
33
+ // Export constants
34
+ export * from "./constants";
31
35
  // All functions now available through the plugin system via createZapierSdk()
32
36
  // Export plugin schemas for external use
33
37
  export { RelayRequestSchema, RelayFetchSchema, } from "./plugins/request/schemas";