@cogenta/schema 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/define-collection.d.ts +8 -0
- package/dist/define-collection.d.ts.map +1 -0
- package/dist/define-collection.js +311 -0
- package/dist/define-collection.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -0
- package/dist/fields.d.ts +117 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +107 -0
- package/dist/fields.js.map +1 -0
- package/dist/generate-schema-json.d.ts +61 -0
- package/dist/generate-schema-json.d.ts.map +1 -0
- package/dist/generate-schema-json.js +128 -0
- package/dist/generate-schema-json.js.map +1 -0
- package/dist/generate-types.d.ts +5 -0
- package/dist/generate-types.d.ts.map +1 -0
- package/dist/generate-types.js +220 -0
- package/dist/generate-types.js.map +1 -0
- package/dist/id.d.ts +8 -0
- package/dist/id.d.ts.map +1 -0
- package/dist/id.js +8 -0
- package/dist/id.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/rich-text.d.ts +164 -0
- package/dist/rich-text.d.ts.map +1 -0
- package/dist/rich-text.js +97 -0
- package/dist/rich-text.js.map +1 -0
- package/dist/routing/ids.d.ts +18 -0
- package/dist/routing/ids.d.ts.map +1 -0
- package/dist/routing/ids.js +41 -0
- package/dist/routing/ids.js.map +1 -0
- package/dist/routing/index.d.ts +13 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +7 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/redirects.d.ts +76 -0
- package/dist/routing/redirects.d.ts.map +1 -0
- package/dist/routing/redirects.js +237 -0
- package/dist/routing/redirects.js.map +1 -0
- package/dist/routing/resolve.d.ts +38 -0
- package/dist/routing/resolve.d.ts.map +1 -0
- package/dist/routing/resolve.js +23 -0
- package/dist/routing/resolve.js.map +1 -0
- package/dist/routing/router.d.ts +51 -0
- package/dist/routing/router.d.ts.map +1 -0
- package/dist/routing/router.js +132 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/routing/slug-change.d.ts +39 -0
- package/dist/routing/slug-change.d.ts.map +1 -0
- package/dist/routing/slug-change.js +44 -0
- package/dist/routing/slug-change.js.map +1 -0
- package/dist/routing/slug.d.ts +82 -0
- package/dist/routing/slug.d.ts.map +1 -0
- package/dist/routing/slug.js +124 -0
- package/dist/routing/slug.js.map +1 -0
- package/dist/routing/slugify.d.ts +29 -0
- package/dist/routing/slugify.d.ts.map +1 -0
- package/dist/routing/slugify.js +104 -0
- package/dist/routing/slugify.js.map +1 -0
- package/dist/scheduling/index.d.ts +3 -0
- package/dist/scheduling/index.d.ts.map +1 -0
- package/dist/scheduling/index.js +2 -0
- package/dist/scheduling/index.js.map +1 -0
- package/dist/scheduling/publish.d.ts +71 -0
- package/dist/scheduling/publish.d.ts.map +1 -0
- package/dist/scheduling/publish.js +122 -0
- package/dist/scheduling/publish.js.map +1 -0
- package/dist/search/extract.d.ts +25 -0
- package/dist/search/extract.d.ts.map +1 -0
- package/dist/search/extract.js +188 -0
- package/dist/search/extract.js.map +1 -0
- package/dist/search/index.d.ts +36 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +44 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/mysql.d.ts +7 -0
- package/dist/search/mysql.d.ts.map +1 -0
- package/dist/search/mysql.js +121 -0
- package/dist/search/mysql.js.map +1 -0
- package/dist/search/postgres.d.ts +9 -0
- package/dist/search/postgres.d.ts.map +1 -0
- package/dist/search/postgres.js +167 -0
- package/dist/search/postgres.js.map +1 -0
- package/dist/search/query.d.ts +35 -0
- package/dist/search/query.d.ts.map +1 -0
- package/dist/search/query.js +116 -0
- package/dist/search/query.js.map +1 -0
- package/dist/search/sqlite.d.ts +16 -0
- package/dist/search/sqlite.d.ts.map +1 -0
- package/dist/search/sqlite.js +166 -0
- package/dist/search/sqlite.js.map +1 -0
- package/dist/search/table.d.ts +49 -0
- package/dist/search/table.d.ts.map +1 -0
- package/dist/search/table.js +86 -0
- package/dist/search/table.js.map +1 -0
- package/dist/search/text.d.ts +42 -0
- package/dist/search/text.d.ts.map +1 -0
- package/dist/search/text.js +56 -0
- package/dist/search/text.js.map +1 -0
- package/dist/search/types.d.ts +98 -0
- package/dist/search/types.d.ts.map +1 -0
- package/dist/search/types.js +2 -0
- package/dist/search/types.js.map +1 -0
- package/dist/store/columns.d.ts +33 -0
- package/dist/store/columns.d.ts.map +1 -0
- package/dist/store/columns.js +113 -0
- package/dist/store/columns.js.map +1 -0
- package/dist/store/cursor.d.ts +23 -0
- package/dist/store/cursor.d.ts.map +1 -0
- package/dist/store/cursor.js +36 -0
- package/dist/store/cursor.js.map +1 -0
- package/dist/store/diff.d.ts +59 -0
- package/dist/store/diff.d.ts.map +1 -0
- package/dist/store/diff.js +124 -0
- package/dist/store/diff.js.map +1 -0
- package/dist/store/fragments.d.ts +13 -0
- package/dist/store/fragments.d.ts.map +1 -0
- package/dist/store/fragments.js +25 -0
- package/dist/store/fragments.js.map +1 -0
- package/dist/store/index.d.ts +22 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +16 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/naming.d.ts +25 -0
- package/dist/store/naming.d.ts.map +1 -0
- package/dist/store/naming.js +80 -0
- package/dist/store/naming.js.map +1 -0
- package/dist/store/read-only.d.ts +16 -0
- package/dist/store/read-only.d.ts.map +1 -0
- package/dist/store/read-only.js +36 -0
- package/dist/store/read-only.js.map +1 -0
- package/dist/store/store.d.ts +52 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +706 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/tables.d.ts +40 -0
- package/dist/store/tables.d.ts.map +1 -0
- package/dist/store/tables.js +267 -0
- package/dist/store/tables.js.map +1 -0
- package/dist/store/types.d.ts +105 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +2 -0
- package/dist/store/types.js.map +1 -0
- package/dist/store/uuid.d.ts +6 -0
- package/dist/store/uuid.d.ts.map +1 -0
- package/dist/store/uuid.js +64 -0
- package/dist/store/uuid.js.map +1 -0
- package/dist/store/values.d.ts +40 -0
- package/dist/store/values.d.ts.map +1 -0
- package/dist/store/values.js +160 -0
- package/dist/store/values.js.map +1 -0
- package/dist/system-fields.d.ts +60 -0
- package/dist/system-fields.d.ts.map +1 -0
- package/dist/system-fields.js +73 -0
- package/dist/system-fields.js.map +1 -0
- package/dist/types.d.ts +101 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +54 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +183 -0
- package/dist/validation.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CollectionDefinition, FieldDefinition } from '../types.js';
|
|
2
|
+
import type { BlockZones, ContentBlock, ContentValues } from './types.js';
|
|
3
|
+
export declare function encodeFieldValue(field: string, definition: FieldDefinition, value: unknown): unknown;
|
|
4
|
+
export declare function decodeFieldValue(definition: FieldDefinition, raw: unknown): unknown;
|
|
5
|
+
export interface NormalisedValues {
|
|
6
|
+
/** Column-backed fields, already encoded for the driver. */
|
|
7
|
+
readonly columns: Record<string, unknown>;
|
|
8
|
+
/** To-many relations: field name to the ordered list of target ids. */
|
|
9
|
+
readonly relations: Record<string, readonly string[]>;
|
|
10
|
+
/** The decoded values, as the caller will read them back. */
|
|
11
|
+
readonly values: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface NormaliseOptions {
|
|
14
|
+
/** A partial update only looks at the keys it was given. */
|
|
15
|
+
readonly partial: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether a missing `required` field is an error.
|
|
18
|
+
*
|
|
19
|
+
* False while writing a draft — a piece being written is incomplete by
|
|
20
|
+
* definition, and refusing to save it loses work. True at publication, which
|
|
21
|
+
* is the moment the rule actually means something.
|
|
22
|
+
*/
|
|
23
|
+
readonly enforceRequired: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validates an input against the collection and splits it into what goes where.
|
|
27
|
+
*
|
|
28
|
+
* `required` is checked here rather than by the column, so that a draft can be
|
|
29
|
+
* saved half-written and only publication has to be complete.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normaliseValues(collection: CollectionDefinition, input: ContentValues, options: NormaliseOptions): NormalisedValues;
|
|
32
|
+
/**
|
|
33
|
+
* Checks a block zone and gives every block a `_key`.
|
|
34
|
+
*
|
|
35
|
+
* A key supplied by the caller is kept, always: it is what ties a block to its
|
|
36
|
+
* previous self across a diff, a comment and a RAG chunk. One is only minted for
|
|
37
|
+
* a block that has never been stored.
|
|
38
|
+
*/
|
|
39
|
+
export declare function normaliseBlocks(collection: CollectionDefinition, zones: BlockZones, newKey?: () => string): Record<string, readonly ContentBlock[]>;
|
|
40
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/store/values.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAiBzE,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,OAAO,GACb,OAAO,CAsCT;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAmBnF;AAED,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAA;IACrD,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC;AAED,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,oBAAoB,EAChC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,gBAAgB,GACxB,gBAAgB,CAiFlB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,oBAAoB,EAChC,KAAK,EAAE,UAAU,EACjB,MAAM,GAAE,MAAM,MAAe,GAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC,CAsCzC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { CogentaError } from '@cogenta/core';
|
|
2
|
+
import { newId as uuidv7 } from '../id.js';
|
|
3
|
+
/**
|
|
4
|
+
* Turning declared values into column values and back.
|
|
5
|
+
*
|
|
6
|
+
* The whole point is that a caller never learns which database it is talking
|
|
7
|
+
* to: a `richText` document goes in as an array and comes back as an array on
|
|
8
|
+
* all four servers, even though one of them stores it as text it would happily
|
|
9
|
+
* have parsed for us and another would not.
|
|
10
|
+
*/
|
|
11
|
+
const JSON_KINDS = new Set(['richText', 'json', 'geo']);
|
|
12
|
+
function invalid(message, hint, details) {
|
|
13
|
+
return new CogentaError({ code: 'CONTENT_INVALID', message, hint, details });
|
|
14
|
+
}
|
|
15
|
+
export function encodeFieldValue(field, definition, value) {
|
|
16
|
+
if (value === undefined || value === null)
|
|
17
|
+
return null;
|
|
18
|
+
if (JSON_KINDS.has(definition.kind))
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
if (definition.kind === 'boolean')
|
|
21
|
+
return Boolean(value);
|
|
22
|
+
if (definition.kind === 'number') {
|
|
23
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
24
|
+
throw invalid(`"${field}" expects a number.`, 'Pass a finite number, or null to clear the field.', { field, received: typeof value });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
if (definition.kind === 'date' || definition.kind === 'datetime') {
|
|
29
|
+
// Stored as an ISO-8601 string in UTC on every dialect: see `columns.ts`.
|
|
30
|
+
const date = value instanceof Date ? value : new Date(String(value));
|
|
31
|
+
if (Number.isNaN(date.getTime())) {
|
|
32
|
+
throw invalid(`"${field}" is not a usable date.`, 'Pass a Date or an ISO-8601 string.', {
|
|
33
|
+
field,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return definition.kind === 'date' ? date.toISOString().slice(0, 10) : date.toISOString();
|
|
37
|
+
}
|
|
38
|
+
if (typeof value !== 'string') {
|
|
39
|
+
throw invalid(`"${field}" expects a string, not ${typeof value}.`, 'Text, slug, select, colour, media and to-one relation fields hold a string.', { field, kind: definition.kind });
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
export function decodeFieldValue(definition, raw) {
|
|
44
|
+
if (raw === undefined || raw === null)
|
|
45
|
+
return null;
|
|
46
|
+
if (JSON_KINDS.has(definition.kind)) {
|
|
47
|
+
if (typeof raw !== 'string')
|
|
48
|
+
return raw;
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(raw);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Never throw while reading: a document stored by an older version, or by
|
|
54
|
+
// hand, must still be recoverable through the admin.
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// MySQL returns 0/1, Postgres a real boolean, SQLite an integer.
|
|
59
|
+
if (definition.kind === 'boolean')
|
|
60
|
+
return Boolean(Number(raw));
|
|
61
|
+
if (definition.kind === 'number')
|
|
62
|
+
return Number(raw);
|
|
63
|
+
return typeof raw === 'string' ? raw : String(raw);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validates an input against the collection and splits it into what goes where.
|
|
67
|
+
*
|
|
68
|
+
* `required` is checked here rather than by the column, so that a draft can be
|
|
69
|
+
* saved half-written and only publication has to be complete.
|
|
70
|
+
*/
|
|
71
|
+
export function normaliseValues(collection, input, options) {
|
|
72
|
+
const columns = {};
|
|
73
|
+
const relations = {};
|
|
74
|
+
const values = {};
|
|
75
|
+
for (const key of Object.keys(input)) {
|
|
76
|
+
if (collection.fields[key] === undefined) {
|
|
77
|
+
throw invalid(`"${key}" is not a field of the "${collection.name}" collection.`, 'Check the field name against the schema, or add it and generate a migration.', { collection: collection.name, field: key });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const [name, definition] of Object.entries(collection.fields)) {
|
|
81
|
+
if (definition.kind === 'blocks')
|
|
82
|
+
continue;
|
|
83
|
+
const provided = Object.hasOwn(input, name);
|
|
84
|
+
if (!provided && options.partial)
|
|
85
|
+
continue;
|
|
86
|
+
const raw = provided ? input[name] : definition.default;
|
|
87
|
+
const many = definition.kind === 'relation' && definition.options['many'] === true;
|
|
88
|
+
if (raw === undefined || raw === null) {
|
|
89
|
+
if (definition.required === true && options.enforceRequired) {
|
|
90
|
+
throw invalid(`"${name}" is required on "${collection.name}".`, 'Give the field a value, or make it optional in the schema.', { collection: collection.name, field: name });
|
|
91
|
+
}
|
|
92
|
+
if (many) {
|
|
93
|
+
relations[name] = [];
|
|
94
|
+
values[name] = [];
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
columns[name] = null;
|
|
98
|
+
values[name] = null;
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (definition.validate !== undefined) {
|
|
103
|
+
const verdict = definition.validate(raw);
|
|
104
|
+
if (verdict !== true) {
|
|
105
|
+
throw invalid(`"${name}" is not valid: ${verdict}`, 'Correct the value and try again.', {
|
|
106
|
+
collection: collection.name,
|
|
107
|
+
field: name,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (many) {
|
|
112
|
+
if (!Array.isArray(raw)) {
|
|
113
|
+
throw invalid(`"${name}" is a to-many relation, so it expects an array of ids.`, 'Pass the ids of the related entries, in the order they should appear.', { collection: collection.name, field: name });
|
|
114
|
+
}
|
|
115
|
+
const ids = raw.map((item) => {
|
|
116
|
+
if (typeof item !== 'string') {
|
|
117
|
+
throw invalid(`"${name}" expects entry ids, and one of them is not a string.`, 'A relation holds identifiers, never whole entries.', { collection: collection.name, field: name });
|
|
118
|
+
}
|
|
119
|
+
return item;
|
|
120
|
+
});
|
|
121
|
+
// Duplicates would break the join table's primary key, and mean nothing.
|
|
122
|
+
relations[name] = [...new Set(ids)];
|
|
123
|
+
values[name] = relations[name];
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
columns[name] = encodeFieldValue(name, definition, raw);
|
|
127
|
+
values[name] = decodeFieldValue(definition, columns[name]);
|
|
128
|
+
}
|
|
129
|
+
return { columns, relations, values };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks a block zone and gives every block a `_key`.
|
|
133
|
+
*
|
|
134
|
+
* A key supplied by the caller is kept, always: it is what ties a block to its
|
|
135
|
+
* previous self across a diff, a comment and a RAG chunk. One is only minted for
|
|
136
|
+
* a block that has never been stored.
|
|
137
|
+
*/
|
|
138
|
+
export function normaliseBlocks(collection, zones, newKey = uuidv7) {
|
|
139
|
+
const normalised = {};
|
|
140
|
+
for (const [zone, blocks] of Object.entries(zones)) {
|
|
141
|
+
const definition = collection.fields[zone];
|
|
142
|
+
if (definition === undefined || definition.kind !== 'blocks') {
|
|
143
|
+
throw invalid(`"${zone}" is not a block zone of "${collection.name}".`, 'A block zone is a field declared with f.blocks().', { collection: collection.name, field: zone });
|
|
144
|
+
}
|
|
145
|
+
const seen = new Set();
|
|
146
|
+
normalised[zone] = blocks.map((block) => {
|
|
147
|
+
if (typeof block.type !== 'string' || block.type.length === 0) {
|
|
148
|
+
throw invalid(`A block in "${zone}" has no type.`, 'Every block declares which block of the vocabulary it is.', { collection: collection.name, field: zone });
|
|
149
|
+
}
|
|
150
|
+
const key = block.key !== undefined && block.key !== '' ? block.key : newKey();
|
|
151
|
+
if (seen.has(key)) {
|
|
152
|
+
throw invalid(`Two blocks in "${zone}" share the key "${key}".`, 'A block key is unique inside its zone: it is how a block is followed across versions.', { collection: collection.name, field: zone, key });
|
|
153
|
+
}
|
|
154
|
+
seen.add(key);
|
|
155
|
+
return { key, type: block.type, data: block.data ?? {} };
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return normalised;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/store/values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAI1C;;;;;;;GAOG;AAEH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;AAEvD,SAAS,OAAO,CAAC,OAAe,EAAE,IAAY,EAAE,OAAgC;IAC9E,OAAO,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAC9E,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,KAAa,EACb,UAA2B,EAC3B,KAAc;IAEd,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAA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,IAAI,EAAE,CAC7C,CAAA;YACH,CAAC;YAED,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;YAC9E,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClB,MAAM,OAAO,CACX,kBAAkB,IAAI,oBAAoB,GAAG,IAAI,EACjD,uFAAuF,EACvF,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAClD,CAAA;YACH,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAEb,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,CAAA;QAC1D,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Contract A § "Champs système". Present on every entry of every collection,
|
|
4
|
+
* never declared by the author, never optional.
|
|
5
|
+
*
|
|
6
|
+
* `provenance` least of all: the European AI framework requires knowing whether
|
|
7
|
+
* a piece of content was written, assisted or generated, so it exists from the
|
|
8
|
+
* first migration rather than being retrofitted once there is content.
|
|
9
|
+
*
|
|
10
|
+
* These are not `FieldDefinition`s. They are not authored, not translated, not
|
|
11
|
+
* validated against user options — describing them as ordinary fields would let
|
|
12
|
+
* a collection redeclare one, which is exactly what `defineCollection` refuses.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SYSTEM_FIELD_NAMES: readonly ['id', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy', 'status', 'locale', 'translationOf', 'version', 'provenance', 'provenanceDetail'];
|
|
15
|
+
export type SystemFieldName = (typeof SYSTEM_FIELD_NAMES)[number];
|
|
16
|
+
export declare function isSystemFieldName(name: string): name is SystemFieldName;
|
|
17
|
+
export declare const provenanceDetailSchema: z.ZodObject<{
|
|
18
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
19
|
+
model: z.ZodOptional<z.ZodString>;
|
|
20
|
+
at: z.ZodOptional<z.ZodISODateTime>;
|
|
21
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
export declare const systemFieldsSchema: z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
createdAt: z.ZodISODateTime;
|
|
26
|
+
updatedAt: z.ZodISODateTime;
|
|
27
|
+
createdBy: z.ZodNullable<z.ZodString>;
|
|
28
|
+
updatedBy: z.ZodNullable<z.ZodString>;
|
|
29
|
+
status: z.ZodEnum<{
|
|
30
|
+
archived: "archived";
|
|
31
|
+
draft: "draft";
|
|
32
|
+
published: "published";
|
|
33
|
+
scheduled: "scheduled";
|
|
34
|
+
}>;
|
|
35
|
+
locale: z.ZodString;
|
|
36
|
+
translationOf: z.ZodNullable<z.ZodString>;
|
|
37
|
+
version: z.ZodNumber;
|
|
38
|
+
provenance: z.ZodEnum<{
|
|
39
|
+
assisted: "assisted";
|
|
40
|
+
generated: "generated";
|
|
41
|
+
human: "human";
|
|
42
|
+
}>;
|
|
43
|
+
provenanceDetail: z.ZodNullable<z.ZodObject<{
|
|
44
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
45
|
+
model: z.ZodOptional<z.ZodString>;
|
|
46
|
+
at: z.ZodOptional<z.ZodISODateTime>;
|
|
47
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
/** How the admin renders a system column. Mirrors `systemFieldsSchema`. */
|
|
51
|
+
export interface SystemFieldDescriptor {
|
|
52
|
+
readonly name: SystemFieldName;
|
|
53
|
+
readonly type: 'id' | 'datetime' | 'enum' | 'string' | 'number' | 'json';
|
|
54
|
+
readonly nullable: boolean;
|
|
55
|
+
/** Never writable by an editor: the runtime owns every one of these. */
|
|
56
|
+
readonly readOnly: true;
|
|
57
|
+
readonly values?: readonly string[];
|
|
58
|
+
}
|
|
59
|
+
export declare const SYSTEM_FIELD_DESCRIPTORS: readonly SystemFieldDescriptor[];
|
|
60
|
+
//# sourceMappingURL=system-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-fields.d.ts","sourceRoot":"","sources":["../src/system-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,kBAAkB,YAC7B,IAAI,EACJ,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,SAAS,EACT,YAAY,EACZ,kBAAkB,CACV,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAIjE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAEvE;AAED,eAAO,MAAM,sBAAsB;;;;;kBAMjC,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAc7B,CAAA;AAEF,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACpC;AAED,eAAO,MAAM,wBAAwB,EAAE,SAAS,qBAAqB,EAkBpE,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CONTENT_STATUSES, PROVENANCE_KINDS } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Contract A § "Champs système". Present on every entry of every collection,
|
|
5
|
+
* never declared by the author, never optional.
|
|
6
|
+
*
|
|
7
|
+
* `provenance` least of all: the European AI framework requires knowing whether
|
|
8
|
+
* a piece of content was written, assisted or generated, so it exists from the
|
|
9
|
+
* first migration rather than being retrofitted once there is content.
|
|
10
|
+
*
|
|
11
|
+
* These are not `FieldDefinition`s. They are not authored, not translated, not
|
|
12
|
+
* validated against user options — describing them as ordinary fields would let
|
|
13
|
+
* a collection redeclare one, which is exactly what `defineCollection` refuses.
|
|
14
|
+
*/
|
|
15
|
+
export const SYSTEM_FIELD_NAMES = [
|
|
16
|
+
'id',
|
|
17
|
+
'createdAt',
|
|
18
|
+
'updatedAt',
|
|
19
|
+
'createdBy',
|
|
20
|
+
'updatedBy',
|
|
21
|
+
'status',
|
|
22
|
+
'locale',
|
|
23
|
+
'translationOf',
|
|
24
|
+
'version',
|
|
25
|
+
'provenance',
|
|
26
|
+
'provenanceDetail',
|
|
27
|
+
];
|
|
28
|
+
const SYSTEM_FIELD_NAME_SET = new Set(SYSTEM_FIELD_NAMES);
|
|
29
|
+
export function isSystemFieldName(name) {
|
|
30
|
+
return SYSTEM_FIELD_NAME_SET.has(name);
|
|
31
|
+
}
|
|
32
|
+
export const provenanceDetailSchema = z.strictObject({
|
|
33
|
+
agent: z.string().optional(),
|
|
34
|
+
model: z.string().optional(),
|
|
35
|
+
at: z.iso.datetime({ offset: true }).optional(),
|
|
36
|
+
/** Kept for audit. Never rendered, never handed back to a model (rule R7). */
|
|
37
|
+
prompt: z.string().optional(),
|
|
38
|
+
});
|
|
39
|
+
export const systemFieldsSchema = z.object({
|
|
40
|
+
id: z.string().min(1),
|
|
41
|
+
createdAt: z.iso.datetime({ offset: true }),
|
|
42
|
+
updatedAt: z.iso.datetime({ offset: true }),
|
|
43
|
+
createdBy: z.string().min(1).nullable(),
|
|
44
|
+
updatedBy: z.string().min(1).nullable(),
|
|
45
|
+
status: z.enum(CONTENT_STATUSES),
|
|
46
|
+
/** Contract A § i18n: one entry per locale (ADR-0014). */
|
|
47
|
+
locale: z.string().min(1),
|
|
48
|
+
/** The source entry of a translation family, or `null` on the source itself. */
|
|
49
|
+
translationOf: z.string().min(1).nullable(),
|
|
50
|
+
version: z.number().int().min(1),
|
|
51
|
+
provenance: z.enum(PROVENANCE_KINDS),
|
|
52
|
+
provenanceDetail: provenanceDetailSchema.nullable(),
|
|
53
|
+
});
|
|
54
|
+
export const SYSTEM_FIELD_DESCRIPTORS = [
|
|
55
|
+
{ name: 'id', type: 'id', nullable: false, readOnly: true },
|
|
56
|
+
{ name: 'createdAt', type: 'datetime', nullable: false, readOnly: true },
|
|
57
|
+
{ name: 'updatedAt', type: 'datetime', nullable: false, readOnly: true },
|
|
58
|
+
{ name: 'createdBy', type: 'id', nullable: true, readOnly: true },
|
|
59
|
+
{ name: 'updatedBy', type: 'id', nullable: true, readOnly: true },
|
|
60
|
+
{ name: 'status', type: 'enum', nullable: false, readOnly: true, values: CONTENT_STATUSES },
|
|
61
|
+
{ name: 'locale', type: 'string', nullable: false, readOnly: true },
|
|
62
|
+
{ name: 'translationOf', type: 'id', nullable: true, readOnly: true },
|
|
63
|
+
{ name: 'version', type: 'number', nullable: false, readOnly: true },
|
|
64
|
+
{
|
|
65
|
+
name: 'provenance',
|
|
66
|
+
type: 'enum',
|
|
67
|
+
nullable: false,
|
|
68
|
+
readOnly: true,
|
|
69
|
+
values: PROVENANCE_KINDS,
|
|
70
|
+
},
|
|
71
|
+
{ name: 'provenanceDetail', type: 'json', nullable: true, readOnly: true },
|
|
72
|
+
];
|
|
73
|
+
//# sour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AE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACjE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE;IAC3F,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;IACnE,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACrE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;IACpE;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,gBAAgB;KACzB;IACD,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;CAC3E,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the content engine is built on.
|
|
3
|
+
*
|
|
4
|
+
* This file is the seam between `@cogenta/schema`, `@cogenta/blocks` and
|
|
5
|
+
* `@cogenta/api`: it declares what a field and a collection *are*, so the three
|
|
6
|
+
* packages can be built against the same shapes rather than against each other.
|
|
7
|
+
*
|
|
8
|
+
* It implements contract A, frozen at `schema@1.0` on 2026-08-13. Every
|
|
9
|
+
* departure from the contract text is a bug in this file, not a liberty.
|
|
10
|
+
*/
|
|
11
|
+
/** Contract A, "Types de champ (v1)". Closed set: adding one is a minor version. */
|
|
12
|
+
export declare const FIELD_KINDS: readonly ['text', 'richText', 'slug', 'number', 'boolean', 'date', 'datetime', 'media', 'relation', 'select', 'json', 'geo', 'color', 'blocks'];
|
|
13
|
+
export type FieldKind = (typeof FIELD_KINDS)[number];
|
|
14
|
+
/** Contract A, "Permissions". Actions are fixed; role names are an open set. */
|
|
15
|
+
export declare const CONTENT_ACTIONS: readonly ['read', 'create', 'update', 'delete', 'publish'];
|
|
16
|
+
export type ContentAction = (typeof CONTENT_ACTIONS)[number];
|
|
17
|
+
export declare const CONTENT_STATUSES: readonly ['draft', 'scheduled', 'published', 'archived'];
|
|
18
|
+
export type ContentStatus = (typeof CONTENT_STATUSES)[number];
|
|
19
|
+
export declare const PROVENANCE_KINDS: readonly ['human', 'assisted', 'generated'];
|
|
20
|
+
export type Provenance = (typeof PROVENANCE_KINDS)[number];
|
|
21
|
+
/** What the admin needs to render a field, and nothing the engine needs. */
|
|
22
|
+
export interface FieldAdminOptions {
|
|
23
|
+
readonly label?: string;
|
|
24
|
+
readonly help?: string;
|
|
25
|
+
readonly group?: string;
|
|
26
|
+
/** Show this field only when another field holds a given value. */
|
|
27
|
+
readonly showWhen?: {
|
|
28
|
+
readonly field: string;
|
|
29
|
+
readonly equals: unknown;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface BaseFieldOptions {
|
|
33
|
+
readonly required?: boolean;
|
|
34
|
+
readonly default?: unknown;
|
|
35
|
+
/**
|
|
36
|
+
* Declares that this field is translated.
|
|
37
|
+
*
|
|
38
|
+
* **Not a storage directive** (ADR-0014): content is stored one entry per
|
|
39
|
+
* locale. This tells the admin the field is worth translating, so it can
|
|
40
|
+
* offer to copy it from the source entry.
|
|
41
|
+
*/
|
|
42
|
+
readonly localized?: boolean;
|
|
43
|
+
readonly unique?: boolean;
|
|
44
|
+
readonly validate?: (value: unknown) => true | string;
|
|
45
|
+
readonly admin?: FieldAdminOptions;
|
|
46
|
+
}
|
|
47
|
+
/** What happens to a referencing row when the target is deleted. */
|
|
48
|
+
export type OnDelete = 'restrict' | 'cascade' | 'setNull';
|
|
49
|
+
export interface FieldDefinition extends BaseFieldOptions {
|
|
50
|
+
readonly kind: FieldKind;
|
|
51
|
+
/** Kind-specific settings: `max`, `to`, `many`, `accept`, `options`, `from`… */
|
|
52
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
53
|
+
}
|
|
54
|
+
export interface CollectionRouting {
|
|
55
|
+
readonly pattern: string;
|
|
56
|
+
/** Prefix the route with the locale. */
|
|
57
|
+
readonly locale?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface CollectionVersioning {
|
|
60
|
+
readonly drafts?: boolean;
|
|
61
|
+
readonly history?: boolean;
|
|
62
|
+
/** Versions kept per entry. Unlimited history is a slow leak, not a feature. */
|
|
63
|
+
readonly keep?: number;
|
|
64
|
+
}
|
|
65
|
+
export type CollectionPermissions = Readonly<Partial<Record<ContentAction, readonly string[]>>>;
|
|
66
|
+
export interface CollectionDefinition {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly labels: {
|
|
69
|
+
readonly singular: string;
|
|
70
|
+
readonly plural: string;
|
|
71
|
+
};
|
|
72
|
+
readonly routing?: CollectionRouting;
|
|
73
|
+
readonly versioning?: CollectionVersioning;
|
|
74
|
+
readonly fields: Readonly<Record<string, FieldDefinition>>;
|
|
75
|
+
readonly indexes?: readonly (readonly string[])[];
|
|
76
|
+
readonly permissions: CollectionPermissions;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Contract A, "Champs système". Present on every entry, never declared by the
|
|
80
|
+
* user, never optional — `provenance` least of all: the European AI framework
|
|
81
|
+
* requires it, so it exists from the first migration.
|
|
82
|
+
*/
|
|
83
|
+
export interface SystemFields {
|
|
84
|
+
readonly id: string;
|
|
85
|
+
readonly createdAt: string;
|
|
86
|
+
readonly updatedAt: string;
|
|
87
|
+
readonly createdBy: string | null;
|
|
88
|
+
readonly updatedBy: string | null;
|
|
89
|
+
readonly status: ContentStatus;
|
|
90
|
+
readonly locale: string;
|
|
91
|
+
readonly translationOf: string | null;
|
|
92
|
+
readonly version: number;
|
|
93
|
+
readonly provenance: Provenance;
|
|
94
|
+
readonly provenanceDetail: {
|
|
95
|
+
readonly agent?: string;
|
|
96
|
+
readonly model?: string;
|
|
97
|
+
readonly at?: string;
|
|
98
|
+
readonly prompt?: string;
|
|
99
|
+
} | null;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,oFAAoF;AACpF,eAAO,MAAM,WAAW,YACtB,MAAM,EACN,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,MAAM,EACN,UAAU,EACV,OAAO,EACP,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACL,OAAO,EACP,QAAQ,CACA,CAAA;AAEV,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpD,gFAAgF;AAChF,eAAO,MAAM,eAAe,YAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAA;AAEzF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AAE5D,eAAO,MAAM,gBAAgB,YAAI,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,CAAU,CAAA;AAExF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE7D,eAAO,MAAM,gBAAgB,YAAI,OAAO,EAAE,UAAU,EAAE,WAAW,CAAU,CAAA;AAE3E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CA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AC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IAC/B,QAAQ,CAAC,gBAAgB,EAAE;QACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;QACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;QACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KACzB,GAAG,IAAI,CAAA;CACT"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the content engine is built on.
|
|
3
|
+
*
|
|
4
|
+
* This file is the seam between `@cogenta/schema`, `@cogenta/blocks` and
|
|
5
|
+
* `@cogenta/api`: it declares what a field and a collection *are*, so the three
|
|
6
|
+
* packages can be built against the same shapes rather than against each other.
|
|
7
|
+
*
|
|
8
|
+
* It implements contract A, frozen at `schema@1.0` on 2026-08-13. Every
|
|
9
|
+
* departure from the contract text is a bug in this file, not a liberty.
|
|
10
|
+
*/
|
|
11
|
+
/** Contract A, "Types de champ (v1)". Closed set: adding one is a minor version. */
|
|
12
|
+
export const FIELD_KINDS = [
|
|
13
|
+
'text',
|
|
14
|
+
'richText',
|
|
15
|
+
'slug',
|
|
16
|
+
'number',
|
|
17
|
+
'boolean',
|
|
18
|
+
'date',
|
|
19
|
+
'datetime',
|
|
20
|
+
'media',
|
|
21
|
+
'relation',
|
|
22
|
+
'select',
|
|
23
|
+
'json',
|
|
24
|
+
'geo',
|
|
25
|
+
'color',
|
|
26
|
+
'blocks',
|
|
27
|
+
];
|
|
28
|
+
/** Contract A, "Permissions". Actions are fixed; role names are an open set. */
|
|
29
|
+
export const CONTENT_ACTIONS = ['read', 'create', 'update', 'delete', 'publish'];
|
|
30
|
+
export const CONTENT_STATUSES = ['draft', 'scheduled', 'published', 'archived'];
|
|
31
|
+
export const PROVENANCE_KINDS = ['human', 'assisted', 'generated'];
|
|
32
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM;IACN,UAAU;IACV,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,UAAU;IACV,OAAO;IACP,UAAU;IACV,QAAQ;IACR,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;CACA,CAAA;AAIV,gFAAgF;AAChF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAA;AAIzF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,CAAU,CAAA;AAIxF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAU,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CollectionDefinition, FieldDefinition } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Turns a field definition into the validator that guards every write.
|
|
5
|
+
*
|
|
6
|
+
* One validator derived from the schema, never a second hand-written one: the
|
|
7
|
+
* schema is the single source of truth (L1 § "Génération"), and a validator
|
|
8
|
+
* that drifts from it is worse than no validator at all.
|
|
9
|
+
*/
|
|
10
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
11
|
+
[key: string]: JsonValue;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Written out rather than taken from Zod's helper: a `json` column must hold
|
|
15
|
+
* what `JSON.parse` can return and nothing else — no `undefined`, no `Date`,
|
|
16
|
+
* no class instance that would come back as `{}` after a round-trip.
|
|
17
|
+
*/
|
|
18
|
+
export declare const jsonValueSchema: z.ZodType<JsonValue>;
|
|
19
|
+
export declare const geoPointSchema: z.ZodObject<{
|
|
20
|
+
lat: z.ZodNumber;
|
|
21
|
+
lng: z.ZodNumber;
|
|
22
|
+
label: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export type GeoPoint = z.infer<typeof geoPointSchema>;
|
|
25
|
+
/** Lowercase words joined by single hyphens: what a URL segment may contain. */
|
|
26
|
+
export declare const SLUG_PATTERN: RegExp;
|
|
27
|
+
/** `#rgb`, `#rrggbb` or `#rrggbbaa`. A colour is data, never a CSS value (R3). */
|
|
28
|
+
export declare const COLOR_PATTERN: RegExp;
|
|
29
|
+
export declare const contentBlockSchema: z.ZodObject<{
|
|
30
|
+
_key: z.ZodString;
|
|
31
|
+
_type: z.ZodString;
|
|
32
|
+
}, z.core.$loose>;
|
|
33
|
+
/**
|
|
34
|
+
* The raw `_key`/`_type` wire envelope a `blocks` field accepts on write —
|
|
35
|
+
* distinct from the store's `ContentBlock` (`store/types.ts`, the normalised
|
|
36
|
+
* `key`/`type`/`data` shape `BlockZones` holds after `values.ts` unwraps
|
|
37
|
+
* this). Two types sharing the name `ContentBlock` used to collide in this
|
|
38
|
+
* package's public exports, with this one silently winning over the store's
|
|
39
|
+
* via `export *` — renamed so both are reachable under their own name.
|
|
40
|
+
*/
|
|
41
|
+
export type RawBlockInput = z.infer<typeof contentBlockSchema>;
|
|
42
|
+
export declare function isCollectionValued(field: FieldDefinition): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The validator for one field, custom rule and optionality included.
|
|
45
|
+
*
|
|
46
|
+
* An optional field accepts `null` and an absent key alike: a form that never
|
|
47
|
+
* showed the field and a form that cleared it mean the same thing to storage.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fieldSchema(field: FieldDefinition): z.ZodType;
|
|
50
|
+
/** What an author may send: the declared fields, and nothing else. */
|
|
51
|
+
export declare function collectionInputSchema(collection: CollectionDefinition): z.ZodType;
|
|
52
|
+
/** A stored entry: system fields plus the declared ones. */
|
|
53
|
+
export declare function collectionEntrySchema(collection: CollectionDefinition): z.ZodType;
|
|
54
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEvE;;;;;;GAMG;AAEH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAEhC;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAShD,CAAA;AAED,eAAO,MAAM,cAAc;;;;kBAIzB,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAErD,gFAAgF;AAChF,eAAO,MAAM,YAAY,QAA+B,CAAA;AAExD,kFAAkF;AAClF,eAAO,MAAM,aAAa,QAAwD,CAAA;AAElF,eAAO,MAAM,kBAAkB;;;iBAI7B,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAiC9D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAIlE;AAyED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,CAAC,CAAC,OAAO,CAoB7D;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,oBAAoB,GAAG,CAAC,CAAC,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