@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.
Files changed (59) hide show
  1. package/discord/index.cjs.js +31 -9
  2. package/discord/index.esm.js +31 -9
  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 +59 -32
  14. package/mailgun/index.esm.js +60 -33
  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 +24 -7
  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 -10
  22. package/openai/index.esm.js +31 -10
  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 -9
  38. package/stripe/index.esm.js +35 -9
  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 -16
  45. package/typeform/index.esm.js +56 -16
  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 +1 -1
  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 -14
  54. package/vapiai/index.esm.js +35 -14
  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
@@ -8,7 +8,7 @@ export type MailgunTemplateKey = string;
8
8
  *
9
9
  * Each value is converted to a JSON string before being sent to Mailgun server.
10
10
  */
11
- export type MailgunTemplateVariables = Record<string, any>;
11
+ export type MailgunTemplateVariables = Record<string, unknown>;
12
12
  export interface MailgunRecipient extends NameEmailPair {
13
13
  readonly userVariables?: Maybe<MailgunTemplateVariables>;
14
14
  }
@@ -152,14 +152,14 @@ export interface MailgunTemplateEmailRequestFinalizeRecipientVariablesFunctionIn
152
152
  *
153
153
  * Can directly modify the input object or return a new object to replace the recipient variables
154
154
  */
155
- export type MailgunTemplateEmailRequestFinalizeRecipientVariablesFunction = (recipientVariables: Record<EmailAddress, Record<string, any>>, input: MailgunTemplateEmailRequestFinalizeRecipientVariablesFunctionInput) => Maybe<Record<EmailAddress, Record<string, any>>>;
155
+ export type MailgunTemplateEmailRequestFinalizeRecipientVariablesFunction = (recipientVariables: Record<EmailAddress, Record<string, unknown>>, input: MailgunTemplateEmailRequestFinalizeRecipientVariablesFunctionInput) => Maybe<Record<EmailAddress, Record<string, unknown>>>;
156
156
  export type MailgunEmailMessageSendResult = MessagesSendResult;
157
157
  export type MailgunAPIResponse = APIResponse;
158
158
  export declare const DEFAULT_RECIPIENT_VARIABLE_PREFIX = "recipient-";
159
159
  export declare const MAILGUN_REPLY_TO_EMAIL_HEADER_DATA_VARIABLE_KEY = "h:Reply-To";
160
160
  export interface ConvertMailgunTemplateEmailRequestToMailgunMessageDataConfig extends MailgunTemplateEmailRequestRecipientVariablesConfig {
161
161
  readonly request: MailgunTemplateEmailRequest;
162
- readonly defaultSender?: string;
162
+ readonly defaultSender?: EmailParticipantString;
163
163
  readonly isTestingEnvironment?: boolean;
164
164
  }
165
165
  /**
@@ -167,13 +167,30 @@ export interface ConvertMailgunTemplateEmailRequestToMailgunMessageDataConfig ex
167
167
  */
168
168
  export declare const MAX_BATCH_SEND_RECIPIENTS = 1000;
169
169
  /**
170
- * Converts a MailgunTemplateEmailRequest to a MailgunMessageData.
170
+ * Converts a {@link MailgunTemplateEmailRequest} into Mailgun-compatible {@link MailgunMessageData},
171
+ * applying sender defaults, recipient variable prefixing, and test environment overrides.
171
172
  *
172
- * @param config
173
- * @returns
173
+ * @param config - The conversion configuration containing the email request, default sender, and recipient variable settings.
174
+ * @returns The constructed {@link MailgunMessageData} ready to be sent via the Mailgun API.
174
175
  */
175
176
  export declare function convertMailgunTemplateEmailRequestToMailgunMessageData(config: ConvertMailgunTemplateEmailRequestToMailgunMessageDataConfig): MailgunMessageData;
177
+ /**
178
+ * Converts an array of MailgunRecipient objects to formatted email address strings.
179
+ *
180
+ * Each recipient is formatted as "Name <email>" when a name is present, or just the email address.
181
+ *
182
+ * @param recipients - the recipients to convert
183
+ * @returns an array of formatted email address strings
184
+ */
176
185
  export declare function convertMailgunRecipientsToStrings(recipients: MailgunRecipient[]): EmailParticipantString[];
186
+ /**
187
+ * Converts a MailgunRecipient to a formatted email address string.
188
+ *
189
+ * Returns "Name <email>" when a name is present, or just the email address otherwise.
190
+ *
191
+ * @param recipient - the recipient to convert
192
+ * @returns a formatted email participant string
193
+ */
177
194
  export declare function convertMailgunRecipientToString(recipient: MailgunRecipient): EmailParticipantString;
178
195
  /**
179
196
  * Encodes a value to a string for use as a Mailgun template variable. Throws an error if the value is not supported.
@@ -181,4 +198,4 @@ export declare function convertMailgunRecipientToString(recipient: MailgunRecipi
181
198
  * @param value The value to encode.
182
199
  * @returns The encoded value, or undefined if the value is null or undefined.
183
200
  */
184
- export declare function encodeMailgunTemplateVariableValue(value: any): Maybe<string>;
201
+ export declare function encodeMailgunTemplateVariableValue(value: unknown): Maybe<string>;
@@ -2,6 +2,7 @@ import { ServerEnvironmentService } from '@dereekb/nestjs';
2
2
  import { type MailgunTemplateEmailRequest, type MailgunEmailMessageSendResult } from './mailgun';
3
3
  import { MailgunApi } from './mailgun.api';
4
4
  export declare class MailgunService {
5
+ private readonly logger;
5
6
  private readonly _mailgunApi;
6
7
  private readonly _serverEnvironmentService;
7
8
  constructor(mailgunApi: MailgunApi, serverEnvironmentService: ServerEnvironmentService);
@@ -1,6 +1,21 @@
1
1
  import { ServerEnvironmentService } from '@dereekb/nestjs';
2
2
  import { ConfigService } from '@nestjs/config';
3
3
  import { MailgunServiceConfig } from './mailgun.config';
4
+ /**
5
+ * Factory that creates a MailgunServiceConfig from environment variables.
6
+ *
7
+ * Automatically switches to sandbox credentials when USE_MAILGUN_SANDBOX is true or the environment is a test environment.
8
+ *
9
+ * @param configService - NestJS config service for reading environment variables
10
+ * @param serverEnvironmentService - service indicating the current server environment
11
+ * @returns a validated MailgunServiceConfig
12
+ */
4
13
  export declare function mailgunServiceConfigFactory(configService: ConfigService, serverEnvironmentService: ServerEnvironmentService): MailgunServiceConfig;
14
+ /**
15
+ * NestJS module that provides the MailgunApi and MailgunService for sending emails.
16
+ *
17
+ * Reads Mailgun credentials and sender configuration from environment variables,
18
+ * with automatic fallback to sandbox settings in test environments.
19
+ */
5
20
  export declare class MailgunServiceModule {
6
21
  }
@@ -72,6 +72,9 @@ export interface MailgunRecipientBatchSendTarget extends MailgunRecipient {
72
72
  export type MailgunRecipientBatchSendTargetFromReplyToBatchGroupKey = string;
73
73
  /**
74
74
  * Creates a composite key from the from/replyTo email addresses used to group MailgunRecipientBatchSendTarget values.
75
+ *
76
+ * @param recipient - the batch send target whose from/replyTo addresses are used as the grouping key
77
+ * @returns a string key in the form "f:{fromEmail}|r:{replyToEmail}" used to group recipients into batches
75
78
  */
76
79
  export declare function mailgunRecipientBatchSendTargetFromReplyToBatchGroupKey(recipient: MailgunRecipientBatchSendTarget): MailgunRecipientBatchSendTargetFromReplyToBatchGroupKey;
77
80
  /**
@@ -66,7 +66,6 @@ var openaiEventHandlerFactory = util.handlerFactory(function(x) {
66
66
  });
67
67
  var openaiEventHandlerConfigurerFactory = util.handlerConfigurerFactory({
68
68
  configurerForAccessor: function configurerForAccessor(accessor) {
69
- // eslint-disable-next-line
70
69
  var fnWithKey = util.handlerMappedSetFunctionFactory(accessor, openAIWebhookEvent);
71
70
  var configurer = _object_spread_props(_object_spread({}, accessor), {
72
71
  handleBatchCancelled: fnWithKey('batch.cancelled'),
@@ -389,13 +388,13 @@ function _ts_generator$2(thisArg, body) {
389
388
  }
390
389
  }
391
390
  /**
392
- * Verifies a OpenAI webhook event header.
391
+ * Verifies an OpenAI webhook event header using the OpenAI client's built-in signature verification.
393
392
  *
394
- * @param vapiSecretTokenGetter The OpenAI secret token. The Vapi client allows for using an AsyncGetterOrValue type, so the verifier supports that as well.
395
- * @returns A function that verifies a OpenAI webhook event.
393
+ * @param config - The verification config containing the OpenAI webhook secret and client.
394
+ * @returns A function that verifies an OpenAI webhook event.
396
395
  */ function openAIWebhookEventVerifier(config) {
397
396
  var secret = config.secret, client = config.client;
398
- return function(request, rawBody) {
397
+ return function(request, _rawBody) {
399
398
  return _async_to_generator$2(function() {
400
399
  var headers, requestBodyString, event, valid, e, result;
401
400
  return _ts_generator$2(this, function(_state) {
@@ -903,7 +902,14 @@ function _class_call_check$1(instance, Constructor) {
903
902
  throw new TypeError("Cannot call a class as a function");
904
903
  }
905
904
  }
906
- function openAIServiceConfigFactory(configService) {
905
+ /**
906
+ * Factory that creates an OpenAIServiceConfig from environment variables.
907
+ *
908
+ * Reads the API key, base URL, organization ID, and project ID from environment variables.
909
+ *
910
+ * @param configService - NestJS config service for reading environment variables
911
+ * @returns a validated OpenAIServiceConfig
912
+ */ function openAIServiceConfigFactory(configService) {
907
913
  var _configService_get;
908
914
  var config = {
909
915
  openai: {
@@ -918,7 +924,11 @@ function openAIServiceConfigFactory(configService) {
918
924
  OpenAIServiceConfig.assertValidConfig(config);
919
925
  return config;
920
926
  }
921
- exports.OpenAIModule = function OpenAIModule() {
927
+ /**
928
+ * NestJS module that provides the OpenAIApi service.
929
+ *
930
+ * Reads the OpenAI API key, organization ID, and project ID from environment variables.
931
+ */ exports.OpenAIModule = function OpenAIModule() {
922
932
  _class_call_check$1(this, OpenAIModule);
923
933
  };
924
934
  exports.OpenAIModule = __decorate([
@@ -947,7 +957,14 @@ function _class_call_check(instance, Constructor) {
947
957
  throw new TypeError("Cannot call a class as a function");
948
958
  }
949
959
  }
950
- function openAIWebhookServiceConfigFactory(configService) {
960
+ /**
961
+ * Factory that creates an OpenAIWebhookServiceConfig from environment variables.
962
+ *
963
+ * Reads the OpenAI webhook secret token from environment variables.
964
+ *
965
+ * @param configService - NestJS config service for reading environment variables
966
+ * @returns a validated OpenAIWebhookServiceConfig
967
+ */ function openAIWebhookServiceConfigFactory(configService) {
951
968
  var config = {
952
969
  openaiWebhook: {
953
970
  webhookSecret: configService.get(OPENAI_WEBHOOK_SECRET_TOKEN_ENV_VAR)
@@ -956,7 +973,11 @@ function openAIWebhookServiceConfigFactory(configService) {
956
973
  OpenAIWebhookServiceConfig.assertValidConfig(config);
957
974
  return config;
958
975
  }
959
- exports.OpenAIWebhookModule = function OpenAIWebhookModule() {
976
+ /**
977
+ * NestJS module that handles incoming OpenAI webhook events.
978
+ *
979
+ * Provides the OpenAIWebhookService and controller for verifying and processing webhook payloads.
980
+ */ exports.OpenAIWebhookModule = function OpenAIWebhookModule() {
960
981
  _class_call_check(this, OpenAIWebhookModule);
961
982
  };
962
983
  exports.OpenAIWebhookModule = __decorate([
@@ -1004,7 +1025,7 @@ exports.OpenAIWebhookModule = __decorate([
1004
1025
  try {
1005
1026
  jsonResponse = JSON.parse(output_text);
1006
1027
  jsonResponseFieldMap = openAIJsonResponseFieldsMap(jsonResponse);
1007
- } catch (e) {
1028
+ } catch (unused) {
1008
1029
  // ignore
1009
1030
  }
1010
1031
  return {
@@ -64,7 +64,6 @@ var openaiEventHandlerFactory = handlerFactory(function(x) {
64
64
  });
65
65
  var openaiEventHandlerConfigurerFactory = handlerConfigurerFactory({
66
66
  configurerForAccessor: function configurerForAccessor(accessor) {
67
- // eslint-disable-next-line
68
67
  var fnWithKey = handlerMappedSetFunctionFactory(accessor, openAIWebhookEvent);
69
68
  var configurer = _object_spread_props(_object_spread({}, accessor), {
70
69
  handleBatchCancelled: fnWithKey('batch.cancelled'),
@@ -387,13 +386,13 @@ function _ts_generator$2(thisArg, body) {
387
386
  }
388
387
  }
389
388
  /**
390
- * Verifies a OpenAI webhook event header.
389
+ * Verifies an OpenAI webhook event header using the OpenAI client's built-in signature verification.
391
390
  *
392
- * @param vapiSecretTokenGetter The OpenAI secret token. The Vapi client allows for using an AsyncGetterOrValue type, so the verifier supports that as well.
393
- * @returns A function that verifies a OpenAI webhook event.
391
+ * @param config - The verification config containing the OpenAI webhook secret and client.
392
+ * @returns A function that verifies an OpenAI webhook event.
394
393
  */ function openAIWebhookEventVerifier(config) {
395
394
  var secret = config.secret, client = config.client;
396
- return function(request, rawBody) {
395
+ return function(request, _rawBody) {
397
396
  return _async_to_generator$2(function() {
398
397
  var headers, requestBodyString, event, valid, e, result;
399
398
  return _ts_generator$2(this, function(_state) {
@@ -901,7 +900,14 @@ function _class_call_check$1(instance, Constructor) {
901
900
  throw new TypeError("Cannot call a class as a function");
902
901
  }
903
902
  }
904
- function openAIServiceConfigFactory(configService) {
903
+ /**
904
+ * Factory that creates an OpenAIServiceConfig from environment variables.
905
+ *
906
+ * Reads the API key, base URL, organization ID, and project ID from environment variables.
907
+ *
908
+ * @param configService - NestJS config service for reading environment variables
909
+ * @returns a validated OpenAIServiceConfig
910
+ */ function openAIServiceConfigFactory(configService) {
905
911
  var _configService_get;
906
912
  var config = {
907
913
  openai: {
@@ -916,7 +922,11 @@ function openAIServiceConfigFactory(configService) {
916
922
  OpenAIServiceConfig.assertValidConfig(config);
917
923
  return config;
918
924
  }
919
- var OpenAIModule = function OpenAIModule() {
925
+ /**
926
+ * NestJS module that provides the OpenAIApi service.
927
+ *
928
+ * Reads the OpenAI API key, organization ID, and project ID from environment variables.
929
+ */ var OpenAIModule = function OpenAIModule() {
920
930
  _class_call_check$1(this, OpenAIModule);
921
931
  };
922
932
  OpenAIModule = __decorate([
@@ -945,7 +955,14 @@ function _class_call_check(instance, Constructor) {
945
955
  throw new TypeError("Cannot call a class as a function");
946
956
  }
947
957
  }
948
- function openAIWebhookServiceConfigFactory(configService) {
958
+ /**
959
+ * Factory that creates an OpenAIWebhookServiceConfig from environment variables.
960
+ *
961
+ * Reads the OpenAI webhook secret token from environment variables.
962
+ *
963
+ * @param configService - NestJS config service for reading environment variables
964
+ * @returns a validated OpenAIWebhookServiceConfig
965
+ */ function openAIWebhookServiceConfigFactory(configService) {
949
966
  var config = {
950
967
  openaiWebhook: {
951
968
  webhookSecret: configService.get(OPENAI_WEBHOOK_SECRET_TOKEN_ENV_VAR)
@@ -954,7 +971,11 @@ function openAIWebhookServiceConfigFactory(configService) {
954
971
  OpenAIWebhookServiceConfig.assertValidConfig(config);
955
972
  return config;
956
973
  }
957
- var OpenAIWebhookModule = function OpenAIWebhookModule() {
974
+ /**
975
+ * NestJS module that handles incoming OpenAI webhook events.
976
+ *
977
+ * Provides the OpenAIWebhookService and controller for verifying and processing webhook payloads.
978
+ */ var OpenAIWebhookModule = function OpenAIWebhookModule() {
958
979
  _class_call_check(this, OpenAIWebhookModule);
959
980
  };
960
981
  OpenAIWebhookModule = __decorate([
@@ -1002,7 +1023,7 @@ OpenAIWebhookModule = __decorate([
1002
1023
  try {
1003
1024
  jsonResponse = JSON.parse(output_text);
1004
1025
  jsonResponseFieldMap = openAIJsonResponseFieldsMap(jsonResponse);
1005
- } catch (e) {
1026
+ } catch (unused) {
1006
1027
  // ignore
1007
1028
  }
1008
1029
  return {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/openai",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.4.0",
6
- "@dereekb/model": "13.4.0",
7
- "@dereekb/nestjs": "13.4.0",
8
- "@dereekb/rxjs": "13.4.0",
9
- "@dereekb/util": "13.4.0",
5
+ "@dereekb/date": "13.4.2",
6
+ "@dereekb/model": "13.4.2",
7
+ "@dereekb/nestjs": "13.4.2",
8
+ "@dereekb/rxjs": "13.4.2",
9
+ "@dereekb/util": "13.4.2",
10
10
  "@nestjs/common": "^11.1.16",
11
11
  "@nestjs/config": "^4.0.3",
12
12
  "express": "^5.0.0",
@@ -1,5 +1,18 @@
1
1
  import { ConfigService } from '@nestjs/config';
2
2
  import { OpenAIServiceConfig } from './openai.config';
3
+ /**
4
+ * Factory that creates an OpenAIServiceConfig from environment variables.
5
+ *
6
+ * Reads the API key, base URL, organization ID, and project ID from environment variables.
7
+ *
8
+ * @param configService - NestJS config service for reading environment variables
9
+ * @returns a validated OpenAIServiceConfig
10
+ */
3
11
  export declare function openAIServiceConfigFactory(configService: ConfigService): OpenAIServiceConfig;
12
+ /**
13
+ * NestJS module that provides the OpenAIApi service.
14
+ *
15
+ * Reads the OpenAI API key, organization ID, and project ID from environment variables.
16
+ */
4
17
  export declare class OpenAIModule {
5
18
  }
@@ -1,5 +1,18 @@
1
1
  import { OpenAIWebhookServiceConfig } from './webhook.openai.config';
2
2
  import { ConfigService } from '@nestjs/config';
3
+ /**
4
+ * Factory that creates an OpenAIWebhookServiceConfig from environment variables.
5
+ *
6
+ * Reads the OpenAI webhook secret token from environment variables.
7
+ *
8
+ * @param configService - NestJS config service for reading environment variables
9
+ * @returns a validated OpenAIWebhookServiceConfig
10
+ */
3
11
  export declare function openAIWebhookServiceConfigFactory(configService: ConfigService): OpenAIWebhookServiceConfig;
12
+ /**
13
+ * NestJS module that handles incoming OpenAI webhook events.
14
+ *
15
+ * Provides the OpenAIWebhookService and controller for verifying and processing webhook payloads.
16
+ */
4
17
  export declare class OpenAIWebhookModule {
5
18
  }
@@ -28,9 +28,9 @@ export interface OpenAIWebhookEventVerificationErrorResult {
28
28
  */
29
29
  export type OpenAIWebhookEventVerifier = (req: Request, rawBody: Buffer) => Promise<OpenAIWebhookEventVerificationResult>;
30
30
  /**
31
- * Verifies a OpenAI webhook event header.
31
+ * Verifies an OpenAI webhook event header using the OpenAI client's built-in signature verification.
32
32
  *
33
- * @param vapiSecretTokenGetter The OpenAI secret token. The Vapi client allows for using an AsyncGetterOrValue type, so the verifier supports that as well.
34
- * @returns A function that verifies a OpenAI webhook event.
33
+ * @param config - The verification config containing the OpenAI webhook secret and client.
34
+ * @returns A function that verifies an OpenAI webhook event.
35
35
  */
36
36
  export declare function openAIWebhookEventVerifier(config: OpenAIWebhookEventVerificationConfig): OpenAIWebhookEventVerifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
4
4
  "types": "./src/index.d.ts",
5
5
  "module": "./index.esm.js",
6
6
  "main": "./index.cjs.js",
@@ -50,7 +50,7 @@
50
50
  }
51
51
  },
52
52
  "peerDependencies": {
53
- "@dereekb/util": "13.4.0",
53
+ "@dereekb/util": "13.4.2",
54
54
  "discord.js": "^14.25.1",
55
55
  "@nestjs/common": "^11.1.16",
56
56
  "@nestjs/config": "^4.0.3",
@@ -3,4 +3,12 @@ import { type ExecutionContext } from '@nestjs/common';
3
3
  * Returns true if the request is from localhost.
4
4
  */
5
5
  export declare const IsRequestFromLocalHost: (...dataOrPipes: unknown[]) => ParameterDecorator;
6
+ /**
7
+ * Returns true if the request's origin header indicates the request came from localhost.
8
+ *
9
+ * Checks for both http://localhost and https://localhost origins.
10
+ *
11
+ * @param context - the NestJS execution context containing the HTTP request
12
+ * @returns true if the request origin is localhost
13
+ */
6
14
  export declare function isLocalhost(context: ExecutionContext): boolean;
@@ -3,19 +3,6 @@ import { type ParsedUrlQuery } from 'querystring';
3
3
  * Buffer type alias representing a raw HTTP request body before any parsing.
4
4
  */
5
5
  export type RawBodyBuffer = Buffer;
6
- /**
7
- * NestJS parameter decorator that reads the raw request body directly from the incoming stream.
8
- *
9
- * Requires the request to still be readable (i.e., no prior body-parsing middleware has consumed it).
10
- *
11
- * @throws {BadRequestException} When the request stream is not readable
12
- *
13
- * @example
14
- * ```typescript
15
- * @Post('webhook')
16
- * handleWebhook(@ParseRawBody() body: RawBodyBuffer) { ... }
17
- * ```
18
- */
19
6
  export declare const ParseRawBody: (...dataOrPipes: any[]) => ParameterDecorator;
20
7
  /**
21
8
  * NestJS parameter decorator that retrieves the already-parsed raw body buffer from `req.body`.
@@ -1,5 +1,18 @@
1
1
  import { ConfigService } from '@nestjs/config';
2
2
  import { ClientAppServiceConfig } from './client.config';
3
+ /**
4
+ * Factory that creates a ClientAppServiceConfig from environment variables.
5
+ *
6
+ * Reads the client web app URL from the CLIENT_WEB_APP_URL environment variable.
7
+ *
8
+ * @param configService - NestJS config service for reading environment variables
9
+ * @returns a validated ClientAppServiceConfig
10
+ */
3
11
  export declare function clientAppConfigFactory(configService: ConfigService): ClientAppServiceConfig;
12
+ /**
13
+ * NestJS module that provides the ClientAppService for accessing client application configuration.
14
+ *
15
+ * Reads the client web app URL from environment variables and makes it available via ClientAppService.
16
+ */
4
17
  export declare class ClientAppModule {
5
18
  }
@@ -1,3 +1,4 @@
1
+ import { type Maybe, type WebsiteUrl } from '@dereekb/util';
1
2
  /**
2
3
  * A server environment configuration.
3
4
  *
@@ -9,11 +10,11 @@ export declare abstract class ServerEnvironmentConfig {
9
10
  /**
10
11
  * Whether or not this is a production environment.
11
12
  */
12
- abstract production: boolean;
13
+ abstract readonly production: boolean;
13
14
  /**
14
15
  * Whether or not this is a staging environment.
15
16
  */
16
- abstract staging?: boolean;
17
+ abstract readonly staging?: boolean;
17
18
  /**
18
19
  * (Optional) Whether or not custom "developer tools" should be enabled.
19
20
  *
@@ -21,11 +22,11 @@ export declare abstract class ServerEnvironmentConfig {
21
22
  *
22
23
  * This is always false when production is true.
23
24
  */
24
- abstract developerToolsEnabled?: boolean;
25
+ abstract readonly developerToolsEnabled?: boolean;
25
26
  /**
26
27
  * The primary URL of the application (e.g., 'https://app.example.com').
27
28
  *
28
29
  * Should not end with a trailing slash.
29
30
  */
30
- abstract appUrl?: string;
31
+ abstract readonly appUrl?: Maybe<WebsiteUrl>;
31
32
  }
@@ -1,4 +1,6 @@
1
1
  /**
2
- * Checks process.env.NODE_ENV for "test"
2
+ * Checks process.env.NODE_ENV for "test".
3
+ *
4
+ * @returns true if the current Node environment is "test", false otherwise
3
5
  */
4
6
  export declare function isTestNodeEnv(): boolean;
@@ -4,4 +4,12 @@ import { type ServerEnvironmentConfig } from './env.config';
4
4
  * Token to access a configured ServerEnvironmentServiceConfig for the app.
5
5
  */
6
6
  export declare const SERVER_ENV_TOKEN: InjectionToken;
7
+ /**
8
+ * Creates a NestJS Provider that supplies a ServerEnvironmentConfig under the SERVER_ENV_TOKEN injection token.
9
+ *
10
+ * Use this to register a server environment configuration instance with the NestJS dependency injection container.
11
+ *
12
+ * @param env - the server environment config to provide
13
+ * @returns a NestJS Provider that supplies the config under SERVER_ENV_TOKEN
14
+ */
7
15
  export declare function serverEnvTokenProvider<T extends ServerEnvironmentConfig = ServerEnvironmentConfig>(env: T): Provider;
@@ -1,3 +1,4 @@
1
+ import { type Maybe, type WebsiteUrl } from '@dereekb/util';
1
2
  import { type ServerEnvironmentConfig } from './env.config';
2
3
  export declare class ServerEnvironmentService {
3
4
  readonly env: ServerEnvironmentConfig;
@@ -6,5 +7,5 @@ export declare class ServerEnvironmentService {
6
7
  get isProduction(): boolean;
7
8
  get isStaging(): boolean;
8
9
  get developerToolsEnabled(): boolean;
9
- get appUrl(): string | undefined;
10
+ get appUrl(): Maybe<WebsiteUrl>;
10
11
  }
@@ -4,9 +4,17 @@ export type AdditionalModuleMetadata = Partial<ModuleMetadata>;
4
4
  /**
5
5
  * Merges two module metadata entries together.
6
6
  *
7
- * @param base
8
- * @param additional
9
- * @returns
7
+ * @param base - the base module metadata
8
+ * @param additional - additional metadata to merge in
9
+ * @returns the merged module metadata
10
10
  */
11
11
  export declare function mergeModuleMetadata(base: ModuleMetadata, additional?: AdditionalModuleMetadata): ModuleMetadata;
12
+ /**
13
+ * Extracts the injection tokens from an array (or single value) of NestJS Providers.
14
+ *
15
+ * For class providers, returns the class itself; for object providers, returns the provide token.
16
+ *
17
+ * @param providers - the providers to extract tokens from
18
+ * @returns an array of injection tokens
19
+ */
12
20
  export declare function injectionTokensFromProviders(providers: ArrayOrValue<Provider<unknown>>): InjectionToken[];
@@ -6,6 +6,9 @@ export type AES256GCMEncryptionSecret = string;
6
6
  /**
7
7
  * Validates that the given secret is a 64-character hexadecimal string (32 bytes for AES-256).
8
8
  *
9
+ * @param secret - the hex-encoded secret key string to validate
10
+ * @returns true if the secret is exactly 64 valid hex characters, false otherwise
11
+ *
9
12
  * @example
10
13
  * ```typescript
11
14
  * isValidAES256GCMEncryptionSecret('a'.repeat(64)); // true
@@ -73,15 +73,22 @@ exports.StripeWebhookEventType = void 0;
73
73
  /**
74
74
  * Creates a StripeWebhookEvent and treats the data as the input type.
75
75
  *
76
- * @param event
77
- * @returns
76
+ * @param event - the raw Stripe event
77
+ * @returns a typed StripeWebhookEvent
78
78
  */ function stripeWebhookEvent(event) {
79
79
  return {
80
80
  event: event,
81
81
  data: event.data.object
82
82
  };
83
83
  }
84
- function stripeWebhookEventMapper(mapFn) {
84
+ /**
85
+ * Creates a mapper function that transforms a raw Stripe.Event into a StripeWebhookEvent using the provided mapping function.
86
+ *
87
+ * Use this when the event data object needs custom transformation before being wrapped in a StripeWebhookEvent.
88
+ *
89
+ * @param mapFn - function to transform the event data object
90
+ * @returns a function that converts a raw Stripe.Event into a StripeWebhookEvent
91
+ */ function stripeWebhookEventMapper(mapFn) {
85
92
  return function(event) {
86
93
  return {
87
94
  event: event,
@@ -94,7 +101,6 @@ var stripeEventHandlerFactory = util.handlerFactory(function(x) {
94
101
  });
95
102
  var stripeEventHandlerConfigurerFactory = util.handlerConfigurerFactory({
96
103
  configurerForAccessor: function configurerForAccessor(accessor) {
97
- // eslint-disable-next-line
98
104
  var fnWithKey = util.handlerMappedSetFunctionFactory(accessor, stripeWebhookEvent);
99
105
  var configurer = _object_spread_props(_object_spread({}, accessor), {
100
106
  handleCheckoutSessionComplete: fnWithKey(exports.StripeWebhookEventType.CHECKOUT_SESSION_COMPLETED),
@@ -220,7 +226,11 @@ function _define_property$2(obj, key, value) {
220
226
  }
221
227
  return obj;
222
228
  }
223
- exports.StripeApi = /*#__PURE__*/ function() {
229
+ /**
230
+ * Injectable service that wraps the Stripe SDK for payment operations.
231
+ *
232
+ * Provides methods for constructing and verifying Stripe webhook events.
233
+ */ exports.StripeApi = /*#__PURE__*/ function() {
224
234
  function StripeApi(config) {
225
235
  _class_call_check$4(this, StripeApi);
226
236
  _define_property$2(this, "config", void 0);
@@ -232,7 +242,12 @@ exports.StripeApi = /*#__PURE__*/ function() {
232
242
  {
233
243
  // MARK: Event
234
244
  /**
235
- * Verifies the event and reads the stripe signature from a request.
245
+ * Verifies the Stripe signature and constructs a Stripe.Event from an incoming webhook request.
246
+ *
247
+ * @param req - the incoming Express request containing the stripe-signature header
248
+ * @param rawBody - the raw request body buffer required for signature verification
249
+ * @returns the verified and parsed Stripe.Event
250
+ * @throws {BadRequestException} when the stripe-signature header is missing or verification fails
236
251
  */ key: "readStripeEventFromWebhookRequest",
237
252
  value: function readStripeEventFromWebhookRequest(req, rawBody) {
238
253
  var signature = req.get('stripe-signature');
@@ -243,7 +258,7 @@ exports.StripeApi = /*#__PURE__*/ function() {
243
258
  try {
244
259
  event = this.stripe.webhooks.constructEvent(rawBody, signature, this.config.stripe.webhookSecret);
245
260
  } catch (e) {
246
- throw new common.BadRequestException("stripe signature read error: ".concat(e === null || e === void 0 ? void 0 : e.message));
261
+ throw new common.BadRequestException("stripe signature read error: ".concat(e.message));
247
262
  }
248
263
  return event;
249
264
  }
@@ -682,7 +697,14 @@ function _class_call_check$1(instance, Constructor) {
682
697
  }
683
698
  }
684
699
  var STRIPE_DEFAULT_API_VERSION = '2020-08-27';
685
- function stripeServiceConfigFactory(configService) {
700
+ /**
701
+ * Factory that creates a StripeServiceConfig from environment variables.
702
+ *
703
+ * Reads STRIPE_SECRET and STRIPE_WEBHOOK_SECRET from environment variables using the default API version.
704
+ *
705
+ * @param configService - NestJS config service for reading environment variables
706
+ * @returns a validated StripeServiceConfig
707
+ */ function stripeServiceConfigFactory(configService) {
686
708
  var config = {
687
709
  stripe: {
688
710
  secret: configService.get('STRIPE_SECRET'),
@@ -695,7 +717,11 @@ function stripeServiceConfigFactory(configService) {
695
717
  StripeServiceConfig.assertValidConfig(config);
696
718
  return config;
697
719
  }
698
- exports.StripeModule = function StripeModule() {
720
+ /**
721
+ * NestJS module that provides the StripeApi service.
722
+ *
723
+ * Reads Stripe API credentials and webhook secret from environment variables.
724
+ */ exports.StripeModule = function StripeModule() {
699
725
  _class_call_check$1(this, StripeModule);
700
726
  };
701
727
  exports.StripeModule = __decorate([