@molecule-dev/ticketapp-contracts 1.0.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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(protoc:*)",
5
+ "Bash(npm install:*)"
6
+ ]
7
+ }
8
+ }
@@ -0,0 +1,32 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish:
10
+ name: Publish to NPM
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: 20
21
+ registry-url: https://registry.npmjs.org/
22
+
23
+ - name: Install deps
24
+ uses: yarn install --frozen-lockfile
25
+
26
+ - name: Generate TS Protobuf
27
+ uses: yarn run generate
28
+
29
+ - name: Publish to NPM
30
+ run: npm publish
31
+ env:
32
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.npmginore ADDED
@@ -0,0 +1,40 @@
1
+ # Node / package managers
2
+ node_modules
3
+ npm-debug.log*
4
+ yarn-debug.log*
5
+ yarn-error.log*
6
+ pnpm-debug.log*
7
+
8
+ # Build tools & configs
9
+ .eslintrc
10
+ .eslintrc.*
11
+ .prettierrc
12
+ .prettierrc.*
13
+ .editorconfig
14
+ tsconfig*.json
15
+ jest.config.*
16
+ vitest.config.*
17
+ webpack.config.*
18
+ rollup.config.*
19
+ vite.config.*
20
+
21
+
22
+ # Git & GitHub
23
+ .git
24
+ .gitignore
25
+ .github
26
+
27
+ # Environment files
28
+ .env
29
+ .env.*
30
+ .env.local
31
+
32
+ # Docs & misc
33
+ docs
34
+ examples
35
+ *.md
36
+
37
+ # OS / IDE
38
+ .DS_Store
39
+ .idea
40
+ .vscode
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Contracts
2
+
3
+ Protocol Buffer definitions and generated TypeScript code.
4
+
5
+ ## Directory Structure
6
+
7
+ - `proto/` - Protocol Buffer definition files (.proto)
8
+ - `gen/` - Generated TypeScript files
9
+
10
+ ## Generating TypeScript from Proto Files
11
+
12
+ To generate TypeScript files from the proto definitions, run:
13
+
14
+ ```bash
15
+ protoc \
16
+ --proto_path=./proto \
17
+ --ts_proto_out=./gen \
18
+ --ts_proto_opt=nestJs=true,package=omit \
19
+ ./proto/*.proto
20
+ ```
21
+
22
+ ### Prerequisites
23
+
24
+ Make sure you have `ts-proto` installed globally:
25
+
26
+ ```bash
27
+ npm install -g ts-proto
28
+ ```
29
+
30
+ ### Options
31
+
32
+ - `--proto_path=./proto` - Specifies the directory containing proto files
33
+ - `--ts_proto_out=./gen` - Output directory for generated TypeScript files
34
+ - `--ts_proto_opt` - ts-proto options:
35
+ - `nestJs=true` - Generate NestJS-compatible code with decorators
36
+ - `addGrpcMetadata=true` - Add gRPC metadata parameter to methods
37
+ - `addNestjsRestParameter=true` - Add rest parameter for additional arguments
38
+ - `outputServices=grpc-js` - Generate service definitions for @grpc/grpc-js
39
+ - `useExactTypes=false` - Use simpler type definitions
40
+ - `./proto/*.proto` - Input proto files
41
+
42
+ ### Using in NestJS
43
+
44
+ The generated code includes:
45
+
46
+ - `AuthServiceController` - Interface for your controller implementation
47
+ - `AuthServiceControllerMethods()` - Decorator to apply to your controller class
48
+ - `AuthServiceClient` - Interface for client-side usage
49
+ - `AuthServiceService` - gRPC service definition for module configuration
package/gen/auth.ts ADDED
@@ -0,0 +1,47 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v6.33.2
5
+ // source: auth.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "auth.v1";
12
+
13
+ export interface SendOtpRequest {
14
+ identifier: string;
15
+ type: string;
16
+ }
17
+
18
+ export interface SendOtpResponse {
19
+ ok: boolean;
20
+ }
21
+
22
+ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
23
+
24
+ export interface AuthServiceClient {
25
+ sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
26
+ }
27
+
28
+ export interface AuthServiceController {
29
+ sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
30
+ }
31
+
32
+ export function AuthServiceControllerMethods() {
33
+ return function (constructor: Function) {
34
+ const grpcMethods: string[] = ["sendOtp"];
35
+ for (const method of grpcMethods) {
36
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
37
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
38
+ }
39
+ const grpcStreamMethods: string[] = [];
40
+ for (const method of grpcStreamMethods) {
41
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
42
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
43
+ }
44
+ };
45
+ }
46
+
47
+ export const AUTH_SERVICE_NAME = "AuthService";
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@molecule-dev/ticketapp-contracts",
3
+ "version": "1.0.0",
4
+ "license": "ISC",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "description": "Protocol Buffer definitions and generated TypeScript code",
10
+ "scripts": {
11
+ "generate": "protoc --proto_path=./proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit ./proto/*.proto"
12
+ },
13
+ "dependencies": {
14
+ "@nestjs/microservices": "^11.1.11",
15
+ "rxjs": "^7.8.2"
16
+ }
17
+ }
@@ -0,0 +1,16 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ service AuthService {
6
+ rpc sendOtp(SendOtpRequest) returns (SendOtpResponse);
7
+ }
8
+
9
+ message SendOtpRequest {
10
+ string identifier = 1;
11
+ string type = 2;
12
+ }
13
+
14
+ message SendOtpResponse {
15
+ bool ok = 1;
16
+ }