libmodulor 0.20.0 → 0.22.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 +32 -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/Validation.js +1 -1
- package/dist/esm/dt/final/TGitSSHURL.d.ts +4 -3
- package/dist/esm/dt/final/TGitSSHURL.js +1 -1
- package/dist/esm/dt/final/TSSHPrivateKey.js +1 -3
- 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/std/HTTPAPICallExecutor.d.ts +16 -7
- package/dist/esm/std/HTTPAPICaller.d.ts +8 -1
- package/dist/esm/std/LLMManager.d.ts +20 -3
- package/dist/esm/std/impl/ConsoleLogger.js +2 -2
- 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/FetchHTTPAPICallExecutor.js +1 -1
- package/dist/esm/std/impl/MistralAILLMManager.js +12 -0
- package/dist/esm/std/impl/NodeFormDataBuilder.js +3 -1
- 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 +67 -16
- package/dist/esm/target/lib/cli/CommandExecutor.js +11 -3
- package/dist/esm/target/lib/react/UCPanel.d.ts +4 -2
- package/dist/esm/target/lib/react/UCPanel.js +2 -6
- package/dist/esm/target/lib/react/form.d.ts +5 -6
- package/dist/esm/target/lib/react/form.js +7 -10
- package/dist/esm/target/lib/react/useUC.d.ts +4 -4
- 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-express/funcs.js +52 -1
- package/dist/esm/target/lib/server-hono/funcs.js +65 -2
- package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.js +1 -0
- package/dist/esm/target/react-native-pure/UCForm.d.ts +1 -1
- package/dist/esm/target/react-native-pure/UCForm.js +2 -2
- package/dist/esm/target/react-native-pure/UCFormField.d.ts +1 -1
- package/dist/esm/target/react-native-pure/UCFormField.js +3 -4
- package/dist/esm/target/react-native-pure/UCFormFieldControl.js +13 -7
- package/dist/esm/target/react-web-pure/UCForm.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCForm.js +2 -2
- package/dist/esm/target/react-web-pure/UCFormField.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormField.js +3 -4
- package/dist/esm/target/react-web-pure/UCFormFieldControl.js +7 -4
- package/dist/esm/testing/AppTester.d.ts +1 -1
- package/dist/esm/testing/AppTester.js +3 -2
- package/dist/esm/testing/impl/SimpleHTMLAppTestReportEmitter.js +1 -1
- package/dist/esm/testing/impl/TypeScriptLibUCDefASTParser.js +2 -2
- package/dist/esm/testing/impl/VitestAppTestSuiteEmitter.js +6 -3
- package/dist/esm/testing/uc-input.js +13 -12
- package/dist/esm/testing/workers/UCExecutor.js +41 -3
- package/dist/esm/uc/UC.d.ts +7 -7
- package/dist/esm/uc/UC.js +4 -3
- package/dist/esm/uc/UCInputField.d.ts +6 -3
- package/dist/esm/uc/UCInputField.js +39 -29
- 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/index.d.ts +0 -1
- package/dist/esm/uc/index.js +0 -1
- package/dist/esm/uc/input-field.d.ts +2 -19
- package/dist/esm/uc/input-field.js +0 -19
- package/dist/esm/uc/input.d.ts +13 -7
- 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/uc/utils/rInput.js +4 -3
- package/dist/esm/uc/utils/rVal.d.ts +5 -5
- package/dist/esm/uc/utils/rVal.js +1 -12
- package/dist/esm/uc/value.d.ts +1 -2
- package/dist/esm/uc/workers/UCInputFilesProcessor.js +3 -3
- 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 +12 -0
- package/dist/esm/utils/http/NDJSONStreamManager.js +42 -0
- package/dist/esm/utils/http/SSEStreamManager.d.ts +12 -0
- package/dist/esm/utils/http/SSEStreamManager.js +57 -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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Validation } from '../dt/index.js';
|
|
2
2
|
import { isBlank } from '../utils/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ucifIsMandatory, ucifMustBeFilledManually, ucifRepeatability, } from './input-field.js';
|
|
4
4
|
import { rVal0, rValArr } from './utils/rVal.js';
|
|
5
|
-
import { ucifcoIsForArray } from './utils/ucifcoIsForArray.js';
|
|
6
5
|
export class UCInputField {
|
|
7
6
|
key;
|
|
8
7
|
def;
|
|
@@ -21,6 +20,18 @@ export class UCInputField {
|
|
|
21
20
|
this.value = initialValue;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
23
|
+
addVal(value) {
|
|
24
|
+
const { type } = this.def;
|
|
25
|
+
type.assign(value);
|
|
26
|
+
const val = type.val();
|
|
27
|
+
if (val === undefined) {
|
|
28
|
+
// The value is invalid for T (we might want to throw an error here)
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const current = Array.isArray(this.value) ? this.value : [];
|
|
32
|
+
// We are not really forced to use immutability here, to be reconsidered
|
|
33
|
+
this.value = current.concat([val]);
|
|
34
|
+
}
|
|
24
35
|
clear() {
|
|
25
36
|
this.value = undefined;
|
|
26
37
|
const initialValue = this.def.type.getInitialValue();
|
|
@@ -28,6 +39,18 @@ export class UCInputField {
|
|
|
28
39
|
this.value = initialValue;
|
|
29
40
|
}
|
|
30
41
|
}
|
|
42
|
+
fillWithExample() {
|
|
43
|
+
this.clear();
|
|
44
|
+
const [isRepeatable] = ucifRepeatability(this.def);
|
|
45
|
+
const { type } = this.def;
|
|
46
|
+
const val = type.getExamples()?.[0] ?? type.example();
|
|
47
|
+
if (isRepeatable) {
|
|
48
|
+
this.addVal(val);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.setVal(val);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
31
54
|
getDynamicWording() {
|
|
32
55
|
return this.dynamicWording;
|
|
33
56
|
}
|
|
@@ -77,7 +100,7 @@ export class UCInputField {
|
|
|
77
100
|
throw new Error(`${this.key.toString()} is not set and has no default value. Do not require it.`);
|
|
78
101
|
}
|
|
79
102
|
/**
|
|
80
|
-
*
|
|
103
|
+
* Read the value as an array
|
|
81
104
|
*
|
|
82
105
|
* Unlink the standalone {@link rValArr}, it returns the default value in an array if present.
|
|
83
106
|
*
|
|
@@ -100,40 +123,27 @@ export class UCInputField {
|
|
|
100
123
|
// Otherwise, we could not get the value of an optional repeatable field (see remark above on the defaultValue).
|
|
101
124
|
return [];
|
|
102
125
|
}
|
|
103
|
-
|
|
104
|
-
if (op === UCInputFieldChangeOperator.RESET) {
|
|
105
|
-
this.clear();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
126
|
+
rmVal(value) {
|
|
108
127
|
const { type } = this.def;
|
|
109
128
|
type.assign(value);
|
|
110
129
|
const val = type.val();
|
|
111
130
|
if (val === undefined) {
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
if (!ucifcoIsForArray(op)) {
|
|
115
|
-
// Using a switch, even for just one case, to have it trigger an error if we miss to handle an enum value
|
|
116
|
-
switch (op) {
|
|
117
|
-
case UCInputFieldChangeOperator.SET:
|
|
118
|
-
this.value = val;
|
|
119
|
-
break;
|
|
120
|
-
default:
|
|
121
|
-
((_) => { })(op);
|
|
122
|
-
}
|
|
131
|
+
// The value is invalid for T (we might want to throw an error here)
|
|
123
132
|
return;
|
|
124
133
|
}
|
|
125
134
|
const current = Array.isArray(this.value) ? this.value : [];
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
// We are not really forced to use immutability here, to be reconsidered
|
|
136
|
+
this.value = current.filter((v) => v !== val);
|
|
137
|
+
}
|
|
138
|
+
setVal(value) {
|
|
139
|
+
const { type } = this.def;
|
|
140
|
+
type.assign(value);
|
|
141
|
+
const val = type.val();
|
|
142
|
+
if (val === undefined) {
|
|
143
|
+
// The value is invalid for T (we might want to throw an error here)
|
|
144
|
+
return;
|
|
136
145
|
}
|
|
146
|
+
this.value = val;
|
|
137
147
|
}
|
|
138
148
|
updateDef(def) {
|
|
139
149
|
this.def = def;
|
package/dist/esm/uc/ext.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTTPMethod, URLPath } from '../dt/index.js';
|
|
1
|
+
import type { HTTPMethod, TransportType, URLPath } from '../dt/index.js';
|
|
2
2
|
import type { UCOPIBase } from './opi.js';
|
|
3
3
|
import type { UCOutput } from './output.js';
|
|
4
4
|
import type { UCMountingPoint } from './utils/ucMountingPoint.js';
|
|
@@ -41,5 +41,11 @@ export interface UCExt<OPI0 extends UCOPIBase | undefined = undefined, OPI1 exte
|
|
|
41
41
|
* @returns
|
|
42
42
|
*/
|
|
43
43
|
transform?: (output: UCOutput<OPI0, OPI1>) => object;
|
|
44
|
+
/**
|
|
45
|
+
* The way the output is transported
|
|
46
|
+
*
|
|
47
|
+
* By default, it's `standard`.
|
|
48
|
+
*/
|
|
49
|
+
transportType?: TransportType;
|
|
44
50
|
};
|
|
45
51
|
}
|
|
@@ -3,7 +3,7 @@ import type { ServerClientManager, ServerClientManagerSettings } from '../../tar
|
|
|
3
3
|
import type { UCInput } from '../input.js';
|
|
4
4
|
import type { UCOPIBase } from '../opi.js';
|
|
5
5
|
import type { UCOutputOrNothing } from '../output.js';
|
|
6
|
-
import type { UCTransporter } from '../transporter.js';
|
|
6
|
+
import type { UCTransporter, UCTransporterOpts } from '../transporter.js';
|
|
7
7
|
import type { UC } from '../UC.js';
|
|
8
8
|
type S = Pick<ServerClientManagerSettings, 'server_cookies_name_auth' | 'server_public_api_key_header_name'>;
|
|
9
9
|
export declare class HTTPUCTransporter implements Configurable<S>, UCTransporter {
|
|
@@ -12,6 +12,6 @@ export declare class HTTPUCTransporter implements Configurable<S>, UCTransporter
|
|
|
12
12
|
private settingsManager;
|
|
13
13
|
constructor(httpAPICaller: HTTPAPICaller, serverClientManager: ServerClientManager, settingsManager: SettingsManager<S>);
|
|
14
14
|
s(): S;
|
|
15
|
-
send<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
15
|
+
send<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, opts: UCTransporterOpts<OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -29,7 +29,7 @@ let HTTPUCTransporter = class HTTPUCTransporter {
|
|
|
29
29
|
server_public_api_key_header_name: this.settingsManager.get()('server_public_api_key_header_name'),
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
async send(uc) {
|
|
32
|
+
async send(uc, opts) {
|
|
33
33
|
const { auth, def: { sec }, } = uc;
|
|
34
34
|
const baseURL = await this.serverClientManager.baseURL({ auth });
|
|
35
35
|
const { contentType, envelope, method, path } = ucHTTPContract(uc);
|
|
@@ -96,10 +96,12 @@ let HTTPUCTransporter = class HTTPUCTransporter {
|
|
|
96
96
|
contentType,
|
|
97
97
|
errBuilder: async (error) => error.message,
|
|
98
98
|
method,
|
|
99
|
+
registerAbort: opts.registerAbort,
|
|
99
100
|
req: {
|
|
100
101
|
builder: async () => rInput(uc, { ignoreUndefined: true }),
|
|
101
102
|
envelope,
|
|
102
103
|
},
|
|
104
|
+
stream: opts.stream,
|
|
103
105
|
urlBuilder: async () => `${baseURL}${path}`,
|
|
104
106
|
});
|
|
105
107
|
// In case of 204, we get an empty object.
|
|
@@ -7,7 +7,7 @@ import { UCOutputReader } from '../helpers/UCOutputReader.js';
|
|
|
7
7
|
import type { UCInit } from '../init.js';
|
|
8
8
|
import type { UCInput } from '../input.js';
|
|
9
9
|
import type { UCMain } from '../main.js';
|
|
10
|
-
import type { UCManager, UCManagerPersistOpts } from '../manager.js';
|
|
10
|
+
import type { UCManager, UCManagerExecClientOpts, UCManagerExecServerOpts, UCManagerPersistOpts } from '../manager.js';
|
|
11
11
|
import type { UCOPIBase } from '../opi.js';
|
|
12
12
|
import type { UCOutputOrNothing } from '../output.js';
|
|
13
13
|
import type { UC } from '../UC.js';
|
|
@@ -29,8 +29,8 @@ export declare class SimpleUCManager implements UCManager {
|
|
|
29
29
|
constructor(ucClientConfirmManager: UCClientConfirmManager, clockManager: ClockManager, cryptoManager: CryptoManager, logger: Logger, ucDataStore: UCDataStore, ucExecChecker: UCExecChecker, ucInputFilesProcessor: UCInputFilesProcessor, ucInputValidator: UCInputValidator, ucInitProvider: Provider<UCInit>, ucMainProvider: Provider<UCMain>);
|
|
30
30
|
commitTx(): Promise<void>;
|
|
31
31
|
confirmClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<boolean>;
|
|
32
|
-
execClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<UCOutputReader<I, OPI0, OPI1>>;
|
|
33
|
-
execServer<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
32
|
+
execClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, opts?: UCManagerExecClientOpts<I, OPI0, OPI1>): Promise<UCOutputReader<I, OPI0, OPI1>>;
|
|
33
|
+
execServer<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, opts?: UCManagerExecServerOpts<OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
34
34
|
initServer<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<void>;
|
|
35
35
|
startTx(): Promise<void>;
|
|
36
36
|
persist<I extends UCInput | undefined = undefined, D extends UCData | null = null, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, data?: D, opts?: UCManagerPersistOpts): Promise<UCDataStoreRecord<I, D>>;
|
|
@@ -59,7 +59,7 @@ let SimpleUCManager = class SimpleUCManager {
|
|
|
59
59
|
}
|
|
60
60
|
return this.ucClientConfirmManager.exec(def);
|
|
61
61
|
}
|
|
62
|
-
async execClient(uc) {
|
|
62
|
+
async execClient(uc, opts) {
|
|
63
63
|
const { lifecycle, metadata } = uc.def;
|
|
64
64
|
const { client, server } = lifecycle;
|
|
65
65
|
if (!client) {
|
|
@@ -81,10 +81,23 @@ let SimpleUCManager = class SimpleUCManager {
|
|
|
81
81
|
await this.ucInputFilesProcessor.exec({ uc });
|
|
82
82
|
}
|
|
83
83
|
const main = (await this.ucMainProvider(client.main));
|
|
84
|
-
const
|
|
84
|
+
const streamOpts = opts?.stream;
|
|
85
|
+
const output = await main.exec({
|
|
86
|
+
opts: {
|
|
87
|
+
registerAbort: opts?.registerAbort,
|
|
88
|
+
stream: streamOpts
|
|
89
|
+
? {
|
|
90
|
+
onClose: streamOpts.onClose,
|
|
91
|
+
onData: (output) => streamOpts.onData(new UCOutputReader(uc.def, output ?? undefined)),
|
|
92
|
+
onDone: streamOpts.onDone,
|
|
93
|
+
}
|
|
94
|
+
: undefined,
|
|
95
|
+
},
|
|
96
|
+
uc,
|
|
97
|
+
});
|
|
85
98
|
return new UCOutputReader(uc.def, output ?? undefined);
|
|
86
99
|
}
|
|
87
|
-
async execServer(uc) {
|
|
100
|
+
async execServer(uc, opts) {
|
|
88
101
|
const { lifecycle, metadata } = uc.def;
|
|
89
102
|
const { server } = lifecycle;
|
|
90
103
|
if (typeof server !== 'object') {
|
|
@@ -101,7 +114,13 @@ let SimpleUCManager = class SimpleUCManager {
|
|
|
101
114
|
this.ucInputValidator.exec({ uc });
|
|
102
115
|
await this.ucInputFilesProcessor.exec({ uc });
|
|
103
116
|
const main = (await this.ucMainProvider(server.main));
|
|
104
|
-
|
|
117
|
+
const output = main.exec({
|
|
118
|
+
opts: {
|
|
119
|
+
stream: opts?.stream,
|
|
120
|
+
},
|
|
121
|
+
uc,
|
|
122
|
+
});
|
|
123
|
+
return output;
|
|
105
124
|
}
|
|
106
125
|
async initServer(uc) {
|
|
107
126
|
const { lifecycle, metadata } = uc.def;
|
package/dist/esm/uc/index.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ export * from './utils/rInput.js';
|
|
|
50
50
|
export * from './utils/rVal.js';
|
|
51
51
|
export * from './utils/stripUCDLifecycleServer.js';
|
|
52
52
|
export * from './utils/ucHTTPContract.js';
|
|
53
|
-
export * from './utils/ucifcoIsForArray.js';
|
|
54
53
|
export * from './utils/ucMountingPoint.js';
|
|
55
54
|
export * from './value.js';
|
|
56
55
|
export * from './workers/SimpleAggregateFinder.js';
|
package/dist/esm/uc/index.js
CHANGED
|
@@ -50,7 +50,6 @@ export * from './utils/rInput.js';
|
|
|
50
50
|
export * from './utils/rVal.js';
|
|
51
51
|
export * from './utils/stripUCDLifecycleServer.js';
|
|
52
52
|
export * from './utils/ucHTTPContract.js';
|
|
53
|
-
export * from './utils/ucifcoIsForArray.js';
|
|
54
53
|
export * from './utils/ucMountingPoint.js';
|
|
55
54
|
export * from './value.js';
|
|
56
55
|
export * from './workers/SimpleAggregateFinder.js';
|
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import type { DataType, TBase, UIntQuantity } from '../dt/index.js';
|
|
2
2
|
import type { UCFieldKey } from './def.js';
|
|
3
3
|
import type { Value } from './value.js';
|
|
4
|
-
export declare enum UCInputFieldChangeOperator {
|
|
5
|
-
/**
|
|
6
|
-
* Considering the cardinality of the field (min > 1), add a new value
|
|
7
|
-
*/
|
|
8
|
-
ADD = "ADD",
|
|
9
|
-
/**
|
|
10
|
-
* Considering the cardinality of the field (min > 1), remove a value
|
|
11
|
-
*/
|
|
12
|
-
REMOVE = "REMOVE",
|
|
13
|
-
/**
|
|
14
|
-
* Reset the value of the field
|
|
15
|
-
*/
|
|
16
|
-
RESET = "RESET",
|
|
17
|
-
/**
|
|
18
|
-
* Considering the cardinality of the field (max <= 1), set the value
|
|
19
|
-
*/
|
|
20
|
-
SET = "SET"
|
|
21
|
-
}
|
|
22
4
|
export declare enum UCInputFieldFillingMode {
|
|
23
5
|
/**
|
|
24
6
|
* Set programmatically on behalf of the user (e.g. a foreign key id for a given object)
|
|
@@ -72,7 +54,8 @@ export interface UCInputFieldDef<T extends DataType> {
|
|
|
72
54
|
transient?: boolean;
|
|
73
55
|
type: TBase<T>;
|
|
74
56
|
}
|
|
75
|
-
export type UCInputFieldValue<T
|
|
57
|
+
export type UCInputFieldValue<T> = Value<T>;
|
|
58
|
+
export type UCInputFieldValueUnwrapped<T> = T extends UCInputFieldValue<infer U> ? U : never;
|
|
76
59
|
export declare function ucifExamples<T extends DataType>(def: UCInputFieldDef<T>): T[] | undefined;
|
|
77
60
|
export declare function ucifHint<T extends DataType>(def: UCInputFieldDef<T>): string | undefined;
|
|
78
61
|
/**
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
export var UCInputFieldChangeOperator;
|
|
2
|
-
(function (UCInputFieldChangeOperator) {
|
|
3
|
-
/**
|
|
4
|
-
* Considering the cardinality of the field (min > 1), add a new value
|
|
5
|
-
*/
|
|
6
|
-
UCInputFieldChangeOperator["ADD"] = "ADD";
|
|
7
|
-
/**
|
|
8
|
-
* Considering the cardinality of the field (min > 1), remove a value
|
|
9
|
-
*/
|
|
10
|
-
UCInputFieldChangeOperator["REMOVE"] = "REMOVE";
|
|
11
|
-
/**
|
|
12
|
-
* Reset the value of the field
|
|
13
|
-
*/
|
|
14
|
-
UCInputFieldChangeOperator["RESET"] = "RESET";
|
|
15
|
-
/**
|
|
16
|
-
* Considering the cardinality of the field (max <= 1), set the value
|
|
17
|
-
*/
|
|
18
|
-
UCInputFieldChangeOperator["SET"] = "SET";
|
|
19
|
-
})(UCInputFieldChangeOperator || (UCInputFieldChangeOperator = {}));
|
|
20
1
|
export var UCInputFieldFillingMode;
|
|
21
2
|
(function (UCInputFieldFillingMode) {
|
|
22
3
|
/**
|
package/dist/esm/uc/input.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import type { DataType } from '../dt/index.js';
|
|
1
2
|
import type { StringKeys } from '../utils/index.js';
|
|
2
|
-
import type { UCInputFieldDef } from './input-field.js';
|
|
3
|
+
import type { UCInputFieldDef, UCInputFieldValue, UCInputFieldValueUnwrapped } from './input-field.js';
|
|
3
4
|
/**
|
|
4
5
|
* Base interface all the use case input interfaces must extend
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
7
|
+
export type UCInput = {};
|
|
8
|
+
export type UCInputUnwrapped<I extends UCInput | undefined> = {
|
|
9
|
+
[K in keyof I]: UCInputFieldValueUnwrapped<I[K]>;
|
|
10
|
+
};
|
|
11
|
+
export type UCInputKey<I extends UCInput | undefined> = StringKeys<UCInputUnwrapped<I>>;
|
|
12
|
+
export type UCInputPartial<I extends UCInput | undefined> = Partial<Record<UCInputKey<I>, UCInputFieldValue<DataType>>>;
|
|
13
|
+
export type UCInputKeyDataType<I extends UCInput | undefined, K extends UCInputKey<I>> = NonNullable<UCInputUnwrapped<I>[K]>;
|
|
8
14
|
/**
|
|
9
15
|
* Definition of a use case input
|
|
10
16
|
*/
|
|
@@ -12,11 +18,11 @@ export interface UCInputDef<I extends UCInput> {
|
|
|
12
18
|
/**
|
|
13
19
|
* This is useful when you want to render a given field only after its dependent fields have been set.
|
|
14
20
|
*/
|
|
15
|
-
dependencies?: Partial<Record<
|
|
21
|
+
dependencies?: Partial<Record<UCInputKey<I>, UCInputKey<I>[]>>;
|
|
16
22
|
/**
|
|
17
23
|
* It must follow strictly the shape of the corresponding {@link UCInput} with fields sorted alphabetically.
|
|
18
24
|
*/
|
|
19
|
-
fields: Record<
|
|
25
|
+
fields: Record<UCInputKey<I>, UCInputFieldDef<any>>;
|
|
20
26
|
/**
|
|
21
27
|
* By default, the fields are displayed in the same order as in {@link fields} (i.e. alphabetically).
|
|
22
28
|
*
|
|
@@ -24,13 +30,13 @@ export interface UCInputDef<I extends UCInput> {
|
|
|
24
30
|
*
|
|
25
31
|
* For example, when rendering a form, this is used.
|
|
26
32
|
*/
|
|
27
|
-
order?:
|
|
33
|
+
order?: UCInputKey<I>[];
|
|
28
34
|
/**
|
|
29
35
|
* Cross-field validation rules
|
|
30
36
|
*
|
|
31
37
|
* For example, if you want the user to provide `a` OR `b` but not both.
|
|
32
38
|
*/
|
|
33
39
|
validation?: {
|
|
34
|
-
or?:
|
|
40
|
+
or?: UCInputKey<I>[];
|
|
35
41
|
};
|
|
36
42
|
}
|
|
@@ -6,5 +6,5 @@ import type { UCTransporter } from '../../transporter.js';
|
|
|
6
6
|
export declare class SendClientMain<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> implements UCMain<I, OPI0, OPI1> {
|
|
7
7
|
private ucTransporter;
|
|
8
8
|
constructor(ucTransporter: UCTransporter);
|
|
9
|
-
exec({ uc, }: UCMainInput<I, OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
9
|
+
exec({ opts, uc, }: UCMainInput<I, OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
10
10
|
}
|
|
@@ -16,8 +16,11 @@ let SendClientMain = class SendClientMain {
|
|
|
16
16
|
constructor(ucTransporter) {
|
|
17
17
|
this.ucTransporter = ucTransporter;
|
|
18
18
|
}
|
|
19
|
-
async exec({ uc, }) {
|
|
20
|
-
return this.ucTransporter.send(uc
|
|
19
|
+
async exec({ opts, uc, }) {
|
|
20
|
+
return this.ucTransporter.send(uc, {
|
|
21
|
+
registerAbort: opts?.registerAbort,
|
|
22
|
+
stream: opts?.stream,
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
};
|
|
23
26
|
SendClientMain = __decorate([
|
package/dist/esm/uc/main.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { Worker } from '../std/index.js';
|
|
2
|
+
import type { RegisterAbortFunc, StreamConfig } from '../utils/index.js';
|
|
2
3
|
import type { UCInput } from './input.js';
|
|
3
4
|
import type { UCOPIBase } from './opi.js';
|
|
4
|
-
import type { UCOutputOrNothing } from './output.js';
|
|
5
|
+
import type { UCOutput, UCOutputOrNothing } from './output.js';
|
|
5
6
|
import type { UC } from './UC.js';
|
|
7
|
+
export type UCMainStream<OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> = StreamConfig<UCOutput<OPI0, OPI1>>;
|
|
8
|
+
export interface UCMainOpts<OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> {
|
|
9
|
+
registerAbort?: RegisterAbortFunc | undefined;
|
|
10
|
+
stream?: UCMainStream<OPI0, OPI1> | undefined;
|
|
11
|
+
}
|
|
6
12
|
export interface UCMainInput<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> {
|
|
13
|
+
opts?: UCMainOpts<OPI0, OPI1>;
|
|
7
14
|
uc: UC<I, OPI0, OPI1>;
|
|
8
15
|
}
|
|
9
16
|
export interface UCMain<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> extends Worker<UCMainInput<I, OPI0, OPI1>, Promise<UCOutputOrNothing<OPI0, OPI1>>> {
|
package/dist/esm/uc/manager.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { UUID } from '../dt/index.js';
|
|
2
|
+
import type { RegisterAbortFunc, StreamConfig } from '../utils/index.js';
|
|
2
3
|
import type { UCData } from './data.js';
|
|
3
4
|
import type { UCDataStoreRecord } from './data-store.js';
|
|
4
5
|
import type { UCExecMode } from './exec.js';
|
|
5
6
|
import type { UCOutputReader } from './helpers/UCOutputReader.js';
|
|
6
7
|
import type { UCInput } from './input.js';
|
|
8
|
+
import type { UCMainStream } from './main.js';
|
|
7
9
|
import type { UCOPIBase } from './opi.js';
|
|
8
10
|
import type { UCOutputOrNothing } from './output.js';
|
|
9
11
|
import type { UC } from './UC.js';
|
|
@@ -23,11 +25,18 @@ export interface UCManagerPersistOpts {
|
|
|
23
25
|
*/
|
|
24
26
|
organizationId?: UUID;
|
|
25
27
|
}
|
|
28
|
+
export interface UCManagerExecClientOpts<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> {
|
|
29
|
+
registerAbort?: RegisterAbortFunc | undefined;
|
|
30
|
+
stream?: StreamConfig<UCOutputReader<I, OPI0, OPI1>> | undefined;
|
|
31
|
+
}
|
|
32
|
+
export interface UCManagerExecServerOpts<OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> {
|
|
33
|
+
stream?: UCMainStream<OPI0, OPI1> | undefined;
|
|
34
|
+
}
|
|
26
35
|
export interface UCManager {
|
|
27
36
|
commitTx(): Promise<void>;
|
|
28
37
|
confirmClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<boolean>;
|
|
29
|
-
execClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<UCOutputReader<I, OPI0, OPI1>>;
|
|
30
|
-
execServer<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
38
|
+
execClient<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, opts?: UCManagerExecClientOpts<I, OPI0, OPI1>): Promise<UCOutputReader<I, OPI0, OPI1>>;
|
|
39
|
+
execServer<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, opts?: UCManagerExecServerOpts<OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
31
40
|
initServer<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<void>;
|
|
32
41
|
startTx(): Promise<void>;
|
|
33
42
|
persist<I extends UCInput | undefined = undefined, D extends UCData | null = null, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, data?: D, opts?: UCManagerPersistOpts): Promise<UCDataStoreRecord<I, D>>;
|
package/dist/esm/uc/output.d.ts
CHANGED
package/dist/esm/uc/output.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import type { RegisterAbortFunc } from '../utils/index.js';
|
|
1
2
|
import type { UCInput } from './input.js';
|
|
3
|
+
import type { UCMainStream } from './main.js';
|
|
2
4
|
import type { UCOPIBase } from './opi.js';
|
|
3
5
|
import type { UCOutputOrNothing } from './output.js';
|
|
4
6
|
import type { UC } from './UC.js';
|
|
7
|
+
export interface UCTransporterOpts<OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined> {
|
|
8
|
+
registerAbort?: RegisterAbortFunc | undefined;
|
|
9
|
+
stream?: UCMainStream<OPI0, OPI1> | undefined;
|
|
10
|
+
}
|
|
5
11
|
export interface UCTransporter {
|
|
6
|
-
send<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
12
|
+
send<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>, opts?: UCTransporterOpts<OPI0, OPI1>): Promise<UCOutputOrNothing<OPI0, OPI1>>;
|
|
7
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TBoolean } from '../../dt/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ucifIsMandatory, ucifRepeatability } from '../input-field.js';
|
|
3
3
|
const DEFAULT_OPTS = {
|
|
4
4
|
forceArrayAsEmpty: false,
|
|
5
5
|
forceBooleanAsFalse: true,
|
|
@@ -24,18 +24,19 @@ export function rInput(uc, opts) {
|
|
|
24
24
|
ucifIsMandatory(f.def) &&
|
|
25
25
|
(value === null || value === undefined)) {
|
|
26
26
|
value = false;
|
|
27
|
-
f.
|
|
27
|
+
f.setVal(value);
|
|
28
28
|
}
|
|
29
29
|
const [isRepeatable] = ucifRepeatability(f.def);
|
|
30
30
|
if (forceArrayAsEmpty &&
|
|
31
31
|
isRepeatable &&
|
|
32
32
|
(value === null || value === undefined)) {
|
|
33
33
|
value = [];
|
|
34
|
-
f.
|
|
34
|
+
f.setVal(value);
|
|
35
35
|
}
|
|
36
36
|
if (!ignoreUndefined || (ignoreUndefined && value !== undefined)) {
|
|
37
37
|
// Useful when we get the input before persisting for example.
|
|
38
38
|
// Otherwise it will persist `undefined` as a string in the database, for nothing.
|
|
39
|
+
// @ts-expect-error
|
|
39
40
|
input[f.key] = value;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DataType } from '../../dt/index.js';
|
|
2
1
|
import type { Value } from '../value.js';
|
|
3
2
|
/**
|
|
4
3
|
* Read the value as a primitive
|
|
@@ -9,7 +8,8 @@ import type { Value } from '../value.js';
|
|
|
9
8
|
* @param or
|
|
10
9
|
* @returns
|
|
11
10
|
*/
|
|
12
|
-
export declare function rVal0<T
|
|
11
|
+
export declare function rVal0<T>(value: Value<T>, or: T): T;
|
|
12
|
+
export declare function rVal0<T>(value: Value<T>, or?: undefined): T | null;
|
|
13
13
|
/**
|
|
14
14
|
* Require the value as a primitive
|
|
15
15
|
*
|
|
@@ -18,13 +18,13 @@ export declare function rVal0<T extends DataType>(value: Value<T>, or?: T): T |
|
|
|
18
18
|
* @param value
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
export declare function reqVal0<T
|
|
21
|
+
export declare function reqVal0<T>(value: Value<T>): T;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Read the value as an array
|
|
24
24
|
*
|
|
25
25
|
* To be used when the field has a 0..* cardinality.
|
|
26
26
|
*
|
|
27
27
|
* @param value
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
|
-
export declare function rValArr<T
|
|
30
|
+
export declare function rValArr<T>(value: Value<T>): T[];
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import { isBlank } from '../../utils/index.js';
|
|
2
|
-
// NOTE : the "r" prefix stands for "read" and the "req" prefix stands for "require"
|
|
3
|
-
/**
|
|
4
|
-
* Read the value as a primitive
|
|
5
|
-
*
|
|
6
|
-
* To be used when the field has a 0..1 cardinality.
|
|
7
|
-
*
|
|
8
|
-
* @param value
|
|
9
|
-
* @param or
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
// TODO : Find a way to return `T` when `or` is set (function override does not work)
|
|
13
2
|
export function rVal0(value, or) {
|
|
14
3
|
if (isBlank(value)) {
|
|
15
4
|
return or ?? null;
|
|
@@ -32,7 +21,7 @@ export function reqVal0(value) {
|
|
|
32
21
|
return val;
|
|
33
22
|
}
|
|
34
23
|
/**
|
|
35
|
-
*
|
|
24
|
+
* Read the value as an array
|
|
36
25
|
*
|
|
37
26
|
* To be used when the field has a 0..* cardinality.
|
|
38
27
|
*
|
package/dist/esm/uc/value.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type Value<T extends DataType> = T | T[] | null | undefined;
|
|
1
|
+
export type Value<T> = T | T[] | null | undefined;
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from 'inversify';
|
|
14
14
|
import { TFile } from '../../dt/index.js';
|
|
15
|
-
import {
|
|
15
|
+
import { ucifRepeatability } from '../input-field.js';
|
|
16
16
|
import { rVal0, rValArr } from '../utils/rVal.js';
|
|
17
17
|
let UCInputFilesProcessor = class UCInputFilesProcessor {
|
|
18
18
|
clockManager;
|
|
@@ -45,13 +45,13 @@ let UCInputFilesProcessor = class UCInputFilesProcessor {
|
|
|
45
45
|
// Although the field is a file, here we fill it with the refs (for persistence)
|
|
46
46
|
// TODO : Improve the mgmt of FileNameRef vs actual File at the use case level
|
|
47
47
|
// I think we need to introduce another value, something like `setValueSerialized` or similar.
|
|
48
|
-
field.
|
|
48
|
+
field.setVal(fileNameRefs);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
const file = rVal0(field.getValue());
|
|
52
52
|
if (file) {
|
|
53
53
|
const fileNameRef = await this.processFile(file);
|
|
54
|
-
field.
|
|
54
|
+
field.setVal(fileNameRef);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTTPAPICallExecutorResBody, Worker } from '../../std/index.js';
|
|
2
|
+
type Encoding = 'utf-8';
|
|
3
|
+
interface I<D extends object = object> {
|
|
4
|
+
encoding?: Encoding | undefined;
|
|
5
|
+
onData: (data: D) => Promise<void>;
|
|
6
|
+
reader: ReturnType<HTTPAPICallExecutorResBody['getReader']>;
|
|
7
|
+
}
|
|
8
|
+
export declare class NDJSONStreamManager implements Worker<I, Promise<void>> {
|
|
9
|
+
private static DEFAULT_ENCODING;
|
|
10
|
+
exec({ encoding, onData, reader, }: I): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|