@open-wa/schema 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated/index.cjs +8 -2
- package/dist/generated/index.cjs.map +1 -1
- package/dist/generated/index.d.cts +7868 -994
- package/dist/generated/index.d.cts.map +1 -1
- package/dist/generated/index.d.mts +7868 -994
- package/dist/generated/index.d.mts.map +1 -1
- package/dist/generated/index.mjs +8 -2
- package/dist/generated/index.mjs.map +1 -1
- package/dist/index-C9Ad0lEr.d.cts +4729 -0
- package/dist/index-C9Ad0lEr.d.cts.map +1 -0
- package/dist/index-D0QN2PaW.d.mts +4729 -0
- package/dist/index-D0QN2PaW.d.mts.map +1 -0
- package/dist/index.cjs +109 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +53 -2
- package/dist/index.mjs.map +1 -1
- package/dist/methods/index.cjs +6 -1
- package/dist/methods/index.d.cts +2 -2
- package/dist/methods/index.d.mts +2 -2
- package/dist/methods/index.mjs +2 -2
- package/dist/{methods-Dizm7Fn9.cjs → methods-BGmdzjd3.cjs} +904 -76
- package/dist/methods-BGmdzjd3.cjs.map +1 -0
- package/dist/{methods-CZqeUhKy.mjs → methods-BhLsQNtL.mjs} +587 -77
- package/dist/methods-BhLsQNtL.mjs.map +1 -0
- package/package.json +4 -3
- package/src/__tests__/generators.contract.test.ts +181 -0
- package/src/__tests__/registry.contract.test.ts +81 -0
- package/src/client-config.ts +30 -0
- package/src/codecs.test.ts +41 -0
- package/src/codecs.ts +191 -0
- package/src/common-types.ts +287 -0
- package/src/config.ts +47 -0
- package/src/enums.ts +63 -0
- package/src/events/groups.ts +33 -0
- package/src/events/index.ts +4 -0
- package/src/events/messaging.ts +86 -0
- package/src/events/registry.ts +124 -0
- package/src/events/state.ts +59 -0
- package/src/generated/AliasMap.ts +216 -0
- package/src/generated/BaseClient.ts +878 -0
- package/src/generated/BaseNamespacedClient.ts +214 -0
- package/src/generated/index.ts +5 -0
- package/src/generated/openapi.json +30049 -0
- package/src/generated/types.ts +383 -0
- package/src/http-manifest.ts +97 -0
- package/src/implementor.test.ts +88 -0
- package/src/implementor.ts +75 -0
- package/src/index.ts +46 -0
- package/src/interactive.ts +151 -0
- package/src/methods/business.ts +52 -0
- package/src/methods/chats.ts +264 -0
- package/src/methods/communities.ts +121 -0
- package/src/methods/contacts.ts +160 -0
- package/src/methods/groups.ts +378 -0
- package/src/methods/index.ts +34 -0
- package/src/methods/interactive.ts +21 -0
- package/src/methods/labels.ts +88 -0
- package/src/methods/media.ts +36 -0
- package/src/methods/messaging.ts +836 -0
- package/src/methods/session.ts +262 -0
- package/src/methods/status.ts +122 -0
- package/src/output-json-schema.ts +27 -0
- package/src/parameters.ts +237 -0
- package/src/registry.test.ts +30 -0
- package/src/registry.ts +601 -0
- package/src/return-types.ts +125 -0
- package/dist/index-BHcd0h7x.d.mts +0 -1265
- package/dist/index-BHcd0h7x.d.mts.map +0 -1
- package/dist/index-ChYFQM1K.d.cts +0 -1265
- package/dist/index-ChYFQM1K.d.cts.map +0 -1
- package/dist/methods-CZqeUhKy.mjs.map +0 -1
- package/dist/methods-Dizm7Fn9.cjs.map +0 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ContactIdSchema, GroupChatIdSchema, GroupIdSchema, IdSchema, ContactSchema, GroupMetadataSchema, MessageIdSchema, MessageSchema } from './common-types';
|
|
3
|
+
|
|
4
|
+
// Public data contracts retained from the v4 models and the shipped WAPI
|
|
5
|
+
// serializers. Optional provider fields stay optional; extensions stay unknown.
|
|
6
|
+
export const LabelSchema = z.object({
|
|
7
|
+
id: z.string(), name: z.string(),
|
|
8
|
+
items: z.array(z.object({ type: z.enum(['Chat', 'Contact', 'Message']), id: z.string() })),
|
|
9
|
+
}).passthrough();
|
|
10
|
+
export type Label = z.infer<typeof LabelSchema>;
|
|
11
|
+
|
|
12
|
+
export const NumberCheckSchema = z.object({
|
|
13
|
+
id: z.union([IdSchema, ContactIdSchema]),
|
|
14
|
+
status: z.unknown().describe('HTTP-like status code, or a provider error value when lookup fails.'), isBusiness: z.boolean().optional(),
|
|
15
|
+
canReceiveMessage: z.boolean(), numberExists: z.boolean().optional(),
|
|
16
|
+
}).passthrough();
|
|
17
|
+
export type NumberCheck = z.infer<typeof NumberCheckSchema>;
|
|
18
|
+
|
|
19
|
+
export const CommonGroupSchema = z.object({ id: GroupIdSchema, title: z.string() }).passthrough();
|
|
20
|
+
export const GroupCreationResultSchema = z.object({
|
|
21
|
+
gid: z.union([GroupIdSchema, IdSchema]),
|
|
22
|
+
status: z.number().optional(),
|
|
23
|
+
participants: z.union([z.record(z.string(), z.object({ code: z.number(), invite_code: z.string().optional(), invite_code_exp: z.string().optional() })), z.array(z.record(z.string(), z.unknown()))]).optional(),
|
|
24
|
+
}).passthrough();
|
|
25
|
+
export const CommunityMetadataSchema = GroupMetadataSchema.extend({ subGroups: z.array(GroupMetadataSchema) });
|
|
26
|
+
export const CommunityParticipantIdsSchema = z.object({ id: GroupChatIdSchema, participants: z.array(ContactIdSchema), subgroup: z.boolean() });
|
|
27
|
+
export const CommunityAdminIdsSchema = z.object({ id: GroupChatIdSchema, admins: z.array(ContactIdSchema), subgroup: z.boolean() });
|
|
28
|
+
export const CommunityParticipantsSchema = z.object({ id: GroupChatIdSchema, participants: z.array(ContactSchema), subgroup: z.boolean() });
|
|
29
|
+
export const CommunityAdminsSchema = z.object({ id: GroupChatIdSchema, admins: z.array(ContactSchema), subgroup: z.boolean() });
|
|
30
|
+
export const MessageInteractionSchema = z.object({ id: ContactIdSchema, t: z.number() });
|
|
31
|
+
export const MessageInfoSchema = z.object({
|
|
32
|
+
id: MessageIdSchema, deliveryRemaining: z.number(), playedRemaining: z.number(), readRemaining: z.number(),
|
|
33
|
+
delivery: z.array(MessageInteractionSchema), read: z.array(MessageInteractionSchema), played: z.array(MessageInteractionSchema),
|
|
34
|
+
}).passthrough();
|
|
35
|
+
export type MessageInfo = z.infer<typeof MessageInfoSchema>;
|
|
36
|
+
export const LLMMessageSchema = z.object({ role: z.enum(['user', 'assistant']), content: z.string() });
|
|
37
|
+
export const ContactStatusSchema = z.object({ id: z.string(), status: z.string() });
|
|
38
|
+
export const HostAccountSchema = z.object({ me: z.union([IdSchema, ContactIdSchema]) }).passthrough()
|
|
39
|
+
.describe('Host account attributes plus the current account ID. Additional WhatsApp Web attributes vary by version.');
|
|
40
|
+
export const HealthCheckSchema = z.object({
|
|
41
|
+
queuedMessages: z.number().optional(), state: z.string().optional(), isPhoneDisconnected: z.boolean().optional(),
|
|
42
|
+
isHere: z.boolean().optional(), wapiInjected: z.boolean().optional(), online: z.boolean().optional(),
|
|
43
|
+
tryingToReachPhone: z.boolean().optional(), retryingIn: z.number().optional(), batteryLow: z.boolean().optional(),
|
|
44
|
+
}).passthrough().describe('Browser health diagnostics. This is not the Easy API /health HTTP envelope.');
|
|
45
|
+
export const LicenseTypeSchema = z.enum(['CUSTOM', 'B2B_RESTRICTED_VOLUME_LICENSE', 'Insiders Program', 'Text Story License Key', 'Image Story License Key', 'Video Story License Key', 'Premium License Key', 'NONE']);
|
|
46
|
+
export const ProductSchema = z.object({
|
|
47
|
+
id: z.string(), currency: z.string(), name: z.string().optional(), description: z.string().optional(),
|
|
48
|
+
isHidden: z.boolean().optional(), catalogWid: z.string().optional(), url: z.string().optional(),
|
|
49
|
+
availability: z.union([z.number(), z.literal('unknown')]).optional(),
|
|
50
|
+
reviewStatus: z.enum(['NO_REVIEW', 'PENDING', 'REJECTED', 'APPROVED', 'OUTDATED']).optional(),
|
|
51
|
+
imageCdnUrl: z.string().optional(), imageCount: z.number().optional(), additionalImageCdnUrl: z.array(z.string()).optional(),
|
|
52
|
+
priceAmount1000: z.number().optional(), retailerId: z.string().optional(), t: z.number().optional(),
|
|
53
|
+
}).passthrough();
|
|
54
|
+
export const CartItemSchema = z.object({ id: z.string(), name: z.string(), qty: z.number(), thumbnailId: z.string(), thumbnailUrl: z.string() });
|
|
55
|
+
export const OrderSchema = z.object({
|
|
56
|
+
id: z.string(), createdAt: z.number(), currency: z.string(), products: z.array(CartItemSchema),
|
|
57
|
+
sellerJid: z.string(), subtotal: z.string(), total: z.string(), message: MessageSchema.optional(),
|
|
58
|
+
}).passthrough();
|
|
59
|
+
export const BusinessProfileSchema = z.object({
|
|
60
|
+
id: ContactIdSchema, tag: z.string().optional(), description: z.string().optional(),
|
|
61
|
+
categories: z.array(z.object({ id: z.string(), localized_display_name: z.string() })).optional(),
|
|
62
|
+
profileOptions: z.object({ commerceExperience: z.enum(['catalog', 'none', 'shop']), cartEnabled: z.boolean() }).optional(),
|
|
63
|
+
email: z.string().optional(), website: z.array(z.string()).optional(),
|
|
64
|
+
businessHours: z.object({ config: z.record(z.string(), z.object({ mode: z.enum(['specific_hours', 'open_24h', 'appointment_only']), hours: z.array(z.array(z.number())) })), timezone: z.string() }).optional(),
|
|
65
|
+
catalogStatus: z.string().optional(), address: z.string().optional(), fbPage: z.unknown().optional(), igProfessional: z.unknown().optional(),
|
|
66
|
+
isProfileLinked: z.boolean().optional(), coverPhoto: z.object({ id: z.string(), url: z.string() }).optional(),
|
|
67
|
+
latitude: z.number().optional(), longitude: z.number().optional(),
|
|
68
|
+
}).passthrough();
|
|
69
|
+
export type BusinessProfile = z.infer<typeof BusinessProfileSchema>;
|
|
70
|
+
export type Product = z.infer<typeof ProductSchema>;
|
|
71
|
+
export type Order = z.infer<typeof OrderSchema>;
|
|
72
|
+
export type HealthCheck = z.infer<typeof HealthCheckSchema>;
|
|
73
|
+
export type HostAccount = z.infer<typeof HostAccountSchema>;
|
|
74
|
+
|
|
75
|
+
// No fixed public payload is available for these patch-supplied methods. Do not
|
|
76
|
+
// fabricate fields or let `any` disable narrowing for callers.
|
|
77
|
+
export const FeatureFlagsSchema = z.record(z.string(), z.unknown())
|
|
78
|
+
.describe('WhatsApp feature flags keyed by name. Values are provider-defined and must be narrowed before use.');
|
|
79
|
+
export const ProcessStatsSchema = z.record(z.string(), z.unknown())
|
|
80
|
+
.describe('Process diagnostics keyed by process ID. The provider controls each entry; no stable entry shape is guaranteed.');
|
|
81
|
+
// Provisional profile contract: reuse the public contact serializer's fields,
|
|
82
|
+
// but do not require them until the licensed provider payload is established.
|
|
83
|
+
// Keep extensions unknown rather than inventing additional profile properties.
|
|
84
|
+
export const NumberProfileSchema = ContactSchema.partial()
|
|
85
|
+
.describe('Provisional number profile based on the public Contact fields. Fields are optional and additional provider fields are unknown. The licensed getNumberProfile payload has not been verified against this model.');
|
|
86
|
+
|
|
87
|
+
// The v4 getMyStoryArray and onStory contracts use Message. Reuse that model
|
|
88
|
+
// for story entries, allowing provider payloads to omit hydrated chat/sender data.
|
|
89
|
+
export const StorySchema = MessageSchema.omit({ chat: true, sender: true }).extend({
|
|
90
|
+
chat: MessageSchema.shape.chat.nullable().optional(),
|
|
91
|
+
sender: ContactSchema.nullable().optional(),
|
|
92
|
+
})
|
|
93
|
+
.describe('Message-shaped status entry, based on the legacy story API. Chat and sender may be absent or null. The licensed getStories payload has not been verified against this model.');
|
|
94
|
+
|
|
95
|
+
export type CommonGroup = z.infer<typeof CommonGroupSchema>;
|
|
96
|
+
|
|
97
|
+
export type GroupCreationResult = z.infer<typeof GroupCreationResultSchema>;
|
|
98
|
+
|
|
99
|
+
export type CommunityMetadata = z.infer<typeof CommunityMetadataSchema>;
|
|
100
|
+
|
|
101
|
+
export type CommunityParticipantIds = z.infer<typeof CommunityParticipantIdsSchema>;
|
|
102
|
+
|
|
103
|
+
export type CommunityAdminIds = z.infer<typeof CommunityAdminIdsSchema>;
|
|
104
|
+
|
|
105
|
+
export type CommunityParticipants = z.infer<typeof CommunityParticipantsSchema>;
|
|
106
|
+
|
|
107
|
+
export type CommunityAdmins = z.infer<typeof CommunityAdminsSchema>;
|
|
108
|
+
|
|
109
|
+
export type MessageInteraction = z.infer<typeof MessageInteractionSchema>;
|
|
110
|
+
|
|
111
|
+
export type LLMMessage = z.infer<typeof LLMMessageSchema>;
|
|
112
|
+
|
|
113
|
+
export type ContactStatus = z.infer<typeof ContactStatusSchema>;
|
|
114
|
+
|
|
115
|
+
export type LicenseType = z.infer<typeof LicenseTypeSchema>;
|
|
116
|
+
|
|
117
|
+
export type CartItem = z.infer<typeof CartItemSchema>;
|
|
118
|
+
|
|
119
|
+
export type FeatureFlags = z.infer<typeof FeatureFlagsSchema>;
|
|
120
|
+
|
|
121
|
+
export type ProcessStats = z.infer<typeof ProcessStatsSchema>;
|
|
122
|
+
|
|
123
|
+
export type NumberProfile = z.infer<typeof NumberProfileSchema>;
|
|
124
|
+
|
|
125
|
+
export type Story = z.infer<typeof StorySchema>;
|