@tstdl/base 0.93.32 → 0.93.34
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/ai.service.js +3 -3
- package/ai/types.d.ts +4 -0
- package/orm/decorators.js +1 -1
- package/orm/server/repository.js +4 -1
- package/orm/server/transactional.d.ts +1 -1
- package/orm/sqls.d.ts +2 -0
- package/orm/sqls.js +2 -0
- package/package.json +2 -2
- package/test1.js +43 -30
package/ai/ai.service.js
CHANGED
|
@@ -205,7 +205,7 @@ let AiService = AiService_1 = class AiService {
|
|
|
205
205
|
};
|
|
206
206
|
const model = this.mapModel(request.model);
|
|
207
207
|
const maxModelTokens = await this.getModelOutputTokenLimit(model);
|
|
208
|
-
const maxTotalOutputTokens = request.generationOptions?.maxOutputTokens ?? maxModelTokens;
|
|
208
|
+
const maxTotalOutputTokens = request.generationOptions?.maxOutputTokens ?? maxModelTokens ?? 8192;
|
|
209
209
|
const inputContent = this.convertContents(request.contents);
|
|
210
210
|
let iterations = 0;
|
|
211
211
|
let totalPromptTokens = 0;
|
|
@@ -221,7 +221,7 @@ let AiService = AiService_1 = class AiService {
|
|
|
221
221
|
model,
|
|
222
222
|
config: {
|
|
223
223
|
...config,
|
|
224
|
-
maxOutputTokens: Math.min(
|
|
224
|
+
maxOutputTokens: Math.min(1000000, maxTotalOutputTokens - totalOutputTokens),
|
|
225
225
|
},
|
|
226
226
|
contents: inputContent,
|
|
227
227
|
});
|
|
@@ -356,7 +356,7 @@ let AiService = AiService_1 = class AiService {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
if (isUndefined(modelInfo.outputTokenLimit)) {
|
|
359
|
-
|
|
359
|
+
return null;
|
|
360
360
|
}
|
|
361
361
|
return modelInfo.outputTokenLimit;
|
|
362
362
|
}
|
package/ai/types.d.ts
CHANGED
|
@@ -137,6 +137,10 @@ export type GenerationOptions = {
|
|
|
137
137
|
* The maximum number of tokens the model is allowed to generate for its thinking phase.
|
|
138
138
|
*/
|
|
139
139
|
thinkingBudget?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Whether to include the model's internal thoughts in the response.
|
|
142
|
+
*/
|
|
143
|
+
includeThoughts?: boolean;
|
|
140
144
|
};
|
|
141
145
|
/**
|
|
142
146
|
* A request to generate content from the AI model.
|
package/orm/decorators.js
CHANGED
|
@@ -177,7 +177,7 @@ export function ParadeIndex(options) {
|
|
|
177
177
|
return createDecorator({ class: true, property: true }, (data, metadata) => {
|
|
178
178
|
match(metadata.metadataType)
|
|
179
179
|
.with('type', () => {
|
|
180
|
-
const existing =
|
|
180
|
+
const existing = metadata.data.tryGet('orm')?.paradeIndex;
|
|
181
181
|
const merged = merge(existing, options);
|
|
182
182
|
return createTableDecorator({ paradeIndex: merged })(data.constructor);
|
|
183
183
|
})
|
package/orm/server/repository.js
CHANGED
|
@@ -54,6 +54,9 @@ let EntityRepository = class EntityRepository extends Transactional {
|
|
|
54
54
|
#tableWithMetadata = this.#table;
|
|
55
55
|
#columnDefinitions = this.#context.columnDefinitions ?? getColumnDefinitions(this.#table);
|
|
56
56
|
#columnDefinitionsMap = this.#context.columnDefinitionsMap ?? getColumnDefinitionsMap(this.#table);
|
|
57
|
+
#upsertManyExcludedMapping = fromEntries(this.#columnDefinitions
|
|
58
|
+
.filter((column) => column.name != this.#table.id.name)
|
|
59
|
+
.map((column) => [column.name, sql `excluded.${sql.identifier(this.getColumn(column).name)}`]));
|
|
57
60
|
hasMetadata = typeExtends(this.type, Entity);
|
|
58
61
|
/**
|
|
59
62
|
* Gets the Drizzle table definition for the entity type.
|
|
@@ -593,7 +596,7 @@ let EntityRepository = class EntityRepository extends Transactional {
|
|
|
593
596
|
const mappedUpdate = isDefined(update)
|
|
594
597
|
? await this.mapUpdate(update)
|
|
595
598
|
: {
|
|
596
|
-
...
|
|
599
|
+
...this.#upsertManyExcludedMapping,
|
|
597
600
|
...this._getMetadataUpdate(update),
|
|
598
601
|
};
|
|
599
602
|
const rows = await this.session
|
|
@@ -22,7 +22,7 @@ declare const getCurrentTransactionalContext: {
|
|
|
22
22
|
export { getCurrentTransactionalContext, isInTransactionalContext, runInTransactionalContext };
|
|
23
23
|
export declare abstract class Transactional<ContextData = unknown> {
|
|
24
24
|
#private;
|
|
25
|
-
readonly session:
|
|
25
|
+
readonly session: Database | PgTransaction;
|
|
26
26
|
readonly isInTransaction: boolean;
|
|
27
27
|
constructor();
|
|
28
28
|
/**
|
package/orm/sqls.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { Uuid } from './types.js';
|
|
|
6
6
|
export declare const TRANSACTION_TIMESTAMP: SQL<Date>;
|
|
7
7
|
/** Drizzle SQL helper for generating a random UUID (v4). Returns a Uuid string. */
|
|
8
8
|
export declare const RANDOM_UUID_V4: SQL<Uuid>;
|
|
9
|
+
/** Drizzle SQL helper for generating a random UUID (v7). Returns a Uuid string. */
|
|
10
|
+
export declare const RANDOM_UUID_V7: SQL<Uuid>;
|
|
9
11
|
/** Represents valid units for PostgreSQL interval values. */
|
|
10
12
|
export type IntervalUnit = 'millennium' | 'millenniums' | 'millennia' | 'century' | 'centuries' | 'decade' | 'decades' | 'year' | 'years' | 'day' | 'days' | 'hour' | 'hours' | 'minute' | 'minutes' | 'second' | 'seconds' | 'millisecond' | 'milliseconds' | 'microsecond' | 'microseconds';
|
|
11
13
|
export type TsHeadlineOptions = {
|
package/orm/sqls.js
CHANGED
|
@@ -10,6 +10,8 @@ import { sql, Table } from 'drizzle-orm';
|
|
|
10
10
|
export const TRANSACTION_TIMESTAMP = sql `transaction_timestamp()`;
|
|
11
11
|
/** Drizzle SQL helper for generating a random UUID (v4). Returns a Uuid string. */
|
|
12
12
|
export const RANDOM_UUID_V4 = sql `gen_random_uuid()`;
|
|
13
|
+
/** Drizzle SQL helper for generating a random UUID (v7). Returns a Uuid string. */
|
|
14
|
+
export const RANDOM_UUID_V7 = sql `uuidv7()`;
|
|
13
15
|
export function array(values) {
|
|
14
16
|
const valueString = sql.join(values, sql.raw(', '));
|
|
15
17
|
return sql `ARRAY[${valueString}]`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.93.
|
|
3
|
+
"version": "0.93.34",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"@zxcvbn-ts/language-de": "^3.0",
|
|
144
144
|
"@zxcvbn-ts/language-en": "^3.0",
|
|
145
145
|
"drizzle-orm": "^0.44",
|
|
146
|
-
"file-type": "^21.
|
|
146
|
+
"file-type": "^21.1",
|
|
147
147
|
"handlebars": "^4.7",
|
|
148
148
|
"minio": "^8.0",
|
|
149
149
|
"mjml": "^4.16",
|
package/test1.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './polyfills.js';
|
|
2
|
+
import { AiService } from './ai/ai.service.js';
|
|
3
|
+
import { configureAiService } from './ai/module.js';
|
|
2
4
|
import { Application, provideInitializer, provideModule, provideSignalHandler } from './application/index.js';
|
|
3
5
|
import { migrateAuditSchema } from './audit/index.js';
|
|
4
6
|
import { configureAuthenticationServer } from './authentication/server/module.js';
|
|
@@ -23,51 +25,62 @@ const config = {
|
|
|
23
25
|
};
|
|
24
26
|
async function bootstrap() {
|
|
25
27
|
const injector = inject(Injector);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
connection: {
|
|
31
|
-
host: config.database.host,
|
|
32
|
-
port: config.database.port,
|
|
33
|
-
user: config.database.user,
|
|
34
|
-
password: config.database.pass,
|
|
35
|
-
database: config.database.database,
|
|
28
|
+
configureAiService({
|
|
29
|
+
vertex: {
|
|
30
|
+
project: '922353391551', // insolytics-application
|
|
31
|
+
location: 'europe-west4', // netherlands
|
|
36
32
|
},
|
|
33
|
+
keyFile: '/home/patrick/.secret-files/insolytics-application-service-key.json',
|
|
34
|
+
});
|
|
35
|
+
/*
|
|
36
|
+
configureOrm({
|
|
37
|
+
repositoryConfig: {
|
|
38
|
+
schema: 'test',
|
|
39
|
+
},
|
|
40
|
+
connection: {
|
|
41
|
+
host: config.database.host,
|
|
42
|
+
port: config.database.port,
|
|
43
|
+
user: config.database.user,
|
|
44
|
+
password: config.database.pass,
|
|
45
|
+
database: config.database.database,
|
|
46
|
+
},
|
|
37
47
|
});
|
|
48
|
+
|
|
38
49
|
configureAuthenticationServer({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
serviceOptions: {
|
|
51
|
+
secret: '6fze56uz5e6ufrtzufrtu',
|
|
52
|
+
},
|
|
42
53
|
});
|
|
54
|
+
|
|
43
55
|
configurePostgresLock();
|
|
44
56
|
configurePostgresQueue();
|
|
45
57
|
configurePostgresKeyValueStore();
|
|
58
|
+
|
|
46
59
|
await runInInjectionContext(injector, migratePostgresKeyValueStoreSchema);
|
|
47
60
|
await runInInjectionContext(injector, migratePostgresLockSchema);
|
|
48
61
|
await runInInjectionContext(injector, migratePostgresQueueSchema);
|
|
49
62
|
await runInInjectionContext(injector, migrateAuditSchema);
|
|
50
63
|
await runInInjectionContext(injector, migrateTestSchema);
|
|
64
|
+
*/
|
|
51
65
|
}
|
|
52
66
|
async function main(_cancellationSignal) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
67
|
+
const aiService = inject(AiService);
|
|
68
|
+
const aiResult = await aiService.generate({
|
|
69
|
+
generationOptions: {
|
|
70
|
+
includeThoughts: true,
|
|
71
|
+
},
|
|
72
|
+
model: 'gemini-2.5-flash-lite',
|
|
73
|
+
contents: [{
|
|
74
|
+
role: 'user',
|
|
75
|
+
parts: [
|
|
76
|
+
{ text: 'asd' },
|
|
77
|
+
],
|
|
78
|
+
}],
|
|
66
79
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
console.log('AI Result:', aiResult);
|
|
81
|
+
console.log(aiResult.content);
|
|
82
|
+
if (1 + 1 == 2)
|
|
83
|
+
process.exit(0);
|
|
71
84
|
}
|
|
72
85
|
Application.run('Test', [
|
|
73
86
|
provideInitializer(bootstrap),
|