@01.software/sdk 0.28.0 → 0.30.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/README.md +273 -73
- package/dist/analytics/react.cjs +4 -1
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.js +4 -1
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs +4 -1
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +4 -1
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +1476 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +28 -0
- package/dist/client.d.ts +28 -0
- package/dist/client.js +1453 -0
- package/dist/client.js.map +1 -0
- package/dist/collection-client-B9d9kr1d.d.ts +218 -0
- package/dist/collection-client-QPbwimkU.d.cts +218 -0
- package/dist/{const-mdQQtIOz.d.ts → const-B75IFDRi.d.ts} +2 -4
- package/dist/{const-Cz9Ki_I7.d.cts → const-VZuk2tWc.d.cts} +2 -4
- package/dist/index-B2WbhEgT.d.cts +106 -0
- package/dist/index-B2WbhEgT.d.ts +106 -0
- package/dist/index.cjs +1291 -1501
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -115
- package/dist/index.d.ts +11 -115
- package/dist/index.js +1292 -1520
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs +91 -0
- package/dist/metadata.cjs.map +1 -0
- package/dist/metadata.d.cts +58 -0
- package/dist/metadata.d.ts +58 -0
- package/dist/metadata.js +68 -0
- package/dist/metadata.js.map +1 -0
- package/dist/{payload-types-BrSYb-sh.d.cts → payload-types-DPjO_IbQ.d.cts} +17 -6
- package/dist/{payload-types-BrSYb-sh.d.ts → payload-types-DPjO_IbQ.d.ts} +17 -6
- package/dist/query.cjs +1791 -0
- package/dist/query.cjs.map +1 -0
- package/dist/query.d.cts +244 -0
- package/dist/query.d.ts +244 -0
- package/dist/query.js +1786 -0
- package/dist/query.js.map +1 -0
- package/dist/realtime.cjs +4 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js +4 -1
- package/dist/realtime.js.map +1 -1
- package/dist/{server-BINWywT8.d.cts → server-CrsPyqEc.d.cts} +14 -31
- package/dist/{server-BINWywT8.d.ts → server-CrsPyqEc.d.ts} +14 -31
- package/dist/server.cjs +300 -844
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +112 -7
- package/dist/server.d.ts +112 -7
- package/dist/server.js +300 -862
- package/dist/server.js.map +1 -1
- package/dist/{types-BLUb4cYq.d.ts → types-1fBLrYU7.d.ts} +1 -1
- package/dist/{types-CW4PaIL7.d.cts → types-BwT0eeaz.d.cts} +1 -1
- package/dist/types-Dlb2mwpX.d.cts +1249 -0
- package/dist/types-DuSKPiY5.d.ts +1249 -0
- package/dist/ui/canvas/server.cjs +7 -6
- package/dist/ui/canvas/server.cjs.map +1 -1
- package/dist/ui/canvas/server.d.cts +1 -3
- package/dist/ui/canvas/server.d.ts +1 -3
- package/dist/ui/canvas/server.js +7 -6
- package/dist/ui/canvas/server.js.map +1 -1
- package/dist/ui/canvas.cjs +11 -10
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.d.cts +29 -6
- package/dist/ui/canvas.d.ts +29 -6
- package/dist/ui/canvas.js +11 -10
- package/dist/ui/canvas.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +82 -13
- package/dist/server-C2Q9R-Lu.d.ts +0 -1662
- package/dist/server-D369bCVJ.d.cts +0 -1662
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/core/metadata/index.ts
|
|
21
|
+
var metadata_exports = {};
|
|
22
|
+
__export(metadata_exports, {
|
|
23
|
+
extractSeo: () => extractSeo,
|
|
24
|
+
generateMetadata: () => generateMetadata
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(metadata_exports);
|
|
27
|
+
|
|
28
|
+
// src/utils/types.ts
|
|
29
|
+
var resolveRelation = (ref) => {
|
|
30
|
+
if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
|
|
31
|
+
return null;
|
|
32
|
+
return ref;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/core/metadata/index.ts
|
|
36
|
+
function extractSeo(doc) {
|
|
37
|
+
const seo = doc.seo ?? {};
|
|
38
|
+
const og = seo.openGraph ?? {};
|
|
39
|
+
return {
|
|
40
|
+
title: seo.title ?? doc.title ?? null,
|
|
41
|
+
description: seo.description ?? null,
|
|
42
|
+
noIndex: seo.noIndex ?? null,
|
|
43
|
+
canonical: seo.canonical ?? null,
|
|
44
|
+
openGraph: {
|
|
45
|
+
title: og.title ?? null,
|
|
46
|
+
description: og.description ?? null,
|
|
47
|
+
image: og.image ?? null
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function generateMetadata(input, options) {
|
|
52
|
+
const title = input.title ?? void 0;
|
|
53
|
+
const description = input.description ?? void 0;
|
|
54
|
+
const ogTitle = input.openGraph?.title ?? title;
|
|
55
|
+
const ogDescription = input.openGraph?.description ?? description;
|
|
56
|
+
const image = resolveMetaImage(input.openGraph?.image);
|
|
57
|
+
return {
|
|
58
|
+
title,
|
|
59
|
+
description,
|
|
60
|
+
...input.noIndex && { robots: { index: false, follow: false } },
|
|
61
|
+
...input.canonical && { alternates: { canonical: input.canonical } },
|
|
62
|
+
openGraph: {
|
|
63
|
+
...ogTitle && { title: ogTitle },
|
|
64
|
+
...ogDescription && { description: ogDescription },
|
|
65
|
+
...options?.siteName && { siteName: options.siteName },
|
|
66
|
+
...image && { images: [image] }
|
|
67
|
+
},
|
|
68
|
+
twitter: {
|
|
69
|
+
card: image ? "summary_large_image" : "summary",
|
|
70
|
+
...ogTitle && { title: ogTitle },
|
|
71
|
+
...ogDescription && { description: ogDescription },
|
|
72
|
+
...image && { images: [image.url] }
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function resolveMetaImage(ref) {
|
|
77
|
+
const image = resolveRelation(ref);
|
|
78
|
+
if (!image) return null;
|
|
79
|
+
const sized = image.sizes?.["1536"];
|
|
80
|
+
const url = sized?.url || image.url;
|
|
81
|
+
if (!url) return null;
|
|
82
|
+
const width = sized?.url ? sized.width : image.width;
|
|
83
|
+
const height = sized?.url ? sized.height : image.height;
|
|
84
|
+
return {
|
|
85
|
+
url,
|
|
86
|
+
...width && { width },
|
|
87
|
+
...height && { height },
|
|
88
|
+
...image.alt && { alt: image.alt }
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=metadata.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/metadata/index.ts","../src/utils/types.ts"],"sourcesContent":["import { resolveRelation } from '../../utils/types'\n\nexport interface MetadataImage {\n url: string\n width?: number\n height?: number\n alt?: string\n}\n\nexport interface Metadata {\n title?: string\n description?: string\n robots?: {\n index?: boolean\n follow?: boolean\n }\n alternates?: {\n canonical?: string\n }\n openGraph?: {\n title?: string\n description?: string\n siteName?: string\n images?: MetadataImage[]\n }\n twitter?: {\n card?: 'summary' | 'summary_large_image'\n title?: string\n description?: string\n images?: string[]\n }\n}\n\nexport interface ImageLike {\n url?: string | null\n width?: number | null\n height?: number | null\n alt?: string | null\n sizes?: Record<\n string,\n | { url?: string | null; width?: number | null; height?: number | null }\n | undefined\n >\n}\n\nexport interface SeoInput {\n title?: string | null\n description?: string | null\n noIndex?: boolean | null\n canonical?: string | null\n openGraph?: {\n title?: string | null\n description?: string | null\n image?: ImageLike | string | null\n } | null\n}\n\nexport interface GenerateMetadataOptions {\n siteName?: string\n}\n\nexport function extractSeo(doc: Record<string, unknown>): SeoInput {\n const seo = (doc.seo ?? {}) as Record<string, unknown>\n const og = (seo.openGraph ?? {}) as Record<string, unknown>\n\n return {\n title: (seo.title as string) ?? (doc.title as string) ?? null,\n description: (seo.description as string) ?? null,\n noIndex: (seo.noIndex as boolean) ?? null,\n canonical: (seo.canonical as string) ?? null,\n openGraph: {\n title: (og.title as string) ?? null,\n description: (og.description as string) ?? null,\n image: (og.image as ImageLike | string | null) ?? null,\n },\n }\n}\n\nexport function generateMetadata(\n input: SeoInput,\n options?: GenerateMetadataOptions,\n): Metadata {\n const title = input.title ?? undefined\n const description = input.description ?? undefined\n\n const ogTitle = input.openGraph?.title ?? title\n const ogDescription = input.openGraph?.description ?? description\n const image = resolveMetaImage(input.openGraph?.image)\n\n return {\n title,\n description,\n ...(input.noIndex && { robots: { index: false, follow: false } }),\n ...(input.canonical && { alternates: { canonical: input.canonical } }),\n openGraph: {\n ...(ogTitle && { title: ogTitle }),\n ...(ogDescription && { description: ogDescription }),\n ...(options?.siteName && { siteName: options.siteName }),\n ...(image && { images: [image] }),\n },\n twitter: {\n card: image ? 'summary_large_image' : 'summary',\n ...(ogTitle && { title: ogTitle }),\n ...(ogDescription && { description: ogDescription }),\n ...(image && { images: [image.url] }),\n },\n }\n}\n\nfunction resolveMetaImage(\n ref: ImageLike | string | null | undefined,\n): MetadataImage | null {\n const image = resolveRelation<ImageLike>(ref)\n if (!image) return null\n\n // Prefer sizes['1536'] (closest to OG 1200px standard), fallback to original url\n const sized = image.sizes?.['1536']\n const url = sized?.url || image.url\n if (!url) return null\n\n const width = sized?.url ? sized.width : image.width\n const height = sized?.url ? sized.height : image.height\n\n return {\n url,\n ...(width && { width }),\n ...(height && { height }),\n ...(image.alt && { alt: image.alt }),\n }\n}\n","/**\n * Resolves a Payload CMS relation field value.\n * When depth is 0, relation fields return just the ID (string or number).\n * When depth > 0, they return the full document object (T).\n * This utility normalizes both cases to T | null.\n *\n * @param ref - The relation field value (T, string, number, null, or undefined)\n * @returns The resolved document object, or null if not populated\n */\nexport const resolveRelation = <T>(\n ref: T | string | number | null | undefined,\n): T | null => {\n if (\n typeof ref === 'string' ||\n typeof ref === 'number' ||\n ref === null ||\n ref === undefined\n )\n return null\n return ref\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,IAAM,kBAAkB,CAC7B,QACa;AACb,MACE,OAAO,QAAQ,YACf,OAAO,QAAQ,YACf,QAAQ,QACR,QAAQ;AAER,WAAO;AACT,SAAO;AACT;;;ADyCO,SAAS,WAAW,KAAwC;AACjE,QAAM,MAAO,IAAI,OAAO,CAAC;AACzB,QAAM,KAAM,IAAI,aAAa,CAAC;AAE9B,SAAO;AAAA,IACL,OAAQ,IAAI,SAAqB,IAAI,SAAoB;AAAA,IACzD,aAAc,IAAI,eAA0B;AAAA,IAC5C,SAAU,IAAI,WAAuB;AAAA,IACrC,WAAY,IAAI,aAAwB;AAAA,IACxC,WAAW;AAAA,MACT,OAAQ,GAAG,S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AM,SAAS,MAAM;AAEjD,SAAO;AAAA,IACL;AAAA,IACA,GAAI,SAAS,EAAE,MAAM;AAAA,IACrB,GAAI,UAAU,EAAE,OAAO;AAAA,IACvB,GAAI,MAAM,OAAO,EAAE,KAAK,MAAM,IAAI;AAAA,EACpC;AACF;","names":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface MetadataImage {
|
|
2
|
+
url: string;
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
alt?: string;
|
|
6
|
+
}
|
|
7
|
+
interface Metadata {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
robots?: {
|
|
11
|
+
index?: boolean;
|
|
12
|
+
follow?: boolean;
|
|
13
|
+
};
|
|
14
|
+
alternates?: {
|
|
15
|
+
canonical?: string;
|
|
16
|
+
};
|
|
17
|
+
openGraph?: {
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
siteName?: string;
|
|
21
|
+
images?: MetadataImage[];
|
|
22
|
+
};
|
|
23
|
+
twitter?: {
|
|
24
|
+
card?: 'summary' | 'summary_large_image';
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
images?: string[];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface ImageLike {
|
|
31
|
+
url?: string | null;
|
|
32
|
+
width?: number | null;
|
|
33
|
+
height?: number | null;
|
|
34
|
+
alt?: string | null;
|
|
35
|
+
sizes?: Record<string, {
|
|
36
|
+
url?: string | null;
|
|
37
|
+
width?: number | null;
|
|
38
|
+
height?: number | null;
|
|
39
|
+
} | undefined>;
|
|
40
|
+
}
|
|
41
|
+
interface SeoInput {
|
|
42
|
+
title?: string | null;
|
|
43
|
+
description?: string | null;
|
|
44
|
+
noIndex?: boolean | null;
|
|
45
|
+
canonical?: string | null;
|
|
46
|
+
openGraph?: {
|
|
47
|
+
title?: string | null;
|
|
48
|
+
description?: string | null;
|
|
49
|
+
image?: ImageLike | string | null;
|
|
50
|
+
} | null;
|
|
51
|
+
}
|
|
52
|
+
interface GenerateMetadataOptions {
|
|
53
|
+
siteName?: string;
|
|
54
|
+
}
|
|
55
|
+
declare function extractSeo(doc: Record<string, unknown>): SeoInput;
|
|
56
|
+
declare function generateMetadata(input: SeoInput, options?: GenerateMetadataOptions): Metadata;
|
|
57
|
+
|
|
58
|
+
export { type GenerateMetadataOptions, type ImageLike, type Metadata, type MetadataImage, type SeoInput, extractSeo, generateMetadata };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface MetadataImage {
|
|
2
|
+
url: string;
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
alt?: string;
|
|
6
|
+
}
|
|
7
|
+
interface Metadata {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
robots?: {
|
|
11
|
+
index?: boolean;
|
|
12
|
+
follow?: boolean;
|
|
13
|
+
};
|
|
14
|
+
alternates?: {
|
|
15
|
+
canonical?: string;
|
|
16
|
+
};
|
|
17
|
+
openGraph?: {
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
siteName?: string;
|
|
21
|
+
images?: MetadataImage[];
|
|
22
|
+
};
|
|
23
|
+
twitter?: {
|
|
24
|
+
card?: 'summary' | 'summary_large_image';
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
images?: string[];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface ImageLike {
|
|
31
|
+
url?: string | null;
|
|
32
|
+
width?: number | null;
|
|
33
|
+
height?: number | null;
|
|
34
|
+
alt?: string | null;
|
|
35
|
+
sizes?: Record<string, {
|
|
36
|
+
url?: string | null;
|
|
37
|
+
width?: number | null;
|
|
38
|
+
height?: number | null;
|
|
39
|
+
} | undefined>;
|
|
40
|
+
}
|
|
41
|
+
interface SeoInput {
|
|
42
|
+
title?: string | null;
|
|
43
|
+
description?: string | null;
|
|
44
|
+
noIndex?: boolean | null;
|
|
45
|
+
canonical?: string | null;
|
|
46
|
+
openGraph?: {
|
|
47
|
+
title?: string | null;
|
|
48
|
+
description?: string | null;
|
|
49
|
+
image?: ImageLike | string | null;
|
|
50
|
+
} | null;
|
|
51
|
+
}
|
|
52
|
+
interface GenerateMetadataOptions {
|
|
53
|
+
siteName?: string;
|
|
54
|
+
}
|
|
55
|
+
declare function extractSeo(doc: Record<string, unknown>): SeoInput;
|
|
56
|
+
declare function generateMetadata(input: SeoInput, options?: GenerateMetadataOptions): Metadata;
|
|
57
|
+
|
|
58
|
+
export { type GenerateMetadataOptions, type ImageLike, type Metadata, type MetadataImage, type SeoInput, extractSeo, generateMetadata };
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/utils/types.ts
|
|
2
|
+
var resolveRelation = (ref) => {
|
|
3
|
+
if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
|
|
4
|
+
return null;
|
|
5
|
+
return ref;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// src/core/metadata/index.ts
|
|
9
|
+
function extractSeo(doc) {
|
|
10
|
+
const seo = doc.seo ?? {};
|
|
11
|
+
const og = seo.openGraph ?? {};
|
|
12
|
+
return {
|
|
13
|
+
title: seo.title ?? doc.title ?? null,
|
|
14
|
+
description: seo.description ?? null,
|
|
15
|
+
noIndex: seo.noIndex ?? null,
|
|
16
|
+
canonical: seo.canonical ?? null,
|
|
17
|
+
openGraph: {
|
|
18
|
+
title: og.title ?? null,
|
|
19
|
+
description: og.description ?? null,
|
|
20
|
+
image: og.image ?? null
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function generateMetadata(input, options) {
|
|
25
|
+
const title = input.title ?? void 0;
|
|
26
|
+
const description = input.description ?? void 0;
|
|
27
|
+
const ogTitle = input.openGraph?.title ?? title;
|
|
28
|
+
const ogDescription = input.openGraph?.description ?? description;
|
|
29
|
+
const image = resolveMetaImage(input.openGraph?.image);
|
|
30
|
+
return {
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
...input.noIndex && { robots: { index: false, follow: false } },
|
|
34
|
+
...input.canonical && { alternates: { canonical: input.canonical } },
|
|
35
|
+
openGraph: {
|
|
36
|
+
...ogTitle && { title: ogTitle },
|
|
37
|
+
...ogDescription && { description: ogDescription },
|
|
38
|
+
...options?.siteName && { siteName: options.siteName },
|
|
39
|
+
...image && { images: [image] }
|
|
40
|
+
},
|
|
41
|
+
twitter: {
|
|
42
|
+
card: image ? "summary_large_image" : "summary",
|
|
43
|
+
...ogTitle && { title: ogTitle },
|
|
44
|
+
...ogDescription && { description: ogDescription },
|
|
45
|
+
...image && { images: [image.url] }
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function resolveMetaImage(ref) {
|
|
50
|
+
const image = resolveRelation(ref);
|
|
51
|
+
if (!image) return null;
|
|
52
|
+
const sized = image.sizes?.["1536"];
|
|
53
|
+
const url = sized?.url || image.url;
|
|
54
|
+
if (!url) return null;
|
|
55
|
+
const width = sized?.url ? sized.width : image.width;
|
|
56
|
+
const height = sized?.url ? sized.height : image.height;
|
|
57
|
+
return {
|
|
58
|
+
url,
|
|
59
|
+
...width && { width },
|
|
60
|
+
...height && { height },
|
|
61
|
+
...image.alt && { alt: image.alt }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
extractSeo,
|
|
66
|
+
generateMetadata
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/types.ts","../src/core/metadata/index.ts"],"sourcesContent":["/**\n * Resolves a Payload CMS relation field value.\n * When depth is 0, relation fields return just the ID (string or number).\n * When depth > 0, they return the full document object (T).\n * This utility normalizes both cases to T | null.\n *\n * @param ref - The relation field value (T, string, number, null, or undefined)\n * @returns The resolved document object, or null if not populated\n */\nexport const resolveRelation = <T>(\n ref: T | string | number | null | undefined,\n): T | null => {\n if (\n typeof ref === 'string' ||\n typeof ref === 'number' ||\n ref === null ||\n ref === undefined\n )\n return null\n return ref\n}\n","import { resolveRelation } from '../../utils/types'\n\nexport interface MetadataImage {\n url: string\n width?: number\n height?: number\n alt?: string\n}\n\nexport interface Metadata {\n title?: string\n description?: string\n robots?: {\n index?: boolean\n follow?: boolean\n }\n alternates?: {\n canonical?: string\n }\n openGraph?: {\n title?: string\n description?: string\n siteName?: string\n images?: MetadataImage[]\n }\n twitter?: {\n card?: 'summary' | 'summary_large_image'\n title?: string\n description?: string\n images?: string[]\n }\n}\n\nexport interface ImageLike {\n url?: string | null\n width?: number | null\n height?: number | null\n alt?: string | null\n sizes?: Record<\n string,\n | { url?: string | null; width?: number | null; height?: number | null }\n | undefined\n >\n}\n\nexport interface SeoInput {\n title?: string | null\n description?: string | null\n noIndex?: boolean | null\n canonical?: string | null\n openGraph?: {\n title?: string | null\n description?: string | null\n image?: ImageLike | string | null\n } | null\n}\n\nexport interface GenerateMetadataOptions {\n siteName?: string\n}\n\nexport function extractSeo(doc: Record<string, unknown>): SeoInput {\n const seo = (doc.seo ?? {}) as Record<string, unknown>\n const og = (seo.openGraph ?? {}) as Record<string, unknown>\n\n return {\n title: (seo.title as string) ?? (doc.title as string) ?? null,\n description: (seo.description as string) ?? null,\n noIndex: (seo.noIndex as boolean) ?? null,\n canonical: (seo.canonical as string) ?? null,\n openGraph: {\n title: (og.title as string) ?? null,\n description: (og.description as string) ?? null,\n image: (og.image as ImageLike | string | null) ?? null,\n },\n }\n}\n\nexport function generateMetadata(\n input: SeoInput,\n options?: GenerateMetadataOptions,\n): Metadata {\n const title = input.title ?? undefined\n const description = input.description ?? undefined\n\n const ogTitle = input.openGraph?.title ?? title\n const ogDescription = input.openGraph?.description ?? description\n const image = resolveMetaImage(input.openGraph?.image)\n\n return {\n title,\n description,\n ...(input.noIndex && { robots: { index: false, follow: false } }),\n ...(input.canonical && { alternates: { canonical: input.canonical } }),\n openGraph: {\n ...(ogTitle && { title: ogTitle }),\n ...(ogDescription && { description: ogDescription }),\n ...(options?.siteName && { siteName: options.siteName }),\n ...(image && { images: [image] }),\n },\n twitter: {\n card: image ? 'summary_large_image' : 'summary',\n ...(ogTitle && { title: ogTitle }),\n ...(ogDescription && { description: ogDescription }),\n ...(image && { images: [image.url] }),\n },\n }\n}\n\nfunction resolveMetaImage(\n ref: ImageLike | string | null | undefined,\n): MetadataImage | null {\n const image = resolveRelation<ImageLike>(ref)\n if (!image) return null\n\n // Prefer sizes['1536'] (closest to OG 1200px standard), fallback to original url\n const sized = image.sizes?.['1536']\n const url = sized?.url || image.url\n if (!url) return null\n\n const width = sized?.url ? sized.width : image.width\n const height = sized?.url ? sized.height : image.height\n\n return {\n url,\n ...(width && { width }),\n ...(height && { height }),\n ...(image.alt && { alt: image.alt }),\n }\n}\n"],"mappings":";AASO,IAAM,kBAAkB,CAC7B,QACa;AACb,MACE,OAAO,QAAQ,YACf,OAAO,QAAQ,YACf,QAAQ,QACR,QAAQ;AAER,WAAO;AACT,SAAO;AACT;;;ACyCO,SAAS,WAAW,KAAwC;AACjE,QAAM,MAAO,IAAI,OAAO,CAAC;AACzB,QAAM,KAAM,IAAI,aAAa,CAAC;AAE9B,SAAO;AAAA,IACL,OAAQ,IAAI,SAAqB,IAAI,SAAoB;AAAA,IACzD,aAAc,IAAI,eAA0B;AAAA,IAC5C,SAAU,IAAI,WAAuB;AAAA,IACrC,WAAY,IAAI,aAAwB;AAAA,IACxC,WAAW;AAAA,MACT,OAAQ,GAAG,SAAoB;AAAA,MAC/B,aAAc,GAAG,eAA0B;AAAA,MAC3C,OAAQ,GAAG,SAAuC;AAAA,IACpD;AAAA,EACF;AACF;AAEO,SAAS,iBACd,OACA,SACU;AACV,QAAM,QAAQ,MAAM,SAAS;AAC7B,QAAM,cAAc,MAAM,eAAe;AAEzC,QAAM,UAAU,MAAM,WAAW,SAAS;AAC1C,QAAM,gBAAgB,MAAM,W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
2147
2147
|
option: string | ProductOption;
|
|
2148
2148
|
/**
|
|
2149
|
-
*
|
|
2149
|
+
* Editable option-value display label for Admin and storefront copy. Changing it after creation does not change the public slug. (e.g. Black, S)
|
|
2150
2150
|
*/
|
|
2151
2151
|
value: string;
|
|
2152
2152
|
/**
|
|
@@ -2157,7 +2157,10 @@ interface ProductOptionValue {
|
|
|
2157
2157
|
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2158
2158
|
*/
|
|
2159
2159
|
generateSlug?: boolean | null;
|
|
2160
|
-
|
|
2160
|
+
/**
|
|
2161
|
+
* Compatibility URL token generated from the option-value label on create. It is fixed after creation.
|
|
2162
|
+
*/
|
|
2163
|
+
slug: string;
|
|
2161
2164
|
thumbnail?: (string | null) | Image;
|
|
2162
2165
|
images?: (string | Image)[] | null;
|
|
2163
2166
|
metadata?: {
|
|
@@ -2181,9 +2184,17 @@ interface ProductOption {
|
|
|
2181
2184
|
*/
|
|
2182
2185
|
product: string | Product;
|
|
2183
2186
|
/**
|
|
2184
|
-
*
|
|
2187
|
+
* Editable option display name for Admin and storefront copy. Changing it after creation does not change the public slug. (e.g. Color, Size)
|
|
2185
2188
|
*/
|
|
2186
2189
|
title: string;
|
|
2190
|
+
/**
|
|
2191
|
+
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2192
|
+
*/
|
|
2193
|
+
generateSlug?: boolean | null;
|
|
2194
|
+
/**
|
|
2195
|
+
* Compatibility URL token generated from the option name on create. It is fixed after creation.
|
|
2196
|
+
*/
|
|
2197
|
+
slug: string;
|
|
2187
2198
|
values?: {
|
|
2188
2199
|
docs?: (string | ProductOptionValue)[];
|
|
2189
2200
|
hasNextPage?: boolean;
|
|
@@ -3589,7 +3600,6 @@ interface Article {
|
|
|
3589
3600
|
* Canonical URL for search engines. Leave empty to use this article URL.
|
|
3590
3601
|
*/
|
|
3591
3602
|
canonicalUrl?: string | null;
|
|
3592
|
-
visibility?: ('public' | 'members' | 'paid') | null;
|
|
3593
3603
|
/**
|
|
3594
3604
|
* Scheduled publish metadata. No automatic publishing job runs from this field.
|
|
3595
3605
|
*/
|
|
@@ -6571,6 +6581,8 @@ interface ProductOptionsSelect<T extends boolean = true> {
|
|
|
6571
6581
|
tenant?: T;
|
|
6572
6582
|
product?: T;
|
|
6573
6583
|
title?: T;
|
|
6584
|
+
generateSlug?: T;
|
|
6585
|
+
slug?: T;
|
|
6574
6586
|
values?: T;
|
|
6575
6587
|
updatedAt?: T;
|
|
6576
6588
|
createdAt?: T;
|
|
@@ -7389,7 +7401,6 @@ interface ArticlesSelect<T extends boolean = true> {
|
|
|
7389
7401
|
readingMinutes?: T;
|
|
7390
7402
|
excerpt?: T;
|
|
7391
7403
|
canonicalUrl?: T;
|
|
7392
|
-
visibility?: T;
|
|
7393
7404
|
scheduledAt?: T;
|
|
7394
7405
|
featuredUntil?: T;
|
|
7395
7406
|
relatedArticles?: T;
|
|
@@ -8782,4 +8793,4 @@ declare module 'payload' {
|
|
|
8782
8793
|
}
|
|
8783
8794
|
}
|
|
8784
8795
|
|
|
8785
|
-
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V, CustomerProfileList as a, Comment as b, Config as c,
|
|
8796
|
+
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V, CustomerProfileList as a, Comment as b, Config as c, Product as d, ArticleAuthor as e, ArticleCategory as f, ArticleTag as g, Cart as h, CartItem as i, PostCategory as j, ProductVariant as k, OrderItem as l, Transaction as m, Fulfillment as n, Return as o };
|
|
@@ -2146,7 +2146,7 @@ interface ProductOptionValue {
|
|
|
2146
2146
|
*/
|
|
2147
2147
|
option: string | ProductOption;
|
|
2148
2148
|
/**
|
|
2149
|
-
*
|
|
2149
|
+
* Editable option-value display label for Admin and storefront copy. Changing it after creation does not change the public slug. (e.g. Black, S)
|
|
2150
2150
|
*/
|
|
2151
2151
|
value: string;
|
|
2152
2152
|
/**
|
|
@@ -2157,7 +2157,10 @@ interface ProductOptionValue {
|
|
|
2157
2157
|
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2158
2158
|
*/
|
|
2159
2159
|
generateSlug?: boolean | null;
|
|
2160
|
-
|
|
2160
|
+
/**
|
|
2161
|
+
* Compatibility URL token generated from the option-value label on create. It is fixed after creation.
|
|
2162
|
+
*/
|
|
2163
|
+
slug: string;
|
|
2161
2164
|
thumbnail?: (string | null) | Image;
|
|
2162
2165
|
images?: (string | Image)[] | null;
|
|
2163
2166
|
metadata?: {
|
|
@@ -2181,9 +2184,17 @@ interface ProductOption {
|
|
|
2181
2184
|
*/
|
|
2182
2185
|
product: string | Product;
|
|
2183
2186
|
/**
|
|
2184
|
-
*
|
|
2187
|
+
* Editable option display name for Admin and storefront copy. Changing it after creation does not change the public slug. (e.g. Color, Size)
|
|
2185
2188
|
*/
|
|
2186
2189
|
title: string;
|
|
2190
|
+
/**
|
|
2191
|
+
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2192
|
+
*/
|
|
2193
|
+
generateSlug?: boolean | null;
|
|
2194
|
+
/**
|
|
2195
|
+
* Compatibility URL token generated from the option name on create. It is fixed after creation.
|
|
2196
|
+
*/
|
|
2197
|
+
slug: string;
|
|
2187
2198
|
values?: {
|
|
2188
2199
|
docs?: (string | ProductOptionValue)[];
|
|
2189
2200
|
hasNextPage?: boolean;
|
|
@@ -3589,7 +3600,6 @@ interface Article {
|
|
|
3589
3600
|
* Canonical URL for search engines. Leave empty to use this article URL.
|
|
3590
3601
|
*/
|
|
3591
3602
|
canonicalUrl?: string | null;
|
|
3592
|
-
visibility?: ('public' | 'members' | 'paid') | null;
|
|
3593
3603
|
/**
|
|
3594
3604
|
* Scheduled publish metadata. No automatic publishing job runs from this field.
|
|
3595
3605
|
*/
|
|
@@ -6571,6 +6581,8 @@ interface ProductOptionsSelect<T extends boolean = true> {
|
|
|
6571
6581
|
tenant?: T;
|
|
6572
6582
|
product?: T;
|
|
6573
6583
|
title?: T;
|
|
6584
|
+
generateSlug?: T;
|
|
6585
|
+
slug?: T;
|
|
6574
6586
|
values?: T;
|
|
6575
6587
|
updatedAt?: T;
|
|
6576
6588
|
createdAt?: T;
|
|
@@ -7389,7 +7401,6 @@ interface ArticlesSelect<T extends boolean = true> {
|
|
|
7389
7401
|
readingMinutes?: T;
|
|
7390
7402
|
excerpt?: T;
|
|
7391
7403
|
canonicalUrl?: T;
|
|
7392
|
-
visibility?: T;
|
|
7393
7404
|
scheduledAt?: T;
|
|
7394
7405
|
featuredUntil?: T;
|
|
7395
7406
|
relatedArticles?: T;
|
|
@@ -8782,4 +8793,4 @@ declare module 'payload' {
|
|
|
8782
8793
|
}
|
|
8783
8794
|
}
|
|
8784
8795
|
|
|
8785
|
-
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V, CustomerProfileList as a, Comment as b, Config as c,
|
|
8796
|
+
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V, CustomerProfileList as a, Comment as b, Config as c, Product as d, ArticleAuthor as e, ArticleCategory as f, ArticleTag as g, Cart as h, CartItem as i, PostCategory as j, ProductVariant as k, OrderItem as l, Transaction as m, Fulfillment as n, Return as o };
|