@clairejs/server 3.23.6 → 3.24.0
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 +4 -0
- package/dist/common/request/endpoint-metadata.d.ts +2 -1
- package/dist/http/common/dto.d.ts +21 -0
- package/dist/http/common/dto.js +143 -0
- package/dist/http/security/decorators.d.ts +3 -0
- package/dist/http/security/decorators.js +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Constructor, type ObjectFieldMetadata } from "@clairejs/core";
|
|
2
2
|
import { type RequestDataSource } from "./types";
|
|
3
|
+
import { ApiInfo } from "../../http/common/dto";
|
|
3
4
|
export interface EndpointMetadata extends ApiInfo, ObjectFieldMetadata {
|
|
4
5
|
controller: any;
|
|
5
6
|
params?: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HttpMethod, SocketMethod, DtoMetadata } from "@clairejs/core";
|
|
2
|
+
export declare class ApiInfo {
|
|
3
|
+
id: string;
|
|
4
|
+
apiGroup?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
displayName: string;
|
|
7
|
+
readOnly: boolean;
|
|
8
|
+
method: HttpMethod | SocketMethod;
|
|
9
|
+
mount: string;
|
|
10
|
+
paramDto?: DtoMetadata;
|
|
11
|
+
queryDto?: DtoMetadata;
|
|
12
|
+
bodyDto?: DtoMetadata;
|
|
13
|
+
responseDto?: DtoMetadata;
|
|
14
|
+
upstreamMessageDtos?: DtoMetadata[];
|
|
15
|
+
downstreamMessageDtos?: DtoMetadata[];
|
|
16
|
+
publicAccess?: boolean;
|
|
17
|
+
tfaRequired?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class ApiInfoResponse {
|
|
20
|
+
apis: ApiInfo[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Data, Field, HttpMethod, Enum, getObjectMetadata, DataType } from "@clairejs/core";
|
|
11
|
+
let ApiInfo = class ApiInfo {
|
|
12
|
+
id;
|
|
13
|
+
apiGroup;
|
|
14
|
+
description;
|
|
15
|
+
displayName;
|
|
16
|
+
readOnly;
|
|
17
|
+
method;
|
|
18
|
+
mount;
|
|
19
|
+
paramDto;
|
|
20
|
+
queryDto;
|
|
21
|
+
bodyDto;
|
|
22
|
+
responseDto;
|
|
23
|
+
upstreamMessageDtos;
|
|
24
|
+
downstreamMessageDtos;
|
|
25
|
+
publicAccess;
|
|
26
|
+
tfaRequired;
|
|
27
|
+
};
|
|
28
|
+
__decorate([
|
|
29
|
+
Field({
|
|
30
|
+
description: "Unique id of the API within the service",
|
|
31
|
+
isRequired: true,
|
|
32
|
+
}),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], ApiInfo.prototype, "id", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
Field({
|
|
37
|
+
description: "Name of the api group",
|
|
38
|
+
}),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], ApiInfo.prototype, "apiGroup", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
Field({
|
|
43
|
+
description: "Description of the API",
|
|
44
|
+
}),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], ApiInfo.prototype, "description", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
Field({
|
|
49
|
+
description: "Display name of the API",
|
|
50
|
+
isRequired: true,
|
|
51
|
+
}),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], ApiInfo.prototype, "displayName", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
Field({
|
|
56
|
+
description: "Whether this API does not allow data modification",
|
|
57
|
+
isRequired: true,
|
|
58
|
+
}),
|
|
59
|
+
__metadata("design:type", Boolean)
|
|
60
|
+
], ApiInfo.prototype, "readOnly", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
Field({
|
|
63
|
+
description: "Http method used to call the API",
|
|
64
|
+
isRequired: true,
|
|
65
|
+
...Enum(HttpMethod),
|
|
66
|
+
}),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], ApiInfo.prototype, "method", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
Field({
|
|
71
|
+
description: "Http mount point of the API",
|
|
72
|
+
isRequired: true,
|
|
73
|
+
}),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], ApiInfo.prototype, "mount", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
Field({
|
|
78
|
+
description: "Validation dto of request param",
|
|
79
|
+
}),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], ApiInfo.prototype, "paramDto", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
Field({
|
|
84
|
+
description: "Validation dto of request queries",
|
|
85
|
+
}),
|
|
86
|
+
__metadata("design:type", Object)
|
|
87
|
+
], ApiInfo.prototype, "queryDto", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
Field({
|
|
90
|
+
description: "Validation dto of request body",
|
|
91
|
+
}),
|
|
92
|
+
__metadata("design:type", Object)
|
|
93
|
+
], ApiInfo.prototype, "bodyDto", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
Field({
|
|
96
|
+
description: "Validation dto of response body",
|
|
97
|
+
}),
|
|
98
|
+
__metadata("design:type", Object)
|
|
99
|
+
], ApiInfo.prototype, "responseDto", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
Field({
|
|
102
|
+
description: "Messages send from client to server for socket",
|
|
103
|
+
}),
|
|
104
|
+
__metadata("design:type", Array)
|
|
105
|
+
], ApiInfo.prototype, "upstreamMessageDtos", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
Field({
|
|
108
|
+
description: "Messages send from server to client for socket",
|
|
109
|
+
}),
|
|
110
|
+
__metadata("design:type", Array)
|
|
111
|
+
], ApiInfo.prototype, "downstreamMessageDtos", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
Field({
|
|
114
|
+
description: "Allow public access and bypass authorization",
|
|
115
|
+
}),
|
|
116
|
+
__metadata("design:type", Boolean)
|
|
117
|
+
], ApiInfo.prototype, "publicAccess", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
Field({
|
|
120
|
+
description: "Upgraded tfa session is required to access this API",
|
|
121
|
+
}),
|
|
122
|
+
__metadata("design:type", Boolean)
|
|
123
|
+
], ApiInfo.prototype, "tfaRequired", void 0);
|
|
124
|
+
ApiInfo = __decorate([
|
|
125
|
+
Data()
|
|
126
|
+
], ApiInfo);
|
|
127
|
+
export { ApiInfo };
|
|
128
|
+
let ApiInfoResponse = class ApiInfoResponse {
|
|
129
|
+
apis;
|
|
130
|
+
};
|
|
131
|
+
__decorate([
|
|
132
|
+
Field({
|
|
133
|
+
description: "All APIs of the service",
|
|
134
|
+
isRequired: true,
|
|
135
|
+
elementDto: getObjectMetadata(ApiInfo),
|
|
136
|
+
vectorProps: { elementDataType: DataType.OBJECT },
|
|
137
|
+
}),
|
|
138
|
+
__metadata("design:type", Array)
|
|
139
|
+
], ApiInfoResponse.prototype, "apis", void 0);
|
|
140
|
+
ApiInfoResponse = __decorate([
|
|
141
|
+
Data()
|
|
142
|
+
], ApiInfoResponse);
|
|
143
|
+
export { ApiInfoResponse };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AbstractHttpController } from "../controller/AbstractHttpController";
|
|
2
|
+
export declare const PublicAccess: () => (prototype: AbstractHttpController, propertyKey: string) => void;
|
|
3
|
+
export declare const TfaRequired: () => (prototype: AbstractHttpController, propertyKey: string) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { initFieldMetadata } from "@clairejs/core";
|
|
2
|
+
export const PublicAccess = () => (prototype, propertyKey) => {
|
|
3
|
+
const endpointMetadata = initFieldMetadata(prototype, propertyKey);
|
|
4
|
+
endpointMetadata.publicAccess = true;
|
|
5
|
+
};
|
|
6
|
+
export const TfaRequired = () => (prototype, propertyKey) => {
|
|
7
|
+
const endpointMetadata = initFieldMetadata(prototype, propertyKey);
|
|
8
|
+
endpointMetadata.tfaRequired = true;
|
|
9
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./http/controller/CrudHttpController";
|
|
|
14
14
|
export * from "./http/controller/AbstractHttpRequestHandler";
|
|
15
15
|
export * from "./http/controller/AbstractHttpMiddleware";
|
|
16
16
|
export * from "./http/security/cors";
|
|
17
|
+
export * from "./http/security/decorators";
|
|
17
18
|
export * from "./http/auth/AbstractHttpAuthorizer";
|
|
18
19
|
export * from "./http/repository/ModelRepository";
|
|
19
20
|
export * from "./http/repository/DtoRepository";
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./http/controller/CrudHttpController";
|
|
|
16
16
|
export * from "./http/controller/AbstractHttpRequestHandler";
|
|
17
17
|
export * from "./http/controller/AbstractHttpMiddleware";
|
|
18
18
|
export * from "./http/security/cors";
|
|
19
|
+
export * from "./http/security/decorators";
|
|
19
20
|
export * from "./http/auth/AbstractHttpAuthorizer";
|
|
20
21
|
export * from "./http/repository/ModelRepository";
|
|
21
22
|
export * from "./http/repository/DtoRepository";
|