@zapier/zapier-sdk 0.102.3 → 0.102.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/{chunk-AQJZPUFM.mjs → chunk-6TIBB6TI.mjs} +80 -11
- package/dist/{chunk-GQP5NSYD.cjs → chunk-WVRZG6I6.cjs} +79 -10
- package/dist/experimental.cjs +355 -355
- package/dist/experimental.d.mts +176 -176
- package/dist/experimental.d.ts +176 -176
- package/dist/experimental.mjs +2 -2
- package/dist/{index-DmQUHMSz.d.mts → index-CfJjkJU-.d.mts} +23 -11
- package/dist/{index-DmQUHMSz.d.ts → index-CfJjkJU-.d.ts} +23 -11
- package/dist/index.cjs +277 -277
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __require } from './chunk-Y6FXYEAI.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { withPositional, createDeprecationLogger, createAsyncContext,
|
|
3
|
+
import { withPositional, declareOptionalProperty, defineProperty, createDeprecationLogger, createAsyncContext, definePlugin, sendHttpRequestPlugin, declareProperty, defineMethod, coreOptionsPluginRef, createValidator, defineFormatter, declareMethod, defineResolver, concatLists, openEnum, defineHook, getRegistryPlugin, paginate, toSnakeCase, isCoreError, toTitleCase, createSdk, CORE_ERROR_SYMBOL, CoreErrorCode, CORE_SIGNAL_SYMBOL, isCoreSignal, CORE_OPTIONS_ID } from '@zapier/kitcore';
|
|
4
4
|
export { CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, addPlugin, composePlugins, createController, createCorePlugin, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getNegatable, getRegistryPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isPositional, omitExports, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, toSnakeCase, toTitleCase } from '@zapier/kitcore';
|
|
5
5
|
import { buildHttpRequestContext, buildActionRunContext } from '@zapier/policy-context';
|
|
6
6
|
import { ListAppsQuerySchema, AppItemSchema as AppItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/apps';
|
|
@@ -1070,6 +1070,51 @@ function createSemaphore(maxPermits) {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
};
|
|
1072
1072
|
}
|
|
1073
|
+
var SDK_OPTIONS_ID = "zapier/sdkOptions";
|
|
1074
|
+
var sdkOptionsPluginRef = declareOptionalProperty({
|
|
1075
|
+
id: SDK_OPTIONS_ID
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
// src/plugins/transport/options.ts
|
|
1079
|
+
function resolveTransportFetch({
|
|
1080
|
+
fetch: customFetch,
|
|
1081
|
+
debug = false
|
|
1082
|
+
}) {
|
|
1083
|
+
const originalFetch = customFetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
1084
|
+
if (!debug) return originalFetch;
|
|
1085
|
+
return createDebugFetch({
|
|
1086
|
+
originalFetch,
|
|
1087
|
+
debugLog: createDebugLogger(debug)
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// src/plugins/transport/http-fetch.ts
|
|
1092
|
+
var httpFetchPlugin = defineProperty({
|
|
1093
|
+
namespace: "kitcore",
|
|
1094
|
+
name: "httpFetch",
|
|
1095
|
+
imports: [sdkOptionsPluginRef],
|
|
1096
|
+
setup: ({ imports }) => resolveTransportFetch({
|
|
1097
|
+
fetch: imports.sdkOptions?.fetch,
|
|
1098
|
+
debug: imports.sdkOptions?.debug
|
|
1099
|
+
}),
|
|
1100
|
+
get: ({ state }) => state
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
// src/plugins/transport/standalone.ts
|
|
1104
|
+
function createZapierSendHttpRequest({
|
|
1105
|
+
fetch: customFetch,
|
|
1106
|
+
debug
|
|
1107
|
+
}) {
|
|
1108
|
+
const sdk = createSdk(
|
|
1109
|
+
definePlugin({
|
|
1110
|
+
name: "zapierStandaloneHttpTransport",
|
|
1111
|
+
imports: [sendHttpRequestPlugin, httpFetchPlugin],
|
|
1112
|
+
exports: [sendHttpRequestPlugin]
|
|
1113
|
+
}),
|
|
1114
|
+
{ configuration: { [SDK_OPTIONS_ID]: { fetch: customFetch, debug } } }
|
|
1115
|
+
);
|
|
1116
|
+
return sdk.sendHttpRequest;
|
|
1117
|
+
}
|
|
1073
1118
|
|
|
1074
1119
|
// src/api/correlation.ts
|
|
1075
1120
|
var CORRELATION_CALL_ID = Symbol(
|
|
@@ -1987,7 +2032,7 @@ function parseDeprecationDate(value) {
|
|
|
1987
2032
|
}
|
|
1988
2033
|
|
|
1989
2034
|
// src/sdk-version.ts
|
|
1990
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.
|
|
2035
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.4" : void 0) || "unknown";
|
|
1991
2036
|
|
|
1992
2037
|
// src/utils/open-url.ts
|
|
1993
2038
|
var nodePrefix = "node:";
|
|
@@ -2275,11 +2320,23 @@ var ZapierApiClient = class {
|
|
|
2275
2320
|
mergedHeaders.set(key, value);
|
|
2276
2321
|
});
|
|
2277
2322
|
this.applyTelemetryHeaders({ headers: mergedHeaders, callId });
|
|
2323
|
+
const {
|
|
2324
|
+
authRequired: _authRequired,
|
|
2325
|
+
requiredScopes: _requiredScopes,
|
|
2326
|
+
searchParams: _searchParams,
|
|
2327
|
+
approvalContext: _approvalContext,
|
|
2328
|
+
customErrorHandler: _customErrorHandler,
|
|
2329
|
+
resource: _resource,
|
|
2330
|
+
...wireInit
|
|
2331
|
+
} = fetchInit;
|
|
2278
2332
|
let retries = 0;
|
|
2279
2333
|
while (true) {
|
|
2280
|
-
const response = await this.options.
|
|
2281
|
-
...
|
|
2282
|
-
headers
|
|
2334
|
+
const response = await this.options.sendHttpRequest({
|
|
2335
|
+
...wireInit,
|
|
2336
|
+
// Set the resolved URL and merged headers after the spread so caller
|
|
2337
|
+
// values cannot override them.
|
|
2338
|
+
url,
|
|
2339
|
+
headers: Object.fromEntries(mergedHeaders)
|
|
2283
2340
|
});
|
|
2284
2341
|
if (response.status !== 429) {
|
|
2285
2342
|
return response;
|
|
@@ -3343,7 +3400,12 @@ var createZapierApi = (options) => {
|
|
|
3343
3400
|
return new ZapierApiClient({
|
|
3344
3401
|
...options,
|
|
3345
3402
|
debug,
|
|
3346
|
-
|
|
3403
|
+
// The credential-exchange transport. Debug-wrapped here rather than in the
|
|
3404
|
+
// pipeline because `resolveAuthToken` is issued outside it.
|
|
3405
|
+
fetch: debugFetch,
|
|
3406
|
+
// Built from the caller's own `fetch`, not `debugFetch`: the pipeline wraps
|
|
3407
|
+
// for debug itself, and passing the wrapped one would log twice.
|
|
3408
|
+
sendHttpRequest: options.sendHttpRequest ?? createZapierSendHttpRequest({ fetch: options.fetch, debug })
|
|
3347
3409
|
});
|
|
3348
3410
|
};
|
|
3349
3411
|
|
|
@@ -3380,9 +3442,11 @@ function getOrCreateApiClient(config) {
|
|
|
3380
3442
|
callerPackage
|
|
3381
3443
|
});
|
|
3382
3444
|
}
|
|
3383
|
-
var
|
|
3384
|
-
|
|
3385
|
-
|
|
3445
|
+
var zapierHttpTransportPlugin = definePlugin({
|
|
3446
|
+
namespace: "zapier",
|
|
3447
|
+
name: "httpTransport",
|
|
3448
|
+
imports: [sendHttpRequestPlugin, httpFetchPlugin],
|
|
3449
|
+
exports: [sendHttpRequestPlugin]
|
|
3386
3450
|
});
|
|
3387
3451
|
|
|
3388
3452
|
// src/plugins/api/index.ts
|
|
@@ -3410,7 +3474,9 @@ function withCorrelationId({
|
|
|
3410
3474
|
var apiPlugin = defineProperty({
|
|
3411
3475
|
namespace: "zapier",
|
|
3412
3476
|
name: "api",
|
|
3413
|
-
|
|
3477
|
+
// Import the aggregate so it also provides `kitcore/httpFetch`; importing
|
|
3478
|
+
// `sendHttpRequestPlugin` alone would bypass `sdkOptions.fetch`.
|
|
3479
|
+
imports: [sdkOptionsPluginRef, zapierHttpTransportPlugin],
|
|
3414
3480
|
setup: ({ imports }) => {
|
|
3415
3481
|
const {
|
|
3416
3482
|
fetch: customFetch = globalThis.fetch,
|
|
@@ -3444,7 +3510,10 @@ var apiPlugin = defineProperty({
|
|
|
3444
3510
|
maxApprovalRetries,
|
|
3445
3511
|
approvalMode,
|
|
3446
3512
|
openAutoModeApprovalsInBrowser,
|
|
3447
|
-
callerPackage
|
|
3513
|
+
callerPackage,
|
|
3514
|
+
// Inject the graph-composed transport so host `dispatchHttpRequest` wraps
|
|
3515
|
+
// apply.
|
|
3516
|
+
sendHttpRequest: imports.sendHttpRequest
|
|
3448
3517
|
});
|
|
3449
3518
|
},
|
|
3450
3519
|
get: ({ state, callContext }) => callContext?.callId ? withCorrelationId({ client: state, callId: callContext.callId }) : state
|
|
@@ -1071,6 +1071,51 @@ function createSemaphore(maxPermits) {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
};
|
|
1073
1073
|
}
|
|
1074
|
+
var SDK_OPTIONS_ID = "zapier/sdkOptions";
|
|
1075
|
+
var sdkOptionsPluginRef = kitcore.declareOptionalProperty({
|
|
1076
|
+
id: SDK_OPTIONS_ID
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
// src/plugins/transport/options.ts
|
|
1080
|
+
function resolveTransportFetch({
|
|
1081
|
+
fetch: customFetch,
|
|
1082
|
+
debug = false
|
|
1083
|
+
}) {
|
|
1084
|
+
const originalFetch = customFetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
1085
|
+
if (!debug) return originalFetch;
|
|
1086
|
+
return createDebugFetch({
|
|
1087
|
+
originalFetch,
|
|
1088
|
+
debugLog: createDebugLogger(debug)
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// src/plugins/transport/http-fetch.ts
|
|
1093
|
+
var httpFetchPlugin = kitcore.defineProperty({
|
|
1094
|
+
namespace: "kitcore",
|
|
1095
|
+
name: "httpFetch",
|
|
1096
|
+
imports: [sdkOptionsPluginRef],
|
|
1097
|
+
setup: ({ imports }) => resolveTransportFetch({
|
|
1098
|
+
fetch: imports.sdkOptions?.fetch,
|
|
1099
|
+
debug: imports.sdkOptions?.debug
|
|
1100
|
+
}),
|
|
1101
|
+
get: ({ state }) => state
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
// src/plugins/transport/standalone.ts
|
|
1105
|
+
function createZapierSendHttpRequest({
|
|
1106
|
+
fetch: customFetch,
|
|
1107
|
+
debug
|
|
1108
|
+
}) {
|
|
1109
|
+
const sdk = kitcore.createSdk(
|
|
1110
|
+
kitcore.definePlugin({
|
|
1111
|
+
name: "zapierStandaloneHttpTransport",
|
|
1112
|
+
imports: [kitcore.sendHttpRequestPlugin, httpFetchPlugin],
|
|
1113
|
+
exports: [kitcore.sendHttpRequestPlugin]
|
|
1114
|
+
}),
|
|
1115
|
+
{ configuration: { [SDK_OPTIONS_ID]: { fetch: customFetch, debug } } }
|
|
1116
|
+
);
|
|
1117
|
+
return sdk.sendHttpRequest;
|
|
1118
|
+
}
|
|
1074
1119
|
|
|
1075
1120
|
// src/api/correlation.ts
|
|
1076
1121
|
var CORRELATION_CALL_ID = Symbol(
|
|
@@ -1988,7 +2033,7 @@ function parseDeprecationDate(value) {
|
|
|
1988
2033
|
}
|
|
1989
2034
|
|
|
1990
2035
|
// src/sdk-version.ts
|
|
1991
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.
|
|
2036
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.102.4" : void 0) || "unknown";
|
|
1992
2037
|
|
|
1993
2038
|
// src/utils/open-url.ts
|
|
1994
2039
|
var nodePrefix = "node:";
|
|
@@ -2276,11 +2321,23 @@ var ZapierApiClient = class {
|
|
|
2276
2321
|
mergedHeaders.set(key, value);
|
|
2277
2322
|
});
|
|
2278
2323
|
this.applyTelemetryHeaders({ headers: mergedHeaders, callId });
|
|
2324
|
+
const {
|
|
2325
|
+
authRequired: _authRequired,
|
|
2326
|
+
requiredScopes: _requiredScopes,
|
|
2327
|
+
searchParams: _searchParams,
|
|
2328
|
+
approvalContext: _approvalContext,
|
|
2329
|
+
customErrorHandler: _customErrorHandler,
|
|
2330
|
+
resource: _resource,
|
|
2331
|
+
...wireInit
|
|
2332
|
+
} = fetchInit;
|
|
2279
2333
|
let retries = 0;
|
|
2280
2334
|
while (true) {
|
|
2281
|
-
const response = await this.options.
|
|
2282
|
-
...
|
|
2283
|
-
headers
|
|
2335
|
+
const response = await this.options.sendHttpRequest({
|
|
2336
|
+
...wireInit,
|
|
2337
|
+
// Set the resolved URL and merged headers after the spread so caller
|
|
2338
|
+
// values cannot override them.
|
|
2339
|
+
url,
|
|
2340
|
+
headers: Object.fromEntries(mergedHeaders)
|
|
2284
2341
|
});
|
|
2285
2342
|
if (response.status !== 429) {
|
|
2286
2343
|
return response;
|
|
@@ -3344,7 +3401,12 @@ var createZapierApi = (options) => {
|
|
|
3344
3401
|
return new ZapierApiClient({
|
|
3345
3402
|
...options,
|
|
3346
3403
|
debug,
|
|
3347
|
-
|
|
3404
|
+
// The credential-exchange transport. Debug-wrapped here rather than in the
|
|
3405
|
+
// pipeline because `resolveAuthToken` is issued outside it.
|
|
3406
|
+
fetch: debugFetch,
|
|
3407
|
+
// Built from the caller's own `fetch`, not `debugFetch`: the pipeline wraps
|
|
3408
|
+
// for debug itself, and passing the wrapped one would log twice.
|
|
3409
|
+
sendHttpRequest: options.sendHttpRequest ?? createZapierSendHttpRequest({ fetch: options.fetch, debug })
|
|
3348
3410
|
});
|
|
3349
3411
|
};
|
|
3350
3412
|
|
|
@@ -3381,9 +3443,11 @@ function getOrCreateApiClient(config) {
|
|
|
3381
3443
|
callerPackage
|
|
3382
3444
|
});
|
|
3383
3445
|
}
|
|
3384
|
-
var
|
|
3385
|
-
|
|
3386
|
-
|
|
3446
|
+
var zapierHttpTransportPlugin = kitcore.definePlugin({
|
|
3447
|
+
namespace: "zapier",
|
|
3448
|
+
name: "httpTransport",
|
|
3449
|
+
imports: [kitcore.sendHttpRequestPlugin, httpFetchPlugin],
|
|
3450
|
+
exports: [kitcore.sendHttpRequestPlugin]
|
|
3387
3451
|
});
|
|
3388
3452
|
|
|
3389
3453
|
// src/plugins/api/index.ts
|
|
@@ -3411,7 +3475,9 @@ function withCorrelationId({
|
|
|
3411
3475
|
var apiPlugin = kitcore.defineProperty({
|
|
3412
3476
|
namespace: "zapier",
|
|
3413
3477
|
name: "api",
|
|
3414
|
-
|
|
3478
|
+
// Import the aggregate so it also provides `kitcore/httpFetch`; importing
|
|
3479
|
+
// `sendHttpRequestPlugin` alone would bypass `sdkOptions.fetch`.
|
|
3480
|
+
imports: [sdkOptionsPluginRef, zapierHttpTransportPlugin],
|
|
3415
3481
|
setup: ({ imports }) => {
|
|
3416
3482
|
const {
|
|
3417
3483
|
fetch: customFetch = globalThis.fetch,
|
|
@@ -3445,7 +3511,10 @@ var apiPlugin = kitcore.defineProperty({
|
|
|
3445
3511
|
maxApprovalRetries,
|
|
3446
3512
|
approvalMode,
|
|
3447
3513
|
openAutoModeApprovalsInBrowser,
|
|
3448
|
-
callerPackage
|
|
3514
|
+
callerPackage,
|
|
3515
|
+
// Inject the graph-composed transport so host `dispatchHttpRequest` wraps
|
|
3516
|
+
// apply.
|
|
3517
|
+
sendHttpRequest: imports.sendHttpRequest
|
|
3449
3518
|
});
|
|
3450
3519
|
},
|
|
3451
3520
|
get: ({ state, callContext }) => callContext?.callId ? withCorrelationId({ client: state, callId: callContext.callId }) : state
|