@futdevpro/fsm-dynamo 1.15.8 → 1.15.10
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/.dynamo/version-bump.config.json +5 -0
- package/.github/workflows/main.yml +427 -394
- package/.husky/pre-commit +1 -0
- package/README.md +3 -0
- package/__documentations/2026-05-17-oai-compatible-providers-howto.md +282 -0
- package/package.json +64 -34
- package/pipeline.cicd.config.json +128 -0
- package/src/_collections/utils/async.util.spec.ts +354 -0
- package/src/_collections/utils/data.util.spec.ts +345 -0
- package/src/_collections/utils/json-error-helper.util.spec.ts +521 -0
- package/src/_collections/utils/math/box-bounds.spec.ts +74 -0
- package/src/_collections/utils/utilities.util.spec.ts +201 -0
- package/src/_models/control-models/http/http-error-response.control-model.spec.ts +116 -0
- package/src/_models/control-models/http/http-headers.control-model.spec.ts +25 -0
- package/src/_models/control-models/http/http-response.model-base.spec.ts +46 -0
- package/src/_models/control-models/server-status.control-model.spec.ts +66 -0
- package/src/_models/control-models/service-endpoint-settings-base.control-model.spec.ts +145 -0
- package/src/_models/data-models/errors.data-model.spec.ts +71 -0
- package/src/_models/data-models/metadata.data-model.spec.ts +184 -0
- package/src/_modules/ai/_modules/anthropic/_models/aai-call-settings.control-model.spec.ts +28 -0
- package/src/_modules/ai/_modules/anthropic/_models/aai-settings.control-model.spec.ts +22 -0
- package/src/_modules/ai/_modules/google-ai/_models/gai-call-settings.control-model.spec.ts +28 -0
- package/src/_modules/ai/_modules/google-ai/_models/gai-settings.control-model.spec.ts +22 -0
- package/src/_modules/ai/_modules/local-ai/_models/lai-call-settings.control-model.spec.ts +28 -0
- package/src/_modules/ai/_modules/local-ai/_models/lai-settings.control-model.spec.ts +22 -0
- package/src/_modules/ai/_modules/open-ai/_models/oai-call-settings.control-model.spec.ts +28 -0
- package/src/_modules/ai/_modules/open-ai/_models/oai-settings.control-model.spec.ts +22 -0
- package/src/_modules/ci-tools/_models/cit-ci-result-info.data-models.spec.ts +58 -0
- package/src/_modules/data-handler/_models/data-handler-settings.control-model.spec.ts +110 -0
- package/src/_modules/data-handler/_models/data-handler.control-model.spec.ts +445 -0
- package/src/_modules/data-handler/_models/data-list-handler.control-model.spec.ts +263 -0
- package/src/_modules/data-handler/_models/data-search-handler.control-model.spec.ts +417 -0
- package/src/_modules/data-handler/_models/list-collector-data-handler.control-model.spec.ts +374 -0
- package/src/_modules/messaging/_models/msg-conversation.data-model.spec.ts +69 -0
- package/src/_modules/messaging/_models/msg-message.data-model.spec.ts +79 -0
- package/src/_modules/pipe/_collections/utils/pip-json-pipe.util.spec.ts +62 -0
- package/src/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.spec.ts +10 -3
- package/futdevpro-fsm-dynamo-01.15.8.tgz +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { DyFM_Metadata } from './metadata.data-model';
|
|
2
|
+
|
|
3
|
+
describe('| DyFM_Metadata', (): void => {
|
|
4
|
+
it('| should create an instance without initial data', (): void => {
|
|
5
|
+
const instance = new DyFM_Metadata();
|
|
6
|
+
expect(instance).toBeTruthy();
|
|
7
|
+
expect(instance.__created).toBeInstanceOf(Date);
|
|
8
|
+
expect(instance.__lastModified).toBeInstanceOf(Date);
|
|
9
|
+
expect(instance.__v).toBe(0);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('| should create an instance with initial data', (): void => {
|
|
13
|
+
const initialData: DyFM_Metadata = {
|
|
14
|
+
_id: 'test-id',
|
|
15
|
+
__created: new Date('2023-01-01'),
|
|
16
|
+
__createdBy: 'user1',
|
|
17
|
+
__lastModified: new Date('2023-01-02'),
|
|
18
|
+
__lastModifiedBy: 'user2',
|
|
19
|
+
__v: 1
|
|
20
|
+
};
|
|
21
|
+
const instance = new DyFM_Metadata(initialData);
|
|
22
|
+
|
|
23
|
+
expect(instance._id).toBe('test-id');
|
|
24
|
+
expect(instance.__created).toEqual(new Date('2023-01-01'));
|
|
25
|
+
expect(instance.__createdBy).toBe('user1');
|
|
26
|
+
expect(instance.__lastModified).toEqual(new Date('2023-01-02'));
|
|
27
|
+
expect(instance.__lastModifiedBy).toBe('user2');
|
|
28
|
+
expect(instance.__v).toBe(1);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('| should set default values when not provided', (): void => {
|
|
32
|
+
const instance = new DyFM_Metadata({});
|
|
33
|
+
|
|
34
|
+
expect(instance.__created).toBeInstanceOf(Date);
|
|
35
|
+
expect(instance.__lastModified).toBeInstanceOf(Date);
|
|
36
|
+
expect(instance.__v).toBe(0);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('| should handle init parameter with id and issuer', (): void => {
|
|
40
|
+
const instance = new DyFM_Metadata(undefined, {
|
|
41
|
+
id: 'init-id',
|
|
42
|
+
issuer: 'init-user'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(instance._id).toBe('init-id');
|
|
46
|
+
expect(instance.__createdBy).toBe('init-user');
|
|
47
|
+
expect(instance.__lastModifiedBy).toBe('init-user');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('| should not override existing _id with init id', (): void => {
|
|
51
|
+
const instance = new DyFM_Metadata(
|
|
52
|
+
{ _id: 'existing-id' },
|
|
53
|
+
{ id: 'init-id', issuer: 'user' }
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(instance._id).toBe('existing-id');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('| should not override existing __createdBy with init issuer', (): void => {
|
|
60
|
+
const instance = new DyFM_Metadata(
|
|
61
|
+
{ __createdBy: 'existing-user' },
|
|
62
|
+
{ issuer: 'init-user' }
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(instance.__createdBy).toBe('existing-user');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('| should handle archived data', (): void => {
|
|
69
|
+
const archivedDate = new Date('2023-01-01');
|
|
70
|
+
const instance = new DyFM_Metadata({
|
|
71
|
+
_archived: archivedDate,
|
|
72
|
+
_originalId: 'original-id'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(instance._archived).toEqual(archivedDate);
|
|
76
|
+
expect(instance._originalId).toBe('original-id');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('| should handle deleted data', (): void => {
|
|
80
|
+
const deletedDate = new Date('2023-01-01');
|
|
81
|
+
const instance = new DyFM_Metadata({
|
|
82
|
+
_deleted: deletedDate,
|
|
83
|
+
_deletedBy: 'deleter'
|
|
84
|
+
} as any);
|
|
85
|
+
instance._deleted = deletedDate;
|
|
86
|
+
instance._deletedBy = 'deleter';
|
|
87
|
+
|
|
88
|
+
expect(instance._deleted).toEqual(deletedDate);
|
|
89
|
+
expect(instance._deletedBy).toBe('deleter');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('| should set _id to undefined when _id is falsy but not undefined', (): void => {
|
|
93
|
+
// Test case for line 40-42: if (!set._id && set._id !== undefined)
|
|
94
|
+
// This happens when _id is null, empty string, 0, false, etc.
|
|
95
|
+
const instance1 = new DyFM_Metadata({ _id: null as any });
|
|
96
|
+
expect(instance1._id).toBeUndefined();
|
|
97
|
+
|
|
98
|
+
const instance2 = new DyFM_Metadata({ _id: '' as any });
|
|
99
|
+
expect(instance2._id).toBeUndefined();
|
|
100
|
+
|
|
101
|
+
const instance3 = new DyFM_Metadata({ _id: 0 as any });
|
|
102
|
+
expect(instance3._id).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('| updateMetadata', (): void => {
|
|
106
|
+
it('| should update metadata correctly', (): void => {
|
|
107
|
+
const data = new DyFM_Metadata();
|
|
108
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater', 'new-id');
|
|
109
|
+
|
|
110
|
+
expect(updated._id).toBe('new-id');
|
|
111
|
+
expect(updated.__createdBy).toBe('updater');
|
|
112
|
+
expect(updated.__lastModifiedBy).toBe('updater');
|
|
113
|
+
expect(updated.__lastModified).toBeInstanceOf(Date);
|
|
114
|
+
expect(updated.__v).toBe(1);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('| should increment version on update', (): void => {
|
|
118
|
+
const data = new DyFM_Metadata({ __v: 5 });
|
|
119
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater');
|
|
120
|
+
|
|
121
|
+
expect(updated.__v).toBe(6);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('| should set version to 1 if not present', (): void => {
|
|
125
|
+
const data = new DyFM_Metadata({ __v: undefined });
|
|
126
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater');
|
|
127
|
+
|
|
128
|
+
expect(updated.__v).toBe(1);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('| should not override existing _id if id not provided', (): void => {
|
|
132
|
+
const data = new DyFM_Metadata({ _id: 'existing-id' });
|
|
133
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater');
|
|
134
|
+
|
|
135
|
+
expect(updated._id).toBe('existing-id');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('| should set _id if not present and id provided', (): void => {
|
|
139
|
+
const data = new DyFM_Metadata({ _id: undefined });
|
|
140
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater', 'new-id');
|
|
141
|
+
|
|
142
|
+
expect(updated._id).toBe('new-id');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('| should throw error when updating deleted data', (): void => {
|
|
146
|
+
const data = new DyFM_Metadata({ _deleted: new Date() } as any);
|
|
147
|
+
data._deleted = new Date();
|
|
148
|
+
|
|
149
|
+
expect(() => {
|
|
150
|
+
DyFM_Metadata.updateMetadata!(data, 'updater');
|
|
151
|
+
}).toThrowError('Cannot update metadata of deleted data');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('| should return data as-is if data is null', (): void => {
|
|
155
|
+
const result = DyFM_Metadata.updateMetadata!(null as any, 'updater');
|
|
156
|
+
|
|
157
|
+
expect(result).toBeNull();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('| should set __created if not present', (): void => {
|
|
161
|
+
const data = new DyFM_Metadata({ __created: undefined });
|
|
162
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater');
|
|
163
|
+
|
|
164
|
+
expect(updated.__created).toBeInstanceOf(Date);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('| should set __createdBy if not present', (): void => {
|
|
168
|
+
const data = new DyFM_Metadata({ __createdBy: undefined });
|
|
169
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater');
|
|
170
|
+
|
|
171
|
+
expect(updated.__createdBy).toBe('updater');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('| should set __created if not present (branch coverage)', (): void => {
|
|
175
|
+
// Test case for line 114-116: if (!data.__created)
|
|
176
|
+
const data = new DyFM_Metadata();
|
|
177
|
+
data.__created = undefined as any;
|
|
178
|
+
const updated = DyFM_Metadata.updateMetadata!(data, 'updater');
|
|
179
|
+
|
|
180
|
+
expect(updated.__created).toBeInstanceOf(Date);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DyFM_AAI_CallSettings } from './aai-call-settings.control-model';
|
|
2
|
+
import { DyFM_AAI_Model } from '../_enums/aai-model.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_AAI_CallSettings', (): void => {
|
|
5
|
+
it('| should create an instance with default model', (): void => {
|
|
6
|
+
const settings = new DyFM_AAI_CallSettings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.useModel).toBe(DyFM_AAI_Model.claude_3_5_sonnet_latest);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('| should create an instance with custom model', (): void => {
|
|
13
|
+
const settings = new DyFM_AAI_CallSettings({
|
|
14
|
+
useModel: DyFM_AAI_Model.claude_3_5_sonnet_latest,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(settings.useModel).toBe(DyFM_AAI_Model.claude_3_5_sonnet_latest);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('| should create an instance with string model', (): void => {
|
|
21
|
+
const settings = new DyFM_AAI_CallSettings({
|
|
22
|
+
useModel: 'custom-model',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
expect(settings.useModel).toBe('custom-model');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DyFM_AAI_Settings } from './aai-settings.control-model';
|
|
2
|
+
import { DyFM_AI_Provider } from '../../../_enums/ai-provider.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_AAI_Settings', (): void => {
|
|
5
|
+
it('| should create an instance with default values', (): void => {
|
|
6
|
+
const settings = new DyFM_AAI_Settings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.Anthropic);
|
|
10
|
+
expect(settings.defaultSettings).toBeTruthy();
|
|
11
|
+
expect(settings.config).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('| should create an instance with custom values', (): void => {
|
|
15
|
+
const settings = new DyFM_AAI_Settings({
|
|
16
|
+
provider: DyFM_AI_Provider.Anthropic,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.Anthropic);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DyFM_GAI_CallSettings } from './gai-call-settings.control-model';
|
|
2
|
+
import { DyFM_GAI_Model } from '../_enums/gai-model.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_GAI_CallSettings', (): void => {
|
|
5
|
+
it('| should create an instance with default model', (): void => {
|
|
6
|
+
const settings = new DyFM_GAI_CallSettings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.useModel).toBe(DyFM_GAI_Model.gemini_1_5_pro_latest);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('| should create an instance with custom model', (): void => {
|
|
13
|
+
const settings = new DyFM_GAI_CallSettings({
|
|
14
|
+
useModel: DyFM_GAI_Model.gemini_1_5_pro_latest,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(settings.useModel).toBe(DyFM_GAI_Model.gemini_1_5_pro_latest);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('| should create an instance with string model', (): void => {
|
|
21
|
+
const settings = new DyFM_GAI_CallSettings({
|
|
22
|
+
useModel: 'custom-model',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
expect(settings.useModel).toBe('custom-model');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DyFM_GAI_Settings } from './gai-settings.control-model';
|
|
2
|
+
import { DyFM_AI_Provider } from '../../../_enums/ai-provider.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_GAI_Settings', (): void => {
|
|
5
|
+
it('| should create an instance with default values', (): void => {
|
|
6
|
+
const settings = new DyFM_GAI_Settings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.Google);
|
|
10
|
+
expect(settings.defaultSettings).toBeTruthy();
|
|
11
|
+
expect(settings.config).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('| should create an instance with custom values', (): void => {
|
|
15
|
+
const settings = new DyFM_GAI_Settings({
|
|
16
|
+
provider: DyFM_AI_Provider.Google,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.Google);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DyFM_LAI_CallSettings } from './lai-call-settings.control-model';
|
|
2
|
+
import { DyFM_LAI_Model } from '../_enums/lai-model.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_LAI_CallSettings', (): void => {
|
|
5
|
+
it('| should create an instance with default model', (): void => {
|
|
6
|
+
const settings = new DyFM_LAI_CallSettings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.useModel).toBe(DyFM_LAI_Model.generic_llm);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('| should create an instance with custom model', (): void => {
|
|
13
|
+
const settings = new DyFM_LAI_CallSettings({
|
|
14
|
+
useModel: DyFM_LAI_Model.generic_llm,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(settings.useModel).toBe(DyFM_LAI_Model.generic_llm);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('| should create an instance with string model', (): void => {
|
|
21
|
+
const settings = new DyFM_LAI_CallSettings({
|
|
22
|
+
useModel: 'custom-model',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
expect(settings.useModel).toBe('custom-model');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DyFM_LAI_Settings } from './lai-settings.control-model';
|
|
2
|
+
import { DyFM_AI_Provider } from '../../../_enums/ai-provider.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_LAI_Settings', (): void => {
|
|
5
|
+
it('| should create an instance with default values', (): void => {
|
|
6
|
+
const settings = new DyFM_LAI_Settings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.LocalAI);
|
|
10
|
+
expect(settings.defaultSettings).toBeTruthy();
|
|
11
|
+
expect(settings.config).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('| should create an instance with custom values', (): void => {
|
|
15
|
+
const settings = new DyFM_LAI_Settings({
|
|
16
|
+
provider: DyFM_AI_Provider.LocalAI,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.LocalAI);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DyFM_OAI_CallSettings } from './oai-call-settings.control-model';
|
|
2
|
+
import { DyFM_OAI_Model } from '../_enums/oai-model.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_OAI_CallSettings', (): void => {
|
|
5
|
+
it('| should create an instance with default model', (): void => {
|
|
6
|
+
const settings = new DyFM_OAI_CallSettings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.useModel).toBe(DyFM_OAI_Model.gpt4o);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('| should create an instance with custom model', (): void => {
|
|
13
|
+
const settings = new DyFM_OAI_CallSettings({
|
|
14
|
+
useModel: DyFM_OAI_Model.gpt4o,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(settings.useModel).toBe(DyFM_OAI_Model.gpt4o);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('| should create an instance with string model', (): void => {
|
|
21
|
+
const settings = new DyFM_OAI_CallSettings({
|
|
22
|
+
useModel: 'custom-model',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
expect(settings.useModel).toBe('custom-model');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DyFM_OAI_Settings } from './oai-settings.control-model';
|
|
2
|
+
import { DyFM_AI_Provider } from '../../../_enums/ai-provider.enum';
|
|
3
|
+
|
|
4
|
+
describe('| DyFM_OAI_Settings', (): void => {
|
|
5
|
+
it('| should create an instance with default values', (): void => {
|
|
6
|
+
const settings = new DyFM_OAI_Settings();
|
|
7
|
+
|
|
8
|
+
expect(settings).toBeTruthy();
|
|
9
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.OpenAI);
|
|
10
|
+
expect(settings.defaultSettings).toBeTruthy();
|
|
11
|
+
expect(settings.config).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('| should create an instance with custom values', (): void => {
|
|
15
|
+
const settings = new DyFM_OAI_Settings({
|
|
16
|
+
provider: DyFM_AI_Provider.OpenAI,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(settings.provider).toBe(DyFM_AI_Provider.OpenAI);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DyFM_CIT_CIResultInfo } from './cit-ci-result-info.data-models';
|
|
2
|
+
import { DyFM_CIT_CIResultCode } from '../_enums/cit-ci-result-code.enum';
|
|
3
|
+
import { DyFM_CIT_CIStepResultCode } from '../_enums/cit-ci-step-result-code.enum';
|
|
4
|
+
import { DyFM_CIT_CIStepResult } from './cit-ci-step-result.interface';
|
|
5
|
+
|
|
6
|
+
describe('| DyFM_CIT_CIResultInfo', (): void => {
|
|
7
|
+
it('| should create an instance without initial data', (): void => {
|
|
8
|
+
const resultInfo = new DyFM_CIT_CIResultInfo();
|
|
9
|
+
|
|
10
|
+
expect(resultInfo).toBeTruthy();
|
|
11
|
+
expect(resultInfo.__created).toBeInstanceOf(Date);
|
|
12
|
+
expect(resultInfo.__lastModified).toBeInstanceOf(Date);
|
|
13
|
+
expect(resultInfo.stepResults).toEqual([]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('| should create an instance with initial data', (): void => {
|
|
17
|
+
const stepResults: DyFM_CIT_CIStepResult[] = [
|
|
18
|
+
{ stepName: 'build', resultCode: DyFM_CIT_CIStepResultCode.success, duration: 100 },
|
|
19
|
+
{ stepName: 'test', resultCode: DyFM_CIT_CIStepResultCode.success, duration: 200 },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const initialData: DyFM_CIT_CIResultInfo = {
|
|
23
|
+
project: 'myProject',
|
|
24
|
+
system: 'mySystem',
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
environment: 'development',
|
|
27
|
+
branch: 'main',
|
|
28
|
+
result: DyFM_CIT_CIResultCode.success,
|
|
29
|
+
stepResults: stepResults,
|
|
30
|
+
linkToAction: 'https://example.com',
|
|
31
|
+
duration: '10 seconds',
|
|
32
|
+
error: 'Error message',
|
|
33
|
+
errorDetails: { error: 'Error object' },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const resultInfo = new DyFM_CIT_CIResultInfo(initialData);
|
|
37
|
+
|
|
38
|
+
expect(resultInfo.project).toBe('myProject');
|
|
39
|
+
expect(resultInfo.system).toBe('mySystem');
|
|
40
|
+
expect(resultInfo.version).toBe('1.0.0');
|
|
41
|
+
expect(resultInfo.environment).toBe('development');
|
|
42
|
+
expect(resultInfo.branch).toBe('main');
|
|
43
|
+
expect(resultInfo.result).toBe(DyFM_CIT_CIResultCode.success);
|
|
44
|
+
expect(resultInfo.stepResults).toEqual(stepResults);
|
|
45
|
+
expect(resultInfo.linkToAction).toBe('https://example.com');
|
|
46
|
+
expect(resultInfo.duration).toBe('10 seconds');
|
|
47
|
+
expect(resultInfo.error).toBe('Error message');
|
|
48
|
+
expect(resultInfo.errorDetails).toEqual({ error: 'Error object' });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('| should have dataParams defined', (): void => {
|
|
52
|
+
const { DyFM_CIT_ciResultInfo_dataParams } = require('./cit-ci-result-info.data-models');
|
|
53
|
+
|
|
54
|
+
expect(DyFM_CIT_ciResultInfo_dataParams).toBeTruthy();
|
|
55
|
+
expect(DyFM_CIT_ciResultInfo_dataParams.dataName).toBe('ci_result_info');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { DyFM_DataHandler_Settings, DyFM_DataListHandler_Settings, DyFM_DataSearchHandler_Settings, DyFM_ListCollectorDataHandler_Settings } from './data-handler-settings.control-model';
|
|
2
|
+
import { DyFM_Metadata } from '../../../_models/data-models/metadata.data-model';
|
|
3
|
+
import { DyFM_SearchQuery } from '../../../_models/interfaces/search-query.interface';
|
|
4
|
+
|
|
5
|
+
class TestMetadata extends DyFM_Metadata {
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
describe('| DyFM_DataHandler_Settings', (): void => {
|
|
10
|
+
it('| should create an instance with minimal settings', (): void => {
|
|
11
|
+
const settings = new DyFM_DataHandler_Settings<TestMetadata>();
|
|
12
|
+
Object.assign(settings, {
|
|
13
|
+
name: 'TestHandler',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expect(settings.name).toBe('TestHandler');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('| should create an instance with all settings', (): void => {
|
|
20
|
+
const getFn = async (): Promise<TestMetadata> => ({ _id: 'test' } as TestMetadata);
|
|
21
|
+
const setFn = async (data: TestMetadata): Promise<TestMetadata> => data;
|
|
22
|
+
const postProcess = async (data: any): Promise<any> => data;
|
|
23
|
+
|
|
24
|
+
const settings = new DyFM_DataHandler_Settings<TestMetadata>();
|
|
25
|
+
Object.assign(settings, {
|
|
26
|
+
name: 'TestHandler',
|
|
27
|
+
get: getFn,
|
|
28
|
+
set: setFn,
|
|
29
|
+
getPostProcess: postProcess,
|
|
30
|
+
defaultValue: { _id: 'default' } as TestMetadata,
|
|
31
|
+
defaultLoadBy: 'defaultId',
|
|
32
|
+
noId: false,
|
|
33
|
+
debugLog: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(settings.name).toBe('TestHandler');
|
|
37
|
+
expect(settings.get).toBe(getFn);
|
|
38
|
+
expect(settings.set).toBe(setFn);
|
|
39
|
+
expect(settings.getPostProcess).toBe(postProcess);
|
|
40
|
+
expect(settings.defaultValue).toEqual({ _id: 'default' });
|
|
41
|
+
expect(settings.defaultLoadBy).toBe('defaultId');
|
|
42
|
+
expect(settings.noId).toBe(false);
|
|
43
|
+
expect(settings.debugLog).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('| DyFM_DataListHandler_Settings', (): void => {
|
|
48
|
+
it('| should create an instance with list handler settings', (): void => {
|
|
49
|
+
const setItemFn = async (item: TestMetadata): Promise<TestMetadata> => item;
|
|
50
|
+
const deleteItemFn = async (id: string): Promise<void> => {};
|
|
51
|
+
|
|
52
|
+
const settings = new DyFM_DataListHandler_Settings<TestMetadata>();
|
|
53
|
+
Object.assign(settings, {
|
|
54
|
+
name: 'TestListHandler',
|
|
55
|
+
setItem: setItemFn,
|
|
56
|
+
deleteItem: deleteItemFn,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(settings.name).toBe('TestListHandler');
|
|
60
|
+
expect(settings.setItem).toBe(setItemFn);
|
|
61
|
+
expect(settings.deleteItem).toBe(deleteItemFn);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('| DyFM_DataSearchHandler_Settings', (): void => {
|
|
66
|
+
it('| should create an instance with search handler settings', (): void => {
|
|
67
|
+
const defaultQuery: DyFM_SearchQuery<TestMetadata> = {
|
|
68
|
+
page: 0,
|
|
69
|
+
pageSize: 10,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const settings = new DyFM_DataSearchHandler_Settings<TestMetadata>();
|
|
73
|
+
Object.assign(settings, {
|
|
74
|
+
name: 'TestSearchHandler',
|
|
75
|
+
defaultQuery: defaultQuery,
|
|
76
|
+
defaultPageSize: 20,
|
|
77
|
+
cacheSize: 10,
|
|
78
|
+
queryUpdateDebounceTime: 500,
|
|
79
|
+
searchOnInit: true,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
expect(settings.name).toBe('TestSearchHandler');
|
|
83
|
+
expect(settings.defaultQuery).toEqual(defaultQuery);
|
|
84
|
+
expect(settings.defaultPageSize).toBe(20);
|
|
85
|
+
expect(settings.cacheSize).toBe(10);
|
|
86
|
+
expect(settings.queryUpdateDebounceTime).toBe(500);
|
|
87
|
+
expect(settings.searchOnInit).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('| DyFM_ListCollectorDataHandler_Settings', (): void => {
|
|
92
|
+
it('| should create an instance with list collector settings', (): void => {
|
|
93
|
+
const setItemFn = async (item: TestMetadata, collectorId?: string): Promise<TestMetadata> => item;
|
|
94
|
+
const deleteItemFn = async (id: string, collectorId?: string): Promise<void> => {};
|
|
95
|
+
|
|
96
|
+
const settings = new DyFM_ListCollectorDataHandler_Settings<TestMetadata, TestMetadata>();
|
|
97
|
+
Object.assign(settings, {
|
|
98
|
+
name: 'TestCollectorHandler',
|
|
99
|
+
listKey: 'items',
|
|
100
|
+
setItem: setItemFn,
|
|
101
|
+
deleteItem: deleteItemFn,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(settings.name).toBe('TestCollectorHandler');
|
|
105
|
+
expect(settings.listKey).toBe('items');
|
|
106
|
+
expect(settings.setItem).toBe(setItemFn);
|
|
107
|
+
expect(settings.deleteItem).toBe(deleteItemFn);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|