@zapier/zapier-sdk 0.16.3 → 0.18.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/README.md +92 -92
- package/dist/api/schemas.d.ts +1 -1
- package/dist/api/schemas.js +1 -1
- package/dist/index.cjs +83 -46
- package/dist/index.d.mts +58 -100
- package/dist/index.mjs +83 -46
- package/dist/plugins/apps/index.js +2 -2
- package/dist/plugins/apps/schemas.d.ts +4 -3
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/apps/schemas.js +3 -2
- package/dist/plugins/fetch/index.d.ts +2 -2
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.d.ts +1 -1
- package/dist/plugins/fetch/schemas.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.js +2 -4
- package/dist/plugins/findFirstAuthentication/index.test.js +4 -4
- package/dist/plugins/findUniqueAuthentication/index.test.js +4 -4
- package/dist/plugins/getAuthentication/index.js +1 -1
- package/dist/plugins/getAuthentication/index.test.js +9 -4
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +1 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +7 -4
- package/dist/plugins/listAuthentications/index.test.js +9 -9
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +1 -1
- package/dist/plugins/listInputFields/schemas.d.ts +1 -1
- package/dist/plugins/manifest/schemas.d.ts +2 -2
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +2 -5
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +2 -1
- package/dist/plugins/request/schemas.d.ts +2 -2
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/request/schemas.js +2 -5
- package/dist/plugins/runAction/schemas.d.ts +1 -1
- package/dist/resolvers/inputFieldKey.d.ts +1 -1
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
- package/dist/resolvers/inputs.d.ts +1 -1
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/schemas/Auth.d.ts +6 -6
- package/dist/schemas/Auth.d.ts.map +1 -1
- package/dist/schemas/Auth.js +3 -1
- package/dist/schemas/UserProfile.d.ts +2 -44
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +10 -21
- package/dist/services/implementations.d.ts +2 -2
- package/dist/services/implementations.d.ts.map +1 -1
- package/dist/services/implementations.js +3 -2
- package/dist/temporary-internal-core/handlers/getAuthentication.test.js +7 -7
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts +8 -8
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/schemas/authentications/index.js +6 -5
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
- package/dist/temporary-internal-core/utils/transformations.js +4 -2
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/properties.js +1 -2
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +4 -2
- package/dist/utils/id-utils.d.ts +13 -0
- package/dist/utils/id-utils.d.ts.map +1 -0
- package/dist/utils/id-utils.js +22 -0
- package/dist/utils/id-utils.test.d.ts +2 -0
- package/dist/utils/id-utils.test.d.ts.map +1 -0
- package/dist/utils/id-utils.test.js +22 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -50,7 +50,7 @@ var ActionTypePropertySchema = z.enum([
|
|
|
50
50
|
"filter"
|
|
51
51
|
]).describe("Action type that matches the action's defined type");
|
|
52
52
|
var ActionKeyPropertySchema = z.string().min(1).describe("Action key to execute");
|
|
53
|
-
var AuthenticationIdPropertySchema = z.number().int().describe("Authentication ID to use for this action");
|
|
53
|
+
var AuthenticationIdPropertySchema = z.union([z.string(), z.number().int().positive()]).describe("Authentication ID to use for this action");
|
|
54
54
|
var InputsPropertySchema = z.record(z.string(), z.unknown()).describe("Input parameters for the action");
|
|
55
55
|
var LimitPropertySchema = z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
|
|
56
56
|
var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
|
|
@@ -194,12 +194,12 @@ HTTP Status: ${error.statusCode}`;
|
|
|
194
194
|
}
|
|
195
195
|
var ActionExecutionInputSchema = z.object({
|
|
196
196
|
inputs: z.record(z.string(), z.unknown()).optional(),
|
|
197
|
-
authenticationId:
|
|
197
|
+
authenticationId: AuthenticationIdPropertySchema.optional()
|
|
198
198
|
}).describe(
|
|
199
199
|
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
200
200
|
);
|
|
201
201
|
var AppFactoryInputSchema = z.object({
|
|
202
|
-
authenticationId:
|
|
202
|
+
authenticationId: AuthenticationIdPropertySchema
|
|
203
203
|
}).describe("Bind an authentication ID to an app");
|
|
204
204
|
function getStringProperty(obj, key) {
|
|
205
205
|
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
@@ -232,7 +232,7 @@ function createActionFunction(appKey, actionType, actionKey, options, pinnedAuth
|
|
|
232
232
|
return (actionOptions = {}) => {
|
|
233
233
|
const { sdk } = options;
|
|
234
234
|
const { inputs, authenticationId: providedAuthenticationId } = actionOptions;
|
|
235
|
-
const authenticationId = pinnedAuthId
|
|
235
|
+
const authenticationId = pinnedAuthId ?? providedAuthenticationId;
|
|
236
236
|
if (!authenticationId) {
|
|
237
237
|
throw new ZapierValidationError(
|
|
238
238
|
`Authentication ID is required. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }) or provide authenticationId in the action call.`
|
|
@@ -251,7 +251,7 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
251
251
|
if (actionType === "fetch") {
|
|
252
252
|
return async (url, init) => {
|
|
253
253
|
const { sdk } = options;
|
|
254
|
-
const authenticationId = pinnedAuthId
|
|
254
|
+
const authenticationId = pinnedAuthId ?? init?.authenticationId;
|
|
255
255
|
if (!authenticationId) {
|
|
256
256
|
throw new ZapierValidationError(
|
|
257
257
|
`Authentication ID is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }).fetch(...) or provide authenticationId in the fetch call.`
|
|
@@ -360,7 +360,7 @@ var FetchInitSchema = z.object({
|
|
|
360
360
|
z.instanceof(FormData),
|
|
361
361
|
z.instanceof(URLSearchParams)
|
|
362
362
|
]).optional(),
|
|
363
|
-
authenticationId:
|
|
363
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
364
364
|
callbackUrl: z.string().optional().describe("URL to send async response to (makes request async)"),
|
|
365
365
|
authenticationTemplate: z.string().optional().describe(
|
|
366
366
|
"Optional JSON string authentication template to bypass Notary lookup"
|
|
@@ -1030,7 +1030,7 @@ z.object({
|
|
|
1030
1030
|
previous: z.string().nullable().optional(),
|
|
1031
1031
|
results: z.array(AuthenticationSchema)
|
|
1032
1032
|
});
|
|
1033
|
-
|
|
1033
|
+
z.object({
|
|
1034
1034
|
id: z.number(),
|
|
1035
1035
|
code: z.string(),
|
|
1036
1036
|
user_id: z.number(),
|
|
@@ -1247,7 +1247,7 @@ z.object({
|
|
|
1247
1247
|
selected_api: z.string().optional().describe(
|
|
1248
1248
|
"Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
|
|
1249
1249
|
),
|
|
1250
|
-
authentication_id: z.number().optional().describe(
|
|
1250
|
+
authentication_id: z.coerce.number().optional().describe(
|
|
1251
1251
|
"If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
|
|
1252
1252
|
),
|
|
1253
1253
|
params: z.record(z.string(), z.unknown()).optional().describe(
|
|
@@ -1436,12 +1436,18 @@ function normalizeAuthenticationItem(auth, options = {}) {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
const {
|
|
1438
1438
|
selected_api: selectedApi,
|
|
1439
|
-
customuser_id:
|
|
1439
|
+
customuser_id: profileId,
|
|
1440
|
+
id,
|
|
1441
|
+
account_id: accountId,
|
|
1440
1442
|
...restOfAuth
|
|
1441
1443
|
} = auth;
|
|
1442
1444
|
return {
|
|
1443
1445
|
...restOfAuth,
|
|
1444
1446
|
// Pass through all other API response fields except selected_api
|
|
1447
|
+
id: String(id),
|
|
1448
|
+
// Convert to string
|
|
1449
|
+
account_id: String(accountId),
|
|
1450
|
+
// Convert to string
|
|
1445
1451
|
implementation_id: selectedApi,
|
|
1446
1452
|
// Rename selected_api to implementation_id
|
|
1447
1453
|
title: auth.title || auth.label || void 0,
|
|
@@ -1454,8 +1460,8 @@ function normalizeAuthenticationItem(auth, options = {}) {
|
|
|
1454
1460
|
// App key from implementations endpoint or parsed from selected_api
|
|
1455
1461
|
app_version: appVersion,
|
|
1456
1462
|
// Version from selected_api or provided
|
|
1457
|
-
|
|
1458
|
-
// Map customuser_id to
|
|
1463
|
+
profile_id: profileId != null ? String(profileId) : void 0
|
|
1464
|
+
// Map customuser_id to profile_id, convert to string
|
|
1459
1465
|
};
|
|
1460
1466
|
}
|
|
1461
1467
|
function normalizeActionItem(action) {
|
|
@@ -1976,6 +1982,20 @@ var RootFieldItemSchema = z.union([
|
|
|
1976
1982
|
FieldsetItemSchema
|
|
1977
1983
|
]);
|
|
1978
1984
|
|
|
1985
|
+
// src/utils/id-utils.ts
|
|
1986
|
+
function coerceToNumericId(fieldName, value) {
|
|
1987
|
+
if (value === "") {
|
|
1988
|
+
throw new ZapierValidationError(`The ${fieldName} cannot be empty`);
|
|
1989
|
+
}
|
|
1990
|
+
const numericValue = typeof value === "number" ? value : Number(value);
|
|
1991
|
+
if (!Number.isFinite(numericValue)) {
|
|
1992
|
+
throw new ZapierValidationError(
|
|
1993
|
+
`The ${fieldName} "${value}" could not be converted to a number`
|
|
1994
|
+
);
|
|
1995
|
+
}
|
|
1996
|
+
return numericValue;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1979
1999
|
// src/services/implementations.ts
|
|
1980
2000
|
async function fetchImplementationNeeds({
|
|
1981
2001
|
api,
|
|
@@ -1992,7 +2012,10 @@ async function fetchImplementationNeeds({
|
|
|
1992
2012
|
params: inputs || {}
|
|
1993
2013
|
};
|
|
1994
2014
|
if (authenticationId !== null) {
|
|
1995
|
-
request.authentication_id =
|
|
2015
|
+
request.authentication_id = coerceToNumericId(
|
|
2016
|
+
"authentication_id",
|
|
2017
|
+
authenticationId
|
|
2018
|
+
);
|
|
1996
2019
|
}
|
|
1997
2020
|
const response = await api.post(
|
|
1998
2021
|
"/zapier/api/v4/implementations/needs/",
|
|
@@ -2020,7 +2043,10 @@ async function fetchImplementationChoices({
|
|
|
2020
2043
|
params: inputs || {}
|
|
2021
2044
|
};
|
|
2022
2045
|
if (authenticationId !== null) {
|
|
2023
|
-
request.authentication_id =
|
|
2046
|
+
request.authentication_id = coerceToNumericId(
|
|
2047
|
+
"authentication_id",
|
|
2048
|
+
authenticationId
|
|
2049
|
+
);
|
|
2024
2050
|
}
|
|
2025
2051
|
const response = await api.post(
|
|
2026
2052
|
"/zapier/api/v4/implementations/choices/",
|
|
@@ -2217,6 +2243,10 @@ var ListAuthenticationsSchema = z.object({
|
|
|
2217
2243
|
var AuthenticationItemSchema = withFormatter(
|
|
2218
2244
|
AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
|
|
2219
2245
|
{
|
|
2246
|
+
id: z.string(),
|
|
2247
|
+
// Converted from number
|
|
2248
|
+
account_id: z.string(),
|
|
2249
|
+
// Converted from number
|
|
2220
2250
|
implementation_id: z.string().optional(),
|
|
2221
2251
|
// Renamed from selected_api
|
|
2222
2252
|
is_expired: z.string().optional(),
|
|
@@ -2227,7 +2257,8 @@ var AuthenticationItemSchema = withFormatter(
|
|
|
2227
2257
|
// App key from implementations endpoint
|
|
2228
2258
|
app_version: z.string().optional(),
|
|
2229
2259
|
// Version extracted from implementation_id
|
|
2230
|
-
|
|
2260
|
+
profile_id: z.string().optional()
|
|
2261
|
+
// Mapped from customuser_id, converted from number
|
|
2231
2262
|
}
|
|
2232
2263
|
),
|
|
2233
2264
|
{
|
|
@@ -2476,9 +2507,12 @@ var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
|
|
|
2476
2507
|
selected_api: true,
|
|
2477
2508
|
customuser_id: true
|
|
2478
2509
|
}).extend({
|
|
2510
|
+
// Override numeric IDs with string versions (converted by normalizeAuthenticationItem)
|
|
2511
|
+
id: z.string(),
|
|
2512
|
+
account_id: z.string(),
|
|
2479
2513
|
// Renamed fields
|
|
2480
2514
|
implementation_id: z.string().optional(),
|
|
2481
|
-
|
|
2515
|
+
profile_id: z.string().optional(),
|
|
2482
2516
|
// Mapped fields (originals preserved in ...restOfAuth)
|
|
2483
2517
|
is_expired: z.string().optional(),
|
|
2484
2518
|
expired_at: z.string().nullable().optional(),
|
|
@@ -2487,7 +2521,7 @@ var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
|
|
|
2487
2521
|
app_version: z.string().optional()
|
|
2488
2522
|
});
|
|
2489
2523
|
var GetAuthenticationOptionsSchema = z.object({
|
|
2490
|
-
authenticationId: z.number().int().positive().describe("Authentication ID to retrieve")
|
|
2524
|
+
authenticationId: z.union([z.string(), z.number().int().positive()]).describe("Authentication ID to retrieve")
|
|
2491
2525
|
}).describe("Get a specific authentication by ID");
|
|
2492
2526
|
var GetAuthenticationHandlerRequestSchema = z.object({
|
|
2493
2527
|
authenticationId: z.union([z.string(), z.number()]).describe("Authentication ID - string from searchParams or number")
|
|
@@ -2503,7 +2537,7 @@ var getAuthenticationPlugin = ({ context }) => {
|
|
|
2503
2537
|
async function getAuthentication(options) {
|
|
2504
2538
|
const { api } = context;
|
|
2505
2539
|
return await api.get(
|
|
2506
|
-
`/api/v0/authentications/${options.authenticationId}`
|
|
2540
|
+
`/api/v0/authentications/${encodeURIComponent(options.authenticationId)}`
|
|
2507
2541
|
);
|
|
2508
2542
|
}
|
|
2509
2543
|
const getAuthenticationDefinition = createFunction(
|
|
@@ -2777,7 +2811,7 @@ var RelayRequestSchema = z.object({
|
|
|
2777
2811
|
url: z.string().url().describe("The URL to request (will be proxied through Relay)"),
|
|
2778
2812
|
method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method"),
|
|
2779
2813
|
body: z.any().optional().describe("Request body as a string"),
|
|
2780
|
-
authenticationId:
|
|
2814
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
2781
2815
|
callbackUrl: z.string().url().optional().describe("URL to send async response to (makes request async)"),
|
|
2782
2816
|
authenticationTemplate: z.string().optional().describe(
|
|
2783
2817
|
"Optional JSON string authentication template to bypass Notary lookup"
|
|
@@ -2829,7 +2863,10 @@ var requestPlugin = ({ context }) => {
|
|
|
2829
2863
|
}
|
|
2830
2864
|
}
|
|
2831
2865
|
if (authenticationId) {
|
|
2832
|
-
headers["X-Relay-Authentication-Id"] =
|
|
2866
|
+
headers["X-Relay-Authentication-Id"] = coerceToNumericId(
|
|
2867
|
+
"authenticationId",
|
|
2868
|
+
authenticationId
|
|
2869
|
+
).toString();
|
|
2833
2870
|
}
|
|
2834
2871
|
if (callbackUrl) {
|
|
2835
2872
|
headers["X-Relay-Callback-Url"] = callbackUrl;
|
|
@@ -2929,7 +2966,7 @@ var ActionEntrySchema = z.object({
|
|
|
2929
2966
|
appKey: z.string().describe("App key (slug or implementation name)"),
|
|
2930
2967
|
actionKey: z.string().describe("Action key identifier"),
|
|
2931
2968
|
actionType: z.string().describe("Action type (e.g., 'read', 'write', 'search')"),
|
|
2932
|
-
authenticationId:
|
|
2969
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
2933
2970
|
inputs: z.record(z.string(), z.unknown()).optional().describe("Resolved input values"),
|
|
2934
2971
|
schema: z.record(z.string(), z.unknown()).describe(
|
|
2935
2972
|
"Complete JSON Schema from getInputFieldsSchema (includes $schema, type, properties, required, etc.)"
|
|
@@ -3315,20 +3352,18 @@ var manifestPlugin = (params) => {
|
|
|
3315
3352
|
};
|
|
3316
3353
|
var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
|
|
3317
3354
|
var UserProfileItemSchema = withFormatter(
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3355
|
+
z.object({
|
|
3356
|
+
id: z.string(),
|
|
3357
|
+
first_name: z.string(),
|
|
3358
|
+
last_name: z.string(),
|
|
3359
|
+
full_name: z.string(),
|
|
3360
|
+
email: z.string(),
|
|
3361
|
+
email_confirmed: z.boolean(),
|
|
3362
|
+
timezone: z.string()
|
|
3321
3363
|
}),
|
|
3322
3364
|
{
|
|
3323
3365
|
format: (item) => {
|
|
3324
3366
|
const details = [];
|
|
3325
|
-
if (item == null || typeof item !== "object" || !("full_name" in item) || !("username" in item)) {
|
|
3326
|
-
return {
|
|
3327
|
-
title: "User Profile",
|
|
3328
|
-
subtitle: "Malformatted result item",
|
|
3329
|
-
details: []
|
|
3330
|
-
};
|
|
3331
|
-
}
|
|
3332
3367
|
if ("email" in item) {
|
|
3333
3368
|
details.push({ text: item.email, style: "dim" });
|
|
3334
3369
|
}
|
|
@@ -3338,15 +3373,9 @@ var UserProfileItemSchema = withFormatter(
|
|
|
3338
3373
|
style: "accent"
|
|
3339
3374
|
});
|
|
3340
3375
|
}
|
|
3341
|
-
if ("since_signup" in item && item.since_signup) {
|
|
3342
|
-
details.push({
|
|
3343
|
-
text: `Member since: ${item.since_signup}`,
|
|
3344
|
-
style: "dim"
|
|
3345
|
-
});
|
|
3346
|
-
}
|
|
3347
3376
|
return {
|
|
3348
3377
|
title: item.full_name,
|
|
3349
|
-
id: item.id
|
|
3378
|
+
id: item.id,
|
|
3350
3379
|
details
|
|
3351
3380
|
};
|
|
3352
3381
|
}
|
|
@@ -3362,13 +3391,15 @@ var getProfilePlugin = ({ context }) => {
|
|
|
3362
3391
|
authRequired: true
|
|
3363
3392
|
}
|
|
3364
3393
|
);
|
|
3365
|
-
const { user_id: _unusedUserId, ...data } = profile;
|
|
3366
3394
|
return {
|
|
3367
3395
|
data: {
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3396
|
+
id: String(profile.id),
|
|
3397
|
+
first_name: profile.first_name,
|
|
3398
|
+
last_name: profile.last_name,
|
|
3399
|
+
full_name: `${profile.first_name} ${profile.last_name}`,
|
|
3400
|
+
email: profile.email,
|
|
3401
|
+
email_confirmed: profile.email_confirmed,
|
|
3402
|
+
timezone: profile.timezone
|
|
3372
3403
|
}
|
|
3373
3404
|
};
|
|
3374
3405
|
}
|
|
@@ -3839,12 +3870,18 @@ function normalizeAuthenticationItem2(auth, options = {}) {
|
|
|
3839
3870
|
}
|
|
3840
3871
|
const {
|
|
3841
3872
|
selected_api: selectedApi,
|
|
3842
|
-
customuser_id:
|
|
3873
|
+
customuser_id: profileId,
|
|
3874
|
+
id,
|
|
3875
|
+
account_id: accountId,
|
|
3843
3876
|
...restOfAuth
|
|
3844
3877
|
} = auth;
|
|
3845
3878
|
return {
|
|
3846
3879
|
...restOfAuth,
|
|
3847
3880
|
// Pass through all other API response fields except selected_api
|
|
3881
|
+
id: String(id),
|
|
3882
|
+
// Convert to string
|
|
3883
|
+
account_id: String(accountId),
|
|
3884
|
+
// Convert to string
|
|
3848
3885
|
implementation_id: selectedApi,
|
|
3849
3886
|
// Rename selected_api to implementation_id
|
|
3850
3887
|
title: auth.title || auth.label || void 0,
|
|
@@ -3857,8 +3894,8 @@ function normalizeAuthenticationItem2(auth, options = {}) {
|
|
|
3857
3894
|
// App key from implementations endpoint or parsed from selected_api
|
|
3858
3895
|
app_version: appVersion,
|
|
3859
3896
|
// Version from selected_api or provided
|
|
3860
|
-
|
|
3861
|
-
// Map customuser_id to
|
|
3897
|
+
profile_id: profileId != null ? String(profileId) : void 0
|
|
3898
|
+
// Map customuser_id to profile_id, convert to string
|
|
3862
3899
|
};
|
|
3863
3900
|
}
|
|
3864
3901
|
|
|
@@ -5010,7 +5047,7 @@ function getCpuTime() {
|
|
|
5010
5047
|
|
|
5011
5048
|
// package.json
|
|
5012
5049
|
var package_default = {
|
|
5013
|
-
version: "0.
|
|
5050
|
+
version: "0.18.0"};
|
|
5014
5051
|
|
|
5015
5052
|
// src/plugins/eventEmission/builders.ts
|
|
5016
5053
|
function createBaseEvent(context = {}) {
|
|
@@ -6,7 +6,7 @@ function createActionFunction(appKey, actionType, actionKey, options, pinnedAuth
|
|
|
6
6
|
const { sdk } = options;
|
|
7
7
|
const { inputs, authenticationId: providedAuthenticationId } = actionOptions;
|
|
8
8
|
// Use pinned auth ID first, then provided auth ID
|
|
9
|
-
const authenticationId = pinnedAuthId
|
|
9
|
+
const authenticationId = pinnedAuthId ?? providedAuthenticationId;
|
|
10
10
|
if (!authenticationId) {
|
|
11
11
|
throw new ZapierValidationError(`Authentication ID is required. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }) or provide authenticationId in the action call.`);
|
|
12
12
|
}
|
|
@@ -26,7 +26,7 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
|
26
26
|
return async (url, init) => {
|
|
27
27
|
const { sdk } = options;
|
|
28
28
|
// Use pinned auth ID first, then provided auth ID
|
|
29
|
-
const authenticationId = pinnedAuthId
|
|
29
|
+
const authenticationId = pinnedAuthId ?? init?.authenticationId;
|
|
30
30
|
if (!authenticationId) {
|
|
31
31
|
throw new ZapierValidationError(`Authentication ID is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }).fetch(...) or provide authenticationId in the fetch call.`);
|
|
32
32
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type AuthenticationIdProperty } from "../../types/properties";
|
|
2
3
|
export declare const ActionExecutionInputSchema: z.ZodObject<{
|
|
3
4
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
4
|
-
authenticationId: z.ZodOptional<z.ZodNumber
|
|
5
|
+
authenticationId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
5
6
|
}, z.core.$strip>;
|
|
6
7
|
export type ActionExecutionOptions = z.infer<typeof ActionExecutionInputSchema>;
|
|
7
8
|
export declare const AppFactoryInputSchema: z.ZodObject<{
|
|
8
|
-
authenticationId: z.ZodNumber
|
|
9
|
+
authenticationId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
9
10
|
}, z.core.$strip>;
|
|
10
11
|
export type AppFactoryInput = z.infer<typeof AppFactoryInputSchema>;
|
|
11
12
|
interface BaseActionTypeProxy {
|
|
@@ -21,7 +22,7 @@ interface BaseActionTypeProxy {
|
|
|
21
22
|
}
|
|
22
23
|
interface FetchActionType {
|
|
23
24
|
fetch: (url: string | URL, init?: RequestInit & {
|
|
24
|
-
authenticationId?:
|
|
25
|
+
authenticationId?: AuthenticationIdProperty;
|
|
25
26
|
callbackUrl?: string;
|
|
26
27
|
authenticationTemplate?: string;
|
|
27
28
|
}) => Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,0BAA0B;;;iBAOpC,CAAC;AAGJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEhF,eAAO,MAAM,qBAAqB;;iBAIgB,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGpE,UAAU,mBAAmB;IAC3B,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC9D,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACpD,KAAK,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;KAC7B,CAAC;CACL;AAGD,UAAU,eAAe;IACvB,KAAK,EAAE,CACL,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,GAAG;QACnB,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;QAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,KACE,OAAO,CAAC,QAAQ,CAAC,CAAC;CACxB;AAGD,KAAK,eAAe,GAAG,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAEtE,UAAU,QAAQ;IAChB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;CACjC;AAED,UAAU,UAAU;IAClB,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC;CACtC;AAGD,KAAK,mBAAmB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACpC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { AuthenticationIdPropertySchema, } from "../../types/properties";
|
|
2
3
|
export const ActionExecutionInputSchema = z
|
|
3
4
|
.object({
|
|
4
5
|
inputs: z.record(z.string(), z.unknown()).optional(),
|
|
5
|
-
authenticationId:
|
|
6
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
6
7
|
})
|
|
7
8
|
.describe("Execute an action with the given inputs for the bound app, as an alternative to runAction");
|
|
8
9
|
export const AppFactoryInputSchema = z
|
|
9
10
|
.object({
|
|
10
|
-
authenticationId:
|
|
11
|
+
authenticationId: AuthenticationIdPropertySchema,
|
|
11
12
|
})
|
|
12
13
|
.describe("Bind an authentication ID to an app");
|
|
13
14
|
// Note: AppsPluginSdkExtension removed - now using AppsPluginProvides in index.ts
|
|
@@ -4,7 +4,7 @@ import type { z } from "zod";
|
|
|
4
4
|
import type { EventEmissionContext } from "../eventEmission";
|
|
5
5
|
export interface FetchPluginProvides {
|
|
6
6
|
fetch: (url: string | URL, init?: RequestInit & {
|
|
7
|
-
authenticationId?: number;
|
|
7
|
+
authenticationId?: string | number;
|
|
8
8
|
callbackUrl?: string;
|
|
9
9
|
authenticationTemplate?: string;
|
|
10
10
|
}) => Promise<Response>;
|
|
@@ -29,7 +29,7 @@ export declare const fetchPlugin: Plugin<GetSdkType<RequestPluginProvides>, // r
|
|
|
29
29
|
EventEmissionContext, // requires eventEmission context for telemetry
|
|
30
30
|
FetchPluginProvides>;
|
|
31
31
|
export type ZapierFetchInitOptions = RequestInit & {
|
|
32
|
-
authenticationId?: number;
|
|
32
|
+
authenticationId?: string | number;
|
|
33
33
|
callbackUrl?: string;
|
|
34
34
|
authenticationTemplate?: string;
|
|
35
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,CACL,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,GAAG;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,CACL,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,GAAG;QACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACnC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,KACE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvB,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,KAAK,EAAE;gBACL,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACnB,UAAU,EAAE,MAAM,EAAE,CAAC;gBACrB,UAAU,EAAE,MAAM,CAAC;gBACnB,eAAe,EAAE,KAAK,CAAC;oBAAE,IAAI,EAAE,MAAM,CAAC;oBAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAA;iBAAE,CAAC,CAAC;aAC/D,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAC9B,UAAU,CAAC,qBAAqB,CAAC,EAAE,0BAA0B;AAC7D,oBAAoB,EAAE,+CAA+C;AACrE,mBAAmB,CA2EpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG;IACjD,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC"}
|
|
@@ -12,7 +12,7 @@ export declare const FetchInitSchema: z.ZodOptional<z.ZodObject<{
|
|
|
12
12
|
}>>;
|
|
13
13
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
14
14
|
body: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<FormData, FormData>, z.ZodCustom<URLSearchParams, URLSearchParams>]>>;
|
|
15
|
-
authenticationId: z.ZodOptional<z.ZodNumber
|
|
15
|
+
authenticationId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
16
16
|
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
17
17
|
authenticationTemplate: z.ZodOptional<z.ZodString>;
|
|
18
18
|
}, z.core.$strip>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,cAAc,2DAEI,CAAC;AAEhC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;kBA0ByB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { AuthenticationIdPropertySchema } from "../../types/properties";
|
|
2
3
|
// Schemas for fetch function parameters
|
|
3
4
|
export const FetchUrlSchema = z
|
|
4
5
|
.union([z.string(), z.instanceof(URL)])
|
|
@@ -16,10 +17,7 @@ export const FetchInitSchema = z
|
|
|
16
17
|
z.instanceof(URLSearchParams),
|
|
17
18
|
])
|
|
18
19
|
.optional(),
|
|
19
|
-
authenticationId:
|
|
20
|
-
.number()
|
|
21
|
-
.optional()
|
|
22
|
-
.describe("Zapier authentication ID to use for the request"),
|
|
20
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
23
21
|
callbackUrl: z
|
|
24
22
|
.string()
|
|
25
23
|
.optional()
|
|
@@ -6,10 +6,10 @@ import { ListAuthenticationsSchema } from "../listAuthentications/schemas";
|
|
|
6
6
|
import { eventEmissionPlugin } from "../eventEmission";
|
|
7
7
|
const mockAuthentications = [
|
|
8
8
|
{
|
|
9
|
-
id: 123,
|
|
9
|
+
id: "123",
|
|
10
10
|
title: "My Slack",
|
|
11
11
|
date: "2021-01-01",
|
|
12
|
-
account_id: 123,
|
|
12
|
+
account_id: "123",
|
|
13
13
|
implementation_id: "api_123",
|
|
14
14
|
is_expired: "false",
|
|
15
15
|
expired_at: null,
|
|
@@ -18,12 +18,12 @@ const mockAuthentications = [
|
|
|
18
18
|
shared_with_all: false,
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
id: 456,
|
|
21
|
+
id: "456",
|
|
22
22
|
title: "Slack Workspace 2",
|
|
23
23
|
is_expired: "false",
|
|
24
24
|
expired_at: null,
|
|
25
25
|
date: "2021-01-01",
|
|
26
|
-
account_id: 123,
|
|
26
|
+
account_id: "123",
|
|
27
27
|
implementation_id: "api_123",
|
|
28
28
|
is_invite_only: false,
|
|
29
29
|
is_private: false,
|
|
@@ -5,10 +5,10 @@ import { createSdk } from "../../sdk";
|
|
|
5
5
|
import { ListAuthenticationsSchema } from "../listAuthentications/schemas";
|
|
6
6
|
import { eventEmissionPlugin } from "../eventEmission";
|
|
7
7
|
const mockAuthentication = {
|
|
8
|
-
id: 123,
|
|
8
|
+
id: "123",
|
|
9
9
|
title: "My Slack",
|
|
10
10
|
date: "2021-01-01",
|
|
11
|
-
account_id: 123,
|
|
11
|
+
account_id: "123",
|
|
12
12
|
implementation_id: "api_123",
|
|
13
13
|
is_expired: "false",
|
|
14
14
|
expired_at: null,
|
|
@@ -19,12 +19,12 @@ const mockAuthentication = {
|
|
|
19
19
|
const mockAuthentications = [
|
|
20
20
|
mockAuthentication,
|
|
21
21
|
{
|
|
22
|
-
id: 456,
|
|
22
|
+
id: "456",
|
|
23
23
|
title: "Slack Workspace 2",
|
|
24
24
|
is_expired: "false",
|
|
25
25
|
expired_at: null,
|
|
26
26
|
date: "2021-01-01",
|
|
27
|
-
account_id: 123,
|
|
27
|
+
account_id: "123",
|
|
28
28
|
implementation_id: "api_123",
|
|
29
29
|
is_invite_only: false,
|
|
30
30
|
is_private: false,
|
|
@@ -8,7 +8,7 @@ export const getAuthenticationPlugin = ({ context }) => {
|
|
|
8
8
|
const { api } = context;
|
|
9
9
|
// Call the SDK API endpoint, which will be routed to the handler via handlerOverride in pathConfig.
|
|
10
10
|
// When the handler is migrated to SDK API, this same API call will go over the network.
|
|
11
|
-
return await api.get(`/api/v0/authentications/${options.authenticationId}`);
|
|
11
|
+
return await api.get(`/api/v0/authentications/${encodeURIComponent(options.authenticationId)}`);
|
|
12
12
|
}
|
|
13
13
|
const getAuthenticationDefinition = createFunction(getAuthentication, GetAuthenticationSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getAuthentication.name));
|
|
14
14
|
return {
|
|
@@ -4,9 +4,9 @@ import { getAuthenticationPlugin } from "./index";
|
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
5
|
import { eventEmissionPlugin } from "../eventEmission";
|
|
6
6
|
const mockAuthenticationItem = {
|
|
7
|
-
id: 123,
|
|
7
|
+
id: "123",
|
|
8
8
|
date: "2021-01-01",
|
|
9
|
-
account_id: 456,
|
|
9
|
+
account_id: "456",
|
|
10
10
|
implementation_id: "SlackCLIAPI@1.21.1",
|
|
11
11
|
is_invite_only: false,
|
|
12
12
|
is_private: false,
|
|
@@ -50,7 +50,7 @@ describe("getAuthentication plugin", () => {
|
|
|
50
50
|
it("should throw validation error for invalid authenticationId type", async () => {
|
|
51
51
|
const sdk = createTestSdk();
|
|
52
52
|
await expect(sdk.getAuthentication({
|
|
53
|
-
authenticationId:
|
|
53
|
+
authenticationId: true,
|
|
54
54
|
})).rejects.toThrow(ZapierValidationError);
|
|
55
55
|
});
|
|
56
56
|
it("should throw validation error for negative authenticationId", async () => {
|
|
@@ -71,7 +71,7 @@ describe("getAuthentication plugin", () => {
|
|
|
71
71
|
authenticationId: 123,
|
|
72
72
|
});
|
|
73
73
|
expect(result.data).toBeDefined();
|
|
74
|
-
expect(result.data.id).toBe(123);
|
|
74
|
+
expect(result.data.id).toBe("123");
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
describe("SDK API endpoint routing", () => {
|
|
@@ -80,6 +80,11 @@ describe("getAuthentication plugin", () => {
|
|
|
80
80
|
await sdk.getAuthentication({ authenticationId: 123 });
|
|
81
81
|
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications/123");
|
|
82
82
|
});
|
|
83
|
+
it("should URI encode string authenticationId in path", async () => {
|
|
84
|
+
const sdk = createTestSdk();
|
|
85
|
+
await sdk.getAuthentication({ authenticationId: "auth/with spaces" });
|
|
86
|
+
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications/auth%2Fwith%20spaces");
|
|
87
|
+
});
|
|
83
88
|
it("should return data from API response", async () => {
|
|
84
89
|
const sdk = createTestSdk();
|
|
85
90
|
const result = await sdk.getAuthentication({ authenticationId: 123 });
|
|
@@ -15,7 +15,7 @@ export declare const GetInputFieldsSchemaSchema: z.ZodObject<{
|
|
|
15
15
|
write: "write";
|
|
16
16
|
}>;
|
|
17
17
|
actionKey: z.ZodString;
|
|
18
|
-
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodNumber
|
|
18
|
+
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
19
19
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
20
|
}, z.core.$strip>;
|
|
21
21
|
export type GetInputFieldsSchemaOptions = z.infer<typeof GetInputFieldsSchemaSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,4CAA4C;AACvF,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,4CAA4C;AACvF,wBAAwB,CA+CzB,CAAC"}
|
|
@@ -8,12 +8,15 @@ export const getProfilePlugin = ({ context }) => {
|
|
|
8
8
|
const profile = await context.api.get("/zapier/api/v4/profile/", {
|
|
9
9
|
authRequired: true,
|
|
10
10
|
});
|
|
11
|
-
// Remove user_id since that's our internal user ID which could confuse things!
|
|
12
|
-
const { user_id: _unusedUserId, ...data } = profile;
|
|
13
11
|
return {
|
|
14
12
|
data: {
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
id: String(profile.id),
|
|
14
|
+
first_name: profile.first_name,
|
|
15
|
+
last_name: profile.last_name,
|
|
16
|
+
full_name: `${profile.first_name} ${profile.last_name}`,
|
|
17
|
+
email: profile.email,
|
|
18
|
+
email_confirmed: profile.email_confirmed,
|
|
19
|
+
timezone: profile.timezone,
|
|
17
20
|
},
|
|
18
21
|
};
|
|
19
22
|
}
|
|
@@ -107,7 +107,7 @@ describe("listAuthentications plugin", () => {
|
|
|
107
107
|
const result = await sdk.listAuthentications();
|
|
108
108
|
expect(result.data).toHaveLength(2);
|
|
109
109
|
expect(result.data[0]).toMatchObject({
|
|
110
|
-
id: 123,
|
|
110
|
+
id: "123",
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
it("should throw validation error for invalid appKey type", () => {
|
|
@@ -403,8 +403,8 @@ describe("listAuthentications plugin", () => {
|
|
|
403
403
|
expect(pages).toHaveLength(2);
|
|
404
404
|
expect(pages[0].data).toHaveLength(1);
|
|
405
405
|
expect(pages[1].data).toHaveLength(1);
|
|
406
|
-
expect(pages[0].data[0].id).toBe(123);
|
|
407
|
-
expect(pages[1].data[0].id).toBe(789);
|
|
406
|
+
expect(pages[0].data[0].id).toBe("123");
|
|
407
|
+
expect(pages[1].data[0].id).toBe("789");
|
|
408
408
|
});
|
|
409
409
|
it("should support async iteration over individual items", async () => {
|
|
410
410
|
const sdk = createTestSdk();
|
|
@@ -415,8 +415,8 @@ describe("listAuthentications plugin", () => {
|
|
|
415
415
|
items.push(item);
|
|
416
416
|
}
|
|
417
417
|
expect(items).toHaveLength(2);
|
|
418
|
-
expect(items[0].id).toBe(123);
|
|
419
|
-
expect(items[1].id).toBe(789);
|
|
418
|
+
expect(items[0].id).toBe("123");
|
|
419
|
+
expect(items[1].id).toBe("789");
|
|
420
420
|
});
|
|
421
421
|
it("should set appropriate pageSize for API calls", async () => {
|
|
422
422
|
const sdk = createTestSdk();
|
|
@@ -577,12 +577,12 @@ describe("listAuthentications plugin", () => {
|
|
|
577
577
|
const sdk = createTestSdk();
|
|
578
578
|
const result = await sdk.listAuthentications({});
|
|
579
579
|
const auth = result.data[0];
|
|
580
|
-
// Verify original fields are preserved
|
|
581
|
-
expect(auth.id).toBe(123);
|
|
580
|
+
// Verify original fields are preserved (IDs are converted to strings)
|
|
581
|
+
expect(auth.id).toBe("123");
|
|
582
582
|
expect(auth.date).toBe("2021-01-01");
|
|
583
583
|
expect(auth.lastchanged).toBe("2021-01-02");
|
|
584
|
-
expect(auth.account_id).toBe(456);
|
|
585
|
-
expect(auth.
|
|
584
|
+
expect(auth.account_id).toBe("456");
|
|
585
|
+
expect(auth.profile_id).toBe("789");
|
|
586
586
|
expect(auth.implementation_id).toBe("SlackCLIAPI@1.21.1");
|
|
587
587
|
expect(auth.destination_selected_api).toBe("SlackDestAPI@1.0.0");
|
|
588
588
|
expect(auth.is_invite_only).toBe(true);
|