@superbee/core 0.1.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 (145) hide show
  1. package/dist/backend.d.ts +77 -0
  2. package/dist/backend.d.ts.map +1 -0
  3. package/dist/backend.js +380 -0
  4. package/dist/backend.js.map +1 -0
  5. package/dist/bundle.d.ts +38 -0
  6. package/dist/bundle.d.ts.map +1 -0
  7. package/dist/bundle.js +107 -0
  8. package/dist/bundle.js.map +1 -0
  9. package/dist/content-type.d.ts +72 -0
  10. package/dist/content-type.d.ts.map +1 -0
  11. package/dist/content-type.js +149 -0
  12. package/dist/content-type.js.map +1 -0
  13. package/dist/document-mutation.d.ts +83 -0
  14. package/dist/document-mutation.d.ts.map +1 -0
  15. package/dist/document-mutation.js +319 -0
  16. package/dist/document-mutation.js.map +1 -0
  17. package/dist/document-precondition.d.ts +62 -0
  18. package/dist/document-precondition.d.ts.map +1 -0
  19. package/dist/document-precondition.js +134 -0
  20. package/dist/document-precondition.js.map +1 -0
  21. package/dist/document-write-policy.d.ts +42 -0
  22. package/dist/document-write-policy.d.ts.map +1 -0
  23. package/dist/document-write-policy.js +134 -0
  24. package/dist/document-write-policy.js.map +1 -0
  25. package/dist/engine.d.ts +48 -0
  26. package/dist/engine.d.ts.map +1 -0
  27. package/dist/engine.js +209 -0
  28. package/dist/engine.js.map +1 -0
  29. package/dist/errors.d.ts +36 -0
  30. package/dist/errors.d.ts.map +1 -0
  31. package/dist/errors.js +50 -0
  32. package/dist/errors.js.map +1 -0
  33. package/dist/filesystem-identity.d.ts +208 -0
  34. package/dist/filesystem-identity.d.ts.map +1 -0
  35. package/dist/filesystem-identity.js +675 -0
  36. package/dist/filesystem-identity.js.map +1 -0
  37. package/dist/filesystem-lock.d.ts +65 -0
  38. package/dist/filesystem-lock.d.ts.map +1 -0
  39. package/dist/filesystem-lock.js +460 -0
  40. package/dist/filesystem-lock.js.map +1 -0
  41. package/dist/freshness.d.ts +31 -0
  42. package/dist/freshness.d.ts.map +1 -0
  43. package/dist/freshness.js +98 -0
  44. package/dist/freshness.js.map +1 -0
  45. package/dist/frontmatter-contract.d.ts +17 -0
  46. package/dist/frontmatter-contract.d.ts.map +1 -0
  47. package/dist/frontmatter-contract.js +29 -0
  48. package/dist/frontmatter-contract.js.map +1 -0
  49. package/dist/frontmatter.d.ts +30 -0
  50. package/dist/frontmatter.d.ts.map +1 -0
  51. package/dist/frontmatter.js +115 -0
  52. package/dist/frontmatter.js.map +1 -0
  53. package/dist/index-marker.d.ts +3 -0
  54. package/dist/index-marker.d.ts.map +1 -0
  55. package/dist/index-marker.js +3 -0
  56. package/dist/index-marker.js.map +1 -0
  57. package/dist/index-projection.d.ts +79 -0
  58. package/dist/index-projection.d.ts.map +1 -0
  59. package/dist/index-projection.js +245 -0
  60. package/dist/index-projection.js.map +1 -0
  61. package/dist/index.d.ts +68 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +110 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/kinds-load.d.ts +13 -0
  66. package/dist/kinds-load.d.ts.map +1 -0
  67. package/dist/kinds-load.js +34 -0
  68. package/dist/kinds-load.js.map +1 -0
  69. package/dist/kinds.d.ts +241 -0
  70. package/dist/kinds.d.ts.map +1 -0
  71. package/dist/kinds.js +1001 -0
  72. package/dist/kinds.js.map +1 -0
  73. package/dist/links.d.ts +62 -0
  74. package/dist/links.d.ts.map +1 -0
  75. package/dist/links.js +203 -0
  76. package/dist/links.js.map +1 -0
  77. package/dist/meaningful-change-time.d.ts +11 -0
  78. package/dist/meaningful-change-time.d.ts.map +1 -0
  79. package/dist/meaningful-change-time.js +16 -0
  80. package/dist/meaningful-change-time.js.map +1 -0
  81. package/dist/memory-backend.d.ts +55 -0
  82. package/dist/memory-backend.d.ts.map +1 -0
  83. package/dist/memory-backend.js +214 -0
  84. package/dist/memory-backend.js.map +1 -0
  85. package/dist/mutation-attribution.d.ts +19 -0
  86. package/dist/mutation-attribution.d.ts.map +1 -0
  87. package/dist/mutation-attribution.js +34 -0
  88. package/dist/mutation-attribution.js.map +1 -0
  89. package/dist/mutation.d.ts +89 -0
  90. package/dist/mutation.d.ts.map +1 -0
  91. package/dist/mutation.js +94 -0
  92. package/dist/mutation.js.map +1 -0
  93. package/dist/page.d.ts +87 -0
  94. package/dist/page.d.ts.map +1 -0
  95. package/dist/page.js +151 -0
  96. package/dist/page.js.map +1 -0
  97. package/dist/paths.d.ts +78 -0
  98. package/dist/paths.d.ts.map +1 -0
  99. package/dist/paths.js +148 -0
  100. package/dist/paths.js.map +1 -0
  101. package/dist/portable-frontmatter.d.ts +8 -0
  102. package/dist/portable-frontmatter.d.ts.map +1 -0
  103. package/dist/portable-frontmatter.js +35 -0
  104. package/dist/portable-frontmatter.js.map +1 -0
  105. package/dist/publication-filesystem.d.ts +6 -0
  106. package/dist/publication-filesystem.d.ts.map +1 -0
  107. package/dist/publication-filesystem.js +6 -0
  108. package/dist/publication-filesystem.js.map +1 -0
  109. package/dist/query-filter.d.ts +12 -0
  110. package/dist/query-filter.d.ts.map +1 -0
  111. package/dist/query-filter.js +29 -0
  112. package/dist/query-filter.js.map +1 -0
  113. package/dist/query-selection.d.ts +25 -0
  114. package/dist/query-selection.d.ts.map +1 -0
  115. package/dist/query-selection.js +48 -0
  116. package/dist/query-selection.js.map +1 -0
  117. package/dist/remote-backend.d.ts +152 -0
  118. package/dist/remote-backend.d.ts.map +1 -0
  119. package/dist/remote-backend.js +505 -0
  120. package/dist/remote-backend.js.map +1 -0
  121. package/dist/remote.d.ts +4 -0
  122. package/dist/remote.d.ts.map +1 -0
  123. package/dist/remote.js +3 -0
  124. package/dist/remote.js.map +1 -0
  125. package/dist/storage.d.ts +7 -0
  126. package/dist/storage.d.ts.map +1 -0
  127. package/dist/storage.js +6 -0
  128. package/dist/storage.js.map +1 -0
  129. package/dist/types.d.ts +438 -0
  130. package/dist/types.d.ts.map +1 -0
  131. package/dist/types.js +12 -0
  132. package/dist/types.js.map +1 -0
  133. package/dist/validation.d.ts +22 -0
  134. package/dist/validation.d.ts.map +1 -0
  135. package/dist/validation.js +12 -0
  136. package/dist/validation.js.map +1 -0
  137. package/dist/version-transport.d.ts +13 -0
  138. package/dist/version-transport.d.ts.map +1 -0
  139. package/dist/version-transport.js +26 -0
  140. package/dist/version-transport.js.map +1 -0
  141. package/dist/versioning.d.ts +48 -0
  142. package/dist/versioning.d.ts.map +1 -0
  143. package/dist/versioning.js +62 -0
  144. package/dist/versioning.js.map +1 -0
  145. package/package.json +84 -0
@@ -0,0 +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,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iFAAiF;AACjF,MAAM,OAAO,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"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Versioning + attribution primitives shared by every {@link StorageBackend}.
3
+ *
4
+ * These make the seam's "hardest case" (content-addressed versions, compare-and-swap
5
+ * writes, actor attribution) implementable uniformly across adapters:
6
+ * - {@link contentVersion} defines the opaque {@link Version} token as a SHA-256 over
7
+ * the canonically serialized document, so identical content yields the same token
8
+ * REGARDLESS of backend. The filesystem adapter hashes the on-disk bytes; the
9
+ * in-memory adapter hashes the same serialization — an engine-written document
10
+ * therefore carries the same version token in either store.
11
+ * - {@link blobVersion} is the SAME idea for opaque blob bytes, but hashes the raw
12
+ * `Uint8Array` directly with no string/UTF-8 step — a doc-shaped hash would corrupt
13
+ * binary content, so blobs get their own primitive rather than reusing `contentVersion`
14
+ * or `versionOfBytes`.
15
+ * - {@link defaultActor} supplies a local identity when a write is unattributed.
16
+ * - {@link VersionConflict} is the typed error a compare-and-swap write throws when
17
+ * the caller's `expectedVersion` no longer matches the backend's current version.
18
+ *
19
+ * Nothing here touches the filesystem — hashing and attribution are backend-neutral,
20
+ * which is precisely why the memory adapter can reuse them.
21
+ */
22
+ import type { OkfDocument, Version } from "./types.js";
23
+ export { VersionConflict, stripETagWrapper } from "./version-transport.js";
24
+ /** Lowercase hex SHA-256 of a UTF-8 string. The version tokens' underlying digest. */
25
+ export declare function sha256Hex(input: string): string;
26
+ /**
27
+ * The content-addressed {@link Version} of a concept document: the SHA-256 of its
28
+ * OKF-serialized bytes (`sha256:<hex>`). Deterministic and backend-independent — two
29
+ * backends holding byte-identical serializations report the same version.
30
+ */
31
+ export declare function contentVersion(doc: OkfDocument): Version;
32
+ /** The version of already-serialized document bytes (the filesystem adapter's on-disk form). */
33
+ export declare function versionOfBytes(raw: string): Version;
34
+ /**
35
+ * The content-addressed {@link Version} of raw blob bytes: the SHA-256 of `bytes`
36
+ * directly, with NO string/UTF-8 encoding step. This is deliberately a SEPARATE
37
+ * primitive from {@link contentVersion} (doc-shaped, serializes frontmatter+body first)
38
+ * and {@link versionOfBytes} (hashes a STRING as UTF-8) — routing binary blob content
39
+ * through either would corrupt any byte sequence that is not valid UTF-8 (e.g. a lone
40
+ * continuation byte decodes to U+FFFD before hashing), silently breaking the
41
+ * byte-identical round-trip a blob promises. Every {@link StorageBackend}'s blob
42
+ * methods must hash bytes through THIS function so the token is identical regardless
43
+ * of adapter, exactly as {@link contentVersion} is for documents.
44
+ */
45
+ export declare function blobVersion(bytes: Uint8Array): Version;
46
+ /** A local identity for unattributed writes: `$USER`/`$USERNAME`/`$LOGNAME`, else `"local"`. */
47
+ export declare function defaultActor(): string;
48
+ //# sourceMappingURL=versioning.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Versioning + attribution primitives shared by every {@link StorageBackend}.
3
+ *
4
+ * These make the seam's "hardest case" (content-addressed versions, compare-and-swap
5
+ * writes, actor attribution) implementable uniformly across adapters:
6
+ * - {@link contentVersion} defines the opaque {@link Version} token as a SHA-256 over
7
+ * the canonically serialized document, so identical content yields the same token
8
+ * REGARDLESS of backend. The filesystem adapter hashes the on-disk bytes; the
9
+ * in-memory adapter hashes the same serialization — an engine-written document
10
+ * therefore carries the same version token in either store.
11
+ * - {@link blobVersion} is the SAME idea for opaque blob bytes, but hashes the raw
12
+ * `Uint8Array` directly with no string/UTF-8 step — a doc-shaped hash would corrupt
13
+ * binary content, so blobs get their own primitive rather than reusing `contentVersion`
14
+ * or `versionOfBytes`.
15
+ * - {@link defaultActor} supplies a local identity when a write is unattributed.
16
+ * - {@link VersionConflict} is the typed error a compare-and-swap write throws when
17
+ * the caller's `expectedVersion` no longer matches the backend's current version.
18
+ *
19
+ * Nothing here touches the filesystem — hashing and attribution are backend-neutral,
20
+ * which is precisely why the memory adapter can reuse them.
21
+ */
22
+ import { createHash } from "node:crypto";
23
+ import { stringifyDoc } from "./frontmatter.js";
24
+ export { VersionConflict, stripETagWrapper } from "./version-transport.js";
25
+ /** Lowercase hex SHA-256 of a UTF-8 string. The version tokens' underlying digest. */
26
+ export function sha256Hex(input) {
27
+ return createHash("sha256").update(input, "utf8").digest("hex");
28
+ }
29
+ /**
30
+ * The content-addressed {@link Version} of a concept document: the SHA-256 of its
31
+ * OKF-serialized bytes (`sha256:<hex>`). Deterministic and backend-independent — two
32
+ * backends holding byte-identical serializations report the same version.
33
+ */
34
+ export function contentVersion(doc) {
35
+ return `sha256:${sha256Hex(stringifyDoc(doc.frontmatter, doc.body ?? ""))}`;
36
+ }
37
+ /** The version of already-serialized document bytes (the filesystem adapter's on-disk form). */
38
+ export function versionOfBytes(raw) {
39
+ return `sha256:${sha256Hex(raw)}`;
40
+ }
41
+ /**
42
+ * The content-addressed {@link Version} of raw blob bytes: the SHA-256 of `bytes`
43
+ * directly, with NO string/UTF-8 encoding step. This is deliberately a SEPARATE
44
+ * primitive from {@link contentVersion} (doc-shaped, serializes frontmatter+body first)
45
+ * and {@link versionOfBytes} (hashes a STRING as UTF-8) — routing binary blob content
46
+ * through either would corrupt any byte sequence that is not valid UTF-8 (e.g. a lone
47
+ * continuation byte decodes to U+FFFD before hashing), silently breaking the
48
+ * byte-identical round-trip a blob promises. Every {@link StorageBackend}'s blob
49
+ * methods must hash bytes through THIS function so the token is identical regardless
50
+ * of adapter, exactly as {@link contentVersion} is for documents.
51
+ */
52
+ export function blobVersion(bytes) {
53
+ return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
54
+ }
55
+ /** A local identity for unattributed writes: `$USER`/`$USERNAME`/`$LOGNAME`, else `"local"`. */
56
+ export function defaultActor() {
57
+ return (process.env.USER?.trim() ||
58
+ process.env.USERNAME?.trim() ||
59
+ process.env.LOGNAME?.trim() ||
60
+ "local");
61
+ }
62
+ //# sourceMappingURL=versioning.js.map
@@ -0,0 +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;QAC3B,OAAO,CACR,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@superbee/core",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "OKF store engine — bundle I/O, cross-links, derived backlinks, freshness, and versioned writes.",
6
+ "license": "Apache-2.0",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./engine": {
16
+ "types": "./dist/engine.d.ts",
17
+ "default": "./dist/engine.js"
18
+ },
19
+ "./kinds": {
20
+ "types": "./dist/kinds.d.ts",
21
+ "default": "./dist/kinds.js"
22
+ },
23
+ "./links": {
24
+ "types": "./dist/links.d.ts",
25
+ "default": "./dist/links.js"
26
+ },
27
+ "./meaningful-change-time": {
28
+ "types": "./dist/meaningful-change-time.d.ts",
29
+ "default": "./dist/meaningful-change-time.js"
30
+ },
31
+ "./mutation-attribution": {
32
+ "types": "./dist/mutation-attribution.d.ts",
33
+ "default": "./dist/mutation-attribution.js"
34
+ },
35
+ "./page": {
36
+ "types": "./dist/page.d.ts",
37
+ "default": "./dist/page.js"
38
+ },
39
+ "./publication-filesystem": {
40
+ "types": "./dist/publication-filesystem.d.ts",
41
+ "default": "./dist/publication-filesystem.js"
42
+ },
43
+ "./query-filter": {
44
+ "types": "./dist/query-filter.d.ts",
45
+ "default": "./dist/query-filter.js"
46
+ },
47
+ "./query-selection": {
48
+ "types": "./dist/query-selection.d.ts",
49
+ "default": "./dist/query-selection.js"
50
+ },
51
+ "./remote": {
52
+ "types": "./dist/remote.d.ts",
53
+ "default": "./dist/remote.js"
54
+ },
55
+ "./storage": {
56
+ "types": "./dist/storage.d.ts",
57
+ "default": "./dist/storage.js"
58
+ }
59
+ },
60
+ "files": [
61
+ "dist"
62
+ ],
63
+ "publishConfig": {
64
+ "access": "restricted",
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "scripts": {
68
+ "build": "tsc",
69
+ "typecheck": "tsc --noEmit",
70
+ "test": "node --test --import ./test/ts-loader.mjs ./test/*.test.ts",
71
+ "mutation": "stryker run",
72
+ "prepublishOnly": "node -e \"console.error('@superbee/core is released by .github/workflows/release-libraries.yml; do not run npm publish here'); process.exit(1)\""
73
+ },
74
+ "dependencies": {
75
+ "gray-matter": "^4.0.3",
76
+ "js-yaml": "^3.15.2"
77
+ },
78
+ "devDependencies": {
79
+ "@superbee/server": "*",
80
+ "@types/js-yaml": "3.12.10",
81
+ "@types/node": "^22.0.0",
82
+ "typescript": "^5.4.0"
83
+ }
84
+ }