@pikku/schedule 0.6.2 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # @pikku/schedule
2
2
 
3
+ ## 0.7.0
4
+
5
+ - Updating to match remaining packages
6
+
7
+
3
8
  ## 0.6.2
4
9
 
5
10
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/schedule",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "author": "yasser.fadl@gmail.com",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "test:coverage": "bash run-tests.sh --coverage"
18
18
  },
19
19
  "peerDependencies": {
20
- "@pikku/core": "^0.6.17"
20
+ "@pikku/core": "^0.7.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "^22.7.8",
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { PikkuTaskScheduler } from './pikku-task-scheduler.js'
@@ -1,80 +0,0 @@
1
- import { CronJob } from 'cron'
2
- import {
3
- CoreAPIFunctionSessionless,
4
- CoreServices,
5
- CoreSingletonServices,
6
- CoreUserSession,
7
- CreateSessionServices,
8
- pikkuState,
9
- } from '@pikku/core'
10
- import { runScheduledTask, CoreScheduledTask } from '@pikku/core/scheduler'
11
-
12
- export class PikkuTaskScheduler<TaskName extends string> {
13
- private jobs = new Map<string, CronJob>()
14
-
15
- constructor(
16
- private singletonServices: CoreSingletonServices,
17
- private createSessionServices?: CreateSessionServices<
18
- CoreSingletonServices,
19
- CoreServices,
20
- CoreUserSession
21
- >
22
- ) {}
23
-
24
- public startAll() {
25
- const scheduledTasks = pikkuState('scheduler', 'tasks')
26
- scheduledTasks.forEach((task) => this.startJobSchedule(task))
27
- }
28
-
29
- public stopAll() {
30
- this.jobs.forEach((job) => job.stop())
31
- this.jobs.clear()
32
- }
33
-
34
- public start(names: TaskName[]) {
35
- const scheduledTasks = pikkuState('scheduler', 'tasks')
36
- for (const name of names) {
37
- const task = scheduledTasks.get(name)
38
- if (task) {
39
- this.startJobSchedule(task)
40
- }
41
- }
42
- }
43
-
44
- public stop(names: TaskName[]) {
45
- for (const name of names) {
46
- const job = this.jobs.get(name)
47
- if (job) {
48
- job.stop()
49
- this.jobs.delete(name)
50
- }
51
- }
52
- }
53
-
54
- private startJobSchedule(
55
- task: CoreScheduledTask<
56
- CoreAPIFunctionSessionless<void, void>,
57
- CoreUserSession
58
- >
59
- ) {
60
- const job = new CronJob(
61
- task.schedule,
62
- async () => {
63
- this.singletonServices.logger.info(
64
- `Running scheduled task: ${task.name}`
65
- )
66
- await runScheduledTask({
67
- singletonServices: this.singletonServices,
68
- createSessionServices: this.createSessionServices as any,
69
- name: task.name,
70
- })
71
- this.singletonServices.logger.debug(
72
- `Completed scheduled task: ${task.name}`
73
- )
74
- },
75
- null,
76
- true
77
- )
78
- this.jobs.set(task.name, job)
79
- }
80
- }
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "module": "Node16",
6
- "outDir": "dist",
7
- "target": "esnext",
8
- "declaration": true,
9
- "resolveJsonModule": true
10
- },
11
- "include": ["bin/**/*.ts", "src/**/*.ts"],
12
- "exclude": ["**/*.test.ts", "node_modules", "bin/dist"],
13
- "references": [
14
- {
15
- "path": "../core/tsconfig.json"
16
- }
17
- ]
18
- }
@@ -1 +0,0 @@
1
- {"root":["./src/index.ts","./src/pikku-task-scheduler.ts"],"version":"5.7.3"}