@analogjs/router 3.0.0-alpha.9 → 3.0.0-alpha.91
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/content/package.json +4 -0
- package/fesm2022/analogjs-router-content.mjs +63 -0
- package/fesm2022/analogjs-router-content.mjs.map +1 -0
- package/fesm2022/analogjs-router-i18n.mjs +156 -0
- package/fesm2022/analogjs-router-i18n.mjs.map +1 -0
- package/fesm2022/analogjs-router-server-actions.mjs +2 -27
- package/fesm2022/analogjs-router-server.mjs +734 -105
- package/fesm2022/analogjs-router-server.mjs.map +1 -0
- package/fesm2022/analogjs-router-tanstack-query-server.mjs +71 -0
- package/fesm2022/analogjs-router-tanstack-query-server.mjs.map +1 -0
- package/fesm2022/analogjs-router-tanstack-query.mjs +39 -0
- package/fesm2022/analogjs-router-tanstack-query.mjs.map +1 -0
- package/fesm2022/analogjs-router-tokens.mjs +7 -2
- package/fesm2022/analogjs-router-tokens.mjs.map +1 -0
- package/fesm2022/analogjs-router.mjs +740 -155
- package/fesm2022/analogjs-router.mjs.map +1 -0
- package/fesm2022/debug.page.mjs +53 -31
- package/fesm2022/debug.page.mjs.map +1 -0
- package/fesm2022/provide-analog-query.mjs +72 -0
- package/fesm2022/provide-analog-query.mjs.map +1 -0
- package/fesm2022/route-files.mjs +361 -0
- package/fesm2022/route-files.mjs.map +1 -0
- package/fesm2022/routes.mjs +5 -278
- package/fesm2022/routes.mjs.map +1 -0
- package/fesm2022/src.mjs +335 -0
- package/fesm2022/src.mjs.map +1 -0
- package/i18n/package.json +4 -0
- package/package.json +51 -6
- package/tanstack-query/package.json +4 -0
- package/tanstack-query/server/package.json +4 -0
- package/types/content/src/index.d.ts +4 -0
- package/types/content/src/lib/debug/routes.d.ts +10 -0
- package/types/{src → content/src}/lib/markdown-helpers.d.ts +1 -1
- package/types/content/src/lib/routes.d.ts +8 -0
- package/types/content/src/lib/with-content-routes.d.ts +2 -0
- package/types/i18n/src/index.d.ts +1 -0
- package/types/i18n/src/provide-i18n.d.ts +92 -0
- package/types/server/actions/src/actions.d.ts +1 -1
- package/types/server/actions/src/define-action.d.ts +54 -0
- package/types/server/actions/src/define-api-route.d.ts +57 -0
- package/types/server/actions/src/define-page-load.d.ts +55 -0
- package/types/server/actions/src/define-server-route.d.ts +68 -0
- package/types/server/actions/src/index.d.ts +9 -1
- package/types/server/actions/src/parse-request-data.d.ts +9 -0
- package/types/server/actions/src/validate.d.ts +8 -0
- package/types/server/src/defer-reconcile-runtime.d.ts +23 -0
- package/types/server/src/index.d.ts +9 -2
- package/types/server/src/provide-server-context.d.ts +15 -1
- package/types/server/src/render-stream.d.ts +40 -0
- package/types/server/src/render.d.ts +3 -3
- package/types/server/src/server-fn/app-injector.d.ts +30 -0
- package/types/server/src/server-fn/dispatch.d.ts +56 -0
- package/types/server/src/server-fn/event-handler.d.ts +22 -0
- package/types/server/src/server-fn/interceptors.d.ts +30 -0
- package/types/server/src/server-fn/node-context.d.ts +14 -0
- package/types/server/src/server-fn/registry.d.ts +7 -0
- package/types/server/src/server-fn/same-origin.d.ts +46 -0
- package/types/server/src/server-fn/server-fn.d.ts +21 -0
- package/types/server/src/server-fn/ssr-dispatcher.d.ts +17 -0
- package/types/server/src/utils/reset-component-def-tviews.d.ts +14 -0
- package/types/server/src/utils/stream-html.d.ts +13 -0
- package/types/server/src/utils/stream-request.d.ts +24 -0
- package/types/src/index.d.ts +18 -6
- package/types/src/lib/cookie-interceptor.d.ts +1 -1
- package/types/src/lib/debug/debug.page.d.ts +4 -2
- package/types/src/lib/define-route.d.ts +6 -1
- package/types/src/lib/endpoints.d.ts +1 -1
- package/types/src/lib/form-action.directive.d.ts +12 -5
- package/types/src/lib/inject-load.d.ts +9 -1
- package/types/src/lib/inject-navigate.d.ts +56 -0
- package/types/src/lib/inject-typed-params.d.ts +33 -0
- package/types/src/lib/json-ld.d.ts +32 -0
- package/types/src/lib/link-to.directive.d.ts +38 -0
- package/types/src/lib/meta-tags.d.ts +3 -1
- package/types/src/lib/models.d.ts +3 -0
- package/types/src/lib/provide-file-router-base.d.ts +4 -0
- package/types/src/lib/provide-file-router.d.ts +2 -8
- package/types/src/lib/route-builder.d.ts +5 -0
- package/types/src/lib/route-files.d.ts +18 -0
- package/types/src/lib/route-types.d.ts +3 -2
- package/types/src/lib/routes.d.ts +2 -10
- package/types/src/lib/server-fn/dispatcher.d.ts +23 -0
- package/types/src/lib/server-fn/inject-server-fn.d.ts +44 -0
- package/types/src/lib/server-fn/server-fn-ref.d.ts +24 -0
- package/types/src/lib/server-fn/types.d.ts +55 -0
- package/types/src/lib/to-route.d.ts +246 -0
- package/types/src/lib/validation-errors.d.ts +7 -0
- package/types/tanstack-query/server/src/define-page-load-queries.d.ts +66 -0
- package/types/tanstack-query/server/src/index.d.ts +3 -0
- package/types/tanstack-query/src/constants.d.ts +9 -0
- package/types/tanstack-query/src/index.d.ts +2 -0
- package/types/tanstack-query/src/provide-analog-query.d.ts +4 -0
- package/types/tanstack-query/src/provide-server-analog-query.d.ts +2 -0
- package/types/tanstack-query/src/server-query.d.ts +16 -0
- package/types/tokens/src/index.d.ts +3 -1
- package/types/server/src/server-component-render.d.ts +0 -4
- package/types/server/src/tokens.d.ts +0 -7
- package/types/src/lib/server.component.d.ts +0 -33
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Router } from '@angular/router';
|
|
2
|
+
import type { Graph, Thing, WithContext } from 'schema-dts';
|
|
3
|
+
export type JsonLdObject = Record<string, unknown>;
|
|
4
|
+
export declare function isJsonLdObject(value: unknown): value is JsonLdObject;
|
|
5
|
+
export declare function normalizeJsonLd(value: unknown): JsonLdObject[];
|
|
6
|
+
export type JsonLd = JsonLdObject | JsonLdObject[];
|
|
7
|
+
/**
|
|
8
|
+
* Typed JSON-LD document based on `schema-dts`.
|
|
9
|
+
*
|
|
10
|
+
* Accepts single Schema.org nodes (`WithContext<Thing>`),
|
|
11
|
+
* `@graph`-based documents (`Graph`), or arrays of nodes.
|
|
12
|
+
*
|
|
13
|
+
* This is the canonical JSON-LD type for route authoring surfaces
|
|
14
|
+
* (`routeMeta.jsonLd`, `routeJsonLd`, generated manifest).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import type { WebPage, WithContext } from 'schema-dts';
|
|
19
|
+
*
|
|
20
|
+
* export const routeMeta = {
|
|
21
|
+
* jsonLd: {
|
|
22
|
+
* '@context': 'https://schema.org',
|
|
23
|
+
* '@type': 'WebPage',
|
|
24
|
+
* name: 'Products',
|
|
25
|
+
* } satisfies WithContext<WebPage>,
|
|
26
|
+
* };
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export type AnalogJsonLdDocument = WithContext<Thing> | Graph | WithContext<Thing>[];
|
|
30
|
+
export declare const ROUTE_JSON_LD_KEY: unique symbol;
|
|
31
|
+
export declare function updateJsonLdOnRouteChange(router?: Router, document?: Document | null): void;
|
|
32
|
+
export declare function serializeJsonLd(entry: JsonLdObject): string | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { InputSignal, OnChanges, OnDestroy } from '@angular/core';
|
|
2
|
+
import { AnalogRoutePath, ResolveRoutePath, RouteParamsOutput, RoutePathOptions, ScopedRoutePathArgs, ScopedRoutePathOptions, ScopedRouteTarget } from './to-route';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "@angular/router";
|
|
5
|
+
type LinkToDestination = {
|
|
6
|
+
[P in AnalogRoutePath]: {
|
|
7
|
+
path: P;
|
|
8
|
+
} & RoutePathOptions<P>;
|
|
9
|
+
}[AnalogRoutePath];
|
|
10
|
+
type StaticRoutePath = {
|
|
11
|
+
[P in AnalogRoutePath]: RouteParamsOutput<P> extends Record<string, never> ? P : never;
|
|
12
|
+
}[AnalogRoutePath];
|
|
13
|
+
type ScopedDestination<From extends AnalogRoutePath> = {
|
|
14
|
+
[T in ScopedRouteTarget<From>]: {
|
|
15
|
+
path: T;
|
|
16
|
+
} & ScopedRoutePathOptions<From, ResolveRoutePath<From, T>>;
|
|
17
|
+
}[ScopedRouteTarget<From>];
|
|
18
|
+
type ScopedStaticTarget<From extends AnalogRoutePath> = {
|
|
19
|
+
[T in ScopedRouteTarget<From>]: [] extends ScopedRoutePathArgs<From, T> ? T : never;
|
|
20
|
+
}[ScopedRouteTarget<From>];
|
|
21
|
+
/** Destinations accepted by `[linkTo]`, relative to `From` when provided. */
|
|
22
|
+
export type LinkToInput<From = undefined> = (unknown extends From ? StaticRoutePath | LinkToDestination : From extends AnalogRoutePath ? ScopedStaticTarget<From> | ScopedDestination<From> : StaticRoutePath | LinkToDestination) | null | undefined;
|
|
23
|
+
export declare class LinkTo<From = undefined> implements OnChanges, OnDestroy {
|
|
24
|
+
readonly linkTo: InputSignal<LinkToInput<From>>;
|
|
25
|
+
/** The current route's path. Enables relative destinations and param inheritance. */
|
|
26
|
+
readonly from: InputSignal<(From & AnalogRoutePath) | undefined>;
|
|
27
|
+
private readonly routerLink;
|
|
28
|
+
private readonly route;
|
|
29
|
+
private currentParams;
|
|
30
|
+
private paramsFrom?;
|
|
31
|
+
private paramsSubscription?;
|
|
32
|
+
ngOnChanges(): void;
|
|
33
|
+
ngOnDestroy(): void;
|
|
34
|
+
private update;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LinkTo<any>, never>;
|
|
36
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<LinkTo<any>, "[linkTo]", never, { "linkTo": { "alias": "linkTo"; "required": true; "isSignal": true; }; "from": { "alias": "from"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.RouterLink; inputs: { "target": "target"; "queryParamsHandling": "queryParamsHandling"; "preserveFragment": "preserveFragment"; "skipLocationChange": "skipLocationChange"; "replaceUrl": "replaceUrl"; "state": "state"; }; outputs: {}; }]>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Meta } from '@angular/platform-browser';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
1
3
|
export declare const ROUTE_META_TAGS_KEY: unique symbol;
|
|
2
4
|
declare const CHARSET_KEY = "charset";
|
|
3
5
|
declare const HTTP_EQUIV_KEY = "httpEquiv";
|
|
@@ -29,5 +31,5 @@ type MetaTagKey = typeof CHARSET_KEY | typeof HTTP_EQUIV_KEY | typeof NAME_KEY |
|
|
|
29
31
|
type ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {
|
|
30
32
|
[K in Exclude<MetaTagKey, Key>]?: never;
|
|
31
33
|
};
|
|
32
|
-
export declare function updateMetaTagsOnRouteChange(): void;
|
|
34
|
+
export declare function updateMetaTagsOnRouteChange(router?: Router, metaService?: Meta): void;
|
|
33
35
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type } from '@angular/core';
|
|
2
2
|
import { CanActivateChildFn, CanActivateFn, CanDeactivateFn, CanMatchFn, DeprecatedGuard, ResolveFn, Route } from '@angular/router';
|
|
3
3
|
import { defineRouteMeta } from './define-route';
|
|
4
|
+
import { AnalogJsonLdDocument } from './json-ld';
|
|
4
5
|
import { MetaTag } from './meta-tags';
|
|
5
6
|
type OmittedRouteProps = 'path' | 'matcher' | 'component' | 'loadComponent' | 'children' | 'loadChildren' | 'canLoad' | 'outlet';
|
|
6
7
|
export type RouteConfig = Omit<Route, OmittedRouteProps>;
|
|
@@ -14,6 +15,7 @@ export interface DefaultRouteMeta extends Omit<Route, OmittedRouteProps | keyof
|
|
|
14
15
|
};
|
|
15
16
|
title?: string | ResolveFn<string>;
|
|
16
17
|
meta?: MetaTag[] | ResolveFn<MetaTag[]>;
|
|
18
|
+
jsonLd?: AnalogJsonLdDocument | ResolveFn<AnalogJsonLdDocument | undefined>;
|
|
17
19
|
}
|
|
18
20
|
export interface RedirectRouteMeta {
|
|
19
21
|
redirectTo: string;
|
|
@@ -25,5 +27,6 @@ export type RouteMeta = (DefaultRouteMeta & {
|
|
|
25
27
|
export type RouteExport = {
|
|
26
28
|
default: Type<unknown>;
|
|
27
29
|
routeMeta?: RouteMeta | ReturnType<typeof defineRouteMeta>;
|
|
30
|
+
routeJsonLd?: AnalogJsonLdDocument | ResolveFn<AnalogJsonLdDocument | undefined>;
|
|
28
31
|
};
|
|
29
32
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { RouterFeatures, Routes } from '@angular/router';
|
|
3
|
+
export declare function provideFileRouterWithRoutes(...features: RouterFeatures[]): EnvironmentProviders;
|
|
4
|
+
export declare function withExtraRoutes(routes: Routes): RouterFeatures;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnvironmentProviders } from '@angular/core';
|
|
2
|
-
import { RouterFeatures
|
|
2
|
+
import { RouterFeatures } from '@angular/router';
|
|
3
3
|
/**
|
|
4
4
|
* Sets up providers for the Angular router, and registers
|
|
5
5
|
* file-based routes. Additional features can be provided
|
|
@@ -9,10 +9,4 @@ import { RouterFeatures, Routes } from '@angular/router';
|
|
|
9
9
|
* @returns Providers and features to configure the router with routes
|
|
10
10
|
*/
|
|
11
11
|
export declare function provideFileRouter(...features: RouterFeatures[]): EnvironmentProviders;
|
|
12
|
-
|
|
13
|
-
* Provides extra custom routes in addition to the routes
|
|
14
|
-
* discovered from the filesystem-based routing. These routes are
|
|
15
|
-
* inserted before the filesystem-based routes, and take priority in
|
|
16
|
-
* route matching.
|
|
17
|
-
*/
|
|
18
|
-
export declare function withExtraRoutes(routes: Routes): RouterFeatures;
|
|
12
|
+
export { withExtraRoutes } from './provide-file-router-base';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Route } from '@angular/router';
|
|
2
|
+
import type { RouteExport } from './models';
|
|
3
|
+
export type RouteModuleFactory = () => Promise<RouteExport>;
|
|
4
|
+
export type RouteModuleResolver<TFile> = (filename: string, fileLoader: () => Promise<TFile>) => RouteModuleFactory;
|
|
5
|
+
export declare function createRoutes<TFile>(files: Record<string, () => Promise<TFile>>, resolveModule: RouteModuleResolver<TFile>, debug?: boolean): Route[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import type { RouteExport } from './models';
|
|
3
|
+
export type Files = Record<string, () => Promise<RouteExport>>;
|
|
4
|
+
/**
|
|
5
|
+
* This variable reference is replaced with a glob of all page routes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ANALOG_ROUTE_FILES: {};
|
|
8
|
+
export interface ExtraRouteFileSource {
|
|
9
|
+
files: Record<string, () => Promise<unknown>>;
|
|
10
|
+
resolveModule: (filename: string, fileLoader: () => Promise<unknown>) => () => Promise<RouteExport>;
|
|
11
|
+
}
|
|
12
|
+
export declare const ANALOG_EXTRA_ROUTE_FILE_SOURCES: InjectionToken<ExtraRouteFileSource[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Replaced at build time by the Vite router plugin with the number of
|
|
15
|
+
* discovered content route files. Used in dev mode to warn when content
|
|
16
|
+
* files exist but `withContentRoutes()` is not configured.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ANALOG_CONTENT_FILE_COUNT = 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { H3Event, H3EventContext } from 'nitro/h3';
|
|
2
|
-
import type { $Fetch } from '
|
|
2
|
+
import type { $Fetch } from 'ofetch';
|
|
3
3
|
export type NodeContext = NonNullable<H3Event['node']>;
|
|
4
4
|
export type PageServerLoad = {
|
|
5
5
|
params: H3EventContext['params'];
|
|
@@ -8,4 +8,5 @@ export type PageServerLoad = {
|
|
|
8
8
|
fetch: $Fetch;
|
|
9
9
|
event: H3Event;
|
|
10
10
|
};
|
|
11
|
-
export type LoadResult<A extends (pageServerLoad: PageServerLoad) => Promise<
|
|
11
|
+
export type LoadResult<A extends (pageServerLoad: PageServerLoad) => Promise<unknown>> = Awaited<ReturnType<A>>;
|
|
12
|
+
export type LoadDataResult<A extends (pageServerLoad: PageServerLoad) => Promise<unknown>> = Exclude<LoadResult<A>, Response>;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import type { Route } from '@angular/router';
|
|
2
|
-
import type
|
|
3
|
-
/**
|
|
4
|
-
* This variable reference is replaced with a glob of all page routes.
|
|
5
|
-
*/
|
|
6
|
-
export declare const ANALOG_ROUTE_FILES: {};
|
|
7
|
-
/**
|
|
8
|
-
* This variable reference is replaced with a glob of all content routes.
|
|
9
|
-
*/
|
|
10
|
-
export declare const ANALOG_CONTENT_ROUTE_FILES: {};
|
|
11
|
-
export type Files = Record<string, () => Promise<RouteExport | string>>;
|
|
2
|
+
import { type Files } from './route-files';
|
|
12
3
|
/**
|
|
13
4
|
* A function used to parse list of files and create configuration of routes.
|
|
14
5
|
*
|
|
@@ -16,4 +7,5 @@ export type Files = Record<string, () => Promise<RouteExport | string>>;
|
|
|
16
7
|
* @returns Array of routes
|
|
17
8
|
*/
|
|
18
9
|
export declare function createRoutes(files: Files, debug?: boolean): Route[];
|
|
10
|
+
export { ANALOG_ROUTE_FILES } from './route-files';
|
|
19
11
|
export declare const routes: Route[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InjectionToken, type Injector } from '@angular/core';
|
|
2
|
+
import type { ServerFn } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* In-process transport for a server function call.
|
|
5
|
+
*
|
|
6
|
+
* Provided on the server by `provideServerContext`, so during SSR a server
|
|
7
|
+
* function runs in the same process — and the same request injector — as the
|
|
8
|
+
* render instead of making an HTTP request back into the app. Absent in the
|
|
9
|
+
* browser, where `ServerFnClient` falls back to `HttpClient`.
|
|
10
|
+
*
|
|
11
|
+
* `injector` is the **app environment injector** — `ServerFnClient` is
|
|
12
|
+
* `providedIn: 'root'`, and SSR bootstraps a fresh application per request, so
|
|
13
|
+
* its injector is both per-request and the right scope for a handler to resolve
|
|
14
|
+
* from. It is passed rather than captured from the token because
|
|
15
|
+
* `provideServerContext` is applied as *platform* providers, which sit above
|
|
16
|
+
* the app's `providedIn: 'root'` services.
|
|
17
|
+
*
|
|
18
|
+
* Deliberately not a component's node injector: a handler resolves app-level
|
|
19
|
+
* services, and making that depend on which component happened to call it would
|
|
20
|
+
* be surprising and unportable.
|
|
21
|
+
*/
|
|
22
|
+
export type ServerFnDispatcher = <In, Out>(fn: ServerFn<In, Out>, input: In, injector: Injector) => Promise<Out>;
|
|
23
|
+
export declare const SERVER_FN_DISPATCHER: InjectionToken<ServerFnDispatcher>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ResourceRef, type StateKey } from '@angular/core';
|
|
2
|
+
import type { ServerFn } from './types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Client transport for server functions. In the browser it goes through Angular
|
|
6
|
+
* `HttpClient`, so client `HttpInterceptorFn`s apply. During SSR the dispatcher
|
|
7
|
+
* token is provided, and the call short-circuits the HTTP round-trip: the
|
|
8
|
+
* handler runs in-process in the current request injector. Lives in the client
|
|
9
|
+
* entry (client-safe).
|
|
10
|
+
*/
|
|
11
|
+
export declare class ServerFnClient {
|
|
12
|
+
private readonly http;
|
|
13
|
+
private readonly transferState;
|
|
14
|
+
private readonly injector;
|
|
15
|
+
private readonly dispatcher;
|
|
16
|
+
/** True while rendering on the server (the in-process dispatcher is provided). */
|
|
17
|
+
get isServer(): boolean;
|
|
18
|
+
call<In, Out>(fn: ServerFn<In, Out>, input: In): Promise<Out>;
|
|
19
|
+
/** Key a read's value for TransferState hydration (fn id + input). */
|
|
20
|
+
stateKey<Out>(fn: ServerFn<unknown, Out>, input: unknown): StateKey<Out>;
|
|
21
|
+
readSeed<Out>(fn: ServerFn<unknown, Out>, input: unknown): Out | undefined;
|
|
22
|
+
writeSeed<Out>(fn: ServerFn<unknown, Out>, input: unknown, value: Out): void;
|
|
23
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ServerFnClient, never>;
|
|
24
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ServerFnClient>;
|
|
25
|
+
}
|
|
26
|
+
/** No-op provider hook; ServerFnClient is `providedIn: 'root'`. */
|
|
27
|
+
export declare function provideServerFnClient(): readonly [];
|
|
28
|
+
/**
|
|
29
|
+
* Reactive read of a server function as an Angular `resource()`.
|
|
30
|
+
*
|
|
31
|
+
* `args` is optional: omit it for an input-less read (the resource loads once);
|
|
32
|
+
* provide it for an input-bearing read (returning `undefined` from `args` leaves
|
|
33
|
+
* the resource idle until inputs are ready, the standard resource pattern). For
|
|
34
|
+
* imperative calls (mutations, event handlers) use `injectServerFnMutation`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function injectServerFn<Out>(fn: ServerFn<void, Out>): ResourceRef<Out | undefined>;
|
|
37
|
+
export declare function injectServerFn<In, Out>(fn: ServerFn<In, Out>, args: () => In | undefined): ResourceRef<Out | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Imperative binding of a server function: returns a callable that dispatches
|
|
40
|
+
* the call through `HttpClient` (so client interceptors apply) and resolves the
|
|
41
|
+
* result. Use for mutations and event-driven calls; use `injectServerFn` for
|
|
42
|
+
* reactive reads.
|
|
43
|
+
*/
|
|
44
|
+
export declare function injectServerFnMutation<In, Out>(fn: ServerFn<In, Out>): (input: In) => Promise<Out>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ServerFn, ServerFnMethod } from './types';
|
|
2
|
+
export interface ServerFnRefConfig {
|
|
3
|
+
id?: string;
|
|
4
|
+
method?: ServerFnMethod;
|
|
5
|
+
/**
|
|
6
|
+
* Only its presence matters here: when `method` is omitted, a config with an
|
|
7
|
+
* `input` schema defaults to `POST`, otherwise `GET`. The schema itself is
|
|
8
|
+
* never used to build the ref — validation happens server-side.
|
|
9
|
+
*/
|
|
10
|
+
input?: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Builds a server-function reference: the client-safe `{ __serverFn, id, url,
|
|
14
|
+
* method }` metadata that `injectServerFn`/`ServerFnClient` dispatch through.
|
|
15
|
+
*
|
|
16
|
+
* Shared by both sides so they produce identical refs: the server `serverFn`
|
|
17
|
+
* wraps this with registration + the handler, and the client build's scrub
|
|
18
|
+
* transform emits a call to this factory in place of the server module so the
|
|
19
|
+
* browser bundle carries only the ref, never the handler or its server imports.
|
|
20
|
+
*
|
|
21
|
+
* The returned value is callable-typed but throws if invoked directly — it is
|
|
22
|
+
* always dispatched via `injectServerFn`/`ServerFnClient`, never called.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createServerFnRef<In, Out>(config: ServerFnRefConfig): ServerFn<In, Out>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Minimal Standard Schema shape (valibot/zod/arktype conform). */
|
|
2
|
+
export interface StandardSchemaV1<In = unknown> {
|
|
3
|
+
readonly '~standard': {
|
|
4
|
+
readonly version: 1;
|
|
5
|
+
readonly vendor: string;
|
|
6
|
+
validate: (value: unknown) => {
|
|
7
|
+
value: In;
|
|
8
|
+
issues?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
issues: ReadonlyArray<{
|
|
11
|
+
message: string;
|
|
12
|
+
}>;
|
|
13
|
+
} | Promise<{
|
|
14
|
+
value: In;
|
|
15
|
+
issues?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
issues: ReadonlyArray<{
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export type ServerFnMethod = 'GET' | 'POST';
|
|
24
|
+
export interface ServerFnConfig<In> {
|
|
25
|
+
/**
|
|
26
|
+
* Opaque route id `/_analog/fn/<id>`. **Build-injected, not author-supplied:**
|
|
27
|
+
* the Analog transform derives `hash(fileId + exportName)` and stamps it into
|
|
28
|
+
* both the server registration and the client proxy, so authors never choose a
|
|
29
|
+
* route. Absent at runtime means the transform did not run — `serverFn` throws.
|
|
30
|
+
*/
|
|
31
|
+
id?: string;
|
|
32
|
+
/** Defaults to 'POST' when `input` is present, otherwise 'GET'. */
|
|
33
|
+
method?: ServerFnMethod;
|
|
34
|
+
input?: StandardSchemaV1<In>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Interceptor-accumulated context, delivered to the handler as its second
|
|
38
|
+
* argument. Apps extend this by declaration merging.
|
|
39
|
+
*/
|
|
40
|
+
export interface ServerFnContext {
|
|
41
|
+
}
|
|
42
|
+
/** A server function reference: callable type on both sides; real impl only on the server. */
|
|
43
|
+
export type ServerFn<In, Out> = ((input: In) => Promise<Out>) & {
|
|
44
|
+
readonly __serverFn: true;
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly url: string;
|
|
47
|
+
readonly method: ServerFnMethod;
|
|
48
|
+
};
|
|
49
|
+
export type ServerFnHandler<In, Out> = (input: In, context: ServerFnContext) => Promise<Out> | Out;
|
|
50
|
+
export interface ServerFnDef {
|
|
51
|
+
id: string;
|
|
52
|
+
method: ServerFnMethod;
|
|
53
|
+
config: ServerFnConfig<unknown>;
|
|
54
|
+
handler: ServerFnHandler<unknown, unknown>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { type ActivatedRoute, type ResolveFn } from '@angular/router';
|
|
2
|
+
/**
|
|
3
|
+
* Typed route path utilities for Analog.
|
|
4
|
+
*
|
|
5
|
+
* This module provides:
|
|
6
|
+
* - The `AnalogRouteTable` base interface (augmented by generated code)
|
|
7
|
+
* - The `AnalogRoutePath` union type
|
|
8
|
+
* - The `toRoute()` URL builder function
|
|
9
|
+
*
|
|
10
|
+
* Link construction does not require an injection context.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Base interface for the typed route table.
|
|
14
|
+
*
|
|
15
|
+
* This interface is augmented by generated code in `src/routeTree.gen.d.ts`.
|
|
16
|
+
* Without the generated declaration, typed helpers reject route paths.
|
|
17
|
+
*/
|
|
18
|
+
export interface AnalogRouteTable {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Union of all valid route paths.
|
|
22
|
+
*
|
|
23
|
+
* When routes are generated, this is a string literal union.
|
|
24
|
+
* Without the generated declaration, this is `never`.
|
|
25
|
+
*/
|
|
26
|
+
export type AnalogRoutePath = Extract<keyof AnalogRouteTable, string>;
|
|
27
|
+
type QueryValue = string | number | boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Query values accepted when building URLs. Angular converts them to strings
|
|
30
|
+
* and drops `null` and `undefined`, or removes those keys when merging.
|
|
31
|
+
*/
|
|
32
|
+
type RouteQueryInput = Record<string, QueryValue | QueryValue[] | null | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Options for building a route URL.
|
|
35
|
+
*/
|
|
36
|
+
export interface RoutePathOptionsBase {
|
|
37
|
+
params?: Record<string, string | number | (string | number)[] | undefined>;
|
|
38
|
+
query?: RouteQueryInput;
|
|
39
|
+
hash?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Raw parameter types from the generated route table. */
|
|
42
|
+
export type RouteParamsOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
43
|
+
params: infer Params;
|
|
44
|
+
} ? Params : Record<string, unknown> : Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Extracts the raw output type for route query params.
|
|
47
|
+
*/
|
|
48
|
+
export type RouteQueryOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
49
|
+
query: infer O;
|
|
50
|
+
} ? O : Record<string, string | string[] | undefined> : Record<string, string | string[] | undefined>;
|
|
51
|
+
type RequiredRouteParamKeys<Params> = Params extends Record<string, never> ? never : {
|
|
52
|
+
[K in keyof Params]-?: Record<string, never> extends Pick<Params, K> ? never : K;
|
|
53
|
+
}[keyof Params];
|
|
54
|
+
type HasRequiredRouteParams<Params> = [RequiredRouteParamKeys<Params>] extends [
|
|
55
|
+
never
|
|
56
|
+
] ? false : true;
|
|
57
|
+
type RouteParamsInput<Params> = {
|
|
58
|
+
[K in keyof Params]: Exclude<Params[K], undefined> extends string[] ? undefined extends Params[K] ? (string | number)[] : [string | number, ...(string | number)[]] : Exclude<Params[K], undefined> extends string ? string | number : Params[K];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Typed options that infer params from the route table when available.
|
|
62
|
+
*/
|
|
63
|
+
export type RoutePathOptions<P extends string = string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
64
|
+
params: infer Params;
|
|
65
|
+
} ? Params extends Record<string, never> ? {
|
|
66
|
+
params?: never;
|
|
67
|
+
query?: RouteQueryInput;
|
|
68
|
+
hash?: string;
|
|
69
|
+
} : HasRequiredRouteParams<Params> extends true ? {
|
|
70
|
+
params: RouteParamsInput<Params>;
|
|
71
|
+
query?: RouteQueryInput;
|
|
72
|
+
hash?: string;
|
|
73
|
+
} : {
|
|
74
|
+
params?: RouteParamsInput<Params>;
|
|
75
|
+
query?: RouteQueryInput;
|
|
76
|
+
hash?: string;
|
|
77
|
+
} : RoutePathOptionsBase : RoutePathOptionsBase;
|
|
78
|
+
/**
|
|
79
|
+
* Conditional args: require options when the route has params.
|
|
80
|
+
*/
|
|
81
|
+
export type RoutePathArgs<P extends string = string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
82
|
+
params: infer Params;
|
|
83
|
+
} ? Params extends Record<string, never> ? [options?: RoutePathOptions<P>] : HasRequiredRouteParams<Params> extends true ? [options: RoutePathOptions<P>] : [options?: RoutePathOptions<P>] : [options?: RoutePathOptionsBase] : [options?: RoutePathOptionsBase];
|
|
84
|
+
type EmptyObject = Record<never, never>;
|
|
85
|
+
type Simplify<T> = {
|
|
86
|
+
[K in keyof T]: T[K];
|
|
87
|
+
};
|
|
88
|
+
type Merge<A, B> = Omit<A, keyof B> & B;
|
|
89
|
+
type MetaObject<T> = unknown extends T ? EmptyObject : string extends keyof NonNullable<T> ? Record<string, unknown> : NonNullable<T>;
|
|
90
|
+
type StaticRouteData<Meta> = Meta extends {
|
|
91
|
+
data?: infer Data;
|
|
92
|
+
} ? MetaObject<Data> : EmptyObject;
|
|
93
|
+
type RouteResolvers<Meta> = Meta extends {
|
|
94
|
+
resolve?: infer Resolvers;
|
|
95
|
+
} ? MetaObject<Resolvers> : EmptyObject;
|
|
96
|
+
type ResolvedRouteData<Meta> = {
|
|
97
|
+
[K in keyof RouteResolvers<Meta>]: RouteResolvers<Meta>[K] extends ResolveFn<infer T> ? T : unknown;
|
|
98
|
+
};
|
|
99
|
+
type RouteMetaData<Meta> = Merge<StaticRouteData<Meta>, ResolvedRouteData<Meta>>;
|
|
100
|
+
type InheritedRouteData<Metas, Data = EmptyObject> = Metas extends [
|
|
101
|
+
infer Meta,
|
|
102
|
+
...infer Rest
|
|
103
|
+
] ? InheritedRouteData<Rest, Merge<Data, RouteMetaData<Exclude<Meta, {
|
|
104
|
+
redirectTo: string;
|
|
105
|
+
}>>>> : Data;
|
|
106
|
+
type RouteResourceMap<Meta> = Meta extends {
|
|
107
|
+
resources?: (ctx: never) => infer R;
|
|
108
|
+
} ? Awaited<R> extends Record<PropertyKey, unknown> ? Awaited<R> : EmptyObject : EmptyObject;
|
|
109
|
+
type PageRouteMetas<P extends keyof AnalogRouteTable> = [
|
|
110
|
+
...(AnalogRouteTable[P] extends {
|
|
111
|
+
layoutRouteMeta: infer Metas extends unknown[];
|
|
112
|
+
} ? Metas : []),
|
|
113
|
+
...(AnalogRouteTable[P] extends {
|
|
114
|
+
routeMeta: infer Meta;
|
|
115
|
+
} ? [Meta] : [])
|
|
116
|
+
];
|
|
117
|
+
type PageLoadData<P extends keyof AnalogRouteTable> = AnalogRouteTable[P] extends {
|
|
118
|
+
load: unknown;
|
|
119
|
+
} ? {
|
|
120
|
+
load: RouteLoadOutput<P>;
|
|
121
|
+
} : EmptyObject;
|
|
122
|
+
/** Route paths whose page has a server `load` function. */
|
|
123
|
+
export type AnalogRouteWithLoad = {
|
|
124
|
+
[P in AnalogRoutePath]: AnalogRouteTable[P] extends {
|
|
125
|
+
load: unknown;
|
|
126
|
+
} ? P : never;
|
|
127
|
+
}[AnalogRoutePath];
|
|
128
|
+
/** Resolved result of a page's server `load` function. */
|
|
129
|
+
export type RouteLoadOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
130
|
+
load: (...args: never[]) => infer R;
|
|
131
|
+
} ? Awaited<R> : never : never;
|
|
132
|
+
/**
|
|
133
|
+
* Data for a page route: static `routeMeta.data` and `routeMeta.resolve`
|
|
134
|
+
* results from its layouts and the page, and the page's server `load` result.
|
|
135
|
+
*/
|
|
136
|
+
export type RouteDataOutput<P extends string> = P extends keyof AnalogRouteTable ? Simplify<Omit<InheritedRouteData<PageRouteMetas<P>>, 'load'> & PageLoadData<P>> : Record<string, unknown>;
|
|
137
|
+
/**
|
|
138
|
+
* Resources for a page route: `routeMeta.resources` results defined on the page.
|
|
139
|
+
*/
|
|
140
|
+
export type RouteResourcesOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
141
|
+
routeMeta: infer Meta;
|
|
142
|
+
} ? Simplify<RouteResourceMap<Exclude<Meta, {
|
|
143
|
+
redirectTo: string;
|
|
144
|
+
}>>> : EmptyObject : ActivatedRoute extends {
|
|
145
|
+
resources: infer Resources;
|
|
146
|
+
} ? Resources : EmptyObject;
|
|
147
|
+
type SplitPath<S extends string> = S extends '' ? [] : S extends `${infer Head}/${infer Tail}` ? [Head, ...SplitPath<Tail>] : [S];
|
|
148
|
+
type Segments<P extends string> = P extends `/${infer Rest}` ? SplitPath<Rest> : SplitPath<P>;
|
|
149
|
+
type JoinPath<S extends string[]> = S extends [
|
|
150
|
+
infer Head extends string,
|
|
151
|
+
...infer Tail extends string[]
|
|
152
|
+
] ? Tail extends [] ? Head : `${Head}/${JoinPath<Tail>}` : '';
|
|
153
|
+
type Pop<S extends string[]> = S extends [
|
|
154
|
+
...infer Init extends string[],
|
|
155
|
+
string
|
|
156
|
+
] ? Init : [];
|
|
157
|
+
type ParentPath<P extends string> = `/${JoinPath<Pop<Segments<P>>>}`;
|
|
158
|
+
type LastSegment<P extends string> = Segments<P> extends [...string[], infer Last extends string] ? Last : never;
|
|
159
|
+
type ResolveSegments<Base extends string[], Parts extends string[]> = Parts extends [infer Head extends string, ...infer Tail extends string[]] ? ResolveSegments<Head extends '.' ? Base : Head extends '..' ? Pop<Base> : [...Base, Head], Tail> : Base;
|
|
160
|
+
/** Resolves a relative target against the `From` route path. */
|
|
161
|
+
export type ResolveRoutePath<From extends string, To extends string> = To extends `/${string}` ? To : `/${JoinPath<ResolveSegments<Segments<From>, SplitPath<To>>>}`;
|
|
162
|
+
type PathPrefix<Base extends string> = Base extends '/' ? '/' : `${Base}/`;
|
|
163
|
+
/** Route paths nested below `Base`, relative to it. */
|
|
164
|
+
type ChildPaths<Base extends string, P extends string = AnalogRoutePath> = P extends `${PathPrefix<Base>}${infer Rest}` ? Rest extends '' ? never : Rest : never;
|
|
165
|
+
type AncestorTargets<From extends string, Up extends string> = From extends '/' ? never : (ParentPath<From> extends AnalogRoutePath ? Up : never) | `${Up}/${Exclude<ChildPaths<ParentPath<From>>, LastSegment<From> | `${LastSegment<From>}/${string}`>}` | AncestorTargets<ParentPath<From>, `${Up}/..`>;
|
|
166
|
+
/** Relative targets from `From`: `.`, `./child`, `..`, and `../sibling`. */
|
|
167
|
+
export type RelativeRouteTarget<From extends string> = '.' | `./${ChildPaths<From>}` | AncestorTargets<From, '..'>;
|
|
168
|
+
/** Absolute route paths plus targets relative to `From`. */
|
|
169
|
+
export type ScopedRouteTarget<From extends string> = AnalogRoutePath | RelativeRouteTarget<From>;
|
|
170
|
+
type SegmentParam<S extends string> = S extends `[[...${infer Name}]]` ? Name : S extends `[...${infer Name}]` ? Name : S extends `[${infer Name}]` ? Name : never;
|
|
171
|
+
type SharedParams<A extends string[], B extends string[]> = A extends [
|
|
172
|
+
infer Head extends string,
|
|
173
|
+
...infer ATail extends string[]
|
|
174
|
+
] ? B extends [Head, ...infer BTail extends string[]] ? SegmentParam<Head> | SharedParams<ATail, BTail> : never : never;
|
|
175
|
+
type WithOptional<T, K extends PropertyKey> = Simplify<Omit<T, K> & Partial<Pick<T, Extract<keyof T, K>>>>;
|
|
176
|
+
type ScopedParamsInput<From extends string, To extends string> = WithOptional<RouteParamsInput<RouteParamsOutput<To>>, SharedParams<Segments<From>, Segments<To>>>;
|
|
177
|
+
/** Options for a route path; params shared with `From` default to current values. */
|
|
178
|
+
export type ScopedRoutePathOptions<From extends string, To extends string> = RouteParamsOutput<To> extends Record<string, never> ? {
|
|
179
|
+
params?: never;
|
|
180
|
+
query?: RouteQueryInput;
|
|
181
|
+
hash?: string;
|
|
182
|
+
} : HasRequiredRouteParams<ScopedParamsInput<From, To>> extends true ? {
|
|
183
|
+
params: ScopedParamsInput<From, To>;
|
|
184
|
+
query?: RouteQueryInput;
|
|
185
|
+
hash?: string;
|
|
186
|
+
} : {
|
|
187
|
+
params?: ScopedParamsInput<From, To>;
|
|
188
|
+
query?: RouteQueryInput;
|
|
189
|
+
hash?: string;
|
|
190
|
+
};
|
|
191
|
+
/** Conditional args for a target resolved against `From`. */
|
|
192
|
+
export type ScopedRoutePathArgs<From extends string, Target extends string> = ScopedRoutePathOptions<From, ResolveRoutePath<From, Target>> extends infer O ? EmptyObject extends O ? [options?: O] : [options: O] : never;
|
|
193
|
+
/**
|
|
194
|
+
* Result of `toRoute()` — contains properties that map directly
|
|
195
|
+
* to Angular's `[routerLink]`, `[queryParams]`, and `[fragment]` inputs.
|
|
196
|
+
*/
|
|
197
|
+
export interface RouteLinkResult {
|
|
198
|
+
path: string[];
|
|
199
|
+
queryParams: RouteQueryInput | null;
|
|
200
|
+
fragment: string | undefined;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Builds a typed route link object from a route path pattern and options.
|
|
204
|
+
*
|
|
205
|
+
* The returned object separates path, query params, and fragment for
|
|
206
|
+
* direct use with Angular's routerLink directive inputs.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* toRoute('/about')
|
|
210
|
+
* // → { path: ['/', 'about'], queryParams: null, fragment: undefined }
|
|
211
|
+
*
|
|
212
|
+
* toRoute('/users/[id]', { params: { id: '42' } })
|
|
213
|
+
* // → { path: ['/', 'users', '42'], queryParams: null, fragment: undefined }
|
|
214
|
+
*
|
|
215
|
+
* toRoute('/users/[id]', { params: { id: '42' }, query: { tab: 'settings' }, hash: 'bio' })
|
|
216
|
+
* // → { path: ['/', 'users', '42'], queryParams: { tab: 'settings' }, fragment: 'bio' }
|
|
217
|
+
*
|
|
218
|
+
* @example Template usage
|
|
219
|
+
* Compute the link in the component:
|
|
220
|
+
* ```ts
|
|
221
|
+
* readonly link = toRoute('/users/[id]', { params: { id: '42' } });
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* ```html
|
|
225
|
+
* <a [routerLink]="link.path" [queryParams]="link.queryParams" [fragment]="link.fragment">
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function toRoute<P extends AnalogRoutePath>(path: P, ...args: RoutePathArgs<P>): RouteLinkResult;
|
|
229
|
+
/**
|
|
230
|
+
* Internal: builds a `RouteLinkResult` from path and options.
|
|
231
|
+
* Exported for direct use in tests (avoids generic constraints).
|
|
232
|
+
*/
|
|
233
|
+
export declare function buildRouteLink(path: string, options?: RoutePathOptionsBase): RouteLinkResult;
|
|
234
|
+
/** Internal URL serialization for programmatic navigation. */
|
|
235
|
+
export declare function buildUrl(path: string, options?: RoutePathOptionsBase): string;
|
|
236
|
+
/** Internal: resolves `.` and `..` segments in `to` against the `from` route path. */
|
|
237
|
+
export declare function resolveRoutePath(from: string, to: string): string;
|
|
238
|
+
/**
|
|
239
|
+
* Internal: resolves `target` against the `from` route path. Params in the
|
|
240
|
+
* leading segments shared with `from` default to the `current` values.
|
|
241
|
+
*/
|
|
242
|
+
export declare function resolveScopedRoute(from: string, target: string, current: Record<string, unknown>, options?: RoutePathOptionsBase): {
|
|
243
|
+
path: string;
|
|
244
|
+
options: RoutePathOptionsBase;
|
|
245
|
+
};
|
|
246
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
export type ValidationFieldErrors = Record<string, string[]>;
|
|
3
|
+
export declare function issuePathToFieldName(path: ReadonlyArray<string | number | symbol | {
|
|
4
|
+
key: string | number | symbol;
|
|
5
|
+
}>): string;
|
|
6
|
+
export declare function issuesToFieldErrors(issues: ReadonlyArray<StandardSchemaV1.Issue>): ValidationFieldErrors;
|
|
7
|
+
export declare function issuesToFormErrors(issues: ReadonlyArray<StandardSchemaV1.Issue>): string[];
|