@conloca/content-api 0.2.0 → 0.2.2

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 (74) hide show
  1. package/dist/asset-metadata-store.d.ts.map +1 -1
  2. package/dist/asset-operations.d.ts +20 -34
  3. package/dist/asset-operations.d.ts.map +1 -1
  4. package/dist/asset-operations.js +219 -166
  5. package/dist/asset-operations.js.map +1 -1
  6. package/dist/asset-usage.d.ts +5 -4
  7. package/dist/asset-usage.d.ts.map +1 -1
  8. package/dist/asset-usage.js +6 -5
  9. package/dist/asset-usage.js.map +1 -1
  10. package/dist/cf-access.d.ts +4 -2
  11. package/dist/cf-access.d.ts.map +1 -1
  12. package/dist/cf-access.js +29 -13
  13. package/dist/cf-access.js.map +1 -1
  14. package/dist/component-registry.d.ts +0 -3
  15. package/dist/component-registry.d.ts.map +1 -1
  16. package/dist/content-file-id.d.ts +9 -0
  17. package/dist/content-file-id.d.ts.map +1 -0
  18. package/dist/content-file-id.js +33 -0
  19. package/dist/content-file-id.js.map +1 -0
  20. package/dist/content-operations.js +2 -2
  21. package/dist/content-operations.js.map +1 -1
  22. package/dist/content-path.d.ts +5 -0
  23. package/dist/content-path.d.ts.map +1 -1
  24. package/dist/content-path.js +7 -0
  25. package/dist/content-path.js.map +1 -1
  26. package/dist/filesystem-content-api.d.ts +0 -15
  27. package/dist/filesystem-content-api.d.ts.map +1 -1
  28. package/dist/filesystem-content-api.js +60 -17
  29. package/dist/filesystem-content-api.js.map +1 -1
  30. package/dist/git-operations.d.ts.map +1 -1
  31. package/dist/git-operations.js +162 -34
  32. package/dist/git-operations.js.map +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +0 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/middleware.d.ts +2 -0
  38. package/dist/middleware.d.ts.map +1 -1
  39. package/dist/middleware.js +21 -31
  40. package/dist/middleware.js.map +1 -1
  41. package/dist/schemas/index.d.ts +9 -97
  42. package/dist/schemas/index.d.ts.map +1 -1
  43. package/dist/schemas/index.js +8 -83
  44. package/dist/schemas/index.js.map +1 -1
  45. package/dist/schemas/normalize.d.ts +101 -0
  46. package/dist/schemas/normalize.d.ts.map +1 -0
  47. package/dist/schemas/normalize.js +168 -0
  48. package/dist/schemas/normalize.js.map +1 -0
  49. package/dist/schemas/types.d.ts +135 -0
  50. package/dist/schemas/types.d.ts.map +1 -0
  51. package/dist/schemas/types.js +17 -0
  52. package/dist/schemas/types.js.map +1 -0
  53. package/dist/schemas/validators.d.ts +46 -0
  54. package/dist/schemas/validators.d.ts.map +1 -0
  55. package/dist/schemas/validators.js +938 -0
  56. package/dist/schemas/validators.js.map +1 -0
  57. package/dist/types.d.ts +7 -0
  58. package/dist/types.d.ts.map +1 -1
  59. package/package.json +12 -5
  60. package/src/asset-operations.ts +260 -187
  61. package/src/asset-usage.ts +6 -5
  62. package/src/cf-access.ts +30 -14
  63. package/src/content-file-id.ts +31 -0
  64. package/src/content-operations.ts +2 -2
  65. package/src/content-path.ts +8 -0
  66. package/src/filesystem-content-api.ts +72 -17
  67. package/src/git-operations.ts +188 -41
  68. package/src/index.ts +17 -1
  69. package/src/middleware.ts +23 -37
  70. package/src/schemas/index.ts +34 -108
  71. package/src/schemas/normalize.ts +194 -0
  72. package/src/schemas/types.ts +154 -0
  73. package/src/schemas/validators.ts +176 -0
  74. package/src/types.ts +7 -0
@@ -0,0 +1,168 @@
1
+ /**
2
+ * The value rewriting the replaced Zod schemas performed before validating that
3
+ * Typia does not do, spelled out as pure functions.
4
+ *
5
+ * Typia validates the value it is given — it never coerces and never copies —
6
+ * so these Zod steps are explicit here, each unit-tested against the recorded
7
+ * Zod behaviour: the fresh object every Zod parse returned, holding the
8
+ * declared fields (and, for `.loose()`/`.passthrough()`, the undeclared ones)
9
+ * with arrays and records copied; `z.coerce.date()`; and `z.string().url()`
10
+ * (Zod's check is "the URL parser accepts it" and it rewrites the value, which
11
+ * Typia's `tags.Format<'url'>` regex neither matches nor does).
12
+ */
13
+ /** The page fields that were declared `z.coerce.date().nullable().optional()`. */
14
+ export const PAGE_DATE_KEYS = ['publishAt', 'unpublishAt'];
15
+ /** The page fields that were declared `z.string().url().optional()`. */
16
+ export const PAGE_URL_KEYS = ['canonical'];
17
+ /** The `expected` a rejected URL field reports, in Typia's notation. */
18
+ const URL_EXPECTED = 'string & Format<"url">';
19
+ /** The `expected` a rejected record field reports, in Typia's notation. */
20
+ const RECORD_EXPECTED = 'Record<string, unknown>';
21
+ /** The URL parser deletes every ASCII tab, LF and CR before parsing; so did Zod's output. */
22
+ const ASCII_TAB_OR_NEWLINE = /[\t\n\r]/g;
23
+ /** A non-null, non-array object — the only input shape normalization can rewrite. */
24
+ function isRecord(value) {
25
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
26
+ }
27
+ /**
28
+ * `z.coerce.date()` under a `.nullable().optional()` wrapper: `undefined` and
29
+ * `null` short-circuit before coercion, anything else goes through `new Date()`.
30
+ *
31
+ * A `Date` input is cloned rather than passed through, which is what Zod did:
32
+ * the parsed value never aliases the caller's Date, so mutating one cannot
33
+ * reach through to the other.
34
+ *
35
+ * An uncoercible value yields an Invalid Date; that is not an error here.
36
+ * `normalize()` reports it, because a `Date` carrying `NaN` still satisfies
37
+ * every `instanceof Date` check a generated validator can make. That includes
38
+ * values `new Date()` throws on (a BigInt, a Symbol, an object whose
39
+ * `toString`/`valueOf` are not callable), so a parse reports them as an issue
40
+ * instead of throwing.
41
+ */
42
+ export function coerceNullableDate(value) {
43
+ if (value === undefined)
44
+ return undefined;
45
+ if (value === null)
46
+ return null;
47
+ try {
48
+ return new Date(value);
49
+ }
50
+ catch {
51
+ return new Date(Number.NaN);
52
+ }
53
+ }
54
+ /**
55
+ * `z.string().url()`: a string passes iff the WHATWG URL parser accepts it once
56
+ * trimmed, and the parsed value is that trimmed string with ASCII tabs and
57
+ * newlines removed (not the normalized `href`). `undefined` means rejected.
58
+ */
59
+ export function coerceUrl(value) {
60
+ const trimmed = value.trim();
61
+ try {
62
+ new URL(trimmed);
63
+ }
64
+ catch {
65
+ return undefined;
66
+ }
67
+ return trimmed.replace(ASCII_TAB_OR_NEWLINE, '');
68
+ }
69
+ /**
70
+ * The value a validator may rewrite, and the issues only normalization can see.
71
+ *
72
+ * Every object input becomes a fresh top-level copy — as every Zod parse
73
+ * returned one — so the parsed value never is the caller's. Like Zod's, the
74
+ * copy reads each field once: first every `declared` field the input has
75
+ * however it holds it (`key in input`: inherited, non-enumerable, a getter),
76
+ * then, for a `keepsUndeclared` shape (`.loose()`), every other enumerable
77
+ * field, own or inherited, by reference — except a `__proto__` key, which Zod
78
+ * dropped. Then:
79
+ * - `dates` are coerced, and each that ends up an Invalid Date is an issue
80
+ * (`expected: Date`), the way Zod reported it;
81
+ * - `urls` holding a string are checked and rewritten by `coerceUrl()`, a
82
+ * rejected one is an issue; a non-string is left for the generated type check;
83
+ * - `arrays` holding an array are copied;
84
+ * - `records` holding a plain object are rebuilt by `copyRecord()`; any other
85
+ * object (an array, a `Date`, a class instance) is an issue, which the
86
+ * generated `Record<string, unknown>` check cannot be relied on to raise.
87
+ *
88
+ * A non-object passes through untouched for the validator to report.
89
+ */
90
+ export function normalize(input, fields) {
91
+ if (!isRecord(input))
92
+ return { value: input, issues: [] };
93
+ const value = {};
94
+ for (const key of fields.declared) {
95
+ if (key in input)
96
+ value[key] = input[key];
97
+ }
98
+ if (fields.keepsUndeclared) {
99
+ for (const key in input) {
100
+ // Skipping `__proto__` also keeps the assignment below from setting the copy's prototype.
101
+ if (key !== '__proto__' && !fields.declared.includes(key))
102
+ value[key] = input[key];
103
+ }
104
+ }
105
+ const issues = [];
106
+ for (const key of fields.dates ?? []) {
107
+ if (!Object.hasOwn(value, key))
108
+ continue;
109
+ const coerced = coerceNullableDate(value[key]);
110
+ value[key] = coerced;
111
+ if (coerced instanceof Date && Number.isNaN(coerced.getTime())) {
112
+ issues.push({ path: `$input.${key}`, expected: 'Date', value: coerced });
113
+ }
114
+ }
115
+ for (const key of fields.urls ?? []) {
116
+ const raw = value[key];
117
+ if (typeof raw !== 'string')
118
+ continue;
119
+ const coerced = coerceUrl(raw);
120
+ if (coerced === undefined)
121
+ issues.push({ path: `$input.${key}`, expected: URL_EXPECTED, value: raw });
122
+ else
123
+ value[key] = coerced;
124
+ }
125
+ for (const key of fields.arrays ?? []) {
126
+ const raw = value[key];
127
+ if (Array.isArray(raw))
128
+ value[key] = [...raw];
129
+ }
130
+ for (const key of fields.records ?? []) {
131
+ const raw = value[key];
132
+ if (typeof raw !== 'object' || raw === null)
133
+ continue;
134
+ const copy = Array.isArray(raw) ? undefined : copyRecord(raw);
135
+ if (copy === undefined)
136
+ issues.push({ path: `$input.${key}`, expected: RECORD_EXPECTED, value: raw });
137
+ else
138
+ value[key] = copy;
139
+ }
140
+ return { value, issues };
141
+ }
142
+ /**
143
+ * `z.record(z.string(), z.unknown())`: `undefined` when Zod rejected the value,
144
+ * else a fresh object with its own enumerable string keys. Zod's plain-object
145
+ * test is constructor-based (`Object.create(null)` and objects inheriting from
146
+ * a plain object pass; a `Date` or a class instance does not), it skipped a
147
+ * `__proto__` key, and its string key schema rejected an enumerable symbol key.
148
+ */
149
+ export function copyRecord(value) {
150
+ const valueConstructor = value.constructor;
151
+ if (typeof valueConstructor === 'function') {
152
+ const prototype = valueConstructor.prototype;
153
+ if (typeof prototype !== 'object' || prototype === null)
154
+ return undefined;
155
+ if (!Object.hasOwn(prototype, 'isPrototypeOf'))
156
+ return undefined;
157
+ }
158
+ if (Object.getOwnPropertySymbols(value).some((symbol) => Object.prototype.propertyIsEnumerable.call(value, symbol))) {
159
+ return undefined;
160
+ }
161
+ const copy = {};
162
+ for (const [key, entry] of Object.entries(value)) {
163
+ if (key !== '__proto__')
164
+ copy[key] = entry;
165
+ }
166
+ return copy;
167
+ }
168
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/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jG,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,gBAAgB,GAAY,KAAK,CAAC,WAAW,CAAC;IACpD,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAY,gBAAgB,CAAC,SAAS,CAAC;QACtD,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO,SAAS,CAAC;QAC1E,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC;YAAE,OAAO,SAAS,CAAC;IACnE,CAAC;IACD,IAAI,MAAM,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;QACpH,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAA4B,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,GAAG,KAAK,WAAW;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Content metadata shapes the CMS reads and writes.
3
+ *
4
+ * These were Zod schema objects (`pageMetaSchema`, `dataMetaSchema`, …) until
5
+ * the Typia migration. They are now plain TypeScript types: `./validators`
6
+ * carries the generated validators, `./normalize` carries the coercion and
7
+ * key-stripping the Zod schemas used to perform. `@conloca/astro-cms` validates
8
+ * collection entries with the same generated validators inside its loader.
9
+ *
10
+ * Optional fields also admit an explicit `undefined`, as the `z.infer` types
11
+ * they replaced did, so consumers compiling with `exactOptionalPropertyTypes`
12
+ * keep accepting `{ description: undefined }`. The closed shapes are type
13
+ * aliases, not interfaces, for the same reason: like the `z.infer` aliases,
14
+ * they stay assignable to `Record<string, unknown>`.
15
+ */
16
+ /**
17
+ * Page metadata — editable fields only. Used by CMS forms for dynamic form
18
+ * generation; the form-field descriptors live in the CMS package.
19
+ */
20
+ export type PageEditable = {
21
+ /** Page title for SEO and browser tab. */
22
+ title: string;
23
+ /** Meta description for search engines. */
24
+ description?: string | undefined;
25
+ /** URL path (e.g. `/about`). */
26
+ pathname: string;
27
+ /** Schedule publish date/time. */
28
+ publishAt?: Date | null | undefined;
29
+ /** Schedule unpublish date/time. */
30
+ unpublishAt?: Date | null | undefined;
31
+ /** Robots meta tag (e.g. `index, follow`). */
32
+ robots?: string | undefined;
33
+ /** Canonical URL for duplicate content. Validated as a URL. */
34
+ canonical?: string | undefined;
35
+ };
36
+ /** Full page metadata with the system fields the loader adds. */
37
+ export type PageMeta = PageEditable & {
38
+ id: string;
39
+ locale: string;
40
+ };
41
+ /** Fragment metadata — editable fields only. */
42
+ export type FragmentEditable = {
43
+ /** Display name for the fragment. */
44
+ title: string;
45
+ /** Brief description of this fragment. */
46
+ description?: string | undefined;
47
+ /** Category for organizing fragments (e.g. headers, cta, content). */
48
+ category?: string | undefined;
49
+ /** Tags for filtering and organization. */
50
+ tags?: string[] | undefined;
51
+ };
52
+ /** Full fragment metadata with the system fields the loader adds. */
53
+ export type FragmentMeta = FragmentEditable & {
54
+ id: string;
55
+ locale: string;
56
+ name: string;
57
+ };
58
+ /**
59
+ * Frontmatter of an `mdx`-type page — renderer-neutral.
60
+ *
61
+ * Default for the CMS form when editing an mdx page; projects override via
62
+ * `mdxPages.schema` when they want a renderer-specific shape.
63
+ *
64
+ * Permissive on purpose: the index signature is the Zod `.passthrough()` this
65
+ * replaced — unknown frontmatter keys flow through unchanged so the file's
66
+ * existing fields are never lost on save.
67
+ */
68
+ export interface MdxPageFrontmatter {
69
+ /** Page title for SEO and browser tab. */
70
+ title: string;
71
+ /** Meta description for search engines. */
72
+ description?: string | undefined;
73
+ /** Hide the page from production builds. */
74
+ draft?: boolean | undefined;
75
+ [key: string]: unknown;
76
+ }
77
+ /** Data-entry metadata — editable fields only. */
78
+ export type DataEditable = {
79
+ /** Display name for the entry. */
80
+ title: string;
81
+ /** Brief description of this entry. */
82
+ description?: string | undefined;
83
+ /** Category for organizing entries. */
84
+ category?: string | undefined;
85
+ /** Tags for filtering and organization. */
86
+ tags?: string[] | undefined;
87
+ };
88
+ /**
89
+ * Full data-entry metadata: the editable fields, the system fields the loader
90
+ * adds, and the arbitrary JSON payload under `data`.
91
+ */
92
+ export type DataMeta = DataEditable & {
93
+ id: string;
94
+ locale: string;
95
+ name: string;
96
+ data?: Record<string, unknown> | undefined;
97
+ };
98
+ /**
99
+ * Page metadata as a collection entry carries it: the declared fields validated,
100
+ * every other top-level field (loader-written `created`/`puckData`, host meta)
101
+ * kept as-is. This is what `pageMetaSchema.loose()` accepted.
102
+ */
103
+ export interface LoosePageMeta extends PageMeta {
104
+ [key: string]: unknown;
105
+ }
106
+ /** Fragment metadata with undeclared top-level fields kept (`fragmentMetaSchema.loose()`). */
107
+ export interface LooseFragmentMeta extends FragmentMeta {
108
+ [key: string]: unknown;
109
+ }
110
+ /** Data-entry metadata with undeclared top-level fields kept (`dataMetaSchema.loose()`). */
111
+ export interface LooseDataMeta extends DataMeta {
112
+ [key: string]: unknown;
113
+ }
114
+ /**
115
+ * One validation failure, in the shape Typia reports it: the `$input`-rooted
116
+ * path, the type that was expected there, and the value that was found.
117
+ *
118
+ * Declared here rather than re-exported from Typia so this package's published
119
+ * declarations stay free of a `typia` type import — the transform runs at build
120
+ * time and consumers get generated code, not a Typia dependency.
121
+ */
122
+ export interface SchemaIssue {
123
+ readonly path: string;
124
+ readonly expected: string;
125
+ readonly value: unknown;
126
+ }
127
+ /** Outcome of a `parse*` call: the Zod `safeParse` contract, without Zod. */
128
+ export type SchemaParseResult<T> = {
129
+ readonly success: true;
130
+ readonly data: T;
131
+ } | {
132
+ readonly success: false;
133
+ readonly issues: readonly SchemaIssue[];
134
+ };
135
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/schemas/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,oCAAoC;IACpC,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IACtC,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CA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AQ,QAAQ;IAC7C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAID;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,6EAA6E;AAC7E,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAC3B;IAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAA;CAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Content metadata shapes the CMS reads and writes.
3
+ *
4
+ * These were Zod schema objects (`pageMetaSchema`, `dataMetaSchema`, …) until
5
+ * the Typia migration. They are now plain TypeScript types: `./validators`
6
+ * carries the generated validators, `./normalize` carries the coercion and
7
+ * key-stripping the Zod schemas used to perform. `@conloca/astro-cms` validates
8
+ * collection entries with the same generated validators inside its loader.
9
+ *
10
+ * Optional fields also admit an explicit `undefined`, as the `z.infer` types
11
+ * they replaced did, so consumers compiling with `exactOptionalPropertyTypes`
12
+ * keep accepting `{ description: undefined }`. The closed shapes are type
13
+ * aliases, not interfaces, for the same reason: like the `z.infer` aliases,
14
+ * they stay assignable to `Record<string, unknown>`.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/schemas/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Generated validators for the content metadata shapes.
3
+ *
4
+ * Every `typia.createValidate<T>()` below is rewritten into concrete generated
5
+ * validation code by the `ttsc` transform (spec 12 §The build chain) — in
6
+ * tsdown's Rolldown pipeline for the published build, and by the Bun test
7
+ * preload for `bun test`. Nothing here hand-rolls a check.
8
+ *
9
+ * `parse*` is the replacement for the Zod schemas' `safeParse`: normalize first
10
+ * (`./normalize` reproduces what Zod did implicitly: the fresh copy, the
11
+ * unknown-key strip of the strict shapes, the date coercion and the `.url()`
12
+ * check), then validate with `typia.createValidate<T>()`.
13
+ *
14
+ * `canonical` deliberately carries no `tags.Format<'url'>`: Typia's URL regex
15
+ * rejects URLs Zod accepted (`https://example.com?lang=en`, `#top`,
16
+ * `http://localhost:4321/`) and accepts ones it rejected (port 99999), so the
17
+ * page parsers keep Zod's parser-based check in `normalize()` instead.
18
+ */
19
+ import type { DataEditable, DataMeta, FragmentEditable, FragmentMeta, LooseDataMeta, LooseFragmentMeta, LoosePageMeta, MdxPageFrontmatter, PageEditable, PageMeta, SchemaParseResult } from './types.js';
20
+ /** Field names `PageMeta` declares — the fields a host page schema may not redeclare. */
21
+ export declare const PAGE_META_KEYS: readonly (keyof PageMeta)[];
22
+ /** Editable page fields: unknown keys stripped, `publishAt`/`unpublishAt` coerced to `Date`, `canonical` checked. */
23
+ export declare function parsePageEditable(input: unknown): SchemaParseResult<PageEditable>;
24
+ /** Full page metadata: editable fields plus `id`/`locale`, same strip, date coercion and URL check. */
25
+ export declare function parsePageMeta(input: unknown): SchemaParseResult<PageMeta>;
26
+ /** Editable fragment fields; unknown keys stripped. */
27
+ export declare function parseFragmentEditable(input: unknown): SchemaParseResult<FragmentEditable>;
28
+ /** Full fragment metadata: editable fields plus `id`/`locale`/`name`. */
29
+ export declare function parseFragmentMeta(input: unknown): SchemaParseResult<FragmentMeta>;
30
+ /** MDX page frontmatter; undeclared keys are preserved (the former `.passthrough()`). */
31
+ export declare function parseMdxPageFrontmatter(input: unknown): SchemaParseResult<MdxPageFrontmatter>;
32
+ /** Editable data-entry fields; unknown keys stripped. */
33
+ export declare function parseDataEditable(input: unknown): SchemaParseResult<DataEditable>;
34
+ /** Full data-entry metadata: editable fields plus `id`/`locale`/`name` and the `data` payload. */
35
+ export declare function parseDataMeta(input: unknown): SchemaParseResult<DataMeta>;
36
+ /**
37
+ * A page collection entry: the declared page fields validated, dates coerced and
38
+ * `canonical` URL-checked, every undeclared top-level field kept (the former
39
+ * `pageMetaSchema.loose()`).
40
+ */
41
+ export declare function parseLoosePageMeta(input: unknown): SchemaParseResult<LoosePageMeta>;
42
+ /** A fragment collection entry; undeclared top-level fields kept (the former `fragmentMetaSchema.loose()`). */
43
+ export declare function parseLooseFragmentMeta(input: unknown): SchemaParseResult<LooseFragmentMeta>;
44
+ /** A data collection entry; undeclared top-level fields kept (the former `dataMetaSchema.loose()`). */
45
+ export declare function parseLooseDataMeta(input: unknown): SchemaParseResult<LooseDataMeta>;
46
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/schemas/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EAER,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,yFAAyF;AACzF,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,MAAM,QAAQ,CAAC,EAA6C,CAAC;AAsFpG,qHAAqH;AACrH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAEjF;AAED,uGAAuG;AACvG,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAEzE;AAED,uDAAuD;AACvD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAE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