@zapier/zapier-sdk 0.104.0 → 0.105.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 +13 -0
- package/README.md +2 -0
- package/dist/{chunk-CJKNVBRZ.mjs → chunk-NF7CPRHH.mjs} +61 -18
- package/dist/{chunk-ZEZNG44W.cjs → chunk-Y2OATBGZ.cjs} +62 -17
- package/dist/experimental.cjs +363 -355
- package/dist/experimental.d.mts +4 -2
- package/dist/experimental.d.ts +4 -2
- package/dist/experimental.mjs +2 -2
- package/dist/{index-Blmu5pN3.d.mts → index-DFhYYVH_.d.mts} +45 -1
- package/dist/{index-Blmu5pN3.d.ts → index-DFhYYVH_.d.ts} +45 -1
- package/dist/index.cjs +285 -277
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.105.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ef3540d: Added `correlationId` and `causationId` options on `createZapierSdk`, matching
|
|
8
|
+
`--correlation-id` and `--causation-id` CLI flags, and the `ZAPIER_CORRELATION_ID`
|
|
9
|
+
and `ZAPIER_CAUSATION_ID` environment variables. When set, they are emitted as
|
|
10
|
+
`zapier-correlation-id` and `zapier-causation-id` headers on every outbound
|
|
11
|
+
Zapier API request. Precedence for both ids is: explicit option, then
|
|
12
|
+
environment variable, and for correlation the SDK falls back to its per-call
|
|
13
|
+
id so requests still carry a trace identifier. Precedence is: explicit option,
|
|
14
|
+
then environment variable. Empty strings at either layer are treated as unset.
|
|
15
|
+
|
|
3
16
|
## 0.104.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -383,6 +383,8 @@ The `createZapierSdk(...)` factory function is the main entry point for the SDK.
|
|
|
383
383
|
| `maxApprovalRetries` | `number` | ❌ | — | — | Maximum number of sequential approval rounds per request (one per gating policy) before giving up. Default: 2. |
|
|
384
384
|
| `approvalMode` | `string` | ❌ | — | `disabled`, `poll`, `throw` | Approval flow behavior for manual approvals. "poll" creates the approval, opens it in a browser, polls until resolved, and retries the original request. "throw" creates the manual approval and throws a ZapierApprovalError with the approval URL so the caller can surface it. Server-created auto-mode approvals always poll until they reach a terminal status and retry the original request on approval, even when this option is "throw". "disabled" throws a ZapierApprovalError on approval-required responses without creating an approval. Resolution order is: explicit option, then ZAPIER_APPROVAL_MODE, then the default behavior (poll for interactive TTY, throw otherwise). |
|
|
385
385
|
| `openAutoModeApprovalsInBrowser` | `boolean` | ❌ | — | — | By default, auto-mode approvals do not open in a browser. Enable this option to open the approval URL and watch the approval process. Resolution order is: explicit option, then ZAPIER_OPEN_AUTO_MODE_APPROVALS_IN_BROWSER, then false. |
|
|
386
|
+
| `correlationId` | `string` | ❌ | — | — | Correlation ID for request tracing. When set, emitted as the `zapier-correlation-id` header on every outbound request. Falls back to the ZAPIER_CORRELATION_ID environment variable. |
|
|
387
|
+
| `causationId` | `string` | ❌ | — | — | Causation ID for request tracing. When set, emitted as the `zapier-causation-id` header on every outbound request. Falls back to the ZAPIER_CAUSATION_ID environment variable. |
|
|
386
388
|
| `canIncludeSharedConnections` | `boolean` | ❌ | — | — | Allow listing shared connections. |
|
|
387
389
|
| `canIncludeSharedTables` | `boolean` | ❌ | — | — | Allow listing shared tables. |
|
|
388
390
|
| `canDeleteTables` | `boolean` | ❌ | — | — | Allow deleting tables. |
|
|
@@ -12,6 +12,12 @@ var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapie
|
|
|
12
12
|
function getZapierSdkService() {
|
|
13
13
|
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
14
14
|
}
|
|
15
|
+
function getZapierCorrelationId() {
|
|
16
|
+
return globalThis.process?.env?.ZAPIER_CORRELATION_ID || void 0;
|
|
17
|
+
}
|
|
18
|
+
function getZapierCausationId() {
|
|
19
|
+
return globalThis.process?.env?.ZAPIER_CAUSATION_ID || void 0;
|
|
20
|
+
}
|
|
15
21
|
var MAX_PAGE_LIMIT = 1e4;
|
|
16
22
|
var DEFAULT_PAGE_SIZE = 100;
|
|
17
23
|
var DEFAULT_ACTION_TIMEOUT_MILLISECONDS = 18e4;
|
|
@@ -1235,6 +1241,17 @@ function createZapierSendHttpRequest({
|
|
|
1235
1241
|
var CORRELATION_CALL_ID = Symbol(
|
|
1236
1242
|
"zapier.correlationCallId"
|
|
1237
1243
|
);
|
|
1244
|
+
function resolveCorrelationId({
|
|
1245
|
+
options,
|
|
1246
|
+
callId
|
|
1247
|
+
}) {
|
|
1248
|
+
return options?.correlationId || getZapierCorrelationId() || callId || void 0;
|
|
1249
|
+
}
|
|
1250
|
+
function resolveCausationId({
|
|
1251
|
+
options
|
|
1252
|
+
}) {
|
|
1253
|
+
return options?.causationId || getZapierCausationId();
|
|
1254
|
+
}
|
|
1238
1255
|
var ClientCredentialsObjectSchema = z.object({
|
|
1239
1256
|
type: z.enum(["client_credentials"]).optional().meta({ internal: true }),
|
|
1240
1257
|
clientId: z.string().describe("OAuth client ID for authentication.").meta({ valueHint: "id" }),
|
|
@@ -2657,7 +2674,7 @@ function logRouteOverride({
|
|
|
2657
2674
|
}
|
|
2658
2675
|
|
|
2659
2676
|
// src/sdk-version.ts
|
|
2660
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
2677
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.105.0" : void 0) || "unknown";
|
|
2661
2678
|
|
|
2662
2679
|
// src/utils/open-url.ts
|
|
2663
2680
|
var nodePrefix = "node:";
|
|
@@ -3386,11 +3403,21 @@ var ZapierApiClient = class {
|
|
|
3386
3403
|
headers.set("zapier-sdk-package-operation", packageOperation);
|
|
3387
3404
|
}
|
|
3388
3405
|
}
|
|
3389
|
-
|
|
3390
|
-
|
|
3406
|
+
const correlationId = resolveCorrelationId({
|
|
3407
|
+
options: this.options,
|
|
3408
|
+
callId
|
|
3409
|
+
});
|
|
3410
|
+
if (correlationId) {
|
|
3411
|
+
headers.set("zapier-correlation-id", correlationId);
|
|
3391
3412
|
} else {
|
|
3392
3413
|
headers.delete("zapier-correlation-id");
|
|
3393
3414
|
}
|
|
3415
|
+
const causationId = resolveCausationId({ options: this.options });
|
|
3416
|
+
if (causationId) {
|
|
3417
|
+
headers.set("zapier-causation-id", causationId);
|
|
3418
|
+
} else {
|
|
3419
|
+
headers.delete("zapier-causation-id");
|
|
3420
|
+
}
|
|
3394
3421
|
}
|
|
3395
3422
|
// Helper to perform HTTP requests with JSON handling
|
|
3396
3423
|
async fetchJson(method, path, data, options = {}) {
|
|
@@ -3970,7 +3997,9 @@ var apiPlugin = defineProperty({
|
|
|
3970
3997
|
approvalMode,
|
|
3971
3998
|
openAutoModeApprovalsInBrowser,
|
|
3972
3999
|
callerPackage,
|
|
3973
|
-
routeOverrides
|
|
4000
|
+
routeOverrides,
|
|
4001
|
+
correlationId,
|
|
4002
|
+
causationId
|
|
3974
4003
|
} = imports.sdkOptions ?? {};
|
|
3975
4004
|
return createZapierApi({
|
|
3976
4005
|
baseUrl,
|
|
@@ -3993,7 +4022,12 @@ var apiPlugin = defineProperty({
|
|
|
3993
4022
|
routeOverrides,
|
|
3994
4023
|
// Inject the graph-composed transport so host `dispatchHttpRequest` wraps
|
|
3995
4024
|
// apply.
|
|
3996
|
-
sendHttpRequest: imports.sendHttpRequest
|
|
4025
|
+
sendHttpRequest: imports.sendHttpRequest,
|
|
4026
|
+
// Pass through unresolved so `resolveCorrelationId` / `resolveCausationId`
|
|
4027
|
+
// do the option-then-env-var chain at request time — the same helper the
|
|
4028
|
+
// event-emission hook calls, so header and MethodCalledEvent stay aligned.
|
|
4029
|
+
correlationId,
|
|
4030
|
+
causationId
|
|
3997
4031
|
});
|
|
3998
4032
|
},
|
|
3999
4033
|
get: ({ state, callContext }) => callContext?.callId ? withCorrelationId({ client: state, callId: callContext.callId }) : state
|
|
@@ -11752,7 +11786,7 @@ function computeArgumentCount(args) {
|
|
|
11752
11786
|
}
|
|
11753
11787
|
return args.filter((a) => a !== void 0).length;
|
|
11754
11788
|
}
|
|
11755
|
-
function makeMethodEndHook(emitMethodCalled) {
|
|
11789
|
+
function makeMethodEndHook(emitMethodCalled, { sdkOptions } = {}) {
|
|
11756
11790
|
return ({
|
|
11757
11791
|
methodName,
|
|
11758
11792
|
args,
|
|
@@ -11768,9 +11802,9 @@ function makeMethodEndHook(emitMethodCalled) {
|
|
|
11768
11802
|
const metadata = readMethodMetadata(annotations);
|
|
11769
11803
|
emitMethodCalled({
|
|
11770
11804
|
method_name: methodName,
|
|
11771
|
-
//
|
|
11772
|
-
//
|
|
11773
|
-
correlation_id: callId ?? null,
|
|
11805
|
+
// Same resolution as the `zapier-correlation-id` header: SDK option >
|
|
11806
|
+
// env var > per-call kitcore id. Not the `call_context` surface label.
|
|
11807
|
+
correlation_id: resolveCorrelationId({ options: sdkOptions, callId }) ?? null,
|
|
11774
11808
|
execution_duration_ms: durationMs,
|
|
11775
11809
|
success_flag: !error,
|
|
11776
11810
|
error_message: error?.message ?? null,
|
|
@@ -12164,17 +12198,20 @@ var eventEmissionPlugin = defineProperty({
|
|
|
12164
12198
|
var eventEmissionHookPlugin = defineHook({
|
|
12165
12199
|
namespace: "zapier",
|
|
12166
12200
|
name: "eventEmissionHook",
|
|
12167
|
-
imports: [eventEmissionPlugin],
|
|
12201
|
+
imports: [eventEmissionPlugin, sdkOptionsPluginRef],
|
|
12168
12202
|
observe: {
|
|
12169
12203
|
onMethodEnd: ({ imports, input }) => {
|
|
12170
12204
|
if (input.methodName === "getRegistry") return;
|
|
12171
|
-
const emitter = imports
|
|
12172
|
-
makeMethodEndHook(
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12205
|
+
const { eventEmission: emitter, sdkOptions } = imports;
|
|
12206
|
+
makeMethodEndHook(
|
|
12207
|
+
(data) => {
|
|
12208
|
+
emitter.emit(METHOD_CALLED_EVENT_SUBJECT, {
|
|
12209
|
+
...buildMethodCalledEvent(data),
|
|
12210
|
+
call_context: emitter.config.callContext ?? "sdk"
|
|
12211
|
+
});
|
|
12212
|
+
},
|
|
12213
|
+
{ sdkOptions }
|
|
12214
|
+
)(input);
|
|
12178
12215
|
}
|
|
12179
12216
|
}
|
|
12180
12217
|
});
|
|
@@ -12435,6 +12472,12 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
12435
12472
|
openAutoModeApprovalsInBrowser: z.boolean().optional().describe(
|
|
12436
12473
|
"By default, auto-mode approvals do not open in a browser. Enable this option to open the approval URL and watch the approval process. Resolution order is: explicit option, then ZAPIER_OPEN_AUTO_MODE_APPROVALS_IN_BROWSER, then false."
|
|
12437
12474
|
),
|
|
12475
|
+
correlationId: z.string().optional().describe(
|
|
12476
|
+
"Correlation ID for request tracing. When set, emitted as the `zapier-correlation-id` header on every outbound request. Falls back to the ZAPIER_CORRELATION_ID environment variable."
|
|
12477
|
+
).meta({ valueHint: "id" }),
|
|
12478
|
+
causationId: z.string().optional().describe(
|
|
12479
|
+
"Causation ID for request tracing. When set, emitted as the `zapier-causation-id` header on every outbound request. Falls back to the ZAPIER_CAUSATION_ID environment variable."
|
|
12480
|
+
).meta({ valueHint: "id" }),
|
|
12438
12481
|
// Internal
|
|
12439
12482
|
manifestPath: z.string().optional().describe("Path to a .zapierrc manifest file for app version locking.").meta({ internal: true }),
|
|
12440
12483
|
manifest: z.custom().optional().describe("Manifest for app version locking.").meta({ internal: true }),
|
|
@@ -12459,4 +12502,4 @@ var registryPlugin = (_sdk) => {
|
|
|
12459
12502
|
return {};
|
|
12460
12503
|
};
|
|
12461
12504
|
|
|
12462
|
-
export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createMemoryCache, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, extractErrorDetail, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, runActionPlugin, runWithCallerContext, sdkOptionsPluginRef, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin };
|
|
12505
|
+
export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createMemoryCache, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, extractErrorDetail, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierCausationId, getZapierCorrelationId, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, runActionPlugin, runWithCallerContext, sdkOptionsPluginRef, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin };
|
|
@@ -13,6 +13,12 @@ var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapie
|
|
|
13
13
|
function getZapierSdkService() {
|
|
14
14
|
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
15
15
|
}
|
|
16
|
+
function getZapierCorrelationId() {
|
|
17
|
+
return globalThis.process?.env?.ZAPIER_CORRELATION_ID || void 0;
|
|
18
|
+
}
|
|
19
|
+
function getZapierCausationId() {
|
|
20
|
+
return globalThis.process?.env?.ZAPIER_CAUSATION_ID || void 0;
|
|
21
|
+
}
|
|
16
22
|
var MAX_PAGE_LIMIT = 1e4;
|
|
17
23
|
var DEFAULT_PAGE_SIZE = 100;
|
|
18
24
|
var DEFAULT_ACTION_TIMEOUT_MILLISECONDS = 18e4;
|
|
@@ -1236,6 +1242,17 @@ function createZapierSendHttpRequest({
|
|
|
1236
1242
|
var CORRELATION_CALL_ID = Symbol(
|
|
1237
1243
|
"zapier.correlationCallId"
|
|
1238
1244
|
);
|
|
1245
|
+
function resolveCorrelationId({
|
|
1246
|
+
options,
|
|
1247
|
+
callId
|
|
1248
|
+
}) {
|
|
1249
|
+
return options?.correlationId || getZapierCorrelationId() || callId || void 0;
|
|
1250
|
+
}
|
|
1251
|
+
function resolveCausationId({
|
|
1252
|
+
options
|
|
1253
|
+
}) {
|
|
1254
|
+
return options?.causationId || getZapierCausationId();
|
|
1255
|
+
}
|
|
1239
1256
|
var ClientCredentialsObjectSchema = zod.z.object({
|
|
1240
1257
|
type: zod.z.enum(["client_credentials"]).optional().meta({ internal: true }),
|
|
1241
1258
|
clientId: zod.z.string().describe("OAuth client ID for authentication.").meta({ valueHint: "id" }),
|
|
@@ -2658,7 +2675,7 @@ function logRouteOverride({
|
|
|
2658
2675
|
}
|
|
2659
2676
|
|
|
2660
2677
|
// src/sdk-version.ts
|
|
2661
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
2678
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.105.0" : void 0) || "unknown";
|
|
2662
2679
|
|
|
2663
2680
|
// src/utils/open-url.ts
|
|
2664
2681
|
var nodePrefix = "node:";
|
|
@@ -3387,11 +3404,21 @@ var ZapierApiClient = class {
|
|
|
3387
3404
|
headers.set("zapier-sdk-package-operation", packageOperation);
|
|
3388
3405
|
}
|
|
3389
3406
|
}
|
|
3390
|
-
|
|
3391
|
-
|
|
3407
|
+
const correlationId = resolveCorrelationId({
|
|
3408
|
+
options: this.options,
|
|
3409
|
+
callId
|
|
3410
|
+
});
|
|
3411
|
+
if (correlationId) {
|
|
3412
|
+
headers.set("zapier-correlation-id", correlationId);
|
|
3392
3413
|
} else {
|
|
3393
3414
|
headers.delete("zapier-correlation-id");
|
|
3394
3415
|
}
|
|
3416
|
+
const causationId = resolveCausationId({ options: this.options });
|
|
3417
|
+
if (causationId) {
|
|
3418
|
+
headers.set("zapier-causation-id", causationId);
|
|
3419
|
+
} else {
|
|
3420
|
+
headers.delete("zapier-causation-id");
|
|
3421
|
+
}
|
|
3395
3422
|
}
|
|
3396
3423
|
// Helper to perform HTTP requests with JSON handling
|
|
3397
3424
|
async fetchJson(method, path, data, options = {}) {
|
|
@@ -3971,7 +3998,9 @@ var apiPlugin = kitcore.defineProperty({
|
|
|
3971
3998
|
approvalMode,
|
|
3972
3999
|
openAutoModeApprovalsInBrowser,
|
|
3973
4000
|
callerPackage,
|
|
3974
|
-
routeOverrides
|
|
4001
|
+
routeOverrides,
|
|
4002
|
+
correlationId,
|
|
4003
|
+
causationId
|
|
3975
4004
|
} = imports.sdkOptions ?? {};
|
|
3976
4005
|
return createZapierApi({
|
|
3977
4006
|
baseUrl,
|
|
@@ -3994,7 +4023,12 @@ var apiPlugin = kitcore.defineProperty({
|
|
|
3994
4023
|
routeOverrides,
|
|
3995
4024
|
// Inject the graph-composed transport so host `dispatchHttpRequest` wraps
|
|
3996
4025
|
// apply.
|
|
3997
|
-
sendHttpRequest: imports.sendHttpRequest
|
|
4026
|
+
sendHttpRequest: imports.sendHttpRequest,
|
|
4027
|
+
// Pass through unresolved so `resolveCorrelationId` / `resolveCausationId`
|
|
4028
|
+
// do the option-then-env-var chain at request time — the same helper the
|
|
4029
|
+
// event-emission hook calls, so header and MethodCalledEvent stay aligned.
|
|
4030
|
+
correlationId,
|
|
4031
|
+
causationId
|
|
3998
4032
|
});
|
|
3999
4033
|
},
|
|
4000
4034
|
get: ({ state, callContext }) => callContext?.callId ? withCorrelationId({ client: state, callId: callContext.callId }) : state
|
|
@@ -11753,7 +11787,7 @@ function computeArgumentCount(args) {
|
|
|
11753
11787
|
}
|
|
11754
11788
|
return args.filter((a) => a !== void 0).length;
|
|
11755
11789
|
}
|
|
11756
|
-
function makeMethodEndHook(emitMethodCalled) {
|
|
11790
|
+
function makeMethodEndHook(emitMethodCalled, { sdkOptions } = {}) {
|
|
11757
11791
|
return ({
|
|
11758
11792
|
methodName,
|
|
11759
11793
|
args,
|
|
@@ -11769,9 +11803,9 @@ function makeMethodEndHook(emitMethodCalled) {
|
|
|
11769
11803
|
const metadata = readMethodMetadata(annotations);
|
|
11770
11804
|
emitMethodCalled({
|
|
11771
11805
|
method_name: methodName,
|
|
11772
|
-
//
|
|
11773
|
-
//
|
|
11774
|
-
correlation_id: callId ?? null,
|
|
11806
|
+
// Same resolution as the `zapier-correlation-id` header: SDK option >
|
|
11807
|
+
// env var > per-call kitcore id. Not the `call_context` surface label.
|
|
11808
|
+
correlation_id: resolveCorrelationId({ options: sdkOptions, callId }) ?? null,
|
|
11775
11809
|
execution_duration_ms: durationMs,
|
|
11776
11810
|
success_flag: !error,
|
|
11777
11811
|
error_message: error?.message ?? null,
|
|
@@ -12165,17 +12199,20 @@ var eventEmissionPlugin = kitcore.defineProperty({
|
|
|
12165
12199
|
var eventEmissionHookPlugin = kitcore.defineHook({
|
|
12166
12200
|
namespace: "zapier",
|
|
12167
12201
|
name: "eventEmissionHook",
|
|
12168
|
-
imports: [eventEmissionPlugin],
|
|
12202
|
+
imports: [eventEmissionPlugin, sdkOptionsPluginRef],
|
|
12169
12203
|
observe: {
|
|
12170
12204
|
onMethodEnd: ({ imports, input }) => {
|
|
12171
12205
|
if (input.methodName === "getRegistry") return;
|
|
12172
|
-
const emitter = imports
|
|
12173
|
-
makeMethodEndHook(
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12206
|
+
const { eventEmission: emitter, sdkOptions } = imports;
|
|
12207
|
+
makeMethodEndHook(
|
|
12208
|
+
(data) => {
|
|
12209
|
+
emitter.emit(METHOD_CALLED_EVENT_SUBJECT, {
|
|
12210
|
+
...buildMethodCalledEvent(data),
|
|
12211
|
+
call_context: emitter.config.callContext ?? "sdk"
|
|
12212
|
+
});
|
|
12213
|
+
},
|
|
12214
|
+
{ sdkOptions }
|
|
12215
|
+
)(input);
|
|
12179
12216
|
}
|
|
12180
12217
|
}
|
|
12181
12218
|
});
|
|
@@ -12436,6 +12473,12 @@ var BaseSdkOptionsSchema = zod.z.object({
|
|
|
12436
12473
|
openAutoModeApprovalsInBrowser: zod.z.boolean().optional().describe(
|
|
12437
12474
|
"By default, auto-mode approvals do not open in a browser. Enable this option to open the approval URL and watch the approval process. Resolution order is: explicit option, then ZAPIER_OPEN_AUTO_MODE_APPROVALS_IN_BROWSER, then false."
|
|
12438
12475
|
),
|
|
12476
|
+
correlationId: zod.z.string().optional().describe(
|
|
12477
|
+
"Correlation ID for request tracing. When set, emitted as the `zapier-correlation-id` header on every outbound request. Falls back to the ZAPIER_CORRELATION_ID environment variable."
|
|
12478
|
+
).meta({ valueHint: "id" }),
|
|
12479
|
+
causationId: zod.z.string().optional().describe(
|
|
12480
|
+
"Causation ID for request tracing. When set, emitted as the `zapier-causation-id` header on every outbound request. Falls back to the ZAPIER_CAUSATION_ID environment variable."
|
|
12481
|
+
).meta({ valueHint: "id" }),
|
|
12439
12482
|
// Internal
|
|
12440
12483
|
manifestPath: zod.z.string().optional().describe("Path to a .zapierrc manifest file for app version locking.").meta({ internal: true }),
|
|
12441
12484
|
manifest: zod.z.custom().optional().describe("Manifest for app version locking.").meta({ internal: true }),
|
|
@@ -12805,6 +12848,8 @@ exports.getTableRecordPlugin = getTableRecordPlugin;
|
|
|
12805
12848
|
exports.getTokenFromCliLogin = getTokenFromCliLogin;
|
|
12806
12849
|
exports.getTtyContext = getTtyContext;
|
|
12807
12850
|
exports.getZapierApprovalMode = getZapierApprovalMode;
|
|
12851
|
+
exports.getZapierCausationId = getZapierCausationId;
|
|
12852
|
+
exports.getZapierCorrelationId = getZapierCorrelationId;
|
|
12808
12853
|
exports.getZapierDefaultApprovalMode = getZapierDefaultApprovalMode;
|
|
12809
12854
|
exports.getZapierOpenAutoModeApprovalsInBrowser = getZapierOpenAutoModeApprovalsInBrowser;
|
|
12810
12855
|
exports.getZapierSdkService = getZapierSdkService;
|