@superbee/core 0.1.5 → 0.2.0-pre.1

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 (125) hide show
  1. package/dist/backend.d.ts.map +1 -1
  2. package/dist/backend.js +29 -7
  3. package/dist/backend.js.map +1 -1
  4. package/dist/bundle-ops.d.ts +42 -0
  5. package/dist/bundle-ops.d.ts.map +1 -0
  6. package/dist/bundle-ops.js +88 -0
  7. package/dist/bundle-ops.js.map +1 -0
  8. package/dist/bundle.d.ts +8 -27
  9. package/dist/bundle.d.ts.map +1 -1
  10. package/dist/bundle.js +9 -66
  11. package/dist/bundle.js.map +1 -1
  12. package/dist/document-field-actions.d.ts +95 -0
  13. package/dist/document-field-actions.d.ts.map +1 -0
  14. package/dist/document-field-actions.js +261 -0
  15. package/dist/document-field-actions.js.map +1 -0
  16. package/dist/document-mutation.d.ts +51 -3
  17. package/dist/document-mutation.d.ts.map +1 -1
  18. package/dist/document-mutation.js +90 -43
  19. package/dist/document-mutation.js.map +1 -1
  20. package/dist/document-write-policy.d.ts +5 -3
  21. package/dist/document-write-policy.d.ts.map +1 -1
  22. package/dist/document-write-policy.js +38 -46
  23. package/dist/document-write-policy.js.map +1 -1
  24. package/dist/engine.d.ts +2 -0
  25. package/dist/engine.d.ts.map +1 -1
  26. package/dist/engine.js +2 -1
  27. package/dist/engine.js.map +1 -1
  28. package/dist/freshness.d.ts +10 -7
  29. package/dist/freshness.d.ts.map +1 -1
  30. package/dist/freshness.js +14 -11
  31. package/dist/freshness.js.map +1 -1
  32. package/dist/frontmatter-contract.d.ts +2 -2
  33. package/dist/frontmatter-contract.js +2 -2
  34. package/dist/frontmatter.d.ts +3 -1
  35. package/dist/frontmatter.d.ts.map +1 -1
  36. package/dist/frontmatter.js +7 -4
  37. package/dist/frontmatter.js.map +1 -1
  38. package/dist/index.d.ts +11 -3
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +13 -2
  41. package/dist/index.js.map +1 -1
  42. package/dist/indexeddb-backend.d.ts +165 -0
  43. package/dist/indexeddb-backend.d.ts.map +1 -0
  44. package/dist/indexeddb-backend.js +718 -0
  45. package/dist/indexeddb-backend.js.map +1 -0
  46. package/dist/journaled-backend.d.ts +178 -0
  47. package/dist/journaled-backend.d.ts.map +1 -0
  48. package/dist/journaled-backend.js +77 -0
  49. package/dist/journaled-backend.js.map +1 -0
  50. package/dist/kind-field-mutation.d.ts +15 -0
  51. package/dist/kind-field-mutation.d.ts.map +1 -0
  52. package/dist/kind-field-mutation.js +160 -0
  53. package/dist/kind-field-mutation.js.map +1 -0
  54. package/dist/kinds-load.d.ts.map +1 -1
  55. package/dist/kinds-load.js +11 -3
  56. package/dist/kinds-load.js.map +1 -1
  57. package/dist/kinds.d.ts +6 -2
  58. package/dist/kinds.d.ts.map +1 -1
  59. package/dist/kinds.js +15 -4
  60. package/dist/kinds.js.map +1 -1
  61. package/dist/meaningful-change-time.d.ts +6 -6
  62. package/dist/meaningful-change-time.d.ts.map +1 -1
  63. package/dist/meaningful-change-time.js +12 -13
  64. package/dist/meaningful-change-time.js.map +1 -1
  65. package/dist/mutation.d.ts.map +1 -1
  66. package/dist/mutation.js +2 -2
  67. package/dist/mutation.js.map +1 -1
  68. package/dist/okf-authored-values.d.ts +11 -0
  69. package/dist/okf-authored-values.d.ts.map +1 -0
  70. package/dist/okf-authored-values.js +37 -0
  71. package/dist/okf-authored-values.js.map +1 -0
  72. package/dist/okf-lifecycle.d.ts +4 -0
  73. package/dist/okf-lifecycle.d.ts.map +1 -0
  74. package/dist/okf-lifecycle.js +6 -0
  75. package/dist/okf-lifecycle.js.map +1 -0
  76. package/dist/okf-standard-fields.d.ts +10 -0
  77. package/dist/okf-standard-fields.d.ts.map +1 -0
  78. package/dist/okf-standard-fields.js +111 -0
  79. package/dist/okf-standard-fields.js.map +1 -0
  80. package/dist/okf-timestamps.d.ts +1 -2
  81. package/dist/okf-timestamps.d.ts.map +1 -1
  82. package/dist/okf-timestamps.js +2 -29
  83. package/dist/okf-timestamps.js.map +1 -1
  84. package/dist/page.d.ts.map +1 -1
  85. package/dist/page.js +2 -1
  86. package/dist/page.js.map +1 -1
  87. package/dist/platform.d.ts +161 -0
  88. package/dist/platform.d.ts.map +1 -0
  89. package/dist/platform.js +77 -0
  90. package/dist/platform.js.map +1 -0
  91. package/dist/recipes.d.ts +3 -1
  92. package/dist/recipes.d.ts.map +1 -1
  93. package/dist/recipes.js +4 -4
  94. package/dist/recipes.js.map +1 -1
  95. package/dist/remote-backend.d.ts +28 -0
  96. package/dist/remote-backend.d.ts.map +1 -1
  97. package/dist/remote-backend.js +75 -2
  98. package/dist/remote-backend.js.map +1 -1
  99. package/dist/remote-operations.d.ts +60 -0
  100. package/dist/remote-operations.d.ts.map +1 -0
  101. package/dist/remote-operations.js +110 -0
  102. package/dist/remote-operations.js.map +1 -0
  103. package/dist/sha256.d.ts +21 -0
  104. package/dist/sha256.d.ts.map +1 -0
  105. package/dist/sha256.js +114 -0
  106. package/dist/sha256.js.map +1 -0
  107. package/dist/storage.d.ts +5 -1
  108. package/dist/storage.d.ts.map +1 -1
  109. package/dist/storage.js +7 -1
  110. package/dist/storage.js.map +1 -1
  111. package/dist/types.d.ts +12 -0
  112. package/dist/types.d.ts.map +1 -1
  113. package/dist/uncertain-write.d.ts +142 -0
  114. package/dist/uncertain-write.d.ts.map +1 -0
  115. package/dist/uncertain-write.js +174 -0
  116. package/dist/uncertain-write.js.map +1 -0
  117. package/dist/version-transport.d.ts +7 -0
  118. package/dist/version-transport.d.ts.map +1 -1
  119. package/dist/version-transport.js +9 -0
  120. package/dist/version-transport.js.map +1 -1
  121. package/dist/versioning.d.ts +9 -3
  122. package/dist/versioning.d.ts.map +1 -1
  123. package/dist/versioning.js +14 -10
  124. package/dist/versioning.js.map +1 -1
  125. package/package.json +42 -3
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;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AW,UAAU;IACzB,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,iGAAiG;IACjG,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iGAAiG;AACjG,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,uFAAuF;IACvF,OAAO,EAAE,gBAAgB,CAAC;IAC1B,yGAAyG;IACzG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * The shared uncertain-write primitive: durable request identity, unknown-outcome handling, and
3
+ * acknowledgement reconciliation for a write whose delivery to a shared authority may be lost.
4
+ *
5
+ * A network write has three answers, not two: the authority applied it, refused it, or the
6
+ * client cannot tell (a dropped response, a timeout, a transport error). Retrying a write in the
7
+ * third case is only safe when the authority can recognize the retry as the same request, so
8
+ * every write carries a {@link OperationIntent.requestId} minted once when the intent is first
9
+ * recorded and never reminted, and every transport offers {@link OperationTransport.lookup} to
10
+ * fetch the authority's recorded outcome for that id.
11
+ *
12
+ * This module is owned by core so the browser-local sync component and bounded CLI remote
13
+ * operations consume one primitive rather than each defining unknown-outcome handling. It
14
+ * imports no Node builtin and bundles for the browser. The only injected time source is the
15
+ * `sleep` used for the submission deadline and the delay between lookups; there is no
16
+ * injectable clock, and a transport's own latency is real.
17
+ */
18
+ import type { Version } from "./types.js";
19
+ /** The operation an intent performs. Only document writes exist today; the union is open. */
20
+ export type OperationKind = "document.write" | (string & {});
21
+ /**
22
+ * The journal states of an intent. `unknown` is the primitive's own classification of an
23
+ * exhausted attempt: the authority may or may not hold the write, and a later attempt begins
24
+ * with a lookup rather than a submission.
25
+ */
26
+ export type OperationState = "pending" | "in_flight" | "acknowledged" | "conflict" | "refused" | "unknown";
27
+ /** A recorded local write awaiting a shared outcome. */
28
+ export interface OperationIntent {
29
+ /** Durable request identity: minted once at record time, reused verbatim on every retry. */
30
+ requestId: string;
31
+ kind: OperationKind;
32
+ /** The target the operation applies to; a concept id for `document.write`. */
33
+ target: string;
34
+ /** The shared version the local edit was made against, or `null` for a create. */
35
+ base: Version | null;
36
+ /** The content-addressed version of `content`. */
37
+ local: Version;
38
+ /** The serialized document: the comparison content reconciliation needs later. */
39
+ content: string;
40
+ createdAt: string;
41
+ /**
42
+ * Submissions made or durably claimed so far. A non-zero count means the authority may already
43
+ * hold the write, so delivery begins with a lookup rather than a submission; a journal records
44
+ * the count before a submission leaves, never only after its outcome is known.
45
+ */
46
+ attempts: number;
47
+ state: OperationState;
48
+ }
49
+ /** The authority's answer for one request identity. */
50
+ export type Outcome = {
51
+ kind: "committed";
52
+ version: Version;
53
+ } | {
54
+ kind: "conflict";
55
+ actual: Version | null;
56
+ } | {
57
+ kind: "refused";
58
+ code: string;
59
+ message: string;
60
+ } | {
61
+ kind: "unknown";
62
+ };
63
+ /** A transport to a shared authority that records outcomes by request identity. */
64
+ export interface OperationTransport {
65
+ /** Deliver the intent once; a repeated `requestId` must return the recorded outcome unchanged. */
66
+ submit(intent: OperationIntent, options?: {
67
+ signal?: AbortSignal;
68
+ }): Promise<Outcome>;
69
+ /** The recorded outcome for `requestId`, or `null` when the authority never recorded it. */
70
+ lookup(requestId: string): Promise<Outcome | null>;
71
+ }
72
+ /** Wait `ms`, resolving early and harmlessly when `signal` aborts. Injected by tests. */
73
+ export type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
74
+ export interface UncertainWriteOptions {
75
+ /** How long one submission may take before its outcome is treated as unknown. */
76
+ deadlineMs?: number;
77
+ /** Lookups attempted after an unknown submission before giving up (default 3). */
78
+ maxLookups?: number;
79
+ /** Delay between lookups (default 250 ms; the injected `sleep` decides what that means). */
80
+ lookupDelayMs?: number;
81
+ /** Submissions permitted in one call, counting the first (default 2). */
82
+ maxSubmissions?: number;
83
+ /** Timer; defaults to a `setTimeout` sleep. */
84
+ sleep?: Sleep;
85
+ }
86
+ export interface UncertainWriteResult {
87
+ /** The intent with `attempts` and `state` advanced to reflect this call. */
88
+ intent: OperationIntent;
89
+ outcome: Outcome;
90
+ /** How many times `lookup` was called in this call. */
91
+ lookups: number;
92
+ }
93
+ /** Refusal codes that mean the caller's authorization is gone rather than the content wrong. */
94
+ export declare const AUTHORIZATION_REFUSAL_CODES: ReadonlySet<string>;
95
+ /** True when a refusal reports lost permission, which pauses further shared operations. */
96
+ export declare function isAuthorizationRefusal(outcome: Outcome): boolean;
97
+ /** The journal state an outcome settles an intent into. */
98
+ export declare function stateForOutcome(outcome: Outcome): OperationState;
99
+ /** The longest request identity the wire accepts as `Idempotency-Key`. */
100
+ export declare const REQUEST_ID_MAX_LENGTH = 128;
101
+ /**
102
+ * True when `value` is a request identity the wire accepts: 1 to {@link REQUEST_ID_MAX_LENGTH}
103
+ * printable ASCII characters with no space, and neither `.` nor `..`, which URL normalization
104
+ * folds away so the lookup route could never name them. One rule, checked by the client before
105
+ * a header is built and by the reference router before a key is claimed, so the two sides cannot
106
+ * disagree about which keys identify a write. A minted UUID always satisfies it.
107
+ */
108
+ export declare function isRequestIdentity(value: string): boolean;
109
+ /** A fresh request identity. UUIDs come from the platform's `crypto` in both Node and browsers. */
110
+ export declare function mintRequestId(): string;
111
+ /**
112
+ * The outcome as it applies to `intent`. A conflict whose `actual` is the intent's own `local`
113
+ * version means the shared head already holds exactly this content, so the write is committed
114
+ * at that version. This is the wire's post-expiry compare-and-swap property: a committed write
115
+ * whose acknowledgement was lost and whose recorded outcome expired from the authority's
116
+ * retention window is resubmitted with its original `base`, which no longer matches, and the
117
+ * authority answers a conflict against the version the client itself committed. The mapping
118
+ * depends only on the outcome and the intent, so the primitive owns it and every consumer
119
+ * settles such a write as acknowledged rather than presenting it as a concurrent edit. Every
120
+ * other conflict, including one against an absent head (`actual: null`), is returned unchanged.
121
+ */
122
+ export declare function settleAgainstIntent(outcome: Outcome, intent: OperationIntent): Outcome;
123
+ /**
124
+ * Deliver `intent` and settle it against the authority's recorded outcome.
125
+ *
126
+ * Flow: when the intent has never been submitted, submit it; when it has (`attempts > 0`), or
127
+ * when a submission's outcome is unknown, look the request identity up. A positive lookup
128
+ * settles the intent. A `null` lookup proves the authority never recorded the request, so a
129
+ * resubmission with the same `requestId` is the first delivery and is allowed, up to
130
+ * `maxSubmissions`. A lookup that fails leaves the outcome unknown and the intent for a later
131
+ * call.
132
+ *
133
+ * No resubmission happens without a `null` lookup because a blind retry after an unknown
134
+ * outcome is unsound: on an authority without request identity the retry applies the write
135
+ * twice, and even on one with it the retry can only ever learn what the lookup already knew.
136
+ * The lookup is what turns "unknown" into a fact before any second delivery.
137
+ *
138
+ * Every outcome passes through {@link settleAgainstIntent} before it is returned, so a conflict
139
+ * that names the intent's own version is reported as committed at that version.
140
+ */
141
+ export declare function performUncertainWrite(transport: OperationTransport, intent: OperationIntent, options?: UncertainWriteOptions): Promise<UncertainWriteResult>;
142
+ //# sourceMappingURL=uncertain-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uncertain-write.d.ts","sourceRoot":"","sources":["../src/uncertain-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,6FAA6F;AAC7F,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,CAAC,M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,CAAC,oBAAoB,CAAC,CAyC/B"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * The shared uncertain-write primitive: durable request identity, unknown-outcome handling, and
3
+ * acknowledgement reconciliation for a write whose delivery to a shared authority may be lost.
4
+ *
5
+ * A network write has three answers, not two: the authority applied it, refused it, or the
6
+ * client cannot tell (a dropped response, a timeout, a transport error). Retrying a write in the
7
+ * third case is only safe when the authority can recognize the retry as the same request, so
8
+ * every write carries a {@link OperationIntent.requestId} minted once when the intent is first
9
+ * recorded and never reminted, and every transport offers {@link OperationTransport.lookup} to
10
+ * fetch the authority's recorded outcome for that id.
11
+ *
12
+ * This module is owned by core so the browser-local sync component and bounded CLI remote
13
+ * operations consume one primitive rather than each defining unknown-outcome handling. It
14
+ * imports no Node builtin and bundles for the browser. The only injected time source is the
15
+ * `sleep` used for the submission deadline and the delay between lookups; there is no
16
+ * injectable clock, and a transport's own latency is real.
17
+ */
18
+ /** Refusal codes that mean the caller's authorization is gone rather than the content wrong. */
19
+ export const AUTHORIZATION_REFUSAL_CODES = new Set(["AUTH_REQUIRED", "FORBIDDEN", "UNAUTHORIZED", "PERMISSION_DENIED"]);
20
+ /** True when a refusal reports lost permission, which pauses further shared operations. */
21
+ export function isAuthorizationRefusal(outcome) {
22
+ return outcome.kind === "refused" && AUTHORIZATION_REFUSAL_CODES.has(outcome.code);
23
+ }
24
+ /** The journal state an outcome settles an intent into. */
25
+ export function stateForOutcome(outcome) {
26
+ switch (outcome.kind) {
27
+ case "committed":
28
+ return "acknowledged";
29
+ case "conflict":
30
+ return "conflict";
31
+ case "refused":
32
+ return "refused";
33
+ case "unknown":
34
+ return "unknown";
35
+ }
36
+ }
37
+ /** The longest request identity the wire accepts as `Idempotency-Key`. */
38
+ export const REQUEST_ID_MAX_LENGTH = 128;
39
+ /**
40
+ * True when `value` is a request identity the wire accepts: 1 to {@link REQUEST_ID_MAX_LENGTH}
41
+ * printable ASCII characters with no space, and neither `.` nor `..`, which URL normalization
42
+ * folds away so the lookup route could never name them. One rule, checked by the client before
43
+ * a header is built and by the reference router before a key is claimed, so the two sides cannot
44
+ * disagree about which keys identify a write. A minted UUID always satisfies it.
45
+ */
46
+ export function isRequestIdentity(value) {
47
+ if (value === "." || value === "..")
48
+ return false;
49
+ return value.length >= 1 && value.length <= REQUEST_ID_MAX_LENGTH && /^[!-~]+$/.test(value);
50
+ }
51
+ /** A fresh request identity. UUIDs come from the platform's `crypto` in both Node and browsers. */
52
+ export function mintRequestId() {
53
+ const cryptoApi = globalThis.crypto;
54
+ if (cryptoApi && typeof cryptoApi.randomUUID === "function")
55
+ return cryptoApi.randomUUID();
56
+ throw new Error("mintRequestId requires crypto.randomUUID in this host.");
57
+ }
58
+ const defaultSleep = (ms, signal) => new Promise((resolve) => {
59
+ if (signal?.aborted) {
60
+ resolve();
61
+ return;
62
+ }
63
+ const timer = setTimeout(() => {
64
+ signal?.removeEventListener("abort", onAbort);
65
+ resolve();
66
+ }, ms);
67
+ function onAbort() {
68
+ clearTimeout(timer);
69
+ resolve();
70
+ }
71
+ signal?.addEventListener("abort", onAbort, { once: true });
72
+ });
73
+ const UNKNOWN = { kind: "unknown" };
74
+ /**
75
+ * The outcome as it applies to `intent`. A conflict whose `actual` is the intent's own `local`
76
+ * version means the shared head already holds exactly this content, so the write is committed
77
+ * at that version. This is the wire's post-expiry compare-and-swap property: a committed write
78
+ * whose acknowledgement was lost and whose recorded outcome expired from the authority's
79
+ * retention window is resubmitted with its original `base`, which no longer matches, and the
80
+ * authority answers a conflict against the version the client itself committed. The mapping
81
+ * depends only on the outcome and the intent, so the primitive owns it and every consumer
82
+ * settles such a write as acknowledged rather than presenting it as a concurrent edit. Every
83
+ * other conflict, including one against an absent head (`actual: null`), is returned unchanged.
84
+ */
85
+ export function settleAgainstIntent(outcome, intent) {
86
+ if (outcome.kind === "conflict" && outcome.actual !== null && outcome.actual === intent.local) {
87
+ return { kind: "committed", version: outcome.actual };
88
+ }
89
+ return outcome;
90
+ }
91
+ /**
92
+ * One submission under a deadline. A transport rejection or a deadline overrun both yield
93
+ * `unknown`: the request may have reached the authority, so nothing here decides otherwise.
94
+ */
95
+ async function submitOnce(transport, intent, deadlineMs, sleep) {
96
+ const controller = new AbortController();
97
+ const attempt = transport.submit(intent, { signal: controller.signal }).then((outcome) => ({ settled: true, outcome }), () => ({ settled: true, outcome: UNKNOWN }));
98
+ if (deadlineMs === undefined)
99
+ return (await attempt).outcome;
100
+ const timerControl = new AbortController();
101
+ const deadline = sleep(deadlineMs, timerControl.signal).then(() => ({ settled: false }));
102
+ const first = await Promise.race([attempt, deadline]);
103
+ if (first.settled) {
104
+ timerControl.abort();
105
+ return first.outcome;
106
+ }
107
+ controller.abort();
108
+ return UNKNOWN;
109
+ }
110
+ /**
111
+ * Deliver `intent` and settle it against the authority's recorded outcome.
112
+ *
113
+ * Flow: when the intent has never been submitted, submit it; when it has (`attempts > 0`), or
114
+ * when a submission's outcome is unknown, look the request identity up. A positive lookup
115
+ * settles the intent. A `null` lookup proves the authority never recorded the request, so a
116
+ * resubmission with the same `requestId` is the first delivery and is allowed, up to
117
+ * `maxSubmissions`. A lookup that fails leaves the outcome unknown and the intent for a later
118
+ * call.
119
+ *
120
+ * No resubmission happens without a `null` lookup because a blind retry after an unknown
121
+ * outcome is unsound: on an authority without request identity the retry applies the write
122
+ * twice, and even on one with it the retry can only ever learn what the lookup already knew.
123
+ * The lookup is what turns "unknown" into a fact before any second delivery.
124
+ *
125
+ * Every outcome passes through {@link settleAgainstIntent} before it is returned, so a conflict
126
+ * that names the intent's own version is reported as committed at that version.
127
+ */
128
+ export async function performUncertainWrite(transport, intent, options = {}) {
129
+ const sleep = options.sleep ?? defaultSleep;
130
+ const maxLookups = Math.max(1, options.maxLookups ?? 3);
131
+ const maxSubmissions = Math.max(1, options.maxSubmissions ?? 2);
132
+ const lookupDelayMs = options.lookupDelayMs ?? 250;
133
+ let attempts = intent.attempts;
134
+ let submissions = 0;
135
+ let lookups = 0;
136
+ const finish = (raw) => {
137
+ const outcome = settleAgainstIntent(raw, intent);
138
+ return { intent: { ...intent, attempts, state: stateForOutcome(outcome) }, outcome, lookups };
139
+ };
140
+ // A previously submitted intent starts at the lookup, never at a submission.
141
+ let needSubmission = attempts === 0;
142
+ for (;;) {
143
+ if (needSubmission) {
144
+ if (submissions >= maxSubmissions)
145
+ return finish(UNKNOWN);
146
+ submissions += 1;
147
+ attempts += 1;
148
+ const outcome = await submitOnce(transport, { ...intent, attempts, state: "in_flight" }, options.deadlineMs, sleep);
149
+ if (outcome.kind !== "unknown")
150
+ return finish(outcome);
151
+ }
152
+ needSubmission = false;
153
+ let recorded;
154
+ for (let round = 0; round < maxLookups; round++) {
155
+ if (round > 0)
156
+ await sleep(lookupDelayMs);
157
+ lookups += 1;
158
+ try {
159
+ recorded = await transport.lookup(intent.requestId);
160
+ }
161
+ catch {
162
+ recorded = undefined;
163
+ continue;
164
+ }
165
+ break;
166
+ }
167
+ if (recorded === undefined)
168
+ return finish(UNKNOWN);
169
+ if (recorded !== null)
170
+ return finish(recorded);
171
+ needSubmission = true;
172
+ }
173
+ }
174
+ //# sourceMappingURL=uncertain-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uncertain-write.js","sourceRoot":"","sources":["../src/uncertain-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA4EH,gGAAgG;AAChG,MAAM,CAAC,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAE7I,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,2BAA2B,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACrF,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC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AAc,GAAG,QAAQ,KAAK,CAAC,CAAC;IACpC,SAAS,CAAC;QACR,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,WAAW,IAAI,cAAc;gBAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;YAC1D,WAAW,IAAI,CAAC,CAAC;YACjB,QAAQ,IAAI,CAAC,CAAC;YACd,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACpH,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;QACzD,CAAC;QACD,cAAc,GAAG,KAAK,CAAC;QACvB,IAAI,QAAoC,CAAC;QACzC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YAChD,IAAI,KAAK,GAAG,CAAC;gBAAE,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,CAAC;YACb,IAAI,CAAC;gBACH,QAAQ,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACtD,CAAC;YAAC,MAAM,CAAC;gBACP,QAAQ,GAAG,SAAS,CAAC;gBACrB,SAAS;YACX,CAAC;YACD,MAAM;QACR,CAAC;QACD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -1,5 +1,12 @@
1
1
  /** Runtime-neutral version transport primitives shared by storage adapters and HTTP clients. */
2
2
  import type { Version } from "./types.js";
3
+ /**
4
+ * True only for a content-addressed {@link Version} token as every conforming backend mints it:
5
+ * `sha256:` followed by 64 lowercase hex characters. One rule, shared by the reference router
6
+ * (an identified delete's premise) and the View registry (an entry pin), so no adapter carries
7
+ * its own reading of what a version looks like.
8
+ */
9
+ export declare function isContentVersion(value: unknown): value is Version;
3
10
  /** Recover a bare version token from a quoted or weak HTTP ETag. */
4
11
  export declare function stripETagWrapper(raw: string): string;
5
12
  /** Typed optimistic-concurrency rejection raised by every conforming backend. */
@@ -1 +1 @@
1
- {"version":3,"file":"version-transport.d.ts","sourceRoot":"","sources":["../src/version-transport.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED,iFAAiF;AACjF,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,IAAI,qBAAqB;IAC3C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;gBAEpB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;CASzE"}
1
+ {"version":3,"file":"version-transport.d.ts","sourceRoot":"","sources":["../src/version-transport.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAEjE;AAED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED,iFAAiF;AACjF,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,IAAI,qBAAqB;IAC3C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;gBAEpB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;CASzE"}
@@ -1,4 +1,13 @@
1
1
  /** Runtime-neutral version transport primitives shared by storage adapters and HTTP clients. */
2
+ /**
3
+ * True only for a content-addressed {@link Version} token as every conforming backend mints it:
4
+ * `sha256:` followed by 64 lowercase hex characters. One rule, shared by the reference router
5
+ * (an identified delete's premise) and the View registry (an entry pin), so no adapter carries
6
+ * its own reading of what a version looks like.
7
+ */
8
+ export function isContentVersion(value) {
9
+ return typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value);
10
+ }
2
11
  /** Recover a bare version token from a quoted or weak HTTP ETag. */
3
12
  export function stripETagWrapper(raw) {
4
13
  let value = raw.trim();
@@ -1 +1 @@
1
- {"version":3,"file":"version-transport.js","sourceRoot":"","sources":["../src/version-transport.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAIhG,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACvB,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACtE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7B,CAA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O,eAAgB,SAAQ,KAAK;IACtB,IAAI,GAAG,iBAAiB,CAAC;IAClC,EAAE,CAAS;IACX,QAAQ,CAAiB;IACzB,MAAM,CAAiB;IAEhC,YAAY,EAAU,EAAE,QAAwB,EAAE,MAAsB;QACtE,KAAK,CACH,wBAAwB,EAAE,eAAe,QAAQ,IAAI,QAAQ,WAAW,MAAM,IAAI,MAAM,GAAG;YACzF,8DAA8D,CACjE,CAAC;QACF,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
@@ -17,10 +17,12 @@
17
17
  * the caller's `expectedVersion` no longer matches the backend's current version.
18
18
  *
19
19
  * Nothing here touches the filesystem — hashing and attribution are backend-neutral,
20
- * which is precisely why the memory adapter can reuse them.
20
+ * which is precisely why the memory adapter can reuse them. The digest itself lives in
21
+ * `sha256.ts`, a pure implementation with no `node:*` import, so this module and the memory
22
+ * adapter bundle for the browser and mint the same tokens there.
21
23
  */
22
24
  import type { OkfDocument, Version } from "./types.js";
23
- export { VersionConflict, stripETagWrapper } from "./version-transport.js";
25
+ export { VersionConflict, isContentVersion, stripETagWrapper } from "./version-transport.js";
24
26
  /** Lowercase hex SHA-256 of a UTF-8 string. The version tokens' underlying digest. */
25
27
  export declare function sha256Hex(input: string): string;
26
28
  /**
@@ -43,6 +45,10 @@ export declare function versionOfBytes(raw: string): Version;
43
45
  * of adapter, exactly as {@link contentVersion} is for documents.
44
46
  */
45
47
  export declare function blobVersion(bytes: Uint8Array): Version;
46
- /** A local identity for unattributed writes: `$USER`/`$USERNAME`/`$LOGNAME`, else `"local"`. */
48
+ /**
49
+ * A local identity for unattributed writes: `$USER`/`$USERNAME`/`$LOGNAME`, else `"local"`.
50
+ * A browser host has no `process` global, so the environment lookup is guarded and such a
51
+ * host attributes to `"local"`.
52
+ */
47
53
  export declare function defaultActor(): string;
48
54
  //# sourceMappingURL=versioning.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,sFAAsF;AACtF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAExD;AAED,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEtD;AAED,gGAAgG;AAChG,wBAAgB,YAAY,IAAI,MAAM,CAOrC"}
1
+ {"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE7F,sFAAsF;AACtF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAExD;AAED,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAGrC"}
@@ -17,14 +17,16 @@
17
17
  * the caller's `expectedVersion` no longer matches the backend's current version.
18
18
  *
19
19
  * Nothing here touches the filesystem — hashing and attribution are backend-neutral,
20
- * which is precisely why the memory adapter can reuse them.
20
+ * which is precisely why the memory adapter can reuse them. The digest itself lives in
21
+ * `sha256.ts`, a pure implementation with no `node:*` import, so this module and the memory
22
+ * adapter bundle for the browser and mint the same tokens there.
21
23
  */
22
- import { createHash } from "node:crypto";
23
24
  import { stringifyDoc } from "./frontmatter.js";
24
- export { VersionConflict, stripETagWrapper } from "./version-transport.js";
25
+ import { sha256HexOfBytes, sha256HexOfUtf8 } from "./sha256.js";
26
+ export { VersionConflict, isContentVersion, stripETagWrapper } from "./version-transport.js";
25
27
  /** Lowercase hex SHA-256 of a UTF-8 string. The version tokens' underlying digest. */
26
28
  export function sha256Hex(input) {
27
- return createHash("sha256").update(input, "utf8").digest("hex");
29
+ return sha256HexOfUtf8(input);
28
30
  }
29
31
  /**
30
32
  * The content-addressed {@link Version} of a concept document: the SHA-256 of its
@@ -50,13 +52,15 @@ export function versionOfBytes(raw) {
50
52
  * of adapter, exactly as {@link contentVersion} is for documents.
51
53
  */
52
54
  export function blobVersion(bytes) {
53
- return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
55
+ return `sha256:${sha256HexOfBytes(bytes)}`;
54
56
  }
55
- /** A local identity for unattributed writes: `$USER`/`$USERNAME`/`$LOGNAME`, else `"local"`. */
57
+ /**
58
+ * A local identity for unattributed writes: `$USER`/`$USERNAME`/`$LOGNAME`, else `"local"`.
59
+ * A browser host has no `process` global, so the environment lookup is guarded and such a
60
+ * host attributes to `"local"`.
61
+ */
56
62
  export function defaultActor() {
57
- return (process.env.USER?.trim() ||
58
- process.env.USERNAME?.trim() ||
59
- process.env.LOGNAME?.trim() ||
60
- "local");
63
+ const env = typeof process !== "undefined" ? process.env : undefined;
64
+ return env?.USER?.trim() || env?.USERNAME?.trim() || env?.LOGNAME?.trim() || "local";
61
65
  }
62
66
  //# sourceMappingURL=versioning.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"versioning.js","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,sFAAsF;AACtF,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAgB;IAC7C,OAAO,UAAU,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,UAAU,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;AACpC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,YAAY;IAC1B,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE;QAC3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  "name": "@superbee/core",
3
- "version": "0.1.5",
3
+ "version": "0.2.0-pre.1",
4
4
  "type": "module",
5
5
  "description": "OKF store engine — bundle I/O, cross-links, derived backlinks, freshness, and versioned writes.",
6
6
  "license": "Apache-2.0",
@@ -11,7 +11,9 @@
11
11
  },
12
12
  "main": "./dist/index.js",
13
13
  "types": "./dist/index.d.ts",
14
- "sideEffects": false,
14
+ "sideEffects": [
15
+ "./dist/bundle.js"
16
+ ],
15
17
  "exports": {
16
18
  "./view-admission": {
17
19
  "types": "./dist/view-admission.d.ts",
@@ -21,10 +23,18 @@
21
23
  "types": "./dist/index.d.ts",
22
24
  "default": "./dist/index.js"
23
25
  },
26
+ "./bundle-ops": {
27
+ "types": "./dist/bundle-ops.d.ts",
28
+ "default": "./dist/bundle-ops.js"
29
+ },
24
30
  "./document-codec": {
25
31
  "types": "./dist/document-codec.d.ts",
26
32
  "default": "./dist/document-codec.js"
27
33
  },
34
+ "./document-mutation": {
35
+ "types": "./dist/document-mutation.d.ts",
36
+ "default": "./dist/document-mutation.js"
37
+ },
28
38
  "./engine": {
29
39
  "types": "./dist/engine.d.ts",
30
40
  "default": "./dist/engine.js"
@@ -73,16 +83,44 @@
73
83
  "types": "./dist/remote.d.ts",
74
84
  "default": "./dist/remote.js"
75
85
  },
86
+ "./remote-operations": {
87
+ "types": "./dist/remote-operations.d.ts",
88
+ "default": "./dist/remote-operations.js"
89
+ },
76
90
  "./storage": {
77
91
  "types": "./dist/storage.d.ts",
78
92
  "default": "./dist/storage.js"
93
+ },
94
+ "./versioning": {
95
+ "types": "./dist/versioning.d.ts",
96
+ "default": "./dist/versioning.js"
97
+ },
98
+ "./memory-backend": {
99
+ "types": "./dist/memory-backend.d.ts",
100
+ "default": "./dist/memory-backend.js"
101
+ },
102
+ "./indexeddb-backend": {
103
+ "types": "./dist/indexeddb-backend.d.ts",
104
+ "default": "./dist/indexeddb-backend.js"
105
+ },
106
+ "./journaled-backend": {
107
+ "types": "./dist/journaled-backend.d.ts",
108
+ "default": "./dist/journaled-backend.js"
109
+ },
110
+ "./uncertain-write": {
111
+ "types": "./dist/uncertain-write.d.ts",
112
+ "default": "./dist/uncertain-write.js"
113
+ },
114
+ "./platform": {
115
+ "types": "./dist/platform.d.ts",
116
+ "default": "./dist/platform.js"
79
117
  }
80
118
  },
81
119
  "files": [
82
120
  "dist"
83
121
  ],
84
122
  "publishConfig": {
85
- "access": "restricted",
123
+ "access": "public",
86
124
  "registry": "https://registry.npmjs.org/"
87
125
  },
88
126
  "scripts": {
@@ -100,6 +138,7 @@
100
138
  "@superbee/server": "*",
101
139
  "@types/js-yaml": "3.12.10",
102
140
  "@types/node": "^22.0.0",
141
+ "fake-indexeddb": "6.2.5",
103
142
  "typescript": "^5.4.0"
104
143
  }
105
144
  }