aws-service-stack 0.10.92
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 +20 -0
- package/dist/_examples/model/user.model.d.ts +6 -0
- package/dist/_examples/model/user.model.js +3 -0
- package/dist/_examples/model/user.model.js.map +1 -0
- package/dist/controller/base-controller.d.ts +34 -0
- package/dist/controller/base-controller.js +151 -0
- package/dist/controller/base-controller.js.map +1 -0
- package/dist/controller/index.d.ts +1 -0
- package/dist/controller/index.js +18 -0
- package/dist/controller/index.js.map +1 -0
- package/dist/exception/errors.d.ts +32 -0
- package/dist/exception/errors.js +46 -0
- package/dist/exception/errors.js.map +1 -0
- package/dist/exception/exception-handler.d.ts +238 -0
- package/dist/exception/exception-handler.js +112 -0
- package/dist/exception/exception-handler.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/model/base.model.d.ts +64 -0
- package/dist/model/base.model.js +20 -0
- package/dist/model/base.model.js.map +1 -0
- package/dist/model/cognito-user.model.d.ts +12 -0
- package/dist/model/cognito-user.model.js +3 -0
- package/dist/model/cognito-user.model.js.map +1 -0
- package/dist/model/filter.model.d.ts +46 -0
- package/dist/model/filter.model.js +22 -0
- package/dist/model/filter.model.js.map +1 -0
- package/dist/model/http.model.d.ts +7 -0
- package/dist/model/http.model.js +12 -0
- package/dist/model/http.model.js.map +1 -0
- package/dist/model/index.d.ts +4 -0
- package/dist/model/index.js +21 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/schema-validation.d.ts +20 -0
- package/dist/model/schema-validation.js +91 -0
- package/dist/model/schema-validation.js.map +1 -0
- package/dist/provider/apigateway.d.ts +4 -0
- package/dist/provider/apigateway.js +28 -0
- package/dist/provider/apigateway.js.map +1 -0
- package/dist/provider/dynamodb.d.ts +3 -0
- package/dist/provider/dynamodb.js +18 -0
- package/dist/provider/dynamodb.js.map +1 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.js +20 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/provider/opensearch.d.ts +4 -0
- package/dist/provider/opensearch.js +34 -0
- package/dist/provider/opensearch.js.map +1 -0
- package/dist/repositories/base-core.repo.interface.d.ts +129 -0
- package/dist/repositories/base-core.repo.interface.js +3 -0
- package/dist/repositories/base-core.repo.interface.js.map +1 -0
- package/dist/repositories/base-db.repo.d.ts +78 -0
- package/dist/repositories/base-db.repo.interface.d.ts +61 -0
- package/dist/repositories/base-db.repo.interface.js +3 -0
- package/dist/repositories/base-db.repo.interface.js.map +1 -0
- package/dist/repositories/base-db.repo.js +471 -0
- package/dist/repositories/base-db.repo.js.map +1 -0
- package/dist/repositories/base-es.repo.d.ts +31 -0
- package/dist/repositories/base-es.repo.interface.d.ts +13 -0
- package/dist/repositories/base-es.repo.interface.js +3 -0
- package/dist/repositories/base-es.repo.interface.js.map +1 -0
- package/dist/repositories/base-es.repo.js +148 -0
- package/dist/repositories/base-es.repo.js.map +1 -0
- package/dist/repositories/index.d.ts +4 -0
- package/dist/repositories/index.js +21 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/service/api.services/api.service.d.ts +11 -0
- package/dist/service/api.services/api.service.interface.d.ts +8 -0
- package/dist/service/api.services/api.service.interface.js +3 -0
- package/dist/service/api.services/api.service.interface.js.map +1 -0
- package/dist/service/api.services/api.service.js +103 -0
- package/dist/service/api.services/api.service.js.map +1 -0
- package/dist/service/api.services/index.d.ts +2 -0
- package/dist/service/api.services/index.js +19 -0
- package/dist/service/api.services/index.js.map +1 -0
- package/dist/service/auth.service.d.ts +8 -0
- package/dist/service/auth.service.interface.d.ts +6 -0
- package/dist/service/auth.service.interface.js +3 -0
- package/dist/service/auth.service.interface.js.map +1 -0
- package/dist/service/auth.service.js +90 -0
- package/dist/service/auth.service.js.map +1 -0
- package/dist/service/base.service.d.ts +39 -0
- package/dist/service/base.service.interface.d.ts +106 -0
- package/dist/service/base.service.interface.js +3 -0
- package/dist/service/base.service.interface.js.map +1 -0
- package/dist/service/base.service.js +167 -0
- package/dist/service/base.service.js.map +1 -0
- package/dist/service/index.d.ts +5 -0
- package/dist/service/index.js +22 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/key-aws.services.d.ts +6 -0
- package/dist/service/key-aws.services.js +48 -0
- package/dist/service/key-aws.services.js.map +1 -0
- package/dist/service/key.services.interface.d.ts +3 -0
- package/dist/service/key.services.interface.js +3 -0
- package/dist/service/key.services.interface.js.map +1 -0
- package/dist/service/socket.service.d.ts +6 -0
- package/dist/service/socket.service.interface.d.ts +3 -0
- package/dist/service/socket.service.interface.js +3 -0
- package/dist/service/socket.service.interface.js.map +1 -0
- package/dist/service/socket.service.js +33 -0
- package/dist/service/socket.service.js.map +1 -0
- package/dist/service/validation.service.interface.d.ts +2 -0
- package/dist/service/validation.service.interface.js +3 -0
- package/dist/service/validation.service.interface.js.map +1 -0
- package/dist/utils/auth.util.d.ts +13 -0
- package/dist/utils/auth.util.js +17 -0
- package/dist/utils/auth.util.js.map +1 -0
- package/dist/utils/dynamodb.utils.d.ts +43 -0
- package/dist/utils/dynamodb.utils.js +303 -0
- package/dist/utils/dynamodb.utils.js.map +1 -0
- package/dist/utils/env.util.d.ts +1 -0
- package/dist/utils/env.util.js +14 -0
- package/dist/utils/env.util.js.map +1 -0
- package/dist/utils/error.util.d.ts +1 -0
- package/dist/utils/error.util.js +5 -0
- package/dist/utils/error.util.js.map +1 -0
- package/dist/utils/file-handler.d.ts +14 -0
- package/dist/utils/file-handler.js +216 -0
- package/dist/utils/file-handler.js.map +1 -0
- package/dist/utils/http.util.d.ts +27 -0
- package/dist/utils/http.util.js +133 -0
- package/dist/utils/http.util.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +25 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json.util.d.ts +1 -0
- package/dist/utils/json.util.js +20 -0
- package/dist/utils/json.util.js.map +1 -0
- package/dist/utils/opensearch.utils.d.ts +40 -0
- package/dist/utils/opensearch.utils.js +293 -0
- package/dist/utils/opensearch.utils.js.map +1 -0
- package/dist/utils/reflection.util.d.ts +20 -0
- package/dist/utils/reflection.util.js +154 -0
- package/dist/utils/reflection.util.js.map +1 -0
- package/dist/utils/validation.util.d.ts +13 -0
- package/dist/utils/validation.util.js +90 -0
- package/dist/utils/validation.util.js.map +1 -0
- package/package.json +106 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.BaseRepoESImpl = void 0;
|
|
22
|
+
const index_1 = require("../index");
|
|
23
|
+
const json_util_1 = require("../utils/json.util");
|
|
24
|
+
const typedi_1 = require("typedi");
|
|
25
|
+
let BaseRepoESImpl = class BaseRepoESImpl {
|
|
26
|
+
constructor(indexName) {
|
|
27
|
+
this.indexName = indexName;
|
|
28
|
+
}
|
|
29
|
+
incrementValueByField(entityId, fieldName, value) {
|
|
30
|
+
throw new Error("Method not implemented.");
|
|
31
|
+
}
|
|
32
|
+
decrementValueByField(entityId, fieldName, value) {
|
|
33
|
+
throw new Error("Method not implemented.");
|
|
34
|
+
}
|
|
35
|
+
save(entity) {
|
|
36
|
+
throw new Error("Method not implemented.");
|
|
37
|
+
}
|
|
38
|
+
saveMany(entities) {
|
|
39
|
+
throw new Error("Method not implemented.");
|
|
40
|
+
}
|
|
41
|
+
update(entity, fieldNames) {
|
|
42
|
+
throw new Error("Method not implemented.");
|
|
43
|
+
}
|
|
44
|
+
updateMany(entities, fieldNames) {
|
|
45
|
+
throw new Error("Method not implemented.");
|
|
46
|
+
}
|
|
47
|
+
delete(id) {
|
|
48
|
+
throw new Error("Method not implemented.");
|
|
49
|
+
}
|
|
50
|
+
deleteMany(ids) {
|
|
51
|
+
throw new Error("Method not implemented.");
|
|
52
|
+
}
|
|
53
|
+
findByIds(ids) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const query = (0, index_1.searchQueryES)().size(10).from(0).filterTerms("id", ids);
|
|
56
|
+
return yield this.search(query.build());
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
find(filter) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const query = (0, index_1.buildQueryOS)(filter);
|
|
62
|
+
console.debug("query: " + JSON.stringify(query));
|
|
63
|
+
return { items: yield this.list(query) };
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
findOne(filter) {
|
|
67
|
+
throw new Error("Method not implemented.");
|
|
68
|
+
}
|
|
69
|
+
count(filter) {
|
|
70
|
+
throw new Error("Method not implemented.");
|
|
71
|
+
}
|
|
72
|
+
getRaw(filter) {
|
|
73
|
+
throw new Error("Method not implemented.");
|
|
74
|
+
}
|
|
75
|
+
setIndexName(indexName) {
|
|
76
|
+
this.indexName = indexName;
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
setEndpoint(endpoint) {
|
|
80
|
+
throw new Error("Method not implemented.");
|
|
81
|
+
}
|
|
82
|
+
getEndpoint() {
|
|
83
|
+
throw new Error("Method not implemented.");
|
|
84
|
+
}
|
|
85
|
+
getIndexName() {
|
|
86
|
+
return this.indexName;
|
|
87
|
+
}
|
|
88
|
+
findById(id) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const result = yield this.findByIds([id]);
|
|
91
|
+
if (result.length > 1)
|
|
92
|
+
console.warn("More than one entity found by id", id);
|
|
93
|
+
return result.length > 0 ? result.at(0) : undefined;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
findByIdFieldSelected(id, includeFields, excludeFields) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const query = (0, index_1.searchQueryES)()
|
|
99
|
+
.size(10)
|
|
100
|
+
.from(0)
|
|
101
|
+
.filterTerm("id", id)
|
|
102
|
+
.includeFields(includeFields)
|
|
103
|
+
.excludeFields(excludeFields);
|
|
104
|
+
const result = yield this.search(query.build());
|
|
105
|
+
return result.length > 0 ? result.at(0) : undefined;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
list(query) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
query.setIndex(this.indexName);
|
|
111
|
+
return yield this.search(query.build());
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exists(id) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
return !!(yield this.findById(id));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
findBetween(fieldName, fromValue, toValue, includeFields) {
|
|
120
|
+
throw new Error("Method not implemented.");
|
|
121
|
+
}
|
|
122
|
+
search(searchQuery) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
searchQuery.index = this.indexName;
|
|
126
|
+
const query = (0, json_util_1.removeEmptyArrays)(searchQuery);
|
|
127
|
+
console.debug(JSON.stringify(query, null, 1));
|
|
128
|
+
try {
|
|
129
|
+
const { body } = yield this.searchClient.search(query);
|
|
130
|
+
return ((_b = (_a = body === null || body === void 0 ? void 0 : body.hits) === null || _a === void 0 ? void 0 : _a.hits) === null || _b === void 0 ? void 0 : _b.map((item) => item._source)) || [];
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
console.error("searchES ERROR: ", err);
|
|
134
|
+
throw new Error(typeof err === "string" ? err : err instanceof Error ? err.message : "Unknown searchES error");
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
exports.BaseRepoESImpl = BaseRepoESImpl;
|
|
140
|
+
__decorate([
|
|
141
|
+
(0, typedi_1.Inject)("ESClientOpenSearch"),
|
|
142
|
+
__metadata("design:type", index_1.ESClientOpenSearch)
|
|
143
|
+
], BaseRepoESImpl.prototype, "searchClient", void 0);
|
|
144
|
+
exports.BaseRepoESImpl = BaseRepoESImpl = __decorate([
|
|
145
|
+
(0, typedi_1.Service)("BaseRepoES"),
|
|
146
|
+
__metadata("design:paramtypes", [String])
|
|
147
|
+
], BaseRepoESImpl);
|
|
148
|
+
//# sourceMappingURL=base-es.repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-es.repo.js","sourceRoot":"","sources":["../../src/repositories/base-es.repo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oCASkB;AAGlB,kDAAuD;AACvD,mCAAyC;AAGlC,IAAe,cAAc,GAA7B,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AAC;gBAEvD,OAAO,CAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,0CAAE,IAAI,0CAAE,GAAG,CAAC,CAAC,IAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAI,EAAE,CAAC;YAC7E,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC;YACjH,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AA9HqB,wCAAc;AACI;IAArC,IAAA,eAAM,EAAC,oBAAoB,CAAC;8BAAuB,0BAAkB;oDAAC;yBADnD,cAAc;IADnC,IAAA,gBAAO,EAAC,YAAY,CAAC;;GACA,cAAc,CA8HnC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base-db.repo"), exports);
|
|
18
|
+
__exportStar(require("./base-db.repo.interface"), exports);
|
|
19
|
+
__exportStar(require("./base-es.repo"), exports);
|
|
20
|
+
__exportStar(require("./base-es.repo.interface"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,2DAAyC;AACzC,iDAA+B;AAC/B,2DAAyC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { ApiService } from './api.service.interface';
|
|
3
|
+
export declare class ApiServiceImpl implements ApiService {
|
|
4
|
+
private api;
|
|
5
|
+
constructor(baseURL?: string, config?: AxiosRequestConfig);
|
|
6
|
+
initialize(token?: string, baseURL?: string): Promise<void>;
|
|
7
|
+
get<T>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<T>;
|
|
8
|
+
post<T>(url: string, data: any, config?: AxiosRequestConfig): Promise<T>;
|
|
9
|
+
put<T>(url: string, data: any, config?: AxiosRequestConfig): Promise<T>;
|
|
10
|
+
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
export interface ApiService {
|
|
3
|
+
initialize(token?: string, baseURL?: string): Promise<void>;
|
|
4
|
+
get<T>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<T>;
|
|
5
|
+
post<T>(url: string, data: any, config?: AxiosRequestConfig): Promise<T>;
|
|
6
|
+
put<T>(url: string, data: any, config?: AxiosRequestConfig): Promise<T>;
|
|
7
|
+
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.service.interface.js","sourceRoot":"","sources":["../../../src/service/api.services/api.service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.ApiServiceImpl = void 0;
|
|
25
|
+
const axios_1 = __importDefault(require("axios"));
|
|
26
|
+
const typedi_1 = require("typedi");
|
|
27
|
+
let ApiServiceImpl = class ApiServiceImpl {
|
|
28
|
+
constructor(baseURL, config) {
|
|
29
|
+
this.api = axios_1.default.create(config !== null && config !== void 0 ? config : {
|
|
30
|
+
baseURL: baseURL !== null && baseURL !== void 0 ? baseURL : '',
|
|
31
|
+
timeout: 5000,
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
Accept: '*/*',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
initialize(token, baseURL) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (token || baseURL) {
|
|
41
|
+
this.api.interceptors.request.use((config) => {
|
|
42
|
+
if (token) {
|
|
43
|
+
config.headers.Authorization = token;
|
|
44
|
+
}
|
|
45
|
+
if (baseURL) {
|
|
46
|
+
config.baseURL = baseURL;
|
|
47
|
+
}
|
|
48
|
+
return config;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
get(url, params, config) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
const response = yield this.api.get(url, Object.assign(Object.assign({}, config), { params }));
|
|
57
|
+
return response.data;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.log('GET api service error: ', error);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
post(url, data, config) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
const response = yield this.api.post(url, data, config);
|
|
68
|
+
return response.data;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.log('POST api service error: ', error);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
put(url, data, config) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
try {
|
|
78
|
+
const response = yield this.api.put(url, data, config);
|
|
79
|
+
return response.data;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.log('PUT api service error: ', error);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
delete(url, config) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
try {
|
|
89
|
+
const response = yield this.api.delete(url, config);
|
|
90
|
+
return response.data;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.log('DELETE api service error: ', error);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
exports.ApiServiceImpl = ApiServiceImpl;
|
|
99
|
+
exports.ApiServiceImpl = ApiServiceImpl = __decorate([
|
|
100
|
+
(0, typedi_1.Service)('ApiService'),
|
|
101
|
+
__metadata("design:paramtypes", [String, Object])
|
|
102
|
+
], ApiServiceImpl);
|
|
103
|
+
//# sourceMappingURL=api.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.service.js","sourceRoot":"","sources":["../../../src/service/api.services/api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAgF;AAChF,mCAAiC;AAI1B,IAAM,cAAc,GAApB,MAAM,cAAc;IAGzB,YAAY,OAAgB,EAAE,MAA2B;QACvD,IAAI,CAAC,GAAG,GAAG,eAAK,CAAC,MAAM,CACrB,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI;YACR,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE;YACtB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,KAAK;aACd;SACF,CACF,CAAC;IACJ,CAAC;IA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qB,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;gBACzE,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;KAAA;IAEY,MAAM,CAAI,GAAW,EAAE,MAA2B;;YAC7D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAqB,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBACtE,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AAjEY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,gBAAO,EAAC,YAAY,CAAC;;GACT,cAAc,CAiE1B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api.service"), exports);
|
|
18
|
+
__exportStar(require("./api.service.interface"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/service/api.services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,0DAAwC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AuthService } from "./auth.service.interface";
|
|
2
|
+
export declare class AuthServiceImpl implements AuthService {
|
|
3
|
+
checkOwnershipAddress(userIdList: string[], addressIdList: string[]): Promise<boolean>;
|
|
4
|
+
isAuthorized(identity: any, notificationId: string): Promise<boolean>;
|
|
5
|
+
checkOwnershipBrand(userIdList: string[], brandIdList: string[]): Promise<boolean>;
|
|
6
|
+
isAdmin(userID: string): Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export declare function Authorize(): MethodDecorator;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface AuthService {
|
|
2
|
+
isAdmin(userID: string): Promise<boolean>;
|
|
3
|
+
isAuthorized(identity: any, notificationId: string): Promise<boolean>;
|
|
4
|
+
checkOwnershipAddress(userIdList: string[], addressIdList: string[]): Promise<boolean>;
|
|
5
|
+
checkOwnershipBrand(userIdList: string[], brandIdList: string[]): Promise<boolean>;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.interface.js","sourceRoot":"","sources":["../../src/service/auth.service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AuthServiceImpl = void 0;
|
|
19
|
+
exports.Authorize = Authorize;
|
|
20
|
+
const typedi_1 = require("typedi");
|
|
21
|
+
const index_1 = require("../index");
|
|
22
|
+
let AuthServiceImpl = class AuthServiceImpl {
|
|
23
|
+
checkOwnershipAddress(userIdList, addressIdList) {
|
|
24
|
+
throw new Error("Method not implemented.");
|
|
25
|
+
}
|
|
26
|
+
isAuthorized(identity, notificationId) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return true;
|
|
29
|
+
//todo implement isAuthorized
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
checkOwnershipBrand(userIdList, brandIdList) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
// todo get brands of profile and check param brandId exist or userId is one of admin
|
|
35
|
+
// const addressListOfBrand = await this.addressRepoDB.findByBrandID(brandId);
|
|
36
|
+
//
|
|
37
|
+
// const address = addressListOfBrand.find((addr) => addr.id === addressId);
|
|
38
|
+
//
|
|
39
|
+
// if (!address) throw new Error(`Address with ID ${addressId} not found for brand ${brandId}`);
|
|
40
|
+
//
|
|
41
|
+
// return address;
|
|
42
|
+
return true;
|
|
43
|
+
//todo implement checkPermissionUserBrand
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
isAdmin(userID) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return true;
|
|
49
|
+
//todo implement isAdmin
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.AuthServiceImpl = AuthServiceImpl;
|
|
54
|
+
exports.AuthServiceImpl = AuthServiceImpl = __decorate([
|
|
55
|
+
(0, typedi_1.Service)("AuthService")
|
|
56
|
+
], AuthServiceImpl);
|
|
57
|
+
function Authorize() {
|
|
58
|
+
return (target, propertyKey, descriptor) => {
|
|
59
|
+
if (descriptor === undefined) {
|
|
60
|
+
throw new Error("Authorize decorator can only be applied to methods.");
|
|
61
|
+
}
|
|
62
|
+
const originalMethod = descriptor.value;
|
|
63
|
+
descriptor.value = function (...args) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
if ((0, index_1.isMethodeHasKeyword)(propertyKey.toString(), [
|
|
66
|
+
"create",
|
|
67
|
+
"update",
|
|
68
|
+
"put",
|
|
69
|
+
"insert",
|
|
70
|
+
"get",
|
|
71
|
+
"find",
|
|
72
|
+
"delete",
|
|
73
|
+
"list",
|
|
74
|
+
])) {
|
|
75
|
+
// const hasPermission = await checkPermission(args);
|
|
76
|
+
// // const hasPermission = false;
|
|
77
|
+
// if (!hasPermission) {
|
|
78
|
+
// throw new Error(
|
|
79
|
+
// "User does not have permission to access this resource."
|
|
80
|
+
// );
|
|
81
|
+
// }
|
|
82
|
+
}
|
|
83
|
+
// Rufe die ursprüngliche Methode auf
|
|
84
|
+
return originalMethod.apply(this, args);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
return descriptor;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/service/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,8BAwCC;AA/ED,mCAAiC;AACjC,oCAA+C;AAGxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,qBAAqB,CACnB,UAAoB,EACpB,aAAuB;QAEvB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAEK,YAAY,CAAC,QAAa,EAAE,cAAsB;;YACtD,OAAO,IAAI,CAAC;YACZ,6BAA6B;QAC/B,CAAC;KAAA;IAEK,mBAAmB,CACvB,UAAoB,EACpB,WAAqB;;YAErB,qFAAqF;YACrF,8EAA8E;YAC9E,EAAE;YACF,4EAA4E;YAC5E,EAAE;YACF,gGAAgG;YAChG,EAAE;YACF,kBAAkB;YAClB,OAAO,IAAI,CAAC;YACZ,yCAAyC;QAC3C,CAAC;KAAA;IAEK,OAAO,CAAC,MAAc;;YAC1B,OAAO,IAAI,CAAC;YACZ,wBAAwB;QAC1B,CAAC;KAAA;CACF,CAAA;AAjCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,EAAC,aAAa,CAAC;GACV,eAAe,CAiC3B;AAED,SAAgB,SAAS;IACvB,OAAO,CACL,MAAM,EACN,WAAW,EACX,UAA8B,EACV,EAAE;QACtB,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,UAAgB,GAAG,IAAW;;gBAC/C,IACE,IAAA,2BAAmB,EAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;oBAC1C,QAAQ;oBACR,QAAQ;oBACR,KAAK;oBACL,QAAQ;oBACR,KAAK;oBACL,MAAM;oBACN,QAAQ;oBACR,MAAM;iBACP,CAAC,EACF,CAAC;oBACD,qDAAqD;oBACrD,kCAAkC;oBAClC,wBAAwB;oBACxB,qBAAqB;oBACrB,+DAA+D;oBAC/D,OAAO;oBACP,IAAI;gBACN,CAAC;gBAED,qCAAqC;gBACrC,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC1C,CAAC;SAAA,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BaseEntity, BaseRepoDB, BaseRepoES, BaseService, DynamoIndexMap, FilterAndSort, List } from "../index";
|
|
2
|
+
import { BaseSocketServiceIml } from "./socket.service";
|
|
3
|
+
import { SchemaValidation } from "../model/schema-validation";
|
|
4
|
+
export declare abstract class BaseServiceImpl<T extends BaseEntity, D extends BaseRepoDB<T>, S extends BaseRepoES<T>, R = any> extends BaseSocketServiceIml<R> implements BaseService<T, R> {
|
|
5
|
+
protected repoDB: D;
|
|
6
|
+
protected repoES: S;
|
|
7
|
+
private schemaMap;
|
|
8
|
+
protected constructor(repoDB: D, repoES: S, validationSchemaMap?: Map<string, SchemaValidation>);
|
|
9
|
+
incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;
|
|
10
|
+
decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;
|
|
11
|
+
find(filter: FilterAndSort): Promise<List<Partial<T>>>;
|
|
12
|
+
search(filter: FilterAndSort): Promise<Partial<T>[]>;
|
|
13
|
+
save(userId: string, entity: Partial<T>): Promise<T>;
|
|
14
|
+
saveAll(userId: string, entities: Partial<T>[]): Promise<Partial<T>[]>;
|
|
15
|
+
update(userId: string, entity: T, fields: string[]): Promise<T>;
|
|
16
|
+
updateAll(userId: string, entities: Partial<T>[], fields: string[]): Promise<boolean>;
|
|
17
|
+
remove(userId: string, entityId: string): Promise<boolean>;
|
|
18
|
+
removeAll(userId: string, entityIds: string[]): Promise<boolean>;
|
|
19
|
+
findById(userId: string, entityId: string): Promise<T>;
|
|
20
|
+
findByIds(userId: string, entityIds: string[]): Promise<T[]>;
|
|
21
|
+
changeOwner(userId: string, ownerId: string, entityId: string): Promise<T>;
|
|
22
|
+
setTable(tableName: string, dynamoIndexMap: DynamoIndexMap): boolean;
|
|
23
|
+
setOpensearch(indexName: string, opensearchEndpoint: string): boolean;
|
|
24
|
+
setValidationSchemaMap(validationSchemaMap: Map<string, SchemaValidation>): boolean;
|
|
25
|
+
getIndexES(): string;
|
|
26
|
+
getIndexMapDB(): DynamoIndexMap;
|
|
27
|
+
findAll(): Promise<List<T>>;
|
|
28
|
+
findByField(fieldName: string, fieldValue: any): Promise<List<T>>;
|
|
29
|
+
findFirst(fieldName: string, fieldValue: string | boolean | number | Date): Promise<T>;
|
|
30
|
+
throwErrorHttp(error: {
|
|
31
|
+
message: string;
|
|
32
|
+
code: number;
|
|
33
|
+
}, message?: string, errorContent?: any): void;
|
|
34
|
+
throwErrorDatabase(tableName: string, command: any, errorContent?: any): void;
|
|
35
|
+
throwErrorValidation(entityName: string, validation: Map<string, any>, errorContent?: any): void;
|
|
36
|
+
throwError(code: number, message: string, errorContent?: any): void;
|
|
37
|
+
validate(entity: Partial<T>, fields?: string[]): boolean;
|
|
38
|
+
private validateMany;
|
|
39
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BaseEntity, BaseSocketService, DynamoIndexMap, FilterAndSort, List } from "../index";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a generic base service interface for working with entities in both
|
|
4
|
+
* DynamoDB and OpenSearch.
|
|
5
|
+
*/
|
|
6
|
+
export interface BaseService<T extends BaseEntity, R = any> extends BaseSocketService<R> {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new entity for the given user.
|
|
9
|
+
* @param userId - The ID of the user who owns the entity.
|
|
10
|
+
* @param entity - The entity to be created.
|
|
11
|
+
* @returns The created entity.
|
|
12
|
+
*/
|
|
13
|
+
save(userId: string, entity: Partial<T>): Promise<Partial<T>>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates multiple new entities for the given user.
|
|
16
|
+
* @param userId - The ID of the user who owns the entities.
|
|
17
|
+
* @param entity - An array of entities to be created.
|
|
18
|
+
* @returns An array of created entities.
|
|
19
|
+
*/
|
|
20
|
+
saveAll(userId: string, entity: Partial<T>[]): Promise<Partial<T>[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Applies partial updates to an entity for the given user.
|
|
23
|
+
* Only the specified fields will be updated.
|
|
24
|
+
* @param userId - The ID of the user who owns the entity.
|
|
25
|
+
* @param entity - The entity with updated fields.
|
|
26
|
+
* @param fields - The list of field names to update.
|
|
27
|
+
* @returns The updated entity.
|
|
28
|
+
*/
|
|
29
|
+
update(userId: string, entity: T, fields: string[]): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Applies partial updates to multiple entities for the given user.
|
|
32
|
+
* Only the specified fields will be updated for each entity.
|
|
33
|
+
* @param userId - The ID of the user who owns the entities.
|
|
34
|
+
* @param entity - An array of entities with updated fields.
|
|
35
|
+
* @param fields - The list of field names to update in each entity.
|
|
36
|
+
* @returns True if all entities were successfully updated.
|
|
37
|
+
*/
|
|
38
|
+
updateAll(userId: string, entity: T[], fields: string[]): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Deletes an entity by ID for the given user.
|
|
41
|
+
* @param userId - The ID of the user who owns the entity.
|
|
42
|
+
* @param entityId - The ID of the entity to delete.
|
|
43
|
+
* @returns True if the entity was successfully deleted.
|
|
44
|
+
*/
|
|
45
|
+
remove(userId: string, entityId: string): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Deletes multiple entities by their IDs for the given user.
|
|
48
|
+
* @param userId - The ID of the user who owns the entities.
|
|
49
|
+
* @param entityIds - An array of entity IDs to delete.
|
|
50
|
+
* @returns True if all entities were successfully deleted.
|
|
51
|
+
*/
|
|
52
|
+
removeAll(userId: string, entityIds: string[]): Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves an entity by its ID for the given user.
|
|
55
|
+
* @param userId - The ID of the user who owns the entity.
|
|
56
|
+
* @param entityId - The ID of the entity to retrieve.
|
|
57
|
+
* @returns The requested entity.
|
|
58
|
+
*/
|
|
59
|
+
findById(userId: string, entityId: string): Promise<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves multiple entities by their IDs for the given user.
|
|
62
|
+
* @param userId - The ID of the user who owns the entities.
|
|
63
|
+
* @param entityIds - An array of entity IDs to retrieve.
|
|
64
|
+
* @returns An array of found entities.
|
|
65
|
+
*/
|
|
66
|
+
findByIds(userId: string, entityIds: string[]): Promise<T[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves a paginated and filtered list of entities from DynamoDB.
|
|
69
|
+
*
|
|
70
|
+
* @param filter - Filtering and sorting options.
|
|
71
|
+
* @returns A promise resolving to a paginated list of entities.
|
|
72
|
+
*/
|
|
73
|
+
find(filter: FilterAndSort): Promise<List<Partial<T>>>;
|
|
74
|
+
findAll(): Promise<List<T>>;
|
|
75
|
+
findByField(fieldName: string, fieldValue: any): Promise<List<T>>;
|
|
76
|
+
findFirst(fieldName: string, fieldValue: string | boolean | number | Date): Promise<T>;
|
|
77
|
+
validate(entity: any, ignoreFields?: string[]): boolean;
|
|
78
|
+
throwError(code: number, message: string, errorContent?: any): void;
|
|
79
|
+
throwErrorHttp(error: {
|
|
80
|
+
message: string;
|
|
81
|
+
code: number;
|
|
82
|
+
}, message: string, errorContent?: any): void;
|
|
83
|
+
throwErrorDatabase(tableName: string, command: any, errorContent?: any): void;
|
|
84
|
+
throwErrorValidation(entityName: string, validation: Map<string, any>, errorContent?: any): void;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves a filtered and sorted list of entities from OpenSearch.
|
|
87
|
+
*
|
|
88
|
+
* @param filter - Filtering and sorting options.
|
|
89
|
+
* @returns A promise resolving to the list of matching entities.
|
|
90
|
+
*/
|
|
91
|
+
search(filter: FilterAndSort): Promise<Partial<T>[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Changes the owner of an entity.
|
|
94
|
+
* @param userId - The current owner of the entity.
|
|
95
|
+
* @param ownerId - The new owner's ID.
|
|
96
|
+
* @param entityId - The ID of the entity to transfer.
|
|
97
|
+
* @returns The updated entity with the new owner.
|
|
98
|
+
*/
|
|
99
|
+
changeOwner(userId: string, ownerId: string, entityId: string): Promise<T>;
|
|
100
|
+
setTable(tableName: string, dynamoIndexMap: DynamoIndexMap): boolean;
|
|
101
|
+
setOpensearch(indexName: string, opensearchEndpoint: string): boolean;
|
|
102
|
+
getIndexES(): string;
|
|
103
|
+
getIndexMapDB(): DynamoIndexMap;
|
|
104
|
+
incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;
|
|
105
|
+
decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.service.interface.js","sourceRoot":"","sources":["../../src/service/base.service.interface.ts"],"names":[],"mappings":""}
|