@nuasite/cms-core 0.53.0 → 0.55.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 (42) hide show
  1. package/dist/types/asset-paths.d.ts +28 -0
  2. package/dist/types/asset-paths.d.ts.map +1 -0
  3. package/dist/types/check-entries.d.ts +50 -0
  4. package/dist/types/check-entries.d.ts.map +1 -0
  5. package/dist/types/check-live.d.ts +25 -0
  6. package/dist/types/check-live.d.ts.map +1 -0
  7. package/dist/types/check-shape.d.ts +28 -0
  8. package/dist/types/check-shape.d.ts.map +1 -0
  9. package/dist/types/check-write.d.ts +35 -0
  10. package/dist/types/check-write.d.ts.map +1 -0
  11. package/dist/types/check.d.ts +18 -1
  12. package/dist/types/check.d.ts.map +1 -1
  13. package/dist/types/collection-scanner.d.ts.map +1 -1
  14. package/dist/types/content-config-ast.d.ts +7 -1
  15. package/dist/types/content-config-ast.d.ts.map +1 -1
  16. package/dist/types/editor-write-model.d.ts +48 -0
  17. package/dist/types/editor-write-model.d.ts.map +1 -0
  18. package/dist/types/handlers/entry-ops.d.ts.map +1 -1
  19. package/dist/types/index.d.ts +10 -2
  20. package/dist/types/index.d.ts.map +1 -1
  21. package/dist/types/schema-port.d.ts +43 -0
  22. package/dist/types/schema-port.d.ts.map +1 -0
  23. package/dist/types/schema-probe.d.ts +53 -0
  24. package/dist/types/schema-probe.d.ts.map +1 -0
  25. package/dist/types/shared.d.ts +34 -10
  26. package/dist/types/shared.d.ts.map +1 -1
  27. package/dist/types/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +7 -2
  29. package/src/asset-paths.ts +54 -0
  30. package/src/check-entries.ts +120 -0
  31. package/src/check-live.ts +61 -0
  32. package/src/check-shape.ts +137 -0
  33. package/src/check-write.ts +280 -0
  34. package/src/check.ts +192 -62
  35. package/src/collection-scanner.ts +14 -0
  36. package/src/content-config-ast.ts +301 -18
  37. package/src/editor-write-model.ts +82 -0
  38. package/src/handlers/entry-ops.ts +153 -73
  39. package/src/index.ts +41 -2
  40. package/src/schema-port.ts +46 -0
  41. package/src/schema-probe.ts +133 -0
  42. package/src/shared.ts +60 -18
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Where an asset value in frontmatter points on disk.
3
+ *
4
+ * Extracted from the entry read path so the content check resolves an image the
5
+ * same way serving it does — two implementations would disagree the moment one
6
+ * of the shapes below changes, and the check would then report missing files
7
+ * that the CMS happily serves.
8
+ */
9
+ /** The directory a relative asset value in `file`'s frontmatter resolves against. */
10
+ export declare function assetBaseDir(file: string): string;
11
+ /** Join `rel` onto `base` segments, applying `.`/`..`; `null` on traversal above root. */
12
+ export declare function normalizeSegments(base: string[], rel: string): string | null;
13
+ /**
14
+ * Resolve a stored asset value (as it appears in frontmatter) to candidate on-disk
15
+ * paths, root-relative, in priority order. Handles the shapes that actually occur:
16
+ *
17
+ * - **Leading `/`** — a runtime URL (`/assets/x.jpeg`, `/uploads/x.webp`). Astro
18
+ * serves the `public/` dir at the site root, so try `public/<path>` first, then
19
+ * `<path>` from the project root (assets kept outside `public/`). `baseDir` is
20
+ * irrelevant, so these resolve without an owning entry.
21
+ * - **Relative** (`../../src/assets/x.webp`, `./x.png`, `x.png`) — an Astro
22
+ * `image()` value, resolved against `baseDir` (the entry's directory), honoring
23
+ * `.`/`..`.
24
+ *
25
+ * Returns `[]` when the path climbs above the project root, or is relative with no `baseDir`.
26
+ */
27
+ export declare function resolveAssetCandidates(baseDir: string | undefined, rel: string): string[];
28
+ //# sourceMappingURL=asset-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-paths.d.ts","sourceRoot":"","sources":["../../src/asset-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY5E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CASzF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Read every declared collection off disk once.
3
+ *
4
+ * Split out of `check.ts` because more than one checker needs the same material: the
5
+ * type/reference rules there, and the live-schema rules that re-parse each entry against
6
+ * the project's real Zod schema. Loading twice would double the I/O on a 1.5k-entry site
7
+ * and let the two disagree about which files even belong to a collection.
8
+ */
9
+ import type { ParsedConfig } from './content-config-ast';
10
+ import type { CollectionKind } from './editor-write-model';
11
+ import type { CmsFileSystem } from './fs/types';
12
+ export interface LoadedEntry {
13
+ /** Root-relative path of the source file. */
14
+ file: string;
15
+ /** The id Astro's `glob()` loader derives from the file, and therefore what a `reference()` must hold. */
16
+ stem: string;
17
+ /** Parsed frontmatter, or `undefined` when it did not parse. */
18
+ frontmatter?: Record<string, unknown>;
19
+ /** First line of the parse failure, set when `frontmatter` is absent. */
20
+ parseError?: string;
21
+ }
22
+ export interface LoadedCollection {
23
+ name: string;
24
+ /** Normalized, root-relative loader base. */
25
+ base: string;
26
+ /** False when the loader base directory is not there at all. */
27
+ exists: boolean;
28
+ entries: LoadedEntry[];
29
+ }
30
+ export type LoadedCollections = Map<string, LoadedCollection>;
31
+ /** `./content/articles` and `content/articles/` both mean the same directory. */
32
+ export declare const normalizeBase: (base: string) => string;
33
+ /** The id Astro's `glob()` loader derives from a file, and therefore what a `reference()` must hold. */
34
+ export declare const entryStem: (file: string) => string;
35
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
36
+ export declare function parseEntry(file: string, raw: string): {
37
+ frontmatter: Record<string, unknown>;
38
+ } | {
39
+ error: string;
40
+ };
41
+ /**
42
+ * Whether a collection holds markdown entries or plain data files.
43
+ *
44
+ * Decides what a create writes, so it reads the entries on disk first and only falls back to
45
+ * the loader pattern for a collection that has none yet.
46
+ */
47
+ export declare function collectionKind(collection: LoadedCollection, loaderPattern: string | undefined): CollectionKind;
48
+ /** Every declared collection's files, read and parsed. Reports nothing — the callers judge. */
49
+ export declare function loadCollections(fs: CmsFileSystem, config: ParsedConfig): Promise<LoadedCollections>;
50
+ //# sourceMappingURL=check-entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-entries.d.ts","sourceRoot":"","sources":["../../src/check-entries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,MAAM,WAAW,WAAW;IAC3B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAA;IACZ,0GAA0G;IAC1G,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,WAAW,EAAE,CAAA;CACtB;AAED,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAI7D,iFAAiF;AACjF,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAAuE,CAAA;AAEpH,wGAAwG;AACxG,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAAmE,CAAA;AAE5G,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9E;AAQD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAwBlH;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,CAI9G;AAED,+FAA+F;AAC/F,wBAAsB,eAAe,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyBzG"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Validate what is on disk against the project's real collection schemas.
3
+ *
4
+ * The AST rules in `check.ts` only type-check fields the content config types explicitly,
5
+ * and deliberately stay silent on a plain `z.string()`. A live schema has no such blind
6
+ * spot: it carries refinements, unions, `.min()`, coercions — everything the build will
7
+ * actually apply. This is the same verdict `astro sync` would give, without the build.
8
+ */
9
+ import type { CheckFinding } from './check';
10
+ import type { LoadedCollections } from './check-entries';
11
+ import type { ParsedConfig } from './content-config-ast';
12
+ import { type LiveSchemas } from './schema-port';
13
+ export interface LiveCheckInput {
14
+ config: ParsedConfig;
15
+ collections: LoadedCollections;
16
+ schemas: LiveSchemas;
17
+ }
18
+ /**
19
+ * One finding per rejected value, with the field path zod reported.
20
+ *
21
+ * Entries whose frontmatter did not parse are skipped — `check.ts` already reports those,
22
+ * and there is nothing to hand a schema.
23
+ */
24
+ export declare function checkAgainstSchemas(input: LiveCheckInput): Promise<CheckFinding[]>;
25
+ //# sourceMappingURL=check-live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-live.d.ts","sourceRoot":"","sources":["../../src/check-live.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAuC,KAAK,WAAW,EAAa,MAAM,eAAe,CAAA;AAEhG,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,YAAY,CAAA;IACpB,WAAW,EAAE,iBAAiB,CAAA;IAC9B,OAAO,EAAE,WAAW,CAAA;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAkCxF"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Where the config parser's picture of a field and the live schema's picture disagree.
3
+ *
4
+ * The editor is built from the parser's picture: what it renders, and what it refuses to save,
5
+ * both come from `parseContentConfig`. The build judges by the live schema. Wherever those two
6
+ * disagree the editor is wrong about the project in a way neither side can notice on its own —
7
+ * the config looks fine, the content parses, and the editor still does the wrong thing.
8
+ *
9
+ * Two disagreements are reported here. Both are held to the same standard as the rest of
10
+ * `check.ts`: the evidence comes from asking the schema (see `schema-probe.ts`), never from
11
+ * assuming the parser's silence means anything.
12
+ *
13
+ * Both are limited to top-level fields, because that is the limit of what they can honestly
14
+ * claim. The write guard in `handlers/entry-ops.ts` stops at the top level and the editor's
15
+ * type fallback is decided per top-level field, so a nested finding would name a consequence
16
+ * that does not follow.
17
+ */
18
+ import type { CheckFinding } from './check';
19
+ import type { LoadedCollections } from './check-entries';
20
+ import type { ParsedConfig } from './content-config-ast';
21
+ import { type LiveSchemas } from './schema-port';
22
+ export interface ShapeCheckInput {
23
+ config: ParsedConfig;
24
+ collections: LoadedCollections;
25
+ schemas: LiveSchemas;
26
+ }
27
+ export declare function checkFieldShapes(input: ShapeCheckInput): Promise<CheckFinding[]>;
28
+ //# sourceMappingURL=check-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-shape.d.ts","sourceRoot":"","sources":["../../src/check-shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,eAAe,CAAA;AAG3D,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,YAAY,CAAA;IACpB,WAAW,EAAE,iBAAiB,CAAA;IAC9B,OAAO,EAAE,WAAW,CAAA;CACpB;AAsFD,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAsBtF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Predict the writes the editor is about to make, and whether the schema will take them.
3
+ *
4
+ * Everything else here validates content that already exists. This runs before the mistake:
5
+ * it builds the exact frontmatter the CMS would write for an editorial action and parses it
6
+ * against the live schema. A rejection is a build that will break the next time someone
7
+ * performs that action — not a guess, since the write shape comes from
8
+ * `editor-write-model.ts`, which the editor itself uses.
9
+ *
10
+ * Two actions are simulated:
11
+ *
12
+ * - **new entry** — `newEntryFrontmatter` then `omitEmptyOnCreate`, then the keys the create
13
+ * route itself injects (`applyCreateRouteFields`). Note what this means: a field left empty
14
+ * arrives *absent*, not as `''`, so the failure to look for is a missing required value.
15
+ * Where `blankRequiredFields` says the write guard in `handlers/entry-ops.ts` would reject
16
+ * the create before it reaches disk, there is no finding to make — with the exception of
17
+ * `hidden` fields, which that guard skips.
18
+ * - **"+ Add" in a repeater** — an object-array field gains an item built by `newRepeaterItem`,
19
+ * which seeds the keys the config declares required and omits the rest. What survives is a
20
+ * required key the config does not know about: `addArrayItem` seeds from the same config the
21
+ * editor renders from, so neither can supply a key neither can see.
22
+ */
23
+ import type { CheckFinding } from './check';
24
+ import { type LoadedCollections } from './check-entries';
25
+ import type { ParsedConfig } from './content-config-ast';
26
+ import { type LiveSchemas } from './schema-port';
27
+ export interface WriteCheckInput {
28
+ config: ParsedConfig;
29
+ collections: LoadedCollections;
30
+ schemas: LiveSchemas;
31
+ /** Injected so a date-defaulted field does not make the report depend on the day it ran. */
32
+ today?: () => Date;
33
+ }
34
+ export declare function checkEditorWrites(input: WriteCheckInput): Promise<CheckFinding[]>;
35
+ //# sourceMappingURL=check-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-write.d.ts","sourceRoot":"","sources":["../../src/check-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAwD,KAAK,iBAAiB,EAAoB,MAAM,iBAAiB,CAAA;AAChI,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,sBAAsB,CAAA;AASrE,OAAO,EAAkD,KAAK,WAAW,EAAa,MAAM,eAAe,CAAA;AAG3G,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,YAAY,CAAA;IACpB,WAAW,EAAE,iBAAiB,CAAA;IAC9B,OAAO,EAAE,WAAW,CAAA;IACpB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CAClB;AA6HD,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CA+GvF"}
@@ -12,6 +12,7 @@
12
12
  * `astro sync` already provides.
13
13
  */
14
14
  import type { CmsFileSystem } from './fs/types';
15
+ import { type LiveSchemas } from './schema-port';
15
16
  export type CheckSeverity = 'error' | 'warning';
16
17
  export interface CheckFinding {
17
18
  severity: CheckSeverity;
@@ -24,19 +25,35 @@ export interface CheckFinding {
24
25
  column?: number;
25
26
  field?: string;
26
27
  message: string;
28
+ /**
29
+ * What to change to make the finding go away, when there is a specific answer.
30
+ *
31
+ * Separate from `message` because it is a different kind of claim: the message states
32
+ * what the checker observed, the hint proposes an edit it cannot verify. Rules add one
33
+ * only where the remedy follows from the evidence — never as a restatement.
34
+ */
35
+ hint?: string;
27
36
  }
28
37
  export interface CheckReport {
29
38
  findings: CheckFinding[];
30
39
  collections: number;
31
40
  entries: number;
32
41
  }
42
+ export interface CheckContentOptions {
43
+ /**
44
+ * The project's real collection schemas. Given these, the check also reports what the
45
+ * build would reject and what the editor's next write would break — see `check-live.ts`
46
+ * and `check-write.ts`. Absent, only the AST/data rules below run.
47
+ */
48
+ schemas?: LiveSchemas;
49
+ }
33
50
  /**
34
51
  * Validate every declared collection against what is on disk.
35
52
  *
36
53
  * Errors are things that fail the build; warnings are things that pass it and then go wrong
37
54
  * at render time (a reference pointing at nothing is the documented example).
38
55
  */
39
- export declare function checkContent(fs: CmsFileSystem): Promise<CheckReport>;
56
+ export declare function checkContent(fs: CmsFileSystem, options?: CheckContentOptions): Promise<CheckReport>;
40
57
  /** Human-readable report. Returns '' when there is nothing to say. */
41
58
  export declare function formatCheckReport(report: CheckReport): string;
42
59
  //# sourceMappingURL=check.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAA;AAE/C,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,aAAa,CAAA;IACvB,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAA;IACZ,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAA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,mBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC,CA6I7G;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA0B7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"collection-scanner.d.ts","sourceRoot":"","sources":["../../src/collection-scanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAmD,MAAM,oBAAoB,CAAA;AAG/G,OAAO,EAAE,KAAK,UAAU,EAA2D,MAAM,sBAAsB,CAAA;AAC/G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAohC/C;;;;;;GAMG;AACH,wBAAsB,eAAe,CACpC,EAAE,EAAE,aAAa,EACjB,UAAU,GAAE,MAAsB,EAClC,UAAU,GAAE,UAAsB,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAoF/C"}
1
+ {"version":3,"file":"collection-scanner.d.ts","sourceRoot":"","sources":["../../src/collection-scanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAmD,MAAM,oBAAoB,CAAA;AAG/G,OAAO,EAAE,KAAK,UAAU,EAA2D,MAAM,sBAAsB,CAAA;AAC/G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAkiC/C;;;;;;GAMG;AACH,wBAAsB,eAAe,CACpC,EAAE,EAAE,aAAa,EACjB,UAAU,GAAE,MAAsB,EAClC,UAAU,GAAE,UAAsB,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAoF/C"}
@@ -1,4 +1,4 @@
1
- import { type CollectionLayout, type FieldHints, type FieldType, type PathnameSpec } from '@nuasite/cms-types';
1
+ import { type CollectionLayout, type DerivedTransform, type FieldHints, type FieldType, type PathnameSpec } from '@nuasite/cms-types';
2
2
  import type { CmsFileSystem } from './fs/types';
3
3
  export interface ParsedReference {
4
4
  target: string;
@@ -32,10 +32,16 @@ export interface ParsedFieldLayout {
32
32
  width?: 'full' | 'half';
33
33
  order?: number;
34
34
  hidden?: boolean;
35
+ /** Name of the field this one is computed from (`n.text({ derivedFrom: 'category' })`). */
36
+ derivedFrom?: string;
37
+ /** Named transform for the derived value; absent means `slugifyHref`. */
38
+ derivedTransform?: DerivedTransform;
35
39
  }
36
40
  export interface ParsedCollection {
37
41
  name: string;
38
42
  fields: ParsedField[];
43
+ /** `fields` is known to be incomplete — a spread or computed key in the schema was skipped. */
44
+ partialFields?: true;
39
45
  loaderPattern?: string;
40
46
  loaderBase?: string;
41
47
  /** Declarative form layout from a `defineCmsCollection({ cms: { … } })` block. */
@@ -1 +1 @@
1
- {"version":3,"file":"content-config-ast.d.ts","sourceRoot":"","sources":["../../src/content-config-ast.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,UAAU,EACf,KAAK,SAAS,EAGd,KAAK,YAAY,EACjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE;QAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAA;KAAE,CAAA;IACvC,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,2GAA2G;IAC3G,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,mFAAmF;IACnF,MAAM,CAAC,EA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CAAA;IAChB,2FAA2F;IAC3F,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACnC;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,+FAA+F;IAC/F,aAAa,CAAC,EAAE,IAAI,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kFAAkF;IAClF,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,kGAAkG;IAClG,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,IAAI,CAAA;IACf,2GAA2G;IAC3G,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAExD,sEAAsE;AACtE,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,CAAC,CAAA;AAmK/E;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAqBpG;AAED,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CA+JpF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * What the editor actually writes when it creates an entry — the create-route half.
3
+ *
4
+ * The value rules underneath (what a blank field holds, which keys a repeater item carries,
5
+ * which required fields count as unfilled) live in `@nuasite/cms-types` so that every editor
6
+ * can reach them: `collections-admin` and webmaster's own collections panel depend on
7
+ * `cms-client`, which is a sibling of this package, not a consumer. They are re-exported here
8
+ * because the create pipeline reads as one thing.
9
+ *
10
+ * What stays is what only makes sense next to the create route: the form's starting
11
+ * frontmatter, the empty filter the request applies, and the keys the route injects.
12
+ *
13
+ * A check built on a second, drifted copy of any of this reports failures that cannot happen
14
+ * and misses the ones that can — which is why none of it may be reimplemented anywhere.
15
+ */
16
+ import { type WriteModelField } from '@nuasite/cms-types';
17
+ export { blankRequiredFields, defaultValueForNewEntry, isBlankFieldValue, newRepeaterItem, type RepeaterItemField, type RequiredGuardField, type WriteModelField, } from '@nuasite/cms-types';
18
+ /**
19
+ * The frontmatter the editor holds when "create entry" opens, before the user types.
20
+ *
21
+ * `title` is excluded because the create form carries it in its own header field, and
22
+ * hidden fields are excluded because the form cannot fill them in. Neither is missing from
23
+ * the finished entry — see `applyCreateRouteFields`, which is what puts `title` back.
24
+ */
25
+ export declare function newEntryFrontmatter(fields: WriteModelField[], today?: () => Date): Record<string, unknown>;
26
+ /** Whether the create route treats a collection's files as markdown entries or as plain data. */
27
+ export type CollectionKind = 'markdown' | 'data';
28
+ /**
29
+ * The last step of a create: what the server adds before the file is written.
30
+ *
31
+ * A markdown entry gets the title from the form — which refuses to be blank — plus today's
32
+ * date, and the form's own frontmatter wins over both (`handlers/api-routes.ts`). A data
33
+ * entry is written verbatim, with the title already among its fields.
34
+ *
35
+ * Anything predicting a create has to apply this. Stopping at the editor's payload predicts
36
+ * an entry with no title, and then reports a required `title` as broken on every project.
37
+ */
38
+ export declare function applyCreateRouteFields(frontmatter: Record<string, unknown>, kind: CollectionKind, today?: () => Date): Record<string, unknown>;
39
+ /**
40
+ * What survives the create request.
41
+ *
42
+ * The editor drops empty strings and `undefined` rather than writing them, so a field
43
+ * the user left alone reaches the schema as *absent*, not as `''`. Anything predicting
44
+ * a create has to apply this — the two produce different validation errors, and only
45
+ * one of them is real.
46
+ */
47
+ export declare function omitEmptyOnCreate(frontmatter: Record<string, unknown>): Record<string, unknown>;
48
+ //# sourceMappingURL=editor-write-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-write-model.d.ts","sourceRoot":"","sources":["../../src/editor-write-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAElF,OAAO,EACN,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACpB,MAAM,oBAAoB,CAAA;AAE3B;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO1G;AAED,iGAAiG;AACjG,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,MAAM,CAAA;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,IAAI,EAAE,cAAc,EACpB,KAAK,GAAE,MAAM,IAAuB,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM/F"}
@@ -1 +1 @@
1
- {"version":3,"file":"entry-ops.d.ts","sourceRoot":"","sources":["../../../src/handlers/entry-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGlG,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,M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AAY,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAuBxG;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAwB9G;AAED,kFAAkF;AAClF,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAGlH"}
@@ -1,14 +1,22 @@
1
- export { checkContent, type CheckFinding, type CheckReport, type CheckSeverity, formatCheckReport } from './check';
1
+ export { resolveAssetCandidates } from './asset-paths';
2
+ export { checkContent, type CheckContentOptions, type CheckFinding, type CheckReport, type CheckSeverity, formatCheckReport } from './check';
3
+ export { collectionKind, entryStem, loadCollections, type LoadedCollection, type LoadedCollections, type LoadedEntry, normalizeBase, parseEntry, } from './check-entries';
4
+ export { checkAgainstSchemas, type LiveCheckInput } from './check-live';
5
+ export { checkFieldShapes, type ShapeCheckInput } from './check-shape';
6
+ export { checkEditorWrites, type WriteCheckInput } from './check-write';
2
7
  export { scanCollections } from './collection-scanner';
3
8
  export { scanComponentDefinitions } from './component-registry';
4
9
  export { type ParseCache, parseConfigSource, parseContentConfig, type ParsedCollection, type ParsedConfig, type ParsedField, type ParsedReference, } from './content-config-ast';
5
10
  export { createCmsCore } from './core';
6
11
  export type { CmsCore, CmsCoreOptions } from './core';
12
+ export { applyCreateRouteFields, blankRequiredFields, type CollectionKind, defaultValueForNewEntry, isBlankFieldValue, newEntryFrontmatter, newRepeaterItem, omitEmptyOnCreate, type RepeaterItemField, type RequiredGuardField, type WriteModelField, } from './editor-write-model';
7
13
  export { globToRegExp } from './fs/glob';
8
14
  export { createNodeFs } from './fs/node-fs';
9
15
  export type { CmsFileSystem } from './fs/types';
10
16
  export { type AddArrayItemInput, type CreateEntryInput, ensureMdxImports, type EntryAsset, type EntryOpsDeps, type GetEntryResult, parseFrontmatter, type RemoveArrayItemInput, serializeFrontmatter, type UpdateEntryInput, } from './handlers/entry-ops';
11
17
  export { type ContemberStorageOptions, createContemberStorageAdapter, createLocalStorageAdapter, createS3StorageAdapter, getFileExtension, listProjectImages, type ListProjectImagesOptions, type LocalStorageOptions, MIME_BY_EXT, mimeFromExt, type S3StorageOptions, uploadsDirRelativeToRoot, } from './media/index';
12
18
  export { parseProjectCmsConfig, parseProjectCmsConfigSource } from './project-config-ast';
13
- export { computePathnameFromSpec, escapeHtml, relativeImportPath, resolvePathnameFromSpec, slugify, slugifyHref } from './shared';
19
+ export { describeIssue, type LiveIssue, type LiveParseResult, type LiveSchema, type LiveSchemas, schemaFor } from './schema-port';
20
+ export { acceptsMissing, firstAcceptedEntry, governsPath, pointAt, type ProbePoint, rejectsValueAt } from './schema-probe';
21
+ export { applyDerivedTransform, computeDerivedFieldUpdates, computePathnameFromSpec, type DerivedFieldSpec, escapeHtml, relativeImportPath, resolvePathnameFromSpec, slugify, slugifyHref, } from './shared';
14
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAClH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EACN,KAAK,UAAU,EACf,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,GACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,QA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AK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,WAAW,EACX,WAAW,EACX,KAAK,gBAAgB,EACrB,wBAAwB,GACxB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AACzF,OAAO,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACjI,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC1H,OAAO,EACN,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,OAAO,EACP,WAAW,GACX,MAAM,UAAU,CAAA"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The port through which a project's real collection schemas reach the checker.
3
+ *
4
+ * `cms-core` deliberately does not load them. Getting a live schema means importing the
5
+ * project's `content.config.ts`, which executes project code, needs an `astro:content`
6
+ * stub installed process-wide, and caches the module for the life of the process — all
7
+ * fine in a one-shot CLI, none of it acceptable inside the long-running dev server and
8
+ * sidecar that also load this package. The CLI does the loading and injects the result.
9
+ *
10
+ * `safeParse` is async because that is how Astro validates content
11
+ * (`astro/dist/content/utils.js` calls `safeParseAsync`), so a schema carrying an async
12
+ * refinement is legal and a synchronous parse would throw on it.
13
+ */
14
+ export interface LiveIssue {
15
+ /** Path to the offending value, as zod reports it: `['stats', 0, 'label']`. */
16
+ path: (string | number)[];
17
+ message: string;
18
+ }
19
+ export type LiveParseResult = {
20
+ success: true;
21
+ } | {
22
+ success: false;
23
+ issues: LiveIssue[];
24
+ };
25
+ export interface LiveSchema {
26
+ safeParse(value: unknown): Promise<LiveParseResult>;
27
+ }
28
+ /** Keyed by collection name. A collection missing from here has no live schema and is skipped. */
29
+ export type LiveSchemas = Record<string, LiveSchema>;
30
+ /**
31
+ * Render an issue as a finding's `field` and `message`.
32
+ *
33
+ * Shared so the two live checkers phrase the same rejection identically — they report
34
+ * different actions but the same schema verdict, and a reader comparing them should not
35
+ * have to wonder whether a wording difference means something.
36
+ */
37
+ export declare function describeIssue(issue: LiveIssue): {
38
+ field?: string;
39
+ message: string;
40
+ };
41
+ /** A collection's live schema, if it has one. Guards against inherited `Object.prototype` keys. */
42
+ export declare function schemaFor(schemas: LiveSchemas, collection: string): LiveSchema | undefined;
43
+ //# sourceMappingURL=schema-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-port.d.ts","sourceRoot":"","sources":["../../src/schema-port.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,SAAS;IACzB,+EAA+E;IAC/E,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,OAAO,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAA;CAAE,CAAA;AAEzF,MAAM,WAAW,UAAU;IAC1B,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;CACnD;AAED,kGAAkG;AAClG,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAEpD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAInF;AAED,mGAAmG;AACnG,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAE1F"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Ask a live schema what it thinks of one field, without the rest of the record answering for it.
3
+ *
4
+ * The static rules read the config's source and the live rules read the schema's verdict on a
5
+ * whole entry. Neither can say what the schema believes about a *single* field, which is what the
6
+ * drift rules need: whether it insists on the key, whether it would take text there.
7
+ *
8
+ * The technique is the same for every question. Start from an entry the schema already accepts,
9
+ * change exactly one value, parse again, and look at where the issues land. Starting from an
10
+ * accepted entry is what makes the answer attributable — on a record the schema already rejects,
11
+ * every probe comes back "rejected" and means nothing. Reading the issue's *path* rather than
12
+ * overall success is the other half: a schema with a cross-field refinement can fail for reasons
13
+ * that have nothing to do with the field being probed.
14
+ *
15
+ * Every function here is total. A schema that throws answers "I don't know", which callers read
16
+ * as "report nothing" — a rule that cannot get evidence has to stay quiet rather than guess.
17
+ */
18
+ import type { LoadedEntry } from './check-entries';
19
+ import type { LiveSchema } from './schema-port';
20
+ /** One field in one record: the accepted entry to start from, and where the field sits in it. */
21
+ export interface ProbePoint {
22
+ /** Never mutated — every probe works on a clone. */
23
+ record: Record<string, unknown>;
24
+ path: (string | number)[];
25
+ }
26
+ /** The point for a top-level field of `seed`. The probe sets the key, so the seed need not already carry it. */
27
+ export declare const pointAt: (seed: Record<string, unknown>, field: string) => ProbePoint;
28
+ /**
29
+ * Whether the schema constrains this path at all.
30
+ *
31
+ * True as soon as one probe value is refused *at the path*. False means either a schema that takes
32
+ * anything here or one that could not be asked; both are reasons to report nothing.
33
+ */
34
+ export declare function governsPath(schema: LiveSchema, point: ProbePoint): Promise<boolean>;
35
+ /**
36
+ * Whether the schema takes the record with this key removed.
37
+ *
38
+ * Deliberately strict — the whole record has to parse, not merely avoid an issue at this path. The
39
+ * claim built on it is that the editor blocks a save the build would accept, and a record failing
40
+ * elsewhere is not evidence the build would accept anything.
41
+ */
42
+ export declare function acceptsMissing(schema: LiveSchema, point: ProbePoint): Promise<boolean>;
43
+ /** Whether the schema refuses `value` *at this path*, as opposed to failing for some unrelated reason. */
44
+ export declare function rejectsValueAt(schema: LiveSchema, point: ProbePoint, value: unknown): Promise<boolean>;
45
+ /**
46
+ * The first entry the schema accepts, or `undefined` when there is none.
47
+ *
48
+ * Shared with the write check so both mean the same thing by "a record the editor is really
49
+ * sitting on". Seeding from a rejected entry would blame every probe for that entry's own
50
+ * problems, which `check-live.ts` already reports.
51
+ */
52
+ export declare function firstAcceptedEntry(schema: LiveSchema, entries: LoadedEntry[]): Promise<Record<string, unknown> | undefined>;
53
+ //# sourceMappingURL=schema-probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-probe.d.ts","sourceRoot":"","sources":["../../src/schema-probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,iGAAiG;AACjG,MAAM,WAAW,UAAU;IAC1B,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACzB;AAED,gHAAgH;AAChH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,KAAG,UAA+C,CAAA;AAwDtH;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAKzF;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5F;AAED,0GAA0G;AAC1G,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5G;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAWjI"}
@@ -1,4 +1,4 @@
1
- import type { CollectionDefinition, PathnameSpec } from '@nuasite/cms-types';
1
+ import { type CollectionDefinition, type DerivedTransform, type PathnameSpec, slugify } from '@nuasite/cms-types';
2
2
  /**
3
3
  * Compose a collection entry's page URL from a declarative {@link PathnameSpec}
4
4
  * and the entry's frontmatter `data`.
@@ -32,17 +32,41 @@ export declare function slugifyHref(text: string): string;
32
32
  /** Runtime guard: a non-null, non-array object usable as a string-keyed record. */
33
33
  export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
34
34
  /**
35
- * Slugify text for URL paths.
36
- * Folds diacritics, lowercases, strips non-word characters, collapses whitespace/underscores
37
- * to hyphens. Keeps `/`, so a nested entry path survives — that is the only thing separating
38
- * this from `slugifyHref` above.
35
+ * Re-exported from `@nuasite/cms-types` so the server and every client slugify identically —
36
+ * a host deriving a slug locally is predicting this write. See `cms-types/src/slug.ts`.
37
+ */
38
+ export { slugify };
39
+ /** A field's derived-value declaration, the subset of `FieldDefinition` the recompute reads. */
40
+ export interface DerivedFieldSpec {
41
+ name: string;
42
+ derivedFrom?: string;
43
+ derivedTransform?: DerivedTransform;
44
+ }
45
+ /**
46
+ * Apply a derived field's named transform to its source value.
47
+ *
48
+ * `slug` reuses `slugify` deliberately, and `slugify` **keeps `/`** — it is written to name
49
+ * files on disk, where a nested entry path has to survive. So `transform: 'slug'` on a value
50
+ * that already contains a slash keeps it (`"news/2024"` → `"news/2024"`). That is a conscious
51
+ * reuse of the existing function, not a bug: the transform is documented as "the `slugifyHref`
52
+ * fold without the leading slash", and every other separator still collapses to `-`.
53
+ */
54
+ export declare function applyDerivedTransform(value: string, transform: DerivedTransform | undefined): string;
55
+ /**
56
+ * Values every derived field in `fields` should hold given `data`, keyed by field name.
57
+ *
58
+ * The single definition of "recompute derived fields", shared by every write path in
59
+ * `cms-core`. A source field that is missing, not a string, or blank yields no entry at all —
60
+ * the existing value is left alone rather than blanked, because "no source" is not "empty
61
+ * result". An empty source is deliberately in that group: every transform maps `''` to
62
+ * something that looks like a value (`slugifyHref('')` is `'/'`, a link to the site root), and
63
+ * writing that into content is worse than leaving the previous value in place. Whitespace-only
64
+ * counts as empty for the same reason — it slugifies to the same thing.
39
65
  *
40
- * The fold matters because this names the file a new entry is written to: `[^\w\s\-/]` alone
41
- * deletes diacritics rather than folding them, turning "Vedra jako zdravotní i sociální
42
- * problém" into "vedra-jako-zdravotn-i-sociln-problm" — which is what any host deriving a
43
- * slug from a Czech title would have to write to disk.
66
+ * `hidden` is deliberately not consulted: an author who sets `hidden: false` on a declared
67
+ * derived field still gets it computed, they only also get to see it.
44
68
  */
45
- export declare function slugify(text: string): string;
69
+ export declare function computeDerivedFieldUpdates(fields: readonly DerivedFieldSpec[], data: Record<string, unknown>): Record<string, unknown>;
46
70
  /**
47
71
  * Escape HTML special characters to prevent injection.
48
72
  * Covers &, <, >, ", and ' — the full set needed for both text content and attribute values.
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAiB5E;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAe7G;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,EAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO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