@nsshunt/stsdatamanagement 1.18.178 → 1.18.179

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.
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PGAccessLayer = exports.updateMode = void 0;
4
1
  /* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
5
- const http_status_codes_1 = require("http-status-codes");
6
- const ioredis_1 = require("ioredis");
7
- const stsconfig_1 = require("@nsshunt/stsconfig");
8
- const pgpoolmanager_js_1 = require("./pgpoolmanager.js");
9
- const commonTypes_js_1 = require("./commonTypes.js");
10
- const tiny_emitter_1 = require("tiny-emitter");
11
- var updateMode;
2
+ import { StatusCodes } from 'http-status-codes';
3
+ import { Redis } from "ioredis";
4
+ import { goptions } from '@nsshunt/stsconfig';
5
+ import { PGPoolManager } from './pgpoolmanager.js';
6
+ import { IDBAccessLayerEvents, eOperations } from './commonTypes.js';
7
+ import { TinyEmitter } from 'tiny-emitter';
8
+ export var updateMode;
12
9
  (function (updateMode) {
13
10
  updateMode[updateMode["patchResources"] = 0] = "patchResources";
14
11
  updateMode[updateMode["updateResources"] = 1] = "updateResources";
@@ -16,8 +13,8 @@ var updateMode;
16
13
  updateMode[updateMode["patchEntities"] = 3] = "patchEntities";
17
14
  updateMode[updateMode["updateEntities"] = 4] = "updateEntities";
18
15
  updateMode[updateMode["deleteEntities"] = 5] = "deleteEntities";
19
- })(updateMode || (exports.updateMode = updateMode = {}));
20
- class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
16
+ })(updateMode || (updateMode = {}));
17
+ export class PGAccessLayer extends TinyEmitter {
21
18
  #options;
22
19
  // eslint-disable-next-line @/no-unused-private-class-members
23
20
  #cache = null;
@@ -25,22 +22,22 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
25
22
  constructor(options) {
26
23
  super();
27
24
  this.#options = options;
28
- const { useRedisDatabaseCache, redisDatabaseCacheUrl } = stsconfig_1.goptions;
29
- this.#poolManager = new pgpoolmanager_js_1.PGPoolManager({
25
+ const { useRedisDatabaseCache, redisDatabaseCacheUrl } = goptions;
26
+ this.#poolManager = new PGPoolManager({
30
27
  logger: this.#options.logger,
31
28
  usedefaultdb: this.#options.usedefaultdb
32
29
  });
33
- this.#poolManager.on(commonTypes_js_1.IDBAccessLayerEvents.UpdateInstruments, this.#UpdateInstruments);
30
+ this.#poolManager.on(IDBAccessLayerEvents.UpdateInstruments, this.#UpdateInstruments);
34
31
  if (useRedisDatabaseCache === true) {
35
32
  const redisOptions = {
36
33
  showFriendlyErrorStack: true,
37
34
  maxRetriesPerRequest: 20
38
35
  };
39
- this.#cache = new ioredis_1.Redis(redisDatabaseCacheUrl, redisOptions);
36
+ this.#cache = new Redis(redisDatabaseCacheUrl, redisOptions);
40
37
  }
41
38
  }
42
39
  #UpdateInstruments = (data) => {
43
- this.emit(commonTypes_js_1.IDBAccessLayerEvents.UpdateInstruments, data);
40
+ this.emit(IDBAccessLayerEvents.UpdateInstruments, data);
44
41
  };
45
42
  #LogErrorMessage = (message) => {
46
43
  this.#options.logger.error(message);
@@ -197,7 +194,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
197
194
  }
198
195
  async EndDatabase() {
199
196
  if (this.#poolManager) {
200
- this.#poolManager.off(commonTypes_js_1.IDBAccessLayerEvents.UpdateInstruments, this.#UpdateInstruments);
197
+ this.#poolManager.off(IDBAccessLayerEvents.UpdateInstruments, this.#UpdateInstruments);
201
198
  await this.#poolManager.End();
202
199
  }
203
200
  this.#poolManager = null;
@@ -220,19 +217,19 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
220
217
  return {
221
218
  options: useOptions,
222
219
  operation: 'GetResourceCount',
223
- status: http_status_codes_1.StatusCodes.OK,
220
+ status: StatusCodes.OK,
224
221
  detail: parseInt(dbResponse.count) //@@ needs to be number
225
222
  };
226
223
  }
227
224
  catch (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}]`);
225
+ return this.#LogAndGetErrorMessage(useOptions, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResourceCount, `pgaccesslayer:GetResourceCount(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
229
226
  }
230
227
  finally {
231
228
  client.release();
232
229
  }
233
230
  }
234
231
  catch (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}]`);
232
+ return this.#LogAndGetErrorMessage(useOptions, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResourceCount, `pgaccesslayer:GetResourceCount(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
236
233
  }
237
234
  }
238
235
  async GetEntityCount(options) {
@@ -255,25 +252,25 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
255
252
  const { rows } = await client.query(query, values);
256
253
  const dbResponse = rows[0];
257
254
  return {
258
- status: http_status_codes_1.StatusCodes.OK,
255
+ status: StatusCodes.OK,
259
256
  options,
260
257
  detail: parseInt(dbResponse.count), //@@ needs to be number
261
258
  operation: 'GetEntityCount'
262
259
  };
263
260
  }
264
261
  catch (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}]`);
262
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntityCount, `pgaccesslayer:GetEntityCount(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
266
263
  }
267
264
  finally {
268
265
  client.release();
269
266
  }
270
267
  }
271
268
  else {
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.`);
269
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntityCount, `pgaccesslayer:GetEntityCount(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
273
270
  }
274
271
  }
275
272
  catch (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}]`);
273
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntityCount, `pgaccesslayer:GetEntityCount(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
277
274
  }
278
275
  }
279
276
  async #__CreateResource(client, options, operation, resource) {
@@ -292,7 +289,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
292
289
  const dbResponse = rows[0];
293
290
  dbResponse.resdesc = this.#JSONParse(dbResponse.resdesc);
294
291
  return {
295
- status: http_status_codes_1.StatusCodes.CREATED,
292
+ status: StatusCodes.CREATED,
296
293
  detail: dbResponse,
297
294
  options,
298
295
  operation
@@ -300,15 +297,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
300
297
  }
301
298
  catch (error) {
302
299
  if (error.code === '23505') {
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}]`);
300
+ return this.#LogAndGetErrorMessage(options, StatusCodes.CONFLICT, eOperations.CreateResource, `pgaccesslayer:__CreateResource(): resourceid [${options.filters?.resname}] already exists. Error: [${this.#ToErrorWithMessage(error).message}]`);
304
301
  }
305
302
  else {
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}]`);
303
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateResource, `pgaccesslayer:__CreateResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
307
304
  }
308
305
  }
309
306
  }
310
307
  else {
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.`);
308
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateResource, `pgaccesslayer:__CreateResource(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
312
309
  }
313
310
  }
314
311
  async CreateResource(options, resource) {
@@ -316,8 +313,8 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
316
313
  const client = await this.#poolManager?.connectReadWrite();
317
314
  try {
318
315
  await client.query('BEGIN');
319
- const retVal = await this.#__CreateResource(client, options, commonTypes_js_1.eOperations.CreateResource, resource);
320
- if (retVal.status === http_status_codes_1.StatusCodes.CREATED) {
316
+ const retVal = await this.#__CreateResource(client, options, eOperations.CreateResource, resource);
317
+ if (retVal.status === StatusCodes.CREATED) {
321
318
  await client.query('COMMIT');
322
319
  }
323
320
  else {
@@ -327,14 +324,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
327
324
  }
328
325
  catch (error) {
329
326
  await client.query('ROLLBACK');
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}]`);
327
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateResource, `pgaccesslayer:CreateResource(): Operation was not successful (__CreateResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
331
328
  }
332
329
  finally {
333
330
  client.release();
334
331
  }
335
332
  }
336
333
  catch (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}]`);
334
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateResource, `pgaccesslayer:CreateResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
338
335
  }
339
336
  }
340
337
  async #__GetResource(client, options) {
@@ -355,10 +352,10 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
355
352
  const { rows } = await client.query(query, values);
356
353
  if (rows.length === 0) {
357
354
  // 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, commonTypes_js_1.eOperations.GetResource, `pgaccesslayer:GetResource(): resourceid [${resourceid}] (current version) not found.`);
355
+ return this.#GetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.GetResource, `pgaccesslayer:GetResource(): resourceid [${resourceid}] (current version) not found.`);
359
356
  }
360
357
  if (rows.length > 1) {
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.`);
358
+ return this.#LogAndGetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.GetResource, `pgaccesslayer:GetResource(): Multiple resourceid [${resourceid}] (current version) exist within database. Invalid database state.`);
362
359
  }
363
360
  const dbResponse = rows[0];
364
361
  //try {
@@ -368,22 +365,22 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
368
365
  //`pgaccesslayer:GetResource(): Could not parse JSON object. Value: [${dbResponse.resdesc}]`);
369
366
  //}
370
367
  return {
371
- status: http_status_codes_1.StatusCodes.OK,
368
+ status: StatusCodes.OK,
372
369
  detail: dbResponse,
373
- operation: commonTypes_js_1.eOperations.GetResource,
370
+ operation: eOperations.GetResource,
374
371
  options
375
372
  };
376
373
  }
377
374
  catch (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}]`);
375
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResource, `pgaccesslayer:GetResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
379
376
  }
380
377
  }
381
378
  else {
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.`);
379
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResource, `pgaccesslayer:GetResource(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
383
380
  }
384
381
  }
385
382
  catch (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}}]`);
383
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResource, `pgaccesslayer:GetResource(): Operation was not successful (outer). Error: [${this.#ToErrorWithMessage(error).message}}]`);
387
384
  }
388
385
  }
389
386
  async GetResource(options) {
@@ -400,7 +397,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
400
397
  return retVal;
401
398
  }
402
399
  catch (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}}]`);
400
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResource, `pgaccesslayer:GetResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}}]`);
404
401
  }
405
402
  }
406
403
  async #__UpdateResource(client, options, operation, resource) {
@@ -416,7 +413,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
416
413
  const dbResponse = rows[0];
417
414
  dbResponse.resdesc = this.#JSONParse(dbResponse.resdesc);
418
415
  return {
419
- status: http_status_codes_1.StatusCodes.OK,
416
+ status: StatusCodes.OK,
420
417
  detail: dbResponse,
421
418
  operation,
422
419
  options
@@ -424,15 +421,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
424
421
  }
425
422
  catch (error) {
426
423
  if (error.code === 'P0002') {
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}]`);
424
+ return this.#LogAndGetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.UpdateResource, `pgaccesslayer:__UpdateResource(): resourceid [${options.filters?.resname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
428
425
  }
429
426
  else {
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}]`);
427
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateResource, `pgaccesslayer:__UpdateResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
431
428
  }
432
429
  }
433
430
  }
434
431
  catch (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}]`);
432
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateResource, `pgaccesslayer:__UpdateResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
436
433
  }
437
434
  }
438
435
  async UpdateResource(options, resource) {
@@ -440,8 +437,8 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
440
437
  const client = await this.#poolManager?.connectReadWrite();
441
438
  try {
442
439
  await client.query('BEGIN');
443
- const retVal = await this.#__UpdateResource(client, options, commonTypes_js_1.eOperations.UpdateResource, resource);
444
- if (retVal.status === http_status_codes_1.StatusCodes.OK) {
440
+ const retVal = await this.#__UpdateResource(client, options, eOperations.UpdateResource, resource);
441
+ if (retVal.status === StatusCodes.OK) {
445
442
  await client.query('COMMIT');
446
443
  }
447
444
  else {
@@ -451,14 +448,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
451
448
  }
452
449
  catch (error) {
453
450
  await client.query('ROLLBACK');
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}]`);
451
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateResource, `pgaccesslayer:UpdateResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
455
452
  }
456
453
  finally {
457
454
  client.release();
458
455
  }
459
456
  }
460
457
  catch (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}]`);
458
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateResource, `pgaccesslayer:UpdateResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
462
459
  }
463
460
  }
464
461
  async PatchResource(options, resource) {
@@ -467,10 +464,10 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
467
464
  try {
468
465
  await client.query('BEGIN');
469
466
  const currentResource = await this.#__GetResource(client, options);
470
- if (currentResource.status === http_status_codes_1.StatusCodes.OK) {
467
+ if (currentResource.status === StatusCodes.OK) {
471
468
  const updatedRecord = { ...currentResource.detail.resdesc, ...resource };
472
- const retVal = await this.#__UpdateResource(client, options, commonTypes_js_1.eOperations.PatchResource, updatedRecord);
473
- if (retVal.status === http_status_codes_1.StatusCodes.OK) {
469
+ const retVal = await this.#__UpdateResource(client, options, eOperations.PatchResource, updatedRecord);
470
+ if (retVal.status === StatusCodes.OK) {
474
471
  await client.query('COMMIT');
475
472
  }
476
473
  else {
@@ -485,14 +482,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
485
482
  }
486
483
  catch (error) {
487
484
  await client.query('ROLLBACK');
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}]`);
485
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.PatchResource, `pgaccesslayer:PatchResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
489
486
  }
490
487
  finally {
491
488
  client.release();
492
489
  }
493
490
  }
494
491
  catch (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}]`);
492
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.PatchResource, `pgaccesslayer:PatchResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
496
493
  }
497
494
  }
498
495
  async #__UpdateOrPatchResources(resourceParameterRecords, mode, operation) {
@@ -505,7 +502,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
505
502
  const UpdateRecordPromise = new Promise((resolve, reject) => {
506
503
  if (mode === updateMode.updateResources || mode === updateMode.patchResources || mode === updateMode.deleteResources) {
507
504
  this.#__GetResource(client, rpr.opitons).then((currentResource) => {
508
- if (currentResource.status === http_status_codes_1.StatusCodes.OK) {
505
+ if (currentResource.status === StatusCodes.OK) {
509
506
  let updatedRecord;
510
507
  switch (mode) {
511
508
  case updateMode.patchResources:
@@ -523,11 +520,11 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
523
520
  reject(`pgaccesslayer:#__UpdateOrPatchResources(): Unknown mode (resource): [${mode}]`);
524
521
  }
525
522
  }
526
- else if (currentResource.status === http_status_codes_1.StatusCodes.NOT_FOUND
523
+ else if (currentResource.status === StatusCodes.NOT_FOUND
527
524
  && mode === updateMode.updateResources
528
525
  && !rpr.opitons.errorOnBatchUpdate) {
529
526
  const createNewResourceRecord = rpr.resource;
530
- this.#__CreateResource(client, rpr.opitons, commonTypes_js_1.eOperations.UpdateResources, createNewResourceRecord).then(retVal => resolve(retVal)).catch(error => reject(error));
527
+ this.#__CreateResource(client, rpr.opitons, eOperations.UpdateResources, createNewResourceRecord).then(retVal => resolve(retVal)).catch(error => reject(error));
531
528
  }
532
529
  else {
533
530
  resolve(currentResource);
@@ -538,7 +535,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
538
535
  }
539
536
  else {
540
537
  this.#__GetEntity(client, rpr.opitons).then((currentEntity) => {
541
- if (currentEntity.status === http_status_codes_1.StatusCodes.OK) {
538
+ if (currentEntity.status === StatusCodes.OK) {
542
539
  let updatedRecord;
543
540
  switch (mode) {
544
541
  case updateMode.patchEntities:
@@ -556,11 +553,11 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
556
553
  reject(`pgaccesslayer:#__UpdateOrPatchResources(): Unknown mode (entity): [${mode}]`);
557
554
  }
558
555
  }
559
- else if (currentEntity.status === http_status_codes_1.StatusCodes.NOT_FOUND
556
+ else if (currentEntity.status === StatusCodes.NOT_FOUND
560
557
  && mode === updateMode.updateEntities
561
558
  && !rpr.opitons.errorOnBatchUpdate) {
562
559
  const createNewEntityRecord = rpr.entity;
563
- this.#__CreateEntity(client, rpr.opitons, commonTypes_js_1.eOperations.UpdateEntities, createNewEntityRecord).then(retVal => resolve(retVal)).catch(error => reject(error));
560
+ this.#__CreateEntity(client, rpr.opitons, eOperations.UpdateEntities, createNewEntityRecord).then(retVal => resolve(retVal)).catch(error => reject(error));
564
561
  }
565
562
  else {
566
563
  resolve(currentEntity);
@@ -578,32 +575,32 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
578
575
  }
579
576
  catch (error) {
580
577
  await client.query('ROLLBACK');
581
- return this.#LogAndGetErrorMessage({}, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, operation, `pgaccesslayer:#__UpdateOrPatchResources(): Operation was not successful (Promise.all(promArray)). Error: [${this.#ToErrorWithMessage(error).message}]`);
578
+ return this.#LogAndGetErrorMessage({}, StatusCodes.INTERNAL_SERVER_ERROR, operation, `pgaccesslayer:#__UpdateOrPatchResources(): Operation was not successful (Promise.all(promArray)). Error: [${this.#ToErrorWithMessage(error).message}]`);
582
579
  }
583
580
  const retVal = {
584
- status: http_status_codes_1.StatusCodes.OK,
581
+ status: StatusCodes.OK,
585
582
  detail: [],
586
583
  options: {},
587
584
  operation: operation
588
585
  };
589
586
  promRetVal.forEach(prv => {
590
- if (!(prv.status === http_status_codes_1.StatusCodes.OK || prv.status === http_status_codes_1.StatusCodes.CREATED)) {
591
- if (retVal.status === http_status_codes_1.StatusCodes.OK) { // only set the first error
587
+ if (!(prv.status === StatusCodes.OK || prv.status === StatusCodes.CREATED)) {
588
+ if (retVal.status === StatusCodes.OK) { // only set the first error
592
589
  const message = `pgaccesslayer:#__UpdateOrPatchResources(): Operation was not successful. Check array for specific details.`;
593
- retVal.status = http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR;
590
+ retVal.status = StatusCodes.INTERNAL_SERVER_ERROR;
594
591
  retVal.options = prv.options;
595
592
  retVal.operation = prv.operation;
596
593
  retVal.error = {
597
594
  error: new Error(message),
598
595
  errorMessage: message,
599
596
  operation: prv.operation,
600
- status: http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR
597
+ status: StatusCodes.INTERNAL_SERVER_ERROR
601
598
  };
602
599
  }
603
600
  }
604
601
  retVal.detail.push(prv);
605
602
  });
606
- if (retVal.status === http_status_codes_1.StatusCodes.OK) {
603
+ if (retVal.status === StatusCodes.OK) {
607
604
  await client.query('COMMIT');
608
605
  }
609
606
  else {
@@ -616,33 +613,33 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
616
613
  }
617
614
  catch (error) {
618
615
  await client.query('ROLLBACK');
619
- return this.#LogAndGetErrorMessage({}, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, operation, `pgaccesslayer:__#UpdateOrPatchResources(): Operation was not successful (Promise processing). Error: [${this.#ToErrorWithMessage(error).message}]`);
616
+ return this.#LogAndGetErrorMessage({}, StatusCodes.INTERNAL_SERVER_ERROR, operation, `pgaccesslayer:__#UpdateOrPatchResources(): Operation was not successful (Promise processing). Error: [${this.#ToErrorWithMessage(error).message}]`);
620
617
  }
621
618
  finally {
622
619
  client.release();
623
620
  }
624
621
  }
625
622
  catch (error) {
626
- return this.#LogAndGetErrorMessage({}, http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR, operation, `pgaccesslayer:__#UpdateOrPatchResources(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
623
+ return this.#LogAndGetErrorMessage({}, StatusCodes.INTERNAL_SERVER_ERROR, operation, `pgaccesslayer:__#UpdateOrPatchResources(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
627
624
  }
628
625
  }
629
626
  async PatchResources(resourceParameterRecords) {
630
- return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchResources, commonTypes_js_1.eOperations.PatchResources);
627
+ return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchResources, eOperations.PatchResources);
631
628
  }
632
629
  async UpdateResources(resourceParameterRecords) {
633
- return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateResources, commonTypes_js_1.eOperations.UpdateResources);
630
+ return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateResources, eOperations.UpdateResources);
634
631
  }
635
632
  async DeleteResources(resourceParameterRecords) {
636
- return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteResources, commonTypes_js_1.eOperations.DeleteResources);
633
+ return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteResources, eOperations.DeleteResources);
637
634
  }
638
635
  async PatchEntities(resourceParameterRecords) {
639
- return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchEntities, commonTypes_js_1.eOperations.PatchEntities);
636
+ return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.patchEntities, eOperations.PatchEntities);
640
637
  }
641
638
  async UpdateEntities(resourceParameterRecords) {
642
- return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateEntities, commonTypes_js_1.eOperations.UpdateEntities);
639
+ return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.updateEntities, eOperations.UpdateEntities);
643
640
  }
644
641
  async DeleteEntities(resourceParameterRecords) {
645
- return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteEntities, commonTypes_js_1.eOperations.DeleteEntities);
642
+ return this.#__UpdateOrPatchResources(resourceParameterRecords, updateMode.deleteEntities, eOperations.DeleteEntities);
646
643
  }
647
644
  async #__DeleteResource(client, options, operation) {
648
645
  try {
@@ -656,7 +653,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
656
653
  const dbResponse = rows[0];
657
654
  dbResponse.resdesc = this.#JSONParse(dbResponse.resdesc);
658
655
  return {
659
- status: http_status_codes_1.StatusCodes.OK,
656
+ status: StatusCodes.OK,
660
657
  detail: dbResponse,
661
658
  options,
662
659
  operation
@@ -664,15 +661,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
664
661
  }
665
662
  catch (error) {
666
663
  if (error.code === 'P0002') {
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}]`);
664
+ return this.#LogAndGetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): resourceid [${options.filters?.resname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
668
665
  }
669
666
  else {
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}]`);
667
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
671
668
  }
672
669
  }
673
670
  }
674
671
  catch (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}]`);
672
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
676
673
  }
677
674
  }
678
675
  async DeleteResource(options) {
@@ -680,8 +677,8 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
680
677
  const client = await this.#poolManager?.connectReadWrite();
681
678
  try {
682
679
  await client.query('BEGIN');
683
- const retVal = await this.#__DeleteResource(client, options, commonTypes_js_1.eOperations.DeleteResource);
684
- if (retVal.status === http_status_codes_1.StatusCodes.OK) {
680
+ const retVal = await this.#__DeleteResource(client, options, eOperations.DeleteResource);
681
+ if (retVal.status === StatusCodes.OK) {
685
682
  await client.query('COMMIT');
686
683
  }
687
684
  else {
@@ -691,14 +688,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
691
688
  }
692
689
  catch (error) {
693
690
  await client.query('ROLLBACK');
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}]`);
691
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Operation was not successful (__GetResource). Error: [${this.#ToErrorWithMessage(error).message}]`);
695
692
  }
696
693
  finally {
697
694
  client.release();
698
695
  }
699
696
  }
700
697
  catch (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}]`);
698
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteResource, `pgaccesslayer:DeleteResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
702
699
  }
703
700
  }
704
701
  async #__CreateEntity(client, options, operation, entity) {
@@ -719,7 +716,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
719
716
  dbResponse.resourceoid = dbResponse.resourceoid.toString();
720
717
  dbResponse.entvalue = this.#JSONParse(dbResponse.entvalue);
721
718
  return {
722
- status: http_status_codes_1.StatusCodes.CREATED,
719
+ status: StatusCodes.CREATED,
723
720
  detail: dbResponse,
724
721
  options,
725
722
  operation
@@ -727,15 +724,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
727
724
  }
728
725
  catch (error) {
729
726
  if (error.code === '23505') {
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}]`);
727
+ return this.#LogAndGetErrorMessage(options, StatusCodes.CONFLICT, eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): entityid [${options.filters?.entname}] already exists. Error: [${this.#ToErrorWithMessage(error).message}]`);
731
728
  }
732
729
  else {
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}]`);
730
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
734
731
  }
735
732
  }
736
733
  }
737
734
  else {
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.`);
735
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
739
736
  }
740
737
  }
741
738
  async CreateEntity(options, entity) {
@@ -743,8 +740,8 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
743
740
  const client = await this.#poolManager?.connectReadWrite();
744
741
  try {
745
742
  await client.query('BEGIN');
746
- const retVal = await this.#__CreateEntity(client, options, commonTypes_js_1.eOperations.CreateEntity, entity);
747
- if (retVal.status === http_status_codes_1.StatusCodes.CREATED) {
743
+ const retVal = await this.#__CreateEntity(client, options, eOperations.CreateEntity, entity);
744
+ if (retVal.status === StatusCodes.CREATED) {
748
745
  await client.query('COMMIT');
749
746
  }
750
747
  else {
@@ -754,14 +751,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
754
751
  }
755
752
  catch (error) {
756
753
  await client.query('ROLLBACK');
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}]`);
754
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
758
755
  }
759
756
  finally {
760
757
  client.release();
761
758
  }
762
759
  }
763
760
  catch (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}]`);
761
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.CreateEntity, `pgaccesslayer:CreateEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
765
762
  }
766
763
  }
767
764
  async #__GetEntity(client, options) {
@@ -784,32 +781,32 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
784
781
  try {
785
782
  const { rows } = await client.query(query, values);
786
783
  if (rows.length === 0) {
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`);
784
+ return this.#LogAndGetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.GetEntity, `pgaccesslayer:GetEntity(): resname: [${options.filters?.resname}], entname: [${options.filters?.entname}] (current version) not found`);
788
785
  }
789
786
  if (rows.length > 1) {
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.`);
787
+ return this.#LogAndGetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.GetEntity, `pgaccesslayer:GetEntity(): Multiple resname [${options.filters?.resname}], entname: [${options.filters?.entname}] (current version) exist within database. Invalid database state.`);
791
788
  }
792
789
  const dbResponse = rows[0];
793
790
  // Convert the resourceoid to a string
794
791
  dbResponse.resourceoid = dbResponse.resourceoid.toString();
795
792
  dbResponse.entvalue = this.#JSONParse(dbResponse.entvalue);
796
793
  return {
797
- status: http_status_codes_1.StatusCodes.OK,
794
+ status: StatusCodes.OK,
798
795
  detail: dbResponse,
799
796
  options,
800
- operation: commonTypes_js_1.eOperations.GetEntity
797
+ operation: eOperations.GetEntity
801
798
  };
802
799
  }
803
800
  catch (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}]`);
801
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntity, `pgaccesslayer:GetEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
805
802
  }
806
803
  }
807
804
  else {
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.`);
805
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntity, `pgaccesslayer:GetEntity(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
809
806
  }
810
807
  }
811
808
  catch (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}}]`);
809
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntity, `pgaccesslayer:GetEntity(): peration was not successful (outer). Error: [${this.#ToErrorWithMessage(error).message}}]`);
813
810
  }
814
811
  }
815
812
  async GetEntity(options) {
@@ -820,7 +817,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
820
817
  return retVal;
821
818
  }
822
819
  catch (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}}]`);
820
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntity, `pgaccesslayer:GetEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}}]`);
824
821
  }
825
822
  }
826
823
  async #__UpdateEntity(client, options, operation, entity) {
@@ -839,7 +836,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
839
836
  dbResponse.resourceoid = dbResponse.resourceoid.toString();
840
837
  dbResponse.entvalue = this.#JSONParse(dbResponse.entvalue);
841
838
  return {
842
- status: http_status_codes_1.StatusCodes.OK,
839
+ status: StatusCodes.OK,
843
840
  detail: dbResponse,
844
841
  options,
845
842
  operation
@@ -847,15 +844,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
847
844
  }
848
845
  catch (error) {
849
846
  if (error.code === 'P0002') {
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}]`);
847
+ return this.#LogAndGetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.UpdateEntity, `resname: [${options.filters?.resname}], entname: [${options.filters?.entname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
851
848
  }
852
849
  else {
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}]`);
850
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateEntity, `pgaccesslayer:__UpdateEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
854
851
  }
855
852
  }
856
853
  }
857
854
  catch (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}]`);
855
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateEntity, `pgaccesslayer:__UpdateEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
859
856
  }
860
857
  }
861
858
  async UpdateEntity(options, entity) {
@@ -863,8 +860,8 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
863
860
  const client = await this.#poolManager?.connectReadWrite();
864
861
  try {
865
862
  await client.query('BEGIN');
866
- const retVal = await this.#__UpdateEntity(client, options, commonTypes_js_1.eOperations.UpdateEntity, entity);
867
- if (retVal.status === http_status_codes_1.StatusCodes.OK) {
863
+ const retVal = await this.#__UpdateEntity(client, options, eOperations.UpdateEntity, entity);
864
+ if (retVal.status === StatusCodes.OK) {
868
865
  await client.query('COMMIT');
869
866
  }
870
867
  else {
@@ -874,14 +871,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
874
871
  }
875
872
  catch (error) {
876
873
  await client.query('ROLLBACK');
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}]`);
874
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateEntity, `pgaccesslayer:GetEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
878
875
  }
879
876
  finally {
880
877
  client.release();
881
878
  }
882
879
  }
883
880
  catch (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}]`);
881
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.UpdateEntity, `pgaccesslayer:UpdateEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
885
882
  }
886
883
  }
887
884
  async PatchEntity(options, entity) {
@@ -890,10 +887,10 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
890
887
  try {
891
888
  await client.query('BEGIN');
892
889
  const currentEntity = await this.#__GetEntity(client, options);
893
- if (currentEntity.status === http_status_codes_1.StatusCodes.OK) {
890
+ if (currentEntity.status === StatusCodes.OK) {
894
891
  const updatedRecord = { ...currentEntity.detail.entvalue, ...entity };
895
- const retVal = await this.#__UpdateEntity(client, options, commonTypes_js_1.eOperations.PatchEntity, updatedRecord);
896
- if (retVal.status === http_status_codes_1.StatusCodes.OK) {
892
+ const retVal = await this.#__UpdateEntity(client, options, eOperations.PatchEntity, updatedRecord);
893
+ if (retVal.status === StatusCodes.OK) {
897
894
  await client.query('COMMIT');
898
895
  }
899
896
  else {
@@ -908,14 +905,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
908
905
  }
909
906
  catch (error) {
910
907
  await client.query('ROLLBACK');
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}]`);
908
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.PatchEntity, `pgaccesslayer:PatchEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
912
909
  }
913
910
  finally {
914
911
  client.release();
915
912
  }
916
913
  }
917
914
  catch (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}]`);
915
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.PatchEntity, `pgaccesslayer:PatchEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
919
916
  }
920
917
  }
921
918
  async #__DeleteEntity(client, options, operation) {
@@ -933,7 +930,7 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
933
930
  dbResponse.resourceoid = dbResponse.resourceoid.toString();
934
931
  dbResponse.entvalue = this.#JSONParse(dbResponse.entvalue);
935
932
  return {
936
- status: http_status_codes_1.StatusCodes.OK,
933
+ status: StatusCodes.OK,
937
934
  detail: dbResponse,
938
935
  options,
939
936
  operation
@@ -941,15 +938,15 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
941
938
  }
942
939
  catch (error) {
943
940
  if (error.code === 'P0002') {
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}]`);
941
+ return this.#LogAndGetErrorMessage(options, StatusCodes.NOT_FOUND, eOperations.DeleteEntity, `resname: [${options.filters?.resname}], entname: [${options.filters?.entname}] not found or not current. Error: [${this.#ToErrorWithMessage(error).message}]`);
945
942
  }
946
943
  else {
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}]`);
944
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteEntity, `pgaccesslayer:__DeleteEntity(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
948
945
  }
949
946
  }
950
947
  }
951
948
  catch (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}]`);
949
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteEntity, `pgaccesslayer:__DeleteEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
953
950
  }
954
951
  }
955
952
  async DeleteEntity(options) {
@@ -957,8 +954,8 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
957
954
  const client = await this.#poolManager?.connectReadWrite();
958
955
  try {
959
956
  await client.query('BEGIN');
960
- const retVal = await this.#__DeleteEntity(client, options, commonTypes_js_1.eOperations.DeleteEntity);
961
- if (retVal.status === http_status_codes_1.StatusCodes.OK) {
957
+ const retVal = await this.#__DeleteEntity(client, options, eOperations.DeleteEntity);
958
+ if (retVal.status === StatusCodes.OK) {
962
959
  await client.query('COMMIT');
963
960
  }
964
961
  else {
@@ -968,14 +965,14 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
968
965
  }
969
966
  catch (error) {
970
967
  await client.query('ROLLBACK');
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}]`);
968
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteEntity, `pgaccesslayer:DeleteEntity(): Operation was not successful (__GetEntity). Error: [${this.#ToErrorWithMessage(error).message}]`);
972
969
  }
973
970
  finally {
974
971
  client.release();
975
972
  }
976
973
  }
977
974
  catch (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}]`);
975
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.DeleteEntity, `pgaccesslayer:DeleteEntity(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
979
976
  }
980
977
  }
981
978
  async GetResources(options) {
@@ -1003,21 +1000,21 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
1003
1000
  r.resdesc = this.#JSONParse(r.resdesc);
1004
1001
  });
1005
1002
  return {
1006
- status: http_status_codes_1.StatusCodes.OK,
1003
+ status: StatusCodes.OK,
1007
1004
  detail: dbResponse,
1008
1005
  options: useOptions,
1009
- operation: commonTypes_js_1.eOperations.GetResources
1006
+ operation: eOperations.GetResources
1010
1007
  };
1011
1008
  }
1012
1009
  catch (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}]`);
1010
+ return this.#LogAndGetErrorMessage(useOptions, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResources, `pgaccesslayer:GetResources(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
1014
1011
  }
1015
1012
  finally {
1016
1013
  client.release();
1017
1014
  }
1018
1015
  }
1019
1016
  catch (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}]`);
1017
+ return this.#LogAndGetErrorMessage(useOptions, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResources, `pgaccesslayer:GetResources(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
1021
1018
  }
1022
1019
  }
1023
1020
  async GetEntities(options) {
@@ -1052,25 +1049,25 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
1052
1049
  r.entvalue = this.#JSONParse(r.entvalue);
1053
1050
  });
1054
1051
  return {
1055
- status: http_status_codes_1.StatusCodes.OK,
1052
+ status: StatusCodes.OK,
1056
1053
  detail: dbResponse,
1057
1054
  options,
1058
- operation: commonTypes_js_1.eOperations.GetEntities
1055
+ operation: eOperations.GetEntities
1059
1056
  };
1060
1057
  }
1061
1058
  catch (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}]`);
1059
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntities, `pgaccesslayer:GetEntities(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
1063
1060
  }
1064
1061
  finally {
1065
1062
  client.release();
1066
1063
  }
1067
1064
  }
1068
1065
  else {
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.`);
1066
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntities, `pgaccesslayer:GetEntities(): Required filters: [${JSON.stringify(requiredFields)}] not specified.`);
1070
1067
  }
1071
1068
  }
1072
1069
  catch (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}]`);
1070
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetEntities, `pgaccesslayer:GetEntities(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}]`);
1074
1071
  }
1075
1072
  }
1076
1073
  async #__SearchResources(client, options, searchOptions) {
@@ -1104,18 +1101,18 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
1104
1101
  dbResponse = rows;
1105
1102
  }
1106
1103
  return {
1107
- status: http_status_codes_1.StatusCodes.OK,
1104
+ status: StatusCodes.OK,
1108
1105
  detail: dbResponse,
1109
1106
  options: useOptions,
1110
- operation: commonTypes_js_1.eOperations.GetResources
1107
+ operation: eOperations.GetResources
1111
1108
  };
1112
1109
  }
1113
1110
  catch (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}]`);
1111
+ return this.#LogAndGetErrorMessage(useOptions, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResources, `pgaccesslayer:GetResources(): Operation was not successful. Error: [${this.#ToErrorWithMessage(error).message}]`);
1115
1112
  }
1116
1113
  }
1117
1114
  catch (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}}]`);
1115
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.GetResource, `pgaccesslayer:__SearchResources(): Operation was not successful (outer). Error: [${this.#ToErrorWithMessage(error).message}}]`);
1119
1116
  }
1120
1117
  }
1121
1118
  async SearchResources(options, searchOptions) {
@@ -1132,9 +1129,8 @@ class PGAccessLayer extends tiny_emitter_1.TinyEmitter {
1132
1129
  return retVal;
1133
1130
  }
1134
1131
  catch (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}}]`);
1132
+ return this.#LogAndGetErrorMessage(options, StatusCodes.INTERNAL_SERVER_ERROR, eOperations.SearchResources, `pgaccesslayer:SearchResource(): Could not get client from pool. Error: [${this.#ToErrorWithMessage(error).message}}]`);
1136
1133
  }
1137
1134
  }
1138
1135
  }
1139
- exports.PGAccessLayer = PGAccessLayer;
1140
1136
  //# sourceMappingURL=pgaccesslayer.js.map