@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.
Files changed (70) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +92 -92
  3. package/dist/api/schemas.d.ts +1 -1
  4. package/dist/api/schemas.js +1 -1
  5. package/dist/index.cjs +132 -93
  6. package/dist/index.d.mts +58 -100
  7. package/dist/index.mjs +132 -93
  8. package/dist/plugins/apps/index.js +2 -2
  9. package/dist/plugins/apps/schemas.d.ts +4 -3
  10. package/dist/plugins/apps/schemas.d.ts.map +1 -1
  11. package/dist/plugins/apps/schemas.js +3 -2
  12. package/dist/plugins/eventEmission/transport.d.ts +8 -18
  13. package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
  14. package/dist/plugins/eventEmission/transport.js +47 -44
  15. package/dist/plugins/eventEmission/transport.test.js +36 -25
  16. package/dist/plugins/fetch/index.d.ts +2 -2
  17. package/dist/plugins/fetch/index.d.ts.map +1 -1
  18. package/dist/plugins/fetch/schemas.d.ts +1 -1
  19. package/dist/plugins/fetch/schemas.d.ts.map +1 -1
  20. package/dist/plugins/fetch/schemas.js +2 -4
  21. package/dist/plugins/findFirstAuthentication/index.test.js +4 -4
  22. package/dist/plugins/findUniqueAuthentication/index.test.js +4 -4
  23. package/dist/plugins/getAuthentication/index.js +1 -1
  24. package/dist/plugins/getAuthentication/index.test.js +9 -4
  25. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +1 -1
  26. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  27. package/dist/plugins/getProfile/index.js +7 -4
  28. package/dist/plugins/listAuthentications/index.test.js +9 -9
  29. package/dist/plugins/listInputFieldChoices/schemas.d.ts +1 -1
  30. package/dist/plugins/listInputFields/schemas.d.ts +1 -1
  31. package/dist/plugins/manifest/schemas.d.ts +2 -2
  32. package/dist/plugins/manifest/schemas.d.ts.map +1 -1
  33. package/dist/plugins/manifest/schemas.js +2 -5
  34. package/dist/plugins/request/index.d.ts.map +1 -1
  35. package/dist/plugins/request/index.js +2 -1
  36. package/dist/plugins/request/schemas.d.ts +2 -2
  37. package/dist/plugins/request/schemas.d.ts.map +1 -1
  38. package/dist/plugins/request/schemas.js +2 -5
  39. package/dist/plugins/runAction/schemas.d.ts +1 -1
  40. package/dist/resolvers/inputFieldKey.d.ts +1 -1
  41. package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
  42. package/dist/resolvers/inputs.d.ts +1 -1
  43. package/dist/resolvers/inputs.d.ts.map +1 -1
  44. package/dist/schemas/Auth.d.ts +6 -6
  45. package/dist/schemas/Auth.d.ts.map +1 -1
  46. package/dist/schemas/Auth.js +3 -1
  47. package/dist/schemas/UserProfile.d.ts +2 -44
  48. package/dist/schemas/UserProfile.d.ts.map +1 -1
  49. package/dist/schemas/UserProfile.js +10 -21
  50. package/dist/services/implementations.d.ts +2 -2
  51. package/dist/services/implementations.d.ts.map +1 -1
  52. package/dist/services/implementations.js +3 -2
  53. package/dist/temporary-internal-core/handlers/getAuthentication.test.js +6 -6
  54. package/dist/temporary-internal-core/schemas/authentications/index.d.ts +7 -7
  55. package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +1 -1
  56. package/dist/temporary-internal-core/schemas/authentications/index.js +5 -4
  57. package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
  58. package/dist/temporary-internal-core/utils/transformations.js +4 -2
  59. package/dist/types/properties.d.ts +1 -1
  60. package/dist/types/properties.d.ts.map +1 -1
  61. package/dist/types/properties.js +1 -2
  62. package/dist/utils/domain-utils.d.ts.map +1 -1
  63. package/dist/utils/domain-utils.js +4 -2
  64. package/dist/utils/id-utils.d.ts +13 -0
  65. package/dist/utils/id-utils.d.ts.map +1 -0
  66. package/dist/utils/id-utils.js +22 -0
  67. package/dist/utils/id-utils.test.d.ts +2 -0
  68. package/dist/utils/id-utils.test.d.ts.map +1 -0
  69. package/dist/utils/id-utils.test.js +22 -0
  70. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -72,7 +72,7 @@ var ActionTypePropertySchema = zod.z.enum([
72
72
  "filter"
73
73
  ]).describe("Action type that matches the action's defined type");
74
74
  var ActionKeyPropertySchema = zod.z.string().min(1).describe("Action key to execute");
75
- var AuthenticationIdPropertySchema = zod.z.number().int().describe("Authentication ID to use for this action");
75
+ var AuthenticationIdPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Authentication ID to use for this action");
76
76
  var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
77
77
  var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
78
78
  var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Number of items to skip for pagination");
@@ -216,12 +216,12 @@ HTTP Status: ${error.statusCode}`;
216
216
  }
217
217
  var ActionExecutionInputSchema = zod.z.object({
218
218
  inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
219
- authenticationId: zod.z.number().optional()
219
+ authenticationId: AuthenticationIdPropertySchema.optional()
220
220
  }).describe(
221
221
  "Execute an action with the given inputs for the bound app, as an alternative to runAction"
222
222
  );
223
223
  var AppFactoryInputSchema = zod.z.object({
224
- authenticationId: zod.z.number()
224
+ authenticationId: AuthenticationIdPropertySchema
225
225
  }).describe("Bind an authentication ID to an app");
226
226
  function getStringProperty(obj, key) {
227
227
  if (typeof obj === "object" && obj !== null && key in obj) {
@@ -254,7 +254,7 @@ function createActionFunction(appKey, actionType, actionKey, options, pinnedAuth
254
254
  return (actionOptions = {}) => {
255
255
  const { sdk } = options;
256
256
  const { inputs, authenticationId: providedAuthenticationId } = actionOptions;
257
- const authenticationId = pinnedAuthId || providedAuthenticationId;
257
+ const authenticationId = pinnedAuthId ?? providedAuthenticationId;
258
258
  if (!authenticationId) {
259
259
  throw new ZapierValidationError(
260
260
  `Authentication ID is required. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }) or provide authenticationId in the action call.`
@@ -273,7 +273,7 @@ function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
273
273
  if (actionType === "fetch") {
274
274
  return async (url, init) => {
275
275
  const { sdk } = options;
276
- const authenticationId = pinnedAuthId || init?.authenticationId;
276
+ const authenticationId = pinnedAuthId ?? init?.authenticationId;
277
277
  if (!authenticationId) {
278
278
  throw new ZapierValidationError(
279
279
  `Authentication ID is required for fetch. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }).fetch(...) or provide authenticationId in the fetch call.`
@@ -382,7 +382,7 @@ var FetchInitSchema = zod.z.object({
382
382
  zod.z.instanceof(FormData),
383
383
  zod.z.instanceof(URLSearchParams)
384
384
  ]).optional(),
385
- authenticationId: zod.z.number().optional().describe("Zapier authentication ID to use for the request"),
385
+ authenticationId: AuthenticationIdPropertySchema.optional(),
386
386
  callbackUrl: zod.z.string().optional().describe("URL to send async response to (makes request async)"),
387
387
  authenticationTemplate: zod.z.string().optional().describe(
388
388
  "Optional JSON string authentication template to bypass Notary lookup"
@@ -1052,7 +1052,7 @@ zod.z.object({
1052
1052
  previous: zod.z.string().nullable().optional(),
1053
1053
  results: zod.z.array(AuthenticationSchema)
1054
1054
  });
1055
- var UserProfileSchema = zod.z.object({
1055
+ zod.z.object({
1056
1056
  id: zod.z.number(),
1057
1057
  code: zod.z.string(),
1058
1058
  user_id: zod.z.number(),
@@ -1269,7 +1269,7 @@ zod.z.object({
1269
1269
  selected_api: zod.z.string().optional().describe(
1270
1270
  "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."
1271
1271
  ),
1272
- authentication_id: zod.z.number().optional().describe(
1272
+ authentication_id: zod.z.coerce.number().optional().describe(
1273
1273
  "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)."
1274
1274
  ),
1275
1275
  params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
@@ -1459,11 +1459,17 @@ function normalizeAuthenticationItem(auth, options = {}) {
1459
1459
  const {
1460
1460
  selected_api: selectedApi,
1461
1461
  customuser_id: profileId,
1462
+ id,
1463
+ account_id: accountId,
1462
1464
  ...restOfAuth
1463
1465
  } = auth;
1464
1466
  return {
1465
1467
  ...restOfAuth,
1466
1468
  // Pass through all other API response fields except selected_api
1469
+ id: String(id),
1470
+ // Convert to string
1471
+ account_id: String(accountId),
1472
+ // Convert to string
1467
1473
  implementation_id: selectedApi,
1468
1474
  // Rename selected_api to implementation_id
1469
1475
  title: auth.title || auth.label || void 0,
@@ -1476,8 +1482,8 @@ function normalizeAuthenticationItem(auth, options = {}) {
1476
1482
  // App key from implementations endpoint or parsed from selected_api
1477
1483
  app_version: appVersion,
1478
1484
  // Version from selected_api or provided
1479
- profile_id: profileId
1480
- // Map customuser_id to profile_id
1485
+ profile_id: profileId != null ? String(profileId) : void 0
1486
+ // Map customuser_id to profile_id, convert to string
1481
1487
  };
1482
1488
  }
1483
1489
  function normalizeActionItem(action) {
@@ -1998,6 +2004,20 @@ var RootFieldItemSchema = zod.z.union([
1998
2004
  FieldsetItemSchema
1999
2005
  ]);
2000
2006
 
2007
+ // src/utils/id-utils.ts
2008
+ function coerceToNumericId(fieldName, value) {
2009
+ if (value === "") {
2010
+ throw new ZapierValidationError(`The ${fieldName} cannot be empty`);
2011
+ }
2012
+ const numericValue = typeof value === "number" ? value : Number(value);
2013
+ if (!Number.isFinite(numericValue)) {
2014
+ throw new ZapierValidationError(
2015
+ `The ${fieldName} "${value}" could not be converted to a number`
2016
+ );
2017
+ }
2018
+ return numericValue;
2019
+ }
2020
+
2001
2021
  // src/services/implementations.ts
2002
2022
  async function fetchImplementationNeeds({
2003
2023
  api,
@@ -2014,7 +2034,10 @@ async function fetchImplementationNeeds({
2014
2034
  params: inputs || {}
2015
2035
  };
2016
2036
  if (authenticationId !== null) {
2017
- request.authentication_id = authenticationId;
2037
+ request.authentication_id = coerceToNumericId(
2038
+ "authentication_id",
2039
+ authenticationId
2040
+ );
2018
2041
  }
2019
2042
  const response = await api.post(
2020
2043
  "/zapier/api/v4/implementations/needs/",
@@ -2042,7 +2065,10 @@ async function fetchImplementationChoices({
2042
2065
  params: inputs || {}
2043
2066
  };
2044
2067
  if (authenticationId !== null) {
2045
- request.authentication_id = authenticationId;
2068
+ request.authentication_id = coerceToNumericId(
2069
+ "authentication_id",
2070
+ authenticationId
2071
+ );
2046
2072
  }
2047
2073
  const response = await api.post(
2048
2074
  "/zapier/api/v4/implementations/choices/",
@@ -2239,6 +2265,10 @@ var ListAuthenticationsSchema = zod.z.object({
2239
2265
  var AuthenticationItemSchema = withFormatter(
2240
2266
  AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
2241
2267
  {
2268
+ id: zod.z.string(),
2269
+ // Converted from number
2270
+ account_id: zod.z.string(),
2271
+ // Converted from number
2242
2272
  implementation_id: zod.z.string().optional(),
2243
2273
  // Renamed from selected_api
2244
2274
  is_expired: zod.z.string().optional(),
@@ -2249,8 +2279,8 @@ var AuthenticationItemSchema = withFormatter(
2249
2279
  // App key from implementations endpoint
2250
2280
  app_version: zod.z.string().optional(),
2251
2281
  // Version extracted from implementation_id
2252
- profile_id: zod.z.number().optional()
2253
- // Mapped from customuser_id
2282
+ profile_id: zod.z.string().optional()
2283
+ // Mapped from customuser_id, converted from number
2254
2284
  }
2255
2285
  ),
2256
2286
  {
@@ -2499,9 +2529,12 @@ var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
2499
2529
  selected_api: true,
2500
2530
  customuser_id: true
2501
2531
  }).extend({
2532
+ // Override numeric IDs with string versions (converted by normalizeAuthenticationItem)
2533
+ id: zod.z.string(),
2534
+ account_id: zod.z.string(),
2502
2535
  // Renamed fields
2503
2536
  implementation_id: zod.z.string().optional(),
2504
- profile_id: zod.z.number().optional(),
2537
+ profile_id: zod.z.string().optional(),
2505
2538
  // Mapped fields (originals preserved in ...restOfAuth)
2506
2539
  is_expired: zod.z.string().optional(),
2507
2540
  expired_at: zod.z.string().nullable().optional(),
@@ -2510,7 +2543,7 @@ var AuthenticationItemSchema2 = AuthenticationSchema2.omit({
2510
2543
  app_version: zod.z.string().optional()
2511
2544
  });
2512
2545
  var GetAuthenticationOptionsSchema = zod.z.object({
2513
- authenticationId: zod.z.number().int().positive().describe("Authentication ID to retrieve")
2546
+ authenticationId: zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe("Authentication ID to retrieve")
2514
2547
  }).describe("Get a specific authentication by ID");
2515
2548
  var GetAuthenticationHandlerRequestSchema = zod.z.object({
2516
2549
  authenticationId: zod.z.union([zod.z.string(), zod.z.number()]).describe("Authentication ID - string from searchParams or number")
@@ -2526,7 +2559,7 @@ var getAuthenticationPlugin = ({ context }) => {
2526
2559
  async function getAuthentication(options) {
2527
2560
  const { api } = context;
2528
2561
  return await api.get(
2529
- `/api/v0/authentications/${options.authenticationId}`
2562
+ `/api/v0/authentications/${encodeURIComponent(options.authenticationId)}`
2530
2563
  );
2531
2564
  }
2532
2565
  const getAuthenticationDefinition = createFunction(
@@ -2800,7 +2833,7 @@ var RelayRequestSchema = zod.z.object({
2800
2833
  url: zod.z.string().url().describe("The URL to request (will be proxied through Relay)"),
2801
2834
  method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method"),
2802
2835
  body: zod.z.any().optional().describe("Request body as a string"),
2803
- authenticationId: zod.z.number().int().optional().describe("Zapier authentication ID to use for the request"),
2836
+ authenticationId: AuthenticationIdPropertySchema.optional(),
2804
2837
  callbackUrl: zod.z.string().url().optional().describe("URL to send async response to (makes request async)"),
2805
2838
  authenticationTemplate: zod.z.string().optional().describe(
2806
2839
  "Optional JSON string authentication template to bypass Notary lookup"
@@ -2852,7 +2885,10 @@ var requestPlugin = ({ context }) => {
2852
2885
  }
2853
2886
  }
2854
2887
  if (authenticationId) {
2855
- headers["X-Relay-Authentication-Id"] = authenticationId.toString();
2888
+ headers["X-Relay-Authentication-Id"] = coerceToNumericId(
2889
+ "authenticationId",
2890
+ authenticationId
2891
+ ).toString();
2856
2892
  }
2857
2893
  if (callbackUrl) {
2858
2894
  headers["X-Relay-Callback-Url"] = callbackUrl;
@@ -2952,7 +2988,7 @@ var ActionEntrySchema = zod.z.object({
2952
2988
  appKey: zod.z.string().describe("App key (slug or implementation name)"),
2953
2989
  actionKey: zod.z.string().describe("Action key identifier"),
2954
2990
  actionType: zod.z.string().describe("Action type (e.g., 'read', 'write', 'search')"),
2955
- authenticationId: zod.z.number().nullable().optional().describe("Authentication ID used"),
2991
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
2956
2992
  inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Resolved input values"),
2957
2993
  schema: zod.z.record(zod.z.string(), zod.z.unknown()).describe(
2958
2994
  "Complete JSON Schema from getInputFieldsSchema (includes $schema, type, properties, required, etc.)"
@@ -3338,20 +3374,18 @@ var manifestPlugin = (params) => {
3338
3374
  };
3339
3375
  var GetProfileSchema = zod.z.object({}).optional().describe("Get current user's profile information");
3340
3376
  var UserProfileItemSchema = withFormatter(
3341
- UserProfileSchema.omit({ user_id: true }).extend({
3342
- full_name: zod.z.string()
3343
- // Computed field: first_name + " " + last_name
3377
+ zod.z.object({
3378
+ id: zod.z.string(),
3379
+ first_name: zod.z.string(),
3380
+ last_name: zod.z.string(),
3381
+ full_name: zod.z.string(),
3382
+ email: zod.z.string(),
3383
+ email_confirmed: zod.z.boolean(),
3384
+ timezone: zod.z.string()
3344
3385
  }),
3345
3386
  {
3346
3387
  format: (item) => {
3347
3388
  const details = [];
3348
- if (item == null || typeof item !== "object" || !("full_name" in item) || !("username" in item)) {
3349
- return {
3350
- title: "User Profile",
3351
- subtitle: "Malformatted result item",
3352
- details: []
3353
- };
3354
- }
3355
3389
  if ("email" in item) {
3356
3390
  details.push({ text: item.email, style: "dim" });
3357
3391
  }
@@ -3361,15 +3395,9 @@ var UserProfileItemSchema = withFormatter(
3361
3395
  style: "accent"
3362
3396
  });
3363
3397
  }
3364
- if ("since_signup" in item && item.since_signup) {
3365
- details.push({
3366
- text: `Member since: ${item.since_signup}`,
3367
- style: "dim"
3368
- });
3369
- }
3370
3398
  return {
3371
3399
  title: item.full_name,
3372
- id: item.id.toString(),
3400
+ id: item.id,
3373
3401
  details
3374
3402
  };
3375
3403
  }
@@ -3385,13 +3413,15 @@ var getProfilePlugin = ({ context }) => {
3385
3413
  authRequired: true
3386
3414
  }
3387
3415
  );
3388
- const { user_id: _unusedUserId, ...data } = profile;
3389
3416
  return {
3390
3417
  data: {
3391
- ...data,
3392
- // Pass through all API response fields
3393
- full_name: `${profile.first_name} ${profile.last_name}`
3394
- // Computed field
3418
+ id: String(profile.id),
3419
+ first_name: profile.first_name,
3420
+ last_name: profile.last_name,
3421
+ full_name: `${profile.first_name} ${profile.last_name}`,
3422
+ email: profile.email,
3423
+ email_confirmed: profile.email_confirmed,
3424
+ timezone: profile.timezone
3395
3425
  }
3396
3426
  };
3397
3427
  }
@@ -3863,11 +3893,17 @@ function normalizeAuthenticationItem2(auth, options = {}) {
3863
3893
  const {
3864
3894
  selected_api: selectedApi,
3865
3895
  customuser_id: profileId,
3896
+ id,
3897
+ account_id: accountId,
3866
3898
  ...restOfAuth
3867
3899
  } = auth;
3868
3900
  return {
3869
3901
  ...restOfAuth,
3870
3902
  // Pass through all other API response fields except selected_api
3903
+ id: String(id),
3904
+ // Convert to string
3905
+ account_id: String(accountId),
3906
+ // Convert to string
3871
3907
  implementation_id: selectedApi,
3872
3908
  // Rename selected_api to implementation_id
3873
3909
  title: auth.title || auth.label || void 0,
@@ -3880,8 +3916,8 @@ function normalizeAuthenticationItem2(auth, options = {}) {
3880
3916
  // App key from implementations endpoint or parsed from selected_api
3881
3917
  app_version: appVersion,
3882
3918
  // Version from selected_api or provided
3883
- profile_id: profileId
3884
- // Map customuser_id to profile_id
3919
+ profile_id: profileId != null ? String(profileId) : void 0
3920
+ // Map customuser_id to profile_id, convert to string
3885
3921
  };
3886
3922
  }
3887
3923
 
@@ -4880,70 +4916,73 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
4880
4916
  // src/plugins/eventEmission/transport.ts
4881
4917
  var DEFAULT_RETRY_ATTEMPTS = 2;
4882
4918
  var DEFAULT_RETRY_DELAY_MS = 300;
4883
- var HttpTransport = class {
4884
- constructor(config) {
4885
- this.config = config;
4886
- }
4887
- async emit(subject, event) {
4888
- try {
4889
- await this.emitWithRetry(
4890
- subject,
4891
- event,
4892
- this.config.retryAttempts || DEFAULT_RETRY_ATTEMPTS
4893
- );
4894
- } catch {
4895
- }
4896
- }
4897
- async emitWithRetry(subject, event, attemptsLeft) {
4919
+ function createHttpTransport(config) {
4920
+ const delay = async (ms) => {
4921
+ return new Promise((resolve2) => {
4922
+ const timer = setTimeout(resolve2, ms);
4923
+ if (typeof timer.unref === "function") {
4924
+ timer.unref();
4925
+ }
4926
+ });
4927
+ };
4928
+ const emitWithRetry = async (subject, event, attemptsLeft) => {
4898
4929
  try {
4899
4930
  const payload = {
4900
4931
  subject,
4901
4932
  properties: event
4902
4933
  };
4903
- const response = await fetch(this.config.endpoint, {
4934
+ const response = await fetch(config.endpoint, {
4904
4935
  method: "POST",
4905
4936
  headers: {
4906
4937
  "Content-Type": "application/json",
4907
- ...this.config.headers
4938
+ ...config.headers
4908
4939
  },
4909
4940
  body: JSON.stringify(payload)
4910
4941
  });
4911
4942
  if (!response.ok && attemptsLeft > 1) {
4912
- await this.delay(this.config.retryDelayMs || DEFAULT_RETRY_DELAY_MS);
4913
- return this.emitWithRetry(subject, event, attemptsLeft - 1);
4943
+ await delay(config.retryDelayMs || DEFAULT_RETRY_DELAY_MS);
4944
+ return emitWithRetry(subject, event, attemptsLeft - 1);
4914
4945
  }
4915
4946
  } catch (error) {
4916
4947
  if (attemptsLeft > 1) {
4917
- await this.delay(this.config.retryDelayMs || DEFAULT_RETRY_DELAY_MS);
4918
- return this.emitWithRetry(subject, event, attemptsLeft - 1);
4948
+ await delay(config.retryDelayMs || DEFAULT_RETRY_DELAY_MS);
4949
+ return emitWithRetry(subject, event, attemptsLeft - 1);
4919
4950
  }
4920
4951
  throw error;
4921
4952
  }
4922
- }
4923
- async delay(ms) {
4924
- return new Promise((resolve2) => {
4925
- const timer = setTimeout(resolve2, ms);
4926
- if (typeof timer.unref === "function") {
4927
- timer.unref();
4953
+ };
4954
+ return {
4955
+ async emit(subject, event) {
4956
+ try {
4957
+ await emitWithRetry(
4958
+ subject,
4959
+ event,
4960
+ config.retryAttempts || DEFAULT_RETRY_ATTEMPTS
4961
+ );
4962
+ } catch {
4928
4963
  }
4929
- });
4930
- }
4931
- };
4932
- var ConsoleTransport = class {
4933
- async emit(subject, event) {
4934
- try {
4935
- console.log(
4936
- "[SDK Telemetry]",
4937
- JSON.stringify({ subject, properties: event }, null, 2)
4938
- );
4939
- } catch {
4940
4964
  }
4941
- }
4942
- };
4943
- var NoopTransport = class {
4944
- async emit(_subject, _event) {
4945
- }
4946
- };
4965
+ };
4966
+ }
4967
+ function createConsoleTransport() {
4968
+ return {
4969
+ async emit(subject, event) {
4970
+ try {
4971
+ console.log(
4972
+ "[SDK Telemetry]",
4973
+ JSON.stringify({ subject, properties: event }, null, 2)
4974
+ );
4975
+ } catch {
4976
+ }
4977
+ }
4978
+ };
4979
+ }
4980
+ function createNoopTransport() {
4981
+ return {
4982
+ async emit(_subject, _event) {
4983
+ }
4984
+ };
4985
+ }
4947
4986
  function createTransport(config) {
4948
4987
  try {
4949
4988
  switch (config.type) {
@@ -4951,20 +4990,20 @@ function createTransport(config) {
4951
4990
  if (!config.endpoint) {
4952
4991
  throw new Error("HTTP transport requires endpoint");
4953
4992
  }
4954
- return new HttpTransport({
4993
+ return createHttpTransport({
4955
4994
  endpoint: config.endpoint,
4956
4995
  headers: config.headers,
4957
4996
  retryAttempts: config.retryAttempts,
4958
4997
  retryDelayMs: config.retryDelayMs
4959
4998
  });
4960
4999
  case "console":
4961
- return new ConsoleTransport();
5000
+ return createConsoleTransport();
4962
5001
  case "noop":
4963
5002
  default:
4964
- return new NoopTransport();
5003
+ return createNoopTransport();
4965
5004
  }
4966
5005
  } catch {
4967
- return new NoopTransport();
5006
+ return createNoopTransport();
4968
5007
  }
4969
5008
  }
4970
5009
  function generateEventId() {
@@ -5033,7 +5072,7 @@ function getCpuTime() {
5033
5072
 
5034
5073
  // package.json
5035
5074
  var package_default = {
5036
- version: "0.17.0"};
5075
+ version: "0.18.1"};
5037
5076
 
5038
5077
  // src/plugins/eventEmission/builders.ts
5039
5078
  function createBaseEvent(context = {}) {