libmodulor 0.18.1 → 0.20.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 +41 -0
- package/README.md +1 -1
- package/dist/esm/apps/Helper/src/lib/project.js +8 -8
- package/dist/esm/convention.d.ts +2 -0
- package/dist/esm/convention.js +2 -0
- package/dist/esm/error/index.d.ts +3 -0
- package/dist/esm/error/index.js +3 -0
- package/dist/esm/error/internal/NotAvailableError.d.ts +3 -0
- package/dist/esm/error/internal/NotAvailableError.js +7 -0
- package/dist/esm/error/internal/NotCallableError.d.ts +4 -0
- package/dist/esm/error/internal/NotCallableError.js +7 -0
- package/dist/esm/error/internal/NotImplementedError.d.ts +3 -0
- package/dist/esm/error/internal/NotImplementedError.js +7 -0
- package/dist/esm/index.cloudflare-worker-hono.d.ts +5 -0
- package/dist/esm/index.cloudflare-worker-hono.js +5 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.node-express.d.ts +2 -0
- package/dist/esm/index.node-express.js +2 -0
- package/dist/esm/index.node-hono.d.ts +1 -0
- package/dist/esm/index.node-hono.js +1 -0
- package/dist/esm/product/index.d.ts +1 -0
- package/dist/esm/product/index.js +1 -0
- package/dist/esm/product/workers/SyncProductUCsLoader.d.ts +15 -0
- package/dist/esm/product/workers/SyncProductUCsLoader.js +52 -0
- package/dist/esm/std/ShellCommandExecutor.d.ts +1 -0
- package/dist/esm/std/impl/FakeFSManager.js +2 -1
- package/dist/esm/std/impl/FakeJobManager.d.ts +1 -0
- package/dist/esm/std/impl/FakeJobManager.js +3 -0
- package/dist/esm/std/impl/NodeSpawnShellCommandExecutor.js +6 -0
- package/dist/esm/std/impl/SimpleMapI18nManager.d.ts +2 -0
- package/dist/esm/std/impl/SimpleMapI18nManager.js +14 -8
- package/dist/esm/std/impl/UCDataStoreExternalResourceManager.js +1 -1
- package/dist/esm/std/impl/WebCryptoManager.js +5 -4
- package/dist/esm/std/impl/WebFSManager.js +15 -14
- package/dist/esm/target/edge-worker-hono-server/SyncEdgeWorkerHonoServerManager.d.ts +32 -0
- package/dist/esm/target/edge-worker-hono-server/SyncEdgeWorkerHonoServerManager.js +87 -0
- package/dist/esm/target/lib/mcp-server/MCPServerBooter.d.ts +3 -2
- package/dist/esm/target/lib/mcp-server/MCPServerBooter.js +10 -6
- package/dist/esm/target/lib/react/UCContainer.js +1 -1
- package/dist/esm/target/lib/server/ServerBooter.d.ts +1 -0
- package/dist/esm/target/lib/server/ServerBooter.js +41 -44
- package/dist/esm/target/lib/server/ServerManager.d.ts +7 -0
- package/dist/esm/target/lib/server/SyncEdgeWorkerInitializer.d.ts +17 -0
- package/dist/esm/target/lib/server/SyncEdgeWorkerInitializer.js +76 -0
- package/dist/esm/target/lib/server/funcs.d.ts +3 -0
- package/dist/esm/target/lib/server/funcs.js +11 -0
- package/dist/esm/target/lib/server-express/HelmetMiddlewareBuilder.d.ts +12 -0
- package/dist/esm/target/lib/server-express/HelmetMiddlewareBuilder.js +39 -0
- package/dist/esm/target/lib/server-express/funcs.d.ts +15 -0
- package/dist/esm/target/lib/server-express/funcs.js +103 -0
- package/dist/esm/target/lib/server-hono/funcs.d.ts +10 -0
- package/dist/esm/target/lib/server-hono/funcs.js +72 -0
- package/dist/esm/target/lib/server-node/funcs.d.ts +5 -0
- package/dist/esm/target/lib/server-node/funcs.js +25 -0
- package/dist/esm/target/lib/server-node/types.d.ts +2 -0
- package/dist/esm/target/nextjs-server/NextJSServerManager.d.ts +2 -0
- package/dist/esm/target/nextjs-server/NextJSServerManager.js +6 -0
- package/dist/esm/target/node-core-cli/NodeCoreCLIManager.d.ts +3 -1
- package/dist/esm/target/node-core-cli/NodeCoreCLIManager.js +8 -5
- package/dist/esm/target/node-express-server/NodeExpressServerManager.d.ts +6 -5
- package/dist/esm/target/node-express-server/NodeExpressServerManager.js +16 -103
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.d.ts +7 -5
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.js +16 -67
- package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.d.ts +5 -1
- package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.js +42 -29
- package/dist/esm/testing/AppTester.d.ts +5 -2
- package/dist/esm/testing/AppTester.js +17 -4
- package/dist/esm/testing/UCDataStoreTester.js +3 -3
- package/dist/esm/testing/impl/VitestAppTestSuiteEmitter.js +132 -115
- package/dist/esm/testing/impl/VitestAppTestSuiteRunner.d.ts +2 -3
- package/dist/esm/testing/impl/VitestAppTestSuiteRunner.js +6 -8
- package/dist/esm/testing/workers/checkers/UCDefChecker.d.ts +2 -0
- package/dist/esm/testing/workers/checkers/UCDefChecker.js +4 -1
- package/dist/esm/uc/data-store.d.ts +3 -4
- package/dist/esm/uc/helpers/UCOutputBuilder.js +1 -0
- package/dist/esm/uc/impl/CloudflareD1UCDataStore.d.ts +34 -0
- package/dist/esm/uc/impl/CloudflareD1UCDataStore.js +201 -0
- package/dist/esm/uc/impl/InMemoryUCDataStore.d.ts +3 -2
- package/dist/esm/uc/impl/InMemoryUCDataStore.js +17 -14
- package/dist/esm/uc/impl/KnexUCDataStore.d.ts +3 -2
- package/dist/esm/uc/impl/KnexUCDataStore.js +9 -5
- package/dist/esm/uc/impl/SimpleUCManager.d.ts +1 -1
- package/dist/esm/uc/impl/SimpleUCManager.js +2 -2
- package/dist/esm/uc/manager.d.ts +1 -1
- package/dist/esm/uc/settings/consts.js +1 -1
- package/dist/esm/utils/concerns/Initializable.d.ts +1 -0
- package/dist/esm/utils/ioc/bindCloudflareWorker.d.ts +2 -0
- package/dist/esm/utils/ioc/bindCloudflareWorker.js +15 -0
- package/package.json +17 -14
- package/pnpm-workspace.yaml +1 -1
- package/tsconfig.json +0 -1
|
@@ -0,0 +1,201 @@
|
|
|
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 { NotAvailableError, NotImplementedError } from '../../error/index.js';
|
|
15
|
+
export const ROW_COLS = [
|
|
16
|
+
'aggregateId',
|
|
17
|
+
'appName',
|
|
18
|
+
'createdAt',
|
|
19
|
+
'data',
|
|
20
|
+
'executionMode',
|
|
21
|
+
'id',
|
|
22
|
+
'input',
|
|
23
|
+
'name',
|
|
24
|
+
'organizationId',
|
|
25
|
+
'userId',
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* @alpha This implementation is still a WIP and needs improvement
|
|
29
|
+
*/
|
|
30
|
+
let CloudflareD1UCDataStore = class CloudflareD1UCDataStore {
|
|
31
|
+
settingsManager;
|
|
32
|
+
// Defined as protected and not private so the `assertClient` guard works correctly
|
|
33
|
+
// See https://stackoverflow.com/a/74267363/1259118
|
|
34
|
+
// > Such property type guards only work when the property you are narrowing is not private; if the property is private then this gets narrowed to never because an object with a private property is not assignable to an object with a public property of the same key.
|
|
35
|
+
client;
|
|
36
|
+
constructor(settingsManager) {
|
|
37
|
+
this.settingsManager = settingsManager;
|
|
38
|
+
}
|
|
39
|
+
s() {
|
|
40
|
+
return {
|
|
41
|
+
uc_data_store_ucs_dataset_name: this.settingsManager.get()('uc_data_store_ucs_dataset_name'),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async clear() {
|
|
45
|
+
throw new NotImplementedError('clear');
|
|
46
|
+
}
|
|
47
|
+
async destroy() {
|
|
48
|
+
throw new NotImplementedError('destroy');
|
|
49
|
+
}
|
|
50
|
+
async exists() {
|
|
51
|
+
throw new NotImplementedError('exists');
|
|
52
|
+
}
|
|
53
|
+
async init() {
|
|
54
|
+
throw new NotAvailableError('initSync');
|
|
55
|
+
// Since workers do not accept top-level await, we cannot invoke this method when initiating it.
|
|
56
|
+
// Plus, calling it in every request handler would be overkill and would add too much overhead.
|
|
57
|
+
// In the meantime, process as follows :
|
|
58
|
+
/*
|
|
59
|
+
mkdir path_to_target/migrations
|
|
60
|
+
|
|
61
|
+
cat > path_to_target/migrations/001_init.sql <<'EOF'
|
|
62
|
+
-- Table Definition
|
|
63
|
+
CREATE TABLE IF NOT EXISTS uc_executions (
|
|
64
|
+
"aggregateId" uuid NOT NULL,
|
|
65
|
+
"appName" varchar(255) NOT NULL,
|
|
66
|
+
"createdAt" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
67
|
+
"data" jsonb,
|
|
68
|
+
"executionMode" varchar(255) NOT NULL,
|
|
69
|
+
"id" uuid NOT NULL,
|
|
70
|
+
"input" jsonb,
|
|
71
|
+
"name" varchar(255) NOT NULL,
|
|
72
|
+
"organizationId" uuid,
|
|
73
|
+
"userId" uuid,
|
|
74
|
+
PRIMARY KEY ("id")
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
-- Indices
|
|
78
|
+
CREATE INDEX IF NOT EXISTS uc_executions_aggregate_id_index ON uc_executions (aggregateId);
|
|
79
|
+
CREATE INDEX IF NOT EXISTS uc_executions_name_index ON uc_executions (name);
|
|
80
|
+
CREATE INDEX IF NOT EXISTS uc_executions_organization_id_index ON uc_executions (organizationId);
|
|
81
|
+
CREATE INDEX IF NOT EXISTS uc_executions_user_id_index ON uc_executions (userId);
|
|
82
|
+
EOF
|
|
83
|
+
|
|
84
|
+
pnpm wrangler d1 create my-app-uc-data-store
|
|
85
|
+
pnpm wrangler d1 execute my-app-uc-data-store --cwd path_to_target --local --file=./migrations/001_init.sql
|
|
86
|
+
pnpm wrangler d1 execute my-app-uc-data-store --cwd path_to_target --remote --file=./migrations/001_init.sql
|
|
87
|
+
pnpm wrangler d1 list
|
|
88
|
+
*/
|
|
89
|
+
}
|
|
90
|
+
initSync() {
|
|
91
|
+
throw new NotAvailableError('initSync');
|
|
92
|
+
}
|
|
93
|
+
async read(opts) {
|
|
94
|
+
this.assertClient();
|
|
95
|
+
// TODO : Consider using a query builder (or Google's pipe operator ?) when it gets too complicated or dangerous
|
|
96
|
+
const query = [
|
|
97
|
+
`select * from ${this.s().uc_data_store_ucs_dataset_name}`,
|
|
98
|
+
];
|
|
99
|
+
// Filter
|
|
100
|
+
const where = [];
|
|
101
|
+
const bindings = [];
|
|
102
|
+
if (opts?.filters) {
|
|
103
|
+
const { aggregateId, appName, idWithinInput, name, organizationId, userId, } = opts.filters;
|
|
104
|
+
this.filter(where, bindings, aggregateId, 'aggregateId');
|
|
105
|
+
this.filter(where, bindings, appName, 'appName');
|
|
106
|
+
this.filter(where, bindings, name, 'name');
|
|
107
|
+
this.filter(where, bindings, organizationId, 'organizationId');
|
|
108
|
+
this.filter(where, bindings, userId, 'userId');
|
|
109
|
+
if (idWithinInput !== undefined) {
|
|
110
|
+
// TODO : Implement CloudflareD1UCDataStore.read.opts.filters.idWithinInput
|
|
111
|
+
throw new Error('opts.filters.idWithinInput is not supported yet');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (where.length > 0) {
|
|
115
|
+
query.push('where', where.join(' and '));
|
|
116
|
+
}
|
|
117
|
+
// Sort
|
|
118
|
+
query.push('order by createdAt asc');
|
|
119
|
+
const sql = query.join(' ');
|
|
120
|
+
const { results } = await this.client
|
|
121
|
+
.prepare(sql)
|
|
122
|
+
.bind(...bindings)
|
|
123
|
+
.run();
|
|
124
|
+
const records = results.map((r) => ({
|
|
125
|
+
...r,
|
|
126
|
+
data: JSON.parse(r.data),
|
|
127
|
+
input: JSON.parse(r.input),
|
|
128
|
+
}));
|
|
129
|
+
return {
|
|
130
|
+
records,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async readProjection(_name, _opts) {
|
|
134
|
+
throw new NotImplementedError('readProjection');
|
|
135
|
+
}
|
|
136
|
+
async startTx() {
|
|
137
|
+
throw new NotImplementedError('startTx');
|
|
138
|
+
}
|
|
139
|
+
supportedSpecificBindings() {
|
|
140
|
+
throw new NotImplementedError('supportedSpecificBindings');
|
|
141
|
+
}
|
|
142
|
+
async testKey(_encryptionKey) {
|
|
143
|
+
throw new NotAvailableError('testKey');
|
|
144
|
+
}
|
|
145
|
+
async write(record, _opts) {
|
|
146
|
+
this.assertClient();
|
|
147
|
+
const cols = ROW_COLS.join(', ');
|
|
148
|
+
const placeholders = ROW_COLS.map(() => '?').join(', ');
|
|
149
|
+
// Use variables only for variables declared here => never for data coming from outside this method !
|
|
150
|
+
const query = `insert into ${this.s().uc_data_store_ucs_dataset_name} (${cols}) values (${placeholders})`;
|
|
151
|
+
const values = ROW_COLS.map((c) => {
|
|
152
|
+
const val = record[c];
|
|
153
|
+
if (val instanceof Date) {
|
|
154
|
+
// D1_TYPE_ERROR: Type 'object' not supported for value 'Wed Jun 18 2025 13:32:27 GMT+0200 (Central European Summer Time)
|
|
155
|
+
return val.toISOString();
|
|
156
|
+
}
|
|
157
|
+
if (val !== null && typeof val === 'object') {
|
|
158
|
+
// D1_TYPE_ERROR: Type 'object' not supported for value '[object Object]'
|
|
159
|
+
return JSON.stringify(val);
|
|
160
|
+
}
|
|
161
|
+
return val;
|
|
162
|
+
});
|
|
163
|
+
await this.client
|
|
164
|
+
.prepare(query)
|
|
165
|
+
.bind(...values)
|
|
166
|
+
.run();
|
|
167
|
+
}
|
|
168
|
+
async writeBulk(_records, _opts) {
|
|
169
|
+
throw new NotImplementedError('writeBulk');
|
|
170
|
+
}
|
|
171
|
+
async writeProjection(_name, _data, _opts) {
|
|
172
|
+
throw new NotImplementedError('writeProjection');
|
|
173
|
+
}
|
|
174
|
+
setClient(client) {
|
|
175
|
+
this.client = client;
|
|
176
|
+
}
|
|
177
|
+
assertClient() {
|
|
178
|
+
if (this.client === undefined) {
|
|
179
|
+
throw new Error('You must call UCDataStore#setClient with the D1Database from the context (e.g. hono context)');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
filter(query, bindings, value, field) {
|
|
183
|
+
if (value === undefined) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (Array.isArray(value)) {
|
|
187
|
+
query.push(`${field} in (${value.map(() => '?')})`);
|
|
188
|
+
bindings.push(...value);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
query.push(`${field} = ?`);
|
|
192
|
+
bindings.push(value);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
CloudflareD1UCDataStore = __decorate([
|
|
197
|
+
injectable(),
|
|
198
|
+
__param(0, inject('SettingsManager')),
|
|
199
|
+
__metadata("design:paramtypes", [Object])
|
|
200
|
+
], CloudflareD1UCDataStore);
|
|
201
|
+
export { CloudflareD1UCDataStore };
|
|
@@ -9,10 +9,11 @@ export declare class InMemoryUCDataStore implements UCDataStore {
|
|
|
9
9
|
clear(): Promise<void>;
|
|
10
10
|
destroy(): Promise<void>;
|
|
11
11
|
exists(): Promise<boolean>;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
init(): Promise<void>;
|
|
13
|
+
initSync(): void;
|
|
14
14
|
read<I extends UCInput | undefined = undefined, D extends UCData | null = null>(opts?: UCDataStoreReadOpts<I, D>): Promise<UCDataStoreReadResponse<I, D>>;
|
|
15
15
|
readProjection<T extends object>(): Promise<T[]>;
|
|
16
|
+
startTx(): Promise<UCDataStoreTx['ref']>;
|
|
16
17
|
supportedSpecificBindings(): UCDataStoreWriteProjectionSpecificBinding[];
|
|
17
18
|
testKey(): Promise<void>;
|
|
18
19
|
write<I extends UCInput | undefined = undefined, D extends UCData | null = null>(record: UCDataStoreRecord<I, D>): Promise<void>;
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { injectable } from 'inversify';
|
|
11
|
-
|
|
11
|
+
import { NotImplementedError } from '../../error/index.js';
|
|
12
12
|
function predicate(key, filter) {
|
|
13
13
|
if (filter === null) {
|
|
14
14
|
return (r) => r[key] === null;
|
|
@@ -34,19 +34,10 @@ let InMemoryUCDataStore = class InMemoryUCDataStore {
|
|
|
34
34
|
async exists() {
|
|
35
35
|
return this.entries.length > 0;
|
|
36
36
|
}
|
|
37
|
-
async
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
commit: async () => {
|
|
41
|
-
this.tx = 'committed';
|
|
42
|
-
},
|
|
43
|
-
rollback: async () => {
|
|
44
|
-
this.tx = 'rollbacked';
|
|
45
|
-
this.entries = [];
|
|
46
|
-
},
|
|
47
|
-
};
|
|
37
|
+
async init() {
|
|
38
|
+
// Nothing to do
|
|
48
39
|
}
|
|
49
|
-
|
|
40
|
+
initSync() {
|
|
50
41
|
// Nothing to do
|
|
51
42
|
}
|
|
52
43
|
async read(opts) {
|
|
@@ -81,6 +72,18 @@ let InMemoryUCDataStore = class InMemoryUCDataStore {
|
|
|
81
72
|
async readProjection() {
|
|
82
73
|
return [];
|
|
83
74
|
}
|
|
75
|
+
async startTx() {
|
|
76
|
+
this.tx = 'pending';
|
|
77
|
+
return {
|
|
78
|
+
commit: async () => {
|
|
79
|
+
this.tx = 'committed';
|
|
80
|
+
},
|
|
81
|
+
rollback: async () => {
|
|
82
|
+
this.tx = 'rollbacked';
|
|
83
|
+
this.entries = [];
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
84
87
|
supportedSpecificBindings() {
|
|
85
88
|
return [];
|
|
86
89
|
}
|
|
@@ -94,7 +97,7 @@ let InMemoryUCDataStore = class InMemoryUCDataStore {
|
|
|
94
97
|
this.entries.push(...records);
|
|
95
98
|
}
|
|
96
99
|
async writeProjection() {
|
|
97
|
-
throw new
|
|
100
|
+
throw new NotImplementedError('writeProjection');
|
|
98
101
|
}
|
|
99
102
|
};
|
|
100
103
|
InMemoryUCDataStore = __decorate([
|
|
@@ -26,10 +26,11 @@ export declare class KnexUCDataStore implements Configurable<S>, UCDataStore {
|
|
|
26
26
|
clear(): Promise<void>;
|
|
27
27
|
destroy(): Promise<void>;
|
|
28
28
|
exists(): Promise<boolean>;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
init(): Promise<void>;
|
|
30
|
+
initSync(): void;
|
|
31
31
|
read<I extends UCInput | undefined = undefined, D extends UCData | null = null>(opts?: UCDataStoreReadOpts<I, D>): Promise<UCDataStoreReadResponse<I, D>>;
|
|
32
32
|
readProjection<T extends object>(name: string, opts?: UCDataStoreReadProjectionOpts<T>): Promise<T[]>;
|
|
33
|
+
startTx(): Promise<UCDataStoreTx['ref']>;
|
|
33
34
|
supportedSpecificBindings(): UCDataStoreWriteProjectionSpecificBinding[];
|
|
34
35
|
testKey(_encryptionKey: Uint8Array): Promise<void>;
|
|
35
36
|
write<I extends UCInput | undefined = undefined, D extends UCData | null = null>(record: UCDataStoreRecord<I, D>, opts?: UCDataStoreWriteOpts): Promise<void>;
|
|
@@ -12,6 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from 'inversify';
|
|
14
14
|
import knex, {} from 'knex';
|
|
15
|
+
import { NotAvailableError, NotCallableError } from '../../error/index.js';
|
|
15
16
|
const FILTERS_MAPPING = new Map([
|
|
16
17
|
['aggregateId', 'aggregate_id'],
|
|
17
18
|
['appName', 'app_name'],
|
|
@@ -50,12 +51,12 @@ let KnexUCDataStore = class KnexUCDataStore {
|
|
|
50
51
|
async exists() {
|
|
51
52
|
return this.client.schema.hasTable(this.s().uc_data_store_ucs_dataset_name);
|
|
52
53
|
}
|
|
53
|
-
async
|
|
54
|
-
return this.client.transaction();
|
|
55
|
-
}
|
|
56
|
-
async install() {
|
|
54
|
+
async init() {
|
|
57
55
|
await this.migration001CreateMainTable();
|
|
58
56
|
}
|
|
57
|
+
initSync() {
|
|
58
|
+
throw new NotCallableError('initSync', 'init', 'async-only');
|
|
59
|
+
}
|
|
59
60
|
async read(opts) {
|
|
60
61
|
const query = this.client(this.s().uc_data_store_ucs_dataset_name);
|
|
61
62
|
// Filter
|
|
@@ -100,6 +101,9 @@ let KnexUCDataStore = class KnexUCDataStore {
|
|
|
100
101
|
const records = await query;
|
|
101
102
|
return records;
|
|
102
103
|
}
|
|
104
|
+
async startTx() {
|
|
105
|
+
return this.client.transaction();
|
|
106
|
+
}
|
|
103
107
|
supportedSpecificBindings() {
|
|
104
108
|
const type = this.s().knex_uc_data_store_type;
|
|
105
109
|
switch (type) {
|
|
@@ -113,7 +117,7 @@ let KnexUCDataStore = class KnexUCDataStore {
|
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
async testKey(_encryptionKey) {
|
|
116
|
-
throw new
|
|
120
|
+
throw new NotAvailableError('testKey');
|
|
117
121
|
}
|
|
118
122
|
async write(record, opts) {
|
|
119
123
|
await this.writeBulk([record], opts);
|
|
@@ -32,7 +32,7 @@ export declare class SimpleUCManager implements UCManager {
|
|
|
32
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
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>>;
|
|
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>>;
|
|
37
37
|
persistProjection<T extends object>(name: string, data: T): Promise<void>;
|
|
38
38
|
rollbackTx(): Promise<void>;
|
|
@@ -116,9 +116,9 @@ let SimpleUCManager = class SimpleUCManager {
|
|
|
116
116
|
const init = (await this.ucInitProvider(server.init));
|
|
117
117
|
await init.exec();
|
|
118
118
|
}
|
|
119
|
-
async
|
|
119
|
+
async startTx() {
|
|
120
120
|
this.tx = {
|
|
121
|
-
ref: await this.ucDataStore.
|
|
121
|
+
ref: await this.ucDataStore.startTx(),
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
async persist(uc, data, opts) {
|
package/dist/esm/uc/manager.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface UCManager {
|
|
|
29
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
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>>;
|
|
31
31
|
initServer<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(uc: UC<I, OPI0, OPI1>): Promise<void>;
|
|
32
|
-
|
|
32
|
+
startTx(): Promise<void>;
|
|
33
33
|
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>>;
|
|
34
34
|
persistProjection<T extends object>(name: string, data: T): Promise<void>;
|
|
35
35
|
rollbackTx(): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NodeBufferManager } from '../../std/impl/NodeBufferManager.js';
|
|
2
|
+
import { NodeCryptoManager } from '../../std/impl/NodeCryptoManager.js';
|
|
3
|
+
import { NodeEnvironmentManager } from '../../std/impl/NodeEnvironmentManager.js';
|
|
4
|
+
import { WebFSManager } from '../../std/impl/WebFSManager.js';
|
|
5
|
+
export function bindCloudflareWorker(container) {
|
|
6
|
+
// Reusing the Node.js implementations available with the `nodejs_compat` compatibility flag
|
|
7
|
+
// https://developers.cloudflare.com/workers/runtime-apis/nodejs/#supported-nodejs-apis
|
|
8
|
+
// std
|
|
9
|
+
container.bind('BufferManager').to(NodeBufferManager);
|
|
10
|
+
container.bind('CryptoManager').to(NodeCryptoManager);
|
|
11
|
+
container
|
|
12
|
+
.bind('EnvironmentManager')
|
|
13
|
+
.to(NodeEnvironmentManager);
|
|
14
|
+
container.bind('FSManager').to(WebFSManager);
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libmodulor",
|
|
3
3
|
"description": "A TypeScript library to create platform-agnostic applications",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0",
|
|
5
5
|
"license": "LGPL-3.0",
|
|
6
6
|
"author": "Chafik H'nini <chafik.hnini@gmail.com>",
|
|
7
7
|
"homepage": "https://libmodulor.c100k.eu",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
".": {
|
|
24
24
|
"import": "./dist/esm/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./cloudflare-worker-hono": {
|
|
27
|
+
"import": "./dist/esm/index.cloudflare-worker-hono.js"
|
|
28
|
+
},
|
|
26
29
|
"./locales/en": {
|
|
27
30
|
"import": "./dist/esm/i18n/locales/en.js"
|
|
28
31
|
},
|
|
@@ -78,32 +81,32 @@
|
|
|
78
81
|
"lint:ci": "biome check"
|
|
79
82
|
},
|
|
80
83
|
"devDependencies": {
|
|
81
|
-
"@biomejs/biome": "^2.
|
|
84
|
+
"@biomejs/biome": "^2.1.2"
|
|
82
85
|
},
|
|
83
86
|
"peerDependencies": {
|
|
84
|
-
"@hono/node-server": "^1.
|
|
85
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
86
|
-
"@stricli/core": "^1.
|
|
87
|
+
"@hono/node-server": "^1.17.1",
|
|
88
|
+
"@modelcontextprotocol/sdk": "^1.16.0",
|
|
89
|
+
"@stricli/core": "^1.2.0",
|
|
87
90
|
"buffer": "^6.0.3",
|
|
88
91
|
"cookie-parser": "^1.4.7",
|
|
89
92
|
"express": "^5.1.0",
|
|
90
|
-
"express-fileupload": "^1.5.
|
|
91
|
-
"fast-check": "^4.
|
|
93
|
+
"express-fileupload": "^1.5.2",
|
|
94
|
+
"fast-check": "^4.2.0",
|
|
92
95
|
"helmet": "^8.1.0",
|
|
93
|
-
"hono": "^4.
|
|
94
|
-
"inversify": "^7.
|
|
95
|
-
"jose": "^6.0.
|
|
96
|
+
"hono": "^4.8.5",
|
|
97
|
+
"inversify": "^7.6.1",
|
|
98
|
+
"jose": "^6.0.12",
|
|
96
99
|
"knex": "^3.1.0",
|
|
97
|
-
"next": "^15.
|
|
98
|
-
"pg": "^8.16.
|
|
100
|
+
"next": "^15.4.2",
|
|
101
|
+
"pg": "^8.16.3",
|
|
99
102
|
"react": "^19.1.0",
|
|
100
103
|
"react-dom": "^19.1.0",
|
|
101
|
-
"react-native": "^0.79.
|
|
104
|
+
"react-native": "^0.79.5",
|
|
102
105
|
"reflect-metadata": "^0.2.2",
|
|
103
106
|
"sqlite3": "^5.1.7",
|
|
104
107
|
"typescript": "^5.8.3",
|
|
105
108
|
"vite": "^6.3.5",
|
|
106
|
-
"vitest": "^3.2.
|
|
109
|
+
"vitest": "^3.2.4"
|
|
107
110
|
},
|
|
108
111
|
"peerDependenciesMeta": {
|
|
109
112
|
"@hono/node-server": {
|
package/pnpm-workspace.yaml
CHANGED