@zapier/zapier-sdk 0.122.2 → 0.124.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.
@@ -1242,15 +1242,12 @@ var { logDeprecation, resetDeprecationWarnings } = kitcore.createDeprecationLogg
1242
1242
  var { logStabilityNotice, resetStabilityNotices } = kitcore.createStabilityNoticeLogger("zapier-sdk");
1243
1243
 
1244
1244
  // src/utils/url-utils.ts
1245
- function withSearchParams({
1246
- url,
1247
- searchParams
1248
- }) {
1249
- const result = new URL(url);
1250
- for (const [key, value] of Object.entries(searchParams ?? {})) {
1251
- result.searchParams.set(key, value);
1245
+ function validateSdkPath(path) {
1246
+ if (!path.startsWith("/") || path.startsWith("//")) {
1247
+ throw new ZapierValidationError(
1248
+ `fetch expects a path starting with a single '/', got: ${path}`
1249
+ );
1252
1250
  }
1253
- return result.toString();
1254
1251
  }
1255
1252
  function getZapierBaseUrl(baseUrl) {
1256
1253
  if (!baseUrl) {
@@ -2070,58 +2067,6 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
2070
2067
  }
2071
2068
  }
2072
2069
  }
2073
-
2074
- // src/api/deprecation.ts
2075
- var DEPRECATION_MESSAGE_HEADER = "zapier-sdk-deprecation-message";
2076
- var DEPRECATION_ID_HEADER = "zapier-sdk-deprecation-id";
2077
- var DEPRECATION_NOTICE_EVENT = "api:deprecation_notice";
2078
- var displayedNoticeIds = /* @__PURE__ */ new Set();
2079
- function handleDeprecationNotice({
2080
- response,
2081
- canSendDeprecationMessaging,
2082
- onEvent
2083
- }) {
2084
- try {
2085
- sniffDeprecationNotice({ response, canSendDeprecationMessaging, onEvent });
2086
- } catch {
2087
- }
2088
- }
2089
- function sniffDeprecationNotice({
2090
- response,
2091
- canSendDeprecationMessaging,
2092
- onEvent
2093
- }) {
2094
- if (!canSendDeprecationMessaging) return;
2095
- const message = response.headers?.get(DEPRECATION_MESSAGE_HEADER);
2096
- if (!message) return;
2097
- const id = response.headers.get(DEPRECATION_ID_HEADER) ?? message;
2098
- if (!displayedNoticeIds.has(id)) {
2099
- displayedNoticeIds.add(id);
2100
- console.warn(`[zapier-sdk] Deprecation: ${message}`);
2101
- }
2102
- if (onEvent) {
2103
- const payload = { id, message };
2104
- const deprecation = parseDeprecationDate(
2105
- response.headers.get("deprecation")
2106
- );
2107
- if (deprecation !== void 0) payload.deprecation = deprecation;
2108
- const maybePromise = onEvent({
2109
- type: DEPRECATION_NOTICE_EVENT,
2110
- payload: { ...payload },
2111
- timestamp: Date.now()
2112
- });
2113
- if (isPromiseLike(maybePromise)) {
2114
- void Promise.resolve(maybePromise).catch(() => {
2115
- });
2116
- }
2117
- }
2118
- }
2119
- function parseDeprecationDate(value) {
2120
- if (!value) return void 0;
2121
- const match = /^@(-?\d+)$/.exec(value.trim());
2122
- if (!match) return void 0;
2123
- return Number(match[1]) * 1e3;
2124
- }
2125
2070
  var RELAY_ERROR_HEADER = "x-relay-error";
2126
2071
  var RELAY_TIMEOUT_HEADER = "x-relay-extended-timeout";
2127
2072
  var SDK_CORRELATION_HEADER = "zapier-correlation-id";
@@ -2452,36 +2397,14 @@ function buildRouteOverrideMap({
2452
2397
  }
2453
2398
  return routeOverrideMap;
2454
2399
  }
2455
- function collectRouteOverrideSources({
2456
- routingOptions,
2457
- environment,
2458
- routingConfig: routingConfig2
2459
- }) {
2460
- try {
2461
- const optionEntries = routingOptions?.routeOverrideEntries ?? [];
2462
- const environmentEntries = readEnvironmentRouteOverrideEntries({
2463
- environment,
2464
- routingConfig: routingConfig2
2465
- });
2466
- if (optionEntries.length === 0 && environmentEntries.length === 0) {
2467
- return void 0;
2468
- }
2469
- return { optionEntries, environmentEntries };
2470
- } catch (error) {
2471
- if (isZapierError(error) && error.code === "ZAPIER_CONFIGURATION_ERROR") {
2472
- throw error;
2473
- }
2474
- return void 0;
2475
- }
2476
- }
2477
2400
  function findRouteOverrideMatch({
2478
2401
  path,
2479
- routeOverrideMap,
2402
+ routeOverrideEntries,
2480
2403
  routingConfig: routingConfig2
2481
2404
  }) {
2482
2405
  let bestMatch;
2483
2406
  const { pathname } = splitPathReference({ path });
2484
- for (const override of routeOverrideMap.values()) {
2407
+ for (const override of routeOverrideEntries) {
2485
2408
  const { route } = override;
2486
2409
  for (const candidate of getRouteCandidates({
2487
2410
  route,
@@ -2525,16 +2448,18 @@ function deriveDirectPath({
2525
2448
  if (!pathPrefix) {
2526
2449
  return path;
2527
2450
  }
2528
- const remainingPath = path.slice(matchedPrefix.length) || "/";
2451
+ const { pathname, search, hash } = splitPathReference({ path });
2452
+ const remainingPath = pathname.slice(matchedPrefix.length) || "/";
2529
2453
  const override = routeConfig.override;
2530
2454
  const pathPrefixMode = override?.enabled === false ? "strip" : override?.pathPrefixMode ?? "strip";
2531
- return pathPrefixMode === "preserve" ? `${pathPrefix}${remainingPath}` : remainingPath;
2455
+ const directPathname = pathPrefixMode === "preserve" ? `${pathPrefix}${remainingPath}` : remainingPath;
2456
+ return `${directPathname}${search}${hash}`;
2532
2457
  }
2533
2458
  function readEnvironmentRouteOverrideEntries({
2534
- environment,
2535
2459
  routingConfig: routingConfig2
2536
2460
  }) {
2537
2461
  const entries = [];
2462
+ const environment = globalThis.process?.env;
2538
2463
  if (!environment) {
2539
2464
  return entries;
2540
2465
  }
@@ -2798,33 +2723,52 @@ function parseRoutingOptions({
2798
2723
  });
2799
2724
  }
2800
2725
  }
2726
+ function withEnvironmentRouteOverrides({
2727
+ routingOptions
2728
+ }) {
2729
+ let environmentEntries;
2730
+ try {
2731
+ environmentEntries = readEnvironmentRouteOverrideEntries({ routingConfig });
2732
+ } catch (error) {
2733
+ if (isZapierError(error) && error.code === "ZAPIER_CONFIGURATION_ERROR") {
2734
+ throw error;
2735
+ }
2736
+ return routingOptions;
2737
+ }
2738
+ if (environmentEntries.length === 0) {
2739
+ return routingOptions;
2740
+ }
2741
+ const routeOverrideMap = buildRouteOverrideMap({
2742
+ environmentEntries,
2743
+ optionEntries: routingOptions.routeOverrideEntries
2744
+ });
2745
+ return { routeOverrideEntries: [...routeOverrideMap.values()] };
2746
+ }
2801
2747
  function resolveRoute({
2802
2748
  path,
2803
2749
  baseUrl,
2804
2750
  routingOptions = { routeOverrideEntries: [] },
2805
- environment,
2806
2751
  debugLog
2807
2752
  }) {
2808
- const overrideSources = collectRouteOverrideSources({
2809
- routingOptions,
2810
- environment,
2811
- routingConfig
2812
- });
2813
- if (!overrideSources) {
2814
- return resolveDefaultRoute({ path, baseUrl });
2815
- }
2816
- const routeOverrideMap = buildRouteOverrideMap(overrideSources);
2817
2753
  const overrideMatch = findRouteOverrideMatch({
2818
2754
  path,
2819
- routeOverrideMap,
2755
+ routeOverrideEntries: routingOptions.routeOverrideEntries,
2820
2756
  routingConfig
2821
2757
  });
2822
2758
  if (overrideMatch) {
2823
- const resolved = resolveOverrideRoute({ overrideMatch, path });
2824
- logRouteOverride({ path, resolved, overrideMatch, debugLog });
2759
+ const resolved2 = resolveOverrideRoute({ overrideMatch, path });
2760
+ logRouteOverride({ path, resolved: resolved2, overrideMatch, debugLog });
2761
+ return resolved2;
2762
+ }
2763
+ const { pathname, search, hash } = splitPathReference({ path });
2764
+ const resolved = resolveDefaultRoute({ path: pathname, baseUrl });
2765
+ if (!search && !hash) {
2825
2766
  return resolved;
2826
2767
  }
2827
- return resolveDefaultRoute({ path, baseUrl });
2768
+ const url = new URL(resolved.url);
2769
+ url.search = search;
2770
+ url.hash = hash;
2771
+ return { ...resolved, url };
2828
2772
  }
2829
2773
  function logRouteOverride({
2830
2774
  path,
@@ -2843,7 +2787,7 @@ function logRouteOverride({
2843
2787
  }
2844
2788
 
2845
2789
  // src/sdk-version.ts
2846
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.122.2" : void 0) || "unknown";
2790
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.124.0" : void 0) || "unknown";
2847
2791
 
2848
2792
  // src/utils/open-url.ts
2849
2793
  var nodePrefix = "node:";
@@ -2970,24 +2914,37 @@ var PollApprovalResponseSchema = zod.z.object({
2970
2914
  approval_url: zod.z.string().optional()
2971
2915
  });
2972
2916
  var APPROVAL_MAX_POLLING_INTERVAL_MILLISECONDS = 5e3;
2973
- function validateSdkPath(path) {
2974
- if (!path.startsWith("/") || path.startsWith("//")) {
2975
- throw new ZapierValidationError(
2976
- `fetch expects a path starting with a single '/', got: ${path}`
2977
- );
2917
+ function mergeSearchParams({
2918
+ path,
2919
+ searchParams
2920
+ }) {
2921
+ const { pathname, search, hash } = splitPathReference({ path });
2922
+ if (!searchParams || Object.keys(searchParams).length === 0) {
2923
+ return `${pathname}${search}${hash}`;
2978
2924
  }
2925
+ const query = new URLSearchParams(search);
2926
+ for (const [key, value] of Object.entries(searchParams)) {
2927
+ query.set(key, value);
2928
+ }
2929
+ const queryString = query.toString();
2930
+ return `${pathname}${queryString ? `?${queryString}` : ""}${hash}`;
2979
2931
  }
2980
2932
  var ZapierApiClient = class {
2981
2933
  constructor(options) {
2982
2934
  this.options = options;
2983
2935
  /**
2984
- * Perform a request against an already-resolved URL.
2936
+ * Perform a request given a destination: either an already
2937
+ * resolved absolute URL, or a Zapier logical path (plus its query string,
2938
+ * since there is no separate `searchParams` slot once a request enters the
2939
+ * pipeline). `zapierRouteHttpRequestPlugin`'s `prepareHttpRequest` wrap
2940
+ * resolves a logical path against `pathConfig` before dispatch; an
2941
+ * absolute URL passes through that wrap untouched.
2985
2942
  *
2986
2943
  * Does auth and header merging, and converts a terminal 429 into
2987
2944
  * `ZapierRateLimitError` — the cross-cutting concerns that every
2988
2945
  * Zapier-bound HTTP call needs and that the transport does not own. Callers
2989
2946
  * that have a path (e.g. `/relay/...`) should use `rawFetch` instead, which
2990
- * does path → URL resolution and delegates here.
2947
+ * merges `searchParams` into the path and delegates here.
2991
2948
  *
2992
2949
  * Exposed as a separate helper so call sites with a server-supplied
2993
2950
  * absolute URL (e.g. an approval poll URL) can still share the same
@@ -3103,10 +3060,13 @@ var ZapierApiClient = class {
3103
3060
  */
3104
3061
  this.rawFetch = async (path, init) => {
3105
3062
  validateSdkPath(path);
3106
- const { url, resolvedRoute } = this.buildUrl(path, init?.searchParams);
3063
+ const { url, resolvedRoute, requestPath } = this.buildUrl(
3064
+ path,
3065
+ init?.searchParams
3066
+ );
3107
3067
  return this.withSemaphore(
3108
3068
  { url, method: init?.method ?? "GET", signal: init?.signal },
3109
- () => this.rawFetchUrl(url, init, resolvedRoute)
3069
+ () => this.rawFetchUrl(requestPath, init, resolvedRoute)
3110
3070
  );
3111
3071
  };
3112
3072
  this.runApprovalFetchLoop = async ({
@@ -3211,10 +3171,6 @@ var ZapierApiClient = class {
3211
3171
  this.fetch = async (path, init) => {
3212
3172
  validateSdkPath(path);
3213
3173
  const maxRetries = this.options.maxApprovalRetries ?? DEFAULT_MAX_APPROVAL_RETRIES;
3214
- const { canSendDeprecationMessaging } = this.buildUrl(
3215
- path,
3216
- init?.searchParams
3217
- );
3218
3174
  const approvalMode = this.options.approvalMode ?? getZapierApprovalMode() ?? getZapierDefaultApprovalMode();
3219
3175
  const approvalContext = init?.approvalContext;
3220
3176
  const { response, approvalRoundError } = await this.runApprovalFetchLoop({
@@ -3224,11 +3180,6 @@ var ZapierApiClient = class {
3224
3180
  approvalMode,
3225
3181
  approvalContext
3226
3182
  });
3227
- handleDeprecationNotice({
3228
- response,
3229
- canSendDeprecationMessaging,
3230
- onEvent: this.options.onEvent
3231
- });
3232
3183
  if (response.status !== 403) {
3233
3184
  return response;
3234
3185
  }
@@ -3537,23 +3488,28 @@ var ZapierApiClient = class {
3537
3488
  return { message: fallbackMessage };
3538
3489
  }
3539
3490
  }
3540
- // Apply any special routing logic for configured paths.
3541
- applyPathConfiguration(path) {
3542
- return resolveRoute({
3543
- path,
3491
+ /**
3492
+ * Build the path `rawFetch` hands the pipeline, alongside the route it
3493
+ * resolves to. The resolution is the client's own: it supplies the
3494
+ * auth-header name, the Relay header transforms, and the URL the
3495
+ * concurrency events report. The transport resolves the same path
3496
+ * independently to pick the destination, so both go through `resolveRoute`
3497
+ * with the same overrides — a path that routed one way here and another way
3498
+ * there would authenticate against the wrong host.
3499
+ *
3500
+ * No `debugLog`: the transport's resolution logs the override decision.
3501
+ * Passing one here would print every route override twice.
3502
+ */
3503
+ buildUrl(path, searchParams) {
3504
+ const requestPath = mergeSearchParams({ path, searchParams });
3505
+ const resolvedRoute = resolveRoute({
3506
+ path: requestPath,
3544
3507
  baseUrl: this.options.baseUrl,
3545
- routingOptions: this.options.routingOptions,
3546
- environment: globalThis.process?.env,
3547
- debugLog: this.options.debugLog
3508
+ routingOptions: withEnvironmentRouteOverrides({
3509
+ routingOptions: this.options.routingOptions
3510
+ })
3548
3511
  });
3549
- }
3550
- buildUrl(path, searchParams) {
3551
- const resolvedRoute = this.applyPathConfiguration(path);
3552
- return {
3553
- url: withSearchParams({ url: resolvedRoute.url, searchParams }),
3554
- resolvedRoute,
3555
- canSendDeprecationMessaging: resolvedRoute.canSendDeprecationMessaging
3556
- };
3512
+ return { url: resolvedRoute.url.toString(), resolvedRoute, requestPath };
3557
3513
  }
3558
3514
  // Helper to build headers
3559
3515
  async buildHeaders(options = {}, pathConfig2) {
@@ -4193,9 +4149,124 @@ function resolveApprovalTimeoutMilliseconds({
4193
4149
  }
4194
4150
  return sdkOptions?.approvalTimeoutMs;
4195
4151
  }
4196
- var SDK_OPTIONS_ID = "zapier/sdkOptions";
4197
- var sdkOptionsPluginRef = kitcore.declareOptionalProperty({
4198
- id: SDK_OPTIONS_ID
4152
+ var sdkOptionsPluginRef = kitcore.declareOptionalProperty({ id: "zapier/sdkOptions" });
4153
+ var SDK_OPTIONS_ID = sdkOptionsPluginRef.id;
4154
+
4155
+ // src/api/deprecation.ts
4156
+ var DEPRECATION_MESSAGE_HEADER = "zapier-sdk-deprecation-message";
4157
+ var DEPRECATION_ID_HEADER = "zapier-sdk-deprecation-id";
4158
+ var DEPRECATION_NOTICE_EVENT = "api:deprecation_notice";
4159
+ var displayedNoticeIds = /* @__PURE__ */ new Set();
4160
+ function handleDeprecationNotice({
4161
+ response,
4162
+ canSendDeprecationMessaging,
4163
+ onEvent
4164
+ }) {
4165
+ try {
4166
+ sniffDeprecationNotice({ response, canSendDeprecationMessaging, onEvent });
4167
+ } catch {
4168
+ }
4169
+ }
4170
+ function sniffDeprecationNotice({
4171
+ response,
4172
+ canSendDeprecationMessaging,
4173
+ onEvent
4174
+ }) {
4175
+ if (!canSendDeprecationMessaging) return;
4176
+ const message = response.headers?.get(DEPRECATION_MESSAGE_HEADER);
4177
+ if (!message) return;
4178
+ const id = response.headers.get(DEPRECATION_ID_HEADER) ?? message;
4179
+ if (!displayedNoticeIds.has(id)) {
4180
+ displayedNoticeIds.add(id);
4181
+ console.warn(`[zapier-sdk] Deprecation: ${message}`);
4182
+ }
4183
+ if (onEvent) {
4184
+ const payload = { id, message };
4185
+ const deprecation = parseDeprecationDate(
4186
+ response.headers.get("deprecation")
4187
+ );
4188
+ if (deprecation !== void 0) payload.deprecation = deprecation;
4189
+ const maybePromise = onEvent({
4190
+ type: DEPRECATION_NOTICE_EVENT,
4191
+ payload: { ...payload },
4192
+ timestamp: Date.now()
4193
+ });
4194
+ if (isPromiseLike(maybePromise)) {
4195
+ void Promise.resolve(maybePromise).catch(() => {
4196
+ });
4197
+ }
4198
+ }
4199
+ }
4200
+ function parseDeprecationDate(value) {
4201
+ if (!value) return void 0;
4202
+ const match = /^@(-?\d+)$/.exec(value.trim());
4203
+ if (!match) return void 0;
4204
+ return Number(match[1]) * 1e3;
4205
+ }
4206
+ var ZAPIER_RESOLVED_ROUTE_STATE = Symbol("zapierResolvedRoute");
4207
+ function isAbsoluteUrl(url) {
4208
+ try {
4209
+ new URL(url);
4210
+ return true;
4211
+ } catch {
4212
+ return false;
4213
+ }
4214
+ }
4215
+ var zapierRouteHttpRequestPlugin = kitcore.defineHook({
4216
+ name: "routeHttpRequest",
4217
+ namespace: "zapier",
4218
+ imports: [kitcore.prepareHttpRequestPlugin, sdkOptionsPluginRef],
4219
+ setup: ({ imports }) => {
4220
+ const sdkOptions = imports.sdkOptions ?? {};
4221
+ return {
4222
+ baseUrl: sdkOptions.baseUrl ?? ZAPIER_BASE_URL,
4223
+ routingOptions: parseRoutingOptions({ options: sdkOptions }),
4224
+ debugLog: createDebugLogger(sdkOptions.debug ?? false)
4225
+ };
4226
+ },
4227
+ wrap: {
4228
+ prepareHttpRequest: ({ input, state, next }) => {
4229
+ const { url } = input.request;
4230
+ if (isAbsoluteUrl(url)) {
4231
+ return next(input);
4232
+ }
4233
+ validateSdkPath(url);
4234
+ const resolvedRoute = resolveRoute({
4235
+ path: url,
4236
+ baseUrl: state.baseUrl,
4237
+ routingOptions: withEnvironmentRouteOverrides({
4238
+ routingOptions: state.routingOptions
4239
+ }),
4240
+ debugLog: state.debugLog
4241
+ });
4242
+ input.attempt.state[ZAPIER_RESOLVED_ROUTE_STATE] = resolvedRoute;
4243
+ return next({
4244
+ ...input,
4245
+ request: { ...input.request, url: resolvedRoute.url.toString() }
4246
+ });
4247
+ }
4248
+ }
4249
+ });
4250
+
4251
+ // src/plugins/transport/deprecation.ts
4252
+ var zapierDeprecationHttpResponsePlugin = kitcore.defineHook({
4253
+ name: "deprecationHttpResponse",
4254
+ namespace: "zapier",
4255
+ imports: [kitcore.receiveHttpResponsePlugin, sdkOptionsPluginRef],
4256
+ wrap: {
4257
+ receiveHttpResponse: async ({ input, imports, next }) => {
4258
+ const resolvedRoute = input.attempt.state[ZAPIER_RESOLVED_ROUTE_STATE];
4259
+ const response = await next(input);
4260
+ if (resolvedRoute) {
4261
+ handleDeprecationNotice({
4262
+ response,
4263
+ canSendDeprecationMessaging: resolvedRoute.canSendDeprecationMessaging,
4264
+ onEvent: imports.sdkOptions?.onEvent
4265
+ });
4266
+ }
4267
+ return response;
4268
+ }
4269
+ }
4199
4270
  });
4200
4271
 
4201
4272
  // src/plugins/transport/options.ts
@@ -4261,16 +4332,18 @@ var zapierHttpTransportPlugin = kitcore.definePlugin({
4261
4332
  kitcore.sendHttpRequestPlugin,
4262
4333
  kitcore.retryHttpRequestPlugin,
4263
4334
  retryHttpRequestOptionsPlugin,
4264
- httpFetchPlugin
4335
+ httpFetchPlugin,
4336
+ zapierRouteHttpRequestPlugin,
4337
+ zapierDeprecationHttpResponsePlugin
4265
4338
  ],
4266
4339
  exports: [kitcore.sendHttpRequestPlugin]
4267
4340
  });
4268
4341
 
4269
4342
  // src/plugins/api/index.ts
4270
- var API_ID = "zapier/api";
4271
4343
  var apiPluginRef = kitcore.declareProperty({
4272
- id: API_ID
4344
+ id: "zapier/api"
4273
4345
  });
4346
+ var API_ID = apiPluginRef.id;
4274
4347
  function withCorrelationId({
4275
4348
  client,
4276
4349
  callId
@@ -4346,8 +4419,8 @@ var apiPlugin = kitcore.defineProperty({
4346
4419
  },
4347
4420
  get: ({ state, callContext }) => callContext?.callId ? withCorrelationId({ client: state, callId: callContext.callId }) : state
4348
4421
  });
4349
- var RESOLVE_CREDENTIALS_ID = "zapier/resolveCredentials";
4350
- var resolveCredentialsPluginRef = kitcore.declareProperty({ id: RESOLVE_CREDENTIALS_ID });
4422
+ var resolveCredentialsPluginRef = kitcore.declareProperty({ id: "zapier/resolveCredentials" });
4423
+ var RESOLVE_CREDENTIALS_ID = resolveCredentialsPluginRef.id;
4351
4424
  var resolveCredentialsPlugin = kitcore.defineProperty({
4352
4425
  namespace: "zapier",
4353
4426
  name: "resolveCredentials",
@@ -5036,8 +5109,8 @@ async function resolveAppKeys({
5036
5109
  });
5037
5110
  return slugResolvedLocators.filter(isResolvedAppLocator);
5038
5111
  }
5039
- var MANIFEST_ID = "zapier/manifest";
5040
- var manifestPluginRef = kitcore.declareProperty({ id: MANIFEST_ID });
5112
+ var manifestPluginRef = kitcore.declareProperty({ id: "zapier/manifest" });
5113
+ var MANIFEST_ID = manifestPluginRef.id;
5041
5114
  var manifestPlugin = kitcore.defineProperty({
5042
5115
  namespace: "zapier",
5043
5116
  name: "manifest",
@@ -5164,8 +5237,8 @@ var manifestPlugin = kitcore.defineProperty({
5164
5237
  });
5165
5238
 
5166
5239
  // src/plugins/connections/index.ts
5167
- var CONNECTIONS_ID = "zapier/connections";
5168
- var connectionsPluginRef = kitcore.declareProperty({ id: CONNECTIONS_ID });
5240
+ var connectionsPluginRef = kitcore.declareProperty({ id: "zapier/connections" });
5241
+ var CONNECTIONS_ID = connectionsPluginRef.id;
5169
5242
  var connectionsPlugin = kitcore.defineProperty({
5170
5243
  namespace: "zapier",
5171
5244
  name: "connections",
@@ -9487,6 +9560,9 @@ var zapierCoreOptions = {
9487
9560
  );
9488
9561
  }
9489
9562
  };
9563
+ var zapierCoreOptionsPlugin = kitcore.declareDefault({
9564
+ plugin: kitcore.defineProperty(kitcore.coreOptionsPluginRef, { value: zapierCoreOptions })
9565
+ });
9490
9566
  var GetConnectionStartUrlSchema = zod.z.object({
9491
9567
  app: AppPropertySchema
9492
9568
  }).describe(
@@ -11125,21 +11201,17 @@ var apiClientRootPlugin = kitcore.definePlugin({
11125
11201
  imports: [apiPlugin],
11126
11202
  exports: []
11127
11203
  });
11128
- function hasStringUrl(request) {
11129
- return typeof request.url === "string";
11130
- }
11131
- function createApiClientGraphConfiguration(options) {
11204
+ function splitApiClientOptions(options) {
11132
11205
  const {
11133
11206
  maxNetworkRetryDelayMilliseconds,
11134
11207
  maxNetworkRetryDelayMs,
11135
11208
  approvalTimeoutMilliseconds,
11136
11209
  approvalTimeoutMs,
11137
- sendHttpRequest: _sendHttpRequest,
11138
11210
  ...sdkOptions
11139
11211
  } = options;
11140
11212
  return {
11141
- [SDK_OPTIONS_ID]: sdkOptions,
11142
- [API_CLIENT_DURATIONS_ID]: {
11213
+ sdkOptions,
11214
+ durations: {
11143
11215
  maxNetworkRetryDelayMilliseconds: maxNetworkRetryDelayMilliseconds ?? maxNetworkRetryDelayMs,
11144
11216
  approvalTimeoutMilliseconds: approvalTimeoutMilliseconds ?? approvalTimeoutMs
11145
11217
  }
@@ -11147,39 +11219,13 @@ function createApiClientGraphConfiguration(options) {
11147
11219
  }
11148
11220
  function createApiClientFromSdkGraph(options) {
11149
11221
  parseRoutingOptions({ options });
11150
- const configuration = createApiClientGraphConfiguration(options);
11151
- const { sendHttpRequest } = options;
11152
- if (!sendHttpRequest) {
11153
- const sdk2 = kitcore.createSdk(apiClientRootPlugin, { configuration });
11154
- return kitcore.resolvePlugin(sdk2, apiPluginRef);
11155
- }
11156
- const replaceSendHttpRequestPlugin = kitcore.defineHook({
11157
- namespace: "zapier",
11158
- name: "replaceApiClientSendHttpRequest",
11159
- imports: [kitcore.sendHttpRequestPlugin],
11160
- wrap: {
11161
- // Replaces the pipeline rather than wrapping it: `next` is deliberately
11162
- // unused. A transport supplied through `sendHttpRequest` owns its retry
11163
- // policy, so running the SDK's stages underneath would nest the caller's
11164
- // retry loop inside a second one. Dropping them is only safe because the
11165
- // SDK's retry hook wraps `attemptHttpRequest`, a stage below this seam,
11166
- // so replacing `sendHttpRequest` removes that loop instead of nesting
11167
- // inside it. The cost is that the SDK cannot observe retries the caller
11168
- // performs, and so reports a terminal 429 as zero.
11169
- sendHttpRequest: ({ input }) => sendHttpRequest(
11170
- hasStringUrl(input) ? input : { ...input, url: input.url.toString() }
11171
- )
11172
- }
11222
+ const { sdkOptions, durations } = splitApiClientOptions(options);
11223
+ const sdk = kitcore.createSdk(apiClientRootPlugin, {
11224
+ imports: [
11225
+ kitcore.defineProperty(sdkOptionsPluginRef, { value: sdkOptions }),
11226
+ kitcore.defineProperty(apiClientDurationsPluginRef, { value: durations })
11227
+ ]
11173
11228
  });
11174
- const sdk = kitcore.createSdk(
11175
- kitcore.definePlugin({
11176
- namespace: "zapier",
11177
- name: "standaloneApiClientRoot",
11178
- imports: [apiPlugin, replaceSendHttpRequestPlugin],
11179
- exports: []
11180
- }),
11181
- { configuration }
11182
- );
11183
11229
  return kitcore.resolvePlugin(sdk, apiPluginRef);
11184
11230
  }
11185
11231
 
@@ -13221,8 +13267,8 @@ function createEventEmitter(options) {
13221
13267
  };
13222
13268
  }
13223
13269
  }
13224
- var EVENT_EMISSION_ID = "zapier/eventEmission";
13225
- var eventEmissionPluginRef = kitcore.declareProperty({ id: EVENT_EMISSION_ID });
13270
+ var eventEmissionPluginRef = kitcore.declareProperty({ id: "zapier/eventEmission" });
13271
+ var EVENT_EMISSION_ID = eventEmissionPluginRef.id;
13226
13272
  var eventEmissionPlugin = kitcore.defineProperty({
13227
13273
  namespace: "zapier",
13228
13274
  name: "eventEmission",
@@ -13264,12 +13310,14 @@ var zapierSdkPlugin = kitcore.definePlugin({
13264
13310
  name: "sdk",
13265
13311
  // Foundation providers are internal imports (not surfaced exports): module
13266
13312
  // plugins resolve `apiPluginRef` etc. to them; each BUILDS its value from
13267
- // the injected options (and sibling providers). `sdkOptions` has no
13268
- // provider: importing the stand-in declares the configurable id, and each
13269
- // factory injects the caller's options under it via `createSdk`'s
13270
- // `configuration`.
13313
+ // the provided options (and sibling providers). `sdkOptions` has no
13314
+ // provider here: importing the stand-in declares the configurable id, and
13315
+ // each factory provides the caller's options in `createSdk`'s `imports`
13316
+ // with `defineProperty(sdkOptionsPluginRef, { value })`. Core options have a
13317
+ // default provider that a factory can outrank with its own.
13271
13318
  imports: [
13272
13319
  sdkOptionsPluginRef,
13320
+ zapierCoreOptionsPlugin,
13273
13321
  apiPlugin,
13274
13322
  resolveCredentialsPlugin,
13275
13323
  manifestPlugin,
@@ -13356,10 +13404,7 @@ var zapierSdkPlugin = kitcore.definePlugin({
13356
13404
  });
13357
13405
  function createZapierSdk(options = {}) {
13358
13406
  return kitcore.createSdk(zapierSdkPlugin, {
13359
- configuration: {
13360
- [SDK_OPTIONS_ID]: options,
13361
- [kitcore.CORE_OPTIONS_ID]: zapierCoreOptions
13362
- }
13407
+ imports: [kitcore.defineProperty(sdkOptionsPluginRef, { value: options })]
13363
13408
  });
13364
13409
  }
13365
13410
 
@@ -13611,6 +13656,10 @@ Object.defineProperty(exports, "applyStabilityLabel", {
13611
13656
  enumerable: true,
13612
13657
  get: function () { return kitcore.applyStabilityLabel; }
13613
13658
  });
13659
+ Object.defineProperty(exports, "coreOptionsPluginRef", {
13660
+ enumerable: true,
13661
+ get: function () { return kitcore.coreOptionsPluginRef; }
13662
+ });
13614
13663
  Object.defineProperty(exports, "createController", {
13615
13664
  enumerable: true,
13616
13665
  get: function () { return kitcore.createController; }
@@ -1,5 +1,5 @@
1
- import { taxonomy, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, extractErrorDetail, ZapierApiError, durableRunIdResolver, ZapierConflictError, workflowVersionIdResolver, workflowDraftIdResolver, workflowRunIdResolver, workflowDraftRevisionResolver, isZapierNotFoundError, ZapierTimeoutError, zapierSdkPlugin, SDK_VERSION, ZapierValidationError, sleep, zapierCoreOptions, SDK_OPTIONS_ID } from './chunk-3WRZWB3X.mjs';
2
- import { defineMethod, openEnum, defineResolver, definePlugin, createSdk, CORE_OPTIONS_ID } from '@zapier/kitcore';
1
+ import { taxonomy, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, extractErrorDetail, ZapierApiError, durableRunIdResolver, ZapierConflictError, workflowVersionIdResolver, workflowDraftIdResolver, workflowRunIdResolver, workflowDraftRevisionResolver, isZapierNotFoundError, ZapierTimeoutError, zapierSdkPlugin, SDK_VERSION, ZapierValidationError, sleep, sdkOptionsPluginRef } from './chunk-EWFUUFGE.mjs';
2
+ import { defineMethod, openEnum, defineResolver, definePlugin, createSdk, defineProperty } from '@zapier/kitcore';
3
3
  import { z } from 'zod';
4
4
 
5
5
  var codeSubstrateDefaults = {
@@ -2568,10 +2568,7 @@ var zapierBetaSdkPlugin = definePlugin({
2568
2568
  });
2569
2569
  function createZapierSdk(options = {}) {
2570
2570
  return createSdk(zapierBetaSdkPlugin, {
2571
- configuration: {
2572
- [SDK_OPTIONS_ID]: options,
2573
- [CORE_OPTIONS_ID]: zapierCoreOptions
2574
- }
2571
+ imports: [defineProperty(sdkOptionsPluginRef, { value: options })]
2575
2572
  });
2576
2573
  }
2577
2574