@open-wa/schema 5.6.7 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/calling-media--BLrFrPc.cjs.map +1 -1
  2. package/dist/calling-media-BNTYvogE.mjs.map +1 -1
  3. package/dist/{calling-media-CeGgSzhw.d.cts → calling-media-TZ9L95OH.d.cts} +2 -1
  4. package/dist/{calling-media-CeGgSzhw.d.cts.map → calling-media-TZ9L95OH.d.cts.map} +1 -1
  5. package/dist/{calling-media-CeGgSzhw.d.mts → calling-media-TZ9L95OH.d.mts} +2 -1
  6. package/dist/{calling-media-CeGgSzhw.d.mts.map → calling-media-TZ9L95OH.d.mts.map} +1 -1
  7. package/dist/calling-media.d.cts +1 -1
  8. package/dist/calling-media.d.mts +1 -1
  9. package/dist/generated/index.cjs +1 -1
  10. package/dist/generated/index.d.cts +141 -581
  11. package/dist/generated/index.d.cts.map +1 -1
  12. package/dist/generated/index.d.mts +141 -581
  13. package/dist/generated/index.d.mts.map +1 -1
  14. package/dist/generated/index.mjs +1 -1
  15. package/dist/{index-HeicIada.d.cts → index-BETdayaV.d.cts} +53 -232
  16. package/dist/index-BETdayaV.d.cts.map +1 -0
  17. package/dist/{index-C3kjyOe-.d.mts → index-DH0WRSA7.d.mts} +53 -232
  18. package/dist/index-DH0WRSA7.d.mts.map +1 -0
  19. package/dist/index.cjs +7 -4
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +4 -4
  22. package/dist/index.d.mts +4 -4
  23. package/dist/index.mjs +3 -3
  24. package/dist/{interactive-DxUwKpzK.d.cts → interactive-BE_M4nur.d.cts} +14 -6
  25. package/dist/interactive-BE_M4nur.d.cts.map +1 -0
  26. package/dist/{interactive-DxUwKpzK.d.mts → interactive-BE_M4nur.d.mts} +14 -6
  27. package/dist/interactive-BE_M4nur.d.mts.map +1 -0
  28. package/dist/interactive-ClvvgmVP.cjs +630 -0
  29. package/dist/interactive-ClvvgmVP.cjs.map +1 -0
  30. package/dist/interactive-Dec4HB2U.mjs +475 -0
  31. package/dist/interactive-Dec4HB2U.mjs.map +1 -0
  32. package/dist/interactive.cjs +26 -304
  33. package/dist/interactive.d.cts +2 -2
  34. package/dist/interactive.d.mts +2 -2
  35. package/dist/interactive.mjs +2 -283
  36. package/dist/methods/index.cjs +1 -1
  37. package/dist/methods/index.d.cts +1 -1
  38. package/dist/methods/index.d.mts +1 -1
  39. package/dist/methods/index.mjs +1 -1
  40. package/dist/{methods-QZbG0hN2.cjs → methods-9kRJiEdZ.cjs} +14 -78
  41. package/dist/methods-9kRJiEdZ.cjs.map +1 -0
  42. package/dist/{methods-CGm5G9VI.mjs → methods-NixIgGkq.mjs} +6 -64
  43. package/dist/methods-NixIgGkq.mjs.map +1 -0
  44. package/package.json +3 -3
  45. package/src/__tests__/booking-time.contract.test.ts +88 -0
  46. package/src/booking-time.ts +39 -0
  47. package/src/calling-media.ts +2 -0
  48. package/src/calling.ts +1 -0
  49. package/src/common-types.ts +1 -1
  50. package/src/effect-projection.ts +90 -47
  51. package/src/generated/asyncapi.json +191 -89
  52. package/src/generated/openapi.json +1681 -1307
  53. package/src/interactive.ts +12 -1
  54. package/src/methods/calls.ts +2 -2
  55. package/dist/index-C3kjyOe-.d.mts.map +0 -1
  56. package/dist/index-HeicIada.d.cts.map +0 -1
  57. package/dist/interactive-DxUwKpzK.d.cts.map +0 -1
  58. package/dist/interactive-DxUwKpzK.d.mts.map +0 -1
  59. package/dist/interactive.cjs.map +0 -1
  60. package/dist/interactive.mjs.map +0 -1
  61. package/dist/methods-CGm5G9VI.mjs.map +0 -1
  62. package/dist/methods-QZbG0hN2.cjs.map +0 -1
@@ -1,305 +1,27 @@
1
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
2
+ const require_interactive = require("./interactive-ClvvgmVP.cjs");
3
+ exports.BookingContentSchema = require_interactive.BookingContentSchema;
4
+ exports.BookingTimestampRegistrySchema = require_interactive.BookingTimestampRegistrySchema;
5
+ exports.BookingTimestampSchema = require_interactive.BookingTimestampSchema;
6
+ exports.ButtonsContentSchema = require_interactive.ButtonsContentSchema;
7
+ exports.CallActionSchema = require_interactive.CallActionSchema;
8
+ exports.CarouselCardSchema = require_interactive.CarouselCardSchema;
9
+ exports.CarouselContentSchema = require_interactive.CarouselContentSchema;
10
+ exports.CopyActionSchema = require_interactive.CopyActionSchema;
11
+ exports.FormContentSchema = require_interactive.FormContentSchema;
12
+ exports.FormQuestionSchema = require_interactive.FormQuestionSchema;
13
+ exports.FormResponseSchema = require_interactive.FormResponseSchema;
14
+ exports.InteractiveActionSchema = require_interactive.InteractiveActionSchema;
15
+ exports.InteractiveContentSchema = require_interactive.InteractiveContentSchema;
16
+ exports.InteractiveHeaderSchema = require_interactive.InteractiveHeaderSchema;
17
+ exports.InteractiveResponseSchema = require_interactive.InteractiveResponseSchema;
18
+ exports.JsonObjectSchema = require_interactive.JsonObjectSchema;
19
+ exports.JsonValueSchema = require_interactive.JsonValueSchema;
20
+ exports.LinkActionSchema = require_interactive.LinkActionSchema;
21
+ exports.ListContentSchema = require_interactive.ListContentSchema;
22
+ exports.ListRowSchema = require_interactive.ListRowSchema;
23
+ exports.NativeActionSchema = require_interactive.NativeActionSchema;
24
+ exports.NativeContentSchema = require_interactive.NativeContentSchema;
25
+ exports.ReplyActionSchema = require_interactive.ReplyActionSchema;
26
+ exports.defineInteractiveMessage = require_interactive.defineInteractiveMessage;
27
+ exports.normalizeBookingTimestamp = require_interactive.normalizeBookingTimestamp;
@@ -1,2 +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 };
1
+ import { A as ReplyActionSchema, C as JsonValue, D as ListRowSchema, E as ListContentSchema, M as BookingTimestamp, N as BookingTimestampSchema, O as NativeActionSchema, P as normalizeBookingTimestamp, S as JsonObjectSchema, T as LinkActionSchema, _ as InteractiveContentSchema, a as CarouselCardSchema, b as InteractiveResponse, c as DecodedInteractiveContent, d as FormQuestionSchema, f as FormResponse, g as InteractiveContent, h as InteractiveActionSchema, i as CallActionSchema, j as defineInteractiveMessage, k as NativeContentSchema, l as FormContentSchema, m as InteractiveAction, n as BookingTimestampRegistrySchema, o as CarouselContentSchema, p as FormResponseSchema, r as ButtonsContentSchema, s as CopyActionSchema, t as BookingContentSchema, u as FormQuestion, v as InteractiveHeader, w as JsonValueSchema, x as InteractiveResponseSchema, y as InteractiveHeaderSchema } from "./interactive-BE_M4nur.cjs";
2
+ export { BookingContentSchema, type BookingTimestamp, BookingTimestampRegistrySchema, BookingTimestampSchema, ButtonsContentSchema, CallActionSchema, CarouselCardSchema, CarouselContentSchema, CopyActionSchema, DecodedInteractiveContent, FormContentSchema, FormQuestion, FormQuestionSchema, FormResponse, FormResponseSchema, InteractiveAction, InteractiveActionSchema, InteractiveContent, InteractiveContentSchema, InteractiveHeader, InteractiveHeaderSchema, InteractiveResponse, InteractiveResponseSchema, JsonObjectSchema, JsonValue, JsonValueSchema, LinkActionSchema, ListContentSchema, ListRowSchema, NativeActionSchema, NativeContentSchema, ReplyActionSchema, defineInteractiveMessage, normalizeBookingTimestamp };
@@ -1,2 +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 };
1
+ import { A as ReplyActionSchema, C as JsonValue, D as ListRowSchema, E as ListContentSchema, M as BookingTimestamp, N as BookingTimestampSchema, O as NativeActionSchema, P as normalizeBookingTimestamp, S as JsonObjectSchema, T as LinkActionSchema, _ as InteractiveContentSchema, a as CarouselCardSchema, b as InteractiveResponse, c as DecodedInteractiveContent, d as FormQuestionSchema, f as FormResponse, g as InteractiveContent, h as InteractiveActionSchema, i as CallActionSchema, j as defineInteractiveMessage, k as NativeContentSchema, l as FormContentSchema, m as InteractiveAction, n as BookingTimestampRegistrySchema, o as CarouselContentSchema, p as FormResponseSchema, r as ButtonsContentSchema, s as CopyActionSchema, t as BookingContentSchema, u as FormQuestion, v as InteractiveHeader, w as JsonValueSchema, x as InteractiveResponseSchema, y as InteractiveHeaderSchema } from "./interactive-BE_M4nur.mjs";
2
+ export { BookingContentSchema, type BookingTimestamp, BookingTimestampRegistrySchema, BookingTimestampSchema, ButtonsContentSchema, CallActionSchema, CarouselCardSchema, CarouselContentSchema, CopyActionSchema, DecodedInteractiveContent, FormContentSchema, FormQuestion, FormQuestionSchema, FormResponse, FormResponseSchema, InteractiveAction, InteractiveActionSchema, InteractiveContent, InteractiveContentSchema, InteractiveHeader, InteractiveHeaderSchema, InteractiveResponse, InteractiveResponseSchema, JsonObjectSchema, JsonValue, JsonValueSchema, LinkActionSchema, ListContentSchema, ListRowSchema, NativeActionSchema, NativeContentSchema, ReplyActionSchema, defineInteractiveMessage, normalizeBookingTimestamp };
@@ -1,283 +1,2 @@
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
1
+ import { C as defineInteractiveMessage, S as ReplyActionSchema, T as normalizeBookingTimestamp, _ as LinkActionSchema, a as CarouselCardSchema, b as NativeActionSchema, c as FormContentSchema, d as InteractiveActionSchema, f as InteractiveContentSchema, g as JsonValueSchema, h as JsonObjectSchema, i as CallActionSchema, l as FormQuestionSchema, m as InteractiveResponseSchema, n as BookingTimestampRegistrySchema, o as CarouselContentSchema, p as InteractiveHeaderSchema, r as ButtonsContentSchema, s as CopyActionSchema, t as BookingContentSchema, u as FormResponseSchema, v as ListContentSchema, w as BookingTimestampSchema, x as NativeContentSchema, y as ListRowSchema } from "./interactive-Dec4HB2U.mjs";
2
+ export { BookingContentSchema, BookingTimestampRegistrySchema, BookingTimestampSchema, ButtonsContentSchema, CallActionSchema, CarouselCardSchema, CarouselContentSchema, CopyActionSchema, FormContentSchema, FormQuestionSchema, FormResponseSchema, InteractiveActionSchema, InteractiveContentSchema, InteractiveHeaderSchema, InteractiveResponseSchema, JsonObjectSchema, JsonValueSchema, LinkActionSchema, ListContentSchema, ListRowSchema, NativeActionSchema, NativeContentSchema, ReplyActionSchema, defineInteractiveMessage, normalizeBookingTimestamp };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_methods = require("../methods-QZbG0hN2.cjs");
2
+ const require_methods = require("../methods-9kRJiEdZ.cjs");
3
3
  exports.AlbumMediaSchema = require_methods.AlbumMediaSchema;
4
4
  exports.AlbumSendResultSchema = require_methods.AlbumSendResultSchema;
5
5
  exports.GroupInfoSchema = require_methods.GroupInfoSchema;
@@ -1,2 +1,2 @@
1
- import { $a as sendTextWithMentions, $i as getChat, $r as deleteAllStatus, Aa as pinMessage, Ai as revokeGroupInviteLink, Ar as getConnectionState, Ba as sendImage, Bi as getBlockedIds, Br as getWAVersion, Ca as getMessagesForLLM, Ci as getGroupMembersId, Cr as SendInteractiveInputSchema, Da as getUnsentMessages, Di as promoteParticipant, Dr as decryptMedia, Ea as getStarredMessages, Ei as leaveGroup, Er as sendRawMessage, Fa as sendBanner, Fi as setGroupToAdminsOnly, Fr as getLoadedMessageCount, Ga as sendMultipleContacts, Gi as requestPhoneNumber, Gr as setProfilePicture, Ha as sendListMessage, Hi as getContact, Hr as isPlugged, Ia as sendButtons, Ii as blockContact, Ir as getMe, Ja as sendPtt, Ji as archiveChat, Jr as getOrder, Ka as sendPaymentRequest, Ki as sharePhoneNumber, Kr as getBusinessProducts, La as sendContact, Li as checkNumberStatus, Lr as getProcessStats, Ma as sendAdvancedButtons, Mi as setGroupEditToAdminsOnly, Mr as getHostNumber, Na as sendAlbum, Ni as setGroupIcon, Nr as getLicenseFeatures, Oa as getVCards, Oi as rejectGroupJoinRequest, Or as downloadMedia, Pa as sendAudio, Pi as setGroupTitle, Pr as getLicenseType, Qa as sendText, Qi as getAllChats, Qr as removeLabel, Ra as sendFile, Ri as checkReadReceipts, Rr as getSnapshot, Sa as getMessageInfo, Si as getGroupMembers, Sr as stopCallAudioObserver, Ta as getPollResults, Ti as joinGroupViaLink, Tr as sendInteractive, Ua as sendLocation, Ui as getNumberProfile, Ur as setMyName, Va as sendLinkWithAutoPreview, Vi as getCommonGroups, Vr as healthCheck, Wa as sendMessageWithThumb, Wi as getProfilePicture, Wr as setMyStatus, Xa as sendSeen, Xi as deleteChat, Xr as getAllLabels, Ya as sendReplyWithMentions, Yi as clearChat, Yr as addLabel, Za as sendSticker, Zi as getAllChatIds, Zr as getChatsByLabel, _a as editMessage, _i as demoteParticipant, _r as muteCall, aa as pinChat, ai as postVideoStatus, ao as unstarMessage, ar as cancelEvent, ba as getAllMessages, bi as getGroupInfo, br as setCallMedia, ca as unmuteChat, ci as getCommunityAdmins, cr as getEventResponses, da as AlbumMediaSchema, di as getCommunityParticipants, dr as sendEvent, ea as getChatWithNonContacts, ei as deleteStatus, eo as sendVCard, fa as AlbumSendResult, fi as GroupInfo, fr as acceptCall, ga as deleteMessage, gi as createGroup, gr as getCallCapabilities, ha as StickerJobSchema, hi as approveGroupJoinRequest, hr as getActiveCall, ia as muteChat, ii as postTextStatus, io as unpinMessage, ja as react, ji as setGroupDescription, jr as getFeatures, ka as loadEarlierMessages, ki as removeParticipant, kr as getBatteryLevel, la as unpinChat, li as getCommunityInfo, lr as getEvents, ma as SendTextResultSchema, mi as addParticipant, mr as endCall, na as markAsRead, ni as getStories, no as sendYouTubeLink, oa as setChatEphemeral, oi as getAllCommunities, oo as voteOnPoll, or as editEvent, pa as AlbumSendResultSchema, pi as GroupInfoSchema, pr as clearCallAudio, qa as sendPoll, qi as unblockContact, qr as getBusinessProfile, ra as markAsUnread, ri as postImageStatus, ro as starMessage, sa as unarchiveChat, si as getCommunityAdminIds, sr as getEvent, ta as isChatOnline, ti as getStatus, to as sendVideoAsGif, ua as AlbumMedia, ui as getCommunityParticipantIds, ur as respondToEvent, va as forwardMessages, vi as getAllGroups, vr as observeCallAudio, wa as getMyLastMessage, wi as getKickedGroups, wr as SendRawMessageInputSchema, xa as getMessageById, xi as getGroupInviteLink, xr as startCall, ya as getAlbumMessages, yi as getGroupAdmins, yr as rejectCall, za as sendFileFromUrl, zi as getAllContacts, zr as getUserAgent } from "../index-HeicIada.cjs";
1
+ import { $a as sendTextWithMentions, $i as getChat, $r as deleteAllStatus, Aa as pinMessage, Ai as revokeGroupInviteLink, Ar as getConnectionState, Ba as sendImage, Bi as getBlockedIds, Br as getWAVersion, Ca as getMessagesForLLM, Ci as getGroupMembersId, Cr as SendInteractiveInputSchema, Da as getUnsentMessages, Di as promoteParticipant, Dr as decryptMedia, Ea as getStarredMessages, Ei as leaveGroup, Er as sendRawMessage, Fa as sendBanner, Fi as setGroupToAdminsOnly, Fr as getLoadedMessageCount, Ga as sendMultipleContacts, Gi as requestPhoneNumber, Gr as setProfilePicture, Ha as sendListMessage, Hi as getContact, Hr as isPlugged, Ia as sendButtons, Ii as blockContact, Ir as getMe, Ja as sendPtt, Ji as archiveChat, Jr as getOrder, Ka as sendPaymentRequest, Ki as sharePhoneNumber, Kr as getBusinessProducts, La as sendContact, Li as checkNumberStatus, Lr as getProcessStats, Ma as sendAdvancedButtons, Mi as setGroupEditToAdminsOnly, Mr as getHostNumber, Na as sendAlbum, Ni as setGroupIcon, Nr as getLicenseFeatures, Oa as getVCards, Oi as rejectGroupJoinRequest, Or as downloadMedia, Pa as sendAudio, Pi as setGroupTitle, Pr as getLicenseType, Qa as sendText, Qi as getAllChats, Qr as removeLabel, Ra as sendFile, Ri as checkReadReceipts, Rr as getSnapshot, Sa as getMessageInfo, Si as getGroupMembers, Sr as stopCallAudioObserver, Ta as getPollResults, Ti as joinGroupViaLink, Tr as sendInteractive, Ua as sendLocation, Ui as getNumberProfile, Ur as setMyName, Va as sendLinkWithAutoPreview, Vi as getCommonGroups, Vr as healthCheck, Wa as sendMessageWithThumb, Wi as getProfilePicture, Wr as setMyStatus, Xa as sendSeen, Xi as deleteChat, Xr as getAllLabels, Ya as sendReplyWithMentions, Yi as clearChat, Yr as addLabel, Za as sendSticker, Zi as getAllChatIds, Zr as getChatsByLabel, _a as editMessage, _i as demoteParticipant, _r as muteCall, aa as pinChat, ai as postVideoStatus, ao as unstarMessage, ar as cancelEvent, ba as getAllMessages, bi as getGroupInfo, br as setCallMedia, ca as unmuteChat, ci as getCommunityAdmins, cr as getEventResponses, da as AlbumMediaSchema, di as getCommunityParticipants, dr as sendEvent, ea as getChatWithNonContacts, ei as deleteStatus, eo as sendVCard, fa as AlbumSendResult, fi as GroupInfo, fr as acceptCall, ga as deleteMessage, gi as createGroup, gr as getCallCapabilities, ha as StickerJobSchema, hi as approveGroupJoinRequest, hr as getActiveCall, ia as muteChat, ii as postTextStatus, io as unpinMessage, ja as react, ji as setGroupDescription, jr as getFeatures, ka as loadEarlierMessages, ki as removeParticipant, kr as getBatteryLevel, la as unpinChat, li as getCommunityInfo, lr as getEvents, ma as SendTextResultSchema, mi as addParticipant, mr as endCall, na as markAsRead, ni as getStories, no as sendYouTubeLink, oa as setChatEphemeral, oi as getAllCommunities, oo as voteOnPoll, or as editEvent, pa as AlbumSendResultSchema, pi as GroupInfoSchema, pr as clearCallAudio, qa as sendPoll, qi as unblockContact, qr as getBusinessProfile, ra as markAsUnread, ri as postImageStatus, ro as starMessage, sa as unarchiveChat, si as getCommunityAdminIds, sr as getEvent, ta as isChatOnline, ti as getStatus, to as sendVideoAsGif, ua as AlbumMedia, ui as getCommunityParticipantIds, ur as respondToEvent, va as forwardMessages, vi as getAllGroups, vr as observeCallAudio, wa as getMyLastMessage, wi as getKickedGroups, wr as SendRawMessageInputSchema, xa as getMessageById, xi as getGroupInviteLink, xr as startCall, ya as getAlbumMessages, yi as getGroupAdmins, yr as rejectCall, za as sendFileFromUrl, zi as getAllContacts, zr as getUserAgent } from "../index-BETdayaV.cjs";
2
2
  export { AlbumMedia, AlbumMediaSchema, AlbumSendResult, AlbumSendResultSchema, GroupInfo, GroupInfoSchema, SendInteractiveInputSchema, SendRawMessageInputSchema, SendTextResultSchema, StickerJobSchema, acceptCall, addLabel, addParticipant, approveGroupJoinRequest, archiveChat, blockContact, cancelEvent, checkNumberStatus, checkReadReceipts, clearCallAudio, clearChat, createGroup, decryptMedia, deleteAllStatus, deleteChat, deleteMessage, deleteStatus, demoteParticipant, downloadMedia, editEvent, editMessage, endCall, forwardMessages, getActiveCall, getAlbumMessages, getAllChatIds, getAllChats, getAllCommunities, getAllContacts, getAllGroups, getAllLabels, getAllMessages, getBatteryLevel, getBlockedIds, getBusinessProducts, getBusinessProfile, getCallCapabilities, getChat, getChatWithNonContacts, getChatsByLabel, getCommonGroups, getCommunityAdminIds, getCommunityAdmins, getCommunityInfo, getCommunityParticipantIds, getCommunityParticipants, getConnectionState, getContact, getEvent, getEventResponses, getEvents, getFeatures, getGroupAdmins, getGroupInfo, getGroupInviteLink, getGroupMembers, getGroupMembersId, getHostNumber, getKickedGroups, getLicenseFeatures, getLicenseType, getLoadedMessageCount, getMe, getMessageById, getMessageInfo, getMessagesForLLM, getMyLastMessage, getNumberProfile, getOrder, getPollResults, getProcessStats, getProfilePicture, getSnapshot, getStarredMessages, getStatus, getStories, getUnsentMessages, getUserAgent, getVCards, getWAVersion, healthCheck, isChatOnline, isPlugged, joinGroupViaLink, leaveGroup, loadEarlierMessages, markAsRead, markAsUnread, muteCall, muteChat, observeCallAudio, pinChat, pinMessage, postImageStatus, postTextStatus, postVideoStatus, promoteParticipant, react, rejectCall, rejectGroupJoinRequest, removeLabel, removeParticipant, requestPhoneNumber, respondToEvent, revokeGroupInviteLink, sendAdvancedButtons, sendAlbum, sendAudio, sendBanner, sendButtons, sendContact, sendEvent, sendFile, sendFileFromUrl, sendImage, sendInteractive, sendLinkWithAutoPreview, sendListMessage, sendLocation, sendMessageWithThumb, sendMultipleContacts, sendPaymentRequest, sendPoll, sendPtt, sendRawMessage, sendReplyWithMentions, sendSeen, sendSticker, sendText, sendTextWithMentions, sendVCard, sendVideoAsGif, sendYouTubeLink, setCallMedia, setChatEphemeral, setGroupDescription, setGroupEditToAdminsOnly, setGroupIcon, setGroupTitle, setGroupToAdminsOnly, setMyName, setMyStatus, setProfilePicture, sharePhoneNumber, starMessage, startCall, stopCallAudioObserver, unarchiveChat, unblockContact, unmuteChat, unpinChat, unpinMessage, unstarMessage, voteOnPoll };