@tstdl/base 0.93.164 → 0.93.166

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.
@@ -5,7 +5,7 @@ import { distinct, shuffle } from '../../utils/array/index.js';
5
5
  import { isInstanceOf, isNullOrUndefined } from '../../utils/type-guards.js';
6
6
  import { millisecondsPerMinute, millisecondsPerSecond } from '../../utils/units.js';
7
7
  const pluginKey = 'vertexai-multi-location';
8
- const geminiModelReference = vertexAI.model('gemini-2.5-flash');
8
+ const geminiModelReference = vertexAI.model('gemini-');
9
9
  const defaultTokenLimitThreshold = 131_072;
10
10
  export function vertexAiMultiLocation(options) {
11
11
  if (options.locations.length == 0) {
@@ -404,9 +404,7 @@ let AuthenticationClientService = class AuthenticationClientService {
404
404
  timer(Math.max(10, delayMs)),
405
405
  from(this.disposeSignal),
406
406
  this.token$.pipe(filter((t) => t?.exp !== referenceExp)),
407
- this.forceRefreshRequested$.pipe(filter(Boolean),
408
- // Skip the current value if already true to prevent infinite tight loops
409
- skip(this.forceRefreshRequested() ? 1 : 0)),
407
+ this.forceRefreshRequested$.pipe(filter(Boolean), skip(1)),
410
408
  ]), { defaultValue: undefined });
411
409
  while (this.disposeSignal.isUnset) {
412
410
  const token = this.token();
@@ -430,10 +428,10 @@ let AuthenticationClientService = class AuthenticationClientService {
430
428
  const currentNow = this.estimatedServerTimestampSeconds();
431
429
  const currentBuffer = calculateRefreshBufferSeconds(currentToken);
432
430
  const stillNeedsRefresh = this.forceRefreshRequested() || (currentNow >= currentToken.exp - currentBuffer);
431
+ this.forceRefreshRequested.set(false);
433
432
  if (stillNeedsRefresh) {
434
433
  await this.refresh();
435
434
  }
436
- this.forceRefreshRequested.set(false);
437
435
  });
438
436
  // If lock is held by another instance/tab, wait briefly for it to finish (passive sync)
439
437
  if (!lockResult.success) {
@@ -447,7 +445,10 @@ let AuthenticationClientService = class AuthenticationClientService {
447
445
  }
448
446
  // 3. Calculate delay and sleep until the next scheduled refresh window
449
447
  const timeUntilRefreshMs = (token.exp - this.estimatedServerTimestampSeconds() - buffer) * millisecondsPerSecond;
450
- const delay = clamp(timeUntilRefreshMs, minRefreshDelay, maxRefreshDelay);
448
+ let delay = clamp(timeUntilRefreshMs, minRefreshDelay, maxRefreshDelay);
449
+ if (Number.isNaN(delay)) {
450
+ delay = minRefreshDelay;
451
+ }
451
452
  await waitForNextAction(delay, token.exp);
452
453
  }
453
454
  catch (error) {
@@ -471,6 +472,9 @@ let AuthenticationClientService = class AuthenticationClientService {
471
472
  async syncClock() {
472
473
  try {
473
474
  const serverTimestamp = await this.client.timestamp();
475
+ if (Number.isNaN(serverTimestamp)) {
476
+ throw new Error('Server timestamp is NaN');
477
+ }
474
478
  this.clockOffset = serverTimestamp - currentTimestampSeconds();
475
479
  }
476
480
  catch (error) {
@@ -538,5 +542,6 @@ export { AuthenticationClientService };
538
542
  function calculateRefreshBufferSeconds(token) {
539
543
  const iat = token.iat ?? (token.exp - secondsPerHour);
540
544
  const lifetime = token.exp - iat;
541
- return (lifetime * 0.1) + 5;
545
+ const buffer = (lifetime * 0.1) + 5;
546
+ return Number.isNaN(buffer) ? 5 : buffer;
542
547
  }
@@ -126,10 +126,10 @@ const assignRequestSystemInstructions = {
126
126
  const assignRequestUserInstructions = { Task: 'Evaluate the document against the list of open requests and find the best match following the system instructions.' };
127
127
  let DocumentManagementAiService = DocumentManagementAiService_1 = class DocumentManagementAiService {
128
128
  #genkit = injectGenkit();
129
- #contentExtractionModel = injectModel('gemini-2.5-flash-lite').withConfig({ temperature: 0.1, topP: 0.75, topK: 8 });
130
- #classifyModel = injectModel('gemini-2.5-flash').withConfig({ temperature: 0.1, topP: 0.75, topK: 8, thinkingConfig: { thinkingBudget: 0 } });
131
- #dataExtractionModel = injectModel('gemini-2.5-flash').withConfig({ temperature: 0.1, topP: 0.75, topK: 8, thinkingConfig: { thinkingBudget: 0 } });
132
- #assignModel = injectModel('gemini-2.5-flash').withConfig({ temperature: 0.1, topP: 0.75, topK: 8, thinkingConfig: { thinkingBudget: 0 } });
129
+ #contentExtractionModel = injectModel('gemini-3.1-flash-lite-preview').withConfig({ thinkingConfig: { thinkingLevel: 'LOW' } });
130
+ #classifyModel = injectModel('gemini-3.1-flash-lite-preview').withConfig({ thinkingConfig: { thinkingLevel: 'LOW' } });
131
+ #dataExtractionModel = injectModel('gemini-3.1-flash-lite-preview').withConfig({ thinkingConfig: { thinkingLevel: 'LOW' } });
132
+ #assignModel = injectModel('gemini-3.1-flash-lite-preview').withConfig({ thinkingConfig: { thinkingLevel: 'LOW' } });
133
133
  #documentCollectionService = inject(DocumentCollectionService);
134
134
  #documentTagService = inject(DocumentTagService);
135
135
  #documentCategoryTypeService = inject(DocumentCategoryTypeService);
@@ -12,7 +12,7 @@ const systemPromptBase = {
12
12
  };
13
13
  export class AiValidationExecutor extends DocumentValidationExecutor {
14
14
  genkit = injectGenkit();
15
- baseModel = injectModel('gemini-2.5-flash');
15
+ baseModel = injectModel('gemini-3.1-flash-lite-preview').withConfig({ thinkingConfig: { thinkingLevel: 'LOW' } });
16
16
  aiProvider = inject(DocumentManagementAiProviderService, undefined, { optional: true });
17
17
  getAiConfiguration(_context) {
18
18
  return {};
@@ -16,7 +16,7 @@ let ExampleAiProviderService = class ExampleAiProviderService extends DocumentMa
16
16
  return {
17
17
  defaults: {
18
18
  language: 'German', // Steer all AI outputs to German
19
- model: injectModel('gemini-2.5-flash'),
19
+ model: injectModel('gemini-3.1-flash-lite-preview').withConfig({ thinkingConfig: { thinkingLevel: 'LOW' } }),
20
20
  prompt: {
21
21
  systemAddition: 'Additional global instructions for all AI steps.',
22
22
  },
@@ -32,7 +32,7 @@ let ExampleAiProviderService = class ExampleAiProviderService extends DocumentMa
32
32
  getClassificationConfiguration() {
33
33
  return {
34
34
  // Use a faster/cheaper model for classification
35
- model: injectModel('gemini-2.5-flash-lite'),
35
+ model: injectModel('gemini-3.1-flash-lite-preview').withConfig({ thinkingConfig: { thinkingLevel: 'LOW' } }),
36
36
  prompt: {
37
37
  systemAddition: 'For classification, focus strictly on the layout.',
38
38
  },
@@ -1,6 +1,6 @@
1
1
  import type { BuildColumns, NotNull } from 'drizzle-orm';
2
2
  import type { ExtraConfigColumn, PgColumn, PgColumnBuilder, PgTableWithColumns } from 'drizzle-orm/pg-core';
3
- import type { CamelCase, ConditionalPick, SnakeCase } from 'type-fest';
3
+ import type { CamelCase, ConditionalKeys, SnakeCase } from 'type-fest';
4
4
  import type { JsonPath } from '../../json-path/json-path.js';
5
5
  import type { Record } from '../../schema/index.js';
6
6
  import type { Tagged, UnionToIntersection } from '../../types/index.js';
@@ -47,9 +47,9 @@ export type PgTableFromType<T extends EntityType = EntityType, S extends string
47
47
  }[keyof EmbeddedProperties<InstanceType<T>>]>, 'pg'>;
48
48
  dialect: 'pg';
49
49
  }>;
50
- export type EmbeddedProperties<T> = ConditionalPick<T, Tagged<unknown, EmbeddedConfigTag, {
50
+ export type EmbeddedProperties<T> = Pick<T, ConditionalKeys<T, Tagged<unknown, EmbeddedConfigTag, {
51
51
  prefix: any;
52
- }>>;
52
+ }>>>;
53
53
  export type EmbeddedColumns<T, Prefix extends string> = {
54
54
  [P in keyof T as CamelCase<`${Prefix}${Extract<P, string>}`>]: Column<CamelCase<`${Prefix}${Extract<P, string>}`>, T[P]>;
55
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.164",
3
+ "version": "0.93.166",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -149,11 +149,11 @@
149
149
  "reflect-metadata": "^0.2",
150
150
  "rxjs": "^7.8",
151
151
  "ts-pattern": "^5.9",
152
- "type-fest": "^5.4"
152
+ "type-fest": "^5.5"
153
153
  },
154
154
  "peerDependencies": {
155
- "@aws-sdk/client-s3": "^3.1010",
156
- "@aws-sdk/s3-request-presigner": "^3.1010",
155
+ "@aws-sdk/client-s3": "^3.1012",
156
+ "@aws-sdk/s3-request-presigner": "^3.1012",
157
157
  "@genkit-ai/google-genai": "^1.30",
158
158
  "@google-cloud/storage": "^7.19",
159
159
  "@toon-format/toon": "^2.1.0",
@@ -199,7 +199,7 @@
199
199
  "globals": "17.4",
200
200
  "tsc-alias": "1.8",
201
201
  "typedoc-github-wiki-theme": "2.1",
202
- "typedoc-plugin-markdown": "4.10",
202
+ "typedoc-plugin-markdown": "4.11",
203
203
  "typedoc-plugin-missing-exports": "4.1",
204
204
  "typescript": "5.9",
205
205
  "typescript-eslint": "8.57",