@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
package/dist/schemas/index.mjs
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
//#region src/schemas/index.ts
|
|
4
|
-
/**
|
|
5
|
-
* Base schema for page metadata - editable fields only.
|
|
6
|
-
* Used by CMS forms for dynamic form generation.
|
|
7
|
-
* Add .describe() for form field labels/hints.
|
|
8
|
-
*/
|
|
9
|
-
const pageEditableSchema = z.object({
|
|
10
|
-
title: z.string().describe("Page title for SEO and browser tab"),
|
|
11
|
-
description: z.string().optional().describe("Meta description for search engines"),
|
|
12
|
-
pathname: z.string().describe("URL path (e.g., /about)"),
|
|
13
|
-
publishAt: z.coerce.date().nullable().optional().describe("Schedule publish date/time"),
|
|
14
|
-
unpublishAt: z.coerce.date().nullable().optional().describe("Schedule unpublish date/time"),
|
|
15
|
-
robots: z.string().optional().describe("Robots meta tag (e.g., index, follow)"),
|
|
16
|
-
canonical: z.string().url().optional().describe("Canonical URL for duplicate content")
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Full page schema with system fields.
|
|
20
|
-
* Used by Astro Content Collections for validation.
|
|
21
|
-
*/
|
|
22
|
-
const pageMetaSchema = pageEditableSchema.extend({
|
|
23
|
-
id: z.string(),
|
|
24
|
-
locale: z.string()
|
|
25
|
-
});
|
|
26
|
-
/**
|
|
27
|
-
* Base schema for block metadata - editable fields only.
|
|
28
|
-
* Used by CMS forms for dynamic form generation.
|
|
29
|
-
* Add .describe() for form field labels/hints.
|
|
30
|
-
*/
|
|
31
|
-
const blockEditableSchema = z.object({
|
|
32
|
-
title: z.string().describe("Display name for the block"),
|
|
33
|
-
description: z.string().optional().describe("Brief description of this block"),
|
|
34
|
-
category: z.string().optional().describe("Category for organizing blocks (e.g., headers, cta, content)"),
|
|
35
|
-
tags: z.array(z.string()).optional().describe("Tags for filtering and organization")
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Full block schema with system fields.
|
|
39
|
-
* Used by Astro Content Collections for validation.
|
|
40
|
-
*/
|
|
41
|
-
const blockMetaSchema = blockEditableSchema.extend({
|
|
42
|
-
id: z.string(),
|
|
43
|
-
locale: z.string(),
|
|
44
|
-
name: z.string()
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* Base schema for data entry metadata - editable fields only.
|
|
48
|
-
* Used by CMS forms for dynamic form generation.
|
|
49
|
-
* Add .describe() for form field labels/hints.
|
|
50
|
-
*/
|
|
51
|
-
const dataEditableSchema = z.object({
|
|
52
|
-
title: z.string().describe("Display name for the entry"),
|
|
53
|
-
description: z.string().optional().describe("Brief description of this entry"),
|
|
54
|
-
category: z.string().optional().describe("Category for organizing entries"),
|
|
55
|
-
tags: z.array(z.string()).optional().describe("Tags for filtering and organization")
|
|
56
|
-
});
|
|
57
|
-
/**
|
|
58
|
-
* Zod schema for data entry metadata.
|
|
59
|
-
* Covers common organizational fields for structured data collections.
|
|
60
|
-
*/
|
|
61
|
-
const dataMetaSchema = dataEditableSchema.extend({
|
|
62
|
-
id: z.string(),
|
|
63
|
-
locale: z.string(),
|
|
64
|
-
name: z.string(),
|
|
65
|
-
data: z.record(z.string(), z.unknown()).optional()
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { blockEditableSchema, blockMetaSchema, dataEditableSchema, dataMetaSchema, pageEditableSchema, pageMetaSchema };
|
|
70
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/schemas/index.ts"],"sourcesContent":["import { z } from 'zod';\n\n// ===== Page Schemas =====\n\n/**\n * Base schema for page metadata - editable fields only.\n * Used by CMS forms for dynamic form generation.\n * Add .describe() for form field labels/hints.\n */\nexport const pageEditableSchema = z.object({\n title: z.string().describe('Page title for SEO and browser tab'),\n description: z.string().optional().describe('Meta description for search engines'),\n pathname: z.string().describe('URL path (e.g., /about)'),\n publishAt: z.coerce.date().nullable().optional().describe('Schedule publish date/time'),\n unpublishAt: z.coerce.date().nullable().optional().describe('Schedule unpublish date/time'),\n robots: z.string().optional().describe('Robots meta tag (e.g., index, follow)'),\n canonical: z.string().url().optional().describe('Canonical URL for duplicate content'),\n});\n\nexport type PageEditable = z.infer<typeof pageEditableSchema>;\n\n/**\n * Full page schema with system fields.\n * Used by Astro Content Collections for validation.\n */\nexport const pageMetaSchema = pageEditableSchema.extend({\n id: z.string(),\n locale: z.string(),\n});\n\nexport type PageMeta = z.infer<typeof pageMetaSchema>;\n\n// ===== Block Schemas =====\n\n/**\n * Base schema for block metadata - editable fields only.\n * Used by CMS forms for dynamic form generation.\n * Add .describe() for form field labels/hints.\n */\nexport const blockEditableSchema = z.object({\n title: z.string().describe('Display name for the block'),\n description: z.string().optional().describe('Brief description of this block'),\n category: z.string().optional().describe('Category for organizing blocks (e.g., headers, cta, content)'),\n tags: z.array(z.string()).optional().describe('Tags for filtering and organization'),\n});\n\nexport type BlockEditable = z.infer<typeof blockEditableSchema>;\n\n/**\n * Full block schema with system fields.\n * Used by Astro Content Collections for validation.\n */\nexport const blockMetaSchema = blockEditableSchema.extend({\n id: z.string(),\n locale: z.string(),\n name: z.string(),\n});\n\nexport type BlockMeta = z.infer<typeof blockMetaSchema>;\n\n// ===== Data Schemas =====\n\n/**\n * Base schema for data entry metadata - editable fields only.\n * Used by CMS forms for dynamic form generation.\n * Add .describe() for form field labels/hints.\n */\nexport const dataEditableSchema = z.object({\n title: z.string().describe('Display name for the entry'),\n description: z.string().optional().describe('Brief description of this entry'),\n category: z.string().optional().describe('Category for organizing entries'),\n tags: z.array(z.string()).optional().describe('Tags for filtering and organization'),\n});\n\nexport type DataEditable = z.infer<typeof dataEditableSchema>;\n\n/**\n * Zod schema for data entry metadata.\n * Covers common organizational fields for structured data collections.\n */\nexport const dataMetaSchema = dataEditableSchema.extend({\n // System fields (added by loader)\n id: z.string(),\n locale: z.string(),\n name: z.string(),\n\n // Actual data content (arbitrary JSON structure)\n data: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport type DataMeta = z.infer<typeof dataMetaSchema>;\n"],"mappings":";;;;;;;;AASA,MAAa,qBAAqB,EAAE,OAAO;CACzC,OAAO,EAAE,QAAQ,CAAC,SAAS,qCAAqC;CAChE,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,sCAAsC;CAClF,UAAU,EAAE,QAAQ,CAAC,SAAS,0BAA0B;CACxD,WAAW,EAAE,OAAO,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,6BAA6B;CACvF,aAAa,EAAE,OAAO,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,+BAA+B;CAC3F,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,wCAAwC;CAC/E,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,sCAAsC;CACvF,CAAC;;;;;AAQF,MAAa,iBAAiB,mBAAmB,OAAO;CACtD,IAAI,EAAE,QAAQ;CACd,QAAQ,EAAE,QAAQ;CACnB,CAAC;;;;;;AAWF,MAAa,sBAAsB,EAAE,OAAO;CAC1C,OAAO,EAAE,QAAQ,CAAC,SAAS,6BAA6B;CACxD,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,kCAAkC;CAC9E,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,+DAA+D;CACxG,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,SAAS,sCAAsC;CACrF,CAAC;;;;;AAQF,MAAa,kBAAkB,oBAAoB,OAAO;CACxD,IAAI,EAAE,QAAQ;CACd,QAAQ,EAAE,QAAQ;CAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;;;;;;AAWF,MAAa,qBAAqB,EAAE,OAAO;CACzC,OAAO,EAAE,QAAQ,CAAC,SAAS,6BAA6B;CACxD,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,kCAAkC;CAC9E,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,kCAAkC;CAC3E,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,SAAS,sCAAsC;CACrF,CAAC;;;;;AAQF,MAAa,iBAAiB,mBAAmB,OAAO;CAEtD,IAAI,EAAE,QAAQ;CACd,QAAQ,EAAE,QAAQ;CAClB,MAAM,EAAE,QAAQ;CAGhB,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,UAAU;CACnD,CAAC"}
|
package/dist/site-vNtJ5jCh.mjs
DELETED
|
@@ -1,538 +0,0 @@
|
|
|
1
|
-
import sortKeys from "sort-keys";
|
|
2
|
-
import { nanoid } from "nanoid";
|
|
3
|
-
import yaml from "yaml";
|
|
4
|
-
|
|
5
|
-
//#region src/blocks.ts
|
|
6
|
-
var Blocks = class {
|
|
7
|
-
constructor(api, blockIndex) {
|
|
8
|
-
this.api = api;
|
|
9
|
-
this.blockIndex = blockIndex;
|
|
10
|
-
}
|
|
11
|
-
*listContent(filters) {
|
|
12
|
-
if (filters?.collection) if (filters.locales && filters.locales.length > 0) {
|
|
13
|
-
for (const manifest of this.blockIndex.getManifestsByCollection(filters.collection)) if (filters.locales.some((locale) => manifest.locales[locale])) yield manifest;
|
|
14
|
-
} else yield* this.blockIndex.getManifestsByCollection(filters.collection);
|
|
15
|
-
else if (filters?.locales && filters.locales.length > 0) {
|
|
16
|
-
for (const manifest of this.blockIndex.getAllManifests()) if (filters.locales.some((locale) => manifest.locales[locale])) yield manifest;
|
|
17
|
-
} else yield* this.blockIndex.getAllManifests();
|
|
18
|
-
}
|
|
19
|
-
get collections() {
|
|
20
|
-
return this.blockIndex.collections;
|
|
21
|
-
}
|
|
22
|
-
getByName(collection, name, locale) {
|
|
23
|
-
return this.blockIndex.getByName(collection, name, locale);
|
|
24
|
-
}
|
|
25
|
-
isNameAvailable(collection, name, excludeId) {
|
|
26
|
-
const existing = this.getByName(collection, name);
|
|
27
|
-
return !existing || existing.id === excludeId;
|
|
28
|
-
}
|
|
29
|
-
getNameConflict(collection, name, excludeId) {
|
|
30
|
-
const existing = this.getByName(collection, name);
|
|
31
|
-
if (existing && existing.id !== excludeId) return existing.id;
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
isBlockNameValid(blockName) {
|
|
35
|
-
if (!blockName || blockName.trim() === "") return false;
|
|
36
|
-
if (blockName.includes(".")) return false;
|
|
37
|
-
if (blockName.includes("/") || blockName.includes("\\")) return false;
|
|
38
|
-
return /^[a-zA-Z0-9_-]+$/.test(blockName);
|
|
39
|
-
}
|
|
40
|
-
async create(data) {
|
|
41
|
-
if (!this.isBlockNameValid(data.name)) return {
|
|
42
|
-
success: false,
|
|
43
|
-
reason: "invalid_name",
|
|
44
|
-
error: /* @__PURE__ */ new Error(`Invalid block name: ${data.name}`)
|
|
45
|
-
};
|
|
46
|
-
if (this.getByName(data.collection, data.name)) return {
|
|
47
|
-
success: false,
|
|
48
|
-
reason: "name_taken",
|
|
49
|
-
error: /* @__PURE__ */ new Error(`Block name ${data.name} already exists in collection ${data.collection}`)
|
|
50
|
-
};
|
|
51
|
-
return this.api.createContent({
|
|
52
|
-
kind: "block",
|
|
53
|
-
collection: data.collection,
|
|
54
|
-
type: "mdx",
|
|
55
|
-
name: data.name,
|
|
56
|
-
meta: data.meta,
|
|
57
|
-
locales: data.locales
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/content-utils.ts
|
|
64
|
-
function* localesOf(manifest) {
|
|
65
|
-
for (const value of Object.values(manifest.locales)) if (value) yield value;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Pure utility functions for content operations
|
|
69
|
-
* These functions don't depend on any class state and can be shared
|
|
70
|
-
* between FileSystemContentAPI, InMemoryContentAPI, and other implementations
|
|
71
|
-
*/
|
|
72
|
-
/**
|
|
73
|
-
* Check if content is published based on publishAt/unpublishAt dates
|
|
74
|
-
*/
|
|
75
|
-
function isContentPublished(localeVersion, now = /* @__PURE__ */ new Date()) {
|
|
76
|
-
if (localeVersion.publishAt) {
|
|
77
|
-
const publishDate = new Date(localeVersion.publishAt);
|
|
78
|
-
if (!isNaN(publishDate.getTime()) && publishDate > now) return false;
|
|
79
|
-
}
|
|
80
|
-
if (localeVersion.unpublishAt) {
|
|
81
|
-
const unpublishDate = new Date(localeVersion.unpublishAt);
|
|
82
|
-
if (!isNaN(unpublishDate.getTime()) && unpublishDate < now) return false;
|
|
83
|
-
}
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Validate that metadata doesn't exceed 4KB when serialized
|
|
88
|
-
* This ensures efficient indexing as per the specification
|
|
89
|
-
*/
|
|
90
|
-
function isMetadataTooLarge(meta) {
|
|
91
|
-
return new TextEncoder().encode(JSON.stringify(meta)).length > 4096;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Extract block name from various sources
|
|
95
|
-
* Used when displaying blocks in the UI
|
|
96
|
-
*/
|
|
97
|
-
function extractBlockName(source) {
|
|
98
|
-
if (source.includes("/") && !source.includes(".")) {
|
|
99
|
-
const parts = source.split("/");
|
|
100
|
-
return parts[parts.length - 1];
|
|
101
|
-
}
|
|
102
|
-
if (source.includes(".")) {
|
|
103
|
-
const match = source.match(/^(.+?)\.([a-z]{2})?\.(mdx|vxjson)$/);
|
|
104
|
-
if (match) return match[1];
|
|
105
|
-
return source.replace(/\.[^.]+$/, "");
|
|
106
|
-
}
|
|
107
|
-
if (source.startsWith("vx-")) return `block-${source.substring(3, 8)}`;
|
|
108
|
-
return source;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Validate block name according to the specification
|
|
112
|
-
* - Cannot contain dots (reserved for locale separator)
|
|
113
|
-
* - Cannot contain slashes (would create subdirectories)
|
|
114
|
-
* - Cannot contain spaces (for clean filenames)
|
|
115
|
-
* - Must have at least one character
|
|
116
|
-
*/
|
|
117
|
-
function isValidBlockName(name) {
|
|
118
|
-
if (!name || name.length === 0) return false;
|
|
119
|
-
if (name.includes(".")) return false;
|
|
120
|
-
if (name.includes("/")) return false;
|
|
121
|
-
if (name.includes(" ")) return false;
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Format file size for display with human-readable units
|
|
126
|
-
* @example formatFileSize(1536) // "1.5 KB"
|
|
127
|
-
*/
|
|
128
|
-
function formatFileSize(bytes) {
|
|
129
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
130
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
131
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Calculate metadata size in bytes
|
|
135
|
-
*/
|
|
136
|
-
function getMetadataSize(meta) {
|
|
137
|
-
return new TextEncoder().encode(JSON.stringify(meta)).length;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Check if a pathname is valid
|
|
141
|
-
* - Must start with /
|
|
142
|
-
* - Cannot contain spaces (should be URL-encoded)
|
|
143
|
-
* - Cannot contain special characters that would break URLs
|
|
144
|
-
*/
|
|
145
|
-
function isValidPathname(pathname) {
|
|
146
|
-
if (!pathname || !pathname.startsWith("/")) return false;
|
|
147
|
-
if (pathname.includes(" ")) return false;
|
|
148
|
-
if (pathname.includes("?") || pathname.includes("#")) return false;
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Normalize a pathname to ensure consistency
|
|
153
|
-
* - Ensure it starts with /
|
|
154
|
-
* - Remove trailing slashes (except for root)
|
|
155
|
-
* - Collapse multiple slashes
|
|
156
|
-
*/
|
|
157
|
-
function normalizePathname(pathname) {
|
|
158
|
-
if (!pathname) return "/";
|
|
159
|
-
if (!pathname.startsWith("/")) pathname = "/" + pathname;
|
|
160
|
-
pathname = pathname.replace(/\/+/g, "/");
|
|
161
|
-
if (pathname !== "/" && pathname.endsWith("/")) pathname = pathname.slice(0, -1);
|
|
162
|
-
return pathname;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Generate a content ID in the standard format
|
|
166
|
-
* IDs are prefixed with "vx-" followed by 8 random characters
|
|
167
|
-
*/
|
|
168
|
-
function generateContentId() {
|
|
169
|
-
return `vx-${nanoid(8)}`;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get the current date/time in ISO format
|
|
173
|
-
* Used for timestamps in content files
|
|
174
|
-
*/
|
|
175
|
-
function getCurrentISODate() {
|
|
176
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Parse a date string safely
|
|
180
|
-
* Returns null if invalid
|
|
181
|
-
*/
|
|
182
|
-
function parseDate(dateStr) {
|
|
183
|
-
if (!dateStr) return null;
|
|
184
|
-
try {
|
|
185
|
-
const date = new Date(dateStr);
|
|
186
|
-
if (isNaN(date.getTime())) return null;
|
|
187
|
-
return date;
|
|
188
|
-
} catch {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Creates a V8-optimized object by mapping site names to values.
|
|
194
|
-
* Ensures all objects have the same hidden class by adding properties in consistent order.
|
|
195
|
-
*
|
|
196
|
-
* @param sitesConfig - Sites configuration containing site names
|
|
197
|
-
* @param factory - Function that creates the value for each site
|
|
198
|
-
* @returns Object with all sites initialized in alphabetical order
|
|
199
|
-
*/
|
|
200
|
-
function mapSiteNames(sitesConfig, factory) {
|
|
201
|
-
const obj = {};
|
|
202
|
-
for (const siteName of Object.keys(sitesConfig.sites)) obj[siteName] = factory(siteName);
|
|
203
|
-
return obj;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Creates a V8-optimized object by mapping locale names to values.
|
|
207
|
-
* Ensures all objects have the same hidden class by adding properties in consistent order.
|
|
208
|
-
*
|
|
209
|
-
* @param locales - Array of locale codes
|
|
210
|
-
* @param factory - Function that creates the value for each locale
|
|
211
|
-
* @returns Object with all locales initialized in array order
|
|
212
|
-
*/
|
|
213
|
-
function mapLocales(locales, factory) {
|
|
214
|
-
const obj = {};
|
|
215
|
-
for (const locale of locales) obj[locale] = factory(locale);
|
|
216
|
-
return obj;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Resolves a publish date value to a valid string or undefined.
|
|
220
|
-
* Handles various input types including null, false, and empty strings.
|
|
221
|
-
*
|
|
222
|
-
* @param updateValue - The value being updated (string | null | false | undefined)
|
|
223
|
-
* @param currentValue - The current value to fall back to if updateValue is undefined
|
|
224
|
-
* @returns A valid date string or undefined
|
|
225
|
-
*/
|
|
226
|
-
function resolvePublishDate(updateValue, currentValue) {
|
|
227
|
-
if (updateValue !== void 0) return updateValue && typeof updateValue === "string" ? updateValue : void 0;
|
|
228
|
-
return currentValue;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Serializes MDX content with frontmatter.
|
|
232
|
-
* This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
|
|
233
|
-
* consistent MDX output that includes frontmatter for variable access.
|
|
234
|
-
*
|
|
235
|
-
* @param frontmatterData - The frontmatter data to serialize
|
|
236
|
-
* @param mdxContent - The MDX content (without frontmatter)
|
|
237
|
-
* @returns Complete MDX file content with frontmatter
|
|
238
|
-
*/
|
|
239
|
-
function serializeMdxWithFrontmatter(frontmatterData, mdxContent) {
|
|
240
|
-
return `---\n${yaml.stringify(frontmatterData)}---\n\n${mdxContent}`;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/content-operations.ts
|
|
245
|
-
/**
|
|
246
|
-
* Validate and prepare metadata for storage
|
|
247
|
-
* Ensures title exists and metadata doesn't exceed 4KB
|
|
248
|
-
*/
|
|
249
|
-
function validateAndPrepareMetadata(meta) {
|
|
250
|
-
if (!meta.title) return {
|
|
251
|
-
valid: false,
|
|
252
|
-
error: "Title is required in metadata"
|
|
253
|
-
};
|
|
254
|
-
const sortedMeta = sortKeys(meta, { deep: true });
|
|
255
|
-
const metaJson = JSON.stringify(sortedMeta, null, 2);
|
|
256
|
-
const metaSize = new TextEncoder().encode(metaJson).length;
|
|
257
|
-
if (metaSize > 4088) return {
|
|
258
|
-
valid: false,
|
|
259
|
-
error: `Metadata exceeds 4KB limit (${metaSize} bytes)`
|
|
260
|
-
};
|
|
261
|
-
return {
|
|
262
|
-
valid: true,
|
|
263
|
-
sortedMeta,
|
|
264
|
-
size: metaSize
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Build pathname history update
|
|
269
|
-
*/
|
|
270
|
-
function buildPathnameHistory(oldPathname, newPathname, isPublished, now) {
|
|
271
|
-
const history = {};
|
|
272
|
-
if (oldPathname && newPathname && oldPathname !== newPathname && isPublished) history[oldPathname] = now;
|
|
273
|
-
return history;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Build a locale manifest
|
|
277
|
-
*/
|
|
278
|
-
function buildLocaleVersion(params) {
|
|
279
|
-
const manifest = {
|
|
280
|
-
locale: params.locale,
|
|
281
|
-
etag: params.etag,
|
|
282
|
-
created: params.created,
|
|
283
|
-
modified: params.modified,
|
|
284
|
-
meta: params.meta
|
|
285
|
-
};
|
|
286
|
-
if (params.publishAt) manifest.publishAt = params.publishAt;
|
|
287
|
-
if (params.unpublishAt) manifest.unpublishAt = params.unpublishAt;
|
|
288
|
-
if (params.pathname && params.kind === "page") manifest.pathname = params.pathname;
|
|
289
|
-
if (params.name && (params.kind === "block" || params.kind === "data")) manifest.name = params.name;
|
|
290
|
-
if (params.previousPathnames && Object.keys(params.previousPathnames).length > 0) manifest.previousPathnames = params.previousPathnames;
|
|
291
|
-
return manifest;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Update publish dates on a locale manifest
|
|
295
|
-
*/
|
|
296
|
-
function updatePublishDates(manifest, data) {
|
|
297
|
-
if ("publishAt" in data) if (data.publishAt && typeof data.publishAt === "string") manifest.publishAt = data.publishAt;
|
|
298
|
-
else delete manifest.publishAt;
|
|
299
|
-
if ("unpublishAt" in data) if (data.unpublishAt && typeof data.unpublishAt === "string") manifest.unpublishAt = data.unpublishAt;
|
|
300
|
-
else delete manifest.unpublishAt;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Validate content creation data
|
|
304
|
-
*/
|
|
305
|
-
function validateCreateContent(data, sites, blocks, dataApi) {
|
|
306
|
-
for (const localeData of Object.values(data.locales)) {
|
|
307
|
-
const validation = validateAndPrepareMetadata({
|
|
308
|
-
...data.meta,
|
|
309
|
-
...localeData.meta
|
|
310
|
-
});
|
|
311
|
-
if (!validation.valid) return {
|
|
312
|
-
valid: false,
|
|
313
|
-
error: validation.error,
|
|
314
|
-
reason: "metadata_too_large"
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
if (data.kind === "page") {
|
|
318
|
-
if (!data.site) return {
|
|
319
|
-
valid: false,
|
|
320
|
-
error: "Site is required for pages"
|
|
321
|
-
};
|
|
322
|
-
const site = sites[data.site];
|
|
323
|
-
if (!site) return {
|
|
324
|
-
valid: false,
|
|
325
|
-
error: `Site ${data.site} not found`
|
|
326
|
-
};
|
|
327
|
-
for (const [locale, localeData] of Object.entries(data.locales)) {
|
|
328
|
-
const pathname = localeData.pathname;
|
|
329
|
-
if (!pathname) return {
|
|
330
|
-
valid: false,
|
|
331
|
-
error: `Pathname is required for pages (locale: ${locale})`
|
|
332
|
-
};
|
|
333
|
-
const existingId = site.getPathnameConflict(pathname, locale);
|
|
334
|
-
if (existingId) return {
|
|
335
|
-
valid: false,
|
|
336
|
-
error: `Pathname ${pathname} already exists`,
|
|
337
|
-
reason: "pathname_taken",
|
|
338
|
-
existingId
|
|
339
|
-
};
|
|
340
|
-
if (site.isPathnameInRedirects(pathname, locale)) return {
|
|
341
|
-
valid: false,
|
|
342
|
-
error: `Pathname ${pathname} is already in use as a redirect`,
|
|
343
|
-
reason: "pathname_in_redirects"
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
if (data.kind === "block") {
|
|
348
|
-
if (!data.name) return {
|
|
349
|
-
valid: false,
|
|
350
|
-
error: "Block name is required",
|
|
351
|
-
reason: "invalid_name"
|
|
352
|
-
};
|
|
353
|
-
if (!blocks.isBlockNameValid(data.name)) return {
|
|
354
|
-
valid: false,
|
|
355
|
-
error: `Invalid block name: ${data.name}. Block names must contain only alphanumeric characters, hyphens, and underscores.`,
|
|
356
|
-
reason: "invalid_name"
|
|
357
|
-
};
|
|
358
|
-
const existingId = blocks.getNameConflict(data.collection, data.name);
|
|
359
|
-
if (existingId) return {
|
|
360
|
-
valid: false,
|
|
361
|
-
error: `Block name ${data.name} already exists in collection ${data.collection}`,
|
|
362
|
-
reason: "name_taken",
|
|
363
|
-
existingId
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
if (data.kind === "data" && dataApi) {
|
|
367
|
-
if (!data.name) return {
|
|
368
|
-
valid: false,
|
|
369
|
-
error: "Data name is required",
|
|
370
|
-
reason: "invalid_name"
|
|
371
|
-
};
|
|
372
|
-
if (!dataApi.isDataNameValid(data.name)) return {
|
|
373
|
-
valid: false,
|
|
374
|
-
error: `Invalid data name: ${data.name}. Data names must contain only alphanumeric characters, hyphens, and underscores.`,
|
|
375
|
-
reason: "invalid_name"
|
|
376
|
-
};
|
|
377
|
-
const existingId = dataApi.getNameConflict(data.collection, data.name);
|
|
378
|
-
if (existingId) return {
|
|
379
|
-
valid: false,
|
|
380
|
-
error: `Data name ${data.name} already exists in collection ${data.collection}`,
|
|
381
|
-
reason: "name_taken",
|
|
382
|
-
existingId
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
return { valid: true };
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Update scope bit flags
|
|
389
|
-
* Can be combined with bitwise OR and checked with bitwise AND
|
|
390
|
-
*/
|
|
391
|
-
const UPDATE_SCOPE = {
|
|
392
|
-
NONE: 0,
|
|
393
|
-
META: 1,
|
|
394
|
-
CONTENT: 2,
|
|
395
|
-
BOTH: 3
|
|
396
|
-
};
|
|
397
|
-
/**
|
|
398
|
-
* Determine what parts of content are being updated
|
|
399
|
-
* Returns bit flags that can be checked with bitwise AND
|
|
400
|
-
*
|
|
401
|
-
* Example usage:
|
|
402
|
-
* ```
|
|
403
|
-
* const scope = analyzeUpdateScope(data);
|
|
404
|
-
* if (scope & UPDATE_SCOPE.META) { // metadata is being updated }
|
|
405
|
-
* if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }
|
|
406
|
-
* if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
function analyzeUpdateScope(data) {
|
|
410
|
-
let scope = UPDATE_SCOPE.NONE;
|
|
411
|
-
if (data.meta !== void 0 || data.publishAt !== void 0 || data.unpublishAt !== void 0) scope |= UPDATE_SCOPE.META;
|
|
412
|
-
if (data.content !== void 0) scope |= UPDATE_SCOPE.CONTENT;
|
|
413
|
-
return scope;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Determine whether the modified timestamp should be updated
|
|
417
|
-
* Updates for ANY change - either metadata or content
|
|
418
|
-
*/
|
|
419
|
-
function shouldUpdateModifiedTimestamp(data) {
|
|
420
|
-
return analyzeUpdateScope(data) !== UPDATE_SCOPE.NONE;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
//#endregion
|
|
424
|
-
//#region src/site.ts
|
|
425
|
-
var Site = class {
|
|
426
|
-
constructor(siteName, api, siteIndex) {
|
|
427
|
-
this.siteName = siteName;
|
|
428
|
-
this.api = api;
|
|
429
|
-
this.siteIndex = siteIndex;
|
|
430
|
-
}
|
|
431
|
-
*listContent(filters) {
|
|
432
|
-
let manifests;
|
|
433
|
-
if (filters?.locales && filters.locales.length === 1) manifests = this.siteIndex.getManifestsByLocale(filters.locales[0]);
|
|
434
|
-
else manifests = this.siteIndex.getAllManifests();
|
|
435
|
-
if (filters?.collection || filters?.type || filters?.published !== void 0) for (const manifest of manifests) {
|
|
436
|
-
if (filters.collection && manifest.collection !== filters.collection) continue;
|
|
437
|
-
if (filters.type && manifest.type !== filters.type) continue;
|
|
438
|
-
if (filters.published !== void 0) {
|
|
439
|
-
let hasPublishedLocale = false;
|
|
440
|
-
for (const locale of localesOf(manifest)) if (!locale.unpublishAt || new Date(locale.unpublishAt) > /* @__PURE__ */ new Date()) {
|
|
441
|
-
hasPublishedLocale = true;
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
if (filters.published !== hasPublishedLocale) continue;
|
|
445
|
-
}
|
|
446
|
-
yield manifest;
|
|
447
|
-
}
|
|
448
|
-
else yield* manifests;
|
|
449
|
-
}
|
|
450
|
-
*listPages(locale) {
|
|
451
|
-
const filters = {};
|
|
452
|
-
if (locale) filters.locales = [locale];
|
|
453
|
-
yield* this.listContent(filters);
|
|
454
|
-
}
|
|
455
|
-
get collections() {
|
|
456
|
-
return this.siteIndex.collections;
|
|
457
|
-
}
|
|
458
|
-
getByPathname(pathname, locale) {
|
|
459
|
-
return this.siteIndex.getByPathname(pathname, locale);
|
|
460
|
-
}
|
|
461
|
-
getByPreviousPathname(pathname, locale) {
|
|
462
|
-
return this.siteIndex.getByPreviousPathname(pathname, locale);
|
|
463
|
-
}
|
|
464
|
-
async move(id, locale, newPathname) {
|
|
465
|
-
const existing = this.getByPathname(newPathname, locale);
|
|
466
|
-
if (existing && existing.id !== id) return {
|
|
467
|
-
moved: false,
|
|
468
|
-
reason: "already_exists"
|
|
469
|
-
};
|
|
470
|
-
const content = await this.api.getLocalized(id, locale);
|
|
471
|
-
if (!content) return {
|
|
472
|
-
moved: false,
|
|
473
|
-
reason: "not_found"
|
|
474
|
-
};
|
|
475
|
-
const updateResult = await this.api.updateLocalized({
|
|
476
|
-
id,
|
|
477
|
-
locale,
|
|
478
|
-
data: {
|
|
479
|
-
pathname: newPathname,
|
|
480
|
-
meta: content.localized.meta
|
|
481
|
-
},
|
|
482
|
-
etag: content.localized.etag
|
|
483
|
-
});
|
|
484
|
-
if (!updateResult.success) return {
|
|
485
|
-
moved: false,
|
|
486
|
-
reason: updateResult.reason,
|
|
487
|
-
error: updateResult.error
|
|
488
|
-
};
|
|
489
|
-
return {
|
|
490
|
-
moved: true,
|
|
491
|
-
previousPathname: content.localized.pathname,
|
|
492
|
-
etag: updateResult.etag
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
getRedirect(pathname) {
|
|
496
|
-
return this.siteIndex.getByPreviousPathname(pathname);
|
|
497
|
-
}
|
|
498
|
-
isPathnameAvailable(pathname, locale, excludeId) {
|
|
499
|
-
const existing = this.getByPathname(pathname, locale);
|
|
500
|
-
if (existing && existing.id !== excludeId) return false;
|
|
501
|
-
const redirect = this.getByPreviousPathname(pathname, locale);
|
|
502
|
-
if (redirect && redirect.id !== excludeId) return false;
|
|
503
|
-
return true;
|
|
504
|
-
}
|
|
505
|
-
getPathnameConflict(pathname, locale, excludeId) {
|
|
506
|
-
const existing = this.getByPathname(pathname, locale);
|
|
507
|
-
if (existing && existing.id !== excludeId) return existing.id;
|
|
508
|
-
return null;
|
|
509
|
-
}
|
|
510
|
-
isPathnameInRedirects(pathname, locale) {
|
|
511
|
-
return this.getByPreviousPathname(pathname, locale) !== null;
|
|
512
|
-
}
|
|
513
|
-
async create(data) {
|
|
514
|
-
for (const [locale, localeData] of Object.entries(data.locales)) {
|
|
515
|
-
if (this.getByPathname(localeData.pathname, locale)) return {
|
|
516
|
-
success: false,
|
|
517
|
-
reason: "pathname_taken",
|
|
518
|
-
error: /* @__PURE__ */ new Error(`Pathname ${localeData.pathname} is already in use for locale ${locale}`)
|
|
519
|
-
};
|
|
520
|
-
if (this.getRedirect(localeData.pathname)) return {
|
|
521
|
-
success: false,
|
|
522
|
-
reason: "pathname_in_redirects",
|
|
523
|
-
error: /* @__PURE__ */ new Error(`Pathname ${localeData.pathname} is in redirect history for locale ${locale}`)
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
return this.api.createContent({
|
|
527
|
-
kind: "page",
|
|
528
|
-
site: this.siteName,
|
|
529
|
-
collection: data.collection,
|
|
530
|
-
type: "puck",
|
|
531
|
-
locales: data.locales
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
//#endregion
|
|
537
|
-
export { parseDate as C, Blocks as E, normalizePathname as S, serializeMdxWithFrontmatter as T, isValidBlockName as _, buildPathnameHistory as a, mapLocales as b, validateAndPrepareMetadata as c, formatFileSize as d, generateContentId as f, isMetadataTooLarge as g, isContentPublished as h, buildLocaleVersion as i, validateCreateContent as l, getMetadataSize as m, UPDATE_SCOPE as n, shouldUpdateModifiedTimestamp as o, getCurrentISODate as p, analyzeUpdateScope as r, updatePublishDates as s, Site as t, extractBlockName as u, isValidPathname as v, resolvePublishDate as w, mapSiteNames as x, localesOf as y };
|
|
538
|
-
//# sourceMappingURL=site-vNtJ5jCh.mjs.map
|