@zapier/zapier-sdk 0.15.4 → 0.15.9
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 +30 -0
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +14 -4
- package/dist/api/auth.test.d.ts +2 -0
- package/dist/api/auth.test.d.ts.map +1 -0
- package/dist/api/auth.test.js +220 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +18 -32
- package/dist/api/client.methods.test.d.ts +2 -0
- package/dist/api/client.methods.test.d.ts.map +1 -0
- package/dist/api/client.methods.test.js +158 -0
- package/dist/api/client.test.js +27 -11
- package/dist/api/router.d.ts +16 -0
- package/dist/api/router.d.ts.map +1 -0
- package/dist/api/router.js +37 -0
- package/dist/api/router.test.d.ts +2 -0
- package/dist/api/router.test.d.ts.map +1 -0
- package/dist/api/router.test.js +109 -0
- package/dist/auth.d.ts +15 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +25 -0
- package/dist/index.cjs +247 -74
- package/dist/index.d.mts +402 -241
- package/dist/index.mjs +247 -75
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +9 -5
- package/dist/plugins/eventEmission/index.test.js +161 -0
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +2 -4
- package/dist/plugins/getAction/index.test.js +26 -3
- package/dist/plugins/getAuthentication/index.d.ts +2 -5
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +3 -24
- package/dist/plugins/getAuthentication/index.test.js +32 -144
- package/dist/plugins/getAuthentication/schemas.d.ts +4 -13
- package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/schemas.js +1 -11
- package/dist/sdk.d.ts +1 -1
- package/dist/temporary-internal-core/handlers/getAuthentication.d.ts +94 -0
- package/dist/temporary-internal-core/handlers/getAuthentication.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/getAuthentication.js +68 -0
- package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts +2 -0
- package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/getAuthentication.test.js +248 -0
- package/dist/temporary-internal-core/handlers/listApps.js +1 -1
- package/dist/temporary-internal-core/index.d.ts +2 -0
- package/dist/temporary-internal-core/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/index.js +2 -0
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts +454 -0
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/authentications/index.js +96 -0
- package/dist/temporary-internal-core/schemas/errors/index.d.ts +139 -0
- package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/errors/index.js +129 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -20
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +1 -1
- package/dist/temporary-internal-core/utils/app-locators.js +1 -45
- package/dist/temporary-internal-core/utils/string-utils.d.ts +28 -0
- package/dist/temporary-internal-core/utils/string-utils.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/string-utils.js +52 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts +14 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
- package/dist/temporary-internal-core/utils/transformations.js +37 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2274,8 +2274,7 @@ var GetActionSchema = zod.z.object({
|
|
|
2274
2274
|
var getActionPlugin = ({ sdk }) => {
|
|
2275
2275
|
const getAction = createFunction(async function getAction2(options) {
|
|
2276
2276
|
const { actionKey, actionType, appKey } = options;
|
|
2277
|
-
const
|
|
2278
|
-
for (const action of actionsResult.data) {
|
|
2277
|
+
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
2279
2278
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2280
2279
|
return { data: action };
|
|
2281
2280
|
}
|
|
@@ -2305,49 +2304,68 @@ var getActionPlugin = ({ sdk }) => {
|
|
|
2305
2304
|
}
|
|
2306
2305
|
};
|
|
2307
2306
|
};
|
|
2308
|
-
var
|
|
2307
|
+
var AuthenticationSchema2 = zod.z.object({
|
|
2308
|
+
id: zod.z.number(),
|
|
2309
|
+
date: zod.z.string(),
|
|
2310
|
+
lastchanged: zod.z.string().optional(),
|
|
2311
|
+
account_id: zod.z.number(),
|
|
2312
|
+
customuser_id: zod.z.number().optional(),
|
|
2313
|
+
selected_api: zod.z.string(),
|
|
2314
|
+
destination_selected_api: zod.z.string().nullable().optional(),
|
|
2315
|
+
is_invite_only: zod.z.boolean(),
|
|
2316
|
+
is_private: zod.z.boolean(),
|
|
2317
|
+
shared_with_all: zod.z.boolean(),
|
|
2318
|
+
is_stale: zod.z.string().optional(),
|
|
2319
|
+
is_shared: zod.z.string().optional(),
|
|
2320
|
+
marked_stale_at: zod.z.string().nullable().optional(),
|
|
2321
|
+
label: zod.z.string().nullable().optional(),
|
|
2322
|
+
identifier: zod.z.string().nullable().optional(),
|
|
2323
|
+
title: zod.z.string().nullable().optional(),
|
|
2324
|
+
url: zod.z.string().optional(),
|
|
2325
|
+
groups: zod.z.string().optional(),
|
|
2326
|
+
members: zod.z.string().optional(),
|
|
2327
|
+
permissions: zod.z.record(zod.z.boolean()).optional()
|
|
2328
|
+
});
|
|
2329
|
+
zod.z.object({
|
|
2330
|
+
count: zod.z.number(),
|
|
2331
|
+
next: zod.z.string().nullable().optional(),
|
|
2332
|
+
previous: zod.z.string().nullable().optional(),
|
|
2333
|
+
results: zod.z.array(AuthenticationSchema2)
|
|
2334
|
+
});
|
|
2335
|
+
var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
|
|
2336
|
+
selected_api: true,
|
|
2337
|
+
customuser_id: true
|
|
2338
|
+
}).extend({
|
|
2339
|
+
// Renamed fields
|
|
2340
|
+
implementation_id: zod.z.string().optional(),
|
|
2341
|
+
user_id: zod.z.number().optional(),
|
|
2342
|
+
// Mapped fields (originals preserved in ...restOfAuth)
|
|
2343
|
+
is_expired: zod.z.string().optional(),
|
|
2344
|
+
expired_at: zod.z.string().nullable().optional(),
|
|
2345
|
+
// Computed fields
|
|
2346
|
+
app_key: zod.z.string().optional(),
|
|
2347
|
+
app_version: zod.z.string().optional()
|
|
2348
|
+
});
|
|
2349
|
+
var GetAuthenticationOptionsSchema = zod.z.object({
|
|
2309
2350
|
authenticationId: zod.z.number().int().positive().describe("Authentication ID to retrieve")
|
|
2310
2351
|
}).describe("Get a specific authentication by ID");
|
|
2352
|
+
var GetAuthenticationHandlerRequestSchema = zod.z.object({
|
|
2353
|
+
authenticationId: zod.z.union([zod.z.string(), zod.z.number()]).describe("Authentication ID - string from searchParams or number")
|
|
2354
|
+
}).transform((data) => ({
|
|
2355
|
+
authenticationId: typeof data.authenticationId === "string" ? parseInt(data.authenticationId, 10) : data.authenticationId
|
|
2356
|
+
}));
|
|
2357
|
+
zod.z.object({
|
|
2358
|
+
data: zod.z.lazy(() => AuthenticationItemSchema2)
|
|
2359
|
+
});
|
|
2311
2360
|
|
|
2312
2361
|
// src/plugins/getAuthentication/index.ts
|
|
2313
2362
|
var getAuthenticationPlugin = ({ context }) => {
|
|
2314
2363
|
const getAuthentication = createFunction(async function getAuthentication2(options) {
|
|
2315
2364
|
const { api } = context;
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
`/zapier/api/v4/authentications/${authenticationId}/`,
|
|
2319
|
-
{
|
|
2320
|
-
customErrorHandler: ({ status }) => {
|
|
2321
|
-
if (status === 401) {
|
|
2322
|
-
return new ZapierAuthenticationError(
|
|
2323
|
-
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
2324
|
-
{ statusCode: status }
|
|
2325
|
-
);
|
|
2326
|
-
}
|
|
2327
|
-
if (status === 403) {
|
|
2328
|
-
return new ZapierAuthenticationError(
|
|
2329
|
-
`Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${status})`,
|
|
2330
|
-
{ statusCode: status }
|
|
2331
|
-
);
|
|
2332
|
-
}
|
|
2333
|
-
if (status === 404) {
|
|
2334
|
-
return new ZapierResourceNotFoundError(
|
|
2335
|
-
`Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${status})`,
|
|
2336
|
-
{
|
|
2337
|
-
resourceType: "Authentication",
|
|
2338
|
-
resourceId: String(authenticationId)
|
|
2339
|
-
}
|
|
2340
|
-
);
|
|
2341
|
-
}
|
|
2342
|
-
return void 0;
|
|
2343
|
-
},
|
|
2344
|
-
authRequired: true
|
|
2345
|
-
}
|
|
2365
|
+
return await api.get(
|
|
2366
|
+
`/api/v0/authentications/${options.authenticationId}`
|
|
2346
2367
|
);
|
|
2347
|
-
|
|
2348
|
-
data: normalizeAuthenticationItem(data)
|
|
2349
|
-
};
|
|
2350
|
-
}, GetAuthenticationSchema);
|
|
2368
|
+
}, GetAuthenticationOptionsSchema);
|
|
2351
2369
|
return {
|
|
2352
2370
|
getAuthentication,
|
|
2353
2371
|
context: {
|
|
@@ -2356,7 +2374,7 @@ var getAuthenticationPlugin = ({ context }) => {
|
|
|
2356
2374
|
categories: ["authentication"],
|
|
2357
2375
|
type: "item",
|
|
2358
2376
|
itemType: "Authentication",
|
|
2359
|
-
inputSchema:
|
|
2377
|
+
inputSchema: GetAuthenticationOptionsSchema,
|
|
2360
2378
|
outputSchema: AuthenticationItemSchema,
|
|
2361
2379
|
resolvers: {
|
|
2362
2380
|
authenticationId: authenticationIdGenericResolver
|
|
@@ -3193,6 +3211,12 @@ function isJwt(token) {
|
|
|
3193
3211
|
const base64UrlPattern = /^[A-Za-z0-9_-]+$/;
|
|
3194
3212
|
return parts.every((part) => part.length > 0 && base64UrlPattern.test(part));
|
|
3195
3213
|
}
|
|
3214
|
+
function parseJwt(token) {
|
|
3215
|
+
if (!isJwt(token)) {
|
|
3216
|
+
return null;
|
|
3217
|
+
}
|
|
3218
|
+
return token.split(".");
|
|
3219
|
+
}
|
|
3196
3220
|
function getAuthorizationHeader(token) {
|
|
3197
3221
|
if (isJwt(token)) {
|
|
3198
3222
|
return `JWT ${token}`;
|
|
@@ -3200,11 +3224,11 @@ function getAuthorizationHeader(token) {
|
|
|
3200
3224
|
return `Bearer ${token}`;
|
|
3201
3225
|
}
|
|
3202
3226
|
function extractUserIdsFromJwt(token) {
|
|
3227
|
+
const parts = parseJwt(token);
|
|
3228
|
+
if (!parts) {
|
|
3229
|
+
return { customuser_id: null, account_id: null };
|
|
3230
|
+
}
|
|
3203
3231
|
try {
|
|
3204
|
-
const parts = token.split(".");
|
|
3205
|
-
if (parts.length !== 3) {
|
|
3206
|
-
return { customuser_id: null, account_id: null };
|
|
3207
|
-
}
|
|
3208
3232
|
const payload = JSON.parse(
|
|
3209
3233
|
Buffer.from(parts[1], "base64url").toString("utf-8")
|
|
3210
3234
|
);
|
|
@@ -3511,6 +3535,18 @@ async function getTokenFromEnvOrConfig(options = {}) {
|
|
|
3511
3535
|
}
|
|
3512
3536
|
return getTokenFromCliLogin(options);
|
|
3513
3537
|
}
|
|
3538
|
+
async function resolveAuthToken(options = {}) {
|
|
3539
|
+
if (options.token) {
|
|
3540
|
+
return options.token;
|
|
3541
|
+
}
|
|
3542
|
+
if (options.getToken) {
|
|
3543
|
+
const token = await options.getToken();
|
|
3544
|
+
if (token) {
|
|
3545
|
+
return token;
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
return getTokenFromEnvOrConfig(options);
|
|
3549
|
+
}
|
|
3514
3550
|
|
|
3515
3551
|
// src/utils/url-utils.ts
|
|
3516
3552
|
function getZapierBaseUrl(baseUrl) {
|
|
@@ -3558,7 +3594,7 @@ function getTrackingBaseUrl({
|
|
|
3558
3594
|
return ZAPIER_BASE_URL;
|
|
3559
3595
|
}
|
|
3560
3596
|
|
|
3561
|
-
// src/temporary-internal-core/utils/
|
|
3597
|
+
// src/temporary-internal-core/utils/string-utils.ts
|
|
3562
3598
|
function splitVersionedKey2(versionedKey) {
|
|
3563
3599
|
const parts = versionedKey.split("@");
|
|
3564
3600
|
if (parts.length >= 2) {
|
|
@@ -3593,6 +3629,44 @@ function extractPaginationCursor(response) {
|
|
|
3593
3629
|
return void 0;
|
|
3594
3630
|
}
|
|
3595
3631
|
}
|
|
3632
|
+
function normalizeAuthenticationItem2(auth, options = {}) {
|
|
3633
|
+
let appKey = options.app_key;
|
|
3634
|
+
let appVersion = options.app_version;
|
|
3635
|
+
if (auth.selected_api) {
|
|
3636
|
+
const [extractedAppKey, extractedVersion] = splitVersionedKey2(
|
|
3637
|
+
auth.selected_api
|
|
3638
|
+
);
|
|
3639
|
+
if (!appKey) {
|
|
3640
|
+
appKey = extractedAppKey;
|
|
3641
|
+
}
|
|
3642
|
+
if (!appVersion) {
|
|
3643
|
+
appVersion = extractedVersion;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
const {
|
|
3647
|
+
selected_api: selectedApi,
|
|
3648
|
+
customuser_id: userId,
|
|
3649
|
+
...restOfAuth
|
|
3650
|
+
} = auth;
|
|
3651
|
+
return {
|
|
3652
|
+
...restOfAuth,
|
|
3653
|
+
// Pass through all other API response fields except selected_api
|
|
3654
|
+
implementation_id: selectedApi,
|
|
3655
|
+
// Rename selected_api to implementation_id
|
|
3656
|
+
title: auth.title || auth.label || void 0,
|
|
3657
|
+
// Coerce title from label if missing
|
|
3658
|
+
is_expired: auth.is_stale,
|
|
3659
|
+
// Map is_stale to is_expired
|
|
3660
|
+
expired_at: auth.marked_stale_at,
|
|
3661
|
+
// Map marked_stale_at to expired_at
|
|
3662
|
+
app_key: appKey,
|
|
3663
|
+
// App key from implementations endpoint or parsed from selected_api
|
|
3664
|
+
app_version: appVersion,
|
|
3665
|
+
// Version from selected_api or provided
|
|
3666
|
+
user_id: userId
|
|
3667
|
+
// Map customuser_id to user_id
|
|
3668
|
+
};
|
|
3669
|
+
}
|
|
3596
3670
|
|
|
3597
3671
|
// src/temporary-internal-core/handlers/listApps.ts
|
|
3598
3672
|
var DEFAULT_PAGE_SIZE = 20;
|
|
@@ -3687,6 +3761,111 @@ var handleListApps = async ({ request, deps }) => {
|
|
|
3687
3761
|
};
|
|
3688
3762
|
};
|
|
3689
3763
|
|
|
3764
|
+
// src/temporary-internal-core/schemas/errors/index.ts
|
|
3765
|
+
var ZapierError2 = class extends Error {
|
|
3766
|
+
constructor(message, options = {}) {
|
|
3767
|
+
super(message);
|
|
3768
|
+
this.statusCode = options.statusCode;
|
|
3769
|
+
this.errors = options.errors;
|
|
3770
|
+
this.cause = options.cause;
|
|
3771
|
+
this.response = options.response;
|
|
3772
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3773
|
+
}
|
|
3774
|
+
};
|
|
3775
|
+
var ZapierAuthenticationError2 = class extends ZapierError2 {
|
|
3776
|
+
constructor(message, options = {}) {
|
|
3777
|
+
super(message, options);
|
|
3778
|
+
this.name = "ZapierAuthenticationError";
|
|
3779
|
+
}
|
|
3780
|
+
};
|
|
3781
|
+
var ZapierResourceNotFoundError2 = class extends ZapierError2 {
|
|
3782
|
+
constructor(message, options = {}) {
|
|
3783
|
+
super(message, options);
|
|
3784
|
+
this.name = "ZapierResourceNotFoundError";
|
|
3785
|
+
this.resourceType = options.resourceType;
|
|
3786
|
+
this.resourceId = options.resourceId;
|
|
3787
|
+
}
|
|
3788
|
+
};
|
|
3789
|
+
|
|
3790
|
+
// src/temporary-internal-core/handlers/getAuthentication.ts
|
|
3791
|
+
var handleGetAuthentication = async ({ request, deps }) => {
|
|
3792
|
+
const validatedRequest = GetAuthenticationHandlerRequestSchema.parse(request);
|
|
3793
|
+
const { httpClient } = deps;
|
|
3794
|
+
const { authenticationId } = validatedRequest;
|
|
3795
|
+
const authentication = await httpClient.get(
|
|
3796
|
+
`/zapier/api/v4/authentications/${authenticationId}/`,
|
|
3797
|
+
{
|
|
3798
|
+
authRequired: true,
|
|
3799
|
+
customErrorHandler: ({ status }) => {
|
|
3800
|
+
if (status === 401) {
|
|
3801
|
+
return new ZapierAuthenticationError2(
|
|
3802
|
+
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
3803
|
+
{ statusCode: status }
|
|
3804
|
+
);
|
|
3805
|
+
}
|
|
3806
|
+
if (status === 403) {
|
|
3807
|
+
return new ZapierAuthenticationError2(
|
|
3808
|
+
`Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${status})`,
|
|
3809
|
+
{ statusCode: status }
|
|
3810
|
+
);
|
|
3811
|
+
}
|
|
3812
|
+
if (status === 404) {
|
|
3813
|
+
return new ZapierResourceNotFoundError2(
|
|
3814
|
+
`Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${status})`,
|
|
3815
|
+
{
|
|
3816
|
+
resourceType: "Authentication",
|
|
3817
|
+
resourceId: String(authenticationId)
|
|
3818
|
+
}
|
|
3819
|
+
);
|
|
3820
|
+
}
|
|
3821
|
+
return void 0;
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
);
|
|
3825
|
+
const normalizedAuthentication = normalizeAuthenticationItem2(authentication);
|
|
3826
|
+
return {
|
|
3827
|
+
data: normalizedAuthentication
|
|
3828
|
+
};
|
|
3829
|
+
};
|
|
3830
|
+
|
|
3831
|
+
// src/api/router.ts
|
|
3832
|
+
var routes = [
|
|
3833
|
+
{
|
|
3834
|
+
method: "GET",
|
|
3835
|
+
pattern: /^\/api\/v0\/apps$/,
|
|
3836
|
+
handler: handleListApps,
|
|
3837
|
+
paramMap: []
|
|
3838
|
+
},
|
|
3839
|
+
{
|
|
3840
|
+
method: "GET",
|
|
3841
|
+
pattern: /^\/api\/v0\/authentications\/([^\/]+)$/,
|
|
3842
|
+
handler: handleGetAuthentication,
|
|
3843
|
+
paramMap: ["authenticationId"]
|
|
3844
|
+
}
|
|
3845
|
+
];
|
|
3846
|
+
function findMatchingRoute(routeList, method, path) {
|
|
3847
|
+
for (const route of routeList) {
|
|
3848
|
+
if (route.method !== method) {
|
|
3849
|
+
continue;
|
|
3850
|
+
}
|
|
3851
|
+
const match = path.match(route.pattern);
|
|
3852
|
+
if (match) {
|
|
3853
|
+
const params = {};
|
|
3854
|
+
route.paramMap.forEach((name, index) => {
|
|
3855
|
+
params[name] = match[index + 1];
|
|
3856
|
+
});
|
|
3857
|
+
return {
|
|
3858
|
+
handler: route.handler,
|
|
3859
|
+
params
|
|
3860
|
+
};
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
return null;
|
|
3864
|
+
}
|
|
3865
|
+
function matchRoute(method, path) {
|
|
3866
|
+
return findMatchingRoute(routes, method, path);
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3690
3869
|
// src/api/client.ts
|
|
3691
3870
|
var pathConfig = {
|
|
3692
3871
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -3698,9 +3877,6 @@ var pathConfig = {
|
|
|
3698
3877
|
"/zapier": {
|
|
3699
3878
|
authHeader: "Authorization",
|
|
3700
3879
|
pathPrefix: "/api/v0/sdk/zapier"
|
|
3701
|
-
},
|
|
3702
|
-
"/api/v0/apps": {
|
|
3703
|
-
handlerOverride: handleListApps
|
|
3704
3880
|
}
|
|
3705
3881
|
};
|
|
3706
3882
|
var ZapierApiClient = class {
|
|
@@ -3746,16 +3922,9 @@ var ZapierApiClient = class {
|
|
|
3746
3922
|
}
|
|
3747
3923
|
// Helper to get a token from the different places it could be gotten
|
|
3748
3924
|
async getAuthToken() {
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
if (this.options.getToken) {
|
|
3753
|
-
const token = await this.options.getToken();
|
|
3754
|
-
if (token) {
|
|
3755
|
-
return token;
|
|
3756
|
-
}
|
|
3757
|
-
}
|
|
3758
|
-
return getTokenFromEnvOrConfig({
|
|
3925
|
+
return resolveAuthToken({
|
|
3926
|
+
token: this.options.token,
|
|
3927
|
+
getToken: this.options.getToken,
|
|
3759
3928
|
onEvent: this.options.onEvent,
|
|
3760
3929
|
fetch: this.options.fetch,
|
|
3761
3930
|
baseUrl: this.options.baseUrl,
|
|
@@ -3858,14 +4027,6 @@ var ZapierApiClient = class {
|
|
|
3858
4027
|
}
|
|
3859
4028
|
return void 0;
|
|
3860
4029
|
}
|
|
3861
|
-
// Helper to check if a path config has a handler override
|
|
3862
|
-
hasHandlerOverride(pathConfig2) {
|
|
3863
|
-
return pathConfig2 !== void 0 && "handlerOverride" in pathConfig2 && typeof pathConfig2.handlerOverride === "function";
|
|
3864
|
-
}
|
|
3865
|
-
// Helper to check if a path config is a standard path config
|
|
3866
|
-
isStandardPathConfig(pathConfig2) {
|
|
3867
|
-
return pathConfig2 !== void 0 && !this.hasHandlerOverride(pathConfig2);
|
|
3868
|
-
}
|
|
3869
4030
|
// Helper to parse API error response
|
|
3870
4031
|
parseErrorResponse(errorInfo) {
|
|
3871
4032
|
const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
|
|
@@ -3917,8 +4078,10 @@ var ZapierApiClient = class {
|
|
|
3917
4078
|
pathConfig: config
|
|
3918
4079
|
};
|
|
3919
4080
|
}
|
|
4081
|
+
const baseUrl = new URL(this.options.baseUrl);
|
|
4082
|
+
const fullPath = baseUrl.pathname.replace(/\/$/, "") + path;
|
|
3920
4083
|
return {
|
|
3921
|
-
url: new URL(
|
|
4084
|
+
url: new URL(fullPath, baseUrl.origin),
|
|
3922
4085
|
pathConfig: config
|
|
3923
4086
|
};
|
|
3924
4087
|
}
|
|
@@ -3937,7 +4100,7 @@ var ZapierApiClient = class {
|
|
|
3937
4100
|
const headers = new Headers(options.headers ?? {});
|
|
3938
4101
|
const authToken = await this.getAuthToken();
|
|
3939
4102
|
if (authToken) {
|
|
3940
|
-
const authHeaderName =
|
|
4103
|
+
const authHeaderName = pathConfig2 && pathConfig2.authHeader ? pathConfig2.authHeader : "Authorization";
|
|
3941
4104
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
3942
4105
|
}
|
|
3943
4106
|
if (options.authRequired) {
|
|
@@ -3951,10 +4114,14 @@ var ZapierApiClient = class {
|
|
|
3951
4114
|
}
|
|
3952
4115
|
// Helper to perform HTTP requests with JSON handling
|
|
3953
4116
|
async fetchJson(method, path, data, options = {}) {
|
|
3954
|
-
const
|
|
3955
|
-
if (
|
|
3956
|
-
const handlerRequest =
|
|
3957
|
-
|
|
4117
|
+
const routeMatch = matchRoute(method, path);
|
|
4118
|
+
if (routeMatch) {
|
|
4119
|
+
const handlerRequest = {
|
|
4120
|
+
...typeof data === "object" ? data : {},
|
|
4121
|
+
...options.searchParams,
|
|
4122
|
+
...routeMatch.params
|
|
4123
|
+
};
|
|
4124
|
+
return routeMatch.handler({
|
|
3958
4125
|
request: handlerRequest,
|
|
3959
4126
|
deps: {
|
|
3960
4127
|
httpClient: this
|
|
@@ -4623,7 +4790,7 @@ function getCpuTime() {
|
|
|
4623
4790
|
|
|
4624
4791
|
// package.json
|
|
4625
4792
|
var package_default = {
|
|
4626
|
-
version: "0.15.
|
|
4793
|
+
version: "0.15.9"};
|
|
4627
4794
|
|
|
4628
4795
|
// src/plugins/eventEmission/builders.ts
|
|
4629
4796
|
function createBaseEvent(context = {}) {
|
|
@@ -4763,9 +4930,14 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4763
4930
|
};
|
|
4764
4931
|
const getUserContext = (async () => {
|
|
4765
4932
|
try {
|
|
4766
|
-
const
|
|
4767
|
-
|
|
4768
|
-
|
|
4933
|
+
const token = await resolveAuthToken({
|
|
4934
|
+
token: context.options.token,
|
|
4935
|
+
getToken: context.options.getToken,
|
|
4936
|
+
baseUrl: context.options.baseUrl,
|
|
4937
|
+
authBaseUrl: context.options.authBaseUrl,
|
|
4938
|
+
authClientId: context.options.authClientId,
|
|
4939
|
+
onEvent: context.options.onEvent,
|
|
4940
|
+
fetch: context.options.fetch
|
|
4769
4941
|
});
|
|
4770
4942
|
if (token) {
|
|
4771
4943
|
return extractUserIdsFromJwt(token);
|
|
@@ -5083,6 +5255,7 @@ exports.manifestPlugin = manifestPlugin;
|
|
|
5083
5255
|
exports.readManifestFromFile = readManifestFromFile;
|
|
5084
5256
|
exports.registryPlugin = registryPlugin;
|
|
5085
5257
|
exports.requestPlugin = requestPlugin;
|
|
5258
|
+
exports.resolveAuthToken = resolveAuthToken;
|
|
5086
5259
|
exports.runActionPlugin = runActionPlugin;
|
|
5087
5260
|
exports.toSnakeCase = toSnakeCase;
|
|
5088
5261
|
exports.toTitleCase = toTitleCase;
|