@jexkcode/baileys 1.1.5 โ 1.3.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/README.md +29 -0
- package/lib/Builders/A2UI.d.ts +275 -0
- package/lib/Builders/A2UI.js +422 -0
- package/lib/Socket/index.js +25 -0
- package/lib/Utils/auto-reconnect.d.ts +54 -0
- package/lib/Utils/auto-reconnect.js +214 -0
- package/lib/Utils/chat-export.d.ts +52 -0
- package/lib/Utils/chat-export.js +248 -0
- package/lib/Utils/index.d.ts +7 -0
- package/lib/Utils/index.js +7 -0
- package/lib/Utils/message-search.d.ts +44 -0
- package/lib/Utils/message-search.js +250 -0
- package/lib/Utils/messages.js +90 -1
- package/lib/Utils/mini-app.d.ts +93 -0
- package/lib/Utils/mini-app.js +447 -0
- package/lib/Utils/mock-socket.d.ts +60 -0
- package/lib/Utils/mock-socket.js +253 -0
- package/lib/Utils/rich-message-utils.js +75 -0
- package/lib/Utils/transcribe.d.ts +12 -0
- package/lib/Utils/transcribe.js +107 -0
- package/lib/Utils/username.d.ts +3 -0
- package/lib/Utils/username.js +73 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,6 +45,35 @@
|
|
|
45
45
|
|
|
46
46
|
<br>
|
|
47
47
|
|
|
48
|
+
|
|
49
|
+
## ๐ v1.3.0 โ fitur tambahan (port dari JAPofc/baileys, MIT)
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
// Mini App: kartu + tombol buka web (bisa dengan link bertanda-tangan HMAC) / WhatsApp Flow
|
|
53
|
+
await sock.sendMiniApp(jid, { title: 'App', body: 'Buka ๐', url: 'https://app.example', params: { ref: 'bot' },
|
|
54
|
+
secret: 'rahasia', expiresIn: 3600, openWebview: true })
|
|
55
|
+
// verifikasi di server web kamu: verifyMiniAppRequest(req.query, { secret })
|
|
56
|
+
|
|
57
|
+
// A2UI widget
|
|
58
|
+
const ui = new A2UI(); ui.root([ui.text('Halo', { variant: 'h1' }), ui.button(ui.text('Klik'))])
|
|
59
|
+
await sock.sendA2UIWidget(jid, { a2ui: ui, bodyText: 'tes' })
|
|
60
|
+
|
|
61
|
+
// Transkripsi voice note (Whisper-compatible)
|
|
62
|
+
const { text } = await sock.transcribeMessage(m, { provider: openAIWhisperProvider({ apiKey }) })
|
|
63
|
+
|
|
64
|
+
// Tombol nativeFlow baru: { webview }, { reminder }, { cancelReminder }, { address }, { location: true },
|
|
65
|
+
// { catalog }, { products }, { flow }, { voiceCall }, { videoCall }, { clearChat }, { screen }
|
|
66
|
+
|
|
67
|
+
await sock.sendScheduledCall(jid, { scheduledAt: Date.now() + 3600e3, callType: 'voice', title: 'Rapat' })
|
|
68
|
+
await sock.sendMentionAll(jid, 'Halo semua')
|
|
69
|
+
await sock.sendStatusMention({ text: 'hi' }, [jid1, jid2])
|
|
70
|
+
|
|
71
|
+
// Username (baca-saja): checkUsername, checkUsernameMulti, getMyUsername, getUsernameRecommendations,
|
|
72
|
+
// findUserByUsername, fetchContactUsernames โ pakai query_id yang bisa kedaluwarsa (lihat sock.setUsernameQueryIds)
|
|
73
|
+
|
|
74
|
+
// Util: autoReconnect, createMockSocket, exportChatAsCSV / exportChatAsText / exportChatAsJSON, chatStatistics
|
|
75
|
+
```
|
|
76
|
+
|
|
48
77
|
## ๐ฆ Install
|
|
49
78
|
|
|
50
79
|
```bash
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI/Bloks "basic" catalog node types โ confirmed from captured traffic, not a
|
|
3
|
+
* public spec, so treat this as best-effort autocomplete rather than an
|
|
4
|
+
* exhaustive guarantee. `ref` is a builder-only tag (stripped before send) so
|
|
5
|
+
* another node can reference this one via `BloksRef`.
|
|
6
|
+
*/
|
|
7
|
+
export interface BloksRef {
|
|
8
|
+
$ref: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BloksNodeBase {
|
|
11
|
+
/** Builder-only tag so another node can reference this one via `{ $ref: ref }`. Stripped before send. */
|
|
12
|
+
ref?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ColumnRowNode extends BloksNodeBase {
|
|
15
|
+
component: 'Column' | 'Row';
|
|
16
|
+
weight?: number;
|
|
17
|
+
justify?: string;
|
|
18
|
+
children?: BloksNode[];
|
|
19
|
+
}
|
|
20
|
+
export interface TextNode extends BloksNodeBase {
|
|
21
|
+
component: 'Text';
|
|
22
|
+
text: string;
|
|
23
|
+
variant?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IconNode extends BloksNodeBase {
|
|
26
|
+
component: 'Icon';
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
export interface DividerNode extends BloksNodeBase {
|
|
30
|
+
component: 'Divider';
|
|
31
|
+
}
|
|
32
|
+
export interface ImageNode extends BloksNodeBase {
|
|
33
|
+
component: 'Image';
|
|
34
|
+
url: string;
|
|
35
|
+
variant?: string;
|
|
36
|
+
fit?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface VideoNode extends BloksNodeBase {
|
|
39
|
+
component: 'Video';
|
|
40
|
+
url: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ListNode extends BloksNodeBase {
|
|
43
|
+
component: 'List';
|
|
44
|
+
children?: BloksNode[];
|
|
45
|
+
}
|
|
46
|
+
export interface TextFieldNode extends BloksNodeBase {
|
|
47
|
+
component: 'TextField';
|
|
48
|
+
label?: string;
|
|
49
|
+
value?: string;
|
|
50
|
+
variant?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface DateTimeInputNode extends BloksNodeBase {
|
|
53
|
+
component: 'DateTimeInput';
|
|
54
|
+
label?: string;
|
|
55
|
+
value?: string;
|
|
56
|
+
enableDate?: boolean;
|
|
57
|
+
enableTime?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface SliderNode extends BloksNodeBase {
|
|
60
|
+
component: 'Slider';
|
|
61
|
+
label?: string;
|
|
62
|
+
min?: number;
|
|
63
|
+
max?: number;
|
|
64
|
+
value?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface SwitchNode extends BloksNodeBase {
|
|
67
|
+
component: 'Switch';
|
|
68
|
+
label?: string;
|
|
69
|
+
value?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface CheckBoxNode extends BloksNodeBase {
|
|
72
|
+
component: 'CheckBox';
|
|
73
|
+
label?: string;
|
|
74
|
+
value?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface ChoicePickerNode extends BloksNodeBase {
|
|
77
|
+
component: 'ChoicePicker';
|
|
78
|
+
label?: string;
|
|
79
|
+
variant?: string;
|
|
80
|
+
displayStyle?: string;
|
|
81
|
+
options?: Array<{ label: string; value: string }>;
|
|
82
|
+
value?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Unlike the CTA/native-flow `Button` class elsewhere, an A2UI Button node has no
|
|
86
|
+
* `label`/`type`+`name` โ its label comes from a nested `child` (usually a `Text` node), and
|
|
87
|
+
* tapping it fires `action.call` (with `action.args`), not a native-flow button name.
|
|
88
|
+
*/
|
|
89
|
+
export interface BloksButtonNode extends BloksNodeBase {
|
|
90
|
+
component: 'Button';
|
|
91
|
+
child?: BloksNode;
|
|
92
|
+
variant?: string;
|
|
93
|
+
action?: { call: string; args?: Record<string, any> };
|
|
94
|
+
}
|
|
95
|
+
export interface ModalNode extends BloksNodeBase {
|
|
96
|
+
component: 'Modal';
|
|
97
|
+
trigger: string | BloksRef;
|
|
98
|
+
content: BloksNode | string | BloksRef;
|
|
99
|
+
}
|
|
100
|
+
export interface TabsNode extends BloksNodeBase {
|
|
101
|
+
component: 'Tabs';
|
|
102
|
+
tabs: Array<{ title: string; child: BloksNode }>;
|
|
103
|
+
}
|
|
104
|
+
export interface CardNode extends BloksNodeBase {
|
|
105
|
+
component: 'Card';
|
|
106
|
+
child?: BloksNode;
|
|
107
|
+
}
|
|
108
|
+
export interface ProgressBarNode extends BloksNodeBase {
|
|
109
|
+
component: 'ProgressBar';
|
|
110
|
+
value?: number;
|
|
111
|
+
min?: number;
|
|
112
|
+
max?: number;
|
|
113
|
+
variant?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface AvatarNode extends BloksNodeBase {
|
|
116
|
+
component: 'Avatar';
|
|
117
|
+
url?: string;
|
|
118
|
+
variant?: string;
|
|
119
|
+
size?: number;
|
|
120
|
+
}
|
|
121
|
+
export interface BadgeNode extends BloksNodeBase {
|
|
122
|
+
component: 'Badge';
|
|
123
|
+
child?: string | BloksNode;
|
|
124
|
+
label?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface SpacerNode extends BloksNodeBase {
|
|
127
|
+
component: 'Spacer';
|
|
128
|
+
height?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface AudioPlayerNode extends BloksNodeBase {
|
|
131
|
+
component: 'AudioPlayer';
|
|
132
|
+
url: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
}
|
|
135
|
+
/** Fallback for components not yet confirmed on the wire โ still works at runtime, just no prop-level autocomplete. */
|
|
136
|
+
export interface AnyBloksNode extends BloksNodeBase {
|
|
137
|
+
component: string;
|
|
138
|
+
[key: string]: any;
|
|
139
|
+
}
|
|
140
|
+
export type BloksNode =
|
|
141
|
+
| ColumnRowNode
|
|
142
|
+
| TextNode
|
|
143
|
+
| IconNode
|
|
144
|
+
| DividerNode
|
|
145
|
+
| ImageNode
|
|
146
|
+
| VideoNode
|
|
147
|
+
| ListNode
|
|
148
|
+
| TextFieldNode
|
|
149
|
+
| DateTimeInputNode
|
|
150
|
+
| SliderNode
|
|
151
|
+
| SwitchNode
|
|
152
|
+
| CheckBoxNode
|
|
153
|
+
| ChoicePickerNode
|
|
154
|
+
| BloksButtonNode
|
|
155
|
+
| ModalNode
|
|
156
|
+
| TabsNode
|
|
157
|
+
| CardNode
|
|
158
|
+
| ProgressBarNode
|
|
159
|
+
| AvatarNode
|
|
160
|
+
| BadgeNode
|
|
161
|
+
| SpacerNode
|
|
162
|
+
| AudioPlayerNode
|
|
163
|
+
| AnyBloksNode;
|
|
164
|
+
|
|
165
|
+
export interface A2UIBuilderOptions {
|
|
166
|
+
catalogId?: string;
|
|
167
|
+
version?: string;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface A2UIBuildOptions {
|
|
171
|
+
uuid?: string;
|
|
172
|
+
surfaceId?: string;
|
|
173
|
+
type?: string;
|
|
174
|
+
wrapped?: boolean;
|
|
175
|
+
/** Run assertValid() before serialising (default true). */
|
|
176
|
+
validate?: boolean;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface A2UIBuildResult {
|
|
180
|
+
uuid: string;
|
|
181
|
+
data: string;
|
|
182
|
+
type: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface ListCardOptions {
|
|
186
|
+
title?: string;
|
|
187
|
+
items?: any[];
|
|
188
|
+
fallbackText?: string;
|
|
189
|
+
uuid?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface SendA2UIWidgetOptions {
|
|
193
|
+
a2ui: A2UI;
|
|
194
|
+
bodyText?: string;
|
|
195
|
+
footer?: string;
|
|
196
|
+
buttons?: any[];
|
|
197
|
+
contextInfo?: Record<string, any>;
|
|
198
|
+
expiration?: number;
|
|
199
|
+
quoted?: any;
|
|
200
|
+
type?: string;
|
|
201
|
+
wrapped?: boolean;
|
|
202
|
+
singleScreen?: boolean;
|
|
203
|
+
header?: {
|
|
204
|
+
title?: string;
|
|
205
|
+
subtitle?: string;
|
|
206
|
+
image?: string | Buffer | { url: string };
|
|
207
|
+
video?: string | Buffer | { url: string };
|
|
208
|
+
document?: string | Buffer | { url: string };
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* A2UI/Bloks widget builder.
|
|
214
|
+
*
|
|
215
|
+
* JAP@Fix (ยง2.37 / v2.4.7): this block previously documented the class as "fluent" and typed
|
|
216
|
+
* every component factory as returning `this`. At runtime they return the generated component
|
|
217
|
+
* **id string** (siblings reference each other by id -- that's the whole point of the API), so
|
|
218
|
+
* `ui.text('a').text('b')` type-checked and then died with "ui.text(...).text is not a function",
|
|
219
|
+
* while the correct `const id = ui.text('a')` was flagged as a type error. Factories are typed
|
|
220
|
+
* `string` now; only the terminal/config methods (root/listCard/setVersion/...) chain.
|
|
221
|
+
*/
|
|
222
|
+
export class A2UI {
|
|
223
|
+
constructor(options?: A2UIBuilderOptions);
|
|
224
|
+
text(text: string, options?: { id?: string; variant?: string }): string;
|
|
225
|
+
image(url: string, options?: { id?: string; variant?: string; fit?: string }): string;
|
|
226
|
+
video(url: string, options?: { id?: string }): string;
|
|
227
|
+
checkbox(label: string, options?: { id?: string; value?: boolean }): string;
|
|
228
|
+
textField(label: string, options?: { id?: string; variant?: string }): string;
|
|
229
|
+
button(childId: string, options?: { id?: string; variant?: string; action?: { call: string; args?: Record<string, any> } }): string;
|
|
230
|
+
card(childId: string, options?: { id?: string }): string;
|
|
231
|
+
modal(triggerId: string, contentId: string, options?: { id?: string }): string;
|
|
232
|
+
raw(component: string, props?: Record<string, any>, options?: { id?: string }): string;
|
|
233
|
+
column(children?: string[], options?: { id?: string }): string;
|
|
234
|
+
row(children?: string[], options?: { id?: string }): string;
|
|
235
|
+
divider(options?: { id?: string }): string;
|
|
236
|
+
slider(options?: { id?: string; value?: number; min?: number; max?: number; step?: number; label?: string }): string;
|
|
237
|
+
switch(label: string, options?: { id?: string; value?: boolean }): string;
|
|
238
|
+
list(children?: string[], options?: { id?: string }): string;
|
|
239
|
+
progressBar(value: number, options?: { id?: string; min?: number; max?: number; variant?: string }): string;
|
|
240
|
+
avatar(url: string, options?: { id?: string; variant?: string; size?: number }): string;
|
|
241
|
+
badge(childId: string, options?: { id?: string; label?: string }): string;
|
|
242
|
+
spacer(options?: { id?: string; height?: number }): string;
|
|
243
|
+
tabs(children?: string[], options?: { id?: string; activeTab?: number }): string;
|
|
244
|
+
choicePicker(label: string, options: Array<{ label: string; value: string }>, opts?: { id?: string; variant?: string; value?: string; displayStyle?: string; filterable?: boolean }): string;
|
|
245
|
+
root(children: string[]): this;
|
|
246
|
+
listCard(options?: ListCardOptions): this;
|
|
247
|
+
send(client: any, jid: string, opts?: Record<string, any>): Promise<any>;
|
|
248
|
+
/** Whether `id` was registered on this instance. */
|
|
249
|
+
has(id: string): boolean;
|
|
250
|
+
/** A copy of the registered component node. */
|
|
251
|
+
get(id: string): Record<string, any> | undefined;
|
|
252
|
+
/** Every registered component id, in registration order. */
|
|
253
|
+
ids(): string[];
|
|
254
|
+
/** How many components are registered (excluding the implicit root). */
|
|
255
|
+
count(): number;
|
|
256
|
+
/** Unregister one component; returns whether it existed. */
|
|
257
|
+
remove(id: string): boolean;
|
|
258
|
+
/** Drop every component, the root selection and any listCard payload. */
|
|
259
|
+
clear(): this;
|
|
260
|
+
/** Override the catalog url used in `createSurface.catalogId`. */
|
|
261
|
+
setCatalogId(catalogId: string): this;
|
|
262
|
+
/** Override the A2UI spec version stamped on the payload. */
|
|
263
|
+
setVersion(version: string): this;
|
|
264
|
+
/** Registered components nothing references -- encoded but never rendered. */
|
|
265
|
+
findOrphans(): string[];
|
|
266
|
+
/** Every structural problem; empty when the widget is safe to build. */
|
|
267
|
+
validate(): string[];
|
|
268
|
+
/** Throw on the first structural problem. */
|
|
269
|
+
assertValid(): this;
|
|
270
|
+
/** Validates refs, then returns the serialised widget payload. Call root() first (unless listCard()). */
|
|
271
|
+
build(options?: A2UIBuildOptions): A2UIBuildResult;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Build + send an A2UI/Bloks widget as an interactiveMessage. */
|
|
275
|
+
export declare const sendA2UIWidget: (client: any, jid: string, options?: SendA2UIWidgetOptions) => Promise<any>;
|