@ecomiq/storefront 0.1.0 → 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 +183 -78
- package/dist/..d.ts +30 -0
- package/dist/{store-CYBCpY6v.d.ts → collection-anMkdWa7.d.ts} +2667 -2667
- package/dist/core.d.ts +47 -51
- package/dist/core.js +324 -212
- package/dist/core.js.map +1 -1
- package/dist/find-storefront-cms-page-DNwLo1iV.d.ts +178 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -0
- package/dist/nextjs/globals.css +3 -4
- package/dist/nextjs.d.ts +59 -54
- package/dist/nextjs.js +871 -1483
- package/dist/nextjs.js.map +1 -1
- package/dist/react.d.ts +50 -130
- package/dist/react.js +1019 -1548
- package/dist/react.js.map +1 -1
- package/package.json +5 -1
- package/dist/find-storefront-cms-page-Bo0-G1FK.d.ts +0 -119
package/dist/core.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import { z } from 'zod';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
import '@opennextjs/cloudflare';
|
|
7
|
+
import '@ecomiq/storefront/core';
|
|
3
8
|
|
|
4
9
|
// src/core/constants/api-paths.ts
|
|
5
10
|
var STOREFRONT_API_PATH_PREFIX = "v1";
|
|
@@ -24,6 +29,232 @@ function formatCurrency(amount, currency = "USD") {
|
|
|
24
29
|
currency
|
|
25
30
|
}).format(amount);
|
|
26
31
|
}
|
|
32
|
+
var StorefrontCheckoutSettingsSchema = z.object({
|
|
33
|
+
allowGuestCheckout: z.boolean().optional(),
|
|
34
|
+
identityScope: z.enum(["store", "tenant", "global"]).optional(),
|
|
35
|
+
signInMethods: z.array(z.string()).optional()
|
|
36
|
+
});
|
|
37
|
+
var looseRecord = z.record(z.string(), z.unknown());
|
|
38
|
+
var StorefrontThemeConfigSchema = z.object({
|
|
39
|
+
name: z.string().nullable().optional(),
|
|
40
|
+
mode: z.string().nullable().optional(),
|
|
41
|
+
colors: looseRecord.optional(),
|
|
42
|
+
fonts: looseRecord.optional(),
|
|
43
|
+
assets: looseRecord.optional()
|
|
44
|
+
}).passthrough();
|
|
45
|
+
var StorefrontFeaturesEnabledSchema = z.object({
|
|
46
|
+
flags: looseRecord.optional()
|
|
47
|
+
}).passthrough();
|
|
48
|
+
var StorefrontCmsBrandingSchema = z.object({
|
|
49
|
+
logoUrl: z.string().nullable().optional(),
|
|
50
|
+
logoDarkUrl: z.string().nullable().optional(),
|
|
51
|
+
faviconUrl: z.string().nullable().optional(),
|
|
52
|
+
socialImageUrl: z.string().nullable().optional()
|
|
53
|
+
});
|
|
54
|
+
var StorefrontCmsSeoSchema = z.object({
|
|
55
|
+
siteName: z.string().nullable().optional(),
|
|
56
|
+
metaTitle: z.string().nullable().optional(),
|
|
57
|
+
metaDescription: z.string().nullable().optional(),
|
|
58
|
+
titleTemplate: z.string().nullable().optional(),
|
|
59
|
+
robotsIndex: z.boolean().optional()
|
|
60
|
+
});
|
|
61
|
+
var StorefrontCmsSocialLinksSchema = z.object({
|
|
62
|
+
instagram: z.string().nullable().optional(),
|
|
63
|
+
facebook: z.string().nullable().optional(),
|
|
64
|
+
tiktok: z.string().nullable().optional(),
|
|
65
|
+
youtube: z.string().nullable().optional(),
|
|
66
|
+
x: z.string().nullable().optional()
|
|
67
|
+
});
|
|
68
|
+
var StorefrontCmsContactSchema = z.object({
|
|
69
|
+
supportEmail: z.string().nullable().optional(),
|
|
70
|
+
phone: z.string().nullable().optional(),
|
|
71
|
+
whatsapp: z.string().nullable().optional(),
|
|
72
|
+
address: z.string().nullable().optional(),
|
|
73
|
+
socialLinks: StorefrontCmsSocialLinksSchema.optional()
|
|
74
|
+
});
|
|
75
|
+
var StorefrontCmsTrackingSchema = z.object({
|
|
76
|
+
googleAnalyticsMeasurementId: z.string().nullable().optional(),
|
|
77
|
+
metaPixelId: z.string().nullable().optional(),
|
|
78
|
+
googleTagManagerContainerId: z.string().nullable().optional()
|
|
79
|
+
});
|
|
80
|
+
var StorefrontCmsCustomScriptsSchema = z.object({
|
|
81
|
+
enabled: z.boolean().optional(),
|
|
82
|
+
head: z.string().nullable().optional(),
|
|
83
|
+
bodyEnd: z.string().nullable().optional()
|
|
84
|
+
});
|
|
85
|
+
var StorefrontCmsSettingsSchema = z.object({
|
|
86
|
+
themeKey: z.string().optional(),
|
|
87
|
+
branding: StorefrontCmsBrandingSchema.optional(),
|
|
88
|
+
seo: StorefrontCmsSeoSchema.optional(),
|
|
89
|
+
contact: StorefrontCmsContactSchema.optional(),
|
|
90
|
+
tracking: StorefrontCmsTrackingSchema.optional(),
|
|
91
|
+
customScripts: StorefrontCmsCustomScriptsSchema.optional(),
|
|
92
|
+
updatedOn: z.string().nullable().optional()
|
|
93
|
+
});
|
|
94
|
+
var StorefrontCmsPageSchema = z.object({
|
|
95
|
+
id: z.string(),
|
|
96
|
+
name: z.string(),
|
|
97
|
+
slug: z.string(),
|
|
98
|
+
layout: z.string().optional(),
|
|
99
|
+
version: z.number().optional(),
|
|
100
|
+
settings: z.record(z.string(), z.unknown()).optional().nullable(),
|
|
101
|
+
sections: z.array(z.unknown()).optional(),
|
|
102
|
+
status: z.string().optional(),
|
|
103
|
+
hasPublishedVersion: z.boolean().optional(),
|
|
104
|
+
publishedOn: z.string().nullable().optional(),
|
|
105
|
+
publishedBy: z.string().nullable().optional(),
|
|
106
|
+
createdOn: z.string().nullable().optional(),
|
|
107
|
+
updatedOn: z.string().nullable().optional(),
|
|
108
|
+
createdBy: z.string().nullable().optional(),
|
|
109
|
+
updatedBy: z.string().nullable().optional(),
|
|
110
|
+
lastModifiedBy: z.string().nullable().optional()
|
|
111
|
+
}).passthrough();
|
|
112
|
+
var StorefrontSettingsLegacyFlatSchema = z.object({
|
|
113
|
+
id: z.coerce.string(),
|
|
114
|
+
tenantId: z.string().nullable().optional(),
|
|
115
|
+
name: z.string(),
|
|
116
|
+
slug: z.coerce.string().optional(),
|
|
117
|
+
description: z.string().nullable().optional(),
|
|
118
|
+
visibility: z.string().nullable().optional(),
|
|
119
|
+
logo: z.string().nullable().optional(),
|
|
120
|
+
favicon: z.string().nullable().optional(),
|
|
121
|
+
icon: z.string().nullable().optional(),
|
|
122
|
+
currency: z.string().nullable().optional(),
|
|
123
|
+
language: z.string().nullable().optional(),
|
|
124
|
+
themeConfig: z.unknown().optional().nullable(),
|
|
125
|
+
featuresEnabled: z.unknown().optional().nullable(),
|
|
126
|
+
checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable()
|
|
127
|
+
}).passthrough();
|
|
128
|
+
function unwrapSettingsResponseBody(v) {
|
|
129
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return v;
|
|
130
|
+
const o = v;
|
|
131
|
+
if ("data" in o && o.data != null && typeof o.data === "object" && !Array.isArray(o.data)) {
|
|
132
|
+
return o.data;
|
|
133
|
+
}
|
|
134
|
+
return v;
|
|
135
|
+
}
|
|
136
|
+
function isLegacyFlatSettingsPayload(v) {
|
|
137
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return false;
|
|
138
|
+
const o = v;
|
|
139
|
+
if ("store" in o || "schemaVersion" in o || "cms" in o) return false;
|
|
140
|
+
return (typeof o.id === "string" || typeof o.id === "number") && typeof o.name === "string";
|
|
141
|
+
}
|
|
142
|
+
function normalizeStorefrontSettingsPayload(v) {
|
|
143
|
+
const body = unwrapSettingsResponseBody(v);
|
|
144
|
+
if (!isLegacyFlatSettingsPayload(body)) return body;
|
|
145
|
+
const raw = body;
|
|
146
|
+
const parsed = StorefrontSettingsLegacyFlatSchema.safeParse(raw);
|
|
147
|
+
if (!parsed.success) return body;
|
|
148
|
+
const l = parsed.data;
|
|
149
|
+
const currency = l.currency?.trim() ? l.currency : "PEN";
|
|
150
|
+
const language = l.language?.trim() ? l.language : "es";
|
|
151
|
+
const slug = l.slug?.trim() ? l.slug : l.id;
|
|
152
|
+
return {
|
|
153
|
+
schemaVersion: 0,
|
|
154
|
+
generatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
155
|
+
store: {
|
|
156
|
+
id: l.id,
|
|
157
|
+
tenantId: l.tenantId ?? void 0,
|
|
158
|
+
name: l.name,
|
|
159
|
+
slug,
|
|
160
|
+
description: l.description ?? null,
|
|
161
|
+
logo: l.logo ?? null,
|
|
162
|
+
icon: l.icon ?? null,
|
|
163
|
+
visibility: l.visibility ?? void 0,
|
|
164
|
+
currency,
|
|
165
|
+
language,
|
|
166
|
+
themeConfig: l.themeConfig ?? void 0,
|
|
167
|
+
featuresEnabled: l.featuresEnabled ?? void 0,
|
|
168
|
+
checkoutSettings: l.checkoutSettings ?? void 0
|
|
169
|
+
},
|
|
170
|
+
cms: {
|
|
171
|
+
settings: {
|
|
172
|
+
branding: {
|
|
173
|
+
faviconUrl: l.favicon ?? null,
|
|
174
|
+
logoUrl: l.logo ?? null,
|
|
175
|
+
logoDarkUrl: null,
|
|
176
|
+
socialImageUrl: null
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
pages: []
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
var StorefrontStoreSchema = z.object({
|
|
184
|
+
id: z.string(),
|
|
185
|
+
tenantId: z.string().optional(),
|
|
186
|
+
sellerId: z.string().optional(),
|
|
187
|
+
plan: z.string().optional(),
|
|
188
|
+
storageLimitBytes: z.number().optional(),
|
|
189
|
+
monthlyTransferLimitBytes: z.number().optional(),
|
|
190
|
+
maxUploadSizeBytes: z.number().optional(),
|
|
191
|
+
maxStores: z.number().optional(),
|
|
192
|
+
maxMembers: z.number().optional(),
|
|
193
|
+
maxProducts: z.number().optional(),
|
|
194
|
+
maxCategories: z.number().optional(),
|
|
195
|
+
maxBrands: z.number().optional(),
|
|
196
|
+
maxAttributes: z.number().optional(),
|
|
197
|
+
maxCollections: z.number().optional(),
|
|
198
|
+
enableApi: z.boolean().optional(),
|
|
199
|
+
isActive: z.boolean().optional(),
|
|
200
|
+
name: z.string(),
|
|
201
|
+
description: z.string().nullable().optional(),
|
|
202
|
+
avatarUrl: z.string().nullable().optional(),
|
|
203
|
+
logo: z.string().nullable().optional(),
|
|
204
|
+
icon: z.string().nullable().optional(),
|
|
205
|
+
slug: z.string(),
|
|
206
|
+
domain: z.string().nullable().optional(),
|
|
207
|
+
domains: z.array(z.string()).optional(),
|
|
208
|
+
timeZone: z.string().nullable().optional(),
|
|
209
|
+
currency: z.string(),
|
|
210
|
+
language: z.string(),
|
|
211
|
+
visibility: z.string().optional(),
|
|
212
|
+
privateAccessHash: z.string().nullable().optional(),
|
|
213
|
+
privateAccessVersion: z.number().optional(),
|
|
214
|
+
themeConfig: StorefrontThemeConfigSchema.optional(),
|
|
215
|
+
featuresEnabled: StorefrontFeaturesEnabledSchema.optional(),
|
|
216
|
+
checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable()
|
|
217
|
+
}).passthrough();
|
|
218
|
+
var StorefrontSettingsEnvelopeSchema = z.object({
|
|
219
|
+
schemaVersion: z.number(),
|
|
220
|
+
generatedAt: z.string(),
|
|
221
|
+
store: StorefrontStoreSchema,
|
|
222
|
+
cms: z.object({
|
|
223
|
+
settings: StorefrontCmsSettingsSchema,
|
|
224
|
+
pages: z.array(StorefrontCmsPageSchema)
|
|
225
|
+
})
|
|
226
|
+
}).passthrough();
|
|
227
|
+
var StorefrontSettingsSchema = z.preprocess(
|
|
228
|
+
normalizeStorefrontSettingsPayload,
|
|
229
|
+
StorefrontSettingsEnvelopeSchema
|
|
230
|
+
);
|
|
231
|
+
function storefrontStoreRecord(settings) {
|
|
232
|
+
return settings?.store ?? null;
|
|
233
|
+
}
|
|
234
|
+
function storefrontFaviconUrl(settings) {
|
|
235
|
+
const b = settings?.cms?.settings?.branding;
|
|
236
|
+
return b?.faviconUrl ?? settings?.store?.logo ?? settings?.store?.icon ?? null;
|
|
237
|
+
}
|
|
238
|
+
function storefrontOgImageUrl(settings) {
|
|
239
|
+
const b = settings?.cms?.settings?.branding;
|
|
240
|
+
return b?.socialImageUrl ?? settings?.store?.logo ?? null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/core/lib/ecomiq-oauth-identity.ts
|
|
244
|
+
function buildEcomiqOAuthIdentityHeaders(settings) {
|
|
245
|
+
const record = storefrontStoreRecord(settings);
|
|
246
|
+
if (!record?.id) {
|
|
247
|
+
throw new Error("Tienda no disponible para iniciar sesi\xF3n");
|
|
248
|
+
}
|
|
249
|
+
const checkout = record.checkoutSettings;
|
|
250
|
+
const identityScope = checkout?.identityScope === "tenant" ? "tenant" : "store";
|
|
251
|
+
const headers = {
|
|
252
|
+
"x-Identity-Scope": identityScope,
|
|
253
|
+
"x-Store-Id": record.id
|
|
254
|
+
};
|
|
255
|
+
if (record.tenantId) headers["x-Tenant-Id"] = record.tenantId;
|
|
256
|
+
return headers;
|
|
257
|
+
}
|
|
27
258
|
|
|
28
259
|
// src/core/lib/customer-order-labels.ts
|
|
29
260
|
var ORDER_STATUS_LABELS = {
|
|
@@ -598,216 +829,6 @@ var PageService = class _PageService {
|
|
|
598
829
|
}
|
|
599
830
|
};
|
|
600
831
|
var pageService = PageService.getInstance();
|
|
601
|
-
var StorefrontCheckoutSettingsSchema = z.object({
|
|
602
|
-
allowGuestCheckout: z.boolean().optional(),
|
|
603
|
-
identityScope: z.enum(["store", "tenant", "global"]).optional(),
|
|
604
|
-
signInMethods: z.array(z.string()).optional()
|
|
605
|
-
});
|
|
606
|
-
var looseRecord = z.record(z.string(), z.unknown());
|
|
607
|
-
var StorefrontThemeConfigSchema = z.object({
|
|
608
|
-
name: z.string().nullable().optional(),
|
|
609
|
-
mode: z.string().nullable().optional(),
|
|
610
|
-
colors: looseRecord.optional(),
|
|
611
|
-
fonts: looseRecord.optional(),
|
|
612
|
-
assets: looseRecord.optional()
|
|
613
|
-
}).passthrough();
|
|
614
|
-
var StorefrontFeaturesEnabledSchema = z.object({
|
|
615
|
-
flags: looseRecord.optional()
|
|
616
|
-
}).passthrough();
|
|
617
|
-
var StorefrontCmsBrandingSchema = z.object({
|
|
618
|
-
logoUrl: z.string().nullable().optional(),
|
|
619
|
-
logoDarkUrl: z.string().nullable().optional(),
|
|
620
|
-
faviconUrl: z.string().nullable().optional(),
|
|
621
|
-
socialImageUrl: z.string().nullable().optional()
|
|
622
|
-
});
|
|
623
|
-
var StorefrontCmsSeoSchema = z.object({
|
|
624
|
-
siteName: z.string().nullable().optional(),
|
|
625
|
-
metaTitle: z.string().nullable().optional(),
|
|
626
|
-
metaDescription: z.string().nullable().optional(),
|
|
627
|
-
titleTemplate: z.string().nullable().optional(),
|
|
628
|
-
robotsIndex: z.boolean().optional()
|
|
629
|
-
});
|
|
630
|
-
var StorefrontCmsSocialLinksSchema = z.object({
|
|
631
|
-
instagram: z.string().nullable().optional(),
|
|
632
|
-
facebook: z.string().nullable().optional(),
|
|
633
|
-
tiktok: z.string().nullable().optional(),
|
|
634
|
-
youtube: z.string().nullable().optional(),
|
|
635
|
-
x: z.string().nullable().optional()
|
|
636
|
-
});
|
|
637
|
-
var StorefrontCmsContactSchema = z.object({
|
|
638
|
-
supportEmail: z.string().nullable().optional(),
|
|
639
|
-
phone: z.string().nullable().optional(),
|
|
640
|
-
whatsapp: z.string().nullable().optional(),
|
|
641
|
-
address: z.string().nullable().optional(),
|
|
642
|
-
socialLinks: StorefrontCmsSocialLinksSchema.optional()
|
|
643
|
-
});
|
|
644
|
-
var StorefrontCmsTrackingSchema = z.object({
|
|
645
|
-
googleAnalyticsMeasurementId: z.string().nullable().optional(),
|
|
646
|
-
metaPixelId: z.string().nullable().optional(),
|
|
647
|
-
googleTagManagerContainerId: z.string().nullable().optional()
|
|
648
|
-
});
|
|
649
|
-
var StorefrontCmsCustomScriptsSchema = z.object({
|
|
650
|
-
enabled: z.boolean().optional(),
|
|
651
|
-
head: z.string().nullable().optional(),
|
|
652
|
-
bodyEnd: z.string().nullable().optional()
|
|
653
|
-
});
|
|
654
|
-
var StorefrontCmsSettingsSchema = z.object({
|
|
655
|
-
themeKey: z.string().optional(),
|
|
656
|
-
branding: StorefrontCmsBrandingSchema.optional(),
|
|
657
|
-
seo: StorefrontCmsSeoSchema.optional(),
|
|
658
|
-
contact: StorefrontCmsContactSchema.optional(),
|
|
659
|
-
tracking: StorefrontCmsTrackingSchema.optional(),
|
|
660
|
-
customScripts: StorefrontCmsCustomScriptsSchema.optional(),
|
|
661
|
-
updatedOn: z.string().nullable().optional()
|
|
662
|
-
});
|
|
663
|
-
var StorefrontCmsPageSchema = z.object({
|
|
664
|
-
id: z.string(),
|
|
665
|
-
name: z.string(),
|
|
666
|
-
slug: z.string(),
|
|
667
|
-
layout: z.string().optional(),
|
|
668
|
-
version: z.number().optional(),
|
|
669
|
-
settings: z.record(z.string(), z.unknown()).optional().nullable(),
|
|
670
|
-
sections: z.array(z.unknown()).optional(),
|
|
671
|
-
status: z.string().optional(),
|
|
672
|
-
hasPublishedVersion: z.boolean().optional(),
|
|
673
|
-
publishedOn: z.string().nullable().optional(),
|
|
674
|
-
publishedBy: z.string().nullable().optional(),
|
|
675
|
-
createdOn: z.string().nullable().optional(),
|
|
676
|
-
updatedOn: z.string().nullable().optional(),
|
|
677
|
-
createdBy: z.string().nullable().optional(),
|
|
678
|
-
updatedBy: z.string().nullable().optional(),
|
|
679
|
-
lastModifiedBy: z.string().nullable().optional()
|
|
680
|
-
}).passthrough();
|
|
681
|
-
var StorefrontSettingsLegacyFlatSchema = z.object({
|
|
682
|
-
id: z.coerce.string(),
|
|
683
|
-
tenantId: z.string().nullable().optional(),
|
|
684
|
-
name: z.string(),
|
|
685
|
-
slug: z.coerce.string().optional(),
|
|
686
|
-
description: z.string().nullable().optional(),
|
|
687
|
-
visibility: z.string().nullable().optional(),
|
|
688
|
-
logo: z.string().nullable().optional(),
|
|
689
|
-
favicon: z.string().nullable().optional(),
|
|
690
|
-
icon: z.string().nullable().optional(),
|
|
691
|
-
currency: z.string().nullable().optional(),
|
|
692
|
-
language: z.string().nullable().optional(),
|
|
693
|
-
themeConfig: z.unknown().optional().nullable(),
|
|
694
|
-
featuresEnabled: z.unknown().optional().nullable(),
|
|
695
|
-
checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable()
|
|
696
|
-
}).passthrough();
|
|
697
|
-
function unwrapSettingsResponseBody(v) {
|
|
698
|
-
if (!v || typeof v !== "object" || Array.isArray(v)) return v;
|
|
699
|
-
const o = v;
|
|
700
|
-
if ("data" in o && o.data != null && typeof o.data === "object" && !Array.isArray(o.data)) {
|
|
701
|
-
return o.data;
|
|
702
|
-
}
|
|
703
|
-
return v;
|
|
704
|
-
}
|
|
705
|
-
function isLegacyFlatSettingsPayload(v) {
|
|
706
|
-
if (!v || typeof v !== "object" || Array.isArray(v)) return false;
|
|
707
|
-
const o = v;
|
|
708
|
-
if ("store" in o || "schemaVersion" in o || "cms" in o) return false;
|
|
709
|
-
return (typeof o.id === "string" || typeof o.id === "number") && typeof o.name === "string";
|
|
710
|
-
}
|
|
711
|
-
function normalizeStorefrontSettingsPayload(v) {
|
|
712
|
-
const body = unwrapSettingsResponseBody(v);
|
|
713
|
-
if (!isLegacyFlatSettingsPayload(body)) return body;
|
|
714
|
-
const raw = body;
|
|
715
|
-
const parsed = StorefrontSettingsLegacyFlatSchema.safeParse(raw);
|
|
716
|
-
if (!parsed.success) return body;
|
|
717
|
-
const l = parsed.data;
|
|
718
|
-
const currency = l.currency?.trim() ? l.currency : "PEN";
|
|
719
|
-
const language = l.language?.trim() ? l.language : "es";
|
|
720
|
-
const slug = l.slug?.trim() ? l.slug : l.id;
|
|
721
|
-
return {
|
|
722
|
-
schemaVersion: 0,
|
|
723
|
-
generatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
724
|
-
store: {
|
|
725
|
-
id: l.id,
|
|
726
|
-
tenantId: l.tenantId ?? void 0,
|
|
727
|
-
name: l.name,
|
|
728
|
-
slug,
|
|
729
|
-
description: l.description ?? null,
|
|
730
|
-
logo: l.logo ?? null,
|
|
731
|
-
icon: l.icon ?? null,
|
|
732
|
-
visibility: l.visibility ?? void 0,
|
|
733
|
-
currency,
|
|
734
|
-
language,
|
|
735
|
-
themeConfig: l.themeConfig ?? void 0,
|
|
736
|
-
featuresEnabled: l.featuresEnabled ?? void 0,
|
|
737
|
-
checkoutSettings: l.checkoutSettings ?? void 0
|
|
738
|
-
},
|
|
739
|
-
cms: {
|
|
740
|
-
settings: {
|
|
741
|
-
branding: {
|
|
742
|
-
faviconUrl: l.favicon ?? null,
|
|
743
|
-
logoUrl: l.logo ?? null,
|
|
744
|
-
logoDarkUrl: null,
|
|
745
|
-
socialImageUrl: null
|
|
746
|
-
}
|
|
747
|
-
},
|
|
748
|
-
pages: []
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
var StorefrontStoreSchema = z.object({
|
|
753
|
-
id: z.string(),
|
|
754
|
-
tenantId: z.string().optional(),
|
|
755
|
-
sellerId: z.string().optional(),
|
|
756
|
-
plan: z.string().optional(),
|
|
757
|
-
storageLimitBytes: z.number().optional(),
|
|
758
|
-
monthlyTransferLimitBytes: z.number().optional(),
|
|
759
|
-
maxUploadSizeBytes: z.number().optional(),
|
|
760
|
-
maxStores: z.number().optional(),
|
|
761
|
-
maxMembers: z.number().optional(),
|
|
762
|
-
maxProducts: z.number().optional(),
|
|
763
|
-
maxCategories: z.number().optional(),
|
|
764
|
-
maxBrands: z.number().optional(),
|
|
765
|
-
maxAttributes: z.number().optional(),
|
|
766
|
-
maxCollections: z.number().optional(),
|
|
767
|
-
enableApi: z.boolean().optional(),
|
|
768
|
-
isActive: z.boolean().optional(),
|
|
769
|
-
name: z.string(),
|
|
770
|
-
description: z.string().nullable().optional(),
|
|
771
|
-
avatarUrl: z.string().nullable().optional(),
|
|
772
|
-
logo: z.string().nullable().optional(),
|
|
773
|
-
icon: z.string().nullable().optional(),
|
|
774
|
-
slug: z.string(),
|
|
775
|
-
domain: z.string().nullable().optional(),
|
|
776
|
-
domains: z.array(z.string()).optional(),
|
|
777
|
-
timeZone: z.string().nullable().optional(),
|
|
778
|
-
currency: z.string(),
|
|
779
|
-
language: z.string(),
|
|
780
|
-
visibility: z.string().optional(),
|
|
781
|
-
privateAccessHash: z.string().nullable().optional(),
|
|
782
|
-
privateAccessVersion: z.number().optional(),
|
|
783
|
-
themeConfig: StorefrontThemeConfigSchema.optional(),
|
|
784
|
-
featuresEnabled: StorefrontFeaturesEnabledSchema.optional(),
|
|
785
|
-
checkoutSettings: StorefrontCheckoutSettingsSchema.optional().nullable()
|
|
786
|
-
}).passthrough();
|
|
787
|
-
var StorefrontSettingsEnvelopeSchema = z.object({
|
|
788
|
-
schemaVersion: z.number(),
|
|
789
|
-
generatedAt: z.string(),
|
|
790
|
-
store: StorefrontStoreSchema,
|
|
791
|
-
cms: z.object({
|
|
792
|
-
settings: StorefrontCmsSettingsSchema,
|
|
793
|
-
pages: z.array(StorefrontCmsPageSchema)
|
|
794
|
-
})
|
|
795
|
-
}).passthrough();
|
|
796
|
-
var StorefrontSettingsSchema = z.preprocess(
|
|
797
|
-
normalizeStorefrontSettingsPayload,
|
|
798
|
-
StorefrontSettingsEnvelopeSchema
|
|
799
|
-
);
|
|
800
|
-
function storefrontStoreRecord(settings) {
|
|
801
|
-
return settings?.store ?? null;
|
|
802
|
-
}
|
|
803
|
-
function storefrontFaviconUrl(settings) {
|
|
804
|
-
const b = settings?.cms?.settings?.branding;
|
|
805
|
-
return b?.faviconUrl ?? settings?.store?.logo ?? settings?.store?.icon ?? null;
|
|
806
|
-
}
|
|
807
|
-
function storefrontOgImageUrl(settings) {
|
|
808
|
-
const b = settings?.cms?.settings?.branding;
|
|
809
|
-
return b?.socialImageUrl ?? settings?.store?.logo ?? null;
|
|
810
|
-
}
|
|
811
832
|
|
|
812
833
|
// src/core/services/store.service.ts
|
|
813
834
|
var StoreService = class _StoreService {
|
|
@@ -1121,7 +1142,98 @@ var CartService = class _CartService {
|
|
|
1121
1142
|
}
|
|
1122
1143
|
};
|
|
1123
1144
|
var cartService = CartService.getInstance();
|
|
1145
|
+
var ECOMIQ_APP_APEX = "ecomiq.app";
|
|
1146
|
+
var ECOMIQ_APP_SUFFIX = [`.${ECOMIQ_APP_APEX}`, `.localhost`];
|
|
1147
|
+
function normalizeStoreHost(hostHeader) {
|
|
1148
|
+
let h = hostHeader.trim().toLowerCase();
|
|
1149
|
+
const colon = h.indexOf(":");
|
|
1150
|
+
if (colon !== -1) h = h.slice(0, colon);
|
|
1151
|
+
if (h.startsWith("www.")) h = h.slice(4);
|
|
1152
|
+
return h;
|
|
1153
|
+
}
|
|
1154
|
+
function resolveStorefrontSettingsHost(hostHeader) {
|
|
1155
|
+
const host = normalizeStoreHost(hostHeader);
|
|
1156
|
+
if (!host) {
|
|
1157
|
+
throw Object.assign(new Error("Host inv\xE1lido para tienda"), { status: 400 });
|
|
1158
|
+
}
|
|
1159
|
+
if (host === ECOMIQ_APP_APEX) {
|
|
1160
|
+
throw Object.assign(new Error("Host apex ecomiq.app sin slug de tienda"), { status: 400 });
|
|
1161
|
+
}
|
|
1162
|
+
if (ECOMIQ_APP_SUFFIX.some((suffix) => host.endsWith(suffix))) {
|
|
1163
|
+
const slug = host.slice(0, -(ECOMIQ_APP_SUFFIX.find((suffix) => host.endsWith(suffix))?.length ?? 0));
|
|
1164
|
+
if (!slug) {
|
|
1165
|
+
throw Object.assign(new Error("Host sin slug para ecomiq.app"), { status: 400 });
|
|
1166
|
+
}
|
|
1167
|
+
return slug;
|
|
1168
|
+
}
|
|
1169
|
+
return host;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
// src/core/config/ecomiq-config.ts
|
|
1173
|
+
var CONFIG_FILENAMES = [
|
|
1174
|
+
"ecomiq.config.js",
|
|
1175
|
+
"ecomiq.config.cjs",
|
|
1176
|
+
"ecomiq.config.mjs"
|
|
1177
|
+
];
|
|
1178
|
+
var EcomiqConfigSchema = z.object({
|
|
1179
|
+
/**
|
|
1180
|
+
* Slug de tienda en Ecomiq (p. ej. `mi-tienda` para `mi-tienda.ecomiq.app`).
|
|
1181
|
+
* Si está definido, tiene prioridad sobre el `Host` de la request (útil en `localhost`).
|
|
1182
|
+
*/
|
|
1183
|
+
slugStore: z.string().min(1).optional()
|
|
1184
|
+
});
|
|
1185
|
+
var cachedConfig;
|
|
1186
|
+
function parseExportedConfig(raw) {
|
|
1187
|
+
const candidate = raw && typeof raw === "object" && "default" in raw ? raw.default : raw;
|
|
1188
|
+
const parsed = EcomiqConfigSchema.safeParse(candidate);
|
|
1189
|
+
if (!parsed.success) {
|
|
1190
|
+
console.warn(
|
|
1191
|
+
"[ecomiq] ecomiq.config.* inv\xE1lido:",
|
|
1192
|
+
parsed.error.flatten().fieldErrors
|
|
1193
|
+
);
|
|
1194
|
+
return null;
|
|
1195
|
+
}
|
|
1196
|
+
const slugStore = parsed.data.slugStore?.trim();
|
|
1197
|
+
return slugStore ? { slugStore } : {};
|
|
1198
|
+
}
|
|
1199
|
+
function loadEcomiqConfig(cwd = process.cwd()) {
|
|
1200
|
+
if (cachedConfig !== void 0) return cachedConfig;
|
|
1201
|
+
for (const filename of CONFIG_FILENAMES) {
|
|
1202
|
+
const configPath = join(cwd, filename);
|
|
1203
|
+
if (!existsSync(configPath)) continue;
|
|
1204
|
+
try {
|
|
1205
|
+
const requireFromApp = createRequire(join(cwd, "package.json"));
|
|
1206
|
+
const loaded = requireFromApp(configPath);
|
|
1207
|
+
const parsed = parseExportedConfig(loaded);
|
|
1208
|
+
cachedConfig = parsed;
|
|
1209
|
+
return cachedConfig;
|
|
1210
|
+
} catch (error) {
|
|
1211
|
+
console.warn(`[ecomiq] No se pudo cargar ${configPath}:`, error);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
cachedConfig = null;
|
|
1215
|
+
return null;
|
|
1216
|
+
}
|
|
1217
|
+
function clearEcomiqConfigCache() {
|
|
1218
|
+
cachedConfig = void 0;
|
|
1219
|
+
}
|
|
1220
|
+
function resolvePublicStoreKey(hostHeader, cwd) {
|
|
1221
|
+
const slugFromConfig = loadEcomiqConfig(cwd)?.slugStore?.trim();
|
|
1222
|
+
if (slugFromConfig) return slugFromConfig;
|
|
1223
|
+
if (!hostHeader?.trim()) {
|
|
1224
|
+
throw Object.assign(
|
|
1225
|
+
new Error(
|
|
1226
|
+
"Host is required, o define slugStore en ecomiq.config.js en la ra\xEDz del proyecto"
|
|
1227
|
+
),
|
|
1228
|
+
{ status: 400 }
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1231
|
+
return resolveStorefrontSettingsHost(hostHeader);
|
|
1232
|
+
}
|
|
1233
|
+
function hasEcomiqSlugStoreConfig(cwd) {
|
|
1234
|
+
return Boolean(loadEcomiqConfig(cwd)?.slugStore?.trim());
|
|
1235
|
+
}
|
|
1124
1236
|
|
|
1125
|
-
export { CartAddressesRequestSchema, CartBuyerRequestSchema, CartCheckoutPaymentActionSchema, CartCheckoutPaymentSchema, CartCheckoutReadResponseSchema, CartCheckoutRequestSchema, CartCheckoutResponseSchema, CartCouponRequestSchema, CartCreateRequestSchema, CartItemModifierRequestSchema, CartItemRequestSchema, CartPaymentMethodSchema, CartPaymentMethodsResponseSchema, CartPaymentReceiptResponseSchema, CartResponseBundleItemSchema, CartResponseItemSchema, CartResponseSchema, CartShippingMethodPutRequestSchema, ProductSchema, ProductVariantSchema, ProductsFiltersSchema, ProductsResponseSchema, STOREFRONT_API_PATH_PREFIX, STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH, ShippingOptionGroupSchema, ShippingOptionsResponseSchema, ShippingRateSchema, StorefrontBundleItemSchema, StorefrontCheckoutSettingsSchema, StorefrontCollectionDetailSchema, StorefrontCollectionSchema, StorefrontCollectionsResponseSchema, StorefrontPageDetailSchema, StorefrontPageListItemSchema, StorefrontPriceTierSchema, StorefrontProductDetailSchema, StorefrontProductSchema, StorefrontProductsParamsSchema, StorefrontProductsResponseSchema, StorefrontSettingsLegacyFlatSchema, StorefrontSettingsSchema, StorefrontStoreSchema, apiClient, cartService, collectionService, countryCurrency, customerOrderStatusTone, fetchStorefrontGeoDistricts, fetchStorefrontGeoProvinces, formatCurrency, formatCustomerOrderStatus, formatOrderDate, formatOrderDateTime, loadStorefrontGeoDepartments, normalizeStorefrontSettingsPayload, pageService, productService, resolveIneiCodesFromLabels, storeService, storefrontFaviconUrl, storefrontOgImageUrl, storefrontStoreRecord, toGeoItems };
|
|
1237
|
+
export { CartAddressesRequestSchema, CartBuyerRequestSchema, CartCheckoutPaymentActionSchema, CartCheckoutPaymentSchema, CartCheckoutReadResponseSchema, CartCheckoutRequestSchema, CartCheckoutResponseSchema, CartCouponRequestSchema, CartCreateRequestSchema, CartItemModifierRequestSchema, CartItemRequestSchema, CartPaymentMethodSchema, CartPaymentMethodsResponseSchema, CartPaymentReceiptResponseSchema, CartResponseBundleItemSchema, CartResponseItemSchema, CartResponseSchema, CartShippingMethodPutRequestSchema, EcomiqConfigSchema, ProductSchema, ProductVariantSchema, ProductsFiltersSchema, ProductsResponseSchema, STOREFRONT_API_PATH_PREFIX, STOREFRONT_ECOMIQ_OAUTH_COOKIE_NAME, STOREFRONT_ECOMIQ_OAUTH_COOKIE_PATH, ShippingOptionGroupSchema, ShippingOptionsResponseSchema, ShippingRateSchema, StorefrontBundleItemSchema, StorefrontCheckoutSettingsSchema, StorefrontCollectionDetailSchema, StorefrontCollectionSchema, StorefrontCollectionsResponseSchema, StorefrontPageDetailSchema, StorefrontPageListItemSchema, StorefrontPriceTierSchema, StorefrontProductDetailSchema, StorefrontProductSchema, StorefrontProductsParamsSchema, StorefrontProductsResponseSchema, StorefrontSettingsLegacyFlatSchema, StorefrontSettingsSchema, StorefrontStoreSchema, apiClient, buildEcomiqOAuthIdentityHeaders, cartService, clearEcomiqConfigCache, collectionService, countryCurrency, customerOrderStatusTone, fetchStorefrontGeoDistricts, fetchStorefrontGeoProvinces, formatCurrency, formatCustomerOrderStatus, formatOrderDate, formatOrderDateTime, hasEcomiqSlugStoreConfig, loadEcomiqConfig, loadStorefrontGeoDepartments, normalizeStorefrontSettingsPayload, pageService, productService, resolveIneiCodesFromLabels, resolvePublicStoreKey, storeService, storefrontFaviconUrl, storefrontOgImageUrl, storefrontStoreRecord, toGeoItems };
|
|
1126
1238
|
//# sourceMappingURL=core.js.map
|
|
1127
1239
|
//# sourceMappingURL=core.js.map
|