@tsed/agenda 6.88.1 → 6.92.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.
Files changed (67) hide show
  1. package/lib/{AgendaModule.d.ts → cjs/AgendaModule.d.ts} +0 -0
  2. package/lib/{AgendaModule.js → cjs/AgendaModule.js} +14 -14
  3. package/lib/cjs/AgendaModule.js.map +1 -0
  4. package/lib/{constants → cjs/constants}/index.d.ts +0 -0
  5. package/lib/{constants → cjs/constants}/index.js +0 -0
  6. package/lib/cjs/constants/index.js.map +1 -0
  7. package/lib/{decorators → cjs/decorators}/agenda.d.ts +0 -0
  8. package/lib/{decorators → cjs/decorators}/agenda.js +1 -1
  9. package/lib/cjs/decorators/agenda.js.map +1 -0
  10. package/lib/{decorators → cjs/decorators}/define.d.ts +0 -0
  11. package/lib/{decorators → cjs/decorators}/define.js +0 -0
  12. package/lib/cjs/decorators/define.js.map +1 -0
  13. package/lib/{decorators → cjs/decorators}/every.d.ts +0 -0
  14. package/lib/{decorators → cjs/decorators}/every.js +1 -1
  15. package/lib/cjs/decorators/every.js.map +1 -0
  16. package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
  17. package/lib/cjs/decorators/index.js +7 -0
  18. package/lib/cjs/decorators/index.js.map +1 -0
  19. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  20. package/lib/cjs/index.js +9 -0
  21. package/lib/cjs/index.js.map +1 -0
  22. package/lib/{interfaces → cjs/interfaces}/AgendaStore.d.ts +0 -0
  23. package/lib/{interfaces → cjs/interfaces}/AgendaStore.js +0 -0
  24. package/lib/cjs/interfaces/AgendaStore.js.map +1 -0
  25. package/lib/{services → cjs/services}/AgendaFactory.d.ts +0 -0
  26. package/lib/{services → cjs/services}/AgendaFactory.js +1 -1
  27. package/lib/cjs/services/AgendaFactory.js.map +1 -0
  28. package/lib/esm/AgendaModule.js +79 -0
  29. package/lib/esm/AgendaModule.js.map +1 -0
  30. package/lib/esm/constants/index.js +2 -0
  31. package/lib/esm/constants/index.js.map +1 -0
  32. package/lib/esm/decorators/agenda.js +9 -0
  33. package/lib/esm/decorators/agenda.js.map +1 -0
  34. package/lib/esm/decorators/define.js +12 -0
  35. package/lib/esm/decorators/define.js.map +1 -0
  36. package/lib/esm/decorators/every.js +13 -0
  37. package/lib/esm/decorators/every.js.map +1 -0
  38. package/lib/esm/decorators/index.js +4 -0
  39. package/lib/esm/decorators/index.js.map +1 -0
  40. package/lib/esm/index.js +6 -0
  41. package/lib/esm/index.js.map +1 -0
  42. package/lib/esm/interfaces/AgendaStore.js +2 -0
  43. package/lib/esm/interfaces/AgendaStore.js.map +1 -0
  44. package/lib/esm/services/AgendaFactory.js +13 -0
  45. package/lib/esm/services/AgendaFactory.js.map +1 -0
  46. package/lib/types/AgendaModule.d.ts +15 -0
  47. package/lib/types/constants/index.d.ts +1 -0
  48. package/lib/types/decorators/agenda.d.ts +16 -0
  49. package/lib/types/decorators/define.d.ts +2 -0
  50. package/lib/types/decorators/every.d.ts +2 -0
  51. package/lib/types/decorators/index.d.ts +3 -0
  52. package/lib/types/index.d.ts +18 -0
  53. package/lib/types/interfaces/AgendaStore.d.ts +16 -0
  54. package/lib/types/services/AgendaFactory.d.ts +3 -0
  55. package/package.json +16 -7
  56. package/tsconfig.compile.esm.json +23 -0
  57. package/lib/AgendaModule.js.map +0 -1
  58. package/lib/constants/index.js.map +0 -1
  59. package/lib/decorators/agenda.js.map +0 -1
  60. package/lib/decorators/define.js.map +0 -1
  61. package/lib/decorators/every.js.map +0 -1
  62. package/lib/decorators/index.js +0 -7
  63. package/lib/decorators/index.js.map +0 -1
  64. package/lib/index.js +0 -9
  65. package/lib/index.js.map +0 -1
  66. package/lib/interfaces/AgendaStore.js.map +0 -1
  67. package/lib/services/AgendaFactory.js.map +0 -1
File without changes
@@ -59,24 +59,24 @@ let AgendaModule = class AgendaModule {
59
59
  return namespace ? `${namespace}.${name}` : name;
60
60
  }
61
61
  };
62
- tslib_1.__decorate([
63
- di_1.Inject(),
64
- tslib_1.__metadata("design:type", common_1.Logger)
62
+ (0, tslib_1.__decorate)([
63
+ (0, di_1.Inject)(),
64
+ (0, tslib_1.__metadata)("design:type", common_1.Logger)
65
65
  ], AgendaModule.prototype, "logger", void 0);
66
- tslib_1.__decorate([
67
- di_1.Inject(),
68
- tslib_1.__metadata("design:type", di_1.InjectorService)
66
+ (0, tslib_1.__decorate)([
67
+ (0, di_1.Inject)(),
68
+ (0, tslib_1.__metadata)("design:type", di_1.InjectorService)
69
69
  ], AgendaModule.prototype, "injector", void 0);
70
- tslib_1.__decorate([
71
- di_1.Inject(),
72
- tslib_1.__metadata("design:type", AgendaFactory_1.AgendaService)
70
+ (0, tslib_1.__decorate)([
71
+ (0, di_1.Inject)(),
72
+ (0, tslib_1.__metadata)("design:type", AgendaFactory_1.AgendaService)
73
73
  ], AgendaModule.prototype, "agenda", void 0);
74
- tslib_1.__decorate([
75
- di_1.Constant("agenda.enabled", false),
76
- tslib_1.__metadata("design:type", Boolean)
74
+ (0, tslib_1.__decorate)([
75
+ (0, di_1.Constant)("agenda.enabled", false),
76
+ (0, tslib_1.__metadata)("design:type", Boolean)
77
77
  ], AgendaModule.prototype, "loadAgenda", void 0);
78
- AgendaModule = tslib_1.__decorate([
79
- di_1.Module()
78
+ AgendaModule = (0, tslib_1.__decorate)([
79
+ (0, di_1.Module)()
80
80
  ], AgendaModule);
81
81
  exports.AgendaModule = AgendaModule;
82
82
  //# sourceMappingURL=AgendaModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgendaModule.js","sourceRoot":"","sources":["../../src/AgendaModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA4D;AAC5D,iCAA6E;AAE7E,6CAAuD;AAEvD,4DAAuD;AAGvD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAavB,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CA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AAC,CAAC,IAAI,CAAC;IACnD,CAAC;CACF,CAAA;AA5EC;IADC,IAAA,WAAM,GAAE;2CACS,eAAM;4CAAC;AAGzB;IADC,IAAA,WAAM,GAAE;2CACW,oBAAe;8CAAC;AAGpC;IADC,IAAA,WAAM,GAAE;2CACS,6BAAa;4CAAC;AAGhC;IADC,IAAA,aAAQ,EAAC,gBAAgB,EAAE,KAAK,CAAC;;gDACN;AAXjB,YAAY;IADxB,IAAA,WAAM,GAAE;GACI,YAAY,CA8ExB;AA9EY,oCAAY","sourcesContent":["import {AfterListen, Logger, OnDestroy} from \"@tsed/common\";\nimport {Constant, Inject, InjectorService, Module, Provider} from \"@tsed/di\";\nimport {Processor} from \"agenda\";\nimport {PROVIDER_TYPE_AGENDA} from \"./constants/index\";\nimport {AgendaStore} from \"./interfaces/AgendaStore\";\nimport {AgendaService} from \"./services/AgendaFactory\";\n\n@Module()\nexport class AgendaModule implements OnDestroy, AfterListen {\n @Inject()\n protected logger: Logger;\n\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected agenda: AgendaService;\n\n @Constant(\"agenda.enabled\", false)\n private loadAgenda: boolean;\n\n async $afterListen(): Promise<any> {\n if (this.loadAgenda) {\n const providers = this.getProviders();\n providers.forEach((provider) => this.addAgendaDefinitionsForProvider(provider));\n\n this.logger.info(\"Agenda add definitions...\");\n await this.agenda.start();\n\n this.logger.info(\"Agenda add scheduled jobs...\");\n providers.forEach((provider) => this.scheduleJobsForProvider(provider));\n } else {\n this.logger.info(\"Agenda jobs disabled...\");\n }\n }\n\n async $onDestroy(): Promise<any> {\n if (this.loadAgenda) {\n await this.agenda.stop();\n await this.agenda.close({force: true});\n\n this.logger.info(\"Agenda jobs stopped...\");\n }\n }\n\n protected getProviders(): Provider<any>[] {\n return Array.from(this.injector.getProviders(PROVIDER_TYPE_AGENDA));\n }\n\n protected addAgendaDefinitionsForProvider(provider: Provider): void {\n const store = provider.store.get<AgendaStore>(\"agenda\");\n\n if (!store.define) {\n return;\n }\n\n const jobsToDefine = Object.entries(store.define);\n\n for (const [propertyKey, {name, ...options}] of jobsToDefine) {\n const instance = this.injector.get(provider.token);\n\n const jobProcessor: Processor = instance[propertyKey].bind(instance) as Processor;\n const jobName = this.getNameForJob(propertyKey, store.namespace, name);\n this.agenda.define(jobName, options, jobProcessor);\n }\n }\n\n protected async scheduleJobsForProvider(provider: Provider<any>): Promise<void> {\n const store = provider.store.get<AgendaStore>(\"agenda\");\n if (!store.every) {\n return;\n }\n\n const jobsToSchedule = Object.entries(store.every);\n await Promise.all(\n jobsToSchedule.map(([propertyKey, {interval, name, ...options}]) => {\n const jobName = this.getNameForJob(propertyKey, store.namespace, name);\n return this.agenda.every(interval, jobName, {}, options);\n })\n );\n }\n\n protected getNameForJob(propertyKey: string, namespace?: string, customName?: string): string {\n const name = customName || propertyKey;\n return namespace ? `${namespace}.${name}` : name;\n }\n}\n"]}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,sBAAsB,CAAC","sourcesContent":["export const PROVIDER_TYPE_AGENDA = \"PROVIDER_TYPE_AGENDA\";\n"]}
File without changes
@@ -5,7 +5,7 @@ const core_1 = require("@tsed/core");
5
5
  const di_1 = require("@tsed/di");
6
6
  const constants_1 = require("../constants");
7
7
  function Agenda(options) {
8
- return core_1.useDecorators(core_1.StoreMerge("agenda", { namespace: options === null || options === void 0 ? void 0 : options.namespace }), di_1.Injectable({
8
+ return (0, core_1.useDecorators)((0, core_1.StoreMerge)("agenda", { namespace: options === null || options === void 0 ? void 0 : options.namespace }), (0, di_1.Injectable)({
9
9
  type: constants_1.PROVIDER_TYPE_AGENDA
10
10
  }));
11
11
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agenda.js","sourceRoot":"","sources":["../../../src/decorators/agenda.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AACrD,iCAAoC;AAEpC,4CAAkD;AAiBlD,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAU,EAAC,QAAQ,EAAE,EAAC,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAC,CAAC,EACrD,IAAA,eAAU,EAAC;QACT,IAAI,EAAE,gCAAoB;KAC3B,CAAC,CACH,CAAC;AACJ,CAAC;AAPD,wBAOC","sourcesContent":["import {StoreMerge, useDecorators} from \"@tsed/core\";\nimport {Injectable} from \"@tsed/di\";\nimport {AgendaConfig} from \"agenda\";\nimport {PROVIDER_TYPE_AGENDA} from \"../constants\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n agenda?: {\n /** * Enable Agenda jobs. Default false. */\n enabled?: boolean;\n } & AgendaConfig;\n }\n }\n}\n\ninterface AgendaOptions {\n namespace?: string;\n}\n\nexport function Agenda(options?: AgendaOptions): ClassDecorator {\n return useDecorators(\n StoreMerge(\"agenda\", {namespace: options?.namespace}),\n Injectable({\n type: PROVIDER_TYPE_AGENDA\n })\n );\n}\n"]}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../../src/decorators/define.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAGjC,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,MAAM,KAAK,GAAgB;YACzB,MAAM,EAAE;gBACN,CAAC,WAAW,CAAC,EAAE,OAAO;aACvB;SACF,CAAC;QAEF,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC;AAVD,wBAUC","sourcesContent":["import {Store} from \"@tsed/core\";\nimport {AgendaStore, DefineOptions} from \"../interfaces/AgendaStore\";\n\nexport function Define(options: DefineOptions = {}): MethodDecorator {\n return (target: any, propertyKey: string) => {\n const store: AgendaStore = {\n define: {\n [propertyKey]: options\n }\n };\n\n Store.from(target).merge(\"agenda\", store);\n };\n}\n"]}
File without changes
@@ -4,7 +4,7 @@ exports.Every = void 0;
4
4
  const core_1 = require("@tsed/core");
5
5
  const define_1 = require("./define");
6
6
  function Every(interval, options = {}) {
7
- return core_1.useDecorators(define_1.Define(options), (target, propertyKey) => {
7
+ return (0, core_1.useDecorators)((0, define_1.Define)(options), (target, propertyKey) => {
8
8
  const store = {
9
9
  every: {
10
10
  [propertyKey]: { ...options, interval }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"every.js","sourceRoot":"","sources":["../../../src/decorators/every.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAChD,qCAAgC;AAGhC,SAAgB,KAAK,CAAC,QAAgB,EAAE,UAAwB,EAAE;IAChE,OAAO,IAAA,oBAAa,EAAC,IAAA,eAAM,EAAC,OAAO,CAAC,EAAE,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACzE,MAAM,KAAK,GAAgB;YACzB,KAAK,EAAE;gBACL,CAAC,WAAW,CAAC,EAAE,EAAC,GAAG,OAAO,EAAE,QAAQ,EAAC;aACtC;SACF,CAAC;QACF,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC;AATD,sBASC","sourcesContent":["import {Store, useDecorators} from \"@tsed/core\";\nimport {Define} from \"./define\";\nimport {AgendaStore, EveryOptions} from \"../interfaces/AgendaStore\";\n\nexport function Every(interval: string, options: EveryOptions = {}): MethodDecorator {\n return useDecorators(Define(options), (target: any, propertyKey: string) => {\n const store: AgendaStore = {\n every: {\n [propertyKey]: {...options, interval}\n }\n };\n Store.from(target).merge(\"agenda\", store);\n });\n}\n"]}
File without changes
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./agenda"), exports);
5
+ (0, tslib_1.__exportStar)(require("./define"), exports);
6
+ (0, tslib_1.__exportStar)(require("./every"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB;AACzB,wDAAyB;AACzB,uDAAwB","sourcesContent":["export * from \"./agenda\";\nexport * from \"./define\";\nexport * from \"./every\";\n"]}
File without changes
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./AgendaModule"), exports);
5
+ (0, tslib_1.__exportStar)(require("./constants"), exports);
6
+ (0, tslib_1.__exportStar)(require("./decorators"), exports);
7
+ (0, tslib_1.__exportStar)(require("./interfaces/AgendaStore"), exports);
8
+ (0, tslib_1.__exportStar)(require("./services/AgendaFactory"), exports);
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAeA,8DAA+B;AAC/B,2DAA4B;AAC5B,4DAA6B;AAC7B,wEAAyC;AACzC,wEAAyC","sourcesContent":["import {AgendaConfig} from \"agenda\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n agenda?: {\n /**\n * Enable Agenda jobs. Default false.\n */\n enabled?: boolean;\n } & AgendaConfig;\n }\n }\n}\n\nexport * from \"./AgendaModule\";\nexport * from \"./constants\";\nexport * from \"./decorators\";\nexport * from \"./interfaces/AgendaStore\";\nexport * from \"./services/AgendaFactory\";\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgendaStore.js","sourceRoot":"","sources":["../../../src/interfaces/AgendaStore.ts"],"names":[],"mappings":"","sourcesContent":["import {DefineOptions as AgendaDefineOptions, JobOptions} from \"agenda\";\n\nexport interface DefineOptions extends AgendaDefineOptions {\n name?: string;\n}\n\nexport type EveryOptions = JobOptions & DefineOptions;\n\nexport interface AgendaStore {\n namespace?: string;\n define?: {[propertyKey: string]: DefineOptions};\n every?: {[propertyKey: string]: EveryOptions & {interval: string}};\n}\n"]}
@@ -5,7 +5,7 @@ const di_1 = require("@tsed/di");
5
5
  const agenda_1 = require("agenda");
6
6
  // create Alias to avoid confusing import between Agenda from "agenda" and Agenda decorator
7
7
  exports.AgendaService = agenda_1.Agenda;
8
- di_1.registerProvider({
8
+ (0, di_1.registerProvider)({
9
9
  provide: agenda_1.Agenda,
10
10
  deps: [di_1.Configuration],
11
11
  useFactory(settings) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgendaFactory.js","sourceRoot":"","sources":["../../../src/services/AgendaFactory.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AACzD,mCAA4C;AAE5C,2FAA2F;AAC9E,QAAA,aAAa,GAAG,eAAM,CAAC;AAGpC,IAAA,qBAAgB,EAAC;IACf,OAAO,EAAE,eAAM;IACf,IAAI,EAAE,CAAC,kBAAa,CAAC;IACrB,UAAU,CAAC,QAAuB;QAChC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAoC,QAAQ,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,eAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport {Agenda, AgendaConfig} from \"agenda\";\n\n// create Alias to avoid confusing import between Agenda from \"agenda\" and Agenda decorator\nexport const AgendaService = Agenda;\nexport type AgendaService = Agenda;\n\nregisterProvider({\n provide: Agenda,\n deps: [Configuration],\n useFactory(settings: Configuration) {\n const opts = settings.get<AgendaConfig & {enabled: boolean}>(\"agenda\", {enabled: false});\n return opts.enabled ? new Agenda(opts) : {};\n }\n});\n"]}
@@ -0,0 +1,79 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Logger } from "@tsed/common";
3
+ import { Constant, Inject, InjectorService, Module } from "@tsed/di";
4
+ import { PROVIDER_TYPE_AGENDA } from "./constants/index";
5
+ import { AgendaService } from "./services/AgendaFactory";
6
+ let AgendaModule = class AgendaModule {
7
+ async $afterListen() {
8
+ if (this.loadAgenda) {
9
+ const providers = this.getProviders();
10
+ providers.forEach((provider) => this.addAgendaDefinitionsForProvider(provider));
11
+ this.logger.info("Agenda add definitions...");
12
+ await this.agenda.start();
13
+ this.logger.info("Agenda add scheduled jobs...");
14
+ providers.forEach((provider) => this.scheduleJobsForProvider(provider));
15
+ }
16
+ else {
17
+ this.logger.info("Agenda jobs disabled...");
18
+ }
19
+ }
20
+ async $onDestroy() {
21
+ if (this.loadAgenda) {
22
+ await this.agenda.stop();
23
+ await this.agenda.close({ force: true });
24
+ this.logger.info("Agenda jobs stopped...");
25
+ }
26
+ }
27
+ getProviders() {
28
+ return Array.from(this.injector.getProviders(PROVIDER_TYPE_AGENDA));
29
+ }
30
+ addAgendaDefinitionsForProvider(provider) {
31
+ const store = provider.store.get("agenda");
32
+ if (!store.define) {
33
+ return;
34
+ }
35
+ const jobsToDefine = Object.entries(store.define);
36
+ for (const [propertyKey, { name, ...options }] of jobsToDefine) {
37
+ const instance = this.injector.get(provider.token);
38
+ const jobProcessor = instance[propertyKey].bind(instance);
39
+ const jobName = this.getNameForJob(propertyKey, store.namespace, name);
40
+ this.agenda.define(jobName, options, jobProcessor);
41
+ }
42
+ }
43
+ async scheduleJobsForProvider(provider) {
44
+ const store = provider.store.get("agenda");
45
+ if (!store.every) {
46
+ return;
47
+ }
48
+ const jobsToSchedule = Object.entries(store.every);
49
+ await Promise.all(jobsToSchedule.map(([propertyKey, { interval, name, ...options }]) => {
50
+ const jobName = this.getNameForJob(propertyKey, store.namespace, name);
51
+ return this.agenda.every(interval, jobName, {}, options);
52
+ }));
53
+ }
54
+ getNameForJob(propertyKey, namespace, customName) {
55
+ const name = customName || propertyKey;
56
+ return namespace ? `${namespace}.${name}` : name;
57
+ }
58
+ };
59
+ __decorate([
60
+ Inject(),
61
+ __metadata("design:type", Logger)
62
+ ], AgendaModule.prototype, "logger", void 0);
63
+ __decorate([
64
+ Inject(),
65
+ __metadata("design:type", InjectorService)
66
+ ], AgendaModule.prototype, "injector", void 0);
67
+ __decorate([
68
+ Inject(),
69
+ __metadata("design:type", AgendaService)
70
+ ], AgendaModule.prototype, "agenda", void 0);
71
+ __decorate([
72
+ Constant("agenda.enabled", false),
73
+ __metadata("design:type", Boolean)
74
+ ], AgendaModule.prototype, "loadAgenda", void 0);
75
+ AgendaModule = __decorate([
76
+ Module()
77
+ ], AgendaModule);
78
+ export { AgendaModule };
79
+ //# sourceMappingURL=AgendaModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgendaModule.js","sourceRoot":"","sources":["../../src/AgendaModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAc,MAAM,EAAY,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAW,MAAM,UAAU,CAAC;AAE7E,OAAO,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAGvD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAavB,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,+BAA+B,CAAC,QAAQ,CAAC,CAAC,CAAC;YAEhF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAC9C,MAAM,IAA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AC,gBAAgB,EAAE,KAAK,CAAC;;gDACN;AAXjB,YAAY;IADxB,MAAM,EAAE;GACI,YAAY,CA8ExB;SA9EY,YAAY","sourcesContent":["import {AfterListen, Logger, OnDestroy} from \"@tsed/common\";\nimport {Constant, Inject, InjectorService, Module, Provider} from \"@tsed/di\";\nimport {Processor} from \"agenda\";\nimport {PROVIDER_TYPE_AGENDA} from \"./constants/index\";\nimport {AgendaStore} from \"./interfaces/AgendaStore\";\nimport {AgendaService} from \"./services/AgendaFactory\";\n\n@Module()\nexport class AgendaModule implements OnDestroy, AfterListen {\n @Inject()\n protected logger: Logger;\n\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected agenda: AgendaService;\n\n @Constant(\"agenda.enabled\", false)\n private loadAgenda: boolean;\n\n async $afterListen(): Promise<any> {\n if (this.loadAgenda) {\n const providers = this.getProviders();\n providers.forEach((provider) => this.addAgendaDefinitionsForProvider(provider));\n\n this.logger.info(\"Agenda add definitions...\");\n await this.agenda.start();\n\n this.logger.info(\"Agenda add scheduled jobs...\");\n providers.forEach((provider) => this.scheduleJobsForProvider(provider));\n } else {\n this.logger.info(\"Agenda jobs disabled...\");\n }\n }\n\n async $onDestroy(): Promise<any> {\n if (this.loadAgenda) {\n await this.agenda.stop();\n await this.agenda.close({force: true});\n\n this.logger.info(\"Agenda jobs stopped...\");\n }\n }\n\n protected getProviders(): Provider<any>[] {\n return Array.from(this.injector.getProviders(PROVIDER_TYPE_AGENDA));\n }\n\n protected addAgendaDefinitionsForProvider(provider: Provider): void {\n const store = provider.store.get<AgendaStore>(\"agenda\");\n\n if (!store.define) {\n return;\n }\n\n const jobsToDefine = Object.entries(store.define);\n\n for (const [propertyKey, {name, ...options}] of jobsToDefine) {\n const instance = this.injector.get(provider.token);\n\n const jobProcessor: Processor = instance[propertyKey].bind(instance) as Processor;\n const jobName = this.getNameForJob(propertyKey, store.namespace, name);\n this.agenda.define(jobName, options, jobProcessor);\n }\n }\n\n protected async scheduleJobsForProvider(provider: Provider<any>): Promise<void> {\n const store = provider.store.get<AgendaStore>(\"agenda\");\n if (!store.every) {\n return;\n }\n\n const jobsToSchedule = Object.entries(store.every);\n await Promise.all(\n jobsToSchedule.map(([propertyKey, {interval, name, ...options}]) => {\n const jobName = this.getNameForJob(propertyKey, store.namespace, name);\n return this.agenda.every(interval, jobName, {}, options);\n })\n );\n }\n\n protected getNameForJob(propertyKey: string, namespace?: string, customName?: string): string {\n const name = customName || propertyKey;\n return namespace ? `${namespace}.${name}` : name;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export const PROVIDER_TYPE_AGENDA = "PROVIDER_TYPE_AGENDA";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC","sourcesContent":["export const PROVIDER_TYPE_AGENDA = \"PROVIDER_TYPE_AGENDA\";\n"]}
@@ -0,0 +1,9 @@
1
+ import { StoreMerge, useDecorators } from "@tsed/core";
2
+ import { Injectable } from "@tsed/di";
3
+ import { PROVIDER_TYPE_AGENDA } from "../constants";
4
+ export function Agenda(options) {
5
+ return useDecorators(StoreMerge("agenda", { namespace: options === null || options === void 0 ? void 0 : options.namespace }), Injectable({
6
+ type: PROVIDER_TYPE_AGENDA
7
+ }));
8
+ }
9
+ //# sourceMappingURL=agenda.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agenda.js","sourceRoot":"","sources":["../../../src/decorators/agenda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAiBlD,MAAM,UAAU,MAAM,CAAC,OAAuB;IAC5C,OAAO,aAAa,CAClB,UAAU,CAAC,QAAQ,EAAE,EAAC,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAC,CAAC,EACrD,UAAU,CAAC;QACT,IAAI,EAAE,oBAAoB;KAC3B,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import {StoreMerge, useDecorators} from \"@tsed/core\";\nimport {Injectable} from \"@tsed/di\";\nimport {AgendaConfig} from \"agenda\";\nimport {PROVIDER_TYPE_AGENDA} from \"../constants\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n agenda?: {\n /** * Enable Agenda jobs. Default false. */\n enabled?: boolean;\n } & AgendaConfig;\n }\n }\n}\n\ninterface AgendaOptions {\n namespace?: string;\n}\n\nexport function Agenda(options?: AgendaOptions): ClassDecorator {\n return useDecorators(\n StoreMerge(\"agenda\", {namespace: options?.namespace}),\n Injectable({\n type: PROVIDER_TYPE_AGENDA\n })\n );\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { Store } from "@tsed/core";
2
+ export function Define(options = {}) {
3
+ return (target, propertyKey) => {
4
+ const store = {
5
+ define: {
6
+ [propertyKey]: options
7
+ }
8
+ };
9
+ Store.from(target).merge("agenda", store);
10
+ };
11
+ }
12
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../../src/decorators/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAGjC,MAAM,UAAU,MAAM,CAAC,UAAyB,EAAE;IAChD,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,MAAM,KAAK,GAAgB;YACzB,MAAM,EAAE;gBACN,CAAC,WAAW,CAAC,EAAE,OAAO;aACvB;SACF,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {Store} from \"@tsed/core\";\nimport {AgendaStore, DefineOptions} from \"../interfaces/AgendaStore\";\n\nexport function Define(options: DefineOptions = {}): MethodDecorator {\n return (target: any, propertyKey: string) => {\n const store: AgendaStore = {\n define: {\n [propertyKey]: options\n }\n };\n\n Store.from(target).merge(\"agenda\", store);\n };\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { Store, useDecorators } from "@tsed/core";
2
+ import { Define } from "./define";
3
+ export function Every(interval, options = {}) {
4
+ return useDecorators(Define(options), (target, propertyKey) => {
5
+ const store = {
6
+ every: {
7
+ [propertyKey]: { ...options, interval }
8
+ }
9
+ };
10
+ Store.from(target).merge("agenda", store);
11
+ });
12
+ }
13
+ //# sourceMappingURL=every.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"every.js","sourceRoot":"","sources":["../../../src/decorators/every.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAGhC,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,UAAwB,EAAE;IAChE,OAAO,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACzE,MAAM,KAAK,GAAgB;YACzB,KAAK,EAAE;gBACL,CAAC,WAAW,CAAC,EAAE,EAAC,GAAG,OAAO,EAAE,QAAQ,EAAC;aACtC;SACF,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Store, useDecorators} from \"@tsed/core\";\nimport {Define} from \"./define\";\nimport {AgendaStore, EveryOptions} from \"../interfaces/AgendaStore\";\n\nexport function Every(interval: string, options: EveryOptions = {}): MethodDecorator {\n return useDecorators(Define(options), (target: any, propertyKey: string) => {\n const store: AgendaStore = {\n every: {\n [propertyKey]: {...options, interval}\n }\n };\n Store.from(target).merge(\"agenda\", store);\n });\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export * from "./agenda";
2
+ export * from "./define";
3
+ export * from "./every";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC","sourcesContent":["export * from \"./agenda\";\nexport * from \"./define\";\nexport * from \"./every\";\n"]}
@@ -0,0 +1,6 @@
1
+ export * from "./AgendaModule";
2
+ export * from "./constants";
3
+ export * from "./decorators";
4
+ export * from "./interfaces/AgendaStore";
5
+ export * from "./services/AgendaFactory";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAeA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC","sourcesContent":["import {AgendaConfig} from \"agenda\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n agenda?: {\n /**\n * Enable Agenda jobs. Default false.\n */\n enabled?: boolean;\n } & AgendaConfig;\n }\n }\n}\n\nexport * from \"./AgendaModule\";\nexport * from \"./constants\";\nexport * from \"./decorators\";\nexport * from \"./interfaces/AgendaStore\";\nexport * from \"./services/AgendaFactory\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AgendaStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgendaStore.js","sourceRoot":"","sources":["../../../src/interfaces/AgendaStore.ts"],"names":[],"mappings":"","sourcesContent":["import {DefineOptions as AgendaDefineOptions, JobOptions} from \"agenda\";\n\nexport interface DefineOptions extends AgendaDefineOptions {\n name?: string;\n}\n\nexport type EveryOptions = JobOptions & DefineOptions;\n\nexport interface AgendaStore {\n namespace?: string;\n define?: {[propertyKey: string]: DefineOptions};\n every?: {[propertyKey: string]: EveryOptions & {interval: string}};\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { Configuration, registerProvider } from "@tsed/di";
2
+ import { Agenda } from "agenda";
3
+ // create Alias to avoid confusing import between Agenda from "agenda" and Agenda decorator
4
+ export const AgendaService = Agenda;
5
+ registerProvider({
6
+ provide: Agenda,
7
+ deps: [Configuration],
8
+ useFactory(settings) {
9
+ const opts = settings.get("agenda", { enabled: false });
10
+ return opts.enabled ? new Agenda(opts) : {};
11
+ }
12
+ });
13
+ //# sourceMappingURL=AgendaFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgendaFactory.js","sourceRoot":"","sources":["../../../src/services/AgendaFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAC,MAAM,EAAe,MAAM,QAAQ,CAAC;AAE5C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAGpC,gBAAgB,CAAC;IACf,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,UAAU,CAAC,QAAuB;QAChC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAoC,QAAQ,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport {Agenda, AgendaConfig} from \"agenda\";\n\n// create Alias to avoid confusing import between Agenda from \"agenda\" and Agenda decorator\nexport const AgendaService = Agenda;\nexport type AgendaService = Agenda;\n\nregisterProvider({\n provide: Agenda,\n deps: [Configuration],\n useFactory(settings: Configuration) {\n const opts = settings.get<AgendaConfig & {enabled: boolean}>(\"agenda\", {enabled: false});\n return opts.enabled ? new Agenda(opts) : {};\n }\n});\n"]}
@@ -0,0 +1,15 @@
1
+ import { AfterListen, Logger, OnDestroy } from "@tsed/common";
2
+ import { InjectorService, Provider } from "@tsed/di";
3
+ import { AgendaService } from "./services/AgendaFactory";
4
+ export declare class AgendaModule implements OnDestroy, AfterListen {
5
+ protected logger: Logger;
6
+ protected injector: InjectorService;
7
+ protected agenda: AgendaService;
8
+ private loadAgenda;
9
+ $afterListen(): Promise<any>;
10
+ $onDestroy(): Promise<any>;
11
+ protected getProviders(): Provider<any>[];
12
+ protected addAgendaDefinitionsForProvider(provider: Provider): void;
13
+ protected scheduleJobsForProvider(provider: Provider<any>): Promise<void>;
14
+ protected getNameForJob(propertyKey: string, namespace?: string, customName?: string): string;
15
+ }
@@ -0,0 +1 @@
1
+ export declare const PROVIDER_TYPE_AGENDA = "PROVIDER_TYPE_AGENDA";
@@ -0,0 +1,16 @@
1
+ import { AgendaConfig } from "agenda";
2
+ declare global {
3
+ namespace TsED {
4
+ interface Configuration {
5
+ agenda?: {
6
+ /** * Enable Agenda jobs. Default false. */
7
+ enabled?: boolean;
8
+ } & AgendaConfig;
9
+ }
10
+ }
11
+ }
12
+ interface AgendaOptions {
13
+ namespace?: string;
14
+ }
15
+ export declare function Agenda(options?: AgendaOptions): ClassDecorator;
16
+ export {};
@@ -0,0 +1,2 @@
1
+ import { DefineOptions } from "../interfaces/AgendaStore";
2
+ export declare function Define(options?: DefineOptions): MethodDecorator;
@@ -0,0 +1,2 @@
1
+ import { EveryOptions } from "../interfaces/AgendaStore";
2
+ export declare function Every(interval: string, options?: EveryOptions): MethodDecorator;
@@ -0,0 +1,3 @@
1
+ export * from "./agenda";
2
+ export * from "./define";
3
+ export * from "./every";
@@ -0,0 +1,18 @@
1
+ import { AgendaConfig } from "agenda";
2
+ declare global {
3
+ namespace TsED {
4
+ interface Configuration {
5
+ agenda?: {
6
+ /**
7
+ * Enable Agenda jobs. Default false.
8
+ */
9
+ enabled?: boolean;
10
+ } & AgendaConfig;
11
+ }
12
+ }
13
+ }
14
+ export * from "./AgendaModule";
15
+ export * from "./constants";
16
+ export * from "./decorators";
17
+ export * from "./interfaces/AgendaStore";
18
+ export * from "./services/AgendaFactory";
@@ -0,0 +1,16 @@
1
+ import { DefineOptions as AgendaDefineOptions, JobOptions } from "agenda";
2
+ export interface DefineOptions extends AgendaDefineOptions {
3
+ name?: string;
4
+ }
5
+ export declare type EveryOptions = JobOptions & DefineOptions;
6
+ export interface AgendaStore {
7
+ namespace?: string;
8
+ define?: {
9
+ [propertyKey: string]: DefineOptions;
10
+ };
11
+ every?: {
12
+ [propertyKey: string]: EveryOptions & {
13
+ interval: string;
14
+ };
15
+ };
16
+ }
@@ -0,0 +1,3 @@
1
+ import { Agenda } from "agenda";
2
+ export declare const AgendaService: typeof Agenda;
3
+ export declare type AgendaService = Agenda;
package/package.json CHANGED
@@ -1,11 +1,20 @@
1
1
  {
2
2
  "name": "@tsed/agenda",
3
- "version": "6.88.1",
3
+ "version": "6.92.0",
4
4
  "description": "Agenda package for Ts.ED framework",
5
- "main": "./lib/index.js",
6
- "typings": "./lib/index.d.ts",
5
+ "source": "./src/index.ts",
6
+ "main": "./lib/cjs/index.js",
7
+ "typings": "./lib/types/index.d.ts",
8
+ "exports": {
9
+ "types": "./lib/types/index.d.ts",
10
+ "import": "./lib/esm/index.js",
11
+ "require": "./lib/cjs/index.js",
12
+ "default": "./lib/esm/index.js"
13
+ },
7
14
  "scripts": {
8
- "build": "tsc --build tsconfig.compile.json",
15
+ "build": "yarn run build:esm && yarn run build:cjs",
16
+ "build:cjs": "tsc --build tsconfig.compile.json",
17
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
9
18
  "test": "cross-env NODE_ENV=test nyc mocha"
10
19
  },
11
20
  "dependencies": {
@@ -13,9 +22,9 @@
13
22
  },
14
23
  "private": false,
15
24
  "devDependencies": {
16
- "@tsed/common": "6.88.1",
17
- "@tsed/core": "6.88.1",
18
- "@tsed/di": "6.88.1",
25
+ "@tsed/common": "6.92.0",
26
+ "@tsed/core": "6.92.0",
27
+ "@tsed/di": "6.92.0",
19
28
  "agenda": "^4.1.3"
20
29
  },
21
30
  "peerDependencies": {
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "test",
14
+ "lib",
15
+ "benchmark",
16
+ "coverage",
17
+ "spec",
18
+ "**/*.benchmark.ts",
19
+ "**/*.spec.ts",
20
+ "keys",
21
+ "jest.config.js"
22
+ ]
23
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgendaModule.js","sourceRoot":"","sources":["../src/AgendaModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA4D;AAC5D,iCAA6E;AAE7E,6CAAuD;AAEvD,4DAAuD;AAGvD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAavB,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,+BAA+B,CAAC,QAAQ,CAAC,CAAC,CAAC;YAEhF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAC9C,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAE1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YACjD,SAAS,CAAC,OAAO,CAAC,CAA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} from \"@tsed/common\";\nimport {Constant, Inject, InjectorService, Module, Provider} from \"@tsed/di\";\nimport {Processor} from \"agenda\";\nimport {PROVIDER_TYPE_AGENDA} from \"./constants/index\";\nimport {AgendaStore} from \"./interfaces/AgendaStore\";\nimport {AgendaService} from \"./services/AgendaFactory\";\n\n@Module()\nexport class AgendaModule implements OnDestroy, AfterListen {\n @Inject()\n protected logger: Logger;\n\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected agenda: AgendaService;\n\n @Constant(\"agenda.enabled\", false)\n private loadAgenda: boolean;\n\n async $afterListen(): Promise<any> {\n if (this.loadAgenda) {\n const providers = this.getProviders();\n providers.forEach((provider) => this.addAgendaDefinitionsForProvider(provider));\n\n this.logger.info(\"Agenda add definitions...\");\n await this.agenda.start();\n\n this.logger.info(\"Agenda add scheduled jobs...\");\n providers.forEach((provider) => this.scheduleJobsForProvider(provider));\n } else {\n this.logger.info(\"Agenda jobs disabled...\");\n }\n }\n\n async $onDestroy(): Promise<any> {\n if (this.loadAgenda) {\n await this.agenda.stop();\n await this.agenda.close({force: true});\n\n this.logger.info(\"Agenda jobs stopped...\");\n }\n }\n\n protected getProviders(): Provider<any>[] {\n return Array.from(this.injector.getProviders(PROVIDER_TYPE_AGENDA));\n }\n\n protected addAgendaDefinitionsForProvider(provider: Provider): void {\n const store = provider.store.get<AgendaStore>(\"agenda\");\n\n if (!store.define) {\n return;\n }\n\n const jobsToDefine = Object.entries(store.define);\n\n for (const [propertyKey, {name, ...options}] of jobsToDefine) {\n const instance = this.injector.get(provider.token);\n\n const jobProcessor: Processor = instance[propertyKey].bind(instance) as Processor;\n const jobName = this.getNameForJob(propertyKey, store.namespace, name);\n this.agenda.define(jobName, options, jobProcessor);\n }\n }\n\n protected async scheduleJobsForProvider(provider: Provider<any>): Promise<void> {\n const store = provider.store.get<AgendaStore>(\"agenda\");\n if (!store.every) {\n return;\n }\n\n const jobsToSchedule = Object.entries(store.every);\n await Promise.all(\n jobsToSchedule.map(([propertyKey, {interval, name, ...options}]) => {\n const jobName = this.getNameForJob(propertyKey, store.namespace, name);\n return this.agenda.every(interval, jobName, {}, options);\n })\n );\n }\n\n protected getNameForJob(propertyKey: string, namespace?: string, customName?: string): string {\n const name = customName || propertyKey;\n return namespace ? `${namespace}.${name}` : name;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,sBAAsB,CAAC","sourcesContent":["export const PROVIDER_TYPE_AGENDA = \"PROVIDER_TYPE_AGENDA\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"agenda.js","sourceRoot":"","sources":["../../src/decorators/agenda.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AACrD,iCAAoC;AAEpC,4CAAkD;AAiBlD,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,oBAAa,CAClB,iBAAU,CAAC,QAAQ,EAAE,EAAC,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAC,CAAC,EACrD,eAAU,CAAC;QACT,IAAI,EAAE,gCAAoB;KAC3B,CAAC,CACH,CAAC;AACJ,CAAC;AAPD,wBAOC","sourcesContent":["import {StoreMerge, useDecorators} from \"@tsed/core\";\nimport {Injectable} from \"@tsed/di\";\nimport {AgendaConfig} from \"agenda\";\nimport {PROVIDER_TYPE_AGENDA} from \"../constants\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n agenda?: {\n /** * Enable Agenda jobs. Default false. */\n enabled?: boolean;\n } & AgendaConfig;\n }\n }\n}\n\ninterface AgendaOptions {\n namespace?: string;\n}\n\nexport function Agenda(options?: AgendaOptions): ClassDecorator {\n return useDecorators(\n StoreMerge(\"agenda\", {namespace: options?.namespace}),\n Injectable({\n type: PROVIDER_TYPE_AGENDA\n })\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/decorators/define.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAGjC,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,MAAM,KAAK,GAAgB;YACzB,MAAM,EAAE;gBACN,CAAC,WAAW,CAAC,EAAE,OAAO;aACvB;SACF,CAAC;QAEF,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC;AAVD,wBAUC","sourcesContent":["import {Store} from \"@tsed/core\";\nimport {AgendaStore, DefineOptions} from \"../interfaces/AgendaStore\";\n\nexport function Define(options: DefineOptions = {}): MethodDecorator {\n return (target: any, propertyKey: string) => {\n const store: AgendaStore = {\n define: {\n [propertyKey]: options\n }\n };\n\n Store.from(target).merge(\"agenda\", store);\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"every.js","sourceRoot":"","sources":["../../src/decorators/every.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAChD,qCAAgC;AAGhC,SAAgB,KAAK,CAAC,QAAgB,EAAE,UAAwB,EAAE;IAChE,OAAO,oBAAa,CAAC,eAAM,CAAC,OAAO,CAAC,EAAE,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACzE,MAAM,KAAK,GAAgB;YACzB,KAAK,EAAE;gBACL,CAAC,WAAW,CAAC,EAAE,EAAC,GAAG,OAAO,EAAE,QAAQ,EAAC;aACtC;SACF,CAAC;QACF,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC;AATD,sBASC","sourcesContent":["import {Store, useDecorators} from \"@tsed/core\";\nimport {Define} from \"./define\";\nimport {AgendaStore, EveryOptions} from \"../interfaces/AgendaStore\";\n\nexport function Every(interval: string, options: EveryOptions = {}): MethodDecorator {\n return useDecorators(Define(options), (target: any, propertyKey: string) => {\n const store: AgendaStore = {\n every: {\n [propertyKey]: {...options, interval}\n }\n };\n Store.from(target).merge(\"agenda\", store);\n });\n}\n"]}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./agenda"), exports);
5
- tslib_1.__exportStar(require("./define"), exports);
6
- tslib_1.__exportStar(require("./every"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,mDAAyB;AACzB,kDAAwB","sourcesContent":["export * from \"./agenda\";\nexport * from \"./define\";\nexport * from \"./every\";\n"]}
package/lib/index.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./AgendaModule"), exports);
5
- tslib_1.__exportStar(require("./constants"), exports);
6
- tslib_1.__exportStar(require("./decorators"), exports);
7
- tslib_1.__exportStar(require("./interfaces/AgendaStore"), exports);
8
- tslib_1.__exportStar(require("./services/AgendaFactory"), exports);
9
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAeA,yDAA+B;AAC/B,sDAA4B;AAC5B,uDAA6B;AAC7B,mEAAyC;AACzC,mEAAyC","sourcesContent":["import {AgendaConfig} from \"agenda\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n agenda?: {\n /**\n * Enable Agenda jobs. Default false.\n */\n enabled?: boolean;\n } & AgendaConfig;\n }\n }\n}\n\nexport * from \"./AgendaModule\";\nexport * from \"./constants\";\nexport * from \"./decorators\";\nexport * from \"./interfaces/AgendaStore\";\nexport * from \"./services/AgendaFactory\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgendaStore.js","sourceRoot":"","sources":["../../src/interfaces/AgendaStore.ts"],"names":[],"mappings":"","sourcesContent":["import {DefineOptions as AgendaDefineOptions, JobOptions} from \"agenda\";\n\nexport interface DefineOptions extends AgendaDefineOptions {\n name?: string;\n}\n\nexport type EveryOptions = JobOptions & DefineOptions;\n\nexport interface AgendaStore {\n namespace?: string;\n define?: {[propertyKey: string]: DefineOptions};\n every?: {[propertyKey: string]: EveryOptions & {interval: string}};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgendaFactory.js","sourceRoot":"","sources":["../../src/services/AgendaFactory.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AACzD,mCAA4C;AAE5C,2FAA2F;AAC9E,QAAA,aAAa,GAAG,eAAM,CAAC;AAGpC,qBAAgB,CAAC;IACf,OAAO,EAAE,eAAM;IACf,IAAI,EAAE,CAAC,kBAAa,CAAC;IACrB,UAAU,CAAC,QAAuB;QAChC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAoC,QAAQ,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,eAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport {Agenda, AgendaConfig} from \"agenda\";\n\n// create Alias to avoid confusing import between Agenda from \"agenda\" and Agenda decorator\nexport const AgendaService = Agenda;\nexport type AgendaService = Agenda;\n\nregisterProvider({\n provide: Agenda,\n deps: [Configuration],\n useFactory(settings: Configuration) {\n const opts = settings.get<AgendaConfig & {enabled: boolean}>(\"agenda\", {enabled: false});\n return opts.enabled ? new Agenda(opts) : {};\n }\n});\n"]}