@valbuild/shared 0.144.5 → 0.145.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/CHANGELOG.md +47 -0
- package/dist/declarations/src/internal/ApiRoutes.d.ts +122 -112
- package/dist/declarations/src/internal/server/types.d.ts +3 -3
- package/dist/declarations/src/internal/zod/History.d.ts +5 -5
- package/dist/declarations/src/internal/zod/Patch.d.ts +0 -1
- package/dist/declarations/src/internal/zod/SerializedSchema.d.ts +1 -1
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +74 -9
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +74 -9
- package/internal/dist/valbuild-shared-internal.esm.js +74 -10
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Json } from "@valbuild/core";
|
|
2
|
-
export declare const VAL_SESSION_COOKIE:
|
|
3
|
-
export declare const VAL_STATE_COOKIE:
|
|
4
|
-
export declare const VAL_ENABLE_COOKIE_NAME:
|
|
2
|
+
export declare const VAL_SESSION_COOKIE: any;
|
|
3
|
+
export declare const VAL_STATE_COOKIE: any;
|
|
4
|
+
export declare const VAL_ENABLE_COOKIE_NAME: any;
|
|
5
5
|
export type VAL_SESSION_COOKIE = typeof VAL_SESSION_COOKIE;
|
|
6
6
|
export type VAL_STATE_COOKIE = typeof VAL_STATE_COOKIE;
|
|
7
7
|
export type VAL_ENABLE_COOKIE_NAME = typeof VAL_ENABLE_COOKIE_NAME;
|
|
@@ -65,8 +65,8 @@ export declare const BinaryFileRef: z.ZodObject<{
|
|
|
65
65
|
export type BinaryFileRef = z.infer<typeof BinaryFileRef>;
|
|
66
66
|
export declare const HistoricalModule: z.ZodObject<{
|
|
67
67
|
source: z.ZodNullable<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
|
|
68
|
-
schema: z.ZodNullable<z.ZodType<
|
|
69
|
-
patchIds: z.ZodArray<z.ZodString & z.ZodType<
|
|
68
|
+
schema: z.ZodNullable<z.ZodType<SerializedSchemaT, unknown, z.core.$ZodTypeInternals<SerializedSchemaT, unknown>>>;
|
|
69
|
+
patchIds: z.ZodArray<z.ZodString & z.ZodType<PatchIdT, string, z.core.$ZodTypeInternals<PatchIdT, string>>>;
|
|
70
70
|
changedPaths: z.ZodArray<z.ZodString>;
|
|
71
71
|
failures: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
72
72
|
kind: z.ZodLiteral<"commit-not-found">;
|
|
@@ -110,8 +110,8 @@ export declare const HistoricalPatchSet: z.ZodObject<{
|
|
|
110
110
|
}, z.core.$strip>;
|
|
111
111
|
modules: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
112
112
|
source: z.ZodNullable<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
|
|
113
|
-
schema: z.ZodNullable<z.ZodType<
|
|
114
|
-
patchIds: z.ZodArray<z.ZodString & z.ZodType<
|
|
113
|
+
schema: z.ZodNullable<z.ZodType<SerializedSchemaT, unknown, z.core.$ZodTypeInternals<SerializedSchemaT, unknown>>>;
|
|
114
|
+
patchIds: z.ZodArray<z.ZodString & z.ZodType<PatchIdT, string, z.core.$ZodTypeInternals<PatchIdT, string>>>;
|
|
115
115
|
changedPaths: z.ZodArray<z.ZodString>;
|
|
116
116
|
failures: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
117
117
|
kind: z.ZodLiteral<"commit-not-found">;
|
|
@@ -139,7 +139,7 @@ export declare const HistoricalPatchSet: z.ZodObject<{
|
|
|
139
139
|
}, z.core.$strip>], "kind">>;
|
|
140
140
|
}, z.core.$strip>>;
|
|
141
141
|
patches: z.ZodArray<z.ZodObject<{
|
|
142
|
-
patchId: z.ZodString & z.ZodType<
|
|
142
|
+
patchId: z.ZodString & z.ZodType<PatchIdT, string, z.core.$ZodTypeInternals<PatchIdT, string>>;
|
|
143
143
|
moduleFilePath: z.ZodString;
|
|
144
144
|
patch: z.ZodUnknown;
|
|
145
145
|
authorId: z.ZodNullable<z.ZodString>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { JSONValue as JSONValueT, PatchJSON as PatchJSONT, PatchBlock as PatchBlockT, ParentRef as ParentRefT } from "@valbuild/core/patch";
|
|
2
|
-
import type { PatchId as PatchIdT } from "@valbuild/core";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
/**
|
|
5
4
|
* JSON, recursively — the shape of a Source over the wire.
|
|
@@ -83,7 +83,7 @@ export declare const SerializedSettingsSchema: z.ZodType<SerializedSettingsSchem
|
|
|
83
83
|
*/
|
|
84
84
|
export declare const SerializedValViewSchema: z.ZodObject<{
|
|
85
85
|
type: z.ZodLiteral<"view">;
|
|
86
|
-
moduleFilePath: z.ZodType<
|
|
86
|
+
moduleFilePath: z.ZodType<ModuleFilePathT, unknown, z.core.$ZodTypeInternals<ModuleFilePathT, unknown>>;
|
|
87
87
|
opt: z.ZodLiteral<false>;
|
|
88
88
|
readonly: z.ZodOptional<z.ZodBoolean>;
|
|
89
89
|
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1086,8 +1086,8 @@ var _excluded = ["directory"];
|
|
|
1086
1086
|
|
|
1087
1087
|
// A render is static config, so unlike a `preview` it travels WHOLE — this
|
|
1088
1088
|
// is the field the editor reads the layout from. See `core/src/render.ts`.
|
|
1089
|
-
//
|
|
1090
|
-
//
|
|
1089
|
+
// Array, record and keyOf carry `{ as: "inline" }`; number carries
|
|
1090
|
+
// `{ as: "slider", ... }`. A stale `render` on any other schema is stripped here, harmlessly.
|
|
1091
1091
|
// NB: these z.objects STRIP unknown keys, so a render variant that is not
|
|
1092
1092
|
// declared here is silently dropped in transit — add it here when it is added
|
|
1093
1093
|
// to `render.ts`.
|
|
@@ -1095,6 +1095,13 @@ var InlineRender = zod.z.object({
|
|
|
1095
1095
|
as: zod.z.literal("inline")
|
|
1096
1096
|
});
|
|
1097
1097
|
var FieldRender = InlineRender.optional();
|
|
1098
|
+
// The other render, and the only one a leaf takes: `s.number()` / `s.int()`.
|
|
1099
|
+
var NumberRender = zod.z.object({
|
|
1100
|
+
as: zod.z.literal("slider"),
|
|
1101
|
+
min: zod.z.number(),
|
|
1102
|
+
max: zod.z.number(),
|
|
1103
|
+
step: zod.z.number().optional()
|
|
1104
|
+
}).optional();
|
|
1098
1105
|
|
|
1099
1106
|
/**
|
|
1100
1107
|
* The fields EVERY serialized schema carries, in one place.
|
|
@@ -1154,8 +1161,11 @@ var SerializedNumberSchema = zod.z.object(getSitemapTree._objectSpread2(getSitem
|
|
|
1154
1161
|
type: zod.z.literal("number"),
|
|
1155
1162
|
options: zod.z.object({
|
|
1156
1163
|
max: zod.z.number().optional(),
|
|
1157
|
-
min: zod.z.number().optional()
|
|
1164
|
+
min: zod.z.number().optional(),
|
|
1165
|
+
integer: zod.z["boolean"]().optional(),
|
|
1166
|
+
step: zod.z.number().optional()
|
|
1158
1167
|
}).optional(),
|
|
1168
|
+
render: NumberRender,
|
|
1159
1169
|
opt: zod.z["boolean"]()
|
|
1160
1170
|
}));
|
|
1161
1171
|
var SerializedObjectSchema = zod.z.lazy(function () {
|
|
@@ -1628,7 +1638,22 @@ var notFoundResponse = zod.z.object({
|
|
|
1628
1638
|
var GenericError = zod.z.object({
|
|
1629
1639
|
message: zod.z.string()
|
|
1630
1640
|
});
|
|
1631
|
-
|
|
1641
|
+
/**
|
|
1642
|
+
* Why Val Build refused a write for the project's plan, as data: the `error` of
|
|
1643
|
+
* its 403 (`refusalError` in valbuild/home's `billing/projectLimits.ts`).
|
|
1644
|
+
*
|
|
1645
|
+
* Every field but `code` is optional and every field is a plain string, so a
|
|
1646
|
+
* newer Val Build that adds a code or a fix still parses: the Studio says an
|
|
1647
|
+
* unknown one with Billing beside it rather than failing to read the answer.
|
|
1648
|
+
*/
|
|
1649
|
+
var PlanRefusalError = zod.z.object({
|
|
1650
|
+
code: zod.z.string(),
|
|
1651
|
+
fix: zod.z.string().optional(),
|
|
1652
|
+
/** When it lifts by itself, as an ISO time, if it does. */
|
|
1653
|
+
until: zod.z.string().optional(),
|
|
1654
|
+
/** The organization's Billing in Val Build. */
|
|
1655
|
+
billingUrl: zod.z.string().optional()
|
|
1656
|
+
});
|
|
1632
1657
|
/**
|
|
1633
1658
|
* The header a request to `/admin/proxy` must carry. A cross-site form or
|
|
1634
1659
|
* `<img>` cannot set a custom header, so without it the proxy cannot be driven
|
|
@@ -2156,7 +2181,13 @@ var Api = {
|
|
|
2156
2181
|
* on the site. What the Studio's switcher says it is in, and
|
|
2157
2182
|
* where its Save goes (valbuild/home `docs/proposals.md`).
|
|
2158
2183
|
*/
|
|
2159
|
-
proposal: StatProposal.optional()
|
|
2184
|
+
proposal: StatProposal.optional(),
|
|
2185
|
+
/**
|
|
2186
|
+
* The branch History lists: the proposal's in a proposal, else
|
|
2187
|
+
* the git mirror's or the one content reports for the project.
|
|
2188
|
+
* Absent where there is no history to show.
|
|
2189
|
+
*/
|
|
2190
|
+
historyBranch: zod.z.string().optional()
|
|
2160
2191
|
}), zod.z.object({
|
|
2161
2192
|
type: zod.z.literal("use-websocket"),
|
|
2162
2193
|
url: zod.z.string(),
|
|
@@ -2286,7 +2317,13 @@ var Api = {
|
|
|
2286
2317
|
* on the site. What the Studio's switcher says it is in, and
|
|
2287
2318
|
* where its Save goes (valbuild/home `docs/proposals.md`).
|
|
2288
2319
|
*/
|
|
2289
|
-
proposal: StatProposal.optional()
|
|
2320
|
+
proposal: StatProposal.optional(),
|
|
2321
|
+
/**
|
|
2322
|
+
* The branch History lists: the proposal's in a proposal, else
|
|
2323
|
+
* the git mirror's or the one content reports for the project.
|
|
2324
|
+
* Absent where there is no history to show.
|
|
2325
|
+
*/
|
|
2326
|
+
historyBranch: zod.z.string().optional()
|
|
2290
2327
|
})])
|
|
2291
2328
|
})])
|
|
2292
2329
|
}
|
|
@@ -2613,6 +2650,29 @@ var Api = {
|
|
|
2613
2650
|
error: GenericError
|
|
2614
2651
|
})))
|
|
2615
2652
|
})
|
|
2653
|
+
}),
|
|
2654
|
+
/*
|
|
2655
|
+
* Val Build refused the write for the project's plan: the Free week's
|
|
2656
|
+
* changes are used, or a trial is over. Not the 400 above, because the
|
|
2657
|
+
* patches are fine -- they are kept, and saved once the plan allows.
|
|
2658
|
+
* `message` is Val Build's own sentence and `error` the same as data,
|
|
2659
|
+
* so the Studio can put the fix beside it.
|
|
2660
|
+
*
|
|
2661
|
+
* The patches of the batch BEFORE the refused one were saved (the Free
|
|
2662
|
+
* week can run out mid-batch), so this carries what a 200 does about
|
|
2663
|
+
* them: the client marks those saved and keeps the rest.
|
|
2664
|
+
*/
|
|
2665
|
+
zod.z.object({
|
|
2666
|
+
status: zod.z.literal(403),
|
|
2667
|
+
json: zod.z.object({
|
|
2668
|
+
type: zod.z.literal("plan-refused"),
|
|
2669
|
+
message: zod.z.string(),
|
|
2670
|
+
error: PlanRefusalError,
|
|
2671
|
+
newPatchIds: zod.z.array(PatchId),
|
|
2672
|
+
parentRef: ParentRef,
|
|
2673
|
+
patchGroupId: zod.z.string().optional(),
|
|
2674
|
+
headVersion: zod.z.number().optional()
|
|
2675
|
+
})
|
|
2616
2676
|
}), zod.z.object({
|
|
2617
2677
|
status: zod.z.literal(200),
|
|
2618
2678
|
json: zod.z.object({
|
|
@@ -5557,7 +5617,11 @@ function emptyOf(schema, context) {
|
|
|
5557
5617
|
} else if (schema.type === "boolean") {
|
|
5558
5618
|
return false;
|
|
5559
5619
|
} else if (schema.type === "number") {
|
|
5560
|
-
|
|
5620
|
+
var _Internal$number$near, _schema$options;
|
|
5621
|
+
// 0, unless the schema rules it out: an `s.int().min(1)` starts at 1
|
|
5622
|
+
// rather than as an error. `null` means the schema allows nothing at all,
|
|
5623
|
+
// which validation will say; 0 is as good a start as any for that.
|
|
5624
|
+
return (_Internal$number$near = core.Internal.number.nearestAllowedNumber(0, (_schema$options = schema.options) !== null && _schema$options !== void 0 ? _schema$options : {})) !== null && _Internal$number$near !== void 0 ? _Internal$number$near : 0;
|
|
5561
5625
|
} else if (schema.type === "keyOf") {
|
|
5562
5626
|
if (schema.values === "string") {
|
|
5563
5627
|
return ""; // TODO: figure out this: user code might very well fail in this case
|
|
@@ -5599,14 +5663,14 @@ function emptyOf(schema, context) {
|
|
|
5599
5663
|
} else if (schema.type === "dateTime") {
|
|
5600
5664
|
return clampDateTimeString(new Date().toISOString(), schema.options);
|
|
5601
5665
|
} else if (schema.type === "color") {
|
|
5602
|
-
var _schema$options$forma, _schema$
|
|
5666
|
+
var _schema$options$forma, _schema$options2;
|
|
5603
5667
|
// Mid grey: visible against both a light and a dark canvas
|
|
5604
5668
|
return core.Internal.color.formatColor({
|
|
5605
5669
|
r: 128,
|
|
5606
5670
|
g: 128,
|
|
5607
5671
|
b: 128,
|
|
5608
5672
|
a: 1
|
|
5609
|
-
}, (_schema$options$forma = (_schema$
|
|
5673
|
+
}, (_schema$options$forma = (_schema$options2 = schema.options) === null || _schema$options2 === void 0 ? void 0 : _schema$options2.format) !== null && _schema$options$forma !== void 0 ? _schema$options$forma : core.DEFAULT_COLOR_FORMAT);
|
|
5610
5674
|
} else if (schema.type === "code") {
|
|
5611
5675
|
return ""; // An empty editor: no language has a sensible starting snippet
|
|
5612
5676
|
} else if (schema.type === "view") {
|
|
@@ -8057,6 +8121,7 @@ exports.PatchBlock = PatchBlock;
|
|
|
8057
8121
|
exports.PatchGroup = PatchGroup;
|
|
8058
8122
|
exports.PatchId = PatchId;
|
|
8059
8123
|
exports.PatchJSON = PatchJSON;
|
|
8124
|
+
exports.PlanRefusalError = PlanRefusalError;
|
|
8060
8125
|
exports.PublishProtocolError = PublishProtocolError;
|
|
8061
8126
|
exports.RAMP_STEPS = RAMP_STEPS;
|
|
8062
8127
|
exports.RemirrorBr = RemirrorBr;
|
|
@@ -1086,8 +1086,8 @@ var _excluded = ["directory"];
|
|
|
1086
1086
|
|
|
1087
1087
|
// A render is static config, so unlike a `preview` it travels WHOLE — this
|
|
1088
1088
|
// is the field the editor reads the layout from. See `core/src/render.ts`.
|
|
1089
|
-
//
|
|
1090
|
-
//
|
|
1089
|
+
// Array, record and keyOf carry `{ as: "inline" }`; number carries
|
|
1090
|
+
// `{ as: "slider", ... }`. A stale `render` on any other schema is stripped here, harmlessly.
|
|
1091
1091
|
// NB: these z.objects STRIP unknown keys, so a render variant that is not
|
|
1092
1092
|
// declared here is silently dropped in transit — add it here when it is added
|
|
1093
1093
|
// to `render.ts`.
|
|
@@ -1095,6 +1095,13 @@ var InlineRender = zod.z.object({
|
|
|
1095
1095
|
as: zod.z.literal("inline")
|
|
1096
1096
|
});
|
|
1097
1097
|
var FieldRender = InlineRender.optional();
|
|
1098
|
+
// The other render, and the only one a leaf takes: `s.number()` / `s.int()`.
|
|
1099
|
+
var NumberRender = zod.z.object({
|
|
1100
|
+
as: zod.z.literal("slider"),
|
|
1101
|
+
min: zod.z.number(),
|
|
1102
|
+
max: zod.z.number(),
|
|
1103
|
+
step: zod.z.number().optional()
|
|
1104
|
+
}).optional();
|
|
1098
1105
|
|
|
1099
1106
|
/**
|
|
1100
1107
|
* The fields EVERY serialized schema carries, in one place.
|
|
@@ -1154,8 +1161,11 @@ var SerializedNumberSchema = zod.z.object(getSitemapTree._objectSpread2(getSitem
|
|
|
1154
1161
|
type: zod.z.literal("number"),
|
|
1155
1162
|
options: zod.z.object({
|
|
1156
1163
|
max: zod.z.number().optional(),
|
|
1157
|
-
min: zod.z.number().optional()
|
|
1164
|
+
min: zod.z.number().optional(),
|
|
1165
|
+
integer: zod.z["boolean"]().optional(),
|
|
1166
|
+
step: zod.z.number().optional()
|
|
1158
1167
|
}).optional(),
|
|
1168
|
+
render: NumberRender,
|
|
1159
1169
|
opt: zod.z["boolean"]()
|
|
1160
1170
|
}));
|
|
1161
1171
|
var SerializedObjectSchema = zod.z.lazy(function () {
|
|
@@ -1628,7 +1638,22 @@ var notFoundResponse = zod.z.object({
|
|
|
1628
1638
|
var GenericError = zod.z.object({
|
|
1629
1639
|
message: zod.z.string()
|
|
1630
1640
|
});
|
|
1631
|
-
|
|
1641
|
+
/**
|
|
1642
|
+
* Why Val Build refused a write for the project's plan, as data: the `error` of
|
|
1643
|
+
* its 403 (`refusalError` in valbuild/home's `billing/projectLimits.ts`).
|
|
1644
|
+
*
|
|
1645
|
+
* Every field but `code` is optional and every field is a plain string, so a
|
|
1646
|
+
* newer Val Build that adds a code or a fix still parses: the Studio says an
|
|
1647
|
+
* unknown one with Billing beside it rather than failing to read the answer.
|
|
1648
|
+
*/
|
|
1649
|
+
var PlanRefusalError = zod.z.object({
|
|
1650
|
+
code: zod.z.string(),
|
|
1651
|
+
fix: zod.z.string().optional(),
|
|
1652
|
+
/** When it lifts by itself, as an ISO time, if it does. */
|
|
1653
|
+
until: zod.z.string().optional(),
|
|
1654
|
+
/** The organization's Billing in Val Build. */
|
|
1655
|
+
billingUrl: zod.z.string().optional()
|
|
1656
|
+
});
|
|
1632
1657
|
/**
|
|
1633
1658
|
* The header a request to `/admin/proxy` must carry. A cross-site form or
|
|
1634
1659
|
* `<img>` cannot set a custom header, so without it the proxy cannot be driven
|
|
@@ -2156,7 +2181,13 @@ var Api = {
|
|
|
2156
2181
|
* on the site. What the Studio's switcher says it is in, and
|
|
2157
2182
|
* where its Save goes (valbuild/home `docs/proposals.md`).
|
|
2158
2183
|
*/
|
|
2159
|
-
proposal: StatProposal.optional()
|
|
2184
|
+
proposal: StatProposal.optional(),
|
|
2185
|
+
/**
|
|
2186
|
+
* The branch History lists: the proposal's in a proposal, else
|
|
2187
|
+
* the git mirror's or the one content reports for the project.
|
|
2188
|
+
* Absent where there is no history to show.
|
|
2189
|
+
*/
|
|
2190
|
+
historyBranch: zod.z.string().optional()
|
|
2160
2191
|
}), zod.z.object({
|
|
2161
2192
|
type: zod.z.literal("use-websocket"),
|
|
2162
2193
|
url: zod.z.string(),
|
|
@@ -2286,7 +2317,13 @@ var Api = {
|
|
|
2286
2317
|
* on the site. What the Studio's switcher says it is in, and
|
|
2287
2318
|
* where its Save goes (valbuild/home `docs/proposals.md`).
|
|
2288
2319
|
*/
|
|
2289
|
-
proposal: StatProposal.optional()
|
|
2320
|
+
proposal: StatProposal.optional(),
|
|
2321
|
+
/**
|
|
2322
|
+
* The branch History lists: the proposal's in a proposal, else
|
|
2323
|
+
* the git mirror's or the one content reports for the project.
|
|
2324
|
+
* Absent where there is no history to show.
|
|
2325
|
+
*/
|
|
2326
|
+
historyBranch: zod.z.string().optional()
|
|
2290
2327
|
})])
|
|
2291
2328
|
})])
|
|
2292
2329
|
}
|
|
@@ -2613,6 +2650,29 @@ var Api = {
|
|
|
2613
2650
|
error: GenericError
|
|
2614
2651
|
})))
|
|
2615
2652
|
})
|
|
2653
|
+
}),
|
|
2654
|
+
/*
|
|
2655
|
+
* Val Build refused the write for the project's plan: the Free week's
|
|
2656
|
+
* changes are used, or a trial is over. Not the 400 above, because the
|
|
2657
|
+
* patches are fine -- they are kept, and saved once the plan allows.
|
|
2658
|
+
* `message` is Val Build's own sentence and `error` the same as data,
|
|
2659
|
+
* so the Studio can put the fix beside it.
|
|
2660
|
+
*
|
|
2661
|
+
* The patches of the batch BEFORE the refused one were saved (the Free
|
|
2662
|
+
* week can run out mid-batch), so this carries what a 200 does about
|
|
2663
|
+
* them: the client marks those saved and keeps the rest.
|
|
2664
|
+
*/
|
|
2665
|
+
zod.z.object({
|
|
2666
|
+
status: zod.z.literal(403),
|
|
2667
|
+
json: zod.z.object({
|
|
2668
|
+
type: zod.z.literal("plan-refused"),
|
|
2669
|
+
message: zod.z.string(),
|
|
2670
|
+
error: PlanRefusalError,
|
|
2671
|
+
newPatchIds: zod.z.array(PatchId),
|
|
2672
|
+
parentRef: ParentRef,
|
|
2673
|
+
patchGroupId: zod.z.string().optional(),
|
|
2674
|
+
headVersion: zod.z.number().optional()
|
|
2675
|
+
})
|
|
2616
2676
|
}), zod.z.object({
|
|
2617
2677
|
status: zod.z.literal(200),
|
|
2618
2678
|
json: zod.z.object({
|
|
@@ -5557,7 +5617,11 @@ function emptyOf(schema, context) {
|
|
|
5557
5617
|
} else if (schema.type === "boolean") {
|
|
5558
5618
|
return false;
|
|
5559
5619
|
} else if (schema.type === "number") {
|
|
5560
|
-
|
|
5620
|
+
var _Internal$number$near, _schema$options;
|
|
5621
|
+
// 0, unless the schema rules it out: an `s.int().min(1)` starts at 1
|
|
5622
|
+
// rather than as an error. `null` means the schema allows nothing at all,
|
|
5623
|
+
// which validation will say; 0 is as good a start as any for that.
|
|
5624
|
+
return (_Internal$number$near = core.Internal.number.nearestAllowedNumber(0, (_schema$options = schema.options) !== null && _schema$options !== void 0 ? _schema$options : {})) !== null && _Internal$number$near !== void 0 ? _Internal$number$near : 0;
|
|
5561
5625
|
} else if (schema.type === "keyOf") {
|
|
5562
5626
|
if (schema.values === "string") {
|
|
5563
5627
|
return ""; // TODO: figure out this: user code might very well fail in this case
|
|
@@ -5599,14 +5663,14 @@ function emptyOf(schema, context) {
|
|
|
5599
5663
|
} else if (schema.type === "dateTime") {
|
|
5600
5664
|
return clampDateTimeString(new Date().toISOString(), schema.options);
|
|
5601
5665
|
} else if (schema.type === "color") {
|
|
5602
|
-
var _schema$options$forma, _schema$
|
|
5666
|
+
var _schema$options$forma, _schema$options2;
|
|
5603
5667
|
// Mid grey: visible against both a light and a dark canvas
|
|
5604
5668
|
return core.Internal.color.formatColor({
|
|
5605
5669
|
r: 128,
|
|
5606
5670
|
g: 128,
|
|
5607
5671
|
b: 128,
|
|
5608
5672
|
a: 1
|
|
5609
|
-
}, (_schema$options$forma = (_schema$
|
|
5673
|
+
}, (_schema$options$forma = (_schema$options2 = schema.options) === null || _schema$options2 === void 0 ? void 0 : _schema$options2.format) !== null && _schema$options$forma !== void 0 ? _schema$options$forma : core.DEFAULT_COLOR_FORMAT);
|
|
5610
5674
|
} else if (schema.type === "code") {
|
|
5611
5675
|
return ""; // An empty editor: no language has a sensible starting snippet
|
|
5612
5676
|
} else if (schema.type === "view") {
|
|
@@ -8057,6 +8121,7 @@ exports.PatchBlock = PatchBlock;
|
|
|
8057
8121
|
exports.PatchGroup = PatchGroup;
|
|
8058
8122
|
exports.PatchId = PatchId;
|
|
8059
8123
|
exports.PatchJSON = PatchJSON;
|
|
8124
|
+
exports.PlanRefusalError = PlanRefusalError;
|
|
8060
8125
|
exports.PublishProtocolError = PublishProtocolError;
|
|
8061
8126
|
exports.RAMP_STEPS = RAMP_STEPS;
|
|
8062
8127
|
exports.RemirrorBr = RemirrorBr;
|
|
@@ -1079,8 +1079,8 @@ var _excluded = ["directory"];
|
|
|
1079
1079
|
|
|
1080
1080
|
// A render is static config, so unlike a `preview` it travels WHOLE — this
|
|
1081
1081
|
// is the field the editor reads the layout from. See `core/src/render.ts`.
|
|
1082
|
-
//
|
|
1083
|
-
//
|
|
1082
|
+
// Array, record and keyOf carry `{ as: "inline" }`; number carries
|
|
1083
|
+
// `{ as: "slider", ... }`. A stale `render` on any other schema is stripped here, harmlessly.
|
|
1084
1084
|
// NB: these z.objects STRIP unknown keys, so a render variant that is not
|
|
1085
1085
|
// declared here is silently dropped in transit — add it here when it is added
|
|
1086
1086
|
// to `render.ts`.
|
|
@@ -1088,6 +1088,13 @@ var InlineRender = z.object({
|
|
|
1088
1088
|
as: z.literal("inline")
|
|
1089
1089
|
});
|
|
1090
1090
|
var FieldRender = InlineRender.optional();
|
|
1091
|
+
// The other render, and the only one a leaf takes: `s.number()` / `s.int()`.
|
|
1092
|
+
var NumberRender = z.object({
|
|
1093
|
+
as: z.literal("slider"),
|
|
1094
|
+
min: z.number(),
|
|
1095
|
+
max: z.number(),
|
|
1096
|
+
step: z.number().optional()
|
|
1097
|
+
}).optional();
|
|
1091
1098
|
|
|
1092
1099
|
/**
|
|
1093
1100
|
* The fields EVERY serialized schema carries, in one place.
|
|
@@ -1147,8 +1154,11 @@ var SerializedNumberSchema = z.object(_objectSpread2(_objectSpread2({}, commonSc
|
|
|
1147
1154
|
type: z.literal("number"),
|
|
1148
1155
|
options: z.object({
|
|
1149
1156
|
max: z.number().optional(),
|
|
1150
|
-
min: z.number().optional()
|
|
1157
|
+
min: z.number().optional(),
|
|
1158
|
+
integer: z["boolean"]().optional(),
|
|
1159
|
+
step: z.number().optional()
|
|
1151
1160
|
}).optional(),
|
|
1161
|
+
render: NumberRender,
|
|
1152
1162
|
opt: z["boolean"]()
|
|
1153
1163
|
}));
|
|
1154
1164
|
var SerializedObjectSchema = z.lazy(function () {
|
|
@@ -1621,7 +1631,22 @@ var notFoundResponse = z.object({
|
|
|
1621
1631
|
var GenericError = z.object({
|
|
1622
1632
|
message: z.string()
|
|
1623
1633
|
});
|
|
1624
|
-
|
|
1634
|
+
/**
|
|
1635
|
+
* Why Val Build refused a write for the project's plan, as data: the `error` of
|
|
1636
|
+
* its 403 (`refusalError` in valbuild/home's `billing/projectLimits.ts`).
|
|
1637
|
+
*
|
|
1638
|
+
* Every field but `code` is optional and every field is a plain string, so a
|
|
1639
|
+
* newer Val Build that adds a code or a fix still parses: the Studio says an
|
|
1640
|
+
* unknown one with Billing beside it rather than failing to read the answer.
|
|
1641
|
+
*/
|
|
1642
|
+
var PlanRefusalError = z.object({
|
|
1643
|
+
code: z.string(),
|
|
1644
|
+
fix: z.string().optional(),
|
|
1645
|
+
/** When it lifts by itself, as an ISO time, if it does. */
|
|
1646
|
+
until: z.string().optional(),
|
|
1647
|
+
/** The organization's Billing in Val Build. */
|
|
1648
|
+
billingUrl: z.string().optional()
|
|
1649
|
+
});
|
|
1625
1650
|
/**
|
|
1626
1651
|
* The header a request to `/admin/proxy` must carry. A cross-site form or
|
|
1627
1652
|
* `<img>` cannot set a custom header, so without it the proxy cannot be driven
|
|
@@ -2149,7 +2174,13 @@ var Api = {
|
|
|
2149
2174
|
* on the site. What the Studio's switcher says it is in, and
|
|
2150
2175
|
* where its Save goes (valbuild/home `docs/proposals.md`).
|
|
2151
2176
|
*/
|
|
2152
|
-
proposal: StatProposal.optional()
|
|
2177
|
+
proposal: StatProposal.optional(),
|
|
2178
|
+
/**
|
|
2179
|
+
* The branch History lists: the proposal's in a proposal, else
|
|
2180
|
+
* the git mirror's or the one content reports for the project.
|
|
2181
|
+
* Absent where there is no history to show.
|
|
2182
|
+
*/
|
|
2183
|
+
historyBranch: z.string().optional()
|
|
2153
2184
|
}), z.object({
|
|
2154
2185
|
type: z.literal("use-websocket"),
|
|
2155
2186
|
url: z.string(),
|
|
@@ -2279,7 +2310,13 @@ var Api = {
|
|
|
2279
2310
|
* on the site. What the Studio's switcher says it is in, and
|
|
2280
2311
|
* where its Save goes (valbuild/home `docs/proposals.md`).
|
|
2281
2312
|
*/
|
|
2282
|
-
proposal: StatProposal.optional()
|
|
2313
|
+
proposal: StatProposal.optional(),
|
|
2314
|
+
/**
|
|
2315
|
+
* The branch History lists: the proposal's in a proposal, else
|
|
2316
|
+
* the git mirror's or the one content reports for the project.
|
|
2317
|
+
* Absent where there is no history to show.
|
|
2318
|
+
*/
|
|
2319
|
+
historyBranch: z.string().optional()
|
|
2283
2320
|
})])
|
|
2284
2321
|
})])
|
|
2285
2322
|
}
|
|
@@ -2606,6 +2643,29 @@ var Api = {
|
|
|
2606
2643
|
error: GenericError
|
|
2607
2644
|
})))
|
|
2608
2645
|
})
|
|
2646
|
+
}),
|
|
2647
|
+
/*
|
|
2648
|
+
* Val Build refused the write for the project's plan: the Free week's
|
|
2649
|
+
* changes are used, or a trial is over. Not the 400 above, because the
|
|
2650
|
+
* patches are fine -- they are kept, and saved once the plan allows.
|
|
2651
|
+
* `message` is Val Build's own sentence and `error` the same as data,
|
|
2652
|
+
* so the Studio can put the fix beside it.
|
|
2653
|
+
*
|
|
2654
|
+
* The patches of the batch BEFORE the refused one were saved (the Free
|
|
2655
|
+
* week can run out mid-batch), so this carries what a 200 does about
|
|
2656
|
+
* them: the client marks those saved and keeps the rest.
|
|
2657
|
+
*/
|
|
2658
|
+
z.object({
|
|
2659
|
+
status: z.literal(403),
|
|
2660
|
+
json: z.object({
|
|
2661
|
+
type: z.literal("plan-refused"),
|
|
2662
|
+
message: z.string(),
|
|
2663
|
+
error: PlanRefusalError,
|
|
2664
|
+
newPatchIds: z.array(PatchId),
|
|
2665
|
+
parentRef: ParentRef,
|
|
2666
|
+
patchGroupId: z.string().optional(),
|
|
2667
|
+
headVersion: z.number().optional()
|
|
2668
|
+
})
|
|
2609
2669
|
}), z.object({
|
|
2610
2670
|
status: z.literal(200),
|
|
2611
2671
|
json: z.object({
|
|
@@ -5550,7 +5610,11 @@ function emptyOf(schema, context) {
|
|
|
5550
5610
|
} else if (schema.type === "boolean") {
|
|
5551
5611
|
return false;
|
|
5552
5612
|
} else if (schema.type === "number") {
|
|
5553
|
-
|
|
5613
|
+
var _Internal$number$near, _schema$options;
|
|
5614
|
+
// 0, unless the schema rules it out: an `s.int().min(1)` starts at 1
|
|
5615
|
+
// rather than as an error. `null` means the schema allows nothing at all,
|
|
5616
|
+
// which validation will say; 0 is as good a start as any for that.
|
|
5617
|
+
return (_Internal$number$near = Internal.number.nearestAllowedNumber(0, (_schema$options = schema.options) !== null && _schema$options !== void 0 ? _schema$options : {})) !== null && _Internal$number$near !== void 0 ? _Internal$number$near : 0;
|
|
5554
5618
|
} else if (schema.type === "keyOf") {
|
|
5555
5619
|
if (schema.values === "string") {
|
|
5556
5620
|
return ""; // TODO: figure out this: user code might very well fail in this case
|
|
@@ -5592,14 +5656,14 @@ function emptyOf(schema, context) {
|
|
|
5592
5656
|
} else if (schema.type === "dateTime") {
|
|
5593
5657
|
return clampDateTimeString(new Date().toISOString(), schema.options);
|
|
5594
5658
|
} else if (schema.type === "color") {
|
|
5595
|
-
var _schema$options$forma, _schema$
|
|
5659
|
+
var _schema$options$forma, _schema$options2;
|
|
5596
5660
|
// Mid grey: visible against both a light and a dark canvas
|
|
5597
5661
|
return Internal.color.formatColor({
|
|
5598
5662
|
r: 128,
|
|
5599
5663
|
g: 128,
|
|
5600
5664
|
b: 128,
|
|
5601
5665
|
a: 1
|
|
5602
|
-
}, (_schema$options$forma = (_schema$
|
|
5666
|
+
}, (_schema$options$forma = (_schema$options2 = schema.options) === null || _schema$options2 === void 0 ? void 0 : _schema$options2.format) !== null && _schema$options$forma !== void 0 ? _schema$options$forma : DEFAULT_COLOR_FORMAT);
|
|
5603
5667
|
} else if (schema.type === "code") {
|
|
5604
5668
|
return ""; // An empty editor: no language has a sensible starting snippet
|
|
5605
5669
|
} else if (schema.type === "view") {
|
|
@@ -8004,4 +8068,4 @@ function parse(schema, body, call) {
|
|
|
8004
8068
|
return parsed.data;
|
|
8005
8069
|
}
|
|
8006
8070
|
|
|
8007
|
-
export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, PublishProtocolError, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SerializedVideoSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_STUDIO_HEADER, ValCommit, ValDeployment, VideoOptions, VideoStreamOption, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, chainHeadOf, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, forEachRichTextImage, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, memoizePerRequest, newestCommitSha, parseArtifacts, parseBuildTarget, parseCancel, parseDeclare, parseDiscard, parseJob, parseNewestCiRun, parsePress, parseProblems, parseProjectSource, parsePromote, parsePublishToken, parseRenew, parseRequestStatus, parseStatus, parseUpdateTarget, parseVerify, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextImageSchema, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
|
|
8071
|
+
export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, PlanRefusalError, PublishProtocolError, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SerializedVideoSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_STUDIO_HEADER, ValCommit, ValDeployment, VideoOptions, VideoStreamOption, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, chainHeadOf, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, forEachRichTextImage, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, memoizePerRequest, newestCommitSha, parseArtifacts, parseBuildTarget, parseCancel, parseDeclare, parseDiscard, parseJob, parseNewestCiRun, parsePress, parseProblems, parseProjectSource, parsePromote, parsePublishToken, parseRenew, parseRequestStatus, parseStatus, parseUpdateTarget, parseVerify, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextImageSchema, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valbuild/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.145.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Val shared types and utilities",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"flexsearch": "^0.8.212",
|
|
38
38
|
"zod": "^4.4.3",
|
|
39
39
|
"zod-validation-error": "^5.0.0",
|
|
40
|
-
"@valbuild/core": "0.
|
|
40
|
+
"@valbuild/core": "0.145.0"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"CHANGELOG.md",
|