@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.cjs +14 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +10 -7
- package/dist/client.d.ts +10 -7
- package/dist/client.js +14 -4
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +15 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
package/dist/client.cjs
CHANGED
|
@@ -819,6 +819,11 @@ async function getCollections(api) {
|
|
|
819
819
|
async function getCollectionBySlug(api, collectionSlug) {
|
|
820
820
|
return api.get(`collections/${encodeURIComponent(collectionSlug)}`, CollectionSchema);
|
|
821
821
|
}
|
|
822
|
+
|
|
823
|
+
// src/services/page.service.ts
|
|
824
|
+
async function getPageBySlug(api, pageSlug) {
|
|
825
|
+
return api.get(`pages/${encodeURIComponent(pageSlug)}`, CmsPageDetailsDtoSchema);
|
|
826
|
+
}
|
|
822
827
|
var CartBuyerParamsSchema = zod.z.object({
|
|
823
828
|
cartId: zod.z.string().uuid(),
|
|
824
829
|
email: zod.z.string().email(),
|
|
@@ -1154,12 +1159,12 @@ async function getDistricts(api, params) {
|
|
|
1154
1159
|
var DEFAULT_SETTINGS_CACHE_TTL_MS = 3e4;
|
|
1155
1160
|
function createClient(options) {
|
|
1156
1161
|
const {
|
|
1157
|
-
|
|
1162
|
+
domain,
|
|
1158
1163
|
settingsCacheTtlMs = DEFAULT_SETTINGS_CACHE_TTL_MS,
|
|
1159
1164
|
...apiOptions
|
|
1160
1165
|
} = options;
|
|
1161
|
-
if (!
|
|
1162
|
-
throw new Error("createClient requiere `
|
|
1166
|
+
if (!domain?.trim()) {
|
|
1167
|
+
throw new Error("createClient requiere `domain` (config.domain de ecomiq.config.js)");
|
|
1163
1168
|
}
|
|
1164
1169
|
if (!Number.isFinite(settingsCacheTtlMs) || settingsCacheTtlMs < 0) {
|
|
1165
1170
|
throw new Error("settingsCacheTtlMs debe ser un n\xFAmero mayor o igual a 0");
|
|
@@ -1187,7 +1192,7 @@ function createClient(options) {
|
|
|
1187
1192
|
if (inflight) return inflight;
|
|
1188
1193
|
const previous = cache?.data;
|
|
1189
1194
|
inflight = api.get("settings", StorefrontSettingsSchema, {
|
|
1190
|
-
headers: { "x-Store-Domain":
|
|
1195
|
+
headers: { "x-Store-Domain": domain }
|
|
1191
1196
|
}).then((data) => {
|
|
1192
1197
|
cache = { data, expiresAt: Date.now() + settingsCacheTtlMs };
|
|
1193
1198
|
return data;
|
|
@@ -1211,6 +1216,10 @@ function createClient(options) {
|
|
|
1211
1216
|
const client = await apiClient();
|
|
1212
1217
|
return getCollectionBySlug(client, collectionSlug);
|
|
1213
1218
|
}
|
|
1219
|
+
async function getPageBySlug2(pageSlug) {
|
|
1220
|
+
const client = await apiClient();
|
|
1221
|
+
return getPageBySlug(client, pageSlug);
|
|
1222
|
+
}
|
|
1214
1223
|
async function getProducts2(params = {}) {
|
|
1215
1224
|
const client = await apiClient();
|
|
1216
1225
|
return getProducts(client, params);
|
|
@@ -1309,6 +1318,7 @@ function createClient(options) {
|
|
|
1309
1318
|
getStoreId,
|
|
1310
1319
|
getCollections: getCollections2,
|
|
1311
1320
|
getCollectionBySlug: getCollectionBySlug2,
|
|
1321
|
+
getPageBySlug: getPageBySlug2,
|
|
1312
1322
|
clearCache,
|
|
1313
1323
|
getProducts: getProducts2,
|
|
1314
1324
|
getProductBySlug: getProductBySlug2,
|