@opra/nestjs 0.33.13 → 1.0.0-alpha.10
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 +1 -0
- package/cjs/augmentation/http-controller.augmentation.js +16 -0
- package/cjs/constants.js +2 -7
- package/cjs/decorators/public.decorator.js +7 -0
- package/cjs/index.js +4 -5
- package/cjs/interfaces/opra-module-options.interface.js +16 -1
- package/cjs/opra-http-core.module.js +60 -0
- package/cjs/opra-http.module.js +24 -0
- package/cjs/opra-nestjs-adapter.js +160 -0
- package/cjs/services/opra-exception-filter.js +14 -13
- package/cjs/services/opra-middleware.js +24 -0
- package/esm/augmentation/http-controller.augmentation.js +16 -0
- package/esm/constants.js +1 -6
- package/esm/decorators/public.decorator.js +3 -0
- package/esm/index.js +4 -5
- package/esm/interfaces/opra-module-options.interface.js +17 -1
- package/esm/opra-http-core.module.js +57 -0
- package/esm/opra-http.module.js +21 -0
- package/esm/opra-nestjs-adapter.js +156 -0
- package/esm/services/opra-exception-filter.js +13 -13
- package/esm/services/opra-middleware.js +21 -0
- package/package.json +16 -13
- package/types/augmentation/http-controller.augmentation.d.ts +0 -0
- package/types/constants.d.ts +1 -6
- package/types/decorators/public.decorator.d.ts +1 -0
- package/types/index.d.ts +4 -5
- package/types/interfaces/opra-module-options.interface.d.ts +0 -25
- package/types/opra-http-core.module.d.ts +10 -0
- package/types/opra-http.module.d.ts +20 -0
- package/types/opra-nestjs-adapter.d.ts +12 -0
- package/types/services/opra-exception-filter.d.ts +6 -2
- package/types/services/opra-middleware.d.ts +5 -0
- package/cjs/augmentation/common-decorator.augmentation.js +0 -40
- package/cjs/decorators/context.decorator.js +0 -10
- package/cjs/enums/handler-paramtype.enum.js +0 -9
- package/cjs/factories/opra-api.factory.js +0 -200
- package/cjs/factories/params.factory.js +0 -23
- package/cjs/opra-core.module.js +0 -140
- package/cjs/opra-module-ref.js +0 -16
- package/cjs/opra.module.js +0 -25
- package/cjs/services/nest-explorer.js +0 -38
- package/cjs/services/opra-api-loader.js +0 -85
- package/cjs/types.js +0 -2
- package/cjs/utils/class.utils.js +0 -25
- package/cjs/utils/function.utils.js +0 -37
- package/cjs/utils/param.utils.js +0 -24
- package/esm/augmentation/common-decorator.augmentation.js +0 -38
- package/esm/decorators/context.decorator.js +0 -7
- package/esm/enums/handler-paramtype.enum.js +0 -6
- package/esm/factories/opra-api.factory.js +0 -197
- package/esm/factories/params.factory.js +0 -19
- package/esm/opra-core.module.js +0 -137
- package/esm/opra-module-ref.js +0 -12
- package/esm/opra.module.js +0 -22
- package/esm/services/nest-explorer.js +0 -34
- package/esm/services/opra-api-loader.js +0 -81
- package/esm/types.js +0 -1
- package/esm/utils/class.utils.js +0 -19
- package/esm/utils/function.utils.js +0 -33
- package/esm/utils/param.utils.js +0 -20
- package/types/augmentation/common-decorator.augmentation.d.ts +0 -1
- package/types/decorators/context.decorator.d.ts +0 -5
- package/types/enums/handler-paramtype.enum.d.ts +0 -5
- package/types/factories/opra-api.factory.d.ts +0 -15
- package/types/factories/params.factory.d.ts +0 -4
- package/types/opra-core.module.d.ts +0 -17
- package/types/opra-module-ref.d.ts +0 -11
- package/types/opra.module.d.ts +0 -6
- package/types/services/nest-explorer.d.ts +0 -8
- package/types/services/opra-api-loader.d.ts +0 -19
- package/types/types.d.ts +0 -2
- package/types/utils/class.utils.d.ts +0 -4
- package/types/utils/function.utils.d.ts +0 -1
- package/types/utils/param.utils.d.ts +0 -8
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { HandlerParamType } from '../enums/handler-paramtype.enum.js';
|
|
2
|
-
export class OpraParamsFactory {
|
|
3
|
-
exchangeKeyForValue(type, data, args) {
|
|
4
|
-
if (!args) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
args = Array.isArray(args) ? args : [];
|
|
8
|
-
switch (type) {
|
|
9
|
-
case HandlerParamType.CONTEXT:
|
|
10
|
-
return args[3];
|
|
11
|
-
case HandlerParamType.REQUEST:
|
|
12
|
-
return args[3].request;
|
|
13
|
-
case HandlerParamType.RESPONSE:
|
|
14
|
-
return args[3].response;
|
|
15
|
-
default:
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
package/esm/opra-core.module.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
var OpraCoreModule_1;
|
|
2
|
-
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
-
import * as crypto from 'crypto';
|
|
4
|
-
import { Global, Inject, Module } from '@nestjs/common';
|
|
5
|
-
import { HttpAdapterHost, ModulesContainer } from '@nestjs/core';
|
|
6
|
-
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
|
|
7
|
-
import { OPRA_INITIALIZER, OPRA_MODULE_ID, OPRA_MODULE_OPTIONS } from './constants.js';
|
|
8
|
-
import { OpraApiFactory } from './factories/opra-api.factory.js';
|
|
9
|
-
import { OpraModuleRef } from './opra-module-ref.js';
|
|
10
|
-
import { NestExplorer } from './services/nest-explorer.js';
|
|
11
|
-
import { OpraApiLoader } from './services/opra-api-loader.js';
|
|
12
|
-
let OpraCoreModule = OpraCoreModule_1 = class OpraCoreModule {
|
|
13
|
-
constructor(httpAdapterHost, modulesContainer, options, apiLoader) {
|
|
14
|
-
this.httpAdapterHost = httpAdapterHost;
|
|
15
|
-
this.modulesContainer = modulesContainer;
|
|
16
|
-
this.options = options;
|
|
17
|
-
this.apiLoader = apiLoader;
|
|
18
|
-
}
|
|
19
|
-
static forRoot(options) {
|
|
20
|
-
const providers = [
|
|
21
|
-
...(options.providers || []),
|
|
22
|
-
{
|
|
23
|
-
provide: OPRA_MODULE_OPTIONS,
|
|
24
|
-
useValue: options,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
provide: OPRA_INITIALIZER,
|
|
28
|
-
useClass: OpraApiLoader
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
provide: options.id || OpraModuleRef,
|
|
32
|
-
inject: [OPRA_INITIALIZER],
|
|
33
|
-
useFactory: (apiLoader) => {
|
|
34
|
-
return apiLoader.opraModuleRef;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
return {
|
|
39
|
-
module: OpraCoreModule_1,
|
|
40
|
-
imports: [...(options.imports || [])],
|
|
41
|
-
exports: [...(options.exports || [])],
|
|
42
|
-
providers
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
static forRootAsync(asyncOptions) {
|
|
46
|
-
return {
|
|
47
|
-
module: OpraCoreModule_1,
|
|
48
|
-
imports: [...(asyncOptions.imports || [])],
|
|
49
|
-
providers: [
|
|
50
|
-
...(asyncOptions.providers || []),
|
|
51
|
-
{
|
|
52
|
-
provide: OPRA_MODULE_ID,
|
|
53
|
-
useValue: crypto.randomUUID()
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
provide: OPRA_INITIALIZER,
|
|
57
|
-
useClass: OpraApiLoader
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
provide: asyncOptions.id || OpraModuleRef,
|
|
61
|
-
inject: [OPRA_INITIALIZER],
|
|
62
|
-
useFactory: (apiLoader) => {
|
|
63
|
-
return apiLoader.opraModuleRef;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
...this.createAsyncProviders(asyncOptions)
|
|
67
|
-
]
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
static createAsyncProviders(asyncOptions) {
|
|
71
|
-
if (asyncOptions.useExisting || asyncOptions.useFactory)
|
|
72
|
-
return [this.createAsyncOptionsProvider(asyncOptions)];
|
|
73
|
-
if (asyncOptions.useClass)
|
|
74
|
-
return [
|
|
75
|
-
this.createAsyncOptionsProvider(asyncOptions),
|
|
76
|
-
{
|
|
77
|
-
provide: asyncOptions.useClass,
|
|
78
|
-
useClass: asyncOptions.useClass
|
|
79
|
-
}
|
|
80
|
-
];
|
|
81
|
-
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
82
|
-
}
|
|
83
|
-
static createAsyncOptionsProvider(asyncOptions) {
|
|
84
|
-
if (asyncOptions.useFactory) {
|
|
85
|
-
return {
|
|
86
|
-
provide: OPRA_MODULE_OPTIONS,
|
|
87
|
-
useFactory: asyncOptions.useFactory,
|
|
88
|
-
inject: asyncOptions.inject || []
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const useClass = asyncOptions.useClass || asyncOptions.useExisting;
|
|
92
|
-
if (useClass) {
|
|
93
|
-
return {
|
|
94
|
-
provide: OPRA_MODULE_OPTIONS,
|
|
95
|
-
useFactory: (optionsFactory) => optionsFactory.createOptions(),
|
|
96
|
-
inject: [useClass]
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
100
|
-
}
|
|
101
|
-
async onModuleInit() {
|
|
102
|
-
const httpAdapter = this.httpAdapterHost?.httpAdapter;
|
|
103
|
-
if (!httpAdapter)
|
|
104
|
-
return;
|
|
105
|
-
const opraModule = (() => {
|
|
106
|
-
for (const m of this.modulesContainer.values()) {
|
|
107
|
-
for (const imp of m.imports.values()) {
|
|
108
|
-
for (const prv of imp.providers.values())
|
|
109
|
-
if (prv.instance === this) {
|
|
110
|
-
return imp;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
})();
|
|
115
|
-
if (opraModule) {
|
|
116
|
-
await this.apiLoader.initialize(opraModule);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async onModuleDestroy() {
|
|
120
|
-
await this.apiLoader.stop();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
OpraCoreModule = OpraCoreModule_1 = __decorate([
|
|
124
|
-
Module({
|
|
125
|
-
providers: [
|
|
126
|
-
OpraApiFactory,
|
|
127
|
-
MetadataScanner,
|
|
128
|
-
NestExplorer
|
|
129
|
-
]
|
|
130
|
-
}),
|
|
131
|
-
Global(),
|
|
132
|
-
__param(2, Inject(OPRA_MODULE_OPTIONS)),
|
|
133
|
-
__param(3, Inject(OPRA_INITIALIZER)),
|
|
134
|
-
__metadata("design:paramtypes", [HttpAdapterHost,
|
|
135
|
-
ModulesContainer, Object, OpraApiLoader])
|
|
136
|
-
], OpraCoreModule);
|
|
137
|
-
export { OpraCoreModule };
|
package/esm/opra-module-ref.js
DELETED
package/esm/opra.module.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var OpraModule_1;
|
|
2
|
-
import { __decorate } from "tslib";
|
|
3
|
-
import { Module } from '@nestjs/common';
|
|
4
|
-
import { OpraCoreModule } from './opra-core.module.js';
|
|
5
|
-
let OpraModule = OpraModule_1 = class OpraModule {
|
|
6
|
-
static forRoot(options) {
|
|
7
|
-
return {
|
|
8
|
-
module: OpraModule_1,
|
|
9
|
-
imports: [OpraCoreModule.forRoot(options)]
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
static forRootAsync(asyncOptions) {
|
|
13
|
-
return {
|
|
14
|
-
module: OpraModule_1,
|
|
15
|
-
imports: [OpraCoreModule.forRootAsync(asyncOptions)]
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
OpraModule = OpraModule_1 = __decorate([
|
|
20
|
-
Module({})
|
|
21
|
-
], OpraModule);
|
|
22
|
-
export { OpraModule };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { OpraSchema, RESOURCE_METADATA } from '@opra/common';
|
|
2
|
-
export class NestExplorer {
|
|
3
|
-
exploreProviders(rootModule, callback) {
|
|
4
|
-
const modules = new Set();
|
|
5
|
-
const tree = [];
|
|
6
|
-
const scanModules = (m) => {
|
|
7
|
-
if (modules.has(m))
|
|
8
|
-
return;
|
|
9
|
-
modules.add(m);
|
|
10
|
-
tree.push(m);
|
|
11
|
-
for (const mm of m.imports.values()) {
|
|
12
|
-
scanModules(mm);
|
|
13
|
-
}
|
|
14
|
-
for (const wrapper of m.providers.values()) {
|
|
15
|
-
callback(wrapper, tree);
|
|
16
|
-
if (wrapper.host)
|
|
17
|
-
scanModules(wrapper.host);
|
|
18
|
-
}
|
|
19
|
-
tree.pop();
|
|
20
|
-
};
|
|
21
|
-
scanModules(rootModule);
|
|
22
|
-
}
|
|
23
|
-
exploreResources(rootModule, callback) {
|
|
24
|
-
this.exploreProviders(rootModule, (wrapper, tree) => {
|
|
25
|
-
if (wrapper.instance
|
|
26
|
-
&& typeof wrapper.instance === 'object'
|
|
27
|
-
&& wrapper.instance.constructor
|
|
28
|
-
&& OpraSchema.isResource(Reflect.getMetadata(RESOURCE_METADATA, wrapper.instance.constructor))) {
|
|
29
|
-
callback(wrapper, tree);
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Inject, Logger } from '@nestjs/common';
|
|
3
|
-
import { ApplicationConfig, HttpAdapterHost } from '@nestjs/core';
|
|
4
|
-
import { OpraURLPath } from '@opra/common';
|
|
5
|
-
import { ExpressAdapter } from '@opra/core';
|
|
6
|
-
import { kAdapter, kOptions, OPRA_MODULE_OPTIONS } from '../constants.js';
|
|
7
|
-
import { OpraApiFactory } from '../factories/opra-api.factory.js';
|
|
8
|
-
import { OpraModuleRef } from '../opra-module-ref.js';
|
|
9
|
-
export class OpraApiLoader {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.logger = new Logger(OpraApiLoader.name, { timestamp: true });
|
|
12
|
-
this.opraModuleRef = new OpraModuleRef();
|
|
13
|
-
}
|
|
14
|
-
async initialize(rootModule) {
|
|
15
|
-
const httpAdapter = this.httpAdapterHost?.httpAdapter;
|
|
16
|
-
const globalPrefix = this.applicationConfig.getGlobalPrefix();
|
|
17
|
-
const platformName = httpAdapter.getType();
|
|
18
|
-
const moduleOptions = this.options;
|
|
19
|
-
this.opraModuleRef[kOptions] = this.options;
|
|
20
|
-
let prefixPath = new OpraURLPath((moduleOptions.useGlobalPrefix !== false ? globalPrefix : ''));
|
|
21
|
-
if (moduleOptions.basePath)
|
|
22
|
-
prefixPath = prefixPath.join(moduleOptions.basePath);
|
|
23
|
-
const name = moduleOptions.document?.info?.title || 'untitled service';
|
|
24
|
-
const options = {
|
|
25
|
-
...moduleOptions,
|
|
26
|
-
basePath: prefixPath.toString()
|
|
27
|
-
};
|
|
28
|
-
try {
|
|
29
|
-
const apiDocument = await this.opraFactory.generateService(rootModule, 'http', options.document);
|
|
30
|
-
if (!Object.keys(apiDocument.root).length) {
|
|
31
|
-
this.logger.warn(`No Sources found (${name})`);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (platformName === 'express') {
|
|
35
|
-
this.opraModuleRef[kAdapter] = await this.registerExpress(apiDocument, options);
|
|
36
|
-
// else if (platformName === 'fastify')
|
|
37
|
-
// await this.registerFastify();
|
|
38
|
-
}
|
|
39
|
-
else { // noinspection ExceptionCaughtLocallyJS
|
|
40
|
-
throw new Error(`No support for current HttpAdapter: ${platformName}`);
|
|
41
|
-
}
|
|
42
|
-
this.logger.log(`Mapped {${prefixPath.toString() || '/'}} to "${name}" service`);
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
this.logger.error(e);
|
|
46
|
-
throw e;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async stop() {
|
|
50
|
-
//
|
|
51
|
-
}
|
|
52
|
-
async registerExpress(apiDocument, moduleOptions) {
|
|
53
|
-
const httpAdapter = this.httpAdapterHost.httpAdapter;
|
|
54
|
-
/* istanbul ignore next */
|
|
55
|
-
if (!httpAdapter)
|
|
56
|
-
throw new Error('HttpAdapterHost is not initialized');
|
|
57
|
-
const app = httpAdapter.getInstance();
|
|
58
|
-
const logger = moduleOptions.logger ||
|
|
59
|
-
(process.env.NODE_ENV === 'test' ? undefined : new Logger(apiDocument.info.title));
|
|
60
|
-
return await ExpressAdapter.create(app, apiDocument, {
|
|
61
|
-
...moduleOptions,
|
|
62
|
-
logger,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
__decorate([
|
|
67
|
-
Inject(),
|
|
68
|
-
__metadata("design:type", HttpAdapterHost)
|
|
69
|
-
], OpraApiLoader.prototype, "httpAdapterHost", void 0);
|
|
70
|
-
__decorate([
|
|
71
|
-
Inject(),
|
|
72
|
-
__metadata("design:type", ApplicationConfig)
|
|
73
|
-
], OpraApiLoader.prototype, "applicationConfig", void 0);
|
|
74
|
-
__decorate([
|
|
75
|
-
Inject(),
|
|
76
|
-
__metadata("design:type", OpraApiFactory)
|
|
77
|
-
], OpraApiLoader.prototype, "opraFactory", void 0);
|
|
78
|
-
__decorate([
|
|
79
|
-
Inject(OPRA_MODULE_OPTIONS),
|
|
80
|
-
__metadata("design:type", Object)
|
|
81
|
-
], OpraApiLoader.prototype, "options", void 0);
|
package/esm/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/esm/utils/class.utils.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isFunction, isString } from '@nestjs/common/utils/shared.utils';
|
|
2
|
-
export function isConstructor(obj) {
|
|
3
|
-
return typeof obj === 'function' &&
|
|
4
|
-
!!(obj.prototype && obj.prototype.constructor);
|
|
5
|
-
}
|
|
6
|
-
export function getClassOrUndefined(typeOrFunc) {
|
|
7
|
-
return isConstructor(typeOrFunc)
|
|
8
|
-
? typeOrFunc
|
|
9
|
-
: isFunction(typeOrFunc)
|
|
10
|
-
? typeOrFunc()
|
|
11
|
-
: undefined;
|
|
12
|
-
}
|
|
13
|
-
export function getClassName(nameOrType) {
|
|
14
|
-
if (isString(nameOrType)) {
|
|
15
|
-
return nameOrType;
|
|
16
|
-
}
|
|
17
|
-
const classOrUndefined = getClassOrUndefined(nameOrType);
|
|
18
|
-
return classOrUndefined && classOrUndefined.name;
|
|
19
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { splitString, tokenize } from 'fast-tokenizer';
|
|
2
|
-
export function getNumberOfArguments(fn) {
|
|
3
|
-
const functionAsString = fn.toString();
|
|
4
|
-
const tokenizer = tokenize(functionAsString, {
|
|
5
|
-
// keepBrackets: true,
|
|
6
|
-
keepDelimiters: true,
|
|
7
|
-
keepQuotes: true,
|
|
8
|
-
brackets: {}
|
|
9
|
-
});
|
|
10
|
-
let k = 0;
|
|
11
|
-
let s = '';
|
|
12
|
-
for (const token of tokenizer) {
|
|
13
|
-
if (token.startsWith('(')) {
|
|
14
|
-
s += token.substring(1);
|
|
15
|
-
k++;
|
|
16
|
-
}
|
|
17
|
-
else if (token.startsWith(')')) {
|
|
18
|
-
if (k === 1)
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
else if (k)
|
|
22
|
-
s += token;
|
|
23
|
-
}
|
|
24
|
-
const x = splitString(s, {
|
|
25
|
-
brackets: {
|
|
26
|
-
'{': '}',
|
|
27
|
-
'(': ')',
|
|
28
|
-
'[': ']',
|
|
29
|
-
'/*': '*/'
|
|
30
|
-
}, delimiters: ','
|
|
31
|
-
});
|
|
32
|
-
return x.length > 1 ? x.length : (x[0] ? 1 : 0);
|
|
33
|
-
}
|
package/esm/utils/param.utils.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { PARAM_ARGS_METADATA } from '../constants.js';
|
|
3
|
-
function assignMetadata(args, paramType, index, data, ...pipes) {
|
|
4
|
-
return {
|
|
5
|
-
...args,
|
|
6
|
-
[`${paramType}:${index}`]: {
|
|
7
|
-
index,
|
|
8
|
-
data,
|
|
9
|
-
pipes,
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function createOpraParamDecorator(paramType) {
|
|
14
|
-
return (target, key, index) => {
|
|
15
|
-
if (!key)
|
|
16
|
-
return;
|
|
17
|
-
const args = Reflect.getMetadata(PARAM_ARGS_METADATA, target.constructor, key) || {};
|
|
18
|
-
Reflect.defineMetadata(PARAM_ARGS_METADATA, assignMetadata(args, paramType, index), target.constructor, key);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ContextType } from '@nestjs/common';
|
|
2
|
-
import { Module } from '@nestjs/core/injector/module.js';
|
|
3
|
-
import { ApiDocument, ApiDocumentFactory } from '@opra/common';
|
|
4
|
-
export declare class OpraApiFactory {
|
|
5
|
-
private readonly paramsFactory;
|
|
6
|
-
private readonly injector;
|
|
7
|
-
private readonly modulesContainer;
|
|
8
|
-
private readonly externalContextCreator;
|
|
9
|
-
private readonly explorerService;
|
|
10
|
-
generateService(rootModule: Module, contextType: ContextType, apiSchema?: Partial<ApiDocumentFactory.InitArguments>): Promise<ApiDocument>;
|
|
11
|
-
private _createHandler;
|
|
12
|
-
private _createContextCallback;
|
|
13
|
-
private getContextId;
|
|
14
|
-
private registerContextProvider;
|
|
15
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DynamicModule, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { HttpAdapterHost, ModulesContainer } from '@nestjs/core';
|
|
3
|
-
import { OpraModuleAsyncOptions, OpraModuleOptions } from './interfaces/opra-module-options.interface.js';
|
|
4
|
-
import { OpraApiLoader } from './services/opra-api-loader.js';
|
|
5
|
-
export declare class OpraCoreModule implements OnModuleInit, OnModuleDestroy {
|
|
6
|
-
private readonly httpAdapterHost;
|
|
7
|
-
protected readonly modulesContainer: ModulesContainer;
|
|
8
|
-
private readonly options;
|
|
9
|
-
private readonly apiLoader;
|
|
10
|
-
constructor(httpAdapterHost: HttpAdapterHost, modulesContainer: ModulesContainer, options: OpraModuleOptions, apiLoader: OpraApiLoader);
|
|
11
|
-
static forRoot(options: OpraModuleOptions & Pick<DynamicModule, 'imports' | 'providers' | 'exports'>): DynamicModule;
|
|
12
|
-
static forRootAsync(asyncOptions: OpraModuleAsyncOptions): DynamicModule;
|
|
13
|
-
private static createAsyncProviders;
|
|
14
|
-
private static createAsyncOptionsProvider;
|
|
15
|
-
onModuleInit(): Promise<void>;
|
|
16
|
-
onModuleDestroy(): Promise<void>;
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ApiDocument } from '@opra/common';
|
|
2
|
-
import { PlatformAdapter } from '@opra/core';
|
|
3
|
-
import { kAdapter, kOptions } from './constants.js';
|
|
4
|
-
import { OpraModuleOptions } from './interfaces/opra-module-options.interface.js';
|
|
5
|
-
export declare class OpraModuleRef {
|
|
6
|
-
protected [kOptions]: OpraModuleOptions;
|
|
7
|
-
protected [kAdapter]: PlatformAdapter;
|
|
8
|
-
get adapter(): PlatformAdapter;
|
|
9
|
-
get api(): ApiDocument;
|
|
10
|
-
get options(): OpraModuleOptions;
|
|
11
|
-
}
|
package/types/opra.module.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { OpraModuleAsyncOptions, OpraModuleOptions } from './interfaces/opra-module-options.interface.js';
|
|
3
|
-
export declare class OpraModule {
|
|
4
|
-
static forRoot(options: OpraModuleOptions & Pick<DynamicModule, 'imports' | 'providers' | 'exports'>): DynamicModule;
|
|
5
|
-
static forRootAsync(asyncOptions: OpraModuleAsyncOptions): DynamicModule;
|
|
6
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
2
|
-
import { Module } from '@nestjs/core/injector/module';
|
|
3
|
-
type WrapperCallback = (wrapper: InstanceWrapper, tree: Module[]) => void;
|
|
4
|
-
export declare class NestExplorer {
|
|
5
|
-
exploreProviders(rootModule: Module, callback: WrapperCallback): void;
|
|
6
|
-
exploreResources(rootModule: Module, callback: WrapperCallback): void;
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@nestjs/common';
|
|
2
|
-
import { ApplicationConfig, HttpAdapterHost } from '@nestjs/core';
|
|
3
|
-
import { Module } from '@nestjs/core/injector/module.js';
|
|
4
|
-
import { ApiDocument } from '@opra/common';
|
|
5
|
-
import { ExpressAdapter } from '@opra/core';
|
|
6
|
-
import { OpraApiFactory } from '../factories/opra-api.factory.js';
|
|
7
|
-
import { OpraModuleOptions } from '../interfaces/opra-module-options.interface.js';
|
|
8
|
-
import { OpraModuleRef } from '../opra-module-ref.js';
|
|
9
|
-
export declare class OpraApiLoader {
|
|
10
|
-
protected readonly logger: Logger;
|
|
11
|
-
readonly opraModuleRef: OpraModuleRef;
|
|
12
|
-
protected readonly httpAdapterHost: HttpAdapterHost;
|
|
13
|
-
protected readonly applicationConfig: ApplicationConfig;
|
|
14
|
-
protected readonly opraFactory: OpraApiFactory;
|
|
15
|
-
protected readonly options: OpraModuleOptions;
|
|
16
|
-
initialize(rootModule: Module): Promise<void>;
|
|
17
|
-
stop(): Promise<void>;
|
|
18
|
-
protected registerExpress(apiDocument: ApiDocument, moduleOptions: OpraModuleOptions): Promise<ExpressAdapter>;
|
|
19
|
-
}
|
package/types/types.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Type } from '@nestjs/common';
|
|
2
|
-
export declare function isConstructor(obj: any): obj is Type;
|
|
3
|
-
export declare function getClassOrUndefined(typeOrFunc: Function | Type): Type | undefined;
|
|
4
|
-
export declare function getClassName(nameOrType: string | Function | Type): string | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getNumberOfArguments(fn: Function): number | undefined;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { HandlerParamType } from '../enums/handler-paramtype.enum.js';
|
|
3
|
-
export type ParamData = object | string | number;
|
|
4
|
-
export type ParamsMetadata = Record<number, {
|
|
5
|
-
index: number;
|
|
6
|
-
data?: ParamData;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function createOpraParamDecorator(paramType: HandlerParamType): ParameterDecorator;
|