paramour 0.5.1 → 0.6.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/dist/codec.d.ts +16 -18
- package/dist/describe.d.ts +14 -3
- package/dist/describe.js +20 -3
- package/dist/errors.d.ts +89 -10
- package/dist/errors.js +79 -13
- package/dist/href.d.ts +38 -41
- package/dist/href.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/internal.d.ts +4 -3
- package/dist/internal.js +4 -3
- package/dist/p.d.ts +11 -10
- package/dist/p.js +45 -37
- package/dist/path.d.ts +26 -26
- package/dist/path.js +78 -42
- package/dist/route.d.ts +73 -73
- package/dist/route.js +30 -30
- package/dist/safe-decode.d.ts +10 -9
- package/dist/safe-decode.js +12 -11
- package/dist/schema.d.ts +4 -4
- package/dist/schema.js +4 -4
- package/dist/search.d.ts +32 -28
- package/dist/search.js +76 -42
- package/dist/standard-schema.d.ts +15 -15
- package/dist/standard-schema.js +15 -15
- package/package.json +1 -1
package/dist/route.js
CHANGED
|
@@ -2,10 +2,10 @@ import { describeType, foreignMessage, ParamourError, ParamsDecodeError, SearchD
|
|
|
2
2
|
import { decodeParams, tokenizePath, } from "./path.js";
|
|
3
3
|
import { decodeSearch, } from "./search.js";
|
|
4
4
|
/**
|
|
5
|
-
* Defines an App Router route: the URL-shaped path literal
|
|
6
|
-
* param/search codec configs. Validates the literal eagerly
|
|
7
|
-
*
|
|
8
|
-
* serialization
|
|
5
|
+
* Defines an App Router route: the URL-shaped path literal plus its
|
|
6
|
+
* param/search codec configs. Validates the literal eagerly — fail-fast at
|
|
7
|
+
* config definition time, the same stance as eager `.default()`
|
|
8
|
+
* serialization. The router is a *declaration*, not an inference:
|
|
9
9
|
* pre-codegen the registry cannot distinguish routers, so an inferred brand
|
|
10
10
|
* would silently degrade in world A — the split constructor is what keeps
|
|
11
11
|
* the brand intact there.
|
|
@@ -15,11 +15,11 @@ export function defineAppRoute(path, config) {
|
|
|
15
15
|
...routeData("app", path, config),
|
|
16
16
|
async parse(props) {
|
|
17
17
|
const [paramsSource, searchSource] = await awaitProps(props);
|
|
18
|
-
//
|
|
18
|
+
// Params first — a params failure throws before search decodes.
|
|
19
19
|
const decodedParams = decodeParams(route, paramsSource ?? {});
|
|
20
20
|
return {
|
|
21
21
|
params: decodedParams,
|
|
22
|
-
search: decodeSearch(route["~search"], searchSource ?? {}),
|
|
22
|
+
search: decodeSearch(route["~search"], searchSource ?? {}, route.path),
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
25
|
async parseParams(props) {
|
|
@@ -28,7 +28,7 @@ export function defineAppRoute(path, config) {
|
|
|
28
28
|
},
|
|
29
29
|
async parseSearch(props) {
|
|
30
30
|
const source = await awaitProp(props.searchParams);
|
|
31
|
-
return decodeSearch(route["~search"], source ?? {});
|
|
31
|
+
return decodeSearch(route["~search"], source ?? {}, route.path);
|
|
32
32
|
},
|
|
33
33
|
safeParse(props) {
|
|
34
34
|
return safely(() => route.parse(props));
|
|
@@ -43,16 +43,16 @@ export function defineAppRoute(path, config) {
|
|
|
43
43
|
return route;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* Defines a Pages Router route
|
|
46
|
+
* Defines a Pages Router route — neither router is the default; see
|
|
47
47
|
* {@link defineAppRoute} for why the constructor is split rather than
|
|
48
|
-
* inferred
|
|
49
|
-
*
|
|
48
|
+
* inferred. Same eager literal validation; the parse surface is the sync
|
|
49
|
+
* context pair.
|
|
50
50
|
*/
|
|
51
51
|
export function definePagesRoute(path, config) {
|
|
52
52
|
const data = routeData("pages", path, config);
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
53
|
+
// The query→params extraction and query→search subtraction both key on
|
|
54
|
+
// the dynamic-segment names; computed once at define time (the ~segments
|
|
55
|
+
// ethos — per-call parses never re-derive them).
|
|
56
56
|
const paramNames = new Set();
|
|
57
57
|
for (const segment of data["~segments"]) {
|
|
58
58
|
if (segment.kind !== "static")
|
|
@@ -62,7 +62,7 @@ export function definePagesRoute(path, config) {
|
|
|
62
62
|
...data,
|
|
63
63
|
parseContext(context) {
|
|
64
64
|
const [paramsSource, searchSource] = splitPagesContext(context, paramNames);
|
|
65
|
-
//
|
|
65
|
+
// Params first — same morally-a-404 rule as the app surface.
|
|
66
66
|
// R5: pages sources (ctx.params / ctx.query) are already percent-decoded
|
|
67
67
|
// by Node's querystring layer, so skip core's decode to avoid a
|
|
68
68
|
// double-decode (App-Router's decodeParams keeps the default).
|
|
@@ -71,12 +71,12 @@ export function definePagesRoute(path, config) {
|
|
|
71
71
|
});
|
|
72
72
|
return {
|
|
73
73
|
params: decodedParams,
|
|
74
|
-
search: decodeSearch(route["~search"], searchSource),
|
|
74
|
+
search: decodeSearch(route["~search"], searchSource, route.path),
|
|
75
75
|
};
|
|
76
76
|
},
|
|
77
77
|
safeParseContext(context) {
|
|
78
|
-
// safely's taxonomy
|
|
79
|
-
//
|
|
78
|
+
// safely's taxonomy, minus the await: only decode failures become the
|
|
79
|
+
// error arm; contract violations stay loud.
|
|
80
80
|
try {
|
|
81
81
|
return { data: route.parseContext(context), status: "success" };
|
|
82
82
|
}
|
|
@@ -96,17 +96,17 @@ function awaitProp(value) {
|
|
|
96
96
|
return rebrandRejection(Promise.resolve(value));
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* Awaits BOTH props members before any decode runs
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
99
|
+
* Awaits BOTH props members before any decode runs: the params-before-search
|
|
100
|
+
* rule is about *decode* order, not await order — throwing while the
|
|
101
|
+
* searchParams promise is still pending would turn a rejecting props promise
|
|
102
|
+
* into an unhandled rejection.
|
|
103
103
|
*/
|
|
104
104
|
function awaitProps(props) {
|
|
105
105
|
return rebrandRejection(Promise.all([props.params, props.searchParams]));
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Own enumerable properties of `source` whose keys are NOT in `keys` —
|
|
109
|
-
* the query→search subtraction
|
|
109
|
+
* the query→search subtraction. Entries → fromEntries so keys like
|
|
110
110
|
* "__proto__" stay ordinary own properties (decodeParams's ethos).
|
|
111
111
|
*/
|
|
112
112
|
function omitOwn(source, keys) {
|
|
@@ -114,7 +114,7 @@ function omitOwn(source, keys) {
|
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Own properties of `source` at exactly `keys` — the query→params
|
|
117
|
-
* extraction
|
|
117
|
+
* extraction. A name missing from the source is simply omitted, so
|
|
118
118
|
* it surfaces downstream as decodeParams's ordinary required-missing issue,
|
|
119
119
|
* never a crash here.
|
|
120
120
|
*/
|
|
@@ -153,9 +153,9 @@ async function rebrandRejection(promise) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
|
-
* Shared define-time core of both constructors
|
|
157
|
-
* eagerly (
|
|
158
|
-
*
|
|
156
|
+
* Shared define-time core of both constructors: validates the literal
|
|
157
|
+
* eagerly (throwing ParamourError on an invalid literal) and pins the data
|
|
158
|
+
* members both parse surfaces build on. The conditional RouteConfig is
|
|
159
159
|
* unresolved inside a generic body; the cast here is the one place its two
|
|
160
160
|
* branches are unified.
|
|
161
161
|
*/
|
|
@@ -171,7 +171,7 @@ function routeData(router, path, config) {
|
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
|
-
* Wraps a throwing parse into the status-discriminated shape
|
|
174
|
+
* Wraps a throwing parse into the status-discriminated shape.
|
|
175
175
|
* Only decode failures become the `error` arm; source-contract violations
|
|
176
176
|
* and rebranded foreign errors stay loud.
|
|
177
177
|
*/
|
|
@@ -188,13 +188,13 @@ async function safely(run) {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
|
-
* Splits a pages context into its params/search decode sources
|
|
191
|
+
* Splits a pages context into its params/search decode sources.
|
|
192
192
|
* `params` is authoritative when present — handed to decodeParams whole,
|
|
193
193
|
* whose own contract check rejects a garbage member; absent, path params
|
|
194
194
|
* are extracted from `query` by name. Search is always `query` minus the
|
|
195
195
|
* path-param names. A missing `query` is a CONTRACT violation, not a decode
|
|
196
196
|
* issue: `getStaticProps` has no query string, so composing its context
|
|
197
|
-
* here would be a lie
|
|
197
|
+
* here would be a lie — the error names the supported path instead.
|
|
198
198
|
*/
|
|
199
199
|
function splitPagesContext(context, paramNames) {
|
|
200
200
|
const untrusted = context;
|
|
@@ -204,7 +204,7 @@ function splitPagesContext(context, paramNames) {
|
|
|
204
204
|
const { params, query } = untrusted;
|
|
205
205
|
const untrustedQuery = query;
|
|
206
206
|
if (typeof untrustedQuery !== "object" || untrustedQuery === null) {
|
|
207
|
-
throw new ParamourError(`pages context has no query object (got ${describeType(untrustedQuery)}): getStaticProps contexts carry no query string — decode ctx.params with safeDecodeParams instead
|
|
207
|
+
throw new ParamourError(`pages context has no query object (got ${describeType(untrustedQuery)}): getStaticProps contexts carry no query string — decode ctx.params with safeDecodeParams instead`);
|
|
208
208
|
}
|
|
209
209
|
return [params ?? pickOwn(query, paramNames), omitOwn(query, paramNames)];
|
|
210
210
|
}
|
package/dist/safe-decode.d.ts
CHANGED
|
@@ -2,15 +2,16 @@ import type { AnyRoute, InferRouteParams, SafeResult } from "./route.js";
|
|
|
2
2
|
import { type DecodeParamsOptions, type ParamsSource } from "./path.js";
|
|
3
3
|
import { type SearchOutputOf, type SearchSource } from "./search.js";
|
|
4
4
|
/**
|
|
5
|
-
* Sync `SafeResult` twins of {@link decodeParams} / {@link decodeSearch}
|
|
6
|
-
*
|
|
7
|
-
* `safeParse*`
|
|
8
|
-
* middleware, route handlers — already hold a
|
|
9
|
-
* Same taxonomy as route.ts's `safely`: only a
|
|
10
|
-
* `error` arm; source-contract violations,
|
|
11
|
-
* async-schema misuse
|
|
5
|
+
* Sync `SafeResult` twins of {@link decodeParams} / {@link decodeSearch},
|
|
6
|
+
* carrying the route methods' safe-parse stance down to the
|
|
7
|
+
* standalone-function layer: `safeParse*` awaits props, but sync callers —
|
|
8
|
+
* client hooks, middleware, route handlers — already hold a
|
|
9
|
+
* decoded-value-layer source. Same taxonomy as route.ts's `safely`: only a
|
|
10
|
+
* decode failure becomes the `error` arm; source-contract violations,
|
|
11
|
+
* rebranded foreign errors, and async-schema misuse stay loud and propagate
|
|
12
|
+
* unchanged.
|
|
12
13
|
*/
|
|
13
|
-
/** Decoded route params as a `SafeResult` (discriminated on `status
|
|
14
|
+
/** Decoded route params as a `SafeResult` (discriminated on `status`). */
|
|
14
15
|
export declare function safeDecodeParams<R extends AnyRoute>(route: R, source: ParamsSource, options?: DecodeParamsOptions): SafeResult<InferRouteParams<R>>;
|
|
15
|
-
/** Decoded search params as a `SafeResult` (discriminated on `status
|
|
16
|
+
/** Decoded search params as a `SafeResult` (discriminated on `status`). */
|
|
16
17
|
export declare function safeDecodeSearch<R extends AnyRoute>(route: R, source: SearchSource): SafeResult<SearchOutputOf<R["~search"]>>;
|
package/dist/safe-decode.js
CHANGED
|
@@ -2,15 +2,16 @@ import { ParamsDecodeError, SearchDecodeError } from "./errors.js";
|
|
|
2
2
|
import { decodeParams, } from "./path.js";
|
|
3
3
|
import { decodeSearch, } from "./search.js";
|
|
4
4
|
/**
|
|
5
|
-
* Sync `SafeResult` twins of {@link decodeParams} / {@link decodeSearch}
|
|
6
|
-
*
|
|
7
|
-
* `safeParse*`
|
|
8
|
-
* middleware, route handlers — already hold a
|
|
9
|
-
* Same taxonomy as route.ts's `safely`: only a
|
|
10
|
-
* `error` arm; source-contract violations,
|
|
11
|
-
* async-schema misuse
|
|
5
|
+
* Sync `SafeResult` twins of {@link decodeParams} / {@link decodeSearch},
|
|
6
|
+
* carrying the route methods' safe-parse stance down to the
|
|
7
|
+
* standalone-function layer: `safeParse*` awaits props, but sync callers —
|
|
8
|
+
* client hooks, middleware, route handlers — already hold a
|
|
9
|
+
* decoded-value-layer source. Same taxonomy as route.ts's `safely`: only a
|
|
10
|
+
* decode failure becomes the `error` arm; source-contract violations,
|
|
11
|
+
* rebranded foreign errors, and async-schema misuse stay loud and propagate
|
|
12
|
+
* unchanged.
|
|
12
13
|
*/
|
|
13
|
-
/** Decoded route params as a `SafeResult` (discriminated on `status
|
|
14
|
+
/** Decoded route params as a `SafeResult` (discriminated on `status`). */
|
|
14
15
|
export function safeDecodeParams(route, source, options) {
|
|
15
16
|
try {
|
|
16
17
|
return { data: decodeParams(route, source, options), status: "success" };
|
|
@@ -21,16 +22,16 @@ export function safeDecodeParams(route, source, options) {
|
|
|
21
22
|
throw error;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
/** Decoded search params as a `SafeResult` (discriminated on `status
|
|
25
|
+
/** Decoded search params as a `SafeResult` (discriminated on `status`). */
|
|
25
26
|
export function safeDecodeSearch(route, source) {
|
|
26
27
|
try {
|
|
27
|
-
// decodeSearch is keyed on SearchOutputOf (
|
|
28
|
+
// decodeSearch is keyed on SearchOutputOf (SS6) — the correct
|
|
28
29
|
// public type — but AnyRoute erases its SC to `any`, so for a still-
|
|
29
30
|
// generic R the call's value side reduces to `unknown` while the
|
|
30
31
|
// annotation side stays deferred. The cast bridges that inference gap to
|
|
31
32
|
// the SAME (correct) type.
|
|
32
33
|
return {
|
|
33
|
-
data: decodeSearch(route["~search"], source),
|
|
34
|
+
data: decodeSearch(route["~search"], source, route.path),
|
|
34
35
|
status: "success",
|
|
35
36
|
};
|
|
36
37
|
}
|
package/dist/schema.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
2
2
|
/**
|
|
3
3
|
* Runs a Standard Schema synchronously and returns the raw result. Standard
|
|
4
4
|
* Schema permits async validation, but URL parsing must be sync — an async
|
|
5
|
-
* schema is a documented runtime error
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* schema is a documented runtime error. Shared by `p.ts` (which joins
|
|
6
|
+
* `result.issues` into one message string) and the raw-search decode path
|
|
7
|
+
* (which needs structured `Issue[]` with `path`) — each call site maps
|
|
8
|
+
* issues its own way.
|
|
9
9
|
*/
|
|
10
10
|
export declare function runStandardSchemaSync<Out>(schema: StandardSchemaV1<unknown, Out>, value: unknown): StandardSchemaV1.Result<Out>;
|
package/dist/schema.js
CHANGED
|
@@ -2,10 +2,10 @@ import { ParamourError } from "./errors.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Runs a Standard Schema synchronously and returns the raw result. Standard
|
|
4
4
|
* Schema permits async validation, but URL parsing must be sync — an async
|
|
5
|
-
* schema is a documented runtime error
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* schema is a documented runtime error. Shared by `p.ts` (which joins
|
|
6
|
+
* `result.issues` into one message string) and the raw-search decode path
|
|
7
|
+
* (which needs structured `Issue[]` with `path`) — each call site maps
|
|
8
|
+
* issues its own way.
|
|
9
9
|
*/
|
|
10
10
|
export function runStandardSchemaSync(schema, value) {
|
|
11
11
|
const result = schema["~standard"].validate(value);
|
package/dist/search.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
2
|
import type { AnyCodec, OutputOf, PresenceOf } from "./codec.js";
|
|
3
3
|
/**
|
|
4
|
-
* href-input side (
|
|
4
|
+
* href-input side (D4): required presence stays required;
|
|
5
5
|
* optional and defaulted keys may be omitted. Array (arity-"many") keys may
|
|
6
6
|
* also be omitted: absent and [] are the same wire state (S6/P6), so
|
|
7
7
|
* requiring `tags: []` ceremony would be pure noise. Omittable keys also
|
|
@@ -17,14 +17,14 @@ export type InferSearchInput<S extends SearchConfig> = {
|
|
|
17
17
|
[K in OptionalInputKeys<S>]?: OutputOf<S[K]> | undefined;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* Parse-output side (
|
|
20
|
+
* Parse-output side (D4): every declared key is PRESENT on the
|
|
21
21
|
* object; optional presence contributes `| undefined` to the value type.
|
|
22
22
|
*/
|
|
23
23
|
export type InferSearchOutput<S extends SearchConfig> = {
|
|
24
24
|
[K in keyof S]: PresenceOf<S[K]> extends "optional" ? OutputOf<S[K]> | undefined : OutputOf<S[K]>;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
* The whole-object search escape hatch (
|
|
27
|
+
* The whole-object search escape hatch (SS1/SS2): wraps a bare
|
|
28
28
|
* Standard Schema in a branded marker so `search:` config discrimination is
|
|
29
29
|
* unambiguous at both the type and runtime level. `~`-prefixed members are
|
|
30
30
|
* reserved (codec convention) — a codec map never carries them at the top
|
|
@@ -37,7 +37,7 @@ export interface RawSearch<S extends StandardSchemaV1> {
|
|
|
37
37
|
/** A search-params schema: key → codec. */
|
|
38
38
|
export type SearchConfig = Record<string, AnyCodec>;
|
|
39
39
|
/**
|
|
40
|
-
* href / encode side of a `search:` config (
|
|
40
|
+
* href / encode side of a `search:` config (SS6): a `RawSearch`
|
|
41
41
|
* route accepts the raw wire record (SS5 — the schema never runs on encode,
|
|
42
42
|
* so there's no encode-side type to infer from it); a codec map keeps its
|
|
43
43
|
* existing `InferSearchInput` behavior. Module-exported for route.ts/href.ts,
|
|
@@ -45,23 +45,23 @@ export type SearchConfig = Record<string, AnyCodec>;
|
|
|
45
45
|
*/
|
|
46
46
|
export type SearchInputOf<SC> = SC extends RawSearch<StandardSchemaV1> ? Record<string, string | string[]> : SC extends SearchConfig ? InferSearchInput<SC> : never;
|
|
47
47
|
/**
|
|
48
|
-
* Parse-output side of a `search:` config (
|
|
48
|
+
* Parse-output side of a `search:` config (SS6): a `RawSearch`
|
|
49
49
|
* route's output is the schema's own inferred output; a codec map keeps its
|
|
50
50
|
* existing `InferSearchOutput` behavior. Module-exported for
|
|
51
51
|
* route.ts/href.ts, not barrel-exported.
|
|
52
52
|
*/
|
|
53
53
|
export type SearchOutputOf<SC> = SC extends RawSearch<infer S> ? StandardSchemaV1.InferOutput<S> : SC extends SearchConfig ? InferSearchOutput<SC> : never;
|
|
54
54
|
/**
|
|
55
|
-
* The `search:` config slot's full type (
|
|
55
|
+
* The `search:` config slot's full type (SS2): a codec map (the
|
|
56
56
|
* main road) or a `RawSearch` marker (the escape hatch). Internal — not
|
|
57
57
|
* barrel-exported; `Route`/`RouteConfig`/`HrefArgs` consume it as their `SC`
|
|
58
58
|
* bound.
|
|
59
59
|
*/
|
|
60
60
|
export type SearchSlot = RawSearch<StandardSchemaV1> | SearchConfig;
|
|
61
61
|
/**
|
|
62
|
-
* Decoded value-layer sources
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* Decoded value-layer sources: Next's server `searchParams` shape or the
|
|
63
|
+
* client's `URLSearchParams`. Both are already percent-decoded by the
|
|
64
|
+
* platform.
|
|
65
65
|
*/
|
|
66
66
|
export type SearchSource = Record<string, string | string[] | undefined> | URLSearchParams;
|
|
67
67
|
type OptionalInputKeys<S extends SearchConfig> = {
|
|
@@ -80,15 +80,19 @@ export declare function buildSearchString(pairs: readonly (readonly [string, str
|
|
|
80
80
|
* under keys paramour doesn't own can never fail a decode.
|
|
81
81
|
* Throws {@link SearchDecodeError} carrying one issue per failed key.
|
|
82
82
|
*
|
|
83
|
-
* A `RawSearch` config (
|
|
83
|
+
* A `RawSearch` config (SS2) branches to the whole-object schema
|
|
84
84
|
* path instead: every source key reaches the schema (P8 does not apply
|
|
85
85
|
* there — the schema owns stripping or passing through extras).
|
|
86
|
+
*
|
|
87
|
+
* `routePath` anchors a thrown {@link SearchDecodeError} to the owning
|
|
88
|
+
* route's path pattern — route-level surfaces pass `route.path`; standalone
|
|
89
|
+
* callers (nuqs, devtools) omit it and the error stays route-less.
|
|
86
90
|
*/
|
|
87
|
-
export declare function decodeSearch<S extends SearchSlot>(config: S, source: SearchSource): SearchOutputOf<S>;
|
|
91
|
+
export declare function decodeSearch<S extends SearchSlot>(config: S, source: SearchSource, routePath?: string): SearchOutputOf<S>;
|
|
88
92
|
/**
|
|
89
93
|
* encodeURIComponent throws a raw URIError on lone surrogates; wrap it so
|
|
90
94
|
* the documented "every error is a ParamourError" contract holds (S7).
|
|
91
|
-
* Exported for path.ts (the byte-layer chokepoint is shared with
|
|
95
|
+
* Exported for path.ts (the byte-layer chokepoint is shared with path
|
|
92
96
|
* segment encoding), not from the package barrel.
|
|
93
97
|
*/
|
|
94
98
|
export declare function encodeComponent(text: string): string;
|
|
@@ -98,7 +102,7 @@ export declare function encodeComponent(text: string): string;
|
|
|
98
102
|
* Caveat: JS property enumeration puts integer-like keys ("0", "42") first
|
|
99
103
|
* in ascending numeric order regardless of declaration — declaration order
|
|
100
104
|
* is unrecoverable for those, so they sort numerically before all others.
|
|
101
|
-
* Params equal to their `.default()` are elided (
|
|
105
|
+
* Params equal to their `.default()` are elided (D8), compared by
|
|
102
106
|
* serialized wire form against the live default (re-serialized per encode —
|
|
103
107
|
* a build-time snapshot would go stale if a reference-typed default were
|
|
104
108
|
* mutated, silently dropping explicit values that then decode differently).
|
|
@@ -106,13 +110,13 @@ export declare function encodeComponent(text: string): string;
|
|
|
106
110
|
* time-varying factory would elide an explicit value that later decodes as
|
|
107
111
|
* a different one.
|
|
108
112
|
*
|
|
109
|
-
* A `RawSearch` config (
|
|
110
|
-
*
|
|
111
|
-
*
|
|
113
|
+
* A `RawSearch` config (SS5) branches to a raw pass-through instead: no
|
|
114
|
+
* serializer exists for a whole-object schema, so the caller's record goes
|
|
115
|
+
* straight to the byte layer and the schema never runs on encode.
|
|
112
116
|
*/
|
|
113
117
|
export declare function encodeSearch<S extends SearchSlot>(config: S, input: SearchInputOf<S>): [string, string][];
|
|
114
118
|
/**
|
|
115
|
-
* Runtime discriminant for the `search:` slot (
|
|
119
|
+
* Runtime discriminant for the `search:` slot (SS2): probes the
|
|
116
120
|
* `~kind` marker's VALUE, which is unambiguous against a codec map — a map
|
|
117
121
|
* key literally named "~kind" would hold a codec object, never the marker
|
|
118
122
|
* string. Exported from the package barrel so derived surfaces
|
|
@@ -126,22 +130,22 @@ export declare function isRawSearch(config: SearchSlot): config is RawSearch<Sta
|
|
|
126
130
|
* the codec's `.catch()` recovery applied (decodeSearch always recovers a
|
|
127
131
|
* caught failure, so a probe through it cannot tell "parsed cleanly" from
|
|
128
132
|
* "failed and was caught"). Exists for reflection-driven tooling — the
|
|
129
|
-
* devtools panel's catch-attribution probe
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
+
* devtools panel's catch-attribution probe — and any other derived surface
|
|
134
|
+
* that must observe the raw parse outcome. A parse failure throws the
|
|
135
|
+
* codec's own {@link ParseError}; foreign throws from a custom codec
|
|
136
|
+
* propagate unwrapped, matching decodeSearch's taxonomy. For
|
|
133
137
|
* arity-"many" codecs this parses ONE element of the repeated-key array,
|
|
134
138
|
* not the whole array (the same contract as `~parseElement` itself).
|
|
135
139
|
*/
|
|
136
140
|
export declare function parseValue(codec: AnyCodec, raw: string): unknown;
|
|
137
141
|
/**
|
|
138
|
-
* The whole-object search escape hatch (
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
142
|
+
* The whole-object search escape hatch (SS1): an explicit, greppable wrapper
|
|
143
|
+
* around a bare Standard Schema so a route's `search:` slot never falls into
|
|
144
|
+
* the degraded raw mode by accident — a bare `search: schema` could be
|
|
145
|
+
* confused for a codec map, but `rawSearch` is a conscious act. Per-key
|
|
146
|
+
* defaults/`.catch()` and round-trip encoding are deliberately unavailable
|
|
147
|
+
* here (SS7); reach for `p.custom` if you need bidirectional per-key
|
|
148
|
+
* transforms instead.
|
|
145
149
|
*/
|
|
146
150
|
export declare function rawSearch<S extends StandardSchemaV1>(schema: S): RawSearch<S>;
|
|
147
151
|
/**
|