@valbuild/shared 0.121.0 → 0.122.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.
@@ -0,0 +1,257 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The wire shapes for reading history.
4
+ *
5
+ * Here rather than in `@valbuild/server` because both sides of `/api/val` need
6
+ * them: the server builds these and the Studio parses them, and a second
7
+ * hand-written copy in the client is how the two drift.
8
+ *
9
+ * `HistoryError` is a closed union of everything that can go wrong
10
+ * reconstructing a commit - see `packages/server/src/history/HistoryError.ts`
11
+ * for what each one means. It travels as data rather than as a message because
12
+ * the Studio decides what to OFFER from it: a schema mismatch means "cannot
13
+ * restore this field", a missing source means "cannot restore this module at
14
+ * all", and a rendered string cannot be told apart.
15
+ */
16
+ export declare const HistoryError: z.ZodDiscriminatedUnion<[z.ZodObject<{
17
+ kind: z.ZodLiteral<"commit-not-found">;
18
+ commitSha: z.ZodString;
19
+ }, z.core.$strip>, z.ZodObject<{
20
+ kind: z.ZodLiteral<"archive-unreadable">;
21
+ commitSha: z.ZodString;
22
+ message: z.ZodString;
23
+ }, z.core.$strip>, z.ZodObject<{
24
+ kind: z.ZodLiteral<"source-unavailable">;
25
+ moduleFilePath: z.ZodString;
26
+ }, z.core.$strip>, z.ZodObject<{
27
+ kind: z.ZodLiteral<"schema-unreadable">;
28
+ moduleFilePath: z.ZodString;
29
+ message: z.ZodString;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ kind: z.ZodLiteral<"file-unavailable">;
32
+ gitPath: z.ZodString;
33
+ message: z.ZodString;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ kind: z.ZodLiteral<"not-supported-in-fs-mode">;
36
+ }, z.core.$strip>, z.ZodObject<{
37
+ kind: z.ZodLiteral<"transport">;
38
+ message: z.ZodString;
39
+ }, z.core.$strip>], "kind">;
40
+ export type HistoryError = z.infer<typeof HistoryError>;
41
+ export declare const HistoricalCommit: z.ZodObject<{
42
+ commitSha: z.ZodString;
43
+ parentCommitSha: z.ZodString;
44
+ clientCommitSha: z.ZodString;
45
+ branch: z.ZodString;
46
+ createdBranch: z.ZodNullable<z.ZodString>;
47
+ creator: z.ZodNullable<z.ZodString>;
48
+ message: z.ZodNullable<z.ZodString>;
49
+ createdAt: z.ZodString;
50
+ seqNum: z.ZodString;
51
+ patchCount: z.ZodNumber;
52
+ hasArchive: z.ZodBoolean;
53
+ }, z.core.$strip>;
54
+ export type HistoricalCommit = z.infer<typeof HistoricalCommit>;
55
+ /**
56
+ * A binary file the commit touched - named, with a URL, and nothing fetched.
57
+ * Only an `<img src>` that mounts pays for the bytes.
58
+ */
59
+ export declare const BinaryFileRef: z.ZodObject<{
60
+ gitPath: z.ZodString;
61
+ change: z.ZodUnion<readonly [z.ZodLiteral<"added">, z.ZodLiteral<"modified">, z.ZodLiteral<"deleted">]>;
62
+ remote: z.ZodBoolean;
63
+ url: z.ZodString;
64
+ }, z.core.$strip>;
65
+ export type BinaryFileRef = z.infer<typeof BinaryFileRef>;
66
+ export declare const HistoricalModule: z.ZodObject<{
67
+ source: z.ZodNullable<z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>>;
68
+ schema: z.ZodNullable<z.ZodType<import("@valbuild/core").SerializedSchema, unknown, z.core.$ZodTypeInternals<import("@valbuild/core").SerializedSchema, unknown>>>;
69
+ patchIds: z.ZodArray<z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>>;
70
+ changedPaths: z.ZodArray<z.ZodString>;
71
+ failures: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
72
+ kind: z.ZodLiteral<"commit-not-found">;
73
+ commitSha: z.ZodString;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ kind: z.ZodLiteral<"archive-unreadable">;
76
+ commitSha: z.ZodString;
77
+ message: z.ZodString;
78
+ }, z.core.$strip>, z.ZodObject<{
79
+ kind: z.ZodLiteral<"source-unavailable">;
80
+ moduleFilePath: z.ZodString;
81
+ }, z.core.$strip>, z.ZodObject<{
82
+ kind: z.ZodLiteral<"schema-unreadable">;
83
+ moduleFilePath: z.ZodString;
84
+ message: z.ZodString;
85
+ }, z.core.$strip>, z.ZodObject<{
86
+ kind: z.ZodLiteral<"file-unavailable">;
87
+ gitPath: z.ZodString;
88
+ message: z.ZodString;
89
+ }, z.core.$strip>, z.ZodObject<{
90
+ kind: z.ZodLiteral<"not-supported-in-fs-mode">;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ kind: z.ZodLiteral<"transport">;
93
+ message: z.ZodString;
94
+ }, z.core.$strip>], "kind">>;
95
+ }, z.core.$strip>;
96
+ export type HistoricalModule = z.infer<typeof HistoricalModule>;
97
+ export declare const HistoricalPatchSet: z.ZodObject<{
98
+ commit: z.ZodObject<{
99
+ commitSha: z.ZodString;
100
+ parentCommitSha: z.ZodString;
101
+ clientCommitSha: z.ZodString;
102
+ branch: z.ZodString;
103
+ createdBranch: z.ZodNullable<z.ZodString>;
104
+ creator: z.ZodNullable<z.ZodString>;
105
+ message: z.ZodNullable<z.ZodString>;
106
+ createdAt: z.ZodString;
107
+ seqNum: z.ZodString;
108
+ patchCount: z.ZodNumber;
109
+ hasArchive: z.ZodBoolean;
110
+ }, z.core.$strip>;
111
+ modules: z.ZodRecord<z.ZodString, z.ZodObject<{
112
+ source: z.ZodNullable<z.ZodType<import("@valbuild/core/patch").JSONValue, unknown, z.core.$ZodTypeInternals<import("@valbuild/core/patch").JSONValue, unknown>>>;
113
+ schema: z.ZodNullable<z.ZodType<import("@valbuild/core").SerializedSchema, unknown, z.core.$ZodTypeInternals<import("@valbuild/core").SerializedSchema, unknown>>>;
114
+ patchIds: z.ZodArray<z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>>;
115
+ changedPaths: z.ZodArray<z.ZodString>;
116
+ failures: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
117
+ kind: z.ZodLiteral<"commit-not-found">;
118
+ commitSha: z.ZodString;
119
+ }, z.core.$strip>, z.ZodObject<{
120
+ kind: z.ZodLiteral<"archive-unreadable">;
121
+ commitSha: z.ZodString;
122
+ message: z.ZodString;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ kind: z.ZodLiteral<"source-unavailable">;
125
+ moduleFilePath: z.ZodString;
126
+ }, z.core.$strip>, z.ZodObject<{
127
+ kind: z.ZodLiteral<"schema-unreadable">;
128
+ moduleFilePath: z.ZodString;
129
+ message: z.ZodString;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ kind: z.ZodLiteral<"file-unavailable">;
132
+ gitPath: z.ZodString;
133
+ message: z.ZodString;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ kind: z.ZodLiteral<"not-supported-in-fs-mode">;
136
+ }, z.core.$strip>, z.ZodObject<{
137
+ kind: z.ZodLiteral<"transport">;
138
+ message: z.ZodString;
139
+ }, z.core.$strip>], "kind">>;
140
+ }, z.core.$strip>>;
141
+ patches: z.ZodArray<z.ZodObject<{
142
+ patchId: z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>;
143
+ moduleFilePath: z.ZodString;
144
+ patch: z.ZodUnknown;
145
+ authorId: z.ZodNullable<z.ZodString>;
146
+ createdAt: z.ZodString;
147
+ baseSha: z.ZodString;
148
+ coreVersion: z.ZodString;
149
+ }, z.core.$strip>>;
150
+ jsonEntries: z.ZodRecord<z.ZodString, z.ZodUnknown>;
151
+ binaryFiles: z.ZodArray<z.ZodObject<{
152
+ gitPath: z.ZodString;
153
+ change: z.ZodUnion<readonly [z.ZodLiteral<"added">, z.ZodLiteral<"modified">, z.ZodLiteral<"deleted">]>;
154
+ remote: z.ZodBoolean;
155
+ url: z.ZodString;
156
+ }, z.core.$strip>>;
157
+ warnings: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
158
+ kind: z.ZodLiteral<"commit-not-found">;
159
+ commitSha: z.ZodString;
160
+ }, z.core.$strip>, z.ZodObject<{
161
+ kind: z.ZodLiteral<"archive-unreadable">;
162
+ commitSha: z.ZodString;
163
+ message: z.ZodString;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ kind: z.ZodLiteral<"source-unavailable">;
166
+ moduleFilePath: z.ZodString;
167
+ }, z.core.$strip>, z.ZodObject<{
168
+ kind: z.ZodLiteral<"schema-unreadable">;
169
+ moduleFilePath: z.ZodString;
170
+ message: z.ZodString;
171
+ }, z.core.$strip>, z.ZodObject<{
172
+ kind: z.ZodLiteral<"file-unavailable">;
173
+ gitPath: z.ZodString;
174
+ message: z.ZodString;
175
+ }, z.core.$strip>, z.ZodObject<{
176
+ kind: z.ZodLiteral<"not-supported-in-fs-mode">;
177
+ }, z.core.$strip>, z.ZodObject<{
178
+ kind: z.ZodLiteral<"transport">;
179
+ message: z.ZodString;
180
+ }, z.core.$strip>], "kind">>;
181
+ }, z.core.$strip>;
182
+ export type HistoricalPatchSet = z.infer<typeof HistoricalPatchSet>;
183
+ /**
184
+ * Whether the historical value can be written back as the project stands.
185
+ *
186
+ * Computed in the Studio, not on the server: the verdict depends on the current
187
+ * source and the current schema, both of which the client already holds, and it
188
+ * runs against the same worker-thread validator that validates ordinary edits.
189
+ * The types stay here because they are what a restore preview hands to the UI.
190
+ *
191
+ * `blocked` carries its reasons so a refusal can name the field and say why,
192
+ * rather than being an unexplained disabled button.
193
+ */
194
+ export declare const RestoreVerdict: z.ZodUnion<readonly [z.ZodObject<{
195
+ status: z.ZodLiteral<"restorable">;
196
+ }, z.core.$strip>, z.ZodObject<{
197
+ status: z.ZodLiteral<"blocked">;
198
+ reasons: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
199
+ kind: z.ZodLiteral<"commit-not-found">;
200
+ commitSha: z.ZodString;
201
+ }, z.core.$strip>, z.ZodObject<{
202
+ kind: z.ZodLiteral<"archive-unreadable">;
203
+ commitSha: z.ZodString;
204
+ message: z.ZodString;
205
+ }, z.core.$strip>, z.ZodObject<{
206
+ kind: z.ZodLiteral<"source-unavailable">;
207
+ moduleFilePath: z.ZodString;
208
+ }, z.core.$strip>, z.ZodObject<{
209
+ kind: z.ZodLiteral<"schema-unreadable">;
210
+ moduleFilePath: z.ZodString;
211
+ message: z.ZodString;
212
+ }, z.core.$strip>, z.ZodObject<{
213
+ kind: z.ZodLiteral<"file-unavailable">;
214
+ gitPath: z.ZodString;
215
+ message: z.ZodString;
216
+ }, z.core.$strip>, z.ZodObject<{
217
+ kind: z.ZodLiteral<"not-supported-in-fs-mode">;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ kind: z.ZodLiteral<"transport">;
220
+ message: z.ZodString;
221
+ }, z.core.$strip>], "kind">>;
222
+ }, z.core.$strip>]>;
223
+ export type RestoreVerdict = z.infer<typeof RestoreVerdict>;
224
+ export declare const ModuleComparison: z.ZodObject<{
225
+ current: z.ZodNullable<z.ZodUnknown>;
226
+ changedVsCurrent: z.ZodArray<z.ZodString>;
227
+ verdict: z.ZodUnion<readonly [z.ZodObject<{
228
+ status: z.ZodLiteral<"restorable">;
229
+ }, z.core.$strip>, z.ZodObject<{
230
+ status: z.ZodLiteral<"blocked">;
231
+ reasons: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
232
+ kind: z.ZodLiteral<"commit-not-found">;
233
+ commitSha: z.ZodString;
234
+ }, z.core.$strip>, z.ZodObject<{
235
+ kind: z.ZodLiteral<"archive-unreadable">;
236
+ commitSha: z.ZodString;
237
+ message: z.ZodString;
238
+ }, z.core.$strip>, z.ZodObject<{
239
+ kind: z.ZodLiteral<"source-unavailable">;
240
+ moduleFilePath: z.ZodString;
241
+ }, z.core.$strip>, z.ZodObject<{
242
+ kind: z.ZodLiteral<"schema-unreadable">;
243
+ moduleFilePath: z.ZodString;
244
+ message: z.ZodString;
245
+ }, z.core.$strip>, z.ZodObject<{
246
+ kind: z.ZodLiteral<"file-unavailable">;
247
+ gitPath: z.ZodString;
248
+ message: z.ZodString;
249
+ }, z.core.$strip>, z.ZodObject<{
250
+ kind: z.ZodLiteral<"not-supported-in-fs-mode">;
251
+ }, z.core.$strip>, z.ZodObject<{
252
+ kind: z.ZodLiteral<"transport">;
253
+ message: z.ZodString;
254
+ }, z.core.$strip>], "kind">>;
255
+ }, z.core.$strip>]>;
256
+ }, z.core.$strip>;
257
+ export type ModuleComparison = z.infer<typeof ModuleComparison>;
@@ -1,6 +1,13 @@
1
1
  import type { JSONValue as JSONValueT, PatchJSON as PatchJSONT, PatchBlock as PatchBlockT, ParentRef as ParentRefT } from "@valbuild/core/patch";
2
2
  import type { PatchId as PatchIdT } from "@valbuild/core";
3
3
  import { z } from "zod";
4
+ /**
5
+ * JSON, recursively — the shape of a Source over the wire.
6
+ *
7
+ * Exported because history reads stored Sources back and needs the same
8
+ * definition; a second copy is a second thing to keep in step.
9
+ */
10
+ export declare const JSONValue: z.ZodType<JSONValueT>;
4
11
  export declare const PatchJSON: z.ZodType<PatchJSONT>;
5
12
  export type PatchJSON = PatchJSONT;
6
13
  export declare const Patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { type SerializedSchema as SerializedSchemaT, type SerializedStringSchema as SerializedStringSchemaT, type SerializedLiteralSchema as SerializedLiteralSchemaT, type SerializedBooleanSchema as SerializedBooleanSchemaT, type SerializedNumberSchema as SerializedNumberSchemaT, type SerializedObjectSchema as SerializedObjectSchemaT, type SerializedArraySchema as SerializedArraySchemaT, type SerializedUnionSchema as SerializedUnionSchemaT, type SerializedRichTextSchema as SerializedRichTextSchemaT, type SerializedRichTextOptions as SerializedRichTextOptionsT, type SerializedRecordSchema as SerializedRecordSchemaT, type SerializedKeyOfSchema as SerializedKeyOfSchemaT, type SerializedRouteSchema as SerializedRouteSchemaT, type SerializedFileSchema as SerializedFileSchemaT, type SerializedDateSchema as SerializedDateSchemaT, type SerializedDateTimeSchema as SerializedDateTimeSchemaT, type SerializedColorSchema as SerializedColorSchemaT, type SerializedCodeSchema as SerializedCodeSchemaT, type SerializedImageSchema as SerializedImageSchemaT } from "@valbuild/core";
2
+ import { type SerializedSchema as SerializedSchemaT, type SerializedStringSchema as SerializedStringSchemaT, type SerializedLiteralSchema as SerializedLiteralSchemaT, type SerializedBooleanSchema as SerializedBooleanSchemaT, type SerializedNumberSchema as SerializedNumberSchemaT, type SerializedObjectSchema as SerializedObjectSchemaT, type SerializedArraySchema as SerializedArraySchemaT, type SerializedUnionSchema as SerializedUnionSchemaT, type SerializedRichTextSchema as SerializedRichTextSchemaT, type SerializedRichTextOptions as SerializedRichTextOptionsT, type SerializedRecordSchema as SerializedRecordSchemaT, type SerializedKeyOfSchema as SerializedKeyOfSchemaT, type SerializedRouteSchema as SerializedRouteSchemaT, type SerializedFileSchema as SerializedFileSchemaT, type SerializedDateSchema as SerializedDateSchemaT, type SerializedDateTimeSchema as SerializedDateTimeSchemaT, type SerializedColorSchema as SerializedColorSchemaT, type SerializedCodeSchema as SerializedCodeSchemaT, type SerializedImageSchema as SerializedImageSchemaT, type SerializedSettingsSchema as SerializedSettingsSchemaT } from "@valbuild/core";
3
3
  export declare const SerializedStringSchema: z.ZodType<SerializedStringSchemaT>;
4
4
  export declare const SerializedLiteralSchema: z.ZodType<SerializedLiteralSchemaT>;
5
5
  export declare const SerializedBooleanSchema: z.ZodType<SerializedBooleanSchemaT>;
@@ -73,4 +73,5 @@ export declare const CodeOptions: z.ZodObject<{
73
73
  }, z.core.$strip>;
74
74
  export declare const SerializedCodeSchema: z.ZodType<SerializedCodeSchemaT>;
75
75
  export declare const SerializedRouteSchema: z.ZodType<SerializedRouteSchemaT>;
76
+ export declare const SerializedSettingsSchema: z.ZodType<SerializedSettingsSchemaT>;
76
77
  export declare const SerializedSchema: z.ZodType<SerializedSchemaT>;