@sa2-movie-ticket/contracts 1.0.0 → 1.0.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.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @sa2-movie-ticket/contracts
2
+
3
+ Shared Protobuf contracts and TypeScript definitions for the Movie Ticket microservices.
4
+
5
+ ## Installation
6
+
7
+ ### TypeScript (NPM)
8
+
9
+ To install the generated TypeScript contracts:
10
+
11
+ ```bash
12
+ npm install @sa2-movie-ticket/contracts
13
+ # or
14
+ bun add @sa2-movie-ticket/contracts
15
+ ```
16
+
17
+ **Peer Dependencies**:
18
+ Ensure you have the required peer dependencies installed:
19
+
20
+ ```bash
21
+ npm install @grpc/grpc-js @bufbuild/protobuf
22
+ ```
23
+
24
+ ### Go
25
+
26
+ To install the generated Go contracts:
27
+
28
+ ```bash
29
+ go get github.com/sa2-movie-ticket/contracts
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ### TypeScript Example
35
+
36
+ ```typescript
37
+ import {
38
+ AuthServiceClient,
39
+ SendOtpRequest,
40
+ } from "@sa2-movie-ticket/contracts/gen/ts/auth";
41
+ import { credentials } from "@grpc/grpc-js";
42
+
43
+ const client = new AuthServiceClient(
44
+ "localhost:50051",
45
+ credentials.createInsecure(),
46
+ );
47
+
48
+ const request: SendOtpRequest = {
49
+ identifier: "test@example.com",
50
+ type: "email",
51
+ };
52
+
53
+ client.SendOtp(request, (err, response) => {
54
+ if (err) {
55
+ console.error("Error:", err);
56
+ } else {
57
+ console.log("Response:", response);
58
+ }
59
+ });
60
+ ```
61
+
62
+ ### Go Example
63
+
64
+ ```go
65
+ package main
66
+
67
+ import (
68
+ "context"
69
+ "log"
70
+ "time"
71
+
72
+ "google.golang.org/grpc"
73
+ "google.golang.org/grpc/credentials/insecure"
74
+
75
+ pb "github.com/sa2-movie-ticket/contracts/gen/go/auth"
76
+ )
77
+
78
+ func main() {
79
+ conn, err := grpc.NewClient("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
80
+ if err != nil {
81
+ log.Fatalf("did not connect: %v", err)
82
+ }
83
+ defer conn.Close()
84
+ c := pb.NewAuthServiceClient(conn)
85
+
86
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
87
+ defer cancel()
88
+
89
+ r, err := c.SendOtp(ctx, &pb.SendOtpRequest{
90
+ Identifier: "test@example.com",
91
+ Type: "email",
92
+ })
93
+ if err != nil {
94
+ log.Fatalf("could not send otp: %v", err)
95
+ }
96
+ log.Printf("Response: %v", r.GetOk())
97
+ }
98
+ ```
99
+
100
+ ## Development
101
+
102
+ ### Adding New Contracts
103
+
104
+ 1. Create a new `.proto` file in the `proto/` directory.
105
+ 2. The GitHub Action will automatically generate and publish the code on push to `main`.
106
+
107
+ ### Local Generation
108
+
109
+ If you need to generate code locally:
110
+
111
+ ```bash
112
+ # Generate TypeScript and Go
113
+ bun run generate
114
+ ```
package/dist/index.d.mts CHANGED
@@ -1,6 +1,86 @@
1
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
2
+ import { Client, ServiceError, ClientUnaryCall, Metadata, CallOptions, ChannelCredentials, ClientOptions, UntypedServiceImplementation, handleUnaryCall } from '@grpc/grpc-js';
3
+
4
+ declare const protobufPackage = "auth.v1";
5
+ interface SendOtpRequest {
6
+ identifier: string;
7
+ type: string;
8
+ }
9
+ declare const SendOtpRequest: MessageFns<SendOtpRequest>;
10
+ interface SendOtpResponse {
11
+ ok: boolean;
12
+ }
13
+ declare const SendOtpResponse: MessageFns<SendOtpResponse>;
14
+ interface VerifyOtpRequest {
15
+ identifier: string;
16
+ type: string;
17
+ otp: string;
18
+ }
19
+ declare const VerifyOtpRequest: MessageFns<VerifyOtpRequest>;
20
+ interface VerifyOtpResponse {
21
+ token: string;
22
+ }
23
+ declare const VerifyOtpResponse: MessageFns<VerifyOtpResponse>;
24
+ type AuthServiceService = typeof AuthServiceService;
25
+ declare const AuthServiceService: {
26
+ readonly sendOtp: {
27
+ readonly path: "/auth.v1.AuthService/SendOtp";
28
+ readonly requestStream: false;
29
+ readonly responseStream: false;
30
+ readonly requestSerialize: (value: SendOtpRequest) => Buffer;
31
+ readonly requestDeserialize: (value: Buffer) => SendOtpRequest;
32
+ readonly responseSerialize: (value: SendOtpResponse) => Buffer;
33
+ readonly responseDeserialize: (value: Buffer) => SendOtpResponse;
34
+ };
35
+ readonly verifyOtp: {
36
+ readonly path: "/auth.v1.AuthService/VerifyOtp";
37
+ readonly requestStream: false;
38
+ readonly responseStream: false;
39
+ readonly requestSerialize: (value: VerifyOtpRequest) => Buffer;
40
+ readonly requestDeserialize: (value: Buffer) => VerifyOtpRequest;
41
+ readonly responseSerialize: (value: VerifyOtpResponse) => Buffer;
42
+ readonly responseDeserialize: (value: Buffer) => VerifyOtpResponse;
43
+ };
44
+ };
45
+ interface AuthServiceServer extends UntypedServiceImplementation {
46
+ sendOtp: handleUnaryCall<SendOtpRequest, SendOtpResponse>;
47
+ verifyOtp: handleUnaryCall<VerifyOtpRequest, VerifyOtpResponse>;
48
+ }
49
+ interface AuthServiceClient extends Client {
50
+ sendOtp(request: SendOtpRequest, callback: (error: ServiceError | null, response: SendOtpResponse) => void): ClientUnaryCall;
51
+ sendOtp(request: SendOtpRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SendOtpResponse) => void): ClientUnaryCall;
52
+ sendOtp(request: SendOtpRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SendOtpResponse) => void): ClientUnaryCall;
53
+ verifyOtp(request: VerifyOtpRequest, callback: (error: ServiceError | null, response: VerifyOtpResponse) => void): ClientUnaryCall;
54
+ verifyOtp(request: VerifyOtpRequest, metadata: Metadata, callback: (error: ServiceError | null, response: VerifyOtpResponse) => void): ClientUnaryCall;
55
+ verifyOtp(request: VerifyOtpRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: VerifyOtpResponse) => void): ClientUnaryCall;
56
+ }
57
+ declare const AuthServiceClient: {
58
+ new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): AuthServiceClient;
59
+ service: typeof AuthServiceService;
60
+ serviceName: string;
61
+ };
62
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
63
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
64
+ [K in keyof T]?: DeepPartial<T[K]>;
65
+ } : Partial<T>;
66
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
67
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
68
+ [K in keyof P]: Exact<P[K], I[K]>;
69
+ } & {
70
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
71
+ };
72
+ interface MessageFns<T> {
73
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
74
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
75
+ fromJSON(object: any): T;
76
+ toJSON(message: T): unknown;
77
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
78
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
79
+ }
80
+
1
81
  declare const _default: {
2
82
  a: number;
3
83
  hello: () => void;
4
84
  };
5
85
 
6
- export { _default as default };
86
+ export { AuthServiceClient, type AuthServiceServer, AuthServiceService, type DeepPartial, type Exact, type MessageFns, SendOtpRequest, SendOtpResponse, VerifyOtpRequest, VerifyOtpResponse, _default as default, protobufPackage };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,86 @@
1
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
2
+ import { Client, ServiceError, ClientUnaryCall, Metadata, CallOptions, ChannelCredentials, ClientOptions, UntypedServiceImplementation, handleUnaryCall } from '@grpc/grpc-js';
3
+
4
+ declare const protobufPackage = "auth.v1";
5
+ interface SendOtpRequest {
6
+ identifier: string;
7
+ type: string;
8
+ }
9
+ declare const SendOtpRequest: MessageFns<SendOtpRequest>;
10
+ interface SendOtpResponse {
11
+ ok: boolean;
12
+ }
13
+ declare const SendOtpResponse: MessageFns<SendOtpResponse>;
14
+ interface VerifyOtpRequest {
15
+ identifier: string;
16
+ type: string;
17
+ otp: string;
18
+ }
19
+ declare const VerifyOtpRequest: MessageFns<VerifyOtpRequest>;
20
+ interface VerifyOtpResponse {
21
+ token: string;
22
+ }
23
+ declare const VerifyOtpResponse: MessageFns<VerifyOtpResponse>;
24
+ type AuthServiceService = typeof AuthServiceService;
25
+ declare const AuthServiceService: {
26
+ readonly sendOtp: {
27
+ readonly path: "/auth.v1.AuthService/SendOtp";
28
+ readonly requestStream: false;
29
+ readonly responseStream: false;
30
+ readonly requestSerialize: (value: SendOtpRequest) => Buffer;
31
+ readonly requestDeserialize: (value: Buffer) => SendOtpRequest;
32
+ readonly responseSerialize: (value: SendOtpResponse) => Buffer;
33
+ readonly responseDeserialize: (value: Buffer) => SendOtpResponse;
34
+ };
35
+ readonly verifyOtp: {
36
+ readonly path: "/auth.v1.AuthService/VerifyOtp";
37
+ readonly requestStream: false;
38
+ readonly responseStream: false;
39
+ readonly requestSerialize: (value: VerifyOtpRequest) => Buffer;
40
+ readonly requestDeserialize: (value: Buffer) => VerifyOtpRequest;
41
+ readonly responseSerialize: (value: VerifyOtpResponse) => Buffer;
42
+ readonly responseDeserialize: (value: Buffer) => VerifyOtpResponse;
43
+ };
44
+ };
45
+ interface AuthServiceServer extends UntypedServiceImplementation {
46
+ sendOtp: handleUnaryCall<SendOtpRequest, SendOtpResponse>;
47
+ verifyOtp: handleUnaryCall<VerifyOtpRequest, VerifyOtpResponse>;
48
+ }
49
+ interface AuthServiceClient extends Client {
50
+ sendOtp(request: SendOtpRequest, callback: (error: ServiceError | null, response: SendOtpResponse) => void): ClientUnaryCall;
51
+ sendOtp(request: SendOtpRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SendOtpResponse) => void): ClientUnaryCall;
52
+ sendOtp(request: SendOtpRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SendOtpResponse) => void): ClientUnaryCall;
53
+ verifyOtp(request: VerifyOtpRequest, callback: (error: ServiceError | null, response: VerifyOtpResponse) => void): ClientUnaryCall;
54
+ verifyOtp(request: VerifyOtpRequest, metadata: Metadata, callback: (error: ServiceError | null, response: VerifyOtpResponse) => void): ClientUnaryCall;
55
+ verifyOtp(request: VerifyOtpRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: VerifyOtpResponse) => void): ClientUnaryCall;
56
+ }
57
+ declare const AuthServiceClient: {
58
+ new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): AuthServiceClient;
59
+ service: typeof AuthServiceService;
60
+ serviceName: string;
61
+ };
62
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
63
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
64
+ [K in keyof T]?: DeepPartial<T[K]>;
65
+ } : Partial<T>;
66
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
67
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
68
+ [K in keyof P]: Exact<P[K], I[K]>;
69
+ } & {
70
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
71
+ };
72
+ interface MessageFns<T> {
73
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
74
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
75
+ fromJSON(object: any): T;
76
+ toJSON(message: T): unknown;
77
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
78
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
79
+ }
80
+
1
81
  declare const _default: {
2
82
  a: number;
3
83
  hello: () => void;
4
84
  };
5
85
 
6
- export { _default as default };
86
+ export { AuthServiceClient, type AuthServiceServer, AuthServiceService, type DeepPartial, type Exact, type MessageFns, SendOtpRequest, SendOtpResponse, VerifyOtpRequest, VerifyOtpResponse, _default as default, protobufPackage };
package/dist/index.js CHANGED
@@ -20,11 +20,312 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- default: () => index_default
23
+ AuthServiceClient: () => AuthServiceClient,
24
+ AuthServiceService: () => AuthServiceService,
25
+ SendOtpRequest: () => SendOtpRequest,
26
+ SendOtpResponse: () => SendOtpResponse,
27
+ VerifyOtpRequest: () => VerifyOtpRequest,
28
+ VerifyOtpResponse: () => VerifyOtpResponse,
29
+ default: () => index_default,
30
+ protobufPackage: () => protobufPackage
24
31
  });
25
32
  module.exports = __toCommonJS(index_exports);
33
+
34
+ // gen/ts/auth.ts
35
+ var import_wire = require("@bufbuild/protobuf/wire");
36
+ var import_grpc_js = require("@grpc/grpc-js");
37
+ var protobufPackage = "auth.v1";
38
+ function createBaseSendOtpRequest() {
39
+ return { identifier: "", type: "" };
40
+ }
41
+ var SendOtpRequest = {
42
+ encode(message, writer = new import_wire.BinaryWriter()) {
43
+ if (message.identifier !== "") {
44
+ writer.uint32(10).string(message.identifier);
45
+ }
46
+ if (message.type !== "") {
47
+ writer.uint32(18).string(message.type);
48
+ }
49
+ return writer;
50
+ },
51
+ decode(input, length) {
52
+ const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input);
53
+ const end = length === void 0 ? reader.len : reader.pos + length;
54
+ const message = createBaseSendOtpRequest();
55
+ while (reader.pos < end) {
56
+ const tag = reader.uint32();
57
+ switch (tag >>> 3) {
58
+ case 1: {
59
+ if (tag !== 10) {
60
+ break;
61
+ }
62
+ message.identifier = reader.string();
63
+ continue;
64
+ }
65
+ case 2: {
66
+ if (tag !== 18) {
67
+ break;
68
+ }
69
+ message.type = reader.string();
70
+ continue;
71
+ }
72
+ }
73
+ if ((tag & 7) === 4 || tag === 0) {
74
+ break;
75
+ }
76
+ reader.skip(tag & 7);
77
+ }
78
+ return message;
79
+ },
80
+ fromJSON(object) {
81
+ return {
82
+ identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
83
+ type: isSet(object.type) ? globalThis.String(object.type) : ""
84
+ };
85
+ },
86
+ toJSON(message) {
87
+ const obj = {};
88
+ if (message.identifier !== "") {
89
+ obj.identifier = message.identifier;
90
+ }
91
+ if (message.type !== "") {
92
+ obj.type = message.type;
93
+ }
94
+ return obj;
95
+ },
96
+ create(base) {
97
+ return SendOtpRequest.fromPartial(base ?? {});
98
+ },
99
+ fromPartial(object) {
100
+ const message = createBaseSendOtpRequest();
101
+ message.identifier = object.identifier ?? "";
102
+ message.type = object.type ?? "";
103
+ return message;
104
+ }
105
+ };
106
+ function createBaseSendOtpResponse() {
107
+ return { ok: false };
108
+ }
109
+ var SendOtpResponse = {
110
+ encode(message, writer = new import_wire.BinaryWriter()) {
111
+ if (message.ok !== false) {
112
+ writer.uint32(8).bool(message.ok);
113
+ }
114
+ return writer;
115
+ },
116
+ decode(input, length) {
117
+ const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input);
118
+ const end = length === void 0 ? reader.len : reader.pos + length;
119
+ const message = createBaseSendOtpResponse();
120
+ while (reader.pos < end) {
121
+ const tag = reader.uint32();
122
+ switch (tag >>> 3) {
123
+ case 1: {
124
+ if (tag !== 8) {
125
+ break;
126
+ }
127
+ message.ok = reader.bool();
128
+ continue;
129
+ }
130
+ }
131
+ if ((tag & 7) === 4 || tag === 0) {
132
+ break;
133
+ }
134
+ reader.skip(tag & 7);
135
+ }
136
+ return message;
137
+ },
138
+ fromJSON(object) {
139
+ return { ok: isSet(object.ok) ? globalThis.Boolean(object.ok) : false };
140
+ },
141
+ toJSON(message) {
142
+ const obj = {};
143
+ if (message.ok !== false) {
144
+ obj.ok = message.ok;
145
+ }
146
+ return obj;
147
+ },
148
+ create(base) {
149
+ return SendOtpResponse.fromPartial(base ?? {});
150
+ },
151
+ fromPartial(object) {
152
+ const message = createBaseSendOtpResponse();
153
+ message.ok = object.ok ?? false;
154
+ return message;
155
+ }
156
+ };
157
+ function createBaseVerifyOtpRequest() {
158
+ return { identifier: "", type: "", otp: "" };
159
+ }
160
+ var VerifyOtpRequest = {
161
+ encode(message, writer = new import_wire.BinaryWriter()) {
162
+ if (message.identifier !== "") {
163
+ writer.uint32(10).string(message.identifier);
164
+ }
165
+ if (message.type !== "") {
166
+ writer.uint32(18).string(message.type);
167
+ }
168
+ if (message.otp !== "") {
169
+ writer.uint32(26).string(message.otp);
170
+ }
171
+ return writer;
172
+ },
173
+ decode(input, length) {
174
+ const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input);
175
+ const end = length === void 0 ? reader.len : reader.pos + length;
176
+ const message = createBaseVerifyOtpRequest();
177
+ while (reader.pos < end) {
178
+ const tag = reader.uint32();
179
+ switch (tag >>> 3) {
180
+ case 1: {
181
+ if (tag !== 10) {
182
+ break;
183
+ }
184
+ message.identifier = reader.string();
185
+ continue;
186
+ }
187
+ case 2: {
188
+ if (tag !== 18) {
189
+ break;
190
+ }
191
+ message.type = reader.string();
192
+ continue;
193
+ }
194
+ case 3: {
195
+ if (tag !== 26) {
196
+ break;
197
+ }
198
+ message.otp = reader.string();
199
+ continue;
200
+ }
201
+ }
202
+ if ((tag & 7) === 4 || tag === 0) {
203
+ break;
204
+ }
205
+ reader.skip(tag & 7);
206
+ }
207
+ return message;
208
+ },
209
+ fromJSON(object) {
210
+ return {
211
+ identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
212
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
213
+ otp: isSet(object.otp) ? globalThis.String(object.otp) : ""
214
+ };
215
+ },
216
+ toJSON(message) {
217
+ const obj = {};
218
+ if (message.identifier !== "") {
219
+ obj.identifier = message.identifier;
220
+ }
221
+ if (message.type !== "") {
222
+ obj.type = message.type;
223
+ }
224
+ if (message.otp !== "") {
225
+ obj.otp = message.otp;
226
+ }
227
+ return obj;
228
+ },
229
+ create(base) {
230
+ return VerifyOtpRequest.fromPartial(base ?? {});
231
+ },
232
+ fromPartial(object) {
233
+ const message = createBaseVerifyOtpRequest();
234
+ message.identifier = object.identifier ?? "";
235
+ message.type = object.type ?? "";
236
+ message.otp = object.otp ?? "";
237
+ return message;
238
+ }
239
+ };
240
+ function createBaseVerifyOtpResponse() {
241
+ return { token: "" };
242
+ }
243
+ var VerifyOtpResponse = {
244
+ encode(message, writer = new import_wire.BinaryWriter()) {
245
+ if (message.token !== "") {
246
+ writer.uint32(10).string(message.token);
247
+ }
248
+ return writer;
249
+ },
250
+ decode(input, length) {
251
+ const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input);
252
+ const end = length === void 0 ? reader.len : reader.pos + length;
253
+ const message = createBaseVerifyOtpResponse();
254
+ while (reader.pos < end) {
255
+ const tag = reader.uint32();
256
+ switch (tag >>> 3) {
257
+ case 1: {
258
+ if (tag !== 10) {
259
+ break;
260
+ }
261
+ message.token = reader.string();
262
+ continue;
263
+ }
264
+ }
265
+ if ((tag & 7) === 4 || tag === 0) {
266
+ break;
267
+ }
268
+ reader.skip(tag & 7);
269
+ }
270
+ return message;
271
+ },
272
+ fromJSON(object) {
273
+ return { token: isSet(object.token) ? globalThis.String(object.token) : "" };
274
+ },
275
+ toJSON(message) {
276
+ const obj = {};
277
+ if (message.token !== "") {
278
+ obj.token = message.token;
279
+ }
280
+ return obj;
281
+ },
282
+ create(base) {
283
+ return VerifyOtpResponse.fromPartial(base ?? {});
284
+ },
285
+ fromPartial(object) {
286
+ const message = createBaseVerifyOtpResponse();
287
+ message.token = object.token ?? "";
288
+ return message;
289
+ }
290
+ };
291
+ var AuthServiceService = {
292
+ sendOtp: {
293
+ path: "/auth.v1.AuthService/SendOtp",
294
+ requestStream: false,
295
+ responseStream: false,
296
+ requestSerialize: (value) => Buffer.from(SendOtpRequest.encode(value).finish()),
297
+ requestDeserialize: (value) => SendOtpRequest.decode(value),
298
+ responseSerialize: (value) => Buffer.from(SendOtpResponse.encode(value).finish()),
299
+ responseDeserialize: (value) => SendOtpResponse.decode(value)
300
+ },
301
+ verifyOtp: {
302
+ path: "/auth.v1.AuthService/VerifyOtp",
303
+ requestStream: false,
304
+ responseStream: false,
305
+ requestSerialize: (value) => Buffer.from(VerifyOtpRequest.encode(value).finish()),
306
+ requestDeserialize: (value) => VerifyOtpRequest.decode(value),
307
+ responseSerialize: (value) => Buffer.from(VerifyOtpResponse.encode(value).finish()),
308
+ responseDeserialize: (value) => VerifyOtpResponse.decode(value)
309
+ }
310
+ };
311
+ var AuthServiceClient = (0, import_grpc_js.makeGenericClientConstructor)(AuthServiceService, "auth.v1.AuthService");
312
+ function isSet(value) {
313
+ return value !== null && value !== void 0;
314
+ }
315
+
316
+ // src/index.ts
26
317
  var a = 1;
27
318
  var hello = () => {
28
319
  console.log("Hello World");
29
320
  };
30
321
  var index_default = { a, hello };
322
+ // Annotate the CommonJS export names for ESM import in node:
323
+ 0 && (module.exports = {
324
+ AuthServiceClient,
325
+ AuthServiceService,
326
+ SendOtpRequest,
327
+ SendOtpResponse,
328
+ VerifyOtpRequest,
329
+ VerifyOtpResponse,
330
+ protobufPackage
331
+ });
package/dist/index.mjs CHANGED
@@ -1,3 +1,287 @@
1
+ // gen/ts/auth.ts
2
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
3
+ import {
4
+ makeGenericClientConstructor
5
+ } from "@grpc/grpc-js";
6
+ var protobufPackage = "auth.v1";
7
+ function createBaseSendOtpRequest() {
8
+ return { identifier: "", type: "" };
9
+ }
10
+ var SendOtpRequest = {
11
+ encode(message, writer = new BinaryWriter()) {
12
+ if (message.identifier !== "") {
13
+ writer.uint32(10).string(message.identifier);
14
+ }
15
+ if (message.type !== "") {
16
+ writer.uint32(18).string(message.type);
17
+ }
18
+ return writer;
19
+ },
20
+ decode(input, length) {
21
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
22
+ const end = length === void 0 ? reader.len : reader.pos + length;
23
+ const message = createBaseSendOtpRequest();
24
+ while (reader.pos < end) {
25
+ const tag = reader.uint32();
26
+ switch (tag >>> 3) {
27
+ case 1: {
28
+ if (tag !== 10) {
29
+ break;
30
+ }
31
+ message.identifier = reader.string();
32
+ continue;
33
+ }
34
+ case 2: {
35
+ if (tag !== 18) {
36
+ break;
37
+ }
38
+ message.type = reader.string();
39
+ continue;
40
+ }
41
+ }
42
+ if ((tag & 7) === 4 || tag === 0) {
43
+ break;
44
+ }
45
+ reader.skip(tag & 7);
46
+ }
47
+ return message;
48
+ },
49
+ fromJSON(object) {
50
+ return {
51
+ identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
52
+ type: isSet(object.type) ? globalThis.String(object.type) : ""
53
+ };
54
+ },
55
+ toJSON(message) {
56
+ const obj = {};
57
+ if (message.identifier !== "") {
58
+ obj.identifier = message.identifier;
59
+ }
60
+ if (message.type !== "") {
61
+ obj.type = message.type;
62
+ }
63
+ return obj;
64
+ },
65
+ create(base) {
66
+ return SendOtpRequest.fromPartial(base ?? {});
67
+ },
68
+ fromPartial(object) {
69
+ const message = createBaseSendOtpRequest();
70
+ message.identifier = object.identifier ?? "";
71
+ message.type = object.type ?? "";
72
+ return message;
73
+ }
74
+ };
75
+ function createBaseSendOtpResponse() {
76
+ return { ok: false };
77
+ }
78
+ var SendOtpResponse = {
79
+ encode(message, writer = new BinaryWriter()) {
80
+ if (message.ok !== false) {
81
+ writer.uint32(8).bool(message.ok);
82
+ }
83
+ return writer;
84
+ },
85
+ decode(input, length) {
86
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
87
+ const end = length === void 0 ? reader.len : reader.pos + length;
88
+ const message = createBaseSendOtpResponse();
89
+ while (reader.pos < end) {
90
+ const tag = reader.uint32();
91
+ switch (tag >>> 3) {
92
+ case 1: {
93
+ if (tag !== 8) {
94
+ break;
95
+ }
96
+ message.ok = reader.bool();
97
+ continue;
98
+ }
99
+ }
100
+ if ((tag & 7) === 4 || tag === 0) {
101
+ break;
102
+ }
103
+ reader.skip(tag & 7);
104
+ }
105
+ return message;
106
+ },
107
+ fromJSON(object) {
108
+ return { ok: isSet(object.ok) ? globalThis.Boolean(object.ok) : false };
109
+ },
110
+ toJSON(message) {
111
+ const obj = {};
112
+ if (message.ok !== false) {
113
+ obj.ok = message.ok;
114
+ }
115
+ return obj;
116
+ },
117
+ create(base) {
118
+ return SendOtpResponse.fromPartial(base ?? {});
119
+ },
120
+ fromPartial(object) {
121
+ const message = createBaseSendOtpResponse();
122
+ message.ok = object.ok ?? false;
123
+ return message;
124
+ }
125
+ };
126
+ function createBaseVerifyOtpRequest() {
127
+ return { identifier: "", type: "", otp: "" };
128
+ }
129
+ var VerifyOtpRequest = {
130
+ encode(message, writer = new BinaryWriter()) {
131
+ if (message.identifier !== "") {
132
+ writer.uint32(10).string(message.identifier);
133
+ }
134
+ if (message.type !== "") {
135
+ writer.uint32(18).string(message.type);
136
+ }
137
+ if (message.otp !== "") {
138
+ writer.uint32(26).string(message.otp);
139
+ }
140
+ return writer;
141
+ },
142
+ decode(input, length) {
143
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
144
+ const end = length === void 0 ? reader.len : reader.pos + length;
145
+ const message = createBaseVerifyOtpRequest();
146
+ while (reader.pos < end) {
147
+ const tag = reader.uint32();
148
+ switch (tag >>> 3) {
149
+ case 1: {
150
+ if (tag !== 10) {
151
+ break;
152
+ }
153
+ message.identifier = reader.string();
154
+ continue;
155
+ }
156
+ case 2: {
157
+ if (tag !== 18) {
158
+ break;
159
+ }
160
+ message.type = reader.string();
161
+ continue;
162
+ }
163
+ case 3: {
164
+ if (tag !== 26) {
165
+ break;
166
+ }
167
+ message.otp = reader.string();
168
+ continue;
169
+ }
170
+ }
171
+ if ((tag & 7) === 4 || tag === 0) {
172
+ break;
173
+ }
174
+ reader.skip(tag & 7);
175
+ }
176
+ return message;
177
+ },
178
+ fromJSON(object) {
179
+ return {
180
+ identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
181
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
182
+ otp: isSet(object.otp) ? globalThis.String(object.otp) : ""
183
+ };
184
+ },
185
+ toJSON(message) {
186
+ const obj = {};
187
+ if (message.identifier !== "") {
188
+ obj.identifier = message.identifier;
189
+ }
190
+ if (message.type !== "") {
191
+ obj.type = message.type;
192
+ }
193
+ if (message.otp !== "") {
194
+ obj.otp = message.otp;
195
+ }
196
+ return obj;
197
+ },
198
+ create(base) {
199
+ return VerifyOtpRequest.fromPartial(base ?? {});
200
+ },
201
+ fromPartial(object) {
202
+ const message = createBaseVerifyOtpRequest();
203
+ message.identifier = object.identifier ?? "";
204
+ message.type = object.type ?? "";
205
+ message.otp = object.otp ?? "";
206
+ return message;
207
+ }
208
+ };
209
+ function createBaseVerifyOtpResponse() {
210
+ return { token: "" };
211
+ }
212
+ var VerifyOtpResponse = {
213
+ encode(message, writer = new BinaryWriter()) {
214
+ if (message.token !== "") {
215
+ writer.uint32(10).string(message.token);
216
+ }
217
+ return writer;
218
+ },
219
+ decode(input, length) {
220
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
221
+ const end = length === void 0 ? reader.len : reader.pos + length;
222
+ const message = createBaseVerifyOtpResponse();
223
+ while (reader.pos < end) {
224
+ const tag = reader.uint32();
225
+ switch (tag >>> 3) {
226
+ case 1: {
227
+ if (tag !== 10) {
228
+ break;
229
+ }
230
+ message.token = reader.string();
231
+ continue;
232
+ }
233
+ }
234
+ if ((tag & 7) === 4 || tag === 0) {
235
+ break;
236
+ }
237
+ reader.skip(tag & 7);
238
+ }
239
+ return message;
240
+ },
241
+ fromJSON(object) {
242
+ return { token: isSet(object.token) ? globalThis.String(object.token) : "" };
243
+ },
244
+ toJSON(message) {
245
+ const obj = {};
246
+ if (message.token !== "") {
247
+ obj.token = message.token;
248
+ }
249
+ return obj;
250
+ },
251
+ create(base) {
252
+ return VerifyOtpResponse.fromPartial(base ?? {});
253
+ },
254
+ fromPartial(object) {
255
+ const message = createBaseVerifyOtpResponse();
256
+ message.token = object.token ?? "";
257
+ return message;
258
+ }
259
+ };
260
+ var AuthServiceService = {
261
+ sendOtp: {
262
+ path: "/auth.v1.AuthService/SendOtp",
263
+ requestStream: false,
264
+ responseStream: false,
265
+ requestSerialize: (value) => Buffer.from(SendOtpRequest.encode(value).finish()),
266
+ requestDeserialize: (value) => SendOtpRequest.decode(value),
267
+ responseSerialize: (value) => Buffer.from(SendOtpResponse.encode(value).finish()),
268
+ responseDeserialize: (value) => SendOtpResponse.decode(value)
269
+ },
270
+ verifyOtp: {
271
+ path: "/auth.v1.AuthService/VerifyOtp",
272
+ requestStream: false,
273
+ responseStream: false,
274
+ requestSerialize: (value) => Buffer.from(VerifyOtpRequest.encode(value).finish()),
275
+ requestDeserialize: (value) => VerifyOtpRequest.decode(value),
276
+ responseSerialize: (value) => Buffer.from(VerifyOtpResponse.encode(value).finish()),
277
+ responseDeserialize: (value) => VerifyOtpResponse.decode(value)
278
+ }
279
+ };
280
+ var AuthServiceClient = makeGenericClientConstructor(AuthServiceService, "auth.v1.AuthService");
281
+ function isSet(value) {
282
+ return value !== null && value !== void 0;
283
+ }
284
+
1
285
  // src/index.ts
2
286
  var a = 1;
3
287
  var hello = () => {
@@ -5,5 +289,12 @@ var hello = () => {
5
289
  };
6
290
  var index_default = { a, hello };
7
291
  export {
8
- index_default as default
292
+ AuthServiceClient,
293
+ AuthServiceService,
294
+ SendOtpRequest,
295
+ SendOtpResponse,
296
+ VerifyOtpRequest,
297
+ VerifyOtpResponse,
298
+ index_default as default,
299
+ protobufPackage
9
300
  };
package/gen/ts/auth.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
3
  // protoc-gen-ts_proto v2.11.2
4
- // protoc v6.33.5
4
+ // protoc v4.23.4
5
5
  // source: auth.proto
6
6
 
7
7
  /* eslint-disable */
package/package.json CHANGED
@@ -1,21 +1,34 @@
1
1
  {
2
2
  "name": "@sa2-movie-ticket/contracts",
3
3
  "description": "Contracts for movie ticket microservices",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "license": "ISC",
6
- "author": "",
7
6
  "type": "commonjs",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
8
10
  "main": "dist/index.js",
9
11
  "module": "dist/index.mjs",
10
12
  "scripts": {
11
13
  "build": "tsup src/index.ts --format esm,cjs --dts --clean",
12
- "generate": "protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto.exe --ts_proto_out=./gen/ts --ts_proto_opt=esModuleInterop=true,forceLong=bigint,outputServices=grpc-js,package=omit -I=./proto ./proto/*.proto"
14
+ "generate": "bun run generate:ts && bun run generate:go",
15
+ "generate:ts": "protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto.exe --ts_proto_out=./gen/ts --ts_proto_opt=esModuleInterop=true,forceLong=bigint,outputServices=grpc-js,package=omit -I=./proto ./proto/*.proto",
16
+ "generate:go": "protoc --go_out=. --go_opt=module=github.com/sa2-movie-ticket/contracts --go-grpc_out=. --go-grpc_opt=module=github.com/sa2-movie-ticket/contracts -I=./proto ./proto/*.proto"
13
17
  },
14
18
  "files": [
15
19
  "dist",
16
20
  "proto",
17
- "gen"
21
+ "gen/ts"
18
22
  ],
23
+ "author": {
24
+ "name": "Shakil Ahmed",
25
+ "email": "sa2avroo@gmail.com",
26
+ "url": "https://github.com/sa3akash"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/sa2-movie-ticket/contracts.git"
31
+ },
19
32
  "devDependencies": {
20
33
  "@types/bun": "latest",
21
34
  "protoc": "^33.5.0",
package/proto/auth.proto CHANGED
@@ -2,6 +2,8 @@ syntax = "proto3";
2
2
 
3
3
  package auth.v1;
4
4
 
5
+ option go_package = "github.com/sa2-movie-ticket/contracts/gen/go/auth";
6
+
5
7
  service AuthService {
6
8
  rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
7
9
  rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);