Skip to content

Commit fc2653b

Browse files
committed
refactor(src): strip all TSDoc comments (docs move to Nextra)
Removed all 555 /** */ doc-comment blocks from src/** (85 files) ahead of the dedicated Nextra documentation site. Code is now comment-free; typecheck, audits, and the full unit suite pass unchanged (behaviour is identical — comments are inert). The audit-comments policy is unchanged (it already permits zero comments).
1 parent a8e84d7 commit fc2653b

85 files changed

Lines changed: 0 additions & 1430 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/auth/adapters/convex.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,12 @@ import type { AuthenticationCreds, SignalDataSet } from 'baileys'
33
import { ConvexKv, type ConvexKvOptions, type ConvexKvRow } from '../../types/convex.js'
44
import type { AuthCredsStore, AuthStore, AuthStoreBundle, AuthStoreKey, AuthStoreValue } from '../types.js'
55

6-
/** Constructor input for {@link ConvexAuthStore}. */
76
export type ConvexAuthStoreOptions = ConvexKvOptions
87

98
const CREDS_KEY = 'creds'
109
const SIGNAL_PREFIX = 'signal:'
1110
const signalKey = (type: string, id: string): string => `${SIGNAL_PREFIX}${type}:${id}`
1211

13-
/**
14-
* Convex-backed `AuthStoreBundle`. Persists the credentials blob and signal keys
15-
* as `BufferJSON`-serialized rows in the user-deployed `zaileys_kv` table, reached
16-
* through a {@link ConvexKv} client (`url` XOR `client`).
17-
*
18-
* Requires the `zaileys_kv` schema + functions to be deployed in the Convex project
19-
* (see the template under `docs/convex/`). `convex` is an optional peer dependency.
20-
*/
2112
export class ConvexAuthStore implements AuthStoreBundle {
2213
readonly creds: AuthCredsStore
2314
readonly signal: AuthStore

src/auth/adapters/file.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import type {
1212
AuthStoreValue,
1313
} from '../types.js'
1414

15-
/** Optional constructor input for {@link FileAuthStore}. */
1615
export interface FileAuthStoreOptions {
17-
/** Root directory for persistence. Defaults to `./.zaileys/auth`. */
1816
basePath?: string
1917
}
2018

@@ -26,10 +24,6 @@ const encodeFilename = (id: string): string =>
2624
const isENOENT = (err: unknown): boolean =>
2725
typeof err === 'object' && err !== null && (err as { code?: string }).code === 'ENOENT'
2826

29-
/**
30-
* Disk-backed `AuthStoreBundle` using atomic write-then-rename for crash safety.
31-
* Default zero-config layout under `./.zaileys/auth/`.
32-
*/
3327
export class FileAuthStore implements AuthStoreBundle {
3428
private readonly basePath: string
3529
private closed = false
@@ -38,7 +32,6 @@ export class FileAuthStore implements AuthStoreBundle {
3832
this.basePath = options?.basePath ?? DEFAULT_BASE_PATH
3933
}
4034

41-
/** Signal-key store view persisting one JSON file per id under `signal/<type>/`. */
4235
readonly signal: AuthStore = {
4336
read: async <K extends AuthStoreKey>(
4437
type: K,
@@ -114,7 +107,6 @@ export class FileAuthStore implements AuthStoreBundle {
114107
},
115108
}
116109

117-
/** Credential store view persisting `creds.json` at the base directory. */
118110
readonly creds: AuthCredsStore = {
119111
readCreds: async (): Promise<AuthenticationCreds | undefined> => {
120112
this.assertOpen()

src/auth/adapters/memory.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ import type {
88
AuthStoreValue,
99
} from '../types.js'
1010

11-
/**
12-
* In-process `AuthStoreBundle` backed by JS `Map` instances.
13-
* Ideal for tests and ephemeral scripts; data is lost on process exit.
14-
*/
1511
export class MemoryAuthStore implements AuthStoreBundle {
1612
private credsBlob: AuthenticationCreds | undefined
1713
private readonly signalMap: Map<AuthStoreKey, Map<string, unknown>> = new Map()
1814
private closed = false
1915

20-
/** Signal-key store view backed by the shared in-process map. */
2116
readonly signal: AuthStore = {
2217
read: async <K extends AuthStoreKey>(
2318
type: K,
@@ -71,7 +66,6 @@ export class MemoryAuthStore implements AuthStoreBundle {
7166
},
7267
}
7368

74-
/** Credential store view sharing closure state with {@link MemoryAuthStore.signal}. */
7569
readonly creds: AuthCredsStore = {
7670
readCreds: async (): Promise<AuthenticationCreds | undefined> => {
7771
this.assertOpen()

src/auth/adapters/postgres.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ import type {
1010
AuthStoreValue,
1111
} from '../types.js'
1212

13-
/** Constructor input for {@link PostgresAuthStore}. XOR between `pool` and `connectionString`. */
1413
export interface PostgresAuthStoreOptions {
15-
/** Caller-owned pg `Pool`. Adapter will NOT end it on close. */
1614
pool?: Pool
17-
/** Connection string for an adapter-owned pool. Adapter ends it on close. */
1815
connectionString?: string
19-
/** Optional `max` pool size when adapter creates the pool. */
2016
max?: number
2117
}
2218

@@ -44,10 +40,6 @@ const CREATE_CREDS_SQL =
4440
const CREATE_SIGNAL_SQL =
4541
'CREATE TABLE IF NOT EXISTS zaileys_auth_signal (type text NOT NULL, id text NOT NULL, data bytea NOT NULL, PRIMARY KEY(type, id))'
4642

47-
/**
48-
* Postgres-backed `AuthStoreBundle` over node-postgres.
49-
* Schema auto-migrates idempotently on first method call.
50-
*/
5143
export class PostgresAuthStore implements AuthStoreBundle {
5244
private readonly externalPool: Pool | undefined
5345
private readonly connectionString: string | undefined
@@ -116,7 +108,6 @@ export class PostgresAuthStore implements AuthStoreBundle {
116108
}
117109
}
118110

119-
/** Signal-key store view over `zaileys_auth_signal`. */
120111
readonly signal: AuthStore = {
121112
read: async <K extends AuthStoreKey>(
122113
type: K,
@@ -245,7 +236,6 @@ export class PostgresAuthStore implements AuthStoreBundle {
245236
},
246237
}
247238

248-
/** Credential store view over `zaileys_auth_creds`. */
249239
readonly creds: AuthCredsStore = {
250240
readCreds: async (): Promise<AuthenticationCreds | undefined> => {
251241
const pool = await this.ensureReady()

src/auth/adapters/redis.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ import type {
1010
AuthStoreValue,
1111
} from '../types.js'
1212

13-
/** Optional constructor input for {@link RedisAuthStore}. */
1413
export interface RedisAuthStoreOptions {
15-
/** Pre-connected node-redis v4 client (caller owns lifecycle). */
1614
client?: RedisClientType
17-
/** Connection URL; adapter creates and owns the client. */
1815
url?: string
19-
/** Namespace prefix isolating keys. Defaults to `'zaileys'`. */
2016
namespace?: string
2117
}
2218

@@ -41,11 +37,6 @@ const isPeerMissingError = (err: unknown): boolean => {
4137
return code === 'ERR_MODULE_NOT_FOUND' || code === 'MODULE_NOT_FOUND'
4238
}
4339

44-
/**
45-
* Redis-backed `AuthStoreBundle` using node-redis v4.
46-
* Accepts EITHER a pre-connected `client` OR a `url` (XOR); throws on both.
47-
* Adapter owns the client lifecycle only when constructed with `url`.
48-
*/
4940
export class RedisAuthStore implements AuthStoreBundle {
5041
private readonly namespace: string
5142
private readonly externalClient: RedisClientType | undefined
@@ -72,7 +63,6 @@ export class RedisAuthStore implements AuthStoreBundle {
7263
this.url = options.url
7364
}
7465

75-
/** Signal-key store view backed by per-id Redis strings and a SET index per type. */
7666
readonly signal: AuthStore = {
7767
read: async <K extends AuthStoreKey>(
7868
type: K,
@@ -147,7 +137,6 @@ export class RedisAuthStore implements AuthStoreBundle {
147137
},
148138
}
149139

150-
/** Credential store view persisting a single Redis string under `<ns>:auth:creds`. */
151140
readonly creds: AuthCredsStore = {
152141
readCreds: async (): Promise<AuthenticationCreds | undefined> => {
153142
this.assertOpen()

src/auth/adapters/sqlite.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ type RawDriverCtor = new (
2828
options?: { readonly?: boolean },
2929
) => DatabaseInstance
3030

31-
/** Optional constructor input for {@link SqliteAuthStore}. */
3231
export interface SqliteAuthStoreOptions {
33-
/** Path on disk, or `':memory:'` for an ephemeral connection. */
3432
database: string | Buffer
35-
/** Open the database read-only. */
3633
readonly?: boolean
3734
}
3835

@@ -76,10 +73,6 @@ const chunked = <T,>(items: readonly T[], size: number): T[][] => {
7673
return out
7774
}
7875

79-
/**
80-
* SQLite-backed `AuthStoreBundle` using `better-sqlite3` with WAL pragmas.
81-
* Schema migrates idempotently on first use; supports `:memory:` mode.
82-
*/
8376
export class SqliteAuthStore implements AuthStoreBundle {
8477
private readonly options: SqliteAuthStoreOptions
8578
private db: DatabaseInstance | null = null
@@ -91,7 +84,6 @@ export class SqliteAuthStore implements AuthStoreBundle {
9184
this.options = options
9285
}
9386

94-
/** Credential persistence view backed by the `auth_creds` table. */
9587
readonly creds: AuthCredsStore = {
9688
readCreds: async (): Promise<AuthenticationCreds | undefined> => {
9789
const prep = await this.ensureReady()
@@ -110,7 +102,6 @@ export class SqliteAuthStore implements AuthStoreBundle {
110102
},
111103
}
112104

113-
/** Signal-key store view backed by the `auth_signal` table. */
114105
readonly signal: AuthStore = {
115106
read: async <K extends AuthStoreKey>(
116107
type: K,

src/auth/cache.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ import type {
77
AuthStoreValue,
88
} from './types.js'
99

10-
/**
11-
* Optional inputs for {@link makeCacheableAuthStore}.
12-
*
13-
* `cacheSize` and `cacheTtlSeconds` are reserved for a future iteration —
14-
* Phase 3 will surface them via the Client `cacheSignal` option. Today the
15-
* wrapper relies on Baileys' internal NodeCache defaults.
16-
*/
1710
export interface CacheableAuthStoreOptions {
1811
logger?: {
1912
trace?: (msg: unknown) => void
@@ -26,14 +19,6 @@ export interface CacheableAuthStoreOptions {
2619
cacheTtlSeconds?: number
2720
}
2821

29-
/**
30-
* Wrap an {@link AuthStoreBundle} so signal reads hit an LRU cache (Baileys'
31-
* `makeCacheableSignalKeyStore`). The creds half passes through untouched —
32-
* caching there has no payoff. Delete invalidates the cache via `set(nulls)`.
33-
*
34-
* NOTE: `cacheSize` / `cacheTtlSeconds` options are not yet honoured; Phase 3
35-
* Client config will own that surface (see plan-007 hand-off in SUMMARY).
36-
*/
3722
export function makeCacheableAuthStore(
3823
bundle: AuthStoreBundle,
3924
options?: CacheableAuthStoreOptions,

src/auth/types.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,26 @@
11
import type { AuthenticationCreds, SignalDataSet, SignalDataTypeMap } from 'baileys'
22

3-
/** Discriminator union for every Baileys signal category. */
43
export type AuthStoreKey = keyof SignalDataTypeMap
54

6-
/** Resolved value type for a given signal category. */
75
export type AuthStoreValue<K extends AuthStoreKey> = SignalDataTypeMap[K]
86

9-
/**
10-
* Pluggable signal-key store mirroring Baileys' `SignalKeyStore` shape.
11-
* After {@link AuthStore.close} resolves every other method MUST throw
12-
* `ZaileysStoreError` with code `STORE_CLOSED`.
13-
*/
147
export interface AuthStore {
15-
/**
16-
* Look up signal values by id within a single category.
17-
* @param type Signal category to read.
18-
* @param ids Identifiers to fetch.
19-
* @returns Map keyed by id; missing ids resolve to `undefined`.
20-
*/
218
read<K extends AuthStoreKey>(
229
type: K,
2310
ids: readonly string[],
2411
): Promise<{ [id: string]: AuthStoreValue<K> | undefined }>
25-
/**
26-
* Persist a partial signal map. `null` values delete the matching id.
27-
* @param data Baileys `SignalDataSet` payload (full or partial).
28-
*/
2912
write(data: SignalDataSet): Promise<void>
30-
/**
31-
* Remove ids from a category.
32-
* @param type Signal category.
33-
* @param ids Identifiers to drop.
34-
*/
3513
delete<K extends AuthStoreKey>(type: K, ids: readonly string[]): Promise<void>
36-
/** Wipe every signal category (used on 401/410 auto-cleanup). */
3714
clear(): Promise<void>
38-
/** Release backing resources; idempotent. */
3915
close(): Promise<void>
4016
}
4117

42-
/**
43-
* Credential persistence for the long-lived `AuthenticationCreds` blob.
44-
* After {@link AuthCredsStore} sibling close every method MUST throw
45-
* `ZaileysStoreError` with code `STORE_CLOSED`.
46-
*/
4718
export interface AuthCredsStore {
48-
/** Load persisted creds; resolves `undefined` when none exist. */
4919
readCreds(): Promise<AuthenticationCreds | undefined>
50-
/** Persist creds atomically. */
5120
writeCreds(creds: AuthenticationCreds): Promise<void>
52-
/** Remove persisted creds. */
5321
deleteCreds(): Promise<void>
5422
}
5523

56-
/** Composite bundle handed to the Client to satisfy Baileys auth wiring. */
5724
export interface AuthStoreBundle {
5825
readonly creds: AuthCredsStore
5926
readonly signal: AuthStore

src/automation/broadcast.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@ import { RateLimiter, type RateLimiterClock } from './rate-limiter.js'
33
import { TaskQueue } from './queue.js'
44
import type { BroadcastOptions, BroadcastResult } from './types.js'
55

6-
/**
7-
* Dependencies for {@link runBroadcast}. Decoupled from `Client` so the core is
8-
* testable with a mock `sendTo` and an injected limiter/clock.
9-
*
10-
* - `sendTo` mirrors `client.send`: a jid in, a fresh `MessageBuilder<'init'>` out.
11-
* - `limiter` is optional; when omitted one is built from `options.rateLimitPerSec`.
12-
* - `now`/`sleep` are injectable timing primitives forwarded to the limiter and
13-
* retry backoff for fake-timer determinism in tests.
14-
*/
156
export type BroadcastDeps = {
167
sendTo: (jid: string) => MessageBuilder<'init'>
178
limiter?: RateLimiter
@@ -22,18 +13,6 @@ export type BroadcastDeps = {
2213
const toError = (value: unknown): Error =>
2314
value instanceof Error ? value : new Error(typeof value === 'string' ? value : String(value))
2415

25-
/**
26-
* Send one message per jid, paced by a {@link RateLimiter} and isolated so a
27-
* single recipient failure never halts the run.
28-
*
29-
* For each jid: a rate-limit token is acquired, then `build(deps.sendTo(jid))`
30-
* is dispatched. When `options.retry` is supplied the per-recipient send is
31-
* wrapped in a {@link TaskQueue} retry loop; otherwise it runs once. Successes
32-
* land in `result.sent`, failures (after retries) in `result.failed` with the
33-
* causing error. `onProgress(done, total, jid, ok)` fires after each recipient
34-
* resolves. The invariant `sent.length + failed.length === jids.length` always
35-
* holds. An empty `jids` array resolves immediately with empty arrays.
36-
*/
3716
export async function runBroadcast(
3817
jids: string[],
3918
build: (b: MessageBuilder<'init'>) => MessageBuilder<'content-set'>,

src/automation/errors.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
/**
2-
* Discriminated error codes for {@link ZaileysAutomationError}.
3-
*
4-
* - `NOT_CONNECTED` — an automation helper was used while the client socket is absent.
5-
* - `RATE_LIMIT_INVALID` — a rate-limiter option (e.g. `perSec`) failed validation.
6-
* - `TASK_FAILED` — a queued task exhausted its retries.
7-
* - `SCHEDULE_INVALID` — a scheduled-send argument (date/recipient) failed validation.
8-
* - `STORE_UNAVAILABLE` — schedule persistence was requested without a backing store.
9-
* - `PRESENCE_FAILED` — the underlying presence update rejected.
10-
*/
111
export type AutomationErrorCode =
122
| 'NOT_CONNECTED'
133
| 'RATE_LIMIT_INVALID'
@@ -16,11 +6,6 @@ export type AutomationErrorCode =
166
| 'STORE_UNAVAILABLE'
177
| 'PRESENCE_FAILED'
188

19-
/**
20-
* Typed error thrown by the automation utilities (rate limiter, queue, broadcast,
21-
* schedule, presence). The `code` field is the contract surface for callers; keep
22-
* raw payloads out of `message` and `cause`.
23-
*/
249
export class ZaileysAutomationError extends Error {
2510
readonly code: AutomationErrorCode
2611
override readonly cause?: unknown

0 commit comments

Comments
 (0)