@01.software/sdk 0.2.6 → 0.2.7

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 CHANGED
@@ -37,8 +37,6 @@ import { handleWebhook, createTypedWebhookHandler } from '@01.software/sdk/webho
37
37
  // Components only - React components
38
38
  import { RichTextContent } from '@01.software/sdk/components'
39
39
 
40
- // Metadata only - SEO meta → Next.js Metadata
41
- import { generateMetadata } from '@01.software/sdk/metadata'
42
40
  ```
43
41
 
44
42
  ## Getting Started
@@ -1,5 +1,5 @@
1
1
  import { Sort, Where } from 'payload';
2
- import './payload-types-D0px2DCK.js';
2
+ import './payload-types-CRSz8jfP.js';
3
3
 
4
4
  declare class SDKError extends Error {
5
5
  readonly code: string;
@@ -1,5 +1,5 @@
1
1
  import { Sort, Where } from 'payload';
2
- import './payload-types-D0px2DCK.cjs';
2
+ import './payload-types-CRSz8jfP.cjs';
3
3
 
4
4
  declare class SDKError extends Error {
5
5
  readonly code: string;
package/dist/auth.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { J as JwtPayload, q as createApiKey, o as createServerToken, p as decodeServerToken, r as parseApiKey, v as verifyServerToken } from './auth-BICuhJxS.cjs';
1
+ export { J as JwtPayload, q as createApiKey, o as createServerToken, p as decodeServerToken, r as parseApiKey, v as verifyServerToken } from './auth-ZBsN9vPn.cjs';
2
2
  import 'payload';
3
- import './payload-types-D0px2DCK.cjs';
3
+ import './payload-types-CRSz8jfP.cjs';
package/dist/auth.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { J as JwtPayload, q as createApiKey, o as createServerToken, p as decodeServerToken, r as parseApiKey, v as verifyServerToken } from './auth-Cj3nVn_P.js';
1
+ export { J as JwtPayload, q as createApiKey, o as createServerToken, p as decodeServerToken, r as parseApiKey, v as verifyServerToken } from './auth-D-_Ju7m5.js';
2
2
  import 'payload';
3
- import './payload-types-D0px2DCK.js';
3
+ import './payload-types-CRSz8jfP.js';
@@ -2,7 +2,7 @@ import React, { CSSProperties } from 'react';
2
2
  import { SerializedLinkNode, SerializedBlockNode } from '@payloadcms/richtext-lexical';
3
3
  import { SerializedEditorState, SerializedLexicalNode } from '@payloadcms/richtext-lexical/lexical';
4
4
  import { JSXConverter } from '@payloadcms/richtext-lexical/react';
5
- import { F as Form } from './payload-types-D0px2DCK.cjs';
5
+ import { F as Form } from './payload-types-CRSz8jfP.cjs';
6
6
  import { I as ImageData } from './image-TT8lTsk5.cjs';
7
7
 
8
8
  type RichTextData = SerializedEditorState<SerializedLexicalNode>;
@@ -2,7 +2,7 @@ import React, { CSSProperties } from 'react';
2
2
  import { SerializedLinkNode, SerializedBlockNode } from '@payloadcms/richtext-lexical';
3
3
  import { SerializedEditorState, SerializedLexicalNode } from '@payloadcms/richtext-lexical/lexical';
4
4
  import { JSXConverter } from '@payloadcms/richtext-lexical/react';
5
- import { F as Form } from './payload-types-D0px2DCK.js';
5
+ import { F as Form } from './payload-types-CRSz8jfP.js';
6
6
  import { I as ImageData } from './image-TT8lTsk5.js';
7
7
 
8
8
  type RichTextData = SerializedEditorState<SerializedLexicalNode>;
package/dist/index.cjs CHANGED
@@ -708,12 +708,27 @@ var resolveRelation = (ref) => {
708
708
  var objectFor = resolveRelation;
709
709
 
710
710
  // src/core/metadata/index.ts
711
- function generateMetadata(doc, options) {
711
+ var COLLECTION_META_FIELDS = {
712
+ products: { description: "subtitle", image: "thumbnail" },
713
+ posts: { description: "excerpt", image: "thumbnail" },
714
+ documents: { description: "summary", image: "" },
715
+ playlists: { description: "description", image: "image" }
716
+ };
717
+ var DEFAULT_META_FIELDS = { description: "description", image: "thumbnail" };
718
+ function extractMetaFields(collection, doc) {
719
+ var _a, _b, _c, _d;
720
+ const mapping = (_a = COLLECTION_META_FIELDS[collection]) != null ? _a : DEFAULT_META_FIELDS;
721
+ return {
722
+ title: (_b = doc.title) != null ? _b : null,
723
+ description: mapping.description ? (_c = doc[mapping.description]) != null ? _c : null : null,
724
+ image: mapping.image ? (_d = doc[mapping.image]) != null ? _d : null : null
725
+ };
726
+ }
727
+ function generateMetadata(input, options) {
712
728
  var _a, _b, _c, _d;
713
- const meta = doc == null ? void 0 : doc.meta;
714
- const title = (_b = (_a = meta == null ? void 0 : meta.title) != null ? _a : options == null ? void 0 : options.title) != null ? _b : void 0;
715
- const description = (_d = (_c = meta == null ? void 0 : meta.description) != null ? _c : options == null ? void 0 : options.description) != null ? _d : void 0;
716
- const image = resolveMetaImage(meta == null ? void 0 : meta.image);
729
+ const title = (_b = (_a = input.title) != null ? _a : options == null ? void 0 : options.title) != null ? _b : void 0;
730
+ const description = (_d = (_c = input.description) != null ? _c : options == null ? void 0 : options.description) != null ? _d : void 0;
731
+ const image = resolveMetaImage(input.image);
717
732
  return {
718
733
  title,
719
734
  description,
@@ -724,11 +739,17 @@ function generateMetadata(doc, options) {
724
739
  };
725
740
  }
726
741
  function resolveMetaImage(ref) {
727
- const media = resolveRelation(ref);
728
- if (!(media == null ? void 0 : media.url)) return null;
742
+ var _a;
743
+ const image = resolveRelation(ref);
744
+ if (!image) return null;
745
+ const sized = (_a = image.sizes) == null ? void 0 : _a["1536"];
746
+ const url = (sized == null ? void 0 : sized.url) || image.url;
747
+ if (!url) return null;
748
+ const width = (sized == null ? void 0 : sized.url) ? sized.width : image.width;
749
+ const height = (sized == null ? void 0 : sized.url) ? sized.height : image.height;
729
750
  return __spreadValues(__spreadValues(__spreadValues({
730
- url: media.url
731
- }, media.width && { width: media.width }), media.height && { height: media.height }), media.alt && { alt: media.alt });
751
+ url
752
+ }, width && { width }), height && { height }), image.alt && { alt: image.alt });
732
753
  }
733
754
 
734
755
  // src/core/collection/query-builder.ts
@@ -813,7 +834,7 @@ var CollectionQueryBuilder = class {
813
834
  const doc = docs[0];
814
835
  if (!doc) return null;
815
836
  return generateMetadata(
816
- doc,
837
+ extractMetaFields(String(this.collection), doc),
817
838
  metadataOptions
818
839
  );
819
840
  });
@@ -827,7 +848,7 @@ var CollectionQueryBuilder = class {
827
848
  return __async(this, null, function* () {
828
849
  const doc = yield this.findById(id, { depth: 1 });
829
850
  return generateMetadata(
830
- doc,
851
+ extractMetaFields(String(this.collection), doc),
831
852
  metadataOptions
832
853
  );
833
854
  });