@zapier/zapier-sdk 0.17.0 → 0.18.1
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 +132 -93
- package/dist/index.d.mts +58 -100
- package/dist/index.mjs +132 -93
- 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/eventEmission/transport.d.ts +8 -18
- package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
- package/dist/plugins/eventEmission/transport.js +47 -44
- package/dist/plugins/eventEmission/transport.test.js +36 -25
- 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 +6 -6
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts +7 -7
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/schemas/authentications/index.js +5 -4
- 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(
|
|
@@ -1437,11 +1437,17 @@ function normalizeAuthenticationItem(auth, options = {}) {
|
|
|
1437
1437
|
const {
|
|
1438
1438
|
selected_api: selectedApi,
|
|
1439
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
|
-
profile_id: profileId
|
|
1458
|
-
// Map customuser_id to profile_id
|
|
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,8 +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
|
-
profile_id: z.
|
|
2231
|
-
// Mapped from customuser_id
|
|
2260
|
+
profile_id: z.string().optional()
|
|
2261
|
+
// Mapped from customuser_id, converted from number
|
|
2232
2262
|
}
|
|
2233
2263
|
),
|
|
2234
2264
|
{
|
|
@@ -2477,9 +2507,12 @@ var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
|
|
|
2477
2507
|
selected_api: true,
|
|
2478
2508
|
customuser_id: true
|
|
2479
2509
|
}).extend({
|
|
2510
|
+
// Override numeric IDs with string versions (converted by normalizeAuthenticationItem)
|
|
2511
|
+
id: z.string(),
|
|
2512
|
+
account_id: z.string(),
|
|
2480
2513
|
// Renamed fields
|
|
2481
2514
|
implementation_id: z.string().optional(),
|
|
2482
|
-
profile_id: z.
|
|
2515
|
+
profile_id: z.string().optional(),
|
|
2483
2516
|
// Mapped fields (originals preserved in ...restOfAuth)
|
|
2484
2517
|
is_expired: z.string().optional(),
|
|
2485
2518
|
expired_at: z.string().nullable().optional(),
|
|
@@ -2488,7 +2521,7 @@ var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
|
|
|
2488
2521
|
app_version: z.string().optional()
|
|
2489
2522
|
});
|
|
2490
2523
|
var GetAuthenticationOptionsSchema = z.object({
|
|
2491
|
-
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")
|
|
2492
2525
|
}).describe("Get a specific authentication by ID");
|
|
2493
2526
|
var GetAuthenticationHandlerRequestSchema = z.object({
|
|
2494
2527
|
authenticationId: z.union([z.string(), z.number()]).describe("Authentication ID - string from searchParams or number")
|
|
@@ -2504,7 +2537,7 @@ var getAuthenticationPlugin = ({ context }) => {
|
|
|
2504
2537
|
async function getAuthentication(options) {
|
|
2505
2538
|
const { api } = context;
|
|
2506
2539
|
return await api.get(
|
|
2507
|
-
`/api/v0/authentications/${options.authenticationId}`
|
|
2540
|
+
`/api/v0/authentications/${encodeURIComponent(options.authenticationId)}`
|
|
2508
2541
|
);
|
|
2509
2542
|
}
|
|
2510
2543
|
const getAuthenticationDefinition = createFunction(
|
|
@@ -2778,7 +2811,7 @@ var RelayRequestSchema = z.object({
|
|
|
2778
2811
|
url: z.string().url().describe("The URL to request (will be proxied through Relay)"),
|
|
2779
2812
|
method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method"),
|
|
2780
2813
|
body: z.any().optional().describe("Request body as a string"),
|
|
2781
|
-
authenticationId:
|
|
2814
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
2782
2815
|
callbackUrl: z.string().url().optional().describe("URL to send async response to (makes request async)"),
|
|
2783
2816
|
authenticationTemplate: z.string().optional().describe(
|
|
2784
2817
|
"Optional JSON string authentication template to bypass Notary lookup"
|
|
@@ -2830,7 +2863,10 @@ var requestPlugin = ({ context }) => {
|
|
|
2830
2863
|
}
|
|
2831
2864
|
}
|
|
2832
2865
|
if (authenticationId) {
|
|
2833
|
-
headers["X-Relay-Authentication-Id"] =
|
|
2866
|
+
headers["X-Relay-Authentication-Id"] = coerceToNumericId(
|
|
2867
|
+
"authenticationId",
|
|
2868
|
+
authenticationId
|
|
2869
|
+
).toString();
|
|
2834
2870
|
}
|
|
2835
2871
|
if (callbackUrl) {
|
|
2836
2872
|
headers["X-Relay-Callback-Url"] = callbackUrl;
|
|
@@ -2930,7 +2966,7 @@ var ActionEntrySchema = z.object({
|
|
|
2930
2966
|
appKey: z.string().describe("App key (slug or implementation name)"),
|
|
2931
2967
|
actionKey: z.string().describe("Action key identifier"),
|
|
2932
2968
|
actionType: z.string().describe("Action type (e.g., 'read', 'write', 'search')"),
|
|
2933
|
-
authenticationId:
|
|
2969
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
2934
2970
|
inputs: z.record(z.string(), z.unknown()).optional().describe("Resolved input values"),
|
|
2935
2971
|
schema: z.record(z.string(), z.unknown()).describe(
|
|
2936
2972
|
"Complete JSON Schema from getInputFieldsSchema (includes $schema, type, properties, required, etc.)"
|
|
@@ -3316,20 +3352,18 @@ var manifestPlugin = (params) => {
|
|
|
3316
3352
|
};
|
|
3317
3353
|
var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
|
|
3318
3354
|
var UserProfileItemSchema = withFormatter(
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
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()
|
|
3322
3363
|
}),
|
|
3323
3364
|
{
|
|
3324
3365
|
format: (item) => {
|
|
3325
3366
|
const details = [];
|
|
3326
|
-
if (item == null || typeof item !== "object" || !("full_name" in item) || !("username" in item)) {
|
|
3327
|
-
return {
|
|
3328
|
-
title: "User Profile",
|
|
3329
|
-
subtitle: "Malformatted result item",
|
|
3330
|
-
details: []
|
|
3331
|
-
};
|
|
3332
|
-
}
|
|
3333
3367
|
if ("email" in item) {
|
|
3334
3368
|
details.push({ text: item.email, style: "dim" });
|
|
3335
3369
|
}
|
|
@@ -3339,15 +3373,9 @@ var UserProfileItemSchema = withFormatter(
|
|
|
3339
3373
|
style: "accent"
|
|
3340
3374
|
});
|
|
3341
3375
|
}
|
|
3342
|
-
if ("since_signup" in item && item.since_signup) {
|
|
3343
|
-
details.push({
|
|
3344
|
-
text: `Member since: ${item.since_signup}`,
|
|
3345
|
-
style: "dim"
|
|
3346
|
-
});
|
|
3347
|
-
}
|
|
3348
3376
|
return {
|
|
3349
3377
|
title: item.full_name,
|
|
3350
|
-
id: item.id
|
|
3378
|
+
id: item.id,
|
|
3351
3379
|
details
|
|
3352
3380
|
};
|
|
3353
3381
|
}
|
|
@@ -3363,13 +3391,15 @@ var getProfilePlugin = ({ context }) => {
|
|
|
3363
3391
|
authRequired: true
|
|
3364
3392
|
}
|
|
3365
3393
|
);
|
|
3366
|
-
const { user_id: _unusedUserId, ...data } = profile;
|
|
3367
3394
|
return {
|
|
3368
3395
|
data: {
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
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
|
|
3373
3403
|
}
|
|
3374
3404
|
};
|
|
3375
3405
|
}
|
|
@@ -3841,11 +3871,17 @@ function normalizeAuthenticationItem2(auth, options = {}) {
|
|
|
3841
3871
|
const {
|
|
3842
3872
|
selected_api: selectedApi,
|
|
3843
3873
|
customuser_id: profileId,
|
|
3874
|
+
id,
|
|
3875
|
+
account_id: accountId,
|
|
3844
3876
|
...restOfAuth
|
|
3845
3877
|
} = auth;
|
|
3846
3878
|
return {
|
|
3847
3879
|
...restOfAuth,
|
|
3848
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
|
|
3849
3885
|
implementation_id: selectedApi,
|
|
3850
3886
|
// Rename selected_api to implementation_id
|
|
3851
3887
|
title: auth.title || auth.label || void 0,
|
|
@@ -3858,8 +3894,8 @@ function normalizeAuthenticationItem2(auth, options = {}) {
|
|
|
3858
3894
|
// App key from implementations endpoint or parsed from selected_api
|
|
3859
3895
|
app_version: appVersion,
|
|
3860
3896
|
// Version from selected_api or provided
|
|
3861
|
-
profile_id: profileId
|
|
3862
|
-
// Map customuser_id to profile_id
|
|
3897
|
+
profile_id: profileId != null ? String(profileId) : void 0
|
|
3898
|
+
// Map customuser_id to profile_id, convert to string
|
|
3863
3899
|
};
|
|
3864
3900
|
}
|
|
3865
3901
|
|
|
@@ -4858,70 +4894,73 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
4858
4894
|
// src/plugins/eventEmission/transport.ts
|
|
4859
4895
|
var DEFAULT_RETRY_ATTEMPTS = 2;
|
|
4860
4896
|
var DEFAULT_RETRY_DELAY_MS = 300;
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
);
|
|
4872
|
-
} catch {
|
|
4873
|
-
}
|
|
4874
|
-
}
|
|
4875
|
-
async emitWithRetry(subject, event, attemptsLeft) {
|
|
4897
|
+
function createHttpTransport(config) {
|
|
4898
|
+
const delay = async (ms) => {
|
|
4899
|
+
return new Promise((resolve2) => {
|
|
4900
|
+
const timer = setTimeout(resolve2, ms);
|
|
4901
|
+
if (typeof timer.unref === "function") {
|
|
4902
|
+
timer.unref();
|
|
4903
|
+
}
|
|
4904
|
+
});
|
|
4905
|
+
};
|
|
4906
|
+
const emitWithRetry = async (subject, event, attemptsLeft) => {
|
|
4876
4907
|
try {
|
|
4877
4908
|
const payload = {
|
|
4878
4909
|
subject,
|
|
4879
4910
|
properties: event
|
|
4880
4911
|
};
|
|
4881
|
-
const response = await fetch(
|
|
4912
|
+
const response = await fetch(config.endpoint, {
|
|
4882
4913
|
method: "POST",
|
|
4883
4914
|
headers: {
|
|
4884
4915
|
"Content-Type": "application/json",
|
|
4885
|
-
...
|
|
4916
|
+
...config.headers
|
|
4886
4917
|
},
|
|
4887
4918
|
body: JSON.stringify(payload)
|
|
4888
4919
|
});
|
|
4889
4920
|
if (!response.ok && attemptsLeft > 1) {
|
|
4890
|
-
await
|
|
4891
|
-
return
|
|
4921
|
+
await delay(config.retryDelayMs || DEFAULT_RETRY_DELAY_MS);
|
|
4922
|
+
return emitWithRetry(subject, event, attemptsLeft - 1);
|
|
4892
4923
|
}
|
|
4893
4924
|
} catch (error) {
|
|
4894
4925
|
if (attemptsLeft > 1) {
|
|
4895
|
-
await
|
|
4896
|
-
return
|
|
4926
|
+
await delay(config.retryDelayMs || DEFAULT_RETRY_DELAY_MS);
|
|
4927
|
+
return emitWithRetry(subject, event, attemptsLeft - 1);
|
|
4897
4928
|
}
|
|
4898
4929
|
throw error;
|
|
4899
4930
|
}
|
|
4900
|
-
}
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4931
|
+
};
|
|
4932
|
+
return {
|
|
4933
|
+
async emit(subject, event) {
|
|
4934
|
+
try {
|
|
4935
|
+
await emitWithRetry(
|
|
4936
|
+
subject,
|
|
4937
|
+
event,
|
|
4938
|
+
config.retryAttempts || DEFAULT_RETRY_ATTEMPTS
|
|
4939
|
+
);
|
|
4940
|
+
} catch {
|
|
4906
4941
|
}
|
|
4907
|
-
});
|
|
4908
|
-
}
|
|
4909
|
-
};
|
|
4910
|
-
var ConsoleTransport = class {
|
|
4911
|
-
async emit(subject, event) {
|
|
4912
|
-
try {
|
|
4913
|
-
console.log(
|
|
4914
|
-
"[SDK Telemetry]",
|
|
4915
|
-
JSON.stringify({ subject, properties: event }, null, 2)
|
|
4916
|
-
);
|
|
4917
|
-
} catch {
|
|
4918
4942
|
}
|
|
4919
|
-
}
|
|
4920
|
-
}
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4943
|
+
};
|
|
4944
|
+
}
|
|
4945
|
+
function createConsoleTransport() {
|
|
4946
|
+
return {
|
|
4947
|
+
async emit(subject, event) {
|
|
4948
|
+
try {
|
|
4949
|
+
console.log(
|
|
4950
|
+
"[SDK Telemetry]",
|
|
4951
|
+
JSON.stringify({ subject, properties: event }, null, 2)
|
|
4952
|
+
);
|
|
4953
|
+
} catch {
|
|
4954
|
+
}
|
|
4955
|
+
}
|
|
4956
|
+
};
|
|
4957
|
+
}
|
|
4958
|
+
function createNoopTransport() {
|
|
4959
|
+
return {
|
|
4960
|
+
async emit(_subject, _event) {
|
|
4961
|
+
}
|
|
4962
|
+
};
|
|
4963
|
+
}
|
|
4925
4964
|
function createTransport(config) {
|
|
4926
4965
|
try {
|
|
4927
4966
|
switch (config.type) {
|
|
@@ -4929,20 +4968,20 @@ function createTransport(config) {
|
|
|
4929
4968
|
if (!config.endpoint) {
|
|
4930
4969
|
throw new Error("HTTP transport requires endpoint");
|
|
4931
4970
|
}
|
|
4932
|
-
return
|
|
4971
|
+
return createHttpTransport({
|
|
4933
4972
|
endpoint: config.endpoint,
|
|
4934
4973
|
headers: config.headers,
|
|
4935
4974
|
retryAttempts: config.retryAttempts,
|
|
4936
4975
|
retryDelayMs: config.retryDelayMs
|
|
4937
4976
|
});
|
|
4938
4977
|
case "console":
|
|
4939
|
-
return
|
|
4978
|
+
return createConsoleTransport();
|
|
4940
4979
|
case "noop":
|
|
4941
4980
|
default:
|
|
4942
|
-
return
|
|
4981
|
+
return createNoopTransport();
|
|
4943
4982
|
}
|
|
4944
4983
|
} catch {
|
|
4945
|
-
return
|
|
4984
|
+
return createNoopTransport();
|
|
4946
4985
|
}
|
|
4947
4986
|
}
|
|
4948
4987
|
function generateEventId() {
|
|
@@ -5011,7 +5050,7 @@ function getCpuTime() {
|
|
|
5011
5050
|
|
|
5012
5051
|
// package.json
|
|
5013
5052
|
var package_default = {
|
|
5014
|
-
version: "0.
|
|
5053
|
+
version: "0.18.1"};
|
|
5015
5054
|
|
|
5016
5055
|
// src/plugins/eventEmission/builders.ts
|
|
5017
5056
|
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
|
|
@@ -15,23 +15,13 @@ export interface TransportConfig {
|
|
|
15
15
|
retryAttempts?: number;
|
|
16
16
|
retryDelayMs?: number;
|
|
17
17
|
}
|
|
18
|
-
export declare
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
emit<T extends any>(subject: string, event: T): Promise<void>;
|
|
27
|
-
private emitWithRetry;
|
|
28
|
-
private delay;
|
|
29
|
-
}
|
|
30
|
-
export declare class ConsoleTransport implements EventTransport {
|
|
31
|
-
emit<T extends any>(subject: string, event: T): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
export declare class NoopTransport implements EventTransport {
|
|
34
|
-
emit<T extends any>(_subject: string, _event: T): Promise<void>;
|
|
35
|
-
}
|
|
18
|
+
export declare function createHttpTransport(config: {
|
|
19
|
+
endpoint: string;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
retryAttempts?: number;
|
|
22
|
+
retryDelayMs?: number;
|
|
23
|
+
}): EventTransport;
|
|
24
|
+
export declare function createConsoleTransport(): EventTransport;
|
|
25
|
+
export declare function createNoopTransport(): EventTransport;
|
|
36
26
|
export declare function createTransport(config: TransportConfig): EventTransport;
|
|
37
27
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,cAAc,CAwDjB;AAGD,wBAAgB,sBAAsB,IAAI,cAAc,CAavD;AAGD,wBAAgB,mBAAmB,IAAI,cAAc,CAMpD;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAyBvE"}
|