fatedb 0.0.0-stage → 0.10.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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +264 -2
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +3 -0
  5. package/dist/cli.d.ts +15 -0
  6. package/dist/cli.js +256 -0
  7. package/dist/client.d.ts +152 -0
  8. package/dist/client.js +416 -0
  9. package/dist/cloudflare.d.ts +197 -0
  10. package/dist/cloudflare.js +159 -0
  11. package/dist/datalog/ast.d.ts +35 -0
  12. package/dist/datalog/ast.js +40 -0
  13. package/dist/datalog/evaluator.d.ts +14 -0
  14. package/dist/datalog/evaluator.js +395 -0
  15. package/dist/datalog/fact-source.d.ts +30 -0
  16. package/dist/datalog/fact-source.js +1 -0
  17. package/dist/datalog/fingerprint.d.ts +12 -0
  18. package/dist/datalog/fingerprint.js +50 -0
  19. package/dist/datalog/parser.d.ts +3 -0
  20. package/dist/datalog/parser.js +302 -0
  21. package/dist/datalog/value.d.ts +34 -0
  22. package/dist/datalog/value.js +104 -0
  23. package/dist/domain/date-validation.d.ts +2 -0
  24. package/dist/domain/date-validation.js +32 -0
  25. package/dist/domain/fact-value.d.ts +91 -0
  26. package/dist/domain/fact-value.js +167 -0
  27. package/dist/domain/fact.d.ts +14 -0
  28. package/dist/domain/fact.js +47 -0
  29. package/dist/domain/failure.d.ts +44 -0
  30. package/dist/domain/failure.js +30 -0
  31. package/dist/domain/graph-id.d.ts +7 -0
  32. package/dist/domain/graph-id.js +10 -0
  33. package/dist/domain/histogram.d.ts +29 -0
  34. package/dist/domain/histogram.js +48 -0
  35. package/dist/domain/identifiers.d.ts +26 -0
  36. package/dist/domain/identifiers.js +75 -0
  37. package/dist/domain/numbers.d.ts +12 -0
  38. package/dist/domain/numbers.js +77 -0
  39. package/dist/domain/projection.d.ts +252 -0
  40. package/dist/domain/projection.js +51 -0
  41. package/dist/domain/query-metrics.d.ts +31 -0
  42. package/dist/domain/query-metrics.js +35 -0
  43. package/dist/domain/read-token.d.ts +37 -0
  44. package/dist/domain/read-token.js +93 -0
  45. package/dist/domain/result.d.ts +22 -0
  46. package/dist/domain/result.js +16 -0
  47. package/dist/domain/schema-observation.d.ts +20 -0
  48. package/dist/domain/schema-observation.js +61 -0
  49. package/dist/domain/string-order.d.ts +2 -0
  50. package/dist/domain/string-order.js +15 -0
  51. package/dist/domain/vocabulary.d.ts +101 -0
  52. package/dist/domain/vocabulary.js +276 -0
  53. package/dist/index.d.ts +15 -0
  54. package/dist/index.js +14 -0
  55. package/dist/projection-config.d.ts +3 -0
  56. package/dist/projection-config.js +212 -0
  57. package/dist/server/access.d.ts +32 -0
  58. package/dist/server/access.js +117 -0
  59. package/dist/server/admin.d.ts +233 -0
  60. package/dist/server/admin.js +483 -0
  61. package/dist/server/authorization.d.ts +35 -0
  62. package/dist/server/authorization.js +76 -0
  63. package/dist/server/console-assets.d.ts +6 -0
  64. package/dist/server/console-assets.js +2 -0
  65. package/dist/server/console.d.ts +8 -0
  66. package/dist/server/console.js +301 -0
  67. package/dist/server/index.d.ts +122 -0
  68. package/dist/server/index.js +487 -0
  69. package/dist/server/mcp.d.ts +31 -0
  70. package/dist/server/mcp.js +169 -0
  71. package/dist/server/telemetry-do.d.ts +31 -0
  72. package/dist/server/telemetry-do.js +342 -0
  73. package/dist/server/telemetry.d.ts +27 -0
  74. package/dist/server/telemetry.js +191 -0
  75. package/dist/storage/constants.d.ts +20 -0
  76. package/dist/storage/constants.js +21 -0
  77. package/dist/storage/environment.d.ts +438 -0
  78. package/dist/storage/environment.js +145 -0
  79. package/dist/storage/facts.d.ts +41 -0
  80. package/dist/storage/facts.js +73 -0
  81. package/dist/storage/http.d.ts +55 -0
  82. package/dist/storage/http.js +169 -0
  83. package/dist/storage/keys.d.ts +50 -0
  84. package/dist/storage/keys.js +84 -0
  85. package/dist/storage/layout.d.ts +67 -0
  86. package/dist/storage/layout.js +134 -0
  87. package/dist/storage/log.d.ts +41 -0
  88. package/dist/storage/log.js +137 -0
  89. package/dist/storage/manifest.d.ts +26 -0
  90. package/dist/storage/manifest.js +206 -0
  91. package/dist/storage/operations.d.ts +303 -0
  92. package/dist/storage/operations.js +719 -0
  93. package/dist/storage/partition.d.ts +125 -0
  94. package/dist/storage/partition.js +816 -0
  95. package/dist/storage/projection.d.ts +72 -0
  96. package/dist/storage/projection.js +1349 -0
  97. package/dist/storage/root.d.ts +120 -0
  98. package/dist/storage/root.js +596 -0
  99. package/dist/storage/segment.d.ts +145 -0
  100. package/dist/storage/segment.js +451 -0
  101. package/dist/storage/shard.d.ts +82 -0
  102. package/dist/storage/shard.js +710 -0
  103. package/dist/storage/source.d.ts +60 -0
  104. package/dist/storage/source.js +199 -0
  105. package/dist/telemetry/model.d.ts +123 -0
  106. package/dist/telemetry/model.js +292 -0
  107. package/dist/version.d.ts +4 -0
  108. package/dist/version.js +6 -0
  109. package/package.json +82 -4
@@ -0,0 +1,72 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ import { type ProjectionDeadLetter, type ProjectionDetail, type ProjectionState } from "../domain/projection.js";
3
+ import { type BackfillInput, type IdentityInput, type ProjectionRpc, type ReplayDeadLettersInput, type StorageEnv, type WakeInput } from "./environment.js";
4
+ export type { BackfillInput, IdentityInput, ReplayDeadLettersInput, WakeInput } from "./environment.js";
5
+ export declare class ProjectionDO extends DurableObject<StorageEnv> implements ProjectionRpc {
6
+ private readonly sql;
7
+ private meta;
8
+ private readonly cursors;
9
+ /**
10
+ * The currently executing alarm, if any (specs/projection-alarm.spock). While an alarm runs in
11
+ * workerd, `getAlarm()` still reports its old timestamp, so concurrent `wake()` / `start()` /
12
+ * `replayFromStart()` calls mark `woken = true` and let `alarm()` reschedule strictly in the future.
13
+ */
14
+ private runningAlarm;
15
+ /** Monotonic generation incremented when cursors are reset so an in-flight scan never overwrites them. */
16
+ private generation;
17
+ constructor(ctx: DurableObjectState, env: StorageEnv);
18
+ private load;
19
+ private configFor;
20
+ private writeMeta;
21
+ private storeMeta;
22
+ private recordEvent;
23
+ private ensureMeta;
24
+ private ensureAlarmSoon;
25
+ /** Called by GraphRootDO after publishing a manifest. Idempotent and safe under retries. */
26
+ wake(input: WakeInput): Promise<void>;
27
+ /** Starts or resumes the projection (including recovering from `error` state). */
28
+ start(input: IdentityInput): Promise<ProjectionState>;
29
+ /** Durably pauses live scanning, backfill, and retries without discarding cursors or pending work. */
30
+ stop(input: IdentityInput): Promise<ProjectionState>;
31
+ /**
32
+ * Starts a backfill:
33
+ * - `since: "current"` (default): scans currently active entities in the published R2 index once
34
+ * (anchoring live partition cursors first if live tailing has not started yet).
35
+ * - `since: 0`: rewinds partition cursors to 0 and replays the entire durable partition log.
36
+ * - `since: <epochMs>`: rewinds partition cursors so every write & retraction with `ts >= since`
37
+ * is reprocessed from the durable partition log.
38
+ */
39
+ backfill(input: BackfillInput): Promise<ProjectionState>;
40
+ private backfillFromLog;
41
+ /** Moves dead-lettered batches back into pending_batches with reset attempts. */
42
+ replayDeadLetters(input: ReplayDeadLettersInput): Promise<Readonly<{
43
+ replayed: number;
44
+ state: ProjectionState;
45
+ }>>;
46
+ /** Deletes dead-lettered batches permanently. */
47
+ discardDeadLetters(input: ReplayDeadLettersInput): Promise<Readonly<{
48
+ discarded: number;
49
+ state: ProjectionState;
50
+ }>>;
51
+ /** Resets partition cursors to 0 and replays the entire durable log from the start. */
52
+ replayFromStart(input: IdentityInput): Promise<ProjectionState>;
53
+ deadLetters(input: IdentityInput & Readonly<{
54
+ limit?: number;
55
+ }>): Promise<readonly ProjectionDeadLetter[]>;
56
+ status(input: IdentityInput): Promise<ProjectionState>;
57
+ /** Rich operational snapshot for the `/projections/:id` Console page. */
58
+ private requireMeta;
59
+ detail(input: IdentityInput & Readonly<{
60
+ limit?: number;
61
+ }>): Promise<ProjectionDetail>;
62
+ alarm(): Promise<void>;
63
+ /**
64
+ * Scans partitions from their durable `(lastSeq, lastChunkKey)` up to the latest published
65
+ * manifest watermark, selects matching entities, and atomically persists pending batches + cursors.
66
+ */
67
+ private scanLiveChanges;
68
+ /** Scans one bounded page of existing matching entities from the R2 index for backfill. */
69
+ private stepBackfill;
70
+ /** Delivers due pending batches to the configured Worker RPC sink or built-in R2 exporter. */
71
+ private deliverDueBatches;
72
+ }