@docs-sdk-dev/reader 0.0.0-stage → 0.4.0-next.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 (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/dist/annotation-projection.d.ts +35 -0
  4. package/dist/annotation-projection.js +78 -0
  5. package/dist/annotation-projection.js.map +1 -0
  6. package/dist/artifacts.d.ts +19 -0
  7. package/dist/artifacts.js +33 -0
  8. package/dist/artifacts.js.map +1 -0
  9. package/dist/ask.d.ts +41 -0
  10. package/dist/ask.js +89 -0
  11. package/dist/ask.js.map +1 -0
  12. package/dist/collection-view.d.ts +190 -0
  13. package/dist/collection-view.js +170 -0
  14. package/dist/collection-view.js.map +1 -0
  15. package/dist/composition.d.ts +199 -0
  16. package/dist/composition.js +473 -0
  17. package/dist/composition.js.map +1 -0
  18. package/dist/condition.d.ts +17 -0
  19. package/dist/condition.js +61 -0
  20. package/dist/condition.js.map +1 -0
  21. package/dist/content-schema.d.ts +182 -0
  22. package/dist/content-schema.js +288 -0
  23. package/dist/content-schema.js.map +1 -0
  24. package/dist/context-search.d.ts +168 -0
  25. package/dist/context-search.js +73 -0
  26. package/dist/context-search.js.map +1 -0
  27. package/dist/context-store.d.ts +93 -0
  28. package/dist/context-store.js +438 -0
  29. package/dist/context-store.js.map +1 -0
  30. package/dist/dimension-runtime.d.ts +203 -0
  31. package/dist/dimension-runtime.js +737 -0
  32. package/dist/dimension-runtime.js.map +1 -0
  33. package/dist/dimensions.d.ts +84 -0
  34. package/dist/dimensions.js +136 -0
  35. package/dist/dimensions.js.map +1 -0
  36. package/dist/directory-navigation.d.ts +60 -0
  37. package/dist/directory-navigation.js +41 -0
  38. package/dist/directory-navigation.js.map +1 -0
  39. package/dist/directory-sections.d.ts +9 -0
  40. package/dist/directory-sections.js +76 -0
  41. package/dist/directory-sections.js.map +1 -0
  42. package/dist/document-reader.d.ts +1017 -0
  43. package/dist/document-reader.js +396 -0
  44. package/dist/document-reader.js.map +1 -0
  45. package/dist/document-selection.d.ts +412 -0
  46. package/dist/document-selection.js +45 -0
  47. package/dist/document-selection.js.map +1 -0
  48. package/dist/evidence.d.ts +102 -0
  49. package/dist/evidence.js +104 -0
  50. package/dist/evidence.js.map +1 -0
  51. package/dist/index.d.ts +19 -0
  52. package/dist/index.js +23 -0
  53. package/dist/model.d.ts +89 -0
  54. package/dist/model.js +31 -0
  55. package/dist/model.js.map +1 -0
  56. package/dist/module.d.ts +657 -0
  57. package/dist/module.js +199 -0
  58. package/dist/module.js.map +1 -0
  59. package/dist/navigation-view.d.ts +33 -0
  60. package/dist/navigation-view.js +68 -0
  61. package/dist/navigation-view.js.map +1 -0
  62. package/dist/node.d.ts +2004 -0
  63. package/dist/node.js +210 -0
  64. package/dist/node.js.map +1 -0
  65. package/dist/open-docs.d.ts +1396 -0
  66. package/dist/open-docs.js +198 -0
  67. package/dist/open-docs.js.map +1 -0
  68. package/dist/outline.d.ts +97 -0
  69. package/dist/outline.js +171 -0
  70. package/dist/outline.js.map +1 -0
  71. package/dist/persistence.d.ts +82 -0
  72. package/dist/persistence.js +377 -0
  73. package/dist/persistence.js.map +1 -0
  74. package/dist/projection-catalog.d.ts +23 -0
  75. package/dist/projection-catalog.js +45 -0
  76. package/dist/projection-catalog.js.map +1 -0
  77. package/dist/publication.d.ts +59 -0
  78. package/dist/publication.js +11 -0
  79. package/dist/publication.js.map +1 -0
  80. package/dist/reader.d.ts +236 -0
  81. package/dist/reader.js +400 -0
  82. package/dist/reader.js.map +1 -0
  83. package/dist/references.d.ts +54 -0
  84. package/dist/references.js +70 -0
  85. package/dist/references.js.map +1 -0
  86. package/dist/retrieval.d.ts +82 -0
  87. package/dist/retrieval.js +135 -0
  88. package/dist/retrieval.js.map +1 -0
  89. package/dist/search-view.d.ts +11 -0
  90. package/dist/search-view.js +30 -0
  91. package/dist/search-view.js.map +1 -0
  92. package/dist/search.d.ts +95 -0
  93. package/dist/search.js +234 -0
  94. package/dist/search.js.map +1 -0
  95. package/dist/semantic.d.ts +177 -0
  96. package/dist/semantic.js +104 -0
  97. package/dist/semantic.js.map +1 -0
  98. package/dist/skills.d.ts +21 -0
  99. package/dist/skills.js +42 -0
  100. package/dist/skills.js.map +1 -0
  101. package/docs/index.md +10 -0
  102. package/docs/sdk/composition.md +72 -0
  103. package/docs/sdk/reader-storage.md +70 -0
  104. package/docs/sdk/reader.md +99 -0
  105. package/docs/zh-CN/sdk/composition.md +72 -0
  106. package/docs/zh-CN/sdk/reader-storage.md +70 -0
  107. package/docs/zh-CN/sdk/reader.md +99 -0
  108. package/package.json +69 -4
package/dist/module.js ADDED
@@ -0,0 +1,199 @@
1
+ import { factContext, openPinnedReader } from "./document-reader.js";
2
+ import { documentEntityId, isEntityId, sectionEntityId } from "./semantic.js";
3
+ import { createSemanticLoader } from "./reader.js";
4
+
5
+ // src/module.ts
6
+ const isSoftwarePackageName = (name) => /^(?:@[a-z0-9_~-][a-z0-9._~-]*\/)?[a-z0-9_~-][a-z0-9._~-]*$/i.test(name);
7
+ function decodeDocumentModule(value) {
8
+ const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
9
+ const string = (value) => typeof value === "string" && value.length > 0;
10
+ if (!object(value) || value.schemaVersion !== 1 || !object(value.software) || !string(value.software.name) || !string(value.software.version) || !object(value.exports) || !Object.keys(value.exports).length || Object.entries(value.exports).some(([name, target]) => !string(name) || !object(target) || ("entity" in target ? typeof target.entity !== "string" || !isEntityId(target.entity) || "scope" in target || "id" in target || "section" in target : !string(target.scope) || !string(target.id) || target.section !== void 0 && !string(target.section)))) throw new Error("Invalid version 1 document module or public export.");
11
+ if (value.adaptation !== void 0) {
12
+ const adaptation = value.adaptation;
13
+ if (!object(adaptation) || !string(adaptation.provider) || !object(adaptation.sources) || Object.keys(value.exports).some((name) => !Object.hasOwn(adaptation.sources, name)) || Object.entries(adaptation.sources).some(([name, source]) => !Object.hasOwn(value.exports, name) || !object(source) || !string(source.path) || !string(source.sha256) || !/^[0-9a-f]{64}$/.test(source.sha256) || !["markdown", "declaration"].includes(String(source.kind)))) throw new Error("Invalid third-party adaptation sources.");
14
+ }
15
+ if (value.imports !== void 0 && (!object(value.imports) || Object.entries(value.imports).some(([name, target]) => !string(name) || !object(target) || !string(target.package) || !isSoftwarePackageName(target.package) || !string(target.version) || !string(target.export)))) throw new Error("Invalid public document import. Each name needs a package, version range and export.");
16
+ return value;
17
+ }
18
+ /** Validate the public contract for every published edition. */
19
+ function validateDocumentExports(module, manifest) {
20
+ const editions = /* @__PURE__ */ new Map();
21
+ for (const document of manifest.documents) {
22
+ const key = JSON.stringify([document.identity.scope, document.identity.id]);
23
+ const group = editions.get(key) ?? {
24
+ contexts: [],
25
+ sections: /* @__PURE__ */ new Map()
26
+ };
27
+ group.contexts.push(document.identity.dimensions);
28
+ for (const section of document.sections) group.sections.set(section.id, (group.sections.get(section.id) ?? 0) + 1);
29
+ editions.set(key, group);
30
+ }
31
+ for (const [name, target] of Object.entries(module.exports)) {
32
+ if ("entity" in target) continue;
33
+ const group = editions.get(JSON.stringify([target.scope, target.id]));
34
+ if (!group || target.section !== void 0 && group.sections.get(target.section) !== group.contexts.length) throw new Error(`Missing document or section for public export ${name}.`);
35
+ }
36
+ return (scope, id) => editions.get(JSON.stringify([scope, id]))?.contexts ?? [];
37
+ }
38
+ /** Report removals and narrowing that can break an existing name. Internal identity moves are compatible. */
39
+ function compareDocumentExports(before, after) {
40
+ if (before.software.name !== after.software.name) throw new Error("Expected releases of the same software package.");
41
+ return Object.entries(before.exports).flatMap(([name, old]) => {
42
+ if (!Object.hasOwn(after.exports, name)) return [{
43
+ name,
44
+ reason: "removed"
45
+ }];
46
+ const updated = after.exports[name];
47
+ if ("entity" in old !== "entity" in updated) return [{
48
+ name,
49
+ reason: "export-kind-changed"
50
+ }];
51
+ if ("entity" in old || "entity" in updated) return "entity" in old && "entity" in updated && old.entity.split(":")[0] !== updated.entity.split(":")[0] ? [{
52
+ name,
53
+ reason: "entity-type-changed"
54
+ }] : [];
55
+ if (old.section === void 0 && updated.section !== void 0) return [{
56
+ name,
57
+ reason: "narrowed-to-section"
58
+ }];
59
+ return [];
60
+ });
61
+ }
62
+ /** Open data supplied by the host. Browser, embedded, sidecar and HTTP readers use the same export and edition rules. */
63
+ async function openDocumentModule(inventoryRevision, software, host) {
64
+ const pinned = await openPinnedReader(inventoryRevision, host);
65
+ const module = decodeDocumentModule(JSON.parse(await pinned.readText("module.json")));
66
+ if (module.software.name !== software.name || module.software.version !== software.version) return {
67
+ status: "version-conflict",
68
+ software,
69
+ documented: module.software
70
+ };
71
+ const documentContexts = validateDocumentExports(module, pinned.manifest);
72
+ const facts = pinned.manifest.semantic && createSemanticLoader(pinned.manifest.semantic, pinned.readText);
73
+ let evidence;
74
+ return {
75
+ status: "opened",
76
+ software,
77
+ inventoryRevision,
78
+ exports: module.exports,
79
+ imports: module.imports,
80
+ ...module.adaptation && { adaptation: module.adaptation },
81
+ async evidenceFor(name, dimensions = {}) {
82
+ if (!Object.hasOwn(module.exports, name)) return { status: "not-found" };
83
+ const target = module.exports[name];
84
+ const entity = "entity" in target ? target.entity : target.section === void 0 ? documentEntityId(target) : sectionEntityId(target, target.section);
85
+ const edition = "entity" in target ? void 0 : pinned.reader.resolveEdition({
86
+ ...target,
87
+ dimensions
88
+ });
89
+ if (edition && edition.status !== "exact") return edition;
90
+ const selection = edition?.resolution && { resolution: edition.resolution };
91
+ if (edition && !facts && !("entity" in target)) {
92
+ const page = edition.value;
93
+ const artifact = target.section === void 0 ? page : page.sections.find((section) => section.id === target.section);
94
+ return {
95
+ status: "published-content",
96
+ entity,
97
+ identity: page.identity,
98
+ mode: page.mode,
99
+ ...selection,
100
+ inventoryRevision,
101
+ contentSha256: pinned.artifact(artifact.markdown).sha256,
102
+ provenance: artifact.provenance
103
+ };
104
+ }
105
+ evidence ??= import("./evidence.js").then(({ createEvidenceReader }) => createEvidenceReader(pinned, facts));
106
+ return {
107
+ ...await (await evidence)(entity, edition?.value.identity.dimensions ?? dimensions),
108
+ ...selection
109
+ };
110
+ },
111
+ async exportContexts(name) {
112
+ const target = Object.hasOwn(module.exports, name) && module.exports[name];
113
+ if (!target) return [];
114
+ return ("entity" in target ? (await facts?.entity(target.entity))?.variants.map((v) => v.context) ?? [] : documentContexts(target.scope, target.id)).map((context) => ({ ...context }));
115
+ },
116
+ async consumersOf(name, dimensions = {}) {
117
+ const target = Object.hasOwn(module.exports, name) && module.exports[name];
118
+ if (!target || !("entity" in target) || !facts) return [];
119
+ const edges = await facts.relations(target.entity, {
120
+ context: factContext(pinned.reader, target.entity, dimensions),
121
+ direction: "in"
122
+ });
123
+ const consumers = [];
124
+ for (const edge of edges) {
125
+ if (![
126
+ "references",
127
+ "derivedFrom",
128
+ "demonstrates",
129
+ "requires"
130
+ ].includes(edge.type)) continue;
131
+ const source = await facts.resolve(edge.source, edge.context ?? dimensions);
132
+ if (source.status !== "exact") continue;
133
+ const data = source.value.data;
134
+ const expectedPin = edge.type === "references" && Array.isArray(data?.references) ? data.references.find((ref) => ref.object === target.entity)?.pin : void 0;
135
+ consumers.push({
136
+ entity: edge.source,
137
+ relation: edge.type,
138
+ provenance: source.value.provenance,
139
+ expectedPin
140
+ });
141
+ }
142
+ return consumers;
143
+ },
144
+ async readExport(name, dimensions = {}) {
145
+ if (!Object.hasOwn(module.exports, name)) return {
146
+ status: "not-found",
147
+ export: name
148
+ };
149
+ const target = module.exports[name];
150
+ const attribution = module.adaptation && {
151
+ provider: module.adaptation.provider,
152
+ source: module.adaptation.sources[name]
153
+ };
154
+ if ("entity" in target) {
155
+ if (!facts) throw new Error("Public fact requires a semantic index.");
156
+ const result = await facts.resolve(target.entity, factContext(pinned.reader, target.entity, dimensions));
157
+ if (result.status !== "exact") return result;
158
+ return {
159
+ status: "exact",
160
+ kind: "entity",
161
+ software,
162
+ inventoryRevision,
163
+ export: name,
164
+ entity: target.entity,
165
+ value: result.value,
166
+ ...attribution && { adaptation: attribution }
167
+ };
168
+ }
169
+ const result = pinned.reader.resolveEdition({
170
+ ...target,
171
+ dimensions
172
+ });
173
+ if (result.status !== "exact") return result;
174
+ const request = result.value.contextVariants || result.value.availability ? result.resolution?.effective ?? dimensions : void 0;
175
+ const value = await pinned.reader.read(result.value.identity, target.section, void 0, request);
176
+ const projection = pinned.reader.projection(result.value.identity, request);
177
+ if (!value || !projection) throw new Error(`Missing published export ${name}.`);
178
+ const path = target.section === void 0 ? projection.markdown : projection.sections.find((section) => section.id === target.section).markdown;
179
+ return {
180
+ status: "exact",
181
+ kind: "markdown",
182
+ software,
183
+ inventoryRevision,
184
+ export: name,
185
+ ...attribution && { adaptation: attribution },
186
+ entity: target.section === void 0 ? documentEntityId(target) : sectionEntityId(target, target.section),
187
+ ...result.resolution && { resolution: result.resolution },
188
+ route: result.value.route,
189
+ losses: (result.value.losses ?? []).filter((loss) => target.section === void 0 || loss.section === target.section),
190
+ contentSha256: pinned.artifact(path).sha256,
191
+ identity: result.value.identity,
192
+ value
193
+ };
194
+ }
195
+ };
196
+ }
197
+
198
+ export { compareDocumentExports, decodeDocumentModule, isSoftwarePackageName, openDocumentModule, validateDocumentExports };
199
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","names":[],"sources":["../src/module.ts"],"sourcesContent":["import { factContext } from \"./document-reader.js\"\nimport type { PageReference } from \"./references.js\"\nimport { documentEntityId, sectionEntityId, isEntityId, type Context } from \"./semantic.js\"\nimport { createSemanticLoader } from \"./reader.js\"\nimport { openPinnedReader, type PublicationHost, type Manifest } from \"./document-reader.js\"\n\n/** A stable public name maps to an identity across editions, optionally restricted to one section. */\nexport type DocumentExport = { scope: string; id: string; section?: string } | { entity: string }\nexport const isSoftwarePackageName = (name: string) =>\n /^(?:@[a-z0-9_~-][a-z0-9._~-]*\\/)?[a-z0-9_~-][a-z0-9._~-]*$/i.test(name)\nexport interface ModuleImport {\n package: string\n version: string\n export: string\n}\nexport interface DocumentModule {\n schemaVersion: 1\n software: { name: string; version: string }\n adaptation?: {\n provider: string\n sources: Record<string, { path: string; sha256: string; kind: \"markdown\" | \"declaration\" }>\n }\n exports: Record<string, DocumentExport>\n imports?: Record<string, ModuleImport>\n}\n\nexport function decodeDocumentModule(value: unknown): DocumentModule {\n const object = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\" && !Array.isArray(value)\n const string = (value: unknown): value is string => typeof value === \"string\" && value.length > 0\n if (\n !object(value) ||\n value.schemaVersion !== 1 ||\n !object(value.software) ||\n !string(value.software.name) ||\n !string(value.software.version) ||\n !object(value.exports) ||\n !Object.keys(value.exports).length ||\n Object.entries(value.exports).some(\n ([name, target]) =>\n !string(name) ||\n !object(target) ||\n (\"entity\" in target\n ? typeof target.entity !== \"string\" ||\n !isEntityId(target.entity) ||\n \"scope\" in target ||\n \"id\" in target ||\n \"section\" in target\n : !string(target.scope) ||\n !string(target.id) ||\n (target.section !== undefined && !string(target.section))),\n )\n )\n throw new Error(\"Invalid version 1 document module or public export.\")\n if (value.adaptation !== undefined) {\n const adaptation = value.adaptation\n if (\n !object(adaptation) ||\n !string(adaptation.provider) ||\n !object(adaptation.sources) ||\n Object.keys(value.exports).some(\n (name) => !Object.hasOwn(adaptation.sources as object, name),\n ) ||\n Object.entries(adaptation.sources).some(\n ([name, source]) =>\n !Object.hasOwn(value.exports as object, name) ||\n !object(source) ||\n !string(source.path) ||\n !string(source.sha256) ||\n !/^[0-9a-f]{64}$/.test(source.sha256) ||\n ![\"markdown\", \"declaration\"].includes(String(source.kind)),\n )\n )\n throw new Error(\"Invalid third-party adaptation sources.\")\n }\n if (\n value.imports !== undefined &&\n (!object(value.imports) ||\n Object.entries(value.imports).some(\n ([name, target]) =>\n !string(name) ||\n !object(target) ||\n !string(target.package) ||\n !isSoftwarePackageName(target.package) ||\n !string(target.version) ||\n !string(target.export),\n ))\n )\n throw new Error(\n \"Invalid public document import. Each name needs a package, version range and export.\",\n )\n return value as unknown as DocumentModule\n}\n\n/** Validate the public contract for every published edition. */\nexport function validateDocumentExports(module: DocumentModule, manifest: Manifest) {\n const editions = new Map<string, { contexts: Context[]; sections: Map<string, number> }>()\n for (const document of manifest.documents) {\n const key = JSON.stringify([document.identity.scope, document.identity.id])\n const group = editions.get(key) ?? { contexts: [], sections: new Map<string, number>() }\n group.contexts.push(document.identity.dimensions)\n for (const section of document.sections)\n group.sections.set(section.id, (group.sections.get(section.id) ?? 0) + 1)\n editions.set(key, group)\n }\n for (const [name, target] of Object.entries(module.exports)) {\n if (\"entity\" in target) continue\n const group = editions.get(JSON.stringify([target.scope, target.id]))\n if (\n !group ||\n (target.section !== undefined && group.sections.get(target.section) !== group.contexts.length)\n )\n throw new Error(`Missing document or section for public export ${name}.`)\n }\n return (scope: string, id: string) => editions.get(JSON.stringify([scope, id]))?.contexts ?? []\n}\n\n/** Report removals and narrowing that can break an existing name. Internal identity moves are compatible. */\nexport function compareDocumentExports(\n before: DocumentModule,\n after: DocumentModule,\n): {\n name: string\n reason: \"removed\" | \"export-kind-changed\" | \"entity-type-changed\" | \"narrowed-to-section\"\n}[] {\n if (before.software.name !== after.software.name)\n throw new Error(\"Expected releases of the same software package.\")\n type Change = ReturnType<typeof compareDocumentExports>[number]\n return Object.entries(before.exports).flatMap<Change>(([name, old]) => {\n if (!Object.hasOwn(after.exports, name)) return [{ name, reason: \"removed\" }]\n const updated = after.exports[name]!\n if (\"entity\" in old !== \"entity\" in updated) return [{ name, reason: \"export-kind-changed\" }]\n if (\"entity\" in old || \"entity\" in updated) {\n return \"entity\" in old &&\n \"entity\" in updated &&\n old.entity.split(\":\")[0] !== updated.entity.split(\":\")[0]\n ? [{ name, reason: \"entity-type-changed\" }]\n : []\n }\n if (old.section === undefined && updated.section !== undefined)\n return [{ name, reason: \"narrowed-to-section\" }]\n return []\n })\n}\n\n/** Open data supplied by the host. Browser, embedded, sidecar and HTTP readers use the same export and edition rules. */\nexport async function openDocumentModule(\n inventoryRevision: string,\n software: DocumentModule[\"software\"],\n host: PublicationHost,\n) {\n const pinned = await openPinnedReader(inventoryRevision, host)\n const module = decodeDocumentModule(JSON.parse(await pinned.readText(\"module.json\")))\n if (module.software.name !== software.name || module.software.version !== software.version)\n return { status: \"version-conflict\" as const, software, documented: module.software }\n const documentContexts = validateDocumentExports(module, pinned.manifest)\n const facts =\n pinned.manifest.semantic && createSemanticLoader(pinned.manifest.semantic, pinned.readText)\n let evidence: Promise<ReturnType<typeof import(\"./evidence.js\").createEvidenceReader>> | undefined\n return {\n status: \"opened\" as const,\n software,\n inventoryRevision,\n exports: module.exports,\n imports: module.imports,\n ...(module.adaptation && { adaptation: module.adaptation }),\n async evidenceFor(name: string, dimensions: Record<string, string> = {}) {\n if (!Object.hasOwn(module.exports, name)) return { status: \"not-found\" as const }\n const target = module.exports[name]!\n const entity =\n \"entity\" in target\n ? target.entity\n : target.section === undefined\n ? documentEntityId(target)\n : sectionEntityId(target, target.section)\n const edition =\n \"entity\" in target ? undefined : pinned.reader.resolveEdition({ ...target, dimensions })\n if (edition && edition.status !== \"exact\") return edition\n const selection = edition?.resolution && { resolution: edition.resolution }\n if (edition && !facts && !(\"entity\" in target)) {\n const page = edition.value\n const artifact =\n target.section === undefined\n ? page\n : page.sections.find((section) => section.id === target.section)!\n return {\n status: \"published-content\" as const,\n entity,\n identity: page.identity,\n mode: page.mode,\n ...selection,\n inventoryRevision,\n contentSha256: pinned.artifact(artifact.markdown).sha256,\n provenance: artifact.provenance,\n }\n }\n evidence ??= import(\"./evidence.js\").then(({ createEvidenceReader }) =>\n createEvidenceReader(pinned, facts),\n )\n return {\n ...(await (\n await evidence\n )(entity, edition?.value.identity.dimensions ?? dimensions)),\n ...selection,\n }\n },\n async exportContexts(name: string): Promise<Context[]> {\n const target = Object.hasOwn(module.exports, name) && module.exports[name]\n if (!target) return []\n const contexts =\n \"entity\" in target\n ? ((await facts?.entity(target.entity))?.variants.map((v) => v.context) ?? [])\n : documentContexts(target.scope, target.id)\n return contexts.map((context) => ({ ...context }))\n },\n async consumersOf(name: string, dimensions: Record<string, string> = {}) {\n const target = Object.hasOwn(module.exports, name) && module.exports[name]\n if (!target || !(\"entity\" in target) || !facts) return []\n const edges = await facts.relations(target.entity, {\n context: factContext(pinned.reader, target.entity, dimensions),\n direction: \"in\",\n })\n const consumers = []\n for (const edge of edges) {\n if (![\"references\", \"derivedFrom\", \"demonstrates\", \"requires\"].includes(edge.type)) continue\n const source = await facts.resolve(edge.source, edge.context ?? dimensions)\n if (source.status !== \"exact\") continue\n const data = source.value.data as {\n references?: PageReference[]\n } | null\n const expectedPin =\n edge.type === \"references\" && Array.isArray(data?.references)\n ? data.references.find((ref) => ref.object === target.entity)?.pin\n : undefined\n consumers.push({\n entity: edge.source,\n relation: edge.type,\n provenance: source.value.provenance,\n expectedPin,\n })\n }\n return consumers\n },\n async readExport(name: string, dimensions: Record<string, string> = {}) {\n if (!Object.hasOwn(module.exports, name))\n return { status: \"not-found\" as const, export: name }\n const target = module.exports[name]!\n const attribution = module.adaptation && {\n provider: module.adaptation.provider,\n source: module.adaptation.sources[name]!,\n }\n if (\"entity\" in target) {\n if (!facts) throw new Error(\"Public fact requires a semantic index.\")\n const result = await facts.resolve(\n target.entity,\n factContext(pinned.reader, target.entity, dimensions),\n )\n if (result.status !== \"exact\") return result\n return {\n status: \"exact\" as const,\n kind: \"entity\" as const,\n software,\n inventoryRevision,\n export: name,\n entity: target.entity,\n value: result.value,\n ...(attribution && { adaptation: attribution }),\n }\n }\n const result = pinned.reader.resolveEdition({ ...target, dimensions })\n if (result.status !== \"exact\") return result\n const request =\n result.value.contextVariants || result.value.availability\n ? (result.resolution?.effective ?? dimensions)\n : undefined\n const value = await pinned.reader.read(\n result.value.identity,\n target.section,\n undefined,\n request,\n )\n const projection = pinned.reader.projection(result.value.identity, request)\n if (!value || !projection) throw new Error(`Missing published export ${name}.`)\n const path =\n target.section === undefined\n ? projection.markdown\n : projection.sections.find((section) => section.id === target.section)!.markdown\n return {\n status: \"exact\" as const,\n kind: \"markdown\" as const,\n software,\n inventoryRevision,\n export: name,\n ...(attribution && { adaptation: attribution }),\n entity:\n target.section === undefined\n ? documentEntityId(target)\n : sectionEntityId(target, target.section),\n ...(result.resolution && { resolution: result.resolution }),\n route: result.value.route,\n losses: (result.value.losses ?? []).filter(\n (loss) => target.section === undefined || loss.section === target.section,\n ),\n contentSha256: pinned.artifact(path).sha256,\n identity: result.value.identity,\n value,\n }\n },\n }\n}\n\nexport type OpenDocumentModule = Extract<\n Awaited<ReturnType<typeof openDocumentModule>>,\n { status: \"opened\" }\n>\nexport type ReadDocumentExport = Awaited<ReturnType<OpenDocumentModule[\"readExport\"]>>\n"],"mappings":";;;;;AAQA,MAAa,yBAAyB,SACpC,8DAA8D,KAAK,IAAI;AAiBzE,SAAgB,qBAAqB,OAAgC;CACnE,MAAM,UAAU,UACd,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;CAC9D,MAAM,UAAU,UAAoC,OAAO,UAAU,YAAY,MAAM,SAAS;CAChG,IACE,CAAC,OAAO,KAAK,KACb,MAAM,kBAAkB,KACxB,CAAC,OAAO,MAAM,QAAQ,KACtB,CAAC,OAAO,MAAM,SAAS,IAAI,KAC3B,CAAC,OAAO,MAAM,SAAS,OAAO,KAC9B,CAAC,OAAO,MAAM,OAAO,KACrB,CAAC,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC,UAC5B,OAAO,QAAQ,MAAM,OAAO,CAAC,CAAC,MAC3B,CAAC,MAAM,YACN,CAAC,OAAO,IAAI,KACZ,CAAC,OAAO,MAAM,MACb,YAAY,SACT,OAAO,OAAO,WAAW,YACzB,CAAC,WAAW,OAAO,MAAM,KACzB,WAAW,UACX,QAAQ,UACR,aAAa,SACb,CAAC,OAAO,OAAO,KAAK,KACpB,CAAC,OAAO,OAAO,EAAE,KAChB,OAAO,YAAY,UAAa,CAAC,OAAO,OAAO,OAAO,EAC/D,GAEA,MAAM,IAAI,MAAM,qDAAqD;CACvE,IAAI,MAAM,eAAe,Q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AAK,EAAE;GAC9E,MAAM,OACJ,OAAO,YAAY,SACf,WAAW,WACX,WAAW,SAAS,MAAM,YAAY,QAAQ,OAAO,OAAO,OAAO,CAAC,CAAE;GAC5E,OAAO;IACL,QAAQ;IACR,MAAM;IACN;IACA;IACA,QAAQ;IACR,GAAI,eAAe,EAAE,YAAY,YAAY;IAC7C,QACE,OAAO,YAAY,SACf,iBAAiB,MAAM,IACvB,gBAAgB,QAAQ,OAAO,OAAO;IAC5C,GAAI,OAAO,cAAc,EAAE,YAAY,OAAO,WAAW;IACzD,OAAO,OAAO,MAAM;IACpB,SAAS,OAAO,MAAM,UAAU,CAAC,EAAC,CAAE,QACjC,SAAS,OAAO,YAAY,UAAa,KAAK,YAAY,OAAO,OACpE;IACA,eAAe,OAAO,SAAS,IAAI,CAAC,CAAC;IACrC,UAAU,OAAO,MAAM;IACvB;GACF;EACF;CACF;AACF"}
@@ -0,0 +1,33 @@
1
+ import { type Condition } from "./condition.js";
2
+ import type { Context } from "./semantic.js";
3
+ export interface NavigationPlacement {
4
+ id: string;
5
+ title: string;
6
+ kind: string;
7
+ description?: string;
8
+ route?: string;
9
+ document?: string;
10
+ availability?: Context;
11
+ when?: Condition;
12
+ children?: NavigationPlacement[];
13
+ }
14
+ export interface PublishedNavigation {
15
+ name: string;
16
+ context: Context;
17
+ nodes: NavigationPlacement[];
18
+ /** Matching fact revisions used by query placements. */
19
+ reads: {
20
+ variant: string;
21
+ revision: string;
22
+ }[];
23
+ }
24
+ export declare function selectNavigationView(views: readonly PublishedNavigation[], name: string, context: Context): PublishedNavigation | undefined;
25
+ /** Prune inapplicable destinations and groups that lose all their children. */
26
+ export declare function filterNavigationView(view: PublishedNavigation, context: Context, include?: (placement: NavigationPlacement) => boolean): PublishedNavigation;
27
+ /** The first placement of a document is its default. A host retaining a placement may select its other path. */
28
+ export declare function navigationPath(view: PublishedNavigation, documentKey: string, placement?: string): {
29
+ current: NavigationPlacement | undefined;
30
+ breadcrumbs: NavigationPlacement[];
31
+ previous: NavigationPlacement | undefined;
32
+ next: NavigationPlacement | undefined;
33
+ };
@@ -0,0 +1,68 @@
1
+ import { DocsError } from "./model.js";
2
+ import { matchesCondition } from "./condition.js";
3
+
4
+ // src/navigation-view.ts
5
+ function selectNavigationView(views, name, context) {
6
+ const size = Object.keys(context).length;
7
+ return views.find((view) => view.name === name && Object.keys(view.context).length === size && matchesCondition(view.context, context));
8
+ }
9
+ /** Prune inapplicable destinations and groups that lose all their children. */
10
+ function filterNavigationView(view, context, include) {
11
+ function filter(nodes) {
12
+ const visible = [];
13
+ let changed = false;
14
+ for (const node of nodes) {
15
+ if (!matchesCondition(node.availability, context) || !matchesCondition(node.when, context) || include !== void 0 && !include(node)) {
16
+ changed = true;
17
+ continue;
18
+ }
19
+ const children = node.children && filter(node.children);
20
+ if (node.children?.length && !children?.length) {
21
+ changed = true;
22
+ continue;
23
+ }
24
+ if (children !== node.children) {
25
+ changed = true;
26
+ visible.push({
27
+ ...node,
28
+ children
29
+ });
30
+ } else visible.push(node);
31
+ }
32
+ return changed ? visible : nodes;
33
+ }
34
+ const nodes = filter(view.nodes);
35
+ return nodes === view.nodes ? view : {
36
+ ...view,
37
+ nodes
38
+ };
39
+ }
40
+ /** The first placement of a document is its default. A host retaining a placement may select its other path. */
41
+ function navigationPath(view, documentKey, placement) {
42
+ const links = [];
43
+ let trail = [];
44
+ let position = -1;
45
+ function visit(nodes, parents) {
46
+ for (const node of nodes) {
47
+ if (node.route) {
48
+ if (node.document === documentKey && (placement ? node.id === placement : position < 0)) {
49
+ trail = [...parents, node];
50
+ position = links.length;
51
+ }
52
+ links.push(node);
53
+ }
54
+ if (node.children) visit(node.children, [...parents, node]);
55
+ }
56
+ }
57
+ visit(view.nodes, []);
58
+ if (placement && position < 0) throw new DocsError("DOCS_NAVIGATION_PLACEMENT", "Unknown placement for this document.", { source: placement });
59
+ return {
60
+ current: trail.at(-1),
61
+ breadcrumbs: trail,
62
+ previous: position > 0 ? links[position - 1] : void 0,
63
+ next: position >= 0 ? links[position + 1] : void 0
64
+ };
65
+ }
66
+
67
+ export { filterNavigationView, navigationPath, selectNavigationView };
68
+ //# sourceMappingURL=navigation-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-view.js","names":[],"sources":["../src/navigation-view.ts"],"sourcesContent":["import { DocsError } from \"./model.js\"\nimport { matchesCondition, type Condition } from \"./condition.js\"\nimport type { Context } from \"./semantic.js\"\n\nexport interface NavigationPlacement {\n id: string\n title: string\n kind: string\n description?: string\n route?: string\n document?: string\n availability?: Context\n when?: Condition\n children?: NavigationPlacement[]\n}\nexport interface PublishedNavigation {\n name: string\n context: Context\n nodes: NavigationPlacement[]\n /** Matching fact revisions used by query placements. */\n reads: { variant: string; revision: string }[]\n}\n\nexport function selectNavigationView(\n views: readonly PublishedNavigation[],\n name: string,\n context: Context,\n) {\n const size = Object.keys(context).length\n return views.find(\n (view) =>\n view.name === name &&\n Object.keys(view.context).length === size &&\n matchesCondition(view.context, context),\n )\n}\n\n/** Prune inapplicable destinations and groups that lose all their children. */\nexport function filterNavigationView(\n view: PublishedNavigation,\n context: Context,\n include?: (placement: NavigationPlacement) => boolean,\n): PublishedNavigation {\n function filter(nodes: NavigationPlacement[]): NavigationPlacement[] {\n const visible: NavigationPlacement[] = []\n let changed = false\n for (const node of nodes) {\n if (\n !matchesCondition(node.availability, context) ||\n !matchesCondition(node.when, context) ||\n (include !== undefined && !include(node))\n ) {\n changed = true\n continue\n }\n const children = node.children && filter(node.children)\n if (node.children?.length && !children?.length) {\n changed = true\n continue\n }\n if (children !== node.children) {\n changed = true\n visible.push({ ...node, children })\n } else visible.push(node)\n }\n return changed ? visible : nodes\n }\n const nodes = filter(view.nodes)\n return nodes === view.nodes ? view : { ...view, nodes }\n}\n\n/** The first placement of a document is its default. A host retaining a placement may select its other path. */\nexport function navigationPath(view: PublishedNavigation, documentKey: string, placement?: string) {\n const links: NavigationPlacement[] = []\n let trail: NavigationPlacement[] = []\n let position = -1\n function visit(nodes: readonly NavigationPlacement[], parents: NavigationPlacement[]) {\n for (const node of nodes) {\n if (node.route) {\n if (node.document === documentKey && (placement ? node.id === placement : position < 0)) {\n trail = [...parents, node]\n position = links.length\n }\n links.push(node)\n }\n if (node.children) visit(node.children, [...parents, node])\n }\n }\n visit(view.nodes, [])\n if (placement && position < 0)\n throw new DocsError(\"DOCS_NAVIGATION_PLACEMENT\", \"Unknown placement for this document.\", {\n source: placement,\n })\n return {\n current: trail.at(-1),\n breadcrumbs: trail,\n previous: position > 0 ? links[position - 1] : undefined,\n next: position >= 0 ? links[position + 1] : undefined,\n }\n}\n"],"mappings":";;;;AAuBA,SAAgB,qBACd,OACA,MACA,SACA;CACA,MAAM,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC;CAClC,OAAO,MAAM,MACV,SACC,KAAK,SAAS,QACd,OAAO,KAAK,KAAK,OAAO,CAAC,CAAC,WAAW,QACrC,iBAAiB,KAAK,SAAS,OAAO,CAC1C;AACF;;AAGA,SAAgB,qBACd,MACA,SACA,SACqB;CACrB,SAAS,OAAO,OAAqD;EACnE,MAAM,UAAiC,CAAC;EACxC,IAAI,UAAU;EACd,KAAK,MAAM,QAAQ,OAAO;GACxB,IACE,CAAC,iBAAiB,KAAK,cAAc,OAAO,KAC5C,CAAC,iBAAiB,KAAK,MAAM,OAAO,KACnC,YAAY,UAAa,CAAC,QAAQ,IAAI,GACvC;IACA,UAAU;IACV;GACF;GACA,MAAM,WAAW,KAAK,YAAY,OAAO,KAAK,QAAQ;GACtD,IAAI,KAAK,UAAU,UAAU,CAAC,UAAU,QAAQ;IAC9C,UAAU;IACV;GACF;GACA,IAAI,aAAa,KAAK,UAAU;IAC9B,UAAU;IACV,QAAQ,KAAK;KAAE,GAAG;KAAM;IAAS,CAAC;GACpC,OAAO,QAAQ,KAAK,IAAI;EAC1B;EACA,OAAO,UAAU,UAAU;CAC7B;CACA,MAAM,QAAQ,OAAO,KAAK,KAAK;CAC/B,OAAO,UAAU,KAAK,QAAQ,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