@crayonscodetech/cms-sdk 1.0.1
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 +2689 -0
- package/dist/index.cjs +680 -0
- package/dist/index.d.cts +1112 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1112 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +645 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let react = require("react");
|
|
25
|
+
react = __toESM(react);
|
|
26
|
+
let lucide_react = require("lucide-react");
|
|
27
|
+
//#region src/constants/pageTypes.ts
|
|
28
|
+
const pageTypes = [
|
|
29
|
+
"home",
|
|
30
|
+
"about",
|
|
31
|
+
"contact"
|
|
32
|
+
];
|
|
33
|
+
const defaultPageTypes = [
|
|
34
|
+
...pageTypes,
|
|
35
|
+
"services",
|
|
36
|
+
"blog",
|
|
37
|
+
"team",
|
|
38
|
+
"gallery",
|
|
39
|
+
"events"
|
|
40
|
+
];
|
|
41
|
+
const allPageTypes = [
|
|
42
|
+
...pageTypes,
|
|
43
|
+
"custom",
|
|
44
|
+
"services",
|
|
45
|
+
"blog",
|
|
46
|
+
"team",
|
|
47
|
+
"gallery",
|
|
48
|
+
"events"
|
|
49
|
+
];
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/constants/index.ts
|
|
52
|
+
const PAGINATION = {
|
|
53
|
+
DEFAULT_PAGE: 1,
|
|
54
|
+
DEFAULT_LIMIT: 10,
|
|
55
|
+
BLOGS_PER_PAGE: 9,
|
|
56
|
+
EVENTS_PER_PAGE: 9,
|
|
57
|
+
ALBUMS_PER_PAGE: 9,
|
|
58
|
+
MAX_ITEMS_FOR_SSG: 200
|
|
59
|
+
};
|
|
60
|
+
const SEARCH = {
|
|
61
|
+
DEBOUNCE_MS: 500,
|
|
62
|
+
MIN_QUERY_LENGTH: 2
|
|
63
|
+
};
|
|
64
|
+
const CACHE = {
|
|
65
|
+
NO_CACHE: 0,
|
|
66
|
+
SHORT: 60,
|
|
67
|
+
MEDIUM: 300,
|
|
68
|
+
LONG: 3600,
|
|
69
|
+
STATIC: 86400
|
|
70
|
+
};
|
|
71
|
+
const ANIMATION = {
|
|
72
|
+
FAST: .2,
|
|
73
|
+
NORMAL: .3,
|
|
74
|
+
SLOW: .6
|
|
75
|
+
};
|
|
76
|
+
const CONTACT_SUBJECTS = [
|
|
77
|
+
"General Inquiry",
|
|
78
|
+
"Project Proposal",
|
|
79
|
+
"Careers",
|
|
80
|
+
"Other"
|
|
81
|
+
];
|
|
82
|
+
const HTTP_STATUS = {
|
|
83
|
+
OK: 200,
|
|
84
|
+
CREATED: 201,
|
|
85
|
+
BAD_REQUEST: 400,
|
|
86
|
+
UNAUTHORIZED: 401,
|
|
87
|
+
FORBIDDEN: 403,
|
|
88
|
+
NOT_FOUND: 404,
|
|
89
|
+
INTERNAL_ERROR: 500
|
|
90
|
+
};
|
|
91
|
+
const MEDIA = {
|
|
92
|
+
IMAGE_EXTENSIONS: [
|
|
93
|
+
".jpg",
|
|
94
|
+
".jpeg",
|
|
95
|
+
".png",
|
|
96
|
+
".gif",
|
|
97
|
+
".webp",
|
|
98
|
+
".svg"
|
|
99
|
+
],
|
|
100
|
+
VIDEO_EXTENSIONS: [
|
|
101
|
+
".mp4",
|
|
102
|
+
".webm",
|
|
103
|
+
".ogg"
|
|
104
|
+
],
|
|
105
|
+
MAX_IMAGE_SIZE: 5 * 1024 * 1024
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/core/client.ts
|
|
109
|
+
var CmsError = class extends Error {
|
|
110
|
+
message;
|
|
111
|
+
status;
|
|
112
|
+
url;
|
|
113
|
+
constructor(message, status, url) {
|
|
114
|
+
super(message);
|
|
115
|
+
this.message = message;
|
|
116
|
+
this.status = status;
|
|
117
|
+
this.url = url;
|
|
118
|
+
this.name = "CmsError";
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
122
|
+
function createCmsClient(config) {
|
|
123
|
+
const { baseUrl, defaultOptions = {} } = config;
|
|
124
|
+
async function cmsFetch(endpoint, options = {}, retries = 2) {
|
|
125
|
+
const url = `${baseUrl}${endpoint}`;
|
|
126
|
+
const { revalidate = CACHE.NO_CACHE, tags, ...rest } = {
|
|
127
|
+
...defaultOptions,
|
|
128
|
+
...options
|
|
129
|
+
};
|
|
130
|
+
const fetchConfig = {
|
|
131
|
+
...rest,
|
|
132
|
+
next: {
|
|
133
|
+
revalidate,
|
|
134
|
+
...tags && { tags }
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
let lastError = null;
|
|
138
|
+
for (let attempt = 0; attempt <= retries; attempt++) try {
|
|
139
|
+
const response = await fetch(url, fetchConfig);
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
const errorMsg = `API request failed: ${response.status} ${url}`;
|
|
142
|
+
console.error(errorMsg);
|
|
143
|
+
if (attempt < retries && [
|
|
144
|
+
502,
|
|
145
|
+
503,
|
|
146
|
+
504
|
|
147
|
+
].includes(response.status)) {
|
|
148
|
+
await sleep(Math.pow(2, attempt) * 1e3);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const result = await response.json();
|
|
154
|
+
return result.data ?? result;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
157
|
+
console.error(`API request error (attempt ${attempt + 1}/${retries + 1}): ${url}`, lastError);
|
|
158
|
+
if (attempt < retries) {
|
|
159
|
+
await sleep(Math.pow(2, attempt) * 1e3);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
async function cmsFetchPaginated(endpoint, options = {}, retries = 2) {
|
|
166
|
+
const emptyResponse = {
|
|
167
|
+
data: [],
|
|
168
|
+
pagination: {
|
|
169
|
+
page: 1,
|
|
170
|
+
limit: PAGINATION.DEFAULT_LIMIT,
|
|
171
|
+
total: 0
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const url = `${baseUrl}${endpoint}`;
|
|
175
|
+
const { revalidate = CACHE.NO_CACHE, tags, ...rest } = {
|
|
176
|
+
...defaultOptions,
|
|
177
|
+
...options
|
|
178
|
+
};
|
|
179
|
+
const fetchConfig = {
|
|
180
|
+
...rest,
|
|
181
|
+
next: {
|
|
182
|
+
revalidate,
|
|
183
|
+
...tags && { tags }
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
for (let attempt = 0; attempt <= retries; attempt++) try {
|
|
187
|
+
const response = await fetch(url, fetchConfig);
|
|
188
|
+
if (!response.ok) {
|
|
189
|
+
console.error(`API request failed: ${response.status} ${url}`);
|
|
190
|
+
if (attempt < retries && [
|
|
191
|
+
502,
|
|
192
|
+
503,
|
|
193
|
+
504
|
|
194
|
+
].includes(response.status)) {
|
|
195
|
+
await sleep(Math.pow(2, attempt) * 1e3);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
return emptyResponse;
|
|
199
|
+
}
|
|
200
|
+
return await response.json();
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error(`API request error (attempt ${attempt + 1}/${retries + 1}): ${url}`, error);
|
|
203
|
+
if (attempt < retries) {
|
|
204
|
+
await sleep(Math.pow(2, attempt) * 1e3);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return emptyResponse;
|
|
209
|
+
}
|
|
210
|
+
function buildQueryString(params) {
|
|
211
|
+
const query = new URLSearchParams();
|
|
212
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
213
|
+
if (value !== void 0 && value !== null) if (Array.isArray(value)) value.forEach((v) => query.append(key, String(v)));
|
|
214
|
+
else query.append(key, String(value));
|
|
215
|
+
});
|
|
216
|
+
return query.toString();
|
|
217
|
+
}
|
|
218
|
+
function fetchHeader(siteId, options) {
|
|
219
|
+
return cmsFetch(`/api/public/cms/${siteId}/header/`, {
|
|
220
|
+
revalidate: CACHE.MEDIUM,
|
|
221
|
+
tags: ["header"],
|
|
222
|
+
...options
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function fetchFooter(siteId, options) {
|
|
226
|
+
return cmsFetch(`/api/public/cms/${siteId}/footer/`, {
|
|
227
|
+
revalidate: CACHE.MEDIUM,
|
|
228
|
+
tags: ["footer"],
|
|
229
|
+
...options
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function fetchSiteConfig(siteId, options) {
|
|
233
|
+
return cmsFetch(`/api/public/cms/${siteId}/site-config/`, {
|
|
234
|
+
revalidate: CACHE.MEDIUM,
|
|
235
|
+
tags: ["site-config"],
|
|
236
|
+
...options
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function fetchPages(siteId, params = {}, options) {
|
|
240
|
+
return cmsFetchPaginated(`/api/public/cms/${siteId}/page/?${buildQueryString(params)}`, {
|
|
241
|
+
revalidate: CACHE.SHORT,
|
|
242
|
+
tags: ["pages"],
|
|
243
|
+
...options
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
async function fetchPageByUrl(siteId, urlPath, options) {
|
|
247
|
+
try {
|
|
248
|
+
const targetUrl = urlPath === "/" || urlPath === "" ? "/" : `/${urlPath.replace(/^\/|\/$/g, "")}`;
|
|
249
|
+
return await cmsFetch(`/api/public/cms/${siteId}/page/by-url/?url=${encodeURIComponent(targetUrl)}`, {
|
|
250
|
+
revalidate: CACHE.SHORT,
|
|
251
|
+
tags: ["pages", `page-${targetUrl || "root"}`],
|
|
252
|
+
...options
|
|
253
|
+
});
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.error(`Error in fetchPageByUrl for ${urlPath}:`, error);
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function fetchAboutUs(siteId, options) {
|
|
260
|
+
return cmsFetch(`/api/public/cms/${siteId}/about-us/`, {
|
|
261
|
+
revalidate: CACHE.MEDIUM,
|
|
262
|
+
tags: ["about"],
|
|
263
|
+
...options
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
async function fetchServices(siteId, options) {
|
|
267
|
+
return await cmsFetch(`/api/public/cms/${siteId}/services/`, {
|
|
268
|
+
revalidate: CACHE.SHORT,
|
|
269
|
+
tags: ["services"],
|
|
270
|
+
...options
|
|
271
|
+
}) ?? [];
|
|
272
|
+
}
|
|
273
|
+
function fetchServiceById(siteId, id, options) {
|
|
274
|
+
return cmsFetch(`/api/public/cms/${siteId}/services/${id}/`, {
|
|
275
|
+
revalidate: CACHE.SHORT,
|
|
276
|
+
tags: ["services", `service-${id}`],
|
|
277
|
+
...options
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function fetchBlogs(siteId, params = {}, options) {
|
|
281
|
+
return cmsFetchPaginated(`/api/public/cms/${siteId}/blog/?${buildQueryString(params)}`, {
|
|
282
|
+
revalidate: CACHE.SHORT,
|
|
283
|
+
tags: ["blogs"],
|
|
284
|
+
...options
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function fetchBlogBySlug(siteId, slug, options) {
|
|
288
|
+
return cmsFetch(`/api/public/cms/${siteId}/blog/${slug}`, {
|
|
289
|
+
revalidate: CACHE.SHORT,
|
|
290
|
+
tags: ["blogs", `blog-${slug}`],
|
|
291
|
+
...options
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function fetchBlogById(siteId, idOrSlug, options) {
|
|
295
|
+
return fetchBlogBySlug(siteId, String(idOrSlug), options);
|
|
296
|
+
}
|
|
297
|
+
async function fetchCategories(siteId, options) {
|
|
298
|
+
return await cmsFetch(`/api/public/cms/${siteId}/categories/`, {
|
|
299
|
+
revalidate: CACHE.MEDIUM,
|
|
300
|
+
tags: ["categories"],
|
|
301
|
+
...options
|
|
302
|
+
}) ?? [];
|
|
303
|
+
}
|
|
304
|
+
async function fetchTeamMembers(siteId, options) {
|
|
305
|
+
return await cmsFetch(`/api/public/cms/${siteId}/team-members/`, {
|
|
306
|
+
revalidate: CACHE.MEDIUM,
|
|
307
|
+
tags: ["team"],
|
|
308
|
+
...options
|
|
309
|
+
}) ?? [];
|
|
310
|
+
}
|
|
311
|
+
async function fetchTeamMembersByCategory(siteId, categoryId, options) {
|
|
312
|
+
return await cmsFetch(`/api/public/cms/${siteId}/team-members/?category_id=${categoryId}`, {
|
|
313
|
+
revalidate: CACHE.MEDIUM,
|
|
314
|
+
tags: ["team", `team-category-${categoryId}`],
|
|
315
|
+
...options
|
|
316
|
+
}) ?? [];
|
|
317
|
+
}
|
|
318
|
+
function fetchAlbums(siteId, params = {}, options) {
|
|
319
|
+
return cmsFetchPaginated(`/api/public/cms/${siteId}/albums/?${buildQueryString(params)}`, {
|
|
320
|
+
revalidate: CACHE.SHORT,
|
|
321
|
+
tags: ["albums"],
|
|
322
|
+
...options
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async function fetchAlbumItems(siteId, params, options) {
|
|
326
|
+
return await cmsFetch(`/api/public/cms/${siteId}/albums/album-items/?${buildQueryString(params)}`, {
|
|
327
|
+
revalidate: CACHE.SHORT,
|
|
328
|
+
tags: ["album-items"],
|
|
329
|
+
...options
|
|
330
|
+
}) ?? [];
|
|
331
|
+
}
|
|
332
|
+
async function fetchBrandGroups(siteId, options) {
|
|
333
|
+
return await cmsFetch(`/api/public/cms/${siteId}/brand-groups/`, {
|
|
334
|
+
revalidate: CACHE.MEDIUM,
|
|
335
|
+
tags: ["brand-groups"],
|
|
336
|
+
...options
|
|
337
|
+
}) ?? [];
|
|
338
|
+
}
|
|
339
|
+
async function fetchBrands(siteId, params, options) {
|
|
340
|
+
return await cmsFetch(`/api/public/cms/${siteId}/brand-groups/brands/?${buildQueryString(params)}`, {
|
|
341
|
+
revalidate: CACHE.MEDIUM,
|
|
342
|
+
tags: ["brands"],
|
|
343
|
+
...options
|
|
344
|
+
}) ?? [];
|
|
345
|
+
}
|
|
346
|
+
async function fetchTestimonials(siteId, params, options) {
|
|
347
|
+
return await cmsFetch(`/api/public/cms/${siteId}/testimonials/?${params?.type ? buildQueryString({ type: params.type }) : ""}`, {
|
|
348
|
+
revalidate: CACHE.MEDIUM,
|
|
349
|
+
tags: ["testimonials"],
|
|
350
|
+
...options
|
|
351
|
+
}) ?? [];
|
|
352
|
+
}
|
|
353
|
+
function fetchEvents(siteId, params = {}, options) {
|
|
354
|
+
return cmsFetchPaginated(`/api/public/cms/${siteId}/events/?${buildQueryString(params)}`, {
|
|
355
|
+
revalidate: CACHE.SHORT,
|
|
356
|
+
tags: ["events"],
|
|
357
|
+
...options
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function fetchEventBySlug(siteId, slug, options) {
|
|
361
|
+
return cmsFetch(`/api/public/cms/${siteId}/events/${slug}`, {
|
|
362
|
+
revalidate: CACHE.SHORT,
|
|
363
|
+
tags: ["events", `event-${slug}`],
|
|
364
|
+
...options
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
async function fetchFaqGroups(siteId, options) {
|
|
368
|
+
return await cmsFetch(`/api/public/cms/${siteId}/faq-groups/`, {
|
|
369
|
+
revalidate: CACHE.MEDIUM,
|
|
370
|
+
tags: ["faq-groups"],
|
|
371
|
+
...options
|
|
372
|
+
}) ?? [];
|
|
373
|
+
}
|
|
374
|
+
async function submitContactForm(siteId, payload, options) {
|
|
375
|
+
return cmsFetch(`/api/public/cms/${siteId}/contact/`, {
|
|
376
|
+
method: "POST",
|
|
377
|
+
headers: { "Content-Type": "application/json" },
|
|
378
|
+
body: JSON.stringify(payload),
|
|
379
|
+
revalidate: CACHE.NO_CACHE,
|
|
380
|
+
...options
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
async function fetchFaqs(siteId, params, options) {
|
|
384
|
+
return await cmsFetch(`/api/public/cms/${siteId}/faqs/?${params?.group_id ? buildQueryString({ group_id: params.group_id }) : ""}`, {
|
|
385
|
+
revalidate: CACHE.MEDIUM,
|
|
386
|
+
tags: ["faqs"],
|
|
387
|
+
...options
|
|
388
|
+
}) ?? [];
|
|
389
|
+
}
|
|
390
|
+
async function fetchRedirects(siteId, options) {
|
|
391
|
+
return await cmsFetch(`/api/public/cms/${siteId}/redirects/`, {
|
|
392
|
+
revalidate: CACHE.SHORT,
|
|
393
|
+
tags: ["redirects"],
|
|
394
|
+
...options
|
|
395
|
+
}) ?? [];
|
|
396
|
+
}
|
|
397
|
+
function resolveRedirect(siteId, sourcePath, options) {
|
|
398
|
+
return cmsFetch(`/api/public/cms/${siteId}/redirects/resolve/?sourcePath=${encodeURIComponent(sourcePath)}`, {
|
|
399
|
+
revalidate: CACHE.NO_CACHE,
|
|
400
|
+
tags: ["redirects", `redirect-${sourcePath}`],
|
|
401
|
+
...options
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
function reportRedirect404(siteId, sourcePath, referrer, options) {
|
|
405
|
+
const headers = {
|
|
406
|
+
"Content-Type": "application/json",
|
|
407
|
+
...options?.headers ?? {}
|
|
408
|
+
};
|
|
409
|
+
return cmsFetch(`/api/public/cms/${siteId}/redirects/404-logs/`, {
|
|
410
|
+
method: "POST",
|
|
411
|
+
...options,
|
|
412
|
+
headers,
|
|
413
|
+
body: JSON.stringify({
|
|
414
|
+
source_path: sourcePath,
|
|
415
|
+
referrer
|
|
416
|
+
}),
|
|
417
|
+
revalidate: CACHE.NO_CACHE,
|
|
418
|
+
tags: ["redirects", "redirect-404-logs"]
|
|
419
|
+
}, 0);
|
|
420
|
+
}
|
|
421
|
+
function fetchStoreSettings(siteId, options) {
|
|
422
|
+
return cmsFetch(`/api/public/store/${siteId}/settings/`, {
|
|
423
|
+
revalidate: CACHE.MEDIUM,
|
|
424
|
+
tags: ["store-settings"],
|
|
425
|
+
...options
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function fetchProductCategories(siteId, params = {}, options) {
|
|
429
|
+
const query = buildQueryString(params);
|
|
430
|
+
return cmsFetchPaginated(`/api/public/store/${siteId}/categories/${query ? `?${query}` : ""}`, {
|
|
431
|
+
revalidate: CACHE.SHORT,
|
|
432
|
+
tags: ["product-categories"],
|
|
433
|
+
...options
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
function fetchProductBrands(siteId, params = {}, options) {
|
|
437
|
+
const query = buildQueryString(params);
|
|
438
|
+
return cmsFetchPaginated(`/api/public/store/${siteId}/brands/${query ? `?${query}` : ""}`, {
|
|
439
|
+
revalidate: CACHE.SHORT,
|
|
440
|
+
tags: ["product-brands"],
|
|
441
|
+
...options
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
function fetchProducts(siteId, params = {}, options) {
|
|
445
|
+
return cmsFetchPaginated(`/api/public/store/${siteId}/products/?${buildQueryString(params)}`, {
|
|
446
|
+
revalidate: CACHE.SHORT,
|
|
447
|
+
tags: ["products"],
|
|
448
|
+
...options
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
function fetchProductDetail(siteId, slug, options) {
|
|
452
|
+
return cmsFetch(`/api/public/store/${siteId}/products/${slug}/`, {
|
|
453
|
+
revalidate: CACHE.SHORT,
|
|
454
|
+
tags: ["products", `product-${slug}`],
|
|
455
|
+
...options
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function fetchProductsByTag(siteId, tag, params = {}, options) {
|
|
459
|
+
const query = buildQueryString({
|
|
460
|
+
tag,
|
|
461
|
+
...params
|
|
462
|
+
});
|
|
463
|
+
return cmsFetch(`/api/public/store/${siteId}/products/by-tag/${query ? `?${query}` : ""}`, {
|
|
464
|
+
revalidate: CACHE.SHORT,
|
|
465
|
+
tags: ["products", `products-tag-${tag}`],
|
|
466
|
+
...options
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
function fetchCollections(siteId, params = {}, options) {
|
|
470
|
+
const query = buildQueryString(params);
|
|
471
|
+
return cmsFetchPaginated(`/api/public/store/${siteId}/collections/${query ? `?${query}` : ""}`, {
|
|
472
|
+
revalidate: CACHE.SHORT,
|
|
473
|
+
tags: ["collections"],
|
|
474
|
+
...options
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function fetchCollectionDetail(siteId, slug, params = {}, options) {
|
|
478
|
+
const query = buildQueryString(params);
|
|
479
|
+
return cmsFetch(`/api/public/store/${siteId}/collections/${slug}/${query ? `?${query}` : ""}`, {
|
|
480
|
+
revalidate: CACHE.SHORT,
|
|
481
|
+
tags: ["collections", `collection-${slug}`],
|
|
482
|
+
...options
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
function fetchCollectionDetailById(siteId, id, params = {}, options) {
|
|
486
|
+
const query = buildQueryString(params);
|
|
487
|
+
return cmsFetch(`/api/public/store/${siteId}/collections/id/${id}/${query ? `?${query}` : ""}`, {
|
|
488
|
+
revalidate: CACHE.SHORT,
|
|
489
|
+
tags: ["collections", `collection-${id}`],
|
|
490
|
+
...options
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
function placeOrder(siteId, payload, options) {
|
|
494
|
+
return cmsFetch(`/api/public/store/${siteId}/orders/`, {
|
|
495
|
+
method: "POST",
|
|
496
|
+
headers: { "Content-Type": "application/json" },
|
|
497
|
+
body: JSON.stringify(payload),
|
|
498
|
+
revalidate: CACHE.NO_CACHE,
|
|
499
|
+
...options
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
fetchHeader,
|
|
504
|
+
fetchFooter,
|
|
505
|
+
fetchSiteConfig,
|
|
506
|
+
fetchPages,
|
|
507
|
+
fetchPageByUrl,
|
|
508
|
+
fetchAboutUs,
|
|
509
|
+
fetchServices,
|
|
510
|
+
fetchServiceById,
|
|
511
|
+
fetchBlogs,
|
|
512
|
+
fetchBlogBySlug,
|
|
513
|
+
fetchBlogById,
|
|
514
|
+
fetchCategories,
|
|
515
|
+
fetchTeamMembers,
|
|
516
|
+
fetchTeamMembersByCategory,
|
|
517
|
+
fetchAlbums,
|
|
518
|
+
fetchAlbumItems,
|
|
519
|
+
fetchBrandGroups,
|
|
520
|
+
fetchBrands,
|
|
521
|
+
fetchTestimonials,
|
|
522
|
+
fetchEvents,
|
|
523
|
+
fetchEventBySlug,
|
|
524
|
+
fetchFaqGroups,
|
|
525
|
+
fetchFaqs,
|
|
526
|
+
fetchRedirects,
|
|
527
|
+
resolveRedirect,
|
|
528
|
+
reportRedirect404,
|
|
529
|
+
submitContactForm,
|
|
530
|
+
fetchStoreSettings,
|
|
531
|
+
fetchProductCategories,
|
|
532
|
+
fetchProductBrands,
|
|
533
|
+
fetchProducts,
|
|
534
|
+
fetchProductDetail,
|
|
535
|
+
fetchProductsByTag,
|
|
536
|
+
fetchCollections,
|
|
537
|
+
fetchCollectionDetail,
|
|
538
|
+
fetchCollectionDetailById,
|
|
539
|
+
placeOrder,
|
|
540
|
+
fetch: cmsFetch,
|
|
541
|
+
fetchPaginated: cmsFetchPaginated,
|
|
542
|
+
utils: { buildQueryString }
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/components/Icon.tsx
|
|
547
|
+
/**
|
|
548
|
+
* A exhaustive map of Lucide icons commonly used in the CMS.
|
|
549
|
+
*/
|
|
550
|
+
const ICON_MAP = {
|
|
551
|
+
Home: lucide_react.Home,
|
|
552
|
+
User: lucide_react.User,
|
|
553
|
+
Settings: lucide_react.Settings,
|
|
554
|
+
Mail: lucide_react.Mail,
|
|
555
|
+
Bell: lucide_react.Bell,
|
|
556
|
+
Calendar: lucide_react.Calendar,
|
|
557
|
+
Star: lucide_react.Star,
|
|
558
|
+
Heart: lucide_react.Heart,
|
|
559
|
+
Bookmark: lucide_react.Bookmark,
|
|
560
|
+
Search: lucide_react.Search,
|
|
561
|
+
Filter: lucide_react.Filter,
|
|
562
|
+
Download: lucide_react.Download,
|
|
563
|
+
Upload: lucide_react.Upload,
|
|
564
|
+
Trash: lucide_react.Trash,
|
|
565
|
+
Edit: lucide_react.Edit,
|
|
566
|
+
Plus: lucide_react.Plus,
|
|
567
|
+
Minus: lucide_react.Minus,
|
|
568
|
+
Check: lucide_react.Check,
|
|
569
|
+
X: lucide_react.X,
|
|
570
|
+
ChevronRight: lucide_react.ChevronRight,
|
|
571
|
+
ChevronLeft: lucide_react.ChevronLeft,
|
|
572
|
+
ChevronUp: lucide_react.ChevronUp,
|
|
573
|
+
ChevronDown: lucide_react.ChevronDown,
|
|
574
|
+
ChevronsUpDown: lucide_react.ChevronsUpDown,
|
|
575
|
+
ArrowRight: lucide_react.ArrowRight,
|
|
576
|
+
ArrowLeft: lucide_react.ArrowLeft,
|
|
577
|
+
ArrowUp: lucide_react.ArrowUp,
|
|
578
|
+
ArrowDown: lucide_react.ArrowDown,
|
|
579
|
+
File: lucide_react.File,
|
|
580
|
+
Folder: lucide_react.Folder,
|
|
581
|
+
Image: lucide_react.Image,
|
|
582
|
+
Video: lucide_react.Video,
|
|
583
|
+
Music: lucide_react.Music,
|
|
584
|
+
Lock: lucide_react.Lock,
|
|
585
|
+
Unlock: lucide_react.Unlock,
|
|
586
|
+
Eye: lucide_react.Eye,
|
|
587
|
+
EyeOff: lucide_react.EyeOff,
|
|
588
|
+
Sun: lucide_react.Sun,
|
|
589
|
+
Moon: lucide_react.Moon,
|
|
590
|
+
Cloud: lucide_react.Cloud,
|
|
591
|
+
Zap: lucide_react.Zap,
|
|
592
|
+
Activity: lucide_react.Activity,
|
|
593
|
+
TrendingUp: lucide_react.TrendingUp,
|
|
594
|
+
TrendingDown: lucide_react.TrendingDown,
|
|
595
|
+
BarChart: lucide_react.BarChart,
|
|
596
|
+
PieChart: lucide_react.PieChart,
|
|
597
|
+
Database: lucide_react.Database,
|
|
598
|
+
Server: lucide_react.Server,
|
|
599
|
+
Wifi: lucide_react.Wifi,
|
|
600
|
+
Battery: lucide_react.Battery,
|
|
601
|
+
Camera: lucide_react.Camera,
|
|
602
|
+
Mic: lucide_react.Mic,
|
|
603
|
+
Phone: lucide_react.Phone,
|
|
604
|
+
MessageSquare: lucide_react.MessageSquare,
|
|
605
|
+
Send: lucide_react.Send,
|
|
606
|
+
Share: lucide_react.Share,
|
|
607
|
+
Link: lucide_react.Link,
|
|
608
|
+
ExternalLink: lucide_react.ExternalLink,
|
|
609
|
+
Globe: lucide_react.Globe,
|
|
610
|
+
MapPin: lucide_react.MapPin,
|
|
611
|
+
Users: lucide_react.Users,
|
|
612
|
+
ShoppingCart: lucide_react.ShoppingCart,
|
|
613
|
+
CreditCard: lucide_react.CreditCard,
|
|
614
|
+
Package: lucide_react.Package,
|
|
615
|
+
Briefcase: lucide_react.Briefcase,
|
|
616
|
+
Target: lucide_react.Target,
|
|
617
|
+
Flag: lucide_react.Flag,
|
|
618
|
+
Clipboard: lucide_react.Clipboard,
|
|
619
|
+
List: lucide_react.List,
|
|
620
|
+
Grid: lucide_react.Grid,
|
|
621
|
+
Layout: lucide_react.Layout,
|
|
622
|
+
Layers: lucide_react.Layers,
|
|
623
|
+
Copy: lucide_react.Copy,
|
|
624
|
+
Save: lucide_react.Save,
|
|
625
|
+
RefreshCw: lucide_react.RefreshCw,
|
|
626
|
+
Maximize: lucide_react.Maximize,
|
|
627
|
+
Code: lucide_react.Code,
|
|
628
|
+
AlertCircle: lucide_react.AlertCircle,
|
|
629
|
+
Info: lucide_react.Info,
|
|
630
|
+
HelpCircle: lucide_react.HelpCircle,
|
|
631
|
+
CheckCircle: lucide_react.CheckCircle,
|
|
632
|
+
XCircle: lucide_react.XCircle,
|
|
633
|
+
Menu: lucide_react.Menu,
|
|
634
|
+
MoreVertical: lucide_react.MoreVertical,
|
|
635
|
+
MoreHorizontal: lucide_react.MoreHorizontal,
|
|
636
|
+
PlayCircle: lucide_react.PlayCircle,
|
|
637
|
+
PauseCircle: lucide_react.PauseCircle,
|
|
638
|
+
LogIn: lucide_react.LogIn,
|
|
639
|
+
LogOut: lucide_react.LogOut,
|
|
640
|
+
UserPlus: lucide_react.UserPlus,
|
|
641
|
+
UserMinus: lucide_react.UserMinus,
|
|
642
|
+
Tag: lucide_react.Tag,
|
|
643
|
+
Award: lucide_react.Award,
|
|
644
|
+
Gift: lucide_react.Gift,
|
|
645
|
+
Truck: lucide_react.Truck,
|
|
646
|
+
Clock: lucide_react.Clock,
|
|
647
|
+
Handshake: lucide_react.Handshake,
|
|
648
|
+
Stethoscope: lucide_react.Stethoscope,
|
|
649
|
+
Microscope: lucide_react.Microscope,
|
|
650
|
+
GraduationCap: lucide_react.GraduationCap,
|
|
651
|
+
BookOpen: lucide_react.BookOpen,
|
|
652
|
+
Building2: lucide_react.Building2,
|
|
653
|
+
Trees: lucide_react.Trees,
|
|
654
|
+
HeartHandshake: lucide_react.HeartHandshake,
|
|
655
|
+
Brain: lucide_react.Brain,
|
|
656
|
+
Lightbulb: lucide_react.Lightbulb
|
|
657
|
+
};
|
|
658
|
+
/**
|
|
659
|
+
* Dynamic Icon component that renders Lucide icons by name.
|
|
660
|
+
* Useful for CMS-driven icons where names are stored as strings.
|
|
661
|
+
*/
|
|
662
|
+
function Icon({ name, fallback = "HelpCircle", ...props }) {
|
|
663
|
+
const IconComponent = ICON_MAP[name] ?? ICON_MAP[fallback] ?? lucide_react.HelpCircle;
|
|
664
|
+
return react.default.createElement(IconComponent, props);
|
|
665
|
+
}
|
|
666
|
+
//#endregion
|
|
667
|
+
exports.ANIMATION = ANIMATION;
|
|
668
|
+
exports.CACHE = CACHE;
|
|
669
|
+
exports.CONTACT_SUBJECTS = CONTACT_SUBJECTS;
|
|
670
|
+
exports.CmsError = CmsError;
|
|
671
|
+
exports.HTTP_STATUS = HTTP_STATUS;
|
|
672
|
+
exports.ICON_MAP = ICON_MAP;
|
|
673
|
+
exports.Icon = Icon;
|
|
674
|
+
exports.MEDIA = MEDIA;
|
|
675
|
+
exports.PAGINATION = PAGINATION;
|
|
676
|
+
exports.SEARCH = SEARCH;
|
|
677
|
+
exports.allPageTypes = allPageTypes;
|
|
678
|
+
exports.createCmsClient = createCmsClient;
|
|
679
|
+
exports.defaultPageTypes = defaultPageTypes;
|
|
680
|
+
exports.pageTypes = pageTypes;
|