@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,215 @@
|
|
|
1
1
|
# @valbuild/shared
|
|
2
2
|
|
|
3
|
+
## 0.126.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#652](https://github.com/valbuild/val/pull/652) [`f2fe70d`](https://github.com/valbuild/val/commit/f2fe70dab2b65000dfaf289f09c70b4a8291467a) Thanks [@freekh](https://github.com/freekh)! - `s.union` is now `s.discriminatedUnion` and `s.enum`.
|
|
8
|
+
|
|
9
|
+
`s.union` did two unrelated jobs and worked out which one you meant from its
|
|
10
|
+
first argument: a string key meant a tagged union of objects, literal schemas
|
|
11
|
+
meant a set of allowed strings. Those are now two schemas with two names.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// A fixed set of strings — presents as a dropdown
|
|
15
|
+
s.enum("primary", "secondary", "ghost"); // Schema<"primary" | "secondary" | "ghost">
|
|
16
|
+
|
|
17
|
+
// One of several object shapes, told apart by a tag field
|
|
18
|
+
s.discriminatedUnion(
|
|
19
|
+
"type",
|
|
20
|
+
s.object({ type: s.literal("hero"), heading: s.string() }),
|
|
21
|
+
s.object({ type: s.literal("quote"), text: s.string() }),
|
|
22
|
+
);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`s.enum` takes the strings directly, so the `s.literal(...)` wrapper is gone.
|
|
26
|
+
|
|
27
|
+
**`s.union` still works** — it is deprecated, and it builds exactly the schema
|
|
28
|
+
above, so nothing has to change today:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
s.union(s.literal("one"), s.literal("two")); // → s.enum("one", "two")
|
|
32
|
+
s.union("type", pageA, pageB); // → s.discriminatedUnion("type", pageA, pageB)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The two are different kinds of node, and that is the reason for the split. A
|
|
36
|
+
discriminated union is a container: the selected variant's fields are the fields
|
|
37
|
+
being edited, and everything that walks a schema descends through it. An enum is
|
|
38
|
+
a leaf — a string with a closed domain — so nothing recurses into it. Told apart
|
|
39
|
+
only by the shape of `key`, every consumer had to re-derive which one it was
|
|
40
|
+
holding; each now has its own serialized type (`"discriminated-union"` and
|
|
41
|
+
`"enum"`) and Val Studio has a field per kind rather than one field that
|
|
42
|
+
branches.
|
|
43
|
+
|
|
44
|
+
Two behaviour changes fall out of the split, both of them fixes:
|
|
45
|
+
|
|
46
|
+
- A value that is not a string at all now fails an enum's validation with a
|
|
47
|
+
type error. `s.union` of literals only ever checked the value against its
|
|
48
|
+
literals when the value WAS a string, so a number or an object where an enum
|
|
49
|
+
was declared validated clean.
|
|
50
|
+
- An enum field now shows its validation errors in Val Studio where the field
|
|
51
|
+
is opened on its own — the module editor and the canvas's fields column — and
|
|
52
|
+
gets the compact error layout inside an inline list row. It is a leaf now, so
|
|
53
|
+
it goes through the same error rendering as every other leaf field; the string
|
|
54
|
+
union bypassed it and showed nothing in those places.
|
|
55
|
+
|
|
56
|
+
Several latent crashes in the old `s.union` are fixed on the way past, all of
|
|
57
|
+
them cases where it threw a `TypeError` instead of reporting:
|
|
58
|
+
|
|
59
|
+
- A required discriminated union holding `null` now reports a type error rather
|
|
60
|
+
than throwing, and resolving a path underneath a nullable one that is `null`
|
|
61
|
+
gives the error the API promises instead of a crash.
|
|
62
|
+
- `s.literal("")` is a legal discriminator tag, and `s.enum("")` a legal value.
|
|
63
|
+
Both used to be treated as absent by a truthiness check — in path resolution,
|
|
64
|
+
in stega encoding, and in the message that lists a union's valid tags. The
|
|
65
|
+
editor's dropdowns handle them too: an empty value is reserved by the select
|
|
66
|
+
component and had to be mapped around.
|
|
67
|
+
- A variant that omits the discriminator entirely is now reported as the schema
|
|
68
|
+
error it is, instead of throwing while the check looked for it.
|
|
69
|
+
- An enum's value is now indexed for search, like every other string leaf. The
|
|
70
|
+
old string union was never indexed at all, so searching for one of its values
|
|
71
|
+
could not find the field.
|
|
72
|
+
- A nullable discriminated union set to `null` no longer renders a spinner that
|
|
73
|
+
never resolves.
|
|
74
|
+
|
|
75
|
+
`s.discriminatedUnion` also requires at least one variant, as `s.enum` requires
|
|
76
|
+
at least one value: a union with nothing to select is not a thing to write, and
|
|
77
|
+
everything downstream reads the first variant where it needs any.
|
|
78
|
+
|
|
79
|
+
If you read serialized schemas yourself, that is the breaking part: `type` is no
|
|
80
|
+
longer `"union"`, an enum carries `values: string[]` instead of a `key` plus
|
|
81
|
+
`items` of literal schemas, and `UnionSchema` is no longer a class.
|
|
82
|
+
`SerializedUnionSchema`, `SerializedStringUnionSchema`,
|
|
83
|
+
`SerializedObjectUnionSchema` and `UnionSchema` remain as deprecated type
|
|
84
|
+
aliases.
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- [#664](https://github.com/valbuild/val/pull/664) [`5bfd630`](https://github.com/valbuild/val/commit/5bfd630b63dee2189e238f20fe72ecc5537160f7) Thanks [@freekh](https://github.com/freekh)! - Show the git message on deployments Val did not publish
|
|
89
|
+
|
|
90
|
+
The deploy feed could only name a publish when Val itself had made the commit:
|
|
91
|
+
the message came off Val's own `ValCommit`, and every other deployment — a
|
|
92
|
+
developer's push, a merged pull request, a revert — showed a seven-character
|
|
93
|
+
sha. On most projects those are the majority, so "what went out at 14:02?" had
|
|
94
|
+
no answer in the Studio.
|
|
95
|
+
|
|
96
|
+
A deployment can now carry its own `commitMessage`, which the Studio uses
|
|
97
|
+
wherever there is no Val commit to prefer. It is optional and nullable, so a
|
|
98
|
+
content service that does not report messages is unaffected — those publishes
|
|
99
|
+
keep showing the short sha, exactly as before.
|
|
100
|
+
|
|
101
|
+
Deployment rows also show only the subject line of a message now. A git message
|
|
102
|
+
is a subject, a blank line and a body, and the rows are one truncated line — so
|
|
103
|
+
a real push arrived as "Subject The body went on like this…". The classic
|
|
104
|
+
Draft changes view still has the whole message in its tooltip.
|
|
105
|
+
|
|
106
|
+
- [#659](https://github.com/valbuild/val/pull/659) [`ccbcda6`](https://github.com/valbuild/val/commit/ccbcda60b3e3c465071229ae1ba28ac735483e63) Thanks [@freekh](https://github.com/freekh)! - Discarding changes now clears the validation errors, previews and search results
|
|
107
|
+
that were computed from them.
|
|
108
|
+
|
|
109
|
+
A discard that removed a module's last pending change announced itself only as
|
|
110
|
+
a "drop", and the stores that keep validation results, previews and the search
|
|
111
|
+
index listened only for changes being applied. So after discarding, the Studio
|
|
112
|
+
kept showing the errors and previews of the discarded edit until something else
|
|
113
|
+
touched the module.
|
|
114
|
+
|
|
115
|
+
Fields that reference another module's keys (`s.keyOf(...)` and `s.route()`)
|
|
116
|
+
also follow that module now. Renaming a page and then discarding the rename left
|
|
117
|
+
every `keyOf` field pointing at it reporting that the key does not exist — about
|
|
118
|
+
a key that was back — because the module holding the reference had not changed
|
|
119
|
+
and was never re-checked. The validation store now tracks which records a
|
|
120
|
+
module's errors resolve against and re-checks it when their keys change, and only
|
|
121
|
+
then: editing content inside a referenced page does not re-validate its
|
|
122
|
+
referrers.
|
|
123
|
+
|
|
124
|
+
- Updated dependencies [[`f2fe70d`](https://github.com/valbuild/val/commit/f2fe70dab2b65000dfaf289f09c70b4a8291467a), [`171208a`](https://github.com/valbuild/val/commit/171208a20177e68ed5a8b1a6fdaabfe893a6aa5f)]:
|
|
125
|
+
- @valbuild/core@0.126.0
|
|
126
|
+
|
|
127
|
+
## 0.125.0
|
|
128
|
+
|
|
129
|
+
### Minor Changes
|
|
130
|
+
|
|
131
|
+
- [#638](https://github.com/valbuild/val/pull/638) [`c390397`](https://github.com/valbuild/val/commit/c390397cb5e203eb1bedae3a6fab15726e850b90) Thanks [@freekh](https://github.com/freekh)! - Val now runs on TanStack Start.
|
|
132
|
+
|
|
133
|
+
`@valbuild/tanstack` is a new package with everything `@valbuild/next` has: Val
|
|
134
|
+
Studio at `/val`, the on-page overlay and canvas, draft mode, the client hooks,
|
|
135
|
+
server-side content reads, images, and the MCP tools.
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
npm install @valbuild/tanstack
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
// val.config.ts
|
|
143
|
+
import { initVal } from "@valbuild/tanstack";
|
|
144
|
+
const { s, c, config, tanstackRouter } = initVal({ project: "org/project" });
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Routes are first class.** A Val module for a route is named after the route
|
|
148
|
+
file it sits beside — `src/routes/posts.$postId.tsx` is served content by
|
|
149
|
+
`src/routes/posts.$postId.val.ts` — and its keys are the URLs that route serves:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
export default c.define(
|
|
153
|
+
"/src/routes/posts.$postId.val.ts",
|
|
154
|
+
s.router(tanstackRouter, s.object({ title: s.string() })),
|
|
155
|
+
{ "/posts/hello-world": { title: "Hello world" } },
|
|
156
|
+
);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`.` and `/` both separate segments, `$param` is a parameter, `$` is a splat, and
|
|
160
|
+
`index`, `route`, `(groups)` and `_pathless` layouts add no URL segment — the
|
|
161
|
+
same rules TanStack Router uses for the route file itself. Val validates every
|
|
162
|
+
key against that pattern, and Val Studio shows these modules as a sitemap under
|
|
163
|
+
**Pages**, where an editor can add a page.
|
|
164
|
+
|
|
165
|
+
Point the route generator away from your content files, in `vite.config.ts` and
|
|
166
|
+
`tsr.config.json`:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
tanstackStart({ router: { routeFileIgnorePattern: "\\.val\\.[tj]sx?$" } });
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
See the [README](https://github.com/valbuild/val/blob/main/packages/tanstack/README.md)
|
|
173
|
+
for the full wiring, and `examples/tanstack` for a working app.
|
|
174
|
+
|
|
175
|
+
**Also fixed, for everyone:** `Internal.VERSION.core` was `null` in any ESM
|
|
176
|
+
bundle — it was read with `require("../package.json")` inside a `try`, so the
|
|
177
|
+
failure was silent. That version goes into every remote file ref and proxy mode
|
|
178
|
+
refuses to start without it. Every package now reads its version through a
|
|
179
|
+
static JSON import, which is inlined at build time.
|
|
180
|
+
|
|
181
|
+
Two smaller fixes that came out of running the whole toolchain against a
|
|
182
|
+
TanStack project:
|
|
183
|
+
|
|
184
|
+
- `val versions` reports `@valbuild/tanstack`, and `val debug` writes a snapshot
|
|
185
|
+
that names whichever framework package the captured project actually has.
|
|
186
|
+
- `@valbuild/eslint-plugin` reads a `tsconfig.json` that has comments in it. A
|
|
187
|
+
tsconfig is JSONC, and `JSON.parse` is not — so on any project whose tsconfig
|
|
188
|
+
carries a comment (the TanStack starter's does) the
|
|
189
|
+
`module-in-val-modules` rule threw `Expected double-quoted property name in
|
|
190
|
+
JSON` on the first file and took the whole lint run with it.
|
|
191
|
+
|
|
192
|
+
Three fixes found by driving the Studio against a real TanStack app:
|
|
193
|
+
|
|
194
|
+
- **A draft image now loads on the page.** The source the Studio pushes to the
|
|
195
|
+
host page carries `patch_id` for any file whose bytes are still in a patch, so
|
|
196
|
+
the page asks `/api/val/files/...?patch_id=` rather than a `/public` path that
|
|
197
|
+
nothing has written yet. This was silent — the image just did not appear — and
|
|
198
|
+
it affects any page that reads media through the hooks rather than on the
|
|
199
|
+
server, `@valbuild/next` included.
|
|
200
|
+
- **A splat route no longer logs an error on every render.** TanStack returns
|
|
201
|
+
both `_splat` and `*` for the same parameter; Val reported the second as a
|
|
202
|
+
parameter it could not place in the path.
|
|
203
|
+
- The TanStack example and starter render a 404 page instead of throwing
|
|
204
|
+
`notFound()` from a component, which escaped to the error boundary and logged
|
|
205
|
+
`Error in renderToReadableStream` (and, with no not-found component
|
|
206
|
+
configured, aborted the response) on every miss.
|
|
207
|
+
|
|
208
|
+
### Patch Changes
|
|
209
|
+
|
|
210
|
+
- Updated dependencies [[`c390397`](https://github.com/valbuild/val/commit/c390397cb5e203eb1bedae3a6fab15726e850b90)]:
|
|
211
|
+
- @valbuild/core@0.125.0
|
|
212
|
+
|
|
3
213
|
## 0.124.0
|
|
4
214
|
|
|
5
215
|
### Minor Changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getSitemapTree = require('../../dist/getSitemapTree-
|
|
5
|
+
var getSitemapTree = require('../../dist/getSitemapTree-d1977d3e.cjs.dev.js');
|
|
6
6
|
require('@valbuild/core');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -12,9 +12,12 @@ exports.VAL_CANVAS_MESSAGE = getSitemapTree.VAL_CANVAS_MESSAGE;
|
|
|
12
12
|
exports.VAL_CANVAS_PARAM = getSitemapTree.VAL_CANVAS_PARAM;
|
|
13
13
|
exports.VAL_CONFIG_SESSION_STORAGE_KEY = getSitemapTree.VAL_CONFIG_SESSION_STORAGE_KEY;
|
|
14
14
|
exports.VAL_THEME_SESSION_STORAGE_KEY = getSitemapTree.VAL_THEME_SESSION_STORAGE_KEY;
|
|
15
|
-
exports.getNextAppRouterSitemapTree = getSitemapTree.getNextAppRouterSitemapTree;
|
|
16
15
|
exports.getNextAppRouterSourceFolder = getSitemapTree.getNextAppRouterSourceFolder;
|
|
16
|
+
exports.getPageRouterSitemapTree = getSitemapTree.getPageRouterSitemapTree;
|
|
17
|
+
exports.getPageRouterSourceFolder = getSitemapTree.getPageRouterSourceFolder;
|
|
17
18
|
exports.getPatternFromModuleFilePath = getSitemapTree.getPatternFromModuleFilePath;
|
|
19
|
+
exports.getTanStackRouterSourceFolder = getSitemapTree.getTanStackRouterSourceFolder;
|
|
20
|
+
exports.isTanStackRoutesFolder = getSitemapTree.isTanStackRoutesFolder;
|
|
18
21
|
exports.isValCanvasFrame = getSitemapTree.isValCanvasFrame;
|
|
19
22
|
exports.isValCanvasPageMessage = getSitemapTree.isValCanvasPageMessage;
|
|
20
23
|
exports.isValCanvasStudioMessage = getSitemapTree.isValCanvasStudioMessage;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getSitemapTree = require('../../dist/getSitemapTree-
|
|
5
|
+
var getSitemapTree = require('../../dist/getSitemapTree-b320d033.cjs.prod.js');
|
|
6
6
|
require('@valbuild/core');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -12,9 +12,12 @@ exports.VAL_CANVAS_MESSAGE = getSitemapTree.VAL_CANVAS_MESSAGE;
|
|
|
12
12
|
exports.VAL_CANVAS_PARAM = getSitemapTree.VAL_CANVAS_PARAM;
|
|
13
13
|
exports.VAL_CONFIG_SESSION_STORAGE_KEY = getSitemapTree.VAL_CONFIG_SESSION_STORAGE_KEY;
|
|
14
14
|
exports.VAL_THEME_SESSION_STORAGE_KEY = getSitemapTree.VAL_THEME_SESSION_STORAGE_KEY;
|
|
15
|
-
exports.getNextAppRouterSitemapTree = getSitemapTree.getNextAppRouterSitemapTree;
|
|
16
15
|
exports.getNextAppRouterSourceFolder = getSitemapTree.getNextAppRouterSourceFolder;
|
|
16
|
+
exports.getPageRouterSitemapTree = getSitemapTree.getPageRouterSitemapTree;
|
|
17
|
+
exports.getPageRouterSourceFolder = getSitemapTree.getPageRouterSourceFolder;
|
|
17
18
|
exports.getPatternFromModuleFilePath = getSitemapTree.getPatternFromModuleFilePath;
|
|
19
|
+
exports.getTanStackRouterSourceFolder = getSitemapTree.getTanStackRouterSourceFolder;
|
|
20
|
+
exports.isTanStackRoutesFolder = getSitemapTree.isTanStackRoutesFolder;
|
|
18
21
|
exports.isValCanvasFrame = getSitemapTree.isValCanvasFrame;
|
|
19
22
|
exports.isValCanvasPageMessage = getSitemapTree.isValCanvasPageMessage;
|
|
20
23
|
exports.isValCanvasStudioMessage = getSitemapTree.isValCanvasStudioMessage;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
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,
|
|
1
|
+
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';
|
|
2
2
|
import '@valbuild/core';
|
|
@@ -443,6 +443,14 @@ export declare const Api: {
|
|
|
443
443
|
createdAt: z.ZodString;
|
|
444
444
|
commitMessage: z.ZodNullable<z.ZodString>;
|
|
445
445
|
}, z.core.$strip>>;
|
|
446
|
+
deployments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
447
|
+
deploymentId: z.ZodString;
|
|
448
|
+
deploymentState: z.ZodString;
|
|
449
|
+
commitSha: z.ZodString;
|
|
450
|
+
updatedAt: z.ZodString;
|
|
451
|
+
createdAt: z.ZodString;
|
|
452
|
+
commitMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
453
|
+
}, z.core.$strip>>>;
|
|
446
454
|
config: z.ZodObject<{
|
|
447
455
|
project: z.ZodOptional<z.ZodString>;
|
|
448
456
|
root: z.ZodOptional<z.ZodString>;
|
|
@@ -1,2 +1,26 @@
|
|
|
1
1
|
import { ModuleFilePath } from "@valbuild/core";
|
|
2
2
|
export declare function getNextAppRouterSourceFolder(moduleFilePath: ModuleFilePath): "/app" | "/src/app" | null;
|
|
3
|
+
/**
|
|
4
|
+
* The folder a TanStack Router app keeps its route files in.
|
|
5
|
+
*
|
|
6
|
+
* The same question as above for the other convention: `routes/` at the project
|
|
7
|
+
* root, or under `src/`. A Val module for a route lives beside the route file
|
|
8
|
+
* and is named the same way, so this is the prefix to strip before reading the
|
|
9
|
+
* route pattern out of the rest.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTanStackRouterSourceFolder(moduleFilePath: ModuleFilePath): "/routes" | "/src/routes" | null;
|
|
12
|
+
/**
|
|
13
|
+
* The route folder of whichever page router this module belongs to.
|
|
14
|
+
*
|
|
15
|
+
* The two conventions have disjoint prefixes — `app/` versus `routes/` — so a
|
|
16
|
+
* module file path answers this on its own, which is what the Studio needs: it
|
|
17
|
+
* walks every schema in the project and has no framework to ask.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPageRouterSourceFolder(moduleFilePath: ModuleFilePath): "/app" | "/src/app" | "/routes" | "/src/routes" | null;
|
|
20
|
+
/**
|
|
21
|
+
* Whether a route folder is a TanStack Router one.
|
|
22
|
+
*
|
|
23
|
+
* Exported so the pattern derivation and the source-folder detection cannot
|
|
24
|
+
* drift apart about what `/src/routes` means.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isTanStackRoutesFolder(srcFolder: string): boolean;
|
|
@@ -23,8 +23,17 @@ export type SitemapNode = {
|
|
|
23
23
|
moduleFilePath?: ModuleFilePath;
|
|
24
24
|
sourcePath?: SourcePath | ModuleFilePath;
|
|
25
25
|
};
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function getPageRouterSitemapTree(srcFolder: string, paths: {
|
|
27
27
|
urlPath: string;
|
|
28
28
|
moduleFilePath: string;
|
|
29
29
|
}[]): SitemapNode;
|
|
30
|
+
/**
|
|
31
|
+
* The route pattern a page-router module serves, e.g. `/blogs/[blog]`.
|
|
32
|
+
*
|
|
33
|
+
* Written in Next's vocabulary for both routers on purpose: the pattern is read
|
|
34
|
+
* by `parseRoutePattern`, the sitemap and the Studio's key inputs, none of which
|
|
35
|
+
* should have to know which framework the project uses. The TanStack branch
|
|
36
|
+
* translates that framework's conventions into it; see
|
|
37
|
+
* `tanStackSegmentsOfRoutePath` in `@valbuild/core` for the rules.
|
|
38
|
+
*/
|
|
30
39
|
export declare function getPatternFromModuleFilePath(moduleFilePath: string, srcFolder: string): string;
|
|
@@ -14,12 +14,37 @@ export declare function findSimilar(key: string, targets: string[]): {
|
|
|
14
14
|
target: string;
|
|
15
15
|
distance: number;
|
|
16
16
|
}[];
|
|
17
|
+
/**
|
|
18
|
+
* The record a `keyof:check-keys` error resolves against — the value and the
|
|
19
|
+
* schema at the error's `sourcePath`.
|
|
20
|
+
*
|
|
21
|
+
* Exported for the one consumer that has to know what a resolution DEPENDED
|
|
22
|
+
* on rather than what it concluded: `ValidationStore` re-reads the keys here
|
|
23
|
+
* to decide whether a change to the referenced module can have moved the
|
|
24
|
+
* answer. Keep this and {@link checkKeyIsValid} reading the same record, or the
|
|
25
|
+
* store will invalidate on one record and the resolution answer from another.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getKeyOfRecordAt(sourcePath: SourcePath, snapshot: SchemaSourceSnapshot): {
|
|
28
|
+
source: unknown;
|
|
29
|
+
schema: SerializedSchema | undefined;
|
|
30
|
+
};
|
|
17
31
|
export type ResolvedFix = {
|
|
18
32
|
status: "resolved";
|
|
19
33
|
} | {
|
|
20
34
|
status: "remaining";
|
|
21
35
|
error: ValidationError;
|
|
22
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* The record a `keyof:check-keys` error resolves against, or null for any other
|
|
39
|
+
* error — including a malformed marker, which
|
|
40
|
+
* {@link resolveSchemaSourceFixForError} reports and this has nothing to say
|
|
41
|
+
* about.
|
|
42
|
+
*
|
|
43
|
+
* For a consumer that needs to know what the resolution READS, not what it
|
|
44
|
+
* concludes: `ValidationStore` keeps this per validated module, so that a change
|
|
45
|
+
* to the referenced record can invalidate the module holding the reference.
|
|
46
|
+
*/
|
|
47
|
+
export declare function keyOfRecordPath(error: ValidationError): SourcePath | null;
|
|
23
48
|
/**
|
|
24
49
|
* Resolves a single `keyof:check-keys` or `router:check-route` error against
|
|
25
50
|
* the given schema/source snapshot. Returns:
|
|
@@ -1,12 +1,13 @@
|
|
|
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
|
|
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 SerializedDiscriminatedUnionSchema as SerializedDiscriminatedUnionSchemaT, type SerializedEnumSchema as SerializedEnumSchemaT, 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>;
|
|
6
6
|
export declare const SerializedNumberSchema: z.ZodType<SerializedNumberSchemaT>;
|
|
7
7
|
export declare const SerializedObjectSchema: z.ZodType<SerializedObjectSchemaT>;
|
|
8
8
|
export declare const SerializedArraySchema: z.ZodType<SerializedArraySchemaT>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const SerializedDiscriminatedUnionSchema: z.ZodType<SerializedDiscriminatedUnionSchemaT>;
|
|
10
|
+
export declare const SerializedEnumSchema: z.ZodType<SerializedEnumSchemaT>;
|
|
10
11
|
export declare const ImageEncodeOption: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
|
|
11
12
|
type: z.ZodLiteral<"webp">;
|
|
12
13
|
quality: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Internal } from '@valbuild/core';
|
|
1
|
+
import { Internal, tanStackSegmentsOfRoutePath } from '@valbuild/core';
|
|
2
2
|
|
|
3
3
|
var VAL_CONFIG_SESSION_STORAGE_KEY = "val-config";
|
|
4
4
|
var VAL_THEME_SESSION_STORAGE_KEY = "val-theme";
|
|
@@ -135,6 +135,45 @@ function getNextAppRouterSourceFolder(moduleFilePath) {
|
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* The folder a TanStack Router app keeps its route files in.
|
|
140
|
+
*
|
|
141
|
+
* The same question as above for the other convention: `routes/` at the project
|
|
142
|
+
* root, or under `src/`. A Val module for a route lives beside the route file
|
|
143
|
+
* and is named the same way, so this is the prefix to strip before reading the
|
|
144
|
+
* route pattern out of the rest.
|
|
145
|
+
*/
|
|
146
|
+
function getTanStackRouterSourceFolder(moduleFilePath) {
|
|
147
|
+
if (moduleFilePath.startsWith("/routes/")) {
|
|
148
|
+
return "/routes";
|
|
149
|
+
} else if (moduleFilePath.startsWith("/src/routes/")) {
|
|
150
|
+
return "/src/routes";
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The route folder of whichever page router this module belongs to.
|
|
157
|
+
*
|
|
158
|
+
* The two conventions have disjoint prefixes — `app/` versus `routes/` — so a
|
|
159
|
+
* module file path answers this on its own, which is what the Studio needs: it
|
|
160
|
+
* walks every schema in the project and has no framework to ask.
|
|
161
|
+
*/
|
|
162
|
+
function getPageRouterSourceFolder(moduleFilePath) {
|
|
163
|
+
var _getNextAppRouterSour;
|
|
164
|
+
return (_getNextAppRouterSour = getNextAppRouterSourceFolder(moduleFilePath)) !== null && _getNextAppRouterSour !== void 0 ? _getNextAppRouterSour : getTanStackRouterSourceFolder(moduleFilePath);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Whether a route folder is a TanStack Router one.
|
|
169
|
+
*
|
|
170
|
+
* Exported so the pattern derivation and the source-folder detection cannot
|
|
171
|
+
* drift apart about what `/src/routes` means.
|
|
172
|
+
*/
|
|
173
|
+
function isTanStackRoutesFolder(srcFolder) {
|
|
174
|
+
return srcFolder === "/routes" || srcFolder === "/src/routes";
|
|
175
|
+
}
|
|
176
|
+
|
|
138
177
|
function _toPrimitive(t, r) {
|
|
139
178
|
if ("object" != typeof t || !t) return t;
|
|
140
179
|
var e = t[Symbol.toPrimitive];
|
|
@@ -245,8 +284,14 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
245
284
|
};
|
|
246
285
|
}
|
|
247
286
|
|
|
248
|
-
// Strictly speaking this should be in the
|
|
249
|
-
|
|
287
|
+
// Strictly speaking this should be in the framework packages but it's shared,
|
|
288
|
+
// because we want to use it in the ui package. We want to resolve that somehow.
|
|
289
|
+
//
|
|
290
|
+
// It is one function for both page routers because the tree it builds is made
|
|
291
|
+
// of URL paths, which is the same thing in either: only `srcFolder` and the
|
|
292
|
+
// pattern derivation differ, and both of those are arguments (or the one call
|
|
293
|
+
// below).
|
|
294
|
+
function getPageRouterSitemapTree(srcFolder, paths) {
|
|
250
295
|
var root = {
|
|
251
296
|
type: "node",
|
|
252
297
|
name: "/",
|
|
@@ -358,7 +403,24 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
|
|
|
358
403
|
}
|
|
359
404
|
return root;
|
|
360
405
|
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* The route pattern a page-router module serves, e.g. `/blogs/[blog]`.
|
|
409
|
+
*
|
|
410
|
+
* Written in Next's vocabulary for both routers on purpose: the pattern is read
|
|
411
|
+
* by `parseRoutePattern`, the sitemap and the Studio's key inputs, none of which
|
|
412
|
+
* should have to know which framework the project uses. The TanStack branch
|
|
413
|
+
* translates that framework's conventions into it; see
|
|
414
|
+
* `tanStackSegmentsOfRoutePath` in `@valbuild/core` for the rules.
|
|
415
|
+
*/
|
|
361
416
|
function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
|
|
417
|
+
if (isTanStackRoutesFolder(srcFolder)) {
|
|
418
|
+
var routePath = moduleFilePath.slice(srcFolder.length).replace(/\.val\.[tj]sx?$/, "");
|
|
419
|
+
var segments = tanStackSegmentsOfRoutePath(routePath);
|
|
420
|
+
// "" rather than "/" for the root, so it matches what the Next branch
|
|
421
|
+
// returns for `/app/page.val.ts` — `parseRoutePattern` reads both as [].
|
|
422
|
+
return segments.length === 0 ? "" : "/".concat(segments.join("/"));
|
|
423
|
+
}
|
|
362
424
|
return moduleFilePath.replace(srcFolder, "")
|
|
363
425
|
// TODO: hacky!
|
|
364
426
|
// remove route groups
|
|
@@ -366,4 +428,4 @@ function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
|
|
|
366
428
|
.replace("/page.val.ts", "").replace("/page.val.js", "");
|
|
367
429
|
}
|
|
368
430
|
|
|
369
|
-
export { VAL_CONFIG_SESSION_STORAGE_KEY as V, _createForOfIteratorHelper as _, VAL_THEME_SESSION_STORAGE_KEY as a, VAL_AI_SESSION_STORAGE_KEY as b, VAL_CANVAS_PARAM as c, VAL_CANVAS_MESSAGE as d, isValCanvasStudioMessage as e, isValCanvasFrame as f, getNextAppRouterSourceFolder as g,
|
|
431
|
+
export { VAL_CONFIG_SESSION_STORAGE_KEY as V, _createForOfIteratorHelper as _, VAL_THEME_SESSION_STORAGE_KEY as a, VAL_AI_SESSION_STORAGE_KEY as b, VAL_CANVAS_PARAM as c, VAL_CANVAS_MESSAGE as d, isValCanvasStudioMessage as e, isValCanvasFrame as f, getNextAppRouterSourceFolder as g, getTanStackRouterSourceFolder as h, isValCanvasPageMessage as i, getPageRouterSourceFolder as j, isTanStackRoutesFolder as k, getPageRouterSitemapTree as l, getPatternFromModuleFilePath as m, _objectSpread2 as n, _arrayLikeToArray as o, parseRoutePattern as p, _unsupportedIterableToArray as q, _defineProperty as r, _typeof as s, withValCanvasParam as w };
|
|
@@ -137,6 +137,45 @@ function getNextAppRouterSourceFolder(moduleFilePath) {
|
|
|
137
137
|
return null;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* The folder a TanStack Router app keeps its route files in.
|
|
142
|
+
*
|
|
143
|
+
* The same question as above for the other convention: `routes/` at the project
|
|
144
|
+
* root, or under `src/`. A Val module for a route lives beside the route file
|
|
145
|
+
* and is named the same way, so this is the prefix to strip before reading the
|
|
146
|
+
* route pattern out of the rest.
|
|
147
|
+
*/
|
|
148
|
+
function getTanStackRouterSourceFolder(moduleFilePath) {
|
|
149
|
+
if (moduleFilePath.startsWith("/routes/")) {
|
|
150
|
+
return "/routes";
|
|
151
|
+
} else if (moduleFilePath.startsWith("/src/routes/")) {
|
|
152
|
+
return "/src/routes";
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The route folder of whichever page router this module belongs to.
|
|
159
|
+
*
|
|
160
|
+
* The two conventions have disjoint prefixes — `app/` versus `routes/` — so a
|
|
161
|
+
* module file path answers this on its own, which is what the Studio needs: it
|
|
162
|
+
* walks every schema in the project and has no framework to ask.
|
|
163
|
+
*/
|
|
164
|
+
function getPageRouterSourceFolder(moduleFilePath) {
|
|
165
|
+
var _getNextAppRouterSour;
|
|
166
|
+
return (_getNextAppRouterSour = getNextAppRouterSourceFolder(moduleFilePath)) !== null && _getNextAppRouterSour !== void 0 ? _getNextAppRouterSour : getTanStackRouterSourceFolder(moduleFilePath);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Whether a route folder is a TanStack Router one.
|
|
171
|
+
*
|
|
172
|
+
* Exported so the pattern derivation and the source-folder detection cannot
|
|
173
|
+
* drift apart about what `/src/routes` means.
|
|
174
|
+
*/
|
|
175
|
+
function isTanStackRoutesFolder(srcFolder) {
|
|
176
|
+
return srcFolder === "/routes" || srcFolder === "/src/routes";
|
|
177
|
+
}
|
|
178
|
+
|
|
140
179
|
function _toPrimitive(t, r) {
|
|
141
180
|
if ("object" != typeof t || !t) return t;
|
|
142
181
|
var e = t[Symbol.toPrimitive];
|
|
@@ -247,8 +286,14 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
247
286
|
};
|
|
248
287
|
}
|
|
249
288
|
|
|
250
|
-
// Strictly speaking this should be in the
|
|
251
|
-
|
|
289
|
+
// Strictly speaking this should be in the framework packages but it's shared,
|
|
290
|
+
// because we want to use it in the ui package. We want to resolve that somehow.
|
|
291
|
+
//
|
|
292
|
+
// It is one function for both page routers because the tree it builds is made
|
|
293
|
+
// of URL paths, which is the same thing in either: only `srcFolder` and the
|
|
294
|
+
// pattern derivation differ, and both of those are arguments (or the one call
|
|
295
|
+
// below).
|
|
296
|
+
function getPageRouterSitemapTree(srcFolder, paths) {
|
|
252
297
|
var root = {
|
|
253
298
|
type: "node",
|
|
254
299
|
name: "/",
|
|
@@ -360,7 +405,24 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
|
|
|
360
405
|
}
|
|
361
406
|
return root;
|
|
362
407
|
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* The route pattern a page-router module serves, e.g. `/blogs/[blog]`.
|
|
411
|
+
*
|
|
412
|
+
* Written in Next's vocabulary for both routers on purpose: the pattern is read
|
|
413
|
+
* by `parseRoutePattern`, the sitemap and the Studio's key inputs, none of which
|
|
414
|
+
* should have to know which framework the project uses. The TanStack branch
|
|
415
|
+
* translates that framework's conventions into it; see
|
|
416
|
+
* `tanStackSegmentsOfRoutePath` in `@valbuild/core` for the rules.
|
|
417
|
+
*/
|
|
363
418
|
function getPatternFromModuleFilePath(moduleFilePath, srcFolder) {
|
|
419
|
+
if (isTanStackRoutesFolder(srcFolder)) {
|
|
420
|
+
var routePath = moduleFilePath.slice(srcFolder.length).replace(/\.val\.[tj]sx?$/, "");
|
|
421
|
+
var segments = core.tanStackSegmentsOfRoutePath(routePath);
|
|
422
|
+
// "" rather than "/" for the root, so it matches what the Next branch
|
|
423
|
+
// returns for `/app/page.val.ts` — `parseRoutePattern` reads both as [].
|
|
424
|
+
return segments.length === 0 ? "" : "/".concat(segments.join("/"));
|
|
425
|
+
}
|
|
364
426
|
return moduleFilePath.replace(srcFolder, "")
|
|
365
427
|
// TODO: hacky!
|
|
366
428
|
// remove route groups
|
|
@@ -379,9 +441,12 @@ exports._defineProperty = _defineProperty;
|
|
|
379
441
|
exports._objectSpread2 = _objectSpread2;
|
|
380
442
|
exports._typeof = _typeof;
|
|
381
443
|
exports._unsupportedIterableToArray = _unsupportedIterableToArray;
|
|
382
|
-
exports.getNextAppRouterSitemapTree = getNextAppRouterSitemapTree;
|
|
383
444
|
exports.getNextAppRouterSourceFolder = getNextAppRouterSourceFolder;
|
|
445
|
+
exports.getPageRouterSitemapTree = getPageRouterSitemapTree;
|
|
446
|
+
exports.getPageRouterSourceFolder = getPageRouterSourceFolder;
|
|
384
447
|
exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
|
|
448
|
+
exports.getTanStackRouterSourceFolder = getTanStackRouterSourceFolder;
|
|
449
|
+
exports.isTanStackRoutesFolder = isTanStackRoutesFolder;
|
|
385
450
|
exports.isValCanvasFrame = isValCanvasFrame;
|
|
386
451
|
exports.isValCanvasPageMessage = isValCanvasPageMessage;
|
|
387
452
|
exports.isValCanvasStudioMessage = isValCanvasStudioMessage;
|