@zapier/zapier-sdk 0.15.3 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/api/auth.d.ts +10 -0
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +35 -0
- package/dist/api/schemas.d.ts +38 -38
- package/dist/index.cjs +112 -23
- package/dist/index.d.mts +28 -28
- package/dist/index.mjs +112 -23
- package/dist/plugins/eventEmission/index.d.ts +1 -1
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +90 -22
- package/dist/plugins/eventEmission/index.test.js +179 -2
- package/dist/schemas/Action.d.ts +1 -1
- package/dist/schemas/Auth.d.ts +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/api/auth.d.ts
CHANGED
|
@@ -6,4 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function isJwt(token: string): boolean;
|
|
8
8
|
export declare function getAuthorizationHeader(token: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Extract user IDs from JWT token
|
|
11
|
+
* Decodes the JWT payload and extracts customuser_id and account_id
|
|
12
|
+
* Handles nested JWTs for service tokens
|
|
13
|
+
* Returns null values on any failure (silent-by-design)
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractUserIdsFromJwt(token: string): {
|
|
16
|
+
customuser_id: number | null;
|
|
17
|
+
account_id: number | null;
|
|
18
|
+
};
|
|
9
19
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/api/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW5C;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO5D"}
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW5C;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG;IACpD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAwCA"}
|
package/dist/api/auth.js
CHANGED
|
@@ -23,3 +23,38 @@ export function getAuthorizationHeader(token) {
|
|
|
23
23
|
// Default to Bearer for other token types
|
|
24
24
|
return `Bearer ${token}`;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Extract user IDs from JWT token
|
|
28
|
+
* Decodes the JWT payload and extracts customuser_id and account_id
|
|
29
|
+
* Handles nested JWTs for service tokens
|
|
30
|
+
* Returns null values on any failure (silent-by-design)
|
|
31
|
+
*/
|
|
32
|
+
export function extractUserIdsFromJwt(token) {
|
|
33
|
+
try {
|
|
34
|
+
const parts = token.split(".");
|
|
35
|
+
if (parts.length !== 3) {
|
|
36
|
+
return { customuser_id: null, account_id: null };
|
|
37
|
+
}
|
|
38
|
+
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf-8"));
|
|
39
|
+
let actualPayload = payload;
|
|
40
|
+
if (payload.sub_type === "service" && payload.njwt) {
|
|
41
|
+
const nestedParts = payload.njwt.split(".");
|
|
42
|
+
if (nestedParts.length === 3) {
|
|
43
|
+
actualPayload = JSON.parse(Buffer.from(nestedParts[1], "base64url").toString("utf-8"));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const accountId = actualPayload["zap:acc"] != null
|
|
47
|
+
? parseInt(String(actualPayload["zap:acc"]), 10)
|
|
48
|
+
: null;
|
|
49
|
+
const customUserId = actualPayload.sub_type === "customuser" && actualPayload.sub != null
|
|
50
|
+
? parseInt(String(actualPayload.sub), 10)
|
|
51
|
+
: null;
|
|
52
|
+
return {
|
|
53
|
+
customuser_id: customUserId !== null && !isNaN(customUserId) ? customUserId : null,
|
|
54
|
+
account_id: accountId !== null && !isNaN(accountId) ? accountId : null,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return { customuser_id: null, account_id: null };
|
|
59
|
+
}
|
|
60
|
+
}
|
package/dist/api/schemas.d.ts
CHANGED
|
@@ -152,19 +152,19 @@ export declare const ActionSchema: z.ZodObject<{
|
|
|
152
152
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
153
153
|
name: string;
|
|
154
154
|
description: string;
|
|
155
|
+
selected_api?: string | undefined;
|
|
155
156
|
id?: string | undefined;
|
|
156
157
|
is_important?: boolean | undefined;
|
|
157
158
|
is_hidden?: boolean | undefined;
|
|
158
|
-
selected_api?: string | undefined;
|
|
159
159
|
}, {
|
|
160
160
|
key: string;
|
|
161
161
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
162
162
|
name: string;
|
|
163
163
|
description: string;
|
|
164
|
+
selected_api?: string | undefined;
|
|
164
165
|
id?: string | undefined;
|
|
165
166
|
is_important?: boolean | undefined;
|
|
166
167
|
is_hidden?: boolean | undefined;
|
|
167
|
-
selected_api?: string | undefined;
|
|
168
168
|
}>;
|
|
169
169
|
export declare const ChoiceSchema: z.ZodObject<{
|
|
170
170
|
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
@@ -313,18 +313,18 @@ export declare const AuthenticationSchema: z.ZodObject<{
|
|
|
313
313
|
members: z.ZodOptional<z.ZodString>;
|
|
314
314
|
permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
315
315
|
}, "strip", z.ZodTypeAny, {
|
|
316
|
+
account_id: number;
|
|
317
|
+
selected_api: string;
|
|
316
318
|
id: number;
|
|
317
319
|
date: string;
|
|
318
|
-
selected_api: string;
|
|
319
|
-
account_id: number;
|
|
320
320
|
is_invite_only: boolean;
|
|
321
321
|
is_private: boolean;
|
|
322
322
|
shared_with_all: boolean;
|
|
323
323
|
url?: string | undefined;
|
|
324
324
|
members?: string | undefined;
|
|
325
|
+
customuser_id?: number | undefined;
|
|
325
326
|
label?: string | null | undefined;
|
|
326
327
|
lastchanged?: string | undefined;
|
|
327
|
-
customuser_id?: number | undefined;
|
|
328
328
|
destination_selected_api?: string | null | undefined;
|
|
329
329
|
is_stale?: string | undefined;
|
|
330
330
|
is_shared?: string | undefined;
|
|
@@ -334,18 +334,18 @@ export declare const AuthenticationSchema: z.ZodObject<{
|
|
|
334
334
|
groups?: string | undefined;
|
|
335
335
|
permissions?: Record<string, boolean> | undefined;
|
|
336
336
|
}, {
|
|
337
|
+
account_id: number;
|
|
338
|
+
selected_api: string;
|
|
337
339
|
id: number;
|
|
338
340
|
date: string;
|
|
339
|
-
selected_api: string;
|
|
340
|
-
account_id: number;
|
|
341
341
|
is_invite_only: boolean;
|
|
342
342
|
is_private: boolean;
|
|
343
343
|
shared_with_all: boolean;
|
|
344
344
|
url?: string | undefined;
|
|
345
345
|
members?: string | undefined;
|
|
346
|
+
customuser_id?: number | undefined;
|
|
346
347
|
label?: string | null | undefined;
|
|
347
348
|
lastchanged?: string | undefined;
|
|
348
|
-
customuser_id?: number | undefined;
|
|
349
349
|
destination_selected_api?: string | null | undefined;
|
|
350
350
|
is_stale?: string | undefined;
|
|
351
351
|
is_shared?: string | undefined;
|
|
@@ -381,18 +381,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
|
|
|
381
381
|
members: z.ZodOptional<z.ZodString>;
|
|
382
382
|
permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
383
383
|
}, "strip", z.ZodTypeAny, {
|
|
384
|
+
account_id: number;
|
|
385
|
+
selected_api: string;
|
|
384
386
|
id: number;
|
|
385
387
|
date: string;
|
|
386
|
-
selected_api: string;
|
|
387
|
-
account_id: number;
|
|
388
388
|
is_invite_only: boolean;
|
|
389
389
|
is_private: boolean;
|
|
390
390
|
shared_with_all: boolean;
|
|
391
391
|
url?: string | undefined;
|
|
392
392
|
members?: string | undefined;
|
|
393
|
+
customuser_id?: number | undefined;
|
|
393
394
|
label?: string | null | undefined;
|
|
394
395
|
lastchanged?: string | undefined;
|
|
395
|
-
customuser_id?: number | undefined;
|
|
396
396
|
destination_selected_api?: string | null | undefined;
|
|
397
397
|
is_stale?: string | undefined;
|
|
398
398
|
is_shared?: string | undefined;
|
|
@@ -402,18 +402,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
|
|
|
402
402
|
groups?: string | undefined;
|
|
403
403
|
permissions?: Record<string, boolean> | undefined;
|
|
404
404
|
}, {
|
|
405
|
+
account_id: number;
|
|
406
|
+
selected_api: string;
|
|
405
407
|
id: number;
|
|
406
408
|
date: string;
|
|
407
|
-
selected_api: string;
|
|
408
|
-
account_id: number;
|
|
409
409
|
is_invite_only: boolean;
|
|
410
410
|
is_private: boolean;
|
|
411
411
|
shared_with_all: boolean;
|
|
412
412
|
url?: string | undefined;
|
|
413
413
|
members?: string | undefined;
|
|
414
|
+
customuser_id?: number | undefined;
|
|
414
415
|
label?: string | null | undefined;
|
|
415
416
|
lastchanged?: string | undefined;
|
|
416
|
-
customuser_id?: number | undefined;
|
|
417
417
|
destination_selected_api?: string | null | undefined;
|
|
418
418
|
is_stale?: string | undefined;
|
|
419
419
|
is_shared?: string | undefined;
|
|
@@ -426,18 +426,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
|
|
|
426
426
|
}, "strip", z.ZodTypeAny, {
|
|
427
427
|
count: number;
|
|
428
428
|
results: {
|
|
429
|
+
account_id: number;
|
|
430
|
+
selected_api: string;
|
|
429
431
|
id: number;
|
|
430
432
|
date: string;
|
|
431
|
-
selected_api: string;
|
|
432
|
-
account_id: number;
|
|
433
433
|
is_invite_only: boolean;
|
|
434
434
|
is_private: boolean;
|
|
435
435
|
shared_with_all: boolean;
|
|
436
436
|
url?: string | undefined;
|
|
437
437
|
members?: string | undefined;
|
|
438
|
+
customuser_id?: number | undefined;
|
|
438
439
|
label?: string | null | undefined;
|
|
439
440
|
lastchanged?: string | undefined;
|
|
440
|
-
customuser_id?: number | undefined;
|
|
441
441
|
destination_selected_api?: string | null | undefined;
|
|
442
442
|
is_stale?: string | undefined;
|
|
443
443
|
is_shared?: string | undefined;
|
|
@@ -452,18 +452,18 @@ export declare const AuthenticationsResponseSchema: z.ZodObject<{
|
|
|
452
452
|
}, {
|
|
453
453
|
count: number;
|
|
454
454
|
results: {
|
|
455
|
+
account_id: number;
|
|
456
|
+
selected_api: string;
|
|
455
457
|
id: number;
|
|
456
458
|
date: string;
|
|
457
|
-
selected_api: string;
|
|
458
|
-
account_id: number;
|
|
459
459
|
is_invite_only: boolean;
|
|
460
460
|
is_private: boolean;
|
|
461
461
|
shared_with_all: boolean;
|
|
462
462
|
url?: string | undefined;
|
|
463
463
|
members?: string | undefined;
|
|
464
|
+
customuser_id?: number | undefined;
|
|
464
465
|
label?: string | null | undefined;
|
|
465
466
|
lastchanged?: string | undefined;
|
|
466
|
-
customuser_id?: number | undefined;
|
|
467
467
|
destination_selected_api?: string | null | undefined;
|
|
468
468
|
is_stale?: string | undefined;
|
|
469
469
|
is_shared?: string | undefined;
|
|
@@ -1067,19 +1067,19 @@ export declare const ImplementationSchema: z.ZodObject<{
|
|
|
1067
1067
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1068
1068
|
name: string;
|
|
1069
1069
|
description: string;
|
|
1070
|
+
selected_api?: string | undefined;
|
|
1070
1071
|
id?: string | undefined;
|
|
1071
1072
|
is_important?: boolean | undefined;
|
|
1072
1073
|
is_hidden?: boolean | undefined;
|
|
1073
|
-
selected_api?: string | undefined;
|
|
1074
1074
|
}, {
|
|
1075
1075
|
key: string;
|
|
1076
1076
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1077
1077
|
name: string;
|
|
1078
1078
|
description: string;
|
|
1079
|
+
selected_api?: string | undefined;
|
|
1079
1080
|
id?: string | undefined;
|
|
1080
1081
|
is_important?: boolean | undefined;
|
|
1081
1082
|
is_hidden?: boolean | undefined;
|
|
1082
|
-
selected_api?: string | undefined;
|
|
1083
1083
|
}>, "many">>;
|
|
1084
1084
|
is_deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
1085
1085
|
is_private_only: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1103,18 +1103,18 @@ export declare const ImplementationSchema: z.ZodObject<{
|
|
|
1103
1103
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1104
1104
|
name: string;
|
|
1105
1105
|
description: string;
|
|
1106
|
+
selected_api?: string | undefined;
|
|
1106
1107
|
id?: string | undefined;
|
|
1107
1108
|
is_important?: boolean | undefined;
|
|
1108
1109
|
is_hidden?: boolean | undefined;
|
|
1109
|
-
selected_api?: string | undefined;
|
|
1110
1110
|
}[] | undefined;
|
|
1111
|
+
app_id?: number | undefined;
|
|
1111
1112
|
name?: string | undefined;
|
|
1112
1113
|
is_hidden?: string | undefined;
|
|
1113
1114
|
is_invite_only?: boolean | undefined;
|
|
1114
1115
|
images?: Record<string, string | null> | undefined;
|
|
1115
1116
|
primary_color?: string | undefined;
|
|
1116
1117
|
slug?: string | undefined;
|
|
1117
|
-
app_id?: number | undefined;
|
|
1118
1118
|
auth_type?: string | undefined;
|
|
1119
1119
|
auth_fields?: string | undefined;
|
|
1120
1120
|
is_deprecated?: boolean | undefined;
|
|
@@ -1129,11 +1129,12 @@ export declare const ImplementationSchema: z.ZodObject<{
|
|
|
1129
1129
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1130
1130
|
name: string;
|
|
1131
1131
|
description: string;
|
|
1132
|
+
selected_api?: string | undefined;
|
|
1132
1133
|
id?: string | undefined;
|
|
1133
1134
|
is_important?: boolean | undefined;
|
|
1134
1135
|
is_hidden?: boolean | undefined;
|
|
1135
|
-
selected_api?: string | undefined;
|
|
1136
1136
|
}[] | undefined;
|
|
1137
|
+
app_id?: number | undefined;
|
|
1137
1138
|
name?: string | undefined;
|
|
1138
1139
|
is_hidden?: string | undefined;
|
|
1139
1140
|
is_invite_only?: boolean | undefined;
|
|
@@ -1142,7 +1143,6 @@ export declare const ImplementationSchema: z.ZodObject<{
|
|
|
1142
1143
|
is_premium?: boolean | undefined;
|
|
1143
1144
|
primary_color?: string | undefined;
|
|
1144
1145
|
slug?: string | undefined;
|
|
1145
|
-
app_id?: number | undefined;
|
|
1146
1146
|
auth_type?: string | undefined;
|
|
1147
1147
|
auth_fields?: string | undefined;
|
|
1148
1148
|
is_deprecated?: boolean | undefined;
|
|
@@ -1174,19 +1174,19 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
|
|
|
1174
1174
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1175
1175
|
name: string;
|
|
1176
1176
|
description: string;
|
|
1177
|
+
selected_api?: string | undefined;
|
|
1177
1178
|
id?: string | undefined;
|
|
1178
1179
|
is_important?: boolean | undefined;
|
|
1179
1180
|
is_hidden?: boolean | undefined;
|
|
1180
|
-
selected_api?: string | undefined;
|
|
1181
1181
|
}, {
|
|
1182
1182
|
key: string;
|
|
1183
1183
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1184
1184
|
name: string;
|
|
1185
1185
|
description: string;
|
|
1186
|
+
selected_api?: string | undefined;
|
|
1186
1187
|
id?: string | undefined;
|
|
1187
1188
|
is_important?: boolean | undefined;
|
|
1188
1189
|
is_hidden?: boolean | undefined;
|
|
1189
|
-
selected_api?: string | undefined;
|
|
1190
1190
|
}>, "many">>;
|
|
1191
1191
|
is_deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
1192
1192
|
is_private_only: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1210,18 +1210,18 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
|
|
|
1210
1210
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1211
1211
|
name: string;
|
|
1212
1212
|
description: string;
|
|
1213
|
+
selected_api?: string | undefined;
|
|
1213
1214
|
id?: string | undefined;
|
|
1214
1215
|
is_important?: boolean | undefined;
|
|
1215
1216
|
is_hidden?: boolean | undefined;
|
|
1216
|
-
selected_api?: string | undefined;
|
|
1217
1217
|
}[] | undefined;
|
|
1218
|
+
app_id?: number | undefined;
|
|
1218
1219
|
name?: string | undefined;
|
|
1219
1220
|
is_hidden?: string | undefined;
|
|
1220
1221
|
is_invite_only?: boolean | undefined;
|
|
1221
1222
|
images?: Record<string, string | null> | undefined;
|
|
1222
1223
|
primary_color?: string | undefined;
|
|
1223
1224
|
slug?: string | undefined;
|
|
1224
|
-
app_id?: number | undefined;
|
|
1225
1225
|
auth_type?: string | undefined;
|
|
1226
1226
|
auth_fields?: string | undefined;
|
|
1227
1227
|
is_deprecated?: boolean | undefined;
|
|
@@ -1236,11 +1236,12 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
|
|
|
1236
1236
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1237
1237
|
name: string;
|
|
1238
1238
|
description: string;
|
|
1239
|
+
selected_api?: string | undefined;
|
|
1239
1240
|
id?: string | undefined;
|
|
1240
1241
|
is_important?: boolean | undefined;
|
|
1241
1242
|
is_hidden?: boolean | undefined;
|
|
1242
|
-
selected_api?: string | undefined;
|
|
1243
1243
|
}[] | undefined;
|
|
1244
|
+
app_id?: number | undefined;
|
|
1244
1245
|
name?: string | undefined;
|
|
1245
1246
|
is_hidden?: string | undefined;
|
|
1246
1247
|
is_invite_only?: boolean | undefined;
|
|
@@ -1249,7 +1250,6 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
|
|
|
1249
1250
|
is_premium?: boolean | undefined;
|
|
1250
1251
|
primary_color?: string | undefined;
|
|
1251
1252
|
slug?: string | undefined;
|
|
1252
|
-
app_id?: number | undefined;
|
|
1253
1253
|
auth_type?: string | undefined;
|
|
1254
1254
|
auth_fields?: string | undefined;
|
|
1255
1255
|
is_deprecated?: boolean | undefined;
|
|
@@ -1269,18 +1269,18 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
|
|
|
1269
1269
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1270
1270
|
name: string;
|
|
1271
1271
|
description: string;
|
|
1272
|
+
selected_api?: string | undefined;
|
|
1272
1273
|
id?: string | undefined;
|
|
1273
1274
|
is_important?: boolean | undefined;
|
|
1274
1275
|
is_hidden?: boolean | undefined;
|
|
1275
|
-
selected_api?: string | undefined;
|
|
1276
1276
|
}[] | undefined;
|
|
1277
|
+
app_id?: number | undefined;
|
|
1277
1278
|
name?: string | undefined;
|
|
1278
1279
|
is_hidden?: string | undefined;
|
|
1279
1280
|
is_invite_only?: boolean | undefined;
|
|
1280
1281
|
images?: Record<string, string | null> | undefined;
|
|
1281
1282
|
primary_color?: string | undefined;
|
|
1282
1283
|
slug?: string | undefined;
|
|
1283
|
-
app_id?: number | undefined;
|
|
1284
1284
|
auth_type?: string | undefined;
|
|
1285
1285
|
auth_fields?: string | undefined;
|
|
1286
1286
|
is_deprecated?: boolean | undefined;
|
|
@@ -1300,11 +1300,12 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
|
|
|
1300
1300
|
type: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
1301
1301
|
name: string;
|
|
1302
1302
|
description: string;
|
|
1303
|
+
selected_api?: string | undefined;
|
|
1303
1304
|
id?: string | undefined;
|
|
1304
1305
|
is_important?: boolean | undefined;
|
|
1305
1306
|
is_hidden?: boolean | undefined;
|
|
1306
|
-
selected_api?: string | undefined;
|
|
1307
1307
|
}[] | undefined;
|
|
1308
|
+
app_id?: number | undefined;
|
|
1308
1309
|
name?: string | undefined;
|
|
1309
1310
|
is_hidden?: string | undefined;
|
|
1310
1311
|
is_invite_only?: boolean | undefined;
|
|
@@ -1313,7 +1314,6 @@ export declare const ImplementationsResponseSchema: z.ZodObject<{
|
|
|
1313
1314
|
is_premium?: boolean | undefined;
|
|
1314
1315
|
primary_color?: string | undefined;
|
|
1315
1316
|
slug?: string | undefined;
|
|
1316
|
-
app_id?: number | undefined;
|
|
1317
1317
|
auth_type?: string | undefined;
|
|
1318
1318
|
auth_fields?: string | undefined;
|
|
1319
1319
|
is_deprecated?: boolean | undefined;
|
|
@@ -1845,16 +1845,16 @@ export declare const NeedChoicesRequestSchema: z.ZodObject<{
|
|
|
1845
1845
|
input_field_id: z.ZodOptional<z.ZodString>;
|
|
1846
1846
|
}, "strip", z.ZodTypeAny, {
|
|
1847
1847
|
page: number;
|
|
1848
|
+
selected_api?: string | undefined;
|
|
1848
1849
|
params?: Record<string, unknown> | undefined;
|
|
1849
1850
|
prefill?: string | undefined;
|
|
1850
|
-
selected_api?: string | undefined;
|
|
1851
1851
|
authentication_id?: number | undefined;
|
|
1852
1852
|
action_id?: string | undefined;
|
|
1853
1853
|
input_field_id?: string | undefined;
|
|
1854
1854
|
}, {
|
|
1855
|
+
selected_api?: string | undefined;
|
|
1855
1856
|
params?: Record<string, unknown> | undefined;
|
|
1856
1857
|
prefill?: string | undefined;
|
|
1857
|
-
selected_api?: string | undefined;
|
|
1858
1858
|
authentication_id?: number | undefined;
|
|
1859
1859
|
page?: number | undefined;
|
|
1860
1860
|
action_id?: string | undefined;
|
package/dist/index.cjs
CHANGED
|
@@ -3199,6 +3199,34 @@ function getAuthorizationHeader(token) {
|
|
|
3199
3199
|
}
|
|
3200
3200
|
return `Bearer ${token}`;
|
|
3201
3201
|
}
|
|
3202
|
+
function extractUserIdsFromJwt(token) {
|
|
3203
|
+
try {
|
|
3204
|
+
const parts = token.split(".");
|
|
3205
|
+
if (parts.length !== 3) {
|
|
3206
|
+
return { customuser_id: null, account_id: null };
|
|
3207
|
+
}
|
|
3208
|
+
const payload = JSON.parse(
|
|
3209
|
+
Buffer.from(parts[1], "base64url").toString("utf-8")
|
|
3210
|
+
);
|
|
3211
|
+
let actualPayload = payload;
|
|
3212
|
+
if (payload.sub_type === "service" && payload.njwt) {
|
|
3213
|
+
const nestedParts = payload.njwt.split(".");
|
|
3214
|
+
if (nestedParts.length === 3) {
|
|
3215
|
+
actualPayload = JSON.parse(
|
|
3216
|
+
Buffer.from(nestedParts[1], "base64url").toString("utf-8")
|
|
3217
|
+
);
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
const accountId = actualPayload["zap:acc"] != null ? parseInt(String(actualPayload["zap:acc"]), 10) : null;
|
|
3221
|
+
const customUserId = actualPayload.sub_type === "customuser" && actualPayload.sub != null ? parseInt(String(actualPayload.sub), 10) : null;
|
|
3222
|
+
return {
|
|
3223
|
+
customuser_id: customUserId !== null && !isNaN(customUserId) ? customUserId : null,
|
|
3224
|
+
account_id: accountId !== null && !isNaN(accountId) ? accountId : null
|
|
3225
|
+
};
|
|
3226
|
+
} catch {
|
|
3227
|
+
return { customuser_id: null, account_id: null };
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3202
3230
|
|
|
3203
3231
|
// src/api/debug.ts
|
|
3204
3232
|
var utilModule = null;
|
|
@@ -4595,7 +4623,7 @@ function getCpuTime() {
|
|
|
4595
4623
|
|
|
4596
4624
|
// package.json
|
|
4597
4625
|
var package_default = {
|
|
4598
|
-
version: "0.15.
|
|
4626
|
+
version: "0.15.4"};
|
|
4599
4627
|
|
|
4600
4628
|
// src/plugins/eventEmission/builders.ts
|
|
4601
4629
|
function createBaseEvent(context = {}) {
|
|
@@ -4666,17 +4694,26 @@ function buildErrorEventWithContext(data, context = {}) {
|
|
|
4666
4694
|
}
|
|
4667
4695
|
|
|
4668
4696
|
// src/plugins/eventEmission/index.ts
|
|
4697
|
+
var TELEMETRY_EMIT_TIMEOUT_MS = 300;
|
|
4669
4698
|
var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
|
|
4670
4699
|
var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
|
|
4671
4700
|
var transportStates = /* @__PURE__ */ new WeakMap();
|
|
4672
|
-
async function silentEmit(transport, subject, event) {
|
|
4701
|
+
async function silentEmit(transport, subject, event, userContextPromise) {
|
|
4673
4702
|
try {
|
|
4674
4703
|
let state = transportStates.get(transport);
|
|
4675
4704
|
if (!state) {
|
|
4676
4705
|
state = { hasWorked: false, hasLoggedFailure: false };
|
|
4677
4706
|
transportStates.set(transport, state);
|
|
4678
4707
|
}
|
|
4679
|
-
|
|
4708
|
+
let enrichedEvent = event;
|
|
4709
|
+
if (userContextPromise) {
|
|
4710
|
+
try {
|
|
4711
|
+
const userContext = await userContextPromise;
|
|
4712
|
+
enrichedEvent = Object.assign({}, event, userContext);
|
|
4713
|
+
} catch {
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
transport.emit(subject, enrichedEvent).then(() => {
|
|
4680
4717
|
state.hasWorked = true;
|
|
4681
4718
|
}).catch((error) => {
|
|
4682
4719
|
if (!state.hasWorked && !state.hasLoggedFailure) {
|
|
@@ -4724,6 +4761,19 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4724
4761
|
)
|
|
4725
4762
|
)
|
|
4726
4763
|
};
|
|
4764
|
+
const getUserContext = (async () => {
|
|
4765
|
+
try {
|
|
4766
|
+
const { getToken } = await import('@zapier/zapier-sdk-cli-login');
|
|
4767
|
+
const token = await getToken({
|
|
4768
|
+
baseUrl: context.options.baseUrl
|
|
4769
|
+
});
|
|
4770
|
+
if (token) {
|
|
4771
|
+
return extractUserIdsFromJwt(token);
|
|
4772
|
+
}
|
|
4773
|
+
} catch {
|
|
4774
|
+
}
|
|
4775
|
+
return { customuser_id: null, account_id: null };
|
|
4776
|
+
})();
|
|
4727
4777
|
const startupTime = Date.now();
|
|
4728
4778
|
let shutdownStartTime = null;
|
|
4729
4779
|
if (!config.enabled) {
|
|
@@ -4734,7 +4784,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4734
4784
|
config,
|
|
4735
4785
|
emit: () => {
|
|
4736
4786
|
},
|
|
4737
|
-
createBaseEvent: () => ({
|
|
4787
|
+
createBaseEvent: async () => ({
|
|
4738
4788
|
event_id: generateEventId(),
|
|
4739
4789
|
timestamp_ms: getCurrentTimestamp(),
|
|
4740
4790
|
release_id: getReleaseId(),
|
|
@@ -4754,21 +4804,34 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4754
4804
|
} catch {
|
|
4755
4805
|
transport = createTransport({ type: "noop" });
|
|
4756
4806
|
}
|
|
4757
|
-
const createBaseEventHelper = () =>
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4807
|
+
const createBaseEventHelper = async () => {
|
|
4808
|
+
const baseEvent = {
|
|
4809
|
+
event_id: generateEventId(),
|
|
4810
|
+
timestamp_ms: getCurrentTimestamp(),
|
|
4811
|
+
release_id: getReleaseId(),
|
|
4812
|
+
customuser_id: null,
|
|
4813
|
+
account_id: null,
|
|
4814
|
+
identity_id: null,
|
|
4815
|
+
visitor_id: null,
|
|
4816
|
+
correlation_id: null
|
|
4817
|
+
};
|
|
4818
|
+
try {
|
|
4819
|
+
const userContext = await getUserContext;
|
|
4820
|
+
return { ...baseEvent, ...userContext };
|
|
4821
|
+
} catch {
|
|
4822
|
+
return baseEvent;
|
|
4823
|
+
}
|
|
4824
|
+
};
|
|
4767
4825
|
if (config.enabled) {
|
|
4768
4826
|
const startupEvent = buildApplicationLifecycleEvent({
|
|
4769
4827
|
lifecycle_event_type: "startup"
|
|
4770
4828
|
});
|
|
4771
|
-
silentEmit(
|
|
4829
|
+
silentEmit(
|
|
4830
|
+
transport,
|
|
4831
|
+
APPLICATION_LIFECYCLE_EVENT_SUBJECT,
|
|
4832
|
+
startupEvent,
|
|
4833
|
+
getUserContext
|
|
4834
|
+
);
|
|
4772
4835
|
if (typeof process?.on === "function") {
|
|
4773
4836
|
process.on("exit", (code) => {
|
|
4774
4837
|
const uptime = Date.now() - startupTime;
|
|
@@ -4780,10 +4843,15 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4780
4843
|
is_graceful_shutdown: code === 0,
|
|
4781
4844
|
shutdown_duration_ms: shutdownDuration
|
|
4782
4845
|
});
|
|
4783
|
-
silentEmit(
|
|
4846
|
+
silentEmit(
|
|
4847
|
+
transport,
|
|
4848
|
+
APPLICATION_LIFECYCLE_EVENT_SUBJECT,
|
|
4849
|
+
exitEvent,
|
|
4850
|
+
getUserContext
|
|
4851
|
+
);
|
|
4784
4852
|
});
|
|
4785
4853
|
process.on("uncaughtException", async (error) => {
|
|
4786
|
-
|
|
4854
|
+
let errorEvent = buildErrorEventWithContext({
|
|
4787
4855
|
error_message: error.message || "Unknown error",
|
|
4788
4856
|
error_type: "UncaughtException",
|
|
4789
4857
|
error_stack_trace: error.stack || null,
|
|
@@ -4792,10 +4860,17 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4792
4860
|
is_recoverable: false,
|
|
4793
4861
|
execution_start_time: startupTime
|
|
4794
4862
|
});
|
|
4863
|
+
try {
|
|
4864
|
+
const userContext = await getUserContext;
|
|
4865
|
+
errorEvent = { ...errorEvent, ...userContext };
|
|
4866
|
+
} catch {
|
|
4867
|
+
}
|
|
4795
4868
|
try {
|
|
4796
4869
|
await Promise.race([
|
|
4797
4870
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
4798
|
-
new Promise(
|
|
4871
|
+
new Promise(
|
|
4872
|
+
(resolve2) => setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS)
|
|
4873
|
+
)
|
|
4799
4874
|
]);
|
|
4800
4875
|
} catch {
|
|
4801
4876
|
}
|
|
@@ -4805,7 +4880,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4805
4880
|
async (reason, promise) => {
|
|
4806
4881
|
const errorMessage = reason instanceof Error ? reason.message : typeof reason === "string" ? reason : "Unhandled promise rejection";
|
|
4807
4882
|
const errorStack = reason instanceof Error ? reason.stack : null;
|
|
4808
|
-
|
|
4883
|
+
let errorEvent = buildErrorEventWithContext({
|
|
4809
4884
|
error_message: errorMessage,
|
|
4810
4885
|
error_type: "UnhandledRejection",
|
|
4811
4886
|
error_stack_trace: errorStack,
|
|
@@ -4817,10 +4892,17 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4817
4892
|
promise: String(promise)
|
|
4818
4893
|
}
|
|
4819
4894
|
});
|
|
4895
|
+
try {
|
|
4896
|
+
const userContext = await getUserContext;
|
|
4897
|
+
errorEvent = { ...errorEvent, ...userContext };
|
|
4898
|
+
} catch {
|
|
4899
|
+
}
|
|
4820
4900
|
try {
|
|
4821
4901
|
await Promise.race([
|
|
4822
4902
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
4823
|
-
new Promise(
|
|
4903
|
+
new Promise(
|
|
4904
|
+
(resolve2) => setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS)
|
|
4905
|
+
)
|
|
4824
4906
|
]);
|
|
4825
4907
|
} catch {
|
|
4826
4908
|
}
|
|
@@ -4829,16 +4911,23 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4829
4911
|
const handleSignal = async (signal) => {
|
|
4830
4912
|
shutdownStartTime = Date.now();
|
|
4831
4913
|
const uptime = Date.now() - startupTime;
|
|
4832
|
-
|
|
4914
|
+
let signalEvent = buildApplicationLifecycleEvent({
|
|
4833
4915
|
lifecycle_event_type: "signal_termination",
|
|
4834
4916
|
signal_name: signal,
|
|
4835
4917
|
uptime_ms: uptime,
|
|
4836
4918
|
is_graceful_shutdown: true
|
|
4837
4919
|
});
|
|
4920
|
+
try {
|
|
4921
|
+
const userContext = await getUserContext;
|
|
4922
|
+
signalEvent = { ...signalEvent, ...userContext };
|
|
4923
|
+
} catch {
|
|
4924
|
+
}
|
|
4838
4925
|
try {
|
|
4839
4926
|
await Promise.race([
|
|
4840
4927
|
transport.emit(APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent),
|
|
4841
|
-
new Promise(
|
|
4928
|
+
new Promise(
|
|
4929
|
+
(resolve2) => setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS)
|
|
4930
|
+
)
|
|
4842
4931
|
]);
|
|
4843
4932
|
} catch {
|
|
4844
4933
|
}
|
|
@@ -4854,7 +4943,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4854
4943
|
transport,
|
|
4855
4944
|
config,
|
|
4856
4945
|
emit: (subject, event) => {
|
|
4857
|
-
silentEmit(transport, subject, event);
|
|
4946
|
+
silentEmit(transport, subject, event, getUserContext);
|
|
4858
4947
|
},
|
|
4859
4948
|
createBaseEvent: createBaseEventHelper
|
|
4860
4949
|
}
|