@nsshunt/stsdatamanagement 1.18.176 → 1.18.178
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/cliworker.js +4 -4
- package/dist/cliworker.js.map +1 -1
- package/dist/dalUserManager.js +6 -6
- package/dist/dalUserManager.js.map +1 -1
- package/dist/dalUserManager.test.js +9 -9
- package/dist/dalUserManager.test.js.map +1 -1
- package/dist/databaseutils.js +9 -9
- package/dist/databaseutils.js.map +1 -1
- package/dist/datagenerator.js +5 -4
- package/dist/datagenerator.js.map +1 -1
- package/dist/dbAccessLayerManager.js +4 -4
- package/dist/dbAccessLayerManager.js.map +1 -1
- package/dist/dbaccess.js +7 -7
- package/dist/dbaccess.js.map +1 -1
- package/dist/dbbuild.test.js +6 -6
- package/dist/dbbuild.test.js.map +1 -1
- package/dist/pcaccesslayer-entity.test.js +31 -31
- package/dist/pcaccesslayer-entity.test.js.map +1 -1
- package/dist/pcaccesslayer.test.js +40 -40
- package/dist/pcaccesslayer.test.js.map +1 -1
- package/dist/pgaccesslayer.js +86 -86
- package/dist/pgaccesslayer.js.map +1 -1
- package/dist/pgpoolmanager.js +2 -2
- package/dist/pgpoolmanager.js.map +1 -1
- package/dist/pgutils.js +6 -6
- package/dist/pgutils.js.map +1 -1
- package/dist/setupdb.js +2 -2
- package/dist/setupdb.js.map +1 -1
- package/package.json +16 -18
- package/types/dalUserManager.d.ts +1 -1
- package/types/dalUserManager.d.ts.map +1 -1
- package/types/databaseutils.d.ts +1 -1
- package/types/databaseutils.d.ts.map +1 -1
- package/types/datagenerator.d.ts +2 -2
- package/types/datagenerator.d.ts.map +1 -1
- package/types/dbAccessLayerManager.d.ts +1 -1
- package/types/dbAccessLayerManager.d.ts.map +1 -1
- package/types/dbaccess.d.ts +7 -7
- package/types/dbaccess.d.ts.map +1 -1
- package/types/pgaccesslayer-old.d.ts +1 -1
- package/types/pgaccesslayer-old.d.ts.map +1 -1
- package/types/pgaccesslayer.d.ts +1 -1
- package/types/pgaccesslayer.d.ts.map +1 -1
- package/types/pgutils.d.ts.map +1 -1
- package/types/setupdb.d.ts +1 -1
- package/types/setupdb.d.ts.map +1 -1
package/dist/pgaccesslayer.js
CHANGED
|
@@ -5,8 +5,8 @@ exports.PGAccessLayer = exports.updateMode = void 0;
|
|
|
5
5
|
const http_status_codes_1 = require("http-status-codes");
|
|
6
6
|
const ioredis_1 = require("ioredis");
|
|
7
7
|
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const pgpoolmanager_js_1 = require("./pgpoolmanager.js");
|
|
9
|
+
const commonTypes_js_1 = require("./commonTypes.js");
|
|
10
10
|
const tiny_emitter_1 = require("tiny-emitter");
|
|
11
11
|
var updateMode;
|
|
12
12
|
(function (updateMode) {
|
|
@@ -26,11 +26,11 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
26
26
|
super();
|
|
27
27
|
this.#options = options;
|
|
28
28
|
const { useRedisDatabaseCache, redisDatabaseCacheUrl } = stsconfig_1.goptions;
|
|
29
|
-
this.#poolManager = new
|
|
29
|
+
this.#poolManager = new pgpoolmanager_js_1.PGPoolManager({
|
|
30
30
|
logger: this.#options.logger,
|
|
31
31
|
usedefaultdb: this.#options.usedefaultdb
|
|
32
32
|
});
|
|
33
|
-
this.#poolManager.on(
|
|
33
|
+
this.#poolManager.on(commonTypes_js_1.IDBAccessLayerEvents.UpdateInstruments, this.#UpdateInstruments);
|
|
34
34
|
if (useRedisDatabaseCache === true) {
|
|
35
35
|
const redisOptions = {
|
|
36
36
|
showFriendlyErrorStack: true,
|
|
@@ -40,7 +40,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
#UpdateInstruments = (data) => {
|
|
43
|
-
this.emit(
|
|
43
|
+
this.emit(commonTypes_js_1.IDBAccessLayerEvents.UpdateInstruments, data);
|
|
44
44
|
};
|
|
45
45
|
#LogErrorMessage = (message) => {
|
|
46
46
|
this.#options.logger.error(message);
|
|
@@ -197,7 +197,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
197
197
|
}
|
|
198
198
|
async EndDatabase() {
|
|
199
199
|
if (this.#poolManager) {
|
|
200
|
-
this.#poolManager.off(
|
|
200
|
+
this.#poolManager.off(commonTypes_js_1.IDBAccessLayerEvents.UpdateInstruments, this.#UpdateInstruments);
|
|
201
201
|
await this.#poolManager.End();
|
|
202
202
|
}
|
|
203
203
|
this.#poolManager = null;
|
|
@@ -225,14 +225,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
catch (error) {
|
|
228
|
-
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
228
|
+
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResourceCount, `pgaccesslayer:GetResourceCount(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
229
229
|
}
|
|
230
230
|
finally {
|
|
231
231
|
client.release();
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
catch (error) {
|
|
235
|
-
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
235
|
+
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResourceCount, `pgaccesslayer:GetResourceCount(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
async GetEntityCount(options) {
|
|
@@ -262,18 +262,18 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
catch (error) {
|
|
265
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
265
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntityCount, `pgaccesslayer:GetEntityCount(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
266
266
|
}
|
|
267
267
|
finally {
|
|
268
268
|
client.release();
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
else {
|
|
272
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
272
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntityCount, `pgaccesslayer:GetEntityCount(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
catch (error) {
|
|
276
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
276
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntityCount, `pgaccesslayer:GetEntityCount(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
async #__CreateResource(client, options, operation, resource) {
|
|
@@ -300,15 +300,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
300
300
|
}
|
|
301
301
|
catch (error) {
|
|
302
302
|
if (error.code === '23505') {
|
|
303
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.CONFLICT,
|
|
303
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.CONFLICT, commonTypes_js_1.eOperations.CreateResource, `pgaccesslayer:__CreateResource(): resourceid [${options.filters?.resname}] already exists. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
304
304
|
}
|
|
305
305
|
else {
|
|
306
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
306
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateResource, `pgaccesslayer:__CreateResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
else {
|
|
311
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
311
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateResource, `pgaccesslayer:__CreateResource(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
async CreateResource(options, resource) {
|
|
@@ -316,7 +316,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
316
316
|
const client = await this.#poolManager?.connectReadWrite();
|
|
317
317
|
try {
|
|
318
318
|
await client.query('BEGIN');
|
|
319
|
-
const retVal = await this.#__CreateResource(client, options,
|
|
319
|
+
const retVal = await this.#__CreateResource(client, options, commonTypes_js_1.eOperations.CreateResource, resource);
|
|
320
320
|
if (retVal.status === http_status_codes_1.StatusCodes.CREATED) {
|
|
321
321
|
await client.query('COMMIT');
|
|
322
322
|
}
|
|
@@ -327,14 +327,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
327
327
|
}
|
|
328
328
|
catch (error) {
|
|
329
329
|
await client.query('ROLLBACK');
|
|
330
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
330
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateResource, `pgaccesslayer:CreateResource(): Operation was not successful (__CreateResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
331
331
|
}
|
|
332
332
|
finally {
|
|
333
333
|
client.release();
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
catch (error) {
|
|
337
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
337
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateResource, `pgaccesslayer:CreateResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
async #__GetResource(client, options) {
|
|
@@ -355,10 +355,10 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
355
355
|
const { rows } = await client.query(query, values);
|
|
356
356
|
if (rows.length === 0) {
|
|
357
357
|
// Don't log this type as this may be used to determine if a record exists.
|
|
358
|
-
return this.#GetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
358
|
+
return this.#GetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:GetResource(): resourceid [${resourceid}] (current version) not found.`);
|
|
359
359
|
}
|
|
360
360
|
if (rows.length > 1) {
|
|
361
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
361
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:GetResource(): Multiple resourceid [${resourceid}] (current version) exist within database. Invalid database state.`);
|
|
362
362
|
}
|
|
363
363
|
const dbResponse = rows[0];
|
|
364
364
|
//try {
|
|
@@ -370,20 +370,20 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
370
370
|
return {
|
|
371
371
|
status: http_status_codes_1.StatusCodes.OK,
|
|
372
372
|
detail: dbResponse,
|
|
373
|
-
operation:
|
|
373
|
+
operation: commonTypes_js_1.eOperations.GetResource,
|
|
374
374
|
options
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
377
|
catch (error) {
|
|
378
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
378
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:GetResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
else {
|
|
382
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
382
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:GetResource(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
catch (error) {
|
|
386
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
386
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:GetResource(): Operation was not successful (outer). Error: [${this.#ToErrorWithMessage(error).message}}]`);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
async GetResource(options) {
|
|
@@ -400,7 +400,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
400
400
|
return retVal;
|
|
401
401
|
}
|
|
402
402
|
catch (error) {
|
|
403
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
403
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:GetResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}}]`);
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
async #__UpdateResource(client, options, operation, resource) {
|
|
@@ -424,15 +424,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
424
424
|
}
|
|
425
425
|
catch (error) {
|
|
426
426
|
if (error.code === 'P0002') {
|
|
427
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
427
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.UpdateResource, `pgaccesslayer:__UpdateResource(): resourceid [${options.filters?.resname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
428
428
|
}
|
|
429
429
|
else {
|
|
430
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
430
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateResource, `pgaccesslayer:__UpdateResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
catch (error) {
|
|
435
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
435
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateResource, `pgaccesslayer:__UpdateResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
async UpdateResource(options, resource) {
|
|
@@ -440,7 +440,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
440
440
|
const client = await this.#poolManager?.connectReadWrite();
|
|
441
441
|
try {
|
|
442
442
|
await client.query('BEGIN');
|
|
443
|
-
const retVal = await this.#__UpdateResource(client, options,
|
|
443
|
+
const retVal = await this.#__UpdateResource(client, options, commonTypes_js_1.eOperations.UpdateResource, resource);
|
|
444
444
|
if (retVal.status === http_status_codes_1.StatusCodes.OK) {
|
|
445
445
|
await client.query('COMMIT');
|
|
446
446
|
}
|
|
@@ -451,14 +451,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
451
451
|
}
|
|
452
452
|
catch (error) {
|
|
453
453
|
await client.query('ROLLBACK');
|
|
454
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
454
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateResource, `pgaccesslayer:UpdateResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
455
455
|
}
|
|
456
456
|
finally {
|
|
457
457
|
client.release();
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
catch (error) {
|
|
461
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
461
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateResource, `pgaccesslayer:UpdateResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
async PatchResource(options, resource) {
|
|
@@ -469,7 +469,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
469
469
|
const currentResource = await this.#__GetResource(client, options);
|
|
470
470
|
if (currentResource.status === http_status_codes_1.StatusCodes.OK) {
|
|
471
471
|
const updatedRecord = { ...currentResource.detail.resdesc, ...resource };
|
|
472
|
-
const retVal = await this.#__UpdateResource(client, options,
|
|
472
|
+
const retVal = await this.#__UpdateResource(client, options, commonTypes_js_1.eOperations.PatchResource, updatedRecord);
|
|
473
473
|
if (retVal.status === http_status_codes_1.StatusCodes.OK) {
|
|
474
474
|
await client.query('COMMIT');
|
|
475
475
|
}
|
|
@@ -485,14 +485,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
485
485
|
}
|
|
486
486
|
catch (error) {
|
|
487
487
|
await client.query('ROLLBACK');
|
|
488
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
488
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.PatchResource, `pgaccesslayer:PatchResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
489
489
|
}
|
|
490
490
|
finally {
|
|
491
491
|
client.release();
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
catch (error) {
|
|
495
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
495
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.PatchResource, `pgaccesslayer:PatchResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
async #__UpdateOrPatchResources(resourceParameterRecords, mode, operation) {
|
|
@@ -527,7 +527,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
527
527
|
&& mode === updateMode.updateResources
|
|
528
528
|
&& !rpr.opitons.errorOnBatchUpdate) {
|
|
529
529
|
const createNewResourceRecord = rpr.resource;
|
|
530
|
-
this.#__CreateResource(client, rpr.opitons,
|
|
530
|
+
this.#__CreateResource(client, rpr.opitons, commonTypes_js_1.eOperations.UpdateResources, createNewResourceRecord).then(retVal => resolve(retVal)).catch(error => reject(error));
|
|
531
531
|
}
|
|
532
532
|
else {
|
|
533
533
|
resolve(currentResource);
|
|
@@ -560,7 +560,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
560
560
|
&& mode === updateMode.updateEntities
|
|
561
561
|
&& !rpr.opitons.errorOnBatchUpdate) {
|
|
562
562
|
const createNewEntityRecord = rpr.entity;
|
|
563
|
-
this.#__CreateEntity(client, rpr.opitons,
|
|
563
|
+
this.#__CreateEntity(client, rpr.opitons, commonTypes_js_1.eOperations.UpdateEntities, createNewEntityRecord).then(retVal => resolve(retVal)).catch(error => reject(error));
|
|
564
564
|
}
|
|
565
565
|
else {
|
|
566
566
|
resolve(currentEntity);
|
|
@@ -627,22 +627,22 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
629
|
async PatchResources(resourceParameterRecords) {
|
|
630
|
-
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchResources,
|
|
630
|
+
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchResources, commonTypes_js_1.eOperations.PatchResources);
|
|
631
631
|
}
|
|
632
632
|
async UpdateResources(resourceParameterRecords) {
|
|
633
|
-
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateResources,
|
|
633
|
+
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateResources, commonTypes_js_1.eOperations.UpdateResources);
|
|
634
634
|
}
|
|
635
635
|
async DeleteResources(resourceParameterRecords) {
|
|
636
|
-
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteResources,
|
|
636
|
+
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteResources, commonTypes_js_1.eOperations.DeleteResources);
|
|
637
637
|
}
|
|
638
638
|
async PatchEntities(resourceParameterRecords) {
|
|
639
|
-
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchEntities,
|
|
639
|
+
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchEntities, commonTypes_js_1.eOperations.PatchEntities);
|
|
640
640
|
}
|
|
641
641
|
async UpdateEntities(resourceParameterRecords) {
|
|
642
|
-
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateEntities,
|
|
642
|
+
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateEntities, commonTypes_js_1.eOperations.UpdateEntities);
|
|
643
643
|
}
|
|
644
644
|
async DeleteEntities(resourceParameterRecords) {
|
|
645
|
-
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteEntities,
|
|
645
|
+
return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteEntities, commonTypes_js_1.eOperations.DeleteEntities);
|
|
646
646
|
}
|
|
647
647
|
async #__DeleteResource(client, options, operation) {
|
|
648
648
|
try {
|
|
@@ -664,15 +664,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
664
664
|
}
|
|
665
665
|
catch (error) {
|
|
666
666
|
if (error.code === 'P0002') {
|
|
667
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
667
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): resourceid [${options.filters?.resname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
668
668
|
}
|
|
669
669
|
else {
|
|
670
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
670
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
674
|
catch (error) {
|
|
675
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
675
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
678
|
async DeleteResource(options) {
|
|
@@ -680,7 +680,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
680
680
|
const client = await this.#poolManager?.connectReadWrite();
|
|
681
681
|
try {
|
|
682
682
|
await client.query('BEGIN');
|
|
683
|
-
const retVal = await this.#__DeleteResource(client, options,
|
|
683
|
+
const retVal = await this.#__DeleteResource(client, options, commonTypes_js_1.eOperations.DeleteResource);
|
|
684
684
|
if (retVal.status === http_status_codes_1.StatusCodes.OK) {
|
|
685
685
|
await client.query('COMMIT');
|
|
686
686
|
}
|
|
@@ -691,14 +691,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
691
691
|
}
|
|
692
692
|
catch (error) {
|
|
693
693
|
await client.query('ROLLBACK');
|
|
694
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
694
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
695
695
|
}
|
|
696
696
|
finally {
|
|
697
697
|
client.release();
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
700
|
catch (error) {
|
|
701
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
701
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
704
|
async #__CreateEntity(client, options, operation, entity) {
|
|
@@ -727,15 +727,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
727
727
|
}
|
|
728
728
|
catch (error) {
|
|
729
729
|
if (error.code === '23505') {
|
|
730
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.CONFLICT,
|
|
730
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.CONFLICT, commonTypes_js_1.eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): entityid [${options.filters?.entname}] already exists. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
731
731
|
}
|
|
732
732
|
else {
|
|
733
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
733
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
737
|
else {
|
|
738
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
738
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
async CreateEntity(options, entity) {
|
|
@@ -743,7 +743,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
743
743
|
const client = await this.#poolManager?.connectReadWrite();
|
|
744
744
|
try {
|
|
745
745
|
await client.query('BEGIN');
|
|
746
|
-
const retVal = await this.#__CreateEntity(client, options,
|
|
746
|
+
const retVal = await this.#__CreateEntity(client, options, commonTypes_js_1.eOperations.CreateEntity, entity);
|
|
747
747
|
if (retVal.status === http_status_codes_1.StatusCodes.CREATED) {
|
|
748
748
|
await client.query('COMMIT');
|
|
749
749
|
}
|
|
@@ -754,14 +754,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
754
754
|
}
|
|
755
755
|
catch (error) {
|
|
756
756
|
await client.query('ROLLBACK');
|
|
757
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
757
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
758
758
|
}
|
|
759
759
|
finally {
|
|
760
760
|
client.release();
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
763
|
catch (error) {
|
|
764
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
764
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
767
|
async #__GetEntity(client, options) {
|
|
@@ -784,10 +784,10 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
784
784
|
try {
|
|
785
785
|
const { rows } = await client.query(query, values);
|
|
786
786
|
if (rows.length === 0) {
|
|
787
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
787
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.GetEntity, `pgaccesslayer:GetEntity(): resname: [${options.filters?.resname}], entname: [${options.filters?.entname}] (current version) not found`);
|
|
788
788
|
}
|
|
789
789
|
if (rows.length > 1) {
|
|
790
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
790
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.GetEntity, `pgaccesslayer:GetEntity(): Multiple resname [${options.filters?.resname}], entname: [${options.filters?.entname}] (current version) exist within database. Invalid database state.`);
|
|
791
791
|
}
|
|
792
792
|
const dbResponse = rows[0];
|
|
793
793
|
// Convert the resourceoid to a string
|
|
@@ -797,19 +797,19 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
797
797
|
status: http_status_codes_1.StatusCodes.OK,
|
|
798
798
|
detail: dbResponse,
|
|
799
799
|
options,
|
|
800
|
-
operation:
|
|
800
|
+
operation: commonTypes_js_1.eOperations.GetEntity
|
|
801
801
|
};
|
|
802
802
|
}
|
|
803
803
|
catch (error) {
|
|
804
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
804
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntity, `pgaccesslayer:GetEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
807
|
else {
|
|
808
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
808
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntity, `pgaccesslayer:GetEntity(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
|
|
809
809
|
}
|
|
810
810
|
}
|
|
811
811
|
catch (error) {
|
|
812
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
812
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntity, `pgaccesslayer:GetEntity(): peration was not successful (outer). Error: [${this.#ToErrorWithMessage(error).message}}]`);
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
async GetEntity(options) {
|
|
@@ -820,7 +820,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
820
820
|
return retVal;
|
|
821
821
|
}
|
|
822
822
|
catch (error) {
|
|
823
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
823
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntity, `pgaccesslayer:GetEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}}]`);
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
826
|
async #__UpdateEntity(client, options, operation, entity) {
|
|
@@ -847,15 +847,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
847
847
|
}
|
|
848
848
|
catch (error) {
|
|
849
849
|
if (error.code === 'P0002') {
|
|
850
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
850
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.UpdateEntity, `resname: [${options.filters?.resname}], entname: [${options.filters?.entname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
851
851
|
}
|
|
852
852
|
else {
|
|
853
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
853
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateEntity, `pgaccesslayer:__UpdateEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
857
|
catch (error) {
|
|
858
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
858
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateEntity, `pgaccesslayer:__UpdateEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
861
|
async UpdateEntity(options, entity) {
|
|
@@ -863,7 +863,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
863
863
|
const client = await this.#poolManager?.connectReadWrite();
|
|
864
864
|
try {
|
|
865
865
|
await client.query('BEGIN');
|
|
866
|
-
const retVal = await this.#__UpdateEntity(client, options,
|
|
866
|
+
const retVal = await this.#__UpdateEntity(client, options, commonTypes_js_1.eOperations.UpdateEntity, entity);
|
|
867
867
|
if (retVal.status === http_status_codes_1.StatusCodes.OK) {
|
|
868
868
|
await client.query('COMMIT');
|
|
869
869
|
}
|
|
@@ -874,14 +874,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
874
874
|
}
|
|
875
875
|
catch (error) {
|
|
876
876
|
await client.query('ROLLBACK');
|
|
877
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
877
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateEntity, `pgaccesslayer:GetEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
878
878
|
}
|
|
879
879
|
finally {
|
|
880
880
|
client.release();
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
883
|
catch (error) {
|
|
884
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
884
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.UpdateEntity, `pgaccesslayer:UpdateEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
887
|
async PatchEntity(options, entity) {
|
|
@@ -892,7 +892,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
892
892
|
const currentEntity = await this.#__GetEntity(client, options);
|
|
893
893
|
if (currentEntity.status === http_status_codes_1.StatusCodes.OK) {
|
|
894
894
|
const updatedRecord = { ...currentEntity.detail.entvalue, ...entity };
|
|
895
|
-
const retVal = await this.#__UpdateEntity(client, options,
|
|
895
|
+
const retVal = await this.#__UpdateEntity(client, options, commonTypes_js_1.eOperations.PatchEntity, updatedRecord);
|
|
896
896
|
if (retVal.status === http_status_codes_1.StatusCodes.OK) {
|
|
897
897
|
await client.query('COMMIT');
|
|
898
898
|
}
|
|
@@ -908,14 +908,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
908
908
|
}
|
|
909
909
|
catch (error) {
|
|
910
910
|
await client.query('ROLLBACK');
|
|
911
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
911
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.PatchEntity, `pgaccesslayer:PatchEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
912
912
|
}
|
|
913
913
|
finally {
|
|
914
914
|
client.release();
|
|
915
915
|
}
|
|
916
916
|
}
|
|
917
917
|
catch (error) {
|
|
918
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
918
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.PatchEntity, `pgaccesslayer:PatchEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
919
919
|
}
|
|
920
920
|
}
|
|
921
921
|
async #__DeleteEntity(client, options, operation) {
|
|
@@ -941,15 +941,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
941
941
|
}
|
|
942
942
|
catch (error) {
|
|
943
943
|
if (error.code === 'P0002') {
|
|
944
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
944
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.NOT_FOUND, commonTypes_js_1.eOperations.DeleteEntity, `resname: [${options.filters?.resname}], entname: [${options.filters?.entname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
945
945
|
}
|
|
946
946
|
else {
|
|
947
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
947
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteEntity, `pgaccesslayer:__DeleteEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
951
|
catch (error) {
|
|
952
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
952
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteEntity, `pgaccesslayer:__DeleteEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
953
953
|
}
|
|
954
954
|
}
|
|
955
955
|
async DeleteEntity(options) {
|
|
@@ -957,7 +957,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
957
957
|
const client = await this.#poolManager?.connectReadWrite();
|
|
958
958
|
try {
|
|
959
959
|
await client.query('BEGIN');
|
|
960
|
-
const retVal = await this.#__DeleteEntity(client, options,
|
|
960
|
+
const retVal = await this.#__DeleteEntity(client, options, commonTypes_js_1.eOperations.DeleteEntity);
|
|
961
961
|
if (retVal.status === http_status_codes_1.StatusCodes.OK) {
|
|
962
962
|
await client.query('COMMIT');
|
|
963
963
|
}
|
|
@@ -968,14 +968,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
968
968
|
}
|
|
969
969
|
catch (error) {
|
|
970
970
|
await client.query('ROLLBACK');
|
|
971
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
971
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteEntity, `pgaccesslayer:DeleteEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
972
972
|
}
|
|
973
973
|
finally {
|
|
974
974
|
client.release();
|
|
975
975
|
}
|
|
976
976
|
}
|
|
977
977
|
catch (error) {
|
|
978
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
978
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.DeleteEntity, `pgaccesslayer:DeleteEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
979
979
|
}
|
|
980
980
|
}
|
|
981
981
|
async GetResources(options) {
|
|
@@ -1006,18 +1006,18 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
1006
1006
|
status: http_status_codes_1.StatusCodes.OK,
|
|
1007
1007
|
detail: dbResponse,
|
|
1008
1008
|
options: useOptions,
|
|
1009
|
-
operation:
|
|
1009
|
+
operation: commonTypes_js_1.eOperations.GetResources
|
|
1010
1010
|
};
|
|
1011
1011
|
}
|
|
1012
1012
|
catch (error) {
|
|
1013
|
-
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1013
|
+
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResources, `pgaccesslayer:GetResources(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
1014
1014
|
}
|
|
1015
1015
|
finally {
|
|
1016
1016
|
client.release();
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
1019
|
catch (error) {
|
|
1020
|
-
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1020
|
+
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResources, `pgaccesslayer:GetResources(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
1023
|
async GetEntities(options) {
|
|
@@ -1055,22 +1055,22 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
1055
1055
|
status: http_status_codes_1.StatusCodes.OK,
|
|
1056
1056
|
detail: dbResponse,
|
|
1057
1057
|
options,
|
|
1058
|
-
operation:
|
|
1058
|
+
operation: commonTypes_js_1.eOperations.GetEntities
|
|
1059
1059
|
};
|
|
1060
1060
|
}
|
|
1061
1061
|
catch (error) {
|
|
1062
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1062
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntities, `pgaccesslayer:GetEntities(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
1063
1063
|
}
|
|
1064
1064
|
finally {
|
|
1065
1065
|
client.release();
|
|
1066
1066
|
}
|
|
1067
1067
|
}
|
|
1068
1068
|
else {
|
|
1069
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1069
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntities, `pgaccesslayer:GetEntities(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
|
|
1070
1070
|
}
|
|
1071
1071
|
}
|
|
1072
1072
|
catch (error) {
|
|
1073
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1073
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetEntities, `pgaccesslayer:GetEntities(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
1074
1074
|
}
|
|
1075
1075
|
}
|
|
1076
1076
|
async #__SearchResources(client, options, searchOptions) {
|
|
@@ -1107,15 +1107,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
1107
1107
|
status: http_status_codes_1.StatusCodes.OK,
|
|
1108
1108
|
detail: dbResponse,
|
|
1109
1109
|
options: useOptions,
|
|
1110
|
-
operation:
|
|
1110
|
+
operation: commonTypes_js_1.eOperations.GetResources
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
1113
|
catch (error) {
|
|
1114
|
-
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1114
|
+
return this.#LogAndGetErrorMessage(useOptions, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResources, `pgaccesslayer:GetResources(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
1117
|
catch (error) {
|
|
1118
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1118
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:__SearchResources(): Operation was not successful (outer). Error: [${this.#ToErrorWithMessage(error).message}}]`);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
1121
|
async SearchResources(options, searchOptions) {
|
|
@@ -1132,7 +1132,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
|
|
|
1132
1132
|
return retVal;
|
|
1133
1133
|
}
|
|
1134
1134
|
catch (error) {
|
|
1135
|
-
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
1135
|
+
return this.#LogAndGetErrorMessage(options, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, commonTypes_js_1.eOperations.SearchResources, `pgaccesslayer:SearchResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}}]`);
|
|
1136
1136
|
}
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|