arky-sdk 0.7.118 → 0.7.120

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
@@ -76,19 +76,21 @@ const formatted = arky.utils.formatPrice(product.variants[0].prices); // "$29.99
76
76
  ### 3. Shop & Checkout
77
77
 
78
78
  ```typescript
79
- // Add to cart and checkout (like arky.io/cart)
80
- const order = await arky.eshop.checkout({
81
- items: [{
82
- productId: 'prod_123',
83
- variantId: 'var_456',
84
- quantity: 2
85
- }],
86
- paymentMethod: 'CREDIT_CARD',
87
- shippingMethodId: 'standard',
88
- blocks: [ // Customer info
89
- { key: 'email', values: ['customer@example.com'] },
90
- { key: 'shipping_address', values: ['123 Main St'] }
91
- ]
79
+ const cart = await arky.eshop.cart.current();
80
+
81
+ await arky.eshop.cart.addItem({
82
+ id: cart.id,
83
+ item: {
84
+ type: 'product',
85
+ product_id: 'prod_123',
86
+ variant_id: 'var_456',
87
+ quantity: 2,
88
+ },
89
+ });
90
+
91
+ const order = await arky.eshop.cart.checkout({
92
+ id: cart.id,
93
+ payment_method_id: 'credit_card',
92
94
  });
93
95
  ```
94
96
 
@@ -106,10 +108,12 @@ const availability = await arky.eshop.service.getAvailability({
106
108
  to: Math.floor(Date.now() / 1000) + 86400,
107
109
  });
108
110
 
109
- // Create an order with a service line
110
- const order = await arky.eshop.order.checkout({
111
+ const cart = await arky.eshop.cart.current();
112
+
113
+ await arky.eshop.cart.update({
114
+ id: cart.id,
111
115
  items: [{
112
- type: 'service',
116
+ type: 'booking',
113
117
  service_id: 'service_haircut',
114
118
  provider_id: 'provider_jane',
115
119
  slots: [{
@@ -117,9 +121,13 @@ const order = await arky.eshop.order.checkout({
117
121
  to: availability.available_slots[0].to,
118
122
  }],
119
123
  }],
120
- payment_method: 'cash',
121
124
  forms: [],
122
125
  });
126
+
127
+ const order = await arky.eshop.cart.checkout({
128
+ id: cart.id,
129
+ payment_method_id: 'cash',
130
+ });
123
131
  ```
124
132
 
125
133
  ### 5. Subscribe to Newsletter
@@ -215,8 +223,10 @@ await arky.eshop.getProducts({ limit: 20, cursor: null })
215
223
  await arky.eshop.getProduct({ id })
216
224
  await arky.eshop.updateProduct({ id, name })
217
225
 
218
- // Orders
219
- await arky.eshop.checkout({ items, paymentMethod, shippingMethodId })
226
+ // Carts and orders
227
+ const cart = await arky.eshop.cart.current()
228
+ await arky.eshop.cart.update({ id: cart.id, items, shipping_method_id })
229
+ await arky.eshop.cart.checkout({ id: cart.id, payment_method_id })
220
230
  await arky.eshop.getOrders({})
221
231
  await arky.eshop.getOrder({ id })
222
232
  await arky.eshop.updateOrderStatus({ id, status: 'SHIPPED' })
@@ -240,9 +250,9 @@ await arky.eshop.service.getAvailability({ service_id, provider_id, from, to })
240
250
  await arky.eshop.provider.create({ name })
241
251
  await arky.eshop.provider.find({})
242
252
 
243
- // Service orders
253
+ // Service cart checkout
244
254
  await arky.eshop.order.getQuote({ items, payment_method })
245
- await arky.eshop.order.checkout({ items, payment_method })
255
+ await arky.eshop.cart.checkout({ id: cart.id, payment_method_id })
246
256
  await arky.eshop.order.find({})
247
257
  ```
248
258
 
@@ -342,7 +352,7 @@ await arky.utils.injectSvgIntoElement(mediaBlock, element, 'custom-class')
342
352
 
343
353
  - 🏪 **E-commerce shops** - Product catalogs, shopping carts, checkout
344
354
  - 📰 **Content websites** - Blogs, documentation, marketing sites
345
- - 📅 **Booking platforms** - Appointment scheduling, service bookings
355
+ - 📅 **Service businesses** - Appointment scheduling, service orders
346
356
  - 📬 **Newsletter platforms** - Subscriber management, email campaigns
347
357
  - 🏢 **SaaS products** - Multi-tenant apps with user auth and billing
348
358
  - 🛍️ **Marketplaces** - Multi-vendor platforms with payments
@@ -393,7 +403,7 @@ When adding a new SDK method, follow this checklist so the API surface stays typ
393
403
  2. **Define the request params** in `src/types/api.ts`. Mirror the Rust DTO in `server/core/src/{module}/types/commands.rs` field-for-field. Two exceptions: `store_id?: string` and `market?: string` are optional in TS (the SDK auto-fills both from `apiConfig.storeId` and `apiConfig.market`). Do **not** use `[key: string]: any` index signatures.
394
404
  3. **Annotate the SDK method's return type** using the matching entity from `src/types/index.ts`.
395
405
  4. **Pass the response generic to the HTTP call**: `apiConfig.httpClient.post<EntityType>(...)`, `apiConfig.httpClient.get<PaginatedResponse<EntityType>>(...)`, etc. Never rely on inference.
396
- 5. **Inject `market` from `apiConfig`**: when a body needs a `market` field, write `{ market: apiConfig.market, ...payload }`. Never hardcode `"booking"`, `"eshop"`, or any other market string in `src/api/*.ts`.
406
+ 5. **Inject `market` from `apiConfig`**: when a body needs a `market` field, write `{ market: apiConfig.market, ...payload }`. Never hardcode `"default"`, `"eshop"`, or any other market string in `src/api/*.ts`.
397
407
  6. **Re-export the entity** from `src/index.ts` if consumers (admin, storefront) will import it.
398
408
  7. **Bump `SDK_VERSION`** in `src/index.ts` and the `version` in `package.json`. Patch only.
399
409
 
package/dist/admin.cjs CHANGED
@@ -1042,35 +1042,6 @@ var createEshopApi = (apiConfig) => {
1042
1042
  options
1043
1043
  );
1044
1044
  },
1045
- async createOrder(params, options) {
1046
- const { store_id, items, ...rest } = params;
1047
- const target_store_id = store_id || apiConfig.storeId;
1048
- const payload = {
1049
- ...rest,
1050
- market: rest.market || apiConfig.market,
1051
- items: normalizeOrderCheckoutItems(items)
1052
- };
1053
- return apiConfig.httpClient.post(
1054
- `/v1/stores/${target_store_id}/orders`,
1055
- payload,
1056
- options
1057
- );
1058
- },
1059
- async checkoutOrder(params, options) {
1060
- const { store_id, items, ...rest } = params;
1061
- const target_store_id = store_id || apiConfig.storeId;
1062
- const payload = {
1063
- ...rest,
1064
- store_id: target_store_id,
1065
- market: rest.market || apiConfig.market,
1066
- items: normalizeOrderCheckoutItems(items)
1067
- };
1068
- return apiConfig.httpClient.post(
1069
- `/v1/stores/${target_store_id}/orders/checkout`,
1070
- payload,
1071
- options
1072
- );
1073
- },
1074
1045
  async updateOrder(params, options) {
1075
1046
  const { store_id, items, ...rest } = params;
1076
1047
  const target_store_id = store_id || apiConfig.storeId;
@@ -1102,6 +1073,24 @@ var createEshopApi = (apiConfig) => {
1102
1073
  }
1103
1074
  );
1104
1075
  },
1076
+ async getCarts(params = {}, options) {
1077
+ const { store_id, ...queryParams } = params;
1078
+ const target_store_id = store_id || apiConfig.storeId;
1079
+ return apiConfig.httpClient.get(
1080
+ `/v1/stores/${target_store_id}/carts`,
1081
+ {
1082
+ ...options,
1083
+ params: queryParams
1084
+ }
1085
+ );
1086
+ },
1087
+ async getCart(params, options) {
1088
+ const target_store_id = params.store_id || apiConfig.storeId;
1089
+ return apiConfig.httpClient.get(
1090
+ `/v1/stores/${target_store_id}/carts/${params.id}`,
1091
+ options
1092
+ );
1093
+ },
1105
1094
  async getQuote(params, options) {
1106
1095
  const { location, store_id, items, ...rest } = params;
1107
1096
  const target_store_id = store_id || apiConfig.storeId;
@@ -1271,6 +1260,8 @@ var createCustomerApi = (apiConfig) => {
1271
1260
  if (params?.query) queryParams.query = params.query;
1272
1261
  if (params?.taxonomy_query) queryParams.taxonomy_query = params.taxonomy_query;
1273
1262
  if (params?.status) queryParams.status = params.status;
1263
+ if (params?.has_activity !== void 0) queryParams.has_activity = params.has_activity;
1264
+ if (params?.has_cart !== void 0) queryParams.has_cart = params.has_cart;
1274
1265
  if (params?.sort_field) queryParams.sort_field = params.sort_field;
1275
1266
  if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
1276
1267
  return apiConfig.httpClient.get(
@@ -2286,14 +2277,16 @@ function createAdmin(config) {
2286
2277
  find: eshopApi.getProducts
2287
2278
  },
2288
2279
  order: {
2289
- create: eshopApi.createOrder,
2290
2280
  update: eshopApi.updateOrder,
2291
2281
  get: eshopApi.getOrder,
2292
2282
  find: eshopApi.getOrders,
2293
2283
  getQuote: eshopApi.getQuote,
2294
- checkout: eshopApi.checkoutOrder,
2295
2284
  processRefund: eshopApi.processRefund
2296
2285
  },
2286
+ cart: {
2287
+ get: eshopApi.getCart,
2288
+ find: eshopApi.getCarts
2289
+ },
2297
2290
  service: {
2298
2291
  create: eshopApi.createService,
2299
2292
  update: eshopApi.updateService,