@conloca/content-api 0.1.14 → 0.1.16
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-manifest.d.ts +23 -0
- package/dist/asset-manifest.d.ts.map +1 -0
- package/dist/asset-manifest.js +73 -0
- package/dist/asset-operations.d.ts +159 -0
- package/dist/asset-operations.d.ts.map +1 -0
- package/dist/asset-operations.js +736 -0
- package/dist/asset-types.d.ts +56 -0
- package/dist/asset-types.d.ts.map +1 -0
- package/dist/asset-types.js +7 -0
- package/dist/base-content-index.d.ts +57 -0
- package/dist/base-content-index.d.ts.map +1 -0
- package/dist/base-content-index.js +179 -0
- package/dist/block-index.d.ts +9 -0
- package/dist/block-index.d.ts.map +1 -0
- package/dist/block-index.js +11 -0
- package/dist/blocks.d.ts +16 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +103 -0
- package/dist/cf-access.d.ts +31 -0
- package/dist/cf-access.d.ts.map +1 -0
- package/dist/cf-access.js +66 -0
- package/dist/component-registry.d.ts +50 -0
- package/dist/component-registry.d.ts.map +1 -0
- package/dist/component-registry.js +120 -0
- package/dist/component-registry.types-C0ctF9nh.d.mts +71 -0
- package/dist/component-registry.types-C0ctF9nh.d.mts.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 +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 +1 -0
- package/dist/content-filters.d.ts +31 -0
- package/dist/content-filters.d.ts.map +1 -0
- package/dist/content-filters.js +246 -0
- package/dist/content-index-D092_vk1.mjs +629 -0
- package/dist/content-index-D092_vk1.mjs.map +1 -0
- package/dist/content-index-D6IVMmAB.d.mts +127 -0
- package/dist/content-index-D6IVMmAB.d.mts.map +1 -0
- package/dist/content-index.d.ts +126 -0
- package/dist/content-index.d.ts.map +1 -0
- package/dist/content-index.js +418 -0
- package/dist/content-operations-DIbsxG5A.d.mts +354 -0
- package/dist/content-operations-DIbsxG5A.d.mts.map +1 -0
- package/dist/content-operations.d.ts +93 -0
- package/dist/content-operations.d.ts.map +1 -0
- package/dist/content-operations.js +275 -0
- package/dist/content-reader.d.ts +10 -0
- package/dist/content-reader.d.ts.map +1 -0
- package/dist/content-reader.js +13 -0
- package/dist/content-utils-fWNHTrPy.mjs +280 -0
- package/dist/content-utils-fWNHTrPy.mjs.map +1 -0
- package/dist/content-utils.d.ts +132 -0
- package/dist/content-utils.d.ts.map +1 -0
- package/dist/content-utils.js +352 -0
- package/dist/content-watcher.d.ts +43 -0
- package/dist/content-watcher.d.ts.map +1 -0
- package/dist/content-watcher.js +83 -0
- package/dist/data-DquNIEnQ.mjs +62 -0
- package/dist/data-DquNIEnQ.mjs.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 +7 -0
- package/dist/data.d.ts +43 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +103 -0
- package/dist/etag-utils.d.ts +77 -0
- package/dist/etag-utils.d.ts.map +1 -0
- package/dist/etag-utils.js +160 -0
- package/dist/filesystem-content-api-B1KIQJfk.mjs +2 -0
- package/dist/filesystem-content-api-C0HIhqZi.mjs +1620 -0
- package/dist/filesystem-content-api-C0HIhqZi.mjs.map +1 -0
- package/dist/filesystem-content-api-DCdNi-co.d.mts +134 -0
- package/dist/filesystem-content-api-DCdNi-co.d.mts.map +1 -0
- package/dist/filesystem-content-api.d.ts +135 -0
- package/dist/filesystem-content-api.d.ts.map +1 -0
- package/dist/filesystem-content-api.js +2181 -0
- package/dist/git-operations.d.ts +49 -0
- package/dist/git-operations.d.ts.map +1 -0
- package/dist/git-operations.js +252 -0
- package/dist/header-parser.d.ts +37 -0
- package/dist/header-parser.d.ts.map +1 -0
- package/dist/header-parser.js +286 -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 +591 -0
- package/dist/index-DxVTFK66.d.mts +105 -0
- package/dist/index-DxVTFK66.d.mts.map +1 -0
- package/dist/index.d.mts +6 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.mjs +37 -5
- package/dist/index.mjs.map +1 -1
- package/dist/indexing.d.mts +152 -0
- package/dist/indexing.d.mts.map +1 -0
- package/dist/indexing.d.ts +5 -0
- package/dist/indexing.d.ts.map +1 -0
- package/dist/indexing.js +7 -0
- package/dist/indexing.mjs +255 -0
- package/dist/indexing.mjs.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 +152 -0
- package/dist/middleware.d.ts +20 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +1031 -0
- package/dist/node.d.mts +28 -126
- package/dist/node.d.mts.map +1 -1
- package/dist/node.d.ts +25 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +24 -0
- package/dist/node.mjs +199 -2890
- package/dist/node.mjs.map +1 -1
- package/dist/reader.d.mts +15 -0
- package/dist/reader.d.mts.map +1 -0
- package/dist/reader.d.ts +15 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +13 -0
- package/dist/reader.mjs +22 -0
- package/dist/reader.mjs.map +1 -0
- package/dist/schemas/index.d.mts +2 -90
- package/dist/schemas/index.d.ts +102 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +87 -0
- package/dist/schemas/index.mjs +2 -70
- package/dist/schemas-CFRD0FIQ.mjs +84 -0
- package/dist/schemas-CFRD0FIQ.mjs.map +1 -0
- package/dist/{types-BUG0Cfkg.mjs → site-8oaj1Q60.mjs} +20 -222
- package/dist/site-8oaj1Q60.mjs.map +1 -0
- package/dist/site-index-B_254bCc.d.mts +136 -0
- package/dist/site-index-B_254bCc.d.mts.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 +287 -0
- package/dist/site.d.ts +21 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +168 -0
- package/dist/types-DOdldbfD.mjs +34 -0
- package/dist/types-DOdldbfD.mjs.map +1 -0
- package/dist/types-DjfhS272.d.mts +456 -0
- package/dist/types-DjfhS272.d.mts.map +1 -0
- package/dist/types.d.ts +453 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +36 -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 +40 -0
- package/dist/url-validation.d.ts +14 -0
- package/dist/url-validation.d.ts.map +1 -0
- package/dist/url-validation.js +81 -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 +20 -0
- package/dist/utils.d.ts +46 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +70 -0
- package/dist/vite-plugin.d.ts +12 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +29 -0
- package/dist/vxjson-qHrgLGip.mjs +555 -0
- package/dist/vxjson-qHrgLGip.mjs.map +1 -0
- package/dist/vxjson-serialize-geF6qvpn.mjs +34 -0
- package/dist/vxjson-serialize-geF6qvpn.mjs.map +1 -0
- package/dist/vxjson-serialize.d.mts +17 -0
- package/dist/vxjson-serialize.d.mts.map +1 -0
- package/dist/vxjson-serialize.d.ts +14 -0
- package/dist/vxjson-serialize.d.ts.map +1 -0
- package/dist/vxjson-serialize.js +50 -0
- package/dist/vxjson-serialize.mjs +2 -0
- package/dist/vxjson.d.ts +112 -0
- package/dist/vxjson.d.ts.map +1 -0
- package/dist/vxjson.js +391 -0
- package/dist/xxhash.d.ts +10 -0
- package/dist/xxhash.d.ts.map +1 -0
- package/dist/xxhash.js +31 -0
- package/package.json +88 -17
- package/dist/content-operations-BZLfJWqT.d.mts +0 -916
- package/dist/content-operations-BZLfJWqT.d.mts.map +0 -1
- package/dist/schemas/index.d.mts.map +0 -1
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/types-BUG0Cfkg.mjs.map +0 -1
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
export interface ContentAPIOptions {
|
|
2
|
+
contentRoot: string;
|
|
3
|
+
canvasDir?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Optional override for the mdx-type pages path. The canonical home for
|
|
6
|
+
* this value is the resolved site's `mdxPages` field in `sites.json`.
|
|
7
|
+
* This option, when present, wins over the sites.json value — useful
|
|
8
|
+
* for tests and programmatic content-api setups that don't want to
|
|
9
|
+
* round-trip through a sites.json file on disk.
|
|
10
|
+
*
|
|
11
|
+
* Decouples the storage location of mdx pages from Conloca's main content
|
|
12
|
+
* tree so projects can host them wherever their renderer expects to read
|
|
13
|
+
* from. The rendering pipeline is the project's own choice — Conloca only
|
|
14
|
+
* owns CRUD on the file bytes.
|
|
15
|
+
*
|
|
16
|
+
* When omitted AND no site in sites.json has `mdxPages`, .mdx files
|
|
17
|
+
* fall back to living alongside Puck pages at
|
|
18
|
+
* `{contentRoot}/{site}/pages/`.
|
|
19
|
+
*/
|
|
20
|
+
mdxPagesRoot?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Default locale for mdx pages. The default locale's files live at
|
|
23
|
+
* `{mdxPagesRoot}/{slug}.mdx` (no locale prefix); other locales live at
|
|
24
|
+
* `{mdxPagesRoot}/{locale}/{slug}.mdx`.
|
|
25
|
+
*
|
|
26
|
+
* If omitted, falls back to the first site's `defaultLocale`, or `'en'`.
|
|
27
|
+
*/
|
|
28
|
+
mdxPagesDefaultLocale?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Site name to associate mdx pages with for pathname collision checking.
|
|
31
|
+
* mdx pages share the URL space with that site's puck pages, so two
|
|
32
|
+
* pages — regardless of type — cannot share a pathname.
|
|
33
|
+
*
|
|
34
|
+
* If omitted, falls back to the first site name in sites.json (or
|
|
35
|
+
* `'default'` when no sites are configured).
|
|
36
|
+
*/
|
|
37
|
+
mdxPagesSite?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The site's supported locales. When provided, this wins over the
|
|
40
|
+
* `globalLocales` field in sites.json. The locale-detection parsers
|
|
41
|
+
* use this list to decide whether a folder or filename suffix that
|
|
42
|
+
* looks locale-shaped (e.g. `de`, `en-US`) is actually a locale or
|
|
43
|
+
* just a folder that happens to match the pattern.
|
|
44
|
+
*
|
|
45
|
+
* Omit to fall back to sites.json (current behavior).
|
|
46
|
+
*/
|
|
47
|
+
availableLocales?: string[];
|
|
48
|
+
/**
|
|
49
|
+
* The site's default locale. Wins over both `mdxPagesDefaultLocale`
|
|
50
|
+
* and the per-site `defaultLocale` in sites.json when provided.
|
|
51
|
+
*/
|
|
52
|
+
defaultLocale?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface APIError {
|
|
55
|
+
error: {
|
|
56
|
+
code: string;
|
|
57
|
+
message: string;
|
|
58
|
+
details?: any;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface MDXCompileResponse {
|
|
62
|
+
code: string;
|
|
63
|
+
metadata: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
export declare const ErrorCodes: {
|
|
66
|
+
readonly CONTENT_NOT_FOUND: 'CONTENT_NOT_FOUND';
|
|
67
|
+
readonly LOCALE_NOT_FOUND: 'LOCALE_NOT_FOUND';
|
|
68
|
+
readonly COLLECTION_NOT_FOUND: 'COLLECTION_NOT_FOUND';
|
|
69
|
+
readonly SITE_NOT_FOUND: 'SITE_NOT_FOUND';
|
|
70
|
+
readonly STALE_WRITE: 'STALE_WRITE';
|
|
71
|
+
readonly ALREADY_EXISTS: 'ALREADY_EXISTS';
|
|
72
|
+
readonly PATHNAME_TAKEN: 'PATHNAME_TAKEN';
|
|
73
|
+
readonly INVALID_PATHNAME: 'INVALID_PATHNAME';
|
|
74
|
+
readonly NAME_TAKEN: 'NAME_TAKEN';
|
|
75
|
+
readonly METADATA_TOO_LARGE: 'METADATA_TOO_LARGE';
|
|
76
|
+
readonly WRITE_ERROR: 'WRITE_ERROR';
|
|
77
|
+
readonly MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD';
|
|
78
|
+
readonly INVALID_LOCALE: 'INVALID_LOCALE';
|
|
79
|
+
readonly INVALID_CONTENT_TYPE: 'INVALID_CONTENT_TYPE';
|
|
80
|
+
readonly INVALID_REQUEST: 'INVALID_REQUEST';
|
|
81
|
+
readonly MDX_COMPILE_FAILED: 'MDX_COMPILE_FAILED';
|
|
82
|
+
readonly INTERNAL_ERROR: 'INTERNAL_ERROR';
|
|
83
|
+
readonly FETCH_ERROR: 'FETCH_ERROR';
|
|
84
|
+
readonly GIT_NOT_REPO: 'GIT_NOT_REPO';
|
|
85
|
+
readonly GIT_COMMIT_FAILED: 'GIT_COMMIT_FAILED';
|
|
86
|
+
readonly GIT_PUSH_FAILED: 'GIT_PUSH_FAILED';
|
|
87
|
+
readonly GIT_PULL_FAILED: 'GIT_PULL_FAILED';
|
|
88
|
+
readonly GIT_STATUS_FAILED: 'GIT_STATUS_FAILED';
|
|
89
|
+
readonly ASSET_NOT_FOUND: 'ASSET_NOT_FOUND';
|
|
90
|
+
readonly ASSET_INVALID_FORMAT: 'ASSET_INVALID_FORMAT';
|
|
91
|
+
readonly ASSET_TOO_LARGE: 'ASSET_TOO_LARGE';
|
|
92
|
+
readonly ASSET_UPLOAD_FAILED: 'ASSET_UPLOAD_FAILED';
|
|
93
|
+
};
|
|
94
|
+
export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
95
|
+
export type ContentType = 'puck' | 'mdx' | 'json';
|
|
96
|
+
export interface ContentData {
|
|
97
|
+
puckData?: any;
|
|
98
|
+
mdx?: string;
|
|
99
|
+
data?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
export interface ContentProp {
|
|
102
|
+
content: ContentData;
|
|
103
|
+
}
|
|
104
|
+
export interface ContentIdentity {
|
|
105
|
+
id: string;
|
|
106
|
+
type: ContentType;
|
|
107
|
+
kind: 'block' | 'page' | 'data';
|
|
108
|
+
site?: string;
|
|
109
|
+
collection: string;
|
|
110
|
+
}
|
|
111
|
+
export interface LocalePathData {
|
|
112
|
+
locale: string;
|
|
113
|
+
pathname?: string;
|
|
114
|
+
name?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface LocaleVersion extends LocalePathData {
|
|
117
|
+
etag: string;
|
|
118
|
+
created: string;
|
|
119
|
+
modified: string;
|
|
120
|
+
publishAt?: string;
|
|
121
|
+
unpublishAt?: string;
|
|
122
|
+
previousPathnames?: Record<string, string>;
|
|
123
|
+
meta: ContentMeta;
|
|
124
|
+
}
|
|
125
|
+
export interface ContentManifest extends ContentIdentity {
|
|
126
|
+
locales: Record<string, LocaleVersion | undefined>;
|
|
127
|
+
}
|
|
128
|
+
export interface LocalizedManifest extends ContentIdentity {
|
|
129
|
+
localized: LocaleVersion;
|
|
130
|
+
}
|
|
131
|
+
export interface LocalizedEntry extends ContentIdentity {
|
|
132
|
+
localized: LocaleVersion & ContentProp;
|
|
133
|
+
}
|
|
134
|
+
export interface ContentEntry extends ContentManifest {
|
|
135
|
+
locales: Record<string, LocaleVersion & ContentProp>;
|
|
136
|
+
}
|
|
137
|
+
export interface UpdateResult {
|
|
138
|
+
success: boolean;
|
|
139
|
+
etag?: string;
|
|
140
|
+
modified?: Date;
|
|
141
|
+
reason?: 'not_found' | 'stale_write' | 'write_error';
|
|
142
|
+
error?: Error;
|
|
143
|
+
currentEtag?: string;
|
|
144
|
+
conflictDetails?: {
|
|
145
|
+
metaChanged: boolean;
|
|
146
|
+
contentChanged: boolean;
|
|
147
|
+
currentMeta?: ContentMeta;
|
|
148
|
+
currentContent?: ContentData;
|
|
149
|
+
localContent?: ContentData;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export interface MoveResult {
|
|
153
|
+
moved: boolean;
|
|
154
|
+
previousPathname?: string;
|
|
155
|
+
files?: string[];
|
|
156
|
+
reason?: 'not_found' | 'already_exists' | 'stale_write' | 'write_error';
|
|
157
|
+
error?: Error;
|
|
158
|
+
etag?: string;
|
|
159
|
+
}
|
|
160
|
+
export interface ContentListResult {
|
|
161
|
+
items: ContentManifest[];
|
|
162
|
+
total: number;
|
|
163
|
+
hasMore?: boolean;
|
|
164
|
+
}
|
|
165
|
+
export interface GlobalFilters {
|
|
166
|
+
site?: string;
|
|
167
|
+
collection?: string;
|
|
168
|
+
locales?: string[];
|
|
169
|
+
type?: 'puck' | 'mdx' | 'json';
|
|
170
|
+
published?: boolean;
|
|
171
|
+
kind?: 'block' | 'page' | 'data';
|
|
172
|
+
localization?: 'complete' | 'partial' | 'one';
|
|
173
|
+
missingLocales?: string[];
|
|
174
|
+
}
|
|
175
|
+
export interface SiteFilters {
|
|
176
|
+
collection?: string;
|
|
177
|
+
locales?: string[];
|
|
178
|
+
type?: 'puck' | 'mdx';
|
|
179
|
+
published?: boolean;
|
|
180
|
+
}
|
|
181
|
+
export interface BlockFilters {
|
|
182
|
+
collection?: string;
|
|
183
|
+
locales?: string[];
|
|
184
|
+
}
|
|
185
|
+
export interface FindOptions {
|
|
186
|
+
excludeSites?: string[];
|
|
187
|
+
includeUnpublished?: boolean;
|
|
188
|
+
}
|
|
189
|
+
export interface CreateContentInput {
|
|
190
|
+
kind: 'block' | 'page' | 'data';
|
|
191
|
+
site?: string;
|
|
192
|
+
collection: string;
|
|
193
|
+
type: ContentType;
|
|
194
|
+
created?: string;
|
|
195
|
+
name?: string;
|
|
196
|
+
meta?: Partial<ContentMeta>;
|
|
197
|
+
locales: {
|
|
198
|
+
[locale: string]: {
|
|
199
|
+
pathname?: string;
|
|
200
|
+
publishAt?: string | null | false;
|
|
201
|
+
unpublishAt?: string | null | false;
|
|
202
|
+
meta?: Partial<ContentMeta>;
|
|
203
|
+
} & ContentProp;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export interface CreatePageInput {
|
|
207
|
+
collection: string;
|
|
208
|
+
locales: {
|
|
209
|
+
[locale: string]: {
|
|
210
|
+
pathname: string;
|
|
211
|
+
publishAt?: string | null | false;
|
|
212
|
+
unpublishAt?: string | null | false;
|
|
213
|
+
meta: ContentMeta;
|
|
214
|
+
content: {
|
|
215
|
+
puckData: any;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
export interface CreateBlockInput {
|
|
221
|
+
collection: string;
|
|
222
|
+
type: 'mdx';
|
|
223
|
+
name: string;
|
|
224
|
+
meta?: Partial<ContentMeta>;
|
|
225
|
+
locales: {
|
|
226
|
+
[locale: string]: {
|
|
227
|
+
publishAt?: string | null | false;
|
|
228
|
+
unpublishAt?: string | null | false;
|
|
229
|
+
meta?: Partial<ContentMeta>;
|
|
230
|
+
content: {
|
|
231
|
+
mdx: string;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
export interface UpdateLocaleInput {
|
|
237
|
+
id: string;
|
|
238
|
+
locale: string;
|
|
239
|
+
data: LocaleUpdateData;
|
|
240
|
+
etag: string;
|
|
241
|
+
}
|
|
242
|
+
export interface LocaleUpdateData {
|
|
243
|
+
pathname?: string;
|
|
244
|
+
name?: string;
|
|
245
|
+
publishAt?: string | null | false;
|
|
246
|
+
unpublishAt?: string | null | false;
|
|
247
|
+
modified?: string;
|
|
248
|
+
meta?: Partial<ContentMeta>;
|
|
249
|
+
content?: ContentData;
|
|
250
|
+
}
|
|
251
|
+
export interface DeleteLocaleInput {
|
|
252
|
+
id: string;
|
|
253
|
+
locale: string;
|
|
254
|
+
etag: string;
|
|
255
|
+
}
|
|
256
|
+
export interface SitesConfig {
|
|
257
|
+
sites: {
|
|
258
|
+
[siteName: string]: {
|
|
259
|
+
locales: string[];
|
|
260
|
+
defaultLocale: string;
|
|
261
|
+
domains?: {
|
|
262
|
+
[locale: string]: string;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Optional filesystem path for this site's mdx-type pages.
|
|
266
|
+
* When set, .mdx files under this path are surfaced in the CMS
|
|
267
|
+
* as `kind: 'page'` + `type: 'mdx'` content owned by this site.
|
|
268
|
+
*
|
|
269
|
+
* Path is interpreted relative to the project root (the same
|
|
270
|
+
* cwd Astro uses), not the content root, so it can live anywhere
|
|
271
|
+
* the renderer expects (e.g. `./src/content/docs` for Starlight).
|
|
272
|
+
*
|
|
273
|
+
* When omitted, .mdx files for this site are expected to live
|
|
274
|
+
* alongside Puck (`.vxjson`) pages at `{contentRoot}/{site}/pages/`
|
|
275
|
+
* — the file extension determines the page type.
|
|
276
|
+
*/
|
|
277
|
+
mdxPages?: string;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
globalLocales: string[];
|
|
281
|
+
}
|
|
282
|
+
export interface BatchResult {
|
|
283
|
+
operations: BatchOperationResult[];
|
|
284
|
+
success: boolean;
|
|
285
|
+
failed: number;
|
|
286
|
+
updated: number;
|
|
287
|
+
}
|
|
288
|
+
export interface ContentMeta {
|
|
289
|
+
title: string;
|
|
290
|
+
description?: string;
|
|
291
|
+
author?: string;
|
|
292
|
+
tags?: string[];
|
|
293
|
+
keywords?: string[];
|
|
294
|
+
ogTitle?: string;
|
|
295
|
+
ogDescription?: string;
|
|
296
|
+
ogImage?: string;
|
|
297
|
+
[key: string]: any;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* VXJSON (Variant JSON) File Format
|
|
301
|
+
*
|
|
302
|
+
* VXJSON is a specialized JSON format that guarantees:
|
|
303
|
+
* 1. The root is always an object (never an array or primitive)
|
|
304
|
+
* 2. The "content" field always comes last in the object
|
|
305
|
+
* 3. Field order is deterministic for consistent ETag calculation
|
|
306
|
+
*
|
|
307
|
+
* This format enables efficient streaming ETag calculation where metadata
|
|
308
|
+
* can be hashed separately from content, supporting partial updates and
|
|
309
|
+
* conflict resolution in CMS scenarios.
|
|
310
|
+
*
|
|
311
|
+
* Files using this format have the extension .vxjson
|
|
312
|
+
*/
|
|
313
|
+
export interface VXJSONFile {
|
|
314
|
+
id: string;
|
|
315
|
+
type: ContentType;
|
|
316
|
+
created: string;
|
|
317
|
+
modified: string;
|
|
318
|
+
publishAt?: string;
|
|
319
|
+
unpublishAt?: string;
|
|
320
|
+
previousPathnames?: Record<string, string>;
|
|
321
|
+
meta: ContentMeta;
|
|
322
|
+
content: ContentData;
|
|
323
|
+
}
|
|
324
|
+
export interface MDXFrontmatter {
|
|
325
|
+
id: string;
|
|
326
|
+
type: 'mdx';
|
|
327
|
+
created: string;
|
|
328
|
+
modified: string;
|
|
329
|
+
publishAt?: string;
|
|
330
|
+
unpublishAt?: string;
|
|
331
|
+
meta: ContentMeta;
|
|
332
|
+
}
|
|
333
|
+
export type WriteResult = {
|
|
334
|
+
success: true;
|
|
335
|
+
etag: string;
|
|
336
|
+
modified?: Date;
|
|
337
|
+
reason?: undefined;
|
|
338
|
+
error?: undefined;
|
|
339
|
+
currentEtag?: undefined;
|
|
340
|
+
} | {
|
|
341
|
+
success: false;
|
|
342
|
+
etag?: undefined;
|
|
343
|
+
modified?: undefined;
|
|
344
|
+
reason: 'stale_write';
|
|
345
|
+
error?: undefined;
|
|
346
|
+
currentEtag: string;
|
|
347
|
+
} | {
|
|
348
|
+
success: false;
|
|
349
|
+
etag?: undefined;
|
|
350
|
+
modified?: undefined;
|
|
351
|
+
reason: 'already_exists';
|
|
352
|
+
error?: undefined;
|
|
353
|
+
currentEtag: string;
|
|
354
|
+
} | {
|
|
355
|
+
success: false;
|
|
356
|
+
etag?: undefined;
|
|
357
|
+
modified?: undefined;
|
|
358
|
+
reason: 'write_error';
|
|
359
|
+
error: Error;
|
|
360
|
+
currentEtag?: string;
|
|
361
|
+
};
|
|
362
|
+
export interface DeleteResult {
|
|
363
|
+
success: boolean;
|
|
364
|
+
error?: Error;
|
|
365
|
+
reason?: 'stale_write' | 'not_found' | 'delete_error';
|
|
366
|
+
currentEtag?: string;
|
|
367
|
+
}
|
|
368
|
+
export interface CreateResult {
|
|
369
|
+
success: boolean;
|
|
370
|
+
id?: string;
|
|
371
|
+
etag?: string;
|
|
372
|
+
created?: Date;
|
|
373
|
+
reason?: 'already_exists' | 'write_error' | 'invalid_name' | 'invalid_pathname' | 'name_taken' | 'pathname_taken' | 'pathname_in_redirects' | 'metadata_too_large';
|
|
374
|
+
error?: Error;
|
|
375
|
+
existingId?: string;
|
|
376
|
+
}
|
|
377
|
+
export interface BatchOperationResult {
|
|
378
|
+
id: string;
|
|
379
|
+
locale: string;
|
|
380
|
+
updated: boolean;
|
|
381
|
+
error?: Error;
|
|
382
|
+
etag?: string;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Minimal page reference for listing/navigation in data context.
|
|
386
|
+
*
|
|
387
|
+
* Used in dataBindings.pages for blog listing components
|
|
388
|
+
* and getStaticPaths() to enumerate available pages.
|
|
389
|
+
*/
|
|
390
|
+
export interface PageReference {
|
|
391
|
+
/** Page identifier. */
|
|
392
|
+
id: string;
|
|
393
|
+
/** URL pathname. */
|
|
394
|
+
pathname: string;
|
|
395
|
+
/** Page title (if available without full load). */
|
|
396
|
+
title?: string;
|
|
397
|
+
/** Content collection. */
|
|
398
|
+
collection: string;
|
|
399
|
+
/** Page metadata from content. */
|
|
400
|
+
meta?: Record<string, unknown>;
|
|
401
|
+
/** Page timestamps for sorting and display. */
|
|
402
|
+
timestamps?: {
|
|
403
|
+
created?: Date;
|
|
404
|
+
modified?: Date;
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* A single entry from a data collection.
|
|
409
|
+
*
|
|
410
|
+
* Simplified representation of collection data for use in component resolvers.
|
|
411
|
+
*/
|
|
412
|
+
export interface DataCollectionEntry {
|
|
413
|
+
/** Unique identifier for the entry. */
|
|
414
|
+
id: string;
|
|
415
|
+
/** Human-readable name of the entry. */
|
|
416
|
+
name: string;
|
|
417
|
+
/** The entry's data content. */
|
|
418
|
+
data: Record<string, unknown>;
|
|
419
|
+
/** Optional metadata for the entry. */
|
|
420
|
+
meta?: Record<string, unknown>;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Context object passed to Puck component resolvers via metadata.
|
|
424
|
+
*
|
|
425
|
+
* Contains fetched collection data and contextual information
|
|
426
|
+
* for data-driven component rendering.
|
|
427
|
+
*/
|
|
428
|
+
export interface DataContext {
|
|
429
|
+
/** Collection data keyed by collection name. */
|
|
430
|
+
collections: Record<string, DataCollectionEntry[]>;
|
|
431
|
+
/** Pages matching the dataBindings.pages filter. */
|
|
432
|
+
pages?: PageReference[];
|
|
433
|
+
/** Current locale used for data fetching. */
|
|
434
|
+
locale: string;
|
|
435
|
+
/** Site name from routing configuration. */
|
|
436
|
+
siteName: string;
|
|
437
|
+
}
|
|
438
|
+
export interface LocaleFileData {
|
|
439
|
+
locale: string;
|
|
440
|
+
etag: string;
|
|
441
|
+
created: string;
|
|
442
|
+
modified: string;
|
|
443
|
+
publishAt?: string;
|
|
444
|
+
unpublishAt?: string;
|
|
445
|
+
previousPathnames?: Record<string, string>;
|
|
446
|
+
meta: ContentMeta;
|
|
447
|
+
content: {
|
|
448
|
+
puckData?: any;
|
|
449
|
+
mdx?: string;
|
|
450
|
+
data?: Record<string, unknown>;
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;;;;OAOG;I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
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Common error codes
|
|
2
|
+
export const ErrorCodes = {
|
|
3
|
+
// Content errors
|
|
4
|
+
CONTENT_NOT_FOUND: 'CONTENT_NOT_FOUND',
|
|
5
|
+
LOCALE_NOT_FOUND: 'LOCALE_NOT_FOUND',
|
|
6
|
+
COLLECTION_NOT_FOUND: 'COLLECTION_NOT_FOUND',
|
|
7
|
+
SITE_NOT_FOUND: 'SITE_NOT_FOUND',
|
|
8
|
+
// Write errors
|
|
9
|
+
STALE_WRITE: 'STALE_WRITE',
|
|
10
|
+
ALREADY_EXISTS: 'ALREADY_EXISTS',
|
|
11
|
+
PATHNAME_TAKEN: 'PATHNAME_TAKEN',
|
|
12
|
+
INVALID_PATHNAME: 'INVALID_PATHNAME',
|
|
13
|
+
NAME_TAKEN: 'NAME_TAKEN',
|
|
14
|
+
METADATA_TOO_LARGE: 'METADATA_TOO_LARGE',
|
|
15
|
+
WRITE_ERROR: 'WRITE_ERROR',
|
|
16
|
+
// Validation errors
|
|
17
|
+
MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',
|
|
18
|
+
INVALID_LOCALE: 'INVALID_LOCALE',
|
|
19
|
+
INVALID_CONTENT_TYPE: 'INVALID_CONTENT_TYPE',
|
|
20
|
+
INVALID_REQUEST: 'INVALID_REQUEST',
|
|
21
|
+
MDX_COMPILE_FAILED: 'MDX_COMPILE_FAILED',
|
|
22
|
+
// System errors
|
|
23
|
+
INTERNAL_ERROR: 'INTERNAL_ERROR',
|
|
24
|
+
FETCH_ERROR: 'FETCH_ERROR',
|
|
25
|
+
// Git errors
|
|
26
|
+
GIT_NOT_REPO: 'GIT_NOT_REPO',
|
|
27
|
+
GIT_COMMIT_FAILED: 'GIT_COMMIT_FAILED',
|
|
28
|
+
GIT_PUSH_FAILED: 'GIT_PUSH_FAILED',
|
|
29
|
+
GIT_PULL_FAILED: 'GIT_PULL_FAILED',
|
|
30
|
+
GIT_STATUS_FAILED: 'GIT_STATUS_FAILED',
|
|
31
|
+
// Asset errors
|
|
32
|
+
ASSET_NOT_FOUND: 'ASSET_NOT_FOUND',
|
|
33
|
+
ASSET_INVALID_FORMAT: 'ASSET_INVALID_FORMAT',
|
|
34
|
+
ASSET_TOO_LARGE: 'ASSET_TOO_LARGE',
|
|
35
|
+
ASSET_UPLOAD_FAILED: 'ASSET_UPLOAD_FAILED',
|
|
36
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert bytes to URL-safe base64
|
|
3
|
+
* Replaces + with -, / with _, and removes = padding
|
|
4
|
+
*/
|
|
5
|
+
export declare function toUrlSafeBase64(bytes: Uint8Array): string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert BigInt to URL-safe base64
|
|
8
|
+
* @param value - The BigInt value to convert
|
|
9
|
+
* @returns URL-safe base64 string representation
|
|
10
|
+
*/
|
|
11
|
+
export declare function bigintToUrlSafeBase64(value: bigint): string;
|
|
12
|
+
//# sourceMappingURL=url-safe-base64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-safe-base64.d.ts","sourceRoot":"","sources":["../src/url-safe-base64.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAoBzD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM3D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert bytes to URL-safe base64
|
|
3
|
+
* Replaces + with -, / with _, and removes = padding
|
|
4
|
+
*/
|
|
5
|
+
export function toUrlSafeBase64(bytes) {
|
|
6
|
+
const b64 = Buffer.from(bytes).toString('base64');
|
|
7
|
+
const buf = Buffer.from(b64, 'ascii');
|
|
8
|
+
let write = 0;
|
|
9
|
+
for (let read = 0; read < buf.length; read++) {
|
|
10
|
+
const c = buf[read];
|
|
11
|
+
if (c === 0x2b) {
|
|
12
|
+
// '+'
|
|
13
|
+
buf[write++] = 0x2d; // '-'
|
|
14
|
+
}
|
|
15
|
+
else if (c === 0x2f) {
|
|
16
|
+
// '/'
|
|
17
|
+
buf[write++] = 0x5f; // '_'
|
|
18
|
+
}
|
|
19
|
+
else if (c === 0x3d) {
|
|
20
|
+
// '='
|
|
21
|
+
// skip padding
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
buf[write++] = c;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return buf.subarray(0, write).toString('ascii');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Convert BigInt to URL-safe base64
|
|
31
|
+
* @param value - The BigInt value to convert
|
|
32
|
+
* @returns URL-safe base64 string representation
|
|
33
|
+
*/
|
|
34
|
+
export function bigintToUrlSafeBase64(value) {
|
|
35
|
+
// Convert BigInt to 8-byte buffer
|
|
36
|
+
const hashBuffer = new Uint8Array(8);
|
|
37
|
+
const dataView = new DataView(hashBuffer.buffer);
|
|
38
|
+
dataView.setBigUint64(0, value, false); // big-endian
|
|
39
|
+
return toUrlSafeBase64(hashBuffer);
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL validation for SSRF prevention in server-side fetch operations.
|
|
3
|
+
* Blocks private/reserved IP addresses and non-http(s) schemes.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Validate that a URL is safe to fetch server-side.
|
|
7
|
+
* Blocks private/reserved IP addresses and non-http(s) schemes.
|
|
8
|
+
*
|
|
9
|
+
* @param url The URL string to validate
|
|
10
|
+
* @returns The parsed URL object if valid
|
|
11
|
+
* @throws Error if the URL is invalid, uses a blocked scheme, or points to a private IP
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateFetchUrl(url: string): URL;
|
|
14
|
+
//# sourceMappingURL=url-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-validation.d.ts","sourceRoot":"","sources":["../src/url-validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8CH;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CA2BjD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL validation for SSRF prevention in server-side fetch operations.
|
|
3
|
+
* Blocks private/reserved IP addresses and non-http(s) schemes.
|
|
4
|
+
*/
|
|
5
|
+
const BLOCKED_HOSTNAMES = new Set(['localhost']);
|
|
6
|
+
/** Check if an IPv4 address string points to a private/reserved range */
|
|
7
|
+
function isPrivateIPv4(hostname) {
|
|
8
|
+
const parts = hostname.split('.');
|
|
9
|
+
if (parts.length !== 4)
|
|
10
|
+
return false;
|
|
11
|
+
const octets = parts.map((p) => Number.parseInt(p, 10));
|
|
12
|
+
if (octets.some((o) => Number.isNaN(o) || o < 0 || o > 255))
|
|
13
|
+
return false;
|
|
14
|
+
const [first, second] = octets;
|
|
15
|
+
// 0.x.x.x — unspecified
|
|
16
|
+
if (first === 0)
|
|
17
|
+
return true;
|
|
18
|
+
// 10.x.x.x — Class A private
|
|
19
|
+
if (first === 10)
|
|
20
|
+
return true;
|
|
21
|
+
// 127.x.x.x — loopback
|
|
22
|
+
if (first === 127)
|
|
23
|
+
return true;
|
|
24
|
+
// 169.254.x.x — link-local (cloud metadata endpoint)
|
|
25
|
+
if (first === 169 && second === 254)
|
|
26
|
+
return true;
|
|
27
|
+
// 172.16.0.0 – 172.31.255.255 — Class B private
|
|
28
|
+
if (first === 172 && second >= 16 && second <= 31)
|
|
29
|
+
return true;
|
|
30
|
+
// 192.168.x.x — Class C private
|
|
31
|
+
if (first === 192 && second === 168)
|
|
32
|
+
return true;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
/** Check if an IPv6 address string points to a private/reserved range */
|
|
36
|
+
function isPrivateIPv6(hostname) {
|
|
37
|
+
const lower = hostname.toLowerCase();
|
|
38
|
+
// ::1 — loopback
|
|
39
|
+
if (lower === '::1')
|
|
40
|
+
return true;
|
|
41
|
+
// :: — unspecified
|
|
42
|
+
if (lower === '::')
|
|
43
|
+
return true;
|
|
44
|
+
// fe80: — link-local
|
|
45
|
+
if (lower.startsWith('fe80:') || lower.startsWith('fe80%'))
|
|
46
|
+
return true;
|
|
47
|
+
// fc00:/fd00: — unique local address (ULA)
|
|
48
|
+
if (lower.startsWith('fc') || lower.startsWith('fd'))
|
|
49
|
+
return true;
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validate that a URL is safe to fetch server-side.
|
|
54
|
+
* Blocks private/reserved IP addresses and non-http(s) schemes.
|
|
55
|
+
*
|
|
56
|
+
* @param url The URL string to validate
|
|
57
|
+
* @returns The parsed URL object if valid
|
|
58
|
+
* @throws Error if the URL is invalid, uses a blocked scheme, or points to a private IP
|
|
59
|
+
*/
|
|
60
|
+
export function validateFetchUrl(url) {
|
|
61
|
+
const parsed = new URL(url); // throws on invalid URLs
|
|
62
|
+
// Check scheme
|
|
63
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
64
|
+
throw new Error('URL scheme must be http or https');
|
|
65
|
+
}
|
|
66
|
+
// Extract hostname (strip brackets from IPv6)
|
|
67
|
+
const hostname = parsed.hostname.replace(/^\[|\]$/g, '');
|
|
68
|
+
// Check blocked hostnames
|
|
69
|
+
if (BLOCKED_HOSTNAMES.has(hostname.toLowerCase())) {
|
|
70
|
+
throw new Error('URL points to a private/reserved IP address');
|
|
71
|
+
}
|
|
72
|
+
// Check IPv4 private ranges
|
|
73
|
+
if (isPrivateIPv4(hostname)) {
|
|
74
|
+
throw new Error('URL points to a private/reserved IP address');
|
|
75
|
+
}
|
|
76
|
+
// Check IPv6 private ranges
|
|
77
|
+
if (isPrivateIPv6(hostname)) {
|
|
78
|
+
throw new Error('URL points to a private/reserved IP address');
|
|
79
|
+
}
|
|
80
|
+
return parsed;
|
|
81
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write file atomically via temp file + rename to prevent corruption on crash.
|
|
3
|
+
* Callers are responsible for ensuring the parent directory exists.
|
|
4
|
+
*/
|
|
5
|
+
export declare function atomicWriteFile(filePath: string, content: string): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=atomic-write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-write.d.ts","sourceRoot":"","sources":["../../src/utils/atomic-write.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAatF"}
|