@kingsworld/plugin-cron 4.0.1-next.ef6b006 → 4.0.1-pr-276.5ed6e26

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-CPIU4D6h.d.cts +84 -0
  2. package/dist/cjs/CronTask-CPIU4D6h.d.cts.map +1 -0
  3. package/dist/cjs/CronTaskHandler-B1NV5U_-.d.cts +30 -0
  4. package/dist/cjs/CronTaskHandler-B1NV5U_-.d.cts.map +1 -0
  5. package/dist/cjs/CronTaskHandler-ZUQoGvcS.cjs +64 -0
  6. package/dist/cjs/CronTaskHandler-ZUQoGvcS.cjs.map +1 -0
  7. package/dist/cjs/CronTaskStore-BK7iLYXq.d.cts +57 -0
  8. package/dist/cjs/CronTaskStore-BK7iLYXq.d.cts.map +1 -0
  9. package/dist/cjs/CronTaskTypes-BCLp38D3.d.cts +30 -0
  10. package/dist/cjs/CronTaskTypes-BCLp38D3.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-CFQhlY0I.d.mts +83 -0
  34. package/dist/esm/CronTask-CFQhlY0I.d.mts.map +1 -0
  35. package/dist/esm/CronTaskHandler-BpMfN0Gk.mjs +56 -0
  36. package/dist/esm/CronTaskHandler-BpMfN0Gk.mjs.map +1 -0
  37. package/dist/esm/CronTaskHandler-CrRFxQDW.d.mts +29 -0
  38. package/dist/esm/CronTaskHandler-CrRFxQDW.d.mts.map +1 -0
  39. package/dist/esm/CronTaskStore-BB2K0ZmF.d.mts +56 -0
  40. package/dist/esm/CronTaskStore-BB2K0ZmF.d.mts.map +1 -0
  41. package/dist/esm/CronTaskTypes-D0hLmxra.d.mts +29 -0
  42. package/dist/esm/CronTaskTypes-D0hLmxra.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 +4 -12
  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
@@ -0,0 +1,84 @@
1
+
2
+ import { t as CronJobOptions } from "./CronTaskTypes-BCLp38D3.cjs";
3
+ import { Piece } from "@sapphire/pieces";
4
+ import { Awaitable } from "@sapphire/framework";
5
+ import { Cron } from "croner";
6
+
7
+ //#region src/lib/structures/CronTask.d.ts
8
+ /**
9
+ * @example
10
+ *
11
+ * ```typescript
12
+ * // ping.ts
13
+ * import { CronTask } from '@kingsworld/plugin-cron';
14
+ *
15
+ * export class PingPong extends CronTask {
16
+ * public constructor(context: CronTask.LoaderContext, options: CronTask.Options) {
17
+ * super(context, {
18
+ * ...options,
19
+ * pattern: '* * * * *'
20
+ * });
21
+ * }
22
+ *
23
+ * public run() {
24
+ * this.info('Ping Pong! 🏓'); // CronTask[ping] Ping Pong! 🏓
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ declare abstract class CronTask<Options extends CronTask.Options = CronTask.Options> extends Piece<Options, 'cron-tasks'> {
30
+ job: Cron;
31
+ constructor(context: CronTask.LoaderContext, options: Options);
32
+ abstract run(): Awaitable<unknown>;
33
+ protect?(job: Cron): Awaitable<unknown>;
34
+ catch?(error: unknown, job: Cron): Awaitable<unknown>;
35
+ /**
36
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
37
+ * @param message The message to include after the prefix
38
+ * @param other Extra parameters to pass to the logger
39
+ * @example
40
+ * this.info('Hello world!'); // CronTask[my-task] Hello world!
41
+ */
42
+ info(message: string, ...other: unknown[]): void;
43
+ /**
44
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
45
+ * @param message The message to include after the prefix
46
+ * @param other Extra parameters to pass to the logger
47
+ * @example
48
+ * this.error('Something went wrong!'); // CronTask[my-task] Something went wrong!
49
+ */
50
+ error(message: string, ...other: unknown[]): void;
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.warn('Something is not right!'); // CronTask[my-task] Something is not right!
57
+ */
58
+ warn(message: string, ...other: unknown[]): void;
59
+ /**
60
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
61
+ * @param message The message to include after the prefix
62
+ * @param other Extra parameters to pass to the logger
63
+ * @example
64
+ * this.debug('Something is happening!'); // CronTask[my-task] Something is happening!
65
+ */
66
+ debug(message: string, ...other: unknown[]): void;
67
+ /**
68
+ * A helper function to log messages with the `CronTask[${name}]` prefix.
69
+ * @param message The message to include after the prefix
70
+ * @param other Extra parameters to pass to the logger
71
+ * @example
72
+ * this.trace('Loaded the file.'); // CronTask[my-task] Loaded the file.
73
+ */
74
+ trace(message: string, ...other: unknown[]): void;
75
+ }
76
+ declare namespace CronTask {
77
+ type Options = Piece.Options & CronJobOptions;
78
+ /** @deprecated Use {@linkcode LoaderContext} instead. */
79
+ type Context = LoaderContext;
80
+ type LoaderContext = Piece.LoaderContext<'cron-tasks'>;
81
+ }
82
+ //#endregion
83
+ export { CronTask as t };
84
+ //# sourceMappingURL=CronTask-CPIU4D6h.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CronTask-CPIU4D6h.d.cts","names":[],"sources":["../../src/lib/structures/CronTask.ts"],"mappings":";;;;;;;;;AA0BA;;;;;;;;;;;;;;;;;;;uBAAsB,QAAA,iBAAyB,QAAA,CAAS,OAAA,GAAU,QAAA,CAAS,OAAA,UAAiB,KAAA,CAAM,OAAA;EAClF,GAAA,EAAK,IAAA;cAED,OAAA,EAAS,QAAA,CAAS,aAAA,EAAe,OAAA,EAAS,OAAA;EAAA,SAI7C,GAAA,CAAA,GAAO,SAAA;EAEhB,OAAA,CAAA,CAAS,GAAA,EAAK,IAAA,GAAO,SAAA;EAErB,KAAA,CAAA,CAAO,KAAA,WAAgB,GAAA,EAAK,IAAA,GAAO,SAAA;EAVtB;;;;;;;EAmBb,IAAA,CAAK,OAAA,aAAoB,KAAA;EAbT;;;;;;;EAwBhB,KAAA,CAAM,OAAA,aAAoB,KAAA;EApBH;;;;;;;EA+BvB,IAAA,CAAK,OAAA,aAAoB,KAAA;EAAzB;;;;;;;EAWA,KAAA,CAAM,OAAA,aAAoB,KAAA;EAWA;;;AAKlC;;;;EALQ,KAAA,CAAM,OAAA,aAAoB,KAAA;AAAA;AAAA,kBAKjB,QAAA;EAAA,KACJ,OAAA,GAAU,KAAA,CAAM,OAAA,GAAU,cAAA;EAGS;EAAA,KADnC,OAAA,GAAU,aAAA;EAAA,KACV,aAAA,GAAgB,KAAA,CAAM,aAAA;AAAA"}
@@ -0,0 +1,30 @@
1
+
2
+ import { n as CronTaskHandlerOptions } from "./CronTaskTypes-BCLp38D3.cjs";
3
+ import Sentry from "@sentry/node";
4
+
5
+ //#region src/lib/CronTaskHandler.d.ts
6
+ declare class CronTaskHandler {
7
+ /**
8
+ * The default IANA/TZ timezone to use for all cron jobs.
9
+ * You can override this per task, using the timezone option.
10
+ * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
11
+ */
12
+ defaultTimezone?: CronTaskHandlerOptions['defaultTimezone'];
13
+ /**
14
+ * The ability to opt-out of instrumenting cron jobs with Sentry.
15
+ * If you don't use Sentry, you can ignore this option.
16
+ * @see https://docs.sentry.io/product/crons/
17
+ * @default false
18
+ */
19
+ disableSentry: boolean;
20
+ /**
21
+ * The Sentry instance to use for instrumenting cron jobs.
22
+ * This is only available when [`@sentry/node`](https://www.npmjs.com/package/@sentry/node)
23
+ * is installed and the {@linkcode disableSentry} option is set to false.
24
+ */
25
+ sentry?: typeof Sentry;
26
+ constructor(options?: Partial<CronTaskHandlerOptions>);
27
+ }
28
+ //#endregion
29
+ export { CronTaskHandler as t };
30
+ //# sourceMappingURL=CronTaskHandler-B1NV5U_-.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CronTaskHandler-B1NV5U_-.d.cts","names":[],"sources":["../../src/lib/CronTaskHandler.ts"],"mappings":";;;;;cAGa,eAAA;;AAAb;;;;EAMQ,eAAA,GAAkB,sBAAA;EAiBY;;;;;;EAT9B,aAAA;EAOA;;;;;EAAA,MAAA,UAAgB,MAAA;cAEJ,OAAA,GAAU,OAAA,CAAQ,sBAAA;AAAA"}
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+
4
+ //#region \0@oxc-project+runtime@0.127.0/helpers/typeof.js
5
+ function _typeof(o) {
6
+ "@babel/helpers - typeof";
7
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
8
+ return typeof o;
9
+ } : function(o) {
10
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
11
+ }, _typeof(o);
12
+ }
13
+
14
+ //#endregion
15
+ //#region \0@oxc-project+runtime@0.127.0/helpers/toPrimitive.js
16
+ function toPrimitive(t, r) {
17
+ if ("object" != _typeof(t) || !t) return t;
18
+ var e = t[Symbol.toPrimitive];
19
+ if (void 0 !== e) {
20
+ var i = e.call(t, r || "default");
21
+ if ("object" != _typeof(i)) return i;
22
+ throw new TypeError("@@toPrimitive must return a primitive value.");
23
+ }
24
+ return ("string" === r ? String : Number)(t);
25
+ }
26
+
27
+ //#endregion
28
+ //#region \0@oxc-project+runtime@0.127.0/helpers/toPropertyKey.js
29
+ function toPropertyKey(t) {
30
+ var i = toPrimitive(t, "string");
31
+ return "symbol" == _typeof(i) ? i : i + "";
32
+ }
33
+
34
+ //#endregion
35
+ //#region \0@oxc-project+runtime@0.127.0/helpers/defineProperty.js
36
+ function _defineProperty(e, r, t) {
37
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
38
+ value: t,
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0
42
+ }) : e[r] = t, e;
43
+ }
44
+
45
+ //#endregion
46
+ //#region src/lib/CronTaskHandler.ts
47
+ var CronTaskHandler = class {
48
+ constructor(options) {
49
+ _defineProperty(this, "defaultTimezone", void 0);
50
+ _defineProperty(this, "disableSentry", void 0);
51
+ _defineProperty(this, "sentry", void 0);
52
+ this.defaultTimezone = options?.defaultTimezone;
53
+ this.disableSentry = options?.disableSentry ?? false;
54
+ }
55
+ };
56
+
57
+ //#endregion
58
+ Object.defineProperty(exports, 'CronTaskHandler', {
59
+ enumerable: true,
60
+ get: function () {
61
+ return CronTaskHandler;
62
+ }
63
+ });
64
+ //# sourceMappingURL=CronTaskHandler-ZUQoGvcS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CronTaskHandler-ZUQoGvcS.cjs","names":[],"sources":["../../src/lib/CronTaskHandler.ts"],"sourcesContent":["import type Sentry from '@sentry/node';\nimport type { CronTaskHandlerOptions } from './types/CronTaskTypes';\n\nexport class CronTaskHandler {\n\t/**\n\t * The default IANA/TZ timezone to use for all cron jobs.\n\t * You can override this per task, using the timezone option.\n\t * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n\t */\n\tpublic defaultTimezone?: CronTaskHandlerOptions['defaultTimezone'];\n\n\t/**\n\t * The ability to opt-out of instrumenting cron jobs with Sentry.\n\t * If you don't use Sentry, you can ignore this option.\n\t * @see https://docs.sentry.io/product/crons/\n\t * @default false\n\t */\n\tpublic disableSentry: boolean;\n\n\t/**\n\t * The Sentry instance to use for instrumenting cron jobs.\n\t * This is only available when [`@sentry/node`](https://www.npmjs.com/package/@sentry/node)\n\t * is installed and the {@linkcode disableSentry} option is set to false.\n\t */\n\tpublic sentry?: typeof Sentry;\n\n\tpublic constructor(options?: Partial<CronTaskHandlerOptions>) {\n\t\tthis.defaultTimezone = options?.defaultTimezone;\n\t\tthis.disableSentry = options?.disableSentry ?? false;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAA,kBAAA,MAAA;CAuBA,AAAA,YAAA,SAAA;wBAjBA,0BAAA;wBAQA,wBAAA;wBAOA,iBAAA;AAGA,OAAA,kBAAA,SAAA;AACA,OAAA,gBAAA,SAAA,iBAAA"}
@@ -0,0 +1,57 @@
1
+
2
+ import { t as CronTask } from "./CronTask-CPIU4D6h.cjs";
3
+ import { Store } from "@sapphire/pieces";
4
+
5
+ //#region src/lib/structures/CronTaskStore.d.ts
6
+ declare class CronTaskStore extends Store<CronTask, 'cron-tasks'> {
7
+ constructor();
8
+ /**
9
+ * Loops over all tasks and pauses those that are running.
10
+ *
11
+ * @remarks
12
+ * This method will only pause tasks that:
13
+ * - Are enabled
14
+ * - Are currently running
15
+ * - Have not been permanently stopped
16
+ *
17
+ * @returns CronTaskStore
18
+ */
19
+ pauseAll(): this;
20
+ /**
21
+ * Loops over all tasks and resumes those that are paused.
22
+ *
23
+ * @remarks
24
+ * This method will only resume tasks that:
25
+ * - Are enabled
26
+ * - Are not currently running
27
+ * - Have not been permanently stopped
28
+ *
29
+ * @returns CronTaskStore
30
+ */
31
+ resumeAll(): this;
32
+ /**
33
+ * Loops over all tasks and stops those that are running.
34
+ *
35
+ * @remarks
36
+ * This method will only stop tasks that:
37
+ * - Are enabled
38
+ * - Have not been permanently stopped
39
+ *
40
+ * ⚠️ Stopping jobs is **permanent** and cannot be resumed afterwards!
41
+ *
42
+ * @returns CronTaskStore
43
+ */
44
+ stopAll(): this;
45
+ set(key: string, value: CronTask): this;
46
+ /**
47
+ * Deletes a task from the store and stops it if it's running.
48
+ */
49
+ delete(key: string): boolean;
50
+ /**
51
+ * Stops all running cron jobs and clears the store.
52
+ */
53
+ clear(): void;
54
+ }
55
+ //#endregion
56
+ export { CronTaskStore as t };
57
+ //# sourceMappingURL=CronTaskStore-BK7iLYXq.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CronTaskStore-BK7iLYXq.d.cts","names":[],"sources":["../../src/lib/structures/CronTaskStore.ts"],"mappings":";;;;;cAKa,aAAA,SAAsB,KAAA,CAAM,QAAA;;EAA5B;;;;;;;;;;;EAgBL,QAAA,CAAA;EAqBA;;;;;;;;;;;EAAA,SAAA,CAAA;;;;;;;;;;;;;EAsBA,OAAA,CAAA;EAUS,GAAA,CAAI,GAAA,UAAa,KAAA,EAAO,QAAA;;;;EAsDxB,MAAA,CAAO,GAAA;;;;EAYP,KAAA,CAAA;AAAA"}
@@ -0,0 +1,30 @@
1
+
2
+ import { CronOptions } from "croner";
3
+
4
+ //#region src/lib/types/CronTaskTypes.d.ts
5
+ interface CronTaskHandlerOptions {
6
+ /**
7
+ * The default IANA timezone to use for all cron jobs.
8
+ * You can override this per task, using the timezone option.
9
+ */
10
+ defaultTimezone?: string;
11
+ /**
12
+ * The ability to opt-out of instrumenting cron jobs with Sentry.
13
+ * If you don't use Sentry, you can ignore this option.
14
+ * @see https://docs.sentry.io/product/crons/
15
+ * @default false
16
+ */
17
+ disableSentry: boolean;
18
+ }
19
+ interface CronJobOptions extends Pick<CronOptions, 'maxRuns' | 'unref' | 'timezone'> {
20
+ pattern: string | Date;
21
+ /**
22
+ * If true, prevents the job from running if the previous execution is still in progress.
23
+ * If the task has a protect method, it will be called if the job is blocked.
24
+ * @default false
25
+ */
26
+ protect?: boolean;
27
+ }
28
+ //#endregion
29
+ export { CronTaskHandlerOptions as n, CronJobOptions as t };
30
+ //# sourceMappingURL=CronTaskTypes-BCLp38D3.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CronTaskTypes-BCLp38D3.d.cts","names":[],"sources":["../../src/lib/types/CronTaskTypes.ts"],"mappings":";;;;UAEiB,sBAAA;;AAAjB;;;EAKC,eAAA;EAQa;AAGd;;;;;EAHC,aAAA;AAAA;AAAA,UAGgB,cAAA,SAAuB,IAAA,CAAK,WAAA;EAC5C,OAAA,WAAkB,IAAA;EAD0B;;;;;EAO5C,OAAA;AAAA"}
@@ -1,37 +1,22 @@
1
1
  'use strict';
2
2
 
3
- var CronTaskHandler_cjs = require('./lib/CronTaskHandler.cjs');
4
- var CronTask_cjs = require('./lib/structures/CronTask.cjs');
5
- var CronTaskStore_cjs = require('./lib/structures/CronTaskStore.cjs');
6
- var CronTaskTypes_cjs = require('./lib/types/CronTaskTypes.cjs');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_CronTaskHandler = require('./CronTaskHandler-ZUQoGvcS.cjs');
5
+ const require_lib_structures_CronTask = require('./lib/structures/CronTask.cjs');
6
+ const require_lib_structures_CronTaskStore = require('./lib/structures/CronTaskStore.cjs');
7
7
 
8
- // src/index.ts
9
- var version = "4.0.1-next.ef6b006";
8
+ //#region src/index.ts
9
+ /**
10
+ * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.
11
+ * An example use of this is showing it of in a bot information command.
12
+ *
13
+ * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild
14
+ */
15
+ const version = "4.0.1-pr-276.5ed6e26";
10
16
 
17
+ //#endregion
18
+ exports.CronTask = require_lib_structures_CronTask.CronTask;
19
+ exports.CronTaskHandler = require_CronTaskHandler.CronTaskHandler;
20
+ exports.CronTaskStore = require_lib_structures_CronTaskStore.CronTaskStore;
11
21
  exports.version = version;
12
- Object.keys(CronTaskHandler_cjs).forEach(function (k) {
13
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
14
- enumerable: true,
15
- get: function () { return CronTaskHandler_cjs[k]; }
16
- });
17
- });
18
- Object.keys(CronTask_cjs).forEach(function (k) {
19
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
20
- enumerable: true,
21
- get: function () { return CronTask_cjs[k]; }
22
- });
23
- });
24
- Object.keys(CronTaskStore_cjs).forEach(function (k) {
25
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
26
- enumerable: true,
27
- get: function () { return CronTaskStore_cjs[k]; }
28
- });
29
- });
30
- Object.keys(CronTaskTypes_cjs).forEach(function (k) {
31
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
32
- enumerable: true,
33
- get: function () { return CronTaskTypes_cjs[k]; }
34
- });
35
- });
36
- //# sourceMappingURL=index.cjs.map
37
22
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;AA+BO,IAAM,OAAA,GAAkB","file":"index.cjs","sourcesContent":["import type { CronTaskStore } from './lib/structures/CronTaskStore';\nimport type { CronTaskHandler } from './lib/CronTaskHandler';\nimport type { CronTaskHandlerOptions } from './lib/types/CronTaskTypes';\n\nexport * from './lib/CronTaskHandler';\nexport * from './lib/structures/CronTask';\nexport * from './lib/structures/CronTaskStore';\nexport * from './lib/types/CronTaskTypes';\n\ndeclare module '@sapphire/pieces' {\n\tinterface Container {\n\t\tcronTasks: CronTaskHandler;\n\t}\n\n\tinterface StoreRegistryEntries {\n\t\t'cron-tasks': CronTaskStore;\n\t}\n}\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\tcronTasks?: Partial<CronTaskHandlerOptions>;\n\t}\n}\n\n/**\n * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\nexport const version: string = '4.0.1-next.ef6b006';\n"]}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import type { CronTaskStore } from './lib/structures/CronTaskStore';\nimport type { CronTaskHandler } from './lib/CronTaskHandler';\nimport type { CronTaskHandlerOptions } from './lib/types/CronTaskTypes';\n\nexport * from './lib/CronTaskHandler';\nexport * from './lib/structures/CronTask';\nexport * from './lib/structures/CronTaskStore';\nexport * from './lib/types/CronTaskTypes';\n\ndeclare module '@sapphire/pieces' {\n\tinterface Container {\n\t\tcronTasks: CronTaskHandler;\n\t}\n\n\tinterface StoreRegistryEntries {\n\t\t'cron-tasks': CronTaskStore;\n\t}\n}\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\tcronTasks?: Partial<CronTaskHandlerOptions>;\n\t}\n}\n\n/**\n * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\nexport const version: string = '[VI]{{inject}}[/VI]';\n"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAA,UAAA"}
@@ -1,192 +1,22 @@
1
- import { Piece, Store } from '@sapphire/pieces';
2
- import { Awaitable } from '@sapphire/framework';
3
- import { CronOptions, Cron } from 'croner';
4
- import Sentry from '@sentry/node';
5
1
 
6
- interface CronTaskHandlerOptions {
7
- /**
8
- * The default IANA timezone to use for all cron jobs.
9
- * You can override this per task, using the timezone option.
10
- */
11
- defaultTimezone?: string;
12
- /**
13
- * The ability to opt-out of instrumenting cron jobs with Sentry.
14
- * If you don't use Sentry, you can ignore this option.
15
- * @see https://docs.sentry.io/product/crons/
16
- * @default false
17
- */
18
- disableSentry: boolean;
19
- }
20
- interface CronJobOptions extends Pick<CronOptions, 'maxRuns' | 'unref' | 'timezone'> {
21
- pattern: string | Date;
22
- /**
23
- * If true, prevents the job from running if the previous execution is still in progress.
24
- * If the task has a protect method, it will be called if the job is blocked.
25
- * @default false
26
- */
27
- protect?: boolean;
28
- }
29
-
30
- /**
31
- * @example
32
- *
33
- * ```typescript
34
- * // ping.ts
35
- * import { CronTask } from '@kingsworld/plugin-cron';
36
- *
37
- * export class PingPong extends CronTask {
38
- * public constructor(context: CronTask.LoaderContext, options: CronTask.Options) {
39
- * super(context, {
40
- * ...options,
41
- * pattern: '* * * * *'
42
- * });
43
- * }
44
- *
45
- * public run() {
46
- * this.info('Ping Pong! 🏓'); // CronTask[ping] Ping Pong! 🏓
47
- * }
48
- * }
49
- * ```
50
- */
51
- declare abstract class CronTask<Options extends CronTask.Options = CronTask.Options> extends Piece<Options, 'cron-tasks'> {
52
- job: Cron;
53
- constructor(context: CronTask.LoaderContext, options: Options);
54
- abstract run(): Awaitable<unknown>;
55
- protect?(job: Cron): Awaitable<unknown>;
56
- catch?(error: unknown, job: Cron): Awaitable<unknown>;
57
- /**
58
- * A helper function to log messages with the `CronTask[${name}]` prefix.
59
- * @param message The message to include after the prefix
60
- * @param other Extra parameters to pass to the logger
61
- * @example
62
- * this.info('Hello world!'); // CronTask[my-task] Hello world!
63
- */
64
- info(message: string, ...other: unknown[]): void;
65
- /**
66
- * A helper function to log messages with the `CronTask[${name}]` prefix.
67
- * @param message The message to include after the prefix
68
- * @param other Extra parameters to pass to the logger
69
- * @example
70
- * this.error('Something went wrong!'); // CronTask[my-task] Something went wrong!
71
- */
72
- error(message: string, ...other: unknown[]): void;
73
- /**
74
- * A helper function to log messages with the `CronTask[${name}]` prefix.
75
- * @param message The message to include after the prefix
76
- * @param other Extra parameters to pass to the logger
77
- * @example
78
- * this.warn('Something is not right!'); // CronTask[my-task] Something is not right!
79
- */
80
- warn(message: string, ...other: unknown[]): void;
81
- /**
82
- * A helper function to log messages with the `CronTask[${name}]` prefix.
83
- * @param message The message to include after the prefix
84
- * @param other Extra parameters to pass to the logger
85
- * @example
86
- * this.debug('Something is happening!'); // CronTask[my-task] Something is happening!
87
- */
88
- debug(message: string, ...other: unknown[]): void;
89
- /**
90
- * A helper function to log messages with the `CronTask[${name}]` prefix.
91
- * @param message The message to include after the prefix
92
- * @param other Extra parameters to pass to the logger
93
- * @example
94
- * this.trace('Loaded the file.'); // CronTask[my-task] Loaded the file.
95
- */
96
- trace(message: string, ...other: unknown[]): void;
97
- }
98
- declare namespace CronTask {
99
- type Options = Piece.Options & CronJobOptions;
100
- /** @deprecated Use {@linkcode LoaderContext} instead. */
101
- type Context = LoaderContext;
102
- type LoaderContext = Piece.LoaderContext<'cron-tasks'>;
103
- }
104
-
105
- declare class CronTaskStore extends Store<CronTask, 'cron-tasks'> {
106
- constructor();
107
- /**
108
- * Loops over all tasks and pauses those that are running.
109
- *
110
- * @remarks
111
- * This method will only pause tasks that:
112
- * - Are enabled
113
- * - Are currently running
114
- * - Have not been permanently stopped
115
- *
116
- * @returns CronTaskStore
117
- */
118
- pauseAll(): this;
119
- /**
120
- * Loops over all tasks and resumes those that are paused.
121
- *
122
- * @remarks
123
- * This method will only resume tasks that:
124
- * - Are enabled
125
- * - Are not currently running
126
- * - Have not been permanently stopped
127
- *
128
- * @returns CronTaskStore
129
- */
130
- resumeAll(): this;
131
- /**
132
- * Loops over all tasks and stops those that are running.
133
- *
134
- * @remarks
135
- * This method will only stop tasks that:
136
- * - Are enabled
137
- * - Have not been permanently stopped
138
- *
139
- * ⚠️ Stopping jobs is **permanent** and cannot be resumed afterwards!
140
- *
141
- * @returns CronTaskStore
142
- */
143
- stopAll(): this;
144
- set(key: string, value: CronTask): this;
145
- /**
146
- * Deletes a task from the store and stops it if it's running.
147
- */
148
- delete(key: string): boolean;
149
- /**
150
- * Stops all running cron jobs and clears the store.
151
- */
152
- clear(): void;
153
- }
154
-
155
- declare class CronTaskHandler {
156
- /**
157
- * The default IANA/TZ timezone to use for all cron jobs.
158
- * You can override this per task, using the timezone option.
159
- * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
160
- */
161
- defaultTimezone?: CronTaskHandlerOptions['defaultTimezone'];
162
- /**
163
- * The ability to opt-out of instrumenting cron jobs with Sentry.
164
- * If you don't use Sentry, you can ignore this option.
165
- * @see https://docs.sentry.io/product/crons/
166
- * @default false
167
- */
168
- disableSentry: boolean;
169
- /**
170
- * The Sentry instance to use for instrumenting cron jobs.
171
- * This is only available when [`@sentry/node`](https://www.npmjs.com/package/@sentry/node)
172
- * is installed and the {@linkcode disableSentry} option is set to false.
173
- */
174
- sentry?: typeof Sentry;
175
- constructor(options?: Partial<CronTaskHandlerOptions>);
176
- }
2
+ import { n as CronTaskHandlerOptions, t as CronJobOptions } from "./CronTaskTypes-BCLp38D3.cjs";
3
+ import { t as CronTask } from "./CronTask-CPIU4D6h.cjs";
4
+ import { t as CronTaskStore } from "./CronTaskStore-BK7iLYXq.cjs";
5
+ import { t as CronTaskHandler } from "./CronTaskHandler-B1NV5U_-.cjs";
177
6
 
7
+ //#region src/index.d.ts
178
8
  declare module '@sapphire/pieces' {
179
- interface Container {
180
- cronTasks: CronTaskHandler;
181
- }
182
- interface StoreRegistryEntries {
183
- 'cron-tasks': CronTaskStore;
184
- }
9
+ interface Container {
10
+ cronTasks: CronTaskHandler;
11
+ }
12
+ interface StoreRegistryEntries {
13
+ 'cron-tasks': CronTaskStore;
14
+ }
185
15
  }
186
16
  declare module 'discord.js' {
187
- interface ClientOptions {
188
- cronTasks?: Partial<CronTaskHandlerOptions>;
189
- }
17
+ interface ClientOptions {
18
+ cronTasks?: Partial<CronTaskHandlerOptions>;
19
+ }
190
20
  }
191
21
  /**
192
22
  * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.
@@ -195,6 +25,6 @@ declare module 'discord.js' {
195
25
  * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild
196
26
  */
197
27
  declare const version: string;
198
-
199
- export { CronTask, CronTaskHandler, CronTaskStore, version };
200
- export type { CronJobOptions, CronTaskHandlerOptions };
28
+ //#endregion
29
+ export { CronJobOptions, CronTask, CronTaskHandler, CronTaskHandlerOptions, CronTaskStore, version };
30
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;YAUW,SAAA;IACT,SAAA,EAAW,eAAA;EAAA;EAAA,UAGF,oBAAA;IACT,YAAA,EAAc,aAAA;EAAA;AAAA;AAAA;EAAA,UAKE,aAAA;IAChB,SAAA,GAAY,OAAA,CAAQ,sBAAA;EAAA;AAAA;;;;;;;cAUT,OAAA"}
@@ -1,39 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var __defProp = Object.defineProperty;
4
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_CronTaskHandler = require('../CronTaskHandler-ZUQoGvcS.cjs');
7
5
 
8
- // src/lib/CronTaskHandler.ts
9
- var _CronTaskHandler = class _CronTaskHandler {
10
- constructor(options) {
11
- /**
12
- * The default IANA/TZ timezone to use for all cron jobs.
13
- * You can override this per task, using the timezone option.
14
- * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
15
- */
16
- __publicField(this, "defaultTimezone");
17
- /**
18
- * The ability to opt-out of instrumenting cron jobs with Sentry.
19
- * If you don't use Sentry, you can ignore this option.
20
- * @see https://docs.sentry.io/product/crons/
21
- * @default false
22
- */
23
- __publicField(this, "disableSentry");
24
- /**
25
- * The Sentry instance to use for instrumenting cron jobs.
26
- * This is only available when [`@sentry/node`](https://www.npmjs.com/package/@sentry/node)
27
- * is installed and the {@linkcode disableSentry} option is set to false.
28
- */
29
- __publicField(this, "sentry");
30
- this.defaultTimezone = options?.defaultTimezone;
31
- this.disableSentry = options?.disableSentry ?? false;
32
- }
33
- };
34
- __name(_CronTaskHandler, "CronTaskHandler");
35
- var CronTaskHandler = _CronTaskHandler;
36
-
37
- exports.CronTaskHandler = CronTaskHandler;
38
- //# sourceMappingURL=CronTaskHandler.cjs.map
39
- //# sourceMappingURL=CronTaskHandler.cjs.map
6
+ exports.CronTaskHandler = require_CronTaskHandler.CronTaskHandler;
@@ -0,0 +1,3 @@
1
+
2
+ import { t as CronTaskHandler } from "../CronTaskHandler-B1NV5U_-.cjs";
3
+ export { CronTaskHandler };