@loozo/angular-router 0.0.7 → 0.0.9
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/README.md +178 -39
- package/fesm2022/loozo-angular-router-_core.mjs +33 -2
- package/fesm2022/loozo-angular-router-_core.mjs.map +1 -1
- package/fesm2022/loozo-angular-router-_generated.mjs +196 -43
- package/fesm2022/loozo-angular-router-_generated.mjs.map +1 -1
- package/fesm2022/loozo-angular-router.mjs +2 -2
- package/node/src/builders/serve.js +82 -87
- package/node/src/generation/emit.js +29 -3
- package/node/src/generation/files.d.ts +1 -0
- package/node/src/generation/files.js +13 -2
- package/node/src/generation/overlay.js +9 -2
- package/node/src/generation/sources.js +12 -5
- package/package.json +1 -1
- package/snippets/generated/destinations.generated.ts +25 -1
- package/snippets/src/routes/products/$productId/route.generated.ts +4 -2
- package/snippets/src/routes/reports/$reportId/route.generated.ts +4 -2
- package/snippets/src/routes/teams/$teamId/items/$id/inputs.ts +2 -1
- package/snippets/src/routes/teams/$teamId/items/$id/links.ts +6 -4
- package/snippets/src/routes/teams/$teamId/items/$id/page.spec.ts +29 -0
- package/snippets/src/routes/teams/$teamId/items/$id/route.generated.ts +4 -2
- package/snippets/src/routes/teams/$teamId/members/$memberId/route.generated.ts +4 -2
- package/snippets/src/routes/teams/$teamId/route.generated.ts +4 -2
- package/snippets/src/routes/teams/$teamId/route.ts +3 -0
- package/snippets/src/shell.ts +39 -3
- package/types/loozo-angular-router-_core.d.ts +135 -53
- package/types/loozo-angular-router-_generated.d.ts +111 -61
- package/types/loozo-angular-router.d.ts +2 -2
|
@@ -8,7 +8,8 @@ import { Observable } from "rxjs";
|
|
|
8
8
|
* like Angular's matching callbacks, it runs once while matching and again for
|
|
9
9
|
* the activated route. Neither method performs URL encoding. Codecs have no
|
|
10
10
|
* Angular injection context, and their returned objects are not recursively frozen.
|
|
11
|
-
* For a terminal `$name[]` path, this codec applies
|
|
11
|
+
* For a terminal `$name[]` path or an `arrayParam` search key, this codec applies
|
|
12
|
+
* to each element separately.
|
|
12
13
|
*
|
|
13
14
|
* @typeParam Value - The logical value, never a promise of that value.
|
|
14
15
|
*
|
|
@@ -28,7 +29,8 @@ interface ParamCodec<Value> {
|
|
|
28
29
|
* @returns The logical value, synchronously. Returning a promise or other
|
|
29
30
|
* thenable is a programming error that fails the navigation with a TypeError.
|
|
30
31
|
* @throws An application error for invalid input: an invalid path value makes
|
|
31
|
-
* the route not match, and an invalid search value reads as absent or as its fallback
|
|
32
|
+
* the route not match, and an invalid search value reads as absent or as its fallback
|
|
33
|
+
* (an `arrayParam` key reads an empty array).
|
|
32
34
|
*/
|
|
33
35
|
parse(raw: string): Value;
|
|
34
36
|
/**
|
|
@@ -41,6 +43,7 @@ interface ParamCodec<Value> {
|
|
|
41
43
|
stringify(value: Value): string;
|
|
42
44
|
}
|
|
43
45
|
declare const searchFallback: unique symbol;
|
|
46
|
+
declare const searchArray: unique symbol;
|
|
44
47
|
/**
|
|
45
48
|
* A search-only codec whose key reads a fallback value when it is missing,
|
|
46
49
|
* repeated or invalid, while URL creation may still omit it.
|
|
@@ -48,13 +51,26 @@ declare const searchFallback: unique symbol;
|
|
|
48
51
|
type FallbackCodec<Value> = ParamCodec<Value> & {
|
|
49
52
|
readonly [searchFallback]: true;
|
|
50
53
|
};
|
|
51
|
-
|
|
54
|
+
/**
|
|
55
|
+
* A search-only codec whose key reads every repeated value, in URL order, as a
|
|
56
|
+
* readonly array; its parse and stringify handle one value each.
|
|
57
|
+
*/
|
|
58
|
+
type ArrayCodec<Value> = ParamCodec<Value> & {
|
|
59
|
+
readonly [searchArray]: true;
|
|
60
|
+
};
|
|
61
|
+
/** Codecs that may only wrap a plain codec: not a fallback or array codec. */
|
|
62
|
+
type PlainCodec = {
|
|
52
63
|
readonly [searchFallback]?: never;
|
|
64
|
+
readonly [searchArray]?: never;
|
|
53
65
|
};
|
|
66
|
+
type PathCodec = ParamCodec<any> & PlainCodec;
|
|
54
67
|
type CodecValue<Codec> = Codec extends ParamCodec<infer Value> ? Value : never;
|
|
55
68
|
type HasFallback<Codec> = Codec extends {
|
|
56
69
|
readonly [searchFallback]: true;
|
|
57
70
|
} ? true : false;
|
|
71
|
+
type IsArray<Codec> = Codec extends {
|
|
72
|
+
readonly [searchArray]: true;
|
|
73
|
+
} ? true : false;
|
|
58
74
|
/** Type-only marker: a codec whose parse returns a promise fails where it is declared. */
|
|
59
75
|
interface SynchronousParse {
|
|
60
76
|
/** Never present: `parse` must return its value synchronously, not a Promise. */
|
|
@@ -68,6 +84,7 @@ type SyncCodecs<Codecs> = { [Key in keyof Codecs]: SyncValue<ParseResult<Codecs[
|
|
|
68
84
|
export declare function codecFallback(codec: object): {
|
|
69
85
|
readonly value: unknown;
|
|
70
86
|
} | undefined;
|
|
87
|
+
export declare function isArrayCodec(codec: object): boolean;
|
|
71
88
|
declare function validateCodec(codec: unknown): asserts codec is ParamCodec<any>;
|
|
72
89
|
/**
|
|
73
90
|
* Preserves strings verbatim, including empty strings and literal percent text.
|
|
@@ -115,7 +132,8 @@ export declare function enumParam<const Values extends readonly string[]>(values
|
|
|
115
132
|
* value of the codec's type, while URL creation, links, navigation and redirect
|
|
116
133
|
* replacements may still omit it. The fallback is returned as is: it is neither
|
|
117
134
|
* parsed nor copied. Present values delegate to the wrapped codec unchanged.
|
|
118
|
-
* Fallback codecs are search-only: a path param can't use one
|
|
135
|
+
* Fallback codecs are search-only: a path param can't use one, and neither
|
|
136
|
+
* `withFallback` nor `arrayParam` can wrap one.
|
|
119
137
|
*
|
|
120
138
|
* @example
|
|
121
139
|
* ```ts
|
|
@@ -127,10 +145,36 @@ export declare function enumParam<const Values extends readonly string[]>(values
|
|
|
127
145
|
* @param codec - The codec used for present search values.
|
|
128
146
|
* @param fallback - The value read when the key is missing, repeated or invalid.
|
|
129
147
|
* @returns A search-only codec that reads the fallback in place of an absent value.
|
|
130
|
-
* @throws TypeError if the codec lacks callable parse/stringify methods
|
|
131
|
-
* has a fallback.
|
|
148
|
+
* @throws TypeError if the codec lacks callable parse/stringify methods, already
|
|
149
|
+
* has a fallback or is an `arrayParam` codec.
|
|
150
|
+
*/
|
|
151
|
+
export declare function withFallback<Value>(codec: ParamCodec<Value> & SyncValue<NoInfer<Value>> & PlainCodec, fallback: NoInfer<Value>): FallbackCodec<Value>;
|
|
152
|
+
/**
|
|
153
|
+
* Reads every value of a repeated search key (`?tag=a&tag=b`) as a readonly array.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* The key always reads an array, never `undefined`: each value parses with the
|
|
157
|
+
* wrapped codec, in URL order and keeping duplicates. A missing key reads `[]`, and
|
|
158
|
+
* so does a key with any invalid value: one invalid value empties the whole list.
|
|
159
|
+
* URL creation, links, navigation and redirect replacements write one `key=value`
|
|
160
|
+
* pair per element in array order; `[]` and `undefined` leave the key out, so an
|
|
161
|
+
* empty list and a missing key share one URL. Array codecs are search-only (a path
|
|
162
|
+
* uses a terminal `$name[]` instead) and take no fallback: `withFallback` can't wrap
|
|
163
|
+
* one, and `arrayParam` can't wrap a fallback or another array codec.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* search: { tag: arrayParam(enumParam(["news", "guides"])) }
|
|
168
|
+
* // ?tag=news&tag=guides reads ["news", "guides"]; no tag and ?tag=other read [].
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @typeParam Value - The wrapped codec's logical value.
|
|
172
|
+
* @param codec - The codec for each value.
|
|
173
|
+
* @returns A search-only codec whose key reads `readonly Value[]`.
|
|
174
|
+
* @throws TypeError if the codec lacks callable parse/stringify methods, has a
|
|
175
|
+
* fallback or is already an array codec.
|
|
132
176
|
*/
|
|
133
|
-
export declare function
|
|
177
|
+
export declare function arrayParam<Value>(codec: ParamCodec<Value> & SyncValue<NoInfer<Value>> & PlainCodec): ArrayCodec<Value>;
|
|
134
178
|
type ValidName<Name extends string> = Name extends "" | "__proto__" | `...${string}` | `${string}?${string}` | `${string}*${string}` | `${string}[]${string}` ? false : true;
|
|
135
179
|
type SegmentValid<Segment extends string> = Segment extends `$${infer Name}` ? ValidName<Name> : Segment extends "" | "." | ".." | "*" | "**" | `:${string}` ? false : true;
|
|
136
180
|
type ValidateSegments<Path extends string, Scalars extends string = never> = Path extends `${infer Head}/${infer Tail}` ? Head extends `$${string}[]` ? false : SegmentValid<Head> extends true ? ValidateSegments<Tail, Scalars | ScalarName<Head>> : false : Path extends `$${infer Name}[]` ? ValidName<Name> extends true ? Name extends Scalars ? false : true : false : SegmentValid<Path>;
|
|
@@ -153,20 +197,25 @@ declare const routeBrand: unique symbol;
|
|
|
153
197
|
*
|
|
154
198
|
* @remarks
|
|
155
199
|
* Prefer inference from `defineRoute` over explicit generic arguments. The
|
|
156
|
-
* optional `__params`, `__search` and `
|
|
200
|
+
* optional `__params`, `__search`, `__data` and `__title` members are type witnesses only;
|
|
157
201
|
* they are not populated runtime properties. Parent/codec/effective-path metadata
|
|
158
202
|
* is private. Spreading a declaration does not produce another valid route.
|
|
159
203
|
*
|
|
160
204
|
* @typeParam Path - The local authored path literal, not the effective URL path.
|
|
161
205
|
* @typeParam Params - Effective inherited and local logical path values.
|
|
162
206
|
* @typeParam Search - Effective inherited and local logical search values; keys
|
|
163
|
-
* without a fallback are optional. URL creation accepts every key as optional.
|
|
207
|
+
* without a fallback or array codec are optional. URL creation accepts every key as optional.
|
|
164
208
|
* @typeParam Resolvers - Local resolver callbacks; data unwraps Promise/Observable
|
|
165
209
|
* results and excludes Angular RedirectCommand values.
|
|
166
210
|
* @typeParam Fragments - This declaration's own allowed fragment-name union.
|
|
167
211
|
* @typeParam Catchall - Whether the declaration is a terminal catchall leaf.
|
|
212
|
+
* @typeParam Data - Effective resolver data: the ancestors' resolver results, then
|
|
213
|
+
* this declaration's own, a nearer key hiding an ancestor's key of the same name.
|
|
214
|
+
* Defaults to the local results alone.
|
|
215
|
+
* @typeParam Title - `string` when this declaration or an ancestor declares a title,
|
|
216
|
+
* otherwise `undefined`.
|
|
168
217
|
*/
|
|
169
|
-
interface Route<Path extends string, Params, Search, Resolvers = {}, Fragments extends string = string, Catchall extends boolean = CatchallName<Path> extends never ? false : true> {
|
|
218
|
+
interface Route<Path extends string, Params, Search, Resolvers = {}, Fragments extends string = string, Catchall extends boolean = CatchallName<Path> extends never ? false : true, Data = LocalData<Resolvers>, Title extends string | undefined = undefined> {
|
|
170
219
|
/** Type-only nominal brand carrying fragment and catchall metadata; not populated at runtime. */
|
|
171
220
|
readonly [routeBrand]: {
|
|
172
221
|
/** Type-only: this declaration's own allowed fragment-name union. */
|
|
@@ -180,8 +229,10 @@ interface Route<Path extends string, Params, Search, Resolvers = {}, Fragments e
|
|
|
180
229
|
readonly __params?: Params;
|
|
181
230
|
/** Type-only witness for effective search values; not populated at runtime. */
|
|
182
231
|
readonly __search?: Search;
|
|
183
|
-
/** Type-only witness for unwrapped
|
|
184
|
-
readonly __data?:
|
|
232
|
+
/** Type-only witness for unwrapped effective resolver data, excluding redirects. */
|
|
233
|
+
readonly __data?: Data;
|
|
234
|
+
/** Type-only witness: string when this declaration or an ancestor declares a title. */
|
|
235
|
+
readonly __title?: Title;
|
|
185
236
|
/** The snapshotted local resolver map, retaining original callback identities. */
|
|
186
237
|
readonly resolve?: Readonly<Resolvers>;
|
|
187
238
|
/** The original native rerun policy; omission preserves Angular's default. */
|
|
@@ -189,23 +240,42 @@ interface Route<Path extends string, Params, Search, Resolvers = {}, Fragments e
|
|
|
189
240
|
}
|
|
190
241
|
type Unwrap<Value> = Value extends Promise<infer Inner> | Observable<infer Inner> ? Unwrap<Inner> : Value;
|
|
191
242
|
type Resolved<Callback> = Callback extends ((...args: any[]) => infer Value) ? Exclude<Unwrap<Value>, RedirectCommand> : never;
|
|
192
|
-
type AnyRoute = Route<string, any, any, any, any, boolean>;
|
|
243
|
+
type AnyRoute = Route<string, any, any, any, any, boolean, any, any>;
|
|
193
244
|
/** Extracts a declaration's effective inherited and local path-value types. */
|
|
194
|
-
type ParamsOf<Target> = Target extends Route<string, infer Params, any, any, any, boolean> ? Params : {};
|
|
195
|
-
/** Extracts effective parsed search-value types; keys without a fallback are optional. */
|
|
196
|
-
type SearchOf<Target> = Target extends Route<string, any, infer Search, any, any, boolean> ? Search : {};
|
|
245
|
+
type ParamsOf<Target> = Target extends Route<string, infer Params, any, any, any, boolean, any, any> ? Params : {};
|
|
246
|
+
/** Extracts effective parsed search-value types; keys without a fallback or array codec are optional. */
|
|
247
|
+
type SearchOf<Target> = Target extends Route<string, any, infer Search, any, any, boolean, any, any> ? Search : {};
|
|
197
248
|
/**
|
|
198
249
|
* Effective search values accepted by URL creation: every key may be omitted or
|
|
199
250
|
* `undefined`, and a supplied value has the key's codec type.
|
|
200
251
|
*/
|
|
201
252
|
type SearchInputOf<Target> = { readonly [Key in keyof SearchOf<Target>]?: SearchOf<Target>[Key] | undefined; };
|
|
202
253
|
/** Extracts only the selected declaration's own allowed fragment-name union. */
|
|
203
|
-
type FragmentsOf<Target> = Target extends Route<string, any, any, any, infer Fragments, boolean> ? Fragments : never;
|
|
254
|
+
type FragmentsOf<Target> = Target extends Route<string, any, any, any, infer Fragments, boolean, any, any> ? Fragments : never;
|
|
204
255
|
type CodecMap = Record<string, ParamCodec<any>>;
|
|
205
256
|
type LocalParams<Path extends string, Codecs> = { readonly [Key in keyof Codecs]: Key extends CatchallName<Path> ? readonly CodecValue<Codecs[Key]>[] : CodecValue<Codecs[Key]>; };
|
|
206
|
-
type
|
|
257
|
+
type SearchValue<Codec> = IsArray<Codec> extends true ? readonly CodecValue<Codec>[] : CodecValue<Codec>;
|
|
258
|
+
type AlwaysReads<Codec> = HasFallback<Codec> extends true ? true : IsArray<Codec>;
|
|
259
|
+
type SearchValues<Codecs> = { readonly [Key in keyof Codecs as AlwaysReads<Codecs[Key]> extends true ? Key : never]: SearchValue<Codecs[Key]>; } & { readonly [Key in keyof Codecs as AlwaysReads<Codecs[Key]> extends true ? never : Key]?: SearchValue<Codecs[Key]>; };
|
|
207
260
|
type EffectiveParams<Path extends string, Codecs, Parent> = ParamsOf<Parent> & LocalParams<Path, Codecs>;
|
|
208
261
|
type EffectiveSearch<Codecs, Parent> = SearchOf<Parent> & SearchValues<Codecs>;
|
|
262
|
+
/** Unwrapped results of a declaration's own resolvers, excluding redirects. */
|
|
263
|
+
type LocalData<Resolvers> = { readonly [Key in keyof Resolvers]: Resolved<Resolvers[Key]>; };
|
|
264
|
+
/**
|
|
265
|
+
* Resolver data of a declaration's whole chain: the parent's effective data with
|
|
266
|
+
* the local results laid over it, so a local key hides an inherited key of the same name.
|
|
267
|
+
*/
|
|
268
|
+
type EffectiveData<Resolvers, Parent> = Unshadowed<Parent extends {
|
|
269
|
+
readonly __data?: infer Data;
|
|
270
|
+
} ? Data : {}, keyof Resolvers> & LocalData<Resolvers>;
|
|
271
|
+
/** The title type of a declaration's chain: string when it or an ancestor declares one. */
|
|
272
|
+
type TitleOf<Target> = Target extends {
|
|
273
|
+
readonly __title?: infer Title;
|
|
274
|
+
} ? Title : undefined;
|
|
275
|
+
/** A local title makes the chain's title a string; otherwise the parent's title type carries over. */
|
|
276
|
+
type EffectiveTitle<LocalTitle, Parent> = unknown extends LocalTitle ? TitleOf<Parent> : [LocalTitle] extends [undefined] ? TitleOf<Parent> : string;
|
|
277
|
+
type KeyIdentity<Key> = Key extends number ? `${Key}` : Key;
|
|
278
|
+
type Unshadowed<Inherited, Local> = { readonly [Key in keyof Inherited as KeyIdentity<Key> extends KeyIdentity<Local> ? never : Key]: Inherited[Key]; };
|
|
209
279
|
/**
|
|
210
280
|
* Shared parsed inputs supplied to typed guards and resolvers.
|
|
211
281
|
* The container and maps are shallow-frozen; nested codec values remain opaque.
|
|
@@ -213,7 +283,7 @@ type EffectiveSearch<Codecs, Parent> = SearchOf<Parent> & SearchValues<Codecs>;
|
|
|
213
283
|
type Inputs<Params, Search> = {
|
|
214
284
|
/** Logical positional path values, not Angular's matrix-merged params. */
|
|
215
285
|
readonly params: Readonly<Params>;
|
|
216
|
-
/** Logical declared search values; keys without a value
|
|
286
|
+
/** Logical declared search values; plain keys without a valid value are absent. */
|
|
217
287
|
readonly search: Readonly<Search>;
|
|
218
288
|
};
|
|
219
289
|
/**
|
|
@@ -286,36 +356,44 @@ type PathInputError = Error & {
|
|
|
286
356
|
* to redirect; `true` is rejected because the params are invalid.
|
|
287
357
|
*/
|
|
288
358
|
type InvalidParamsHandler = (error: PathInputError, routeConfig: Route$1, segments: UrlSegment[], partialSnapshot: PartialMatchRouteSnapshot) => MaybeAsync<false | UrlTree | RedirectCommand>;
|
|
289
|
-
type SearchInput<Schema, Keys extends keyof Schema> = keyof Schema extends never ? Record<string, never> : Pick<Schema, Keys>;
|
|
359
|
+
type SearchInput<Schema, Keys extends keyof Schema> = keyof Schema extends never ? Record<string, never> : [Keys] extends [never] ? Schema : Pick<Schema, Keys>;
|
|
360
|
+
/** The `search` field type of URL values for supplied keys; `never` for a searchless destination. */
|
|
361
|
+
type SearchFieldOf<Target extends AnyRoute, SearchKeys> = keyof SearchInputOf<Target> extends never ? never : SearchInput<SearchInputOf<Target>, SearchKeys & keyof SearchInputOf<Target>>;
|
|
362
|
+
/** URL values for a destination without effective path params. */
|
|
363
|
+
type PathlessUrlValues<Search, Fragment> = {
|
|
364
|
+
/** Forbidden: the destination has no effective path params. */
|
|
365
|
+
params?: never;
|
|
366
|
+
/** Any declared search values; absent or undefined values are omitted. `never` when the destination declares no search. */
|
|
367
|
+
search?: Search;
|
|
368
|
+
/** An optional logical name declared by this exact destination, without `#`. `never` when it declares none. */
|
|
369
|
+
fragment?: Fragment;
|
|
370
|
+
};
|
|
371
|
+
/** URL values for a destination with effective path params. */
|
|
372
|
+
type PathUrlValues<Params, Search, Fragment> = {
|
|
373
|
+
/** All effective path values; catchalls are readonly element-value arrays. */
|
|
374
|
+
params: Params;
|
|
375
|
+
/** Any declared search values; absent or undefined values are omitted. `never` when the destination declares no search. */
|
|
376
|
+
search?: Search;
|
|
377
|
+
/** An optional logical name declared by this exact destination, without `#`. `never` when it declares none. */
|
|
378
|
+
fragment?: Fragment;
|
|
379
|
+
};
|
|
290
380
|
/**
|
|
291
381
|
* Explicit values for URL creation and generated link/navigation calls.
|
|
292
382
|
* Effective path keys must be present; every search key may be omitted.
|
|
293
383
|
* Paramless/searchless routes forbid those fields. Fragment names come only
|
|
294
384
|
* from the destination's own declaration.
|
|
295
385
|
*
|
|
386
|
+
* @remarks
|
|
387
|
+
* One object type literal, not an intersection: TypeScript relates a string to
|
|
388
|
+
* each member of an intersection without its weak-type check, so String's own
|
|
389
|
+
* `search` method would match the search field. A type literal, unlike an
|
|
390
|
+
* interface, stays assignable to `Record<string, unknown>`.
|
|
391
|
+
*
|
|
296
392
|
* @typeParam Target - The selected route declaration.
|
|
297
393
|
* @typeParam SearchKeys - Supplied search keys inferred by each call to preserve
|
|
298
394
|
* optional-key typing, including keys that coincide with Object members.
|
|
299
395
|
*/
|
|
300
|
-
type UrlValues<Target extends AnyRoute, SearchKeys extends keyof SearchOf<Target> = keyof SearchOf<Target>> =
|
|
301
|
-
/** Forbidden when the destination has no effective path params. */
|
|
302
|
-
params?: never;
|
|
303
|
-
} : {
|
|
304
|
-
/** All effective path values; catchalls are readonly element-value arrays. */
|
|
305
|
-
params: ParamsOf<Target>;
|
|
306
|
-
}) & (keyof SearchInputOf<Target> extends never ? {
|
|
307
|
-
/** Forbidden when the destination has no search declarations. */
|
|
308
|
-
search?: never;
|
|
309
|
-
} : {
|
|
310
|
-
/** Any declared search values; absent or undefined values are omitted. */
|
|
311
|
-
search?: SearchInput<SearchInputOf<Target>, SearchKeys & keyof SearchInputOf<Target>>;
|
|
312
|
-
}) & (FragmentsOf<Target> extends never ? {
|
|
313
|
-
/** Forbidden when this declaration has no fragment names. */
|
|
314
|
-
fragment?: never;
|
|
315
|
-
} : {
|
|
316
|
-
/** An optional logical name declared by this exact destination, without `#`. */
|
|
317
|
-
fragment?: FragmentsOf<Target>;
|
|
318
|
-
});
|
|
396
|
+
type UrlValues<Target extends AnyRoute, SearchKeys extends keyof SearchOf<Target> = keyof SearchOf<Target>> = keyof ParamsOf<Target> extends never ? PathlessUrlValues<SearchFieldOf<Target, SearchKeys>, FragmentsOf<Target>> : PathUrlValues<ParamsOf<Target>, SearchFieldOf<Target, SearchKeys>, FragmentsOf<Target>>;
|
|
319
397
|
type CompatibleKeys<Source, Value> = { [Key in keyof Source]: Source[Key] extends Value ? Key : never; }[keyof Source];
|
|
320
398
|
type Mapping<Source, Destination> = { [Key in keyof Destination]: CompatibleKeys<Source, Destination[Key]>; };
|
|
321
399
|
type Forwardable<Source, Destination> = { [Key in keyof Destination]: Key extends keyof Source ? Source[Key] extends Destination[Key] ? never : Key : Key; }[keyof Destination] extends never ? true : false;
|
|
@@ -364,10 +442,10 @@ type Redirect<SourceParams, Target extends AnyRoute, SearchKeys extends keyof Se
|
|
|
364
442
|
* Options inferred by `defineRoute`; Angular's structural route fields are excluded.
|
|
365
443
|
* Local params/search cannot redeclare keys inherited from the parent.
|
|
366
444
|
*/
|
|
367
|
-
type RouteConfig<Path extends string, Parent extends AnyRoute | undefined, Params extends Record<string, PathCodec>, Search extends CodecMap, Resolvers, Fragments extends readonly string[], Target extends AnyRoute | undefined, ReplacementKeys extends keyof SearchOf<Target
|
|
445
|
+
type RouteConfig<Path extends string, Parent extends AnyRoute | undefined, Params extends Record<string, PathCodec>, Search extends CodecMap, Resolvers, Fragments extends readonly string[], Target extends AnyRoute | undefined, ReplacementKeys extends keyof SearchOf<Target>, Title = unknown> = {
|
|
368
446
|
/** Genuine authored parent; pathless nodes retain inherited input ownership. */
|
|
369
|
-
parent?: Parent & (Parent extends Route<string, any, any, any, any, true> ? never : unknown);
|
|
370
|
-
/** Local search codecs; a key is absent unless present and valid
|
|
447
|
+
parent?: Parent & (Parent extends Route<string, any, any, any, any, true, any, any> ? never : unknown);
|
|
448
|
+
/** Local search codecs; a plain key is absent unless present and valid. withFallback and arrayParam keys always read a value. */
|
|
371
449
|
search?: Search & Record<Extract<keyof Search, keyof SearchOf<Parent>>, never> & SyncCodecs<NoInfer<Search>>;
|
|
372
450
|
/** Local parsed-input resolvers; not snapshot-first native ResolveFn callbacks. */
|
|
373
451
|
resolve?: Resolvers & Record<PropertyKey, Resolver<EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>>> & {
|
|
@@ -384,7 +462,7 @@ type RouteConfig<Path extends string, Parent extends AnyRoute | undefined, Param
|
|
|
384
462
|
/** Native route-scoped providers; provider factories are not run at declaration. */
|
|
385
463
|
providers?: Route$1["providers"];
|
|
386
464
|
/** A static title, or a parsed-input callback; not a snapshot-first native ResolveFn. */
|
|
387
|
-
title?: string | TitleResolver<EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent
|
|
465
|
+
title?: Title & (string | TitleResolver<EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>>);
|
|
388
466
|
/** Native static data; cannot set the reserved __loozoAngularRouterRouteId key. */
|
|
389
467
|
data?: Route$1["data"] & {
|
|
390
468
|
__loozoAngularRouterRouteId?: never;
|
|
@@ -435,8 +513,9 @@ export declare function routeMetadata(route: unknown): RouteMetadata;
|
|
|
435
513
|
* catchall. Repeated local scalar names reuse one value. Leading/trailing or
|
|
436
514
|
* repeated slashes, dot segments and Angular `:name`/wildcard notation are invalid.
|
|
437
515
|
*
|
|
438
|
-
* Parents compose effective params/search transitively,
|
|
439
|
-
* pathless nodes
|
|
516
|
+
* Parents compose effective params/search and resolver data transitively,
|
|
517
|
+
* including through pathless nodes; a local resolver key hides an inherited
|
|
518
|
+
* one. Children cannot redeclare ancestor-owned param or search keys or have a
|
|
440
519
|
* catchall parent. Fragment names belong only to this declaration.
|
|
441
520
|
* The route and copied containers are shallow-frozen; application codecs,
|
|
442
521
|
* callbacks, providers and opaque values retain identity and are not deep-frozen.
|
|
@@ -450,10 +529,11 @@ export declare function routeMetadata(route: unknown): RouteMetadata;
|
|
|
450
529
|
* @param config - Local codecs, parent, fragments and supported native behavior.
|
|
451
530
|
* Structural Angular options such as children, component and matcher are
|
|
452
531
|
* generator-owned and cannot be overridden.
|
|
453
|
-
* @returns A frozen route preserving inferred effective input and
|
|
532
|
+
* @returns A frozen route preserving inferred effective input and resolver data types.
|
|
454
533
|
* @throws TypeError for invalid paths/configuration, missing or extra local
|
|
455
|
-
* codecs, fallback codecs in path params, inherited key conflicts,
|
|
456
|
-
*
|
|
534
|
+
* codecs, fallback or array codecs in path params, inherited key conflicts,
|
|
535
|
+
* nonarray redirect replacements for array search keys, or nongenuine
|
|
536
|
+
* parent/redirect routes.
|
|
457
537
|
*
|
|
458
538
|
* @example
|
|
459
539
|
* ```ts
|
|
@@ -464,20 +544,22 @@ export declare function routeMetadata(route: unknown): RouteMetadata;
|
|
|
464
544
|
* });
|
|
465
545
|
* ```
|
|
466
546
|
*/
|
|
467
|
-
export declare function defineRoute<const Path extends string, Parent extends AnyRoute | undefined = undefined, Params extends Record<string, PathCodec> = {}, Search extends CodecMap = {}, Resolvers extends Record<string, (...args: any[]) => unknown> = {}, const Fragments extends readonly string[] = [], Target extends AnyRoute | undefined = undefined, ReplacementKeys extends keyof SearchOf<NoInfer<Target>> = never>(path: Path & ValidPath<Path>, config: RouteConfig<Path, Parent, Params, Search, Resolvers, Fragments, Target, ReplacementKeys>): Route<Path, EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>, Resolvers, Fragments[number], CatchallName<Path> extends never ? false : true
|
|
547
|
+
export declare function defineRoute<const Path extends string, Parent extends AnyRoute | undefined = undefined, Params extends Record<string, PathCodec> = {}, Search extends CodecMap = {}, Resolvers extends Record<string, (...args: any[]) => unknown> = {}, const Fragments extends readonly string[] = [], Target extends AnyRoute | undefined = undefined, ReplacementKeys extends keyof SearchOf<NoInfer<Target>> = never, Title = unknown>(path: Path & ValidPath<Path>, config: RouteConfig<Path, Parent, Params, Search, Resolvers, Fragments, Target, ReplacementKeys, Title>): Route<Path, EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>, Resolvers, Fragments[number], CatchallName<Path> extends never ? false : true, EffectiveData<Resolvers, Parent>, EffectiveTitle<Title, Parent>>;
|
|
468
548
|
/**
|
|
469
549
|
* Synchronously serializes a route's explicit values into a root-relative URL.
|
|
470
550
|
*
|
|
471
551
|
* @remarks
|
|
472
552
|
* Includes inherited path/search declarations, but only this route's fragment
|
|
473
553
|
* names. Every effective path value must be supplied; any search key may be
|
|
474
|
-
* omitted. Searchless/paramless routes forbid those records. Catchalls
|
|
554
|
+
* omitted. Searchless/paramless routes forbid those records. Catchalls and
|
|
555
|
+
* `arrayParam` search keys require readonly arrays, including a valid empty array.
|
|
475
556
|
* Values are never taken from a current navigation.
|
|
476
557
|
*
|
|
477
558
|
* Stringifies without calling parsers, guards, resolvers or redirects. Static
|
|
478
559
|
* segments and logical values are component-encoded (also escaping parentheses),
|
|
479
560
|
* so a dynamic slash becomes `%2F`. Search keys are globally sorted; omitted
|
|
480
|
-
* and `undefined` values are left out. An
|
|
561
|
+
* and `undefined` values are left out. An `arrayParam` key writes one pair per
|
|
562
|
+
* element in array order, and nothing for `[]`. An empty effective path produces `/`.
|
|
481
563
|
* Redirect declarations serialize their source URL, not their redirect target.
|
|
482
564
|
*
|
|
483
565
|
* @param route - A genuine declaration from this physical package instance,
|
|
@@ -487,7 +569,7 @@ export declare function defineRoute<const Path extends string, Parent extends An
|
|
|
487
569
|
* @returns A root-relative URL string, typed `` `/${string}` ``; this does not navigate or
|
|
488
570
|
* return a UrlTree.
|
|
489
571
|
* @throws TypeError for invalid routes/records, missing or unknown keys,
|
|
490
|
-
* undeclared fragments, nonarray catchalls, nonstring codec output, or empty/dot
|
|
572
|
+
* undeclared fragments, nonarray catchalls or array search values, nonstring codec output, or empty/dot
|
|
491
573
|
* path output. Application stringifier failures propagate unchanged.
|
|
492
574
|
* @throws URIError for ill-formed Unicode in a serialized value.
|
|
493
575
|
*
|
|
@@ -502,4 +584,4 @@ export declare function defineRoute<const Path extends string, Parent extends An
|
|
|
502
584
|
* ```
|
|
503
585
|
*/
|
|
504
586
|
export declare function createUrl<Target extends AnyRoute, SearchKeys extends keyof SearchOf<NoInfer<Target>> = never>(route: Target, values: UrlValues<NoInfer<Target>, SearchKeys>): `/${string}`;
|
|
505
|
-
export type { AnyRoute, FragmentsOf, Inputs, ParamCodec, ParamsOf, Route, RouteMetadata, SearchOf, UrlValues };
|
|
587
|
+
export type { AnyRoute, FragmentsOf, Inputs, ParamCodec, ParamsOf, PathUrlValues, PathlessUrlValues, Route, RouteMetadata, SearchFieldOf, SearchOf, TitleOf, UrlValues };
|