@conloca/content-api 0.1.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/README.md +7 -0
- package/dist/content-operations-CydU4aAl.d.mts +861 -0
- package/dist/content-operations-CydU4aAl.d.mts.map +1 -0
- package/dist/index-CYptkSgT.d.mts +184 -0
- package/dist/index-CYptkSgT.d.mts.map +1 -0
- package/dist/index.d.mts +52 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node.d.mts +465 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +5077 -0
- package/dist/node.mjs.map +1 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +3 -0
- package/dist/schemas-DenV0mr4.mjs +70 -0
- package/dist/schemas-DenV0mr4.mjs.map +1 -0
- package/dist/types-9p2HHS8z.mjs +567 -0
- package/dist/types-9p2HHS8z.mjs.map +1 -0
- package/package.json +62 -0
package/dist/node.d.mts
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import { $ as DeleteResult, B as ContentData, C as mapSiteNames, Ct as ManifestEntryData, D as serializeMdxWithFrontmatter, E as resolvePublishDate, F as APIError, G as ContentMeta, H as ContentIdentity, I as BatchOperationResult, J as CreateBlockInput, K as ContentProp, L as BatchResult, M as ContentAPI, N as Site, O as ComponentEntry, P as Data, Q as DeleteLocaleInput, R as BlockFilters, S as mapLocales, St as FolderTreeNode, T as parseDate, U as ContentListResult, V as ContentEntry, W as ContentManifest, X as CreatePageInput, Y as CreateContentInput, Z as CreateResult, _ as isContentPublished, _t as WriteResult, a as analyzeUpdateScope, at as LocalePathData, b as isValidPathname, bt as AssetUsage, c as shouldUpdateModifiedTimestamp, ct as LocalizedEntry, d as validateCreateContent, dt as MoveResult, et as ErrorCode, f as extractBlockName, ft as SiteFilters, g as getMetadataSize, gt as VXJSONFile, h as getCurrentISODate, ht as UpdateResult, i as ValidationResult, it as LocaleFileData, j as Blocks, k as ComponentEntryWithId, l as updatePublishDates, lt as LocalizedManifest, m as generateContentId, mt as UpdateLocaleInput, n as UPDATE_SCOPE, nt as FindOptions, o as buildLocaleVersion, ot as LocaleUpdateData, p as formatFileSize, pt as SitesConfig, q as ContentType, r as UpdateScope, rt as GlobalFilters, s as buildPathnameHistory, st as LocaleVersion, t as CreateValidationResult, tt as ErrorCodes, u as validateAndPrepareMetadata, ut as MDXFrontmatter, v as isMetadataTooLarge, vt as AssetEntry, w as normalizePathname, x as localesOf, xt as FolderListing, y as isValidBlockName, yt as AssetManifestData, z as ContentAPIOptions } from "./content-operations-CydU4aAl.mjs";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import * as hono_types0 from "hono/types";
|
|
4
|
+
import { Plugin } from "vite";
|
|
5
|
+
|
|
6
|
+
//#region src/asset-manifest.d.ts
|
|
7
|
+
declare class AssetManifest {
|
|
8
|
+
private manifestPath;
|
|
9
|
+
constructor(assetsPath: string);
|
|
10
|
+
read(): Promise<AssetManifestData>;
|
|
11
|
+
write(data: AssetManifestData): Promise<void>;
|
|
12
|
+
add(relativePath: string, data: ManifestEntryData): Promise<void>;
|
|
13
|
+
remove(relativePath: string): Promise<boolean>;
|
|
14
|
+
get(relativePath: string): Promise<ManifestEntryData | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Backward compat helper: search manifest keys for entry ending with /filename or equal to filename
|
|
17
|
+
* Useful during transition when only filename is known (not full relative path)
|
|
18
|
+
*/
|
|
19
|
+
getByFilename(filename: string): Promise<{
|
|
20
|
+
relativePath: string;
|
|
21
|
+
data: ManifestEntryData;
|
|
22
|
+
} | undefined>;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/asset-operations.d.ts
|
|
26
|
+
interface AssetConfig {
|
|
27
|
+
assetsPath: string;
|
|
28
|
+
maxFileSize?: number;
|
|
29
|
+
acceptedFormats?: string[];
|
|
30
|
+
/** Content root directory for usage tracking (scanning VXJSON files) */
|
|
31
|
+
contentRoot?: string;
|
|
32
|
+
}
|
|
33
|
+
declare class AssetOperations {
|
|
34
|
+
private config;
|
|
35
|
+
private manifest;
|
|
36
|
+
private dirEnsured;
|
|
37
|
+
private lfsSetup;
|
|
38
|
+
constructor(config: AssetConfig);
|
|
39
|
+
private ensureDir;
|
|
40
|
+
/**
|
|
41
|
+
* Validate that a subpath is safe (no path traversal attacks)
|
|
42
|
+
* Returns the resolved full path if valid, throws if invalid
|
|
43
|
+
*/
|
|
44
|
+
private validateSubpath;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a unique filename by appending -1, -2, etc. if collision exists
|
|
47
|
+
* @param originalName Original filename
|
|
48
|
+
* @param folder Optional folder path (relative to assets root)
|
|
49
|
+
*/
|
|
50
|
+
private resolveFilename;
|
|
51
|
+
private validateFormat;
|
|
52
|
+
private validateSize;
|
|
53
|
+
/**
|
|
54
|
+
* Get image dimensions from manifest cache or by reading file headers
|
|
55
|
+
*/
|
|
56
|
+
private getDimensions;
|
|
57
|
+
/**
|
|
58
|
+
* Build an AssetEntry from a directory entry, enriching with manifest metadata
|
|
59
|
+
*/
|
|
60
|
+
private buildAssetEntry;
|
|
61
|
+
upload(file: File, metadata?: {
|
|
62
|
+
alt?: string;
|
|
63
|
+
uploadedBy?: string;
|
|
64
|
+
width?: number;
|
|
65
|
+
height?: number;
|
|
66
|
+
folder?: string;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
success: true;
|
|
69
|
+
asset: AssetEntry;
|
|
70
|
+
} | {
|
|
71
|
+
success: false;
|
|
72
|
+
error: string;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* List all assets recursively from filesystem
|
|
76
|
+
*/
|
|
77
|
+
list(): Promise<AssetEntry[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Get asset by filename and optional folder
|
|
80
|
+
*/
|
|
81
|
+
getAsset(filename: string, folder?: string): Promise<AssetEntry | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete asset file and manifest entry
|
|
84
|
+
*/
|
|
85
|
+
delete(filename: string, folder?: string): Promise<{
|
|
86
|
+
success: true;
|
|
87
|
+
} | {
|
|
88
|
+
success: false;
|
|
89
|
+
error: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Import an image from a URL (server-side fetch, no CORS issues)
|
|
93
|
+
*/
|
|
94
|
+
importFromUrl(url: string, metadata?: {
|
|
95
|
+
alt?: string;
|
|
96
|
+
uploadedBy?: string;
|
|
97
|
+
folder?: string;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
success: true;
|
|
100
|
+
asset: AssetEntry;
|
|
101
|
+
} | {
|
|
102
|
+
success: false;
|
|
103
|
+
error: string;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* List assets and subfolders within a folder (filesystem-first)
|
|
107
|
+
* @param subpath Folder path relative to assets root (default '/')
|
|
108
|
+
*/
|
|
109
|
+
listFolder(subpath?: string): Promise<FolderListing>;
|
|
110
|
+
/**
|
|
111
|
+
* Create a folder on disk
|
|
112
|
+
* @param subpath Folder path relative to assets root
|
|
113
|
+
*/
|
|
114
|
+
createFolder(subpath: string): Promise<{
|
|
115
|
+
success: true;
|
|
116
|
+
} | {
|
|
117
|
+
success: false;
|
|
118
|
+
error: string;
|
|
119
|
+
}>;
|
|
120
|
+
/**
|
|
121
|
+
* Update asset metadata (alt text, tags)
|
|
122
|
+
* @param filename Asset filename
|
|
123
|
+
* @param updates Metadata updates (alt, tags)
|
|
124
|
+
* @param folder Optional folder path (default '/')
|
|
125
|
+
*/
|
|
126
|
+
updateMetadata(filename: string, updates: Partial<ManifestEntryData>, folder?: string): Promise<{
|
|
127
|
+
success: true;
|
|
128
|
+
asset: AssetEntry;
|
|
129
|
+
} | {
|
|
130
|
+
success: false;
|
|
131
|
+
error: string;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Get usage information for an asset (which pages reference it)
|
|
135
|
+
* @param filename Asset filename
|
|
136
|
+
*/
|
|
137
|
+
getUsage(filename: string): Promise<AssetUsage[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Get the file path for an asset
|
|
140
|
+
* @param filename Asset filename
|
|
141
|
+
* @param folder Optional folder path (defaults to asset's stored folder)
|
|
142
|
+
*/
|
|
143
|
+
getAssetPath(filename: string, folder?: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* Read asset file contents for serving (filesystem-first)
|
|
146
|
+
* @param filename Asset filename
|
|
147
|
+
* @param folder Optional folder path (default '/')
|
|
148
|
+
*/
|
|
149
|
+
readAssetFile(filename: string, folder?: string): Promise<{
|
|
150
|
+
success: true;
|
|
151
|
+
buffer: Buffer;
|
|
152
|
+
mimeType: string;
|
|
153
|
+
} | {
|
|
154
|
+
success: false;
|
|
155
|
+
error: string;
|
|
156
|
+
}>;
|
|
157
|
+
/**
|
|
158
|
+
* Helper to find which field contains an asset reference
|
|
159
|
+
*/
|
|
160
|
+
private findFieldWithAsset;
|
|
161
|
+
/**
|
|
162
|
+
* Move assets from one folder to another
|
|
163
|
+
* @param filenames List of filenames to move
|
|
164
|
+
* @param sourceFolder Source folder path (relative to assets root)
|
|
165
|
+
* @param targetFolder Target folder path (relative to assets root)
|
|
166
|
+
*/
|
|
167
|
+
moveAssets(filenames: string[], sourceFolder: string, targetFolder: string): Promise<{
|
|
168
|
+
success: true;
|
|
169
|
+
moved: number;
|
|
170
|
+
} | {
|
|
171
|
+
success: false;
|
|
172
|
+
error: string;
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* Get the complete folder tree with asset counts
|
|
176
|
+
* @returns Array of folder tree nodes representing the folder hierarchy
|
|
177
|
+
*/
|
|
178
|
+
getFolderTree(): Promise<FolderTreeNode[]>;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/cf-access.d.ts
|
|
182
|
+
/**
|
|
183
|
+
* Cloudflare Access JWT validation utility
|
|
184
|
+
*
|
|
185
|
+
* Validates JWT tokens from CF Access for API authorization and git commit attribution.
|
|
186
|
+
* When CF_ACCESS_TEAM_NAME and CF_ACCESS_AUD env vars are set, requests must have valid tokens.
|
|
187
|
+
* When env vars are not set (local dev), validation is skipped.
|
|
188
|
+
*/
|
|
189
|
+
interface CFAccessUser {
|
|
190
|
+
email: string;
|
|
191
|
+
sub: string;
|
|
192
|
+
}
|
|
193
|
+
interface CFAccessResult {
|
|
194
|
+
valid: boolean;
|
|
195
|
+
required: boolean;
|
|
196
|
+
user?: CFAccessUser;
|
|
197
|
+
error?: string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Extract CF Access JWT token from request.
|
|
201
|
+
* Checks Cf-Access-Jwt-Assertion header first, falls back to CF_Authorization cookie.
|
|
202
|
+
*/
|
|
203
|
+
declare function extractCFAccessToken(request: Request): string | null;
|
|
204
|
+
/**
|
|
205
|
+
* Validate CF Access JWT from request.
|
|
206
|
+
*
|
|
207
|
+
* Returns { valid: true, required: false } when env vars not set (local dev mode).
|
|
208
|
+
* Returns { valid: true, required: true, user } when token is valid.
|
|
209
|
+
* Returns { valid: false, required: true, error } when token is invalid or missing.
|
|
210
|
+
*/
|
|
211
|
+
declare function validateCFAccessRequest(request: Request): Promise<CFAccessResult>;
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/component-registry.d.ts
|
|
214
|
+
/**
|
|
215
|
+
* Component Registry for managing linked and unlinked components
|
|
216
|
+
*
|
|
217
|
+
* Registry is stored at {canvasDir}/components/registry.json
|
|
218
|
+
* Component IDs must follow the format: vx-{uuid}
|
|
219
|
+
*/
|
|
220
|
+
declare class ComponentRegistry {
|
|
221
|
+
private registryPath;
|
|
222
|
+
private registry;
|
|
223
|
+
private initialized;
|
|
224
|
+
constructor(canvasDir: string);
|
|
225
|
+
/**
|
|
226
|
+
* Initialize the registry by loading from disk or creating new
|
|
227
|
+
*/
|
|
228
|
+
initialize(): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Validate component ID format (vx-{uuid})
|
|
231
|
+
*/
|
|
232
|
+
private validateComponentId;
|
|
233
|
+
/**
|
|
234
|
+
* Save registry to disk atomically
|
|
235
|
+
*/
|
|
236
|
+
private save;
|
|
237
|
+
/**
|
|
238
|
+
* Register a new component or update existing
|
|
239
|
+
*/
|
|
240
|
+
register(id: string, entry: ComponentEntry): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Get a component entry by ID
|
|
243
|
+
*/
|
|
244
|
+
get(id: string): Promise<ComponentEntry | null>;
|
|
245
|
+
/**
|
|
246
|
+
* Link a component to a path
|
|
247
|
+
*/
|
|
248
|
+
link(id: string, path: string): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Unlink a component (set path to null)
|
|
251
|
+
*/
|
|
252
|
+
unlink(id: string): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* List all components
|
|
255
|
+
*/
|
|
256
|
+
list(): Promise<ComponentEntryWithId[]>;
|
|
257
|
+
/**
|
|
258
|
+
* Delete a component from registry
|
|
259
|
+
*/
|
|
260
|
+
delete(id: string): Promise<void>;
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/filesystem-content-api.d.ts
|
|
264
|
+
interface ReindexResult {
|
|
265
|
+
filesProcessed: number;
|
|
266
|
+
filesSkipped: number;
|
|
267
|
+
filesDeleted?: number;
|
|
268
|
+
errors?: number;
|
|
269
|
+
updated: LocalizedManifest[];
|
|
270
|
+
deleted?: Array<{
|
|
271
|
+
id: string;
|
|
272
|
+
locale: string;
|
|
273
|
+
kind: 'page' | 'block' | 'data';
|
|
274
|
+
}>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* FileSystem-based Content API Implementation
|
|
278
|
+
*
|
|
279
|
+
* Stores content as files on disk in a git-friendly format:
|
|
280
|
+
* - Pages: /{site}/pages/{filename}.{locale}.vxjson
|
|
281
|
+
* - Blocks: /blocks/{collection}/{filename}.{locale}.{mdx|vxjson}
|
|
282
|
+
*
|
|
283
|
+
* ## Indexing
|
|
284
|
+
*
|
|
285
|
+
* Content is indexed at startup for performance. The index is cached per
|
|
286
|
+
* content root path and cleared when the process restarts.
|
|
287
|
+
*
|
|
288
|
+
* ## Read-Repair
|
|
289
|
+
*
|
|
290
|
+
* Since files can be modified externally (git, editors), this implementation:
|
|
291
|
+
*
|
|
292
|
+
* 1. Repairs invalid VXJSON files (ensures "content" field is last)
|
|
293
|
+
* 2. Adds missing required fields (id, created, modified)
|
|
294
|
+
* 3. Handles files added after initial indexing
|
|
295
|
+
* 4. Updates the index when files are repaired or discovered
|
|
296
|
+
*
|
|
297
|
+
* ## Performance
|
|
298
|
+
*
|
|
299
|
+
* - Initial indexing reads only first 4KB of each file
|
|
300
|
+
* - Full content is loaded on demand
|
|
301
|
+
* - ETags are calculated using streaming for efficiency
|
|
302
|
+
*/
|
|
303
|
+
declare class FileSystemContentAPI implements ContentAPI {
|
|
304
|
+
private contentRoot;
|
|
305
|
+
private absoluteContentRoot;
|
|
306
|
+
private contentIndex;
|
|
307
|
+
readonly sitesConfig: SitesConfig;
|
|
308
|
+
readonly blocks: Blocks;
|
|
309
|
+
readonly data: Data;
|
|
310
|
+
private readonly sites;
|
|
311
|
+
get normalizedContentRoot(): string;
|
|
312
|
+
private constructor();
|
|
313
|
+
static create(options: ContentAPIOptions): Promise<FileSystemContentAPI>;
|
|
314
|
+
/**
|
|
315
|
+
* Clear all caches - useful for testing
|
|
316
|
+
*/
|
|
317
|
+
static clearCaches(): void;
|
|
318
|
+
private indexAllContent;
|
|
319
|
+
private parseFileHeaderWithRepair;
|
|
320
|
+
/**
|
|
321
|
+
* Perform read-repair by writing back the file with missing fields
|
|
322
|
+
* This ensures stable IDs and timestamps across restarts
|
|
323
|
+
*/
|
|
324
|
+
private performReadRepair;
|
|
325
|
+
private scanContentFiles;
|
|
326
|
+
private getFilePath;
|
|
327
|
+
/**
|
|
328
|
+
* Parse a file path back into its components for checking against the path index
|
|
329
|
+
* Returns null if the path doesn't match expected patterns
|
|
330
|
+
*/
|
|
331
|
+
parseFilePath(filePath: string): {
|
|
332
|
+
kind: 'page' | 'block' | 'data';
|
|
333
|
+
site?: string;
|
|
334
|
+
collection: string;
|
|
335
|
+
pathname?: string;
|
|
336
|
+
name?: string;
|
|
337
|
+
locale: string;
|
|
338
|
+
} | null;
|
|
339
|
+
getContent(id: string): Promise<ContentEntry | null>;
|
|
340
|
+
getLocalized(id: string, locale: string): Promise<LocalizedEntry | null>;
|
|
341
|
+
private readLocaleFile;
|
|
342
|
+
createContent(data: CreateContentInput): Promise<CreateResult>;
|
|
343
|
+
updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult>;
|
|
344
|
+
deleteContent(id: string, etag: string): Promise<DeleteResult>;
|
|
345
|
+
deleteLocalized(input: DeleteLocaleInput): Promise<DeleteResult>;
|
|
346
|
+
getSite(siteName: string): Site | null;
|
|
347
|
+
listAllContent(filters?: GlobalFilters): Generator<ContentManifest>;
|
|
348
|
+
findUntranslatedContent(targetLocale: string, options?: FindOptions): Generator<ContentManifest>;
|
|
349
|
+
/**
|
|
350
|
+
* Reindex files that were added or changed after initial creation
|
|
351
|
+
*
|
|
352
|
+
* This method:
|
|
353
|
+
* 1. Either scans for all content files or processes specific paths
|
|
354
|
+
* 2. Uses the path index to check if files are already indexed
|
|
355
|
+
* 3. Indexes new files or force-reindexes specified files
|
|
356
|
+
* 4. Optionally handles file deletions
|
|
357
|
+
*
|
|
358
|
+
* @param paths - Optional array of specific file paths to reindex. If not provided, scans all content files.
|
|
359
|
+
* @param options - Options for reindexing behavior
|
|
360
|
+
* @returns Statistics about the reindexing operation
|
|
361
|
+
*/
|
|
362
|
+
reindex(paths?: string[], options?: {
|
|
363
|
+
handleDeletions?: boolean;
|
|
364
|
+
}): Promise<ReindexResult>;
|
|
365
|
+
/**
|
|
366
|
+
* Read content directly from cache
|
|
367
|
+
* For testing purposes - returns null if not cached
|
|
368
|
+
*/
|
|
369
|
+
readFromCache(id: string, locale: string): Promise<ContentData | null>;
|
|
370
|
+
getContentAsBuffer(id: string, locale: string): Promise<{
|
|
371
|
+
buffer: Uint8Array;
|
|
372
|
+
etag: string;
|
|
373
|
+
contentType: 'application/json' | 'text/mdx';
|
|
374
|
+
} | null>;
|
|
375
|
+
batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult>;
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/content-watcher.d.ts
|
|
379
|
+
interface ContentWatcherOptions {
|
|
380
|
+
contentRoot: string;
|
|
381
|
+
canvasDir?: string;
|
|
382
|
+
}
|
|
383
|
+
interface WebSocketSender {
|
|
384
|
+
send(payload: {
|
|
385
|
+
type: string;
|
|
386
|
+
event: string;
|
|
387
|
+
data: any;
|
|
388
|
+
}): void;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Creates a content API instance for the given options
|
|
392
|
+
*/
|
|
393
|
+
declare function createContentAPI(options: ContentWatcherOptions): Promise<FileSystemContentAPI>;
|
|
394
|
+
/**
|
|
395
|
+
* Creates file change handlers for content watching
|
|
396
|
+
*/
|
|
397
|
+
declare function createContentWatchHandlers(contentApi: FileSystemContentAPI, options: ContentWatcherOptions, ws: WebSocketSender): {
|
|
398
|
+
onChange: (file: string) => Promise<void>;
|
|
399
|
+
onAdd: (file: string) => Promise<void>;
|
|
400
|
+
onUnlink: (file: string) => Promise<void>;
|
|
401
|
+
};
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/in-memory-content-api.d.ts
|
|
404
|
+
/**
|
|
405
|
+
* In-memory implementation of ContentAPI for testing
|
|
406
|
+
* Provides a clean, mock-free way to test the API without filesystem dependencies
|
|
407
|
+
*/
|
|
408
|
+
declare class InMemoryContentAPI implements ContentAPI {
|
|
409
|
+
private contentIndex;
|
|
410
|
+
readonly sitesConfig: SitesConfig;
|
|
411
|
+
readonly blocks: Blocks;
|
|
412
|
+
readonly data: Data;
|
|
413
|
+
private readonly sites;
|
|
414
|
+
constructor(sitesConfig?: SitesConfig);
|
|
415
|
+
getContent(id: string): Promise<ContentEntry | null>;
|
|
416
|
+
getLocalized(id: string, locale: string): Promise<LocalizedEntry | null>;
|
|
417
|
+
createContent(data: CreateContentInput): Promise<CreateResult>;
|
|
418
|
+
updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult>;
|
|
419
|
+
deleteContent(id: string, etag: string): Promise<DeleteResult>;
|
|
420
|
+
getSite(siteName: string): Site | null;
|
|
421
|
+
listAllContent(filters?: GlobalFilters): Generator<ContentManifest>;
|
|
422
|
+
findUntranslatedContent(targetLocale: string, options?: FindOptions): Generator<ContentManifest>;
|
|
423
|
+
deleteLocalized(input: DeleteLocaleInput): Promise<DeleteResult>;
|
|
424
|
+
batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult>;
|
|
425
|
+
setContent(id: string, content: ContentEntry): void;
|
|
426
|
+
clear(): void;
|
|
427
|
+
getContentAsBuffer(id: string, locale: string): Promise<{
|
|
428
|
+
buffer: Uint8Array;
|
|
429
|
+
etag: string;
|
|
430
|
+
contentType: 'application/json' | 'text/mdx';
|
|
431
|
+
} | null>;
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/middleware.d.ts
|
|
435
|
+
/**
|
|
436
|
+
* Create REST API router using Hono
|
|
437
|
+
* Implements the ID-based API specification from implementation-plan.md
|
|
438
|
+
*/
|
|
439
|
+
interface ContentAPIRouterOptions {
|
|
440
|
+
assetsPath?: string;
|
|
441
|
+
assetConfig?: Omit<AssetConfig, 'assetsPath'>;
|
|
442
|
+
/** Content root directory for asset usage tracking */
|
|
443
|
+
contentRoot?: string;
|
|
444
|
+
}
|
|
445
|
+
declare function createContentAPIRouter(api: ContentAPI, options?: ContentAPIRouterOptions): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
|
|
446
|
+
/**
|
|
447
|
+
* Create middleware for backwards compatibility with existing code
|
|
448
|
+
* This wraps the Hono app to work with Node.js IncomingMessage/ServerResponse
|
|
449
|
+
*/
|
|
450
|
+
declare function createContentMiddleware(contentApi: ContentAPI): (req: any, res: any, next: () => void) => Promise<void>;
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/vite-plugin.d.ts
|
|
453
|
+
interface ConlocaContentOptions {
|
|
454
|
+
contentRoot: string;
|
|
455
|
+
canvasDir?: string;
|
|
456
|
+
basePath?: string;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Vite plugin wrapper for content middleware
|
|
460
|
+
* This follows the spec in 04-cms-api.md and 09-conloca-content-editing.md
|
|
461
|
+
*/
|
|
462
|
+
declare function conlocaContent(options: ConlocaContentOptions): Plugin;
|
|
463
|
+
//#endregion
|
|
464
|
+
export { APIError, type AssetConfig, type AssetEntry, AssetManifest, type AssetManifestData, AssetOperations, BatchOperationResult, BatchResult, BlockFilters, Blocks, type CFAccessResult, type CFAccessUser, ComponentEntry, ComponentEntryWithId, ComponentRegistry, type ConlocaContentOptions, type ContentAPI, ContentAPIOptions, ContentData, ContentEntry, ContentIdentity, ContentListResult, ContentManifest, ContentMeta, ContentProp, ContentType, type ContentWatcherOptions, CreateBlockInput, CreateContentInput, CreatePageInput, CreateResult, CreateValidationResult, DeleteLocaleInput, DeleteResult, ErrorCode, ErrorCodes, FileSystemContentAPI, FindOptions, GlobalFilters, InMemoryContentAPI, LocaleFileData, LocalePathData, LocaleUpdateData, LocaleVersion, LocalizedEntry, LocalizedManifest, MDXFrontmatter, MoveResult, Site, SiteFilters, SitesConfig, UPDATE_SCOPE, UpdateLocaleInput, UpdateResult, UpdateScope, VXJSONFile, ValidationResult, type WebSocketSender, WriteResult, analyzeUpdateScope, buildLocaleVersion, buildPathnameHistory, conlocaContent, createContentAPI, createContentAPIRouter, createContentMiddleware, createContentWatchHandlers, extractBlockName, extractCFAccessToken, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, normalizePathname, parseDate, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCFAccessRequest, validateCreateContent };
|
|
465
|
+
//# sourceMappingURL=node.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.mts","names":[],"sources":["../src/asset-manifest.ts","../src/asset-operations.ts","../src/cf-access.ts","../src/component-registry.ts","../src/filesystem-content-api.ts","../src/content-watcher.ts","../src/in-memory-content-api.ts","../src/middleware.ts","../src/vite-plugin.ts"],"sourcesContent":[],"mappings":";;;;;;cAiBa,aAAA;;;UAOG,QAAQ;EAPX,KAAA,CAAA,IAAA,EAgBO,iBAhBM,CAAA,EAgBc,OAhBd,CAAA,IAAA,CAAA;EAOF,GAAA,CAAA,YAAA,EAAA,MAAA,EAAA,IAAA,EAagB,iBAbhB,CAAA,EAaoC,OAbpC,CAAA,IAAA,CAAA;EAAR,MAAA,CAAA,YAAA,EAAA,MAAA,CAAA,EAmBsB,OAnBtB,CAAA,OAAA,CAAA;EASI,GAAA,CAAA,YAAA,EAAA,MAAA,CAAA,EAkBe,OAlBf,CAkBuB,iBAlBvB,GAAA,SAAA,CAAA;EAAoB;;;;EAkBG,aAAA,CAAA,QAAA,EAAA,MAAA,CAAA,EASF,OATE,CAAA;IAAR,YAAA,EAAA,MAAA;IAS4C,IAAA,EAAA,iBAAA;EAAtC,CAAA,GAAA,SAAA,CAAA;;;;UC7CxB,WAAA;;;;;EDEJ,WAAA,CAAA,EAAA,MAAa;;AAOV,cC8BH,eAAA,CD9BG;EASI,QAAA,MAAA;EAAoB,QAAA,QAAA;EAIA,QAAA,UAAA;EAAoB,QAAA,QAAA;EAMtB,WAAA,CAAA,MAAA,ECiBhB,WDjBgB;EAQK,QAAA,SAAA;EAAR;;;;;;;ACpCnC;AAuCA;;EAmJU,QAAA,eAAA;EAE2B,QAAA,cAAA;EAAhC,QAAA,YAAA;EAkFmB;;;EAyC0B,QAAA,aAAA;EAoDF;;;EAoDL,QAAA,eAAA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