@barumetric/contracts 1.2.0 → 1.2.2

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