@conloca/content-api 0.1.16 → 0.2.1
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 +21 -28
- package/dist/asset-operations.d.ts.map +1 -1
- package/dist/asset-operations.js +268 -305
- package/dist/asset-operations.js.map +1 -0
- package/dist/asset-types.d.ts +23 -7
- package/dist/asset-types.d.ts.map +1 -1
- package/dist/asset-types.js +8 -2
- package/dist/asset-types.js.map +1 -0
- package/dist/asset-usage.d.ts +11 -0
- package/dist/asset-usage.d.ts.map +1 -0
- package/dist/asset-usage.js +50 -0
- package/dist/asset-usage.js.map +1 -0
- package/dist/base-content-index.d.ts +8 -2
- package/dist/base-content-index.d.ts.map +1 -1
- package/dist/base-content-index.js +24 -3
- package/dist/base-content-index.js.map +1 -0
- package/dist/cf-access.js +1 -0
- package/dist/cf-access.js.map +1 -0
- package/dist/component-registry.d.ts +1 -1
- package/dist/component-registry.d.ts.map +1 -1
- package/dist/component-registry.js +2 -1
- package/dist/component-registry.js.map +1 -0
- package/dist/component-registry.types.js +1 -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 +5 -5
- package/dist/content-api.interface.d.ts.map +1 -1
- package/dist/content-api.interface.js +1 -0
- package/dist/content-api.interface.js.map +1 -0
- package/dist/content-filters.d.ts +2 -2
- package/dist/content-filters.d.ts.map +1 -1
- package/dist/content-filters.js +9 -8
- package/dist/content-filters.js.map +1 -0
- package/dist/content-index.d.ts +74 -16
- package/dist/content-index.d.ts.map +1 -1
- package/dist/content-index.js +183 -55
- package/dist/content-index.js.map +1 -0
- package/dist/content-operations.d.ts +71 -7
- package/dist/content-operations.d.ts.map +1 -1
- package/dist/content-operations.js +166 -82
- package/dist/content-operations.js.map +1 -0
- package/dist/content-path.d.ts +64 -0
- package/dist/content-path.d.ts.map +1 -0
- package/dist/content-path.js +95 -0
- package/dist/content-path.js.map +1 -0
- package/dist/content-reader.d.ts +2 -2
- package/dist/content-reader.d.ts.map +1 -1
- package/dist/content-reader.js +2 -1
- package/dist/content-reader.js.map +1 -0
- package/dist/content-utils.d.ts +53 -10
- package/dist/content-utils.d.ts.map +1 -1
- package/dist/content-utils.js +103 -34
- package/dist/content-utils.js.map +1 -0
- package/dist/content-watcher.d.ts +3 -3
- package/dist/content-watcher.d.ts.map +1 -1
- package/dist/content-watcher.js +13 -10
- package/dist/content-watcher.js.map +1 -0
- package/dist/data-index.d.ts +1 -1
- package/dist/data-index.d.ts.map +1 -1
- package/dist/data-index.js +2 -1
- package/dist/data-index.js.map +1 -0
- package/dist/data.d.ts +5 -13
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +7 -6
- 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.map +1 -1
- package/dist/etag-utils.js +5 -4
- package/dist/etag-utils.js.map +1 -0
- package/dist/filesystem-content-api.d.ts +45 -18
- package/dist/filesystem-content-api.d.ts.map +1 -1
- package/dist/filesystem-content-api.js +455 -286
- 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.map +1 -1
- package/dist/git-operations.js +5 -1
- package/dist/git-operations.js.map +1 -0
- package/dist/header-parser.d.ts +4 -4
- package/dist/header-parser.d.ts.map +1 -1
- package/dist/header-parser.js +8 -61
- package/dist/header-parser.js.map +1 -0
- package/dist/in-memory-content-api.d.ts +7 -7
- package/dist/in-memory-content-api.d.ts.map +1 -1
- package/dist/in-memory-content-api.js +74 -56
- package/dist/in-memory-content-api.js.map +1 -0
- package/dist/index.d.ts +19 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -0
- package/dist/indexing.d.ts +4 -4
- package/dist/indexing.d.ts.map +1 -1
- package/dist/indexing.js +6 -5
- package/dist/indexing.js.map +1 -0
- package/dist/json-whitespace-view.js +1 -0
- package/dist/json-whitespace-view.js.map +1 -0
- package/dist/middleware.d.ts +8 -6
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +178 -142
- package/dist/middleware.js.map +1 -0
- package/dist/node.d.ts +24 -17
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +17 -14
- 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 +8 -8
- package/dist/reader.d.ts.map +1 -1
- package/dist/reader.js +8 -7
- package/dist/reader.js.map +1 -0
- package/dist/schemas/index.d.ts +6 -6
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +9 -8
- package/dist/schemas/index.js.map +1 -0
- package/dist/site-index.d.ts +3 -3
- package/dist/site-index.d.ts.map +1 -1
- package/dist/site-index.js +9 -5
- package/dist/site-index.js.map +1 -0
- package/dist/site.d.ts +5 -3
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +14 -2
- package/dist/site.js.map +1 -0
- package/dist/types.d.ts +203 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/url-safe-base64.js +1 -0
- package/dist/url-safe-base64.js.map +1 -0
- package/dist/url-validation.d.ts +14 -0
- package/dist/url-validation.d.ts.map +1 -1
- package/dist/url-validation.js +56 -14
- package/dist/url-validation.js.map +1 -0
- package/dist/utils/atomic-write.js +1 -0
- package/dist/utils/atomic-write.js.map +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -1
- package/dist/utils.js.map +1 -0
- package/dist/vite-plugin.d.ts +2 -2
- package/dist/vite-plugin.js +5 -4
- package/dist/vite-plugin.js.map +1 -0
- package/dist/vxjson-serialize.d.ts +5 -6
- package/dist/vxjson-serialize.d.ts.map +1 -1
- package/dist/vxjson-serialize.js +13 -10
- package/dist/vxjson-serialize.js.map +1 -0
- package/dist/vxjson.d.ts +4 -3
- package/dist/vxjson.d.ts.map +1 -1
- package/dist/vxjson.js +10 -20
- package/dist/vxjson.js.map +1 -0
- package/dist/xxhash.d.ts.map +1 -1
- package/dist/xxhash.js +6 -2
- package/dist/xxhash.js.map +1 -0
- package/package.json +92 -56
- package/src/asset-constraints.ts +33 -0
- package/src/asset-metadata-store.ts +401 -0
- package/src/asset-operations.ts +814 -0
- package/src/asset-types.ts +74 -0
- package/src/asset-usage.ts +48 -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 +121 -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 +2740 -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 +1322 -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/asset-manifest.d.ts +0 -23
- package/dist/asset-manifest.d.ts.map +0 -1
- package/dist/asset-manifest.js +0 -73
- package/dist/block-index.d.ts +0 -9
- package/dist/block-index.d.ts.map +0 -1
- package/dist/block-index.js +0 -11
- package/dist/blocks.d.ts +0 -16
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -103
- package/dist/component-registry.types-C0ctF9nh.d.mts +0 -71
- package/dist/component-registry.types-C0ctF9nh.d.mts.map +0 -1
- package/dist/content-index-D092_vk1.mjs +0 -629
- package/dist/content-index-D092_vk1.mjs.map +0 -1
- package/dist/content-index-D6IVMmAB.d.mts +0 -127
- package/dist/content-index-D6IVMmAB.d.mts.map +0 -1
- package/dist/content-operations-DIbsxG5A.d.mts +0 -354
- package/dist/content-operations-DIbsxG5A.d.mts.map +0 -1
- package/dist/content-utils-fWNHTrPy.mjs +0 -280
- package/dist/content-utils-fWNHTrPy.mjs.map +0 -1
- package/dist/data-DquNIEnQ.mjs +0 -62
- package/dist/data-DquNIEnQ.mjs.map +0 -1
- package/dist/filesystem-content-api-B1KIQJfk.mjs +0 -2
- package/dist/filesystem-content-api-C0HIhqZi.mjs +0 -1620
- package/dist/filesystem-content-api-C0HIhqZi.mjs.map +0 -1
- package/dist/filesystem-content-api-DCdNi-co.d.mts +0 -134
- package/dist/filesystem-content-api-DCdNi-co.d.mts.map +0 -1
- package/dist/index-DxVTFK66.d.mts +0 -105
- package/dist/index-DxVTFK66.d.mts.map +0 -1
- package/dist/index.d.mts +0 -80
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -78
- package/dist/index.mjs.map +0 -1
- package/dist/indexing.d.mts +0 -152
- package/dist/indexing.d.mts.map +0 -1
- package/dist/indexing.mjs +0 -255
- package/dist/indexing.mjs.map +0 -1
- package/dist/node.d.mts +0 -373
- package/dist/node.d.mts.map +0 -1
- package/dist/node.mjs +0 -2572
- package/dist/node.mjs.map +0 -1
- package/dist/reader.d.mts +0 -15
- 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 -2
- package/dist/schemas/index.mjs +0 -2
- package/dist/schemas-CFRD0FIQ.mjs +0 -84
- package/dist/schemas-CFRD0FIQ.mjs.map +0 -1
- package/dist/site-8oaj1Q60.mjs +0 -366
- package/dist/site-8oaj1Q60.mjs.map +0 -1
- package/dist/site-index-B_254bCc.d.mts +0 -136
- package/dist/site-index-B_254bCc.d.mts.map +0 -1
- package/dist/types-DOdldbfD.mjs +0 -34
- package/dist/types-DOdldbfD.mjs.map +0 -1
- package/dist/types-DjfhS272.d.mts +0 -456
- package/dist/types-DjfhS272.d.mts.map +0 -1
- package/dist/vxjson-qHrgLGip.mjs +0 -555
- package/dist/vxjson-qHrgLGip.mjs.map +0 -1
- package/dist/vxjson-serialize-geF6qvpn.mjs +0 -34
- package/dist/vxjson-serialize-geF6qvpn.mjs.map +0 -1
- package/dist/vxjson-serialize.d.mts +0 -17
- package/dist/vxjson-serialize.d.mts.map +0 -1
- package/dist/vxjson-serialize.mjs +0 -2
package/dist/content-reader.js
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* eagerly traverse native hashing dependencies through the reader entrypoint.
|
|
6
6
|
*/
|
|
7
7
|
export async function createContentAPI(options) {
|
|
8
|
-
const { FileSystemContentAPI: ReaderAPI } = await import('./filesystem-content-api');
|
|
8
|
+
const { FileSystemContentAPI: ReaderAPI } = await import('./filesystem-content-api.js');
|
|
9
9
|
return ReaderAPI.create({
|
|
10
10
|
...options,
|
|
11
11
|
canvasDir: options.canvasDir || './canvas',
|
|
12
12
|
});
|
|
13
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"}
|
package/dist/content-utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentMeta,
|
|
1
|
+
import type { ContentMeta, ContentMetaPatch } from './types.js';
|
|
2
2
|
export declare function localesOf<T>(manifest: {
|
|
3
3
|
locales: Record<string, T | undefined>;
|
|
4
4
|
}): Generator<T>;
|
|
@@ -8,27 +8,67 @@ export declare function localesOf<T>(manifest: {
|
|
|
8
8
|
* between FileSystemContentAPI, InMemoryContentAPI, and other implementations
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
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.
|
|
12
52
|
*/
|
|
13
|
-
export declare function
|
|
53
|
+
export declare function metaString(value: unknown): string | undefined;
|
|
14
54
|
/**
|
|
15
55
|
* Validate that metadata doesn't exceed 4KB when serialized
|
|
16
56
|
* This ensures efficient indexing as per the specification
|
|
17
57
|
*/
|
|
18
58
|
export declare function isMetadataTooLarge(meta: ContentMeta): boolean;
|
|
19
59
|
/**
|
|
20
|
-
* Extract
|
|
21
|
-
* Used when displaying
|
|
60
|
+
* Extract fragment name from various sources
|
|
61
|
+
* Used when displaying fragments in the UI
|
|
22
62
|
*/
|
|
23
|
-
export declare function
|
|
63
|
+
export declare function extractFragmentName(source: string): string;
|
|
24
64
|
/**
|
|
25
|
-
* Validate
|
|
65
|
+
* Validate fragment name according to the specification
|
|
26
66
|
* - Cannot contain dots (reserved for locale separator)
|
|
27
67
|
* - Cannot contain slashes (would create subdirectories)
|
|
28
68
|
* - Cannot contain spaces (for clean filenames)
|
|
29
69
|
* - Must have at least one character
|
|
30
70
|
*/
|
|
31
|
-
export declare function
|
|
71
|
+
export declare function isValidFragmentName(name: string): boolean;
|
|
32
72
|
/**
|
|
33
73
|
* Format file size for display with human-readable units
|
|
34
74
|
* @example formatFileSize(1536) // "1.5 KB"
|
|
@@ -56,7 +96,7 @@ export declare function normalizePathname(pathname: string): string;
|
|
|
56
96
|
* Reasons a pathname can be rejected. Each maps to a specific user-facing
|
|
57
97
|
* error message so the UI can highlight the exact problem.
|
|
58
98
|
*/
|
|
59
|
-
export type PathnameValidationReason = 'empty' | 'whitespace' | 'forbidden_char' | 'control_char' | 'uppercase' | 'non_ascii' | 'traversal_segment' | 'disallowed_char';
|
|
99
|
+
export type PathnameValidationReason = 'empty' | 'whitespace' | 'forbidden_char' | 'control_char' | 'uppercase' | 'non_ascii' | 'traversal_segment' | 'index_segment' | 'disallowed_char';
|
|
60
100
|
export interface PathnameValidationResult {
|
|
61
101
|
/** When valid: the normalized pathname. When invalid: the raw (trimmed) input. */
|
|
62
102
|
value: string;
|
|
@@ -72,7 +112,10 @@ export interface PathnameValidationResult {
|
|
|
72
112
|
* the UI can show a helpful error message.
|
|
73
113
|
*
|
|
74
114
|
* Accepted chars: a–z, 0–9, `-`, `_`, `/`. Mixed case, accents, spaces,
|
|
75
|
-
* `?`, `#`, `\`, and traversal segments (`.`, `..`) are rejected
|
|
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`.
|
|
76
119
|
*/
|
|
77
120
|
export declare function normalizeAndValidatePathname(input: string | undefined | null): PathnameValidationResult;
|
|
78
121
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-utils.d.ts","sourceRoot":"","sources":["../src/content-utils.ts"],"names":[],"mappings":"
|
|
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,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C,MAAM,EAAE,CAAC,CAAC,CAMlG;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,EAC9C,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAQpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiC5G"}
|
package/dist/content-utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid';
|
|
2
2
|
import yaml, { Document, isScalar } from 'yaml';
|
|
3
|
+
import { parseLocaleFilename } from './content-path.js';
|
|
4
|
+
import { readDate } from './read-date.js';
|
|
3
5
|
// Pinned key order at the top of every .mdx frontmatter block. Anything not
|
|
4
6
|
// listed here is appended after, sorted alphabetically for determinism. Without
|
|
5
7
|
// this, the JS object insertion order in the update path leaks into the file
|
|
@@ -33,23 +35,74 @@ export function* localesOf(manifest) {
|
|
|
33
35
|
* between FileSystemContentAPI, InMemoryContentAPI, and other implementations
|
|
34
36
|
*/
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
38
|
+
* Whether content is published at `now`: from its publish time on, until the
|
|
39
|
+
* instant its unpublish time arrives. Empty or invalid dates count as not set.
|
|
40
|
+
* Serving a page, the page feed, the site index and the status the editor
|
|
41
|
+
* shows for a page all ask this, so the site and the editor agree at the
|
|
42
|
+
* unpublish instant.
|
|
43
|
+
* The `published` listing filter asks a different question: whether any
|
|
44
|
+
* locale is still before its unpublish time.
|
|
45
|
+
*
|
|
46
|
+
* The schedule takes a locale version or a page entry. A page entry from the
|
|
47
|
+
* Astro schema holds Date values and nulls, and `undefined` is spelled out
|
|
48
|
+
* rather than left to `?:` so a host compiling with exactOptionalPropertyTypes
|
|
49
|
+
* can pass the entry straight in: its schedule keys can be present with no
|
|
50
|
+
* value.
|
|
37
51
|
*/
|
|
38
|
-
export function isContentPublished(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (localeVersion.unpublishAt) {
|
|
46
|
-
const unpublishDate = new Date(localeVersion.unpublishAt);
|
|
47
|
-
// Check for invalid dates (e.g., from empty strings or invalid values)
|
|
48
|
-
if (!isNaN(unpublishDate.getTime()) && unpublishDate < now)
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
52
|
+
export function isContentPublished(schedule, now = new Date()) {
|
|
53
|
+
const publishAt = readDate(schedule.publishAt);
|
|
54
|
+
if (publishAt && publishAt > now)
|
|
55
|
+
return false;
|
|
56
|
+
const unpublishAt = readDate(schedule.unpublishAt);
|
|
57
|
+
if (unpublishAt && unpublishAt <= now)
|
|
58
|
+
return false;
|
|
51
59
|
return true;
|
|
52
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Apply a dialog's metadata patch: absent keys keep the stored value, null
|
|
63
|
+
* deletes the field. Every update path merges through here so "clear" cannot
|
|
64
|
+
* silently regress back into "keep" at one of the spread sites.
|
|
65
|
+
*/
|
|
66
|
+
export function applyMetaPatch(current, patch) {
|
|
67
|
+
return applyNullClearPatch(current, patch);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The underlying merge: null deletes, absent or undefined keeps. Shared by
|
|
71
|
+
* content metadata and asset-manifest updates so "clear" means one thing
|
|
72
|
+
* everywhere a dialog saves a fixed set of fields.
|
|
73
|
+
*/
|
|
74
|
+
export function applyNullClearPatch(current, patch) {
|
|
75
|
+
// Interfaces carry no index signature, so the spread needs the widened view.
|
|
76
|
+
const merged = { ...current };
|
|
77
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
78
|
+
if (value === null) {
|
|
79
|
+
delete merged[key];
|
|
80
|
+
}
|
|
81
|
+
else if (value !== undefined) {
|
|
82
|
+
if (key === '__proto__') {
|
|
83
|
+
// JSON keys are data, including this legacy prototype setter name.
|
|
84
|
+
Object.defineProperty(merged, key, { value, enumerable: true, configurable: true, writable: true });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
merged[key] = value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return merged;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A meta field read as a string, or undefined when it holds anything else.
|
|
95
|
+
*
|
|
96
|
+
* Fields outside ContentMeta's declared set are typed as JsonValue, because
|
|
97
|
+
* that is all the format guarantees. Content meta is also hand-editable in
|
|
98
|
+
* git, so a reader that wants a string genuinely cannot assume it has one —
|
|
99
|
+
* narrowing here stops a malformed value from posing as a real one, which a
|
|
100
|
+
* cast would wave through. Takes `unknown` so it also serves callers holding
|
|
101
|
+
* meta in a looser shape than ContentMeta.
|
|
102
|
+
*/
|
|
103
|
+
export function metaString(value) {
|
|
104
|
+
return typeof value === 'string' ? value : undefined;
|
|
105
|
+
}
|
|
53
106
|
/**
|
|
54
107
|
* Validate that metadata doesn't exceed 4KB when serialized
|
|
55
108
|
* This ensures efficient indexing as per the specification
|
|
@@ -59,10 +112,10 @@ export function isMetadataTooLarge(meta) {
|
|
|
59
112
|
return size > 4096;
|
|
60
113
|
}
|
|
61
114
|
/**
|
|
62
|
-
* Extract
|
|
63
|
-
* Used when displaying
|
|
115
|
+
* Extract fragment name from various sources
|
|
116
|
+
* Used when displaying fragments in the UI
|
|
64
117
|
*/
|
|
65
|
-
export function
|
|
118
|
+
export function extractFragmentName(source) {
|
|
66
119
|
// If it's a collection/name path, extract the name part
|
|
67
120
|
if (source.includes('/') && !source.includes('.')) {
|
|
68
121
|
const parts = source.split('/');
|
|
@@ -70,28 +123,32 @@ export function extractBlockName(source) {
|
|
|
70
123
|
}
|
|
71
124
|
// If it's a filename, extract the base name
|
|
72
125
|
if (source.includes('.')) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
126
|
+
// Same locale grammar as every reader (content-path.ts), so 'hero.en-US.mdx'
|
|
127
|
+
// displays as 'hero' rather than 'hero.en-US'. The whole source is passed
|
|
128
|
+
// on purpose — the greedy base tolerates '/', so 'heroes/main.en.mdx'
|
|
129
|
+
// names as 'heroes/main'.
|
|
130
|
+
const suffix = parseLocaleFilename(source);
|
|
131
|
+
if (suffix) {
|
|
132
|
+
return suffix.base;
|
|
76
133
|
}
|
|
77
134
|
// Fallback: remove any extension
|
|
78
135
|
return source.replace(/\.[^.]+$/, '');
|
|
79
136
|
}
|
|
80
137
|
// If it's an ID, create a simple name
|
|
81
138
|
if (source.startsWith('vx-')) {
|
|
82
|
-
return `
|
|
139
|
+
return `fragment-${source.substring(3, 8)}`;
|
|
83
140
|
}
|
|
84
141
|
// Otherwise return as-is
|
|
85
142
|
return source;
|
|
86
143
|
}
|
|
87
144
|
/**
|
|
88
|
-
* Validate
|
|
145
|
+
* Validate fragment name according to the specification
|
|
89
146
|
* - Cannot contain dots (reserved for locale separator)
|
|
90
147
|
* - Cannot contain slashes (would create subdirectories)
|
|
91
148
|
* - Cannot contain spaces (for clean filenames)
|
|
92
149
|
* - Must have at least one character
|
|
93
150
|
*/
|
|
94
|
-
export function
|
|
151
|
+
export function isValidFragmentName(name) {
|
|
95
152
|
if (!name || name.length === 0)
|
|
96
153
|
return false;
|
|
97
154
|
if (name.includes('.'))
|
|
@@ -126,7 +183,7 @@ export function getMetadataSize(meta) {
|
|
|
126
183
|
* - Cannot contain special characters that would break URLs
|
|
127
184
|
*/
|
|
128
185
|
export function isValidPathname(pathname) {
|
|
129
|
-
if (!pathname
|
|
186
|
+
if (!pathname?.startsWith('/'))
|
|
130
187
|
return false;
|
|
131
188
|
if (pathname.includes(' '))
|
|
132
189
|
return false;
|
|
@@ -143,18 +200,18 @@ export function isValidPathname(pathname) {
|
|
|
143
200
|
export function normalizePathname(pathname) {
|
|
144
201
|
if (!pathname)
|
|
145
202
|
return '/';
|
|
146
|
-
let
|
|
203
|
+
let normalizedPathname = pathname;
|
|
147
204
|
// Ensure it starts with /
|
|
148
|
-
if (!
|
|
149
|
-
|
|
205
|
+
if (!normalizedPathname.startsWith('/')) {
|
|
206
|
+
normalizedPathname = `/${normalizedPathname}`;
|
|
150
207
|
}
|
|
151
208
|
// Collapse multiple slashes
|
|
152
|
-
|
|
209
|
+
normalizedPathname = normalizedPathname.replace(/\/+/g, '/');
|
|
153
210
|
// Remove trailing slash unless it's the root
|
|
154
|
-
if (
|
|
155
|
-
|
|
211
|
+
if (normalizedPathname !== '/' && normalizedPathname.endsWith('/')) {
|
|
212
|
+
normalizedPathname = normalizedPathname.slice(0, -1);
|
|
156
213
|
}
|
|
157
|
-
return
|
|
214
|
+
return normalizedPathname;
|
|
158
215
|
}
|
|
159
216
|
/**
|
|
160
217
|
* Validate the shape of a CMS pathname and normalize it for storage.
|
|
@@ -164,7 +221,10 @@ export function normalizePathname(pathname) {
|
|
|
164
221
|
* the UI can show a helpful error message.
|
|
165
222
|
*
|
|
166
223
|
* Accepted chars: a–z, 0–9, `-`, `_`, `/`. Mixed case, accents, spaces,
|
|
167
|
-
* `?`, `#`, `\`, and traversal segments (`.`, `..`) are rejected
|
|
224
|
+
* `?`, `#`, `\`, and traversal segments (`.`, `..`) are rejected, as is a
|
|
225
|
+
* last segment `index`: a page's file is named after its path, `/` is stored
|
|
226
|
+
* as `index`, and `blog/index` reads back as `/blog`, so `/index` would be the
|
|
227
|
+
* home page's file and `/blog/index` a second page at `/blog`.
|
|
168
228
|
*/
|
|
169
229
|
export function normalizeAndValidatePathname(input) {
|
|
170
230
|
const raw = (input ?? '').trim();
|
|
@@ -198,7 +258,7 @@ export function normalizeAndValidatePathname(input) {
|
|
|
198
258
|
// Normalize: add leading slash, collapse //, strip trailing slash.
|
|
199
259
|
let value = raw;
|
|
200
260
|
if (!value.startsWith('/'))
|
|
201
|
-
value =
|
|
261
|
+
value = `/${value}`;
|
|
202
262
|
value = value.replace(/\/+/g, '/');
|
|
203
263
|
if (value !== '/' && value.endsWith('/'))
|
|
204
264
|
value = value.slice(0, -1);
|
|
@@ -217,6 +277,14 @@ export function normalizeAndValidatePathname(input) {
|
|
|
217
277
|
}
|
|
218
278
|
}
|
|
219
279
|
}
|
|
280
|
+
if (value.endsWith('/index')) {
|
|
281
|
+
return {
|
|
282
|
+
value,
|
|
283
|
+
valid: false,
|
|
284
|
+
reason: 'index_segment',
|
|
285
|
+
message: 'Path cannot end in `/index`: `/index` is the home page and `/blog/index` is `/blog`',
|
|
286
|
+
};
|
|
287
|
+
}
|
|
220
288
|
// Final allowed-chars check — catches stray dots and anything else.
|
|
221
289
|
if (!/^[a-z0-9\-_/]*$/.test(value)) {
|
|
222
290
|
return {
|
|
@@ -251,7 +319,7 @@ export function parseDate(dateStr) {
|
|
|
251
319
|
return null;
|
|
252
320
|
try {
|
|
253
321
|
const date = new Date(dateStr);
|
|
254
|
-
if (isNaN(date.getTime()))
|
|
322
|
+
if (Number.isNaN(date.getTime()))
|
|
255
323
|
return null;
|
|
256
324
|
return date;
|
|
257
325
|
}
|
|
@@ -350,3 +418,4 @@ export function serializeMdxWithFrontmatter(frontmatterData, mdxContent) {
|
|
|
350
418
|
const body = mdxContent.replace(/^\n+/, '');
|
|
351
419
|
return `---\n${doc.toString()}---\n\n${body}`;
|
|
352
420
|
}
|
|
421
|
+
//# sourceMappingURL=content-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-utils.js","sourceRoot":"","sources":["../src/content-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,4EAA4E;AAC5E,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,qBAAqB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,GAAG,EAAE;QACd,MAAM,CAAC,IAAI,EAAE,IAAI;YACf,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1F,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;YAC7B,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,wEAAwE;IACxE,sEAAsE;IACtE,6EAA6E;IAC7E,4EAA4E;IAC5E,0BAA0B;IAC1B,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAE5C,OAAO,QAAQ,GAAG,CAAC,QAAQ,EAAE,UAAU,IAAI,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FileSystemContentAPI } from './filesystem-content-api';
|
|
2
|
-
import type { ContentAPIOptions } from './types';
|
|
1
|
+
import { FileSystemContentAPI } from './filesystem-content-api.js';
|
|
2
|
+
import type { ContentAPIOptions } from './types.js';
|
|
3
3
|
export type ContentWatcherOptions = ContentAPIOptions;
|
|
4
4
|
export interface WebSocketSender {
|
|
5
5
|
send(payload: {
|
|
@@ -19,7 +19,7 @@ interface ReindexResultLike {
|
|
|
19
19
|
deleted?: {
|
|
20
20
|
id: string;
|
|
21
21
|
locale: string;
|
|
22
|
-
kind: 'page' | '
|
|
22
|
+
kind: 'page' | 'fragment' | 'data';
|
|
23
23
|
}[];
|
|
24
24
|
}
|
|
25
25
|
interface ReindexableContentAPI {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-watcher.d.ts","sourceRoot":"","sources":["../src/content-watcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"content-watcher.d.ts","sourceRoot":"","sources":["../src/content-watcher.ts"],"names":[],"mappings":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AAM;IACvB,KAAK,SAAS,MAAM;IACpB,QAAQ,SAAS,MAAM;EAE1B"}
|
package/dist/content-watcher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalize, resolve } from 'node:path';
|
|
2
|
-
import { FileSystemContentAPI } from './filesystem-content-api';
|
|
2
|
+
import { FileSystemContentAPI } from './filesystem-content-api.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a content API instance for the given options
|
|
5
5
|
*/
|
|
@@ -14,24 +14,26 @@ export async function createContentAPI(options) {
|
|
|
14
14
|
*/
|
|
15
15
|
export function createContentWatchHandlers(contentApi, options, ws, onReindexed) {
|
|
16
16
|
const handleFileChange = async (file, action) => {
|
|
17
|
-
// Only process content files (.mdx, .vxjson, and .json in data/ directory)
|
|
18
|
-
const isContentFile = file.endsWith('.mdx') || file.endsWith('.vxjson');
|
|
19
|
-
const isDataFile = file.endsWith('.json') && file.includes('/data/');
|
|
20
|
-
if (!isContentFile && !isDataFile) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
17
|
// Normalize paths for consistent comparison
|
|
24
18
|
const normalizedFile = normalize(resolve(file));
|
|
25
19
|
const normalizedRoot = normalize(resolve(options.contentRoot));
|
|
26
20
|
const normalizedMdxRoot = options.mdxPagesRoot ? normalize(resolve(options.mdxPagesRoot)) : null;
|
|
21
|
+
// Only the files the content scanner indexes: .mdx and .vxjson, and .json
|
|
22
|
+
// only under the content root's data/ directory. Other .json files under
|
|
23
|
+
// the content root, such as asset metadata records, are not content.
|
|
24
|
+
const isContentFile = normalizedFile.endsWith('.mdx') || normalizedFile.endsWith('.vxjson');
|
|
25
|
+
const isDataFile = normalizedFile.endsWith('.json') && normalizedFile.startsWith(`${normalizedRoot}/data/`);
|
|
26
|
+
if (!isContentFile && !isDataFile) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
27
29
|
// Trailing-slash guard avoids prefix collisions
|
|
28
30
|
// (e.g. `/foo/content-extra/...` matching root `/foo/content`).
|
|
29
|
-
const inContentRoot = normalizedFile === normalizedRoot || normalizedFile.startsWith(normalizedRoot
|
|
31
|
+
const inContentRoot = normalizedFile === normalizedRoot || normalizedFile.startsWith(`${normalizedRoot}/`);
|
|
30
32
|
const inMdxRoot = !!normalizedMdxRoot &&
|
|
31
|
-
(normalizedFile === normalizedMdxRoot || normalizedFile.startsWith(normalizedMdxRoot
|
|
33
|
+
(normalizedFile === normalizedMdxRoot || normalizedFile.startsWith(`${normalizedMdxRoot}/`));
|
|
32
34
|
if (inContentRoot || inMdxRoot) {
|
|
33
35
|
const matchedRoot = inContentRoot ? normalizedRoot : normalizedMdxRoot;
|
|
34
|
-
const relativePath = normalizedFile.replace(matchedRoot
|
|
36
|
+
const relativePath = normalizedFile.replace(`${matchedRoot}/`, '');
|
|
35
37
|
console.log(`[Content] ${action}: ${relativePath}`);
|
|
36
38
|
try {
|
|
37
39
|
// Reindex the file
|
|
@@ -81,3 +83,4 @@ export function createContentWatchHandlers(contentApi, options, ws, onReindexed)
|
|
|
81
83
|
onUnlink: (file) => handleFileChange(file, 'delete'),
|
|
82
84
|
};
|
|
83
85
|
}
|
|
86
|
+
//# sourceMappingURL=content-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-watcher.js","sourceRoot":"","sources":["../src/content-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAyBnE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA8B;IACnE,OAAO,MAAM,oBAAoB,CAAC,MAAM,CAAC;QACvC,GAAG,OAAO;QACV,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,UAAU;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAiC,EACjC,OAA8B,EAC9B,EAAm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,CAAC;YAClF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,gDAAgD,EAAE,KAAK,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;QAC5D,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;QACzD,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
package/dist/data-index.d.ts
CHANGED
package/dist/data-index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-index.d.ts","sourceRoot":"","sources":["../src/data-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"data-index.d.ts","sourceRoot":"","sources":["../src/data-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,SAAU,SAAQ,gBAAgB;CAAG"}
|
package/dist/data-index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BaseContentIndex } from './base-content-index';
|
|
1
|
+
import { BaseContentIndex } from './base-content-index.js';
|
|
2
2
|
/**
|
|
3
3
|
* V8-optimized index for data collections
|
|
4
4
|
* Maintains collection->name->locale lookups
|
|
5
5
|
*/
|
|
6
6
|
export class DataIndex extends BaseContentIndex {
|
|
7
7
|
}
|
|
8
|
+
//# sourceMappingURL=data-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-index.js","sourceRoot":"","sources":["../src/data-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,gBAAgB;CAAG"}
|
package/dist/data.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ContentAPI } from './content-api.interface';
|
|
2
|
-
import type { DataIndex } from './data-index';
|
|
3
|
-
import type { ContentManifest, CreateResult } from './types';
|
|
1
|
+
import type { ContentAPI } from './content-api.interface.js';
|
|
2
|
+
import type { DataIndex } from './data-index.js';
|
|
3
|
+
import type { ContentManifest, ContentMeta, CreateResult } from './types.js';
|
|
4
4
|
export interface DataFilters {
|
|
5
5
|
collection?: string;
|
|
6
6
|
locales?: string[];
|
|
@@ -8,20 +8,12 @@ export interface DataFilters {
|
|
|
8
8
|
export interface CreateDataInput {
|
|
9
9
|
collection: string;
|
|
10
10
|
name: string;
|
|
11
|
-
meta?:
|
|
12
|
-
title?: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
11
|
+
meta?: Partial<ContentMeta>;
|
|
16
12
|
locales: {
|
|
17
13
|
[locale: string]: {
|
|
18
14
|
publishAt?: string | null | false;
|
|
19
15
|
unpublishAt?: string | null | false;
|
|
20
|
-
meta?:
|
|
21
|
-
title?: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
[key: string]: unknown;
|
|
24
|
-
};
|
|
16
|
+
meta?: Partial<ContentMeta>;
|
|
25
17
|
content: {
|
|
26
18
|
data: Record<string, unknown>;
|
|
27
19
|
};
|
package/dist/data.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,E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AG,OAAO,CAE7E;IAGD,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnF;IAGD,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAkBzC;IAGK,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CA6B1D;CACF"}
|
package/dist/data.js
CHANGED
|
@@ -41,16 +41,16 @@ export class Data {
|
|
|
41
41
|
getByName(collection, name, locale) {
|
|
42
42
|
return this.dataIndex.getByName(collection, name, locale);
|
|
43
43
|
}
|
|
44
|
-
// Check if data name is available
|
|
44
|
+
// Check if data name is available, in any letter case as getNameConflict checks it
|
|
45
45
|
isNameAvailable(collection, name, excludeId) {
|
|
46
|
-
|
|
47
|
-
return !existing || existing.id === excludeId;
|
|
46
|
+
return this.getNameConflict(collection, name, excludeId) === null;
|
|
48
47
|
}
|
|
49
48
|
// Get the ID of content that conflicts with a data name
|
|
50
49
|
getNameConflict(collection, name, excludeId) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
// In any letter case: those names share one file on a case-insensitive disk.
|
|
51
|
+
for (const existing of this.dataIndex.getAllByNameInAnyCase(collection, name)) {
|
|
52
|
+
if (existing.id !== excludeId)
|
|
53
|
+
return existing.id;
|
|
54
54
|
}
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
@@ -101,3 +101,4 @@ export class Data {
|
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
+
//# sourceMappingURL=data.js.map
|
package/dist/data.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAyBA,MAAM,OAAO,IAAI;IAEL,GAAG;IACH,SAAS;IAFnB,YACU,GAAe,EACf,SAAoB;mBADpB,GAAG;yBACH,SAAS;I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AqB;QACrB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,cAAc;gBACtB,KAAK,EAAE,IAAI,KAAK,CAAC,sBAAsB,KAAK,CAAC,IAAI,EAAE,CAAC;aACrD,CAAC;QACJ,CAAC;QAED,+CAA+C;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,YAAY;gBACpB,KAAK,EAAE,IAAI,KAAK,CAAC,aAAa,KAAK,CAAC,IAAI,iCAAiC,KAAK,CAAC,UAAU,EAAE,CAAC;aAC7F,CAAC;QACJ,CAAC;QAED,qBAAqB;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC;YAC5B,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorDataBindings } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a site's data bindings off a channel the editor does not control (a
|
|
4
|
+
* build's environment, or a host app that passes them in), or undefined when
|
|
5
|
+
* the value is not bindings at all. A malformed route is dropped and its
|
|
6
|
+
* neighbours kept: one bad route must not cost every other page its data
|
|
7
|
+
* context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readEditorDataBindings(raw: unknown): EditorDataBindings | undefined;
|
|
10
|
+
//# sourceMappingURL=editor-data-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-data-bindings.d.ts","sourceRoot":"","sources":["../src/editor-data-bindings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA8CxE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAUnF"}
|