@valbuild/core 0.40.0 → 0.42.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/ValApi.d.ts +1 -1
- package/dist/declarations/src/index.d.ts +4 -2
- package/dist/declarations/src/initSchema.d.ts +2 -2
- package/dist/declarations/src/initVal.d.ts +2 -3
- package/dist/declarations/src/schema/keyOf.d.ts +1 -0
- package/dist/declarations/src/schema/union.d.ts +7 -7
- package/dist/{ops-ce47df64.esm.js → ops-266faf09.esm.js} +30 -4
- package/dist/{ops-6489efeb.cjs.prod.js → ops-d88e99cd.cjs.prod.js} +30 -4
- package/dist/{ops-bec039cc.cjs.dev.js → ops-e02ab215.cjs.dev.js} +30 -4
- package/dist/valbuild-core.cjs.dev.js +360 -33
- package/dist/valbuild-core.cjs.prod.js +360 -33
- package/dist/valbuild-core.esm.js +360 -33
- 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
@@ -10,13 +10,13 @@ export declare class ValApi {
|
|
10
10
|
host: string;
|
11
11
|
constructor(host: string);
|
12
12
|
getDisableUrl(redirectTo: string): string;
|
13
|
-
getEditUrl(): string;
|
14
13
|
getLoginUrl(redirectTo: string): string;
|
15
14
|
getEnableUrl(redirectTo: string): string;
|
16
15
|
getPatches({ patchIds, headers, }: {
|
17
16
|
patchIds?: string[];
|
18
17
|
headers?: Record<string, string> | undefined;
|
19
18
|
}): Promise<result.Result<ApiGetPatchResponse, FetchError>>;
|
19
|
+
getEditUrl(): string;
|
20
20
|
postPatches(moduleId: ModuleId, patches: PatchJSON, headers?: Record<string, string> | undefined): Promise<result.Result<ApiPostPatchResponse, FetchError>>;
|
21
21
|
getSession(): Promise<result.Result<{
|
22
22
|
mode: "proxy" | "local";
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export { initVal } from "./initVal.js";
|
2
|
-
export type { InitVal, ValConfig } from "./initVal.js";
|
2
|
+
export type { InitVal, ValConfig, ValConstructor } from "./initVal.js";
|
3
3
|
export { Schema, type SerializedSchema } from "./schema/index.js";
|
4
4
|
export type { ImageMetadata } from "./schema/image.js";
|
5
5
|
export type { LinkSource } from "./source/link.js";
|
@@ -35,6 +35,8 @@ export type { SerializedNumberSchema } from "./schema/number.js";
|
|
35
35
|
export type { SerializedBooleanSchema } from "./schema/boolean.js";
|
36
36
|
export type { SerializedImageSchema } from "./schema/image.js";
|
37
37
|
export type { SerializedRichTextSchema } from "./schema/richtext.js";
|
38
|
+
export type { SerializedUnionSchema } from "./schema/union.js";
|
39
|
+
export type { SerializedLiteralSchema } from "./schema/literal.js";
|
38
40
|
export type ApiTreeResponse = {
|
39
41
|
git: {
|
40
42
|
commit?: string;
|
@@ -79,7 +81,7 @@ declare const Internal: {
|
|
79
81
|
splitModuleIdAndModulePath: typeof splitModuleIdAndModulePath;
|
80
82
|
isVal: typeof isVal;
|
81
83
|
createValPathOfItem: typeof createValPathOfItem;
|
82
|
-
getSHA256Hash: (bits: Uint8Array) =>
|
84
|
+
getSHA256Hash: (bits: Uint8Array) => string;
|
83
85
|
createPatchJSONPath: (modulePath: ModulePath) => string;
|
84
86
|
VAL_ENABLE_COOKIE_NAME: "val_enable";
|
85
87
|
VAL_STATE_COOKIE: "val_state";
|
@@ -36,7 +36,7 @@ export declare function initSchema(): {
|
|
36
36
|
max?: number | undefined;
|
37
37
|
min?: number | undefined;
|
38
38
|
} | undefined) => import("./schema/index.js").Schema<number>;
|
39
|
-
union: <Key extends string
|
39
|
+
union: <Key extends string | import("./schema/index.js").Schema<string>, T_1 extends import("./schema/index.js").Schema<Key extends string ? {
|
40
40
|
[x: string]: import("./source/index.js").Source;
|
41
41
|
} & {
|
42
42
|
fold?: undefined;
|
@@ -46,7 +46,7 @@ export declare function initSchema(): {
|
|
46
46
|
_type?: undefined;
|
47
47
|
val?: undefined;
|
48
48
|
valPath?: undefined;
|
49
|
-
} & { [k in Key]: string; }>[]>(key: Key, ...objects: T_1) => import("./schema/index.js").Schema<T_1 extends import("./schema/index.js").Schema<infer S_1 extends import("./selector/index.js").SelectorSource>[] ? S_1 extends import("./selector/index.js").SelectorSource ? S_1 : never : never>;
|
49
|
+
} & { [k in Key]: string; } : Key extends import("./schema/index.js").Schema<string> ? string : unknown>[]>(key: Key, ...objects: T_1) => import("./schema/index.js").Schema<T_1 extends import("./schema/index.js").Schema<infer S_1 extends import("./selector/index.js").SelectorSource>[] ? S_1 extends import("./selector/index.js").SelectorSource ? S_1 | (Key extends import("./schema/index.js").Schema<infer K extends import("./selector/index.js").SelectorSource> ? K : never) : never : never>;
|
50
50
|
richtext: <O extends import("./index.js").RichTextOptions>(options?: O | undefined) => import("./schema/index.js").Schema<import("./index.js").RichTextSource<O>>;
|
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>;
|
@@ -4,7 +4,7 @@ import { getValPath as getPath } from "./val/index.js";
|
|
4
4
|
import { file } from "./source/file.js";
|
5
5
|
import { richtext } from "./source/richtext.js";
|
6
6
|
import { link } from "./source/link.js";
|
7
|
-
type ValConstructor = {
|
7
|
+
export type ValConstructor = {
|
8
8
|
content: typeof content;
|
9
9
|
getPath: typeof getPath;
|
10
10
|
file: typeof file;
|
@@ -14,7 +14,7 @@ type ValConstructor = {
|
|
14
14
|
export type ValConfig = {
|
15
15
|
gitCommit?: string;
|
16
16
|
gitBranch?: string;
|
17
|
-
valConfigPath
|
17
|
+
valConfigPath?: string;
|
18
18
|
};
|
19
19
|
export type InitVal = {
|
20
20
|
val: ValConstructor;
|
@@ -22,4 +22,3 @@ export type InitVal = {
|
|
22
22
|
config: ValConfig;
|
23
23
|
};
|
24
24
|
export declare const initVal: () => InitVal;
|
25
|
-
export {};
|
@@ -8,6 +8,7 @@ export type SerializedKeyOfSchema = {
|
|
8
8
|
type: "keyOf";
|
9
9
|
selector: SourcePath;
|
10
10
|
opt: boolean;
|
11
|
+
values: "string" | "number" | string[];
|
11
12
|
};
|
12
13
|
type KeyOfSelector<Sel extends GenericSelector<SourceArray | SourceObject>> = Sel extends GenericSelector<infer S> ? S extends readonly any[] ? number : S extends SourceObject ? keyof S : S extends Record<string, any> ? string : never : never;
|
13
14
|
export declare class KeyOfSchema<Sel extends GenericSelector<SourceArray | SourceObject>> extends Schema<KeyOfSelector<Sel>> {
|
@@ -5,16 +5,16 @@ import { SourcePath } from "../val/index.js";
|
|
5
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
6
6
|
export type SerializedUnionSchema = {
|
7
7
|
type: "union";
|
8
|
-
key
|
8
|
+
key?: string;
|
9
9
|
items: SerializedSchema[];
|
10
10
|
opt: boolean;
|
11
11
|
};
|
12
|
-
type SourceOf<Key extends string
|
12
|
+
type SourceOf<Key extends string | Schema<string>, T extends Schema<Key extends string ? SourceObject & {
|
13
13
|
[k in Key]: string;
|
14
|
-
}>[]> = T extends Schema<infer S>[] ? S extends SelectorSource ? S : never : never;
|
15
|
-
export declare class UnionSchema<Key extends string
|
14
|
+
} : Key extends Schema<string> ? string : unknown>[]> = T extends Schema<infer S>[] ? S extends SelectorSource ? S | (Key extends Schema<infer K> ? K : never) : never : never;
|
15
|
+
export declare class UnionSchema<Key extends string | Schema<string>, T extends Schema<Key extends string ? SourceObject & {
|
16
16
|
[k in Key]: string;
|
17
|
-
}>[]> extends Schema<SourceOf<Key, T>> {
|
17
|
+
} : Key extends Schema<string> ? string : unknown>[]> extends Schema<SourceOf<Key, T>> {
|
18
18
|
readonly key: Key;
|
19
19
|
readonly items: T;
|
20
20
|
readonly opt: boolean;
|
@@ -24,7 +24,7 @@ export declare class UnionSchema<Key extends string, T extends Schema<SourceObje
|
|
24
24
|
serialize(): SerializedSchema;
|
25
25
|
constructor(key: Key, items: T, opt?: boolean);
|
26
26
|
}
|
27
|
-
export declare const union: <Key extends string
|
27
|
+
export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? {
|
28
28
|
[x: string]: import("../source/index.js").Source;
|
29
29
|
} & {
|
30
30
|
fold?: undefined;
|
@@ -34,5 +34,5 @@ export declare const union: <Key extends string, T extends Schema<{
|
|
34
34
|
_type?: undefined;
|
35
35
|
val?: undefined;
|
36
36
|
valPath?: undefined;
|
37
|
-
} & { [k in Key]: string; }>[]>(key: Key, ...objects: T) => Schema<SourceOf<Key, T>>;
|
37
|
+
} & { [k in Key]: string; } : Key extends Schema<string> ? string : unknown>[]>(key: Key, ...objects: T) => Schema<SourceOf<Key, T>>;
|
38
38
|
export {};
|
@@ -342,24 +342,34 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
342
342
|
_createClass(UnionSchema, [{
|
343
343
|
key: "validate",
|
344
344
|
value: function validate(path, src) {
|
345
|
-
|
345
|
+
// TODO:
|
346
|
+
return false;
|
346
347
|
}
|
347
348
|
}, {
|
348
349
|
key: "assert",
|
349
350
|
value: function assert(src) {
|
350
|
-
|
351
|
+
return true;
|
351
352
|
}
|
352
353
|
}, {
|
353
354
|
key: "optional",
|
354
355
|
value: function optional() {
|
355
|
-
|
356
|
+
return new UnionSchema(this.key, this.items, true);
|
356
357
|
}
|
357
358
|
}, {
|
358
359
|
key: "serialize",
|
359
360
|
value: function serialize() {
|
361
|
+
if (typeof this.key === "string") {
|
362
|
+
return {
|
363
|
+
type: "union",
|
364
|
+
key: this.key,
|
365
|
+
items: this.items.map(function (o) {
|
366
|
+
return o.serialize();
|
367
|
+
}),
|
368
|
+
opt: this.opt
|
369
|
+
};
|
370
|
+
}
|
360
371
|
return {
|
361
372
|
type: "union",
|
362
|
-
key: this.key,
|
363
373
|
items: this.items.map(function (o) {
|
364
374
|
return o.serialize();
|
365
375
|
}),
|
@@ -645,6 +655,22 @@ function resolvePath(path, valModule, schema) {
|
|
645
655
|
};
|
646
656
|
} else if (isUnionSchema(resolvedSchema)) {
|
647
657
|
var _key = resolvedSchema.key;
|
658
|
+
if (!_key) {
|
659
|
+
return {
|
660
|
+
v: {
|
661
|
+
path: origParts.map(function (p) {
|
662
|
+
if (!Number.isNaN(Number(p))) {
|
663
|
+
return p;
|
664
|
+
} else {
|
665
|
+
return JSON.stringify(p);
|
666
|
+
}
|
667
|
+
}).join("."),
|
668
|
+
// TODO: create a function generate path from parts (not sure if this always works)
|
669
|
+
schema: resolvedSchema,
|
670
|
+
source: resolvedSource
|
671
|
+
}
|
672
|
+
};
|
673
|
+
}
|
648
674
|
var keyValue = resolvedSource[_key];
|
649
675
|
if (!keyValue) {
|
650
676
|
throw Error("Invalid path: union source ".concat(resolvedSchema, " did not have required key ").concat(_key, " in path: ").concat(path));
|
@@ -344,24 +344,34 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
344
344
|
index._createClass(UnionSchema, [{
|
345
345
|
key: "validate",
|
346
346
|
value: function validate(path, src) {
|
347
|
-
|
347
|
+
// TODO:
|
348
|
+
return false;
|
348
349
|
}
|
349
350
|
}, {
|
350
351
|
key: "assert",
|
351
352
|
value: function assert(src) {
|
352
|
-
|
353
|
+
return true;
|
353
354
|
}
|
354
355
|
}, {
|
355
356
|
key: "optional",
|
356
357
|
value: function optional() {
|
357
|
-
|
358
|
+
return new UnionSchema(this.key, this.items, true);
|
358
359
|
}
|
359
360
|
}, {
|
360
361
|
key: "serialize",
|
361
362
|
value: function serialize() {
|
363
|
+
if (typeof this.key === "string") {
|
364
|
+
return {
|
365
|
+
type: "union",
|
366
|
+
key: this.key,
|
367
|
+
items: this.items.map(function (o) {
|
368
|
+
return o.serialize();
|
369
|
+
}),
|
370
|
+
opt: this.opt
|
371
|
+
};
|
372
|
+
}
|
362
373
|
return {
|
363
374
|
type: "union",
|
364
|
-
key: this.key,
|
365
375
|
items: this.items.map(function (o) {
|
366
376
|
return o.serialize();
|
367
377
|
}),
|
@@ -647,6 +657,22 @@ function resolvePath(path, valModule, schema) {
|
|
647
657
|
};
|
648
658
|
} else if (isUnionSchema(resolvedSchema)) {
|
649
659
|
var _key = resolvedSchema.key;
|
660
|
+
if (!_key) {
|
661
|
+
return {
|
662
|
+
v: {
|
663
|
+
path: origParts.map(function (p) {
|
664
|
+
if (!Number.isNaN(Number(p))) {
|
665
|
+
return p;
|
666
|
+
} else {
|
667
|
+
return JSON.stringify(p);
|
668
|
+
}
|
669
|
+
}).join("."),
|
670
|
+
// TODO: create a function generate path from parts (not sure if this always works)
|
671
|
+
schema: resolvedSchema,
|
672
|
+
source: resolvedSource
|
673
|
+
}
|
674
|
+
};
|
675
|
+
}
|
650
676
|
var keyValue = resolvedSource[_key];
|
651
677
|
if (!keyValue) {
|
652
678
|
throw Error("Invalid path: union source ".concat(resolvedSchema, " did not have required key ").concat(_key, " in path: ").concat(path));
|
@@ -344,24 +344,34 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
344
344
|
index._createClass(UnionSchema, [{
|
345
345
|
key: "validate",
|
346
346
|
value: function validate(path, src) {
|
347
|
-
|
347
|
+
// TODO:
|
348
|
+
return false;
|
348
349
|
}
|
349
350
|
}, {
|
350
351
|
key: "assert",
|
351
352
|
value: function assert(src) {
|
352
|
-
|
353
|
+
return true;
|
353
354
|
}
|
354
355
|
}, {
|
355
356
|
key: "optional",
|
356
357
|
value: function optional() {
|
357
|
-
|
358
|
+
return new UnionSchema(this.key, this.items, true);
|
358
359
|
}
|
359
360
|
}, {
|
360
361
|
key: "serialize",
|
361
362
|
value: function serialize() {
|
363
|
+
if (typeof this.key === "string") {
|
364
|
+
return {
|
365
|
+
type: "union",
|
366
|
+
key: this.key,
|
367
|
+
items: this.items.map(function (o) {
|
368
|
+
return o.serialize();
|
369
|
+
}),
|
370
|
+
opt: this.opt
|
371
|
+
};
|
372
|
+
}
|
362
373
|
return {
|
363
374
|
type: "union",
|
364
|
-
key: this.key,
|
365
375
|
items: this.items.map(function (o) {
|
366
376
|
return o.serialize();
|
367
377
|
}),
|
@@ -647,6 +657,22 @@ function resolvePath(path, valModule, schema) {
|
|
647
657
|
};
|
648
658
|
} else if (isUnionSchema(resolvedSchema)) {
|
649
659
|
var _key = resolvedSchema.key;
|
660
|
+
if (!_key) {
|
661
|
+
return {
|
662
|
+
v: {
|
663
|
+
path: origParts.map(function (p) {
|
664
|
+
if (!Number.isNaN(Number(p))) {
|
665
|
+
return p;
|
666
|
+
} else {
|
667
|
+
return JSON.stringify(p);
|
668
|
+
}
|
669
|
+
}).join("."),
|
670
|
+
// TODO: create a function generate path from parts (not sure if this always works)
|
671
|
+
schema: resolvedSchema,
|
672
|
+
source: resolvedSource
|
673
|
+
}
|
674
|
+
};
|
675
|
+
}
|
650
676
|
var keyValue = resolvedSource[_key];
|
651
677
|
if (!keyValue) {
|
652
678
|
throw Error("Invalid path: union source ".concat(resolvedSchema, " did not have required key ").concat(_key, " in path: ").concat(path));
|