@nsshunt/stsappframework 3.1.149 → 3.1.151

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.
Files changed (110) hide show
  1. package/dist/commonTypes.js +9 -1
  2. package/dist/commonTypes.js.map +1 -1
  3. package/dist/index.js +0 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/masterprocessbase.js +6 -6
  6. package/dist/masterprocessbase.js.map +1 -1
  7. package/dist/processbase.js +8 -6
  8. package/dist/processbase.js.map +1 -1
  9. package/dist/redisMessageHandler.js.map +1 -1
  10. package/dist/server.js.map +1 -1
  11. package/dist/serverprocessbase.js +6 -6
  12. package/dist/serverprocessbase.js.map +1 -1
  13. package/dist/singleprocessbase.js.map +1 -1
  14. package/dist/workerprocessbase.js.map +1 -1
  15. package/package.json +10 -10
  16. package/src/commonTypes.ts +170 -2
  17. package/src/index.ts +0 -3
  18. package/src/masterprocessbase.ts +1 -2
  19. package/src/processbase.ts +12 -9
  20. package/src/redisMessageHandler.ts +1 -3
  21. package/src/server.ts +1 -3
  22. package/src/serverprocessbase.ts +1 -1
  23. package/src/singleprocessbase.ts +1 -2
  24. package/src/tcpserver/appmaster.ts +1 -1
  25. package/src/workerprocessbase.ts +1 -2
  26. package/types/commonTypes.d.ts +129 -2
  27. package/types/commonTypes.d.ts.map +1 -1
  28. package/types/index.d.ts +0 -3
  29. package/types/index.d.ts.map +1 -1
  30. package/types/masterprocessbase.d.ts +1 -2
  31. package/types/masterprocessbase.d.ts.map +1 -1
  32. package/types/processbase.d.ts +3 -4
  33. package/types/processbase.d.ts.map +1 -1
  34. package/types/redisMessageHandler.d.ts +1 -2
  35. package/types/redisMessageHandler.d.ts.map +1 -1
  36. package/types/server.d.ts +1 -2
  37. package/types/server.d.ts.map +1 -1
  38. package/types/serverprocessbase.d.ts +1 -1
  39. package/types/serverprocessbase.d.ts.map +1 -1
  40. package/types/singleprocessbase.d.ts +1 -2
  41. package/types/singleprocessbase.d.ts.map +1 -1
  42. package/types/tcpserver/appmaster.d.ts +1 -1
  43. package/types/tcpserver/appmaster.d.ts.map +1 -1
  44. package/types/workerprocessbase.d.ts +1 -2
  45. package/types/workerprocessbase.d.ts.map +1 -1
  46. package/dist/fhir/STSFhirTypes.js +0 -11
  47. package/dist/fhir/STSFhirTypes.js.map +0 -1
  48. package/dist/fhir/dalFhirManager.js +0 -34
  49. package/dist/fhir/dalFhirManager.js.map +0 -1
  50. package/dist/fhir/dalFhirManagerBase.js +0 -63
  51. package/dist/fhir/dalFhirManagerBase.js.map +0 -1
  52. package/dist/fhir/dalFhirManagerIORedisJson.js +0 -250
  53. package/dist/fhir/dalFhirManagerIORedisJson.js.map +0 -1
  54. package/dist/fhir/dalFhirManagerIORedisJson.test.js +0 -73
  55. package/dist/fhir/dalFhirManagerIORedisJson.test.js.map +0 -1
  56. package/dist/fhir/dalFhirManagerPGRes.js +0 -133
  57. package/dist/fhir/dalFhirManagerPGRes.js.map +0 -1
  58. package/dist/fhir/dalFhirManagerPGRes.test.js +0 -72
  59. package/dist/fhir/dalFhirManagerPGRes.test.js.map +0 -1
  60. package/dist/fhir/dalFhirManagerPGResEntity.js +0 -166
  61. package/dist/fhir/dalFhirManagerPGResEntity.js.map +0 -1
  62. package/dist/fhir/dalFhirManagerPGResEntity.test.js +0 -73
  63. package/dist/fhir/dalFhirManagerPGResEntity.test.js.map +0 -1
  64. package/dist/fhir/dalFhirManagerRedisJson.js +0 -226
  65. package/dist/fhir/dalFhirManagerRedisJson.js.map +0 -1
  66. package/dist/fhir/dalFhirManagerRedisJson.test.js +0 -73
  67. package/dist/fhir/dalFhirManagerRedisJson.test.js.map +0 -1
  68. package/dist/fhir/dalFhirTestHelpers.js +0 -227
  69. package/dist/fhir/dalFhirTestHelpers.js.map +0 -1
  70. package/dist/processoptions.js +0 -12
  71. package/dist/processoptions.js.map +0 -1
  72. package/src/fhir/STSFhirTypes.ts +0 -541
  73. package/src/fhir/dalFhirManager.ts +0 -33
  74. package/src/fhir/dalFhirManagerBase.ts +0 -77
  75. package/src/fhir/dalFhirManagerIORedisJson.test.ts +0 -94
  76. package/src/fhir/dalFhirManagerIORedisJson.ts +0 -260
  77. package/src/fhir/dalFhirManagerPGRes.test.ts +0 -91
  78. package/src/fhir/dalFhirManagerPGRes.ts +0 -147
  79. package/src/fhir/dalFhirManagerPGResEntity.test.ts +0 -93
  80. package/src/fhir/dalFhirManagerPGResEntity.ts +0 -183
  81. package/src/fhir/dalFhirManagerRedisJson.test.ts +0 -93
  82. package/src/fhir/dalFhirManagerRedisJson.ts +0 -230
  83. package/src/fhir/dalFhirTestHelpers.ts +0 -276
  84. package/src/processoptions.ts +0 -169
  85. package/types/fhir/STSFhirTypes.d.ts +0 -351
  86. package/types/fhir/STSFhirTypes.d.ts.map +0 -1
  87. package/types/fhir/dalFhirManager.d.ts +0 -7
  88. package/types/fhir/dalFhirManager.d.ts.map +0 -1
  89. package/types/fhir/dalFhirManagerBase.d.ts +0 -19
  90. package/types/fhir/dalFhirManagerBase.d.ts.map +0 -1
  91. package/types/fhir/dalFhirManagerIORedisJson.d.ts +0 -18
  92. package/types/fhir/dalFhirManagerIORedisJson.d.ts.map +0 -1
  93. package/types/fhir/dalFhirManagerIORedisJson.test.d.ts +0 -2
  94. package/types/fhir/dalFhirManagerIORedisJson.test.d.ts.map +0 -1
  95. package/types/fhir/dalFhirManagerPGRes.d.ts +0 -14
  96. package/types/fhir/dalFhirManagerPGRes.d.ts.map +0 -1
  97. package/types/fhir/dalFhirManagerPGRes.test.d.ts +0 -2
  98. package/types/fhir/dalFhirManagerPGRes.test.d.ts.map +0 -1
  99. package/types/fhir/dalFhirManagerPGResEntity.d.ts +0 -14
  100. package/types/fhir/dalFhirManagerPGResEntity.d.ts.map +0 -1
  101. package/types/fhir/dalFhirManagerPGResEntity.test.d.ts +0 -2
  102. package/types/fhir/dalFhirManagerPGResEntity.test.d.ts.map +0 -1
  103. package/types/fhir/dalFhirManagerRedisJson.d.ts +0 -15
  104. package/types/fhir/dalFhirManagerRedisJson.d.ts.map +0 -1
  105. package/types/fhir/dalFhirManagerRedisJson.test.d.ts +0 -2
  106. package/types/fhir/dalFhirManagerRedisJson.test.d.ts.map +0 -1
  107. package/types/fhir/dalFhirTestHelpers.d.ts +0 -20
  108. package/types/fhir/dalFhirTestHelpers.d.ts.map +0 -1
  109. package/types/processoptions.d.ts +0 -128
  110. package/types/processoptions.d.ts.map +0 -1
@@ -1,276 +0,0 @@
1
- import { expect } from 'vitest';
2
- import { IDALFhirDataAccessManager, INarrative, IPerson } from './STSFhirTypes'
3
- import { v4 as uuidv4 } from 'uuid';
4
-
5
- import chalk from 'chalk';
6
-
7
- import { goptions, $ResetOptions } from '@nsshunt/stsconfig'
8
-
9
- import { JestSleep, defaultLogger, Sleep } from '@nsshunt/stsutils'
10
-
11
- import { DatabaseUtils, DBAccessLayerManager, IDBAccessLayer, accessLayerType, IPGAccessLayerOptions } from '@nsshunt/stsdatamanagement'
12
-
13
- import { GenericContainer } from "testcontainers";
14
-
15
- import winston from 'winston'
16
-
17
- export class TestHelpers {
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- #postgresContainer: any;
20
- #accessLayer: IDBAccessLayer | null = null;
21
- #logger: winston.Logger;
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- #ioRedisContainer: any;
24
- #ioRedisMessageProcessorUrl = '';
25
-
26
- constructor() {
27
- winston.format.combine(
28
- winston.format.colorize(),
29
- winston.format.simple()
30
- );
31
-
32
- this.#logger = winston.createLogger({
33
- level: 'silly',
34
- format: winston.format.combine(
35
- winston.format.colorize(),
36
- winston.format.simple()
37
- ),
38
- transports: [
39
- new winston.transports.Console(),
40
- ]});
41
- }
42
-
43
- get logger(): winston.Logger {
44
- return this.#logger;
45
- }
46
-
47
- TestFhirPerson = async (personManager: IDALFhirDataAccessManager<IPerson>) => {
48
- expect.assertions(6);
49
-
50
- const id = uuidv4();
51
-
52
- const personRecord: IPerson = {
53
- id,
54
- _resourceType: 'Person',
55
- name: [
56
- {
57
- family: 'family',
58
- given: [ 'given' ],
59
- use: 'usual'
60
- }
61
- ],
62
- text: {
63
- div: 'New Record',
64
- status: 'generated'
65
- }
66
- };
67
-
68
- const newPerson01 = await personManager.CreateFhirResource(personRecord);
69
- expect(newPerson01).toMatchObject(personRecord);
70
-
71
- (personRecord.text as INarrative).div = 'user01 updated at ' + new Date().toString();
72
- const updatedPerson01 = await personManager.UpdateFhirResource(personRecord);
73
- expect(updatedPerson01).toMatchObject(personRecord);
74
-
75
- const getPerson01 = await personManager.GetFhirResource({id})
76
- expect(getPerson01).toMatchObject(personRecord);
77
-
78
- const getPerson02 = await personManager.GetFhirResource({id:'willnotfind'})
79
- expect(getPerson02).toBeNull();
80
-
81
- const deletePerson01 = await personManager.DeleteFhirResource({id})
82
- expect(deletePerson01).toMatchObject(personRecord);
83
-
84
- const getPerson01AfterDelete = await personManager.GetFhirResource({id})
85
- expect(getPerson01AfterDelete).toBeNull();
86
- }
87
-
88
- AddFhirPersons = async (personManager: IDALFhirDataAccessManager<IPerson>, iterations: number) => {
89
- for (let i=0; i < iterations; i++) {
90
- const id = uuidv4();
91
-
92
- const personRecord: IPerson = {
93
- id,
94
- _resourceType: 'Person',
95
- name: [
96
- {
97
- family: `family ${i}`,
98
- given: [ `given ${i}` ],
99
- use: `usual`
100
- }
101
- ],
102
- text: {
103
- div: `New Record ${i}`,
104
- status: 'generated'
105
- }
106
- };
107
-
108
- const newPerson01 = await personManager.CreateFhirResource(personRecord);
109
- expect(newPerson01).toMatchObject(personRecord);
110
- }
111
- }
112
-
113
- AddFhirPersonsByArray = async (personManager: IDALFhirDataAccessManager<IPerson>, iterations: number) => {
114
- const persons: IPerson[] = [ ];
115
- for (let i=0; i < iterations; i++) {
116
- const id = `bulk_${i}`;
117
-
118
- const personRecord: IPerson = {
119
- id,
120
- _resourceType: 'Person',
121
- name: [
122
- {
123
- family: `family ${i}`,
124
- given: [ `given ${i}` ],
125
- use: `usual`
126
- }
127
- ],
128
- text: {
129
- div: `New Record ${i}`,
130
- status: 'generated'
131
- }
132
- };
133
-
134
- persons.push(personRecord);
135
- }
136
-
137
- const newPersons = await personManager.CreateFhirResources(persons);
138
- expect(newPersons).toMatchObject(persons);
139
- }
140
-
141
- UpdateFhirPersonsByArray = async (personManager: IDALFhirDataAccessManager<IPerson>, iterations: number) => {
142
- const persons: IPerson[] = [ ];
143
- for (let i=0; i < iterations; i++) {
144
- const id = `bulk_${i}`;
145
-
146
- const personRecord: IPerson = {
147
- id,
148
- _resourceType: 'Person',
149
- name: [
150
- {
151
- family: `family ${i}`,
152
- given: [ `given ${i}` ],
153
- use: `usual`
154
- }
155
- ],
156
- text: {
157
- div: `Updated Record ${i}`,
158
- status: 'generated'
159
- }
160
- };
161
-
162
- persons.push(personRecord);
163
- }
164
-
165
- const newPersons = await personManager.UpdateFhirResources(persons);
166
- expect(newPersons).toMatchObject(persons);
167
- }
168
-
169
- DeleteFhirPersonsByArray = async (personManager: IDALFhirDataAccessManager<IPerson>, iterations: number) => {
170
- const persons: IPerson[] = [ ];
171
- for (let i=0; i < iterations; i++) {
172
- const id = `bulk_${i}`;
173
-
174
- const personRecord: IPerson = {
175
- id,
176
- _resourceType: 'Person',
177
- name: [
178
- {
179
- family: `family ${i}`,
180
- given: [ `given ${i}` ],
181
- use: `usual`
182
- }
183
- ],
184
- text: {
185
- div: `Updated Record ${i}`,
186
- status: 'generated'
187
- }
188
- };
189
-
190
- persons.push(personRecord);
191
- }
192
-
193
- const newPersons = await personManager.DeleteFhirResources(persons);
194
- expect(newPersons).toMatchObject(persons);
195
- }
196
-
197
- StartDatabase = async() => {
198
- this.#postgresContainer = await new GenericContainer("postgres")
199
- .withExposedPorts(5432)
200
- .withEnvironment({
201
- POSTGRES_PASSWORD: "postgres",
202
- //UV_THREADPOOL_SIZE: "64"
203
- })
204
- .withCommand(['-c', 'max_connections=20'])
205
- .start();
206
-
207
- await Sleep(1000);
208
-
209
- const postgresHttpPort = this.#postgresContainer.getMappedPort(5432);
210
- const postgresHost = this.#postgresContainer.getHost();
211
-
212
- process.env.DB_HOST = `${postgresHost}:${postgresHttpPort}`;
213
- process.env.POOL_SIZE = '10';
214
-
215
- $ResetOptions();
216
-
217
- this.logger.info(chalk.green(`httpPort: [${postgresHttpPort}]`));
218
- this.logger.info(chalk.green(`host: [${postgresHost}]`));
219
- this.logger.info(chalk.yellow(`connectionString: [${goptions.connectionString}]`));
220
- this.logger.info(chalk.yellow(`defaultDatabaseConnectionString: [${goptions.defaultDatabaseConnectionString }]`));
221
-
222
- const dbOptions = {
223
- start: 0,
224
- iterations: 10000,
225
- minextradata: 0,
226
- maxextradata: 1000,
227
- workerScriptFolder: './dist', //@@
228
- useMultiBar: false
229
- }
230
-
231
- const dbUtils = new DatabaseUtils({
232
- logger: this.logger
233
- });
234
- await dbUtils.CreateDatabase(dbOptions);
235
-
236
- await Sleep(1000);
237
-
238
- this.logger.info(chalk.green(`Starting accessLayer`));
239
-
240
- this.#accessLayer = new DBAccessLayerManager().CreateAccessLayer({
241
- accessLayerType: accessLayerType.postgresql,
242
- accessLayerOptions: {
243
- logger: defaultLogger,
244
- usedefaultdb: false
245
- } as IPGAccessLayerOptions
246
- })
247
-
248
- this.logger.info(chalk.green(`accessLayer:startdatabase()`));
249
- await this.#accessLayer.StartDatabase();
250
- }
251
-
252
- get accessLayer() {
253
- return this.#accessLayer;
254
- }
255
-
256
- StopDatabase = async () => {
257
- await this.#accessLayer?.EndDatabase();
258
- await JestSleep();
259
- await this.#postgresContainer.stop();
260
- }
261
-
262
- StartRedis = async () => {
263
- this.#ioRedisContainer = await new GenericContainer("redis/redis-stack-server")
264
- .withExposedPorts(6379)
265
- .start();
266
- this.#ioRedisMessageProcessorUrl = `redis://${this.#ioRedisContainer.getHost()}:${this.#ioRedisContainer.getMappedPort(6379)}`;
267
- }
268
-
269
- get ioRedisMessageProcessorUrl() {
270
- return this.#ioRedisMessageProcessorUrl;
271
- }
272
-
273
- StopRedis = async () => {
274
- await this.#ioRedisContainer.stop();
275
- }
276
- }
@@ -1,169 +0,0 @@
1
- import express from 'express'
2
-
3
- import { IProcessBase, IServiceProcessContext } from './commonTypes'
4
- import { ISTSLogger } from '@nsshunt/stsutils'
5
-
6
- export interface STSExpressServer {
7
- get App(): express.Express
8
- }
9
-
10
- /**
11
- * Factory method that adds express routes to the express app object.
12
- */
13
- export type ExpressRouteFactory = (app: express.Express, stsApp: IProcessBase) => void
14
-
15
- export enum STSServerType {
16
- NONE = "NONE",
17
- EXPRESS = "EXPRESS",
18
- EXPRESS_TLS = "EXPRESS_TLS",
19
- TCPRAW_TLS = "TCPRAW_TLS",
20
- JSONRPC2_TLS = "JSONRPC_TLS"
21
- }
22
-
23
- //export interface ProcessOptions extends JSONObject {
24
- export interface ProcessOptions {
25
- /**
26
- * Is this service worker the master worker (thread).
27
- */
28
- isMaster: boolean
29
-
30
- /**
31
- * Unique service instance ID (uuidv4).
32
- */
33
- serviceInstanceId: string
34
-
35
- // Service details
36
-
37
- serverType: STSServerType
38
-
39
- /**
40
- * HTTPS service public key path.
41
- */
42
- httpsServerKeyPath: string
43
-
44
- /**
45
- * HTTPS service certificate (private key) path.
46
- */
47
- httpsServerCertificatePath: string
48
-
49
- /**
50
- * Determines whether the process will explicitly exit (using code 0) when any terminate signal is received.
51
- */
52
- processExitOnTerminate: boolean
53
-
54
- /**
55
- * Does this service run a Web Socket Server (wss).
56
- */
57
- wssServer: boolean
58
-
59
- /**
60
- * Service Prometheus metric support.
61
- */
62
- prometheusSupport: boolean
63
-
64
- /**
65
- * Service endpoint (without trailing /). Example: https://localhost
66
- */
67
- endpoint: string
68
-
69
- /**
70
- * Service API root (without trailing /). Example: /stsrest01/v1
71
- */
72
- apiRoot: string
73
-
74
- /**
75
- * Service listen port. Example: 3001.
76
- * Note that unix domain sockets are also supported. Example: /tmp/stsrest01.sock.
77
- * The socket file may also need permissions changed, i.e. chmodSync(port, 511); or chmodSync(port, 777);
78
- * Axios client calls will also need to use socketPath. Example: ..., socketPath: '/tmp/stsrest01.sock'
79
- * Ref: https://stackoverflow.com/questions/21342828/node-express-unix-domain-socket-permissions
80
- * To setup side car service (per running machine/node)
81
- * sudo mkdir /var/run/sts
82
- * sudo chown marcusbettens /var/run/sts
83
- * In .env file per service
84
- * PORT=/var/run/sts/stsrest01.sock
85
- */
86
- listenPort: string
87
-
88
- /**
89
- * Port that this service will be exposed externally on, i.e. clients will use this port to invoke APIs on this service.
90
- */
91
- port: string
92
-
93
- /**
94
- * Prometheus Cluster Server port (port used for cluster prometheus scrapes). Example: 3011.
95
- */
96
- prometheusClusterPort: string
97
-
98
- /**
99
- * Service Name. Example: Rest01
100
- */
101
- serviceName: string
102
-
103
- /**
104
- * Service Version. Example: 1.0.0
105
- */
106
- serviceVersion: string
107
-
108
- /**
109
- * Determines where logging is output to the console (stdout).
110
- */
111
- consoleLogging: boolean
112
-
113
- /**
114
- * Determines where logging is output to the logging instrument (if present).
115
- */
116
- instrumentLogging: boolean
117
-
118
- // Publisher options.
119
-
120
- serviceProcessContext?: IServiceProcessContext
121
-
122
- /**
123
- * Factory method that adds express routes to the express app object. Used for non-static content.
124
- * Non-Static content is applied after logging middleware.
125
- */
126
- expressServerRouteFactory?: ExpressRouteFactory
127
-
128
- /**
129
- * Factory method that adds express routes to the express app object for static content.
130
- * Static content is applied before logging middleware.
131
- */
132
- expressServerRouteStaticFactory?: ExpressRouteFactory
133
-
134
- /**
135
- * Determines whether the service will monitor its own health via the /latency API endpoint.
136
- * Note: The service must implement the /latency end-point for this to work.
137
- */
138
- useLatency: boolean
139
-
140
- /**
141
- * Determines whether this service is going to need database access.
142
- */
143
- useDatabase: boolean
144
-
145
- instrumentationObservationInterval: number
146
-
147
- instrumentationTimeWindow: number
148
-
149
- useSocketIoRedisAdaptor: boolean
150
-
151
- socketIoRedisAdaptorUrl?: string
152
-
153
- useRedisInstrumentationTransport?: boolean
154
-
155
- redisInstrumentationTransportUrl?: string
156
-
157
- workerExec?: string
158
-
159
- /**
160
- * Is this application using nodejs cluster mode?
161
- */
162
- clusterMode: boolean
163
-
164
- logger: ISTSLogger
165
-
166
- publisherLogger: ISTSLogger
167
-
168
- publishInterval: number
169
- }