@opra/nestjs 1.9.3 → 1.9.4
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/cjs/helpers/base-opra-nest-factory.js +4 -4
- package/cjs/helpers/rpc-controller-factory.service.js +12 -12
- package/esm/helpers/base-opra-nest-factory.js +1 -1
- package/esm/helpers/rpc-controller-factory.service.js +5 -5
- package/package.json +5 -5
- package/types/helpers/rpc-controller-factory.service.d.ts +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseOpraNestFactory = void 0;
|
|
4
|
-
const
|
|
4
|
+
const constants_js_1 = require("@nestjs/common/constants.js");
|
|
5
5
|
class BaseOpraNestFactory {
|
|
6
6
|
static copyDecoratorMetadata(target, ...source) {
|
|
7
7
|
for (const parent of source) {
|
|
@@ -14,9 +14,9 @@ class BaseOpraNestFactory {
|
|
|
14
14
|
Reflect.defineMetadata(key, metadata, target);
|
|
15
15
|
continue;
|
|
16
16
|
}
|
|
17
|
-
if (key ===
|
|
18
|
-
key ===
|
|
19
|
-
key ===
|
|
17
|
+
if (key === constants_js_1.GUARDS_METADATA ||
|
|
18
|
+
key === constants_js_1.INTERCEPTORS_METADATA ||
|
|
19
|
+
key === constants_js_1.EXCEPTION_FILTERS_METADATA) {
|
|
20
20
|
const m1 = Reflect.getMetadata(key, target) || [];
|
|
21
21
|
const metadata = [...m1];
|
|
22
22
|
const m2 = Reflect.getOwnMetadata(key, parent) || [];
|
|
@@ -5,11 +5,11 @@ exports.RpcControllerFactory = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const core_1 = require("@nestjs/core");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const external_context_creator_js_1 = require("@nestjs/core/helpers/external-context-creator.js");
|
|
9
|
+
const injector_js_1 = require("@nestjs/core/injector/injector.js");
|
|
10
|
+
const index_js_1 = require("@nestjs/core/injector/internal-core-module/index.js");
|
|
11
|
+
const request_constants_js_1 = require("@nestjs/core/router/request/request-constants.js");
|
|
12
|
+
const constants_js_1 = require("@nestjs/microservices/constants.js");
|
|
13
13
|
const common_2 = require("@opra/common");
|
|
14
14
|
const base_opra_nest_factory_js_1 = require("./base-opra-nest-factory.js");
|
|
15
15
|
const rpc_params_factory_js_1 = require("./rpc-params.factory.js");
|
|
@@ -19,7 +19,7 @@ let RpcControllerFactory = RpcControllerFactory_1 = class RpcControllerFactory e
|
|
|
19
19
|
this.modulesContainer = modulesContainer;
|
|
20
20
|
this.externalContextCreator = externalContextCreator;
|
|
21
21
|
this.paramsFactory = new rpc_params_factory_js_1.RpcParamsFactory();
|
|
22
|
-
this.injector = new
|
|
22
|
+
this.injector = new injector_js_1.Injector();
|
|
23
23
|
}
|
|
24
24
|
wrapControllers() {
|
|
25
25
|
const out = [];
|
|
@@ -41,7 +41,7 @@ let RpcControllerFactory = RpcControllerFactory_1 = class RpcControllerFactory e
|
|
|
41
41
|
for (const operationName of Object.keys(metadata.operations)) {
|
|
42
42
|
// const orgFn: Function = sourceClass.prototype[operationName];
|
|
43
43
|
newClass.prototype[operationName] = this._createContextCallback(instance, wrapper, module, operationName, isRequestScoped, 'rpc');
|
|
44
|
-
Reflect.defineMetadata(
|
|
44
|
+
Reflect.defineMetadata(constants_js_1.PARAM_ARGS_METADATA, [core_1.REQUEST], instance.constructor, operationName);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -52,7 +52,7 @@ let RpcControllerFactory = RpcControllerFactory_1 = class RpcControllerFactory e
|
|
|
52
52
|
if (isRequestScoped) {
|
|
53
53
|
return async (opraContext) => {
|
|
54
54
|
const contextId = (0, core_1.createContextId)();
|
|
55
|
-
Object.defineProperty(opraContext,
|
|
55
|
+
Object.defineProperty(opraContext, request_constants_js_1.REQUEST_CONTEXT_ID, {
|
|
56
56
|
value: contextId,
|
|
57
57
|
enumerable: false,
|
|
58
58
|
configurable: false,
|
|
@@ -60,18 +60,18 @@ let RpcControllerFactory = RpcControllerFactory_1 = class RpcControllerFactory e
|
|
|
60
60
|
});
|
|
61
61
|
this.registerContextProvider(opraContext, contextId);
|
|
62
62
|
const contextInstance = await this.injector.loadPerContext(instance, moduleRef, moduleRef.providers, contextId);
|
|
63
|
-
const contextCallback = this.externalContextCreator.create(contextInstance, contextInstance[methodName], methodName,
|
|
63
|
+
const contextCallback = this.externalContextCreator.create(contextInstance, contextInstance[methodName], methodName, constants_js_1.PARAM_ARGS_METADATA, paramsFactory, contextId, wrapper.id, options, opraContext.protocol);
|
|
64
64
|
return contextCallback(opraContext);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
return this.externalContextCreator.create(instance, instance[methodName], methodName,
|
|
67
|
+
return this.externalContextCreator.create(instance, instance[methodName], methodName, constants_js_1.PARAM_ARGS_METADATA, paramsFactory, undefined, undefined, options, contextType);
|
|
68
68
|
}
|
|
69
69
|
registerContextProvider(request, contextId) {
|
|
70
70
|
if (!this._coreModuleRef) {
|
|
71
71
|
const coreModuleArray = [...this.modulesContainer.entries()]
|
|
72
72
|
.filter(
|
|
73
73
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
|
-
([_, { metatype }]) => metatype && metatype.name ===
|
|
74
|
+
([_, { metatype }]) => metatype && metatype.name === index_js_1.InternalCoreModule.name)
|
|
75
75
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
76
|
.map(([_, value]) => value);
|
|
77
77
|
this._coreModuleRef = coreModuleArray[0];
|
|
@@ -119,5 +119,5 @@ exports.RpcControllerFactory = RpcControllerFactory = RpcControllerFactory_1 = t
|
|
|
119
119
|
tslib_1.__param(0, (0, common_1.Inject)()),
|
|
120
120
|
tslib_1.__param(1, (0, common_1.Inject)()),
|
|
121
121
|
tslib_1.__metadata("design:paramtypes", [core_1.ModulesContainer,
|
|
122
|
-
|
|
122
|
+
external_context_creator_js_1.ExternalContextCreator])
|
|
123
123
|
], RpcControllerFactory);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EXCEPTION_FILTERS_METADATA, GUARDS_METADATA, INTERCEPTORS_METADATA, } from '@nestjs/common/constants';
|
|
1
|
+
import { EXCEPTION_FILTERS_METADATA, GUARDS_METADATA, INTERCEPTORS_METADATA, } from '@nestjs/common/constants.js';
|
|
2
2
|
export class BaseOpraNestFactory {
|
|
3
3
|
static copyDecoratorMetadata(target, ...source) {
|
|
4
4
|
for (const parent of source) {
|
|
@@ -2,11 +2,11 @@ var RpcControllerFactory_1;
|
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
3
|
import { Controller, Inject, Injectable, } from '@nestjs/common';
|
|
4
4
|
import { createContextId, ModulesContainer, REQUEST } from '@nestjs/core';
|
|
5
|
-
import { ExternalContextCreator, } from '@nestjs/core/helpers/external-context-creator';
|
|
6
|
-
import { Injector } from '@nestjs/core/injector/injector';
|
|
7
|
-
import { InternalCoreModule } from '@nestjs/core/injector/internal-core-module';
|
|
8
|
-
import { REQUEST_CONTEXT_ID } from '@nestjs/core/router/request/request-constants';
|
|
9
|
-
import { PARAM_ARGS_METADATA } from '@nestjs/microservices/constants';
|
|
5
|
+
import { ExternalContextCreator, } from '@nestjs/core/helpers/external-context-creator.js';
|
|
6
|
+
import { Injector } from '@nestjs/core/injector/injector.js';
|
|
7
|
+
import { InternalCoreModule } from '@nestjs/core/injector/internal-core-module/index.js';
|
|
8
|
+
import { REQUEST_CONTEXT_ID } from '@nestjs/core/router/request/request-constants.js';
|
|
9
|
+
import { PARAM_ARGS_METADATA } from '@nestjs/microservices/constants.js';
|
|
10
10
|
import { RPC_CONTROLLER_METADATA } from '@opra/common';
|
|
11
11
|
import { BaseOpraNestFactory } from './base-opra-nest-factory.js';
|
|
12
12
|
import { RpcParamsFactory } from './rpc-params.factory.js';
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"description": "Opra NestJS module",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@jsopen/objects": "^1.5.0",
|
|
9
|
-
"@opra/common": "^1.9.
|
|
10
|
-
"@opra/core": "^1.9.
|
|
9
|
+
"@opra/common": "^1.9.4",
|
|
10
|
+
"@opra/core": "^1.9.4",
|
|
11
11
|
"fast-tokenizer": "^1.7.0",
|
|
12
12
|
"putil-promisify": "^1.10.1",
|
|
13
13
|
"reflect-metadata": "^0.2.2",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"optionalDependencies": {
|
|
21
21
|
"@nestjs/microservices": "^10.0.0 || ^11.0.0",
|
|
22
|
-
"@opra/http": "^1.9.
|
|
23
|
-
"@opra/kafka": "^1.9.
|
|
22
|
+
"@opra/http": "^1.9.4",
|
|
23
|
+
"@opra/kafka": "^1.9.4"
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"exports": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Type } from '@nestjs/common';
|
|
2
2
|
import { ModulesContainer } from '@nestjs/core';
|
|
3
|
-
import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator';
|
|
4
|
-
import type { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
3
|
+
import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator.js';
|
|
4
|
+
import type { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js';
|
|
5
5
|
import type { Module } from '@nestjs/core/injector/module.js';
|
|
6
6
|
import { BaseOpraNestFactory } from './base-opra-nest-factory.js';
|
|
7
7
|
export declare class RpcControllerFactory extends BaseOpraNestFactory {
|