iwgt 2.3.0

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.
@@ -0,0 +1,430 @@
1
+ /**
2
+ * Инструменты для работы со справочной информацией
3
+ * Модуль содержит функции для получения данных из справочников
4
+ */
5
+ import blockTemplatesFull from '../data/references/block-templates-full.json' with { type: 'json' };
6
+ import categoryBlockTemplates from '../data/references/category-block-templates.json' with { type: 'json' };
7
+ import iconsRegistry from '../data/references/icons-registry.json' with { type: 'json' };
8
+ import categorySettings from '../data/references/category-settings.json' with { type: 'json' };
9
+ import librariesRegistry from '../data/references/libraries-registry.json' with { type: 'json' };
10
+ import liquidVariables from '../data/references/liquid-variables.json' with { type: 'json' };
11
+ import liquidFilters from '../data/references/liquid-filters.json' with { type: 'json' };
12
+ import commonjsReference from '../data/references/commonjs-reference.json' with { type: 'json' };
13
+ import collectionsMenuPatterns from '../data/references/collections-menu-patterns.json' with { type: 'json' };
14
+ /**
15
+ * Получить список блок-темплейтов с фильтрацией
16
+ */
17
+ export function getBlockTemplates(args = {}) {
18
+ const { category, search } = args;
19
+ const fullData = blockTemplatesFull;
20
+ let templates = fullData.templates || [];
21
+ if (category) {
22
+ const categoryData = categoryBlockTemplates[category] || [];
23
+ const categoryHandles = categoryData.map((t) => t.handle);
24
+ templates = templates.filter((t) => categoryHandles.includes(t.handle));
25
+ }
26
+ if (search) {
27
+ const searchLower = search.toLowerCase();
28
+ templates = templates.filter((t) => t.keywords?.some((k) => k.toLowerCase().includes(searchLower)) ||
29
+ t.handle.toLowerCase().includes(searchLower));
30
+ }
31
+ return {
32
+ total: templates.length,
33
+ category: category || 'all',
34
+ templates: templates.map((t) => ({
35
+ handle: t.handle,
36
+ name: t.name,
37
+ keywords: t.keywords,
38
+ fields: t.fields.map((f) => ({
39
+ name: f.name,
40
+ handle: f.handle,
41
+ kind: f.kind,
42
+ })),
43
+ })),
44
+ };
45
+ }
46
+ /**
47
+ * Получить список доступных иконок
48
+ * Иконки используются через иконочный шрифт
49
+ */
50
+ export function getAvailableIcons(args = {}) {
51
+ const { search, category } = args;
52
+ const iconsData = iconsRegistry;
53
+ const defaultIcons = iconsData.iconSets?.default?.icons || [];
54
+ let icons = defaultIcons;
55
+ if (category) {
56
+ const categoryIcons = iconsData.categories?.[category] || [];
57
+ icons = icons.filter((icon) => categoryIcons.includes(icon.name));
58
+ }
59
+ if (search) {
60
+ const searchLower = search.toLowerCase();
61
+ icons = icons.filter((icon) => icon.name.toLowerCase().includes(searchLower) ||
62
+ icon.keywords?.some((k) => k.toLowerCase().includes(searchLower)));
63
+ }
64
+ return {
65
+ 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
+ icons: icons.map((icon) => ({
74
+ name: icon.name,
75
+ keywords: icon.keywords,
76
+ htmlClass: `<i class="icon icon-${icon.name}"></i>`,
77
+ className: `icon icon-${icon.name}`,
78
+ })),
79
+ };
80
+ }
81
+ /**
82
+ * Получить информацию о категории виджетов
83
+ */
84
+ export function getCategoryInfo(args) {
85
+ const { category } = args;
86
+ if (!category) {
87
+ const categories = Object.keys(categorySettings);
88
+ return {
89
+ available_categories: categories,
90
+ message: "Укажите category для получения детальной информации",
91
+ };
92
+ }
93
+ const categoryData = categorySettings[category];
94
+ if (!categoryData) {
95
+ return {
96
+ error: `Категория "${category}" не найдена`,
97
+ available_categories: Object.keys(categorySettings),
98
+ };
99
+ }
100
+ return {
101
+ category,
102
+ libraries: categoryData.libraries,
103
+ common_settings: categoryData.commonSettings,
104
+ examples: categoryData.examples || [],
105
+ block_templates: (categoryBlockTemplates[category] || []).map((t) => t.handle),
106
+ };
107
+ }
108
+ /**
109
+ * Получить информацию о библиотеках
110
+ */
111
+ export function getLibrariesInfo(args = {}) {
112
+ const { category } = args;
113
+ 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
+ };
129
+ }
130
+ const librariesData = librariesRegistry.libraries || [];
131
+ return {
132
+ libraries: librariesData.map((lib) => ({
133
+ name: lib.name,
134
+ description: lib.description,
135
+ documentation: lib.documentation,
136
+ categories: lib.categories,
137
+ })),
138
+ };
139
+ }
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
+ /**
192
+ * Получить справочник Liquid фильтров
193
+ */
194
+ export function getLiquidFilters(args = {}) {
195
+ const { category, search } = args;
196
+ 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
+ }
207
+ 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
+ };
220
+ }
221
+ if (search) {
222
+ 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
+ };
240
+ }
241
+ }
242
+ /**
243
+ * Получить справочник CommonJS API
244
+ */
245
+ export function getCommonJSAPI(args = {}) {
246
+ 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
+ };
262
+ }
263
+ // Поиск по категории (не используется в CommonJS)
264
+ 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
+ };
295
+ }
296
+ // Поиск по ключевому слову
297
+ if (search) {
298
+ 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
+ };
359
+ }
360
+ }
361
+ /**
362
+ * Получить паттерны меню категорий
363
+ */
364
+ export function getCollectionsMenuPatterns(args = {}) {
365
+ const { patternId, category } = args;
366
+ 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
+ // Поиск конкретного паттерна
385
+ if (patternId) {
386
+ const pattern = data.patterns.find((p) => p.id === patternId);
387
+ if (!pattern) {
388
+ return {
389
+ error: `Паттерн "${patternId}" не найден`,
390
+ available_patterns: data.patterns.map((p) => p.id),
391
+ };
392
+ }
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
+ };
410
+ }
411
+ // Фильтрация по категории (по useCase)
412
+ 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
+ };
428
+ }
429
+ }
430
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,181 @@
1
+ export interface WidgetInfo {
2
+ widget_category_handle: string;
3
+ widget_type: 'simple_widget_type' | 'block_list_widget_type';
4
+ snippet_type: 'liquid';
5
+ libraries: string[];
6
+ block_template_handle?: string;
7
+ }
8
+ export interface SettingsField {
9
+ name: string;
10
+ type: string;
11
+ label?: string;
12
+ class?: string;
13
+ min?: number;
14
+ max?: number;
15
+ step?: number;
16
+ unit?: string;
17
+ with_btns?: boolean;
18
+ value?: any;
19
+ helper?: string;
20
+ frequency?: number;
21
+ }
22
+ export interface BlockTemplate {
23
+ handle: string;
24
+ name: string;
25
+ fields: BlockField[];
26
+ keywords: string[];
27
+ usedInCategories: string[];
28
+ usageCount: number;
29
+ }
30
+ export interface BlockField {
31
+ handle: string;
32
+ kind: string;
33
+ name: string;
34
+ }
35
+ export interface CategoryData {
36
+ commonSettings: SettingsField[];
37
+ totalWidgets: number;
38
+ libraries: string[];
39
+ blockTemplates: string[];
40
+ examples: string[];
41
+ }
42
+ export interface CreateWidgetParams {
43
+ description: string;
44
+ category?: string;
45
+ type?: 'simple_widget_type' | 'block_list_widget_type';
46
+ handle?: string;
47
+ }
48
+ export interface WidgetFiles {
49
+ 'info.json': string;
50
+ 'settings_form.json': string;
51
+ 'settings_data.json': string;
52
+ 'snippet.liquid': string;
53
+ 'snippet.scss': string;
54
+ 'snippet.js': string;
55
+ 'messages.json': string;
56
+ 'setup.json'?: string;
57
+ }
58
+ export interface LiquidVariable {
59
+ id: string;
60
+ name: string;
61
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date' | 'html' | 'unknown';
62
+ description: string;
63
+ example: string;
64
+ }
65
+ export interface LiquidVariableCategory {
66
+ id: string;
67
+ name: string;
68
+ description: string;
69
+ variables: LiquidVariable[];
70
+ }
71
+ export interface LiquidVariablesReference {
72
+ meta: {
73
+ source: string;
74
+ description: string;
75
+ totalCategories: number;
76
+ totalVariables: number;
77
+ generatedAt: string;
78
+ };
79
+ categories: LiquidVariableCategory[];
80
+ }
81
+ export interface LiquidFilter {
82
+ id: string;
83
+ name: string;
84
+ description: string;
85
+ parameters: string[];
86
+ example: string;
87
+ }
88
+ export interface LiquidFilterCategory {
89
+ id: string;
90
+ name: string;
91
+ description: string;
92
+ filters: LiquidFilter[];
93
+ }
94
+ export interface LiquidFiltersReference {
95
+ meta: {
96
+ source: string;
97
+ description: string;
98
+ totalCategories: number;
99
+ totalFilters: number;
100
+ generatedAt: string;
101
+ };
102
+ categories: LiquidFilterCategory[];
103
+ }
104
+ export interface CommonJSMethod {
105
+ name: string;
106
+ fullName: string;
107
+ description: string;
108
+ parameters: CommonJSParameter[];
109
+ returns: CommonJSReturn | null;
110
+ example: string | null;
111
+ events?: CommonJSEvent[];
112
+ }
113
+ export interface CommonJSParameter {
114
+ name: string;
115
+ type: string;
116
+ description: string;
117
+ }
118
+ export interface CommonJSReturn {
119
+ type: string;
120
+ description: string;
121
+ }
122
+ export interface CommonJSAttribute {
123
+ name: string;
124
+ description: string;
125
+ example: string | null;
126
+ }
127
+ export interface CommonJSEvent {
128
+ name: string;
129
+ description: string;
130
+ }
131
+ export interface CommonJSExample {
132
+ code: string;
133
+ language: 'javascript' | 'html';
134
+ }
135
+ export interface CommonJSModule {
136
+ name: string;
137
+ displayName: string;
138
+ description: string;
139
+ methods: CommonJSMethod[];
140
+ attributes: CommonJSAttribute[];
141
+ events: CommonJSEvent[];
142
+ examples: CommonJSExample[];
143
+ }
144
+ export interface CommonJSGlobalObject {
145
+ global: string;
146
+ module: string;
147
+ description: string;
148
+ }
149
+ export interface CommonJSCategory {
150
+ id: string;
151
+ name: string;
152
+ description: string;
153
+ modules: string[];
154
+ }
155
+ export interface CommonJSReference {
156
+ version: string;
157
+ generatedAt: string;
158
+ description: string;
159
+ installation: {
160
+ method: string;
161
+ code: string;
162
+ alternative: string;
163
+ };
164
+ dependencies: Array<{
165
+ name: string;
166
+ version: string;
167
+ url: string;
168
+ }>;
169
+ globalObjects: CommonJSGlobalObject[];
170
+ categories: CommonJSCategory[];
171
+ modules: CommonJSModule[];
172
+ meta: {
173
+ modulesCount: number;
174
+ methodsCount: number;
175
+ attributesCount: number;
176
+ eventsCount: number;
177
+ globalObjectsCount: number;
178
+ categoriesCount: number;
179
+ };
180
+ }
181
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ // Типы для виджетов InSales
2
+ export {};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Утилиты для работы с виджетами
3
+ * Модуль содержит вспомогательные функции
4
+ */
5
+ import type { BlockTemplate } from '../types/index.js';
6
+ /**
7
+ * Определить категорию виджета по описанию
8
+ */
9
+ export declare function inferCategory(description: string): string;
10
+ /**
11
+ * Определить тип виджета по описанию
12
+ */
13
+ export declare function inferType(description: string): 'simple_widget_type' | 'block_list_widget_type';
14
+ /**
15
+ * Сгенерировать handle виджета из описания
16
+ */
17
+ export declare function generateHandle(description: string): string;
18
+ /**
19
+ * Выбрать подходящий блок-темплейт
20
+ */
21
+ export declare function selectBlockTemplate(description: string, category: string): BlockTemplate | undefined;
22
+ /**
23
+ * Валидация handle виджета
24
+ */
25
+ export declare function validateHandle(handle: string): {
26
+ valid: boolean;
27
+ error?: string;
28
+ };
29
+ //# sourceMappingURL=index.d.ts.map