@teacinema/contracts 1.1.8 → 1.2.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.
- package/dist/proto/paths.d.ts +2 -0
- package/dist/proto/paths.js +2 -0
- package/gen/ts/category.ts +51 -0
- package/gen/ts/google/protobuf/timestamp.ts +118 -0
- package/gen/ts/movie.ts +86 -0
- package/package.json +1 -1
- package/proto/category.proto +19 -0
- package/proto/movie.proto +53 -0
package/dist/proto/paths.d.ts
CHANGED
package/dist/proto/paths.js
CHANGED
|
@@ -7,4 +7,6 @@ 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
|
+
MOVIE: (0, path_1.join)(__dirname, '../../proto/movie.proto'),
|
|
11
|
+
CATEGORY: (0, path_1.join)(__dirname, '../../proto/category.proto'),
|
|
10
12
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.8.3
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
// source: category.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
import { Empty } from "./google/protobuf/empty";
|
|
11
|
+
|
|
12
|
+
export const protobufPackage = "category.v1";
|
|
13
|
+
|
|
14
|
+
export interface GetAllCategoriesResponse {
|
|
15
|
+
categories: Category[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Category {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const CATEGORY_V1_PACKAGE_NAME = "category.v1";
|
|
25
|
+
|
|
26
|
+
export interface CategoryServiceClient {
|
|
27
|
+
getAllCategories(request: Empty): Observable<GetAllCategoriesResponse>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CategoryServiceController {
|
|
31
|
+
getAllCategories(
|
|
32
|
+
request: Empty,
|
|
33
|
+
): Promise<GetAllCategoriesResponse> | Observable<GetAllCategoriesResponse> | GetAllCategoriesResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function CategoryServiceControllerMethods() {
|
|
37
|
+
return function (constructor: Function) {
|
|
38
|
+
const grpcMethods: string[] = ["getAllCategories"];
|
|
39
|
+
for (const method of grpcMethods) {
|
|
40
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
41
|
+
GrpcMethod("CategoryService", method)(constructor.prototype[method], method, descriptor);
|
|
42
|
+
}
|
|
43
|
+
const grpcStreamMethods: string[] = [];
|
|
44
|
+
for (const method of grpcStreamMethods) {
|
|
45
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
46
|
+
GrpcStreamMethod("CategoryService", method)(constructor.prototype[method], method, descriptor);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const CATEGORY_SERVICE_NAME = "CategoryService";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.8.3
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
// source: google/protobuf/timestamp.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
|
|
9
|
+
export const protobufPackage = "google.protobuf";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A Timestamp represents a point in time independent of any time zone or local
|
|
13
|
+
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
14
|
+
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
15
|
+
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
16
|
+
* Gregorian calendar backwards to year one.
|
|
17
|
+
*
|
|
18
|
+
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
19
|
+
* second table is needed for interpretation, using a [24-hour linear
|
|
20
|
+
* smear](https://developers.google.com/time/smear).
|
|
21
|
+
*
|
|
22
|
+
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
23
|
+
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
24
|
+
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
25
|
+
*
|
|
26
|
+
* # Examples
|
|
27
|
+
*
|
|
28
|
+
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
29
|
+
*
|
|
30
|
+
* Timestamp timestamp;
|
|
31
|
+
* timestamp.set_seconds(time(NULL));
|
|
32
|
+
* timestamp.set_nanos(0);
|
|
33
|
+
*
|
|
34
|
+
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
35
|
+
*
|
|
36
|
+
* struct timeval tv;
|
|
37
|
+
* gettimeofday(&tv, NULL);
|
|
38
|
+
*
|
|
39
|
+
* Timestamp timestamp;
|
|
40
|
+
* timestamp.set_seconds(tv.tv_sec);
|
|
41
|
+
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
42
|
+
*
|
|
43
|
+
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
44
|
+
*
|
|
45
|
+
* FILETIME ft;
|
|
46
|
+
* GetSystemTimeAsFileTime(&ft);
|
|
47
|
+
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
48
|
+
*
|
|
49
|
+
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
50
|
+
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
51
|
+
* Timestamp timestamp;
|
|
52
|
+
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
53
|
+
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
54
|
+
*
|
|
55
|
+
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
56
|
+
*
|
|
57
|
+
* long millis = System.currentTimeMillis();
|
|
58
|
+
*
|
|
59
|
+
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
60
|
+
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
61
|
+
*
|
|
62
|
+
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
63
|
+
*
|
|
64
|
+
* Instant now = Instant.now();
|
|
65
|
+
*
|
|
66
|
+
* Timestamp timestamp =
|
|
67
|
+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
68
|
+
* .setNanos(now.getNano()).build();
|
|
69
|
+
*
|
|
70
|
+
* Example 6: Compute Timestamp from current time in Python.
|
|
71
|
+
*
|
|
72
|
+
* timestamp = Timestamp()
|
|
73
|
+
* timestamp.GetCurrentTime()
|
|
74
|
+
*
|
|
75
|
+
* # JSON Mapping
|
|
76
|
+
*
|
|
77
|
+
* In JSON format, the Timestamp type is encoded as a string in the
|
|
78
|
+
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
79
|
+
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
80
|
+
* where {year} is always expressed using four digits while {month}, {day},
|
|
81
|
+
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
82
|
+
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
83
|
+
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
84
|
+
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
85
|
+
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
86
|
+
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
87
|
+
*
|
|
88
|
+
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
89
|
+
* 01:30 UTC on January 15, 2017.
|
|
90
|
+
*
|
|
91
|
+
* In JavaScript, one can convert a Date object to this format using the
|
|
92
|
+
* standard
|
|
93
|
+
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
94
|
+
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
95
|
+
* to this format using
|
|
96
|
+
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
97
|
+
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
98
|
+
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
99
|
+
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
|
100
|
+
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
101
|
+
*/
|
|
102
|
+
export interface Timestamp {
|
|
103
|
+
/**
|
|
104
|
+
* Represents seconds of UTC time since Unix epoch
|
|
105
|
+
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
106
|
+
* 9999-12-31T23:59:59Z inclusive.
|
|
107
|
+
*/
|
|
108
|
+
seconds: number;
|
|
109
|
+
/**
|
|
110
|
+
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
111
|
+
* second values with fractions must still have non-negative nanos values
|
|
112
|
+
* that count forward in time. Must be from 0 to 999,999,999
|
|
113
|
+
* inclusive.
|
|
114
|
+
*/
|
|
115
|
+
nanos: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
package/gen/ts/movie.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.8.3
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
// source: movie.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
import { Timestamp } from "./google/protobuf/timestamp";
|
|
11
|
+
|
|
12
|
+
export const protobufPackage = "movie.v1";
|
|
13
|
+
|
|
14
|
+
export interface ListMoviesRequest {
|
|
15
|
+
category: string;
|
|
16
|
+
random: boolean;
|
|
17
|
+
limit: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ListMoviesResponse {
|
|
21
|
+
movies: Movie[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GetMovieRequest {
|
|
25
|
+
id?: string | undefined;
|
|
26
|
+
slug?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface GetMovieResponse {
|
|
30
|
+
movie: MovieDetails | undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Movie {
|
|
34
|
+
id: string;
|
|
35
|
+
title: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
poster: string;
|
|
38
|
+
ratingAge: string;
|
|
39
|
+
releaseDate: Timestamp | undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface MovieDetails {
|
|
43
|
+
id: string;
|
|
44
|
+
title: string;
|
|
45
|
+
slug: string;
|
|
46
|
+
description: string;
|
|
47
|
+
poster: string;
|
|
48
|
+
banner: string;
|
|
49
|
+
duration: number;
|
|
50
|
+
ratingAge: string;
|
|
51
|
+
country: string;
|
|
52
|
+
releaseDate: Timestamp | undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const MOVIE_V1_PACKAGE_NAME = "movie.v1";
|
|
56
|
+
|
|
57
|
+
export interface MovieServiceClient {
|
|
58
|
+
listMovies(request: ListMoviesRequest): Observable<ListMoviesResponse>;
|
|
59
|
+
|
|
60
|
+
getMovie(request: GetMovieRequest): Observable<GetMovieResponse>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface MovieServiceController {
|
|
64
|
+
listMovies(
|
|
65
|
+
request: ListMoviesRequest,
|
|
66
|
+
): Promise<ListMoviesResponse> | Observable<ListMoviesResponse> | ListMoviesResponse;
|
|
67
|
+
|
|
68
|
+
getMovie(request: GetMovieRequest): Promise<GetMovieResponse> | Observable<GetMovieResponse> | GetMovieResponse;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function MovieServiceControllerMethods() {
|
|
72
|
+
return function (constructor: Function) {
|
|
73
|
+
const grpcMethods: string[] = ["listMovies", "getMovie"];
|
|
74
|
+
for (const method of grpcMethods) {
|
|
75
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
76
|
+
GrpcMethod("MovieService", method)(constructor.prototype[method], method, descriptor);
|
|
77
|
+
}
|
|
78
|
+
const grpcStreamMethods: string[] = [];
|
|
79
|
+
for (const method of grpcStreamMethods) {
|
|
80
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
81
|
+
GrpcStreamMethod("MovieService", method)(constructor.prototype[method], method, descriptor);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const MOVIE_SERVICE_NAME = "MovieService";
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package category.v1;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/empty.proto";
|
|
6
|
+
|
|
7
|
+
service CategoryService {
|
|
8
|
+
rpc GetAllCategories (google.protobuf.Empty) returns (GetAllCategoriesResponse);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
message GetAllCategoriesResponse {
|
|
12
|
+
repeated Category categories = 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message Category {
|
|
16
|
+
string id = 1;
|
|
17
|
+
string title = 2;
|
|
18
|
+
string slug = 3;
|
|
19
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package movie.v1;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/timestamp.proto";
|
|
6
|
+
|
|
7
|
+
service MovieService {
|
|
8
|
+
rpc ListMovies (ListMoviesRequest) returns (ListMoviesResponse);
|
|
9
|
+
rpc GetMovie (GetMovieRequest) returns (GetMovieResponse);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
message ListMoviesRequest {
|
|
13
|
+
string category = 1;
|
|
14
|
+
bool random = 2;
|
|
15
|
+
int32 limit = 3;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message ListMoviesResponse {
|
|
19
|
+
repeated Movie movies = 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
message GetMovieRequest {
|
|
23
|
+
oneof key {
|
|
24
|
+
string id = 1;
|
|
25
|
+
string slug = 2;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
message GetMovieResponse {
|
|
30
|
+
MovieDetails movie = 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
message Movie {
|
|
34
|
+
string id = 1;
|
|
35
|
+
string title = 2;
|
|
36
|
+
string slug = 3;
|
|
37
|
+
string poster = 4;
|
|
38
|
+
string rating_age = 5;
|
|
39
|
+
google.protobuf.Timestamp release_date = 6;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message MovieDetails {
|
|
43
|
+
string id = 1;
|
|
44
|
+
string title = 2;
|
|
45
|
+
string slug = 3;
|
|
46
|
+
string description = 4;
|
|
47
|
+
string poster = 5;
|
|
48
|
+
string banner = 6;
|
|
49
|
+
int32 duration = 7;;
|
|
50
|
+
string rating_age = 8;
|
|
51
|
+
string country = 9;
|
|
52
|
+
google.protobuf.Timestamp release_date = 10;
|
|
53
|
+
}
|