@sagebox-be/proto-contracts 1.0.0 → 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.
package/README.md CHANGED
@@ -17,14 +17,7 @@ pnpm add @sagebox-be/proto-contracts
17
17
  ### Import TypeScript Types
18
18
 
19
19
  ```typescript
20
- import {
21
- ProductServiceClient,
22
- ProductServiceController,
23
- GetProductByIdRequest,
24
- ProductResponse,
25
- getProtoPath,
26
- getAllProtosPaths,
27
- } from '@sagebox-be/proto-contracts';
20
+ import { ProductServiceClient, ProductServiceController, GetProductByIdRequest, ProductResponse, getProtoPath, getAllProtosPaths } from '@sagebox-be/proto-contracts';
28
21
  ```
29
22
 
30
23
  ### Use in NestJS gRPC Microservice
@@ -73,10 +66,7 @@ const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
73
66
  const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
74
67
  const productProto = protoDescriptor.product as any;
75
68
 
76
- const client: ProductServiceClient = new productProto.ProductService(
77
- 'localhost:5000',
78
- grpc.credentials.createInsecure()
79
- );
69
+ const client: ProductServiceClient = new productProto.ProductService('localhost:5000', grpc.credentials.createInsecure());
80
70
 
81
71
  // Make gRPC calls
82
72
  client.getProductById({ id: 'product-123' }, (error, response) => {
@@ -1,6 +1,6 @@
1
- import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
- import type { Metadata } from "@grpc/grpc-js";
3
- import { Observable } from "rxjs";
1
+ import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
2
+ import type { Metadata } from '@grpc/grpc-js';
3
+ import { Observable } from 'rxjs';
4
4
  export declare const protobufPackage = "product";
5
5
  /** Request messages */
6
6
  export interface GetProductsByCategoryIdRequest {
@@ -10,14 +10,14 @@ exports.ProductServiceControllerMethods = ProductServiceControllerMethods;
10
10
  /* eslint-disable */
11
11
  const wire_1 = require("@bufbuild/protobuf/wire");
12
12
  const microservices_1 = require("@nestjs/microservices");
13
- exports.protobufPackage = "product";
14
- exports.PRODUCT_PACKAGE_NAME = "product";
13
+ exports.protobufPackage = 'product';
14
+ exports.PRODUCT_PACKAGE_NAME = 'product';
15
15
  function createBaseGetProductsByCategoryIdRequest() {
16
- return { categoryId: "" };
16
+ return { categoryId: '' };
17
17
  }
18
18
  exports.GetProductsByCategoryIdRequest = {
19
19
  encode(message, writer = new wire_1.BinaryWriter()) {
20
- if (message.categoryId !== "") {
20
+ if (message.categoryId !== '') {
21
21
  writer.uint32(10).string(message.categoryId);
22
22
  }
23
23
  return writer;
@@ -46,11 +46,11 @@ exports.GetProductsByCategoryIdRequest = {
46
46
  },
47
47
  };
48
48
  function createBaseGetProductByIdRequest() {
49
- return { id: "" };
49
+ return { id: '' };
50
50
  }
51
51
  exports.GetProductByIdRequest = {
52
52
  encode(message, writer = new wire_1.BinaryWriter()) {
53
- if (message.id !== "") {
53
+ if (message.id !== '') {
54
54
  writer.uint32(10).string(message.id);
55
55
  }
56
56
  return writer;
@@ -79,26 +79,35 @@ exports.GetProductByIdRequest = {
79
79
  },
80
80
  };
81
81
  function createBaseCreateProductRequest() {
82
- return { name: "", title: "", description: "", categoryId: "", storeId: "", status: "", mediaKeys: [], skus: [] };
82
+ return {
83
+ name: '',
84
+ title: '',
85
+ description: '',
86
+ categoryId: '',
87
+ storeId: '',
88
+ status: '',
89
+ mediaKeys: [],
90
+ skus: [],
91
+ };
83
92
  }
84
93
  exports.CreateProductRequest = {
85
94
  encode(message, writer = new wire_1.BinaryWriter()) {
86
- if (message.name !== "") {
95
+ if (message.name !== '') {
87
96
  writer.uint32(10).string(message.name);
88
97
  }
89
- if (message.title !== "") {
98
+ if (message.title !== '') {
90
99
  writer.uint32(18).string(message.title);
91
100
  }
92
- if (message.description !== "") {
101
+ if (message.description !== '') {
93
102
  writer.uint32(26).string(message.description);
94
103
  }
95
- if (message.categoryId !== "") {
104
+ if (message.categoryId !== '') {
96
105
  writer.uint32(34).string(message.categoryId);
97
106
  }
98
- if (message.storeId !== "") {
107
+ if (message.storeId !== '') {
99
108
  writer.uint32(42).string(message.storeId);
100
109
  }
101
- if (message.status !== "") {
110
+ if (message.status !== '') {
102
111
  writer.uint32(50).string(message.status);
103
112
  }
104
113
  for (const v of message.mediaKeys) {
@@ -215,14 +224,14 @@ exports.GetProductsResponse = {
215
224
  },
216
225
  };
217
226
  function createBaseProductResponse() {
218
- return { product: undefined, error: "" };
227
+ return { product: undefined, error: '' };
219
228
  }
220
229
  exports.ProductResponse = {
221
230
  encode(message, writer = new wire_1.BinaryWriter()) {
222
231
  if (message.product !== undefined) {
223
232
  exports.Product.encode(message.product, writer.uint32(10).fork()).join();
224
233
  }
225
- if (message.error !== "") {
234
+ if (message.error !== '') {
226
235
  writer.uint32(18).string(message.error);
227
236
  }
228
237
  return writer;
@@ -259,60 +268,60 @@ exports.ProductResponse = {
259
268
  };
260
269
  function createBaseProduct() {
261
270
  return {
262
- id: "",
263
- name: "",
264
- title: "",
265
- description: "",
266
- keywords: "",
267
- categoryId: "",
268
- storeId: "",
271
+ id: '',
272
+ name: '',
273
+ title: '',
274
+ description: '',
275
+ keywords: '',
276
+ categoryId: '',
277
+ storeId: '',
269
278
  viewedCount: 0,
270
- status: "",
271
- url: "",
279
+ status: '',
280
+ url: '',
272
281
  media: [],
273
- createdAt: "",
274
- updatedAt: "",
282
+ createdAt: '',
283
+ updatedAt: '',
275
284
  };
276
285
  }
277
286
  exports.Product = {
278
287
  encode(message, writer = new wire_1.BinaryWriter()) {
279
- if (message.id !== "") {
288
+ if (message.id !== '') {
280
289
  writer.uint32(10).string(message.id);
281
290
  }
282
- if (message.name !== "") {
291
+ if (message.name !== '') {
283
292
  writer.uint32(18).string(message.name);
284
293
  }
285
- if (message.title !== "") {
294
+ if (message.title !== '') {
286
295
  writer.uint32(26).string(message.title);
287
296
  }
288
- if (message.description !== "") {
297
+ if (message.description !== '') {
289
298
  writer.uint32(34).string(message.description);
290
299
  }
291
- if (message.keywords !== "") {
300
+ if (message.keywords !== '') {
292
301
  writer.uint32(42).string(message.keywords);
293
302
  }
294
- if (message.categoryId !== "") {
303
+ if (message.categoryId !== '') {
295
304
  writer.uint32(50).string(message.categoryId);
296
305
  }
297
- if (message.storeId !== "") {
306
+ if (message.storeId !== '') {
298
307
  writer.uint32(58).string(message.storeId);
299
308
  }
300
309
  if (message.viewedCount !== 0) {
301
310
  writer.uint32(64).int32(message.viewedCount);
302
311
  }
303
- if (message.status !== "") {
312
+ if (message.status !== '') {
304
313
  writer.uint32(74).string(message.status);
305
314
  }
306
- if (message.url !== "") {
315
+ if (message.url !== '') {
307
316
  writer.uint32(82).string(message.url);
308
317
  }
309
318
  for (const v of message.media) {
310
319
  exports.Media.encode(v, writer.uint32(90).fork()).join();
311
320
  }
312
- if (message.createdAt !== "") {
321
+ if (message.createdAt !== '') {
313
322
  writer.uint32(98).string(message.createdAt);
314
323
  }
315
- if (message.updatedAt !== "") {
324
+ if (message.updatedAt !== '') {
316
325
  writer.uint32(106).string(message.updatedAt);
317
326
  }
318
327
  return writer;
@@ -425,26 +434,26 @@ exports.Product = {
425
434
  },
426
435
  };
427
436
  function createBaseMedia() {
428
- return { id: "", key: "", url: "", type: "", createdAt: "", updatedAt: "" };
437
+ return { id: '', key: '', url: '', type: '', createdAt: '', updatedAt: '' };
429
438
  }
430
439
  exports.Media = {
431
440
  encode(message, writer = new wire_1.BinaryWriter()) {
432
- if (message.id !== "") {
441
+ if (message.id !== '') {
433
442
  writer.uint32(10).string(message.id);
434
443
  }
435
- if (message.key !== "") {
444
+ if (message.key !== '') {
436
445
  writer.uint32(18).string(message.key);
437
446
  }
438
- if (message.url !== "") {
447
+ if (message.url !== '') {
439
448
  writer.uint32(26).string(message.url);
440
449
  }
441
- if (message.type !== "") {
450
+ if (message.type !== '') {
442
451
  writer.uint32(34).string(message.type);
443
452
  }
444
- if (message.createdAt !== "") {
453
+ if (message.createdAt !== '') {
445
454
  writer.uint32(42).string(message.createdAt);
446
455
  }
447
- if (message.updatedAt !== "") {
456
+ if (message.updatedAt !== '') {
448
457
  writer.uint32(50).string(message.updatedAt);
449
458
  }
450
459
  return writer;
@@ -581,17 +590,17 @@ exports.ProductSkuInput = {
581
590
  },
582
591
  };
583
592
  function createBaseAttributeValueInput() {
584
- return { attrId: "", value: "", name: "" };
593
+ return { attrId: '', value: '', name: '' };
585
594
  }
586
595
  exports.AttributeValueInput = {
587
596
  encode(message, writer = new wire_1.BinaryWriter()) {
588
- if (message.attrId !== "") {
597
+ if (message.attrId !== '') {
589
598
  writer.uint32(10).string(message.attrId);
590
599
  }
591
- if (message.value !== "") {
600
+ if (message.value !== '') {
592
601
  writer.uint32(18).string(message.value);
593
602
  }
594
- if (message.name !== "") {
603
+ if (message.name !== '') {
595
604
  writer.uint32(26).string(message.name);
596
605
  }
597
606
  return writer;
@@ -635,16 +644,20 @@ exports.AttributeValueInput = {
635
644
  };
636
645
  function ProductServiceControllerMethods() {
637
646
  return function (constructor) {
638
- const grpcMethods = ["getProductsByCategoryId", "getProductById", "createProduct"];
647
+ const grpcMethods = [
648
+ 'getProductsByCategoryId',
649
+ 'getProductById',
650
+ 'createProduct',
651
+ ];
639
652
  for (const method of grpcMethods) {
640
653
  const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
641
- (0, microservices_1.GrpcMethod)("ProductService", method)(constructor.prototype[method], method, descriptor);
654
+ (0, microservices_1.GrpcMethod)('ProductService', method)(constructor.prototype[method], method, descriptor);
642
655
  }
643
656
  const grpcStreamMethods = [];
644
657
  for (const method of grpcStreamMethods) {
645
658
  const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
646
- (0, microservices_1.GrpcStreamMethod)("ProductService", method)(constructor.prototype[method], method, descriptor);
659
+ (0, microservices_1.GrpcStreamMethod)('ProductService', method)(constructor.prototype[method], method, descriptor);
647
660
  }
648
661
  };
649
662
  }
650
- exports.PRODUCT_SERVICE_NAME = "ProductService";
663
+ exports.PRODUCT_SERVICE_NAME = 'ProductService';
package/dist/utils.js CHANGED
@@ -9,7 +9,8 @@ const path_1 = require("path");
9
9
  * @returns The absolute path to the proto file
10
10
  */
11
11
  function getProtoPath(protoFileName) {
12
- return (0, path_1.join)(__dirname, '../proto', protoFileName);
12
+ // Use absolute path from workspace root to avoid dist folder issues
13
+ return (0, path_1.join)(process.cwd(), 'libs/proto-contracts/proto', protoFileName);
13
14
  }
14
15
  /**
15
16
  * Get all proto file paths
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sagebox-be/proto-contracts",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Sagebox gRPC Protocol Buffer contracts and TypeScript definitions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,10 +24,12 @@
24
24
  ],
25
25
  "author": "Sagebox Team",
26
26
  "license": "MIT",
27
+ "dependencies": {
28
+ "@nestjs/microservices": "^11.1.9"
29
+ },
27
30
  "devDependencies": {
28
31
  "@grpc/grpc-js": "^1.14.3",
29
32
  "@grpc/proto-loader": "^0.8.0",
30
- "@nestjs/microservices": "^11.1.9",
31
33
  "typescript": "^5.0.0"
32
34
  },
33
35
  "peerDependencies": {