@valbuild/core 0.60.27 → 0.62.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.
Files changed (31) hide show
  1. package/dist/declarations/src/ValApi.d.ts +18 -15
  2. package/dist/declarations/src/index.d.ts +37 -42
  3. package/dist/declarations/src/initVal.d.ts +1 -1
  4. package/dist/declarations/src/module.d.ts +3 -2
  5. package/dist/declarations/src/modules.d.ts +30 -0
  6. package/dist/declarations/src/source/file.d.ts +1 -0
  7. package/dist/declarations/src/val/index.d.ts +4 -4
  8. package/dist/index-316f5dd8.esm.js +4016 -0
  9. package/dist/index-3193efd5.cjs.dev.js +4057 -0
  10. package/dist/index-596f28bb.cjs.prod.js +4057 -0
  11. package/dist/{result-b96df128.esm.js → result-a8316efa.esm.js} +1 -1
  12. package/dist/valbuild-core.cjs.dev.js +29 -1824
  13. package/dist/valbuild-core.cjs.prod.js +29 -1824
  14. package/dist/valbuild-core.esm.js +2 -1804
  15. package/expr/dist/valbuild-core-expr.cjs.dev.js +7 -8
  16. package/expr/dist/valbuild-core-expr.cjs.prod.js +7 -8
  17. package/expr/dist/valbuild-core-expr.esm.js +2 -3
  18. package/fp/dist/valbuild-core-fp.esm.js +1 -1
  19. package/package.json +1 -1
  20. package/patch/dist/valbuild-core-patch.cjs.dev.js +46 -50
  21. package/patch/dist/valbuild-core-patch.cjs.prod.js +46 -50
  22. package/patch/dist/valbuild-core-patch.esm.js +6 -10
  23. package/dist/index-051c34f3.esm.js +0 -539
  24. package/dist/index-0df230ef.cjs.dev.js +0 -572
  25. package/dist/index-2dfaf8f7.cjs.prod.js +0 -643
  26. package/dist/index-e8ab2166.cjs.dev.js +0 -643
  27. package/dist/index-ed5767a3.esm.js +0 -639
  28. package/dist/index-f2552460.cjs.prod.js +0 -572
  29. package/dist/ops-34737ef0.cjs.dev.js +0 -1068
  30. package/dist/ops-92570725.cjs.prod.js +0 -1068
  31. package/dist/ops-9262cf01.esm.js +0 -1044
@@ -1,7 +1,7 @@
1
- import { ApiCommitResponse, ApiGetPatchResponse, ApiPostValidationErrorResponse, ApiPostPatchResponse, ApiPostValidationResponse, ApiTreeResponse, Json } from "./index.js";
1
+ import { ApiCommitResponse, ApiGetPatchResponse, ApiPostValidationErrorResponse, ApiPostValidationResponse, ApiTreeResponse, Json, ApiSchemaResponse } from "./index.js";
2
2
  import { result } from "./fp/index.js";
3
3
  import { Patch } from "./patch/index.js";
4
- import { ModuleId, PatchId } from "./val/index.js";
4
+ import { ModuleFilePath, PatchId } from "./val/index.js";
5
5
  type FetchError = {
6
6
  message: string;
7
7
  details?: unknown;
@@ -13,13 +13,9 @@ export declare class ValApi {
13
13
  getDisableUrl(redirectTo: string): string;
14
14
  getLoginUrl(redirectTo: string): string;
15
15
  getEnableUrl(redirectTo: string): string;
16
- getPatches({ patchIds, headers, }: {
17
- patchIds?: string[];
18
- headers?: Record<string, string> | undefined;
19
- }): Promise<result.Result<ApiGetPatchResponse, FetchError>>;
16
+ getPatches(): Promise<result.Result<ApiGetPatchResponse, FetchError>>;
20
17
  deletePatches(ids: string[], headers?: Record<string, string>): Promise<result.Result<Json, FetchError>>;
21
18
  getEditUrl(): string;
22
- postPatches(moduleId: ModuleId, patches: Patch, headers?: Record<string, string> | undefined): Promise<result.Result<ApiPostPatchResponse, FetchError>>;
23
19
  getSession(): Promise<result.Result<{
24
20
  mode: "proxy" | "local";
25
21
  member_role: "owner" | "developer" | "editor";
@@ -27,19 +23,26 @@ export declare class ValApi {
27
23
  mode: "proxy" | "local";
28
24
  member_role: "owner" | "developer" | "editor";
29
25
  }>>;
30
- getTree({ patch, includeSchema, includeSource, treePath, headers, }: {
31
- patch?: boolean;
32
- includeSchema?: boolean;
33
- includeSource?: boolean;
26
+ getSchema({ headers }: {
27
+ headers?: Record<string, string> | undefined;
28
+ }): Promise<result.Result<ApiSchemaResponse, FetchError>>;
29
+ putTree({ treePath, patchIds, addPatch, validateAll, validateSource, validateBinaryFiles, headers, }: {
34
30
  treePath?: string;
31
+ patchIds?: PatchId[];
32
+ addPatch?: {
33
+ path: ModuleFilePath;
34
+ patch: Patch;
35
+ };
36
+ validateAll?: boolean;
37
+ validateSource?: boolean;
38
+ validateBinaryFiles?: boolean;
35
39
  headers?: Record<string, string> | undefined;
36
40
  }): Promise<result.Result<ApiTreeResponse, FetchError>>;
37
- postCommit({ patches, headers, }: {
38
- patches?: Record<ModuleId, PatchId[]>;
39
- headers?: Record<string, string> | undefined;
41
+ postSave({ patchIds, }: {
42
+ patchIds: PatchId[];
40
43
  }): Promise<result.Result<ApiCommitResponse, FetchError | ApiPostValidationErrorResponse>>;
41
44
  postValidate({ patches, headers, }: {
42
- patches?: Record<ModuleId, PatchId[]>;
45
+ patches?: Record<ModuleFilePath, PatchId[]>;
43
46
  headers?: Record<string, string> | undefined;
44
47
  }): Promise<result.Result<ApiPostValidationResponse | ApiPostValidationErrorResponse, FetchError>>;
45
48
  }
@@ -1,4 +1,5 @@
1
1
  export { initVal } from "./initVal.js";
2
+ export { modules, type ValModules } from "./modules.js";
2
3
  export type { InitVal, ValConfig, ValConstructor, ContentConstructor, } from "./initVal.js";
3
4
  export { Schema, type SerializedSchema, type SelectorOfSchema } from "./schema/index.js";
4
5
  export type { ImageMetadata } from "./schema/image.js";
@@ -11,26 +12,26 @@ export type { RawString } from "./schema/string.js";
11
12
  export type { ImageSource } from "./source/image.js";
12
13
  export { RT_IMAGE_TAG } from "./source/richtext.js";
13
14
  export type { AnyRichTextOptions, Bold, Classes, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, LinkNode, OrderedListNode, ParagraphNode, BrNode, RichText, RichTextNode, RichTextOptions, RichTextSource, RootNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
14
- export { type Val, type SerializedVal, type ModuleId, type PatchId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
15
+ export { type Val, type SerializedVal, type ModuleFilePath, type PatchId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
15
16
  export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
16
17
  export type { ValidationError, ValidationErrors, } from "./schema/validation/ValidationError.js";
17
- import type { ValidationErrors } from "./schema/validation/ValidationError.js";
18
+ import type { ValidationError, ValidationErrors } from "./schema/validation/ValidationError.js";
18
19
  export type { ValidationFix } from "./schema/validation/ValidationFix.js";
19
20
  export * as expr from "./expr/index.js";
20
21
  export { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from "./source/file.js";
21
22
  export { VAL_EXTENSION, type SourceArray } from "./source/index.js";
22
23
  export { derefPatch } from "./patch/deref.js";
23
24
  export { type SelectorSource, type SelectorOf, GenericSelector, } from "./selector/index.js";
24
- import { getSource, resolvePath, splitModuleIdAndModulePath } from "./module.js";
25
+ import { getSource, resolvePath, splitModuleFilePathAndModulePath } from "./module.js";
25
26
  import { getSchema } from "./selector/index.js";
26
- import { ModuleId, ModulePath, PatchId, getValPath, isVal } from "./val/index.js";
27
+ import { ModuleFilePath, ModulePath, PatchId, SourcePath, getValPath, isVal } from "./val/index.js";
27
28
  import { convertFileSource } from "./schema/file.js";
28
29
  import { createValPathOfItem } from "./selector/SelectorProxy.js";
29
30
  import { getVal } from "./future/fetchVal.js";
30
31
  import type { Json } from "./Json.js";
31
- import { SerializedSchema } from "./schema/index.js";
32
- import { Operation, Patch } from "./patch/index.js";
32
+ import { Operation } from "./patch/index.js";
33
33
  import { initSchema } from "./initSchema.js";
34
+ import { SerializedSchema } from "./schema/index.js";
34
35
  export { type SerializedArraySchema, ArraySchema } from "./schema/array.js";
35
36
  export { type SerializedObjectSchema, ObjectSchema } from "./schema/object.js";
36
37
  export { type SerializedRecordSchema, RecordSchema } from "./schema/record.js";
@@ -44,55 +45,48 @@ export { type SerializedUnionSchema, UnionSchema } from "./schema/union.js";
44
45
  export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
45
46
  export { deserializeSchema } from "./schema/deserialize.js";
46
47
  export { ValApi } from "./ValApi.js";
47
- export type ApiCommitResponse = {
48
- validationErrors: false;
49
- modules: Record<ModuleId, {
50
- patches: {
51
- applied: PatchId[];
52
- };
53
- }>;
54
- git: {
55
- commit?: string;
56
- branch?: string;
57
- };
48
+ export type ApiCommitResponse = {};
49
+ export type ApiSchemaResponse = {
50
+ schemaSha: string;
51
+ schemas: Record<ModuleFilePath, SerializedSchema>;
58
52
  };
59
53
  export type ApiTreeResponse = {
60
- git: {
61
- commit?: string;
62
- branch?: string;
63
- };
64
- modules: Record<ModuleId, {
65
- schema?: SerializedSchema;
54
+ schemaSha: string;
55
+ fatalErrors?: ({
56
+ message: string;
57
+ type: "invalid-module-file-path";
58
+ actualModuleFilePath: string;
59
+ expectedModuleFilePath: string;
60
+ } | {
61
+ message: string;
62
+ stack?: string;
63
+ type?: undefined;
64
+ })[];
65
+ modules: Record<ModuleFilePath, {
66
+ source: Json;
66
67
  patches?: {
67
68
  applied: PatchId[];
68
- failed?: PatchId[];
69
- };
70
- source?: Json;
71
- errors?: false | {
72
- invalidModuleId?: ModuleId;
73
- validation?: ValidationErrors;
74
- fatal?: {
69
+ skipped?: PatchId[];
70
+ errors?: Record<PatchId, {
75
71
  message: string;
76
- stack?: string;
77
- type?: string;
78
- }[];
72
+ }>;
79
73
  };
74
+ validationErrors?: Record<SourcePath, ValidationError[]>;
80
75
  }>;
81
76
  };
82
- export type ApiGetPatchResponse = Record<ModuleId, {
83
- patch: Patch;
77
+ export type ApiGetPatchResponse = Record<ModuleFilePath, {
84
78
  patch_id: PatchId;
85
79
  created_at: string;
86
- commit_sha?: string;
80
+ applied_at_base_sha: string | null;
87
81
  author?: string;
88
82
  }[]>;
89
83
  export type ApiDeletePatchResponse = PatchId[];
90
- export type ApiPostPatchResponse = Record<ModuleId, {
84
+ export type ApiPostPatchResponse = Record<ModuleFilePath, {
91
85
  patch_id: PatchId;
92
86
  }>;
93
87
  export type ApiPostValidationResponse = {
94
88
  validationErrors: false;
95
- modules: Record<ModuleId, {
89
+ modules: Record<ModuleFilePath, {
96
90
  patches: {
97
91
  applied: PatchId[];
98
92
  };
@@ -101,16 +95,16 @@ export type ApiPostValidationResponse = {
101
95
  export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
102
96
  export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
103
97
  export type ApiPostValidationErrorResponse = {
104
- modules: Record<ModuleId, {
98
+ modules: Record<ModuleFilePath, {
105
99
  patches: {
106
100
  applied: PatchId[];
107
101
  failed?: PatchId[];
108
102
  };
109
103
  }>;
110
- validationErrors: Record<ModuleId, {
104
+ validationErrors: Record<ModuleFilePath, {
111
105
  source?: Json;
112
106
  errors: {
113
- invalidModuleId?: ModuleId;
107
+ invalidModulePath?: ModuleFilePath;
114
108
  validation?: ValidationErrors;
115
109
  fatal?: {
116
110
  message: string;
@@ -130,11 +124,12 @@ declare const Internal: {
130
124
  getVal: typeof getVal;
131
125
  getSource: typeof getSource;
132
126
  resolvePath: typeof resolvePath;
133
- splitModuleIdAndModulePath: typeof splitModuleIdAndModulePath;
127
+ splitModuleFilePathAndModulePath: typeof splitModuleFilePathAndModulePath;
134
128
  isVal: typeof isVal;
135
129
  createValPathOfItem: typeof createValPathOfItem;
136
130
  getSHA256Hash: (bits: Uint8Array) => string;
137
131
  initSchema: typeof initSchema;
132
+ ModuleFilePathSep: string;
138
133
  notFileOp: (op: Operation) => boolean;
139
134
  isFileOp: (op: Operation) => op is {
140
135
  op: "file";
@@ -17,7 +17,7 @@ export type ValConstructor = {
17
17
  unstable_getPath: typeof getPath;
18
18
  };
19
19
  export type ValConfig = {
20
- remote?: string;
20
+ project?: string;
21
21
  root?: string;
22
22
  gitCommit?: string;
23
23
  gitBranch?: string;
@@ -1,7 +1,7 @@
1
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
- import { ModuleId, ModulePath, SourcePath } from "./val/index.js";
4
+ import { ModuleFilePath, ModulePath, SourcePath } from "./val/index.js";
5
5
  import { Json } from "./Json.js";
6
6
  import { RawString } from "./schema/string.js";
7
7
  import { ImageSelector } from "./selector/image.js";
@@ -20,7 +20,8 @@ type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource exten
20
20
  export declare function define<T extends Schema<SelectorSource>>(id: string, // TODO: `/${string}`
21
21
  schema: T, source: ReplaceRawStringWithString<SelectorOfSchema<T>>): ValModule<SelectorOfSchema<T>>;
22
22
  export declare function getSource(valModule: ValModule<SelectorSource>): Source;
23
- export declare function splitModuleIdAndModulePath(path: SourcePath): [moduleId: ModuleId, path: ModulePath];
23
+ export declare function splitModuleFilePathAndModulePath(path: SourcePath): [moduleId: ModuleFilePath, path: ModulePath];
24
+ export declare const ModuleFilePathSep = "?p=";
24
25
  export declare function getSourceAtPath(modulePath: ModulePath, valModule: ValModule<SelectorSource> | Source): any;
25
26
  export declare function resolvePath<Src extends ValModule<SelectorSource> | Source, Sch extends Schema<SelectorSource> | SerializedSchema>(path: ModulePath, valModule: Src, schema: Sch): {
26
27
  path: SourcePath;
@@ -0,0 +1,30 @@
1
+ import { ValConfig } from "./initVal.js";
2
+ import { ValModule } from "./module.js";
3
+ import { SelectorSource } from "./selector/index.js";
4
+ export type ValModules = {
5
+ config: ValConfig;
6
+ modules: {
7
+ /**
8
+ * A module definition defined as a function that returns a promise that resolves to the module.
9
+ *
10
+ * @example
11
+ * { def: () => import('./module.val') }
12
+ */
13
+ def: () => Promise<{
14
+ default: ValModule<SelectorSource>;
15
+ }>;
16
+ }[];
17
+ };
18
+ /**
19
+ * Define the set of modules that can be edited using the Val UI.
20
+ *
21
+ * @example
22
+ * import { modules } from "@valbuild/next";
23
+ * import { config } from "./val.config";
24
+ *
25
+ * export default modules(config, [
26
+ * { def: () => import("./app/page.val.ts") },
27
+ * { def: () => import("./app/another/page.val.ts") },
28
+ * ]);
29
+ */
30
+ export declare function modules(config: ValConfig, modules: ValModules["modules"]): ValModules;
@@ -16,6 +16,7 @@ export type FileSource<Metadata extends FileMetadata | undefined = FileMetadata
16
16
  readonly [VAL_EXTENSION]: "file";
17
17
  readonly [FILE_REF_SUBTYPE_TAG]?: string;
18
18
  readonly metadata?: Metadata;
19
+ readonly patch_id?: string;
19
20
  };
20
21
  export declare function file<Metadata extends {
21
22
  readonly [key: string]: Json;
@@ -42,13 +42,13 @@ export type ModulePath = string & {
42
42
  [brand]: "ModulePath";
43
43
  };
44
44
  /**
45
- * The id of the module.
45
+ * The path of the module.
46
46
  *
47
47
  * @example
48
- * '/app/blogs' // the /app/blogs module
48
+ * '/app/blogs.val.ts'
49
49
  */
50
- export type ModuleId = string & {
51
- [brand]: "ModuleId";
50
+ export type ModuleFilePath = string & {
51
+ [brand]: "ModuleFilePath";
52
52
  };
53
53
  export type PatchId = string & {
54
54
  [brand]: "PatchId";