@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas-CFRD0FIQ.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// ===== MDX Page Schemas =====\n\n/**\n * Base schema for mdx-type page frontmatter — renderer-neutral.\n *\n * Default for the CMS form when editing an mdx page; projects override via\n * `mdxPages.schema` when they want a renderer-specific shape (e.g. an\n * Astro-collection schema with extra fields).\n *\n * Permissive on purpose: `.passthrough()` lets unknown frontmatter keys flow\n * through unchanged so the file's existing fields are never lost on save.\n */\nexport const mdxPageFrontmatterSchema = z\n .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 draft: z.boolean().optional().describe('Hide the page from production builds'),\n })\n .passthrough();\n\nexport type MdxPageFrontmatter = z.infer<typeof mdxPageFrontmatterSchema>;\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 dataM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CAC/D,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,qCAAqC;CACjF,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,sCAAsC;AAC/E,CAAC,CAAC,CACD,YAAY;;;;;;AAWf,MAAa,qBAAqB,EAAE,OAAO;CACzC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,4BAA4B;CACvD,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,iCAAiC;CAC7E,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,iCAAiC;CAC1E,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,qCAAqC;AACrF,CAAC;;;;;AAQD,MAAa,iBAAiB,mBAAmB,OAAO;CAEtD,IAAI,EAAE,OAAO;CACb,QAAQ,EAAE,OAAO;CACjB,MAAM,EAAE,OAAO;CAGf,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;AACnD,CAAC"}
|
package/dist/site-8oaj1Q60.mjs
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
import { p as normalizeAndValidatePathname, u as localesOf } from "./content-utils-fWNHTrPy.mjs";
|
|
2
|
-
import sortKeys from "sort-keys";
|
|
3
|
-
//#region src/blocks.ts
|
|
4
|
-
var Blocks = class {
|
|
5
|
-
api;
|
|
6
|
-
blockIndex;
|
|
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
|
-
//#endregion
|
|
62
|
-
//#region src/content-operations.ts
|
|
63
|
-
/**
|
|
64
|
-
* Validate and prepare metadata for storage
|
|
65
|
-
* Ensures title exists and metadata doesn't exceed 4KB
|
|
66
|
-
*/
|
|
67
|
-
function validateAndPrepareMetadata(meta) {
|
|
68
|
-
if (!meta.title) return {
|
|
69
|
-
valid: false,
|
|
70
|
-
error: "Title is required in metadata"
|
|
71
|
-
};
|
|
72
|
-
const sortedMeta = sortKeys(meta, { deep: true });
|
|
73
|
-
const metaJson = JSON.stringify(sortedMeta, null, 2);
|
|
74
|
-
const metaSize = new TextEncoder().encode(metaJson).length;
|
|
75
|
-
if (metaSize > 4088) return {
|
|
76
|
-
valid: false,
|
|
77
|
-
error: `Metadata exceeds 4KB limit (${metaSize} bytes)`
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
valid: true,
|
|
81
|
-
sortedMeta,
|
|
82
|
-
size: metaSize
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Build pathname history update
|
|
87
|
-
*/
|
|
88
|
-
function buildPathnameHistory(oldPathname, newPathname, isPublished, now) {
|
|
89
|
-
const history = {};
|
|
90
|
-
if (oldPathname && newPathname && oldPathname !== newPathname && isPublished) history[oldPathname] = now;
|
|
91
|
-
return history;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Build a locale manifest
|
|
95
|
-
*/
|
|
96
|
-
function buildLocaleVersion(params) {
|
|
97
|
-
const manifest = {
|
|
98
|
-
locale: params.locale,
|
|
99
|
-
etag: params.etag,
|
|
100
|
-
created: params.created,
|
|
101
|
-
modified: params.modified,
|
|
102
|
-
meta: params.meta
|
|
103
|
-
};
|
|
104
|
-
if (params.publishAt) manifest.publishAt = params.publishAt;
|
|
105
|
-
if (params.unpublishAt) manifest.unpublishAt = params.unpublishAt;
|
|
106
|
-
if (params.pathname && params.kind === "page") manifest.pathname = params.pathname;
|
|
107
|
-
if (params.name && (params.kind === "block" || params.kind === "data")) manifest.name = params.name;
|
|
108
|
-
if (params.previousPathnames && Object.keys(params.previousPathnames).length > 0) manifest.previousPathnames = params.previousPathnames;
|
|
109
|
-
return manifest;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Update publish dates on a locale manifest
|
|
113
|
-
*/
|
|
114
|
-
function updatePublishDates(manifest, data) {
|
|
115
|
-
if ("publishAt" in data) if (data.publishAt && typeof data.publishAt === "string") manifest.publishAt = data.publishAt;
|
|
116
|
-
else delete manifest.publishAt;
|
|
117
|
-
if ("unpublishAt" in data) if (data.unpublishAt && typeof data.unpublishAt === "string") manifest.unpublishAt = data.unpublishAt;
|
|
118
|
-
else delete manifest.unpublishAt;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Validate content creation data
|
|
122
|
-
*/
|
|
123
|
-
function validateCreateContent(data, sites, blocks, dataApi) {
|
|
124
|
-
for (const localeData of Object.values(data.locales)) {
|
|
125
|
-
const validation = validateAndPrepareMetadata({
|
|
126
|
-
...data.meta,
|
|
127
|
-
...localeData.meta
|
|
128
|
-
});
|
|
129
|
-
if (!validation.valid) return {
|
|
130
|
-
valid: false,
|
|
131
|
-
error: validation.error,
|
|
132
|
-
reason: "metadata_too_large"
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
if (data.kind === "page") {
|
|
136
|
-
if (!data.site) return {
|
|
137
|
-
valid: false,
|
|
138
|
-
error: "Site is required for pages"
|
|
139
|
-
};
|
|
140
|
-
const site = sites[data.site];
|
|
141
|
-
if (!site) return {
|
|
142
|
-
valid: false,
|
|
143
|
-
error: `Site ${data.site} not found`
|
|
144
|
-
};
|
|
145
|
-
for (const [locale, localeData] of Object.entries(data.locales)) {
|
|
146
|
-
const pathname = localeData.pathname;
|
|
147
|
-
if (!pathname) return {
|
|
148
|
-
valid: false,
|
|
149
|
-
error: `Pathname is required for pages (locale: ${locale})`
|
|
150
|
-
};
|
|
151
|
-
const validation = normalizeAndValidatePathname(pathname);
|
|
152
|
-
if (!validation.valid) return {
|
|
153
|
-
valid: false,
|
|
154
|
-
error: `Invalid pathname for locale ${locale}: ${validation.message}`,
|
|
155
|
-
reason: "invalid_pathname"
|
|
156
|
-
};
|
|
157
|
-
localeData.pathname = validation.value;
|
|
158
|
-
const normalized = validation.value;
|
|
159
|
-
const existingId = site.getPathnameConflict(normalized, locale);
|
|
160
|
-
if (existingId) return {
|
|
161
|
-
valid: false,
|
|
162
|
-
error: `Pathname ${normalized} already exists`,
|
|
163
|
-
reason: "pathname_taken",
|
|
164
|
-
existingId
|
|
165
|
-
};
|
|
166
|
-
if (site.isPathnameInRedirects(normalized, locale)) return {
|
|
167
|
-
valid: false,
|
|
168
|
-
error: `Pathname ${normalized} is already in use as a redirect`,
|
|
169
|
-
reason: "pathname_in_redirects"
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (data.kind === "block") {
|
|
174
|
-
if (!data.name) return {
|
|
175
|
-
valid: false,
|
|
176
|
-
error: "Block name is required",
|
|
177
|
-
reason: "invalid_name"
|
|
178
|
-
};
|
|
179
|
-
if (!blocks.isBlockNameValid(data.name)) return {
|
|
180
|
-
valid: false,
|
|
181
|
-
error: `Invalid block name: ${data.name}. Block names must contain only alphanumeric characters, hyphens, and underscores.`,
|
|
182
|
-
reason: "invalid_name"
|
|
183
|
-
};
|
|
184
|
-
const existingId = blocks.getNameConflict(data.collection, data.name);
|
|
185
|
-
if (existingId) return {
|
|
186
|
-
valid: false,
|
|
187
|
-
error: `Block name ${data.name} already exists in collection ${data.collection}`,
|
|
188
|
-
reason: "name_taken",
|
|
189
|
-
existingId
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
if (data.kind === "data" && dataApi) {
|
|
193
|
-
if (!data.name) return {
|
|
194
|
-
valid: false,
|
|
195
|
-
error: "Data name is required",
|
|
196
|
-
reason: "invalid_name"
|
|
197
|
-
};
|
|
198
|
-
if (!dataApi.isDataNameValid(data.name)) return {
|
|
199
|
-
valid: false,
|
|
200
|
-
error: `Invalid data name: ${data.name}. Data names must contain only alphanumeric characters, hyphens, and underscores.`,
|
|
201
|
-
reason: "invalid_name"
|
|
202
|
-
};
|
|
203
|
-
const existingId = dataApi.getNameConflict(data.collection, data.name);
|
|
204
|
-
if (existingId) return {
|
|
205
|
-
valid: false,
|
|
206
|
-
error: `Data name ${data.name} already exists in collection ${data.collection}`,
|
|
207
|
-
reason: "name_taken",
|
|
208
|
-
existingId
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
return { valid: true };
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Update scope bit flags
|
|
215
|
-
* Can be combined with bitwise OR and checked with bitwise AND
|
|
216
|
-
*/
|
|
217
|
-
const UPDATE_SCOPE = {
|
|
218
|
-
NONE: 0,
|
|
219
|
-
META: 1,
|
|
220
|
-
CONTENT: 2,
|
|
221
|
-
BOTH: 3
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Determine what parts of content are being updated
|
|
225
|
-
* Returns bit flags that can be checked with bitwise AND
|
|
226
|
-
*
|
|
227
|
-
* Example usage:
|
|
228
|
-
* ```
|
|
229
|
-
* const scope = analyzeUpdateScope(data);
|
|
230
|
-
* if (scope & UPDATE_SCOPE.META) { // metadata is being updated }
|
|
231
|
-
* if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }
|
|
232
|
-
* if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
function analyzeUpdateScope(data) {
|
|
236
|
-
let scope = UPDATE_SCOPE.NONE;
|
|
237
|
-
if (data.meta !== void 0 || data.publishAt !== void 0 || data.unpublishAt !== void 0) scope |= UPDATE_SCOPE.META;
|
|
238
|
-
if (data.content !== void 0) scope |= UPDATE_SCOPE.CONTENT;
|
|
239
|
-
return scope;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Determine whether the modified timestamp should be updated
|
|
243
|
-
* Updates for ANY change - either metadata or content
|
|
244
|
-
*/
|
|
245
|
-
function shouldUpdateModifiedTimestamp(data) {
|
|
246
|
-
return analyzeUpdateScope(data) !== UPDATE_SCOPE.NONE;
|
|
247
|
-
}
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/site.ts
|
|
250
|
-
var Site = class {
|
|
251
|
-
siteName;
|
|
252
|
-
api;
|
|
253
|
-
siteIndex;
|
|
254
|
-
constructor(siteName, api, siteIndex) {
|
|
255
|
-
this.siteName = siteName;
|
|
256
|
-
this.api = api;
|
|
257
|
-
this.siteIndex = siteIndex;
|
|
258
|
-
}
|
|
259
|
-
*listContent(filters) {
|
|
260
|
-
let manifests;
|
|
261
|
-
if (filters?.locales && filters.locales.length === 1) manifests = this.siteIndex.getManifestsByLocale(filters.locales[0]);
|
|
262
|
-
else manifests = this.siteIndex.getAllManifests();
|
|
263
|
-
if (filters?.collection || filters?.type || filters?.published !== void 0) for (const manifest of manifests) {
|
|
264
|
-
if (filters.collection && manifest.collection !== filters.collection) continue;
|
|
265
|
-
if (filters.type && manifest.type !== filters.type) continue;
|
|
266
|
-
if (filters.published !== void 0) {
|
|
267
|
-
let hasPublishedLocale = false;
|
|
268
|
-
for (const locale of localesOf(manifest)) if (!locale.unpublishAt || new Date(locale.unpublishAt) > /* @__PURE__ */ new Date()) {
|
|
269
|
-
hasPublishedLocale = true;
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
if (filters.published !== hasPublishedLocale) continue;
|
|
273
|
-
}
|
|
274
|
-
yield manifest;
|
|
275
|
-
}
|
|
276
|
-
else yield* manifests;
|
|
277
|
-
}
|
|
278
|
-
*listPages(locale) {
|
|
279
|
-
const filters = {};
|
|
280
|
-
if (locale) filters.locales = [locale];
|
|
281
|
-
yield* this.listContent(filters);
|
|
282
|
-
}
|
|
283
|
-
get collections() {
|
|
284
|
-
return this.siteIndex.collections;
|
|
285
|
-
}
|
|
286
|
-
getByPathname(pathname, locale) {
|
|
287
|
-
return this.siteIndex.getByPathname(pathname, locale);
|
|
288
|
-
}
|
|
289
|
-
getByPreviousPathname(pathname, locale) {
|
|
290
|
-
return this.siteIndex.getByPreviousPathname(pathname, locale);
|
|
291
|
-
}
|
|
292
|
-
async move(id, locale, newPathname) {
|
|
293
|
-
const existing = this.getByPathname(newPathname, locale);
|
|
294
|
-
if (existing && existing.id !== id) return {
|
|
295
|
-
moved: false,
|
|
296
|
-
reason: "already_exists"
|
|
297
|
-
};
|
|
298
|
-
const content = await this.api.getLocalized(id, locale);
|
|
299
|
-
if (!content) return {
|
|
300
|
-
moved: false,
|
|
301
|
-
reason: "not_found"
|
|
302
|
-
};
|
|
303
|
-
const updateResult = await this.api.updateLocalized({
|
|
304
|
-
id,
|
|
305
|
-
locale,
|
|
306
|
-
data: {
|
|
307
|
-
pathname: newPathname,
|
|
308
|
-
meta: content.localized.meta
|
|
309
|
-
},
|
|
310
|
-
etag: content.localized.etag
|
|
311
|
-
});
|
|
312
|
-
if (!updateResult.success) return {
|
|
313
|
-
moved: false,
|
|
314
|
-
reason: updateResult.reason,
|
|
315
|
-
error: updateResult.error
|
|
316
|
-
};
|
|
317
|
-
return {
|
|
318
|
-
moved: true,
|
|
319
|
-
previousPathname: content.localized.pathname,
|
|
320
|
-
etag: updateResult.etag
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
getRedirect(pathname) {
|
|
324
|
-
return this.siteIndex.getByPreviousPathname(pathname);
|
|
325
|
-
}
|
|
326
|
-
isPathnameAvailable(pathname, locale, excludeId) {
|
|
327
|
-
const existing = this.getByPathname(pathname, locale);
|
|
328
|
-
if (existing && existing.id !== excludeId) return false;
|
|
329
|
-
const redirect = this.getByPreviousPathname(pathname, locale);
|
|
330
|
-
if (redirect && redirect.id !== excludeId) return false;
|
|
331
|
-
return true;
|
|
332
|
-
}
|
|
333
|
-
getPathnameConflict(pathname, locale, excludeId) {
|
|
334
|
-
const existing = this.getByPathname(pathname, locale);
|
|
335
|
-
if (existing && existing.id !== excludeId) return existing.id;
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
isPathnameInRedirects(pathname, locale) {
|
|
339
|
-
return this.getByPreviousPathname(pathname, locale) !== null;
|
|
340
|
-
}
|
|
341
|
-
async create(data) {
|
|
342
|
-
for (const [locale, localeData] of Object.entries(data.locales)) {
|
|
343
|
-
if (this.getByPathname(localeData.pathname, locale)) return {
|
|
344
|
-
success: false,
|
|
345
|
-
reason: "pathname_taken",
|
|
346
|
-
error: /* @__PURE__ */ new Error(`Pathname ${localeData.pathname} is already in use for locale ${locale}`)
|
|
347
|
-
};
|
|
348
|
-
if (this.getRedirect(localeData.pathname)) return {
|
|
349
|
-
success: false,
|
|
350
|
-
reason: "pathname_in_redirects",
|
|
351
|
-
error: /* @__PURE__ */ new Error(`Pathname ${localeData.pathname} is in redirect history for locale ${locale}`)
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
return this.api.createContent({
|
|
355
|
-
kind: "page",
|
|
356
|
-
site: this.siteName,
|
|
357
|
-
collection: data.collection,
|
|
358
|
-
type: "puck",
|
|
359
|
-
locales: data.locales
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
//#endregion
|
|
364
|
-
export { buildPathnameHistory as a, validateAndPrepareMetadata as c, buildLocaleVersion as i, validateCreateContent as l, UPDATE_SCOPE as n, shouldUpdateModifiedTimestamp as o, analyzeUpdateScope as r, updatePublishDates as s, Site as t, Blocks as u };
|
|
365
|
-
|
|
366
|
-
//# sourceMappingURL=site-8oaj1Q60.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"site-8oaj1Q60.mjs","names":[],"sources":["../src/blocks.ts","../src/content-operations.ts","../src/site.ts"],"sourcesContent":["import type { BlockIndex } from './block-index';\nimport type { ContentAPI } from './content-api.interface';\nimport type { BlockFilters, ContentManifest, CreateBlockInput, CreateResult } from './types';\n\nexport class Blocks {\n constructor(\n private api: ContentAPI,\n private blockIndex: BlockIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: BlockFilters): Generator<ContentManifest> {\n // Choose the most efficient method based on filters\n if (filters?.collection) {\n if (filters.locales && filters.locales.length > 0) {\n // Filter by locales after getting collection entries\n for (const manifest of this.blockIndex.getManifestsByCollection(filters.collection)) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getManifestsByCollection(filters.collection);\n }\n } else if (filters?.locales && filters.locales.length > 0) {\n // For multiple locales, we need to check each\n for (const manifest of this.blockIndex.getAllManifests()) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getAllManifests();\n }\n }\n\n // Get all block collections\n get collections(): Set<string> {\n return this.blockIndex.collections;\n }\n\n // Block operations (returns null if not found)\n getByName(collection: string, name: string, locale?: string): ContentManifest | null {\n return this.blockIndex.getByName(collection, name, locale);\n }\n\n // Check if block name is available\n isNameAvailable(collection: string, name: string, excludeId?: string): boolean {\n const existing = this.getByName(collection, name);\n return !existing || existing.id === excludeId;\n }\n\n // Get the ID of content that conflicts with a block name\n getNameConflict(collection: string, name: string, excludeId?: string): string | null {\n const existing = this.getByName(collection, name);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if block name is valid\n isBlockNameValid(blockName: string): boolean {\n // Block names must not be empty\n if (!blockName || blockName.trim() === '') {\n return false;\n }\n\n // Block names must not contain dots (would interfere with locale suffixes)\n if (blockName.includes('.')) {\n return false;\n }\n\n // Block names must not contain path separators\n if (blockName.includes('/') || blockName.includes('\\\\')) {\n return false;\n }\n\n // Block names should only contain alphanumeric, hyphens, underscores\n return /^[a-zA-Z0-9_-]+$/.test(blockName);\n }\n\n // Create block with name validation\n async create(data: CreateBlockInput): Promise<CreateResult> {\n // Validate block name\n if (!this.isBlockNameValid(data.name)) {\n return {\n success: false,\n reason: 'invalid_name',\n error: new Error(`Invalid block name: ${data.name}`),\n };\n }\n\n // Check if name is already taken in any locale\n const existing = this.getByName(data.collection, data.name);\n if (existing) {\n return {\n success: false,\n reason: 'name_taken',\n error: new Error(`Block name ${data.name} already exists in collection ${data.collection}`),\n };\n }\n\n // Create the content\n return this.api.createContent({\n kind: 'block',\n collection: data.collection,\n type: 'mdx',\n name: data.name,\n meta: data.meta,\n locales: data.locales,\n });\n }\n}\n","import sortKeys from 'sort-keys';\nimport type { Blocks } from './blocks';\nimport { generateContentId, isContentPublished, normalizeAndValidatePathname } from './content-utils';\nimport type { Site } from './site';\nimport type { ContentMeta, CreateContentInput, LocaleUpdateData, LocaleVersion } from './types';\n\n/**\n * Shared business logic for content operations\n * Used by both FileSystemContentAPI and InMemoryContentAPI\n */\n\n// Validation result types\nexport interface ValidationResult {\n valid: boolean;\n error?: string;\n sortedMeta?: ContentMeta;\n size?: number;\n}\n\nexport interface CreateValidationResult {\n valid: boolean;\n error?: string;\n reason?:\n | 'metadata_too_large'\n | 'pathname_taken'\n | 'pathname_in_redirects'\n | 'invalid_pathname'\n | 'invalid_name'\n | 'name_taken';\n existingId?: string;\n}\n\n/**\n * Validate and prepare metadata for storage\n * Ensures title exists and metadata doesn't exceed 4KB\n */\nexport function validateAndPrepareMetadata(meta: Partial<ContentMeta>): ValidationResult {\n // Ensure title is present\n if (!meta.title) {\n return {\n valid: false,\n error: 'Title is required in metadata',\n };\n }\n\n const sortedMeta = sortKeys(meta, { deep: true }) as ContentMeta; // We've validated title exists\n const metaJson = JSON.stringify(sortedMeta, null, 2);\n const metaSize = new TextEncoder().encode(metaJson).length;\n\n if (metaSize > 4088) {\n // Leave 8 bytes for safety\n return {\n valid: false,\n error: `Metadata exceeds 4KB limit (${metaSize} bytes)`,\n };\n }\n\n return {\n valid: true,\n sortedMeta,\n size: metaSize,\n };\n}\n\n/**\n * Build pathname history update\n */\nexport function buildPathnameHistory(\n oldPathname: string | undefined,\n newPathname: string | undefined,\n isPublished: boolean,\n now: string,\n): Record<string, string> {\n const history: Record<string, string> = {};\n\n if (oldPathname && newPathname && oldPathname !== newPathname && isPublished) {\n history[oldPathname] = now;\n }\n\n return history;\n}\n\n/**\n * Build a locale manifest\n */\nexport function buildLocaleVersion(params: {\n locale: string;\n etag: string;\n created: string;\n modified: string;\n meta: ContentMeta;\n kind: 'block' | 'page' | 'data';\n publishAt?: string;\n unpublishAt?: string;\n pathname?: string;\n name?: string;\n previousPathnames?: Record<string, string>;\n}): LocaleVersion {\n const manifest: LocaleVersion = {\n locale: params.locale,\n etag: params.etag,\n created: params.created,\n modified: params.modified,\n meta: params.meta,\n };\n\n // Add optional fields only if they exist\n if (params.publishAt) {\n manifest.publishAt = params.publishAt;\n }\n if (params.unpublishAt) {\n manifest.unpublishAt = params.unpublishAt;\n }\n if (params.pathname && params.kind === 'page') {\n manifest.pathname = params.pathname;\n }\n if (params.name && (params.kind === 'block' || params.kind === 'data')) {\n manifest.name = params.name;\n }\n if (params.previousPathnames && Object.keys(params.previousPathnames).length > 0) {\n manifest.previousPathnames = params.previousPathnames;\n }\n\n return manifest;\n}\n\n/**\n * Update publish dates on a locale manifest\n */\nexport function updatePublishDates(manifest: LocaleVersion, data: LocaleUpdateData): void {\n // Handle publishAt\n if ('publishAt' in data) {\n if (data.publishAt && typeof data.publishAt === 'string') {\n manifest.publishAt = data.publishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.publishAt;\n }\n }\n\n // Handle unpublishAt\n if ('unpublishAt' in data) {\n if (data.unpublishAt && typeof data.unpublishAt === 'string') {\n manifest.unpublishAt = data.unpublishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.unpublishAt;\n }\n }\n}\n\n/**\n * Validate content creation data\n */\nexport function validateCreateContent(\n data: CreateContentInput,\n sites: Record<string, Site>,\n blocks: Blocks,\n dataApi?: {\n isDataNameValid: (name: string) => boolean;\n getNameConflict: (collection: string, name: string) => string | null;\n },\n): CreateValidationResult {\n // Validate metadata for all locales\n for (const localeData of Object.values(data.locales)) {\n const meta = { ...data.meta, ...localeData.meta };\n const validation = validateAndPrepareMetadata(meta);\n if (!validation.valid) {\n return {\n valid: false,\n error: validation.error,\n reason: 'metadata_too_large',\n };\n }\n }\n\n // Validate pathname for pages\n if (data.kind === 'page') {\n if (!data.site) {\n return {\n valid: false,\n error: 'Site is required for pages',\n };\n }\n\n const site = sites[data.site];\n if (!site) {\n return {\n valid: false,\n error: `Site ${data.site} not found`,\n };\n }\n\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const pathname = localeData.pathname;\n\n // Pathname is required for pages\n if (!pathname) {\n return {\n valid: false,\n error: `Pathname is required for pages (locale: ${locale})`,\n };\n }\n\n // Validate and normalize pathname shape. The normalized value is\n // written back to localeData so the rest of the create flow (file\n // writes, indexing) sees the cleaned form.\n const validation = normalizeAndValidatePathname(pathname);\n if (!validation.valid) {\n return {\n valid: false,\n error: `Invalid pathname for locale ${locale}: ${validation.message}`,\n reason: 'invalid_pathname',\n };\n }\n localeData.pathname = validation.value;\n const normalized = validation.value;\n\n // Check if pathname is already taken\n const existingId = site.getPathnameConflict(normalized, locale);\n if (existingId) {\n return {\n valid: false,\n error: `Pathname ${normalized} already exists`,\n reason: 'pathname_taken',\n existingId,\n };\n }\n\n // Check if pathname is in redirects\n if (site.isPathnameInRedirects(normalized, locale)) {\n return {\n valid: false,\n error: `Pathname ${normalized} is already in use as a redirect`,\n reason: 'pathname_in_redirects',\n };\n }\n }\n }\n\n // Validate block name uniqueness\n if (data.kind === 'block') {\n if (!data.name) {\n return {\n valid: false,\n error: 'Block name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate block name format\n if (!blocks.isBlockNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid block name: ${data.name}. Block names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = blocks.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Block name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n // Validate data entry name uniqueness\n if (data.kind === 'data' && dataApi) {\n if (!data.name) {\n return {\n valid: false,\n error: 'Data name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate data name format\n if (!dataApi.isDataNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid data name: ${data.name}. Data names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = dataApi.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Data name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n return { valid: true };\n}\n\n/**\n * Generate a new content ID\n */\n/**\n * Check if content is published\n */\nexport { generateContentId, isContentPublished };\n\n/**\n * Update scope bit flags\n * Can be combined with bitwise OR and checked with bitwise AND\n */\nexport const UPDATE_SCOPE = {\n NONE: 0, // 00\n META: 1 << 0, // 01\n CONTENT: 1 << 1, // 10\n BOTH: 3, // 11 (META | CONTENT)\n} as const;\n\nexport type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];\n\n/**\n * Determine what parts of content are being updated\n * Returns bit flags that can be checked with bitwise AND\n *\n * Example usage:\n * ```\n * const scope = analyzeUpdateScope(data);\n * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }\n * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }\n * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }\n * ```\n */\nexport function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope {\n let scope = UPDATE_SCOPE.NONE;\n\n // Note: pathname is NOT considered a metadata change because:\n // - For pages, pathname is derived from file path, not stored in metadata\n // - Pathname changes don't affect the metadata hash in the ETag\n if (data.meta !== undefined || data.publishAt !== undefined || data.unpublishAt !== undefined) {\n scope |= UPDATE_SCOPE.META;\n }\n\n if (data.content !== undefined) {\n scope |= UPDATE_SCOPE.CONTENT;\n }\n\n return scope;\n}\n\n/**\n * Determine whether the modified timestamp should be updated\n * Updates for ANY change - either metadata or content\n */\nexport function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean {\n const scope = analyzeUpdateScope(data);\n return scope !== UPDATE_SCOPE.NONE;\n}\n","import type { ContentAPI } from './content-api.interface';\nimport { localesOf } from './content-utils';\nimport type { SiteIndex } from './site-index';\nimport type { ContentManifest, CreatePageInput, CreateResult, MoveResult, SiteFilters } from './types';\n\nexport class Site {\n constructor(\n private siteName: string,\n private api: ContentAPI,\n private siteIndex: SiteIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: SiteFilters): Generator<ContentManifest> {\n // Get the base manifests using the most efficient method\n let manifests: Generator<ContentManifest>;\n\n if (filters?.locales && filters.locales.length === 1) {\n manifests = this.siteIndex.getManifestsByLocale(filters.locales[0]);\n } else {\n manifests = this.siteIndex.getAllManifests();\n }\n\n // Apply additional filters if needed\n if (filters?.collection || filters?.type || filters?.published !== undefined) {\n for (const manifest of manifests) {\n if (filters.collection && manifest.collection !== filters.collection) continue;\n if (filters.type && manifest.type !== filters.type) continue;\n if (filters.published !== undefined) {\n // Check if any locale is published\n let hasPublishedLocale = false;\n for (const locale of localesOf(manifest)) {\n if (!locale.unpublishAt || new Date(locale.unpublishAt) > new Date()) {\n hasPublishedLocale = true;\n break;\n }\n }\n if (filters.published !== hasPublishedLocale) continue;\n }\n yield manifest;\n }\n } else {\n // No additional filters, yield all manifests\n yield* manifests;\n }\n }\n\n // List pages (convenience method for middleware)\n *listPages(locale?: string): Generator<ContentManifest> {\n const filters: SiteFilters = {};\n if (locale) filters.locales = [locale];\n\n yield* this.listContent(filters);\n }\n\n // Get all collections for this site\n get collections(): Set<string> {\n return this.siteIndex.collections;\n }\n\n // Pathname operations (returns null if available, ContentManifest if taken)\n getByPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPathname(pathname, locale);\n }\n\n // Get by previous pathname (for redirects)\n getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname, locale);\n }\n\n // Move content (handles rename + redirect tracking)\n async move(id: string, locale: string, newPathname: string): Promise<MoveResult> {\n // Check if new pathname is available\n const existing = this.getByPathname(newPathname, locale);\n if (existing && existing.id !== id) {\n return {\n moved: false,\n reason: 'already_exists',\n };\n }\n\n // Get current content\n const content = await this.api.getLocalized(id, locale);\n if (!content) {\n return {\n moved: false,\n reason: 'not_found',\n };\n }\n\n // Update with new pathname (this will handle previousPathnames)\n const updateResult = await this.api.updateLocalized({\n id,\n locale,\n data: {\n pathname: newPathname,\n meta: content.localized.meta,\n },\n etag: content.localized.etag,\n });\n\n if (!updateResult.success) {\n return {\n moved: false,\n reason: updateResult.reason,\n error: updateResult.error,\n };\n }\n\n return {\n moved: true,\n previousPathname: content.localized.pathname,\n etag: updateResult.etag,\n };\n }\n\n // Check if pathname is in redirect history\n getRedirect(pathname: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname);\n }\n\n // Validate pathname is available (not taken or in redirects)\n isPathnameAvailable(pathname: string, locale: string, excludeId?: string): boolean {\n // Check if pathname is already taken\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return false;\n }\n\n // Check if pathname is in redirects\n const redirect = this.getByPreviousPathname(pathname, locale);\n if (redirect && redirect.id !== excludeId) {\n return false;\n }\n\n return true;\n }\n\n // Get the ID of content that conflicts with a pathname\n getPathnameConflict(pathname: string, locale: string, excludeId?: string): string | null {\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if pathname is in redirects\n isPathnameInRedirects(pathname: string, locale: string): boolean {\n return this.getByPreviousPathname(pathname, locale) !== null;\n }\n\n // Create page with validation\n async create(data: CreatePageInput): Promise<CreateResult> {\n // Validate pathname availability for all locales\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const existing = this.getByPathname(localeData.pathname, locale);\n if (existing) {\n return {\n success: false,\n reason: 'pathname_taken',\n error: new Error(`Pathname ${localeData.pathname} is already in use for locale ${locale}`),\n };\n }\n\n // Check redirects too\n const redirect = this.getRedirect(localeData.pathname);\n if (redirect) {\n return {\n success: false,\n reason: 'pathname_in_redirects',\n error: new Error(`Pathname ${localeData.pathname} is in redirect history for locale ${locale}`),\n };\n }\n }\n\n return this.api.createContent({\n kind: 'page',\n site: this.siteName,\n collection: data.collection,\n type: 'puck',\n locales: data.locales,\n });\n }\n}\n"],"mappings":";;;AAIA,IAAa,SAAb,MAAoB;CAER;CACA;CAFV,YACE,KACA,YACA;EAFQ,KAAA,MAAA;EACA,KAAA,aAAA;CACP;CAGH,CAAC,YAAY,SAAoD;EAE/D,IAAI,SAAS,YACX,IAAI,QAAQ,WAAW,QAAQ,QAAQ,SAAS,GAEzC;QAAA,MAAM,YAAY,KAAK,WAAW,yBAAyB,QAAQ,UAAU,GAChF,IAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,OAAO,GAC3D,MAAM;EAAA,OAIV,OAAO,KAAK,WAAW,yBAAyB,QAAQ,UAAU;OAE/D,IAAI,SAAS,WAAW,QAAQ,QAAQ,SAAS,GAEjD;QAAA,MAAM,YAAY,KAAK,WAAW,gBAAgB,GACrD,IAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,OAAO,GAC3D,MAAM;EAAA,OAIV,OAAO,KAAK,WAAW,gBAAgB;CAE3C;CAGA,IAAI,cAA2B;EAC7B,OAAO,KAAK,WAAW;CACzB;CAGA,UAAU,YAAoB,MAAc,QAAyC;EACnF,OAAO,KAAK,WAAW,UAAU,YAAY,MAAM,MAAM;CAC3D;CAGA,gBAAgB,YAAoB,MAAc,WAA6B;EAC7E,MAAM,WAAW,KAAK,UAAU,YAAY,IAAI;EAChD,OAAO,CAAC,YAAY,SAAS,OAAO;CACtC;CAGA,gBAAgB,YAAo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AU,MAAM;EACpD,IAAI,YAAY,SAAS,OAAO,WAC9B,OAAO;EAIT,MAAM,WAAW,KAAK,sBAAsB,UAAU,MAAM;EAC5D,IAAI,YAAY,SAAS,OAAO,WAC9B,OAAO;EAGT,OAAO;CACT;CAGA,oBAAoB,UAAkB,QAAgB,WAAmC;EACvF,MAAM,WAAW,KAAK,cAAc,UAAU,MAAM;EACpD,IAAI,YAAY,SAAS,OAAO,WAC9B,OAAO,SAAS;EAElB,OAAO;CACT;CAGA,sBAAsB,UAAkB,QAAyB;EAC/D,OAAO,KAAK,sBAAsB,UAAU,MAAM,MAAM;CAC1D;CAGA,MAAM,OAAO,MAA8C;EAEzD,KAAK,MAAM,CAAC,QAAQ,eAAe,OAAO,QAAQ,KAAK,OAAO,GAAG;GAE/D,IADiB,KAAK,cAAc,WAAW,UAAU,MAC9C,GACT,OAAO;IACL,SAAS;IACT,QAAQ;IACR,uBAAO,IAAI,MAAM,YAAY,WAAW,SAAS,gCAAgC,QAAQ;GAC3F;GAKF,IADiB,KAAK,YAAY,WAAW,QAClC,GACT,OAAO;IACL,SAAS;IACT,QAAQ;IACR,uBAAO,IAAI,MAAM,YAAY,WAAW,SAAS,qCAAqC,QAAQ;GAChG;EAEJ;EAEA,OAAO,KAAK,IAAI,cAAc;GAC5B,MAAM;GACN,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,MAAM;GACN,SAAS,KAAK;EAChB,CAAC;CACH;AACF"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { c as ContentIdentity, k as LocaleVersion, o as ContentData, u as ContentManifest } from "./types-DjfhS272.mjs";
|
|
2
|
-
//#region src/base-content-index.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Base class for content indexes (blocks, data)
|
|
5
|
-
* Maintains collection->name->locale lookups with V8-optimized structures
|
|
6
|
-
*/
|
|
7
|
-
declare class BaseContentIndex {
|
|
8
|
-
protected index: Map<string, ContentManifest>;
|
|
9
|
-
protected contentCache: Map<string, Record<string, ContentData | null>>;
|
|
10
|
-
protected nameIndex: Map<string, Map<string, ContentManifest>>;
|
|
11
|
-
readonly collections: Set<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Add or update content in the index
|
|
14
|
-
* Merges manifest locales and updates content cache if provided
|
|
15
|
-
*/
|
|
16
|
-
addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
|
|
17
|
-
/**
|
|
18
|
-
* Remove a specific locale from an entry
|
|
19
|
-
*/
|
|
20
|
-
removeLocale(id: string, locale: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Remove an entry from the index
|
|
23
|
-
*/
|
|
24
|
-
removeEntry(id: string): void;
|
|
25
|
-
/**
|
|
26
|
-
* Get cached content for a specific locale
|
|
27
|
-
*/
|
|
28
|
-
getCachedContent(id: string, locale: string): ContentData | null;
|
|
29
|
-
/**
|
|
30
|
-
* Get content manifest
|
|
31
|
-
*/
|
|
32
|
-
getManifest(id: string): ContentManifest | null;
|
|
33
|
-
/**
|
|
34
|
-
* Find entry by name
|
|
35
|
-
*/
|
|
36
|
-
getByName(collection: string, name: string, locale?: string): ContentManifest | null;
|
|
37
|
-
/**
|
|
38
|
-
* Generator for all manifests
|
|
39
|
-
*/
|
|
40
|
-
getAllManifests(): Generator<ContentManifest>;
|
|
41
|
-
/**
|
|
42
|
-
* Generator for manifests by locale
|
|
43
|
-
*/
|
|
44
|
-
getManifestsByLocale(locale: string): Generator<ContentManifest>;
|
|
45
|
-
/**
|
|
46
|
-
* Generator for manifests by collection
|
|
47
|
-
*/
|
|
48
|
-
getManifestsByCollection(collection: string): Generator<ContentManifest>;
|
|
49
|
-
/**
|
|
50
|
-
* Get the count of indexed content entries (unique IDs)
|
|
51
|
-
*/
|
|
52
|
-
get entryCount(): number;
|
|
53
|
-
/**
|
|
54
|
-
* Clear all indexes
|
|
55
|
-
*/
|
|
56
|
-
clear(): void;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/block-index.d.ts
|
|
60
|
-
/**
|
|
61
|
-
* V8-optimized index for blocks
|
|
62
|
-
* Maintains collection->name->locale lookups
|
|
63
|
-
*/
|
|
64
|
-
declare class BlockIndex extends BaseContentIndex {
|
|
65
|
-
constructor(locales: string[]);
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/data-index.d.ts
|
|
69
|
-
/**
|
|
70
|
-
* V8-optimized index for data collections
|
|
71
|
-
* Maintains collection->name->locale lookups
|
|
72
|
-
*/
|
|
73
|
-
declare class DataIndex extends BaseContentIndex {}
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/site-index.d.ts
|
|
76
|
-
/**
|
|
77
|
-
* V8-optimized index for a single site
|
|
78
|
-
* Maintains pathname lookups and collections for one site only
|
|
79
|
-
*/
|
|
80
|
-
declare class SiteIndex {
|
|
81
|
-
private locales;
|
|
82
|
-
private index;
|
|
83
|
-
private contentCache;
|
|
84
|
-
private pathnameIndex;
|
|
85
|
-
private previousPathnameIndex;
|
|
86
|
-
readonly collections: Set<string>;
|
|
87
|
-
constructor(siteName: string, locales: string[]);
|
|
88
|
-
/**
|
|
89
|
-
* Add or update content in the index
|
|
90
|
-
* Merges manifest locales and updates content cache if provided
|
|
91
|
-
*/
|
|
92
|
-
addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
|
|
93
|
-
/**
|
|
94
|
-
* Remove a specific locale from an entry
|
|
95
|
-
*/
|
|
96
|
-
removeLocale(id: string, locale: string): void;
|
|
97
|
-
/**
|
|
98
|
-
* Remove an entry from the index
|
|
99
|
-
*/
|
|
100
|
-
removeEntry(id: string): void;
|
|
101
|
-
/**
|
|
102
|
-
* Get cached content for a specific locale
|
|
103
|
-
*/
|
|
104
|
-
getCachedContent(id: string, locale: string): ContentData | null;
|
|
105
|
-
/**
|
|
106
|
-
* Get content manifest
|
|
107
|
-
*/
|
|
108
|
-
getManifest(id: string): ContentManifest | null;
|
|
109
|
-
/**
|
|
110
|
-
* Find content by pathname
|
|
111
|
-
*/
|
|
112
|
-
getByPathname(pathname: string, locale?: string): ContentManifest | null;
|
|
113
|
-
/**
|
|
114
|
-
* Find content by previous pathname (for redirects)
|
|
115
|
-
*/
|
|
116
|
-
getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null;
|
|
117
|
-
/**
|
|
118
|
-
* Generator for all manifests
|
|
119
|
-
*/
|
|
120
|
-
getAllManifests(): Generator<ContentManifest>;
|
|
121
|
-
/**
|
|
122
|
-
* Generator for manifests by locale
|
|
123
|
-
*/
|
|
124
|
-
getManifestsByLocale(locale: string): Generator<ContentManifest>;
|
|
125
|
-
/**
|
|
126
|
-
* Get the count of indexed content entries (unique IDs)
|
|
127
|
-
*/
|
|
128
|
-
get entryCount(): number;
|
|
129
|
-
/**
|
|
130
|
-
* Clear all indexes
|
|
131
|
-
*/
|
|
132
|
-
clear(): void;
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
export { DataIndex as n, BlockIndex as r, SiteIndex as t };
|
|
136
|
-
//# sourceMappingURL=site-index-B_254bCc.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"site-index-B_254bCc.d.mts","names":[],"sources":["../src/base-content-index.ts","../src/block-index.ts","../src/data-index.ts","../src/site-index.ts"],"mappings":";;;;;;cAOa;YAED,OAAO,YAAY;YAGnB,cAAc,YAAY,eAAe;YAGzC,WAAW,YAAY,YAAY;WAGpC,aAAa;;;;;EAMtB,WAAW,UAAU,iBAAiB,eAAe,eAAe,UAAU;;;;EAoD9E,aAAa,YAAY;;;;EAuBzB,YAAY;;;;EAyBZ,iBAAiB,YAAY,iBAAiB;;;;EAQ9C,YAAY,aAAa;;;;EAOzB,UAAU,oBAAoB,cAAc,kBAAkB;;;;EAkB7D,mBAAmB,UAAU;;;;EAS7B,qBAAqB,iBAAiB,UAAU;;;;EAWhD,yBAAyB,qBAAqB,UAAU;;;;MAWrD;;;;EAOJ;;;;;;;;cC7LW,mBAAmB;EAClB,YAAA;;;;;;;;cCDD,kBAAkB;;;;;;;cCClB;UAoBD;UAlBF;UAGA;UAIA;UAIA;WAGC,aAAa;EAGpB,YAAA,kBACQ;;;;;EAWV,WAAW,UAAU,iBAAiB,eAAe,eAAe,UAAU;;;;EA4I9E,aAAa,YAAY;;;;EAkCzB,YAAY;;;;EA2BZ,iBAAiB,YAAY,iBAAiB;;;;EAQ9C,YAAY,aAAa;;;;EAOzB,cAAc,kBAAkB,kBAAkB;;;;EAmBlD,sBAAsB,kBAAkB,kBAAkB;;;;EAmBzD,mBAAmB,UAAU;;;;EAS7B,qBAAqB,iBAAiB,UAAU;;;;MAW7C;;;;EAOJ"}
|
package/dist/types-DOdldbfD.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//#region src/types.ts
|
|
2
|
-
const ErrorCodes = {
|
|
3
|
-
CONTENT_NOT_FOUND: "CONTENT_NOT_FOUND",
|
|
4
|
-
LOCALE_NOT_FOUND: "LOCALE_NOT_FOUND",
|
|
5
|
-
COLLECTION_NOT_FOUND: "COLLECTION_NOT_FOUND",
|
|
6
|
-
SITE_NOT_FOUND: "SITE_NOT_FOUND",
|
|
7
|
-
STALE_WRITE: "STALE_WRITE",
|
|
8
|
-
ALREADY_EXISTS: "ALREADY_EXISTS",
|
|
9
|
-
PATHNAME_TAKEN: "PATHNAME_TAKEN",
|
|
10
|
-
INVALID_PATHNAME: "INVALID_PATHNAME",
|
|
11
|
-
NAME_TAKEN: "NAME_TAKEN",
|
|
12
|
-
METADATA_TOO_LARGE: "METADATA_TOO_LARGE",
|
|
13
|
-
WRITE_ERROR: "WRITE_ERROR",
|
|
14
|
-
MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD",
|
|
15
|
-
INVALID_LOCALE: "INVALID_LOCALE",
|
|
16
|
-
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
17
|
-
INVALID_REQUEST: "INVALID_REQUEST",
|
|
18
|
-
MDX_COMPILE_FAILED: "MDX_COMPILE_FAILED",
|
|
19
|
-
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
20
|
-
FETCH_ERROR: "FETCH_ERROR",
|
|
21
|
-
GIT_NOT_REPO: "GIT_NOT_REPO",
|
|
22
|
-
GIT_COMMIT_FAILED: "GIT_COMMIT_FAILED",
|
|
23
|
-
GIT_PUSH_FAILED: "GIT_PUSH_FAILED",
|
|
24
|
-
GIT_PULL_FAILED: "GIT_PULL_FAILED",
|
|
25
|
-
GIT_STATUS_FAILED: "GIT_STATUS_FAILED",
|
|
26
|
-
ASSET_NOT_FOUND: "ASSET_NOT_FOUND",
|
|
27
|
-
ASSET_INVALID_FORMAT: "ASSET_INVALID_FORMAT",
|
|
28
|
-
ASSET_TOO_LARGE: "ASSET_TOO_LARGE",
|
|
29
|
-
ASSET_UPLOAD_FAILED: "ASSET_UPLOAD_FAILED"
|
|
30
|
-
};
|
|
31
|
-
//#endregion
|
|
32
|
-
export { ErrorCodes as t };
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=types-DOdldbfD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-DOdldbfD.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export interface ContentAPIOptions {\n contentRoot: string;\n canvasDir?: string;\n\n /**\n * Optional override for the mdx-type pages path. The canonical home for\n * this value is the resolved site's `mdxPages` field in `sites.json`.\n * This option, when present, wins over the sites.json value — useful\n * for tests and programmatic content-api setups that don't want to\n * round-trip through a sites.json file on disk.\n *\n * Decouples the storage location of mdx pages from Conloca's main content\n * tree so projects can host them wherever their renderer expects to read\n * from. The rendering pipeline is the project's own choice — Conloca only\n * owns CRUD on the file bytes.\n *\n * When omitted AND no site in sites.json has `mdxPages`, .mdx files\n * fall back to living alongside Puck pages at\n * `{contentRoot}/{site}/pages/`.\n */\n mdxPagesRoot?: string;\n\n /**\n * Default locale for mdx pages. The default locale's files live at\n * `{mdxPagesRoot}/{slug}.mdx` (no locale prefix); other locales live at\n * `{mdxPagesRoot}/{locale}/{slug}.mdx`.\n *\n * If omitted, falls back to the first site's `defaultLocale`, or `'en'`.\n */\n mdxPagesDefaultLocale?: string;\n\n /**\n * Site name to associate mdx pages with for pathname collision checking.\n * mdx pages share the URL space with that site's puck pages, so two\n * pages — regardless of type — cannot share a pathname.\n *\n * If omitted, falls back to the first site name in sites.json (or\n * `'default'` when no sites are configured).\n */\n mdxPagesSite?: string;\n\n /**\n * The site's supported locales. When provided, this wins over the\n * `globalLocales` field in sites.json. The locale-detection parsers\n * use this list to decide whether a folder or filename suffix that\n * looks locale-shaped (e.g. `de`, `en-US`) is actually a locale or\n * just a folder that happens to match the pattern.\n *\n * Omit to fall back to sites.json (current behavior).\n */\n availableLocales?: string[];\n\n /**\n * The site's default locale. Wins over both `mdxPagesDefaultLocale`\n * and the per-site `defaultLocale` in sites.json when provided.\n */\n defaultLocale?: string;\n}\n\n// Error response format for all API errors\nexport interface APIError {\n error: {\n code: string; // Machine-readable error code (e.g., 'CONTENT_NOT_FOUND', 'STALE_WRITE')\n message: string; // Human-readable error message\n details?: any; // Optional additional error details\n };\n}\n\nexport interface MDXCompileResponse {\n code: string;\n metadata: Record<string, unknown>;\n}\n\n// Common error codes\nexport const ErrorCodes = {\n // Content errors\n CONTENT_NOT_FOUND: 'CONTENT_NOT_FOUND',\n LOCALE_NOT_FOUND: 'LOCALE_NOT_FOUND',\n COLLECTION_NOT_FOUND: 'COLLECTION_NOT_FOUND',\n SITE_NOT_FOUND: 'SITE_NOT_FOUND',\n\n // Write errors\n STALE_WRITE: 'STALE_WRITE',\n ALREADY_EXISTS: 'ALREADY_EXISTS',\n PATHNAME_TAKEN: 'PATHNAME_TAKEN',\n INVALID_PATHNAME: 'INVALID_PATHNAME',\n NAME_TAKEN: 'NAME_TAKEN',\n METADATA_TOO_LARGE: 'METADATA_TOO_LARGE',\n WRITE_ERROR: 'WRITE_ERROR',\n\n // Validation errors\n MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',\n INVALID_LOCALE: 'INVALID_LOCALE',\n INVALID_CONTENT_TYPE: 'INVALID_CONTENT_TYPE',\n INVALID_REQUEST: 'INVALID_REQUEST',\n MDX_COMPILE_FAILED: 'MDX_COMPILE_FAILED',\n\n // System errors\n INTERNAL_ERROR: 'INTERNAL_ERROR',\n FETCH_ERROR: 'FETCH_ERROR',\n\n // Git errors\n GIT_NOT_REPO: 'GIT_NOT_REPO',\n GIT_COMMIT_FAILED: 'GIT_COMMIT_FAILED',\n GIT_PUSH_FAILED: 'GIT_PUSH_FAILED',\n GIT_PULL_FAILED: 'GIT_PULL_FAILED',\n GIT_STATUS_FAILED: 'GIT_STATUS_FAILED',\n\n // Asset errors\n ASSET_NOT_FOUND: 'ASSET_NOT_FOUND',\n ASSET_INVALID_FORMAT: 'ASSET_INVALID_FORMAT',\n ASSET_TOO_LARGE: 'ASSET_TOO_LARGE',\n ASSET_UPLOAD_FAILED: 'ASSET_UPLOAD_FAILED',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\n// Content type - the format of the content\nexport type ContentType = 'puck' | 'mdx' | 'json';\n\n// Content data - the actual content (puck, mdx, or json data)\nexport interface ContentData {\n puckData?: any;\n mdx?: string;\n data?: Record<string, unknown>;\n}\n\n// Content property that extends manifests with actual content\nexport interface ContentProp {\n content: ContentData;\n}\n\n// Base identity fields shared by all content representations\nexport interface ContentIdentity {\n id: string;\n type: ContentType;\n kind: 'block' | 'page' | 'data';\n site?: string; // Only for pages\n collection: string;\n}\n\n// Locale file data derived from file path\nexport interface LocalePathData {\n locale: string;\n pathname?: string; // pages only - derived from file path\n name?: string; // blocks only - derived from filename\n}\n\n// Localized content manifest - metadata about translated content without the actual content\nexport interface LocaleVersion extends LocalePathData {\n etag: string; // Format: \"metaEtag.contentEtag\"\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>; // pages only\n meta: ContentMeta; // title, description, seo, etc.\n}\n\n// Manifest for all locales (what's in the index and returned in listings)\nexport interface ContentManifest extends ContentIdentity {\n locales: Record<string, LocaleVersion | undefined>;\n}\n\n// Single locale without content (used for updates/changes)\nexport interface LocalizedManifest extends ContentIdentity {\n localized: LocaleVersion;\n}\n\n// Single locale with content\nexport interface LocalizedEntry extends ContentIdentity {\n localized: LocaleVersion & ContentProp;\n}\n\n// All locales with content\nexport interface ContentEntry extends ContentManifest {\n locales: Record<string, LocaleVersion & ContentProp>;\n}\n\n// Result types\nexport interface UpdateResult {\n success: boolean;\n etag?: string;\n modified?: Date;\n reason?: 'not_found' | 'stale_write' | 'write_error';\n error?: Error;\n currentEtag?: string;\n conflictDetails?: {\n metaChanged: boolean;\n contentChanged: boolean;\n currentMeta?: ContentMeta;\n currentContent?: ContentData;\n localContent?: ContentData;\n };\n}\n\nexport interface MoveResult {\n moved: boolean;\n previousPathname?: string;\n files?: string[];\n reason?: 'not_found' | 'already_exists' | 'stale_write' | 'write_error';\n error?: Error;\n etag?: string;\n}\n\nexport interface ContentListResult {\n items: ContentManifest[];\n total: number;\n hasMore?: boolean;\n}\n\n// Filter types\nexport interface GlobalFilters {\n site?: string;\n collection?: string;\n locales?: string[];\n type?: 'puck' | 'mdx' | 'json';\n published?: boolean;\n kind?: 'block' | 'page' | 'data';\n localization?: 'complete' | 'partial' | 'one';\n missingLocales?: string[];\n}\n\nexport interface SiteFilters {\n collection?: string;\n locales?: string[];\n type?: 'puck' | 'mdx';\n published?: boolean;\n}\n\nexport interface BlockFilters {\n collection?: string;\n locales?: string[];\n}\n\nexport interface FindOptions {\n excludeSites?: string[];\n includeUnpublished?: boolean;\n}\n\n// Input types\n\nexport interface CreateContentInput {\n kind: 'block' | 'page' | 'data';\n site?: string; // Required for pages, must be undefined for blocks and data\n collection: string;\n type: ContentType;\n created?: string; // Optional, will use current time if not provided\n name?: string; // Internal identifier for blocks and data (same across all locales)\n meta?: Partial<ContentMeta>; // Shared metadata defaults (applied to all locales)\n locales: {\n [locale: string]: {\n pathname?: string; // for pages (locale-specific route)\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta?: Partial<ContentMeta>;\n } & ContentProp;\n };\n}\n\nexport interface CreatePageInput {\n collection: string;\n locales: {\n [locale: string]: {\n pathname: string; // Required pathname for each locale\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta: ContentMeta; // Required metadata with title for each locale\n content: {\n puckData: any;\n };\n };\n };\n}\n\nexport interface CreateBlockInput {\n collection: string;\n type: 'mdx';\n name: string; // Internal identifier (same across all locales)\n meta?: Partial<ContentMeta>; // Shared metadata defaults\n locales: {\n [locale: string]: {\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta?: Partial<ContentMeta>; // Locale-specific metadata overrides\n content: {\n mdx: string;\n };\n };\n };\n}\n\nexport interface UpdateLocaleInput {\n id: string;\n locale: string;\n data: LocaleUpdateData;\n etag: string;\n}\n\nexport interface LocaleUpdateData {\n pathname?: string; // for pages - update pathname\n name?: string; // for blocks - update name (filename)\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n modified?: string; // Optional, will use current time if not provided\n meta?: Partial<ContentMeta>;\n content?: ContentData;\n}\n\nexport interface DeleteLocaleInput {\n id: string;\n locale: string;\n etag: string;\n}\n\n// Sites configuration\nexport interface SitesConfig {\n sites: {\n [siteName: string]: {\n locales: string[];\n defaultLocale: string;\n domains?: {\n [locale: string]: string;\n };\n /**\n * Optional filesystem path for this site's mdx-type pages.\n * When set, .mdx files under this path are surfaced in the CMS\n * as `kind: 'page'` + `type: 'mdx'` content owned by this site.\n *\n * Path is interpreted relative to the project root (the same\n * cwd Astro uses), not the content root, so it can live anywhere\n * the renderer expects (e.g. `./src/content/docs` for Starlight).\n *\n * When omitted, .mdx files for this site are expected to live\n * alongside Puck (`.vxjson`) pages at `{contentRoot}/{site}/pages/`\n * — the file extension determines the page type.\n */\n mdxPages?: string;\n };\n };\n globalLocales: string[];\n}\n\n// Batch operations\nexport interface BatchResult {\n operations: BatchOperationResult[];\n success: boolean; // true if all operations succeeded\n failed: number;\n updated: number; // number of successfully updated items\n}\n\n// Common metadata structure for all content types (stored in 'meta' field)\nexport interface ContentMeta {\n // Required\n title: string; // Display name for UI\n\n // Common optional fields\n description?: string;\n author?: string;\n tags?: string[];\n\n // SEO (mainly for pages)\n keywords?: string[];\n ogTitle?: string;\n ogDescription?: string;\n ogImage?: string;\n\n // Any additional fields from frontmatter/pageMeta\n [key: string]: any;\n}\n\n// File format types\n\n/**\n * VXJSON (Variant JSON) File Format\n *\n * VXJSON is a specialized JSON format that guarantees:\n * 1. The root is always an object (never an array or primitive)\n * 2. The \"content\" field always comes last in the object\n * 3. Field order is deterministic for consistent ETag calculation\n *\n * This format enables efficient streaming ETag calculation where metadata\n * can be hashed separately from content, supporting partial updates and\n * conflict resolution in CMS scenarios.\n *\n * Files using this format have the extension .vxjson\n */\nexport interface VXJSONFile {\n id: string;\n type: ContentType;\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>;\n meta: ContentMeta;\n content: ContentData; // Always last field in VXJSON\n}\n\nexport interface MDXFrontmatter {\n id: string;\n type: 'mdx';\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n meta: ContentMeta;\n}\n\n// All properties are declared in each variant to make destructuring safe and predictable\nexport type WriteResult =\n | { success: true; etag: string; modified?: Date; reason?: undefined; error?: undefined; currentEtag?: undefined }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'stale_write';\n error?: undefined;\n currentEtag: string;\n }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'already_exists';\n error?: undefined;\n currentEtag: string;\n }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'write_error';\n error: Error;\n currentEtag?: string;\n };\n\nexport interface DeleteResult {\n success: boolean;\n error?: Error;\n reason?: 'stale_write' | 'not_found' | 'delete_error';\n currentEtag?: string;\n}\n\nexport interface CreateResult {\n success: boolean;\n id?: string;\n etag?: string;\n created?: Date;\n reason?:\n | 'already_exists'\n | 'write_error'\n | 'invalid_name'\n | 'invalid_pathname'\n | 'name_taken'\n | 'pathname_taken'\n | 'pathname_in_redirects'\n | 'metadata_too_large';\n error?: Error;\n existingId?: string;\n}\n\nexport interface BatchOperationResult {\n id: string;\n locale: string;\n updated: boolean;\n error?: Error;\n etag?: string;\n}\n\n// ===== Data Context Types =====\n\n/**\n * Minimal page reference for listing/navigation in data context.\n *\n * Used in dataBindings.pages for blog listing components\n * and getStaticPaths() to enumerate available pages.\n */\nexport interface PageReference {\n /** Page identifier. */\n id: string;\n /** URL pathname. */\n pathname: string;\n /** Page title (if available without full load). */\n title?: string;\n /** Content collection. */\n collection: string;\n /** Page metadata from content. */\n meta?: Record<string, unknown>;\n /** Page timestamps for sorting and display. */\n timestamps?: {\n created?: Date;\n modified?: Date;\n };\n}\n\n/**\n * A single entry from a data collection.\n *\n * Simplified representation of collection data for use in component resolvers.\n */\nexport interface DataCollectionEntry {\n /** Unique identifier for the entry. */\n id: string;\n /** Human-readable name of the entry. */\n name: string;\n /** The entry's data content. */\n data: Record<string, unknown>;\n /** Optional metadata for the entry. */\n meta?: Record<string, unknown>;\n}\n\n/**\n * Context object passed to Puck component resolvers via metadata.\n *\n * Contains fetched collection data and contextual information\n * for data-driven component rendering.\n */\nexport interface DataContext {\n /** Collection data keyed by collection name. */\n collections: Record<string, DataCollectionEntry[]>;\n /** Pages matching the dataBindings.pages filter. */\n pages?: PageReference[];\n /** Current locale used for data fetching. */\n locale: string;\n /** Site name from routing configuration. */\n siteName: string;\n}\n\n// Internal type for locale data returned by readLocaleFile\nexport interface LocaleFileData {\n locale: string;\n etag: string;\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>;\n meta: ContentMeta;\n content: {\n puckData?: any;\n mdx?: string;\n data?: Record<string, unknown>;\n };\n}\n"],"mappings":";AA0EA,MAAa,aAAa;CAExB,mBAAmB;CACnB,kBAAkB;CAClB,sBAAsB;CACtB,gBAAgB;CAGhB,aAAa;CACb,gBAAgB;CAChB,gBAAgB;CAChB,kBAAkB;CAClB,YAAY;CACZ,oBAAoB;CACpB,aAAa;CAGb,wBAAwB;CACxB,gBAAgB;CAChB,sBAAsB;CACtB,iBAAiB;CACjB,oBAAoB;CAGpB,gBAAgB;CAChB,aAAa;CAGb,cAAc;CACd,mBAAmB;CACnB,iBAAiB;CACjB,iBAAiB;CACjB,mBAAmB;CAGnB,iBAAiB;CACjB,sBAAsB;CACtB,iBAAiB;CACjB,qBAAqB;AACvB"}
|