@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.
@@ -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
@@ -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
- if (text == 'null') {
7
+ const trimmed = text?.trim();
8
+ if (isUndefined(trimmed) || (trimmed == 'null')) {
8
9
  return null;
9
10
  }
10
- return text;
11
+ return trimmed;
11
12
  }
12
13
  export function parseAiDateToNumericDate(dateOrString, allowNull = true, fallback) {
13
14
  if (isDate(dateOrString)) {
@@ -11,7 +11,7 @@ export type InstructionOverride = string | {
11
11
  /**
12
12
  * Advanced way: Provide full custom instructions.
13
13
  */
14
- content?: string;
14
+ content?: string | Instructions;
15
15
  /**
16
16
  * Strategy for 'content'. Defaults to 'append'.
17
17
  */
@@ -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 = override.content;
502
+ result = content;
502
503
  }
503
504
  else {
504
- result = `${result}\n\n${override.content}`;
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).filter((val) => !isInstanceOf(val, Column)).map((condition) => isBoolean(condition) ? (condition ? SQL_TRUE : SQL_FALSE) : condition);
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.130",
3
+ "version": "0.93.132",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"