aws-service-stack 0.10.130 → 0.11.143
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/dist/controller/base-controller.d.ts +28 -13
- package/dist/controller/base-controller.js +181 -64
- package/dist/controller/base-controller.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/base.config.d.ts +123 -0
- package/dist/model/base.config.js +132 -0
- package/dist/model/base.config.js.map +1 -0
- package/dist/model/base.model.d.ts +23 -31
- package/dist/model/base.model.js +23 -12
- package/dist/model/base.model.js.map +1 -1
- package/dist/model/schema-validator.d.ts +27 -0
- package/dist/model/schema-validator.js +116 -0
- package/dist/model/schema-validator.js.map +1 -0
- package/dist/repositories/base-core.repo.interface.d.ts +2 -4
- package/dist/repositories/base-db.repo.d.ts +10 -23
- package/dist/repositories/base-db.repo.interface.d.ts +11 -2
- package/dist/repositories/base-db.repo.js +45 -45
- package/dist/repositories/base-db.repo.js.map +1 -1
- package/dist/repositories/base-es.repo.d.ts +2 -2
- package/dist/repositories/base-es.repo.js +2 -2
- package/dist/repositories/base-es.repo.js.map +1 -1
- package/dist/service/base.service.d.ts +27 -23
- package/dist/service/base.service.interface.d.ts +27 -34
- package/dist/service/base.service.js +145 -86
- package/dist/service/base.service.js.map +1 -1
- package/dist/utils/dynamodb.utils.d.ts +4 -2
- package/dist/utils/dynamodb.utils.js +73 -10
- package/dist/utils/dynamodb.utils.js.map +1 -1
- package/dist/utils/http.util.js +2 -1
- package/dist/utils/http.util.js.map +1 -1
- package/dist/utils/opensearch.utils.d.ts +5 -0
- package/dist/utils/opensearch.utils.js +9 -0
- package/dist/utils/opensearch.utils.js.map +1 -1
- package/dist/utils/reflection.util.js +0 -3
- package/dist/utils/reflection.util.js.map +1 -1
- package/package.json +4 -1
- package/dist/model/schema-validation.d.ts +0 -20
- package/dist/model/schema-validation.js +0 -91
- package/dist/model/schema-validation.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { APIResponse, BaseService, HttpMethod, HttpRequest } from "../index";
|
|
2
2
|
import { APIGatewayProxyEvent, APIGatewayProxyResult, APIGatewayProxyWebsocketEventV2, CreateAuthChallengeTriggerEvent, DefineAuthChallengeTriggerEvent, DynamoDBStreamEvent, PostConfirmationTriggerEvent, PreSignUpTriggerEvent, ScheduledEvent, SQSEvent, VerifyAuthChallengeResponseTriggerEvent } from "aws-lambda";
|
|
3
|
+
import { EntityConfig } from "../model/base.config";
|
|
3
4
|
export declare abstract class BaseController<T extends BaseService<any, any>> {
|
|
4
|
-
protected
|
|
5
|
+
protected resourcePath: string;
|
|
5
6
|
protected userId: string;
|
|
6
7
|
protected isAdmin: boolean;
|
|
7
8
|
protected request: HttpRequest;
|
|
@@ -16,24 +17,23 @@ export declare abstract class BaseController<T extends BaseService<any, any>> {
|
|
|
16
17
|
protected methode: HttpMethod;
|
|
17
18
|
protected groups: string[];
|
|
18
19
|
protected username: string;
|
|
19
|
-
|
|
20
|
+
private ownerId;
|
|
21
|
+
private requestType;
|
|
22
|
+
private config;
|
|
23
|
+
private path;
|
|
24
|
+
protected constructor(baseService: T, config: EntityConfig);
|
|
20
25
|
resolveCrudRequest(event: APIGatewayProxyEvent): Promise<APIResponse>;
|
|
21
26
|
resolveSQSEvent(sqsEvent: SQSEvent): Promise<void>;
|
|
22
27
|
resolveStreamEvent(event: DynamoDBStreamEvent): Promise<void>;
|
|
23
28
|
resolveScheduledEvent(event: ScheduledEvent): Promise<void>;
|
|
24
29
|
resolveWebSocketEvent(event: APIGatewayProxyWebsocketEventV2): Promise<void>;
|
|
25
30
|
resolveTriggerEvent(event: CreateAuthChallengeTriggerEvent | DefineAuthChallengeTriggerEvent | VerifyAuthChallengeResponseTriggerEvent | PostConfirmationTriggerEvent | PreSignUpTriggerEvent): Promise<void>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
protected
|
|
31
|
-
protected
|
|
32
|
-
protected isFieldDeleteRequest(): boolean;
|
|
33
|
-
protected isFieldFetchRequest(): boolean;
|
|
34
|
-
protected handleFieldUpdate(): Promise<APIGatewayProxyResult>;
|
|
35
|
-
protected handleFieldDelete(): Promise<boolean>;
|
|
36
|
-
protected handleFieldFetch(): Promise<any>;
|
|
31
|
+
protected handleList(): Promise<any>;
|
|
32
|
+
protected handleUpdate(): Promise<APIGatewayProxyResult>;
|
|
33
|
+
protected handleDelete(): Promise<boolean>;
|
|
34
|
+
protected handleFetch(): Promise<any>;
|
|
35
|
+
protected handleReplace(): Promise<any>;
|
|
36
|
+
protected handlePostCreate(): Promise<any>;
|
|
37
37
|
protected abstract processCrudRequest(event: APIGatewayProxyEvent): Promise<any>;
|
|
38
38
|
/**
|
|
39
39
|
* service дээр processChanges methode ажилсны дараа хийгдэх үйлдлүүд байна
|
|
@@ -45,4 +45,19 @@ export declare abstract class BaseController<T extends BaseService<any, any>> {
|
|
|
45
45
|
protected abstract processWebSocketEvent(event: APIGatewayProxyWebsocketEventV2): Promise<void>;
|
|
46
46
|
protected processTriggerEvent?(event: CreateAuthChallengeTriggerEvent | DefineAuthChallengeTriggerEvent | VerifyAuthChallengeResponseTriggerEvent | PostConfirmationTriggerEvent | PreSignUpTriggerEvent): Promise<void>;
|
|
47
47
|
protected abstract processSQSEvent(sqsEvent: SQSEvent): Promise<any>;
|
|
48
|
+
protected isListRequest(): boolean;
|
|
49
|
+
protected isUpdateRequest(): boolean;
|
|
50
|
+
protected isDeleteRequest(): boolean;
|
|
51
|
+
protected isFetchRequest(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Map RequestType to Access for permission checking
|
|
54
|
+
*/
|
|
55
|
+
private getUserAccessLevel;
|
|
56
|
+
/**
|
|
57
|
+
* Check if user has permission for the current operation
|
|
58
|
+
*/
|
|
59
|
+
private checkPermission;
|
|
60
|
+
private setUserFilter;
|
|
61
|
+
private bootstrapRequest;
|
|
62
|
+
private parseEntity;
|
|
48
63
|
}
|
|
@@ -14,44 +14,43 @@ const index_1 = require("../index");
|
|
|
14
14
|
const exception_handler_1 = require("../exception/exception-handler");
|
|
15
15
|
const errors_1 = require("../exception/errors");
|
|
16
16
|
class BaseController {
|
|
17
|
-
constructor(baseService,
|
|
17
|
+
constructor(baseService, config) {
|
|
18
18
|
this.adminGroupName = "admin";
|
|
19
19
|
this.groups = [];
|
|
20
20
|
this.service = baseService;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Store config for use in subclasses
|
|
22
|
+
if (!config)
|
|
23
|
+
return;
|
|
24
|
+
this.config = config;
|
|
25
|
+
// Set adminGroupName from config if available
|
|
26
|
+
if (config.ADMIN_GROUP_NAME) {
|
|
27
|
+
this.adminGroupName = config.ADMIN_GROUP_NAME;
|
|
23
28
|
}
|
|
29
|
+
this.service.setConfig(config);
|
|
24
30
|
}
|
|
25
31
|
resolveCrudRequest(event) {
|
|
26
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
|
|
28
|
-
this.groups = ((_c = (_b = (_a = event === null || event === void 0 ? void 0 : event.requestContext) === null || _a === void 0 ? void 0 : _a.authorizer) === null || _b === void 0 ? void 0 : _b.claims) === null || _c === void 0 ? void 0 : _c["cognito:groups"]) || [];
|
|
29
|
-
this.username = ((_f = (_e = (_d = event === null || event === void 0 ? void 0 : event.requestContext) === null || _d === void 0 ? void 0 : _d.authorizer) === null || _e === void 0 ? void 0 : _e.claims) === null || _f === void 0 ? void 0 : _f["cognito:username"]) || "";
|
|
30
|
-
this.endpoint = `${event.httpMethod} ${(_g = event === null || event === void 0 ? void 0 : event.requestContext) === null || _g === void 0 ? void 0 : _g.resourcePath}`;
|
|
31
|
-
this.isAdmin = JSON.stringify(this.groups).toLowerCase().includes(this.adminGroupName.toLowerCase());
|
|
32
|
-
this.userId = (_k = (_j = (_h = event === null || event === void 0 ? void 0 : event.requestContext) === null || _h === void 0 ? void 0 : _h.authorizer) === null || _j === void 0 ? void 0 : _j.claims) === null || _k === void 0 ? void 0 : _k.sub;
|
|
33
|
-
this.request = (0, index_1.parseHttpRequest)(event);
|
|
34
|
-
this.requestBody = this.request.body;
|
|
35
|
-
this.event = event;
|
|
36
|
-
this.resource = (event === null || event === void 0 ? void 0 : event.resource) || "";
|
|
37
|
-
this.methode = event === null || event === void 0 ? void 0 : event.httpMethod;
|
|
38
|
-
this.entityId = ((_l = event === null || event === void 0 ? void 0 : event.pathParameters) === null || _l === void 0 ? void 0 : _l.id) || "";
|
|
39
|
-
let statusCode = 200;
|
|
40
|
-
let content;
|
|
33
|
+
console.log("Resolving Crud Request");
|
|
41
34
|
try {
|
|
42
|
-
|
|
43
|
-
if (this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
this.bootstrapRequest(event);
|
|
36
|
+
if (this.isListRequest())
|
|
37
|
+
return (0, index_1.createApiResponse)(200, yield this.handleList());
|
|
38
|
+
if (this.isUpdateRequest())
|
|
39
|
+
return (0, index_1.createApiResponse)(200, yield this.handleUpdate());
|
|
40
|
+
if (this.isDeleteRequest())
|
|
41
|
+
return (0, index_1.createApiResponse)(200, yield this.handleDelete());
|
|
42
|
+
if (this.isFetchRequest())
|
|
43
|
+
return (0, index_1.createApiResponse)(200, yield this.handleFetch());
|
|
44
|
+
if (this.methode === "PUT" && this.entityId)
|
|
45
|
+
return (0, index_1.createApiResponse)(200, yield this.handleReplace());
|
|
46
|
+
if (this.methode === "POST")
|
|
47
|
+
return (0, index_1.createApiResponse)(200, yield this.handlePostCreate());
|
|
48
|
+
return (0, index_1.createApiResponse)(200, yield this.processCrudRequest(event));
|
|
48
49
|
}
|
|
49
50
|
catch (err) {
|
|
50
51
|
const error = (0, exception_handler_1.errorHandlerHttp)(err);
|
|
51
|
-
|
|
52
|
-
content = error.content;
|
|
52
|
+
return (0, index_1.createApiResponse)(error.statusCode, error.content);
|
|
53
53
|
}
|
|
54
|
-
return (0, index_1.createApiResponse)(statusCode, content);
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
56
|
resolveSQSEvent(sqsEvent) {
|
|
@@ -92,7 +91,7 @@ class BaseController {
|
|
|
92
91
|
resolveWebSocketEvent(event) {
|
|
93
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
93
|
try {
|
|
95
|
-
return this.processWebSocketEvent(event);
|
|
94
|
+
return yield this.processWebSocketEvent(event);
|
|
96
95
|
}
|
|
97
96
|
catch (error) {
|
|
98
97
|
console.error("Error handling request event:", error);
|
|
@@ -104,68 +103,186 @@ class BaseController {
|
|
|
104
103
|
try {
|
|
105
104
|
this.triggerEvent = event;
|
|
106
105
|
this.eventAttr = this.triggerEvent.userAttributes;
|
|
107
|
-
return this.processTriggerEvent(event);
|
|
106
|
+
return yield this.processTriggerEvent(event);
|
|
108
107
|
}
|
|
109
108
|
catch (error) {
|
|
110
109
|
console.error("Error handling request event:", error);
|
|
111
110
|
}
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const segmentsLength = segments.length;
|
|
127
|
-
return this.event.httpMethod === "PATCH" && idIndex !== -1 && idIndex === segmentsLength - 1;
|
|
128
|
-
}
|
|
129
|
-
isFieldDeleteRequest() {
|
|
130
|
-
const segments = this.resource.split("/").filter(Boolean);
|
|
131
|
-
const idIndex = segments.indexOf("{id}");
|
|
132
|
-
const segmentsLength = segments.length;
|
|
133
|
-
return this.event.httpMethod === "DELETE" && idIndex !== -1 && idIndex === segmentsLength - 1;
|
|
134
|
-
}
|
|
135
|
-
isFieldFetchRequest() {
|
|
136
|
-
const segments = this.resource.split("/").filter(Boolean);
|
|
137
|
-
const idIndex = segments.indexOf("{id}");
|
|
138
|
-
const segmentsLength = segments.length;
|
|
139
|
-
return this.event.httpMethod === "GET" && idIndex !== -1 && idIndex === segmentsLength - 1;
|
|
113
|
+
handleList() {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
if (this.methode === "GET" && this.resourcePath.endsWith("/search")) {
|
|
116
|
+
return yield this.service.search(this.request.filterAndSort || {});
|
|
117
|
+
}
|
|
118
|
+
if (this.methode === "GET" && this.resourcePath.endsWith("/scan")) {
|
|
119
|
+
return yield this.service.scan(this.request.filterAndSort || {});
|
|
120
|
+
}
|
|
121
|
+
if (this.methode === "GET") {
|
|
122
|
+
return yield this.service.find(this.request.filterAndSort || {});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
140
125
|
}
|
|
141
|
-
|
|
126
|
+
handleUpdate() {
|
|
142
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
128
|
const entity = JSON.parse(this.event.body || "{}");
|
|
144
129
|
if (Object.keys(entity).length === 0) {
|
|
145
|
-
throw new errors_1.ErrorHttp({ code: 400, error: "
|
|
130
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "BadRequest" }, "No fields to update");
|
|
146
131
|
}
|
|
147
|
-
//
|
|
132
|
+
// id change is forbidden
|
|
148
133
|
if ("id" in entity) {
|
|
149
|
-
throw new errors_1.ErrorHttp({ code: 400, error: "
|
|
134
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "BadRequest" }, "Cannot modify the id field");
|
|
150
135
|
}
|
|
151
|
-
const fields = Object.keys(entity);
|
|
152
136
|
entity.id = this.entityId;
|
|
153
|
-
return this.service.update(
|
|
137
|
+
return this.service.update(entity, this.ownerId);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
handleDelete() {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
if (!this.entityId)
|
|
143
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "BadRequest" }, "Cannot delete resource without id field");
|
|
144
|
+
//todo check permission via owner. check ownerId from data
|
|
145
|
+
return this.service.remove(this.entityId, this.ownerId);
|
|
154
146
|
});
|
|
155
147
|
}
|
|
156
|
-
|
|
148
|
+
handleFetch() {
|
|
157
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
|
|
150
|
+
if (!this.isFetchRequest())
|
|
151
|
+
return null;
|
|
152
|
+
if (!this.entityId)
|
|
153
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "BadRequest" }, "Cannot fetch resource without id field");
|
|
154
|
+
const result = yield this.service.findById(this.entityId, this.ownerId);
|
|
155
|
+
if (result)
|
|
156
|
+
return result;
|
|
157
|
+
throw new errors_1.ErrorHttp({ code: 404, error: "NotFound" }, `Resource with ID ${this.entityId} not found`);
|
|
159
158
|
});
|
|
160
159
|
}
|
|
161
|
-
|
|
160
|
+
handleReplace() {
|
|
162
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
|
|
162
|
+
const entity = this.parseEntity();
|
|
163
|
+
if (!Object.keys(entity).length) {
|
|
164
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "Bad Request" }, "No entity provided for PUT update");
|
|
165
|
+
}
|
|
166
|
+
if (entity.id && entity.id !== this.entityId) {
|
|
167
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "Bad Request" }, "Path id and body id mismatch");
|
|
168
|
+
}
|
|
169
|
+
entity.id = this.entityId;
|
|
170
|
+
// const fields = Object.keys(entity).filter((k) => k !== "id");
|
|
171
|
+
// todo check update permission via owner. check ownerId from data
|
|
172
|
+
return this.service.update(entity, this.ownerId);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
handlePostCreate() {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
const entity = this.parseEntity();
|
|
178
|
+
if (!Object.keys(entity).length) {
|
|
179
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "Bad Request" }, "No entity payload provided");
|
|
180
|
+
}
|
|
181
|
+
if (!this.isAdmin)
|
|
182
|
+
entity.profileId = this.ownerId;
|
|
183
|
+
else if (!entity.proflileId) {
|
|
184
|
+
throw new errors_1.ErrorHttp({ code: 400, error: "BadRequest" }, "No profileId provided");
|
|
185
|
+
}
|
|
186
|
+
return this.service.save(entity, this.ownerId);
|
|
164
187
|
});
|
|
165
188
|
}
|
|
166
189
|
processTriggerEvent(event) {
|
|
167
190
|
return Promise.resolve();
|
|
168
191
|
}
|
|
192
|
+
isListRequest() {
|
|
193
|
+
return this.methode === "GET" && !this.resource.endsWith("/{id}");
|
|
194
|
+
}
|
|
195
|
+
isUpdateRequest() {
|
|
196
|
+
const segments = this.resource.split("/").filter(Boolean);
|
|
197
|
+
const idIndex = segments.indexOf("{id}");
|
|
198
|
+
const segmentsLength = segments.length;
|
|
199
|
+
return this.methode === "PATCH" && idIndex !== -1 && idIndex === segmentsLength - 1;
|
|
200
|
+
}
|
|
201
|
+
isDeleteRequest() {
|
|
202
|
+
return this.methode === "DELETE" && this.resource.endsWith("/{id}");
|
|
203
|
+
}
|
|
204
|
+
isFetchRequest() {
|
|
205
|
+
return this.methode === "GET" && this.resource.endsWith("/{id}");
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Map RequestType to Access for permission checking
|
|
209
|
+
*/
|
|
210
|
+
getUserAccessLevel() {
|
|
211
|
+
switch (this.requestType) {
|
|
212
|
+
case index_1.RequestType.ADMIN:
|
|
213
|
+
return index_1.Access.ADMIN;
|
|
214
|
+
case index_1.RequestType.USER:
|
|
215
|
+
return index_1.Access.USER;
|
|
216
|
+
case index_1.RequestType.GUEST:
|
|
217
|
+
return index_1.Access.PUBLIC;
|
|
218
|
+
case index_1.RequestType.SYSTEM:
|
|
219
|
+
return index_1.Access.SYSTEM;
|
|
220
|
+
default:
|
|
221
|
+
return index_1.Access.PUBLIC;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Check if user has permission for the current operation
|
|
226
|
+
*/
|
|
227
|
+
checkPermission() {
|
|
228
|
+
if (!this.config.PATH_PERMISSIONS) {
|
|
229
|
+
return { allowed: false, message: "No permission config" };
|
|
230
|
+
}
|
|
231
|
+
const currentMethod = this.methode;
|
|
232
|
+
if (!this.path || !currentMethod) {
|
|
233
|
+
return { allowed: true, message: "No path or method" };
|
|
234
|
+
}
|
|
235
|
+
const matchingPermission = this.config.PATH_PERMISSIONS.find((permission) => permission.method === currentMethod && permission.path === this.path);
|
|
236
|
+
// If no specific permission is defined for this path/method, deny access by default
|
|
237
|
+
if (!matchingPermission) {
|
|
238
|
+
throw new errors_1.ErrorHttp({ code: 403, error: "PermissionDenied" }, `No permission defined for ${currentMethod} --- ${this.path}`);
|
|
239
|
+
}
|
|
240
|
+
const accessLevels = matchingPermission.allowed;
|
|
241
|
+
const userAccessLevel = this.getUserAccessLevel();
|
|
242
|
+
// This means USER can access OWNER-level permissions, but the service will verify actual ownership
|
|
243
|
+
const hasPermission = accessLevels.includes(userAccessLevel) ||
|
|
244
|
+
(this.requestType === index_1.RequestType.USER && accessLevels.includes(index_1.Access.OWNER));
|
|
245
|
+
if (!hasPermission) {
|
|
246
|
+
throw new errors_1.ErrorHttp({ code: 403, error: "PermissionDenied" }, `Access denied. Required: ${accessLevels.join(", ")}, Current: ${userAccessLevel}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
setUserFilter() {
|
|
250
|
+
if (this.isAdmin)
|
|
251
|
+
return;
|
|
252
|
+
const ownerIdFieldName = this.config.OWNER_ID_FIELD_NAME || "ownerId";
|
|
253
|
+
this.request.filterAndSort[ownerIdFieldName] = this.ownerId;
|
|
254
|
+
}
|
|
255
|
+
bootstrapRequest(event) {
|
|
256
|
+
var _a, _b, _c, _d, _e;
|
|
257
|
+
const claims = (this.groups = (_b = (_a = event.requestContext) === null || _a === void 0 ? void 0 : _a.authorizer) === null || _b === void 0 ? void 0 : _b.claims);
|
|
258
|
+
this.groups = (claims === null || claims === void 0 ? void 0 : claims["cognito:groups"]) || [];
|
|
259
|
+
this.username = (claims === null || claims === void 0 ? void 0 : claims["cognito:username"]) || "";
|
|
260
|
+
// this.profileId = claims?.["custom:profileId"] || "";
|
|
261
|
+
this.ownerId = "0f761530-9b92-4706-86ab-8bacf311439f";
|
|
262
|
+
this.userId = (_c = claims === null || claims === void 0 ? void 0 : claims.sub) !== null && _c !== void 0 ? _c : "";
|
|
263
|
+
this.isAdmin = JSON.stringify(this.groups).toLowerCase().includes(this.adminGroupName.toLowerCase());
|
|
264
|
+
if (this.isAdmin)
|
|
265
|
+
this.requestType = index_1.RequestType.ADMIN;
|
|
266
|
+
else if (this.ownerId || this.userId)
|
|
267
|
+
this.requestType = index_1.RequestType.USER;
|
|
268
|
+
else
|
|
269
|
+
this.requestType = index_1.RequestType.GUEST;
|
|
270
|
+
this.path = (_d = event === null || event === void 0 ? void 0 : event.requestContext) === null || _d === void 0 ? void 0 : _d.resourcePath;
|
|
271
|
+
this.methode = event.httpMethod;
|
|
272
|
+
this.resourcePath = `${this.methode} ${this.path}`;
|
|
273
|
+
this.request = (0, index_1.parseHttpRequest)(event);
|
|
274
|
+
this.requestBody = this.request.body;
|
|
275
|
+
this.event = event;
|
|
276
|
+
this.resource = event.resource || "";
|
|
277
|
+
this.entityId = ((_e = event.pathParameters) === null || _e === void 0 ? void 0 : _e.id) || "";
|
|
278
|
+
this.checkPermission();
|
|
279
|
+
this.setUserFilter();
|
|
280
|
+
}
|
|
281
|
+
parseEntity() {
|
|
282
|
+
if (!this.requestBody)
|
|
283
|
+
return {};
|
|
284
|
+
return typeof this.requestBody === "string" ? JSON.parse(this.requestBody) : this.requestBody;
|
|
285
|
+
}
|
|
169
286
|
}
|
|
170
287
|
exports.BaseController = BaseController;
|
|
171
288
|
//# sourceMappingURL=base-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-controller.js","sourceRoot":"","sources":["../../src/controller/base-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAWkB;AAclB,sEAAkE;AAClE,gDAAgD;AAEhD,MAAsB,cAAc;IAiBlC,YAAsB,WAAc,EAAE,cAAuB;QAXnD,mBAAc,GAA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KAAK,CAAC,UAAwB,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,IAAA,wBAAgB,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,CAAA,MAAA,KAAK,CAAC,cAAc,0CAAE,EAAE,KAAI,EAAE,CAAC;QAC/C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO,EAAE,CAAC;QACjC,OAAO,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IAChG,CAAC;CACF;AAnVD,wCAmVC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,10 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./model"), exports);
|
|
18
17
|
__exportStar(require("./repositories"), exports);
|
|
19
18
|
__exportStar(require("./service"), exports);
|
|
20
19
|
__exportStar(require("./utils"), exports);
|
|
21
20
|
__exportStar(require("./controller"), exports);
|
|
22
21
|
__exportStar(require("./provider"), exports);
|
|
22
|
+
__exportStar(require("./model"), exports);
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,4CAA0B;AAC1B,0CAAwB;AACxB,+CAA6B;AAC7B,6CAA2B;AAC3B,0CAAwB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Access, DynamoIndexMap } from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generic DynamoDB Configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare class DynamoDBConfig {
|
|
6
|
+
/** DynamoDB table name */
|
|
7
|
+
NAME: string;
|
|
8
|
+
/** DynamoDB index map for queries */
|
|
9
|
+
MAP: DynamoIndexMap;
|
|
10
|
+
constructor(tableName: string, indexMap: DynamoIndexMap);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generic OpenSearch Configuration
|
|
14
|
+
*/
|
|
15
|
+
export declare class OpenSearchConfig {
|
|
16
|
+
/** OpenSearch index name */
|
|
17
|
+
INDEX: string;
|
|
18
|
+
constructor(indexName: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generic Validator Configuration
|
|
22
|
+
*/
|
|
23
|
+
export declare class ValidatorConfig {
|
|
24
|
+
/** Zod/Yup schema for CREATE operations */
|
|
25
|
+
CREATE: any;
|
|
26
|
+
/** Zod/Yup schema for UPDATE operations */
|
|
27
|
+
UPDATE: any;
|
|
28
|
+
constructor(createSchema?: any, updateSchema?: any);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* HTTP Method enum
|
|
32
|
+
*/
|
|
33
|
+
export declare enum HttpMethod {
|
|
34
|
+
GET = "GET",
|
|
35
|
+
POST = "POST",
|
|
36
|
+
PUT = "PUT",
|
|
37
|
+
PATCH = "PATCH",
|
|
38
|
+
DELETE = "DELETE"
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Path-based permission definition
|
|
42
|
+
*/
|
|
43
|
+
export interface PathPermission {
|
|
44
|
+
method: HttpMethod;
|
|
45
|
+
path: string;
|
|
46
|
+
allowed: Access[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration interface for type safety
|
|
50
|
+
*/
|
|
51
|
+
export interface EntityConfig {
|
|
52
|
+
BASE_PATH: string;
|
|
53
|
+
DYNAMO_DB: DynamoDBConfig;
|
|
54
|
+
OPEN_SEARCH: OpenSearchConfig;
|
|
55
|
+
PATH_PERMISSIONS: PathPermission[];
|
|
56
|
+
VALIDATORS: ValidatorConfig;
|
|
57
|
+
ADMIN_GROUP_NAME: string;
|
|
58
|
+
OWNER_ID_FIELD_NAME?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generic Entity Configuration Class
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const config = new EntityConfig("User")
|
|
66
|
+
* .setDynamoDB("User-table", indexMap)
|
|
67
|
+
* .setOpenSearch("user-search")
|
|
68
|
+
* .setPermissions([
|
|
69
|
+
* { role: Role.PUBLIC, actions: [Action.READ] },
|
|
70
|
+
* { role: Role.ADMIN, actions: [Action.READ, Action.CREATE, Action.UPDATE, Action.DELETE] }
|
|
71
|
+
* ])
|
|
72
|
+
* .setValidators(createSchema, updateSchema)
|
|
73
|
+
* .setAdminGroup("admin");
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare class EntityConfigImpl implements EntityConfig {
|
|
77
|
+
/** Entity name for logging and debugging */
|
|
78
|
+
BASE_PATH: string;
|
|
79
|
+
/** DynamoDB configuration */
|
|
80
|
+
DYNAMO_DB: DynamoDBConfig;
|
|
81
|
+
/** OpenSearch configuration */
|
|
82
|
+
OPEN_SEARCH: OpenSearchConfig;
|
|
83
|
+
/** Path-based permission configuration */
|
|
84
|
+
PATH_PERMISSIONS: PathPermission[];
|
|
85
|
+
/** Validator configuration */
|
|
86
|
+
VALIDATORS: ValidatorConfig;
|
|
87
|
+
/** Admin group name for Cognito */
|
|
88
|
+
ADMIN_GROUP_NAME: string;
|
|
89
|
+
OWNER_ID_FIELD_NAME: string;
|
|
90
|
+
constructor(basePath: string, ownerIdFieldName?: string);
|
|
91
|
+
/**
|
|
92
|
+
* Set DynamoDB configuration
|
|
93
|
+
*/
|
|
94
|
+
setDynamoDB(tableName: string, indexMap: DynamoIndexMap): this;
|
|
95
|
+
/**
|
|
96
|
+
* Set OpenSearch configuration
|
|
97
|
+
*/
|
|
98
|
+
setOpenSearch(indexName: string): this;
|
|
99
|
+
/**
|
|
100
|
+
* Set path-based permissions
|
|
101
|
+
*/
|
|
102
|
+
setPermissions(permissions: PathPermission[]): this;
|
|
103
|
+
/**
|
|
104
|
+
* Set validator configuration
|
|
105
|
+
*/
|
|
106
|
+
setValidators(createSchema?: any, updateSchema?: any): this;
|
|
107
|
+
/**
|
|
108
|
+
* Set admin group name
|
|
109
|
+
*/
|
|
110
|
+
setAdminGroup(groupName: string): this;
|
|
111
|
+
/**
|
|
112
|
+
* Set owner field name for filtering user-specific data
|
|
113
|
+
*/
|
|
114
|
+
setOwnerFieldName(fieldName: string): this;
|
|
115
|
+
/**
|
|
116
|
+
* Add a single path permission
|
|
117
|
+
*/
|
|
118
|
+
addPathPermission(method: HttpMethod, path: string, allowedRoles: Access[]): this;
|
|
119
|
+
/**
|
|
120
|
+
* Get configuration as plain object (for BaseController compatibility)
|
|
121
|
+
*/
|
|
122
|
+
toObject(): EntityConfig;
|
|
123
|
+
}
|