@zapier/zapier-sdk 0.32.4 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +1 -0
- package/dist/constants.d.ts +0 -14
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -14
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +19 -20
- package/dist/index.cjs +30 -48
- package/dist/index.d.mts +1 -16
- package/dist/index.mjs +31 -41
- package/dist/plugins/eventEmission/builders.js +5 -5
- package/dist/plugins/eventEmission/builders.test.js +74 -1
- package/dist/plugins/eventEmission/index.test.js +8 -0
- package/dist/plugins/eventEmission/types.d.ts +0 -1
- package/dist/plugins/eventEmission/types.d.ts.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f442359: Credential env vars (ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_SCOPE) are now read at call time rather than at import time. If you set or modify these env vars after importing the SDK, the updated values will now be picked up correctly. Also fixes baseUrl not being passed through when calling resolveAuthToken with an explicit baseUrl option.
|
|
8
|
+
|
|
9
|
+
## 0.32.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0feaeb1: Fix telemetry sdk_version via build-time constant
|
|
14
|
+
|
|
3
15
|
## 0.32.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","s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CAAC;IACf,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhB"}
|
package/dist/auth.js
CHANGED
|
@@ -249,6 +249,7 @@ export async function resolveAuthToken(options = {}) {
|
|
|
249
249
|
const credentials = await resolveCredentials({
|
|
250
250
|
credentials: options.credentials,
|
|
251
251
|
token: options.token,
|
|
252
|
+
baseUrl: options.baseUrl,
|
|
252
253
|
});
|
|
253
254
|
// If we got credentials, process them based on type
|
|
254
255
|
if (credentials !== undefined) {
|
package/dist/constants.d.ts
CHANGED
|
@@ -15,23 +15,9 @@ export declare const MAX_PAGE_LIMIT = 10000;
|
|
|
15
15
|
* Default timeout for action execution (in milliseconds)
|
|
16
16
|
*/
|
|
17
17
|
export declare const DEFAULT_ACTION_TIMEOUT_MS = 180000;
|
|
18
|
-
/**
|
|
19
|
-
* Credentials from environment variables
|
|
20
|
-
*/
|
|
21
|
-
export declare const ZAPIER_CREDENTIALS: string | undefined;
|
|
22
|
-
export declare const ZAPIER_CREDENTIALS_CLIENT_ID: string | undefined;
|
|
23
|
-
export declare const ZAPIER_CREDENTIALS_CLIENT_SECRET: string | undefined;
|
|
24
|
-
export declare const ZAPIER_CREDENTIALS_BASE_URL: string | undefined;
|
|
25
|
-
export declare const ZAPIER_CREDENTIALS_SCOPE: string | undefined;
|
|
26
18
|
/**
|
|
27
19
|
* Network retry configuration from environment variables
|
|
28
20
|
*/
|
|
29
21
|
export declare const ZAPIER_MAX_NETWORK_RETRIES: number;
|
|
30
22
|
export declare const ZAPIER_MAX_NETWORK_RETRY_DELAY_MS: number;
|
|
31
|
-
/**
|
|
32
|
-
* Deprecated environment variables (kept for backwards compatibility)
|
|
33
|
-
*/
|
|
34
|
-
export declare const ZAPIER_TOKEN: string | undefined;
|
|
35
|
-
export declare const ZAPIER_AUTH_BASE_URL: string | undefined;
|
|
36
|
-
export declare const ZAPIER_AUTH_CLIENT_ID: string | undefined;
|
|
37
23
|
//# sourceMappingURL=constants.d.ts.map
|
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,QACyB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,QACyB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACY,CAAC;AACpD,eAAO,MAAM,iCAAiC,QACiB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -15,14 +15,6 @@ export const MAX_PAGE_LIMIT = 10000;
|
|
|
15
15
|
* Default timeout for action execution (in milliseconds)
|
|
16
16
|
*/
|
|
17
17
|
export const DEFAULT_ACTION_TIMEOUT_MS = 180000;
|
|
18
|
-
/**
|
|
19
|
-
* Credentials from environment variables
|
|
20
|
-
*/
|
|
21
|
-
export const ZAPIER_CREDENTIALS = process.env.ZAPIER_CREDENTIALS;
|
|
22
|
-
export const ZAPIER_CREDENTIALS_CLIENT_ID = process.env.ZAPIER_CREDENTIALS_CLIENT_ID;
|
|
23
|
-
export const ZAPIER_CREDENTIALS_CLIENT_SECRET = process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET;
|
|
24
|
-
export const ZAPIER_CREDENTIALS_BASE_URL = process.env.ZAPIER_CREDENTIALS_BASE_URL;
|
|
25
|
-
export const ZAPIER_CREDENTIALS_SCOPE = process.env.ZAPIER_CREDENTIALS_SCOPE;
|
|
26
18
|
function parseIntEnvVar(name) {
|
|
27
19
|
const value = process.env[name];
|
|
28
20
|
if (value === undefined)
|
|
@@ -39,9 +31,3 @@ function parseIntEnvVar(name) {
|
|
|
39
31
|
*/
|
|
40
32
|
export const ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
41
33
|
export const ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 60000;
|
|
42
|
-
/**
|
|
43
|
-
* Deprecated environment variables (kept for backwards compatibility)
|
|
44
|
-
*/
|
|
45
|
-
export const ZAPIER_TOKEN = process.env.ZAPIER_TOKEN;
|
|
46
|
-
export const ZAPIER_AUTH_BASE_URL = process.env.ZAPIER_AUTH_BASE_URL;
|
|
47
|
-
export const ZAPIER_AUTH_CLIENT_ID = process.env.ZAPIER_AUTH_CLIENT_ID;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EAEpB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EAEpB,MAAM,qBAAqB,CAAC;AAY7B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAqDD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,CAAC,EAAE,MAAM,GAClB,mBAAmB,GAAG,SAAS,CAyDjC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAkD1C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,mBAAmB,GAAG,SAAS,GAC3C,MAAM,GAAG,SAAS,CAKpB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,mBAAmB,GAAG,SAAS,GAC3C,MAAM,GAAG,SAAS,CAKpB"}
|
package/dist/credentials.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { isCredentialsFunction, isCredentialsObject, } from "./types/credentials";
|
|
11
11
|
import { logDeprecation } from "./utils/logging";
|
|
12
12
|
import { getZapierBaseUrl } from "./utils/url-utils";
|
|
13
|
-
import { ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_TOKEN, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, } from "./constants";
|
|
14
13
|
/**
|
|
15
14
|
* Derive the auth base URL from the SDK base URL.
|
|
16
15
|
* Returns the Zapier root domain (e.g., https://zapier.com from https://api.zapier.com).
|
|
@@ -28,9 +27,9 @@ function normalizeCredentialsObject(obj, sdkBaseUrl) {
|
|
|
28
27
|
// Build defaults from env vars for optional fields, then override with explicit credentials.
|
|
29
28
|
// clientId is required in CredentialsObject so it always comes from obj.
|
|
30
29
|
const merged = {
|
|
31
|
-
clientSecret: ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
32
|
-
baseUrl: ZAPIER_CREDENTIALS_BASE_URL,
|
|
33
|
-
scope: ZAPIER_CREDENTIALS_SCOPE,
|
|
30
|
+
clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
31
|
+
baseUrl: process.env.ZAPIER_CREDENTIALS_BASE_URL,
|
|
32
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE,
|
|
34
33
|
...obj,
|
|
35
34
|
};
|
|
36
35
|
// Derive baseUrl from SDK if still not set
|
|
@@ -66,45 +65,45 @@ function normalizeCredentialsObject(obj, sdkBaseUrl) {
|
|
|
66
65
|
*/
|
|
67
66
|
export function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
68
67
|
// 1. Check ZAPIER_CREDENTIALS (string token only)
|
|
69
|
-
if (ZAPIER_CREDENTIALS) {
|
|
70
|
-
return ZAPIER_CREDENTIALS;
|
|
68
|
+
if (process.env.ZAPIER_CREDENTIALS) {
|
|
69
|
+
return process.env.ZAPIER_CREDENTIALS;
|
|
71
70
|
}
|
|
72
71
|
// 2. Check ZAPIER_CREDENTIALS_* individual vars
|
|
73
|
-
if (ZAPIER_CREDENTIALS_CLIENT_ID) {
|
|
74
|
-
const resolvedBaseUrl = ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
72
|
+
if (process.env.ZAPIER_CREDENTIALS_CLIENT_ID) {
|
|
73
|
+
const resolvedBaseUrl = process.env.ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
75
74
|
// Infer type from presence of clientSecret
|
|
76
|
-
if (ZAPIER_CREDENTIALS_CLIENT_SECRET) {
|
|
75
|
+
if (process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET) {
|
|
77
76
|
return {
|
|
78
77
|
type: "client_credentials",
|
|
79
|
-
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
80
|
-
clientSecret: ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
78
|
+
clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
79
|
+
clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
81
80
|
baseUrl: resolvedBaseUrl,
|
|
82
|
-
scope: ZAPIER_CREDENTIALS_SCOPE,
|
|
81
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE,
|
|
83
82
|
};
|
|
84
83
|
}
|
|
85
84
|
else {
|
|
86
85
|
return {
|
|
87
86
|
type: "pkce",
|
|
88
|
-
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
87
|
+
clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
89
88
|
baseUrl: resolvedBaseUrl,
|
|
90
|
-
scope: ZAPIER_CREDENTIALS_SCOPE,
|
|
89
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE,
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
// 3. Check deprecated env vars (with warnings)
|
|
95
|
-
if (ZAPIER_TOKEN) {
|
|
94
|
+
if (process.env.ZAPIER_TOKEN) {
|
|
96
95
|
logDeprecation("ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead.");
|
|
97
|
-
return ZAPIER_TOKEN;
|
|
96
|
+
return process.env.ZAPIER_TOKEN;
|
|
98
97
|
}
|
|
99
|
-
if (ZAPIER_AUTH_CLIENT_ID) {
|
|
98
|
+
if (process.env.ZAPIER_AUTH_CLIENT_ID) {
|
|
100
99
|
logDeprecation("ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead.");
|
|
101
|
-
if (ZAPIER_AUTH_BASE_URL) {
|
|
100
|
+
if (process.env.ZAPIER_AUTH_BASE_URL) {
|
|
102
101
|
logDeprecation("ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead.");
|
|
103
102
|
}
|
|
104
|
-
const resolvedBaseUrl = ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
103
|
+
const resolvedBaseUrl = process.env.ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
105
104
|
return {
|
|
106
105
|
type: "pkce",
|
|
107
|
-
clientId: ZAPIER_AUTH_CLIENT_ID,
|
|
106
|
+
clientId: process.env.ZAPIER_AUTH_CLIENT_ID,
|
|
108
107
|
baseUrl: resolvedBaseUrl,
|
|
109
108
|
};
|
|
110
109
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -65,11 +65,6 @@ function isPositional(schema) {
|
|
|
65
65
|
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
66
66
|
var MAX_PAGE_LIMIT = 1e4;
|
|
67
67
|
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
68
|
-
var ZAPIER_CREDENTIALS = process.env.ZAPIER_CREDENTIALS;
|
|
69
|
-
var ZAPIER_CREDENTIALS_CLIENT_ID = process.env.ZAPIER_CREDENTIALS_CLIENT_ID;
|
|
70
|
-
var ZAPIER_CREDENTIALS_CLIENT_SECRET = process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET;
|
|
71
|
-
var ZAPIER_CREDENTIALS_BASE_URL = process.env.ZAPIER_CREDENTIALS_BASE_URL;
|
|
72
|
-
var ZAPIER_CREDENTIALS_SCOPE = process.env.ZAPIER_CREDENTIALS_SCOPE;
|
|
73
68
|
function parseIntEnvVar(name) {
|
|
74
69
|
const value = process.env[name];
|
|
75
70
|
if (value === void 0) return void 0;
|
|
@@ -84,9 +79,6 @@ function parseIntEnvVar(name) {
|
|
|
84
79
|
}
|
|
85
80
|
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
86
81
|
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
87
|
-
var ZAPIER_TOKEN = process.env.ZAPIER_TOKEN;
|
|
88
|
-
var ZAPIER_AUTH_BASE_URL = process.env.ZAPIER_AUTH_BASE_URL;
|
|
89
|
-
var ZAPIER_AUTH_CLIENT_ID = process.env.ZAPIER_AUTH_CLIENT_ID;
|
|
90
82
|
|
|
91
83
|
// src/types/properties.ts
|
|
92
84
|
var AppKeyPropertySchema = withPositional(
|
|
@@ -4073,9 +4065,9 @@ function deriveAuthBaseUrl(sdkBaseUrl) {
|
|
|
4073
4065
|
}
|
|
4074
4066
|
function normalizeCredentialsObject(obj, sdkBaseUrl) {
|
|
4075
4067
|
const merged = {
|
|
4076
|
-
clientSecret: ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4077
|
-
baseUrl: ZAPIER_CREDENTIALS_BASE_URL,
|
|
4078
|
-
scope: ZAPIER_CREDENTIALS_SCOPE,
|
|
4068
|
+
clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4069
|
+
baseUrl: process.env.ZAPIER_CREDENTIALS_BASE_URL,
|
|
4070
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE,
|
|
4079
4071
|
...obj
|
|
4080
4072
|
};
|
|
4081
4073
|
const resolvedBaseUrl = merged.baseUrl || deriveAuthBaseUrl(sdkBaseUrl);
|
|
@@ -4096,47 +4088,47 @@ function normalizeCredentialsObject(obj, sdkBaseUrl) {
|
|
|
4096
4088
|
};
|
|
4097
4089
|
}
|
|
4098
4090
|
function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
4099
|
-
if (ZAPIER_CREDENTIALS) {
|
|
4100
|
-
return ZAPIER_CREDENTIALS;
|
|
4091
|
+
if (process.env.ZAPIER_CREDENTIALS) {
|
|
4092
|
+
return process.env.ZAPIER_CREDENTIALS;
|
|
4101
4093
|
}
|
|
4102
|
-
if (ZAPIER_CREDENTIALS_CLIENT_ID) {
|
|
4103
|
-
const resolvedBaseUrl = ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4104
|
-
if (ZAPIER_CREDENTIALS_CLIENT_SECRET) {
|
|
4094
|
+
if (process.env.ZAPIER_CREDENTIALS_CLIENT_ID) {
|
|
4095
|
+
const resolvedBaseUrl = process.env.ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4096
|
+
if (process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET) {
|
|
4105
4097
|
return {
|
|
4106
4098
|
type: "client_credentials",
|
|
4107
|
-
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4108
|
-
clientSecret: ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4099
|
+
clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4100
|
+
clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4109
4101
|
baseUrl: resolvedBaseUrl,
|
|
4110
|
-
scope: ZAPIER_CREDENTIALS_SCOPE
|
|
4102
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE
|
|
4111
4103
|
};
|
|
4112
4104
|
} else {
|
|
4113
4105
|
return {
|
|
4114
4106
|
type: "pkce",
|
|
4115
|
-
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4107
|
+
clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4116
4108
|
baseUrl: resolvedBaseUrl,
|
|
4117
|
-
scope: ZAPIER_CREDENTIALS_SCOPE
|
|
4109
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE
|
|
4118
4110
|
};
|
|
4119
4111
|
}
|
|
4120
4112
|
}
|
|
4121
|
-
if (ZAPIER_TOKEN) {
|
|
4113
|
+
if (process.env.ZAPIER_TOKEN) {
|
|
4122
4114
|
logDeprecation(
|
|
4123
4115
|
"ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
|
|
4124
4116
|
);
|
|
4125
|
-
return ZAPIER_TOKEN;
|
|
4117
|
+
return process.env.ZAPIER_TOKEN;
|
|
4126
4118
|
}
|
|
4127
|
-
if (ZAPIER_AUTH_CLIENT_ID) {
|
|
4119
|
+
if (process.env.ZAPIER_AUTH_CLIENT_ID) {
|
|
4128
4120
|
logDeprecation(
|
|
4129
4121
|
"ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
|
|
4130
4122
|
);
|
|
4131
|
-
if (ZAPIER_AUTH_BASE_URL) {
|
|
4123
|
+
if (process.env.ZAPIER_AUTH_BASE_URL) {
|
|
4132
4124
|
logDeprecation(
|
|
4133
4125
|
"ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
|
|
4134
4126
|
);
|
|
4135
4127
|
}
|
|
4136
|
-
const resolvedBaseUrl = ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4128
|
+
const resolvedBaseUrl = process.env.ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4137
4129
|
return {
|
|
4138
4130
|
type: "pkce",
|
|
4139
|
-
clientId: ZAPIER_AUTH_CLIENT_ID,
|
|
4131
|
+
clientId: process.env.ZAPIER_AUTH_CLIENT_ID,
|
|
4140
4132
|
baseUrl: resolvedBaseUrl
|
|
4141
4133
|
};
|
|
4142
4134
|
}
|
|
@@ -4335,7 +4327,8 @@ async function getTokenFromCliLogin(options) {
|
|
|
4335
4327
|
async function resolveAuthToken(options = {}) {
|
|
4336
4328
|
const credentials = await resolveCredentials({
|
|
4337
4329
|
credentials: options.credentials,
|
|
4338
|
-
token: options.token
|
|
4330
|
+
token: options.token,
|
|
4331
|
+
baseUrl: options.baseUrl
|
|
4339
4332
|
});
|
|
4340
4333
|
if (credentials !== void 0) {
|
|
4341
4334
|
return resolveAuthTokenFromCredentials(credentials, options);
|
|
@@ -5518,11 +5511,8 @@ function getCpuTime() {
|
|
|
5518
5511
|
return null;
|
|
5519
5512
|
}
|
|
5520
5513
|
|
|
5521
|
-
// package.json
|
|
5522
|
-
var package_default = {
|
|
5523
|
-
version: "0.32.4"};
|
|
5524
|
-
|
|
5525
5514
|
// src/plugins/eventEmission/builders.ts
|
|
5515
|
+
var SDK_VERSION = "0.33.0";
|
|
5526
5516
|
function createBaseEvent(context = {}) {
|
|
5527
5517
|
return {
|
|
5528
5518
|
event_id: generateEventId(),
|
|
@@ -5544,8 +5534,8 @@ function buildErrorEvent(data, context = {}) {
|
|
|
5544
5534
|
app_id: context.app_id,
|
|
5545
5535
|
app_version_id: context.app_version_id,
|
|
5546
5536
|
environment: context.environment,
|
|
5547
|
-
|
|
5548
|
-
|
|
5537
|
+
...data,
|
|
5538
|
+
sdk_version: SDK_VERSION
|
|
5549
5539
|
};
|
|
5550
5540
|
}
|
|
5551
5541
|
function buildApplicationLifecycleEvent(data, context = {}) {
|
|
@@ -5556,7 +5546,6 @@ function buildApplicationLifecycleEvent(data, context = {}) {
|
|
|
5556
5546
|
selected_api: context.selected_api,
|
|
5557
5547
|
app_id: context.app_id,
|
|
5558
5548
|
app_version_id: context.app_version_id,
|
|
5559
|
-
sdk_version: package_default.version,
|
|
5560
5549
|
cli_version: null,
|
|
5561
5550
|
memory_usage_bytes: data.memory_usage_bytes ?? getMemoryUsage(),
|
|
5562
5551
|
cpu_time_ms: data.cpu_time_ms ?? getCpuTime(),
|
|
@@ -5570,7 +5559,8 @@ function buildApplicationLifecycleEvent(data, context = {}) {
|
|
|
5570
5559
|
session_id: null,
|
|
5571
5560
|
metadata: null,
|
|
5572
5561
|
process_argv: process.argv || null,
|
|
5573
|
-
...data
|
|
5562
|
+
...data,
|
|
5563
|
+
sdk_version: SDK_VERSION
|
|
5574
5564
|
};
|
|
5575
5565
|
}
|
|
5576
5566
|
function buildErrorEventWithContext(data, context = {}) {
|
|
@@ -5583,9 +5573,9 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
5583
5573
|
app_id: context.app_id,
|
|
5584
5574
|
app_version_id: context.app_version_id,
|
|
5585
5575
|
environment: context.environment ?? (process.env.NODE_ENV || null),
|
|
5586
|
-
sdk_version: package_default.version,
|
|
5587
5576
|
execution_time_before_error_ms: executionTime,
|
|
5588
|
-
...data
|
|
5577
|
+
...data,
|
|
5578
|
+
sdk_version: SDK_VERSION
|
|
5589
5579
|
};
|
|
5590
5580
|
}
|
|
5591
5581
|
function buildMethodCalledEvent(data, context = {}) {
|
|
@@ -5599,7 +5589,6 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
5599
5589
|
error_type: data.error_type ?? null,
|
|
5600
5590
|
argument_count: data.argument_count,
|
|
5601
5591
|
is_paginated: data.is_paginated ?? false,
|
|
5602
|
-
sdk_version: package_default.version,
|
|
5603
5592
|
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
5604
5593
|
selected_api: data.selected_api ?? context.selected_api ?? null,
|
|
5605
5594
|
app_id: context.app_id ?? null,
|
|
@@ -5617,7 +5606,8 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
5617
5606
|
call_stack_depth: null,
|
|
5618
5607
|
is_synchronous: false,
|
|
5619
5608
|
cpu_time_ms: null,
|
|
5620
|
-
memory_usage_bytes: null
|
|
5609
|
+
memory_usage_bytes: null,
|
|
5610
|
+
sdk_version: SDK_VERSION
|
|
5621
5611
|
};
|
|
5622
5612
|
}
|
|
5623
5613
|
|
|
@@ -6064,17 +6054,9 @@ exports.PkceCredentialsObjectSchema = PkceCredentialsObjectSchema;
|
|
|
6064
6054
|
exports.RelayFetchSchema = RelayFetchSchema;
|
|
6065
6055
|
exports.RelayRequestSchema = RelayRequestSchema;
|
|
6066
6056
|
exports.ResolvedCredentialsSchema = ResolvedCredentialsSchema;
|
|
6067
|
-
exports.ZAPIER_AUTH_BASE_URL = ZAPIER_AUTH_BASE_URL;
|
|
6068
|
-
exports.ZAPIER_AUTH_CLIENT_ID = ZAPIER_AUTH_CLIENT_ID;
|
|
6069
6057
|
exports.ZAPIER_BASE_URL = ZAPIER_BASE_URL;
|
|
6070
|
-
exports.ZAPIER_CREDENTIALS = ZAPIER_CREDENTIALS;
|
|
6071
|
-
exports.ZAPIER_CREDENTIALS_BASE_URL = ZAPIER_CREDENTIALS_BASE_URL;
|
|
6072
|
-
exports.ZAPIER_CREDENTIALS_CLIENT_ID = ZAPIER_CREDENTIALS_CLIENT_ID;
|
|
6073
|
-
exports.ZAPIER_CREDENTIALS_CLIENT_SECRET = ZAPIER_CREDENTIALS_CLIENT_SECRET;
|
|
6074
|
-
exports.ZAPIER_CREDENTIALS_SCOPE = ZAPIER_CREDENTIALS_SCOPE;
|
|
6075
6058
|
exports.ZAPIER_MAX_NETWORK_RETRIES = ZAPIER_MAX_NETWORK_RETRIES;
|
|
6076
6059
|
exports.ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS;
|
|
6077
|
-
exports.ZAPIER_TOKEN = ZAPIER_TOKEN;
|
|
6078
6060
|
exports.ZapierActionError = ZapierActionError;
|
|
6079
6061
|
exports.ZapierApiError = ZapierApiError;
|
|
6080
6062
|
exports.ZapierAppNotFoundError = ZapierAppNotFoundError;
|
package/dist/index.d.mts
CHANGED
|
@@ -257,7 +257,6 @@ interface EventContext {
|
|
|
257
257
|
zap_id?: number | null;
|
|
258
258
|
node_id?: number | null;
|
|
259
259
|
environment?: string | null;
|
|
260
|
-
sdk_version?: string | null;
|
|
261
260
|
operation_type?: string | null;
|
|
262
261
|
}
|
|
263
262
|
interface ErrorEventData {
|
|
@@ -2769,25 +2768,11 @@ declare const MAX_PAGE_LIMIT = 10000;
|
|
|
2769
2768
|
* Default timeout for action execution (in milliseconds)
|
|
2770
2769
|
*/
|
|
2771
2770
|
declare const DEFAULT_ACTION_TIMEOUT_MS = 180000;
|
|
2772
|
-
/**
|
|
2773
|
-
* Credentials from environment variables
|
|
2774
|
-
*/
|
|
2775
|
-
declare const ZAPIER_CREDENTIALS: string | undefined;
|
|
2776
|
-
declare const ZAPIER_CREDENTIALS_CLIENT_ID: string | undefined;
|
|
2777
|
-
declare const ZAPIER_CREDENTIALS_CLIENT_SECRET: string | undefined;
|
|
2778
|
-
declare const ZAPIER_CREDENTIALS_BASE_URL: string | undefined;
|
|
2779
|
-
declare const ZAPIER_CREDENTIALS_SCOPE: string | undefined;
|
|
2780
2771
|
/**
|
|
2781
2772
|
* Network retry configuration from environment variables
|
|
2782
2773
|
*/
|
|
2783
2774
|
declare const ZAPIER_MAX_NETWORK_RETRIES: number;
|
|
2784
2775
|
declare const ZAPIER_MAX_NETWORK_RETRY_DELAY_MS: number;
|
|
2785
|
-
/**
|
|
2786
|
-
* Deprecated environment variables (kept for backwards compatibility)
|
|
2787
|
-
*/
|
|
2788
|
-
declare const ZAPIER_TOKEN: string | undefined;
|
|
2789
|
-
declare const ZAPIER_AUTH_BASE_URL: string | undefined;
|
|
2790
|
-
declare const ZAPIER_AUTH_CLIENT_ID: string | undefined;
|
|
2791
2776
|
|
|
2792
2777
|
interface ZapierSdkOptions extends BaseSdkOptions {
|
|
2793
2778
|
}
|
|
@@ -2974,4 +2959,4 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
|
|
|
2974
2959
|
}>;
|
|
2975
2960
|
declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
|
|
2976
2961
|
|
|
2977
|
-
export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, 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 OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, type RateLimitInfo, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type StaticResolver, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UserProfile, type UserProfileItem,
|
|
2962
|
+
export { type Action, type ActionEntry, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTimeoutMsProperty, ActionTimeoutMsPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type AddActionEntryOptions, type AddActionEntryResult, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type ApplicationLifecycleEventData, type AppsPluginProvides, type AuthEvent, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type BaseEvent, BaseSdkOptionsSchema, type BatchOptions, type Choice, type ClientCredentialsObject, ClientCredentialsObjectSchema, type Connection, type ConnectionIdProperty, ConnectionIdPropertySchema, type ConnectionItem, type ConnectionsResponse, type CreateClientCredentialsPluginProvides, type Credentials, type CredentialsFunction, CredentialsFunctionSchema, type CredentialsObject, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type DeleteClientCredentialsPluginProvides, type DynamicResolver, type EnhancedErrorEventData, type ErrorOptions, type EventCallback, type EventContext, type EventEmissionContext, type FetchPluginProvides, type Field, type FieldsResolver, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindFirstConnectionPluginProvides, type FindUniqueAuthenticationPluginProvides, type FindUniqueConnectionPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetConnectionPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListClientCredentialsPluginProvides, type ListConnectionsPluginProvides, type ListInputFieldsPluginProvides, 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 OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type PkceCredentialsObject, PkceCredentialsObjectSchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, type RateLimitInfo, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type ResolveAuthTokenOptions, type ResolveCredentialsOptions, type ResolvedCredentials, ResolvedCredentialsSchema, type Resolver, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type StaticResolver, type UpdateManifestEntryOptions, type UpdateManifestEntryResult, type UserProfile, type UserProfileItem, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, 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, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
|
package/dist/index.mjs
CHANGED
|
@@ -43,11 +43,6 @@ function isPositional(schema) {
|
|
|
43
43
|
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
44
44
|
var MAX_PAGE_LIMIT = 1e4;
|
|
45
45
|
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
46
|
-
var ZAPIER_CREDENTIALS = process.env.ZAPIER_CREDENTIALS;
|
|
47
|
-
var ZAPIER_CREDENTIALS_CLIENT_ID = process.env.ZAPIER_CREDENTIALS_CLIENT_ID;
|
|
48
|
-
var ZAPIER_CREDENTIALS_CLIENT_SECRET = process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET;
|
|
49
|
-
var ZAPIER_CREDENTIALS_BASE_URL = process.env.ZAPIER_CREDENTIALS_BASE_URL;
|
|
50
|
-
var ZAPIER_CREDENTIALS_SCOPE = process.env.ZAPIER_CREDENTIALS_SCOPE;
|
|
51
46
|
function parseIntEnvVar(name) {
|
|
52
47
|
const value = process.env[name];
|
|
53
48
|
if (value === void 0) return void 0;
|
|
@@ -62,9 +57,6 @@ function parseIntEnvVar(name) {
|
|
|
62
57
|
}
|
|
63
58
|
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
64
59
|
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
65
|
-
var ZAPIER_TOKEN = process.env.ZAPIER_TOKEN;
|
|
66
|
-
var ZAPIER_AUTH_BASE_URL = process.env.ZAPIER_AUTH_BASE_URL;
|
|
67
|
-
var ZAPIER_AUTH_CLIENT_ID = process.env.ZAPIER_AUTH_CLIENT_ID;
|
|
68
60
|
|
|
69
61
|
// src/types/properties.ts
|
|
70
62
|
var AppKeyPropertySchema = withPositional(
|
|
@@ -4051,9 +4043,9 @@ function deriveAuthBaseUrl(sdkBaseUrl) {
|
|
|
4051
4043
|
}
|
|
4052
4044
|
function normalizeCredentialsObject(obj, sdkBaseUrl) {
|
|
4053
4045
|
const merged = {
|
|
4054
|
-
clientSecret: ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4055
|
-
baseUrl: ZAPIER_CREDENTIALS_BASE_URL,
|
|
4056
|
-
scope: ZAPIER_CREDENTIALS_SCOPE,
|
|
4046
|
+
clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4047
|
+
baseUrl: process.env.ZAPIER_CREDENTIALS_BASE_URL,
|
|
4048
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE,
|
|
4057
4049
|
...obj
|
|
4058
4050
|
};
|
|
4059
4051
|
const resolvedBaseUrl = merged.baseUrl || deriveAuthBaseUrl(sdkBaseUrl);
|
|
@@ -4074,47 +4066,47 @@ function normalizeCredentialsObject(obj, sdkBaseUrl) {
|
|
|
4074
4066
|
};
|
|
4075
4067
|
}
|
|
4076
4068
|
function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
4077
|
-
if (ZAPIER_CREDENTIALS) {
|
|
4078
|
-
return ZAPIER_CREDENTIALS;
|
|
4069
|
+
if (process.env.ZAPIER_CREDENTIALS) {
|
|
4070
|
+
return process.env.ZAPIER_CREDENTIALS;
|
|
4079
4071
|
}
|
|
4080
|
-
if (ZAPIER_CREDENTIALS_CLIENT_ID) {
|
|
4081
|
-
const resolvedBaseUrl = ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4082
|
-
if (ZAPIER_CREDENTIALS_CLIENT_SECRET) {
|
|
4072
|
+
if (process.env.ZAPIER_CREDENTIALS_CLIENT_ID) {
|
|
4073
|
+
const resolvedBaseUrl = process.env.ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4074
|
+
if (process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET) {
|
|
4083
4075
|
return {
|
|
4084
4076
|
type: "client_credentials",
|
|
4085
|
-
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4086
|
-
clientSecret: ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4077
|
+
clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4078
|
+
clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
4087
4079
|
baseUrl: resolvedBaseUrl,
|
|
4088
|
-
scope: ZAPIER_CREDENTIALS_SCOPE
|
|
4080
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE
|
|
4089
4081
|
};
|
|
4090
4082
|
} else {
|
|
4091
4083
|
return {
|
|
4092
4084
|
type: "pkce",
|
|
4093
|
-
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4085
|
+
clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
4094
4086
|
baseUrl: resolvedBaseUrl,
|
|
4095
|
-
scope: ZAPIER_CREDENTIALS_SCOPE
|
|
4087
|
+
scope: process.env.ZAPIER_CREDENTIALS_SCOPE
|
|
4096
4088
|
};
|
|
4097
4089
|
}
|
|
4098
4090
|
}
|
|
4099
|
-
if (ZAPIER_TOKEN) {
|
|
4091
|
+
if (process.env.ZAPIER_TOKEN) {
|
|
4100
4092
|
logDeprecation(
|
|
4101
4093
|
"ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
|
|
4102
4094
|
);
|
|
4103
|
-
return ZAPIER_TOKEN;
|
|
4095
|
+
return process.env.ZAPIER_TOKEN;
|
|
4104
4096
|
}
|
|
4105
|
-
if (ZAPIER_AUTH_CLIENT_ID) {
|
|
4097
|
+
if (process.env.ZAPIER_AUTH_CLIENT_ID) {
|
|
4106
4098
|
logDeprecation(
|
|
4107
4099
|
"ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
|
|
4108
4100
|
);
|
|
4109
|
-
if (ZAPIER_AUTH_BASE_URL) {
|
|
4101
|
+
if (process.env.ZAPIER_AUTH_BASE_URL) {
|
|
4110
4102
|
logDeprecation(
|
|
4111
4103
|
"ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
|
|
4112
4104
|
);
|
|
4113
4105
|
}
|
|
4114
|
-
const resolvedBaseUrl = ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4106
|
+
const resolvedBaseUrl = process.env.ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
4115
4107
|
return {
|
|
4116
4108
|
type: "pkce",
|
|
4117
|
-
clientId: ZAPIER_AUTH_CLIENT_ID,
|
|
4109
|
+
clientId: process.env.ZAPIER_AUTH_CLIENT_ID,
|
|
4118
4110
|
baseUrl: resolvedBaseUrl
|
|
4119
4111
|
};
|
|
4120
4112
|
}
|
|
@@ -4313,7 +4305,8 @@ async function getTokenFromCliLogin(options) {
|
|
|
4313
4305
|
async function resolveAuthToken(options = {}) {
|
|
4314
4306
|
const credentials = await resolveCredentials({
|
|
4315
4307
|
credentials: options.credentials,
|
|
4316
|
-
token: options.token
|
|
4308
|
+
token: options.token,
|
|
4309
|
+
baseUrl: options.baseUrl
|
|
4317
4310
|
});
|
|
4318
4311
|
if (credentials !== void 0) {
|
|
4319
4312
|
return resolveAuthTokenFromCredentials(credentials, options);
|
|
@@ -5496,11 +5489,8 @@ function getCpuTime() {
|
|
|
5496
5489
|
return null;
|
|
5497
5490
|
}
|
|
5498
5491
|
|
|
5499
|
-
// package.json
|
|
5500
|
-
var package_default = {
|
|
5501
|
-
version: "0.32.4"};
|
|
5502
|
-
|
|
5503
5492
|
// src/plugins/eventEmission/builders.ts
|
|
5493
|
+
var SDK_VERSION = "0.33.0";
|
|
5504
5494
|
function createBaseEvent(context = {}) {
|
|
5505
5495
|
return {
|
|
5506
5496
|
event_id: generateEventId(),
|
|
@@ -5522,8 +5512,8 @@ function buildErrorEvent(data, context = {}) {
|
|
|
5522
5512
|
app_id: context.app_id,
|
|
5523
5513
|
app_version_id: context.app_version_id,
|
|
5524
5514
|
environment: context.environment,
|
|
5525
|
-
|
|
5526
|
-
|
|
5515
|
+
...data,
|
|
5516
|
+
sdk_version: SDK_VERSION
|
|
5527
5517
|
};
|
|
5528
5518
|
}
|
|
5529
5519
|
function buildApplicationLifecycleEvent(data, context = {}) {
|
|
@@ -5534,7 +5524,6 @@ function buildApplicationLifecycleEvent(data, context = {}) {
|
|
|
5534
5524
|
selected_api: context.selected_api,
|
|
5535
5525
|
app_id: context.app_id,
|
|
5536
5526
|
app_version_id: context.app_version_id,
|
|
5537
|
-
sdk_version: package_default.version,
|
|
5538
5527
|
cli_version: null,
|
|
5539
5528
|
memory_usage_bytes: data.memory_usage_bytes ?? getMemoryUsage(),
|
|
5540
5529
|
cpu_time_ms: data.cpu_time_ms ?? getCpuTime(),
|
|
@@ -5548,7 +5537,8 @@ function buildApplicationLifecycleEvent(data, context = {}) {
|
|
|
5548
5537
|
session_id: null,
|
|
5549
5538
|
metadata: null,
|
|
5550
5539
|
process_argv: process.argv || null,
|
|
5551
|
-
...data
|
|
5540
|
+
...data,
|
|
5541
|
+
sdk_version: SDK_VERSION
|
|
5552
5542
|
};
|
|
5553
5543
|
}
|
|
5554
5544
|
function buildErrorEventWithContext(data, context = {}) {
|
|
@@ -5561,9 +5551,9 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
5561
5551
|
app_id: context.app_id,
|
|
5562
5552
|
app_version_id: context.app_version_id,
|
|
5563
5553
|
environment: context.environment ?? (process.env.NODE_ENV || null),
|
|
5564
|
-
sdk_version: package_default.version,
|
|
5565
5554
|
execution_time_before_error_ms: executionTime,
|
|
5566
|
-
...data
|
|
5555
|
+
...data,
|
|
5556
|
+
sdk_version: SDK_VERSION
|
|
5567
5557
|
};
|
|
5568
5558
|
}
|
|
5569
5559
|
function buildMethodCalledEvent(data, context = {}) {
|
|
@@ -5577,7 +5567,6 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
5577
5567
|
error_type: data.error_type ?? null,
|
|
5578
5568
|
argument_count: data.argument_count,
|
|
5579
5569
|
is_paginated: data.is_paginated ?? false,
|
|
5580
|
-
sdk_version: package_default.version,
|
|
5581
5570
|
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
5582
5571
|
selected_api: data.selected_api ?? context.selected_api ?? null,
|
|
5583
5572
|
app_id: context.app_id ?? null,
|
|
@@ -5595,7 +5584,8 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
5595
5584
|
call_stack_depth: null,
|
|
5596
5585
|
is_synchronous: false,
|
|
5597
5586
|
cpu_time_ms: null,
|
|
5598
|
-
memory_usage_bytes: null
|
|
5587
|
+
memory_usage_bytes: null,
|
|
5588
|
+
sdk_version: SDK_VERSION
|
|
5599
5589
|
};
|
|
5600
5590
|
}
|
|
5601
5591
|
|
|
@@ -6018,4 +6008,4 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
6018
6008
|
// Use credentials instead
|
|
6019
6009
|
});
|
|
6020
6010
|
|
|
6021
|
-
export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, ClientCredentialsObjectSchema, ConnectionIdPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema,
|
|
6011
|
+
export { ActionKeyPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, ClientCredentialsObjectSchema, ConnectionIdPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
|
|
@@ -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
|
+
const SDK_VERSION = process.env.SDK_VERSION || "unknown";
|
|
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 = {}) {
|
|
@@ -29,8 +29,8 @@ export function buildErrorEvent(data, context = {}) {
|
|
|
29
29
|
app_id: context.app_id,
|
|
30
30
|
app_version_id: context.app_version_id,
|
|
31
31
|
environment: context.environment,
|
|
32
|
-
sdk_version: sdkPackageJson.version,
|
|
33
32
|
...data,
|
|
33
|
+
sdk_version: SDK_VERSION,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
export function buildApplicationLifecycleEvent(data, context = {}) {
|
|
@@ -41,7 +41,6 @@ export function buildApplicationLifecycleEvent(data, context = {}) {
|
|
|
41
41
|
selected_api: context.selected_api,
|
|
42
42
|
app_id: context.app_id,
|
|
43
43
|
app_version_id: context.app_version_id,
|
|
44
|
-
sdk_version: sdkPackageJson.version,
|
|
45
44
|
cli_version: null,
|
|
46
45
|
memory_usage_bytes: data.memory_usage_bytes ?? getMemoryUsage(),
|
|
47
46
|
cpu_time_ms: data.cpu_time_ms ?? getCpuTime(),
|
|
@@ -56,6 +55,7 @@ export function buildApplicationLifecycleEvent(data, context = {}) {
|
|
|
56
55
|
metadata: null,
|
|
57
56
|
process_argv: process.argv || null,
|
|
58
57
|
...data,
|
|
58
|
+
sdk_version: SDK_VERSION,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
export function buildErrorEventWithContext(data, context = {}) {
|
|
@@ -70,9 +70,9 @@ export function buildErrorEventWithContext(data, context = {}) {
|
|
|
70
70
|
app_id: context.app_id,
|
|
71
71
|
app_version_id: context.app_version_id,
|
|
72
72
|
environment: context.environment ?? (process.env.NODE_ENV || null),
|
|
73
|
-
sdk_version: sdkPackageJson.version,
|
|
74
73
|
execution_time_before_error_ms: executionTime,
|
|
75
74
|
...data,
|
|
75
|
+
sdk_version: SDK_VERSION,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
export function buildMethodCalledEvent(data, context = {}) {
|
|
@@ -86,7 +86,6 @@ export function buildMethodCalledEvent(data, context = {}) {
|
|
|
86
86
|
error_type: data.error_type ?? null,
|
|
87
87
|
argument_count: data.argument_count,
|
|
88
88
|
is_paginated: data.is_paginated ?? false,
|
|
89
|
-
sdk_version: sdkPackageJson.version,
|
|
90
89
|
environment: context.environment ?? (process?.env?.NODE_ENV || null),
|
|
91
90
|
selected_api: data.selected_api ?? context.selected_api ?? null,
|
|
92
91
|
app_id: context.app_id ?? null,
|
|
@@ -105,5 +104,6 @@ export function buildMethodCalledEvent(data, context = {}) {
|
|
|
105
104
|
is_synchronous: false,
|
|
106
105
|
cpu_time_ms: null,
|
|
107
106
|
memory_usage_bytes: null,
|
|
107
|
+
sdk_version: SDK_VERSION,
|
|
108
108
|
};
|
|
109
109
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { buildMethodCalledEvent } from "./builders";
|
|
2
|
+
import { buildMethodCalledEvent, buildErrorEvent, buildApplicationLifecycleEvent, buildErrorEventWithContext, } from "./builders";
|
|
3
3
|
describe("buildMethodCalledEvent", () => {
|
|
4
4
|
it("should use data.selected_api when provided", () => {
|
|
5
5
|
const event = buildMethodCalledEvent({
|
|
@@ -62,4 +62,77 @@ describe("buildMethodCalledEvent", () => {
|
|
|
62
62
|
});
|
|
63
63
|
expect(event.call_context).toBeNull();
|
|
64
64
|
});
|
|
65
|
+
it("should populate sdk_version", () => {
|
|
66
|
+
const event = buildMethodCalledEvent({
|
|
67
|
+
method_name: "listApps",
|
|
68
|
+
execution_duration_ms: 50,
|
|
69
|
+
success_flag: true,
|
|
70
|
+
argument_count: 0,
|
|
71
|
+
});
|
|
72
|
+
expect(event.sdk_version).toBe("unknown");
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe("buildErrorEvent", () => {
|
|
76
|
+
it("should build an error event with correct fields", () => {
|
|
77
|
+
const event = buildErrorEvent({
|
|
78
|
+
error_message: "Something went wrong",
|
|
79
|
+
error_type: "RuntimeError",
|
|
80
|
+
is_user_facing: false,
|
|
81
|
+
}, { selected_api: "SlackCLIAPI@1.0.0" });
|
|
82
|
+
expect(event.error_message).toBe("Something went wrong");
|
|
83
|
+
expect(event.error_type).toBe("RuntimeError");
|
|
84
|
+
expect(event.selected_api).toBe("SlackCLIAPI@1.0.0");
|
|
85
|
+
expect(event.sdk_version).toBe("unknown");
|
|
86
|
+
});
|
|
87
|
+
it("should not allow sdk_version to be overwritten via data spread", () => {
|
|
88
|
+
const event = buildErrorEvent({
|
|
89
|
+
error_message: "test",
|
|
90
|
+
error_type: "Error",
|
|
91
|
+
is_user_facing: false,
|
|
92
|
+
sdk_version: "evil-version",
|
|
93
|
+
}, {});
|
|
94
|
+
expect(event.sdk_version).not.toBe("evil-version");
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe("buildApplicationLifecycleEvent", () => {
|
|
98
|
+
it("should build a lifecycle event with correct fields", () => {
|
|
99
|
+
const event = buildApplicationLifecycleEvent({
|
|
100
|
+
lifecycle_event_type: "startup",
|
|
101
|
+
}, { app_id: 123 });
|
|
102
|
+
expect(event.lifecycle_event_type).toBe("startup");
|
|
103
|
+
expect(event.app_id).toBe(123);
|
|
104
|
+
expect(event.sdk_version).toBe("unknown");
|
|
105
|
+
});
|
|
106
|
+
it("should not allow sdk_version to be overwritten via data spread", () => {
|
|
107
|
+
const event = buildApplicationLifecycleEvent({
|
|
108
|
+
lifecycle_event_type: "startup",
|
|
109
|
+
sdk_version: "evil-version",
|
|
110
|
+
}, {});
|
|
111
|
+
expect(event.sdk_version).not.toBe("evil-version");
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
describe("buildErrorEventWithContext", () => {
|
|
115
|
+
it("should build an error event with execution time", () => {
|
|
116
|
+
const startTime = Date.now() - 500;
|
|
117
|
+
const event = buildErrorEventWithContext({
|
|
118
|
+
error_message: "Timeout",
|
|
119
|
+
error_type: "TimeoutError",
|
|
120
|
+
is_user_facing: false,
|
|
121
|
+
execution_start_time: startTime,
|
|
122
|
+
}, { selected_api: "SlackCLIAPI@1.0.0" });
|
|
123
|
+
expect(event.error_message).toBe("Timeout");
|
|
124
|
+
expect(event.error_type).toBe("TimeoutError");
|
|
125
|
+
expect(event.selected_api).toBe("SlackCLIAPI@1.0.0");
|
|
126
|
+
expect(event.sdk_version).toBe("unknown");
|
|
127
|
+
expect(event.execution_time_before_error_ms).toBeGreaterThanOrEqual(400);
|
|
128
|
+
});
|
|
129
|
+
it("should not allow sdk_version to be overwritten via data spread", () => {
|
|
130
|
+
const event = buildErrorEventWithContext({
|
|
131
|
+
error_message: "test",
|
|
132
|
+
error_type: "Error",
|
|
133
|
+
is_user_facing: false,
|
|
134
|
+
sdk_version: "evil-version",
|
|
135
|
+
}, {});
|
|
136
|
+
expect(event.sdk_version).not.toBe("evil-version");
|
|
137
|
+
});
|
|
65
138
|
});
|
|
@@ -29,6 +29,14 @@ describe("eventEmissionPlugin", () => {
|
|
|
29
29
|
clearTokenCache();
|
|
30
30
|
// Reset to default behavior - no token available
|
|
31
31
|
mockGetToken.mockResolvedValue(undefined);
|
|
32
|
+
delete process.env.ZAPIER_CREDENTIALS;
|
|
33
|
+
delete process.env.ZAPIER_CREDENTIALS_CLIENT_ID;
|
|
34
|
+
delete process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET;
|
|
35
|
+
delete process.env.ZAPIER_CREDENTIALS_BASE_URL;
|
|
36
|
+
delete process.env.ZAPIER_CREDENTIALS_SCOPE;
|
|
37
|
+
delete process.env.ZAPIER_TOKEN;
|
|
38
|
+
delete process.env.ZAPIER_AUTH_CLIENT_ID;
|
|
39
|
+
delete process.env.ZAPIER_AUTH_BASE_URL;
|
|
32
40
|
});
|
|
33
41
|
it("should create plugin with default configuration", () => {
|
|
34
42
|
const plugin = eventEmissionPlugin({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;I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AAI,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
10
11
|
"require": {
|
|
11
12
|
"types": "./dist/index.d.ts",
|
|
12
13
|
"default": "./dist/index.cjs"
|