@caldik/client 0.1.4 → 0.1.5

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
@@ -59,14 +59,59 @@ const { products } = await caldik.products.list(20)
59
59
 
60
60
  ### Get Product
61
61
 
62
- Retrieve a specific product by its ID.
62
+ Retrieve a visible product by its ID or slug. Product IDs are unambiguous. The
63
+ same slug can be used in different categories, but must be unique within a
64
+ category. Uncategorized products have their own shared slug namespace.
63
65
 
64
66
  **Basic usage**
65
67
 
66
68
  ```ts
67
- const { product } = await caldik.products.get("product_123")
69
+ const { product } = await caldik.products.get("PRODUCT_...")
68
70
  ```
69
71
 
72
+ **Get a product by category and slug**
73
+
74
+ Pass a category ID or slug when the product slug is shared across categories.
75
+
76
+ ```ts
77
+ const { product: rustProduct } = await caldik.products.get("stealth", {
78
+ category: "test2",
79
+ })
80
+
81
+ const { product: testProduct } = await caldik.products.get("stealth", {
82
+ category: "test",
83
+ })
84
+ ```
85
+
86
+ **Get a product by a unique slug**
87
+
88
+ ```ts
89
+ const { product } = await caldik.products.get("unique-product")
90
+ ```
91
+
92
+ ### Get Store
93
+
94
+ **Get the store profile and statistics**
95
+
96
+ ```ts
97
+ const { store } = await caldik.store.get()
98
+
99
+ console.log(store.name)
100
+ console.log(store.averageRating) // e.g. 4.9; null when there are no reviews
101
+ console.log(store.orders) // integer count of all store order records
102
+ console.log(store.customers) // integer count of all customer records, including guests
103
+ ```
104
+
105
+ **Read the store's social links**
106
+
107
+ ```ts
108
+ const { store } = await caldik.store.get()
109
+
110
+ const { instagram, tiktok, x, youtube, discord, telegram } = store.socials
111
+ ```
112
+
113
+ Socials are included in the same response. Each unconfigured link is `null`.
114
+
70
115
  ### Get Category
71
116
 
72
117
  Retrieve a specific category by its ID.
package/dist/index.d.mts CHANGED
@@ -70,6 +70,25 @@ interface CategoryResponse {
70
70
  interface Store {
71
71
  name: string;
72
72
  description: string;
73
+ /** Average of all store reviews, rounded to one decimal; null without reviews. */
74
+ averageRating: number | null;
75
+ /** All store order records, including unpaid, failed and refunded orders. */
76
+ orders: number;
77
+ /** All store customer records, including guest customers. */
78
+ customers: number;
79
+ socials: StoreSocials;
80
+ }
81
+ interface StoreSocials {
82
+ instagram: string | null;
83
+ tiktok: string | null;
84
+ x: string | null;
85
+ youtube: string | null;
86
+ discord: string | null;
87
+ telegram: string | null;
88
+ }
89
+ interface ProductGetOptions {
90
+ /** Category ID or slug. Required for a slug used in multiple categories. */
91
+ category?: string;
73
92
  }
74
93
  interface StoreResponse {
75
94
  success: boolean;
@@ -393,7 +412,7 @@ declare class ProductsApi {
393
412
  private client;
394
413
  constructor(client: CaldikHttpClient);
395
414
  list(): Promise<ProductsResponse>;
396
- get(productIdOrSlug: string): Promise<ProductResponse>;
415
+ get(productIdOrSlug: string, options?: ProductGetOptions): Promise<ProductResponse>;
397
416
  }
398
417
  //#endregion
399
418
  //#region src/reviews.d.ts
@@ -559,4 +578,4 @@ declare class CaldikClient {
559
578
  constructor(options?: CaldikClientOptions);
560
579
  }
561
580
  //#endregion
562
- export { AppliedDiscount, CaldikClient, CaldikClientOptions, CartApi, CartCheckoutInput, CartDiscount, CartItem, CartSnapshot, CategoriesResponse, Category, CategoryDetails, CategoryInclude, CategoryListOptions, CategoryMetadata, CategoryProduct, CategoryResponse, CheckDiscountInput, CheckoutPayment, CheckoutPaymentMethod, CheckoutPaymentMethodsResponse, CheckoutPaymentProviderId, CheckoutSettings, CheckoutSettingsResponse, CommerceItem, CreateOrderInput, CreateSubscriptionInput, CustomerEmailLoginInput, CustomerLoginResponse, CustomerLoginSettings, CustomerLoginSettingsResponse, CustomerLoginVerifyResponse, CustomerPasswordInput, CustomerPasswordResetInput, CustomerPasswordResetResponse, CustomerPasswordResetVerifyResponse, CustomerPasswordResponse, CustomerProfileResponse, CustomerRegistrationInput, CustomerRegistrationResponse, CustomerSessionResponse, DiscountQuoteResponse, DiscountsApi, ManualCommerceItem, OrderResponse, PaymentProviderId, Product, ProductCommerceItem, ProductCustomField, ProductCustomFieldInputType, ProductCustomFieldOption, ProductMetadata, ProductResponse, ProductTag, ProductVariant, ProductsResponse, Review, ReviewsResponse, Store, StoreResponse, StoreWebhookEvent, StoreWebhookEventName, StorefrontMetadata, StorefrontOrder, SubscriptionPaymentProviderId, SubscriptionResponse, checkoutPaymentProviderIds, paymentProviderIds, storeWebhookEventNames, subscriptionPaymentProviderIds };
581
+ export { AppliedDiscount, CaldikClient, CaldikClientOptions, CartApi, CartCheckoutInput, CartDiscount, CartItem, CartSnapshot, CategoriesResponse, Category, CategoryDetails, CategoryInclude, CategoryListOptions, CategoryMetadata, CategoryProduct, CategoryResponse, CheckDiscountInput, CheckoutPayment, CheckoutPaymentMethod, CheckoutPaymentMethodsResponse, CheckoutPaymentProviderId, CheckoutSettings, CheckoutSettingsResponse, CommerceItem, CreateOrderInput, CreateSubscriptionInput, CustomerEmailLoginInput, CustomerLoginResponse, CustomerLoginSettings, CustomerLoginSettingsResponse, CustomerLoginVerifyResponse, CustomerPasswordInput, CustomerPasswordResetInput, CustomerPasswordResetResponse, CustomerPasswordResetVerifyResponse, CustomerPasswordResponse, CustomerProfileResponse, CustomerRegistrationInput, CustomerRegistrationResponse, CustomerSessionResponse, DiscountQuoteResponse, DiscountsApi, ManualCommerceItem, OrderResponse, PaymentProviderId, Product, ProductCommerceItem, ProductCustomField, ProductCustomFieldInputType, ProductCustomFieldOption, ProductGetOptions, ProductMetadata, ProductResponse, ProductTag, ProductVariant, ProductsResponse, Review, ReviewsResponse, Store, StoreResponse, StoreSocials, StoreWebhookEvent, StoreWebhookEventName, StorefrontMetadata, StorefrontOrder, SubscriptionPaymentProviderId, SubscriptionResponse, checkoutPaymentProviderIds, paymentProviderIds, storeWebhookEventNames, subscriptionPaymentProviderIds };
package/dist/index.mjs CHANGED
@@ -173,8 +173,8 @@ var ProductsApi = class {
173
173
  list() {
174
174
  return this.client.get("/products", void 0, { access: "public" });
175
175
  }
176
- get(productIdOrSlug) {
177
- return this.client.get(`/products/${encodeURIComponent(productIdOrSlug)}`, void 0, { access: "public" });
176
+ get(productIdOrSlug, options) {
177
+ return this.client.get(`/products/${encodeURIComponent(productIdOrSlug)}`, options?.category === void 0 ? void 0 : { category: options.category }, { access: "public" });
178
178
  }
179
179
  };
180
180
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caldik/client",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",