@ecomiq/core 0.1.1 → 0.1.3

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/dist/client.d.cts CHANGED
@@ -6,15 +6,16 @@ import { ListProductReviewsParams, StorefrontReviews, CreateProductReviewParams,
6
6
  import { CreateCartParams, StorefrontCart, GetCartParams, AddCartItemParams, UpdateCartItemQuantityParams, RemoveCartItemParams } from './models/storefront-cart.cjs';
7
7
  import { CartCheckoutReadParams, CartCheckoutReadResponse, GetShippingOptionsParams, ShippingOptionsResponse, PutShippingMethodParams, CartBuyerParams, CartAddressesParams, CartCheckoutParams, CartCheckoutResponse, UploadPaymentReceiptParams, CartPaymentReceiptResponse, CartPromotionCodeParams } from './models/storefront-checkout.cjs';
8
8
  import { Countries, GetDepartmentsParams, Departments, GetProvincesParams, Provinces, GetDistrictsParams, Districts } from './models/geo.cjs';
9
- import { StorefrontSettings } from './models/settings.cjs';
9
+ import { StorefrontSettings, CmsPageDetailsDto } from './models/settings.cjs';
10
10
  import 'zod';
11
11
 
12
12
  interface CreateClientOptions extends CreateApiOptions {
13
13
  /**
14
- * Slug de la tienda (header x-Store-Domain).
15
- * Debe venir de ecomiq.config.js (`config.slug`).
14
+ * Dominio/slug de la tienda (header x-Store-Domain).
15
+ * Debe venir de ecomiq.config.js (`config.domain`).
16
+ * Acepta `marketplace`, `marketplace.ecomiq.app` o `marketplace.pe`.
16
17
  */
17
- slug: string;
18
+ domain: string;
18
19
  settingsCacheTtlMs?: number;
19
20
  }
20
21
  interface StorefrontClient extends Api {
@@ -25,6 +26,8 @@ interface StorefrontClient extends Api {
25
26
  getCollections(): Promise<Collections>;
26
27
  /** GET /v1/collections/by-slug/:slug */
27
28
  getCollectionBySlug(slug: string): Promise<Collection>;
29
+ /** GET /v1/pages/{slug} */
30
+ getPageBySlug(slug: string): Promise<CmsPageDetailsDto>;
28
31
  /** Invalida el cache de settings. */
29
32
  clearCache(): void;
30
33
  getProducts(params?: ProductsParamsInput): Promise<ProductsResponse>;
@@ -67,11 +70,11 @@ interface StorefrontClient extends Api {
67
70
  getDistricts(params: GetDistrictsParams): Promise<Districts>;
68
71
  }
69
72
  /**
70
- * Crea el cliente storefront de bajo nivel (requiere slug).
71
- * En apps Ecomiq usa `createClient()` de `@ecomiq/framework`, que toma el slug del config.
73
+ * Crea el cliente storefront de bajo nivel (requiere domain).
74
+ * En apps Ecomiq usa `createClient()` de `@ecomiq/storefront`, que toma el domain del config.
72
75
  *
73
76
  * ```ts
74
- * const api = createClient({ slug: 'marketplace' })
77
+ * const api = createClient({ domain: 'marketplace' })
75
78
  * const collections = await api.getCollections()
76
79
  * ```
77
80
  */
package/dist/client.d.ts CHANGED
@@ -6,15 +6,16 @@ import { ListProductReviewsParams, StorefrontReviews, CreateProductReviewParams,
6
6
  import { CreateCartParams, StorefrontCart, GetCartParams, AddCartItemParams, UpdateCartItemQuantityParams, RemoveCartItemParams } from './models/storefront-cart.js';
7
7
  import { CartCheckoutReadParams, CartCheckoutReadResponse, GetShippingOptionsParams, ShippingOptionsResponse, PutShippingMethodParams, CartBuyerParams, CartAddressesParams, CartCheckoutParams, CartCheckoutResponse, UploadPaymentReceiptParams, CartPaymentReceiptResponse, CartPromotionCodeParams } from './models/storefront-checkout.js';
8
8
  import { Countries, GetDepartmentsParams, Departments, GetProvincesParams, Provinces, GetDistrictsParams, Districts } from './models/geo.js';
9
- import { StorefrontSettings } from './models/settings.js';
9
+ import { StorefrontSettings, CmsPageDetailsDto } from './models/settings.js';
10
10
  import 'zod';
11
11
 
12
12
  interface CreateClientOptions extends CreateApiOptions {
13
13
  /**
14
- * Slug de la tienda (header x-Store-Domain).
15
- * Debe venir de ecomiq.config.js (`config.slug`).
14
+ * Dominio/slug de la tienda (header x-Store-Domain).
15
+ * Debe venir de ecomiq.config.js (`config.domain`).
16
+ * Acepta `marketplace`, `marketplace.ecomiq.app` o `marketplace.pe`.
16
17
  */
17
- slug: string;
18
+ domain: string;
18
19
  settingsCacheTtlMs?: number;
19
20
  }
20
21
  interface StorefrontClient extends Api {
@@ -25,6 +26,8 @@ interface StorefrontClient extends Api {
25
26
  getCollections(): Promise<Collections>;
26
27
  /** GET /v1/collections/by-slug/:slug */
27
28
  getCollectionBySlug(slug: string): Promise<Collection>;
29
+ /** GET /v1/pages/{slug} */
30
+ getPageBySlug(slug: string): Promise<CmsPageDetailsDto>;
28
31
  /** Invalida el cache de settings. */
29
32
  clearCache(): void;
30
33
  getProducts(params?: ProductsParamsInput): Promise<ProductsResponse>;
@@ -67,11 +70,11 @@ interface StorefrontClient extends Api {
67
70
  getDistricts(params: GetDistrictsParams): Promise<Districts>;
68
71
  }
69
72
  /**
70
- * Crea el cliente storefront de bajo nivel (requiere slug).
71
- * En apps Ecomiq usa `createClient()` de `@ecomiq/framework`, que toma el slug del config.
73
+ * Crea el cliente storefront de bajo nivel (requiere domain).
74
+ * En apps Ecomiq usa `createClient()` de `@ecomiq/storefront`, que toma el domain del config.
72
75
  *
73
76
  * ```ts
74
- * const api = createClient({ slug: 'marketplace' })
77
+ * const api = createClient({ domain: 'marketplace' })
75
78
  * const collections = await api.getCollections()
76
79
  * ```
77
80
  */
package/dist/client.js CHANGED
@@ -817,6 +817,11 @@ async function getCollections(api) {
817
817
  async function getCollectionBySlug(api, collectionSlug) {
818
818
  return api.get(`collections/${encodeURIComponent(collectionSlug)}`, CollectionSchema);
819
819
  }
820
+
821
+ // src/services/page.service.ts
822
+ async function getPageBySlug(api, pageSlug) {
823
+ return api.get(`pages/${encodeURIComponent(pageSlug)}`, CmsPageDetailsDtoSchema);
824
+ }
820
825
  var CartBuyerParamsSchema = z.object({
821
826
  cartId: z.string().uuid(),
822
827
  email: z.string().email(),
@@ -1152,12 +1157,12 @@ async function getDistricts(api, params) {
1152
1157
  var DEFAULT_SETTINGS_CACHE_TTL_MS = 3e4;
1153
1158
  function createClient(options) {
1154
1159
  const {
1155
- slug,
1160
+ domain,
1156
1161
  settingsCacheTtlMs = DEFAULT_SETTINGS_CACHE_TTL_MS,
1157
1162
  ...apiOptions
1158
1163
  } = options;
1159
- if (!slug?.trim()) {
1160
- throw new Error("createClient requiere `slug` (config.slug de ecomiq.config.js)");
1164
+ if (!domain?.trim()) {
1165
+ throw new Error("createClient requiere `domain` (config.domain de ecomiq.config.js)");
1161
1166
  }
1162
1167
  if (!Number.isFinite(settingsCacheTtlMs) || settingsCacheTtlMs < 0) {
1163
1168
  throw new Error("settingsCacheTtlMs debe ser un n\xFAmero mayor o igual a 0");
@@ -1185,7 +1190,7 @@ function createClient(options) {
1185
1190
  if (inflight) return inflight;
1186
1191
  const previous = cache?.data;
1187
1192
  inflight = api.get("settings", StorefrontSettingsSchema, {
1188
- headers: { "x-Store-Domain": slug }
1193
+ headers: { "x-Store-Domain": domain }
1189
1194
  }).then((data) => {
1190
1195
  cache = { data, expiresAt: Date.now() + settingsCacheTtlMs };
1191
1196
  return data;
@@ -1209,6 +1214,10 @@ function createClient(options) {
1209
1214
  const client = await apiClient();
1210
1215
  return getCollectionBySlug(client, collectionSlug);
1211
1216
  }
1217
+ async function getPageBySlug2(pageSlug) {
1218
+ const client = await apiClient();
1219
+ return getPageBySlug(client, pageSlug);
1220
+ }
1212
1221
  async function getProducts2(params = {}) {
1213
1222
  const client = await apiClient();
1214
1223
  return getProducts(client, params);
@@ -1307,6 +1316,7 @@ function createClient(options) {
1307
1316
  getStoreId,
1308
1317
  getCollections: getCollections2,
1309
1318
  getCollectionBySlug: getCollectionBySlug2,
1319
+ getPageBySlug: getPageBySlug2,
1310
1320
  clearCache,
1311
1321
  getProducts: getProducts2,
1312
1322
  getProductBySlug: getProductBySlug2,