iwgt 2.4.7 → 2.4.9

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,9 @@ 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' };
14
15
  /**
15
16
  * Получить список блок-темплейтов с фильтрацией
16
17
  */
@@ -240,121 +241,207 @@ export function getLiquidFilters(args = {}) {
240
241
  }
241
242
  }
242
243
  /**
243
- * Получить справочник CommonJS API
244
+ * Получить справочник CommonJS API v2 для InSales
245
+ * ОБНОВЛЕНО: использует commonjs-api-complete.json с акцентом на глобальные переменные
244
246
  */
245
247
  export function getCommonJSAPI(args = {}) {
246
248
  const { category, module, search } = args;
247
- const data = commonjsReference;
248
- // Без параметров - общая информация
249
+ const completeData = commonjsApiComplete;
250
+ // Без параметров - критическая информация и обзор
249
251
  if (!category && !module && !search) {
250
252
  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,
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,
256
272
  })),
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 для детальной информации",
273
+ quick_reference: completeData.quick_reference,
274
+ message: "⚠️ ВСЕ модули доступны ГЛОБАЛЬНО! НЕ используйте import. Укажите module или search для детальной информации."
261
275
  };
262
276
  }
263
- // Поиск по категории (не используется в CommonJS)
277
+ // Поиск по категории (для UI компонентов)
264
278
  if (category) {
265
- // CommonJS не имеет категорий, игнорируем
266
- const modules = data.modules;
267
- return {
279
+ const categoryMap = {
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 = {
268
291
  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
- })),
292
+ global_modules: [],
293
+ ui_components: [],
276
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;
277
310
  }
278
311
  // Поиск по модулю
279
312
  if (module) {
280
- const mod = data.modules.find(m => m.name === module);
281
- if (!mod) {
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];
282
329
  return {
283
- error: `Модуль "${module}" не найден`,
284
- available_modules: data.modules.map(m => m.name),
330
+ type: 'ui_component',
331
+ key: module,
332
+ ...comp,
333
+ usage_note: comp.no_js_needed ?
334
+ "✅ Этот компонент работает ПОЛНОСТЬЮ без JavaScript!" :
335
+ "⚠️ Этот компонент требует инициализации через JavaScript.",
285
336
  };
286
337
  }
287
338
  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,
339
+ error: `Модуль "${module}" не найден`,
340
+ available_global_modules: Object.keys(completeData.global_modules),
341
+ available_ui_components: Object.keys(completeData.ui_components || {}),
294
342
  };
295
343
  }
296
344
  // Поиск по ключевому слову
297
345
  if (search) {
298
346
  const searchLower = search.toLowerCase();
299
347
  const results = {
348
+ global_modules: [],
349
+ data_attributes: [],
300
350
  methods: [],
301
351
  events: [],
302
- attributes: [],
303
- method_events: [], // События, связанные с методами
352
+ ui_components: [],
353
+ patterns: [],
304
354
  };
305
- data.modules.forEach(mod => {
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
+ }
306
380
  // Поиск по методам
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) ||
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) ||
318
397
  event.description?.toLowerCase().includes(searchLower)) {
319
- results.method_events.push({
398
+ results.events.push({
399
+ name: eventName,
400
+ module: name,
320
401
  ...event,
321
- module: mod.name,
322
- method: method.name,
323
402
  });
324
403
  }
325
404
  });
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,
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,
334
416
  });
335
417
  }
336
418
  });
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,
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,
344
428
  });
345
429
  }
346
430
  });
347
- });
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;
348
438
  return {
349
439
  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,
440
+ total_results: totalResults,
357
441
  results,
442
+ note: totalResults === 0 ?
443
+ "Ничего не найдено. Попробуйте другой запрос или используйте module для просмотра конкретного модуля." :
444
+ `Найдено ${totalResults} результатов. Используйте data-атрибуты вместо JavaScript где возможно!`,
358
445
  };
359
446
  }
360
447
  }
@@ -427,4 +514,144 @@ export function getCollectionsMenuPatterns(args = {}) {
427
514
  };
428
515
  }
429
516
  }
517
+ /**
518
+ * Получить справочник API библиотек
519
+ * Объединяет информацию из libraries-registry и libraries-api-reference
520
+ */
521
+ export function getLibrariesAPI(args = {}) {
522
+ const { library, search, category } = args;
523
+ const apiData = librariesApiReference;
524
+ const registryData = librariesRegistry;
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
+ // Поиск конкретной библиотеки
544
+ if (library) {
545
+ const lib = apiData.libraries.find((l) => l.handle === library || l.name.toLowerCase() === library.toLowerCase());
546
+ if (!lib) {
547
+ return {
548
+ error: `Библиотека "${library}" не найдена в API справочнике`,
549
+ available_libraries: apiData.libraries.map((l) => ({
550
+ handle: l.handle,
551
+ name: l.name,
552
+ })),
553
+ note: "Некоторые библиотеки могут не иметь подробной API документации",
554
+ };
555
+ }
556
+ // Полная информация о библиотеке
557
+ return {
558
+ library: {
559
+ name: lib.name,
560
+ handle: lib.handle,
561
+ version: lib.version,
562
+ type: lib.type,
563
+ description: lib.description,
564
+ categories: lib.categories,
565
+ dependencies: lib.dependencies,
566
+ },
567
+ usage: lib.usage,
568
+ options: lib.options,
569
+ methods: lib.methods,
570
+ events: lib.events,
571
+ cssClasses: lib.cssClasses,
572
+ examples: lib.examples,
573
+ bestPractices: lib.bestPractices,
574
+ notes: lib.notes,
575
+ };
576
+ }
577
+ // Поиск по ключевому слову
578
+ if (search) {
579
+ const searchLower = search.toLowerCase();
580
+ const results = {
581
+ libraries: [],
582
+ options: [],
583
+ methods: [],
584
+ examples: [],
585
+ };
586
+ apiData.libraries.forEach((lib) => {
587
+ // Поиск по библиотекам
588
+ if (lib.name.toLowerCase().includes(searchLower) ||
589
+ lib.handle.toLowerCase().includes(searchLower) ||
590
+ lib.description?.toLowerCase().includes(searchLower)) {
591
+ results.libraries.push({
592
+ name: lib.name,
593
+ handle: lib.handle,
594
+ description: lib.description,
595
+ type: lib.type,
596
+ });
597
+ }
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
+ });
632
+ return {
633
+ search,
634
+ libraries_count: results.libraries.length,
635
+ options_count: results.options.length,
636
+ methods_count: results.methods.length,
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
+ })),
654
+ };
655
+ }
656
+ }
430
657
  //# 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.9",
4
4
  "description": "MCP server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",