@roidev/kachina-md 2.0.5 → 2.1.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/lib/index.d.ts ADDED
@@ -0,0 +1,265 @@
1
+ // Type definitions for @roidev/kachina-md
2
+ // Project: https://github.com/idlanyor/kachina-core
3
+ // Definitions by: Roynaldi <https://github.com/idlanyor>
4
+
5
+ /// <reference types="node" />
6
+
7
+ import { WASocket, proto } from 'baileys';
8
+ import EventEmitter from 'events';
9
+
10
+ // ============================================================================
11
+ // Main Client
12
+ // ============================================================================
13
+
14
+ export interface ClientOptions {
15
+ sessionId?: string;
16
+ phoneNumber?: string;
17
+ loginMethod?: 'qr' | 'pairing';
18
+ browser?: [string, string, string];
19
+ logger?: any;
20
+ prefix?: string;
21
+ store?: any;
22
+ owners?: string[] | string;
23
+ owner?: string[] | string;
24
+ }
25
+
26
+ export class Client extends EventEmitter {
27
+ static StickerTypes: typeof StickerTypes;
28
+
29
+ config: ClientOptions;
30
+ sock: WASocket | null;
31
+ store: any;
32
+ isReady: boolean;
33
+ user: any;
34
+ pluginHandler: PluginHandler;
35
+
36
+ constructor(options?: ClientOptions);
37
+
38
+ start(): Promise<WASocket>;
39
+
40
+ // Message sending methods
41
+ sendMessage(jid: string, content: any, options?: any): Promise<any>;
42
+ sendText(jid: string, text: string, options?: any): Promise<any>;
43
+ sendImage(jid: string, buffer: Buffer | string, caption?: string, options?: any): Promise<any>;
44
+ sendVideo(jid: string, buffer: Buffer | string, caption?: string, options?: any): Promise<any>;
45
+ sendAudio(jid: string, buffer: Buffer | string, options?: any): Promise<any>;
46
+ sendDocument(jid: string, buffer: Buffer | string, filename: string, mimetype: string, options?: any): Promise<any>;
47
+ sendSticker(jid: string, buffer: Buffer | string, options?: any): Promise<any>;
48
+ sendContact(jid: string, contacts: Contact[], options?: any): Promise<any>;
49
+ sendLocation(jid: string, latitude: number, longitude: number, options?: any): Promise<any>;
50
+ sendPoll(jid: string, name: string, values: string[], options?: any): Promise<any>;
51
+ sendReact(jid: string, messageKey: any, emoji: string): Promise<any>;
52
+
53
+ // View once methods
54
+ readViewOnce(quotedMessage: any): Promise<{ buffer: Buffer, type: 'image' | 'video', caption: string }>;
55
+ sendViewOnce(jid: string, quotedMessage: any, options?: any): Promise<any>;
56
+
57
+ // Group methods
58
+ groupMetadata(jid: string): Promise<any>;
59
+ groupParticipantsUpdate(jid: string, participants: string[], action: 'add' | 'remove' | 'promote' | 'demote'): Promise<any>;
60
+ groupUpdateSubject(jid: string, subject: string): Promise<any>;
61
+ groupUpdateDescription(jid: string, description: string): Promise<any>;
62
+
63
+ // Plugin methods
64
+ loadPlugin(path: string): Promise<void>;
65
+ loadPlugins(directory: string): Promise<void>;
66
+
67
+ // Getters/Setters
68
+ get prefix(): string;
69
+ set prefix(prefix: string);
70
+
71
+ // Events
72
+ on(event: 'ready', listener: (user: any) => void): this;
73
+ on(event: 'message', listener: (message: SerializedMessage) => void): this;
74
+ on(event: 'group.update', listener: (update: any) => void): this;
75
+ on(event: 'groups.update', listener: (updates: any[]) => void): this;
76
+ on(event: 'call', listener: (calls: any) => void): this;
77
+ on(event: 'pairing.code', listener: (code: string) => void): this;
78
+ on(event: 'pairing.error', listener: (error: Error) => void): this;
79
+ on(event: 'reconnecting', listener: () => void): this;
80
+ on(event: 'connecting', listener: () => void): this;
81
+ on(event: 'logout', listener: () => void): this;
82
+ }
83
+
84
+ // ============================================================================
85
+ // Plugin System
86
+ // ============================================================================
87
+
88
+ export interface Plugin {
89
+ name: string;
90
+ commands: string[];
91
+ category?: string;
92
+ description?: string;
93
+ owner?: boolean;
94
+ group?: boolean;
95
+ private?: boolean;
96
+ admin?: boolean;
97
+ botAdmin?: boolean;
98
+ exec: (context: PluginContext) => Promise<void>;
99
+ }
100
+
101
+ export interface PluginContext {
102
+ client: Client;
103
+ m: SerializedMessage;
104
+ args: string[];
105
+ command: string;
106
+ prefix: string;
107
+ sock: WASocket;
108
+ }
109
+
110
+ export class PluginHandler {
111
+ client: Client;
112
+ plugins: Map<string, Plugin>;
113
+ commands: Map<string, Plugin>;
114
+ isLoaded: boolean;
115
+
116
+ constructor(client: Client);
117
+
118
+ load(pluginPath: string): Promise<Plugin | null>;
119
+ loadAll(directory: string): Promise<number>;
120
+ execute(m: SerializedMessage): Promise<void>;
121
+ isOwner(jid: string): boolean;
122
+ reload(pluginName: string): boolean;
123
+ list(): Plugin[];
124
+ get(name: string): Plugin | undefined;
125
+ }
126
+
127
+ // ============================================================================
128
+ // Message Serialization
129
+ // ============================================================================
130
+
131
+ export interface SerializedMessage {
132
+ key: any;
133
+ chat: string;
134
+ fromMe: boolean;
135
+ id: string;
136
+ isGroup: boolean;
137
+ sender: string;
138
+ pushName: string;
139
+ type: string;
140
+ message: any;
141
+ body: string;
142
+ quoted?: SerializedMessage;
143
+ caption: string;
144
+ mimetype: string;
145
+ fileSize: number;
146
+ mentions: string[];
147
+
148
+ // Helper methods
149
+ reply(text: string, options?: any): Promise<any>;
150
+ react(emoji: string): Promise<any>;
151
+ download(): Promise<Buffer | null>;
152
+ delete(): Promise<any>;
153
+ forward(jid: string, options?: any): Promise<any>;
154
+ copyNForward(jid: string, options?: any): Promise<any>;
155
+ }
156
+
157
+ export function serialize(msg: any, sock: WASocket): Promise<SerializedMessage>;
158
+
159
+ // ============================================================================
160
+ // Database
161
+ // ============================================================================
162
+
163
+ export interface DatabaseOptions {
164
+ path?: string;
165
+ }
166
+
167
+ export class Database {
168
+ path: string;
169
+ collections: Map<string, any>;
170
+
171
+ constructor(options?: DatabaseOptions);
172
+
173
+ collection(name: string, defaultData?: any): Promise<any>;
174
+ get<T = any>(collection: string, key: string, defaultValue?: T): Promise<T>;
175
+ set<T = any>(collection: string, key: string, value: T): Promise<T>;
176
+ has(collection: string, key: string): Promise<boolean>;
177
+ delete(collection: string, key: string): Promise<boolean>;
178
+ all(collection: string): Promise<any>;
179
+ clear(collection: string): Promise<boolean>;
180
+ update(collection: string, key: string, updater: Function | object): Promise<any>;
181
+ increment(collection: string, key: string, field: string, amount?: number): Promise<any>;
182
+ push(collection: string, key: string, value: any): Promise<any[]>;
183
+ pull(collection: string, key: string, value: any): Promise<any[]>;
184
+ }
185
+
186
+ // ============================================================================
187
+ // Logger
188
+ // ============================================================================
189
+
190
+ export type LogLevel = 'debug' | 'info' | 'success' | 'warn' | 'error';
191
+
192
+ export interface LoggerOptions {
193
+ level?: LogLevel;
194
+ prefix?: string;
195
+ }
196
+
197
+ export class Logger {
198
+ level: LogLevel;
199
+ prefix: string;
200
+ levels: Record<LogLevel, number>;
201
+
202
+ constructor(options?: LoggerOptions);
203
+
204
+ debug(...args: any[]): void;
205
+ info(...args: any[]): void;
206
+ success(...args: any[]): void;
207
+ warn(...args: any[]): void;
208
+ error(...args: any[]): void;
209
+ command(command: string, from: string): void;
210
+ }
211
+
212
+ // ============================================================================
213
+ // Sticker
214
+ // ============================================================================
215
+
216
+ export enum StickerTypes {
217
+ DEFAULT = 'default',
218
+ CROPPED = 'crop',
219
+ FULL = 'full',
220
+ CIRCLE = 'circle',
221
+ ROUNDED = 'rounded'
222
+ }
223
+
224
+ export interface StickerOptions {
225
+ pack?: string;
226
+ author?: string;
227
+ type?: StickerTypes;
228
+ categories?: string[];
229
+ id?: string;
230
+ quality?: number;
231
+ background?: string;
232
+ }
233
+
234
+ export function createSticker(buffer: Buffer | string, options?: StickerOptions): Promise<Buffer>;
235
+ export function createFullSticker(buffer: Buffer | string, options?: StickerOptions): Promise<Buffer>;
236
+ export function createCroppedSticker(buffer: Buffer | string, options?: StickerOptions): Promise<Buffer>;
237
+ export function createCircleSticker(buffer: Buffer | string, options?: StickerOptions): Promise<Buffer>;
238
+ export function createRoundedSticker(buffer: Buffer | string, options?: StickerOptions): Promise<Buffer>;
239
+
240
+ // ============================================================================
241
+ // Utility Functions
242
+ // ============================================================================
243
+
244
+ export function sleep(ms: number): Promise<void>;
245
+ export function formatTime(seconds: number): string;
246
+ export function formatBytes(bytes: number): string;
247
+ export function parseCommand(text: string, prefix?: string): { command: string; args: string[]; text: string } | null;
248
+ export function isUrl(text: string): boolean;
249
+ export function extractUrls(text: string): string[];
250
+ export function randomString(length?: number): string;
251
+ export function randomNumber(min: number, max: number): number;
252
+ export function pickRandom<T>(array: T[]): T;
253
+ export function chunk<T>(array: T[], size: number): T[][];
254
+
255
+ // ============================================================================
256
+ // Additional Types
257
+ // ============================================================================
258
+
259
+ export interface Contact {
260
+ displayName: string;
261
+ vcard: string;
262
+ }
263
+
264
+ // Default export
265
+ export default Client;
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "@roidev/kachina-md",
3
- "version": "2.0.5",
3
+ "version": "2.1.1",
4
4
  "description": "WhatsApp Bot Framework - Simple, Fast, and Modular",
5
5
  "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
6
7
  "type": "module",
7
8
  "scripts": {
8
9
  "build": "node build.js",
9
10
  "test": "node examples/basic-bot.js",
10
11
  "prepublishOnly": "npm run build",
11
- "release": "bash scripts/release.sh"
12
+ "release": "bash scripts/release.sh",
13
+ "docs:dev": "vitepress dev docs-site --host",
14
+ "docs:build": "vitepress build docs-site",
15
+ "docs:preview": "vitepress preview docs-site"
12
16
  },
13
17
  "keywords": [
14
18
  "whatsapp",
@@ -32,7 +36,7 @@
32
36
  "dependencies": {
33
37
  "@hapi/boom": "^10.0.1",
34
38
  "axios": "^1.6.0",
35
- "baileys": "npm:@whiskeysockets/baileys@latest",
39
+ "baileys": "npm:@whiskeysockets/baileys@6.7.21",
36
40
  "chalk": "^5.3.0",
37
41
  "file-type": "^18.7.0",
38
42
  "fs-extra": "^11.2.0",
@@ -44,13 +48,16 @@
44
48
  "wa-sticker-formatter": "^4.4.4"
45
49
  },
46
50
  "devDependencies": {
47
- "gradient-string": "^2.0.2"
51
+ "gradient-string": "^2.0.2",
52
+ "vitepress": "^1.6.4",
53
+ "vue": "^3.5.24"
48
54
  },
49
55
  "engines": {
50
56
  "node": ">=16.0.0"
51
57
  },
52
58
  "exports": {
53
59
  ".": {
60
+ "types": "./lib/index.d.ts",
54
61
  "import": "./lib/index.js"
55
62
  },
56
63
  "./plugins": {