@sagebox-be/proto-contracts 1.0.11 → 1.0.13
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/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/interfaces/sagebox.d.ts +179 -0
- package/dist/interfaces/sagebox.js +920 -0
- package/dist/types/product.d.ts +50 -9
- package/dist/types/product.js +32 -1
- package/dist/types/sagebox.d.ts +260 -0
- package/dist/types/sagebox.js +1486 -0
- package/dist/utils.d.ts +1 -8
- package/dist/utils.js +4 -13
- package/package.json +4 -8
- package/proto/sagebox.proto +134 -0
- package/proto/product.proto +0 -79
package/dist/utils.d.ts
CHANGED
|
@@ -3,11 +3,4 @@
|
|
|
3
3
|
* @param protoFileName - The name of the proto file (e.g., 'product.proto')
|
|
4
4
|
* @returns The absolute path to the proto file
|
|
5
5
|
*/
|
|
6
|
-
export declare function getProtoPath(
|
|
7
|
-
/**
|
|
8
|
-
* Get all proto file paths
|
|
9
|
-
* @returns Object with proto file paths
|
|
10
|
-
*/
|
|
11
|
-
export declare function getAllProtosPaths(): {
|
|
12
|
-
product: string;
|
|
13
|
-
};
|
|
6
|
+
export declare function getProtoPath(): string;
|
package/dist/utils.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getProtoPath = getProtoPath;
|
|
4
|
-
exports.getAllProtosPaths = getAllProtosPaths;
|
|
5
4
|
const path_1 = require("path");
|
|
6
5
|
/**
|
|
7
6
|
* Get the absolute path to a proto file
|
|
8
7
|
* @param protoFileName - The name of the proto file (e.g., 'product.proto')
|
|
9
8
|
* @returns The absolute path to the proto file
|
|
10
9
|
*/
|
|
11
|
-
function getProtoPath(
|
|
10
|
+
function getProtoPath() {
|
|
12
11
|
// Use absolute path from workspace root to avoid dist folder issues
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get all proto file paths
|
|
18
|
-
* @returns Object with proto file paths
|
|
19
|
-
*/
|
|
20
|
-
function getAllProtosPaths() {
|
|
21
|
-
return {
|
|
22
|
-
product: getProtoPath('product.proto'),
|
|
23
|
-
};
|
|
12
|
+
const protoPath = 'node_modules/@sagebox-be/proto-contracts/proto/sagebox.proto';
|
|
13
|
+
// const protoPath = 'libs/proto-contracts/proto/sagebox.proto';
|
|
14
|
+
return (0, path_1.join)(process.cwd(), protoPath);
|
|
24
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sagebox-be/proto-contracts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Sagebox gRPC Protocol Buffer contracts and TypeScript definitions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,9 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
|
-
"prepublishOnly": "npm run build"
|
|
15
|
-
"proto:copy": "cp -r ../common/src/grpc/proto ./proto",
|
|
16
|
-
"proto:generate": "../../bin/proto-generate.sh typescript"
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
17
15
|
},
|
|
18
16
|
"keywords": [
|
|
19
17
|
"grpc",
|
|
@@ -27,8 +25,7 @@
|
|
|
27
25
|
"dependencies": {
|
|
28
26
|
"@bufbuild/protobuf": "^2.2.2",
|
|
29
27
|
"@grpc/grpc-js": "^1.14.3",
|
|
30
|
-
"@grpc/proto-loader": "^0.8.0"
|
|
31
|
-
"nice-grpc-common": "^2.0.2"
|
|
28
|
+
"@grpc/proto-loader": "^0.8.0"
|
|
32
29
|
},
|
|
33
30
|
"devDependencies": {
|
|
34
31
|
"typescript": "^5.0.0"
|
|
@@ -36,8 +33,7 @@
|
|
|
36
33
|
"peerDependencies": {
|
|
37
34
|
"@bufbuild/protobuf": "^2.2.2",
|
|
38
35
|
"@grpc/grpc-js": "^1.14.0",
|
|
39
|
-
"@grpc/proto-loader": "^0.8.0"
|
|
40
|
-
"nice-grpc-common": "^2.0.2"
|
|
36
|
+
"@grpc/proto-loader": "^0.8.0"
|
|
41
37
|
},
|
|
42
38
|
"publishConfig": {
|
|
43
39
|
"access": "public"
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sagebox;
|
|
4
|
+
|
|
5
|
+
// ============================================
|
|
6
|
+
// Product Service
|
|
7
|
+
// ============================================
|
|
8
|
+
service ProductService {
|
|
9
|
+
rpc GetProductsByCategoryId(GetProductsByCategoryIdRequest) returns (GetProductsResponse);
|
|
10
|
+
rpc GetProductById(GetProductByIdRequest) returns (ProductResponse);
|
|
11
|
+
rpc CreateProduct(CreateProductRequest) returns (ProductResponse);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ============================================
|
|
15
|
+
// Address Service
|
|
16
|
+
// ============================================
|
|
17
|
+
service AddressService {
|
|
18
|
+
rpc GetProvinces(GetProvincesRequest) returns (GetProvincesResponse);
|
|
19
|
+
rpc GetDistricts(GetDistrictsRequest) returns (GetDistrictsResponse);
|
|
20
|
+
rpc GetWards(GetWardsRequest) returns (GetWardsResponse);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ============================================
|
|
24
|
+
// Product Request Messages
|
|
25
|
+
// ============================================
|
|
26
|
+
message GetProductsByCategoryIdRequest {
|
|
27
|
+
string categoryId = 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
message GetProductByIdRequest {
|
|
31
|
+
string id = 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
message CreateProductRequest {
|
|
35
|
+
string name = 1;
|
|
36
|
+
string title = 2;
|
|
37
|
+
string description = 3;
|
|
38
|
+
string categoryId = 4;
|
|
39
|
+
string storeId = 5;
|
|
40
|
+
string status = 6;
|
|
41
|
+
repeated string mediaKeys = 7;
|
|
42
|
+
repeated ProductSkuInput skus = 8;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ============================================
|
|
46
|
+
// Product Response Messages
|
|
47
|
+
// ============================================
|
|
48
|
+
message GetProductsResponse {
|
|
49
|
+
repeated Product products = 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
message ProductResponse {
|
|
53
|
+
Product product = 1;
|
|
54
|
+
string error = 2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ============================================
|
|
58
|
+
// Address Request Messages
|
|
59
|
+
// ============================================
|
|
60
|
+
message GetProvincesRequest {}
|
|
61
|
+
|
|
62
|
+
message GetDistrictsRequest {
|
|
63
|
+
string provinceCode = 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
message GetWardsRequest {
|
|
67
|
+
string provinceCode = 1;
|
|
68
|
+
string districtCode = 2;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ============================================
|
|
72
|
+
// Address Response Messages
|
|
73
|
+
// ============================================
|
|
74
|
+
message GetProvincesResponse {
|
|
75
|
+
repeated AddressUnit provinces = 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
message GetDistrictsResponse {
|
|
79
|
+
repeated AddressUnit districts = 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
message GetWardsResponse {
|
|
83
|
+
repeated AddressUnit wards = 1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ============================================
|
|
87
|
+
// Product Data Structures
|
|
88
|
+
// ============================================
|
|
89
|
+
message Product {
|
|
90
|
+
string id = 1;
|
|
91
|
+
string name = 2;
|
|
92
|
+
string title = 3;
|
|
93
|
+
string description = 4;
|
|
94
|
+
string keywords = 5;
|
|
95
|
+
string categoryId = 6;
|
|
96
|
+
string storeId = 7;
|
|
97
|
+
int32 viewedCount = 8;
|
|
98
|
+
string status = 9;
|
|
99
|
+
string url = 10;
|
|
100
|
+
repeated Media media = 11;
|
|
101
|
+
string createdAt = 12;
|
|
102
|
+
string updatedAt = 13;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
message Media {
|
|
106
|
+
string id = 1;
|
|
107
|
+
string key = 2;
|
|
108
|
+
string url = 3;
|
|
109
|
+
string type = 4;
|
|
110
|
+
string createdAt = 5;
|
|
111
|
+
string updatedAt = 6;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
message ProductSkuInput {
|
|
115
|
+
int32 price = 1;
|
|
116
|
+
int32 quantity = 2;
|
|
117
|
+
optional string brand = 3;
|
|
118
|
+
repeated string mediaKeys = 4;
|
|
119
|
+
repeated AttributeValueInput attributeValues = 5;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
message AttributeValueInput {
|
|
123
|
+
string attrId = 1;
|
|
124
|
+
string value = 2;
|
|
125
|
+
string name = 3;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ============================================
|
|
129
|
+
// Address Data Structures
|
|
130
|
+
// ============================================
|
|
131
|
+
message AddressUnit {
|
|
132
|
+
string code = 1;
|
|
133
|
+
string name = 2;
|
|
134
|
+
}
|
package/proto/product.proto
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
package product;
|
|
4
|
-
|
|
5
|
-
service ProductService {
|
|
6
|
-
rpc GetProductsByCategoryId(GetProductsByCategoryIdRequest) returns (GetProductsResponse);
|
|
7
|
-
rpc GetProductById(GetProductByIdRequest) returns (ProductResponse);
|
|
8
|
-
rpc CreateProduct(CreateProductRequest) returns (ProductResponse);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Request messages
|
|
12
|
-
message GetProductsByCategoryIdRequest {
|
|
13
|
-
string categoryId = 1;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
message GetProductByIdRequest {
|
|
17
|
-
string id = 1;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
message CreateProductRequest {
|
|
21
|
-
string name = 1;
|
|
22
|
-
string title = 2;
|
|
23
|
-
string description = 3;
|
|
24
|
-
string categoryId = 4;
|
|
25
|
-
string storeId = 5;
|
|
26
|
-
string status = 6;
|
|
27
|
-
repeated string mediaKeys = 7;
|
|
28
|
-
repeated ProductSkuInput skus = 8;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Response messages
|
|
32
|
-
message GetProductsResponse {
|
|
33
|
-
repeated Product products = 1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
message ProductResponse {
|
|
37
|
-
Product product = 1;
|
|
38
|
-
string error = 2;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Data structures
|
|
42
|
-
message Product {
|
|
43
|
-
string id = 1;
|
|
44
|
-
string name = 2;
|
|
45
|
-
string title = 3;
|
|
46
|
-
string description = 4;
|
|
47
|
-
string keywords = 5;
|
|
48
|
-
string categoryId = 6;
|
|
49
|
-
string storeId = 7;
|
|
50
|
-
int32 viewedCount = 8;
|
|
51
|
-
string status = 9;
|
|
52
|
-
string url = 10;
|
|
53
|
-
repeated Media media = 11;
|
|
54
|
-
string createdAt = 12;
|
|
55
|
-
string updatedAt = 13;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
message Media {
|
|
59
|
-
string id = 1;
|
|
60
|
-
string key = 2;
|
|
61
|
-
string url = 3;
|
|
62
|
-
string type = 4;
|
|
63
|
-
string createdAt = 5;
|
|
64
|
-
string updatedAt = 6;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
message ProductSkuInput {
|
|
68
|
-
int32 price = 1;
|
|
69
|
-
int32 quantity = 2;
|
|
70
|
-
optional string brand = 3;
|
|
71
|
-
repeated string mediaKeys = 4;
|
|
72
|
-
repeated AttributeValueInput attributeValues = 5;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
message AttributeValueInput {
|
|
76
|
-
string attrId = 1;
|
|
77
|
-
string value = 2;
|
|
78
|
-
string name = 3;
|
|
79
|
-
}
|