@open-wa/schema 5.6.2 → 5.6.4
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/dist/generated/index.cjs +1 -1
- package/dist/generated/index.d.cts +1 -1
- package/dist/generated/index.d.mts +1 -1
- package/dist/generated/index.mjs +1 -1
- package/dist/{index-DOca1sBu.d.mts → index-C3kjyOe-.d.mts} +3 -526
- package/dist/index-C3kjyOe-.d.mts.map +1 -0
- package/dist/{index-Cl1bU6DB.d.cts → index-HeicIada.d.cts} +3 -526
- package/dist/index-HeicIada.d.cts.map +1 -0
- package/dist/index.cjs +26 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interactive-DxUwKpzK.d.cts +527 -0
- package/dist/interactive-DxUwKpzK.d.cts.map +1 -0
- package/dist/interactive-DxUwKpzK.d.mts +527 -0
- package/dist/interactive-DxUwKpzK.d.mts.map +1 -0
- package/dist/interactive.cjs +305 -0
- package/dist/interactive.cjs.map +1 -0
- package/dist/interactive.d.cts +2 -0
- package/dist/interactive.d.mts +2 -0
- package/dist/interactive.mjs +283 -0
- package/dist/interactive.mjs.map +1 -0
- package/dist/methods/index.cjs +1 -1
- package/dist/methods/index.d.cts +1 -1
- package/dist/methods/index.d.mts +1 -1
- package/dist/methods/index.mjs +1 -1
- package/dist/{methods-BH7nDC3z.mjs → methods-CGm5G9VI.mjs} +14 -292
- package/dist/methods-CGm5G9VI.mjs.map +1 -0
- package/dist/{methods-DpDzgsbe.cjs → methods-QZbG0hN2.cjs} +15 -425
- package/dist/methods-QZbG0hN2.cjs.map +1 -0
- package/package.json +13 -3
- package/src/generated/asyncapi.json +1 -1
- package/src/generated/openapi.json +2 -2
- package/dist/index-Cl1bU6DB.d.cts.map +0 -1
- package/dist/index-DOca1sBu.d.mts.map +0 -1
- package/dist/methods-BH7nDC3z.mjs.map +0 -1
- package/dist/methods-DpDzgsbe.cjs.map +0 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region src/interactive.ts
|
|
4
|
+
const JsonValueSchema = zod.z.lazy(() => zod.z.union([
|
|
5
|
+
zod.z.null(),
|
|
6
|
+
zod.z.boolean(),
|
|
7
|
+
zod.z.number().finite(),
|
|
8
|
+
zod.z.string(),
|
|
9
|
+
zod.z.array(JsonValueSchema),
|
|
10
|
+
zod.z.record(zod.z.string(), JsonValueSchema)
|
|
11
|
+
]));
|
|
12
|
+
const JsonObjectSchema = zod.z.record(zod.z.string(), JsonValueSchema);
|
|
13
|
+
const text = zod.z.string().min(1);
|
|
14
|
+
const url = zod.z.url().refine((value) => /^https?:\/\//i.test(value), "Use an HTTP or HTTPS URL");
|
|
15
|
+
const id = text.describe("Stable application-defined ID returned when the recipient chooses this item");
|
|
16
|
+
const ReplyActionSchema = zod.z.object({
|
|
17
|
+
type: zod.z.literal("reply"),
|
|
18
|
+
id,
|
|
19
|
+
label: text
|
|
20
|
+
}).strict();
|
|
21
|
+
const LinkActionSchema = zod.z.object({
|
|
22
|
+
type: zod.z.literal("url"),
|
|
23
|
+
label: text,
|
|
24
|
+
url
|
|
25
|
+
}).strict();
|
|
26
|
+
const CallActionSchema = zod.z.object({
|
|
27
|
+
type: zod.z.literal("call"),
|
|
28
|
+
label: text,
|
|
29
|
+
phoneNumber: text
|
|
30
|
+
}).strict();
|
|
31
|
+
const CopyActionSchema = zod.z.object({
|
|
32
|
+
type: zod.z.literal("copy"),
|
|
33
|
+
label: text,
|
|
34
|
+
code: text
|
|
35
|
+
}).strict();
|
|
36
|
+
const InteractiveActionSchema = zod.z.discriminatedUnion("type", [
|
|
37
|
+
ReplyActionSchema,
|
|
38
|
+
LinkActionSchema,
|
|
39
|
+
CallActionSchema,
|
|
40
|
+
CopyActionSchema
|
|
41
|
+
]);
|
|
42
|
+
const NativeActionSchema = zod.z.object({
|
|
43
|
+
name: text.describe("WhatsApp native action name; availability depends on the recipient and account"),
|
|
44
|
+
parameters: JsonObjectSchema.optional()
|
|
45
|
+
}).strict();
|
|
46
|
+
const actions = zod.z.array(InteractiveActionSchema).min(1).superRefine((items, ctx) => {
|
|
47
|
+
const replies = items.filter((item) => item.type === "reply");
|
|
48
|
+
if (replies.length && replies.length !== items.length) ctx.addIssue({
|
|
49
|
+
code: "custom",
|
|
50
|
+
message: "Reply actions cannot be mixed with URL, call or copy actions"
|
|
51
|
+
});
|
|
52
|
+
const ids = /* @__PURE__ */ new Set();
|
|
53
|
+
items.forEach((item, index) => {
|
|
54
|
+
if (item.type !== "reply") return;
|
|
55
|
+
if (ids.has(item.id)) ctx.addIssue({
|
|
56
|
+
code: "custom",
|
|
57
|
+
path: [index, "id"],
|
|
58
|
+
message: "Duplicate reply ID"
|
|
59
|
+
});
|
|
60
|
+
ids.add(item.id);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const media = {
|
|
64
|
+
source: text.describe("HTTP(S) URL, local file path or base64 data URL; resolved by the client before sending"),
|
|
65
|
+
filename: text.optional(),
|
|
66
|
+
title: zod.z.string().optional()
|
|
67
|
+
};
|
|
68
|
+
const InteractiveHeaderSchema = zod.z.discriminatedUnion("type", [
|
|
69
|
+
zod.z.object({
|
|
70
|
+
type: zod.z.literal("text"),
|
|
71
|
+
text
|
|
72
|
+
}).strict(),
|
|
73
|
+
zod.z.object({
|
|
74
|
+
type: zod.z.literal("image"),
|
|
75
|
+
...media
|
|
76
|
+
}).strict(),
|
|
77
|
+
zod.z.object({
|
|
78
|
+
type: zod.z.literal("video"),
|
|
79
|
+
...media
|
|
80
|
+
}).strict(),
|
|
81
|
+
zod.z.object({
|
|
82
|
+
type: zod.z.literal("document"),
|
|
83
|
+
...media
|
|
84
|
+
}).strict()
|
|
85
|
+
]);
|
|
86
|
+
const base = {
|
|
87
|
+
version: zod.z.literal(1).optional().describe("Document format version, defaults to 1; independent of WhatsApp protocol versions"),
|
|
88
|
+
body: text,
|
|
89
|
+
footer: zod.z.string().optional()
|
|
90
|
+
};
|
|
91
|
+
const ButtonsContentSchema = zod.z.object({
|
|
92
|
+
...base,
|
|
93
|
+
type: zod.z.literal("buttons"),
|
|
94
|
+
header: InteractiveHeaderSchema.optional(),
|
|
95
|
+
actions
|
|
96
|
+
}).strict();
|
|
97
|
+
const ListRowSchema = zod.z.object({
|
|
98
|
+
id,
|
|
99
|
+
title: text,
|
|
100
|
+
description: zod.z.string().optional()
|
|
101
|
+
}).strict();
|
|
102
|
+
const ListContentSchema = zod.z.object({
|
|
103
|
+
...base,
|
|
104
|
+
type: zod.z.literal("list"),
|
|
105
|
+
title: zod.z.string().optional(),
|
|
106
|
+
buttonLabel: text.default("Choose an option"),
|
|
107
|
+
sections: zod.z.array(zod.z.object({
|
|
108
|
+
title: zod.z.string().optional(),
|
|
109
|
+
rows: zod.z.array(ListRowSchema).min(1)
|
|
110
|
+
}).strict()).min(1)
|
|
111
|
+
}).strict();
|
|
112
|
+
const FormQuestionSchema = zod.z.object({
|
|
113
|
+
type: zod.z.enum(["singleSelect", "multiSelect"]),
|
|
114
|
+
id,
|
|
115
|
+
label: text,
|
|
116
|
+
options: zod.z.array(zod.z.object({
|
|
117
|
+
id,
|
|
118
|
+
label: text
|
|
119
|
+
}).strict()).min(1),
|
|
120
|
+
allowCustomAnswer: zod.z.boolean().optional()
|
|
121
|
+
}).strict();
|
|
122
|
+
const FormContentSchema = zod.z.object({
|
|
123
|
+
...base,
|
|
124
|
+
type: zod.z.literal("form"),
|
|
125
|
+
title: zod.z.string().optional(),
|
|
126
|
+
questions: zod.z.array(FormQuestionSchema).min(1)
|
|
127
|
+
}).strict();
|
|
128
|
+
const CarouselCardSchema = zod.z.object({
|
|
129
|
+
body: text,
|
|
130
|
+
header: zod.z.object({
|
|
131
|
+
type: zod.z.literal("image"),
|
|
132
|
+
...media
|
|
133
|
+
}).strict(),
|
|
134
|
+
actions
|
|
135
|
+
}).strict();
|
|
136
|
+
const CarouselContentSchema = zod.z.object({
|
|
137
|
+
...base,
|
|
138
|
+
type: zod.z.literal("carousel"),
|
|
139
|
+
cards: zod.z.array(CarouselCardSchema).min(1)
|
|
140
|
+
}).strict();
|
|
141
|
+
const BookingContentSchema = zod.z.object({
|
|
142
|
+
...base,
|
|
143
|
+
type: zod.z.literal("booking"),
|
|
144
|
+
title: zod.z.string().optional(),
|
|
145
|
+
buttonLabel: text.default("View booking"),
|
|
146
|
+
booking: zod.z.object({
|
|
147
|
+
startAt: zod.z.iso.datetime({ offset: true }),
|
|
148
|
+
endAt: zod.z.iso.datetime({ offset: true }).optional(),
|
|
149
|
+
location: zod.z.string().optional(),
|
|
150
|
+
url: url.optional(),
|
|
151
|
+
managementUrl: url.optional(),
|
|
152
|
+
phoneNumber: zod.z.string().optional(),
|
|
153
|
+
email: zod.z.email().optional(),
|
|
154
|
+
description: zod.z.string().optional(),
|
|
155
|
+
labels: zod.z.object({
|
|
156
|
+
language: zod.z.string().optional(),
|
|
157
|
+
meetingType: zod.z.string().optional(),
|
|
158
|
+
detailsTitle: zod.z.string().optional(),
|
|
159
|
+
addToCalendar: zod.z.string().optional(),
|
|
160
|
+
viewOnMap: zod.z.string().optional(),
|
|
161
|
+
manageBooking: zod.z.string().optional()
|
|
162
|
+
}).strict().optional()
|
|
163
|
+
}).strict(),
|
|
164
|
+
actions: zod.z.array(zod.z.discriminatedUnion("type", [
|
|
165
|
+
LinkActionSchema,
|
|
166
|
+
CallActionSchema,
|
|
167
|
+
CopyActionSchema
|
|
168
|
+
])).optional()
|
|
169
|
+
}).strict();
|
|
170
|
+
const NativeContentSchema = zod.z.object({
|
|
171
|
+
...base,
|
|
172
|
+
type: zod.z.literal("native"),
|
|
173
|
+
header: InteractiveHeaderSchema.optional(),
|
|
174
|
+
actions: zod.z.array(NativeActionSchema).min(1),
|
|
175
|
+
parameters: JsonObjectSchema.optional()
|
|
176
|
+
}).strict().describe("Advanced extension for new native action types; parameters are passed through without claiming recipient support");
|
|
177
|
+
const InteractiveContentSchema = zod.z.discriminatedUnion("type", [
|
|
178
|
+
ButtonsContentSchema,
|
|
179
|
+
ListContentSchema,
|
|
180
|
+
FormContentSchema,
|
|
181
|
+
CarouselContentSchema,
|
|
182
|
+
BookingContentSchema,
|
|
183
|
+
NativeContentSchema
|
|
184
|
+
]).superRefine((content, ctx) => {
|
|
185
|
+
const unique = (items, path) => {
|
|
186
|
+
const seen = /* @__PURE__ */ new Set();
|
|
187
|
+
items.forEach((item, index) => {
|
|
188
|
+
if (seen.has(item.id)) ctx.addIssue({
|
|
189
|
+
code: "custom",
|
|
190
|
+
path: [
|
|
191
|
+
...path,
|
|
192
|
+
index,
|
|
193
|
+
"id"
|
|
194
|
+
],
|
|
195
|
+
message: "IDs must be unique"
|
|
196
|
+
});
|
|
197
|
+
seen.add(item.id);
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
if (content.type === "form") {
|
|
201
|
+
unique(content.questions, ["questions"]);
|
|
202
|
+
content.questions.forEach((q, index) => {
|
|
203
|
+
unique(q.options, [
|
|
204
|
+
"questions",
|
|
205
|
+
index,
|
|
206
|
+
"options"
|
|
207
|
+
]);
|
|
208
|
+
if (q.id === "__openwa_form__") ctx.addIssue({
|
|
209
|
+
code: "custom",
|
|
210
|
+
path: [
|
|
211
|
+
"questions",
|
|
212
|
+
index,
|
|
213
|
+
"id"
|
|
214
|
+
],
|
|
215
|
+
message: "This question ID is reserved"
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
if (content.type === "list") {
|
|
220
|
+
const seen = /* @__PURE__ */ new Set();
|
|
221
|
+
content.sections.forEach((section, s) => section.rows.forEach((row, r) => {
|
|
222
|
+
if (seen.has(row.id)) ctx.addIssue({
|
|
223
|
+
code: "custom",
|
|
224
|
+
path: [
|
|
225
|
+
"sections",
|
|
226
|
+
s,
|
|
227
|
+
"rows",
|
|
228
|
+
r,
|
|
229
|
+
"id"
|
|
230
|
+
],
|
|
231
|
+
message: "Row IDs must be unique across sections"
|
|
232
|
+
});
|
|
233
|
+
seen.add(row.id);
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
if (content.type === "booking" && content.booking.endAt && Date.parse(content.booking.endAt) <= Date.parse(content.booking.startAt)) ctx.addIssue({
|
|
237
|
+
code: "custom",
|
|
238
|
+
path: ["booking", "endAt"],
|
|
239
|
+
message: "Booking end must be after its start"
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
/** Validate a JSON document without sending it or loading media; suitable for UI builders. */
|
|
243
|
+
function defineInteractiveMessage(content) {
|
|
244
|
+
return InteractiveContentSchema.parse(content);
|
|
245
|
+
}
|
|
246
|
+
const responseBase = {
|
|
247
|
+
messageId: text,
|
|
248
|
+
chatId: text,
|
|
249
|
+
senderId: text,
|
|
250
|
+
originalMessageId: zod.z.string().optional().describe("Original WhatsApp stanza ID; may not be a full serialized message key"),
|
|
251
|
+
timestamp: zod.z.number().optional(),
|
|
252
|
+
raw: JsonObjectSchema
|
|
253
|
+
};
|
|
254
|
+
const FormResponseSchema = zod.z.object({
|
|
255
|
+
...responseBase,
|
|
256
|
+
type: zod.z.literal("form"),
|
|
257
|
+
answers: zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]))
|
|
258
|
+
});
|
|
259
|
+
const InteractiveResponseSchema = zod.z.discriminatedUnion("type", [
|
|
260
|
+
FormResponseSchema,
|
|
261
|
+
zod.z.object({
|
|
262
|
+
...responseBase,
|
|
263
|
+
type: zod.z.literal("reply"),
|
|
264
|
+
id: text,
|
|
265
|
+
label: zod.z.string().optional()
|
|
266
|
+
}),
|
|
267
|
+
zod.z.object({
|
|
268
|
+
...responseBase,
|
|
269
|
+
type: zod.z.literal("list"),
|
|
270
|
+
id: text,
|
|
271
|
+
label: zod.z.string().optional()
|
|
272
|
+
}),
|
|
273
|
+
zod.z.object({
|
|
274
|
+
...responseBase,
|
|
275
|
+
type: zod.z.literal("native"),
|
|
276
|
+
name: text,
|
|
277
|
+
parameters: JsonValueSchema.optional(),
|
|
278
|
+
parseError: zod.z.string().optional()
|
|
279
|
+
})
|
|
280
|
+
]);
|
|
281
|
+
//#endregion
|
|
282
|
+
exports.BookingContentSchema = BookingContentSchema;
|
|
283
|
+
exports.ButtonsContentSchema = ButtonsContentSchema;
|
|
284
|
+
exports.CallActionSchema = CallActionSchema;
|
|
285
|
+
exports.CarouselCardSchema = CarouselCardSchema;
|
|
286
|
+
exports.CarouselContentSchema = CarouselContentSchema;
|
|
287
|
+
exports.CopyActionSchema = CopyActionSchema;
|
|
288
|
+
exports.FormContentSchema = FormContentSchema;
|
|
289
|
+
exports.FormQuestionSchema = FormQuestionSchema;
|
|
290
|
+
exports.FormResponseSchema = FormResponseSchema;
|
|
291
|
+
exports.InteractiveActionSchema = InteractiveActionSchema;
|
|
292
|
+
exports.InteractiveContentSchema = InteractiveContentSchema;
|
|
293
|
+
exports.InteractiveHeaderSchema = InteractiveHeaderSchema;
|
|
294
|
+
exports.InteractiveResponseSchema = InteractiveResponseSchema;
|
|
295
|
+
exports.JsonObjectSchema = JsonObjectSchema;
|
|
296
|
+
exports.JsonValueSchema = JsonValueSchema;
|
|
297
|
+
exports.LinkActionSchema = LinkActionSchema;
|
|
298
|
+
exports.ListContentSchema = ListContentSchema;
|
|
299
|
+
exports.ListRowSchema = ListRowSchema;
|
|
300
|
+
exports.NativeActionSchema = NativeActionSchema;
|
|
301
|
+
exports.NativeContentSchema = NativeContentSchema;
|
|
302
|
+
exports.ReplyActionSchema = ReplyActionSchema;
|
|
303
|
+
exports.defineInteractiveMessage = defineInteractiveMessage;
|
|
304
|
+
|
|
305
|
+
//# sourceMappingURL=interactive.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.cjs","names":["z"],"sources":["../src/interactive.ts"],"sourcesContent":["import { z } from 'zod';\n\n/** A portable JSON document shared by the SDK, HTTP API and message builders. */\nexport type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };\nexport const JsonValueSchema: z.ZodType<JsonValue> = z.lazy(() => z.union([\n z.null(), z.boolean(), z.number().finite(), z.string(),\n z.array(JsonValueSchema), z.record(z.string(), JsonValueSchema),\n]));\nexport const JsonObjectSchema = z.record(z.string(), JsonValueSchema);\nconst text = z.string().min(1);\nconst url = z.url().refine(value => /^https?:\\/\\//i.test(value), 'Use an HTTP or HTTPS URL');\nconst id = text.describe('Stable application-defined ID returned when the recipient chooses this item');\n\nexport const ReplyActionSchema = z.object({ type: z.literal('reply'), id, label: text }).strict();\nexport const LinkActionSchema = z.object({ type: z.literal('url'), label: text, url }).strict();\nexport const CallActionSchema = z.object({ type: z.literal('call'), label: text, phoneNumber: text }).strict();\nexport const CopyActionSchema = z.object({ type: z.literal('copy'), label: text, code: text }).strict();\nexport const InteractiveActionSchema = z.discriminatedUnion('type', [\n ReplyActionSchema, LinkActionSchema, CallActionSchema, CopyActionSchema,\n]);\nexport const NativeActionSchema = z.object({\n name: text.describe('WhatsApp native action name; availability depends on the recipient and account'),\n parameters: JsonObjectSchema.optional(),\n}).strict();\nconst actions = z.array(InteractiveActionSchema).min(1).superRefine((items, ctx) => {\n const replies = items.filter(item => item.type === 'reply');\n if (replies.length && replies.length !== items.length) {\n ctx.addIssue({ code: 'custom', message: 'Reply actions cannot be mixed with URL, call or copy actions' });\n }\n const ids = new Set<string>();\n items.forEach((item, index) => {\n if (item.type !== 'reply') return;\n if (ids.has(item.id)) ctx.addIssue({ code: 'custom', path: [index, 'id'], message: 'Duplicate reply ID' });\n ids.add(item.id);\n });\n});\n\nconst media = {\n source: text.describe('HTTP(S) URL, local file path or base64 data URL; resolved by the client before sending'),\n filename: text.optional(),\n title: z.string().optional(),\n};\nexport const InteractiveHeaderSchema = z.discriminatedUnion('type', [\n z.object({ type: z.literal('text'), text }).strict(),\n z.object({ type: z.literal('image'), ...media }).strict(),\n z.object({ type: z.literal('video'), ...media }).strict(),\n z.object({ type: z.literal('document'), ...media }).strict(),\n]);\nconst base = {\n version: z.literal(1).optional().describe('Document format version, defaults to 1; independent of WhatsApp protocol versions'),\n body: text,\n footer: z.string().optional(),\n};\nexport const ButtonsContentSchema = z.object({\n ...base, type: z.literal('buttons'), header: InteractiveHeaderSchema.optional(), actions,\n}).strict();\nexport const ListRowSchema = z.object({ id, title: text, description: z.string().optional() }).strict();\nexport const ListContentSchema = z.object({\n ...base, type: z.literal('list'), title: z.string().optional(), buttonLabel: text.default('Choose an option'),\n sections: z.array(z.object({ title: z.string().optional(), rows: z.array(ListRowSchema).min(1) }).strict()).min(1),\n}).strict();\nexport const FormQuestionSchema = z.object({\n type: z.enum(['singleSelect', 'multiSelect']), id, label: text,\n options: z.array(z.object({ id, label: text }).strict()).min(1),\n allowCustomAnswer: z.boolean().optional(),\n}).strict();\nexport const FormContentSchema = z.object({\n ...base, type: z.literal('form'), title: z.string().optional(), questions: z.array(FormQuestionSchema).min(1),\n}).strict();\nexport const CarouselCardSchema = z.object({\n body: text,\n header: z.object({ type: z.literal('image'), ...media }).strict(),\n actions,\n}).strict();\nexport const CarouselContentSchema = z.object({\n ...base, type: z.literal('carousel'), cards: z.array(CarouselCardSchema).min(1),\n}).strict();\nexport const BookingContentSchema = z.object({\n ...base, type: z.literal('booking'), title: z.string().optional(), buttonLabel: text.default('View booking'),\n booking: z.object({\n startAt: z.iso.datetime({ offset: true }), endAt: z.iso.datetime({ offset: true }).optional(),\n location: z.string().optional(), url: url.optional(), managementUrl: url.optional(),\n phoneNumber: z.string().optional(), email: z.email().optional(), description: z.string().optional(),\n labels: z.object({\n language: z.string().optional(), meetingType: z.string().optional(), detailsTitle: z.string().optional(),\n addToCalendar: z.string().optional(), viewOnMap: z.string().optional(), manageBooking: z.string().optional(),\n }).strict().optional(),\n }).strict(),\n actions: z.array(z.discriminatedUnion('type', [LinkActionSchema, CallActionSchema, CopyActionSchema])).optional(),\n}).strict();\nexport const NativeContentSchema = z.object({\n ...base, type: z.literal('native'), header: InteractiveHeaderSchema.optional(),\n actions: z.array(NativeActionSchema).min(1), parameters: JsonObjectSchema.optional(),\n}).strict().describe('Advanced extension for new native action types; parameters are passed through without claiming recipient support');\n\nexport const InteractiveContentSchema = z.discriminatedUnion('type', [\n ButtonsContentSchema, ListContentSchema, FormContentSchema, CarouselContentSchema, BookingContentSchema, NativeContentSchema,\n]).superRefine((content, ctx) => {\n const unique = (items: { id: string }[], path: (string | number)[]) => {\n const seen = new Set<string>();\n items.forEach((item, index) => {\n if (seen.has(item.id)) ctx.addIssue({ code: 'custom', path: [...path, index, 'id'], message: 'IDs must be unique' });\n seen.add(item.id);\n });\n };\n if (content.type === 'form') {\n unique(content.questions, ['questions']);\n content.questions.forEach((q, index) => {\n unique(q.options, ['questions', index, 'options']);\n if (q.id === '__openwa_form__') ctx.addIssue({ code: 'custom', path: ['questions', index, 'id'], message: 'This question ID is reserved' });\n });\n }\n if (content.type === 'list') {\n const seen = new Set<string>();\n content.sections.forEach((section, s) => section.rows.forEach((row, r) => {\n if (seen.has(row.id)) ctx.addIssue({ code: 'custom', path: ['sections', s, 'rows', r, 'id'], message: 'Row IDs must be unique across sections' });\n seen.add(row.id);\n }));\n }\n if (content.type === 'booking' && content.booking.endAt && Date.parse(content.booking.endAt) <= Date.parse(content.booking.startAt)) {\n ctx.addIssue({ code: 'custom', path: ['booking', 'endAt'], message: 'Booking end must be after its start' });\n }\n});\n\nexport type InteractiveContent = z.input<typeof InteractiveContentSchema>;\nexport type InteractiveAction = z.infer<typeof InteractiveActionSchema>;\nexport type InteractiveHeader = z.infer<typeof InteractiveHeaderSchema>;\nexport type FormQuestion = z.infer<typeof FormQuestionSchema>;\n/** Validate a JSON document without sending it or loading media; suitable for UI builders. */\nexport function defineInteractiveMessage<T extends InteractiveContent>(content: T): Extract<z.output<typeof InteractiveContentSchema>, { type: T['type'] }> {\n return InteractiveContentSchema.parse(content) as Extract<z.output<typeof InteractiveContentSchema>, { type: T['type'] }>;\n}\n\nconst responseBase = {\n messageId: text, chatId: text, senderId: text,\n originalMessageId: z.string().optional().describe('Original WhatsApp stanza ID; may not be a full serialized message key'),\n timestamp: z.number().optional(),\n raw: JsonObjectSchema,\n};\nexport const FormResponseSchema = z.object({\n ...responseBase, type: z.literal('form'),\n answers: z.record(z.string(), z.union([z.string(), z.array(z.string())])),\n});\nexport const InteractiveResponseSchema = z.discriminatedUnion('type', [\n FormResponseSchema,\n z.object({ ...responseBase, type: z.literal('reply'), id: text, label: z.string().optional() }),\n z.object({ ...responseBase, type: z.literal('list'), id: text, label: z.string().optional() }),\n z.object({ ...responseBase, type: z.literal('native'), name: text, parameters: JsonValueSchema.optional(), parseError: z.string().optional() }),\n]);\nexport type FormResponse = z.infer<typeof FormResponseSchema>;\nexport type InteractiveResponse = z.infer<typeof InteractiveResponseSchema>;\n"],"mappings":";;;AAIA,MAAa,kBAAwCA,IAAAA,EAAE,WAAWA,IAAAA,EAAE,MAAM;CACxEA,IAAAA,EAAE,KAAK;CAAGA,IAAAA,EAAE,QAAQ;CAAGA,IAAAA,EAAE,OAAO,CAAC,CAAC,OAAO;CAAGA,IAAAA,EAAE,OAAO;CACrDA,IAAAA,EAAE,MAAM,eAAe;CAAGA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,OAAO,GAAG,eAAe;AAChE,CAAC,CAAC;AACF,MAAa,mBAAmBA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,OAAO,GAAG,eAAe;AACpE,MAAM,OAAOA,IAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAC7B,MAAM,MAAMA,IAAAA,EAAE,IAAI,CAAC,CAAC,QAAO,UAAS,gBAAgB,KAAK,KAAK,GAAG,0BAA0B;AAC3F,MAAM,KAAK,KAAK,SAAS,6EAA6E;AAEtG,MAAa,oBAAoBA,IAAAA,EAAE,OAAO;CAAE,MAAMA,IAAAA,EAAE,QAAQ,OAAO;CAAG;CAAI,OAAO;AAAK,CAAC,CAAC,CA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AAAA,EAAE,OAAO,CAAC,CAAC,SAAS;CAAE,CAAC;AAChJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as LinkActionSchema, D as NativeContentSchema, E as NativeActionSchema, O as ReplyActionSchema, S as JsonValueSchema, T as ListRowSchema, _ as InteractiveHeaderSchema, a as CarouselContentSchema, b as JsonObjectSchema, c as FormQuestion, d as FormResponseSchema, f as InteractiveAction, g as InteractiveHeader, h as InteractiveContentSchema, i as CarouselCardSchema, k as defineInteractiveMessage, l as FormQuestionSchema, m as InteractiveContent, n as ButtonsContentSchema, o as CopyActionSchema, p as InteractiveActionSchema, r as CallActionSchema, s as FormContentSchema, t as BookingContentSchema, u as FormResponse, v as InteractiveResponse, w as ListContentSchema, x as JsonValue, y as InteractiveResponseSchema } from "./interactive-DxUwKpzK.cjs";
|
|
2
|
+
export { BookingContentSchema, ButtonsContentSchema, CallActionSchema, CarouselCardSchema, CarouselContentSchema, CopyActionSchema, FormContentSchema, FormQuestion, FormQuestionSchema, FormResponse, FormResponseSchema, InteractiveAction, InteractiveActionSchema, InteractiveContent, InteractiveContentSchema, InteractiveHeader, InteractiveHeaderSchema, InteractiveResponse, InteractiveResponseSchema, JsonObjectSchema, JsonValue, JsonValueSchema, LinkActionSchema, ListContentSchema, ListRowSchema, NativeActionSchema, NativeContentSchema, ReplyActionSchema, defineInteractiveMessage };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as LinkActionSchema, D as NativeContentSchema, E as NativeActionSchema, O as ReplyActionSchema, S as JsonValueSchema, T as ListRowSchema, _ as InteractiveHeaderSchema, a as CarouselContentSchema, b as JsonObjectSchema, c as FormQuestion, d as FormResponseSchema, f as InteractiveAction, g as InteractiveHeader, h as InteractiveContentSchema, i as CarouselCardSchema, k as defineInteractiveMessage, l as FormQuestionSchema, m as InteractiveContent, n as ButtonsContentSchema, o as CopyActionSchema, p as InteractiveActionSchema, r as CallActionSchema, s as FormContentSchema, t as BookingContentSchema, u as FormResponse, v as InteractiveResponse, w as ListContentSchema, x as JsonValue, y as InteractiveResponseSchema } from "./interactive-DxUwKpzK.mjs";
|
|
2
|
+
export { BookingContentSchema, ButtonsContentSchema, CallActionSchema, CarouselCardSchema, CarouselContentSchema, CopyActionSchema, FormContentSchema, FormQuestion, FormQuestionSchema, FormResponse, FormResponseSchema, InteractiveAction, InteractiveActionSchema, InteractiveContent, InteractiveContentSchema, InteractiveHeader, InteractiveHeaderSchema, InteractiveResponse, InteractiveResponseSchema, JsonObjectSchema, JsonValue, JsonValueSchema, LinkActionSchema, ListContentSchema, ListRowSchema, NativeActionSchema, NativeContentSchema, ReplyActionSchema, defineInteractiveMessage };
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/interactive.ts
|
|
3
|
+
const JsonValueSchema = z.lazy(() => z.union([
|
|
4
|
+
z.null(),
|
|
5
|
+
z.boolean(),
|
|
6
|
+
z.number().finite(),
|
|
7
|
+
z.string(),
|
|
8
|
+
z.array(JsonValueSchema),
|
|
9
|
+
z.record(z.string(), JsonValueSchema)
|
|
10
|
+
]));
|
|
11
|
+
const JsonObjectSchema = z.record(z.string(), JsonValueSchema);
|
|
12
|
+
const text = z.string().min(1);
|
|
13
|
+
const url = z.url().refine((value) => /^https?:\/\//i.test(value), "Use an HTTP or HTTPS URL");
|
|
14
|
+
const id = text.describe("Stable application-defined ID returned when the recipient chooses this item");
|
|
15
|
+
const ReplyActionSchema = z.object({
|
|
16
|
+
type: z.literal("reply"),
|
|
17
|
+
id,
|
|
18
|
+
label: text
|
|
19
|
+
}).strict();
|
|
20
|
+
const LinkActionSchema = z.object({
|
|
21
|
+
type: z.literal("url"),
|
|
22
|
+
label: text,
|
|
23
|
+
url
|
|
24
|
+
}).strict();
|
|
25
|
+
const CallActionSchema = z.object({
|
|
26
|
+
type: z.literal("call"),
|
|
27
|
+
label: text,
|
|
28
|
+
phoneNumber: text
|
|
29
|
+
}).strict();
|
|
30
|
+
const CopyActionSchema = z.object({
|
|
31
|
+
type: z.literal("copy"),
|
|
32
|
+
label: text,
|
|
33
|
+
code: text
|
|
34
|
+
}).strict();
|
|
35
|
+
const InteractiveActionSchema = z.discriminatedUnion("type", [
|
|
36
|
+
ReplyActionSchema,
|
|
37
|
+
LinkActionSchema,
|
|
38
|
+
CallActionSchema,
|
|
39
|
+
CopyActionSchema
|
|
40
|
+
]);
|
|
41
|
+
const NativeActionSchema = z.object({
|
|
42
|
+
name: text.describe("WhatsApp native action name; availability depends on the recipient and account"),
|
|
43
|
+
parameters: JsonObjectSchema.optional()
|
|
44
|
+
}).strict();
|
|
45
|
+
const actions = z.array(InteractiveActionSchema).min(1).superRefine((items, ctx) => {
|
|
46
|
+
const replies = items.filter((item) => item.type === "reply");
|
|
47
|
+
if (replies.length && replies.length !== items.length) ctx.addIssue({
|
|
48
|
+
code: "custom",
|
|
49
|
+
message: "Reply actions cannot be mixed with URL, call or copy actions"
|
|
50
|
+
});
|
|
51
|
+
const ids = /* @__PURE__ */ new Set();
|
|
52
|
+
items.forEach((item, index) => {
|
|
53
|
+
if (item.type !== "reply") return;
|
|
54
|
+
if (ids.has(item.id)) ctx.addIssue({
|
|
55
|
+
code: "custom",
|
|
56
|
+
path: [index, "id"],
|
|
57
|
+
message: "Duplicate reply ID"
|
|
58
|
+
});
|
|
59
|
+
ids.add(item.id);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const media = {
|
|
63
|
+
source: text.describe("HTTP(S) URL, local file path or base64 data URL; resolved by the client before sending"),
|
|
64
|
+
filename: text.optional(),
|
|
65
|
+
title: z.string().optional()
|
|
66
|
+
};
|
|
67
|
+
const InteractiveHeaderSchema = z.discriminatedUnion("type", [
|
|
68
|
+
z.object({
|
|
69
|
+
type: z.literal("text"),
|
|
70
|
+
text
|
|
71
|
+
}).strict(),
|
|
72
|
+
z.object({
|
|
73
|
+
type: z.literal("image"),
|
|
74
|
+
...media
|
|
75
|
+
}).strict(),
|
|
76
|
+
z.object({
|
|
77
|
+
type: z.literal("video"),
|
|
78
|
+
...media
|
|
79
|
+
}).strict(),
|
|
80
|
+
z.object({
|
|
81
|
+
type: z.literal("document"),
|
|
82
|
+
...media
|
|
83
|
+
}).strict()
|
|
84
|
+
]);
|
|
85
|
+
const base = {
|
|
86
|
+
version: z.literal(1).optional().describe("Document format version, defaults to 1; independent of WhatsApp protocol versions"),
|
|
87
|
+
body: text,
|
|
88
|
+
footer: z.string().optional()
|
|
89
|
+
};
|
|
90
|
+
const ButtonsContentSchema = z.object({
|
|
91
|
+
...base,
|
|
92
|
+
type: z.literal("buttons"),
|
|
93
|
+
header: InteractiveHeaderSchema.optional(),
|
|
94
|
+
actions
|
|
95
|
+
}).strict();
|
|
96
|
+
const ListRowSchema = z.object({
|
|
97
|
+
id,
|
|
98
|
+
title: text,
|
|
99
|
+
description: z.string().optional()
|
|
100
|
+
}).strict();
|
|
101
|
+
const ListContentSchema = z.object({
|
|
102
|
+
...base,
|
|
103
|
+
type: z.literal("list"),
|
|
104
|
+
title: z.string().optional(),
|
|
105
|
+
buttonLabel: text.default("Choose an option"),
|
|
106
|
+
sections: z.array(z.object({
|
|
107
|
+
title: z.string().optional(),
|
|
108
|
+
rows: z.array(ListRowSchema).min(1)
|
|
109
|
+
}).strict()).min(1)
|
|
110
|
+
}).strict();
|
|
111
|
+
const FormQuestionSchema = z.object({
|
|
112
|
+
type: z.enum(["singleSelect", "multiSelect"]),
|
|
113
|
+
id,
|
|
114
|
+
label: text,
|
|
115
|
+
options: z.array(z.object({
|
|
116
|
+
id,
|
|
117
|
+
label: text
|
|
118
|
+
}).strict()).min(1),
|
|
119
|
+
allowCustomAnswer: z.boolean().optional()
|
|
120
|
+
}).strict();
|
|
121
|
+
const FormContentSchema = z.object({
|
|
122
|
+
...base,
|
|
123
|
+
type: z.literal("form"),
|
|
124
|
+
title: z.string().optional(),
|
|
125
|
+
questions: z.array(FormQuestionSchema).min(1)
|
|
126
|
+
}).strict();
|
|
127
|
+
const CarouselCardSchema = z.object({
|
|
128
|
+
body: text,
|
|
129
|
+
header: z.object({
|
|
130
|
+
type: z.literal("image"),
|
|
131
|
+
...media
|
|
132
|
+
}).strict(),
|
|
133
|
+
actions
|
|
134
|
+
}).strict();
|
|
135
|
+
const CarouselContentSchema = z.object({
|
|
136
|
+
...base,
|
|
137
|
+
type: z.literal("carousel"),
|
|
138
|
+
cards: z.array(CarouselCardSchema).min(1)
|
|
139
|
+
}).strict();
|
|
140
|
+
const BookingContentSchema = z.object({
|
|
141
|
+
...base,
|
|
142
|
+
type: z.literal("booking"),
|
|
143
|
+
title: z.string().optional(),
|
|
144
|
+
buttonLabel: text.default("View booking"),
|
|
145
|
+
booking: z.object({
|
|
146
|
+
startAt: z.iso.datetime({ offset: true }),
|
|
147
|
+
endAt: z.iso.datetime({ offset: true }).optional(),
|
|
148
|
+
location: z.string().optional(),
|
|
149
|
+
url: url.optional(),
|
|
150
|
+
managementUrl: url.optional(),
|
|
151
|
+
phoneNumber: z.string().optional(),
|
|
152
|
+
email: z.email().optional(),
|
|
153
|
+
description: z.string().optional(),
|
|
154
|
+
labels: z.object({
|
|
155
|
+
language: z.string().optional(),
|
|
156
|
+
meetingType: z.string().optional(),
|
|
157
|
+
detailsTitle: z.string().optional(),
|
|
158
|
+
addToCalendar: z.string().optional(),
|
|
159
|
+
viewOnMap: z.string().optional(),
|
|
160
|
+
manageBooking: z.string().optional()
|
|
161
|
+
}).strict().optional()
|
|
162
|
+
}).strict(),
|
|
163
|
+
actions: z.array(z.discriminatedUnion("type", [
|
|
164
|
+
LinkActionSchema,
|
|
165
|
+
CallActionSchema,
|
|
166
|
+
CopyActionSchema
|
|
167
|
+
])).optional()
|
|
168
|
+
}).strict();
|
|
169
|
+
const NativeContentSchema = z.object({
|
|
170
|
+
...base,
|
|
171
|
+
type: z.literal("native"),
|
|
172
|
+
header: InteractiveHeaderSchema.optional(),
|
|
173
|
+
actions: z.array(NativeActionSchema).min(1),
|
|
174
|
+
parameters: JsonObjectSchema.optional()
|
|
175
|
+
}).strict().describe("Advanced extension for new native action types; parameters are passed through without claiming recipient support");
|
|
176
|
+
const InteractiveContentSchema = z.discriminatedUnion("type", [
|
|
177
|
+
ButtonsContentSchema,
|
|
178
|
+
ListContentSchema,
|
|
179
|
+
FormContentSchema,
|
|
180
|
+
CarouselContentSchema,
|
|
181
|
+
BookingContentSchema,
|
|
182
|
+
NativeContentSchema
|
|
183
|
+
]).superRefine((content, ctx) => {
|
|
184
|
+
const unique = (items, path) => {
|
|
185
|
+
const seen = /* @__PURE__ */ new Set();
|
|
186
|
+
items.forEach((item, index) => {
|
|
187
|
+
if (seen.has(item.id)) ctx.addIssue({
|
|
188
|
+
code: "custom",
|
|
189
|
+
path: [
|
|
190
|
+
...path,
|
|
191
|
+
index,
|
|
192
|
+
"id"
|
|
193
|
+
],
|
|
194
|
+
message: "IDs must be unique"
|
|
195
|
+
});
|
|
196
|
+
seen.add(item.id);
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
if (content.type === "form") {
|
|
200
|
+
unique(content.questions, ["questions"]);
|
|
201
|
+
content.questions.forEach((q, index) => {
|
|
202
|
+
unique(q.options, [
|
|
203
|
+
"questions",
|
|
204
|
+
index,
|
|
205
|
+
"options"
|
|
206
|
+
]);
|
|
207
|
+
if (q.id === "__openwa_form__") ctx.addIssue({
|
|
208
|
+
code: "custom",
|
|
209
|
+
path: [
|
|
210
|
+
"questions",
|
|
211
|
+
index,
|
|
212
|
+
"id"
|
|
213
|
+
],
|
|
214
|
+
message: "This question ID is reserved"
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (content.type === "list") {
|
|
219
|
+
const seen = /* @__PURE__ */ new Set();
|
|
220
|
+
content.sections.forEach((section, s) => section.rows.forEach((row, r) => {
|
|
221
|
+
if (seen.has(row.id)) ctx.addIssue({
|
|
222
|
+
code: "custom",
|
|
223
|
+
path: [
|
|
224
|
+
"sections",
|
|
225
|
+
s,
|
|
226
|
+
"rows",
|
|
227
|
+
r,
|
|
228
|
+
"id"
|
|
229
|
+
],
|
|
230
|
+
message: "Row IDs must be unique across sections"
|
|
231
|
+
});
|
|
232
|
+
seen.add(row.id);
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
if (content.type === "booking" && content.booking.endAt && Date.parse(content.booking.endAt) <= Date.parse(content.booking.startAt)) ctx.addIssue({
|
|
236
|
+
code: "custom",
|
|
237
|
+
path: ["booking", "endAt"],
|
|
238
|
+
message: "Booking end must be after its start"
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
/** Validate a JSON document without sending it or loading media; suitable for UI builders. */
|
|
242
|
+
function defineInteractiveMessage(content) {
|
|
243
|
+
return InteractiveContentSchema.parse(content);
|
|
244
|
+
}
|
|
245
|
+
const responseBase = {
|
|
246
|
+
messageId: text,
|
|
247
|
+
chatId: text,
|
|
248
|
+
senderId: text,
|
|
249
|
+
originalMessageId: z.string().optional().describe("Original WhatsApp stanza ID; may not be a full serialized message key"),
|
|
250
|
+
timestamp: z.number().optional(),
|
|
251
|
+
raw: JsonObjectSchema
|
|
252
|
+
};
|
|
253
|
+
const FormResponseSchema = z.object({
|
|
254
|
+
...responseBase,
|
|
255
|
+
type: z.literal("form"),
|
|
256
|
+
answers: z.record(z.string(), z.union([z.string(), z.array(z.string())]))
|
|
257
|
+
});
|
|
258
|
+
const InteractiveResponseSchema = z.discriminatedUnion("type", [
|
|
259
|
+
FormResponseSchema,
|
|
260
|
+
z.object({
|
|
261
|
+
...responseBase,
|
|
262
|
+
type: z.literal("reply"),
|
|
263
|
+
id: text,
|
|
264
|
+
label: z.string().optional()
|
|
265
|
+
}),
|
|
266
|
+
z.object({
|
|
267
|
+
...responseBase,
|
|
268
|
+
type: z.literal("list"),
|
|
269
|
+
id: text,
|
|
270
|
+
label: z.string().optional()
|
|
271
|
+
}),
|
|
272
|
+
z.object({
|
|
273
|
+
...responseBase,
|
|
274
|
+
type: z.literal("native"),
|
|
275
|
+
name: text,
|
|
276
|
+
parameters: JsonValueSchema.optional(),
|
|
277
|
+
parseError: z.string().optional()
|
|
278
|
+
})
|
|
279
|
+
]);
|
|
280
|
+
//#endregion
|
|
281
|
+
export { BookingContentSchema, ButtonsContentSchema, CallActionSchema, CarouselCardSchema, CarouselContentSchema, CopyActionSchema, FormContentSchema, FormQuestionSchema, FormResponseSchema, InteractiveActionSchema, InteractiveContentSchema, InteractiveHeaderSchema, InteractiveResponseSchema, JsonObjectSchema, JsonValueSchema, LinkActionSchema, ListContentSchema, ListRowSchema, NativeActionSchema, NativeContentSchema, ReplyActionSchema, defineInteractiveMessage };
|
|
282
|
+
|
|
283
|
+
//# sourceMappingURL=interactive.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.mjs","names":[],"sources":["../src/interactive.ts"],"sourcesContent":["import { z } from 'zod';\n\n/** A portable JSON document shared by the SDK, HTTP API and message builders. */\nexport type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };\nexport const JsonValueSchema: z.ZodType<JsonValue> = z.lazy(() => z.union([\n z.null(), z.boolean(), z.number().finite(), z.string(),\n z.array(JsonValueSchema), z.record(z.string(), JsonValueSchema),\n]));\nexport const JsonObjectSchema = z.record(z.string(), JsonValueSchema);\nconst text = z.string().min(1);\nconst url = z.url().refine(value => /^https?:\\/\\//i.test(value), 'Use an HTTP or HTTPS URL');\nconst id = text.describe('Stable application-defined ID returned when the recipient chooses this item');\n\nexport const ReplyActionSchema = z.object({ type: z.literal('reply'), id, label: text }).strict();\nexport const LinkActionSchema = z.object({ type: z.literal('url'), label: text, url }).strict();\nexport const CallActionSchema = z.object({ type: z.literal('call'), label: text, phoneNumber: text }).strict();\nexport const CopyActionSchema = z.object({ type: z.literal('copy'), label: text, code: text }).strict();\nexport const InteractiveActionSchema = z.discriminatedUnion('type', [\n ReplyActionSchema, LinkActionSchema, CallActionSchema, CopyActionSchema,\n]);\nexport const NativeActionSchema = z.object({\n name: text.describe('WhatsApp native action name; availability depends on the recipient and account'),\n parameters: JsonObjectSchema.optional(),\n}).strict();\nconst actions = z.array(InteractiveActionSchema).min(1).superRefine((items, ctx) => {\n const replies = items.filter(item => item.type === 'reply');\n if (replies.length && replies.length !== items.length) {\n ctx.addIssue({ code: 'custom', message: 'Reply actions cannot be mixed with URL, call or copy actions' });\n }\n const ids = new Set<string>();\n items.forEach((item, index) => {\n if (item.type !== 'reply') return;\n if (ids.has(item.id)) ctx.addIssue({ code: 'custom', path: [index, 'id'], message: 'Duplicate reply ID' });\n ids.add(item.id);\n });\n});\n\nconst media = {\n source: text.describe('HTTP(S) URL, local file path or base64 data URL; resolved by the client before sending'),\n filename: text.optional(),\n title: z.string().optional(),\n};\nexport const InteractiveHeaderSchema = z.discriminatedUnion('type', [\n z.object({ type: z.literal('text'), text }).strict(),\n z.object({ type: z.literal('image'), ...media }).strict(),\n z.object({ type: z.literal('video'), ...media }).strict(),\n z.object({ type: z.literal('document'), ...media }).strict(),\n]);\nconst base = {\n version: z.literal(1).optional().describe('Document format version, defaults to 1; independent of WhatsApp protocol versions'),\n body: text,\n footer: z.string().optional(),\n};\nexport const ButtonsContentSchema = z.object({\n ...base, type: z.literal('buttons'), header: InteractiveHeaderSchema.optional(), actions,\n}).strict();\nexport const ListRowSchema = z.object({ id, title: text, description: z.string().optional() }).strict();\nexport const ListContentSchema = z.object({\n ...base, type: z.literal('list'), title: z.string().optional(), buttonLabel: text.default('Choose an option'),\n sections: z.array(z.object({ title: z.string().optional(), rows: z.array(ListRowSchema).min(1) }).strict()).min(1),\n}).strict();\nexport const FormQuestionSchema = z.object({\n type: z.enum(['singleSelect', 'multiSelect']), id, label: text,\n options: z.array(z.object({ id, label: text }).strict()).min(1),\n allowCustomAnswer: z.boolean().optional(),\n}).strict();\nexport const FormContentSchema = z.object({\n ...base, type: z.literal('form'), title: z.string().optional(), questions: z.array(FormQuestionSchema).min(1),\n}).strict();\nexport const CarouselCardSchema = z.object({\n body: text,\n header: z.object({ type: z.literal('image'), ...media }).strict(),\n actions,\n}).strict();\nexport const CarouselContentSchema = z.object({\n ...base, type: z.literal('carousel'), cards: z.array(CarouselCardSchema).min(1),\n}).strict();\nexport const BookingContentSchema = z.object({\n ...base, type: z.literal('booking'), title: z.string().optional(), buttonLabel: text.default('View booking'),\n booking: z.object({\n startAt: z.iso.datetime({ offset: true }), endAt: z.iso.datetime({ offset: true }).optional(),\n location: z.string().optional(), url: url.optional(), managementUrl: url.optional(),\n phoneNumber: z.string().optional(), email: z.email().optional(), description: z.string().optional(),\n labels: z.object({\n language: z.string().optional(), meetingType: z.string().optional(), detailsTitle: z.string().optional(),\n addToCalendar: z.string().optional(), viewOnMap: z.string().optional(), manageBooking: z.string().optional(),\n }).strict().optional(),\n }).strict(),\n actions: z.array(z.discriminatedUnion('type', [LinkActionSchema, CallActionSchema, CopyActionSchema])).optional(),\n}).strict();\nexport const NativeContentSchema = z.object({\n ...base, type: z.literal('native'), header: InteractiveHeaderSchema.optional(),\n actions: z.array(NativeActionSchema).min(1), parameters: JsonObjectSchema.optional(),\n}).strict().describe('Advanced extension for new native action types; parameters are passed through without claiming recipient support');\n\nexport const InteractiveContentSchema = z.discriminatedUnion('type', [\n ButtonsContentSchema, ListContentSchema, FormContentSchema, CarouselContentSchema, BookingContentSchema, NativeContentSchema,\n]).superRefine((content, ctx) => {\n const unique = (items: { id: string }[], path: (string | number)[]) => {\n const seen = new Set<string>();\n items.forEach((item, index) => {\n if (seen.has(item.id)) ctx.addIssue({ code: 'custom', path: [...path, index, 'id'], message: 'IDs must be unique' });\n seen.add(item.id);\n });\n };\n if (content.type === 'form') {\n unique(content.questions, ['questions']);\n content.questions.forEach((q, index) => {\n unique(q.options, ['questions', index, 'options']);\n if (q.id === '__openwa_form__') ctx.addIssue({ code: 'custom', path: ['questions', index, 'id'], message: 'This question ID is reserved' });\n });\n }\n if (content.type === 'list') {\n const seen = new Set<string>();\n content.sections.forEach((section, s) => section.rows.forEach((row, r) => {\n if (seen.has(row.id)) ctx.addIssue({ code: 'custom', path: ['sections', s, 'rows', r, 'id'], message: 'Row IDs must be unique across sections' });\n seen.add(row.id);\n }));\n }\n if (content.type === 'booking' && content.booking.endAt && Date.parse(content.booking.endAt) <= Date.parse(content.booking.startAt)) {\n ctx.addIssue({ code: 'custom', path: ['booking', 'endAt'], message: 'Booking end must be after its start' });\n }\n});\n\nexport type InteractiveContent = z.input<typeof InteractiveContentSchema>;\nexport type InteractiveAction = z.infer<typeof InteractiveActionSchema>;\nexport type InteractiveHeader = z.infer<typeof InteractiveHeaderSchema>;\nexport type FormQuestion = z.infer<typeof FormQuestionSchema>;\n/** Validate a JSON document without sending it or loading media; suitable for UI builders. */\nexport function defineInteractiveMessage<T extends InteractiveContent>(content: T): Extract<z.output<typeof InteractiveContentSchema>, { type: T['type'] }> {\n return InteractiveContentSchema.parse(content) as Extract<z.output<typeof InteractiveContentSchema>, { type: T['type'] }>;\n}\n\nconst responseBase = {\n messageId: text, chatId: text, senderId: text,\n originalMessageId: z.string().optional().describe('Original WhatsApp stanza ID; may not be a full serialized message key'),\n timestamp: z.number().optional(),\n raw: JsonObjectSchema,\n};\nexport const FormResponseSchema = z.object({\n ...responseBase, type: z.literal('form'),\n answers: z.record(z.string(), z.union([z.string(), z.array(z.string())])),\n});\nexport const InteractiveResponseSchema = z.discriminatedUnion('type', [\n FormResponseSchema,\n z.object({ ...responseBase, type: z.literal('reply'), id: text, label: z.string().optional() }),\n z.object({ ...responseBase, type: z.literal('list'), id: text, label: z.string().optional() }),\n z.object({ ...responseBase, type: z.literal('native'), name: text, parameters: JsonValueSchema.optional(), parseError: z.string().optional() }),\n]);\nexport type FormResponse = z.infer<typeof FormResponseSchema>;\nexport type InteractiveResponse = z.infer<typeof InteractiveResponseSchema>;\n"],"mappings":";;AAIA,MAAa,kBAAwC,EAAE,WAAW,EAAE,MAAM;CACxE,EAAE,KAAK;CAAG,EAAE,QAAQ;CAAG,EAAE,OAAO,CAAC,CAAC,OAAO;CAAG,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OAAO;EAAG,SAAS;CAAsC,CAAC;AAE/G,CAAC;;AAOD,SAAgB,yBAAuD,SAAqF;CAC1J,OAAO,yBAAyB,MAAM,OAAO;AAC/C;AAEA,MAAM,eAAe;CACnB,WAAW;CAAM,QAAQ;CAAM,UAAU;CACzC,mBAAmB,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,uEAAuE;CACzH,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,KAAK;AACP;AACA,MAAa,qBAAqB,EAAE,OAAO;CACzC,GAAG;CAAc,MAAM,EAAE,QAAQ,MAAM;CACvC,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AACD,MAAa,4BAA4B,EAAE,mBAAmB,QAAQ;CACpE;CACA,EAAE,OAAO;EAAE,GAAG;EAAc,MAAM,EAAE,QAAQ,OAAO;EAAG,IAAI;EAAM,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAAE,CAAC;CAC9F,EAAE,OAAO;EAAE,GAAG;EAAc,MAAM,EAAE,QAAQ,MAAM;EAAG,IAAI;EAAM,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAAE,CAAC;CAC7F,EAAE,OAAO;EAAE,GAAG;EAAc,MAAM,EAAE,QAAQ,QAAQ;EAAG,MAAM;EAAM,YAAY,gBAAgB,SAAS;EAAG,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAAE,CAAC;AAChJ,CAAC"}
|
package/dist/methods/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_methods = require("../methods-
|
|
2
|
+
const require_methods = require("../methods-QZbG0hN2.cjs");
|
|
3
3
|
exports.AlbumMediaSchema = require_methods.AlbumMediaSchema;
|
|
4
4
|
exports.AlbumSendResultSchema = require_methods.AlbumSendResultSchema;
|
|
5
5
|
exports.GroupInfoSchema = require_methods.GroupInfoSchema;
|