libmodulor 0.21.0 → 0.23.0
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/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/dist/esm/apps/Helper/src/lib/project.js +7 -7
- package/dist/esm/apps/Helper/src/ucds/CreateProjectUCD.d.ts +1 -0
- package/dist/esm/apps/Helper/src/ucds/CreateProjectUCD.js +20 -13
- package/dist/esm/dt/DataType.d.ts +2 -1
- package/dist/esm/dt/DataTypes.js +1 -0
- package/dist/esm/dt/final/TTransportType.d.ts +8 -0
- package/dist/esm/dt/final/TTransportType.js +16 -0
- package/dist/esm/dt/index.d.ts +1 -0
- package/dist/esm/dt/index.js +1 -0
- package/dist/esm/error/funcs.d.ts +2 -0
- package/dist/esm/error/funcs.js +19 -0
- package/dist/esm/error/index.d.ts +1 -0
- package/dist/esm/error/index.js +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.react.d.ts +1 -1
- package/dist/esm/index.react.js +1 -1
- package/dist/esm/std/HTTPAPICallExecutor.d.ts +16 -7
- package/dist/esm/std/HTTPAPICaller.d.ts +8 -1
- package/dist/esm/std/JWTManager.d.ts +16 -1
- package/dist/esm/std/LLMManager.d.ts +20 -3
- package/dist/esm/std/impl/FakeClockManager.d.ts +6 -0
- package/dist/esm/std/impl/FakeClockManager.js +19 -0
- package/dist/esm/std/impl/FakeHTTPAPICallExecutor.js +19 -18
- package/dist/esm/std/impl/FakeLLMManager.d.ts +4 -0
- package/dist/esm/std/impl/FakeLLMManager.js +40 -0
- package/dist/esm/std/impl/JoseJWTManager.d.ts +3 -2
- package/dist/esm/std/impl/JoseJWTManager.js +4 -0
- package/dist/esm/std/impl/MistralAILLMManager.js +12 -0
- package/dist/esm/std/impl/OllamaLLMManager.d.ts +7 -2
- package/dist/esm/std/impl/OllamaLLMManager.js +32 -5
- package/dist/esm/std/impl/OpenAILLMManager.js +9 -0
- package/dist/esm/std/impl/SimpleHTTPAPICaller.d.ts +7 -3
- package/dist/esm/std/impl/SimpleHTTPAPICaller.js +68 -15
- package/dist/esm/target/lib/cli/CommandExecutor.js +9 -1
- package/dist/esm/target/lib/client/consts.js +1 -0
- package/dist/esm/target/lib/react/UCPanel.d.ts +11 -10
- package/dist/esm/target/lib/react/UCPanel.js +2 -2
- package/dist/esm/target/lib/react/useUC.js +11 -1
- package/dist/esm/target/lib/server/ServerManager.d.ts +1 -0
- package/dist/esm/target/lib/server/ServerRequestHandler.d.ts +3 -2
- package/dist/esm/target/lib/server/ServerRequestHandler.js +2 -2
- package/dist/esm/target/lib/server/consts.js +1 -0
- package/dist/esm/target/lib/server-express/funcs.js +53 -1
- package/dist/esm/target/lib/server-hono/funcs.js +65 -2
- package/dist/esm/target/lib/server-node/funcs.d.ts +2 -2
- package/dist/esm/target/lib/server-node/funcs.js +11 -1
- package/dist/esm/target/lib/server-node/types.d.ts +1 -0
- package/dist/esm/target/node-express-server/NodeExpressServerManager.d.ts +2 -2
- package/dist/esm/target/node-express-server/NodeExpressServerManager.js +2 -1
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.d.ts +2 -2
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.js +2 -1
- package/dist/esm/testing/impl/newNodeAppTester.js +3 -2
- package/dist/esm/testing/workers/UCExecutor.js +39 -1
- package/dist/esm/uc/ext.d.ts +7 -1
- package/dist/esm/uc/impl/HTTPUCTransporter.d.ts +2 -2
- package/dist/esm/uc/impl/HTTPUCTransporter.js +3 -1
- package/dist/esm/uc/impl/SimpleUCManager.d.ts +3 -3
- package/dist/esm/uc/impl/SimpleUCManager.js +23 -4
- package/dist/esm/uc/lifecycle/client/SendClientMain.d.ts +1 -1
- package/dist/esm/uc/lifecycle/client/SendClientMain.js +5 -2
- package/dist/esm/uc/main.d.ts +8 -1
- package/dist/esm/uc/manager.d.ts +11 -2
- package/dist/esm/uc/output.d.ts +1 -0
- package/dist/esm/uc/output.js +10 -1
- package/dist/esm/uc/transporter.d.ts +7 -1
- package/dist/esm/utils/async/types.d.ts +2 -0
- package/dist/esm/utils/async/types.js +1 -0
- package/dist/esm/utils/http/NDJSONStreamManager.d.ts +13 -0
- package/dist/esm/utils/http/NDJSONStreamManager.js +45 -0
- package/dist/esm/utils/http/SSEStreamManager.d.ts +13 -0
- package/dist/esm/utils/http/SSEStreamManager.js +60 -0
- package/dist/esm/utils/http/nd-json.d.ts +1 -0
- package/dist/esm/utils/http/nd-json.js +2 -0
- package/dist/esm/utils/http/sse.d.ts +14 -0
- package/dist/esm/utils/http/sse.js +24 -0
- package/dist/esm/utils/http/status.d.ts +4 -0
- package/dist/esm/utils/http/status.js +9 -0
- package/dist/esm/utils/index.d.ts +6 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/streams/types.d.ts +17 -0
- package/dist/esm/utils/streams/types.js +1 -0
- package/package.json +15 -15
- package/pnpm-workspace.yaml +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v0.23.0 (2025-11-11)
|
|
4
|
+
|
|
5
|
+
See all the changes here : https://github.com/c100k/libmodulor/compare/v0.22.0...master
|
|
6
|
+
|
|
7
|
+
## v0.22.0 (2025-10-25)
|
|
8
|
+
|
|
9
|
+
**Added**
|
|
10
|
+
|
|
11
|
+
- Add `verbose` option to `CreateProject` : `pnpm libmodulor CreateProject --outPath ~/Downloads --projectName libmodulor-test --verbose`
|
|
12
|
+
- Add stream ability to `LLMManager`
|
|
13
|
+
- Introduce stream output to use cases : set `transportType: 'stream'` in `ucd.def.http` and send partial output in your `ServerMain` so your clients can start showing data before the processing is done
|
|
14
|
+
- Use stream from client to server
|
|
15
|
+
- Add `FakeClockManager` and `FakeLLMManager` to `std` : they are now centralized so they can be reused by all the apps instead of duplicating them
|
|
16
|
+
- Handle targets without fetch stream capabilities
|
|
17
|
+
- Stream responses in cli targets
|
|
18
|
+
- Add ability to abort UC execution
|
|
19
|
+
|
|
3
20
|
## v0.21.0 (2025-08-19)
|
|
4
21
|
|
|
5
22
|
**BREAKING**
|
package/README.md
CHANGED
|
@@ -81,23 +81,23 @@ export const PACKAGE_JSON = (name) => `{
|
|
|
81
81
|
"test": "tsc && vitest run --passWithNoTests"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"inversify": "^7.
|
|
84
|
+
"inversify": "^7.10.4",
|
|
85
85
|
"libmodulor": "latest",
|
|
86
86
|
"reflect-metadata": "^0.2.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@biomejs/biome": "^2.
|
|
90
|
-
"@types/node": "^
|
|
89
|
+
"@biomejs/biome": "^2.3.4",
|
|
90
|
+
"@types/node": "^24.10.0",
|
|
91
91
|
"@vitest/coverage-v8": "^3.2.4",
|
|
92
92
|
"buffer": "^6.0.3",
|
|
93
93
|
"cookie-parser": "^1.4.7",
|
|
94
94
|
"express": "^5.1.0",
|
|
95
95
|
"express-fileupload": "^1.5.2",
|
|
96
|
-
"fast-check": "^4.
|
|
96
|
+
"fast-check": "^4.3.0",
|
|
97
97
|
"helmet": "^8.1.0",
|
|
98
|
-
"jose": "^6.0
|
|
99
|
-
"typescript": "^5.9.
|
|
100
|
-
"vite": "^6.
|
|
98
|
+
"jose": "^6.1.0",
|
|
99
|
+
"typescript": "^5.9.3",
|
|
100
|
+
"vite": "^6.4.1",
|
|
101
101
|
"vitest": "^3.2.4"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -7,6 +7,7 @@ export interface CreateProjectInput extends UCInput {
|
|
|
7
7
|
pkgManagerBin: UCInputFieldValue<FileName>;
|
|
8
8
|
projectName: UCInputFieldValue<Slug>;
|
|
9
9
|
scmBin: UCInputFieldValue<FileName>;
|
|
10
|
+
verbose: UCInputFieldValue<boolean>;
|
|
10
11
|
}
|
|
11
12
|
export declare class CreateProjectClientMain implements UCMain<CreateProjectInput> {
|
|
12
13
|
private fsManager;
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from 'inversify';
|
|
14
14
|
import { APPS_ROOT_PATH, PRODUCTS_ROOT_PATH } from '../../../../convention.js';
|
|
15
|
-
import { TDirPath, TFileName, TFreeTextShort, TSlug, } from '../../../../dt/index.js';
|
|
15
|
+
import { TBoolean, TDirPath, TFileName, TFreeTextShort, TSlug, } from '../../../../dt/index.js';
|
|
16
16
|
import { IllegalArgumentError } from '../../../../error/index.js';
|
|
17
17
|
import { EverybodyUCPolicy, } from '../../../../uc/index.js';
|
|
18
18
|
import { projectFiles } from '../lib/project.js';
|
|
@@ -32,17 +32,18 @@ let CreateProjectClientMain = class CreateProjectClientMain {
|
|
|
32
32
|
const pkgManagerBin = uc.reqVal0('pkgManagerBin');
|
|
33
33
|
const projectName = uc.reqVal0('projectName');
|
|
34
34
|
const scmBin = uc.reqVal0('scmBin');
|
|
35
|
+
const verbose = uc.reqVal0('verbose');
|
|
35
36
|
await this.assertBinPresence(pkgManagerBin);
|
|
36
37
|
await this.assertBinPresence(scmBin);
|
|
37
38
|
const cwd = this.fsManager.path(outPath, projectName);
|
|
38
39
|
// TODO : Rollback the whole thing in case of failure
|
|
39
40
|
await this.createRootDir(cwd);
|
|
40
|
-
await this.initRepository(scmBin, cwd);
|
|
41
|
+
await this.initRepository(scmBin, cwd, verbose);
|
|
41
42
|
await this.createConfigFiles(projectName, cwd);
|
|
42
43
|
await this.createDirs(cwd);
|
|
43
|
-
await this.installDeps(pkgManagerBin, cwd);
|
|
44
|
-
await this.commit(scmBin, initialCommit, cwd);
|
|
45
|
-
await this.runDevCmds(pkgManagerBin, cwd);
|
|
44
|
+
await this.installDeps(pkgManagerBin, cwd, verbose);
|
|
45
|
+
await this.commit(scmBin, initialCommit, cwd, verbose);
|
|
46
|
+
await this.runDevCmds(pkgManagerBin, cwd, verbose);
|
|
46
47
|
this.logger.info('Done ! Project ready ! ✅ 🚀');
|
|
47
48
|
}
|
|
48
49
|
async assertBinPresence(bin) {
|
|
@@ -56,7 +57,7 @@ let CreateProjectClientMain = class CreateProjectClientMain {
|
|
|
56
57
|
throw new IllegalArgumentError(`'${bin}' seems missing. Is it installed on your machine ?`);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
async commit(scmBin, initialCommit, cwd) {
|
|
60
|
+
async commit(scmBin, initialCommit, cwd, verbose) {
|
|
60
61
|
this.logger.info('Committing');
|
|
61
62
|
const cmdArgs = [
|
|
62
63
|
['branch', '-M', 'master'],
|
|
@@ -66,7 +67,7 @@ let CreateProjectClientMain = class CreateProjectClientMain {
|
|
|
66
67
|
for await (const args of cmdArgs) {
|
|
67
68
|
await this.shellCommandExecutor.exec({
|
|
68
69
|
bin: scmBin,
|
|
69
|
-
opts: { args, cwd },
|
|
70
|
+
opts: { args, cwd, streamData: verbose },
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -90,30 +91,30 @@ let CreateProjectClientMain = class CreateProjectClientMain {
|
|
|
90
91
|
this.logger.info('Creating root dir : %s', cwd);
|
|
91
92
|
await this.fsManager.mkdir(cwd, { recursive: true });
|
|
92
93
|
}
|
|
93
|
-
async initRepository(scmBin, cwd) {
|
|
94
|
+
async initRepository(scmBin, cwd, verbose) {
|
|
94
95
|
const cmd = 'init';
|
|
95
96
|
this.logger.info('Initializing repository : %s %s', scmBin, cmd);
|
|
96
97
|
await this.shellCommandExecutor.exec({
|
|
97
98
|
bin: scmBin,
|
|
98
|
-
opts: { args: [cmd], cwd },
|
|
99
|
+
opts: { args: [cmd], cwd, streamData: verbose },
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
|
-
async installDeps(pkgManagerBin, cwd) {
|
|
102
|
+
async installDeps(pkgManagerBin, cwd, verbose) {
|
|
102
103
|
const cmd = 'install';
|
|
103
104
|
this.logger.info('Installing dependencies : %s %s', pkgManagerBin, cmd);
|
|
104
105
|
await this.shellCommandExecutor.exec({
|
|
105
106
|
bin: pkgManagerBin,
|
|
106
|
-
opts: { args: [cmd], cwd },
|
|
107
|
+
opts: { args: [cmd], cwd, streamData: verbose },
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
|
-
async runDevCmds(pkgManagerBin, cwd) {
|
|
110
|
+
async runDevCmds(pkgManagerBin, cwd, verbose) {
|
|
110
111
|
const cmd = 'run';
|
|
111
112
|
const scripts = ['lint', 'test'];
|
|
112
113
|
for await (const script of scripts) {
|
|
113
114
|
this.logger.info('Running dev command : %s %s %s', pkgManagerBin, cmd, script);
|
|
114
115
|
await this.shellCommandExecutor.exec({
|
|
115
116
|
bin: pkgManagerBin,
|
|
116
|
-
opts: { args: [cmd, script], cwd },
|
|
117
|
+
opts: { args: [cmd, script], cwd, streamData: verbose },
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
120
|
}
|
|
@@ -170,6 +171,12 @@ export const CreateProjectUCD = {
|
|
|
170
171
|
.setDefaultValue('git')
|
|
171
172
|
.setExamples(['git']),
|
|
172
173
|
},
|
|
174
|
+
verbose: {
|
|
175
|
+
cardinality: {
|
|
176
|
+
min: 0,
|
|
177
|
+
},
|
|
178
|
+
type: new TBoolean().setDefaultValue(false),
|
|
179
|
+
},
|
|
173
180
|
},
|
|
174
181
|
},
|
|
175
182
|
},
|
|
@@ -57,6 +57,7 @@ import type { SSHPrivateKey } from './final/TSSHPrivateKey.js';
|
|
|
57
57
|
import type { SSHPublicKey } from './final/TSSHPublicKey.js';
|
|
58
58
|
import type { Time } from './final/TTime.js';
|
|
59
59
|
import type { Timestamp } from './final/TTimestamp.js';
|
|
60
|
+
import type { TransportType } from './final/TTransportType.js';
|
|
60
61
|
import type { UIntDuration } from './final/TUIntDuration.js';
|
|
61
62
|
import type { UIntQuantity } from './final/TUIntQuantity.js';
|
|
62
63
|
import type { URL } from './final/TURL.js';
|
|
@@ -66,5 +67,5 @@ import type { UUID } from './final/TUUID.js';
|
|
|
66
67
|
import type { Year } from './final/TYear.js';
|
|
67
68
|
import type { YesNo } from './final/TYesNo.js';
|
|
68
69
|
type Primitive = string | number | boolean;
|
|
69
|
-
export type DataType = Primitive | Address | Amount | ApiKey | BarCode | CSS | Color | ColorRGBA | CompanyName | CountryISO3166Alpha2 | CurrencyISO4217 | DateISO8601 | DateTimeFormat | DirPath | DomainName | Email | EmbeddedObject | Emoji | EncryptionKey | ErrorMessage | ExternalServiceId | File | FileExtension | FileMimeType | FileName | FilePath | FreeTextLong | FreeTextShort | Geolocation | GitSSHURL | HTML | HTTPContentType | HTTPMethod | HTTPStatusNumber | HostAddress | HostPort | IPv4 | IPv6 | JSONString | JWT | JavaScript | JobTitle | Markdown | NumIndex | Password | Percentage | PersonFirstname | PersonFullname | PersonInitials | PersonLastname | QRCode | SQLQuery | SSHPrivateKey | SSHPublicKey | SearchQuery | SemVerVersion | ShellCommand | Slug | Time | Timestamp | UIntDuration | UIntQuantity | URL | URLPath | UUID | Username | Year | YesNo;
|
|
70
|
+
export type DataType = Primitive | Address | Amount | ApiKey | BarCode | CSS | Color | ColorRGBA | CompanyName | CountryISO3166Alpha2 | CurrencyISO4217 | DateISO8601 | DateTimeFormat | DirPath | DomainName | Email | EmbeddedObject | Emoji | EncryptionKey | ErrorMessage | ExternalServiceId | File | FileExtension | FileMimeType | FileName | FilePath | FreeTextLong | FreeTextShort | Geolocation | GitSSHURL | HTML | HTTPContentType | HTTPMethod | HTTPStatusNumber | HostAddress | HostPort | IPv4 | IPv6 | JSONString | JWT | JavaScript | JobTitle | Markdown | NumIndex | Password | Percentage | PersonFirstname | PersonFullname | PersonInitials | PersonLastname | QRCode | SQLQuery | SSHPrivateKey | SSHPublicKey | SearchQuery | SemVerVersion | ShellCommand | Slug | Time | Timestamp | TransportType | UIntDuration | UIntQuantity | URL | URLPath | UUID | Username | Year | YesNo;
|
|
70
71
|
export {};
|
package/dist/esm/dt/DataTypes.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TName } from '../base/TBase.js';
|
|
2
|
+
import { TString } from '../base/TString.js';
|
|
3
|
+
export type TransportType = 'standard' | 'stream';
|
|
4
|
+
export declare class TTransportType extends TString<TransportType, 'TransportType'> {
|
|
5
|
+
constructor();
|
|
6
|
+
tName(): TName;
|
|
7
|
+
example(): TransportType;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TString } from '../base/TString.js';
|
|
2
|
+
export class TTransportType extends TString {
|
|
3
|
+
constructor() {
|
|
4
|
+
super();
|
|
5
|
+
this.setOptions([
|
|
6
|
+
{ label: 'standard', value: 'standard' },
|
|
7
|
+
{ label: 'stream', value: 'stream' },
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
tName() {
|
|
11
|
+
return 'TransportType';
|
|
12
|
+
}
|
|
13
|
+
example() {
|
|
14
|
+
return 'standard';
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist/esm/dt/index.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export { type SSHPrivateKey, TSSHPrivateKey } from './final/TSSHPrivateKey.js';
|
|
|
66
66
|
export { type SSHPublicKey, TSSHPublicKey } from './final/TSSHPublicKey.js';
|
|
67
67
|
export { type Time, TTime } from './final/TTime.js';
|
|
68
68
|
export { type Timestamp, TTimestamp } from './final/TTimestamp.js';
|
|
69
|
+
export { type TransportType, TTransportType } from './final/TTransportType.js';
|
|
69
70
|
export { TUIntDuration, type UIntDuration } from './final/TUIntDuration.js';
|
|
70
71
|
export { TUIntQuantity, type UIntQuantity } from './final/TUIntQuantity.js';
|
|
71
72
|
export { TURL, type URL } from './final/TURL.js';
|
package/dist/esm/dt/index.js
CHANGED
|
@@ -65,6 +65,7 @@ export { TSSHPrivateKey } from './final/TSSHPrivateKey.js';
|
|
|
65
65
|
export { TSSHPublicKey } from './final/TSSHPublicKey.js';
|
|
66
66
|
export { TTime } from './final/TTime.js';
|
|
67
67
|
export { TTimestamp } from './final/TTimestamp.js';
|
|
68
|
+
export { TTransportType } from './final/TTransportType.js';
|
|
68
69
|
export { TUIntDuration } from './final/TUIntDuration.js';
|
|
69
70
|
export { TUIntQuantity } from './final/TUIntQuantity.js';
|
|
70
71
|
export { TURL } from './final/TURL.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ForbiddenError } from './ForbiddenError.js';
|
|
2
|
+
import { IllegalArgumentError } from './IllegalArgumentError.js';
|
|
3
|
+
import { InternalServerError } from './InternalServerError.js';
|
|
4
|
+
import { NotFoundError } from './NotFoundError.js';
|
|
5
|
+
import { UnauthorizedError } from './UnauthorizedError.js';
|
|
6
|
+
const ERROR_HTTP_STATUS_MAP = new Map([
|
|
7
|
+
[400, IllegalArgumentError],
|
|
8
|
+
[401, UnauthorizedError],
|
|
9
|
+
[403, ForbiddenError],
|
|
10
|
+
[404, NotFoundError],
|
|
11
|
+
[500, InternalServerError],
|
|
12
|
+
]);
|
|
13
|
+
export function throwCustomError(message, status) {
|
|
14
|
+
const clazz = ERROR_HTTP_STATUS_MAP.get(status);
|
|
15
|
+
if (clazz) {
|
|
16
|
+
throw new clazz(message);
|
|
17
|
+
}
|
|
18
|
+
throw new InternalServerError(message);
|
|
19
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CustomError, type ServerError } from './CustomError.js';
|
|
2
2
|
export { ForbiddenAsNotFoundError } from './ForbiddenAsNotFoundError.js';
|
|
3
3
|
export { ForbiddenError } from './ForbiddenError.js';
|
|
4
|
+
export { throwCustomError } from './funcs.js';
|
|
4
5
|
export { IllegalArgumentError } from './IllegalArgumentError.js';
|
|
5
6
|
export { InternalServerError } from './InternalServerError.js';
|
|
6
7
|
export { NotAvailableError } from './internal/NotAvailableError.js';
|
package/dist/esm/error/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CustomError } from './CustomError.js';
|
|
2
2
|
export { ForbiddenAsNotFoundError } from './ForbiddenAsNotFoundError.js';
|
|
3
3
|
export { ForbiddenError } from './ForbiddenError.js';
|
|
4
|
+
export { throwCustomError } from './funcs.js';
|
|
4
5
|
export { IllegalArgumentError } from './IllegalArgumentError.js';
|
|
5
6
|
export { InternalServerError } from './InternalServerError.js';
|
|
6
7
|
export { NotAvailableError } from './internal/NotAvailableError.js';
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -7,10 +7,12 @@ export * from './icon/index.js';
|
|
|
7
7
|
export * from './product/index.js';
|
|
8
8
|
export * from './std/impl/ConsoleLogger.js';
|
|
9
9
|
export * from './std/impl/EnvSettingsManager.js';
|
|
10
|
+
export * from './std/impl/FakeClockManager.js';
|
|
10
11
|
export * from './std/impl/FakeEmailManager.js';
|
|
11
12
|
export * from './std/impl/FakeFSManager.js';
|
|
12
13
|
export * from './std/impl/FakeHTTPAPICallExecutor.js';
|
|
13
14
|
export * from './std/impl/FakeJobManager.js';
|
|
15
|
+
export * from './std/impl/FakeLLMManager.js';
|
|
14
16
|
export * from './std/impl/FetchHTTPAPICallExecutor.js';
|
|
15
17
|
export * from './std/impl/MistralAILLMManager.js';
|
|
16
18
|
export * from './std/impl/NoopHTTPAPICallExecutorAgentBuilder.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -8,10 +8,12 @@ export * from './icon/index.js';
|
|
|
8
8
|
export * from './product/index.js';
|
|
9
9
|
export * from './std/impl/ConsoleLogger.js';
|
|
10
10
|
export * from './std/impl/EnvSettingsManager.js';
|
|
11
|
+
export * from './std/impl/FakeClockManager.js';
|
|
11
12
|
export * from './std/impl/FakeEmailManager.js';
|
|
12
13
|
export * from './std/impl/FakeFSManager.js';
|
|
13
14
|
export * from './std/impl/FakeHTTPAPICallExecutor.js';
|
|
14
15
|
export * from './std/impl/FakeJobManager.js';
|
|
16
|
+
export * from './std/impl/FakeLLMManager.js';
|
|
15
17
|
export * from './std/impl/FetchHTTPAPICallExecutor.js';
|
|
16
18
|
export * from './std/impl/MistralAILLMManager.js';
|
|
17
19
|
export * from './std/impl/NoopHTTPAPICallExecutorAgentBuilder.js';
|
|
@@ -6,7 +6,7 @@ export type { RenderUCEntrypointTouchable, RenderUCExecTouchable, UCEntrypointTo
|
|
|
6
6
|
export { UCContainer } from './target/lib/react/UCContainer.js';
|
|
7
7
|
export { UCEntrypoint } from './target/lib/react/UCEntrypoint.js';
|
|
8
8
|
export { type Props as UCOutputFieldValueFragmentProps, UCOutputFieldValueFragment, } from './target/lib/react/UCOutputFieldValueFragment.js';
|
|
9
|
-
export { UCPanel } from './target/lib/react/UCPanel.js';
|
|
9
|
+
export { type Props as UCPanelProps, UCPanel, } from './target/lib/react/UCPanel.js';
|
|
10
10
|
export { type UseActionOpts, useAction, } from './target/lib/react/useAction.js';
|
|
11
11
|
export { type CloneFunc, type DivertFunc, type RefillFunc, useUC, } from './target/lib/react/useUC.js';
|
|
12
12
|
export { type AppendFunc, type RemoveFunc, type UpdateFunc, useUCOR, } from './target/lib/react/useUCOR.js';
|
package/dist/esm/index.react.js
CHANGED
|
@@ -3,7 +3,7 @@ export { StyleContext, StyleContextProvider, styleDef, useStyleContext, } from '
|
|
|
3
3
|
export { UCContainer } from './target/lib/react/UCContainer.js';
|
|
4
4
|
export { UCEntrypoint } from './target/lib/react/UCEntrypoint.js';
|
|
5
5
|
export { UCOutputFieldValueFragment, } from './target/lib/react/UCOutputFieldValueFragment.js';
|
|
6
|
-
export { UCPanel } from './target/lib/react/UCPanel.js';
|
|
6
|
+
export { UCPanel, } from './target/lib/react/UCPanel.js';
|
|
7
7
|
export { useAction, } from './target/lib/react/useAction.js';
|
|
8
8
|
export { useUC, } from './target/lib/react/useUC.js';
|
|
9
9
|
export { useUCOR, } from './target/lib/react/useUCOR.js';
|
|
@@ -16,16 +16,25 @@ export type HTTPAPICallExecutorFunc<Res> = (url: URL | URLString, info?: {
|
|
|
16
16
|
body?: Awaited<ReturnType<HTTPRequestBuilder['exec']>>['body'];
|
|
17
17
|
headers?: HTTPAPICallerHeaders;
|
|
18
18
|
method?: HTTPMethod;
|
|
19
|
+
signal?: AbortController['signal'];
|
|
19
20
|
}) => Promise<HTTPAPICallExecutorResponse<Res>>;
|
|
21
|
+
export interface HTTPAPICallExecutorResBody {
|
|
22
|
+
getReader(): {
|
|
23
|
+
read: () => Promise<{
|
|
24
|
+
done: boolean;
|
|
25
|
+
value: Uint8Array;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
readable: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface HTTPAPICallExecutorResHeaders {
|
|
31
|
+
entries(): IterableIterator<[string, string]>;
|
|
32
|
+
get: (name: 'Content-Type') => HTTPContentType;
|
|
33
|
+
}
|
|
20
34
|
export interface HTTPAPICallExecutorResponse<Res> {
|
|
21
35
|
arrayBuffer(): Promise<Buffer>;
|
|
22
|
-
body:
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
headers: {
|
|
26
|
-
entries(): IterableIterator<[string, string]>;
|
|
27
|
-
get: (name: 'Content-Type') => HTTPContentType;
|
|
28
|
-
};
|
|
36
|
+
body: HTTPAPICallExecutorResBody | undefined;
|
|
37
|
+
headers: HTTPAPICallExecutorResHeaders;
|
|
29
38
|
json: () => Promise<Res>;
|
|
30
39
|
ok: boolean;
|
|
31
40
|
redirected: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApiKey, ErrorMessage, HTTPContentType, HTTPMethod, JWT, Password, URL, Username } from '../dt/index.js';
|
|
2
|
-
import type { HTTPDataEnvelope } from '../utils/index.js';
|
|
2
|
+
import type { HTTPDataEnvelope, RegisterAbortFunc } from '../utils/index.js';
|
|
3
3
|
import type { XMLManagerParseOpts } from './XMLManager.js';
|
|
4
4
|
type AdditionalHeadersBuilder<AH> = () => Promise<AH>;
|
|
5
5
|
type ErrBuilder<ResBad> = (response: ResBad) => Promise<ErrorMessage>;
|
|
@@ -30,6 +30,9 @@ export interface HTTPAPICallerInput<AH extends object | undefined, Req extends o
|
|
|
30
30
|
additionalHeadersBuilder?: AdditionalHeadersBuilder<AH> | undefined;
|
|
31
31
|
authorizationHeader?: HTTPAPICallerAuthorizationHeader | undefined;
|
|
32
32
|
basicAuth?: HTTPAPICallerBasicAuth | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @default application/json
|
|
35
|
+
*/
|
|
33
36
|
contentType?: HTTPContentType;
|
|
34
37
|
errBuilder: ErrBuilder<ResBad>;
|
|
35
38
|
method: HTTPMethod;
|
|
@@ -38,10 +41,14 @@ export interface HTTPAPICallerInput<AH extends object | undefined, Req extends o
|
|
|
38
41
|
* If not set, it will assume that `ResGood` and `O` are the same and thus return `ResGood` as is.
|
|
39
42
|
*/
|
|
40
43
|
outputBuilder?: OutputBuilder<ResGood, O> | undefined;
|
|
44
|
+
registerAbort?: RegisterAbortFunc | undefined;
|
|
41
45
|
req?: {
|
|
42
46
|
builder: ReqBuilder<Req>;
|
|
43
47
|
envelope: HTTPDataEnvelope;
|
|
44
48
|
} | undefined;
|
|
49
|
+
stream?: {
|
|
50
|
+
onData: (res: O) => void;
|
|
51
|
+
} | undefined;
|
|
45
52
|
unknownErrorMessage?: ErrorMessage | undefined;
|
|
46
53
|
urlBuilder: URLBuilder;
|
|
47
54
|
}
|
|
@@ -41,6 +41,19 @@ export interface JWTManager {
|
|
|
41
41
|
* @param opts
|
|
42
42
|
*/
|
|
43
43
|
decode<T extends JWTManagerPayload>(value: JWT, opts?: JWTManagerDecodeOpts): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Decode the token without checking the signature
|
|
46
|
+
*
|
|
47
|
+
* IMPORTANT : IT DOES NOT CHECK THE SIGNATURE
|
|
48
|
+
*
|
|
49
|
+
* The main purpose of this method is to be used client side to decode the JWT in order to update some state including :
|
|
50
|
+
* - displaying the firstname in the UI
|
|
51
|
+
* - set the payload in some state
|
|
52
|
+
* - etc.
|
|
53
|
+
*
|
|
54
|
+
* @param value
|
|
55
|
+
*/
|
|
56
|
+
decodeUnsafe<T extends JWTManagerPayload>(value: JWT): Promise<T>;
|
|
44
57
|
/**
|
|
45
58
|
* Encode the payload
|
|
46
59
|
*
|
|
@@ -53,7 +66,9 @@ export interface JWTManager {
|
|
|
53
66
|
/**
|
|
54
67
|
* Check whether the token is usable or not
|
|
55
68
|
*
|
|
56
|
-
*
|
|
69
|
+
* IMPORTANT : IT DOES NOT CHECK THE SIGNATURE
|
|
70
|
+
*
|
|
71
|
+
* The main purpose of this method is to be used client side to save some requests (e.g. when the token is expired).
|
|
57
72
|
* In this case, no need to send a request that will trigger an error. Better to renew the token at the client's initiative.
|
|
58
73
|
*/
|
|
59
74
|
isUsable(value: JWT): Promise<boolean>;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import type { ApiKey, FreeTextLong } from '../dt/index.js';
|
|
2
|
+
import type { StreamConfig } from '../utils/index.js';
|
|
2
3
|
export type LLMManagerModel = string;
|
|
3
4
|
export type LLMManagerTemperature = number;
|
|
4
5
|
export interface LLMManagerSendOpts {
|
|
5
6
|
/**
|
|
6
|
-
* By default, each implementation reads the auth from the settings.
|
|
7
|
+
* By default, each implementation reads the auth from the settings.
|
|
8
|
+
* If provided here, it takes precedence over the settings value.
|
|
7
9
|
*/
|
|
8
10
|
auth?: {
|
|
9
11
|
apiKey?: ApiKey;
|
|
10
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Callbacks used when `stream` is `true`
|
|
15
|
+
*/
|
|
16
|
+
stream?: StreamConfig<LLMManagerSendRes>;
|
|
11
17
|
}
|
|
12
18
|
export interface LLMManagerSendReq {
|
|
13
19
|
messages: {
|
|
@@ -19,11 +25,22 @@ export interface LLMManagerSendReq {
|
|
|
19
25
|
role: 'assistant' | 'developer' | 'system' | 'user';
|
|
20
26
|
}[];
|
|
21
27
|
model: LLMManagerModel;
|
|
22
|
-
|
|
28
|
+
stream?: boolean | undefined;
|
|
29
|
+
temperature?: LLMManagerTemperature | undefined;
|
|
23
30
|
}
|
|
24
31
|
export interface LLMManagerSendRes {
|
|
25
32
|
choices: {
|
|
26
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Result chunk when stream is enabled
|
|
35
|
+
*/
|
|
36
|
+
delta?: {
|
|
37
|
+
content: string;
|
|
38
|
+
};
|
|
39
|
+
finish_reason: 'content_filter' | 'length' | 'stop' | 'tool_calls' | null;
|
|
40
|
+
/**
|
|
41
|
+
* Full result stream is not enabled
|
|
42
|
+
*/
|
|
43
|
+
message?: {
|
|
27
44
|
content: string;
|
|
28
45
|
};
|
|
29
46
|
}[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { injectable } from 'inversify';
|
|
8
|
+
import { StdDateClockManager } from './StdDateClockManager.js';
|
|
9
|
+
// We set now as this specific value to make tests deterministic
|
|
10
|
+
export const FAKE_CLOCK_MANAGER_NOW = '2022-05-15T20:23:30.123Z';
|
|
11
|
+
let FakeClockManager = class FakeClockManager extends StdDateClockManager {
|
|
12
|
+
now() {
|
|
13
|
+
return new Date(Date.parse(FAKE_CLOCK_MANAGER_NOW));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
FakeClockManager = __decorate([
|
|
17
|
+
injectable()
|
|
18
|
+
], FakeClockManager);
|
|
19
|
+
export { FakeClockManager };
|
|
@@ -26,19 +26,27 @@ let FakeHTTPAPICallExecutor = class FakeHTTPAPICallExecutor {
|
|
|
26
26
|
}
|
|
27
27
|
const key = (typeof url === 'string' ? url : url.toString());
|
|
28
28
|
const content = this.entries.get(key);
|
|
29
|
+
const body = {
|
|
30
|
+
getReader: () => ({
|
|
31
|
+
read: async () => ({
|
|
32
|
+
done: true,
|
|
33
|
+
value: new Uint8Array(),
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
readable: true,
|
|
37
|
+
};
|
|
38
|
+
const headers = {
|
|
39
|
+
entries: () => [
|
|
40
|
+
['Content-Type', 'application/json'],
|
|
41
|
+
].values(),
|
|
42
|
+
get: (_) => 'application/json',
|
|
43
|
+
};
|
|
29
44
|
if (!content) {
|
|
30
45
|
const message = `Endpoint ${url} not defined in FakeHTTPAPICallExecutor.entries`;
|
|
31
46
|
return {
|
|
32
47
|
arrayBuffer: async () => Buffer.from(''),
|
|
33
|
-
body
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
headers: {
|
|
37
|
-
entries: () => [
|
|
38
|
-
['Content-Type', 'application/json'],
|
|
39
|
-
].values(),
|
|
40
|
-
get: (_) => 'application/json',
|
|
41
|
-
},
|
|
48
|
+
body,
|
|
49
|
+
headers,
|
|
42
50
|
json: async () => ({ message }),
|
|
43
51
|
ok: false,
|
|
44
52
|
redirected: false,
|
|
@@ -48,15 +56,8 @@ let FakeHTTPAPICallExecutor = class FakeHTTPAPICallExecutor {
|
|
|
48
56
|
}
|
|
49
57
|
return {
|
|
50
58
|
arrayBuffer: async () => Buffer.from(content),
|
|
51
|
-
body
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
headers: {
|
|
55
|
-
entries: () => [
|
|
56
|
-
['Content-Type', 'application/json'],
|
|
57
|
-
].values(),
|
|
58
|
-
get: (_) => 'application/json',
|
|
59
|
-
},
|
|
59
|
+
body,
|
|
60
|
+
headers,
|
|
60
61
|
json: async () => JSON.parse(content),
|
|
61
62
|
ok: true,
|
|
62
63
|
redirected: false,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { injectable } from 'inversify';
|
|
8
|
+
let FakeLLMManager = class FakeLLMManager {
|
|
9
|
+
async send(req, opts) {
|
|
10
|
+
const content = `I'm not able to process your request : ${JSON.stringify(req)}`;
|
|
11
|
+
if (req.stream) {
|
|
12
|
+
await opts?.stream?.onData({
|
|
13
|
+
choices: [
|
|
14
|
+
{
|
|
15
|
+
delta: {
|
|
16
|
+
content,
|
|
17
|
+
},
|
|
18
|
+
finish_reason: 'stop',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
await opts?.stream?.onDone();
|
|
23
|
+
return { choices: [] };
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
choices: [
|
|
27
|
+
{
|
|
28
|
+
finish_reason: 'stop',
|
|
29
|
+
message: {
|
|
30
|
+
content,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
FakeLLMManager = __decorate([
|
|
38
|
+
injectable()
|
|
39
|
+
], FakeLLMManager);
|
|
40
|
+
export { FakeLLMManager };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JWT } from '../../dt/index.js';
|
|
2
2
|
import type { ClockManager } from '../ClockManager.js';
|
|
3
|
-
import type { JWTManager, JWTManagerDecodeOpts, JWTManagerEncodeOpts, JWTManagerSettings } from '../JWTManager.js';
|
|
3
|
+
import type { JWTManager, JWTManagerDecodeOpts, JWTManagerEncodeOpts, JWTManagerPayload, JWTManagerSettings } from '../JWTManager.js';
|
|
4
4
|
import type { SettingsManager } from '../SettingsManager.js';
|
|
5
5
|
export type S = Omit<JWTManagerSettings, 'jwt_manager_invalidate_issued_before'>;
|
|
6
6
|
export declare class JoseJWTManager implements JWTManager {
|
|
@@ -8,7 +8,8 @@ export declare class JoseJWTManager implements JWTManager {
|
|
|
8
8
|
private settingsManager;
|
|
9
9
|
constructor(clockManager: ClockManager, settingsManager: SettingsManager<S>);
|
|
10
10
|
s(): S;
|
|
11
|
-
decode<T extends
|
|
11
|
+
decode<T extends JWTManagerPayload>(value: JWT, opts?: JWTManagerDecodeOpts): Promise<T>;
|
|
12
|
+
decodeUnsafe<T extends JWTManagerPayload>(value: JWT): Promise<T>;
|
|
12
13
|
encode<T extends object>(payload: T, opts?: JWTManagerEncodeOpts): Promise<JWT>;
|
|
13
14
|
isUsable(value: JWT): Promise<boolean>;
|
|
14
15
|
}
|
|
@@ -54,6 +54,10 @@ let JoseJWTManager = class JoseJWTManager {
|
|
|
54
54
|
}
|
|
55
55
|
throw new Error(`Unsupported alg ${alg}`);
|
|
56
56
|
}
|
|
57
|
+
async decodeUnsafe(value) {
|
|
58
|
+
const decoded = decodeJwt(value);
|
|
59
|
+
return decoded;
|
|
60
|
+
}
|
|
57
61
|
async encode(payload, opts) {
|
|
58
62
|
const alg = opts?.alg ?? this.s().jwt_manager_algorithm;
|
|
59
63
|
const aud = opts?.aud ?? this.s().jwt_manager_audience;
|