@valbuild/core 0.94.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/declarations/src/getSourcePathFromRoute.d.ts +15 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/initVal.d.ts +8 -0
- package/dist/declarations/src/router.d.ts +4 -0
- package/dist/{index-bfe08f16.esm.js → index-1e99dc98.esm.js} +36 -1
- package/dist/{index-f8101689.cjs.prod.js → index-37395d55.cjs.prod.js} +36 -0
- package/dist/{index-c9252d4a.cjs.dev.js → index-e7f3333f.cjs.dev.js} +36 -0
- package/dist/valbuild-core.cjs.dev.js +2 -1
- package/dist/valbuild-core.cjs.prod.js +2 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModuleFilePath, SourcePath } from "./val/index.js";
|
|
2
|
+
import type { SerializedSchema } from "./schema/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Given a URL pathname (e.g. "/blogs/blog-1") and all serialized module schemas,
|
|
5
|
+
* finds the matching next-app-router module and returns the module file path
|
|
6
|
+
* and the source path for that route's content.
|
|
7
|
+
*
|
|
8
|
+
* External routers (e.g. external-url-router) are intentionally skipped.
|
|
9
|
+
* Returns null if no next-app-router module matches the pathname.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getSourcePathFromRoute(pathname: string, schemas: Record<ModuleFilePath, SerializedSchema>): {
|
|
12
|
+
moduleFilePath: ModuleFilePath;
|
|
13
|
+
sourcePath: SourcePath;
|
|
14
|
+
route: string;
|
|
15
|
+
} | null;
|
|
@@ -55,6 +55,7 @@ export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js
|
|
|
55
55
|
export { deserializeSchema } from "./schema/deserialize.js";
|
|
56
56
|
export { type ListRecordRender, type ListArrayRender, type ReifiedRender, type CodeLanguage, type CodeRender, } from "./render.js";
|
|
57
57
|
export type { ValRouter, RouteValidationError } from "./router.js";
|
|
58
|
+
export { getSourcePathFromRoute } from "./getSourcePathFromRoute.js";
|
|
58
59
|
export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
|
59
60
|
export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
|
|
60
61
|
export declare const DEFAULT_CONTENT_HOST = "https://content.val.build";
|
|
@@ -27,6 +27,14 @@ export type ValConfig = {
|
|
|
27
27
|
commitMessages?: {
|
|
28
28
|
disabled?: boolean;
|
|
29
29
|
};
|
|
30
|
+
chat?: {
|
|
31
|
+
experimental?: {
|
|
32
|
+
enable?: boolean;
|
|
33
|
+
};
|
|
34
|
+
suggestions?: string[];
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
};
|
|
30
38
|
};
|
|
31
39
|
};
|
|
32
40
|
export type InitVal = {
|
|
@@ -7,6 +7,10 @@ export type RouteValidationError = {
|
|
|
7
7
|
expectedPath: string | null;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
+
export declare function validateUrlAgainstPattern(urlPath: string, routePattern: string[]): {
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
expectedPath?: string;
|
|
13
|
+
};
|
|
10
14
|
export declare const nextAppRouter: ValRouter;
|
|
11
15
|
/**
|
|
12
16
|
* Parse Next.js route pattern from file path
|
|
@@ -2245,6 +2245,10 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2245
2245
|
}])
|
|
2246
2246
|
};
|
|
2247
2247
|
}
|
|
2248
|
+
var supportedTags = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul", "li", "a", "img", "br"];
|
|
2249
|
+
if (!supportedTags.includes(node.tag)) {
|
|
2250
|
+
addError(path, "Tag '".concat(node.tag, "' is not supported. Supported tags: ").concat(supportedTags.join(", ")), true);
|
|
2251
|
+
}
|
|
2248
2252
|
if (node.tag === "h1" && !((_this2$options$block = _this2.options.block) !== null && _this2$options$block !== void 0 && _this2$options$block.h1)) {
|
|
2249
2253
|
addError(path, "'h' block is not valid", false);
|
|
2250
2254
|
}
|
|
@@ -6113,6 +6117,37 @@ function parseNextJsRoutePattern(moduleFilePath) {
|
|
|
6113
6117
|
return [];
|
|
6114
6118
|
}
|
|
6115
6119
|
|
|
6120
|
+
/**
|
|
6121
|
+
* Given a URL pathname (e.g. "/blogs/blog-1") and all serialized module schemas,
|
|
6122
|
+
* finds the matching next-app-router module and returns the module file path
|
|
6123
|
+
* and the source path for that route's content.
|
|
6124
|
+
*
|
|
6125
|
+
* External routers (e.g. external-url-router) are intentionally skipped.
|
|
6126
|
+
* Returns null if no next-app-router module matches the pathname.
|
|
6127
|
+
*/
|
|
6128
|
+
function getSourcePathFromRoute(pathname, schemas) {
|
|
6129
|
+
for (var _i = 0, _arr = Object.entries(schemas); _i < _arr.length; _i++) {
|
|
6130
|
+
var _arr$_i = _slicedToArray(_arr[_i], 2),
|
|
6131
|
+
moduleFilePath = _arr$_i[0],
|
|
6132
|
+
schema = _arr$_i[1];
|
|
6133
|
+
if (schema.type !== "record" || schema.router !== "next-app-router") {
|
|
6134
|
+
continue;
|
|
6135
|
+
}
|
|
6136
|
+
var routePattern = parseNextJsRoutePattern(moduleFilePath);
|
|
6137
|
+
var _validateUrlAgainstPa = validateUrlAgainstPattern(pathname, routePattern),
|
|
6138
|
+
isValid = _validateUrlAgainstPa.isValid;
|
|
6139
|
+
if (isValid) {
|
|
6140
|
+
var sourcePath = "".concat(moduleFilePath, "?p=").concat(JSON.stringify(pathname));
|
|
6141
|
+
return {
|
|
6142
|
+
moduleFilePath: moduleFilePath,
|
|
6143
|
+
sourcePath: sourcePath,
|
|
6144
|
+
route: pathname
|
|
6145
|
+
};
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
return null;
|
|
6149
|
+
}
|
|
6150
|
+
|
|
6116
6151
|
var ModuleFilePathSep = "?p=";
|
|
6117
6152
|
var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
|
6118
6153
|
var DEFAULT_CONTENT_HOST = "https://content.val.build";
|
|
@@ -6216,4 +6251,4 @@ function tryJsonParse(str) {
|
|
|
6216
6251
|
}
|
|
6217
6252
|
}
|
|
6218
6253
|
|
|
6219
|
-
export { ArraySchema as A, BooleanSchema as B, DEFAULT_CONTENT_HOST as D, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, DEFAULT_VAL_REMOTE_HOST as f, FILE_REF_PROP as g, FILE_REF_SUBTYPE_TAG as h, initVal as i, derefPatch as j, StringSchema as k, ImageSchema as l, modules as m, FileSchema as n, DateSchema as o, RouteSchema as p, RichTextSchema as q, deserializeSchema as r, splitModuleFilePathAndModulePath as s };
|
|
6254
|
+
export { ArraySchema as A, BooleanSchema as B, DEFAULT_CONTENT_HOST as D, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, DEFAULT_VAL_REMOTE_HOST as f, FILE_REF_PROP as g, FILE_REF_SUBTYPE_TAG as h, initVal as i, derefPatch as j, StringSchema as k, ImageSchema as l, modules as m, FileSchema as n, DateSchema as o, RouteSchema as p, RichTextSchema as q, deserializeSchema as r, splitModuleFilePathAndModulePath as s, getSourcePathFromRoute as t };
|
|
@@ -2247,6 +2247,10 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2247
2247
|
}])
|
|
2248
2248
|
};
|
|
2249
2249
|
}
|
|
2250
|
+
var supportedTags = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul", "li", "a", "img", "br"];
|
|
2251
|
+
if (!supportedTags.includes(node.tag)) {
|
|
2252
|
+
addError(path, "Tag '".concat(node.tag, "' is not supported. Supported tags: ").concat(supportedTags.join(", ")), true);
|
|
2253
|
+
}
|
|
2250
2254
|
if (node.tag === "h1" && !((_this2$options$block = _this2.options.block) !== null && _this2$options$block !== void 0 && _this2$options$block.h1)) {
|
|
2251
2255
|
addError(path, "'h' block is not valid", false);
|
|
2252
2256
|
}
|
|
@@ -6115,6 +6119,37 @@ function parseNextJsRoutePattern(moduleFilePath) {
|
|
|
6115
6119
|
return [];
|
|
6116
6120
|
}
|
|
6117
6121
|
|
|
6122
|
+
/**
|
|
6123
|
+
* Given a URL pathname (e.g. "/blogs/blog-1") and all serialized module schemas,
|
|
6124
|
+
* finds the matching next-app-router module and returns the module file path
|
|
6125
|
+
* and the source path for that route's content.
|
|
6126
|
+
*
|
|
6127
|
+
* External routers (e.g. external-url-router) are intentionally skipped.
|
|
6128
|
+
* Returns null if no next-app-router module matches the pathname.
|
|
6129
|
+
*/
|
|
6130
|
+
function getSourcePathFromRoute(pathname, schemas) {
|
|
6131
|
+
for (var _i = 0, _arr = Object.entries(schemas); _i < _arr.length; _i++) {
|
|
6132
|
+
var _arr$_i = _slicedToArray(_arr[_i], 2),
|
|
6133
|
+
moduleFilePath = _arr$_i[0],
|
|
6134
|
+
schema = _arr$_i[1];
|
|
6135
|
+
if (schema.type !== "record" || schema.router !== "next-app-router") {
|
|
6136
|
+
continue;
|
|
6137
|
+
}
|
|
6138
|
+
var routePattern = parseNextJsRoutePattern(moduleFilePath);
|
|
6139
|
+
var _validateUrlAgainstPa = validateUrlAgainstPattern(pathname, routePattern),
|
|
6140
|
+
isValid = _validateUrlAgainstPa.isValid;
|
|
6141
|
+
if (isValid) {
|
|
6142
|
+
var sourcePath = "".concat(moduleFilePath, "?p=").concat(JSON.stringify(pathname));
|
|
6143
|
+
return {
|
|
6144
|
+
moduleFilePath: moduleFilePath,
|
|
6145
|
+
sourcePath: sourcePath,
|
|
6146
|
+
route: pathname
|
|
6147
|
+
};
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6150
|
+
return null;
|
|
6151
|
+
}
|
|
6152
|
+
|
|
6118
6153
|
var ModuleFilePathSep = "?p=";
|
|
6119
6154
|
var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
|
6120
6155
|
var DEFAULT_CONTENT_HOST = "https://content.val.build";
|
|
@@ -6251,6 +6286,7 @@ exports._toConsumableArray = _toConsumableArray;
|
|
|
6251
6286
|
exports._typeof = _typeof;
|
|
6252
6287
|
exports.derefPatch = derefPatch;
|
|
6253
6288
|
exports.deserializeSchema = deserializeSchema;
|
|
6289
|
+
exports.getSourcePathFromRoute = getSourcePathFromRoute;
|
|
6254
6290
|
exports.initVal = initVal;
|
|
6255
6291
|
exports.modules = modules;
|
|
6256
6292
|
exports.splitModuleFilePathAndModulePath = splitModuleFilePathAndModulePath;
|
|
@@ -2247,6 +2247,10 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2247
2247
|
}])
|
|
2248
2248
|
};
|
|
2249
2249
|
}
|
|
2250
|
+
var supportedTags = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul", "li", "a", "img", "br"];
|
|
2251
|
+
if (!supportedTags.includes(node.tag)) {
|
|
2252
|
+
addError(path, "Tag '".concat(node.tag, "' is not supported. Supported tags: ").concat(supportedTags.join(", ")), true);
|
|
2253
|
+
}
|
|
2250
2254
|
if (node.tag === "h1" && !((_this2$options$block = _this2.options.block) !== null && _this2$options$block !== void 0 && _this2$options$block.h1)) {
|
|
2251
2255
|
addError(path, "'h' block is not valid", false);
|
|
2252
2256
|
}
|
|
@@ -6115,6 +6119,37 @@ function parseNextJsRoutePattern(moduleFilePath) {
|
|
|
6115
6119
|
return [];
|
|
6116
6120
|
}
|
|
6117
6121
|
|
|
6122
|
+
/**
|
|
6123
|
+
* Given a URL pathname (e.g. "/blogs/blog-1") and all serialized module schemas,
|
|
6124
|
+
* finds the matching next-app-router module and returns the module file path
|
|
6125
|
+
* and the source path for that route's content.
|
|
6126
|
+
*
|
|
6127
|
+
* External routers (e.g. external-url-router) are intentionally skipped.
|
|
6128
|
+
* Returns null if no next-app-router module matches the pathname.
|
|
6129
|
+
*/
|
|
6130
|
+
function getSourcePathFromRoute(pathname, schemas) {
|
|
6131
|
+
for (var _i = 0, _arr = Object.entries(schemas); _i < _arr.length; _i++) {
|
|
6132
|
+
var _arr$_i = _slicedToArray(_arr[_i], 2),
|
|
6133
|
+
moduleFilePath = _arr$_i[0],
|
|
6134
|
+
schema = _arr$_i[1];
|
|
6135
|
+
if (schema.type !== "record" || schema.router !== "next-app-router") {
|
|
6136
|
+
continue;
|
|
6137
|
+
}
|
|
6138
|
+
var routePattern = parseNextJsRoutePattern(moduleFilePath);
|
|
6139
|
+
var _validateUrlAgainstPa = validateUrlAgainstPattern(pathname, routePattern),
|
|
6140
|
+
isValid = _validateUrlAgainstPa.isValid;
|
|
6141
|
+
if (isValid) {
|
|
6142
|
+
var sourcePath = "".concat(moduleFilePath, "?p=").concat(JSON.stringify(pathname));
|
|
6143
|
+
return {
|
|
6144
|
+
moduleFilePath: moduleFilePath,
|
|
6145
|
+
sourcePath: sourcePath,
|
|
6146
|
+
route: pathname
|
|
6147
|
+
};
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6150
|
+
return null;
|
|
6151
|
+
}
|
|
6152
|
+
|
|
6118
6153
|
var ModuleFilePathSep = "?p=";
|
|
6119
6154
|
var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
|
6120
6155
|
var DEFAULT_CONTENT_HOST = "https://content.val.build";
|
|
@@ -6251,6 +6286,7 @@ exports._toConsumableArray = _toConsumableArray;
|
|
|
6251
6286
|
exports._typeof = _typeof;
|
|
6252
6287
|
exports.derefPatch = derefPatch;
|
|
6253
6288
|
exports.deserializeSchema = deserializeSchema;
|
|
6289
|
+
exports.getSourcePathFromRoute = getSourcePathFromRoute;
|
|
6254
6290
|
exports.initVal = initVal;
|
|
6255
6291
|
exports.modules = modules;
|
|
6256
6292
|
exports.splitModuleFilePathAndModulePath = splitModuleFilePathAndModulePath;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('./index-
|
|
5
|
+
var dist_valbuildCore = require('./index-e7f3333f.cjs.dev.js');
|
|
6
6
|
require('./result-bb1f436e.cjs.dev.js');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -34,5 +34,6 @@ exports.UnionSchema = dist_valbuildCore.UnionSchema;
|
|
|
34
34
|
exports.VAL_EXTENSION = dist_valbuildCore.VAL_EXTENSION;
|
|
35
35
|
exports.derefPatch = dist_valbuildCore.derefPatch;
|
|
36
36
|
exports.deserializeSchema = dist_valbuildCore.deserializeSchema;
|
|
37
|
+
exports.getSourcePathFromRoute = dist_valbuildCore.getSourcePathFromRoute;
|
|
37
38
|
exports.initVal = dist_valbuildCore.initVal;
|
|
38
39
|
exports.modules = dist_valbuildCore.modules;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('./index-
|
|
5
|
+
var dist_valbuildCore = require('./index-37395d55.cjs.prod.js');
|
|
6
6
|
require('./result-787e35f6.cjs.prod.js');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -34,5 +34,6 @@ exports.UnionSchema = dist_valbuildCore.UnionSchema;
|
|
|
34
34
|
exports.VAL_EXTENSION = dist_valbuildCore.VAL_EXTENSION;
|
|
35
35
|
exports.derefPatch = dist_valbuildCore.derefPatch;
|
|
36
36
|
exports.deserializeSchema = dist_valbuildCore.deserializeSchema;
|
|
37
|
+
exports.getSourcePathFromRoute = dist_valbuildCore.getSourcePathFromRoute;
|
|
37
38
|
exports.initVal = dist_valbuildCore.initVal;
|
|
38
39
|
exports.modules = dist_valbuildCore.modules;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, f as DEFAULT_VAL_REMOTE_HOST, o as DateSchema, F as FATAL_ERROR_TYPES, g as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, n as FileSchema, G as GenericSelector, l as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, q as RichTextSchema, p as RouteSchema, S as Schema, k as StringSchema, U as UnionSchema, V as VAL_EXTENSION, j as derefPatch, r as deserializeSchema, i as initVal, m as modules } from './index-
|
|
1
|
+
export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, f as DEFAULT_VAL_REMOTE_HOST, o as DateSchema, F as FATAL_ERROR_TYPES, g as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, n as FileSchema, G as GenericSelector, l as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, q as RichTextSchema, p as RouteSchema, S as Schema, k as StringSchema, U as UnionSchema, V as VAL_EXTENSION, j as derefPatch, r as deserializeSchema, t as getSourcePathFromRoute, i as initVal, m as modules } from './index-1e99dc98.esm.js';
|
|
2
2
|
import './result-4bd63123.esm.js';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
|
5
|
+
var dist_valbuildCore = require('../../dist/index-e7f3333f.cjs.dev.js');
|
|
6
6
|
var result = require('../../dist/result-bb1f436e.cjs.dev.js');
|
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
|
5
|
+
var dist_valbuildCore = require('../../dist/index-37395d55.cjs.prod.js');
|
|
6
6
|
var result = require('../../dist/result-787e35f6.cjs.prod.js');
|
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-
|
|
2
|
-
export { P as PatchError } from '../../dist/index-
|
|
1
|
+
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-1e99dc98.esm.js';
|
|
2
|
+
export { P as PatchError } from '../../dist/index-1e99dc98.esm.js';
|
|
3
3
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-4bd63123.esm.js';
|
|
4
4
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
|
5
5
|
|