@kyyinfinite/zapo-message 0.0.0-stage → 1.0.1
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 +1401 -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 +36 -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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"noComments": {
|
|
3
|
+
"include": ["src/**/*.ts", "test/**/*.ts", "examples/**/*.ts"],
|
|
4
|
+
"allowUrlsInStrings": true,
|
|
5
|
+
"allowStringsStartingWithSlashSlashOrSlashStar": true
|
|
6
|
+
},
|
|
7
|
+
"package": {
|
|
8
|
+
"allowedTopLevel": [
|
|
9
|
+
"src",
|
|
10
|
+
"test",
|
|
11
|
+
"examples",
|
|
12
|
+
"docs",
|
|
13
|
+
"scripts",
|
|
14
|
+
"dist",
|
|
15
|
+
"package.json",
|
|
16
|
+
"tsconfig.json",
|
|
17
|
+
"tsconfig.test.json",
|
|
18
|
+
"build.config.json",
|
|
19
|
+
"README.md",
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"consumer": {
|
|
25
|
+
"nodeModulesCopy": ["zapo-js"],
|
|
26
|
+
"compileFile": "consumer-entry.ts"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { Proto } from "zapo-js";
|
|
2
|
+
import { BaseBuilder, type SendResolutionArg } from "../core/base-builder.js";
|
|
3
|
+
import { type MessageSendOptions } from "../core/async-send.js";
|
|
4
|
+
import type { MessageSendResult } from "../zapo-client.js";
|
|
5
|
+
import type { SubmessagePayload, WrapBotForwardedResult, PlaceholderBuildResult, EditBuildResult } from "../payloads.js";
|
|
6
|
+
import type { ZapoClient } from "../zapo-client.js";
|
|
7
|
+
import { type ParseInlineOptions } from "./inline.js";
|
|
8
|
+
import { type AllowedContextInfo } from "./context.js";
|
|
9
|
+
import { type UnifiedResponseSection } from "./protocol.js";
|
|
10
|
+
import { type SourceInput, type ImageSectionOptions, type VideoSectionOptions, type FooterActionItem, type WidgetItem, type ProductItem, type PostItem, type ReelsItem, type SectionLayoutOptions, type HtmlSectionOptions } from "./primitives.js";
|
|
11
|
+
export interface AIRichConstructorOptions {
|
|
12
|
+
botJid?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface RawNodeOptions {
|
|
15
|
+
id?: string | null | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface InsertNodeOptions extends RawNodeOptions {
|
|
18
|
+
after?: boolean | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface QuotableMessage {
|
|
21
|
+
key?: {
|
|
22
|
+
id?: string;
|
|
23
|
+
participant?: string;
|
|
24
|
+
remoteJid?: string;
|
|
25
|
+
};
|
|
26
|
+
id?: string;
|
|
27
|
+
message?: Proto.IMessage | Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export type RichTarget = string | number;
|
|
30
|
+
export declare class AIRich extends BaseBuilder {
|
|
31
|
+
#private;
|
|
32
|
+
constructor(client?: ZapoClient, { botJid }?: AIRichConstructorOptions);
|
|
33
|
+
get lastId(): string | null;
|
|
34
|
+
get size(): number;
|
|
35
|
+
ids(): string[];
|
|
36
|
+
has(id: string): boolean;
|
|
37
|
+
pendingEdit(jid: string): string | null;
|
|
38
|
+
raw(section: UnifiedResponseSection, submessage?: SubmessagePayload, { id }?: RawNodeOptions): this;
|
|
39
|
+
replace(target: RichTarget, section: UnifiedResponseSection, submessage?: SubmessagePayload, { id }?: RawNodeOptions): this;
|
|
40
|
+
insert(target: RichTarget, section: UnifiedResponseSection, submessage?: SubmessagePayload, { id, after }?: InsertNodeOptions): this;
|
|
41
|
+
insertAt(index: number, section: UnifiedResponseSection, submessage?: SubmessagePayload, { id }?: RawNodeOptions): this;
|
|
42
|
+
loadPayload(payload: unknown): this;
|
|
43
|
+
text(text: string, { id, hyperlink, citation, latex, }?: RawNodeOptions & ParseInlineOptions): this;
|
|
44
|
+
code(language: string, code: string, { id }?: RawNodeOptions): this;
|
|
45
|
+
table(rows: string[][], { id, hyperlink, citation, latex, }?: RawNodeOptions & ParseInlineOptions): this;
|
|
46
|
+
metadata(text: string, { id }?: RawNodeOptions): this;
|
|
47
|
+
tip(text: string, { id }?: RawNodeOptions): this;
|
|
48
|
+
suggest(items: string | string[], { id, scroll, layout: layoutName, }?: {
|
|
49
|
+
id?: string | null | undefined;
|
|
50
|
+
scroll?: boolean | undefined;
|
|
51
|
+
layout?: string | undefined;
|
|
52
|
+
}): this;
|
|
53
|
+
source(sources: SourceInput[], { id, layout: layoutName }?: RawNodeOptions & SectionLayoutOptions): this;
|
|
54
|
+
image(url: string, { id, ...options }?: RawNodeOptions & ImageSectionOptions): this;
|
|
55
|
+
video(url: string, { id, ...options }?: RawNodeOptions & VideoSectionOptions): this;
|
|
56
|
+
footerAction(data: FooterActionItem | FooterActionItem[], { id, layout: layoutName }?: RawNodeOptions & SectionLayoutOptions): this;
|
|
57
|
+
widget(data: WidgetItem | WidgetItem[], { id, layout: layoutName }?: RawNodeOptions & SectionLayoutOptions): this;
|
|
58
|
+
product(data: ProductItem | ProductItem[], { id, layout: layoutName }?: RawNodeOptions & SectionLayoutOptions): this;
|
|
59
|
+
post(data: PostItem | PostItem[], { id, layout: layoutName }?: RawNodeOptions & SectionLayoutOptions): this;
|
|
60
|
+
reels(items: ReelsItem | ReelsItem[], { id, layout: layoutName }?: RawNodeOptions & SectionLayoutOptions): this;
|
|
61
|
+
html(html: string, { id, ...options }?: RawNodeOptions & HtmlSectionOptions): this;
|
|
62
|
+
footer(text: string): this;
|
|
63
|
+
context(info: AllowedContextInfo | Record<string, unknown>): this;
|
|
64
|
+
quote(message: QuotableMessage): this;
|
|
65
|
+
remove(target: RichTarget): this;
|
|
66
|
+
clear(): this;
|
|
67
|
+
build({ submessages, }?: {
|
|
68
|
+
submessages?: boolean;
|
|
69
|
+
}): WrapBotForwardedResult;
|
|
70
|
+
buildPlaceholder(): PlaceholderBuildResult;
|
|
71
|
+
buildEdit(jid: string, id: string | null, { submessages }?: {
|
|
72
|
+
submessages?: boolean;
|
|
73
|
+
}): EditBuildResult;
|
|
74
|
+
send(jid?: string, arg?: SendResolutionArg): Promise<unknown>;
|
|
75
|
+
edit(jid: string, id?: string | null, arg?: SendResolutionArg): Promise<unknown>;
|
|
76
|
+
}
|
|
77
|
+
export declare function airich(client?: ZapoClient, options?: AIRichConstructorOptions): AIRich;
|
|
78
|
+
export declare function airich(client: ZapoClient | undefined, jid: string, config: AIRichConfig, options?: AIRichSendOptions): Promise<MessageSendResult>;
|
|
79
|
+
export interface AIRichSendOptions extends MessageSendOptions {
|
|
80
|
+
twoStep?: boolean;
|
|
81
|
+
submessages?: boolean;
|
|
82
|
+
}
|
|
83
|
+
export type AIRichSectionConfig = {
|
|
84
|
+
type: "text";
|
|
85
|
+
text: string;
|
|
86
|
+
hyperlink?: boolean;
|
|
87
|
+
citation?: boolean;
|
|
88
|
+
latex?: boolean;
|
|
89
|
+
id?: string | null;
|
|
90
|
+
} | {
|
|
91
|
+
type: "code";
|
|
92
|
+
language: string;
|
|
93
|
+
code: string;
|
|
94
|
+
id?: string | null;
|
|
95
|
+
} | {
|
|
96
|
+
type: "table";
|
|
97
|
+
rows: string[][];
|
|
98
|
+
hyperlink?: boolean;
|
|
99
|
+
citation?: boolean;
|
|
100
|
+
latex?: boolean;
|
|
101
|
+
id?: string | null;
|
|
102
|
+
} | {
|
|
103
|
+
type: "metadata";
|
|
104
|
+
text: string;
|
|
105
|
+
id?: string | null;
|
|
106
|
+
} | {
|
|
107
|
+
type: "tip";
|
|
108
|
+
text: string;
|
|
109
|
+
id?: string | null;
|
|
110
|
+
} | {
|
|
111
|
+
type: "suggest";
|
|
112
|
+
items: string | readonly string[];
|
|
113
|
+
scroll?: boolean;
|
|
114
|
+
layout?: string;
|
|
115
|
+
id?: string | null;
|
|
116
|
+
} | {
|
|
117
|
+
type: "source";
|
|
118
|
+
sources: readonly SourceInput[];
|
|
119
|
+
layout?: string;
|
|
120
|
+
id?: string | null;
|
|
121
|
+
} | {
|
|
122
|
+
type: "image";
|
|
123
|
+
url: string;
|
|
124
|
+
width?: number;
|
|
125
|
+
height?: number;
|
|
126
|
+
status?: string;
|
|
127
|
+
updateText?: string;
|
|
128
|
+
id?: string | null;
|
|
129
|
+
} | {
|
|
130
|
+
type: "video";
|
|
131
|
+
url: string;
|
|
132
|
+
mimeType?: string;
|
|
133
|
+
fileLength?: number;
|
|
134
|
+
duration?: number;
|
|
135
|
+
status?: string;
|
|
136
|
+
id?: string | null;
|
|
137
|
+
} | {
|
|
138
|
+
type: "footerAction";
|
|
139
|
+
items: FooterActionItem | readonly FooterActionItem[];
|
|
140
|
+
layout?: string;
|
|
141
|
+
id?: string | null;
|
|
142
|
+
} | {
|
|
143
|
+
type: "widget";
|
|
144
|
+
items: WidgetItem | readonly WidgetItem[];
|
|
145
|
+
layout?: string;
|
|
146
|
+
id?: string | null;
|
|
147
|
+
} | {
|
|
148
|
+
type: "product";
|
|
149
|
+
items: ProductItem | readonly ProductItem[];
|
|
150
|
+
layout?: string;
|
|
151
|
+
id?: string | null;
|
|
152
|
+
} | {
|
|
153
|
+
type: "post";
|
|
154
|
+
items: PostItem | readonly PostItem[];
|
|
155
|
+
layout?: string;
|
|
156
|
+
id?: string | null;
|
|
157
|
+
} | {
|
|
158
|
+
type: "reels";
|
|
159
|
+
items: ReelsItem | readonly ReelsItem[];
|
|
160
|
+
layout?: string;
|
|
161
|
+
id?: string | null;
|
|
162
|
+
} | {
|
|
163
|
+
type: "html";
|
|
164
|
+
html: string;
|
|
165
|
+
trustedSources?: readonly unknown[];
|
|
166
|
+
id?: string | null;
|
|
167
|
+
} | {
|
|
168
|
+
type: "raw";
|
|
169
|
+
section: UnifiedResponseSection;
|
|
170
|
+
submessage?: SubmessagePayload;
|
|
171
|
+
id?: string | null;
|
|
172
|
+
};
|
|
173
|
+
export interface AIRichConfig {
|
|
174
|
+
sections: readonly AIRichSectionConfig[];
|
|
175
|
+
footer?: string;
|
|
176
|
+
context?: AllowedContextInfo | Record<string, unknown>;
|
|
177
|
+
quote?: QuotableMessage;
|
|
178
|
+
}
|
|
179
|
+
export declare const applyAIRichConfig: (builder: AIRich, config: AIRichConfig) => void;
|
|
180
|
+
export declare const sendAIRich: (client: ZapoClient | undefined, jid: string | undefined, config: AIRichConfig, options?: AIRichSendOptions) => Promise<MessageSendResult>;
|