lonnymq 1.0.2 → 1.2.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/dist/index.d.ts DELETED
@@ -1,281 +0,0 @@
1
- // Generated by dts-bundle-generator v9.5.1
2
-
3
- export type DatabaseClientQueryResult = {
4
- rows: Array<Record<string, unknown>>;
5
- };
6
- export interface DatabaseClient {
7
- query(query: string, params: Array<unknown>): Promise<DatabaseClientQueryResult>;
8
- }
9
- export type DatabaseClientAdaptor<T> = (client: T) => DatabaseClient;
10
- export type MessageDeferCommandResultMessageNotFound = {
11
- resultType: "MESSAGE_NOT_FOUND";
12
- };
13
- export type MessageDeferCommandResultStateInvalid = {
14
- resultType: "STATE_INVALID";
15
- };
16
- export type MessageDeferCommandResultMessageDeferred = {
17
- resultType: "MESSAGE_DEFERRED";
18
- };
19
- export type MessageDeferCommandResult = MessageDeferCommandResultMessageNotFound | MessageDeferCommandResultStateInvalid | MessageDeferCommandResultMessageDeferred;
20
- export declare class MessageDeferCommand {
21
- readonly schema: string;
22
- readonly id: bigint;
23
- readonly numAttempts: number;
24
- readonly state: Buffer | null;
25
- readonly dequeueAt: number | null;
26
- constructor(params: {
27
- schema: string;
28
- id: bigint;
29
- numAttempts: number;
30
- state: Buffer | null;
31
- dequeueAt: number | null;
32
- });
33
- execute(databaseClient: DatabaseClient): Promise<MessageDeferCommandResult>;
34
- }
35
- export type MessageDeleteCommandResultMessageNotFound = {
36
- resultType: "MESSAGE_NOT_FOUND";
37
- };
38
- export type MessageDeleteCommandResultStateInvalid = {
39
- resultType: "STATE_INVALID";
40
- };
41
- export type MessageDeleteCommandResultMessageDeleted = {
42
- resultType: "MESSAGE_DELETED";
43
- };
44
- export type MessageDeleteCommandResult = MessageDeleteCommandResultMessageNotFound | MessageDeleteCommandResultStateInvalid | MessageDeleteCommandResultMessageDeleted;
45
- export declare class MessageDeleteCommand {
46
- readonly schema: string;
47
- readonly id: bigint;
48
- readonly numAttempts: number;
49
- constructor(params: {
50
- schema: string;
51
- numAttempts: number;
52
- id: bigint;
53
- });
54
- execute(databaseClient: DatabaseClient): Promise<MessageDeleteCommandResult>;
55
- }
56
- export type MessageHeartbeatCommandResultMessageNotFound = {
57
- resultType: "MESSAGE_NOT_FOUND";
58
- };
59
- export type MessageHeartbeatCommandResultStateInvalid = {
60
- resultType: "MESSAGE_STATE_INVALID";
61
- };
62
- export type MessageHeartbeatCommandResultMessageHeartbeated = {
63
- resultType: "MESSAGE_HEARTBEATED";
64
- };
65
- export type MessageHeartbeatCommandResult = MessageHeartbeatCommandResultMessageNotFound | MessageHeartbeatCommandResultStateInvalid | MessageHeartbeatCommandResultMessageHeartbeated;
66
- export declare class MessageHeartbeatCommand {
67
- readonly schema: string;
68
- readonly id: bigint;
69
- readonly numAttempts: number;
70
- readonly lockMs: number;
71
- constructor(params: {
72
- schema: string;
73
- id: bigint;
74
- numAttempts: number;
75
- lockMs: number;
76
- });
77
- execute(databaseClient: DatabaseClient): Promise<MessageHeartbeatCommandResult>;
78
- }
79
- export declare class QueueMessage<T> {
80
- private readonly schema;
81
- private readonly adaptor;
82
- readonly id: bigint;
83
- readonly isUnlocked: boolean;
84
- readonly channelId: string;
85
- readonly content: Buffer;
86
- readonly state: Buffer | null;
87
- readonly numAttempts: number;
88
- constructor(params: {
89
- schema: string;
90
- adaptor: DatabaseClientAdaptor<T>;
91
- id: bigint;
92
- channelId: string;
93
- isUnlocked: boolean;
94
- content: Buffer;
95
- state: Buffer | null;
96
- numAttempts: number;
97
- });
98
- defer(params: {
99
- databaseClient: T;
100
- state?: Buffer;
101
- dequeueAt?: number;
102
- }): Promise<MessageDeferCommandResult>;
103
- delete(params: {
104
- databaseClient: T;
105
- }): Promise<MessageDeleteCommandResult>;
106
- heartbeat(params: {
107
- databaseClient: T;
108
- lockMs: number;
109
- }): Promise<MessageHeartbeatCommandResult>;
110
- }
111
- export type MessageCreateCommandResultMessageCreated = {
112
- resultType: "MESSAGE_CREATED";
113
- id: bigint;
114
- channelSize: number;
115
- };
116
- export type MessageCreateCommandResultMessageDropped = {
117
- resultType: "MESSAGE_DROPPED";
118
- };
119
- export type MessageCreateCommandResult = MessageCreateCommandResultMessageCreated | MessageCreateCommandResultMessageDropped;
120
- export declare class MessageCreateCommand {
121
- readonly schema: string;
122
- readonly channelId: string;
123
- readonly content: Buffer;
124
- readonly dequeueAt: number | null;
125
- constructor(params: {
126
- schema: string;
127
- channelId: string;
128
- content: Buffer;
129
- dequeueAt: number | null;
130
- });
131
- execute(databaseClient: DatabaseClient): Promise<MessageCreateCommandResult>;
132
- }
133
- export declare class QueueMessageModule<T> {
134
- private readonly schema;
135
- private readonly adaptor;
136
- constructor(params: {
137
- schema: string;
138
- adaptor: DatabaseClientAdaptor<T>;
139
- });
140
- create(params: {
141
- databaseClient: T;
142
- content: Buffer;
143
- dequeueAt?: number;
144
- }): Promise<MessageCreateCommandResult>;
145
- }
146
- export declare class QueueChannelMessageModule<T> {
147
- private readonly schema;
148
- private readonly channelId;
149
- private readonly adaptor;
150
- constructor(params: {
151
- schema: string;
152
- adaptor: DatabaseClientAdaptor<T>;
153
- channelId: string;
154
- });
155
- create(params: {
156
- databaseClient: T;
157
- content: Buffer;
158
- dequeueAt?: number;
159
- }): Promise<MessageCreateCommandResult>;
160
- }
161
- export declare class QueueChannelPolicyModule<T> {
162
- private readonly schema;
163
- private readonly adaptor;
164
- private readonly channelId;
165
- constructor(params: {
166
- schema: string;
167
- adaptor: DatabaseClientAdaptor<T>;
168
- channelId: string;
169
- });
170
- set(params: {
171
- databaseClient: T;
172
- maxConcurrency?: number | null;
173
- maxSize?: number | null;
174
- releaseIntervalMs?: number | null;
175
- }): Promise<void>;
176
- clear(params: {
177
- databaseClient: T;
178
- }): Promise<void>;
179
- }
180
- export declare class QueueChannelModule<T> {
181
- readonly policy: QueueChannelPolicyModule<T>;
182
- readonly message: QueueChannelMessageModule<T>;
183
- constructor(params: {
184
- schema: string;
185
- adaptor: DatabaseClientAdaptor<T>;
186
- channelId: string;
187
- });
188
- }
189
- export type QueueEventMessageCreate = {
190
- eventType: "MESSAGE_CREATED";
191
- id: string;
192
- dequeueAt: number;
193
- };
194
- export type QueueEventMessageDeleted = {
195
- eventType: "MESSAGE_DELETED";
196
- id: string;
197
- };
198
- export type QueueEventMessageDeferred = {
199
- eventType: "MESSAGE_DEFERRED";
200
- id: string;
201
- dequeueAt: number;
202
- };
203
- export type QueueEvent = QueueEventMessageCreate | QueueEventMessageDeleted | QueueEventMessageDeferred;
204
- export declare class ChannelPolicyClearCommand {
205
- readonly schema: string;
206
- readonly channelId: string;
207
- readonly createdAt: Date;
208
- constructor(params: {
209
- schema: string;
210
- channelId: string;
211
- });
212
- execute(databaseClient: DatabaseClient): Promise<void>;
213
- }
214
- export declare class ChannelPolicySetCommand {
215
- readonly schema: string;
216
- readonly channelId: string;
217
- readonly maxConcurrency: number | null;
218
- readonly maxSize: number | null;
219
- readonly releaseIntervalMs: number | null;
220
- readonly createdAt: Date;
221
- constructor(params: {
222
- schema: string;
223
- channelId: string;
224
- maxConcurrency?: number | null;
225
- maxSize?: number | null;
226
- releaseIntervalMs?: number | null;
227
- });
228
- execute(databaseClient: DatabaseClient): Promise<void>;
229
- }
230
- export type MessageDequeueCommandResultMessageDequeued = {
231
- resultType: "MESSAGE_DEQUEUED";
232
- id: bigint;
233
- channelId: string;
234
- isUnlocked: boolean;
235
- content: Buffer;
236
- state: Buffer | null;
237
- numAttempts: number;
238
- };
239
- export type MessageDequeueCommandResultMessageNotAvailable = {
240
- resultType: "MESSAGE_NOT_AVAILABLE";
241
- };
242
- export type MessageDequeueCommandResult = MessageDequeueCommandResultMessageDequeued | MessageDequeueCommandResultMessageNotAvailable;
243
- export declare class MessageDequeueCommand {
244
- readonly schema: string;
245
- readonly lockMs: number;
246
- constructor(params: {
247
- schema: string;
248
- lockMs: number;
249
- });
250
- execute(databaseClient: DatabaseClient): Promise<MessageDequeueCommandResult>;
251
- }
252
- export type QueueMessageDequeueResult<T> = {
253
- resultType: "MESSAGE_NOT_AVAILABLE";
254
- } | {
255
- resultType: "MESSAGE_DEQUEUED";
256
- message: QueueMessage<T>;
257
- };
258
- export type QueueParams<T> = T extends DatabaseClient ? {
259
- schema: string;
260
- adaptor?: DatabaseClientAdaptor<T>;
261
- } : {
262
- schema: string;
263
- adaptor: DatabaseClientAdaptor<T>;
264
- };
265
- export declare class Queue<T = DatabaseClient> {
266
- readonly schema: string;
267
- readonly message: QueueMessageModule<T>;
268
- private readonly adaptor;
269
- constructor(params: QueueParams<T>);
270
- dequeue(params: {
271
- databaseClient: T;
272
- lockMs: number;
273
- }): Promise<QueueMessageDequeueResult<T>>;
274
- channel(channelId: string): QueueChannelModule<T>;
275
- install(params?: {
276
- eventChannel?: string;
277
- }): string[];
278
- static decode(payload: string): QueueEvent;
279
- }
280
-
281
- export {};