@nsshunt/stsdatamanagement 1.17.70 → 1.17.72

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.
@@ -0,0 +1,460 @@
1
+ -- SEQUENCE: public.stsentity_oid_seq
2
+
3
+ -- DROP SEQUENCE public.stsentity_oid_seq;
4
+
5
+ CREATE SEQUENCE public.stsentity_oid_seq
6
+ AS BIGINT
7
+ INCREMENT 1
8
+ START 1
9
+ MINVALUE 1
10
+ CACHE 1;
11
+
12
+ ALTER SEQUENCE public.stsentity_oid_seq
13
+ OWNER TO postgres;
14
+
15
+
16
+ -- SEQUENCE: public.stsresource_oid_seq
17
+
18
+ -- DROP SEQUENCE public.stsresource_oid_seq;
19
+
20
+ CREATE SEQUENCE public.stsresource_oid_seq
21
+ AS BIGINT
22
+ INCREMENT 1
23
+ START 1
24
+ MINVALUE 1
25
+ CACHE 1;
26
+
27
+ ALTER SEQUENCE public.stsresource_oid_seq
28
+ OWNER TO postgres;
29
+
30
+
31
+ -- Table: public.stsresource
32
+
33
+ -- DROP TABLE public.stsresource;
34
+
35
+ CREATE TABLE public.stsresource
36
+ (
37
+ oid bigint NOT NULL DEFAULT nextval('stsresource_oid_seq'::regclass),
38
+ resname character varying(128) COLLATE pg_catalog."default" NOT NULL,
39
+ resdesc character varying(32768) COLLATE pg_catalog."default",
40
+ vnum bigint NOT NULL,
41
+ validfrom timestamp with time zone NOT NULL,
42
+ validto timestamp with time zone,
43
+ dbaction smallint NOT NULL,
44
+ dbactionuser character varying(64) COLLATE pg_catalog."default" NOT NULL,
45
+ CONSTRAINT stsresource_pkey PRIMARY KEY (oid)
46
+ )
47
+
48
+ TABLESPACE pg_default;
49
+
50
+ ALTER TABLE public.stsresource
51
+ OWNER to postgres;
52
+ -- Index: stsresource_resname_vnum;
53
+
54
+ -- DROP INDEX public.stsresource_resname_vnum;
55
+
56
+ CREATE UNIQUE INDEX stsresource_resname_vnum
57
+ ON public.stsresource USING btree
58
+ (resname COLLATE pg_catalog."default" ASC NULLS LAST, vnum ASC NULLS LAST)
59
+ TABLESPACE pg_default;
60
+
61
+ -- Index: stsresource_resname_validto
62
+
63
+ -- DROP INDEX public.stsresource_resname_validto;
64
+
65
+ CREATE INDEX stsresource_resname_validto
66
+ ON public.stsresource USING btree
67
+ (resname COLLATE pg_catalog."default" ASC NULLS LAST, validto DESC NULLS LAST)
68
+ TABLESPACE pg_default;
69
+
70
+
71
+
72
+ -- Table: public.stsentity
73
+
74
+ -- DROP TABLE public.stsentity;
75
+
76
+ CREATE TABLE public.stsentity
77
+ (
78
+ oid bigint NOT NULL DEFAULT nextval('stsentity_oid_seq'::regclass),
79
+ stsresourceoid integer NOT NULL,
80
+ entname character varying(128) COLLATE pg_catalog."default" NOT NULL,
81
+ entvalue character varying(32768) COLLATE pg_catalog."default",
82
+ vnum bigint NOT NULL,
83
+ validfrom timestamp without time zone NOT NULL,
84
+ validto timestamp without time zone,
85
+ dbaction smallint NOT NULL,
86
+ dbactionuser character varying(64) COLLATE pg_catalog."default" NOT NULL,
87
+ CONSTRAINT stsentity_pkey PRIMARY KEY (oid),
88
+ CONSTRAINT fk_stsresource FOREIGN KEY (stsresourceoid)
89
+ REFERENCES public.stsresource (oid) MATCH SIMPLE
90
+ ON UPDATE NO ACTION
91
+ ON DELETE CASCADE
92
+ )
93
+
94
+ TABLESPACE pg_default;
95
+
96
+ ALTER TABLE public.stsentity
97
+ OWNER to postgres;
98
+ -- Index: stsentity_stsresourceid_entname
99
+
100
+ -- DROP INDEX public.stsentity_stsresourceoid_entname;
101
+
102
+ CREATE UNIQUE INDEX stsentity_stsresourceoid_entname_vnum
103
+ ON public.stsentity USING btree
104
+ (stsresourceoid ASC NULLS LAST, entname COLLATE pg_catalog."default" ASC NULLS LAST, vnum ASC NULLS LAST)
105
+ TABLESPACE pg_default;
106
+
107
+
108
+ -- FUNCTION: public.create_stsentity(character varying, character varying, integer, character varying, character varying)
109
+
110
+ -- DROP FUNCTION public.create_stsentity(character varying, character varying, integer, character varying, character varying);
111
+
112
+ CREATE OR REPLACE FUNCTION public.create_stsentity(
113
+ _dbactionuser character varying,
114
+ _resname character varying,
115
+ _resvnum integer,
116
+ _entname character varying,
117
+ _entvalue character varying)
118
+ RETURNS SETOF stsentity
119
+ LANGUAGE 'plpgsql'
120
+
121
+ COST 100
122
+ VOLATILE
123
+ ROWS 1000
124
+
125
+ AS $BODY$
126
+ declare
127
+ resoid bigint;
128
+ __inserted_oid bigint;
129
+ BEGIN
130
+ -- Ensure we get the current non-deleted resource.
131
+ resoid := (select oid from stsresource r where r.resname = _resname and r.vnum = _resvnum and r.validto is null and r.dbaction != 3);
132
+ if resoid is null then
133
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
134
+ RAISE 'resname and version not found or not current version (not deleted) within stsresource %', _resname USING ERRCODE = 'no_data_found';
135
+ end if;
136
+ if (select count(*) from stsentity e
137
+ where e.stsresourceoid = resoid and e.entname = _entname and e.validto is null and e.dbaction != 3) > 0 then
138
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
139
+ -- RAISE EXCEPTION 'resname already exists within stsresource %', now();
140
+ RAISE 'Duplicate entname within stsresource: %', _resname USING ERRCODE = 'unique_violation';
141
+ else
142
+ insert into stsentity(stsresourceoid, entname, entvalue, vnum, dbaction, dbactionuser, validfrom)
143
+ values (resoid, _entname, _entvalue, 1, 1, _dbactionuser, now())
144
+ returning oid into __inserted_oid;
145
+
146
+ return query
147
+ select * from stsentity where oid = __inserted_oid;
148
+ END IF;
149
+ END;
150
+ $BODY$;
151
+
152
+ ALTER FUNCTION public.create_stsentity(character varying, character varying, integer, character varying, character varying)
153
+ OWNER TO postgres;
154
+
155
+
156
+ -- FUNCTION: public.create_stsresource(character varying, character varying, character varying)
157
+
158
+ -- DROP FUNCTION public.create_stsresource(character varying, character varying, character varying);
159
+
160
+ CREATE OR REPLACE FUNCTION public.create_stsresource(
161
+ _dbactionuser character varying,
162
+ _resname character varying,
163
+ _resdesc character varying)
164
+ RETURNS SETOF stsresource
165
+ LANGUAGE 'plpgsql'
166
+
167
+ COST 100
168
+ VOLATILE
169
+ ROWS 1000
170
+
171
+ AS $BODY$
172
+ DECLARE
173
+ __now timestamp without time zone := now();
174
+ __resoid bigint;
175
+ __vnum bigint;
176
+ __dbaction smallint;
177
+ __inserted_oid bigint;
178
+ BEGIN
179
+ begin
180
+ select oid, vnum, dbaction into __resoid, __vnum, __dbaction from stsresource r where r.resname = _resname and r.validto is null;
181
+ -- Too many records exists using the supplied data, the database is in an invalid state for this resource
182
+ exception
183
+ when sqlstate '21000' then
184
+ raise exception 'Too many stsresource records for current version using stsresource %', _resname USING ERRCODE = 'cardinality_violation';
185
+ end;
186
+
187
+ if __resoid is not null then
188
+ -- We have an existing resource
189
+ if __dbaction = 3 then
190
+ -- The existing resource is deleted, end this current version
191
+ update stsresource set validto = __now where oid = __resoid;
192
+
193
+ -- Create a new record
194
+ insert into stsresource(resname, resdesc, vnum, dbaction, dbactionuser, validfrom)
195
+ values (_resname, _resdesc, __vnum+1, 1, _dbactionuser, __now)
196
+ returning oid into __inserted_oid;
197
+
198
+ return query
199
+ select * from stsresource where oid = __inserted_oid;
200
+ else
201
+ -- The current version is in an active state, raise unique violate condition
202
+ RAISE 'Duplicate resname within stsresource: %', _resname USING ERRCODE = 'unique_violation';
203
+ end if;
204
+ else
205
+ /*
206
+ For some unknown reason, the below works in pg outside and inside a docker container
207
+ but does NOT work inside a docker swarm of a K3 cluster.
208
+ -- No current version exists, create a new record
209
+ return query
210
+ insert into stsresource(resname, resdesc, vnum, dbaction, dbactionuser, validfrom)
211
+ values (_resname, _resdesc, 1, 1, _dbactionuser, __now)
212
+ returning *;
213
+ */
214
+
215
+ insert into stsresource(resname, resdesc, vnum, dbaction, dbactionuser, validfrom)
216
+ values (_resname, _resdesc, 1, 1, _dbactionuser, __now)
217
+ returning oid into __inserted_oid;
218
+
219
+ return query
220
+ select * from stsresource where oid = __inserted_oid;
221
+ end if;
222
+ END;
223
+ $BODY$;
224
+
225
+ ALTER FUNCTION public.create_stsresource(character varying, character varying, character varying)
226
+ OWNER TO postgres;
227
+
228
+
229
+ -- FUNCTION: public.delete_stsentity(character varying, character varying, integer, character varying, integer)
230
+
231
+ -- DROP FUNCTION public.delete_stsentity(character varying, character varying, integer, character varying, integer);
232
+
233
+ CREATE OR REPLACE FUNCTION public.delete_stsentity(
234
+ _dbactionuser character varying,
235
+ _resname character varying,
236
+ _resvnum integer,
237
+ _entname character varying,
238
+ _entvnum integer)
239
+ RETURNS SETOF stsentity
240
+ LANGUAGE 'plpgsql'
241
+
242
+ COST 100
243
+ VOLATILE
244
+ ROWS 1000
245
+
246
+ AS $BODY$
247
+ declare
248
+ _now timestamp without time zone := now();
249
+ resoid bigint;
250
+ entoid bigint;
251
+ __inserted_oid bigint;
252
+ BEGIN
253
+ BEGIN
254
+ -- Ensure we get the current non-deleted resource.
255
+ resoid := (select oid from stsresource r where r.resname = _resname and r.vnum = _resvnum and r.validto is null and r.dbaction != 3);
256
+ exception
257
+ when sqlstate '21000' then
258
+ raise exception 'Too many stsresource records for current version using stsresource %', _resname USING ERRCODE = 'cardinality_violation';
259
+ END;
260
+ if resoid is null then
261
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
262
+ RAISE 'resname and version not found or not current version (not deleted) within stsresource %', _resname USING ERRCODE = 'no_data_found';
263
+ end if;
264
+
265
+ -- Ensure we get the current non-deleted entity for this resource.
266
+ begin
267
+ entoid = (select oid from stsentity e where e.stsresourceoid = resoid and e.entname = _entname and e.vnum = _entvnum and e.validto is null and e.dbaction != 3);
268
+ exception
269
+ when sqlstate '21000' then
270
+ raise exception 'Too many stsentity records for current version using stsentity %', _entname USING ERRCODE = 'cardinality_violation';
271
+ end;
272
+
273
+ if entoid is null then
274
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
275
+ RAISE 'entname and version not found or not current version (not deleted) within stsentity %', _entname USING ERRCODE = 'no_data_found';
276
+ end if;
277
+
278
+ update stsentity set validto = _now where oid = entoid;
279
+
280
+ insert into stsentity(stsresourceoid, entname, entvalue, vnum, dbaction, dbactionuser, validfrom)
281
+ (select resoid, e.entname, e.entvalue, _entvnum+1, 3, _dbactionuser, _now
282
+ from stsentity e where e.oid = entoid)
283
+ returning oid into __inserted_oid;
284
+
285
+ return query
286
+ select * from stsentity where oid = __inserted_oid;
287
+ END;
288
+ $BODY$;
289
+
290
+ ALTER FUNCTION public.delete_stsentity(character varying, character varying, integer, character varying, integer)
291
+ OWNER TO postgres;
292
+
293
+
294
+
295
+ -- FUNCTION: public.delete_stsresource(character varying, character varying, integer)
296
+
297
+ -- DROP FUNCTION public.delete_stsresource(character varying, character varying, integer);
298
+
299
+ CREATE OR REPLACE FUNCTION public.delete_stsresource(
300
+ _dbactionuser character varying,
301
+ _resname character varying,
302
+ _resvnum integer)
303
+ RETURNS SETOF stsresource
304
+ LANGUAGE 'plpgsql'
305
+
306
+ COST 100
307
+ VOLATILE
308
+ ROWS 1000
309
+
310
+ AS $BODY$
311
+ declare
312
+ _now timestamp without time zone := now();
313
+ resoid bigint;
314
+ newresoid stsresource.oid%TYPE;
315
+ BEGIN
316
+ begin
317
+ resoid := (select oid from stsresource r where r.resname = _resname and r.vnum = _resvnum and r.validto is null and r.dbaction != 3);
318
+ exception
319
+ when sqlstate '21000' then
320
+ raise exception 'Too many stsresource records for current version using stsresource %', _resname USING ERRCODE = 'cardinality_violation';
321
+ end;
322
+
323
+ if resoid is null then
324
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
325
+ RAISE 'resname and version not found or not current version within stsresource %', _resname USING ERRCODE = 'no_data_found';
326
+ end if;
327
+
328
+ update stsresource set validto = _now where oid = resoid;
329
+
330
+ insert into stsresource(resname, resdesc, vnum, dbaction, dbactionuser, validfrom)
331
+ select r.resname, r.resdesc, _resvnum+1, 3, _dbactionuser, _now
332
+ from stsresource r where r.oid = resoid
333
+ RETURNING oid INTO newresoid;
334
+
335
+ update stsentity set stsresourceoid = newresoid where stsresourceoid = resoid;
336
+
337
+ return query
338
+ select * from stsresource where oid = newresoid;
339
+ END;
340
+ $BODY$;
341
+
342
+ ALTER FUNCTION public.delete_stsresource(character varying, character varying, integer)
343
+ OWNER TO postgres;
344
+
345
+
346
+ -- FUNCTION: public.update_stsentity(character varying, character varying, integer, character varying, integer, character varying)
347
+
348
+ -- DROP FUNCTION public.update_stsentity(character varying, character varying, integer, character varying, integer, character varying);
349
+
350
+ CREATE OR REPLACE FUNCTION public.update_stsentity(
351
+ _dbactionuser character varying,
352
+ _resname character varying,
353
+ _resvnum integer,
354
+ _entname character varying,
355
+ _entvnum integer,
356
+ _entvalue character varying)
357
+ RETURNS SETOF stsentity
358
+ LANGUAGE 'plpgsql'
359
+
360
+ COST 100
361
+ VOLATILE
362
+ ROWS 1000
363
+
364
+ AS $BODY$
365
+ declare
366
+ _now timestamp without time zone := now();
367
+ resoid bigint;
368
+ entoid bigint;
369
+ __inserted_oid bigint;
370
+ BEGIN
371
+ BEGIN
372
+ -- Ensure we get the current non-deleted resource.
373
+ resoid := (select oid from stsresource r where r.resname = _resname and r.vnum = _resvnum and r.validto is null and r.dbaction != 3);
374
+ exception
375
+ when sqlstate '21000' then
376
+ raise exception 'Too many stsresource records for current version using stsresource %', _resname USING ERRCODE = 'cardinality_violation';
377
+ END;
378
+ if resoid is null then
379
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
380
+ RAISE 'resname and version not found or not current version (not deleted) within stsresource %', _resname USING ERRCODE = 'no_data_found';
381
+ end if;
382
+
383
+ -- Ensure we get the current non-deleted entity for this resource.
384
+ begin
385
+ entoid = (select oid from stsentity e where e.stsresourceoid = resoid and e.entname = _entname and e.vnum = _entvnum and e.validto is null and e.dbaction != 3);
386
+ exception
387
+ when sqlstate '21000' then
388
+ raise exception 'Too many stsentity records for current version using stsentity %', _entname USING ERRCODE = 'cardinality_violation';
389
+ end;
390
+
391
+ if entoid is null then
392
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
393
+ RAISE 'entname and version not found or not current version (not deleted) within stsentity %', _entname USING ERRCODE = 'no_data_found';
394
+ end if;
395
+
396
+ update stsentity set validto = _now where oid = entoid;
397
+
398
+ insert into stsentity(stsresourceoid, entname, entvalue, vnum, dbaction, dbactionuser, validfrom)
399
+ values (resoid, _entname, _entvalue, _entvnum+1, 2, _dbactionuser, _now)
400
+ returning oid into __inserted_oid;
401
+
402
+ return query
403
+ select * from stsentity where oid = __inserted_oid;
404
+ END;
405
+ $BODY$;
406
+
407
+ ALTER FUNCTION public.update_stsentity(character varying, character varying, integer, character varying, integer, character varying)
408
+ OWNER TO postgres;
409
+
410
+
411
+ -- FUNCTION: public.update_stsresource(character varying, character varying, integer, character varying)
412
+
413
+ -- DROP FUNCTION public.update_stsresource(character varying, character varying, integer, character varying);
414
+
415
+ CREATE OR REPLACE FUNCTION public.update_stsresource(
416
+ _dbactionuser character varying,
417
+ _resname character varying,
418
+ _resvnum integer,
419
+ _resdesc character varying)
420
+ RETURNS SETOF stsresource
421
+ LANGUAGE 'plpgsql'
422
+
423
+ COST 100
424
+ VOLATILE
425
+ ROWS 1000
426
+
427
+ AS $BODY$
428
+ declare
429
+ _now timestamp without time zone := now();
430
+ resoid bigint;
431
+ newresoid stsresource.oid%TYPE;
432
+ BEGIN
433
+ begin
434
+ resoid := (select oid from stsresource r where r.resname = _resname and r.vnum = _resvnum and r.validto is null and r.dbaction != 3);
435
+ exception
436
+ when sqlstate '21000' then
437
+ raise exception 'Too many stsresource records for current version using stsresource %', _resname USING ERRCODE = 'cardinality_violation';
438
+ end;
439
+
440
+ if resoid is null then
441
+ -- Exception Codes: https://www.postgresql.org/docs/10/errcodes-appendix.html
442
+ RAISE 'resname and version not found or not current version (not deleted) within stsresource %', _resname USING ERRCODE = 'no_data_found';
443
+ end if;
444
+
445
+ update stsresource set validto = _now where oid = resoid;
446
+
447
+ insert into stsresource(resname, resdesc, vnum, dbaction, dbactionuser, validfrom)
448
+ values (_resname, _resdesc, _resvnum+1, 2, _dbactionuser, _now)
449
+ RETURNING oid INTO newresoid;
450
+
451
+ update stsentity set stsresourceoid = newresoid where stsresourceoid = resoid;
452
+
453
+ return query
454
+ select * from stsresource where oid = newresoid;
455
+ END;
456
+ $BODY$;
457
+
458
+ ALTER FUNCTION public.update_stsresource(character varying, character varying, integer, character varying)
459
+ OWNER TO postgres;
460
+
@@ -0,0 +1,13 @@
1
+ CREATE UNIQUE INDEX stsresource_resname_vnum
2
+ ON public.stsresource USING btree
3
+ (resname COLLATE pg_catalog."default" ASC NULLS LAST, vnum ASC NULLS LAST)
4
+ TABLESPACE pg_default;
5
+
6
+ -- Index: stsresource_resname_validto
7
+
8
+ -- DROP INDEX public.stsresource_resname_validto;
9
+
10
+ CREATE INDEX stsresource_resname_validto
11
+ ON public.stsresource USING btree
12
+ (resname COLLATE pg_catalog."default" ASC NULLS LAST, validto DESC NULLS LAST)
13
+ TABLESPACE pg_default;
@@ -0,0 +1,13 @@
1
+ -- Database: testdb
2
+
3
+ -- DROP DATABASE testdb;
4
+
5
+ CREATE DATABASE testdb
6
+ WITH
7
+ OWNER = postgres
8
+ ENCODING = 'UTF8'
9
+ LC_COLLATE = 'en_AU.UTF-8'
10
+ LC_CTYPE = 'en_AU.UTF-8'
11
+ TABLESPACE = pg_default
12
+ CONNECTION LIMIT = -1;
13
+
@@ -0,0 +1,2 @@
1
+ DROP INDEX public.stsresource_resname_vnum;
2
+ DROP INDEX public.stsresource_resname_validto;
@@ -0,0 +1,7 @@
1
+ --DROP FUNCTION public.create_stsresource(character varying, character varying, character varying);
2
+ --DROP FUNCTION public.update_stsresource(integer, character varying, character varying, character varying);
3
+ --DROP FUNCTION public.delete_stsresource(integer, character varying, character varying);
4
+ DROP SEQUENCE IF EXISTS public.stsresource_oid_seq CASCADE;
5
+ DROP SEQUENCE IF EXISTS public.stsentity_oid_seq CASCADE;
6
+ DROP TABLE IF EXISTS public.stsentity CASCADE;
7
+ DROP TABLE IF EXISTS public.stsresource CASCADE;
@@ -0,0 +1,7 @@
1
+ select * from create_stsresource('createuser', 'res01', 'resource res01');
2
+ select * from create_stsentity('createuser', 'res01', 1, 'ent01', 'entity ent01 for resource res01');
3
+ select * from create_stsentity('createuser', 'res01', 1, 'ent02', 'entity ent02 for resource res01');
4
+
5
+ select * from stsresource;
6
+ select * from stsentity;
7
+
@@ -0,0 +1,25 @@
1
+ select * from create_stsresource('createuser', 'res01', 'resource res01');
2
+ select * from create_stsentity('createuser', 'res01', 1, 'ent01', 'entity ent01 for resource res01');
3
+ select * from create_stsentity('createuser', 'res01', 1, 'ent02', 'entity ent02 for resource res01');
4
+
5
+
6
+ select * from create_stsresource('createuser', 'res02', 'create a new record');
7
+
8
+
9
+
10
+
11
+ select * from create_stsresource('createuser', 'res07', 'create a new record');
12
+ select * from update_stsresource(1, 'updateuser', 'res07', 'update an existing record');
13
+
14
+ select * from create_stsresource('createuser', 'res08', 'create a new record');
15
+ select * from update_stsresource(1, 'updateuser', 'res08', 'update an existing record');
16
+ select * from update_stsresource(2, 'updateuser', 'res08', 'update an existing record');
17
+
18
+ select * from create_stsresource('createuser', 'res09', 'create a new record');
19
+ select * from update_stsresource(1, 'updateuser', 'res09', 'update an existing record');
20
+ select * from update_stsresource(2, 'updateuser', 'res09', 'update an existing record');
21
+ select * from delete_stsresource(3, 'deleteuser', 'res09');
22
+ select * from stsresource where resname = 'res09' and validto is null and dbaction != 3;
23
+ select * from stsresource where validto is null and dbaction != 3; -- Get all current and active resources
24
+ select * from stsresource where validto is null; -- Get all current resources including deletes
25
+ select * from stsresource order by resname, vnum desc -- Get all resources
@@ -0,0 +1 @@
1
+ truncate table stsresource cascade
@@ -19,7 +19,7 @@ exports.PGPoolManager = void 0;
19
19
  const stsconfig_1 = require("@nsshunt/stsconfig");
20
20
  const { databaseUrl, connectionString, defaultDatabaseConnectionString, isProduction, poolSize } = (0, stsconfig_1.$Options)();
21
21
  const stsutils_1 = require("@nsshunt/stsutils");
22
- //import { Gauge, InstrumentGaugeTelemetry } from '@nsshunt/stsinstrumentation'
22
+ const stsinstrumentation_1 = require("@nsshunt/stsinstrumentation");
23
23
  const debug_1 = __importDefault(require("debug"));
24
24
  const debug = (0, debug_1.default)(`proc:${process.pid}`);
25
25
  require("colors");
@@ -95,27 +95,19 @@ class PGPoolManager {
95
95
  get pool() {
96
96
  return __classPrivateFieldGet(this, _PGPoolManager_pool, "f");
97
97
  }
98
- // eslint-disable-next-line @typescript-eslint/no-empty-function
99
98
  UpdateInstruments() {
100
- }
101
- /*
102
- UpdateInstruments()
103
- {
104
- if ($stsgd.app) {
105
- $stsgd.app.UpdateInstrument(Gauge.CONNECTION_POOL_TOTAL_GAUGE, {
99
+ if (stsutils_1.$stsgd.app) {
100
+ stsutils_1.$stsgd.app.UpdateInstrument(stsinstrumentation_1.Gauge.CONNECTION_POOL_TOTAL_GAUGE, {
106
101
  val: this.pool.totalCount
107
- } as InstrumentGaugeTelemetry);
108
-
109
- $stsgd.app.UpdateInstrument(Gauge.CONNECTION_POOL_IDLE_GAUGE, {
102
+ });
103
+ stsutils_1.$stsgd.app.UpdateInstrument(stsinstrumentation_1.Gauge.CONNECTION_POOL_IDLE_GAUGE, {
110
104
  val: this.pool.idleCount
111
- } as InstrumentGaugeTelemetry);
112
-
113
- $stsgd.app.UpdateInstrument(Gauge.CONNECTION_POOL_WAITING_GAUGE, {
105
+ });
106
+ stsutils_1.$stsgd.app.UpdateInstrument(stsinstrumentation_1.Gauge.CONNECTION_POOL_WAITING_GAUGE, {
114
107
  val: this.pool.waitingCount
115
- } as InstrumentGaugeTelemetry);
108
+ });
116
109
  }
117
110
  }
118
- */
119
111
  AttachInstruments(interval = 1000) {
120
112
  if (stsutils_1.$stsgd.app) {
121
113
  __classPrivateFieldSet(this, _PGPoolManager_observer, setInterval(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"pgpoolmanager.js","sourceRoot":"","sources":["../src/pgpoolmanager.ts"],"names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AI,CAAC,UAAU;aACA,CAAC,CAAC;YAE/B,iBAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0BAAK,CAAC,0BAA0B,EAAE;gBAC1D,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;aACC,CAAC,CAAC;YAE/B,iBAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0BAAK,CAAC,6BAA6B,EAAE;gBAC7D,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY;aACF,CAAC,CAAC;SAClC;IACL,CAAC;IAED,iBAAiB,CAAC,QAAQ,GAAG,IAAI;QAE7B,IAAI,iBAAM,CAAC,GAAG,EAAE;YACZ,uBAAA,IAAI,2BAAa,WAAW,CAAC,GAAG,EAAE;gBAE9B,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC7B,CAAC,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAA,CAAC;SACxB;IACL,CAAC;IAED,iBAAiB;QAEb,aAAa,CAAC,uBAAA,IAAI,+BAA0B,CAAC,CAAC;QAC9C,uBAAA,IAAI,2BAAa,IAAI,MAAA,CAAC;IAC1B,CAAC;CACJ;AAnHD,sCAmHC"}
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@nsshunt/stsdatamanagement",
3
- "version": "1.17.70",
3
+ "version": "1.17.72",
4
4
  "description": "STS Data Management Modules, Utilities and Services",
5
5
  "main": "./dist/dbaccess.js",
6
6
  "types": "./types/dbaccess.d.ts",
7
7
  "files": [
8
8
  "dist",
9
- "types"
9
+ "types",
10
+ "db-scripts"
10
11
  ],
11
12
  "dependencies": {
12
13
  "@nsshunt/stsconfig": "^1.25.36",
14
+ "@nsshunt/stsinstrumentation": "^6.11.79",
13
15
  "@nsshunt/stsutils": "^1.15.40",
14
16
  "axios": "^1.3.4",
15
17
  "cli-progress": "^3.12.0",
@@ -55,7 +57,7 @@
55
57
  "build": "tsc",
56
58
  "build5": "esbuild ./src/* --bundle --platform=node --packages=external --outdir=./dist",
57
59
  "build2": "tsc",
58
- "build3": "esbuild ./src/* --bundle --platform=node --packages=external --outdir=./dist",
60
+ "build3": "npx tsc --emitDeclarationOnly && esbuild ./src/* --bundle --platform=node --packages=external --outdir=./dist",
59
61
  "build4": "tsc && vite build",
60
62
  "test": "vitest run --reporter verbose --threads false",
61
63
  "coverage": "vitest run --coverage"
@@ -1 +1 @@
1
- {"version":3,"file":"pgpoolmanager.d.ts","sourceRoot":"","sources":["../src/pgpoolmanager.ts"],"names":[],"mappings":"AASA,OAAO,QAAQ,CAAA;AAOf,OAAO,EAAE,IAAI,EAAc,MAAM,IAAI,CAAA;AAErC,MAAM,WAAW,oBAAoB;IACpC,YAAY,EAAE,OAAO,CAAA;CACrB;AAED,qBAAa,aAAa;;gBAMV,OAAO,CAAC,EAAE,oBAAoB;IAwE1C,IAAI,IAAI,IAAI,IAAI,CAGf;IAGD,iBAAiB;IAuBjB,iBAAiB,CAAC,QAAQ,SAAO;IAUjC,iBAAiB;CAKpB"}
1
+ {"version":3,"file":"pgpoolmanager.d.ts","sourceRoot":"","sources":["../src/pgpoolmanager.ts"],"names":[],"mappings":"AASA,OAAO,QAAQ,CAAA;AAOf,OAAO,EAAE,IAAI,EAAc,MAAM,IAAI,CAAA;AAErC,MAAM,WAAW,oBAAoB;IACpC,YAAY,EAAE,OAAO,CAAA;CACrB;AAED,qBAAa,aAAa;;gBAMV,OAAO,CAAC,EAAE,oBAAoB;IAwE1C,IAAI,IAAI,IAAI,IAAI,CAGf;IAED,iBAAiB;IAiBjB,iBAAiB,CAAC,QAAQ,SAAO;IAUjC,iBAAiB;CAKpB"}