@opra/nestjs 0.31.11 → 0.31.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/factories/opra-api.factory.js +6 -5
- package/cjs/services/opra-api-loader.js +2 -2
- package/esm/factories/opra-api.factory.js +6 -5
- package/esm/services/opra-api-loader.js +2 -2
- package/package.json +4 -4
- package/types/factories/opra-api.factory.d.ts +2 -3
- package/types/interfaces/opra-module-options.interface.d.ts +5 -3
|
@@ -21,17 +21,18 @@ let OpraApiFactory = class OpraApiFactory {
|
|
|
21
21
|
this.paramsFactory = new params_factory_js_1.OpraParamsFactory();
|
|
22
22
|
this.injector = new injector_1.Injector();
|
|
23
23
|
}
|
|
24
|
-
async generateService(rootModule,
|
|
25
|
-
const info = {
|
|
24
|
+
async generateService(rootModule, contextType, apiSchema) {
|
|
25
|
+
const info = { ...apiSchema?.info };
|
|
26
26
|
info.title = info.title || 'Untitled service';
|
|
27
27
|
info.version = info.version || '1';
|
|
28
28
|
const root = {
|
|
29
29
|
resources: []
|
|
30
30
|
};
|
|
31
|
-
const
|
|
31
|
+
const apiInit = {
|
|
32
32
|
version: common_2.OpraSchema.SpecVersion,
|
|
33
|
+
...apiSchema,
|
|
33
34
|
info,
|
|
34
|
-
types: [],
|
|
35
|
+
types: apiSchema?.types || [],
|
|
35
36
|
root
|
|
36
37
|
};
|
|
37
38
|
/*
|
|
@@ -93,7 +94,7 @@ let OpraApiFactory = class OpraApiFactory {
|
|
|
93
94
|
}
|
|
94
95
|
});
|
|
95
96
|
// Create api document
|
|
96
|
-
return common_2.ApiDocumentFactory.createDocument(
|
|
97
|
+
return common_2.ApiDocumentFactory.createDocument(apiInit);
|
|
97
98
|
}
|
|
98
99
|
_createHandler(callback) {
|
|
99
100
|
return function (ctx) {
|
|
@@ -23,13 +23,13 @@ class OpraApiLoader {
|
|
|
23
23
|
let prefixPath = new common_2.OpraURLPath((moduleOptions.useGlobalPrefix !== false ? globalPrefix : ''));
|
|
24
24
|
if (moduleOptions.basePath)
|
|
25
25
|
prefixPath = prefixPath.join(moduleOptions.basePath);
|
|
26
|
-
const name = moduleOptions.info?.title || 'untitled service';
|
|
26
|
+
const name = moduleOptions.document?.info?.title || 'untitled service';
|
|
27
27
|
const options = {
|
|
28
28
|
...moduleOptions,
|
|
29
29
|
basePath: prefixPath.toString()
|
|
30
30
|
};
|
|
31
31
|
try {
|
|
32
|
-
const apiDocument = await this.opraFactory.generateService(rootModule,
|
|
32
|
+
const apiDocument = await this.opraFactory.generateService(rootModule, 'http', options.document);
|
|
33
33
|
if (!Object.keys(apiDocument.root).length) {
|
|
34
34
|
this.logger.warn(`No Sources found (${name})`);
|
|
35
35
|
return;
|
|
@@ -18,17 +18,18 @@ let OpraApiFactory = class OpraApiFactory {
|
|
|
18
18
|
this.paramsFactory = new OpraParamsFactory();
|
|
19
19
|
this.injector = new Injector();
|
|
20
20
|
}
|
|
21
|
-
async generateService(rootModule,
|
|
22
|
-
const info = {
|
|
21
|
+
async generateService(rootModule, contextType, apiSchema) {
|
|
22
|
+
const info = { ...apiSchema?.info };
|
|
23
23
|
info.title = info.title || 'Untitled service';
|
|
24
24
|
info.version = info.version || '1';
|
|
25
25
|
const root = {
|
|
26
26
|
resources: []
|
|
27
27
|
};
|
|
28
|
-
const
|
|
28
|
+
const apiInit = {
|
|
29
29
|
version: OpraSchema.SpecVersion,
|
|
30
|
+
...apiSchema,
|
|
30
31
|
info,
|
|
31
|
-
types: [],
|
|
32
|
+
types: apiSchema?.types || [],
|
|
32
33
|
root
|
|
33
34
|
};
|
|
34
35
|
/*
|
|
@@ -90,7 +91,7 @@ let OpraApiFactory = class OpraApiFactory {
|
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
93
|
// Create api document
|
|
93
|
-
return ApiDocumentFactory.createDocument(
|
|
94
|
+
return ApiDocumentFactory.createDocument(apiInit);
|
|
94
95
|
}
|
|
95
96
|
_createHandler(callback) {
|
|
96
97
|
return function (ctx) {
|
|
@@ -20,13 +20,13 @@ export class OpraApiLoader {
|
|
|
20
20
|
let prefixPath = new OpraURLPath((moduleOptions.useGlobalPrefix !== false ? globalPrefix : ''));
|
|
21
21
|
if (moduleOptions.basePath)
|
|
22
22
|
prefixPath = prefixPath.join(moduleOptions.basePath);
|
|
23
|
-
const name = moduleOptions.info?.title || 'untitled service';
|
|
23
|
+
const name = moduleOptions.document?.info?.title || 'untitled service';
|
|
24
24
|
const options = {
|
|
25
25
|
...moduleOptions,
|
|
26
26
|
basePath: prefixPath.toString()
|
|
27
27
|
};
|
|
28
28
|
try {
|
|
29
|
-
const apiDocument = await this.opraFactory.generateService(rootModule,
|
|
29
|
+
const apiDocument = await this.opraFactory.generateService(rootModule, 'http', options.document);
|
|
30
30
|
if (!Object.keys(apiDocument.root).length) {
|
|
31
31
|
this.logger.warn(`No Sources found (${name})`);
|
|
32
32
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.13",
|
|
4
4
|
"description": "Opra NestJS module",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"clean:cover": "rimraf ../../coverage/client"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@opra/common": "^0.31.
|
|
30
|
-
"@opra/core": "^0.31.
|
|
29
|
+
"@opra/common": "^0.31.13",
|
|
30
|
+
"@opra/core": "^0.31.13",
|
|
31
31
|
"fast-tokenizer": "^1.2.2",
|
|
32
32
|
"lodash.head": "^4.0.1",
|
|
33
33
|
"reflect-metadata": "^0.1.13"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@nestjs/platform-express": "^10.2.10",
|
|
41
41
|
"@nestjs/testing": "^10.2.10",
|
|
42
42
|
"@types/lodash.head": "^4.0.9",
|
|
43
|
-
"filedirname": "^
|
|
43
|
+
"filedirname": "^3.1.0",
|
|
44
44
|
"ts-gems": "^2.5.0"
|
|
45
45
|
},
|
|
46
46
|
"type": "module",
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { ContextType } from '@nestjs/common';
|
|
2
2
|
import { Module } from '@nestjs/core/injector/module.js';
|
|
3
|
-
import { ApiDocument } from '@opra/common';
|
|
4
|
-
import { OpraModuleOptions } from '../interfaces/opra-module-options.interface.js';
|
|
3
|
+
import { ApiDocument, ApiDocumentFactory } from '@opra/common';
|
|
5
4
|
export declare class OpraApiFactory {
|
|
6
5
|
private readonly paramsFactory;
|
|
7
6
|
private readonly injector;
|
|
8
7
|
private readonly modulesContainer;
|
|
9
8
|
private readonly externalContextCreator;
|
|
10
9
|
private readonly explorerService;
|
|
11
|
-
generateService(rootModule: Module,
|
|
10
|
+
generateService(rootModule: Module, contextType: ContextType, apiSchema?: Partial<ApiDocumentFactory.InitArguments>): Promise<ApiDocument>;
|
|
12
11
|
private _createHandler;
|
|
13
12
|
private _createContextCallback;
|
|
14
13
|
private getContextId;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
|
-
import {
|
|
3
|
-
import { NodeHttpAdapter } from '@opra/core';
|
|
2
|
+
import { ApiDocumentFactory } from '@opra/common';
|
|
3
|
+
import { ExpressAdapter, NodeHttpAdapter } from '@opra/core';
|
|
4
4
|
export type OpraModuleOptions = NodeHttpAdapter.Options & {
|
|
5
5
|
id?: any;
|
|
6
|
-
|
|
6
|
+
adapterNode?: ExpressAdapter.Options;
|
|
7
|
+
adapterExpress?: ExpressAdapter.Options;
|
|
8
|
+
document?: Partial<ApiDocumentFactory.InitArguments>;
|
|
7
9
|
/**
|
|
8
10
|
* @default true
|
|
9
11
|
*/
|