@qkitt/queue 0.1.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/LICENSE +15 -0
- package/README.md +723 -0
- package/dist/config/config-freeze.util.d.ts +7 -0
- package/dist/config/from-config.d.ts +33 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/parse.util.d.ts +12 -0
- package/dist/config/store-resolve.util.d.ts +11 -0
- package/dist/config/types.d.ts +205 -0
- package/dist/config/validate.d.ts +36 -0
- package/dist/events/index.d.ts +48 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1552 -0
- package/dist/persist/index.d.ts +3 -0
- package/dist/persist/json-codec.util.d.ts +13 -0
- package/dist/persist/memory.d.ts +14 -0
- package/dist/persist/web-storage-access.util.d.ts +10 -0
- package/dist/persist/web-storage.d.ts +59 -0
- package/dist/queue/core/forward.util.d.ts +21 -0
- package/dist/queue/core/layers.util.d.ts +13 -0
- package/dist/queue/core/queue.d.ts +66 -0
- package/dist/queue/index.d.ts +7 -0
- package/dist/queue/persist/create-id.util.d.ts +10 -0
- package/dist/queue/persist/hydrate-gate.util.d.ts +9 -0
- package/dist/queue/persist/persist.support.d.ts +19 -0
- package/dist/queue/persist/persist.types.d.ts +23 -0
- package/dist/queue/persist/row-ids.util.d.ts +14 -0
- package/dist/queue/persist/with-row-persist.d.ts +72 -0
- package/dist/queue/persist/with-snapshot-persist.d.ts +45 -0
- package/dist/queue/persist/write-chain.util.d.ts +12 -0
- package/dist/queue/worker/with-worker.d.ts +56 -0
- package/dist/router/index.d.ts +3 -0
- package/dist/router/match.util.d.ts +24 -0
- package/dist/router/router.d.ts +107 -0
- package/dist/worker/index.d.ts +4 -0
- package/dist/worker/pipeline.d.ts +22 -0
- package/dist/worker/retry.d.ts +31 -0
- package/dist/worker/types.d.ts +5 -0
- package/package.json +64 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SystemConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Shallow-freeze so callers cannot reassign top-level fields, while keeping
|
|
4
|
+
* worker / store impl references intact (unlike JSON round-trip).
|
|
5
|
+
*/
|
|
6
|
+
export declare const freezeConfig: <TConfig extends SystemConfig>(config: TConfig) => Readonly<TConfig>;
|
|
7
|
+
//# sourceMappingURL=config-freeze.util.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BuildFromConfigOptions, ConfiguredSystem, SystemConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Build named stores, queues, optional workers, and an optional topic router
|
|
4
|
+
* from a single {@link SystemConfig}.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const config = defineConfig({
|
|
8
|
+
* stores: {
|
|
9
|
+
* jobsDb: { adapter: 'memory', strategy: 'row' },
|
|
10
|
+
* redis: { strategy: 'row', impl: createRedisRowStore() },
|
|
11
|
+
* },
|
|
12
|
+
* queues: {
|
|
13
|
+
* jobs: {
|
|
14
|
+
* persist: { store: 'jobsDb' },
|
|
15
|
+
* worker: { run: handleJob, concurrency: 2 },
|
|
16
|
+
* },
|
|
17
|
+
* },
|
|
18
|
+
* router: { bindings: [{ pattern: 'jobs.#', queue: 'jobs' }] },
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* const system = await buildFromConfig(config)
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Order: resolve stores → queue → persist → worker → router bind → hydrate.
|
|
25
|
+
*/
|
|
26
|
+
export declare const buildFromConfig: <TConfig extends SystemConfig, T = unknown>(config: TConfig, options?: BuildFromConfigOptions) => Promise<ConfiguredSystem<TConfig, T>>;
|
|
27
|
+
/**
|
|
28
|
+
* Parse **data-only** JSON, validate, and build the system.
|
|
29
|
+
* Workers / custom store `impl` cannot appear in JSON — use a JS module and
|
|
30
|
+
* {@link buildFromConfig} instead.
|
|
31
|
+
*/
|
|
32
|
+
export declare const buildFromJson: <T = unknown>(json: string, options?: BuildFromConfigOptions) => Promise<ConfiguredSystem<SystemConfig, T>>;
|
|
33
|
+
//# sourceMappingURL=from-config.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildFromConfig, buildFromJson, } from './from-config';
|
|
2
|
+
export { defineConfig, parseSystemConfig, validateJsConfig, validateSystemConfig, } from './validate';
|
|
3
|
+
export type { BindingConfig, BuildFromConfigOptions, BuiltinStoreAdapter, ConfiguredQueue, ConfiguredSystem, PersistConfig, QueueConfig, ResolvedStore, RouterConfig, StoreDefinition, StoreKind, SystemConfig, WorkerConfig, } from './types';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuiltinStoreAdapter } from './types';
|
|
2
|
+
export declare const BUILTIN_ADAPTERS: Set<BuiltinStoreAdapter>;
|
|
3
|
+
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
4
|
+
export declare const expectString: (value: unknown, path: string) => string;
|
|
5
|
+
export declare const expectBoolean: (value: unknown, path: string) => boolean;
|
|
6
|
+
/** Finite number ≥ 1 (queue maxSize, worker concurrency, …). */
|
|
7
|
+
export declare const expectPositiveFinite: (value: unknown, path: string) => number;
|
|
8
|
+
export declare const parseAdapter: (value: unknown, path: string) => BuiltinStoreAdapter;
|
|
9
|
+
export declare const isSnapshotStoreLike: (value: unknown) => boolean;
|
|
10
|
+
export declare const isRowStoreLike: (value: unknown) => boolean;
|
|
11
|
+
export declare const parseStrategy: (value: unknown, path: string) => 'snapshot' | 'row';
|
|
12
|
+
//# sourceMappingURL=parse.util.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RowStore, SnapshotStore } from '../queue/persist/persist.types';
|
|
2
|
+
import type { BuildFromConfigOptions, ResolvedStore, StoreDefinition } from './types';
|
|
3
|
+
export declare const isSnapshotStore: <T>(value: SnapshotStore<T> | RowStore<T>) => value is SnapshotStore<T>;
|
|
4
|
+
export declare const isRowStore: <T>(value: SnapshotStore<T> | RowStore<T>) => value is RowStore<T>;
|
|
5
|
+
/**
|
|
6
|
+
* Materialize one store definition into a live SnapshotStore or RowStore.
|
|
7
|
+
* Custom `impl` is used as-is; built-ins are constructed from `adapter`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveStore: <T>(storeName: string, definition: StoreDefinition, options: BuildFromConfigOptions) => ResolvedStore<T>;
|
|
10
|
+
export declare const resolveAllStores: <T>(stores: Record<string, StoreDefinition> | undefined, options: BuildFromConfigOptions) => Record<string, ResolvedStore<T>>;
|
|
11
|
+
//# sourceMappingURL=store-resolve.util.d.ts.map
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { WebStorageLike } from '../persist/web-storage-access.util';
|
|
2
|
+
import type { Queue } from '../queue/core/queue';
|
|
3
|
+
import type { RowStore, SnapshotStore } from '../queue/persist/persist.types';
|
|
4
|
+
import type { WithWorkerOptions, WorkerControls } from '../queue/worker/with-worker';
|
|
5
|
+
import type { Router } from '../router';
|
|
6
|
+
import type { WorkerFn } from '../worker/types';
|
|
7
|
+
/**
|
|
8
|
+
* Built-in store **adapters** the library can construct for you.
|
|
9
|
+
* Custom backends do not appear here — implement {@link SnapshotStore} or
|
|
10
|
+
* {@link RowStore} and register the instance under `stores`.
|
|
11
|
+
*/
|
|
12
|
+
export type BuiltinStoreAdapter = 'memory' | 'localStorage' | 'sessionStorage';
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use {@link BuiltinStoreAdapter}. Kept as an alias.
|
|
15
|
+
*/
|
|
16
|
+
export type StoreKind = BuiltinStoreAdapter;
|
|
17
|
+
/**
|
|
18
|
+
* Named entry in `config.stores`.
|
|
19
|
+
*
|
|
20
|
+
* - **Built-in**: `{ adapter, strategy, key? }` — library creates the store.
|
|
21
|
+
* - **Custom**: `{ strategy, impl }` — your {@link SnapshotStore} / {@link RowStore}.
|
|
22
|
+
*/
|
|
23
|
+
export type StoreDefinition = {
|
|
24
|
+
strategy: 'snapshot';
|
|
25
|
+
adapter: BuiltinStoreAdapter;
|
|
26
|
+
/**
|
|
27
|
+
* Required when `adapter` is `localStorage` or `sessionStorage`.
|
|
28
|
+
* Storage key for the full JSON array.
|
|
29
|
+
*/
|
|
30
|
+
key?: string;
|
|
31
|
+
} | {
|
|
32
|
+
strategy: 'row';
|
|
33
|
+
adapter: BuiltinStoreAdapter;
|
|
34
|
+
/**
|
|
35
|
+
* Required when `adapter` is `localStorage` or `sessionStorage`.
|
|
36
|
+
* Key prefix for order list + per-row keys.
|
|
37
|
+
*/
|
|
38
|
+
key?: string;
|
|
39
|
+
} | {
|
|
40
|
+
strategy: 'snapshot';
|
|
41
|
+
/** JS config only — custom snapshot backend. */
|
|
42
|
+
impl: SnapshotStore<any>;
|
|
43
|
+
} | {
|
|
44
|
+
strategy: 'row';
|
|
45
|
+
/** JS config only — custom row backend. */
|
|
46
|
+
impl: RowStore<any>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Queue-level persistence: pick a named store from `config.stores`.
|
|
50
|
+
* Strategy comes from the store definition, not from the queue.
|
|
51
|
+
*/
|
|
52
|
+
export type PersistConfig = {
|
|
53
|
+
/** Name of an entry in `config.stores`. */
|
|
54
|
+
store: string;
|
|
55
|
+
/**
|
|
56
|
+
* Snapshot stores only: auto-save after mutations.
|
|
57
|
+
* Defaults to `true`. Ignored for row stores.
|
|
58
|
+
*/
|
|
59
|
+
autoSave?: boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Worker attachment for a queue (JS config only — functions are not JSON).
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { handleJob } from './workers/job'
|
|
66
|
+
*
|
|
67
|
+
* worker: handleJob
|
|
68
|
+
* // or
|
|
69
|
+
* worker: { run: handleJob, concurrency: 4, autoStart: false }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export type WorkerConfig = WorkerFn<any, any> | ({
|
|
73
|
+
run: WorkerFn<any, any>;
|
|
74
|
+
} & WithWorkerOptions);
|
|
75
|
+
export type QueueConfig = {
|
|
76
|
+
/**
|
|
77
|
+
* Maximum items in the in-memory queue (backpressure).
|
|
78
|
+
* Same semantics as `buildQueue({ maxSize })` — enqueue throws
|
|
79
|
+
* {@link import('../queue/core/queue').QueueFullError} when exceeded.
|
|
80
|
+
*/
|
|
81
|
+
maxSize?: number;
|
|
82
|
+
/** Optional persistence via a named store in `config.stores`. */
|
|
83
|
+
persist?: PersistConfig;
|
|
84
|
+
/**
|
|
85
|
+
* JS config only — process items with {@link withWorker}.
|
|
86
|
+
* Import the function from your app and pass it here.
|
|
87
|
+
*/
|
|
88
|
+
worker?: WorkerConfig;
|
|
89
|
+
};
|
|
90
|
+
export type BindingConfig = {
|
|
91
|
+
/** Topic pattern (`orders.*`, `mail.#`, …). */
|
|
92
|
+
pattern: string;
|
|
93
|
+
/** Name of a queue defined under `queues`. */
|
|
94
|
+
queue: string;
|
|
95
|
+
};
|
|
96
|
+
export type RouterConfig = {
|
|
97
|
+
bindings?: BindingConfig[];
|
|
98
|
+
/**
|
|
99
|
+
* Named queue that receives {@link import('../router').RouteMessage}
|
|
100
|
+
* envelopes when a publish matches **no** bindings (unrouted).
|
|
101
|
+
* Must exist under `queues`. The queue is not auto-bound as a pattern —
|
|
102
|
+
* it is only the unmatched sink.
|
|
103
|
+
*/
|
|
104
|
+
unmatchedQueue?: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Single system config: **stores** (adapters) + **queues** (+ optional router).
|
|
108
|
+
*
|
|
109
|
+
* Prefer a JS/TS module so workers and custom store `impl`s can be imported.
|
|
110
|
+
* A JSON subset (built-in adapters only, no workers) works via
|
|
111
|
+
* {@link parseSystemConfig} / {@link buildFromJson}.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { defineConfig } from '@qkitt/queue'
|
|
116
|
+
* import { handleMail } from './workers/mail'
|
|
117
|
+
* import { createRedisRowStore } from './stores/redis'
|
|
118
|
+
*
|
|
119
|
+
* export default defineConfig({
|
|
120
|
+
* stores: {
|
|
121
|
+
* mailDb: { adapter: 'localStorage', strategy: 'row', key: 'mail' },
|
|
122
|
+
* redis: { strategy: 'row', impl: createRedisRowStore() },
|
|
123
|
+
* },
|
|
124
|
+
* queues: {
|
|
125
|
+
* mail: {
|
|
126
|
+
* persist: { store: 'mailDb' },
|
|
127
|
+
* worker: { run: handleMail, concurrency: 2 },
|
|
128
|
+
* },
|
|
129
|
+
* },
|
|
130
|
+
* router: {
|
|
131
|
+
* bindings: [{ pattern: 'mail.#', queue: 'mail' }],
|
|
132
|
+
* unmatchedQueue: 'unrouted',
|
|
133
|
+
* },
|
|
134
|
+
* })
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export type SystemConfig = {
|
|
138
|
+
/**
|
|
139
|
+
* Named store adapters. Queues reference them with `persist.store`.
|
|
140
|
+
* Omit (or `{}`) when no queue uses persistence.
|
|
141
|
+
*/
|
|
142
|
+
stores?: Record<string, StoreDefinition>;
|
|
143
|
+
queues: Record<string, QueueConfig>;
|
|
144
|
+
/**
|
|
145
|
+
* When present, a router is created and bindings applied.
|
|
146
|
+
* Use `{}` or `{ bindings: [] }` for an empty router.
|
|
147
|
+
* Optional `unmatchedQueue` parks unrouted publishes.
|
|
148
|
+
*/
|
|
149
|
+
router?: RouterConfig;
|
|
150
|
+
/**
|
|
151
|
+
* Hydrate all persisted queues after construction (and after workers
|
|
152
|
+
* are attached, so restored items can be processed when autoStart is on).
|
|
153
|
+
* Defaults to `true` when any queue has `persist`.
|
|
154
|
+
*/
|
|
155
|
+
hydrate?: boolean;
|
|
156
|
+
};
|
|
157
|
+
/** Build-time options that cannot live in config data. */
|
|
158
|
+
export type BuildFromConfigOptions = {
|
|
159
|
+
/**
|
|
160
|
+
* Inject Web Storage (tests, Node, custom backends).
|
|
161
|
+
* Used when a store's `adapter` is `localStorage` or `sessionStorage`.
|
|
162
|
+
*/
|
|
163
|
+
storage?: WebStorageLike;
|
|
164
|
+
};
|
|
165
|
+
/** Resolved store instance after build (custom or built-in). */
|
|
166
|
+
export type ResolvedStore<T = unknown> = SnapshotStore<T> | RowStore<T>;
|
|
167
|
+
/**
|
|
168
|
+
* Queue surface returned by the config builder.
|
|
169
|
+
* Persist / worker helpers are present only when configured.
|
|
170
|
+
*/
|
|
171
|
+
export type ConfiguredQueue<T = unknown> = Queue<T> & Partial<WorkerControls> & {
|
|
172
|
+
hydrate?: () => Promise<void>;
|
|
173
|
+
persist?: () => Promise<void>;
|
|
174
|
+
flush?: () => Promise<void>;
|
|
175
|
+
rowIds?: () => string[];
|
|
176
|
+
};
|
|
177
|
+
export type ConfiguredSystem<TConfig extends SystemConfig = SystemConfig, T = unknown> = {
|
|
178
|
+
queues: {
|
|
179
|
+
[K in keyof TConfig['queues']]: ConfiguredQueue<T>;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Resolved store instances keyed by `config.stores` names.
|
|
183
|
+
* Empty object when no stores were defined.
|
|
184
|
+
*/
|
|
185
|
+
stores: {
|
|
186
|
+
[K in keyof NonNullable<TConfig['stores']>]: ResolvedStore<T>;
|
|
187
|
+
} & Record<string, ResolvedStore<T>>;
|
|
188
|
+
/**
|
|
189
|
+
* Present when `router` was set in config.
|
|
190
|
+
* Always defined for that case; `undefined` when no router was requested.
|
|
191
|
+
*/
|
|
192
|
+
router: TConfig extends {
|
|
193
|
+
router: RouterConfig;
|
|
194
|
+
} ? Router : Router | undefined;
|
|
195
|
+
/** Hydrate every queue that exposes `hydrate`. */
|
|
196
|
+
hydrateAll: () => Promise<void>;
|
|
197
|
+
/** Flush every queue that exposes `flush`. */
|
|
198
|
+
flushAll: () => Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* The config used to build this system (shallow-frozen).
|
|
201
|
+
* Function references (workers, store impls) are preserved.
|
|
202
|
+
*/
|
|
203
|
+
config: Readonly<TConfig>;
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SystemConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Validate an unknown value as **data-only** config (JSON-safe).
|
|
4
|
+
* Rejects `worker` and custom store `impl` (JS-only fields).
|
|
5
|
+
*/
|
|
6
|
+
export declare const validateSystemConfig: (value: unknown) => SystemConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Validate a JS/TS module config, preserving workers and custom store impls.
|
|
9
|
+
* Prefer {@link defineConfig} at the export site for typed inference.
|
|
10
|
+
*/
|
|
11
|
+
export declare const validateJsConfig: <TConfig extends SystemConfig>(value: TConfig) => TConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Identity helper for typed JS config modules.
|
|
14
|
+
* Validates structure and preserves function / store instance references.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* export default defineConfig({
|
|
19
|
+
* stores: {
|
|
20
|
+
* jobs: { adapter: 'memory', strategy: 'row' },
|
|
21
|
+
* },
|
|
22
|
+
* queues: {
|
|
23
|
+
* jobs: {
|
|
24
|
+
* persist: { store: 'jobs' },
|
|
25
|
+
* worker: handleJob,
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const defineConfig: <const TConfig extends SystemConfig>(config: TConfig) => TConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Parse a JSON string into a validated **data-only** {@link SystemConfig}.
|
|
34
|
+
*/
|
|
35
|
+
export declare const parseSystemConfig: (json: string) => SystemConfig;
|
|
36
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Base constraint for typed event maps. Avoids a string index signature so intersections stay precise. */
|
|
2
|
+
export type EventMap = Record<never, never>;
|
|
3
|
+
/**
|
|
4
|
+
* Merge event maps. Extra keys overwrite base keys (no `A[K] & B[K]` intersection).
|
|
5
|
+
* Needed so generic expand/withWorker emit payloads stay assignable.
|
|
6
|
+
*/
|
|
7
|
+
export type MergeEventMaps<TBase extends EventMap, TExtra extends EventMap> = Omit<TBase, keyof TExtra> & TExtra;
|
|
8
|
+
export type EventCallback<T> = (data: T) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Typed emit bridge over a loosely typed `emit`.
|
|
11
|
+
* Avoids `TBase[K] & TExtra[K]` from generic map merges making concrete
|
|
12
|
+
* payloads unassignable under a free `TEvents`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createTypedEmit: <TEvents extends EventMap>(emit: (eventName: string, data: unknown) => void) => <K extends keyof TEvents>(eventName: K, data: TEvents[K]) => void;
|
|
15
|
+
export type EventEmitter<TEvents extends EventMap = EventMap> = {
|
|
16
|
+
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
17
|
+
on: <K extends keyof TEvents>(eventName: K, callback: EventCallback<TEvents[K]>) => () => void;
|
|
18
|
+
/** Subscribe for a single emission, then auto-unsubscribe. Returns an unsubscribe function. */
|
|
19
|
+
once: <K extends keyof TEvents>(eventName: K, callback: EventCallback<TEvents[K]>) => () => void;
|
|
20
|
+
/** Remove a specific listener, or all listeners for the event if no callback is given. */
|
|
21
|
+
off: <K extends keyof TEvents>(eventName: K, callback?: EventCallback<TEvents[K]>) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Emit an event to all current listeners (snapshot taken before dispatch).
|
|
24
|
+
* Listener errors are isolated: one throw does not skip remaining listeners.
|
|
25
|
+
* Failures are swallowed at emit time — listeners should handle their own errors
|
|
26
|
+
* (critical paths like worker pump must not die because of a user handler).
|
|
27
|
+
*/
|
|
28
|
+
emit: <K extends keyof TEvents>(eventName: K, data: TEvents[K]) => void;
|
|
29
|
+
/** Remove all listeners for all events. */
|
|
30
|
+
clear: () => void;
|
|
31
|
+
/** Number of listeners registered for an event. */
|
|
32
|
+
listenerCount: <K extends keyof TEvents>(eventName: K) => number;
|
|
33
|
+
/** Event names that currently have at least one listener. */
|
|
34
|
+
eventNames: () => (keyof TEvents)[];
|
|
35
|
+
/**
|
|
36
|
+
* Widen the event map with additional event types.
|
|
37
|
+
* Returns the same instance (listeners preserved), typed as the merged map.
|
|
38
|
+
* Extra keys overwrite base keys (see {@link MergeEventMaps}).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const base = buildEventEmitter<{ job: { id: string } }>()
|
|
42
|
+
* const events = base.expand<{ drained: undefined; error: Error }>()
|
|
43
|
+
* events.on('drained', () => {})
|
|
44
|
+
*/
|
|
45
|
+
expand: <TExtra extends EventMap>() => EventEmitter<MergeEventMaps<TEvents, TExtra>>;
|
|
46
|
+
};
|
|
47
|
+
export declare const buildEventEmitter: <TEvents extends EventMap = EventMap>() => EventEmitter<TEvents>;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { buildFromConfig, buildFromJson, defineConfig, parseSystemConfig, validateJsConfig, validateSystemConfig, type BindingConfig, type BuildFromConfigOptions, type BuiltinStoreAdapter, type ConfiguredQueue, type ConfiguredSystem, type PersistConfig, type QueueConfig, type ResolvedStore, type RouterConfig, type StoreDefinition, type StoreKind, type SystemConfig, type WorkerConfig, } from './config';
|
|
2
|
+
export { buildEventEmitter, createTypedEmit, type EventCallback, type EventEmitter, type EventMap, type MergeEventMaps, } from './events';
|
|
3
|
+
export { createLocalStorageRowStore, createLocalStorageSnapshotStore, createMemoryRowStore, createMemorySnapshotStore, createSessionStorageRowStore, createSessionStorageSnapshotStore, createWebRowStore, createWebSnapshotStore, StorageCodecError, type JsonCodec, type MemoryRowStore, type MemorySnapshotStore, type WebRowStoreOptions, type WebSnapshotStoreOptions, type WebStorageLike, } from './persist';
|
|
4
|
+
export { buildQueue, createId, QueueFullError, withRowPersist, withSnapshotPersist, withWorker, type BuildQueueOptions, type Queue, type QueueEvents, type QueueWithRowPersist, type QueueWithSnapshotPersist, type QueueWithWorker, type RowPersistEvents, type RowPersistOptions, type RowRecord, type RowStore, type SnapshotPersistEvents, type SnapshotPersistOptions, type SnapshotStore, type WithWorkerOptions, type WorkerControls, type WorkerEvents, } from './queue';
|
|
5
|
+
export { buildRouter, isValidPattern, isValidTopic, matchTopic, MULTI_WILDCARD, SINGLE_WILDCARD, TOPIC_SEPARATOR, type Binding, type BuildRouterOptions, type RouteMessage, type RouteTarget, type Router, type RouterEvents, type UnmatchedRecord, } from './router';
|
|
6
|
+
export { pipeline, RetryExhaustedError, withRetry, type RetryOptions, type StepFn, type WorkerFn, } from './worker';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|