@tstdl/base 0.93.130 → 0.93.132
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/ai/parser/parser.d.ts +1 -1
- package/ai/parser/parser.js +4 -3
- package/document-management/models/ai-configuration.d.ts +1 -1
- package/document-management/server/services/document-management-ai.service.js +4 -3
- package/document-management/tests/ai-config-merge.test.js +8 -0
- package/orm/sqls/sqls.js +3 -1
- package/package.json +1 -1
package/ai/parser/parser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AIs sometimes return the string "null" instead of an actual null value. This function converts such strings to null, while leaving other strings unchanged.
|
|
3
3
|
*/
|
|
4
|
-
export declare function parseAiNullableText(text: string | null): string | null;
|
|
4
|
+
export declare function parseAiNullableText(text: string | null | undefined): string | null;
|
|
5
5
|
/**
|
|
6
6
|
* Convert the output of AIs that is supposed to be a date into a numeric date (days since epoch). If the input is invalid, returns null (if allowNull is true) or the fallback value (if provided), or throws an error otherwise.
|
|
7
7
|
* @param dateOrString
|
package/ai/parser/parser.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { dateToNumericDate } from '../../utils/date-time.js';
|
|
2
|
-
import { isDate } from '../../utils/type-guards.js';
|
|
2
|
+
import { isDate, isUndefined } from '../../utils/type-guards.js';
|
|
3
3
|
/**
|
|
4
4
|
* AIs sometimes return the string "null" instead of an actual null value. This function converts such strings to null, while leaving other strings unchanged.
|
|
5
5
|
*/
|
|
6
6
|
export function parseAiNullableText(text) {
|
|
7
|
-
|
|
7
|
+
const trimmed = text?.trim();
|
|
8
|
+
if (isUndefined(trimmed) || (trimmed == 'null')) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
|
-
return
|
|
11
|
+
return trimmed;
|
|
11
12
|
}
|
|
12
13
|
export function parseAiDateToNumericDate(dateOrString, allowNull = true, fallback) {
|
|
13
14
|
if (isDate(dateOrString)) {
|
|
@@ -9,7 +9,7 @@ var DocumentManagementAiService_1;
|
|
|
9
9
|
import { and, isNull as drizzleIsNull, eq, inArray } from 'drizzle-orm';
|
|
10
10
|
import { P, match } from 'ts-pattern';
|
|
11
11
|
import { genkitGenerationOptions, injectGenkit, injectModel } from '../../../ai/genkit/index.js';
|
|
12
|
-
import { buildPrompts, jsonOutputInstructions, orderedList } from '../../../ai/prompts/index.js';
|
|
12
|
+
import { buildPrompts, formatInstructions, jsonOutputInstructions, orderedList } from '../../../ai/prompts/index.js';
|
|
13
13
|
import { inject } from '../../../injector/inject.js';
|
|
14
14
|
import { Logger } from '../../../logger/logger.js';
|
|
15
15
|
import { arrayAgg } from '../../../orm/index.js';
|
|
@@ -497,11 +497,12 @@ export function mergeInstructions(base, overrides, options = {}) {
|
|
|
497
497
|
}
|
|
498
498
|
if (isDefined(override.content)) {
|
|
499
499
|
const strategy = override.strategy ?? 'append';
|
|
500
|
+
const content = isString(override.content) ? override.content : formatInstructions(override.content);
|
|
500
501
|
if (strategy == 'replace') {
|
|
501
|
-
result =
|
|
502
|
+
result = content;
|
|
502
503
|
}
|
|
503
504
|
else {
|
|
504
|
-
result = `${result}\n\n${
|
|
505
|
+
result = `${result}\n\n${content}`;
|
|
505
506
|
}
|
|
506
507
|
}
|
|
507
508
|
}
|
|
@@ -35,4 +35,12 @@ describe('AI Instruction Merging', () => {
|
|
|
35
35
|
const result = mergeInstructions(base, overrides);
|
|
36
36
|
expect(result).toContain('[ID] - [Name]');
|
|
37
37
|
});
|
|
38
|
+
test('should handle Instructions in content', () => {
|
|
39
|
+
const base = 'Base';
|
|
40
|
+
const overrides = [{ content: { Detail: 'More info' }, strategy: 'append' }];
|
|
41
|
+
const result = mergeInstructions(base, overrides);
|
|
42
|
+
expect(result).toContain('Base');
|
|
43
|
+
expect(result).toContain('# Detail');
|
|
44
|
+
expect(result).toContain('More info');
|
|
45
|
+
});
|
|
38
46
|
});
|
package/orm/sqls/sqls.js
CHANGED
|
@@ -79,7 +79,9 @@ export function exclusiveColumn(enumeration, discriminator, conditionMapping) {
|
|
|
79
79
|
}
|
|
80
80
|
const requiredColumns = toArray(value).filter((value) => isInstanceOf(value, Column));
|
|
81
81
|
const nullColumns = participatingColumns.filter((column) => !requiredColumns.includes(column));
|
|
82
|
-
const customConditions = toArray(value)
|
|
82
|
+
const customConditions = toArray(value)
|
|
83
|
+
.filter((val) => !isInstanceOf(val, Column) && (val !== true))
|
|
84
|
+
.map((condition) => isBoolean(condition) ? (condition ? SQL_TRUE : SQL_FALSE) : condition);
|
|
83
85
|
const condition = and(...requiredColumns.map((col) => sqlIsNotNull(col)), ...nullColumns.map((col) => sqlIsNull(col)), ...customConditions);
|
|
84
86
|
return [key, condition];
|
|
85
87
|
});
|