@highstate/backend 0.4.1 → 0.4.2
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/dist/index.d.ts +498 -338
- package/dist/index.mjs +2155 -513
- package/dist/input-hash-C8HEDMjz.mjs +292 -0
- package/dist/library/worker/main.mjs +169 -0
- package/dist/operation-8k4Tv4dw.d.ts +841 -0
- package/dist/shared/index.d.ts +21 -0
- package/dist/shared/index.mjs +4 -0
- package/package.json +20 -9
- package/dist/library/workers/evaluator.mjs +0 -43
- package/dist/library/workers/loader.mjs +0 -11
- package/dist/shared-B55c8XjT.mjs +0 -36
@@ -0,0 +1,21 @@
|
|
1
|
+
export { I as InstanceModel, u as InstanceRepresentationMeta, b as InstanceState, c as InstanceStatePatch, d as InstanceStatus, r as InstanceStatusField, s as InstanceStatusFieldMap, D as OperationStatus, O as OperationType, P as Position, a as ProjectOperation, e as ProjectOperationRequest, T as TerminalFactory, x as applyInstanceStateFrontendPatch, w as applyInstanceStatePatch, h as compositeInstanceSchema, v as createInstanceState, y as createInstanceStateFrontendPatch, f as instanceInputMapSchema, i as instanceInputSchema, g as instanceModelSchema, m as instanceRepresentationMetaSchema, n as instanceRepresentationSchema, o as instanceStatePatchSchema, q as instanceStateSchema, l as instanceStatusFieldMapSchema, k as instanceStatusFieldSchema, j as instanceStatusSchema, A as operationStatusSchema, z as operationTypeSchema, p as positionSchema, C as projectOperationRequestSchema, B as projectOperationSchema, t as terminalFactorySchema } from '../operation-8k4Tv4dw.js';
|
2
|
+
import { BaseInstanceModel } from '@highstate/contract';
|
3
|
+
import 'zod';
|
4
|
+
|
5
|
+
interface CacheEntry {
|
6
|
+
inputHash: string;
|
7
|
+
dependencies: string[];
|
8
|
+
dependents: string[];
|
9
|
+
}
|
10
|
+
declare class InputHashCalculator {
|
11
|
+
private readonly instances;
|
12
|
+
private readonly cache;
|
13
|
+
private readonly promiseCache;
|
14
|
+
constructor(instances: Map<string, BaseInstanceModel>);
|
15
|
+
reset(instanceId: string): void;
|
16
|
+
calculate(instance: BaseInstanceModel): Promise<string>;
|
17
|
+
calculateFull(instance: BaseInstanceModel): Promise<CacheEntry>;
|
18
|
+
private _calculate;
|
19
|
+
}
|
20
|
+
|
21
|
+
export { type CacheEntry, InputHashCalculator };
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export { I as InputHashCalculator, n as applyInstanceStateFrontendPatch, m as applyInstanceStatePatch, c as compositeInstanceSchema, l as createInstanceState, o as createInstanceStateFrontendPatch, a as instanceInputMapSchema, i as instanceInputSchema, b as instanceModelSchema, g as instanceRepresentationMetaSchema, h as instanceRepresentationSchema, j as instanceStatePatchSchema, k as instanceStateSchema, f as instanceStatusFieldMapSchema, e as instanceStatusFieldSchema, d as instanceStatusSchema, r as operationStatusSchema, q as operationTypeSchema, p as positionSchema, u as projectOperationRequestSchema, s as projectOperationSchema, t as terminalFactorySchema } from '../input-hash-C8HEDMjz.mjs';
|
2
|
+
import 'zod';
|
3
|
+
import '@highstate/contract';
|
4
|
+
import 'crypto-hash';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/backend",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.2",
|
4
4
|
"type": "module",
|
5
5
|
"module": "dist/index.mjs",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -12,48 +12,59 @@
|
|
12
12
|
"types": "./dist/index.d.ts",
|
13
13
|
"default": "./dist/index.mjs"
|
14
14
|
},
|
15
|
-
"./
|
16
|
-
"
|
15
|
+
"./shared": {
|
16
|
+
"types": "./dist/shared/index.d.ts",
|
17
|
+
"default": "./dist/shared/index.mjs"
|
17
18
|
},
|
18
|
-
"./library-
|
19
|
-
"default": "./dist/library/
|
19
|
+
"./library-worker": {
|
20
|
+
"default": "./dist/library/worker/main.mjs"
|
20
21
|
}
|
21
22
|
},
|
22
23
|
"publishConfig": {
|
23
24
|
"access": "public"
|
24
25
|
},
|
25
26
|
"scripts": {
|
26
|
-
"build": "pkgroll --
|
27
|
+
"build": "pkgroll --tsconfig=tsconfig.build.json"
|
27
28
|
},
|
28
29
|
"dependencies": {
|
29
|
-
"@highstate/contract": "^0.4.
|
30
|
+
"@highstate/contract": "^0.4.2",
|
30
31
|
"@trpc/server": "^11.0.0-rc.660",
|
31
32
|
"@types/node": "^22.10.1",
|
32
33
|
"better-lock": "^3.2.0",
|
33
34
|
"consola": "^3.2.3",
|
35
|
+
"crypto-hash": "^3.1.0",
|
34
36
|
"dotenv": "^16.4.7",
|
35
37
|
"import-meta-resolve": "^4.1.0",
|
36
38
|
"ix": "^7.0.0",
|
37
39
|
"jiti": "^2.4.1",
|
40
|
+
"nano-spawn": "^0.2.0",
|
38
41
|
"nypm": "^0.4.1",
|
42
|
+
"pino": "^9.6.0",
|
39
43
|
"pkg-types": "^1.2.1",
|
40
44
|
"remeda": "^2.17.4",
|
45
|
+
"uuidv7": "^1.0.2",
|
41
46
|
"watcher": "^2.3.1",
|
42
47
|
"zod": "^3.23.8"
|
43
48
|
},
|
44
49
|
"peerDependencies": {
|
45
|
-
"@pulumi/pulumi": "^3.142.0"
|
50
|
+
"@pulumi/pulumi": "^3.142.0",
|
51
|
+
"classic-level": "^2.0.0"
|
46
52
|
},
|
47
53
|
"peerDependenciesMeta": {
|
48
54
|
"@pulumi/pulumi": {
|
49
55
|
"optional": true
|
56
|
+
},
|
57
|
+
"classic-level": {
|
58
|
+
"optional": true
|
50
59
|
}
|
51
60
|
},
|
52
61
|
"devDependencies": {
|
53
62
|
"@pulumi/pulumi": "^3.142.0",
|
63
|
+
"classic-level": "^2.0.0",
|
64
|
+
"pino-pretty": "^13.0.0",
|
54
65
|
"pkgroll": "^2.5.1",
|
55
66
|
"rollup": "^4.28.1",
|
56
67
|
"typescript": "^5.7.2"
|
57
68
|
},
|
58
|
-
"gitHead": "
|
69
|
+
"gitHead": "e88c7c588267cf028c054f694d402902dc057919"
|
59
70
|
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import { workerData, parentPort } from 'node:worker_threads';
|
2
|
-
import { getUnitRegistrations } from '@highstate/contract';
|
3
|
-
import { l as loadLibrary } from '../../shared-B55c8XjT.mjs';
|
4
|
-
import 'jiti';
|
5
|
-
|
6
|
-
const library = await loadLibrary(workerData.modulePaths);
|
7
|
-
const instances = workerData.instances;
|
8
|
-
const instanceIds = workerData.instanceIds;
|
9
|
-
const instanceOutputs = {};
|
10
|
-
function evaluateInstance(instanceId, instance) {
|
11
|
-
let outputs = instanceOutputs[instanceId];
|
12
|
-
if (!outputs) {
|
13
|
-
outputs = instanceOutputs[instanceId] = {};
|
14
|
-
}
|
15
|
-
outputs[instance.name] = _evaluateInstance(instance);
|
16
|
-
return outputs;
|
17
|
-
}
|
18
|
-
function _evaluateInstance(instance) {
|
19
|
-
const inputs = {};
|
20
|
-
for (const [inputName, input] of Object.entries(instance.inputs)) {
|
21
|
-
if (!Array.isArray(input)) {
|
22
|
-
const outputs = evaluateInstance(input.instanceId, instances[input.instanceId]);
|
23
|
-
inputs[inputName] = outputs[input.output];
|
24
|
-
continue;
|
25
|
-
}
|
26
|
-
inputs[inputName] = input.map((input2) => {
|
27
|
-
const evaluated = evaluateInstance(input2.instanceId, instances[input2.instanceId]);
|
28
|
-
return evaluated[input2.output];
|
29
|
-
});
|
30
|
-
}
|
31
|
-
return library.components[instance.type]({
|
32
|
-
name: instance.name,
|
33
|
-
args: instance.args,
|
34
|
-
inputs
|
35
|
-
});
|
36
|
-
}
|
37
|
-
for (const [instanceId, instance] of Object.entries(instances)) {
|
38
|
-
if (instanceIds && !instanceIds.includes(instanceId)) {
|
39
|
-
continue;
|
40
|
-
}
|
41
|
-
evaluateInstance(instanceId, instance);
|
42
|
-
}
|
43
|
-
parentPort.postMessage(getUnitRegistrations());
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { workerData, parentPort } from 'node:worker_threads';
|
2
|
-
import { mapValues } from 'remeda';
|
3
|
-
import { l as loadLibrary } from '../../shared-B55c8XjT.mjs';
|
4
|
-
import '@highstate/contract';
|
5
|
-
import 'jiti';
|
6
|
-
|
7
|
-
const library = await loadLibrary(workerData.modulePaths);
|
8
|
-
parentPort.postMessage({
|
9
|
-
components: mapValues(library.components, (component) => component.model),
|
10
|
-
entities: library.entities
|
11
|
-
});
|
package/dist/shared-B55c8XjT.mjs
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
import { isComponent, isEntity } from '@highstate/contract';
|
2
|
-
import { createJiti } from 'jiti';
|
3
|
-
|
4
|
-
async function loadLibrary(modulePaths) {
|
5
|
-
const jiti = createJiti(import.meta.filename);
|
6
|
-
const modules = {};
|
7
|
-
for (const modulePath of modulePaths) {
|
8
|
-
try {
|
9
|
-
modules[modulePath] = await jiti.import(modulePath);
|
10
|
-
} catch (error) {
|
11
|
-
console.warn(`Failed to load module: ${modulePath}`, error);
|
12
|
-
}
|
13
|
-
}
|
14
|
-
const components = {};
|
15
|
-
const entities = {};
|
16
|
-
_loadLibrary(modules, components, entities);
|
17
|
-
return { components, entities };
|
18
|
-
}
|
19
|
-
function _loadLibrary(value, components, entities) {
|
20
|
-
if (isComponent(value)) {
|
21
|
-
components[value.model.type] = value;
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
if (isEntity(value)) {
|
25
|
-
entities[value.type] = value;
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
if (typeof value !== "object" || value === null) {
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
for (const key in value) {
|
32
|
-
_loadLibrary(value[key], components, entities);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
export { loadLibrary as l };
|