@barumetric/contracts 1.3.18 → 1.3.20
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/dist/events/index.d.ts +1 -0
- package/dist/events/index.js +1 -0
- package/dist/events/listings/create-listing.interface.d.ts +25 -0
- package/dist/events/listings/create-listing.interface.js +2 -0
- package/dist/events/listings/delete-listing.interface.d.ts +4 -0
- package/dist/events/listings/delete-listing.interface.js +2 -0
- package/dist/events/listings/index.d.ts +3 -0
- package/dist/events/listings/index.js +19 -0
- package/dist/events/listings/update-listing.interface.d.ts +26 -0
- package/dist/events/listings/update-listing.interface.js +2 -0
- package/dist/proto/paths.d.ts +1 -1
- package/dist/proto/paths.js +1 -1
- package/gen/ts/listings.ts +148 -0
- package/package.json +1 -1
- package/proto/listings.proto +94 -0
- package/gen/ts/ad.ts +0 -234
- package/proto/ad.proto +0 -162
package/dist/events/index.d.ts
CHANGED
package/dist/events/index.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface CreateListingEvent {
|
|
2
|
+
title: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
price?: number;
|
|
5
|
+
categoryId: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
latitude?: number;
|
|
8
|
+
longitude?: number;
|
|
9
|
+
videoUrl?: string;
|
|
10
|
+
status?: string;
|
|
11
|
+
images?: Array<{
|
|
12
|
+
url: string;
|
|
13
|
+
order?: number;
|
|
14
|
+
}>;
|
|
15
|
+
attributes?: Array<{
|
|
16
|
+
attributeId: string;
|
|
17
|
+
stringValue?: string;
|
|
18
|
+
textValue?: string;
|
|
19
|
+
integerValue?: number;
|
|
20
|
+
floatValue?: number;
|
|
21
|
+
booleanValue?: boolean;
|
|
22
|
+
enumValue?: string;
|
|
23
|
+
multiEnumValue?: string[];
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create-listing.interface"), exports);
|
|
18
|
+
__exportStar(require("./update-listing.interface"), exports);
|
|
19
|
+
__exportStar(require("./delete-listing.interface"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface UpdateListingEvent {
|
|
2
|
+
id: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
price?: number;
|
|
6
|
+
categoryId?: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
latitude?: number;
|
|
9
|
+
longitude?: number;
|
|
10
|
+
videoUrl?: string;
|
|
11
|
+
status?: string;
|
|
12
|
+
images?: Array<{
|
|
13
|
+
url: string;
|
|
14
|
+
order?: number;
|
|
15
|
+
}>;
|
|
16
|
+
attributes?: Array<{
|
|
17
|
+
attributeId: string;
|
|
18
|
+
stringValue?: string;
|
|
19
|
+
textValue?: string;
|
|
20
|
+
integerValue?: number;
|
|
21
|
+
floatValue?: number;
|
|
22
|
+
booleanValue?: boolean;
|
|
23
|
+
enumValue?: string;
|
|
24
|
+
multiEnumValue?: string[];
|
|
25
|
+
}>;
|
|
26
|
+
}
|
package/dist/proto/paths.d.ts
CHANGED
package/dist/proto/paths.js
CHANGED
|
@@ -10,7 +10,7 @@ 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"),
|
|
14
13
|
PAYMENT: (0, path_1.join)(__dirname, "../../proto/payment.proto"),
|
|
15
14
|
BALANCE: (0, path_1.join)(__dirname, "../../proto/balance.proto"),
|
|
15
|
+
LISTINGS: (0, path_1.join)(__dirname, "../../proto/listings.proto"),
|
|
16
16
|
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.0
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
// source: listings.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "listings.v1";
|
|
12
|
+
|
|
13
|
+
/** Статусы объявлений */
|
|
14
|
+
export enum ListingStatus {
|
|
15
|
+
LISTING_STATUS_UNSPECIFIED = 0,
|
|
16
|
+
/** LISTING_STATUS_DRAFT - Черновик */
|
|
17
|
+
LISTING_STATUS_DRAFT = 1,
|
|
18
|
+
/** LISTING_STATUS_ACTIVE - Активные */
|
|
19
|
+
LISTING_STATUS_ACTIVE = 2,
|
|
20
|
+
/** LISTING_STATUS_UNPUBLISHED - Неопубликованные */
|
|
21
|
+
LISTING_STATUS_UNPUBLISHED = 3,
|
|
22
|
+
/** LISTING_STATUS_WITH_ERRORS - С ошибками */
|
|
23
|
+
LISTING_STATUS_WITH_ERRORS = 4,
|
|
24
|
+
/** LISTING_STATUS_ARCHIVED - Архив */
|
|
25
|
+
LISTING_STATUS_ARCHIVED = 5,
|
|
26
|
+
/** LISTING_STATUS_DELETED - Удаленные */
|
|
27
|
+
LISTING_STATUS_DELETED = 6,
|
|
28
|
+
/** LISTING_STATUS_PENDING_REVIEW - На модерации (внутренний) */
|
|
29
|
+
LISTING_STATUS_PENDING_REVIEW = 7,
|
|
30
|
+
/** LISTING_STATUS_REJECTED - Отклонено (внутренний) */
|
|
31
|
+
LISTING_STATUS_REJECTED = 8,
|
|
32
|
+
/** LISTING_STATUS_SUSPENDED - Приостановлено (внутренний) */
|
|
33
|
+
LISTING_STATUS_SUSPENDED = 9,
|
|
34
|
+
UNRECOGNIZED = -1,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Запросы для получения данных */
|
|
38
|
+
export interface GetListingRequest {
|
|
39
|
+
id: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface GetListingsByUserRequest {
|
|
43
|
+
userId: string;
|
|
44
|
+
status?: ListingStatus | undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface GetListingsByCategoryRequest {
|
|
48
|
+
categoryId: string;
|
|
49
|
+
status?: ListingStatus | undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Ответы */
|
|
53
|
+
export interface GetListingResponse {
|
|
54
|
+
listing: Listing | undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface GetListingsByUserResponse {
|
|
58
|
+
listings: Listing[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface GetListingsByCategoryResponse {
|
|
62
|
+
listings: Listing[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Модели */
|
|
66
|
+
export interface Listing {
|
|
67
|
+
id: string;
|
|
68
|
+
title: string;
|
|
69
|
+
description?: string | undefined;
|
|
70
|
+
price?: number | undefined;
|
|
71
|
+
categoryId: string;
|
|
72
|
+
userId: string;
|
|
73
|
+
latitude?: number | undefined;
|
|
74
|
+
longitude?: number | undefined;
|
|
75
|
+
videoUrl?: string | undefined;
|
|
76
|
+
status: ListingStatus;
|
|
77
|
+
viewsCount: number;
|
|
78
|
+
favoritesCount: number;
|
|
79
|
+
images: ListingImage[];
|
|
80
|
+
attributes: ListingAttribute[];
|
|
81
|
+
createdAt: string;
|
|
82
|
+
updatedAt: string;
|
|
83
|
+
publishedAt?: string | undefined;
|
|
84
|
+
deletedAt?: string | undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ListingImage {
|
|
88
|
+
id: string;
|
|
89
|
+
url: string;
|
|
90
|
+
order: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ListingAttribute {
|
|
94
|
+
id: string;
|
|
95
|
+
attributeId: string;
|
|
96
|
+
stringValue?: string | undefined;
|
|
97
|
+
textValue?: string | undefined;
|
|
98
|
+
integerValue?: number | undefined;
|
|
99
|
+
floatValue?: number | undefined;
|
|
100
|
+
booleanValue?: boolean | undefined;
|
|
101
|
+
enumValue?: string | undefined;
|
|
102
|
+
multiEnumValue: string[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const LISTINGS_V1_PACKAGE_NAME = "listings.v1";
|
|
106
|
+
|
|
107
|
+
export interface ListingsServiceClient {
|
|
108
|
+
/** Получение данных через gRPC */
|
|
109
|
+
|
|
110
|
+
getListing(request: GetListingRequest): Observable<GetListingResponse>;
|
|
111
|
+
|
|
112
|
+
getListingsByUser(request: GetListingsByUserRequest): Observable<GetListingsByUserResponse>;
|
|
113
|
+
|
|
114
|
+
getListingsByCategory(request: GetListingsByCategoryRequest): Observable<GetListingsByCategoryResponse>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface ListingsServiceController {
|
|
118
|
+
/** Получение данных через gRPC */
|
|
119
|
+
|
|
120
|
+
getListing(
|
|
121
|
+
request: GetListingRequest,
|
|
122
|
+
): Promise<GetListingResponse> | Observable<GetListingResponse> | GetListingResponse;
|
|
123
|
+
|
|
124
|
+
getListingsByUser(
|
|
125
|
+
request: GetListingsByUserRequest,
|
|
126
|
+
): Promise<GetListingsByUserResponse> | Observable<GetListingsByUserResponse> | GetListingsByUserResponse;
|
|
127
|
+
|
|
128
|
+
getListingsByCategory(
|
|
129
|
+
request: GetListingsByCategoryRequest,
|
|
130
|
+
): Promise<GetListingsByCategoryResponse> | Observable<GetListingsByCategoryResponse> | GetListingsByCategoryResponse;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function ListingsServiceControllerMethods() {
|
|
134
|
+
return function (constructor: Function) {
|
|
135
|
+
const grpcMethods: string[] = ["getListing", "getListingsByUser", "getListingsByCategory"];
|
|
136
|
+
for (const method of grpcMethods) {
|
|
137
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
138
|
+
GrpcMethod("ListingsService", method)(constructor.prototype[method], method, descriptor);
|
|
139
|
+
}
|
|
140
|
+
const grpcStreamMethods: string[] = [];
|
|
141
|
+
for (const method of grpcStreamMethods) {
|
|
142
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
143
|
+
GrpcStreamMethod("ListingsService", method)(constructor.prototype[method], method, descriptor);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const LISTINGS_SERVICE_NAME = "ListingsService";
|
package/package.json
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package listings.v1;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/empty.proto";
|
|
6
|
+
|
|
7
|
+
service ListingsService {
|
|
8
|
+
// Получение данных через gRPC
|
|
9
|
+
rpc GetListing (GetListingRequest) returns (GetListingResponse);
|
|
10
|
+
rpc GetListingsByUser (GetListingsByUserRequest) returns (GetListingsByUserResponse);
|
|
11
|
+
rpc GetListingsByCategory (GetListingsByCategoryRequest) returns (GetListingsByCategoryResponse);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Запросы для получения данных
|
|
15
|
+
message GetListingRequest {
|
|
16
|
+
string id = 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message GetListingsByUserRequest {
|
|
20
|
+
string user_id = 1;
|
|
21
|
+
optional ListingStatus status = 2;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
message GetListingsByCategoryRequest {
|
|
25
|
+
string category_id = 1;
|
|
26
|
+
optional ListingStatus status = 2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Ответы
|
|
30
|
+
message GetListingResponse {
|
|
31
|
+
Listing listing = 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
message GetListingsByUserResponse {
|
|
35
|
+
repeated Listing listings = 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
message GetListingsByCategoryResponse {
|
|
39
|
+
repeated Listing listings = 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Модели
|
|
43
|
+
message Listing {
|
|
44
|
+
string id = 1;
|
|
45
|
+
string title = 2;
|
|
46
|
+
optional string description = 3;
|
|
47
|
+
optional float price = 4;
|
|
48
|
+
string category_id = 5;
|
|
49
|
+
string user_id = 6;
|
|
50
|
+
optional float latitude = 7;
|
|
51
|
+
optional float longitude = 8;
|
|
52
|
+
optional string video_url = 9;
|
|
53
|
+
ListingStatus status = 10;
|
|
54
|
+
int64 views_count = 11;
|
|
55
|
+
int64 favorites_count = 12;
|
|
56
|
+
repeated ListingImage images = 13;
|
|
57
|
+
repeated ListingAttribute attributes = 14;
|
|
58
|
+
string created_at = 15;
|
|
59
|
+
string updated_at = 16;
|
|
60
|
+
optional string published_at = 17;
|
|
61
|
+
optional string deleted_at = 18;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
message ListingImage {
|
|
65
|
+
string id = 1;
|
|
66
|
+
string url = 2;
|
|
67
|
+
int32 order = 3;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
message ListingAttribute {
|
|
71
|
+
string id = 1;
|
|
72
|
+
string attribute_id = 2;
|
|
73
|
+
optional string string_value = 3;
|
|
74
|
+
optional string text_value = 4;
|
|
75
|
+
optional int32 integer_value = 5;
|
|
76
|
+
optional float float_value = 6;
|
|
77
|
+
optional bool boolean_value = 7;
|
|
78
|
+
optional string enum_value = 8;
|
|
79
|
+
repeated string multi_enum_value = 9;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Статусы объявлений
|
|
83
|
+
enum ListingStatus {
|
|
84
|
+
LISTING_STATUS_UNSPECIFIED = 0;
|
|
85
|
+
LISTING_STATUS_DRAFT = 1; // Черновик
|
|
86
|
+
LISTING_STATUS_ACTIVE = 2; // Активные
|
|
87
|
+
LISTING_STATUS_UNPUBLISHED = 3; // Неопубликованные
|
|
88
|
+
LISTING_STATUS_WITH_ERRORS = 4; // С ошибками
|
|
89
|
+
LISTING_STATUS_ARCHIVED = 5; // Архив
|
|
90
|
+
LISTING_STATUS_DELETED = 6; // Удаленные
|
|
91
|
+
LISTING_STATUS_PENDING_REVIEW = 7; // На модерации (внутренний)
|
|
92
|
+
LISTING_STATUS_REJECTED = 8; // Отклонено (внутренний)
|
|
93
|
+
LISTING_STATUS_SUSPENDED = 9; // Приостановлено (внутренний)
|
|
94
|
+
}
|
package/gen/ts/ad.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
-
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.11.0
|
|
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/proto/ad.proto
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
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
|
-
|