@highstate/backend 0.20.0 → 0.21.1
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/chunk-b05q6fm2.js +37 -0
- package/dist/{chunk-52MY2TCE.js → chunk-gxjwa93h.js} +506 -734
- package/dist/{chunk-X2WG3WGL.js → chunk-vzdz6chj.js} +18 -15
- package/dist/highstate.manifest.json +4 -4
- package/dist/index.js +4020 -3558
- package/dist/library/package-resolution-worker.js +121 -10
- package/dist/library/worker/main.js +27 -16
- package/dist/shared/index.js +254 -4
- package/package.json +15 -16
- package/src/artifact/factory.ts +3 -2
- package/src/library/find-package-json.test.ts +77 -0
- package/src/library/find-package-json.ts +149 -0
- package/src/library/package-resolution-worker.ts +7 -3
- package/src/orchestrator/operation.ts +2 -0
- package/src/orchestrator/operation.update.skip.test.ts +86 -0
- package/src/runner/factory.ts +3 -3
- package/src/runner/force-abort.ts +7 -2
- package/src/runner/local.ts +8 -3
- package/src/runner/pulumi.ts +3 -5
- package/src/services.ts +1 -1
- package/src/terminal/run.sh.ts +9 -4
- package/LICENSE +0 -21
- package/dist/chunk-52MY2TCE.js.map +0 -1
- package/dist/chunk-UAWBPTDW.js +0 -49
- package/dist/chunk-UAWBPTDW.js.map +0 -1
- package/dist/chunk-X2WG3WGL.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/library/package-resolution-worker.js.map +0 -1
- package/dist/library/worker/main.js.map +0 -1
- package/dist/shared/index.js.map +0 -1
|
@@ -1,8 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
1
|
+
// @bun
|
|
2
|
+
import"../chunk-b05q6fm2.js";
|
|
3
|
+
|
|
4
|
+
// src/library/package-resolution-worker.ts
|
|
5
|
+
import { realpath } from "fs/promises";
|
|
6
|
+
import { dirname as dirname2 } from "path";
|
|
7
|
+
import { parentPort, workerData } from "worker_threads";
|
|
8
|
+
import pino from "pino";
|
|
9
|
+
|
|
10
|
+
// src/library/find-package-json.ts
|
|
11
|
+
import { access } from "fs/promises";
|
|
12
|
+
import { dirname, isAbsolute, resolve } from "path";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
async function findPackageJSONCompat(specifier, base) {
|
|
15
|
+
const parsedSpecifier = toPathSpecifier(specifier);
|
|
16
|
+
if (parsedSpecifier.type === "bare") {
|
|
17
|
+
if (!base) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const basePath = resolveBasePath(base);
|
|
21
|
+
const baseDir = await normalizePathForLookup(basePath);
|
|
22
|
+
return await findPackageJsonForBareSpecifier(baseDir, parsedSpecifier.value);
|
|
23
|
+
}
|
|
24
|
+
const resolvedPath = resolvePathSpecifier(parsedSpecifier.value, base);
|
|
25
|
+
const lookupStart = await normalizePathForLookup(resolvedPath);
|
|
26
|
+
return await findNearestPackageJson(lookupStart);
|
|
27
|
+
}
|
|
28
|
+
function toPathSpecifier(specifier) {
|
|
29
|
+
if (specifier instanceof URL) {
|
|
30
|
+
if (specifier.protocol !== "file:") {
|
|
31
|
+
throw new Error(`Unsupported URL protocol "${specifier.protocol}"`);
|
|
32
|
+
}
|
|
33
|
+
return { type: "path", value: fileURLToPath(specifier) };
|
|
34
|
+
}
|
|
35
|
+
if (specifier.startsWith("file:")) {
|
|
36
|
+
return { type: "path", value: fileURLToPath(new URL(specifier)) };
|
|
37
|
+
}
|
|
38
|
+
if (isBareSpecifier(specifier)) {
|
|
39
|
+
return { type: "bare", value: specifier };
|
|
40
|
+
}
|
|
41
|
+
return { type: "path", value: specifier };
|
|
42
|
+
}
|
|
43
|
+
function isBareSpecifier(specifier) {
|
|
44
|
+
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("file:");
|
|
45
|
+
}
|
|
46
|
+
function resolvePathSpecifier(specifierPath, base) {
|
|
47
|
+
if (isAbsolute(specifierPath)) {
|
|
48
|
+
return specifierPath;
|
|
49
|
+
}
|
|
50
|
+
const basePath = base ? resolveBasePath(base) : process.cwd();
|
|
51
|
+
if (specifierPath.startsWith(".")) {
|
|
52
|
+
const baseDir = isLikelyFilePath(basePath) ? dirname(basePath) : basePath;
|
|
53
|
+
return resolve(baseDir, specifierPath);
|
|
54
|
+
}
|
|
55
|
+
return specifierPath;
|
|
56
|
+
}
|
|
57
|
+
function resolveBasePath(base) {
|
|
58
|
+
if (base instanceof URL) {
|
|
59
|
+
if (base.protocol !== "file:") {
|
|
60
|
+
throw new Error(`Unsupported base URL protocol "${base.protocol}"`);
|
|
61
|
+
}
|
|
62
|
+
return fileURLToPath(base);
|
|
63
|
+
}
|
|
64
|
+
if (base.startsWith("file:")) {
|
|
65
|
+
return fileURLToPath(new URL(base));
|
|
66
|
+
}
|
|
67
|
+
return base;
|
|
68
|
+
}
|
|
69
|
+
async function normalizePathForLookup(pathValue) {
|
|
70
|
+
const existsAsFile = await pathExists(pathValue);
|
|
71
|
+
if (existsAsFile && isLikelyFilePath(pathValue)) {
|
|
72
|
+
return dirname(pathValue);
|
|
73
|
+
}
|
|
74
|
+
return pathValue;
|
|
75
|
+
}
|
|
76
|
+
function isLikelyFilePath(pathValue) {
|
|
77
|
+
return pathValue.endsWith(".json") || pathValue.endsWith(".mjs") || pathValue.endsWith(".js");
|
|
78
|
+
}
|
|
79
|
+
async function findNearestPackageJson(startPath) {
|
|
80
|
+
let current = startPath;
|
|
81
|
+
while (true) {
|
|
82
|
+
const candidate = resolve(current, "package.json");
|
|
83
|
+
if (await pathExists(candidate)) {
|
|
84
|
+
return candidate;
|
|
85
|
+
}
|
|
86
|
+
const parent = dirname(current);
|
|
87
|
+
if (parent === current) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
current = parent;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function findPackageJsonForBareSpecifier(startDirectory, packageName) {
|
|
94
|
+
let current = startDirectory;
|
|
95
|
+
while (true) {
|
|
96
|
+
const candidate = resolve(current, "node_modules", packageName, "package.json");
|
|
97
|
+
if (await pathExists(candidate)) {
|
|
98
|
+
return candidate;
|
|
99
|
+
}
|
|
100
|
+
const parent = dirname(current);
|
|
101
|
+
if (parent === current) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
current = parent;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function pathExists(pathValue) {
|
|
108
|
+
try {
|
|
109
|
+
await access(pathValue);
|
|
110
|
+
return true;
|
|
111
|
+
} catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
6
115
|
|
|
7
116
|
// src/library/package-resolution-worker.ts
|
|
8
117
|
var { importPath: rootDir, packageNames, logLevel } = workerData;
|
|
@@ -10,14 +119,18 @@ var logger = pino({ name: "source-resolution-worker", level: logLevel ?? "silent
|
|
|
10
119
|
var results = [];
|
|
11
120
|
for (const packageName of packageNames) {
|
|
12
121
|
try {
|
|
13
|
-
const path =
|
|
122
|
+
const path = await findPackageJSONCompat(packageName, rootDir);
|
|
14
123
|
if (!path) {
|
|
15
|
-
|
|
124
|
+
results.push({
|
|
125
|
+
type: "not-found",
|
|
126
|
+
packageName
|
|
127
|
+
});
|
|
128
|
+
continue;
|
|
16
129
|
}
|
|
17
130
|
results.push({
|
|
18
131
|
type: "success",
|
|
19
132
|
packageName,
|
|
20
|
-
packageRootPath: await realpath(
|
|
133
|
+
packageRootPath: await realpath(dirname2(path))
|
|
21
134
|
});
|
|
22
135
|
} catch (error) {
|
|
23
136
|
logger.error({ error }, `failed to resolve package "%s"`, packageName);
|
|
@@ -39,5 +152,3 @@ parentPort?.postMessage({
|
|
|
39
152
|
type: "result",
|
|
40
153
|
results
|
|
41
154
|
});
|
|
42
|
-
//# sourceMappingURL=package-resolution-worker.js.map
|
|
43
|
-
//# sourceMappingURL=package-resolution-worker.js.map
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import { mapValues } from 'remeda';
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
errorToString
|
|
4
|
+
} from "../../chunk-vzdz6chj.js";
|
|
5
|
+
import"../../chunk-b05q6fm2.js";
|
|
7
6
|
|
|
7
|
+
// src/library/worker/main.ts
|
|
8
|
+
import { parentPort, workerData } from "worker_threads";
|
|
9
|
+
import { pino } from "pino";
|
|
10
|
+
|
|
11
|
+
// src/library/worker/evaluator.ts
|
|
12
|
+
import {
|
|
13
|
+
getRuntimeInstances,
|
|
14
|
+
InstanceNameConflictError,
|
|
15
|
+
parseArgumentValue
|
|
16
|
+
} from "@highstate/contract";
|
|
17
|
+
import { mapValues } from "remeda";
|
|
8
18
|
function toCloneSafeInstanceModel(instance) {
|
|
9
19
|
return JSON.parse(JSON.stringify(instance));
|
|
10
20
|
}
|
|
11
|
-
function evaluateProject(
|
|
21
|
+
function evaluateProject(logger, components, allInstances, resolvedInputs) {
|
|
12
22
|
const allInstancesMap = new Map(allInstances.map((instance) => [instance.id, instance]));
|
|
13
23
|
const instanceErrors = {};
|
|
14
24
|
const topLevelErrors = {};
|
|
15
|
-
const instanceOutputs =
|
|
25
|
+
const instanceOutputs = new Map;
|
|
16
26
|
for (const instance of allInstances) {
|
|
17
27
|
try {
|
|
18
28
|
evaluateInstance(instance.id);
|
|
@@ -57,7 +67,7 @@ function evaluateProject(logger2, components, allInstances, resolvedInputs) {
|
|
|
57
67
|
}
|
|
58
68
|
function _evaluateInstance(instance) {
|
|
59
69
|
const inputs = {};
|
|
60
|
-
|
|
70
|
+
logger.debug(`evaluating instance "%s"`, instance.id);
|
|
61
71
|
for (const [inputName, input] of Object.entries(resolvedInputs[instance.id] ?? {})) {
|
|
62
72
|
inputs[inputName] = input.map((input2) => {
|
|
63
73
|
const evaluated = evaluateInstance(input2.input.instanceId);
|
|
@@ -76,20 +86,23 @@ function evaluateProject(logger2, components, allInstances, resolvedInputs) {
|
|
|
76
86
|
});
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
|
-
|
|
89
|
+
|
|
90
|
+
// src/library/worker/loader.lite.ts
|
|
91
|
+
import { isComponent } from "@highstate/contract";
|
|
92
|
+
async function loadComponents(logger, modulePaths) {
|
|
80
93
|
const modules = {};
|
|
81
94
|
for (const modulePath of modulePaths) {
|
|
82
95
|
try {
|
|
83
|
-
|
|
96
|
+
logger.debug({ modulePath }, "loading module");
|
|
84
97
|
modules[modulePath] = await import(modulePath);
|
|
85
|
-
|
|
98
|
+
logger.debug({ modulePath }, "module loaded");
|
|
86
99
|
} catch (err) {
|
|
87
|
-
|
|
100
|
+
logger.error({ modulePath, err }, "module load failed");
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
const components = {};
|
|
91
104
|
await _loadLibrary(modules, components);
|
|
92
|
-
|
|
105
|
+
logger.debug("library loaded with %s components", Object.keys(components).length);
|
|
93
106
|
return components;
|
|
94
107
|
}
|
|
95
108
|
async function _loadLibrary(value, components) {
|
|
@@ -128,5 +141,3 @@ try {
|
|
|
128
141
|
error: errorToString(error)
|
|
129
142
|
});
|
|
130
143
|
}
|
|
131
|
-
//# sourceMappingURL=main.js.map
|
|
132
|
-
//# sourceMappingURL=main.js.map
|
package/dist/shared/index.js
CHANGED
|
@@ -1,4 +1,254 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
AccessError,
|
|
4
|
+
BackendError,
|
|
5
|
+
BackendUnlockMethodNotFoundError,
|
|
6
|
+
CannotDeleteLastBackendUnlockMethodError,
|
|
7
|
+
CannotDeleteLastUnlockMethodError,
|
|
8
|
+
GraphResolver,
|
|
9
|
+
InputHashResolver,
|
|
10
|
+
InputResolver,
|
|
11
|
+
InstanceLockLostError,
|
|
12
|
+
InstanceLockedError,
|
|
13
|
+
InstanceNotFoundError,
|
|
14
|
+
InstanceStateNotFoundError,
|
|
15
|
+
InvalidInstanceKindError,
|
|
16
|
+
MAX_WORKER_START_ATTEMPTS,
|
|
17
|
+
OperationNotFoundError,
|
|
18
|
+
ProjectLockedError,
|
|
19
|
+
ProjectNotFoundError,
|
|
20
|
+
PromiseTracker,
|
|
21
|
+
SystemSecretNames,
|
|
22
|
+
ValidationResolver,
|
|
23
|
+
WorkerVersionNotFoundError,
|
|
24
|
+
apiKeyMetaSchema,
|
|
25
|
+
apiKeyOutputSchema,
|
|
26
|
+
apiKeyQuerySchema,
|
|
27
|
+
applyLibraryUpdate,
|
|
28
|
+
artifactOutputSchema,
|
|
29
|
+
artifactQuerySchema,
|
|
30
|
+
backendUnlockMethodInputSchema,
|
|
31
|
+
backendUnlockMethodMetaSchema,
|
|
32
|
+
codebaseLibrary,
|
|
33
|
+
codebaseProjectModelStorage,
|
|
34
|
+
collectionQueryResult,
|
|
35
|
+
collectionQuerySchema,
|
|
36
|
+
createAsyncBatcher,
|
|
37
|
+
databaseProjectModelStorage,
|
|
38
|
+
diffLibraries,
|
|
39
|
+
entityDetailsOutputSchema,
|
|
40
|
+
entityOutputSchema,
|
|
41
|
+
entityQuerySchema,
|
|
42
|
+
entityReferenceOutputSchema,
|
|
43
|
+
entitySnapshotDetailsOutputSchema,
|
|
44
|
+
entitySnapshotListItemOutputSchema,
|
|
45
|
+
entitySnapshotOutputSchema,
|
|
46
|
+
extractDigestFromImage,
|
|
47
|
+
finalInstanceOperationStatuses,
|
|
48
|
+
finalOperationStatuses,
|
|
49
|
+
forSchema,
|
|
50
|
+
getAllDependents,
|
|
51
|
+
getMatchedInjectionInstanceInputs,
|
|
52
|
+
getResolvedHubInputs,
|
|
53
|
+
getResolvedInjectionInstanceInputs,
|
|
54
|
+
getResolvedInstanceInputs,
|
|
55
|
+
getResolvedInstanceOutputs,
|
|
56
|
+
getWorkerIdentity,
|
|
57
|
+
globalProjectSpace,
|
|
58
|
+
hasObjectMeta,
|
|
59
|
+
hostPulumiBackend,
|
|
60
|
+
instanceCustomStatusInputSchema,
|
|
61
|
+
instanceLockEventSchema,
|
|
62
|
+
instanceLockOutputSchema,
|
|
63
|
+
instanceStateEventSchema,
|
|
64
|
+
int32ToBytes,
|
|
65
|
+
isFinalOperationStatus,
|
|
66
|
+
isInstanceDeployed,
|
|
67
|
+
isTransientInstanceOperationStatus,
|
|
68
|
+
isTransientOperationStatus,
|
|
69
|
+
isVirtualGhostInstance,
|
|
70
|
+
librarySpecSchema,
|
|
71
|
+
operationEventSchema,
|
|
72
|
+
operationLaunchInputSchema,
|
|
73
|
+
operationMetaSchema,
|
|
74
|
+
operationOptionsSchema,
|
|
75
|
+
operationOutputSchema,
|
|
76
|
+
operationPhaseInstanceSchema,
|
|
77
|
+
operationPhaseSchema,
|
|
78
|
+
operationPhaseTypeSchema,
|
|
79
|
+
operationPlanInputSchema,
|
|
80
|
+
operationStatusSchema,
|
|
81
|
+
operationTypeSchema,
|
|
82
|
+
pageDetailsOutputSchema,
|
|
83
|
+
pageOutputSchema,
|
|
84
|
+
pageQuerySchema,
|
|
85
|
+
projectInputSchema,
|
|
86
|
+
projectModelEventSchema,
|
|
87
|
+
projectModelStorageSpecSchema,
|
|
88
|
+
projectOutputSchema,
|
|
89
|
+
projectUnlockStateSchema,
|
|
90
|
+
projectUnlockSuiteSchema,
|
|
91
|
+
pulumiBackendSpecSchema,
|
|
92
|
+
resolveEffectiveOutputType,
|
|
93
|
+
resolverFactories,
|
|
94
|
+
secretOutputSchema,
|
|
95
|
+
secretQuerySchema,
|
|
96
|
+
serviceAccountOutputSchema,
|
|
97
|
+
serviceAccountQuerySchema,
|
|
98
|
+
stableInstanceInputSchema,
|
|
99
|
+
stableJsonStringify,
|
|
100
|
+
terminalDetailsOutputSchema,
|
|
101
|
+
terminalOutputSchema,
|
|
102
|
+
terminalQuerySchema,
|
|
103
|
+
terminalSessionOutputSchema,
|
|
104
|
+
terminalStatusSchema,
|
|
105
|
+
toApiKeyOutput,
|
|
106
|
+
toCommonEntityMeta,
|
|
107
|
+
toPageOutput,
|
|
108
|
+
toSecretOutput,
|
|
109
|
+
toTerminalDetailsOutput,
|
|
110
|
+
toTerminalOutput,
|
|
111
|
+
toTerminalSessionOutput,
|
|
112
|
+
toWorkerOutput,
|
|
113
|
+
toWorkerVersionOutput,
|
|
114
|
+
triggerOutputSchema,
|
|
115
|
+
triggerQuerySchema,
|
|
116
|
+
unlockMethodInputSchema,
|
|
117
|
+
unlockMethodMetaSchema,
|
|
118
|
+
unlockMethodOutputSchema,
|
|
119
|
+
unlockMethodType,
|
|
120
|
+
waitAll,
|
|
121
|
+
workerOutputSchema,
|
|
122
|
+
workerQuerySchema,
|
|
123
|
+
workerUnitRegistrationEventSchema,
|
|
124
|
+
workerVersionOutputSchema,
|
|
125
|
+
workerVersionStatusEventSchema,
|
|
126
|
+
workerVersionStatusSchema
|
|
127
|
+
} from "../chunk-gxjwa93h.js";
|
|
128
|
+
import"../chunk-b05q6fm2.js";
|
|
129
|
+
export {
|
|
130
|
+
workerVersionStatusSchema,
|
|
131
|
+
workerVersionStatusEventSchema,
|
|
132
|
+
workerVersionOutputSchema,
|
|
133
|
+
workerUnitRegistrationEventSchema,
|
|
134
|
+
workerQuerySchema,
|
|
135
|
+
workerOutputSchema,
|
|
136
|
+
waitAll,
|
|
137
|
+
unlockMethodType,
|
|
138
|
+
unlockMethodOutputSchema,
|
|
139
|
+
unlockMethodMetaSchema,
|
|
140
|
+
unlockMethodInputSchema,
|
|
141
|
+
triggerQuerySchema,
|
|
142
|
+
triggerOutputSchema,
|
|
143
|
+
toWorkerVersionOutput,
|
|
144
|
+
toWorkerOutput,
|
|
145
|
+
toTerminalSessionOutput,
|
|
146
|
+
toTerminalOutput,
|
|
147
|
+
toTerminalDetailsOutput,
|
|
148
|
+
toSecretOutput,
|
|
149
|
+
toPageOutput,
|
|
150
|
+
toCommonEntityMeta,
|
|
151
|
+
toApiKeyOutput,
|
|
152
|
+
terminalStatusSchema,
|
|
153
|
+
terminalSessionOutputSchema,
|
|
154
|
+
terminalQuerySchema,
|
|
155
|
+
terminalOutputSchema,
|
|
156
|
+
terminalDetailsOutputSchema,
|
|
157
|
+
stableJsonStringify,
|
|
158
|
+
stableInstanceInputSchema,
|
|
159
|
+
serviceAccountQuerySchema,
|
|
160
|
+
serviceAccountOutputSchema,
|
|
161
|
+
secretQuerySchema,
|
|
162
|
+
secretOutputSchema,
|
|
163
|
+
resolverFactories,
|
|
164
|
+
resolveEffectiveOutputType,
|
|
165
|
+
pulumiBackendSpecSchema,
|
|
166
|
+
projectUnlockSuiteSchema,
|
|
167
|
+
projectUnlockStateSchema,
|
|
168
|
+
projectOutputSchema,
|
|
169
|
+
projectModelStorageSpecSchema,
|
|
170
|
+
projectModelEventSchema,
|
|
171
|
+
projectInputSchema,
|
|
172
|
+
pageQuerySchema,
|
|
173
|
+
pageOutputSchema,
|
|
174
|
+
pageDetailsOutputSchema,
|
|
175
|
+
operationTypeSchema,
|
|
176
|
+
operationStatusSchema,
|
|
177
|
+
operationPlanInputSchema,
|
|
178
|
+
operationPhaseTypeSchema,
|
|
179
|
+
operationPhaseSchema,
|
|
180
|
+
operationPhaseInstanceSchema,
|
|
181
|
+
operationOutputSchema,
|
|
182
|
+
operationOptionsSchema,
|
|
183
|
+
operationMetaSchema,
|
|
184
|
+
operationLaunchInputSchema,
|
|
185
|
+
operationEventSchema,
|
|
186
|
+
librarySpecSchema,
|
|
187
|
+
isVirtualGhostInstance,
|
|
188
|
+
isTransientOperationStatus,
|
|
189
|
+
isTransientInstanceOperationStatus,
|
|
190
|
+
isInstanceDeployed,
|
|
191
|
+
isFinalOperationStatus,
|
|
192
|
+
int32ToBytes,
|
|
193
|
+
instanceStateEventSchema,
|
|
194
|
+
instanceLockOutputSchema,
|
|
195
|
+
instanceLockEventSchema,
|
|
196
|
+
instanceCustomStatusInputSchema,
|
|
197
|
+
hostPulumiBackend,
|
|
198
|
+
hasObjectMeta,
|
|
199
|
+
globalProjectSpace,
|
|
200
|
+
getWorkerIdentity,
|
|
201
|
+
getResolvedInstanceOutputs,
|
|
202
|
+
getResolvedInstanceInputs,
|
|
203
|
+
getResolvedInjectionInstanceInputs,
|
|
204
|
+
getResolvedHubInputs,
|
|
205
|
+
getMatchedInjectionInstanceInputs,
|
|
206
|
+
getAllDependents,
|
|
207
|
+
forSchema,
|
|
208
|
+
finalOperationStatuses,
|
|
209
|
+
finalInstanceOperationStatuses,
|
|
210
|
+
extractDigestFromImage,
|
|
211
|
+
entitySnapshotOutputSchema,
|
|
212
|
+
entitySnapshotListItemOutputSchema,
|
|
213
|
+
entitySnapshotDetailsOutputSchema,
|
|
214
|
+
entityReferenceOutputSchema,
|
|
215
|
+
entityQuerySchema,
|
|
216
|
+
entityOutputSchema,
|
|
217
|
+
entityDetailsOutputSchema,
|
|
218
|
+
diffLibraries,
|
|
219
|
+
databaseProjectModelStorage,
|
|
220
|
+
createAsyncBatcher,
|
|
221
|
+
collectionQuerySchema,
|
|
222
|
+
collectionQueryResult,
|
|
223
|
+
codebaseProjectModelStorage,
|
|
224
|
+
codebaseLibrary,
|
|
225
|
+
backendUnlockMethodMetaSchema,
|
|
226
|
+
backendUnlockMethodInputSchema,
|
|
227
|
+
artifactQuerySchema,
|
|
228
|
+
artifactOutputSchema,
|
|
229
|
+
applyLibraryUpdate,
|
|
230
|
+
apiKeyQuerySchema,
|
|
231
|
+
apiKeyOutputSchema,
|
|
232
|
+
apiKeyMetaSchema,
|
|
233
|
+
WorkerVersionNotFoundError,
|
|
234
|
+
ValidationResolver,
|
|
235
|
+
SystemSecretNames,
|
|
236
|
+
PromiseTracker,
|
|
237
|
+
ProjectNotFoundError,
|
|
238
|
+
ProjectLockedError,
|
|
239
|
+
OperationNotFoundError,
|
|
240
|
+
MAX_WORKER_START_ATTEMPTS,
|
|
241
|
+
InvalidInstanceKindError,
|
|
242
|
+
InstanceStateNotFoundError,
|
|
243
|
+
InstanceNotFoundError,
|
|
244
|
+
InstanceLockedError,
|
|
245
|
+
InstanceLockLostError,
|
|
246
|
+
InputResolver,
|
|
247
|
+
InputHashResolver,
|
|
248
|
+
GraphResolver,
|
|
249
|
+
CannotDeleteLastUnlockMethodError,
|
|
250
|
+
CannotDeleteLastBackendUnlockMethodError,
|
|
251
|
+
BackendUnlockMethodNotFoundError,
|
|
252
|
+
BackendError,
|
|
253
|
+
AccessError
|
|
254
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@highstate/backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -27,8 +27,19 @@
|
|
|
27
27
|
"platform"
|
|
28
28
|
]
|
|
29
29
|
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "bun run --bun highstate build",
|
|
32
|
+
"typecheck": "tsgo --noEmit --skipLibCheck",
|
|
33
|
+
"biome": "biome check --write --unsafe --error-on-warnings",
|
|
34
|
+
"biome:check": "biome check --error-on-warnings",
|
|
35
|
+
"test": "bun run --bun vitest --run",
|
|
36
|
+
"generate:project": "prisma generate --schema prisma/project",
|
|
37
|
+
"generate:backend": "prisma generate --schema prisma/backend/postgresql && prisma generate --schema prisma/backend/sqlite",
|
|
38
|
+
"migrate": "prisma migrate deploy --config dist/database/local/prisma.config.js"
|
|
39
|
+
},
|
|
30
40
|
"dependencies": {
|
|
31
41
|
"@aws-crypto/crc32": "^5.2.0",
|
|
42
|
+
"@highstate/contract": "0.20.0",
|
|
32
43
|
"@msgpack/msgpack": "^3.1.2",
|
|
33
44
|
"@napi-rs/keyring": "^1.1.8",
|
|
34
45
|
"@noble/ciphers": "^1.3.0",
|
|
@@ -37,7 +48,7 @@
|
|
|
37
48
|
"@prisma/adapter-libsql": "7.4.1",
|
|
38
49
|
"@prisma/client": "7.4.1",
|
|
39
50
|
"@prisma/driver-adapter-utils": "7.4.1",
|
|
40
|
-
"@pulumi/pulumi": "3.
|
|
51
|
+
"@pulumi/pulumi": "3.232.0",
|
|
41
52
|
"age-encryption": "^0.2.3",
|
|
42
53
|
"ajv": "^8.17.1",
|
|
43
54
|
"ansi-colors": "^4.1.3",
|
|
@@ -63,14 +74,12 @@
|
|
|
63
74
|
"uuid": "^11.1.0",
|
|
64
75
|
"watcher": "^2.3.1",
|
|
65
76
|
"yaml": "^2.7.1",
|
|
66
|
-
"zod": "^4.0.5"
|
|
67
|
-
"@highstate/contract": "0.20.0"
|
|
77
|
+
"zod": "^4.0.5"
|
|
68
78
|
},
|
|
69
79
|
"devDependencies": {
|
|
70
80
|
"@biomejs/biome": "2.2.0",
|
|
71
81
|
"@typescript/native-preview": "^7.0.0-dev.20250920.1",
|
|
72
82
|
"classic-level": "^3.0.0",
|
|
73
|
-
"highstate-cli-bootstrap": "npm:@highstate/cli",
|
|
74
83
|
"pino-pretty": "^13.0.0",
|
|
75
84
|
"prisma-json-types-generator": "^3.5.2",
|
|
76
85
|
"rollup": "^4.28.1",
|
|
@@ -80,15 +89,5 @@
|
|
|
80
89
|
},
|
|
81
90
|
"repository": {
|
|
82
91
|
"url": "https://github.com/highstate-io/highstate"
|
|
83
|
-
},
|
|
84
|
-
"scripts": {
|
|
85
|
-
"build": "highstate build",
|
|
86
|
-
"typecheck": "tsgo --noEmit --skipLibCheck",
|
|
87
|
-
"biome": "biome check --write --unsafe --error-on-warnings",
|
|
88
|
-
"biome:check": "biome check --error-on-warnings",
|
|
89
|
-
"test": "vitest --run",
|
|
90
|
-
"generate:project": "prisma generate --schema prisma/project",
|
|
91
|
-
"generate:backend": "prisma generate --schema prisma/backend/postgresql && prisma generate --schema prisma/backend/sqlite",
|
|
92
|
-
"migrate": "prisma migrate deploy --config dist/database/local/prisma.config.js"
|
|
93
92
|
}
|
|
94
|
-
}
|
|
93
|
+
}
|
package/src/artifact/factory.ts
CHANGED
|
@@ -7,17 +7,18 @@ import { LocalArtifactBackend, localArtifactBackendConfig } from "./local"
|
|
|
7
7
|
|
|
8
8
|
export const artifactBackendConfig = z.object({
|
|
9
9
|
HIGHSTATE_ARTIFACT_BACKEND_TYPE: z.enum(["local"]).default("local"),
|
|
10
|
+
HIGHSTATE_ENCRYPTION_ENABLED: z.stringbool().default(true),
|
|
10
11
|
...localArtifactBackendConfig.shape,
|
|
11
12
|
})
|
|
12
13
|
|
|
13
14
|
export async function createArtifactBackend(
|
|
14
|
-
config: z.infer<typeof artifactBackendConfig
|
|
15
|
+
config: z.infer<typeof artifactBackendConfig>,
|
|
15
16
|
database: DatabaseManager,
|
|
16
17
|
logger: Logger,
|
|
17
18
|
): Promise<ArtifactBackend> {
|
|
18
19
|
let backend: ArtifactBackend
|
|
19
20
|
|
|
20
|
-
const fileExtension = config.
|
|
21
|
+
const fileExtension = config.HIGHSTATE_ENCRYPTION_ENABLED ? ".tgz.enc" : ".tgz"
|
|
21
22
|
|
|
22
23
|
switch (config.HIGHSTATE_ARTIFACT_BACKEND_TYPE) {
|
|
23
24
|
case "local": {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"
|
|
2
|
+
import { tmpdir } from "node:os"
|
|
3
|
+
import { resolve } from "node:path"
|
|
4
|
+
import { pathToFileURL } from "node:url"
|
|
5
|
+
import { describe, expect, test } from "vitest"
|
|
6
|
+
import { findPackageJSONCompat } from "./find-package-json"
|
|
7
|
+
|
|
8
|
+
describe("findPackageJSONPolyfill", () => {
|
|
9
|
+
test("resolves bare package name from nearest node_modules ancestor", async () => {
|
|
10
|
+
const sandbox = await mkdtemp(resolve(tmpdir(), "find-package-json-"))
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const projectRoot = resolve(sandbox, "project")
|
|
14
|
+
const appDir = resolve(projectRoot, "apps", "api")
|
|
15
|
+
const packageJsonPath = resolve(projectRoot, "package.json")
|
|
16
|
+
const dependencyPackageJsonPath = resolve(
|
|
17
|
+
projectRoot,
|
|
18
|
+
"node_modules",
|
|
19
|
+
"@highstate",
|
|
20
|
+
"library",
|
|
21
|
+
"package.json",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
await mkdir(resolve(appDir), { recursive: true })
|
|
25
|
+
await mkdir(resolve(projectRoot, "node_modules", "@highstate", "library"), {
|
|
26
|
+
recursive: true,
|
|
27
|
+
})
|
|
28
|
+
await writeFile(packageJsonPath, '{"name":"project"}')
|
|
29
|
+
await writeFile(dependencyPackageJsonPath, '{"name":"@highstate/library"}')
|
|
30
|
+
|
|
31
|
+
const result = await findPackageJSONCompat("@highstate/library", resolve(appDir, "index.ts"))
|
|
32
|
+
|
|
33
|
+
expect(result).toBe(dependencyPackageJsonPath)
|
|
34
|
+
} finally {
|
|
35
|
+
await rm(sandbox, { recursive: true, force: true })
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test("resolves nearest package.json for relative path specifier", async () => {
|
|
40
|
+
const sandbox = await mkdtemp(resolve(tmpdir(), "find-package-json-"))
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const projectRoot = resolve(sandbox, "project")
|
|
44
|
+
const sourceDir = resolve(projectRoot, "src")
|
|
45
|
+
const sourceFile = resolve(sourceDir, "entry.ts")
|
|
46
|
+
const packageJsonPath = resolve(projectRoot, "package.json")
|
|
47
|
+
|
|
48
|
+
await mkdir(sourceDir, { recursive: true })
|
|
49
|
+
await writeFile(packageJsonPath, '{"name":"project"}')
|
|
50
|
+
await writeFile(sourceFile, "export {}")
|
|
51
|
+
|
|
52
|
+
const result = await findPackageJSONCompat("./entry.ts", pathToFileURL(sourceFile))
|
|
53
|
+
|
|
54
|
+
expect(result).toBe(packageJsonPath)
|
|
55
|
+
} finally {
|
|
56
|
+
await rm(sandbox, { recursive: true, force: true })
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test("returns undefined for missing bare package", async () => {
|
|
61
|
+
const sandbox = await mkdtemp(resolve(tmpdir(), "find-package-json-"))
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const projectRoot = resolve(sandbox, "project")
|
|
65
|
+
await mkdir(projectRoot, { recursive: true })
|
|
66
|
+
|
|
67
|
+
const result = await findPackageJSONCompat(
|
|
68
|
+
"missing-package",
|
|
69
|
+
resolve(projectRoot, "index.ts"),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
expect(result).toBeUndefined()
|
|
73
|
+
} finally {
|
|
74
|
+
await rm(sandbox, { recursive: true, force: true })
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
})
|