@valbuild/shared 0.124.0 → 0.126.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 +210 -0
- package/client/dist/valbuild-shared-client.cjs.dev.js +5 -2
- package/client/dist/valbuild-shared-client.cjs.prod.js +5 -2
- package/client/dist/valbuild-shared-client.esm.js +1 -1
- package/dist/declarations/src/internal/ApiRoutes.d.ts +8 -0
- package/dist/declarations/src/internal/getNextAppRouterSourceFolder.d.ts +24 -0
- package/dist/declarations/src/internal/getSitemapTree.d.ts +10 -1
- package/dist/declarations/src/internal/resolveSchemaSourceFixes.d.ts +25 -0
- package/dist/declarations/src/internal/zod/SerializedSchema.d.ts +3 -2
- package/dist/declarations/src/internal/zod/ValDeployment.d.ts +1 -0
- package/dist/{getSitemapTree-d3e98a2e.esm.js → getSitemapTree-a6cb37cb.esm.js} +66 -4
- package/dist/{getSitemapTree-77b1203a.cjs.prod.js → getSitemapTree-b320d033.cjs.prod.js} +68 -3
- package/dist/{getSitemapTree-a0c9a0e3.cjs.dev.js → getSitemapTree-d1977d3e.cjs.dev.js} +68 -3
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +189 -91
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +189 -91
- package/internal/dist/valbuild-shared-internal.esm.js +183 -91
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Internal, CODE_LANGUAGES, DEFAULT_COLOR_FORMAT } from '@valbuild/core';
|
|
2
|
-
import { _ as _createForOfIteratorHelper,
|
|
3
|
-
export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY,
|
|
2
|
+
import { _ as _createForOfIteratorHelper, n as _objectSpread2, o as _arrayLikeToArray, q as _unsupportedIterableToArray, r as _defineProperty, s as _typeof } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
|
|
3
|
+
export { b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, g as getNextAppRouterSourceFolder, l as getPageRouterSitemapTree, j as getPageRouterSourceFolder, m as getPatternFromModuleFilePath, h as getTanStackRouterSourceFolder, k as isTanStackRoutesFolder, f as isValCanvasFrame, i as isValCanvasPageMessage, e as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-a6cb37cb.esm.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { fromError } from 'zod-validation-error';
|
|
6
6
|
import FlexSearch from 'flexsearch';
|
|
@@ -982,19 +982,19 @@ var SerializedArraySchema = z.lazy(function () {
|
|
|
982
982
|
opt: z["boolean"]()
|
|
983
983
|
}));
|
|
984
984
|
});
|
|
985
|
-
var
|
|
986
|
-
return z.
|
|
987
|
-
type: z.literal("union"),
|
|
988
|
-
key: SerializedLiteralSchema,
|
|
989
|
-
items: z.array(SerializedLiteralSchema),
|
|
990
|
-
opt: z["boolean"]()
|
|
991
|
-
})), z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
|
|
992
|
-
type: z.literal("union"),
|
|
985
|
+
var SerializedDiscriminatedUnionSchema = z.lazy(function () {
|
|
986
|
+
return z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
|
|
987
|
+
type: z.literal("discriminated-union"),
|
|
993
988
|
key: z.string(),
|
|
994
989
|
items: z.array(SerializedObjectSchema),
|
|
995
990
|
opt: z["boolean"]()
|
|
996
|
-
}))
|
|
991
|
+
}));
|
|
997
992
|
});
|
|
993
|
+
var SerializedEnumSchema = z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
|
|
994
|
+
type: z.literal("enum"),
|
|
995
|
+
values: z.array(z.string()),
|
|
996
|
+
opt: z["boolean"]()
|
|
997
|
+
}));
|
|
998
998
|
var ImageEncodeOption = z.union([z.literal(false), z.object({
|
|
999
999
|
type: z.literal("webp"),
|
|
1000
1000
|
quality: z.number().optional(),
|
|
@@ -1146,7 +1146,7 @@ var SerializedSettingsSchema = z.lazy(function () {
|
|
|
1146
1146
|
opt: z["boolean"]()
|
|
1147
1147
|
}));
|
|
1148
1148
|
});
|
|
1149
|
-
var SerializedSchema = z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema,
|
|
1149
|
+
var SerializedSchema = z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema]);
|
|
1150
1150
|
|
|
1151
1151
|
var ValCommit = z.object({
|
|
1152
1152
|
commitSha: z.string(),
|
|
@@ -1158,6 +1158,31 @@ var ValCommit = z.object({
|
|
|
1158
1158
|
commitMessage: z.string().nullable()
|
|
1159
1159
|
});
|
|
1160
1160
|
|
|
1161
|
+
var ValDeployment = z.object({
|
|
1162
|
+
deploymentId: z.string(),
|
|
1163
|
+
deploymentState: z.string(),
|
|
1164
|
+
commitSha: z.string(),
|
|
1165
|
+
updatedAt: z.string(),
|
|
1166
|
+
createdAt: z.string(),
|
|
1167
|
+
/**
|
|
1168
|
+
* The commit message, as the deployment's host reported it.
|
|
1169
|
+
*
|
|
1170
|
+
* Val's OWN publishes carry their message on the commit (`ValCommit`), and
|
|
1171
|
+
* that is the one the Studio prefers — it is the message Val wrote. This is
|
|
1172
|
+
* for every OTHER deployment: a developer's push, a merged pull request, a
|
|
1173
|
+
* revert. Those have no Val commit at all, so without this the deploy feed
|
|
1174
|
+
* could only name them by their short sha, and "what went out at 14:02?" had
|
|
1175
|
+
* no answer inside the Studio.
|
|
1176
|
+
*
|
|
1177
|
+
* Optional AND nullable, and the two mean different things: absent is a
|
|
1178
|
+
* content service that does not report messages (or an older one), null is
|
|
1179
|
+
* one that reports having none. Both render as the short sha, so nothing
|
|
1180
|
+
* depends on telling them apart — but a schema that demanded the field would
|
|
1181
|
+
* reject the whole deployment feed of a service that does not send it.
|
|
1182
|
+
*/
|
|
1183
|
+
commitMessage: z.string().nullable().optional()
|
|
1184
|
+
});
|
|
1185
|
+
|
|
1161
1186
|
/**
|
|
1162
1187
|
* The wire shapes for reading history.
|
|
1163
1188
|
*
|
|
@@ -1750,6 +1775,21 @@ var Api = {
|
|
|
1750
1775
|
*/
|
|
1751
1776
|
headCommitSha: z.string().optional(),
|
|
1752
1777
|
commits: z.array(ValCommit),
|
|
1778
|
+
/**
|
|
1779
|
+
* The publishes the content service knows about.
|
|
1780
|
+
*
|
|
1781
|
+
* Declared, at last. `getStat` has always returned these in
|
|
1782
|
+
* `http` mode and the Studio has always read them - the response
|
|
1783
|
+
* validator strips unknown keys rather than rejecting them, and
|
|
1784
|
+
* the raw json is what the client hands back, so they arrived
|
|
1785
|
+
* while the contract said they could not. That was survivable
|
|
1786
|
+
* until a deployment started carrying a commit MESSAGE: a field
|
|
1787
|
+
* nobody has declared is a field the next person deletes.
|
|
1788
|
+
*
|
|
1789
|
+
* Optional, because a content service that reports no
|
|
1790
|
+
* deployments sends none.
|
|
1791
|
+
*/
|
|
1792
|
+
deployments: z.array(ValDeployment).optional(),
|
|
1753
1793
|
config: ValConfig,
|
|
1754
1794
|
profileId: z.string().nullable(),
|
|
1755
1795
|
mode: z.union([z.literal("http"), z.literal("fs")])
|
|
@@ -3242,19 +3282,9 @@ function explainIncompatible(reason) {
|
|
|
3242
3282
|
* not a failure: it is what makes the caller return `unknown` rather than guess.
|
|
3243
3283
|
*/
|
|
3244
3284
|
function variantOf(schema, value) {
|
|
3245
|
-
if (schema.type !== "union") {
|
|
3285
|
+
if (schema.type !== "discriminated-union") {
|
|
3246
3286
|
return undefined;
|
|
3247
3287
|
}
|
|
3248
|
-
// String union: the value IS the discriminator.
|
|
3249
|
-
if (typeof schema.key !== "string") {
|
|
3250
|
-
if (typeof value !== "string") {
|
|
3251
|
-
return undefined;
|
|
3252
|
-
}
|
|
3253
|
-
return schema.items.find(function (item) {
|
|
3254
|
-
return item.type === "literal" && item.value === value;
|
|
3255
|
-
});
|
|
3256
|
-
}
|
|
3257
|
-
// Object union: the discriminator is a literal at `key`.
|
|
3258
3288
|
var discriminator = schema.key;
|
|
3259
3289
|
if (!isJsonObject(value)) {
|
|
3260
3290
|
return undefined;
|
|
@@ -3272,9 +3302,6 @@ function variantOf(schema, value) {
|
|
|
3272
3302
|
});
|
|
3273
3303
|
}
|
|
3274
3304
|
function describeVariant(schema, key) {
|
|
3275
|
-
if (schema.type === "literal") {
|
|
3276
|
-
return schema.value;
|
|
3277
|
-
}
|
|
3278
3305
|
if (schema.type === "object") {
|
|
3279
3306
|
var tag = schema.items[key];
|
|
3280
3307
|
if ((tag === null || tag === void 0 ? void 0 : tag.type) === "literal") {
|
|
@@ -3292,11 +3319,24 @@ function checkCompatibility(from, to) {
|
|
|
3292
3319
|
});
|
|
3293
3320
|
}
|
|
3294
3321
|
|
|
3322
|
+
// An enum's domain IS its schema, so the value decides: whatever the old
|
|
3323
|
+
// schema was — an enum, a literal, a plain string — the only question is
|
|
3324
|
+
// whether this string is still offered here.
|
|
3325
|
+
if (to.schema.type === "enum") {
|
|
3326
|
+
if (typeof from.value === "string" && to.schema.values.includes(from.value)) {
|
|
3327
|
+
return compatible;
|
|
3328
|
+
}
|
|
3329
|
+
return incompatible({
|
|
3330
|
+
kind: "no-matching-variant",
|
|
3331
|
+
variants: to.schema.values
|
|
3332
|
+
});
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3295
3335
|
// A changed union is not itself disqualifying. What matters is whether the
|
|
3296
3336
|
// variant being restored still has somewhere to go — comparing the unions
|
|
3297
3337
|
// wholesale would refuse a restore that is perfectly safe.
|
|
3298
|
-
if (to.schema.type === "union") {
|
|
3299
|
-
var key =
|
|
3338
|
+
if (to.schema.type === "discriminated-union") {
|
|
3339
|
+
var key = to.schema.key;
|
|
3300
3340
|
var _iterator = _createForOfIteratorHelper(to.schema.items),
|
|
3301
3341
|
_step;
|
|
3302
3342
|
try {
|
|
@@ -3321,9 +3361,9 @@ function checkCompatibility(from, to) {
|
|
|
3321
3361
|
});
|
|
3322
3362
|
}
|
|
3323
3363
|
|
|
3324
|
-
// Coming FROM a union into something that is not one: only the
|
|
3325
|
-
// value actually is matters, so narrow before comparing.
|
|
3326
|
-
if (from.schema.type === "union") {
|
|
3364
|
+
// Coming FROM a discriminated union into something that is not one: only the
|
|
3365
|
+
// variant this value actually is matters, so narrow before comparing.
|
|
3366
|
+
if (from.schema.type === "discriminated-union") {
|
|
3327
3367
|
var _variant = variantOf(from.schema, from.value);
|
|
3328
3368
|
if (_variant === undefined) {
|
|
3329
3369
|
return {
|
|
@@ -3336,6 +3376,25 @@ function checkCompatibility(from, to) {
|
|
|
3336
3376
|
value: from.value
|
|
3337
3377
|
}, to);
|
|
3338
3378
|
}
|
|
3379
|
+
|
|
3380
|
+
// Coming FROM an enum into something that is not one: the value it holds is
|
|
3381
|
+
// all the old schema contributes, so compare as that one value.
|
|
3382
|
+
if (from.schema.type === "enum") {
|
|
3383
|
+
if (typeof from.value !== "string") {
|
|
3384
|
+
return {
|
|
3385
|
+
status: "unknown",
|
|
3386
|
+
message: "The old value is not one of the options it was stored as, so we cannot tell whether it fits here."
|
|
3387
|
+
};
|
|
3388
|
+
}
|
|
3389
|
+
return checkCompatibility({
|
|
3390
|
+
schema: {
|
|
3391
|
+
type: "literal",
|
|
3392
|
+
value: from.value,
|
|
3393
|
+
opt: from.schema.opt
|
|
3394
|
+
},
|
|
3395
|
+
value: from.value
|
|
3396
|
+
}, to);
|
|
3397
|
+
}
|
|
3339
3398
|
if (from.schema.type !== to.schema.type) {
|
|
3340
3399
|
return incompatible({
|
|
3341
3400
|
kind: "type-changed",
|
|
@@ -3569,14 +3628,6 @@ var SharedValConfig = z.object({
|
|
|
3569
3628
|
* Config that is shared between the client and server.
|
|
3570
3629
|
*/
|
|
3571
3630
|
|
|
3572
|
-
var ValDeployment = z.object({
|
|
3573
|
-
deploymentId: z.string(),
|
|
3574
|
-
deploymentState: z.string(),
|
|
3575
|
-
commitSha: z.string(),
|
|
3576
|
-
updatedAt: z.string(),
|
|
3577
|
-
createdAt: z.string()
|
|
3578
|
-
});
|
|
3579
|
-
|
|
3580
3631
|
/**
|
|
3581
3632
|
* Shared route validation utilities
|
|
3582
3633
|
*/
|
|
@@ -3749,6 +3800,16 @@ function findSimilar(key, targets) {
|
|
|
3749
3800
|
return a.distance - b.distance;
|
|
3750
3801
|
});
|
|
3751
3802
|
}
|
|
3803
|
+
/**
|
|
3804
|
+
* The record a `keyof:check-keys` error resolves against — the value and the
|
|
3805
|
+
* schema at the error's `sourcePath`.
|
|
3806
|
+
*
|
|
3807
|
+
* Exported for the one consumer that has to know what a resolution DEPENDED
|
|
3808
|
+
* on rather than what it concluded: `ValidationStore` re-reads the keys here
|
|
3809
|
+
* to decide whether a change to the referenced module can have moved the
|
|
3810
|
+
* answer. Keep this and {@link checkKeyIsValid} reading the same record, or the
|
|
3811
|
+
* store will invalidate on one record and the resolution answer from another.
|
|
3812
|
+
*/
|
|
3752
3813
|
function getKeyOfRecordAt(sourcePath, snapshot) {
|
|
3753
3814
|
var _Internal$splitModule = Internal.splitModuleFilePathAndModulePath(sourcePath),
|
|
3754
3815
|
_Internal$splitModule2 = _slicedToArray(_Internal$splitModule, 2),
|
|
@@ -3892,6 +3953,29 @@ function checkRouteIsValid(route, includePattern, excludePattern, snapshot) {
|
|
|
3892
3953
|
error: false
|
|
3893
3954
|
};
|
|
3894
3955
|
}
|
|
3956
|
+
/**
|
|
3957
|
+
* The record a `keyof:check-keys` error resolves against, or null for any other
|
|
3958
|
+
* error — including a malformed marker, which
|
|
3959
|
+
* {@link resolveSchemaSourceFixForError} reports and this has nothing to say
|
|
3960
|
+
* about.
|
|
3961
|
+
*
|
|
3962
|
+
* For a consumer that needs to know what the resolution READS, not what it
|
|
3963
|
+
* concludes: `ValidationStore` keeps this per validated module, so that a change
|
|
3964
|
+
* to the referenced record can invalidate the module holding the reference.
|
|
3965
|
+
*/
|
|
3966
|
+
function keyOfRecordPath(error) {
|
|
3967
|
+
var _error$fixes;
|
|
3968
|
+
if (!((_error$fixes = error.fixes) !== null && _error$fixes !== void 0 ? _error$fixes : []).includes("keyof:check-keys")) {
|
|
3969
|
+
return null;
|
|
3970
|
+
}
|
|
3971
|
+
var value = error.value;
|
|
3972
|
+
if (!value || _typeof(value) !== "object") {
|
|
3973
|
+
return null;
|
|
3974
|
+
}
|
|
3975
|
+
var sourcePath = value.sourcePath;
|
|
3976
|
+
return typeof sourcePath === "string" ? sourcePath : null;
|
|
3977
|
+
}
|
|
3978
|
+
|
|
3895
3979
|
/**
|
|
3896
3980
|
* Resolves a single `keyof:check-keys` or `router:check-route` error against
|
|
3897
3981
|
* the given schema/source snapshot. Returns:
|
|
@@ -3900,8 +3984,8 @@ function checkRouteIsValid(route, includePattern, excludePattern, snapshot) {
|
|
|
3900
3984
|
* - { status: "remaining"; error } if invalid (rewritten error to surface)
|
|
3901
3985
|
*/
|
|
3902
3986
|
function resolveSchemaSourceFixForError(error, snapshot) {
|
|
3903
|
-
var _error$
|
|
3904
|
-
var fixes = (_error$
|
|
3987
|
+
var _error$fixes2;
|
|
3988
|
+
var fixes = (_error$fixes2 = error.fixes) !== null && _error$fixes2 !== void 0 ? _error$fixes2 : [];
|
|
3905
3989
|
if (fixes.includes("keyof:check-keys")) {
|
|
3906
3990
|
if (!error.value) {
|
|
3907
3991
|
return {
|
|
@@ -4130,11 +4214,20 @@ function emptyOf(schema) {
|
|
|
4130
4214
|
return null; // returning null is the only thing we can do, however, it means that the patches cannot be applied yet since that might fail
|
|
4131
4215
|
} else if (schema.type === "literal") {
|
|
4132
4216
|
return schema.value;
|
|
4133
|
-
} else if (schema.type === "union") {
|
|
4134
|
-
|
|
4135
|
-
|
|
4217
|
+
} else if (schema.type === "discriminated-union") {
|
|
4218
|
+
// The first variant is what a new value starts as. `s.discriminatedUnion`
|
|
4219
|
+
// requires one, so an empty `items` means a serialized schema that was not
|
|
4220
|
+
// built by it — say so rather than returning `undefined`, which is not
|
|
4221
|
+
// JSON and would be written into a patch as a missing key.
|
|
4222
|
+
if (schema.items.length === 0) {
|
|
4223
|
+
throw Error("Cannot create an empty value for a discriminated union with no variants");
|
|
4136
4224
|
}
|
|
4137
|
-
return schema.
|
|
4225
|
+
return emptyOf(schema.items[0]);
|
|
4226
|
+
} else if (schema.type === "enum") {
|
|
4227
|
+
if (schema.values.length === 0) {
|
|
4228
|
+
throw Error("Cannot create an empty value for an enum with no values");
|
|
4229
|
+
}
|
|
4230
|
+
return schema.values[0];
|
|
4138
4231
|
} else if (schema.type === "date") {
|
|
4139
4232
|
return clampDateString(formatLocalDate(new Date()), schema.options);
|
|
4140
4233
|
} else if (schema.type === "dateTime") {
|
|
@@ -4222,24 +4315,19 @@ function resolveSerializedSchemaAtPath(schema, path) {
|
|
|
4222
4315
|
schema: current,
|
|
4223
4316
|
remainingPath: path.slice(i)
|
|
4224
4317
|
};
|
|
4225
|
-
} else if (current.type === "union") {
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
if (resolved.kind !== "unresolved") return resolved;
|
|
4234
|
-
}
|
|
4235
|
-
} catch (err) {
|
|
4236
|
-
_iterator2.e(err);
|
|
4237
|
-
} finally {
|
|
4238
|
-
_iterator2.f();
|
|
4318
|
+
} else if (current.type === "discriminated-union") {
|
|
4319
|
+
var _iterator2 = _createForOfIteratorHelper(current.items),
|
|
4320
|
+
_step2;
|
|
4321
|
+
try {
|
|
4322
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4323
|
+
var variant = _step2.value;
|
|
4324
|
+
var resolved = resolveSerializedSchemaAtPath(variant, path.slice(i));
|
|
4325
|
+
if (resolved.kind !== "unresolved") return resolved;
|
|
4239
4326
|
}
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4327
|
+
} catch (err) {
|
|
4328
|
+
_iterator2.e(err);
|
|
4329
|
+
} finally {
|
|
4330
|
+
_iterator2.f();
|
|
4243
4331
|
}
|
|
4244
4332
|
return {
|
|
4245
4333
|
kind: "unresolved"
|
|
@@ -5168,6 +5256,18 @@ function traverseSchemaSource(source, schema, path, callback) {
|
|
|
5168
5256
|
return;
|
|
5169
5257
|
}
|
|
5170
5258
|
|
|
5259
|
+
// Handle enum: a leaf, like a literal with more than one allowed value
|
|
5260
|
+
if (schema.type === "enum") {
|
|
5261
|
+
if (typeof source === "string") {
|
|
5262
|
+
callback({
|
|
5263
|
+
source: source,
|
|
5264
|
+
schema: schema,
|
|
5265
|
+
path: path
|
|
5266
|
+
});
|
|
5267
|
+
}
|
|
5268
|
+
return;
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5171
5271
|
// Handle route
|
|
5172
5272
|
if (schema.type === "route") {
|
|
5173
5273
|
if (typeof source === "string") {
|
|
@@ -5215,36 +5315,24 @@ function traverseSchemaSource(source, schema, path, callback) {
|
|
|
5215
5315
|
return;
|
|
5216
5316
|
}
|
|
5217
5317
|
|
|
5218
|
-
// Handle union
|
|
5219
|
-
if (schema.type === "union") {
|
|
5318
|
+
// Handle discriminated union: descend through the variant the value takes
|
|
5319
|
+
if (schema.type === "discriminated-union") {
|
|
5220
5320
|
var schemaKey = schema.key;
|
|
5221
|
-
if (
|
|
5222
|
-
|
|
5223
|
-
if (
|
|
5224
|
-
var
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
if ((itemKeySchema === null || itemKeySchema === void 0 ? void 0 : itemKeySchema.type) === "literal") {
|
|
5231
|
-
return itemKeySchema.value === itemKey;
|
|
5232
|
-
}
|
|
5233
|
-
return false;
|
|
5234
|
-
});
|
|
5235
|
-
if (schemaOfItem) {
|
|
5236
|
-
traverseSchemaSource(source, schemaOfItem, path, callback);
|
|
5321
|
+
if (source && _typeof(source) === "object" && !Array.isArray(source) && schemaKey in source) {
|
|
5322
|
+
var itemKey = source[schemaKey];
|
|
5323
|
+
if (typeof itemKey === "string") {
|
|
5324
|
+
var schemaOfItem = schema.items.filter(function (item) {
|
|
5325
|
+
return item.type === "object";
|
|
5326
|
+
}).find(function (item) {
|
|
5327
|
+
var itemKeySchema = item.items[schemaKey];
|
|
5328
|
+
if ((itemKeySchema === null || itemKeySchema === void 0 ? void 0 : itemKeySchema.type) === "literal") {
|
|
5329
|
+
return itemKeySchema.value === itemKey;
|
|
5237
5330
|
}
|
|
5238
|
-
|
|
5239
|
-
}
|
|
5240
|
-
} else {
|
|
5241
|
-
// Literal union - treat as primitive
|
|
5242
|
-
if (typeof source === "string") {
|
|
5243
|
-
callback({
|
|
5244
|
-
source: source,
|
|
5245
|
-
schema: schema,
|
|
5246
|
-
path: path
|
|
5331
|
+
return false;
|
|
5247
5332
|
});
|
|
5333
|
+
if (schemaOfItem) {
|
|
5334
|
+
traverseSchemaSource(source, schemaOfItem, path, callback);
|
|
5335
|
+
}
|
|
5248
5336
|
}
|
|
5249
5337
|
}
|
|
5250
5338
|
return;
|
|
@@ -5404,7 +5492,11 @@ function indexModule(searchIndex, moduleFilePath, source, schema) {
|
|
|
5404
5492
|
var label = "";
|
|
5405
5493
|
|
|
5406
5494
|
// Handle primitives
|
|
5407
|
-
if (schema.type === "string" || schema.type === "number" || schema.type === "boolean" || schema.type === "date" || schema.type === "dateTime" || schema.type === "color" || schema.type === "code" || schema.type === "keyOf" || schema.type === "route"
|
|
5495
|
+
if (schema.type === "string" || schema.type === "number" || schema.type === "boolean" || schema.type === "date" || schema.type === "dateTime" || schema.type === "color" || schema.type === "code" || schema.type === "keyOf" || schema.type === "route" ||
|
|
5496
|
+
// An enum's value is a string the editor chose; it is as searchable as
|
|
5497
|
+
// any other string leaf. The old string union was never indexed at all,
|
|
5498
|
+
// which is the gap this closes.
|
|
5499
|
+
schema.type === "enum") {
|
|
5408
5500
|
var _source$toString, _source$toString2;
|
|
5409
5501
|
searchText = (_source$toString = source === null || source === void 0 ? void 0 : source.toString()) !== null && _source$toString !== void 0 ? _source$toString : "";
|
|
5410
5502
|
label = (_source$toString2 = source === null || source === void 0 ? void 0 : source.toString()) !== null && _source$toString2 !== void 0 ? _source$toString2 : "";
|
|
@@ -5545,4 +5637,4 @@ function performSearch(searchIndex, query) {
|
|
|
5545
5637
|
};
|
|
5546
5638
|
}
|
|
5547
5639
|
|
|
5548
|
-
export { Api, 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, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema,
|
|
5640
|
+
export { Api, 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, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, ValCommit, ValDeployment, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, checkCompatibility, chooseEncoded, concatModulePath, createRegExpFromPattern, createSearchIndex, createValClient, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSkippedSource, keyOfRecordPath, levenshtein, newestCommitSha, partitionValidationErrors, performSearch, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextToRemirror, safeParsePatch, sourcePathOfChild, 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.126.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.126.0"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"CHANGELOG.md",
|