@conloca/content-api 0.1.15 → 0.2.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/asset-constraints.d.ts +16 -0
- package/dist/asset-constraints.d.ts.map +1 -0
- package/dist/asset-constraints.js +29 -0
- package/dist/asset-constraints.js.map +1 -0
- package/dist/asset-metadata-store.d.ts +60 -0
- package/dist/asset-metadata-store.d.ts.map +1 -0
- package/dist/asset-metadata-store.js +335 -0
- package/dist/asset-metadata-store.js.map +1 -0
- package/dist/asset-operations.d.ts +164 -0
- package/dist/asset-operations.d.ts.map +1 -0
- package/dist/asset-operations.js +784 -0
- package/dist/asset-operations.js.map +1 -0
- package/dist/asset-types.d.ts +72 -0
- package/dist/asset-types.d.ts.map +1 -0
- package/dist/asset-types.js +13 -0
- package/dist/asset-types.js.map +1 -0
- package/dist/asset-usage.d.ts +10 -0
- package/dist/asset-usage.d.ts.map +1 -0
- package/dist/asset-usage.js +49 -0
- package/dist/asset-usage.js.map +1 -0
- package/dist/base-content-index.d.ts +63 -0
- package/dist/base-content-index.d.ts.map +1 -0
- package/dist/base-content-index.js +200 -0
- package/dist/base-content-index.js.map +1 -0
- package/dist/cf-access.d.ts +31 -0
- package/dist/cf-access.d.ts.map +1 -0
- package/dist/cf-access.js +67 -0
- package/dist/cf-access.js.map +1 -0
- package/dist/component-registry.d.ts +50 -0
- package/dist/component-registry.d.ts.map +1 -0
- package/dist/component-registry.js +121 -0
- package/dist/component-registry.js.map +1 -0
- package/dist/component-registry.types.d.ts +11 -0
- package/dist/component-registry.types.d.ts.map +1 -0
- package/dist/component-registry.types.js +2 -0
- package/dist/component-registry.types.js.map +1 -0
- package/dist/component-vocabulary.d.ts +33 -0
- package/dist/component-vocabulary.d.ts.map +1 -0
- package/dist/component-vocabulary.js +105 -0
- package/dist/component-vocabulary.js.map +1 -0
- package/dist/content-api.interface.d.ts +64 -0
- package/dist/content-api.interface.d.ts.map +1 -0
- package/dist/content-api.interface.js +2 -0
- package/dist/content-api.interface.js.map +1 -0
- package/dist/content-filters.d.ts +31 -0
- package/dist/content-filters.d.ts.map +1 -0
- package/dist/content-filters.js +247 -0
- package/dist/content-filters.js.map +1 -0
- package/dist/content-index.d.ts +184 -0
- package/dist/content-index.d.ts.map +1 -0
- package/dist/content-index.js +546 -0
- package/dist/content-index.js.map +1 -0
- package/dist/content-operations.d.ts +157 -0
- package/dist/content-operations.d.ts.map +1 -0
- package/dist/content-operations.js +359 -0
- package/dist/content-operations.js.map +1 -0
- package/dist/content-path.d.ts +59 -0
- package/dist/content-path.d.ts.map +1 -0
- package/dist/content-path.js +88 -0
- package/dist/content-path.js.map +1 -0
- package/dist/content-reader.d.ts +10 -0
- package/dist/content-reader.d.ts.map +1 -0
- package/dist/content-reader.js +14 -0
- package/dist/content-reader.js.map +1 -0
- package/dist/content-utils.d.ts +175 -0
- package/dist/content-utils.d.ts.map +1 -0
- package/dist/content-utils.js +421 -0
- package/dist/content-utils.js.map +1 -0
- package/dist/content-watcher.d.ts +43 -0
- package/dist/content-watcher.d.ts.map +1 -0
- package/dist/content-watcher.js +86 -0
- package/dist/content-watcher.js.map +1 -0
- package/dist/data-index.d.ts +8 -0
- package/dist/data-index.d.ts.map +1 -0
- package/dist/data-index.js +8 -0
- package/dist/data-index.js.map +1 -0
- package/dist/data.d.ts +35 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +104 -0
- package/dist/data.js.map +1 -0
- package/dist/editor-data-bindings.d.ts +10 -0
- package/dist/editor-data-bindings.d.ts.map +1 -0
- package/dist/editor-data-bindings.js +67 -0
- package/dist/editor-data-bindings.js.map +1 -0
- package/dist/etag-utils.d.ts +77 -0
- package/dist/etag-utils.d.ts.map +1 -0
- package/dist/etag-utils.js +161 -0
- package/dist/etag-utils.js.map +1 -0
- package/dist/filesystem-content-api.d.ts +162 -0
- package/dist/filesystem-content-api.d.ts.map +1 -0
- package/dist/filesystem-content-api.js +2307 -0
- package/dist/filesystem-content-api.js.map +1 -0
- package/dist/filesystem-reader-backend.d.ts +46 -0
- package/dist/filesystem-reader-backend.d.ts.map +1 -0
- package/dist/filesystem-reader-backend.js +119 -0
- package/dist/filesystem-reader-backend.js.map +1 -0
- package/dist/fragment-index.d.ts +8 -0
- package/dist/fragment-index.d.ts.map +1 -0
- package/dist/fragment-index.js +8 -0
- package/dist/fragment-index.js.map +1 -0
- package/dist/fragments.d.ts +16 -0
- package/dist/fragments.d.ts.map +1 -0
- package/dist/fragments.js +104 -0
- package/dist/fragments.js.map +1 -0
- package/dist/git-operations.d.ts +49 -0
- package/dist/git-operations.d.ts.map +1 -0
- package/dist/git-operations.js +256 -0
- package/dist/git-operations.js.map +1 -0
- package/dist/header-parser.d.ts +37 -0
- package/dist/header-parser.d.ts.map +1 -0
- package/dist/header-parser.js +233 -0
- package/dist/header-parser.js.map +1 -0
- package/dist/in-memory-content-api.d.ts +35 -0
- package/dist/in-memory-content-api.d.ts.map +1 -0
- package/dist/in-memory-content-api.js +609 -0
- package/dist/in-memory-content-api.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/indexing.d.ts +5 -0
- package/dist/indexing.d.ts.map +1 -0
- package/dist/indexing.js +8 -0
- package/dist/indexing.js.map +1 -0
- package/dist/json-whitespace-view.d.ts +32 -0
- package/dist/json-whitespace-view.d.ts.map +1 -0
- package/dist/json-whitespace-view.js +153 -0
- package/dist/json-whitespace-view.js.map +1 -0
- package/dist/middleware.d.ts +20 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +1082 -0
- package/dist/middleware.js.map +1 -0
- package/dist/node.d.ts +32 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +27 -0
- package/dist/node.js.map +1 -0
- package/dist/page-references.d.ts +21 -0
- package/dist/page-references.d.ts.map +1 -0
- package/dist/page-references.js +50 -0
- package/dist/page-references.js.map +1 -0
- package/dist/read-date.d.ts +3 -0
- package/dist/read-date.d.ts.map +1 -0
- package/dist/read-date.js +9 -0
- package/dist/read-date.js.map +1 -0
- package/dist/reader-backend.d.ts +54 -0
- package/dist/reader-backend.d.ts.map +1 -0
- package/dist/reader-backend.js +2 -0
- package/dist/reader-backend.js.map +1 -0
- package/dist/reader.d.ts +15 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +14 -0
- package/dist/reader.js.map +1 -0
- package/dist/schemas/index.d.ts +102 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +88 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/site-index.d.ts +60 -0
- package/dist/site-index.d.ts.map +1 -0
- package/dist/site-index.js +291 -0
- package/dist/site-index.js.map +1 -0
- package/dist/site.d.ts +23 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +180 -0
- package/dist/site.js.map +1 -0
- package/dist/types.d.ts +641 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +45 -0
- package/dist/types.js.map +1 -0
- package/dist/url-safe-base64.d.ts +12 -0
- package/dist/url-safe-base64.d.ts.map +1 -0
- package/dist/url-safe-base64.js +41 -0
- package/dist/url-safe-base64.js.map +1 -0
- package/dist/url-validation.d.ts +28 -0
- package/dist/url-validation.d.ts.map +1 -0
- package/dist/url-validation.js +123 -0
- package/dist/url-validation.js.map +1 -0
- package/dist/utils/atomic-write.d.ts +6 -0
- package/dist/utils/atomic-write.d.ts.map +1 -0
- package/dist/utils/atomic-write.js +21 -0
- package/dist/utils/atomic-write.js.map +1 -0
- package/dist/utils.d.ts +46 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +71 -0
- package/dist/utils.js.map +1 -0
- package/dist/vite-plugin.d.ts +12 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +30 -0
- package/dist/vite-plugin.js.map +1 -0
- package/dist/vxjson-serialize.d.ts +13 -0
- package/dist/vxjson-serialize.d.ts.map +1 -0
- package/dist/vxjson-serialize.js +53 -0
- package/dist/vxjson-serialize.js.map +1 -0
- package/dist/vxjson.d.ts +113 -0
- package/dist/vxjson.d.ts.map +1 -0
- package/dist/vxjson.js +381 -0
- package/dist/vxjson.js.map +1 -0
- package/dist/xxhash.d.ts +10 -0
- package/dist/xxhash.d.ts.map +1 -0
- package/dist/xxhash.js +35 -0
- package/dist/xxhash.js.map +1 -0
- package/package.json +132 -34
- package/src/asset-constraints.ts +33 -0
- package/src/asset-metadata-store.ts +401 -0
- package/src/asset-operations.ts +914 -0
- package/src/asset-types.ts +74 -0
- package/src/asset-usage.ts +47 -0
- package/src/base-content-index.ts +227 -0
- package/src/cf-access.ts +85 -0
- package/src/component-registry.ts +145 -0
- package/src/component-registry.types.ts +12 -0
- package/src/component-vocabulary.ts +87 -0
- package/src/content-api.interface.ts +94 -0
- package/src/content-filters.ts +278 -0
- package/src/content-index.ts +642 -0
- package/src/content-operations.ts +497 -0
- package/src/content-path.ts +113 -0
- package/src/content-reader.ts +18 -0
- package/src/content-utils.ts +474 -0
- package/src/content-watcher.ts +122 -0
- package/src/data-index.ts +7 -0
- package/src/data.ts +134 -0
- package/src/editor-data-bindings.ts +66 -0
- package/src/etag-utils.ts +204 -0
- package/src/filesystem-content-api.ts +2685 -0
- package/src/filesystem-reader-backend.ts +135 -0
- package/src/fragment-index.ts +7 -0
- package/src/fragments.ts +113 -0
- package/src/git-operations.ts +340 -0
- package/src/header-parser.ts +272 -0
- package/src/in-memory-content-api.ts +760 -0
- package/src/index.ts +45 -0
- package/src/indexing.ts +8 -0
- package/src/json-whitespace-view.ts +155 -0
- package/src/middleware.ts +1341 -0
- package/src/node.ts +40 -0
- package/src/page-references.ts +76 -0
- package/src/read-date.ts +7 -0
- package/src/reader-backend.ts +54 -0
- package/src/reader.ts +15 -0
- package/src/schemas/index.ts +113 -0
- package/src/site-index.ts +330 -0
- package/src/site.ts +198 -0
- package/src/types.ts +759 -0
- package/src/url-safe-base64.ts +38 -0
- package/src/url-validation.ts +121 -0
- package/src/utils/atomic-write.ts +20 -0
- package/src/utils.ts +84 -0
- package/src/vite-plugin.ts +45 -0
- package/src/vxjson-serialize.ts +66 -0
- package/src/vxjson.ts +442 -0
- package/src/xxhash.ts +43 -0
- package/dist/component-registry.types-CBGONnYn.d.mts +0 -71
- package/dist/component-registry.types-CBGONnYn.d.mts.map +0 -1
- package/dist/content-operations-Dv67amz3.d.mts +0 -852
- package/dist/content-operations-Dv67amz3.d.mts.map +0 -1
- package/dist/data-Db1Iv9T0.mjs +0 -60
- package/dist/data-Db1Iv9T0.mjs.map +0 -1
- package/dist/filesystem-content-api-C1TM0GLo.d.mts +0 -119
- package/dist/filesystem-content-api-C1TM0GLo.d.mts.map +0 -1
- package/dist/filesystem-content-api-kxKY5IUw.mjs +0 -2678
- package/dist/filesystem-content-api-kxKY5IUw.mjs.map +0 -1
- package/dist/index.d.mts +0 -79
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -47
- package/dist/index.mjs.map +0 -1
- package/dist/node.d.mts +0 -378
- package/dist/node.d.mts.map +0 -1
- package/dist/node.mjs +0 -2618
- package/dist/node.mjs.map +0 -1
- package/dist/reader.d.mts +0 -18
- package/dist/reader.d.mts.map +0 -1
- package/dist/reader.mjs +0 -22
- package/dist/reader.mjs.map +0 -1
- package/dist/schemas/index.d.mts +0 -90
- package/dist/schemas/index.d.mts.map +0 -1
- package/dist/schemas/index.mjs +0 -70
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/site-vNtJ5jCh.mjs +0 -538
- package/dist/site-vNtJ5jCh.mjs.map +0 -1
- package/dist/types-DWt912tu.mjs +0 -33
- package/dist/types-DWt912tu.mjs.map +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE locale/path grammar for content files.
|
|
3
|
+
*
|
|
4
|
+
* Every reader that turns a storage path back into content identity parses it
|
|
5
|
+
* here: the pure header parser, the filesystem indexer, and any other reader
|
|
6
|
+
* of content files. Each of those used to carry its own copy of the
|
|
7
|
+
* regex and the copies disagreed — a copy that refused `about.EN.mdx`
|
|
8
|
+
* made content the index had accepted unreadable, and an indexer copy
|
|
9
|
+
* matching `\w+` filed `about.en-US.mdx` under a fallback locale with no
|
|
10
|
+
* pathname at all.
|
|
11
|
+
*
|
|
12
|
+
* Zero imports on purpose: some consumers embed this module where nothing
|
|
13
|
+
* effectful may run at import time.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* A two-letter language subtag, optionally followed by a two-letter upper-case
|
|
17
|
+
* region (`en`, `nl`, `en-US`). Case is PRESERVED, never normalized: writers
|
|
18
|
+
* splice this exact string back into the filename (`getFilePath`, and any other
|
|
19
|
+
* writer of content files), so lower-casing it here would make a repo holding
|
|
20
|
+
* `about.EN.mdx` save its next edit to `about.en.mdx` and orphan the original.
|
|
21
|
+
*
|
|
22
|
+
* Wider BCP-47 forms (three-letter languages, script subtags like `zh-Hans`,
|
|
23
|
+
* lower-case regions) are deliberately NOT accepted: no spec text defines the
|
|
24
|
+
* grammar, and every writer in the system emits this shape today.
|
|
25
|
+
*/
|
|
26
|
+
const LOCALE_SUBTAG = '[a-zA-Z]{2}(?:-[A-Z]{2})?';
|
|
27
|
+
const LOCALE = new RegExp(`^${LOCALE_SUBTAG}$`);
|
|
28
|
+
/**
|
|
29
|
+
* Whether `locale` is one this grammar reads back. A writer checks a new entry's locale with it:
|
|
30
|
+
* the locale is spliced into the file path, so anything else is either unreadable or, like
|
|
31
|
+
* '../x', a path out of the entry's folder.
|
|
32
|
+
*/
|
|
33
|
+
export function isContentLocale(locale) {
|
|
34
|
+
return LOCALE.test(locale);
|
|
35
|
+
}
|
|
36
|
+
/** `<base>.<locale>.<ext>` — the filename half of every content layout. */
|
|
37
|
+
const LOCALE_FILENAME = new RegExp(`^(.+)\\.(${LOCALE_SUBTAG})\\.(mdx|vxjson|json)$`);
|
|
38
|
+
/** Split `<base>.<locale>.<ext>`. Null when the filename carries no locale suffix. */
|
|
39
|
+
export function parseLocaleFilename(filename) {
|
|
40
|
+
const match = LOCALE_FILENAME.exec(filename);
|
|
41
|
+
if (!match)
|
|
42
|
+
return null;
|
|
43
|
+
return { base: match[1], locale: match[2], extension: match[3] };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pure path → identity mapper. Returns null when the path doesn't match any
|
|
47
|
+
* supported layout or lacks an explicit locale suffix.
|
|
48
|
+
*
|
|
49
|
+
* Layouts honoured here mirror filesystem-content-api.ts:137-144:
|
|
50
|
+
*
|
|
51
|
+
* - `fragments/<collection>/<name>.<locale>.{mdx,vxjson}` (collection required;
|
|
52
|
+
* `fragments/<name>.<locale>.ext` is a legacy form that FileSystemContentAPI
|
|
53
|
+
* repairs by renaming. The pure parser refuses it.)
|
|
54
|
+
* - `data/<collection>/<name>.<locale>.json`
|
|
55
|
+
* - `<site>/<collection>/<path...>/<file>.<locale>.{vxjson,mdx}` (pages; `index`
|
|
56
|
+
* basename maps to the parent path).
|
|
57
|
+
*
|
|
58
|
+
* Reads accept .mdx pages even though the filesystem writer emits main-layout
|
|
59
|
+
* pages as .vxjson only (its mdx pages live under the separate mdxPagesRoot):
|
|
60
|
+
* another writer may derive the extension from the content type, so an
|
|
61
|
+
* mdx-typed page can land here as <site>/pages/<f>.<l>.mdx and must re-parse —
|
|
62
|
+
* dropping it made written pages unreadable.
|
|
63
|
+
*/
|
|
64
|
+
export function parseContentPathLayout(path) {
|
|
65
|
+
const parts = path.split('/').filter(Boolean);
|
|
66
|
+
if (parts.length < 3)
|
|
67
|
+
return null;
|
|
68
|
+
const suffix = parseLocaleFilename(parts[parts.length - 1]);
|
|
69
|
+
if (!suffix)
|
|
70
|
+
return null;
|
|
71
|
+
if (parts[0] === 'fragments') {
|
|
72
|
+
if (parts.length !== 3 || suffix.extension === 'json')
|
|
73
|
+
return null;
|
|
74
|
+
return { kind: 'fragment', collection: parts[1], name: suffix.base, locale: suffix.locale };
|
|
75
|
+
}
|
|
76
|
+
if (parts[0] === 'data') {
|
|
77
|
+
if (parts.length !== 3 || suffix.extension !== 'json')
|
|
78
|
+
return null;
|
|
79
|
+
return { kind: 'data', collection: parts[1], name: suffix.base, locale: suffix.locale };
|
|
80
|
+
}
|
|
81
|
+
if (suffix.extension === 'json')
|
|
82
|
+
return null;
|
|
83
|
+
const pathParts = parts.slice(2);
|
|
84
|
+
pathParts[pathParts.length - 1] = suffix.base;
|
|
85
|
+
const pathname = pathParts[pathParts.length - 1] === 'index' ? `/${pathParts.slice(0, -1).join('/')}` : `/${pathParts.join('/')}`;
|
|
86
|
+
return { kind: 'page', site: parts[0], collection: parts[1], locale: suffix.locale, pathname };
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=content-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-path.js","sourceRoot":"","sources":["../src/content-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAElD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED,2EAA2E;AAC3E,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,YAAY,aAAa,wBAAwB,CAAC,CAAC;AAYtF,sFAAsF;AACtF,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAyB,EAA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SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;IAC9C,MAAM,QAAQ,GACZ,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAEnH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentAPIOptions } from './types.js';
|
|
2
|
+
export type ContentReaderOptions = ContentAPIOptions;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a read-oriented content API instance for build-time consumers.
|
|
5
|
+
*
|
|
6
|
+
* The filesystem implementation is loaded lazily so build tooling does not
|
|
7
|
+
* eagerly traverse native hashing dependencies through the reader entrypoint.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createContentAPI(options: ContentReaderOptions): Promise<import("./filesystem-content-api.js").FileSystemContentAPI>;
|
|
10
|
+
//# sourceMappingURL=content-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-reader.d.ts","sourceRoot":"","sources":["../src/content-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAErD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,uEAOnE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a read-oriented content API instance for build-time consumers.
|
|
3
|
+
*
|
|
4
|
+
* The filesystem implementation is loaded lazily so build tooling does not
|
|
5
|
+
* eagerly traverse native hashing dependencies through the reader entrypoint.
|
|
6
|
+
*/
|
|
7
|
+
export async function createContentAPI(options) {
|
|
8
|
+
const { FileSystemContentAPI: ReaderAPI } = await import('./filesystem-content-api.js');
|
|
9
|
+
return ReaderAPI.create({
|
|
10
|
+
...options,
|
|
11
|
+
canvasDir: options.canvasDir || './canvas',
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=content-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-reader.js","sourceRoot":"","sources":["../src/content-reader.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA6B;IAClE,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IAExF,OAAO,SAAS,CAAC,MAAM,CAAC;QACtB,GAAG,OAAO;QACV,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,UAAU;KAC3C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { ContentMeta, ContentMetaPatch } from './types.js';
|
|
2
|
+
export declare function localesOf<T>(manifest: {
|
|
3
|
+
locales: Record<string, T | undefined>;
|
|
4
|
+
}): Generator<T>;
|
|
5
|
+
/**
|
|
6
|
+
* Pure utility functions for content operations
|
|
7
|
+
* These functions don't depend on any class state and can be shared
|
|
8
|
+
* between FileSystemContentAPI, InMemoryContentAPI, and other implementations
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Whether content is published at `now`: from its publish time on, until the
|
|
12
|
+
* instant its unpublish time arrives. Empty or invalid dates count as not set.
|
|
13
|
+
* Serving a page, the page feed, the site index and the status the editor
|
|
14
|
+
* shows for a page all ask this, so the site and the editor agree at the
|
|
15
|
+
* unpublish instant.
|
|
16
|
+
* The `published` listing filter asks a different question: whether any
|
|
17
|
+
* locale is still before its unpublish time.
|
|
18
|
+
*
|
|
19
|
+
* The schedule takes a locale version or a page entry. A page entry from the
|
|
20
|
+
* Astro schema holds Date values and nulls, and `undefined` is spelled out
|
|
21
|
+
* rather than left to `?:` so a host compiling with exactOptionalPropertyTypes
|
|
22
|
+
* can pass the entry straight in: its schedule keys can be present with no
|
|
23
|
+
* value.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isContentPublished(schedule: {
|
|
26
|
+
publishAt?: string | Date | null | undefined;
|
|
27
|
+
unpublishAt?: string | Date | null | undefined;
|
|
28
|
+
}, now?: Date): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Apply a dialog's metadata patch: absent keys keep the stored value, null
|
|
31
|
+
* deletes the field. Every update path merges through here so "clear" cannot
|
|
32
|
+
* silently regress back into "keep" at one of the spread sites.
|
|
33
|
+
*/
|
|
34
|
+
export declare function applyMetaPatch(current: ContentMeta, patch: ContentMetaPatch): Partial<ContentMeta>;
|
|
35
|
+
/**
|
|
36
|
+
* The underlying merge: null deletes, absent or undefined keeps. Shared by
|
|
37
|
+
* content metadata and asset-manifest updates so "clear" means one thing
|
|
38
|
+
* everywhere a dialog saves a fixed set of fields.
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyNullClearPatch<T extends object>(current: T, patch: {
|
|
41
|
+
[K in keyof T]?: T[K] | null;
|
|
42
|
+
}): Partial<T>;
|
|
43
|
+
/**
|
|
44
|
+
* A meta field read as a string, or undefined when it holds anything else.
|
|
45
|
+
*
|
|
46
|
+
* Fields outside ContentMeta's declared set are typed as JsonValue, because
|
|
47
|
+
* that is all the format guarantees. Content meta is also hand-editable in
|
|
48
|
+
* git, so a reader that wants a string genuinely cannot assume it has one —
|
|
49
|
+
* narrowing here stops a malformed value from posing as a real one, which a
|
|
50
|
+
* cast would wave through. Takes `unknown` so it also serves callers holding
|
|
51
|
+
* meta in a looser shape than ContentMeta.
|
|
52
|
+
*/
|
|
53
|
+
export declare function metaString(value: unknown): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Validate that metadata doesn't exceed 4KB when serialized
|
|
56
|
+
* This ensures efficient indexing as per the specification
|
|
57
|
+
*/
|
|
58
|
+
export declare function isMetadataTooLarge(meta: ContentMeta): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Extract fragment name from various sources
|
|
61
|
+
* Used when displaying fragments in the UI
|
|
62
|
+
*/
|
|
63
|
+
export declare function extractFragmentName(source: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Validate fragment name according to the specification
|
|
66
|
+
* - Cannot contain dots (reserved for locale separator)
|
|
67
|
+
* - Cannot contain slashes (would create subdirectories)
|
|
68
|
+
* - Cannot contain spaces (for clean filenames)
|
|
69
|
+
* - Must have at least one character
|
|
70
|
+
*/
|
|
71
|
+
export declare function isValidFragmentName(name: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Format file size for display with human-readable units
|
|
74
|
+
* @example formatFileSize(1536) // "1.5 KB"
|
|
75
|
+
*/
|
|
76
|
+
export declare function formatFileSize(bytes: number): string;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate metadata size in bytes
|
|
79
|
+
*/
|
|
80
|
+
export declare function getMetadataSize(meta: ContentMeta): number;
|
|
81
|
+
/**
|
|
82
|
+
* Check if a pathname is valid
|
|
83
|
+
* - Must start with /
|
|
84
|
+
* - Cannot contain spaces (should be URL-encoded)
|
|
85
|
+
* - Cannot contain special characters that would break URLs
|
|
86
|
+
*/
|
|
87
|
+
export declare function isValidPathname(pathname: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Normalize a pathname to ensure consistency
|
|
90
|
+
* - Ensure it starts with /
|
|
91
|
+
* - Remove trailing slashes (except for root)
|
|
92
|
+
* - Collapse multiple slashes
|
|
93
|
+
*/
|
|
94
|
+
export declare function normalizePathname(pathname: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Reasons a pathname can be rejected. Each maps to a specific user-facing
|
|
97
|
+
* error message so the UI can highlight the exact problem.
|
|
98
|
+
*/
|
|
99
|
+
export type PathnameValidationReason = 'empty' | 'whitespace' | 'forbidden_char' | 'control_char' | 'uppercase' | 'non_ascii' | 'traversal_segment' | 'index_segment' | 'disallowed_char';
|
|
100
|
+
export interface PathnameValidationResult {
|
|
101
|
+
/** When valid: the normalized pathname. When invalid: the raw (trimmed) input. */
|
|
102
|
+
value: string;
|
|
103
|
+
valid: boolean;
|
|
104
|
+
reason?: PathnameValidationReason;
|
|
105
|
+
message?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Validate the shape of a CMS pathname and normalize it for storage.
|
|
109
|
+
*
|
|
110
|
+
* Silently fixes harmless slips (missing leading slash, doubled slashes,
|
|
111
|
+
* trailing slash) and rejects malformed inputs with a specific reason so
|
|
112
|
+
* the UI can show a helpful error message.
|
|
113
|
+
*
|
|
114
|
+
* Accepted chars: a–z, 0–9, `-`, `_`, `/`. Mixed case, accents, spaces,
|
|
115
|
+
* `?`, `#`, `\`, and traversal segments (`.`, `..`) are rejected, as is a
|
|
116
|
+
* last segment `index`: a page's file is named after its path, `/` is stored
|
|
117
|
+
* as `index`, and `blog/index` reads back as `/blog`, so `/index` would be the
|
|
118
|
+
* home page's file and `/blog/index` a second page at `/blog`.
|
|
119
|
+
*/
|
|
120
|
+
export declare function normalizeAndValidatePathname(input: string | undefined | null): PathnameValidationResult;
|
|
121
|
+
/**
|
|
122
|
+
* Generate a content ID in the standard format
|
|
123
|
+
* IDs are prefixed with "vx-" followed by 8 random characters
|
|
124
|
+
*/
|
|
125
|
+
export declare function generateContentId(): string;
|
|
126
|
+
/**
|
|
127
|
+
* Get the current date/time in ISO format
|
|
128
|
+
* Used for timestamps in content files
|
|
129
|
+
*/
|
|
130
|
+
export declare function getCurrentISODate(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Parse a date string safely
|
|
133
|
+
* Returns null if invalid
|
|
134
|
+
*/
|
|
135
|
+
export declare function parseDate(dateStr: string | undefined): Date | null;
|
|
136
|
+
/**
|
|
137
|
+
* Creates a V8-optimized object by mapping site names to values.
|
|
138
|
+
* Ensures all objects have the same hidden class by adding properties in consistent order.
|
|
139
|
+
*
|
|
140
|
+
* @param sitesConfig - Sites configuration containing site names
|
|
141
|
+
* @param factory - Function that creates the value for each site
|
|
142
|
+
* @returns Object with all sites initialized in alphabetical order
|
|
143
|
+
*/
|
|
144
|
+
export declare function mapSiteNames<T>(sitesConfig: {
|
|
145
|
+
sites: Record<string, any>;
|
|
146
|
+
}, factory: (siteName: string) => T): Record<string, T>;
|
|
147
|
+
/**
|
|
148
|
+
* Creates a V8-optimized object by mapping locale names to values.
|
|
149
|
+
* Ensures all objects have the same hidden class by adding properties in consistent order.
|
|
150
|
+
*
|
|
151
|
+
* @param locales - Array of locale codes
|
|
152
|
+
* @param factory - Function that creates the value for each locale
|
|
153
|
+
* @returns Object with all locales initialized in array order
|
|
154
|
+
*/
|
|
155
|
+
export declare function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T>;
|
|
156
|
+
/**
|
|
157
|
+
* Resolves a publish date value to a valid string or undefined.
|
|
158
|
+
* Handles various input types including null, false, and empty strings.
|
|
159
|
+
*
|
|
160
|
+
* @param updateValue - The value being updated (string | null | false | undefined)
|
|
161
|
+
* @param currentValue - The current value to fall back to if updateValue is undefined
|
|
162
|
+
* @returns A valid date string or undefined
|
|
163
|
+
*/
|
|
164
|
+
export declare function resolvePublishDate(updateValue: string | null | false | undefined, currentValue: string | undefined): string | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Serializes MDX content with frontmatter.
|
|
167
|
+
* This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
|
|
168
|
+
* consistent MDX output that includes frontmatter for variable access.
|
|
169
|
+
*
|
|
170
|
+
* @param frontmatterData - The frontmatter data to serialize
|
|
171
|
+
* @param mdxContent - The MDX content (without frontmatter)
|
|
172
|
+
* @returns Complete MDX file content with frontmatter
|
|
173
|
+
*/
|
|
174
|
+
export declare function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string;
|
|
175
|
+
//# sourceMappingURL=content-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-utils.d.ts","sourceRoot":"","sources":["../src/content-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAyBhE,wBAAiB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAIhG;AAED;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAC1G,GAAG,OAAa,GACf,OAAO,CAQT;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAElG;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAgBrH;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE7D;AAED;;;GAG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