@hodfords/nestjs-grpc-helper 10.0.0-rc.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 +89 -0
- package/clients/custom-grpc.client.d.ts +27 -0
- package/clients/custom-grpc.client.js +265 -0
- package/clients/custom-grpc.client.js.map +1 -0
- package/commands/generate-sdk.command.d.ts +4 -0
- package/commands/generate-sdk.command.js +28 -0
- package/commands/generate-sdk.command.js.map +1 -0
- package/decorators/grpc-value.decorator.d.ts +1 -0
- package/decorators/grpc-value.decorator.js +12 -0
- package/decorators/grpc-value.decorator.js.map +1 -0
- package/decorators/microservice.decorator.d.ts +2 -0
- package/decorators/microservice.decorator.js +22 -0
- package/decorators/microservice.decorator.js.map +1 -0
- package/decorators/mock.decorator.d.ts +4 -0
- package/decorators/mock.decorator.js +34 -0
- package/decorators/mock.decorator.js.map +1 -0
- package/decorators/property.decorator.d.ts +2 -0
- package/decorators/property.decorator.js +21 -0
- package/decorators/property.decorator.js.map +1 -0
- package/documents/grpc-test.dto.d.ts +6 -0
- package/documents/grpc-test.dto.js +42 -0
- package/documents/grpc-test.dto.js.map +1 -0
- package/documents/microservice-document.controller.d.ts +10 -0
- package/documents/microservice-document.controller.js +59 -0
- package/documents/microservice-document.controller.js.map +1 -0
- package/documents/microservice-document.module.d.ts +5 -0
- package/documents/microservice-document.module.js +60 -0
- package/documents/microservice-document.module.js.map +1 -0
- package/frontend/3rdpartylicenses.txt +393 -0
- package/frontend/assets/config.json +1 -0
- package/frontend/chunk-5FZOKLP6.js +1 -0
- package/frontend/chunk-IKVALLPG.js +9 -0
- package/frontend/favicon.ico +0 -0
- package/frontend/index.html +14 -0
- package/frontend/main-GUJBJU47.js +21 -0
- package/frontend/polyfills-BJX5WH5B.js +2 -0
- package/frontend/styles-GLNRDJWV.css +1 -0
- package/helpers/api-property.helper.d.ts +2 -0
- package/helpers/api-property.helper.js +9 -0
- package/helpers/api-property.helper.js.map +1 -0
- package/helpers/generate.helper.d.ts +3 -0
- package/helpers/generate.helper.js +19 -0
- package/helpers/generate.helper.js.map +1 -0
- package/helpers/mock.helper.d.ts +1 -0
- package/helpers/mock.helper.js +61 -0
- package/helpers/mock.helper.js.map +1 -0
- package/helpers/property.helper.d.ts +8 -0
- package/helpers/property.helper.js +92 -0
- package/helpers/property.helper.js.map +1 -0
- package/helpers/proto-type.helper.d.ts +3 -0
- package/helpers/proto-type.helper.js +36 -0
- package/helpers/proto-type.helper.js.map +1 -0
- package/index.d.ts +11 -0
- package/index.js +28 -0
- package/index.js.map +1 -0
- package/package.json +107 -0
- package/sdk-stub/constants/multi-language-key.constant.d.ts +3 -0
- package/sdk-stub/constants/multi-language-key.constant.js +7 -0
- package/sdk-stub/constants/multi-language-key.constant.js.map +1 -0
- package/sdk-stub/constants/multi-language-key.constant.ts +3 -0
- package/sdk-stub/helpers/grpc.helper.d.ts +25 -0
- package/sdk-stub/helpers/grpc.helper.js +106 -0
- package/sdk-stub/helpers/grpc.helper.js.map +1 -0
- package/sdk-stub/helpers/grpc.helper.ts +129 -0
- package/sdk-stub/types/microservice-option.type.d.ts +12 -0
- package/sdk-stub/types/microservice-option.type.js +3 -0
- package/sdk-stub/types/microservice-option.type.js.map +1 -0
- package/sdk-stub/types/microservice-option.type.ts +13 -0
- package/services/generate-document.service.d.ts +12 -0
- package/services/generate-document.service.js +121 -0
- package/services/generate-document.service.js.map +1 -0
- package/services/generate-microservice.service.d.ts +23 -0
- package/services/generate-microservice.service.js +200 -0
- package/services/generate-microservice.service.js.map +1 -0
- package/services/generate-proto.service.d.ts +12 -0
- package/services/generate-proto.service.js +132 -0
- package/services/generate-proto.service.js.map +1 -0
- package/services/method-template.service.d.ts +5 -0
- package/services/method-template.service.js +50 -0
- package/services/method-template.service.js.map +1 -0
- package/services/mock-method-template.service.d.ts +5 -0
- package/services/mock-method-template.service.js +32 -0
- package/services/mock-method-template.service.js.map +1 -0
- package/services/mock-module-template.service.d.ts +6 -0
- package/services/mock-module-template.service.js +37 -0
- package/services/mock-module-template.service.js.map +1 -0
- package/services/module-template.service.d.ts +6 -0
- package/services/module-template.service.js +60 -0
- package/services/module-template.service.js.map +1 -0
- package/services/service-template.service.d.ts +10 -0
- package/services/service-template.service.js +105 -0
- package/services/service-template.service.js.map +1 -0
- package/storages/microservice.storage.d.ts +1 -0
- package/storages/microservice.storage.js +5 -0
- package/storages/microservice.storage.js.map +1 -0
- package/storages/property.storage.d.ts +3 -0
- package/storages/property.storage.js +6 -0
- package/storages/property.storage.js.map +1 -0
- package/types/document-module-option.type.d.ts +8 -0
- package/types/document-module-option.type.js +3 -0
- package/types/document-module-option.type.js.map +1 -0
- package/types/document.type.d.ts +40 -0
- package/types/document.type.js +3 -0
- package/types/document.type.js.map +1 -0
- package/types/mock-option.type.d.ts +12 -0
- package/types/mock-option.type.js +3 -0
- package/types/mock-option.type.js.map +1 -0
- package/types/property-option.type.d.ts +15 -0
- package/types/property-option.type.js +3 -0
- package/types/property-option.type.js.map +1 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.GenerateProtoService = void 0;
|
|
30
|
+
const nestjs_response_1 = require("@hodfords/nestjs-response");
|
|
31
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
32
|
+
const fs = __importStar(require("fs-extra"));
|
|
33
|
+
const path_1 = __importDefault(require("path"));
|
|
34
|
+
const property_helper_1 = require("../helpers/property.helper");
|
|
35
|
+
const microservice_storage_1 = require("../storages/microservice.storage");
|
|
36
|
+
class GenerateProtoService {
|
|
37
|
+
constructor(packageName, dirPath) {
|
|
38
|
+
this.packageName = packageName;
|
|
39
|
+
this.dirPath = dirPath;
|
|
40
|
+
}
|
|
41
|
+
generate() {
|
|
42
|
+
let microserviceContent = this.generateMicroservices();
|
|
43
|
+
const modelContent = this.generateModels();
|
|
44
|
+
const headerContent = `
|
|
45
|
+
syntax = "proto3";
|
|
46
|
+
import "google/protobuf/empty.proto";
|
|
47
|
+
package ${this.packageName};
|
|
48
|
+
`;
|
|
49
|
+
microserviceContent = `
|
|
50
|
+
${headerContent}
|
|
51
|
+
${microserviceContent}
|
|
52
|
+
${modelContent}
|
|
53
|
+
`
|
|
54
|
+
.replaceAll(' ', '')
|
|
55
|
+
.trim();
|
|
56
|
+
const microserviceProtoPath = path_1.default.join(this.dirPath, 'microservice.proto');
|
|
57
|
+
fs.ensureFileSync(microserviceProtoPath);
|
|
58
|
+
fs.writeFileSync(microserviceProtoPath, microserviceContent);
|
|
59
|
+
}
|
|
60
|
+
generateModels() {
|
|
61
|
+
const dtoWithProperties = (0, property_helper_1.extractProperties)();
|
|
62
|
+
const content = Object.keys(dtoWithProperties).map((name) => this.generateModel({ name }, dtoWithProperties[name]));
|
|
63
|
+
return content.reverse().join('\n');
|
|
64
|
+
}
|
|
65
|
+
generateModel(dto, properties) {
|
|
66
|
+
const propertyContent = properties
|
|
67
|
+
.map((property, index) => `${property.option.isArray ? 'repeated ' : ''}${this.getProtoType(property.option.type)} ${property.name} = ${index + 1};`)
|
|
68
|
+
.join('\n\t');
|
|
69
|
+
return `
|
|
70
|
+
message ${dto.name} {
|
|
71
|
+
${propertyContent}
|
|
72
|
+
}
|
|
73
|
+
message Proto${dto.name}List {
|
|
74
|
+
repeated ${dto.name} items = 1;
|
|
75
|
+
bool grpcArray = 2;
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
getProtoType(type) {
|
|
80
|
+
if ((0, shared_utils_1.isFunction)(type)) {
|
|
81
|
+
if (type.name === 'type') {
|
|
82
|
+
return type().name;
|
|
83
|
+
}
|
|
84
|
+
return type.name;
|
|
85
|
+
}
|
|
86
|
+
return type;
|
|
87
|
+
}
|
|
88
|
+
generateMicroservices() {
|
|
89
|
+
const content = [];
|
|
90
|
+
for (const constructor of microservice_storage_1.microserviceStorage) {
|
|
91
|
+
content.push(this.generateMicroservice(constructor));
|
|
92
|
+
}
|
|
93
|
+
return content.join('\n');
|
|
94
|
+
}
|
|
95
|
+
generateMicroservice(constructor) {
|
|
96
|
+
const propertyKeys = Object.getOwnPropertyNames(constructor.prototype);
|
|
97
|
+
const rpcMethods = propertyKeys
|
|
98
|
+
.map((propertyKey) => this.generateRpcMethod(constructor, propertyKey))
|
|
99
|
+
.filter((method) => method);
|
|
100
|
+
if (!rpcMethods.length) {
|
|
101
|
+
return '';
|
|
102
|
+
}
|
|
103
|
+
return `
|
|
104
|
+
service ${constructor.name} {
|
|
105
|
+
${rpcMethods.join('\n\t')}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
generateRpcMethod(constructor, propertyKey) {
|
|
110
|
+
if (Reflect.hasMetadata('grpc:method', constructor.prototype, propertyKey)) {
|
|
111
|
+
const params = Reflect.getMetadata('design:paramtypes', constructor.prototype, propertyKey);
|
|
112
|
+
const parameterIndex = Reflect.getMetadata('grpc:parameter-index', constructor.prototype, propertyKey);
|
|
113
|
+
let parameterName = 'google.protobuf.Empty';
|
|
114
|
+
if (!(0, shared_utils_1.isUndefined)(parameterIndex)) {
|
|
115
|
+
parameterName = params[parameterIndex].name;
|
|
116
|
+
}
|
|
117
|
+
const response = Reflect.getMetadata(nestjs_response_1.RESPONSE_METADATA_KEY, constructor.prototype[propertyKey]);
|
|
118
|
+
let returnType = 'google.protobuf.Empty';
|
|
119
|
+
if (response) {
|
|
120
|
+
if (response.isArray) {
|
|
121
|
+
returnType = `Proto${response.responseClass.name}List`;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
returnType = response.responseClass.name;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return `rpc ${propertyKey} (${parameterName}) returns (${returnType}) {}`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.GenerateProtoService = GenerateProtoService;
|
|
132
|
+
//# sourceMappingURL=generate-proto.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-proto.service.js","sourceRoot":"","sources":["../../../libs/services/generate-proto.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAkE;AAClE,oEAA4E;AAC5E,6CAA+B;AAC/B,gDAAwB;AACxB,gEAA+D;AAC/D,2EAAuE;AAEvE,MAAa,oBAAoB;IAC7B,YACY,WAAmB,EACnB,OAAe;QADf,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,C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,EAAE,WAAmB;QAC9C,IAAI,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC;YACzE,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YAC5F,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,sBAAsB,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YACvG,IAAI,aAAa,GAAG,uBAAuB,CAAC;YAC5C,IAAI,CAAC,IAAA,0BAAW,EAAC,cAAc,CAAC,EAAE,CAAC;gBAC/B,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC;YAChD,CAAC;YACD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,uCAAqB,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;YAChG,IAAI,UAAU,GAAG,uBAAuB,CAAC;YACzC,IAAI,QAAQ,EAAE,CAAC;gBACX,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;oBACnB,UAAU,GAAG,QAAQ,QAAQ,CAAC,aAAa,CAAC,IAAI,MAAM,CAAC;gBAC3D,CAAC;qBAAM,CAAC;oBACJ,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC;gBAC7C,CAAC;YACL,CAAC;YACD,OAAO,OAAO,WAAW,KAAK,aAAa,cAAc,UAAU,MAAM,CAAC;QAC9E,CAAC;IACL,CAAC;CACJ;AAhHD,oDAgHC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ResponseMetadata } from '@hodfords/nestjs-response';
|
|
2
|
+
export declare class MethodTemplateService {
|
|
3
|
+
templateBody(response: ResponseMetadata, serviceName: string, method: string, parameterName: string): string;
|
|
4
|
+
methodTemplate(method: string, params: string, returnType: string, body: string): string;
|
|
5
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MethodTemplateService = void 0;
|
|
4
|
+
class MethodTemplateService {
|
|
5
|
+
templateBody(response, serviceName, method, parameterName) {
|
|
6
|
+
if (response) {
|
|
7
|
+
if (response.isArray) {
|
|
8
|
+
return `
|
|
9
|
+
return await GrpcHelper.with(this.client, ${response.responseClass.name}, this.options)
|
|
10
|
+
.service('${serviceName}')
|
|
11
|
+
.method('${method}')
|
|
12
|
+
.data(${parameterName ? 'param' : '{}'})
|
|
13
|
+
.getMany();
|
|
14
|
+
`;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return `
|
|
18
|
+
return await GrpcHelper.with(this.client, ${response.responseClass.name}, this.options)
|
|
19
|
+
.service('${serviceName}')
|
|
20
|
+
.method('${method}')
|
|
21
|
+
.data(${parameterName ? 'param' : '{}'})
|
|
22
|
+
.getOne();
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return `
|
|
28
|
+
await GrpcHelper.with(this.client, null as any, this.options)
|
|
29
|
+
.service('${serviceName}')
|
|
30
|
+
.method('${method}')
|
|
31
|
+
.data(${parameterName ? 'param' : '{}'})
|
|
32
|
+
.getMany();
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
methodTemplate(method, params, returnType, body) {
|
|
37
|
+
if (params) {
|
|
38
|
+
return `
|
|
39
|
+
async ${method}(param: ${params}): Promise<${returnType}> {
|
|
40
|
+
${body}
|
|
41
|
+
}`;
|
|
42
|
+
}
|
|
43
|
+
return `
|
|
44
|
+
async ${method}(): Promise<${returnType}> {
|
|
45
|
+
${body}
|
|
46
|
+
}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.MethodTemplateService = MethodTemplateService;
|
|
50
|
+
//# sourceMappingURL=method-template.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-template.service.js","sourceRoot":"","sources":["../../../libs/services/method-template.service.ts"],"names":[],"mappings":";;;AAEA,MAAa,qBAAqB;IAC9B,YAAY,CAAC,QAA0B,EAAE,WAAmB,EAAE,MAAc,EAAE,aAAqB;QAC/F,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO;gEACyC,QAAQ,CAAC,aAAa,CAAC,IAAI;oCACvD,WAAW;mCACZ,MAAM;gCACT,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;qBAEzC,CAAC;YACV,CAAC;iBAAM,CAAC;gBACJ,OAAO;gEACyC,QAAQ,CAAC,aAAa,CAAC,IAAI;oCACvD,WAAW;mCACZ,MAAM;gCACT,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;qBAEzC,CAAC;YACV,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,OAAO;;oCAEiB,WAAW;mCACZ,MAAM;gCACT,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;aAEjD,CAAC;QACN,CAAC;IACL,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,MAAc,EAAE,UAAkB,EAAE,IAAY;QAC3E,IAAI,MAAM,EAAE,CAAC;YACT,OAAO;oBACC,MAAM,WAAW,MAAM,cAAc,UAAU;kBACjD,IAAI;cACR,CAAC;QACP,CAAC;QACD,OAAO;oBACK,MAAM,eAAe,UAAU;kBACjC,IAAI;cACR,CAAC;IACX,CAAC;CACJ;AA3CD,sDA2CC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockMethodTemplateService = void 0;
|
|
4
|
+
class MockMethodTemplateService {
|
|
5
|
+
templateBody(response) {
|
|
6
|
+
if (response) {
|
|
7
|
+
if (response.isArray) {
|
|
8
|
+
return `return [sample(${response.responseClass.name})];`;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return `return sample(${response.responseClass.name});`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return ``;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
methodTemplate(method, params, returnType, body) {
|
|
19
|
+
if (params) {
|
|
20
|
+
return `
|
|
21
|
+
async ${method}(param: ${params}): Promise<${returnType}> {
|
|
22
|
+
${body}
|
|
23
|
+
}`;
|
|
24
|
+
}
|
|
25
|
+
return `
|
|
26
|
+
async ${method}(): Promise<${returnType}> {
|
|
27
|
+
${body}
|
|
28
|
+
}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.MockMethodTemplateService = MockMethodTemplateService;
|
|
32
|
+
//# sourceMappingURL=mock-method-template.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-method-template.service.js","sourceRoot":"","sources":["../../../libs/services/mock-method-template.service.ts"],"names":[],"mappings":";;;AAEA,MAAa,yBAAyB;IAClC,YAAY,CAAC,QAA0B;QACnC,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,kBAAkB,QAAQ,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACJ,OAAO,iBAAiB,QAAQ,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;YAC5D,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,MAAc,EAAE,UAAkB,EAAE,IAAY;QAC3E,IAAI,MAAM,EAAE,CAAC;YACT,OAAO;oBACC,MAAM,WAAW,MAAM,cAAc,UAAU;kBACjD,IAAI;cACR,CAAC;QACP,CAAC;QACD,OAAO;oBACK,MAAM,eAAe,UAAU;kBACjC,IAAI;cACR,CAAC;IACX,CAAC;CACJ;AAzBD,8DAyBC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockModuleTemplateService = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
class MockModuleTemplateService {
|
|
6
|
+
constructor(packageName, fileName) {
|
|
7
|
+
this.packageName = packageName;
|
|
8
|
+
this.fileName = fileName;
|
|
9
|
+
}
|
|
10
|
+
template(services) {
|
|
11
|
+
const moduleName = (0, lodash_1.upperFirst)((0, lodash_1.camelCase)(this.packageName));
|
|
12
|
+
const providers = services
|
|
13
|
+
.map((service) => `{
|
|
14
|
+
provide: ${service},
|
|
15
|
+
useClass: Mock${service}
|
|
16
|
+
}`)
|
|
17
|
+
.join(',');
|
|
18
|
+
const mockServices = services.map((service) => `Mock${service}`);
|
|
19
|
+
const importServices = [...services, ...mockServices].join(',');
|
|
20
|
+
return `
|
|
21
|
+
import { Module, Global } from '@nestjs/common';
|
|
22
|
+
import { ${importServices} } from './services/${this.fileName}.service';
|
|
23
|
+
|
|
24
|
+
@Global()
|
|
25
|
+
@Module({
|
|
26
|
+
providers: [
|
|
27
|
+
${providers}
|
|
28
|
+
],
|
|
29
|
+
exports: [${services.join(',')}]
|
|
30
|
+
})
|
|
31
|
+
export class Mock${moduleName}Module {
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.MockModuleTemplateService = MockModuleTemplateService;
|
|
37
|
+
//# sourceMappingURL=mock-module-template.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-module-template.service.js","sourceRoot":"","sources":["../../../libs/services/mock-module-template.service.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,MAAa,yBAAyB;IAClC,YACY,WAAmB,EACnB,QAAgB;QADhB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAQ;IACzB,CAAC;IAEJ,QAAQ,CAAC,QAAkB;QACvB,MAAM,UAAU,GAAG,IAAA,mBAAU,EAAC,IAAA,kBAAS,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,QAAQ;aACrB,GAAG,CACA,CAAC,OAAO,EAAE,EAAE,CAAC;+BACE,OAAO;oCACF,OAAO;kBACzB,CACL;aACA,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC;QACjE,MAAM,cAAc,GAAG,CAAC,GAAG,QAAQ,EAAE,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEhE,OAAO;;mBAEI,cAAc,uBAAuB,IAAI,CAAC,QAAQ;;;;;kBAKnD,SAAS;;wBAEH,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;;2BAEf,UAAU;;SAE5B,CAAC;IACN,CAAC;CACJ;AAlCD,8DAkCC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModuleTemplateService = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
class ModuleTemplateService {
|
|
6
|
+
constructor(packageName, fileName) {
|
|
7
|
+
this.packageName = packageName;
|
|
8
|
+
this.fileName = fileName;
|
|
9
|
+
}
|
|
10
|
+
template(services) {
|
|
11
|
+
const moduleName = (0, lodash_1.upperFirst)((0, lodash_1.camelCase)(this.packageName));
|
|
12
|
+
return `
|
|
13
|
+
import { DynamicModule, Module, Global } from '@nestjs/common';
|
|
14
|
+
import { ClientsModule } from '@nestjs/microservices';
|
|
15
|
+
import path from 'path';
|
|
16
|
+
import { MicroserviceModuleOptionType } from './types/microservice-option.type';
|
|
17
|
+
import { ${services.join(',')} } from './services/${this.fileName}.service';
|
|
18
|
+
import { CustomGrpcClient } from '@hodfords/nestjs-grpc-helper';
|
|
19
|
+
import * as grpc from '@grpc/grpc-js';
|
|
20
|
+
|
|
21
|
+
@Global()
|
|
22
|
+
@Module({})
|
|
23
|
+
export class ${moduleName}Module {
|
|
24
|
+
static register(options: MicroserviceModuleOptionType): DynamicModule {
|
|
25
|
+
return {
|
|
26
|
+
module: ${moduleName}Module,
|
|
27
|
+
providers: [
|
|
28
|
+
${services.join(',')},
|
|
29
|
+
{
|
|
30
|
+
provide: '${this.packageName}_OPTIONS',
|
|
31
|
+
useValue: options
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
exports: [${services.join(',')}],
|
|
35
|
+
imports: [
|
|
36
|
+
ClientsModule.register([
|
|
37
|
+
{
|
|
38
|
+
name: '${this.packageName}_PACKAGE',
|
|
39
|
+
customClass: CustomGrpcClient,
|
|
40
|
+
options: {
|
|
41
|
+
url: options.url,
|
|
42
|
+
package: '${this.packageName}',
|
|
43
|
+
protoPath: path.join(__dirname, 'microservice.proto'),
|
|
44
|
+
credentials: options.ssl ? grpc.credentials.createSsl() : undefined,
|
|
45
|
+
maxReceiveMessageLength: options.maxReceiveMessageLength ?? 4 * 1024 * 1024,
|
|
46
|
+
loader: {
|
|
47
|
+
arrays: options.shouldLoadEmptyArray ?? false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
])
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.ModuleTemplateService = ModuleTemplateService;
|
|
60
|
+
//# sourceMappingURL=module-template.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-template.service.js","sourceRoot":"","sources":["../../../libs/services/module-template.service.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,MAAa,qBAAqB;IAC9B,YACY,WAAmB,EACnB,QAAgB;QADhB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAQ;IACzB,CAAC;IAEJ,QAAQ,CAAC,QAAkB;QACvB,MAAM,UAAU,GAAG,IAAA,mBAAU,EAAC,IAAA,kBAAS,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3D,OAAO;;;;;mBAKI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,CAAC,QAAQ;;;;;;uBAMlD,UAAU;;;8BAGH,UAAU;;0BAEd,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;;wCAEJ,IAAI,CAAC,WAAW;;;;gCAIxB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;;;;yCAIT,IAAI,CAAC,WAAW;;;;gDAIT,IAAI,CAAC,WAAW;;;;;;;;;;;;;;SAcvD,CAAC;IACN,CAAC;CACJ;AAtDD,sDAsDC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiPropertyOptions } from '@nestjs/swagger';
|
|
2
|
+
export declare class ServiceTemplateService {
|
|
3
|
+
private packageName;
|
|
4
|
+
constructor(packageName: string);
|
|
5
|
+
templateServiceAndModel(serviceContent: string, modelContent: string, enumContent: string): string;
|
|
6
|
+
templateService(serviceName: string, method: string[], isMock: boolean): string;
|
|
7
|
+
modelTemplate(name: string, properties: string[], parentClass: Function): string;
|
|
8
|
+
enumTemplate(options: ApiPropertyOptions): string;
|
|
9
|
+
propertyTemplate(property: any, type: string): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceTemplateService = void 0;
|
|
4
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
|
+
const api_property_helper_1 = require("../helpers/api-property.helper");
|
|
6
|
+
class ServiceTemplateService {
|
|
7
|
+
constructor(packageName) {
|
|
8
|
+
this.packageName = packageName;
|
|
9
|
+
}
|
|
10
|
+
templateServiceAndModel(serviceContent, modelContent, enumContent) {
|
|
11
|
+
return `
|
|
12
|
+
import { GrpcHelper } from '../helpers/grpc.helper';
|
|
13
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
14
|
+
import { ClientGrpc } from '@nestjs/microservices';
|
|
15
|
+
import { MicroserviceModuleOptionType } from '../types/microservice-option.type';
|
|
16
|
+
import { Type } from 'class-transformer';
|
|
17
|
+
import { Property, sample } from '@hodfords/nestjs-grpc-helper';
|
|
18
|
+
|
|
19
|
+
${enumContent}
|
|
20
|
+
|
|
21
|
+
${modelContent}
|
|
22
|
+
|
|
23
|
+
${serviceContent}
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
templateService(serviceName, method, isMock) {
|
|
27
|
+
if (isMock) {
|
|
28
|
+
return `
|
|
29
|
+
export class Mock${serviceName} {
|
|
30
|
+
${method.join('\n')}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
return `
|
|
35
|
+
@Injectable()
|
|
36
|
+
export class ${serviceName} {
|
|
37
|
+
constructor(
|
|
38
|
+
@Inject('${this.packageName}_PACKAGE') private client: ClientGrpc,
|
|
39
|
+
@Inject('${this.packageName}_OPTIONS') private options: MicroserviceModuleOptionType
|
|
40
|
+
) {}
|
|
41
|
+
${method.join('\n')}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
modelTemplate(name, properties, parentClass) {
|
|
46
|
+
let extendClass = '';
|
|
47
|
+
if (parentClass.name) {
|
|
48
|
+
extendClass = `extends ${parentClass.name}`;
|
|
49
|
+
}
|
|
50
|
+
return `
|
|
51
|
+
export class ${name} ${extendClass} {
|
|
52
|
+
${properties.join('\n')}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
enumTemplate(options) {
|
|
57
|
+
const { enum: properties, enumName, type } = options;
|
|
58
|
+
const valueFormatter = (value) => (type === 'string' ? `'${value}'` : value);
|
|
59
|
+
return `
|
|
60
|
+
export enum ${enumName} {
|
|
61
|
+
${Object.keys(properties)
|
|
62
|
+
.filter((key) => !parseInt(key))
|
|
63
|
+
.map((key) => `${key} = ${valueFormatter(properties[key])}`)
|
|
64
|
+
.join(',\n')}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
propertyTemplate(property, type) {
|
|
69
|
+
const isPrimitiveType = ['object', 'string', 'number', 'bool', 'boolean'].includes(type);
|
|
70
|
+
const isEnumType = (0, api_property_helper_1.isEnumProperty)(property.option);
|
|
71
|
+
const isNestedType = !isPrimitiveType && !isEnumType;
|
|
72
|
+
let propertyType = '';
|
|
73
|
+
if (isNestedType) {
|
|
74
|
+
propertyType = `ReturnType<() => ${type} ${property.option.isArray ? '[]' : ''}>`;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
propertyType = `${type} ${property.option.isArray ? '[]' : ''}`;
|
|
78
|
+
}
|
|
79
|
+
const propertyName = `${property.name}${property.option.required === false ? '?' : ''}: ${propertyType}`;
|
|
80
|
+
let typeDecorator = '';
|
|
81
|
+
if (isNestedType) {
|
|
82
|
+
typeDecorator = `@Type(() => ${type})`;
|
|
83
|
+
}
|
|
84
|
+
const options = { ...property.option, isAutoGenerated: true };
|
|
85
|
+
let propertyOption = JSON.stringify(options);
|
|
86
|
+
if ((0, shared_utils_1.isFunction)(property.option.type)) {
|
|
87
|
+
if (isNestedType) {
|
|
88
|
+
propertyOption = JSON.stringify({ ...options, type: type }).replaceAll(`"type":"${type}"`, `"type": () => ${type}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
propertyOption = JSON.stringify({ ...options, type: type }).replaceAll(`"type":"${type}"`, `"type":${type}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const propertyDecorator = `
|
|
95
|
+
@Property(${propertyOption})
|
|
96
|
+
`;
|
|
97
|
+
return `
|
|
98
|
+
${propertyDecorator}
|
|
99
|
+
${typeDecorator}
|
|
100
|
+
${propertyName}
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.ServiceTemplateService = ServiceTemplateService;
|
|
105
|
+
//# sourceMappingURL=service-template.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-template.service.js","sourceRoot":"","sources":["../../../libs/services/service-template.service.ts"],"names":[],"mappings":";;;AAAA,oEAA+D;AAE/D,wEAAkE;AAElE,MAAa,sBAAsB;IAC/B,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAE3C,uBAAuB,CAAC,cAAsB,EAAE,YAAoB,EAAE,WAAmB;QACrF,OAAO;;;;;;;;UAQL,WAAW;;UAEX,YAAY;;UAEZ,cAAc;SACf,CAAC;IACN,CAAC;IAED,eAAe,CAAC,WAAmB,EAAE,MAAgB,EAAE,MAAe;QAClE,IAAI,MAAM,EAAE,CAAC;YACT,OAAO;2BACQ,WAAW;aACzB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;SAErB,CAAC;QACF,CAAC;QACD,OAAO;;uBAEQ,WAAW;;2BAEP,IAAI,CAAC,WAAW;2BAChB,IAAI,CAAC,WAAW;;aAE9B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;SAErB,CAAC;IACN,CAAC;IAED,aAAa,CAAC,IAAY,EAAE,UAAoB,EAAE,WAAqB;QACnE,IAAI,WAAW,GAAG,EAAE,CAAC;QACrB,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;YACnB,WAAW,GAAG,WAAW,WAAW,CAAC,IAAI,EAAE,CAAC;QAChD,CAAC;QACD,OAAO;+BACgB,IAAI,IAAI,WAAW;sBAC5B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;aAE9B,CAAC;IACV,CAAC;I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ourceRoot":"","sources":["../../../libs/storages/microservice.storage.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property.storage.js","sourceRoot":"","sources":["../../../libs/storages/property.storage.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,IAAI,GAAG,EAA4B,CAAC;AACtD,QAAA,OAAO,GAAG,IAAI,GAAG,EAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ClientProvider } from '@nestjs/microservices/module/interfaces/clients-module.interface';
|
|
2
|
+
export type DocumentModuleOptionType = {
|
|
3
|
+
isEnable: boolean;
|
|
4
|
+
packageName: string;
|
|
5
|
+
clientOptions: ClientProvider;
|
|
6
|
+
waitingTime?: number;
|
|
7
|
+
prefix?: string;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-module-option.type.js","sourceRoot":"","sources":["../../../libs/types/document-module-option.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type DocumentType = {
|
|
2
|
+
title: string;
|
|
3
|
+
package: string;
|
|
4
|
+
description: string;
|
|
5
|
+
installDescription: string;
|
|
6
|
+
usageDescription: string;
|
|
7
|
+
microservices: MicroserviceDocumentType[];
|
|
8
|
+
models: ModelDocumentType[];
|
|
9
|
+
};
|
|
10
|
+
export type ModelDocumentType = {
|
|
11
|
+
classId: string;
|
|
12
|
+
model: Function;
|
|
13
|
+
name: string;
|
|
14
|
+
properties: PropertyDocumentType[];
|
|
15
|
+
};
|
|
16
|
+
export type PropertyDocumentType = {
|
|
17
|
+
name: string;
|
|
18
|
+
option: {
|
|
19
|
+
type: any;
|
|
20
|
+
isArray?: boolean;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
description?: string;
|
|
23
|
+
default?: any;
|
|
24
|
+
typeId?: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type MicroserviceDocumentType = {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
methods: MethodDocumentType[];
|
|
31
|
+
};
|
|
32
|
+
export type MethodDocumentType = {
|
|
33
|
+
name: string;
|
|
34
|
+
sdkUsage: string;
|
|
35
|
+
description: string;
|
|
36
|
+
parameter: string;
|
|
37
|
+
response: string;
|
|
38
|
+
isResponseArray: boolean;
|
|
39
|
+
exampleResponse: string;
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.type.js","sourceRoot":"","sources":["../../../libs/types/document.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="faker" />
|
|
2
|
+
type NestedKeyOf<ObjectType extends object> = {
|
|
3
|
+
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
|
|
4
|
+
}[keyof ObjectType & (string | number)];
|
|
5
|
+
export type MockMethodType = `faker.${NestedKeyOf<Faker.FakerStatic>}`;
|
|
6
|
+
export type MockOptionType = {
|
|
7
|
+
method?: MockMethodType;
|
|
8
|
+
args?: any[];
|
|
9
|
+
sample?: any;
|
|
10
|
+
nestedMaxSize?: number;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-option.type.js","sourceRoot":"","sources":["../../../libs/types/mock-option.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiPropertyOptions } from '@nestjs/swagger';
|
|
2
|
+
import { MockOptionType } from './mock-option.type';
|
|
3
|
+
export type PropertyType = {
|
|
4
|
+
name: string;
|
|
5
|
+
option: PropertyOptionType;
|
|
6
|
+
};
|
|
7
|
+
export type PropertyOptionType = {
|
|
8
|
+
type?: any;
|
|
9
|
+
isArray?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
description?: string;
|
|
12
|
+
default?: any;
|
|
13
|
+
mock?: MockOptionType;
|
|
14
|
+
isAutoGenerated?: boolean;
|
|
15
|
+
} & ApiPropertyOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-option.type.js","sourceRoot":"","sources":["../../../libs/types/property-option.type.ts"],"names":[],"mappings":""}
|