@uniflowed/config 0.0.0-alpha.35 → 0.0.0-alpha.39

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.
Files changed (2) hide show
  1. package/internal/schema.js +122 -2
  2. package/package.json +1 -1
@@ -161,8 +161,10 @@ export type PackageManagerSpec = string;
161
161
  * because it is the binary that is running. `"bun"` is `bun test`, on the Bun
162
162
  * it names — so it also decides the test runtime when `test.runtime` is
163
163
  * absent, and a `test.runtime` naming anything else is an error. The version
164
- * follows the same grammar as a runtime's. `uf test` refuses a Bun runner until
165
- * ubugeeei-prod/uf#942 lands, rather than running its own suite in its place.
164
+ * follows the same grammar as a runtime's. Under a Bun runner `uf test` hands
165
+ * the files its discovery found to `bun test`, with uf's Flow preload, and
166
+ * `@uniflowed/test` resolves to `bun:test`; what Bun has no equivalent for
167
+ * raises `UnsupportedError` by name. See guide/testing, "Choosing a runner".
166
168
  *
167
169
  * The type of `test.runner`.
168
170
  */
@@ -196,6 +198,64 @@ export type PluginEntry =
196
198
  readonly apply?: "build" | "serve" | "always",
197
199
  };
198
200
 
201
+ // # `app.router`'s three lists
202
+ //
203
+ // Next.js's `redirects`, `rewrites` and `headers`, written as data rather than
204
+ // as async functions, because this file is read without being run. A `source`
205
+ // is a path in the route table's own grammar — a literal segment, `:name` for
206
+ // one segment, and a trailing `:name*` for the rest — and each rule is an exact
207
+ // object, so a misspelled field is an error here and where `uf` reads the file.
208
+
209
+ /**
210
+ * One redirect: a request for `source` is answered with a redirect to
211
+ * `destination`, before anything else answers — a file included.
212
+ *
213
+ * `destination` is a path of this application or an absolute `http(s)` URL,
214
+ * and may use the `:name` and `:name*` segments `source` declared. The
215
+ * request's query is passed through. `permanent: true` is a `308`, `false` a
216
+ * `307`; both keep the method.
217
+ */
218
+ export type RouteRedirect = {
219
+ readonly source: string,
220
+ readonly destination: string,
221
+ readonly permanent: boolean,
222
+ };
223
+
224
+ /**
225
+ * One rewrite: a request for `source` is answered by the route at
226
+ * `destination`, and the address bar keeps `source`.
227
+ *
228
+ * `destination` is a path of this application — never another origin, which
229
+ * is a route handler that fetches — and may use `source`'s segments. Applied
230
+ * after the build's own files and before middleware, so the middleware that
231
+ * runs is the destination's.
232
+ */
233
+ export type RouteRewrite = {
234
+ readonly source: string,
235
+ readonly destination: string,
236
+ };
237
+
238
+ /**
239
+ * Response headers for every request whose path matches `source`, files
240
+ * included. Every matching rule applies, in order, and a later one setting the
241
+ * same name wins — over the response's own header of that name, too.
242
+ */
243
+ export type RouteHeaders = {
244
+ readonly source: string,
245
+ readonly headers: { readonly [name: string]: string },
246
+ };
247
+
248
+ /**
249
+ * Which spelling of a path is the page.
250
+ *
251
+ * `"never"` answers `/about/` with a `308` to `/about` and writes the page as
252
+ * `about.html`; `"always"` answers `/about` with a `308` to `/about/` and
253
+ * writes `about/index.html`; `"ignore"`, the default, answers both and writes
254
+ * `about/index.html`. `next.config.js`'s `trailingSlash: false`, `true` and
255
+ * `skipTrailingSlashRedirect: true`.
256
+ */
257
+ export type RouterTrailingSlash = "never" | "always" | "ignore";
258
+
199
259
  /**
200
260
  * A ceiling `uf build` fails over, and what it is measured on.
201
261
  *
@@ -453,6 +513,37 @@ export type UniflowedConfig = {
453
513
  // **library** rather than an application, and `uf build` reads it: see
454
514
  // `build.lib` below and docs/app/reference/config.
455
515
  readonly enabled?: boolean,
516
+ /**
517
+ * Redirects answered before anything else, in order; the first whose
518
+ * `source` matches wins. `next.config.js`'s `redirects()`. See
519
+ * `RouteRedirect` and docs/app/guide/routing.
520
+ */
521
+ readonly redirects?: $ReadOnlyArray<RouteRedirect>,
522
+ /**
523
+ * Routes served at another path, in order; the first whose `source`
524
+ * matches wins. `next.config.js`'s `rewrites()`, without proxying. See
525
+ * `RouteRewrite` and docs/app/guide/routing.
526
+ */
527
+ readonly rewrites?: $ReadOnlyArray<RouteRewrite>,
528
+ /**
529
+ * Response headers by path; every matching rule applies.
530
+ * `next.config.js`'s `headers()`. See `RouteHeaders` and
531
+ * docs/app/guide/routing.
532
+ */
533
+ readonly headers?: $ReadOnlyArray<RouteHeaders>,
534
+ /**
535
+ * The path the whole application is served under — `"/docs"` — with no
536
+ * trailing slash. Every link, redirect, asset URL, payload URL and
537
+ * sitemap entry carries it, and a request outside it is a `404`. The
538
+ * sources of the three lists above are written without it.
539
+ * `next.config.js`'s `basePath`.
540
+ */
541
+ readonly basePath?: string,
542
+ /**
543
+ * Which spelling of a path is the page; see `RouterTrailingSlash`.
544
+ * `"ignore"` when absent.
545
+ */
546
+ readonly trailingSlash?: RouterTrailingSlash,
456
547
  },
457
548
  readonly rendering?: {
458
549
  // `"csr"` is the one value that cannot share the list: it renders every
@@ -467,6 +558,12 @@ export type UniflowedConfig = {
467
558
  // request — the client router is not installed and `Link` renders an
468
559
  // ordinary anchor. See docs/app/guide/routing/navigation.
469
560
  readonly navigation?: "client" | "document",
561
+ // How long, in whole seconds, the client router shows a route it already
562
+ // fetched or prefetched without asking the server again: a click on a
563
+ // prefetched link, a second visit and the back button all read it. `0`,
564
+ // the default, keeps nothing. `router.refresh()` and every server action
565
+ // clear it. See docs/app/guide/routing and docs/app/guide/cache.
566
+ readonly staleTime?: number,
470
567
  readonly cache?: {
471
568
  readonly actions?: boolean,
472
569
  readonly data?: boolean,
@@ -916,6 +1013,29 @@ export type UniflowedConfig = {
916
1013
  },
917
1014
  },
918
1015
  readonly tasks?: { readonly [string]: TaskDefinition },
1016
+ /**
1017
+ * Tasks `uf prepare` runs before a commit, keyed by a glob over the staged
1018
+ * files.
1019
+ *
1020
+ * A glob with no `/` matches a file's name wherever it is; one with a `/`
1021
+ * matches its path from the project root. Each task named runs once, with
1022
+ * every staged file its glob matches appended to its command, over what is
1023
+ * staged rather than what is on disk. A fix to a fully staged file is staged
1024
+ * with it; a fix to a half-staged one is not kept, and stops the commit.
1025
+ */
1026
+ readonly staged?: { readonly [string]: string | $ReadOnlyArray<string> },
1027
+ /**
1028
+ * Where `uf ui add` writes the components a project owns, and where
1029
+ * `uf ui list` and `uf ui diff` look for them.
1030
+ *
1031
+ * `directory` is relative to the project root, and `app/components/ui` when
1032
+ * absent. Every component goes in the one directory, because each imports
1033
+ * the ones it builds on as siblings (`./button.js`). A path that leaves the
1034
+ * project is refused before anything is written.
1035
+ */
1036
+ readonly ui?: {
1037
+ readonly directory?: string,
1038
+ },
919
1039
  /**
920
1040
  * Vite's own configuration, merged over the one uf generates.
921
1041
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniflowed/config",
3
- "version": "0.0.0-alpha.35",
3
+ "version": "0.0.0-alpha.39",
4
4
  "description": "Flow declarations for @uniflowed/config, part of the Unified Toolchain for Flow.",
5
5
  "type": "module",
6
6
  "license": "MIT",