@v7-cms/core 0.0.0-alpha.9
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/body-mode.d.ts +35 -0
- package/dist/body-mode.d.ts.map +1 -0
- package/dist/body-mode.js +116 -0
- package/dist/body-mode.js.map +1 -0
- package/dist/config-load.d.ts +106 -0
- package/dist/config-load.d.ts.map +1 -0
- package/dist/config-load.js +193 -0
- package/dist/config-load.js.map +1 -0
- package/dist/config.d.ts +148 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/fields-builtin.d.ts +21 -0
- package/dist/fields-builtin.d.ts.map +1 -0
- package/dist/fields-builtin.js +240 -0
- package/dist/fields-builtin.js.map +1 -0
- package/dist/fields.d.ts +84 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +10 -0
- package/dist/fields.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/serialize/entry.d.ts +64 -0
- package/dist/serialize/entry.d.ts.map +1 -0
- package/dist/serialize/entry.js +151 -0
- package/dist/serialize/entry.js.map +1 -0
- package/dist/serialize/index.d.ts +2 -0
- package/dist/serialize/index.d.ts.map +1 -0
- package/dist/serialize/index.js +2 -0
- package/dist/serialize/index.js.map +1 -0
- package/dist/storage/types.d.ts +97 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +14 -0
- package/dist/storage/types.js.map +1 -0
- package/package.json +59 -0
- package/schema/config.json +171 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in field types.
|
|
3
|
+
*
|
|
4
|
+
* These are value-level only: how to read the stored form, how to write it back, and what counts
|
|
5
|
+
* as empty. The visual controls live in `@v7-cms/cms`, which is what keeps this package usable
|
|
6
|
+
* from a Node script.
|
|
7
|
+
*/
|
|
8
|
+
import type { FieldSpec, FieldType, ValidationIssue } from './fields.js';
|
|
9
|
+
/** Registered by name so configs can refer to a type the CMS knows about. */
|
|
10
|
+
export declare const builtInFields: FieldType<never>[];
|
|
11
|
+
/** Add a field type. Consumers call this to extend the CMS with their own. */
|
|
12
|
+
export declare function registerFieldType(field: FieldType<never>): void;
|
|
13
|
+
export declare function getFieldType(name: string): FieldType<never> | undefined;
|
|
14
|
+
export declare function fieldTypeNames(): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Validate one value against one field's spec. Used by the field types above for nested values,
|
|
17
|
+
* and by the editor for top-level ones, so a `required` inside a list item behaves exactly like
|
|
18
|
+
* one at the top level.
|
|
19
|
+
*/
|
|
20
|
+
export declare function runFieldValidation(field: FieldSpec, value: unknown, path: string, siblings: Readonly<Record<string, unknown>>): ValidationIssue[];
|
|
21
|
+
//# sourceMappingURL=fields-builtin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields-builtin.d.ts","sourceRoot":"","sources":["../src/fields-builtin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAa,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAyNpF,6EAA6E;AAC7E,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,KAAK,CAAC,EAW3C,CAAC;AAIF,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAE/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAEvE;AAED,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,eAAe,EAAE,CAInB"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
const isBlank = (value) => value === undefined || value === null || (typeof value === 'string' && value.trim() === '');
|
|
2
|
+
/** Shared validation for the `required` flag, so every type reports it the same way. */
|
|
3
|
+
function requiredIssue(value, options, path) {
|
|
4
|
+
if (options.required !== true)
|
|
5
|
+
return [];
|
|
6
|
+
if (Array.isArray(value) ? value.length === 0 : isBlank(value)) {
|
|
7
|
+
return [
|
|
8
|
+
{ level: 'error', message: `${options.label ?? options.name} is required.`, path: path.path },
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
function checkPattern(value, options, path) {
|
|
14
|
+
if (typeof value !== 'string' || !options.pattern)
|
|
15
|
+
return [];
|
|
16
|
+
const [source, message] = options.pattern;
|
|
17
|
+
if (new RegExp(source).test(value))
|
|
18
|
+
return [];
|
|
19
|
+
return [{ level: 'error', message: message || `Does not match ${source}.`, path: path.path }];
|
|
20
|
+
}
|
|
21
|
+
const string = {
|
|
22
|
+
name: 'string',
|
|
23
|
+
isEmpty: isBlank,
|
|
24
|
+
validate: (value, options, path) => [
|
|
25
|
+
...requiredIssue(value, options, path),
|
|
26
|
+
...checkPattern(value, options, path),
|
|
27
|
+
],
|
|
28
|
+
summary: (value) => value,
|
|
29
|
+
defaultValue: () => '',
|
|
30
|
+
};
|
|
31
|
+
const text = {
|
|
32
|
+
...string,
|
|
33
|
+
name: 'text',
|
|
34
|
+
};
|
|
35
|
+
/** Numbers may arrive as strings from YAML, so they are coerced on read and written as numbers. */
|
|
36
|
+
const number = {
|
|
37
|
+
name: 'number',
|
|
38
|
+
isEmpty: (value) => value === undefined || value === null || Number.isNaN(value),
|
|
39
|
+
toValue: (stored) => {
|
|
40
|
+
if (typeof stored !== 'string')
|
|
41
|
+
return stored;
|
|
42
|
+
const parsed = Number(stored.trim());
|
|
43
|
+
return stored.trim() === '' || Number.isNaN(parsed) ? 0 : parsed;
|
|
44
|
+
},
|
|
45
|
+
toStored: (value) => value,
|
|
46
|
+
validate: (value, options, path) => {
|
|
47
|
+
const issues = requiredIssue(value, options, path);
|
|
48
|
+
if (value !== undefined && value !== null && typeof value === 'number' && Number.isNaN(value)) {
|
|
49
|
+
issues.push({
|
|
50
|
+
level: 'error',
|
|
51
|
+
message: `${options.label ?? options.name} must be a number.`,
|
|
52
|
+
path: path.path,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return issues;
|
|
56
|
+
},
|
|
57
|
+
summary: (value) => String(value),
|
|
58
|
+
defaultValue: () => 0,
|
|
59
|
+
};
|
|
60
|
+
const boolean = {
|
|
61
|
+
name: 'boolean',
|
|
62
|
+
// `false` is a real value, not an absence — writing it is meaningful for a flag like `draft`.
|
|
63
|
+
isEmpty: (value) => value === undefined || value === null,
|
|
64
|
+
validate: () => [],
|
|
65
|
+
summary: (value) => (value ? 'true' : 'false'),
|
|
66
|
+
defaultValue: () => false,
|
|
67
|
+
};
|
|
68
|
+
const select = {
|
|
69
|
+
name: 'select',
|
|
70
|
+
isEmpty: isBlank,
|
|
71
|
+
validate: (value, options, path) => {
|
|
72
|
+
const issues = requiredIssue(value, options, path);
|
|
73
|
+
if (isBlank(value))
|
|
74
|
+
return issues;
|
|
75
|
+
const allowed = (options.options ?? []).map((option) => typeof option === 'string' ? option : option.value);
|
|
76
|
+
if (allowed.length && !allowed.includes(value)) {
|
|
77
|
+
issues.push({
|
|
78
|
+
level: 'error',
|
|
79
|
+
message: `${options.label ?? options.name} must be one of: ${allowed.join(', ')}.`,
|
|
80
|
+
path: path.path,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return issues;
|
|
84
|
+
},
|
|
85
|
+
summary: (value) => value,
|
|
86
|
+
defaultValue: () => '',
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Dates keep the value the file used. The blog's frontmatter writes `'2026-09-12'` as a quoted
|
|
90
|
+
* string and full timestamps elsewhere, and both must survive, so this type does not normalise
|
|
91
|
+
* to a `Date`.
|
|
92
|
+
*/
|
|
93
|
+
const datetime = {
|
|
94
|
+
name: 'datetime',
|
|
95
|
+
isEmpty: isBlank,
|
|
96
|
+
validate: (value, options, path) => {
|
|
97
|
+
const issues = requiredIssue(value, options, path);
|
|
98
|
+
if (isBlank(value))
|
|
99
|
+
return issues;
|
|
100
|
+
if (Number.isNaN(new Date(String(value)).getTime())) {
|
|
101
|
+
issues.push({
|
|
102
|
+
level: 'error',
|
|
103
|
+
message: `${options.label ?? options.name} must be a valid date.`,
|
|
104
|
+
path: path.path,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return issues;
|
|
108
|
+
},
|
|
109
|
+
summary: (value) => value,
|
|
110
|
+
defaultValue: () => '',
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* A list. Two shapes, matching how the configs are written: `field` for a list of scalars
|
|
114
|
+
* (`tags: ['a', 'b']`), and `fields` for a list of objects (`images: [{ src, alt, … }]`).
|
|
115
|
+
* Both validate their items and report the offending item's path.
|
|
116
|
+
*/
|
|
117
|
+
const list = {
|
|
118
|
+
name: 'list',
|
|
119
|
+
isEmpty: (value) => !Array.isArray(value) || value.length === 0,
|
|
120
|
+
validate: (value, options, path) => {
|
|
121
|
+
const issues = requiredIssue(value, options, path);
|
|
122
|
+
if (!Array.isArray(value))
|
|
123
|
+
return issues;
|
|
124
|
+
const itemFields = options.fields ?? (options.field ? [options.field] : []);
|
|
125
|
+
if (itemFields.length === 0)
|
|
126
|
+
return issues;
|
|
127
|
+
value.forEach((item, index) => {
|
|
128
|
+
const itemPath = `${path.path}.${index}`;
|
|
129
|
+
// A list of objects validates each declared field against the item's own keys.
|
|
130
|
+
const targets = options.fields
|
|
131
|
+
? itemFields.map((field) => ({
|
|
132
|
+
field,
|
|
133
|
+
value: item?.[field.name],
|
|
134
|
+
at: `${itemPath}.${field.name}`,
|
|
135
|
+
}))
|
|
136
|
+
: [{ field: itemFields[0], value: item, at: itemPath }];
|
|
137
|
+
for (const target of targets) {
|
|
138
|
+
issues.push(...runFieldValidation(target.field, target.value, target.at, path.siblings));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return issues;
|
|
142
|
+
},
|
|
143
|
+
summary: (value) => `${value.length} item${value.length === 1 ? '' : 's'}`,
|
|
144
|
+
defaultValue: () => [],
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* A nested object. `collapseEmpty` is what keeps an all-blank sub-object out of the file —
|
|
148
|
+
* the browser CMS wrote `cover:` with nothing under it, which the site's schema rejects.
|
|
149
|
+
*/
|
|
150
|
+
const object = {
|
|
151
|
+
name: 'object',
|
|
152
|
+
isEmpty: (value, options) => {
|
|
153
|
+
if (!value || typeof value !== 'object')
|
|
154
|
+
return true;
|
|
155
|
+
const entries = Object.entries(value);
|
|
156
|
+
if (entries.length === 0)
|
|
157
|
+
return true;
|
|
158
|
+
if (options?.collapseEmpty !== true)
|
|
159
|
+
return false;
|
|
160
|
+
return entries.every(([, item]) => isBlank(item) || (Array.isArray(item) && item.length === 0));
|
|
161
|
+
},
|
|
162
|
+
validate: (value, options, path) => {
|
|
163
|
+
const issues = [];
|
|
164
|
+
if (!value || typeof value !== 'object')
|
|
165
|
+
return issues;
|
|
166
|
+
for (const field of options.fields ?? []) {
|
|
167
|
+
issues.push(...runFieldValidation(field, value[field.name], `${path.path}.${field.name}`, path.siblings));
|
|
168
|
+
}
|
|
169
|
+
return issues;
|
|
170
|
+
},
|
|
171
|
+
summary: (value) => Object.keys(value).join(', '),
|
|
172
|
+
defaultValue: () => ({}),
|
|
173
|
+
};
|
|
174
|
+
/** A stored reference, validated only for presence; the consumer decides what values are legal. */
|
|
175
|
+
const relation = {
|
|
176
|
+
name: 'relation',
|
|
177
|
+
isEmpty: isBlank,
|
|
178
|
+
validate: (value, options, path) => requiredIssue(value, options, path),
|
|
179
|
+
summary: (value) => value,
|
|
180
|
+
defaultValue: () => '',
|
|
181
|
+
};
|
|
182
|
+
/** An object of `{ locale: string }` pairs, e.g. `{ "zh-CN": "…", en: "…" }`. */
|
|
183
|
+
const i18nString = {
|
|
184
|
+
name: 'i18n-string',
|
|
185
|
+
isEmpty: (value) => !value || typeof value !== 'object' || Object.values(value).every((item) => isBlank(item)),
|
|
186
|
+
validate: (value, options, path) => {
|
|
187
|
+
const issues = [];
|
|
188
|
+
if (options.required !== true)
|
|
189
|
+
return issues;
|
|
190
|
+
const locales = options.locales ?? ['zh-CN', 'en'];
|
|
191
|
+
for (const locale of locales) {
|
|
192
|
+
if (isBlank(value?.[locale])) {
|
|
193
|
+
issues.push({
|
|
194
|
+
level: 'error',
|
|
195
|
+
message: `${options.label ?? options.name} needs a value for ${locale}.`,
|
|
196
|
+
path: `${path.path}.${locale}`,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return issues;
|
|
201
|
+
},
|
|
202
|
+
summary: (value) => Object.values(value ?? {}).find((item) => !isBlank(item)) ?? '',
|
|
203
|
+
defaultValue: () => ({}),
|
|
204
|
+
};
|
|
205
|
+
/** Registered by name so configs can refer to a type the CMS knows about. */
|
|
206
|
+
export const builtInFields = [
|
|
207
|
+
string,
|
|
208
|
+
text,
|
|
209
|
+
number,
|
|
210
|
+
boolean,
|
|
211
|
+
select,
|
|
212
|
+
datetime,
|
|
213
|
+
list,
|
|
214
|
+
object,
|
|
215
|
+
relation,
|
|
216
|
+
i18nString,
|
|
217
|
+
];
|
|
218
|
+
const registry = new Map(builtInFields.map((field) => [field.name, field]));
|
|
219
|
+
/** Add a field type. Consumers call this to extend the CMS with their own. */
|
|
220
|
+
export function registerFieldType(field) {
|
|
221
|
+
registry.set(field.name, field);
|
|
222
|
+
}
|
|
223
|
+
export function getFieldType(name) {
|
|
224
|
+
return registry.get(name);
|
|
225
|
+
}
|
|
226
|
+
export function fieldTypeNames() {
|
|
227
|
+
return [...registry.keys()].sort();
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Validate one value against one field's spec. Used by the field types above for nested values,
|
|
231
|
+
* and by the editor for top-level ones, so a `required` inside a list item behaves exactly like
|
|
232
|
+
* one at the top level.
|
|
233
|
+
*/
|
|
234
|
+
export function runFieldValidation(field, value, path, siblings) {
|
|
235
|
+
const type = getFieldType(field.widget ?? 'string');
|
|
236
|
+
if (!type?.validate)
|
|
237
|
+
return [];
|
|
238
|
+
return type.validate(value, field, { path, siblings });
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=fields-builtin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields-builtin.js","sourceRoot":"","sources":["../src/fields-builtin.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,GAAG,CAAC,KAAc,EAAW,EAAE,CAC1C,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAE9F,wFAAwF;AACxF,SAAS,aAAa,CAAC,KAAc,EAAE,OAAkB,EAAE,IAAe;IACxE,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACzC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/D,OAAO;YACL,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;SAC9F,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,OAAkB,EAAE,IAAe;IACvE,IAAI,OAAO,KAAK,KAAK,QAAQ,IA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3
|
+
*
|
|
4
|
+
* A field type is the smallest unit of extension: it knows how to read a stored value, how to
|
|
5
|
+
* write it back, and how to validate it. It deliberately says nothing about rendering — that is
|
|
6
|
+
* the widget layer's job (see `packages/cms`), so `core` stays free of DOM and React and can be
|
|
7
|
+
* reused from Node scripts.
|
|
8
|
+
*/
|
|
9
|
+
/** Where a value lives, for error messages and for fields that need sibling values. */
|
|
10
|
+
export interface FieldPath {
|
|
11
|
+
/** Dotted path inside the entry, e.g. `images.0.photo.camera`. */
|
|
12
|
+
readonly path: string;
|
|
13
|
+
/** The entry's raw frontmatter, so a field can consult its siblings. */
|
|
14
|
+
readonly siblings: Readonly<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
export interface ValidationIssue {
|
|
17
|
+
level: 'error' | 'warning';
|
|
18
|
+
message: string;
|
|
19
|
+
/** Dotted path of the offending value; defaults to the field's own path. */
|
|
20
|
+
path?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Options every field shares. Field types extend this with their own. */
|
|
23
|
+
export interface CommonFieldOptions {
|
|
24
|
+
name: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
hint?: string;
|
|
28
|
+
/** Shown in list summaries. Falls back to the field's own `summary()`. */
|
|
29
|
+
widget?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What a field type is handed when asked to validate or summarise. It is the full field spec, not
|
|
33
|
+
* just the common options, so a `list` can see its `fields`, a `select` its `options`, and so on.
|
|
34
|
+
* Declared loosely here because `core` cannot import the config module without a cycle.
|
|
35
|
+
*/
|
|
36
|
+
export interface FieldSpec extends CommonFieldOptions {
|
|
37
|
+
fields?: FieldSpec[];
|
|
38
|
+
field?: FieldSpec;
|
|
39
|
+
options?: Array<string | {
|
|
40
|
+
label: string;
|
|
41
|
+
value: string;
|
|
42
|
+
}>;
|
|
43
|
+
pattern?: [string, string];
|
|
44
|
+
collapseEmpty?: boolean;
|
|
45
|
+
locales?: string[];
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The shape a field type must implement.
|
|
50
|
+
*
|
|
51
|
+
* `TStored` is the value as it appears in the file; `TValue` is the value the editor works with.
|
|
52
|
+
* For most types they are the same and `toValue`/`toStored` can be omitted.
|
|
53
|
+
*/
|
|
54
|
+
export interface FieldType<TValue = unknown, TStored = TValue> {
|
|
55
|
+
/** Registry name, e.g. `string`, `date`, `image`. */
|
|
56
|
+
readonly name: string;
|
|
57
|
+
/**
|
|
58
|
+
* Whether this value should be omitted from the file entirely. Returning true means "the user
|
|
59
|
+
* has not set this", which is what keeps optional keys out of the output rather than writing
|
|
60
|
+
* them as empty strings — the blog's build treats `''` and a missing key differently.
|
|
61
|
+
*/
|
|
62
|
+
isEmpty?(value: TValue): boolean;
|
|
63
|
+
/** File value -> editor value. Omit when the two are identical. */
|
|
64
|
+
toValue?(stored: TStored): TValue;
|
|
65
|
+
/** Editor value -> file value. Omit when the two are identical. */
|
|
66
|
+
toStored?(value: TValue, context: {
|
|
67
|
+
originalStyle?: ScalarStyle;
|
|
68
|
+
}): TStored;
|
|
69
|
+
/** Validation runs on the editor value. */
|
|
70
|
+
validate?(value: TValue, options: FieldSpec, path: FieldPath): ValidationIssue[];
|
|
71
|
+
/** One-line label for the entry list and for collapsed list items. */
|
|
72
|
+
summary?(value: TValue, options: FieldSpec): string;
|
|
73
|
+
/** A value to use when the user adds a new item. */
|
|
74
|
+
defaultValue?(): TValue;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* How a scalar was written in the source file, so that editing a value does not silently change
|
|
78
|
+
* its style. `'2026-09-12'` and `2026-09-12` mean different things to some consumers, and the
|
|
79
|
+
* blog's content mixes both.
|
|
80
|
+
*/
|
|
81
|
+
export interface ScalarStyle {
|
|
82
|
+
quote: 'single' | 'double' | false;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAEjC,mEAAmE;IACnE,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IAElC,mEAAmE;IACnE,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,aAAa,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC;IAE5E,2CAA2C;IAC3C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,eAAe,EAAE,CAAC;IAEjF,sEAAsE;IACtE,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;IAEpD,oDAAoD;IACpD,YAAY,CAAC,IAAI,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;CACpC"}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The field type contract.
|
|
3
|
+
*
|
|
4
|
+
* A field type is the smallest unit of extension: it knows how to read a stored value, how to
|
|
5
|
+
* write it back, and how to validate it. It deliberately says nothing about rendering — that is
|
|
6
|
+
* the widget layer's job (see `packages/cms`), so `core` stays free of DOM and React and can be
|
|
7
|
+
* reused from Node scripts.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading and writing entry files without disturbing what was not edited.
|
|
3
|
+
*
|
|
4
|
+
* The rule that makes this work: the file's text is the source of truth. Parsing keeps the
|
|
5
|
+
* original strings, and saving only touches the nodes whose values actually changed. Nothing is
|
|
6
|
+
* ever re-serialised from a plain object, because that would normalise quoting, flow style,
|
|
7
|
+
* key order and comments away — and the blog's build treats `'2026-09-12'` and a bare date, or a
|
|
8
|
+
* missing key and an empty one, as different things.
|
|
9
|
+
*/
|
|
10
|
+
import { type Document } from 'yaml';
|
|
11
|
+
export interface ParsedEntry {
|
|
12
|
+
/** The file exactly as it was read. */
|
|
13
|
+
raw: string;
|
|
14
|
+
/** Frontmatter including the `---` fences, or '' when the file has none. */
|
|
15
|
+
frontmatterRaw: string;
|
|
16
|
+
/** Everything after the frontmatter, byte for byte. */
|
|
17
|
+
bodyRaw: string;
|
|
18
|
+
/** The frontmatter as a mutable YAML document. */
|
|
19
|
+
document: Document.Parsed;
|
|
20
|
+
/** Whether the original file had frontmatter at all. */
|
|
21
|
+
hasFrontmatter: boolean;
|
|
22
|
+
/** Flow collections written as `{ a: 1 }`, which the writer would otherwise emit as `{a: 1}`. */
|
|
23
|
+
paddedFlows: FlowPadding[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A flow collection whose original text had a space just inside its brackets. Real files mix the
|
|
27
|
+
* two styles — `[a, b]` in one line and `{ a: b }` in the next — and the YAML writer has a single
|
|
28
|
+
* global setting, so these are recorded on parse and repaired after writing.
|
|
29
|
+
*/
|
|
30
|
+
interface FlowPadding {
|
|
31
|
+
/** Dotted path of the collection, as used by `getIn`/`setIn`. */
|
|
32
|
+
path: string[];
|
|
33
|
+
/** Whether the source text had a space after the opening bracket. */
|
|
34
|
+
leading: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function parseEntry(raw: string): ParsedEntry;
|
|
37
|
+
/** The frontmatter as plain data. For reading and comparing only — never for writing. */
|
|
38
|
+
export declare function readData(entry: ParsedEntry): Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Set a value at a dotted path, touching only that node, so every other node keeps its original
|
|
41
|
+
* style: quoting, flow vs block sequences, key order and comments all survive.
|
|
42
|
+
*/
|
|
43
|
+
export declare function setValue(entry: ParsedEntry, path: string, value: unknown): void;
|
|
44
|
+
/** Remove a key entirely, which is how optional fields stay absent rather than blank. */
|
|
45
|
+
export declare function deleteValue(entry: ParsedEntry, path: string): void;
|
|
46
|
+
/** Read a value at a dotted path, as plain data. */
|
|
47
|
+
export declare function getValue(entry: ParsedEntry, path: string): unknown;
|
|
48
|
+
/** Whether the node at `path` exists at all. */
|
|
49
|
+
export declare function hasValue(entry: ParsedEntry, path: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The quoting of the node currently at `path`, so a rewrite can match its neighbourhood rather
|
|
52
|
+
* than falling back to the YAML default. Dates in the blog are single-quoted strings; dropping
|
|
53
|
+
* the quotes would turn them into date objects downstream.
|
|
54
|
+
*/
|
|
55
|
+
export declare function scalarStyleAt(entry: ParsedEntry, path: string): {
|
|
56
|
+
quote: 'single' | 'double' | false;
|
|
57
|
+
} | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* The file text for the current document state. `bodyRaw` goes back out untouched unless the
|
|
60
|
+
* caller passes a new body, which is what makes "parse then save" a no-op for untouched content.
|
|
61
|
+
*/
|
|
62
|
+
export declare function serializeEntry(entry: ParsedEntry, body?: string): string;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/serialize/entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAoD,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEvF,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;IAC1B,wDAAwD;IACxD,cAAc,EAAE,OAAO,CAAC;IACxB,iGAAiG;IACjG,WAAW,EAAE,WAAW,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,UAAU,WAAW;IACnB,iEAAiE;IACjE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,qEAAqE;IACrE,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAwBnD;AAwBD,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKpE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/E;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAElE;AAED,oDAAoD;AACpD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlE;AAED,gDAAgD;AAChD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAElE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAA;CAAE,GAAG,SAAS,CAOpD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQxE"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading and writing entry files without disturbing what was not edited.
|
|
3
|
+
*
|
|
4
|
+
* The rule that makes this work: the file's text is the source of truth. Parsing keeps the
|
|
5
|
+
* original strings, and saving only touches the nodes whose values actually changed. Nothing is
|
|
6
|
+
* ever re-serialised from a plain object, because that would normalise quoting, flow style,
|
|
7
|
+
* key order and comments away — and the blog's build treats `'2026-09-12'` and a bare date, or a
|
|
8
|
+
* missing key and an empty one, as different things.
|
|
9
|
+
*/
|
|
10
|
+
import { parseDocument, stringify, isScalar, isSeq, isMap } from 'yaml';
|
|
11
|
+
// The frontmatter block may be empty, which is what a brand new entry starts as, so the inner
|
|
12
|
+
// group is optional rather than `[\s\S]*?` between two newlines.
|
|
13
|
+
const FRONTMATTER = /^---[ \t]*\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(\r?\n|$)/;
|
|
14
|
+
export function parseEntry(raw) {
|
|
15
|
+
const match = FRONTMATTER.exec(raw);
|
|
16
|
+
if (!match) {
|
|
17
|
+
return {
|
|
18
|
+
raw,
|
|
19
|
+
frontmatterRaw: '',
|
|
20
|
+
bodyRaw: raw,
|
|
21
|
+
document: parseDocument(''),
|
|
22
|
+
hasFrontmatter: false,
|
|
23
|
+
paddedFlows: [],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const frontmatterRaw = match[0];
|
|
27
|
+
const yamlText = match[1] ?? '';
|
|
28
|
+
const document = parseDocument(yamlText);
|
|
29
|
+
return {
|
|
30
|
+
raw,
|
|
31
|
+
frontmatterRaw,
|
|
32
|
+
bodyRaw: raw.slice(frontmatterRaw.length),
|
|
33
|
+
document,
|
|
34
|
+
hasFrontmatter: true,
|
|
35
|
+
// Node ranges are offsets into the YAML text that was parsed, not into the whole file.
|
|
36
|
+
paddedFlows: collectPadding(document, yamlText),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function collectPadding(document, yamlText) {
|
|
40
|
+
const found = [];
|
|
41
|
+
const visit = (node, path) => {
|
|
42
|
+
if (!isMap(node) && !isSeq(node))
|
|
43
|
+
return;
|
|
44
|
+
const range = node.range;
|
|
45
|
+
if (node.flow && range) {
|
|
46
|
+
const text = yamlText.slice(range[0], range[0] + 2);
|
|
47
|
+
found.push({ path: [...path], leading: /^[[{] /.test(text) });
|
|
48
|
+
}
|
|
49
|
+
if (isMap(node)) {
|
|
50
|
+
for (const item of node.items) {
|
|
51
|
+
const key = isScalar(item.key) ? String(item.key.value) : undefined;
|
|
52
|
+
if (key !== undefined)
|
|
53
|
+
visit(item.value, [...path, key]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (isSeq(node)) {
|
|
57
|
+
node.items.forEach((item, index) => visit(item, [...path, String(index)]));
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
visit(document.contents, []);
|
|
61
|
+
return found;
|
|
62
|
+
}
|
|
63
|
+
/** The frontmatter as plain data. For reading and comparing only — never for writing. */
|
|
64
|
+
export function readData(entry) {
|
|
65
|
+
const value = entry.document.toJS({});
|
|
66
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
67
|
+
? value
|
|
68
|
+
: {};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Set a value at a dotted path, touching only that node, so every other node keeps its original
|
|
72
|
+
* style: quoting, flow vs block sequences, key order and comments all survive.
|
|
73
|
+
*/
|
|
74
|
+
export function setValue(entry, path, value) {
|
|
75
|
+
entry.document.setIn(path.split('.'), value);
|
|
76
|
+
}
|
|
77
|
+
/** Remove a key entirely, which is how optional fields stay absent rather than blank. */
|
|
78
|
+
export function deleteValue(entry, path) {
|
|
79
|
+
entry.document.deleteIn(path.split('.'));
|
|
80
|
+
}
|
|
81
|
+
/** Read a value at a dotted path, as plain data. */
|
|
82
|
+
export function getValue(entry, path) {
|
|
83
|
+
const node = entry.document.getIn(path.split('.'), true);
|
|
84
|
+
if (node === undefined)
|
|
85
|
+
return undefined;
|
|
86
|
+
if (isScalar(node))
|
|
87
|
+
return node.value;
|
|
88
|
+
return node.toJS?.({}) ?? undefined;
|
|
89
|
+
}
|
|
90
|
+
/** Whether the node at `path` exists at all. */
|
|
91
|
+
export function hasValue(entry, path) {
|
|
92
|
+
return entry.document.hasIn(path.split('.'));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The quoting of the node currently at `path`, so a rewrite can match its neighbourhood rather
|
|
96
|
+
* than falling back to the YAML default. Dates in the blog are single-quoted strings; dropping
|
|
97
|
+
* the quotes would turn them into date objects downstream.
|
|
98
|
+
*/
|
|
99
|
+
export function scalarStyleAt(entry, path) {
|
|
100
|
+
const node = entry.document.getIn(path.split('.'), true);
|
|
101
|
+
if (!isScalar(node))
|
|
102
|
+
return undefined;
|
|
103
|
+
const type = node.type;
|
|
104
|
+
return {
|
|
105
|
+
quote: type === 'QUOTE_SINGLE' ? 'single' : type === 'QUOTE_DOUBLE' ? 'double' : false,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The file text for the current document state. `bodyRaw` goes back out untouched unless the
|
|
110
|
+
* caller passes a new body, which is what makes "parse then save" a no-op for untouched content.
|
|
111
|
+
*/
|
|
112
|
+
export function serializeEntry(entry, body) {
|
|
113
|
+
if (!entry.hasFrontmatter)
|
|
114
|
+
return body ?? entry.bodyRaw;
|
|
115
|
+
// `lineWidth: 0` stops the writer folding long lines, which would reflow existing text.
|
|
116
|
+
let yamlText = entry.document
|
|
117
|
+
.toString({ lineWidth: 0, flowCollectionPadding: false })
|
|
118
|
+
.replace(/\n+$/, '\n');
|
|
119
|
+
yamlText = restoreFlowPadding(entry, yamlText);
|
|
120
|
+
return `---\n${yamlText}---\n${body ?? entry.bodyRaw}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Put back the inner spaces that `flowCollectionPadding: false` removed, but only for the
|
|
124
|
+
* collections that had them. Real files mix `[a, b]` and `{ a: b }`, sometimes on adjacent lines,
|
|
125
|
+
* and the writer has one global setting — so the source style is recorded on parse and repaired
|
|
126
|
+
* here, matching on each collection's own inline text rather than on its position.
|
|
127
|
+
*/
|
|
128
|
+
function restoreFlowPadding(entry, yamlText) {
|
|
129
|
+
const wanted = entry.paddedFlows.filter((flow) => flow.leading);
|
|
130
|
+
if (wanted.length === 0)
|
|
131
|
+
return yamlText;
|
|
132
|
+
let result = yamlText;
|
|
133
|
+
for (const flow of wanted) {
|
|
134
|
+
const node = entry.document.getIn(flow.path, true);
|
|
135
|
+
if (!node || !(isMap(node) || isSeq(node)) || !node.flow)
|
|
136
|
+
continue;
|
|
137
|
+
const compact = stringify(node, {
|
|
138
|
+
lineWidth: 0,
|
|
139
|
+
flowCollectionPadding: false,
|
|
140
|
+
});
|
|
141
|
+
const padded = stringify(node, {
|
|
142
|
+
lineWidth: 0,
|
|
143
|
+
flowCollectionPadding: true,
|
|
144
|
+
});
|
|
145
|
+
if (typeof compact !== 'string' || typeof padded !== 'string')
|
|
146
|
+
continue;
|
|
147
|
+
result = result.replace(compact.trim(), padded.trim());
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|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