@zapier/zapier-sdk 0.76.1 → 0.77.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.
- package/CHANGELOG.md +12 -0
- package/README.md +7 -7
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +5 -0
- package/dist/experimental.cjs +55 -60
- package/dist/experimental.d.mts +8 -8
- package/dist/experimental.d.ts +6 -6
- package/dist/experimental.mjs +55 -60
- package/dist/{index-Dlf9DlnJ.d.mts → index-BZShISEr.d.mts} +45 -44
- package/dist/{index-Dlf9DlnJ.d.ts → index-BZShISEr.d.ts} +45 -44
- package/dist/index.cjs +37 -31
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +37 -31
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +3 -9
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.js +17 -29
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts +3 -3
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/triggerWorkflow/schemas.js +4 -9
- package/dist/plugins/eventEmission/builders.js +2 -1
- package/dist/plugins/eventEmission/utils.d.ts +0 -43
- package/dist/plugins/eventEmission/utils.d.ts.map +1 -1
- package/dist/plugins/eventEmission/utils.js +0 -76
- package/dist/utils/agent.d.ts +44 -0
- package/dist/utils/agent.d.ts.map +1 -0
- package/dist/utils/agent.js +76 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.77.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 19303e0: `triggerWorkflow` (and `trigger-workflow`) now authenticates with Zapier credentials and runs the workflow as the authenticated account; triggering is limited to workflows that account can access. It now returns the trigger's `id`, `workflow_id`, and `created_at` on `data` (previously `{ workflow, status, body }`). The call is unchanged: pass the workflow id and optional `input`.
|
|
8
|
+
|
|
9
|
+
## 0.76.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 27ca0c5: Add zapier-sdk-agent header to identify the AI agent using the SDK
|
|
14
|
+
|
|
3
15
|
## 0.76.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1744,7 +1744,7 @@ const result = await zapier.runDurable({
|
|
|
1744
1744
|
|
|
1745
1745
|
#### `triggerWorkflow` 🧪 _experimental_
|
|
1746
1746
|
|
|
1747
|
-
Look up a workflow's trigger URL and fire it manually
|
|
1747
|
+
Look up a workflow's trigger URL and fire it manually, as the authenticated account.
|
|
1748
1748
|
|
|
1749
1749
|
**Parameters:**
|
|
1750
1750
|
|
|
@@ -1756,12 +1756,12 @@ Look up a workflow's trigger URL and fire it manually. The trigger endpoint is t
|
|
|
1756
1756
|
|
|
1757
1757
|
**Returns:** `Promise<WorkflowRunItem>`
|
|
1758
1758
|
|
|
1759
|
-
| Name
|
|
1760
|
-
|
|
|
1761
|
-
| `data`
|
|
1762
|
-
| ↳ `
|
|
1763
|
-
| ↳ `
|
|
1764
|
-
| ↳ `
|
|
1759
|
+
| Name | Type | Required | Possible Values | Description |
|
|
1760
|
+
| ----------------- | -------- | -------- | --------------- | ---------------------------------------- |
|
|
1761
|
+
| `data` | `object` | ✅ | — | |
|
|
1762
|
+
| ↳ `id` | `string` | ✅ | — | Trigger ID (UUID) |
|
|
1763
|
+
| ↳ `workflow_id` | `string` | ✅ | — | The workflow that was triggered (UUID) |
|
|
1764
|
+
| ↳ `created_at` | `string` | ✅ | — | When the trigger was received (ISO-8601) |
|
|
1765
1765
|
|
|
1766
1766
|
**Example:**
|
|
1767
1767
|
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAglDjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
|
package/dist/api/client.js
CHANGED
|
@@ -14,6 +14,7 @@ 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
16
|
import { getCallerContext } from "../utils/caller-context";
|
|
17
|
+
import { getAgent } from "../utils/agent";
|
|
17
18
|
import { createSseParserStream, jsonFrames, } from "./sse-parser";
|
|
18
19
|
import { consumeApprovalReviewStream } from "./approval-review-stream";
|
|
19
20
|
import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierConfigurationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
|
|
@@ -766,6 +767,10 @@ class ZapierApiClient {
|
|
|
766
767
|
headers.set("zapier-service", sdkService);
|
|
767
768
|
headers.set("x-zapier-service", sdkService);
|
|
768
769
|
}
|
|
770
|
+
const agent = getAgent();
|
|
771
|
+
if (agent) {
|
|
772
|
+
headers.set("zapier-sdk-agent", agent);
|
|
773
|
+
}
|
|
769
774
|
const callerPackage = this.options.callerPackage;
|
|
770
775
|
if (callerPackage) {
|
|
771
776
|
headers.set("zapier-sdk-package", callerPackage.name);
|
package/dist/experimental.cjs
CHANGED
|
@@ -3220,6 +3220,38 @@ function getCallerContext() {
|
|
|
3220
3220
|
}
|
|
3221
3221
|
}
|
|
3222
3222
|
|
|
3223
|
+
// src/utils/agent.ts
|
|
3224
|
+
var isTruthy = (value) => {
|
|
3225
|
+
const lower = value.toLowerCase();
|
|
3226
|
+
return lower === "1" || lower === "true";
|
|
3227
|
+
};
|
|
3228
|
+
var isNonEmpty = (value) => value !== "";
|
|
3229
|
+
var agentDetectors = [
|
|
3230
|
+
{ name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
|
|
3231
|
+
{ name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
|
|
3232
|
+
{ name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
|
|
3233
|
+
{ name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
|
|
3234
|
+
{ name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
|
|
3235
|
+
{ name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
|
|
3236
|
+
{ name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
|
|
3237
|
+
{ name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
|
|
3238
|
+
];
|
|
3239
|
+
function getAgent() {
|
|
3240
|
+
try {
|
|
3241
|
+
const env = globalThis.process?.env;
|
|
3242
|
+
if (!env) return null;
|
|
3243
|
+
for (const detector of agentDetectors) {
|
|
3244
|
+
const value = env[detector.key];
|
|
3245
|
+
if (value !== void 0 && detector.predicate(value)) {
|
|
3246
|
+
return detector.name;
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
return null;
|
|
3250
|
+
} catch {
|
|
3251
|
+
return null;
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
|
|
3223
3255
|
// src/api/sse-parser.ts
|
|
3224
3256
|
async function* jsonFrames(source) {
|
|
3225
3257
|
for await (const { data } of source) {
|
|
@@ -3371,7 +3403,7 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
|
|
|
3371
3403
|
}
|
|
3372
3404
|
|
|
3373
3405
|
// src/sdk-version.ts
|
|
3374
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
3406
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.77.0" : void 0) || "unknown";
|
|
3375
3407
|
|
|
3376
3408
|
// src/utils/open-url.ts
|
|
3377
3409
|
var nodePrefix = "node:";
|
|
@@ -4089,6 +4121,10 @@ var ZapierApiClient = class {
|
|
|
4089
4121
|
headers.set("zapier-service", sdkService);
|
|
4090
4122
|
headers.set("x-zapier-service", sdkService);
|
|
4091
4123
|
}
|
|
4124
|
+
const agent = getAgent();
|
|
4125
|
+
if (agent) {
|
|
4126
|
+
headers.set("zapier-sdk-agent", agent);
|
|
4127
|
+
}
|
|
4092
4128
|
const callerPackage = this.options.callerPackage;
|
|
4093
4129
|
if (callerPackage) {
|
|
4094
4130
|
headers.set("zapier-sdk-package", callerPackage.name);
|
|
@@ -9602,36 +9638,6 @@ function getTtyContext() {
|
|
|
9602
9638
|
return { stdin_is_tty: null, stdout_is_tty: null };
|
|
9603
9639
|
}
|
|
9604
9640
|
}
|
|
9605
|
-
var isTruthy = (value) => {
|
|
9606
|
-
const lower = value.toLowerCase();
|
|
9607
|
-
return lower === "1" || lower === "true";
|
|
9608
|
-
};
|
|
9609
|
-
var isNonEmpty = (value) => value !== "";
|
|
9610
|
-
var agentDetectors = [
|
|
9611
|
-
{ name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
|
|
9612
|
-
{ name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
|
|
9613
|
-
{ name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
|
|
9614
|
-
{ name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
|
|
9615
|
-
{ name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
|
|
9616
|
-
{ name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
|
|
9617
|
-
{ name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
|
|
9618
|
-
{ name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
|
|
9619
|
-
];
|
|
9620
|
-
function getAgent() {
|
|
9621
|
-
try {
|
|
9622
|
-
const env = globalThis.process?.env;
|
|
9623
|
-
if (!env) return null;
|
|
9624
|
-
for (const detector of agentDetectors) {
|
|
9625
|
-
const value = env[detector.key];
|
|
9626
|
-
if (value !== void 0 && detector.predicate(value)) {
|
|
9627
|
-
return detector.name;
|
|
9628
|
-
}
|
|
9629
|
-
}
|
|
9630
|
-
return null;
|
|
9631
|
-
} catch {
|
|
9632
|
-
return null;
|
|
9633
|
-
}
|
|
9634
|
-
}
|
|
9635
9641
|
|
|
9636
9642
|
// src/plugins/eventEmission/builders.ts
|
|
9637
9643
|
function createBaseEvent(context = {}) {
|
|
@@ -13093,14 +13099,12 @@ var TriggerWorkflowOptionsSchema = zod.z.object({
|
|
|
13093
13099
|
"JSON payload delivered as the trigger body. Sent as `application/json`; omit to fire with an empty body."
|
|
13094
13100
|
)
|
|
13095
13101
|
}).describe(
|
|
13096
|
-
"Look up a workflow's trigger URL and fire it manually
|
|
13102
|
+
"Look up a workflow's trigger URL and fire it manually, as the authenticated account."
|
|
13097
13103
|
);
|
|
13098
13104
|
var TriggerWorkflowResponseSchema = zod.z.object({
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
"Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text."
|
|
13103
|
-
)
|
|
13105
|
+
id: zod.z.string().describe("Trigger ID (UUID)"),
|
|
13106
|
+
workflow_id: zod.z.string().describe("The workflow that was triggered (UUID)"),
|
|
13107
|
+
created_at: zod.z.string().describe("When the trigger was received (ISO-8601)")
|
|
13104
13108
|
});
|
|
13105
13109
|
|
|
13106
13110
|
// src/plugins/codeSubstrate/triggerWorkflow/index.ts
|
|
@@ -13122,32 +13126,23 @@ var triggerWorkflowPlugin = definePlugin(
|
|
|
13122
13126
|
}
|
|
13123
13127
|
);
|
|
13124
13128
|
const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
|
|
13125
|
-
const
|
|
13126
|
-
const
|
|
13127
|
-
|
|
13128
|
-
headers: { "Content-Type": "application/json" },
|
|
13129
|
-
body: options.input === void 0 ? void 0 : JSON.stringify(options.input)
|
|
13130
|
-
});
|
|
13131
|
-
const text = await response.text().catch(() => "");
|
|
13132
|
-
let body = text;
|
|
13133
|
-
if (text) {
|
|
13134
|
-
try {
|
|
13135
|
-
body = JSON.parse(text);
|
|
13136
|
-
} catch {
|
|
13137
|
-
body = text;
|
|
13138
|
-
}
|
|
13139
|
-
}
|
|
13140
|
-
if (!response.ok) {
|
|
13129
|
+
const segments = new URL(workflow.trigger_url).pathname.split("/");
|
|
13130
|
+
const triggerToken = segments[segments.length - 1];
|
|
13131
|
+
if (!triggerToken) {
|
|
13141
13132
|
throw new ZapierApiError(
|
|
13142
|
-
`
|
|
13143
|
-
{ statusCode:
|
|
13133
|
+
`Workflow ${options.workflow} returned a malformed trigger_url`,
|
|
13134
|
+
{ statusCode: 0, response: workflow.trigger_url }
|
|
13144
13135
|
);
|
|
13145
13136
|
}
|
|
13146
|
-
const
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13137
|
+
const raw = await sdk2.context.api.post(
|
|
13138
|
+
`/durableworkflowzaps/api/v0/workflows/trigger/${encodeURIComponent(triggerToken)}`,
|
|
13139
|
+
options.input,
|
|
13140
|
+
{
|
|
13141
|
+
authRequired: true,
|
|
13142
|
+
resource: { type: "workflow", id: options.workflow }
|
|
13143
|
+
}
|
|
13144
|
+
);
|
|
13145
|
+
const data = TriggerWorkflowResponseSchema.parse(raw);
|
|
13151
13146
|
return { data };
|
|
13152
13147
|
}
|
|
13153
13148
|
})
|
package/dist/experimental.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BaseSdkOptions, P as PluginStack, a as PluginMeta, M as MethodHooks, C as CoreOptions, Z as ZapierSdkOptions$1, E as EventEmissionContext, A as ApiClient, b as Manifest, R as ResolvedAppLocator, U as UpdateManifestEntryOptions, c as UpdateManifestEntryResult, d as AddActionEntryOptions, e as AddActionEntryResult, f as ActionEntry, g as findManifestEntry, r as readManifestFromFile, h as CapabilitiesContext, i as PaginatedSdkResult, G as GetConnectionStartUrlItem, W as WaitForNewConnectionItem, j as CreateConnectionItem, F as FieldsetItem, k as PositionalMetadata, O as OutputFormatter, l as ZapierFetchInitOptions, D as DrainTriggerInboxOptions, m as DynamicResolver, n as WatchTriggerInboxOptions, o as ActionProxy, p as ZapierSdkApps, q as WithAddPlugin } from './index-
|
|
2
|
-
export { H as Action,
|
|
1
|
+
import { B as BaseSdkOptions, P as PluginStack, a as PluginMeta, M as MethodHooks, C as CoreOptions, Z as ZapierSdkOptions$1, E as EventEmissionContext, A as ApiClient, b as Manifest, R as ResolvedAppLocator, U as UpdateManifestEntryOptions, c as UpdateManifestEntryResult, d as AddActionEntryOptions, e as AddActionEntryResult, f as ActionEntry, g as findManifestEntry, r as readManifestFromFile, h as CapabilitiesContext, i as PaginatedSdkResult, G as GetConnectionStartUrlItem, W as WaitForNewConnectionItem, j as CreateConnectionItem, F as FieldsetItem, k as PositionalMetadata, O as OutputFormatter, l as ZapierFetchInitOptions, D as DrainTriggerInboxOptions, m as DynamicResolver, n as WatchTriggerInboxOptions, o as ActionProxy, p as ZapierSdkApps, q as WithAddPlugin } from './index-BZShISEr.mjs';
|
|
2
|
+
export { H as Action, cj as ActionExecutionOptions, Q as ActionExecutionResult, S as ActionField, V as ActionFieldChoice, aX as ActionItem, bx as ActionKeyProperty, b5 as ActionKeyPropertySchema, by as ActionProperty, b6 as ActionPropertySchema, aK as ActionResolverItem, bJ as ActionTimeoutMsProperty, bh as ActionTimeoutMsPropertySchema, aL as ActionTypeItem, bw as ActionTypeProperty, b4 as ActionTypePropertySchema, cf as ApiError, dM as ApiEvent, d1 as ApiPluginOptions, d3 as ApiPluginProvides, I as App, ck as AppFactoryInput, aV as AppItem, bu as AppKeyProperty, b2 as AppKeyPropertySchema, bv as AppProperty, b3 as AppPropertySchema, eW as ApplicationLifecycleEventData, cb as ApprovalStatus, ci as AppsPluginProvides, bO as AppsProperty, bm as AppsPropertySchema, a8 as ArrayResolver, dL as AuthEvent, dw as AuthMechanism, bC as AuthenticationIdProperty, b9 as AuthenticationIdPropertySchema, f2 as BaseEvent, ay as BaseSdkOptionsSchema, am as BatchOptions, cQ as CONTEXT_CACHE_MAX_SIZE, cP as CONTEXT_CACHE_TTL_MS, aC as CORE_ERROR_SYMBOL, ai as CallerContext, K as Choice, dS as ClientCredentialsObject, e1 as ClientCredentialsObjectSchema, _ as Connection, e9 as ConnectionEntry, e8 as ConnectionEntrySchema, bA as ConnectionIdProperty, b8 as ConnectionIdPropertySchema, aW as ConnectionItem, bB as ConnectionProperty, ba as ConnectionPropertySchema, eb as ConnectionsMap, ea as ConnectionsMapSchema, ed as ConnectionsPluginProvides, bQ as ConnectionsProperty, bo as ConnectionsPropertySchema, $ as ConnectionsResponse, aD as CoreErrorCode, cC as CreateClientCredentialsPluginProvides, eE as CreateTableFieldsPluginProvides, ey as CreateTablePluginProvides, eM as CreateTableRecordsPluginProvides, dP as Credentials, e6 as CredentialsFunction, e5 as CredentialsFunctionSchema, dR as CredentialsObject, e3 as CredentialsObjectSchema, e7 as CredentialsSchema, ei as DEFAULT_ACTION_TIMEOUT_MS, er as DEFAULT_APPROVAL_TIMEOUT_MS, cZ as DEFAULT_CONFIG_PATH, es as DEFAULT_MAX_APPROVAL_RETRIES, eh as DEFAULT_PAGE_SIZE, bH as DebugProperty, bf as DebugPropertySchema, cE as DeleteClientCredentialsPluginProvides, eG as DeleteTableFieldsPluginProvides, eA as DeleteTablePluginProvides, eO as DeleteTableRecordsPluginProvides, u as DrainTriggerInboxCallback, v as DrainTriggerInboxErrorObserver, ab as DynamicListResolver, ac as DynamicSearchResolver, eX as EnhancedErrorEventData, bW as ErrorOptions, dO as EventCallback, eV as EventContext, eS as EventEmissionConfig, eU as EventEmissionProvides, cm as FetchPluginProvides, J as Field, bN as FieldsProperty, bl as FieldsPropertySchema, ad as FieldsResolver, y as FindFirstAuthenticationPluginProvides, cM as FindFirstConnectionPluginProvides, z as FindUniqueAuthenticationPluginProvides, cO as FindUniqueConnectionPluginProvides, a6 as FormattedItem, ax as FunctionDeprecation, aw as FunctionRegistryEntry, cw as GetActionInputFieldsSchemaPluginProvides, cI as GetActionPluginProvides, cG as GetAppPluginProvides, x as GetAuthenticationPluginProvides, cK as GetConnectionPluginProvides, d0 as GetProfilePluginProvides, ew as GetTablePluginProvides, eI as GetTableRecordPluginProvides, aZ as InfoFieldItem, aY as InputFieldItem, bz as InputFieldProperty, b7 as InputFieldPropertySchema, bD as InputsProperty, bb as InputsPropertySchema, aU as JsonSseMessage, bV as LeaseLimitProperty, bt as LeaseLimitPropertySchema, bT as LeaseProperty, br as LeasePropertySchema, bU as LeaseSecondsProperty, bs as LeaseSecondsPropertySchema, L as LeasedTriggerMessageItem, bE as LimitProperty, bc as LimitPropertySchema, cu as ListActionInputFieldChoicesPluginProvides, cs as ListActionInputFieldsPluginProvides, cq as ListActionsPluginProvides, co as ListAppsPluginProvides, w as ListAuthenticationsPluginProvides, cA as ListClientCredentialsPluginProvides, cy as ListConnectionsPluginProvides, eC as ListTableFieldsPluginProvides, eK as ListTableRecordsPluginProvides, eu as ListTablesPluginProvides, dN as LoadingEvent, el as MAX_CONCURRENCY_LIMIT, eg as MAX_PAGE_LIMIT, c_ as ManifestEntry, cV as ManifestPluginOptions, cY as ManifestPluginProvides, f3 as MethodCalledEvent, eY as MethodCalledEventData, N as Need, X as NeedsRequest, Y as NeedsResponse, bF as OffsetProperty, bd as OffsetPropertySchema, bG as OutputProperty, be as OutputPropertySchema, b1 as PaginatedSdkFunction, bI as ParamsProperty, bg as ParamsPropertySchema, dT as PkceCredentialsObject, e2 as PkceCredentialsObjectSchema, aE as Plugin, aF as PluginProvides, aP as PollOptions, c9 as RateLimitInfo, bL as RecordProperty, bj as RecordPropertySchema, bM as RecordsProperty, bk as RecordsPropertySchema, ar as RelayFetchSchema, aq as RelayRequestSchema, aO as RequestOptions, cU as RequestPluginProvides, dv as ResolveAuthTokenOptions, dY as ResolveCredentialsOptions, dx as ResolvedAuth, dQ as ResolvedCredentials, e4 as ResolvedCredentialsSchema, a7 as Resolver, a9 as ResolverMetadata, a_ as RootFieldItem, cS as RunActionPluginProvides, dK as SdkEvent, b0 as SdkPage, aT as SseMessage, aa as StaticResolver, bK as TableProperty, bi as TablePropertySchema, bP as TablesProperty, bn as TablesPropertySchema, bS as TriggerInboxNameProperty, bq as TriggerInboxNamePropertySchema, bR as TriggerInboxProperty, bp as TriggerInboxPropertySchema, T as TriggerMessageStatus, eQ as UpdateTableRecordsPluginProvides, a0 as UserProfile, a$ as UserProfileItem, ee as ZAPIER_BASE_URL, en as ZAPIER_MAX_CONCURRENT_REQUESTS, ej as ZAPIER_MAX_NETWORK_RETRIES, ek as ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, s as ZapierAbortDrainSignal, c7 as ZapierActionError, c0 as ZapierApiError, c1 as ZapierAppNotFoundError, cc as ZapierApprovalError, b_ as ZapierAuthenticationError, c5 as ZapierBundleError, dG as ZapierCache, dH as ZapierCacheEntry, dI as ZapierCacheSetOptions, c4 as ZapierConfigurationError, c8 as ZapierConflictError, bX as ZapierError, c2 as ZapierNotFoundError, ca as ZapierRateLimitError, cd as ZapierRelayError, t as ZapierReleaseTriggerMessageSignal, c3 as ZapierResourceNotFoundError, cg as ZapierSignal, c6 as ZapierTimeoutError, bZ as ZapierUnknownError, bY as ZapierValidationError, d6 as actionKeyResolver, d5 as actionTypeResolver, a5 as addPlugin, d2 as apiPlugin, d4 as appKeyResolver, ch as appsPlugin, d8 as authenticationIdGenericResolver, d7 as authenticationIdResolver, al as batch, eZ as buildApplicationLifecycleEvent, an as buildCapabilityMessage, e$ as buildErrorEvent, e_ as buildErrorEventWithContext, f1 as buildMethodCalledEvent, eR as cleanupEventListeners, dy as clearTokenCache, dc as clientCredentialsNameResolver, dd as clientIdResolver, aJ as composePlugins, d8 as connectionIdGenericResolver, d7 as connectionIdResolver, ec as connectionsPlugin, f0 as createBaseEvent, cB as createClientCredentialsPlugin, a4 as createCorePlugin, a2 as createFunction, dJ as createMemoryCache, au as createOptionsPlugin, aI as createPaginatedPluginMethod, aH as createPluginMethod, a3 as createPluginStack, at as createSdk, eD as createTableFieldsPlugin, ex as createTablePlugin, eL as createTableRecordsPlugin, aQ as createZapierApi, av as createZapierCoreStack, as as createZapierSdkWithoutRegistry, aG as definePlugin, cD as deleteClientCredentialsPlugin, eF as deleteTableFieldsPlugin, ez as deleteTablePlugin, eN as deleteTableRecordsPlugin, dh as durableRunIdResolver, eT as eventEmissionPlugin, cl as fetchPlugin, cL as findFirstConnectionPlugin, cN as findUniqueConnectionPlugin, ce as formatErrorMessage, f4 as generateEventId, cv as getActionInputFieldsSchemaPlugin, cH as getActionPlugin, aM as getAgent, cF as getAppPlugin, d$ as getBaseUrlFromCredentials, ag as getCallerContext, fa as getCiPlatform, e0 as getClientIdFromCredentials, cJ as getConnectionPlugin, aB as getCoreErrorCause, aA as getCoreErrorCode, fc as getCpuTime, f5 as getCurrentTimestamp, fb as getMemoryUsage, aR as getOrCreateApiClient, f7 as getOsInfo, f8 as getPlatformVersions, cW as getPreferredManifestEntryKey, c$ as getProfilePlugin, f6 as getReleaseId, ev as getTablePlugin, eH as getTableRecordPlugin, dC as getTokenFromCliLogin, fd as getTtyContext, eo as getZapierApprovalMode, eq as getZapierDefaultApprovalMode, ep as getZapierOpenAutoModeApprovalsInBrowser, ef as getZapierSdkService, dA as injectCliLogin, db as inputFieldKeyResolver, da as inputsAllOptionalResolver, d9 as inputsResolver, dz as invalidateCachedToken, dF as invalidateCredentialsToken, f9 as isCi, dB as isCliLoginAvailable, dU as isClientCredentials, az as isCoreError, dX as isCredentialsFunction, dW as isCredentialsObject, aS as isPermanentHttpError, dV as isPkceCredentials, a1 as isPositional, ct as listActionInputFieldChoicesPlugin, cr as listActionInputFieldsPlugin, cp as listActionsPlugin, cn as listAppsPlugin, cz as listClientCredentialsPlugin, cx as listConnectionsPlugin, eB as listTableFieldsPlugin, eJ as listTableRecordsPlugin, et as listTablesPlugin, ao as logDeprecation, cX as manifestPlugin, em as parseConcurrencyEnvVar, aN as registryPlugin, cT as requestPlugin, ap as resetDeprecationWarnings, dD as resolveAuth, dE as resolveAuthToken, d_ as resolveCredentials, dZ as resolveCredentialsFromEnv, cR as runActionPlugin, ae as runInMethodScope, ah as runWithCallerContext, af as runWithTelemetryContext, dn as tableFieldIdsResolver, dq as tableFieldsResolver, dt as tableFiltersResolver, de as tableIdResolver, dp as tableNameResolver, dl as tableRecordIdResolver, dm as tableRecordIdsResolver, dr as tableRecordsResolver, du as tableSortResolver, ds as tableUpdateRecordsResolver, aj as toSnakeCase, ak as toTitleCase, df as triggerInboxResolver, dk as triggerMessagesResolver, eP as updateTableRecordsPlugin, dg as workflowIdResolver, dj as workflowRunIdResolver, di as workflowVersionIdResolver, b$ as zapierAdaptError } from './index-BZShISEr.mjs';
|
|
3
3
|
import * as zod_v4_core from 'zod/v4/core';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import '@zapier/zapier-sdk-core/v0/schemas/connections';
|
|
@@ -3162,9 +3162,9 @@ declare function createZapierSdkStack(options?: ZapierSdkOptions): PluginStack<o
|
|
|
3162
3162
|
input?: unknown;
|
|
3163
3163
|
} | undefined) => Promise<{
|
|
3164
3164
|
data: {
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3165
|
+
id: string;
|
|
3166
|
+
workflow_id: string;
|
|
3167
|
+
created_at: string;
|
|
3168
3168
|
};
|
|
3169
3169
|
}>;
|
|
3170
3170
|
} & {
|
|
@@ -6365,9 +6365,9 @@ declare function createZapierSdk(options?: ZapierSdkOptions): WithAddPlugin<obje
|
|
|
6365
6365
|
input?: unknown;
|
|
6366
6366
|
} | undefined) => Promise<{
|
|
6367
6367
|
data: {
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6368
|
+
id: string;
|
|
6369
|
+
workflow_id: string;
|
|
6370
|
+
created_at: string;
|
|
6371
6371
|
};
|
|
6372
6372
|
}>;
|
|
6373
6373
|
} & {
|
package/dist/experimental.d.ts
CHANGED
|
@@ -3177,9 +3177,9 @@ export declare function createZapierSdkStack(options?: ZapierSdkOptions): import
|
|
|
3177
3177
|
input?: unknown;
|
|
3178
3178
|
} | undefined) => Promise<{
|
|
3179
3179
|
data: {
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3180
|
+
id: string;
|
|
3181
|
+
workflow_id: string;
|
|
3182
|
+
created_at: string;
|
|
3183
3183
|
};
|
|
3184
3184
|
}>;
|
|
3185
3185
|
} & {
|
|
@@ -6380,9 +6380,9 @@ export declare function createZapierSdk(options?: ZapierSdkOptions): import("kit
|
|
|
6380
6380
|
input?: unknown;
|
|
6381
6381
|
} | undefined) => Promise<{
|
|
6382
6382
|
data: {
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6383
|
+
id: string;
|
|
6384
|
+
workflow_id: string;
|
|
6385
|
+
created_at: string;
|
|
6386
6386
|
};
|
|
6387
6387
|
}>;
|
|
6388
6388
|
} & {
|
package/dist/experimental.mjs
CHANGED
|
@@ -3218,6 +3218,38 @@ function getCallerContext() {
|
|
|
3218
3218
|
}
|
|
3219
3219
|
}
|
|
3220
3220
|
|
|
3221
|
+
// src/utils/agent.ts
|
|
3222
|
+
var isTruthy = (value) => {
|
|
3223
|
+
const lower = value.toLowerCase();
|
|
3224
|
+
return lower === "1" || lower === "true";
|
|
3225
|
+
};
|
|
3226
|
+
var isNonEmpty = (value) => value !== "";
|
|
3227
|
+
var agentDetectors = [
|
|
3228
|
+
{ name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
|
|
3229
|
+
{ name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
|
|
3230
|
+
{ name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
|
|
3231
|
+
{ name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
|
|
3232
|
+
{ name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
|
|
3233
|
+
{ name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
|
|
3234
|
+
{ name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
|
|
3235
|
+
{ name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
|
|
3236
|
+
];
|
|
3237
|
+
function getAgent() {
|
|
3238
|
+
try {
|
|
3239
|
+
const env = globalThis.process?.env;
|
|
3240
|
+
if (!env) return null;
|
|
3241
|
+
for (const detector of agentDetectors) {
|
|
3242
|
+
const value = env[detector.key];
|
|
3243
|
+
if (value !== void 0 && detector.predicate(value)) {
|
|
3244
|
+
return detector.name;
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
return null;
|
|
3248
|
+
} catch {
|
|
3249
|
+
return null;
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3221
3253
|
// src/api/sse-parser.ts
|
|
3222
3254
|
async function* jsonFrames(source) {
|
|
3223
3255
|
for await (const { data } of source) {
|
|
@@ -3369,7 +3401,7 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
|
|
|
3369
3401
|
}
|
|
3370
3402
|
|
|
3371
3403
|
// src/sdk-version.ts
|
|
3372
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
3404
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.77.0" : void 0) || "unknown";
|
|
3373
3405
|
|
|
3374
3406
|
// src/utils/open-url.ts
|
|
3375
3407
|
var nodePrefix = "node:";
|
|
@@ -4087,6 +4119,10 @@ var ZapierApiClient = class {
|
|
|
4087
4119
|
headers.set("zapier-service", sdkService);
|
|
4088
4120
|
headers.set("x-zapier-service", sdkService);
|
|
4089
4121
|
}
|
|
4122
|
+
const agent = getAgent();
|
|
4123
|
+
if (agent) {
|
|
4124
|
+
headers.set("zapier-sdk-agent", agent);
|
|
4125
|
+
}
|
|
4090
4126
|
const callerPackage = this.options.callerPackage;
|
|
4091
4127
|
if (callerPackage) {
|
|
4092
4128
|
headers.set("zapier-sdk-package", callerPackage.name);
|
|
@@ -9600,36 +9636,6 @@ function getTtyContext() {
|
|
|
9600
9636
|
return { stdin_is_tty: null, stdout_is_tty: null };
|
|
9601
9637
|
}
|
|
9602
9638
|
}
|
|
9603
|
-
var isTruthy = (value) => {
|
|
9604
|
-
const lower = value.toLowerCase();
|
|
9605
|
-
return lower === "1" || lower === "true";
|
|
9606
|
-
};
|
|
9607
|
-
var isNonEmpty = (value) => value !== "";
|
|
9608
|
-
var agentDetectors = [
|
|
9609
|
-
{ name: "claude-code", key: "CLAUDECODE", predicate: isTruthy },
|
|
9610
|
-
{ name: "github-copilot", key: "COPILOT_AGENT", predicate: isTruthy },
|
|
9611
|
-
{ name: "cursor", key: "CURSOR_AGENT", predicate: isTruthy },
|
|
9612
|
-
{ name: "codex", key: "CODEX_SANDBOX", predicate: isNonEmpty },
|
|
9613
|
-
{ name: "gemini-cli", key: "GEMINI_CLI", predicate: isTruthy },
|
|
9614
|
-
{ name: "augment", key: "AUGMENT_AGENT", predicate: isTruthy },
|
|
9615
|
-
{ name: "cline", key: "CLINE_ACTIVE", predicate: isTruthy },
|
|
9616
|
-
{ name: "opencode", key: "OPENCODE_CLIENT", predicate: isNonEmpty }
|
|
9617
|
-
];
|
|
9618
|
-
function getAgent() {
|
|
9619
|
-
try {
|
|
9620
|
-
const env = globalThis.process?.env;
|
|
9621
|
-
if (!env) return null;
|
|
9622
|
-
for (const detector of agentDetectors) {
|
|
9623
|
-
const value = env[detector.key];
|
|
9624
|
-
if (value !== void 0 && detector.predicate(value)) {
|
|
9625
|
-
return detector.name;
|
|
9626
|
-
}
|
|
9627
|
-
}
|
|
9628
|
-
return null;
|
|
9629
|
-
} catch {
|
|
9630
|
-
return null;
|
|
9631
|
-
}
|
|
9632
|
-
}
|
|
9633
9639
|
|
|
9634
9640
|
// src/plugins/eventEmission/builders.ts
|
|
9635
9641
|
function createBaseEvent(context = {}) {
|
|
@@ -13091,14 +13097,12 @@ var TriggerWorkflowOptionsSchema = z.object({
|
|
|
13091
13097
|
"JSON payload delivered as the trigger body. Sent as `application/json`; omit to fire with an empty body."
|
|
13092
13098
|
)
|
|
13093
13099
|
}).describe(
|
|
13094
|
-
"Look up a workflow's trigger URL and fire it manually
|
|
13100
|
+
"Look up a workflow's trigger URL and fire it manually, as the authenticated account."
|
|
13095
13101
|
);
|
|
13096
13102
|
var TriggerWorkflowResponseSchema = z.object({
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
"Response body from the trigger endpoint. Parsed as JSON when the response body parses, otherwise returned as the raw response text."
|
|
13101
|
-
)
|
|
13103
|
+
id: z.string().describe("Trigger ID (UUID)"),
|
|
13104
|
+
workflow_id: z.string().describe("The workflow that was triggered (UUID)"),
|
|
13105
|
+
created_at: z.string().describe("When the trigger was received (ISO-8601)")
|
|
13102
13106
|
});
|
|
13103
13107
|
|
|
13104
13108
|
// src/plugins/codeSubstrate/triggerWorkflow/index.ts
|
|
@@ -13120,32 +13124,23 @@ var triggerWorkflowPlugin = definePlugin(
|
|
|
13120
13124
|
}
|
|
13121
13125
|
);
|
|
13122
13126
|
const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
|
|
13123
|
-
const
|
|
13124
|
-
const
|
|
13125
|
-
|
|
13126
|
-
headers: { "Content-Type": "application/json" },
|
|
13127
|
-
body: options.input === void 0 ? void 0 : JSON.stringify(options.input)
|
|
13128
|
-
});
|
|
13129
|
-
const text = await response.text().catch(() => "");
|
|
13130
|
-
let body = text;
|
|
13131
|
-
if (text) {
|
|
13132
|
-
try {
|
|
13133
|
-
body = JSON.parse(text);
|
|
13134
|
-
} catch {
|
|
13135
|
-
body = text;
|
|
13136
|
-
}
|
|
13137
|
-
}
|
|
13138
|
-
if (!response.ok) {
|
|
13127
|
+
const segments = new URL(workflow.trigger_url).pathname.split("/");
|
|
13128
|
+
const triggerToken = segments[segments.length - 1];
|
|
13129
|
+
if (!triggerToken) {
|
|
13139
13130
|
throw new ZapierApiError(
|
|
13140
|
-
`
|
|
13141
|
-
{ statusCode:
|
|
13131
|
+
`Workflow ${options.workflow} returned a malformed trigger_url`,
|
|
13132
|
+
{ statusCode: 0, response: workflow.trigger_url }
|
|
13142
13133
|
);
|
|
13143
13134
|
}
|
|
13144
|
-
const
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
|
|
13148
|
-
|
|
13135
|
+
const raw = await sdk2.context.api.post(
|
|
13136
|
+
`/durableworkflowzaps/api/v0/workflows/trigger/${encodeURIComponent(triggerToken)}`,
|
|
13137
|
+
options.input,
|
|
13138
|
+
{
|
|
13139
|
+
authRequired: true,
|
|
13140
|
+
resource: { type: "workflow", id: options.workflow }
|
|
13141
|
+
}
|
|
13142
|
+
);
|
|
13143
|
+
const data = TriggerWorkflowResponseSchema.parse(raw);
|
|
13149
13144
|
return { data };
|
|
13150
13145
|
}
|
|
13151
13146
|
})
|