@dereekb/nestjs 14.14.0 → 14.15.0
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/eslint/package.json +2 -2
- package/mailgun/index.esm.js +148 -4
- package/mailgun/package.json +6 -6
- package/mailgun/src/lib/mailgun.diagnostic.d.ts +110 -1
- package/openai/package.json +6 -6
- package/openrouter/package.json +3 -3
- package/package.json +3 -3
- package/stripe/package.json +6 -6
- package/twilio/index.esm.js +1181 -129
- package/twilio/package.json +6 -6
- package/twilio/src/lib/index.d.ts +1 -0
- package/twilio/src/lib/lookup/lookup.module.d.ts +19 -1
- package/twilio/src/lib/twilio.api.d.ts +11 -1
- package/twilio/src/lib/twilio.config.d.ts +55 -1
- package/twilio/src/lib/twilio.diagnostic.d.ts +306 -0
- package/twilio/src/lib/twilio.module.d.ts +38 -2
- package/twilio/src/lib/twilio.service.d.ts +4 -0
- package/twilio/src/lib/verify/verify.module.d.ts +19 -1
- package/twilio/src/lib/webhook/index.d.ts +2 -0
- package/twilio/src/lib/webhook/webhook.twilio.config.d.ts +11 -6
- package/twilio/src/lib/webhook/webhook.twilio.d.ts +11 -1
- package/twilio/src/lib/webhook/webhook.twilio.module.d.ts +35 -3
- package/twilio/src/lib/webhook/webhook.twilio.optout.d.ts +63 -0
- package/twilio/src/lib/webhook/webhook.twilio.service.d.ts +1 -2
- package/twilio/src/lib/webhook/webhook.twilio.url.d.ts +57 -0
- package/typeform/package.json +6 -6
- package/vapiai/package.json +6 -6
|
@@ -1,22 +1,54 @@
|
|
|
1
|
+
import { type ModuleMetadata } from '@nestjs/common';
|
|
1
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
4
|
import { TwilioWebhookServiceConfig } from './webhook.twilio.config';
|
|
5
|
+
import { TwilioWebhookUrlsConfig } from './webhook.twilio.url';
|
|
3
6
|
/**
|
|
4
7
|
* Factory that creates a {@link TwilioWebhookServiceConfig} from environment variables.
|
|
5
8
|
*
|
|
9
|
+
* The auth token is read from `TWILIO_WEBHOOK_AUTH_TOKEN`, falling back to `TWILIO_AUTH_TOKEN`. A real
|
|
10
|
+
* value is preferred over a placeholder one (see {@link isPlaceholderTwilioConfigValue}), so a placeholder
|
|
11
|
+
* webhook token does not shadow a real auth token. When both are placeholders the placeholder is kept,
|
|
12
|
+
* which lets the app start and rejects every request as unverified.
|
|
13
|
+
*
|
|
14
|
+
* Requests are verified against the app's public webhook URL when `webhookUrlsConfig` is set, and otherwise
|
|
15
|
+
* against the URL rebuilt from the request headers.
|
|
16
|
+
*
|
|
6
17
|
* @param configService - NestJS config service for reading environment variables.
|
|
18
|
+
* @param webhookUrlsConfig - The app's public webhook URLs.
|
|
7
19
|
* @returns A populated {@link TwilioWebhookServiceConfig}.
|
|
8
20
|
*/
|
|
9
|
-
export declare function twilioWebhookServiceConfigFactory(configService: ConfigService): TwilioWebhookServiceConfig;
|
|
21
|
+
export declare function twilioWebhookServiceConfigFactory(configService: ConfigService, webhookUrlsConfig?: Maybe<TwilioWebhookUrlsConfig>): TwilioWebhookServiceConfig;
|
|
22
|
+
export interface ProvideAppTwilioWebhookMetadataConfig extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
|
|
23
|
+
/**
|
|
24
|
+
* Optional module that exports a {@link TwilioWebhookUrlsConfig}. When provided, requests are verified against
|
|
25
|
+
* the app's public webhook URL.
|
|
26
|
+
*/
|
|
27
|
+
readonly dependencyModule?: Maybe<Required<ModuleMetadata>['imports']['0']>;
|
|
28
|
+
}
|
|
10
29
|
/**
|
|
11
|
-
*
|
|
30
|
+
* Convenience function used to generate ModuleMetadata for an app's Twilio webhook module, which handles
|
|
31
|
+
* incoming Twilio webhook requests at:
|
|
12
32
|
* - `POST /webhook/twilio/status` (Message status callbacks)
|
|
13
33
|
* - `POST /webhook/twilio/incoming` (Incoming SMS / MMS messages)
|
|
14
34
|
*
|
|
15
|
-
* Webhook bodies are verified against the X-Twilio-Signature header before dispatch.
|
|
35
|
+
* Webhook bodies are verified against the X-Twilio-Signature header before dispatch. Only the auth
|
|
36
|
+
* token is needed for that, so this module does not depend on the Twilio module and can be imported in
|
|
37
|
+
* environments without a usable Twilio sending config.
|
|
16
38
|
*
|
|
17
39
|
* Requires the consuming application to register the raw-body middleware from
|
|
18
40
|
* `@dereekb/nestjs` for the `/webhook/twilio` path so that signature verification can read
|
|
19
41
|
* the unparsed form body.
|
|
42
|
+
*
|
|
43
|
+
* Register handlers by injecting the exported {@link TwilioWebhookService} into a provider passed in `providers`.
|
|
44
|
+
*
|
|
45
|
+
* @param config - The module metadata configuration including the optional dependency module.
|
|
46
|
+
* @returns NestJS ModuleMetadata for registering the Twilio webhook module.
|
|
47
|
+
*/
|
|
48
|
+
export declare function appTwilioWebhookModuleMetadata(config?: Maybe<ProvideAppTwilioWebhookMetadataConfig>): ModuleMetadata;
|
|
49
|
+
/**
|
|
50
|
+
* NestJS module that handles incoming Twilio webhook requests at `/webhook/twilio`. See
|
|
51
|
+
* {@link appTwilioWebhookModuleMetadata}, which also lets the app supply its public webhook URLs.
|
|
20
52
|
*/
|
|
21
53
|
export declare class TwilioWebhookModule {
|
|
22
54
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type TwilioIncomingMessagePayload } from './webhook.twilio';
|
|
3
|
+
/**
|
|
4
|
+
* The opt-out keyword type Twilio reports on an incoming message (`OptOutType`).
|
|
5
|
+
*
|
|
6
|
+
* https://help.twilio.com/articles/31560110671259
|
|
7
|
+
*/
|
|
8
|
+
export declare enum TwilioOptOutType {
|
|
9
|
+
/**
|
|
10
|
+
* The sender opted out. Twilio blocks every message to them until they opt back in.
|
|
11
|
+
*/
|
|
12
|
+
STOP = "STOP",
|
|
13
|
+
/**
|
|
14
|
+
* The sender opted back in.
|
|
15
|
+
*/
|
|
16
|
+
START = "START",
|
|
17
|
+
/**
|
|
18
|
+
* The sender asked for help.
|
|
19
|
+
*/
|
|
20
|
+
HELP = "HELP"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Twilio's default opt-out keywords.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_TWILIO_OPT_OUT_KEYWORDS: readonly string[];
|
|
26
|
+
/**
|
|
27
|
+
* Twilio's default opt-in keywords.
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_TWILIO_OPT_IN_KEYWORDS: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Twilio's default help keywords.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_TWILIO_HELP_KEYWORDS: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* Reads a {@link TwilioOptOutType} from a string, case-insensitively.
|
|
36
|
+
*
|
|
37
|
+
* @param value - The value to read, such as Twilio's `OptOutType` parameter.
|
|
38
|
+
* @returns The opt-out type, or undefined when the value is not one.
|
|
39
|
+
*/
|
|
40
|
+
export declare function twilioOptOutTypeFromString(value: Maybe<string>): Maybe<TwilioOptOutType>;
|
|
41
|
+
/**
|
|
42
|
+
* Config for {@link twilioIncomingMessageOptOutType}.
|
|
43
|
+
*/
|
|
44
|
+
export interface TwilioIncomingMessageOptOutTypeConfig {
|
|
45
|
+
/**
|
|
46
|
+
* Only trust Twilio's `OptOutType` parameter, and never match the body against the default keywords.
|
|
47
|
+
*
|
|
48
|
+
* Use with Advanced Opt-Out and custom keywords, where the default keywords may not be keywords at all.
|
|
49
|
+
*/
|
|
50
|
+
readonly optOutTypeOnly?: Maybe<boolean>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the opt-out keyword type of an incoming message, if it is one.
|
|
54
|
+
*
|
|
55
|
+
* Twilio's `OptOutType` parameter wins when present. It is only sent for messages to a Messaging Service, or to a number with
|
|
56
|
+
* Advanced Opt-Out. Otherwise the body is matched, trimmed and case-insensitively, against Twilio's default keywords. Only a whole-body
|
|
57
|
+
* match counts, so "Stop please" is not a keyword, matching how Twilio itself handles keywords.
|
|
58
|
+
*
|
|
59
|
+
* @param payload - The incoming message.
|
|
60
|
+
* @param config - Whether to skip the default keyword fallback.
|
|
61
|
+
* @returns The opt-out type, or undefined when the message is not a keyword.
|
|
62
|
+
*/
|
|
63
|
+
export declare function twilioIncomingMessageOptOutType(payload: Pick<TwilioIncomingMessagePayload, 'OptOutType' | 'Body'>, config?: Maybe<TwilioIncomingMessageOptOutTypeConfig>): Maybe<TwilioOptOutType>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type Handler } from '@dereekb/util';
|
|
2
2
|
import { type Request } from 'express';
|
|
3
|
-
import { TwilioApi } from '../twilio.api';
|
|
4
3
|
import { type TwilioWebhookEvent, type TwilioWebhookEventType } from './webhook.twilio';
|
|
5
4
|
import { TwilioWebhookServiceConfig } from './webhook.twilio.config';
|
|
6
5
|
export declare class TwilioWebhookService {
|
|
@@ -8,7 +7,7 @@ export declare class TwilioWebhookService {
|
|
|
8
7
|
private readonly _verifier;
|
|
9
8
|
readonly handler: Handler<TwilioWebhookEvent, TwilioWebhookEventType>;
|
|
10
9
|
readonly configure: import("@dereekb/util").HandlerConfigurer<import("./webhook.twilio").TwilioWebhookEventHandlerConfigurer, TwilioWebhookEvent, TwilioWebhookEventType, boolean>;
|
|
11
|
-
constructor(
|
|
10
|
+
constructor(webhookConfig: TwilioWebhookServiceConfig);
|
|
12
11
|
handleStatusCallback(req: Request, rawBody: Buffer): Promise<void>;
|
|
13
12
|
handleIncomingMessage(req: Request, rawBody: Buffer): Promise<void>;
|
|
14
13
|
private dispatchEvent;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Maybe, type WebsitePath, type WebsiteUrl } from '@dereekb/util';
|
|
2
|
+
import { type TwilioStatusCallbackUrl } from '../twilio.type';
|
|
3
|
+
/**
|
|
4
|
+
* Path of the {@link TwilioWebhookController} under the app's webhook path (`/webhook`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const TWILIO_WEBHOOK_PATH: WebsitePath;
|
|
7
|
+
/**
|
|
8
|
+
* Path of the message status callback route under {@link TWILIO_WEBHOOK_PATH}.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TWILIO_WEBHOOK_STATUS_PATH: WebsitePath;
|
|
11
|
+
/**
|
|
12
|
+
* Path of the incoming message route under {@link TWILIO_WEBHOOK_PATH}.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TWILIO_WEBHOOK_INCOMING_PATH: WebsitePath;
|
|
15
|
+
/**
|
|
16
|
+
* Public URLs of the {@link TwilioWebhookController} routes.
|
|
17
|
+
*/
|
|
18
|
+
export interface TwilioWebhookUrls {
|
|
19
|
+
/**
|
|
20
|
+
* Origin Twilio calls the webhooks on. Use as `TwilioWebhookConfig.baseUrl`.
|
|
21
|
+
*/
|
|
22
|
+
readonly baseUrl: WebsiteUrl;
|
|
23
|
+
/**
|
|
24
|
+
* URL Twilio posts message status updates to. Use as `TwilioMessagesConfig.defaultStatusCallback`.
|
|
25
|
+
*/
|
|
26
|
+
readonly statusCallbackUrl: TwilioStatusCallbackUrl;
|
|
27
|
+
/**
|
|
28
|
+
* URL Twilio posts incoming messages to. Set it as the phone number's "A message comes in" webhook in the Twilio Console.
|
|
29
|
+
*/
|
|
30
|
+
readonly incomingMessageUrl: WebsiteUrl;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Builds the public URLs of the {@link TwilioWebhookController} routes from the app's public webhook URL.
|
|
34
|
+
*
|
|
35
|
+
* The `baseUrl` is the origin of the webhook URL, since the verifier appends the request's full path to it.
|
|
36
|
+
* This assumes requests reach the app with their public path intact, as they do through a Firebase Hosting
|
|
37
|
+
* rewrite.
|
|
38
|
+
*
|
|
39
|
+
* @param webhookUrl - Public URL the app's `/webhook` routes are served at, e.g. `https://app.example.com/api/webhook`.
|
|
40
|
+
* @returns The Twilio webhook URLs.
|
|
41
|
+
*/
|
|
42
|
+
export declare function twilioWebhookUrls(webhookUrl: WebsiteUrl): TwilioWebhookUrls;
|
|
43
|
+
/**
|
|
44
|
+
* The app's public Twilio webhook URLs, provided to the Twilio modules through their `dependencyModule`.
|
|
45
|
+
*
|
|
46
|
+
* When a module built by `appTwilioModuleMetadata()` can resolve it, outbound texts request status callbacks at
|
|
47
|
+
* {@link TwilioWebhookUrls.statusCallbackUrl}. When one built by `appTwilioWebhookModuleMetadata()` can, webhook
|
|
48
|
+
* requests are verified against {@link TwilioWebhookUrls.baseUrl}.
|
|
49
|
+
*
|
|
50
|
+
* `twilioWebhookUrlsConfigProvider()` from `@dereekb/firebase-server/twilio` provides it from the server environment.
|
|
51
|
+
*/
|
|
52
|
+
export declare abstract class TwilioWebhookUrlsConfig {
|
|
53
|
+
/**
|
|
54
|
+
* The URLs, or undefined when Twilio cannot reach the app's webhooks.
|
|
55
|
+
*/
|
|
56
|
+
readonly twilioWebhookUrls?: Maybe<TwilioWebhookUrls>;
|
|
57
|
+
}
|
package/typeform/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/nestjs/typeform",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.15.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@dereekb/date": "14.
|
|
8
|
-
"@dereekb/model": "14.
|
|
9
|
-
"@dereekb/nestjs": "14.
|
|
10
|
-
"@dereekb/rxjs": "14.
|
|
11
|
-
"@dereekb/util": "14.
|
|
7
|
+
"@dereekb/date": "14.15.0",
|
|
8
|
+
"@dereekb/model": "14.15.0",
|
|
9
|
+
"@dereekb/nestjs": "14.15.0",
|
|
10
|
+
"@dereekb/rxjs": "14.15.0",
|
|
11
|
+
"@dereekb/util": "14.15.0",
|
|
12
12
|
"@nestjs/common": "^12.0.1",
|
|
13
13
|
"@nestjs/config": "^12.0.0",
|
|
14
14
|
"@typeform/api-client": "^2.10.2",
|
package/vapiai/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/nestjs/vapiai",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.15.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@dereekb/date": "14.
|
|
8
|
-
"@dereekb/model": "14.
|
|
9
|
-
"@dereekb/nestjs": "14.
|
|
10
|
-
"@dereekb/rxjs": "14.
|
|
11
|
-
"@dereekb/util": "14.
|
|
7
|
+
"@dereekb/date": "14.15.0",
|
|
8
|
+
"@dereekb/model": "14.15.0",
|
|
9
|
+
"@dereekb/nestjs": "14.15.0",
|
|
10
|
+
"@dereekb/rxjs": "14.15.0",
|
|
11
|
+
"@dereekb/util": "14.15.0",
|
|
12
12
|
"@nestjs/common": "^12.0.1",
|
|
13
13
|
"@nestjs/config": "^12.0.0",
|
|
14
14
|
"@vapi-ai/server-sdk": "^1.2.0",
|