@barumetric/contracts 1.1.9 → 1.2.1

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.
@@ -7,6 +7,7 @@
7
7
  /* eslint-disable */
8
8
  import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
9
  import { Observable } from "rxjs";
10
+ import { Empty } from "./google/protobuf/empty";
10
11
 
11
12
  export const protobufPackage = "categories.v1";
12
13
 
@@ -49,18 +50,6 @@ export interface GetCategoryBySlugRequest {
49
50
  includeAttributes: boolean;
50
51
  }
51
52
 
52
- export interface GetChildrenRequest {
53
- parentId: string;
54
- onlyActive: boolean;
55
- }
56
-
57
- export interface GetPopularRequest {
58
- /** Количество категорий */
59
- limit: number;
60
- /** Популярные в конкретной категории */
61
- parentId?: string | undefined;
62
- }
63
-
64
53
  export interface GetAttributesRequest {
65
54
  categoryId: string;
66
55
  /** Только для фильтров */
@@ -99,53 +88,73 @@ export interface DeleteCategoryRequest {
99
88
  }
100
89
 
101
90
  export interface CreateAttributeRequest {
91
+ /** Категория, к которой привязываем атрибут */
102
92
  categoryId: string;
93
+ /** Название атрибута */
103
94
  name: string;
95
+ /** Глобальный ключ (если атрибут с таким key уже существует, он будет переиспользован) */
104
96
  key: string;
105
97
  type: AttributeType;
106
- isRequired: boolean;
107
- isFilterable: boolean;
98
+ /** Override для категории (null = использовать default из Attribute) */
99
+ isRequired?:
100
+ | boolean
101
+ | undefined;
102
+ /** Override для категории (null = использовать default из Attribute) */
103
+ isFilterable?:
104
+ | boolean
105
+ | undefined;
106
+ /** Наследуется ли атрибут дочерним категориям */
108
107
  inherited: boolean;
109
- unit?: string | undefined;
110
- minValue?: number | undefined;
111
- maxValue?: number | undefined;
108
+ /** Единица измерения (₽, км и т.д.) */
109
+ unit?:
110
+ | string
111
+ | undefined;
112
+ /** Минимальное значение */
113
+ minValue?:
114
+ | number
115
+ | undefined;
116
+ /** Максимальное значение */
117
+ maxValue?:
118
+ | number
119
+ | undefined;
120
+ /** Порядок сортировки в категории */
112
121
  sortOrder: number;
113
- /** Для ENUM/MULTI_ENUM типов */
122
+ /** Для ENUM/MULTI_ENUM типов (создаются только если атрибут новый) */
114
123
  enumValues: EnumValueInput[];
115
124
  }
116
125
 
117
126
  export interface UpdateAttributeRequest {
127
+ /** ID CategoryAttribute (связи) */
118
128
  id: string;
119
- name?: string | undefined;
120
- isRequired?: boolean | undefined;
121
- isFilterable?: boolean | undefined;
122
- unit?: string | undefined;
123
- minValue?: number | undefined;
124
- maxValue?: number | undefined;
125
- sortOrder?: number | undefined;
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 глобального атрибута */
126
142
  enumValues: EnumValueInput[];
127
143
  }
128
144
 
129
145
  export interface DeleteAttributeRequest {
146
+ /** ID CategoryAttribute (связи) - удаляется только связь, глобальный Attribute остается */
130
147
  id: string;
131
148
  }
132
149
 
133
- export interface GetTreeResponse {
134
- nodes: CategoryNode[];
150
+ export interface GetAllCategoriesResponse {
151
+ categories: Category[];
135
152
  }
136
153
 
137
154
  export interface GetCategoryResponse {
138
155
  category: Category | undefined;
139
156
  }
140
157
 
141
- export interface GetChildrenResponse {
142
- categories: Category[];
143
- }
144
-
145
- export interface GetPopularResponse {
146
- categories: Category[];
147
- }
148
-
149
158
  export interface GetAttributesResponse {
150
159
  attributes: CategoryAttribute[];
151
160
  }
@@ -194,24 +203,38 @@ export interface Category {
194
203
  attributes: CategoryAttribute[];
195
204
  }
196
205
 
197
- export interface CategoryNode {
198
- category: Category | undefined;
199
- children: CategoryNode[];
200
- }
201
-
202
206
  export interface CategoryAttribute {
207
+ /** ID CategoryAttribute (связи) */
203
208
  id: string;
209
+ /** ID категории */
204
210
  categoryId: string;
211
+ /** Название из глобального Attribute */
205
212
  name: string;
213
+ /** Ключ из глобального Attribute */
206
214
  key: string;
215
+ /** Тип из глобального Attribute */
207
216
  type: AttributeType;
217
+ /** Финальное значение (override или default из Attribute) */
208
218
  isRequired: boolean;
219
+ /** Финальное значение (override или default из Attribute) */
209
220
  isFilterable: boolean;
221
+ /** Наследуется ли дочерним категориям */
210
222
  inherited: boolean;
211
- unit?: string | undefined;
212
- minValue?: number | undefined;
213
- maxValue?: number | undefined;
223
+ /** Единица измерения из глобального Attribute */
224
+ unit?:
225
+ | string
226
+ | undefined;
227
+ /** Минимальное значение из глобального Attribute */
228
+ minValue?:
229
+ | number
230
+ | undefined;
231
+ /** Максимальное значение из глобального Attribute */
232
+ maxValue?:
233
+ | number
234
+ | undefined;
235
+ /** Порядок сортировки в категории */
214
236
  sortOrder: number;
237
+ /** Значения из глобального Attribute */
215
238
  enumValues: EnumValue[];
216
239
  }
217
240
 
@@ -231,9 +254,9 @@ export interface EnumValueInput {
231
254
  export const CATEGORIES_V1_PACKAGE_NAME = "categories.v1";
232
255
 
233
256
  export interface CategoriesServiceClient {
234
- /** Получить дерево категорий */
257
+ /** Получить все категории */
235
258
 
236
- getTree(request: GetTreeRequest): Observable<GetTreeResponse>;
259
+ getAllCategories(request: Empty): Observable<GetAllCategoriesResponse>;
237
260
 
238
261
  /** Получить категорию по ID */
239
262
 
@@ -243,14 +266,6 @@ export interface CategoriesServiceClient {
243
266
 
244
267
  getCategoryBySlug(request: GetCategoryBySlugRequest): Observable<GetCategoryResponse>;
245
268
 
246
- /** Получить дочерние категории */
247
-
248
- getChildren(request: GetChildrenRequest): Observable<GetChildrenResponse>;
249
-
250
- /** Получить популярные категории */
251
-
252
- getPopular(request: GetPopularRequest): Observable<GetPopularResponse>;
253
-
254
269
  /** Получить атрибуты категории (для фильтров) */
255
270
 
256
271
  getAttributes(request: GetAttributesRequest): Observable<GetAttributesResponse>;
@@ -281,9 +296,11 @@ export interface CategoriesServiceClient {
281
296
  }
282
297
 
283
298
  export interface CategoriesServiceController {
284
- /** Получить дерево категорий */
299
+ /** Получить все категории */
285
300
 
286
- getTree(request: GetTreeRequest): Promise<GetTreeResponse> | Observable<GetTreeResponse> | GetTreeResponse;
301
+ getAllCategories(
302
+ request: Empty,
303
+ ): Promise<GetAllCategoriesResponse> | Observable<GetAllCategoriesResponse> | GetAllCategoriesResponse;
287
304
 
288
305
  /** Получить категорию по ID */
289
306
 
@@ -297,18 +314,6 @@ export interface CategoriesServiceController {
297
314
  request: GetCategoryBySlugRequest,
298
315
  ): Promise<GetCategoryResponse> | Observable<GetCategoryResponse> | GetCategoryResponse;
299
316
 
300
- /** Получить дочерние категории */
301
-
302
- getChildren(
303
- request: GetChildrenRequest,
304
- ): Promise<GetChildrenResponse> | Observable<GetChildrenResponse> | GetChildrenResponse;
305
-
306
- /** Получить популярные категории */
307
-
308
- getPopular(
309
- request: GetPopularRequest,
310
- ): Promise<GetPopularResponse> | Observable<GetPopularResponse> | GetPopularResponse;
311
-
312
317
  /** Получить атрибуты категории (для фильтров) */
313
318
 
314
319
  getAttributes(
@@ -355,11 +360,9 @@ export interface CategoriesServiceController {
355
360
  export function CategoriesServiceControllerMethods() {
356
361
  return function (constructor: Function) {
357
362
  const grpcMethods: string[] = [
358
- "getTree",
363
+ "getAllCategories",
359
364
  "getCategory",
360
365
  "getCategoryBySlug",
361
- "getChildren",
362
- "getPopular",
363
366
  "getAttributes",
364
367
  "createCategory",
365
368
  "updateCategory",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barumetric/contracts",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -5,8 +5,8 @@ package categories.v1;
5
5
  import "google/protobuf/empty.proto";
6
6
 
7
7
  service CategoriesService {
8
- // Получить дерево категорий
9
- rpc GetTree (GetTreeRequest) returns (GetTreeResponse);
8
+ // Получить все категории
9
+ rpc GetAllCategories (google.protobuf.Empty) returns (GetAllCategoriesResponse);
10
10
 
11
11
  // Получить категорию по ID
12
12
  rpc GetCategory (GetCategoryRequest) returns (GetCategoryResponse);
@@ -14,12 +14,6 @@ service CategoriesService {
14
14
  // Получить категорию по slug
15
15
  rpc GetCategoryBySlug (GetCategoryBySlugRequest) returns (GetCategoryResponse);
16
16
 
17
- // Получить дочерние категории
18
- rpc GetChildren (GetChildrenRequest) returns (GetChildrenResponse);
19
-
20
- // Получить популярные категории
21
- rpc GetPopular (GetPopularRequest) returns (GetPopularResponse);
22
-
23
17
  // Получить атрибуты категории (для фильтров)
24
18
  rpc GetAttributes (GetAttributesRequest) returns (GetAttributesResponse);
25
19
 
@@ -61,16 +55,6 @@ message GetCategoryBySlugRequest {
61
55
  bool include_attributes = 3;
62
56
  }
63
57
 
64
- message GetChildrenRequest {
65
- string parent_id = 1;
66
- bool only_active = 2;
67
- }
68
-
69
- message GetPopularRequest {
70
- int32 limit = 1; // Количество категорий
71
- optional string parent_id = 2; // Популярные в конкретной категории
72
- }
73
-
74
58
  message GetAttributesRequest {
75
59
  string category_id = 1;
76
60
  bool only_filterable = 2; // Только для фильтров
@@ -106,54 +90,42 @@ message DeleteCategoryRequest {
106
90
  }
107
91
 
108
92
  message CreateAttributeRequest {
109
- string category_id = 1;
110
- string name = 2;
111
- string key = 3;
93
+ string category_id = 1; // Категория, к которой привязываем атрибут
94
+ string name = 2; // Название атрибута
95
+ string key = 3; // Глобальный ключ (если атрибут с таким key уже существует, он будет переиспользован)
112
96
  AttributeType type = 4;
113
- bool is_required = 5;
114
- bool is_filterable = 6;
115
- bool inherited = 7;
116
- optional string unit = 8;
117
- optional float min_value = 9;
118
- optional float max_value = 10;
119
- int32 sort_order = 11;
120
- repeated EnumValueInput enum_values = 12; // Для ENUM/MULTI_ENUM типов
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 типов (создаются только если атрибут новый)
121
105
  }
122
106
 
123
107
  message UpdateAttributeRequest {
124
- string id = 1;
125
- optional string name = 2;
126
- optional bool is_required = 3;
127
- optional bool is_filterable = 4;
128
- optional string unit = 5;
129
- optional float min_value = 6;
130
- optional float max_value = 7;
131
- optional int32 sort_order = 8;
132
- repeated EnumValueInput enum_values = 9;
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 глобального атрибута
133
113
  }
134
114
 
135
115
  message DeleteAttributeRequest {
136
- string id = 1;
116
+ string id = 1; // ID CategoryAttribute (связи) - удаляется только связь, глобальный Attribute остается
137
117
  }
138
118
 
139
119
  // Ответы
140
120
 
141
- message GetTreeResponse {
142
- repeated CategoryNode nodes = 1;
121
+ message GetAllCategoriesResponse {
122
+ repeated Category categories = 1;
143
123
  }
144
124
 
145
125
  message GetCategoryResponse {
146
126
  Category category = 1;
147
127
  }
148
128
 
149
- message GetChildrenResponse {
150
- repeated Category categories = 1;
151
- }
152
-
153
- message GetPopularResponse {
154
- repeated Category categories = 1;
155
- }
156
-
157
129
  message GetAttributesResponse {
158
130
  repeated CategoryAttribute attributes = 1;
159
131
  }
@@ -202,25 +174,20 @@ message Category {
202
174
  repeated CategoryAttribute attributes = 15; // Если include_attributes = true
203
175
  }
204
176
 
205
- message CategoryNode {
206
- Category category = 1;
207
- repeated CategoryNode children = 2;
208
- }
209
-
210
177
  message CategoryAttribute {
211
- string id = 1;
212
- string category_id = 2;
213
- string name = 3;
214
- string key = 4;
215
- AttributeType type = 5;
216
- bool is_required = 6;
217
- bool is_filterable = 7;
218
- bool inherited = 8;
219
- optional string unit = 9;
220
- optional float min_value = 10;
221
- optional float max_value = 11;
222
- int32 sort_order = 12;
223
- repeated EnumValue enum_values = 13;
178
+ string id = 1; // ID CategoryAttribute (связи)
179
+ string category_id = 2; // ID категории
180
+ string name = 3; // Название из глобального Attribute
181
+ string key = 4; // Ключ из глобального Attribute
182
+ AttributeType type = 5; // Тип из глобального Attribute
183
+ bool is_required = 6; // Финальное значение (override или default из Attribute)
184
+ bool is_filterable = 7; // Финальное значение (override или default из Attribute)
185
+ bool inherited = 8; // Наследуется ли дочерним категориям
186
+ optional string unit = 9; // Единица измерения из глобального Attribute
187
+ optional float min_value = 10; // Минимальное значение из глобального Attribute
188
+ optional float max_value = 11; // Максимальное значение из глобального Attribute
189
+ int32 sort_order = 12; // Порядок сортировки в категории
190
+ repeated EnumValue enum_values = 13; // Значения из глобального Attribute
224
191
  }
225
192
 
226
193
  message EnumValue {
@@ -250,3 +217,5 @@ enum AttributeType {
250
217
  ATTRIBUTE_TYPE_DATE = 9;
251
218
  }
252
219
 
220
+
221
+