@molecule/api-scheduler-cloudflare 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -23
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -10,34 +10,31 @@
|
|
|
10
10
|
* change — only the bond wired in `bonds/`.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* import { bond } from '@molecule/api-bond'
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { schedule, setProvider, start } from '@molecule/api-scheduler'
|
|
16
15
|
* import { createProvider } from '@molecule/api-scheduler-cloudflare'
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* bond('scheduler', scheduler)
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* // worker.ts — the Cron Trigger entry point
|
|
26
|
-
* import { scheduler } from './bonds/scheduler-cloudflare.js'
|
|
27
|
-
* import { setupBonds } from './bonds/index.js'
|
|
17
|
+
* const scheduler = createProvider()
|
|
18
|
+
* setProvider(scheduler)
|
|
28
19
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
20
|
+
* schedule({
|
|
21
|
+
* name: 'monitor-sweep',
|
|
22
|
+
* intervalMs: 60000,
|
|
23
|
+
* async handler() {
|
|
24
|
+
* // ...
|
|
33
25
|
* },
|
|
34
|
-
* }
|
|
35
|
-
*
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // REQUIRED, same as the default provider: nothing runs until start().
|
|
29
|
+
* // Unlike it, start() begins no timers — a Worker has no process to hold one.
|
|
30
|
+
* start()
|
|
36
31
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
32
|
+
* // Then, from the Worker's scheduled() handler, wrapped in ctx.waitUntil():
|
|
33
|
+
* // export default { async scheduled(event, env, ctx) {
|
|
34
|
+
* // ctx.waitUntil(scheduler.runDueTasks())
|
|
35
|
+
* // } }
|
|
36
|
+
* // and in wrangler.toml: [triggers] crons = ["* * * * *"]
|
|
37
|
+
* void scheduler.runDueTasks()
|
|
41
38
|
* ```
|
|
42
39
|
*
|
|
43
40
|
* @remarks
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,34 +10,31 @@
|
|
|
10
10
|
* change — only the bond wired in `bonds/`.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* import { bond } from '@molecule/api-bond'
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { schedule, setProvider, start } from '@molecule/api-scheduler'
|
|
16
15
|
* import { createProvider } from '@molecule/api-scheduler-cloudflare'
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* bond('scheduler', scheduler)
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* // worker.ts — the Cron Trigger entry point
|
|
26
|
-
* import { scheduler } from './bonds/scheduler-cloudflare.js'
|
|
27
|
-
* import { setupBonds } from './bonds/index.js'
|
|
17
|
+
* const scheduler = createProvider()
|
|
18
|
+
* setProvider(scheduler)
|
|
28
19
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
20
|
+
* schedule({
|
|
21
|
+
* name: 'monitor-sweep',
|
|
22
|
+
* intervalMs: 60000,
|
|
23
|
+
* async handler() {
|
|
24
|
+
* // ...
|
|
33
25
|
* },
|
|
34
|
-
* }
|
|
35
|
-
*
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // REQUIRED, same as the default provider: nothing runs until start().
|
|
29
|
+
* // Unlike it, start() begins no timers — a Worker has no process to hold one.
|
|
30
|
+
* start()
|
|
36
31
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
32
|
+
* // Then, from the Worker's scheduled() handler, wrapped in ctx.waitUntil():
|
|
33
|
+
* // export default { async scheduled(event, env, ctx) {
|
|
34
|
+
* // ctx.waitUntil(scheduler.runDueTasks())
|
|
35
|
+
* // } }
|
|
36
|
+
* // and in wrangler.toml: [triggers] crons = ["* * * * *"]
|
|
37
|
+
* void scheduler.runDueTasks()
|
|
41
38
|
* ```
|
|
42
39
|
*
|
|
43
40
|
* @remarks
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-scheduler-cloudflare",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Scheduler provider for Cloudflare Workers Cron Triggers — the platform owns the clock, so tasks run from the scheduled() handler instead of an in-process timer.",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/api-scheduler-cloudflare",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"types": "dist/index.d.ts",
|
|
@@ -32,11 +33,11 @@
|
|
|
32
33
|
"directory": "packages/api/bonds/scheduler/cloudflare"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@molecule/api-bond": "1.0.
|
|
36
|
-
"@molecule/api-scheduler": "1.0.
|
|
36
|
+
"@molecule/api-bond": "1.0.2",
|
|
37
|
+
"@molecule/api-scheduler": "1.0.2",
|
|
37
38
|
"@types/node": "26.1.2",
|
|
38
39
|
"typescript": "6.0.3",
|
|
39
|
-
"vitest": "4.1.
|
|
40
|
+
"vitest": "4.1.11"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"@molecule/api-scheduler": "^1.0.1",
|