@01.software/sdk 0.37.0 → 0.38.0

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.
Files changed (48) hide show
  1. package/README.md +75 -53
  2. package/dist/client.cjs +67 -104
  3. package/dist/client.cjs.map +1 -1
  4. package/dist/client.d.cts +6 -6
  5. package/dist/client.d.ts +6 -6
  6. package/dist/client.js +67 -104
  7. package/dist/client.js.map +1 -1
  8. package/dist/{collection-client-zOmnxwdA.d.cts → collection-client-B0J9wMNE.d.cts} +5 -5
  9. package/dist/{collection-client-DyELGUcL.d.ts → collection-client-BroIWHY1.d.ts} +5 -5
  10. package/dist/const-6XHz_jej.d.ts +32 -0
  11. package/dist/const-B5KT72c7.d.cts +32 -0
  12. package/dist/{index-DRJs7QIh.d.cts → index-BOLQxveo.d.cts} +3 -3
  13. package/dist/{index-DTqoUZk_.d.ts → index-CSwR2HSg.d.ts} +3 -3
  14. package/dist/index.cjs +95 -123
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +9 -9
  17. package/dist/index.d.ts +9 -9
  18. package/dist/index.js +95 -123
  19. package/dist/index.js.map +1 -1
  20. package/dist/{payload-types-CREOjFNT.d.cts → payload-types-m3jjhxk9.d.cts} +418 -106
  21. package/dist/{payload-types-CREOjFNT.d.ts → payload-types-m3jjhxk9.d.ts} +418 -106
  22. package/dist/query.cjs +3 -1035
  23. package/dist/query.cjs.map +1 -1
  24. package/dist/query.d.cts +13 -13
  25. package/dist/query.d.ts +13 -13
  26. package/dist/query.js +3 -1035
  27. package/dist/query.js.map +1 -1
  28. package/dist/realtime.d.cts +2 -2
  29. package/dist/realtime.d.ts +2 -2
  30. package/dist/server.cjs +42 -21
  31. package/dist/server.cjs.map +1 -1
  32. package/dist/server.d.cts +7 -7
  33. package/dist/server.d.ts +7 -7
  34. package/dist/server.js +42 -21
  35. package/dist/server.js.map +1 -1
  36. package/dist/{types-DMvVHdb1.d.ts → types-CIGscmus.d.cts} +1455 -1208
  37. package/dist/{types-CxzWHspI.d.ts → types-Cmrd1ezc.d.ts} +1 -15
  38. package/dist/{types-BkZNhuBh.d.cts → types-D0ubzQw0.d.cts} +1 -15
  39. package/dist/{types-BWMUr3Zw.d.cts → types-D2xYdz4P.d.ts} +1455 -1208
  40. package/dist/ui/form.d.cts +1 -1
  41. package/dist/ui/form.d.ts +1 -1
  42. package/dist/ui/video.d.cts +1 -1
  43. package/dist/ui/video.d.ts +1 -1
  44. package/dist/webhook.d.cts +4 -4
  45. package/dist/webhook.d.ts +4 -4
  46. package/package.json +3 -3
  47. package/dist/const-CK_FPaIn.d.cts +0 -32
  48. package/dist/const-Dqz05oaG.d.ts +0 -32
package/dist/client.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- import { R as ReadOnlyCollectionClient } from './collection-client-zOmnxwdA.cjs';
2
- import { C as CommerceClient, a as CommunityClient, E as EventsClient, b as CustomerNamespace, c as ClientState, d as ClientConfig } from './types-BWMUr3Zw.cjs';
3
- export { A as ApiQueryOptions, e as ClientMetadata, D as DebugConfig, f as DeepPartial, g as ExtractArrayType, P as PayloadFindResponse, h as PayloadMutationResponse, R as RetryConfig, i as RootClient, i as RootClientType, j as RootCollectionClient, k as RootReadOnlyQueryBuilder, S as Sort, W as Where } from './types-BWMUr3Zw.cjs';
4
- export { C as Collection, P as PublicCollection } from './const-CK_FPaIn.cjs';
1
+ import { R as ReadOnlyCollectionClient } from './collection-client-B0J9wMNE.cjs';
2
+ import { C as CommerceClient, a as CommunityClient, E as EventsClient, b as CustomerNamespace, c as ClientState, d as ClientConfig } from './types-CIGscmus.cjs';
3
+ export { A as AddItemParams, e as ApiQueryOptions, f as ApplyDiscountParams, g as CheckoutParams, h as ClearCartParams, i as ClientMetadata, D as DebugConfig, j as DeepPartial, k as ExtractArrayType, P as PayloadFindResponse, l as PayloadMutationResponse, m as PublicCart, n as PublicCartItem, o as PublicCartReference, p as PublicMediaAsset, q as PublicMediaSize, r as PublicOrder, s as PublicOrderItem, t as PublicOrderReference, R as RemoveDiscountParams, u as RemoveItemParams, v as RetryConfig, w as RootClient, w as RootClientType, x as RootCollectionClient, y as RootReadOnlyQueryBuilder, S as Sort, U as UpdateItemParams, W as Where } from './types-CIGscmus.cjs';
4
+ import './payload-types-m3jjhxk9.cjs';
5
+ export { C as Collection, P as PublicCollection } from './const-B5KT72c7.cjs';
5
6
  import './metadata.cjs';
6
- import './types-BkZNhuBh.cjs';
7
- import './payload-types-CREOjFNT.cjs';
7
+ import './types-D0ubzQw0.cjs';
8
8
 
9
9
  declare class Client {
10
10
  commerce: CommerceClient;
package/dist/client.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { R as ReadOnlyCollectionClient } from './collection-client-DyELGUcL.js';
2
- import { C as CommerceClient, a as CommunityClient, E as EventsClient, b as CustomerNamespace, c as ClientState, d as ClientConfig } from './types-DMvVHdb1.js';
3
- export { A as ApiQueryOptions, e as ClientMetadata, D as DebugConfig, f as DeepPartial, g as ExtractArrayType, P as PayloadFindResponse, h as PayloadMutationResponse, R as RetryConfig, i as RootClient, i as RootClientType, j as RootCollectionClient, k as RootReadOnlyQueryBuilder, S as Sort, W as Where } from './types-DMvVHdb1.js';
4
- export { C as Collection, P as PublicCollection } from './const-Dqz05oaG.js';
1
+ import { R as ReadOnlyCollectionClient } from './collection-client-BroIWHY1.js';
2
+ import { C as CommerceClient, a as CommunityClient, E as EventsClient, b as CustomerNamespace, c as ClientState, d as ClientConfig } from './types-D2xYdz4P.js';
3
+ export { A as AddItemParams, e as ApiQueryOptions, f as ApplyDiscountParams, g as CheckoutParams, h as ClearCartParams, i as ClientMetadata, D as DebugConfig, j as DeepPartial, k as ExtractArrayType, P as PayloadFindResponse, l as PayloadMutationResponse, m as PublicCart, n as PublicCartItem, o as PublicCartReference, p as PublicMediaAsset, q as PublicMediaSize, r as PublicOrder, s as PublicOrderItem, t as PublicOrderReference, R as RemoveDiscountParams, u as RemoveItemParams, v as RetryConfig, w as RootClient, w as RootClientType, x as RootCollectionClient, y as RootReadOnlyQueryBuilder, S as Sort, U as UpdateItemParams, W as Where } from './types-D2xYdz4P.js';
4
+ import './payload-types-m3jjhxk9.js';
5
+ export { C as Collection, P as PublicCollection } from './const-6XHz_jej.js';
5
6
  import './metadata.js';
6
- import './types-CxzWHspI.js';
7
- import './payload-types-CREOjFNT.js';
7
+ import './types-Cmrd1ezc.js';
8
8
 
9
9
  declare class Client {
10
10
  commerce: CommerceClient;
package/dist/client.js CHANGED
@@ -744,73 +744,14 @@ var HttpClient = class {
744
744
  }
745
745
  };
746
746
 
747
- // src/utils/types.ts
748
- function resolveRelation(ref) {
749
- if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
750
- return null;
751
- return ref;
752
- }
753
-
754
- // src/core/metadata/index.ts
755
- var OPEN_GRAPH_IMAGE_SIZE = "1200";
756
- var LEGACY_OPEN_GRAPH_IMAGE_SIZE = "1536";
757
- function extractSeo(doc) {
758
- const seo = doc.seo ?? {};
759
- const og = seo.openGraph ?? {};
760
- return {
761
- title: seo.title ?? doc.title ?? null,
762
- description: seo.description ?? null,
763
- noIndex: seo.noIndex ?? null,
764
- canonical: seo.canonical ?? null,
765
- openGraph: {
766
- title: og.title ?? null,
767
- description: og.description ?? null,
768
- image: og.image ?? null
769
- }
770
- };
771
- }
772
- function generateMetadata(input, options) {
773
- const title = input.title ?? void 0;
774
- const description = input.description ?? void 0;
775
- const ogTitle = input.openGraph?.title ?? title;
776
- const ogDescription = input.openGraph?.description ?? description;
777
- const image = resolveMetaImage(input.openGraph?.image);
778
- return {
779
- title,
780
- description,
781
- ...input.noIndex && { robots: { index: false, follow: false } },
782
- ...input.canonical && { alternates: { canonical: input.canonical } },
783
- openGraph: {
784
- ...ogTitle && { title: ogTitle },
785
- ...ogDescription && { description: ogDescription },
786
- ...options?.siteName && { siteName: options.siteName },
787
- ...image && { images: [image] }
788
- },
789
- twitter: {
790
- card: image ? "summary_large_image" : "summary",
791
- ...ogTitle && { title: ogTitle },
792
- ...ogDescription && { description: ogDescription },
793
- ...image && { images: [image.url] }
794
- }
795
- };
796
- }
797
- function resolveMetaImage(ref) {
798
- const image = resolveRelation(ref);
799
- if (!image) return null;
800
- const sized = image.sizes?.[OPEN_GRAPH_IMAGE_SIZE] ?? image.sizes?.[LEGACY_OPEN_GRAPH_IMAGE_SIZE];
801
- const url = sized?.url || image.url;
802
- if (!url) return null;
803
- const width = sized?.url ? sized.width : image.width;
804
- const height = sized?.url ? sized.height : image.height;
747
+ // src/core/collection/query-builder.ts
748
+ function withDefaultPublicReadOptions(options) {
805
749
  return {
806
- url,
807
- ...width && { width },
808
- ...height && { height },
809
- ...image.alt && { alt: image.alt }
750
+ ...options,
751
+ depth: options?.depth ?? 0,
752
+ joins: options?.joins ?? false
810
753
  };
811
754
  }
812
-
813
- // src/core/collection/query-builder.ts
814
755
  var ReadOnlyCollectionQueryBuilder = class {
815
756
  constructor(api, collection) {
816
757
  this.api = api;
@@ -819,13 +760,13 @@ var ReadOnlyCollectionQueryBuilder = class {
819
760
  async find(options) {
820
761
  return this.api.requestFind(
821
762
  `/api/${String(this.collection)}`,
822
- options
763
+ withDefaultPublicReadOptions(options)
823
764
  );
824
765
  }
825
766
  async findById(id, options) {
826
767
  return this.api.requestFindById(
827
768
  `/api/${String(this.collection)}/${String(id)}`,
828
- options
769
+ withDefaultPublicReadOptions(options)
829
770
  );
830
771
  }
831
772
  async count(options) {
@@ -834,22 +775,6 @@ var ReadOnlyCollectionQueryBuilder = class {
834
775
  options
835
776
  );
836
777
  }
837
- async findMetadata(options, metadataOptions) {
838
- const { docs } = await this.find({ ...options, limit: 1, depth: 1 });
839
- const doc = docs[0];
840
- if (!doc) return null;
841
- return generateMetadata(
842
- extractSeo(doc),
843
- metadataOptions
844
- );
845
- }
846
- async findMetadataById(id, metadataOptions) {
847
- const doc = await this.findById(id, { depth: 1 });
848
- return generateMetadata(
849
- extractSeo(doc),
850
- metadataOptions
851
- );
852
- }
853
778
  };
854
779
 
855
780
  // src/core/collection/collection-client.ts
@@ -865,6 +790,21 @@ var ReadOnlyCollectionClient = class extends HttpClient {
865
790
  });
866
791
  return this.parseFindResponse(response);
867
792
  }
793
+ async requestFindEndpoint(endpoint, data) {
794
+ const response = await this.fetchWithTracking(endpoint, {
795
+ ...this.defaultOptions,
796
+ method: "POST",
797
+ body: data ? JSON.stringify(data) : void 0
798
+ });
799
+ return this.parseFindResponse(response);
800
+ }
801
+ async requestFindEndpointGet(endpoint) {
802
+ const response = await this.fetchWithTracking(endpoint, {
803
+ ...this.defaultOptions,
804
+ method: "GET"
805
+ });
806
+ return this.parseFindResponse(response);
807
+ }
868
808
  async requestFindById(endpoint, options) {
869
809
  const url = this.buildUrl(endpoint, options);
870
810
  const response = await this.fetchWithTracking(url, {
@@ -995,7 +935,8 @@ var CommunityClient = class extends CustomerScopedApi {
995
935
  const urlParams = new URLSearchParams();
996
936
  const sort = params?.sort ?? DEFAULT_POST_LIST_SORT;
997
937
  urlParams.set("sort", sort);
998
- if (params?.limit !== void 0) urlParams.set("limit", String(params.limit));
938
+ if (params?.limit !== void 0)
939
+ urlParams.set("limit", String(params.limit));
999
940
  if (params?.page !== void 0) urlParams.set("page", String(params.page));
1000
941
  if (params?.categoryId !== void 0) {
1001
942
  urlParams.set("where[categories][in]", params.categoryId);
@@ -1003,7 +944,7 @@ var CommunityClient = class extends CustomerScopedApi {
1003
944
  if (params?.tagId !== void 0) {
1004
945
  urlParams.set("where[tags][in]", params.tagId);
1005
946
  }
1006
- return `/api/posts?${urlParams.toString()}`;
947
+ return `/api/posts/public?${urlParams.toString()}`;
1007
948
  }
1008
949
  buildCommentsListQuery(params) {
1009
950
  const urlParams = new URLSearchParams();
@@ -1023,7 +964,7 @@ var CommunityClient = class extends CustomerScopedApi {
1023
964
  }
1024
965
  if (params.limit !== void 0) urlParams.set("limit", String(params.limit));
1025
966
  if (params.page !== void 0) urlParams.set("page", String(params.page));
1026
- return `/api/comments?${urlParams.toString()}`;
967
+ return `/api/comments/public?${urlParams.toString()}`;
1027
968
  }
1028
969
  async execute(endpoint, method, body) {
1029
970
  return this.request(endpoint, { method, body });
@@ -1033,7 +974,11 @@ var CommunityClient = class extends CustomerScopedApi {
1033
974
  return unwrapPayloadDoc(response);
1034
975
  }
1035
976
  createPost(params) {
1036
- return this.executeDoc("/api/posts", "POST", params);
977
+ return this.executeDoc(
978
+ "/api/posts",
979
+ "POST",
980
+ params
981
+ );
1037
982
  }
1038
983
  /**
1039
984
  * Public post feed. Server applies the same visibility contract as
@@ -1090,7 +1035,11 @@ var CommunityClient = class extends CustomerScopedApi {
1090
1035
  if (parentId !== void 0) {
1091
1036
  body.parent = parentId;
1092
1037
  }
1093
- return this.executeDoc("/api/comments", "POST", body);
1038
+ return this.executeDoc(
1039
+ "/api/comments",
1040
+ "POST",
1041
+ body
1042
+ );
1094
1043
  }
1095
1044
  /**
1096
1045
  * List comments for a post.
@@ -1159,10 +1108,14 @@ var CommunityClient = class extends CustomerScopedApi {
1159
1108
  400
1160
1109
  );
1161
1110
  }
1162
- return this.executeDoc("/api/reactions", "POST", {
1163
- post: postId,
1164
- type: reactionType
1165
- });
1111
+ return this.executeDoc(
1112
+ "/api/reactions",
1113
+ "POST",
1114
+ {
1115
+ post: postId,
1116
+ type: reactionType
1117
+ }
1118
+ );
1166
1119
  }
1167
1120
  removeReaction(params) {
1168
1121
  const { postId, type } = params;
@@ -1181,10 +1134,14 @@ var CommunityClient = class extends CustomerScopedApi {
1181
1134
  400
1182
1135
  );
1183
1136
  }
1184
- return this.executeDoc("/api/reactions", "POST", {
1185
- comment: commentId,
1186
- type: reactionType
1187
- });
1137
+ return this.executeDoc(
1138
+ "/api/reactions",
1139
+ "POST",
1140
+ {
1141
+ comment: commentId,
1142
+ type: reactionType
1143
+ }
1144
+ );
1188
1145
  }
1189
1146
  removeCommentReaction(params) {
1190
1147
  const { commentId, type } = params;
@@ -1213,9 +1170,13 @@ var CommunityClient = class extends CustomerScopedApi {
1213
1170
  }
1214
1171
  // Bookmarks
1215
1172
  addBookmark(params) {
1216
- return this.executeDoc("/api/bookmarks", "POST", {
1217
- post: params.postId
1218
- });
1173
+ return this.executeDoc(
1174
+ "/api/bookmarks",
1175
+ "POST",
1176
+ {
1177
+ post: params.postId
1178
+ }
1179
+ );
1219
1180
  }
1220
1181
  removeBookmark(params) {
1221
1182
  return this.execute(
@@ -1231,10 +1192,7 @@ var CommunityClient = class extends CustomerScopedApi {
1231
1192
  }
1232
1193
  // Profiles
1233
1194
  listProfileLists(params) {
1234
- return this.execute(
1235
- `/api/customer-profile-lists${this.buildQuery(params)}`,
1236
- "GET"
1237
- );
1195
+ return this.execute(`/api/customer-profile-lists${this.buildQuery(params)}`, "GET");
1238
1196
  }
1239
1197
  async getProfileList(params) {
1240
1198
  const query = "slug" in params ? `?where[slug][equals]=${encodeURIComponent(params.slug)}&limit=1` : `?where[id][equals]=${encodeURIComponent(params.id)}&limit=1`;
@@ -1472,7 +1430,10 @@ var CartApi = class extends CustomerScopedApi {
1472
1430
  return this.request(endpoint, { method, body });
1473
1431
  }
1474
1432
  getCart(cartId) {
1475
- return this.execute(`/api/carts/${cartId}`, "GET");
1433
+ return this.execute(
1434
+ `/api/carts/${cartId}?depth=0&joins=false`,
1435
+ "GET"
1436
+ );
1476
1437
  }
1477
1438
  addItem(params) {
1478
1439
  return this.execute("/api/carts/add-item", "POST", params);
@@ -1568,7 +1529,9 @@ var CommerceClient = class {
1568
1529
  stockCheck: (params) => api.post("/api/products/stock-check", params),
1569
1530
  stockSnapshot: (params) => api.get(stockSnapshotQuery(params)),
1570
1531
  listingGroups: (params) => api.get(listingGroupsQuery(params)),
1571
- listingGroupsCatalog: (params) => api.get(listingGroupsCatalogQuery(params)),
1532
+ listingGroupsCatalog: (params) => api.get(
1533
+ listingGroupsCatalogQuery(params)
1534
+ ),
1572
1535
  detail: async (params) => {
1573
1536
  try {
1574
1537
  const product = await api.get(productDetailQuery(params));