@topik/core 0.1.0-alpha.5 → 0.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,26 +1,39 @@
1
+ import { CourseReferenceContext, ResolvedCourseContentLink, ResolvedCourseContentReference, ResolvedCourseNavigation, ResolvedCoursePage, resolveCourseContentHref, resolveCourseContentReference, resolveCourseNavigation } from "./course-navigation.mjs";
2
+ import { $ as TopikAssetPathDiagnosticReason, A as AssetBlobUri, B as parseGeneratedAssetName, C as TopikMaterializationResourceV1, D as digestTopikAssetSemanticRecord, E as createTopikMaterializationRecord, F as generateAutomaticAssetName, G as validateProjectNamespace, H as topikAssetNameDescriptor, I as isAssetBlobUri, J as TOPIK_ASSET_DIAGNOSTIC_IDS, K as TOPIK_ASSET_CORRELATION_ID_PATTERN, L as isGeneratedAssetName, M as GenerateAutomaticAssetNameOptions, N as GeneratedAssetName, O as digestTopikMaterializationRecord, P as ParsedAsset, Q as TopikAssetDiagnosticLocation, R as parseAsset, S as TopikMaterializationResourceInput, T as createTopikAssetSemanticRecord, U as validateAssetBlobUri, V as serializeAsset, W as validateAssetValue, X as TopikAssetDiagnostic, Y as TopikAssetCorrelationId, Z as TopikAssetDiagnosticId, _ as TopikAssetReferenceMappingV1, a as PreviewState, at as ASSET_TYPE, b as TopikMaterializationPayloadV1, c as AssetCompilationOptions, ct as TOPIK_ASSET_REFERENCE_VERSION, d as AssetNameInput, dt as TOPIK_MATERIALIZATION_VERSION, et as TopikAssetRecoveryCategory, f as AssetPayload, ft as TOPIK_PATH_V1_DESCRIPTOR, g as compileAssetResources, gt as SourceResource, h as ContentBearingResource, ht as ResourceType, i as PreviewPayloadDescriptor, it as ASSET_SCHEMA_ID, j as CompiledAsset, k as validateTopikMaterializationRecord, l as AssetCompilationResult, lt as TOPIK_BLOB_OUTPUT_PREFIX, m as CompiledResource, mt as Resource, n as CourseNavigationModule, nt as correlateTopikAssetResult, o as TOPIK_PREVIEW_PROTOCOL, ot as TOPIK_ASSET_LIMITS, p as CompileAssetResourcesInput, pt as TOPIK_PATH_VERSION, q as TOPIK_ASSET_DEFAULT_CORRELATION_ID, r as PreviewDiagnostic, rt as ASSET_API_VERSION, s as AssetCompilationError, st as TOPIK_ASSET_NAME_VERSION, t as CourseNavigationIndex, tt as TopikAssetResult, u as AssetNameGenerator, ut as TOPIK_JSON_VERSION, v as TopikAssetSemanticRecordV1, w as compareTopikAssetIdentities, x as TopikMaterializationRecordV1, y as TopikMaterializationPayloadInput, z as parseAssetBlobUri } from "./preview-C_3OnNUi.mjs";
3
+ import { ExternalWikiDropdown, ExternalWikiTab, InternalWikiDropdown, InternalWikiTab, ResolvedWikiContentLink, ResolvedWikiContentReference, ResolvedWikiNavigation, ResolvedWikiPage, WikiSwitcherNode, findFirstWikiPage, findWikiPageAncestors, hasWikiNavChildren, isExternalWikiDropdown, isExternalWikiTab, isInternalWikiDropdown, isInternalWikiTab, joinWikiPath, resolveWikiContentHref, resolveWikiContentReference, resolveWikiNavigation } from "./wiki-navigation.mjs";
1
4
  import { z } from "zod";
2
- import { TopikContentDiagnostic, TopikGeneratedAssetName } from "@topik/content-schema";
5
+ import { TopikContentDiagnostic, TopikNavigationReference, TopikResourceReference } from "@topik/content";
6
+ import "yaml";
7
+ import { Person } from "@topik/schema/person/v1";
3
8
  import { CoursePage } from "@topik/schema/course-page/v1";
4
9
  import { Guide } from "@topik/schema/guide/v1";
10
+ import { Wiki, WikiNavNode } from "@topik/schema/wiki/v1";
5
11
  import { WikiPage } from "@topik/schema/wiki-page/v1";
6
- import { Asset } from "@topik/schema/asset/v1";
7
- import { Course } from "@topik/schema/course/v1";
8
- import { CourseModule } from "@topik/schema/course-module/v1";
9
- import { Person } from "@topik/schema/person/v1";
10
- import { Wiki, WikiDropdownNavNode, WikiExternalDropdownNavNode, WikiExternalTabNavNode, WikiInternalDropdownNavNode, WikiInternalTabNavNode, WikiNavContainerNode, WikiNavNode, WikiNavigation, WikiPageNavNode, WikiTabNavNode } from "@topik/schema/wiki/v1";
12
+ //#region src/config/source-version.d.ts
13
+ /** The public resource validator owns Person fields, including future schema additions. */
14
+ declare function parseSourcePersons(value: unknown): Person[];
15
+ //#endregion
11
16
  //#region src/config/collection.d.ts
12
17
  declare const collectionConfigSchema: z.ZodObject<{
13
18
  id: z.ZodString;
14
19
  title: z.ZodString;
20
+ sourceVersion: z.ZodOptional<z.ZodLiteral<1>>;
21
+ persons: z.ZodOptional<z.ZodUnknown>;
22
+ assets: z.ZodDefault<z.ZodObject<{
23
+ directory: z.ZodDefault<z.ZodString>;
24
+ }, z.core.$strict>>;
15
25
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
26
  }, z.core.$strip>;
17
- type CollectionConfig = z.infer<typeof collectionConfigSchema>;
18
- declare function parseCollectionConfig(raw: unknown): CollectionConfig;
27
+ type CollectionConfig = Omit<z.infer<typeof collectionConfigSchema>, "persons"> & {
28
+ persons?: ReturnType<typeof parseSourcePersons>;
29
+ };
30
+ export declare function parseCollectionConfig(raw: unknown): CollectionConfig;
19
31
  //#endregion
20
32
  //#region src/config/wiki.d.ts
21
33
  type WikiPageNavNode$1 = {
22
34
  type: "page";
23
35
  slug: string;
36
+ source?: string;
24
37
  icon?: string;
25
38
  hidden?: boolean;
26
39
  };
@@ -59,6 +72,11 @@ type WikiNavNode$1 = string | WikiPageNavNode$1 | WikiGroupNavNode | WikiInterna
59
72
  declare const wikiConfigSchema: z.ZodObject<{
60
73
  id: z.ZodString;
61
74
  title: z.ZodString;
75
+ sourceVersion: z.ZodOptional<z.ZodLiteral<1>>;
76
+ labels: z.ZodOptional<z.ZodUnknown>;
77
+ assets: z.ZodDefault<z.ZodObject<{
78
+ directory: z.ZodDefault<z.ZodString>;
79
+ }, z.core.$strict>>;
62
80
  description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
63
81
  navigation: z.ZodOptional<z.ZodArray<z.ZodType<WikiNavNode$1, unknown, z.core.$ZodTypeInternals<WikiNavNode$1, unknown>>>>;
64
82
  theme: z.ZodOptional<z.ZodObject<{
@@ -76,294 +94,288 @@ declare const wikiConfigSchema: z.ZodObject<{
76
94
  }, z.core.$strip>>;
77
95
  }, z.core.$strip>>;
78
96
  }, z.core.$strip>;
79
- type WikiConfig = z.infer<typeof wikiConfigSchema>;
80
- declare function parseWikiConfig(raw: unknown): WikiConfig;
81
- //#endregion
82
- //#region src/resource.d.ts
83
- type Resource = Asset | Course | CourseModule | CoursePage | Guide | Person | Wiki | WikiPage;
84
- /** Resources accepted as compiler input. `Asset` exists only in compiler output. */
85
- type SourceResource = Exclude<Resource, Asset>;
86
- type ResourceType = Resource["type"];
87
- //#endregion
88
- //#region src/assets/constants.d.ts
89
- declare const ASSET_API_VERSION: "v1";
90
- declare const ASSET_TYPE: "Asset";
91
- declare const ASSET_SCHEMA_ID: "https://topik.dev/schemas/asset/v1.json";
92
- declare const TOPIK_JSON_VERSION: "topik-json-v1";
93
- declare const TOPIK_PATH_VERSION: "topik-path-v1";
94
- declare const TOPIK_ASSET_REFERENCE_VERSION: "topik-asset-reference-v1";
95
- declare const TOPIK_MATERIALIZATION_VERSION: "topik-materialization-v1";
96
- declare const TOPIK_ASSET_NAME_VERSION: "topik-asset-name-v1";
97
- declare const TOPIK_BLOB_OUTPUT_PREFIX: "blobs";
98
- declare const TOPIK_PATH_V1_DESCRIPTOR: {
99
- readonly collisionNormalization: "toNFKC_Casefold";
100
- readonly id: "topik-path-v1";
101
- readonly localReferenceEncoding: "rfc3986-utf8-upper-v1";
102
- readonly maxComponentUtf8Bytes: 255;
103
- readonly maxComponents: 64;
104
- readonly maxRepositoryPathUtf8Bytes: 768;
105
- readonly normalizationSensitiveExclusion: "unicode-17-new-marks";
106
- readonly storageNormalization: "NFC";
107
- readonly unicodeVersion: "17.0.0";
108
- };
109
- declare const TOPIK_ASSET_LIMITS: {
110
- readonly maxDescriptorBytes: 1048576;
111
- readonly maxAssetBytes: 268435456;
112
- readonly maxAssets: 10000;
113
- readonly maxJsonDepth: 8;
114
- readonly maxComponentUtf8Bytes: 255;
115
- readonly maxComponents: 64;
116
- readonly maxRepositoryPathUtf8Bytes: 768;
97
+ type WikiConfig = Omit<z.infer<typeof wikiConfigSchema>, "labels"> & {
98
+ labels?: Record<string, string>;
117
99
  };
100
+ export declare function parseWikiConfig(raw: unknown): WikiConfig;
118
101
  //#endregion
119
- //#region src/assets/diagnostics.d.ts
120
- declare const TOPIK_ASSET_DIAGNOSTIC_IDS: readonly ["TOPIK_ASSET_UNSUPPORTED_VERSION", "TOPIK_ASSET_DUPLICATE_MEMBER", "TOPIK_ASSET_SCHEMA_INVALID", "TOPIK_ASSET_NON_CANONICAL", "TOPIK_ASSET_NAME_INVALID", "TOPIK_ASSET_NAME_COLLISION", "TOPIK_ASSET_SOURCE_NAMESPACE_REQUIRED", "TOPIK_ASSET_SOURCE_NAMESPACE_INVALID", "TOPIK_ASSET_PATH_INVALID", "TOPIK_ASSET_PATH_COLLISION", "TOPIK_ASSET_REFERENCE_AMBIGUOUS", "TOPIK_ASSET_REFERENCE_MALFORMED", "TOPIK_ASSET_REFERENCE_MISSING", "TOPIK_ASSET_FILE_MISSING", "TOPIK_ASSET_DIGEST_MISMATCH", "TOPIK_ASSET_SIZE_MISMATCH", "TOPIK_ASSET_MEDIA_TYPE_MISMATCH", "TOPIK_ASSET_FILE_TYPE_UNSUPPORTED", "TOPIK_ASSET_ACTIVE_CONTENT_UNSUPPORTED", "TOPIK_ASSET_REFERENCE_ACCESSIBILITY_INVALID", "TOPIK_EXTERNAL_REFERENCE_UNSAFE", "TOPIK_ASSET_INVENTORY_INCOMPLETE", "TOPIK_ASSET_VERSION_INCOMPARABLE"];
121
- declare const TOPIK_ASSET_DEFAULT_CORRELATION_ID: "cor_00000000000000000000000000";
122
- declare const TOPIK_ASSET_CORRELATION_ID_PATTERN: RegExp;
123
- type TopikAssetCorrelationId = `cor_${string}`;
124
- type TopikAssetDiagnosticId = (typeof TOPIK_ASSET_DIAGNOSTIC_IDS)[number];
125
- type TopikAssetPathDiagnosticReason = "invalid_utf8" | "capability_invalid" | "unicode_version_unsupported" | "not_nfc" | "absolute" | "separator_alias" | "dot_segment" | "percent_noncanonical" | "forbidden_character" | "reserved_name" | "too_long" | "casefold_collision";
126
- type TopikAssetRecoveryCategory = "upgrade-reader" | "repair-source" | "restore-file" | "verify-bytes" | "preserve-read-only";
127
- interface TopikAssetDiagnosticLocation {
128
- jsonPointer?: string;
129
- contentPosition?: string;
130
- path?: string;
131
- key?: string;
132
- commit?: string;
133
- }
134
- interface TopikAssetDiagnostic {
135
- id: TopikAssetDiagnosticId;
136
- /** Safe opaque operation correlation; callers may replace the deterministic default. */
137
- correlationId: TopikAssetCorrelationId;
138
- severity: "error";
139
- consequence: "block-resource" | "block-identity-and-writes" | "block-mutation";
140
- descriptorVersion: string;
141
- location: TopikAssetDiagnosticLocation;
142
- recovery: TopikAssetRecoveryCategory;
143
- reason?: TopikAssetPathDiagnosticReason;
144
- /** Human wording is intentionally not a stable compatibility surface. */
145
- message: string;
146
- }
147
- type TopikAssetResult<T> = {
148
- ok: true;
149
- value: T;
150
- diagnostics: readonly [];
151
- source?: Uint8Array;
152
- } | {
153
- ok: false;
154
- value?: T;
155
- diagnostics: readonly TopikAssetDiagnostic[];
156
- /** Exact caller bytes are non-loggable evidence; never copy them into diagnostics/telemetry. */
157
- source?: Uint8Array;
102
+ //#region src/config/course.d.ts
103
+ declare const moduleSchema: z.ZodObject<{
104
+ id: z.ZodString;
105
+ title: z.ZodString;
106
+ slug: z.ZodString;
107
+ order: z.ZodNumber;
108
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
109
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
110
+ pages: z.ZodArray<z.ZodString>;
111
+ }, z.core.$strip>;
112
+ declare const courseConfigSchema: z.ZodObject<{
113
+ sourceVersion: z.ZodLiteral<1>;
114
+ id: z.ZodString;
115
+ title: z.ZodString;
116
+ slug: z.ZodString;
117
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
119
+ authors: z.ZodOptional<z.ZodArray<z.ZodString>>;
120
+ persons: z.ZodOptional<z.ZodUnknown>;
121
+ assets: z.ZodDefault<z.ZodObject<{
122
+ directory: z.ZodDefault<z.ZodString>;
123
+ }, z.core.$strict>>;
124
+ modules: z.ZodArray<z.ZodObject<{
125
+ id: z.ZodString;
126
+ title: z.ZodString;
127
+ slug: z.ZodString;
128
+ order: z.ZodNumber;
129
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
130
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
131
+ pages: z.ZodArray<z.ZodString>;
132
+ }, z.core.$strip>>;
133
+ }, z.core.$strip>;
134
+ type CourseConfig = Omit<z.infer<typeof courseConfigSchema>, "persons"> & {
135
+ persons?: ReturnType<typeof parseSourcePersons>;
158
136
  };
159
- declare function correlateTopikAssetResult<T>(result: TopikAssetResult<T>, correlationId: TopikAssetCorrelationId): TopikAssetResult<T>;
137
+ type CourseModuleConfig = z.infer<typeof moduleSchema>;
138
+ export declare function parseCourseConfig(raw: unknown): CourseConfig;
160
139
  //#endregion
161
- //#region src/assets/asset.d.ts
162
- interface ParsedAsset {
163
- asset: Asset;
164
- canonicalBytes: Uint8Array;
165
- }
166
- /** Compiler-generated name used by automatic Asset compilation. */
167
- type GeneratedAssetName = TopikGeneratedAssetName;
168
- declare const assetBlobUriBrand: unique symbol;
169
- /** Opaque compiler output path for one SHA-256-addressed Asset blob. */
170
- type AssetBlobUri = string & {
171
- readonly [assetBlobUriBrand]: "AssetBlobUri";
172
- };
173
- declare function isAssetBlobUri(value: unknown): value is AssetBlobUri;
174
- declare function parseAssetBlobUri(value: string): AssetBlobUri;
175
- declare function parseGeneratedAssetName(value: string): GeneratedAssetName;
176
- /** Asset descriptor emitted by the compiler with a materialized payload. */
177
- interface CompiledAsset extends Asset {
178
- name: GeneratedAssetName;
179
- spec: {
180
- uri: AssetBlobUri;
181
- integrity: `sha256:${string}`;
182
- size: number;
183
- mediaType: string;
184
- };
185
- }
186
- declare function parseAsset(input: string | Uint8Array): TopikAssetResult<ParsedAsset>;
187
- declare function validateAssetValue(value: unknown): TopikAssetResult<Asset>;
188
- /** Serialize one Asset to deterministic UTF-8 canonical JSON and prove its round trip. */
189
- declare function serializeAsset(value: unknown): TopikAssetResult<Uint8Array>;
190
- /** Admit a compiler-materialized blob path; Asset resources may use other URI forms. */
191
- declare function validateAssetBlobUri(value: string): TopikAssetResult<{
192
- uri: AssetBlobUri;
193
- }>;
194
- declare function isGeneratedAssetName(value: unknown): value is GeneratedAssetName;
195
- declare function validateStableSourceNamespace(value: string): TopikAssetResult<string>;
196
- interface GenerateAutomaticAssetNameOptions {
197
- stableSourceNamespace: string;
198
- normalizedPath: string;
199
- }
200
- declare function generateAutomaticAssetName(options: GenerateAutomaticAssetNameOptions): TopikAssetResult<GeneratedAssetName>;
201
- declare function topikAssetNameDescriptor(): {
202
- id: typeof TOPIK_ASSET_NAME_VERSION;
140
+ //#region src/config/manifest.d.ts
141
+ export declare const TOPIK_MANIFEST_FILENAME = ".topik.yaml";
142
+ export declare const TOPIK_MANIFEST_LIMITS: {
143
+ readonly maxBytes: 1048576;
144
+ readonly maxSources: 1000;
145
+ readonly maxDepth: 32;
203
146
  };
147
+ export declare const topikManifestSourceSchema: z.ZodObject<{
148
+ kind: z.ZodEnum<{
149
+ collection: "collection";
150
+ course: "course";
151
+ wiki: "wiki";
152
+ }>;
153
+ config: z.ZodString;
154
+ }, z.core.$strict>;
155
+ export declare const topikManifestSchema: z.ZodObject<{
156
+ version: z.ZodLiteral<1>;
157
+ namespace: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
158
+ sources: z.ZodArray<z.ZodObject<{
159
+ kind: z.ZodEnum<{
160
+ collection: "collection";
161
+ course: "course";
162
+ wiki: "wiki";
163
+ }>;
164
+ config: z.ZodString;
165
+ }, z.core.$strict>>;
166
+ }, z.core.$strict>;
167
+ type TopikManifest = z.infer<typeof topikManifestSchema>;
168
+ type TopikManifestSource = z.infer<typeof topikManifestSourceSchema>;
169
+ export declare function parseTopikManifest(raw: unknown): TopikManifest;
204
170
  //#endregion
205
- //#region src/assets/identity.d.ts
206
- interface TopikAssetReferenceMappingV1 {
207
- resource: string;
208
- position: string;
209
- slot: string;
210
- name: string;
211
- }
212
- interface TopikAssetSemanticRecordV1 {
213
- descriptor: "topik-asset-semantic-v1";
214
- assetNames: readonly string[];
215
- references: readonly TopikAssetReferenceMappingV1[];
216
- }
217
- interface TopikMaterializationResourceV1 {
218
- resource: string;
219
- path: string;
220
- size: number;
221
- sha256: string;
222
- }
223
- interface TopikMaterializationPayloadV1 {
224
- path: string;
225
- size: number;
226
- sha256: string;
227
- assetNames: readonly string[];
228
- }
229
- interface TopikMaterializationRecordV1 {
230
- descriptor: "topik-materialization-v1";
231
- resources: readonly TopikMaterializationResourceV1[];
232
- payloads: readonly TopikMaterializationPayloadV1[];
233
- }
234
- interface TopikMaterializationResourceInput {
235
- resource: {
236
- type: string;
237
- name: string;
238
- };
239
- bytes: Uint8Array;
240
- }
241
- interface TopikMaterializationPayloadInput {
242
- path: string;
243
- bytes: Uint8Array;
244
- assetNames: readonly string[];
245
- }
246
- declare function createTopikAssetSemanticRecord(assets: readonly Asset[], references: readonly TopikAssetReferenceMappingV1[]): TopikAssetSemanticRecordV1;
247
- declare function createTopikMaterializationRecord(resources: readonly TopikMaterializationResourceInput[], payloads: readonly TopikMaterializationPayloadInput[]): TopikMaterializationRecordV1;
248
- declare function validateTopikMaterializationRecord(record: unknown, resources: readonly Resource[], semantic: unknown): TopikAssetResult<TopikMaterializationRecordV1>;
249
- declare function digestTopikAssetSemanticRecord(record: TopikAssetSemanticRecordV1): string;
250
- declare function digestTopikMaterializationRecord(record: TopikMaterializationRecordV1): string;
251
- declare function compareTopikAssetIdentities(left: {
252
- semantic: TopikAssetSemanticRecordV1;
253
- materialization: TopikMaterializationRecordV1;
254
- }, right: {
255
- semantic: TopikAssetSemanticRecordV1;
256
- materialization: TopikMaterializationRecordV1;
257
- }): TopikAssetResult<{
258
- semanticEqual: boolean;
259
- exactEqual: boolean;
260
- }>;
171
+ //#region src/config/assets.d.ts
172
+ export declare const DEFAULT_ASSET_DIRECTORY = "_assets";
173
+ /** Source-local destination for new synced media; not an input scan or compiler output path. */
174
+ export declare const sourceAssetsConfigSchema: z.ZodObject<{
175
+ directory: z.ZodDefault<z.ZodString>;
176
+ }, z.core.$strict>;
177
+ type SourceAssetsConfig = z.infer<typeof sourceAssetsConfigSchema>;
261
178
  //#endregion
262
- //#region src/compile/assets.d.ts
263
- type ContentBearingResource = CoursePage | Guide | WikiPage;
264
- interface AssetCompilationOptions {
265
- /** Required only when supported local references are discovered automatically. */
266
- sourceNamespace?: string;
179
+ //#region src/compile/public-errors.d.ts
180
+ declare const PUBLIC_COMPILE_ERROR_MESSAGES: {
181
+ readonly "manifest-required": 'Project compilation requires .topik.yaml in the selected directory. Add a manifest such as: {"version":1,"namespace":"owner/project","sources":[{"kind":"wiki","config":"wiki.yaml"}]}';
182
+ readonly "manifest-invalid": "Root manifest is invalid.";
183
+ readonly "manifest-source-failed": "Manifest source could not be compiled.";
184
+ readonly "manifest-resource-conflict": "Manifest sources produce conflicting resource identities.";
185
+ readonly "config-access-failed": "Configuration file could not be accessed.";
186
+ readonly "config-invalid": "Configuration is invalid.";
187
+ readonly "config-not-found": "Required configuration file was not found.";
188
+ readonly "config-parse-failed": "Configuration file could not be parsed.";
189
+ readonly "config-read-failed": "Configuration file could not be read safely.";
190
+ readonly "file-safe-read-unsupported": "This platform cannot safely open compilation inputs.";
191
+ readonly "file-not-regular": "Compilation input must be a regular file.";
192
+ readonly "file-outside-compilation-root": "Compilation input resolves outside the source root.";
193
+ readonly "frontmatter-invalid": "Document frontmatter is invalid.";
194
+ readonly "reference-list-invalid": "Document resource references are invalid.";
195
+ readonly "reference-targets-invalid": "Resource reference target catalogue is invalid.";
196
+ readonly "wiki-page-not-found": "A configured Wiki page file was not found.";
197
+ readonly "wiki-page-ambiguous": "A Wiki source path matches more than one Markdown file. Keep exactly one source file.";
198
+ readonly "course-page-not-found": "A configured Course page file was not found.";
199
+ readonly "course-page-ambiguous": "A Course source path matches more than one Markdown file. Keep exactly one source file.";
200
+ readonly "author-not-found": "An author must reference a Person in the declared project.";
201
+ };
202
+ type PublicCompileErrorId = keyof typeof PUBLIC_COMPILE_ERROR_MESSAGES;
203
+ export declare function publicCompileErrorMessage(id: unknown): string | undefined;
204
+ /** Public compiler failure with fixed wording, stable ID, and optional safe relative location. */
205
+ export declare class PublicCompileError extends Error {
206
+ readonly id: PublicCompileErrorId;
207
+ readonly location?: string;
208
+ constructor(id: PublicCompileErrorId, location?: string);
267
209
  }
268
- interface CompileAssetResourcesInput extends AssetCompilationOptions {
269
- rootDir: string;
270
- resources: readonly SourceResource[];
271
- /** Compilation-root-relative source paths keyed by `Type/name`. */
210
+ //#endregion
211
+ //#region src/compile/manifest.d.ts
212
+ interface ManifestSourceDescriptor extends TopikManifestSource {
213
+ /** Zero-based declaration index, used only for provenance and diagnostics. */
214
+ sourceIndex: number;
215
+ /** Canonical root-relative directory; empty for the project root. */
216
+ directory: string;
217
+ /** Project namespace declared in the manifest. */
218
+ namespace: string;
219
+ }
220
+ interface ManifestSourceProvenance extends ManifestSourceDescriptor {
221
+ /** Root-relative destination for new synced media. Compilation does not write here. */
222
+ assetDirectory: string;
223
+ /** Authored resource keys mapped to root-relative content/config paths. */
272
224
  sourcePathsByResource: Readonly<Record<string, string>>;
273
- /** Other consumed compiler inputs that cannot be owned as Asset bytes. */
274
- protectedSourcePaths?: readonly string[];
275
- }
276
- interface AssetPayload {
277
- path: AssetBlobUri;
278
- integrity: `sha256:${string}`;
279
- mediaType: string;
280
- size: number;
281
- bytes: Uint8Array;
282
- assetNames: readonly string[];
283
225
  }
284
- interface AssetCompilationResult {
285
- resources: CompiledResource[];
286
- payloads: AssetPayload[];
287
- semantic: TopikAssetSemanticRecordV1;
288
- materialization: TopikMaterializationRecordV1;
226
+ interface ManifestCompileResult extends CompileResult {
227
+ provenance: ManifestSourceProvenance[];
289
228
  }
290
- type CompiledResource = SourceResource | CompiledAsset;
291
- declare class AssetCompilationError extends Error {
292
- readonly diagnostics: readonly TopikAssetDiagnostic[];
293
- constructor(message: string, diagnostics?: readonly TopikAssetDiagnostic[]);
229
+ export declare class ManifestSourceError extends PublicCompileError {
230
+ readonly sourceIndex: number;
231
+ readonly kind?: TopikManifestSource["kind"];
232
+ constructor(id: PublicCompileErrorId, sourceIndex: number, kind?: TopikManifestSource["kind"], config?: string);
294
233
  }
295
- /** Discover and resolve one compilation-wide Asset set and deduplicated payload inventory. */
296
- declare function compileAssetResources(input: CompileAssetResourcesInput): Promise<AssetCompilationResult>;
234
+ /** Explicit loading requires the canonical file in exactly the supplied root. */
235
+ export declare function loadTopikManifest(dir: string): Promise<TopikManifest>;
236
+ export declare function discoverManifestSources(options: CompileOptions): Promise<ManifestSourceDescriptor[]>;
237
+ /** Compile only declared sources, sharing the existing local compiler and Asset pipeline. */
238
+ export declare function compileManifest(options: CompileOptions): Promise<ManifestCompileResult>;
297
239
  //#endregion
298
240
  //#region src/compile/shared.d.ts
299
241
  interface CompileResult {
242
+ courseNavigation: CourseNavigationIndex;
243
+ /** Present for manifest compilation, in declaration order. */
244
+ provenance?: ManifestSourceProvenance[];
300
245
  diagnostics: TopikContentDiagnostic[];
301
246
  resources: CompiledResource[];
302
247
  payloads: AssetPayload[];
303
248
  semantic: TopikAssetSemanticRecordV1;
304
249
  materialization: TopikMaterializationRecordV1;
250
+ /** Portable document references and their compilation-time validation state. */
251
+ references: CompiledResourceReference[];
305
252
  }
306
253
  type LinkValidationPolicy = "error" | "warning" | "off";
307
254
  interface CompileValidationOptions {
308
- /** How unresolved wiki page links and same-page guide fragments are handled. */
255
+ /** How unresolved document targets and invalid destination fragments are handled. */
309
256
  links?: LinkValidationPolicy;
310
257
  }
311
- declare class CompileError extends Error {
258
+ export declare class CompileError extends Error {
312
259
  readonly diagnostics: TopikContentDiagnostic[];
313
260
  constructor(diagnostics: TopikContentDiagnostic[]);
314
261
  }
315
- declare function isErrorDiagnostic(diagnostic: TopikContentDiagnostic): boolean;
262
+ export declare function isErrorDiagnostic(diagnostic: TopikContentDiagnostic): boolean;
263
+ //#endregion
264
+ //#region src/compile/links.d.ts
265
+ /** Optional application-provided catalogue; Topik never fetches targets. */
266
+ interface CompileResourceReferenceTarget {
267
+ type: TopikResourceReference["type"];
268
+ name: string;
269
+ /** Published heading IDs, when known. Without them a fragment remains deferred. */
270
+ headings?: readonly string[];
271
+ }
272
+ interface CompiledResourceReference {
273
+ resource: string;
274
+ sourcePath: string;
275
+ kind: "link" | "card";
276
+ position: string;
277
+ /** The original authored destination, retained for source round trips. */
278
+ href: string;
279
+ reference: TopikResourceReference;
280
+ status: "verified" | "deferred" | "invalid";
281
+ }
282
+ interface CompileResourceLinksInput {
283
+ rootDir: string;
284
+ resources: readonly SourceResource[];
285
+ sourcePathsByResource: Readonly<Record<string, string>>;
286
+ sourceDirectoriesByResource?: Readonly<Record<string, string>>;
287
+ referenceTargets?: readonly CompileResourceReferenceTarget[];
288
+ /** @internal Source round-trip comparison may already contain compiled Asset locators. */
289
+ allowCompiledAssetReferences?: boolean;
290
+ validation?: CompileValidationOptions;
291
+ }
292
+ /** Resolve document identity after all declared sources have been discovered, before Assets. */
293
+ export declare function compileResourceLinks(input: CompileResourceLinksInput): Promise<{
294
+ resources: SourceResource[];
295
+ diagnostics: TopikContentDiagnostic[];
296
+ references: CompiledResourceReference[];
297
+ }>;
316
298
  //#endregion
317
299
  //#region src/compile/guide.d.ts
318
300
  interface CompileGuidesOptions {
319
301
  dir: string;
302
+ /** Exact config path relative to dir; content is relative to the config directory. */
303
+ configFile?: string;
320
304
  validation?: CompileValidationOptions;
321
305
  assets?: AssetCompilationOptions;
306
+ referenceTargets?: readonly CompileResourceReferenceTarget[];
322
307
  }
323
- declare function compileGuides(options: CompileGuidesOptions): Promise<CompileResult>;
308
+ interface CompileResourceDiscovery {
309
+ courseNavigation?: CourseNavigationIndex;
310
+ sourceVersion?: 1;
311
+ /** Destination relative to the selected configuration directory, if a config was loaded. */
312
+ assetDirectory?: string;
313
+ diagnostics: CompileResult["diagnostics"];
314
+ resources: SourceResource[];
315
+ sourcePathsByResource: Record<string, string>;
316
+ consumedSourcePaths: string[];
317
+ }
318
+ export declare function compileGuides(options: CompileGuidesOptions): Promise<CompileResult>;
319
+ //#endregion
320
+ //#region src/compile/discovery.d.ts
321
+ interface DiscoverResourceOptions {
322
+ dir: string;
323
+ /** Exact config path relative to dir; content is relative to its directory. */
324
+ configFile?: string;
325
+ }
326
+ type SourceResourceDiscovery = CompileResourceDiscovery;
327
+ /** Read authoring metadata and paths before combining a caller-owned source inventory. */
328
+ export declare function discoverGuideResources(options: DiscoverResourceOptions): Promise<SourceResourceDiscovery>;
329
+ /** Read authoring metadata and paths before combining a caller-owned source inventory. */
330
+ export declare function discoverWikiResources(options: DiscoverResourceOptions): Promise<SourceResourceDiscovery>;
331
+ /** Read Course membership, metadata and paths without compiling links or Assets. */
332
+ export declare function discoverCourseResources(options: DiscoverResourceOptions): Promise<SourceResourceDiscovery>;
324
333
  //#endregion
325
334
  //#region src/compile/wiki.d.ts
326
335
  interface CompileWikiOptions {
327
336
  dir: string;
337
+ /** Exact config path relative to dir; content is relative to the config directory. */
338
+ configFile?: string;
328
339
  validation?: CompileValidationOptions;
329
340
  assets?: AssetCompilationOptions;
341
+ referenceTargets?: readonly CompileResourceReferenceTarget[];
330
342
  }
331
- declare function compileWiki(options: CompileWikiOptions): Promise<CompileResult>;
332
- declare function pagePathToName(wikiId: string, pagePath: string): string;
343
+ export declare function compileWiki(options: CompileWikiOptions): Promise<CompileResult>;
344
+ export declare function pagePathToName(wikiId: string, pagePath: string): string;
333
345
  //#endregion
334
- //#region src/compile/public-errors.d.ts
335
- declare const PUBLIC_COMPILE_ERROR_MESSAGES: {
336
- readonly "config-access-failed": "Configuration file could not be accessed.";
337
- readonly "config-invalid": "Configuration is invalid.";
338
- readonly "config-not-found": "Required configuration file was not found.";
339
- readonly "config-parse-failed": "Configuration file could not be parsed.";
340
- readonly "config-read-failed": "Configuration file could not be read safely.";
341
- readonly "file-not-regular": "Compilation input must be a regular file.";
342
- readonly "file-outside-compilation-root": "Compilation input resolves outside the source root.";
343
- readonly "frontmatter-invalid": "Document frontmatter is invalid.";
344
- readonly "reference-list-invalid": "Document resource references are invalid.";
345
- readonly "wiki-page-not-found": "A configured Wiki page file was not found.";
346
- };
347
- type PublicCompileErrorId = keyof typeof PUBLIC_COMPILE_ERROR_MESSAGES;
348
- declare function publicCompileErrorMessage(id: unknown): string | undefined;
349
- /** Public compiler failure with fixed wording, stable ID, and optional safe relative location. */
350
- declare class PublicCompileError extends Error {
351
- readonly id: PublicCompileErrorId;
352
- readonly location?: string;
353
- constructor(id: PublicCompileErrorId, location?: string);
346
+ //#region src/compile/course.d.ts
347
+ interface CompileCourseOptions {
348
+ dir: string;
349
+ /** Exact configuration path relative to dir; page sources are relative to its directory. */
350
+ configFile?: string;
351
+ validation?: CompileValidationOptions;
352
+ assets?: AssetCompilationOptions;
353
+ referenceTargets?: readonly CompileResourceReferenceTarget[];
354
354
  }
355
+ export declare function compileCourse(options: CompileCourseOptions): Promise<CompileResult>;
356
+ //#endregion
357
+ //#region src/compile/asset-names.d.ts
358
+ interface ProjectAssetNameOptions {
359
+ /** Directory containing the manifest, or an explicitly chosen root for standalone use. */
360
+ projectRoot: string;
361
+ projectNamespace: string;
362
+ }
363
+ /** Create the project's naming policy without reading or requiring a manifest. */
364
+ export declare function createProjectAssetNameGenerator(options: ProjectAssetNameOptions): AssetNameGenerator;
355
365
  //#endregion
356
366
  //#region src/compile/index.d.ts
357
367
  interface CompileOptions {
358
368
  dir: string;
359
369
  validation?: CompileValidationOptions;
360
- assets?: AssetCompilationOptions;
370
+ /** Optional application-supplied inventory for explicit resource references. */
371
+ referenceTargets?: readonly CompileResourceReferenceTarget[];
361
372
  }
362
- declare function compile(options: CompileOptions): Promise<CompileResult>;
373
+ /** Compile exactly the project declared by .topik.yaml in dir. */
374
+ export declare function compile(options: CompileOptions): Promise<CompileResult>;
363
375
  interface LintResult {
364
376
  diagnostics: CompileResult["diagnostics"];
365
377
  }
366
- declare function lint(options: CompileOptions): Promise<LintResult>;
378
+ export declare function lint(options: CompileOptions): Promise<LintResult>;
367
379
  //#endregion
368
380
  //#region src/validate.d.ts
369
381
  interface ValidationError {
@@ -377,72 +389,31 @@ interface ValidationResult {
377
389
  errors: ValidationError[];
378
390
  }
379
391
  /** Validate the resources produced by `compile` and the CLI export. */
380
- declare function validateResources(resources: readonly unknown[]): ValidationResult;
381
- //#endregion
382
- //#region src/wiki-navigation.d.ts
383
- type ResolvedWikiPage = {
384
- /** The compiled WikiPage resource name. */
385
- page: string;
386
- /** The page navigation node from the Wiki resource. */
387
- node: WikiPageNavNode;
388
- /** Public path without a leading slash. */
389
- route: string;
390
- /** Logical Markdown source path without an extension. */
391
- sourcePath: string;
392
- /** Internal navigation containers from outermost to innermost. */
393
- ancestors: readonly WikiNavContainerNode[];
394
- };
395
- type ResolvedWikiNavigation = {
396
- pages: readonly ResolvedWikiPage[];
397
- pageByName: ReadonlyMap<string, ResolvedWikiPage>;
398
- pageByRoute: ReadonlyMap<string, ResolvedWikiPage>;
399
- };
400
- type ResolvedWikiContentLink = {
401
- page: ResolvedWikiPage;
402
- route: string;
403
- hash: string;
404
- };
405
- /** Returns true for tab, dropdown, and group nodes containing navigation children. */
406
- declare function hasWikiNavChildren(node: WikiNavNode): node is WikiNavContainerNode;
407
- declare function isInternalWikiTab(node: WikiNavNode): node is WikiInternalTabNavNode;
408
- declare function isExternalWikiTab(node: WikiNavNode): node is WikiExternalTabNavNode;
409
- declare function isInternalWikiDropdown(node: WikiNavNode): node is WikiInternalDropdownNavNode;
410
- declare function isExternalWikiDropdown(node: WikiNavNode): node is WikiExternalDropdownNavNode;
411
- /** Resolves page routes, source paths, and navigation ancestry from a compiled Wiki tree. */
412
- declare function resolveWikiNavigation(navigation: WikiNavigation | readonly WikiNavNode[]): ResolvedWikiNavigation;
413
- /** Finds the first page node in navigation order, ignoring external destinations. */
414
- declare function findFirstWikiPage(navigation: WikiNavigation | readonly WikiNavNode[]): WikiPageNavNode | null;
415
- /** Returns the internal containers owning a page, or an empty array for an unknown page. */
416
- declare function findWikiPageAncestors(resolved: ResolvedWikiNavigation, pageName: string): readonly WikiNavContainerNode[];
417
- /** Resolves an internal Markdown link against the logical source path of its current page. */
418
- declare function resolveWikiContentHref(href: string, currentPageName: string, resolved: ResolvedWikiNavigation): ResolvedWikiContentLink | null;
419
- declare function joinWikiPath(prefix: string, slug?: string): string;
420
- type InternalWikiTab = WikiInternalTabNavNode;
421
- type ExternalWikiTab = WikiExternalTabNavNode;
422
- type InternalWikiDropdown = WikiInternalDropdownNavNode;
423
- type ExternalWikiDropdown = WikiExternalDropdownNavNode;
424
- type WikiSwitcherNode = WikiTabNavNode | WikiDropdownNavNode;
392
+ export declare function validateResources(resources: readonly unknown[]): ValidationResult;
425
393
  //#endregion
426
394
  //#region src/watch.d.ts
427
395
  interface WatchOptions {
428
396
  dir: string;
429
397
  signal?: AbortSignal;
430
- assets?: AssetCompilationOptions;
431
398
  }
432
399
  type UpdateListener = (key: string, resource: Resource) => void;
433
400
  type ErrorListener = (error: Error) => void;
401
+ type PreviewStateListener = (state: PreviewState) => void;
434
402
  interface Watcher {
435
- /** Current compiled resources, keyed by `Type/name`. */
403
+ /** Compatibility inventory; replaced completely before any success notification. */
436
404
  resources: Map<string, Resource>;
437
- /** Current deduplicated local payloads, keyed by compilation-relative output path. */
438
405
  payloads: Map<string, AssetPayload>;
406
+ /** Immutable, complete authoritative state. Treat resources/order/payloads as one commit. */
407
+ readonly state: PreviewState;
408
+ on(event: "preview-state", listener: PreviewStateListener): this;
439
409
  on(event: "update", listener: UpdateListener): this;
440
410
  on(event: "error", listener: ErrorListener): this;
411
+ off(event: "preview-state", listener: PreviewStateListener): this;
441
412
  off(event: "update", listener: UpdateListener): this;
442
413
  off(event: "error", listener: ErrorListener): this;
443
414
  close(): Promise<void>;
444
415
  }
445
- declare function watch(options: WatchOptions): Promise<Watcher>;
416
+ export declare function watch(options: WatchOptions): Promise<Watcher>;
446
417
  //#endregion
447
418
  //#region src/assets/path.d.ts
448
419
  interface ValidateTopikPathOptions {
@@ -458,22 +429,22 @@ interface ValidTopikPath {
458
429
  collisionKey: string;
459
430
  utf8Bytes: number;
460
431
  }
461
- declare function validateTopikPath(input: string | Uint8Array, options?: ValidateTopikPathOptions): TopikAssetResult<ValidTopikPath>;
462
- declare function computeTopikPathCollisionKey(path: string, options?: ValidateTopikPathOptions): TopikAssetResult<string>;
463
- declare function validateTopikPathSet(paths: readonly string[], options?: ValidateTopikPathOptions): TopikAssetResult<Map<string, string>>;
432
+ export declare function validateTopikPath(input: string | Uint8Array, options?: ValidateTopikPathOptions): TopikAssetResult<ValidTopikPath>;
433
+ export declare function computeTopikPathCollisionKey(path: string, options?: ValidateTopikPathOptions): TopikAssetResult<string>;
434
+ export declare function validateTopikPathSet(paths: readonly string[], options?: ValidateTopikPathOptions): TopikAssetResult<Map<string, string>>;
464
435
  /** Unicode 17 NFKC casefold for topik-path-v1-admitted input. */
465
- declare function toNfkcCasefold(value: string): string;
436
+ export declare function toNfkcCasefold(value: string): string;
466
437
  //#endregion
467
438
  //#region src/assets/json.d.ts
468
- declare class TopikJsonSyntaxError extends SyntaxError {
439
+ export declare class TopikJsonSyntaxError extends SyntaxError {
469
440
  readonly offset: number;
470
441
  readonly duplicatePointer?: string | undefined;
471
442
  constructor(message: string, offset: number, duplicatePointer?: string | undefined);
472
443
  }
473
- declare function parseStrictTopikJson(source: string, maxDepth?: number): unknown;
444
+ export declare function parseStrictTopikJson(source: string, maxDepth?: number): unknown;
474
445
  /** RFC 8785 scalar/member rules with Topik's two-space layout and final LF. */
475
- declare function serializeTopikJson(value: unknown): string;
476
- declare function topikJsonDescriptor(): {
446
+ export declare function serializeTopikJson(value: unknown): string;
447
+ export declare function topikJsonDescriptor(): {
477
448
  id: typeof TOPIK_JSON_VERSION;
478
449
  };
479
450
  //#endregion
@@ -491,21 +462,297 @@ interface PortableAssetFileDescriptor {
491
462
  contentFilter?: string;
492
463
  workingTreeEncoding?: string;
493
464
  }
494
- declare function validatePortableAssetFile(file: PortableAssetFileDescriptor): TopikAssetResult<PortableAssetFileDescriptor>;
495
- declare function validatePortableAssetTree(files: readonly PortableAssetFileDescriptor[]): TopikAssetResult<readonly PortableAssetFileDescriptor[]>;
465
+ export declare function validatePortableAssetFile(file: PortableAssetFileDescriptor): TopikAssetResult<PortableAssetFileDescriptor>;
466
+ export declare function validatePortableAssetTree(files: readonly PortableAssetFileDescriptor[]): TopikAssetResult<readonly PortableAssetFileDescriptor[]>;
496
467
  interface ReadPortableAssetFileOptions {
497
468
  root: string;
498
469
  path: string;
470
+ /** Optional tighter read limit; cannot exceed the portable asset maximum. */
471
+ maxBytes?: number;
499
472
  }
500
473
  /** Filesystem reader using no-follow traversal and stable same-handle identity checks. */
501
- declare function readPortableAssetFile(options: ReadPortableAssetFileOptions): Promise<TopikAssetResult<PortableAssetFileDescriptor>>;
502
- declare function looksLikeGitLfsPointer(bytes: Uint8Array): boolean;
474
+ export declare function readPortableAssetFile(options: ReadPortableAssetFileOptions): Promise<TopikAssetResult<PortableAssetFileDescriptor>>;
475
+ export declare function looksLikeGitLfsPointer(bytes: Uint8Array): boolean;
503
476
  //#endregion
504
477
  //#region src/assets/media.d.ts
505
- declare const TOPIK_UNRESOLVED_ACTIVE_CONTENT_TYPE: "application/x-topik-active-content";
478
+ export declare const TOPIK_UNRESOLVED_ACTIVE_CONTENT_TYPE: "application/x-topik-active-content";
506
479
  /** Sniff exact bytes conservatively. Unknown safe bytes remain opaque downloads. */
507
- declare function sniffPortableMediaType(bytes: Uint8Array): string;
508
- declare function isTopikActiveMediaType(mediaType: string): boolean;
509
- declare function isInlineMediaCompatible(mediaType: string, role: string): boolean;
480
+ export declare function sniffPortableMediaType(bytes: Uint8Array): string;
481
+ export declare function isTopikActiveMediaType(mediaType: string): boolean;
482
+ export declare function isInlineMediaCompatible(mediaType: string, role: string): boolean;
483
+ //#endregion
484
+ //#region src/source/syntax.d.ts
485
+ interface SourceByteRange {
486
+ start: number;
487
+ end: number;
488
+ }
489
+ interface SourceFieldEvidence {
490
+ selector: string;
491
+ value?: SourceByteRange;
492
+ entry?: SourceByteRange;
493
+ insertion: number;
494
+ }
495
+ interface SourceByteEdit extends SourceByteRange {
496
+ selector: string;
497
+ oldSha256: string;
498
+ replacement: Uint8Array;
499
+ }
500
+ //#endregion
501
+ //#region src/source/project.d.ts
502
+ export declare const SOURCE_WRITER_VERSION: "topik-source-writer-v1";
503
+ export declare const SOURCE_PROJECT_LIMITS: {
504
+ readonly maxFiles: 10000;
505
+ readonly maxFileBytes: 268435456;
506
+ readonly maxTreeBytes: 536870912;
507
+ };
508
+ export declare const SOURCE_WRITER_DESCRIPTOR: {
509
+ readonly writer: "topik-source-writer-v1";
510
+ readonly manifest: 1;
511
+ readonly sourceVersions: readonly [0, 1];
512
+ readonly formatter: 1;
513
+ readonly contentSchema: "0.2.2";
514
+ readonly resourceSchema: "v1";
515
+ readonly references: "source-links-v5";
516
+ readonly provenance: 7;
517
+ readonly graph: "authored-resource-bytes-v1";
518
+ readonly packageVersion: string;
519
+ };
520
+ interface SourceTreeFile {
521
+ path: string;
522
+ mode: "100644" | "100755";
523
+ bytes: Uint8Array;
524
+ }
525
+ interface SourceDocumentProvenance {
526
+ resource: string;
527
+ apiVersion: Resource["apiVersion"];
528
+ type: Resource["type"];
529
+ name: string;
530
+ path: string;
531
+ config: string;
532
+ kind: ManifestSourceProvenance["kind"];
533
+ directory: string;
534
+ sourceVersion?: 1;
535
+ sha256: string;
536
+ mode: SourceTreeFile["mode"];
537
+ body?: SourceByteRange;
538
+ frontmatter?: SourceByteRange;
539
+ fields: readonly SourceFieldEvidence[];
540
+ fieldOrigins: readonly SourceFieldOrigin[];
541
+ /** Recognized legacy metadata whose compiled value would lose authored meaning. */
542
+ lossyMetadata?: readonly string[];
543
+ /** Context travels with immutable saved source; a later source move must not reinterpret it. */
544
+ sourceContext: {
545
+ path: string;
546
+ extension: string;
547
+ /** Key in SourceProject.wikiContexts; retain that snapshot with saved content. */
548
+ wiki?: string;
549
+ /** Key in SourceProject.courseContexts for a Course page's immutable saved links. */
550
+ course?: string;
551
+ };
552
+ references: readonly (TopikNavigationReference & {
553
+ target?: string;
554
+ search?: string;
555
+ hash?: string;
556
+ })[];
557
+ /** Complete derived Asset identity closure for this compiled resource. */
558
+ assetReferences: readonly string[];
559
+ }
560
+ interface SourceFieldOrigin {
561
+ field: string;
562
+ origin: "explicit" | "derived" | "inherited" | "default";
563
+ path?: string;
564
+ selector?: string;
565
+ range?: SourceByteRange;
566
+ }
567
+ interface SourceConfigurationProvenance {
568
+ path: string;
569
+ sha256: string;
570
+ mode: SourceTreeFile["mode"];
571
+ fields: readonly SourceFieldEvidence[];
572
+ insertion: number;
573
+ }
574
+ interface SourceProject {
575
+ tree: readonly SourceTreeFile[];
576
+ treeDigest: string;
577
+ manifest: TopikManifest;
578
+ manifestSha256: string;
579
+ compilation: ManifestCompileResult;
580
+ documents: readonly SourceDocumentProvenance[];
581
+ configurations: readonly SourceConfigurationProvenance[];
582
+ wikiContexts: Readonly<Record<string, Wiki>>;
583
+ courseContexts: Readonly<Record<string, CourseReferenceContext>>;
584
+ descriptor: typeof SOURCE_WRITER_DESCRIPTOR;
585
+ }
586
+ export declare function digestSourceTree(tree: readonly SourceTreeFile[]): string;
587
+ /** Seal the exact desired authoring graph without parsing or formatting its content. */
588
+ export declare function digestSourceResourceGraph(resources: readonly Resource[]): string;
589
+ /** Inspection compiles exactly the manifest tree and retains original documents and byte ranges. */
590
+ export declare function readSourceProject(input: {
591
+ tree: readonly SourceTreeFile[];
592
+ }): Promise<SourceProject>;
593
+ //#endregion
594
+ //#region src/source/asset-context.d.ts
595
+ type SourceAssetReferenceContexts = Readonly<Record<string, Readonly<Record<string, string>>>>;
596
+ //#endregion
597
+ //#region src/source/initialize.d.ts
598
+ interface SourceInitializationIntent {
599
+ namespace: string;
600
+ source: TopikManifestSource & {
601
+ id: string;
602
+ title: string;
603
+ assetDirectory?: string;
604
+ };
605
+ }
606
+ interface SourceMediaSelection {
607
+ name: string;
608
+ filename: string;
609
+ sha256: string;
610
+ bytes: Uint8Array;
611
+ }
612
+ interface InitializeSourceProjectInput {
613
+ /** Full occupied-path inventory; missing/invalid manifests are never admitted as empty projects. */
614
+ tree: readonly SourceTreeFile[];
615
+ expectedTreeDigest: string;
616
+ packageCohort: string;
617
+ /** This explicit reviewed intent is sealed by the application before planning. */
618
+ intent: SourceInitializationIntent;
619
+ resources: readonly Resource[];
620
+ media?: readonly SourceMediaSelection[];
621
+ /** Immutable Wiki context retained with each saved page body. */
622
+ referenceContexts?: Readonly<Record<string, Wiki>>;
623
+ courseReferenceContexts?: Readonly<Record<string, CourseReferenceContext>>;
624
+ /** Explicit new Guide or CoursePage file paths, independently admitted in createPaths. */
625
+ documentPaths?: Readonly<Record<string, string>>;
626
+ assetReferenceContexts?: SourceAssetReferenceContexts;
627
+ /** Exact expected-absence paths admitted from the complete inventory. */
628
+ createPaths: readonly string[];
629
+ }
630
+ /** Initialization is distinct from adding a source to a valid existing manifest. */
631
+ export declare function initializeSourceProject(input: InitializeSourceProjectInput): Promise<SourcePlanResult>;
632
+ interface AddSourceToProjectInput {
633
+ project: SourceProject;
634
+ expectedTreeDigest: string;
635
+ packageCohort: string;
636
+ source: SourceInitializationIntent["source"];
637
+ resources: readonly Resource[];
638
+ media?: readonly SourceMediaSelection[];
639
+ referenceContexts?: Readonly<Record<string, Wiki>>;
640
+ courseReferenceContexts?: Readonly<Record<string, CourseReferenceContext>>;
641
+ documentPaths?: Readonly<Record<string, string>>;
642
+ assetReferenceContexts?: SourceAssetReferenceContexts;
643
+ createPaths: readonly string[];
644
+ manifestAuthority: SourceSharedAuthority;
645
+ }
646
+ /** Adding a declaration preserves the existing namespace, order and every original source. */
647
+ export declare function addSourceToProject(input: AddSourceToProjectInput): Promise<SourcePlanResult>;
648
+ //#endregion
649
+ //#region src/source/diagnostics.d.ts
650
+ interface SourcePlanDiagnostic {
651
+ code: string;
652
+ message: string;
653
+ resource?: string;
654
+ path?: string;
655
+ /** One-based lines in the compiled document body, excluding frontmatter. */
656
+ lines?: readonly number[];
657
+ sourceIndex?: number;
658
+ kind?: "wiki" | "collection" | "course";
659
+ config?: string;
660
+ }
661
+ //#endregion
662
+ //#region src/source/plan.d.ts
663
+ type SourceResourceOperation = {
664
+ kind: "update" | "delete";
665
+ resource: string;
666
+ } | {
667
+ kind: "move";
668
+ resource: string;
669
+ path: string;
670
+ } | {
671
+ kind: "create";
672
+ resource: string;
673
+ config: string;
674
+ path?: string;
675
+ };
676
+ interface SourceExclusiveAuthority {
677
+ path: string;
678
+ sha256: string;
679
+ mode: SourceTreeFile["mode"];
680
+ }
681
+ interface SourceSharedAuthority extends SourceExclusiveAuthority {
682
+ fields: readonly SourceFieldEvidence[];
683
+ }
684
+ interface SourceWriteAuthority {
685
+ /** Resources whose authored or shared referenced facts may change, admitted independently. */
686
+ resources: readonly string[];
687
+ exclusive: readonly SourceExclusiveAuthority[];
688
+ shared: readonly SourceSharedAuthority[];
689
+ create: readonly string[];
690
+ }
691
+ interface SourceFileChange {
692
+ kind: "create" | "update" | "delete";
693
+ path: string;
694
+ base: {
695
+ sha256: string;
696
+ mode: SourceTreeFile["mode"];
697
+ } | null;
698
+ candidate: {
699
+ sha256: string;
700
+ mode: SourceTreeFile["mode"];
701
+ bytes: Uint8Array;
702
+ } | null;
703
+ sharedEdits?: readonly SourceByteEdit[];
704
+ }
705
+ interface SourceUpdatePlan {
706
+ assetMappings: readonly {
707
+ from: string;
708
+ to: string;
709
+ path: string;
710
+ }[];
711
+ descriptor: typeof SOURCE_WRITER_DESCRIPTOR;
712
+ packageCohort: string;
713
+ baseTreeDigest: string;
714
+ desiredGraphDigest: string;
715
+ candidateTreeDigest: string;
716
+ planDigest: string;
717
+ changes: readonly SourceFileChange[];
718
+ candidate: SourceProject;
719
+ affectedResources: readonly string[];
720
+ derivedRepairs: readonly {
721
+ resource: string;
722
+ kind: "navigation" | "reference";
723
+ position?: string;
724
+ before?: string;
725
+ after?: string;
726
+ target?: string;
727
+ }[];
728
+ }
729
+ type SourcePlanResult = {
730
+ ok: true;
731
+ plan: SourceUpdatePlan;
732
+ } | {
733
+ ok: false;
734
+ diagnostics: readonly SourcePlanDiagnostic[];
735
+ };
736
+ interface PlanSourceUpdatesInput {
737
+ project: SourceProject;
738
+ expectedTreeDigest: string;
739
+ packageCohort: string;
740
+ /** Complete project graph, including untouched declarations and derived Assets. */
741
+ desiredResources: readonly Resource[];
742
+ operations: readonly SourceResourceOperation[];
743
+ authority: SourceWriteAuthority;
744
+ /** Explicit reviewed opt-in; reserved legacy keys still block it. */
745
+ optInConfigs?: readonly string[];
746
+ /** Retained portable context of saved authoring content, before previous source repairs. */
747
+ referenceContexts?: Readonly<Record<string, Wiki>>;
748
+ /** Retained Course route/source snapshots keyed by CoursePage identity. */
749
+ courseReferenceContexts?: Readonly<Record<string, CourseReferenceContext>>;
750
+ assetReferenceContexts?: SourceAssetReferenceContexts;
751
+ media?: readonly (SourceMediaSelection & {
752
+ config: string;
753
+ })[];
754
+ }
755
+ /** The complete candidate is compiled before any applicable file changes are returned. */
756
+ export declare function planSourceUpdates(input: PlanSourceUpdatesInput): Promise<SourcePlanResult>;
510
757
  //#endregion
511
- export { ASSET_API_VERSION, ASSET_SCHEMA_ID, ASSET_TYPE, type AssetBlobUri, AssetCompilationError, type AssetCompilationOptions, type AssetCompilationResult, type AssetPayload, type CollectionConfig, type CompileAssetResourcesInput, CompileError, type CompileGuidesOptions, type CompileOptions, type CompileResult, type CompileValidationOptions, type CompileWikiOptions, type CompiledAsset, type CompiledResource, type ContentBearingResource, type ExternalWikiDropdown, type ExternalWikiTab, type GenerateAutomaticAssetNameOptions, type GeneratedAssetName, type InternalWikiDropdown, type InternalWikiTab, type LinkValidationPolicy, type LintResult, type ParsedAsset, type PortableAssetFileDescriptor, type PortableAssetFileType, PublicCompileError, type PublicCompileErrorId, type ReadPortableAssetFileOptions, type ResolvedWikiContentLink, type ResolvedWikiNavigation, type ResolvedWikiPage, type Resource, type ResourceType, type SourceResource, TOPIK_ASSET_CORRELATION_ID_PATTERN, TOPIK_ASSET_DEFAULT_CORRELATION_ID, TOPIK_ASSET_DIAGNOSTIC_IDS, TOPIK_ASSET_LIMITS, TOPIK_ASSET_NAME_VERSION, TOPIK_ASSET_REFERENCE_VERSION, TOPIK_BLOB_OUTPUT_PREFIX, TOPIK_JSON_VERSION, TOPIK_MATERIALIZATION_VERSION, TOPIK_PATH_V1_DESCRIPTOR, TOPIK_PATH_VERSION, TOPIK_UNRESOLVED_ACTIVE_CONTENT_TYPE, type TopikAssetCorrelationId, type TopikAssetDiagnostic, type TopikAssetDiagnosticId, type TopikAssetDiagnosticLocation, type TopikAssetPathDiagnosticReason, type TopikAssetRecoveryCategory, type TopikAssetReferenceMappingV1, type TopikAssetResult, type TopikAssetSemanticRecordV1, TopikJsonSyntaxError, type TopikMaterializationPayloadInput, type TopikMaterializationPayloadV1, type TopikMaterializationRecordV1, type TopikMaterializationResourceInput, type TopikMaterializationResourceV1, type ValidTopikPath, type ValidateTopikPathOptions, type ValidationError, type ValidationResult, type WatchOptions, type Watcher, type WikiConfig, type WikiSwitcherNode, compareTopikAssetIdentities, compile, compileAssetResources, compileGuides, compileWiki, computeTopikPathCollisionKey, correlateTopikAssetResult, createTopikAssetSemanticRecord, createTopikMaterializationRecord, digestTopikAssetSemanticRecord, digestTopikMaterializationRecord, findFirstWikiPage, findWikiPageAncestors, generateAutomaticAssetName, hasWikiNavChildren, isAssetBlobUri, isErrorDiagnostic, isExternalWikiDropdown, isExternalWikiTab, isGeneratedAssetName, isInlineMediaCompatible, isInternalWikiDropdown, isInternalWikiTab, isTopikActiveMediaType, joinWikiPath, lint, looksLikeGitLfsPointer, pagePathToName, parseAsset, parseAssetBlobUri, parseCollectionConfig, parseGeneratedAssetName, parseStrictTopikJson, parseWikiConfig, publicCompileErrorMessage, readPortableAssetFile, resolveWikiContentHref, resolveWikiNavigation, serializeAsset, serializeTopikJson, sniffPortableMediaType, toNfkcCasefold, topikAssetNameDescriptor, topikJsonDescriptor, validateAssetBlobUri, validateAssetValue, validatePortableAssetFile, validatePortableAssetTree, validateResources, validateStableSourceNamespace, validateTopikMaterializationRecord, validateTopikPath, validateTopikPathSet, watch };
758
+ export { ASSET_API_VERSION, ASSET_SCHEMA_ID, ASSET_TYPE, type AddSourceToProjectInput, type AssetBlobUri, AssetCompilationError, type AssetCompilationOptions, type AssetCompilationResult, type AssetNameGenerator, type AssetNameInput, type AssetPayload, type CollectionConfig, type CompileAssetResourcesInput, type CompileCourseOptions, type CompileGuidesOptions, type CompileOptions, type CompileResourceLinksInput, type CompileResourceReferenceTarget, type CompileResult, type CompileValidationOptions, type CompileWikiOptions, type CompiledAsset, type CompiledResource, type CompiledResourceReference, type ContentBearingResource, type CourseConfig, type CourseModuleConfig, CourseNavigationIndex, CourseNavigationModule, type CourseReferenceContext, type DiscoverResourceOptions, type ExternalWikiDropdown, type ExternalWikiTab, type GenerateAutomaticAssetNameOptions, type GeneratedAssetName, type InitializeSourceProjectInput, type InternalWikiDropdown, type InternalWikiTab, type LinkValidationPolicy, type LintResult, type ManifestCompileResult, type ManifestSourceDescriptor, type ManifestSourceProvenance, type ParsedAsset, type PlanSourceUpdatesInput, type PortableAssetFileDescriptor, type PortableAssetFileType, PreviewDiagnostic, PreviewPayloadDescriptor, PreviewState, type ProjectAssetNameOptions, type PublicCompileErrorId, type ReadPortableAssetFileOptions, type ResolvedCourseContentLink, type ResolvedCourseContentReference, type ResolvedCourseNavigation, type ResolvedCoursePage, type ResolvedWikiContentLink, type ResolvedWikiContentReference, type ResolvedWikiNavigation, type ResolvedWikiPage, type Resource, type ResourceType, type SourceAssetsConfig, type SourceByteEdit, type SourceByteRange, type SourceConfigurationProvenance, type SourceDocumentProvenance, type SourceExclusiveAuthority, type SourceFieldEvidence, type SourceFieldOrigin, type SourceFileChange, type SourceInitializationIntent, type SourceMediaSelection, type SourcePlanDiagnostic, type SourcePlanResult, type SourceProject, type SourceResource, type SourceResourceDiscovery, type SourceResourceOperation, type SourceSharedAuthority, type SourceTreeFile, type SourceUpdatePlan, type SourceWriteAuthority, TOPIK_ASSET_CORRELATION_ID_PATTERN, TOPIK_ASSET_DEFAULT_CORRELATION_ID, TOPIK_ASSET_DIAGNOSTIC_IDS, TOPIK_ASSET_LIMITS, TOPIK_ASSET_NAME_VERSION, TOPIK_ASSET_REFERENCE_VERSION, TOPIK_BLOB_OUTPUT_PREFIX, TOPIK_JSON_VERSION, TOPIK_MATERIALIZATION_VERSION, TOPIK_PATH_V1_DESCRIPTOR, TOPIK_PATH_VERSION, TOPIK_PREVIEW_PROTOCOL, type TopikAssetCorrelationId, type TopikAssetDiagnostic, type TopikAssetDiagnosticId, type TopikAssetDiagnosticLocation, type TopikAssetPathDiagnosticReason, type TopikAssetRecoveryCategory, type TopikAssetReferenceMappingV1, type TopikAssetResult, type TopikAssetSemanticRecordV1, type TopikManifest, type TopikManifestSource, type TopikMaterializationPayloadInput, type TopikMaterializationPayloadV1, type TopikMaterializationRecordV1, type TopikMaterializationResourceInput, type TopikMaterializationResourceV1, type ValidTopikPath, type ValidateTopikPathOptions, type ValidationError, type ValidationResult, type WatchOptions, type Watcher, type WikiConfig, type WikiSwitcherNode, compareTopikAssetIdentities, compileAssetResources, correlateTopikAssetResult, createTopikAssetSemanticRecord, createTopikMaterializationRecord, digestTopikAssetSemanticRecord, digestTopikMaterializationRecord, findFirstWikiPage, findWikiPageAncestors, generateAutomaticAssetName, hasWikiNavChildren, isAssetBlobUri, isExternalWikiDropdown, isExternalWikiTab, isGeneratedAssetName, isInternalWikiDropdown, isInternalWikiTab, joinWikiPath, parseAsset, parseAssetBlobUri, parseGeneratedAssetName, resolveCourseContentHref, resolveCourseContentReference, resolveCourseNavigation, resolveWikiContentHref, resolveWikiContentReference, resolveWikiNavigation, serializeAsset, topikAssetNameDescriptor, validateAssetBlobUri, validateAssetValue, validateProjectNamespace, validateTopikMaterializationRecord };