@01.software/sdk 0.1.6 → 0.1.8

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.
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+
34
+ // src/metadata.ts
35
+ var metadata_exports = {};
36
+ __export(metadata_exports, {
37
+ generateMetadata: () => generateMetadata
38
+ });
39
+ module.exports = __toCommonJS(metadata_exports);
40
+
41
+ // src/utils/types.ts
42
+ var resolveRelation = (ref) => {
43
+ if (typeof ref === "number" || ref === null || ref === void 0) return null;
44
+ return ref;
45
+ };
46
+
47
+ // src/core/metadata/index.ts
48
+ function generateMetadata(doc, options) {
49
+ var _a, _b, _c, _d;
50
+ const meta = doc == null ? void 0 : doc.meta;
51
+ const title = (_b = (_a = meta == null ? void 0 : meta.title) != null ? _a : options == null ? void 0 : options.title) != null ? _b : void 0;
52
+ const description = (_d = (_c = meta == null ? void 0 : meta.description) != null ? _c : options == null ? void 0 : options.description) != null ? _d : void 0;
53
+ const image = resolveMetaImage(meta == null ? void 0 : meta.image);
54
+ return {
55
+ title,
56
+ description,
57
+ openGraph: __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, title && { title }), description && { description }), (options == null ? void 0 : options.siteName) && { siteName: options.siteName }), image && { images: [image] }),
58
+ twitter: __spreadValues(__spreadValues(__spreadValues({
59
+ card: image ? "summary_large_image" : "summary"
60
+ }, title && { title }), description && { description }), image && { images: [image.url] })
61
+ };
62
+ }
63
+ function resolveMetaImage(ref) {
64
+ const media = resolveRelation(ref);
65
+ if (!(media == null ? void 0 : media.url)) return null;
66
+ return __spreadValues(__spreadValues(__spreadValues({
67
+ url: media.url
68
+ }, media.width && { width: media.width }), media.height && { height: media.height }), media.alt && { alt: media.alt });
69
+ }
70
+ //# sourceMappingURL=metadata.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/metadata.ts","../src/utils/types.ts","../src/core/metadata/index.ts"],"sourcesContent":["export { generateMetadata } from './core/metadata'\nexport type { GenerateMetadataOptions } from './core/metadata'\n","/**\n * Resolves a Payload CMS relation field value.\n * When depth is 0, relation fields return just the ID (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, number, null, or undefined)\n * @returns The resolved document object, or null if not populated\n */\nexport const resolveRelation = <T>(ref: T | number | null | undefined): T | null => {\n if (typeof ref === 'number' || ref === null || ref === undefined) return null\n return ref\n}\n\n/** @deprecated Use `resolveRelation` instead */\nexport const objectFor = resolveRelation\n","import type { Metadata } from 'next'\nimport type { Media } from '../../payload-types'\nimport { resolveRelation } from '../../utils/types'\n\ninterface MetaField {\n title?: string | null\n description?: string | null\n image?: (number | null) | Media\n}\n\nexport interface GenerateMetadataOptions {\n title?: string\n description?: string\n siteName?: string\n}\n\nexport function generateMetadata(\n doc: { meta?: MetaField | null },\n options?: GenerateMetadataOptions,\n): Metadata {\n const meta = doc?.meta\n const title = meta?.title ?? options?.title ?? undefined\n const description = meta?.description ?? options?.description ?? undefined\n const image = resolveMetaImage(meta?.image)\n\n return {\n title,\n description,\n openGraph: {\n ...(title && { title }),\n ...(description && { description }),\n ...(options?.siteName && { siteName: options.siteName }),\n ...(image && { images: [image] }),\n },\n twitter: {\n card: image ? 'summary_large_image' : 'summary',\n ...(title && { title }),\n ...(description && { description }),\n ...(image && { images: [image.url] }),\n },\n }\n}\n\nfunction resolveMetaImage(\n ref: (number | null) | Media | undefined,\n): { url: string; width?: number; height?: number; alt?: string } | null {\n const media = resolveRelation<Media>(ref)\n if (!media?.url) return null\n return {\n url: media.url,\n ...(media.width && { width: media.width }),\n ...(media.height && { height: media.height }),\n ...(media.alt && { alt: media.alt }),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,IAAM,kBAAkB,CAAI,QAAiD;AAClF,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AACzE,SAAO;AACT;;;ACIO,SAAS,iBACd,KACA,SACU;AAnBZ;AAoBE,QAAM,OAAO,2BAAK;AAClB,QAAM,SAAQ,wCAAM,UAAN,YAAe,mCAAS,UAAxB,YAAiC;AAC/C,QAAM,eAAc,wCAAM,gBAAN,YAAqB,mCAAS,gBAA9B,YAA6C;AACjE,QAAM,QAAQ,iBAAiB,6BAAM,KAAK;AAE1C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW,gEACL,SAAS,EAAE,MAAM,IACjB,eAAe,EAAE,YAAY,KAC7B,mCAAS,aAAY,EAAE,UAAU,QAAQ,SAAS,IAClD,SAAS,EAAE,QAAQ,CAAC,KAAK,EAAE;AAAA,IAEjC,SAAS;AAAA,MACP,MAAM,QAAQ,wBAAwB;AAAA,OAClC,SAAS,EAAE,MAAM,IACjB,eAAe,EAAE,YAAY,IAC7B,SAAS,EAAE,QAAQ,CAAC,MAAM,GAAG,EAAE;AAAA,EAEvC;AACF;AAEA,SAAS,iBACP,KACuE;AACvE,QAAM,QAAQ,gBAAuB,GAAG;AACxC,MAAI,EAAC,+BAAO,KAAK,QAAO;AACxB,SAAO;AAAA,IACL,KAAK,MAAM;AAAA,KACP,MAAM,SAAS,EAAE,OAAO,MAAM,MAAM,IACpC,MAAM,UAAU,EAAE,QAAQ,MAAM,OAAO,IACvC,MAAM,OAAO,EAAE,KAAK,MAAM,IAAI;AAEtC;","names":[]}
@@ -0,0 +1,18 @@
1
+ import { Metadata } from 'next';
2
+ import { M as Media } from './payload-types-DcOQUD4x.cjs';
3
+
4
+ interface MetaField {
5
+ title?: string | null;
6
+ description?: string | null;
7
+ image?: (number | null) | Media;
8
+ }
9
+ interface GenerateMetadataOptions {
10
+ title?: string;
11
+ description?: string;
12
+ siteName?: string;
13
+ }
14
+ declare function generateMetadata(doc: {
15
+ meta?: MetaField | null;
16
+ }, options?: GenerateMetadataOptions): Metadata;
17
+
18
+ export { type GenerateMetadataOptions, generateMetadata };
@@ -0,0 +1,18 @@
1
+ import { Metadata } from 'next';
2
+ import { M as Media } from './payload-types-DcOQUD4x.js';
3
+
4
+ interface MetaField {
5
+ title?: string | null;
6
+ description?: string | null;
7
+ image?: (number | null) | Media;
8
+ }
9
+ interface GenerateMetadataOptions {
10
+ title?: string;
11
+ description?: string;
12
+ siteName?: string;
13
+ }
14
+ declare function generateMetadata(doc: {
15
+ meta?: MetaField | null;
16
+ }, options?: GenerateMetadataOptions): Metadata;
17
+
18
+ export { type GenerateMetadataOptions, generateMetadata };
@@ -0,0 +1,50 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+
18
+ // src/utils/types.ts
19
+ var resolveRelation = (ref) => {
20
+ if (typeof ref === "number" || ref === null || ref === void 0) return null;
21
+ return ref;
22
+ };
23
+
24
+ // src/core/metadata/index.ts
25
+ function generateMetadata(doc, options) {
26
+ var _a, _b, _c, _d;
27
+ const meta = doc == null ? void 0 : doc.meta;
28
+ const title = (_b = (_a = meta == null ? void 0 : meta.title) != null ? _a : options == null ? void 0 : options.title) != null ? _b : void 0;
29
+ const description = (_d = (_c = meta == null ? void 0 : meta.description) != null ? _c : options == null ? void 0 : options.description) != null ? _d : void 0;
30
+ const image = resolveMetaImage(meta == null ? void 0 : meta.image);
31
+ return {
32
+ title,
33
+ description,
34
+ openGraph: __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, title && { title }), description && { description }), (options == null ? void 0 : options.siteName) && { siteName: options.siteName }), image && { images: [image] }),
35
+ twitter: __spreadValues(__spreadValues(__spreadValues({
36
+ card: image ? "summary_large_image" : "summary"
37
+ }, title && { title }), description && { description }), image && { images: [image.url] })
38
+ };
39
+ }
40
+ function resolveMetaImage(ref) {
41
+ const media = resolveRelation(ref);
42
+ if (!(media == null ? void 0 : media.url)) return null;
43
+ return __spreadValues(__spreadValues(__spreadValues({
44
+ url: media.url
45
+ }, media.width && { width: media.width }), media.height && { height: media.height }), media.alt && { alt: media.alt });
46
+ }
47
+ export {
48
+ generateMetadata
49
+ };
50
+ //# 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 (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, number, null, or undefined)\n * @returns The resolved document object, or null if not populated\n */\nexport const resolveRelation = <T>(ref: T | number | null | undefined): T | null => {\n if (typeof ref === 'number' || ref === null || ref === undefined) return null\n return ref\n}\n\n/** @deprecated Use `resolveRelation` instead */\nexport const objectFor = resolveRelation\n","import type { Metadata } from 'next'\nimport type { Media } from '../../payload-types'\nimport { resolveRelation } from '../../utils/types'\n\ninterface MetaField {\n title?: string | null\n description?: string | null\n image?: (number | null) | Media\n}\n\nexport interface GenerateMetadataOptions {\n title?: string\n description?: string\n siteName?: string\n}\n\nexport function generateMetadata(\n doc: { meta?: MetaField | null },\n options?: GenerateMetadataOptions,\n): Metadata {\n const meta = doc?.meta\n const title = meta?.title ?? options?.title ?? undefined\n const description = meta?.description ?? options?.description ?? undefined\n const image = resolveMetaImage(meta?.image)\n\n return {\n title,\n description,\n openGraph: {\n ...(title && { title }),\n ...(description && { description }),\n ...(options?.siteName && { siteName: options.siteName }),\n ...(image && { images: [image] }),\n },\n twitter: {\n card: image ? 'summary_large_image' : 'summary',\n ...(title && { title }),\n ...(description && { description }),\n ...(image && { images: [image.url] }),\n },\n }\n}\n\nfunction resolveMetaImage(\n ref: (number | null) | Media | undefined,\n): { url: string; width?: number; height?: number; alt?: string } | null {\n const media = resolveRelation<Media>(ref)\n if (!media?.url) return null\n return {\n url: media.url,\n ...(media.width && { width: media.width }),\n ...(media.height && { height: media.height }),\n ...(media.alt && { alt: media.alt }),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASO,IAAM,kBAAkB,CAAI,QAAiD;AAClF,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AACzE,SAAO;AACT;;;ACIO,SAAS,iBACd,KACA,SACU;AAnBZ;AAoBE,QAAM,OAAO,2BAAK;AAClB,QAAM,SAAQ,wCAAM,UAAN,YAAe,mCAAS,UAAxB,YAAiC;AAC/C,QAAM,eAAc,wCAAM,gBAAN,YAAqB,mCAAS,gBAA9B,YAA6C;AACjE,QAAM,QAAQ,iBAAiB,6BAAM,KAAK;AAE1C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW,gEACL,SAAS,EAAE,MAAM,IACjB,eAAe,EAAE,YAAY,KAC7B,mCAAS,aAAY,EAAE,UAAU,QAAQ,SAAS,IAClD,SAAS,EAAE,QAAQ,CAAC,KAAK,EAAE;AAAA,IAEjC,SAAS;AAAA,MACP,MAAM,QAAQ,wBAAwB;AAAA,OAClC,SAAS,EAAE,MAAM,IACjB,eAAe,EAAE,YAAY,IAC7B,SAAS,EAAE,QAAQ,CAAC,MAAM,GAAG,EAAE;AAAA,EAEvC;AACF;AAEA,SAAS,iBACP,KACuE;AACvE,QAAM,QAAQ,gBAAuB,GAAG;AACxC,MAAI,EAAC,+BAAO,KAAK,QAAO;AACxB,SAAO;AAAA,IACL,KAAK,MAAM;AAAA,KACP,MAAM,SAAS,EAAE,OAAO,MAAM,MAAM,IACpC,MAAM,UAAU,EAAE,QAAQ,MAAM,OAAO,IACvC,MAAM,OAAO,EAAE,KAAK,MAAM,IAAI;AAEtC;","names":[]}