@opra/common 1.0.0-alpha.1 → 1.0.0-alpha.3
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/browser.js +155 -78
- package/cjs/document/api-document.js +18 -12
- package/cjs/document/common/data-type-map.js +1 -1
- package/cjs/document/constants.js +1 -1
- package/cjs/document/data-type/api-field.js +1 -1
- package/cjs/document/data-type/complex-type.js +2 -3
- package/cjs/document/data-type/extended-types/base64.type.js +2 -1
- package/cjs/document/data-type/extended-types/date-string.type.js +6 -3
- package/cjs/document/data-type/extended-types/date-time-string.type.js +6 -3
- package/cjs/document/data-type/extended-types/date-time.type.js +6 -3
- package/cjs/document/data-type/extended-types/date.type.js +6 -3
- package/cjs/document/data-type/extended-types/email.type.js +20 -10
- package/cjs/document/data-type/extended-types/field-path.type.js +8 -4
- package/cjs/document/data-type/extended-types/filter.type.js +6 -3
- package/cjs/document/data-type/extended-types/object-id.type.js +2 -1
- package/cjs/document/data-type/extended-types/operation-result.type.js +20 -10
- package/cjs/document/data-type/extended-types/time.type.js +6 -3
- package/cjs/document/data-type/extended-types/url.type.js +2 -1
- package/cjs/document/data-type/extended-types/uuid.type.js +4 -2
- package/cjs/document/data-type/primitive-types/any.type.js +2 -1
- package/cjs/document/data-type/primitive-types/bigint.type.js +2 -1
- package/cjs/document/data-type/primitive-types/boolean.type.js +2 -1
- package/cjs/document/data-type/primitive-types/integer.type.js +2 -1
- package/cjs/document/data-type/primitive-types/null.type.js +2 -1
- package/cjs/document/data-type/primitive-types/number.type.js +6 -3
- package/cjs/document/data-type/primitive-types/object.type.js +2 -1
- package/cjs/document/data-type/primitive-types/string.type.js +10 -5
- package/cjs/document/factory/api-document.factory.js +5 -0
- package/cjs/document/factory/data-type.factory.js +1 -1
- package/cjs/document/factory/http-api.factory.js +1 -1
- package/esm/document/api-document.js +18 -12
- package/esm/document/common/data-type-map.js +1 -1
- package/esm/document/constants.js +1 -1
- package/esm/document/data-type/api-field.js +1 -1
- package/esm/document/data-type/complex-type.js +2 -3
- package/esm/document/data-type/extended-types/base64.type.js +3 -2
- package/esm/document/data-type/extended-types/date-string.type.js +7 -4
- package/esm/document/data-type/extended-types/date-time-string.type.js +7 -4
- package/esm/document/data-type/extended-types/date-time.type.js +7 -4
- package/esm/document/data-type/extended-types/date.type.js +7 -4
- package/esm/document/data-type/extended-types/email.type.js +21 -11
- package/esm/document/data-type/extended-types/field-path.type.js +9 -5
- package/esm/document/data-type/extended-types/filter.type.js +7 -4
- package/esm/document/data-type/extended-types/object-id.type.js +3 -2
- package/esm/document/data-type/extended-types/operation-result.type.js +21 -11
- package/esm/document/data-type/extended-types/time.type.js +7 -4
- package/esm/document/data-type/extended-types/url.type.js +3 -2
- package/esm/document/data-type/extended-types/uuid.type.js +5 -3
- package/esm/document/data-type/primitive-types/any.type.js +3 -2
- package/esm/document/data-type/primitive-types/bigint.type.js +3 -2
- package/esm/document/data-type/primitive-types/boolean.type.js +3 -2
- package/esm/document/data-type/primitive-types/integer.type.js +3 -2
- package/esm/document/data-type/primitive-types/null.type.js +3 -2
- package/esm/document/data-type/primitive-types/number.type.js +7 -4
- package/esm/document/data-type/primitive-types/object.type.js +3 -2
- package/esm/document/data-type/primitive-types/string.type.js +11 -6
- package/esm/document/factory/api-document.factory.js +4 -0
- package/esm/document/factory/data-type.factory.js +1 -1
- package/esm/document/factory/http-api.factory.js +1 -1
- package/package.json +2 -2
- package/types/document/api-document.d.ts +3 -6
- package/types/document/factory/api-document.factory.d.ts +1 -1
- package/types/schema/document.interface.d.ts +13 -1
- package/types/schema/index.d.ts +1 -0
- package/cjs/document/data-type/decorators/api-field-decorator.js +0 -26
- package/cjs/document/data-type/decorators/complex-type.decorator.js +0 -33
- package/cjs/document/data-type/decorators/simple-type.decorator.js +0 -67
- package/cjs/document/http/decorators/http-controller.decorator.js +0 -117
- package/cjs/document/http/decorators/http-operation-entity.decorator.js +0 -461
- package/cjs/document/http/decorators/http-operation.decorator.js +0 -183
- package/cjs/helpers/is-url-string.js +0 -12
- package/cjs/http/opra-url-path.js +0 -266
- package/cjs/http/opra-url.js +0 -253
- package/esm/document/data-type/decorators/api-field-decorator.js +0 -22
- package/esm/document/data-type/decorators/complex-type.decorator.js +0 -28
- package/esm/document/data-type/decorators/simple-type.decorator.js +0 -61
- package/esm/document/http/decorators/http-controller.decorator.js +0 -112
- package/esm/document/http/decorators/http-operation-entity.decorator.js +0 -459
- package/esm/document/http/decorators/http-operation.decorator.js +0 -178
- package/esm/helpers/is-url-string.js +0 -7
- package/esm/http/opra-url-path.js +0 -260
- package/esm/http/opra-url.js +0 -249
- package/types/document/data-type/decorators/api-field-decorator.d.ts +0 -5
- package/types/document/data-type/decorators/complex-type.decorator.d.ts +0 -2
- package/types/document/data-type/decorators/simple-type.decorator.d.ts +0 -20
- package/types/document/http/decorators/http-controller.decorator.d.ts +0 -14
- package/types/document/http/decorators/http-operation-entity.decorator.d.ts +0 -100
- package/types/document/http/decorators/http-operation.decorator.d.ts +0 -30
- package/types/helpers/is-url-string.d.ts +0 -2
- package/types/http/opra-url-path.d.ts +0 -55
- package/types/http/opra-url.d.ts +0 -66
|
@@ -205,7 +205,7 @@ export class HttpApiFactory {
|
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
if (metadata.requestBody) {
|
|
208
|
-
await context.
|
|
208
|
+
await context.enterAsync('.requestBody', async () => {
|
|
209
209
|
const requestBody = new HttpRequestBody(operation);
|
|
210
210
|
await this._initHttpRequestBody(context, requestBody, metadata.requestBody);
|
|
211
211
|
operation.requestBody = requestBody;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@browsery/util": "^0.12.5",
|
|
56
56
|
"@types/encodeurl": "^1.0.2",
|
|
57
57
|
"@types/lodash.omit": "^4.5.9",
|
|
58
|
-
"@types/validator": "^13.
|
|
58
|
+
"@types/validator": "^13.12.0",
|
|
59
59
|
"path-browserify": "^1.0.1",
|
|
60
60
|
"ts-gems": "^3.4.0"
|
|
61
61
|
},
|
|
@@ -7,17 +7,13 @@ import { kTypeNSMap } from './constants.js';
|
|
|
7
7
|
import { DataType } from './data-type/data-type.js';
|
|
8
8
|
import type { EnumType } from './data-type/enum-type.js';
|
|
9
9
|
import type { HttpApi } from './http/http-api.js';
|
|
10
|
-
export declare namespace ApiDocument {
|
|
11
|
-
interface ExportOptions {
|
|
12
|
-
references?: 'inline' | 'relative-url' | 'external-url';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
10
|
/**
|
|
16
11
|
*
|
|
17
12
|
* @class ApiDocument
|
|
18
13
|
*/
|
|
19
14
|
export declare class ApiDocument extends DocumentElement {
|
|
20
15
|
protected [kTypeNSMap]: WeakMap<DataType, string>;
|
|
16
|
+
readonly id: string;
|
|
21
17
|
url?: string;
|
|
22
18
|
info: OpraSchema.DocumentInfo;
|
|
23
19
|
references: ResponsiveMap<ApiDocument>;
|
|
@@ -29,10 +25,11 @@ export declare class ApiDocument extends DocumentElement {
|
|
|
29
25
|
* @param nameOrCtor
|
|
30
26
|
*/
|
|
31
27
|
getDataTypeNs(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject | DataType): string | undefined;
|
|
28
|
+
findDocument(id: string): ApiDocument | undefined;
|
|
32
29
|
toJSON(): OpraSchema.ApiDocument;
|
|
33
30
|
/**
|
|
34
31
|
* Export as Opra schema definition object
|
|
35
32
|
*/
|
|
36
|
-
export(
|
|
33
|
+
export(): OpraSchema.ApiDocument;
|
|
37
34
|
protected _findDataType(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject, visitedRefs?: WeakMap<ApiDocument, boolean>): DataType | undefined;
|
|
38
35
|
}
|
|
@@ -5,7 +5,7 @@ import { DocumentInitContext } from '../common/document-init-context.js';
|
|
|
5
5
|
import { DataTypeFactory } from './data-type.factory.js';
|
|
6
6
|
import { HttpApiFactory } from './http-api.factory.js';
|
|
7
7
|
export declare namespace ApiDocumentFactory {
|
|
8
|
-
interface InitArguments extends PartialSome<StrictOmit<OpraSchema.ApiDocument, 'references' | 'types' | 'api'>, 'spec'> {
|
|
8
|
+
interface InitArguments extends PartialSome<StrictOmit<OpraSchema.ApiDocument, 'id' | 'references' | 'types' | 'api'>, 'spec'> {
|
|
9
9
|
references?: Record<string, ReferenceThunk>;
|
|
10
10
|
types?: DataTypeInitSources;
|
|
11
11
|
api?: HttpApiFactory.InitArguments;
|
|
@@ -7,9 +7,10 @@ export type Protocol = 'http' | 'ws' | 'rpc';
|
|
|
7
7
|
*/
|
|
8
8
|
export interface Document extends DataTypeContainer {
|
|
9
9
|
spec: SpecVersion;
|
|
10
|
+
id: string;
|
|
10
11
|
url?: string;
|
|
11
12
|
info?: DocumentInfo;
|
|
12
|
-
references?: Record<string,
|
|
13
|
+
references?: Record<string, DocumentReference>;
|
|
13
14
|
api?: HttpApi;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
@@ -39,6 +40,14 @@ export interface LicenseInfo {
|
|
|
39
40
|
url?: string;
|
|
40
41
|
content?: string;
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @interface DocumentReference
|
|
45
|
+
*/
|
|
46
|
+
export interface DocumentReference extends Pick<Document, 'id' | 'url' | 'info'> {
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @interface Api
|
|
50
|
+
*/
|
|
42
51
|
export interface Api extends DataTypeContainer {
|
|
43
52
|
protocol: Protocol;
|
|
44
53
|
/**
|
|
@@ -47,6 +56,9 @@ export interface Api extends DataTypeContainer {
|
|
|
47
56
|
name: string;
|
|
48
57
|
description?: string;
|
|
49
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* @interface HttpApi
|
|
61
|
+
*/
|
|
50
62
|
export interface HttpApi extends Api {
|
|
51
63
|
protocol: 'http';
|
|
52
64
|
description?: string;
|
package/types/schema/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare namespace OpraSchema {
|
|
|
26
26
|
export import DocumentInfo = apiDocument_.DocumentInfo;
|
|
27
27
|
export import ContactPerson = apiDocument_.ContactPerson;
|
|
28
28
|
export import LicenseInfo = apiDocument_.LicenseInfo;
|
|
29
|
+
export import DocumentReference = apiDocument_.DocumentReference;
|
|
29
30
|
export import HttpApi = apiDocument_.HttpApi;
|
|
30
31
|
export import Api = apiDocument_.Api;
|
|
31
32
|
export import HttpMethod = types_.HttpMethod;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiFieldDecorator = void 0;
|
|
4
|
-
const index_js_1 = require("../../../helpers/index.js");
|
|
5
|
-
const index_js_2 = require("../../../schema/index.js");
|
|
6
|
-
const constants_js_1 = require("../../constants.js");
|
|
7
|
-
function ApiFieldDecorator(options) {
|
|
8
|
-
return function (target, propertyKey) {
|
|
9
|
-
if (typeof propertyKey !== 'string')
|
|
10
|
-
throw new TypeError(`Symbol properties can't be used as a field`);
|
|
11
|
-
const metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target.constructor) || {};
|
|
12
|
-
metadata.kind = index_js_2.OpraSchema.ComplexType.Kind;
|
|
13
|
-
metadata.fields = metadata.fields || {};
|
|
14
|
-
const designType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
15
|
-
const elemMeta = (metadata.fields[propertyKey] = {
|
|
16
|
-
...options,
|
|
17
|
-
});
|
|
18
|
-
if (designType === Array) {
|
|
19
|
-
elemMeta.isArray = true;
|
|
20
|
-
}
|
|
21
|
-
else
|
|
22
|
-
elemMeta.type = elemMeta.type || designType;
|
|
23
|
-
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, (0, index_js_1.omitUndefined)(metadata), target.constructor);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.ApiFieldDecorator = ApiFieldDecorator;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComplexTypeDecorator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
|
-
const index_js_1 = require("../../../schema/index.js");
|
|
7
|
-
const constants_js_1 = require("../../constants.js");
|
|
8
|
-
function ComplexTypeDecorator(options) {
|
|
9
|
-
return function (target) {
|
|
10
|
-
let name;
|
|
11
|
-
if (!options?.embedded) {
|
|
12
|
-
if (options?.name) {
|
|
13
|
-
if (!constants_js_1.CLASS_NAME_PATTERN.test(options.name))
|
|
14
|
-
throw new TypeError(`"${options.name}" is not a valid type name`);
|
|
15
|
-
name = options.name;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
name = target.name.match(constants_js_1.EXTRACT_TYPENAME_PATTERN)?.[1] || target.name;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
let metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target);
|
|
22
|
-
if (!metadata) {
|
|
23
|
-
metadata = {};
|
|
24
|
-
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target);
|
|
25
|
-
}
|
|
26
|
-
metadata.kind = index_js_1.OpraSchema.ComplexType.Kind;
|
|
27
|
-
metadata.name = name;
|
|
28
|
-
// Merge options
|
|
29
|
-
if (options)
|
|
30
|
-
Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'name', 'base', 'fields']));
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
exports.ComplexTypeDecorator = ComplexTypeDecorator;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AttributeDecoratorFactory = exports.SimpleTypeDecoratorFactory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
|
-
const index_js_1 = require("../../../schema/index.js");
|
|
7
|
-
const constants_js_1 = require("../../constants.js");
|
|
8
|
-
function SimpleTypeDecoratorFactory(options) {
|
|
9
|
-
const decoratorChain = [];
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
const decorator = function (target) {
|
|
14
|
-
let name;
|
|
15
|
-
if (!options?.embedded) {
|
|
16
|
-
if (options?.name) {
|
|
17
|
-
if (!constants_js_1.CLASS_NAME_PATTERN.test(options.name))
|
|
18
|
-
throw new TypeError(`"${options.name}" is not a valid type name`);
|
|
19
|
-
name = options.name;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
name = target.name.match(constants_js_1.EXTRACT_TYPENAME_PATTERN)?.[1] || target.name;
|
|
23
|
-
name = name.toLowerCase();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target) || {};
|
|
27
|
-
metadata.kind = index_js_1.OpraSchema.SimpleType.Kind;
|
|
28
|
-
metadata.name = name;
|
|
29
|
-
if (options)
|
|
30
|
-
Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'name']));
|
|
31
|
-
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target);
|
|
32
|
-
};
|
|
33
|
-
decorator.Example = (value, description) => {
|
|
34
|
-
decoratorChain.push((meta) => {
|
|
35
|
-
meta.examples = meta.examples || [];
|
|
36
|
-
meta.examples.push({
|
|
37
|
-
description,
|
|
38
|
-
value,
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
return decorator;
|
|
42
|
-
};
|
|
43
|
-
return decorator;
|
|
44
|
-
}
|
|
45
|
-
exports.SimpleTypeDecoratorFactory = SimpleTypeDecoratorFactory;
|
|
46
|
-
function AttributeDecoratorFactory(options) {
|
|
47
|
-
return (target, propertyKey) => {
|
|
48
|
-
if (typeof propertyKey !== 'string')
|
|
49
|
-
throw new TypeError(`Symbol properties can't be decorated with Attribute`);
|
|
50
|
-
const metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target.constructor) || {};
|
|
51
|
-
const designType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
52
|
-
let format = 'string';
|
|
53
|
-
if (designType === Boolean)
|
|
54
|
-
format = 'boolean';
|
|
55
|
-
else if (designType === Number)
|
|
56
|
-
format = 'number';
|
|
57
|
-
metadata.kind = index_js_1.OpraSchema.SimpleType.Kind;
|
|
58
|
-
metadata.attributes = metadata.attributes || {};
|
|
59
|
-
metadata.attributes[propertyKey] = {
|
|
60
|
-
format: options?.format || format,
|
|
61
|
-
description: options?.description,
|
|
62
|
-
deprecated: options?.deprecated,
|
|
63
|
-
};
|
|
64
|
-
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target.constructor);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
exports.AttributeDecoratorFactory = AttributeDecoratorFactory;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpControllerDecoratorFactory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
|
-
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
7
|
-
const index_js_1 = require("../../../schema/index.js");
|
|
8
|
-
const constants_js_1 = require("../../constants.js");
|
|
9
|
-
const CLASS_NAME_PATTERN = /^(.*)(Collection|Singleton|Resource|Controller)$/;
|
|
10
|
-
function HttpControllerDecoratorFactory(options) {
|
|
11
|
-
const decoratorChain = [];
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
const decorator = function (target) {
|
|
16
|
-
let name = options?.name;
|
|
17
|
-
if (!name)
|
|
18
|
-
name = CLASS_NAME_PATTERN.exec(target.name)?.[1] || target.name;
|
|
19
|
-
const metadata = {};
|
|
20
|
-
const baseMetadata = Reflect.getOwnMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, Object.getPrototypeOf(target));
|
|
21
|
-
if (baseMetadata)
|
|
22
|
-
(0, putil_merge_1.default)(metadata, baseMetadata, { deep: true });
|
|
23
|
-
const oldMetadata = Reflect.getOwnMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, target);
|
|
24
|
-
if (oldMetadata)
|
|
25
|
-
(0, putil_merge_1.default)(metadata, oldMetadata, { deep: true });
|
|
26
|
-
(0, putil_merge_1.default)(metadata, {
|
|
27
|
-
kind: index_js_1.OpraSchema.HttpController.Kind,
|
|
28
|
-
name,
|
|
29
|
-
path: name,
|
|
30
|
-
...(0, lodash_omit_1.default)(options, ['kind', 'name', 'instance', 'endpoints', 'key']),
|
|
31
|
-
}, { deep: true });
|
|
32
|
-
Reflect.defineMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, metadata, target);
|
|
33
|
-
for (const fn of decoratorChain)
|
|
34
|
-
fn(metadata);
|
|
35
|
-
Reflect.defineMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, metadata, target);
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
decorator.Cookie = (name, arg1) => {
|
|
41
|
-
decoratorChain.push((meta) => {
|
|
42
|
-
const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
|
|
43
|
-
? {
|
|
44
|
-
name,
|
|
45
|
-
location: 'cookie',
|
|
46
|
-
type: arg1,
|
|
47
|
-
}
|
|
48
|
-
: { ...arg1, name, location: 'cookie' };
|
|
49
|
-
meta.parameters = meta.parameters || [];
|
|
50
|
-
meta.parameters.push(paramMeta);
|
|
51
|
-
});
|
|
52
|
-
return decorator;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
decorator.Header = (name, arg1) => {
|
|
58
|
-
decoratorChain.push((meta) => {
|
|
59
|
-
const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
|
|
60
|
-
? {
|
|
61
|
-
name,
|
|
62
|
-
location: 'header',
|
|
63
|
-
type: arg1,
|
|
64
|
-
}
|
|
65
|
-
: { ...arg1, name, location: 'header' };
|
|
66
|
-
meta.parameters = meta.parameters || [];
|
|
67
|
-
meta.parameters.push(paramMeta);
|
|
68
|
-
});
|
|
69
|
-
return decorator;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
*/
|
|
74
|
-
decorator.QueryParam = (name, arg1) => {
|
|
75
|
-
decoratorChain.push((meta) => {
|
|
76
|
-
const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
|
|
77
|
-
? {
|
|
78
|
-
name,
|
|
79
|
-
location: 'query',
|
|
80
|
-
type: arg1,
|
|
81
|
-
}
|
|
82
|
-
: { ...arg1, name, location: 'query' };
|
|
83
|
-
meta.parameters = meta.parameters || [];
|
|
84
|
-
meta.parameters.push(paramMeta);
|
|
85
|
-
});
|
|
86
|
-
return decorator;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
decorator.PathParam = (name, arg1) => {
|
|
92
|
-
decoratorChain.push((meta) => {
|
|
93
|
-
const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
|
|
94
|
-
? {
|
|
95
|
-
name,
|
|
96
|
-
location: 'path',
|
|
97
|
-
type: arg1,
|
|
98
|
-
}
|
|
99
|
-
: { ...arg1, name, location: 'path' };
|
|
100
|
-
meta.parameters = meta.parameters || [];
|
|
101
|
-
meta.parameters.push(paramMeta);
|
|
102
|
-
});
|
|
103
|
-
return decorator;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
decorator.UseType = (...type) => {
|
|
109
|
-
decoratorChain.push((meta) => {
|
|
110
|
-
meta.types = meta.types || [];
|
|
111
|
-
meta.types.push(...type);
|
|
112
|
-
});
|
|
113
|
-
return decorator;
|
|
114
|
-
};
|
|
115
|
-
return decorator;
|
|
116
|
-
}
|
|
117
|
-
exports.HttpControllerDecoratorFactory = HttpControllerDecoratorFactory;
|