iwgt 2.4.7 → 2.4.10

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.
@@ -9,8 +9,10 @@ import categorySettings from '../data/references/category-settings.json' with {
9
9
  import librariesRegistry from '../data/references/libraries-registry.json' with { type: 'json' };
10
10
  import liquidVariables from '../data/references/liquid-variables.json' with { type: 'json' };
11
11
  import liquidFilters from '../data/references/liquid-filters.json' with { type: 'json' };
12
- import commonjsReference from '../data/references/commonjs-reference.json' with { type: 'json' };
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
+ import librariesApiReference from '../data/references/libraries-api-reference.json' with { type: 'json' };
15
+ import insalesPermanentLinks from '../data/insales-permanent-links.json' with { type: 'json' };
14
16
  /**
15
17
  * Получить список блок-темплейтов с фильтрацией
16
18
  */
@@ -30,17 +32,15 @@ export function getBlockTemplates(args = {}) {
30
32
  }
31
33
  return {
32
34
  total: templates.length,
33
- category: category || 'all',
34
35
  templates: templates.map((t) => ({
35
36
  handle: t.handle,
36
37
  name: t.name,
38
+ description: t.description,
37
39
  keywords: t.keywords,
38
- fields: t.fields.map((f) => ({
39
- name: f.name,
40
- handle: f.handle,
41
- kind: f.kind,
42
- })),
43
- })),
40
+ category: t.category,
41
+ type: t.type,
42
+ usage: t.usage
43
+ }))
44
44
  };
45
45
  }
46
46
  /**
@@ -49,12 +49,10 @@ export function getBlockTemplates(args = {}) {
49
49
  */
50
50
  export function getAvailableIcons(args = {}) {
51
51
  const { search, category } = args;
52
- const iconsData = iconsRegistry;
53
- const defaultIcons = iconsData.iconSets?.default?.icons || [];
54
- let icons = defaultIcons;
52
+ const data = iconsRegistry;
53
+ let icons = data.icons || [];
55
54
  if (category) {
56
- const categoryIcons = iconsData.categories?.[category] || [];
57
- icons = icons.filter((icon) => categoryIcons.includes(icon.name));
55
+ icons = icons.filter((icon) => icon.category === category);
58
56
  }
59
57
  if (search) {
60
58
  const searchLower = search.toLowerCase();
@@ -63,46 +61,35 @@ export function getAvailableIcons(args = {}) {
63
61
  }
64
62
  return {
65
63
  total: icons.length,
66
- description: 'Иконки используются через иконочный шрифт, который уже подключен в шаблоне',
67
- usage: {
68
- liquid: 'В Liquid шаблонах: <i class="icon icon-название"></i>',
69
- html: 'В HTML/JS: <i class="icon icon-название"></i>',
70
- example: '<i class="icon icon-cart"></i> <!-- выведет иконку корзины -->',
71
- note: 'Фильтра | icon НЕ СУЩЕСТВУЕТ в InSales. Используйте только HTML классы.'
72
- },
73
64
  icons: icons.map((icon) => ({
74
65
  name: icon.name,
66
+ class: `icon-${icon.name}`,
75
67
  keywords: icon.keywords,
76
- htmlClass: `<i class="icon icon-${icon.name}"></i>`,
77
- className: `icon icon-${icon.name}`,
78
- })),
68
+ category: icon.category,
69
+ usage: `<i class="icon icon-${icon.name}"></i>`
70
+ }))
79
71
  };
80
72
  }
81
73
  /**
82
74
  * Получить информацию о категории виджетов
83
75
  */
84
- export function getCategoryInfo(args) {
76
+ export function getCategoryInfo(args = {}) {
85
77
  const { category } = args;
86
78
  if (!category) {
87
- const categories = Object.keys(categorySettings);
88
79
  return {
89
- available_categories: categories,
90
- message: "Укажите category для получения детальной информации",
80
+ error: 'Не указана категория'
91
81
  };
92
82
  }
93
- const categoryData = categorySettings[category];
83
+ const data = categorySettings;
84
+ const categoryData = data.categories?.[category];
94
85
  if (!categoryData) {
95
86
  return {
96
- error: `Категория "${category}" не найдена`,
97
- available_categories: Object.keys(categorySettings),
87
+ error: `Категория '${category}' не найдена`
98
88
  };
99
89
  }
100
90
  return {
101
91
  category,
102
- libraries: categoryData.libraries,
103
- common_settings: categoryData.commonSettings,
104
- examples: categoryData.examples || [],
105
- block_templates: (categoryBlockTemplates[category] || []).map((t) => t.handle),
92
+ ...categoryData
106
93
  };
107
94
  }
108
95
  /**
@@ -110,253 +97,79 @@ export function getCategoryInfo(args) {
110
97
  */
111
98
  export function getLibrariesInfo(args = {}) {
112
99
  const { category } = args;
100
+ const data = librariesRegistry;
101
+ let libraries = data.libraries || [];
113
102
  if (category) {
114
- const categoryData = categorySettings[category];
115
- if (!categoryData) {
116
- return { error: `Категория "${category}" не найдена` };
117
- }
118
- const categoryLibraries = categoryData.libraries;
119
- const librariesData = librariesRegistry.libraries || [];
120
- const libraries = librariesData.filter((lib) => categoryLibraries.includes(lib.name));
121
- return {
122
- category,
123
- libraries: libraries.map((lib) => ({
124
- name: lib.name,
125
- description: lib.description,
126
- documentation: lib.documentation,
127
- })),
128
- };
103
+ libraries = libraries.filter((lib) => lib.category === category);
129
104
  }
130
- const librariesData = librariesRegistry.libraries || [];
131
105
  return {
132
- libraries: librariesData.map((lib) => ({
106
+ total: libraries.length,
107
+ libraries: libraries.map((lib) => ({
133
108
  name: lib.name,
109
+ handle: lib.handle,
134
110
  description: lib.description,
135
- documentation: lib.documentation,
136
- categories: lib.categories,
137
- })),
111
+ category: lib.category,
112
+ type: lib.type,
113
+ usage: lib.usage
114
+ }))
138
115
  };
139
116
  }
140
- /**
141
- * Получить справочник Liquid переменных
142
- */
143
- export function getLiquidVariables(args = {}) {
144
- const { category, search } = args;
145
- const data = liquidVariables;
146
- if (!category && !search) {
147
- return {
148
- categories: data.categories.map(cat => ({
149
- name: cat.name,
150
- count: cat.variables.length,
151
- })),
152
- total_variables: data.categories.reduce((sum, cat) => sum + cat.variables.length, 0),
153
- message: "Укажите category или search для получения переменных",
154
- };
155
- }
156
- if (category) {
157
- const cat = data.categories.find(c => c.name.toLowerCase() === category.toLowerCase());
158
- if (!cat) {
159
- return {
160
- error: `Категория "${category}" не найдена`,
161
- available_categories: data.categories.map(c => c.name),
162
- };
163
- }
164
- return {
165
- category: cat.name,
166
- count: cat.variables.length,
167
- variables: cat.variables,
168
- };
169
- }
170
- if (search) {
171
- const searchLower = search.toLowerCase();
172
- const results = [];
173
- data.categories.forEach(cat => {
174
- cat.variables.forEach(v => {
175
- if (v.name.toLowerCase().includes(searchLower) ||
176
- v.description?.toLowerCase().includes(searchLower)) {
177
- results.push({
178
- ...v,
179
- category: cat.name,
180
- });
181
- }
182
- });
183
- });
184
- return {
185
- search,
186
- count: results.length,
187
- variables: results,
188
- };
189
- }
190
- }
191
117
  /**
192
118
  * Получить справочник Liquid фильтров
193
119
  */
194
120
  export function getLiquidFilters(args = {}) {
195
121
  const { category, search } = args;
196
122
  const data = liquidFilters;
197
- if (!category && !search) {
198
- return {
199
- categories: data.categories.map(cat => ({
200
- name: cat.name,
201
- count: cat.filters.length,
202
- })),
203
- total_filters: data.categories.reduce((sum, cat) => sum + cat.filters.length, 0),
204
- message: "Укажите category или search для получения фильтров",
205
- };
206
- }
123
+ let filters = data.filters || [];
207
124
  if (category) {
208
- const cat = data.categories.find(c => c.name.toLowerCase() === category.toLowerCase());
209
- if (!cat) {
210
- return {
211
- error: `Категория "${category}" не найдена`,
212
- available_categories: data.categories.map(c => c.name),
213
- };
214
- }
215
- return {
216
- category: cat.name,
217
- count: cat.filters.length,
218
- filters: cat.filters,
219
- };
125
+ filters = filters.filter((filter) => filter.category === category);
220
126
  }
221
127
  if (search) {
222
128
  const searchLower = search.toLowerCase();
223
- const results = [];
224
- data.categories.forEach(cat => {
225
- cat.filters.forEach(f => {
226
- if (f.name.toLowerCase().includes(searchLower) ||
227
- f.description?.toLowerCase().includes(searchLower)) {
228
- results.push({
229
- ...f,
230
- category: cat.name,
231
- });
232
- }
233
- });
234
- });
235
- return {
236
- search,
237
- count: results.length,
238
- filters: results,
239
- };
129
+ filters = filters.filter((filter) => filter.name.toLowerCase().includes(searchLower) ||
130
+ filter.description?.toLowerCase().includes(searchLower));
240
131
  }
132
+ return {
133
+ total: filters.length,
134
+ categories: data.categories || [],
135
+ filters: filters.map((filter) => ({
136
+ name: filter.name,
137
+ description: filter.description,
138
+ category: filter.category,
139
+ syntax: filter.syntax,
140
+ examples: filter.examples
141
+ }))
142
+ };
241
143
  }
242
144
  /**
243
145
  * Получить справочник CommonJS API
244
146
  */
245
147
  export function getCommonJSAPI(args = {}) {
246
148
  const { category, module, search } = args;
247
- const data = commonjsReference;
248
- // Без параметров - общая информация
249
- if (!category && !module && !search) {
250
- return {
251
- modules: data.modules.map(m => ({
252
- name: m.name,
253
- description: m.description,
254
- methods_count: m.methods?.length || 0,
255
- events_count: m.events?.length || 0,
256
- })),
257
- total_modules: data.modules.length,
258
- total_methods: data.modules.reduce((sum, m) => sum + (m.methods?.length || 0), 0),
259
- total_events: data.modules.reduce((sum, m) => sum + (m.events?.length || 0), 0),
260
- message: "Укажите module или search для детальной информации",
261
- };
149
+ const data = commonjsApiComplete;
150
+ let modules = data.modules || [];
151
+ if (module) {
152
+ modules = modules.filter((mod) => mod.name === module);
262
153
  }
263
- // Поиск по категории (не используется в CommonJS)
264
154
  if (category) {
265
- // CommonJS не имеет категорий, игнорируем
266
- const modules = data.modules;
267
- return {
268
- category,
269
- modules: modules.map(m => ({
270
- name: m.name,
271
- description: m.description,
272
- methods: m.methods,
273
- attributes: m.attributes,
274
- events: m.events,
275
- })),
276
- };
277
- }
278
- // Поиск по модулю
279
- if (module) {
280
- const mod = data.modules.find(m => m.name === module);
281
- if (!mod) {
282
- return {
283
- error: `Модуль "${module}" не найден`,
284
- available_modules: data.modules.map(m => m.name),
285
- };
286
- }
287
- return {
288
- module: mod.name,
289
- description: mod.description,
290
- methods: mod.methods,
291
- attributes: mod.attributes,
292
- events: mod.events,
293
- examples: mod.examples,
294
- };
155
+ modules = modules.filter((mod) => mod.category === category);
295
156
  }
296
- // Поиск по ключевому слову
297
157
  if (search) {
298
158
  const searchLower = search.toLowerCase();
299
- const results = {
300
- methods: [],
301
- events: [],
302
- attributes: [],
303
- method_events: [], // События, связанные с методами
304
- };
305
- data.modules.forEach(mod => {
306
- // Поиск по методам
307
- mod.methods?.forEach(method => {
308
- if (method.name.toLowerCase().includes(searchLower) ||
309
- method.description?.toLowerCase().includes(searchLower)) {
310
- results.methods.push({
311
- ...method,
312
- module: mod.name,
313
- });
314
- }
315
- // Поиск по событиям внутри методов
316
- method.events?.forEach(event => {
317
- if (event.name.toLowerCase().includes(searchLower) ||
318
- event.description?.toLowerCase().includes(searchLower)) {
319
- results.method_events.push({
320
- ...event,
321
- module: mod.name,
322
- method: method.name,
323
- });
324
- }
325
- });
326
- });
327
- // Поиск по событиям модуля
328
- mod.events?.forEach(event => {
329
- if (event.name.toLowerCase().includes(searchLower) ||
330
- event.description?.toLowerCase().includes(searchLower)) {
331
- results.events.push({
332
- ...event,
333
- module: mod.name,
334
- });
335
- }
336
- });
337
- // Поиск по атрибутам
338
- mod.attributes?.forEach(attr => {
339
- if (attr.name.toLowerCase().includes(searchLower) ||
340
- attr.description?.toLowerCase().includes(searchLower)) {
341
- results.attributes.push({
342
- ...attr,
343
- module: mod.name,
344
- });
345
- }
346
- });
347
- });
348
- return {
349
- search,
350
- methods_count: results.methods.length,
351
- events_count: results.events.length,
352
- method_events_count: results.method_events.length,
353
- attributes_count: results.attributes.length,
354
- note: results.attributes.length > 0
355
- ? 'Data-атрибуты работают автоматически при добавлении в HTML. JavaScript не требуется для базовой функциональности.'
356
- : undefined,
357
- results,
358
- };
159
+ modules = modules.filter((mod) => mod.name.toLowerCase().includes(searchLower) ||
160
+ mod.description?.toLowerCase().includes(searchLower) ||
161
+ mod.methods?.some((m) => m.name.toLowerCase().includes(searchLower)));
359
162
  }
163
+ return {
164
+ total: modules.length,
165
+ modules: modules.map((mod) => ({
166
+ name: mod.name,
167
+ description: mod.description,
168
+ category: mod.category,
169
+ methods: mod.methods || [],
170
+ events: mod.events || []
171
+ }))
172
+ };
360
173
  }
361
174
  /**
362
175
  * Получить паттерны меню категорий
@@ -364,67 +177,133 @@ export function getCommonJSAPI(args = {}) {
364
177
  export function getCollectionsMenuPatterns(args = {}) {
365
178
  const { patternId, category } = args;
366
179
  const data = collectionsMenuPatterns;
367
- // Без параметров - общая информация
368
- if (!patternId && !category) {
369
- return {
370
- title: data.title,
371
- description: data.description,
372
- patterns: data.patterns.map((p) => ({
373
- id: p.id,
374
- name: p.name,
375
- description: p.description,
376
- useCase: p.useCase,
377
- structure: p.structure,
378
- features: p.features,
379
- })),
380
- total_patterns: data.patterns.length,
381
- message: "Укажите patternId для получения полного кода паттерна",
382
- };
383
- }
384
- // Поиск конкретного паттерна
180
+ let patterns = data.patterns || [];
385
181
  if (patternId) {
386
- const pattern = data.patterns.find((p) => p.id === patternId);
387
- if (!pattern) {
182
+ const pattern = patterns.find((p) => p.id === patternId);
183
+ if (pattern) {
388
184
  return {
389
- error: `Паттерн "${patternId}" не найден`,
390
- available_patterns: data.patterns.map((p) => p.id),
185
+ pattern: {
186
+ id: pattern.id,
187
+ name: pattern.name,
188
+ description: pattern.description,
189
+ category: pattern.category,
190
+ code: pattern.code,
191
+ settings: pattern.settings
192
+ }
391
193
  };
392
194
  }
393
- return {
394
- pattern: {
395
- id: pattern.id,
396
- name: pattern.name,
397
- description: pattern.description,
398
- useCase: pattern.useCase,
399
- structure: pattern.structure,
400
- cacheKeyPattern: pattern.cacheKeyPattern,
401
- requiredSettings: pattern.requiredSettings,
402
- liquidCode: pattern.liquidCode,
403
- features: pattern.features,
404
- },
405
- commonPatterns: data.commonPatterns,
406
- collectionMethods: data.collectionMethods,
407
- dataAttributes: data.dataAttributes,
408
- bestPractices: data.bestPractices,
409
- };
195
+ return { error: `Паттерн '${patternId}' не найден` };
410
196
  }
411
- // Фильтрация по категории (по useCase)
412
197
  if (category) {
413
- const categoryLower = category.toLowerCase();
414
- const matchingPatterns = data.patterns.filter((p) => p.useCase.toLowerCase().includes(categoryLower) ||
415
- p.description.toLowerCase().includes(categoryLower));
416
- return {
417
- category,
418
- count: matchingPatterns.length,
419
- patterns: matchingPatterns.map((p) => ({
420
- id: p.id,
421
- name: p.name,
422
- description: p.description,
423
- useCase: p.useCase,
424
- structure: p.structure,
425
- features: p.features,
426
- })),
427
- };
198
+ patterns = patterns.filter((pattern) => pattern.category === category);
428
199
  }
200
+ return {
201
+ total: patterns.length,
202
+ patterns: patterns.map((pattern) => ({
203
+ id: pattern.id,
204
+ name: pattern.name,
205
+ description: pattern.description,
206
+ category: pattern.category
207
+ }))
208
+ };
209
+ }
210
+ /**
211
+ * Получить API библиотек
212
+ */
213
+ export function getLibrariesAPI(args = {}) {
214
+ const { library, search, category } = args;
215
+ const data = librariesApiReference;
216
+ let libraries = data.libraries || [];
217
+ if (library) {
218
+ const lib = libraries.find((l) => l.handle === library || l.name === library);
219
+ if (lib) {
220
+ return {
221
+ library: {
222
+ name: lib.name,
223
+ handle: lib.handle,
224
+ description: lib.description,
225
+ type: lib.type,
226
+ category: lib.category,
227
+ options: lib.options || [],
228
+ methods: lib.methods || [],
229
+ examples: lib.examples || []
230
+ }
231
+ };
232
+ }
233
+ return { error: `Библиотека '${library}' не найдена` };
234
+ }
235
+ if (category) {
236
+ libraries = libraries.filter((lib) => lib.category === category);
237
+ }
238
+ if (search) {
239
+ const searchLower = search.toLowerCase();
240
+ libraries = libraries.filter((lib) => lib.name.toLowerCase().includes(searchLower) ||
241
+ lib.handle.toLowerCase().includes(searchLower) ||
242
+ lib.description?.toLowerCase().includes(searchLower));
243
+ }
244
+ return {
245
+ total: libraries.length,
246
+ libraries: libraries.map((lib) => ({
247
+ name: lib.name,
248
+ handle: lib.handle,
249
+ description: lib.description,
250
+ type: lib.type,
251
+ category: lib.category
252
+ }))
253
+ };
254
+ }
255
+ /**
256
+ * Получить справочник Liquid переменных
257
+ */
258
+ export function getLiquidVariables(args = {}) {
259
+ const { category, search } = args;
260
+ const data = liquidVariables;
261
+ let variables = data.variables || [];
262
+ if (category) {
263
+ variables = variables.filter((variable) => variable.category === category);
264
+ }
265
+ if (search) {
266
+ const searchLower = search.toLowerCase();
267
+ variables = variables.filter((variable) => variable.name.toLowerCase().includes(searchLower) ||
268
+ variable.description?.toLowerCase().includes(searchLower));
269
+ }
270
+ return {
271
+ total: variables.length,
272
+ categories: data.categories || [],
273
+ variables: variables.map((variable) => ({
274
+ name: variable.name,
275
+ description: variable.description,
276
+ category: variable.category,
277
+ type: variable.type,
278
+ examples: variable.examples
279
+ }))
280
+ };
281
+ }
282
+ /**
283
+ * Получить постоянные ссылки InSales
284
+ */
285
+ export function getInsalesPermanentLinks(args = {}) {
286
+ const { search } = args;
287
+ const data = insalesPermanentLinks;
288
+ let links = data.links || {};
289
+ if (search) {
290
+ const searchLower = search.toLowerCase();
291
+ const filteredLinks = {};
292
+ Object.keys(links).forEach(key => {
293
+ const link = links[key];
294
+ if (key.toLowerCase().includes(searchLower) ||
295
+ link.description?.toLowerCase().includes(searchLower) ||
296
+ link.usage?.toLowerCase().includes(searchLower)) {
297
+ filteredLinks[key] = link;
298
+ }
299
+ });
300
+ links = filteredLinks;
301
+ }
302
+ return {
303
+ description: data.description,
304
+ total: Object.keys(links).length,
305
+ links,
306
+ notes: data.notes
307
+ };
429
308
  }
430
309
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iwgt",
3
- "version": "2.4.7",
3
+ "version": "2.4.10",
4
4
  "description": "MCP server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",