@dereekb/nestjs 13.12.5 → 13.12.7

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.
@@ -899,6 +899,27 @@ function _define_property$2(obj, key, value) {
899
899
  /**
900
900
  * Default environment variable for the Discord bot token.
901
901
  */ var DISCORD_BOT_TOKEN_ENV_VAR = 'DISCORD_BOT_TOKEN';
902
+ /**
903
+ * Placeholder bot token value used in development and CI environments where a real Discord
904
+ * login should not be attempted. Mirrors the value used in the workspace's .env file.
905
+ */ var DISCORD_BOT_TOKEN_PLACEHOLDER = 'placeholder';
906
+ /**
907
+ * Returns true if the input is a real, usable Discord bot token.
908
+ *
909
+ * A token is usable when it is non-empty and is not the shared placeholder value, allowing
910
+ * non-production environments to skip a real gateway login that would always fail.
911
+ *
912
+ * @param botToken - The bot token read from configuration, if any.
913
+ * @returns True when the token should be used to log in.
914
+ *
915
+ * @example
916
+ * ```ts
917
+ * isUsableDiscordBotToken('placeholder'); // false
918
+ * isUsableDiscordBotToken('real-token'); // true
919
+ * ```
920
+ */ function isUsableDiscordBotToken(botToken) {
921
+ return Boolean(botToken) && botToken !== DISCORD_BOT_TOKEN_PLACEHOLDER;
922
+ }
902
923
  /**
903
924
  * Default gateway intents for a bot that reads guild messages.
904
925
  *
@@ -1264,13 +1285,18 @@ function _class_call_check(instance, Constructor) {
1264
1285
  /**
1265
1286
  * Factory that creates a DiscordServiceConfig from environment variables.
1266
1287
  *
1288
+ * autoLogin is enabled only when a real bot token is configured and the process is not running
1289
+ * under a test environment, so development and CI runs (which use a placeholder token) never
1290
+ * attempt a real gateway login that would fail.
1291
+ *
1267
1292
  * @param configService - The NestJS config service used to read Discord environment variables.
1268
1293
  * @returns A validated DiscordServiceConfig populated from environment variables.
1269
1294
  */ function discordServiceConfigFactory(configService) {
1295
+ var botToken = configService.get(DISCORD_BOT_TOKEN_ENV_VAR);
1270
1296
  var config = {
1271
1297
  discord: {
1272
- botToken: configService.get(DISCORD_BOT_TOKEN_ENV_VAR),
1273
- autoLogin: true
1298
+ botToken: botToken,
1299
+ autoLogin: isUsableDiscordBotToken(botToken) && !nestjs.isTestNodeEnv()
1274
1300
  }
1275
1301
  };
1276
1302
  DiscordServiceConfig.assertValidConfig(config);
@@ -1476,6 +1502,7 @@ function _unsupported_iterable_to_array(o, minLen) {
1476
1502
  exports.DEFAULT_DISCORD_INTENTS = DEFAULT_DISCORD_INTENTS;
1477
1503
  exports.DEFAULT_DISCORD_MESSAGES_PER_PAGE = DEFAULT_DISCORD_MESSAGES_PER_PAGE;
1478
1504
  exports.DISCORD_BOT_TOKEN_ENV_VAR = DISCORD_BOT_TOKEN_ENV_VAR;
1505
+ exports.DISCORD_BOT_TOKEN_PLACEHOLDER = DISCORD_BOT_TOKEN_PLACEHOLDER;
1479
1506
  exports.DISCORD_ED25519_PUBLIC_KEY_BYTE_LENGTH = DISCORD_ED25519_PUBLIC_KEY_BYTE_LENGTH;
1480
1507
  exports.DISCORD_PUBLIC_KEY_ENV_VAR = DISCORD_PUBLIC_KEY_ENV_VAR;
1481
1508
  exports.DiscordServiceConfig = DiscordServiceConfig;
@@ -1489,3 +1516,4 @@ exports.discordServiceConfigFactory = discordServiceConfigFactory;
1489
1516
  exports.discordWebhookEventVerifier = discordWebhookEventVerifier;
1490
1517
  exports.discordWebhookInteraction = discordWebhookInteraction;
1491
1518
  exports.discordWebhookServiceConfigFactory = discordWebhookServiceConfigFactory;
1519
+ exports.isUsableDiscordBotToken = isUsableDiscordBotToken;
@@ -1,6 +1,6 @@
1
1
  import { handlerFactory, handlerConfigurerFactory, handlerMappedSetFunctionFactory, isHexWithByteLength, lastValue } from '@dereekb/util';
2
2
  import { InteractionType, GatewayIntentBits, Client, Events, TextChannel } from 'discord.js';
3
- import { RawBody } from '@dereekb/nestjs';
3
+ import { RawBody, isTestNodeEnv } from '@dereekb/nestjs';
4
4
  import { Injectable, Inject, Logger, Post, Req, Controller, Module } from '@nestjs/common';
5
5
  import { createPublicKey, verify } from 'node:crypto';
6
6
  import { ConfigService, ConfigModule } from '@nestjs/config';
@@ -897,6 +897,27 @@ function _define_property$2(obj, key, value) {
897
897
  /**
898
898
  * Default environment variable for the Discord bot token.
899
899
  */ var DISCORD_BOT_TOKEN_ENV_VAR = 'DISCORD_BOT_TOKEN';
900
+ /**
901
+ * Placeholder bot token value used in development and CI environments where a real Discord
902
+ * login should not be attempted. Mirrors the value used in the workspace's .env file.
903
+ */ var DISCORD_BOT_TOKEN_PLACEHOLDER = 'placeholder';
904
+ /**
905
+ * Returns true if the input is a real, usable Discord bot token.
906
+ *
907
+ * A token is usable when it is non-empty and is not the shared placeholder value, allowing
908
+ * non-production environments to skip a real gateway login that would always fail.
909
+ *
910
+ * @param botToken - The bot token read from configuration, if any.
911
+ * @returns True when the token should be used to log in.
912
+ *
913
+ * @example
914
+ * ```ts
915
+ * isUsableDiscordBotToken('placeholder'); // false
916
+ * isUsableDiscordBotToken('real-token'); // true
917
+ * ```
918
+ */ function isUsableDiscordBotToken(botToken) {
919
+ return Boolean(botToken) && botToken !== DISCORD_BOT_TOKEN_PLACEHOLDER;
920
+ }
900
921
  /**
901
922
  * Default gateway intents for a bot that reads guild messages.
902
923
  *
@@ -1262,13 +1283,18 @@ function _class_call_check(instance, Constructor) {
1262
1283
  /**
1263
1284
  * Factory that creates a DiscordServiceConfig from environment variables.
1264
1285
  *
1286
+ * autoLogin is enabled only when a real bot token is configured and the process is not running
1287
+ * under a test environment, so development and CI runs (which use a placeholder token) never
1288
+ * attempt a real gateway login that would fail.
1289
+ *
1265
1290
  * @param configService - The NestJS config service used to read Discord environment variables.
1266
1291
  * @returns A validated DiscordServiceConfig populated from environment variables.
1267
1292
  */ function discordServiceConfigFactory(configService) {
1293
+ var botToken = configService.get(DISCORD_BOT_TOKEN_ENV_VAR);
1268
1294
  var config = {
1269
1295
  discord: {
1270
- botToken: configService.get(DISCORD_BOT_TOKEN_ENV_VAR),
1271
- autoLogin: true
1296
+ botToken: botToken,
1297
+ autoLogin: isUsableDiscordBotToken(botToken) && !isTestNodeEnv()
1272
1298
  }
1273
1299
  };
1274
1300
  DiscordServiceConfig.assertValidConfig(config);
@@ -1471,4 +1497,4 @@ function _unsupported_iterable_to_array(o, minLen) {
1471
1497
  };
1472
1498
  }
1473
1499
 
1474
- export { DEFAULT_DISCORD_INTENTS, DEFAULT_DISCORD_MESSAGES_PER_PAGE, DISCORD_BOT_TOKEN_ENV_VAR, DISCORD_ED25519_PUBLIC_KEY_BYTE_LENGTH, DISCORD_PUBLIC_KEY_ENV_VAR, DiscordApi, DiscordModule, DiscordServiceConfig, DiscordWebhookController, DiscordWebhookModule, DiscordWebhookService, DiscordWebhookServiceConfig, discordClientOptionsWithIntents, discordDefaultClientOptions, discordFetchMessagePageFactory, discordInteractionHandlerConfigurerFactory, discordInteractionHandlerFactory, discordServiceConfigFactory, discordWebhookEventVerifier, discordWebhookInteraction, discordWebhookServiceConfigFactory };
1500
+ export { DEFAULT_DISCORD_INTENTS, DEFAULT_DISCORD_MESSAGES_PER_PAGE, DISCORD_BOT_TOKEN_ENV_VAR, DISCORD_BOT_TOKEN_PLACEHOLDER, DISCORD_ED25519_PUBLIC_KEY_BYTE_LENGTH, DISCORD_PUBLIC_KEY_ENV_VAR, DiscordApi, DiscordModule, DiscordServiceConfig, DiscordWebhookController, DiscordWebhookModule, DiscordWebhookService, DiscordWebhookServiceConfig, discordClientOptionsWithIntents, discordDefaultClientOptions, discordFetchMessagePageFactory, discordInteractionHandlerConfigurerFactory, discordInteractionHandlerFactory, discordServiceConfigFactory, discordWebhookEventVerifier, discordWebhookInteraction, discordWebhookServiceConfigFactory, isUsableDiscordBotToken };
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/discord",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/nestjs": "13.12.5",
6
- "@dereekb/rxjs": "13.12.5",
7
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/nestjs": "13.12.7",
6
+ "@dereekb/rxjs": "13.12.7",
7
+ "@dereekb/util": "13.12.7",
8
8
  "@nestjs/common": "^11.1.19",
9
9
  "@nestjs/config": "^4.0.4",
10
10
  "discord.js": "^14.26.3",
@@ -1,9 +1,31 @@
1
+ import { type Maybe } from '@dereekb/util';
1
2
  import { type ClientOptions, GatewayIntentBits } from 'discord.js';
2
3
  import { type DiscordBotToken } from './discord.type';
3
4
  /**
4
5
  * Default environment variable for the Discord bot token.
5
6
  */
6
7
  export declare const DISCORD_BOT_TOKEN_ENV_VAR = "DISCORD_BOT_TOKEN";
8
+ /**
9
+ * Placeholder bot token value used in development and CI environments where a real Discord
10
+ * login should not be attempted. Mirrors the value used in the workspace's .env file.
11
+ */
12
+ export declare const DISCORD_BOT_TOKEN_PLACEHOLDER = "placeholder";
13
+ /**
14
+ * Returns true if the input is a real, usable Discord bot token.
15
+ *
16
+ * A token is usable when it is non-empty and is not the shared placeholder value, allowing
17
+ * non-production environments to skip a real gateway login that would always fail.
18
+ *
19
+ * @param botToken - The bot token read from configuration, if any.
20
+ * @returns True when the token should be used to log in.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * isUsableDiscordBotToken('placeholder'); // false
25
+ * isUsableDiscordBotToken('real-token'); // true
26
+ * ```
27
+ */
28
+ export declare function isUsableDiscordBotToken(botToken: Maybe<DiscordBotToken>): boolean;
7
29
  /**
8
30
  * Default gateway intents for a bot that reads guild messages.
9
31
  *
@@ -3,6 +3,10 @@ import { DiscordServiceConfig } from './discord.config';
3
3
  /**
4
4
  * Factory that creates a DiscordServiceConfig from environment variables.
5
5
  *
6
+ * autoLogin is enabled only when a real bot token is configured and the process is not running
7
+ * under a test environment, so development and CI runs (which use a placeholder token) never
8
+ * attempt a real gateway login that would fail.
9
+ *
6
10
  * @param configService - The NestJS config service used to read Discord environment variables.
7
11
  * @returns A validated DiscordServiceConfig populated from environment variables.
8
12
  */
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/eslint",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/util": "13.12.7",
6
6
  "@typescript-eslint/utils": "8.59.3"
7
7
  },
8
8
  "devDependencies": {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/mailgun",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.12.5",
6
- "@dereekb/model": "13.12.5",
7
- "@dereekb/nestjs": "13.12.5",
8
- "@dereekb/rxjs": "13.12.5",
9
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/date": "13.12.7",
6
+ "@dereekb/model": "13.12.7",
7
+ "@dereekb/nestjs": "13.12.7",
8
+ "@dereekb/rxjs": "13.12.7",
9
+ "@dereekb/util": "13.12.7",
10
10
  "@nestjs/common": "^11.1.19",
11
11
  "@nestjs/config": "^4.0.4",
12
12
  "form-data": "^4.0.5",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/openai",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.12.5",
6
- "@dereekb/model": "13.12.5",
7
- "@dereekb/nestjs": "13.12.5",
8
- "@dereekb/rxjs": "13.12.5",
9
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/date": "13.12.7",
6
+ "@dereekb/model": "13.12.7",
7
+ "@dereekb/nestjs": "13.12.7",
8
+ "@dereekb/rxjs": "13.12.7",
9
+ "@dereekb/util": "13.12.7",
10
10
  "@nestjs/common": "^11.1.19",
11
11
  "@nestjs/config": "^4.0.4",
12
12
  "express": "^5.2.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "types": "./src/index.d.ts",
5
5
  "module": "./index.esm.js",
6
6
  "main": "./index.cjs.js",
@@ -62,8 +62,8 @@
62
62
  }
63
63
  },
64
64
  "peerDependencies": {
65
- "@dereekb/rxjs": "13.12.5",
66
- "@dereekb/util": "13.12.5",
65
+ "@dereekb/rxjs": "13.12.7",
66
+ "@dereekb/util": "13.12.7",
67
67
  "@nestjs/common": "^11.1.19",
68
68
  "@nestjs/config": "^4.0.4",
69
69
  "@typeform/api-client": "^2.10.2",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/stripe",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.12.5",
6
- "@dereekb/model": "13.12.5",
7
- "@dereekb/nestjs": "13.12.5",
8
- "@dereekb/rxjs": "13.12.5",
9
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/date": "13.12.7",
6
+ "@dereekb/model": "13.12.7",
7
+ "@dereekb/nestjs": "13.12.7",
8
+ "@dereekb/rxjs": "13.12.7",
9
+ "@dereekb/util": "13.12.7",
10
10
  "@nestjs/common": "^11.1.19",
11
11
  "@nestjs/config": "^4.0.4",
12
12
  "express": "^5.2.1",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/twilio",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.12.5",
6
- "@dereekb/model": "13.12.5",
7
- "@dereekb/nestjs": "13.12.5",
8
- "@dereekb/rxjs": "13.12.5",
9
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/date": "13.12.7",
6
+ "@dereekb/model": "13.12.7",
7
+ "@dereekb/nestjs": "13.12.7",
8
+ "@dereekb/rxjs": "13.12.7",
9
+ "@dereekb/util": "13.12.7",
10
10
  "@nestjs/common": "^11.1.19",
11
11
  "@nestjs/config": "^4.0.4",
12
12
  "express": "^5.2.1",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/typeform",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.12.5",
6
- "@dereekb/model": "13.12.5",
7
- "@dereekb/nestjs": "13.12.5",
8
- "@dereekb/rxjs": "13.12.5",
9
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/date": "13.12.7",
6
+ "@dereekb/model": "13.12.7",
7
+ "@dereekb/nestjs": "13.12.7",
8
+ "@dereekb/rxjs": "13.12.7",
9
+ "@dereekb/util": "13.12.7",
10
10
  "@nestjs/common": "^11.1.19",
11
11
  "@nestjs/config": "^4.0.4",
12
12
  "@typeform/api-client": "^2.10.2",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/vapiai",
3
- "version": "13.12.5",
3
+ "version": "13.12.7",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.12.5",
6
- "@dereekb/model": "13.12.5",
7
- "@dereekb/nestjs": "13.12.5",
8
- "@dereekb/rxjs": "13.12.5",
9
- "@dereekb/util": "13.12.5",
5
+ "@dereekb/date": "13.12.7",
6
+ "@dereekb/model": "13.12.7",
7
+ "@dereekb/nestjs": "13.12.7",
8
+ "@dereekb/rxjs": "13.12.7",
9
+ "@dereekb/util": "13.12.7",
10
10
  "@nestjs/common": "^11.1.19",
11
11
  "@nestjs/config": "^4.0.4",
12
12
  "@vapi-ai/server-sdk": "^0.11.0",