@kingsworld/plugin-cron 4.0.1-next.7885c0a → 4.0.1-next.81c5469

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 (71) hide show
  1. package/dist/cjs/CronTask-CWQGUBCQ.d.cts +84 -0
  2. package/dist/cjs/CronTask-CWQGUBCQ.d.cts.map +1 -0
  3. package/dist/cjs/CronTaskHandler-DI4ENcPU.d.cts +30 -0
  4. package/dist/cjs/CronTaskHandler-DI4ENcPU.d.cts.map +1 -0
  5. package/dist/cjs/CronTaskHandler-DWPv3gFR.cjs +64 -0
  6. package/dist/cjs/CronTaskHandler-DWPv3gFR.cjs.map +1 -0
  7. package/dist/cjs/CronTaskStore-RmZUHmVY.d.cts +57 -0
  8. package/dist/cjs/CronTaskStore-RmZUHmVY.d.cts.map +1 -0
  9. package/dist/cjs/CronTaskTypes-8bwitvv3.d.cts +30 -0
  10. package/dist/cjs/CronTaskTypes-8bwitvv3.d.cts.map +1 -0
  11. package/dist/cjs/index.cjs +16 -31
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/cjs/index.d.cts +17 -187
  14. package/dist/cjs/index.d.cts.map +1 -0
  15. package/dist/cjs/lib/CronTaskHandler.cjs +3 -36
  16. package/dist/cjs/lib/CronTaskHandler.d.cts +3 -0
  17. package/dist/cjs/lib/structures/CronTask.cjs +79 -60
  18. package/dist/cjs/lib/structures/CronTask.cjs.map +1 -1
  19. package/dist/cjs/lib/structures/CronTask.d.cts +3 -0
  20. package/dist/cjs/lib/structures/CronTaskStore.cjs +121 -132
  21. package/dist/cjs/lib/structures/CronTaskStore.cjs.map +1 -1
  22. package/dist/cjs/lib/structures/CronTaskStore.d.cts +3 -0
  23. package/dist/cjs/lib/types/CronTaskTypes.cjs +0 -2
  24. package/dist/cjs/lib/types/CronTaskTypes.d.cts +3 -0
  25. package/dist/cjs/lib/utils/normalizePattern.cjs +33 -35
  26. package/dist/cjs/lib/utils/normalizePattern.cjs.map +1 -1
  27. package/dist/cjs/lib/utils/normalizePattern.d.cts +6 -0
  28. package/dist/cjs/lib/utils/normalizePattern.d.cts.map +1 -0
  29. package/dist/cjs/register.cjs +25 -25
  30. package/dist/cjs/register.cjs.map +1 -1
  31. package/dist/cjs/register.d.cts +10 -8
  32. package/dist/cjs/register.d.cts.map +1 -0
  33. package/dist/esm/CronTask-bjAF2VtU.d.mts +83 -0
  34. package/dist/esm/CronTask-bjAF2VtU.d.mts.map +1 -0
  35. package/dist/esm/CronTaskHandler-C2NIvWlD.d.mts +29 -0
  36. package/dist/esm/CronTaskHandler-C2NIvWlD.d.mts.map +1 -0
  37. package/dist/esm/CronTaskHandler-DfpLsyA6.mjs +56 -0
  38. package/dist/esm/CronTaskHandler-DfpLsyA6.mjs.map +1 -0
  39. package/dist/esm/CronTaskStore-CYzBM1td.d.mts +56 -0
  40. package/dist/esm/CronTaskStore-CYzBM1td.d.mts.map +1 -0
  41. package/dist/esm/CronTaskTypes-BOgAse0r.d.mts +29 -0
  42. package/dist/esm/CronTaskTypes-BOgAse0r.d.mts.map +1 -0
  43. package/dist/esm/index.d.mts +17 -188
  44. package/dist/esm/index.d.mts.map +1 -0
  45. package/dist/esm/index.mjs +13 -8
  46. package/dist/esm/index.mjs.map +1 -1
  47. package/dist/esm/lib/CronTaskHandler.d.mts +2 -0
  48. package/dist/esm/lib/CronTaskHandler.mjs +2 -33
  49. package/dist/esm/lib/structures/CronTask.d.mts +2 -0
  50. package/dist/esm/lib/structures/CronTask.mjs +78 -59
  51. package/dist/esm/lib/structures/CronTask.mjs.map +1 -1
  52. package/dist/esm/lib/structures/CronTaskStore.d.mts +2 -0
  53. package/dist/esm/lib/structures/CronTaskStore.mjs +120 -131
  54. package/dist/esm/lib/structures/CronTaskStore.mjs.map +1 -1
  55. package/dist/esm/lib/types/CronTaskTypes.d.mts +2 -0
  56. package/dist/esm/lib/types/CronTaskTypes.mjs +1 -3
  57. package/dist/esm/lib/utils/normalizePattern.d.mts +5 -0
  58. package/dist/esm/lib/utils/normalizePattern.d.mts.map +1 -0
  59. package/dist/esm/lib/utils/normalizePattern.mjs +32 -35
  60. package/dist/esm/lib/utils/normalizePattern.mjs.map +1 -1
  61. package/dist/esm/register.d.mts +9 -8
  62. package/dist/esm/register.d.mts.map +1 -0
  63. package/dist/esm/register.mjs +20 -20
  64. package/dist/esm/register.mjs.map +1 -1
  65. package/package.json +7 -15
  66. package/dist/cjs/lib/CronTaskHandler.cjs.map +0 -1
  67. package/dist/cjs/lib/types/CronTaskTypes.cjs.map +0 -1
  68. package/dist/esm/chunk-2JTKI4GS.mjs +0 -8
  69. package/dist/esm/chunk-2JTKI4GS.mjs.map +0 -1
  70. package/dist/esm/lib/CronTaskHandler.mjs.map +0 -1
  71. package/dist/esm/lib/types/CronTaskTypes.mjs.map +0 -1
@@ -1,67 +1,86 @@
1
1
  'use strict';
2
2
 
3
- var pieces = require('@sapphire/pieces');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ let _sapphire_pieces = require("@sapphire/pieces");
4
5
 
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var _CronTask = class _CronTask extends pieces.Piece {
8
- constructor(context, options) {
9
- super(context, options);
10
- }
11
- /**
12
- * A helper function to log messages with the `CronTask[${name}]` prefix.
13
- * @param message The message to include after the prefix
14
- * @param other Extra parameters to pass to the logger
15
- * @example
16
- * this.info('Hello world!'); // CronTask[my-task] Hello world!
17
- */
18
- info(message, ...other) {
19
- this.container.logger.info(`CronTask[${this.name}] ${message}`, ...other);
20
- }
21
- /**
22
- * A helper function to log messages with the `CronTask[${name}]` prefix.
23
- * @param message The message to include after the prefix
24
- * @param other Extra parameters to pass to the logger
25
- * @example
26
- * this.error('Something went wrong!'); // CronTask[my-task] Something went wrong!
27
- */
28
- error(message, ...other) {
29
- this.container.logger.error(`CronTask[${this.name}] ${message}`, ...other);
30
- }
31
- /**
32
- * A helper function to log messages with the `CronTask[${name}]` prefix.
33
- * @param message The message to include after the prefix
34
- * @param other Extra parameters to pass to the logger
35
- * @example
36
- * this.warn('Something is not right!'); // CronTask[my-task] Something is not right!
37
- */
38
- warn(message, ...other) {
39
- this.container.logger.warn(`CronTask[${this.name}] ${message}`, ...other);
40
- }
41
- /**
42
- * A helper function to log messages with the `CronTask[${name}]` prefix.
43
- * @param message The message to include after the prefix
44
- * @param other Extra parameters to pass to the logger
45
- * @example
46
- * this.debug('Something is happening!'); // CronTask[my-task] Something is happening!
47
- */
48
- debug(message, ...other) {
49
- this.container.logger.debug(`CronTask[${this.name}] ${message}`, ...other);
50
- }
51
- /**
52
- * A helper function to log messages with the `CronTask[${name}]` prefix.
53
- * @param message The message to include after the prefix
54
- * @param other Extra parameters to pass to the logger
55
- * @example
56
- * this.trace('Loaded the file.'); // CronTask[my-task] Loaded the file.
57
- */
58
- trace(message, ...other) {
59
- this.container.logger.trace(`CronTask[${this.name}] ${message}`, ...other);
60
- }
6
+ //#region src/lib/structures/CronTask.ts
7
+ /**
8
+ * @example
9
+ *
10
+ * ```typescript
11
+ * // ping.ts
12
+ * import { CronTask } from '@kingsworld/plugin-cron';
13
+ *
14
+ * export class PingPong extends CronTask {
15
+ * public constructor(context: CronTask.LoaderContext, options: CronTask.Options) {
16
+ * super(context, {
17
+ * ...options,
18
+ * pattern: '* * * * *'
19
+ * });
20
+ * }
21
+ *
22
+ * public run() {
23
+ * this.info('Ping Pong! 🏓'); // CronTask[ping] Ping Pong! 🏓
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ var CronTask = class extends _sapphire_pieces.Piece {
29
+ constructor(context, options) {
30
+ super(context, options);
31
+ }
32
+ /**
33
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
34
+ * @param message The message to include after the prefix
35
+ * @param other Extra parameters to pass to the logger
36
+ * @example
37
+ * this.info('Hello world!'); // CronTask[my-task] Hello world!
38
+ */
39
+ info(message, ...other) {
40
+ this.container.logger.info(`CronTask[${this.name}] ${message}`, ...other);
41
+ }
42
+ /**
43
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
44
+ * @param message The message to include after the prefix
45
+ * @param other Extra parameters to pass to the logger
46
+ * @example
47
+ * this.error('Something went wrong!'); // CronTask[my-task] Something went wrong!
48
+ */
49
+ error(message, ...other) {
50
+ this.container.logger.error(`CronTask[${this.name}] ${message}`, ...other);
51
+ }
52
+ /**
53
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
54
+ * @param message The message to include after the prefix
55
+ * @param other Extra parameters to pass to the logger
56
+ * @example
57
+ * this.warn('Something is not right!'); // CronTask[my-task] Something is not right!
58
+ */
59
+ warn(message, ...other) {
60
+ this.container.logger.warn(`CronTask[${this.name}] ${message}`, ...other);
61
+ }
62
+ /**
63
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
64
+ * @param message The message to include after the prefix
65
+ * @param other Extra parameters to pass to the logger
66
+ * @example
67
+ * this.debug('Something is happening!'); // CronTask[my-task] Something is happening!
68
+ */
69
+ debug(message, ...other) {
70
+ this.container.logger.debug(`CronTask[${this.name}] ${message}`, ...other);
71
+ }
72
+ /**
73
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
74
+ * @param message The message to include after the prefix
75
+ * @param other Extra parameters to pass to the logger
76
+ * @example
77
+ * this.trace('Loaded the file.'); // CronTask[my-task] Loaded the file.
78
+ */
79
+ trace(message, ...other) {
80
+ this.container.logger.trace(`CronTask[${this.name}] ${message}`, ...other);
81
+ }
61
82
  };
62
- __name(_CronTask, "CronTask");
63
- var CronTask = _CronTask;
64
83
 
84
+ //#endregion
65
85
  exports.CronTask = CronTask;
66
- //# sourceMappingURL=CronTask.cjs.map
67
86
  //# sourceMappingURL=CronTask.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/structures/CronTask.ts"],"names":["Piece"],"mappings":";;;;;;AA0BO,IAAe,SAAA,GAAf,MAAe,SAAA,SAAsEA,YAAA,CAA6B;AAAA,EAGjH,WAAA,CAAY,SAA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AM,CAAA,SAAA,EAAY,IAAA,CAAK,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAA,EAAI,GAAG,KAAK,CAAA;AAAA,EAC1E;AACD,CAAA;AAnEyH,MAAA,CAAA,SAAA,EAAA,UAAA,CAAA;AAAlH,IAAe,QAAA,GAAf","file":"CronTask.cjs","sourcesContent":["import type { Awaitable } from '@sapphire/framework';\nimport { Piece } from '@sapphire/pieces';\nimport type { Cron } from 'croner';\nimport type { CronJobOptions } from '../types/CronTaskTypes';\n\n/**\n * @example\n *\n * ```typescript\n * // ping.ts\n * import { CronTask } from '@kingsworld/plugin-cron';\n *\n * export class PingPong extends CronTask {\n * \tpublic constructor(context: CronTask.LoaderContext, options: CronTask.Options) {\n * \t\tsuper(context, {\n * \t\t\t...options,\n * \t\t\tpattern: '* * * * *'\n * \t\t});\n * \t}\n *\n * \tpublic run() {\n * \t\tthis.info('Ping Pong! 🏓'); // CronTask[ping] Ping Pong! 🏓\n * \t}\n * }\n * ```\n */\nexport abstract class CronTask<Options extends CronTask.Options = CronTask.Options> extends Piece<Options, 'cron-tasks'> {\n\tdeclare public job: Cron;\n\n\tpublic constructor(context: CronTask.LoaderContext, options: Options) {\n\t\tsuper(context, options);\n\t}\n\n\tpublic abstract run(): Awaitable<unknown>;\n\n\tpublic protect?(job: Cron): Awaitable<unknown>;\n\n\tpublic catch?(error: unknown, job: Cron): Awaitable<unknown>;\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.info('Hello world!'); // CronTask[my-task] Hello world!\n\t */\n\tpublic info(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.info(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.error('Something went wrong!'); // CronTask[my-task] Something went wrong!\n\t */\n\tpublic error(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.error(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.warn('Something is not right!'); // CronTask[my-task] Something is not right!\n\t */\n\tpublic warn(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.warn(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.debug('Something is happening!'); // CronTask[my-task] Something is happening!\n\t */\n\tpublic debug(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.debug(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.trace('Loaded the file.'); // CronTask[my-task] Loaded the file.\n\t */\n\tpublic trace(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.trace(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n}\n\nexport namespace CronTask {\n\texport type Options = Piece.Options & CronJobOptions;\n\t/** @deprecated Use {@linkcode LoaderContext} instead. */\n\texport type Context = LoaderContext;\n\texport type LoaderContext = Piece.LoaderContext<'cron-tasks'>;\n}\n"]}
1
+ {"version":3,"file":"CronTask.cjs","names":[],"sources":["../../../../src/lib/structures/CronTask.ts"],"sourcesContent":["import type { Awaitable } from '@sapphire/framework';\nimport { Piece } from '@sapphire/pieces';\nimport type { Cron } from 'croner';\nimport type { CronJobOptions } from '../types/CronTaskTypes';\n\n/**\n * @example\n *\n * ```typescript\n * // ping.ts\n * import { CronTask } from '@kingsworld/plugin-cron';\n *\n * export class PingPong extends CronTask {\n * \tpublic constructor(context: CronTask.LoaderContext, options: CronTask.Options) {\n * \t\tsuper(context, {\n * \t\t\t...options,\n * \t\t\tpattern: '* * * * *'\n * \t\t});\n * \t}\n *\n * \tpublic run() {\n * \t\tthis.info('Ping Pong! 🏓'); // CronTask[ping] Ping Pong! 🏓\n * \t}\n * }\n * ```\n */\nexport abstract class CronTask<Options extends CronTask.Options = CronTask.Options> extends Piece<Options, 'cron-tasks'> {\n\tdeclare public job: Cron;\n\n\tpublic constructor(context: CronTask.LoaderContext, options: Options) {\n\t\tsuper(context, options);\n\t}\n\n\tpublic abstract run(): Awaitable<unknown>;\n\n\tpublic protect?(job: Cron): Awaitable<unknown>;\n\n\tpublic catch?(error: unknown, job: Cron): Awaitable<unknown>;\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.info('Hello world!'); // CronTask[my-task] Hello world!\n\t */\n\tpublic info(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.info(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.error('Something went wrong!'); // CronTask[my-task] Something went wrong!\n\t */\n\tpublic error(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.error(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.warn('Something is not right!'); // CronTask[my-task] Something is not right!\n\t */\n\tpublic warn(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.warn(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.debug('Something is happening!'); // CronTask[my-task] Something is happening!\n\t */\n\tpublic debug(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.debug(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n\n\t/**\n\t * A helper function to log messages with the `CronTask[${name}]` prefix.\n\t * @param message The message to include after the prefix\n\t * @param other Extra parameters to pass to the logger\n\t * @example\n\t * this.trace('Loaded the file.'); // CronTask[my-task] Loaded the file.\n\t */\n\tpublic trace(message: string, ...other: unknown[]) {\n\t\tthis.container.logger.trace(`CronTask[${this.name}] ${message}`, ...other);\n\t}\n}\n\nexport namespace CronTask {\n\texport type Options = Piece.Options & CronJobOptions;\n\t/** @deprecated Use {@linkcode LoaderContext} instead. */\n\texport type Context = LoaderContext;\n\texport type LoaderContext = Piece.LoaderContext<'cron-tasks'>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAA,WAAA,cAAA,uBAAA;CAGA,AAAA,YAAA,SAAA,SAAA;EACA,MAAA,SAAA,OAAA;CACA;;;;;;;;CAeA,AAAA,KAAA,SAAA,GAAA,OAAA;EACA,KAAA,UAAA,OAAA,KAAA,YAAA,KAAA,KAAA,IAAA,WAAA,GAAA,KAAA;CACA;;;;;;;;CASA,AAAA,MAAA,SAAA,GAAA,OAAA;EACA,KAAA,UAAA,OAAA,MAAA,YAAA,KAAA,KAAA,IAAA,WAAA,GAAA,KAAA;CACA;;;;;;;;CASA,AAAA,KAAA,SAAA,GAAA,OAAA;EACA,KAAA,UAAA,OAAA,KAAA,YAAA,KAAA,KAAA,IAAA,WAAA,GAAA,KAAA;CACA;;;;;;;;CASA,AAAA,MAAA,SAAA,GAAA,OAAA;EACA,KAAA,UAAA,OAAA,MAAA,YAAA,KAAA,KAAA,IAAA,WAAA,GAAA,KAAA;CACA;;;;;;;;CASA,AAAA,MAAA,SAAA,GAAA,OAAA;EACA,KAAA,UAAA,OAAA,MAAA,YAAA,KAAA,KAAA,IAAA,WAAA,GAAA,KAAA;CACA;AACA"}
@@ -0,0 +1,3 @@
1
+
2
+ import { t as CronTask } from "../../CronTask-CWQGUBCQ.cjs";
3
+ export { CronTask };
@@ -1,139 +1,128 @@
1
1
  'use strict';
2
2
 
3
- var pieces = require('@sapphire/pieces');
4
- var croner = require('croner');
5
- var CronTask_cjs = require('./CronTask.cjs');
6
- var normalizePattern_cjs = require('../utils/normalizePattern.cjs');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_lib_structures_CronTask = require('./CronTask.cjs');
5
+ const require_lib_utils_normalizePattern = require('../utils/normalizePattern.cjs');
6
+ let _sapphire_pieces = require("@sapphire/pieces");
7
+ let croner = require("croner");
7
8
 
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- var _CronTaskStore = class _CronTaskStore extends pieces.Store {
11
- constructor() {
12
- super(CronTask_cjs.CronTask, { name: "cron-tasks" });
13
- }
14
- /**
15
- * Loops over all tasks and pauses those that are running.
16
- *
17
- * @remarks
18
- * This method will only pause tasks that:
19
- * - Are enabled
20
- * - Are currently running
21
- * - Have not been permanently stopped
22
- *
23
- * @returns CronTaskStore
24
- */
25
- pauseAll() {
26
- for (const task of this.values()) {
27
- if (!task.enabled || !task.job.isRunning()) continue;
28
- task.job.pause();
29
- }
30
- pieces.Store.logger?.(`[STORE => ${this.name}] [PAUSE] Paused all cronjob tasks.`);
31
- return this;
32
- }
33
- /**
34
- * Loops over all tasks and resumes those that are paused.
35
- *
36
- * @remarks
37
- * This method will only resume tasks that:
38
- * - Are enabled
39
- * - Are not currently running
40
- * - Have not been permanently stopped
41
- *
42
- * @returns CronTaskStore
43
- */
44
- resumeAll() {
45
- for (const task of this.values()) {
46
- if (!task.enabled || task.job.isRunning() || task.job.isStopped()) continue;
47
- task.job.resume();
48
- }
49
- pieces.Store.logger?.(`[STORE => ${this.name}] [RESUME] Resumed all cronjob tasks.`);
50
- return this;
51
- }
52
- /**
53
- * Loops over all tasks and stops those that are running.
54
- *
55
- * @remarks
56
- * This method will only stop tasks that:
57
- * - Are enabled
58
- * - Have not been permanently stopped
59
- *
60
- * ⚠️ Stopping jobs is **permanent** and cannot be resumed afterwards!
61
- *
62
- * @returns CronTaskStore
63
- */
64
- stopAll() {
65
- for (const task of this.values()) {
66
- if (!task.enabled || task.job.isStopped()) continue;
67
- task.job.stop();
68
- }
69
- pieces.Store.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);
70
- return this;
71
- }
72
- set(key, value) {
73
- const { pattern, timezone, protect, ...options } = value.options;
74
- const { sentry, defaultTimezone } = this.container.cronTasks;
75
- if (this.has(key)) {
76
- pieces.Store.logger?.(`[STORE => ${this.name}] [SET] Stopping existing cronjob task before creating a new one.`);
77
- this.get(key)?.job.stop();
78
- }
79
- const timeZone = timezone ?? defaultTimezone;
80
- try {
81
- pieces.Store.logger?.(
82
- `[STORE => ${this.name}] [SET] Creating cronjob for ${key} with '${pattern}' as the pattern and '${timeZone}' for the timezone`
83
- );
84
- value.job = new croner.Cron(
85
- pattern,
86
- {
87
- name: key,
88
- timezone: timeZone,
89
- paused: true,
90
- // we start the job manually once the client is ready
91
- protect: value.protect?.bind(value) ?? protect,
92
- catch: /* @__PURE__ */ __name((error) => {
93
- value.error("Encountered an error while running the cron job", error);
94
- sentry?.captureException(error);
95
- value.catch?.bind(value)(error, value.job);
96
- }, "catch"),
97
- ...options
98
- },
99
- async () => {
100
- if (sentry && typeof pattern === "string" && !pattern.includes(":")) {
101
- await sentry.withMonitor(key, value.run.bind(value), {
102
- schedule: { type: "crontab", value: normalizePattern_cjs.normalizePattern(pattern) },
103
- timezone: timeZone
104
- });
105
- } else {
106
- await value.run.bind(value)();
107
- }
108
- }
109
- );
110
- } catch (error) {
111
- value.error("Encountered an error while creating the cron job", error);
112
- void value.unload();
113
- }
114
- return super.set(key, value);
115
- }
116
- /**
117
- * Deletes a task from the store and stops it if it's running.
118
- */
119
- delete(key) {
120
- const task = this.get(key);
121
- if (task && !task.job.isStopped()) {
122
- task.job.stop();
123
- }
124
- return super.delete(key);
125
- }
126
- /**
127
- * Stops all running cron jobs and clears the store.
128
- */
129
- clear() {
130
- this.stopAll();
131
- return super.clear();
132
- }
9
+ //#region src/lib/structures/CronTaskStore.ts
10
+ var CronTaskStore = class extends _sapphire_pieces.Store {
11
+ constructor() {
12
+ super(require_lib_structures_CronTask.CronTask, { name: "cron-tasks" });
13
+ }
14
+ /**
15
+ * Loops over all tasks and pauses those that are running.
16
+ *
17
+ * @remarks
18
+ * This method will only pause tasks that:
19
+ * - Are enabled
20
+ * - Are currently running
21
+ * - Have not been permanently stopped
22
+ *
23
+ * @returns CronTaskStore
24
+ */
25
+ pauseAll() {
26
+ for (const task of this.values()) {
27
+ if (!task.enabled || !task.job.isRunning()) continue;
28
+ task.job.pause();
29
+ }
30
+ _sapphire_pieces.Store.logger?.(`[STORE => ${this.name}] [PAUSE] Paused all cronjob tasks.`);
31
+ return this;
32
+ }
33
+ /**
34
+ * Loops over all tasks and resumes those that are paused.
35
+ *
36
+ * @remarks
37
+ * This method will only resume tasks that:
38
+ * - Are enabled
39
+ * - Are not currently running
40
+ * - Have not been permanently stopped
41
+ *
42
+ * @returns CronTaskStore
43
+ */
44
+ resumeAll() {
45
+ for (const task of this.values()) {
46
+ if (!task.enabled || task.job.isRunning() || task.job.isStopped()) continue;
47
+ task.job.resume();
48
+ }
49
+ _sapphire_pieces.Store.logger?.(`[STORE => ${this.name}] [RESUME] Resumed all cronjob tasks.`);
50
+ return this;
51
+ }
52
+ /**
53
+ * Loops over all tasks and stops those that are running.
54
+ *
55
+ * @remarks
56
+ * This method will only stop tasks that:
57
+ * - Are enabled
58
+ * - Have not been permanently stopped
59
+ *
60
+ * ⚠️ Stopping jobs is **permanent** and cannot be resumed afterwards!
61
+ *
62
+ * @returns CronTaskStore
63
+ */
64
+ stopAll() {
65
+ for (const task of this.values()) {
66
+ if (!task.enabled || task.job.isStopped()) continue;
67
+ task.job.stop();
68
+ }
69
+ _sapphire_pieces.Store.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);
70
+ return this;
71
+ }
72
+ set(key, value) {
73
+ const { pattern, timezone, protect, ...options } = value.options;
74
+ const { sentry, defaultTimezone } = this.container.cronTasks;
75
+ if (this.has(key)) {
76
+ _sapphire_pieces.Store.logger?.(`[STORE => ${this.name}] [SET] Stopping existing cronjob task before creating a new one.`);
77
+ this.get(key)?.job.stop();
78
+ }
79
+ const timeZone = timezone ?? defaultTimezone;
80
+ try {
81
+ _sapphire_pieces.Store.logger?.(`[STORE => ${this.name}] [SET] Creating cronjob for ${key} with '${pattern}' as the pattern and '${timeZone}' for the timezone`);
82
+ value.job = new croner.Cron(pattern, {
83
+ name: key,
84
+ timezone: timeZone,
85
+ paused: true,
86
+ protect: value.protect?.bind(value) ?? protect,
87
+ catch: (error) => {
88
+ value.error("Encountered an error while running the cron job", error);
89
+ sentry?.captureException(error);
90
+ value.catch?.bind(value)(error, value.job);
91
+ },
92
+ ...options
93
+ }, async () => {
94
+ if (sentry && typeof pattern === "string" && !pattern.includes(":")) await sentry.withMonitor(key, value.run.bind(value), {
95
+ schedule: {
96
+ type: "crontab",
97
+ value: require_lib_utils_normalizePattern.normalizePattern(pattern)
98
+ },
99
+ timezone: timeZone
100
+ });
101
+ else await value.run.bind(value)();
102
+ });
103
+ } catch (error) {
104
+ value.error("Encountered an error while creating the cron job", error);
105
+ value.unload();
106
+ }
107
+ return super.set(key, value);
108
+ }
109
+ /**
110
+ * Deletes a task from the store and stops it if it's running.
111
+ */
112
+ delete(key) {
113
+ const task = this.get(key);
114
+ if (task && !task.job.isStopped()) task.job.stop();
115
+ return super.delete(key);
116
+ }
117
+ /**
118
+ * Stops all running cron jobs and clears the store.
119
+ */
120
+ clear() {
121
+ this.stopAll();
122
+ return super.clear();
123
+ }
133
124
  };
134
- __name(_CronTaskStore, "CronTaskStore");
135
- var CronTaskStore = _CronTaskStore;
136
125
 
126
+ //#endregion
137
127
  exports.CronTaskStore = CronTaskStore;
138
- //# sourceMappingURL=CronTaskStore.cjs.map
139
128
  //# sourceMappingURL=CronTaskStore.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/structures/CronTaskStore.ts"],"names":["Store","CronTask","Cron","normalizePattern"],"mappings":";;;;;;;;;AAKO,IAAM,cAAA,GAAN,MAAM,cAAA,SAAsBA,YAAA,CAA8B;AAAA,EACzD,WAAA,GAAc;AACpB,IAAA,KAAA,CAAMC,qBAAA,EAAU,EAAE,IAAA,EAAM,YAAA,EAAc,CAAA;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,QAAA,GAAW;AACjB,IAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,MAAA,EAAO,EAAG;AACjC,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,IAAW,CAAC,IAAA,CAAK,GAAA,CAAI,WAAU,EAAG;AAC5C,MAAA,IAAA,CAAK,IAAI,KAAA,EAAM;AAAA,IAChB;AAEA,IAAAD,YAAA,CAAM,MAAA,GAAS,CAAA,UAAA,EAAa,IAAA,CAAK,IAAI,CAAA,mCAAA,CAAqC,CAAA;AAC1E,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,SAAA,GAAY;AAClB,IAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,MAAA,EAAO,EAAG;AACjC,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,IAAW,IAAA,CAAK,GAAA,CAAI,WAAU,IAAK,IAAA,CAAK,GAAA,CAAI,SAAA,EAAU,EAAG;AACnE,MAAA,IAAA,CAAK,IAAI,MAAA,EAAO;AAAA,IACjB;AAEA,IAAAA,YAAA,CAAM,MAAA,GAAS,CAAA,UAAA,EAAa,IAAA,CAAK,IAAI,CAAA,qCAAA,CA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a;AACnC,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA;AACzB,IAAA,IAAI,IAAA,IAAQ,CAAC,IAAA,CAAK,GAAA,CAAI,WAAU,EAAG;AAClC,MAAA,IAAA,CAAK,IAAI,IAAA,EAAK;AAAA,IACf;AAEA,IAAA,OAAO,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKgB,KAAA,GAAQ;AACvB,IAAA,IAAA,CAAK,OAAA,EAAQ;AACb,IAAA,OAAO,MAAM,KAAA,EAAM;AAAA,EACpB;AACD,CAAA;AA3IiE,MAAA,CAAA,cAAA,EAAA,eAAA,CAAA;AAA1D,IAAM,aAAA,GAAN","file":"CronTaskStore.cjs","sourcesContent":["import { Store } from '@sapphire/pieces';\nimport { Cron } from 'croner';\nimport { CronTask } from './CronTask';\nimport { normalizePattern } from '../utils/normalizePattern';\n\nexport class CronTaskStore extends Store<CronTask, 'cron-tasks'> {\n\tpublic constructor() {\n\t\tsuper(CronTask, { name: 'cron-tasks' });\n\t}\n\n\t/**\n\t * Loops over all tasks and pauses those that are running.\n\t *\n\t * @remarks\n\t * This method will only pause tasks that:\n\t * - Are enabled\n\t * - Are currently running\n\t * - Have not been permanently stopped\n\t *\n\t * @returns CronTaskStore\n\t */\n\tpublic pauseAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled || !task.job.isRunning()) continue;\n\t\t\ttask.job.pause();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [PAUSE] Paused all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and resumes those that are paused.\n\t *\n\t * @remarks\n\t * This method will only resume tasks that:\n\t * - Are enabled\n\t * - Are not currently running\n\t * - Have not been permanently stopped\n\t *\n\t * @returns CronTaskStore\n\t */\n\tpublic resumeAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled || task.job.isRunning() || task.job.isStopped()) continue;\n\t\t\ttask.job.resume();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [RESUME] Resumed all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and stops those that are running.\n\t *\n\t * @remarks\n\t * This method will only stop tasks that:\n\t * - Are enabled\n\t * - Have not been permanently stopped\n\t *\n\t * ⚠️ Stopping jobs is **permanent** and cannot be resumed afterwards!\n\t *\n\t * @returns CronTaskStore\n\t */\n\tpublic stopAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled || task.job.isStopped()) continue;\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\tpublic override set(key: string, value: CronTask): this {\n\t\tconst { pattern, timezone, protect, ...options } = value.options;\n\t\tconst { sentry, defaultTimezone } = this.container.cronTasks;\n\n\t\t// if a task with the same key already exists, stop it before creating a new one\n\t\tif (this.has(key)) {\n\t\t\tStore.logger?.(`[STORE => ${this.name}] [SET] Stopping existing cronjob task before creating a new one.`);\n\t\t\tthis.get(key)?.job.stop();\n\t\t}\n\n\t\tconst timeZone = timezone ?? defaultTimezone;\n\n\t\ttry {\n\t\t\tStore.logger?.(\n\t\t\t\t`[STORE => ${this.name}] [SET] Creating cronjob for ${key} with '${pattern}' as the pattern and '${timeZone}' for the timezone`\n\t\t\t);\n\n\t\t\tvalue.job = new Cron(\n\t\t\t\tpattern,\n\t\t\t\t{\n\t\t\t\t\tname: key,\n\t\t\t\t\ttimezone: timeZone,\n\t\t\t\t\tpaused: true, // we start the job manually once the client is ready\n\t\t\t\t\tprotect: value.protect?.bind(value) ?? protect,\n\t\t\t\t\tcatch: (error) => {\n\t\t\t\t\t\tvalue.error('Encountered an error while running the cron job', error);\n\t\t\t\t\t\tsentry?.captureException(error);\n\t\t\t\t\t\tvalue.catch?.bind(value)(error, value.job);\n\t\t\t\t\t},\n\t\t\t\t\t...options\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\t// we only want to monitor cron patterns and not single-use tasks that croner supports\n\t\t\t\t\tif (sentry && typeof pattern === 'string' && !pattern.includes(':')) {\n\t\t\t\t\t\tawait sentry.withMonitor(key, value.run.bind(value), {\n\t\t\t\t\t\t\tschedule: { type: 'crontab', value: normalizePattern(pattern) },\n\t\t\t\t\t\t\ttimezone: timeZone\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait value.run.bind(value)();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tvalue.error('Encountered an error while creating the cron job', error);\n\t\t\tvoid value.unload();\n\t\t}\n\n\t\treturn super.set(key, value);\n\t}\n\n\t/**\n\t * Deletes a task from the store and stops it if it's running.\n\t */\n\tpublic override delete(key: string) {\n\t\tconst task = this.get(key);\n\t\tif (task && !task.job.isStopped()) {\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\treturn super.delete(key);\n\t}\n\n\t/**\n\t * Stops all running cron jobs and clears the store.\n\t */\n\tpublic override clear() {\n\t\tthis.stopAll();\n\t\treturn super.clear();\n\t}\n}\n"]}
1
+ {"version":3,"file":"CronTaskStore.cjs","names":[],"sources":["../../../../src/lib/structures/CronTaskStore.ts"],"sourcesContent":["import { Store } from '@sapphire/pieces';\nimport { Cron } from 'croner';\nimport { CronTask } from './CronTask';\nimport { normalizePattern } from '../utils/normalizePattern';\n\nexport class CronTaskStore extends Store<CronTask, 'cron-tasks'> {\n\tpublic constructor() {\n\t\tsuper(CronTask, { name: 'cron-tasks' });\n\t}\n\n\t/**\n\t * Loops over all tasks and pauses those that are running.\n\t *\n\t * @remarks\n\t * This method will only pause tasks that:\n\t * - Are enabled\n\t * - Are currently running\n\t * - Have not been permanently stopped\n\t *\n\t * @returns CronTaskStore\n\t */\n\tpublic pauseAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled || !task.job.isRunning()) continue;\n\t\t\ttask.job.pause();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [PAUSE] Paused all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and resumes those that are paused.\n\t *\n\t * @remarks\n\t * This method will only resume tasks that:\n\t * - Are enabled\n\t * - Are not currently running\n\t * - Have not been permanently stopped\n\t *\n\t * @returns CronTaskStore\n\t */\n\tpublic resumeAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled || task.job.isRunning() || task.job.isStopped()) continue;\n\t\t\ttask.job.resume();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [RESUME] Resumed all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and stops those that are running.\n\t *\n\t * @remarks\n\t * This method will only stop tasks that:\n\t * - Are enabled\n\t * - Have not been permanently stopped\n\t *\n\t * ⚠️ Stopping jobs is **permanent** and cannot be resumed afterwards!\n\t *\n\t * @returns CronTaskStore\n\t */\n\tpublic stopAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled || task.job.isStopped()) continue;\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\tpublic override set(key: string, value: CronTask): this {\n\t\tconst { pattern, timezone, protect, ...options } = value.options;\n\t\tconst { sentry, defaultTimezone } = this.container.cronTasks;\n\n\t\t// if a task with the same key already exists, stop it before creating a new one\n\t\tif (this.has(key)) {\n\t\t\tStore.logger?.(`[STORE => ${this.name}] [SET] Stopping existing cronjob task before creating a new one.`);\n\t\t\tthis.get(key)?.job.stop();\n\t\t}\n\n\t\tconst timeZone = timezone ?? defaultTimezone;\n\n\t\ttry {\n\t\t\tStore.logger?.(\n\t\t\t\t`[STORE => ${this.name}] [SET] Creating cronjob for ${key} with '${pattern}' as the pattern and '${timeZone}' for the timezone`\n\t\t\t);\n\n\t\t\tvalue.job = new Cron(\n\t\t\t\tpattern,\n\t\t\t\t{\n\t\t\t\t\tname: key,\n\t\t\t\t\ttimezone: timeZone,\n\t\t\t\t\tpaused: true, // we start the job manually once the client is ready\n\t\t\t\t\tprotect: value.protect?.bind(value) ?? protect,\n\t\t\t\t\tcatch: (error) => {\n\t\t\t\t\t\tvalue.error('Encountered an error while running the cron job', error);\n\t\t\t\t\t\tsentry?.captureException(error);\n\t\t\t\t\t\tvalue.catch?.bind(value)(error, value.job);\n\t\t\t\t\t},\n\t\t\t\t\t...options\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\t// we only want to monitor cron patterns and not single-use tasks that croner supports\n\t\t\t\t\tif (sentry && typeof pattern === 'string' && !pattern.includes(':')) {\n\t\t\t\t\t\tawait sentry.withMonitor(key, value.run.bind(value), {\n\t\t\t\t\t\t\tschedule: { type: 'crontab', value: normalizePattern(pattern) },\n\t\t\t\t\t\t\ttimezone: timeZone\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait value.run.bind(value)();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tvalue.error('Encountered an error while creating the cron job', error);\n\t\t\tvoid value.unload();\n\t\t}\n\n\t\treturn super.set(key, value);\n\t}\n\n\t/**\n\t * Deletes a task from the store and stops it if it's running.\n\t */\n\tpublic override delete(key: string) {\n\t\tconst task = this.get(key);\n\t\tif (task && !task.job.isStopped()) {\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\treturn super.delete(key);\n\t}\n\n\t/**\n\t * Stops all running cron jobs and clears the store.\n\t */\n\tpublic override clear() {\n\t\tthis.stopAll();\n\t\treturn super.clear();\n\t}\n}\n"],"mappings":";;;;;;;;;AAKA,IAAA,gBAAA,cAAA,uBAAA;CACA,AAAA,cAAA;EACA,MAAA,0CAAA,EAAA,MAAA,aAAA,CAAA;CACA;;;;;;;;;;;;CAaA,AAAA,WAAA;EACA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MAAA,GAAA;IACA;IACA,GAAA;GACA,GACA,YAAA;IAEA,IAAA,UAAA,OAAA,YAAA,YAAA,CAAA,QAAA,SAAA,GAAA,GACA,MAAA,OAAA,YAAA,KAAA,MAAA,IAAA,KAAA,KAAA,GAAA;KACA,UAAA;MAAA,MAAA;MAAA,OAAA,oDAAA,OAAA;KAAA;KACA,UAAA;IACA,CAAA;SAEA,MAAA,MAAA,IAAA,KAAA,KAAA,CAAA,CAAA;GAEA,CACA;EACA,SAAA,OAAA;GACA,MAAA,MAAA,oDAAA,KAAA;GACA,AAAA,MAAA,OAAA;EACA;EAEA,OAAA,MAAA,IAAA,KAAA,KAAA;CACA;;;;CAKA,AAAA,OAAA,KAAA;EACA,MAAA,OAAA,KAAA,IAAA,GAAA;EACA,IAAA,QAAA,CAAA,KAAA,IAAA,UAAA,GACA,KAAA,IAAA,KAAA;EAGA,OAAA,MAAA,OAAA,GAAA;CACA;;;;CAKA,AAAA,QAAA;EACA,KAAA,QAAA;EACA,OAAA,MAAA,MAAA;CACA;AACA"}
@@ -0,0 +1,3 @@
1
+
2
+ import { t as CronTaskStore } from "../../CronTaskStore-RmZUHmVY.cjs";
3
+ export { CronTaskStore };
@@ -1,4 +1,2 @@
1
1
  'use strict';
2
2
 
3
- //# sourceMappingURL=CronTaskTypes.cjs.map
4
- //# sourceMappingURL=CronTaskTypes.cjs.map
@@ -0,0 +1,3 @@
1
+
2
+ import { n as CronTaskHandlerOptions, t as CronJobOptions } from "../../CronTaskTypes-8bwitvv3.cjs";
3
+ export { CronJobOptions, CronTaskHandlerOptions };
@@ -1,45 +1,43 @@
1
1
  'use strict';
2
2
 
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
4
 
6
- // src/lib/utils/normalizePattern.ts
7
- var predefined = {
8
- "@annually": "0 0 1 1 *",
9
- "@yearly": "0 0 1 1 *",
10
- "@monthly": "0 0 1 * *",
11
- "@weekly": "0 0 * * 0",
12
- "@daily": "0 0 * * *",
13
- "@hourly": "0 * * * *"
5
+ //#region src/lib/utils/normalizePattern.ts
6
+ const predefined = {
7
+ "@annually": "0 0 1 1 *",
8
+ "@yearly": "0 0 1 1 *",
9
+ "@monthly": "0 0 1 * *",
10
+ "@weekly": "0 0 * * 0",
11
+ "@daily": "0 0 * * *",
12
+ "@hourly": "0 * * * *"
14
13
  };
15
- var cronTokens = {
16
- jan: 1,
17
- feb: 2,
18
- mar: 3,
19
- apr: 4,
20
- may: 5,
21
- jun: 6,
22
- jul: 7,
23
- aug: 8,
24
- sep: 9,
25
- oct: 10,
26
- nov: 11,
27
- dec: 12,
28
- sun: 0,
29
- mon: 1,
30
- tue: 2,
31
- wed: 3,
32
- thu: 4,
33
- fri: 5,
34
- sat: 6
14
+ const cronTokens = {
15
+ jan: 1,
16
+ feb: 2,
17
+ mar: 3,
18
+ apr: 4,
19
+ may: 5,
20
+ jun: 6,
21
+ jul: 7,
22
+ aug: 8,
23
+ sep: 9,
24
+ oct: 10,
25
+ nov: 11,
26
+ dec: 12,
27
+ sun: 0,
28
+ mon: 1,
29
+ tue: 2,
30
+ wed: 3,
31
+ thu: 4,
32
+ fri: 5,
33
+ sat: 6
35
34
  };
36
- var tokensRegex = new RegExp(Object.keys(cronTokens).join("|"), "g");
35
+ const tokensRegex = new RegExp(Object.keys(cronTokens).join("|"), "g");
37
36
  function normalizePattern(pattern) {
38
- if (Reflect.has(predefined, pattern)) return Reflect.get(predefined, pattern);
39
- return pattern.replace(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));
37
+ if (Reflect.has(predefined, pattern)) return Reflect.get(predefined, pattern);
38
+ return pattern.replaceAll(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));
40
39
  }
41
- __name(normalizePattern, "normalizePattern");
42
40
 
41
+ //#endregion
43
42
  exports.normalizePattern = normalizePattern;
44
- //# sourceMappingURL=normalizePattern.cjs.map
45
43
  //# sourceMapping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KAAU,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,UAAA,EAAY,KAAK,CAAC,CAAC,CAAA;AACtF;AAHgB,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA","file":"normalizePattern.cjs","sourcesContent":["/*\n * Credits to Sapphire for this\n * https://github.com/sapphiredev/utilities/blob/main/packages/cron/src/lib/constants.ts#L26-L57\n * https://github.com/sapphiredev/utilities/blob/main/packages/cron/src/lib/Cron.ts#L91\n */\n\nconst predefined = {\n\t'@annually': '0 0 1 1 *',\n\t'@yearly': '0 0 1 1 *',\n\t'@monthly': '0 0 1 * *',\n\t'@weekly': '0 0 * * 0',\n\t'@daily': '0 0 * * *',\n\t'@hourly': '0 * * * *'\n} as const;\n\nconst cronTokens: Record<string, number> = {\n\tjan: 1,\n\tfeb: 2,\n\tmar: 3,\n\tapr: 4,\n\tmay: 5,\n\tjun: 6,\n\tjul: 7,\n\taug: 8,\n\tsep: 9,\n\toct: 10,\n\tnov: 11,\n\tdec: 12,\n\tsun: 0,\n\tmon: 1,\n\ttue: 2,\n\twed: 3,\n\tthu: 4,\n\tfri: 5,\n\tsat: 6\n} as const;\n\nconst tokensRegex = new RegExp(Object.keys(cronTokens).join('|'), 'g');\n\nexport function normalizePattern(pattern: string): string {\n\tif (Reflect.has(predefined, pattern)) return Reflect.get(predefined, pattern);\n\treturn pattern.replace(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));\n}\n"]}
1
+ {"version":3,"file":"normalizePattern.cjs","names":[],"sources":["../../../../src/lib/utils/normalizePattern.ts"],"sourcesContent":["/*\n * Credits to Sapphire for this\n * https://github.com/sapphiredev/utilities/blob/main/packages/cron/src/lib/constants.ts#L26-L57\n * https://github.com/sapphiredev/utilities/blob/main/packages/cron/src/lib/Cron.ts#L91\n */\n\nconst predefined = {\n\t'@annually': '0 0 1 1 *',\n\t'@yearly': '0 0 1 1 *',\n\t'@monthly': '0 0 1 * *',\n\t'@weekly': '0 0 * * 0',\n\t'@daily': '0 0 * * *',\n\t'@hourly': '0 * * * *'\n} as const;\n\nconst cronTokens: Record<string, number> = {\n\tjan: 1,\n\tfeb: 2,\n\tmar: 3,\n\tapr: 4,\n\tmay: 5,\n\tjun: 6,\n\tjul: 7,\n\taug: 8,\n\tsep: 9,\n\toct: 10,\n\tnov: 11,\n\tdec: 12,\n\tsun: 0,\n\tmon: 1,\n\ttue: 2,\n\twed: 3,\n\tthu: 4,\n\tfri: 5,\n\tsat: 6\n} as const;\n\nconst tokensRegex = new RegExp(Object.keys(cronTokens).join('|'), 'g');\n\nexport function normalizePattern(pattern: string): string {\n\tif (Reflect.has(predefined, pattern)) return Reflect.get(predefined, pattern);\n\treturn pattern.replaceAll(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));\n}\n"],"mappings":";;;;;AAMA,MAAA,aAAA;CACA,aAAA;CACA,WAAA;CACA,YAAA;CACA,WAAA;CACA,UAAA;CACA,WAAA;AACA;AAEA,MAAA,aAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;CACA,KAAA;AACA;AAEA,MAAA,cAAA,IAAA,OAAA,OAAA,KAAA,UAAA,CAAA,CAAA,KAAA,GAAA,GAAA,GAAA;AAEA,SAAA,iBAAA,SAAA;CACA,IAAA,QAAA,IAAA,YAAA,OAAA,GAAA,OAAA,QAAA,IAAA,YAAA,OAAA;CACA,OAAA,QAAA,WAAA,cAAA,UAAA,OAAA,QAAA,IAAA,YAAA,KAAA,CAAA,CAAA;AACA"}
@@ -0,0 +1,6 @@
1
+
2
+ //#region src/lib/utils/normalizePattern.d.ts
3
+ declare function normalizePattern(pattern: string): string;
4
+ //#endregion
5
+ export { normalizePattern };
6
+ //# sourceMappingURL=normalizePattern.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizePattern.d.cts","names":[],"sources":["../../../../src/lib/utils/normalizePattern.ts"],"mappings":";;iBAuCgB,gBAAA,CAAiB,OAAe"}