@betterstore/sdk 0.3.68 → 0.3.70

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.70
4
+
5
+ ### Patch Changes
6
+
7
+ - bug fix
8
+
9
+ ## 0.3.69
10
+
11
+ ### Patch Changes
12
+
13
+ - bug fixes
14
+
3
15
  ## 0.3.68
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -113,6 +113,18 @@ interface Collection {
113
113
  interface CollectionWithProducts extends Collection {
114
114
  products: ProductWithoutVariants[];
115
115
  }
116
+ type ListProductsQuery = {
117
+ collectionId: string;
118
+ } | {
119
+ collectionSeoHandle: string;
120
+ };
121
+ type SortBy = "createdAt" | "updatedAt" | "bestSelling";
122
+ type SortOrder = "asc" | "desc";
123
+ type ListProductsParams = {
124
+ sortBy?: SortBy;
125
+ sortOrder?: SortOrder;
126
+ query?: string;
127
+ };
116
128
 
117
129
  type ShippingRate = ZasilkovnaRate;
118
130
  interface BaseRate {
@@ -138,7 +150,11 @@ interface LineItem {
138
150
  productData: ProductData;
139
151
  metadata?: string;
140
152
  }
141
- interface LineItemCreate extends Omit<LineItem, "productData" | "product" | "metadata"> {
153
+ interface LineItemCreate extends Omit<LineItem, "productData" | "product" | "metadata" | "variantOptions"> {
154
+ variantOptions?: {
155
+ name: string;
156
+ value: string;
157
+ }[];
142
158
  productId: string;
143
159
  product?: Pick<Product, "title" | "priceInCents" | "images">;
144
160
  metadata?: RecursiveRecord;
@@ -358,11 +374,12 @@ declare class Helpers {
358
374
  declare class Products {
359
375
  private apiClient;
360
376
  constructor(apiKey: string, proxy?: string);
361
- list(): Promise<ProductWithoutVariants[]>;
377
+ list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
362
378
  retrieve(productId: string): Promise<Product | null>;
379
+ retrieveBySeoHandle(seoHandle: string): Promise<Product | null>;
363
380
  listCollections(): Promise<Collection[]>;
364
381
  retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
365
- retrieveCollectionById(collectionId: string): Promise<CollectionWithProducts>;
382
+ retrieveCollection(collectionId: string): Promise<CollectionWithProducts>;
366
383
  }
367
384
 
368
385
  declare function createBetterStore(config: {
@@ -380,4 +397,4 @@ declare function createStoreHelpers(config?: {
380
397
  proxy?: string;
381
398
  }): Helpers;
382
399
 
383
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
400
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.d.ts CHANGED
@@ -113,6 +113,18 @@ interface Collection {
113
113
  interface CollectionWithProducts extends Collection {
114
114
  products: ProductWithoutVariants[];
115
115
  }
116
+ type ListProductsQuery = {
117
+ collectionId: string;
118
+ } | {
119
+ collectionSeoHandle: string;
120
+ };
121
+ type SortBy = "createdAt" | "updatedAt" | "bestSelling";
122
+ type SortOrder = "asc" | "desc";
123
+ type ListProductsParams = {
124
+ sortBy?: SortBy;
125
+ sortOrder?: SortOrder;
126
+ query?: string;
127
+ };
116
128
 
117
129
  type ShippingRate = ZasilkovnaRate;
118
130
  interface BaseRate {
@@ -138,7 +150,11 @@ interface LineItem {
138
150
  productData: ProductData;
139
151
  metadata?: string;
140
152
  }
141
- interface LineItemCreate extends Omit<LineItem, "productData" | "product" | "metadata"> {
153
+ interface LineItemCreate extends Omit<LineItem, "productData" | "product" | "metadata" | "variantOptions"> {
154
+ variantOptions?: {
155
+ name: string;
156
+ value: string;
157
+ }[];
142
158
  productId: string;
143
159
  product?: Pick<Product, "title" | "priceInCents" | "images">;
144
160
  metadata?: RecursiveRecord;
@@ -358,11 +374,12 @@ declare class Helpers {
358
374
  declare class Products {
359
375
  private apiClient;
360
376
  constructor(apiKey: string, proxy?: string);
361
- list(): Promise<ProductWithoutVariants[]>;
377
+ list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
362
378
  retrieve(productId: string): Promise<Product | null>;
379
+ retrieveBySeoHandle(seoHandle: string): Promise<Product | null>;
363
380
  listCollections(): Promise<Collection[]>;
364
381
  retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
365
- retrieveCollectionById(collectionId: string): Promise<CollectionWithProducts>;
382
+ retrieveCollection(collectionId: string): Promise<CollectionWithProducts>;
366
383
  }
367
384
 
368
385
  declare function createBetterStore(config: {
@@ -380,4 +397,4 @@ declare function createStoreHelpers(config?: {
380
397
  proxy?: string;
381
398
  }): Helpers;
382
399
 
383
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
400
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.js CHANGED
@@ -509,9 +509,15 @@ var Products = class {
509
509
  constructor(apiKey, proxy) {
510
510
  this.apiClient = createApiClient(apiKey, proxy);
511
511
  }
512
- list() {
512
+ list(params) {
513
513
  return __async(this, null, function* () {
514
- const data = yield this.apiClient.get("/products");
514
+ const queryParams = new URLSearchParams();
515
+ if (params) {
516
+ queryParams.set("params", JSON.stringify(params));
517
+ }
518
+ const data = yield this.apiClient.get(
519
+ `/products?${queryParams.toString()}`
520
+ );
515
521
  return data;
516
522
  });
517
523
  }
@@ -525,6 +531,18 @@ var Products = class {
525
531
  return data;
526
532
  });
527
533
  }
534
+ retrieveBySeoHandle(seoHandle) {
535
+ return __async(this, null, function* () {
536
+ const data = yield this.apiClient.get(
537
+ `/products/seoHandle/${seoHandle}`
538
+ );
539
+ if (!data) {
540
+ console.error(`Product with seoHandle ${seoHandle} not found`);
541
+ return null;
542
+ }
543
+ return data;
544
+ });
545
+ }
528
546
  listCollections() {
529
547
  return __async(this, null, function* () {
530
548
  const data = yield this.apiClient.get("/collections");
@@ -539,7 +557,7 @@ var Products = class {
539
557
  return data;
540
558
  });
541
559
  }
542
- retrieveCollectionById(collectionId) {
560
+ retrieveCollection(collectionId) {
543
561
  return __async(this, null, function* () {
544
562
  const data = yield this.apiClient.get(
545
563
  `/collections/id/${collectionId}`
package/dist/index.mjs CHANGED
@@ -472,9 +472,15 @@ var Products = class {
472
472
  constructor(apiKey, proxy) {
473
473
  this.apiClient = createApiClient(apiKey, proxy);
474
474
  }
475
- list() {
475
+ list(params) {
476
476
  return __async(this, null, function* () {
477
- const data = yield this.apiClient.get("/products");
477
+ const queryParams = new URLSearchParams();
478
+ if (params) {
479
+ queryParams.set("params", JSON.stringify(params));
480
+ }
481
+ const data = yield this.apiClient.get(
482
+ `/products?${queryParams.toString()}`
483
+ );
478
484
  return data;
479
485
  });
480
486
  }
@@ -488,6 +494,18 @@ var Products = class {
488
494
  return data;
489
495
  });
490
496
  }
497
+ retrieveBySeoHandle(seoHandle) {
498
+ return __async(this, null, function* () {
499
+ const data = yield this.apiClient.get(
500
+ `/products/seoHandle/${seoHandle}`
501
+ );
502
+ if (!data) {
503
+ console.error(`Product with seoHandle ${seoHandle} not found`);
504
+ return null;
505
+ }
506
+ return data;
507
+ });
508
+ }
491
509
  listCollections() {
492
510
  return __async(this, null, function* () {
493
511
  const data = yield this.apiClient.get("/collections");
@@ -502,7 +520,7 @@ var Products = class {
502
520
  return data;
503
521
  });
504
522
  }
505
- retrieveCollectionById(collectionId) {
523
+ retrieveCollection(collectionId) {
506
524
  return __async(this, null, function* () {
507
525
  const data = yield this.apiClient.get(
508
526
  `/collections/id/${collectionId}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.3.68",
3
+ "version": "0.3.70",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {