payload-intl 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_common/index.d.ts +17 -0
- package/dist/_common/index.d.ts.map +1 -0
- package/dist/_common/index.js +27 -0
- package/dist/_common/index.js.map +1 -0
- package/dist/_common/procedure.d.ts +34 -0
- package/dist/_common/procedure.d.ts.map +1 -0
- package/dist/_common/procedure.js +110 -0
- package/dist/_common/procedure.js.map +1 -0
- package/dist/_common/urls.d.ts +11 -0
- package/dist/_common/urls.d.ts.map +1 -0
- package/dist/_common/urls.js +23 -0
- package/dist/_common/urls.js.map +1 -0
- package/dist/_common/utils.d.ts +5 -0
- package/dist/_common/utils.d.ts.map +1 -0
- package/dist/_common/utils.js +42 -0
- package/dist/_common/utils.js.map +1 -0
- package/dist/components/MessagesLink.js +1 -1
- package/dist/components/MessagesView.js +1 -1
- package/dist/const.d.ts +2 -2
- package/dist/const.js +1 -1
- package/dist/entities.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CollectionConfig, CollectionSlug, TypeWithID } from 'payload';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
export declare const entityIdSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
4
|
+
export type EntityID = TypeWithID['id'] & z.infer<typeof entityIdSchema>;
|
|
5
|
+
export declare const isPopulated: <T extends TypeWithID>(relationship: T | EntityID) => relationship is T;
|
|
6
|
+
export declare function assertPopulated<T extends TypeWithID | null>(docsOrIds: (T | EntityID)[], errorMessage?: (id: EntityID) => string): T[];
|
|
7
|
+
export declare function assertPopulated<T extends TypeWithID | null>(docOrId: T | EntityID, errorMessage?: (id: EntityID) => string): T;
|
|
8
|
+
export declare const createCollectionConfigFactory: <T extends Record<string, unknown>>(factory: Omit<CollectionConfig, "slug"> | ((options: T & {
|
|
9
|
+
slug: CollectionSlug;
|
|
10
|
+
}) => Omit<CollectionConfig, "slug">)) => (options: T & {
|
|
11
|
+
slug: CollectionSlug;
|
|
12
|
+
}) => CollectionConfig;
|
|
13
|
+
export declare const resolveForeignKey: (entity: TypeWithID["id"] | TypeWithID) => string | number;
|
|
14
|
+
export { defineProcedure, type Procedure, type ProcedureBuilder, } from './procedure';
|
|
15
|
+
export { getAdminURL, getApiURL, getServerURL } from './urls';
|
|
16
|
+
export { findFields, uncaughtSwitchCase } from './utils';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/_common/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,CAAC,MAAM,KAAK,CAAC;AAIpB,eAAO,MAAM,cAAc,iDAAoC,CAAC;AAChE,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAIzE,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,gBAChC,CAAC,GAAG,QAAQ,KACzB,YAAY,IAAI,CAAqC,CAAC;AAEzD,wBAAgB,eAAe,CAAC,CAAC,SAAS,UAAU,GAAG,IAAI,EACzD,SAAS,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,EAC3B,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,GACtC,CAAC,EAAE,CAAC;AACP,wBAAgB,eAAe,CAAC,CAAC,SAAS,UAAU,GAAG,IAAI,EACzD,OAAO,EAAE,CAAC,GAAG,QAAQ,EACrB,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,GACtC,CAAC,CAAC;AAeL,eAAO,MAAM,6BAA6B,GACvC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAE5B,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAC9B,CAAC,CACC,OAAO,EAAE,CAAC,GAAG;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,KAClC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,eAEhC,CAAC,GAAG;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,KAAG,gBAGvC,CAAC;AAEL,eAAO,MAAM,iBAAiB,WAAY,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,oBACtB,CAAC;AAElD,OAAO,EACL,eAAe,EACf,KAAK,SAAS,EACd,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
// MARK: Types
|
|
3
|
+
export const entityIdSchema = z.union([
|
|
4
|
+
z.number(),
|
|
5
|
+
z.string()
|
|
6
|
+
]);
|
|
7
|
+
// MARK: Type Guards
|
|
8
|
+
export const isPopulated = (relationship)=>typeof relationship === 'object';
|
|
9
|
+
export function assertPopulated(value, errorMessage = (id)=>`Doc is not populated: [${id}]`) {
|
|
10
|
+
if (value === null) return value;
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
return value.map((item)=>assertPopulated(item, errorMessage));
|
|
13
|
+
}
|
|
14
|
+
if (isPopulated(value)) return value;
|
|
15
|
+
throw new Error(errorMessage(value));
|
|
16
|
+
}
|
|
17
|
+
// MARK: Utilities
|
|
18
|
+
export const createCollectionConfigFactory = (factory)=>(options)=>({
|
|
19
|
+
slug: options.slug,
|
|
20
|
+
...typeof factory === 'function' ? factory(options) : factory
|
|
21
|
+
});
|
|
22
|
+
export const resolveForeignKey = (entity)=>typeof entity === 'object' ? entity.id : entity;
|
|
23
|
+
export { defineProcedure } from './procedure';
|
|
24
|
+
export { getAdminURL, getApiURL, getServerURL } from './urls';
|
|
25
|
+
export { findFields, uncaughtSwitchCase } from './utils';
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_common/index.ts"],"sourcesContent":["import type { CollectionConfig, CollectionSlug, TypeWithID } from 'payload';\nimport z from 'zod';\n\n// MARK: Types\n\nexport const entityIdSchema = z.union([z.number(), z.string()]);\nexport type EntityID = TypeWithID['id'] & z.infer<typeof entityIdSchema>;\n\n// MARK: Type Guards\n\nexport const isPopulated = <T extends TypeWithID>(\n relationship: T | EntityID,\n): relationship is T => typeof relationship === 'object';\n\nexport function assertPopulated<T extends TypeWithID | null>(\n docsOrIds: (T | EntityID)[],\n errorMessage?: (id: EntityID) => string,\n): T[];\nexport function assertPopulated<T extends TypeWithID | null>(\n docOrId: T | EntityID,\n errorMessage?: (id: EntityID) => string,\n): T;\nexport function assertPopulated<T extends TypeWithID | null>(\n value: T | EntityID | (T | EntityID)[],\n errorMessage = (id: EntityID) => `Doc is not populated: [${id}]`,\n): T | T[] {\n if (value === null) return value;\n if (Array.isArray(value)) {\n return value.map((item) => assertPopulated(item, errorMessage));\n }\n if (isPopulated(value)) return value;\n throw new Error(errorMessage(value as EntityID));\n}\n\n// MARK: Utilities\n\nexport const createCollectionConfigFactory =\n <T extends Record<string, unknown>>(\n factory:\n | Omit<CollectionConfig, 'slug'>\n | ((\n options: T & { slug: CollectionSlug },\n ) => Omit<CollectionConfig, 'slug'>),\n ) =>\n (options: T & { slug: CollectionSlug }): CollectionConfig => ({\n slug: options.slug,\n ...(typeof factory === 'function' ? factory(options) : factory),\n });\n\nexport const resolveForeignKey = (entity: TypeWithID['id'] | TypeWithID) =>\n typeof entity === 'object' ? entity.id : entity;\n\nexport {\n defineProcedure,\n type Procedure,\n type ProcedureBuilder,\n} from './procedure';\nexport { getAdminURL, getApiURL, getServerURL } from './urls';\nexport { findFields, uncaughtSwitchCase } from './utils';\n"],"names":["z","entityIdSchema","union","number","string","isPopulated","relationship","assertPopulated","value","errorMessage","id","Array","isArray","map","item","Error","createCollectionConfigFactory","factory","options","slug","resolveForeignKey","entity","defineProcedure","getAdminURL","getApiURL","getServerURL","findFields","uncaughtSwitchCase"],"mappings":"AACA,OAAOA,OAAO,MAAM;AAEpB,cAAc;AAEd,OAAO,MAAMC,iBAAiBD,EAAEE,KAAK,CAAC;IAACF,EAAEG,MAAM;IAAIH,EAAEI,MAAM;CAAG,EAAE;AAGhE,oBAAoB;AAEpB,OAAO,MAAMC,cAAc,CACzBC,eACsB,OAAOA,iBAAiB,SAAS;AAUzD,OAAO,SAASC,gBACdC,KAAsC,EACtCC,eAAe,CAACC,KAAiB,CAAC,uBAAuB,EAAEA,GAAG,CAAC,CAAC;IAEhE,IAAIF,UAAU,MAAM,OAAOA;IAC3B,IAAIG,MAAMC,OAAO,CAACJ,QAAQ;QACxB,OAAOA,MAAMK,GAAG,CAAC,CAACC,OAASP,gBAAgBO,MAAML;IACnD;IACA,IAAIJ,YAAYG,QAAQ,OAAOA;IAC/B,MAAM,IAAIO,MAAMN,aAAaD;AAC/B;AAEA,kBAAkB;AAElB,OAAO,MAAMQ,gCACX,CACEC,UAMF,CAACC,UAA6D,CAAA;YAC5DC,MAAMD,QAAQC,IAAI;YAClB,GAAI,OAAOF,YAAY,aAAaA,QAAQC,WAAWD,OAAO;QAChE,CAAA,EAAG;AAEL,OAAO,MAAMG,oBAAoB,CAACC,SAChC,OAAOA,WAAW,WAAWA,OAAOX,EAAE,GAAGW,OAAO;AAElD,SACEC,eAAe,QAGV,cAAc;AACrB,SAASC,WAAW,EAAEC,SAAS,EAAEC,YAAY,QAAQ,SAAS;AAC9D,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,UAAU"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Endpoint, PayloadRequest } from 'payload';
|
|
2
|
+
type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
3
|
+
/** Any Zod-like schema with safeParse and inferred output */
|
|
4
|
+
interface ZodLike<TOutput = unknown> {
|
|
5
|
+
safeParse(data: unknown): {
|
|
6
|
+
success: true;
|
|
7
|
+
data: TOutput;
|
|
8
|
+
} | {
|
|
9
|
+
success: false;
|
|
10
|
+
error: unknown;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type InferOutput<T> = T extends ZodLike<infer O> ? O : never;
|
|
14
|
+
interface ProcedureConfig<TSchema extends ZodLike | undefined = undefined> {
|
|
15
|
+
path: `/${string}`;
|
|
16
|
+
method: Method;
|
|
17
|
+
input?: TSchema;
|
|
18
|
+
}
|
|
19
|
+
export interface Procedure<TInput, TOutput> {
|
|
20
|
+
path: `/${string}`;
|
|
21
|
+
method: Method;
|
|
22
|
+
endpoint(handler: (req: PayloadRequest, ...args: TInput extends void ? [] : [input: TInput]) => Promise<unknown | Response>): Endpoint;
|
|
23
|
+
call(apiUrl: string, ...args: TInput extends void ? [] : [input: TInput]): Promise<TOutput>;
|
|
24
|
+
}
|
|
25
|
+
export interface ProcedureBuilder<TInput> {
|
|
26
|
+
path: string;
|
|
27
|
+
method: Method;
|
|
28
|
+
returns<TOutput>(): Procedure<TInput, TOutput>;
|
|
29
|
+
endpoint(handler: (req: PayloadRequest, ...args: TInput extends void ? [] : [input: TInput]) => Promise<unknown | Response>): Endpoint;
|
|
30
|
+
call(apiUrl: string, ...args: TInput extends void ? [] : [input: TInput]): Promise<unknown>;
|
|
31
|
+
}
|
|
32
|
+
export declare function defineProcedure<TSchema extends ZodLike | undefined = undefined>(config: ProcedureConfig<TSchema>): ProcedureBuilder<TSchema extends ZodLike ? InferOutput<TSchema> : void>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=procedure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/_common/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,KAAK,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE1D,6DAA6D;AAC7D,UAAU,OAAO,CAAC,OAAO,GAAG,OAAO;IACjC,SAAS,CACP,IAAI,EAAE,OAAO,GACZ;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1E;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE7D,UAAU,eAAe,CAAC,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS;IACvE,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,SAAS,CAAC,MAAM,EAAE,OAAO;IACxC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CACN,OAAO,EAAE,CACP,GAAG,EAAE,cAAc,EACnB,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAChD,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,GAC/B,QAAQ,CAAC;IACZ,IAAI,CACF,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB,CAAC,MAAM;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,QAAQ,CACN,OAAO,EAAE,CACP,GAAG,EAAE,cAAc,EACnB,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAChD,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,GAC/B,QAAQ,CAAC;IACZ,IAAI,CACF,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AA2GD,wBAAgB,eAAe,CAC7B,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAE/C,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,GAC/B,gBAAgB,CAAC,OAAO,SAAS,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAazE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
function wrapOutput(output) {
|
|
2
|
+
if (output instanceof Response) return output;
|
|
3
|
+
return Response.json(output);
|
|
4
|
+
}
|
|
5
|
+
function createProcedure(config, inputSchema) {
|
|
6
|
+
return {
|
|
7
|
+
path: config.path,
|
|
8
|
+
method: config.method,
|
|
9
|
+
endpoint (handler) {
|
|
10
|
+
return {
|
|
11
|
+
path: config.path,
|
|
12
|
+
method: config.method,
|
|
13
|
+
handler: async (req)=>{
|
|
14
|
+
if (inputSchema) {
|
|
15
|
+
if (config.method === 'get') {
|
|
16
|
+
const routeParams = req.routeParams ?? {};
|
|
17
|
+
const searchParams = req.searchParams ? Object.fromEntries(req.searchParams.entries()) : {};
|
|
18
|
+
const merged = {
|
|
19
|
+
...searchParams,
|
|
20
|
+
...routeParams
|
|
21
|
+
};
|
|
22
|
+
const result = inputSchema.safeParse(merged);
|
|
23
|
+
if (!result.success) {
|
|
24
|
+
return Response.json({
|
|
25
|
+
error: result.error
|
|
26
|
+
}, {
|
|
27
|
+
status: 400
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// biome-ignore lint/complexity/noBannedTypes: ugly type cast
|
|
31
|
+
const output = await handler(req, result.data);
|
|
32
|
+
return wrapOutput(output);
|
|
33
|
+
}
|
|
34
|
+
const { addDataAndFileToRequest } = await import(/* webpackIgnore: true */ 'payload');
|
|
35
|
+
await addDataAndFileToRequest(req);
|
|
36
|
+
const result = inputSchema.safeParse(req.data);
|
|
37
|
+
if (!result.success) {
|
|
38
|
+
return Response.json({
|
|
39
|
+
error: result.error
|
|
40
|
+
}, {
|
|
41
|
+
status: 400
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// biome-ignore lint/complexity/noBannedTypes: ugly type cast
|
|
45
|
+
const output = await handler(req, result.data);
|
|
46
|
+
return wrapOutput(output);
|
|
47
|
+
}
|
|
48
|
+
// biome-ignore lint/complexity/noBannedTypes: ugly type cast
|
|
49
|
+
const output = await handler(req);
|
|
50
|
+
return wrapOutput(output);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
call (apiUrl, ...args) {
|
|
55
|
+
const input = args[0];
|
|
56
|
+
if (config.method === 'get') {
|
|
57
|
+
let resolvedPath = config.path;
|
|
58
|
+
const queryParams = {};
|
|
59
|
+
if (input) {
|
|
60
|
+
for (const [key, value] of Object.entries(input)){
|
|
61
|
+
if (resolvedPath.includes(`:${key}`)) {
|
|
62
|
+
resolvedPath = resolvedPath.replace(`:${key}`, encodeURIComponent(String(value)));
|
|
63
|
+
} else {
|
|
64
|
+
queryParams[key] = String(value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const queryString = new URLSearchParams(queryParams).toString();
|
|
69
|
+
const url = `${apiUrl}${resolvedPath}${queryString ? `?${queryString}` : ''}`;
|
|
70
|
+
return fetch(url, {
|
|
71
|
+
method: 'GET',
|
|
72
|
+
credentials: 'include'
|
|
73
|
+
}).then(async (response)=>{
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
|
|
76
|
+
}
|
|
77
|
+
return response.json();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const url = `${apiUrl}${config.path}`;
|
|
81
|
+
return fetch(url, {
|
|
82
|
+
method: config.method.toUpperCase(),
|
|
83
|
+
credentials: 'include',
|
|
84
|
+
headers: {
|
|
85
|
+
'Content-Type': 'application/json'
|
|
86
|
+
},
|
|
87
|
+
body: input ? JSON.stringify(input) : undefined
|
|
88
|
+
}).then(async (response)=>{
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
|
|
91
|
+
}
|
|
92
|
+
return response.json();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function defineProcedure(config) {
|
|
98
|
+
const proc = createProcedure(config, config.input);
|
|
99
|
+
return {
|
|
100
|
+
path: config.path,
|
|
101
|
+
method: config.method,
|
|
102
|
+
returns () {
|
|
103
|
+
return createProcedure(config, config.input);
|
|
104
|
+
},
|
|
105
|
+
endpoint: proc.endpoint,
|
|
106
|
+
call: proc.call
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=procedure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_common/procedure.ts"],"sourcesContent":["import type { Endpoint, PayloadRequest } from 'payload';\n\ntype Method = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n/** Any Zod-like schema with safeParse and inferred output */\ninterface ZodLike<TOutput = unknown> {\n safeParse(\n data: unknown,\n ): { success: true; data: TOutput } | { success: false; error: unknown };\n}\n\ntype InferOutput<T> = T extends ZodLike<infer O> ? O : never;\n\ninterface ProcedureConfig<TSchema extends ZodLike | undefined = undefined> {\n path: `/${string}`;\n method: Method;\n input?: TSchema;\n}\n\nexport interface Procedure<TInput, TOutput> {\n path: `/${string}`;\n method: Method;\n endpoint(\n handler: (\n req: PayloadRequest,\n ...args: TInput extends void ? [] : [input: TInput]\n ) => Promise<unknown | Response>,\n ): Endpoint;\n call(\n apiUrl: string,\n ...args: TInput extends void ? [] : [input: TInput]\n ): Promise<TOutput>;\n}\n\nexport interface ProcedureBuilder<TInput> {\n path: string;\n method: Method;\n returns<TOutput>(): Procedure<TInput, TOutput>;\n endpoint(\n handler: (\n req: PayloadRequest,\n ...args: TInput extends void ? [] : [input: TInput]\n ) => Promise<unknown | Response>,\n ): Endpoint;\n call(\n apiUrl: string,\n ...args: TInput extends void ? [] : [input: TInput]\n ): Promise<unknown>;\n}\n\nfunction wrapOutput(output: unknown): Response {\n if (output instanceof Response) return output;\n return Response.json(output);\n}\n\nfunction createProcedure<TInput, TOutput>(\n config: ProcedureConfig<ZodLike | undefined>,\n inputSchema: ZodLike | undefined,\n): Procedure<TInput, TOutput> {\n return {\n path: config.path,\n method: config.method,\n endpoint(handler) {\n return {\n path: config.path,\n method: config.method,\n handler: async (req) => {\n if (inputSchema) {\n if (config.method === 'get') {\n const routeParams = req.routeParams ?? {};\n const searchParams = req.searchParams\n ? Object.fromEntries(req.searchParams.entries())\n : {};\n const merged = { ...searchParams, ...routeParams };\n const result = inputSchema.safeParse(merged);\n if (!result.success) {\n return Response.json({ error: result.error }, { status: 400 });\n }\n // biome-ignore lint/complexity/noBannedTypes: ugly type cast\n const output = await (handler as Function)(req, result.data);\n return wrapOutput(output);\n }\n\n const { addDataAndFileToRequest } = await import(\n /* webpackIgnore: true */ 'payload'\n );\n await addDataAndFileToRequest(req);\n const result = inputSchema.safeParse(req.data);\n if (!result.success) {\n return Response.json({ error: result.error }, { status: 400 });\n }\n // biome-ignore lint/complexity/noBannedTypes: ugly type cast\n const output = await (handler as Function)(req, result.data);\n return wrapOutput(output);\n }\n // biome-ignore lint/complexity/noBannedTypes: ugly type cast\n const output = await (handler as Function)(req);\n return wrapOutput(output);\n },\n };\n },\n call(apiUrl, ...args) {\n const input = args[0] as Record<string, unknown> | undefined;\n\n if (config.method === 'get') {\n let resolvedPath = config.path;\n const queryParams: Record<string, string> = {};\n\n if (input) {\n for (const [key, value] of Object.entries(input)) {\n if (resolvedPath.includes(`:${key}`)) {\n resolvedPath = resolvedPath.replace(\n `:${key}`,\n encodeURIComponent(String(value)),\n ) as `/${string}`;\n } else {\n queryParams[key] = String(value);\n }\n }\n }\n\n const queryString = new URLSearchParams(queryParams).toString();\n const url = `${apiUrl}${resolvedPath}${queryString ? `?${queryString}` : ''}`;\n\n return fetch(url, {\n method: 'GET',\n credentials: 'include',\n }).then(async (response) => {\n if (!response.ok) {\n throw new Error(\n `Request failed: ${response.status} ${response.statusText}`,\n );\n }\n return response.json();\n }) as Promise<TOutput>;\n }\n\n const url = `${apiUrl}${config.path}`;\n return fetch(url, {\n method: config.method.toUpperCase(),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: input ? JSON.stringify(input) : undefined,\n }).then(async (response) => {\n if (!response.ok) {\n throw new Error(\n `Request failed: ${response.status} ${response.statusText}`,\n );\n }\n return response.json();\n }) as Promise<TOutput>;\n },\n };\n}\n\nexport function defineProcedure<\n TSchema extends ZodLike | undefined = undefined,\n>(\n config: ProcedureConfig<TSchema>,\n): ProcedureBuilder<TSchema extends ZodLike ? InferOutput<TSchema> : void> {\n type TInput = TSchema extends ZodLike ? InferOutput<TSchema> : undefined;\n const proc = createProcedure<TInput, unknown>(config, config.input);\n\n return {\n path: config.path,\n method: config.method,\n returns<TOutput>(): Procedure<TInput, TOutput> {\n return createProcedure<TInput, TOutput>(config, config.input);\n },\n endpoint: proc.endpoint as unknown as ProcedureBuilder<TInput>['endpoint'],\n call: proc.call as ProcedureBuilder<TInput>['call'],\n };\n}\n"],"names":["wrapOutput","output","Response","json","createProcedure","config","inputSchema","path","method","endpoint","handler","req","routeParams","searchParams","Object","fromEntries","entries","merged","result","safeParse","success","error","status","data","addDataAndFileToRequest","call","apiUrl","args","input","resolvedPath","queryParams","key","value","includes","replace","encodeURIComponent","String","queryString","URLSearchParams","toString","url","fetch","credentials","then","response","ok","Error","statusText","toUpperCase","headers","body","JSON","stringify","undefined","defineProcedure","proc","returns"],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
export declare function getServerURL(req: PayloadRequest): string;
|
|
3
|
+
export declare function getAdminURL({ req, path, }: {
|
|
4
|
+
req: PayloadRequest;
|
|
5
|
+
path?: '' | `/${string}` | null;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function getApiURL({ req, path, }: {
|
|
8
|
+
req: PayloadRequest;
|
|
9
|
+
path?: '' | `/${string}` | null;
|
|
10
|
+
}): string;
|
|
11
|
+
//# sourceMappingURL=urls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/_common/urls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CAWxD;AAED,wBAAgB,WAAW,CAAC,EAC1B,GAAG,EACH,IAAI,GACL,EAAE;IACD,GAAG,EAAE,cAAc,CAAC;IACpB,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,CAAC;CACjC,GAAG,MAAM,CAMT;AAED,wBAAgB,SAAS,CAAC,EACxB,GAAG,EACH,IAAI,GACL,EAAE;IACD,GAAG,EAAE,cAAc,CAAC;IACpB,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,CAAC;CACjC,GAAG,MAAM,CAMT"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { formatAdminURL } from 'payload/shared';
|
|
2
|
+
export function getServerURL(req) {
|
|
3
|
+
if (!req.url) throw new Error('Could not get serverURL, since request URL is not available');
|
|
4
|
+
const { config } = req.payload;
|
|
5
|
+
if (config.serverURL) return config.serverURL;
|
|
6
|
+
return `${new URL(req.url).protocol}//${req.headers.get('host')}`;
|
|
7
|
+
}
|
|
8
|
+
export function getAdminURL({ req, path }) {
|
|
9
|
+
return formatAdminURL({
|
|
10
|
+
adminRoute: req.payload.config.routes.admin,
|
|
11
|
+
serverURL: getServerURL(req),
|
|
12
|
+
path
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function getApiURL({ req, path }) {
|
|
16
|
+
return formatAdminURL({
|
|
17
|
+
apiRoute: req.payload.config.routes.api,
|
|
18
|
+
serverURL: getServerURL(req),
|
|
19
|
+
path
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=urls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_common/urls.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload';\nimport { formatAdminURL } from 'payload/shared';\n\nexport function getServerURL(req: PayloadRequest): string {\n if (!req.url)\n throw new Error(\n 'Could not get serverURL, since request URL is not available',\n );\n\n const { config } = req.payload;\n\n if (config.serverURL) return config.serverURL;\n\n return `${new URL(req.url).protocol}//${req.headers.get('host')}`;\n}\n\nexport function getAdminURL({\n req,\n path,\n}: {\n req: PayloadRequest;\n path?: '' | `/${string}` | null;\n}): string {\n return formatAdminURL({\n adminRoute: req.payload.config.routes.admin,\n serverURL: getServerURL(req),\n path,\n });\n}\n\nexport function getApiURL({\n req,\n path,\n}: {\n req: PayloadRequest;\n path?: '' | `/${string}` | null;\n}): string {\n return formatAdminURL({\n apiRoute: req.payload.config.routes.api,\n serverURL: getServerURL(req),\n path,\n });\n}\n"],"names":["formatAdminURL","getServerURL","req","url","Error","config","payload","serverURL","URL","protocol","headers","get","getAdminURL","path","adminRoute","routes","admin","getApiURL","apiRoute","api"],"mappings":"AACA,SAASA,cAAc,QAAQ,iBAAiB;AAEhD,OAAO,SAASC,aAAaC,GAAmB;IAC9C,IAAI,CAACA,IAAIC,GAAG,EACV,MAAM,IAAIC,MACR;IAGJ,MAAM,EAAEC,MAAM,EAAE,GAAGH,IAAII,OAAO;IAE9B,IAAID,OAAOE,SAAS,EAAE,OAAOF,OAAOE,SAAS;IAE7C,OAAO,GAAG,IAAIC,IAAIN,IAAIC,GAAG,EAAEM,QAAQ,CAAC,EAAE,EAAEP,IAAIQ,OAAO,CAACC,GAAG,CAAC,SAAS;AACnE;AAEA,OAAO,SAASC,YAAY,EAC1BV,GAAG,EACHW,IAAI,EAIL;IACC,OAAOb,eAAe;QACpBc,YAAYZ,IAAII,OAAO,CAACD,MAAM,CAACU,MAAM,CAACC,KAAK;QAC3CT,WAAWN,aAAaC;QACxBW;IACF;AACF;AAEA,OAAO,SAASI,UAAU,EACxBf,GAAG,EACHW,IAAI,EAIL;IACC,OAAOb,eAAe;QACpBkB,UAAUhB,IAAII,OAAO,CAACD,MAAM,CAACU,MAAM,CAACI,GAAG;QACvCZ,WAAWN,aAAaC;QACxBW;IACF;AACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Field } from 'payload';
|
|
2
|
+
export declare const uncaughtSwitchCase: (value: never) => never;
|
|
3
|
+
export declare function findFields<T extends Field>(fields: Field[], condition: (field: Field) => field is T): T[];
|
|
4
|
+
export declare function findFields(fields: Field[], condition: (field: Field) => boolean): Field[];
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/_common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,kBAAkB,UAAW,KAAK,UAE9C,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,EACxC,MAAM,EAAE,KAAK,EAAE,EACf,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,IAAI,CAAC,GACtC,CAAC,EAAE,CAAC;AACP,wBAAgB,UAAU,CACxB,MAAM,EAAE,KAAK,EAAE,EACf,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,GACnC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const uncaughtSwitchCase = (value)=>{
|
|
2
|
+
throw new Error(`Unhandled switch case: ${value}`);
|
|
3
|
+
};
|
|
4
|
+
export function findFields(fields, condition) {
|
|
5
|
+
return fields.flatMap((field)=>{
|
|
6
|
+
if (condition(field)) {
|
|
7
|
+
return [
|
|
8
|
+
field
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
if ('fields' in field) {
|
|
12
|
+
return findFields(field.fields, condition);
|
|
13
|
+
}
|
|
14
|
+
switch(field.type){
|
|
15
|
+
case 'blocks':
|
|
16
|
+
return field.blocks.flatMap((block)=>findFields(block.fields, condition));
|
|
17
|
+
case 'tabs':
|
|
18
|
+
return field.tabs.flatMap((tab)=>findFields(tab.fields, condition));
|
|
19
|
+
case 'text':
|
|
20
|
+
case 'richText':
|
|
21
|
+
case 'number':
|
|
22
|
+
case 'checkbox':
|
|
23
|
+
case 'date':
|
|
24
|
+
case 'email':
|
|
25
|
+
case 'select':
|
|
26
|
+
case 'json':
|
|
27
|
+
case 'code':
|
|
28
|
+
case 'join':
|
|
29
|
+
case 'point':
|
|
30
|
+
case 'radio':
|
|
31
|
+
case 'textarea':
|
|
32
|
+
case 'ui':
|
|
33
|
+
case 'relationship':
|
|
34
|
+
case 'upload':
|
|
35
|
+
return [];
|
|
36
|
+
default:
|
|
37
|
+
return uncaughtSwitchCase(field);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_common/utils.ts"],"sourcesContent":["import type { Field } from 'payload';\n\nexport const uncaughtSwitchCase = (value: never) => {\n throw new Error(`Unhandled switch case: ${value}`);\n};\n\nexport function findFields<T extends Field>(\n fields: Field[],\n condition: (field: Field) => field is T,\n): T[];\nexport function findFields(\n fields: Field[],\n condition: (field: Field) => boolean,\n): Field[];\nexport function findFields(\n fields: Field[],\n condition: (field: Field) => boolean,\n): Field[] {\n return fields.flatMap((field) => {\n if (condition(field)) {\n return [field];\n }\n\n if ('fields' in field) {\n return findFields(field.fields, condition);\n }\n\n switch (field.type) {\n case 'blocks':\n return field.blocks.flatMap((block) =>\n findFields(block.fields, condition),\n );\n case 'tabs':\n return field.tabs.flatMap((tab) => findFields(tab.fields, condition));\n case 'text':\n case 'richText':\n case 'number':\n case 'checkbox':\n case 'date':\n case 'email':\n case 'select':\n case 'json':\n case 'code':\n case 'join':\n case 'point':\n case 'radio':\n case 'textarea':\n case 'ui':\n case 'relationship':\n case 'upload':\n return [];\n default:\n return uncaughtSwitchCase(field);\n }\n });\n}\n"],"names":["uncaughtSwitchCase","value","Error","findFields","fields","condition","flatMap","field","type","blocks","block","tabs","tab"],"mappings":"AAEA,OAAO,MAAMA,qBAAqB,CAACC;IACjC,MAAM,IAAIC,MAAM,CAAC,uBAAuB,EAAED,OAAO;AACnD,EAAE;AAUF,OAAO,SAASE,WACdC,MAAe,EACfC,SAAoC;IAEpC,OAAOD,OAAOE,OAAO,CAAC,CAACC;QACrB,IAAIF,UAAUE,QAAQ;YACpB,OAAO;gBAACA;aAAM;QAChB;QAEA,IAAI,YAAYA,OAAO;YACrB,OAAOJ,WAAWI,MAAMH,MAAM,EAAEC;QAClC;QAEA,OAAQE,MAAMC,IAAI;YAChB,KAAK;gBACH,OAAOD,MAAME,MAAM,CAACH,OAAO,CAAC,CAACI,QAC3BP,WAAWO,MAAMN,MAAM,EAAEC;YAE7B,KAAK;gBACH,OAAOE,MAAMI,IAAI,CAACL,OAAO,CAAC,CAACM,MAAQT,WAAWS,IAAIR,MAAM,EAAEC;YAC5D,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;gBACH,OAAO,EAAE;YACX;gBACE,OAAOL,mBAAmBO;QAC9B;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from '@payloadcms/ui';
|
|
3
|
-
import { getAdminURL } from '
|
|
3
|
+
import { getAdminURL } from '../_common/index.js';
|
|
4
4
|
import { IconWorld } from '@tabler/icons-react';
|
|
5
5
|
export async function MessagesLink({ access = ()=>true, req }) {
|
|
6
6
|
const hasAccess = await access(req);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DefaultTemplate } from '@payloadcms/next/templates';
|
|
3
3
|
import { Gutter } from '@payloadcms/ui';
|
|
4
|
-
import { getAdminURL } from '
|
|
4
|
+
import { getAdminURL } from '../_common/index.js';
|
|
5
5
|
import { RedirectType, redirect } from 'next/navigation';
|
|
6
6
|
import { sanitizeMessages } from '../utils/sanitize';
|
|
7
7
|
import { fetchMessages } from '../requests/fetchMessages';
|
package/dist/const.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Messages } from './types';
|
|
2
2
|
export declare const ENDPOINTS: {
|
|
3
|
-
getMessages: import("
|
|
3
|
+
getMessages: import("./_common/index.js").Procedure<{
|
|
4
4
|
locale: string;
|
|
5
5
|
}, Messages>;
|
|
6
|
-
setMessages: import("
|
|
6
|
+
setMessages: import("./_common/index.js").Procedure<void, {
|
|
7
7
|
success: boolean;
|
|
8
8
|
}>;
|
|
9
9
|
};
|
package/dist/const.js
CHANGED
package/dist/entities.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createCollectionConfigFactory } from '
|
|
1
|
+
import { createCollectionConfigFactory } from './_common/index.js';
|
|
2
2
|
import { getMessagesEndpoint } from './endpoints/get-messages';
|
|
3
3
|
import { setMessagesEndpoint } from './endpoints/set-messages';
|
|
4
4
|
import { createHooks } from './hooks';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload-intl",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Payload Plugin for I18N using ICU Messages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"scripts": {
|
|
48
|
-
"prebuild": "pnpm typecheck",
|
|
48
|
+
"prebuild": "rm -f src/_common 2>/dev/null; pnpm typecheck",
|
|
49
49
|
"build": "plugin-build",
|
|
50
50
|
"clean": "rm -rf dist && rm -rf node_modules",
|
|
51
51
|
"dev": "plugin-build --watch",
|