@barumetric/contracts 1.1.8 → 1.1.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.
@@ -3,4 +3,5 @@ export declare const PROTO_PATHS: {
3
3
  readonly ACCOUNT: string;
4
4
  readonly USERS: string;
5
5
  readonly MEDIA: string;
6
+ readonly CATEGORIES: string;
6
7
  };
@@ -7,4 +7,5 @@ exports.PROTO_PATHS = {
7
7
  ACCOUNT: (0, path_1.join)(__dirname, "../../proto/account.proto"),
8
8
  USERS: (0, path_1.join)(__dirname, "../../proto/users.proto"),
9
9
  MEDIA: (0, path_1.join)(__dirname, "../../proto/media.proto"),
10
+ CATEGORIES: (0, path_1.join)(__dirname, "../../proto/categories.proto"),
10
11
  };
@@ -0,0 +1,383 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v3.21.12
5
+ // source: categories.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "categories.v1";
12
+
13
+ /** Типы атрибутов */
14
+ export enum AttributeType {
15
+ ATTRIBUTE_TYPE_UNSPECIFIED = 0,
16
+ ATTRIBUTE_TYPE_STRING = 1,
17
+ ATTRIBUTE_TYPE_TEXT = 2,
18
+ ATTRIBUTE_TYPE_INTEGER = 3,
19
+ ATTRIBUTE_TYPE_FLOAT = 4,
20
+ ATTRIBUTE_TYPE_BOOLEAN = 5,
21
+ ATTRIBUTE_TYPE_ENUM = 6,
22
+ ATTRIBUTE_TYPE_MULTI_ENUM = 7,
23
+ ATTRIBUTE_TYPE_RANGE = 8,
24
+ ATTRIBUTE_TYPE_DATE = 9,
25
+ UNRECOGNIZED = -1,
26
+ }
27
+
28
+ export interface GetTreeRequest {
29
+ /** Если не указан, возвращает корневые категории */
30
+ parentId?:
31
+ | string
32
+ | undefined;
33
+ /** Максимальная глубина (0 = без ограничений) */
34
+ maxDepth: number;
35
+ /** Только активные категории */
36
+ onlyActive: boolean;
37
+ }
38
+
39
+ export interface GetCategoryRequest {
40
+ id: string;
41
+ /** Включить атрибуты */
42
+ includeAttributes: boolean;
43
+ }
44
+
45
+ export interface GetCategoryBySlugRequest {
46
+ slug: string;
47
+ /** Для уникальности */
48
+ parentId?: string | undefined;
49
+ includeAttributes: boolean;
50
+ }
51
+
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
+ export interface GetAttributesRequest {
65
+ categoryId: string;
66
+ /** Только для фильтров */
67
+ onlyFilterable: boolean;
68
+ /** Включить наследуемые от родителей */
69
+ includeInherited: boolean;
70
+ }
71
+
72
+ export interface CreateCategoryRequest {
73
+ name: string;
74
+ slug: string;
75
+ description?: string | undefined;
76
+ iconUrl?: string | undefined;
77
+ bannerUrl?: string | undefined;
78
+ parentId?: string | undefined;
79
+ isLeaf: boolean;
80
+ sortOrder: number;
81
+ }
82
+
83
+ export interface UpdateCategoryRequest {
84
+ id: string;
85
+ name?: string | undefined;
86
+ slug?: string | undefined;
87
+ description?: string | undefined;
88
+ iconUrl?: string | undefined;
89
+ bannerUrl?: string | undefined;
90
+ isLeaf?: boolean | undefined;
91
+ isActive?: boolean | undefined;
92
+ sortOrder?: number | undefined;
93
+ }
94
+
95
+ export interface DeleteCategoryRequest {
96
+ id: string;
97
+ /** Удалить дочерние категории */
98
+ cascade: boolean;
99
+ }
100
+
101
+ export interface CreateAttributeRequest {
102
+ categoryId: string;
103
+ name: string;
104
+ key: string;
105
+ type: AttributeType;
106
+ isRequired: boolean;
107
+ isFilterable: boolean;
108
+ inherited: boolean;
109
+ unit?: string | undefined;
110
+ minValue?: number | undefined;
111
+ maxValue?: number | undefined;
112
+ sortOrder: number;
113
+ /** Для ENUM/MULTI_ENUM типов */
114
+ enumValues: EnumValueInput[];
115
+ }
116
+
117
+ export interface UpdateAttributeRequest {
118
+ 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;
126
+ enumValues: EnumValueInput[];
127
+ }
128
+
129
+ export interface DeleteAttributeRequest {
130
+ id: string;
131
+ }
132
+
133
+ export interface GetTreeResponse {
134
+ nodes: CategoryNode[];
135
+ }
136
+
137
+ export interface GetCategoryResponse {
138
+ category: Category | undefined;
139
+ }
140
+
141
+ export interface GetChildrenResponse {
142
+ categories: Category[];
143
+ }
144
+
145
+ export interface GetPopularResponse {
146
+ categories: Category[];
147
+ }
148
+
149
+ export interface GetAttributesResponse {
150
+ attributes: CategoryAttribute[];
151
+ }
152
+
153
+ export interface CreateCategoryResponse {
154
+ category: Category | undefined;
155
+ }
156
+
157
+ export interface UpdateCategoryResponse {
158
+ category: Category | undefined;
159
+ }
160
+
161
+ export interface DeleteCategoryResponse {
162
+ ok: boolean;
163
+ }
164
+
165
+ export interface CreateAttributeResponse {
166
+ attribute: CategoryAttribute | undefined;
167
+ }
168
+
169
+ export interface UpdateAttributeResponse {
170
+ attribute: CategoryAttribute | undefined;
171
+ }
172
+
173
+ export interface DeleteAttributeResponse {
174
+ ok: boolean;
175
+ }
176
+
177
+ export interface Category {
178
+ id: string;
179
+ name: string;
180
+ slug: string;
181
+ description?: string | undefined;
182
+ iconUrl?: string | undefined;
183
+ bannerUrl?: string | undefined;
184
+ isLeaf: boolean;
185
+ isActive: boolean;
186
+ sortOrder: number;
187
+ parentId?: string | undefined;
188
+ path: string;
189
+ depth: number;
190
+ adsCount: number;
191
+ /** Для дерева */
192
+ children: Category[];
193
+ /** Если include_attributes = true */
194
+ attributes: CategoryAttribute[];
195
+ }
196
+
197
+ export interface CategoryNode {
198
+ category: Category | undefined;
199
+ children: CategoryNode[];
200
+ }
201
+
202
+ export interface CategoryAttribute {
203
+ id: string;
204
+ categoryId: string;
205
+ name: string;
206
+ key: string;
207
+ type: AttributeType;
208
+ isRequired: boolean;
209
+ isFilterable: boolean;
210
+ inherited: boolean;
211
+ unit?: string | undefined;
212
+ minValue?: number | undefined;
213
+ maxValue?: number | undefined;
214
+ sortOrder: number;
215
+ enumValues: EnumValue[];
216
+ }
217
+
218
+ export interface EnumValue {
219
+ id: string;
220
+ value: string;
221
+ label: string;
222
+ sortOrder: number;
223
+ }
224
+
225
+ export interface EnumValueInput {
226
+ value: string;
227
+ label: string;
228
+ sortOrder: number;
229
+ }
230
+
231
+ export const CATEGORIES_V1_PACKAGE_NAME = "categories.v1";
232
+
233
+ export interface CategoriesServiceClient {
234
+ /** Получить дерево категорий */
235
+
236
+ getTree(request: GetTreeRequest): Observable<GetTreeResponse>;
237
+
238
+ /** Получить категорию по ID */
239
+
240
+ getCategory(request: GetCategoryRequest): Observable<GetCategoryResponse>;
241
+
242
+ /** Получить категорию по slug */
243
+
244
+ getCategoryBySlug(request: GetCategoryBySlugRequest): Observable<GetCategoryResponse>;
245
+
246
+ /** Получить дочерние категории */
247
+
248
+ getChildren(request: GetChildrenRequest): Observable<GetChildrenResponse>;
249
+
250
+ /** Получить популярные категории */
251
+
252
+ getPopular(request: GetPopularRequest): Observable<GetPopularResponse>;
253
+
254
+ /** Получить атрибуты категории (для фильтров) */
255
+
256
+ getAttributes(request: GetAttributesRequest): Observable<GetAttributesResponse>;
257
+
258
+ /** Создать категорию (админ) */
259
+
260
+ createCategory(request: CreateCategoryRequest): Observable<CreateCategoryResponse>;
261
+
262
+ /** Обновить категорию (админ) */
263
+
264
+ updateCategory(request: UpdateCategoryRequest): Observable<UpdateCategoryResponse>;
265
+
266
+ /** Удалить категорию (админ) */
267
+
268
+ deleteCategory(request: DeleteCategoryRequest): Observable<DeleteCategoryResponse>;
269
+
270
+ /** Создать атрибут (админ) */
271
+
272
+ createAttribute(request: CreateAttributeRequest): Observable<CreateAttributeResponse>;
273
+
274
+ /** Обновить атрибут (админ) */
275
+
276
+ updateAttribute(request: UpdateAttributeRequest): Observable<UpdateAttributeResponse>;
277
+
278
+ /** Удалить атрибут (админ) */
279
+
280
+ deleteAttribute(request: DeleteAttributeRequest): Observable<DeleteAttributeResponse>;
281
+ }
282
+
283
+ export interface CategoriesServiceController {
284
+ /** Получить дерево категорий */
285
+
286
+ getTree(request: GetTreeRequest): Promise<GetTreeResponse> | Observable<GetTreeResponse> | GetTreeResponse;
287
+
288
+ /** Получить категорию по ID */
289
+
290
+ getCategory(
291
+ request: GetCategoryRequest,
292
+ ): Promise<GetCategoryResponse> | Observable<GetCategoryResponse> | GetCategoryResponse;
293
+
294
+ /** Получить категорию по slug */
295
+
296
+ getCategoryBySlug(
297
+ request: GetCategoryBySlugRequest,
298
+ ): Promise<GetCategoryResponse> | Observable<GetCategoryResponse> | GetCategoryResponse;
299
+
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
+ /** Получить атрибуты категории (для фильтров) */
313
+
314
+ getAttributes(
315
+ request: GetAttributesRequest,
316
+ ): Promise<GetAttributesResponse> | Observable<GetAttributesResponse> | GetAttributesResponse;
317
+
318
+ /** Создать категорию (админ) */
319
+
320
+ createCategory(
321
+ request: CreateCategoryRequest,
322
+ ): Promise<CreateCategoryResponse> | Observable<CreateCategoryResponse> | CreateCategoryResponse;
323
+
324
+ /** Обновить категорию (админ) */
325
+
326
+ updateCategory(
327
+ request: UpdateCategoryRequest,
328
+ ): Promise<UpdateCategoryResponse> | Observable<UpdateCategoryResponse> | UpdateCategoryResponse;
329
+
330
+ /** Удалить категорию (админ) */
331
+
332
+ deleteCategory(
333
+ request: DeleteCategoryRequest,
334
+ ): Promise<DeleteCategoryResponse> | Observable<DeleteCategoryResponse> | DeleteCategoryResponse;
335
+
336
+ /** Создать атрибут (админ) */
337
+
338
+ createAttribute(
339
+ request: CreateAttributeRequest,
340
+ ): Promise<CreateAttributeResponse> | Observable<CreateAttributeResponse> | CreateAttributeResponse;
341
+
342
+ /** Обновить атрибут (админ) */
343
+
344
+ updateAttribute(
345
+ request: UpdateAttributeRequest,
346
+ ): Promise<UpdateAttributeResponse> | Observable<UpdateAttributeResponse> | UpdateAttributeResponse;
347
+
348
+ /** Удалить атрибут (админ) */
349
+
350
+ deleteAttribute(
351
+ request: DeleteAttributeRequest,
352
+ ): Promise<DeleteAttributeResponse> | Observable<DeleteAttributeResponse> | DeleteAttributeResponse;
353
+ }
354
+
355
+ export function CategoriesServiceControllerMethods() {
356
+ return function (constructor: Function) {
357
+ const grpcMethods: string[] = [
358
+ "getTree",
359
+ "getCategory",
360
+ "getCategoryBySlug",
361
+ "getChildren",
362
+ "getPopular",
363
+ "getAttributes",
364
+ "createCategory",
365
+ "updateCategory",
366
+ "deleteCategory",
367
+ "createAttribute",
368
+ "updateAttribute",
369
+ "deleteAttribute",
370
+ ];
371
+ for (const method of grpcMethods) {
372
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
373
+ GrpcMethod("CategoriesService", method)(constructor.prototype[method], method, descriptor);
374
+ }
375
+ const grpcStreamMethods: string[] = [];
376
+ for (const method of grpcStreamMethods) {
377
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
378
+ GrpcStreamMethod("CategoriesService", method)(constructor.prototype[method], method, descriptor);
379
+ }
380
+ };
381
+ }
382
+
383
+ export const CATEGORIES_SERVICE_NAME = "CategoriesService";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barumetric/contracts",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,252 @@
1
+ syntax = "proto3";
2
+
3
+ package categories.v1;
4
+
5
+ import "google/protobuf/empty.proto";
6
+
7
+ service CategoriesService {
8
+ // Получить дерево категорий
9
+ rpc GetTree (GetTreeRequest) returns (GetTreeResponse);
10
+
11
+ // Получить категорию по ID
12
+ rpc GetCategory (GetCategoryRequest) returns (GetCategoryResponse);
13
+
14
+ // Получить категорию по slug
15
+ rpc GetCategoryBySlug (GetCategoryBySlugRequest) returns (GetCategoryResponse);
16
+
17
+ // Получить дочерние категории
18
+ rpc GetChildren (GetChildrenRequest) returns (GetChildrenResponse);
19
+
20
+ // Получить популярные категории
21
+ rpc GetPopular (GetPopularRequest) returns (GetPopularResponse);
22
+
23
+ // Получить атрибуты категории (для фильтров)
24
+ rpc GetAttributes (GetAttributesRequest) returns (GetAttributesResponse);
25
+
26
+ // Создать категорию (админ)
27
+ rpc CreateCategory (CreateCategoryRequest) returns (CreateCategoryResponse);
28
+
29
+ // Обновить категорию (админ)
30
+ rpc UpdateCategory (UpdateCategoryRequest) returns (UpdateCategoryResponse);
31
+
32
+ // Удалить категорию (админ)
33
+ rpc DeleteCategory (DeleteCategoryRequest) returns (DeleteCategoryResponse);
34
+
35
+ // Создать атрибут (админ)
36
+ rpc CreateAttribute (CreateAttributeRequest) returns (CreateAttributeResponse);
37
+
38
+ // Обновить атрибут (админ)
39
+ rpc UpdateAttribute (UpdateAttributeRequest) returns (UpdateAttributeResponse);
40
+
41
+ // Удалить атрибут (админ)
42
+ rpc DeleteAttribute (DeleteAttributeRequest) returns (DeleteAttributeResponse);
43
+ }
44
+
45
+ // Запросы
46
+
47
+ message GetTreeRequest {
48
+ optional string parent_id = 1; // Если не указан, возвращает корневые категории
49
+ int32 max_depth = 2; // Максимальная глубина (0 = без ограничений)
50
+ bool only_active = 3; // Только активные категории
51
+ }
52
+
53
+ message GetCategoryRequest {
54
+ string id = 1;
55
+ bool include_attributes = 2; // Включить атрибуты
56
+ }
57
+
58
+ message GetCategoryBySlugRequest {
59
+ string slug = 1;
60
+ optional string parent_id = 2; // Для уникальности
61
+ bool include_attributes = 3;
62
+ }
63
+
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
+ message GetAttributesRequest {
75
+ string category_id = 1;
76
+ bool only_filterable = 2; // Только для фильтров
77
+ bool include_inherited = 3; // Включить наследуемые от родителей
78
+ }
79
+
80
+ message CreateCategoryRequest {
81
+ string name = 1;
82
+ string slug = 2;
83
+ optional string description = 3;
84
+ optional string icon_url = 4;
85
+ optional string banner_url = 5;
86
+ optional string parent_id = 6;
87
+ bool is_leaf = 7;
88
+ int32 sort_order = 8;
89
+ }
90
+
91
+ message UpdateCategoryRequest {
92
+ string id = 1;
93
+ optional string name = 2;
94
+ optional string slug = 3;
95
+ optional string description = 4;
96
+ optional string icon_url = 5;
97
+ optional string banner_url = 6;
98
+ optional bool is_leaf = 7;
99
+ optional bool is_active = 8;
100
+ optional int32 sort_order = 9;
101
+ }
102
+
103
+ message DeleteCategoryRequest {
104
+ string id = 1;
105
+ bool cascade = 2; // Удалить дочерние категории
106
+ }
107
+
108
+ message CreateAttributeRequest {
109
+ string category_id = 1;
110
+ string name = 2;
111
+ string key = 3;
112
+ 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 типов
121
+ }
122
+
123
+ 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;
133
+ }
134
+
135
+ message DeleteAttributeRequest {
136
+ string id = 1;
137
+ }
138
+
139
+ // Ответы
140
+
141
+ message GetTreeResponse {
142
+ repeated CategoryNode nodes = 1;
143
+ }
144
+
145
+ message GetCategoryResponse {
146
+ Category category = 1;
147
+ }
148
+
149
+ message GetChildrenResponse {
150
+ repeated Category categories = 1;
151
+ }
152
+
153
+ message GetPopularResponse {
154
+ repeated Category categories = 1;
155
+ }
156
+
157
+ message GetAttributesResponse {
158
+ repeated CategoryAttribute attributes = 1;
159
+ }
160
+
161
+ message CreateCategoryResponse {
162
+ Category category = 1;
163
+ }
164
+
165
+ message UpdateCategoryResponse {
166
+ Category category = 1;
167
+ }
168
+
169
+ message DeleteCategoryResponse {
170
+ bool ok = 1;
171
+ }
172
+
173
+ message CreateAttributeResponse {
174
+ CategoryAttribute attribute = 1;
175
+ }
176
+
177
+ message UpdateAttributeResponse {
178
+ CategoryAttribute attribute = 1;
179
+ }
180
+
181
+ message DeleteAttributeResponse {
182
+ bool ok = 1;
183
+ }
184
+
185
+ // Модели
186
+
187
+ message Category {
188
+ string id = 1;
189
+ string name = 2;
190
+ string slug = 3;
191
+ optional string description = 4;
192
+ optional string icon_url = 5;
193
+ optional string banner_url = 6;
194
+ bool is_leaf = 7;
195
+ bool is_active = 8;
196
+ int32 sort_order = 9;
197
+ optional string parent_id = 10;
198
+ string path = 11;
199
+ int32 depth = 12;
200
+ int64 ads_count = 13;
201
+ repeated Category children = 14; // Для дерева
202
+ repeated CategoryAttribute attributes = 15; // Если include_attributes = true
203
+ }
204
+
205
+ message CategoryNode {
206
+ Category category = 1;
207
+ repeated CategoryNode children = 2;
208
+ }
209
+
210
+ 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;
224
+ }
225
+
226
+ message EnumValue {
227
+ string id = 1;
228
+ string value = 2;
229
+ string label = 3;
230
+ int32 sort_order = 4;
231
+ }
232
+
233
+ message EnumValueInput {
234
+ string value = 1;
235
+ string label = 2;
236
+ int32 sort_order = 3;
237
+ }
238
+
239
+ // Типы атрибутов
240
+ enum AttributeType {
241
+ ATTRIBUTE_TYPE_UNSPECIFIED = 0;
242
+ ATTRIBUTE_TYPE_STRING = 1;
243
+ ATTRIBUTE_TYPE_TEXT = 2;
244
+ ATTRIBUTE_TYPE_INTEGER = 3;
245
+ ATTRIBUTE_TYPE_FLOAT = 4;
246
+ ATTRIBUTE_TYPE_BOOLEAN = 5;
247
+ ATTRIBUTE_TYPE_ENUM = 6;
248
+ ATTRIBUTE_TYPE_MULTI_ENUM = 7;
249
+ ATTRIBUTE_TYPE_RANGE = 8;
250
+ ATTRIBUTE_TYPE_DATE = 9;
251
+ }
252
+