@zapier/zapier-sdk 0.14.0 → 0.15.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 +6 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +45 -22
- package/dist/index.cjs +99 -85
- package/dist/index.mjs +99 -85
- package/dist/plugins/getAuthentication/index.js +1 -1
- package/dist/plugins/getAuthentication/index.test.js +1 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +1 -1
- package/dist/plugins/listActions/index.js +1 -1
- package/dist/plugins/listActions/index.test.js +1 -1
- package/dist/plugins/listApps/index.js +2 -2
- package/dist/plugins/listApps/index.test.js +1 -1
- package/dist/plugins/listAuthentications/index.js +1 -1
- package/dist/plugins/listAuthentications/index.test.js +13 -13
- package/dist/plugins/listInputFieldChoices/index.test.js +19 -19
- package/dist/plugins/listInputFields/index.test.js +4 -4
- package/dist/plugins/manifest/index.js +2 -2
- package/dist/plugins/manifest/index.test.js +3 -3
- package/dist/plugins/runAction/index.js +2 -2
- package/dist/plugins/runAction/index.test.js +4 -4
- package/dist/sdk.test.js +1 -1
- package/dist/services/implementations.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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;AAwejB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
|
package/dist/api/client.js
CHANGED
|
@@ -8,11 +8,18 @@ import { getAuthorizationHeader } from "./auth";
|
|
|
8
8
|
import { createDebugLogger, createDebugFetch } from "./debug";
|
|
9
9
|
import { pollUntilComplete } from "./polling";
|
|
10
10
|
import { getTokenFromEnvOrConfig } from "../auth";
|
|
11
|
+
import { getZapierBaseUrl } from "../utils/url-utils";
|
|
11
12
|
import { ZapierApiError, ZapierAuthenticationError, ZapierValidationError, ZapierNotFoundError, } from "../types/errors";
|
|
12
|
-
const
|
|
13
|
-
// e.g. https://
|
|
14
|
-
relay: {
|
|
13
|
+
const pathConfig = {
|
|
14
|
+
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
15
|
+
"/relay": {
|
|
15
16
|
authHeader: "X-Relay-Authorization",
|
|
17
|
+
pathPrefix: "/api/v0/sdk/relay",
|
|
18
|
+
},
|
|
19
|
+
// e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
|
|
20
|
+
"/zapier": {
|
|
21
|
+
authHeader: "Authorization",
|
|
22
|
+
pathPrefix: "/api/v0/sdk/zapier",
|
|
16
23
|
},
|
|
17
24
|
};
|
|
18
25
|
class ZapierApiClient {
|
|
@@ -223,37 +230,53 @@ class ZapierApiClient {
|
|
|
223
230
|
return { message: fallbackMessage };
|
|
224
231
|
}
|
|
225
232
|
}
|
|
226
|
-
//
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
// Apply any special routing logic for configured paths.
|
|
234
|
+
applyPathConfiguration(path) {
|
|
235
|
+
// Find matching path configuration.
|
|
236
|
+
const matchingPathKey = Object.keys(pathConfig).find((configPath) => path === configPath || path.startsWith(configPath + "/"));
|
|
237
|
+
const config = matchingPathKey ? pathConfig[matchingPathKey] : undefined;
|
|
238
|
+
// Check if baseUrl is a Zapier-inferred base URL.
|
|
239
|
+
const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
|
|
240
|
+
// Let's remain compatible with a base URL that is set to a Zapier-inferred
|
|
241
|
+
// domain, rather than requiring the base URL to go to our proxy. Later, the
|
|
242
|
+
// proxy will be removed, so this should make that transition easier.
|
|
243
|
+
if (zapierBaseUrl === this.options.baseUrl) {
|
|
244
|
+
// If baseUrl is already the Zapier base URL, use sdkapi subdomain.
|
|
235
245
|
const originalBaseUrl = new URL(this.options.baseUrl);
|
|
236
|
-
const finalBaseUrl = `https
|
|
237
|
-
|
|
238
|
-
|
|
246
|
+
const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
|
|
247
|
+
// Only prepend pathPrefix if there's a matching config with pathPrefix.
|
|
248
|
+
let finalPath = path;
|
|
249
|
+
if (config &&
|
|
250
|
+
"pathPrefix" in config &&
|
|
251
|
+
config.pathPrefix &&
|
|
252
|
+
matchingPathKey) {
|
|
253
|
+
// Strip the matching path key, and use the pathPrefix instead.
|
|
254
|
+
const pathWithoutPrefix = path.slice(matchingPathKey.length) || "/";
|
|
255
|
+
finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
url: new URL(finalPath, finalBaseUrl),
|
|
259
|
+
pathConfig: config,
|
|
260
|
+
};
|
|
239
261
|
}
|
|
262
|
+
// For a base URL that isn't a Zapier-inferred domain, use the whole base URL.
|
|
240
263
|
return {
|
|
241
264
|
url: new URL(path, this.options.baseUrl),
|
|
242
|
-
|
|
265
|
+
pathConfig: config,
|
|
243
266
|
};
|
|
244
267
|
}
|
|
245
268
|
// Helper to build full URLs and return routing info
|
|
246
269
|
buildUrl(path, searchParams) {
|
|
247
|
-
const { url,
|
|
270
|
+
const { url, pathConfig: config } = this.applyPathConfiguration(path);
|
|
248
271
|
if (searchParams) {
|
|
249
272
|
Object.entries(searchParams).forEach(([key, value]) => {
|
|
250
273
|
url.searchParams.set(key, value);
|
|
251
274
|
});
|
|
252
275
|
}
|
|
253
|
-
return { url: url.toString(),
|
|
276
|
+
return { url: url.toString(), pathConfig: config };
|
|
254
277
|
}
|
|
255
278
|
// Helper to build headers
|
|
256
|
-
async buildHeaders(options = {},
|
|
279
|
+
async buildHeaders(options = {}, pathConfig) {
|
|
257
280
|
const headers = new Headers(options.headers ?? {});
|
|
258
281
|
// Even if auth is not required, we still want to add it in case it adds
|
|
259
282
|
// useful context to the API. The session is a good example of this. Auth
|
|
@@ -261,7 +284,7 @@ class ZapierApiClient {
|
|
|
261
284
|
// session!
|
|
262
285
|
const authToken = await this.getAuthToken();
|
|
263
286
|
if (authToken) {
|
|
264
|
-
const authHeaderName =
|
|
287
|
+
const authHeaderName = pathConfig?.authHeader || "Authorization";
|
|
265
288
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
266
289
|
}
|
|
267
290
|
// If we know auth is required, and we don't have a token, throw an error
|
|
@@ -307,8 +330,8 @@ class ZapierApiClient {
|
|
|
307
330
|
if (fetchOptions?.body && typeof fetchOptions.body === "object") {
|
|
308
331
|
fetchOptions.body = JSON.stringify(fetchOptions.body);
|
|
309
332
|
}
|
|
310
|
-
const { url,
|
|
311
|
-
const builtHeaders = await this.buildHeaders(fetchOptions,
|
|
333
|
+
const { url, pathConfig } = this.buildUrl(path, fetchOptions?.searchParams);
|
|
334
|
+
const builtHeaders = await this.buildHeaders(fetchOptions, pathConfig);
|
|
312
335
|
const inputHeaders = new Headers(fetchOptions?.headers ?? {});
|
|
313
336
|
const mergedHeaders = new Headers();
|
|
314
337
|
builtHeaders.forEach((value, key) => {
|
package/dist/index.cjs
CHANGED
|
@@ -1295,7 +1295,7 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1295
1295
|
const searchParams2 = {};
|
|
1296
1296
|
searchParams2.term = options.search;
|
|
1297
1297
|
const searchEnvelope = await api.get(
|
|
1298
|
-
"/api/v4/implementations-meta/search/",
|
|
1298
|
+
"/zapier/api/v4/implementations-meta/search/",
|
|
1299
1299
|
{
|
|
1300
1300
|
searchParams: searchParams2
|
|
1301
1301
|
}
|
|
@@ -1335,7 +1335,7 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1335
1335
|
};
|
|
1336
1336
|
}
|
|
1337
1337
|
const implementationsEnvelope = await api.get(
|
|
1338
|
-
"/api/v4/implementations-meta/lookup/",
|
|
1338
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
1339
1339
|
{
|
|
1340
1340
|
searchParams
|
|
1341
1341
|
}
|
|
@@ -1621,7 +1621,7 @@ var listActionsPlugin = ({ context }) => {
|
|
|
1621
1621
|
selected_apis: selectedApi
|
|
1622
1622
|
};
|
|
1623
1623
|
const data = await api.get(
|
|
1624
|
-
"/api/v4/implementations/",
|
|
1624
|
+
"/zapier/api/v4/implementations/",
|
|
1625
1625
|
{
|
|
1626
1626
|
searchParams,
|
|
1627
1627
|
customErrorHandler: ({ status }) => {
|
|
@@ -1831,7 +1831,7 @@ async function fetchImplementationNeeds({
|
|
|
1831
1831
|
request.authentication_id = authenticationId;
|
|
1832
1832
|
}
|
|
1833
1833
|
const response = await api.post(
|
|
1834
|
-
"/api/v4/implementations/needs/",
|
|
1834
|
+
"/zapier/api/v4/implementations/needs/",
|
|
1835
1835
|
request
|
|
1836
1836
|
);
|
|
1837
1837
|
if (!response.success) {
|
|
@@ -1859,7 +1859,7 @@ async function fetchImplementationChoices({
|
|
|
1859
1859
|
request.authentication_id = authenticationId;
|
|
1860
1860
|
}
|
|
1861
1861
|
const response = await api.post(
|
|
1862
|
-
"/api/v4/implementations/choices/",
|
|
1862
|
+
"/zapier/api/v4/implementations/choices/",
|
|
1863
1863
|
request
|
|
1864
1864
|
);
|
|
1865
1865
|
if (!response.success) {
|
|
@@ -2124,7 +2124,7 @@ var listAuthenticationsPlugin = ({ context }) => {
|
|
|
2124
2124
|
searchParams.offset = options.cursor;
|
|
2125
2125
|
}
|
|
2126
2126
|
const data = await api.get(
|
|
2127
|
-
"/api/v4/authentications/",
|
|
2127
|
+
"/zapier/api/v4/authentications/",
|
|
2128
2128
|
{
|
|
2129
2129
|
searchParams,
|
|
2130
2130
|
customErrorHandler: ({ status }) => {
|
|
@@ -2264,7 +2264,7 @@ var getAuthenticationPlugin = ({ context }) => {
|
|
|
2264
2264
|
const { api } = context;
|
|
2265
2265
|
const { authenticationId } = options;
|
|
2266
2266
|
const data = await api.get(
|
|
2267
|
-
`/api/v4/authentications/${authenticationId}/`,
|
|
2267
|
+
`/zapier/api/v4/authentications/${authenticationId}/`,
|
|
2268
2268
|
{
|
|
2269
2269
|
customErrorHandler: ({ status }) => {
|
|
2270
2270
|
if (status === 401) {
|
|
@@ -2457,11 +2457,11 @@ async function executeAction(actionOptions) {
|
|
|
2457
2457
|
data: runRequestData
|
|
2458
2458
|
};
|
|
2459
2459
|
const runData = await api.post(
|
|
2460
|
-
"/api/actions/v1/runs",
|
|
2460
|
+
"/zapier/api/actions/v1/runs",
|
|
2461
2461
|
runRequest
|
|
2462
2462
|
);
|
|
2463
2463
|
const runId = runData.data.id;
|
|
2464
|
-
return await api.poll(`/api/actions/v1/runs/${runId}`, {
|
|
2464
|
+
return await api.poll(`/zapier/api/actions/v1/runs/${runId}`, {
|
|
2465
2465
|
successStatus: 200,
|
|
2466
2466
|
pendingStatus: 202,
|
|
2467
2467
|
resultExtractor: (result) => result.data
|
|
@@ -2742,7 +2742,7 @@ async function getPreferredManifestEntryKey({
|
|
|
2742
2742
|
}
|
|
2743
2743
|
if (locator.implementationName) {
|
|
2744
2744
|
try {
|
|
2745
|
-
const implementationsEnvelope = await api.get(`/api/v4/implementations-meta/lookup/`, {
|
|
2745
|
+
const implementationsEnvelope = await api.get(`/zapier/api/v4/implementations-meta/lookup/`, {
|
|
2746
2746
|
searchParams: {
|
|
2747
2747
|
selected_apis: locator.implementationName
|
|
2748
2748
|
}
|
|
@@ -2769,7 +2769,7 @@ async function listAppsForSlugsPage({
|
|
|
2769
2769
|
searchParams.offset = cursor;
|
|
2770
2770
|
}
|
|
2771
2771
|
const implementationsEnvelope = await api.get(
|
|
2772
|
-
"/api/v4/implementations-meta/lookup/",
|
|
2772
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
2773
2773
|
{
|
|
2774
2774
|
searchParams
|
|
2775
2775
|
}
|
|
@@ -3008,9 +3008,12 @@ var UserProfileItemSchema = withFormatter(
|
|
|
3008
3008
|
// src/plugins/getProfile/index.ts
|
|
3009
3009
|
var getProfilePlugin = ({ context }) => {
|
|
3010
3010
|
const getProfile = createFunction(async function getProfile2() {
|
|
3011
|
-
const profile = await context.api.get(
|
|
3012
|
-
|
|
3013
|
-
|
|
3011
|
+
const profile = await context.api.get(
|
|
3012
|
+
"/zapier/api/v4/profile/",
|
|
3013
|
+
{
|
|
3014
|
+
authRequired: true
|
|
3015
|
+
}
|
|
3016
|
+
);
|
|
3014
3017
|
const { user_id: _unusedUserId, ...data } = profile;
|
|
3015
3018
|
return {
|
|
3016
3019
|
data: {
|
|
@@ -3337,11 +3340,63 @@ async function getTokenFromEnvOrConfig(options = {}) {
|
|
|
3337
3340
|
return getTokenFromCliLogin(options);
|
|
3338
3341
|
}
|
|
3339
3342
|
|
|
3343
|
+
// src/utils/url-utils.ts
|
|
3344
|
+
function getZapierBaseUrl(baseUrl) {
|
|
3345
|
+
if (!baseUrl) {
|
|
3346
|
+
return void 0;
|
|
3347
|
+
}
|
|
3348
|
+
try {
|
|
3349
|
+
const url = new URL(baseUrl);
|
|
3350
|
+
const hostname = url.hostname;
|
|
3351
|
+
const hostParts = hostname.split(".");
|
|
3352
|
+
if (hostParts.length < 2) {
|
|
3353
|
+
return void 0;
|
|
3354
|
+
}
|
|
3355
|
+
const hasZapierPart = hostParts.some(
|
|
3356
|
+
(part) => part === "zapier" || part.startsWith("zapier-")
|
|
3357
|
+
);
|
|
3358
|
+
if (!hasZapierPart) {
|
|
3359
|
+
return void 0;
|
|
3360
|
+
}
|
|
3361
|
+
const rootDomain = hostParts.slice(-2).join(".");
|
|
3362
|
+
return `${url.protocol}//${rootDomain}`;
|
|
3363
|
+
} catch {
|
|
3364
|
+
return void 0;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
function getTrackingBaseUrl({
|
|
3368
|
+
trackingBaseUrl,
|
|
3369
|
+
baseUrl
|
|
3370
|
+
}) {
|
|
3371
|
+
if (trackingBaseUrl) {
|
|
3372
|
+
return trackingBaseUrl;
|
|
3373
|
+
}
|
|
3374
|
+
if (process.env.ZAPIER_TRACKING_BASE_URL) {
|
|
3375
|
+
return process.env.ZAPIER_TRACKING_BASE_URL;
|
|
3376
|
+
}
|
|
3377
|
+
if (baseUrl) {
|
|
3378
|
+
const zapierBaseUrl = getZapierBaseUrl(baseUrl);
|
|
3379
|
+
if (zapierBaseUrl) {
|
|
3380
|
+
return zapierBaseUrl;
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
if (baseUrl) {
|
|
3384
|
+
return baseUrl;
|
|
3385
|
+
}
|
|
3386
|
+
return ZAPIER_BASE_URL;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3340
3389
|
// src/api/client.ts
|
|
3341
|
-
var
|
|
3342
|
-
// e.g. https://
|
|
3343
|
-
relay: {
|
|
3344
|
-
authHeader: "X-Relay-Authorization"
|
|
3390
|
+
var pathConfig = {
|
|
3391
|
+
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
3392
|
+
"/relay": {
|
|
3393
|
+
authHeader: "X-Relay-Authorization",
|
|
3394
|
+
pathPrefix: "/api/v0/sdk/relay"
|
|
3395
|
+
},
|
|
3396
|
+
// e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
|
|
3397
|
+
"/zapier": {
|
|
3398
|
+
authHeader: "Authorization",
|
|
3399
|
+
pathPrefix: "/api/v0/sdk/zapier"
|
|
3345
3400
|
}
|
|
3346
3401
|
};
|
|
3347
3402
|
var ZapierApiClient = class {
|
|
@@ -3530,39 +3585,47 @@ var ZapierApiClient = class {
|
|
|
3530
3585
|
return { message: fallbackMessage };
|
|
3531
3586
|
}
|
|
3532
3587
|
}
|
|
3533
|
-
//
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3588
|
+
// Apply any special routing logic for configured paths.
|
|
3589
|
+
applyPathConfiguration(path) {
|
|
3590
|
+
const matchingPathKey = Object.keys(pathConfig).find(
|
|
3591
|
+
(configPath) => path === configPath || path.startsWith(configPath + "/")
|
|
3592
|
+
);
|
|
3593
|
+
const config = matchingPathKey ? pathConfig[matchingPathKey] : void 0;
|
|
3594
|
+
const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
|
|
3595
|
+
if (zapierBaseUrl === this.options.baseUrl) {
|
|
3540
3596
|
const originalBaseUrl = new URL(this.options.baseUrl);
|
|
3541
|
-
const finalBaseUrl = `https
|
|
3542
|
-
|
|
3543
|
-
|
|
3597
|
+
const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
|
|
3598
|
+
let finalPath = path;
|
|
3599
|
+
if (config && "pathPrefix" in config && config.pathPrefix && matchingPathKey) {
|
|
3600
|
+
const pathWithoutPrefix = path.slice(matchingPathKey.length) || "/";
|
|
3601
|
+
finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
|
|
3602
|
+
}
|
|
3603
|
+
return {
|
|
3604
|
+
url: new URL(finalPath, finalBaseUrl),
|
|
3605
|
+
pathConfig: config
|
|
3606
|
+
};
|
|
3544
3607
|
}
|
|
3545
3608
|
return {
|
|
3546
3609
|
url: new URL(path, this.options.baseUrl),
|
|
3547
|
-
|
|
3610
|
+
pathConfig: config
|
|
3548
3611
|
};
|
|
3549
3612
|
}
|
|
3550
3613
|
// Helper to build full URLs and return routing info
|
|
3551
3614
|
buildUrl(path, searchParams) {
|
|
3552
|
-
const { url,
|
|
3615
|
+
const { url, pathConfig: config } = this.applyPathConfiguration(path);
|
|
3553
3616
|
if (searchParams) {
|
|
3554
3617
|
Object.entries(searchParams).forEach(([key, value]) => {
|
|
3555
3618
|
url.searchParams.set(key, value);
|
|
3556
3619
|
});
|
|
3557
3620
|
}
|
|
3558
|
-
return { url: url.toString(),
|
|
3621
|
+
return { url: url.toString(), pathConfig: config };
|
|
3559
3622
|
}
|
|
3560
3623
|
// Helper to build headers
|
|
3561
|
-
async buildHeaders(options = {},
|
|
3624
|
+
async buildHeaders(options = {}, pathConfig2) {
|
|
3562
3625
|
const headers = new Headers(options.headers ?? {});
|
|
3563
3626
|
const authToken = await this.getAuthToken();
|
|
3564
3627
|
if (authToken) {
|
|
3565
|
-
const authHeaderName =
|
|
3628
|
+
const authHeaderName = pathConfig2?.authHeader || "Authorization";
|
|
3566
3629
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
3567
3630
|
}
|
|
3568
3631
|
if (options.authRequired) {
|
|
@@ -3609,13 +3672,10 @@ var ZapierApiClient = class {
|
|
|
3609
3672
|
if (fetchOptions?.body && typeof fetchOptions.body === "object") {
|
|
3610
3673
|
fetchOptions.body = JSON.stringify(fetchOptions.body);
|
|
3611
3674
|
}
|
|
3612
|
-
const { url,
|
|
3613
|
-
path,
|
|
3614
|
-
fetchOptions?.searchParams
|
|
3615
|
-
);
|
|
3675
|
+
const { url, pathConfig: pathConfig2 } = this.buildUrl(path, fetchOptions?.searchParams);
|
|
3616
3676
|
const builtHeaders = await this.buildHeaders(
|
|
3617
3677
|
fetchOptions,
|
|
3618
|
-
|
|
3678
|
+
pathConfig2
|
|
3619
3679
|
);
|
|
3620
3680
|
const inputHeaders = new Headers(fetchOptions?.headers ?? {});
|
|
3621
3681
|
const mergedHeaders = new Headers();
|
|
@@ -4162,7 +4222,7 @@ function getCpuTime() {
|
|
|
4162
4222
|
|
|
4163
4223
|
// package.json
|
|
4164
4224
|
var package_default = {
|
|
4165
|
-
version: "0.
|
|
4225
|
+
version: "0.15.0"};
|
|
4166
4226
|
|
|
4167
4227
|
// src/plugins/eventEmission/builders.ts
|
|
4168
4228
|
function createBaseEvent(context = {}) {
|
|
@@ -4232,52 +4292,6 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
4232
4292
|
};
|
|
4233
4293
|
}
|
|
4234
4294
|
|
|
4235
|
-
// src/utils/url-utils.ts
|
|
4236
|
-
function getZapierBaseUrl(baseUrl) {
|
|
4237
|
-
if (!baseUrl) {
|
|
4238
|
-
return void 0;
|
|
4239
|
-
}
|
|
4240
|
-
try {
|
|
4241
|
-
const url = new URL(baseUrl);
|
|
4242
|
-
const hostname = url.hostname;
|
|
4243
|
-
const hostParts = hostname.split(".");
|
|
4244
|
-
if (hostParts.length < 2) {
|
|
4245
|
-
return void 0;
|
|
4246
|
-
}
|
|
4247
|
-
const hasZapierPart = hostParts.some(
|
|
4248
|
-
(part) => part === "zapier" || part.startsWith("zapier-")
|
|
4249
|
-
);
|
|
4250
|
-
if (!hasZapierPart) {
|
|
4251
|
-
return void 0;
|
|
4252
|
-
}
|
|
4253
|
-
const rootDomain = hostParts.slice(-2).join(".");
|
|
4254
|
-
return `${url.protocol}//${rootDomain}`;
|
|
4255
|
-
} catch {
|
|
4256
|
-
return void 0;
|
|
4257
|
-
}
|
|
4258
|
-
}
|
|
4259
|
-
function getTrackingBaseUrl({
|
|
4260
|
-
trackingBaseUrl,
|
|
4261
|
-
baseUrl
|
|
4262
|
-
}) {
|
|
4263
|
-
if (trackingBaseUrl) {
|
|
4264
|
-
return trackingBaseUrl;
|
|
4265
|
-
}
|
|
4266
|
-
if (process.env.ZAPIER_TRACKING_BASE_URL) {
|
|
4267
|
-
return process.env.ZAPIER_TRACKING_BASE_URL;
|
|
4268
|
-
}
|
|
4269
|
-
if (baseUrl) {
|
|
4270
|
-
const zapierBaseUrl = getZapierBaseUrl(baseUrl);
|
|
4271
|
-
if (zapierBaseUrl) {
|
|
4272
|
-
return zapierBaseUrl;
|
|
4273
|
-
}
|
|
4274
|
-
}
|
|
4275
|
-
if (baseUrl) {
|
|
4276
|
-
return baseUrl;
|
|
4277
|
-
}
|
|
4278
|
-
return ZAPIER_BASE_URL;
|
|
4279
|
-
}
|
|
4280
|
-
|
|
4281
4295
|
// src/plugins/eventEmission/index.ts
|
|
4282
4296
|
var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
|
|
4283
4297
|
var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
|