@zapier/zapier-sdk 0.100.0 → 0.101.1

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,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.101.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e0fcb04: `sdk.apps` now runs actions for apps that do not require a connection without rejecting the call before execution.
8
+
9
+ ## 0.101.0
10
+
11
+ ### Minor Changes
12
+
13
+ - cfc7020: Added `importWorkflow` (experimental), exposed in the CLI as `import-workflow`. Converts an existing Zap into a durable workflow: pass `zap` (the Zap ID) and optionally `name` and `private`. Returns `{ workflow, draft, issues }`. The workflow is created disabled with no published version; publish the draft to make it live, once any blocking `issues` are resolved. The original Zap is untouched.
14
+
3
15
  ## 0.100.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -42,6 +42,7 @@
42
42
  - [`getWorkflowDraft`](#getworkflowdraft--experimental)
43
43
  - [`getWorkflowRun`](#getworkflowrun--experimental)
44
44
  - [`getWorkflowVersion`](#getworkflowversion--experimental)
45
+ - [`importWorkflow`](#importworkflow--experimental)
45
46
  - [`listDurableRuns`](#listdurableruns--experimental)
46
47
  - [`listWorkflowDrafts`](#listworkflowdrafts--experimental)
47
48
  - [`listWorkflowRuns`](#listworkflowruns--experimental)
@@ -1671,6 +1672,81 @@ const { data: workflowVersion } = await zapier.getWorkflowVersion({
1671
1672
  });
1672
1673
  ```
1673
1674
 
1675
+ #### `importWorkflow` 🧪 _experimental_
1676
+
1677
+ Convert an existing Zap into a durable workflow. Transforms the Zap's latest published version (falling back to its draft only when the Zap has never been published) and puts the resulting source in an open draft. The workflow is created disabled with no published version, so publish the draft to make it live. The original Zap is untouched and keeps running.
1678
+
1679
+ **Parameters:**
1680
+
1681
+ | Name | Type | Required | Default | Possible Values | Description |
1682
+ | ------------- | --------- | -------- | ------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
1683
+ | `options` | `object` | ✅ | — | — | |
1684
+ | ​ ↳ `zap` | `string` | ✅ | — | — | ID of the Zap to import. Must be owned by the requesting user. Recorded on the created workflow as source_zap_id. |
1685
+ | ​ ↳ `name` | `string` | ❌ | — | — | Name for the created workflow. Defaults to a kebab-cased form of the Zap's title, or "imported-workflow" when the Zap has no title. |
1686
+ | ​ ↳ `private` | `boolean` | ❌ | — | — | Restrict the created workflow to the creating user. Defaults to false, which makes it account-visible. |
1687
+
1688
+ **Returns:** `Promise<ImportWorkflowResponse>`
1689
+
1690
+ | Name | Type | Required | Possible Values | Description |
1691
+ | ------------------------------ | ---------- | -------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1692
+ | `data` | `object` | ✅ | — | |
1693
+ | ​ ↳ `workflow` | `object` | ✅ | — | The created workflow. Disabled, with no published version, and source_zap_id set to the imported Zap. |
1694
+ | ​   ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1695
+ | ​   ↳ `name` | `string` | ✅ | — | Workflow name |
1696
+ | ​   ↳ `description` | `string` | ❌ | — | Optional workflow description (null if unset) |
1697
+ | ​   ↳ `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. |
1698
+ | ​   ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow accepts triggers. An import always lands disabled. |
1699
+ | ​   ↳ `disabled_reason` | `string` | ❌ | `trigger_claim_failed` | Why the workflow is off, when system-disabled. |
1700
+ | ​   ↳ `is_private` | `boolean` | ✅ | — | Whether the workflow is private to the creating user. False means account-visible. |
1701
+ | ​   ↳ `source_zap_id` | `string` | ❌ | — | The Zap this workflow was imported from. |
1702
+ | ​   ↳ `created_by_user_id` | `string` | ✅ | — | |
1703
+ | ​   ↳ `updated_by_user_id` | `string` | ❌ | — | |
1704
+ | ​   ↳ `current_version_id` | `string` | ❌ | — | Null on a fresh import, which has no published version yet. |
1705
+ | ​   ↳ `triggers[]` | `object[]` | ✅ | — | Empty on a fresh import, which has no published version yet. |
1706
+ | ​     ↳ `selected_api` | `string` | ✅ | — | Zapier app/API identifier (e.g. 'GoogleSheetsAPI') |
1707
+ | ​     ↳ `action` | `string` | ✅ | — | Trigger action key (e.g. 'new_row') |
1708
+ | ​     ↳ `authentication_id` | `string` | ❌ | — | Connection ID for the trigger source. Null for no-auth triggers. |
1709
+ | ​     ↳ `params` | `object` | ❌ | — | Trigger parameters as a JSON object |
1710
+ | ​     ↳ `status` | `string` | ✅ | `unclaimed`, `pending`, `active`, `releasing`, `released`, `failed` | Live trigger claim status — whether the trigger is currently subscribed to its source. |
1711
+ | ​     ↳ `error` | `string` | ❌ | — | Failure reason for the latest claim. Present (non-null) only when status is 'failed'. |
1712
+ | ​     ↳ `details` | `object` | ❌ | — | Trigger-type-specific metadata; shape varies by trigger type (e.g. `webhook_url` on catch-hook triggers). Null or absent when none applies. |
1713
+ | ​   ↳ `created_at` | `string` | ✅ | — | |
1714
+ | ​   ↳ `updated_at` | `string` | ❌ | — | |
1715
+ | ​ ↳ `draft` | `object` | ✅ | — | The open draft holding the transformed source. |
1716
+ | ​   ↳ `id` | `string` | ✅ | — | Workflow draft ID (UUID) |
1717
+ | ​   ↳ `workflow_id` | `string` | ✅ | — | Parent workflow ID (UUID) |
1718
+ | ​   ↳ `slug` | `string` | ✅ | — | Human-friendly identifier for URL routing; unique among open drafts per workflow |
1719
+ | ​   ↳ `base_version_id` | `string` | ✅ | — | The version this draft was forked from (the live version at draft creation), or null when the workflow had no published version yet |
1720
+ | ​   ↳ `source_files` | `object` | ✅ | — | Source files keyed by filename → contents |
1721
+ | ​   ↳ `zapier_durable_version` | `string` | ✅ | — | Pinned semver of @zapier/zapier-durable used by this draft |
1722
+ | ​   ↳ `dependencies` | `object` | ✅ | — | Additional npm dependencies pinned for this draft (or null) |
1723
+ | ​   ↳ `draft_revision` | `number` | ✅ | — | Monotonic revision counter for optimistic concurrency. Echo it back on draft updates to detect concurrent edits. |
1724
+ | ​   ↳ `status` | `string` | ✅ | `open`, `discarded` | Lifecycle status of a workflow draft. |
1725
+ | ​   ↳ `created_by_user_id` | `string` | ✅ | — | ID of the user who created (forked) this draft |
1726
+ | ​   ↳ `last_edited_by_user_id` | `string` | ✅ | — | ID of the user who last saved this draft (or null) |
1727
+ | ​   ↳ `last_edited_at` | `string` | ✅ | — | When the draft was last edited (ISO-8601, or null) |
1728
+ | ​   ↳ `discarded_at` | `string` | ✅ | — | When the draft was discarded (ISO-8601), or null while open |
1729
+ | ​   ↳ `created_at` | `string` | ✅ | — | When the draft was created (ISO-8601) |
1730
+ | ​   ↳ `updated_at` | `string` | ✅ | — | When the draft row was last updated (ISO-8601) |
1731
+ | ​   ↳ `trigger` | `object` | ✅ | — | Trigger configuration held on this draft, or null for webhook-only workflows. |
1732
+ | ​   ↳ `connections` | `object` | ✅ | — | Connection aliases bound on this draft (or null). |
1733
+ | ​   ↳ `app_versions` | `object` | ✅ | — | App-version pins bound on this draft (or null). |
1734
+ | ​ ↳ `issues[]` | `object[]` | ✅ | — | Blocking and non-blocking translation issues from the transform, passed through unchanged. Blocking issues do not prevent draft creation; they must be resolved before the draft will publish. |
1735
+ | ​   ↳ `line` | `number` | ✅ | — | 1-based line in the generated source the issue relates to, or 0 when not line-specific. |
1736
+ | ​   ↳ `column` | `number` | ✅ | — | 1-based column, or 0 when not column-specific. |
1737
+ | ​   ↳ `node_kind` | `string` | ✅ | — | Category of the issue, used to group and message them, e.g. "invalid-connection-id", "DelayStep", "app-version-conflict". |
1738
+ | ​   ↳ `step_name` | `string` | ❌ | — | ZDL step id or name the issue originated from, when known. |
1739
+ | ​   ↳ `message` | `string` | ✅ | — | Human-readable description of the issue. |
1740
+ | ​   ↳ `blocking` | `boolean` | ✅ | — | Whether the issue must be resolved before the draft can be published. Computed server-side, so callers do not re-derive it. A blocking issue does not prevent the draft being created. |
1741
+
1742
+ **Example:**
1743
+
1744
+ ```typescript
1745
+ const { data: workflow } = await zapier.importWorkflow({
1746
+ zap: "example-zap",
1747
+ });
1748
+ ```
1749
+
1674
1750
  #### `listDurableRuns` 🧪 _experimental_
1675
1751
 
1676
1752
  List run-once durable runs for the authenticated account, newest first
@@ -6903,7 +6903,7 @@ function parseDeprecationDate(value) {
6903
6903
  }
6904
6904
 
6905
6905
  // src/sdk-version.ts
6906
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.100.0" : void 0) || "unknown";
6906
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.101.1" : void 0) || "unknown";
6907
6907
 
6908
6908
  // src/utils/open-url.ts
6909
6909
  var nodePrefix = "node:";
@@ -11345,8 +11345,7 @@ function resolveProxyConnection({
11345
11345
  providedConnection,
11346
11346
  providedAuthenticationId,
11347
11347
  pinnedAuthId,
11348
- pinnedConnection,
11349
- errorContext
11348
+ pinnedConnection
11350
11349
  }) {
11351
11350
  const hasDirectId = providedConnectionId != null || providedAuthenticationId != null;
11352
11351
  if (hasDirectId && providedConnection != null) {
@@ -11364,9 +11363,6 @@ function resolveProxyConnection({
11364
11363
  finalConnectionId = pinnedAuthId;
11365
11364
  finalConnection = pinnedAuthId != null ? void 0 : pinnedConnection;
11366
11365
  }
11367
- if (finalConnectionId == null && finalConnection == null) {
11368
- throw new ZapierValidationError(errorContext);
11369
- }
11370
11366
  return { connectionId: finalConnectionId, connection: finalConnection };
11371
11367
  }
11372
11368
  function createActionFunction(appKey, actionType, actionKey, imports, pinnedAuthId, pinnedConnection) {
@@ -11384,8 +11380,7 @@ function createActionFunction(appKey, actionType, actionKey, imports, pinnedAuth
11384
11380
  providedConnection,
11385
11381
  providedAuthenticationId,
11386
11382
  pinnedAuthId,
11387
- pinnedConnection,
11388
- errorContext: `Connection is required. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }) or sdk.apps.${appKey}({ connection: "name" }), or provide connectionId/connection in the action call.`
11383
+ pinnedConnection
11389
11384
  });
11390
11385
  return imports.runAction({
11391
11386
  app: appKey,
@@ -11406,9 +11401,13 @@ function createActionTypeProxy(appKey, actionType, imports, pinnedAuthId, pinned
11406
11401
  providedConnection: init?.connection,
11407
11402
  providedAuthenticationId: init?.authenticationId,
11408
11403
  pinnedAuthId,
11409
- pinnedConnection,
11410
- errorContext: `Connection is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }).fetch(...) or provide connectionId/connection in the fetch call.`
11404
+ pinnedConnection
11411
11405
  });
11406
+ if (connectionId == null && connection == null) {
11407
+ throw new ZapierValidationError(
11408
+ `Connection is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }).fetch(...) or provide connectionId/connection in the fetch call.`
11409
+ );
11410
+ }
11412
11411
  return imports.fetch(url, {
11413
11412
  ...init,
11414
11413
  connection: connectionId ?? connection
@@ -11462,11 +11461,6 @@ function createAppProxy(appKey, imports) {
11462
11461
  "Cannot specify both connectionId/authenticationId and connection. Use connectionId for a direct ID, or connection for an alias or numeric ID."
11463
11462
  );
11464
11463
  }
11465
- if (resolvedConnectionId == null && resolvedConnection == null) {
11466
- throw new ZapierValidationError(
11467
- `Connection is required. Use sdk.apps.${appKey}({ connectionId: "..." }) or sdk.apps.${appKey}({ connection: "name" })`
11468
- );
11469
- }
11470
11464
  return createPinnedAppProxy(
11471
11465
  appKey,
11472
11466
  imports,
@@ -6901,7 +6901,7 @@ function parseDeprecationDate(value) {
6901
6901
  }
6902
6902
 
6903
6903
  // src/sdk-version.ts
6904
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.100.0" : void 0) || "unknown";
6904
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.101.1" : void 0) || "unknown";
6905
6905
 
6906
6906
  // src/utils/open-url.ts
6907
6907
  var nodePrefix = "node:";
@@ -11343,8 +11343,7 @@ function resolveProxyConnection({
11343
11343
  providedConnection,
11344
11344
  providedAuthenticationId,
11345
11345
  pinnedAuthId,
11346
- pinnedConnection,
11347
- errorContext
11346
+ pinnedConnection
11348
11347
  }) {
11349
11348
  const hasDirectId = providedConnectionId != null || providedAuthenticationId != null;
11350
11349
  if (hasDirectId && providedConnection != null) {
@@ -11362,9 +11361,6 @@ function resolveProxyConnection({
11362
11361
  finalConnectionId = pinnedAuthId;
11363
11362
  finalConnection = pinnedAuthId != null ? void 0 : pinnedConnection;
11364
11363
  }
11365
- if (finalConnectionId == null && finalConnection == null) {
11366
- throw new ZapierValidationError(errorContext);
11367
- }
11368
11364
  return { connectionId: finalConnectionId, connection: finalConnection };
11369
11365
  }
11370
11366
  function createActionFunction(appKey, actionType, actionKey, imports, pinnedAuthId, pinnedConnection) {
@@ -11382,8 +11378,7 @@ function createActionFunction(appKey, actionType, actionKey, imports, pinnedAuth
11382
11378
  providedConnection,
11383
11379
  providedAuthenticationId,
11384
11380
  pinnedAuthId,
11385
- pinnedConnection,
11386
- errorContext: `Connection is required. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }) or sdk.apps.${appKey}({ connection: "name" }), or provide connectionId/connection in the action call.`
11381
+ pinnedConnection
11387
11382
  });
11388
11383
  return imports.runAction({
11389
11384
  app: appKey,
@@ -11404,9 +11399,13 @@ function createActionTypeProxy(appKey, actionType, imports, pinnedAuthId, pinned
11404
11399
  providedConnection: init?.connection,
11405
11400
  providedAuthenticationId: init?.authenticationId,
11406
11401
  pinnedAuthId,
11407
- pinnedConnection,
11408
- errorContext: `Connection is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }).fetch(...) or provide connectionId/connection in the fetch call.`
11402
+ pinnedConnection
11409
11403
  });
11404
+ if (connectionId == null && connection == null) {
11405
+ throw new ZapierValidationError(
11406
+ `Connection is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ connectionId }).fetch(...) or provide connectionId/connection in the fetch call.`
11407
+ );
11408
+ }
11410
11409
  return imports.fetch(url, {
11411
11410
  ...init,
11412
11411
  connection: connectionId ?? connection
@@ -11460,11 +11459,6 @@ function createAppProxy(appKey, imports) {
11460
11459
  "Cannot specify both connectionId/authenticationId and connection. Use connectionId for a direct ID, or connection for an alias or numeric ID."
11461
11460
  );
11462
11461
  }
11463
- if (resolvedConnectionId == null && resolvedConnection == null) {
11464
- throw new ZapierValidationError(
11465
- `Connection is required. Use sdk.apps.${appKey}({ connectionId: "..." }) or sdk.apps.${appKey}({ connection: "name" })`
11466
- );
11467
- }
11468
11462
  return createPinnedAppProxy(
11469
11463
  appKey,
11470
11464
  imports,