@chidchanun/bcp 0.2.8 → 0.2.9

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/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # BCP Framework
2
2
 
3
- BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, guarded application flows, API routes, authentication, authorization, database access, background jobs, observability, validation, uploads, storage and standalone Node.js production deployment.
3
+ BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, guarded application flows, API routes, authentication, authorization, database access, background jobs, recurring scheduling, observability, validation, uploads, storage and standalone Node.js production deployment.
4
4
 
5
- > **Development target:** `0.2.8Background Jobs Platform`
5
+ > **Development target:** `0.2.9Job Scheduling Platform`
6
6
  >
7
- > `0.2.8` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
7
+ > `0.2.9` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
8
8
 
9
9
  ## 0.2 platform
10
10
 
11
- `0.2.0` established the Framework Platform baseline, `0.2.1` added the Documentation Platform, `0.2.2` added Configuration & Environment v2, `0.2.3` added Database Platform v2, `0.2.4` added Application Packaging, `0.2.5` added Authentication Platform v2, `0.2.6` added Authorization & Security v2, `0.2.7` added Observability Platform v2, and `0.2.8` adds a provider-neutral background-job queue/worker contract with delayed work, retry/backoff, cancellation and process-local reference storage.
11
+ `0.2.0` established the Framework Platform baseline, `0.2.1` added the Documentation Platform, `0.2.2` added Configuration & Environment v2, `0.2.3` added Database Platform v2, `0.2.4` added Application Packaging, `0.2.5` added Authentication Platform v2, `0.2.6` added Authorization & Security v2, `0.2.7` added Observability Platform v2, `0.2.8` added Background Jobs Platform, and `0.2.9` adds recurring interval/UTC-cron scheduling with lease-aware shared-store contracts.
12
12
 
13
13
  Machine-readable platform contracts:
14
14
 
@@ -36,6 +36,7 @@ docs/api-manifest.json
36
36
  | Request security | Same-origin validation and signed CSRF tokens for unsafe mutations |
37
37
  | Middleware | Middleware System v2 with onion execution |
38
38
  | Background jobs | Adapter contract, in-memory queue, delayed jobs, retries/backoff, cancellation and concurrent workers |
39
+ | Scheduling | Recurring interval jobs, UTC cron, schedule-store leases and deterministic scheduled run IDs |
39
40
  | Observability | Structured logs, counters/gauges/histograms, Prometheus output, request metrics and health/readiness checks |
40
41
  | Validation | Typed validators and structured validation errors |
41
42
  | Error handling | HTTP error helpers and consistent error responses |
@@ -274,24 +275,6 @@ import {
274
275
  authorize,
275
276
  defineAuthorizationPolicy,
276
277
  } from "bcp/auth";
277
-
278
- const updateProject =
279
- defineAuthorizationPolicy(
280
- ({
281
- user,
282
- resource,
283
- }) =>
284
- resource.ownerId ===
285
- user.id
286
- );
287
-
288
- await authorize(
289
- updateProject,
290
- {
291
- user,
292
- resource: project,
293
- }
294
- );
295
278
  ```
296
279
 
297
280
  Request-security helpers are exposed from `bcp/server`:
@@ -308,48 +291,12 @@ Read more: [Authorization & Security v2](docs/authorization-security.md)
308
291
 
309
292
  ## Observability Platform v2 — 0.2.7
310
293
 
311
- Create one application metrics registry:
312
-
313
294
  ```ts
314
295
  import {
296
+ createHealthRegistry,
315
297
  createMetricsRegistry,
316
- } from "bcp/observability";
317
-
318
- export const metrics =
319
- createMetricsRegistry();
320
- ```
321
-
322
- Supported metric types:
323
-
324
- ```text
325
- counter
326
- gauge
327
- histogram
328
- ```
329
-
330
- Expose Prometheus-compatible text:
331
-
332
- ```ts
333
- import {
334
298
  createMetricsResponse,
335
299
  } from "bcp/observability";
336
-
337
- export function GET() {
338
- return createMetricsResponse(
339
- metrics
340
- );
341
- }
342
- ```
343
-
344
- Health/readiness registry:
345
-
346
- ```ts
347
- import {
348
- createHealthRegistry,
349
- } from "bcp/observability";
350
-
351
- export const health =
352
- createHealthRegistry();
353
300
  ```
354
301
 
355
302
  Read more: [Observability Platform v2](docs/observability.md)
@@ -405,16 +352,75 @@ const worker =
405
352
  concurrency: 4,
406
353
  pollIntervalMs: 250,
407
354
  });
355
+ ```
408
356
 
409
- // graceful shutdown
410
- await worker.stop();
357
+ The default memory adapter is process-local. Durable multi-process deployments should implement `JobQueueAdapter` against shared infrastructure.
358
+
359
+ Read more: [Background Jobs Platform](docs/background-jobs.md)
360
+
361
+ ## Job Scheduling Platform — 0.2.9
362
+
363
+ Create a scheduler on top of the same queue:
364
+
365
+ ```ts
366
+ import {
367
+ createJobScheduler,
368
+ } from "bcp/jobs";
369
+
370
+ export const scheduler =
371
+ createJobScheduler({
372
+ queue: jobs,
373
+ });
411
374
  ```
412
375
 
413
- The default in-memory adapter is process-local and is intended for development/tests/prototypes. Durable multi-process deployments should implement `JobQueueAdapter` against shared infrastructure. Adapter `reserve()` must atomically claim work.
376
+ Interval schedule:
377
+
378
+ ```ts
379
+ await scheduler.schedule(
380
+ "cache.cleanup",
381
+ {},
382
+ {
383
+ id: "cache-cleanup",
384
+ everyMs: 5 * 60 * 1000,
385
+ }
386
+ );
387
+ ```
414
388
 
415
- Retry behavior is configurable with fixed or callback-based backoff. The default is capped exponential backoff. Jobs can also be cancelled and inspected with `get()` / `list()`.
389
+ UTC cron schedule:
416
390
 
417
- Read more: [Background Jobs Platform](docs/background-jobs.md)
391
+ ```ts
392
+ await scheduler.schedule(
393
+ "report.weekday",
394
+ {},
395
+ {
396
+ cron: "30 9 * * 1-5",
397
+ }
398
+ );
399
+ ```
400
+
401
+ Supported cron shape:
402
+
403
+ ```text
404
+ minute hour day-of-month month day-of-week
405
+ ```
406
+
407
+ The scheduler runner polls due schedules and enqueues normal BCP jobs:
408
+
409
+ ```ts
410
+ const scheduleRunner =
411
+ scheduler.start({
412
+ pollIntervalMs: 1_000,
413
+ leaseMs: 30_000,
414
+ });
415
+
416
+ // graceful shutdown
417
+ await scheduleRunner.stop();
418
+ await scheduler.close();
419
+ ```
420
+
421
+ The built-in `createMemoryJobScheduleStore()` is process-local. Multi-instance production deployments should implement a shared `JobScheduleStore` whose `acquireDue()` operation atomically claims schedules with lease ownership/expiry. Scheduled occurrences also use deterministic queue ids for duplicate protection.
422
+
423
+ Read more: [Job Scheduling Platform](docs/job-scheduling.md)
418
424
 
419
425
  ## Public entrypoints
420
426
 
@@ -495,7 +501,7 @@ React SSR
495
501
  Hydration / SPA navigation
496
502
 
497
503
  Operational side channels:
498
- background jobs + structured logs + metrics + health/readiness
504
+ background jobs + scheduler + structured logs + metrics + health/readiness
499
505
  ```
500
506
 
501
507
  ## Production build
@@ -541,7 +547,7 @@ npm run test:e2e
541
547
  npm run rc:check
542
548
  ```
543
549
 
544
- `0.2.8` adds Background Jobs Platform unit and prepared-package smoke checks covering delayed work, retries/backoff, cancellation, worker concurrency, server-only boundaries and the public `bcp/jobs` package surface.
550
+ `0.2.9` adds Job Scheduling Platform unit and prepared-package smoke checks covering interval schedules, UTC cron parsing, standard day matching, schedule-store leases, deterministic scheduled run ids, retry propagation and lifecycle validation.
545
551
 
546
552
  Do not tag or publish until the final release commit passes the complete RC sequence.
547
553
 
@@ -564,12 +570,13 @@ Do not tag or publish until the final release commit passes the complete RC sequ
564
570
  | `0.2.6` | Authorization & Security v2 |
565
571
  | `0.2.7` | Observability Platform v2 |
566
572
  | `0.2.8` | Background Jobs Platform |
573
+ | `0.2.9` | Job Scheduling Platform |
567
574
 
568
575
  ## Roadmap
569
576
 
570
- `0.2.8Background Jobs Platform` establishes a provider-neutral queue/worker contract on top of the existing server runtime and lifecycle model.
577
+ `0.2.9Job Scheduling Platform` establishes recurring scheduling and the durable schedule-store contract on top of the provider-neutral queue introduced in `0.2.8`.
571
578
 
572
- Later `0.2.x` work can add durable queue providers, recurring schedules, distributed leases or workflow orchestration without changing the base enqueue/worker contract. Native `.exe`, desktop and mobile compilation remain later roadmap work.
579
+ Future work can add first-party durable queue/schedule adapters, dead-letter queues or workflow orchestration without changing the base queue and scheduler contracts. Native `.exe`, desktop and mobile compilation remain later roadmap work.
573
580
 
574
581
  ## License
575
582
 
package/docs/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The `docs/` directory is the documentation source of truth for BCP Framework and is organized for **`bcp-docs-web`**.
4
4
 
5
- > **Documentation target:** BCP Framework `0.2.8Background Jobs Platform`
5
+ > **Documentation target:** BCP Framework `0.2.9Job Scheduling Platform`
6
6
  >
7
7
  > **Release state:** unreleased development target until RC validation, tagging and npm publication complete.
8
8
 
@@ -21,24 +21,6 @@ docs/api-manifest.json
21
21
  -> public package entrypoints, source ownership and guide mapping
22
22
  ```
23
23
 
24
- Markdown files under `docs/` remain the authored documentation content.
25
-
26
- Recommended flow:
27
-
28
- ```text
29
- framework source/tests
30
-
31
- docs/
32
- ├─ Markdown content
33
- ├─ docs-web-manifest.json
34
- ├─ platform-manifest.json
35
- └─ api-manifest.json
36
-
37
- manifest-driven sync
38
-
39
- bcp-docs-web
40
- ```
41
-
42
24
  Framework source and tests remain authoritative for runtime behavior.
43
25
 
44
26
  ## Current 0.2.x milestones
@@ -54,49 +36,52 @@ Framework source and tests remain authoritative for runtime behavior.
54
36
  | `0.2.6` | Authorization & Security v2 |
55
37
  | `0.2.7` | Observability Platform v2 |
56
38
  | `0.2.8` | Background Jobs Platform |
39
+ | `0.2.9` | Job Scheduling Platform |
57
40
 
58
- ## 0.2.8Background Jobs Platform
41
+ ## 0.2.9Job Scheduling Platform
59
42
 
60
- `0.2.8` adds a server-only provider-neutral queue/worker layer without adding a third-party queue dependency.
43
+ `0.2.9` extends `bcp/jobs` with recurring interval jobs, dependency-free UTC cron schedules, scheduler runners, deterministic scheduled occurrence IDs and a lease-aware `JobScheduleStore` contract.
61
44
 
62
45
  New/updated documentation sources:
63
46
 
64
47
  | Source | Purpose |
65
48
  | --- | --- |
66
- | `background-jobs.md` | Queue contract, memory adapter, delay, retries, workers and production guidance |
67
- | `api-reference.md` | Public `bcp/jobs` exports |
68
- | `platform-manifest.json` | Background Jobs capability flags and public entrypoint |
49
+ | `background-jobs.md` | Base queue/worker contract from `0.2.8` |
50
+ | `job-scheduling.md` | Interval/cron schedules, leases and durable schedule-store guidance |
51
+ | `api-reference.md` | Public queue + scheduler APIs under `bcp/jobs` |
52
+ | `platform-manifest.json` | Job Scheduling capability flags |
69
53
  | `api-manifest.json` | `bcp/jobs` guide ownership |
70
- | `docs-web-manifest.json` | Background Jobs navigation and `0.2.8` release route |
71
- | `releases/0.2.8.md` | Background Jobs Platform release notes |
54
+ | `docs-web-manifest.json` | Scheduling navigation and `0.2.9` release route |
55
+ | `releases/0.2.9.md` | Job Scheduling Platform release notes |
72
56
 
73
- Primary APIs:
57
+ Primary scheduling APIs:
74
58
 
75
59
  ```ts
76
60
  import {
77
- createJobQueue,
78
- createMemoryJobQueueAdapter,
61
+ createJobScheduler,
62
+ createMemoryJobScheduleStore,
63
+ nextCronTime,
64
+ nextScheduleTime,
79
65
  } from "bcp/jobs";
80
66
  ```
81
67
 
82
68
  Runtime model:
83
69
 
84
70
  ```text
85
- web/API/action
71
+ recurring schedule
86
72
  |
87
- | enqueue
88
73
  v
89
- JobQueueAdapter
74
+ JobScheduleStore.acquireDue()
90
75
  |
76
+ | lease + deterministic run id
91
77
  v
92
- worker loop(s)
78
+ JobQueueAdapter.enqueue()
93
79
  |
94
- +-> success
95
- +-> retry/backoff
96
- +-> failed/cancelled
80
+ v
81
+ queue worker(s)
97
82
  ```
98
83
 
99
- The built-in memory adapter is process-local and not durable. Multi-process/container production deployments should implement `JobQueueAdapter` against shared durable infrastructure.
84
+ The built-in schedule store and queue are process-local. Multi-process/container production deployments should implement shared durable `JobScheduleStore` and `JobQueueAdapter` contracts.
100
85
 
101
86
  ## Update rule
102
87
 
@@ -115,21 +100,6 @@ When framework behavior or public surface changes:
115
100
 
116
101
  `docs/docs-web-manifest.json` is the authoritative ordered navigation contract.
117
102
 
118
- Current sections:
119
-
120
- ```text
121
- Getting Started
122
- Routing & Data
123
- Authentication & Authorization
124
- Database
125
- Runtime & Infrastructure
126
- Storage & Uploads
127
- Developer Experience
128
- Platform & Compatibility
129
- API Reference
130
- Releases
131
- ```
132
-
133
103
  Important current routes:
134
104
 
135
105
  | Website route | Markdown source |
@@ -138,40 +108,17 @@ Important current routes:
138
108
  | `/docs/authorization-security` | `authorization-security.md` |
139
109
  | `/docs/observability` | `observability.md` |
140
110
  | `/docs/background-jobs` | `background-jobs.md` |
141
- | `/docs/development-logging` | `development-logging.md` |
111
+ | `/docs/job-scheduling` | `job-scheduling.md` |
142
112
  | `/docs/application-packaging` | `application-packaging.md` |
143
113
  | `/docs/database` | `database.md` |
144
114
  | `/docs/api-reference` | `api-reference.md` |
145
- | `/releases/0.2.8` | `releases/0.2.8.md` |
115
+ | `/releases/0.2.9` | `releases/0.2.9.md` |
146
116
 
147
117
  Every route/source pair is validated by unit tests.
148
118
 
149
- ## Platform manifest
150
-
151
- `docs/platform-manifest.json` describes:
152
-
153
- ```text
154
- framework version/release state
155
- Node/React/runtime baseline
156
- production build/package target
157
- public package entrypoints
158
- CLI command families
159
- capability flags
160
- previous-baseline compatibility intent
161
- documentation contract files
162
- ```
119
+ ## Public entrypoints
163
120
 
164
- The supported production target remains:
165
-
166
- ```text
167
- standalone-node
168
- ```
169
-
170
- ## API manifest
171
-
172
- `docs/api-manifest.json` describes public package entrypoints documentation tooling may present as supported APIs.
173
-
174
- Current entrypoints:
121
+ Current documented entrypoints:
175
122
 
176
123
  ```text
177
124
  bcp
@@ -191,39 +138,9 @@ bcp/middleware
191
138
 
192
139
  The API-manifest entrypoint set must match the platform public-entrypoint set exactly.
193
140
 
194
- ## bcp-docs-web synchronization
195
-
196
- The docs website sync loads the manifests before Markdown content:
197
-
198
- ```text
199
- selected framework ref
200
-
201
- docs-web-manifest.json
202
- platform-manifest.json
203
- api-manifest.json
204
-
205
- validate version/release/API parity
206
-
207
- load referenced Markdown
208
-
209
- synchronize CMS/search/navigation
210
- ```
211
-
212
- ## Source conventions
213
-
214
- - one H1 per Markdown page,
215
- - stable heading hierarchy,
216
- - fenced code blocks with language tags,
217
- - relative links between docs,
218
- - exact public API names,
219
- - clear stable/RC/roadmap labels,
220
- - security limitations next to affected APIs,
221
- - no framework-internal module presented as public API,
222
- - no secrets/runtime `.env` values in public documentation metadata.
223
-
224
141
  ## Release validation
225
142
 
226
- Before publishing `0.2.8`:
143
+ Before publishing `0.2.9`:
227
144
 
228
145
  ```bash
229
146
  npm run typecheck
@@ -234,15 +151,16 @@ npm run test:e2e
234
151
  npm run rc:check
235
152
  ```
236
153
 
237
- Background Jobs Platform validation covers:
154
+ Job Scheduling Platform validation covers:
238
155
 
239
- - immediate and delayed jobs,
240
- - retry/backoff behavior,
241
- - terminal success/failure/cancellation states,
242
- - duplicate job IDs,
243
- - worker concurrency and graceful stop,
244
- - public `bcp/jobs` exports,
245
- - server-only browser/client boundaries,
156
+ - interval scheduling,
157
+ - five-field UTC cron parsing,
158
+ - standard day-of-month/day-of-week behavior,
159
+ - schedule-store leasing,
160
+ - deterministic scheduled run IDs,
161
+ - retry-limit propagation into queue jobs,
162
+ - schedule inspection/removal,
163
+ - scheduler configuration validation,
246
164
  - prepared npm package contents,
247
165
  - docs/platform/API version parity.
248
166
 
@@ -250,17 +168,4 @@ The final release tag must point to the exact commit that passed the complete RC
250
168
 
251
169
  ## Repository authority
252
170
 
253
- The framework repository remains authoritative for:
254
-
255
- ```text
256
- source
257
- public exports
258
- tests
259
- Markdown docs
260
- docs-web manifest
261
- platform manifest
262
- API manifest
263
- release notes
264
- ```
265
-
266
- `bcp-docs-web` remains the presentation/search/navigation layer for this content.
171
+ The framework repository remains authoritative for source, public exports, tests, Markdown docs, manifests and release notes. `bcp-docs-web` remains the presentation/search/navigation layer.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "framework": "bcp",
4
- "version": "0.2.8",
4
+ "version": "0.2.9",
5
5
  "releaseState": "unreleased",
6
6
  "coverage": "public-entrypoints",
7
7
  "entrypoints": [
@@ -99,9 +99,10 @@
99
99
  "source": "packages/client/src/jobs.ts",
100
100
  "environment": "server",
101
101
  "route": "/docs/api-reference#bcp-jobs",
102
- "summary": "Background job queue contract with in-memory adapter, delayed jobs, retry/backoff, cancellation and concurrent workers.",
102
+ "summary": "Background job queues plus recurring interval/cron scheduling, schedule-store leases and worker lifecycle APIs.",
103
103
  "guides": [
104
104
  "/docs/background-jobs",
105
+ "/docs/job-scheduling",
105
106
  "/docs/observability"
106
107
  ]
107
108
  },