@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,19 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
1
  /* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
7
- const vitest_1 = require("vitest");
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const stsconfig_1 = require("@nsshunt/stsconfig");
10
- const stsutils_1 = require("@nsshunt/stsutils");
11
- const databaseutils_js_1 = require("./databaseutils.js");
12
- const testcontainers_1 = require("testcontainers");
13
- const winston_1 = __importDefault(require("winston"));
14
- const dbAccessLayerManager_js_1 = require("./dbAccessLayerManager.js");
15
- const commonTypes_js_1 = require("./commonTypes.js");
16
- const http_status_codes_1 = require("http-status-codes");
2
+ import { beforeAll, afterAll, test, describe, expect } from 'vitest';
3
+ import chalk from 'chalk';
4
+ import { goptions, $ResetOptions } from '@nsshunt/stsconfig';
5
+ import { JestSleep, defaultLogger, Sleep, edbaction } from '@nsshunt/stsutils';
6
+ import { DatabaseUtils } from './databaseutils.js';
7
+ import { GenericContainer } from "testcontainers";
8
+ import winston from 'winston';
9
+ import { DBAccessLayerManager } from './dbAccessLayerManager.js';
10
+ import { accessLayerType, eOperations } from './commonTypes.js';
11
+ import { StatusCodes } from 'http-status-codes';
17
12
  const dbactionuser = 'jesttest';
18
13
  const sort = (a, b) => {
19
14
  if (a.detail && b.detail) {
@@ -23,7 +18,7 @@ const sort = (a, b) => {
23
18
  return -1;
24
19
  }
25
20
  };
26
- (0, vitest_1.describe)("Test pgaccesslayer", () => {
21
+ describe("Test pgaccesslayer", () => {
27
22
  let postgresContainer;
28
23
  let accessLayer;
29
24
  const finalResults = {};
@@ -33,16 +28,16 @@ const sort = (a, b) => {
33
28
  code: 1
34
29
  };
35
30
  let resourceoid = "";
36
- (0, vitest_1.beforeAll)(async () => {
37
- winston_1.default.format.combine(winston_1.default.format.colorize(), winston_1.default.format.simple());
38
- const logger = winston_1.default.createLogger({
31
+ beforeAll(async () => {
32
+ winston.format.combine(winston.format.colorize(), winston.format.simple());
33
+ const logger = winston.createLogger({
39
34
  level: 'silly',
40
- format: winston_1.default.format.combine(winston_1.default.format.colorize(), winston_1.default.format.simple()),
35
+ format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
41
36
  transports: [
42
- new winston_1.default.transports.Console(),
37
+ new winston.transports.Console(),
43
38
  ]
44
39
  });
45
- postgresContainer = await new testcontainers_1.GenericContainer("postgres")
40
+ postgresContainer = await new GenericContainer("postgres")
46
41
  .withExposedPorts(5432)
47
42
  .withEnvironment({
48
43
  POSTGRES_PASSWORD: "postgres",
@@ -50,16 +45,16 @@ const sort = (a, b) => {
50
45
  })
51
46
  .withCommand(['-c', 'max_connections=20'])
52
47
  .start();
53
- await (0, stsutils_1.Sleep)(1000);
48
+ await Sleep(1000);
54
49
  const postgresHttpPort = postgresContainer.getMappedPort(5432);
55
50
  const postgresHost = postgresContainer.getHost();
56
51
  process.env.DB_HOST = `${postgresHost}:${postgresHttpPort}`;
57
52
  process.env.POOL_SIZE = '10';
58
- (0, stsconfig_1.$ResetOptions)();
59
- logger.info(chalk_1.default.green(`httpPort: [${postgresHttpPort}]`));
60
- logger.info(chalk_1.default.green(`host: [${postgresHost}]`));
61
- logger.info(chalk_1.default.yellow(`connectionString: [${stsconfig_1.goptions.connectionString}]`));
62
- logger.info(chalk_1.default.yellow(`defaultDatabaseConnectionString: [${stsconfig_1.goptions.defaultDatabaseConnectionString}]`));
53
+ $ResetOptions();
54
+ logger.info(chalk.green(`httpPort: [${postgresHttpPort}]`));
55
+ logger.info(chalk.green(`host: [${postgresHost}]`));
56
+ logger.info(chalk.yellow(`connectionString: [${goptions.connectionString}]`));
57
+ logger.info(chalk.yellow(`defaultDatabaseConnectionString: [${goptions.defaultDatabaseConnectionString}]`));
63
58
  const dbOptions = {
64
59
  start: 0,
65
60
  iterations: 10000,
@@ -68,24 +63,24 @@ const sort = (a, b) => {
68
63
  workerScriptFolder: './dist', //@@
69
64
  useMultiBar: false
70
65
  };
71
- const dbUtils = new databaseutils_js_1.DatabaseUtils({
66
+ const dbUtils = new DatabaseUtils({
72
67
  logger
73
68
  });
74
69
  await dbUtils.CreateDatabase(dbOptions);
75
- await (0, stsutils_1.Sleep)(1000);
76
- logger.info(chalk_1.default.green(`Starting accessLayer`));
77
- accessLayer = new dbAccessLayerManager_js_1.DBAccessLayerManager().CreateAccessLayer({
78
- accessLayerType: commonTypes_js_1.accessLayerType.postgresql,
70
+ await Sleep(1000);
71
+ logger.info(chalk.green(`Starting accessLayer`));
72
+ accessLayer = new DBAccessLayerManager().CreateAccessLayer({
73
+ accessLayerType: accessLayerType.postgresql,
79
74
  accessLayerOptions: {
80
- logger: stsutils_1.defaultLogger,
75
+ logger: defaultLogger,
81
76
  usedefaultdb: false
82
77
  }
83
78
  });
84
- logger.info(chalk_1.default.green(`accessLayer:startdatabase()`));
79
+ logger.info(chalk.green(`accessLayer:startdatabase()`));
85
80
  await accessLayer.StartDatabase();
86
81
  }, 120000);
87
- (0, vitest_1.test)('Testing Database Entity create, update, patch, read and delete', async () => {
88
- vitest_1.expect.assertions(30);
82
+ test('Testing Database Entity create, update, patch, read and delete', async () => {
83
+ expect.assertions(30);
89
84
  const userResourceOptions = {
90
85
  filters: {
91
86
  dbactionuser,
@@ -94,11 +89,11 @@ const sort = (a, b) => {
94
89
  };
95
90
  const userResourceTypeCreateRecord = await accessLayer.CreateResource(userResourceOptions, userResourceType);
96
91
  const matchCreateResource = {
97
- operation: commonTypes_js_1.eOperations.CreateResource,
92
+ operation: eOperations.CreateResource,
98
93
  options: userResourceOptions,
99
- status: http_status_codes_1.StatusCodes.CREATED,
94
+ status: StatusCodes.CREATED,
100
95
  detail: {
101
- dbaction: stsutils_1.edbaction.created,
96
+ dbaction: edbaction.created,
102
97
  dbactionuser,
103
98
  resdesc: userResourceType,
104
99
  resname: userResourceType.name,
@@ -107,9 +102,9 @@ const sort = (a, b) => {
107
102
  }
108
103
  };
109
104
  const createdResource = userResourceTypeCreateRecord.detail;
110
- (0, vitest_1.expect)(userResourceTypeCreateRecord).toMatchObject(matchCreateResource);
111
- (0, vitest_1.expect)(createdResource.oid).not.toBeNull();
112
- (0, vitest_1.expect)(new Date(createdResource.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
105
+ expect(userResourceTypeCreateRecord).toMatchObject(matchCreateResource);
106
+ expect(createdResource.oid).not.toBeNull();
107
+ expect(new Date(createdResource.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
113
108
  resourceoid = createdResource.oid;
114
109
  const userEntity01 = {
115
110
  userId: 'user01',
@@ -127,12 +122,12 @@ const sort = (a, b) => {
127
122
  // Create Record -------------------------------------------------------------------------------------
128
123
  const entityUser01CreateRecord = await accessLayer.CreateEntity(entityResourceOptions, userEntity01);
129
124
  const matchCreateEntity = {
130
- operation: commonTypes_js_1.eOperations.CreateEntity,
125
+ operation: eOperations.CreateEntity,
131
126
  options: entityResourceOptions,
132
- status: http_status_codes_1.StatusCodes.CREATED,
127
+ status: StatusCodes.CREATED,
133
128
  detail: {
134
129
  resourceoid,
135
- dbaction: stsutils_1.edbaction.created,
130
+ dbaction: edbaction.created,
136
131
  dbactionuser,
137
132
  entvalue: userEntity01,
138
133
  entname: userEntity01.userId,
@@ -141,27 +136,27 @@ const sort = (a, b) => {
141
136
  }
142
137
  };
143
138
  const createdEntity = entityUser01CreateRecord.detail;
144
- (0, vitest_1.expect)(entityUser01CreateRecord).toMatchObject(matchCreateEntity);
145
- (0, vitest_1.expect)(createdEntity.oid).not.toBeNull();
146
- (0, vitest_1.expect)(new Date(createdEntity.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
139
+ expect(entityUser01CreateRecord).toMatchObject(matchCreateEntity);
140
+ expect(createdEntity.oid).not.toBeNull();
141
+ expect(new Date(createdEntity.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
147
142
  // Get Entity Count Post Create -------------------------------------------------------------------------------------
148
143
  const entityCountPostCreate = await accessLayer.GetEntityCount(entityResourceOptions);
149
144
  const matchEntityCountPostCreate = {
150
- operation: commonTypes_js_1.eOperations.GetEntityCount,
145
+ operation: eOperations.GetEntityCount,
151
146
  options: entityResourceOptions,
152
- status: http_status_codes_1.StatusCodes.OK,
147
+ status: StatusCodes.OK,
153
148
  detail: 1
154
149
  };
155
- (0, vitest_1.expect)(entityCountPostCreate).toMatchObject(matchEntityCountPostCreate);
150
+ expect(entityCountPostCreate).toMatchObject(matchEntityCountPostCreate);
156
151
  // Get Record -------------------------------------------------------------------------------------
157
152
  const getRecord1 = await accessLayer.GetEntity(entityResourceOptions);
158
153
  const matchGetEntity = {
159
- operation: commonTypes_js_1.eOperations.GetEntity,
154
+ operation: eOperations.GetEntity,
160
155
  options: entityResourceOptions,
161
- status: http_status_codes_1.StatusCodes.OK,
156
+ status: StatusCodes.OK,
162
157
  detail: {
163
158
  resourceoid,
164
- dbaction: stsutils_1.edbaction.created,
159
+ dbaction: edbaction.created,
165
160
  dbactionuser,
166
161
  entvalue: userEntity01,
167
162
  entname: userEntity01.userId,
@@ -170,9 +165,9 @@ const sort = (a, b) => {
170
165
  }
171
166
  };
172
167
  const getEntityRecord = getRecord1.detail;
173
- (0, vitest_1.expect)(getRecord1).toMatchObject(matchGetEntity);
174
- (0, vitest_1.expect)(getEntityRecord.oid).not.toBeNull();
175
- (0, vitest_1.expect)(new Date(getEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
168
+ expect(getRecord1).toMatchObject(matchGetEntity);
169
+ expect(getEntityRecord.oid).not.toBeNull();
170
+ expect(new Date(getEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
176
171
  // Update Record -------------------------------------------------------------------------------------
177
172
  const updateEntityResource = {
178
173
  userId: userEntity01.userId,
@@ -182,12 +177,12 @@ const sort = (a, b) => {
182
177
  };
183
178
  const userEntity01UpdateRecord = await accessLayer.UpdateEntity(entityResourceOptions, updateEntityResource);
184
179
  const matchUpdateEntity = {
185
- operation: commonTypes_js_1.eOperations.UpdateEntity,
180
+ operation: eOperations.UpdateEntity,
186
181
  options: entityResourceOptions,
187
- status: http_status_codes_1.StatusCodes.OK,
182
+ status: StatusCodes.OK,
188
183
  detail: {
189
184
  resourceoid,
190
- dbaction: stsutils_1.edbaction.updated,
185
+ dbaction: edbaction.updated,
191
186
  dbactionuser,
192
187
  entvalue: updateEntityResource,
193
188
  entname: updateEntityResource.userId,
@@ -196,9 +191,9 @@ const sort = (a, b) => {
196
191
  }
197
192
  };
198
193
  const updateEntityRecord = userEntity01UpdateRecord.detail;
199
- (0, vitest_1.expect)(userEntity01UpdateRecord).toMatchObject(matchUpdateEntity);
200
- (0, vitest_1.expect)(updateEntityRecord.oid).not.toBeNull();
201
- (0, vitest_1.expect)(new Date(updateEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
194
+ expect(userEntity01UpdateRecord).toMatchObject(matchUpdateEntity);
195
+ expect(updateEntityRecord.oid).not.toBeNull();
196
+ expect(new Date(updateEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
202
197
  // Patch Record -------------------------------------------------------------------------------------
203
198
  const patchEntityResource = {
204
199
  userId: userEntity01.userId,
@@ -206,12 +201,12 @@ const sort = (a, b) => {
206
201
  };
207
202
  const userEntity01PatchRecord = await accessLayer.PatchEntity(entityResourceOptions, patchEntityResource);
208
203
  const matchPatchedEntity = {
209
- operation: commonTypes_js_1.eOperations.PatchEntity,
204
+ operation: eOperations.PatchEntity,
210
205
  options: entityResourceOptions,
211
- status: http_status_codes_1.StatusCodes.OK,
206
+ status: StatusCodes.OK,
212
207
  detail: {
213
208
  resourceoid,
214
- dbaction: stsutils_1.edbaction.updated,
209
+ dbaction: edbaction.updated,
215
210
  dbactionuser,
216
211
  entvalue: { ...updateEntityResource, ...patchEntityResource },
217
212
  entname: patchEntityResource.userId,
@@ -220,18 +215,18 @@ const sort = (a, b) => {
220
215
  }
221
216
  };
222
217
  const patchedEntityRecord = userEntity01PatchRecord.detail;
223
- (0, vitest_1.expect)(userEntity01PatchRecord).toMatchObject(matchPatchedEntity);
224
- (0, vitest_1.expect)(patchedEntityRecord.oid).not.toBeNull();
225
- (0, vitest_1.expect)(new Date(patchedEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
218
+ expect(userEntity01PatchRecord).toMatchObject(matchPatchedEntity);
219
+ expect(patchedEntityRecord.oid).not.toBeNull();
220
+ expect(new Date(patchedEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
226
221
  // Delete Record -------------------------------------------------------------------------------------
227
222
  const userEntity01DeleteRecord = await accessLayer.DeleteEntity(entityResourceOptions);
228
223
  const matchDeletedEntity = {
229
- operation: commonTypes_js_1.eOperations.DeleteEntity,
224
+ operation: eOperations.DeleteEntity,
230
225
  options: entityResourceOptions,
231
- status: http_status_codes_1.StatusCodes.OK,
226
+ status: StatusCodes.OK,
232
227
  detail: {
233
228
  resourceoid,
234
- dbaction: stsutils_1.edbaction.deleted,
229
+ dbaction: edbaction.deleted,
235
230
  dbactionuser,
236
231
  entvalue: { ...updateEntityResource, ...patchEntityResource },
237
232
  entname: patchEntityResource.userId,
@@ -240,32 +235,32 @@ const sort = (a, b) => {
240
235
  }
241
236
  };
242
237
  const deletedEntityRecord = userEntity01DeleteRecord.detail;
243
- (0, vitest_1.expect)(userEntity01DeleteRecord).toMatchObject(matchDeletedEntity);
244
- (0, vitest_1.expect)(deletedEntityRecord.oid).not.toBeNull();
245
- (0, vitest_1.expect)(new Date(deletedEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
238
+ expect(userEntity01DeleteRecord).toMatchObject(matchDeletedEntity);
239
+ expect(deletedEntityRecord.oid).not.toBeNull();
240
+ expect(new Date(deletedEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
246
241
  // Get a Deleted Record -------------------------------------------------------------------------------------
247
242
  const getDeleted = await accessLayer.GetEntity(entityResourceOptions);
248
243
  const matchGetDeletedEntity = {
249
- operation: commonTypes_js_1.eOperations.GetEntity,
244
+ operation: eOperations.GetEntity,
250
245
  options: entityResourceOptions,
251
- status: http_status_codes_1.StatusCodes.NOT_FOUND,
246
+ status: StatusCodes.NOT_FOUND,
252
247
  detail: null,
253
248
  error: {
254
- operation: commonTypes_js_1.eOperations.GetEntity,
255
- status: http_status_codes_1.StatusCodes.NOT_FOUND
249
+ operation: eOperations.GetEntity,
250
+ status: StatusCodes.NOT_FOUND
256
251
  }
257
252
  };
258
- (0, vitest_1.expect)(getDeleted).toMatchObject(matchGetDeletedEntity);
259
- (0, vitest_1.expect)(getDeleted.error?.errorMessage).toMatch(/\(current version\) not found/);
253
+ expect(getDeleted).toMatchObject(matchGetDeletedEntity);
254
+ expect(getDeleted.error?.errorMessage).toMatch(/\(current version\) not found/);
260
255
  // Get Entity Count Post Delete -------------------------------------------------------------------------------------
261
256
  const entityCountPostDelete = await accessLayer.GetEntityCount(entityResourceOptions);
262
257
  const matchEntityCountPostDelete = {
263
- operation: commonTypes_js_1.eOperations.GetEntityCount,
258
+ operation: eOperations.GetEntityCount,
264
259
  options: entityResourceOptions,
265
- status: http_status_codes_1.StatusCodes.OK,
260
+ status: StatusCodes.OK,
266
261
  detail: 0
267
262
  };
268
- (0, vitest_1.expect)(entityCountPostDelete).toMatchObject(matchEntityCountPostDelete);
263
+ expect(entityCountPostDelete).toMatchObject(matchEntityCountPostDelete);
269
264
  // Create Additional Entities -------------------------------------------------------------------------------------
270
265
  const expDetail = [];
271
266
  const createCount = 2;
@@ -287,12 +282,12 @@ const sort = (a, b) => {
287
282
  const entityCreateRecord = await accessLayer.CreateEntity(entityResourceOptions, userEntity);
288
283
  expDetail.push(entityCreateRecord.detail);
289
284
  const matchCreateEntity = {
290
- operation: commonTypes_js_1.eOperations.CreateEntity,
285
+ operation: eOperations.CreateEntity,
291
286
  options: entityResourceOptions,
292
- status: http_status_codes_1.StatusCodes.CREATED,
287
+ status: StatusCodes.CREATED,
293
288
  detail: {
294
289
  resourceoid,
295
- dbaction: stsutils_1.edbaction.created,
290
+ dbaction: edbaction.created,
296
291
  dbactionuser,
297
292
  entvalue: userEntity,
298
293
  entname: userEntity.userId,
@@ -301,9 +296,9 @@ const sort = (a, b) => {
301
296
  }
302
297
  };
303
298
  const createdEntityRecord = entityCreateRecord.detail;
304
- (0, vitest_1.expect)(entityCreateRecord).toMatchObject(matchCreateEntity);
305
- (0, vitest_1.expect)(createdEntityRecord.oid).not.toBeNull();
306
- (0, vitest_1.expect)(new Date(createdEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
299
+ expect(entityCreateRecord).toMatchObject(matchCreateEntity);
300
+ expect(createdEntityRecord.oid).not.toBeNull();
301
+ expect(new Date(createdEntityRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
307
302
  }
308
303
  // Get Entities (using filters) -------------------------------------------------------------------------------------
309
304
  const entities = await accessLayer.GetEntities({
@@ -312,7 +307,7 @@ const sort = (a, b) => {
312
307
  filter: '%'
313
308
  }
314
309
  });
315
- (0, vitest_1.expect)(entities.detail).toMatchObject(expDetail);
310
+ expect(entities.detail).toMatchObject(expDetail);
316
311
  // Get Entity Count Post Delete -------------------------------------------------------------------------------------
317
312
  const entityCountOptions = {
318
313
  filters: {
@@ -321,17 +316,17 @@ const sort = (a, b) => {
321
316
  };
322
317
  const entityCountPostMultiCreate = await accessLayer.GetEntityCount(entityCountOptions);
323
318
  const matchEntityCountPostMultiCreate = {
324
- operation: commonTypes_js_1.eOperations.GetEntityCount,
319
+ operation: eOperations.GetEntityCount,
325
320
  options: entityCountOptions,
326
- status: http_status_codes_1.StatusCodes.OK,
321
+ status: StatusCodes.OK,
327
322
  detail: createCount
328
323
  };
329
- (0, vitest_1.expect)(entityCountPostMultiCreate).toMatchObject(matchEntityCountPostMultiCreate);
324
+ expect(entityCountPostMultiCreate).toMatchObject(matchEntityCountPostMultiCreate);
330
325
  }, 120000);
331
- (0, vitest_1.test)('Testing Database Entity Batch Create', async () => {
326
+ test('Testing Database Entity Batch Create', async () => {
332
327
  const createStart = 100;
333
328
  const createNum = 60;
334
- vitest_1.expect.assertions(180);
329
+ expect.assertions(180);
335
330
  for (let i = createStart; i < createStart + createNum; i++) {
336
331
  const userId = `user_${String(i).padStart(4, '0')}`;
337
332
  const createUserEntity = {
@@ -348,28 +343,28 @@ const sort = (a, b) => {
348
343
  }
349
344
  }, createUserEntity);
350
345
  const checkObject = {
351
- status: http_status_codes_1.StatusCodes.CREATED,
346
+ status: StatusCodes.CREATED,
352
347
  detail: {
353
348
  entname: createUserEntity.userId,
354
349
  entvalue: createUserEntity,
355
350
  resourceoid,
356
351
  vnum: '1',
357
352
  validto: null,
358
- dbaction: stsutils_1.edbaction.created,
353
+ dbaction: edbaction.created,
359
354
  dbactionuser
360
355
  }
361
356
  };
362
357
  const createdRecord = userCreateRecord.detail;
363
358
  finalResults[createdRecord.entname] = createdRecord;
364
- (0, vitest_1.expect)(userCreateRecord).toMatchObject(checkObject);
365
- (0, vitest_1.expect)(new Date(createdRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
366
- (0, vitest_1.expect)(parseInt(createdRecord.oid)).toBeGreaterThan(0);
359
+ expect(userCreateRecord).toMatchObject(checkObject);
360
+ expect(new Date(createdRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
361
+ expect(parseInt(createdRecord.oid)).toBeGreaterThan(0);
367
362
  }
368
363
  }, 120000);
369
- (0, vitest_1.test)('Testing Database Entity Batch Create using Update', async () => {
364
+ test('Testing Database Entity Batch Create using Update', async () => {
370
365
  const updateStart = 100;
371
366
  const updateNum = 5;
372
- vitest_1.expect.assertions(15);
367
+ expect.assertions(15);
373
368
  const resourceParameterPatchRecord = [];
374
369
  const testRecords = [];
375
370
  for (let i = updateStart; i < updateStart + updateNum; i++) {
@@ -392,17 +387,17 @@ const sort = (a, b) => {
392
387
  };
393
388
  resourceParameterPatchRecord.push(resourceParameterRecord);
394
389
  const testObject = {
395
- status: http_status_codes_1.StatusCodes.CREATED,
390
+ status: StatusCodes.CREATED,
396
391
  detail: {
397
392
  entname: createFromUpdateUserEntity.userId,
398
393
  entvalue: createFromUpdateUserEntity,
399
394
  resourceoid,
400
395
  vnum: "1",
401
396
  validto: null,
402
- dbaction: stsutils_1.edbaction.created,
397
+ dbaction: edbaction.created,
403
398
  dbactionuser
404
399
  },
405
- operation: commonTypes_js_1.eOperations.UpdateEntities,
400
+ operation: eOperations.UpdateEntities,
406
401
  options: {}
407
402
  };
408
403
  testRecords.push(testObject);
@@ -413,18 +408,18 @@ const sort = (a, b) => {
413
408
  testRecords.sort(sort);
414
409
  if (retVal.length === testRecords.length) {
415
410
  for (let i = 0; i < retVal.length; i++) {
416
- (0, vitest_1.expect)(retVal[i]).toMatchObject(testRecords[i]);
411
+ expect(retVal[i]).toMatchObject(testRecords[i]);
417
412
  const updatedResourceRecord = retVal[i].detail;
418
413
  finalResults[updatedResourceRecord.entname] = updatedResourceRecord;
419
- (0, vitest_1.expect)(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
420
- (0, vitest_1.expect)(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
414
+ expect(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
415
+ expect(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
421
416
  }
422
417
  }
423
418
  }, 120000);
424
- (0, vitest_1.test)('Testing Database Entity Batch Update', async () => {
419
+ test('Testing Database Entity Batch Update', async () => {
425
420
  const updateStart = 100;
426
421
  const updateNum = 5;
427
- vitest_1.expect.assertions(15);
422
+ expect.assertions(15);
428
423
  const resourceParameterPatchRecord = [];
429
424
  const testRecords = [];
430
425
  for (let i = updateStart; i < updateStart + updateNum; i++) {
@@ -447,17 +442,17 @@ const sort = (a, b) => {
447
442
  };
448
443
  resourceParameterPatchRecord.push(resourceParameterRecord);
449
444
  const testObject = {
450
- status: http_status_codes_1.StatusCodes.OK,
445
+ status: StatusCodes.OK,
451
446
  detail: {
452
447
  entname: createFromUpdateUserEntity.userId,
453
448
  entvalue: createFromUpdateUserEntity,
454
449
  resourceoid,
455
450
  vnum: "2",
456
451
  validto: null,
457
- dbaction: stsutils_1.edbaction.updated,
452
+ dbaction: edbaction.updated,
458
453
  dbactionuser
459
454
  },
460
- operation: commonTypes_js_1.eOperations.UpdateEntities,
455
+ operation: eOperations.UpdateEntities,
461
456
  options: {}
462
457
  };
463
458
  testRecords.push(testObject);
@@ -468,19 +463,19 @@ const sort = (a, b) => {
468
463
  testRecords.sort(sort);
469
464
  if (retVal.length === testRecords.length) {
470
465
  for (let i = 0; i < retVal.length; i++) {
471
- (0, vitest_1.expect)(retVal[i]).toMatchObject(testRecords[i]);
466
+ expect(retVal[i]).toMatchObject(testRecords[i]);
472
467
  const updatedResourceRecord = retVal[i].detail;
473
468
  finalResults[updatedResourceRecord.entname] = updatedResourceRecord;
474
- (0, vitest_1.expect)(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
475
- (0, vitest_1.expect)(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
469
+ expect(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
470
+ expect(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
476
471
  }
477
472
  }
478
473
  }, 120000);
479
- (0, vitest_1.test)('Testing Database Entity Batch Update with Errors', async () => {
474
+ test('Testing Database Entity Batch Update with Errors', async () => {
480
475
  const updateErrorStart = 110;
481
476
  const updateErrorNum = 5;
482
477
  const updateErrorIndex = 112;
483
- vitest_1.expect.assertions(6);
478
+ expect.assertions(6);
484
479
  const resourceParameterPatchRecord = [];
485
480
  const testRecords = [];
486
481
  for (let i = updateErrorStart; i < updateErrorStart + updateErrorNum; i++) {
@@ -508,22 +503,22 @@ const sort = (a, b) => {
508
503
  resourceParameterPatchRecord.push(resourceParameterRecord);
509
504
  if (i === updateErrorIndex) {
510
505
  const testObject = {
511
- status: http_status_codes_1.StatusCodes.NOT_FOUND,
506
+ status: StatusCodes.NOT_FOUND,
512
507
  detail: null,
513
- operation: commonTypes_js_1.eOperations.GetEntity,
508
+ operation: eOperations.GetEntity,
514
509
  options: {},
515
510
  error: {
516
- operation: commonTypes_js_1.eOperations.GetEntity,
517
- status: http_status_codes_1.StatusCodes.NOT_FOUND
511
+ operation: eOperations.GetEntity,
512
+ status: StatusCodes.NOT_FOUND
518
513
  }
519
514
  };
520
515
  testRecords.push(testObject);
521
516
  }
522
517
  else {
523
518
  const testObject = {
524
- status: http_status_codes_1.StatusCodes.OK,
519
+ status: StatusCodes.OK,
525
520
  detail: null,
526
- operation: commonTypes_js_1.eOperations.UpdateEntities,
521
+ operation: eOperations.UpdateEntities,
527
522
  options: {}
528
523
  };
529
524
  testRecords.push(testObject);
@@ -535,12 +530,12 @@ const sort = (a, b) => {
535
530
  testRecords.sort(sort);
536
531
  if (retVal.length === testRecords.length) {
537
532
  for (let i = 0; i < retVal.length; i++) {
538
- (0, vitest_1.expect)(retVal[i]).toMatchObject(testRecords[i]);
533
+ expect(retVal[i]).toMatchObject(testRecords[i]);
539
534
  if (retVal[i].error) {
540
535
  const updatedResourceRecordError = retVal[i].error;
541
536
  const entName = retVal[i].options.filters.entname;
542
537
  finalResults[entName] = updatedResourceRecordError;
543
- (0, vitest_1.expect)(retVal[i].error?.errorMessage).toMatch(/\(current version\) not found/);
538
+ expect(retVal[i].error?.errorMessage).toMatch(/\(current version\) not found/);
544
539
  }
545
540
  else {
546
541
  const entName = retVal[i].options.filters.entname;
@@ -550,10 +545,10 @@ const sort = (a, b) => {
550
545
  }
551
546
  }
552
547
  }, 120000);
553
- (0, vitest_1.test)('Testing Database Entity Batch Patch', async () => {
548
+ test('Testing Database Entity Batch Patch', async () => {
554
549
  const patchStart = 120;
555
550
  const patchNum = 5;
556
- vitest_1.expect.assertions(15);
551
+ expect.assertions(15);
557
552
  const resourceParameterPatchRecord = [];
558
553
  const testRecords = [];
559
554
  for (let i = patchStart; i < patchStart + patchNum; i++) {
@@ -580,17 +575,17 @@ const sort = (a, b) => {
580
575
  };
581
576
  resourceParameterPatchRecord.push(resourceParameterRecord);
582
577
  const testObject = {
583
- status: http_status_codes_1.StatusCodes.OK,
578
+ status: StatusCodes.OK,
584
579
  detail: {
585
580
  entname: recordPostPatch.userId,
586
581
  entvalue: recordPostPatch,
587
582
  resourceoid,
588
583
  vnum: "2",
589
584
  validto: null,
590
- dbaction: stsutils_1.edbaction.updated,
585
+ dbaction: edbaction.updated,
591
586
  dbactionuser
592
587
  },
593
- operation: commonTypes_js_1.eOperations.PatchEntities,
588
+ operation: eOperations.PatchEntities,
594
589
  options: {}
595
590
  };
596
591
  testRecords.push(testObject);
@@ -601,19 +596,19 @@ const sort = (a, b) => {
601
596
  testRecords.sort(sort);
602
597
  if (retVal.length === testRecords.length) {
603
598
  for (let i = 0; i < retVal.length; i++) {
604
- (0, vitest_1.expect)(retVal[i]).toMatchObject(testRecords[i]);
599
+ expect(retVal[i]).toMatchObject(testRecords[i]);
605
600
  const updatedResourceRecord = retVal[i].detail;
606
601
  finalResults[updatedResourceRecord.entname] = updatedResourceRecord;
607
- (0, vitest_1.expect)(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
608
- (0, vitest_1.expect)(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
602
+ expect(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
603
+ expect(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
609
604
  }
610
605
  }
611
606
  }, 120000);
612
- (0, vitest_1.test)('Testing Database Entity Batch Patch with Errors', async () => {
607
+ test('Testing Database Entity Batch Patch with Errors', async () => {
613
608
  const patchErrorStart = 130;
614
609
  const patchErrorNum = 5;
615
610
  const patchErrorIndex = 132;
616
- vitest_1.expect.assertions(6);
611
+ expect.assertions(6);
617
612
  const resourceParameterPatchRecord = [];
618
613
  const testRecords = [];
619
614
  for (let i = patchErrorStart; i < patchErrorStart + patchErrorNum; i++) {
@@ -646,22 +641,22 @@ const sort = (a, b) => {
646
641
  resourceParameterPatchRecord.push(resourceParameterRecord);
647
642
  if (i === patchErrorIndex) {
648
643
  const testObject = {
649
- status: http_status_codes_1.StatusCodes.NOT_FOUND,
644
+ status: StatusCodes.NOT_FOUND,
650
645
  detail: null,
651
- operation: commonTypes_js_1.eOperations.GetEntity,
646
+ operation: eOperations.GetEntity,
652
647
  options: {},
653
648
  error: {
654
- operation: commonTypes_js_1.eOperations.GetEntity,
655
- status: http_status_codes_1.StatusCodes.NOT_FOUND
649
+ operation: eOperations.GetEntity,
650
+ status: StatusCodes.NOT_FOUND
656
651
  }
657
652
  };
658
653
  testRecords.push(testObject);
659
654
  }
660
655
  else {
661
656
  const testObject = {
662
- status: http_status_codes_1.StatusCodes.OK,
657
+ status: StatusCodes.OK,
663
658
  detail: null,
664
- operation: commonTypes_js_1.eOperations.PatchEntities,
659
+ operation: eOperations.PatchEntities,
665
660
  options: {}
666
661
  };
667
662
  testRecords.push(testObject);
@@ -673,12 +668,12 @@ const sort = (a, b) => {
673
668
  testRecords.sort(sort);
674
669
  if (retVal.length === testRecords.length) {
675
670
  for (let i = 0; i < retVal.length; i++) {
676
- (0, vitest_1.expect)(retVal[i]).toMatchObject(testRecords[i]);
671
+ expect(retVal[i]).toMatchObject(testRecords[i]);
677
672
  if (retVal[i].error) {
678
673
  const patchedResourceRecordError = retVal[i].error;
679
674
  const entname = retVal[i].options.filters.entname;
680
675
  finalResults[entname] = patchedResourceRecordError;
681
- (0, vitest_1.expect)(retVal[i].error?.errorMessage).toMatch(/\(current version\) not found/);
676
+ expect(retVal[i].error?.errorMessage).toMatch(/\(current version\) not found/);
682
677
  }
683
678
  else {
684
679
  const entname = retVal[i].options.filters.entname;
@@ -688,10 +683,10 @@ const sort = (a, b) => {
688
683
  }
689
684
  }
690
685
  }, 120000);
691
- (0, vitest_1.test)('Testing Database Entity Batch Delete', async () => {
686
+ test('Testing Database Entity Batch Delete', async () => {
692
687
  const deleteStart = 140;
693
688
  const deleteNum = 5;
694
- vitest_1.expect.assertions(15);
689
+ expect.assertions(15);
695
690
  const resourceParameterPatchRecord = [];
696
691
  const testRecords = [];
697
692
  for (let i = deleteStart; i < deleteStart + deleteNum; i++) {
@@ -717,17 +712,17 @@ const sort = (a, b) => {
717
712
  };
718
713
  resourceParameterPatchRecord.push(resourceParameterRecord);
719
714
  const testObject = {
720
- status: http_status_codes_1.StatusCodes.OK,
715
+ status: StatusCodes.OK,
721
716
  detail: {
722
717
  entname: originalRecord.userId,
723
718
  entvalue: originalRecord,
724
719
  resourceoid,
725
720
  vnum: "2",
726
721
  validto: null,
727
- dbaction: stsutils_1.edbaction.deleted,
722
+ dbaction: edbaction.deleted,
728
723
  dbactionuser
729
724
  },
730
- operation: commonTypes_js_1.eOperations.DeleteEntities,
725
+ operation: eOperations.DeleteEntities,
731
726
  options: {}
732
727
  };
733
728
  testRecords.push(testObject);
@@ -738,19 +733,19 @@ const sort = (a, b) => {
738
733
  testRecords.sort(sort);
739
734
  if (retVal.length === testRecords.length) {
740
735
  for (let i = 0; i < retVal.length; i++) {
741
- (0, vitest_1.expect)(retVal[i]).toMatchObject(testRecords[i]);
736
+ expect(retVal[i]).toMatchObject(testRecords[i]);
742
737
  const updatedResourceRecord = retVal[i].detail;
743
738
  finalResults[updatedResourceRecord.entname] = updatedResourceRecord;
744
- (0, vitest_1.expect)(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
745
- (0, vitest_1.expect)(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
739
+ expect(new Date(updatedResourceRecord.validfrom).getTime()).toBeLessThanOrEqual(new Date().getTime());
740
+ expect(parseInt(updatedResourceRecord.oid)).toBeGreaterThan(0);
746
741
  }
747
742
  }
748
743
  }, 120000);
749
- (0, vitest_1.test)('Testing Database Entity Batch Delete with Errors', async () => {
744
+ test('Testing Database Entity Batch Delete with Errors', async () => {
750
745
  const deleteErrorStart = 150;
751
746
  const deleteErrorNum = 5;
752
747
  const deleteErrorIndex = 152;
753
- vitest_1.expect.assertions(6);
748
+ expect.assertions(6);
754
749
  const resourceParameterPatchRecord = [];
755
750
  const testRecords = [];
756
751
  for (let i = deleteErrorStart; i < deleteErrorStart + deleteErrorNum; i++) {
@@ -775,22 +770,22 @@ const sort = (a, b) => {
775
770
  resourceParameterPatchRecord.push(resourceParameterRecord);
776
771
  if (i === deleteErrorIndex) {
777
772
  const testObject = {
778
- status: http_status_codes_1.StatusCodes.NOT_FOUND,
773
+ status: StatusCodes.NOT_FOUND,
779
774
  detail: null,
780
- operation: commonTypes_js_1.eOperations.GetEntity,
775
+ operation: eOperations.GetEntity,
781
776
  options: {},
782
777
  error: {
783
- operation: commonTypes_js_1.eOperations.GetEntity,
784
- status: http_status_codes_1.StatusCodes.NOT_FOUND
778
+ operation: eOperations.GetEntity,
779
+ status: StatusCodes.NOT_FOUND
785
780
  }
786
781
  };
787
782
  testRecords.push(testObject);
788
783
  }
789
784
  else {
790
785
  const testObject = {
791
- status: http_status_codes_1.StatusCodes.OK,
786
+ status: StatusCodes.OK,
792
787
  detail: null,
793
- operation: commonTypes_js_1.eOperations.DeleteEntities,
788
+ operation: eOperations.DeleteEntities,
794
789
  options: {}
795
790
  };
796
791
  testRecords.push(testObject);
@@ -802,12 +797,12 @@ const sort = (a, b) => {
802
797
  testRecords.sort(sort);
803
798
  if (retVal.length === testRecords.length) {
804
799
  for (let i = 0; i < retVal.length; i++) {
805
- (0, vitest_1.expect)(retVal[i]).toMatchObject(testRecords[i]);
800
+ expect(retVal[i]).toMatchObject(testRecords[i]);
806
801
  if (retVal[i].error) {
807
802
  const patchedResourceRecordError = retVal[i].error;
808
803
  const entname = retVal[i].options.filters.entname;
809
804
  finalResults[entname] = patchedResourceRecordError;
810
- (0, vitest_1.expect)(retVal[i].error?.errorMessage).toMatch(/\(current version\) not found/);
805
+ expect(retVal[i].error?.errorMessage).toMatch(/\(current version\) not found/);
811
806
  }
812
807
  else {
813
808
  const entname = retVal[i].options.filters.entname;
@@ -817,8 +812,8 @@ const sort = (a, b) => {
817
812
  }
818
813
  }
819
814
  }, 120000);
820
- (0, vitest_1.test)('Get All user_patch_test_ Resources', async () => {
821
- vitest_1.expect.assertions(51);
815
+ test('Get All user_patch_test_ Resources', async () => {
816
+ expect.assertions(51);
822
817
  // All Records
823
818
  const AllRecords = await accessLayer.GetEntities({
824
819
  filters: {
@@ -827,14 +822,14 @@ const sort = (a, b) => {
827
822
  limit: '50'
828
823
  }
829
824
  });
830
- (0, vitest_1.expect)(AllRecords.detail.length).toEqual(50);
825
+ expect(AllRecords.detail.length).toEqual(50);
831
826
  AllRecords.detail.forEach(u => {
832
827
  const compareObject = finalResults[u.entname];
833
828
  if (compareObject) {
834
- (0, vitest_1.expect)(u).toMatchObject(compareObject);
829
+ expect(u).toMatchObject(compareObject);
835
830
  }
836
831
  });
837
- console.log(chalk_1.default.cyan(`Entities List`));
832
+ console.log(chalk.cyan(`Entities List`));
838
833
  // Output formatted table
839
834
  const columns = [
840
835
  {
@@ -878,9 +873,9 @@ const sort = (a, b) => {
878
873
  console.log(detail);
879
874
  });
880
875
  });
881
- (0, vitest_1.afterAll)(async () => {
876
+ afterAll(async () => {
882
877
  await accessLayer.EndDatabase();
883
- await (0, stsutils_1.JestSleep)();
878
+ await JestSleep();
884
879
  await postgresContainer.stop();
885
880
  }, 5000);
886
881
  });