@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.mjs
CHANGED
|
@@ -2252,8 +2252,7 @@ var GetActionSchema = z.object({
|
|
|
2252
2252
|
var getActionPlugin = ({ sdk }) => {
|
|
2253
2253
|
const getAction = createFunction(async function getAction2(options) {
|
|
2254
2254
|
const { actionKey, actionType, appKey } = options;
|
|
2255
|
-
const
|
|
2256
|
-
for (const action of actionsResult.data) {
|
|
2255
|
+
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
2257
2256
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2258
2257
|
return { data: action };
|
|
2259
2258
|
}
|
|
@@ -2283,49 +2282,68 @@ var getActionPlugin = ({ sdk }) => {
|
|
|
2283
2282
|
}
|
|
2284
2283
|
};
|
|
2285
2284
|
};
|
|
2286
|
-
var
|
|
2285
|
+
var AuthenticationSchema2 = z.object({
|
|
2286
|
+
id: z.number(),
|
|
2287
|
+
date: z.string(),
|
|
2288
|
+
lastchanged: z.string().optional(),
|
|
2289
|
+
account_id: z.number(),
|
|
2290
|
+
customuser_id: z.number().optional(),
|
|
2291
|
+
selected_api: z.string(),
|
|
2292
|
+
destination_selected_api: z.string().nullable().optional(),
|
|
2293
|
+
is_invite_only: z.boolean(),
|
|
2294
|
+
is_private: z.boolean(),
|
|
2295
|
+
shared_with_all: z.boolean(),
|
|
2296
|
+
is_stale: z.string().optional(),
|
|
2297
|
+
is_shared: z.string().optional(),
|
|
2298
|
+
marked_stale_at: z.string().nullable().optional(),
|
|
2299
|
+
label: z.string().nullable().optional(),
|
|
2300
|
+
identifier: z.string().nullable().optional(),
|
|
2301
|
+
title: z.string().nullable().optional(),
|
|
2302
|
+
url: z.string().optional(),
|
|
2303
|
+
groups: z.string().optional(),
|
|
2304
|
+
members: z.string().optional(),
|
|
2305
|
+
permissions: z.record(z.boolean()).optional()
|
|
2306
|
+
});
|
|
2307
|
+
z.object({
|
|
2308
|
+
count: z.number(),
|
|
2309
|
+
next: z.string().nullable().optional(),
|
|
2310
|
+
previous: z.string().nullable().optional(),
|
|
2311
|
+
results: z.array(AuthenticationSchema2)
|
|
2312
|
+
});
|
|
2313
|
+
var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
|
|
2314
|
+
selected_api: true,
|
|
2315
|
+
customuser_id: true
|
|
2316
|
+
}).extend({
|
|
2317
|
+
// Renamed fields
|
|
2318
|
+
implementation_id: z.string().optional(),
|
|
2319
|
+
user_id: z.number().optional(),
|
|
2320
|
+
// Mapped fields (originals preserved in ...restOfAuth)
|
|
2321
|
+
is_expired: z.string().optional(),
|
|
2322
|
+
expired_at: z.string().nullable().optional(),
|
|
2323
|
+
// Computed fields
|
|
2324
|
+
app_key: z.string().optional(),
|
|
2325
|
+
app_version: z.string().optional()
|
|
2326
|
+
});
|
|
2327
|
+
var GetAuthenticationOptionsSchema = z.object({
|
|
2287
2328
|
authenticationId: z.number().int().positive().describe("Authentication ID to retrieve")
|
|
2288
2329
|
}).describe("Get a specific authentication by ID");
|
|
2330
|
+
var GetAuthenticationHandlerRequestSchema = z.object({
|
|
2331
|
+
authenticationId: z.union([z.string(), z.number()]).describe("Authentication ID - string from searchParams or number")
|
|
2332
|
+
}).transform((data) => ({
|
|
2333
|
+
authenticationId: typeof data.authenticationId === "string" ? parseInt(data.authenticationId, 10) : data.authenticationId
|
|
2334
|
+
}));
|
|
2335
|
+
z.object({
|
|
2336
|
+
data: z.lazy(() => AuthenticationItemSchema2)
|
|
2337
|
+
});
|
|
2289
2338
|
|
|
2290
2339
|
// src/plugins/getAuthentication/index.ts
|
|
2291
2340
|
var getAuthenticationPlugin = ({ context }) => {
|
|
2292
2341
|
const getAuthentication = createFunction(async function getAuthentication2(options) {
|
|
2293
2342
|
const { api } = context;
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
`/zapier/api/v4/authentications/${authenticationId}/`,
|
|
2297
|
-
{
|
|
2298
|
-
customErrorHandler: ({ status }) => {
|
|
2299
|
-
if (status === 401) {
|
|
2300
|
-
return new ZapierAuthenticationError(
|
|
2301
|
-
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
2302
|
-
{ statusCode: status }
|
|
2303
|
-
);
|
|
2304
|
-
}
|
|
2305
|
-
if (status === 403) {
|
|
2306
|
-
return new ZapierAuthenticationError(
|
|
2307
|
-
`Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${status})`,
|
|
2308
|
-
{ statusCode: status }
|
|
2309
|
-
);
|
|
2310
|
-
}
|
|
2311
|
-
if (status === 404) {
|
|
2312
|
-
return new ZapierResourceNotFoundError(
|
|
2313
|
-
`Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${status})`,
|
|
2314
|
-
{
|
|
2315
|
-
resourceType: "Authentication",
|
|
2316
|
-
resourceId: String(authenticationId)
|
|
2317
|
-
}
|
|
2318
|
-
);
|
|
2319
|
-
}
|
|
2320
|
-
return void 0;
|
|
2321
|
-
},
|
|
2322
|
-
authRequired: true
|
|
2323
|
-
}
|
|
2343
|
+
return await api.get(
|
|
2344
|
+
`/api/v0/authentications/${options.authenticationId}`
|
|
2324
2345
|
);
|
|
2325
|
-
|
|
2326
|
-
data: normalizeAuthenticationItem(data)
|
|
2327
|
-
};
|
|
2328
|
-
}, GetAuthenticationSchema);
|
|
2346
|
+
}, GetAuthenticationOptionsSchema);
|
|
2329
2347
|
return {
|
|
2330
2348
|
getAuthentication,
|
|
2331
2349
|
context: {
|
|
@@ -2334,7 +2352,7 @@ var getAuthenticationPlugin = ({ context }) => {
|
|
|
2334
2352
|
categories: ["authentication"],
|
|
2335
2353
|
type: "item",
|
|
2336
2354
|
itemType: "Authentication",
|
|
2337
|
-
inputSchema:
|
|
2355
|
+
inputSchema: GetAuthenticationOptionsSchema,
|
|
2338
2356
|
outputSchema: AuthenticationItemSchema,
|
|
2339
2357
|
resolvers: {
|
|
2340
2358
|
authenticationId: authenticationIdGenericResolver
|
|
@@ -3171,6 +3189,12 @@ function isJwt(token) {
|
|
|
3171
3189
|
const base64UrlPattern = /^[A-Za-z0-9_-]+$/;
|
|
3172
3190
|
return parts.every((part) => part.length > 0 && base64UrlPattern.test(part));
|
|
3173
3191
|
}
|
|
3192
|
+
function parseJwt(token) {
|
|
3193
|
+
if (!isJwt(token)) {
|
|
3194
|
+
return null;
|
|
3195
|
+
}
|
|
3196
|
+
return token.split(".");
|
|
3197
|
+
}
|
|
3174
3198
|
function getAuthorizationHeader(token) {
|
|
3175
3199
|
if (isJwt(token)) {
|
|
3176
3200
|
return `JWT ${token}`;
|
|
@@ -3178,11 +3202,11 @@ function getAuthorizationHeader(token) {
|
|
|
3178
3202
|
return `Bearer ${token}`;
|
|
3179
3203
|
}
|
|
3180
3204
|
function extractUserIdsFromJwt(token) {
|
|
3205
|
+
const parts = parseJwt(token);
|
|
3206
|
+
if (!parts) {
|
|
3207
|
+
return { customuser_id: null, account_id: null };
|
|
3208
|
+
}
|
|
3181
3209
|
try {
|
|
3182
|
-
const parts = token.split(".");
|
|
3183
|
-
if (parts.length !== 3) {
|
|
3184
|
-
return { customuser_id: null, account_id: null };
|
|
3185
|
-
}
|
|
3186
3210
|
const payload = JSON.parse(
|
|
3187
3211
|
Buffer.from(parts[1], "base64url").toString("utf-8")
|
|
3188
3212
|
);
|
|
@@ -3489,6 +3513,18 @@ async function getTokenFromEnvOrConfig(options = {}) {
|
|
|
3489
3513
|
}
|
|
3490
3514
|
return getTokenFromCliLogin(options);
|
|
3491
3515
|
}
|
|
3516
|
+
async function resolveAuthToken(options = {}) {
|
|
3517
|
+
if (options.token) {
|
|
3518
|
+
return options.token;
|
|
3519
|
+
}
|
|
3520
|
+
if (options.getToken) {
|
|
3521
|
+
const token = await options.getToken();
|
|
3522
|
+
if (token) {
|
|
3523
|
+
return token;
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
return getTokenFromEnvOrConfig(options);
|
|
3527
|
+
}
|
|
3492
3528
|
|
|
3493
3529
|
// src/utils/url-utils.ts
|
|
3494
3530
|
function getZapierBaseUrl(baseUrl) {
|
|
@@ -3536,7 +3572,7 @@ function getTrackingBaseUrl({
|
|
|
3536
3572
|
return ZAPIER_BASE_URL;
|
|
3537
3573
|
}
|
|
3538
3574
|
|
|
3539
|
-
// src/temporary-internal-core/utils/
|
|
3575
|
+
// src/temporary-internal-core/utils/string-utils.ts
|
|
3540
3576
|
function splitVersionedKey2(versionedKey) {
|
|
3541
3577
|
const parts = versionedKey.split("@");
|
|
3542
3578
|
if (parts.length >= 2) {
|
|
@@ -3571,6 +3607,44 @@ function extractPaginationCursor(response) {
|
|
|
3571
3607
|
return void 0;
|
|
3572
3608
|
}
|
|
3573
3609
|
}
|
|
3610
|
+
function normalizeAuthenticationItem2(auth, options = {}) {
|
|
3611
|
+
let appKey = options.app_key;
|
|
3612
|
+
let appVersion = options.app_version;
|
|
3613
|
+
if (auth.selected_api) {
|
|
3614
|
+
const [extractedAppKey, extractedVersion] = splitVersionedKey2(
|
|
3615
|
+
auth.selected_api
|
|
3616
|
+
);
|
|
3617
|
+
if (!appKey) {
|
|
3618
|
+
appKey = extractedAppKey;
|
|
3619
|
+
}
|
|
3620
|
+
if (!appVersion) {
|
|
3621
|
+
appVersion = extractedVersion;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
const {
|
|
3625
|
+
selected_api: selectedApi,
|
|
3626
|
+
customuser_id: userId,
|
|
3627
|
+
...restOfAuth
|
|
3628
|
+
} = auth;
|
|
3629
|
+
return {
|
|
3630
|
+
...restOfAuth,
|
|
3631
|
+
// Pass through all other API response fields except selected_api
|
|
3632
|
+
implementation_id: selectedApi,
|
|
3633
|
+
// Rename selected_api to implementation_id
|
|
3634
|
+
title: auth.title || auth.label || void 0,
|
|
3635
|
+
// Coerce title from label if missing
|
|
3636
|
+
is_expired: auth.is_stale,
|
|
3637
|
+
// Map is_stale to is_expired
|
|
3638
|
+
expired_at: auth.marked_stale_at,
|
|
3639
|
+
// Map marked_stale_at to expired_at
|
|
3640
|
+
app_key: appKey,
|
|
3641
|
+
// App key from implementations endpoint or parsed from selected_api
|
|
3642
|
+
app_version: appVersion,
|
|
3643
|
+
// Version from selected_api or provided
|
|
3644
|
+
user_id: userId
|
|
3645
|
+
// Map customuser_id to user_id
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3574
3648
|
|
|
3575
3649
|
// src/temporary-internal-core/handlers/listApps.ts
|
|
3576
3650
|
var DEFAULT_PAGE_SIZE = 20;
|
|
@@ -3665,6 +3739,111 @@ var handleListApps = async ({ request, deps }) => {
|
|
|
3665
3739
|
};
|
|
3666
3740
|
};
|
|
3667
3741
|
|
|
3742
|
+
// src/temporary-internal-core/schemas/errors/index.ts
|
|
3743
|
+
var ZapierError2 = class extends Error {
|
|
3744
|
+
constructor(message, options = {}) {
|
|
3745
|
+
super(message);
|
|
3746
|
+
this.statusCode = options.statusCode;
|
|
3747
|
+
this.errors = options.errors;
|
|
3748
|
+
this.cause = options.cause;
|
|
3749
|
+
this.response = options.response;
|
|
3750
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3751
|
+
}
|
|
3752
|
+
};
|
|
3753
|
+
var ZapierAuthenticationError2 = class extends ZapierError2 {
|
|
3754
|
+
constructor(message, options = {}) {
|
|
3755
|
+
super(message, options);
|
|
3756
|
+
this.name = "ZapierAuthenticationError";
|
|
3757
|
+
}
|
|
3758
|
+
};
|
|
3759
|
+
var ZapierResourceNotFoundError2 = class extends ZapierError2 {
|
|
3760
|
+
constructor(message, options = {}) {
|
|
3761
|
+
super(message, options);
|
|
3762
|
+
this.name = "ZapierResourceNotFoundError";
|
|
3763
|
+
this.resourceType = options.resourceType;
|
|
3764
|
+
this.resourceId = options.resourceId;
|
|
3765
|
+
}
|
|
3766
|
+
};
|
|
3767
|
+
|
|
3768
|
+
// src/temporary-internal-core/handlers/getAuthentication.ts
|
|
3769
|
+
var handleGetAuthentication = async ({ request, deps }) => {
|
|
3770
|
+
const validatedRequest = GetAuthenticationHandlerRequestSchema.parse(request);
|
|
3771
|
+
const { httpClient } = deps;
|
|
3772
|
+
const { authenticationId } = validatedRequest;
|
|
3773
|
+
const authentication = await httpClient.get(
|
|
3774
|
+
`/zapier/api/v4/authentications/${authenticationId}/`,
|
|
3775
|
+
{
|
|
3776
|
+
authRequired: true,
|
|
3777
|
+
customErrorHandler: ({ status }) => {
|
|
3778
|
+
if (status === 401) {
|
|
3779
|
+
return new ZapierAuthenticationError2(
|
|
3780
|
+
`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`,
|
|
3781
|
+
{ statusCode: status }
|
|
3782
|
+
);
|
|
3783
|
+
}
|
|
3784
|
+
if (status === 403) {
|
|
3785
|
+
return new ZapierAuthenticationError2(
|
|
3786
|
+
`Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${status})`,
|
|
3787
|
+
{ statusCode: status }
|
|
3788
|
+
);
|
|
3789
|
+
}
|
|
3790
|
+
if (status === 404) {
|
|
3791
|
+
return new ZapierResourceNotFoundError2(
|
|
3792
|
+
`Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${status})`,
|
|
3793
|
+
{
|
|
3794
|
+
resourceType: "Authentication",
|
|
3795
|
+
resourceId: String(authenticationId)
|
|
3796
|
+
}
|
|
3797
|
+
);
|
|
3798
|
+
}
|
|
3799
|
+
return void 0;
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
);
|
|
3803
|
+
const normalizedAuthentication = normalizeAuthenticationItem2(authentication);
|
|
3804
|
+
return {
|
|
3805
|
+
data: normalizedAuthentication
|
|
3806
|
+
};
|
|
3807
|
+
};
|
|
3808
|
+
|
|
3809
|
+
// src/api/router.ts
|
|
3810
|
+
var routes = [
|
|
3811
|
+
{
|
|
3812
|
+
method: "GET",
|
|
3813
|
+
pattern: /^\/api\/v0\/apps$/,
|
|
3814
|
+
handler: handleListApps,
|
|
3815
|
+
paramMap: []
|
|
3816
|
+
},
|
|
3817
|
+
{
|
|
3818
|
+
method: "GET",
|
|
3819
|
+
pattern: /^\/api\/v0\/authentications\/([^\/]+)$/,
|
|
3820
|
+
handler: handleGetAuthentication,
|
|
3821
|
+
paramMap: ["authenticationId"]
|
|
3822
|
+
}
|
|
3823
|
+
];
|
|
3824
|
+
function findMatchingRoute(routeList, method, path) {
|
|
3825
|
+
for (const route of routeList) {
|
|
3826
|
+
if (route.method !== method) {
|
|
3827
|
+
continue;
|
|
3828
|
+
}
|
|
3829
|
+
const match = path.match(route.pattern);
|
|
3830
|
+
if (match) {
|
|
3831
|
+
const params = {};
|
|
3832
|
+
route.paramMap.forEach((name, index) => {
|
|
3833
|
+
params[name] = match[index + 1];
|
|
3834
|
+
});
|
|
3835
|
+
return {
|
|
3836
|
+
handler: route.handler,
|
|
3837
|
+
params
|
|
3838
|
+
};
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3841
|
+
return null;
|
|
3842
|
+
}
|
|
3843
|
+
function matchRoute(method, path) {
|
|
3844
|
+
return findMatchingRoute(routes, method, path);
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3668
3847
|
// src/api/client.ts
|
|
3669
3848
|
var pathConfig = {
|
|
3670
3849
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -3676,9 +3855,6 @@ var pathConfig = {
|
|
|
3676
3855
|
"/zapier": {
|
|
3677
3856
|
authHeader: "Authorization",
|
|
3678
3857
|
pathPrefix: "/api/v0/sdk/zapier"
|
|
3679
|
-
},
|
|
3680
|
-
"/api/v0/apps": {
|
|
3681
|
-
handlerOverride: handleListApps
|
|
3682
3858
|
}
|
|
3683
3859
|
};
|
|
3684
3860
|
var ZapierApiClient = class {
|
|
@@ -3724,16 +3900,9 @@ var ZapierApiClient = class {
|
|
|
3724
3900
|
}
|
|
3725
3901
|
// Helper to get a token from the different places it could be gotten
|
|
3726
3902
|
async getAuthToken() {
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
if (this.options.getToken) {
|
|
3731
|
-
const token = await this.options.getToken();
|
|
3732
|
-
if (token) {
|
|
3733
|
-
return token;
|
|
3734
|
-
}
|
|
3735
|
-
}
|
|
3736
|
-
return getTokenFromEnvOrConfig({
|
|
3903
|
+
return resolveAuthToken({
|
|
3904
|
+
token: this.options.token,
|
|
3905
|
+
getToken: this.options.getToken,
|
|
3737
3906
|
onEvent: this.options.onEvent,
|
|
3738
3907
|
fetch: this.options.fetch,
|
|
3739
3908
|
baseUrl: this.options.baseUrl,
|
|
@@ -3836,14 +4005,6 @@ var ZapierApiClient = class {
|
|
|
3836
4005
|
}
|
|
3837
4006
|
return void 0;
|
|
3838
4007
|
}
|
|
3839
|
-
// Helper to check if a path config has a handler override
|
|
3840
|
-
hasHandlerOverride(pathConfig2) {
|
|
3841
|
-
return pathConfig2 !== void 0 && "handlerOverride" in pathConfig2 && typeof pathConfig2.handlerOverride === "function";
|
|
3842
|
-
}
|
|
3843
|
-
// Helper to check if a path config is a standard path config
|
|
3844
|
-
isStandardPathConfig(pathConfig2) {
|
|
3845
|
-
return pathConfig2 !== void 0 && !this.hasHandlerOverride(pathConfig2);
|
|
3846
|
-
}
|
|
3847
4008
|
// Helper to parse API error response
|
|
3848
4009
|
parseErrorResponse(errorInfo) {
|
|
3849
4010
|
const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
|
|
@@ -3895,8 +4056,10 @@ var ZapierApiClient = class {
|
|
|
3895
4056
|
pathConfig: config
|
|
3896
4057
|
};
|
|
3897
4058
|
}
|
|
4059
|
+
const baseUrl = new URL(this.options.baseUrl);
|
|
4060
|
+
const fullPath = baseUrl.pathname.replace(/\/$/, "") + path;
|
|
3898
4061
|
return {
|
|
3899
|
-
url: new URL(
|
|
4062
|
+
url: new URL(fullPath, baseUrl.origin),
|
|
3900
4063
|
pathConfig: config
|
|
3901
4064
|
};
|
|
3902
4065
|
}
|
|
@@ -3915,7 +4078,7 @@ var ZapierApiClient = class {
|
|
|
3915
4078
|
const headers = new Headers(options.headers ?? {});
|
|
3916
4079
|
const authToken = await this.getAuthToken();
|
|
3917
4080
|
if (authToken) {
|
|
3918
|
-
const authHeaderName =
|
|
4081
|
+
const authHeaderName = pathConfig2 && pathConfig2.authHeader ? pathConfig2.authHeader : "Authorization";
|
|
3919
4082
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
3920
4083
|
}
|
|
3921
4084
|
if (options.authRequired) {
|
|
@@ -3929,10 +4092,14 @@ var ZapierApiClient = class {
|
|
|
3929
4092
|
}
|
|
3930
4093
|
// Helper to perform HTTP requests with JSON handling
|
|
3931
4094
|
async fetchJson(method, path, data, options = {}) {
|
|
3932
|
-
const
|
|
3933
|
-
if (
|
|
3934
|
-
const handlerRequest =
|
|
3935
|
-
|
|
4095
|
+
const routeMatch = matchRoute(method, path);
|
|
4096
|
+
if (routeMatch) {
|
|
4097
|
+
const handlerRequest = {
|
|
4098
|
+
...typeof data === "object" ? data : {},
|
|
4099
|
+
...options.searchParams,
|
|
4100
|
+
...routeMatch.params
|
|
4101
|
+
};
|
|
4102
|
+
return routeMatch.handler({
|
|
3936
4103
|
request: handlerRequest,
|
|
3937
4104
|
deps: {
|
|
3938
4105
|
httpClient: this
|
|
@@ -4601,7 +4768,7 @@ function getCpuTime() {
|
|
|
4601
4768
|
|
|
4602
4769
|
// package.json
|
|
4603
4770
|
var package_default = {
|
|
4604
|
-
version: "0.15.
|
|
4771
|
+
version: "0.15.9"};
|
|
4605
4772
|
|
|
4606
4773
|
// src/plugins/eventEmission/builders.ts
|
|
4607
4774
|
function createBaseEvent(context = {}) {
|
|
@@ -4741,9 +4908,14 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4741
4908
|
};
|
|
4742
4909
|
const getUserContext = (async () => {
|
|
4743
4910
|
try {
|
|
4744
|
-
const
|
|
4745
|
-
|
|
4746
|
-
|
|
4911
|
+
const token = await resolveAuthToken({
|
|
4912
|
+
token: context.options.token,
|
|
4913
|
+
getToken: context.options.getToken,
|
|
4914
|
+
baseUrl: context.options.baseUrl,
|
|
4915
|
+
authBaseUrl: context.options.authBaseUrl,
|
|
4916
|
+
authClientId: context.options.authClientId,
|
|
4917
|
+
onEvent: context.options.onEvent,
|
|
4918
|
+
fetch: context.options.fetch
|
|
4747
4919
|
});
|
|
4748
4920
|
if (token) {
|
|
4749
4921
|
return extractUserIdsFromJwt(token);
|
|
@@ -4984,4 +5156,4 @@ function createZapierSdk(options = {}) {
|
|
|
4984
5156
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
4985
5157
|
}
|
|
4986
5158
|
|
|
4987
|
-
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin, toSnakeCase, toTitleCase };
|
|
5159
|
+
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isCi, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resolveAuthToken, runActionPlugin, toSnakeCase, toTitleCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAgBnE,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAGD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE;QACb,SAAS,EAAE,cAAc,CAAC;QAC1B,MAAM,EAAE,mBAAmB,CAAC;QAE5B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;QAErD,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;KACvC,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AA4FD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,EAAE,EACF;IACE,OAAO,EAAE;QACP,aAAa,CAAC,EAAE,mBAAmB,CAAC;QACpC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,EACD,qBAAqB,CA6QtB,CAAC;AAGF,YAAY,EACV,YAAY,EACZ,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,cAAc,SAAS,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { createTransport } from "./transport";
|
|
8
8
|
import { generateEventId, getCurrentTimestamp, getReleaseId } from "./utils";
|
|
9
9
|
import { extractUserIdsFromJwt } from "../../api/auth";
|
|
10
|
+
import { resolveAuthToken } from "../../auth";
|
|
10
11
|
import { buildApplicationLifecycleEvent, buildErrorEventWithContext, } from "./builders";
|
|
11
12
|
import { getTrackingBaseUrl } from "../../utils/url-utils";
|
|
12
13
|
// Maximum time to wait for telemetry emission before allowing process to exit
|
|
@@ -94,18 +95,21 @@ export const eventEmissionPlugin = ({ context }) => {
|
|
|
94
95
|
// Create getUserContext promise for dynamic user context injection
|
|
95
96
|
const getUserContext = (async () => {
|
|
96
97
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const token = await getToken({
|
|
98
|
+
const token = await resolveAuthToken({
|
|
99
|
+
token: context.options.token,
|
|
100
|
+
getToken: context.options.getToken,
|
|
101
101
|
baseUrl: context.options.baseUrl,
|
|
102
|
+
authBaseUrl: context.options.authBaseUrl,
|
|
103
|
+
authClientId: context.options.authClientId,
|
|
104
|
+
onEvent: context.options.onEvent,
|
|
105
|
+
fetch: context.options.fetch,
|
|
102
106
|
});
|
|
103
107
|
if (token) {
|
|
104
108
|
return extractUserIdsFromJwt(token);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
catch {
|
|
108
|
-
//
|
|
112
|
+
// Fall back to null context on any error
|
|
109
113
|
}
|
|
110
114
|
return { customuser_id: null, account_id: null };
|
|
111
115
|
})();
|
|
@@ -417,4 +417,165 @@ describe("eventEmissionPlugin", () => {
|
|
|
417
417
|
expect(baseEvent.customuser_id).toBe(null);
|
|
418
418
|
expect(baseEvent.account_id).toBe(null);
|
|
419
419
|
});
|
|
420
|
+
it("should extract user IDs from static token in SDK options", async () => {
|
|
421
|
+
// Create a test JWT token
|
|
422
|
+
const header = { alg: "HS256", typ: "JWT" };
|
|
423
|
+
const payload = {
|
|
424
|
+
"zap:acc": "11111",
|
|
425
|
+
sub: "22222",
|
|
426
|
+
sub_type: "customuser",
|
|
427
|
+
};
|
|
428
|
+
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
429
|
+
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
430
|
+
const testJwt = `${encodedHeader}.${encodedPayload}.static-signature`;
|
|
431
|
+
const plugin = eventEmissionPlugin({
|
|
432
|
+
sdk: {},
|
|
433
|
+
context: {
|
|
434
|
+
meta: {},
|
|
435
|
+
options: {
|
|
436
|
+
token: testJwt,
|
|
437
|
+
eventEmission: {
|
|
438
|
+
enabled: true,
|
|
439
|
+
transport: { type: "console" },
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
445
|
+
// Should extract from static token in options
|
|
446
|
+
expect(baseEvent.customuser_id).toBe(22222);
|
|
447
|
+
expect(baseEvent.account_id).toBe(11111);
|
|
448
|
+
// CLI login package should not be called when token is in options
|
|
449
|
+
expect(mockGetToken).not.toHaveBeenCalled();
|
|
450
|
+
});
|
|
451
|
+
it("should extract user IDs from getToken function in SDK options", async () => {
|
|
452
|
+
// Create a test JWT token
|
|
453
|
+
const header = { alg: "HS256", typ: "JWT" };
|
|
454
|
+
const payload = {
|
|
455
|
+
"zap:acc": "33333",
|
|
456
|
+
sub: "44444",
|
|
457
|
+
sub_type: "customuser",
|
|
458
|
+
};
|
|
459
|
+
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
460
|
+
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
461
|
+
const testJwt = `${encodedHeader}.${encodedPayload}.custom-signature`;
|
|
462
|
+
const customGetToken = vi.fn().mockResolvedValue(testJwt);
|
|
463
|
+
const plugin = eventEmissionPlugin({
|
|
464
|
+
sdk: {},
|
|
465
|
+
context: {
|
|
466
|
+
meta: {},
|
|
467
|
+
options: {
|
|
468
|
+
getToken: customGetToken,
|
|
469
|
+
eventEmission: {
|
|
470
|
+
enabled: true,
|
|
471
|
+
transport: { type: "console" },
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
477
|
+
// Should extract from custom getToken function
|
|
478
|
+
expect(baseEvent.customuser_id).toBe(44444);
|
|
479
|
+
expect(baseEvent.account_id).toBe(33333);
|
|
480
|
+
expect(customGetToken).toHaveBeenCalled();
|
|
481
|
+
// CLI login package should not be called when getToken is in options
|
|
482
|
+
expect(mockGetToken).not.toHaveBeenCalled();
|
|
483
|
+
});
|
|
484
|
+
it("should prioritize static token over getToken function", async () => {
|
|
485
|
+
// Create test JWT tokens
|
|
486
|
+
const staticHeader = { alg: "HS256", typ: "JWT" };
|
|
487
|
+
const staticPayload = {
|
|
488
|
+
"zap:acc": "55555",
|
|
489
|
+
sub: "66666",
|
|
490
|
+
sub_type: "customuser",
|
|
491
|
+
};
|
|
492
|
+
const staticEncodedHeader = Buffer.from(JSON.stringify(staticHeader)).toString("base64url");
|
|
493
|
+
const staticEncodedPayload = Buffer.from(JSON.stringify(staticPayload)).toString("base64url");
|
|
494
|
+
const staticJwt = `${staticEncodedHeader}.${staticEncodedPayload}.static-sig`;
|
|
495
|
+
const customGetToken = vi.fn().mockResolvedValue("should-not-be-used");
|
|
496
|
+
const plugin = eventEmissionPlugin({
|
|
497
|
+
sdk: {},
|
|
498
|
+
context: {
|
|
499
|
+
meta: {},
|
|
500
|
+
options: {
|
|
501
|
+
token: staticJwt,
|
|
502
|
+
getToken: customGetToken,
|
|
503
|
+
eventEmission: {
|
|
504
|
+
enabled: true,
|
|
505
|
+
transport: { type: "console" },
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
});
|
|
510
|
+
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
511
|
+
// Should use static token, not getToken
|
|
512
|
+
expect(baseEvent.customuser_id).toBe(66666);
|
|
513
|
+
expect(baseEvent.account_id).toBe(55555);
|
|
514
|
+
expect(customGetToken).not.toHaveBeenCalled();
|
|
515
|
+
expect(mockGetToken).not.toHaveBeenCalled();
|
|
516
|
+
});
|
|
517
|
+
it("should fall back to CLI login when SDK options have no token", async () => {
|
|
518
|
+
// Create a test JWT token for CLI login
|
|
519
|
+
const header = { alg: "HS256", typ: "JWT" };
|
|
520
|
+
const payload = {
|
|
521
|
+
"zap:acc": "77777",
|
|
522
|
+
sub: "88888",
|
|
523
|
+
sub_type: "customuser",
|
|
524
|
+
};
|
|
525
|
+
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
526
|
+
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
527
|
+
const testJwt = `${encodedHeader}.${encodedPayload}.cli-signature`;
|
|
528
|
+
mockGetToken.mockResolvedValue(testJwt);
|
|
529
|
+
const plugin = eventEmissionPlugin({
|
|
530
|
+
sdk: {},
|
|
531
|
+
context: {
|
|
532
|
+
meta: {},
|
|
533
|
+
options: {
|
|
534
|
+
// No token or getToken in options
|
|
535
|
+
eventEmission: {
|
|
536
|
+
enabled: true,
|
|
537
|
+
transport: { type: "console" },
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
543
|
+
// Should fall back to CLI login package
|
|
544
|
+
expect(baseEvent.customuser_id).toBe(88888);
|
|
545
|
+
expect(baseEvent.account_id).toBe(77777);
|
|
546
|
+
expect(mockGetToken).toHaveBeenCalled();
|
|
547
|
+
});
|
|
548
|
+
it("should handle custom getToken returning undefined", async () => {
|
|
549
|
+
const customGetToken = vi.fn().mockResolvedValue(undefined);
|
|
550
|
+
// Also mock CLI login to return a token
|
|
551
|
+
const header = { alg: "HS256", typ: "JWT" };
|
|
552
|
+
const payload = {
|
|
553
|
+
"zap:acc": "99999",
|
|
554
|
+
sub: "10101",
|
|
555
|
+
sub_type: "customuser",
|
|
556
|
+
};
|
|
557
|
+
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
558
|
+
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
559
|
+
const testJwt = `${encodedHeader}.${encodedPayload}.fallback-signature`;
|
|
560
|
+
mockGetToken.mockResolvedValue(testJwt);
|
|
561
|
+
const plugin = eventEmissionPlugin({
|
|
562
|
+
sdk: {},
|
|
563
|
+
context: {
|
|
564
|
+
meta: {},
|
|
565
|
+
options: {
|
|
566
|
+
getToken: customGetToken,
|
|
567
|
+
eventEmission: {
|
|
568
|
+
enabled: true,
|
|
569
|
+
transport: { type: "console" },
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
});
|
|
574
|
+
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
575
|
+
// Should fall back to CLI login when custom getToken returns undefined
|
|
576
|
+
expect(baseEvent.customuser_id).toBe(10101);
|
|
577
|
+
expect(baseEvent.account_id).toBe(99999);
|
|
578
|
+
expect(customGetToken).toHaveBeenCalled();
|
|
579
|
+
expect(mockGetToken).toHaveBeenCalled();
|
|
580
|
+
});
|
|
420
581
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAQhE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;AACrE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAQhE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;AACrE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,uBAAuB,CA2CxB,CAAC"}
|
|
@@ -6,10 +6,8 @@ import { ActionItemSchema } from "../../schemas/Action";
|
|
|
6
6
|
export const getActionPlugin = ({ sdk }) => {
|
|
7
7
|
const getAction = createFunction(async function getAction(options) {
|
|
8
8
|
const { actionKey, actionType, appKey } = options;
|
|
9
|
-
// Use the listActions function from the SDK to search for the specific action
|
|
10
|
-
const
|
|
11
|
-
// Search through all actions to find the matching one (by key or ID)
|
|
12
|
-
for (const action of actionsResult.data) {
|
|
9
|
+
// Use the listActions function from the SDK to search for the specific action across all pages
|
|
10
|
+
for await (const action of sdk.listActions({ appKey }).items()) {
|
|
13
11
|
if ((action.key === actionKey || action.id === actionKey) &&
|
|
14
12
|
action.action_type === actionType) {
|
|
15
13
|
return { data: action };
|