@zapier/zapier-sdk 0.102.2 → 0.102.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.102.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 2c8ea56: _This release contains no user-facing changes._
8
+ - Updated dependencies [2c8ea56]
9
+ - @zapier/kitcore@0.18.0
10
+
11
+ ## 0.102.3
12
+
13
+ ### Patch Changes
14
+
15
+ - 4a51b07: Added `editor_url` to the experimental create, get, list, update, and import workflow responses in the SDK and CLI.
16
+
3
17
  ## 0.102.2
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -1250,6 +1250,7 @@ Create a durable workflow container. Starts disabled with no version; publish a
1250
1250
  | ​ ↳ `name` | `string` | ✅ | — | Workflow name |
1251
1251
  | ​ ↳ `description` | `string` | ✅ | — | Workflow description (null if unset) |
1252
1252
  | ​ ↳ `trigger_url` | `string` | ✅ | — | Public URL that fires this workflow when POSTed to. Embeds a trigger token in the path — treat as sensitive. Requests must also be authenticated as the account. |
1253
+ | ​ ↳ `editor_url` | `string` | ✅ | — | URL to the Zapier workflow editor for this workflow |
1253
1254
  | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers. Always false on a new workflow until enabled. |
1254
1255
  | ​ ↳ `is_private` | `boolean` | ✅ | — | Whether the workflow is private to the creating user. False means account-visible. |
1255
1256
  | ​ ↳ `created_by_user_id` | `string` | ✅ | — | User ID of the workflow creator (null in legacy data) |
@@ -1520,6 +1521,7 @@ Get a durable workflow with its current version details and trigger claim status
1520
1521
  | ​ ↳ `name` | `string` | ✅ | — | Workflow name |
1521
1522
  | ​ ↳ `description` | `string` | ✅ | — | Optional workflow description (null if unset) |
1522
1523
  | ​ ↳ `trigger_url` | `string` | ✅ | — | Public URL that fires this workflow when POSTed to. Embeds a trigger token in the path — treat as sensitive. Requests must also be authenticated as the account. |
1524
+ | ​ ↳ `editor_url` | `string` | ✅ | — | URL to the Zapier workflow editor for this workflow |
1523
1525
  | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers |
1524
1526
  | ​ ↳ `disabled_reason` | `string` | ❌ | `trigger_claim_failed` | Why the workflow is off, when system-disabled. Null when not system-disabled. Independent of per-trigger claim status: an enabled workflow can still have a failed trigger. |
1525
1527
  | ​ ↳ `is_private` | `boolean` | ✅ | — | Whether the workflow is private to the creating user. False means account-visible. |
@@ -1695,6 +1697,7 @@ Convert an existing Zap into a durable workflow. Transforms the Zap's latest pub
1695
1697
  | ​   ↳ `name` | `string` | ✅ | — | Workflow name |
1696
1698
  | ​   ↳ `description` | `string` | ❌ | — | Optional workflow description (null if unset) |
1697
1699
  | ​   ↳ `trigger_url` | `string` | ✅ | — | Public URL that fires this workflow when POSTed to. Embeds a trigger token in the path — treat as sensitive. Requests must also be authenticated as the account. |
1700
+ | ​   ↳ `editor_url` | `string` | ✅ | — | URL to the Zapier workflow editor for this workflow |
1698
1701
  | ​   ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow accepts triggers. An import always lands disabled. |
1699
1702
  | ​   ↳ `disabled_reason` | `string` | ❌ | `trigger_claim_failed` | Why the workflow is off, when system-disabled. |
1700
1703
  | ​   ↳ `is_private` | `boolean` | ✅ | — | Whether the workflow is private to the creating user. False means account-visible. |
@@ -1988,6 +1991,7 @@ List all active durable workflows for the authenticated account
1988
1991
  | ​ ↳ `name` | `string` | ✅ | — | Workflow name |
1989
1992
  | ​ ↳ `description` | `string` | ✅ | — | Optional workflow description (null if unset) |
1990
1993
  | ​ ↳ `trigger_url` | `string` | ✅ | — | Public URL that fires this workflow when POSTed to. Embeds a trigger token in the path — treat as sensitive. Requests must also be authenticated as the account. |
1994
+ | ​ ↳ `editor_url` | `string` | ✅ | — | URL to the Zapier workflow editor for this workflow |
1991
1995
  | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers |
1992
1996
  | ​ ↳ `disabled_reason` | `string` | ❌ | `trigger_claim_failed` | Why the workflow is off, when system-disabled. Null when not system-disabled. |
1993
1997
  | ​ ↳ `is_private` | `boolean` | ✅ | — | Whether the workflow is private to the creating user. False means account-visible. |
@@ -2222,6 +2226,7 @@ Update a durable workflow's name and/or description
2222
2226
  | ​ ↳ `name` | `string` | ✅ | — | Workflow name (post-update) |
2223
2227
  | ​ ↳ `description` | `string` | ✅ | — | Workflow description, post-update (null if unset) |
2224
2228
  | ​ ↳ `trigger_url` | `string` | ✅ | — | Public URL that fires this workflow when POSTed to. Embeds a trigger token in the path — treat as sensitive. Requests must also be authenticated as the account. |
2229
+ | ​ ↳ `editor_url` | `string` | ✅ | — | URL to the Zapier workflow editor for this workflow |
2225
2230
  | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers |
2226
2231
  | ​ ↳ `is_private` | `boolean` | ✅ | — | Whether the workflow is private to the creating user. False means account-visible. |
2227
2232
  | ​ ↳ `created_by_user_id` | `string` | ✅ | — | User ID of the workflow creator (null in legacy data) |
@@ -1,6 +1,6 @@
1
1
  import { __require } from './chunk-Y6FXYEAI.mjs';
2
2
  import { z } from 'zod';
3
- import { withPositional, createDeprecationLogger, createAsyncContext, declareOptionalProperty, declareProperty, defineProperty, defineMethod, coreOptionsPluginRef, createValidator, defineFormatter, declareMethod, defineResolver, concatLists, openEnum, defineHook, definePlugin, getRegistryPlugin, paginate, toSnakeCase, isCoreError, toTitleCase, CORE_ERROR_SYMBOL, CoreErrorCode, CORE_SIGNAL_SYMBOL, isCoreSignal, createSdk, CORE_OPTIONS_ID } from '@zapier/kitcore';
3
+ import { withPositional, declareOptionalProperty, defineProperty, createDeprecationLogger, createAsyncContext, definePlugin, sendHttpRequestPlugin, declareProperty, defineMethod, coreOptionsPluginRef, createValidator, defineFormatter, declareMethod, defineResolver, concatLists, openEnum, defineHook, getRegistryPlugin, paginate, toSnakeCase, isCoreError, toTitleCase, createSdk, CORE_ERROR_SYMBOL, CoreErrorCode, CORE_SIGNAL_SYMBOL, isCoreSignal, CORE_OPTIONS_ID } from '@zapier/kitcore';
4
4
  export { CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, addPlugin, composePlugins, createController, createCorePlugin, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getNegatable, getRegistryPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isPositional, omitExports, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, toSnakeCase, toTitleCase } from '@zapier/kitcore';
5
5
  import { buildHttpRequestContext, buildActionRunContext } from '@zapier/policy-context';
6
6
  import { ListAppsQuerySchema, AppItemSchema as AppItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/apps';
@@ -1070,6 +1070,51 @@ function createSemaphore(maxPermits) {
1070
1070
  }
1071
1071
  };
1072
1072
  }
1073
+ var SDK_OPTIONS_ID = "zapier/sdkOptions";
1074
+ var sdkOptionsPluginRef = declareOptionalProperty({
1075
+ id: SDK_OPTIONS_ID
1076
+ });
1077
+
1078
+ // src/plugins/transport/options.ts
1079
+ function resolveTransportFetch({
1080
+ fetch: customFetch,
1081
+ debug = false
1082
+ }) {
1083
+ const originalFetch = customFetch ?? ((input, init) => globalThis.fetch(input, init));
1084
+ if (!debug) return originalFetch;
1085
+ return createDebugFetch({
1086
+ originalFetch,
1087
+ debugLog: createDebugLogger(debug)
1088
+ });
1089
+ }
1090
+
1091
+ // src/plugins/transport/http-fetch.ts
1092
+ var httpFetchPlugin = defineProperty({
1093
+ namespace: "kitcore",
1094
+ name: "httpFetch",
1095
+ imports: [sdkOptionsPluginRef],
1096
+ setup: ({ imports }) => resolveTransportFetch({
1097
+ fetch: imports.sdkOptions?.fetch,
1098
+ debug: imports.sdkOptions?.debug
1099
+ }),
1100
+ get: ({ state }) => state
1101
+ });
1102
+
1103
+ // src/plugins/transport/standalone.ts
1104
+ function createZapierSendHttpRequest({
1105
+ fetch: customFetch,
1106
+ debug
1107
+ }) {
1108
+ const sdk = createSdk(
1109
+ definePlugin({
1110
+ name: "zapierStandaloneHttpTransport",
1111
+ imports: [sendHttpRequestPlugin, httpFetchPlugin],
1112
+ exports: [sendHttpRequestPlugin]
1113
+ }),
1114
+ { configuration: { [SDK_OPTIONS_ID]: { fetch: customFetch, debug } } }
1115
+ );
1116
+ return sdk.sendHttpRequest;
1117
+ }
1073
1118
 
1074
1119
  // src/api/correlation.ts
1075
1120
  var CORRELATION_CALL_ID = Symbol(
@@ -1987,7 +2032,7 @@ function parseDeprecationDate(value) {
1987
2032
  }
1988
2033
 
1989
2034
  // src/sdk-version.ts
1990
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.2" : void 0) || "unknown";
2035
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.4" : void 0) || "unknown";
1991
2036
 
1992
2037
  // src/utils/open-url.ts
1993
2038
  var nodePrefix = "node:";
@@ -2275,11 +2320,23 @@ var ZapierApiClient = class {
2275
2320
  mergedHeaders.set(key, value);
2276
2321
  });
2277
2322
  this.applyTelemetryHeaders({ headers: mergedHeaders, callId });
2323
+ const {
2324
+ authRequired: _authRequired,
2325
+ requiredScopes: _requiredScopes,
2326
+ searchParams: _searchParams,
2327
+ approvalContext: _approvalContext,
2328
+ customErrorHandler: _customErrorHandler,
2329
+ resource: _resource,
2330
+ ...wireInit
2331
+ } = fetchInit;
2278
2332
  let retries = 0;
2279
2333
  while (true) {
2280
- const response = await this.options.fetch(url, {
2281
- ...fetchInit,
2282
- headers: mergedHeaders
2334
+ const response = await this.options.sendHttpRequest({
2335
+ ...wireInit,
2336
+ // Set the resolved URL and merged headers after the spread so caller
2337
+ // values cannot override them.
2338
+ url,
2339
+ headers: Object.fromEntries(mergedHeaders)
2283
2340
  });
2284
2341
  if (response.status !== 429) {
2285
2342
  return response;
@@ -3343,7 +3400,12 @@ var createZapierApi = (options) => {
3343
3400
  return new ZapierApiClient({
3344
3401
  ...options,
3345
3402
  debug,
3346
- fetch: debugFetch
3403
+ // The credential-exchange transport. Debug-wrapped here rather than in the
3404
+ // pipeline because `resolveAuthToken` is issued outside it.
3405
+ fetch: debugFetch,
3406
+ // Built from the caller's own `fetch`, not `debugFetch`: the pipeline wraps
3407
+ // for debug itself, and passing the wrapped one would log twice.
3408
+ sendHttpRequest: options.sendHttpRequest ?? createZapierSendHttpRequest({ fetch: options.fetch, debug })
3347
3409
  });
3348
3410
  };
3349
3411
 
@@ -3380,9 +3442,11 @@ function getOrCreateApiClient(config) {
3380
3442
  callerPackage
3381
3443
  });
3382
3444
  }
3383
- var SDK_OPTIONS_ID = "zapier/sdkOptions";
3384
- var sdkOptionsPluginRef = declareOptionalProperty({
3385
- id: SDK_OPTIONS_ID
3445
+ var zapierHttpTransportPlugin = definePlugin({
3446
+ namespace: "zapier",
3447
+ name: "httpTransport",
3448
+ imports: [sendHttpRequestPlugin, httpFetchPlugin],
3449
+ exports: [sendHttpRequestPlugin]
3386
3450
  });
3387
3451
 
3388
3452
  // src/plugins/api/index.ts
@@ -3410,7 +3474,9 @@ function withCorrelationId({
3410
3474
  var apiPlugin = defineProperty({
3411
3475
  namespace: "zapier",
3412
3476
  name: "api",
3413
- imports: [sdkOptionsPluginRef],
3477
+ // Import the aggregate so it also provides `kitcore/httpFetch`; importing
3478
+ // `sendHttpRequestPlugin` alone would bypass `sdkOptions.fetch`.
3479
+ imports: [sdkOptionsPluginRef, zapierHttpTransportPlugin],
3414
3480
  setup: ({ imports }) => {
3415
3481
  const {
3416
3482
  fetch: customFetch = globalThis.fetch,
@@ -3444,7 +3510,10 @@ var apiPlugin = defineProperty({
3444
3510
  maxApprovalRetries,
3445
3511
  approvalMode,
3446
3512
  openAutoModeApprovalsInBrowser,
3447
- callerPackage
3513
+ callerPackage,
3514
+ // Inject the graph-composed transport so host `dispatchHttpRequest` wraps
3515
+ // apply.
3516
+ sendHttpRequest: imports.sendHttpRequest
3448
3517
  });
3449
3518
  },
3450
3519
  get: ({ state, callContext }) => callContext?.callId ? withCorrelationId({ client: state, callId: callContext.callId }) : state
@@ -1071,6 +1071,51 @@ function createSemaphore(maxPermits) {
1071
1071
  }
1072
1072
  };
1073
1073
  }
1074
+ var SDK_OPTIONS_ID = "zapier/sdkOptions";
1075
+ var sdkOptionsPluginRef = kitcore.declareOptionalProperty({
1076
+ id: SDK_OPTIONS_ID
1077
+ });
1078
+
1079
+ // src/plugins/transport/options.ts
1080
+ function resolveTransportFetch({
1081
+ fetch: customFetch,
1082
+ debug = false
1083
+ }) {
1084
+ const originalFetch = customFetch ?? ((input, init) => globalThis.fetch(input, init));
1085
+ if (!debug) return originalFetch;
1086
+ return createDebugFetch({
1087
+ originalFetch,
1088
+ debugLog: createDebugLogger(debug)
1089
+ });
1090
+ }
1091
+
1092
+ // src/plugins/transport/http-fetch.ts
1093
+ var httpFetchPlugin = kitcore.defineProperty({
1094
+ namespace: "kitcore",
1095
+ name: "httpFetch",
1096
+ imports: [sdkOptionsPluginRef],
1097
+ setup: ({ imports }) => resolveTransportFetch({
1098
+ fetch: imports.sdkOptions?.fetch,
1099
+ debug: imports.sdkOptions?.debug
1100
+ }),
1101
+ get: ({ state }) => state
1102
+ });
1103
+
1104
+ // src/plugins/transport/standalone.ts
1105
+ function createZapierSendHttpRequest({
1106
+ fetch: customFetch,
1107
+ debug
1108
+ }) {
1109
+ const sdk = kitcore.createSdk(
1110
+ kitcore.definePlugin({
1111
+ name: "zapierStandaloneHttpTransport",
1112
+ imports: [kitcore.sendHttpRequestPlugin, httpFetchPlugin],
1113
+ exports: [kitcore.sendHttpRequestPlugin]
1114
+ }),
1115
+ { configuration: { [SDK_OPTIONS_ID]: { fetch: customFetch, debug } } }
1116
+ );
1117
+ return sdk.sendHttpRequest;
1118
+ }
1074
1119
 
1075
1120
  // src/api/correlation.ts
1076
1121
  var CORRELATION_CALL_ID = Symbol(
@@ -1988,7 +2033,7 @@ function parseDeprecationDate(value) {
1988
2033
  }
1989
2034
 
1990
2035
  // src/sdk-version.ts
1991
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.2" : void 0) || "unknown";
2036
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.4" : void 0) || "unknown";
1992
2037
 
1993
2038
  // src/utils/open-url.ts
1994
2039
  var nodePrefix = "node:";
@@ -2276,11 +2321,23 @@ var ZapierApiClient = class {
2276
2321
  mergedHeaders.set(key, value);
2277
2322
  });
2278
2323
  this.applyTelemetryHeaders({ headers: mergedHeaders, callId });
2324
+ const {
2325
+ authRequired: _authRequired,
2326
+ requiredScopes: _requiredScopes,
2327
+ searchParams: _searchParams,
2328
+ approvalContext: _approvalContext,
2329
+ customErrorHandler: _customErrorHandler,
2330
+ resource: _resource,
2331
+ ...wireInit
2332
+ } = fetchInit;
2279
2333
  let retries = 0;
2280
2334
  while (true) {
2281
- const response = await this.options.fetch(url, {
2282
- ...fetchInit,
2283
- headers: mergedHeaders
2335
+ const response = await this.options.sendHttpRequest({
2336
+ ...wireInit,
2337
+ // Set the resolved URL and merged headers after the spread so caller
2338
+ // values cannot override them.
2339
+ url,
2340
+ headers: Object.fromEntries(mergedHeaders)
2284
2341
  });
2285
2342
  if (response.status !== 429) {
2286
2343
  return response;
@@ -3344,7 +3401,12 @@ var createZapierApi = (options) => {
3344
3401
  return new ZapierApiClient({
3345
3402
  ...options,
3346
3403
  debug,
3347
- fetch: debugFetch
3404
+ // The credential-exchange transport. Debug-wrapped here rather than in the
3405
+ // pipeline because `resolveAuthToken` is issued outside it.
3406
+ fetch: debugFetch,
3407
+ // Built from the caller's own `fetch`, not `debugFetch`: the pipeline wraps
3408
+ // for debug itself, and passing the wrapped one would log twice.
3409
+ sendHttpRequest: options.sendHttpRequest ?? createZapierSendHttpRequest({ fetch: options.fetch, debug })
3348
3410
  });
3349
3411
  };
3350
3412
 
@@ -3381,9 +3443,11 @@ function getOrCreateApiClient(config) {
3381
3443
  callerPackage
3382
3444
  });
3383
3445
  }
3384
- var SDK_OPTIONS_ID = "zapier/sdkOptions";
3385
- var sdkOptionsPluginRef = kitcore.declareOptionalProperty({
3386
- id: SDK_OPTIONS_ID
3446
+ var zapierHttpTransportPlugin = kitcore.definePlugin({
3447
+ namespace: "zapier",
3448
+ name: "httpTransport",
3449
+ imports: [kitcore.sendHttpRequestPlugin, httpFetchPlugin],
3450
+ exports: [kitcore.sendHttpRequestPlugin]
3387
3451
  });
3388
3452
 
3389
3453
  // src/plugins/api/index.ts
@@ -3411,7 +3475,9 @@ function withCorrelationId({
3411
3475
  var apiPlugin = kitcore.defineProperty({
3412
3476
  namespace: "zapier",
3413
3477
  name: "api",
3414
- imports: [sdkOptionsPluginRef],
3478
+ // Import the aggregate so it also provides `kitcore/httpFetch`; importing
3479
+ // `sendHttpRequestPlugin` alone would bypass `sdkOptions.fetch`.
3480
+ imports: [sdkOptionsPluginRef, zapierHttpTransportPlugin],
3415
3481
  setup: ({ imports }) => {
3416
3482
  const {
3417
3483
  fetch: customFetch = globalThis.fetch,
@@ -3445,7 +3511,10 @@ var apiPlugin = kitcore.defineProperty({
3445
3511
  maxApprovalRetries,
3446
3512
  approvalMode,
3447
3513
  openAutoModeApprovalsInBrowser,
3448
- callerPackage
3514
+ callerPackage,
3515
+ // Inject the graph-composed transport so host `dispatchHttpRequest` wraps
3516
+ // apply.
3517
+ sendHttpRequest: imports.sendHttpRequest
3449
3518
  });
3450
3519
  },
3451
3520
  get: ({ state, callContext }) => callContext?.callId ? withCorrelationId({ client: state, callId: callContext.callId }) : state