@zapier/zapier-sdk 0.73.0 → 0.74.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 (36) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +32 -32
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +5 -0
  5. package/dist/experimental.cjs +218 -80
  6. package/dist/experimental.d.mts +160 -12
  7. package/dist/experimental.d.ts +158 -10
  8. package/dist/experimental.d.ts.map +1 -1
  9. package/dist/experimental.mjs +217 -81
  10. package/dist/{index-D1O7Pcex.d.mts → index-WMit6fkJ.d.mts} +22 -1
  11. package/dist/{index-D1O7Pcex.d.ts → index-WMit6fkJ.d.ts} +22 -1
  12. package/dist/index.cjs +53 -16
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -0
  17. package/dist/index.mjs +52 -17
  18. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +42 -3
  19. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
  20. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +49 -11
  21. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts +117 -5
  22. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts.map +1 -1
  23. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.js +77 -14
  24. package/dist/plugins/codeSubstrate/runDurable/index.d.ts +37 -2
  25. package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +1 -1
  26. package/dist/plugins/codeSubstrate/runDurable/index.js +10 -9
  27. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +117 -4
  28. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +1 -1
  29. package/dist/plugins/codeSubstrate/runDurable/schemas.js +38 -37
  30. package/dist/plugins/codeSubstrate/shared.d.ts +56 -0
  31. package/dist/plugins/codeSubstrate/shared.d.ts.map +1 -1
  32. package/dist/plugins/codeSubstrate/shared.js +100 -0
  33. package/dist/utils/caller-context.d.ts +21 -0
  34. package/dist/utils/caller-context.d.ts.map +1 -0
  35. package/dist/utils/caller-context.js +35 -0
  36. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.74.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 571f90d: Add zapier-sdk-package-operation header to identify the caller operation
8
+
9
+ ## 0.73.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 6c7627c: CamelCase the input params on `runDurable` and `publishWorkflowVersion` (`sourceFiles`, `zapierDurableVersion`, `appVersions`, and the nested connection / app-version / trigger fields), keeping the old snake_case names as deprecated aliases. Handlers map them back to the snake_case wire body; output fields are unchanged.
14
+
3
15
  ## 0.73.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -1658,21 +1658,21 @@ Publish a new version of a durable workflow. Enables the workflow by default.
1658
1658
 
1659
1659
  **Parameters:**
1660
1660
 
1661
- | Name | Type | Required | Default | Possible Values | Description |
1662
- | ---------------------------- | --------- | -------- | ------- | --------------- | -------------------------------------------------------------------------------------------------------------------- |
1663
- | `options` | `object` | ✅ | — | — | |
1664
- | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1665
- | ​ ↳ `source_files` | `object` | ✅ | — | — | Source files keyed by filename → contents |
1666
- | ​ ↳ `dependencies` | `object` | ❌ | — | — | Optional npm package dependencies |
1667
- | ​ ↳ `zapier_durable_version` | `string` | ❌ | — | — | Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted. |
1668
- | ​ ↳ `enabled` | `boolean` | ❌ | — | — | Enable the workflow after publishing. Defaults to true; pass false to publish without enabling. |
1669
- | ​ ↳ `connections` | `object` | ❌ | — | — | Map of connection aliases to Zapier connections used by the workflow. Pass `null` to clear an existing binding. |
1670
- | ​ ↳ `app_versions` | `object` | ❌ | — | — | Map of app keys to pinned app implementation/version used by the workflow. Pass `null` to clear an existing binding. |
1671
- | ​ ↳ `trigger` | `object` | ❌ | — | — | Trigger configuration. When provided, the workflow subscribes to a Zapier trigger; omit for webhook-only workflows. |
1672
- | ​   ↳ `selected_api` | `string` | | — | — | Zapier app/API identifier (e.g. 'GoogleSheetsAPI') |
1673
- | ​   ↳ `action` | `string` | ✅ | — | — | Trigger action key (e.g. 'new_row') |
1674
- | ​   ↳ `authentication_id` | `string` | ❌ | — | — | Connection ID for the trigger source. Omit or pass null for no-auth triggers (e.g. Schedule by Zapier). |
1675
- | ​   ↳ `params` | `object` | ❌ | — | — | Trigger parameters as a JSON object |
1661
+ | Name | Type | Required | Default | Possible Values | Description |
1662
+ | -------------------------- | --------- | -------- | ------- | --------------- | -------------------------------------------------------------------------------------------------------------------- |
1663
+ | `options` | `object` | ✅ | — | — | |
1664
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1665
+ | ​ ↳ `sourceFiles` | `object` | ✅ | — | — | Source files keyed by filename → contents |
1666
+ | ​ ↳ `dependencies` | `object` | ❌ | — | — | Optional npm package dependencies |
1667
+ | ​ ↳ `zapierDurableVersion` | `string` | ❌ | — | — | Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted. |
1668
+ | ​ ↳ `enabled` | `boolean` | ❌ | — | — | Enable the workflow after publishing. Defaults to true; pass false to publish without enabling. |
1669
+ | ​ ↳ `connections` | `object` | ❌ | — | — | Map of connection aliases to Zapier connections used by the workflow. Pass `null` to clear an existing binding. |
1670
+ | ​ ↳ `appVersions` | `object` | ❌ | — | — | Map of app keys to pinned app implementation/version used by the workflow. Pass `null` to clear an existing binding. |
1671
+ | ​ ↳ `trigger` | `object` | ❌ | — | — | Trigger configuration. When provided, the workflow subscribes to a Zapier trigger; omit for webhook-only workflows. |
1672
+ | ​   ↳ `selectedApi` | `string` | | — | — | Zapier app/API identifier (e.g. 'GoogleSheetsAPI'). Required when a trigger is configured. |
1673
+ | ​   ↳ `action` | `string` | ✅ | — | — | Trigger action key (e.g. 'new_row') |
1674
+ | ​   ↳ `authenticationId` | `string` | ❌ | — | — | Connection ID for the trigger source. Omit or pass null for no-auth triggers (e.g. Schedule by Zapier). |
1675
+ | ​   ↳ `params` | `object` | ❌ | — | — | Trigger parameters as a JSON object |
1676
1676
 
1677
1677
  **Returns:** `Promise<WorkflowVersionItem>`
1678
1678
 
@@ -1695,7 +1695,7 @@ Publish a new version of a durable workflow. Enables the workflow by default.
1695
1695
  ```typescript
1696
1696
  const result = await zapier.publishWorkflowVersion({
1697
1697
  workflow: "example-workflow",
1698
- source_files: {},
1698
+ sourceFiles: {},
1699
1699
  });
1700
1700
  ```
1701
1701
 
@@ -1705,21 +1705,21 @@ Run a workflow source file as a run-once durable run on sdkdurableapi (no deploy
1705
1705
 
1706
1706
  **Parameters:**
1707
1707
 
1708
- | Name | Type | Required | Default | Possible Values | Description |
1709
- | ---------------------------- | ---------- | -------- | ------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
1710
- | `options` | `object` | ✅ | — | — | |
1711
- | ​ ↳ `source_files` | `object` | ✅ | — | — | Source files keyed by filename → contents |
1712
- | ​ ↳ `input` | `unknown` | ❌ | — | — | Input data passed to the run |
1713
- | ​ ↳ `dependencies` | `object` | ❌ | — | — | Optional npm package dependencies |
1714
- | ​ ↳ `zapier_durable_version` | `string` | ❌ | — | — | Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted. |
1715
- | ​ ↳ `connections` | `object` | ❌ | — | — | Named connection aliases. Maps each alias to an object holding its Zapier connection ID, e.g. `{ "slack": { "connection_id": "123" } }`. |
1716
- | ​ ↳ `app_versions` | `object` | ❌ | — | — | Pinned app versions. Maps app keys (slugs) to implementation names and versions. |
1717
- | ​ ↳ `private` | `boolean` | ❌ | — | — | Only the creating user can see the run (default false) |
1718
- | ​ ↳ `notifications[]` | `object[]` | ❌ | — | — | Webhook subscribers for run lifecycle events. Each entry specifies a URL and the events it subscribes to. |
1719
- | ​   ↳ `type` | `string` | ❌ | — | `webhook` | Notification transport. Webhook is the only supported type. |
1720
- | ​   ↳ `url` | `string` | ✅ | — | — | URL to POST event notifications to. Payload is `{run_id, event}`. |
1721
- | ​   ↳ `max_retries` | `number` | ❌ | — | — | Max delivery attempts with exponential backoff. Defaults to 3 server-side. |
1722
- | ​   ↳ `events` | `array` | ✅ | — | — | One or more lifecycle events to subscribe this URL to. |
1708
+ | Name | Type | Required | Default | Possible Values | Description |
1709
+ | -------------------------- | ---------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
1710
+ | `options` | `object` | ✅ | — | — | |
1711
+ | ​ ↳ `sourceFiles` | `object` | ✅ | — | — | Source files keyed by filename → contents |
1712
+ | ​ ↳ `input` | `unknown` | ❌ | — | — | Input data passed to the run |
1713
+ | ​ ↳ `dependencies` | `object` | ❌ | — | — | Optional npm package dependencies |
1714
+ | ​ ↳ `zapierDurableVersion` | `string` | ❌ | — | — | Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted. |
1715
+ | ​ ↳ `connections` | `object` | ❌ | — | — | Named connection aliases. Maps each alias to an object holding its Zapier connection ID, e.g. `{ "slack": { "connectionId": "123" } }`. |
1716
+ | ​ ↳ `appVersions` | `object` | ❌ | — | — | Pinned app versions. Maps app keys (slugs) to implementation names and versions. |
1717
+ | ​ ↳ `private` | `boolean` | ❌ | — | — | Only the creating user can see the run (default false) |
1718
+ | ​ ↳ `notifications[]` | `object[]` | ❌ | — | — | Webhook subscribers for run lifecycle events. Each entry specifies a URL and the events it subscribes to. |
1719
+ | ​   ↳ `type` | `string` | ❌ | — | `webhook` | Notification transport. Webhook is the only supported type. |
1720
+ | ​   ↳ `url` | `string` | ✅ | — | — | URL to POST event notifications to. Payload is `{run_id, event}`. |
1721
+ | ​   ↳ `max_retries` | `number` | ❌ | — | — | Max delivery attempts with exponential backoff. Defaults to 3 server-side. |
1722
+ | ​   ↳ `events` | `array` | ✅ | — | — | One or more lifecycle events to subscribe this URL to. |
1723
1723
 
1724
1724
  **Returns:** `Promise<DurableRunItem>`
1725
1725
 
@@ -1735,7 +1735,7 @@ Run a workflow source file as a run-once durable run on sdkdurableapi (no deploy
1735
1735
 
1736
1736
  ```typescript
1737
1737
  const result = await zapier.runDurable({
1738
- source_files: {},
1738
+ sourceFiles: {},
1739
1739
  });
1740
1740
  ```
1741
1741
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AAokDjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AA0kDjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
@@ -13,6 +13,7 @@ import { getZapierBaseUrl, isLocalhostBaseUrl } from "../utils/url-utils";
13
13
  import { sleep, calculateExponentialBackoffMs } from "../utils/retry-utils";
14
14
  import { isPlainObject } from "../utils/type-guard-utils";
15
15
  import { isAbortError } from "../utils/abort-utils";
16
+ import { getCallerContext } from "../utils/caller-context";
16
17
  import { createSseParserStream, jsonFrames, } from "./sse-parser";
17
18
  import { consumeApprovalReviewStream } from "./approval-review-stream";
18
19
  import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierConfigurationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
@@ -771,6 +772,10 @@ class ZapierApiClient {
771
772
  headers.set("x-zapier-sdk-package", callerPackage.name);
772
773
  headers.set("zapier-sdk-package-version", callerPackage.version);
773
774
  headers.set("x-zapier-sdk-package-version", callerPackage.version);
775
+ const { packageOperation } = getCallerContext();
776
+ if (packageOperation) {
777
+ headers.set("zapier-sdk-package-operation", packageOperation);
778
+ }
774
779
  }
775
780
  }
776
781
  // Helper to perform HTTP requests with JSON handling
@@ -475,22 +475,34 @@ function createValidator(schema, { adaptError } = {}) {
475
475
  };
476
476
  }
477
477
  var validateOptions = (schema, options, { adaptError } = {}) => parseOrThrow(schema, options, { adaptError });
478
- var scopeStore = null;
479
- try {
480
- scopeStore = new async_hooks.AsyncLocalStorage();
481
- } catch {
478
+ function createAsyncContext() {
479
+ let store = null;
480
+ try {
481
+ store = new async_hooks.AsyncLocalStorage();
482
+ } catch {
483
+ store = null;
484
+ }
485
+ return {
486
+ available: store !== null,
487
+ run(value, fn) {
488
+ return store ? store.run(value, fn) : fn();
489
+ },
490
+ get() {
491
+ return store?.getStore();
492
+ }
493
+ };
482
494
  }
495
+ var scope = createAsyncContext();
483
496
  function getCurrentScope() {
484
- if (!scopeStore) return void 0;
485
- return scopeStore.getStore();
497
+ return scope.get();
486
498
  }
487
499
  function getCurrentDepth() {
488
500
  return getCurrentScope()?.depth ?? 0;
489
501
  }
490
502
  function runInMethodScope(fn) {
491
- if (!scopeStore) return fn();
492
- const currentDepth = scopeStore.getStore()?.depth ?? -1;
493
- return scopeStore.run({ depth: currentDepth + 1 }, fn);
503
+ if (!scope.available) return fn();
504
+ const currentDepth = scope.get()?.depth ?? -1;
505
+ return scope.run({ depth: currentDepth + 1 }, fn);
494
506
  }
495
507
  var runWithTelemetryContext = runInMethodScope;
496
508
  function normalizeError(error, adaptError) {
@@ -2868,10 +2880,10 @@ function mergeScopes(credentialsScope, requiredScopes) {
2868
2880
  return [...scopeSet].sort();
2869
2881
  }
2870
2882
  async function exchangeClientCredentials(options) {
2871
- const { clientId, clientSecret, baseUrl, scope, requiredScopes, onEvent } = options;
2883
+ const { clientId, clientSecret, baseUrl, scope: scope2, requiredScopes, onEvent } = options;
2872
2884
  const fetchFn = options.fetch || globalThis.fetch;
2873
2885
  const tokenUrl = getTokenEndpointUrl(baseUrl);
2874
- const mergedScopes = mergeScopes(scope, requiredScopes);
2886
+ const mergedScopes = mergeScopes(scope2, requiredScopes);
2875
2887
  const scopeString = mergedScopes.join(" ");
2876
2888
  onEvent?.({
2877
2889
  type: "auth_exchanging",
@@ -3136,6 +3148,25 @@ async function invalidateCredentialsToken(options) {
3136
3148
  }
3137
3149
  }
3138
3150
 
3151
+ // src/utils/caller-context.ts
3152
+ var callerContext = createAsyncContext();
3153
+ function runWithCallerContext(context, fn) {
3154
+ let parent;
3155
+ try {
3156
+ parent = callerContext.get() ?? {};
3157
+ } catch {
3158
+ return fn();
3159
+ }
3160
+ return callerContext.run({ ...parent, ...context }, fn);
3161
+ }
3162
+ function getCallerContext() {
3163
+ try {
3164
+ return callerContext.get() ?? {};
3165
+ } catch {
3166
+ return {};
3167
+ }
3168
+ }
3169
+
3139
3170
  // src/api/sse-parser.ts
3140
3171
  async function* jsonFrames(source) {
3141
3172
  for await (const { data } of source) {
@@ -3287,7 +3318,7 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
3287
3318
  }
3288
3319
 
3289
3320
  // src/sdk-version.ts
3290
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.73.0" : void 0) || "unknown";
3321
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.74.0" : void 0) || "unknown";
3291
3322
 
3292
3323
  // src/utils/open-url.ts
3293
3324
  var nodePrefix = "node:";
@@ -4011,6 +4042,10 @@ var ZapierApiClient = class {
4011
4042
  headers.set("x-zapier-sdk-package", callerPackage.name);
4012
4043
  headers.set("zapier-sdk-package-version", callerPackage.version);
4013
4044
  headers.set("x-zapier-sdk-package-version", callerPackage.version);
4045
+ const { packageOperation } = getCallerContext();
4046
+ if (packageOperation) {
4047
+ headers.set("zapier-sdk-package-operation", packageOperation);
4048
+ }
4014
4049
  }
4015
4050
  }
4016
4051
  // Helper to perform HTTP requests with JSON handling
@@ -6086,10 +6121,10 @@ var actionItemFormatter = {
6086
6121
  // src/plugins/eventEmission/method-metadata.ts
6087
6122
  var SCOPE_KEY = "methodMetadata";
6088
6123
  function setMethodMetadata(metadata) {
6089
- const scope = getCurrentScope();
6090
- if (!scope) return;
6091
- const existing = scope[SCOPE_KEY];
6092
- scope[SCOPE_KEY] = { ...existing, ...metadata };
6124
+ const scope2 = getCurrentScope();
6125
+ if (!scope2) return;
6126
+ const existing = scope2[SCOPE_KEY];
6127
+ scope2[SCOPE_KEY] = { ...existing, ...metadata };
6093
6128
  }
6094
6129
  function getMethodMetadata() {
6095
6130
  return getCurrentScope()?.[SCOPE_KEY];
@@ -11756,13 +11791,62 @@ var getTriggerInputFieldsSchemaPlugin = definePlugin(
11756
11791
  }
11757
11792
  })
11758
11793
  );
11759
-
11760
- // src/plugins/codeSubstrate/shared.ts
11761
11794
  var codeSubstrateDefaults = {
11762
11795
  categories: ["code-workflow"],
11763
11796
  experimental: true
11764
11797
  };
11798
+ var SourceFilesSchema = zod.z.record(zod.z.string(), zod.z.string()).refine((files) => Object.keys(files).length > 0, {
11799
+ message: "sourceFiles must contain at least one file"
11800
+ }).describe("Source files keyed by filename \u2192 contents");
11801
+ var UUID_PATTERN = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
11802
+ var ConnectionIdValueSchema = zod.z.union([
11803
+ zod.z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
11804
+ zod.z.string().regex(UUID_PATTERN, "must be a UUID"),
11805
+ zod.z.number().int().positive()
11806
+ ]).describe(
11807
+ "Zapier connection ID. Accepts a positive integer (legacy) or a UUID string (newer connections)."
11808
+ );
11765
11809
  var ConnectionBindingSchema = zod.z.object({
11810
+ connectionId: ConnectionIdValueSchema.optional(),
11811
+ /** @deprecated Use `connectionId` instead. */
11812
+ connection_id: ConnectionIdValueSchema.optional().meta({ deprecated: true })
11813
+ });
11814
+ var AppVersionBindingSchema = zod.z.object({
11815
+ implementationName: zod.z.string().min(1).optional().describe("Zapier app implementation name (e.g. `SlackCLIAPI`)"),
11816
+ /** @deprecated Use `implementationName` instead. */
11817
+ implementation_name: zod.z.string().min(1).optional().meta({ deprecated: true }),
11818
+ version: zod.z.string().optional().describe("Pinned app version (e.g. `1.27.1`). Latest if omitted.")
11819
+ });
11820
+ function toWireConnections(connections) {
11821
+ const wire = {};
11822
+ for (const [alias, entry] of Object.entries(connections)) {
11823
+ const connectionId = entry.connectionId ?? entry.connection_id;
11824
+ if (connectionId === void 0) {
11825
+ throw new ZapierValidationError(
11826
+ `connections["${alias}"] is missing connectionId`
11827
+ );
11828
+ }
11829
+ wire[alias] = { connection_id: connectionId };
11830
+ }
11831
+ return wire;
11832
+ }
11833
+ function toWireAppVersions(appVersions) {
11834
+ const wire = {};
11835
+ for (const [key, entry] of Object.entries(appVersions)) {
11836
+ const implementationName = entry.implementationName ?? entry.implementation_name;
11837
+ if (implementationName === void 0) {
11838
+ throw new ZapierValidationError(
11839
+ `appVersions["${key}"] is missing implementationName`
11840
+ );
11841
+ }
11842
+ wire[key] = {
11843
+ implementation_name: implementationName,
11844
+ ...entry.version !== void 0 ? { version: entry.version } : {}
11845
+ };
11846
+ }
11847
+ return wire;
11848
+ }
11849
+ var ConnectionBindingSchema2 = zod.z.object({
11766
11850
  connection_id: zod.z.union([
11767
11851
  zod.z.number().int().positive(),
11768
11852
  zod.z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
@@ -11773,7 +11857,7 @@ var ConnectionBindingSchema = zod.z.object({
11773
11857
  }).describe(
11774
11858
  "Connection binding: maps a single alias to a concrete connection."
11775
11859
  );
11776
- var AppVersionBindingSchema = zod.z.object({
11860
+ var AppVersionBindingSchema2 = zod.z.object({
11777
11861
  implementation_name: zod.z.string().describe("App implementation identifier (e.g. 'SlackCLIAPI')"),
11778
11862
  version: zod.z.string().optional().describe("App implementation version (e.g. '1.27.1')")
11779
11863
  }).describe("App-version binding: maps a single alias to an app version.");
@@ -11891,8 +11975,8 @@ var WorkflowVersionSchema = zod.z.object({
11891
11975
  trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
11892
11976
  "Trigger configuration persisted on this version, or null for webhook-only workflows."
11893
11977
  ),
11894
- connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).nullable().describe("Connection aliases bound on this version (or null)."),
11895
- app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullable().describe("App-version pins bound on this version (or null).")
11978
+ connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
11979
+ app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null).")
11896
11980
  });
11897
11981
  var GetWorkflowOptionsSchema = zod.z.object({
11898
11982
  workflow: zod.z.string().uuid().describe("Durable workflow ID")
@@ -12343,19 +12427,6 @@ var getDurableRunPlugin = definePlugin(
12343
12427
  }
12344
12428
  })
12345
12429
  );
12346
- var ConnectionMapEntrySchema = zod.z.object({
12347
- connection_id: zod.z.union([
12348
- zod.z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
12349
- zod.z.string().uuid("must be a UUID"),
12350
- zod.z.number().int().positive()
12351
- ]).describe(
12352
- "Zapier connection ID. Accepts a positive integer (legacy) or a UUID string (newer connections)."
12353
- )
12354
- });
12355
- var AppVersionMapEntrySchema = zod.z.object({
12356
- implementation_name: zod.z.string().min(1).describe("Zapier app implementation name (e.g. `SlackCLIAPI`)"),
12357
- version: zod.z.string().optional().describe("Pinned app version (e.g. `1.27.1`). Latest if omitted.")
12358
- });
12359
12430
  var RunNotificationEventSchema = zod.z.enum(["started", "progress", "completed", "error", "cancelled"]).describe("Run lifecycle event this notification subscribes to");
12360
12431
  var RunNotificationSchema = zod.z.object({
12361
12432
  type: zod.z.literal("webhook").optional().describe("Notification transport. Webhook is the only supported type."),
@@ -12369,28 +12440,37 @@ var RunNotificationSchema = zod.z.object({
12369
12440
  }).describe(
12370
12441
  "Webhook subscriber for run lifecycle events. Server POSTs `{run_id, event}` on each subscribed transition."
12371
12442
  );
12372
- var RunDurableOptionsSchema = zod.z.object({
12373
- source_files: zod.z.record(zod.z.string(), zod.z.string()).refine((files) => Object.keys(files).length > 0, {
12374
- message: "source_files must contain at least one file"
12375
- }).describe("Source files keyed by filename \u2192 contents"),
12443
+ var RunDurableBaseSchema = zod.z.object({
12376
12444
  input: zod.z.unknown().optional().describe("Input data passed to the run"),
12377
12445
  dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("Optional npm package dependencies"),
12378
- zapier_durable_version: zod.z.string().optional().describe(
12446
+ zapierDurableVersion: zod.z.string().optional().describe(
12379
12447
  'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted.'
12380
12448
  ),
12381
- connections: zod.z.record(zod.z.string(), ConnectionMapEntrySchema).optional().describe(
12382
- 'Named connection aliases. Maps each alias to an object holding its Zapier connection ID, e.g. `{ "slack": { "connection_id": "123" } }`.'
12449
+ /** @deprecated Use `zapierDurableVersion` instead. */
12450
+ zapier_durable_version: zod.z.string().optional().meta({ deprecated: true }),
12451
+ connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).optional().describe(
12452
+ 'Named connection aliases. Maps each alias to an object holding its Zapier connection ID, e.g. `{ "slack": { "connectionId": "123" } }`.'
12383
12453
  ),
12384
- app_versions: zod.z.record(zod.z.string(), AppVersionMapEntrySchema).optional().describe(
12454
+ appVersions: zod.z.record(zod.z.string(), AppVersionBindingSchema).optional().describe(
12385
12455
  "Pinned app versions. Maps app keys (slugs) to implementation names and versions."
12386
12456
  ),
12457
+ /** @deprecated Use `appVersions` instead. */
12458
+ app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).optional().meta({ deprecated: true }),
12387
12459
  private: zod.z.boolean().optional().describe("Only the creating user can see the run (default false)"),
12388
12460
  notifications: zod.z.array(RunNotificationSchema).optional().describe(
12389
12461
  "Webhook subscribers for run lifecycle events. Each entry specifies a URL and the events it subscribes to."
12390
12462
  )
12391
- }).describe(
12392
- "Run a workflow source file as a run-once durable run on sdkdurableapi (no deployed workflow required). Returns the run ID immediately; poll via getDurableRun for terminal status."
12393
- );
12463
+ });
12464
+ var RunDurableDescription = "Run a workflow source file as a run-once durable run on sdkdurableapi (no deployed workflow required). Returns the run ID immediately; poll via getDurableRun for terminal status.";
12465
+ var RunDurableSchema = zod.z.object({ sourceFiles: SourceFilesSchema }).merge(RunDurableBaseSchema).describe(RunDurableDescription).meta({
12466
+ aliases: {
12467
+ source_files: "sourceFiles",
12468
+ zapier_durable_version: "zapierDurableVersion",
12469
+ app_versions: "appVersions"
12470
+ }
12471
+ });
12472
+ var RunDurableSchemaDeprecated = zod.z.object({ source_files: SourceFilesSchema }).merge(RunDurableBaseSchema);
12473
+ var RunDurableOptionsSchema = zod.z.union([RunDurableSchema, RunDurableSchemaDeprecated]).describe(RunDurableDescription);
12394
12474
  var RunDurableResponseSchema = zod.z.object({
12395
12475
  id: zod.z.string().describe("Run ID (UUID) \u2014 server-generated, time-sortable"),
12396
12476
  status: zod.z.literal("initialized").describe(
@@ -12412,23 +12492,24 @@ var runDurablePlugin = definePlugin(
12412
12492
  inputSchema: RunDurableOptionsSchema,
12413
12493
  outputSchema: RunDurableResponseSchema,
12414
12494
  handler: async ({ sdk: sdk2, options }) => {
12415
- const body = {
12416
- source_files: options.source_files
12417
- };
12495
+ const sourceFiles = "sourceFiles" in options ? options.sourceFiles : options.source_files;
12496
+ const zapierDurableVersion = options.zapierDurableVersion ?? options.zapier_durable_version;
12497
+ const appVersions = options.appVersions ?? options.app_versions;
12498
+ const body = { source_files: sourceFiles };
12418
12499
  if (options.input !== void 0) {
12419
12500
  body.input = options.input;
12420
12501
  }
12421
12502
  if (options.dependencies !== void 0) {
12422
12503
  body.dependencies = options.dependencies;
12423
12504
  }
12424
- if (options.zapier_durable_version !== void 0) {
12425
- body.zapier_durable_version = options.zapier_durable_version;
12505
+ if (zapierDurableVersion !== void 0) {
12506
+ body.zapier_durable_version = zapierDurableVersion;
12426
12507
  }
12427
12508
  if (options.connections !== void 0) {
12428
- body.connections = options.connections;
12509
+ body.connections = toWireConnections(options.connections);
12429
12510
  }
12430
- if (options.app_versions !== void 0) {
12431
- body.app_versions = options.app_versions;
12511
+ if (appVersions !== void 0) {
12512
+ body.app_versions = toWireAppVersions(appVersions);
12432
12513
  }
12433
12514
  if (options.private !== void 0) {
12434
12515
  body.is_private = options.private;
@@ -12483,30 +12564,61 @@ var cancelDurableRunPlugin = definePlugin(
12483
12564
  }
12484
12565
  })
12485
12566
  );
12486
- var PublishWorkflowVersionOptionsSchema = zod.z.object({
12487
- workflow: zod.z.string().uuid().describe("Durable workflow ID"),
12488
- source_files: zod.z.record(zod.z.string(), zod.z.string()).refine((files) => Object.keys(files).length > 0, {
12489
- message: "source_files must contain at least one file"
12490
- }).describe("Source files keyed by filename \u2192 contents"),
12567
+ var TriggerConfigSchema = zod.z.object({
12568
+ selectedApi: zod.z.string().optional().describe(
12569
+ "Zapier app/API identifier (e.g. 'GoogleSheetsAPI'). Required when a trigger is configured."
12570
+ ),
12571
+ /** @deprecated Use `selectedApi` instead. */
12572
+ selected_api: zod.z.string().optional().meta({ deprecated: true }),
12573
+ action: zod.z.string().describe("Trigger action key (e.g. 'new_row')"),
12574
+ authenticationId: zod.z.string().nullish().describe(
12575
+ "Connection ID for the trigger source. Omit or pass null for no-auth triggers (e.g. Schedule by Zapier)."
12576
+ ),
12577
+ /** @deprecated Use `authenticationId` instead. */
12578
+ authentication_id: zod.z.string().nullish().meta({ deprecated: true }),
12579
+ params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Trigger parameters as a JSON object")
12580
+ }).describe(
12581
+ "Zapier trigger configuration. When set, the workflow subscribes to trigger events."
12582
+ );
12583
+ var PublishWorkflowVersionDescription = "Publish a new version of a durable workflow. Enables the workflow by default.";
12584
+ var PublishWorkflowVersionBaseSchema = zod.z.object({
12491
12585
  dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("Optional npm package dependencies"),
12492
- zapier_durable_version: zod.z.string().optional().describe(
12586
+ zapierDurableVersion: zod.z.string().optional().describe(
12493
12587
  'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted.'
12494
12588
  ),
12589
+ /** @deprecated Use `zapierDurableVersion` instead. */
12590
+ zapier_durable_version: zod.z.string().optional().meta({ deprecated: true }),
12495
12591
  enabled: zod.z.boolean().optional().describe(
12496
12592
  "Enable the workflow after publishing. Defaults to true; pass false to publish without enabling."
12497
12593
  ),
12498
12594
  connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).nullish().describe(
12499
12595
  "Map of connection aliases to Zapier connections used by the workflow. Pass `null` to clear an existing binding."
12500
12596
  ),
12501
- app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullish().describe(
12597
+ appVersions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullish().describe(
12502
12598
  "Map of app keys to pinned app implementation/version used by the workflow. Pass `null` to clear an existing binding."
12503
12599
  ),
12504
- trigger: WorkflowVersionTriggerConfigSchema.optional().describe(
12600
+ /** @deprecated Use `appVersions` instead. */
12601
+ app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullish().meta({ deprecated: true }),
12602
+ trigger: TriggerConfigSchema.optional().describe(
12505
12603
  "Trigger configuration. When provided, the workflow subscribes to a Zapier trigger; omit for webhook-only workflows."
12506
12604
  )
12507
- }).describe(
12508
- "Publish a new version of a durable workflow. Enables the workflow by default."
12509
- );
12605
+ });
12606
+ var WorkflowPropertySchema = zod.z.string().uuid().describe("Durable workflow ID");
12607
+ var PublishWorkflowVersionSchema = zod.z.object({
12608
+ workflow: WorkflowPropertySchema,
12609
+ sourceFiles: SourceFilesSchema
12610
+ }).merge(PublishWorkflowVersionBaseSchema).describe(PublishWorkflowVersionDescription).meta({
12611
+ aliases: {
12612
+ source_files: "sourceFiles",
12613
+ zapier_durable_version: "zapierDurableVersion",
12614
+ app_versions: "appVersions"
12615
+ }
12616
+ });
12617
+ var PublishWorkflowVersionSchemaDeprecated = zod.z.object({
12618
+ workflow: WorkflowPropertySchema,
12619
+ source_files: SourceFilesSchema
12620
+ }).merge(PublishWorkflowVersionBaseSchema);
12621
+ var PublishWorkflowVersionOptionsSchema = zod.z.union([PublishWorkflowVersionSchema, PublishWorkflowVersionSchemaDeprecated]).describe(PublishWorkflowVersionDescription);
12510
12622
  var PublishWorkflowVersionResponseSchema = zod.z.object({
12511
12623
  id: zod.z.string().describe("Workflow version ID (UUID)"),
12512
12624
  workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
@@ -12520,11 +12632,30 @@ var PublishWorkflowVersionResponseSchema = zod.z.object({
12520
12632
  trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
12521
12633
  "Trigger configuration persisted on this version, or null for webhook-only workflows."
12522
12634
  ),
12523
- connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).nullable().describe("Connection aliases bound on this version (or null)."),
12524
- app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullable().describe("App-version pins bound on this version (or null).")
12635
+ connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
12636
+ app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null).")
12525
12637
  });
12526
12638
 
12527
12639
  // src/plugins/codeSubstrate/publishWorkflowVersion/index.ts
12640
+ function toWireTrigger(trigger) {
12641
+ const selectedApi = trigger.selectedApi ?? trigger.selected_api;
12642
+ if (selectedApi === void 0) {
12643
+ throw new ZapierValidationError("trigger is missing selectedApi");
12644
+ }
12645
+ const wire = {
12646
+ selected_api: selectedApi,
12647
+ action: trigger.action
12648
+ };
12649
+ if ("authenticationId" in trigger) {
12650
+ wire.authentication_id = trigger.authenticationId;
12651
+ } else if ("authentication_id" in trigger) {
12652
+ wire.authentication_id = trigger.authentication_id;
12653
+ }
12654
+ if (trigger.params !== void 0) {
12655
+ wire.params = trigger.params;
12656
+ }
12657
+ return wire;
12658
+ }
12528
12659
  var publishWorkflowVersionPlugin = definePlugin(
12529
12660
  (sdk) => createPluginMethod(sdk, {
12530
12661
  ...codeSubstrateDefaults,
@@ -12535,26 +12666,31 @@ var publishWorkflowVersionPlugin = definePlugin(
12535
12666
  outputSchema: PublishWorkflowVersionResponseSchema,
12536
12667
  resolvers: { workflow: workflowIdResolver },
12537
12668
  handler: async ({ sdk: sdk2, options }) => {
12538
- const body = {
12539
- source_files: options.source_files
12540
- };
12669
+ const sourceFiles = "sourceFiles" in options ? options.sourceFiles : options.source_files;
12670
+ const zapierDurableVersion = options.zapierDurableVersion ?? options.zapier_durable_version;
12671
+ const appVersions = "appVersions" in options ? options.appVersions : options.app_versions;
12672
+ const body = { source_files: sourceFiles };
12541
12673
  if (options.dependencies !== void 0) {
12542
12674
  body.dependencies = options.dependencies;
12543
12675
  }
12544
- if (options.zapier_durable_version !== void 0) {
12545
- body.zapier_durable_version = options.zapier_durable_version;
12676
+ if (zapierDurableVersion !== void 0) {
12677
+ body.zapier_durable_version = zapierDurableVersion;
12546
12678
  }
12547
12679
  if (options.enabled !== void 0) {
12548
12680
  body.enabled = options.enabled;
12549
12681
  }
12550
- if (options.connections !== void 0) {
12551
- body.connections = options.connections;
12682
+ if (options.connections === null) {
12683
+ body.connections = null;
12684
+ } else if (options.connections !== void 0) {
12685
+ body.connections = toWireConnections(options.connections);
12552
12686
  }
12553
- if (options.app_versions !== void 0) {
12554
- body.app_versions = options.app_versions;
12687
+ if (appVersions === null) {
12688
+ body.app_versions = null;
12689
+ } else if (appVersions !== void 0) {
12690
+ body.app_versions = toWireAppVersions(appVersions);
12555
12691
  }
12556
12692
  if (options.trigger !== void 0) {
12557
- body.trigger = options.trigger;
12693
+ body.trigger = toWireTrigger(options.trigger);
12558
12694
  }
12559
12695
  const raw = await sdk2.context.api.post(
12560
12696
  `/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}/versions`,
@@ -12581,8 +12717,8 @@ var WorkflowVersionListItemSchema = zod.z.object({
12581
12717
  trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
12582
12718
  "Trigger configuration persisted on this version, or null for webhook-only workflows."
12583
12719
  ),
12584
- connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).nullable().describe("Connection aliases bound on this version (or null)."),
12585
- app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullable().describe("App-version pins bound on this version (or null).")
12720
+ connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
12721
+ app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null).")
12586
12722
  });
12587
12723
  var ListWorkflowVersionsOptionsSchema = zod.z.object({
12588
12724
  workflow: zod.z.string().uuid().describe("Durable workflow ID"),
@@ -12654,8 +12790,8 @@ var GetWorkflowVersionResponseSchema = zod.z.object({
12654
12790
  trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
12655
12791
  "Trigger configuration persisted on this version, or null for webhook-only workflows."
12656
12792
  ),
12657
- connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).nullable().describe("Connection aliases bound on this version (or null)."),
12658
- app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullable().describe("App-version pins bound on this version (or null).")
12793
+ connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
12794
+ app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null).")
12659
12795
  });
12660
12796
 
12661
12797
  // src/plugins/codeSubstrate/getWorkflowVersion/index.ts
@@ -13226,6 +13362,7 @@ exports.getActionPlugin = getActionPlugin;
13226
13362
  exports.getAgent = getAgent;
13227
13363
  exports.getAppPlugin = getAppPlugin;
13228
13364
  exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;
13365
+ exports.getCallerContext = getCallerContext;
13229
13366
  exports.getCiPlatform = getCiPlatform;
13230
13367
  exports.getClientIdFromCredentials = getClientIdFromCredentials;
13231
13368
  exports.getConnectionPlugin = getConnectionPlugin;
@@ -13284,6 +13421,7 @@ exports.resolveCredentials = resolveCredentials;
13284
13421
  exports.resolveCredentialsFromEnv = resolveCredentialsFromEnv;
13285
13422
  exports.runActionPlugin = runActionPlugin;
13286
13423
  exports.runInMethodScope = runInMethodScope;
13424
+ exports.runWithCallerContext = runWithCallerContext;
13287
13425
  exports.runWithTelemetryContext = runWithTelemetryContext;
13288
13426
  exports.tableFieldIdsResolver = tableFieldIdsResolver;
13289
13427
  exports.tableFieldsResolver = tableFieldsResolver;