@barumetric/contracts 1.2.15 → 1.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.
@@ -6,4 +6,5 @@ export declare const PROTO_PATHS: {
6
6
  readonly CATEGORIES: string;
7
7
  readonly SESSION: string;
8
8
  readonly PRESENCE: string;
9
+ readonly AD: string;
9
10
  };
@@ -10,4 +10,5 @@ exports.PROTO_PATHS = {
10
10
  CATEGORIES: (0, path_1.join)(__dirname, "../../proto/categories.proto"),
11
11
  SESSION: (0, path_1.join)(__dirname, "../../proto/session.proto"),
12
12
  PRESENCE: (0, path_1.join)(__dirname, "../../proto/presence.proto"),
13
+ AD: (0, path_1.join)(__dirname, "../../proto/ad.proto"),
13
14
  };
package/gen/ts/ad.ts ADDED
@@ -0,0 +1,234 @@
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: ad.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "ad.v1";
12
+
13
+ export enum AdStatus {
14
+ AD_STATUS_UNSPECIFIED = 0,
15
+ AD_STATUS_DRAFT = 1,
16
+ AD_STATUS_MODERATION = 2,
17
+ AD_STATUS_ACTIVE = 3,
18
+ AD_STATUS_SOLD = 4,
19
+ AD_STATUS_ARCHIVED = 5,
20
+ AD_STATUS_REJECTED = 6,
21
+ UNRECOGNIZED = -1,
22
+ }
23
+
24
+ export interface CreateAdRequest {
25
+ userId: string;
26
+ categoryId: string;
27
+ title: string;
28
+ description?: string | undefined;
29
+ price: number;
30
+ currency?: string | undefined;
31
+ location?: Location | undefined;
32
+ attributes?: Attributes | undefined;
33
+ imageUrls: string[];
34
+ }
35
+
36
+ export interface UpdateAdRequest {
37
+ id: string;
38
+ userId: string;
39
+ categoryId?: string | undefined;
40
+ title?: string | undefined;
41
+ description?: string | undefined;
42
+ price?: number | undefined;
43
+ currency?: string | undefined;
44
+ location?: Location | undefined;
45
+ attributes?: Attributes | undefined;
46
+ imageUrls: string[];
47
+ }
48
+
49
+ export interface GetAdRequest {
50
+ id: string;
51
+ /** для проверки прав доступа */
52
+ userId?: string | undefined;
53
+ }
54
+
55
+ export interface DeleteAdRequest {
56
+ id: string;
57
+ userId: string;
58
+ }
59
+
60
+ export interface ListAdsRequest {
61
+ categoryId?: string | undefined;
62
+ userId?: string | undefined;
63
+ status?: AdStatus | undefined;
64
+ page: number;
65
+ pageSize: number;
66
+ minPrice?: number | undefined;
67
+ maxPrice?:
68
+ | number
69
+ | undefined;
70
+ /** "created_at", "price", "views" */
71
+ sortBy?:
72
+ | string
73
+ | undefined;
74
+ /** "asc", "desc" */
75
+ sortOrder?: string | undefined;
76
+ }
77
+
78
+ export interface GetMyAdsRequest {
79
+ userId: string;
80
+ status?: AdStatus | undefined;
81
+ page: number;
82
+ pageSize: number;
83
+ }
84
+
85
+ export interface PublishAdRequest {
86
+ id: string;
87
+ userId: string;
88
+ }
89
+
90
+ export interface ArchiveAdRequest {
91
+ id: string;
92
+ userId: string;
93
+ }
94
+
95
+ export interface CreateAdResponse {
96
+ ad: Ad | undefined;
97
+ }
98
+
99
+ export interface GetAdResponse {
100
+ ad: Ad | undefined;
101
+ }
102
+
103
+ export interface UpdateAdResponse {
104
+ ad: Ad | undefined;
105
+ }
106
+
107
+ export interface DeleteAdResponse {
108
+ ok: boolean;
109
+ }
110
+
111
+ export interface ListAdsResponse {
112
+ ads: Ad[];
113
+ total: number;
114
+ page: number;
115
+ pageSize: number;
116
+ }
117
+
118
+ export interface PublishAdResponse {
119
+ ad: Ad | undefined;
120
+ }
121
+
122
+ export interface ArchiveAdResponse {
123
+ ad: Ad | undefined;
124
+ }
125
+
126
+ export interface Ad {
127
+ id: string;
128
+ userId: string;
129
+ categoryId: string;
130
+ title: string;
131
+ description?: string | undefined;
132
+ price: number;
133
+ currency: string;
134
+ status: AdStatus;
135
+ location?: Location | undefined;
136
+ attributes?: Attributes | undefined;
137
+ images: AdImage[];
138
+ views: number;
139
+ favorites: number;
140
+ promoted: boolean;
141
+ promotedUntil?: number | undefined;
142
+ createdAt: number;
143
+ updatedAt: number;
144
+ publishedAt?: number | undefined;
145
+ }
146
+
147
+ export interface AdImage {
148
+ id: string;
149
+ url: string;
150
+ order: number;
151
+ isPrimary: boolean;
152
+ }
153
+
154
+ export interface Location {
155
+ lat: number;
156
+ lng: number;
157
+ address?: string | undefined;
158
+ city?: string | undefined;
159
+ region?: string | undefined;
160
+ }
161
+
162
+ export interface Attributes {
163
+ /** key-value пары атрибутов */
164
+ values: { [key: string]: string };
165
+ }
166
+
167
+ export interface Attributes_ValuesEntry {
168
+ key: string;
169
+ value: string;
170
+ }
171
+
172
+ export const AD_V1_PACKAGE_NAME = "ad.v1";
173
+
174
+ export interface AdServiceClient {
175
+ createAd(request: CreateAdRequest): Observable<CreateAdResponse>;
176
+
177
+ getAd(request: GetAdRequest): Observable<GetAdResponse>;
178
+
179
+ updateAd(request: UpdateAdRequest): Observable<UpdateAdResponse>;
180
+
181
+ deleteAd(request: DeleteAdRequest): Observable<DeleteAdResponse>;
182
+
183
+ listAds(request: ListAdsRequest): Observable<ListAdsResponse>;
184
+
185
+ getMyAds(request: GetMyAdsRequest): Observable<ListAdsResponse>;
186
+
187
+ publishAd(request: PublishAdRequest): Observable<PublishAdResponse>;
188
+
189
+ archiveAd(request: ArchiveAdRequest): Observable<ArchiveAdResponse>;
190
+ }
191
+
192
+ export interface AdServiceController {
193
+ createAd(request: CreateAdRequest): Promise<CreateAdResponse> | Observable<CreateAdResponse> | CreateAdResponse;
194
+
195
+ getAd(request: GetAdRequest): Promise<GetAdResponse> | Observable<GetAdResponse> | GetAdResponse;
196
+
197
+ updateAd(request: UpdateAdRequest): Promise<UpdateAdResponse> | Observable<UpdateAdResponse> | UpdateAdResponse;
198
+
199
+ deleteAd(request: DeleteAdRequest): Promise<DeleteAdResponse> | Observable<DeleteAdResponse> | DeleteAdResponse;
200
+
201
+ listAds(request: ListAdsRequest): Promise<ListAdsResponse> | Observable<ListAdsResponse> | ListAdsResponse;
202
+
203
+ getMyAds(request: GetMyAdsRequest): Promise<ListAdsResponse> | Observable<ListAdsResponse> | ListAdsResponse;
204
+
205
+ publishAd(request: PublishAdRequest): Promise<PublishAdResponse> | Observable<PublishAdResponse> | PublishAdResponse;
206
+
207
+ archiveAd(request: ArchiveAdRequest): Promise<ArchiveAdResponse> | Observable<ArchiveAdResponse> | ArchiveAdResponse;
208
+ }
209
+
210
+ export function AdServiceControllerMethods() {
211
+ return function (constructor: Function) {
212
+ const grpcMethods: string[] = [
213
+ "createAd",
214
+ "getAd",
215
+ "updateAd",
216
+ "deleteAd",
217
+ "listAds",
218
+ "getMyAds",
219
+ "publishAd",
220
+ "archiveAd",
221
+ ];
222
+ for (const method of grpcMethods) {
223
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
224
+ GrpcMethod("AdService", method)(constructor.prototype[method], method, descriptor);
225
+ }
226
+ const grpcStreamMethods: string[] = [];
227
+ for (const method of grpcStreamMethods) {
228
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
229
+ GrpcStreamMethod("AdService", method)(constructor.prototype[method], method, descriptor);
230
+ }
231
+ };
232
+ }
233
+
234
+ export const AD_SERVICE_NAME = "AdService";
package/gen/ts/auth.ts CHANGED
@@ -139,6 +139,21 @@ export interface VkConsumeResponse {
139
139
  sessionToken: string;
140
140
  }
141
141
 
142
+ export interface GoogleInitResponse {
143
+ url: string;
144
+ }
145
+
146
+ export interface GoogleVerifyRequest {
147
+ idToken: string;
148
+ metadata: SessionMetadata | undefined;
149
+ }
150
+
151
+ export interface GoogleVerifyResponse {
152
+ accessToken: string;
153
+ refreshToken: string;
154
+ sessionToken: string;
155
+ }
156
+
142
157
  export const AUTH_V1_PACKAGE_NAME = "auth.v1";
143
158
 
144
159
  export interface AuthServiceClient {
@@ -163,6 +178,10 @@ export interface AuthServiceClient {
163
178
  vkVerify(request: VkVerifyRequest): Observable<VkVerifyResponse>;
164
179
 
165
180
  vkConsume(request: VkConsumeRequest): Observable<VkConsumeResponse>;
181
+
182
+ googleInit(request: Empty): Observable<GoogleInitResponse>;
183
+
184
+ googleVerify(request: GoogleVerifyRequest): Observable<GoogleVerifyResponse>;
166
185
  }
167
186
 
168
187
  export interface AuthServiceController {
@@ -193,6 +212,12 @@ export interface AuthServiceController {
193
212
  vkVerify(request: VkVerifyRequest): Promise<VkVerifyResponse> | Observable<VkVerifyResponse> | VkVerifyResponse;
194
213
 
195
214
  vkConsume(request: VkConsumeRequest): Promise<VkConsumeResponse> | Observable<VkConsumeResponse> | VkConsumeResponse;
215
+
216
+ googleInit(request: Empty): Promise<GoogleInitResponse> | Observable<GoogleInitResponse> | GoogleInitResponse;
217
+
218
+ googleVerify(
219
+ request: GoogleVerifyRequest,
220
+ ): Promise<GoogleVerifyResponse> | Observable<GoogleVerifyResponse> | GoogleVerifyResponse;
196
221
  }
197
222
 
198
223
  export function AuthServiceControllerMethods() {
@@ -209,6 +234,8 @@ export function AuthServiceControllerMethods() {
209
234
  "vkInit",
210
235
  "vkVerify",
211
236
  "vkConsume",
237
+ "googleInit",
238
+ "googleVerify",
212
239
  ];
213
240
  for (const method of grpcMethods) {
214
241
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barumetric/contracts",
3
- "version": "1.2.15",
3
+ "version": "1.3.0",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/proto/ad.proto ADDED
@@ -0,0 +1,162 @@
1
+ syntax = "proto3";
2
+
3
+ package ad.v1;
4
+
5
+ import "google/protobuf/empty.proto";
6
+
7
+ service AdService {
8
+ rpc CreateAd (CreateAdRequest) returns (CreateAdResponse);
9
+ rpc GetAd (GetAdRequest) returns (GetAdResponse);
10
+ rpc UpdateAd (UpdateAdRequest) returns (UpdateAdResponse);
11
+ rpc DeleteAd (DeleteAdRequest) returns (DeleteAdResponse);
12
+ rpc ListAds (ListAdsRequest) returns (ListAdsResponse);
13
+ rpc GetMyAds (GetMyAdsRequest) returns (ListAdsResponse);
14
+ rpc PublishAd (PublishAdRequest) returns (PublishAdResponse);
15
+ rpc ArchiveAd (ArchiveAdRequest) returns (ArchiveAdResponse);
16
+ }
17
+
18
+ enum AdStatus {
19
+ AD_STATUS_UNSPECIFIED = 0;
20
+ AD_STATUS_DRAFT = 1;
21
+ AD_STATUS_MODERATION = 2;
22
+ AD_STATUS_ACTIVE = 3;
23
+ AD_STATUS_SOLD = 4;
24
+ AD_STATUS_ARCHIVED = 5;
25
+ AD_STATUS_REJECTED = 6;
26
+ }
27
+
28
+ message CreateAdRequest {
29
+ string user_id = 1;
30
+ string category_id = 2;
31
+ string title = 3;
32
+ optional string description = 4;
33
+ double price = 5;
34
+ optional string currency = 6;
35
+ optional Location location = 7;
36
+ optional Attributes attributes = 8;
37
+ repeated string image_urls = 9;
38
+ }
39
+
40
+ message UpdateAdRequest {
41
+ string id = 1;
42
+ string user_id = 2;
43
+ optional string category_id = 3;
44
+ optional string title = 4;
45
+ optional string description = 5;
46
+ optional double price = 6;
47
+ optional string currency = 7;
48
+ optional Location location = 8;
49
+ optional Attributes attributes = 9;
50
+ repeated string image_urls = 10;
51
+ }
52
+
53
+ message GetAdRequest {
54
+ string id = 1;
55
+ optional string user_id = 2; // для проверки прав доступа
56
+ }
57
+
58
+ message DeleteAdRequest {
59
+ string id = 1;
60
+ string user_id = 2;
61
+ }
62
+
63
+ message ListAdsRequest {
64
+ optional string category_id = 1;
65
+ optional string user_id = 2;
66
+ optional AdStatus status = 3;
67
+ int32 page = 4;
68
+ int32 page_size = 5;
69
+ optional double min_price = 6;
70
+ optional double max_price = 7;
71
+ optional string sort_by = 8; // "created_at", "price", "views"
72
+ optional string sort_order = 9; // "asc", "desc"
73
+ }
74
+
75
+ message GetMyAdsRequest {
76
+ string user_id = 1;
77
+ optional AdStatus status = 2;
78
+ int32 page = 3;
79
+ int32 page_size = 4;
80
+ }
81
+
82
+ message PublishAdRequest {
83
+ string id = 1;
84
+ string user_id = 2;
85
+ }
86
+
87
+ message ArchiveAdRequest {
88
+ string id = 1;
89
+ string user_id = 2;
90
+ }
91
+
92
+ message CreateAdResponse {
93
+ Ad ad = 1;
94
+ }
95
+
96
+ message GetAdResponse {
97
+ Ad ad = 1;
98
+ }
99
+
100
+ message UpdateAdResponse {
101
+ Ad ad = 1;
102
+ }
103
+
104
+ message DeleteAdResponse {
105
+ bool ok = 1;
106
+ }
107
+
108
+ message ListAdsResponse {
109
+ repeated Ad ads = 1;
110
+ int32 total = 2;
111
+ int32 page = 3;
112
+ int32 page_size = 4;
113
+ }
114
+
115
+ message PublishAdResponse {
116
+ Ad ad = 1;
117
+ }
118
+
119
+ message ArchiveAdResponse {
120
+ Ad ad = 1;
121
+ }
122
+
123
+ message Ad {
124
+ string id = 1;
125
+ string user_id = 2;
126
+ string category_id = 3;
127
+ string title = 4;
128
+ optional string description = 5;
129
+ double price = 6;
130
+ string currency = 7;
131
+ AdStatus status = 8;
132
+ optional Location location = 9;
133
+ optional Attributes attributes = 10;
134
+ repeated AdImage images = 11;
135
+ int32 views = 12;
136
+ int32 favorites = 13;
137
+ bool promoted = 14;
138
+ optional int64 promoted_until = 15;
139
+ int64 created_at = 16;
140
+ int64 updated_at = 17;
141
+ optional int64 published_at = 18;
142
+ }
143
+
144
+ message AdImage {
145
+ string id = 1;
146
+ string url = 2;
147
+ int32 order = 3;
148
+ bool is_primary = 4;
149
+ }
150
+
151
+ message Location {
152
+ double lat = 1;
153
+ double lng = 2;
154
+ optional string address = 3;
155
+ optional string city = 4;
156
+ optional string region = 5;
157
+ }
158
+
159
+ message Attributes {
160
+ map<string, string> values = 1; // key-value пары атрибутов
161
+ }
162
+
package/proto/auth.proto CHANGED
@@ -18,6 +18,9 @@ service AuthService {
18
18
  rpc VkInit (google.protobuf.Empty) returns (VkInitResponse);
19
19
  rpc VkVerify (VkVerifyRequest) returns (VkVerifyResponse);
20
20
  rpc VkConsume (VkConsumeRequest) returns (VkConsumeResponse);
21
+
22
+ rpc GoogleInit (google.protobuf.Empty) returns (GoogleInitResponse);
23
+ rpc GoogleVerify (GoogleVerifyRequest) returns (GoogleVerifyResponse);
21
24
  }
22
25
 
23
26
  message SendOtpRequest {
@@ -147,3 +150,18 @@ message VkConsumeResponse {
147
150
  string refresh_token = 2;
148
151
  string session_token = 3;
149
152
  }
153
+
154
+ message GoogleInitResponse {
155
+ string url = 1;
156
+ }
157
+
158
+ message GoogleVerifyRequest {
159
+ string id_token = 1;
160
+ SessionMetadata metadata = 2;
161
+ }
162
+
163
+ message GoogleVerifyResponse {
164
+ string access_token = 1;
165
+ string refresh_token = 2;
166
+ string session_token = 3;
167
+ }