@futdevpro/nts-dynamo 1.15.154 → 1.15.155

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,124 +1,124 @@
1
- import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
2
-
3
- import { DyNTS_SafeDiagnosticCause_Type } from './safe-diagnostic-cause.type-enum';
4
- import { DyNTS_SafeDiagnosticStage_Type } from './safe-diagnostic-stage.type-enum';
5
- import {
6
- DyNTS_SafeDiagnosticInput_Interface,
7
- DyNTS_SafeDiagnostic_Interface
8
- } from './safe-diagnostic.interface';
9
- import { DyNTS_SafeDiagnostic_ControlService } from './safe-diagnostic.control-service';
10
-
11
- describe('| DyNTS_SafeDiagnostic_ControlService', (): void => {
12
- const canary: string = 'mongodb://user:secret@private-host.example/raw-driver-message';
13
-
14
- it('| returns the exact immutable content-free allowlist', (): void => {
15
- const result: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project({
16
- code: 'DYNTS|APP|DB_CONNECT_FAILED',
17
- stage: DyNTS_SafeDiagnosticStage_Type.databaseConnect,
18
- error: new Error(canary),
19
- status: 503,
20
- });
21
-
22
- expect(Object.keys(result).sort()).toEqual([
23
- 'causeType',
24
- 'code',
25
- 'contractVersion',
26
- 'fingerprint',
27
- 'stage',
28
- 'status',
29
- ]);
30
- expect(result).toEqual({
31
- contractVersion: 'dynts-safe-diagnostic/1',
32
- code: 'DYNTS|APP|DB_CONNECT_FAILED',
33
- stage: DyNTS_SafeDiagnosticStage_Type.databaseConnect,
34
- causeType: DyNTS_SafeDiagnosticCause_Type.nativeError,
35
- fingerprint: jasmine.stringMatching(/^[a-f0-9]{64}$/),
36
- status: 503,
37
- });
38
- expect(Object.isFrozen(result)).toBeTrue();
39
- expect(JSON.stringify(result)).not.toContain(canary);
40
- expect(JSON.stringify(result)).not.toContain('secret');
41
- });
42
-
43
- it('| creates a deterministic correlation without reflecting its raw subject', (): void => {
44
- const input: DyNTS_SafeDiagnosticInput_Interface = {
45
- code: 'DYNTS|APP|BOOT_FAILED',
46
- stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
47
- error: new Error(canary),
48
- };
49
- const first: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project(input);
50
- const second: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project(input);
51
-
52
- expect(first.fingerprint).toBe(second.fingerprint);
53
- expect(first.fingerprint).not.toContain(canary);
54
- });
55
-
56
- it('| classifies Dynamo, object, primitive and absent failures without returning content', (): void => {
57
- const failures: unknown[] = [
58
- new DyFM_Error({ errorCode: 'TEST', message: canary }),
59
- { privateValue: canary },
60
- canary,
61
- undefined,
62
- ];
63
- const expected: DyNTS_SafeDiagnosticCause_Type[] = [
64
- DyNTS_SafeDiagnosticCause_Type.dynamoError,
65
- DyNTS_SafeDiagnosticCause_Type.object,
66
- DyNTS_SafeDiagnosticCause_Type.primitive,
67
- DyNTS_SafeDiagnosticCause_Type.unknown,
68
- ];
69
-
70
- failures.forEach((error: unknown, index: number): void => {
71
- const result: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project({
72
- code: 'DYNTS|APP|FAILURE',
73
- stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
74
- error: error,
75
- });
76
-
77
- expect(result.causeType).toBe(expected[index]);
78
- expect(JSON.stringify(result)).not.toContain(canary);
79
- });
80
- });
81
-
82
- it('| fails closed for invalid code, status and hostile getters', (): void => {
83
- const hostile: Error = new Error('placeholder');
84
-
85
- Object.defineProperty(hostile, 'message', {
86
- get: (): never => {
87
- throw new Error(canary);
88
- },
89
- });
90
- Object.defineProperty(hostile, 'stack', {
91
- get: (): never => {
92
- throw new Error(canary);
93
- },
94
- });
95
-
96
- const result: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project({
97
- code: canary,
98
- stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
99
- error: hostile,
100
- status: 999,
101
- });
102
-
103
- expect(result.code).toBe('DYNTS_SAFE_DIAGNOSTIC_INVALID_CODE');
104
- expect(result.status).toBe(500);
105
- expect(result.fingerprint).toMatch(/^[a-f0-9]{64}$/);
106
- expect(JSON.stringify(result)).not.toContain(canary);
107
- });
108
-
109
- it('| reports and creates framework errors from the safe result only', (): void => {
110
- const logSpy: jasmine.Spy = spyOn(DyFM_Log, 'error');
111
- const diagnostic: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.report({
112
- code: 'DYNTS|APP|FAILURE',
113
- stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
114
- error: new Error(canary),
115
- });
116
- const error: DyFM_Error = DyNTS_SafeDiagnostic_ControlService.toError(diagnostic);
117
- const serialized: string = JSON.stringify(error);
118
-
119
- expect(logSpy).toHaveBeenCalledOnceWith('[DyNTS safe diagnostic]', diagnostic);
120
- expect(serialized).not.toContain(canary);
121
- expect(serialized).not.toContain('secret');
122
- expect(serialized).toContain(diagnostic.fingerprint);
123
- });
124
- });
1
+ import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
2
+
3
+ import { DyNTS_SafeDiagnosticCause_Type } from './safe-diagnostic-cause.type-enum';
4
+ import { DyNTS_SafeDiagnosticStage_Type } from './safe-diagnostic-stage.type-enum';
5
+ import {
6
+ DyNTS_SafeDiagnosticInput_Interface,
7
+ DyNTS_SafeDiagnostic_Interface
8
+ } from './safe-diagnostic.interface';
9
+ import { DyNTS_SafeDiagnostic_ControlService } from './safe-diagnostic.control-service';
10
+
11
+ describe('| DyNTS_SafeDiagnostic_ControlService', (): void => {
12
+ const canary: string = 'mongodb://user:secret@private-host.example/raw-driver-message';
13
+
14
+ it('| returns the exact immutable content-free allowlist', (): void => {
15
+ const result: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project({
16
+ code: 'DYNTS|APP|DB_CONNECT_FAILED',
17
+ stage: DyNTS_SafeDiagnosticStage_Type.databaseConnect,
18
+ error: new Error(canary),
19
+ status: 503,
20
+ });
21
+
22
+ expect(Object.keys(result).sort()).toEqual([
23
+ 'causeType',
24
+ 'code',
25
+ 'contractVersion',
26
+ 'fingerprint',
27
+ 'stage',
28
+ 'status',
29
+ ]);
30
+ expect(result).toEqual({
31
+ contractVersion: 'dynts-safe-diagnostic/1',
32
+ code: 'DYNTS|APP|DB_CONNECT_FAILED',
33
+ stage: DyNTS_SafeDiagnosticStage_Type.databaseConnect,
34
+ causeType: DyNTS_SafeDiagnosticCause_Type.nativeError,
35
+ fingerprint: jasmine.stringMatching(/^[a-f0-9]{64}$/),
36
+ status: 503,
37
+ });
38
+ expect(Object.isFrozen(result)).toBeTrue();
39
+ expect(JSON.stringify(result)).not.toContain(canary);
40
+ expect(JSON.stringify(result)).not.toContain('secret');
41
+ });
42
+
43
+ it('| creates a deterministic correlation without reflecting its raw subject', (): void => {
44
+ const input: DyNTS_SafeDiagnosticInput_Interface = {
45
+ code: 'DYNTS|APP|BOOT_FAILED',
46
+ stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
47
+ error: new Error(canary),
48
+ };
49
+ const first: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project(input);
50
+ const second: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project(input);
51
+
52
+ expect(first.fingerprint).toBe(second.fingerprint);
53
+ expect(first.fingerprint).not.toContain(canary);
54
+ });
55
+
56
+ it('| classifies Dynamo, object, primitive and absent failures without returning content', (): void => {
57
+ const failures: unknown[] = [
58
+ new DyFM_Error({ errorCode: 'TEST', message: canary }),
59
+ { privateValue: canary },
60
+ canary,
61
+ undefined,
62
+ ];
63
+ const expected: DyNTS_SafeDiagnosticCause_Type[] = [
64
+ DyNTS_SafeDiagnosticCause_Type.dynamoError,
65
+ DyNTS_SafeDiagnosticCause_Type.object,
66
+ DyNTS_SafeDiagnosticCause_Type.primitive,
67
+ DyNTS_SafeDiagnosticCause_Type.unknown,
68
+ ];
69
+
70
+ failures.forEach((error: unknown, index: number): void => {
71
+ const result: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project({
72
+ code: 'DYNTS|APP|FAILURE',
73
+ stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
74
+ error: error,
75
+ });
76
+
77
+ expect(result.causeType).toBe(expected[index]);
78
+ expect(JSON.stringify(result)).not.toContain(canary);
79
+ });
80
+ });
81
+
82
+ it('| fails closed for invalid code, status and hostile getters', (): void => {
83
+ const hostile: Error = new Error('placeholder');
84
+
85
+ Object.defineProperty(hostile, 'message', {
86
+ get: (): never => {
87
+ throw new Error(canary);
88
+ },
89
+ });
90
+ Object.defineProperty(hostile, 'stack', {
91
+ get: (): never => {
92
+ throw new Error(canary);
93
+ },
94
+ });
95
+
96
+ const result: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.project({
97
+ code: canary,
98
+ stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
99
+ error: hostile,
100
+ status: 999,
101
+ });
102
+
103
+ expect(result.code).toBe('DYNTS_SAFE_DIAGNOSTIC_INVALID_CODE');
104
+ expect(result.status).toBe(500);
105
+ expect(result.fingerprint).toMatch(/^[a-f0-9]{64}$/);
106
+ expect(JSON.stringify(result)).not.toContain(canary);
107
+ });
108
+
109
+ it('| reports and creates framework errors from the safe result only', (): void => {
110
+ const logSpy: jasmine.Spy = spyOn(DyFM_Log, 'error');
111
+ const diagnostic: DyNTS_SafeDiagnostic_Interface = DyNTS_SafeDiagnostic_ControlService.report({
112
+ code: 'DYNTS|APP|FAILURE',
113
+ stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
114
+ error: new Error(canary),
115
+ });
116
+ const error: DyFM_Error = DyNTS_SafeDiagnostic_ControlService.toError(diagnostic);
117
+ const serialized: string = JSON.stringify(error);
118
+
119
+ expect(logSpy).toHaveBeenCalledOnceWith('[DyNTS safe diagnostic]', diagnostic);
120
+ expect(serialized).not.toContain(canary);
121
+ expect(serialized).not.toContain('secret');
122
+ expect(serialized).toContain(diagnostic.fingerprint);
123
+ });
124
+ });
@@ -1,99 +1,99 @@
1
- import { createHash } from 'crypto';
2
-
3
- import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
4
-
5
- import { DyNTS_SafeDiagnosticCause_Type } from './safe-diagnostic-cause.type-enum';
6
- import {
7
- DyNTS_SafeDiagnosticInput_Interface,
8
- DyNTS_SafeDiagnostic_Interface
9
- } from './safe-diagnostic.interface';
10
-
11
- /** Projects arbitrary failures to a versioned, content-free public diagnostic. */
12
- export class DyNTS_SafeDiagnostic_ControlService {
13
- private static readonly contractVersion: 'dynts-safe-diagnostic/1' = 'dynts-safe-diagnostic/1';
14
- private static readonly defaultCode: string = 'DYNTS_SAFE_DIAGNOSTIC_INVALID_CODE';
15
- private static readonly defaultStatus: number = 500;
16
-
17
- /** Returns an immutable exact allowlist and never reflects raw failure content. */
18
- static project(input: DyNTS_SafeDiagnosticInput_Interface): DyNTS_SafeDiagnostic_Interface {
19
- const code: string = this.getCode(input.code);
20
- const causeType: DyNTS_SafeDiagnosticCause_Type = this.getCauseType(input.error);
21
- const status: number = this.getStatus(input.status);
22
- const fingerprint: string = this.getFingerprint([
23
- this.contractVersion,
24
- code,
25
- input.stage,
26
- causeType,
27
- status.toString(),
28
- ]);
29
-
30
- return Object.freeze({
31
- contractVersion: this.contractVersion,
32
- code: code,
33
- stage: input.stage,
34
- causeType: causeType,
35
- fingerprint: fingerprint,
36
- status: status,
37
- });
38
- }
39
-
40
- /** Logs only the projected allowlist and returns the same immutable diagnostic. */
41
- static report(input: DyNTS_SafeDiagnosticInput_Interface): DyNTS_SafeDiagnostic_Interface {
42
- const diagnostic: DyNTS_SafeDiagnostic_Interface = this.project(input);
43
-
44
- DyFM_Log.error('[DyNTS safe diagnostic]', diagnostic);
45
-
46
- return diagnostic;
47
- }
48
-
49
- /** Creates a framework error that carries only the safe diagnostic allowlist. */
50
- static toError(diagnostic: DyNTS_SafeDiagnostic_Interface): DyFM_Error {
51
- return new DyFM_Error({
52
- errorCode: diagnostic.code,
53
- message: `Framework failure at ${diagnostic.stage}. Correlation: ${diagnostic.fingerprint}.`,
54
- userMessage: 'A server operation failed. Contact the responsible team with the correlation fingerprint.',
55
- additionalContent: { diagnostic: diagnostic },
56
- status: diagnostic.status,
57
- });
58
- }
59
-
60
- private static getCode(code: string): string {
61
- return /^[A-Z][A-Z0-9_|-]{2,127}$/.test(code) ? code : this.defaultCode;
62
- }
63
-
64
- private static getCauseType(error: unknown): DyNTS_SafeDiagnosticCause_Type {
65
- try {
66
- if (error instanceof DyFM_Error) {
67
- return DyNTS_SafeDiagnosticCause_Type.dynamoError;
68
- }
69
-
70
- if (error instanceof Error) {
71
- return DyNTS_SafeDiagnosticCause_Type.nativeError;
72
- }
73
-
74
- if (error !== null && typeof error === 'object') {
75
- return DyNTS_SafeDiagnosticCause_Type.object;
76
- }
77
-
78
- if (error !== undefined) {
79
- return DyNTS_SafeDiagnosticCause_Type.primitive;
80
- }
81
- } catch {
82
- return DyNTS_SafeDiagnosticCause_Type.unknown;
83
- }
84
-
85
- return DyNTS_SafeDiagnosticCause_Type.unknown;
86
- }
87
-
88
- private static getStatus(status?: number): number {
89
- if (typeof status !== 'number' || !Number.isInteger(status) || status < 100 || status > 599) {
90
- return this.defaultStatus;
91
- }
92
-
93
- return status;
94
- }
95
-
96
- private static getFingerprint(subject: string[]): string {
97
- return createHash('sha256').update(subject.join('\u0000'), 'utf8').digest('hex');
98
- }
99
- }
1
+ import { createHash } from 'crypto';
2
+
3
+ import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
4
+
5
+ import { DyNTS_SafeDiagnosticCause_Type } from './safe-diagnostic-cause.type-enum';
6
+ import {
7
+ DyNTS_SafeDiagnosticInput_Interface,
8
+ DyNTS_SafeDiagnostic_Interface
9
+ } from './safe-diagnostic.interface';
10
+
11
+ /** Projects arbitrary failures to a versioned, content-free public diagnostic. */
12
+ export class DyNTS_SafeDiagnostic_ControlService {
13
+ private static readonly contractVersion: 'dynts-safe-diagnostic/1' = 'dynts-safe-diagnostic/1';
14
+ private static readonly defaultCode: string = 'DYNTS_SAFE_DIAGNOSTIC_INVALID_CODE';
15
+ private static readonly defaultStatus: number = 500;
16
+
17
+ /** Returns an immutable exact allowlist and never reflects raw failure content. */
18
+ static project(input: DyNTS_SafeDiagnosticInput_Interface): DyNTS_SafeDiagnostic_Interface {
19
+ const code: string = this.getCode(input.code);
20
+ const causeType: DyNTS_SafeDiagnosticCause_Type = this.getCauseType(input.error);
21
+ const status: number = this.getStatus(input.status);
22
+ const fingerprint: string = this.getFingerprint([
23
+ this.contractVersion,
24
+ code,
25
+ input.stage,
26
+ causeType,
27
+ status.toString(),
28
+ ]);
29
+
30
+ return Object.freeze({
31
+ contractVersion: this.contractVersion,
32
+ code: code,
33
+ stage: input.stage,
34
+ causeType: causeType,
35
+ fingerprint: fingerprint,
36
+ status: status,
37
+ });
38
+ }
39
+
40
+ /** Logs only the projected allowlist and returns the same immutable diagnostic. */
41
+ static report(input: DyNTS_SafeDiagnosticInput_Interface): DyNTS_SafeDiagnostic_Interface {
42
+ const diagnostic: DyNTS_SafeDiagnostic_Interface = this.project(input);
43
+
44
+ DyFM_Log.error('[DyNTS safe diagnostic]', diagnostic);
45
+
46
+ return diagnostic;
47
+ }
48
+
49
+ /** Creates a framework error that carries only the safe diagnostic allowlist. */
50
+ static toError(diagnostic: DyNTS_SafeDiagnostic_Interface): DyFM_Error {
51
+ return new DyFM_Error({
52
+ errorCode: diagnostic.code,
53
+ message: `Framework failure at ${diagnostic.stage}. Correlation: ${diagnostic.fingerprint}.`,
54
+ userMessage: 'A server operation failed. Contact the responsible team with the correlation fingerprint.',
55
+ additionalContent: { diagnostic: diagnostic },
56
+ status: diagnostic.status,
57
+ });
58
+ }
59
+
60
+ private static getCode(code: string): string {
61
+ return /^[A-Z][A-Z0-9_|-]{2,127}$/.test(code) ? code : this.defaultCode;
62
+ }
63
+
64
+ private static getCauseType(error: unknown): DyNTS_SafeDiagnosticCause_Type {
65
+ try {
66
+ if (error instanceof DyFM_Error) {
67
+ return DyNTS_SafeDiagnosticCause_Type.dynamoError;
68
+ }
69
+
70
+ if (error instanceof Error) {
71
+ return DyNTS_SafeDiagnosticCause_Type.nativeError;
72
+ }
73
+
74
+ if (error !== null && typeof error === 'object') {
75
+ return DyNTS_SafeDiagnosticCause_Type.object;
76
+ }
77
+
78
+ if (error !== undefined) {
79
+ return DyNTS_SafeDiagnosticCause_Type.primitive;
80
+ }
81
+ } catch {
82
+ return DyNTS_SafeDiagnosticCause_Type.unknown;
83
+ }
84
+
85
+ return DyNTS_SafeDiagnosticCause_Type.unknown;
86
+ }
87
+
88
+ private static getStatus(status?: number): number {
89
+ if (typeof status !== 'number' || !Number.isInteger(status) || status < 100 || status > 599) {
90
+ return this.defaultStatus;
91
+ }
92
+
93
+ return status;
94
+ }
95
+
96
+ private static getFingerprint(subject: string[]): string {
97
+ return createHash('sha256').update(subject.join('\u0000'), 'utf8').digest('hex');
98
+ }
99
+ }
@@ -1,20 +1,20 @@
1
- import { DyNTS_SafeDiagnosticCause_Type } from './safe-diagnostic-cause.type-enum';
2
- import { DyNTS_SafeDiagnosticStage_Type } from './safe-diagnostic-stage.type-enum';
3
-
4
- /** Caller-owned input whose raw failure content is never returned or logged. */
5
- export interface DyNTS_SafeDiagnosticInput_Interface {
6
- code: string;
7
- stage: DyNTS_SafeDiagnosticStage_Type;
8
- error?: unknown;
9
- status?: number;
10
- }
11
-
12
- /** Exact public allowlist emitted by the safe diagnostic boundary. */
13
- export interface DyNTS_SafeDiagnostic_Interface {
14
- contractVersion: 'dynts-safe-diagnostic/1';
15
- code: string;
16
- stage: DyNTS_SafeDiagnosticStage_Type;
17
- causeType: DyNTS_SafeDiagnosticCause_Type;
18
- fingerprint: string;
19
- status: number;
20
- }
1
+ import { DyNTS_SafeDiagnosticCause_Type } from './safe-diagnostic-cause.type-enum';
2
+ import { DyNTS_SafeDiagnosticStage_Type } from './safe-diagnostic-stage.type-enum';
3
+
4
+ /** Caller-owned input whose raw failure content is never returned or logged. */
5
+ export interface DyNTS_SafeDiagnosticInput_Interface {
6
+ code: string;
7
+ stage: DyNTS_SafeDiagnosticStage_Type;
8
+ error?: unknown;
9
+ status?: number;
10
+ }
11
+
12
+ /** Exact public allowlist emitted by the safe diagnostic boundary. */
13
+ export interface DyNTS_SafeDiagnostic_Interface {
14
+ contractVersion: 'dynts-safe-diagnostic/1';
15
+ code: string;
16
+ stage: DyNTS_SafeDiagnosticStage_Type;
17
+ causeType: DyNTS_SafeDiagnosticCause_Type;
18
+ fingerprint: string;
19
+ status: number;
20
+ }
@@ -1,4 +1,4 @@
1
- import {
1
+ import {
2
2
  DyFM_AnyError,
3
3
  DyFM_Array,
4
4
  DyFM_DataModel_Params,
@@ -6,28 +6,28 @@ import {
6
6
  DyFM_Error_Settings,
7
7
  DyFM_global_settings,
8
8
  DyFM_Log,
9
- DyFM_Metadata
10
- } from '@futdevpro/fsm-dynamo';
11
-
12
- import { DyNTS_AuthService } from './auth.service';
13
- import { DyNTS_EmailService } from './email.service';
14
- import { DyNTS_Service_Collection } from './service-collection.service';
15
- /* import { DyNTS_DBServiceCollection } from './db-service-collection.service'; */
16
- /* import { DyNTS_EmailServiceCollection } from './email-service-collection.service'; */
17
- import { DyNTS_DBService } from '../base/db.service';
18
- import { DyNTS_SingletonService } from '../base/singleton.service';
19
- /* import { DyNTS_archiveFlag } from '../../_collections/archive-flag.const'; */
20
- import { DyNTS_getArchivedDBName } from '../../_collections/archive.util';
21
- import { DyNTS_global_settings } from '../../_collections/global-settings.const';
22
- import { DyNTS_App_Params } from '../../_models/control-models/app-params.control-model';
23
- import {
24
- DyNTS_GlobalErrorHandlerFn,
25
- DyNTS_GlobalService_Settings
26
- } from '../../_models/interfaces/global-service-settings.interface';
27
- import { DyNTS_SafeDiagnosticStage_Type } from '../../_modules/server/safe-diagnostic/safe-diagnostic-stage.type-enum';
28
- import {
29
- DyNTS_SafeDiagnostic_ControlService
30
- } from '../../_modules/server/safe-diagnostic/safe-diagnostic.control-service';
9
+ DyFM_Metadata
10
+ } from '@futdevpro/fsm-dynamo';
11
+
12
+ import { DyNTS_AuthService } from './auth.service';
13
+ import { DyNTS_EmailService } from './email.service';
14
+ import { DyNTS_Service_Collection } from './service-collection.service';
15
+ /* import { DyNTS_DBServiceCollection } from './db-service-collection.service'; */
16
+ /* import { DyNTS_EmailServiceCollection } from './email-service-collection.service'; */
17
+ import { DyNTS_DBService } from '../base/db.service';
18
+ import { DyNTS_SingletonService } from '../base/singleton.service';
19
+ /* import { DyNTS_archiveFlag } from '../../_collections/archive-flag.const'; */
20
+ import { DyNTS_getArchivedDBName } from '../../_collections/archive.util';
21
+ import { DyNTS_global_settings } from '../../_collections/global-settings.const';
22
+ import { DyNTS_App_Params } from '../../_models/control-models/app-params.control-model';
23
+ import {
24
+ DyNTS_GlobalErrorHandlerFn,
25
+ DyNTS_GlobalService_Settings
26
+ } from '../../_models/interfaces/global-service-settings.interface';
27
+ import { DyNTS_SafeDiagnosticStage_Type } from '../../_modules/server/safe-diagnostic/safe-diagnostic-stage.type-enum';
28
+ import {
29
+ DyNTS_SafeDiagnostic_ControlService
30
+ } from '../../_modules/server/safe-diagnostic/safe-diagnostic.control-service';
31
31
 
32
32
  /**
33
33
  * This is the main Global/Core Service Collection used by DynamoNTS,
@@ -74,14 +74,14 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
74
74
  `We encountered an unhandled Control Service Error, ` +
75
75
  `\nplease contact the responsible development team.`;
76
76
 
77
- static globalErrorHandler: DyNTS_GlobalErrorHandlerFn =
78
- async (error: DyFM_AnyError): Promise<void> => {
79
- DyNTS_SafeDiagnostic_ControlService.report({
80
- code: 'DYNTS|GLOBAL|HANDLER_NOT_SET',
81
- stage: DyNTS_SafeDiagnosticStage_Type.globalErrorHandler,
82
- error: error,
83
- });
84
- };
77
+ static globalErrorHandler: DyNTS_GlobalErrorHandlerFn =
78
+ async (error: DyFM_AnyError): Promise<void> => {
79
+ DyNTS_SafeDiagnostic_ControlService.report({
80
+ code: 'DYNTS|GLOBAL|HANDLER_NOT_SET',
81
+ stage: DyNTS_SafeDiagnosticStage_Type.globalErrorHandler,
82
+ error: error,
83
+ });
84
+ };
85
85
 
86
86
  /**
87
87
  * You need to setup global Services through this function
@@ -183,16 +183,16 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
183
183
  return;
184
184
  }
185
185
 
186
- try {
187
- this.instance.dbServiceCollection[dbModel.dataName] = new DyNTS_DBService(dbModel);
188
- } catch (error) {
189
- DyNTS_SafeDiagnostic_ControlService.report({
190
- code: 'DYNTS|GLOBAL|DB_SERVICE_CREATE_FAILED',
191
- stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
192
- error: error,
193
- });
194
-
195
- throw new DyFM_Error({
186
+ try {
187
+ this.instance.dbServiceCollection[dbModel.dataName] = new DyNTS_DBService(dbModel);
188
+ } catch (error) {
189
+ DyNTS_SafeDiagnostic_ControlService.report({
190
+ code: 'DYNTS|GLOBAL|DB_SERVICE_CREATE_FAILED',
191
+ stage: DyNTS_SafeDiagnosticStage_Type.bootstrap,
192
+ error: error,
193
+ });
194
+
195
+ throw new DyFM_Error({
196
196
  ...this.getDefaultErrorSettings('setDBServices', error, 'DyNTS_GlobalService'),
197
197
 
198
198
  additionalContent: {
@@ -269,7 +269,7 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
269
269
 
270
270
  private static async setErrorHandler(errorHandler?: DyNTS_GlobalErrorHandlerFn): Promise<void> {
271
271
  try {
272
- DyNTS_GlobalService.globalErrorHandler = (async (error: unknown): Promise<void> => {
272
+ DyNTS_GlobalService.globalErrorHandler = (async (error: unknown): Promise<void> => {
273
273
  try {
274
274
  if (errorHandler) {
275
275
  await errorHandler(error);
@@ -284,19 +284,19 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
284
284
  'please check if it is using the same node_modules as the app)'
285
285
  );
286
286
 
287
- DyNTS_SafeDiagnostic_ControlService.report({
288
- code: 'DYNTS|GLOBAL|UNHANDLED_ERROR',
289
- stage: DyNTS_SafeDiagnosticStage_Type.globalErrorHandler,
290
- error: error,
291
- });
292
- } catch (error) {
293
- DyNTS_SafeDiagnostic_ControlService.report({
294
- code: 'DYNTS|GLOBAL|HANDLER_FAILED',
295
- stage: DyNTS_SafeDiagnosticStage_Type.globalErrorHandler,
296
- error: error,
297
- });
298
- }
299
- });
287
+ DyNTS_SafeDiagnostic_ControlService.report({
288
+ code: 'DYNTS|GLOBAL|UNHANDLED_ERROR',
289
+ stage: DyNTS_SafeDiagnosticStage_Type.globalErrorHandler,
290
+ error: error,
291
+ });
292
+ } catch (error) {
293
+ DyNTS_SafeDiagnostic_ControlService.report({
294
+ code: 'DYNTS|GLOBAL|HANDLER_FAILED',
295
+ stage: DyNTS_SafeDiagnosticStage_Type.globalErrorHandler,
296
+ error: error,
297
+ });
298
+ }
299
+ });
300
300
  } catch (error) {
301
301
  throw new DyFM_Error({
302
302
  ...this.getDefaultErrorSettings('setErrorHandler', error, 'DyNTS_GlobalService'),