@zapier/zapier-sdk 0.45.0 → 0.45.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 +6 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +19 -1
- package/dist/api/types.d.ts +11 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +8 -0
- package/dist/index.cjs +31 -7
- package/dist/index.d.mts +14 -1
- package/dist/index.mjs +31 -8
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +2 -1
- package/dist/plugins/eventEmission/builders.js +1 -1
- package/dist/sdk-version.d.ts +28 -0
- package/dist/sdk-version.d.ts.map +1 -0
- package/dist/sdk-version.js +29 -0
- package/dist/types/sdk.d.ts +7 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +4 -0
- package/dist/utils/telemetry-context.d.ts.map +1 -1
- package/dist/utils/telemetry-context.js +13 -6
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.45.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cb0d898: Added telemetry headers so sdkapi can attribute traffic to the SDK entry point that produced it. Every outbound request now includes `x-zapier-sdk-version`, with `x-zapier-service` added when `ZAPIER_SDK_SERVICE` is set. Requests originating from `createZapierCliSdk` or `createZapierMcpServer` additionally include `x-zapier-sdk-package` and `x-zapier-sdk-package-version` identifying the wrapping package; direct `createZapierSdk` callers omit those two. Headers are applied after caller-supplied header merging, so they can't be spoofed via per-request `options.headers`.
|
|
8
|
+
|
|
3
9
|
## 0.45.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
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,EAGjB,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,EAGjB,MAAM,SAAS,CAAC;AAihCjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
|
package/dist/api/client.js
CHANGED
|
@@ -12,7 +12,8 @@ import { getZapierBaseUrl } from "../utils/url-utils";
|
|
|
12
12
|
import { sleep, calculateExponentialBackoffMs } from "../utils/retry-utils";
|
|
13
13
|
import { isPlainObject } from "../utils/type-guard-utils";
|
|
14
14
|
import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierTimeoutError, ZapierValidationError, ZapierNotFoundError, ZapierRateLimitError, } from "../types/errors";
|
|
15
|
-
import { ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierIsInteractive, getZapierApprovalMode, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
|
|
15
|
+
import { ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierIsInteractive, getZapierApprovalMode, getZapierSdkService, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
|
|
16
|
+
import { SDK_VERSION } from "../sdk-version";
|
|
16
17
|
import { openApproval } from "../utils/open-approval";
|
|
17
18
|
import { z } from "zod";
|
|
18
19
|
const ApprovalStatusSchema = z.enum(["pending_approval", "approved", "denied"]);
|
|
@@ -124,6 +125,7 @@ class ZapierApiClient {
|
|
|
124
125
|
inputHeaders.forEach((value, key) => {
|
|
125
126
|
mergedHeaders.set(key, value);
|
|
126
127
|
});
|
|
128
|
+
this.applyTelemetryHeaders(mergedHeaders);
|
|
127
129
|
let retries = 0;
|
|
128
130
|
// Retry loop for rate limiting (429)
|
|
129
131
|
while (true) {
|
|
@@ -573,6 +575,22 @@ class ZapierApiClient {
|
|
|
573
575
|
}
|
|
574
576
|
return headers;
|
|
575
577
|
}
|
|
578
|
+
// Telemetry headers consumed by sdkapi's ApiRequestCompletedEvent.
|
|
579
|
+
// Applied at the outbound layer (after caller-supplied header merging) so
|
|
580
|
+
// they always reflect the SDK's actual identity and can't be spoofed via
|
|
581
|
+
// options.headers.
|
|
582
|
+
applyTelemetryHeaders(headers) {
|
|
583
|
+
headers.set("x-zapier-sdk-version", SDK_VERSION);
|
|
584
|
+
const sdkService = getZapierSdkService();
|
|
585
|
+
if (sdkService) {
|
|
586
|
+
headers.set("x-zapier-service", sdkService);
|
|
587
|
+
}
|
|
588
|
+
const callerPackage = this.options.callerPackage;
|
|
589
|
+
if (callerPackage) {
|
|
590
|
+
headers.set("x-zapier-sdk-package", callerPackage.name);
|
|
591
|
+
headers.set("x-zapier-sdk-package-version", callerPackage.version);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
576
594
|
// Helper to perform HTTP requests with JSON handling
|
|
577
595
|
async fetchJson(method, path, data, options = {}) {
|
|
578
596
|
const headers = { ...options.headers };
|
package/dist/api/types.d.ts
CHANGED
|
@@ -60,6 +60,17 @@ export interface ApiClientOptions {
|
|
|
60
60
|
* keeps returning approval_required. Default: 2.
|
|
61
61
|
*/
|
|
62
62
|
maxApprovalRetries?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Identifies the wrapping package that built this client (e.g., the CLI or
|
|
65
|
+
* MCP server). When set, emitted as `x-zapier-sdk-package` /
|
|
66
|
+
* `x-zapier-sdk-package-version` telemetry headers. Omitted by direct
|
|
67
|
+
* `createZapierSdk` callers — their identity is captured by
|
|
68
|
+
* `x-zapier-sdk-version` alone.
|
|
69
|
+
*/
|
|
70
|
+
callerPackage?: {
|
|
71
|
+
name: string;
|
|
72
|
+
version: string;
|
|
73
|
+
};
|
|
63
74
|
}
|
|
64
75
|
export interface ApiClient {
|
|
65
76
|
get: <T = unknown>(path: string, options?: RequestOptions) => Promise<T>;
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACV,wBAAwB,EACxB,iCAAiC,EAClC,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,6BAA6B,EAC7B,aAAa,EACb,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,6BAA6B,EAC7B,8BAA8B,EAC/B,MAAM,WAAW,CAAC;AAMnB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAA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,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* Base URL for Zapier API endpoints
|
|
8
8
|
*/
|
|
9
9
|
export declare const ZAPIER_BASE_URL: string;
|
|
10
|
+
/**
|
|
11
|
+
* Calling service name for telemetry headers.
|
|
12
|
+
*
|
|
13
|
+
* Read lazily so tests can stub the env var after module import.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getZapierSdkService(): string | undefined;
|
|
10
16
|
/**
|
|
11
17
|
* Maximum number of items that can be requested per page across all paginated functions
|
|
12
18
|
*/
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,QACsC,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACY,CAAC;AACpD,eAAO,MAAM,iCAAiC,QACiB,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,MAAM,GAAG,SAAS,CAInE;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAiB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,QACsC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAExD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACY,CAAC;AACpD,eAAO,MAAM,iCAAiC,QACiB,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,MAAM,GAAG,SAAS,CAInE;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAiB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
* Base URL for Zapier API endpoints
|
|
8
8
|
*/
|
|
9
9
|
export const ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
|
|
10
|
+
/**
|
|
11
|
+
* Calling service name for telemetry headers.
|
|
12
|
+
*
|
|
13
|
+
* Read lazily so tests can stub the env var after module import.
|
|
14
|
+
*/
|
|
15
|
+
export function getZapierSdkService() {
|
|
16
|
+
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
17
|
+
}
|
|
10
18
|
/**
|
|
11
19
|
* Maximum number of items that can be requested per page across all paginated functions
|
|
12
20
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var policyContext = require('@zapier/policy-context');
|
|
5
|
+
var async_hooks = require('async_hooks');
|
|
5
6
|
var apps = require('@zapier/zapier-sdk-core/v0/schemas/apps');
|
|
6
7
|
var connections = require('@zapier/zapier-sdk-core/v0/schemas/connections');
|
|
7
8
|
var clientCredentials = require('@zapier/zapier-sdk-core/v0/schemas/client-credentials');
|
|
@@ -42,6 +43,9 @@ function isPositional(schema) {
|
|
|
42
43
|
|
|
43
44
|
// src/constants.ts
|
|
44
45
|
var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
|
|
46
|
+
function getZapierSdkService() {
|
|
47
|
+
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
48
|
+
}
|
|
45
49
|
var MAX_PAGE_LIMIT = 1e4;
|
|
46
50
|
var DEFAULT_PAGE_SIZE = 100;
|
|
47
51
|
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
@@ -834,12 +838,9 @@ function isPlainObject(value) {
|
|
|
834
838
|
const proto = Object.getPrototypeOf(value);
|
|
835
839
|
return proto === Object.prototype || proto === null;
|
|
836
840
|
}
|
|
837
|
-
|
|
838
|
-
// src/utils/telemetry-context.ts
|
|
839
841
|
var telemetryStore = null;
|
|
840
842
|
try {
|
|
841
|
-
|
|
842
|
-
telemetryStore = new mod.AsyncLocalStorage();
|
|
843
|
+
telemetryStore = new async_hooks.AsyncLocalStorage();
|
|
843
844
|
} catch {
|
|
844
845
|
}
|
|
845
846
|
function isTelemetryNested() {
|
|
@@ -5744,6 +5745,9 @@ async function invalidateCredentialsToken(options) {
|
|
|
5744
5745
|
}
|
|
5745
5746
|
}
|
|
5746
5747
|
|
|
5748
|
+
// src/sdk-version.ts
|
|
5749
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.45.1" : void 0) || "unknown";
|
|
5750
|
+
|
|
5747
5751
|
// src/utils/open-url.ts
|
|
5748
5752
|
var nodePrefix = "node:";
|
|
5749
5753
|
async function loadChildProcess() {
|
|
@@ -5916,6 +5920,7 @@ var ZapierApiClient = class {
|
|
|
5916
5920
|
inputHeaders.forEach((value, key) => {
|
|
5917
5921
|
mergedHeaders.set(key, value);
|
|
5918
5922
|
});
|
|
5923
|
+
this.applyTelemetryHeaders(mergedHeaders);
|
|
5919
5924
|
let retries = 0;
|
|
5920
5925
|
while (true) {
|
|
5921
5926
|
const response = await this.options.fetch(url, {
|
|
@@ -6285,6 +6290,22 @@ var ZapierApiClient = class {
|
|
|
6285
6290
|
}
|
|
6286
6291
|
return headers;
|
|
6287
6292
|
}
|
|
6293
|
+
// Telemetry headers consumed by sdkapi's ApiRequestCompletedEvent.
|
|
6294
|
+
// Applied at the outbound layer (after caller-supplied header merging) so
|
|
6295
|
+
// they always reflect the SDK's actual identity and can't be spoofed via
|
|
6296
|
+
// options.headers.
|
|
6297
|
+
applyTelemetryHeaders(headers) {
|
|
6298
|
+
headers.set("x-zapier-sdk-version", SDK_VERSION);
|
|
6299
|
+
const sdkService = getZapierSdkService();
|
|
6300
|
+
if (sdkService) {
|
|
6301
|
+
headers.set("x-zapier-service", sdkService);
|
|
6302
|
+
}
|
|
6303
|
+
const callerPackage = this.options.callerPackage;
|
|
6304
|
+
if (callerPackage) {
|
|
6305
|
+
headers.set("x-zapier-sdk-package", callerPackage.name);
|
|
6306
|
+
headers.set("x-zapier-sdk-package-version", callerPackage.version);
|
|
6307
|
+
}
|
|
6308
|
+
}
|
|
6288
6309
|
// Helper to perform HTTP requests with JSON handling
|
|
6289
6310
|
async fetchJson(method, path, data, options = {}) {
|
|
6290
6311
|
const headers = { ...options.headers };
|
|
@@ -6490,7 +6511,8 @@ var apiPlugin = (sdk) => {
|
|
|
6490
6511
|
isInteractive,
|
|
6491
6512
|
approvalTimeoutMs,
|
|
6492
6513
|
maxApprovalRetries,
|
|
6493
|
-
approvalMode
|
|
6514
|
+
approvalMode,
|
|
6515
|
+
callerPackage
|
|
6494
6516
|
} = sdk.context.options;
|
|
6495
6517
|
const api = createZapierApi({
|
|
6496
6518
|
baseUrl,
|
|
@@ -6504,7 +6526,8 @@ var apiPlugin = (sdk) => {
|
|
|
6504
6526
|
isInteractive,
|
|
6505
6527
|
approvalTimeoutMs,
|
|
6506
6528
|
maxApprovalRetries,
|
|
6507
|
-
approvalMode
|
|
6529
|
+
approvalMode,
|
|
6530
|
+
callerPackage
|
|
6508
6531
|
});
|
|
6509
6532
|
return {
|
|
6510
6533
|
context: {
|
|
@@ -8493,7 +8516,6 @@ function getCpuTime() {
|
|
|
8493
8516
|
}
|
|
8494
8517
|
|
|
8495
8518
|
// src/plugins/eventEmission/builders.ts
|
|
8496
|
-
var SDK_VERSION = globalThis.process?.env?.SDK_VERSION || "unknown";
|
|
8497
8519
|
function createBaseEvent(context = {}) {
|
|
8498
8520
|
return {
|
|
8499
8521
|
event_id: generateEventId(),
|
|
@@ -9047,6 +9069,7 @@ var BaseSdkOptionsSchema = zod.z.object({
|
|
|
9047
9069
|
onEvent: zod.z.custom().optional().meta({ internal: true }),
|
|
9048
9070
|
fetch: zod.z.custom().optional().meta({ internal: true }),
|
|
9049
9071
|
eventEmission: zod.z.custom().optional().meta({ internal: true }),
|
|
9072
|
+
callerPackage: zod.z.custom().optional().meta({ internal: true }),
|
|
9050
9073
|
canIncludeSharedConnections: zod.z.boolean().optional().describe("Allow listing shared connections."),
|
|
9051
9074
|
canIncludeSharedTables: zod.z.boolean().optional().describe("Allow listing shared tables."),
|
|
9052
9075
|
canDeleteTables: zod.z.boolean().optional().describe("Allow deleting tables."),
|
|
@@ -9181,6 +9204,7 @@ exports.getTableRecordPlugin = getTableRecordPlugin;
|
|
|
9181
9204
|
exports.getTokenFromCliLogin = getTokenFromCliLogin;
|
|
9182
9205
|
exports.getZapierApprovalMode = getZapierApprovalMode;
|
|
9183
9206
|
exports.getZapierIsInteractive = getZapierIsInteractive;
|
|
9207
|
+
exports.getZapierSdkService = getZapierSdkService;
|
|
9184
9208
|
exports.injectCliLogin = injectCliLogin;
|
|
9185
9209
|
exports.inputFieldKeyResolver = inputFieldKeyResolver;
|
|
9186
9210
|
exports.inputsAllOptionalResolver = inputsAllOptionalResolver;
|
package/dist/index.d.mts
CHANGED
|
@@ -1456,6 +1456,13 @@ declare const BaseSdkOptionsSchema: z.ZodObject<{
|
|
|
1456
1456
|
onEvent: z.ZodOptional<z.ZodCustom<EventCallback, EventCallback>>;
|
|
1457
1457
|
fetch: z.ZodOptional<z.ZodCustom<typeof fetch, typeof fetch>>;
|
|
1458
1458
|
eventEmission: z.ZodOptional<z.ZodCustom<EventEmissionConfig, EventEmissionConfig>>;
|
|
1459
|
+
callerPackage: z.ZodOptional<z.ZodCustom<{
|
|
1460
|
+
name: string;
|
|
1461
|
+
version: string;
|
|
1462
|
+
}, {
|
|
1463
|
+
name: string;
|
|
1464
|
+
version: string;
|
|
1465
|
+
}>>;
|
|
1459
1466
|
canIncludeSharedConnections: z.ZodOptional<z.ZodBoolean>;
|
|
1460
1467
|
canIncludeSharedTables: z.ZodOptional<z.ZodBoolean>;
|
|
1461
1468
|
canDeleteTables: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -3389,6 +3396,12 @@ declare function resetDeprecationWarnings(): void;
|
|
|
3389
3396
|
* Base URL for Zapier API endpoints
|
|
3390
3397
|
*/
|
|
3391
3398
|
declare const ZAPIER_BASE_URL: string;
|
|
3399
|
+
/**
|
|
3400
|
+
* Calling service name for telemetry headers.
|
|
3401
|
+
*
|
|
3402
|
+
* Read lazily so tests can stub the env var after module import.
|
|
3403
|
+
*/
|
|
3404
|
+
declare function getZapierSdkService(): string | undefined;
|
|
3392
3405
|
/**
|
|
3393
3406
|
* Maximum number of items that can be requested per page across all paginated functions
|
|
3394
3407
|
*/
|
|
@@ -3916,4 +3929,4 @@ declare const updateTableRecordsPlugin: Plugin<ApiPluginProvides & EventEmission
|
|
|
3916
3929
|
*/
|
|
3917
3930
|
declare const registryPlugin: Plugin<{}, {}>;
|
|
3918
3931
|
|
|
3919
|
-
export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionProperty, ActionPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppFactoryInput, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type AppProperty, AppPropertySchema, type ApplicationLifecycleEventData, type ApprovalStatus, type AppsPluginProvides, type AppsProperty, AppsPropertySchema, type ArrayResolver, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionEntry, ConnectionEntrySchema, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionProperty, ConnectionPropertySchema, type ConnectionsMap, ConnectionsMapSchema, type ConnectionsPluginProvides, type ConnectionsProperty, ConnectionsPropertySchema, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type CreateTableFieldsPluginProvides, type CreateTablePluginProvides, type CreateTableRecordsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DeleteTableFieldsPluginProvides, type DeleteTablePluginProvides, type DeleteTableRecordsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type EventEmissionProvides, type FetchPluginProvides, type Field, type FieldsProperty, FieldsPropertySchema, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionDeprecation, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetProfilePluginProvides, type GetTablePluginProvides, type GetTableRecordPluginProvides, type InfoFieldItem, type InputFieldItem, type InputFieldProperty, InputFieldPropertySchema, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type ListTableFieldsPluginProvides, type ListTableRecordsPluginProvides, type ListTablesPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type MethodCalledEvent, type MethodCalledEventData, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputFormatter, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginProvides, type PositionalMetadata, type RateLimitInfo, type RecordProperty, RecordPropertySchema, type RecordsProperty, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type ResolverMetadata, type RootFieldItem, type RunActionPluginProvides, type SdkEvent, type SdkPage, type StaticResolver, type TableProperty, TablePropertySchema, type TablesProperty, TablesPropertySchema, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UpdateTableRecordsPluginProvides, type UserProfile, type UserProfileItem, type WithAddPlugin, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createOptionsPlugin, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
|
3932
|
+
export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionProperty, ActionPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppFactoryInput, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type AppProperty, AppPropertySchema, type ApplicationLifecycleEventData, type ApprovalStatus, type AppsPluginProvides, type AppsProperty, AppsPropertySchema, type ArrayResolver, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionEntry, ConnectionEntrySchema, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionProperty, ConnectionPropertySchema, type ConnectionsMap, ConnectionsMapSchema, type ConnectionsPluginProvides, type ConnectionsProperty, ConnectionsPropertySchema, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type CreateTableFieldsPluginProvides, type CreateTablePluginProvides, type CreateTableRecordsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DeleteTableFieldsPluginProvides, type DeleteTablePluginProvides, type DeleteTableRecordsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type EventEmissionProvides, type FetchPluginProvides, type Field, type FieldsProperty, FieldsPropertySchema, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionDeprecation, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetProfilePluginProvides, type GetTablePluginProvides, type GetTableRecordPluginProvides, type InfoFieldItem, type InputFieldItem, type InputFieldProperty, InputFieldPropertySchema, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, type ListTableFieldsPluginProvides, type ListTableRecordsPluginProvides, type ListTablesPluginProvides, type LoadingEvent, MAX_PAGE_LIMIT, type Manifest, type ManifestEntry, type ManifestPluginOptions, type ManifestPluginProvides, type MethodCalledEvent, type MethodCalledEventData, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputFormatter, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginProvides, type PositionalMetadata, type RateLimitInfo, type RecordProperty, RecordPropertySchema, type RecordsProperty, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type ResolverMetadata, type RootFieldItem, type RunActionPluginProvides, type SdkEvent, type SdkPage, type StaticResolver, type TableProperty, TablePropertySchema, type TablesProperty, TablesPropertySchema, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UpdateTableRecordsPluginProvides, type UserProfile, type UserProfileItem, type WithAddPlugin, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createOptionsPlugin, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { buildHttpRequestContext, buildActionRunContext } from '@zapier/policy-context';
|
|
3
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
4
|
import { ListAppsQuerySchema, AppItemSchema as AppItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/apps';
|
|
4
5
|
import { ListConnectionsQuerySchema as ListConnectionsQuerySchema$1, ConnectionItemSchema as ConnectionItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/connections';
|
|
5
6
|
import { ListClientCredentialsQuerySchema as ListClientCredentialsQuerySchema$1, CreateClientCredentialsRequestSchema, ClientCredentialsItemSchema as ClientCredentialsItemSchema$1, ClientCredentialsCreatedItemSchema as ClientCredentialsCreatedItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/client-credentials';
|
|
@@ -40,6 +41,9 @@ function isPositional(schema) {
|
|
|
40
41
|
|
|
41
42
|
// src/constants.ts
|
|
42
43
|
var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
|
|
44
|
+
function getZapierSdkService() {
|
|
45
|
+
return globalThis.process?.env?.ZAPIER_SDK_SERVICE;
|
|
46
|
+
}
|
|
43
47
|
var MAX_PAGE_LIMIT = 1e4;
|
|
44
48
|
var DEFAULT_PAGE_SIZE = 100;
|
|
45
49
|
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
@@ -832,12 +836,9 @@ function isPlainObject(value) {
|
|
|
832
836
|
const proto = Object.getPrototypeOf(value);
|
|
833
837
|
return proto === Object.prototype || proto === null;
|
|
834
838
|
}
|
|
835
|
-
|
|
836
|
-
// src/utils/telemetry-context.ts
|
|
837
839
|
var telemetryStore = null;
|
|
838
840
|
try {
|
|
839
|
-
|
|
840
|
-
telemetryStore = new mod.AsyncLocalStorage();
|
|
841
|
+
telemetryStore = new AsyncLocalStorage();
|
|
841
842
|
} catch {
|
|
842
843
|
}
|
|
843
844
|
function isTelemetryNested() {
|
|
@@ -5742,6 +5743,9 @@ async function invalidateCredentialsToken(options) {
|
|
|
5742
5743
|
}
|
|
5743
5744
|
}
|
|
5744
5745
|
|
|
5746
|
+
// src/sdk-version.ts
|
|
5747
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.45.1" : void 0) || "unknown";
|
|
5748
|
+
|
|
5745
5749
|
// src/utils/open-url.ts
|
|
5746
5750
|
var nodePrefix = "node:";
|
|
5747
5751
|
async function loadChildProcess() {
|
|
@@ -5914,6 +5918,7 @@ var ZapierApiClient = class {
|
|
|
5914
5918
|
inputHeaders.forEach((value, key) => {
|
|
5915
5919
|
mergedHeaders.set(key, value);
|
|
5916
5920
|
});
|
|
5921
|
+
this.applyTelemetryHeaders(mergedHeaders);
|
|
5917
5922
|
let retries = 0;
|
|
5918
5923
|
while (true) {
|
|
5919
5924
|
const response = await this.options.fetch(url, {
|
|
@@ -6283,6 +6288,22 @@ var ZapierApiClient = class {
|
|
|
6283
6288
|
}
|
|
6284
6289
|
return headers;
|
|
6285
6290
|
}
|
|
6291
|
+
// Telemetry headers consumed by sdkapi's ApiRequestCompletedEvent.
|
|
6292
|
+
// Applied at the outbound layer (after caller-supplied header merging) so
|
|
6293
|
+
// they always reflect the SDK's actual identity and can't be spoofed via
|
|
6294
|
+
// options.headers.
|
|
6295
|
+
applyTelemetryHeaders(headers) {
|
|
6296
|
+
headers.set("x-zapier-sdk-version", SDK_VERSION);
|
|
6297
|
+
const sdkService = getZapierSdkService();
|
|
6298
|
+
if (sdkService) {
|
|
6299
|
+
headers.set("x-zapier-service", sdkService);
|
|
6300
|
+
}
|
|
6301
|
+
const callerPackage = this.options.callerPackage;
|
|
6302
|
+
if (callerPackage) {
|
|
6303
|
+
headers.set("x-zapier-sdk-package", callerPackage.name);
|
|
6304
|
+
headers.set("x-zapier-sdk-package-version", callerPackage.version);
|
|
6305
|
+
}
|
|
6306
|
+
}
|
|
6286
6307
|
// Helper to perform HTTP requests with JSON handling
|
|
6287
6308
|
async fetchJson(method, path, data, options = {}) {
|
|
6288
6309
|
const headers = { ...options.headers };
|
|
@@ -6488,7 +6509,8 @@ var apiPlugin = (sdk) => {
|
|
|
6488
6509
|
isInteractive,
|
|
6489
6510
|
approvalTimeoutMs,
|
|
6490
6511
|
maxApprovalRetries,
|
|
6491
|
-
approvalMode
|
|
6512
|
+
approvalMode,
|
|
6513
|
+
callerPackage
|
|
6492
6514
|
} = sdk.context.options;
|
|
6493
6515
|
const api = createZapierApi({
|
|
6494
6516
|
baseUrl,
|
|
@@ -6502,7 +6524,8 @@ var apiPlugin = (sdk) => {
|
|
|
6502
6524
|
isInteractive,
|
|
6503
6525
|
approvalTimeoutMs,
|
|
6504
6526
|
maxApprovalRetries,
|
|
6505
|
-
approvalMode
|
|
6527
|
+
approvalMode,
|
|
6528
|
+
callerPackage
|
|
6506
6529
|
});
|
|
6507
6530
|
return {
|
|
6508
6531
|
context: {
|
|
@@ -8491,7 +8514,6 @@ function getCpuTime() {
|
|
|
8491
8514
|
}
|
|
8492
8515
|
|
|
8493
8516
|
// src/plugins/eventEmission/builders.ts
|
|
8494
|
-
var SDK_VERSION = globalThis.process?.env?.SDK_VERSION || "unknown";
|
|
8495
8517
|
function createBaseEvent(context = {}) {
|
|
8496
8518
|
return {
|
|
8497
8519
|
event_id: generateEventId(),
|
|
@@ -9045,6 +9067,7 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
9045
9067
|
onEvent: z.custom().optional().meta({ internal: true }),
|
|
9046
9068
|
fetch: z.custom().optional().meta({ internal: true }),
|
|
9047
9069
|
eventEmission: z.custom().optional().meta({ internal: true }),
|
|
9070
|
+
callerPackage: z.custom().optional().meta({ internal: true }),
|
|
9048
9071
|
canIncludeSharedConnections: z.boolean().optional().describe("Allow listing shared connections."),
|
|
9049
9072
|
canIncludeSharedTables: z.boolean().optional().describe("Allow listing shared tables."),
|
|
9050
9073
|
canDeleteTables: z.boolean().optional().describe("Allow deleting tables."),
|
|
@@ -9061,4 +9084,4 @@ var registryPlugin = () => {
|
|
|
9061
9084
|
return {};
|
|
9062
9085
|
};
|
|
9063
9086
|
|
|
9064
|
-
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createOptionsPlugin, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
|
9087
|
+
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createOptionsPlugin, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;QACf,kBAAkB,EAAE,MAAM,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;KACpE,CAAC;CACH;AAED,eAAO,MAAM,SAAS,EAAE,MAAM,CAC5B;IAAE,OAAO,EAAE;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE,CAAA;CAAE,EACxC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;QACf,kBAAkB,EAAE,MAAM,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;KACpE,CAAC;CACH;AAED,eAAO,MAAM,SAAS,EAAE,MAAM,CAC5B;IAAE,OAAO,EAAE;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE,CAAA;CAAE,EACxC,iBAAiB,CAgDlB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { resolveCredentials } from "../../credentials";
|
|
|
3
3
|
import { ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, } from "../../constants";
|
|
4
4
|
export const apiPlugin = (sdk) => {
|
|
5
5
|
// Extract all options - everything passed to the plugin
|
|
6
|
-
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, credentials, token, onEvent, debug = false, maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES, maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, isInteractive, approvalTimeoutMs, maxApprovalRetries, approvalMode, } = sdk.context.options;
|
|
6
|
+
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, credentials, token, onEvent, debug = false, maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES, maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, isInteractive, approvalTimeoutMs, maxApprovalRetries, approvalMode, callerPackage, } = sdk.context.options;
|
|
7
7
|
// Create the API client - it will handle token resolution internally
|
|
8
8
|
const api = createZapierApi({
|
|
9
9
|
baseUrl,
|
|
@@ -18,6 +18,7 @@ export const apiPlugin = (sdk) => {
|
|
|
18
18
|
approvalTimeoutMs,
|
|
19
19
|
maxApprovalRetries,
|
|
20
20
|
approvalMode,
|
|
21
|
+
callerPackage,
|
|
21
22
|
});
|
|
22
23
|
// Return flat structure with context only
|
|
23
24
|
return {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* schema compliance for all event types.
|
|
6
6
|
*/
|
|
7
7
|
import { generateEventId, getCurrentTimestamp, getReleaseId, getOsInfo, getPlatformVersions, getMemoryUsage, getCpuTime, isCi, getCiPlatform, } from "./utils";
|
|
8
|
-
|
|
8
|
+
import { SDK_VERSION } from "../../sdk-version";
|
|
9
9
|
// Create base event with auto-populated common fields
|
|
10
10
|
// Kept for backward compatibility but can be replaced with direct construction
|
|
11
11
|
export function createBaseEvent(context = {}) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK package version, injected at build time.
|
|
3
|
+
*
|
|
4
|
+
* tsup's `define` (see `tsup.config.ts`) replaces the literal
|
|
5
|
+
* `process.env.SDK_VERSION` token with the package version string when the
|
|
6
|
+
* dist bundle is produced. That dist is what NPM publishes and what external
|
|
7
|
+
* consumers resolve via the `main`/`module` exports.
|
|
8
|
+
*
|
|
9
|
+
* In source-mode consumers (anything resolving the `source` export
|
|
10
|
+
* condition) tsup never runs, so the read falls through to a real
|
|
11
|
+
* `process.env.SDK_VERSION` env-var lookup — usually unset, hence the
|
|
12
|
+
* "unknown" fallback. The `typeof process` guard keeps the source-mode read
|
|
13
|
+
* safe in browsers where `process` is undefined; the additional
|
|
14
|
+
* `process.env` check covers oddly-shimmed environments where `process`
|
|
15
|
+
* exists but `process.env` doesn't (some bundler polyfills), preventing a
|
|
16
|
+
* TypeError on member access.
|
|
17
|
+
*
|
|
18
|
+
* The literal `process.env.SDK_VERSION` member access has to stay textually
|
|
19
|
+
* intact in this expression so esbuild's `define` matches and substitutes
|
|
20
|
+
* it; the surrounding guards don't interfere with that match.
|
|
21
|
+
*
|
|
22
|
+
* This pattern is intentionally different from the runtime env reads in
|
|
23
|
+
* `constants.ts` (`globalThis.process?.env?.X`): those must NOT be inlined
|
|
24
|
+
* because they're per-consumer config; this one MUST be inlined because
|
|
25
|
+
* it's a fixed, package-published value.
|
|
26
|
+
*/
|
|
27
|
+
export declare const SDK_VERSION: string;
|
|
28
|
+
//# sourceMappingURL=sdk-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-version.d.ts","sourceRoot":"","sources":["../src/sdk-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,WAAW,QAGK,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK package version, injected at build time.
|
|
3
|
+
*
|
|
4
|
+
* tsup's `define` (see `tsup.config.ts`) replaces the literal
|
|
5
|
+
* `process.env.SDK_VERSION` token with the package version string when the
|
|
6
|
+
* dist bundle is produced. That dist is what NPM publishes and what external
|
|
7
|
+
* consumers resolve via the `main`/`module` exports.
|
|
8
|
+
*
|
|
9
|
+
* In source-mode consumers (anything resolving the `source` export
|
|
10
|
+
* condition) tsup never runs, so the read falls through to a real
|
|
11
|
+
* `process.env.SDK_VERSION` env-var lookup — usually unset, hence the
|
|
12
|
+
* "unknown" fallback. The `typeof process` guard keeps the source-mode read
|
|
13
|
+
* safe in browsers where `process` is undefined; the additional
|
|
14
|
+
* `process.env` check covers oddly-shimmed environments where `process`
|
|
15
|
+
* exists but `process.env` doesn't (some bundler polyfills), preventing a
|
|
16
|
+
* TypeError on member access.
|
|
17
|
+
*
|
|
18
|
+
* The literal `process.env.SDK_VERSION` member access has to stay textually
|
|
19
|
+
* intact in this expression so esbuild's `define` matches and substitutes
|
|
20
|
+
* it; the surrounding guards don't interfere with that match.
|
|
21
|
+
*
|
|
22
|
+
* This pattern is intentionally different from the runtime env reads in
|
|
23
|
+
* `constants.ts` (`globalThis.process?.env?.X`): those must NOT be inlined
|
|
24
|
+
* because they're per-consumer config; this one MUST be inlined because
|
|
25
|
+
* it's a fixed, package-published value.
|
|
26
|
+
*/
|
|
27
|
+
export const SDK_VERSION = (typeof process !== "undefined" && process.env
|
|
28
|
+
? process.env.SDK_VERSION
|
|
29
|
+
: undefined) || "unknown";
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -69,6 +69,13 @@ export declare const BaseSdkOptionsSchema: z.ZodObject<{
|
|
|
69
69
|
onEvent: z.ZodOptional<z.ZodCustom<EventCallback, EventCallback>>;
|
|
70
70
|
fetch: z.ZodOptional<z.ZodCustom<typeof fetch, typeof fetch>>;
|
|
71
71
|
eventEmission: z.ZodOptional<z.ZodCustom<EventEmissionConfig, EventEmissionConfig>>;
|
|
72
|
+
callerPackage: z.ZodOptional<z.ZodCustom<{
|
|
73
|
+
name: string;
|
|
74
|
+
version: string;
|
|
75
|
+
}, {
|
|
76
|
+
name: string;
|
|
77
|
+
version: string;
|
|
78
|
+
}>>;
|
|
72
79
|
canIncludeSharedConnections: z.ZodOptional<z.ZodBoolean>;
|
|
73
80
|
canIncludeSharedTables: z.ZodOptional<z.ZodBoolean>;
|
|
74
81
|
canDeleteTables: z.ZodOptional<z.ZodBoolean>;
|
package/dist/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgFb,MAAM;iBAAW,MAAM;;cAAvB,MAAM;iBAAW,MAAM;;;;;;iBAgBzC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAG7E,MAAM,WAAW,kBACf,SAAQ,0BAA0B,EAChC,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,uBAAuB;CAAG"}
|
package/dist/types/sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-context.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"telemetry-context.d.ts","sourceRoot":"","sources":["../../src/utils/telemetry-context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAwBD,wBAAgB,iBAAiB,IAAI,OAAO,CAI3C;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAIzD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAKhE;AAED,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAG9D"}
|
|
@@ -3,16 +3,23 @@
|
|
|
3
3
|
* SDK method call runs in its own ALS scope (via runWithTelemetryContext), isolating
|
|
4
4
|
* its depth counter and method metadata from concurrent calls.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
//
|
|
6
|
+
import { AsyncLocalStorage, } from "node:async_hooks";
|
|
7
|
+
// Static import of `AsyncLocalStorage` works in both CJS and ESM tsup bundles
|
|
8
|
+
// because tsup converts the import statement directly (to `require()` in CJS,
|
|
9
|
+
// kept as native `import` in ESM), bypassing the `__require` shim that
|
|
10
|
+
// silently broke the previous `require("node:async_hooks")` pattern in ESM —
|
|
11
|
+
// the bug that left ESM consumers (notably the CLI) without a telemetry
|
|
12
|
+
// store and dropped nested-call detection on every call.
|
|
13
|
+
//
|
|
14
|
+
// Browsers can't resolve `node:async_hooks` at bundle time; consumers who
|
|
15
|
+
// bundle the SDK for browsers need to mark this module external or polyfill
|
|
16
|
+
// it. The try/catch covers any other instantiation failure.
|
|
8
17
|
let telemetryStore = null;
|
|
9
18
|
try {
|
|
10
|
-
|
|
11
|
-
telemetryStore = new mod.AsyncLocalStorage();
|
|
19
|
+
telemetryStore = new AsyncLocalStorage();
|
|
12
20
|
}
|
|
13
21
|
catch {
|
|
14
|
-
//
|
|
15
|
-
// always returns true) since we can't reliably deduplicate nested calls.
|
|
22
|
+
// Non-Node environment (browser, etc.) — telemetry context disabled.
|
|
16
23
|
}
|
|
17
24
|
export function isTelemetryNested() {
|
|
18
25
|
if (!telemetryStore)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.1",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -42,7 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"browser": {
|
|
44
44
|
"@zapier/zapier-sdk-cli/login": false,
|
|
45
|
-
"@zapier/zapier-sdk-cli-login": false
|
|
45
|
+
"@zapier/zapier-sdk-cli-login": false,
|
|
46
|
+
"async_hooks": false,
|
|
47
|
+
"node:async_hooks": false,
|
|
48
|
+
"os": false,
|
|
49
|
+
"node:os": false
|
|
46
50
|
},
|
|
47
51
|
"files": [
|
|
48
52
|
"dist",
|