@dereekb/nestjs 13.3.1 → 13.4.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 (59) hide show
  1. package/discord/index.cjs.js +31 -8
  2. package/discord/index.esm.js +31 -8
  3. package/discord/package.json +3 -3
  4. package/discord/src/lib/discord.api.d.ts +14 -0
  5. package/discord/src/lib/discord.api.page.d.ts +23 -5
  6. package/discord/src/lib/discord.module.d.ts +3 -0
  7. package/discord/src/lib/discord.util.d.ts +3 -0
  8. package/discord/src/lib/webhook/webhook.discord.d.ts +1 -0
  9. package/discord/src/lib/webhook/webhook.discord.module.d.ts +3 -0
  10. package/discord/src/lib/webhook/webhook.discord.verify.d.ts +1 -0
  11. package/index.cjs.js +52 -13
  12. package/index.esm.js +53 -14
  13. package/mailgun/index.cjs.js +58 -30
  14. package/mailgun/index.esm.js +59 -31
  15. package/mailgun/package.json +6 -6
  16. package/mailgun/src/lib/mailgun.api.d.ts +5 -3
  17. package/mailgun/src/lib/mailgun.d.ts +20 -4
  18. package/mailgun/src/lib/mailgun.service.d.ts +1 -0
  19. package/mailgun/src/lib/mailgun.service.module.d.ts +15 -0
  20. package/mailgun/src/lib/mailgun.util.d.ts +3 -0
  21. package/openai/index.cjs.js +31 -9
  22. package/openai/index.esm.js +31 -9
  23. package/openai/package.json +6 -6
  24. package/openai/src/lib/openai.module.d.ts +13 -0
  25. package/openai/src/lib/webhook/webhook.openai.module.d.ts +13 -0
  26. package/openai/src/lib/webhook/webhook.openai.verify.d.ts +3 -3
  27. package/package.json +2 -2
  28. package/src/lib/decorators/local.decorator.d.ts +8 -0
  29. package/src/lib/decorators/rawbody.d.ts +0 -13
  30. package/src/lib/module/client/client.module.d.ts +13 -0
  31. package/src/lib/module/env/env.config.d.ts +5 -4
  32. package/src/lib/module/env/env.d.ts +3 -1
  33. package/src/lib/module/env/env.nest.d.ts +8 -0
  34. package/src/lib/module/env/env.service.d.ts +2 -1
  35. package/src/lib/module/module.d.ts +11 -3
  36. package/src/lib/util/encryption/json.encrypt.d.ts +3 -0
  37. package/stripe/index.cjs.js +35 -8
  38. package/stripe/index.esm.js +35 -8
  39. package/stripe/package.json +6 -6
  40. package/stripe/src/lib/stripe.api.d.ts +11 -1
  41. package/stripe/src/lib/stripe.config.d.ts +4 -4
  42. package/stripe/src/lib/stripe.module.d.ts +13 -0
  43. package/stripe/src/lib/webhook/webhook.stripe.d.ts +10 -2
  44. package/typeform/index.cjs.js +56 -15
  45. package/typeform/index.esm.js +56 -15
  46. package/typeform/package.json +6 -6
  47. package/typeform/src/lib/typeform.module.d.ts +13 -0
  48. package/typeform/src/lib/typeform.type.d.ts +2 -2
  49. package/typeform/src/lib/typeform.util.d.ts +8 -0
  50. package/typeform/src/lib/webhook/webhook.typeform.form.d.ts +11 -1
  51. package/typeform/src/lib/webhook/webhook.typeform.module.d.ts +13 -0
  52. package/typeform/src/lib/webhook/webhook.typeform.verify.d.ts +2 -2
  53. package/vapiai/index.cjs.js +35 -13
  54. package/vapiai/index.esm.js +35 -13
  55. package/vapiai/package.json +6 -6
  56. package/vapiai/src/lib/vapiai.api.d.ts +2 -2
  57. package/vapiai/src/lib/vapiai.module.d.ts +13 -0
  58. package/vapiai/src/lib/webhook/webhook.vapiai.module.d.ts +13 -0
  59. package/vapiai/src/lib/webhook/webhook.vapiai.verify.d.ts +5 -3
@@ -59,6 +59,7 @@ function _object_spread_props$1(target, source) {
59
59
  * Casts an untyped Discord interaction to a typed one.
60
60
  *
61
61
  * @param interaction - the raw interaction to cast
62
+ * @returns the interaction cast to the specified typed DiscordWebhookInteraction
62
63
  */ function discordWebhookInteraction(interaction) {
63
64
  return interaction;
64
65
  }
@@ -292,6 +293,7 @@ function _ts_generator$3(thisArg, body) {
292
293
  * Uses Node.js built-in crypto with JWK key import — no external dependencies required.
293
294
  *
294
295
  * @param config - verification config containing the application's public key
296
+ * @returns a DiscordWebhookEventVerifier function that validates Ed25519-signed requests
295
297
  *
296
298
  * @example
297
299
  * ```ts
@@ -811,6 +813,9 @@ function _class_call_check$3(instance, Constructor) {
811
813
  }
812
814
  /**
813
815
  * Factory that creates a DiscordWebhookServiceConfig from environment variables.
816
+ *
817
+ * @param configService - the NestJS config service used to read the Discord public key environment variable
818
+ * @returns a validated DiscordWebhookServiceConfig populated from environment variables
814
819
  */ function discordWebhookServiceConfigFactory(configService) {
815
820
  var config = {
816
821
  discordWebhook: {
@@ -1127,7 +1132,9 @@ function _ts_generator(thisArg, body) {
1127
1132
  _this = this;
1128
1133
  _this_config_discord = this.config.discord, _this_config_discord_autoLogin = _this_config_discord.autoLogin, autoLogin = _this_config_discord_autoLogin === void 0 ? true : _this_config_discord_autoLogin, botToken = _this_config_discord.botToken;
1129
1134
  if (autoLogin) {
1130
- result = this.client.login(botToken).then(function() {}).catch(function(e) {
1135
+ result = this.client.login(botToken).then(function() {
1136
+ return undefined;
1137
+ }).catch(function(e) {
1131
1138
  _this.logger.error('Failed to log in to Discord', e);
1132
1139
  });
1133
1140
  } else {
@@ -1168,6 +1175,13 @@ function _ts_generator(thisArg, body) {
1168
1175
  * ```ts
1169
1176
  * const message = await discordApi.sendMessage('123456789', 'Hello from the bot!');
1170
1177
  * ```
1178
+ */ /**
1179
+ * Sends a text message to the specified Discord channel.
1180
+ *
1181
+ * @param channelId - target channel's snowflake ID
1182
+ * @param content - message text to send
1183
+ * @returns the sent Discord Message
1184
+ * @throws {Error} when the channel is not found or is not a text channel
1171
1185
  */ function sendMessage(channelId, content) {
1172
1186
  return _async_to_generator(function() {
1173
1187
  var channel;
@@ -1211,6 +1225,11 @@ function _ts_generator(thisArg, body) {
1211
1225
  * // Later, to stop listening:
1212
1226
  * unsubscribe();
1213
1227
  * ```
1228
+ */ /**
1229
+ * Registers a handler for incoming Discord messages (MessageCreate event).
1230
+ *
1231
+ * @param handler - callback invoked for each incoming Message
1232
+ * @returns an unsubscribe function that removes the registered handler
1214
1233
  */ key: "onMessage",
1215
1234
  value: function onMessage(handler) {
1216
1235
  var _this = this;
@@ -1235,6 +1254,9 @@ function _class_call_check(instance, Constructor) {
1235
1254
  }
1236
1255
  /**
1237
1256
  * Factory that creates a DiscordServiceConfig from environment variables.
1257
+ *
1258
+ * @param configService - the NestJS config service used to read Discord environment variables
1259
+ * @returns a validated DiscordServiceConfig populated from environment variables
1238
1260
  */ function discordServiceConfigFactory(configService) {
1239
1261
  var config = {
1240
1262
  discord: {
@@ -1330,14 +1352,12 @@ function _object_spread_props(target, source) {
1330
1352
  * message's ID from each response and sets it as the `before` cursor for the next request.
1331
1353
  * When the number of returned messages is less than the requested limit, pagination stops.
1332
1354
  *
1333
- * @param fetch - The Discord fetch function to paginate over
1334
- * @param config - Optional config for reading message IDs
1335
- * @param defaults - Optional default configuration for the page factory
1355
+ * @param input - The factory input configuration
1336
1356
  * @returns A page factory that produces iterable page fetchers
1337
1357
  *
1338
1358
  * @example
1339
1359
  * ```typescript
1340
- * const pageFactory = discordFetchMessagePageFactory(fetchChannelMessages);
1360
+ * const pageFactory = discordFetchMessagePageFactory({ fetch: fetchChannelMessages });
1341
1361
  *
1342
1362
  * const fetchPage = pageFactory({ limit: 50 });
1343
1363
  * const firstPage = await fetchPage.fetchNext();
@@ -1346,8 +1366,9 @@ function _object_spread_props(target, source) {
1346
1366
  * const secondPage = await firstPage.fetchNext();
1347
1367
  * }
1348
1368
  * ```
1349
- */ function discordFetchMessagePageFactory(fetch$1, config, defaults) {
1369
+ */ function discordFetchMessagePageFactory(input) {
1350
1370
  var _ref;
1371
+ var fetch$1 = input.fetch, config = input.config, defaults = input.defaults;
1351
1372
  var readMessageId = (_ref = config === null || config === void 0 ? void 0 : config.readMessageId) !== null && _ref !== void 0 ? _ref : function(message) {
1352
1373
  return message.id;
1353
1374
  };
@@ -1355,8 +1376,7 @@ function _object_spread_props(target, source) {
1355
1376
  fetch: fetch$1,
1356
1377
  readFetchPageResultInfo: function readFetchPageResultInfo(result) {
1357
1378
  var count = result.data.length;
1358
- var lastMessage = util.lastValue(result.data);
1359
- var nextCursor = lastMessage ? readMessageId(lastMessage) : undefined;
1379
+ var nextCursor = count > 0 ? readMessageId(util.lastValue(result.data)) : undefined;
1360
1380
  return {
1361
1381
  hasNext: count > 0,
1362
1382
  nextPageCursor: nextCursor
@@ -1412,6 +1432,8 @@ function _unsupported_iterable_to_array(o, minLen) {
1412
1432
  *
1413
1433
  * Includes Guilds, GuildMessages, and MessageContent intents.
1414
1434
  *
1435
+ * @returns partial ClientOptions with the default bot intents set
1436
+ *
1415
1437
  * @example
1416
1438
  * ```ts
1417
1439
  * const options = discordDefaultClientOptions();
@@ -1426,6 +1448,7 @@ function _unsupported_iterable_to_array(o, minLen) {
1426
1448
  * Returns ClientOptions with additional intents merged with the defaults.
1427
1449
  *
1428
1450
  * @param additionalIntents - extra intents to include beyond the defaults
1451
+ * @returns partial ClientOptions with the merged intent list
1429
1452
  *
1430
1453
  * @example
1431
1454
  * ```ts
@@ -57,6 +57,7 @@ function _object_spread_props$1(target, source) {
57
57
  * Casts an untyped Discord interaction to a typed one.
58
58
  *
59
59
  * @param interaction - the raw interaction to cast
60
+ * @returns the interaction cast to the specified typed DiscordWebhookInteraction
60
61
  */ function discordWebhookInteraction(interaction) {
61
62
  return interaction;
62
63
  }
@@ -290,6 +291,7 @@ function _ts_generator$3(thisArg, body) {
290
291
  * Uses Node.js built-in crypto with JWK key import — no external dependencies required.
291
292
  *
292
293
  * @param config - verification config containing the application's public key
294
+ * @returns a DiscordWebhookEventVerifier function that validates Ed25519-signed requests
293
295
  *
294
296
  * @example
295
297
  * ```ts
@@ -809,6 +811,9 @@ function _class_call_check$3(instance, Constructor) {
809
811
  }
810
812
  /**
811
813
  * Factory that creates a DiscordWebhookServiceConfig from environment variables.
814
+ *
815
+ * @param configService - the NestJS config service used to read the Discord public key environment variable
816
+ * @returns a validated DiscordWebhookServiceConfig populated from environment variables
812
817
  */ function discordWebhookServiceConfigFactory(configService) {
813
818
  var config = {
814
819
  discordWebhook: {
@@ -1125,7 +1130,9 @@ function _ts_generator(thisArg, body) {
1125
1130
  _this = this;
1126
1131
  _this_config_discord = this.config.discord, _this_config_discord_autoLogin = _this_config_discord.autoLogin, autoLogin = _this_config_discord_autoLogin === void 0 ? true : _this_config_discord_autoLogin, botToken = _this_config_discord.botToken;
1127
1132
  if (autoLogin) {
1128
- result = this.client.login(botToken).then(function() {}).catch(function(e) {
1133
+ result = this.client.login(botToken).then(function() {
1134
+ return undefined;
1135
+ }).catch(function(e) {
1129
1136
  _this.logger.error('Failed to log in to Discord', e);
1130
1137
  });
1131
1138
  } else {
@@ -1166,6 +1173,13 @@ function _ts_generator(thisArg, body) {
1166
1173
  * ```ts
1167
1174
  * const message = await discordApi.sendMessage('123456789', 'Hello from the bot!');
1168
1175
  * ```
1176
+ */ /**
1177
+ * Sends a text message to the specified Discord channel.
1178
+ *
1179
+ * @param channelId - target channel's snowflake ID
1180
+ * @param content - message text to send
1181
+ * @returns the sent Discord Message
1182
+ * @throws {Error} when the channel is not found or is not a text channel
1169
1183
  */ function sendMessage(channelId, content) {
1170
1184
  return _async_to_generator(function() {
1171
1185
  var channel;
@@ -1209,6 +1223,11 @@ function _ts_generator(thisArg, body) {
1209
1223
  * // Later, to stop listening:
1210
1224
  * unsubscribe();
1211
1225
  * ```
1226
+ */ /**
1227
+ * Registers a handler for incoming Discord messages (MessageCreate event).
1228
+ *
1229
+ * @param handler - callback invoked for each incoming Message
1230
+ * @returns an unsubscribe function that removes the registered handler
1212
1231
  */ key: "onMessage",
1213
1232
  value: function onMessage(handler) {
1214
1233
  var _this = this;
@@ -1233,6 +1252,9 @@ function _class_call_check(instance, Constructor) {
1233
1252
  }
1234
1253
  /**
1235
1254
  * Factory that creates a DiscordServiceConfig from environment variables.
1255
+ *
1256
+ * @param configService - the NestJS config service used to read Discord environment variables
1257
+ * @returns a validated DiscordServiceConfig populated from environment variables
1236
1258
  */ function discordServiceConfigFactory(configService) {
1237
1259
  var config = {
1238
1260
  discord: {
@@ -1328,14 +1350,12 @@ function _object_spread_props(target, source) {
1328
1350
  * message's ID from each response and sets it as the `before` cursor for the next request.
1329
1351
  * When the number of returned messages is less than the requested limit, pagination stops.
1330
1352
  *
1331
- * @param fetch - The Discord fetch function to paginate over
1332
- * @param config - Optional config for reading message IDs
1333
- * @param defaults - Optional default configuration for the page factory
1353
+ * @param input - The factory input configuration
1334
1354
  * @returns A page factory that produces iterable page fetchers
1335
1355
  *
1336
1356
  * @example
1337
1357
  * ```typescript
1338
- * const pageFactory = discordFetchMessagePageFactory(fetchChannelMessages);
1358
+ * const pageFactory = discordFetchMessagePageFactory({ fetch: fetchChannelMessages });
1339
1359
  *
1340
1360
  * const fetchPage = pageFactory({ limit: 50 });
1341
1361
  * const firstPage = await fetchPage.fetchNext();
@@ -1344,8 +1364,9 @@ function _object_spread_props(target, source) {
1344
1364
  * const secondPage = await firstPage.fetchNext();
1345
1365
  * }
1346
1366
  * ```
1347
- */ function discordFetchMessagePageFactory(fetch, config, defaults) {
1367
+ */ function discordFetchMessagePageFactory(input) {
1348
1368
  var _ref;
1369
+ var fetch = input.fetch, config = input.config, defaults = input.defaults;
1349
1370
  var readMessageId = (_ref = config === null || config === void 0 ? void 0 : config.readMessageId) !== null && _ref !== void 0 ? _ref : function(message) {
1350
1371
  return message.id;
1351
1372
  };
@@ -1353,8 +1374,7 @@ function _object_spread_props(target, source) {
1353
1374
  fetch: fetch,
1354
1375
  readFetchPageResultInfo: function readFetchPageResultInfo(result) {
1355
1376
  var count = result.data.length;
1356
- var lastMessage = lastValue(result.data);
1357
- var nextCursor = lastMessage ? readMessageId(lastMessage) : undefined;
1377
+ var nextCursor = count > 0 ? readMessageId(lastValue(result.data)) : undefined;
1358
1378
  return {
1359
1379
  hasNext: count > 0,
1360
1380
  nextPageCursor: nextCursor
@@ -1410,6 +1430,8 @@ function _unsupported_iterable_to_array(o, minLen) {
1410
1430
  *
1411
1431
  * Includes Guilds, GuildMessages, and MessageContent intents.
1412
1432
  *
1433
+ * @returns partial ClientOptions with the default bot intents set
1434
+ *
1413
1435
  * @example
1414
1436
  * ```ts
1415
1437
  * const options = discordDefaultClientOptions();
@@ -1424,6 +1446,7 @@ function _unsupported_iterable_to_array(o, minLen) {
1424
1446
  * Returns ClientOptions with additional intents merged with the defaults.
1425
1447
  *
1426
1448
  * @param additionalIntents - extra intents to include beyond the defaults
1449
+ * @returns partial ClientOptions with the merged intent list
1427
1450
  *
1428
1451
  * @example
1429
1452
  * ```ts
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/discord",
3
- "version": "13.3.1",
3
+ "version": "13.4.1",
4
4
  "peerDependencies": {
5
- "@dereekb/nestjs": "13.3.1",
6
- "@dereekb/util": "13.3.1",
5
+ "@dereekb/nestjs": "13.4.1",
6
+ "@dereekb/util": "13.4.1",
7
7
  "@nestjs/common": "^11.1.16",
8
8
  "@nestjs/config": "^4.0.3",
9
9
  "discord.js": "^14.25.1",
@@ -31,6 +31,14 @@ export declare class DiscordApi implements OnModuleInit, OnModuleDestroy {
31
31
  * const message = await discordApi.sendMessage('123456789', 'Hello from the bot!');
32
32
  * ```
33
33
  */
34
+ /**
35
+ * Sends a text message to the specified Discord channel.
36
+ *
37
+ * @param channelId - target channel's snowflake ID
38
+ * @param content - message text to send
39
+ * @returns the sent Discord Message
40
+ * @throws {Error} when the channel is not found or is not a text channel
41
+ */
34
42
  sendMessage(channelId: DiscordChannelId, content: string): Promise<Message>;
35
43
  /**
36
44
  * Registers a handler for the MessageCreate event (incoming messages).
@@ -51,5 +59,11 @@ export declare class DiscordApi implements OnModuleInit, OnModuleDestroy {
51
59
  * unsubscribe();
52
60
  * ```
53
61
  */
62
+ /**
63
+ * Registers a handler for incoming Discord messages (MessageCreate event).
64
+ *
65
+ * @param handler - callback invoked for each incoming Message
66
+ * @returns an unsubscribe function that removes the registered handler
67
+ */
54
68
  onMessage(handler: (message: Message) => void): () => void;
55
69
  }
@@ -60,6 +60,26 @@ export interface DiscordFetchMessagePageFactoryConfig<T> {
60
60
  */
61
61
  readonly readMessageId?: (message: T) => DiscordMessageId;
62
62
  }
63
+ /**
64
+ * Configuration for {@link discordFetchMessagePageFactory}.
65
+ *
66
+ * @typeParam I - The input filter type
67
+ * @typeParam T - The message type
68
+ */
69
+ export interface DiscordFetchMessagePageFactoryInput<I extends DiscordMessagePageFilter, T> {
70
+ /**
71
+ * The Discord fetch function to paginate over.
72
+ */
73
+ readonly fetch: DiscordFetchMessagePageFetchFunction<I, T>;
74
+ /**
75
+ * Optional config for reading message IDs.
76
+ */
77
+ readonly config?: Maybe<DiscordFetchMessagePageFactoryConfig<T>>;
78
+ /**
79
+ * Optional default configuration for the page factory.
80
+ */
81
+ readonly defaults?: Maybe<FetchPageFactoryConfigDefaults>;
82
+ }
63
83
  /**
64
84
  * Creates a page factory that wraps a Discord message fetch function with automatic cursor-based pagination.
65
85
  *
@@ -67,14 +87,12 @@ export interface DiscordFetchMessagePageFactoryConfig<T> {
67
87
  * message's ID from each response and sets it as the `before` cursor for the next request.
68
88
  * When the number of returned messages is less than the requested limit, pagination stops.
69
89
  *
70
- * @param fetch - The Discord fetch function to paginate over
71
- * @param config - Optional config for reading message IDs
72
- * @param defaults - Optional default configuration for the page factory
90
+ * @param input - The factory input configuration
73
91
  * @returns A page factory that produces iterable page fetchers
74
92
  *
75
93
  * @example
76
94
  * ```typescript
77
- * const pageFactory = discordFetchMessagePageFactory(fetchChannelMessages);
95
+ * const pageFactory = discordFetchMessagePageFactory({ fetch: fetchChannelMessages });
78
96
  *
79
97
  * const fetchPage = pageFactory({ limit: 50 });
80
98
  * const firstPage = await fetchPage.fetchNext();
@@ -86,4 +104,4 @@ export interface DiscordFetchMessagePageFactoryConfig<T> {
86
104
  */
87
105
  export declare function discordFetchMessagePageFactory<I extends DiscordMessagePageFilter, T extends {
88
106
  id: string;
89
- }>(fetch: DiscordFetchMessagePageFetchFunction<I, T>, config?: Maybe<DiscordFetchMessagePageFactoryConfig<T>>, defaults?: Maybe<FetchPageFactoryConfigDefaults>): FetchPageFactory<I, DiscordMessagePageResult<T>>;
107
+ }>(input: DiscordFetchMessagePageFactoryInput<I, T>): FetchPageFactory<I, DiscordMessagePageResult<T>>;
@@ -2,6 +2,9 @@ import { ConfigService } from '@nestjs/config';
2
2
  import { DiscordServiceConfig } from './discord.config';
3
3
  /**
4
4
  * Factory that creates a DiscordServiceConfig from environment variables.
5
+ *
6
+ * @param configService - the NestJS config service used to read Discord environment variables
7
+ * @returns a validated DiscordServiceConfig populated from environment variables
5
8
  */
6
9
  export declare function discordServiceConfigFactory(configService: ConfigService): DiscordServiceConfig;
7
10
  /**
@@ -4,6 +4,8 @@ import { type GatewayIntentBits, type ClientOptions } from 'discord.js';
4
4
  *
5
5
  * Includes Guilds, GuildMessages, and MessageContent intents.
6
6
  *
7
+ * @returns partial ClientOptions with the default bot intents set
8
+ *
7
9
  * @example
8
10
  * ```ts
9
11
  * const options = discordDefaultClientOptions();
@@ -15,6 +17,7 @@ export declare function discordDefaultClientOptions(): Partial<ClientOptions>;
15
17
  * Returns ClientOptions with additional intents merged with the defaults.
16
18
  *
17
19
  * @param additionalIntents - extra intents to include beyond the defaults
20
+ * @returns partial ClientOptions with the merged intent list
18
21
  *
19
22
  * @example
20
23
  * ```ts
@@ -21,6 +21,7 @@ export type DiscordWebhookInteraction<T extends Interaction = Interaction> = T;
21
21
  * Casts an untyped Discord interaction to a typed one.
22
22
  *
23
23
  * @param interaction - the raw interaction to cast
24
+ * @returns the interaction cast to the specified typed DiscordWebhookInteraction
24
25
  */
25
26
  export declare function discordWebhookInteraction<T extends Interaction = Interaction>(interaction: UntypedDiscordInteraction): DiscordWebhookInteraction<T>;
26
27
  export type DiscordInteractionHandler = Handler<UntypedDiscordInteraction, DiscordInteractionType>;
@@ -2,6 +2,9 @@ import { ConfigService } from '@nestjs/config';
2
2
  import { DiscordWebhookServiceConfig } from './webhook.discord.config';
3
3
  /**
4
4
  * Factory that creates a DiscordWebhookServiceConfig from environment variables.
5
+ *
6
+ * @param configService - the NestJS config service used to read the Discord public key environment variable
7
+ * @returns a validated DiscordWebhookServiceConfig populated from environment variables
5
8
  */
6
9
  export declare function discordWebhookServiceConfigFactory(configService: ConfigService): DiscordWebhookServiceConfig;
7
10
  /**
@@ -31,6 +31,7 @@ export type DiscordWebhookEventVerifier = (req: Request, rawBody: Buffer) => Pro
31
31
  * Uses Node.js built-in crypto with JWK key import — no external dependencies required.
32
32
  *
33
33
  * @param config - verification config containing the application's public key
34
+ * @returns a DiscordWebhookEventVerifier function that validates Ed25519-signed requests
34
35
  *
35
36
  * @example
36
37
  * ```ts
package/index.cjs.js CHANGED
@@ -13,7 +13,14 @@ var crypto = require('crypto');
13
13
  */ var IsRequestFromLocalHost = common.createParamDecorator(function(data, context) {
14
14
  return isLocalhost(context);
15
15
  });
16
- function isLocalhost(context) {
16
+ /**
17
+ * Returns true if the request's origin header indicates the request came from localhost.
18
+ *
19
+ * Checks for both http://localhost and https://localhost origins.
20
+ *
21
+ * @param context - the NestJS execution context containing the HTTP request
22
+ * @returns true if the request origin is localhost
23
+ */ function isLocalhost(context) {
17
24
  var _req_headers_origin;
18
25
  var req = context.switchToHttp().getRequest();
19
26
  var origin = (_req_headers_origin = req.headers['origin']) !== null && _req_headers_origin !== void 0 ? _req_headers_origin : '';
@@ -160,7 +167,8 @@ function _ts_generator(thisArg, body) {
160
167
  * @Post('webhook')
161
168
  * handleWebhook(@ParseRawBody() body: RawBodyBuffer) { ... }
162
169
  * ```
163
- */ var ParseRawBody = common.createParamDecorator(function(_, context) {
170
+ */ var rawBodyLogger = new common.Logger('RawBody');
171
+ var ParseRawBody = common.createParamDecorator(function(_, context) {
164
172
  return _async_to_generator(function() {
165
173
  var req, body;
166
174
  return _ts_generator(this, function(_state) {
@@ -168,7 +176,7 @@ function _ts_generator(thisArg, body) {
168
176
  case 0:
169
177
  req = context.switchToHttp().getRequest();
170
178
  if (!req.readable) {
171
- console.error('RawBody request was not readable. This is generally due to bad configuration.');
179
+ rawBodyLogger.error('RawBody request was not readable. This is generally due to bad configuration.');
172
180
  throw new common.BadRequestException('Invalid body');
173
181
  }
174
182
  return [
@@ -204,7 +212,7 @@ function _ts_generator(thisArg, body) {
204
212
  req = context.switchToHttp().getRequest();
205
213
  body = req.body;
206
214
  if (!Buffer.isBuffer(body)) {
207
- console.error('RawBody expected a buffer set to req.body.');
215
+ rawBodyLogger.error('RawBody expected a buffer set to req.body.');
208
216
  throw new common.InternalServerErrorException('failed parsing body');
209
217
  }
210
218
  return [
@@ -556,9 +564,9 @@ function _type_of(obj) {
556
564
  /**
557
565
  * Merges two module metadata entries together.
558
566
  *
559
- * @param base
560
- * @param additional
561
- * @returns
567
+ * @param base - the base module metadata
568
+ * @param additional - additional metadata to merge in
569
+ * @returns the merged module metadata
562
570
  */ function mergeModuleMetadata(base) {
563
571
  var additional = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
564
572
  return {
@@ -580,7 +588,14 @@ function _type_of(obj) {
580
588
  ])
581
589
  };
582
590
  }
583
- function injectionTokensFromProviders(providers) {
591
+ /**
592
+ * Extracts the injection tokens from an array (or single value) of NestJS Providers.
593
+ *
594
+ * For class providers, returns the class itself; for object providers, returns the provide token.
595
+ *
596
+ * @param providers - the providers to extract tokens from
597
+ * @returns an array of injection tokens
598
+ */ function injectionTokensFromProviders(providers) {
584
599
  return util.asArray(providers).map(function(x) {
585
600
  return (typeof x === "undefined" ? "undefined" : _type_of(x)) === 'object' ? x.provide : x;
586
601
  });
@@ -720,7 +735,14 @@ function _class_call_check$2(instance, Constructor) {
720
735
  throw new TypeError("Cannot call a class as a function");
721
736
  }
722
737
  }
723
- function clientAppConfigFactory(configService) {
738
+ /**
739
+ * Factory that creates a ClientAppServiceConfig from environment variables.
740
+ *
741
+ * Reads the client web app URL from the CLIENT_WEB_APP_URL environment variable.
742
+ *
743
+ * @param configService - NestJS config service for reading environment variables
744
+ * @returns a validated ClientAppServiceConfig
745
+ */ function clientAppConfigFactory(configService) {
724
746
  var config = {
725
747
  client: {
726
748
  clientWebAppUrl: configService.get(CLIENT_WEB_APP_URL_ENV_VAR)
@@ -729,7 +751,11 @@ function clientAppConfigFactory(configService) {
729
751
  ClientAppServiceConfig.assertValidConfig(config);
730
752
  return config;
731
753
  }
732
- exports.ClientAppModule = function ClientAppModule() {
754
+ /**
755
+ * NestJS module that provides the ClientAppService for accessing client application configuration.
756
+ *
757
+ * Reads the client web app URL from environment variables and makes it available via ClientAppService.
758
+ */ exports.ClientAppModule = function ClientAppModule() {
733
759
  _class_call_check$2(this, ClientAppModule);
734
760
  };
735
761
  exports.ClientAppModule = __decorate([
@@ -744,7 +770,8 @@ exports.ClientAppModule = __decorate([
744
770
  config.ConfigService
745
771
  ],
746
772
  useFactory: clientAppConfigFactory
747
- }
773
+ },
774
+ exports.ClientAppService
748
775
  ],
749
776
  exports: [
750
777
  exports.ClientAppService
@@ -772,7 +799,14 @@ function _class_call_check$1(instance, Constructor) {
772
799
  /**
773
800
  * Token to access a configured ServerEnvironmentServiceConfig for the app.
774
801
  */ var SERVER_ENV_TOKEN = 'SERVER_ENV_TOKEN';
775
- function serverEnvTokenProvider(env) {
802
+ /**
803
+ * Creates a NestJS Provider that supplies a ServerEnvironmentConfig under the SERVER_ENV_TOKEN injection token.
804
+ *
805
+ * Use this to register a server environment configuration instance with the NestJS dependency injection container.
806
+ *
807
+ * @param env - the server environment config to provide
808
+ * @returns a NestJS Provider that supplies the config under SERVER_ENV_TOKEN
809
+ */ function serverEnvTokenProvider(env) {
776
810
  return {
777
811
  provide: SERVER_ENV_TOKEN,
778
812
  useValue: env
@@ -780,7 +814,9 @@ function serverEnvTokenProvider(env) {
780
814
  }
781
815
 
782
816
  /**
783
- * Checks process.env.NODE_ENV for "test"
817
+ * Checks process.env.NODE_ENV for "test".
818
+ *
819
+ * @returns true if the current Node environment is "test", false otherwise
784
820
  */ function isTestNodeEnv() {
785
821
  return process.env['NODE_ENV'] === 'test';
786
822
  }
@@ -871,6 +907,9 @@ var ENCRYPTED_FIELD_KEY_LENGTH = 32;
871
907
  /**
872
908
  * Validates that the given secret is a 64-character hexadecimal string (32 bytes for AES-256).
873
909
  *
910
+ * @param secret - the hex-encoded secret key string to validate
911
+ * @returns true if the secret is exactly 64 valid hex characters, false otherwise
912
+ *
874
913
  * @example
875
914
  * ```typescript
876
915
  * isValidAES256GCMEncryptionSecret('a'.repeat(64)); // true