@barumetric/contracts 1.2.1 → 1.2.3
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/gen/ts/categories.ts +13 -223
- package/package.json +1 -1
- package/proto/categories.proto +7 -122
package/gen/ts/categories.ts
CHANGED
|
@@ -26,127 +26,22 @@ export enum AttributeType {
|
|
|
26
26
|
UNRECOGNIZED = -1,
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export interface GetTreeRequest {
|
|
30
|
-
/** Если не указан, возвращает корневые категории */
|
|
31
|
-
parentId?:
|
|
32
|
-
| string
|
|
33
|
-
| undefined;
|
|
34
|
-
/** Максимальная глубина (0 = без ограничений) */
|
|
35
|
-
maxDepth: number;
|
|
36
|
-
/** Только активные категории */
|
|
37
|
-
onlyActive: boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
29
|
export interface GetCategoryRequest {
|
|
41
30
|
id: string;
|
|
42
31
|
/** Включить атрибуты */
|
|
43
32
|
includeAttributes: boolean;
|
|
44
33
|
}
|
|
45
34
|
|
|
46
|
-
export interface
|
|
47
|
-
|
|
48
|
-
/** Для уникальности */
|
|
49
|
-
parentId?: string | undefined;
|
|
50
|
-
includeAttributes: boolean;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface GetAttributesRequest {
|
|
35
|
+
export interface GetCategoryAttributesRequest {
|
|
36
|
+
/** ID категории */
|
|
54
37
|
categoryId: string;
|
|
55
|
-
/** Только для фильтров */
|
|
38
|
+
/** Только фильтруемые атрибуты (для фильтров на фронте) */
|
|
56
39
|
onlyFilterable: boolean;
|
|
57
|
-
/** Включить наследуемые от
|
|
40
|
+
/** Включить наследуемые атрибуты от родительских категорий */
|
|
58
41
|
includeInherited: boolean;
|
|
59
42
|
}
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
name: string;
|
|
63
|
-
slug: string;
|
|
64
|
-
description?: string | undefined;
|
|
65
|
-
iconUrl?: string | undefined;
|
|
66
|
-
bannerUrl?: string | undefined;
|
|
67
|
-
parentId?: string | undefined;
|
|
68
|
-
isLeaf: boolean;
|
|
69
|
-
sortOrder: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface UpdateCategoryRequest {
|
|
73
|
-
id: string;
|
|
74
|
-
name?: string | undefined;
|
|
75
|
-
slug?: string | undefined;
|
|
76
|
-
description?: string | undefined;
|
|
77
|
-
iconUrl?: string | undefined;
|
|
78
|
-
bannerUrl?: string | undefined;
|
|
79
|
-
isLeaf?: boolean | undefined;
|
|
80
|
-
isActive?: boolean | undefined;
|
|
81
|
-
sortOrder?: number | undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface DeleteCategoryRequest {
|
|
85
|
-
id: string;
|
|
86
|
-
/** Удалить дочерние категории */
|
|
87
|
-
cascade: boolean;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface CreateAttributeRequest {
|
|
91
|
-
/** Категория, к которой привязываем атрибут */
|
|
92
|
-
categoryId: string;
|
|
93
|
-
/** Название атрибута */
|
|
94
|
-
name: string;
|
|
95
|
-
/** Глобальный ключ (если атрибут с таким key уже существует, он будет переиспользован) */
|
|
96
|
-
key: string;
|
|
97
|
-
type: AttributeType;
|
|
98
|
-
/** Override для категории (null = использовать default из Attribute) */
|
|
99
|
-
isRequired?:
|
|
100
|
-
| boolean
|
|
101
|
-
| undefined;
|
|
102
|
-
/** Override для категории (null = использовать default из Attribute) */
|
|
103
|
-
isFilterable?:
|
|
104
|
-
| boolean
|
|
105
|
-
| undefined;
|
|
106
|
-
/** Наследуется ли атрибут дочерним категориям */
|
|
107
|
-
inherited: boolean;
|
|
108
|
-
/** Единица измерения (₽, км и т.д.) */
|
|
109
|
-
unit?:
|
|
110
|
-
| string
|
|
111
|
-
| undefined;
|
|
112
|
-
/** Минимальное значение */
|
|
113
|
-
minValue?:
|
|
114
|
-
| number
|
|
115
|
-
| undefined;
|
|
116
|
-
/** Максимальное значение */
|
|
117
|
-
maxValue?:
|
|
118
|
-
| number
|
|
119
|
-
| undefined;
|
|
120
|
-
/** Порядок сортировки в категории */
|
|
121
|
-
sortOrder: number;
|
|
122
|
-
/** Для ENUM/MULTI_ENUM типов (создаются только если атрибут новый) */
|
|
123
|
-
enumValues: EnumValueInput[];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface UpdateAttributeRequest {
|
|
127
|
-
/** ID CategoryAttribute (связи) */
|
|
128
|
-
id: string;
|
|
129
|
-
/** Override для категории (null = использовать default из Attribute) */
|
|
130
|
-
isRequired?:
|
|
131
|
-
| boolean
|
|
132
|
-
| undefined;
|
|
133
|
-
/** Override для категории (null = использовать default из Attribute) */
|
|
134
|
-
isFilterable?:
|
|
135
|
-
| boolean
|
|
136
|
-
| undefined;
|
|
137
|
-
/** Порядок сортировки в категории */
|
|
138
|
-
sortOrder?:
|
|
139
|
-
| number
|
|
140
|
-
| undefined;
|
|
141
|
-
/** Обновить enum values глобального атрибута */
|
|
142
|
-
enumValues: EnumValueInput[];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface DeleteAttributeRequest {
|
|
146
|
-
/** ID CategoryAttribute (связи) - удаляется только связь, глобальный Attribute остается */
|
|
147
|
-
id: string;
|
|
148
|
-
}
|
|
149
|
-
|
|
44
|
+
/** Ответы */
|
|
150
45
|
export interface GetAllCategoriesResponse {
|
|
151
46
|
categories: Category[];
|
|
152
47
|
}
|
|
@@ -155,34 +50,10 @@ export interface GetCategoryResponse {
|
|
|
155
50
|
category: Category | undefined;
|
|
156
51
|
}
|
|
157
52
|
|
|
158
|
-
export interface
|
|
53
|
+
export interface GetCategoryAttributesResponse {
|
|
159
54
|
attributes: CategoryAttribute[];
|
|
160
55
|
}
|
|
161
56
|
|
|
162
|
-
export interface CreateCategoryResponse {
|
|
163
|
-
category: Category | undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export interface UpdateCategoryResponse {
|
|
167
|
-
category: Category | undefined;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export interface DeleteCategoryResponse {
|
|
171
|
-
ok: boolean;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export interface CreateAttributeResponse {
|
|
175
|
-
attribute: CategoryAttribute | undefined;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface UpdateAttributeResponse {
|
|
179
|
-
attribute: CategoryAttribute | undefined;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export interface DeleteAttributeResponse {
|
|
183
|
-
ok: boolean;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
57
|
export interface Category {
|
|
187
58
|
id: string;
|
|
188
59
|
name: string;
|
|
@@ -262,37 +133,9 @@ export interface CategoriesServiceClient {
|
|
|
262
133
|
|
|
263
134
|
getCategory(request: GetCategoryRequest): Observable<GetCategoryResponse>;
|
|
264
135
|
|
|
265
|
-
/** Получить
|
|
266
|
-
|
|
267
|
-
getCategoryBySlug(request: GetCategoryBySlugRequest): Observable<GetCategoryResponse>;
|
|
268
|
-
|
|
269
|
-
/** Получить атрибуты категории (для фильтров) */
|
|
270
|
-
|
|
271
|
-
getAttributes(request: GetAttributesRequest): Observable<GetAttributesResponse>;
|
|
136
|
+
/** Получить атрибуты категории (для фильтрации) */
|
|
272
137
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
createCategory(request: CreateCategoryRequest): Observable<CreateCategoryResponse>;
|
|
276
|
-
|
|
277
|
-
/** Обновить категорию (админ) */
|
|
278
|
-
|
|
279
|
-
updateCategory(request: UpdateCategoryRequest): Observable<UpdateCategoryResponse>;
|
|
280
|
-
|
|
281
|
-
/** Удалить категорию (админ) */
|
|
282
|
-
|
|
283
|
-
deleteCategory(request: DeleteCategoryRequest): Observable<DeleteCategoryResponse>;
|
|
284
|
-
|
|
285
|
-
/** Создать атрибут (админ) */
|
|
286
|
-
|
|
287
|
-
createAttribute(request: CreateAttributeRequest): Observable<CreateAttributeResponse>;
|
|
288
|
-
|
|
289
|
-
/** Обновить атрибут (админ) */
|
|
290
|
-
|
|
291
|
-
updateAttribute(request: UpdateAttributeRequest): Observable<UpdateAttributeResponse>;
|
|
292
|
-
|
|
293
|
-
/** Удалить атрибут (админ) */
|
|
294
|
-
|
|
295
|
-
deleteAttribute(request: DeleteAttributeRequest): Observable<DeleteAttributeResponse>;
|
|
138
|
+
getCategoryAttributes(request: GetCategoryAttributesRequest): Observable<GetCategoryAttributesResponse>;
|
|
296
139
|
}
|
|
297
140
|
|
|
298
141
|
export interface CategoriesServiceController {
|
|
@@ -308,69 +151,16 @@ export interface CategoriesServiceController {
|
|
|
308
151
|
request: GetCategoryRequest,
|
|
309
152
|
): Promise<GetCategoryResponse> | Observable<GetCategoryResponse> | GetCategoryResponse;
|
|
310
153
|
|
|
311
|
-
/** Получить
|
|
312
|
-
|
|
313
|
-
getCategoryBySlug(
|
|
314
|
-
request: GetCategoryBySlugRequest,
|
|
315
|
-
): Promise<GetCategoryResponse> | Observable<GetCategoryResponse> | GetCategoryResponse;
|
|
316
|
-
|
|
317
|
-
/** Получить атрибуты категории (для фильтров) */
|
|
318
|
-
|
|
319
|
-
getAttributes(
|
|
320
|
-
request: GetAttributesRequest,
|
|
321
|
-
): Promise<GetAttributesResponse> | Observable<GetAttributesResponse> | GetAttributesResponse;
|
|
322
|
-
|
|
323
|
-
/** Создать категорию (админ) */
|
|
324
|
-
|
|
325
|
-
createCategory(
|
|
326
|
-
request: CreateCategoryRequest,
|
|
327
|
-
): Promise<CreateCategoryResponse> | Observable<CreateCategoryResponse> | CreateCategoryResponse;
|
|
328
|
-
|
|
329
|
-
/** Обновить категорию (админ) */
|
|
330
|
-
|
|
331
|
-
updateCategory(
|
|
332
|
-
request: UpdateCategoryRequest,
|
|
333
|
-
): Promise<UpdateCategoryResponse> | Observable<UpdateCategoryResponse> | UpdateCategoryResponse;
|
|
334
|
-
|
|
335
|
-
/** Удалить категорию (админ) */
|
|
336
|
-
|
|
337
|
-
deleteCategory(
|
|
338
|
-
request: DeleteCategoryRequest,
|
|
339
|
-
): Promise<DeleteCategoryResponse> | Observable<DeleteCategoryResponse> | DeleteCategoryResponse;
|
|
340
|
-
|
|
341
|
-
/** Создать атрибут (админ) */
|
|
342
|
-
|
|
343
|
-
createAttribute(
|
|
344
|
-
request: CreateAttributeRequest,
|
|
345
|
-
): Promise<CreateAttributeResponse> | Observable<CreateAttributeResponse> | CreateAttributeResponse;
|
|
346
|
-
|
|
347
|
-
/** Обновить атрибут (админ) */
|
|
348
|
-
|
|
349
|
-
updateAttribute(
|
|
350
|
-
request: UpdateAttributeRequest,
|
|
351
|
-
): Promise<UpdateAttributeResponse> | Observable<UpdateAttributeResponse> | UpdateAttributeResponse;
|
|
352
|
-
|
|
353
|
-
/** Удалить атрибут (админ) */
|
|
154
|
+
/** Получить атрибуты категории (для фильтрации) */
|
|
354
155
|
|
|
355
|
-
|
|
356
|
-
request:
|
|
357
|
-
): Promise<
|
|
156
|
+
getCategoryAttributes(
|
|
157
|
+
request: GetCategoryAttributesRequest,
|
|
158
|
+
): Promise<GetCategoryAttributesResponse> | Observable<GetCategoryAttributesResponse> | GetCategoryAttributesResponse;
|
|
358
159
|
}
|
|
359
160
|
|
|
360
161
|
export function CategoriesServiceControllerMethods() {
|
|
361
162
|
return function (constructor: Function) {
|
|
362
|
-
const grpcMethods: string[] = [
|
|
363
|
-
"getAllCategories",
|
|
364
|
-
"getCategory",
|
|
365
|
-
"getCategoryBySlug",
|
|
366
|
-
"getAttributes",
|
|
367
|
-
"createCategory",
|
|
368
|
-
"updateCategory",
|
|
369
|
-
"deleteCategory",
|
|
370
|
-
"createAttribute",
|
|
371
|
-
"updateAttribute",
|
|
372
|
-
"deleteAttribute",
|
|
373
|
-
];
|
|
163
|
+
const grpcMethods: string[] = ["getAllCategories", "getCategory", "getCategoryAttributes"];
|
|
374
164
|
for (const method of grpcMethods) {
|
|
375
165
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
376
166
|
GrpcMethod("CategoriesService", method)(constructor.prototype[method], method, descriptor);
|
package/package.json
CHANGED
package/proto/categories.proto
CHANGED
|
@@ -11,37 +11,8 @@ service CategoriesService {
|
|
|
11
11
|
// Получить категорию по ID
|
|
12
12
|
rpc GetCategory (GetCategoryRequest) returns (GetCategoryResponse);
|
|
13
13
|
|
|
14
|
-
// Получить
|
|
15
|
-
rpc
|
|
16
|
-
|
|
17
|
-
// Получить атрибуты категории (для фильтров)
|
|
18
|
-
rpc GetAttributes (GetAttributesRequest) returns (GetAttributesResponse);
|
|
19
|
-
|
|
20
|
-
// Создать категорию (админ)
|
|
21
|
-
rpc CreateCategory (CreateCategoryRequest) returns (CreateCategoryResponse);
|
|
22
|
-
|
|
23
|
-
// Обновить категорию (админ)
|
|
24
|
-
rpc UpdateCategory (UpdateCategoryRequest) returns (UpdateCategoryResponse);
|
|
25
|
-
|
|
26
|
-
// Удалить категорию (админ)
|
|
27
|
-
rpc DeleteCategory (DeleteCategoryRequest) returns (DeleteCategoryResponse);
|
|
28
|
-
|
|
29
|
-
// Создать атрибут (админ)
|
|
30
|
-
rpc CreateAttribute (CreateAttributeRequest) returns (CreateAttributeResponse);
|
|
31
|
-
|
|
32
|
-
// Обновить атрибут (админ)
|
|
33
|
-
rpc UpdateAttribute (UpdateAttributeRequest) returns (UpdateAttributeResponse);
|
|
34
|
-
|
|
35
|
-
// Удалить атрибут (админ)
|
|
36
|
-
rpc DeleteAttribute (DeleteAttributeRequest) returns (DeleteAttributeResponse);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Запросы
|
|
40
|
-
|
|
41
|
-
message GetTreeRequest {
|
|
42
|
-
optional string parent_id = 1; // Если не указан, возвращает корневые категории
|
|
43
|
-
int32 max_depth = 2; // Максимальная глубина (0 = без ограничений)
|
|
44
|
-
bool only_active = 3; // Только активные категории
|
|
14
|
+
// Получить атрибуты категории (для фильтрации)
|
|
15
|
+
rpc GetCategoryAttributes (GetCategoryAttributesRequest) returns (GetCategoryAttributesResponse);
|
|
45
16
|
}
|
|
46
17
|
|
|
47
18
|
message GetCategoryRequest {
|
|
@@ -49,75 +20,13 @@ message GetCategoryRequest {
|
|
|
49
20
|
bool include_attributes = 2; // Включить атрибуты
|
|
50
21
|
}
|
|
51
22
|
|
|
52
|
-
message
|
|
53
|
-
string
|
|
54
|
-
|
|
55
|
-
bool
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
message GetAttributesRequest {
|
|
59
|
-
string category_id = 1;
|
|
60
|
-
bool only_filterable = 2; // Только для фильтров
|
|
61
|
-
bool include_inherited = 3; // Включить наследуемые от родителей
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
message CreateCategoryRequest {
|
|
65
|
-
string name = 1;
|
|
66
|
-
string slug = 2;
|
|
67
|
-
optional string description = 3;
|
|
68
|
-
optional string icon_url = 4;
|
|
69
|
-
optional string banner_url = 5;
|
|
70
|
-
optional string parent_id = 6;
|
|
71
|
-
bool is_leaf = 7;
|
|
72
|
-
int32 sort_order = 8;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
message UpdateCategoryRequest {
|
|
76
|
-
string id = 1;
|
|
77
|
-
optional string name = 2;
|
|
78
|
-
optional string slug = 3;
|
|
79
|
-
optional string description = 4;
|
|
80
|
-
optional string icon_url = 5;
|
|
81
|
-
optional string banner_url = 6;
|
|
82
|
-
optional bool is_leaf = 7;
|
|
83
|
-
optional bool is_active = 8;
|
|
84
|
-
optional int32 sort_order = 9;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
message DeleteCategoryRequest {
|
|
88
|
-
string id = 1;
|
|
89
|
-
bool cascade = 2; // Удалить дочерние категории
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
message CreateAttributeRequest {
|
|
93
|
-
string category_id = 1; // Категория, к которой привязываем атрибут
|
|
94
|
-
string name = 2; // Название атрибута
|
|
95
|
-
string key = 3; // Глобальный ключ (если атрибут с таким key уже существует, он будет переиспользован)
|
|
96
|
-
AttributeType type = 4;
|
|
97
|
-
optional bool is_required = 5; // Override для категории (null = использовать default из Attribute)
|
|
98
|
-
optional bool is_filterable = 6; // Override для категории (null = использовать default из Attribute)
|
|
99
|
-
bool inherited = 7; // Наследуется ли атрибут дочерним категориям
|
|
100
|
-
optional string unit = 8; // Единица измерения (₽, км и т.д.)
|
|
101
|
-
optional float min_value = 9; // Минимальное значение
|
|
102
|
-
optional float max_value = 10; // Максимальное значение
|
|
103
|
-
int32 sort_order = 11; // Порядок сортировки в категории
|
|
104
|
-
repeated EnumValueInput enum_values = 12; // Для ENUM/MULTI_ENUM типов (создаются только если атрибут новый)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
message UpdateAttributeRequest {
|
|
108
|
-
string id = 1; // ID CategoryAttribute (связи)
|
|
109
|
-
optional bool is_required = 2; // Override для категории (null = использовать default из Attribute)
|
|
110
|
-
optional bool is_filterable = 3; // Override для категории (null = использовать default из Attribute)
|
|
111
|
-
optional int32 sort_order = 4; // Порядок сортировки в категории
|
|
112
|
-
repeated EnumValueInput enum_values = 5; // Обновить enum values глобального атрибута
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
message DeleteAttributeRequest {
|
|
116
|
-
string id = 1; // ID CategoryAttribute (связи) - удаляется только связь, глобальный Attribute остается
|
|
23
|
+
message GetCategoryAttributesRequest {
|
|
24
|
+
string category_id = 1; // ID категории
|
|
25
|
+
bool only_filterable = 2; // Только фильтруемые атрибуты (для фильтров на фронте)
|
|
26
|
+
bool include_inherited = 3; // Включить наследуемые атрибуты от родительских категорий
|
|
117
27
|
}
|
|
118
28
|
|
|
119
29
|
// Ответы
|
|
120
|
-
|
|
121
30
|
message GetAllCategoriesResponse {
|
|
122
31
|
repeated Category categories = 1;
|
|
123
32
|
}
|
|
@@ -126,34 +35,10 @@ message GetCategoryResponse {
|
|
|
126
35
|
Category category = 1;
|
|
127
36
|
}
|
|
128
37
|
|
|
129
|
-
message
|
|
38
|
+
message GetCategoryAttributesResponse {
|
|
130
39
|
repeated CategoryAttribute attributes = 1;
|
|
131
40
|
}
|
|
132
41
|
|
|
133
|
-
message CreateCategoryResponse {
|
|
134
|
-
Category category = 1;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
message UpdateCategoryResponse {
|
|
138
|
-
Category category = 1;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
message DeleteCategoryResponse {
|
|
142
|
-
bool ok = 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
message CreateAttributeResponse {
|
|
146
|
-
CategoryAttribute attribute = 1;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
message UpdateAttributeResponse {
|
|
150
|
-
CategoryAttribute attribute = 1;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
message DeleteAttributeResponse {
|
|
154
|
-
bool ok = 1;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
42
|
// Модели
|
|
158
43
|
|
|
159
44
|
message Category {
|