@kyyinfinite/zapo-message 0.0.0-stage → 1.0.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/CHANGELOG.md +159 -0
- package/LICENSE +20 -0
- package/README.md +532 -2
- package/build.config.json +28 -0
- package/dist/airich/airich.d.ts +180 -0
- package/dist/airich/airich.js +548 -0
- package/dist/airich/context.d.ts +24 -0
- package/dist/airich/context.js +48 -0
- package/dist/airich/encode.d.ts +3 -0
- package/dist/airich/encode.js +16 -0
- package/dist/airich/index.d.ts +20 -0
- package/dist/airich/index.js +11 -0
- package/dist/airich/inline.d.ts +45 -0
- package/dist/airich/inline.js +152 -0
- package/dist/airich/nodes.d.ts +30 -0
- package/dist/airich/nodes.js +121 -0
- package/dist/airich/primitives.d.ts +144 -0
- package/dist/airich/primitives.js +230 -0
- package/dist/airich/protocol.d.ts +35 -0
- package/dist/airich/protocol.js +65 -0
- package/dist/airich/table.d.ts +22 -0
- package/dist/airich/table.js +35 -0
- package/dist/airich/tokenizer.d.ts +13 -0
- package/dist/airich/tokenizer.js +717 -0
- package/dist/airich/transport.d.ts +15 -0
- package/dist/airich/transport.js +56 -0
- package/dist/branding.d.ts +5 -0
- package/dist/branding.js +9 -0
- package/dist/btn/builders.d.ts +246 -0
- package/dist/btn/builders.js +710 -0
- package/dist/btn/media-slot.d.ts +28 -0
- package/dist/btn/media-slot.js +323 -0
- package/dist/btn/media-source.d.ts +38 -0
- package/dist/btn/media-source.js +116 -0
- package/dist/btn/sharp-loader.d.ts +5 -0
- package/dist/btn/sharp-loader.js +18 -0
- package/dist/btn/thumbnail.d.ts +21 -0
- package/dist/btn/thumbnail.js +124 -0
- package/dist/btn/validators.d.ts +40 -0
- package/dist/btn/validators.js +135 -0
- package/dist/btn.d.ts +1 -0
- package/dist/btn.js +1 -0
- package/dist/core/async-send.d.ts +20 -0
- package/dist/core/async-send.js +1 -0
- package/dist/core/base-builder.d.ts +20 -0
- package/dist/core/base-builder.js +67 -0
- package/dist/core/errors.d.ts +30 -0
- package/dist/core/errors.js +61 -0
- package/dist/download.d.ts +24 -0
- package/dist/download.js +123 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +22 -0
- package/dist/integration/augment.d.ts +97 -0
- package/dist/integration/augment.js +1 -0
- package/dist/integration/auto.d.ts +8 -0
- package/dist/integration/auto.js +79 -0
- package/dist/integration/index.d.ts +4 -0
- package/dist/integration/index.js +2 -0
- package/dist/integration/methods.d.ts +25 -0
- package/dist/integration/methods.js +24 -0
- package/dist/interactive.d.ts +24 -0
- package/dist/interactive.js +121 -0
- package/dist/media-gate.d.ts +99 -0
- package/dist/media-gate.js +322 -0
- package/dist/message/album.d.ts +33 -0
- package/dist/message/album.js +107 -0
- package/dist/message/contact.d.ts +29 -0
- package/dist/message/contact.js +123 -0
- package/dist/message/forward.d.ts +23 -0
- package/dist/message/forward.js +77 -0
- package/dist/message/index.d.ts +26 -0
- package/dist/message/index.js +13 -0
- package/dist/message/link-preview.d.ts +28 -0
- package/dist/message/link-preview.js +98 -0
- package/dist/message/location.d.ts +24 -0
- package/dist/message/location.js +94 -0
- package/dist/message/media.d.ts +90 -0
- package/dist/message/media.js +123 -0
- package/dist/message/poll.d.ts +24 -0
- package/dist/message/poll.js +98 -0
- package/dist/message/reaction.d.ts +20 -0
- package/dist/message/reaction.js +71 -0
- package/dist/message/sticker.d.ts +29 -0
- package/dist/message/sticker.js +44 -0
- package/dist/message/target.d.ts +18 -0
- package/dist/message/target.js +24 -0
- package/dist/message/text.d.ts +17 -0
- package/dist/message/text.js +29 -0
- package/dist/message/vcard.d.ts +9 -0
- package/dist/message/vcard.js +23 -0
- package/dist/message/webp.d.ts +6 -0
- package/dist/message/webp.js +57 -0
- package/dist/payloads.d.ts +180 -0
- package/dist/payloads.js +1 -0
- package/dist/serialize.d.ts +41 -0
- package/dist/serialize.js +93 -0
- package/dist/status.d.ts +3 -0
- package/dist/status.js +21 -0
- package/dist/zapo-client.d.ts +44 -0
- package/dist/zapo-client.js +1 -0
- package/examples/airich.ts +59 -0
- package/examples/buttons.ts +48 -0
- package/examples/client-methods.ts +58 -0
- package/examples/hybrid.ts +133 -0
- package/examples/serialize.ts +61 -0
- package/package.json +271 -4
- package/scripts/check-no-comments.mjs +101 -0
- package/scripts/compare-golden.mjs +461 -0
- package/scripts/lib-config.mjs +9 -0
- package/scripts/smoke-auto.mjs +75 -0
- package/scripts/test-external-consumer.mjs +316 -0
- package/scripts/verify-package.mjs +78 -0
- package/src/airich/airich.ts +970 -0
- package/src/airich/context.ts +96 -0
- package/src/airich/encode.ts +25 -0
- package/src/airich/index.ts +98 -0
- package/src/airich/inline.ts +272 -0
- package/src/airich/nodes.ts +174 -0
- package/src/airich/primitives.ts +474 -0
- package/src/airich/protocol.ts +133 -0
- package/src/airich/table.ts +70 -0
- package/src/airich/tokenizer.ts +799 -0
- package/src/airich/transport.ts +106 -0
- package/src/branding.ts +23 -0
- package/src/btn/builders.ts +1073 -0
- package/src/btn/media-slot.ts +486 -0
- package/src/btn/media-source.ts +189 -0
- package/src/btn/sharp-loader.ts +23 -0
- package/src/btn/thumbnail.ts +182 -0
- package/src/btn/validators.ts +237 -0
- package/src/btn.ts +8 -0
- package/src/core/async-send.ts +28 -0
- package/src/core/base-builder.ts +104 -0
- package/src/core/errors.ts +82 -0
- package/src/download.ts +212 -0
- package/src/index.ts +229 -0
- package/src/integration/augment.ts +262 -0
- package/src/integration/auto.ts +103 -0
- package/src/integration/index.ts +8 -0
- package/src/integration/methods.ts +45 -0
- package/src/interactive.ts +188 -0
- package/src/media-gate.ts +499 -0
- package/src/message/album.ts +187 -0
- package/src/message/contact.ts +170 -0
- package/src/message/forward.ts +123 -0
- package/src/message/index.ts +83 -0
- package/src/message/link-preview.ts +148 -0
- package/src/message/location.ts +150 -0
- package/src/message/media.ts +323 -0
- package/src/message/poll.ts +158 -0
- package/src/message/reaction.ts +133 -0
- package/src/message/sticker.ts +100 -0
- package/src/message/target.ts +38 -0
- package/src/message/text.ts +61 -0
- package/src/message/vcard.ts +36 -0
- package/src/message/webp.ts +78 -0
- package/src/payloads.ts +204 -0
- package/src/serialize.ts +180 -0
- package/src/status.ts +29 -0
- package/src/zapo-client.ts +84 -0
- package/test/airich-inline.test.ts +200 -0
- package/test/airich-primitives.test.ts +226 -0
- package/test/airich-tokenizer.test.ts +145 -0
- package/test/airich.golden.test.ts +406 -0
- package/test/airich.test.ts +1006 -0
- package/test/btn-button.test.ts +416 -0
- package/test/btn-header.test.ts +646 -0
- package/test/btn-legacy.test.ts +342 -0
- package/test/btn-lifecycle.test.ts +295 -0
- package/test/btn-list.test.ts +261 -0
- package/test/btn-media-source.test.ts +150 -0
- package/test/btn-thumbnail.test.ts +160 -0
- package/test/builder-compat.test.ts +264 -0
- package/test/helpers.ts +27 -0
- package/test/hybrid-airich.test.ts +345 -0
- package/test/hybrid-client.test.ts +239 -0
- package/test/hybrid-errors.test.ts +557 -0
- package/test/hybrid-interactive.test.ts +455 -0
- package/test/hybrid.golden.test.ts +349 -0
- package/test/hybrid.test.ts +479 -0
- package/test/integration-auto.test.ts +159 -0
- package/test/integration.fakeserver.test.ts +440 -0
- package/test/media-gate.test.ts +215 -0
- package/test/message-album.test.ts +145 -0
- package/test/message-builders.test.ts +401 -0
- package/test/message-media.test.ts +303 -0
- package/test/message.fakeserver.test.ts +284 -0
- package/test/message.golden.test.ts +254 -0
- package/test/serializer.test.ts +448 -0
- package/tsconfig.json +26 -0
- package/tsconfig.test.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.2.0 — Complete Hybrid API
|
|
4
|
+
|
|
5
|
+
Versi minor: hanya tambahan aditif; seluruh API 1.1.0 dipertahankan
|
|
6
|
+
(lihat `docs/API_COMPATIBILITY.md`). Prinsip: satu jenis pesan = dua gaya pemanggilan
|
|
7
|
+
(object async + fluent chain) = satu implementasi bersama.
|
|
8
|
+
|
|
9
|
+
### Hybrid API (object async)
|
|
10
|
+
|
|
11
|
+
- Semua method client/factory kini overload: `client.text(jid, config, options?)`
|
|
12
|
+
mengirim langsung dan mengembalikan `Promise<MessageSendResult>`;
|
|
13
|
+
`client.text()` tetap mengembalikan builder chain.
|
|
14
|
+
- Config bertipe untuk seluruh jenis pesan: `TextConfig`, `LinkPreviewConfig`,
|
|
15
|
+
`MediaConfig` (discriminated union image/video/audio/document), `ImageMessageConfig`
|
|
16
|
+
(+ `Video`/`Audio`/`Document`), `StickerConfig`, `ContactConfig`, `PollConfig`,
|
|
17
|
+
`ReactionConfig`, `ForwardConfig`, `AlbumConfig`, `LocationConfig`, `ButtonConfig`
|
|
18
|
+
(seluruh primitive: quick_reply, cta_url, cta_copy, cta_call, send_location,
|
|
19
|
+
single_select, bottomSheet, limitedTimeOffer, semua header), `LegacyButtonConfig`,
|
|
20
|
+
`ListMessageConfig`, dan `AIRichConfig` (15 primitive + raw + footer + context + quote).
|
|
21
|
+
- Bentuk async dieksekusi lewat builder yang sama (validasi, payload, transport, error
|
|
22
|
+
identik) — suite parity 76 test + 14 golden async membuktikannya.
|
|
23
|
+
|
|
24
|
+
### Builder & fitur baru
|
|
25
|
+
|
|
26
|
+
- `client.location()` — standalone location (`locationMessage` proto, payload sama
|
|
27
|
+
dengan header location interaktif).
|
|
28
|
+
- `client.image()/video()/audio()/document()` — fasad convenience atas engine
|
|
29
|
+
`MediaBuilder` yang sama (satu pipeline upload, tanpa duplikasi).
|
|
30
|
+
- `BaseBuilder.to(jid)` — alias ramah untuk `defaultTo(jid)`.
|
|
31
|
+
- `MessageSendOptions` (quote, mentions, contextInfo, forward, id, expirationSeconds,
|
|
32
|
+
additionalAttributes, viewOnce, messageSecret, opsi publish) dan `AIRichSendOptions`
|
|
33
|
+
(twoStep, submessages) — hanya field yang terverifikasi di `WaSendMessageOptions`
|
|
34
|
+
zapo-js 1.11.0.
|
|
35
|
+
- `MessageSendResult` kini diekspor dari root.
|
|
36
|
+
|
|
37
|
+
### Perbaikan
|
|
38
|
+
|
|
39
|
+
- `ListMessage.send()` tanpa jid kini memakai target `defaultTo()`/`to()` dan melempar
|
|
40
|
+
`NO_TARGET` yang konsisten (sebelumnya crash `isGroupJid(undefined)` dari zapo-js).
|
|
41
|
+
|
|
42
|
+
### Integrasi
|
|
43
|
+
|
|
44
|
+
- Method yang dipasang otomatis: 13 -> 18 (`image`, `video`, `audio`, `document`,
|
|
45
|
+
`location`); augmentation `WaClient` memuat overload chain + async.
|
|
46
|
+
- Subpath exports baru: `./core/async-send.js`, `./message/location.js`.
|
|
47
|
+
- `verify:package` / `verify:consumer` tidak lagi meng-hardcode versi tarball.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 1.1.0 — Restructuring & Developer Experience
|
|
51
|
+
|
|
52
|
+
Package identity berpindah ke `@kyyinfinite/zapo-message` (pengganti `zapo-message` 1.0.0;
|
|
53
|
+
API lama 100% dipertahankan — lihat `docs/MIGRATION.md`). Versi minor: tidak ada
|
|
54
|
+
breaking change terhadap API publik 1.0.0.
|
|
55
|
+
|
|
56
|
+
### Automatic client integration
|
|
57
|
+
|
|
58
|
+
- `import "@kyyinfinite/zapo-message"` memasang 13 method builder di `WaClient` zapo-js:
|
|
59
|
+
`button()`, `legacyButton()`, `listMessage()`, `airich(options?)`, `text()`,
|
|
60
|
+
`reaction()`, `media()`, `sticker()`, `contact()`, `poll()`, `album()`,
|
|
61
|
+
`linkPreview()`, `forward()`.
|
|
62
|
+
- Prototype patch idempoten (symbol guard `Symbol.for`), non-enumerable, tidak pernah
|
|
63
|
+
menimpa method bawaan, dan menjangkau build ESM maupun CJS zapo-js (import statis +
|
|
64
|
+
fallback `createRequire`).
|
|
65
|
+
- Declaration merging `declare module "zapo-js"` — semua method baru ter-typed untuk
|
|
66
|
+
konsumen TypeScript tanpa konfigurasi apa pun.
|
|
67
|
+
- `installZapoMessage(client)` untuk instalasi manual per-instance (client duck-typed,
|
|
68
|
+
lingkungan bundler).
|
|
69
|
+
- `zapoMessageMethods`, `ZAPO_MESSAGE_METHOD_NAMES`, `autoInstallStatus()` diekspor
|
|
70
|
+
untuk introspeksi dan pengujian.
|
|
71
|
+
|
|
72
|
+
### Builder pesan baru (src/message/)
|
|
73
|
+
|
|
74
|
+
- `text()` — payload `{ conversation }`, paritas dengan normalisasi string zapo-js.
|
|
75
|
+
- `linkPreview()` — `extendedTextMessage` dengan `matchedText`/`previewType`/`title`/
|
|
76
|
+
`description`/`jpegThumbnail` (field set mengikuti `buildExtendedTextWithPreview`
|
|
77
|
+
zapo-js; tanpa fetch jaringan).
|
|
78
|
+
- `reaction()` — input terketik `{ type: "reaction", emoji, target }`; konstruksi
|
|
79
|
+
`reactionMessage` didelegasikan ke zapo-js (`buildReactionMessage`), target berupa
|
|
80
|
+
event pesan masuk atau message key; jid tujuan turun dari target.
|
|
81
|
+
- `forward()` — mengirim ulang konten pesan sumber dengan opsi `forward` (skor
|
|
82
|
+
`forwardingScore` sumber diteruskan agar badge "sering diteruskan" tetap benar).
|
|
83
|
+
- `media()` — image/video/audio/document lewat pipeline media slot: sniffing mimetype
|
|
84
|
+
(file-type), upload `client.message.upload` (termasuk tipe `ptt` untuk voice note),
|
|
85
|
+
proto field lengkap (`imageMessage`/`videoMessage`/`audioMessage`/`documentMessage`).
|
|
86
|
+
- `sticker()` — `stickerMessage` dari sumber WebP; parser header container WebP
|
|
87
|
+
(`probeWebp`) membaca dimensi (VP8X/VP8/VP8L) dan status animasi (chunk ANIM) tanpa
|
|
88
|
+
dependensi; `pngThumbnail` otomatis bila sharp tersedia.
|
|
89
|
+
- `contact()` — `contactMessage` dengan pembangkit vCard 3.0 (`buildVcard`) atau
|
|
90
|
+
vCard mentah; escape karakter khusus.
|
|
91
|
+
- `poll()` — input terketik `{ type: "poll", ... }`; pemilihan varian proto
|
|
92
|
+
(V3/V6/klasik) didelegasikan ke zapo-js.
|
|
93
|
+
- `album()` — `albumMessage` (`expectedImageCount`/`expectedVideoCount`) lalu tiap
|
|
94
|
+
media dikirim mengutip id album (mekanisme quote standar). Alur multi-pesan
|
|
95
|
+
eksperimental — dokumentasi lengkap di `docs/PROTOCOL_TRACEABILITY.md`.
|
|
96
|
+
|
|
97
|
+
### Dependency strategy
|
|
98
|
+
|
|
99
|
+
- `sharp` berpindah dari dependency wajib ke peer dependency opsional
|
|
100
|
+
(`peerDependenciesMeta.optional`). Dengan sharp: perilaku identik dengan 1.0.0.
|
|
101
|
+
Tanpa sharp: fitur inti tetap jalan; jalur yang membutuhkannya gagal dengan pesan
|
|
102
|
+
error yang menyebut cara menginstal. Lazy-load `src/btn/sharp-loader.ts`.
|
|
103
|
+
- `file-type` tetap dependency wajib (ringan, tanpa native binding).
|
|
104
|
+
|
|
105
|
+
### Engineering
|
|
106
|
+
|
|
107
|
+
- 90 test baru: unit builder, golden payload, integrasi auto-install (multi-client,
|
|
108
|
+
idempotensi, non-override, non-extensible, properti instance), dan satu suite
|
|
109
|
+
integrasi fake-server yang memverifikasi text/reaction/poll/contact/linkPreview/
|
|
110
|
+
sticker/album/forward sampai level stanza terdekripsi di peer.
|
|
111
|
+
- External consumer verification diperluas: import side-effect + augmentation TS di
|
|
112
|
+
proyek konsumen nyata tanpa sharp terpasang.
|
|
113
|
+
- Subpath exports baru: `message/*`, `integration/*`, `btn/sharp-loader.js`.
|
|
114
|
+
|
|
115
|
+
## 1.0.0 — Initial Release
|
|
116
|
+
|
|
117
|
+
First standalone release of the Avelyna message library as `zapo-message`.
|
|
118
|
+
|
|
119
|
+
### Extracted from Avelyna with behavior parity
|
|
120
|
+
|
|
121
|
+
- BTN subsystem: `Button` (native flow: quick reply, URL/copy/call CTA, send location, single
|
|
122
|
+
select, bottom sheet, limited-time offer, interactive headers with media/location/thumbnail),
|
|
123
|
+
`LegacyButton` (ButtonsMessage with IMAGE/VIDEO/DOCUMENT/TEXT/LOCATION/EMPTY headers),
|
|
124
|
+
`ListMessage` (classic list with auto/native/never fallback in `send()`), media slot upload
|
|
125
|
+
pipeline with thumbnail generation and mimetype sniffing, and the full validator set with the
|
|
126
|
+
original limits.
|
|
127
|
+
- AIRich subsystem: text/code/table/suggest/metadata/tip content, inline hyperlink/citation/latex
|
|
128
|
+
entities, experimental primitives (source/image/video/footerAction/widget/product/post/reels/html),
|
|
129
|
+
node store operations (raw/replace/insert/insertAt/remove/clear), payload loading, contextInfo
|
|
130
|
+
allowlist, placeholder + protocol-edit (type 14) construction, and the two-step
|
|
131
|
+
placeholder-then-edit transport.
|
|
132
|
+
- Serialization: `mSerialize`/`qSerialize` with hidden client, reply/react/download helpers;
|
|
133
|
+
`extractInteractiveResponse` for buttons/list/template/native-flow shapes;
|
|
134
|
+
`inspectInteractiveContext` advisory metadata.
|
|
135
|
+
- Media download helpers (`mDownload`, `qDownload`, thumbnail fallback) and status formatting
|
|
136
|
+
(`formatStatus`, `toBoldSans`).
|
|
137
|
+
|
|
138
|
+
### Avelyna decoupling
|
|
139
|
+
|
|
140
|
+
- Media admission control ported as a standalone gate (`zapo-message/media-gate.js`) with identical
|
|
141
|
+
API, defaults, and environment variables.
|
|
142
|
+
- Fake-quoted branding replaced by an optional injected provider
|
|
143
|
+
(`zapo-message/branding.js`).
|
|
144
|
+
- `send-plugin.js` stays in Avelyna (plugin-runtime specific).
|
|
145
|
+
|
|
146
|
+
### Engineering
|
|
147
|
+
|
|
148
|
+
- Strict TypeScript (`strict`, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`,
|
|
149
|
+
`noImplicitOverride`, `useUnknownInCatchVariables`), ESM output with generated declarations.
|
|
150
|
+
- Zero comments across all source, test, and example files (enforced by
|
|
151
|
+
`scripts/check-no-comments.mjs` using the TypeScript scanner).
|
|
152
|
+
- Ported test suites plus a ZapoJS fake-server integration suite, golden payload comparison
|
|
153
|
+
against the original JavaScript implementation (25/25 match), external consumer verification,
|
|
154
|
+
and package content verification.
|
|
155
|
+
|
|
156
|
+
### Compatibility
|
|
157
|
+
|
|
158
|
+
- Peer dependency: `zapo-js >=1.11.0 <2.0.0` (tested against exactly 1.11.0).
|
|
159
|
+
- Node.js `>= 20.9.0`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kyyinfinite (Avelyna)
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
12
|
+
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
17
|
+
This package is a standalone extraction of the message library of the
|
|
18
|
+
Avelyna project (https://github.com/kyyinfinite/avelyna), which is
|
|
19
|
+
distributed under the ISC license. The ISC license permits reuse and
|
|
20
|
+
redistribution with the copyright notice preserved, as done here.
|