@valbuild/core 0.61.0 → 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.
@@ -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
  }
@@ -12,26 +12,26 @@ export type { RawString } from "./schema/string.js";
12
12
  export type { ImageSource } from "./source/image.js";
13
13
  export { RT_IMAGE_TAG } from "./source/richtext.js";
14
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";
15
- 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";
16
16
  export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
17
17
  export type { ValidationError, ValidationErrors, } from "./schema/validation/ValidationError.js";
18
- import type { ValidationErrors } from "./schema/validation/ValidationError.js";
18
+ import type { ValidationError, ValidationErrors } from "./schema/validation/ValidationError.js";
19
19
  export type { ValidationFix } from "./schema/validation/ValidationFix.js";
20
20
  export * as expr from "./expr/index.js";
21
21
  export { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from "./source/file.js";
22
22
  export { VAL_EXTENSION, type SourceArray } from "./source/index.js";
23
23
  export { derefPatch } from "./patch/deref.js";
24
24
  export { type SelectorSource, type SelectorOf, GenericSelector, } from "./selector/index.js";
25
- import { getSource, resolvePath, splitModuleIdAndModulePath } from "./module.js";
25
+ import { getSource, resolvePath, splitModuleFilePathAndModulePath } from "./module.js";
26
26
  import { getSchema } from "./selector/index.js";
27
- import { ModuleId, ModulePath, PatchId, getValPath, isVal } from "./val/index.js";
27
+ import { ModuleFilePath, ModulePath, PatchId, SourcePath, getValPath, isVal } from "./val/index.js";
28
28
  import { convertFileSource } from "./schema/file.js";
29
29
  import { createValPathOfItem } from "./selector/SelectorProxy.js";
30
30
  import { getVal } from "./future/fetchVal.js";
31
31
  import type { Json } from "./Json.js";
32
- import { SerializedSchema } from "./schema/index.js";
33
- import { Operation, Patch } from "./patch/index.js";
32
+ import { Operation } from "./patch/index.js";
34
33
  import { initSchema } from "./initSchema.js";
34
+ import { SerializedSchema } from "./schema/index.js";
35
35
  export { type SerializedArraySchema, ArraySchema } from "./schema/array.js";
36
36
  export { type SerializedObjectSchema, ObjectSchema } from "./schema/object.js";
37
37
  export { type SerializedRecordSchema, RecordSchema } from "./schema/record.js";
@@ -45,55 +45,48 @@ export { type SerializedUnionSchema, UnionSchema } from "./schema/union.js";
45
45
  export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
46
46
  export { deserializeSchema } from "./schema/deserialize.js";
47
47
  export { ValApi } from "./ValApi.js";
48
- export type ApiCommitResponse = {
49
- validationErrors: false;
50
- modules: Record<ModuleId, {
51
- patches: {
52
- applied: PatchId[];
53
- };
54
- }>;
55
- git: {
56
- commit?: string;
57
- branch?: string;
58
- };
48
+ export type ApiCommitResponse = {};
49
+ export type ApiSchemaResponse = {
50
+ schemaSha: string;
51
+ schemas: Record<ModuleFilePath, SerializedSchema>;
59
52
  };
60
53
  export type ApiTreeResponse = {
61
- git: {
62
- commit?: string;
63
- branch?: string;
64
- };
65
- modules: Record<ModuleId, {
66
- 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;
67
67
  patches?: {
68
68
  applied: PatchId[];
69
- failed?: PatchId[];
70
- };
71
- source?: Json;
72
- errors?: false | {
73
- invalidModuleId?: ModuleId;
74
- validation?: ValidationErrors;
75
- fatal?: {
69
+ skipped?: PatchId[];
70
+ errors?: Record<PatchId, {
76
71
  message: string;
77
- stack?: string;
78
- type?: string;
79
- }[];
72
+ }>;
80
73
  };
74
+ validationErrors?: Record<SourcePath, ValidationError[]>;
81
75
  }>;
82
76
  };
83
- export type ApiGetPatchResponse = Record<ModuleId, {
84
- patch: Patch;
77
+ export type ApiGetPatchResponse = Record<ModuleFilePath, {
85
78
  patch_id: PatchId;
86
79
  created_at: string;
87
- commit_sha?: string;
80
+ applied_at_base_sha: string | null;
88
81
  author?: string;
89
82
  }[]>;
90
83
  export type ApiDeletePatchResponse = PatchId[];
91
- export type ApiPostPatchResponse = Record<ModuleId, {
84
+ export type ApiPostPatchResponse = Record<ModuleFilePath, {
92
85
  patch_id: PatchId;
93
86
  }>;
94
87
  export type ApiPostValidationResponse = {
95
88
  validationErrors: false;
96
- modules: Record<ModuleId, {
89
+ modules: Record<ModuleFilePath, {
97
90
  patches: {
98
91
  applied: PatchId[];
99
92
  };
@@ -102,16 +95,16 @@ export type ApiPostValidationResponse = {
102
95
  export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
103
96
  export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
104
97
  export type ApiPostValidationErrorResponse = {
105
- modules: Record<ModuleId, {
98
+ modules: Record<ModuleFilePath, {
106
99
  patches: {
107
100
  applied: PatchId[];
108
101
  failed?: PatchId[];
109
102
  };
110
103
  }>;
111
- validationErrors: Record<ModuleId, {
104
+ validationErrors: Record<ModuleFilePath, {
112
105
  source?: Json;
113
106
  errors: {
114
- invalidModuleId?: ModuleId;
107
+ invalidModulePath?: ModuleFilePath;
115
108
  validation?: ValidationErrors;
116
109
  fatal?: {
117
110
  message: string;
@@ -131,11 +124,12 @@ declare const Internal: {
131
124
  getVal: typeof getVal;
132
125
  getSource: typeof getSource;
133
126
  resolvePath: typeof resolvePath;
134
- splitModuleIdAndModulePath: typeof splitModuleIdAndModulePath;
127
+ splitModuleFilePathAndModulePath: typeof splitModuleFilePathAndModulePath;
135
128
  isVal: typeof isVal;
136
129
  createValPathOfItem: typeof createValPathOfItem;
137
130
  getSHA256Hash: (bits: Uint8Array) => string;
138
131
  initSchema: typeof initSchema;
132
+ ModuleFilePathSep: string;
139
133
  notFileOp: (op: Operation) => boolean;
140
134
  isFileOp: (op: Operation) => op is {
141
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;
@@ -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";