@futdevpro/nts-dynamo 1.6.39 → 1.6.41
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/lib/_constants/global-settings.const.js +1 -1
- package/lib/_constants/global-settings.const.js.map +1 -1
- package/lib/_constants/mocks/app-params.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/app-params.mock.js.map +1 -1
- package/lib/_constants/mocks/app-server.mock.d.ts +15 -0
- package/lib/_constants/mocks/app-server.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/app-server.mock.js +57 -1
- package/lib/_constants/mocks/app-server.mock.js.map +1 -1
- package/lib/_constants/mocks/data-model.mock.d.ts +4 -4
- package/lib/_constants/mocks/data-model.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/data-model.mock.js +5 -5
- package/lib/_constants/mocks/data-model.mock.js.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.d.ts +1 -0
- package/lib/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.js +33 -22
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-event.control-model.js +2 -2
- package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
- package/lib/_services/base/data.service.d.ts +1 -0
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +36 -226
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +1 -0
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +15 -9
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/base/db.service.spec.d.ts +1 -0
- package/lib/_services/base/db.service.spec.d.ts.map +1 -0
- package/lib/_services/base/db.service.spec.js +7 -0
- package/lib/_services/base/db.service.spec.js.map +1 -0
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +2 -1
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/server/app.server.spec.js.map +1 -1
- package/lib/_services/socket/socket-server.service.d.ts +1 -0
- package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
- package/lib/_services/socket/socket-server.service.js +20 -17
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_constants/global-settings.const.ts +1 -1
- package/src/_constants/mocks/app-params.mock.ts +1 -1
- package/src/_constants/mocks/app-server.mock.ts +74 -1
- package/src/_constants/mocks/data-model.mock.ts +4 -4
- package/src/_models/control-models/endpoint-params.control-model.ts +34 -16
- package/src/_models/control-models/socket-event.control-model.ts +2 -2
- package/src/_services/base/data.service.ts +99 -148
- package/src/_services/base/db.service.spec.ts +9 -0
- package/src/_services/base/db.service.ts +20 -9
- package/src/_services/server/app.server.spec.ts +1 -2
- package/src/_services/server/app.server.ts +3 -3
- package/src/_services/socket/socket-server.service.ts +38 -13
|
@@ -103,4 +103,77 @@ export class DynamoNTS_AppFull_Mock extends DynamoNTS_App {
|
|
|
103
103
|
async getRootServices(): Promise<DynamoNTS_SingletonService[]> {
|
|
104
104
|
return [];
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
////////////////////////////////////////////////////////////////////
|
|
109
|
+
////////////////////////////////////////////////////////////////////
|
|
110
|
+
////////////////////////////////////////////////////////////////////
|
|
111
|
+
|
|
112
|
+
export class DynamoNTS_AppTEST_Mock extends DynamoNTS_App {
|
|
113
|
+
constructor(
|
|
114
|
+
overrides: {
|
|
115
|
+
getAppParams?(): DynamoNTS_AppParams;
|
|
116
|
+
getGlobalServiceCollection?(): DynamoNTS_GlobalServiceSettings;
|
|
117
|
+
getPortSettings?(): DynamoNTS_PortSettings;
|
|
118
|
+
getRoutingModules?(): DynamoNTS_RoutingModule[];
|
|
119
|
+
getRootServices?(): Promise<DynamoNTS_SingletonService[]>;
|
|
120
|
+
}
|
|
121
|
+
) {
|
|
122
|
+
if (overrides.getAppParams) {
|
|
123
|
+
DynamoNTS_App.prototype.getAppParams = overrides.getAppParams;
|
|
124
|
+
}
|
|
125
|
+
if (overrides.getGlobalServiceCollection) {
|
|
126
|
+
DynamoNTS_App.prototype.getGlobalServiceCollection = overrides.getGlobalServiceCollection;
|
|
127
|
+
}
|
|
128
|
+
if (overrides.getPortSettings) {
|
|
129
|
+
DynamoNTS_App.prototype.getPortSettings = overrides.getPortSettings;
|
|
130
|
+
}
|
|
131
|
+
if (overrides.getRoutingModules) {
|
|
132
|
+
DynamoNTS_App.prototype.getRoutingModules = overrides.getRoutingModules;
|
|
133
|
+
}
|
|
134
|
+
if (overrides.getRootServices) {
|
|
135
|
+
DynamoNTS_App.prototype.getRootServices = overrides.getRootServices;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
super();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getAppParams(): DynamoNTS_AppParams {
|
|
142
|
+
return new DynamoNTS_AppParams({
|
|
143
|
+
name: 'test-partial',
|
|
144
|
+
version: 'p.0.1',
|
|
145
|
+
dbName: 'test-partial',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
overrideDynamoNTSGlobalSettings(): void {}
|
|
150
|
+
|
|
151
|
+
getGlobalServiceCollection(): DynamoNTS_GlobalServiceSettings {
|
|
152
|
+
return {
|
|
153
|
+
authService: AuthService_Mock.getInstance(),
|
|
154
|
+
dbModels: [
|
|
155
|
+
dependency_mock_DataParams,
|
|
156
|
+
dependent_mock_DataParams,
|
|
157
|
+
|
|
158
|
+
usageSessionModelParams,
|
|
159
|
+
customDataModelParams,
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
getPortSettings(): DynamoNTS_PortSettings {
|
|
165
|
+
return {
|
|
166
|
+
httpPort: 10203,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
getRoutingModules(): DynamoNTS_RoutingModule[] {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async getRootServices(): Promise<DynamoNTS_SingletonService[]> {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dynamo_DataParams, Dynamo_Metadata } from '@futdevpro/fsm-dynamo';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class Dependency_Mock extends Dynamo_Metadata {
|
|
5
5
|
string?: string;
|
|
6
6
|
number?: number;
|
|
7
7
|
date?: Date;
|
|
@@ -12,7 +12,7 @@ export class Depemndency_Mock extends Dynamo_Metadata {
|
|
|
12
12
|
objectArrayArray?: any[][];
|
|
13
13
|
|
|
14
14
|
constructor(
|
|
15
|
-
set?:
|
|
15
|
+
set?: Dependent_Mock
|
|
16
16
|
) {
|
|
17
17
|
super(set);
|
|
18
18
|
|
|
@@ -40,7 +40,7 @@ export const dependency_mock_DataParams = new Dynamo_DataParams({
|
|
|
40
40
|
////////////////////////////////////////////////////////////////////
|
|
41
41
|
////////////////////////////////////////////////////////////////////
|
|
42
42
|
|
|
43
|
-
export class
|
|
43
|
+
export class Dependent_Mock extends Dynamo_Metadata {
|
|
44
44
|
dependencyId?: string;
|
|
45
45
|
|
|
46
46
|
string?: string;
|
|
@@ -53,7 +53,7 @@ export class Depemndent_Mock extends Dynamo_Metadata {
|
|
|
53
53
|
objectArrayArray?: any[][];
|
|
54
54
|
|
|
55
55
|
constructor(
|
|
56
|
-
set?:
|
|
56
|
+
set?: Dependent_Mock
|
|
57
57
|
) {
|
|
58
58
|
super(set);
|
|
59
59
|
|
|
@@ -105,7 +105,7 @@ export class DynamoNTS_EndpointParams{
|
|
|
105
105
|
|
|
106
106
|
this.logRequest = set.logRequest ?? dynamoNTS_globalSettings.logRequest;
|
|
107
107
|
this.logRequestsContent = set.logRequestsContent ?? dynamoNTS_globalSettings.logRequestsContent;
|
|
108
|
-
this.logResponseContent = set.logResponseContent ?? dynamoNTS_globalSettings.logResponseContent;
|
|
108
|
+
/* this.logResponseContent = set.logResponseContent ?? dynamoNTS_globalSettings.logResponseContent; */
|
|
109
109
|
} catch (error) {
|
|
110
110
|
Dynamo_Log.error(
|
|
111
111
|
`\nEndpoint params setup failed: name: '${set.name}' (security: ${set.security}) endpoint: ${set.endpoint}\nERROR:\n`, error);
|
|
@@ -121,21 +121,22 @@ export class DynamoNTS_EndpointParams{
|
|
|
121
121
|
try {
|
|
122
122
|
if (this.logRequest) {
|
|
123
123
|
if (this.logRequestsContent) {
|
|
124
|
-
|
|
124
|
+
const params = this.getPathParamsLogContent(req);
|
|
125
|
+
/* let params = '';
|
|
125
126
|
for(let i = 0; i < this.pathParams.length; i++) {
|
|
126
|
-
|
|
127
|
-
if (i + 1 < this.pathParams.length
|
|
128
|
-
|
|
127
|
+
params += `\n ${this.pathParams[i]}: ${req.params[this.pathParams[i]]}`;
|
|
128
|
+
if (i + 1 < this.pathParams.length) {
|
|
129
|
+
params += ',';
|
|
129
130
|
}
|
|
130
|
-
}
|
|
131
|
+
} */
|
|
131
132
|
|
|
132
133
|
if (req.body && 0 < Object.keys(req.body).length) {
|
|
133
|
-
console.log(
|
|
134
|
+
console.log(`===> incoming ${this.name} request...\npathParams:${params}\nbody:`, req.body);
|
|
134
135
|
} else {
|
|
135
|
-
console.log(
|
|
136
|
+
console.log(`===> incoming ${this.name} request...\npathParams:${params}`);
|
|
136
137
|
}
|
|
137
138
|
} else {
|
|
138
|
-
console.log(
|
|
139
|
+
console.log(`===> incoming ${this.name} request...`);
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
|
|
@@ -191,17 +192,24 @@ export class DynamoNTS_EndpointParams{
|
|
|
191
192
|
private error(req: Request, res: Response, error: Error | Dynamo_Error): void {
|
|
192
193
|
try {
|
|
193
194
|
let msg: string = `Endpoint catched an error. ${this.name} (${this.endpoint})`;
|
|
194
|
-
this.pathParams.forEach((param: string) => {
|
|
195
|
+
/* this.pathParams.forEach((param: string) => {
|
|
195
196
|
msg += `\n${param}: ${req.params[param]}`;
|
|
196
|
-
});
|
|
197
|
+
}); */
|
|
198
|
+
msg += this.getPathParamsLogContent(req);
|
|
197
199
|
msg += `\nERROR:`;
|
|
198
200
|
|
|
199
201
|
Dynamo_Log.error(msg);
|
|
200
|
-
console.log(
|
|
201
|
-
|
|
202
|
+
console.log(
|
|
203
|
+
(error as Dynamo_Error)?.flag.includes('DYNAMO') ?
|
|
204
|
+
(error as Dynamo_Error).getErrorSimplified() :
|
|
205
|
+
error,
|
|
206
|
+
'\n'
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
/* if (this.logRequest && req.body && 0 < Object.keys(req.body).length) {
|
|
202
210
|
console.log('body: ');
|
|
203
211
|
console.log(req.body, '\n');
|
|
204
|
-
}
|
|
212
|
+
} */
|
|
205
213
|
|
|
206
214
|
res.status((error as Dynamo_Error)?.___status ?? 501);
|
|
207
215
|
res.send(error);
|
|
@@ -209,14 +217,14 @@ export class DynamoNTS_EndpointParams{
|
|
|
209
217
|
if (this.logRequest) {
|
|
210
218
|
if (this.logResponseContent) {
|
|
211
219
|
Dynamo_Log.error(
|
|
212
|
-
` <<<===== ${this.name} error sent
|
|
220
|
+
` <<<===== ${this.name} error sent: ${(error as Dynamo_Error)?._message ?? ''}`
|
|
213
221
|
);
|
|
214
222
|
Dynamo_Log.error(
|
|
215
223
|
'sorry, the logResponseContent is not implemented yet.'
|
|
216
224
|
);
|
|
217
225
|
} else {
|
|
218
226
|
Dynamo_Log.error(
|
|
219
|
-
` <<<===== ${this.name} error sent
|
|
227
|
+
` <<<===== ${this.name} error sent: ${(error as Dynamo_Error)?._message ?? ''}`
|
|
220
228
|
);
|
|
221
229
|
}
|
|
222
230
|
}
|
|
@@ -227,6 +235,16 @@ export class DynamoNTS_EndpointParams{
|
|
|
227
235
|
);
|
|
228
236
|
}
|
|
229
237
|
}
|
|
238
|
+
|
|
239
|
+
private getPathParamsLogContent(req: Request): string {
|
|
240
|
+
let params: string = '';
|
|
241
|
+
|
|
242
|
+
this.pathParams.forEach((param: string) => {
|
|
243
|
+
params += `\n${param}: ${req.params[param]}\n`;
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
return params;
|
|
247
|
+
}
|
|
230
248
|
}
|
|
231
249
|
|
|
232
250
|
|
|
@@ -94,9 +94,9 @@ export class DynamoNTS_SocketEvent<T>{
|
|
|
94
94
|
private async getPreLog(content: T, issuer?: string): Promise<void> {
|
|
95
95
|
try {
|
|
96
96
|
if (this.logEventContent && this.eventType !== DynamoNTS_SocketEventType.connection) {
|
|
97
|
-
Dynamo_Log.log(
|
|
97
|
+
Dynamo_Log.log(`---> incoming socket(${this.socketName}) event: ${this.eventType};\ncontent:`, content);
|
|
98
98
|
} else {
|
|
99
|
-
Dynamo_Log.log(
|
|
99
|
+
Dynamo_Log.log(`---> incoming socket(${this.socketName}) event: ${this.eventType}...`);
|
|
100
100
|
}
|
|
101
101
|
} catch (error) {
|
|
102
102
|
Dynamo_Log.error(`PreLog failed... (socket: ${this.socketName})`, error);
|
|
@@ -94,14 +94,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
94
94
|
return dataListExists;
|
|
95
95
|
} catch (error) {
|
|
96
96
|
throw new Dynamo_Error({
|
|
97
|
-
|
|
97
|
+
...this.getDefaultErrorSettings('getAll', error),
|
|
98
|
+
|
|
98
99
|
errorCode: 'NTS-DS0-GA0',
|
|
99
|
-
addECToUserMsg: true,
|
|
100
|
-
message: `getAll was unsuccessful (${this.dataParams.dataName})`,
|
|
101
|
-
userMessage: this.defaultErrorUserMsg,
|
|
102
|
-
issuer: this.issuer,
|
|
103
|
-
issuerService: this.serviceName,
|
|
104
|
-
error: error
|
|
105
100
|
});
|
|
106
101
|
}
|
|
107
102
|
}
|
|
@@ -126,13 +121,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
126
121
|
try {
|
|
127
122
|
if (!id && !this.data._id) {
|
|
128
123
|
throw new Dynamo_Error({
|
|
129
|
-
|
|
124
|
+
...this.getDefaultErrorSettings(
|
|
125
|
+
'getDataById',
|
|
126
|
+
new Error(`getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`)
|
|
127
|
+
),
|
|
128
|
+
|
|
130
129
|
errorCode: 'NTS-DS0-GI1',
|
|
131
|
-
addECToUserMsg: true,
|
|
132
|
-
message: `getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`,
|
|
133
|
-
userMessage: this.defaultErrorUserMsg,
|
|
134
|
-
issuer: this.issuer,
|
|
135
|
-
issuerService: this.serviceName,
|
|
136
130
|
});
|
|
137
131
|
}
|
|
138
132
|
|
|
@@ -147,14 +141,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
147
141
|
throw error;
|
|
148
142
|
} else {
|
|
149
143
|
throw new Dynamo_Error({
|
|
150
|
-
|
|
144
|
+
...this.getDefaultErrorSettings('getDataById', error),
|
|
145
|
+
|
|
151
146
|
errorCode: 'NTS-DS0-GI0',
|
|
152
|
-
addECToUserMsg: true,
|
|
153
|
-
message: `getDataById was unsuccessful (${this.dataParams.dataName})`,
|
|
154
|
-
userMessage: this.defaultErrorUserMsg,
|
|
155
|
-
issuer: this.issuer,
|
|
156
|
-
issuerService: this.serviceName,
|
|
157
|
-
error: error
|
|
158
147
|
});
|
|
159
148
|
}
|
|
160
149
|
}
|
|
@@ -169,25 +158,23 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
169
158
|
try {
|
|
170
159
|
if (!this.depKey) {
|
|
171
160
|
throw new Dynamo_Error({
|
|
172
|
-
|
|
161
|
+
...this.getDefaultErrorSettings(
|
|
162
|
+
'getDataByDependencyId',
|
|
163
|
+
new Error(`getDataByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
|
|
164
|
+
),
|
|
165
|
+
|
|
173
166
|
errorCode: 'NTS-DS0-GD1',
|
|
174
|
-
addECToUserMsg: true,
|
|
175
|
-
message: `getDataByDependencyId failed, dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
|
|
176
|
-
userMessage: this.defaultErrorUserMsg,
|
|
177
|
-
issuer: this.issuer,
|
|
178
|
-
issuerService: this.serviceName,
|
|
179
167
|
});
|
|
180
168
|
}
|
|
181
169
|
|
|
182
170
|
if (!dependencyId && !this.data[this.depKey]) {
|
|
183
171
|
throw new Dynamo_Error({
|
|
184
|
-
|
|
172
|
+
...this.getDefaultErrorSettings(
|
|
173
|
+
'getDataByDependencyId',
|
|
174
|
+
new Error(`getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
|
|
175
|
+
),
|
|
176
|
+
|
|
185
177
|
errorCode: 'NTS-DS0-GD2',
|
|
186
|
-
addECToUserMsg: true,
|
|
187
|
-
message: `getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`,
|
|
188
|
-
userMessage: this.defaultErrorUserMsg,
|
|
189
|
-
issuer: this.issuer,
|
|
190
|
-
issuerService: this.serviceName,
|
|
191
178
|
});
|
|
192
179
|
}
|
|
193
180
|
|
|
@@ -209,14 +196,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
209
196
|
throw error;
|
|
210
197
|
} else {
|
|
211
198
|
throw new Dynamo_Error({
|
|
212
|
-
|
|
199
|
+
...this.getDefaultErrorSettings('getDataByDependencyId', error),
|
|
200
|
+
|
|
213
201
|
errorCode: 'NTS-DS0-GD0',
|
|
214
|
-
addECToUserMsg: true,
|
|
215
|
-
message: `getDataByDependencyId was unsuccessful (${this.dataParams.dataName})`,
|
|
216
|
-
userMessage: this.defaultErrorUserMsg,
|
|
217
|
-
issuer: this.issuer,
|
|
218
|
-
issuerService: this.serviceName,
|
|
219
|
-
error: error
|
|
220
202
|
});
|
|
221
203
|
}
|
|
222
204
|
}
|
|
@@ -230,25 +212,23 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
230
212
|
try {
|
|
231
213
|
if (!this.depKey) {
|
|
232
214
|
throw new Dynamo_Error({
|
|
233
|
-
|
|
215
|
+
...this.getDefaultErrorSettings(
|
|
216
|
+
'getDataListByDependencyId',
|
|
217
|
+
new Error(`getDataListByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
|
|
218
|
+
),
|
|
219
|
+
|
|
234
220
|
errorCode: 'NTS-DS0-GLD1',
|
|
235
|
-
addECToUserMsg: true,
|
|
236
|
-
message: `dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
|
|
237
|
-
userMessage: this.defaultErrorUserMsg,
|
|
238
|
-
issuer: this.issuer,
|
|
239
|
-
issuerService: this.serviceName,
|
|
240
221
|
});
|
|
241
222
|
}
|
|
242
223
|
|
|
243
224
|
if (!dependencyId && !this.data[this.depKey]) {
|
|
244
225
|
throw new Dynamo_Error({
|
|
245
|
-
|
|
226
|
+
...this.getDefaultErrorSettings(
|
|
227
|
+
'getDataListByDependencyId',
|
|
228
|
+
new Error(`getDataListByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
|
|
229
|
+
),
|
|
230
|
+
|
|
246
231
|
errorCode: 'NTS-DS0-GLD2',
|
|
247
|
-
addECToUserMsg: true,
|
|
248
|
-
message: `getDataListByDependencyId failed, ${this.depKey} is missing (${this.dataParams.dataName})`,
|
|
249
|
-
userMessage: this.defaultErrorUserMsg,
|
|
250
|
-
issuer: this.issuer,
|
|
251
|
-
issuerService: this.serviceName,
|
|
252
232
|
});
|
|
253
233
|
}
|
|
254
234
|
|
|
@@ -270,14 +250,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
270
250
|
throw error;
|
|
271
251
|
} else {
|
|
272
252
|
throw new Dynamo_Error({
|
|
273
|
-
|
|
253
|
+
...this.getDefaultErrorSettings('getDataListByDependencyId', error),
|
|
254
|
+
|
|
274
255
|
errorCode: 'NTS-DS0-GLD0',
|
|
275
|
-
addECToUserMsg: true,
|
|
276
|
-
message: `getDataListByDependencyId was unsuccessful (${this.dataParams.dataName})`,
|
|
277
|
-
userMessage: this.defaultErrorUserMsg,
|
|
278
|
-
issuer: this.issuer,
|
|
279
|
-
issuerService: this.serviceName,
|
|
280
|
-
error: error
|
|
281
256
|
});
|
|
282
257
|
}
|
|
283
258
|
}
|
|
@@ -330,14 +305,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
330
305
|
return dataExists;
|
|
331
306
|
} catch (error) {
|
|
332
307
|
throw new Dynamo_Error({
|
|
333
|
-
|
|
308
|
+
...this.getDefaultErrorSettings('findData', error),
|
|
309
|
+
|
|
334
310
|
errorCode: 'NTS-DS0-FD0',
|
|
335
|
-
addECToUserMsg: true,
|
|
336
|
-
message: `findData was unsuccessful (${this.dataParams.dataName})`,
|
|
337
|
-
userMessage: this.defaultErrorUserMsg,
|
|
338
|
-
issuer: this.issuer,
|
|
339
|
-
issuerService: this.serviceName,
|
|
340
|
-
error: error
|
|
341
311
|
});
|
|
342
312
|
}
|
|
343
313
|
}
|
|
@@ -389,14 +359,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
389
359
|
return dataListExists;
|
|
390
360
|
} catch (error) {
|
|
391
361
|
throw new Dynamo_Error({
|
|
392
|
-
|
|
362
|
+
...this.getDefaultErrorSettings('findDatas', error),
|
|
363
|
+
|
|
393
364
|
errorCode: 'NTS-DS0-FDS0',
|
|
394
|
-
addECToUserMsg: true,
|
|
395
|
-
message: `findDatas was unsuccessful (${this.dataParams.dataName})`,
|
|
396
|
-
userMessage: this.defaultErrorUserMsg,
|
|
397
|
-
issuer: this.issuer,
|
|
398
|
-
issuerService: this.serviceName,
|
|
399
|
-
error: error
|
|
400
365
|
});
|
|
401
366
|
}
|
|
402
367
|
}
|
|
@@ -467,13 +432,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
467
432
|
await this.dataDBService.updateOne({ [this.depKey]: this.data[this.depKey] } as DynamoNTS_DBFilter<T>, set.update, this.issuer);
|
|
468
433
|
} else {
|
|
469
434
|
throw new Dynamo_Error({
|
|
470
|
-
|
|
435
|
+
...this.getDefaultErrorSettings(
|
|
436
|
+
'updateData',
|
|
437
|
+
new Error(`no usable parameter provided for updateData; no updateBy, no id, no dependencyId (${this.dataParams.dataName})`)
|
|
438
|
+
),
|
|
439
|
+
|
|
471
440
|
errorCode: 'NTS-DS0-UD1',
|
|
472
|
-
addECToUserMsg: true,
|
|
473
|
-
message: `no usable parameter provided for updateData; no updateBy, no id, no dependencyId (${this.dataParams.dataName})`,
|
|
474
|
-
userMessage: this.defaultErrorUserMsg,
|
|
475
|
-
issuer: this.issuer,
|
|
476
|
-
issuerService: this.serviceName,
|
|
477
441
|
});
|
|
478
442
|
}
|
|
479
443
|
} catch (error) {
|
|
@@ -481,14 +445,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
481
445
|
throw error;
|
|
482
446
|
} else {
|
|
483
447
|
throw new Dynamo_Error({
|
|
484
|
-
|
|
448
|
+
...this.getDefaultErrorSettings('updateData', error),
|
|
449
|
+
|
|
485
450
|
errorCode: 'NTS-DS0-UD0',
|
|
486
|
-
addECToUserMsg: true,
|
|
487
|
-
message: `updateData was unsuccessful (${this.dataParams.dataName})`,
|
|
488
|
-
userMessage: this.defaultErrorUserMsg,
|
|
489
|
-
issuer: this.issuer,
|
|
490
|
-
issuerService: this.serviceName,
|
|
491
|
-
error: error
|
|
492
451
|
});
|
|
493
452
|
}
|
|
494
453
|
}
|
|
@@ -509,13 +468,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
509
468
|
try {
|
|
510
469
|
if (!this.data) {
|
|
511
470
|
throw new Dynamo_Error({
|
|
512
|
-
|
|
471
|
+
...this.getDefaultErrorSettings('saveData', new Error(`no data to save! (${this.dataParams.dataName})`)),
|
|
472
|
+
|
|
513
473
|
errorCode: 'NTS-DS0-SD4',
|
|
514
|
-
addECToUserMsg: true,
|
|
515
|
-
message: `saveData was unsuccessful: no data to save!, (${this.dataParams.dataName})`,
|
|
516
|
-
userMessage: this.defaultErrorUserMsg,
|
|
517
|
-
issuer: this.issuer,
|
|
518
|
-
issuerService: this.serviceName,
|
|
519
474
|
});
|
|
520
475
|
}
|
|
521
476
|
|
|
@@ -536,13 +491,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
536
491
|
return;
|
|
537
492
|
} else {
|
|
538
493
|
throw new Dynamo_Error({
|
|
539
|
-
|
|
494
|
+
...this.getDefaultErrorSettings(
|
|
495
|
+
'saveData',
|
|
496
|
+
new Error(`saveData was unsuccessful: provided ID not exists (id: ${this.data._id}, ${this.dataParams.dataName})`)
|
|
497
|
+
),
|
|
498
|
+
|
|
540
499
|
errorCode: 'NTS-DS0-SD1',
|
|
541
|
-
addECToUserMsg: true,
|
|
542
|
-
message: `saveData was unsuccessful: provided ID not exists (id: ${this.data._id}, ${this.dataParams.dataName})`,
|
|
543
|
-
userMessage: this.defaultErrorUserMsg,
|
|
544
|
-
issuer: this.issuer,
|
|
545
|
-
issuerService: this.serviceName,
|
|
546
500
|
});
|
|
547
501
|
}
|
|
548
502
|
}
|
|
@@ -550,13 +504,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
550
504
|
if (this.depKey) {
|
|
551
505
|
if (!this.data[this.depKey]) {
|
|
552
506
|
throw new Dynamo_Error({
|
|
553
|
-
|
|
507
|
+
...this.getDefaultErrorSettings(
|
|
508
|
+
'saveData',
|
|
509
|
+
new Error(`saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey}, ${this.dataParams.dataName})`)
|
|
510
|
+
),
|
|
511
|
+
|
|
554
512
|
errorCode: 'NTS-DS0-SD2',
|
|
555
|
-
addECToUserMsg: true,
|
|
556
|
-
message: `saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey}, ${this.dataParams.dataName})`,
|
|
557
|
-
userMessage: this.defaultErrorUserMsg,
|
|
558
|
-
issuer: this.issuer,
|
|
559
|
-
issuerService: this.serviceName,
|
|
560
513
|
});
|
|
561
514
|
}
|
|
562
515
|
|
|
@@ -572,13 +525,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
572
525
|
const dependencyExists = await this.getDependencyDataDBService().getDataById(this.data[this.depKey]);
|
|
573
526
|
if(!dependencyExists) {
|
|
574
527
|
throw new Dynamo_Error({
|
|
575
|
-
|
|
528
|
+
...this.getDefaultErrorSettings(
|
|
529
|
+
'saveData',
|
|
530
|
+
new Error(`saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]}, ${this.dataParams.dataName})`)
|
|
531
|
+
),
|
|
532
|
+
|
|
576
533
|
errorCode: 'NTS-DS0-SD3',
|
|
577
|
-
addECToUserMsg: true,
|
|
578
|
-
message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]}, ${this.dataParams.dataName})`,
|
|
579
|
-
userMessage: this.defaultErrorUserMsg,
|
|
580
|
-
issuer: this.issuer,
|
|
581
|
-
issuerService: this.serviceName,
|
|
582
534
|
});
|
|
583
535
|
}
|
|
584
536
|
}
|
|
@@ -593,14 +545,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
593
545
|
throw error;
|
|
594
546
|
} else {
|
|
595
547
|
throw new Dynamo_Error({
|
|
596
|
-
|
|
548
|
+
...this.getDefaultErrorSettings('saveData', error),
|
|
549
|
+
|
|
597
550
|
errorCode: 'NTS-DS0-SD0',
|
|
598
|
-
addECToUserMsg: true,
|
|
599
|
-
message: `saveData was unsuccessful (${this.dataParams.dataName})`,
|
|
600
|
-
userMessage: this.defaultErrorUserMsg,
|
|
601
|
-
issuer: this.issuer,
|
|
602
|
-
issuerService: this.serviceName,
|
|
603
|
-
error: error
|
|
604
551
|
});
|
|
605
552
|
}
|
|
606
553
|
}
|
|
@@ -613,13 +560,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
613
560
|
try {
|
|
614
561
|
if (!this.data._id) {
|
|
615
562
|
throw new Dynamo_Error({
|
|
616
|
-
|
|
563
|
+
...this.getDefaultErrorSettings(
|
|
564
|
+
'deleteData',
|
|
565
|
+
new Error(`deleteData failed, ID is missing! (${this.dataParams.dataName})`)
|
|
566
|
+
),
|
|
567
|
+
|
|
617
568
|
errorCode: 'NTS-DS0-DD1',
|
|
618
|
-
addECToUserMsg: true,
|
|
619
|
-
message: `deleteData failed, ID is missing! (${this.dataParams.dataName})` ,
|
|
620
|
-
userMessage: this.defaultErrorUserMsg,
|
|
621
|
-
issuer: this.issuer,
|
|
622
|
-
issuerService: this.serviceName,
|
|
623
569
|
});
|
|
624
570
|
}
|
|
625
571
|
|
|
@@ -629,14 +575,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
629
575
|
throw error;
|
|
630
576
|
} else {
|
|
631
577
|
throw new Dynamo_Error({
|
|
632
|
-
|
|
578
|
+
...this.getDefaultErrorSettings('deleteData', error),
|
|
579
|
+
|
|
633
580
|
errorCode: 'NTS-DS0-DD0',
|
|
634
|
-
addECToUserMsg: true,
|
|
635
|
-
message: `deleteData was unsuccessful (${this.dataParams.dataName})`,
|
|
636
|
-
userMessage: this.defaultErrorUserMsg,
|
|
637
|
-
issuer: this.issuer,
|
|
638
|
-
issuerService: this.serviceName,
|
|
639
|
-
error: error
|
|
640
581
|
});
|
|
641
582
|
}
|
|
642
583
|
}
|
|
@@ -661,13 +602,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
661
602
|
)
|
|
662
603
|
) {
|
|
663
604
|
throw new Dynamo_Error({
|
|
605
|
+
...this.getDefaultErrorSettings(
|
|
606
|
+
'validateForSave',
|
|
607
|
+
new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.dataName})`)
|
|
608
|
+
),
|
|
609
|
+
|
|
664
610
|
status: 422,
|
|
665
611
|
errorCode: 'NTS-DS0-VD1',
|
|
666
|
-
addECToUserMsg: true,
|
|
667
|
-
message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.modelParams[i].required ? 'required' : 'index'}) (${this.dataParams.dataName})`,
|
|
668
612
|
userMessage: this.defaultValidationErrorUserMsg,
|
|
669
|
-
issuer: this.issuer,
|
|
670
|
-
issuerService: this.serviceName,
|
|
671
613
|
});
|
|
672
614
|
}
|
|
673
615
|
|
|
@@ -676,13 +618,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
676
618
|
!(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)
|
|
677
619
|
) {
|
|
678
620
|
throw new Dynamo_Error({
|
|
621
|
+
...this.getDefaultErrorSettings(
|
|
622
|
+
'validateForSave',
|
|
623
|
+
new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`)
|
|
624
|
+
),
|
|
625
|
+
|
|
679
626
|
status: 422,
|
|
680
627
|
errorCode: 'NTS-DS0-VD2',
|
|
681
|
-
addECToUserMsg: true,
|
|
682
|
-
message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`,
|
|
683
628
|
userMessage: this.defaultValidationErrorUserMsg,
|
|
684
|
-
issuer: this.issuer,
|
|
685
|
-
issuerService: this.serviceName,
|
|
686
629
|
});
|
|
687
630
|
}
|
|
688
631
|
|
|
@@ -698,14 +641,10 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
698
641
|
throw error;
|
|
699
642
|
} else {
|
|
700
643
|
throw new Dynamo_Error({
|
|
644
|
+
...this.getDefaultErrorSettings('validateForSave', error),
|
|
645
|
+
|
|
701
646
|
status: 422,
|
|
702
647
|
errorCode: 'NTS-DS0-VD0',
|
|
703
|
-
addECToUserMsg: true,
|
|
704
|
-
message: `validateForSave was unsuccessful (${this.dataParams.dataName})`,
|
|
705
|
-
userMessage: this.defaultErrorUserMsg,
|
|
706
|
-
issuer: this.issuer,
|
|
707
|
-
issuerService: this.serviceName,
|
|
708
|
-
error: error
|
|
709
648
|
});
|
|
710
649
|
}
|
|
711
650
|
}
|
|
@@ -736,13 +675,13 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
736
675
|
getDependencyDataDBService(): DynamoNTS_DBService<any> {
|
|
737
676
|
if (!this.depDBServiceKey) {
|
|
738
677
|
throw new Dynamo_Error({
|
|
678
|
+
...this.getDefaultErrorSettings(
|
|
679
|
+
'getDependencyDataDBService',
|
|
680
|
+
new Error(`getDependencyDataDBService was unsuccessful, service key not setted up! (${this.dataParams.dataName}))`)
|
|
681
|
+
),
|
|
682
|
+
|
|
739
683
|
status: 501,
|
|
740
684
|
errorCode: 'NTS-DS0-GDDB0',
|
|
741
|
-
addECToUserMsg: true,
|
|
742
|
-
message: `getDependencyDataDBService was unsuccessful, service key not setted up! (${this.dataParams.dataName}))`,
|
|
743
|
-
userMessage: this.defaultErrorUserMsg,
|
|
744
|
-
issuer: this.issuer,
|
|
745
|
-
issuerService: this.serviceName,
|
|
746
685
|
});
|
|
747
686
|
}
|
|
748
687
|
|
|
@@ -753,4 +692,16 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
753
692
|
return this.depDataDBService;
|
|
754
693
|
}
|
|
755
694
|
}
|
|
695
|
+
|
|
696
|
+
private getDefaultErrorSettings(fnName: string, error?: Error | Dynamo_Error) {
|
|
697
|
+
return {
|
|
698
|
+
status: 417,
|
|
699
|
+
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS; ${this.dataParams.dataName})`,
|
|
700
|
+
addECToUserMsg: true,
|
|
701
|
+
userMessage: this.defaultErrorUserMsg,
|
|
702
|
+
issuer: this.issuer,
|
|
703
|
+
issuerService: this.serviceName,
|
|
704
|
+
error: error,
|
|
705
|
+
}
|
|
706
|
+
}
|
|
756
707
|
}
|