@ecomiq/storefront 0.1.1 → 0.1.2
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 +144 -47
- package/dist/..d.ts +30 -0
- package/dist/core.d.ts +47 -42
- package/dist/core.js +324 -212
- package/dist/core.js.map +1 -1
- package/dist/{find-storefront-cms-page-c8CktSz7.d.ts → find-storefront-cms-page-DNwLo1iV.d.ts} +17 -3
- package/dist/index.d.ts +30 -0
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -0
- package/dist/nextjs.d.ts +119 -111
- package/dist/nextjs.js +336 -43
- package/dist/nextjs.js.map +1 -1
- package/dist/react.d.ts +84 -83
- package/dist/react.js +342 -238
- package/dist/react.js.map +1 -1
- package/package.json +5 -1
- package/dist/{store-to_vuWRF.d.ts → collection-anMkdWa7.d.ts} +2666 -2666
package/dist/nextjs.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Modal } from '@ecomiq/ui/components/modal';
|
|
3
|
-
import { StorefrontPageDetailSchema as StorefrontPageDetailSchema$1, formatCurrency, useCart, useStore as useStore$1, useStorefrontAuthClient, useStorefrontSession, SignInForm, SignUpForm,
|
|
3
|
+
import { StorefrontPageDetailSchema as StorefrontPageDetailSchema$1, formatCurrency, useCart, useStore as useStore$1, useStorefrontAuthClient, useStorefrontSession, SignInForm, SignUpForm, signInWithEcomiqCredentials } from '@ecomiq/storefront/react';
|
|
4
4
|
import { toast, Toaster as Toaster$1 } from 'sonner';
|
|
5
5
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
6
6
|
import { useTheme } from 'next-themes';
|
|
7
7
|
import { headers } from 'next/headers';
|
|
8
8
|
import { StorefrontSettingsSchema, StorefrontProductsParamsSchema, StorefrontProductsResponseSchema, StorefrontProductDetailSchema, StorefrontCollectionsResponseSchema, StorefrontCollectionDetailSchema, StorefrontPageListItemSchema, StorefrontPageDetailSchema, CartCreateRequestSchema, CartResponseSchema, CartBuyerRequestSchema, CartAddressesRequestSchema, CartCouponRequestSchema, CartCheckoutRequestSchema, CartCheckoutResponseSchema, CartPaymentReceiptResponseSchema, CartCheckoutReadResponseSchema, ShippingOptionsResponseSchema, CartShippingMethodPutRequestSchema, CartItemRequestSchema } from '@ecomiq/storefront/core';
|
|
9
9
|
import { getCloudflareContext } from '@opennextjs/cloudflare';
|
|
10
|
+
import { existsSync } from 'fs';
|
|
11
|
+
import { createRequire } from 'module';
|
|
12
|
+
import { join } from 'path';
|
|
10
13
|
import React2, { createContext, useEffect, useState, useMemo, useCallback, useRef } from 'react';
|
|
11
|
-
import { QueryClient,
|
|
14
|
+
import { QueryClient, useMutation, useQuery, QueryClientProvider, useQueryClient, useInfiniteQuery } from '@tanstack/react-query';
|
|
12
15
|
import { create } from 'zustand';
|
|
13
16
|
|
|
14
17
|
var __defProp = Object.defineProperty;
|
|
@@ -312,31 +315,8 @@ var init_modals_factory = __esm({
|
|
|
312
315
|
const authClient = useStorefrontAuthClient();
|
|
313
316
|
const { refetch } = useStorefrontSession();
|
|
314
317
|
const handlerLogin = async (values) => {
|
|
315
|
-
const settings = store.data;
|
|
316
|
-
const record = storefrontStoreRecord(settings);
|
|
317
|
-
const checkout = record?.checkoutSettings;
|
|
318
|
-
if (!record?.id) {
|
|
319
|
-
toast.error("Tienda no disponible");
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const identityScope = checkout?.identityScope === "tenant" ? "tenant" : "store";
|
|
323
|
-
const identityHeaders = {
|
|
324
|
-
"x-Identity-Scope": identityScope,
|
|
325
|
-
"x-Store-Id": record.id
|
|
326
|
-
};
|
|
327
|
-
if (record.tenantId) {
|
|
328
|
-
identityHeaders["x-Tenant-Id"] = record.tenantId;
|
|
329
|
-
}
|
|
330
318
|
try {
|
|
331
|
-
|
|
332
|
-
method: "POST",
|
|
333
|
-
headers: identityHeaders,
|
|
334
|
-
body: { email: values.email, password: values.password }
|
|
335
|
-
});
|
|
336
|
-
if (response.error) {
|
|
337
|
-
toast.error(response.error.message);
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
319
|
+
await signInWithEcomiqCredentials(authClient, store.data, values);
|
|
340
320
|
const me = await getCustomerMe();
|
|
341
321
|
const displayName = `${me.firstName} ${me.lastName}`.trim() || me.email;
|
|
342
322
|
const updateUserResponse = await authClient.$fetch("/update-user", {
|
|
@@ -521,8 +501,17 @@ function resolveStorefrontSettingsHost(hostHeader) {
|
|
|
521
501
|
}
|
|
522
502
|
return host;
|
|
523
503
|
}
|
|
504
|
+
function buildStorefrontKvSnapshotKeyFromStoreKey(storeKey) {
|
|
505
|
+
const key = storeKey.trim();
|
|
506
|
+
if (!key) {
|
|
507
|
+
throw Object.assign(new Error("Store key vac\xEDo para KV"), { status: 400 });
|
|
508
|
+
}
|
|
509
|
+
return `storefront:snapshots:store:${key}`;
|
|
510
|
+
}
|
|
524
511
|
function buildStorefrontKvSnapshotKey(hostHeader) {
|
|
525
|
-
return
|
|
512
|
+
return buildStorefrontKvSnapshotKeyFromStoreKey(
|
|
513
|
+
resolveStorefrontSettingsHost(hostHeader)
|
|
514
|
+
);
|
|
526
515
|
}
|
|
527
516
|
function getKvNamespace(env) {
|
|
528
517
|
if (!env || typeof env !== "object") return void 0;
|
|
@@ -532,7 +521,7 @@ function getKvNamespace(env) {
|
|
|
532
521
|
}
|
|
533
522
|
return ns;
|
|
534
523
|
}
|
|
535
|
-
async function
|
|
524
|
+
async function getStorefrontSettingsFromKvByStoreKey(storeKey) {
|
|
536
525
|
const { env } = await getCloudflareContext({ async: true });
|
|
537
526
|
const kv = getKvNamespace(env);
|
|
538
527
|
if (!kv) {
|
|
@@ -541,7 +530,7 @@ async function getStorefrontSettingsFromKv(hostHeader) {
|
|
|
541
530
|
);
|
|
542
531
|
throw Object.assign(err, { status: 500 });
|
|
543
532
|
}
|
|
544
|
-
const cacheKey =
|
|
533
|
+
const cacheKey = buildStorefrontKvSnapshotKeyFromStoreKey(storeKey);
|
|
545
534
|
const raw = await kv.get(cacheKey, { type: "json" });
|
|
546
535
|
if (raw == null) {
|
|
547
536
|
const err = new Error("Store settings not found in KV");
|
|
@@ -549,6 +538,68 @@ async function getStorefrontSettingsFromKv(hostHeader) {
|
|
|
549
538
|
}
|
|
550
539
|
return StorefrontSettingsSchema.parse(raw);
|
|
551
540
|
}
|
|
541
|
+
async function getStorefrontSettingsFromKv(hostHeader) {
|
|
542
|
+
return getStorefrontSettingsFromKvByStoreKey(
|
|
543
|
+
resolveStorefrontSettingsHost(hostHeader)
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
var CONFIG_FILENAMES = [
|
|
547
|
+
"ecomiq.config.js",
|
|
548
|
+
"ecomiq.config.cjs",
|
|
549
|
+
"ecomiq.config.mjs"
|
|
550
|
+
];
|
|
551
|
+
var EcomiqConfigSchema = z.object({
|
|
552
|
+
/**
|
|
553
|
+
* Slug de tienda en Ecomiq (p. ej. `mi-tienda` para `mi-tienda.ecomiq.app`).
|
|
554
|
+
* Si está definido, tiene prioridad sobre el `Host` de la request (útil en `localhost`).
|
|
555
|
+
*/
|
|
556
|
+
slugStore: z.string().min(1).optional()
|
|
557
|
+
});
|
|
558
|
+
var cachedConfig;
|
|
559
|
+
function parseExportedConfig(raw) {
|
|
560
|
+
const candidate = raw && typeof raw === "object" && "default" in raw ? raw.default : raw;
|
|
561
|
+
const parsed = EcomiqConfigSchema.safeParse(candidate);
|
|
562
|
+
if (!parsed.success) {
|
|
563
|
+
console.warn(
|
|
564
|
+
"[ecomiq] ecomiq.config.* inv\xE1lido:",
|
|
565
|
+
parsed.error.flatten().fieldErrors
|
|
566
|
+
);
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
const slugStore = parsed.data.slugStore?.trim();
|
|
570
|
+
return slugStore ? { slugStore } : {};
|
|
571
|
+
}
|
|
572
|
+
function loadEcomiqConfig(cwd = process.cwd()) {
|
|
573
|
+
if (cachedConfig !== void 0) return cachedConfig;
|
|
574
|
+
for (const filename of CONFIG_FILENAMES) {
|
|
575
|
+
const configPath = join(cwd, filename);
|
|
576
|
+
if (!existsSync(configPath)) continue;
|
|
577
|
+
try {
|
|
578
|
+
const requireFromApp = createRequire(join(cwd, "package.json"));
|
|
579
|
+
const loaded = requireFromApp(configPath);
|
|
580
|
+
const parsed = parseExportedConfig(loaded);
|
|
581
|
+
cachedConfig = parsed;
|
|
582
|
+
return cachedConfig;
|
|
583
|
+
} catch (error) {
|
|
584
|
+
console.warn(`[ecomiq] No se pudo cargar ${configPath}:`, error);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
cachedConfig = null;
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
function resolvePublicStoreKey(hostHeader, cwd) {
|
|
591
|
+
const slugFromConfig = loadEcomiqConfig(cwd)?.slugStore?.trim();
|
|
592
|
+
if (slugFromConfig) return slugFromConfig;
|
|
593
|
+
if (!hostHeader?.trim()) {
|
|
594
|
+
throw Object.assign(
|
|
595
|
+
new Error(
|
|
596
|
+
"Host is required, o define slugStore en ecomiq.config.js en la ra\xEDz del proyecto"
|
|
597
|
+
),
|
|
598
|
+
{ status: 400 }
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
return resolveStorefrontSettingsHost(hostHeader);
|
|
602
|
+
}
|
|
552
603
|
|
|
553
604
|
// src/react/shell/lib/public-store-settings-source.ts
|
|
554
605
|
var ENV_PUBLIC_STORE_SETTINGS_SOURCE = "PUBLIC_STORE_SETTINGS_SOURCE";
|
|
@@ -562,27 +613,33 @@ init_store_api_client();
|
|
|
562
613
|
async function getPublicStore(options) {
|
|
563
614
|
const headerList = await headers();
|
|
564
615
|
const host = headerList.get("host");
|
|
565
|
-
|
|
616
|
+
let storeKey;
|
|
617
|
+
try {
|
|
618
|
+
storeKey = resolvePublicStoreKey(host);
|
|
619
|
+
} catch (error) {
|
|
620
|
+
const err = error;
|
|
566
621
|
return {
|
|
567
622
|
data: null,
|
|
568
623
|
error: {
|
|
569
|
-
message: "Host is required",
|
|
570
|
-
statusCode: 400,
|
|
624
|
+
message: err.message ?? "Host is required",
|
|
625
|
+
statusCode: err.status ?? 400,
|
|
571
626
|
isNotFound: true,
|
|
572
627
|
subdomain: void 0
|
|
573
628
|
}
|
|
574
629
|
};
|
|
575
630
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
631
|
+
if (host?.trim()) {
|
|
632
|
+
const proto = headerList.get("x-forwarded-proto") ?? headerList.get("x-forwarded-ssl") ?? "http";
|
|
633
|
+
const secure = proto === "https" || (headerList.get("x-forwarded-ssl") ?? "") === "on";
|
|
634
|
+
setServerRequestOrigin(`${secure ? "https" : "http"}://${host}`);
|
|
635
|
+
}
|
|
580
636
|
const source = options?.source ?? resolvePublicStoreSettingsSource();
|
|
581
|
-
let storeDomain;
|
|
582
637
|
try {
|
|
583
|
-
storeDomain = resolveStorefrontSettingsHost(host);
|
|
584
638
|
setServerStoreId(null);
|
|
585
|
-
const data = source === "kv" ? await
|
|
639
|
+
const data = source === "kv" ? await getStorefrontSettingsFromKvByStoreKey(storeKey) : await getStorefrontSettings(
|
|
640
|
+
storeKey,
|
|
641
|
+
`storefront-settings-${storeKey}`
|
|
642
|
+
);
|
|
586
643
|
setServerStoreId(data.store.id);
|
|
587
644
|
return { data, error: null };
|
|
588
645
|
} catch (error) {
|
|
@@ -594,7 +651,7 @@ async function getPublicStore(options) {
|
|
|
594
651
|
message: err.message ?? "Error fetching store settings",
|
|
595
652
|
statusCode,
|
|
596
653
|
isNotFound: statusCode === 404,
|
|
597
|
-
subdomain:
|
|
654
|
+
subdomain: storeKey
|
|
598
655
|
}
|
|
599
656
|
};
|
|
600
657
|
}
|
|
@@ -688,10 +745,12 @@ function EcomiqProvider({
|
|
|
688
745
|
return () => setClientStoreId(null);
|
|
689
746
|
}, [store]);
|
|
690
747
|
const [queryClient] = useState(() => new QueryClient());
|
|
691
|
-
|
|
748
|
+
const tree = /* @__PURE__ */ jsxs(QueryClientProvider, { client: queryClient, children: [
|
|
692
749
|
children,
|
|
693
750
|
withShellUi ? /* @__PURE__ */ jsx(EcomiqShellUi2, {}) : null
|
|
694
|
-
] })
|
|
751
|
+
] });
|
|
752
|
+
if (!authClient) return tree;
|
|
753
|
+
return /* @__PURE__ */ jsx(StorefrontAuthProvider, { authClient, children: tree });
|
|
695
754
|
}
|
|
696
755
|
function EcomiqShellUi2() {
|
|
697
756
|
const [ui, setUi] = useState(null);
|
|
@@ -1154,6 +1213,240 @@ async function getSharedOrderDraft(shareToken) {
|
|
|
1154
1213
|
);
|
|
1155
1214
|
return OrderDraftSchema.parse(response);
|
|
1156
1215
|
}
|
|
1216
|
+
|
|
1217
|
+
// src/npm/nextjs.ts
|
|
1218
|
+
init_store_api_customer_service();
|
|
1219
|
+
var StorefrontCheckoutSettingsSchema = z.object({
|
|
1220
|
+
allowGuestCheckout: z.boolean().optional(),
|
|
1221
|
+
identityScope: z.enum(["store", "tenant", "global"]).optional(),
|
|
1222
|
+
signInMethods: z.array(z.string()).optional()
|
|
1223
|
+
});
|
|
1224
|
+
var looseRecord = z.record(z.string(), z.unknown());
|
|
1225
|
+
var StorefrontThemeConfigSchema = z.object({
|
|
1226
|
+
name: z.string().nullable().optional(),
|
|
1227
|
+
mode: z.string().nullable().optional(),
|
|
1228
|
+
colors: looseRecord.optional(),
|
|
1229
|
+
fonts: looseRecord.optional(),
|
|
1230
|
+
assets: looseRecord.optional()
|
|
1231
|
+
}).passthrough();
|
|
1232
|
+
var StorefrontFeaturesEnabledSchema = z.object({
|
|
1233
|
+
flags: looseRecord.optional()
|
|
1234
|
+
}).passthrough();
|
|
1235
|
+
var StorefrontCmsBrandingSchema = z.object({
|
|
1236
|
+
logoUrl: z.string().nullable().optional(),
|
|
1237
|
+
logoDarkUrl: z.string().nullable().optional(),
|
|
1238
|
+
faviconUrl: z.string().nullable().optional(),
|
|
1239
|
+
socialImageUrl: z.string().nullable().optional()
|
|
1240
|
+
});
|
|
1241
|
+
var StorefrontCmsSeoSchema = z.object({
|
|
1242
|
+
siteName: z.string().nullable().optional(),
|
|
1243
|
+
metaTitle: z.string().nullable().optional(),
|
|
1244
|
+
metaDescription: z.string().nullable().optional(),
|
|
1245
|
+
titleTemplate: z.string().nullable().optional(),
|
|
1246
|
+
robotsIndex: z.boolean().optional()
|
|
1247
|
+
});
|
|
1248
|
+
var StorefrontCmsSocialLinksSchema = z.object({
|
|
1249
|
+
instagram: z.string().nullable().optional(),
|
|
1250
|
+
facebook: z.string().nullable().optional(),
|
|
1251
|
+
tiktok: z.string().nullable().optional(),
|
|
1252
|
+
youtube: z.string().nullable().optional(),
|
|
1253
|
+
x: z.string().nullable().optional()
|
|
1254
|
+
});
|
|
1255
|
+
var StorefrontCmsContactSchema = z.object({
|
|
1256
|
+
supportEmail: z.string().nullable().optional(),
|
|
1257
|
+
phone: z.string().nullable().optional(),
|
|
1258
|
+
whatsapp: z.string().nullable().optional(),
|
|
1259
|
+
address: z.string().nullable().optional(),
|
|
1260
|
+
socialLinks: StorefrontCmsSocialLinksSchema.optional()
|
|
1261
|
+
});
|
|
1262
|
+
var StorefrontCmsTrackingSchema = z.object({
|
|
1263
|
+
googleAnalyticsMeasurementId: z.string().nullable().optional(),
|
|
1264
|
+
metaPixelId: z.string().nullable().optional(),
|
|
1265
|
+
googleTagManagerContainerId: z.string().nullable().optional()
|
|
1266
|
+
});
|
|
1267
|
+
var StorefrontCmsCustomScriptsSchema = z.object({
|
|
1268
|
+
enabled: z.boolean().optional(),
|
|
1269
|
+
head: z.string().nullable().optional(),
|
|
1270
|
+
bodyEnd: z.string().nullable().optional()
|
|
1271
|
+
});
|
|
1272
|
+
var StorefrontCmsSettingsSchema = z.object({
|
|
1273
|
+
themeKey: z.string().optional(),
|
|
1274
|
+
branding: StorefrontCmsBrandingSchema.optional(),
|
|
1275
|
+
seo: StorefrontCmsSeoSchema.optional(),
|
|
1276
|
+
contact: StorefrontCmsContactSchema.optional(),
|
|
1277
|
+
tracking: StorefrontCmsTrackingSchema.optional(),
|
|
1278
|
+
customScripts: StorefrontCmsCustomScriptsSchema.optional(),
|
|
1279
|
+
updatedOn: z.string().nullable().optional()
|
|
1280
|
+
});
|
|
1281
|
+
var StorefrontCmsPageSchema = z.object({
|
|
1282
|
+
id: z.string(),
|
|
1283
|
+
name: z.string(),
|
|
1284
|
+
slug: z.string(),
|
|
1285
|
+
layout: z.string().optional(),
|
|
1286
|
+
version: z.number().optional(),
|
|
1287
|
+
settings: z.record(z.string(), z.unknown()).optional().nullable(),
|
|
1288
|
+
sections: z.array(z.unknown()).optional(),
|
|
1289
|
+
status: z.string().optional(),
|
|
1290
|
+
hasPublishedVersion: z.boolean().optional(),
|
|
1291
|
+
publishedOn: z.string().nullable().optional(),
|
|
1292
|
+
publishedBy: z.string().nullable().optional(),
|
|
1293
|
+
createdOn: z.string().nullable().optional(),
|
|
1294
|
+
updatedOn: z.string().nullable().optional(),
|
|
1295
|
+
createdBy: z.string().nullable().optional(),
|
|
1296
|
+
updatedBy: z.string().nullable().optional(),
|
|
1297
|
+
lastModifiedBy: z.string().nullable().optional()
|
|
1298
|
+
}).passthrough();
|
|
1299
|
+
var StorefrontSettingsLegacyFlatSchema = z.object({
|
|
1300
|
+
id: z.coerce.string(),
|
|
1301
|
+
tenantId: z.string().nullable().optional(),
|
|
1302
|
+
name: z.string(),
|
|
1303
|
+
slug: z.coerce.string().optional(),
|
|
1304
|
+
description: z.string().nullable().optional(),
|
|
1305
|
+
visibility: z.string().nullable().optional(),
|
|
1306
|
+
logo: z.string().nullable().optional(),
|
|
1307
|
+
favicon: z.string().nullable().optional(),
|
|
1308
|
+
icon: z.string().nullable().optional(),
|
|
1309
|
+
currency: z.string().nullable().optional(),
|
|
1310
|
+
language: z.string().nullable().optional(),
|
|
1311
|
+
themeConfig: z.unknown().optional().nullable(),
|
|
1312
|
+
featuresEnabled: z.unknown().optional().nullable(),
|
|
1313
|
+
checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable()
|
|
1314
|
+
}).passthrough();
|
|
1315
|
+
function unwrapSettingsResponseBody(v) {
|
|
1316
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return v;
|
|
1317
|
+
const o = v;
|
|
1318
|
+
if ("data" in o && o.data != null && typeof o.data === "object" && !Array.isArray(o.data)) {
|
|
1319
|
+
return o.data;
|
|
1320
|
+
}
|
|
1321
|
+
return v;
|
|
1322
|
+
}
|
|
1323
|
+
function isLegacyFlatSettingsPayload(v) {
|
|
1324
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return false;
|
|
1325
|
+
const o = v;
|
|
1326
|
+
if ("store" in o || "schemaVersion" in o || "cms" in o) return false;
|
|
1327
|
+
return (typeof o.id === "string" || typeof o.id === "number") && typeof o.name === "string";
|
|
1328
|
+
}
|
|
1329
|
+
function normalizeStorefrontSettingsPayload(v) {
|
|
1330
|
+
const body = unwrapSettingsResponseBody(v);
|
|
1331
|
+
if (!isLegacyFlatSettingsPayload(body)) return body;
|
|
1332
|
+
const raw = body;
|
|
1333
|
+
const parsed = StorefrontSettingsLegacyFlatSchema.safeParse(raw);
|
|
1334
|
+
if (!parsed.success) return body;
|
|
1335
|
+
const l = parsed.data;
|
|
1336
|
+
const currency = l.currency?.trim() ? l.currency : "PEN";
|
|
1337
|
+
const language = l.language?.trim() ? l.language : "es";
|
|
1338
|
+
const slug = l.slug?.trim() ? l.slug : l.id;
|
|
1339
|
+
return {
|
|
1340
|
+
schemaVersion: 0,
|
|
1341
|
+
generatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
1342
|
+
store: {
|
|
1343
|
+
id: l.id,
|
|
1344
|
+
tenantId: l.tenantId ?? void 0,
|
|
1345
|
+
name: l.name,
|
|
1346
|
+
slug,
|
|
1347
|
+
description: l.description ?? null,
|
|
1348
|
+
logo: l.logo ?? null,
|
|
1349
|
+
icon: l.icon ?? null,
|
|
1350
|
+
visibility: l.visibility ?? void 0,
|
|
1351
|
+
currency,
|
|
1352
|
+
language,
|
|
1353
|
+
themeConfig: l.themeConfig ?? void 0,
|
|
1354
|
+
featuresEnabled: l.featuresEnabled ?? void 0,
|
|
1355
|
+
checkoutSettings: l.checkoutSettings ?? void 0
|
|
1356
|
+
},
|
|
1357
|
+
cms: {
|
|
1358
|
+
settings: {
|
|
1359
|
+
branding: {
|
|
1360
|
+
faviconUrl: l.favicon ?? null,
|
|
1361
|
+
logoUrl: l.logo ?? null,
|
|
1362
|
+
logoDarkUrl: null,
|
|
1363
|
+
socialImageUrl: null
|
|
1364
|
+
}
|
|
1365
|
+
},
|
|
1366
|
+
pages: []
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
var StorefrontStoreSchema = z.object({
|
|
1371
|
+
id: z.string(),
|
|
1372
|
+
tenantId: z.string().optional(),
|
|
1373
|
+
sellerId: z.string().optional(),
|
|
1374
|
+
plan: z.string().optional(),
|
|
1375
|
+
storageLimitBytes: z.number().optional(),
|
|
1376
|
+
monthlyTransferLimitBytes: z.number().optional(),
|
|
1377
|
+
maxUploadSizeBytes: z.number().optional(),
|
|
1378
|
+
maxStores: z.number().optional(),
|
|
1379
|
+
maxMembers: z.number().optional(),
|
|
1380
|
+
maxProducts: z.number().optional(),
|
|
1381
|
+
maxCategories: z.number().optional(),
|
|
1382
|
+
maxBrands: z.number().optional(),
|
|
1383
|
+
maxAttributes: z.number().optional(),
|
|
1384
|
+
maxCollections: z.number().optional(),
|
|
1385
|
+
enableApi: z.boolean().optional(),
|
|
1386
|
+
isActive: z.boolean().optional(),
|
|
1387
|
+
name: z.string(),
|
|
1388
|
+
description: z.string().nullable().optional(),
|
|
1389
|
+
avatarUrl: z.string().nullable().optional(),
|
|
1390
|
+
logo: z.string().nullable().optional(),
|
|
1391
|
+
icon: z.string().nullable().optional(),
|
|
1392
|
+
slug: z.string(),
|
|
1393
|
+
domain: z.string().nullable().optional(),
|
|
1394
|
+
domains: z.array(z.string()).optional(),
|
|
1395
|
+
timeZone: z.string().nullable().optional(),
|
|
1396
|
+
currency: z.string(),
|
|
1397
|
+
language: z.string(),
|
|
1398
|
+
visibility: z.string().optional(),
|
|
1399
|
+
privateAccessHash: z.string().nullable().optional(),
|
|
1400
|
+
privateAccessVersion: z.number().optional(),
|
|
1401
|
+
themeConfig: StorefrontThemeConfigSchema.optional(),
|
|
1402
|
+
featuresEnabled: StorefrontFeaturesEnabledSchema.optional(),
|
|
1403
|
+
checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable()
|
|
1404
|
+
}).passthrough();
|
|
1405
|
+
var StorefrontSettingsEnvelopeSchema = z.object({
|
|
1406
|
+
schemaVersion: z.number(),
|
|
1407
|
+
generatedAt: z.string(),
|
|
1408
|
+
store: StorefrontStoreSchema,
|
|
1409
|
+
cms: z.object({
|
|
1410
|
+
settings: StorefrontCmsSettingsSchema,
|
|
1411
|
+
pages: z.array(StorefrontCmsPageSchema)
|
|
1412
|
+
})
|
|
1413
|
+
}).passthrough();
|
|
1414
|
+
z.preprocess(
|
|
1415
|
+
normalizeStorefrontSettingsPayload,
|
|
1416
|
+
StorefrontSettingsEnvelopeSchema
|
|
1417
|
+
);
|
|
1418
|
+
function storefrontStoreRecord(settings) {
|
|
1419
|
+
return settings?.store ?? null;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// src/core/lib/ecomiq-oauth-identity.ts
|
|
1423
|
+
function buildEcomiqOAuthIdentityHeaders(settings) {
|
|
1424
|
+
const record = storefrontStoreRecord(settings);
|
|
1425
|
+
if (!record?.id) {
|
|
1426
|
+
throw new Error("Tienda no disponible para iniciar sesi\xF3n");
|
|
1427
|
+
}
|
|
1428
|
+
const checkout = record.checkoutSettings;
|
|
1429
|
+
const identityScope = checkout?.identityScope === "tenant" ? "tenant" : "store";
|
|
1430
|
+
const headers3 = {
|
|
1431
|
+
"x-Identity-Scope": identityScope,
|
|
1432
|
+
"x-Store-Id": record.id
|
|
1433
|
+
};
|
|
1434
|
+
if (record.tenantId) headers3["x-Tenant-Id"] = record.tenantId;
|
|
1435
|
+
return headers3;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// src/react/auth/ecomiq-storefront-sign-in.ts
|
|
1439
|
+
async function signInWithEcomiqCredentials2(authClient, settings, credentials) {
|
|
1440
|
+
const response = await authClient.$fetch("/ecomiq-oauth/sign-in", {
|
|
1441
|
+
method: "POST",
|
|
1442
|
+
headers: buildEcomiqOAuthIdentityHeaders(settings),
|
|
1443
|
+
body: credentials
|
|
1444
|
+
});
|
|
1445
|
+
if (response.error) {
|
|
1446
|
+
throw new Error(response.error.message ?? "Error al iniciar sesi\xF3n");
|
|
1447
|
+
}
|
|
1448
|
+
return response;
|
|
1449
|
+
}
|
|
1157
1450
|
function useStoreProducts() {
|
|
1158
1451
|
const useStorefrontProductsList = (params) => {
|
|
1159
1452
|
return useQuery({
|
|
@@ -1495,6 +1788,6 @@ function ProductVariantSelector({
|
|
|
1495
1788
|
// src/npm/nextjs.ts
|
|
1496
1789
|
var usePublicStore = () => useStore.getState().data;
|
|
1497
1790
|
|
|
1498
|
-
export { CustomerAddressSchema, CustomerAddressUpsertSchema, CustomerMeSchema, CustomerOrderDetailSchema, CustomerOrderListItemSchema, CustomerProfilePatchSchema, CustomerRegisterRequestSchema, ECOMIQ_CLIENTS_STORE_KV_BINDING, EcomiqProvider, ProductVariantSelector, StoreApiClient, addCartCoupon, buildStorefrontKvSnapshotKey, checkoutCart, createCart, createCustomerAddress, createStoreApiClient, customerMeToProfilePatch, deleteCustomerAddress, findStorefrontCmsPageBySlug, getCart, getCartCheckout, getCartPaymentMethods, getCustomerAddresses, getCustomerMe, getCustomerOrder, getCustomerOrders, getHostname, getPublicStore, getSharedOrderDraft, getShippingOptions, getStoreApiBaseUrl, getStoreApiClient, getStorefrontCollectionBySlug, getStorefrontCollections, getStorefrontPageBySlug, getStorefrontPagePreview, getStorefrontPages, getStorefrontProductBySlug, getStorefrontProducts, getStorefrontSettings, getStorefrontSettingsFromKv, isCartNotActiveApiError, normalizeStoreHost, patchCartAddresses, patchCartBuyer, patchCustomer, putCartShippingMethod, registerCustomer, removeCartCoupon, resolvePublicStoreSettingsSource, resolveStorefrontSettingsHost, setClientStoreId, setServerRequestOrigin, setServerStoreId, storeApiClient, updateCustomerAddress, uploadPaymentReceipt, usePublicStore, useStore, useStoreCart, useStoreCollections, useStorePages, useStoreProducts };
|
|
1791
|
+
export { CustomerAddressSchema, CustomerAddressUpsertSchema, CustomerMeSchema, CustomerOrderDetailSchema, CustomerOrderListItemSchema, CustomerProfilePatchSchema, CustomerRegisterRequestSchema, ECOMIQ_CLIENTS_STORE_KV_BINDING, EcomiqProvider, ProductVariantSelector, StoreApiClient, addCartCoupon, buildStorefrontKvSnapshotKey, buildStorefrontKvSnapshotKeyFromStoreKey, checkoutCart, createCart, createCustomerAddress, createStoreApiClient, customerMeToProfilePatch, deleteCustomerAddress, findStorefrontCmsPageBySlug, getCart, getCartCheckout, getCartPaymentMethods, getCustomerAddresses, getCustomerMe, getCustomerOrder, getCustomerOrders, getHostname, getPublicStore, getSharedOrderDraft, getShippingOptions, getStoreApiBaseUrl, getStoreApiClient, getStorefrontCollectionBySlug, getStorefrontCollections, getStorefrontPageBySlug, getStorefrontPagePreview, getStorefrontPages, getStorefrontProductBySlug, getStorefrontProducts, getStorefrontSettings, getStorefrontSettingsFromKv, getStorefrontSettingsFromKvByStoreKey, isCartNotActiveApiError, normalizeStoreHost, patchCartAddresses, patchCartBuyer, patchCustomer, putCartShippingMethod, registerCustomer, removeCartCoupon, resolvePublicStoreSettingsSource, resolveStorefrontSettingsHost, setClientStoreId, setServerRequestOrigin, setServerStoreId, signInWithEcomiqCredentials2 as signInWithEcomiqCredentials, storeApiClient, updateCustomerAddress, uploadPaymentReceipt, usePublicStore, useStore, useStoreCart, useStoreCollections, useStorePages, useStoreProducts };
|
|
1499
1792
|
//# sourceMappingURL=nextjs.js.map
|
|
1500
1793
|
//# sourceMappingURL=nextjs.js.map
|