@gravito/stream 1.0.0-alpha.6 → 1.0.0-beta.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/README.md +8 -3
- package/dist/index.cjs +1016 -31676
- package/dist/index.d.cts +1132 -0
- package/dist/index.d.ts +1123 -36
- package/dist/index.js +1412 -0
- package/package.json +3 -3
- package/dist/Consumer.d.ts +0 -67
- package/dist/Consumer.d.ts.map +0 -1
- package/dist/Job.d.ts +0 -76
- package/dist/Job.d.ts.map +0 -1
- package/dist/OrbitQueue.d.ts +0 -74
- package/dist/OrbitQueue.d.ts.map +0 -1
- package/dist/QueueManager.d.ts +0 -86
- package/dist/QueueManager.d.ts.map +0 -1
- package/dist/Queueable.d.ts +0 -63
- package/dist/Queueable.d.ts.map +0 -1
- package/dist/Worker.d.ts +0 -48
- package/dist/Worker.d.ts.map +0 -1
- package/dist/core/src/ConfigManager.d.ts +0 -26
- package/dist/core/src/ConfigManager.d.ts.map +0 -1
- package/dist/core/src/Container.d.ts +0 -39
- package/dist/core/src/Container.d.ts.map +0 -1
- package/dist/core/src/Event.d.ts +0 -6
- package/dist/core/src/Event.d.ts.map +0 -1
- package/dist/core/src/EventManager.d.ts +0 -124
- package/dist/core/src/EventManager.d.ts.map +0 -1
- package/dist/core/src/GlobalErrorHandlers.d.ts +0 -32
- package/dist/core/src/GlobalErrorHandlers.d.ts.map +0 -1
- package/dist/core/src/HookManager.d.ts +0 -29
- package/dist/core/src/HookManager.d.ts.map +0 -1
- package/dist/core/src/Listener.d.ts +0 -5
- package/dist/core/src/Listener.d.ts.map +0 -1
- package/dist/core/src/Logger.d.ts +0 -21
- package/dist/core/src/Logger.d.ts.map +0 -1
- package/dist/core/src/PlanetCore.d.ts +0 -116
- package/dist/core/src/PlanetCore.d.ts.map +0 -1
- package/dist/core/src/Route.d.ts +0 -13
- package/dist/core/src/Route.d.ts.map +0 -1
- package/dist/core/src/Router.d.ts +0 -168
- package/dist/core/src/Router.d.ts.map +0 -1
- package/dist/core/src/ServiceProvider.d.ts +0 -17
- package/dist/core/src/ServiceProvider.d.ts.map +0 -1
- package/dist/core/src/exceptions/AuthenticationException.d.ts +0 -5
- package/dist/core/src/exceptions/AuthenticationException.d.ts.map +0 -1
- package/dist/core/src/exceptions/AuthorizationException.d.ts +0 -5
- package/dist/core/src/exceptions/AuthorizationException.d.ts.map +0 -1
- package/dist/core/src/exceptions/GravitoException.d.ts +0 -15
- package/dist/core/src/exceptions/GravitoException.d.ts.map +0 -1
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +0 -7
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts.map +0 -1
- package/dist/core/src/exceptions/ValidationException.d.ts +0 -15
- package/dist/core/src/exceptions/ValidationException.d.ts.map +0 -1
- package/dist/core/src/exceptions/index.d.ts +0 -6
- package/dist/core/src/exceptions/index.d.ts.map +0 -1
- package/dist/core/src/helpers/Arr.d.ts +0 -15
- package/dist/core/src/helpers/Arr.d.ts.map +0 -1
- package/dist/core/src/helpers/Str.d.ts +0 -19
- package/dist/core/src/helpers/Str.d.ts.map +0 -1
- package/dist/core/src/helpers/data.d.ts +0 -6
- package/dist/core/src/helpers/data.d.ts.map +0 -1
- package/dist/core/src/helpers/errors.d.ts +0 -13
- package/dist/core/src/helpers/errors.d.ts.map +0 -1
- package/dist/core/src/helpers/response.d.ts +0 -19
- package/dist/core/src/helpers/response.d.ts.map +0 -1
- package/dist/core/src/helpers.d.ts +0 -39
- package/dist/core/src/helpers.d.ts.map +0 -1
- package/dist/core/src/http/CookieJar.d.ts +0 -34
- package/dist/core/src/http/CookieJar.d.ts.map +0 -1
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -13
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts.map +0 -1
- package/dist/core/src/index.d.ts +0 -32
- package/dist/core/src/index.d.ts.map +0 -1
- package/dist/core/src/security/Encrypter.d.ts +0 -25
- package/dist/core/src/security/Encrypter.d.ts.map +0 -1
- package/dist/core/src/security/Hasher.d.ts +0 -30
- package/dist/core/src/security/Hasher.d.ts.map +0 -1
- package/dist/core/src/types/events.d.ts +0 -95
- package/dist/core/src/types/events.d.ts.map +0 -1
- package/dist/drivers/DatabaseDriver.d.ts +0 -60
- package/dist/drivers/DatabaseDriver.d.ts.map +0 -1
- package/dist/drivers/KafkaDriver.d.ts +0 -134
- package/dist/drivers/KafkaDriver.d.ts.map +0 -1
- package/dist/drivers/MemoryDriver.d.ts +0 -45
- package/dist/drivers/MemoryDriver.d.ts.map +0 -1
- package/dist/drivers/QueueDriver.d.ts +0 -89
- package/dist/drivers/QueueDriver.d.ts.map +0 -1
- package/dist/drivers/RedisDriver.d.ts +0 -79
- package/dist/drivers/RedisDriver.d.ts.map +0 -1
- package/dist/drivers/SQSDriver.d.ts +0 -100
- package/dist/drivers/SQSDriver.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -422
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -32096
- package/dist/index.mjs.map +0 -422
- package/dist/orbit-db/src/DBService.d.ts +0 -270
- package/dist/orbit-db/src/DBService.d.ts.map +0 -1
- package/dist/orbit-db/src/EventBus.d.ts +0 -53
- package/dist/orbit-db/src/EventBus.d.ts.map +0 -1
- package/dist/orbit-db/src/MigrationDriver.d.ts +0 -55
- package/dist/orbit-db/src/MigrationDriver.d.ts.map +0 -1
- package/dist/orbit-db/src/Model.d.ts +0 -564
- package/dist/orbit-db/src/Model.d.ts.map +0 -1
- package/dist/orbit-db/src/ModelCollection.d.ts +0 -35
- package/dist/orbit-db/src/ModelCollection.d.ts.map +0 -1
- package/dist/orbit-db/src/index.d.ts +0 -34
- package/dist/orbit-db/src/index.d.ts.map +0 -1
- package/dist/orbit-db/src/types.d.ts +0 -146
- package/dist/orbit-db/src/types.d.ts.map +0 -1
- package/dist/orbit-queue/src/Consumer.d.ts +0 -67
- package/dist/orbit-queue/src/Consumer.d.ts.map +0 -1
- package/dist/orbit-queue/src/Job.d.ts +0 -76
- package/dist/orbit-queue/src/Job.d.ts.map +0 -1
- package/dist/orbit-queue/src/OrbitQueue.d.ts +0 -74
- package/dist/orbit-queue/src/OrbitQueue.d.ts.map +0 -1
- package/dist/orbit-queue/src/QueueManager.d.ts +0 -86
- package/dist/orbit-queue/src/QueueManager.d.ts.map +0 -1
- package/dist/orbit-queue/src/Queueable.d.ts +0 -63
- package/dist/orbit-queue/src/Queueable.d.ts.map +0 -1
- package/dist/orbit-queue/src/Worker.d.ts +0 -48
- package/dist/orbit-queue/src/Worker.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/DatabaseDriver.d.ts +0 -60
- package/dist/orbit-queue/src/drivers/DatabaseDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/KafkaDriver.d.ts +0 -134
- package/dist/orbit-queue/src/drivers/KafkaDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/MemoryDriver.d.ts +0 -45
- package/dist/orbit-queue/src/drivers/MemoryDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/QueueDriver.d.ts +0 -89
- package/dist/orbit-queue/src/drivers/QueueDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/RedisDriver.d.ts +0 -79
- package/dist/orbit-queue/src/drivers/RedisDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/SQSDriver.d.ts +0 -100
- package/dist/orbit-queue/src/drivers/SQSDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/index.d.ts +0 -45
- package/dist/orbit-queue/src/index.d.ts.map +0 -1
- package/dist/orbit-queue/src/serializers/ClassNameSerializer.d.ts +0 -46
- package/dist/orbit-queue/src/serializers/ClassNameSerializer.d.ts.map +0 -1
- package/dist/orbit-queue/src/serializers/JobSerializer.d.ts +0 -36
- package/dist/orbit-queue/src/serializers/JobSerializer.d.ts.map +0 -1
- package/dist/orbit-queue/src/serializers/JsonSerializer.d.ts +0 -32
- package/dist/orbit-queue/src/serializers/JsonSerializer.d.ts.map +0 -1
- package/dist/orbit-queue/src/types.d.ts +0 -85
- package/dist/orbit-queue/src/types.d.ts.map +0 -1
- package/dist/serializers/ClassNameSerializer.d.ts +0 -46
- package/dist/serializers/ClassNameSerializer.d.ts.map +0 -1
- package/dist/serializers/JobSerializer.d.ts +0 -36
- package/dist/serializers/JobSerializer.d.ts.map +0 -1
- package/dist/serializers/JsonSerializer.d.ts +0 -32
- package/dist/serializers/JsonSerializer.d.ts.map +0 -1
- package/dist/types.d.ts +0 -85
- package/dist/types.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravito/stream",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@aws-sdk/client-sqs": "^3.955.0",
|
|
43
|
-
"gravito-core": "1.0.0-beta.
|
|
43
|
+
"gravito-core": "1.0.0-beta.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@gravito/db": "1.0.0-alpha.6",
|
|
47
46
|
"bun-types": "latest",
|
|
47
|
+
"tsup": "^8.5.1",
|
|
48
48
|
"typescript": "^5.9.3"
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/gravito-framework/gravito#readme",
|
package/dist/Consumer.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { QueueManager } from './QueueManager';
|
|
2
|
-
import type { WorkerOptions } from './Worker';
|
|
3
|
-
/**
|
|
4
|
-
* Consumer options.
|
|
5
|
-
*/
|
|
6
|
-
export interface ConsumerOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Queues to listen on.
|
|
9
|
-
*/
|
|
10
|
-
queues: string[];
|
|
11
|
-
/**
|
|
12
|
-
* Connection name.
|
|
13
|
-
*/
|
|
14
|
-
connection?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Worker options.
|
|
17
|
-
*/
|
|
18
|
-
workerOptions?: WorkerOptions;
|
|
19
|
-
/**
|
|
20
|
-
* Polling interval (milliseconds).
|
|
21
|
-
*/
|
|
22
|
-
pollInterval?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Whether to keep polling when queues are empty.
|
|
25
|
-
*/
|
|
26
|
-
keepAlive?: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Consumer
|
|
30
|
-
*
|
|
31
|
-
* Consumes and executes jobs from queues.
|
|
32
|
-
* Supports embedded mode (inside the main app) and standalone mode (as a worker service).
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* // Embedded mode
|
|
37
|
-
* const consumer = new Consumer(queueManager, {
|
|
38
|
-
* queues: ['default', 'emails'],
|
|
39
|
-
* pollInterval: 1000
|
|
40
|
-
* })
|
|
41
|
-
*
|
|
42
|
-
* consumer.start()
|
|
43
|
-
*
|
|
44
|
-
* // Standalone mode (CLI)
|
|
45
|
-
* // Start via CLI tooling with graceful shutdown
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare class Consumer {
|
|
49
|
-
private queueManager;
|
|
50
|
-
private options;
|
|
51
|
-
private running;
|
|
52
|
-
private stopRequested;
|
|
53
|
-
constructor(queueManager: QueueManager, options: ConsumerOptions);
|
|
54
|
-
/**
|
|
55
|
-
* Start the consumer loop.
|
|
56
|
-
*/
|
|
57
|
-
start(): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Stop the consumer loop (graceful shutdown).
|
|
60
|
-
*/
|
|
61
|
-
stop(): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Check whether the consumer is running.
|
|
64
|
-
*/
|
|
65
|
-
isRunning(): boolean;
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=Consumer.d.ts.map
|
package/dist/Consumer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Consumer.d.ts","sourceRoot":"","sources":["../src/Consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAA;IAEhB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAE7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,QAAQ;IAKjB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,OAAO;IALjB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,aAAa,CAAQ;gBAGnB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,eAAe;IAGlC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmD5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB"}
|
package/dist/Job.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { Queueable } from './Queueable';
|
|
2
|
-
/**
|
|
3
|
-
* Base Job.
|
|
4
|
-
*
|
|
5
|
-
* All tasks that should be pushed to a queue should extend this class.
|
|
6
|
-
* Implements the `Queueable` interface, providing a fluent API for queue/connection/delay.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* class SendWelcomeEmail extends Job {
|
|
11
|
-
* constructor(private userId: string) {
|
|
12
|
-
* super()
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* async handle(): Promise<void> {
|
|
16
|
-
* const user = await User.find(this.userId)
|
|
17
|
-
* await mail.send(new WelcomeEmail(user))
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* // Usage
|
|
22
|
-
* await queue.push(new SendWelcomeEmail('123'))
|
|
23
|
-
* .onQueue('emails')
|
|
24
|
-
* .delay(60)
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare abstract class Job implements Queueable {
|
|
28
|
-
/**
|
|
29
|
-
* Queue name.
|
|
30
|
-
*/
|
|
31
|
-
queueName?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Connection name.
|
|
34
|
-
*/
|
|
35
|
-
connectionName?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Delay before execution (seconds).
|
|
38
|
-
*/
|
|
39
|
-
delaySeconds?: number;
|
|
40
|
-
/**
|
|
41
|
-
* Current attempt number.
|
|
42
|
-
*/
|
|
43
|
-
attempts?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Maximum attempts.
|
|
46
|
-
*/
|
|
47
|
-
maxAttempts?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Set target queue.
|
|
50
|
-
*/
|
|
51
|
-
onQueue(queue: string): this;
|
|
52
|
-
/**
|
|
53
|
-
* Set target connection.
|
|
54
|
-
*/
|
|
55
|
-
onConnection(connection: string): this;
|
|
56
|
-
/**
|
|
57
|
-
* Set delay (seconds).
|
|
58
|
-
*/
|
|
59
|
-
delay(delay: number): this;
|
|
60
|
-
/**
|
|
61
|
-
* Job handler logic.
|
|
62
|
-
*
|
|
63
|
-
* Subclasses must implement this method.
|
|
64
|
-
*/
|
|
65
|
-
abstract handle(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Failure handler (optional).
|
|
68
|
-
*
|
|
69
|
-
* Called when the job fails and reaches the maximum number of attempts.
|
|
70
|
-
* Subclasses can override to implement custom failure handling.
|
|
71
|
-
*
|
|
72
|
-
* @param error - Error instance
|
|
73
|
-
*/
|
|
74
|
-
failed(_error: Error): Promise<void>;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=Job.d.ts.map
|
package/dist/Job.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Job.d.ts","sourceRoot":"","sources":["../src/Job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8BAAsB,GAAI,YAAW,SAAS;IAC5C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKtC;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3C"}
|
package/dist/OrbitQueue.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { GravitoOrbit, PlanetCore } from 'gravito-core';
|
|
2
|
-
import type { ConsumerOptions } from './Consumer';
|
|
3
|
-
import { QueueManager } from './QueueManager';
|
|
4
|
-
import type { QueueConfig } from './types';
|
|
5
|
-
/**
|
|
6
|
-
* Orbit Queue configuration options.
|
|
7
|
-
*/
|
|
8
|
-
export interface OrbitQueueOptions extends QueueConfig {
|
|
9
|
-
/**
|
|
10
|
-
* Whether to auto-start an embedded worker in development.
|
|
11
|
-
*/
|
|
12
|
-
autoStartWorker?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Embedded worker options.
|
|
15
|
-
*/
|
|
16
|
-
workerOptions?: ConsumerOptions;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Orbit Queue
|
|
20
|
-
*
|
|
21
|
-
* Gravito Orbit implementation providing queue functionality.
|
|
22
|
-
* Integrates with PlanetCore and injects a `queue` service into the Hono Context.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const core = await PlanetCore.boot({
|
|
27
|
-
* orbits: [
|
|
28
|
-
* OrbitQueue.configure({
|
|
29
|
-
* default: 'database',
|
|
30
|
-
* connections: {
|
|
31
|
-
* database: { driver: 'database', table: 'jobs' }
|
|
32
|
-
* }
|
|
33
|
-
* })
|
|
34
|
-
* ]
|
|
35
|
-
* })
|
|
36
|
-
*
|
|
37
|
-
* // Use in a controller/handler
|
|
38
|
-
* const queue = c.get('queue')
|
|
39
|
-
* await queue.push(new SendEmail('user@example.com'))
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare class OrbitQueue implements GravitoOrbit {
|
|
43
|
-
private options;
|
|
44
|
-
private queueManager?;
|
|
45
|
-
private consumer?;
|
|
46
|
-
constructor(options?: OrbitQueueOptions);
|
|
47
|
-
/**
|
|
48
|
-
* Static configuration helper.
|
|
49
|
-
*/
|
|
50
|
-
static configure(options: OrbitQueueOptions): OrbitQueue;
|
|
51
|
-
/**
|
|
52
|
-
* Install into PlanetCore.
|
|
53
|
-
*/
|
|
54
|
-
install(core: PlanetCore): void;
|
|
55
|
-
/**
|
|
56
|
-
* Start embedded worker.
|
|
57
|
-
*/
|
|
58
|
-
startWorker(options: ConsumerOptions): void;
|
|
59
|
-
/**
|
|
60
|
-
* Stop embedded worker.
|
|
61
|
-
*/
|
|
62
|
-
stopWorker(): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Get QueueManager instance.
|
|
65
|
-
*/
|
|
66
|
-
getQueueManager(): QueueManager | undefined;
|
|
67
|
-
}
|
|
68
|
-
declare module 'hono' {
|
|
69
|
-
interface ContextVariableMap {
|
|
70
|
-
queue: QueueManager;
|
|
71
|
-
db?: unknown;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=OrbitQueue.d.ts.map
|
package/dist/OrbitQueue.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrbitQueue.d.ts","sourceRoot":"","sources":["../src/OrbitQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;OAEG;IACH,aAAa,CAAC,EAAE,eAAe,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAW,YAAW,YAAY;IAIjC,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,YAAY,CAAC,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,CAAU;gBAEP,OAAO,GAAE,iBAAsB;IAEnD;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU;IAIxD;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAqD/B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAe3C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC;;OAEG;IACH,eAAe,IAAI,YAAY,GAAG,SAAS;CAG5C;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,kBAAkB;QAC1B,KAAK,EAAE,YAAY,CAAA;QACnB,EAAE,CAAC,EAAE,OAAO,CAAA;KACb;CACF"}
|
package/dist/QueueManager.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { QueueDriver } from './drivers/QueueDriver';
|
|
2
|
-
import type { Job } from './Job';
|
|
3
|
-
import type { Queueable } from './Queueable';
|
|
4
|
-
import type { JobSerializer } from './serializers/JobSerializer';
|
|
5
|
-
import type { QueueConfig } from './types';
|
|
6
|
-
/**
|
|
7
|
-
* Queue Manager
|
|
8
|
-
*
|
|
9
|
-
* Manages multiple queue connections and drivers, exposing a unified API for pushing and consuming jobs.
|
|
10
|
-
* Supports lazy-loading drivers to keep the core lightweight.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const manager = new QueueManager({
|
|
15
|
-
* default: 'database',
|
|
16
|
-
* connections: {
|
|
17
|
-
* database: { driver: 'database', table: 'jobs' },
|
|
18
|
-
* redis: { driver: 'redis', url: 'redis://...' }
|
|
19
|
-
* }
|
|
20
|
-
* })
|
|
21
|
-
*
|
|
22
|
-
* await manager.push(new SendEmail('user@example.com'))
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare class QueueManager {
|
|
26
|
-
private drivers;
|
|
27
|
-
private serializers;
|
|
28
|
-
private defaultConnection;
|
|
29
|
-
private defaultSerializer;
|
|
30
|
-
constructor(config?: QueueConfig);
|
|
31
|
-
/**
|
|
32
|
-
* Register a connection.
|
|
33
|
-
* @param name - Connection name
|
|
34
|
-
* @param config - Connection config
|
|
35
|
-
*/
|
|
36
|
-
registerConnection(name: string, config: unknown): void;
|
|
37
|
-
/**
|
|
38
|
-
* Get a driver for a connection.
|
|
39
|
-
* @param connection - Connection name
|
|
40
|
-
* @returns Driver instance
|
|
41
|
-
*/
|
|
42
|
-
getDriver(connection: string): QueueDriver;
|
|
43
|
-
/**
|
|
44
|
-
* Get a serializer.
|
|
45
|
-
* @param type - Serializer type
|
|
46
|
-
* @returns Serializer instance
|
|
47
|
-
*/
|
|
48
|
-
getSerializer(type?: string): JobSerializer;
|
|
49
|
-
/**
|
|
50
|
-
* Register Job classes (used by ClassNameSerializer).
|
|
51
|
-
* @param jobClasses - Job class array
|
|
52
|
-
*/
|
|
53
|
-
registerJobClasses(jobClasses: Array<new (...args: unknown[]) => Job>): void;
|
|
54
|
-
/**
|
|
55
|
-
* Push a Job to the queue.
|
|
56
|
-
* @param job - Job instance
|
|
57
|
-
* @returns The same job instance (for fluent chaining)
|
|
58
|
-
*/
|
|
59
|
-
push<T extends Job & Queueable>(job: T): Promise<T>;
|
|
60
|
-
/**
|
|
61
|
-
* Push multiple jobs.
|
|
62
|
-
* @param jobs - Job array
|
|
63
|
-
*/
|
|
64
|
-
pushMany<T extends Job & Queueable>(jobs: T[]): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Pop a job from the queue.
|
|
67
|
-
* @param queue - Queue name
|
|
68
|
-
* @param connection - Connection name
|
|
69
|
-
* @returns Job instance or null
|
|
70
|
-
*/
|
|
71
|
-
pop(queue?: string, connection?: string): Promise<Job | null>;
|
|
72
|
-
/**
|
|
73
|
-
* Get queue size.
|
|
74
|
-
* @param queue - Queue name
|
|
75
|
-
* @param connection - Connection name
|
|
76
|
-
* @returns Number of jobs in the queue
|
|
77
|
-
*/
|
|
78
|
-
size(queue?: string, connection?: string): Promise<number>;
|
|
79
|
-
/**
|
|
80
|
-
* Clear a queue.
|
|
81
|
-
* @param queue - Queue name
|
|
82
|
-
* @param connection - Connection name
|
|
83
|
-
*/
|
|
84
|
-
clear(queue?: string, connection?: string): Promise<void>;
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=QueueManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueueManager.d.ts","sourceRoot":"","sources":["../src/QueueManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAA;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,iBAAiB,CAAe;gBAE5B,MAAM,GAAE,WAAgB;IAwBpC;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IA6FvD;;;;OAIG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW;IAQ1C;;;;OAIG;IACH,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa;IAW3C;;;OAGG;IACH,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,IAAI;IAM5E;;;;OAIG;IACG,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAezD;;;OAGG;IACG,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCnE;;;;;OAKG;IACG,GAAG,CAAC,KAAK,SAAY,EAAE,UAAU,GAAE,MAA+B,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAkB9F;;;;;OAKG;IACG,IAAI,CAAC,KAAK,SAAY,EAAE,UAAU,GAAE,MAA+B,GAAG,OAAO,CAAC,MAAM,CAAC;IAK3F;;;;OAIG;IACG,KAAK,CAAC,KAAK,SAAY,EAAE,UAAU,GAAE,MAA+B,GAAG,OAAO,CAAC,IAAI,CAAC;CAI3F"}
|
package/dist/Queueable.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queueable interface.
|
|
3
|
-
*
|
|
4
|
-
* Classes implementing this interface can be pushed to a queue for execution.
|
|
5
|
-
* Provides a fluent API for queue/connection/delay configuration.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* class MyJob implements Queueable {
|
|
10
|
-
* queueName?: string
|
|
11
|
-
* connectionName?: string
|
|
12
|
-
* delaySeconds?: number
|
|
13
|
-
*
|
|
14
|
-
* onQueue(queue: string): this {
|
|
15
|
-
* this.queueName = queue
|
|
16
|
-
* return this
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* onConnection(connection: string): this {
|
|
20
|
-
* this.connectionName = connection
|
|
21
|
-
* return this
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* delay(seconds: number): this {
|
|
25
|
-
* this.delaySeconds = seconds
|
|
26
|
-
* return this
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export interface Queueable {
|
|
32
|
-
/**
|
|
33
|
-
* Queue name where the job should be pushed.
|
|
34
|
-
*/
|
|
35
|
-
queueName?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Connection name the job should use.
|
|
38
|
-
*/
|
|
39
|
-
connectionName?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Delay before execution (seconds).
|
|
42
|
-
*/
|
|
43
|
-
delaySeconds?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Set target queue.
|
|
46
|
-
* @param queue - Queue name
|
|
47
|
-
* @returns Self for fluent chaining
|
|
48
|
-
*/
|
|
49
|
-
onQueue(queue: string): this;
|
|
50
|
-
/**
|
|
51
|
-
* Set target connection.
|
|
52
|
-
* @param connection - Connection name
|
|
53
|
-
* @returns Self for fluent chaining
|
|
54
|
-
*/
|
|
55
|
-
onConnection(connection: string): this;
|
|
56
|
-
/**
|
|
57
|
-
* Set delay (seconds).
|
|
58
|
-
* @param delay - Delay seconds
|
|
59
|
-
* @returns Self for fluent chaining
|
|
60
|
-
*/
|
|
61
|
-
delay(delay: number): this;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=Queueable.d.ts.map
|
package/dist/Queueable.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Queueable.d.ts","sourceRoot":"","sources":["../src/Queueable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;;;OAIG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B"}
|
package/dist/Worker.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Job } from './Job';
|
|
2
|
-
/**
|
|
3
|
-
* Worker options.
|
|
4
|
-
*/
|
|
5
|
-
export interface WorkerOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Maximum retry attempts.
|
|
8
|
-
*/
|
|
9
|
-
maxAttempts?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Job timeout (seconds).
|
|
12
|
-
*/
|
|
13
|
-
timeout?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Failure callback.
|
|
16
|
-
*/
|
|
17
|
-
onFailed?: (job: Job, error: Error) => Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Base Worker.
|
|
21
|
-
*
|
|
22
|
-
* Responsible for executing `Job` instances.
|
|
23
|
-
* Provides error handling, retry logic, and timeout support.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const worker = new Worker({
|
|
28
|
-
* maxAttempts: 3,
|
|
29
|
-
* timeout: 60
|
|
30
|
-
* })
|
|
31
|
-
*
|
|
32
|
-
* await worker.process(job)
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare class Worker {
|
|
36
|
-
private options;
|
|
37
|
-
constructor(options?: WorkerOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Process a Job.
|
|
40
|
-
* @param job - Job instance
|
|
41
|
-
*/
|
|
42
|
-
process(job: Job): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Handle failure.
|
|
45
|
-
*/
|
|
46
|
-
private handleFailure;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=Worker.d.ts.map
|
package/dist/Worker.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../src/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACrD;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,MAAM;IACL,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,aAAkB;IAE/C;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CtC;;OAEG;YACW,aAAa;CAiB5B"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration manager (ConfigManager)
|
|
3
|
-
*
|
|
4
|
-
* Unifies environment variables and application configuration access.
|
|
5
|
-
*/
|
|
6
|
-
export declare class ConfigManager {
|
|
7
|
-
private config;
|
|
8
|
-
constructor(initialConfig?: Record<string, unknown>);
|
|
9
|
-
/**
|
|
10
|
-
* Load all environment variables from `Bun.env`.
|
|
11
|
-
*/
|
|
12
|
-
private loadEnv;
|
|
13
|
-
/**
|
|
14
|
-
* Get a configuration value (generic return type supported).
|
|
15
|
-
*/
|
|
16
|
-
get<T = unknown>(key: string, defaultValue?: T): T;
|
|
17
|
-
/**
|
|
18
|
-
* Set a configuration value.
|
|
19
|
-
*/
|
|
20
|
-
set(key: string, value: unknown): void;
|
|
21
|
-
/**
|
|
22
|
-
* Check whether a key exists.
|
|
23
|
-
*/
|
|
24
|
-
has(key: string): boolean;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=ConfigManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigManager.d.ts","sourceRoot":"","sources":["../../../../core/src/ConfigManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAkC;gBAEpC,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAUvD;;OAEG;IACH,OAAO,CAAC,OAAO;IASf;;OAEG;IACH,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC;IAUlD;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAItC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG1B"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Factory type for creating service instances
|
|
3
|
-
*/
|
|
4
|
-
export type Factory<T> = (container: Container) => T;
|
|
5
|
-
export declare class Container {
|
|
6
|
-
private bindings;
|
|
7
|
-
private instances;
|
|
8
|
-
/**
|
|
9
|
-
* Bind a service to the container.
|
|
10
|
-
* New instance will be created on each resolution.
|
|
11
|
-
*/
|
|
12
|
-
bind<T>(key: string, factory: Factory<T>): void;
|
|
13
|
-
/**
|
|
14
|
-
* Bind a shared service to the container (Singleton).
|
|
15
|
-
* Same instance will be returned on each resolution.
|
|
16
|
-
*/
|
|
17
|
-
singleton<T>(key: string, factory: Factory<T>): void;
|
|
18
|
-
/**
|
|
19
|
-
* Register an existing instance as shared service.
|
|
20
|
-
*/
|
|
21
|
-
instance<T>(key: string, instance: T): void;
|
|
22
|
-
/**
|
|
23
|
-
* Resolve a service from the container.
|
|
24
|
-
*/
|
|
25
|
-
make<T>(key: string): T;
|
|
26
|
-
/**
|
|
27
|
-
* Check if a service is bound.
|
|
28
|
-
*/
|
|
29
|
-
has(key: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Flush all instances and bindings.
|
|
32
|
-
*/
|
|
33
|
-
flush(): void;
|
|
34
|
-
/**
|
|
35
|
-
* Forget a specific instance (but keep binding)
|
|
36
|
-
*/
|
|
37
|
-
forget(key: string): void;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=Container.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../../core/src/Container.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,CAAA;AAOpD,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,SAAS,CAA6B;IAE9C;;;OAGG;IACH,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;IAI/C;;;OAGG;IACH,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;IAIpD;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI;IAI3C;;OAEG;IACH,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAuBvB;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAG1B"}
|
package/dist/core/src/Event.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../../../core/src/Event.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Event } from './Event';
|
|
2
|
-
import type { Listener } from './Listener';
|
|
3
|
-
import type { PlanetCore } from './PlanetCore';
|
|
4
|
-
/**
|
|
5
|
-
* Listener registration metadata.
|
|
6
|
-
*/
|
|
7
|
-
interface ListenerRegistration<TEvent extends Event = Event> {
|
|
8
|
-
listener: Listener<TEvent> | (new () => Listener<TEvent>);
|
|
9
|
-
queue?: string;
|
|
10
|
-
connection?: string;
|
|
11
|
-
delay?: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Event manager.
|
|
15
|
-
*
|
|
16
|
-
* Provides type-safe event dispatching and listener registration.
|
|
17
|
-
* Supports both synchronous listeners and asynchronous (queued) listeners.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* class UserRegistered extends Event {
|
|
22
|
-
* constructor(public user: User) {
|
|
23
|
-
* super()
|
|
24
|
-
* }
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* class SendWelcomeEmail implements Listener<UserRegistered> {
|
|
28
|
-
* async handle(event: UserRegistered): Promise<void> {
|
|
29
|
-
* // send welcome email
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
* // Register listener
|
|
34
|
-
* core.events.listen(UserRegistered, SendWelcomeEmail)
|
|
35
|
-
*
|
|
36
|
-
* // Dispatch event
|
|
37
|
-
* await core.events.dispatch(new UserRegistered(user))
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare class EventManager {
|
|
41
|
-
private core;
|
|
42
|
-
/**
|
|
43
|
-
* Listener registry.
|
|
44
|
-
* Key: event class or event name
|
|
45
|
-
* Value: listener registrations
|
|
46
|
-
*/
|
|
47
|
-
private listeners;
|
|
48
|
-
/**
|
|
49
|
-
* Broadcast manager (optional, injected by `orbit-broadcasting`).
|
|
50
|
-
*/
|
|
51
|
-
private broadcastManager;
|
|
52
|
-
/**
|
|
53
|
-
* Queue manager (optional, injected by `orbit-queue`).
|
|
54
|
-
*/
|
|
55
|
-
private queueManager;
|
|
56
|
-
constructor(core: PlanetCore);
|
|
57
|
-
/**
|
|
58
|
-
* Register the broadcast manager (called by `orbit-broadcasting`).
|
|
59
|
-
*/
|
|
60
|
-
setBroadcastManager(manager: EventManager['broadcastManager']): void;
|
|
61
|
-
/**
|
|
62
|
-
* Register the queue manager (called by `orbit-queue`).
|
|
63
|
-
*/
|
|
64
|
-
setQueueManager(manager: EventManager['queueManager']): void;
|
|
65
|
-
/**
|
|
66
|
-
* Register an event listener.
|
|
67
|
-
*
|
|
68
|
-
* @param event - Event class or event name
|
|
69
|
-
* @param listener - Listener instance or listener class
|
|
70
|
-
* @param options - Optional queue options
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* // Synchronous listener
|
|
75
|
-
* core.events.listen(UserRegistered, SendWelcomeEmail)
|
|
76
|
-
*
|
|
77
|
-
* // Queued listener (async)
|
|
78
|
-
* core.events.listen(UserRegistered, SendWelcomeEmail, {
|
|
79
|
-
* queue: 'emails',
|
|
80
|
-
* delay: 60
|
|
81
|
-
* })
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
listen<TEvent extends Event>(event: string | (new (...args: unknown[]) => TEvent), listener: Listener<TEvent> | (new () => Listener<TEvent>), options?: {
|
|
85
|
-
queue?: string;
|
|
86
|
-
connection?: string;
|
|
87
|
-
delay?: number;
|
|
88
|
-
}): void;
|
|
89
|
-
/**
|
|
90
|
-
* Remove an event listener.
|
|
91
|
-
*
|
|
92
|
-
* @param event - Event class or event name
|
|
93
|
-
* @param listener - Listener to remove
|
|
94
|
-
*/
|
|
95
|
-
unlisten<TEvent extends Event>(event: string | (new (...args: unknown[]) => TEvent), listener: Listener<TEvent> | (new () => Listener<TEvent>)): void;
|
|
96
|
-
/**
|
|
97
|
-
* Dispatch an event.
|
|
98
|
-
*
|
|
99
|
-
* Runs all registered listeners. If a listener implements `ShouldQueue` or
|
|
100
|
-
* has queue options, the listener will be pushed to the queue for async execution.
|
|
101
|
-
*
|
|
102
|
-
* @param event - Event instance
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```typescript
|
|
106
|
-
* await core.events.dispatch(new UserRegistered(user))
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
dispatch<TEvent extends Event>(event: TEvent): Promise<void>;
|
|
110
|
-
/**
|
|
111
|
-
* Serialize an event (for queueing).
|
|
112
|
-
*/
|
|
113
|
-
private serializeEvent;
|
|
114
|
-
/**
|
|
115
|
-
* Get all registered listeners.
|
|
116
|
-
*/
|
|
117
|
-
getListeners(event?: string | (new () => Event)): ListenerRegistration[];
|
|
118
|
-
/**
|
|
119
|
-
* Clear all listeners.
|
|
120
|
-
*/
|
|
121
|
-
clear(): void;
|
|
122
|
-
}
|
|
123
|
-
export {};
|
|
124
|
-
//# sourceMappingURL=EventManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventManager.d.ts","sourceRoot":"","sources":["../../../../core/src/EventManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C;;GAEG;AACH,UAAU,oBAAoB,CAAC,MAAM,SAAS,KAAK,GAAG,KAAK;IACzD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IACzD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,YAAY;IA+BX,OAAO,CAAC,IAAI;IA9BxB;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAgE;IAEjF;;OAEG;IACH,OAAO,CAAC,gBAAgB,CASX;IAEb;;OAEG;IACH,OAAO,CAAC,YAAY,CAIP;gBAEO,IAAI,EAAE,UAAU;IAEpC;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAIpE;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,GAAG,IAAI;IAI5D;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,MAAM,SAAS,KAAK,EACzB,KAAK,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,EACpD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,QAAQ,CAAC,MAAM,CAAC,CAAC,EACzD,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GACA,IAAI;IAcP;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,SAAS,KAAK,EAC3B,KAAK,EAAE,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,EACpD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,QAAQ,CAAC,MAAM,CAAC,CAAC,GACxD,IAAI;IAeP;;;;;;;;;;;;OAYG;IACG,QAAQ,CAAC,MAAM,SAAS,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgFlE;;OAEG;IACH,OAAO,CAAC,cAAc;IAUtB;;OAEG;IACH,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,UAAU,KAAK,CAAC,GAAG,oBAAoB,EAAE;IAYxE;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|