meta-cloud-api 0.2.12 → 0.2.13
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/README.md +5 -2
- package/dist/api/index.d.mts +495 -27
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/chunk-KZQQJAPX.mjs +2 -0
- package/dist/chunk-KZQQJAPX.mjs.map +1 -0
- package/dist/chunk-N7A7DQDX.mjs +2 -0
- package/dist/chunk-N7A7DQDX.mjs.map +1 -0
- package/dist/chunk-QE4PKOSW.mjs +2 -0
- package/dist/chunk-QE4PKOSW.mjs.map +1 -0
- package/dist/chunk-R4CFE2XP.mjs +2 -0
- package/dist/chunk-R4CFE2XP.mjs.map +1 -0
- package/dist/chunk-XVYL7ZTG.mjs +2 -0
- package/dist/chunk-XVYL7ZTG.mjs.map +1 -0
- package/dist/index.d.mts +142 -43
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.mts +512 -19
- package/dist/types/index.mjs +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/index.d.mts +70 -21
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/waba-RRlZTQUG.d.mts +2229 -0
- package/dist/{types/whatsapp.d.ts → whatsapp-BNHXjrds.d.mts} +2 -17
- package/package.json +52 -18
- package/dist/api/base.d.mts +0 -15
- package/dist/api/base.d.ts +0 -15
- package/dist/api/base.js +0 -2
- package/dist/api/base.js.map +0 -1
- package/dist/api/base.mjs +0 -2
- package/dist/api/base.mjs.map +0 -1
- package/dist/api/businessProfile.d.mts +0 -145
- package/dist/api/businessProfile.d.ts +0 -145
- package/dist/api/businessProfile.js +0 -2
- package/dist/api/businessProfile.js.map +0 -1
- package/dist/api/businessProfile.mjs +0 -2
- package/dist/api/businessProfile.mjs.map +0 -1
- package/dist/api/encryption.d.mts +0 -15
- package/dist/api/encryption.d.ts +0 -15
- package/dist/api/encryption.js +0 -2
- package/dist/api/encryption.js.map +0 -1
- package/dist/api/encryption.mjs +0 -2
- package/dist/api/encryption.mjs.map +0 -1
- package/dist/api/flow.d.mts +0 -126
- package/dist/api/flow.d.ts +0 -126
- package/dist/api/flow.js +0 -2
- package/dist/api/flow.js.map +0 -1
- package/dist/api/flow.mjs +0 -2
- package/dist/api/flow.mjs.map +0 -1
- package/dist/api/index.d.ts +0 -28
- package/dist/api/index.js +0 -2
- package/dist/api/index.js.map +0 -1
- package/dist/api/media.d.mts +0 -17
- package/dist/api/media.d.ts +0 -17
- package/dist/api/media.js +0 -2
- package/dist/api/media.js.map +0 -1
- package/dist/api/media.mjs +0 -2
- package/dist/api/media.mjs.map +0 -1
- package/dist/api/messages.d.mts +0 -193
- package/dist/api/messages.d.ts +0 -193
- package/dist/api/messages.js +0 -2
- package/dist/api/messages.js.map +0 -1
- package/dist/api/messages.mjs +0 -2
- package/dist/api/messages.mjs.map +0 -1
- package/dist/api/phoneNumber.d.mts +0 -17
- package/dist/api/phoneNumber.d.ts +0 -17
- package/dist/api/phoneNumber.js +0 -2
- package/dist/api/phoneNumber.js.map +0 -1
- package/dist/api/phoneNumber.mjs +0 -2
- package/dist/api/phoneNumber.mjs.map +0 -1
- package/dist/api/qrCode.d.mts +0 -18
- package/dist/api/qrCode.d.ts +0 -18
- package/dist/api/qrCode.js +0 -2
- package/dist/api/qrCode.js.map +0 -1
- package/dist/api/qrCode.mjs +0 -2
- package/dist/api/qrCode.mjs.map +0 -1
- package/dist/api/registration.d.mts +0 -14
- package/dist/api/registration.d.ts +0 -14
- package/dist/api/registration.js +0 -2
- package/dist/api/registration.js.map +0 -1
- package/dist/api/registration.mjs +0 -2
- package/dist/api/registration.mjs.map +0 -1
- package/dist/api/template.d.mts +0 -18
- package/dist/api/template.d.ts +0 -18
- package/dist/api/template.js +0 -2
- package/dist/api/template.js.map +0 -1
- package/dist/api/template.mjs +0 -2
- package/dist/api/template.mjs.map +0 -1
- package/dist/api/twoStepVerification.d.mts +0 -13
- package/dist/api/twoStepVerification.d.ts +0 -13
- package/dist/api/twoStepVerification.js +0 -2
- package/dist/api/twoStepVerification.js.map +0 -1
- package/dist/api/twoStepVerification.mjs +0 -2
- package/dist/api/twoStepVerification.mjs.map +0 -1
- package/dist/api/waba.d.mts +0 -16
- package/dist/api/waba.d.ts +0 -16
- package/dist/api/waba.js +0 -2
- package/dist/api/waba.js.map +0 -1
- package/dist/api/waba.mjs +0 -2
- package/dist/api/waba.mjs.map +0 -1
- package/dist/enums-CI7vzKhn.d.mts +0 -687
- package/dist/enums-CI7vzKhn.d.ts +0 -687
- package/dist/httpsClient.d.mts +0 -22
- package/dist/httpsClient.d.ts +0 -22
- package/dist/httpsClient.js +0 -2
- package/dist/httpsClient.js.map +0 -1
- package/dist/httpsClient.mjs +0 -2
- package/dist/httpsClient.mjs.map +0 -1
- package/dist/index.d.ts +0 -46
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/request.d.mts +0 -25
- package/dist/request.d.ts +0 -25
- package/dist/request.js +0 -2
- package/dist/request.js.map +0 -1
- package/dist/request.mjs +0 -2
- package/dist/request.mjs.map +0 -1
- package/dist/types/base.d.mts +0 -8
- package/dist/types/base.d.ts +0 -8
- package/dist/types/base.js +0 -2
- package/dist/types/base.js.map +0 -1
- package/dist/types/base.mjs +0 -1
- package/dist/types/base.mjs.map +0 -1
- package/dist/types/businessProfile.d.mts +0 -153
- package/dist/types/businessProfile.d.ts +0 -153
- package/dist/types/businessProfile.js +0 -2
- package/dist/types/businessProfile.js.map +0 -1
- package/dist/types/businessProfile.mjs +0 -1
- package/dist/types/businessProfile.mjs.map +0 -1
- package/dist/types/config.d.mts +0 -62
- package/dist/types/config.d.ts +0 -62
- package/dist/types/config.js +0 -2
- package/dist/types/config.js.map +0 -1
- package/dist/types/config.mjs +0 -1
- package/dist/types/config.mjs.map +0 -1
- package/dist/types/encryption.d.mts +0 -13
- package/dist/types/encryption.d.ts +0 -13
- package/dist/types/encryption.js +0 -2
- package/dist/types/encryption.js.map +0 -1
- package/dist/types/encryption.mjs +0 -1
- package/dist/types/encryption.mjs.map +0 -1
- package/dist/types/enums.d.mts +0 -1
- package/dist/types/enums.d.ts +0 -1
- package/dist/types/enums.js +0 -2
- package/dist/types/enums.js.map +0 -1
- package/dist/types/enums.mjs +0 -2
- package/dist/types/enums.mjs.map +0 -1
- package/dist/types/flow.d.mts +0 -404
- package/dist/types/flow.d.ts +0 -404
- package/dist/types/flow.js +0 -2
- package/dist/types/flow.js.map +0 -1
- package/dist/types/flow.mjs +0 -2
- package/dist/types/flow.mjs.map +0 -1
- package/dist/types/httpsClient.d.mts +0 -19
- package/dist/types/httpsClient.d.ts +0 -19
- package/dist/types/httpsClient.js +0 -2
- package/dist/types/httpsClient.js.map +0 -1
- package/dist/types/httpsClient.mjs +0 -1
- package/dist/types/httpsClient.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -20
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/logger.d.mts +0 -9
- package/dist/types/logger.d.ts +0 -9
- package/dist/types/logger.js +0 -2
- package/dist/types/logger.js.map +0 -1
- package/dist/types/logger.mjs +0 -1
- package/dist/types/logger.mjs.map +0 -1
- package/dist/types/media.d.mts +0 -31
- package/dist/types/media.d.ts +0 -31
- package/dist/types/media.js +0 -2
- package/dist/types/media.js.map +0 -1
- package/dist/types/media.mjs +0 -1
- package/dist/types/media.mjs.map +0 -1
- package/dist/types/messages.d.mts +0 -558
- package/dist/types/messages.d.ts +0 -558
- package/dist/types/messages.js +0 -2
- package/dist/types/messages.js.map +0 -1
- package/dist/types/messages.mjs +0 -1
- package/dist/types/messages.mjs.map +0 -1
- package/dist/types/phoneNumber.d.mts +0 -82
- package/dist/types/phoneNumber.d.ts +0 -82
- package/dist/types/phoneNumber.js +0 -2
- package/dist/types/phoneNumber.js.map +0 -1
- package/dist/types/phoneNumber.mjs +0 -1
- package/dist/types/phoneNumber.mjs.map +0 -1
- package/dist/types/qrCode.d.mts +0 -27
- package/dist/types/qrCode.d.ts +0 -27
- package/dist/types/qrCode.js +0 -2
- package/dist/types/qrCode.js.map +0 -1
- package/dist/types/qrCode.mjs +0 -1
- package/dist/types/qrCode.mjs.map +0 -1
- package/dist/types/registration.d.mts +0 -14
- package/dist/types/registration.d.ts +0 -14
- package/dist/types/registration.js +0 -2
- package/dist/types/registration.js.map +0 -1
- package/dist/types/registration.mjs +0 -1
- package/dist/types/registration.mjs.map +0 -1
- package/dist/types/request.d.mts +0 -50
- package/dist/types/request.d.ts +0 -50
- package/dist/types/request.js +0 -2
- package/dist/types/request.js.map +0 -1
- package/dist/types/request.mjs +0 -1
- package/dist/types/request.mjs.map +0 -1
- package/dist/types/template.d.mts +0 -106
- package/dist/types/template.d.ts +0 -106
- package/dist/types/template.js +0 -2
- package/dist/types/template.js.map +0 -1
- package/dist/types/template.mjs +0 -1
- package/dist/types/template.mjs.map +0 -1
- package/dist/types/twoStepVerification.d.mts +0 -11
- package/dist/types/twoStepVerification.d.ts +0 -11
- package/dist/types/twoStepVerification.js +0 -2
- package/dist/types/twoStepVerification.js.map +0 -1
- package/dist/types/twoStepVerification.mjs +0 -1
- package/dist/types/twoStepVerification.mjs.map +0 -1
- package/dist/types/waba.d.mts +0 -78
- package/dist/types/waba.d.ts +0 -78
- package/dist/types/waba.js +0 -2
- package/dist/types/waba.js.map +0 -1
- package/dist/types/waba.mjs +0 -2
- package/dist/types/waba.mjs.map +0 -1
- package/dist/types/webhook.d.mts +0 -486
- package/dist/types/webhook.d.ts +0 -486
- package/dist/types/webhook.js +0 -2
- package/dist/types/webhook.js.map +0 -1
- package/dist/types/webhook.mjs +0 -2
- package/dist/types/webhook.mjs.map +0 -1
- package/dist/types/whatsapp.d.mts +0 -61
- package/dist/types/whatsapp.js +0 -2
- package/dist/types/whatsapp.js.map +0 -1
- package/dist/types/whatsapp.mjs +0 -1
- package/dist/types/whatsapp.mjs.map +0 -1
- package/dist/utils/buildFieldsQueryString.d.mts +0 -3
- package/dist/utils/buildFieldsQueryString.d.ts +0 -3
- package/dist/utils/buildFieldsQueryString.js +0 -2
- package/dist/utils/buildFieldsQueryString.js.map +0 -1
- package/dist/utils/buildFieldsQueryString.mjs +0 -2
- package/dist/utils/buildFieldsQueryString.mjs.map +0 -1
- package/dist/utils/filters.d.mts +0 -144
- package/dist/utils/filters.d.ts +0 -144
- package/dist/utils/filters.js +0 -2
- package/dist/utils/filters.js.map +0 -1
- package/dist/utils/filters.mjs +0 -2
- package/dist/utils/filters.mjs.map +0 -1
- package/dist/utils/flowTypeGuards.d.mts +0 -46
- package/dist/utils/flowTypeGuards.d.ts +0 -46
- package/dist/utils/flowTypeGuards.js +0 -2
- package/dist/utils/flowTypeGuards.js.map +0 -1
- package/dist/utils/flowTypeGuards.mjs +0 -2
- package/dist/utils/flowTypeGuards.mjs.map +0 -1
- package/dist/utils/generateXHub256Sig.d.mts +0 -3
- package/dist/utils/generateXHub256Sig.d.ts +0 -3
- package/dist/utils/generateXHub256Sig.js +0 -2
- package/dist/utils/generateXHub256Sig.js.map +0 -1
- package/dist/utils/generateXHub256Sig.mjs +0 -2
- package/dist/utils/generateXHub256Sig.mjs.map +0 -1
- package/dist/utils/importConfig.d.mts +0 -21
- package/dist/utils/importConfig.d.ts +0 -21
- package/dist/utils/importConfig.js +0 -2
- package/dist/utils/importConfig.js.map +0 -1
- package/dist/utils/importConfig.mjs +0 -2
- package/dist/utils/importConfig.mjs.map +0 -1
- package/dist/utils/index.d.ts +0 -22
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/isMetaError.d.mts +0 -21
- package/dist/utils/isMetaError.d.ts +0 -21
- package/dist/utils/isMetaError.js +0 -2
- package/dist/utils/isMetaError.js.map +0 -1
- package/dist/utils/isMetaError.mjs +0 -2
- package/dist/utils/isMetaError.mjs.map +0 -1
- package/dist/utils/logger.d.mts +0 -13
- package/dist/utils/logger.d.ts +0 -13
- package/dist/utils/logger.js +0 -2
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/logger.mjs +0 -2
- package/dist/utils/logger.mjs.map +0 -1
- package/dist/utils/objectToQueryString.d.mts +0 -3
- package/dist/utils/objectToQueryString.d.ts +0 -3
- package/dist/utils/objectToQueryString.js +0 -2
- package/dist/utils/objectToQueryString.js.map +0 -1
- package/dist/utils/objectToQueryString.mjs +0 -2
- package/dist/utils/objectToQueryString.mjs.map +0 -1
- package/dist/webhook.d.mts +0 -123
- package/dist/webhook.d.ts +0 -123
- package/dist/webhook.js +0 -3
- package/dist/webhook.js.map +0 -1
- package/dist/webhook.mjs +0 -3
- package/dist/webhook.mjs.map +0 -1
- package/dist/whatsapp.d.mts +0 -58
- package/dist/whatsapp.d.ts +0 -58
- package/dist/whatsapp.js +0 -2
- package/dist/whatsapp.js.map +0 -1
- package/dist/whatsapp.mjs +0 -2
- package/dist/whatsapp.mjs.map +0 -1
package/dist/utils/filters.d.mts
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { M as MessageTypesEnum } from '../enums-CI7vzKhn.mjs';
|
|
2
|
-
import { WebhookMessage } from '../types/webhook.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Filters for message handling, inspired by PyWa
|
|
6
|
-
*/
|
|
7
|
-
declare const filters: {
|
|
8
|
-
/**
|
|
9
|
-
* Filters messages by type
|
|
10
|
-
* @param type Message type to filter for
|
|
11
|
-
* @returns A filter function
|
|
12
|
-
*/
|
|
13
|
-
type: (type: MessageTypesEnum | string) => ((message: WebhookMessage) => boolean);
|
|
14
|
-
/**
|
|
15
|
-
* Filters text messages
|
|
16
|
-
* @param message Message to check
|
|
17
|
-
* @returns True if the message is a text message
|
|
18
|
-
*/
|
|
19
|
-
text: (message: WebhookMessage) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Filters image messages
|
|
22
|
-
* @param message Message to check
|
|
23
|
-
* @returns True if the message is an image message
|
|
24
|
-
*/
|
|
25
|
-
image: (message: WebhookMessage) => boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Filters audio messages
|
|
28
|
-
* @param message Message to check
|
|
29
|
-
* @returns True if the message is an audio message
|
|
30
|
-
*/
|
|
31
|
-
audio: (message: WebhookMessage) => boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Filters video messages
|
|
34
|
-
* @param message Message to check
|
|
35
|
-
* @returns True if the message is a video message
|
|
36
|
-
*/
|
|
37
|
-
video: (message: WebhookMessage) => boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Filters document messages
|
|
40
|
-
* @param message Message to check
|
|
41
|
-
* @returns True if the message is a document message
|
|
42
|
-
*/
|
|
43
|
-
document: (message: WebhookMessage) => boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Filters sticker messages
|
|
46
|
-
* @param message Message to check
|
|
47
|
-
* @returns True if the message is a sticker message
|
|
48
|
-
*/
|
|
49
|
-
sticker: (message: WebhookMessage) => boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Filters location messages
|
|
52
|
-
* @param message Message to check
|
|
53
|
-
* @returns True if the message is a location message
|
|
54
|
-
*/
|
|
55
|
-
location: (message: WebhookMessage) => boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Filters contact messages
|
|
58
|
-
* @param message Message to check
|
|
59
|
-
* @returns True if the message is a contacts message
|
|
60
|
-
*/
|
|
61
|
-
contacts: (message: WebhookMessage) => boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Filters button messages
|
|
64
|
-
* @param message Message to check
|
|
65
|
-
* @returns True if the message is a button message
|
|
66
|
-
*/
|
|
67
|
-
button: (message: WebhookMessage) => boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Filters interactive messages
|
|
70
|
-
* @param message Message to check
|
|
71
|
-
* @returns True if the message is an interactive message
|
|
72
|
-
*/
|
|
73
|
-
interactive: (message: WebhookMessage) => boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Filters system messages
|
|
76
|
-
* @param message Message to check
|
|
77
|
-
* @returns True if the message is a system message
|
|
78
|
-
*/
|
|
79
|
-
system: (message: WebhookMessage) => boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Filters order messages
|
|
82
|
-
* @param message Message to check
|
|
83
|
-
* @returns True if the message is an order message
|
|
84
|
-
*/
|
|
85
|
-
order: (message: WebhookMessage) => boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Matches text content against a pattern
|
|
88
|
-
* @param patterns String or regular expression or array of patterns to match against
|
|
89
|
-
* @returns A filter function
|
|
90
|
-
*/
|
|
91
|
-
matches: (patterns: string | RegExp | (string | RegExp)[]) => ((message: WebhookMessage) => boolean);
|
|
92
|
-
/**
|
|
93
|
-
* Checks if a message is a reply to another message
|
|
94
|
-
* @returns A filter function that returns true if the message is a reply
|
|
95
|
-
*/
|
|
96
|
-
isReply: (message: WebhookMessage) => boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Checks if a message is a reply to a specific message
|
|
99
|
-
* @param messageId The ID of the original message to check for
|
|
100
|
-
* @returns A filter function that returns true if the message is a reply to the specified message
|
|
101
|
-
*/
|
|
102
|
-
isReplyTo: (messageId: string) => ((message: WebhookMessage) => boolean);
|
|
103
|
-
/**
|
|
104
|
-
* Checks if a message is forwarded
|
|
105
|
-
* @returns A filter function that returns true if the message is forwarded
|
|
106
|
-
*/
|
|
107
|
-
isForwarded: (message: WebhookMessage) => boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Checks if a message is frequently forwarded
|
|
110
|
-
* @returns A filter function that returns true if the message is frequently forwarded
|
|
111
|
-
*/
|
|
112
|
-
isFrequentlyForwarded: (message: WebhookMessage) => boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Combines multiple filters with AND logic
|
|
115
|
-
* @param filterFunctions Array of filter functions to combine
|
|
116
|
-
* @returns A filter function that returns true only if all filters return true
|
|
117
|
-
*/
|
|
118
|
-
and: (...filterFunctions: ((message: WebhookMessage) => boolean)[]) => ((message: WebhookMessage) => boolean);
|
|
119
|
-
/**
|
|
120
|
-
* Combines multiple filters with OR logic
|
|
121
|
-
* @param filterFunctions Array of filter functions to combine
|
|
122
|
-
* @returns A filter function that returns true if any filter returns true
|
|
123
|
-
*/
|
|
124
|
-
or: (...filterFunctions: ((message: WebhookMessage) => boolean)[]) => ((message: WebhookMessage) => boolean);
|
|
125
|
-
/**
|
|
126
|
-
* Negates a filter
|
|
127
|
-
* @param filterFunction Filter function to negate
|
|
128
|
-
* @returns A filter function that returns the opposite of the input filter
|
|
129
|
-
*/
|
|
130
|
-
not: (filterFunction: (message: WebhookMessage) => boolean) => ((message: WebhookMessage) => boolean);
|
|
131
|
-
/**
|
|
132
|
-
* Filters messages from a specific sender
|
|
133
|
-
* @param from Sender phone number to filter for
|
|
134
|
-
* @returns A filter function
|
|
135
|
-
*/
|
|
136
|
-
from: (from: string) => ((message: WebhookMessage) => boolean);
|
|
137
|
-
/**
|
|
138
|
-
* Filter function that accepts all messages
|
|
139
|
-
* @returns Always returns true
|
|
140
|
-
*/
|
|
141
|
-
all: () => ((message: WebhookMessage) => boolean);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export { filters };
|
package/dist/utils/filters.d.ts
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { M as MessageTypesEnum } from '../enums-CI7vzKhn.js';
|
|
2
|
-
import { WebhookMessage } from '../types/webhook.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Filters for message handling, inspired by PyWa
|
|
6
|
-
*/
|
|
7
|
-
declare const filters: {
|
|
8
|
-
/**
|
|
9
|
-
* Filters messages by type
|
|
10
|
-
* @param type Message type to filter for
|
|
11
|
-
* @returns A filter function
|
|
12
|
-
*/
|
|
13
|
-
type: (type: MessageTypesEnum | string) => ((message: WebhookMessage) => boolean);
|
|
14
|
-
/**
|
|
15
|
-
* Filters text messages
|
|
16
|
-
* @param message Message to check
|
|
17
|
-
* @returns True if the message is a text message
|
|
18
|
-
*/
|
|
19
|
-
text: (message: WebhookMessage) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Filters image messages
|
|
22
|
-
* @param message Message to check
|
|
23
|
-
* @returns True if the message is an image message
|
|
24
|
-
*/
|
|
25
|
-
image: (message: WebhookMessage) => boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Filters audio messages
|
|
28
|
-
* @param message Message to check
|
|
29
|
-
* @returns True if the message is an audio message
|
|
30
|
-
*/
|
|
31
|
-
audio: (message: WebhookMessage) => boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Filters video messages
|
|
34
|
-
* @param message Message to check
|
|
35
|
-
* @returns True if the message is a video message
|
|
36
|
-
*/
|
|
37
|
-
video: (message: WebhookMessage) => boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Filters document messages
|
|
40
|
-
* @param message Message to check
|
|
41
|
-
* @returns True if the message is a document message
|
|
42
|
-
*/
|
|
43
|
-
document: (message: WebhookMessage) => boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Filters sticker messages
|
|
46
|
-
* @param message Message to check
|
|
47
|
-
* @returns True if the message is a sticker message
|
|
48
|
-
*/
|
|
49
|
-
sticker: (message: WebhookMessage) => boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Filters location messages
|
|
52
|
-
* @param message Message to check
|
|
53
|
-
* @returns True if the message is a location message
|
|
54
|
-
*/
|
|
55
|
-
location: (message: WebhookMessage) => boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Filters contact messages
|
|
58
|
-
* @param message Message to check
|
|
59
|
-
* @returns True if the message is a contacts message
|
|
60
|
-
*/
|
|
61
|
-
contacts: (message: WebhookMessage) => boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Filters button messages
|
|
64
|
-
* @param message Message to check
|
|
65
|
-
* @returns True if the message is a button message
|
|
66
|
-
*/
|
|
67
|
-
button: (message: WebhookMessage) => boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Filters interactive messages
|
|
70
|
-
* @param message Message to check
|
|
71
|
-
* @returns True if the message is an interactive message
|
|
72
|
-
*/
|
|
73
|
-
interactive: (message: WebhookMessage) => boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Filters system messages
|
|
76
|
-
* @param message Message to check
|
|
77
|
-
* @returns True if the message is a system message
|
|
78
|
-
*/
|
|
79
|
-
system: (message: WebhookMessage) => boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Filters order messages
|
|
82
|
-
* @param message Message to check
|
|
83
|
-
* @returns True if the message is an order message
|
|
84
|
-
*/
|
|
85
|
-
order: (message: WebhookMessage) => boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Matches text content against a pattern
|
|
88
|
-
* @param patterns String or regular expression or array of patterns to match against
|
|
89
|
-
* @returns A filter function
|
|
90
|
-
*/
|
|
91
|
-
matches: (patterns: string | RegExp | (string | RegExp)[]) => ((message: WebhookMessage) => boolean);
|
|
92
|
-
/**
|
|
93
|
-
* Checks if a message is a reply to another message
|
|
94
|
-
* @returns A filter function that returns true if the message is a reply
|
|
95
|
-
*/
|
|
96
|
-
isReply: (message: WebhookMessage) => boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Checks if a message is a reply to a specific message
|
|
99
|
-
* @param messageId The ID of the original message to check for
|
|
100
|
-
* @returns A filter function that returns true if the message is a reply to the specified message
|
|
101
|
-
*/
|
|
102
|
-
isReplyTo: (messageId: string) => ((message: WebhookMessage) => boolean);
|
|
103
|
-
/**
|
|
104
|
-
* Checks if a message is forwarded
|
|
105
|
-
* @returns A filter function that returns true if the message is forwarded
|
|
106
|
-
*/
|
|
107
|
-
isForwarded: (message: WebhookMessage) => boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Checks if a message is frequently forwarded
|
|
110
|
-
* @returns A filter function that returns true if the message is frequently forwarded
|
|
111
|
-
*/
|
|
112
|
-
isFrequentlyForwarded: (message: WebhookMessage) => boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Combines multiple filters with AND logic
|
|
115
|
-
* @param filterFunctions Array of filter functions to combine
|
|
116
|
-
* @returns A filter function that returns true only if all filters return true
|
|
117
|
-
*/
|
|
118
|
-
and: (...filterFunctions: ((message: WebhookMessage) => boolean)[]) => ((message: WebhookMessage) => boolean);
|
|
119
|
-
/**
|
|
120
|
-
* Combines multiple filters with OR logic
|
|
121
|
-
* @param filterFunctions Array of filter functions to combine
|
|
122
|
-
* @returns A filter function that returns true if any filter returns true
|
|
123
|
-
*/
|
|
124
|
-
or: (...filterFunctions: ((message: WebhookMessage) => boolean)[]) => ((message: WebhookMessage) => boolean);
|
|
125
|
-
/**
|
|
126
|
-
* Negates a filter
|
|
127
|
-
* @param filterFunction Filter function to negate
|
|
128
|
-
* @returns A filter function that returns the opposite of the input filter
|
|
129
|
-
*/
|
|
130
|
-
not: (filterFunction: (message: WebhookMessage) => boolean) => ((message: WebhookMessage) => boolean);
|
|
131
|
-
/**
|
|
132
|
-
* Filters messages from a specific sender
|
|
133
|
-
* @param from Sender phone number to filter for
|
|
134
|
-
* @returns A filter function
|
|
135
|
-
*/
|
|
136
|
-
from: (from: string) => ((message: WebhookMessage) => boolean);
|
|
137
|
-
/**
|
|
138
|
-
* Filter function that accepts all messages
|
|
139
|
-
* @returns Always returns true
|
|
140
|
-
*/
|
|
141
|
-
all: () => ((message: WebhookMessage) => boolean);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export { filters };
|
package/dist/utils/filters.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var r=(t,i)=>{for(var o in i)l(t,o,{get:i[o],enumerable:!0})},_=(t,i,o,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of A(i))!R.call(t,e)&&e!==o&&l(t,e,{get:()=>i[e],enumerable:!(a=p(i,e))||a.enumerable});return t};var P=t=>_(l({},"__esModule",{value:!0}),t);var D={};r(D,{filters:()=>S});module.exports=P(D);var S={type:t=>i=>i.type===t,text:t=>t.type==="text",image:t=>t.type==="image",audio:t=>t.type==="audio",video:t=>t.type==="video",document:t=>t.type==="document",sticker:t=>t.type==="sticker",location:t=>t.type==="location",contacts:t=>t.type==="contacts",button:t=>t.type==="button",interactive:t=>t.type==="interactive",system:t=>t.type==="system",order:t=>t.type==="order",matches:t=>{let i=Array.isArray(t)?t:[t];return o=>{if(o.type!=="text"||!o.text)return!1;let a=o.text.body;for(let e of i)if(typeof e=="string"){if(a.includes(e))return!0}else if(e instanceof RegExp&&e.test(a))return!0;return!1}},isReply:t=>!!t.context&&!!t.context.message_id,isReplyTo:t=>i=>!!i.context&&i.context.message_id===t,isForwarded:t=>!!t.context&&!!t.context.forwarded,isFrequentlyForwarded:t=>!!t.context&&!!t.context.frequently_forwarded,and:(...t)=>i=>{for(let o of t)if(!o(i))return!1;return!0},or:(...t)=>i=>{for(let o of t)if(o(i))return!0;return!1},not:t=>i=>!t(i),from:t=>i=>i.from===t,all:()=>()=>!0};0&&(module.exports={filters});
|
|
2
|
-
//# sourceMappingURL=filters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/filters.ts"],"sourcesContent":["import { MessageTypesEnum } from 'src/types';\nimport { WebhookMessage } from '../types/webhook';\n\n/**\n * Filters for message handling, inspired by PyWa\n */\nexport const filters = {\n /**\n * Filters messages by type\n * @param type Message type to filter for\n * @returns A filter function\n */\n type: (type: MessageTypesEnum | string): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage) => message.type === type;\n },\n\n /**\n * Filters text messages\n * @param message Message to check\n * @returns True if the message is a text message\n */\n text: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Text;\n },\n\n /**\n * Filters image messages\n * @param message Message to check\n * @returns True if the message is an image message\n */\n image: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Image;\n },\n\n /**\n * Filters audio messages\n * @param message Message to check\n * @returns True if the message is an audio message\n */\n audio: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Audio;\n },\n\n /**\n * Filters video messages\n * @param message Message to check\n * @returns True if the message is a video message\n */\n video: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Video;\n },\n\n /**\n * Filters document messages\n * @param message Message to check\n * @returns True if the message is a document message\n */\n document: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Document;\n },\n\n /**\n * Filters sticker messages\n * @param message Message to check\n * @returns True if the message is a sticker message\n */\n sticker: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Sticker;\n },\n\n /**\n * Filters location messages\n * @param message Message to check\n * @returns True if the message is a location message\n */\n location: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Location;\n },\n\n /**\n * Filters contact messages\n * @param message Message to check\n * @returns True if the message is a contacts message\n */\n contacts: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Contacts;\n },\n\n /**\n * Filters button messages\n * @param message Message to check\n * @returns True if the message is a button message\n */\n button: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Button;\n },\n\n /**\n * Filters interactive messages\n * @param message Message to check\n * @returns True if the message is an interactive message\n */\n interactive: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Interactive;\n },\n\n /**\n * Filters system messages\n * @param message Message to check\n * @returns True if the message is a system message\n */\n system: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.System;\n },\n\n /**\n * Filters order messages\n * @param message Message to check\n * @returns True if the message is an order message\n */\n order: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Order;\n },\n\n /**\n * Matches text content against a pattern\n * @param patterns String or regular expression or array of patterns to match against\n * @returns A filter function\n */\n matches: (patterns: string | RegExp | (string | RegExp)[]): ((message: WebhookMessage) => boolean) => {\n const patternsArray = Array.isArray(patterns) ? patterns : [patterns];\n\n return (message: WebhookMessage): boolean => {\n if (message.type !== MessageTypesEnum.Text || !message.text) {\n return false;\n }\n\n const text = message.text.body;\n\n for (const pattern of patternsArray) {\n if (typeof pattern === 'string') {\n if (text.includes(pattern)) {\n return true;\n }\n } else if (pattern instanceof RegExp) {\n if (pattern.test(text)) {\n return true;\n }\n }\n }\n\n return false;\n };\n },\n\n /**\n * Checks if a message is a reply to another message\n * @returns A filter function that returns true if the message is a reply\n */\n isReply: (message: WebhookMessage): boolean => {\n return !!message.context && !!message.context.message_id;\n },\n\n /**\n * Checks if a message is a reply to a specific message\n * @param messageId The ID of the original message to check for\n * @returns A filter function that returns true if the message is a reply to the specified message\n */\n isReplyTo: (messageId: string): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n return !!message.context && message.context.message_id === messageId;\n };\n },\n\n /**\n * Checks if a message is forwarded\n * @returns A filter function that returns true if the message is forwarded\n */\n isForwarded: (message: WebhookMessage): boolean => {\n return !!message.context && !!message.context.forwarded;\n },\n\n /**\n * Checks if a message is frequently forwarded\n * @returns A filter function that returns true if the message is frequently forwarded\n */\n isFrequentlyForwarded: (message: WebhookMessage): boolean => {\n return !!message.context && !!message.context.frequently_forwarded;\n },\n\n /**\n * Combines multiple filters with AND logic\n * @param filterFunctions Array of filter functions to combine\n * @returns A filter function that returns true only if all filters return true\n */\n and: (...filterFunctions: ((message: WebhookMessage) => boolean)[]): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n for (const filter of filterFunctions) {\n if (!filter(message)) {\n return false;\n }\n }\n return true;\n };\n },\n\n /**\n * Combines multiple filters with OR logic\n * @param filterFunctions Array of filter functions to combine\n * @returns A filter function that returns true if any filter returns true\n */\n or: (...filterFunctions: ((message: WebhookMessage) => boolean)[]): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n for (const filter of filterFunctions) {\n if (filter(message)) {\n return true;\n }\n }\n return false;\n };\n },\n\n /**\n * Negates a filter\n * @param filterFunction Filter function to negate\n * @returns A filter function that returns the opposite of the input filter\n */\n not: (filterFunction: (message: WebhookMessage) => boolean): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n return !filterFunction(message);\n };\n },\n\n /**\n * Filters messages from a specific sender\n * @param from Sender phone number to filter for\n * @returns A filter function\n */\n from: (from: string): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n return message.from === from;\n };\n },\n\n /**\n * Filter function that accepts all messages\n * @returns Always returns true\n */\n all: (): ((message: WebhookMessage) => boolean) => {\n return (): boolean => true;\n },\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAMO,IAAMI,EAAU,CAMnB,KAAOC,GACKC,GAA4BA,EAAQ,OAASD,EAQzD,KAAOC,GACIA,EAAQ,OAAS,OAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,SAAWA,GACAA,EAAQ,OAAS,WAQ5B,QAAUA,GACCA,EAAQ,OAAS,UAQ5B,SAAWA,GACAA,EAAQ,OAAS,WAQ5B,SAAWA,GACAA,EAAQ,OAAS,WAQ5B,OAASA,GACEA,EAAQ,OAAS,SAQ5B,YAAcA,GACHA,EAAQ,OAAS,cAQ5B,OAASA,GACEA,EAAQ,OAAS,SAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,QAAUC,GAA4F,CAClG,IAAMC,EAAgB,MAAM,QAAQD,CAAQ,EAAIA,EAAW,CAACA,CAAQ,EAEpE,OAAQD,GAAqC,CACzC,GAAIA,EAAQ,OAAS,QAAyB,CAACA,EAAQ,KACnD,MAAO,GAGX,IAAMG,EAAOH,EAAQ,KAAK,KAE1B,QAAWI,KAAWF,EAClB,GAAI,OAAOE,GAAY,UACnB,GAAID,EAAK,SAASC,CAAO,EACrB,MAAO,WAEJA,aAAmB,QACtBA,EAAQ,KAAKD,CAAI,EACjB,MAAO,GAKnB,MAAO,EACX,CACJ,EAMA,QAAUH,GACC,CAAC,CAACA,EAAQ,SAAW,CAAC,CAACA,EAAQ,QAAQ,WAQlD,UAAYK,GACAL,GACG,CAAC,CAACA,EAAQ,SAAWA,EAAQ,QAAQ,aAAeK,EAQnE,YAAcL,GACH,CAAC,CAACA,EAAQ,SAAW,CAAC,CAACA,EAAQ,QAAQ,UAOlD,sBAAwBA,GACb,CAAC,CAACA,EAAQ,SAAW,CAAC,CAACA,EAAQ,QAAQ,qBAQlD,IAAK,IAAIM,IACGN,GAAqC,CACzC,QAAWO,KAAUD,EACjB,GAAI,CAACC,EAAOP,CAAO,EACf,MAAO,GAGf,MAAO,EACX,EAQJ,GAAI,IAAIM,IACIN,GAAqC,CACzC,QAAWO,KAAUD,EACjB,GAAIC,EAAOP,CAAO,EACd,MAAO,GAGf,MAAO,EACX,EAQJ,IAAMQ,GACMR,GACG,CAACQ,EAAeR,CAAO,EAStC,KAAOS,GACKT,GACGA,EAAQ,OAASS,EAQhC,IAAK,IACM,IAAe,EAE9B","names":["filters_exports","__export","filters","__toCommonJS","filters","type","message","patterns","patternsArray","text","pattern","messageId","filterFunctions","filter","filterFunction","from"]}
|
package/dist/utils/filters.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var H={type:t=>i=>i.type===t,text:t=>t.type==="text",image:t=>t.type==="image",audio:t=>t.type==="audio",video:t=>t.type==="video",document:t=>t.type==="document",sticker:t=>t.type==="sticker",location:t=>t.type==="location",contacts:t=>t.type==="contacts",button:t=>t.type==="button",interactive:t=>t.type==="interactive",system:t=>t.type==="system",order:t=>t.type==="order",matches:t=>{let i=Array.isArray(t)?t:[t];return o=>{if(o.type!=="text"||!o.text)return!1;let a=o.text.body;for(let e of i)if(typeof e=="string"){if(a.includes(e))return!0}else if(e instanceof RegExp&&e.test(a))return!0;return!1}},isReply:t=>!!t.context&&!!t.context.message_id,isReplyTo:t=>i=>!!i.context&&i.context.message_id===t,isForwarded:t=>!!t.context&&!!t.context.forwarded,isFrequentlyForwarded:t=>!!t.context&&!!t.context.frequently_forwarded,and:(...t)=>i=>{for(let o of t)if(!o(i))return!1;return!0},or:(...t)=>i=>{for(let o of t)if(o(i))return!0;return!1},not:t=>i=>!t(i),from:t=>i=>i.from===t,all:()=>()=>!0};export{H as filters};
|
|
2
|
-
//# sourceMappingURL=filters.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/filters.ts"],"sourcesContent":["import { MessageTypesEnum } from 'src/types';\nimport { WebhookMessage } from '../types/webhook';\n\n/**\n * Filters for message handling, inspired by PyWa\n */\nexport const filters = {\n /**\n * Filters messages by type\n * @param type Message type to filter for\n * @returns A filter function\n */\n type: (type: MessageTypesEnum | string): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage) => message.type === type;\n },\n\n /**\n * Filters text messages\n * @param message Message to check\n * @returns True if the message is a text message\n */\n text: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Text;\n },\n\n /**\n * Filters image messages\n * @param message Message to check\n * @returns True if the message is an image message\n */\n image: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Image;\n },\n\n /**\n * Filters audio messages\n * @param message Message to check\n * @returns True if the message is an audio message\n */\n audio: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Audio;\n },\n\n /**\n * Filters video messages\n * @param message Message to check\n * @returns True if the message is a video message\n */\n video: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Video;\n },\n\n /**\n * Filters document messages\n * @param message Message to check\n * @returns True if the message is a document message\n */\n document: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Document;\n },\n\n /**\n * Filters sticker messages\n * @param message Message to check\n * @returns True if the message is a sticker message\n */\n sticker: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Sticker;\n },\n\n /**\n * Filters location messages\n * @param message Message to check\n * @returns True if the message is a location message\n */\n location: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Location;\n },\n\n /**\n * Filters contact messages\n * @param message Message to check\n * @returns True if the message is a contacts message\n */\n contacts: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Contacts;\n },\n\n /**\n * Filters button messages\n * @param message Message to check\n * @returns True if the message is a button message\n */\n button: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Button;\n },\n\n /**\n * Filters interactive messages\n * @param message Message to check\n * @returns True if the message is an interactive message\n */\n interactive: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Interactive;\n },\n\n /**\n * Filters system messages\n * @param message Message to check\n * @returns True if the message is a system message\n */\n system: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.System;\n },\n\n /**\n * Filters order messages\n * @param message Message to check\n * @returns True if the message is an order message\n */\n order: (message: WebhookMessage): boolean => {\n return message.type === MessageTypesEnum.Order;\n },\n\n /**\n * Matches text content against a pattern\n * @param patterns String or regular expression or array of patterns to match against\n * @returns A filter function\n */\n matches: (patterns: string | RegExp | (string | RegExp)[]): ((message: WebhookMessage) => boolean) => {\n const patternsArray = Array.isArray(patterns) ? patterns : [patterns];\n\n return (message: WebhookMessage): boolean => {\n if (message.type !== MessageTypesEnum.Text || !message.text) {\n return false;\n }\n\n const text = message.text.body;\n\n for (const pattern of patternsArray) {\n if (typeof pattern === 'string') {\n if (text.includes(pattern)) {\n return true;\n }\n } else if (pattern instanceof RegExp) {\n if (pattern.test(text)) {\n return true;\n }\n }\n }\n\n return false;\n };\n },\n\n /**\n * Checks if a message is a reply to another message\n * @returns A filter function that returns true if the message is a reply\n */\n isReply: (message: WebhookMessage): boolean => {\n return !!message.context && !!message.context.message_id;\n },\n\n /**\n * Checks if a message is a reply to a specific message\n * @param messageId The ID of the original message to check for\n * @returns A filter function that returns true if the message is a reply to the specified message\n */\n isReplyTo: (messageId: string): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n return !!message.context && message.context.message_id === messageId;\n };\n },\n\n /**\n * Checks if a message is forwarded\n * @returns A filter function that returns true if the message is forwarded\n */\n isForwarded: (message: WebhookMessage): boolean => {\n return !!message.context && !!message.context.forwarded;\n },\n\n /**\n * Checks if a message is frequently forwarded\n * @returns A filter function that returns true if the message is frequently forwarded\n */\n isFrequentlyForwarded: (message: WebhookMessage): boolean => {\n return !!message.context && !!message.context.frequently_forwarded;\n },\n\n /**\n * Combines multiple filters with AND logic\n * @param filterFunctions Array of filter functions to combine\n * @returns A filter function that returns true only if all filters return true\n */\n and: (...filterFunctions: ((message: WebhookMessage) => boolean)[]): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n for (const filter of filterFunctions) {\n if (!filter(message)) {\n return false;\n }\n }\n return true;\n };\n },\n\n /**\n * Combines multiple filters with OR logic\n * @param filterFunctions Array of filter functions to combine\n * @returns A filter function that returns true if any filter returns true\n */\n or: (...filterFunctions: ((message: WebhookMessage) => boolean)[]): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n for (const filter of filterFunctions) {\n if (filter(message)) {\n return true;\n }\n }\n return false;\n };\n },\n\n /**\n * Negates a filter\n * @param filterFunction Filter function to negate\n * @returns A filter function that returns the opposite of the input filter\n */\n not: (filterFunction: (message: WebhookMessage) => boolean): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n return !filterFunction(message);\n };\n },\n\n /**\n * Filters messages from a specific sender\n * @param from Sender phone number to filter for\n * @returns A filter function\n */\n from: (from: string): ((message: WebhookMessage) => boolean) => {\n return (message: WebhookMessage): boolean => {\n return message.from === from;\n };\n },\n\n /**\n * Filter function that accepts all messages\n * @returns Always returns true\n */\n all: (): ((message: WebhookMessage) => boolean) => {\n return (): boolean => true;\n },\n};\n"],"mappings":"AAMO,IAAMA,EAAU,CAMnB,KAAOC,GACKC,GAA4BA,EAAQ,OAASD,EAQzD,KAAOC,GACIA,EAAQ,OAAS,OAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,SAAWA,GACAA,EAAQ,OAAS,WAQ5B,QAAUA,GACCA,EAAQ,OAAS,UAQ5B,SAAWA,GACAA,EAAQ,OAAS,WAQ5B,SAAWA,GACAA,EAAQ,OAAS,WAQ5B,OAASA,GACEA,EAAQ,OAAS,SAQ5B,YAAcA,GACHA,EAAQ,OAAS,cAQ5B,OAASA,GACEA,EAAQ,OAAS,SAQ5B,MAAQA,GACGA,EAAQ,OAAS,QAQ5B,QAAUC,GAA4F,CAClG,IAAMC,EAAgB,MAAM,QAAQD,CAAQ,EAAIA,EAAW,CAACA,CAAQ,EAEpE,OAAQD,GAAqC,CACzC,GAAIA,EAAQ,OAAS,QAAyB,CAACA,EAAQ,KACnD,MAAO,GAGX,IAAMG,EAAOH,EAAQ,KAAK,KAE1B,QAAWI,KAAWF,EAClB,GAAI,OAAOE,GAAY,UACnB,GAAID,EAAK,SAASC,CAAO,EACrB,MAAO,WAEJA,aAAmB,QACtBA,EAAQ,KAAKD,CAAI,EACjB,MAAO,GAKnB,MAAO,EACX,CACJ,EAMA,QAAUH,GACC,CAAC,CAACA,EAAQ,SAAW,CAAC,CAACA,EAAQ,QAAQ,WAQlD,UAAYK,GACAL,GACG,CAAC,CAACA,EAAQ,SAAWA,EAAQ,QAAQ,aAAeK,EAQnE,YAAcL,GACH,CAAC,CAACA,EAAQ,SAAW,CAAC,CAACA,EAAQ,QAAQ,UAOlD,sBAAwBA,GACb,CAAC,CAACA,EAAQ,SAAW,CAAC,CAACA,EAAQ,QAAQ,qBAQlD,IAAK,IAAIM,IACGN,GAAqC,CACzC,QAAWO,KAAUD,EACjB,GAAI,CAACC,EAAOP,CAAO,EACf,MAAO,GAGf,MAAO,EACX,EAQJ,GAAI,IAAIM,IACIN,GAAqC,CACzC,QAAWO,KAAUD,EACjB,GAAIC,EAAOP,CAAO,EACd,MAAO,GAGf,MAAO,EACX,EAQJ,IAAMQ,GACMR,GACG,CAACQ,EAAeR,CAAO,EAStC,KAAOS,GACKT,GACGA,EAAQ,OAASS,EAQhC,IAAK,IACM,IAAe,EAE9B","names":["filters","type","message","patterns","patternsArray","text","pattern","messageId","filterFunctions","filter","filterFunction","from"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { FlowEndpointRequest, FlowDataExchangeRequest, FlowActionEnum, FlowErrorNotificationRequest, FlowHealthCheckRequest } from '../types/flow.mjs';
|
|
2
|
-
import 'http';
|
|
3
|
-
import '../types/request.mjs';
|
|
4
|
-
import '../enums-CI7vzKhn.mjs';
|
|
5
|
-
|
|
6
|
-
declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
|
|
7
|
-
declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
|
|
8
|
-
/**
|
|
9
|
-
* Type guard to check if a request is a Data Exchange request
|
|
10
|
-
* Validates the request structure according to the Flow API specifications
|
|
11
|
-
*
|
|
12
|
-
* @param request The Flow endpoint request to check
|
|
13
|
-
* @returns True if the request is a valid Data Exchange request, false otherwise
|
|
14
|
-
*/
|
|
15
|
-
declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {
|
|
16
|
-
action: (typeof DATA_EXCHANGE_ACTIONS)[number];
|
|
17
|
-
screen?: string;
|
|
18
|
-
flow_token: string;
|
|
19
|
-
data?: Record<string, any>;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Type guard to check if a request is an Error Notification request
|
|
23
|
-
* Validates the request structure according to the Flow API error specifications
|
|
24
|
-
*
|
|
25
|
-
* @param request The Flow endpoint request to check
|
|
26
|
-
* @returns True if the request is a valid Error Notification request, false otherwise
|
|
27
|
-
*/
|
|
28
|
-
declare function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {
|
|
29
|
-
action: (typeof ERROR_ACTIONS)[number];
|
|
30
|
-
screen: string;
|
|
31
|
-
flow_token: string;
|
|
32
|
-
data: {
|
|
33
|
-
error: string;
|
|
34
|
-
error_message: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Type guard to check if a request is a Ping (health check) request
|
|
39
|
-
* Simple validation for health check endpoints in the Flow API
|
|
40
|
-
*
|
|
41
|
-
* @param request The Flow endpoint request to check
|
|
42
|
-
* @returns True if the request is a Ping request, false otherwise
|
|
43
|
-
*/
|
|
44
|
-
declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
|
|
45
|
-
|
|
46
|
-
export { isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { FlowEndpointRequest, FlowDataExchangeRequest, FlowActionEnum, FlowErrorNotificationRequest, FlowHealthCheckRequest } from '../types/flow.js';
|
|
2
|
-
import 'http';
|
|
3
|
-
import '../types/request.js';
|
|
4
|
-
import '../enums-CI7vzKhn.js';
|
|
5
|
-
|
|
6
|
-
declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
|
|
7
|
-
declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
|
|
8
|
-
/**
|
|
9
|
-
* Type guard to check if a request is a Data Exchange request
|
|
10
|
-
* Validates the request structure according to the Flow API specifications
|
|
11
|
-
*
|
|
12
|
-
* @param request The Flow endpoint request to check
|
|
13
|
-
* @returns True if the request is a valid Data Exchange request, false otherwise
|
|
14
|
-
*/
|
|
15
|
-
declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {
|
|
16
|
-
action: (typeof DATA_EXCHANGE_ACTIONS)[number];
|
|
17
|
-
screen?: string;
|
|
18
|
-
flow_token: string;
|
|
19
|
-
data?: Record<string, any>;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Type guard to check if a request is an Error Notification request
|
|
23
|
-
* Validates the request structure according to the Flow API error specifications
|
|
24
|
-
*
|
|
25
|
-
* @param request The Flow endpoint request to check
|
|
26
|
-
* @returns True if the request is a valid Error Notification request, false otherwise
|
|
27
|
-
*/
|
|
28
|
-
declare function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {
|
|
29
|
-
action: (typeof ERROR_ACTIONS)[number];
|
|
30
|
-
screen: string;
|
|
31
|
-
flow_token: string;
|
|
32
|
-
data: {
|
|
33
|
-
error: string;
|
|
34
|
-
error_message: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Type guard to check if a request is a Ping (health check) request
|
|
39
|
-
* Simple validation for health check endpoints in the Flow API
|
|
40
|
-
*
|
|
41
|
-
* @param request The Flow endpoint request to check
|
|
42
|
-
* @returns True if the request is a Ping request, false otherwise
|
|
43
|
-
*/
|
|
44
|
-
declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
|
|
45
|
-
|
|
46
|
-
export { isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var e=Object.prototype.hasOwnProperty;var f=(t,i)=>{for(var l in i)_(t,l,{get:i[l],enumerable:!0})},I=(t,i,l,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of N(i))!e.call(t,o)&&o!==l&&_(t,o,{get:()=>i[o],enumerable:!(a=r(i,o))||a.enumerable});return t};var U=t=>I(_({},"__esModule",{value:!0}),t);var G={};f(G,{isFlowDataExchangeRequest:()=>O,isFlowErrorRequest:()=>w,isFlowPingRequest:()=>B});module.exports=U(G);function P(t){return typeof t=="object"&&t!==null}function p(t){return typeof t=="string"}var F=["data_exchange","INIT","BACK"],x=["data_exchange","INIT"];function O(t){if(!("flow_token"in t&&p(t.flow_token)&&"action"in t))return!1;let{action:i,version:l,screen:a,data:o}=t,A=l==="3.0",R=F.includes(i),S=typeof a>"u"||p(a)&&a!=="SUCCESS",D=i==="data_exchange"||P(o);return A&&R&&S&&D}function w(t){if(!("flow_token"in t&&p(t.flow_token)&&"action"in t))return!1;let{action:i,screen:l,data:a}=t,o=x.includes(i),A=p(l),R=P(a)&&"error_key"in a&&p(a.error)&&"error_message"in a&&p(a.error_message);return o&&A&&R}function B(t){return"action"in t&&t.action==="ping"}0&&(module.exports={isFlowDataExchangeRequest,isFlowErrorRequest,isFlowPingRequest});
|
|
2
|
-
//# sourceMappingURL=flowTypeGuards.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/flowTypeGuards.ts"],"sourcesContent":["import {\n FlowActionEnum,\n FlowDataExchangeRequest,\n FlowEndpointRequest,\n FlowErrorNotificationRequest,\n FlowHealthCheckRequest,\n} from 'src/types';\n\n/**\n * Helper function to check if a value is an object\n * @param value The value to check\n * @returns True if the value is a non-null object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Helper function to check if a value is a string\n * @param value The value to check\n * @returns True if the value is a string\n */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n// Array of allowed action types for data exchange requests\nconst DATA_EXCHANGE_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK] as const;\n\n// Array of allowed action types for error notification requests\nconst ERROR_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT] as const;\n\n/**\n * Type guard to check if a request is a Data Exchange request\n * Validates the request structure according to the Flow API specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Data Exchange request, false otherwise\n */\nexport function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {\n action: (typeof DATA_EXCHANGE_ACTIONS)[number];\n screen?: string;\n flow_token: string;\n data?: Record<string, any>;\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, version, screen, data } = request;\n\n // Validate API version\n const hasValidVersion = version === '3.0';\n\n // Check if the action is one of the allowed actions for data exchange\n const hasValidAction = DATA_EXCHANGE_ACTIONS.includes(action as any);\n\n // Screen is optional, but when present must be a string and not 'SUCCESS'\n const hasValidScreen = typeof screen === 'undefined' || (isString(screen) && screen !== 'SUCCESS');\n\n // Data is required except for DATA_EXCHANGE action\n const hasValidData = action === FlowActionEnum.DATA_EXCHANGE || isObject(data);\n\n // All conditions must be met for a valid data exchange request\n return hasValidVersion && hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is an Error Notification request\n * Validates the request structure according to the Flow API error specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Error Notification request, false otherwise\n */\nexport function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {\n action: (typeof ERROR_ACTIONS)[number];\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, screen, data } = request;\n\n // Check if the action is one of the allowed actions for error notifications\n const hasValidAction = ERROR_ACTIONS.includes(action as any);\n\n // Screen is required for error notifications\n const hasValidScreen = isString(screen);\n\n // Validate error data structure\n const hasValidData =\n isObject(data) &&\n 'error_key' in data &&\n isString(data.error) &&\n 'error_message' in data &&\n isString(data.error_message);\n\n // All conditions must be met for a valid error notification request\n return hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is a Ping (health check) request\n * Simple validation for health check endpoints in the Flow API\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a Ping request, false otherwise\n */\nexport function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest {\n // A ping request only requires the 'action' field with value 'ping'\n return 'action' in request && request.action === 'ping';\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,uBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GAaA,SAASM,EAASC,EAAkD,CAChE,OAAO,OAAOA,GAAU,UAAYA,IAAU,IAClD,CAOA,SAASC,EAASD,EAAiC,CAC/C,OAAO,OAAOA,GAAU,QAC5B,CAGA,IAAME,EAAwB,8BAAuE,EAG/FC,EAAgB,uBAAkD,EASjE,SAASC,EAA0BC,EAKxC,CAEE,GAAI,EAAE,eAAgBA,GAAWJ,EAASI,EAAQ,UAAU,GAAK,WAAYA,GACzE,MAAO,GAGX,GAAM,CAAE,OAAAC,EAAQ,QAAAC,EAAS,OAAAC,EAAQ,KAAAC,CAAK,EAAIJ,EAGpCK,EAAkBH,IAAY,MAG9BI,EAAiBT,EAAsB,SAASI,CAAa,EAG7DM,EAAiB,OAAOJ,EAAW,KAAgBP,EAASO,CAAM,GAAKA,IAAW,UAGlFK,EAAeP,IAAW,iBAAgCP,EAASU,CAAI,EAG7E,OAAOC,GAAmBC,GAAkBC,GAAkBC,CAClE,CASO,SAASC,EAAmBT,EAQjC,CAEE,GAAI,EAAE,eAAgBA,GAAWJ,EAASI,EAAQ,UAAU,GAAK,WAAYA,GACzE,MAAO,GAGX,GAAM,CAAE,OAAAC,EAAQ,OAAAE,EAAQ,KAAAC,CAAK,EAAIJ,EAG3BM,EAAiBR,EAAc,SAASG,CAAa,EAGrDM,EAAiBX,EAASO,CAAM,EAGhCK,EACFd,EAASU,CAAI,GACb,cAAeA,GACfR,EAASQ,EAAK,KAAK,GACnB,kBAAmBA,GACnBR,EAASQ,EAAK,aAAa,EAG/B,OAAOE,GAAkBC,GAAkBC,CAC/C,CASO,SAASE,EAAkBV,EAAiE,CAE/F,MAAO,WAAYA,GAAWA,EAAQ,SAAW,MACrD","names":["flowTypeGuards_exports","__export","isFlowDataExchangeRequest","isFlowErrorRequest","isFlowPingRequest","__toCommonJS","isObject","value","isString","DATA_EXCHANGE_ACTIONS","ERROR_ACTIONS","isFlowDataExchangeRequest","request","action","version","screen","data","hasValidVersion","hasValidAction","hasValidScreen","hasValidData","isFlowErrorRequest","isFlowPingRequest"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function _(t){return typeof t=="object"&&t!==null}function a(t){return typeof t=="string"}var D=["data_exchange","INIT","BACK"],r=["data_exchange","INIT"];function Q(t){if(!("flow_token"in t&&a(t.flow_token)&&"action"in t))return!1;let{action:o,version:l,screen:i,data:p}=t,A=l==="3.0",R=D.includes(o),P=typeof i>"u"||a(i)&&i!=="SUCCESS",S=o==="data_exchange"||_(p);return A&&R&&P&&S}function $(t){if(!("flow_token"in t&&a(t.flow_token)&&"action"in t))return!1;let{action:o,screen:l,data:i}=t,p=r.includes(o),A=a(l),R=_(i)&&"error_key"in i&&a(i.error)&&"error_message"in i&&a(i.error_message);return p&&A&&R}function z(t){return"action"in t&&t.action==="ping"}export{Q as isFlowDataExchangeRequest,$ as isFlowErrorRequest,z as isFlowPingRequest};
|
|
2
|
-
//# sourceMappingURL=flowTypeGuards.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/flowTypeGuards.ts"],"sourcesContent":["import {\n FlowActionEnum,\n FlowDataExchangeRequest,\n FlowEndpointRequest,\n FlowErrorNotificationRequest,\n FlowHealthCheckRequest,\n} from 'src/types';\n\n/**\n * Helper function to check if a value is an object\n * @param value The value to check\n * @returns True if the value is a non-null object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Helper function to check if a value is a string\n * @param value The value to check\n * @returns True if the value is a string\n */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n// Array of allowed action types for data exchange requests\nconst DATA_EXCHANGE_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK] as const;\n\n// Array of allowed action types for error notification requests\nconst ERROR_ACTIONS = [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT] as const;\n\n/**\n * Type guard to check if a request is a Data Exchange request\n * Validates the request structure according to the Flow API specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Data Exchange request, false otherwise\n */\nexport function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {\n action: (typeof DATA_EXCHANGE_ACTIONS)[number];\n screen?: string;\n flow_token: string;\n data?: Record<string, any>;\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, version, screen, data } = request;\n\n // Validate API version\n const hasValidVersion = version === '3.0';\n\n // Check if the action is one of the allowed actions for data exchange\n const hasValidAction = DATA_EXCHANGE_ACTIONS.includes(action as any);\n\n // Screen is optional, but when present must be a string and not 'SUCCESS'\n const hasValidScreen = typeof screen === 'undefined' || (isString(screen) && screen !== 'SUCCESS');\n\n // Data is required except for DATA_EXCHANGE action\n const hasValidData = action === FlowActionEnum.DATA_EXCHANGE || isObject(data);\n\n // All conditions must be met for a valid data exchange request\n return hasValidVersion && hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is an Error Notification request\n * Validates the request structure according to the Flow API error specifications\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a valid Error Notification request, false otherwise\n */\nexport function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {\n action: (typeof ERROR_ACTIONS)[number];\n screen: string;\n flow_token: string;\n data: {\n error: string;\n error_message: string;\n };\n} {\n // Check for basic required fields\n if (!('flow_token' in request && isString(request.flow_token) && 'action' in request)) {\n return false;\n }\n\n const { action, screen, data } = request;\n\n // Check if the action is one of the allowed actions for error notifications\n const hasValidAction = ERROR_ACTIONS.includes(action as any);\n\n // Screen is required for error notifications\n const hasValidScreen = isString(screen);\n\n // Validate error data structure\n const hasValidData =\n isObject(data) &&\n 'error_key' in data &&\n isString(data.error) &&\n 'error_message' in data &&\n isString(data.error_message);\n\n // All conditions must be met for a valid error notification request\n return hasValidAction && hasValidScreen && hasValidData;\n}\n\n/**\n * Type guard to check if a request is a Ping (health check) request\n * Simple validation for health check endpoints in the Flow API\n *\n * @param request The Flow endpoint request to check\n * @returns True if the request is a Ping request, false otherwise\n */\nexport function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest {\n // A ping request only requires the 'action' field with value 'ping'\n return 'action' in request && request.action === 'ping';\n}\n"],"mappings":"AAaA,SAASA,EAASC,EAAkD,CAChE,OAAO,OAAOA,GAAU,UAAYA,IAAU,IAClD,CAOA,SAASC,EAASD,EAAiC,CAC/C,OAAO,OAAOA,GAAU,QAC5B,CAGA,IAAME,EAAwB,8BAAuE,EAG/FC,EAAgB,uBAAkD,EASjE,SAASC,EAA0BC,EAKxC,CAEE,GAAI,EAAE,eAAgBA,GAAWJ,EAASI,EAAQ,UAAU,GAAK,WAAYA,GACzE,MAAO,GAGX,GAAM,CAAE,OAAAC,EAAQ,QAAAC,EAAS,OAAAC,EAAQ,KAAAC,CAAK,EAAIJ,EAGpCK,EAAkBH,IAAY,MAG9BI,EAAiBT,EAAsB,SAASI,CAAa,EAG7DM,EAAiB,OAAOJ,EAAW,KAAgBP,EAASO,CAAM,GAAKA,IAAW,UAGlFK,EAAeP,IAAW,iBAAgCP,EAASU,CAAI,EAG7E,OAAOC,GAAmBC,GAAkBC,GAAkBC,CAClE,CASO,SAASC,EAAmBT,EAQjC,CAEE,GAAI,EAAE,eAAgBA,GAAWJ,EAASI,EAAQ,UAAU,GAAK,WAAYA,GACzE,MAAO,GAGX,GAAM,CAAE,OAAAC,EAAQ,OAAAE,EAAQ,KAAAC,CAAK,EAAIJ,EAG3BM,EAAiBR,EAAc,SAASG,CAAa,EAGrDM,EAAiBX,EAASO,CAAM,EAGhCK,EACFd,EAASU,CAAI,GACb,cAAeA,GACfR,EAASQ,EAAK,KAAK,GACnB,kBAAmBA,GACnBR,EAASQ,EAAK,aAAa,EAG/B,OAAOE,GAAkBC,GAAkBC,CAC/C,CASO,SAASE,EAAkBV,EAAiE,CAE/F,MAAO,WAAYA,GAAWA,EAAQ,SAAW,MACrD","names":["isObject","value","isString","DATA_EXCHANGE_ACTIONS","ERROR_ACTIONS","isFlowDataExchangeRequest","request","action","version","screen","data","hasValidVersion","hasValidAction","hasValidScreen","hasValidData","isFlowErrorRequest","isFlowPingRequest"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var i=Object.create;var o=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var d=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})},c=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of p(r))!m.call(t,a)&&a!==e&&o(t,a,{get:()=>r[a],enumerable:!(s=n(r,a))||s.enumerable});return t};var f=(t,r,e)=>(e=t!=null?i(u(t)):{},c(r||!t||!t.__esModule?o(e,"default",{value:t,enumerable:!0}):e,t)),h=t=>c(o({},"__esModule",{value:!0}),t);var y={};d(y,{generateXHub256Sig:()=>x});module.exports=h(y);var g=f(require("crypto")),x=(t,r)=>g.createHmac("sha256",r).update(t,"utf-8").digest("hex");0&&(module.exports={generateXHub256Sig});
|
|
2
|
-
//# sourceMappingURL=generateXHub256Sig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/generateXHub256Sig.ts"],"sourcesContent":["import * as crypto from 'crypto';\n\nexport const generateXHub256Sig = (body: string, appSecret: string) => {\n return crypto.createHmac('sha256', appSecret).update(body, 'utf-8').digest('hex');\n};\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwB,qBAEXF,EAAqB,CAACG,EAAcC,IAC/B,aAAW,SAAUA,CAAS,EAAE,OAAOD,EAAM,OAAO,EAAE,OAAO,KAAK","names":["generateXHub256Sig_exports","__export","generateXHub256Sig","__toCommonJS","crypto","body","appSecret"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/generateXHub256Sig.ts"],"sourcesContent":["import * as crypto from 'crypto';\n\nexport const generateXHub256Sig = (body: string, appSecret: string) => {\n return crypto.createHmac('sha256', appSecret).update(body, 'utf-8').digest('hex');\n};\n"],"mappings":"AAAA,UAAYA,MAAY,SAEjB,IAAMC,EAAqB,CAACC,EAAcC,IAC/B,aAAW,SAAUA,CAAS,EAAE,OAAOD,EAAM,OAAO,EAAE,OAAO,KAAK","names":["crypto","generateXHub256Sig","body","appSecret"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { WhatsAppConfig } from '../types/whatsapp.mjs';
|
|
2
|
-
import { WabaConfigType } from '../types/config.mjs';
|
|
3
|
-
import '../types/businessProfile.mjs';
|
|
4
|
-
import '../enums-CI7vzKhn.mjs';
|
|
5
|
-
import '../types/request.mjs';
|
|
6
|
-
import '../types/encryption.mjs';
|
|
7
|
-
import '../types/flow.mjs';
|
|
8
|
-
import 'http';
|
|
9
|
-
import '../types/media.mjs';
|
|
10
|
-
import '../types/messages.mjs';
|
|
11
|
-
import '../types/base.mjs';
|
|
12
|
-
import '../types/phoneNumber.mjs';
|
|
13
|
-
import '../types/qrCode.mjs';
|
|
14
|
-
import '../types/registration.mjs';
|
|
15
|
-
import '../types/template.mjs';
|
|
16
|
-
import '../types/twoStepVerification.mjs';
|
|
17
|
-
import '../types/waba.mjs';
|
|
18
|
-
|
|
19
|
-
declare const importConfig: (inputConfig?: WhatsAppConfig) => WabaConfigType;
|
|
20
|
-
|
|
21
|
-
export { importConfig };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { WhatsAppConfig } from '../types/whatsapp.js';
|
|
2
|
-
import { WabaConfigType } from '../types/config.js';
|
|
3
|
-
import '../types/businessProfile.js';
|
|
4
|
-
import '../enums-CI7vzKhn.js';
|
|
5
|
-
import '../types/request.js';
|
|
6
|
-
import '../types/encryption.js';
|
|
7
|
-
import '../types/flow.js';
|
|
8
|
-
import 'http';
|
|
9
|
-
import '../types/media.js';
|
|
10
|
-
import '../types/messages.js';
|
|
11
|
-
import '../types/base.js';
|
|
12
|
-
import '../types/phoneNumber.js';
|
|
13
|
-
import '../types/qrCode.js';
|
|
14
|
-
import '../types/registration.js';
|
|
15
|
-
import '../types/template.js';
|
|
16
|
-
import '../types/twoStepVerification.js';
|
|
17
|
-
import '../types/waba.js';
|
|
18
|
-
|
|
19
|
-
declare const importConfig: (inputConfig?: WhatsAppConfig) => WabaConfigType;
|
|
20
|
-
|
|
21
|
-
export { importConfig };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var N=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var G=(A,R)=>{for(var S in R)N(A,S,{get:R[S],enumerable:!0})},T=(A,R,S,I)=>{if(R&&typeof R=="object"||typeof R=="function")for(let P of t(R))!_.call(A,P)&&P!==S&&N(A,P,{get:()=>R[P],enumerable:!(I=U(R,P))||I.enumerable});return A};var B=A=>T(N({},"__esModule",{value:!0}),A);var X={};G(X,{importConfig:()=>L});module.exports=B(X);var D=class{name;debug;constructor(R,S=!1){this.name=R,this.debug=S}log(...R){if(this.debug){let S=`[ ${Date.now()} ]`;this.name&&(S+=` - ${this.name}`),console.log.apply(console,[S,": ",...R])}}error(...R){let S=`[ ${Date.now()} ] - ERROR`;this.name&&(S+=` - ${this.name}`),console.error.apply(console,[S,": ",...R])}warn(...R){let S=`[ ${Date.now()} ] - WARN`;this.name&&(S+=` - ${this.name}`),console.warn.apply(console,[S,": ",...R])}info(...R){let S=`[ ${Date.now()} ] - INFO`;this.name&&(S+=` - ${this.name}`),console.info.apply(console,[S,": ",...R])}};var K="UTILS",M=!1,O=new D(K,process.env.DEBUG==="true"||M),F=3e3,p=30,H=2e4,i=A=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A?.accessToken)throw O.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},L=A=>{i(A);let R={M4D_APP_ID:A?.appId||process.env.M4D_APP_ID||"",M4D_APP_SECRET:A?.appSecret||process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:A?.phoneNumberId||Number(process.env.WA_PHONE_NUMBER_ID),WA_BUSINESS_ACCOUNT_ID:A?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:A?.apiVersion||process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:A?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:A?.webhookEndpoint||process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:A?.webhookVerificationToken||process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:A?.listenerPort||parseInt(process.env.LISTENER_PORT||"")||F,MAX_RETRIES_AFTER_WAIT:A?.maxRetriesAfterWait||parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||p,REQUEST_TIMEOUT:A?.requestTimeout||parseInt(process.env.REQUEST_TIMEOUT||"")||H,DEBUG:A?.debug||process.env.DEBUG==="true",FLOW_API_PRIVATE_PEM:A?.privatePem||process.env.FLOW_API_PRIVATE_PEM||"",FLOW_API_PASSPHRASE:A?.passphrase||process.env.FLOW_API_PASSPHRASE||""};return O.log(`Configuration loaded for App Id ${R.M4D_APP_ID}`),R};0&&(module.exports={importConfig});
|
|
2
|
-
//# sourceMappingURL=importConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/importConfig.ts","../../src/utils/logger.ts"],"sourcesContent":["import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.AppId]: inputConfig?.appId || process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: inputConfig?.appSecret || process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || Number(process.env.WA_PHONE_NUMBER_ID),\n [WabaConfigEnum.BusinessAcctId]: inputConfig?.businessAcctId || process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: inputConfig?.apiVersion || process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: inputConfig?.webhookEndpoint || process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]:\n inputConfig?.webhookVerificationToken || process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]:\n inputConfig?.listenerPort || parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n inputConfig?.maxRetriesAfterWait ||\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') ||\n DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]:\n inputConfig?.requestTimeout || parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: inputConfig?.debug || process.env.DEBUG === 'true',\n [WabaConfigEnum.PrivatePem]: inputConfig?.privatePem || process.env.FLOW_API_PRIVATE_PEM || '',\n [WabaConfigEnum.Passphrase]: inputConfig?.passphrase || process.env.FLOW_API_PASSPHRASE || '',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,EDxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAsBC,GAAuC,CAC/D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACA,GAAQ,YACrD,MAAAN,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,CAExD,EAEaO,EAAgBC,GAAiC,CAC1DH,EAAmBG,CAAW,EAE9B,IAAMC,EAA6B,CAC9B,WAAuBD,GAAa,OAAS,QAAQ,IAAI,YAAc,GACvE,eAA2BA,GAAa,WAAa,QAAQ,IAAI,gBAAkB,GACnF,mBAA+BA,GAAa,eAAiB,OAAO,QAAQ,IAAI,kBAAkB,EAClG,uBAAgCA,GAAa,gBAAkB,QAAQ,IAAI,wBAA0B,GACrG,kBAA4BA,GAAa,YAAc,QAAQ,IAAI,mBAAqB,GACxF,uBAA6BA,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiCA,GAAa,iBAAmB,QAAQ,IAAI,kBAAoB,GACjG,2BACGA,GAAa,0BAA4B,QAAQ,IAAI,4BAA8B,GACtF,cACGA,GAAa,cAAgB,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKN,EAC7E,uBACGM,GAAa,qBACb,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GACjDL,EACH,gBACGK,GAAa,gBAAkB,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKJ,EACjF,MAAuBI,GAAa,OAAS,QAAQ,IAAI,QAAU,OACnE,qBAA4BA,GAAa,YAAc,QAAQ,IAAI,sBAAwB,GAC3F,oBAA4BA,GAAa,YAAc,QAAQ,IAAI,qBAAuB,EAC/F,EAEA,OAAAR,EAAO,IAAI,mCAAmCS,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["importConfig_exports","__export","importConfig","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","config","importConfig","inputConfig","wabaConfig"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var P=class{name;debug;constructor(S,R=!1){this.name=S,this.debug=R}log(...S){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...S])}}error(...S){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...S])}warn(...S){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...S])}info(...S){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...S])}};var N="UTILS",I=!1,D=new P(N,process.env.DEBUG==="true"||I),O=3e3,U=30,t=2e4,_=A=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!A?.accessToken)throw D.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},F=A=>{_(A);let S={M4D_APP_ID:A?.appId||process.env.M4D_APP_ID||"",M4D_APP_SECRET:A?.appSecret||process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:A?.phoneNumberId||Number(process.env.WA_PHONE_NUMBER_ID),WA_BUSINESS_ACCOUNT_ID:A?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:A?.apiVersion||process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:A?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:A?.webhookEndpoint||process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:A?.webhookVerificationToken||process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:A?.listenerPort||parseInt(process.env.LISTENER_PORT||"")||O,MAX_RETRIES_AFTER_WAIT:A?.maxRetriesAfterWait||parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||U,REQUEST_TIMEOUT:A?.requestTimeout||parseInt(process.env.REQUEST_TIMEOUT||"")||t,DEBUG:A?.debug||process.env.DEBUG==="true",FLOW_API_PRIVATE_PEM:A?.privatePem||process.env.FLOW_API_PRIVATE_PEM||"",FLOW_API_PASSPHRASE:A?.passphrase||process.env.FLOW_API_PASSPHRASE||""};return D.log(`Configuration loaded for App Id ${S.M4D_APP_ID}`),S};export{F as importConfig};
|
|
2
|
-
//# sourceMappingURL=importConfig.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/importConfig.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import { WhatsAppConfig } from 'src/types/whatsapp';\nimport type { WabaConfigType } from '../types/config';\nimport { WabaConfigEnum } from '../types/enums';\nimport Logger from './logger';\n\nconst LIB_NAME = 'UTILS';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\nconst DEFAULT_LISTENER_PORT = 3000;\nconst DEFAULT_MAX_RETRIES_AFTER_WAIT = 30;\nconst DEFAULT_REQUEST_TIMEOUT = 20000;\n\nconst emptyConfigChecker = (config: WhatsAppConfig | undefined) => {\n if (!process.env[WabaConfigEnum.AccessToken] && !config?.accessToken) {\n LOGGER.log(`Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined.`);\n throw new Error('Missing WhatsApp access token.');\n }\n};\n\nexport const importConfig = (inputConfig?: WhatsAppConfig) => {\n emptyConfigChecker(inputConfig);\n\n const wabaConfig: WabaConfigType = {\n [WabaConfigEnum.AppId]: inputConfig?.appId || process.env.M4D_APP_ID || '',\n [WabaConfigEnum.AppSecret]: inputConfig?.appSecret || process.env.M4D_APP_SECRET || '',\n [WabaConfigEnum.PhoneNumberId]: inputConfig?.phoneNumberId || Number(process.env.WA_PHONE_NUMBER_ID),\n [WabaConfigEnum.BusinessAcctId]: inputConfig?.businessAcctId || process.env.WA_BUSINESS_ACCOUNT_ID || '',\n [WabaConfigEnum.APIVersion]: inputConfig?.apiVersion || process.env.CLOUD_API_VERSION || '',\n [WabaConfigEnum.AccessToken]: inputConfig?.accessToken || process.env.CLOUD_API_ACCESS_TOKEN || '',\n [WabaConfigEnum.WebhookEndpoint]: inputConfig?.webhookEndpoint || process.env.WEBHOOK_ENDPOINT || '',\n [WabaConfigEnum.WebhookVerificationToken]:\n inputConfig?.webhookVerificationToken || process.env.WEBHOOK_VERIFICATION_TOKEN || '',\n [WabaConfigEnum.ListenerPort]:\n inputConfig?.listenerPort || parseInt(process.env.LISTENER_PORT || '') || DEFAULT_LISTENER_PORT,\n [WabaConfigEnum.MaxRetriesAfterWait]:\n inputConfig?.maxRetriesAfterWait ||\n parseInt(process.env.MAX_RETRIES_AFTER_WAIT || '') ||\n DEFAULT_MAX_RETRIES_AFTER_WAIT,\n [WabaConfigEnum.RequestTimeout]:\n inputConfig?.requestTimeout || parseInt(process.env.REQUEST_TIMEOUT || '') || DEFAULT_REQUEST_TIMEOUT,\n [WabaConfigEnum.Debug]: inputConfig?.debug || process.env.DEBUG === 'true',\n [WabaConfigEnum.PrivatePem]: inputConfig?.privatePem || process.env.FLOW_API_PRIVATE_PEM || '',\n [WabaConfigEnum.Passphrase]: inputConfig?.passphrase || process.env.FLOW_API_PASSPHRASE || '',\n };\n\n LOGGER.log(`Configuration loaded for App Id ${wabaConfig[WabaConfigEnum.AppId]}`);\n\n return wabaConfig;\n};\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,ECxCA,IAAME,EAAW,QACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EACvEG,EAAwB,IACxBC,EAAiC,GACjCC,EAA0B,IAE1BC,EAAsBC,GAAuC,CAC/D,GAAI,CAAC,QAAQ,IAAI,wBAA+B,CAACA,GAAQ,YACrD,MAAAN,EAAO,IAAI,2FAA2F,EAChG,IAAI,MAAM,gCAAgC,CAExD,EAEaO,EAAgBC,GAAiC,CAC1DH,EAAmBG,CAAW,EAE9B,IAAMC,EAA6B,CAC9B,WAAuBD,GAAa,OAAS,QAAQ,IAAI,YAAc,GACvE,eAA2BA,GAAa,WAAa,QAAQ,IAAI,gBAAkB,GACnF,mBAA+BA,GAAa,eAAiB,OAAO,QAAQ,IAAI,kBAAkB,EAClG,uBAAgCA,GAAa,gBAAkB,QAAQ,IAAI,wBAA0B,GACrG,kBAA4BA,GAAa,YAAc,QAAQ,IAAI,mBAAqB,GACxF,uBAA6BA,GAAa,aAAe,QAAQ,IAAI,wBAA0B,GAC/F,iBAAiCA,GAAa,iBAAmB,QAAQ,IAAI,kBAAoB,GACjG,2BACGA,GAAa,0BAA4B,QAAQ,IAAI,4BAA8B,GACtF,cACGA,GAAa,cAAgB,SAAS,QAAQ,IAAI,eAAiB,EAAE,GAAKN,EAC7E,uBACGM,GAAa,qBACb,SAAS,QAAQ,IAAI,wBAA0B,EAAE,GACjDL,EACH,gBACGK,GAAa,gBAAkB,SAAS,QAAQ,IAAI,iBAAmB,EAAE,GAAKJ,EACjF,MAAuBI,GAAa,OAAS,QAAQ,IAAI,QAAU,OACnE,qBAA4BA,GAAa,YAAc,QAAQ,IAAI,sBAAwB,GAC3F,oBAA4BA,GAAa,YAAc,QAAQ,IAAI,qBAAuB,EAC/F,EAEA,OAAAR,EAAO,IAAI,mCAAmCS,EAAW,UAAqB,EAAE,EAEzEA,CACX","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","DEFAULT_LISTENER_PORT","DEFAULT_MAX_RETRIES_AFTER_WAIT","DEFAULT_REQUEST_TIMEOUT","emptyConfigChecker","config","importConfig","inputConfig","wabaConfig"]}
|