@tstdl/base 0.93.77 → 0.93.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/authentication/client/http-client.middleware.js +2 -2
- package/authentication/models/authentication-credentials.model.d.ts +2 -2
- package/authentication/models/authentication-credentials.model.js +5 -3
- package/authentication/models/authentication-session.model.d.ts +2 -2
- package/authentication/models/authentication-session.model.js +5 -3
- package/authentication/models/index.d.ts +4 -0
- package/authentication/models/index.js +4 -0
- package/authentication/models/service-account.model.d.ts +7 -0
- package/authentication/models/service-account.model.js +31 -0
- package/authentication/models/subject.model.d.ts +16 -0
- package/authentication/models/subject.model.js +59 -0
- package/authentication/models/system-account.model.d.ts +5 -0
- package/authentication/models/system-account.model.js +25 -0
- package/authentication/models/user.model.d.ts +15 -0
- package/authentication/models/user.model.js +47 -0
- package/authentication/server/drizzle/0000_violet_callisto.sql +99 -0
- package/authentication/server/drizzle/meta/0000_snapshot.json +500 -6
- package/authentication/server/drizzle/meta/_journal.json +2 -2
- package/authentication/server/index.d.ts +1 -0
- package/authentication/server/index.js +1 -0
- package/authentication/server/schemas.d.ts +16 -1
- package/authentication/server/schemas.js +7 -1
- package/authentication/server/subject.service.d.ts +6 -0
- package/authentication/server/subject.service.js +44 -0
- package/circuit-breaker/circuit-breaker.d.ts +32 -0
- package/circuit-breaker/circuit-breaker.js +9 -0
- package/circuit-breaker/index.d.ts +2 -0
- package/circuit-breaker/index.js +2 -0
- package/circuit-breaker/postgres/circuit-breaker.d.ts +7 -0
- package/circuit-breaker/postgres/circuit-breaker.js +78 -0
- package/circuit-breaker/postgres/drizzle/0000_hard_shocker.sql +9 -0
- package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +82 -0
- package/circuit-breaker/postgres/drizzle/meta/_journal.json +13 -0
- package/circuit-breaker/postgres/drizzle.config.d.ts +2 -0
- package/circuit-breaker/postgres/drizzle.config.js +11 -0
- package/circuit-breaker/postgres/index.d.ts +5 -0
- package/circuit-breaker/postgres/index.js +5 -0
- package/circuit-breaker/postgres/model.d.ts +9 -0
- package/circuit-breaker/postgres/model.js +40 -0
- package/circuit-breaker/postgres/module.d.ts +6 -0
- package/circuit-breaker/postgres/module.js +25 -0
- package/circuit-breaker/postgres/provider.d.ts +6 -0
- package/circuit-breaker/postgres/provider.js +21 -0
- package/circuit-breaker/postgres/schemas.d.ts +8 -0
- package/circuit-breaker/postgres/schemas.js +6 -0
- package/circuit-breaker/provider.d.ts +4 -0
- package/circuit-breaker/provider.js +2 -0
- package/circuit-breaker/tests/circuit-breaker.test.js +113 -0
- package/document-management/models/document.model.d.ts +0 -1
- package/document-management/models/document.model.js +0 -5
- package/document-management/server/api/document-management.api.js +1 -2
- package/document-management/server/drizzle/{0000_ordinary_pretty_boy.sql → 0000_glamorous_lorna_dane.sql} +96 -76
- package/document-management/server/drizzle/meta/0000_snapshot.json +360 -142
- package/document-management/server/drizzle/meta/_journal.json +2 -9
- package/document-management/server/services/document-collection.service.js +3 -3
- package/document-management/server/services/document-management-ancillary.service.d.ts +1 -1
- package/document-management/server/services/document-management.service.js +1 -1
- package/document-management/server/services/document-workflow.service.js +5 -5
- package/document-management/server/services/document.service.d.ts +0 -2
- package/document-management/server/services/document.service.js +1 -2
- package/document-management/service-models/enriched/enriched-document.view.d.ts +1 -1
- package/examples/document-management/main.d.ts +1 -1
- package/examples/document-management/main.js +1 -1
- package/logger/transports/console.d.ts +1 -1
- package/logger/transports/console.js +4 -1
- package/message-bus/message-bus-base.js +1 -1
- package/orm/server/drizzle/schema-converter.js +53 -32
- package/package.json +6 -3
- package/queue/enqueue-batch.d.ts +11 -11
- package/queue/enqueue-batch.js +2 -3
- package/queue/index.d.ts +1 -0
- package/queue/index.js +1 -0
- package/queue/postgres/drizzle/0003_tricky_venom.sql +30 -0
- package/queue/postgres/drizzle/meta/0003_snapshot.json +288 -0
- package/queue/postgres/drizzle/meta/_journal.json +7 -0
- package/queue/postgres/drizzle.config.js +2 -2
- package/queue/postgres/index.d.ts +1 -1
- package/queue/postgres/index.js +1 -1
- package/queue/postgres/module.d.ts +1 -1
- package/queue/postgres/module.js +1 -1
- package/queue/postgres/queue.d.ts +52 -23
- package/queue/postgres/queue.js +582 -64
- package/queue/postgres/queue.provider.d.ts +1 -1
- package/queue/postgres/schemas.d.ts +13 -2
- package/queue/postgres/schemas.js +4 -2
- package/queue/postgres/task.model.d.ts +24 -0
- package/queue/postgres/task.model.js +115 -0
- package/queue/provider.d.ts +1 -1
- package/queue/queue.d.ts +158 -37
- package/queue/queue.js +97 -19
- package/queue/task-context.d.ts +38 -0
- package/queue/task-context.js +102 -0
- package/queue/tests/queue.test.d.ts +1 -0
- package/queue/tests/queue.test.js +623 -0
- package/test4.d.ts +1 -1
- package/test4.js +1 -1
- package/utils/format-error.d.ts +17 -20
- package/utils/format-error.js +105 -47
- package/authentication/server/drizzle/0000_calm_warlock.sql +0 -28
- package/document-management/server/drizzle/0001_lyrical_wong.sql +0 -123
- package/document-management/server/drizzle/meta/0001_snapshot.json +0 -2728
- package/queue/postgres/job.model.d.ts +0 -12
- package/queue/postgres/job.model.js +0 -53
- package/test6.js +0 -33
- /package/{test6.d.ts → circuit-breaker/tests/circuit-breaker.test.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "c88f8c29-7029-4da0-b085-bd866a480533",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"subject": {
|
|
19
19
|
"name": "subject",
|
|
20
|
-
"type": "
|
|
20
|
+
"type": "uuid",
|
|
21
21
|
"primaryKey": false,
|
|
22
22
|
"notNull": true
|
|
23
23
|
},
|
|
@@ -72,7 +72,22 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"indexes": {},
|
|
75
|
-
"foreignKeys": {
|
|
75
|
+
"foreignKeys": {
|
|
76
|
+
"credentials_subject_subject_id_fk": {
|
|
77
|
+
"name": "credentials_subject_subject_id_fk",
|
|
78
|
+
"tableFrom": "credentials",
|
|
79
|
+
"tableTo": "subject",
|
|
80
|
+
"schemaTo": "authentication",
|
|
81
|
+
"columnsFrom": [
|
|
82
|
+
"subject"
|
|
83
|
+
],
|
|
84
|
+
"columnsTo": [
|
|
85
|
+
"id"
|
|
86
|
+
],
|
|
87
|
+
"onDelete": "no action",
|
|
88
|
+
"onUpdate": "no action"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
76
91
|
"compositePrimaryKeys": {},
|
|
77
92
|
"uniqueConstraints": {
|
|
78
93
|
"credentials_subject_unique": {
|
|
@@ -100,7 +115,7 @@
|
|
|
100
115
|
},
|
|
101
116
|
"subject": {
|
|
102
117
|
"name": "subject",
|
|
103
|
-
"type": "
|
|
118
|
+
"type": "uuid",
|
|
104
119
|
"primaryKey": false,
|
|
105
120
|
"notNull": true
|
|
106
121
|
},
|
|
@@ -167,15 +182,494 @@
|
|
|
167
182
|
}
|
|
168
183
|
},
|
|
169
184
|
"indexes": {},
|
|
170
|
-
"foreignKeys": {
|
|
185
|
+
"foreignKeys": {
|
|
186
|
+
"session_subject_subject_id_fk": {
|
|
187
|
+
"name": "session_subject_subject_id_fk",
|
|
188
|
+
"tableFrom": "session",
|
|
189
|
+
"tableTo": "subject",
|
|
190
|
+
"schemaTo": "authentication",
|
|
191
|
+
"columnsFrom": [
|
|
192
|
+
"subject"
|
|
193
|
+
],
|
|
194
|
+
"columnsTo": [
|
|
195
|
+
"id"
|
|
196
|
+
],
|
|
197
|
+
"onDelete": "no action",
|
|
198
|
+
"onUpdate": "no action"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
171
201
|
"compositePrimaryKeys": {},
|
|
172
202
|
"uniqueConstraints": {},
|
|
173
203
|
"policies": {},
|
|
174
204
|
"checkConstraints": {},
|
|
175
205
|
"isRLSEnabled": false
|
|
206
|
+
},
|
|
207
|
+
"authentication.service_account": {
|
|
208
|
+
"name": "service_account",
|
|
209
|
+
"schema": "authentication",
|
|
210
|
+
"columns": {
|
|
211
|
+
"id": {
|
|
212
|
+
"name": "id",
|
|
213
|
+
"type": "uuid",
|
|
214
|
+
"primaryKey": false,
|
|
215
|
+
"notNull": true,
|
|
216
|
+
"default": "gen_random_uuid()"
|
|
217
|
+
},
|
|
218
|
+
"tenant_id": {
|
|
219
|
+
"name": "tenant_id",
|
|
220
|
+
"type": "uuid",
|
|
221
|
+
"primaryKey": false,
|
|
222
|
+
"notNull": true
|
|
223
|
+
},
|
|
224
|
+
"description": {
|
|
225
|
+
"name": "description",
|
|
226
|
+
"type": "text",
|
|
227
|
+
"primaryKey": false,
|
|
228
|
+
"notNull": true
|
|
229
|
+
},
|
|
230
|
+
"parent": {
|
|
231
|
+
"name": "parent",
|
|
232
|
+
"type": "uuid",
|
|
233
|
+
"primaryKey": false,
|
|
234
|
+
"notNull": false
|
|
235
|
+
},
|
|
236
|
+
"revision": {
|
|
237
|
+
"name": "revision",
|
|
238
|
+
"type": "integer",
|
|
239
|
+
"primaryKey": false,
|
|
240
|
+
"notNull": true
|
|
241
|
+
},
|
|
242
|
+
"revision_timestamp": {
|
|
243
|
+
"name": "revision_timestamp",
|
|
244
|
+
"type": "timestamp with time zone",
|
|
245
|
+
"primaryKey": false,
|
|
246
|
+
"notNull": true
|
|
247
|
+
},
|
|
248
|
+
"create_timestamp": {
|
|
249
|
+
"name": "create_timestamp",
|
|
250
|
+
"type": "timestamp with time zone",
|
|
251
|
+
"primaryKey": false,
|
|
252
|
+
"notNull": true
|
|
253
|
+
},
|
|
254
|
+
"delete_timestamp": {
|
|
255
|
+
"name": "delete_timestamp",
|
|
256
|
+
"type": "timestamp with time zone",
|
|
257
|
+
"primaryKey": false,
|
|
258
|
+
"notNull": false
|
|
259
|
+
},
|
|
260
|
+
"attributes": {
|
|
261
|
+
"name": "attributes",
|
|
262
|
+
"type": "jsonb",
|
|
263
|
+
"primaryKey": false,
|
|
264
|
+
"notNull": true,
|
|
265
|
+
"default": "'{}'::jsonb"
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"indexes": {},
|
|
269
|
+
"foreignKeys": {
|
|
270
|
+
"service_account_id_subject_fkey": {
|
|
271
|
+
"name": "service_account_id_subject_fkey",
|
|
272
|
+
"tableFrom": "service_account",
|
|
273
|
+
"tableTo": "subject",
|
|
274
|
+
"schemaTo": "authentication",
|
|
275
|
+
"columnsFrom": [
|
|
276
|
+
"tenant_id",
|
|
277
|
+
"parent"
|
|
278
|
+
],
|
|
279
|
+
"columnsTo": [
|
|
280
|
+
"tenant_id",
|
|
281
|
+
"id"
|
|
282
|
+
],
|
|
283
|
+
"onDelete": "no action",
|
|
284
|
+
"onUpdate": "no action"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
"compositePrimaryKeys": {
|
|
288
|
+
"service_account_tenant_id_id_pk": {
|
|
289
|
+
"name": "service_account_tenant_id_id_pk",
|
|
290
|
+
"columns": [
|
|
291
|
+
"tenant_id",
|
|
292
|
+
"id"
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"uniqueConstraints": {},
|
|
297
|
+
"policies": {},
|
|
298
|
+
"checkConstraints": {},
|
|
299
|
+
"isRLSEnabled": false
|
|
300
|
+
},
|
|
301
|
+
"authentication.subject": {
|
|
302
|
+
"name": "subject",
|
|
303
|
+
"schema": "authentication",
|
|
304
|
+
"columns": {
|
|
305
|
+
"id": {
|
|
306
|
+
"name": "id",
|
|
307
|
+
"type": "uuid",
|
|
308
|
+
"primaryKey": false,
|
|
309
|
+
"notNull": true,
|
|
310
|
+
"default": "gen_random_uuid()"
|
|
311
|
+
},
|
|
312
|
+
"tenant_id": {
|
|
313
|
+
"name": "tenant_id",
|
|
314
|
+
"type": "uuid",
|
|
315
|
+
"primaryKey": false,
|
|
316
|
+
"notNull": true
|
|
317
|
+
},
|
|
318
|
+
"type": {
|
|
319
|
+
"name": "type",
|
|
320
|
+
"type": "subject_type",
|
|
321
|
+
"typeSchema": "authentication",
|
|
322
|
+
"primaryKey": false,
|
|
323
|
+
"notNull": true
|
|
324
|
+
},
|
|
325
|
+
"display_name": {
|
|
326
|
+
"name": "display_name",
|
|
327
|
+
"type": "text",
|
|
328
|
+
"primaryKey": false,
|
|
329
|
+
"notNull": true
|
|
330
|
+
},
|
|
331
|
+
"system_account_id": {
|
|
332
|
+
"name": "system_account_id",
|
|
333
|
+
"type": "uuid",
|
|
334
|
+
"primaryKey": false,
|
|
335
|
+
"notNull": false
|
|
336
|
+
},
|
|
337
|
+
"user_id": {
|
|
338
|
+
"name": "user_id",
|
|
339
|
+
"type": "uuid",
|
|
340
|
+
"primaryKey": false,
|
|
341
|
+
"notNull": false
|
|
342
|
+
},
|
|
343
|
+
"service_account_id": {
|
|
344
|
+
"name": "service_account_id",
|
|
345
|
+
"type": "uuid",
|
|
346
|
+
"primaryKey": false,
|
|
347
|
+
"notNull": false
|
|
348
|
+
},
|
|
349
|
+
"revision": {
|
|
350
|
+
"name": "revision",
|
|
351
|
+
"type": "integer",
|
|
352
|
+
"primaryKey": false,
|
|
353
|
+
"notNull": true
|
|
354
|
+
},
|
|
355
|
+
"revision_timestamp": {
|
|
356
|
+
"name": "revision_timestamp",
|
|
357
|
+
"type": "timestamp with time zone",
|
|
358
|
+
"primaryKey": false,
|
|
359
|
+
"notNull": true
|
|
360
|
+
},
|
|
361
|
+
"create_timestamp": {
|
|
362
|
+
"name": "create_timestamp",
|
|
363
|
+
"type": "timestamp with time zone",
|
|
364
|
+
"primaryKey": false,
|
|
365
|
+
"notNull": true
|
|
366
|
+
},
|
|
367
|
+
"delete_timestamp": {
|
|
368
|
+
"name": "delete_timestamp",
|
|
369
|
+
"type": "timestamp with time zone",
|
|
370
|
+
"primaryKey": false,
|
|
371
|
+
"notNull": false
|
|
372
|
+
},
|
|
373
|
+
"attributes": {
|
|
374
|
+
"name": "attributes",
|
|
375
|
+
"type": "jsonb",
|
|
376
|
+
"primaryKey": false,
|
|
377
|
+
"notNull": true,
|
|
378
|
+
"default": "'{}'::jsonb"
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
"indexes": {},
|
|
382
|
+
"foreignKeys": {
|
|
383
|
+
"subject_id_system_account_fkey": {
|
|
384
|
+
"name": "subject_id_system_account_fkey",
|
|
385
|
+
"tableFrom": "subject",
|
|
386
|
+
"tableTo": "system_account",
|
|
387
|
+
"schemaTo": "authentication",
|
|
388
|
+
"columnsFrom": [
|
|
389
|
+
"tenant_id",
|
|
390
|
+
"system_account_id"
|
|
391
|
+
],
|
|
392
|
+
"columnsTo": [
|
|
393
|
+
"tenant_id",
|
|
394
|
+
"id"
|
|
395
|
+
],
|
|
396
|
+
"onDelete": "no action",
|
|
397
|
+
"onUpdate": "no action"
|
|
398
|
+
},
|
|
399
|
+
"subject_id_user_fkey": {
|
|
400
|
+
"name": "subject_id_user_fkey",
|
|
401
|
+
"tableFrom": "subject",
|
|
402
|
+
"tableTo": "user",
|
|
403
|
+
"schemaTo": "authentication",
|
|
404
|
+
"columnsFrom": [
|
|
405
|
+
"tenant_id",
|
|
406
|
+
"user_id"
|
|
407
|
+
],
|
|
408
|
+
"columnsTo": [
|
|
409
|
+
"tenant_id",
|
|
410
|
+
"id"
|
|
411
|
+
],
|
|
412
|
+
"onDelete": "no action",
|
|
413
|
+
"onUpdate": "no action"
|
|
414
|
+
},
|
|
415
|
+
"subject_id_service_account_fkey": {
|
|
416
|
+
"name": "subject_id_service_account_fkey",
|
|
417
|
+
"tableFrom": "subject",
|
|
418
|
+
"tableTo": "service_account",
|
|
419
|
+
"schemaTo": "authentication",
|
|
420
|
+
"columnsFrom": [
|
|
421
|
+
"tenant_id",
|
|
422
|
+
"service_account_id"
|
|
423
|
+
],
|
|
424
|
+
"columnsTo": [
|
|
425
|
+
"tenant_id",
|
|
426
|
+
"id"
|
|
427
|
+
],
|
|
428
|
+
"onDelete": "no action",
|
|
429
|
+
"onUpdate": "no action"
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
"compositePrimaryKeys": {
|
|
433
|
+
"subject_tenant_id_id_pk": {
|
|
434
|
+
"name": "subject_tenant_id_id_pk",
|
|
435
|
+
"columns": [
|
|
436
|
+
"tenant_id",
|
|
437
|
+
"id"
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
"uniqueConstraints": {
|
|
442
|
+
"subject_system_account_id_unique": {
|
|
443
|
+
"name": "subject_system_account_id_unique",
|
|
444
|
+
"nullsNotDistinct": false,
|
|
445
|
+
"columns": [
|
|
446
|
+
"system_account_id"
|
|
447
|
+
]
|
|
448
|
+
},
|
|
449
|
+
"subject_user_id_unique": {
|
|
450
|
+
"name": "subject_user_id_unique",
|
|
451
|
+
"nullsNotDistinct": false,
|
|
452
|
+
"columns": [
|
|
453
|
+
"user_id"
|
|
454
|
+
]
|
|
455
|
+
},
|
|
456
|
+
"subject_service_account_id_unique": {
|
|
457
|
+
"name": "subject_service_account_id_unique",
|
|
458
|
+
"nullsNotDistinct": false,
|
|
459
|
+
"columns": [
|
|
460
|
+
"service_account_id"
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
"policies": {},
|
|
465
|
+
"checkConstraints": {
|
|
466
|
+
"authentication_subject_reference_check": {
|
|
467
|
+
"name": "authentication_subject_reference_check",
|
|
468
|
+
"value": "num_nonnulls(\"authentication\".\"subject\".\"system_account_id\", \"authentication\".\"subject\".\"user_id\", \"authentication\".\"subject\".\"service_account_id\") = 1"
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
"isRLSEnabled": false
|
|
472
|
+
},
|
|
473
|
+
"authentication.system_account": {
|
|
474
|
+
"name": "system_account",
|
|
475
|
+
"schema": "authentication",
|
|
476
|
+
"columns": {
|
|
477
|
+
"id": {
|
|
478
|
+
"name": "id",
|
|
479
|
+
"type": "uuid",
|
|
480
|
+
"primaryKey": false,
|
|
481
|
+
"notNull": true,
|
|
482
|
+
"default": "gen_random_uuid()"
|
|
483
|
+
},
|
|
484
|
+
"tenant_id": {
|
|
485
|
+
"name": "tenant_id",
|
|
486
|
+
"type": "uuid",
|
|
487
|
+
"primaryKey": false,
|
|
488
|
+
"notNull": true
|
|
489
|
+
},
|
|
490
|
+
"identifier": {
|
|
491
|
+
"name": "identifier",
|
|
492
|
+
"type": "text",
|
|
493
|
+
"primaryKey": false,
|
|
494
|
+
"notNull": true
|
|
495
|
+
},
|
|
496
|
+
"revision": {
|
|
497
|
+
"name": "revision",
|
|
498
|
+
"type": "integer",
|
|
499
|
+
"primaryKey": false,
|
|
500
|
+
"notNull": true
|
|
501
|
+
},
|
|
502
|
+
"revision_timestamp": {
|
|
503
|
+
"name": "revision_timestamp",
|
|
504
|
+
"type": "timestamp with time zone",
|
|
505
|
+
"primaryKey": false,
|
|
506
|
+
"notNull": true
|
|
507
|
+
},
|
|
508
|
+
"create_timestamp": {
|
|
509
|
+
"name": "create_timestamp",
|
|
510
|
+
"type": "timestamp with time zone",
|
|
511
|
+
"primaryKey": false,
|
|
512
|
+
"notNull": true
|
|
513
|
+
},
|
|
514
|
+
"delete_timestamp": {
|
|
515
|
+
"name": "delete_timestamp",
|
|
516
|
+
"type": "timestamp with time zone",
|
|
517
|
+
"primaryKey": false,
|
|
518
|
+
"notNull": false
|
|
519
|
+
},
|
|
520
|
+
"attributes": {
|
|
521
|
+
"name": "attributes",
|
|
522
|
+
"type": "jsonb",
|
|
523
|
+
"primaryKey": false,
|
|
524
|
+
"notNull": true,
|
|
525
|
+
"default": "'{}'::jsonb"
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
"indexes": {},
|
|
529
|
+
"foreignKeys": {},
|
|
530
|
+
"compositePrimaryKeys": {
|
|
531
|
+
"system_account_tenant_id_id_pk": {
|
|
532
|
+
"name": "system_account_tenant_id_id_pk",
|
|
533
|
+
"columns": [
|
|
534
|
+
"tenant_id",
|
|
535
|
+
"id"
|
|
536
|
+
]
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
"uniqueConstraints": {
|
|
540
|
+
"system_account_identifier_unique": {
|
|
541
|
+
"name": "system_account_identifier_unique",
|
|
542
|
+
"nullsNotDistinct": false,
|
|
543
|
+
"columns": [
|
|
544
|
+
"identifier"
|
|
545
|
+
]
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
"policies": {},
|
|
549
|
+
"checkConstraints": {},
|
|
550
|
+
"isRLSEnabled": false
|
|
551
|
+
},
|
|
552
|
+
"authentication.user": {
|
|
553
|
+
"name": "user",
|
|
554
|
+
"schema": "authentication",
|
|
555
|
+
"columns": {
|
|
556
|
+
"id": {
|
|
557
|
+
"name": "id",
|
|
558
|
+
"type": "uuid",
|
|
559
|
+
"primaryKey": false,
|
|
560
|
+
"notNull": true,
|
|
561
|
+
"default": "gen_random_uuid()"
|
|
562
|
+
},
|
|
563
|
+
"tenant_id": {
|
|
564
|
+
"name": "tenant_id",
|
|
565
|
+
"type": "uuid",
|
|
566
|
+
"primaryKey": false,
|
|
567
|
+
"notNull": true
|
|
568
|
+
},
|
|
569
|
+
"status": {
|
|
570
|
+
"name": "status",
|
|
571
|
+
"type": "user_status",
|
|
572
|
+
"typeSchema": "authentication",
|
|
573
|
+
"primaryKey": false,
|
|
574
|
+
"notNull": true
|
|
575
|
+
},
|
|
576
|
+
"email": {
|
|
577
|
+
"name": "email",
|
|
578
|
+
"type": "text",
|
|
579
|
+
"primaryKey": false,
|
|
580
|
+
"notNull": true
|
|
581
|
+
},
|
|
582
|
+
"first_name": {
|
|
583
|
+
"name": "first_name",
|
|
584
|
+
"type": "text",
|
|
585
|
+
"primaryKey": false,
|
|
586
|
+
"notNull": true
|
|
587
|
+
},
|
|
588
|
+
"last_name": {
|
|
589
|
+
"name": "last_name",
|
|
590
|
+
"type": "text",
|
|
591
|
+
"primaryKey": false,
|
|
592
|
+
"notNull": true
|
|
593
|
+
},
|
|
594
|
+
"revision": {
|
|
595
|
+
"name": "revision",
|
|
596
|
+
"type": "integer",
|
|
597
|
+
"primaryKey": false,
|
|
598
|
+
"notNull": true
|
|
599
|
+
},
|
|
600
|
+
"revision_timestamp": {
|
|
601
|
+
"name": "revision_timestamp",
|
|
602
|
+
"type": "timestamp with time zone",
|
|
603
|
+
"primaryKey": false,
|
|
604
|
+
"notNull": true
|
|
605
|
+
},
|
|
606
|
+
"create_timestamp": {
|
|
607
|
+
"name": "create_timestamp",
|
|
608
|
+
"type": "timestamp with time zone",
|
|
609
|
+
"primaryKey": false,
|
|
610
|
+
"notNull": true
|
|
611
|
+
},
|
|
612
|
+
"delete_timestamp": {
|
|
613
|
+
"name": "delete_timestamp",
|
|
614
|
+
"type": "timestamp with time zone",
|
|
615
|
+
"primaryKey": false,
|
|
616
|
+
"notNull": false
|
|
617
|
+
},
|
|
618
|
+
"attributes": {
|
|
619
|
+
"name": "attributes",
|
|
620
|
+
"type": "jsonb",
|
|
621
|
+
"primaryKey": false,
|
|
622
|
+
"notNull": true,
|
|
623
|
+
"default": "'{}'::jsonb"
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
"indexes": {},
|
|
627
|
+
"foreignKeys": {},
|
|
628
|
+
"compositePrimaryKeys": {
|
|
629
|
+
"user_tenant_id_id_pk": {
|
|
630
|
+
"name": "user_tenant_id_id_pk",
|
|
631
|
+
"columns": [
|
|
632
|
+
"tenant_id",
|
|
633
|
+
"id"
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
"uniqueConstraints": {
|
|
638
|
+
"user_tenant_id_email_unique": {
|
|
639
|
+
"name": "user_tenant_id_email_unique",
|
|
640
|
+
"nullsNotDistinct": false,
|
|
641
|
+
"columns": [
|
|
642
|
+
"tenant_id",
|
|
643
|
+
"email"
|
|
644
|
+
]
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
"policies": {},
|
|
648
|
+
"checkConstraints": {},
|
|
649
|
+
"isRLSEnabled": false
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
"enums": {
|
|
653
|
+
"authentication.subject_type": {
|
|
654
|
+
"name": "subject_type",
|
|
655
|
+
"schema": "authentication",
|
|
656
|
+
"values": [
|
|
657
|
+
"system",
|
|
658
|
+
"user",
|
|
659
|
+
"service-account"
|
|
660
|
+
]
|
|
661
|
+
},
|
|
662
|
+
"authentication.user_status": {
|
|
663
|
+
"name": "user_status",
|
|
664
|
+
"schema": "authentication",
|
|
665
|
+
"values": [
|
|
666
|
+
"active",
|
|
667
|
+
"suspended",
|
|
668
|
+
"pending-approval",
|
|
669
|
+
"invited"
|
|
670
|
+
]
|
|
176
671
|
}
|
|
177
672
|
},
|
|
178
|
-
"enums": {},
|
|
179
673
|
"schemas": {},
|
|
180
674
|
"sequences": {},
|
|
181
675
|
"roles": {},
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import { AuthenticationCredentials, AuthenticationSession } from '../models/index.js';
|
|
1
|
+
import { AuthenticationCredentials, AuthenticationSession, ServiceAccount, Subject, SystemAccount, User } from '../models/index.js';
|
|
2
2
|
export declare const authenticationSchema: import("../../orm/server/index.js").DatabaseSchema<"authentication">;
|
|
3
|
+
export declare const subjectType: import("../../orm/enums.js").PgEnumFromEnumeration<{
|
|
4
|
+
readonly System: "system";
|
|
5
|
+
readonly User: "user";
|
|
6
|
+
readonly ServiceAccount: "service-account";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const userStatus: import("../../orm/enums.js").PgEnumFromEnumeration<{
|
|
9
|
+
readonly Active: "active";
|
|
10
|
+
readonly Suspended: "suspended";
|
|
11
|
+
readonly PendingApproval: "pending-approval";
|
|
12
|
+
readonly Invited: "invited";
|
|
13
|
+
}>;
|
|
3
14
|
export declare const authenticationCredentials: import("../../orm/server/types.js").PgTableFromType<typeof AuthenticationCredentials, "authentication">;
|
|
4
15
|
export declare const authenticationSession: import("../../orm/server/types.js").PgTableFromType<typeof AuthenticationSession, "authentication">;
|
|
16
|
+
export declare const serviceAccount: import("../../orm/server/types.js").PgTableFromType<typeof ServiceAccount, "authentication">;
|
|
17
|
+
export declare const subject: import("../../orm/server/types.js").PgTableFromType<typeof Subject, "authentication">;
|
|
18
|
+
export declare const systemAccount: import("../../orm/server/types.js").PgTableFromType<typeof SystemAccount, "authentication">;
|
|
19
|
+
export declare const user: import("../../orm/server/types.js").PgTableFromType<typeof User, "authentication">;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { databaseSchema } from '../../orm/server/index.js';
|
|
2
|
-
import { AuthenticationCredentials, AuthenticationSession } from '../models/index.js';
|
|
2
|
+
import { AuthenticationCredentials, AuthenticationSession, ServiceAccount, Subject, SubjectType, SystemAccount, User, UserStatus } from '../models/index.js';
|
|
3
3
|
export const authenticationSchema = databaseSchema('authentication');
|
|
4
|
+
export const subjectType = authenticationSchema.getEnum(SubjectType);
|
|
5
|
+
export const userStatus = authenticationSchema.getEnum(UserStatus);
|
|
4
6
|
export const authenticationCredentials = authenticationSchema.getTable(AuthenticationCredentials);
|
|
5
7
|
export const authenticationSession = authenticationSchema.getTable(AuthenticationSession);
|
|
8
|
+
export const serviceAccount = authenticationSchema.getTable(ServiceAccount);
|
|
9
|
+
export const subject = authenticationSchema.getTable(Subject);
|
|
10
|
+
export const systemAccount = authenticationSchema.getTable(SystemAccount);
|
|
11
|
+
export const user = authenticationSchema.getTable(User);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Subject, SystemAccount } from '../models/index.js';
|
|
2
|
+
export declare class SubjectService {
|
|
3
|
+
readonly subjectRepository: import("../../orm/server/index.js").EntityRepository<Subject>;
|
|
4
|
+
readonly systemAccountRepository: import("../../orm/server/index.js").EntityRepository<SystemAccount>;
|
|
5
|
+
getSystemAccountSubject(tenantId: string, identifier: string): Promise<Subject>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Singleton } from '../../injector/index.js';
|
|
8
|
+
import { injectRepository } from '../../orm/server/index.js';
|
|
9
|
+
import { isUndefined } from '../../utils/type-guards.js';
|
|
10
|
+
import { Subject, SubjectType, SystemAccount } from '../models/index.js';
|
|
11
|
+
let SubjectService = class SubjectService {
|
|
12
|
+
subjectRepository = injectRepository(Subject);
|
|
13
|
+
systemAccountRepository = injectRepository(SystemAccount);
|
|
14
|
+
async getSystemAccountSubject(tenantId, identifier) {
|
|
15
|
+
return await this.subjectRepository.transaction(async (tx) => {
|
|
16
|
+
let systemAccount = await this.systemAccountRepository.withTransaction(tx).tryLoadByQuery({
|
|
17
|
+
tenantId,
|
|
18
|
+
identifier,
|
|
19
|
+
});
|
|
20
|
+
if (isUndefined(systemAccount)) {
|
|
21
|
+
systemAccount = await this.systemAccountRepository.withTransaction(tx).insert({
|
|
22
|
+
tenantId,
|
|
23
|
+
identifier,
|
|
24
|
+
});
|
|
25
|
+
return await this.subjectRepository.withTransaction(tx).insert({
|
|
26
|
+
type: SubjectType.System,
|
|
27
|
+
tenantId,
|
|
28
|
+
systemAccountId: systemAccount.id,
|
|
29
|
+
displayName: `System: ${identifier}`,
|
|
30
|
+
userId: null,
|
|
31
|
+
serviceAccountId: null,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return await this.subjectRepository.withTransaction(tx).loadByQuery({
|
|
35
|
+
tenantId,
|
|
36
|
+
systemAccountId: systemAccount.id,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
SubjectService = __decorate([
|
|
42
|
+
Singleton()
|
|
43
|
+
], SubjectService);
|
|
44
|
+
export { SubjectService };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type EnumType } from '../enumeration/enumeration.js';
|
|
2
|
+
import { resolveArgumentType, type Resolvable } from '../injector/interfaces.js';
|
|
3
|
+
export declare const CircuitBreakerState: {
|
|
4
|
+
readonly Closed: "closed";
|
|
5
|
+
readonly Open: "open";
|
|
6
|
+
readonly HalfOpen: "half-open";
|
|
7
|
+
};
|
|
8
|
+
export type CircuitBreakerState = EnumType<typeof CircuitBreakerState>;
|
|
9
|
+
export interface CircuitBreakerConfig {
|
|
10
|
+
threshold: number;
|
|
11
|
+
resetTimeout: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CircuitBreakerCheckResult {
|
|
14
|
+
allowed: boolean;
|
|
15
|
+
state: CircuitBreakerState;
|
|
16
|
+
isProbe?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type CircuitBreakerArgument = string | (CircuitBreakerConfig & {
|
|
19
|
+
key: string;
|
|
20
|
+
});
|
|
21
|
+
export declare abstract class CircuitBreaker implements Resolvable<CircuitBreakerArgument> {
|
|
22
|
+
readonly [resolveArgumentType]: CircuitBreakerArgument;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if execution is allowed.
|
|
25
|
+
* Transitions from Open to Half-Open automatically if timeout passed.
|
|
26
|
+
*/
|
|
27
|
+
abstract check(): Promise<CircuitBreakerCheckResult>;
|
|
28
|
+
/** Records a success, resetting the breaker to Closed. */
|
|
29
|
+
abstract recordSuccess(): Promise<void>;
|
|
30
|
+
/** Records a failure, potentially tripping the breaker to Open. */
|
|
31
|
+
abstract recordFailure(): Promise<void>;
|
|
32
|
+
}
|