iwgt 2.4.9 → 2.4.11
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/data/insales-permanent-links.json +68 -0
- package/dist/data/references/commonjs-reference.json +1 -1
- package/dist/data/references/icons-registry.json +39 -24
- package/dist/data/references/javascript-guide.json +436 -0
- package/dist/data/references/liquid-filters.json +1 -1
- package/dist/data/references/liquid-variables.json +1 -1
- package/dist/data/widget-wrapper-and-context.md +647 -0
- package/dist/generators/index.d.ts +23 -0
- package/dist/generators/index.js +91 -1
- package/dist/server-http.js +1 -1
- package/dist/server.js +79 -2
- package/dist/tools/index.d.ts +15 -9
- package/dist/tools/index.js +286 -512
- package/package.json +1 -1
package/dist/tools/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import liquidFilters from '../data/references/liquid-filters.json' with { type:
|
|
|
12
12
|
import commonjsApiComplete from '../data/references/commonjs-api-complete.json' with { type: 'json' };
|
|
13
13
|
import collectionsMenuPatterns from '../data/references/collections-menu-patterns.json' with { type: 'json' };
|
|
14
14
|
import librariesApiReference from '../data/references/libraries-api-reference.json' with { type: 'json' };
|
|
15
|
+
import insalesPermanentLinks from '../data/insales-permanent-links.json' with { type: 'json' };
|
|
16
|
+
import javascriptGuide from '../data/references/javascript-guide.json' with { type: 'json' };
|
|
15
17
|
/**
|
|
16
18
|
* Получить список блок-темплейтов с фильтрацией
|
|
17
19
|
*/
|
|
@@ -31,17 +33,15 @@ export function getBlockTemplates(args = {}) {
|
|
|
31
33
|
}
|
|
32
34
|
return {
|
|
33
35
|
total: templates.length,
|
|
34
|
-
category: category || 'all',
|
|
35
36
|
templates: templates.map((t) => ({
|
|
36
37
|
handle: t.handle,
|
|
37
38
|
name: t.name,
|
|
39
|
+
description: t.description,
|
|
38
40
|
keywords: t.keywords,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})),
|
|
44
|
-
})),
|
|
41
|
+
category: t.category,
|
|
42
|
+
type: t.type,
|
|
43
|
+
usage: t.usage
|
|
44
|
+
}))
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -50,12 +50,10 @@ export function getBlockTemplates(args = {}) {
|
|
|
50
50
|
*/
|
|
51
51
|
export function getAvailableIcons(args = {}) {
|
|
52
52
|
const { search, category } = args;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
let icons = defaultIcons;
|
|
53
|
+
const data = iconsRegistry;
|
|
54
|
+
let icons = data.icons || [];
|
|
56
55
|
if (category) {
|
|
57
|
-
|
|
58
|
-
icons = icons.filter((icon) => categoryIcons.includes(icon.name));
|
|
56
|
+
icons = icons.filter((icon) => icon.category === category);
|
|
59
57
|
}
|
|
60
58
|
if (search) {
|
|
61
59
|
const searchLower = search.toLowerCase();
|
|
@@ -64,46 +62,35 @@ export function getAvailableIcons(args = {}) {
|
|
|
64
62
|
}
|
|
65
63
|
return {
|
|
66
64
|
total: icons.length,
|
|
67
|
-
description: 'Иконки используются через иконочный шрифт, который уже подключен в шаблоне',
|
|
68
|
-
usage: {
|
|
69
|
-
liquid: 'В Liquid шаблонах: <i class="icon icon-название"></i>',
|
|
70
|
-
html: 'В HTML/JS: <i class="icon icon-название"></i>',
|
|
71
|
-
example: '<i class="icon icon-cart"></i> <!-- выведет иконку корзины -->',
|
|
72
|
-
note: 'Фильтра | icon НЕ СУЩЕСТВУЕТ в InSales. Используйте только HTML классы.'
|
|
73
|
-
},
|
|
74
65
|
icons: icons.map((icon) => ({
|
|
75
66
|
name: icon.name,
|
|
67
|
+
class: `icon-${icon.name}`,
|
|
76
68
|
keywords: icon.keywords,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}))
|
|
69
|
+
category: icon.category,
|
|
70
|
+
usage: `<i class="icon icon-${icon.name}"></i>`
|
|
71
|
+
}))
|
|
80
72
|
};
|
|
81
73
|
}
|
|
82
74
|
/**
|
|
83
75
|
* Получить информацию о категории виджетов
|
|
84
76
|
*/
|
|
85
|
-
export function getCategoryInfo(args) {
|
|
77
|
+
export function getCategoryInfo(args = {}) {
|
|
86
78
|
const { category } = args;
|
|
87
79
|
if (!category) {
|
|
88
|
-
const categories = Object.keys(categorySettings);
|
|
89
80
|
return {
|
|
90
|
-
|
|
91
|
-
message: "Укажите category для получения детальной информации",
|
|
81
|
+
error: 'Не указана категория'
|
|
92
82
|
};
|
|
93
83
|
}
|
|
94
|
-
const
|
|
84
|
+
const data = categorySettings;
|
|
85
|
+
const categoryData = data.categories?.[category];
|
|
95
86
|
if (!categoryData) {
|
|
96
87
|
return {
|
|
97
|
-
error: `Категория
|
|
98
|
-
available_categories: Object.keys(categorySettings),
|
|
88
|
+
error: `Категория '${category}' не найдена`
|
|
99
89
|
};
|
|
100
90
|
}
|
|
101
91
|
return {
|
|
102
92
|
category,
|
|
103
|
-
|
|
104
|
-
common_settings: categoryData.commonSettings,
|
|
105
|
-
examples: categoryData.examples || [],
|
|
106
|
-
block_templates: (categoryBlockTemplates[category] || []).map((t) => t.handle),
|
|
93
|
+
...categoryData
|
|
107
94
|
};
|
|
108
95
|
}
|
|
109
96
|
/**
|
|
@@ -111,339 +98,79 @@ export function getCategoryInfo(args) {
|
|
|
111
98
|
*/
|
|
112
99
|
export function getLibrariesInfo(args = {}) {
|
|
113
100
|
const { category } = args;
|
|
101
|
+
const data = librariesRegistry;
|
|
102
|
+
let libraries = data.libraries || [];
|
|
114
103
|
if (category) {
|
|
115
|
-
|
|
116
|
-
if (!categoryData) {
|
|
117
|
-
return { error: `Категория "${category}" не найдена` };
|
|
118
|
-
}
|
|
119
|
-
const categoryLibraries = categoryData.libraries;
|
|
120
|
-
const librariesData = librariesRegistry.libraries || [];
|
|
121
|
-
const libraries = librariesData.filter((lib) => categoryLibraries.includes(lib.name));
|
|
122
|
-
return {
|
|
123
|
-
category,
|
|
124
|
-
libraries: libraries.map((lib) => ({
|
|
125
|
-
name: lib.name,
|
|
126
|
-
description: lib.description,
|
|
127
|
-
documentation: lib.documentation,
|
|
128
|
-
})),
|
|
129
|
-
};
|
|
104
|
+
libraries = libraries.filter((lib) => lib.category === category);
|
|
130
105
|
}
|
|
131
|
-
const librariesData = librariesRegistry.libraries || [];
|
|
132
106
|
return {
|
|
133
|
-
|
|
107
|
+
total: libraries.length,
|
|
108
|
+
libraries: libraries.map((lib) => ({
|
|
134
109
|
name: lib.name,
|
|
110
|
+
handle: lib.handle,
|
|
135
111
|
description: lib.description,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
112
|
+
category: lib.category,
|
|
113
|
+
type: lib.type,
|
|
114
|
+
usage: lib.usage
|
|
115
|
+
}))
|
|
139
116
|
};
|
|
140
117
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Получить справочник Liquid переменных
|
|
143
|
-
*/
|
|
144
|
-
export function getLiquidVariables(args = {}) {
|
|
145
|
-
const { category, search } = args;
|
|
146
|
-
const data = liquidVariables;
|
|
147
|
-
if (!category && !search) {
|
|
148
|
-
return {
|
|
149
|
-
categories: data.categories.map(cat => ({
|
|
150
|
-
name: cat.name,
|
|
151
|
-
count: cat.variables.length,
|
|
152
|
-
})),
|
|
153
|
-
total_variables: data.categories.reduce((sum, cat) => sum + cat.variables.length, 0),
|
|
154
|
-
message: "Укажите category или search для получения переменных",
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
if (category) {
|
|
158
|
-
const cat = data.categories.find(c => c.name.toLowerCase() === category.toLowerCase());
|
|
159
|
-
if (!cat) {
|
|
160
|
-
return {
|
|
161
|
-
error: `Категория "${category}" не найдена`,
|
|
162
|
-
available_categories: data.categories.map(c => c.name),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
category: cat.name,
|
|
167
|
-
count: cat.variables.length,
|
|
168
|
-
variables: cat.variables,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
if (search) {
|
|
172
|
-
const searchLower = search.toLowerCase();
|
|
173
|
-
const results = [];
|
|
174
|
-
data.categories.forEach(cat => {
|
|
175
|
-
cat.variables.forEach(v => {
|
|
176
|
-
if (v.name.toLowerCase().includes(searchLower) ||
|
|
177
|
-
v.description?.toLowerCase().includes(searchLower)) {
|
|
178
|
-
results.push({
|
|
179
|
-
...v,
|
|
180
|
-
category: cat.name,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
return {
|
|
186
|
-
search,
|
|
187
|
-
count: results.length,
|
|
188
|
-
variables: results,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
118
|
/**
|
|
193
119
|
* Получить справочник Liquid фильтров
|
|
194
120
|
*/
|
|
195
121
|
export function getLiquidFilters(args = {}) {
|
|
196
122
|
const { category, search } = args;
|
|
197
123
|
const data = liquidFilters;
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
categories: data.categories.map(cat => ({
|
|
201
|
-
name: cat.name,
|
|
202
|
-
count: cat.filters.length,
|
|
203
|
-
})),
|
|
204
|
-
total_filters: data.categories.reduce((sum, cat) => sum + cat.filters.length, 0),
|
|
205
|
-
message: "Укажите category или search для получения фильтров",
|
|
206
|
-
};
|
|
207
|
-
}
|
|
124
|
+
let filters = data.filters || [];
|
|
208
125
|
if (category) {
|
|
209
|
-
|
|
210
|
-
if (!cat) {
|
|
211
|
-
return {
|
|
212
|
-
error: `Категория "${category}" не найдена`,
|
|
213
|
-
available_categories: data.categories.map(c => c.name),
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
category: cat.name,
|
|
218
|
-
count: cat.filters.length,
|
|
219
|
-
filters: cat.filters,
|
|
220
|
-
};
|
|
126
|
+
filters = filters.filter((filter) => filter.category === category);
|
|
221
127
|
}
|
|
222
128
|
if (search) {
|
|
223
129
|
const searchLower = search.toLowerCase();
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
cat.filters.forEach(f => {
|
|
227
|
-
if (f.name.toLowerCase().includes(searchLower) ||
|
|
228
|
-
f.description?.toLowerCase().includes(searchLower)) {
|
|
229
|
-
results.push({
|
|
230
|
-
...f,
|
|
231
|
-
category: cat.name,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
return {
|
|
237
|
-
search,
|
|
238
|
-
count: results.length,
|
|
239
|
-
filters: results,
|
|
240
|
-
};
|
|
130
|
+
filters = filters.filter((filter) => filter.name.toLowerCase().includes(searchLower) ||
|
|
131
|
+
filter.description?.toLowerCase().includes(searchLower));
|
|
241
132
|
}
|
|
133
|
+
return {
|
|
134
|
+
total: filters.length,
|
|
135
|
+
categories: data.categories || [],
|
|
136
|
+
filters: filters.map((filter) => ({
|
|
137
|
+
name: filter.name,
|
|
138
|
+
description: filter.description,
|
|
139
|
+
category: filter.category,
|
|
140
|
+
syntax: filter.syntax,
|
|
141
|
+
examples: filter.examples
|
|
142
|
+
}))
|
|
143
|
+
};
|
|
242
144
|
}
|
|
243
145
|
/**
|
|
244
|
-
* Получить справочник CommonJS API
|
|
245
|
-
* ОБНОВЛЕНО: использует commonjs-api-complete.json с акцентом на глобальные переменные
|
|
146
|
+
* Получить справочник CommonJS API
|
|
246
147
|
*/
|
|
247
148
|
export function getCommonJSAPI(args = {}) {
|
|
248
149
|
const { category, module, search } = args;
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
version: completeData.version,
|
|
254
|
-
title: completeData.title,
|
|
255
|
-
description: completeData.description,
|
|
256
|
-
critical_info: completeData.critical_info,
|
|
257
|
-
installation: completeData.installation,
|
|
258
|
-
global_modules: Object.keys(completeData.global_modules).map(name => ({
|
|
259
|
-
name,
|
|
260
|
-
description: completeData.global_modules[name].description,
|
|
261
|
-
global_access: completeData.global_modules[name].global_access,
|
|
262
|
-
declarative: completeData.global_modules[name].declarative || false,
|
|
263
|
-
has_data_attributes: Object.keys(completeData.global_modules[name].data_attributes || {}).length > 0,
|
|
264
|
-
methods_count: Object.keys(completeData.global_modules[name].methods || {}).length,
|
|
265
|
-
events_count: Object.keys(completeData.global_modules[name].events || {}).length,
|
|
266
|
-
})),
|
|
267
|
-
ui_components: Object.keys(completeData.ui_components || {}).map(key => ({
|
|
268
|
-
name: completeData.ui_components[key].name,
|
|
269
|
-
description: completeData.ui_components[key].description,
|
|
270
|
-
declarative: completeData.ui_components[key].declarative,
|
|
271
|
-
no_js_needed: completeData.ui_components[key].no_js_needed,
|
|
272
|
-
})),
|
|
273
|
-
quick_reference: completeData.quick_reference,
|
|
274
|
-
message: "⚠️ ВСЕ модули доступны ГЛОБАЛЬНО! НЕ используйте import. Укажите module или search для детальной информации."
|
|
275
|
-
};
|
|
150
|
+
const data = commonjsApiComplete;
|
|
151
|
+
let modules = data.modules || [];
|
|
152
|
+
if (module) {
|
|
153
|
+
modules = modules.filter((mod) => mod.name === module);
|
|
276
154
|
}
|
|
277
|
-
// Поиск по категории (для UI компонентов)
|
|
278
155
|
if (category) {
|
|
279
|
-
|
|
280
|
-
'product': ['Cart', 'Products', 'ajax_products', 'ajax_product', 'accessories'],
|
|
281
|
-
'cart': ['Cart'],
|
|
282
|
-
'lists': ['Compare', 'FavoritesProducts'],
|
|
283
|
-
'search': ['AjaxSearch'],
|
|
284
|
-
'forms': ['feedback_form', 'reviews_form', 'comments_form'],
|
|
285
|
-
'events': ['EventBus'],
|
|
286
|
-
'helpers': ['Shop', 'Template', 'ajaxAPI'],
|
|
287
|
-
'checkout': ['quick_checkout']
|
|
288
|
-
};
|
|
289
|
-
const modulesInCategory = categoryMap[category] || [];
|
|
290
|
-
const results = {
|
|
291
|
-
category,
|
|
292
|
-
global_modules: [],
|
|
293
|
-
ui_components: [],
|
|
294
|
-
};
|
|
295
|
-
modulesInCategory.forEach((modName) => {
|
|
296
|
-
if (completeData.global_modules[modName]) {
|
|
297
|
-
results.global_modules.push({
|
|
298
|
-
name: modName,
|
|
299
|
-
...completeData.global_modules[modName]
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
if (completeData.ui_components[modName]) {
|
|
303
|
-
results.ui_components.push({
|
|
304
|
-
key: modName,
|
|
305
|
-
...completeData.ui_components[modName]
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
return results;
|
|
310
|
-
}
|
|
311
|
-
// Поиск по модулю
|
|
312
|
-
if (module) {
|
|
313
|
-
// Сначала ищем в глобальных модулях
|
|
314
|
-
if (completeData.global_modules[module]) {
|
|
315
|
-
const mod = completeData.global_modules[module];
|
|
316
|
-
return {
|
|
317
|
-
type: 'global_module',
|
|
318
|
-
name: module,
|
|
319
|
-
...mod,
|
|
320
|
-
usage_note: mod.declarative ?
|
|
321
|
-
"💡 Этот модуль поддерживает декларативную работу через data-атрибуты. Используйте их вместо JavaScript где возможно." :
|
|
322
|
-
"⚠️ Этот модуль требует JavaScript для работы.",
|
|
323
|
-
best_practices: completeData.best_practices,
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
// Затем ищем в UI компонентах
|
|
327
|
-
if (completeData.ui_components[module]) {
|
|
328
|
-
const comp = completeData.ui_components[module];
|
|
329
|
-
return {
|
|
330
|
-
type: 'ui_component',
|
|
331
|
-
key: module,
|
|
332
|
-
...comp,
|
|
333
|
-
usage_note: comp.no_js_needed ?
|
|
334
|
-
"✅ Этот компонент работает ПОЛНОСТЬЮ без JavaScript!" :
|
|
335
|
-
"⚠️ Этот компонент требует инициализации через JavaScript.",
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
return {
|
|
339
|
-
error: `Модуль "${module}" не найден`,
|
|
340
|
-
available_global_modules: Object.keys(completeData.global_modules),
|
|
341
|
-
available_ui_components: Object.keys(completeData.ui_components || {}),
|
|
342
|
-
};
|
|
156
|
+
modules = modules.filter((mod) => mod.category === category);
|
|
343
157
|
}
|
|
344
|
-
// Поиск по ключевому слову
|
|
345
158
|
if (search) {
|
|
346
159
|
const searchLower = search.toLowerCase();
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
methods: [],
|
|
351
|
-
events: [],
|
|
352
|
-
ui_components: [],
|
|
353
|
-
patterns: [],
|
|
354
|
-
};
|
|
355
|
-
// Поиск в глобальных модулях
|
|
356
|
-
Object.entries(completeData.global_modules).forEach(([name, mod]) => {
|
|
357
|
-
// Поиск по имени и описанию модуля
|
|
358
|
-
if (name.toLowerCase().includes(searchLower) ||
|
|
359
|
-
mod.description?.toLowerCase().includes(searchLower)) {
|
|
360
|
-
results.global_modules.push({
|
|
361
|
-
name,
|
|
362
|
-
description: mod.description,
|
|
363
|
-
global_access: mod.global_access,
|
|
364
|
-
declarative: mod.declarative,
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
// Поиск по data-атрибутам
|
|
368
|
-
if (mod.data_attributes) {
|
|
369
|
-
Object.entries(mod.data_attributes).forEach(([attrName, attr]) => {
|
|
370
|
-
if (attrName.toLowerCase().includes(searchLower) ||
|
|
371
|
-
attr.description?.toLowerCase().includes(searchLower)) {
|
|
372
|
-
results.data_attributes.push({
|
|
373
|
-
name: attrName,
|
|
374
|
-
module: name,
|
|
375
|
-
...attr,
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
// Поиск по методам
|
|
381
|
-
if (mod.methods) {
|
|
382
|
-
Object.entries(mod.methods).forEach(([methodName, method]) => {
|
|
383
|
-
if (methodName.toLowerCase().includes(searchLower) ||
|
|
384
|
-
method.description?.toLowerCase().includes(searchLower)) {
|
|
385
|
-
results.methods.push({
|
|
386
|
-
name: methodName,
|
|
387
|
-
module: name,
|
|
388
|
-
...method,
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
// Поиск по событиям
|
|
394
|
-
if (mod.events) {
|
|
395
|
-
Object.entries(mod.events).forEach(([eventName, event]) => {
|
|
396
|
-
if (eventName.toLowerCase().includes(searchLower) ||
|
|
397
|
-
event.description?.toLowerCase().includes(searchLower)) {
|
|
398
|
-
results.events.push({
|
|
399
|
-
name: eventName,
|
|
400
|
-
module: name,
|
|
401
|
-
...event,
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
// Поиск в UI компонентах
|
|
408
|
-
if (completeData.ui_components) {
|
|
409
|
-
Object.entries(completeData.ui_components).forEach(([key, comp]) => {
|
|
410
|
-
if (key.toLowerCase().includes(searchLower) ||
|
|
411
|
-
comp.name?.toLowerCase().includes(searchLower) ||
|
|
412
|
-
comp.description?.toLowerCase().includes(searchLower)) {
|
|
413
|
-
results.ui_components.push({
|
|
414
|
-
key,
|
|
415
|
-
...comp,
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
// Поиск в паттернах
|
|
421
|
-
if (completeData.common_patterns) {
|
|
422
|
-
Object.entries(completeData.common_patterns).forEach(([key, pattern]) => {
|
|
423
|
-
if (key.toLowerCase().includes(searchLower) ||
|
|
424
|
-
pattern.title?.toLowerCase().includes(searchLower)) {
|
|
425
|
-
results.patterns.push({
|
|
426
|
-
key,
|
|
427
|
-
...pattern,
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
const totalResults = results.global_modules.length +
|
|
433
|
-
results.data_attributes.length +
|
|
434
|
-
results.methods.length +
|
|
435
|
-
results.events.length +
|
|
436
|
-
results.ui_components.length +
|
|
437
|
-
results.patterns.length;
|
|
438
|
-
return {
|
|
439
|
-
search,
|
|
440
|
-
total_results: totalResults,
|
|
441
|
-
results,
|
|
442
|
-
note: totalResults === 0 ?
|
|
443
|
-
"Ничего не найдено. Попробуйте другой запрос или используйте module для просмотра конкретного модуля." :
|
|
444
|
-
`Найдено ${totalResults} результатов. Используйте data-атрибуты вместо JavaScript где возможно!`,
|
|
445
|
-
};
|
|
160
|
+
modules = modules.filter((mod) => mod.name.toLowerCase().includes(searchLower) ||
|
|
161
|
+
mod.description?.toLowerCase().includes(searchLower) ||
|
|
162
|
+
mod.methods?.some((m) => m.name.toLowerCase().includes(searchLower)));
|
|
446
163
|
}
|
|
164
|
+
return {
|
|
165
|
+
total: modules.length,
|
|
166
|
+
modules: modules.map((mod) => ({
|
|
167
|
+
name: mod.name,
|
|
168
|
+
description: mod.description,
|
|
169
|
+
category: mod.category,
|
|
170
|
+
methods: mod.methods || [],
|
|
171
|
+
events: mod.events || []
|
|
172
|
+
}))
|
|
173
|
+
};
|
|
447
174
|
}
|
|
448
175
|
/**
|
|
449
176
|
* Получить паттерны меню категорий
|
|
@@ -451,207 +178,254 @@ export function getCommonJSAPI(args = {}) {
|
|
|
451
178
|
export function getCollectionsMenuPatterns(args = {}) {
|
|
452
179
|
const { patternId, category } = args;
|
|
453
180
|
const data = collectionsMenuPatterns;
|
|
454
|
-
|
|
455
|
-
if (!patternId && !category) {
|
|
456
|
-
return {
|
|
457
|
-
title: data.title,
|
|
458
|
-
description: data.description,
|
|
459
|
-
patterns: data.patterns.map((p) => ({
|
|
460
|
-
id: p.id,
|
|
461
|
-
name: p.name,
|
|
462
|
-
description: p.description,
|
|
463
|
-
useCase: p.useCase,
|
|
464
|
-
structure: p.structure,
|
|
465
|
-
features: p.features,
|
|
466
|
-
})),
|
|
467
|
-
total_patterns: data.patterns.length,
|
|
468
|
-
message: "Укажите patternId для получения полного кода паттерна",
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
// Поиск конкретного паттерна
|
|
181
|
+
let patterns = data.patterns || [];
|
|
472
182
|
if (patternId) {
|
|
473
|
-
const pattern =
|
|
474
|
-
if (
|
|
183
|
+
const pattern = patterns.find((p) => p.id === patternId);
|
|
184
|
+
if (pattern) {
|
|
475
185
|
return {
|
|
476
|
-
|
|
477
|
-
|
|
186
|
+
pattern: {
|
|
187
|
+
id: pattern.id,
|
|
188
|
+
name: pattern.name,
|
|
189
|
+
description: pattern.description,
|
|
190
|
+
category: pattern.category,
|
|
191
|
+
code: pattern.code,
|
|
192
|
+
settings: pattern.settings
|
|
193
|
+
}
|
|
478
194
|
};
|
|
479
195
|
}
|
|
480
|
-
return {
|
|
481
|
-
pattern: {
|
|
482
|
-
id: pattern.id,
|
|
483
|
-
name: pattern.name,
|
|
484
|
-
description: pattern.description,
|
|
485
|
-
useCase: pattern.useCase,
|
|
486
|
-
structure: pattern.structure,
|
|
487
|
-
cacheKeyPattern: pattern.cacheKeyPattern,
|
|
488
|
-
requiredSettings: pattern.requiredSettings,
|
|
489
|
-
liquidCode: pattern.liquidCode,
|
|
490
|
-
features: pattern.features,
|
|
491
|
-
},
|
|
492
|
-
commonPatterns: data.commonPatterns,
|
|
493
|
-
collectionMethods: data.collectionMethods,
|
|
494
|
-
dataAttributes: data.dataAttributes,
|
|
495
|
-
bestPractices: data.bestPractices,
|
|
496
|
-
};
|
|
196
|
+
return { error: `Паттерн '${patternId}' не найден` };
|
|
497
197
|
}
|
|
498
|
-
// Фильтрация по категории (по useCase)
|
|
499
198
|
if (category) {
|
|
500
|
-
|
|
501
|
-
const matchingPatterns = data.patterns.filter((p) => p.useCase.toLowerCase().includes(categoryLower) ||
|
|
502
|
-
p.description.toLowerCase().includes(categoryLower));
|
|
503
|
-
return {
|
|
504
|
-
category,
|
|
505
|
-
count: matchingPatterns.length,
|
|
506
|
-
patterns: matchingPatterns.map((p) => ({
|
|
507
|
-
id: p.id,
|
|
508
|
-
name: p.name,
|
|
509
|
-
description: p.description,
|
|
510
|
-
useCase: p.useCase,
|
|
511
|
-
structure: p.structure,
|
|
512
|
-
features: p.features,
|
|
513
|
-
})),
|
|
514
|
-
};
|
|
199
|
+
patterns = patterns.filter((pattern) => pattern.category === category);
|
|
515
200
|
}
|
|
201
|
+
return {
|
|
202
|
+
total: patterns.length,
|
|
203
|
+
patterns: patterns.map((pattern) => ({
|
|
204
|
+
id: pattern.id,
|
|
205
|
+
name: pattern.name,
|
|
206
|
+
description: pattern.description,
|
|
207
|
+
category: pattern.category
|
|
208
|
+
}))
|
|
209
|
+
};
|
|
516
210
|
}
|
|
517
211
|
/**
|
|
518
|
-
* Получить
|
|
519
|
-
* Объединяет информацию из libraries-registry и libraries-api-reference
|
|
212
|
+
* Получить API библиотек
|
|
520
213
|
*/
|
|
521
214
|
export function getLibrariesAPI(args = {}) {
|
|
522
215
|
const { library, search, category } = args;
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
// Без параметров - список всех библиотек с API документацией
|
|
526
|
-
if (!library && !search && !category) {
|
|
527
|
-
return {
|
|
528
|
-
title: apiData.title,
|
|
529
|
-
description: apiData.description,
|
|
530
|
-
libraries_with_api: apiData.libraries.map((lib) => ({
|
|
531
|
-
name: lib.name,
|
|
532
|
-
handle: lib.handle,
|
|
533
|
-
type: lib.type,
|
|
534
|
-
description: lib.description,
|
|
535
|
-
dependencies: lib.dependencies,
|
|
536
|
-
categories: lib.categories,
|
|
537
|
-
})),
|
|
538
|
-
total_libraries: apiData.libraries.length,
|
|
539
|
-
message: "Укажите library для получения полной документации по API, или search для поиска",
|
|
540
|
-
available_libraries: apiData.libraries.map((lib) => lib.handle),
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
// Поиск конкретной библиотеки
|
|
216
|
+
const data = librariesApiReference;
|
|
217
|
+
let libraries = data.libraries || [];
|
|
544
218
|
if (library) {
|
|
545
|
-
const lib =
|
|
546
|
-
if (
|
|
219
|
+
const lib = libraries.find((l) => l.handle === library || l.name === library);
|
|
220
|
+
if (lib) {
|
|
547
221
|
return {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
handle:
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
222
|
+
library: {
|
|
223
|
+
name: lib.name,
|
|
224
|
+
handle: lib.handle,
|
|
225
|
+
description: lib.description,
|
|
226
|
+
type: lib.type,
|
|
227
|
+
category: lib.category,
|
|
228
|
+
options: lib.options || [],
|
|
229
|
+
methods: lib.methods || [],
|
|
230
|
+
examples: lib.examples || []
|
|
231
|
+
}
|
|
554
232
|
};
|
|
555
233
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
234
|
+
return { error: `Библиотека '${library}' не найдена` };
|
|
235
|
+
}
|
|
236
|
+
if (category) {
|
|
237
|
+
libraries = libraries.filter((lib) => lib.category === category);
|
|
238
|
+
}
|
|
239
|
+
if (search) {
|
|
240
|
+
const searchLower = search.toLowerCase();
|
|
241
|
+
libraries = libraries.filter((lib) => lib.name.toLowerCase().includes(searchLower) ||
|
|
242
|
+
lib.handle.toLowerCase().includes(searchLower) ||
|
|
243
|
+
lib.description?.toLowerCase().includes(searchLower));
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
total: libraries.length,
|
|
247
|
+
libraries: libraries.map((lib) => ({
|
|
248
|
+
name: lib.name,
|
|
249
|
+
handle: lib.handle,
|
|
250
|
+
description: lib.description,
|
|
251
|
+
type: lib.type,
|
|
252
|
+
category: lib.category
|
|
253
|
+
}))
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Получить справочник Liquid переменных
|
|
258
|
+
*/
|
|
259
|
+
export function getLiquidVariables(args = {}) {
|
|
260
|
+
const { category, search } = args;
|
|
261
|
+
const data = liquidVariables;
|
|
262
|
+
let variables = data.variables || [];
|
|
263
|
+
if (category) {
|
|
264
|
+
variables = variables.filter((variable) => variable.category === category);
|
|
265
|
+
}
|
|
266
|
+
if (search) {
|
|
267
|
+
const searchLower = search.toLowerCase();
|
|
268
|
+
variables = variables.filter((variable) => variable.name.toLowerCase().includes(searchLower) ||
|
|
269
|
+
variable.description?.toLowerCase().includes(searchLower));
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
total: variables.length,
|
|
273
|
+
categories: data.categories || [],
|
|
274
|
+
variables: variables.map((variable) => ({
|
|
275
|
+
name: variable.name,
|
|
276
|
+
description: variable.description,
|
|
277
|
+
category: variable.category,
|
|
278
|
+
type: variable.type,
|
|
279
|
+
examples: variable.examples
|
|
280
|
+
}))
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Получить постоянные ссылки InSales
|
|
285
|
+
*/
|
|
286
|
+
export function getInsalesPermanentLinks(args = {}) {
|
|
287
|
+
const { search } = args;
|
|
288
|
+
const data = insalesPermanentLinks;
|
|
289
|
+
let links = data.links || {};
|
|
290
|
+
if (search) {
|
|
291
|
+
const searchLower = search.toLowerCase();
|
|
292
|
+
const filteredLinks = {};
|
|
293
|
+
Object.keys(links).forEach(key => {
|
|
294
|
+
const link = links[key];
|
|
295
|
+
if (key.toLowerCase().includes(searchLower) ||
|
|
296
|
+
link.description?.toLowerCase().includes(searchLower) ||
|
|
297
|
+
link.usage?.toLowerCase().includes(searchLower)) {
|
|
298
|
+
filteredLinks[key] = link;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
links = filteredLinks;
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
description: data.description,
|
|
305
|
+
total: Object.keys(links).length,
|
|
306
|
+
links,
|
|
307
|
+
notes: data.notes
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Получить руководство по JavaScript для виджетов
|
|
312
|
+
*/
|
|
313
|
+
export function getJavaScriptGuide(args = {}) {
|
|
314
|
+
const { section, search, pattern, error, api_module } = args;
|
|
315
|
+
const data = javascriptGuide;
|
|
316
|
+
if (section) {
|
|
317
|
+
const sectionData = data.sections?.[section];
|
|
318
|
+
if (sectionData) {
|
|
319
|
+
return {
|
|
320
|
+
section,
|
|
321
|
+
...sectionData
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return { error: `Раздел '${section}' не найден` };
|
|
325
|
+
}
|
|
326
|
+
if (pattern) {
|
|
327
|
+
const patterns = data.sections?.patterns?.patterns || [];
|
|
328
|
+
const foundPattern = patterns.find((p) => p.id === pattern);
|
|
329
|
+
if (foundPattern) {
|
|
330
|
+
return {
|
|
331
|
+
pattern: foundPattern
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
return { error: `Паттерн '${pattern}' не найден` };
|
|
335
|
+
}
|
|
336
|
+
if (error) {
|
|
337
|
+
const errors = data.sections?.common_errors?.errors || [];
|
|
338
|
+
const foundError = errors.find((e) => e.id === error);
|
|
339
|
+
if (foundError) {
|
|
340
|
+
return {
|
|
341
|
+
error: foundError
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
return { error: `Ошибка '${error}' не найдена` };
|
|
345
|
+
}
|
|
346
|
+
if (api_module) {
|
|
347
|
+
const modules = data.sections?.global_apis?.modules || [];
|
|
348
|
+
const foundModule = modules.find((m) => m.name === api_module);
|
|
349
|
+
if (foundModule) {
|
|
350
|
+
return {
|
|
351
|
+
module: foundModule
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return { error: `Модуль API '${api_module}' не найден` };
|
|
576
355
|
}
|
|
577
|
-
// Поиск по ключевому слову
|
|
578
356
|
if (search) {
|
|
579
357
|
const searchLower = search.toLowerCase();
|
|
580
358
|
const results = {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
359
|
+
sections: {},
|
|
360
|
+
patterns: [],
|
|
361
|
+
errors: [],
|
|
362
|
+
modules: [],
|
|
363
|
+
attributes: []
|
|
585
364
|
};
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
results.
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
365
|
+
// Поиск по разделам
|
|
366
|
+
Object.keys(data.sections || {}).forEach(sectionKey => {
|
|
367
|
+
const section = data.sections[sectionKey];
|
|
368
|
+
if (section.title?.toLowerCase().includes(searchLower) ||
|
|
369
|
+
section.description?.toLowerCase().includes(searchLower)) {
|
|
370
|
+
results.sections[sectionKey] = section;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
// Поиск по паттернам
|
|
374
|
+
const patterns = data.sections?.patterns?.patterns || [];
|
|
375
|
+
patterns.forEach((pattern) => {
|
|
376
|
+
if (pattern.title?.toLowerCase().includes(searchLower) ||
|
|
377
|
+
pattern.description?.toLowerCase().includes(searchLower) ||
|
|
378
|
+
pattern.code?.toLowerCase().includes(searchLower)) {
|
|
379
|
+
results.patterns.push(pattern);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
// Поиск по ошибкам
|
|
383
|
+
const errors = data.sections?.common_errors?.errors || [];
|
|
384
|
+
errors.forEach((error) => {
|
|
385
|
+
if (error.title?.toLowerCase().includes(searchLower) ||
|
|
386
|
+
error.description?.toLowerCase().includes(searchLower)) {
|
|
387
|
+
results.errors.push(error);
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
// Поиск по модулям API
|
|
391
|
+
const modules = data.sections?.global_apis?.modules || [];
|
|
392
|
+
modules.forEach((module) => {
|
|
393
|
+
if (module.name?.toLowerCase().includes(searchLower) ||
|
|
394
|
+
module.description?.toLowerCase().includes(searchLower)) {
|
|
395
|
+
results.modules.push(module);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
// Поиск по data-атрибутам
|
|
399
|
+
const attributes = data.sections?.data_attributes?.attributes || [];
|
|
400
|
+
attributes.forEach((attr) => {
|
|
401
|
+
if (attr.name?.toLowerCase().includes(searchLower) ||
|
|
402
|
+
attr.description?.toLowerCase().includes(searchLower)) {
|
|
403
|
+
results.attributes.push(attr);
|
|
597
404
|
}
|
|
598
|
-
// Поиск по опциям
|
|
599
|
-
lib.options?.forEach((opt) => {
|
|
600
|
-
if (opt.name.toLowerCase().includes(searchLower) ||
|
|
601
|
-
opt.description?.toLowerCase().includes(searchLower)) {
|
|
602
|
-
results.options.push({
|
|
603
|
-
...opt,
|
|
604
|
-
library: lib.name,
|
|
605
|
-
library_handle: lib.handle,
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
// Поиск по методам
|
|
610
|
-
lib.methods?.forEach((method) => {
|
|
611
|
-
if (method.name.toLowerCase().includes(searchLower) ||
|
|
612
|
-
method.description?.toLowerCase().includes(searchLower)) {
|
|
613
|
-
results.methods.push({
|
|
614
|
-
...method,
|
|
615
|
-
library: lib.name,
|
|
616
|
-
library_handle: lib.handle,
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
// Поиск по примерам
|
|
621
|
-
lib.examples?.forEach((example) => {
|
|
622
|
-
if (example.title?.toLowerCase().includes(searchLower) ||
|
|
623
|
-
example.description?.toLowerCase().includes(searchLower)) {
|
|
624
|
-
results.examples.push({
|
|
625
|
-
...example,
|
|
626
|
-
library: lib.name,
|
|
627
|
-
library_handle: lib.handle,
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
405
|
});
|
|
632
406
|
return {
|
|
633
407
|
search,
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
examples_count: results.examples.length,
|
|
638
|
-
results,
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
// Фильтрация по категории
|
|
642
|
-
if (category) {
|
|
643
|
-
const categoryLibraries = apiData.libraries.filter((lib) => lib.categories?.includes(category));
|
|
644
|
-
return {
|
|
645
|
-
category,
|
|
646
|
-
count: categoryLibraries.length,
|
|
647
|
-
libraries: categoryLibraries.map((lib) => ({
|
|
648
|
-
name: lib.name,
|
|
649
|
-
handle: lib.handle,
|
|
650
|
-
description: lib.description,
|
|
651
|
-
type: lib.type,
|
|
652
|
-
usage: lib.usage,
|
|
653
|
-
})),
|
|
408
|
+
total: Object.keys(results.sections).length + results.patterns.length +
|
|
409
|
+
results.errors.length + results.modules.length + results.attributes.length,
|
|
410
|
+
results
|
|
654
411
|
};
|
|
655
412
|
}
|
|
413
|
+
return {
|
|
414
|
+
title: data.title,
|
|
415
|
+
description: data.description,
|
|
416
|
+
version: data.version,
|
|
417
|
+
sections: Object.keys(data.sections || {}),
|
|
418
|
+
available_sections: {
|
|
419
|
+
principles: "Основные принципы написания JavaScript",
|
|
420
|
+
global_apis: "Глобальные API (Cart, Products, EventBus, etc.)",
|
|
421
|
+
data_attributes: "Data-атрибуты CommonJS",
|
|
422
|
+
patterns: "Паттерны и примеры кода",
|
|
423
|
+
common_errors: "Частые ошибки и их исправление",
|
|
424
|
+
debugging: "Способы отладки",
|
|
425
|
+
linting: "Линтер и проверка кода",
|
|
426
|
+
checklist: "Чеклист перед завершением",
|
|
427
|
+
golden_rule: "Золотое правило"
|
|
428
|
+
}
|
|
429
|
+
};
|
|
656
430
|
}
|
|
657
431
|
//# sourceMappingURL=index.js.map
|