@abinnovision/payloadcms-wayfinder 1.0.0-beta.3 → 1.0.0-beta.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.
- package/README.md +5 -0
- package/dist/admin/LinkLabelFeature.client.d.mts +2 -3
- package/dist/config/collection-string-field.d.mts +3 -4
- package/dist/config/has-duplicates.d.mts +2 -3
- package/dist/config/link-field.d.mts +4 -5
- package/dist/config/load-mappings.d.mts +4 -5
- package/dist/config/mapping-global.d.mts +4 -5
- package/dist/config/plugin.d.mts +3 -4
- package/dist/config/translations.d.mts +2 -3
- package/dist/lexical/index.d.mts +4 -5
- package/dist/montage/index.d.mts +5 -6
- package/dist/pattern/define-links.d.mts +13 -14
- package/dist/pattern/define-mappings.d.mts +2 -3
- package/dist/pattern/derive-link-label.d.mts +2 -3
- package/dist/pattern/link-node.d.mts +2 -3
- package/dist/pattern/matcher.d.mts +3 -4
- package/dist/pattern/param-query-path.d.mts +4 -5
- package/dist/pattern/resolver.d.mts +4 -5
- package/dist/pattern/types.d.mts +17 -18
- package/dist/runtime/build-href.d.mts +5 -6
- package/dist/runtime/build-path.d.mts +3 -4
- package/dist/runtime/create-router.d.mts +4 -5
- package/dist/runtime/diagnostics.d.mts +7 -8
- package/dist/runtime/resolve-link.d.mts +5 -6
- package/dist/runtime/resolve-path.d.mts +6 -7
- package/dist/runtime/resolve-relationship-slug.d.mts +3 -4
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
Editor-authored URL routing for [Payload CMS](https://payloadcms.com/).
|
|
6
6
|
|
|
7
|
+
On a shoot, the route to set is marked by a trail of small signs, one arrow per junction, put
|
|
8
|
+
up by someone who walked it first. Nobody has to be told the address. Wayfinder is that trail for
|
|
9
|
+
URLs: editors author which collection is served at which path pattern, and everything that needs
|
|
10
|
+
a link follows the signs instead of hard-coding the route.
|
|
11
|
+
|
|
7
12
|
Wayfinder owns one thing: the map from collections to the URL patterns their documents are served
|
|
8
13
|
at. That map is authored in the CMS, so adding a page type is an editorial act rather than a code
|
|
9
14
|
change. Everything else in the package falls out of it. `createRouter` binds the mapping, the
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/admin/LinkLabelFeature.client.d.ts
|
|
2
2
|
/** Client feature registering {@link LinkLabelPlugin} on the editor. */
|
|
3
|
-
declare const LinkLabelFeatureClient: import("@payloadcms/richtext-lexical").FeatureProviderProviderClient<undefined, undefined>;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { LinkLabelFeatureClient };
|
|
3
|
+
export declare const LinkLabelFeatureClient: import("@payloadcms/richtext-lexical").FeatureProviderProviderClient<undefined, undefined>;
|
|
4
|
+
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Field, TextField } from "payload";
|
|
2
2
|
//#region src/config/collection-string-field.d.ts
|
|
3
|
-
interface CreateCollectionStringFieldArgs {
|
|
3
|
+
export interface CreateCollectionStringFieldArgs {
|
|
4
4
|
name: string;
|
|
5
5
|
required?: boolean;
|
|
6
6
|
label?: TextField["label"];
|
|
@@ -15,6 +15,5 @@ interface CreateCollectionStringFieldArgs {
|
|
|
15
15
|
*
|
|
16
16
|
* @param args Field name and presentation overrides.
|
|
17
17
|
*/
|
|
18
|
-
declare const createCollectionStringField: (args: CreateCollectionStringFieldArgs) => Field;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { CreateCollectionStringFieldArgs, createCollectionStringField };
|
|
18
|
+
export declare const createCollectionStringField: (args: CreateCollectionStringFieldArgs) => Field;
|
|
19
|
+
//#endregion
|
|
@@ -10,6 +10,5 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @param keys The authored keys, in row order.
|
|
12
12
|
*/
|
|
13
|
-
declare const hasDuplicates: (keys: (string | undefined)[]) => boolean;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { hasDuplicates };
|
|
13
|
+
export declare const hasDuplicates: (keys: (string | undefined)[]) => boolean;
|
|
14
|
+
//#endregion
|
|
@@ -3,7 +3,7 @@ import { LinkDeclaration, LinkVariantSource } from "../pattern/define-links.mjs"
|
|
|
3
3
|
import { Field } from "payload";
|
|
4
4
|
//#region src/config/link-field.d.ts
|
|
5
5
|
/** Admin labels for the built-in link types. */
|
|
6
|
-
interface LinkFieldLabels {
|
|
6
|
+
export interface LinkFieldLabels {
|
|
7
7
|
label?: LabelLike;
|
|
8
8
|
none?: LabelLike;
|
|
9
9
|
reference?: LabelLike;
|
|
@@ -14,7 +14,7 @@ interface LinkFieldLabels {
|
|
|
14
14
|
urlField?: LabelLike;
|
|
15
15
|
samePageField?: LabelLike;
|
|
16
16
|
}
|
|
17
|
-
interface LinkFieldArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> extends LinkVariantSource<TDeclaration> {
|
|
17
|
+
export interface LinkFieldArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> extends LinkVariantSource<TDeclaration> {
|
|
18
18
|
/**
|
|
19
19
|
* Every collection that has a URL. A target missing here cannot be linked
|
|
20
20
|
* to from the admin panel even if its mapping exists.
|
|
@@ -30,6 +30,5 @@ interface LinkFieldArgs<TDeclaration extends LinkDeclaration = LinkDeclaration>
|
|
|
30
30
|
*/
|
|
31
31
|
interfaceName?: string;
|
|
32
32
|
}
|
|
33
|
-
declare const linkField: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: LinkFieldArgs<TDeclaration>) => Field;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { LinkFieldArgs, LinkFieldLabels, linkField };
|
|
33
|
+
export declare const linkField: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: LinkFieldArgs<TDeclaration>) => Field;
|
|
34
|
+
//#endregion
|
|
@@ -10,11 +10,11 @@ import { Payload } from "payload";
|
|
|
10
10
|
* `loadMappings` call in your own framework cache and invalidate it from
|
|
11
11
|
* `createMappingGlobal({ onChange })`.
|
|
12
12
|
*/
|
|
13
|
-
interface MappingCache {
|
|
13
|
+
export interface MappingCache {
|
|
14
14
|
get: (key: string) => PayloadCollectionMappingResolved[] | undefined;
|
|
15
15
|
set: (key: string, value: PayloadCollectionMappingResolved[]) => void;
|
|
16
16
|
}
|
|
17
|
-
interface LoadMappingsArgs {
|
|
17
|
+
export interface LoadMappingsArgs {
|
|
18
18
|
payload: Payload;
|
|
19
19
|
globalSlug?: string;
|
|
20
20
|
/**
|
|
@@ -49,6 +49,5 @@ interface LoadMappingsArgs {
|
|
|
49
49
|
*
|
|
50
50
|
* @param args The Payload instance and mapping-global settings.
|
|
51
51
|
*/
|
|
52
|
-
declare const loadMappings: (args: LoadMappingsArgs) => Promise<PayloadCollectionMappingResolved[]>;
|
|
53
|
-
//#endregion
|
|
54
|
-
export { LoadMappingsArgs, MappingCache, loadMappings };
|
|
52
|
+
export declare const loadMappings: (args: LoadMappingsArgs) => Promise<PayloadCollectionMappingResolved[]>;
|
|
53
|
+
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GlobalConfig } from "payload";
|
|
2
2
|
//#region src/config/mapping-global.d.ts
|
|
3
3
|
/** The global the mapping is authored in, unless overridden. */
|
|
4
|
-
declare const DEFAULT_MAPPING_GLOBAL_SLUG = "collections-mapping";
|
|
5
|
-
interface CreateMappingGlobalArgs {
|
|
4
|
+
export declare const DEFAULT_MAPPING_GLOBAL_SLUG = "collections-mapping";
|
|
5
|
+
export interface CreateMappingGlobalArgs {
|
|
6
6
|
/** Defaults to {@link DEFAULT_MAPPING_GLOBAL_SLUG}. */
|
|
7
7
|
globalSlug?: string;
|
|
8
8
|
/**
|
|
@@ -38,6 +38,5 @@ interface CreateMappingGlobalArgs {
|
|
|
38
38
|
*
|
|
39
39
|
* @param args Slug, localization and presentation overrides.
|
|
40
40
|
*/
|
|
41
|
-
declare const createMappingGlobal: (args?: CreateMappingGlobalArgs) => GlobalConfig;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { CreateMappingGlobalArgs, DEFAULT_MAPPING_GLOBAL_SLUG, createMappingGlobal };
|
|
41
|
+
export declare const createMappingGlobal: (args?: CreateMappingGlobalArgs) => GlobalConfig;
|
|
42
|
+
//#endregion
|
package/dist/config/plugin.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CreateMappingGlobalArgs } from "./mapping-global.mjs";
|
|
2
2
|
import { Plugin } from "payload";
|
|
3
3
|
//#region src/config/plugin.d.ts
|
|
4
|
-
interface WayfinderPluginArgs extends CreateMappingGlobalArgs {
|
|
4
|
+
export interface WayfinderPluginArgs extends CreateMappingGlobalArgs {
|
|
5
5
|
/**
|
|
6
6
|
* Collections to check for `defaultPopulate` at boot.
|
|
7
7
|
*
|
|
@@ -29,6 +29,5 @@ interface WayfinderPluginArgs extends CreateMappingGlobalArgs {
|
|
|
29
29
|
*
|
|
30
30
|
* @param args Mapping-global settings and startup-check inputs.
|
|
31
31
|
*/
|
|
32
|
-
declare const wayfinderPlugin: (args?: WayfinderPluginArgs) => Plugin;
|
|
33
|
-
//#endregion
|
|
34
|
-
export { WayfinderPluginArgs, wayfinderPlugin };
|
|
32
|
+
export declare const wayfinderPlugin: (args?: WayfinderPluginArgs) => Plugin;
|
|
33
|
+
//#endregion
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* without the plugin still works — `req.t` returns the key's fallback — but
|
|
7
7
|
* sees these in English regardless of the admin locale.
|
|
8
8
|
*/
|
|
9
|
-
declare const wayfinderTranslations: {
|
|
9
|
+
export declare const wayfinderTranslations: {
|
|
10
10
|
readonly en: {
|
|
11
11
|
readonly wayfinder: {
|
|
12
12
|
readonly duplicateCollection: "Each collection may only be mapped once";
|
|
@@ -30,5 +30,4 @@ declare const wayfinderTranslations: {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
//#endregion
|
|
34
|
-
export { wayfinderTranslations };
|
|
33
|
+
//#endregion
|
package/dist/lexical/index.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import { LinkFeature } from "@payloadcms/richtext-lexical";
|
|
|
8
8
|
* destination, so the floating link editor shows a useful hover preview
|
|
9
9
|
* instead of a blank one.
|
|
10
10
|
*/
|
|
11
|
-
declare const linkLabelFeature: import("@payloadcms/richtext-lexical").FeatureProviderProviderServer<undefined, undefined, undefined>;
|
|
11
|
+
export declare const linkLabelFeature: import("@payloadcms/richtext-lexical").FeatureProviderProviderServer<undefined, undefined, undefined>;
|
|
12
12
|
/**
|
|
13
13
|
* Replaces Lexical's link fields with the wayfinder link field, so links
|
|
14
14
|
* written in rich text route through the collection mapping exactly like links
|
|
@@ -16,7 +16,7 @@ declare const linkLabelFeature: import("@payloadcms/richtext-lexical").FeaturePr
|
|
|
16
16
|
*
|
|
17
17
|
* @param args The same arguments as the standalone link field.
|
|
18
18
|
*/
|
|
19
|
-
declare const wayfinderLinkFeature: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: LinkFieldArgs<TDeclaration>) => ReturnType<typeof LinkFeature>;
|
|
19
|
+
export declare const wayfinderLinkFeature: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: LinkFieldArgs<TDeclaration>) => ReturnType<typeof LinkFeature>;
|
|
20
20
|
/**
|
|
21
21
|
* Resolves a rich-text link node to an href.
|
|
22
22
|
*
|
|
@@ -31,8 +31,7 @@ declare const wayfinderLinkFeature: <TDeclaration extends LinkDeclaration = Link
|
|
|
31
31
|
*
|
|
32
32
|
* @param args The node's fields plus the usual link-resolution arguments.
|
|
33
33
|
*/
|
|
34
|
-
declare const resolveLinkNode: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: Omit<ResolveLinkArgs<TDeclaration>, "link"> & {
|
|
34
|
+
export declare const resolveLinkNode: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: Omit<ResolveLinkArgs<TDeclaration>, "link"> & {
|
|
35
35
|
fields: unknown;
|
|
36
36
|
}) => ResolvedLinkOf<TDeclaration> | null;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { linkLabelFeature, resolveLinkNode, wayfinderLinkFeature };
|
|
37
|
+
//#endregion
|
package/dist/montage/index.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ import { MontageSlots } from "@abinnovision/payloadcms-montage";
|
|
|
10
10
|
* Prefixed with the package name because extension names share one namespace
|
|
11
11
|
* across every library using montage.
|
|
12
12
|
*/
|
|
13
|
-
declare const wayfinderExtension: import("@abinnovision/payloadcms-montage").ContextExtension<Router<LinkDeclaration<Record<string, AnyLinkVariantDefinition>>>>;
|
|
13
|
+
export declare const wayfinderExtension: import("@abinnovision/payloadcms-montage").ContextExtension<Router<LinkDeclaration<Record<string, AnyLinkVariantDefinition>>>>;
|
|
14
14
|
/**
|
|
15
15
|
* What `initWayfinder` needs: a router's settings, plus where the mappings
|
|
16
16
|
* come from.
|
|
@@ -19,7 +19,7 @@ declare const wayfinderExtension: import("@abinnovision/payloadcms-montage").Con
|
|
|
19
19
|
* from. A route that resolved a path has them already, and reading the global
|
|
20
20
|
* a second time to render the same page is a query for nothing.
|
|
21
21
|
*/
|
|
22
|
-
type InitWayfinderArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> = Omit<CreateRouterArgs<TDeclaration>, "mappings"> & ({
|
|
22
|
+
export type InitWayfinderArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> = Omit<CreateRouterArgs<TDeclaration>, "mappings"> & ({
|
|
23
23
|
mappings: PayloadCollectionMappingResolved[];
|
|
24
24
|
} | {
|
|
25
25
|
load: Omit<LoadMappingsArgs, "localized"> & {
|
|
@@ -37,7 +37,7 @@ type InitWayfinderArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> =
|
|
|
37
37
|
* @param ctx The render context.
|
|
38
38
|
* @param args The router's settings, and the mappings or where to read them.
|
|
39
39
|
*/
|
|
40
|
-
declare const initWayfinder: <TDeclaration extends LinkDeclaration = LinkDeclaration>(ctx: MontageSlots, args: InitWayfinderArgs<TDeclaration>) => Promise<void>;
|
|
40
|
+
export declare const initWayfinder: <TDeclaration extends LinkDeclaration = LinkDeclaration>(ctx: MontageSlots, args: InitWayfinderArgs<TDeclaration>) => Promise<void>;
|
|
41
41
|
/**
|
|
42
42
|
* Reads the router off the render context.
|
|
43
43
|
*
|
|
@@ -49,6 +49,5 @@ declare const initWayfinder: <TDeclaration extends LinkDeclaration = LinkDeclara
|
|
|
49
49
|
*
|
|
50
50
|
* @param ctx The render context.
|
|
51
51
|
*/
|
|
52
|
-
declare const wayfinderFrom: <TDeclaration extends LinkDeclaration = LinkDeclaration>(ctx: MontageSlots) => Router<TDeclaration>;
|
|
53
|
-
//#endregion
|
|
54
|
-
export { InitWayfinderArgs, initWayfinder, wayfinderExtension, wayfinderFrom };
|
|
52
|
+
export declare const wayfinderFrom: <TDeclaration extends LinkDeclaration = LinkDeclaration>(ctx: MontageSlots) => Router<TDeclaration>;
|
|
53
|
+
//#endregion
|
|
@@ -58,9 +58,9 @@ type FieldData<F1> = F1 extends {
|
|
|
58
58
|
* signatures that reject ordinary link data, so such a variant contributes
|
|
59
59
|
* nothing rather than something wrong.
|
|
60
60
|
*/
|
|
61
|
-
type DataOfFields<TFields extends readonly unknown[]> = number extends TFields["length"] ? object : UnionToIntersection<FieldData<TFields[number]>>;
|
|
61
|
+
export type DataOfFields<TFields extends readonly unknown[]> = number extends TFields["length"] ? object : UnionToIntersection<FieldData<TFields[number]>>;
|
|
62
62
|
/** A variant that has had no resolver attached. */
|
|
63
|
-
interface LinkVariantSpec<TFields extends readonly Field[]> {
|
|
63
|
+
export interface LinkVariantSpec<TFields extends readonly Field[]> {
|
|
64
64
|
label: LabelLike;
|
|
65
65
|
fields?: TFields;
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ interface LinkVariantSpec<TFields extends readonly Field[]> {
|
|
|
68
68
|
* A declared link type: its admin presentation, the fields it contributes, and
|
|
69
69
|
* how it turns into an href.
|
|
70
70
|
*/
|
|
71
|
-
interface LinkVariantDefinition<TCtx = unknown, TFields extends readonly Field[] = readonly Field[], TExtra = object, TData = DataOfFields<TFields>> {
|
|
71
|
+
export interface LinkVariantDefinition<TCtx = unknown, TFields extends readonly Field[] = readonly Field[], TExtra = object, TData = DataOfFields<TFields>> {
|
|
72
72
|
label: LabelLike;
|
|
73
73
|
fields?: TFields;
|
|
74
74
|
resolve?: (args: {
|
|
@@ -91,13 +91,13 @@ interface LinkVariantDefinition<TCtx = unknown, TFields extends readonly Field[]
|
|
|
91
91
|
* `resolve` takes `never` so that any resolver satisfies it: a parameter is
|
|
92
92
|
* contravariant, and `never` is assignable to every argument type.
|
|
93
93
|
*/
|
|
94
|
-
interface AnyLinkVariantDefinition {
|
|
94
|
+
export interface AnyLinkVariantDefinition {
|
|
95
95
|
label: LabelLike;
|
|
96
96
|
fields?: readonly Field[];
|
|
97
97
|
resolve?: (args: never) => unknown;
|
|
98
98
|
}
|
|
99
99
|
/** The link vocabulary an app declares: which types exist and how each resolves. */
|
|
100
|
-
interface LinkDeclaration<TVariants1 extends Record<string, AnyLinkVariantDefinition> = Record<string, AnyLinkVariantDefinition>> {
|
|
100
|
+
export interface LinkDeclaration<TVariants1 extends Record<string, AnyLinkVariantDefinition> = Record<string, AnyLinkVariantDefinition>> {
|
|
101
101
|
variants: TVariants1;
|
|
102
102
|
}
|
|
103
103
|
/** The stored shape of a link field built from a declaration. */
|
|
@@ -116,9 +116,9 @@ type FieldsData<V> = V extends {
|
|
|
116
116
|
type DataOfVariant<V> = V extends {
|
|
117
117
|
__data?: infer D;
|
|
118
118
|
} ? unknown extends D ? FieldsData<V> : D : FieldsData<V>;
|
|
119
|
-
type LinkDataOf<T> = T extends LinkDeclaration<infer TVariants> ? LinkFieldData<Extract<keyof TVariants, string>, UnionToIntersection<{ [K in keyof TVariants]: DataOfVariant<TVariants[K]>; }[keyof TVariants]>> : never;
|
|
119
|
+
export type LinkDataOf<T> = T extends LinkDeclaration<infer TVariants> ? LinkFieldData<Extract<keyof TVariants, string>, UnionToIntersection<{ [K in keyof TVariants]: DataOfVariant<TVariants[K]>; }[keyof TVariants]>> : never;
|
|
120
120
|
/** What resolving a link built from a declaration can produce. */
|
|
121
|
-
type ResolvedLinkOf<T> = T extends LinkDeclaration<infer TVariants> ? BaseResolvedLink & Contributed<UnionToIntersection<{ [K in keyof TVariants]: TVariants[K] extends {
|
|
121
|
+
export type ResolvedLinkOf<T> = T extends LinkDeclaration<infer TVariants> ? BaseResolvedLink & Contributed<UnionToIntersection<{ [K in keyof TVariants]: TVariants[K] extends {
|
|
122
122
|
resolve?: (args: never) => infer R;
|
|
123
123
|
} ? Extract<R, BaseResolvedLink> extends (infer E) ? Omit<E, keyof BaseResolvedLink> : object : object; }[keyof TVariants]>> : never;
|
|
124
124
|
/**
|
|
@@ -144,7 +144,7 @@ interface VariantStep<TCtx, TFields extends readonly Field[], TData> {
|
|
|
144
144
|
*/
|
|
145
145
|
data: <TOverride>() => VariantStep<TCtx, TFields, TOverride>;
|
|
146
146
|
}
|
|
147
|
-
type VariantBuilder<TCtx> = <const TFields extends readonly Field[]>(spec: LinkVariantSpec<TFields>) => LinkVariantDefinition<TCtx, TFields, object, DataOfFields<TFields>> & VariantStep<TCtx, TFields, DataOfFields<TFields>>;
|
|
147
|
+
export type VariantBuilder<TCtx> = <const TFields extends readonly Field[]>(spec: LinkVariantSpec<TFields>) => LinkVariantDefinition<TCtx, TFields, object, DataOfFields<TFields>> & VariantStep<TCtx, TFields, DataOfFields<TFields>>;
|
|
148
148
|
/**
|
|
149
149
|
* Declares the link types an app offers.
|
|
150
150
|
*
|
|
@@ -161,7 +161,7 @@ type VariantBuilder<TCtx> = <const TFields extends readonly Field[]>(spec: LinkV
|
|
|
161
161
|
* stays free of the Payload runtime and a frontend can hold the same
|
|
162
162
|
* declaration the CMS config does.
|
|
163
163
|
*/
|
|
164
|
-
declare const defineLinks: <TCtx = unknown>() => <const TVariants1 extends Record<string, AnyLinkVariantDefinition>>(build: (variant: VariantBuilder<TCtx>) => {
|
|
164
|
+
export declare const defineLinks: <TCtx = unknown>() => <const TVariants1 extends Record<string, AnyLinkVariantDefinition>>(build: (variant: VariantBuilder<TCtx>) => {
|
|
165
165
|
variants: TVariants1;
|
|
166
166
|
}) => LinkDeclaration<TVariants1>;
|
|
167
167
|
/**
|
|
@@ -173,7 +173,7 @@ type ContextOfVariant<V> = V extends {
|
|
|
173
173
|
} ? NonNullable<R> extends ((...args: never[]) => unknown) ? Parameters<NonNullable<R>>[0] extends {
|
|
174
174
|
context: infer C;
|
|
175
175
|
} ? C : never : never : never;
|
|
176
|
-
type LinkContextOf<T> = T extends LinkDeclaration<infer TVariants> ? UnionToIntersection<{ [K in keyof TVariants]: ContextOfVariant<TVariants[K]>; }[keyof TVariants]> : unknown;
|
|
176
|
+
export type LinkContextOf<T> = T extends LinkDeclaration<infer TVariants> ? UnionToIntersection<{ [K in keyof TVariants]: ContextOfVariant<TVariants[K]>; }[keyof TVariants]> : unknown;
|
|
177
177
|
/**
|
|
178
178
|
* Carries a declaration to whichever function needs it.
|
|
179
179
|
*
|
|
@@ -182,7 +182,7 @@ type LinkContextOf<T> = T extends LinkDeclaration<infer TVariants> ? UnionToInte
|
|
|
182
182
|
* the context they expect, both flow to the call site. Without it a caller
|
|
183
183
|
* would have to annotate the result to see its own variants' properties.
|
|
184
184
|
*/
|
|
185
|
-
interface LinkVariantSource<TDeclaration extends LinkDeclaration = LinkDeclaration> {
|
|
185
|
+
export interface LinkVariantSource<TDeclaration extends LinkDeclaration = LinkDeclaration> {
|
|
186
186
|
/** The declaration built by {@link defineLinks}. */
|
|
187
187
|
links?: TDeclaration;
|
|
188
188
|
}
|
|
@@ -194,6 +194,5 @@ interface LinkVariantSource<TDeclaration extends LinkDeclaration = LinkDeclarati
|
|
|
194
194
|
*
|
|
195
195
|
* @param source The declaration, or nothing.
|
|
196
196
|
*/
|
|
197
|
-
declare const variantsOf: <TCtx, TExtra>(source: LinkVariantSource) => readonly DeclaredLinkVariant<TCtx, TExtra>[];
|
|
198
|
-
//#endregion
|
|
199
|
-
export { AnyLinkVariantDefinition, DataOfFields, LinkContextOf, LinkDataOf, LinkDeclaration, LinkVariantDefinition, LinkVariantSource, LinkVariantSpec, ResolvedLinkOf, VariantBuilder, defineLinks, variantsOf };
|
|
197
|
+
export declare const variantsOf: <TCtx, TExtra>(source: LinkVariantSource) => readonly DeclaredLinkVariant<TCtx, TExtra>[];
|
|
198
|
+
//#endregion
|
|
@@ -12,8 +12,7 @@ import { PayloadCollectionMapping, PayloadCollectionMappingResolved } from "./ty
|
|
|
12
12
|
* @param options Where a relationship parameter falls back to when the target
|
|
13
13
|
* collection's own pattern cannot name an identifier.
|
|
14
14
|
*/
|
|
15
|
-
declare const defineMappings: (mappings: PayloadCollectionMapping[], options?: {
|
|
15
|
+
export declare const defineMappings: (mappings: PayloadCollectionMapping[], options?: {
|
|
16
16
|
fallbackIdentifierField?: string;
|
|
17
17
|
}) => PayloadCollectionMappingResolved[];
|
|
18
|
-
//#endregion
|
|
19
|
-
export { defineMappings };
|
|
18
|
+
//#endregion
|
|
@@ -18,6 +18,5 @@ import { LinkVariantSource } from "./define-links.mjs";
|
|
|
18
18
|
* @param link The nested link group of a link node.
|
|
19
19
|
* @param source App-declared link types, which may describe themselves.
|
|
20
20
|
*/
|
|
21
|
-
declare const deriveLinkLabel: <TExtra>(link: LinkFieldData<string, TExtra>, source?: LinkVariantSource) => string | undefined;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { deriveLinkLabel };
|
|
21
|
+
export declare const deriveLinkLabel: <TExtra>(link: LinkFieldData<string, TExtra>, source?: LinkVariantSource) => string | undefined;
|
|
22
|
+
//#endregion
|
|
@@ -16,6 +16,5 @@ import { LinkFieldData } from "./types.mjs";
|
|
|
16
16
|
*
|
|
17
17
|
* @param fields The node's `fields` object, in whatever shape it arrived.
|
|
18
18
|
*/
|
|
19
|
-
declare const normaliseLinkNodeFields: (fields: unknown) => LinkFieldData | undefined;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { normaliseLinkNodeFields };
|
|
19
|
+
export declare const normaliseLinkNodeFields: (fields: unknown) => LinkFieldData | undefined;
|
|
20
|
+
//#endregion
|
|
@@ -5,7 +5,7 @@ interface MatchOpts {
|
|
|
5
5
|
locale: string;
|
|
6
6
|
mappings: PayloadCollectionMappingResolved[];
|
|
7
7
|
}
|
|
8
|
-
type PayloadCollectionMatch = {
|
|
8
|
+
export type PayloadCollectionMatch = {
|
|
9
9
|
mapping: PayloadCollectionMappingResolved;
|
|
10
10
|
} & PayloadCollectionMappingMatch;
|
|
11
11
|
/**
|
|
@@ -21,6 +21,5 @@ type PayloadCollectionMatch = {
|
|
|
21
21
|
*
|
|
22
22
|
* @param opts The path, locale and candidate mappings.
|
|
23
23
|
*/
|
|
24
|
-
declare const matchCollectionMappings: (opts: MatchOpts) => PayloadCollectionMatch[];
|
|
25
|
-
//#endregion
|
|
26
|
-
export { PayloadCollectionMatch, matchCollectionMappings };
|
|
24
|
+
export declare const matchCollectionMappings: (opts: MatchOpts) => PayloadCollectionMatch[];
|
|
25
|
+
//#endregion
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PayloadCollectionMappingResolved } from "./types.mjs";
|
|
2
2
|
import { SanitizedCollectionConfig } from "payload";
|
|
3
3
|
//#region src/pattern/param-query-path.d.ts
|
|
4
|
-
type RegisteredCollections = Record<string, {
|
|
4
|
+
export type RegisteredCollections = Record<string, {
|
|
5
5
|
config: SanitizedCollectionConfig;
|
|
6
6
|
} | undefined>;
|
|
7
|
-
interface ResolveParamQueryPathArgs {
|
|
7
|
+
export interface ResolveParamQueryPathArgs {
|
|
8
8
|
/** The collection the mapping belongs to. */
|
|
9
9
|
config: SanitizedCollectionConfig;
|
|
10
10
|
/** The parameter name taken from the path pattern. */
|
|
@@ -35,10 +35,9 @@ interface ResolveParamQueryPathArgs {
|
|
|
35
35
|
*
|
|
36
36
|
* @param args The collection, parameter and resolution context.
|
|
37
37
|
*/
|
|
38
|
-
declare const resolveParamQueryPath: (args: ResolveParamQueryPathArgs) => {
|
|
38
|
+
export declare const resolveParamQueryPath: (args: ResolveParamQueryPathArgs) => {
|
|
39
39
|
queryPath: string;
|
|
40
40
|
} | {
|
|
41
41
|
error: string;
|
|
42
42
|
};
|
|
43
|
-
//#endregion
|
|
44
|
-
export { RegisteredCollections, ResolveParamQueryPathArgs, resolveParamQueryPath };
|
|
43
|
+
//#endregion
|
|
@@ -8,7 +8,7 @@ import { PayloadCollectionMapping, PayloadCollectionMappingResolved, PayloadColl
|
|
|
8
8
|
* @param resolvers The pattern's compiled resolvers.
|
|
9
9
|
* @param values The parameter values, in pattern order.
|
|
10
10
|
*/
|
|
11
|
-
declare const isRootWildcard: (resolvers: PayloadCollectionMappingResolvers, values: string[]) => boolean;
|
|
11
|
+
export declare const isRootWildcard: (resolvers: PayloadCollectionMappingResolvers, values: string[]) => boolean;
|
|
12
12
|
/**
|
|
13
13
|
* Picks the resolvers for a locale, falling back to the unlocalized bucket.
|
|
14
14
|
*
|
|
@@ -19,7 +19,7 @@ declare const isRootWildcard: (resolvers: PayloadCollectionMappingResolvers, val
|
|
|
19
19
|
* @param mapping The compiled mapping.
|
|
20
20
|
* @param locale The locale to resolve for.
|
|
21
21
|
*/
|
|
22
|
-
declare const resolversFor: (mapping: PayloadCollectionMappingResolved, locale: string) => PayloadCollectionMappingResolvers | undefined;
|
|
22
|
+
export declare const resolversFor: (mapping: PayloadCollectionMappingResolved, locale: string) => PayloadCollectionMappingResolvers | undefined;
|
|
23
23
|
/**
|
|
24
24
|
* Compiles a mapping's patterns into match and build functions.
|
|
25
25
|
*
|
|
@@ -27,6 +27,5 @@ declare const resolversFor: (mapping: PayloadCollectionMappingResolved, locale:
|
|
|
27
27
|
* @param fallbackIdentifierField The field a relationship parameter falls back
|
|
28
28
|
* to when the target's own pattern cannot name one.
|
|
29
29
|
*/
|
|
30
|
-
declare const resolveCollectionMapping: (input: PayloadCollectionMapping, fallbackIdentifierField?: string) => PayloadCollectionMappingResolved;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { isRootWildcard, resolveCollectionMapping, resolversFor };
|
|
30
|
+
export declare const resolveCollectionMapping: (input: PayloadCollectionMapping, fallbackIdentifierField?: string) => PayloadCollectionMappingResolved;
|
|
31
|
+
//#endregion
|
package/dist/pattern/types.d.mts
CHANGED
|
@@ -9,9 +9,9 @@ import { Field } from "payload";
|
|
|
9
9
|
* arrives as a plain string, which normalises into this single bucket so the
|
|
10
10
|
* rest of the package has one shape to work with.
|
|
11
11
|
*/
|
|
12
|
-
declare const DEFAULT_LOCALE_KEY = "__default";
|
|
12
|
+
export declare const DEFAULT_LOCALE_KEY = "__default";
|
|
13
13
|
/** The field a relationship parameter matches on unless something says otherwise. */
|
|
14
|
-
declare const DEFAULT_IDENTIFIER_FIELD = "slug";
|
|
14
|
+
export declare const DEFAULT_IDENTIFIER_FIELD = "slug";
|
|
15
15
|
/**
|
|
16
16
|
* Maps one collection onto the URL patterns its documents live at.
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@ declare const DEFAULT_IDENTIFIER_FIELD = "slug";
|
|
|
19
19
|
* localization supplies a single pattern. Authored in the mapping global, so
|
|
20
20
|
* adding a page type never means touching routing code.
|
|
21
21
|
*/
|
|
22
|
-
interface PayloadCollectionMapping {
|
|
22
|
+
export interface PayloadCollectionMapping {
|
|
23
23
|
collection: string;
|
|
24
24
|
/**
|
|
25
25
|
* Either one pattern per locale (`{ de: "/:format/:slug" }`) or a single
|
|
@@ -30,7 +30,7 @@ interface PayloadCollectionMapping {
|
|
|
30
30
|
/**
|
|
31
31
|
* Result of matching a path against one mapping.
|
|
32
32
|
*/
|
|
33
|
-
interface PayloadCollectionMappingMatch {
|
|
33
|
+
export interface PayloadCollectionMappingMatch {
|
|
34
34
|
/**
|
|
35
35
|
* The pattern's last parameter, which identifies the document within its
|
|
36
36
|
* collection.
|
|
@@ -50,14 +50,14 @@ interface PayloadCollectionMappingMatch {
|
|
|
50
50
|
* How specific a pattern is, used to order candidates so that the most
|
|
51
51
|
* precise pattern wins regardless of the order rows sit in the admin UI.
|
|
52
52
|
*/
|
|
53
|
-
interface PayloadCollectionMappingSpecificity {
|
|
53
|
+
export interface PayloadCollectionMappingSpecificity {
|
|
54
54
|
/** Segments that are literal text rather than a parameter. */
|
|
55
55
|
literalSegments: number;
|
|
56
56
|
/** Whether the pattern ends in a catch-all. */
|
|
57
57
|
hasWildcard: boolean;
|
|
58
58
|
totalSegments: number;
|
|
59
59
|
}
|
|
60
|
-
interface PayloadCollectionMappingResolvers {
|
|
60
|
+
export interface PayloadCollectionMappingResolvers {
|
|
61
61
|
match: (path: string) => false | PayloadCollectionMappingMatch;
|
|
62
62
|
build: (params: ParamData) => string;
|
|
63
63
|
/**
|
|
@@ -68,7 +68,7 @@ interface PayloadCollectionMappingResolvers {
|
|
|
68
68
|
paramNames: string[];
|
|
69
69
|
specificity: PayloadCollectionMappingSpecificity;
|
|
70
70
|
}
|
|
71
|
-
interface PayloadCollectionMappingResolved {
|
|
71
|
+
export interface PayloadCollectionMappingResolved {
|
|
72
72
|
collection: string;
|
|
73
73
|
/**
|
|
74
74
|
* The field a relationship parameter matches on when it cannot be derived
|
|
@@ -106,12 +106,12 @@ interface PayloadCollectionMappingResolved {
|
|
|
106
106
|
* Defaults to returning the path untouched, so a project serving unprefixed
|
|
107
107
|
* URLs needs no configuration.
|
|
108
108
|
*/
|
|
109
|
-
type FormatHref = (args: {
|
|
109
|
+
export type FormatHref = (args: {
|
|
110
110
|
path: string;
|
|
111
111
|
locale: string;
|
|
112
112
|
}) => string;
|
|
113
113
|
/** Label accepted wherever the admin panel shows one. */
|
|
114
|
-
type LabelLike = string | Record<string, string>;
|
|
114
|
+
export type LabelLike = string | Record<string, string>;
|
|
115
115
|
/**
|
|
116
116
|
* Optional-everything, including an explicit `undefined`.
|
|
117
117
|
*
|
|
@@ -120,9 +120,9 @@ type LabelLike = string | Record<string, string>;
|
|
|
120
120
|
* reads one of its own optional fields and passes it straight back would not
|
|
121
121
|
* typecheck against its own declared shape.
|
|
122
122
|
*/
|
|
123
|
-
type Contributed<T> = { [K in keyof T]?: T[K] | undefined; };
|
|
123
|
+
export type Contributed<T> = { [K in keyof T]?: T[K] | undefined; };
|
|
124
124
|
/** The link types the package understands without configuration. */
|
|
125
|
-
type BuiltinLinkVariant = "none" | "reference" | "custom" | "same-page";
|
|
125
|
+
export type BuiltinLinkVariant = "none" | "reference" | "custom" | "same-page";
|
|
126
126
|
/**
|
|
127
127
|
* How Payload identifies a document.
|
|
128
128
|
*
|
|
@@ -130,7 +130,7 @@ type BuiltinLinkVariant = "none" | "reference" | "custom" | "same-page";
|
|
|
130
130
|
* reference id crosses the package boundary accepts both, so a project is not
|
|
131
131
|
* forced to cast at the call site over its own choice of adapter.
|
|
132
132
|
*/
|
|
133
|
-
type DocumentId = string | number;
|
|
133
|
+
export type DocumentId = string | number;
|
|
134
134
|
/**
|
|
135
135
|
* Structural shape of the `link` field group.
|
|
136
136
|
*
|
|
@@ -143,7 +143,7 @@ type DocumentId = string | number;
|
|
|
143
143
|
* those variants contribute, so a variant's own resolver can read the data its
|
|
144
144
|
* own fields produced without a cast.
|
|
145
145
|
*/
|
|
146
|
-
type LinkFieldData<TVariant extends string = never, TExtra = object> = {
|
|
146
|
+
export type LinkFieldData<TVariant extends string = never, TExtra = object> = {
|
|
147
147
|
type?: BuiltinLinkVariant | TVariant | null;
|
|
148
148
|
label?: string | null;
|
|
149
149
|
reference?: {
|
|
@@ -157,7 +157,7 @@ type LinkFieldData<TVariant extends string = never, TExtra = object> = {
|
|
|
157
157
|
newTab?: boolean | null;
|
|
158
158
|
} & Contributed<TExtra>;
|
|
159
159
|
/** What every link resolves to, before any variant adds to it. */
|
|
160
|
-
interface BaseResolvedLink {
|
|
160
|
+
export interface BaseResolvedLink {
|
|
161
161
|
href: string;
|
|
162
162
|
target?: string;
|
|
163
163
|
rel?: string;
|
|
@@ -174,7 +174,7 @@ interface BaseResolvedLink {
|
|
|
174
174
|
* so requiring all of it would mean each variant had to return the other
|
|
175
175
|
* variants' properties alongside its own.
|
|
176
176
|
*/
|
|
177
|
-
type ResolvedLink<E = object> = BaseResolvedLink & Contributed<E>;
|
|
177
|
+
export type ResolvedLink<E = object> = BaseResolvedLink & Contributed<E>;
|
|
178
178
|
/**
|
|
179
179
|
* One variant, flattened out of a declaration with its key put back on it.
|
|
180
180
|
*
|
|
@@ -182,7 +182,7 @@ type ResolvedLink<E = object> = BaseResolvedLink & Contributed<E>;
|
|
|
182
182
|
* authoring form: variants are written through the builder, which is what
|
|
183
183
|
* derives their field types.
|
|
184
184
|
*/
|
|
185
|
-
interface DeclaredLinkVariant<TCtx = unknown, TExtra = object> {
|
|
185
|
+
export interface DeclaredLinkVariant<TCtx = unknown, TExtra = object> {
|
|
186
186
|
value: string;
|
|
187
187
|
label: LabelLike;
|
|
188
188
|
/** Readonly, because a `const` type parameter infers a readonly tuple. */
|
|
@@ -192,5 +192,4 @@ interface DeclaredLinkVariant<TCtx = unknown, TExtra = object> {
|
|
|
192
192
|
context: TCtx;
|
|
193
193
|
}) => ResolvedLink<TExtra> | null;
|
|
194
194
|
}
|
|
195
|
-
//#endregion
|
|
196
|
-
export { BaseResolvedLink, BuiltinLinkVariant, Contributed, DEFAULT_IDENTIFIER_FIELD, DEFAULT_LOCALE_KEY, DeclaredLinkVariant, DocumentId, FormatHref, LabelLike, LinkFieldData, PayloadCollectionMapping, PayloadCollectionMappingMatch, PayloadCollectionMappingResolved, PayloadCollectionMappingResolvers, PayloadCollectionMappingSpecificity, ResolvedLink };
|
|
195
|
+
//#endregion
|
|
@@ -8,10 +8,10 @@ import { BuildDiagnosticReason, OnDiagnostic } from "./diagnostics.mjs";
|
|
|
8
8
|
* collection interfaces assign to it; the fields the path pattern names are
|
|
9
9
|
* read dynamically below.
|
|
10
10
|
*/
|
|
11
|
-
type LinkableDocument = object;
|
|
11
|
+
export type LinkableDocument = object;
|
|
12
12
|
/** Applied when no {@link FormatHref} is supplied: the path, untouched. */
|
|
13
|
-
declare const identityFormatHref: FormatHref;
|
|
14
|
-
interface BuildHrefArgs {
|
|
13
|
+
export declare const identityFormatHref: FormatHref;
|
|
14
|
+
export interface BuildHrefArgs {
|
|
15
15
|
mappings: PayloadCollectionMappingResolved[];
|
|
16
16
|
collection: string;
|
|
17
17
|
document: LinkableDocument;
|
|
@@ -28,6 +28,5 @@ interface BuildHrefArgs {
|
|
|
28
28
|
*
|
|
29
29
|
* @param args The mappings, target collection, document and locale.
|
|
30
30
|
*/
|
|
31
|
-
declare const buildHref: (args: BuildHrefArgs) => string | null;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { BuildHrefArgs, LinkableDocument, buildHref, identityFormatHref };
|
|
31
|
+
export declare const buildHref: (args: BuildHrefArgs) => string | null;
|
|
32
|
+
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormatHref, PayloadCollectionMappingResolved } from "../pattern/types.mjs";
|
|
2
2
|
import { BuildDiagnosticReason, OnDiagnostic } from "./diagnostics.mjs";
|
|
3
3
|
//#region src/runtime/build-path.d.ts
|
|
4
|
-
interface BuildPathArgs {
|
|
4
|
+
export interface BuildPathArgs {
|
|
5
5
|
mappings: PayloadCollectionMappingResolved[];
|
|
6
6
|
collection: string;
|
|
7
7
|
locale: string;
|
|
@@ -27,6 +27,5 @@ interface BuildPathArgs {
|
|
|
27
27
|
*
|
|
28
28
|
* @param args The mappings, collection, locale and parameter values.
|
|
29
29
|
*/
|
|
30
|
-
declare const buildPath: (args: BuildPathArgs) => string;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { BuildPathArgs, buildPath };
|
|
30
|
+
export declare const buildPath: (args: BuildPathArgs) => string;
|
|
31
|
+
//#endregion
|
|
@@ -6,7 +6,7 @@ import { ResolveReference } from "./resolve-link.mjs";
|
|
|
6
6
|
import { PayloadDocument, ResolvePathWhere, ResolvedPath } from "./resolve-path.mjs";
|
|
7
7
|
import { Payload } from "payload";
|
|
8
8
|
//#region src/runtime/create-router.d.ts
|
|
9
|
-
interface CreateRouterArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> {
|
|
9
|
+
export interface CreateRouterArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> {
|
|
10
10
|
mappings: PayloadCollectionMappingResolved[];
|
|
11
11
|
/** Which locale's pattern every call builds and matches against. */
|
|
12
12
|
locale: string;
|
|
@@ -27,7 +27,7 @@ interface CreateRouterArgs<TDeclaration extends LinkDeclaration = LinkDeclaratio
|
|
|
27
27
|
onDiagnostic?: OnDiagnostic<DiagnosticReason>;
|
|
28
28
|
}
|
|
29
29
|
/** Everything a request needs in order to turn documents and links into URLs. */
|
|
30
|
-
interface Router<TDeclaration extends LinkDeclaration = LinkDeclaration> {
|
|
30
|
+
export interface Router<TDeclaration extends LinkDeclaration = LinkDeclaration> {
|
|
31
31
|
/** The href a document is served at, or null. */
|
|
32
32
|
href: (collection: string, document: LinkableDocument) => string | null;
|
|
33
33
|
/**
|
|
@@ -67,6 +67,5 @@ interface Router<TDeclaration extends LinkDeclaration = LinkDeclaration> {
|
|
|
67
67
|
*
|
|
68
68
|
* @param args The mappings, locale and per-request link settings.
|
|
69
69
|
*/
|
|
70
|
-
declare const createRouter: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: CreateRouterArgs<TDeclaration>) => Router<TDeclaration>;
|
|
71
|
-
//#endregion
|
|
72
|
-
export { CreateRouterArgs, Router, createRouter };
|
|
70
|
+
export declare const createRouter: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: CreateRouterArgs<TDeclaration>) => Router<TDeclaration>;
|
|
71
|
+
//#endregion
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* the distinction someone staring at a missing link needs. These reasons carry
|
|
9
9
|
* it out of band.
|
|
10
10
|
*/
|
|
11
|
-
type DiagnosticReason = "no-mapping" | "no-locale-pattern" | "unpopulated-reference" | "missing-param" | "no-document" | "unknown-variant";
|
|
12
|
-
interface Diagnostic<TReason extends DiagnosticReason> {
|
|
11
|
+
export type DiagnosticReason = "no-mapping" | "no-locale-pattern" | "unpopulated-reference" | "missing-param" | "no-document" | "unknown-variant";
|
|
12
|
+
export interface Diagnostic<TReason extends DiagnosticReason> {
|
|
13
13
|
reason: TReason;
|
|
14
14
|
collection?: string;
|
|
15
15
|
locale?: string;
|
|
@@ -24,12 +24,11 @@ interface Diagnostic<TReason extends DiagnosticReason> {
|
|
|
24
24
|
* misconfigured collection reports forty times. Deduplicating is the caller's
|
|
25
25
|
* job — the package cannot know which of them are worth surfacing.
|
|
26
26
|
*/
|
|
27
|
-
type OnDiagnostic<TReason extends DiagnosticReason> = (diagnostic: Diagnostic<TReason>) => void;
|
|
27
|
+
export type OnDiagnostic<TReason extends DiagnosticReason> = (diagnostic: Diagnostic<TReason>) => void;
|
|
28
28
|
/** Reasons {@link buildHref} and {@link buildPath} can report. */
|
|
29
|
-
type BuildDiagnosticReason = "no-mapping" | "no-locale-pattern" | "missing-param";
|
|
29
|
+
export type BuildDiagnosticReason = "no-mapping" | "no-locale-pattern" | "missing-param";
|
|
30
30
|
/** Reasons link resolution can report. */
|
|
31
|
-
type ResolveLinkDiagnosticReason = BuildDiagnosticReason | "unpopulated-reference" | "unknown-variant";
|
|
31
|
+
export type ResolveLinkDiagnosticReason = BuildDiagnosticReason | "unpopulated-reference" | "unknown-variant";
|
|
32
32
|
/** Reasons path resolution can report. */
|
|
33
|
-
type ResolvePathDiagnosticReason = "no-mapping" | "no-document";
|
|
34
|
-
//#endregion
|
|
35
|
-
export { BuildDiagnosticReason, Diagnostic, DiagnosticReason, OnDiagnostic, ResolveLinkDiagnosticReason, ResolvePathDiagnosticReason };
|
|
33
|
+
export type ResolvePathDiagnosticReason = "no-mapping" | "no-document";
|
|
34
|
+
//#endregion
|
|
@@ -11,14 +11,14 @@ import { OnDiagnostic, ResolveLinkDiagnosticReason } from "./diagnostics.mjs";
|
|
|
11
11
|
* strategy: the package resolves from the populated document, and this is the
|
|
12
12
|
* documented way out for setups that cannot.
|
|
13
13
|
*/
|
|
14
|
-
type ResolveReference = (args: {
|
|
14
|
+
export type ResolveReference = (args: {
|
|
15
15
|
relationTo: string;
|
|
16
16
|
value: DocumentId | {
|
|
17
17
|
id: DocumentId;
|
|
18
18
|
};
|
|
19
19
|
locale: string;
|
|
20
20
|
}) => string | null;
|
|
21
|
-
interface ResolveLinkArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> extends LinkVariantSource<TDeclaration> {
|
|
21
|
+
export interface ResolveLinkArgs<TDeclaration extends LinkDeclaration = LinkDeclaration> extends LinkVariantSource<TDeclaration> {
|
|
22
22
|
/**
|
|
23
23
|
* The link group's value.
|
|
24
24
|
*
|
|
@@ -53,7 +53,7 @@ interface ResolveLinkArgs<TDeclaration extends LinkDeclaration = LinkDeclaration
|
|
|
53
53
|
*
|
|
54
54
|
* @param args The link value, mappings, locale and any app-declared variants.
|
|
55
55
|
*/
|
|
56
|
-
declare const resolveLink: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: ResolveLinkArgs<TDeclaration>) => ResolvedLinkOf<TDeclaration> | null;
|
|
56
|
+
export declare const resolveLink: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: ResolveLinkArgs<TDeclaration>) => ResolvedLinkOf<TDeclaration> | null;
|
|
57
57
|
/**
|
|
58
58
|
* Whether a link would resolve to something navigable. Use it to decide
|
|
59
59
|
* whether to render a link at all, rather than emitting a dead anchor.
|
|
@@ -61,8 +61,7 @@ declare const resolveLink: <TDeclaration extends LinkDeclaration = LinkDeclarati
|
|
|
61
61
|
* @param args The same arguments as {@link resolveLink}, plus whether a label
|
|
62
62
|
* is required for the link to be worth rendering.
|
|
63
63
|
*/
|
|
64
|
-
declare const isAvailableLink: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: ResolveLinkArgs<TDeclaration> & {
|
|
64
|
+
export declare const isAvailableLink: <TDeclaration extends LinkDeclaration = LinkDeclaration>(args: ResolveLinkArgs<TDeclaration> & {
|
|
65
65
|
withLabel?: boolean;
|
|
66
66
|
}) => boolean;
|
|
67
|
-
//#endregion
|
|
68
|
-
export { ResolveLinkArgs, ResolveReference, isAvailableLink, resolveLink };
|
|
67
|
+
//#endregion
|
|
@@ -8,7 +8,7 @@ import { Payload, Where } from "payload";
|
|
|
8
8
|
* read it structurally, so it is an open record rather than the union of every
|
|
9
9
|
* generated collection type.
|
|
10
10
|
*/
|
|
11
|
-
type PayloadDocument = {
|
|
11
|
+
export type PayloadDocument = {
|
|
12
12
|
id: string | number;
|
|
13
13
|
} & Record<string, unknown>;
|
|
14
14
|
/**
|
|
@@ -27,18 +27,18 @@ type PayloadDocument = {
|
|
|
27
27
|
* anything the compiler can see. It states what the mapping can produce, not
|
|
28
28
|
* what it will.
|
|
29
29
|
*/
|
|
30
|
-
type ResolvedPath<TDocs extends Record<string, object> = Record<string, PayloadDocument>> = { [K in keyof TDocs & string]: {
|
|
30
|
+
export type ResolvedPath<TDocs extends Record<string, object> = Record<string, PayloadDocument>> = { [K in keyof TDocs & string]: {
|
|
31
31
|
match: PayloadCollectionMatch;
|
|
32
32
|
collection: K;
|
|
33
33
|
document: TDocs[K];
|
|
34
34
|
}; }[keyof TDocs & string];
|
|
35
35
|
/** Extra conditions to AND into the lookup. */
|
|
36
|
-
type ResolvePathWhere = Where | ((args: {
|
|
36
|
+
export type ResolvePathWhere = Where | ((args: {
|
|
37
37
|
collection: string;
|
|
38
38
|
match: PayloadCollectionMatch;
|
|
39
39
|
draft: boolean;
|
|
40
40
|
}) => Where | undefined);
|
|
41
|
-
interface ResolvePathToDocumentArgs {
|
|
41
|
+
export interface ResolvePathToDocumentArgs {
|
|
42
42
|
payload: Payload;
|
|
43
43
|
mappings: PayloadCollectionMappingResolved[];
|
|
44
44
|
path: string;
|
|
@@ -64,6 +64,5 @@ interface ResolvePathToDocumentArgs {
|
|
|
64
64
|
*
|
|
65
65
|
* @param args The Payload instance, mappings, path and locale.
|
|
66
66
|
*/
|
|
67
|
-
declare const resolvePathToDocument: <TDocs extends Record<string, object> = Record<string, PayloadDocument>>(args: ResolvePathToDocumentArgs) => Promise<ResolvedPath<TDocs> | null>;
|
|
68
|
-
//#endregion
|
|
69
|
-
export { PayloadDocument, ResolvePathToDocumentArgs, ResolvePathWhere, ResolvedPath, resolvePathToDocument };
|
|
67
|
+
export declare const resolvePathToDocument: <TDocs extends Record<string, object> = Record<string, PayloadDocument>>(args: ResolvePathToDocumentArgs) => Promise<ResolvedPath<TDocs> | null>;
|
|
68
|
+
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PayloadCollectionMappingResolved } from "../pattern/types.mjs";
|
|
2
2
|
import { Payload, SanitizedCollectionConfig } from "payload";
|
|
3
3
|
//#region src/runtime/resolve-relationship-slug.d.ts
|
|
4
|
-
interface ResolveRelationshipSlugArgs {
|
|
4
|
+
export interface ResolveRelationshipSlugArgs {
|
|
5
5
|
payload: Payload;
|
|
6
6
|
/** The collection the pattern parameter belongs to. */
|
|
7
7
|
config: SanitizedCollectionConfig;
|
|
@@ -27,6 +27,5 @@ interface ResolveRelationshipSlugArgs {
|
|
|
27
27
|
*
|
|
28
28
|
* @param args The Payload instance, the parameter and its raw value.
|
|
29
29
|
*/
|
|
30
|
-
declare const resolveRelationshipSlug: (args: ResolveRelationshipSlugArgs) => Promise<string | null>;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { ResolveRelationshipSlugArgs, resolveRelationshipSlug };
|
|
30
|
+
export declare const resolveRelationshipSlug: (args: ResolveRelationshipSlugArgs) => Promise<string | null>;
|
|
31
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@abinnovision/payloadcms-wayfinder",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.6",
|
|
5
5
|
"description": "Editor-authored URL routing for Payload: collection-to-path patterns, document-to-href building, path-to-document resolution and a routing-aware link field.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"payload",
|
|
@@ -78,27 +78,27 @@
|
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@abinnovision/eslint-config-base": "^3.4.2",
|
|
81
|
-
"@abinnovision/payloadcms-montage": "1.0.
|
|
81
|
+
"@abinnovision/payloadcms-montage": "1.0.1-beta.1",
|
|
82
82
|
"@abinnovision/prettier-config": "^2.2.0",
|
|
83
83
|
"@arethetypeswrong/core": "^0.18.5",
|
|
84
84
|
"@lexical/react": "0.41.0",
|
|
85
|
-
"@payloadcms/db-sqlite": "3.
|
|
86
|
-
"@payloadcms/richtext-lexical": "3.
|
|
87
|
-
"@payloadcms/ui": "3.
|
|
88
|
-
"@swc/core": "^1.16.
|
|
89
|
-
"@types/node": "^26.
|
|
90
|
-
"@types/react": "^19.
|
|
91
|
-
"@vitest/coverage-v8": "^
|
|
92
|
-
"eslint": "^10.
|
|
85
|
+
"@payloadcms/db-sqlite": "3.89.0",
|
|
86
|
+
"@payloadcms/richtext-lexical": "3.89.0",
|
|
87
|
+
"@payloadcms/ui": "3.89.0",
|
|
88
|
+
"@swc/core": "^1.16.2",
|
|
89
|
+
"@types/node": "^26.5.1",
|
|
90
|
+
"@types/react": "^19.3.0",
|
|
91
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
92
|
+
"eslint": "^10.10.0",
|
|
93
93
|
"lexical": "0.41.0",
|
|
94
|
-
"payload": "3.
|
|
94
|
+
"payload": "3.89.0",
|
|
95
95
|
"prettier": "^3.9.5",
|
|
96
96
|
"publint": "^0.3.24",
|
|
97
|
-
"react": "^19.
|
|
98
|
-
"tsdown": "^0.
|
|
97
|
+
"react": "^19.3.0",
|
|
98
|
+
"tsdown": "^0.23.0",
|
|
99
99
|
"typescript": "^6.0.3",
|
|
100
|
-
"unplugin-swc": "^1.
|
|
101
|
-
"vitest": "^
|
|
100
|
+
"unplugin-swc": "^1.6.0",
|
|
101
|
+
"vitest": "^5.0.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"@abinnovision/payloadcms-montage": ">=1.0.0-beta.1",
|