@kitbag/router 0.17.4 → 0.17.6

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.
@@ -11,7 +11,6 @@ import { PublicProps } from 'vue';
11
11
  import { Ref } from 'vue';
12
12
  import { UnwrapRef } from 'vue';
13
13
  import { VNode } from 'vue';
14
- import { ZodSchema } from 'zod';
15
14
 
16
15
  declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
17
16
 
@@ -374,12 +373,11 @@ declare type ExtractParamName<TParam extends PropertyKey> = TParam extends `?${i
374
373
  declare type ExtractParamsFromString<TValue extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TValue extends `${string}${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? Record<Param, ExtractWithParamsParamType<Param, TParams>> & ExtractParamsFromString<Rest, TParams> : Record<never, never>;
375
374
 
376
375
  /**
377
- * Extracts the actual type from a parameter type, handling getters, setters, and potential undefined values.
378
- * This type also is responsible for narrowing possibly undefined values when the param has a default value.
376
+ * Extracts the actual type from a parameter type, handling getters and setters.
379
377
  * @template TParam - The parameter type.
380
378
  * @returns The extracted type, or 'string' as a fallback.
381
379
  */
382
- declare type ExtractParamType<TParam extends Param, TParamKey extends PropertyKey = string> = TParam extends Required<ParamGetSet> ? Exclude<ExtractParamTypeWithoutLosingOptional<TParam, TParamKey>, undefined> : ExtractParamTypeWithoutLosingOptional<TParam, TParamKey>;
380
+ declare type ExtractParamType<TParam extends Param> = TParam extends ParamGetSet<infer Type> ? Type : TParam extends ParamGetter ? ReturnType<TParam> : TParam extends ZodSchemaLike<infer Type> ? Type : TParam extends LiteralParam ? TParam : string;
383
381
 
384
382
  /**
385
383
  * Transforms a record of parameter types into a type with optional properties where the original type allows undefined.
@@ -387,37 +385,25 @@ declare type ExtractParamType<TParam extends Param, TParamKey extends PropertyKe
387
385
  * @returns A new type with the appropriate properties marked as optional.
388
386
  */
389
387
  declare type ExtractParamTypes<TParams extends Record<string, Param>> = Identity<MakeOptional<{
390
- [K in keyof TParams as ExtractParamName<K>]: ExtractParamType<TParams[K], K>;
388
+ [K in keyof TParams as ExtractParamName<K>]: ExtractParamType<TParams[K]>;
391
389
  }>>;
392
390
 
393
- declare type ExtractParamTypesWithoutLosingOptional<TParams extends Record<string, Param>> = Identity<MakeOptional<{
394
- [K in keyof TParams as ExtractParamName<K>]: ExtractParamTypeWithoutLosingOptional<TParams[K], K>;
391
+ /**
392
+ * Transforms a record of parameter types into a type with optional properties where the original type allows undefined.
393
+ * @template TParams - The record of parameter types, possibly including undefined.
394
+ * @returns A new type with the appropriate properties marked as optional.
395
+ */
396
+ declare type ExtractParamTypesWithOptional<TParams extends Record<string, Param>> = Identity<MakeOptional<{
397
+ [K in keyof TParams as ExtractParamName<K>]: K extends `?${string}` ? TParams[K] extends Required<ParamGetSet> ? ExtractParamType<TParams[K]> : ExtractParamType<TParams[K]> | undefined : ExtractParamType<TParams[K]>;
395
398
  }>>;
396
399
 
397
- declare type ExtractParamTypeWithoutLosingOptional<TParam extends Param, TParamKey extends PropertyKey> = TParam extends ParamGetSet<infer Type> ? TParamKey extends `?${string}` ? Type | undefined : Type : TParam extends ParamGetter ? TParamKey extends `?${string}` ? ReturnType<TParam> | undefined : ReturnType<TParam> : TParam extends ZodSchema<infer Type> ? TParamKey extends `?${string}` ? Type | undefined : Type : TParam extends LiteralParam ? TParamKey extends `?${string}` ? TParam | undefined : TParam : TParamKey extends `?${string}` ? string | undefined : string;
398
-
399
400
  /**
400
401
  * Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
401
402
  * This parameter object type represents the expected type when accessing params from router.route or useRoute.
402
403
  * @template TRoute - The route type from which to extract and merge parameter types.
403
404
  * @returns A record of parameter names to their respective types, extracted and merged from both path and query parameters.
404
405
  */
405
- declare type ExtractRouteParamTypes<TRoute> = TRoute extends {
406
- path: {
407
- params: infer PathParams extends Record<string, Param>;
408
- };
409
- query: {
410
- params: infer QueryParams extends Record<string, Param>;
411
- };
412
- host: {
413
- params: infer HostParams extends Record<string, Param>;
414
- };
415
- hash: {
416
- params: infer HashParams extends Record<string, Param>;
417
- };
418
- } ? ExtractParamTypes<HostParams & PathParams & QueryParams & HashParams> : {};
419
-
420
- declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extends {
406
+ declare type ExtractRouteParamTypesWithOptional<TRoute> = TRoute extends {
421
407
  host: {
422
408
  params: infer HostParams extends Record<string, Param>;
423
409
  };
@@ -430,9 +416,9 @@ declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extend
430
416
  hash: {
431
417
  params: infer HashParams extends Record<string, Param>;
432
418
  };
433
- } ? ExtractParamTypesWithoutLosingOptional<HostParams & PathParams & QueryParams & HashParams> : Record<string, unknown>;
419
+ } ? ExtractParamTypesWithOptional<HostParams & PathParams & QueryParams & HashParams> : Record<string, unknown>;
434
420
 
435
- declare type ExtractRouteStateParamsAsOptional<T extends Record<string, Param>> = ExtractParamTypes<{
421
+ declare type ExtractRouteStateParamsAsOptional<T extends Record<string, Param>> = ExtractParamTypesWithOptional<{
436
422
  [K in keyof T as K extends string ? `?${K}` : never]: T[K];
437
423
  }>;
438
424
 
@@ -610,7 +596,7 @@ declare type OnlyRequiredProperties<T> = {
610
596
  [K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K];
611
597
  };
612
598
 
613
- export declare type Param = ParamGetter | ParamGetSet | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON | ZodSchema | LiteralParam;
599
+ export declare type Param = ParamGetter | ParamGetSet | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON | ZodSchemaLike | LiteralParam;
614
600
 
615
601
  declare type ParamEnd = typeof paramEnd;
616
602
 
@@ -804,7 +790,7 @@ export declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
804
790
  /**
805
791
  * Key value pair for route params, values will be the user provided value from current browser location.
806
792
  */
807
- params: ExtractRouteParamTypes<TRoute>;
793
+ params: ExtractRouteParamTypesWithOptional<TRoute>;
808
794
  /**
809
795
  * Type for additional data intended to be stored in history state.
810
796
  */
@@ -925,7 +911,7 @@ export declare type RouteMeta<T = Register> = T extends {
925
911
  routeMeta: infer RouteMeta extends Record<string, unknown>;
926
912
  } ? RouteMeta : Record<string, unknown>;
927
913
 
928
- declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = ExtractRouteParamTypesWithoutLosingOptional<RouteGetByKey<TRoutes, TKey>>;
914
+ declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = ExtractRouteParamTypesWithOptional<RouteGetByKey<TRoutes, TKey>>;
929
915
 
930
916
  declare type RoutePropsRecord<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponents extends Record<string, Component> = Record<string, Component>> = {
931
917
  [K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends true ? K : never]?: PropsGetter<TOptions, TComponents[K]>;
@@ -1416,6 +1402,10 @@ declare type WithParent<TParent extends Route = Route> = {
1416
1402
  parent: TParent;
1417
1403
  };
1418
1404
 
1405
+ declare type ZodSchemaLike<TOutput = any> = {
1406
+ parse: (input: any) => TOutput;
1407
+ };
1408
+
1419
1409
  export { }
1420
1410
 
1421
1411