libmodulor 0.29.0 → 0.31.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 +66 -0
- package/README.md +2 -2
- package/dist/esm/apps/Helper/src/lib/layers/product.js +1 -1
- package/dist/esm/apps/Helper/src/lib/layers/project.js +7 -7
- package/dist/esm/apps/Helper/src/lib/layers/target.js +27 -11
- package/dist/esm/convention.d.ts +2 -0
- package/dist/esm/convention.js +1 -0
- package/dist/esm/dt/base/TObject.js +13 -5
- package/dist/esm/dt/index.d.ts +1 -1
- package/dist/esm/dt/targets/json-schema.d.ts +23 -11
- package/dist/esm/error/funcs.d.ts +1 -0
- package/dist/esm/error/funcs.js +4 -0
- package/dist/esm/error/index.d.ts +1 -1
- package/dist/esm/error/index.js +1 -1
- package/dist/esm/i18n/WordingManager.js +12 -4
- package/dist/esm/i18n/locales/de.js +2 -0
- package/dist/esm/i18n/locales/en.js +2 -0
- package/dist/esm/i18n/locales/es.js +2 -0
- package/dist/esm/i18n/locales/fr.js +2 -0
- package/dist/esm/i18n/types.d.ts +1 -1
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.instrumentation-otl.d.ts +1 -0
- package/dist/esm/index.instrumentation-otl.js +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.node-express.d.ts +2 -0
- package/dist/esm/index.node-express.js +1 -0
- package/dist/esm/index.node-hono.d.ts +2 -0
- package/dist/esm/index.node-hono.js +1 -0
- package/dist/esm/index.node-mcp-express.d.ts +3 -0
- package/dist/esm/index.node-mcp-express.js +2 -0
- package/dist/esm/index.node-mcp-hono.d.ts +3 -0
- package/dist/esm/index.node-mcp-hono.js +2 -0
- package/dist/esm/index.node-mcp.d.ts +3 -1
- package/dist/esm/index.node-mcp.js +3 -1
- package/dist/esm/instrumentation/instrumentation-otl.d.ts +12 -0
- package/dist/esm/instrumentation/instrumentation-otl.js +119 -0
- package/dist/esm/products/Helper/i18n.d.ts +2 -0
- package/dist/esm/std/CryptoManager.d.ts +1 -1
- package/dist/esm/std/HTTPAPICaller.d.ts +2 -1
- package/dist/esm/std/impl/JoseJWTManager.js +9 -4
- package/dist/esm/std/impl/SimpleHTTPAPICaller.js +13 -7
- package/dist/esm/std/lib/settings.js +4 -5
- package/dist/esm/target/edge-worker-hono-server/SyncEdgeWorkerHonoServerManager.d.ts +2 -0
- package/dist/esm/target/edge-worker-hono-server/SyncEdgeWorkerHonoServerManager.js +3 -0
- package/dist/esm/target/index.d.ts +1 -1
- package/dist/esm/target/index.js +1 -1
- package/dist/esm/target/lib/client/AuthDataStore.d.ts +5 -0
- package/dist/esm/target/lib/client/impl/InMemoryAuthDataStore.d.ts +7 -0
- package/dist/esm/target/lib/client/impl/InMemoryAuthDataStore.js +20 -0
- package/dist/esm/target/lib/client/impl/MixedServerClientManager.d.ts +15 -0
- package/dist/esm/target/lib/client/impl/MixedServerClientManager.js +44 -0
- package/dist/esm/target/lib/json-schema/error.d.ts +3 -0
- package/dist/esm/target/lib/json-schema/error.js +14 -0
- package/dist/esm/target/lib/json-schema/input.d.ts +16 -0
- package/dist/esm/target/lib/json-schema/input.js +67 -0
- package/dist/esm/target/lib/json-schema/output.d.ts +19 -0
- package/dist/esm/target/lib/json-schema/output.js +128 -0
- package/dist/esm/target/lib/manifest.d.ts +32 -1
- package/dist/esm/target/lib/manifest.js +22 -1
- package/dist/esm/target/lib/mcp-server/MCPServerRequestChecker.d.ts +22 -0
- package/dist/esm/target/lib/mcp-server/MCPServerRequestChecker.js +71 -0
- package/dist/esm/target/lib/mcp-server/MCPServerRequestHandler.d.ts +16 -0
- package/dist/esm/target/lib/mcp-server/MCPServerRequestHandler.js +54 -0
- package/dist/esm/target/lib/mcp-server/consts.d.ts +1 -0
- package/dist/esm/target/lib/mcp-server/consts.js +1 -0
- package/dist/esm/target/lib/mcp-server/funcs.d.ts +13 -0
- package/dist/esm/target/lib/mcp-server/funcs.js +84 -0
- package/dist/esm/target/lib/mcp-server/http/MCPHTTPRequestHandlerBuilder.d.ts +14 -0
- package/dist/esm/target/lib/mcp-server/http/MCPHTTPRequestHandlerBuilder.js +1 -0
- package/dist/esm/target/lib/mcp-server/http/express/MCPHTTPExpressFakeRequestHandlerBuilder.d.ts +5 -0
- package/dist/esm/target/lib/mcp-server/http/express/MCPHTTPExpressFakeRequestHandlerBuilder.js +18 -0
- package/dist/esm/target/lib/mcp-server/http/express/MCPHTTPExpressProtocolRequestHandlerBuilder.d.ts +17 -0
- package/dist/esm/target/lib/mcp-server/http/express/MCPHTTPExpressProtocolRequestHandlerBuilder.js +100 -0
- package/dist/esm/target/lib/mcp-server/http/express/types.d.ts +3 -0
- package/dist/esm/target/lib/mcp-server/http/express/types.js +1 -0
- package/dist/esm/target/lib/mcp-server/http/funcs.d.ts +6 -0
- package/dist/esm/target/lib/mcp-server/http/funcs.js +50 -0
- package/dist/esm/target/lib/mcp-server/http/hono/MCPHTTPHonoFakeRequestHandlerBuilder.d.ts +5 -0
- package/dist/esm/target/lib/mcp-server/http/hono/MCPHTTPHonoFakeRequestHandlerBuilder.js +18 -0
- package/dist/esm/target/lib/mcp-server/http/hono/MCPHTTPHonoProtocolRequestHandlerBuilder.d.ts +17 -0
- package/dist/esm/target/lib/mcp-server/http/hono/MCPHTTPHonoProtocolRequestHandlerBuilder.js +100 -0
- package/dist/esm/target/lib/mcp-server/http/hono/types.d.ts +3 -0
- package/dist/esm/target/lib/mcp-server/http/hono/types.js +1 -0
- package/dist/esm/target/lib/mcp-server/stdio/MCPStdioRequestHandler.d.ts +31 -0
- package/dist/esm/target/lib/mcp-server/stdio/MCPStdioRequestHandler.js +108 -0
- package/dist/esm/target/lib/mcp-server/stdio/MCPStdioUCClientConfirmManager.d.ts +7 -0
- package/dist/esm/target/lib/mcp-server/stdio/MCPStdioUCClientConfirmManager.js +36 -0
- package/dist/esm/target/lib/mcp-server/stdio/consts.d.ts +2 -0
- package/dist/esm/target/lib/mcp-server/stdio/consts.js +3 -0
- package/dist/esm/target/lib/mcp-server/stdio/funcs.d.ts +2 -0
- package/dist/esm/target/lib/mcp-server/stdio/funcs.js +10 -0
- package/dist/esm/target/lib/mcp-server/stdio/input.d.ts +10 -0
- package/dist/esm/target/lib/mcp-server/stdio/input.js +15 -0
- package/dist/esm/target/lib/mcp-server/types.d.ts +2 -0
- package/dist/esm/target/lib/mcp-server/types.js +1 -0
- package/dist/esm/target/lib/openapi/OpenAPISpecBuilder.js +8 -4
- package/dist/esm/target/lib/openapi/funcs.d.ts +4 -9
- package/dist/esm/target/lib/openapi/funcs.js +18 -119
- package/dist/esm/target/lib/openapi/types.d.ts +5 -16
- package/dist/esm/target/lib/react/useAction.js +0 -1
- package/dist/esm/target/lib/react/useUC.js +0 -3
- package/dist/esm/target/lib/server/AuthenticationChecker.js +15 -10
- package/dist/esm/target/lib/server/JWTAuthenticationChecker.d.ts +1 -0
- package/dist/esm/target/lib/server/JWTAuthenticationChecker.js +11 -2
- package/dist/esm/target/lib/server/ServerBooter.d.ts +1 -1
- package/dist/esm/target/lib/server/ServerBooter.js +10 -0
- package/dist/esm/target/lib/server/ServerManager.d.ts +10 -0
- package/dist/esm/target/lib/server/ServerRequestHandler.d.ts +10 -5
- package/dist/esm/target/lib/server/ServerRequestHandler.js +35 -25
- package/dist/esm/target/lib/server/consts.js +4 -0
- package/dist/esm/target/lib/server-express/funcs.js +2 -6
- package/dist/esm/target/lib/server-hono/funcs.js +4 -2
- package/dist/esm/target/lib/shared.d.ts +1 -0
- package/dist/esm/target/lib/shared.js +1 -0
- package/dist/esm/target/nextjs-server/NextJSServerManager.d.ts +2 -0
- package/dist/esm/target/nextjs-server/NextJSServerManager.js +3 -0
- package/dist/esm/target/node-express-server/NodeExpressServerManager.d.ts +6 -2
- package/dist/esm/target/node-express-server/NodeExpressServerManager.js +15 -6
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.d.ts +6 -2
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.js +15 -6
- package/dist/esm/target/{node-mcp-server/NodeLocalStdioMCPServerManager.d.ts → node-mcp-server-stdio/NodeMCPStdioServerManager.d.ts} +9 -20
- package/dist/esm/target/node-mcp-server-stdio/NodeMCPStdioServerManager.js +108 -0
- package/dist/esm/target/react-native-pure/UCFormFieldControl.js +0 -1
- package/dist/esm/testing/impl/NodeAppTesterConfigurator.js +7 -0
- package/dist/esm/testing/impl/newNodeAppTester.js +12 -0
- package/dist/esm/uc/cardinality.d.ts +7 -0
- package/dist/esm/uc/cardinality.js +14 -0
- package/dist/esm/uc/examples.d.ts +2 -0
- package/dist/esm/uc/examples.js +12 -0
- package/dist/esm/uc/helpers/UCOutputReader.d.ts +2 -2
- package/dist/esm/uc/helpers/UCOutputReader.js +2 -2
- package/dist/esm/uc/index.d.ts +2 -0
- package/dist/esm/uc/index.js +2 -0
- package/dist/esm/uc/input-field.d.ts +3 -6
- package/dist/esm/uc/input-field.js +5 -21
- package/dist/esm/uc/opi.d.ts +3 -1
- package/dist/esm/uc/opi.js +4 -1
- package/dist/esm/uc/output-field.d.ts +13 -1
- package/dist/esm/uc/output-field.js +9 -11
- package/dist/esm/utils/bundling/funcs.js +1 -1
- package/dist/esm/utils/bundling/vite/plugin.d.ts +1 -1
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/streams/funcs.d.ts +2 -0
- package/dist/esm/utils/streams/funcs.js +10 -0
- package/dist/esm/utils/strings/humanize.js +4 -1
- package/package.json +47 -20
- package/dist/esm/target/lib/openapi/consts.d.ts +0 -2
- package/dist/esm/target/lib/openapi/consts.js +0 -1
- package/dist/esm/target/lib/openapi/input.d.ts +0 -16
- package/dist/esm/target/lib/openapi/input.js +0 -33
- package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.js +0 -188
- package/dist/esm/target/node-mcp-server/funcs.d.ts +0 -7
- package/dist/esm/target/node-mcp-server/funcs.js +0 -45
- package/dist/esm/target/node-mcp-server/types.d.ts +0 -15
- /package/dist/esm/target/{node-mcp-server/types.js → lib/client/AuthDataStore.js} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { context, SpanStatusCode, trace } from '@opentelemetry/api';
|
|
2
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition, } from '@opentelemetry/instrumentation';
|
|
3
|
+
const LIB_NAME = 'libmodulor';
|
|
4
|
+
const LIB_VERSION = '';
|
|
5
|
+
const LIB_MIN_VERSION = '*';
|
|
6
|
+
const NAME = `instrumentation-${LIB_NAME}`;
|
|
7
|
+
const TRACABLES = {
|
|
8
|
+
[LIB_NAME]: {
|
|
9
|
+
SimpleUCManager: [
|
|
10
|
+
'commitTx',
|
|
11
|
+
'confirmClient',
|
|
12
|
+
'execClient',
|
|
13
|
+
'execServer',
|
|
14
|
+
'initServer',
|
|
15
|
+
'persist',
|
|
16
|
+
'persistProjection',
|
|
17
|
+
'rollbackTx',
|
|
18
|
+
],
|
|
19
|
+
UCExecChecker: ['exec'],
|
|
20
|
+
UCInputFilesProcessor: ['exec'],
|
|
21
|
+
UCInputValidator: ['exec'],
|
|
22
|
+
UCOutputFilesProcessor: ['exec'],
|
|
23
|
+
},
|
|
24
|
+
[`${LIB_NAME}/uc-data-store-knex`]: {
|
|
25
|
+
KnexUCDataStore: [
|
|
26
|
+
'clear',
|
|
27
|
+
'destroy',
|
|
28
|
+
'exists',
|
|
29
|
+
'init',
|
|
30
|
+
'initSync',
|
|
31
|
+
'read',
|
|
32
|
+
'readProjection',
|
|
33
|
+
'startTx',
|
|
34
|
+
'supportedSpecificBindings',
|
|
35
|
+
'testKey',
|
|
36
|
+
'write',
|
|
37
|
+
'writeBulk',
|
|
38
|
+
'writeProjection',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export class InstrumentationOTL extends InstrumentationBase {
|
|
43
|
+
constructor(config) {
|
|
44
|
+
super(NAME, LIB_VERSION, config);
|
|
45
|
+
}
|
|
46
|
+
init() {
|
|
47
|
+
const namespaces = Object.keys(TRACABLES);
|
|
48
|
+
const defs = namespaces.map((namespace) => new InstrumentationNodeModuleDefinition(this.moduleName(namespace, this._config.libPath), [LIB_MIN_VERSION], (moduleExports) => this.wrapAll(moduleExports, namespace), (moduleExports) => this.unwrapAll(moduleExports, namespace)));
|
|
49
|
+
return defs;
|
|
50
|
+
}
|
|
51
|
+
moduleName(namespace, libPath) {
|
|
52
|
+
if (!libPath) {
|
|
53
|
+
return namespace; // e.g. libmodulor, libmodulor/uc-data-store-knex
|
|
54
|
+
}
|
|
55
|
+
if (!namespace.includes('/')) {
|
|
56
|
+
return libPath; // ../../../index.js
|
|
57
|
+
}
|
|
58
|
+
const moduleName = namespace.split('/')[1];
|
|
59
|
+
return libPath.replace('.js', `.${moduleName}.js`); // e.g. ../../../index.uc-data-store-knex.js
|
|
60
|
+
}
|
|
61
|
+
patchMethod(namespace, className, methodName) {
|
|
62
|
+
return (original) => {
|
|
63
|
+
const tracer = this.tracer;
|
|
64
|
+
const spanName = `${className}.${methodName}`;
|
|
65
|
+
// biome-ignore lint/suspicious/noExplicitAny: can be anything
|
|
66
|
+
return function patched(...args) {
|
|
67
|
+
const span = tracer.startSpan(spanName, {
|
|
68
|
+
attributes: {
|
|
69
|
+
'scope.name': namespace,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
const ctx = trace.setSpan(context.active(), span);
|
|
73
|
+
return context.with(ctx, async () => {
|
|
74
|
+
try {
|
|
75
|
+
const res = await original.apply(this, args);
|
|
76
|
+
span.setStatus({
|
|
77
|
+
code: SpanStatusCode.OK,
|
|
78
|
+
});
|
|
79
|
+
return res;
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
span.recordException(err);
|
|
83
|
+
span.setStatus({
|
|
84
|
+
code: SpanStatusCode.ERROR,
|
|
85
|
+
message: err.message,
|
|
86
|
+
});
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
span.end();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
unwrapAll(moduleExports, namespace) {
|
|
97
|
+
// biome-ignore lint/style/noNonNullAssertion: we want it
|
|
98
|
+
const entries = Object.entries(TRACABLES[namespace]);
|
|
99
|
+
for (const [className, methodNames] of entries) {
|
|
100
|
+
for (const methodName of methodNames) {
|
|
101
|
+
// biome-ignore lint/style/noNonNullAssertion: we want it
|
|
102
|
+
this._unwrap(moduleExports[className].prototype, methodName);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return moduleExports;
|
|
106
|
+
}
|
|
107
|
+
wrapAll(moduleExports, namespace) {
|
|
108
|
+
// biome-ignore lint/style/noNonNullAssertion: we want it
|
|
109
|
+
const entries = Object.entries(TRACABLES[namespace]);
|
|
110
|
+
for (const [className, methodNames] of entries) {
|
|
111
|
+
for (const methodName of methodNames) {
|
|
112
|
+
this._wrap(
|
|
113
|
+
// biome-ignore lint/style/noNonNullAssertion: we want it
|
|
114
|
+
moduleExports[className].prototype, methodName, this.patchMethod(namespace, className, methodName).bind(this));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return moduleExports;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Password, UIntQuantity, UUID } from '../dt/index.js';
|
|
2
2
|
import type { Clearable } from '../utils/index.js';
|
|
3
3
|
import type { BufferManagerBase64String } from './BufferManager.js';
|
|
4
|
-
export type CryptoManagerBinaryToTextEncoding = 'hex';
|
|
4
|
+
export type CryptoManagerBinaryToTextEncoding = 'base64' | 'base64url' | 'hex';
|
|
5
5
|
export type CryptoManagerHash = string;
|
|
6
6
|
export type CryptoManagerHashAlgorithm = 'sha1' | 'sha256' | 'sha512';
|
|
7
7
|
export type CryptoManagerHMACKey = string;
|
|
@@ -12,8 +12,9 @@ export interface HTTPAPICallerHeaders {
|
|
|
12
12
|
'Content-Type'?: HTTPContentType;
|
|
13
13
|
Cookie?: string;
|
|
14
14
|
}
|
|
15
|
+
export type HTTPAPICallerAuthorizationHeaderPrefix = 'AWS4-HMAC-SHA256' | 'Basic' | 'Bearer' | 'JWT' | 'OAuth';
|
|
15
16
|
export interface HTTPAPICallerAuthorizationHeader {
|
|
16
|
-
prefix?:
|
|
17
|
+
prefix?: HTTPAPICallerAuthorizationHeaderPrefix;
|
|
17
18
|
value: ApiKey | JWT | Password;
|
|
18
19
|
}
|
|
19
20
|
export interface HTTPAPICallerBasicAuth {
|
|
@@ -34,10 +34,10 @@ let JoseJWTManager = class JoseJWTManager {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
async decode(value, opts) {
|
|
37
|
-
const { alg } = decodeProtectedHeader(value);
|
|
38
|
-
assertIsDefined(alg, 'alg');
|
|
39
|
-
const secret = opts?.secret || this.s().jwt_manager_secret;
|
|
40
37
|
try {
|
|
38
|
+
const { alg } = decodeProtectedHeader(value);
|
|
39
|
+
assertIsDefined(alg, 'alg');
|
|
40
|
+
const secret = opts?.secret || this.s().jwt_manager_secret;
|
|
41
41
|
if (alg.startsWith('HS')) {
|
|
42
42
|
return (await jwtVerify(value, new TextEncoder().encode(secret))).payload;
|
|
43
43
|
}
|
|
@@ -51,8 +51,13 @@ let JoseJWTManager = class JoseJWTManager {
|
|
|
51
51
|
if (err instanceof JWSSignatureVerificationFailed) {
|
|
52
52
|
throw new UnauthorizedError();
|
|
53
53
|
}
|
|
54
|
+
// See node_modules/jose/dist/webapi/util/decode_protected_header.js
|
|
55
|
+
if (err instanceof TypeError &&
|
|
56
|
+
err.message.toLowerCase().includes('invalid token')) {
|
|
57
|
+
throw new UnauthorizedError();
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
|
-
throw new
|
|
60
|
+
throw new UnauthorizedError();
|
|
56
61
|
}
|
|
57
62
|
async decodeUnsafe(value) {
|
|
58
63
|
const decoded = decodeJwt(value);
|
|
@@ -55,13 +55,19 @@ let SimpleHTTPAPICaller = class SimpleHTTPAPICaller {
|
|
|
55
55
|
registerAbort?.(() => {
|
|
56
56
|
abortController.abort();
|
|
57
57
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
let response;
|
|
59
|
+
try {
|
|
60
|
+
response = await this.httpAPICallExecutor.fn()(url, {
|
|
61
|
+
agent,
|
|
62
|
+
body,
|
|
63
|
+
headers: reqHeaders,
|
|
64
|
+
method,
|
|
65
|
+
signal: abortController.signal,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
throw new Error('err_unreachable', { cause: err });
|
|
70
|
+
}
|
|
65
71
|
const { headers, status } = response;
|
|
66
72
|
this.logger.trace('HTTPAPICaller', {
|
|
67
73
|
body,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { logDevWarning } from '../../error/index.js';
|
|
1
2
|
const UNSAFE_SETTING = 'UNSAFE_CHANGE_ME';
|
|
2
3
|
export function unsafeDefaultSetting(suffix = '') {
|
|
3
4
|
return `${UNSAFE_SETTING}${suffix}`;
|
|
4
5
|
}
|
|
5
6
|
export function assertSettingNotUnsafe(key, value) {
|
|
6
7
|
if (typeof value === 'string' && value.startsWith(UNSAFE_SETTING)) {
|
|
7
|
-
throw new Error(`"${key}" still has the unsafe default value
|
|
8
|
+
throw new Error(`"${key}" still has the unsafe default value`);
|
|
8
9
|
}
|
|
9
10
|
if (Array.isArray(value)) {
|
|
10
11
|
for (const v of value) {
|
|
@@ -28,12 +29,10 @@ export function checkSettings(settings, throwIfViolations) {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
if (violations.length > 0) {
|
|
31
|
-
|
|
32
|
-
const message = `\x1b[1m\x1b[33m[WARNING] THE SETTINGS ARE NOT SAFE (THIS WILL THROW IN PROD) :\n${violations.join('\n')}\x1b[0m`;
|
|
32
|
+
const message = `Settings contain violations :\n${violations.join('\n')}`;
|
|
33
33
|
if (throwIfViolations) {
|
|
34
34
|
throw new Error(message);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
console.warn(message);
|
|
36
|
+
logDevWarning(message);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Hono } from 'hono';
|
|
2
2
|
import type { AppManifest } from '../../app/index.js';
|
|
3
3
|
import type { DirPath, URLPath } from '../../dt/index.js';
|
|
4
|
+
import type { ProductUCsLoaderOutput } from '../../product/index.js';
|
|
4
5
|
import type { Configurable, SettingsManager } from '../../std/index.js';
|
|
5
6
|
import type { UCDataStore, UCDef, UCHTTPContract, UCInput, UCManager, UCOPIBase } from '../../uc/index.js';
|
|
6
7
|
import type { OpenAPISpec } from '../lib/openapi/types.js';
|
|
@@ -28,6 +29,7 @@ export declare class SyncEdgeWorkerHonoServerManager implements Configurable<S>,
|
|
|
28
29
|
initSync(): void;
|
|
29
30
|
mount<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(_appManifest: AppManifest, _ucd: UCDef<I, OPI0, OPI1>, _contract: UCHTTPContract): Promise<void>;
|
|
30
31
|
mountSync<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(appManifest: AppManifest, ucd: UCDef<I, OPI0, OPI1>, contract: UCHTTPContract): void;
|
|
32
|
+
mountMCP(_ucs: ProductUCsLoaderOutput, _at: URLPath): Promise<void>;
|
|
31
33
|
mountOpenAPISpec(_spec: OpenAPISpec, _at: URLPath): Promise<void>;
|
|
32
34
|
mountStaticDir(_dirPath: DirPath): Promise<void>;
|
|
33
35
|
start(): Promise<void>;
|
|
@@ -55,6 +55,9 @@ let SyncEdgeWorkerHonoServerManager = class SyncEdgeWorkerHonoServerManager {
|
|
|
55
55
|
mountSync(appManifest, ucd, contract) {
|
|
56
56
|
mountHandler(contract, this.runtime, buildHandler(appManifest, ucd, contract, this.serverRequestHandler, this.ucManager, (c) => this.beforeExec(c)));
|
|
57
57
|
}
|
|
58
|
+
async mountMCP(_ucs, _at) {
|
|
59
|
+
throw new NotImplementedError('mountMCP');
|
|
60
|
+
}
|
|
58
61
|
async mountOpenAPISpec(_spec, _at) {
|
|
59
62
|
throw new NotImplementedError('mountOpenAPISpec');
|
|
60
63
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { TARGETS, type TargetName } from './lib/manifest.js';
|
|
1
|
+
export { TARGET_CAPABILITIES_SAMPLE, TARGETS, type TargetCapabilities, TargetCapability, type TargetDef, type TargetDefSrc, type TargetName, } from './lib/manifest.js';
|
|
2
2
|
export type { OpenAPISpec } from './lib/openapi/types.js';
|
package/dist/esm/target/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TARGETS } from './lib/manifest.js';
|
|
1
|
+
export { TARGET_CAPABILITIES_SAMPLE, TARGETS, TargetCapability, } from './lib/manifest.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JWT } from '../../../../dt/index.js';
|
|
2
|
+
import type { AuthDataStore } from '../AuthDataStore.js';
|
|
3
|
+
export declare class InMemoryAuthDataStore implements AuthDataStore {
|
|
4
|
+
private jwt;
|
|
5
|
+
get(): Promise<JWT | null>;
|
|
6
|
+
set(jwt: JWT | null): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 InMemoryAuthDataStore = class InMemoryAuthDataStore {
|
|
9
|
+
jwt = null;
|
|
10
|
+
async get() {
|
|
11
|
+
return this.jwt;
|
|
12
|
+
}
|
|
13
|
+
async set(jwt) {
|
|
14
|
+
this.jwt = jwt;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
InMemoryAuthDataStore = __decorate([
|
|
18
|
+
injectable()
|
|
19
|
+
], InMemoryAuthDataStore);
|
|
20
|
+
export { InMemoryAuthDataStore };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ApiKey, JWT, URL } from '../../../../dt/index.js';
|
|
2
|
+
import { SettingsServerClientManager } from '../../../../std/impl/SettingsServerClientManager.js';
|
|
3
|
+
import type { HTTPAPICallerBasicAuth } from '../../../../std/index.js';
|
|
4
|
+
import type { AuthDataStore } from '../AuthDataStore.js';
|
|
5
|
+
import type { ServerClientManager, ServerClientManagerOpts } from '../ServerClientManager.js';
|
|
6
|
+
export declare class MixedServerClientManager implements ServerClientManager {
|
|
7
|
+
private authDataStore;
|
|
8
|
+
private settingsServerClientManager;
|
|
9
|
+
constructor(authDataStore: AuthDataStore, settingsServerClientManager: SettingsServerClientManager);
|
|
10
|
+
authApiKey(opts?: ServerClientManagerOpts): Promise<ApiKey | null>;
|
|
11
|
+
authBasic(opts?: ServerClientManagerOpts): Promise<HTTPAPICallerBasicAuth | null>;
|
|
12
|
+
authJWT(_opts?: ServerClientManagerOpts): Promise<JWT | null>;
|
|
13
|
+
baseURL(opts?: ServerClientManagerOpts): Promise<URL>;
|
|
14
|
+
publicApiKey(opts?: ServerClientManagerOpts): Promise<ApiKey | null>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { inject, injectable } from 'inversify';
|
|
14
|
+
import { SettingsServerClientManager } from '../../../../std/impl/SettingsServerClientManager.js';
|
|
15
|
+
let MixedServerClientManager = class MixedServerClientManager {
|
|
16
|
+
authDataStore;
|
|
17
|
+
settingsServerClientManager;
|
|
18
|
+
constructor(authDataStore, settingsServerClientManager) {
|
|
19
|
+
this.authDataStore = authDataStore;
|
|
20
|
+
this.settingsServerClientManager = settingsServerClientManager;
|
|
21
|
+
}
|
|
22
|
+
async authApiKey(opts) {
|
|
23
|
+
return this.settingsServerClientManager.authApiKey(opts);
|
|
24
|
+
}
|
|
25
|
+
async authBasic(opts) {
|
|
26
|
+
return this.settingsServerClientManager.authBasic(opts);
|
|
27
|
+
}
|
|
28
|
+
async authJWT(_opts) {
|
|
29
|
+
return this.authDataStore.get();
|
|
30
|
+
}
|
|
31
|
+
async baseURL(opts) {
|
|
32
|
+
return this.settingsServerClientManager.baseURL(opts);
|
|
33
|
+
}
|
|
34
|
+
async publicApiKey(opts) {
|
|
35
|
+
return this.settingsServerClientManager.publicApiKey(opts);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
MixedServerClientManager = __decorate([
|
|
39
|
+
injectable(),
|
|
40
|
+
__param(0, inject('AuthDataStore')),
|
|
41
|
+
__param(1, inject(SettingsServerClientManager)),
|
|
42
|
+
__metadata("design:paramtypes", [Object, SettingsServerClientManager])
|
|
43
|
+
], MixedServerClientManager);
|
|
44
|
+
export { MixedServerClientManager };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IllegalArgumentError, } from '../../../error/index.js';
|
|
2
|
+
export function serverErrorJsonSchema(message) {
|
|
3
|
+
return {
|
|
4
|
+
additionalProperties: false,
|
|
5
|
+
properties: {
|
|
6
|
+
message: {
|
|
7
|
+
examples: [message ?? new IllegalArgumentError().message],
|
|
8
|
+
type: 'string',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
required: ['message'],
|
|
12
|
+
type: 'object',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DataType, JSONSchemaObject, JSONSchemaProperty } from '../../../dt/index.js';
|
|
2
|
+
import { type UC, type UCInput, type UCInputField, type UCInputUnwrapped, type UCOPIBase } from '../../../uc/index.js';
|
|
3
|
+
export interface UCInputFieldJsonSchemaDef<T extends DataType> {
|
|
4
|
+
/**
|
|
5
|
+
* Internal types that are not part of the spec
|
|
6
|
+
*/
|
|
7
|
+
internal?: {
|
|
8
|
+
required?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Fields that are part of the spec
|
|
12
|
+
*/
|
|
13
|
+
spec?: JSONSchemaProperty<T>;
|
|
14
|
+
}
|
|
15
|
+
export declare function ucifJsonSchemaDef<T extends DataType>(field: UCInputField<T>): UCInputFieldJsonSchemaDef<T>;
|
|
16
|
+
export declare function ucInputJsonSchema<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): JSONSchemaObject<UCInputUnwrapped<I>>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ucifExamples, ucifIsMandatory, ucifRepeatability, } from '../../../uc/index.js';
|
|
2
|
+
export function ucifJsonSchemaDef(field) {
|
|
3
|
+
const def = {
|
|
4
|
+
internal: {},
|
|
5
|
+
spec: { type: 'string' },
|
|
6
|
+
};
|
|
7
|
+
if (!def.internal || !def.spec) {
|
|
8
|
+
// Just a guard to safely type the rest of the function without using !
|
|
9
|
+
return def;
|
|
10
|
+
}
|
|
11
|
+
const { def: fDef } = field;
|
|
12
|
+
const { type: fType } = fDef;
|
|
13
|
+
def.internal.required = ucifIsMandatory(fDef);
|
|
14
|
+
def.spec = fType.jsonSchemaType();
|
|
15
|
+
if (!def.internal.required && !Array.isArray(def.spec.type)) {
|
|
16
|
+
def.spec.type = [def.spec.type, 'null'];
|
|
17
|
+
}
|
|
18
|
+
const examples = ucifExamples(fDef);
|
|
19
|
+
if (examples) {
|
|
20
|
+
def.spec.examples = examples;
|
|
21
|
+
}
|
|
22
|
+
const options = fType.getOptions();
|
|
23
|
+
if (options) {
|
|
24
|
+
def.spec.enum = options.map((o) => o.value);
|
|
25
|
+
if (!def.internal.required) {
|
|
26
|
+
def.spec.enum.push(null);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const [isRepeatable] = ucifRepeatability(fDef);
|
|
30
|
+
if (isRepeatable) {
|
|
31
|
+
def.spec = {
|
|
32
|
+
items: def.spec,
|
|
33
|
+
type: def.internal.required ? 'array' : ['array', 'null'],
|
|
34
|
+
};
|
|
35
|
+
if (fDef.cardinality?.max !== undefined) {
|
|
36
|
+
def.spec.maxItems = fDef.cardinality?.max;
|
|
37
|
+
}
|
|
38
|
+
if (fDef.cardinality?.min !== undefined) {
|
|
39
|
+
def.spec.minItems = fDef.cardinality?.min;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return def;
|
|
43
|
+
}
|
|
44
|
+
export function ucInputJsonSchema(uc) {
|
|
45
|
+
const res = {
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
properties: {},
|
|
48
|
+
type: 'object',
|
|
49
|
+
};
|
|
50
|
+
for (const f of uc.inputFields) {
|
|
51
|
+
const { key } = f;
|
|
52
|
+
const { internal, spec } = ucifJsonSchemaDef(f);
|
|
53
|
+
if (!spec) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const k = key;
|
|
57
|
+
res.properties[k] = spec;
|
|
58
|
+
if (!internal?.required) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (!res.required) {
|
|
62
|
+
res.required = [];
|
|
63
|
+
}
|
|
64
|
+
res.required.push(k);
|
|
65
|
+
}
|
|
66
|
+
return res;
|
|
67
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DataType, JSONSchemaObject, JSONSchemaProperty } from '../../../dt/index.js';
|
|
2
|
+
import { type UC, type UCInput, type UCOPIBase, type UCOutput, UCOutputField, type UCOutputPart, type UCOutputPartDef } from '../../../uc/index.js';
|
|
3
|
+
export interface UCOutputFieldJsonSchemaDef<T extends DataType> {
|
|
4
|
+
/**
|
|
5
|
+
* Internal types that are not part of the spec
|
|
6
|
+
*/
|
|
7
|
+
internal?: {
|
|
8
|
+
required?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Fields that are part of the spec
|
|
12
|
+
*/
|
|
13
|
+
spec?: JSONSchemaProperty<T>;
|
|
14
|
+
}
|
|
15
|
+
export declare function ucofJsonSchemaDef<OPI extends UCOPIBase, T extends DataType>(field: UCOutputField<OPI, T>): UCOutputFieldJsonSchemaDef<T>;
|
|
16
|
+
export declare function ucOPIJsonSchema<OPI extends UCOPIBase>(part: UCOutputPartDef<NonNullable<OPI>>): JSONSchemaObject<OPI>;
|
|
17
|
+
export declare function ucOutputPartJsonSchema<OPI extends UCOPIBase>(part: UCOutputPartDef<NonNullable<OPI>>): JSONSchemaObject<UCOutputPart<OPI>>;
|
|
18
|
+
export declare function ucOutputPartPaginationJsonSchema<OPI extends UCOPIBase>(): JSONSchemaObject<NonNullable<UCOutputPart<OPI>['pagination']>>;
|
|
19
|
+
export declare function ucOutputJsonSchema<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): JSONSchemaObject<UCOutput<OPI0, OPI1>> | null;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { UCOPIBaseDefFields, UCOutputField, ucofExamples, ucofIsMandatory, ucofRepeatability, } from '../../../uc/index.js';
|
|
2
|
+
export function ucofJsonSchemaDef(field) {
|
|
3
|
+
const def = {
|
|
4
|
+
internal: {},
|
|
5
|
+
spec: { type: 'string' },
|
|
6
|
+
};
|
|
7
|
+
if (!def.internal || !def.spec) {
|
|
8
|
+
// Just a guard to safely type the rest of the function without using !
|
|
9
|
+
return def;
|
|
10
|
+
}
|
|
11
|
+
const { def: fDef } = field;
|
|
12
|
+
const { type: fType } = fDef;
|
|
13
|
+
def.internal.required = ucofIsMandatory(fDef);
|
|
14
|
+
def.spec = fType.jsonSchemaType();
|
|
15
|
+
if (!def.internal.required && !Array.isArray(def.spec.type)) {
|
|
16
|
+
def.spec.type = [def.spec.type, 'null'];
|
|
17
|
+
}
|
|
18
|
+
const examples = ucofExamples(fDef);
|
|
19
|
+
if (examples) {
|
|
20
|
+
def.spec.examples = examples;
|
|
21
|
+
}
|
|
22
|
+
const options = fType.getOptions();
|
|
23
|
+
if (options) {
|
|
24
|
+
def.spec.enum = options.map((o) => o.value);
|
|
25
|
+
if (!def.internal.required) {
|
|
26
|
+
def.spec.enum.push(null);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const [isRepeatable] = ucofRepeatability(fDef);
|
|
30
|
+
if (isRepeatable) {
|
|
31
|
+
def.spec = {
|
|
32
|
+
items: def.spec,
|
|
33
|
+
type: def.internal.required ? 'array' : ['array', 'null'],
|
|
34
|
+
};
|
|
35
|
+
if (fDef.cardinality?.max !== undefined) {
|
|
36
|
+
def.spec.maxItems = fDef.cardinality?.max;
|
|
37
|
+
}
|
|
38
|
+
if (fDef.cardinality?.min !== undefined) {
|
|
39
|
+
def.spec.minItems = fDef.cardinality?.min;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return def;
|
|
43
|
+
}
|
|
44
|
+
export function ucOPIJsonSchema(part) {
|
|
45
|
+
const res = {
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
properties: {},
|
|
48
|
+
type: 'object',
|
|
49
|
+
};
|
|
50
|
+
const allFields = { ...UCOPIBaseDefFields, ...part.fields };
|
|
51
|
+
for (const entry of Object.entries(allFields)) {
|
|
52
|
+
const key = entry[0];
|
|
53
|
+
const fDef = entry[1];
|
|
54
|
+
const f = new UCOutputField(key, fDef);
|
|
55
|
+
const { internal, spec } = ucofJsonSchemaDef(f);
|
|
56
|
+
if (!spec) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const k = key;
|
|
60
|
+
res.properties[k] = spec;
|
|
61
|
+
if (!internal?.required) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!res.required) {
|
|
65
|
+
res.required = [];
|
|
66
|
+
}
|
|
67
|
+
res.required.push(k);
|
|
68
|
+
}
|
|
69
|
+
return res;
|
|
70
|
+
}
|
|
71
|
+
export function ucOutputPartJsonSchema(part) {
|
|
72
|
+
return {
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
properties: {
|
|
75
|
+
items: {
|
|
76
|
+
items: ucOPIJsonSchema(part),
|
|
77
|
+
type: 'array',
|
|
78
|
+
},
|
|
79
|
+
pagination: ucOutputPartPaginationJsonSchema(),
|
|
80
|
+
total: { examples: [1], type: 'integer' },
|
|
81
|
+
},
|
|
82
|
+
required: ['items', 'total'],
|
|
83
|
+
type: 'object',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function ucOutputPartPaginationJsonSchema() {
|
|
87
|
+
return {
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
properties: {
|
|
90
|
+
id: { format: 'uuid', type: 'string' },
|
|
91
|
+
limit: { type: 'integer' },
|
|
92
|
+
offset: { type: 'integer' },
|
|
93
|
+
q: { type: 'string' },
|
|
94
|
+
},
|
|
95
|
+
type: 'object',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export function ucOutputJsonSchema(uc) {
|
|
99
|
+
if (!uc.hasOutputParts()) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const res = {
|
|
103
|
+
additionalProperties: false,
|
|
104
|
+
properties: {},
|
|
105
|
+
type: 'object',
|
|
106
|
+
};
|
|
107
|
+
const part0 = uc.def.io.o?.parts?._0;
|
|
108
|
+
if (!part0) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
res.properties.parts = {
|
|
112
|
+
additionalProperties: false,
|
|
113
|
+
properties: {
|
|
114
|
+
_0: ucOutputPartJsonSchema(part0),
|
|
115
|
+
},
|
|
116
|
+
required: ['_0'],
|
|
117
|
+
type: 'object',
|
|
118
|
+
};
|
|
119
|
+
const part1 = uc.def.io.o?.parts?._1;
|
|
120
|
+
if (!part1) {
|
|
121
|
+
return res;
|
|
122
|
+
}
|
|
123
|
+
res.properties.parts.properties = {
|
|
124
|
+
_1: ucOutputPartJsonSchema(part1),
|
|
125
|
+
};
|
|
126
|
+
res.properties.parts.required?.push('_1');
|
|
127
|
+
return res;
|
|
128
|
+
}
|