@conloca/content-api 0.1.15 → 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-CBGONnYn.d.mts → component-registry.types-C0ctF9nh.d.mts} +1 -1
- 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-Db1Iv9T0.mjs → data-DquNIEnQ.mjs} +4 -2
- package/dist/{data-Db1Iv9T0.mjs.map → data-DquNIEnQ.mjs.map} +1 -1
- 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-kxKY5IUw.mjs → filesystem-content-api-C0HIhqZi.mjs} +172 -1230
- package/dist/filesystem-content-api-C0HIhqZi.mjs.map +1 -0
- package/dist/{filesystem-content-api-C1TM0GLo.d.mts → filesystem-content-api-DCdNi-co.d.mts} +19 -4
- 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 -5
- 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 -6
- 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 +10 -15
- 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 +89 -135
- package/dist/node.mjs.map +1 -1
- package/dist/reader.d.mts +5 -8
- package/dist/reader.d.mts.map +1 -1
- 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 +8 -8
- package/dist/reader.mjs.map +1 -1
- 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/{site-vNtJ5jCh.mjs → site-8oaj1Q60.mjs} +21 -193
- 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-DWt912tu.mjs → types-DOdldbfD.mjs} +3 -2
- 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 +79 -17
- 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/filesystem-content-api-C1TM0GLo.d.mts.map +0 -1
- package/dist/filesystem-content-api-kxKY5IUw.mjs.map +0 -1
- package/dist/schemas/index.d.mts.map +0 -1
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/site-vNtJ5jCh.mjs.map +0 -1
- package/dist/types-DWt912tu.mjs.map +0 -1
package/dist/node.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { a as AssetManifestData, c as FolderTreeNode, i as AssetEntry, l as ManifestEntryData, n as ComponentEntryWithId, o as AssetUsage, s as FolderListing, t as ComponentEntry } from "./component-registry.types-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { a as AssetManifestData, c as FolderTreeNode, i as AssetEntry, l as ManifestEntryData, n as ComponentEntryWithId, o as AssetUsage, s as FolderListing, t as ComponentEntry } from "./component-registry.types-C0ctF9nh.mjs";
|
|
2
|
+
import { A as LocalizedEntry, B as VXJSONFile, C as ErrorCodes, D as LocalePathData, E as LocaleFileData, F as PageReference, I as SiteFilters, L as SitesConfig, M as MDXCompileResponse, N as MDXFrontmatter, O as LocaleUpdateData, P as MoveResult, R as UpdateLocaleInput, S as ErrorCode, T as GlobalFilters, V as WriteResult, _ as CreateResult, a as ContentAPIOptions, b as DeleteLocaleInput, c as ContentIdentity, d as ContentMeta, f as ContentProp, g as CreatePageInput, h as CreateContentInput, i as BlockFilters, j as LocalizedManifest, k as LocaleVersion, l as ContentListResult, m as CreateBlockInput, n as BatchOperationResult, o as ContentData, p as ContentType, r as BatchResult, s as ContentEntry, t as APIError, u as ContentManifest, v as DataCollectionEntry, w as FindOptions, x as DeleteResult, y as DataContext, z as UpdateResult } from "./types-DjfhS272.mjs";
|
|
3
|
+
import { A as serializeMdxWithFrontmatter, C as localesOf, D as normalizePathname, E as normalizeAndValidatePathname, M as ContentAPI, N as Site, O as parseDate, P as Data, S as isValidPathname, T as mapSiteNames, _ as getCurrentISODate, a as analyzeUpdateScope, b as isMetadataTooLarge, c as shouldUpdateModifiedTimestamp, d as validateCreateContent, f as PathnameValidationReason, g as generateContentId, h as formatFileSize, i as ValidationResult, j as Blocks, k as resolvePublishDate, l as updatePublishDates, m as extractBlockName, n as UPDATE_SCOPE, o as buildLocaleVersion, p as PathnameValidationResult, r as UpdateScope, s as buildPathnameHistory, t as CreateValidationResult, u as validateAndPrepareMetadata, v as getMetadataSize, w as mapLocales, x as isValidBlockName, y as isContentPublished } from "./content-operations-DIbsxG5A.mjs";
|
|
4
|
+
import { n as readSitesConfig, t as FileSystemContentAPI } from "./filesystem-content-api-DCdNi-co.mjs";
|
|
4
5
|
import { Hono } from "hono";
|
|
5
|
-
import * as hono_types0 from "hono/types";
|
|
6
6
|
import { Plugin } from "vite";
|
|
7
|
-
|
|
8
7
|
//#region src/asset-manifest.d.ts
|
|
9
8
|
declare class AssetManifest {
|
|
10
9
|
private manifestPath;
|
|
@@ -269,10 +268,7 @@ declare class ComponentRegistry {
|
|
|
269
268
|
}
|
|
270
269
|
//#endregion
|
|
271
270
|
//#region src/content-watcher.d.ts
|
|
272
|
-
|
|
273
|
-
contentRoot: string;
|
|
274
|
-
canvasDir?: string;
|
|
275
|
-
}
|
|
271
|
+
type ContentWatcherOptions = ContentAPIOptions;
|
|
276
272
|
interface WebSocketSender {
|
|
277
273
|
send(payload: {
|
|
278
274
|
type: string;
|
|
@@ -283,6 +279,8 @@ interface WebSocketSender {
|
|
|
283
279
|
interface ContentWatchEvent {
|
|
284
280
|
file: string;
|
|
285
281
|
action: 'update' | 'create' | 'delete';
|
|
282
|
+
inMdxRoot: boolean;
|
|
283
|
+
inContentRoot: boolean;
|
|
286
284
|
}
|
|
287
285
|
interface ReindexResultLike {
|
|
288
286
|
updated: unknown[];
|
|
@@ -341,9 +339,6 @@ declare class InMemoryContentAPI implements ContentAPI {
|
|
|
341
339
|
} | null>;
|
|
342
340
|
}
|
|
343
341
|
//#endregion
|
|
344
|
-
//#region src/mdx/compile.d.ts
|
|
345
|
-
declare function compileMDX(content: string): Promise<MDXCompileResponse>;
|
|
346
|
-
//#endregion
|
|
347
342
|
//#region src/middleware.d.ts
|
|
348
343
|
/**
|
|
349
344
|
* Create REST API router using Hono
|
|
@@ -355,12 +350,12 @@ interface ContentAPIRouterOptions {
|
|
|
355
350
|
/** Content root directory for asset usage tracking */
|
|
356
351
|
contentRoot?: string;
|
|
357
352
|
}
|
|
358
|
-
declare function createContentAPIRouter(api: ContentAPI, options?: ContentAPIRouterOptions): Hono<
|
|
353
|
+
declare function createContentAPIRouter(api: ContentAPI, options?: ContentAPIRouterOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
359
354
|
/**
|
|
360
355
|
* Create middleware for backwards compatibility with existing code
|
|
361
356
|
* This wraps the Hono app to work with Node.js IncomingMessage/ServerResponse
|
|
362
357
|
*/
|
|
363
|
-
declare function createContentMiddleware(contentApi: ContentAPI): (req: any, res: any, next: () => void) => Promise<void>;
|
|
358
|
+
declare function createContentMiddleware(contentApi: ContentAPI, options?: ContentAPIRouterOptions): (req: any, res: any, next: () => void) => Promise<void>;
|
|
364
359
|
//#endregion
|
|
365
360
|
//#region src/vite-plugin.d.ts
|
|
366
361
|
interface ConlocaContentOptions {
|
|
@@ -374,5 +369,5 @@ interface ConlocaContentOptions {
|
|
|
374
369
|
*/
|
|
375
370
|
declare function conlocaContent(options: ConlocaContentOptions): Plugin;
|
|
376
371
|
//#endregion
|
|
377
|
-
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, DataCollectionEntry, DataContext, DeleteLocaleInput, DeleteResult, ErrorCode, ErrorCodes, FileSystemContentAPI, FindOptions, GlobalFilters, InMemoryContentAPI, LocaleFileData, LocalePathData, LocaleUpdateData, LocaleVersion, LocalizedEntry, LocalizedManifest, MDXCompileResponse, MDXFrontmatter, MoveResult, PageReference, Site, SiteFilters, SitesConfig, UPDATE_SCOPE, UpdateLocaleInput, UpdateResult, UpdateScope, VXJSONFile, ValidationResult, type WebSocketSender, WriteResult, analyzeUpdateScope, buildLocaleVersion, buildPathnameHistory,
|
|
372
|
+
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, DataCollectionEntry, DataContext, DeleteLocaleInput, DeleteResult, ErrorCode, ErrorCodes, FileSystemContentAPI, FindOptions, GlobalFilters, InMemoryContentAPI, LocaleFileData, LocalePathData, LocaleUpdateData, LocaleVersion, LocalizedEntry, LocalizedManifest, MDXCompileResponse, MDXFrontmatter, MoveResult, PageReference, PathnameValidationReason, PathnameValidationResult, 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, normalizeAndValidatePathname, normalizePathname, parseDate, readSitesConfig, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCFAccessRequest, validateCreateContent };
|
|
378
373
|
//# sourceMappingURL=node.d.mts.map
|
package/dist/node.d.mts.map
CHANGED
|
@@ -1 +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/content-watcher.ts","../src/in-memory-content-api.ts","../src/
|
|
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/content-watcher.ts","../src/in-memory-content-api.ts","../src/middleware.ts","../src/vite-plugin.ts"],"mappings":"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"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js-specific exports for @conloca/content-api
|
|
3
|
+
*
|
|
4
|
+
* These exports require Node.js runtime APIs and should not be imported in browser environments.
|
|
5
|
+
* Use the main package exports for browser-compatible APIs.
|
|
6
|
+
*/
|
|
7
|
+
export { type AssetEntry, AssetManifest, type AssetManifestData } from './asset-manifest';
|
|
8
|
+
export { type AssetConfig, AssetOperations } from './asset-operations';
|
|
9
|
+
export { Blocks } from './blocks';
|
|
10
|
+
export { type CFAccessResult, type CFAccessUser, extractCFAccessToken, validateCFAccessRequest, } from './cf-access.js';
|
|
11
|
+
export { ComponentRegistry } from './component-registry';
|
|
12
|
+
export * from './component-registry.types';
|
|
13
|
+
export type { ContentAPI } from './content-api.interface';
|
|
14
|
+
export * from './content-operations';
|
|
15
|
+
export * from './content-utils';
|
|
16
|
+
export type { ContentWatcherOptions, WebSocketSender } from './content-watcher';
|
|
17
|
+
export { createContentAPI, createContentWatchHandlers } from './content-watcher';
|
|
18
|
+
export { FileSystemContentAPI, readSitesConfig } from './filesystem-content-api';
|
|
19
|
+
export { InMemoryContentAPI } from './in-memory-content-api';
|
|
20
|
+
export { createContentAPIRouter, createContentMiddleware } from './middleware';
|
|
21
|
+
export { Site } from './site';
|
|
22
|
+
export * from './types';
|
|
23
|
+
export type { ConlocaContentOptions } from './vite-plugin';
|
|
24
|
+
export { conlocaContent } from './vite-plugin';
|
|
25
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,KAAK,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js-specific exports for @conloca/content-api
|
|
3
|
+
*
|
|
4
|
+
* These exports require Node.js runtime APIs and should not be imported in browser environments.
|
|
5
|
+
* Use the main package exports for browser-compatible APIs.
|
|
6
|
+
*/
|
|
7
|
+
export { AssetManifest } from './asset-manifest';
|
|
8
|
+
export { AssetOperations } from './asset-operations';
|
|
9
|
+
export { Blocks } from './blocks';
|
|
10
|
+
// CF Access authentication
|
|
11
|
+
export { extractCFAccessToken, validateCFAccessRequest, } from './cf-access.js';
|
|
12
|
+
export { ComponentRegistry } from './component-registry';
|
|
13
|
+
export * from './component-registry.types';
|
|
14
|
+
export * from './content-operations';
|
|
15
|
+
export * from './content-utils';
|
|
16
|
+
export { createContentAPI, createContentWatchHandlers } from './content-watcher';
|
|
17
|
+
// Node.js specific implementations (require fs, xxhash, etc.)
|
|
18
|
+
export { FileSystemContentAPI, readSitesConfig } from './filesystem-content-api';
|
|
19
|
+
export { InMemoryContentAPI } from './in-memory-content-api';
|
|
20
|
+
export { createContentAPIRouter, createContentMiddleware } from './middleware';
|
|
21
|
+
export { Site } from './site';
|
|
22
|
+
// Re-export types and utilities that are safe for Node.js environments
|
|
23
|
+
export * from './types';
|
|
24
|
+
export { conlocaContent } from './vite-plugin';
|
package/dist/node.mjs
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
1
|
+
import { a as buildPathnameHistory, c as validateAndPrepareMetadata, i as buildLocaleVersion, l as validateCreateContent, n as UPDATE_SCOPE, o as shouldUpdateModifiedTimestamp, r as analyzeUpdateScope, s as updatePublishDates, t as Site, u as Blocks } from "./site-8oaj1Q60.mjs";
|
|
2
|
+
import { _ as serializeMdxWithFrontmatter, a as getMetadataSize, c as isValidBlockName, d as mapLocales, f as mapSiteNames, g as resolvePublishDate, h as parseDate, i as getCurrentISODate, l as isValidPathname, m as normalizePathname, n as formatFileSize, o as isContentPublished, p as normalizeAndValidatePathname, r as generateContentId, s as isMetadataTooLarge, t as extractBlockName, u as localesOf } from "./content-utils-fWNHTrPy.mjs";
|
|
3
|
+
import { t as ContentIndex } from "./content-index-D092_vk1.mjs";
|
|
4
|
+
import { t as ErrorCodes } from "./types-DOdldbfD.mjs";
|
|
5
|
+
import { n as calculateEtagsFromMdxBuffer, r as findMdxContentStartPosition, t as VXJSON } from "./vxjson-qHrgLGip.mjs";
|
|
6
|
+
import { i as atomicWriteFile, n as readSitesConfig, r as filterContentWithIndexes, t as FileSystemContentAPI } from "./filesystem-content-api-C0HIhqZi.mjs";
|
|
7
|
+
import { t as Data } from "./data-DquNIEnQ.mjs";
|
|
5
8
|
import sortKeys from "sort-keys";
|
|
6
9
|
import { access, mkdir, readFile, readdir, rename, stat, unlink, writeFile } from "node:fs/promises";
|
|
7
10
|
import { dirname, extname, join, normalize, parse, resolve } from "node:path";
|
|
8
11
|
import { imageSize } from "image-size";
|
|
9
12
|
import { spawn } from "node:child_process";
|
|
10
13
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
11
|
-
import matter from "gray-matter";
|
|
12
|
-
import { compile } from "@mdx-js/mdx";
|
|
13
|
-
import remarkFrontmatter from "remark-frontmatter";
|
|
14
|
-
import remarkGfm from "remark-gfm";
|
|
15
|
-
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
16
14
|
import { Hono } from "hono";
|
|
17
15
|
import { cors } from "hono/cors";
|
|
18
16
|
import { getRequestListener } from "@hono/node-server";
|
|
19
|
-
|
|
20
17
|
//#region src/asset-manifest.ts
|
|
21
18
|
const MANIFEST_FILENAME = ".asset-manifest.json";
|
|
22
19
|
var AssetManifest = class {
|
|
@@ -81,7 +78,6 @@ var AssetManifest = class {
|
|
|
81
78
|
};
|
|
82
79
|
}
|
|
83
80
|
};
|
|
84
|
-
|
|
85
81
|
//#endregion
|
|
86
82
|
//#region src/git-operations.ts
|
|
87
83
|
function runGitCommand(cwd, args) {
|
|
@@ -371,14 +367,13 @@ async function setupGitLfsAttributes(contentRoot) {
|
|
|
371
367
|
if (missingPatterns.length === 0) return;
|
|
372
368
|
await writeFile(gitattributesPath, existing ? `${existing.trimEnd()}\n${missingPatterns.join("\n")}\n` : `${missingPatterns.join("\n")}\n`, "utf-8");
|
|
373
369
|
}
|
|
374
|
-
|
|
375
370
|
//#endregion
|
|
376
371
|
//#region src/url-validation.ts
|
|
377
372
|
/**
|
|
378
373
|
* URL validation for SSRF prevention in server-side fetch operations.
|
|
379
374
|
* Blocks private/reserved IP addresses and non-http(s) schemes.
|
|
380
375
|
*/
|
|
381
|
-
const BLOCKED_HOSTNAMES = new Set(["localhost"]);
|
|
376
|
+
const BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set(["localhost"]);
|
|
382
377
|
/** Check if an IPv4 address string points to a private/reserved range */
|
|
383
378
|
function isPrivateIPv4(hostname) {
|
|
384
379
|
const parts = hostname.split(".");
|
|
@@ -420,7 +415,6 @@ function validateFetchUrl(url) {
|
|
|
420
415
|
if (isPrivateIPv6(hostname)) throw new Error("URL points to a private/reserved IP address");
|
|
421
416
|
return parsed;
|
|
422
417
|
}
|
|
423
|
-
|
|
424
418
|
//#endregion
|
|
425
419
|
//#region src/asset-operations.ts
|
|
426
420
|
const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
@@ -445,7 +439,7 @@ const MIME_MAP = {
|
|
|
445
439
|
ico: "image/x-icon"
|
|
446
440
|
};
|
|
447
441
|
/** Recognized web image extensions for filesystem scanning */
|
|
448
|
-
const RECOGNIZED_IMAGE_EXTENSIONS = new Set([
|
|
442
|
+
const RECOGNIZED_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
449
443
|
"jpg",
|
|
450
444
|
"jpeg",
|
|
451
445
|
"png",
|
|
@@ -456,7 +450,7 @@ const RECOGNIZED_IMAGE_EXTENSIONS = new Set([
|
|
|
456
450
|
"ico"
|
|
457
451
|
]);
|
|
458
452
|
/** System files to skip during filesystem scanning */
|
|
459
|
-
const SYSTEM_FILES = new Set([
|
|
453
|
+
const SYSTEM_FILES = /* @__PURE__ */ new Set([
|
|
460
454
|
".ds_store",
|
|
461
455
|
"thumbs.db",
|
|
462
456
|
".gitkeep",
|
|
@@ -664,8 +658,10 @@ var AssetOperations = class {
|
|
|
664
658
|
for (const entry of entries) {
|
|
665
659
|
if (isSystemFile(entry.name) || entry.isSymbolicLink()) continue;
|
|
666
660
|
const entryPath = join(folderPath, entry.name);
|
|
667
|
-
if (entry.isDirectory())
|
|
668
|
-
|
|
661
|
+
if (entry.isDirectory()) {
|
|
662
|
+
const subFolder = folder === "/" ? `/${entry.name}` : `${folder}/${entry.name}`;
|
|
663
|
+
await scanFolder(entryPath, subFolder);
|
|
664
|
+
} else if (entry.isFile() && isRecognizedImageExtension(entry.name)) {
|
|
669
665
|
const assetEntry = await this.buildAssetEntry(entry, folder, manifestData);
|
|
670
666
|
assets.push(assetEntry);
|
|
671
667
|
}
|
|
@@ -678,9 +674,9 @@ var AssetOperations = class {
|
|
|
678
674
|
* Get asset by filename and optional folder
|
|
679
675
|
*/
|
|
680
676
|
async getAsset(filename, folder = "/") {
|
|
681
|
-
|
|
682
|
-
const relativePath =
|
|
683
|
-
const fullPath = this.getAssetPath(filename,
|
|
677
|
+
const resolvedFolder = folder === "/" ? await this.resolveFolder(filename) : folder;
|
|
678
|
+
const relativePath = resolvedFolder === "/" ? filename : `${resolvedFolder.slice(1)}/${filename}`;
|
|
679
|
+
const fullPath = this.getAssetPath(filename, resolvedFolder);
|
|
684
680
|
let stats;
|
|
685
681
|
try {
|
|
686
682
|
stats = await stat(fullPath);
|
|
@@ -707,7 +703,7 @@ var AssetOperations = class {
|
|
|
707
703
|
alt: manifestEntry?.alt,
|
|
708
704
|
uploadedAt: manifestEntry?.uploadedAt || stats.birthtime.toISOString(),
|
|
709
705
|
uploadedBy: manifestEntry?.uploadedBy,
|
|
710
|
-
folder,
|
|
706
|
+
folder: resolvedFolder,
|
|
711
707
|
tags: manifestEntry?.tags
|
|
712
708
|
};
|
|
713
709
|
}
|
|
@@ -715,9 +711,9 @@ var AssetOperations = class {
|
|
|
715
711
|
* Delete asset file and manifest entry
|
|
716
712
|
*/
|
|
717
713
|
async delete(filename, folder = "/") {
|
|
718
|
-
|
|
719
|
-
const relativePath =
|
|
720
|
-
const filePath = this.getAssetPath(filename,
|
|
714
|
+
const resolvedFolder = folder === "/" ? await this.resolveFolder(filename) : folder;
|
|
715
|
+
const relativePath = resolvedFolder === "/" ? filename : `${resolvedFolder.slice(1)}/${filename}`;
|
|
716
|
+
const filePath = this.getAssetPath(filename, resolvedFolder);
|
|
721
717
|
try {
|
|
722
718
|
await unlink(filePath);
|
|
723
719
|
} catch {}
|
|
@@ -833,9 +829,9 @@ var AssetOperations = class {
|
|
|
833
829
|
* @param folder Optional folder path (default '/')
|
|
834
830
|
*/
|
|
835
831
|
async updateMetadata(filename, updates, folder = "/") {
|
|
836
|
-
|
|
837
|
-
const relativePath =
|
|
838
|
-
const fullPath = this.getAssetPath(filename,
|
|
832
|
+
const resolvedFolder = folder === "/" ? await this.resolveFolder(filename) : folder;
|
|
833
|
+
const relativePath = resolvedFolder === "/" ? filename : `${resolvedFolder.slice(1)}/${filename}`;
|
|
834
|
+
const fullPath = this.getAssetPath(filename, resolvedFolder);
|
|
839
835
|
try {
|
|
840
836
|
await stat(fullPath);
|
|
841
837
|
} catch {
|
|
@@ -849,7 +845,7 @@ var AssetOperations = class {
|
|
|
849
845
|
...updates
|
|
850
846
|
};
|
|
851
847
|
await this.manifest.add(relativePath, merged);
|
|
852
|
-
const asset = await this.getAsset(filename,
|
|
848
|
+
const asset = await this.getAsset(filename, resolvedFolder);
|
|
853
849
|
if (!asset) return {
|
|
854
850
|
success: false,
|
|
855
851
|
error: "Failed to retrieve updated asset"
|
|
@@ -1078,7 +1074,6 @@ var AssetOperations = class {
|
|
|
1078
1074
|
}];
|
|
1079
1075
|
}
|
|
1080
1076
|
};
|
|
1081
|
-
|
|
1082
1077
|
//#endregion
|
|
1083
1078
|
//#region src/cf-access.ts
|
|
1084
1079
|
/**
|
|
@@ -1140,7 +1135,6 @@ async function validateCFAccessRequest(request) {
|
|
|
1140
1135
|
};
|
|
1141
1136
|
}
|
|
1142
1137
|
}
|
|
1143
|
-
|
|
1144
1138
|
//#endregion
|
|
1145
1139
|
//#region src/component-registry.ts
|
|
1146
1140
|
/**
|
|
@@ -1243,7 +1237,6 @@ var ComponentRegistry = class {
|
|
|
1243
1237
|
await this.save();
|
|
1244
1238
|
}
|
|
1245
1239
|
};
|
|
1246
|
-
|
|
1247
1240
|
//#endregion
|
|
1248
1241
|
//#region src/content-watcher.ts
|
|
1249
1242
|
/**
|
|
@@ -1251,7 +1244,7 @@ var ComponentRegistry = class {
|
|
|
1251
1244
|
*/
|
|
1252
1245
|
async function createContentAPI(options) {
|
|
1253
1246
|
return await FileSystemContentAPI.create({
|
|
1254
|
-
|
|
1247
|
+
...options,
|
|
1255
1248
|
canvasDir: options.canvasDir || "./canvas"
|
|
1256
1249
|
});
|
|
1257
1250
|
}
|
|
@@ -1265,8 +1258,12 @@ function createContentWatchHandlers(contentApi, options, ws, onReindexed) {
|
|
|
1265
1258
|
if (!isContentFile && !isDataFile) return;
|
|
1266
1259
|
const normalizedFile = normalize(resolve(file));
|
|
1267
1260
|
const normalizedRoot = normalize(resolve(options.contentRoot));
|
|
1268
|
-
|
|
1269
|
-
|
|
1261
|
+
const normalizedMdxRoot = options.mdxPagesRoot ? normalize(resolve(options.mdxPagesRoot)) : null;
|
|
1262
|
+
const inContentRoot = normalizedFile === normalizedRoot || normalizedFile.startsWith(normalizedRoot + "/");
|
|
1263
|
+
const inMdxRoot = !!normalizedMdxRoot && (normalizedFile === normalizedMdxRoot || normalizedFile.startsWith(normalizedMdxRoot + "/"));
|
|
1264
|
+
if (inContentRoot || inMdxRoot) {
|
|
1265
|
+
const matchedRoot = inContentRoot ? normalizedRoot : normalizedMdxRoot;
|
|
1266
|
+
const relativePath = normalizedFile.replace(matchedRoot + "/", "");
|
|
1270
1267
|
console.log(`[Content] ${action}: ${relativePath}`);
|
|
1271
1268
|
try {
|
|
1272
1269
|
const reindexOptions = action === "delete" ? { handleDeletions: true } : void 0;
|
|
@@ -1297,7 +1294,9 @@ function createContentWatchHandlers(contentApi, options, ws, onReindexed) {
|
|
|
1297
1294
|
try {
|
|
1298
1295
|
await onReindexed?.({
|
|
1299
1296
|
file: normalizedFile,
|
|
1300
|
-
action
|
|
1297
|
+
action,
|
|
1298
|
+
inMdxRoot,
|
|
1299
|
+
inContentRoot
|
|
1301
1300
|
});
|
|
1302
1301
|
} catch (error) {
|
|
1303
1302
|
console.error("[Content Watcher] onReindexed callback failed:", error);
|
|
@@ -1310,7 +1309,6 @@ function createContentWatchHandlers(contentApi, options, ws, onReindexed) {
|
|
|
1310
1309
|
onUnlink: (file) => handleFileChange(file, "delete")
|
|
1311
1310
|
};
|
|
1312
1311
|
}
|
|
1313
|
-
|
|
1314
1312
|
//#endregion
|
|
1315
1313
|
//#region src/in-memory-content-api.ts
|
|
1316
1314
|
/**
|
|
@@ -1351,27 +1349,10 @@ var InMemoryContentAPI = class {
|
|
|
1351
1349
|
for (const localeVersion of localesOf(manifest)) {
|
|
1352
1350
|
const { locale } = localeVersion;
|
|
1353
1351
|
const cachedContent = this.contentIndex.getCachedContent(id, locale);
|
|
1354
|
-
if (cachedContent) {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
id: manifest.id,
|
|
1359
|
-
created: localeVersion.created,
|
|
1360
|
-
modified: localeVersion.modified,
|
|
1361
|
-
...localeVersion.publishAt && { publishAt: localeVersion.publishAt },
|
|
1362
|
-
...localeVersion.unpublishAt && { unpublishAt: localeVersion.unpublishAt },
|
|
1363
|
-
...localeVersion.meta
|
|
1364
|
-
};
|
|
1365
|
-
contentToReturn = {
|
|
1366
|
-
...cachedContent,
|
|
1367
|
-
mdx: serializeMdxWithFrontmatter(frontmatterData, cachedContent.mdx)
|
|
1368
|
-
};
|
|
1369
|
-
}
|
|
1370
|
-
contentEntry.locales[locale] = {
|
|
1371
|
-
...localeVersion,
|
|
1372
|
-
content: contentToReturn
|
|
1373
|
-
};
|
|
1374
|
-
}
|
|
1352
|
+
if (cachedContent) contentEntry.locales[locale] = {
|
|
1353
|
+
...localeVersion,
|
|
1354
|
+
content: cachedContent
|
|
1355
|
+
};
|
|
1375
1356
|
}
|
|
1376
1357
|
return contentEntry;
|
|
1377
1358
|
}
|
|
@@ -1381,21 +1362,7 @@ var InMemoryContentAPI = class {
|
|
|
1381
1362
|
const localeVersion = manifest.locales[locale];
|
|
1382
1363
|
const cachedContent = this.contentIndex.getCachedContent(id, locale);
|
|
1383
1364
|
if (!cachedContent) return null;
|
|
1384
|
-
|
|
1385
|
-
if (manifest.type === "mdx" && cachedContent.mdx) {
|
|
1386
|
-
const frontmatterData = {
|
|
1387
|
-
id: manifest.id,
|
|
1388
|
-
created: localeVersion.created,
|
|
1389
|
-
modified: localeVersion.modified,
|
|
1390
|
-
...localeVersion.publishAt && { publishAt: localeVersion.publishAt },
|
|
1391
|
-
...localeVersion.unpublishAt && { unpublishAt: localeVersion.unpublishAt },
|
|
1392
|
-
...localeVersion.meta
|
|
1393
|
-
};
|
|
1394
|
-
contentToReturn = {
|
|
1395
|
-
...cachedContent,
|
|
1396
|
-
mdx: serializeMdxWithFrontmatter(frontmatterData, cachedContent.mdx)
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1365
|
+
const contentToReturn = { ...cachedContent };
|
|
1399
1366
|
return {
|
|
1400
1367
|
id,
|
|
1401
1368
|
site: manifest.site,
|
|
@@ -1778,35 +1745,6 @@ var InMemoryContentAPI = class {
|
|
|
1778
1745
|
};
|
|
1779
1746
|
}
|
|
1780
1747
|
};
|
|
1781
|
-
|
|
1782
|
-
//#endregion
|
|
1783
|
-
//#region src/mdx/compile.ts
|
|
1784
|
-
async function compileMDX(content) {
|
|
1785
|
-
try {
|
|
1786
|
-
const { data: metadata } = matter(content);
|
|
1787
|
-
const compiled = await compile(content, {
|
|
1788
|
-
outputFormat: "function-body",
|
|
1789
|
-
development: process.env.NODE_ENV === "development",
|
|
1790
|
-
remarkPlugins: [
|
|
1791
|
-
remarkFrontmatter,
|
|
1792
|
-
remarkMdxFrontmatter,
|
|
1793
|
-
remarkGfm
|
|
1794
|
-
]
|
|
1795
|
-
});
|
|
1796
|
-
return {
|
|
1797
|
-
code: String(compiled.value),
|
|
1798
|
-
metadata
|
|
1799
|
-
};
|
|
1800
|
-
} catch (error) {
|
|
1801
|
-
if (error instanceof Error) {
|
|
1802
|
-
const enhancedError = /* @__PURE__ */ new Error(`MDX compilation failed: ${error.message}`);
|
|
1803
|
-
enhancedError.stack = error.stack;
|
|
1804
|
-
throw enhancedError;
|
|
1805
|
-
}
|
|
1806
|
-
throw error;
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
1748
|
//#endregion
|
|
1811
1749
|
//#region src/middleware.ts
|
|
1812
1750
|
/**
|
|
@@ -1847,10 +1785,14 @@ function createContentAPIRouter(api, options) {
|
|
|
1847
1785
|
app.get("/content/collections", async (c) => {
|
|
1848
1786
|
try {
|
|
1849
1787
|
const allCollections = /* @__PURE__ */ new Set();
|
|
1850
|
-
api.blocks.collections
|
|
1788
|
+
const blockCollections = api.blocks.collections;
|
|
1789
|
+
for (const collection of blockCollections) allCollections.add(collection);
|
|
1851
1790
|
for (const siteName of Object.keys(api.sitesConfig.sites)) {
|
|
1852
1791
|
const site = api.getSite(siteName);
|
|
1853
|
-
if (site)
|
|
1792
|
+
if (site) {
|
|
1793
|
+
const siteCollections = site.collections;
|
|
1794
|
+
for (const collection of siteCollections) allCollections.add(collection);
|
|
1795
|
+
}
|
|
1854
1796
|
}
|
|
1855
1797
|
return c.json({ collections: Array.from(allCollections).sort() });
|
|
1856
1798
|
} catch (error) {
|
|
@@ -1912,10 +1854,35 @@ function createContentAPIRouter(api, options) {
|
|
|
1912
1854
|
const data = await c.req.json();
|
|
1913
1855
|
const result = await api.createContent(data);
|
|
1914
1856
|
if (!result.success) {
|
|
1915
|
-
|
|
1916
|
-
if (result.reason === "
|
|
1917
|
-
|
|
1918
|
-
|
|
1857
|
+
const errMessage = (result.error instanceof Error ? result.error.message : void 0) ?? "";
|
|
1858
|
+
if (result.reason === "already_exists") return c.json({
|
|
1859
|
+
...result,
|
|
1860
|
+
...errorResponse(ErrorCodes.ALREADY_EXISTS, errMessage || "Content already exists")
|
|
1861
|
+
}, 409);
|
|
1862
|
+
if (result.reason === "name_taken") return c.json({
|
|
1863
|
+
...result,
|
|
1864
|
+
...errorResponse(ErrorCodes.NAME_TAKEN, errMessage || "A block with that name already exists")
|
|
1865
|
+
}, 409);
|
|
1866
|
+
if (result.reason === "pathname_taken") return c.json({
|
|
1867
|
+
...result,
|
|
1868
|
+
...errorResponse(ErrorCodes.PATHNAME_TAKEN, errMessage || "Pathname already taken")
|
|
1869
|
+
}, 409);
|
|
1870
|
+
if (result.reason === "invalid_name") return c.json({
|
|
1871
|
+
...result,
|
|
1872
|
+
...errorResponse(ErrorCodes.INVALID_REQUEST, errMessage || "Invalid name")
|
|
1873
|
+
}, 400);
|
|
1874
|
+
if (result.reason === "invalid_pathname") return c.json({
|
|
1875
|
+
...result,
|
|
1876
|
+
...errorResponse(ErrorCodes.INVALID_PATHNAME, errMessage || "Invalid pathname")
|
|
1877
|
+
}, 400);
|
|
1878
|
+
if (result.reason === "metadata_too_large") return c.json({
|
|
1879
|
+
...result,
|
|
1880
|
+
...errorResponse(ErrorCodes.METADATA_TOO_LARGE, errMessage || "Metadata too large")
|
|
1881
|
+
}, 400);
|
|
1882
|
+
return c.json({
|
|
1883
|
+
...result,
|
|
1884
|
+
...errorResponse(ErrorCodes.WRITE_ERROR, errMessage || "Failed to create content")
|
|
1885
|
+
}, 500);
|
|
1919
1886
|
}
|
|
1920
1887
|
return c.json(result, 201);
|
|
1921
1888
|
} catch (error) {
|
|
@@ -1923,7 +1890,7 @@ function createContentAPIRouter(api, options) {
|
|
|
1923
1890
|
return c.json({
|
|
1924
1891
|
success: false,
|
|
1925
1892
|
reason: "write_error",
|
|
1926
|
-
|
|
1893
|
+
...errorResponse(ErrorCodes.WRITE_ERROR, errorMessage(error, "Failed to create content"))
|
|
1927
1894
|
}, 500);
|
|
1928
1895
|
}
|
|
1929
1896
|
});
|
|
@@ -2283,10 +2250,17 @@ function createContentAPIRouter(api, options) {
|
|
|
2283
2250
|
if (!pathname) return c.json(errorResponse(ErrorCodes.MISSING_REQUIRED_FIELD, "pathname query parameter is required", { field: "pathname" }), 400);
|
|
2284
2251
|
try {
|
|
2285
2252
|
if (site === "blocks") return c.json(errorResponse(ErrorCodes.INVALID_REQUEST, "Blocks do not have pathnames. This endpoint is only for page content."), 400);
|
|
2253
|
+
const validation = normalizeAndValidatePathname(pathname);
|
|
2254
|
+
if (!validation.valid) return c.json({
|
|
2255
|
+
available: false,
|
|
2256
|
+
reason: "invalid_pathname",
|
|
2257
|
+
message: validation.message
|
|
2258
|
+
});
|
|
2259
|
+
const normalized = validation.value;
|
|
2286
2260
|
const siteObj = api.getSite(site);
|
|
2287
2261
|
if (!siteObj) return c.json(errorResponse(ErrorCodes.SITE_NOT_FOUND, `Site '${site}' not found`, { site }), 404);
|
|
2288
|
-
if (siteObj.isPathnameAvailable(
|
|
2289
|
-
const existingId = siteObj.getPathnameConflict(
|
|
2262
|
+
if (siteObj.isPathnameAvailable(normalized, locale, excludeId)) return c.json({ available: true });
|
|
2263
|
+
const existingId = siteObj.getPathnameConflict(normalized, locale, excludeId);
|
|
2290
2264
|
return c.json({
|
|
2291
2265
|
available: false,
|
|
2292
2266
|
existingId
|
|
@@ -2525,33 +2499,14 @@ function createContentAPIRouter(api, options) {
|
|
|
2525
2499
|
return c.json(logAndCreateErrorResponse(error, ErrorCodes.GIT_PULL_FAILED, "Failed to pull from origin"), 500);
|
|
2526
2500
|
}
|
|
2527
2501
|
});
|
|
2528
|
-
app.post("/mdx/compile", async (c) => {
|
|
2529
|
-
try {
|
|
2530
|
-
let body;
|
|
2531
|
-
try {
|
|
2532
|
-
body = await c.req.json();
|
|
2533
|
-
} catch {
|
|
2534
|
-
return c.json(errorResponse(ErrorCodes.INVALID_REQUEST, "Invalid JSON body"), 400);
|
|
2535
|
-
}
|
|
2536
|
-
const mdxContent = typeof body === "object" && body !== null ? body.mdxContent : null;
|
|
2537
|
-
if (!mdxContent || typeof mdxContent !== "string") return c.json(errorResponse(ErrorCodes.MISSING_REQUIRED_FIELD, "mdxContent string required", { field: "mdxContent" }), 400);
|
|
2538
|
-
const { code, metadata } = await compileMDX(mdxContent);
|
|
2539
|
-
return c.json({
|
|
2540
|
-
code,
|
|
2541
|
-
metadata
|
|
2542
|
-
});
|
|
2543
|
-
} catch (error) {
|
|
2544
|
-
return c.json(logAndCreateErrorResponse(error, ErrorCodes.MDX_COMPILE_FAILED, errorMessage(error, "Failed to compile MDX")), 422);
|
|
2545
|
-
}
|
|
2546
|
-
});
|
|
2547
2502
|
return app;
|
|
2548
2503
|
}
|
|
2549
2504
|
/**
|
|
2550
2505
|
* Create middleware for backwards compatibility with existing code
|
|
2551
2506
|
* This wraps the Hono app to work with Node.js IncomingMessage/ServerResponse
|
|
2552
2507
|
*/
|
|
2553
|
-
function createContentMiddleware(contentApi) {
|
|
2554
|
-
const app = createContentAPIRouter(contentApi);
|
|
2508
|
+
function createContentMiddleware(contentApi, options) {
|
|
2509
|
+
const app = createContentAPIRouter(contentApi, options);
|
|
2555
2510
|
return async (req, res, next) => {
|
|
2556
2511
|
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
2557
2512
|
const basePath = url.pathname.startsWith("/__cms/api") ? "/__cms/api" : "/__conloca/api";
|
|
@@ -2588,7 +2543,6 @@ function readBody(req) {
|
|
|
2588
2543
|
req.on("error", reject);
|
|
2589
2544
|
});
|
|
2590
2545
|
}
|
|
2591
|
-
|
|
2592
2546
|
//#endregion
|
|
2593
2547
|
//#region src/vite-plugin.ts
|
|
2594
2548
|
/**
|
|
@@ -2612,7 +2566,7 @@ function conlocaContent(options) {
|
|
|
2612
2566
|
}
|
|
2613
2567
|
};
|
|
2614
2568
|
}
|
|
2615
|
-
|
|
2616
2569
|
//#endregion
|
|
2617
|
-
export { AssetManifest, AssetOperations, Blocks, ComponentRegistry, ErrorCodes, FileSystemContentAPI, InMemoryContentAPI, Site, UPDATE_SCOPE, analyzeUpdateScope, buildLocaleVersion, buildPathnameHistory,
|
|
2570
|
+
export { AssetManifest, AssetOperations, Blocks, ComponentRegistry, ErrorCodes, FileSystemContentAPI, InMemoryContentAPI, Site, UPDATE_SCOPE, analyzeUpdateScope, buildLocaleVersion, buildPathnameHistory, conlocaContent, createContentAPI, createContentAPIRouter, createContentMiddleware, createContentWatchHandlers, extractBlockName, extractCFAccessToken, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, normalizeAndValidatePathname, normalizePathname, parseDate, readSitesConfig, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCFAccessRequest, validateCreateContent };
|
|
2571
|
+
|
|
2618
2572
|
//# sourceMappingURL=node.mjs.map
|