@rsdk/grpc.server 4.0.0-next.4 → 4.0.0-next.5
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/CHANGELOG.md +10 -0
- package/dist/controllers/index.d.ts +2 -0
- package/dist/controllers/index.js +2 -0
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/reflection/v1.base.controller.d.ts +32 -0
- package/dist/controllers/reflection/v1.base.controller.js +177 -0
- package/dist/controllers/reflection/v1.base.controller.js.map +1 -0
- package/dist/controllers/reflection/v1.controller.d.ts +10 -0
- package/dist/controllers/reflection/v1.controller.js +25 -0
- package/dist/controllers/reflection/v1.controller.js.map +1 -0
- package/dist/controllers/reflection/v1alpha.controller.d.ts +10 -0
- package/dist/controllers/reflection/v1alpha.controller.js +25 -0
- package/dist/controllers/reflection/v1alpha.controller.js.map +1 -0
- package/dist/grpc.config.d.ts +1 -0
- package/dist/grpc.config.js +8 -0
- package/dist/grpc.config.js.map +1 -1
- package/dist/grpc.transport.d.ts +13 -1
- package/dist/grpc.transport.js +40 -9
- package/dist/grpc.transport.js.map +1 -1
- package/dist/grpc.utils.d.ts +9 -0
- package/dist/grpc.utils.js +18 -0
- package/dist/grpc.utils.js.map +1 -0
- package/dist/reflection.module.d.ts +5 -0
- package/dist/reflection.module.js +33 -0
- package/dist/reflection.module.js.map +1 -0
- package/dist/reflection.service.d.ts +43 -0
- package/dist/reflection.service.js +151 -0
- package/dist/reflection.service.js.map +1 -0
- package/jest.config.js +11 -0
- package/package.json +7 -6
- package/src/controllers/index.ts +2 -0
- package/src/controllers/reflection/v1.base.controller.ts +173 -0
- package/src/controllers/reflection/v1.controller.ts +25 -0
- package/src/controllers/reflection/v1alpha.controller.ts +25 -0
- package/src/grpc.config.ts +7 -0
- package/src/grpc.transport.ts +51 -15
- package/src/grpc.utils.ts +20 -0
- package/src/reflection.module.ts +26 -0
- package/src/reflection.service.spec.ts +86 -0
- package/src/reflection.service.ts +210 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.0.0-next.5](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.4...v4.0.0-next.5) (2023-11-13)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **PFM-126:** reflection added ([ffaaa99](https://github.com/R-Vision/rsdk/commit/ffaaa996e0a81f98be46b0b73badb59f3e680eac))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* resolve comments ([6ab44dc](https://github.com/R-Vision/rsdk/commit/6ab44dc3cde0a36ec6dea67522e8f0c54505513c))
|
|
15
|
+
|
|
6
16
|
## [4.0.0-next.4](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.3...v4.0.0-next.4) (2023-11-12)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @rsdk/grpc.server
|
|
@@ -16,4 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./health.controller"), exports);
|
|
18
18
|
__exportStar(require("./metrics.controller"), exports);
|
|
19
|
+
__exportStar(require("./reflection/v1.controller"), exports);
|
|
20
|
+
__exportStar(require("./reflection/v1alpha.controller"), exports);
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,uDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,uDAAqC;AACrC,6DAA2C;AAC3C,kEAAgD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ServerReflectionGrpcController, ServerReflectionRequest, ServerReflectionResponse } from '@rsdk/builtin-contract/dist/grpc.reflection.v1';
|
|
2
|
+
import { ILogger } from '@rsdk/logging';
|
|
3
|
+
import type { Observable } from 'rxjs';
|
|
4
|
+
import { GRPCConfig } from '../../grpc.config';
|
|
5
|
+
import { ReflectionService } from '../../reflection.service';
|
|
6
|
+
/**
|
|
7
|
+
* Base class for alpha and final 'v1' versions of the gRPC reflection API
|
|
8
|
+
*
|
|
9
|
+
* note: the final version of the v1 spec was identical to the alpha version, so
|
|
10
|
+
* this common class is used in order to share logic across multiple controllers
|
|
11
|
+
* (this class itself is *not* a controller). See child classes for actual APIs
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://github.com/grpc/grpc/blob/master/doc/server-reflection.md}
|
|
14
|
+
*/
|
|
15
|
+
export declare class BaseV1GrpcReflectionController implements ServerReflectionGrpcController {
|
|
16
|
+
private readonly config;
|
|
17
|
+
private readonly logger;
|
|
18
|
+
private readonly service;
|
|
19
|
+
constructor(config: GRPCConfig, logger: ILogger, service: ReflectionService);
|
|
20
|
+
/** Main method for providing information about the running gRPC server
|
|
21
|
+
*
|
|
22
|
+
* The spec defines this as a single streaming method so that the connection
|
|
23
|
+
* stays open to the same running instance of the server for all follow-up
|
|
24
|
+
* requests. This means that we can keep some kind of state about what we've
|
|
25
|
+
* already to that client or not if we need to.
|
|
26
|
+
*/
|
|
27
|
+
serverReflectionInfo(request$: Observable<ServerReflectionRequest>): Observable<ServerReflectionResponse>;
|
|
28
|
+
private makeResponse;
|
|
29
|
+
private createServerReflectionResponse;
|
|
30
|
+
private resolveReflection;
|
|
31
|
+
private reflectionIsDisabled;
|
|
32
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
35
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.BaseV1GrpcReflectionController = void 0;
|
|
39
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
40
|
+
const common_1 = require("@nestjs/common");
|
|
41
|
+
const core_1 = require("@rsdk/core");
|
|
42
|
+
const rxjs_1 = require("rxjs");
|
|
43
|
+
const grpc_config_1 = require("../../grpc.config");
|
|
44
|
+
const reflection_service_1 = require("../../reflection.service");
|
|
45
|
+
/**
|
|
46
|
+
* Base class for alpha and final 'v1' versions of the gRPC reflection API
|
|
47
|
+
*
|
|
48
|
+
* note: the final version of the v1 spec was identical to the alpha version, so
|
|
49
|
+
* this common class is used in order to share logic across multiple controllers
|
|
50
|
+
* (this class itself is *not* a controller). See child classes for actual APIs
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://github.com/grpc/grpc/blob/master/doc/server-reflection.md}
|
|
53
|
+
*/
|
|
54
|
+
let BaseV1GrpcReflectionController = class BaseV1GrpcReflectionController {
|
|
55
|
+
config;
|
|
56
|
+
logger;
|
|
57
|
+
service;
|
|
58
|
+
constructor(config, logger, service) {
|
|
59
|
+
this.config = config;
|
|
60
|
+
this.logger = logger;
|
|
61
|
+
this.service = service;
|
|
62
|
+
}
|
|
63
|
+
/** Main method for providing information about the running gRPC server
|
|
64
|
+
*
|
|
65
|
+
* The spec defines this as a single streaming method so that the connection
|
|
66
|
+
* stays open to the same running instance of the server for all follow-up
|
|
67
|
+
* requests. This means that we can keep some kind of state about what we've
|
|
68
|
+
* already to that client or not if we need to.
|
|
69
|
+
*/
|
|
70
|
+
serverReflectionInfo(request$) {
|
|
71
|
+
const response$ = new rxjs_1.Subject();
|
|
72
|
+
request$.subscribe({
|
|
73
|
+
next: this.config.reflection
|
|
74
|
+
? this.resolveReflection(response$)
|
|
75
|
+
: this.reflectionIsDisabled(response$),
|
|
76
|
+
complete: () => response$.complete(),
|
|
77
|
+
});
|
|
78
|
+
return response$.asObservable();
|
|
79
|
+
}
|
|
80
|
+
makeResponse(request) {
|
|
81
|
+
if (request.messageRequest?.$case === 'listServices') {
|
|
82
|
+
return this.createServerReflectionResponse(request, {
|
|
83
|
+
$case: 'listServicesResponse',
|
|
84
|
+
listServicesResponse: {
|
|
85
|
+
service: this.service.listServices().map((name) => ({ name })),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (request.messageRequest?.$case === 'fileContainingSymbol') {
|
|
90
|
+
return this.createServerReflectionResponse(request, {
|
|
91
|
+
$case: 'fileDescriptorResponse',
|
|
92
|
+
fileDescriptorResponse: {
|
|
93
|
+
fileDescriptorProto: [
|
|
94
|
+
this.service.fileBySymbol(request.messageRequest.fileContainingSymbol),
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (request.messageRequest?.$case === 'fileByFilename') {
|
|
100
|
+
return this.createServerReflectionResponse(request, {
|
|
101
|
+
$case: 'fileDescriptorResponse',
|
|
102
|
+
fileDescriptorResponse: {
|
|
103
|
+
fileDescriptorProto: [
|
|
104
|
+
this.service.fileByName(request.messageRequest.fileByFilename),
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (request.messageRequest?.$case === 'fileContainingExtension') {
|
|
110
|
+
return this.createServerReflectionResponse(request, {
|
|
111
|
+
$case: 'fileDescriptorResponse',
|
|
112
|
+
fileDescriptorResponse: {
|
|
113
|
+
fileDescriptorProto: [
|
|
114
|
+
this.service.fileContainingExtension(request.messageRequest.fileContainingExtension.containingType, request.messageRequest.fileContainingExtension.extensionNumber),
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (request.messageRequest?.$case === 'allExtensionNumbersOfType') {
|
|
120
|
+
return this.createServerReflectionResponse(request, {
|
|
121
|
+
$case: 'allExtensionNumbersResponse',
|
|
122
|
+
allExtensionNumbersResponse: {
|
|
123
|
+
baseTypeName: request.messageRequest.allExtensionNumbersOfType,
|
|
124
|
+
extensionNumber: this.service.allExtensionNumbersOfType(request.messageRequest.allExtensionNumbersOfType),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
this.logger.error('NotImplementedException', { request });
|
|
129
|
+
throw new common_1.NotImplementedException(request.messageRequest);
|
|
130
|
+
}
|
|
131
|
+
createServerReflectionResponse(request, message) {
|
|
132
|
+
return {
|
|
133
|
+
validHost: request.host,
|
|
134
|
+
originalRequest: request,
|
|
135
|
+
messageResponse: message,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
resolveReflection(response$) {
|
|
139
|
+
return (message) => {
|
|
140
|
+
try {
|
|
141
|
+
response$.next(this.makeResponse(message));
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
if (error instanceof Error) {
|
|
145
|
+
this.logger.error(error);
|
|
146
|
+
}
|
|
147
|
+
const response = this.createServerReflectionResponse(message, {
|
|
148
|
+
$case: 'errorResponse',
|
|
149
|
+
errorResponse: {
|
|
150
|
+
errorCode: grpc.status.UNKNOWN,
|
|
151
|
+
errorMessage: `Failed to process gRPC reflection request: ${error}`,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
response$.next(response);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
reflectionIsDisabled(response$) {
|
|
159
|
+
return (message) => {
|
|
160
|
+
const response = this.createServerReflectionResponse(message, {
|
|
161
|
+
$case: 'errorResponse',
|
|
162
|
+
errorResponse: {
|
|
163
|
+
errorCode: grpc.status.UNAVAILABLE,
|
|
164
|
+
errorMessage: `Reflection is disabled by config`,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
return response$.next(response);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
exports.BaseV1GrpcReflectionController = BaseV1GrpcReflectionController;
|
|
172
|
+
exports.BaseV1GrpcReflectionController = BaseV1GrpcReflectionController = __decorate([
|
|
173
|
+
__param(1, (0, core_1.InjectLogger)(reflection_service_1.ReflectionService)),
|
|
174
|
+
__param(2, (0, common_1.Inject)(reflection_service_1.ReflectionService)),
|
|
175
|
+
__metadata("design:paramtypes", [grpc_config_1.GRPCConfig, Object, reflection_service_1.ReflectionService])
|
|
176
|
+
], BaseV1GrpcReflectionController);
|
|
177
|
+
//# sourceMappingURL=v1.base.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1.base.controller.js","sourceRoot":"","sources":["../../../src/controllers/reflection/v1.base.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,2CAAiE;AAMjE,qCAA0C;AAG1C,+BAA+B;AAE/B,mDAA+C;AAC/C,iEAA6D;AAE7D;;;;;;;;GAQG;AACH,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAItB;IACiC;IACN;IAH9C,YACmB,MAAkB,EACe,MAAe,EACrB,OAA0B;QAFrD,WAAM,GAAN,MAAM,CAAY;QACe,WAAM,GAAN,MAAM,CAAS;QACrB,YAAO,GAAP,OAAO,CAAmB;IACrE,CAAC;IAEJ;;;;;;OAMG;IACH,oBAAoB,CAClB,QAA6C;QAE7C,MAAM,SAAS,GAAG,IAAI,cAAO,EAA4B,CAAC;QAE1D,QAAQ,CAAC,SAAS,CAAC;YACjB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;gBAC1B,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC;gBACnC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC;YACxC,QAAQ,EAAE,GAAS,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE;SAC3C,CAAC,CAAC;QAEH,OAAO,SAAS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AAC,MAAM,CAAC,OAAO;wBAC9B,YAAY,EAAE,8CAA8C,KAAK,EAAE;qBACpE;iBACF,CAAC,CAAC;gBAEH,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC1B;QACH,CAAC,CAAC;IACJ,CAAC;IAEO,oBAAoB,CAC1B,SAA4C;QAE5C,OAAO,CAAC,OAAgC,EAAQ,EAAE;YAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,8BAA8B,CAAC,OAAO,EAAE;gBAC5D,KAAK,EAAE,eAAe;gBACtB,aAAa,EAAE;oBACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;oBAClC,YAAY,EAAE,kCAAkC;iBACjD;aACF,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AApJY,wEAA8B;yCAA9B,8BAA8B;IAKtC,WAAA,IAAA,mBAAY,EAAC,sCAAiB,CAAC,CAAA;IAC/B,WAAA,IAAA,eAAM,EAAC,sCAAiB,CAAC,CAAA;qCAFD,wBAAU,UAEkB,sCAAiB;GAN7D,8BAA8B,CAoJ1C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ServerReflectionGrpcController, ServerReflectionRequest, ServerReflectionResponse } from '@rsdk/builtin-contract/dist/grpc.reflection.v1';
|
|
2
|
+
import type { Observable } from 'rxjs';
|
|
3
|
+
import { BaseV1GrpcReflectionController } from './v1.base.controller';
|
|
4
|
+
/** Implements the 'v1' (final) version of the gRPC Reflection API spec
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://github.com/grpc/grpc/blob/master/doc/server-reflection.md}
|
|
7
|
+
*/
|
|
8
|
+
export declare class ReflectionV1Controller extends BaseV1GrpcReflectionController implements ServerReflectionGrpcController {
|
|
9
|
+
serverReflectionInfo(request: Observable<ServerReflectionRequest>): Observable<ServerReflectionResponse>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ReflectionV1Controller = void 0;
|
|
10
|
+
const grpc_reflection_v1_1 = require("@rsdk/builtin-contract/dist/grpc.reflection.v1");
|
|
11
|
+
const v1_base_controller_1 = require("./v1.base.controller");
|
|
12
|
+
/** Implements the 'v1' (final) version of the gRPC Reflection API spec
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://github.com/grpc/grpc/blob/master/doc/server-reflection.md}
|
|
15
|
+
*/
|
|
16
|
+
let ReflectionV1Controller = class ReflectionV1Controller extends v1_base_controller_1.BaseV1GrpcReflectionController {
|
|
17
|
+
serverReflectionInfo(request) {
|
|
18
|
+
return super.serverReflectionInfo(request);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.ReflectionV1Controller = ReflectionV1Controller;
|
|
22
|
+
exports.ReflectionV1Controller = ReflectionV1Controller = __decorate([
|
|
23
|
+
(0, grpc_reflection_v1_1.ServerReflectionGrpcMethods)()
|
|
24
|
+
], ReflectionV1Controller);
|
|
25
|
+
//# sourceMappingURL=v1.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1.controller.js","sourceRoot":"","sources":["../../../src/controllers/reflection/v1.controller.ts"],"names":[],"mappings":";;;;;;;;;AAKA,uFAA6F;AAG7F,6DAAsE;AAEtE;;;GAGG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBACX,SAAQ,mDAA8B;IAG7B,oBAAoB,CAC3B,OAA4C;QAE5C,OAAO,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AATY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,gDAA2B,GAAE;GACjB,sBAAsB,CASlC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ServerReflectionGrpcController, ServerReflectionRequest, ServerReflectionResponse } from '@rsdk/builtin-contract/dist/grpc.reflection.v1alpha';
|
|
2
|
+
import type { Observable } from 'rxjs';
|
|
3
|
+
import { BaseV1GrpcReflectionController } from './v1.base.controller';
|
|
4
|
+
/** Implements the 'v1alpha' version of the gRPC Reflection API spec
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://github.com/grpc/grpc/blob/master/doc/server-reflection.md}
|
|
7
|
+
*/
|
|
8
|
+
export declare class ReflectionV1alphaController extends BaseV1GrpcReflectionController implements ServerReflectionGrpcController {
|
|
9
|
+
serverReflectionInfo(request: Observable<ServerReflectionRequest>): Observable<ServerReflectionResponse>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ReflectionV1alphaController = void 0;
|
|
10
|
+
const grpc_reflection_v1_1 = require("@rsdk/builtin-contract/dist/grpc.reflection.v1");
|
|
11
|
+
const v1_base_controller_1 = require("./v1.base.controller");
|
|
12
|
+
/** Implements the 'v1alpha' version of the gRPC Reflection API spec
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://github.com/grpc/grpc/blob/master/doc/server-reflection.md}
|
|
15
|
+
*/
|
|
16
|
+
let ReflectionV1alphaController = class ReflectionV1alphaController extends v1_base_controller_1.BaseV1GrpcReflectionController {
|
|
17
|
+
serverReflectionInfo(request) {
|
|
18
|
+
return super.serverReflectionInfo(request);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.ReflectionV1alphaController = ReflectionV1alphaController;
|
|
22
|
+
exports.ReflectionV1alphaController = ReflectionV1alphaController = __decorate([
|
|
23
|
+
(0, grpc_reflection_v1_1.ServerReflectionGrpcMethods)()
|
|
24
|
+
], ReflectionV1alphaController);
|
|
25
|
+
//# sourceMappingURL=v1alpha.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1alpha.controller.js","sourceRoot":"","sources":["../../../src/controllers/reflection/v1alpha.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uFAA6F;AAQ7F,6DAAsE;AAEtE;;;GAGG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BACX,SAAQ,mDAA8B;IAG7B,oBAAoB,CAC3B,OAA4C;QAE5C,OAAO,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AATY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,gDAA2B,GAAE;GACjB,2BAA2B,CASvC"}
|
package/dist/grpc.config.d.ts
CHANGED
package/dist/grpc.config.js
CHANGED
|
@@ -18,6 +18,7 @@ let GRPCConfig = class GRPCConfig extends core_1.Config {
|
|
|
18
18
|
address;
|
|
19
19
|
maxRecv;
|
|
20
20
|
maxSend;
|
|
21
|
+
reflection;
|
|
21
22
|
};
|
|
22
23
|
exports.GRPCConfig = GRPCConfig;
|
|
23
24
|
__decorate([
|
|
@@ -44,6 +45,13 @@ __decorate([
|
|
|
44
45
|
}),
|
|
45
46
|
__metadata("design:type", Number)
|
|
46
47
|
], GRPCConfig.prototype, "maxSend", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, core_1.Property)('GRPC_REFLECTION', new core_1.BoolParser(), {
|
|
50
|
+
defaultValue: false,
|
|
51
|
+
description: 'Enable reflection',
|
|
52
|
+
}),
|
|
53
|
+
__metadata("design:type", Boolean)
|
|
54
|
+
], GRPCConfig.prototype, "reflection", void 0);
|
|
47
55
|
exports.GRPCConfig = GRPCConfig = __decorate([
|
|
48
56
|
(0, core_1.ConfigSection)({
|
|
49
57
|
tags: [core_1.ConfigTag.infrastructure, core_1.ConfigTag.transport, core_1.ConfigTag.grpcServer],
|
package/dist/grpc.config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.config.js","sourceRoot":"","sources":["../src/grpc.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAG2C;AAC3C,yCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"grpc.config.js","sourceRoot":"","sources":["../src/grpc.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAG2C;AAC3C,yCAAoC;AACpC,qCAOoB;AACpB,mDAAsD;AAK/C,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,aAAM;IAQ3B,OAAO,CAAU;IAMjB,OAAO,CAAU;IAMjB,OAAO,CAAU;IAMjB,UAAU,CAAW;CAC/B,CAAA;AA3BY,gCAAU;AAQZ;IAPR,IAAA,eAAQ,EAAC,cAAc,EAAE,IAAI,+BAAiB,EAAE,EAAE;QACjD,YAAY,EAAE,eAAe;QAC7B,WAAW,EAAE,IAAA,aAAI,EAAA;;;KAGhB;KACF,CAAC;;2CACwB;AAMjB;IAJR,IAAA,eAAQ,EAAC,iCAAiC,EAAE,IAAI,gBAAS,EAAE,EAAE;QAC5D,YAAY,EAAE,8CAAkC;QAChD,WAAW,EAAE,iCAAiC;KAC/C,CAAC;;2CACwB;AAMjB;IAJR,IAAA,eAAQ,EAAC,8BAA8B,EAAE,IAAI,gBAAS,EAAE,EAAE;QACzD,YAAY,EAAE,2CAA+B;QAC7C,WAAW,EAAE,8BAA8B;KAC5C,CAAC;;2CACwB;AAMjB;IAJR,IAAA,eAAQ,EAAC,iBAAiB,EAAE,IAAI,iBAAU,EAAE,EAAE;QAC7C,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,mBAAmB;KACjC,CAAC;;8CAC4B;qBA1BnB,UAAU;IAHtB,IAAA,oBAAa,EAAC;QACb,IAAI,EAAE,CAAC,gBAAS,CAAC,cAAc,EAAE,gBAAS,CAAC,SAAS,EAAE,gBAAS,CAAC,UAAU,CAAC;KAC5E,CAAC;GACW,UAAU,CA2BtB"}
|
package/dist/grpc.transport.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Controller } from '@nestjs/common/interfaces';
|
|
2
2
|
import type { MicroserviceOptions } from '@nestjs/microservices';
|
|
3
3
|
import type { Constructor } from '@rsdk/common';
|
|
4
|
-
import type { ConfigContext, IErrorsFormatter, IErrorsSender, IErrorsTransformer, IMicroserviceTransport } from '@rsdk/core';
|
|
4
|
+
import type { ConfigContext, IErrorsFormatter, IErrorsSender, IErrorsTransformer, IMicroserviceTransport, NestModuleDefinitions } from '@rsdk/core';
|
|
5
5
|
import type { Package } from '@rsdk/grpc.loader';
|
|
6
6
|
export declare class GrpcTransport implements IMicroserviceTransport {
|
|
7
|
+
private readonly systemPackages;
|
|
7
8
|
private readonly logger;
|
|
8
9
|
private readonly packages;
|
|
9
10
|
private address?;
|
|
@@ -23,6 +24,17 @@ export declare class GrpcTransport implements IMicroserviceTransport {
|
|
|
23
24
|
*/
|
|
24
25
|
init(configContext: ConfigContext): void;
|
|
25
26
|
createMicroserviceOptions(): MicroserviceOptions;
|
|
27
|
+
modules(): NestModuleDefinitions;
|
|
26
28
|
onStart(): void;
|
|
27
29
|
private checkIsInitialized;
|
|
30
|
+
/**
|
|
31
|
+
* Checks the value must be defined and not null
|
|
32
|
+
* @param value any value
|
|
33
|
+
*/
|
|
34
|
+
private assertIsDefined;
|
|
35
|
+
/**
|
|
36
|
+
* Merge user packages with system packages
|
|
37
|
+
* @returns array of unique packages
|
|
38
|
+
*/
|
|
39
|
+
private getUniquePackages;
|
|
28
40
|
}
|
package/dist/grpc.transport.js
CHANGED
|
@@ -6,14 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GrpcTransport = void 0;
|
|
7
7
|
const grpc_health_v1_1 = __importDefault(require("@rsdk/builtin-contract/dist/grpc.health.v1"));
|
|
8
8
|
const grpc_metrics_v1_1 = __importDefault(require("@rsdk/builtin-contract/dist/grpc.metrics.v1"));
|
|
9
|
+
const grpc_reflection_v1_1 = __importDefault(require("@rsdk/builtin-contract/dist/grpc.reflection.v1"));
|
|
10
|
+
const grpc_reflection_v1alpha_1 = __importDefault(require("@rsdk/builtin-contract/dist/grpc.reflection.v1alpha"));
|
|
9
11
|
const core_1 = require("@rsdk/core");
|
|
10
12
|
const grpc_loader_1 = require("@rsdk/grpc.loader");
|
|
11
13
|
const logging_1 = require("@rsdk/logging");
|
|
12
14
|
const controllers_1 = require("./controllers");
|
|
13
15
|
const grpc_config_1 = require("./grpc.config");
|
|
16
|
+
const grpc_utils_1 = require("./grpc.utils");
|
|
14
17
|
const grpc_errors_formatter_1 = require("./grpc-errors.formatter");
|
|
15
18
|
const grpc_errors_sender_1 = require("./grpc-errors.sender");
|
|
19
|
+
const reflection_module_1 = require("./reflection.module");
|
|
16
20
|
class GrpcTransport {
|
|
21
|
+
systemPackages = [
|
|
22
|
+
grpc_health_v1_1.default,
|
|
23
|
+
grpc_metrics_v1_1.default,
|
|
24
|
+
grpc_reflection_v1_1.default,
|
|
25
|
+
grpc_reflection_v1alpha_1.default,
|
|
26
|
+
];
|
|
17
27
|
logger = logging_1.LoggerFactory.create(GrpcTransport);
|
|
18
28
|
packages;
|
|
19
29
|
address;
|
|
@@ -53,26 +63,25 @@ class GrpcTransport {
|
|
|
53
63
|
this.isInitialized = true;
|
|
54
64
|
}
|
|
55
65
|
createMicroserviceOptions() {
|
|
56
|
-
this.
|
|
57
|
-
const packages = [...this.packages];
|
|
58
|
-
if (!packages.some((x) => x.name === grpc_health_v1_1.default.name)) {
|
|
59
|
-
packages.push(grpc_health_v1_1.default);
|
|
60
|
-
}
|
|
61
|
-
if (!packages.some((x) => x.name === grpc_metrics_v1_1.default.name)) {
|
|
62
|
-
packages.push(grpc_metrics_v1_1.default);
|
|
63
|
-
}
|
|
66
|
+
const packages = this.getUniquePackages();
|
|
64
67
|
for (const pkg of packages) {
|
|
65
68
|
for (const service of Object.keys(pkg.definitions['grpc-js'])) {
|
|
66
69
|
this.logger.info(`Expose grpc-service: ${pkg.name}.${service}`);
|
|
67
70
|
}
|
|
68
71
|
}
|
|
72
|
+
this.checkIsInitialized();
|
|
73
|
+
this.assertIsDefined(this.address);
|
|
74
|
+
this.assertIsDefined(this.maxRecv);
|
|
75
|
+
this.assertIsDefined(this.maxSend);
|
|
69
76
|
return (0, grpc_loader_1.createGrpcOptions)(packages, {
|
|
70
|
-
// FIXME добавить проверку
|
|
71
77
|
address: this.address,
|
|
72
78
|
maxRecv: this.maxRecv,
|
|
73
79
|
maxSend: this.maxSend,
|
|
74
80
|
});
|
|
75
81
|
}
|
|
82
|
+
modules() {
|
|
83
|
+
return [reflection_module_1.ReflectionModule.forRoot(this.packages)];
|
|
84
|
+
}
|
|
76
85
|
onStart() {
|
|
77
86
|
this.checkIsInitialized();
|
|
78
87
|
this.logger.info(`Grpc server is listening on port ${this.address}`);
|
|
@@ -82,6 +91,28 @@ class GrpcTransport {
|
|
|
82
91
|
throw new core_1.SequenceException('You should call init() method first!');
|
|
83
92
|
}
|
|
84
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Checks the value must be defined and not null
|
|
96
|
+
* @param value any value
|
|
97
|
+
*/
|
|
98
|
+
assertIsDefined(value) {
|
|
99
|
+
if (value === undefined || value === null) {
|
|
100
|
+
throw new Error(`${value} is not defined`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Merge user packages with system packages
|
|
105
|
+
* @returns array of unique packages
|
|
106
|
+
*/
|
|
107
|
+
getUniquePackages() {
|
|
108
|
+
const packages = [...this.packages];
|
|
109
|
+
for (const pkg of this.systemPackages) {
|
|
110
|
+
if ((0, grpc_utils_1.isPackageNotIncluded)(packages, pkg)) {
|
|
111
|
+
packages.push(pkg);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return packages;
|
|
115
|
+
}
|
|
85
116
|
}
|
|
86
117
|
exports.GrpcTransport = GrpcTransport;
|
|
87
118
|
//# sourceMappingURL=grpc.transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.transport.js","sourceRoot":"","sources":["../src/grpc.transport.ts"],"names":[],"mappings":";;;;;;AAEA,gGAA2E;AAC3E,kGAA6E;
|
|
1
|
+
{"version":3,"file":"grpc.transport.js","sourceRoot":"","sources":["../src/grpc.transport.ts"],"names":[],"mappings":";;;;;;AAEA,gGAA2E;AAC3E,kGAA6E;AAC7E,wGAAqF;AACrF,kHAA+F;AAU/F,qCAA+C;AAE/C,mDAAsD;AACtD,2CAA8C;AAE9C,+CAAoE;AACpE,+CAA2C;AAC3C,6CAAoD;AACpD,mEAA8D;AAC9D,6DAAwD;AACxD,2DAAuD;AAEvD,MAAa,aAAa;IACP,cAAc,GAAc;QAC3C,wBAAiB;QACjB,yBAAkB;QAClB,4BAAuB;QACvB,iCAA4B;KAC7B,CAAC;IAEe,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7C,QAAQ,CAAY;IAE7B,OAAO,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|
+
/**
|
|
2
|
+
* Checks whether a pkg is in the array
|
|
3
|
+
* @param packages array of packages
|
|
4
|
+
* @param pkg package you are looking for
|
|
5
|
+
* @returns true if pkg exists in packages
|
|
6
|
+
*/
|
|
7
|
+
export declare const isPackageNotIncluded: <T extends {
|
|
8
|
+
name: string;
|
|
9
|
+
}>(packages: T[], pkg: T) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPackageNotIncluded = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Match packages name
|
|
6
|
+
* @param pkg
|
|
7
|
+
* @returns true if names is equal
|
|
8
|
+
*/
|
|
9
|
+
const isEqualPackageName = (pkg) => (x) => x.name === pkg.name;
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether a pkg is in the array
|
|
12
|
+
* @param packages array of packages
|
|
13
|
+
* @param pkg package you are looking for
|
|
14
|
+
* @returns true if pkg exists in packages
|
|
15
|
+
*/
|
|
16
|
+
const isPackageNotIncluded = (packages, pkg) => !packages.some(isEqualPackageName(pkg));
|
|
17
|
+
exports.isPackageNotIncluded = isPackageNotIncluded;
|
|
18
|
+
//# sourceMappingURL=grpc.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc.utils.js","sourceRoot":"","sources":["../src/grpc.utils.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAM,kBAAkB,GACtB,CAA6B,GAAM,EAAE,EAAE,CACvC,CAAC,CAAI,EAAW,EAAE,CAChB,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC;AAExB;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAClC,QAAa,EACb,GAAM,EACG,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;AAHzC,QAAA,oBAAoB,wBAGqB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var ReflectionModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ReflectionModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const controllers_1 = require("./controllers");
|
|
13
|
+
const reflection_service_1 = require("./reflection.service");
|
|
14
|
+
let ReflectionModule = ReflectionModule_1 = class ReflectionModule {
|
|
15
|
+
static forRoot(packages) {
|
|
16
|
+
return {
|
|
17
|
+
module: ReflectionModule_1,
|
|
18
|
+
controllers: [controllers_1.ReflectionV1alphaController, controllers_1.ReflectionV1Controller],
|
|
19
|
+
providers: [
|
|
20
|
+
reflection_service_1.ReflectionService,
|
|
21
|
+
{
|
|
22
|
+
provide: 'GRPC_PACKAGES',
|
|
23
|
+
useValue: packages,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.ReflectionModule = ReflectionModule;
|
|
30
|
+
exports.ReflectionModule = ReflectionModule = ReflectionModule_1 = __decorate([
|
|
31
|
+
(0, common_1.Module)({})
|
|
32
|
+
], ReflectionModule);
|
|
33
|
+
//# sourceMappingURL=reflection.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection.module.js","sourceRoot":"","sources":["../src/reflection.module.ts"],"names":[],"mappings":";;;;;;;;;;AACA,2CAAwC;AAGxC,+CAGuB;AACvB,6DAAyD;AAGlD,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,QAAmB;QAChC,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,WAAW,EAAE,CAAC,yCAA2B,EAAE,oCAAsB,CAAC;YAClE,SAAS,EAAE;gBACT,sCAAiB;gBACjB;oBACE,OAAO,EAAE,eAAe;oBACxB,QAAQ,EAAE,QAAQ;iBACnB;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAdY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAc5B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { OnModuleInit } from '@nestjs/common';
|
|
3
|
+
import type { Package } from '@rsdk/grpc.loader';
|
|
4
|
+
export declare class ReflectionService implements OnModuleInit {
|
|
5
|
+
private readonly packages;
|
|
6
|
+
private readonly services;
|
|
7
|
+
private readonly files;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
constructor(packages: Package[]);
|
|
10
|
+
onModuleInit(): void;
|
|
11
|
+
/**
|
|
12
|
+
* List the full names of registered gRPC services
|
|
13
|
+
*
|
|
14
|
+
* note: the spec is unclear as to what the 'listServices' param can be; most
|
|
15
|
+
* clients seem to only pass '*' but unsure if this should behave like a
|
|
16
|
+
* filter. Until we know how this should behave with different inputs this
|
|
17
|
+
* just always returns *all* services.
|
|
18
|
+
*
|
|
19
|
+
* @returns full-qualified service names (eg. 'sample.SampleService')
|
|
20
|
+
*/
|
|
21
|
+
listServices(): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Find the proto file(s) that declares the given fully-qualified symbol name
|
|
24
|
+
*
|
|
25
|
+
* @param symbol fully-qualified name of the symbol to lookup
|
|
26
|
+
* (e.g. package.service[.method] or package.type)
|
|
27
|
+
*
|
|
28
|
+
* @returns descriptors of the file which contains this symbol and its imports
|
|
29
|
+
*/
|
|
30
|
+
fileBySymbol(symbol: string): Buffer;
|
|
31
|
+
/**
|
|
32
|
+
* Find a proto file by the file name
|
|
33
|
+
* @returns descriptors of the file which contains this symbol and its imports
|
|
34
|
+
*/
|
|
35
|
+
fileByName(filename: string): Buffer;
|
|
36
|
+
/**
|
|
37
|
+
* Find a proto file containing an extension to a message type
|
|
38
|
+
* @returns descriptors of the file which contains this symbol and its imports
|
|
39
|
+
*/
|
|
40
|
+
fileContainingExtension(containingType: string, extensionNumber: number): Buffer;
|
|
41
|
+
allExtensionNumbersOfType(symbol: string): number[];
|
|
42
|
+
private findSymbol;
|
|
43
|
+
}
|