@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/src/types.ts
ADDED
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
export interface ContentAPIOptions {
|
|
2
|
+
contentRoot: string;
|
|
3
|
+
canvasDir?: string;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Optional override for the mdx-type pages path. The canonical home for
|
|
7
|
+
* this value is the resolved site's `mdxPages` field in `sites.json`.
|
|
8
|
+
* This option, when present, wins over the sites.json value — useful
|
|
9
|
+
* for tests and programmatic content-api setups that don't want to
|
|
10
|
+
* round-trip through a sites.json file on disk.
|
|
11
|
+
*
|
|
12
|
+
* Decouples the storage location of mdx pages from Conloca's main content
|
|
13
|
+
* tree so projects can host them wherever their renderer expects to read
|
|
14
|
+
* from. The rendering pipeline is the project's own choice — Conloca only
|
|
15
|
+
* owns CRUD on the file bytes.
|
|
16
|
+
*
|
|
17
|
+
* When omitted AND no site in sites.json has `mdxPages`, .mdx files
|
|
18
|
+
* fall back to living alongside Puck pages at
|
|
19
|
+
* `{contentRoot}/{site}/pages/`.
|
|
20
|
+
*/
|
|
21
|
+
mdxPagesRoot?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Default locale for mdx pages. The default locale's files live at
|
|
25
|
+
* `{mdxPagesRoot}/{slug}.mdx` (no locale prefix); other locales live at
|
|
26
|
+
* `{mdxPagesRoot}/{locale}/{slug}.mdx`.
|
|
27
|
+
*
|
|
28
|
+
* If omitted, falls back to the first site's `defaultLocale`, or `'en'`.
|
|
29
|
+
*/
|
|
30
|
+
mdxPagesDefaultLocale?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Site name to associate mdx pages with for pathname collision checking.
|
|
34
|
+
* mdx pages share the URL space with that site's puck pages, so two
|
|
35
|
+
* pages — regardless of type — cannot share a pathname.
|
|
36
|
+
*
|
|
37
|
+
* If omitted, falls back to the first site name in sites.json (or
|
|
38
|
+
* `'default'` when no sites are configured).
|
|
39
|
+
*/
|
|
40
|
+
mdxPagesSite?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The site's supported locales. When provided, this wins over the
|
|
44
|
+
* `globalLocales` field in sites.json. The locale-detection parsers
|
|
45
|
+
* use this list to decide whether a folder or filename suffix that
|
|
46
|
+
* looks locale-shaped (e.g. `de`, `en-US`) is actually a locale or
|
|
47
|
+
* just a folder that happens to match the pattern.
|
|
48
|
+
*
|
|
49
|
+
* Omit to fall back to sites.json (current behavior).
|
|
50
|
+
*/
|
|
51
|
+
availableLocales?: string[];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The site's default locale. Wins over both `mdxPagesDefaultLocale`
|
|
55
|
+
* and the per-site `defaultLocale` in sites.json when provided.
|
|
56
|
+
*/
|
|
57
|
+
defaultLocale?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Error response format for all API errors
|
|
61
|
+
export interface APIError {
|
|
62
|
+
error: {
|
|
63
|
+
code: string; // Machine-readable error code (e.g., 'CONTENT_NOT_FOUND', 'STALE_WRITE')
|
|
64
|
+
message: string; // Human-readable error message
|
|
65
|
+
details?: any; // Optional additional error details
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface MDXCompileResponse {
|
|
70
|
+
code: string;
|
|
71
|
+
metadata: Record<string, unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* The content's headings, in document order, carrying the ids the compiled
|
|
74
|
+
* markup puts on them. Editing surfaces render the body inside a sandbox
|
|
75
|
+
* they cannot read, so the outline rides the compile they already request
|
|
76
|
+
* rather than being scraped back off the frame.
|
|
77
|
+
*/
|
|
78
|
+
outline: readonly MDXHeading[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** One heading of compiled MDX: the anchor target and the text to label it with. */
|
|
82
|
+
export interface MDXHeading {
|
|
83
|
+
/** Heading level as authored: 2 for `##`, 3 for `###`. */
|
|
84
|
+
depth: number;
|
|
85
|
+
id: string;
|
|
86
|
+
text: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Common error codes
|
|
90
|
+
export const ErrorCodes = {
|
|
91
|
+
// Content errors
|
|
92
|
+
CONTENT_NOT_FOUND: 'CONTENT_NOT_FOUND',
|
|
93
|
+
LOCALE_NOT_FOUND: 'LOCALE_NOT_FOUND',
|
|
94
|
+
COLLECTION_NOT_FOUND: 'COLLECTION_NOT_FOUND',
|
|
95
|
+
SITE_NOT_FOUND: 'SITE_NOT_FOUND',
|
|
96
|
+
|
|
97
|
+
// Write errors
|
|
98
|
+
STALE_WRITE: 'STALE_WRITE',
|
|
99
|
+
ALREADY_EXISTS: 'ALREADY_EXISTS',
|
|
100
|
+
PATHNAME_TAKEN: 'PATHNAME_TAKEN',
|
|
101
|
+
INVALID_PATHNAME: 'INVALID_PATHNAME',
|
|
102
|
+
NAME_TAKEN: 'NAME_TAKEN',
|
|
103
|
+
METADATA_TOO_LARGE: 'METADATA_TOO_LARGE',
|
|
104
|
+
WRITE_ERROR: 'WRITE_ERROR',
|
|
105
|
+
|
|
106
|
+
// Validation errors
|
|
107
|
+
MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',
|
|
108
|
+
INVALID_LOCALE: 'INVALID_LOCALE',
|
|
109
|
+
INVALID_CONTENT_TYPE: 'INVALID_CONTENT_TYPE',
|
|
110
|
+
INVALID_REQUEST: 'INVALID_REQUEST',
|
|
111
|
+
MDX_COMPILE_FAILED: 'MDX_COMPILE_FAILED',
|
|
112
|
+
|
|
113
|
+
// Request errors
|
|
114
|
+
/** A write another website sent through the developer's browser. */
|
|
115
|
+
FORBIDDEN: 'FORBIDDEN',
|
|
116
|
+
|
|
117
|
+
// System errors
|
|
118
|
+
INTERNAL_ERROR: 'INTERNAL_ERROR',
|
|
119
|
+
FETCH_ERROR: 'FETCH_ERROR',
|
|
120
|
+
|
|
121
|
+
// Git errors
|
|
122
|
+
GIT_NOT_REPO: 'GIT_NOT_REPO',
|
|
123
|
+
GIT_COMMIT_FAILED: 'GIT_COMMIT_FAILED',
|
|
124
|
+
GIT_PUSH_FAILED: 'GIT_PUSH_FAILED',
|
|
125
|
+
GIT_PULL_FAILED: 'GIT_PULL_FAILED',
|
|
126
|
+
GIT_STATUS_FAILED: 'GIT_STATUS_FAILED',
|
|
127
|
+
|
|
128
|
+
// Asset errors
|
|
129
|
+
ASSET_NOT_FOUND: 'ASSET_NOT_FOUND',
|
|
130
|
+
ASSET_INVALID_FORMAT: 'ASSET_INVALID_FORMAT',
|
|
131
|
+
ASSET_TOO_LARGE: 'ASSET_TOO_LARGE',
|
|
132
|
+
ASSET_UPLOAD_FAILED: 'ASSET_UPLOAD_FAILED',
|
|
133
|
+
|
|
134
|
+
// Preview errors
|
|
135
|
+
/** The target site is not serving the preview endpoint, so a generated
|
|
136
|
+
* preview URL would 404 there. This describes the target deployment, not a
|
|
137
|
+
* failure of the request — callers must not render it as an error. */
|
|
138
|
+
PREVIEW_NOT_DEPLOYED: 'PREVIEW_NOT_DEPLOYED',
|
|
139
|
+
} as const;
|
|
140
|
+
|
|
141
|
+
export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
142
|
+
|
|
143
|
+
// Content type - the format of the content
|
|
144
|
+
export type ContentType = 'puck' | 'mdx' | 'json';
|
|
145
|
+
|
|
146
|
+
// Content data - the actual content (puck, mdx, or json data)
|
|
147
|
+
export interface ContentData {
|
|
148
|
+
puckData?: any;
|
|
149
|
+
mdx?: string;
|
|
150
|
+
data?: Record<string, unknown>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Content property that extends manifests with actual content
|
|
154
|
+
export interface ContentProp {
|
|
155
|
+
content: ContentData;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Base identity fields shared by all content representations
|
|
159
|
+
export interface ContentIdentity {
|
|
160
|
+
id: string;
|
|
161
|
+
type: ContentType;
|
|
162
|
+
kind: 'fragment' | 'page' | 'data';
|
|
163
|
+
site?: string; // Only for pages
|
|
164
|
+
collection: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Locale file data derived from file path
|
|
168
|
+
export interface LocalePathData {
|
|
169
|
+
locale: string;
|
|
170
|
+
pathname?: string; // pages only - derived from file path
|
|
171
|
+
name?: string; // fragments only - derived from filename
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Localized content manifest - metadata about translated content without the actual content
|
|
175
|
+
export interface LocaleVersion extends LocalePathData {
|
|
176
|
+
etag: string; // Format: "metaEtag.contentEtag"
|
|
177
|
+
created: string;
|
|
178
|
+
modified: string;
|
|
179
|
+
publishAt?: string;
|
|
180
|
+
unpublishAt?: string;
|
|
181
|
+
previousPathnames?: Record<string, string>; // pages only
|
|
182
|
+
meta: ContentMeta; // title, description, seo, etc.
|
|
183
|
+
/**
|
|
184
|
+
* Path of the file backing this locale, as the hydrating backend knows it.
|
|
185
|
+
* Set during filesystem hydration; absent on backends that do not read
|
|
186
|
+
* files and on manifests built in-memory before the first rescan. Diagnostic only — it exists so an error about this locale can
|
|
187
|
+
* name a file a human can open instead of the opaque content id.
|
|
188
|
+
*/
|
|
189
|
+
sourcePath?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Manifest for all locales (what's in the index and returned in listings)
|
|
193
|
+
export interface ContentManifest extends ContentIdentity {
|
|
194
|
+
locales: Record<string, LocaleVersion | undefined>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Single locale without content (used for updates/changes)
|
|
198
|
+
export interface LocalizedManifest extends ContentIdentity {
|
|
199
|
+
localized: LocaleVersion;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Single locale with content
|
|
203
|
+
export interface LocalizedEntry extends ContentIdentity {
|
|
204
|
+
localized: LocaleVersion & ContentProp;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// All locales with content
|
|
208
|
+
export interface ContentEntry extends ContentManifest {
|
|
209
|
+
locales: Record<string, LocaleVersion & ContentProp>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Result types
|
|
213
|
+
export interface UpdateResult {
|
|
214
|
+
success: boolean;
|
|
215
|
+
etag?: string;
|
|
216
|
+
modified?: Date;
|
|
217
|
+
/**
|
|
218
|
+
* The `invalid_pathname`, `pathname_taken` and `pathname_in_redirects`
|
|
219
|
+
* refusals of a page's new path, and the `invalid_name` and `name_taken`
|
|
220
|
+
* refusals of a fragment or data entry's new name, mean what they mean for a
|
|
221
|
+
* create; a backend that does not tell them apart reports `write_error`.
|
|
222
|
+
*/
|
|
223
|
+
reason?:
|
|
224
|
+
| 'not_found'
|
|
225
|
+
| 'stale_write'
|
|
226
|
+
| 'write_error'
|
|
227
|
+
| 'invalid_pathname'
|
|
228
|
+
| 'pathname_taken'
|
|
229
|
+
| 'pathname_in_redirects'
|
|
230
|
+
| 'invalid_name'
|
|
231
|
+
| 'name_taken';
|
|
232
|
+
error?: Error;
|
|
233
|
+
currentEtag?: string;
|
|
234
|
+
conflictDetails?: {
|
|
235
|
+
metaChanged: boolean;
|
|
236
|
+
contentChanged: boolean;
|
|
237
|
+
currentMeta?: ContentMeta;
|
|
238
|
+
currentContent?: ContentData;
|
|
239
|
+
localContent?: ContentData;
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface MoveResult {
|
|
244
|
+
moved: boolean;
|
|
245
|
+
previousPathname?: string;
|
|
246
|
+
files?: string[];
|
|
247
|
+
/** `already_exists` also covers a path another page redirects from; `invalid_pathname` is a malformed path. */
|
|
248
|
+
reason?: 'not_found' | 'already_exists' | 'stale_write' | 'write_error' | 'invalid_pathname';
|
|
249
|
+
error?: Error;
|
|
250
|
+
etag?: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface ContentListResult {
|
|
254
|
+
items: ContentManifest[];
|
|
255
|
+
total: number;
|
|
256
|
+
hasMore?: boolean;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Filter types
|
|
260
|
+
export interface GlobalFilters {
|
|
261
|
+
site?: string;
|
|
262
|
+
collection?: string;
|
|
263
|
+
locales?: string[];
|
|
264
|
+
type?: 'puck' | 'mdx' | 'json';
|
|
265
|
+
published?: boolean;
|
|
266
|
+
kind?: 'fragment' | 'page' | 'data';
|
|
267
|
+
localization?: 'complete' | 'partial' | 'one';
|
|
268
|
+
missingLocales?: string[];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface SiteFilters {
|
|
272
|
+
collection?: string;
|
|
273
|
+
locales?: string[];
|
|
274
|
+
type?: 'puck' | 'mdx';
|
|
275
|
+
published?: boolean;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface FragmentFilters {
|
|
279
|
+
collection?: string;
|
|
280
|
+
locales?: string[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface FindOptions {
|
|
284
|
+
excludeSites?: string[];
|
|
285
|
+
includeUnpublished?: boolean;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Input types
|
|
289
|
+
|
|
290
|
+
export interface CreateContentInput {
|
|
291
|
+
kind: 'fragment' | 'page' | 'data';
|
|
292
|
+
site?: string; // Required for pages, must be undefined for fragments and data
|
|
293
|
+
collection: string;
|
|
294
|
+
type: ContentType;
|
|
295
|
+
created?: string; // Optional, will use current time if not provided
|
|
296
|
+
name?: string; // Internal identifier for fragments and data (same across all locales)
|
|
297
|
+
meta?: Partial<ContentMeta>; // Shared metadata defaults (applied to all locales)
|
|
298
|
+
locales: {
|
|
299
|
+
[locale: string]: {
|
|
300
|
+
pathname?: string; // for pages (locale-specific route)
|
|
301
|
+
publishAt?: string | null | false;
|
|
302
|
+
unpublishAt?: string | null | false;
|
|
303
|
+
meta?: Partial<ContentMeta>;
|
|
304
|
+
} & ContentProp;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface CreatePageInput {
|
|
309
|
+
collection: string;
|
|
310
|
+
locales: {
|
|
311
|
+
[locale: string]: {
|
|
312
|
+
pathname: string; // Required pathname for each locale
|
|
313
|
+
publishAt?: string | null | false;
|
|
314
|
+
unpublishAt?: string | null | false;
|
|
315
|
+
meta: ContentMeta; // Required metadata with title for each locale
|
|
316
|
+
content: {
|
|
317
|
+
puckData: any;
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface CreateFragmentInput {
|
|
324
|
+
collection: string;
|
|
325
|
+
type: 'mdx';
|
|
326
|
+
name: string; // Internal identifier (same across all locales)
|
|
327
|
+
meta?: Partial<ContentMeta>; // Shared metadata defaults
|
|
328
|
+
locales: {
|
|
329
|
+
[locale: string]: {
|
|
330
|
+
publishAt?: string | null | false;
|
|
331
|
+
unpublishAt?: string | null | false;
|
|
332
|
+
meta?: Partial<ContentMeta>; // Locale-specific metadata overrides
|
|
333
|
+
content: {
|
|
334
|
+
mdx: string;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface UpdateLocaleInput {
|
|
341
|
+
id: string;
|
|
342
|
+
locale: string;
|
|
343
|
+
data: LocaleUpdateData;
|
|
344
|
+
etag: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* A metadata update as a dialog sends it: absent keys are left alone, null
|
|
349
|
+
* clears the stored field. "Cleared" used to travel as undefined, which
|
|
350
|
+
* JSON.stringify drops, so the server's shallow merge silently kept the old
|
|
351
|
+
* value — the dialog reported success and the field reappeared on refresh.
|
|
352
|
+
*/
|
|
353
|
+
export type ContentMetaPatch = { [K in keyof ContentMeta]?: ContentMeta[K] | null };
|
|
354
|
+
|
|
355
|
+
export interface LocaleUpdateData {
|
|
356
|
+
pathname?: string; // for pages - update pathname
|
|
357
|
+
name?: string; // for fragments - update name (filename)
|
|
358
|
+
publishAt?: string | null | false;
|
|
359
|
+
unpublishAt?: string | null | false;
|
|
360
|
+
modified?: string; // Optional, will use current time if not provided
|
|
361
|
+
meta?: ContentMetaPatch;
|
|
362
|
+
content?: ContentData;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export interface DeleteLocaleInput {
|
|
366
|
+
id: string;
|
|
367
|
+
locale: string;
|
|
368
|
+
etag: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Sites configuration
|
|
372
|
+
export interface SitesConfig {
|
|
373
|
+
sites: {
|
|
374
|
+
[siteName: string]: {
|
|
375
|
+
locales: string[];
|
|
376
|
+
defaultLocale: string;
|
|
377
|
+
domains?: {
|
|
378
|
+
[locale: string]: string;
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Optional filesystem path for this site's mdx-type pages.
|
|
382
|
+
* When set, .mdx files under this path are surfaced in the CMS
|
|
383
|
+
* as `kind: 'page'` + `type: 'mdx'` content owned by this site.
|
|
384
|
+
*
|
|
385
|
+
* Path is interpreted relative to the project root (the same
|
|
386
|
+
* cwd Astro uses), not the content root, so it can live anywhere
|
|
387
|
+
* the renderer expects (e.g. `./src/content/docs` for Starlight).
|
|
388
|
+
*
|
|
389
|
+
* When omitted, .mdx files for this site are expected to live
|
|
390
|
+
* alongside Puck (`.vxjson`) pages at `{contentRoot}/{site}/pages/`
|
|
391
|
+
* — the file extension determines the page type.
|
|
392
|
+
*/
|
|
393
|
+
mdxPages?: string;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
globalLocales: string[];
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Batch operations
|
|
400
|
+
export interface BatchResult {
|
|
401
|
+
operations: BatchOperationResult[];
|
|
402
|
+
success: boolean; // true if all operations succeeded
|
|
403
|
+
failed: number;
|
|
404
|
+
updated: number; // number of successfully updated items
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Any value that survives a JSON round trip.
|
|
409
|
+
*
|
|
410
|
+
* Content metadata is serialised into `.vxjson` files on disk, so JSON is the
|
|
411
|
+
* real ceiling on what a meta field can hold. Saying that concretely — rather
|
|
412
|
+
* than `unknown` — keeps the type honest in both directions: readers still
|
|
413
|
+
* have to narrow before using a value, and the structure stays visible to
|
|
414
|
+
* anything that has to prove the type is serialisable in order to carry it.
|
|
415
|
+
*/
|
|
416
|
+
export type JsonValue = string | number | boolean | null | JsonArray | JsonObject;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* The array arm of {@link JsonValue}. An interface for the same reason as
|
|
420
|
+
* {@link JsonObject}; `Array<JsonValue>` rather than `JsonValue[]` only
|
|
421
|
+
* because `extends` has no shorthand-array form to use here.
|
|
422
|
+
*/
|
|
423
|
+
export interface JsonArray extends Array<JsonValue> {}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* The object arm of {@link JsonValue}, kept as an interface rather than an
|
|
427
|
+
* inline type so the recursion terminates: a structural checker walking this
|
|
428
|
+
* type can defer the interface instead of re-expanding it at every level.
|
|
429
|
+
*/
|
|
430
|
+
export interface JsonObject {
|
|
431
|
+
[key: string]: JsonValue;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Host-declared page-meta fields. Sites augment this from their `pageSchemas`
|
|
436
|
+
* so listing components see `excerpt` / `featuredImage` as real keys instead
|
|
437
|
+
* of an open bag. Empty until a host writes `declare module '@conloca/content-api'`.
|
|
438
|
+
*/
|
|
439
|
+
// biome-ignore lint/suspicious/noEmptyInterface: empty interface is the module-augmentation hole hosts fill
|
|
440
|
+
export interface HostPageMeta {}
|
|
441
|
+
|
|
442
|
+
// Common metadata structure for all content types (stored in 'meta' field)
|
|
443
|
+
export interface ContentMeta extends HostPageMeta {
|
|
444
|
+
// Required
|
|
445
|
+
title: string; // Display name for UI
|
|
446
|
+
|
|
447
|
+
// Common optional fields
|
|
448
|
+
description?: string;
|
|
449
|
+
author?: string;
|
|
450
|
+
tags?: string[];
|
|
451
|
+
|
|
452
|
+
// SEO (mainly for pages)
|
|
453
|
+
keywords?: string[];
|
|
454
|
+
ogTitle?: string;
|
|
455
|
+
ogDescription?: string;
|
|
456
|
+
ogImage?: string;
|
|
457
|
+
|
|
458
|
+
// Leftover host fields that were not declared on HostPageMeta.
|
|
459
|
+
[key: string]: JsonValue | undefined;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// File format types
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* VXJSON (Variant JSON) File Format
|
|
466
|
+
*
|
|
467
|
+
* VXJSON is a specialized JSON format that guarantees:
|
|
468
|
+
* 1. The root is always an object (never an array or primitive)
|
|
469
|
+
* 2. The "content" field always comes last in the object
|
|
470
|
+
* 3. Field order is deterministic for consistent ETag calculation
|
|
471
|
+
*
|
|
472
|
+
* This format enables efficient streaming ETag calculation where metadata
|
|
473
|
+
* can be hashed separately from content, supporting partial updates and
|
|
474
|
+
* conflict resolution in CMS scenarios.
|
|
475
|
+
*
|
|
476
|
+
* Files using this format have the extension .vxjson
|
|
477
|
+
*/
|
|
478
|
+
export interface VXJSONFile {
|
|
479
|
+
id: string;
|
|
480
|
+
type: ContentType;
|
|
481
|
+
created: string;
|
|
482
|
+
modified: string;
|
|
483
|
+
publishAt?: string;
|
|
484
|
+
unpublishAt?: string;
|
|
485
|
+
previousPathnames?: Record<string, string>;
|
|
486
|
+
meta: ContentMeta;
|
|
487
|
+
content: ContentData; // Always last field in VXJSON
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface MDXFrontmatter {
|
|
491
|
+
id: string;
|
|
492
|
+
type: 'mdx';
|
|
493
|
+
created: string;
|
|
494
|
+
modified: string;
|
|
495
|
+
publishAt?: string;
|
|
496
|
+
unpublishAt?: string;
|
|
497
|
+
meta: ContentMeta;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// All properties are declared in each variant to make destructuring safe and predictable
|
|
501
|
+
export type WriteResult =
|
|
502
|
+
| { success: true; etag: string; modified?: Date; reason?: undefined; error?: undefined; currentEtag?: undefined }
|
|
503
|
+
| {
|
|
504
|
+
success: false;
|
|
505
|
+
etag?: undefined;
|
|
506
|
+
modified?: undefined;
|
|
507
|
+
reason: 'stale_write';
|
|
508
|
+
error?: undefined;
|
|
509
|
+
currentEtag: string;
|
|
510
|
+
}
|
|
511
|
+
| {
|
|
512
|
+
success: false;
|
|
513
|
+
etag?: undefined;
|
|
514
|
+
modified?: undefined;
|
|
515
|
+
reason: 'already_exists';
|
|
516
|
+
error?: undefined;
|
|
517
|
+
currentEtag: string;
|
|
518
|
+
}
|
|
519
|
+
| {
|
|
520
|
+
success: false;
|
|
521
|
+
etag?: undefined;
|
|
522
|
+
modified?: undefined;
|
|
523
|
+
reason: 'write_error';
|
|
524
|
+
error: Error;
|
|
525
|
+
currentEtag?: string;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
export interface DeleteResult {
|
|
529
|
+
success: boolean;
|
|
530
|
+
error?: Error;
|
|
531
|
+
reason?: 'stale_write' | 'not_found' | 'delete_error';
|
|
532
|
+
currentEtag?: string;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export interface CreateResult {
|
|
536
|
+
success: boolean;
|
|
537
|
+
id?: string;
|
|
538
|
+
etag?: string;
|
|
539
|
+
created?: Date;
|
|
540
|
+
reason?:
|
|
541
|
+
| 'already_exists'
|
|
542
|
+
| 'write_error'
|
|
543
|
+
| 'invalid_name'
|
|
544
|
+
| 'invalid_pathname'
|
|
545
|
+
| 'name_taken'
|
|
546
|
+
| 'pathname_taken'
|
|
547
|
+
| 'pathname_in_redirects'
|
|
548
|
+
| 'invalid_collection'
|
|
549
|
+
| 'invalid_locale'
|
|
550
|
+
| 'metadata_too_large'
|
|
551
|
+
| 'missing_field'
|
|
552
|
+
| 'unknown_site'
|
|
553
|
+
| 'no_sites_configured';
|
|
554
|
+
error?: Error;
|
|
555
|
+
existingId?: string;
|
|
556
|
+
/** The input field a caller has to change, when the failure points at one. */
|
|
557
|
+
field?: string;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export interface BatchOperationResult {
|
|
561
|
+
id: string;
|
|
562
|
+
locale: string;
|
|
563
|
+
updated: boolean;
|
|
564
|
+
error?: Error;
|
|
565
|
+
etag?: string;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// ===== Data Context Types =====
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Minimal page reference for listing/navigation in data context.
|
|
572
|
+
*
|
|
573
|
+
* Used in dataBindings.pages for blog listing components
|
|
574
|
+
* and getStaticPaths() to enumerate available pages.
|
|
575
|
+
*/
|
|
576
|
+
export interface PageReference {
|
|
577
|
+
/** Page identifier. */
|
|
578
|
+
id: string;
|
|
579
|
+
/** URL pathname. */
|
|
580
|
+
pathname: string;
|
|
581
|
+
/** Page title (if available without full load). */
|
|
582
|
+
title?: string;
|
|
583
|
+
/** Content collection. */
|
|
584
|
+
collection: string;
|
|
585
|
+
/** Page metadata from content. */
|
|
586
|
+
meta?: ContentMeta;
|
|
587
|
+
/** Page timestamps for sorting and display. */
|
|
588
|
+
timestamps?: {
|
|
589
|
+
/** When the page was created. */
|
|
590
|
+
created?: Date;
|
|
591
|
+
/** When the page was last saved. Page lists never order by it, so an edit does not move a page. */
|
|
592
|
+
modified?: Date;
|
|
593
|
+
/**
|
|
594
|
+
* When the page went or goes live: its publish time (`publishAt`), or its
|
|
595
|
+
* creation time when it has none. Page lists order by it.
|
|
596
|
+
*/
|
|
597
|
+
published?: Date;
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* A single entry from a data collection.
|
|
603
|
+
*
|
|
604
|
+
* Simplified representation of collection data for use in component resolvers.
|
|
605
|
+
*/
|
|
606
|
+
export interface DataCollectionEntry {
|
|
607
|
+
/** Unique identifier for the entry. */
|
|
608
|
+
id: string;
|
|
609
|
+
/** Human-readable name of the entry. */
|
|
610
|
+
name: string;
|
|
611
|
+
/** The entry's data content. */
|
|
612
|
+
data: Record<string, unknown>;
|
|
613
|
+
/** Optional metadata for the entry. */
|
|
614
|
+
meta?: Record<string, unknown>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Context Puck hands every block of a page as its metadata: to `resolveData`
|
|
619
|
+
* as `metadata` and to `render` as `puck.metadata`.
|
|
620
|
+
*
|
|
621
|
+
* Contains the page being rendered, the data its route binds and contextual
|
|
622
|
+
* information for data-driven component rendering.
|
|
623
|
+
*/
|
|
624
|
+
export interface DataContext {
|
|
625
|
+
/** The page being rendered, with its settings. */
|
|
626
|
+
page: PageReference;
|
|
627
|
+
/** Collection data keyed by collection name. */
|
|
628
|
+
collections: Record<string, DataCollectionEntry[]>;
|
|
629
|
+
/** Pages matching the dataBindings.pages filter. */
|
|
630
|
+
pages?: PageReference[];
|
|
631
|
+
/** Current locale used for data fetching. */
|
|
632
|
+
locale: string;
|
|
633
|
+
/** Site name from routing configuration. */
|
|
634
|
+
siteName: string;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Configuration for automatic data collection injection into Puck components.
|
|
639
|
+
*
|
|
640
|
+
* Allows components to declare data dependencies on Conloca data collections,
|
|
641
|
+
* which are automatically fetched and injected via Puck's metadata system.
|
|
642
|
+
*
|
|
643
|
+
* @example Route with data bindings
|
|
644
|
+
* ```typescript
|
|
645
|
+
* conlocaCMS({
|
|
646
|
+
* routing: {
|
|
647
|
+
* routes: {
|
|
648
|
+
* pages: {
|
|
649
|
+
* pattern: '/[...slug]',
|
|
650
|
+
* dataBindings: {
|
|
651
|
+
* collections: ['team', 'testimonials'],
|
|
652
|
+
* },
|
|
653
|
+
* },
|
|
654
|
+
* },
|
|
655
|
+
* },
|
|
656
|
+
* });
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
export interface DataBindingConfig {
|
|
660
|
+
/**
|
|
661
|
+
* Collections to fetch and inject into component resolvers.
|
|
662
|
+
*
|
|
663
|
+
* Each collection name must match a data collection in the content directory.
|
|
664
|
+
* The fetched data will be available in `metadata.collections[collectionName]`
|
|
665
|
+
* within Puck component resolvers.
|
|
666
|
+
*
|
|
667
|
+
* @example ['team', 'testimonials', 'products']
|
|
668
|
+
*/
|
|
669
|
+
collections?: string[];
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Locale override for data fetching.
|
|
673
|
+
*
|
|
674
|
+
* Defaults to the route's locale setting (from routing.locale).
|
|
675
|
+
* Use this to fetch data in a specific locale regardless of route config.
|
|
676
|
+
*/
|
|
677
|
+
locale?: string;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Page discovery configuration for listing pages by path prefix.
|
|
681
|
+
*
|
|
682
|
+
* Enables components to access lists of pages matching a URL pattern,
|
|
683
|
+
* useful for blog listings, category pages, and site navigation.
|
|
684
|
+
*
|
|
685
|
+
* @example Blog listing page
|
|
686
|
+
* ```typescript
|
|
687
|
+
* {
|
|
688
|
+
* pattern: '/blog',
|
|
689
|
+
* dataBindings: {
|
|
690
|
+
* pages: {
|
|
691
|
+
* prefix: '/blog/',
|
|
692
|
+
* sort: 'date-desc',
|
|
693
|
+
* limit: 10,
|
|
694
|
+
* },
|
|
695
|
+
* },
|
|
696
|
+
* }
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
699
|
+
pages?: {
|
|
700
|
+
/**
|
|
701
|
+
* Path prefix to filter pages.
|
|
702
|
+
*
|
|
703
|
+
* Only pages whose pathname starts with this prefix are included.
|
|
704
|
+
* The listing page itself is excluded.
|
|
705
|
+
*
|
|
706
|
+
* @example '/blog/' matches '/blog/post-1', '/blog/post-2'
|
|
707
|
+
*/
|
|
708
|
+
prefix: string;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Maximum number of pages to return.
|
|
712
|
+
*
|
|
713
|
+
* Useful for showing "latest N posts" on a homepage or sidebar.
|
|
714
|
+
*/
|
|
715
|
+
limit?: number;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Sort order for returned pages.
|
|
719
|
+
*
|
|
720
|
+
* - 'date-desc': Newest first by `timestamps.published`, so editing a page never moves it
|
|
721
|
+
* - 'date-asc': Oldest first
|
|
722
|
+
* - 'title': Alphabetical by title
|
|
723
|
+
*
|
|
724
|
+
* Pages that tie are listed by pathname, then id, so every surface shows one order.
|
|
725
|
+
*
|
|
726
|
+
* @default 'date-desc'
|
|
727
|
+
*/
|
|
728
|
+
sort?: 'date-desc' | 'date-asc' | 'title';
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* What an editor needs to build a page's {@link DataContext} the way the
|
|
734
|
+
* published page gets it: the site and locale the routes read under, and every
|
|
735
|
+
* page collection a route serves, keyed by collection, with that route's
|
|
736
|
+
* bindings. The first route wins when two share a collection.
|
|
737
|
+
*/
|
|
738
|
+
export interface EditorDataBindings {
|
|
739
|
+
siteName: string;
|
|
740
|
+
locale: string;
|
|
741
|
+
routes: Record<string, DataBindingConfig>;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// Internal type for locale data returned by readLocaleFile
|
|
745
|
+
export interface LocaleFileData {
|
|
746
|
+
locale: string;
|
|
747
|
+
etag: string;
|
|
748
|
+
created: string;
|
|
749
|
+
modified: string;
|
|
750
|
+
publishAt?: string;
|
|
751
|
+
unpublishAt?: string;
|
|
752
|
+
previousPathnames?: Record<string, string>;
|
|
753
|
+
meta: ContentMeta;
|
|
754
|
+
content: {
|
|
755
|
+
puckData?: any;
|
|
756
|
+
mdx?: string;
|
|
757
|
+
data?: Record<string, unknown>;
|
|
758
|
+
};
|
|
759
|
+
}
|