@chromahq/core 0.1.10 → 0.1.12
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/IJob-Bds0eWrM.js +17 -0
- package/dist/IJob-Bds0eWrM.js.map +1 -0
- package/dist/IJob-aWBqI3FC.js +14 -0
- package/dist/IJob-aWBqI3FC.js.map +1 -0
- package/dist/boot.cjs.js +1557 -0
- package/dist/boot.cjs.js.map +1 -0
- package/dist/boot.d.ts +21 -0
- package/dist/boot.es.js +1555 -0
- package/dist/boot.es.js.map +1 -0
- package/dist/index.cjs.js +29 -1689
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +19 -53
- package/dist/index.es.js +27 -1680
- package/dist/index.es.js.map +1 -0
- package/package.json +20 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/decorators/Service.ts","../src/decorators/Message.ts","../src/scheduler/core/Job.ts","../src/scheduler/decorators/Job.ts","../src/scheduler/decorators/Delay.ts","../src/scheduler/decorators/Every.ts","../src/services/booteable.ts"],"sourcesContent":["import { inject, injectable } from '@inversifyjs/core';\nimport { TOKENS } from './tokens';\n\nexport function Service() {\n return injectable();\n}\n\nexport const Use = (id: symbol | string | NewableFunction) => inject(id);\nexport const Store = () => Use(TOKENS.Store);\n","import { injectable } from '@inversifyjs/core';\n\nexport abstract class IMessage {\n handle(...args: any[]): Promise<void> | void {\n throw new Error('Method not implemented.');\n }\n}\n\nexport function Message(name: string) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('name', name, constructor);\n return constructor;\n };\n}\n","import { IJob, JobContext } from './IJob';\n\nexport abstract class Job<T = unknown> implements IJob<T> {\n constructor(public readonly data?: T) {}\n\n abstract handle(context?: JobContext): Promise<void> | void;\n\n pause?(): Promise<void> | void {\n console.log(`Job ${this.constructor.name} paused`);\n }\n\n resume?(): Promise<void> | void {\n console.log(`Job ${this.constructor.name} resumed`);\n }\n\n stop?(): Promise<void> | void {\n console.log(`Job ${this.constructor.name} stopped`);\n }\n}\n","import { injectable } from '@inversifyjs/core';\nimport { JobOptions } from '../core/JobOptions';\n\nexport function JobConfig<T extends new (...args: any[]) => any>(options: JobOptions = {}) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('job:options', { options }, constructor);\n return constructor;\n };\n}\n","import { JobConfig } from './Job';\n\nexport const Delay = (ms: number) => JobConfig({ delay: ms });\n","import { injectable } from '@inversifyjs/core';\n\nexport function Every(cron: string) {\n return function (constructor: any) {\n injectable()(constructor);\n Reflect.defineMetadata('job:options', { cron }, constructor);\n return constructor;\n };\n}\n","export abstract class Booteable {\n /**\n * Boot method to be called when the service is initialized.\n * This method can be used to perform any setup or initialization logic.\n */\n abstract boot(): void;\n /**\n * Optional destroy method to be called when the service is being destroyed.\n * This can be used to clean up resources or perform any necessary teardown logic.\n */\n destroy?(): void {\n // Default implementation does nothing\n }\n}\n\nexport function isBooteable(obj: any): obj is Booteable {\n return typeof obj.boot === 'function';\n}\n\nexport function isDestroyable(obj: any): obj is Booteable {\n return typeof obj.destroy === 'function';\n}\n"],"names":["injectable","inject","TOKENS"],"mappings":";;;;;AAGO,SAAS,OAAA,GAAU;AACxB,EAAA,OAAOA,eAAA,EAAW;AACpB;AAEO,MAAM,GAAA,GAAM,CAAC,EAAA,KAA0CC,WAAA,CAAO,EAAE;AAChE,MAAM,KAAA,GAAQ,MAAM,GAAA,CAAIC,WAAA,CAAO,KAAK;;ACNpC,MAAe,QAAA,CAAS;AAAA,EAC7B,UAAU,IAAA,EAAmC;AAC3C,IAAA,MAAM,IAAI,MAAM,yBAAyB,CAAA;AAAA;AAE7C;AAEO,SAAS,QAAQ,IAAA,EAAc;AACpC,EAAA,OAAO,SAAU,WAAA,EAAkB;AACjC,IAAAF,eAAA,GAAa,WAAW,CAAA;AACxB,IAAA,OAAA,CAAQ,cAAA,CAAe,MAAA,EAAQ,IAAA,EAAM,WAAW,CAAA;AACh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EAA4B;AACtD,EAAA,OAAO,OAAO,IAAI,IAAA,KAAS,UAAA;AAC7B;AAEO,SAAS,cAAc,GAAA,EAA4B;AACxD,EAAA,OAAO,OAAO,IAAI,OAAA,KAAY,UAAA;AAChC;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,61 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
PARAM_TYPES: string;
|
|
5
|
-
TYPE: string;
|
|
6
|
-
RETURN_TYPE: string;
|
|
7
|
-
};
|
|
8
|
-
declare const container: any;
|
|
9
|
-
declare const bind: <T>(id: symbol | (new (...a: any[]) => T), cls: new (...a: any[]) => T) => any;
|
|
10
|
-
declare const resolve: <T>(id: symbol | (new (...a: any[]) => T)) => T;
|
|
11
|
-
declare function isInjectable(target: any): boolean;
|
|
12
|
-
|
|
13
|
-
declare function create({ keepPortAlive, portName, }?: {
|
|
14
|
-
keepPortAlive?: boolean;
|
|
15
|
-
portName?: string;
|
|
16
|
-
}): Promise<void>;
|
|
17
|
-
declare function bootstrap(): BootstrapBuilder;
|
|
18
|
-
declare class BootstrapBuilder {
|
|
19
|
-
private readonly app;
|
|
20
|
-
/**
|
|
21
|
-
* Add a store definition to be initialized
|
|
22
|
-
*/
|
|
23
|
-
withStore(storeDefinition: any): BootstrapBuilder;
|
|
24
|
-
/**
|
|
25
|
-
* Add multiple store definitions to be initialized
|
|
26
|
-
*/
|
|
27
|
-
withStores(storeDefinitions: any[]): BootstrapBuilder;
|
|
28
|
-
/**
|
|
29
|
-
* Create and start the application
|
|
30
|
-
*/
|
|
31
|
-
create({ keepPortAlive, portName, }?: {
|
|
32
|
-
keepPortAlive?: boolean;
|
|
33
|
-
portName?: string;
|
|
34
|
-
}): Promise<void>;
|
|
35
|
-
}
|
|
1
|
+
declare function Service(): ClassDecorator;
|
|
2
|
+
declare const Use: (id: symbol | string | NewableFunction) => MethodDecorator & ParameterDecorator & PropertyDecorator;
|
|
3
|
+
declare const Store: () => MethodDecorator & ParameterDecorator & PropertyDecorator;
|
|
36
4
|
|
|
37
5
|
declare abstract class IMessage {
|
|
38
6
|
handle(...args: any[]): Promise<void> | void;
|
|
39
7
|
}
|
|
40
8
|
declare function Message(name: string): (constructor: any) => any;
|
|
41
9
|
|
|
42
|
-
declare function Injectable(): (constructor: new (...args: any[]) => any) => void;
|
|
43
|
-
|
|
44
|
-
declare abstract class Booteable {
|
|
45
|
-
/**
|
|
46
|
-
* Boot method to be called when the service is initialized.
|
|
47
|
-
* This method can be used to perform any setup or initialization logic.
|
|
48
|
-
*/
|
|
49
|
-
abstract boot(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Optional destroy method to be called when the service is being destroyed.
|
|
52
|
-
* This can be used to clean up resources or perform any necessary teardown logic.
|
|
53
|
-
*/
|
|
54
|
-
destroy?(): void;
|
|
55
|
-
}
|
|
56
|
-
declare function isBooteable(obj: any): obj is Booteable;
|
|
57
|
-
declare function isDestroyable(obj: any): obj is Booteable;
|
|
58
|
-
|
|
59
10
|
interface JobOptions {
|
|
60
11
|
id?: string;
|
|
61
12
|
delay?: number;
|
|
@@ -127,5 +78,20 @@ declare const Delay: (ms: number) => (constructor: any) => any;
|
|
|
127
78
|
|
|
128
79
|
declare function Every(cron: string): (constructor: any) => any;
|
|
129
80
|
|
|
130
|
-
|
|
81
|
+
declare abstract class Booteable {
|
|
82
|
+
/**
|
|
83
|
+
* Boot method to be called when the service is initialized.
|
|
84
|
+
* This method can be used to perform any setup or initialization logic.
|
|
85
|
+
*/
|
|
86
|
+
abstract boot(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Optional destroy method to be called when the service is being destroyed.
|
|
89
|
+
* This can be used to clean up resources or perform any necessary teardown logic.
|
|
90
|
+
*/
|
|
91
|
+
destroy?(): void;
|
|
92
|
+
}
|
|
93
|
+
declare function isBooteable(obj: any): obj is Booteable;
|
|
94
|
+
declare function isDestroyable(obj: any): obj is Booteable;
|
|
95
|
+
|
|
96
|
+
export { Booteable, Delay, Every, IMessage, Job, JobState, Message, Service, Store, Use, isBooteable, isDestroyable };
|
|
131
97
|
export type { IJob, JobContext };
|