@sa2-movie-ticket/testing 1.0.1

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.
@@ -0,0 +1,70 @@
1
+ name: Generate Code & Publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ generate-and-publish:
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout Repo
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ # Setup Node (needed for npm publish)
23
+ - name: Setup Node
24
+ uses: actions/setup-node@v4
25
+ with:
26
+ node-version: 20
27
+ registry-url: https://registry.npmjs.org/
28
+
29
+ # Setup Bun
30
+ - name: Setup Bun
31
+ uses: oven-sh/setup-bun@v2
32
+ with:
33
+ bun-version: latest
34
+
35
+ # Install protoc
36
+ - name: Install Protoc
37
+ run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
38
+
39
+ # Install dependencies
40
+ - name: Install Dependencies
41
+ run: bun install --frozen-lockfile
42
+
43
+ # Generate TypeScript from proto
44
+ - name: Generate Code
45
+ run: bun run generate
46
+
47
+ # Build (ONLY if your package needs dist output)
48
+ # - name: Build
49
+ # run: bun run build
50
+
51
+ # Configure git
52
+ - name: Configure Git
53
+ run: |
54
+ git config user.name "github-actions"
55
+ git config user.email "github-actions@github.com"
56
+
57
+ # Bump version + commit
58
+ - name: Bump Version
59
+ run: |
60
+ npm version patch -m "chore: bump version to %s"
61
+
62
+ # Push version commit
63
+ - name: Push Changes
64
+ run: git push --follow-tags
65
+
66
+ # Publish to npm
67
+ - name: Publish Package
68
+ run: npm publish --access public
69
+ env:
70
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/bun.lock ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 1,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "testing",
7
+ "devDependencies": {
8
+ "ts-proto": "^2.11.2",
9
+ },
10
+ },
11
+ },
12
+ "packages": {
13
+ "@bufbuild/protobuf": ["@bufbuild/protobuf@2.11.0", "", {}, "sha512-sBXGT13cpmPR5BMgHE6UEEfEaShh5Ror6rfN3yEK5si7QVrtZg8LEPQb0VVhiLRUslD2yLnXtnRzG035J/mZXQ=="],
14
+
15
+ "case-anything": ["case-anything@2.1.13", "", {}, "sha512-zlOQ80VrQ2Ue+ymH5OuM/DlDq64mEm+B9UTdHULv5osUMD6HalNTblf2b1u/m6QecjsnOkBpqVZ+XPwIVsy7Ng=="],
16
+
17
+ "detect-libc": ["detect-libc@1.0.3", "", { "bin": { "detect-libc": "./bin/detect-libc.js" } }, "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg=="],
18
+
19
+ "dprint-node": ["dprint-node@1.0.8", "", { "dependencies": { "detect-libc": "^1.0.3" } }, "sha512-iVKnUtYfGrYcW1ZAlfR/F59cUVL8QIhWoBJoSjkkdua/dkWIgjZfiLMeTjiB06X0ZLkQ0M2C1VbUj/CxkIf1zg=="],
20
+
21
+ "ts-poet": ["ts-poet@6.12.0", "", { "dependencies": { "dprint-node": "^1.0.8" } }, "sha512-xo+iRNMWqyvXpFTaOAvLPA5QAWO6TZrSUs5s4Odaya3epqofBu/fMLHEWl8jPmjhA0s9sgj9sNvF1BmaQlmQkA=="],
22
+
23
+ "ts-proto": ["ts-proto@2.11.2", "", { "dependencies": { "@bufbuild/protobuf": "^2.10.2", "case-anything": "^2.1.13", "ts-poet": "^6.12.0", "ts-proto-descriptors": "2.1.0" }, "bin": { "protoc-gen-ts_proto": "protoc-gen-ts_proto" } }, "sha512-+bPq2zDwNtJHtuyu2fGYgvTDxS7cBcY4u4moO1LyFA+my144Mfj9/sbNyGXKMtBK7DNXVGf76puwGa6hPzJw/g=="],
24
+
25
+ "ts-proto-descriptors": ["ts-proto-descriptors@2.1.0", "", { "dependencies": { "@bufbuild/protobuf": "^2.0.0" } }, "sha512-S5EZYEQ6L9KLFfjSRpZWDIXDV/W7tAj8uW7pLsihIxyr62EAVSiKuVPwE8iWnr849Bqa53enex1jhDUcpgquzA=="],
26
+ }
27
+ }
@@ -0,0 +1,397 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.2
4
+ // protoc v3.21.12
5
+ // source: proto/auth.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+
10
+ export const protobufPackage = "auth.v1";
11
+
12
+ export interface SendOtpRequest {
13
+ identifier: string;
14
+ type: string;
15
+ }
16
+
17
+ export interface SendOtpResponse {
18
+ ok: boolean;
19
+ }
20
+
21
+ export interface VerifyOtpRequest {
22
+ identifier: string;
23
+ type: string;
24
+ code: string;
25
+ }
26
+
27
+ export interface VerifyOtpResponse {
28
+ accessToken: string;
29
+ refreshToken: string;
30
+ }
31
+
32
+ function createBaseSendOtpRequest(): SendOtpRequest {
33
+ return { identifier: "", type: "" };
34
+ }
35
+
36
+ export const SendOtpRequest: MessageFns<SendOtpRequest> = {
37
+ encode(message: SendOtpRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
38
+ if (message.identifier !== "") {
39
+ writer.uint32(10).string(message.identifier);
40
+ }
41
+ if (message.type !== "") {
42
+ writer.uint32(18).string(message.type);
43
+ }
44
+ return writer;
45
+ },
46
+
47
+ decode(input: BinaryReader | Uint8Array, length?: number): SendOtpRequest {
48
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
49
+ const end = length === undefined ? reader.len : reader.pos + length;
50
+ const message = createBaseSendOtpRequest();
51
+ while (reader.pos < end) {
52
+ const tag = reader.uint32();
53
+ switch (tag >>> 3) {
54
+ case 1: {
55
+ if (tag !== 10) {
56
+ break;
57
+ }
58
+
59
+ message.identifier = reader.string();
60
+ continue;
61
+ }
62
+ case 2: {
63
+ if (tag !== 18) {
64
+ break;
65
+ }
66
+
67
+ message.type = reader.string();
68
+ continue;
69
+ }
70
+ }
71
+ if ((tag & 7) === 4 || tag === 0) {
72
+ break;
73
+ }
74
+ reader.skip(tag & 7);
75
+ }
76
+ return message;
77
+ },
78
+
79
+ fromJSON(object: any): SendOtpRequest {
80
+ return {
81
+ identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
82
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
83
+ };
84
+ },
85
+
86
+ toJSON(message: SendOtpRequest): unknown {
87
+ const obj: any = {};
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
+
97
+ create<I extends Exact<DeepPartial<SendOtpRequest>, I>>(base?: I): SendOtpRequest {
98
+ return SendOtpRequest.fromPartial(base ?? ({} as any));
99
+ },
100
+ fromPartial<I extends Exact<DeepPartial<SendOtpRequest>, I>>(object: I): SendOtpRequest {
101
+ const message = createBaseSendOtpRequest();
102
+ message.identifier = object.identifier ?? "";
103
+ message.type = object.type ?? "";
104
+ return message;
105
+ },
106
+ };
107
+
108
+ function createBaseSendOtpResponse(): SendOtpResponse {
109
+ return { ok: false };
110
+ }
111
+
112
+ export const SendOtpResponse: MessageFns<SendOtpResponse> = {
113
+ encode(message: SendOtpResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
114
+ if (message.ok !== false) {
115
+ writer.uint32(8).bool(message.ok);
116
+ }
117
+ return writer;
118
+ },
119
+
120
+ decode(input: BinaryReader | Uint8Array, length?: number): SendOtpResponse {
121
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
122
+ const end = length === undefined ? reader.len : reader.pos + length;
123
+ const message = createBaseSendOtpResponse();
124
+ while (reader.pos < end) {
125
+ const tag = reader.uint32();
126
+ switch (tag >>> 3) {
127
+ case 1: {
128
+ if (tag !== 8) {
129
+ break;
130
+ }
131
+
132
+ message.ok = reader.bool();
133
+ continue;
134
+ }
135
+ }
136
+ if ((tag & 7) === 4 || tag === 0) {
137
+ break;
138
+ }
139
+ reader.skip(tag & 7);
140
+ }
141
+ return message;
142
+ },
143
+
144
+ fromJSON(object: any): SendOtpResponse {
145
+ return { ok: isSet(object.ok) ? globalThis.Boolean(object.ok) : false };
146
+ },
147
+
148
+ toJSON(message: SendOtpResponse): unknown {
149
+ const obj: any = {};
150
+ if (message.ok !== false) {
151
+ obj.ok = message.ok;
152
+ }
153
+ return obj;
154
+ },
155
+
156
+ create<I extends Exact<DeepPartial<SendOtpResponse>, I>>(base?: I): SendOtpResponse {
157
+ return SendOtpResponse.fromPartial(base ?? ({} as any));
158
+ },
159
+ fromPartial<I extends Exact<DeepPartial<SendOtpResponse>, I>>(object: I): SendOtpResponse {
160
+ const message = createBaseSendOtpResponse();
161
+ message.ok = object.ok ?? false;
162
+ return message;
163
+ },
164
+ };
165
+
166
+ function createBaseVerifyOtpRequest(): VerifyOtpRequest {
167
+ return { identifier: "", type: "", code: "" };
168
+ }
169
+
170
+ export const VerifyOtpRequest: MessageFns<VerifyOtpRequest> = {
171
+ encode(message: VerifyOtpRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
172
+ if (message.identifier !== "") {
173
+ writer.uint32(10).string(message.identifier);
174
+ }
175
+ if (message.type !== "") {
176
+ writer.uint32(18).string(message.type);
177
+ }
178
+ if (message.code !== "") {
179
+ writer.uint32(26).string(message.code);
180
+ }
181
+ return writer;
182
+ },
183
+
184
+ decode(input: BinaryReader | Uint8Array, length?: number): VerifyOtpRequest {
185
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
186
+ const end = length === undefined ? reader.len : reader.pos + length;
187
+ const message = createBaseVerifyOtpRequest();
188
+ while (reader.pos < end) {
189
+ const tag = reader.uint32();
190
+ switch (tag >>> 3) {
191
+ case 1: {
192
+ if (tag !== 10) {
193
+ break;
194
+ }
195
+
196
+ message.identifier = reader.string();
197
+ continue;
198
+ }
199
+ case 2: {
200
+ if (tag !== 18) {
201
+ break;
202
+ }
203
+
204
+ message.type = reader.string();
205
+ continue;
206
+ }
207
+ case 3: {
208
+ if (tag !== 26) {
209
+ break;
210
+ }
211
+
212
+ message.code = reader.string();
213
+ continue;
214
+ }
215
+ }
216
+ if ((tag & 7) === 4 || tag === 0) {
217
+ break;
218
+ }
219
+ reader.skip(tag & 7);
220
+ }
221
+ return message;
222
+ },
223
+
224
+ fromJSON(object: any): VerifyOtpRequest {
225
+ return {
226
+ identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
227
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
228
+ code: isSet(object.code) ? globalThis.String(object.code) : "",
229
+ };
230
+ },
231
+
232
+ toJSON(message: VerifyOtpRequest): unknown {
233
+ const obj: any = {};
234
+ if (message.identifier !== "") {
235
+ obj.identifier = message.identifier;
236
+ }
237
+ if (message.type !== "") {
238
+ obj.type = message.type;
239
+ }
240
+ if (message.code !== "") {
241
+ obj.code = message.code;
242
+ }
243
+ return obj;
244
+ },
245
+
246
+ create<I extends Exact<DeepPartial<VerifyOtpRequest>, I>>(base?: I): VerifyOtpRequest {
247
+ return VerifyOtpRequest.fromPartial(base ?? ({} as any));
248
+ },
249
+ fromPartial<I extends Exact<DeepPartial<VerifyOtpRequest>, I>>(object: I): VerifyOtpRequest {
250
+ const message = createBaseVerifyOtpRequest();
251
+ message.identifier = object.identifier ?? "";
252
+ message.type = object.type ?? "";
253
+ message.code = object.code ?? "";
254
+ return message;
255
+ },
256
+ };
257
+
258
+ function createBaseVerifyOtpResponse(): VerifyOtpResponse {
259
+ return { accessToken: "", refreshToken: "" };
260
+ }
261
+
262
+ export const VerifyOtpResponse: MessageFns<VerifyOtpResponse> = {
263
+ encode(message: VerifyOtpResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
264
+ if (message.accessToken !== "") {
265
+ writer.uint32(10).string(message.accessToken);
266
+ }
267
+ if (message.refreshToken !== "") {
268
+ writer.uint32(18).string(message.refreshToken);
269
+ }
270
+ return writer;
271
+ },
272
+
273
+ decode(input: BinaryReader | Uint8Array, length?: number): VerifyOtpResponse {
274
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
275
+ const end = length === undefined ? reader.len : reader.pos + length;
276
+ const message = createBaseVerifyOtpResponse();
277
+ while (reader.pos < end) {
278
+ const tag = reader.uint32();
279
+ switch (tag >>> 3) {
280
+ case 1: {
281
+ if (tag !== 10) {
282
+ break;
283
+ }
284
+
285
+ message.accessToken = reader.string();
286
+ continue;
287
+ }
288
+ case 2: {
289
+ if (tag !== 18) {
290
+ break;
291
+ }
292
+
293
+ message.refreshToken = reader.string();
294
+ continue;
295
+ }
296
+ }
297
+ if ((tag & 7) === 4 || tag === 0) {
298
+ break;
299
+ }
300
+ reader.skip(tag & 7);
301
+ }
302
+ return message;
303
+ },
304
+
305
+ fromJSON(object: any): VerifyOtpResponse {
306
+ return {
307
+ accessToken: isSet(object.accessToken)
308
+ ? globalThis.String(object.accessToken)
309
+ : isSet(object.access_token)
310
+ ? globalThis.String(object.access_token)
311
+ : "",
312
+ refreshToken: isSet(object.refreshToken)
313
+ ? globalThis.String(object.refreshToken)
314
+ : isSet(object.refresh_token)
315
+ ? globalThis.String(object.refresh_token)
316
+ : "",
317
+ };
318
+ },
319
+
320
+ toJSON(message: VerifyOtpResponse): unknown {
321
+ const obj: any = {};
322
+ if (message.accessToken !== "") {
323
+ obj.accessToken = message.accessToken;
324
+ }
325
+ if (message.refreshToken !== "") {
326
+ obj.refreshToken = message.refreshToken;
327
+ }
328
+ return obj;
329
+ },
330
+
331
+ create<I extends Exact<DeepPartial<VerifyOtpResponse>, I>>(base?: I): VerifyOtpResponse {
332
+ return VerifyOtpResponse.fromPartial(base ?? ({} as any));
333
+ },
334
+ fromPartial<I extends Exact<DeepPartial<VerifyOtpResponse>, I>>(object: I): VerifyOtpResponse {
335
+ const message = createBaseVerifyOtpResponse();
336
+ message.accessToken = object.accessToken ?? "";
337
+ message.refreshToken = object.refreshToken ?? "";
338
+ return message;
339
+ },
340
+ };
341
+
342
+ export interface AuthService {
343
+ SendOtp(request: SendOtpRequest): Promise<SendOtpResponse>;
344
+ VerifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse>;
345
+ }
346
+
347
+ export const AuthServiceServiceName = "auth.v1.AuthService";
348
+ export class AuthServiceClientImpl implements AuthService {
349
+ private readonly rpc: Rpc;
350
+ private readonly service: string;
351
+ constructor(rpc: Rpc, opts?: { service?: string }) {
352
+ this.service = opts?.service || AuthServiceServiceName;
353
+ this.rpc = rpc;
354
+ this.SendOtp = this.SendOtp.bind(this);
355
+ this.VerifyOtp = this.VerifyOtp.bind(this);
356
+ }
357
+ SendOtp(request: SendOtpRequest): Promise<SendOtpResponse> {
358
+ const data = SendOtpRequest.encode(request).finish();
359
+ const promise = this.rpc.request(this.service, "SendOtp", data);
360
+ return promise.then((data) => SendOtpResponse.decode(new BinaryReader(data)));
361
+ }
362
+
363
+ VerifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> {
364
+ const data = VerifyOtpRequest.encode(request).finish();
365
+ const promise = this.rpc.request(this.service, "VerifyOtp", data);
366
+ return promise.then((data) => VerifyOtpResponse.decode(new BinaryReader(data)));
367
+ }
368
+ }
369
+
370
+ interface Rpc {
371
+ request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
372
+ }
373
+
374
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
375
+
376
+ export type DeepPartial<T> = T extends Builtin ? T
377
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
378
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
379
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
380
+ : Partial<T>;
381
+
382
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
383
+ export type Exact<P, I extends P> = P extends Builtin ? P
384
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
385
+
386
+ function isSet(value: any): boolean {
387
+ return value !== null && value !== undefined;
388
+ }
389
+
390
+ export interface MessageFns<T> {
391
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
392
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
393
+ fromJSON(object: any): T;
394
+ toJSON(message: T): unknown;
395
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
396
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
397
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@sa2-movie-ticket/testing",
3
+ "version": "1.0.1",
4
+ "description": "",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "generate": "mkdir -p gen && protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./gen proto/*.proto",
8
+ "start": "node src/index.js"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "license": "ISC",
16
+ "type": "commonjs",
17
+ "devDependencies": {
18
+ "ts-proto": "^2.11.2"
19
+ }
20
+ }
@@ -0,0 +1,31 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ option go_package = "github.com/sa2-movie-ticket/contracts/gen/go/auth";
6
+
7
+ service AuthService {
8
+ rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
9
+ rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);
10
+ }
11
+
12
+ message SendOtpRequest {
13
+ string identifier = 1;
14
+ string type = 2;
15
+ }
16
+
17
+ message SendOtpResponse {
18
+ bool ok = 1;
19
+ }
20
+
21
+ message VerifyOtpRequest {
22
+ string identifier = 1;
23
+ string type = 2;
24
+ string code = 3;
25
+ }
26
+
27
+ message VerifyOtpResponse {
28
+ string access_token = 1;
29
+ string refresh_token = 2;
30
+ }
31
+
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export const add = (a, b) => a + b;