@tstdl/base 0.92.16 → 0.92.17
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 +4 -4
- package/authentication/server/authentication.service.d.ts +2 -2
- package/file/mime-type.js +8 -22
- package/package.json +1 -1
- package/pdf/index.d.ts +1 -0
- package/pdf/index.js +1 -0
- package/pdf/utils.d.ts +1 -0
- package/pdf/utils.js +11 -0
- package/process/spawn.d.ts +5 -3
- package/process/spawn.js +7 -7
- package/rpc/rpc.d.ts +1 -1
- package/signals/operators/derive-async.js +12 -4
- package/utils/type-guards.d.ts +1 -13
package/ai/ai.service.js
CHANGED
|
@@ -46,7 +46,7 @@ let AiService = class AiService {
|
|
|
46
46
|
model: options?.model,
|
|
47
47
|
generationOptions: {
|
|
48
48
|
maxOutputTokens: 1048,
|
|
49
|
-
temperature: 0.
|
|
49
|
+
temperature: 0.5,
|
|
50
50
|
...options
|
|
51
51
|
},
|
|
52
52
|
generationSchema,
|
|
@@ -71,7 +71,7 @@ let AiService = class AiService {
|
|
|
71
71
|
const generation = await this.generate({
|
|
72
72
|
model: options?.model,
|
|
73
73
|
generationOptions: {
|
|
74
|
-
temperature: 0.
|
|
74
|
+
temperature: 0.5,
|
|
75
75
|
...options
|
|
76
76
|
},
|
|
77
77
|
generationSchema: schema,
|
|
@@ -107,7 +107,7 @@ Carefully read and analyze the provided document. Identify relevant information
|
|
|
107
107
|
const generation = await this.generate({
|
|
108
108
|
generationOptions: {
|
|
109
109
|
maxOutputTokens: 2048,
|
|
110
|
-
temperature: 0.
|
|
110
|
+
temperature: 0.5,
|
|
111
111
|
...options
|
|
112
112
|
},
|
|
113
113
|
generationSchema: schema,
|
|
@@ -139,7 +139,7 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
|
|
|
139
139
|
const generation = await this.generate({
|
|
140
140
|
model: options.model,
|
|
141
141
|
generationOptions: {
|
|
142
|
-
temperature: 0.
|
|
142
|
+
temperature: 0.5,
|
|
143
143
|
...options
|
|
144
144
|
},
|
|
145
145
|
systemInstruction: options.systemInstruction,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AfterResolve, afterResolve } from '../../injector/index.js';
|
|
1
|
+
import { type AfterResolve, afterResolve } from '../../injector/index.js';
|
|
2
2
|
import type { BinaryData, Record } from '../../types.js';
|
|
3
3
|
import type { RefreshToken, SecretCheckResult, SecretResetToken, Token } from '../models/index.js';
|
|
4
|
-
import { SecretTestResult } from './authentication-secret-requirements.validator.js';
|
|
4
|
+
import { type SecretTestResult } from './authentication-secret-requirements.validator.js';
|
|
5
5
|
export type CreateTokenData<AdditionalTokenPayload extends Record> = {
|
|
6
6
|
tokenVersion?: number;
|
|
7
7
|
jwtId?: string;
|
package/file/mime-type.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { readTextStream } from '../utils/stream/stream-reader.js';
|
|
4
|
-
import { isReadableStream, isString, isUint8Array } from '../utils/type-guards.js';
|
|
1
|
+
import { spawnCommand } from '../process/spawn.js';
|
|
2
|
+
import { isDefined, isString } from '../utils/type-guards.js';
|
|
5
3
|
import { mimeTypesMap } from './mime-types.js';
|
|
6
4
|
export async function getMimeType(file) {
|
|
7
5
|
const path = isString(file) ? file : '-';
|
|
@@ -12,22 +10,10 @@ export function getMimeTypeExtensions(mimeType) {
|
|
|
12
10
|
return mimeTypesMap.get(mimeType) ?? [];
|
|
13
11
|
}
|
|
14
12
|
async function spawnFileCommand(args, file) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
await file.pipeTo(stdin);
|
|
22
|
-
}
|
|
23
|
-
else if (isUint8Array(file)) {
|
|
24
|
-
const writer = stdin.getWriter();
|
|
25
|
-
try {
|
|
26
|
-
await writer.write(file);
|
|
27
|
-
await writer.close();
|
|
28
|
-
}
|
|
29
|
-
catch { /* File command closes stream as soon as it has the required data */ }
|
|
30
|
-
}
|
|
31
|
-
const output = await readTextStream(stdout);
|
|
32
|
-
return output.trim();
|
|
13
|
+
const process = await spawnCommand('file', args, { stdinPipeOptions: { preventCancel: true } });
|
|
14
|
+
const [stdout] = await Promise.all([
|
|
15
|
+
process.readOutput(),
|
|
16
|
+
isDefined(file) ? process.write(file) : undefined
|
|
17
|
+
]);
|
|
18
|
+
return stdout.trim();
|
|
33
19
|
}
|
package/package.json
CHANGED
package/pdf/index.d.ts
CHANGED
package/pdf/index.js
CHANGED
package/pdf/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPdfPageCount(file: string): Promise<number>;
|
package/pdf/utils.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { spawnCommand } from '../process/spawn.js';
|
|
2
|
+
export async function getPdfPageCount(file) {
|
|
3
|
+
const process = await spawnCommand('qpdf', ['--show-npages', file]);
|
|
4
|
+
const { code } = await process.wait();
|
|
5
|
+
if (code != 0) {
|
|
6
|
+
const errorOutput = await process.readError();
|
|
7
|
+
throw new Error(errorOutput.trim());
|
|
8
|
+
}
|
|
9
|
+
const output = await process.readOutput();
|
|
10
|
+
return Number(output);
|
|
11
|
+
}
|
package/process/spawn.d.ts
CHANGED
|
@@ -5,11 +5,13 @@ export type SpawnCommandResult = TransformStream<Uint8Array, Uint8Array> & {
|
|
|
5
5
|
write(chunk: ReadableStream<Uint8Array> | Uint8Array | string): Promise<void>;
|
|
6
6
|
readOutputBytes(): Promise<Uint8Array>;
|
|
7
7
|
readOutput(): Promise<string>;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
readErrorBytes(): Promise<Uint8Array>;
|
|
9
|
+
readError(): Promise<string>;
|
|
10
10
|
wait(): Promise<{
|
|
11
11
|
code: number | null;
|
|
12
12
|
signal: string | null;
|
|
13
13
|
}>;
|
|
14
14
|
};
|
|
15
|
-
export declare function spawnCommand(command: string, args
|
|
15
|
+
export declare function spawnCommand(command: string, args?: string[], options?: {
|
|
16
|
+
stdinPipeOptions?: StreamPipeOptions;
|
|
17
|
+
}): Promise<SpawnCommandResult>;
|
package/process/spawn.js
CHANGED
|
@@ -3,7 +3,7 @@ import { decodeTextStream, encodeUtf8Stream } from '../utils/encoding.js';
|
|
|
3
3
|
import { readBinaryStream, readTextStream } from '../utils/stream/stream-reader.js';
|
|
4
4
|
import { toReadableStream } from '../utils/stream/to-readable-stream.js';
|
|
5
5
|
import { isReadableStream, isString, isUint8Array } from '../utils/type-guards.js';
|
|
6
|
-
export async function spawnCommand(command, args) {
|
|
6
|
+
export async function spawnCommand(command, args, options) {
|
|
7
7
|
const { spawn } = await dynamicImport('node:child_process');
|
|
8
8
|
const { Readable, Writable } = await dynamicImport('node:stream');
|
|
9
9
|
const process = spawn(command, args, { stdio: 'pipe' });
|
|
@@ -16,13 +16,13 @@ export async function spawnCommand(command, args) {
|
|
|
16
16
|
const stderr = Readable.toWeb(process.stderr);
|
|
17
17
|
async function write(data) {
|
|
18
18
|
if (isReadableStream(data)) {
|
|
19
|
-
await data.pipeTo(writable);
|
|
19
|
+
await data.pipeTo(writable, options?.stdinPipeOptions);
|
|
20
20
|
}
|
|
21
21
|
else if (isUint8Array(data)) {
|
|
22
|
-
await toReadableStream(data).pipeTo(writable);
|
|
22
|
+
await toReadableStream(data).pipeTo(writable, options?.stdinPipeOptions);
|
|
23
23
|
}
|
|
24
24
|
else if (isString(data)) {
|
|
25
|
-
await toReadableStream(data).pipeThrough(encodeUtf8Stream()).pipeTo(writable);
|
|
25
|
+
await toReadableStream(data).pipeThrough(encodeUtf8Stream()).pipeTo(writable, options?.stdinPipeOptions);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
async function readOutputBytes() {
|
|
@@ -46,10 +46,10 @@ export async function spawnCommand(command, args) {
|
|
|
46
46
|
write,
|
|
47
47
|
readOutputBytes,
|
|
48
48
|
readOutput,
|
|
49
|
-
readErrBytes,
|
|
50
|
-
readErr,
|
|
49
|
+
readErrorBytes: readErrBytes,
|
|
50
|
+
readError: readErr,
|
|
51
51
|
async wait() {
|
|
52
52
|
return signalPromise;
|
|
53
|
-
}
|
|
53
|
+
}
|
|
54
54
|
};
|
|
55
55
|
}
|
package/rpc/rpc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SerializationOptions } from '../serializer/index.js';
|
|
2
2
|
import type { RpcRemote, RpcRemoteInput } from './model.js';
|
|
3
3
|
import type { RpcAdapter } from './rpc.adapter.js';
|
|
4
4
|
import type { RpcEndpoint } from './rpc.endpoint.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Subject, concatAll, exhaustAll, isObservable, mergeAll, of, switchAll, takeUntil } from 'rxjs';
|
|
1
|
+
import { Subject, concatAll, exhaustAll, from, isObservable, mergeAll, of, switchAll, takeUntil } from 'rxjs';
|
|
2
2
|
import { registerFinalization } from '../../memory/finalization.js';
|
|
3
3
|
import { isPromise } from '../../utils/type-guards.js';
|
|
4
4
|
import { computed, effect, toSignal, untracked } from '../api.js';
|
|
@@ -9,15 +9,23 @@ const operatorMap = {
|
|
|
9
9
|
switch: switchAll,
|
|
10
10
|
};
|
|
11
11
|
export function deriveAsync(source, options) {
|
|
12
|
-
const outerSource = computed(
|
|
12
|
+
const outerSource = computed(() => {
|
|
13
|
+
const rawSource = source();
|
|
14
|
+
if (isPromise(rawSource)) {
|
|
15
|
+
return from(rawSource);
|
|
16
|
+
}
|
|
17
|
+
if (isObservable(rawSource)) {
|
|
18
|
+
return rawSource;
|
|
19
|
+
}
|
|
20
|
+
return of(rawSource);
|
|
21
|
+
});
|
|
13
22
|
const source$ = new Subject();
|
|
14
23
|
const destroy$ = new Subject();
|
|
15
24
|
const operator = operatorMap[options?.behavior ?? 'switch'];
|
|
16
25
|
const valueSource$ = source$.pipe(operator(), takeUntil(destroy$));
|
|
17
26
|
const result = toSignal(valueSource$, options);
|
|
18
27
|
const effectRef = effect(() => {
|
|
19
|
-
const
|
|
20
|
-
const observableInput = (isPromise(rawSource) || isObservable(rawSource)) ? rawSource : of(rawSource);
|
|
28
|
+
const observableInput = outerSource();
|
|
21
29
|
untracked(() => source$.next(observableInput));
|
|
22
30
|
});
|
|
23
31
|
registerFinalization(result, () => {
|
package/utils/type-guards.d.ts
CHANGED
|
@@ -6,19 +6,7 @@ export type AssertFunction<T> = <U extends T = T>(value: any, message?: Assertio
|
|
|
6
6
|
export type AssertNotFunction<T> = <V>(value: V, message?: AssertionMessage) => asserts value is Exclude<V, T>;
|
|
7
7
|
export type AssertPassFunction<T> = <U extends T = T>(value: any, message?: AssertionMessage) => U;
|
|
8
8
|
export type AssertNotPassFunction<T> = <V>(value: V, message?: AssertionMessage) => Exclude<V, T>;
|
|
9
|
-
export type GuardFunctions<N extends string, T> = {
|
|
10
|
-
[P in `is${PascalCase<N>}`]: IsFunction<T>;
|
|
11
|
-
} & {
|
|
12
|
-
[P in `isNot${PascalCase<N>}`]: IsNotFunction<T>;
|
|
13
|
-
} & {
|
|
14
|
-
[P in `assert${PascalCase<N>}`]: AssertFunction<T>;
|
|
15
|
-
} & {
|
|
16
|
-
[P in `assertNot${PascalCase<N>}`]: AssertNotFunction<T>;
|
|
17
|
-
} & {
|
|
18
|
-
[P in `assert${PascalCase<N>}Pass`]: AssertPassFunction<T>;
|
|
19
|
-
} & {
|
|
20
|
-
[P in `assertNot${PascalCase<N>}Pass`]: AssertNotPassFunction<T>;
|
|
21
|
-
};
|
|
9
|
+
export type GuardFunctions<N extends string, T> = Record<`is${PascalCase<N>}`, IsFunction<T>> & Record<`isNot${PascalCase<N>}`, IsNotFunction<T>> & Record<`assert${PascalCase<N>}`, AssertFunction<T>> & Record<`assertNot${PascalCase<N>}`, AssertNotFunction<T>> & Record<`assert${PascalCase<N>}Pass`, AssertPassFunction<T>> & Record<`assertNot${PascalCase<N>}Pass`, AssertNotPassFunction<T>>;
|
|
22
10
|
export declare function assert(condition: boolean, message?: AssertionMessage): asserts condition;
|
|
23
11
|
export declare function assertNot(condition: boolean, message?: AssertionMessage): asserts condition;
|
|
24
12
|
export declare function createGuards<N extends string, T>(name: N, testFn: (value: any) => value is T): GuardFunctions<N, T>;
|