@valbuild/core 0.42.0 → 0.43.1
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/ValApi.d.ts +5 -1
- package/dist/declarations/src/index.d.ts +13 -2
- package/dist/declarations/src/initSchema.d.ts +3 -3
- package/dist/declarations/src/module.d.ts +3 -3
- package/dist/declarations/src/schema/array.d.ts +6 -6
- package/dist/declarations/src/schema/index.d.ts +1 -1
- package/dist/declarations/src/schema/object.d.ts +3 -3
- package/dist/declarations/src/schema/record.d.ts +6 -6
- package/dist/valbuild-core.cjs.dev.js +20 -3
- package/dist/valbuild-core.cjs.prod.js +20 -3
- package/dist/valbuild-core.esm.js +20 -3
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ApiGetPatchResponse, ApiPostPatchResponse, ApiTreeResponse } from "./index.js";
|
1
|
+
import { ApiCommitResponse, ApiGetPatchResponse, ApiPostPatchResponse, ApiTreeResponse } from "./index.js";
|
2
2
|
import { result } from "./fp/index.js";
|
3
3
|
import { PatchJSON } from "./patch/index.js";
|
4
4
|
import { ModuleId } from "./val/index.js";
|
@@ -32,5 +32,9 @@ export declare class ValApi {
|
|
32
32
|
treePath?: string;
|
33
33
|
headers?: Record<string, string> | undefined;
|
34
34
|
}): Promise<result.Result<ApiTreeResponse, FetchError>>;
|
35
|
+
postCommit({ patches, headers, }: {
|
36
|
+
patches?: Record<ModuleId, string[]>;
|
37
|
+
headers?: Record<string, string> | undefined;
|
38
|
+
}): Promise<result.Result<ApiCommitResponse, FetchError>>;
|
35
39
|
}
|
36
40
|
export {};
|
@@ -1,9 +1,9 @@
|
|
1
1
|
export { initVal } from "./initVal.js";
|
2
2
|
export type { InitVal, ValConfig, ValConstructor } from "./initVal.js";
|
3
|
-
export { Schema, type SerializedSchema } from "./schema/index.js";
|
3
|
+
export { Schema, type SerializedSchema, type SelectorOfSchema } from "./schema/index.js";
|
4
4
|
export type { ImageMetadata } from "./schema/image.js";
|
5
5
|
export type { LinkSource } from "./source/link.js";
|
6
|
-
export type { ValModule, SerializedModule } from "./module.js";
|
6
|
+
export type { ValModule, SerializedModule, InferValModuleType } from "./module.js";
|
7
7
|
export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
|
8
8
|
export type { FileSource } from "./source/file.js";
|
9
9
|
export type { RawString } from "./schema/string.js";
|
@@ -37,6 +37,17 @@ export type { SerializedImageSchema } from "./schema/image.js";
|
|
37
37
|
export type { SerializedRichTextSchema } from "./schema/richtext.js";
|
38
38
|
export type { SerializedUnionSchema } from "./schema/union.js";
|
39
39
|
export type { SerializedLiteralSchema } from "./schema/literal.js";
|
40
|
+
export type ApiCommitResponse = {
|
41
|
+
modules: Record<ModuleId, {
|
42
|
+
patches: {
|
43
|
+
applied: string[];
|
44
|
+
};
|
45
|
+
}>;
|
46
|
+
git: {
|
47
|
+
commit?: string;
|
48
|
+
branch?: string;
|
49
|
+
};
|
50
|
+
};
|
40
51
|
export type ApiTreeResponse = {
|
41
52
|
git: {
|
42
53
|
commit?: string;
|
@@ -28,10 +28,10 @@ export declare function initSchema(): {
|
|
28
28
|
minLength?: number | undefined;
|
29
29
|
} | undefined) => import("./schema/string.js").StringSchema<T>;
|
30
30
|
boolean: () => import("./schema/index.js").Schema<boolean>;
|
31
|
-
array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/index.js").Schema<import("./schema/index.js").
|
31
|
+
array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/index.js").Schema<import("./schema/index.js").SelectorOfSchema<S>[]>;
|
32
32
|
object: <Props extends {
|
33
33
|
[key: string]: import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>;
|
34
|
-
}>(schema: Props) => import("./schema/index.js").Schema<{ [key in keyof Props]: import("./schema/index.js").
|
34
|
+
}>(schema: Props) => import("./schema/index.js").Schema<{ [key in keyof Props]: import("./schema/index.js").SelectorOfSchema<Props[key]>; }>;
|
35
35
|
number: (options?: {
|
36
36
|
max?: number | undefined;
|
37
37
|
min?: number | undefined;
|
@@ -51,5 +51,5 @@ export declare function initSchema(): {
|
|
51
51
|
image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/image.js").ImageMetadata>>;
|
52
52
|
literal: <T_2 extends string>(value: T_2) => import("./schema/index.js").Schema<T_2>;
|
53
53
|
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject | import("./source/index.js").SourceArray, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly any[] ? number : S_2 extends import("./source/index.js").SourceObject ? keyof S_2 : S_2 extends Record<string, any> ? string : never : never>;
|
54
|
-
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").
|
54
|
+
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
|
55
55
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema,
|
1
|
+
import { Schema, SelectorOfSchema, SerializedSchema } from "./schema/index.js";
|
2
2
|
import { GenericSelector, SelectorOf, SelectorSource } from "./selector/index.js";
|
3
3
|
import { Source } from "./source/index.js";
|
4
4
|
import { ModuleId, ModulePath, SourcePath } from "./val/index.js";
|
@@ -9,13 +9,13 @@ export type ValModule<T extends SelectorSource> = SelectorOf<T> & ValModuleBrand
|
|
9
9
|
export type ValModuleBrand = {
|
10
10
|
[brand]: "ValModule";
|
11
11
|
};
|
12
|
-
export type
|
12
|
+
export type InferValModuleType<T extends ValModule<SelectorSource>> = T extends GenericSelector<infer S> ? S : never;
|
13
13
|
type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource extends T ? T : T extends RawString ? string : T extends {
|
14
14
|
[key in string]: SelectorSource;
|
15
15
|
} ? {
|
16
16
|
[key in keyof T]: ReplaceRawStringWithString<T[key]>;
|
17
17
|
} : T extends SelectorSource[] ? ReplaceRawStringWithString<T[number]>[] : T;
|
18
|
-
export declare function content<T extends Schema<SelectorSource>>(id: string, schema: T, source: ReplaceRawStringWithString<
|
18
|
+
export declare function content<T extends Schema<SelectorSource>>(id: string, schema: T, source: ReplaceRawStringWithString<SelectorOfSchema<T>>): ValModule<SelectorOfSchema<T>>;
|
19
19
|
export declare function getSource(valModule: ValModule<SelectorSource>): Source;
|
20
20
|
export declare function splitModuleIdAndModulePath(path: SourcePath): [moduleId: ModuleId, path: ModulePath];
|
21
21
|
export declare function getSourceAtPath(modulePath: ModulePath, valModule: ValModule<SelectorSource> | Source): any;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema,
|
1
|
+
import { Schema, SelectorOfSchema, SerializedSchema } from "./index.js";
|
2
2
|
import { SelectorSource } from "../selector/index.js";
|
3
3
|
import { SourcePath } from "../val/index.js";
|
4
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
@@ -7,13 +7,13 @@ export type SerializedArraySchema = {
|
|
7
7
|
item: SerializedSchema;
|
8
8
|
opt: boolean;
|
9
9
|
};
|
10
|
-
export declare class ArraySchema<T extends Schema<SelectorSource>> extends Schema<
|
10
|
+
export declare class ArraySchema<T extends Schema<SelectorSource>> extends Schema<SelectorOfSchema<T>[]> {
|
11
11
|
readonly item: T;
|
12
12
|
readonly opt: boolean;
|
13
13
|
constructor(item: T, opt?: boolean);
|
14
|
-
validate(path: SourcePath, src:
|
15
|
-
assert(src:
|
16
|
-
optional(): Schema<
|
14
|
+
validate(path: SourcePath, src: SelectorOfSchema<T>[]): ValidationErrors;
|
15
|
+
assert(src: SelectorOfSchema<T>[]): boolean;
|
16
|
+
optional(): Schema<SelectorOfSchema<T>[] | null>;
|
17
17
|
serialize(): SerializedArraySchema;
|
18
18
|
}
|
19
|
-
export declare const array: <S extends Schema<SelectorSource>>(schema: S) => Schema<
|
19
|
+
export declare const array: <S extends Schema<SelectorSource>>(schema: S) => Schema<SelectorOfSchema<S>[]>;
|
@@ -21,4 +21,4 @@ export declare abstract class Schema<Src extends SelectorSource> {
|
|
21
21
|
/** MUTATES! since internal and perf sensitive */
|
22
22
|
protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value?: unknown): ValidationErrors;
|
23
23
|
}
|
24
|
-
export type
|
24
|
+
export type SelectorOfSchema<T extends Schema<SelectorSource>> = T extends Schema<infer Src> ? Src : never;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema,
|
1
|
+
import { Schema, SelectorOfSchema, SerializedSchema } from "./index.js";
|
2
2
|
import { SelectorSource } from "../selector/index.js";
|
3
3
|
import { SourcePath } from "../val/index.js";
|
4
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
@@ -11,7 +11,7 @@ type ObjectSchemaProps = {
|
|
11
11
|
[key: string]: Schema<SelectorSource>;
|
12
12
|
};
|
13
13
|
type ObjectSchemaSrcOf<Props extends ObjectSchemaProps> = {
|
14
|
-
[key in keyof Props]:
|
14
|
+
[key in keyof Props]: SelectorOfSchema<Props[key]>;
|
15
15
|
};
|
16
16
|
export declare class ObjectSchema<Props extends ObjectSchemaProps> extends Schema<ObjectSchemaSrcOf<Props>> {
|
17
17
|
readonly items: Props;
|
@@ -22,5 +22,5 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps> extends Schem
|
|
22
22
|
optional(): Schema<ObjectSchemaSrcOf<Props> | null>;
|
23
23
|
serialize(): SerializedSchema;
|
24
24
|
}
|
25
|
-
export declare const object: <Props extends ObjectSchemaProps>(schema: Props) => Schema<{ [key in keyof Props]:
|
25
|
+
export declare const object: <Props extends ObjectSchemaProps>(schema: Props) => Schema<{ [key in keyof Props]: SelectorOfSchema<Props[key]>; }>;
|
26
26
|
export {};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema,
|
1
|
+
import { Schema, SelectorOfSchema, SerializedSchema } from "./index.js";
|
2
2
|
import { SelectorSource } from "../selector/index.js";
|
3
3
|
import { SourcePath } from "../val/index.js";
|
4
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
@@ -7,13 +7,13 @@ export type SerializedRecordSchema = {
|
|
7
7
|
item: SerializedSchema;
|
8
8
|
opt: boolean;
|
9
9
|
};
|
10
|
-
export declare class RecordSchema<T extends Schema<SelectorSource>> extends Schema<Record<string,
|
10
|
+
export declare class RecordSchema<T extends Schema<SelectorSource>> extends Schema<Record<string, SelectorOfSchema<T>>> {
|
11
11
|
readonly item: T;
|
12
12
|
readonly opt: boolean;
|
13
13
|
constructor(item: T, opt?: boolean);
|
14
|
-
validate(path: SourcePath, src: Record<string,
|
15
|
-
assert(src: Record<string,
|
16
|
-
optional(): Schema<Record<string,
|
14
|
+
validate(path: SourcePath, src: Record<string, SelectorOfSchema<T>>): ValidationErrors;
|
15
|
+
assert(src: Record<string, SelectorOfSchema<T>>): boolean;
|
16
|
+
optional(): Schema<Record<string, SelectorOfSchema<T>> | null>;
|
17
17
|
serialize(): SerializedRecordSchema;
|
18
18
|
}
|
19
|
-
export declare const record: <S extends Schema<SelectorSource>>(schema: S) => Schema<Record<string,
|
19
|
+
export declare const record: <S extends Schema<SelectorSource>>(schema: S) => Schema<Record<string, SelectorOfSchema<S>>>;
|
@@ -1507,6 +1507,23 @@ var ValApi = /*#__PURE__*/function () {
|
|
1507
1507
|
return parse(res);
|
1508
1508
|
})["catch"](createError);
|
1509
1509
|
}
|
1510
|
+
}, {
|
1511
|
+
key: "postCommit",
|
1512
|
+
value: function postCommit(_ref3) {
|
1513
|
+
var patches = _ref3.patches,
|
1514
|
+
headers = _ref3.headers;
|
1515
|
+
return fetch("".concat(this.host, "/commit"), {
|
1516
|
+
method: "POST",
|
1517
|
+
body: JSON.stringify({
|
1518
|
+
patches: patches
|
1519
|
+
}),
|
1520
|
+
headers: headers || {
|
1521
|
+
"Content-Type": "application/json"
|
1522
|
+
}
|
1523
|
+
}).then(function (res) {
|
1524
|
+
return parse(res);
|
1525
|
+
})["catch"](createError);
|
1526
|
+
}
|
1510
1527
|
}]);
|
1511
1528
|
return ValApi;
|
1512
1529
|
}();
|
@@ -1547,9 +1564,9 @@ function _parse() {
|
|
1547
1564
|
return _context2.abrupt("return", result.err({
|
1548
1565
|
statusCode: res.status,
|
1549
1566
|
message: json.message || res.statusText,
|
1550
|
-
details: json.details || Object.fromEntries(Object.entries(json).filter(function (
|
1551
|
-
var
|
1552
|
-
key =
|
1567
|
+
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref4) {
|
1568
|
+
var _ref5 = index._slicedToArray(_ref4, 1),
|
1569
|
+
key = _ref5[0];
|
1553
1570
|
return key !== "message";
|
1554
1571
|
}))
|
1555
1572
|
}));
|
@@ -1507,6 +1507,23 @@ var ValApi = /*#__PURE__*/function () {
|
|
1507
1507
|
return parse(res);
|
1508
1508
|
})["catch"](createError);
|
1509
1509
|
}
|
1510
|
+
}, {
|
1511
|
+
key: "postCommit",
|
1512
|
+
value: function postCommit(_ref3) {
|
1513
|
+
var patches = _ref3.patches,
|
1514
|
+
headers = _ref3.headers;
|
1515
|
+
return fetch("".concat(this.host, "/commit"), {
|
1516
|
+
method: "POST",
|
1517
|
+
body: JSON.stringify({
|
1518
|
+
patches: patches
|
1519
|
+
}),
|
1520
|
+
headers: headers || {
|
1521
|
+
"Content-Type": "application/json"
|
1522
|
+
}
|
1523
|
+
}).then(function (res) {
|
1524
|
+
return parse(res);
|
1525
|
+
})["catch"](createError);
|
1526
|
+
}
|
1510
1527
|
}]);
|
1511
1528
|
return ValApi;
|
1512
1529
|
}();
|
@@ -1547,9 +1564,9 @@ function _parse() {
|
|
1547
1564
|
return _context2.abrupt("return", result.err({
|
1548
1565
|
statusCode: res.status,
|
1549
1566
|
message: json.message || res.statusText,
|
1550
|
-
details: json.details || Object.fromEntries(Object.entries(json).filter(function (
|
1551
|
-
var
|
1552
|
-
key =
|
1567
|
+
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref4) {
|
1568
|
+
var _ref5 = index._slicedToArray(_ref4, 1),
|
1569
|
+
key = _ref5[0];
|
1553
1570
|
return key !== "message";
|
1554
1571
|
}))
|
1555
1572
|
}));
|
@@ -1504,6 +1504,23 @@ var ValApi = /*#__PURE__*/function () {
|
|
1504
1504
|
return parse(res);
|
1505
1505
|
})["catch"](createError);
|
1506
1506
|
}
|
1507
|
+
}, {
|
1508
|
+
key: "postCommit",
|
1509
|
+
value: function postCommit(_ref3) {
|
1510
|
+
var patches = _ref3.patches,
|
1511
|
+
headers = _ref3.headers;
|
1512
|
+
return fetch("".concat(this.host, "/commit"), {
|
1513
|
+
method: "POST",
|
1514
|
+
body: JSON.stringify({
|
1515
|
+
patches: patches
|
1516
|
+
}),
|
1517
|
+
headers: headers || {
|
1518
|
+
"Content-Type": "application/json"
|
1519
|
+
}
|
1520
|
+
}).then(function (res) {
|
1521
|
+
return parse(res);
|
1522
|
+
})["catch"](createError);
|
1523
|
+
}
|
1507
1524
|
}]);
|
1508
1525
|
return ValApi;
|
1509
1526
|
}();
|
@@ -1544,9 +1561,9 @@ function _parse() {
|
|
1544
1561
|
return _context2.abrupt("return", err({
|
1545
1562
|
statusCode: res.status,
|
1546
1563
|
message: json.message || res.statusText,
|
1547
|
-
details: json.details || Object.fromEntries(Object.entries(json).filter(function (
|
1548
|
-
var
|
1549
|
-
key =
|
1564
|
+
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref4) {
|
1565
|
+
var _ref5 = _slicedToArray(_ref4, 1),
|
1566
|
+
key = _ref5[0];
|
1550
1567
|
return key !== "message";
|
1551
1568
|
}))
|
1552
1569
|
}));
|