@dereekb/nestjs 13.4.0 → 13.4.2
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/discord/index.cjs.js +31 -9
- package/discord/index.esm.js +31 -9
- package/discord/package.json +3 -3
- package/discord/src/lib/discord.api.d.ts +14 -0
- package/discord/src/lib/discord.api.page.d.ts +23 -5
- package/discord/src/lib/discord.module.d.ts +3 -0
- package/discord/src/lib/discord.util.d.ts +3 -0
- package/discord/src/lib/webhook/webhook.discord.d.ts +1 -0
- package/discord/src/lib/webhook/webhook.discord.module.d.ts +3 -0
- package/discord/src/lib/webhook/webhook.discord.verify.d.ts +1 -0
- package/index.cjs.js +52 -13
- package/index.esm.js +53 -14
- package/mailgun/index.cjs.js +59 -32
- package/mailgun/index.esm.js +60 -33
- package/mailgun/package.json +6 -6
- package/mailgun/src/lib/mailgun.api.d.ts +5 -3
- package/mailgun/src/lib/mailgun.d.ts +24 -7
- package/mailgun/src/lib/mailgun.service.d.ts +1 -0
- package/mailgun/src/lib/mailgun.service.module.d.ts +15 -0
- package/mailgun/src/lib/mailgun.util.d.ts +3 -0
- package/openai/index.cjs.js +31 -10
- package/openai/index.esm.js +31 -10
- package/openai/package.json +6 -6
- package/openai/src/lib/openai.module.d.ts +13 -0
- package/openai/src/lib/webhook/webhook.openai.module.d.ts +13 -0
- package/openai/src/lib/webhook/webhook.openai.verify.d.ts +3 -3
- package/package.json +2 -2
- package/src/lib/decorators/local.decorator.d.ts +8 -0
- package/src/lib/decorators/rawbody.d.ts +0 -13
- package/src/lib/module/client/client.module.d.ts +13 -0
- package/src/lib/module/env/env.config.d.ts +5 -4
- package/src/lib/module/env/env.d.ts +3 -1
- package/src/lib/module/env/env.nest.d.ts +8 -0
- package/src/lib/module/env/env.service.d.ts +2 -1
- package/src/lib/module/module.d.ts +11 -3
- package/src/lib/util/encryption/json.encrypt.d.ts +3 -0
- package/stripe/index.cjs.js +35 -9
- package/stripe/index.esm.js +35 -9
- package/stripe/package.json +6 -6
- package/stripe/src/lib/stripe.api.d.ts +11 -1
- package/stripe/src/lib/stripe.config.d.ts +4 -4
- package/stripe/src/lib/stripe.module.d.ts +13 -0
- package/stripe/src/lib/webhook/webhook.stripe.d.ts +10 -2
- package/typeform/index.cjs.js +56 -16
- package/typeform/index.esm.js +56 -16
- package/typeform/package.json +6 -6
- package/typeform/src/lib/typeform.module.d.ts +13 -0
- package/typeform/src/lib/typeform.type.d.ts +1 -1
- package/typeform/src/lib/typeform.util.d.ts +8 -0
- package/typeform/src/lib/webhook/webhook.typeform.form.d.ts +11 -1
- package/typeform/src/lib/webhook/webhook.typeform.module.d.ts +13 -0
- package/typeform/src/lib/webhook/webhook.typeform.verify.d.ts +2 -2
- package/vapiai/index.cjs.js +35 -14
- package/vapiai/index.esm.js +35 -14
- package/vapiai/package.json +6 -6
- package/vapiai/src/lib/vapiai.api.d.ts +2 -2
- package/vapiai/src/lib/vapiai.module.d.ts +13 -0
- package/vapiai/src/lib/webhook/webhook.vapiai.module.d.ts +13 -0
- package/vapiai/src/lib/webhook/webhook.vapiai.verify.d.ts +5 -3
package/discord/index.cjs.js
CHANGED
|
@@ -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
|
}
|
|
@@ -67,7 +68,6 @@ var discordInteractionHandlerFactory = util.handlerFactory(function(x) {
|
|
|
67
68
|
});
|
|
68
69
|
var discordInteractionHandlerConfigurerFactory = util.handlerConfigurerFactory({
|
|
69
70
|
configurerForAccessor: function configurerForAccessor(accessor) {
|
|
70
|
-
// eslint-disable-next-line
|
|
71
71
|
var fnWithKey = util.handlerMappedSetFunctionFactory(accessor, discordWebhookInteraction);
|
|
72
72
|
var configurer = _object_spread_props$1(_object_spread$2({}, accessor), {
|
|
73
73
|
handleApplicationCommand: fnWithKey(discord_js.InteractionType.ApplicationCommand),
|
|
@@ -292,6 +292,7 @@ function _ts_generator$3(thisArg, body) {
|
|
|
292
292
|
* Uses Node.js built-in crypto with JWK key import — no external dependencies required.
|
|
293
293
|
*
|
|
294
294
|
* @param config - verification config containing the application's public key
|
|
295
|
+
* @returns a DiscordWebhookEventVerifier function that validates Ed25519-signed requests
|
|
295
296
|
*
|
|
296
297
|
* @example
|
|
297
298
|
* ```ts
|
|
@@ -811,6 +812,9 @@ function _class_call_check$3(instance, Constructor) {
|
|
|
811
812
|
}
|
|
812
813
|
/**
|
|
813
814
|
* Factory that creates a DiscordWebhookServiceConfig from environment variables.
|
|
815
|
+
*
|
|
816
|
+
* @param configService - the NestJS config service used to read the Discord public key environment variable
|
|
817
|
+
* @returns a validated DiscordWebhookServiceConfig populated from environment variables
|
|
814
818
|
*/ function discordWebhookServiceConfigFactory(configService) {
|
|
815
819
|
var config = {
|
|
816
820
|
discordWebhook: {
|
|
@@ -1127,7 +1131,9 @@ function _ts_generator(thisArg, body) {
|
|
|
1127
1131
|
_this = this;
|
|
1128
1132
|
_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
1133
|
if (autoLogin) {
|
|
1130
|
-
result = this.client.login(botToken).then(function() {
|
|
1134
|
+
result = this.client.login(botToken).then(function() {
|
|
1135
|
+
return undefined;
|
|
1136
|
+
}).catch(function(e) {
|
|
1131
1137
|
_this.logger.error('Failed to log in to Discord', e);
|
|
1132
1138
|
});
|
|
1133
1139
|
} else {
|
|
@@ -1168,6 +1174,13 @@ function _ts_generator(thisArg, body) {
|
|
|
1168
1174
|
* ```ts
|
|
1169
1175
|
* const message = await discordApi.sendMessage('123456789', 'Hello from the bot!');
|
|
1170
1176
|
* ```
|
|
1177
|
+
*/ /**
|
|
1178
|
+
* Sends a text message to the specified Discord channel.
|
|
1179
|
+
*
|
|
1180
|
+
* @param channelId - target channel's snowflake ID
|
|
1181
|
+
* @param content - message text to send
|
|
1182
|
+
* @returns the sent Discord Message
|
|
1183
|
+
* @throws {Error} when the channel is not found or is not a text channel
|
|
1171
1184
|
*/ function sendMessage(channelId, content) {
|
|
1172
1185
|
return _async_to_generator(function() {
|
|
1173
1186
|
var channel;
|
|
@@ -1211,6 +1224,11 @@ function _ts_generator(thisArg, body) {
|
|
|
1211
1224
|
* // Later, to stop listening:
|
|
1212
1225
|
* unsubscribe();
|
|
1213
1226
|
* ```
|
|
1227
|
+
*/ /**
|
|
1228
|
+
* Registers a handler for incoming Discord messages (MessageCreate event).
|
|
1229
|
+
*
|
|
1230
|
+
* @param handler - callback invoked for each incoming Message
|
|
1231
|
+
* @returns an unsubscribe function that removes the registered handler
|
|
1214
1232
|
*/ key: "onMessage",
|
|
1215
1233
|
value: function onMessage(handler) {
|
|
1216
1234
|
var _this = this;
|
|
@@ -1235,6 +1253,9 @@ function _class_call_check(instance, Constructor) {
|
|
|
1235
1253
|
}
|
|
1236
1254
|
/**
|
|
1237
1255
|
* Factory that creates a DiscordServiceConfig from environment variables.
|
|
1256
|
+
*
|
|
1257
|
+
* @param configService - the NestJS config service used to read Discord environment variables
|
|
1258
|
+
* @returns a validated DiscordServiceConfig populated from environment variables
|
|
1238
1259
|
*/ function discordServiceConfigFactory(configService) {
|
|
1239
1260
|
var config = {
|
|
1240
1261
|
discord: {
|
|
@@ -1330,14 +1351,12 @@ function _object_spread_props(target, source) {
|
|
|
1330
1351
|
* message's ID from each response and sets it as the `before` cursor for the next request.
|
|
1331
1352
|
* When the number of returned messages is less than the requested limit, pagination stops.
|
|
1332
1353
|
*
|
|
1333
|
-
* @param
|
|
1334
|
-
* @param config - Optional config for reading message IDs
|
|
1335
|
-
* @param defaults - Optional default configuration for the page factory
|
|
1354
|
+
* @param input - The factory input configuration
|
|
1336
1355
|
* @returns A page factory that produces iterable page fetchers
|
|
1337
1356
|
*
|
|
1338
1357
|
* @example
|
|
1339
1358
|
* ```typescript
|
|
1340
|
-
* const pageFactory = discordFetchMessagePageFactory(fetchChannelMessages);
|
|
1359
|
+
* const pageFactory = discordFetchMessagePageFactory({ fetch: fetchChannelMessages });
|
|
1341
1360
|
*
|
|
1342
1361
|
* const fetchPage = pageFactory({ limit: 50 });
|
|
1343
1362
|
* const firstPage = await fetchPage.fetchNext();
|
|
@@ -1346,8 +1365,9 @@ function _object_spread_props(target, source) {
|
|
|
1346
1365
|
* const secondPage = await firstPage.fetchNext();
|
|
1347
1366
|
* }
|
|
1348
1367
|
* ```
|
|
1349
|
-
*/ function discordFetchMessagePageFactory(
|
|
1368
|
+
*/ function discordFetchMessagePageFactory(input) {
|
|
1350
1369
|
var _ref;
|
|
1370
|
+
var fetch$1 = input.fetch, config = input.config, defaults = input.defaults;
|
|
1351
1371
|
var readMessageId = (_ref = config === null || config === void 0 ? void 0 : config.readMessageId) !== null && _ref !== void 0 ? _ref : function(message) {
|
|
1352
1372
|
return message.id;
|
|
1353
1373
|
};
|
|
@@ -1355,8 +1375,7 @@ function _object_spread_props(target, source) {
|
|
|
1355
1375
|
fetch: fetch$1,
|
|
1356
1376
|
readFetchPageResultInfo: function readFetchPageResultInfo(result) {
|
|
1357
1377
|
var count = result.data.length;
|
|
1358
|
-
var
|
|
1359
|
-
var nextCursor = lastMessage ? readMessageId(lastMessage) : undefined;
|
|
1378
|
+
var nextCursor = count > 0 ? readMessageId(util.lastValue(result.data)) : undefined;
|
|
1360
1379
|
return {
|
|
1361
1380
|
hasNext: count > 0,
|
|
1362
1381
|
nextPageCursor: nextCursor
|
|
@@ -1412,6 +1431,8 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
1412
1431
|
*
|
|
1413
1432
|
* Includes Guilds, GuildMessages, and MessageContent intents.
|
|
1414
1433
|
*
|
|
1434
|
+
* @returns partial ClientOptions with the default bot intents set
|
|
1435
|
+
*
|
|
1415
1436
|
* @example
|
|
1416
1437
|
* ```ts
|
|
1417
1438
|
* const options = discordDefaultClientOptions();
|
|
@@ -1426,6 +1447,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
1426
1447
|
* Returns ClientOptions with additional intents merged with the defaults.
|
|
1427
1448
|
*
|
|
1428
1449
|
* @param additionalIntents - extra intents to include beyond the defaults
|
|
1450
|
+
* @returns partial ClientOptions with the merged intent list
|
|
1429
1451
|
*
|
|
1430
1452
|
* @example
|
|
1431
1453
|
* ```ts
|
package/discord/index.esm.js
CHANGED
|
@@ -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
|
}
|
|
@@ -65,7 +66,6 @@ var discordInteractionHandlerFactory = handlerFactory(function(x) {
|
|
|
65
66
|
});
|
|
66
67
|
var discordInteractionHandlerConfigurerFactory = handlerConfigurerFactory({
|
|
67
68
|
configurerForAccessor: function configurerForAccessor(accessor) {
|
|
68
|
-
// eslint-disable-next-line
|
|
69
69
|
var fnWithKey = handlerMappedSetFunctionFactory(accessor, discordWebhookInteraction);
|
|
70
70
|
var configurer = _object_spread_props$1(_object_spread$2({}, accessor), {
|
|
71
71
|
handleApplicationCommand: fnWithKey(InteractionType.ApplicationCommand),
|
|
@@ -290,6 +290,7 @@ function _ts_generator$3(thisArg, body) {
|
|
|
290
290
|
* Uses Node.js built-in crypto with JWK key import — no external dependencies required.
|
|
291
291
|
*
|
|
292
292
|
* @param config - verification config containing the application's public key
|
|
293
|
+
* @returns a DiscordWebhookEventVerifier function that validates Ed25519-signed requests
|
|
293
294
|
*
|
|
294
295
|
* @example
|
|
295
296
|
* ```ts
|
|
@@ -809,6 +810,9 @@ function _class_call_check$3(instance, Constructor) {
|
|
|
809
810
|
}
|
|
810
811
|
/**
|
|
811
812
|
* Factory that creates a DiscordWebhookServiceConfig from environment variables.
|
|
813
|
+
*
|
|
814
|
+
* @param configService - the NestJS config service used to read the Discord public key environment variable
|
|
815
|
+
* @returns a validated DiscordWebhookServiceConfig populated from environment variables
|
|
812
816
|
*/ function discordWebhookServiceConfigFactory(configService) {
|
|
813
817
|
var config = {
|
|
814
818
|
discordWebhook: {
|
|
@@ -1125,7 +1129,9 @@ function _ts_generator(thisArg, body) {
|
|
|
1125
1129
|
_this = this;
|
|
1126
1130
|
_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
1131
|
if (autoLogin) {
|
|
1128
|
-
result = this.client.login(botToken).then(function() {
|
|
1132
|
+
result = this.client.login(botToken).then(function() {
|
|
1133
|
+
return undefined;
|
|
1134
|
+
}).catch(function(e) {
|
|
1129
1135
|
_this.logger.error('Failed to log in to Discord', e);
|
|
1130
1136
|
});
|
|
1131
1137
|
} else {
|
|
@@ -1166,6 +1172,13 @@ function _ts_generator(thisArg, body) {
|
|
|
1166
1172
|
* ```ts
|
|
1167
1173
|
* const message = await discordApi.sendMessage('123456789', 'Hello from the bot!');
|
|
1168
1174
|
* ```
|
|
1175
|
+
*/ /**
|
|
1176
|
+
* Sends a text message to the specified Discord channel.
|
|
1177
|
+
*
|
|
1178
|
+
* @param channelId - target channel's snowflake ID
|
|
1179
|
+
* @param content - message text to send
|
|
1180
|
+
* @returns the sent Discord Message
|
|
1181
|
+
* @throws {Error} when the channel is not found or is not a text channel
|
|
1169
1182
|
*/ function sendMessage(channelId, content) {
|
|
1170
1183
|
return _async_to_generator(function() {
|
|
1171
1184
|
var channel;
|
|
@@ -1209,6 +1222,11 @@ function _ts_generator(thisArg, body) {
|
|
|
1209
1222
|
* // Later, to stop listening:
|
|
1210
1223
|
* unsubscribe();
|
|
1211
1224
|
* ```
|
|
1225
|
+
*/ /**
|
|
1226
|
+
* Registers a handler for incoming Discord messages (MessageCreate event).
|
|
1227
|
+
*
|
|
1228
|
+
* @param handler - callback invoked for each incoming Message
|
|
1229
|
+
* @returns an unsubscribe function that removes the registered handler
|
|
1212
1230
|
*/ key: "onMessage",
|
|
1213
1231
|
value: function onMessage(handler) {
|
|
1214
1232
|
var _this = this;
|
|
@@ -1233,6 +1251,9 @@ function _class_call_check(instance, Constructor) {
|
|
|
1233
1251
|
}
|
|
1234
1252
|
/**
|
|
1235
1253
|
* Factory that creates a DiscordServiceConfig from environment variables.
|
|
1254
|
+
*
|
|
1255
|
+
* @param configService - the NestJS config service used to read Discord environment variables
|
|
1256
|
+
* @returns a validated DiscordServiceConfig populated from environment variables
|
|
1236
1257
|
*/ function discordServiceConfigFactory(configService) {
|
|
1237
1258
|
var config = {
|
|
1238
1259
|
discord: {
|
|
@@ -1328,14 +1349,12 @@ function _object_spread_props(target, source) {
|
|
|
1328
1349
|
* message's ID from each response and sets it as the `before` cursor for the next request.
|
|
1329
1350
|
* When the number of returned messages is less than the requested limit, pagination stops.
|
|
1330
1351
|
*
|
|
1331
|
-
* @param
|
|
1332
|
-
* @param config - Optional config for reading message IDs
|
|
1333
|
-
* @param defaults - Optional default configuration for the page factory
|
|
1352
|
+
* @param input - The factory input configuration
|
|
1334
1353
|
* @returns A page factory that produces iterable page fetchers
|
|
1335
1354
|
*
|
|
1336
1355
|
* @example
|
|
1337
1356
|
* ```typescript
|
|
1338
|
-
* const pageFactory = discordFetchMessagePageFactory(fetchChannelMessages);
|
|
1357
|
+
* const pageFactory = discordFetchMessagePageFactory({ fetch: fetchChannelMessages });
|
|
1339
1358
|
*
|
|
1340
1359
|
* const fetchPage = pageFactory({ limit: 50 });
|
|
1341
1360
|
* const firstPage = await fetchPage.fetchNext();
|
|
@@ -1344,8 +1363,9 @@ function _object_spread_props(target, source) {
|
|
|
1344
1363
|
* const secondPage = await firstPage.fetchNext();
|
|
1345
1364
|
* }
|
|
1346
1365
|
* ```
|
|
1347
|
-
*/ function discordFetchMessagePageFactory(
|
|
1366
|
+
*/ function discordFetchMessagePageFactory(input) {
|
|
1348
1367
|
var _ref;
|
|
1368
|
+
var fetch = input.fetch, config = input.config, defaults = input.defaults;
|
|
1349
1369
|
var readMessageId = (_ref = config === null || config === void 0 ? void 0 : config.readMessageId) !== null && _ref !== void 0 ? _ref : function(message) {
|
|
1350
1370
|
return message.id;
|
|
1351
1371
|
};
|
|
@@ -1353,8 +1373,7 @@ function _object_spread_props(target, source) {
|
|
|
1353
1373
|
fetch: fetch,
|
|
1354
1374
|
readFetchPageResultInfo: function readFetchPageResultInfo(result) {
|
|
1355
1375
|
var count = result.data.length;
|
|
1356
|
-
var
|
|
1357
|
-
var nextCursor = lastMessage ? readMessageId(lastMessage) : undefined;
|
|
1376
|
+
var nextCursor = count > 0 ? readMessageId(lastValue(result.data)) : undefined;
|
|
1358
1377
|
return {
|
|
1359
1378
|
hasNext: count > 0,
|
|
1360
1379
|
nextPageCursor: nextCursor
|
|
@@ -1410,6 +1429,8 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
1410
1429
|
*
|
|
1411
1430
|
* Includes Guilds, GuildMessages, and MessageContent intents.
|
|
1412
1431
|
*
|
|
1432
|
+
* @returns partial ClientOptions with the default bot intents set
|
|
1433
|
+
*
|
|
1413
1434
|
* @example
|
|
1414
1435
|
* ```ts
|
|
1415
1436
|
* const options = discordDefaultClientOptions();
|
|
@@ -1424,6 +1445,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
1424
1445
|
* Returns ClientOptions with additional intents merged with the defaults.
|
|
1425
1446
|
*
|
|
1426
1447
|
* @param additionalIntents - extra intents to include beyond the defaults
|
|
1448
|
+
* @returns partial ClientOptions with the merged intent list
|
|
1427
1449
|
*
|
|
1428
1450
|
* @example
|
|
1429
1451
|
* ```ts
|
package/discord/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/nestjs/discord",
|
|
3
|
-
"version": "13.4.
|
|
3
|
+
"version": "13.4.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/nestjs": "13.4.
|
|
6
|
-
"@dereekb/util": "13.4.
|
|
5
|
+
"@dereekb/nestjs": "13.4.2",
|
|
6
|
+
"@dereekb/util": "13.4.2",
|
|
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
|
|
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
|
-
}>(
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|