@futdevpro/nts-dynamo 1.15.1 → 1.15.3
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/.cursor/rules/__assistant_guide.mdc +30 -0
- package/.cursor/rules/__main.mdc +62 -0
- package/.cursor/rules/_ag_backend-structure.mdc +86 -0
- package/.cursor/rules/_ag_backend.mdc +16 -0
- package/.cursor/rules/_ag_debug.mdc +8 -0
- package/.cursor/rules/_ag_documentation_writing_rules.mdc +372 -0
- package/.cursor/rules/_ag_file-refactoring.mdc +113 -0
- package/.cursor/rules/_ag_fixes_rules.mdc +6 -0
- package/.cursor/rules/_ag_frontend-structure.mdc +87 -0
- package/.cursor/rules/_ag_frontend.mdc +40 -0
- package/.cursor/rules/_ag_import-rules.mdc +45 -0
- package/.cursor/rules/_ag_naming.mdc +116 -0
- package/.cursor/rules/_ag_running_commands.mdc +5 -0
- package/.cursor/rules/_ag_server-controller.mdc +6 -0
- package/.cursor/rules/_ag_should-be.mdc +7 -0
- package/.cursor/rules/_ag_swearing.mdc +47 -0
- package/.cursor/rules/ai_development_guide.md +61 -0
- package/.cursor/rules/ai_directives.md +114 -0
- package/.cursor/rules/cursor-rules.md +160 -0
- package/.cursor/rules/default-command.mdc +229 -0
- package/.cursor/rules/error_code_pattern.md +40 -0
- package/.cursor/rules/saved rule mcp server use.md +16 -0
- package/build/_models/control-models/app-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/app-params.control-model.js +6 -1
- package/build/_models/control-models/app-params.control-model.js.map +1 -1
- package/build/_modules/custom-data/custom-data.controller.d.ts.map +1 -1
- package/build/_modules/custom-data/custom-data.controller.js +1 -2
- package/build/_modules/custom-data/custom-data.controller.js.map +1 -1
- package/build/_services/core/api.service.d.ts.map +1 -1
- package/build/_services/core/api.service.js +1 -0
- package/build/_services/core/api.service.js.map +1 -1
- package/build/_services/server/app.server.d.ts.map +1 -1
- package/build/_services/server/app.server.js +11 -0
- package/build/_services/server/app.server.js.map +1 -1
- package/package.json +5 -4
- package/scripts/run-coverage-tests.js +5 -1
- package/spec/support/helpers/spec-reporter-loader.js +359 -0
- package/spec/support/helpers/ts-node-helper.js +84 -0
- package/spec/support/jasmine.coverage.json +2 -1
- package/spec/support/jasmine.json +3 -3
- package/src/_collections/archive.util.spec.ts +36 -0
- package/src/_collections/get-environment-settings.util.spec.ts +210 -0
- package/src/_collections/star.controller.spec.ts +224 -0
- package/src/_models/control-models/api-call-params.control-model.spec.ts +62 -3
- package/src/_models/control-models/app-ext-system-controls.control-model.spec.ts +52 -0
- package/src/_models/control-models/app-params.control-model.spec.ts +158 -2
- package/src/_models/control-models/app-params.control-model.ts +8 -2
- package/src/_models/control-models/endpoint-params.control-model.spec.ts +578 -0
- package/src/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.spec.ts +242 -0
- package/src/_modules/ai/_modules/document-ai/_collections/dai-document.util.spec.ts +209 -0
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.spec.ts +342 -0
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.spec.ts +550 -0
- package/src/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.spec.ts +240 -0
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.spec.ts +462 -0
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.spec.ts +437 -0
- package/src/_modules/ai/_services/ai-embedding.service-base.spec.ts +98 -0
- package/src/_modules/ai/_services/ai-llm-chat.service-base.spec.ts +229 -0
- package/src/_modules/ai/_services/ai-llm.service-base.spec.ts +250 -0
- package/src/_modules/ai/_services/ai-provider.service-base.spec.ts +79 -0
- package/src/_modules/assistant/_collections/ass.util.spec.ts +176 -0
- package/src/_modules/assistant/_services/ass-io.control-service.spec.ts +140 -0
- package/src/_modules/assistant/_services/ass-main.control-service.spec.ts +192 -0
- package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.spec.ts +431 -0
- package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.spec.ts +160 -0
- package/src/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.spec.ts +374 -0
- package/src/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.spec.ts +344 -0
- package/src/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.spec.ts +345 -0
- package/src/_modules/bot/_services/bot-commands.control-service.spec.ts +116 -0
- package/src/_modules/bot/_services/bot-io.control-service.spec.ts +285 -0
- package/src/_modules/bot/_services/bot-main.control-service.spec.ts +208 -0
- package/src/_modules/bot/_services/bot-messaging-provider.service-base.spec.ts +349 -0
- package/src/_modules/bot/_services/bot-routines.control-service.spec.ts +111 -0
- package/src/_modules/custom-data/custom-data.controller.spec.ts +49 -0
- package/src/_modules/custom-data/custom-data.controller.ts +1 -3
- package/src/_modules/custom-data/custom-data.data-service.spec.ts +54 -0
- package/src/_modules/custom-data/get-custom-data-routing-module.util.spec.ts +28 -0
- package/src/_modules/defaults/_services/default-auth.service.spec.ts +269 -0
- package/src/_modules/defaults/_services/default-socket-events.service.spec.ts +42 -0
- package/src/_modules/defaults/_services/default-user.data-service.spec.ts +187 -0
- package/src/_modules/discord-assistant/_collections/dias.util.spec.ts +366 -0
- package/src/_modules/discord-assistant/_services/dias-io.control-service.spec.ts +108 -0
- package/src/_modules/discord-assistant/_services/dias-main.control-service.spec.ts +22 -0
- package/src/_modules/discord-assistant/_services/dias.service-base.spec.ts +195 -0
- package/src/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.spec.ts +34 -0
- package/src/_modules/discord-bot/_collections/dibo-operations.util.spec.ts +214 -0
- package/src/_modules/discord-bot/_services/dibo-commands.control-service.spec.ts +154 -0
- package/src/_modules/discord-bot/_services/dibo-io.control-service.spec.ts +264 -0
- package/src/_modules/discord-bot/_services/dibo-main.control-service.spec.ts +408 -0
- package/src/_modules/discord-bot/_services/dibo-routines.control-service.spec.ts +105 -0
- package/src/_modules/local-vector-search/_services/lvs-doc-chunk-data.service.spec.ts +418 -0
- package/src/_modules/local-vector-search/_services/lvs-local-vector-search.data-service.spec.ts +345 -0
- package/src/_modules/messaging/_collections/msg.util.spec.ts +226 -0
- package/src/_modules/messaging/_services/msg-events.service.spec.ts +219 -0
- package/src/_modules/messaging/_services/msg-main.control-service.spec.ts +147 -0
- package/src/_modules/messaging/_services/msg.controller.spec.ts +201 -0
- package/src/_modules/mock/data-model.mock.spec.ts +27 -24
- package/src/_modules/oauth2/_routes/oauth2.controller.spec.ts +107 -0
- package/src/_modules/oauth2/_services/oauth2.auth-service.spec.ts +254 -0
- package/src/_modules/oauth2/_services/oauth2.control-service.spec.ts +585 -0
- package/src/_modules/server/errors/errors.control-service.spec.ts +230 -0
- package/src/_modules/server/errors/errors.controller.spec.ts +165 -0
- package/src/_modules/server/errors/errors.data-service.spec.ts +355 -0
- package/src/_modules/server/server-status/server-status-snapshot.control-service.spec.ts +70 -0
- package/src/_modules/server/server-status/server-status-snapshot.data-service.spec.ts +77 -0
- package/src/_modules/server/server-status/server-status.control-service.spec.ts +516 -0
- package/src/_modules/server/server-status/server-status.controller.spec.ts +156 -0
- package/src/_modules/socket/_models/socket-client-service-params.control-model.spec.ts +6 -3
- package/src/_modules/socket/_models/socket-presence.control-model.spec.ts +164 -0
- package/src/_modules/socket/_services/socket-client.service.spec.ts +15 -0
- package/src/_modules/test/get-test-routing-module.util.spec.ts +28 -0
- package/src/_modules/test/test.controller.spec.ts +72 -0
- package/src/_modules/usage/usage.controller.spec.ts +81 -0
- package/src/_modules/usage/usage.data-service.spec.ts +332 -0
- package/src/_services/base/api.service-base.spec.ts +125 -0
- package/src/_services/base/archive-data.service.spec.ts +196 -0
- package/src/_services/base/data.service.spec.ts +493 -0
- package/src/_services/base/db.service.spec.ts +59 -18
- package/src/_services/base/singleton.service-base.spec.ts +28 -0
- package/src/_services/base/singleton.service.spec.ts +114 -0
- package/src/_services/core/api.service.ts +1 -0
- package/src/_services/core/auth.service.spec.ts +159 -0
- package/src/_services/core/email.service.spec.ts +14 -22
- package/src/_services/core/global.service.spec.ts +275 -0
- package/src/_services/core/service-collection.service.spec.ts +46 -0
- package/src/_services/route/routing-module.service.spec.ts +8 -6
- package/src/_services/server/app.server.ts +12 -0
- package/src/_services/shared.static-service.spec.ts +89 -0
- package/build/_collections/archive.util.spec.d.ts +0 -2
- package/build/_collections/archive.util.spec.d.ts.map +0 -1
- package/build/_collections/archive.util.spec.js +0 -21
- package/build/_collections/archive.util.spec.js.map +0 -1
- package/build/_models/control-models/api-call-params.control-model.spec.d.ts +0 -2
- package/build/_models/control-models/api-call-params.control-model.spec.d.ts.map +0 -1
- package/build/_models/control-models/api-call-params.control-model.spec.js +0 -80
- package/build/_models/control-models/api-call-params.control-model.spec.js.map +0 -1
- package/build/_models/control-models/app-params.control-model.spec.d.ts +0 -2
- package/build/_models/control-models/app-params.control-model.spec.d.ts.map +0 -1
- package/build/_models/control-models/app-params.control-model.spec.js +0 -59
- package/build/_models/control-models/app-params.control-model.spec.js.map +0 -1
- package/build/_models/control-models/app-system-controls.control-model.spec.d.ts +0 -2
- package/build/_models/control-models/app-system-controls.control-model.spec.d.ts.map +0 -1
- package/build/_models/control-models/app-system-controls.control-model.spec.js +0 -26
- package/build/_models/control-models/app-system-controls.control-model.spec.js.map +0 -1
- package/build/_models/control-models/http-settings.control-model.spec.d.ts +0 -2
- package/build/_models/control-models/http-settings.control-model.spec.d.ts.map +0 -1
- package/build/_models/control-models/http-settings.control-model.spec.js +0 -62
- package/build/_models/control-models/http-settings.control-model.spec.js.map +0 -1
- package/build/_models/control-models/system-control.control-model.spec.d.ts +0 -2
- package/build/_models/control-models/system-control.control-model.spec.d.ts.map +0 -1
- package/build/_models/control-models/system-control.control-model.spec.js +0 -24
- package/build/_models/control-models/system-control.control-model.spec.js.map +0 -1
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.spec.d.ts +0 -2
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.spec.d.ts.map +0 -1
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.spec.js +0 -294
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.spec.js.map +0 -1
- package/build/_modules/mock/app-params.mock.spec.d.ts +0 -2
- package/build/_modules/mock/app-params.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/app-params.mock.spec.js +0 -19
- package/build/_modules/mock/app-params.mock.spec.js.map +0 -1
- package/build/_modules/mock/auth-service.mock.spec.d.ts +0 -2
- package/build/_modules/mock/auth-service.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/auth-service.mock.spec.js +0 -40
- package/build/_modules/mock/auth-service.mock.spec.js.map +0 -1
- package/build/_modules/mock/controller.mock.spec.d.ts +0 -2
- package/build/_modules/mock/controller.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/controller.mock.spec.js +0 -23
- package/build/_modules/mock/controller.mock.spec.js.map +0 -1
- package/build/_modules/mock/data-model.mock.spec.d.ts +0 -2
- package/build/_modules/mock/data-model.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/data-model.mock.spec.js +0 -98
- package/build/_modules/mock/data-model.mock.spec.js.map +0 -1
- package/build/_modules/mock/email-service-collection.mock.spec.d.ts +0 -2
- package/build/_modules/mock/email-service-collection.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/email-service-collection.mock.spec.js +0 -21
- package/build/_modules/mock/email-service-collection.mock.spec.js.map +0 -1
- package/build/_modules/mock/email-service.mock.spec.d.ts +0 -2
- package/build/_modules/mock/email-service.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/email-service.mock.spec.js +0 -14
- package/build/_modules/mock/email-service.mock.spec.js.map +0 -1
- package/build/_modules/mock/socket-client.mock.spec.d.ts +0 -2
- package/build/_modules/mock/socket-client.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/socket-client.mock.spec.js +0 -32
- package/build/_modules/mock/socket-client.mock.spec.js.map +0 -1
- package/build/_modules/mock/socket-server.mock.spec.d.ts +0 -2
- package/build/_modules/mock/socket-server.mock.spec.d.ts.map +0 -1
- package/build/_modules/mock/socket-server.mock.spec.js +0 -36
- package/build/_modules/mock/socket-server.mock.spec.js.map +0 -1
- package/build/_modules/socket/_models/socket-client-service-params.control-model.spec.d.ts +0 -2
- package/build/_modules/socket/_models/socket-client-service-params.control-model.spec.d.ts.map +0 -1
- package/build/_modules/socket/_models/socket-client-service-params.control-model.spec.js +0 -22
- package/build/_modules/socket/_models/socket-client-service-params.control-model.spec.js.map +0 -1
- package/build/_modules/socket/_models/socket-server-service-params.control-model.spec.d.ts +0 -2
- package/build/_modules/socket/_models/socket-server-service-params.control-model.spec.d.ts.map +0 -1
- package/build/_modules/socket/_models/socket-server-service-params.control-model.spec.js +0 -29
- package/build/_modules/socket/_models/socket-server-service-params.control-model.spec.js.map +0 -1
- package/build/_modules/socket/_services/socket-server.service.spec.d.ts +0 -2
- package/build/_modules/socket/_services/socket-server.service.spec.d.ts.map +0 -1
- package/build/_modules/socket/_services/socket-server.service.spec.js +0 -9
- package/build/_modules/socket/_services/socket-server.service.spec.js.map +0 -1
- package/build/_modules/socket/app-extended.server.spec.d.ts +0 -2
- package/build/_modules/socket/app-extended.server.spec.d.ts.map +0 -1
- package/build/_modules/socket/app-extended.server.spec.js +0 -149
- package/build/_modules/socket/app-extended.server.spec.js.map +0 -1
- package/build/_services/base/db.service.spec.d.ts +0 -1
- package/build/_services/base/db.service.spec.d.ts.map +0 -1
- package/build/_services/base/db.service.spec.js +0 -28
- package/build/_services/base/db.service.spec.js.map +0 -1
- package/build/_services/core/api.service.spec.d.ts +0 -2
- package/build/_services/core/api.service.spec.d.ts.map +0 -1
- package/build/_services/core/api.service.spec.js +0 -109
- package/build/_services/core/api.service.spec.js.map +0 -1
- package/build/_services/core/email.service.spec.d.ts +0 -2
- package/build/_services/core/email.service.spec.d.ts.map +0 -1
- package/build/_services/core/email.service.spec.js +0 -77
- package/build/_services/core/email.service.spec.js.map +0 -1
- package/build/_services/route/controller.service.spec.d.ts +0 -2
- package/build/_services/route/controller.service.spec.d.ts.map +0 -1
- package/build/_services/route/controller.service.spec.js +0 -48
- package/build/_services/route/controller.service.spec.js.map +0 -1
- package/build/_services/route/routing-module.service.spec.d.ts +0 -2
- package/build/_services/route/routing-module.service.spec.d.ts.map +0 -1
- package/build/_services/route/routing-module.service.spec.js +0 -64
- package/build/_services/route/routing-module.service.spec.js.map +0 -1
- package/build/_services/server/app.server.spec.d.ts +0 -2
- package/build/_services/server/app.server.spec.d.ts.map +0 -1
- package/build/_services/server/app.server.spec.js +0 -80
- package/build/_services/server/app.server.spec.js.map +0 -1
- package/build/_services/shared.static-service.spec.d.ts +0 -2
- package/build/_services/shared.static-service.spec.d.ts.map +0 -1
- package/build/_services/shared.static-service.spec.js +0 -12
- package/build/_services/shared.static-service.spec.js.map +0 -1
- package/src/_modules/socket/app-extended.server.spec.ts +0 -227
- package/src/_services/server/app.server.spec.ts +0 -138
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { DyNTS_DAI_DocChunking_Util } from './dai-chunking.util';
|
|
4
|
+
import { DyNTS_DAI_DocPage } from '../_models/data-models/dai-doc-page.data-model';
|
|
5
|
+
import { DyNTS_DAI_DocChunk } from '../_models/data-models/dai-doc-chunk.data-model';
|
|
6
|
+
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
7
|
+
|
|
8
|
+
describe('| DyNTS_DAI_DocChunking_Util', () => {
|
|
9
|
+
describe('| chunkMdContent', () => {
|
|
10
|
+
it('| should throw error when page documentId is not set', async () => {
|
|
11
|
+
const page = new DyNTS_DAI_DocPage({
|
|
12
|
+
name: 'Test Page',
|
|
13
|
+
content: 'Test content',
|
|
14
|
+
documentId: '',
|
|
15
|
+
_id: 'page-123',
|
|
16
|
+
parentedPath: [],
|
|
17
|
+
allFlaggedParents: [],
|
|
18
|
+
allFlaggedParentsMerged: '',
|
|
19
|
+
filePath: '',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const getPageLink = (page: any, issuer: string) => 'http://example.com/page';
|
|
23
|
+
|
|
24
|
+
await expectAsync(
|
|
25
|
+
DyNTS_DAI_DocChunking_Util.chunkMdContent(page, getPageLink, 'issuer-123')
|
|
26
|
+
).toBeRejected();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('| should throw error when page _id is not set', async () => {
|
|
30
|
+
const page = new DyNTS_DAI_DocPage({
|
|
31
|
+
name: 'Test Page',
|
|
32
|
+
content: 'Test content',
|
|
33
|
+
documentId: 'doc-123',
|
|
34
|
+
_id: '',
|
|
35
|
+
parentedPath: [],
|
|
36
|
+
allFlaggedParents: [],
|
|
37
|
+
allFlaggedParentsMerged: '',
|
|
38
|
+
filePath: '',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const getPageLink = (page: any, issuer: string) => 'http://example.com/page';
|
|
42
|
+
|
|
43
|
+
await expectAsync(
|
|
44
|
+
DyNTS_DAI_DocChunking_Util.chunkMdContent(page, getPageLink, 'issuer-123')
|
|
45
|
+
).toBeRejected();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('| should create chunks from markdown content', async () => {
|
|
49
|
+
const page = new DyNTS_DAI_DocPage({
|
|
50
|
+
name: 'Test Page',
|
|
51
|
+
content: '# Header 1\n\nThis is some content.\n\n## Header 2\n\nMore content here.',
|
|
52
|
+
documentId: 'doc-123',
|
|
53
|
+
_id: 'page-123',
|
|
54
|
+
parentedPath: [],
|
|
55
|
+
allFlaggedParents: [],
|
|
56
|
+
allFlaggedParentsMerged: '',
|
|
57
|
+
filePath: '',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const getPageLink = (page: any, issuer: string) => 'http://example.com/page';
|
|
61
|
+
|
|
62
|
+
const chunks = await DyNTS_DAI_DocChunking_Util.chunkMdContent(page, getPageLink, 'issuer-123');
|
|
63
|
+
|
|
64
|
+
expect(chunks.length).toBeGreaterThan(0);
|
|
65
|
+
expect(chunks[0]).toBeInstanceOf(DyNTS_DAI_DocChunk);
|
|
66
|
+
expect(chunks[0].documentId).toBe('doc-123');
|
|
67
|
+
expect(chunks[0].pageId).toBe('page-123');
|
|
68
|
+
expect(chunks[0].chunkContent).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('| should handle empty content', async () => {
|
|
72
|
+
const page = new DyNTS_DAI_DocPage({
|
|
73
|
+
name: 'Test Page',
|
|
74
|
+
content: '',
|
|
75
|
+
documentId: 'doc-123',
|
|
76
|
+
_id: 'page-123',
|
|
77
|
+
parentedPath: [],
|
|
78
|
+
allFlaggedParents: [],
|
|
79
|
+
allFlaggedParentsMerged: '',
|
|
80
|
+
filePath: '',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const getPageLink = (page: any, issuer: string) => 'http://example.com/page';
|
|
84
|
+
|
|
85
|
+
const chunks = await DyNTS_DAI_DocChunking_Util.chunkMdContent(page, getPageLink, 'issuer-123');
|
|
86
|
+
|
|
87
|
+
expect(chunks.length).toBe(0);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('| should log warning for level 5+ headers', async () => {
|
|
91
|
+
const logSpy = spyOn(DyFM_Log, 'warn');
|
|
92
|
+
const page = new DyNTS_DAI_DocPage({
|
|
93
|
+
name: 'Test Page',
|
|
94
|
+
content: '##### Level 5 Header\n\nContent',
|
|
95
|
+
documentId: 'doc-123',
|
|
96
|
+
_id: 'page-123',
|
|
97
|
+
parentedPath: [],
|
|
98
|
+
allFlaggedParents: [],
|
|
99
|
+
allFlaggedParentsMerged: '',
|
|
100
|
+
filePath: '',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const getPageLink = (page: any, issuer: string) => 'http://example.com/page';
|
|
104
|
+
|
|
105
|
+
await DyNTS_DAI_DocChunking_Util.chunkMdContent(page, getPageLink, 'issuer-123');
|
|
106
|
+
|
|
107
|
+
expect(logSpy).toHaveBeenCalled();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('| should respect maxChunkCount limit', async () => {
|
|
111
|
+
const logSpy = spyOn(DyFM_Log, 'warn');
|
|
112
|
+
const longContent = '# Header\n\n' + 'Content. '.repeat(10000);
|
|
113
|
+
const page = new DyNTS_DAI_DocPage({
|
|
114
|
+
name: 'Test Page',
|
|
115
|
+
content: longContent,
|
|
116
|
+
documentId: 'doc-123',
|
|
117
|
+
_id: 'page-123',
|
|
118
|
+
parentedPath: [],
|
|
119
|
+
allFlaggedParents: [],
|
|
120
|
+
allFlaggedParentsMerged: '',
|
|
121
|
+
filePath: '',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const getPageLink = (page: any, issuer: string) => 'http://example.com/page';
|
|
125
|
+
|
|
126
|
+
const chunks = await DyNTS_DAI_DocChunking_Util.chunkMdContent(page, getPageLink, 'issuer-123');
|
|
127
|
+
|
|
128
|
+
expect(chunks.length).toBeLessThanOrEqual(DyNTS_global_settings.docChunking.maxChunkCount);
|
|
129
|
+
if (chunks.length >= DyNTS_global_settings.docChunking.maxChunkCount) {
|
|
130
|
+
expect(logSpy).toHaveBeenCalled();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('| reassembleChunksToContent', () => {
|
|
136
|
+
it('| should reassemble chunks to content', () => {
|
|
137
|
+
const chunks = [
|
|
138
|
+
new DyNTS_DAI_DocChunk({
|
|
139
|
+
documentId: 'doc-123',
|
|
140
|
+
pageId: 'page-123',
|
|
141
|
+
filePathParents: [],
|
|
142
|
+
chunkHeadParents: [],
|
|
143
|
+
allFlaggedParents: [],
|
|
144
|
+
path: '',
|
|
145
|
+
documentName: 'Test Document',
|
|
146
|
+
pageName: 'Test Page',
|
|
147
|
+
pageLink: '',
|
|
148
|
+
chunkContent: 'First chunk content',
|
|
149
|
+
chunkIndex: 0,
|
|
150
|
+
_id: 'chunk-1',
|
|
151
|
+
} as any),
|
|
152
|
+
new DyNTS_DAI_DocChunk({
|
|
153
|
+
documentId: 'doc-123',
|
|
154
|
+
pageId: 'page-123',
|
|
155
|
+
filePathParents: [],
|
|
156
|
+
chunkHeadParents: [],
|
|
157
|
+
allFlaggedParents: [],
|
|
158
|
+
path: '',
|
|
159
|
+
documentName: 'Test Document',
|
|
160
|
+
pageName: 'Test Page',
|
|
161
|
+
pageLink: '',
|
|
162
|
+
chunkContent: 'Second chunk content',
|
|
163
|
+
chunkIndex: 1,
|
|
164
|
+
_id: 'chunk-2',
|
|
165
|
+
} as any),
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
const result = DyNTS_DAI_DocChunking_Util.reassembleChunksToContent(chunks, 'issuer-123');
|
|
169
|
+
|
|
170
|
+
expect(result).toContain('First chunk content');
|
|
171
|
+
expect(result).toContain('Second chunk content');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('| should handle empty chunks array', () => {
|
|
175
|
+
const result = DyNTS_DAI_DocChunking_Util.reassembleChunksToContent([], 'issuer-123');
|
|
176
|
+
|
|
177
|
+
expect(result).toBe('');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('| should concatenate chunks in order', () => {
|
|
181
|
+
const chunks = [
|
|
182
|
+
new DyNTS_DAI_DocChunk({
|
|
183
|
+
documentId: 'doc-123',
|
|
184
|
+
pageId: 'page-123',
|
|
185
|
+
filePathParents: [],
|
|
186
|
+
chunkHeadParents: [],
|
|
187
|
+
allFlaggedParents: [],
|
|
188
|
+
path: '',
|
|
189
|
+
documentName: 'Test Document',
|
|
190
|
+
pageName: 'Test Page',
|
|
191
|
+
pageLink: '',
|
|
192
|
+
chunkContent: 'First',
|
|
193
|
+
chunkIndex: 0,
|
|
194
|
+
_id: 'chunk-1',
|
|
195
|
+
} as any),
|
|
196
|
+
new DyNTS_DAI_DocChunk({
|
|
197
|
+
documentId: 'doc-123',
|
|
198
|
+
pageId: 'page-123',
|
|
199
|
+
filePathParents: [],
|
|
200
|
+
chunkHeadParents: [],
|
|
201
|
+
allFlaggedParents: [],
|
|
202
|
+
path: '',
|
|
203
|
+
documentName: 'Test Document',
|
|
204
|
+
pageName: 'Test Page',
|
|
205
|
+
pageLink: '',
|
|
206
|
+
chunkContent: 'Second',
|
|
207
|
+
chunkIndex: 1,
|
|
208
|
+
_id: 'chunk-2',
|
|
209
|
+
} as any),
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
const result = DyNTS_DAI_DocChunking_Util.reassembleChunksToContent(chunks, 'issuer-123');
|
|
213
|
+
|
|
214
|
+
expect(result).toBe('FirstSecond');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('| should throw error when chunk is null', () => {
|
|
218
|
+
const chunks = [
|
|
219
|
+
new DyNTS_DAI_DocChunk({
|
|
220
|
+
documentId: 'doc-123',
|
|
221
|
+
pageId: 'page-123',
|
|
222
|
+
filePathParents: [],
|
|
223
|
+
chunkHeadParents: [],
|
|
224
|
+
allFlaggedParents: [],
|
|
225
|
+
path: '',
|
|
226
|
+
documentName: 'Test Document',
|
|
227
|
+
pageName: 'Test Page',
|
|
228
|
+
pageLink: '',
|
|
229
|
+
chunkContent: 'First',
|
|
230
|
+
chunkIndex: 0,
|
|
231
|
+
_id: 'chunk-1',
|
|
232
|
+
} as any),
|
|
233
|
+
null as any,
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
expect(() => {
|
|
237
|
+
DyNTS_DAI_DocChunking_Util.reassembleChunksToContent(chunks, 'issuer-123');
|
|
238
|
+
}).toThrow();
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyNTS_DAI_Document_Util } from './dai-document.util';
|
|
3
|
+
import { DyNTS_DAI_DocPage } from '../_models/data-models/dai-doc-page.data-model';
|
|
4
|
+
import { DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
5
|
+
|
|
6
|
+
describe('| DyNTS_DAI_Document_Util', () => {
|
|
7
|
+
describe('| getClickupPageLink', () => {
|
|
8
|
+
it('| should generate ClickUp page link', () => {
|
|
9
|
+
const result = DyNTS_DAI_Document_Util.getClickupPageLink(
|
|
10
|
+
'Test Page',
|
|
11
|
+
'workspace-123',
|
|
12
|
+
'doc-456',
|
|
13
|
+
'page-789'
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(result).toContain('Test Page');
|
|
17
|
+
expect(result).toContain('https://app.clickup.com/workspace-123/v/dc/doc-456/page-789');
|
|
18
|
+
expect(result).toMatch(/\[Test Page\]\(https:\/\/app\.clickup\.com\/workspace-123\/v\/dc\/doc-456\/page-789\)/);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('| validateDocumentPage', () => {
|
|
23
|
+
it('| should return true for valid page', () => {
|
|
24
|
+
const page = new DyNTS_DAI_DocPage({
|
|
25
|
+
name: 'Test Page',
|
|
26
|
+
content: 'Test content',
|
|
27
|
+
documentId: 'doc-123',
|
|
28
|
+
_id: 'page-123',
|
|
29
|
+
parentedPath: [],
|
|
30
|
+
allFlaggedParents: [],
|
|
31
|
+
allFlaggedParentsMerged: '',
|
|
32
|
+
filePath: '',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const result = DyNTS_DAI_Document_Util.validateDocumentPage(page);
|
|
36
|
+
|
|
37
|
+
expect(result).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('| should return false when name is missing', () => {
|
|
41
|
+
const logSpy = spyOn(DyFM_Log, 'error');
|
|
42
|
+
const page = new DyNTS_DAI_DocPage({
|
|
43
|
+
name: '',
|
|
44
|
+
content: 'Test content',
|
|
45
|
+
documentId: 'doc-123',
|
|
46
|
+
_id: 'page-123',
|
|
47
|
+
parentedPath: [],
|
|
48
|
+
allFlaggedParents: [],
|
|
49
|
+
allFlaggedParentsMerged: '',
|
|
50
|
+
filePath: '',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const result = DyNTS_DAI_Document_Util.validateDocumentPage(page);
|
|
54
|
+
|
|
55
|
+
expect(result).toBe(false);
|
|
56
|
+
expect(logSpy).toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('| should return false when content is missing', () => {
|
|
60
|
+
const logSpy = spyOn(DyFM_Log, 'error');
|
|
61
|
+
const page = new DyNTS_DAI_DocPage({
|
|
62
|
+
name: 'Test Page',
|
|
63
|
+
content: '',
|
|
64
|
+
documentId: 'doc-123',
|
|
65
|
+
_id: 'page-123',
|
|
66
|
+
parentedPath: [],
|
|
67
|
+
allFlaggedParents: [],
|
|
68
|
+
allFlaggedParentsMerged: '',
|
|
69
|
+
filePath: '',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const result = DyNTS_DAI_Document_Util.validateDocumentPage(page);
|
|
73
|
+
|
|
74
|
+
expect(result).toBe(false);
|
|
75
|
+
expect(logSpy).toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('| normalizeContent', () => {
|
|
80
|
+
it('| should normalize line endings from CRLF to LF', () => {
|
|
81
|
+
const content = 'Line 1\r\nLine 2\r\nLine 3';
|
|
82
|
+
const result = DyNTS_DAI_Document_Util.normalizeContent(content);
|
|
83
|
+
|
|
84
|
+
expect(result).toBe('Line 1\nLine 2\nLine 3');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('| should normalize line endings from CR to LF', () => {
|
|
88
|
+
const content = 'Line 1\rLine 2\rLine 3';
|
|
89
|
+
const result = DyNTS_DAI_Document_Util.normalizeContent(content);
|
|
90
|
+
|
|
91
|
+
expect(result).toBe('Line 1\nLine 2\nLine 3');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('| should trim leading and trailing whitespace', () => {
|
|
95
|
+
const content = ' Line 1\nLine 2 ';
|
|
96
|
+
const result = DyNTS_DAI_Document_Util.normalizeContent(content);
|
|
97
|
+
|
|
98
|
+
expect(result).toBe('Line 1\nLine 2');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('| should handle mixed line endings', () => {
|
|
102
|
+
const content = 'Line 1\r\nLine 2\rLine 3\nLine 4';
|
|
103
|
+
const result = DyNTS_DAI_Document_Util.normalizeContent(content);
|
|
104
|
+
|
|
105
|
+
expect(result).toBe('Line 1\nLine 2\nLine 3\nLine 4');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('| extractMetadata', () => {
|
|
110
|
+
it('| should extract title from first header', () => {
|
|
111
|
+
const content = '# Title\n\nContent here';
|
|
112
|
+
const result = DyNTS_DAI_Document_Util.extractMetadata(content);
|
|
113
|
+
|
|
114
|
+
expect(result.title).toBe('Title');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('| should extract word count', () => {
|
|
118
|
+
const content = 'This is a test content with multiple words';
|
|
119
|
+
const result = DyNTS_DAI_Document_Util.extractMetadata(content);
|
|
120
|
+
|
|
121
|
+
// Content.split(/\s+/) returns 8 words: "This", "is", "a", "test", "content", "with", "multiple", "words"
|
|
122
|
+
expect(result.wordCount).toBe(8);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('| should extract character count', () => {
|
|
126
|
+
const content = 'Test content';
|
|
127
|
+
const result = DyNTS_DAI_Document_Util.extractMetadata(content);
|
|
128
|
+
|
|
129
|
+
expect(result.characterCount).toBe(content.length);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('| should extract header count', () => {
|
|
133
|
+
const content = '# Header 1\n## Header 2\n### Header 3';
|
|
134
|
+
const result = DyNTS_DAI_Document_Util.extractMetadata(content);
|
|
135
|
+
|
|
136
|
+
expect(result.headerCount).toBe(3);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('| should return 0 header count when no headers', () => {
|
|
140
|
+
const content = 'Just plain text without headers';
|
|
141
|
+
const result = DyNTS_DAI_Document_Util.extractMetadata(content);
|
|
142
|
+
|
|
143
|
+
expect(result.headerCount).toBe(0);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('| should extract all metadata fields', () => {
|
|
147
|
+
const content = '# Document Title\n\nThis is the content of the document.';
|
|
148
|
+
const result = DyNTS_DAI_Document_Util.extractMetadata(content);
|
|
149
|
+
|
|
150
|
+
expect(result.title).toBe('Document Title');
|
|
151
|
+
expect(result.wordCount).toBeGreaterThan(0);
|
|
152
|
+
expect(result.characterCount).toBeGreaterThan(0);
|
|
153
|
+
expect(result.headerCount).toBe(1);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('| isEmpty', () => {
|
|
158
|
+
it('| should return true for empty string', () => {
|
|
159
|
+
expect(DyNTS_DAI_Document_Util.isEmpty('')).toBe(true);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('| should return true for whitespace only', () => {
|
|
163
|
+
expect(DyNTS_DAI_Document_Util.isEmpty(' \n\t ')).toBe(true);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('| should return false for content with text', () => {
|
|
167
|
+
expect(DyNTS_DAI_Document_Util.isEmpty('Some content')).toBe(false);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('| should return true for null or undefined', () => {
|
|
171
|
+
expect(DyNTS_DAI_Document_Util.isEmpty(null as any)).toBe(true);
|
|
172
|
+
expect(DyNTS_DAI_Document_Util.isEmpty(undefined as any)).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe('| getPreview', () => {
|
|
177
|
+
it('| should return full content when shorter than maxLength', () => {
|
|
178
|
+
const content = 'Short content';
|
|
179
|
+
const result = DyNTS_DAI_Document_Util.getPreview(content, 200);
|
|
180
|
+
|
|
181
|
+
expect(result).toBe('Short content');
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('| should truncate content when longer than maxLength', () => {
|
|
185
|
+
const content = 'A'.repeat(300);
|
|
186
|
+
const result = DyNTS_DAI_Document_Util.getPreview(content, 200);
|
|
187
|
+
|
|
188
|
+
expect(result.length).toBe(203); // 200 + '...'
|
|
189
|
+
expect(result.endsWith('...')).toBe(true);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('| should use default maxLength of 200', () => {
|
|
193
|
+
const content = 'A'.repeat(250);
|
|
194
|
+
const result = DyNTS_DAI_Document_Util.getPreview(content);
|
|
195
|
+
|
|
196
|
+
expect(result.length).toBe(203); // 200 + '...'
|
|
197
|
+
expect(result.endsWith('...')).toBe(true);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('| should handle exact maxLength', () => {
|
|
201
|
+
const content = 'A'.repeat(200);
|
|
202
|
+
const result = DyNTS_DAI_Document_Util.getPreview(content, 200);
|
|
203
|
+
|
|
204
|
+
expect(result).toBe(content);
|
|
205
|
+
expect(result.endsWith('...')).toBe(false);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|