@highstate/backend 0.19.1 → 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-V2NILDHS.js → chunk-gxjwa93h.js} +704 -604
- package/dist/{chunk-X2WG3WGL.js → chunk-vzdz6chj.js} +18 -15
- package/dist/highstate.manifest.json +4 -4
- package/dist/index.js +7350 -3514
- package/dist/library/package-resolution-worker.js +121 -10
- package/dist/library/worker/main.js +31 -17
- package/dist/shared/index.js +254 -4
- package/package.json +19 -20
- package/prisma/backend/_schema/object.prisma +12 -0
- package/prisma/backend/sqlite/migrations/20260222113554_add_object_tracking/migration.sql +7 -0
- package/prisma/project/artifact.prisma +3 -0
- package/prisma/project/entity.prisma +125 -0
- package/prisma/project/instance.prisma +6 -0
- package/prisma/project/migrations/20260301210131_add_entity_tracking/migration.sql +70 -0
- package/prisma/project/migrations/20260302212734_add_resource_hooks_flag/migration.sql +1 -0
- package/prisma/project/operation.prisma +3 -0
- package/src/artifact/factory.ts +3 -2
- package/src/business/artifact.test.ts +22 -2
- package/src/business/artifact.ts +7 -1
- package/src/business/entity-snapshot.test.ts +684 -0
- package/src/business/entity-snapshot.ts +904 -0
- package/src/business/evaluation.test.ts +56 -0
- package/src/business/evaluation.ts +102 -22
- package/src/business/global-search.test.ts +344 -0
- package/src/business/global-search.ts +902 -0
- package/src/business/index.ts +4 -0
- package/src/business/instance-lock.ts +58 -74
- package/src/business/instance-state.test.ts +15 -1
- package/src/business/instance-state.ts +37 -14
- package/src/business/object-ref-index.test.ts +140 -0
- package/src/business/object-ref-index.ts +193 -0
- package/src/business/operation.test.ts +15 -1
- package/src/business/operation.ts +4 -0
- package/src/business/project-model.ts +154 -13
- package/src/business/project-unlock.ts +25 -2
- package/src/business/project.ts +9 -0
- package/src/business/secret.test.ts +35 -2
- package/src/business/secret.ts +32 -9
- package/src/business/settings.ts +761 -0
- package/src/business/unit-output.test.ts +477 -0
- package/src/business/unit-output.ts +461 -0
- package/src/business/worker.ts +55 -4
- package/src/database/_generated/backend/postgresql/browser.ts +6 -0
- package/src/database/_generated/backend/postgresql/client.ts +6 -0
- package/src/database/_generated/backend/postgresql/internal/class.ts +23 -5
- package/src/database/_generated/backend/postgresql/internal/prismaNamespace.ts +89 -5
- package/src/database/_generated/backend/postgresql/internal/prismaNamespaceBrowser.ts +9 -0
- package/src/database/_generated/backend/postgresql/models/Object.ts +1076 -0
- package/src/database/_generated/backend/postgresql/models.ts +1 -0
- package/src/database/_generated/backend/sqlite/browser.ts +6 -0
- package/src/database/_generated/backend/sqlite/client.ts +6 -0
- package/src/database/_generated/backend/sqlite/internal/class.ts +23 -5
- package/src/database/_generated/backend/sqlite/internal/prismaNamespace.ts +89 -5
- package/src/database/_generated/backend/sqlite/internal/prismaNamespaceBrowser.ts +9 -0
- package/src/database/_generated/backend/sqlite/models/Object.ts +1074 -0
- package/src/database/_generated/backend/sqlite/models.ts +1 -0
- package/src/database/_generated/project/browser.ts +23 -0
- package/src/database/_generated/project/client.ts +23 -0
- package/src/database/_generated/project/commonInputTypes.ts +87 -53
- package/src/database/_generated/project/enums.ts +8 -0
- package/src/database/_generated/project/internal/class.ts +53 -5
- package/src/database/_generated/project/internal/prismaNamespace.ts +367 -13
- package/src/database/_generated/project/internal/prismaNamespaceBrowser.ts +48 -1
- package/src/database/_generated/project/models/Artifact.ts +199 -11
- package/src/database/_generated/project/models/Entity.ts +1274 -0
- package/src/database/_generated/project/models/EntitySnapshot.ts +2389 -0
- package/src/database/_generated/project/models/EntitySnapshotContent.ts +1260 -0
- package/src/database/_generated/project/models/EntitySnapshotReference.ts +1449 -0
- package/src/database/_generated/project/models/InstanceState.ts +361 -1
- package/src/database/_generated/project/models/Operation.ts +148 -3
- package/src/database/_generated/project/models/OperationLog.ts +0 -4
- package/src/database/_generated/project/models.ts +4 -0
- package/src/database/migration.ts +3 -0
- 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/library/worker/evaluator.ts +7 -1
- package/src/orchestrator/manager.ts +7 -0
- package/src/orchestrator/operation-context.captured-outputs.test.ts +118 -0
- package/src/orchestrator/operation-context.ts +154 -16
- package/src/orchestrator/operation-plan.destroy.test.md +33 -12
- package/src/orchestrator/operation-plan.destroy.test.ts +140 -2
- package/src/orchestrator/operation-plan.fixtures.ts +2 -0
- package/src/orchestrator/operation-plan.md +4 -1
- package/src/orchestrator/operation-plan.ts +286 -92
- package/src/orchestrator/operation-plan.update.test.md +286 -11
- package/src/orchestrator/operation-plan.update.test.ts +656 -5
- package/src/orchestrator/operation-workset.ts +72 -22
- package/src/orchestrator/operation.cancel.test.ts +4 -0
- package/src/orchestrator/operation.composite.test.ts +341 -0
- package/src/orchestrator/operation.destroy.test.ts +4 -0
- package/src/orchestrator/operation.output-validation.failure.test.ts +124 -0
- package/src/orchestrator/operation.preview.test.ts +4 -0
- package/src/orchestrator/operation.refresh.test.ts +4 -0
- package/src/orchestrator/operation.test-utils.ts +52 -13
- package/src/orchestrator/operation.ts +230 -68
- package/src/orchestrator/operation.update.failure.test.ts +4 -0
- package/src/orchestrator/operation.update.skip.test.ts +196 -0
- package/src/orchestrator/operation.update.test.ts +4 -0
- package/src/orchestrator/plan-test-builder.ts +1 -0
- package/src/orchestrator/unit-input-values.test.ts +450 -0
- package/src/orchestrator/unit-input-values.ts +281 -0
- package/src/pubsub/manager.ts +3 -0
- package/src/runner/abstractions.ts +23 -54
- package/src/runner/factory.ts +3 -3
- package/src/runner/force-abort.ts +7 -2
- package/src/runner/local.ts +116 -87
- package/src/runner/pulumi.ts +3 -5
- package/src/services.ts +53 -2
- package/src/shared/models/prisma.ts +1 -0
- package/src/shared/models/project/entity.ts +121 -0
- package/src/shared/models/project/index.ts +1 -0
- package/src/shared/models/project/operation.ts +61 -3
- package/src/shared/models/project/state.ts +10 -0
- package/src/shared/models/project/worker.ts +7 -0
- package/src/shared/resolvers/effective-output-type.test.ts +494 -0
- package/src/shared/resolvers/effective-output-type.ts +162 -0
- package/src/shared/resolvers/index.ts +1 -0
- package/src/shared/resolvers/input.ts +59 -9
- package/src/shared/utils/index.ts +1 -0
- package/src/shared/utils/stable-json.ts +41 -0
- package/src/terminal/manager.ts +6 -0
- package/src/terminal/run.sh.ts +9 -4
- package/src/worker/manager.ts +97 -1
- package/LICENSE +0 -21
- package/dist/chunk-I7BWSAN6.js +0 -49
- package/dist/chunk-I7BWSAN6.js.map +0 -1
- package/dist/chunk-V2NILDHS.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,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { z as z$1 } from 'zod';
|
|
3
|
-
import { mapValues, constant, unique, fromEntries } from 'remeda';
|
|
4
|
-
import { crc32 } from '@aws-crypto/crc32';
|
|
5
|
-
import { encode } from '@msgpack/msgpack';
|
|
6
|
-
import { Buffer } from 'buffer-polyfill';
|
|
7
|
-
import { Ajv } from 'ajv';
|
|
8
|
-
import styles from 'ansi-styles';
|
|
9
|
-
|
|
1
|
+
// @bun
|
|
10
2
|
// src/shared/models/backend/library.ts
|
|
3
|
+
import { z } from "@highstate/contract";
|
|
11
4
|
var librarySpecSchema = z.discriminatedUnion("type", [
|
|
12
5
|
z.object({
|
|
13
6
|
type: z.literal("host")
|
|
@@ -55,6 +48,8 @@ function applyLibraryUpdate(components, entities, update) {
|
|
|
55
48
|
break;
|
|
56
49
|
}
|
|
57
50
|
}
|
|
51
|
+
// src/shared/models/backend/project.ts
|
|
52
|
+
import { commonObjectMetaSchema, genericNameSchema, timestampsSchema, z as z2 } from "@highstate/contract";
|
|
58
53
|
|
|
59
54
|
// src/shared/models/backend/well-known.ts
|
|
60
55
|
var globalProjectSpace = {
|
|
@@ -104,219 +99,202 @@ var databaseProjectModelStorage = {
|
|
|
104
99
|
};
|
|
105
100
|
|
|
106
101
|
// src/shared/models/backend/project.ts
|
|
107
|
-
var projectModelStorageSpecSchema =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* The project model is stored in the codebase where Highstate is running.
|
|
111
|
-
*/
|
|
112
|
-
type: z.literal("codebase")
|
|
102
|
+
var projectModelStorageSpecSchema = z2.discriminatedUnion("type", [
|
|
103
|
+
z2.object({
|
|
104
|
+
type: z2.literal("codebase")
|
|
113
105
|
}),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* The project model is stored in the project database alongside the project data.
|
|
117
|
-
*/
|
|
118
|
-
type: z.literal("database")
|
|
106
|
+
z2.object({
|
|
107
|
+
type: z2.literal("database")
|
|
119
108
|
})
|
|
120
109
|
]);
|
|
121
|
-
var projectInputSchema =
|
|
110
|
+
var projectInputSchema = z2.object({
|
|
122
111
|
name: genericNameSchema,
|
|
123
|
-
spaceId:
|
|
124
|
-
modelStorageId:
|
|
125
|
-
libraryId:
|
|
126
|
-
pulumiBackendId:
|
|
112
|
+
spaceId: z2.cuid2().default(globalProjectSpace.id),
|
|
113
|
+
modelStorageId: z2.cuid2().default(codebaseProjectModelStorage.id),
|
|
114
|
+
libraryId: z2.cuid2().default(codebaseLibrary.id),
|
|
115
|
+
pulumiBackendId: z2.cuid2().default(hostPulumiBackend.id),
|
|
127
116
|
meta: commonObjectMetaSchema
|
|
128
117
|
});
|
|
129
|
-
var projectOutputSchema =
|
|
130
|
-
id:
|
|
118
|
+
var projectOutputSchema = z2.object({
|
|
119
|
+
id: z2.string(),
|
|
131
120
|
name: genericNameSchema,
|
|
132
121
|
meta: commonObjectMetaSchema,
|
|
133
|
-
spaceId:
|
|
134
|
-
modelStorageId:
|
|
135
|
-
libraryId:
|
|
136
|
-
pulumiBackendId:
|
|
122
|
+
spaceId: z2.cuid2(),
|
|
123
|
+
modelStorageId: z2.cuid2(),
|
|
124
|
+
libraryId: z2.cuid2(),
|
|
125
|
+
pulumiBackendId: z2.cuid2(),
|
|
137
126
|
...timestampsSchema.shape
|
|
138
127
|
});
|
|
139
|
-
var projectUnlockSuiteSchema =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*
|
|
143
|
-
* The frontend should try to decrypt at least one of these identities
|
|
144
|
-
* using the password or passkey.
|
|
145
|
-
*/
|
|
146
|
-
encryptedIdentities: z.array(z.string()),
|
|
147
|
-
/**
|
|
148
|
-
* Whether one of the identities is a passkey and user should be asked to use it.
|
|
149
|
-
*/
|
|
150
|
-
hasPasskey: z.boolean()
|
|
128
|
+
var projectUnlockSuiteSchema = z2.object({
|
|
129
|
+
encryptedIdentities: z2.array(z2.string()),
|
|
130
|
+
hasPasskey: z2.boolean()
|
|
151
131
|
});
|
|
152
|
-
var projectUnlockStateSchema =
|
|
153
|
-
|
|
154
|
-
type:
|
|
132
|
+
var projectUnlockStateSchema = z2.discriminatedUnion("type", [
|
|
133
|
+
z2.object({
|
|
134
|
+
type: z2.literal("locked"),
|
|
155
135
|
unlockSuite: projectUnlockSuiteSchema.optional()
|
|
156
136
|
}),
|
|
157
|
-
|
|
158
|
-
type:
|
|
137
|
+
z2.object({
|
|
138
|
+
type: z2.literal("unlocked")
|
|
159
139
|
})
|
|
160
140
|
]);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* The backend is expected to be configured with the `pulumi login` command by the user.
|
|
167
|
-
*/
|
|
168
|
-
type: z.literal("host")
|
|
141
|
+
// src/shared/models/backend/pulumi.ts
|
|
142
|
+
import { z as z3 } from "@highstate/contract";
|
|
143
|
+
var pulumiBackendSpecSchema = z3.discriminatedUnion("type", [
|
|
144
|
+
z3.object({
|
|
145
|
+
type: z3.literal("host")
|
|
169
146
|
})
|
|
170
147
|
]);
|
|
148
|
+
// src/shared/models/backend/unlock-method.ts
|
|
149
|
+
import { objectMetaSchema } from "@highstate/contract";
|
|
150
|
+
import { z as z4 } from "zod";
|
|
171
151
|
var backendUnlockMethodMetaSchema = objectMetaSchema.pick({ title: true, description: true }).required({ title: true });
|
|
172
|
-
var backendUnlockMethodInputSchema =
|
|
152
|
+
var backendUnlockMethodInputSchema = z4.object({
|
|
173
153
|
meta: backendUnlockMethodMetaSchema,
|
|
174
|
-
recipient:
|
|
154
|
+
recipient: z4.string()
|
|
175
155
|
});
|
|
156
|
+
// src/shared/models/base.ts
|
|
157
|
+
import { constant, mapValues } from "remeda";
|
|
158
|
+
import { z as z5 } from "zod";
|
|
176
159
|
function hasObjectMeta(value) {
|
|
177
160
|
return typeof value === "object" && value !== null && "meta" in value;
|
|
178
161
|
}
|
|
179
|
-
var sortBySchema =
|
|
180
|
-
key:
|
|
181
|
-
order:
|
|
162
|
+
var sortBySchema = z5.object({
|
|
163
|
+
key: z5.string(),
|
|
164
|
+
order: z5.enum(["asc", "desc"])
|
|
182
165
|
});
|
|
183
|
-
var collectionQuerySchema =
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* The sorting configuration for the results.
|
|
190
|
-
*
|
|
191
|
-
* Can be a single sort field or an array of sort fields.
|
|
192
|
-
* Each sort field contains the key and order.
|
|
193
|
-
*/
|
|
194
|
-
sortBy: z$1.array(sortBySchema).optional(),
|
|
195
|
-
/**
|
|
196
|
-
* The number of items to skip.
|
|
197
|
-
*
|
|
198
|
-
* Defaults to 0 if not specified.
|
|
199
|
-
*/
|
|
200
|
-
skip: z$1.number().int().nonnegative().default(0).optional(),
|
|
201
|
-
/**
|
|
202
|
-
* The count of documents to return.
|
|
203
|
-
*
|
|
204
|
-
* Defaults to 20 if not specified.
|
|
205
|
-
* Maximum value is 100.
|
|
206
|
-
*/
|
|
207
|
-
count: z$1.number().int().positive().max(100).default(20).optional()
|
|
166
|
+
var collectionQuerySchema = z5.object({
|
|
167
|
+
search: z5.string().optional(),
|
|
168
|
+
sortBy: z5.array(sortBySchema).optional(),
|
|
169
|
+
skip: z5.number().int().nonnegative().default(0).optional(),
|
|
170
|
+
count: z5.number().int().positive().max(100).default(20).optional()
|
|
208
171
|
});
|
|
209
172
|
function collectionQueryResult(schema) {
|
|
210
|
-
return
|
|
211
|
-
items:
|
|
212
|
-
total:
|
|
173
|
+
return z5.object({
|
|
174
|
+
items: z5.array(schema),
|
|
175
|
+
total: z5.number().int().nonnegative()
|
|
213
176
|
});
|
|
214
177
|
}
|
|
215
178
|
function forSchema(schema) {
|
|
216
179
|
return mapValues(schema.shape, constant(true));
|
|
217
180
|
}
|
|
218
|
-
|
|
219
181
|
// src/shared/models/errors.ts
|
|
220
|
-
|
|
182
|
+
class BackendError extends Error {
|
|
221
183
|
constructor(message, cause) {
|
|
222
184
|
super(message, { cause });
|
|
223
185
|
this.name = "BackendError";
|
|
224
186
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
class AccessError extends BackendError {
|
|
227
190
|
constructor(message) {
|
|
228
191
|
super(message);
|
|
229
192
|
this.name = "AccessError";
|
|
230
193
|
}
|
|
231
|
-
}
|
|
232
|
-
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
class ProjectLockedError extends AccessError {
|
|
233
197
|
constructor(projectId) {
|
|
234
198
|
super(`The project with ID "${projectId}" is locked, decryption is not possible.`);
|
|
235
199
|
}
|
|
236
|
-
}
|
|
237
|
-
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
class ProjectNotFoundError extends BackendError {
|
|
238
203
|
constructor(projectId) {
|
|
239
204
|
super(`Project with ID "${projectId}" not found.`);
|
|
240
205
|
this.name = "ProjectNotFoundError";
|
|
241
206
|
}
|
|
242
|
-
}
|
|
243
|
-
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
class CannotDeleteLastUnlockMethodError extends BackendError {
|
|
244
210
|
constructor(projectId) {
|
|
245
211
|
super(`Refused to delete the last unlock method for project "${projectId}".`);
|
|
246
212
|
this.name = "CannotDeleteLastUnlockMethodError";
|
|
247
213
|
}
|
|
248
|
-
}
|
|
249
|
-
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
class InstanceNotFoundError extends BackendError {
|
|
250
217
|
constructor(projectId, instanceId) {
|
|
251
218
|
super(`Instance with ID "${instanceId}" not found in project "${projectId}".`);
|
|
252
219
|
this.name = "InstanceNotFoundError";
|
|
253
220
|
}
|
|
254
|
-
}
|
|
255
|
-
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
class InvalidInstanceKindError extends BackendError {
|
|
256
224
|
constructor(projectId, instanceId, expectedKind, actualKind) {
|
|
257
|
-
super(
|
|
258
|
-
`Instance "${instanceId}" in project "${projectId}" has kind "${actualKind}", but expected "${expectedKind}".`
|
|
259
|
-
);
|
|
225
|
+
super(`Instance "${instanceId}" in project "${projectId}" has kind "${actualKind}", but expected "${expectedKind}".`);
|
|
260
226
|
this.name = "InvalidInstanceKindError";
|
|
261
227
|
}
|
|
262
|
-
}
|
|
263
|
-
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
class OperationNotFoundError extends BackendError {
|
|
264
231
|
constructor(projectId, operationId) {
|
|
265
232
|
super(`Operation with ID "${operationId}" not found in project "${projectId}".`);
|
|
266
233
|
this.name = "OperationNotFoundError";
|
|
267
234
|
}
|
|
268
|
-
}
|
|
269
|
-
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
class InstanceLockLostError extends BackendError {
|
|
270
238
|
constructor(projectId, instanceIds, token) {
|
|
271
|
-
super(
|
|
272
|
-
`Instance lock lost for instances [${instanceIds.join(", ")}] in project "${projectId}" with token "${token}".`
|
|
273
|
-
);
|
|
239
|
+
super(`Instance lock lost for instances [${instanceIds.join(", ")}] in project "${projectId}" with token "${token}".`);
|
|
274
240
|
this.name = "InstanceLockLostError";
|
|
275
241
|
}
|
|
276
|
-
}
|
|
277
|
-
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
class InstanceStateNotFoundError extends BackendError {
|
|
278
245
|
constructor(projectId, instanceId) {
|
|
279
246
|
super(`State for instance with ID "${instanceId}" not found in project "${projectId}".`);
|
|
280
247
|
this.name = "InstanceStateNotFoundError";
|
|
281
248
|
}
|
|
282
|
-
}
|
|
283
|
-
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
class InstanceLockedError extends BackendError {
|
|
284
252
|
constructor(projectId, instanceId) {
|
|
285
253
|
super(`Instance with ID "${instanceId}" in project "${projectId}" is locked.`);
|
|
286
254
|
this.name = "InstanceLockedError";
|
|
287
255
|
}
|
|
288
|
-
}
|
|
289
|
-
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
class WorkerVersionNotFoundError extends BackendError {
|
|
290
259
|
constructor(projectId, workerVersionId) {
|
|
291
260
|
super(`Worker version with ID "${workerVersionId}" not found in project "${projectId}".`);
|
|
292
261
|
this.name = "WorkerVersionNotFoundError";
|
|
293
262
|
}
|
|
294
|
-
}
|
|
295
|
-
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
class BackendUnlockMethodNotFoundError extends BackendError {
|
|
296
266
|
constructor(id) {
|
|
297
267
|
super(`Backend unlock method with ID "${id}" not found.`);
|
|
298
268
|
this.name = "BackendUnlockMethodNotFoundError";
|
|
299
269
|
}
|
|
300
|
-
}
|
|
301
|
-
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
class CannotDeleteLastBackendUnlockMethodError extends BackendError {
|
|
302
273
|
constructor() {
|
|
303
274
|
super(`Refused to delete the last backend unlock method.`);
|
|
304
275
|
this.name = "CannotDeleteLastBackendUnlockMethodError";
|
|
305
276
|
}
|
|
306
|
-
}
|
|
307
|
-
|
|
277
|
+
}
|
|
278
|
+
// src/shared/models/project/api-key.ts
|
|
279
|
+
import {
|
|
280
|
+
commonObjectMetaSchema as commonObjectMetaSchema2,
|
|
281
|
+
objectMetaSchema as objectMetaSchema2,
|
|
282
|
+
serviceAccountMetaSchema,
|
|
283
|
+
z as z6
|
|
284
|
+
} from "@highstate/contract";
|
|
285
|
+
var apiKeyMetaSchema = objectMetaSchema2.pick({
|
|
308
286
|
title: true,
|
|
309
287
|
description: true
|
|
310
288
|
}).required({ title: true });
|
|
311
|
-
var apiKeyOutputSchema =
|
|
312
|
-
id:
|
|
313
|
-
meta:
|
|
314
|
-
serviceAccountId:
|
|
289
|
+
var apiKeyOutputSchema = z6.object({
|
|
290
|
+
id: z6.cuid2(),
|
|
291
|
+
meta: commonObjectMetaSchema2,
|
|
292
|
+
serviceAccountId: z6.cuid2(),
|
|
315
293
|
serviceAccountMeta: serviceAccountMetaSchema.nullable(),
|
|
316
|
-
createdAt:
|
|
294
|
+
createdAt: z6.date()
|
|
317
295
|
});
|
|
318
296
|
var apiKeyQuerySchema = collectionQuerySchema.extend({
|
|
319
|
-
serviceAccountId:
|
|
297
|
+
serviceAccountId: z6.string().optional()
|
|
320
298
|
});
|
|
321
299
|
function toApiKeyOutput(apiKey, serviceAccount) {
|
|
322
300
|
return {
|
|
@@ -324,230 +302,184 @@ function toApiKeyOutput(apiKey, serviceAccount) {
|
|
|
324
302
|
serviceAccountMeta: serviceAccount?.meta ?? null
|
|
325
303
|
};
|
|
326
304
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
305
|
+
// src/shared/models/project/artifact.ts
|
|
306
|
+
import { commonObjectMetaSchema as commonObjectMetaSchema3 } from "@highstate/contract";
|
|
307
|
+
import { z as z7 } from "zod";
|
|
308
|
+
var artifactOutputSchema = z7.object({
|
|
309
|
+
id: z7.cuid2(),
|
|
310
|
+
hash: z7.string(),
|
|
311
|
+
size: z7.number(),
|
|
312
|
+
meta: commonObjectMetaSchema3,
|
|
313
|
+
createdAt: z7.date(),
|
|
314
|
+
updatedAt: z7.date()
|
|
334
315
|
});
|
|
335
316
|
var artifactQuerySchema = collectionQuerySchema.extend({
|
|
336
|
-
stateId:
|
|
337
|
-
serviceAccountId:
|
|
338
|
-
terminalId:
|
|
339
|
-
pageId:
|
|
317
|
+
stateId: z7.string().optional(),
|
|
318
|
+
serviceAccountId: z7.string().optional(),
|
|
319
|
+
terminalId: z7.string().optional(),
|
|
320
|
+
pageId: z7.string().optional()
|
|
340
321
|
});
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
322
|
+
// src/shared/models/project/custom-status.ts
|
|
323
|
+
import { commonObjectMetaSchema as commonObjectMetaSchema4 } from "@highstate/contract";
|
|
324
|
+
import { z as z8 } from "zod";
|
|
325
|
+
var instanceCustomStatusInputSchema = z8.object({
|
|
326
|
+
name: z8.string(),
|
|
327
|
+
meta: commonObjectMetaSchema4,
|
|
328
|
+
value: z8.string(),
|
|
329
|
+
message: z8.string().optional(),
|
|
330
|
+
order: z8.number().min(0).max(100).optional()
|
|
347
331
|
});
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
332
|
+
// src/shared/models/project/entity.ts
|
|
333
|
+
import { commonObjectMetaSchema as commonObjectMetaSchema5 } from "@highstate/contract";
|
|
334
|
+
import { z as z9 } from "zod";
|
|
335
|
+
var rawEntityMetaSchema = z9.object({
|
|
336
|
+
identity: z9.string().optional(),
|
|
337
|
+
title: z9.string().optional(),
|
|
338
|
+
description: z9.string().optional(),
|
|
339
|
+
icon: z9.string().optional(),
|
|
340
|
+
iconColor: z9.string().optional()
|
|
341
|
+
}).passthrough();
|
|
342
|
+
var entityOutputSchema = z9.object({
|
|
343
|
+
id: z9.string(),
|
|
344
|
+
type: z9.string(),
|
|
345
|
+
identity: z9.string(),
|
|
346
|
+
meta: commonObjectMetaSchema5,
|
|
347
|
+
snapshotId: z9.string().optional(),
|
|
348
|
+
createdAt: z9.date().optional()
|
|
349
|
+
});
|
|
350
|
+
var entityQuerySchema = collectionQuerySchema.extend({
|
|
351
|
+
type: z9.string().optional()
|
|
352
|
+
});
|
|
353
|
+
var entitySnapshotOutputSchema = z9.object({
|
|
354
|
+
id: z9.string(),
|
|
355
|
+
meta: commonObjectMetaSchema5,
|
|
356
|
+
content: z9.unknown(),
|
|
357
|
+
operationId: z9.string(),
|
|
358
|
+
stateId: z9.string(),
|
|
359
|
+
referencedInOutputs: z9.string().array(),
|
|
360
|
+
exportedInOutputs: z9.string().array(),
|
|
361
|
+
createdAt: z9.date()
|
|
352
362
|
});
|
|
353
|
-
var
|
|
354
|
-
|
|
355
|
-
|
|
363
|
+
var entitySnapshotListItemOutputSchema = z9.object({
|
|
364
|
+
id: z9.string(),
|
|
365
|
+
meta: commonObjectMetaSchema5,
|
|
366
|
+
operationId: z9.string(),
|
|
367
|
+
stateId: z9.string(),
|
|
368
|
+
createdAt: z9.date()
|
|
369
|
+
});
|
|
370
|
+
var entitySnapshotDetailsOutputSchema = z9.object({
|
|
371
|
+
entity: z9.object({
|
|
372
|
+
id: z9.string(),
|
|
373
|
+
type: z9.string(),
|
|
374
|
+
identity: z9.string()
|
|
375
|
+
}),
|
|
376
|
+
snapshot: entitySnapshotOutputSchema
|
|
377
|
+
});
|
|
378
|
+
var entityDetailsOutputSchema = z9.object({
|
|
379
|
+
...entityOutputSchema.shape,
|
|
380
|
+
lastSnapshot: entitySnapshotOutputSchema.nullable()
|
|
381
|
+
});
|
|
382
|
+
var entityReferenceOutputSchema = z9.object({
|
|
383
|
+
id: z9.string(),
|
|
384
|
+
meta: commonObjectMetaSchema5,
|
|
385
|
+
group: z9.string(),
|
|
386
|
+
fromSnapshotId: z9.string(),
|
|
387
|
+
fromEntityId: z9.string(),
|
|
388
|
+
fromEntityType: z9.string(),
|
|
389
|
+
fromEntityIdentity: z9.string(),
|
|
390
|
+
fromEntityMeta: commonObjectMetaSchema5,
|
|
391
|
+
toSnapshotId: z9.string(),
|
|
392
|
+
toEntityId: z9.string(),
|
|
393
|
+
toEntityType: z9.string(),
|
|
394
|
+
toEntityIdentity: z9.string(),
|
|
395
|
+
toEntityMeta: commonObjectMetaSchema5
|
|
396
|
+
});
|
|
397
|
+
function toCommonEntityMeta(meta) {
|
|
398
|
+
const parsedRawMeta = rawEntityMetaSchema.safeParse(meta);
|
|
399
|
+
if (parsedRawMeta.success) {
|
|
400
|
+
return {
|
|
401
|
+
title: parsedRawMeta.data.title ?? parsedRawMeta.data.identity ?? "Unknown",
|
|
402
|
+
description: parsedRawMeta.data.description,
|
|
403
|
+
icon: parsedRawMeta.data.icon,
|
|
404
|
+
iconColor: parsedRawMeta.data.iconColor
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
title: "Unknown"
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
// src/shared/models/project/lock.ts
|
|
412
|
+
import { commonObjectMetaSchema as commonObjectMetaSchema6 } from "@highstate/contract";
|
|
413
|
+
import { z as z10 } from "zod";
|
|
414
|
+
var instanceLockOutputSchema = z10.object({
|
|
415
|
+
stateId: z10.cuid2(),
|
|
416
|
+
meta: commonObjectMetaSchema6,
|
|
417
|
+
acquiredAt: z10.date()
|
|
418
|
+
});
|
|
419
|
+
var instanceLockEventSchema = z10.discriminatedUnion("type", [
|
|
420
|
+
z10.object({
|
|
421
|
+
type: z10.literal("locked"),
|
|
356
422
|
locks: instanceLockOutputSchema.array()
|
|
357
423
|
}),
|
|
358
|
-
|
|
359
|
-
type:
|
|
360
|
-
stateIds:
|
|
424
|
+
z10.object({
|
|
425
|
+
type: z10.literal("unlocked"),
|
|
426
|
+
stateIds: z10.array(z10.string())
|
|
361
427
|
})
|
|
362
428
|
]);
|
|
363
|
-
|
|
429
|
+
// src/shared/models/project/model.ts
|
|
430
|
+
import {
|
|
431
|
+
hubModelSchema,
|
|
432
|
+
instanceIdSchema,
|
|
433
|
+
instanceModelSchema
|
|
434
|
+
} from "@highstate/contract";
|
|
435
|
+
import { z as z11 } from "zod";
|
|
436
|
+
var projectModelEventSchema = z11.object({
|
|
364
437
|
updatedInstances: instanceModelSchema.array().optional(),
|
|
365
438
|
updatedHubs: hubModelSchema.array().optional(),
|
|
366
439
|
updatedVirtualInstances: instanceModelSchema.array().optional(),
|
|
367
440
|
updatedGhostInstances: instanceModelSchema.array().optional(),
|
|
368
441
|
deletedInstanceIds: instanceIdSchema.array().optional(),
|
|
369
|
-
deletedHubIds:
|
|
442
|
+
deletedHubIds: z11.string().array().optional(),
|
|
370
443
|
deletedVirtualInstanceIds: instanceIdSchema.array().optional(),
|
|
371
444
|
deletedGhostInstanceIds: instanceIdSchema.array().optional()
|
|
372
445
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
* The parent ID of the instance, either from the model or the state.
|
|
381
|
-
*/
|
|
382
|
-
parentId: z.string().optional(),
|
|
383
|
-
/**
|
|
384
|
-
* Human-readable explanation of the decision.
|
|
385
|
-
* */
|
|
386
|
-
message: z.string()
|
|
446
|
+
// src/shared/models/project/operation.ts
|
|
447
|
+
import { instanceIdSchema as instanceIdSchema2, objectMetaSchema as objectMetaSchema3, z as z12 } from "@highstate/contract";
|
|
448
|
+
var operationPhaseTypeSchema = z12.enum(["destroy", "preview", "update", "refresh"]);
|
|
449
|
+
var operationPhaseInstanceSchema = z12.object({
|
|
450
|
+
id: instanceIdSchema2,
|
|
451
|
+
parentId: z12.string().optional(),
|
|
452
|
+
message: z12.string()
|
|
387
453
|
});
|
|
388
|
-
var operationPhaseSchema =
|
|
389
|
-
/**
|
|
390
|
-
* Type of phase being executed.
|
|
391
|
-
*/
|
|
454
|
+
var operationPhaseSchema = z12.object({
|
|
392
455
|
type: operationPhaseTypeSchema,
|
|
393
|
-
|
|
394
|
-
* List of instances to be processed in this phase.
|
|
395
|
-
*/
|
|
396
|
-
instances: z.array(operationPhaseInstanceSchema)
|
|
456
|
+
instances: z12.array(operationPhaseInstanceSchema)
|
|
397
457
|
});
|
|
398
|
-
var operationOptionsSchema =
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
*
|
|
415
|
-
* **Operation Behavior Impact:**
|
|
416
|
-
* - skips dependency inclusion even when dependencies are failed or undeployed;
|
|
417
|
-
* - caller must explicitly include every prerequisite instance to avoid failures;
|
|
418
|
-
* - complements on-demand or targeted updates where dependency safety is managed externally.
|
|
419
|
-
*
|
|
420
|
-
* **Usage with other options:**
|
|
421
|
-
* - mutually exclusive with `forceUpdateDependencies`;
|
|
422
|
-
* - independent of child/composite inclusion options.
|
|
423
|
-
*/
|
|
424
|
-
ignoreDependencies: z.boolean().default(false),
|
|
425
|
-
/**
|
|
426
|
-
* Force update all children of composite instances regardless of their state.
|
|
427
|
-
*
|
|
428
|
-
* **Operation Behavior Impact:**
|
|
429
|
-
* - overrides selective child inclusion logic for composites;
|
|
430
|
-
* - includes **ALL** children of affected composites (up-to-date, out-of-date, and error states);
|
|
431
|
-
* - applied after dependency traversal and parent inclusion.
|
|
432
|
-
*
|
|
433
|
-
* **Usage with other options:**
|
|
434
|
-
* - combined with `forceUpdateDependencies`: creates comprehensive force-update behavior;
|
|
435
|
-
* - overrides `allowPartialCompositeInstanceCreation`: when enabled, **ALL** children are included regardless of existence.
|
|
436
|
-
*/
|
|
437
|
-
forceUpdateChildren: z.boolean().default(false),
|
|
438
|
-
/**
|
|
439
|
-
* Include dependent instances when destroying instances.
|
|
440
|
-
*
|
|
441
|
-
* **Operation Behavior Impact:**
|
|
442
|
-
* - extends destroy operations to include instances that depend on the target;
|
|
443
|
-
* - traverses the dependency graph in reverse (dependents, not dependencies);
|
|
444
|
-
* - prevents orphaned instances that would fail without their dependencies.
|
|
445
|
-
*
|
|
446
|
-
* **Usage with other options:**
|
|
447
|
-
* - works with `invokeDestroyTriggers`: ensures triggers run for all dependents;
|
|
448
|
-
* - independent of update-related options.
|
|
449
|
-
*/
|
|
450
|
-
destroyDependentInstances: z.boolean().default(true),
|
|
451
|
-
/**
|
|
452
|
-
* Execute destroy triggers when destroying instances.
|
|
453
|
-
*
|
|
454
|
-
* **Operation Behavior Impact:**
|
|
455
|
-
* - affects how individual units are destroyed (triggers vs direct deletion);
|
|
456
|
-
* - does not change which instances are selected for destruction;
|
|
457
|
-
* - controls trigger execution during the destruction phase.
|
|
458
|
-
*
|
|
459
|
-
* **Usage with other options:**
|
|
460
|
-
* - used with `destroyDependentInstances`: ensures triggers run for cascade deletions;
|
|
461
|
-
* - independent of update-related options.
|
|
462
|
-
*/
|
|
463
|
-
invokeDestroyTriggers: z.boolean().default(true),
|
|
464
|
-
/**
|
|
465
|
-
* Delete Pulumi resources that are no longer referenced in the state.
|
|
466
|
-
*
|
|
467
|
-
* **Operation Behavior Impact:**
|
|
468
|
-
* - does not affect which instances are selected for operations;
|
|
469
|
-
* - deletes orphaned Pulumi resources within individual instances.
|
|
470
|
-
*
|
|
471
|
-
* **Usage with other options:**
|
|
472
|
-
* - independent of instance selection options;
|
|
473
|
-
* - complements destroy-related options for thorough cleanup.
|
|
474
|
-
*/
|
|
475
|
-
deleteUnreachableResources: z.boolean().default(false),
|
|
476
|
-
/**
|
|
477
|
-
* Force deletion of instance state even if the destroy operation fails.
|
|
478
|
-
*
|
|
479
|
-
* **Operation Behavior Impact:**
|
|
480
|
-
* - forces state deletion even when destroy operations fail;
|
|
481
|
-
* - does not affect which instances are selected for operations;
|
|
482
|
-
* - bypasses normal destroy procedures as emergency fallback.
|
|
483
|
-
*
|
|
484
|
-
* **Usage with other options:**
|
|
485
|
-
* - used with destroy-related options when normal cleanup fails;
|
|
486
|
-
* - should be used cautiously as it can create state inconsistencies.
|
|
487
|
-
*/
|
|
488
|
-
forceDeleteState: z.boolean().default(false),
|
|
489
|
-
/**
|
|
490
|
-
* Allow partial update of composite instances without requiring all outdated children.
|
|
491
|
-
*
|
|
492
|
-
* **Operation Behavior Impact:**
|
|
493
|
-
* - controls whether composite operations must include all outdated children or only necessary ones;
|
|
494
|
-
* - when `false` (default): all outdated children of substantive composites are included in operations;
|
|
495
|
-
* - when `true`: only necessary children are included, allowing partial composite operations;
|
|
496
|
-
* - applied during composite child traversal phase for substantive composites only.
|
|
497
|
-
*
|
|
498
|
-
* **Usage with other options:**
|
|
499
|
-
* - overridden by `forceUpdateChildren`: when force is enabled, **ALL** children are included regardless;
|
|
500
|
-
* - independent of `forceUpdateDependencies`: affects composite logic, not dependency traversal.
|
|
501
|
-
*/
|
|
502
|
-
allowPartialCompositeInstanceUpdate: z.boolean().default(false),
|
|
503
|
-
/**
|
|
504
|
-
* Allow partial destruction of composite instances during cascade operations.
|
|
505
|
-
*
|
|
506
|
-
* **Operation Behavior Impact:**
|
|
507
|
-
* - controls whether cascade destruction must include all children or only necessary ones;
|
|
508
|
-
* - when `false` (default): cascade destruction includes **ALL** children of affected composites;
|
|
509
|
-
* - when `true`: cascade destruction includes only directly dependent children;
|
|
510
|
-
* - does not affect explicit composite destruction (always destroys all children);
|
|
511
|
-
* - does not affect parent propagation when destroying sibling composites.
|
|
512
|
-
*
|
|
513
|
-
* **Usage with other options:**
|
|
514
|
-
* - works with `destroyDependentInstances`: controls completeness of cascade destruction;
|
|
515
|
-
* - independent of update-related options.
|
|
516
|
-
*/
|
|
517
|
-
allowPartialCompositeInstanceDestruction: z.boolean().default(false),
|
|
518
|
-
/**
|
|
519
|
-
* Also refresh the state of instances during the operation.
|
|
520
|
-
*
|
|
521
|
-
* **Operation Behavior Impact:**
|
|
522
|
-
* - does not change which instances are selected for operations;
|
|
523
|
-
* - synchronizes state with actual infrastructure during the operation.
|
|
524
|
-
*
|
|
525
|
-
* **Usage with other options:**
|
|
526
|
-
* - additive with dependency resolution options: refreshes all selected instances;
|
|
527
|
-
* - works with both all operation types.
|
|
528
|
-
*/
|
|
529
|
-
refresh: z.boolean().default(false),
|
|
530
|
-
/**
|
|
531
|
-
* Enable debug logging for Pulumi engine and resource providers.
|
|
532
|
-
*
|
|
533
|
-
* **Security Note:**
|
|
534
|
-
* Debug mode may expose sensitive information including credentials in the logs.
|
|
535
|
-
* Use only when absolutely necessary for troubleshooting.
|
|
536
|
-
*
|
|
537
|
-
* **Implementation:**
|
|
538
|
-
* - sets Pulumi's debug option to true;
|
|
539
|
-
* - sets TF_LOG=DEBUG environment variable for Terraform providers.
|
|
540
|
-
*/
|
|
541
|
-
debug: z.boolean().default(false)
|
|
458
|
+
var operationOptionsSchema = z12.object({
|
|
459
|
+
forceUpdateDependencies: z12.boolean().default(false),
|
|
460
|
+
ignoreChangedDependencies: z12.boolean().default(false),
|
|
461
|
+
ignoreDependencies: z12.boolean().default(false),
|
|
462
|
+
forceUpdateChildren: z12.boolean().default(false),
|
|
463
|
+
onlyDestroyGhosts: z12.boolean().default(false),
|
|
464
|
+
firstDestroyGhosts: z12.boolean().default(false),
|
|
465
|
+
ignoreGhosts: z12.boolean().default(false),
|
|
466
|
+
destroyDependentInstances: z12.boolean().default(true),
|
|
467
|
+
invokeDestroyTriggers: z12.boolean().default(true),
|
|
468
|
+
deleteUnreachableResources: z12.boolean().default(false),
|
|
469
|
+
forceDeleteState: z12.boolean().default(false),
|
|
470
|
+
allowPartialCompositeInstanceUpdate: z12.boolean().default(false),
|
|
471
|
+
allowPartialCompositeInstanceDestruction: z12.boolean().default(false),
|
|
472
|
+
refresh: z12.boolean().default(false),
|
|
473
|
+
debug: z12.boolean().default(false)
|
|
542
474
|
}).partial();
|
|
543
|
-
var operationTypeSchema =
|
|
475
|
+
var operationTypeSchema = z12.enum([
|
|
544
476
|
"update",
|
|
545
477
|
"preview",
|
|
546
478
|
"destroy",
|
|
547
479
|
"recreate",
|
|
548
480
|
"refresh"
|
|
549
481
|
]);
|
|
550
|
-
var operationStatusSchema =
|
|
482
|
+
var operationStatusSchema = z12.enum([
|
|
551
483
|
"pending",
|
|
552
484
|
"running",
|
|
553
485
|
"failing",
|
|
@@ -556,38 +488,38 @@ var operationStatusSchema = z.enum([
|
|
|
556
488
|
"cancelled",
|
|
557
489
|
"cancelling"
|
|
558
490
|
]);
|
|
559
|
-
var operationMetaSchema =
|
|
491
|
+
var operationMetaSchema = objectMetaSchema3.pick({
|
|
560
492
|
title: true,
|
|
561
493
|
description: true
|
|
562
494
|
}).required({ title: true });
|
|
563
|
-
var operationPlanInputSchema =
|
|
564
|
-
projectId:
|
|
495
|
+
var operationPlanInputSchema = z12.object({
|
|
496
|
+
projectId: z12.string(),
|
|
565
497
|
type: operationTypeSchema,
|
|
566
|
-
instanceIds:
|
|
498
|
+
instanceIds: z12.array(instanceIdSchema2).min(1),
|
|
567
499
|
options: operationOptionsSchema.partial().optional()
|
|
568
500
|
});
|
|
569
501
|
var operationLaunchInputSchema = operationPlanInputSchema.extend({
|
|
570
502
|
meta: operationMetaSchema,
|
|
571
503
|
plan: operationPhaseSchema.array().optional()
|
|
572
504
|
});
|
|
573
|
-
var operationEventSchema =
|
|
574
|
-
|
|
575
|
-
type:
|
|
576
|
-
operation:
|
|
505
|
+
var operationEventSchema = z12.discriminatedUnion("type", [
|
|
506
|
+
z12.object({
|
|
507
|
+
type: z12.literal("updated"),
|
|
508
|
+
operation: z12.custom()
|
|
577
509
|
}),
|
|
578
|
-
|
|
579
|
-
type:
|
|
580
|
-
operationId:
|
|
510
|
+
z12.object({
|
|
511
|
+
type: z12.literal("deleted"),
|
|
512
|
+
operationId: z12.string()
|
|
581
513
|
})
|
|
582
514
|
]);
|
|
583
|
-
var operationOutputSchema =
|
|
584
|
-
id:
|
|
515
|
+
var operationOutputSchema = z12.object({
|
|
516
|
+
id: z12.cuid2(),
|
|
585
517
|
type: operationTypeSchema,
|
|
586
518
|
status: operationStatusSchema,
|
|
587
519
|
meta: operationMetaSchema,
|
|
588
|
-
startedAt:
|
|
589
|
-
updatedAt:
|
|
590
|
-
finishedAt:
|
|
520
|
+
startedAt: z12.date(),
|
|
521
|
+
updatedAt: z12.date(),
|
|
522
|
+
finishedAt: z12.date().nullable()
|
|
591
523
|
});
|
|
592
524
|
var finalOperationStatuses = ["completed", "failed", "cancelled"];
|
|
593
525
|
function isFinalOperationStatus(status) {
|
|
@@ -596,24 +528,31 @@ function isFinalOperationStatus(status) {
|
|
|
596
528
|
function isTransientOperationStatus(status) {
|
|
597
529
|
return !!status && !finalOperationStatuses.includes(status);
|
|
598
530
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
531
|
+
// src/shared/models/project/page.ts
|
|
532
|
+
import {
|
|
533
|
+
commonObjectMetaSchema as commonObjectMetaSchema7,
|
|
534
|
+
pageBlockSchema,
|
|
535
|
+
serviceAccountMetaSchema as serviceAccountMetaSchema2
|
|
536
|
+
} from "@highstate/contract";
|
|
537
|
+
import { z as z13 } from "zod";
|
|
538
|
+
var pageOutputSchema = z13.object({
|
|
539
|
+
id: z13.cuid2(),
|
|
540
|
+
meta: commonObjectMetaSchema7,
|
|
541
|
+
name: z13.string().nullable(),
|
|
542
|
+
stateId: z13.cuid2().nullable(),
|
|
543
|
+
serviceAccountId: z13.cuid2().nullable(),
|
|
544
|
+
serviceAccountMeta: serviceAccountMetaSchema2.nullable(),
|
|
545
|
+
createdAt: z13.date(),
|
|
546
|
+
updatedAt: z13.date()
|
|
608
547
|
});
|
|
609
548
|
var pageQuerySchema = collectionQuerySchema.extend({
|
|
610
|
-
serviceAccountId:
|
|
611
|
-
stateId:
|
|
612
|
-
artifactId:
|
|
549
|
+
serviceAccountId: z13.string().optional(),
|
|
550
|
+
stateId: z13.string().optional(),
|
|
551
|
+
artifactId: z13.string().optional()
|
|
613
552
|
});
|
|
614
|
-
var pageDetailsOutputSchema =
|
|
553
|
+
var pageDetailsOutputSchema = z13.object({
|
|
615
554
|
...pageOutputSchema.shape,
|
|
616
|
-
content:
|
|
555
|
+
content: z13.array(pageBlockSchema)
|
|
617
556
|
});
|
|
618
557
|
function toPageOutput(page, serviceAccount) {
|
|
619
558
|
return {
|
|
@@ -621,20 +560,22 @@ function toPageOutput(page, serviceAccount) {
|
|
|
621
560
|
serviceAccountMeta: serviceAccount?.meta ?? null
|
|
622
561
|
};
|
|
623
562
|
}
|
|
624
|
-
|
|
625
|
-
|
|
563
|
+
// src/shared/models/project/secret.ts
|
|
564
|
+
import { globalCommonObjectMetaSchema, serviceAccountMetaSchema as serviceAccountMetaSchema3, z as z14 } from "@highstate/contract";
|
|
565
|
+
var secretOutputSchema = z14.object({
|
|
566
|
+
id: z14.cuid2(),
|
|
626
567
|
meta: globalCommonObjectMetaSchema,
|
|
627
|
-
name:
|
|
628
|
-
systemName:
|
|
629
|
-
stateId:
|
|
630
|
-
serviceAccountId:
|
|
631
|
-
serviceAccountMeta:
|
|
632
|
-
createdAt:
|
|
633
|
-
updatedAt:
|
|
568
|
+
name: z14.string().nullable(),
|
|
569
|
+
systemName: z14.string().nullable(),
|
|
570
|
+
stateId: z14.cuid2().nullable(),
|
|
571
|
+
serviceAccountId: z14.cuid2().nullable(),
|
|
572
|
+
serviceAccountMeta: serviceAccountMetaSchema3.nullable(),
|
|
573
|
+
createdAt: z14.date(),
|
|
574
|
+
updatedAt: z14.date()
|
|
634
575
|
});
|
|
635
576
|
var secretQuerySchema = collectionQuerySchema.extend({
|
|
636
|
-
serviceAccountId:
|
|
637
|
-
stateId:
|
|
577
|
+
serviceAccountId: z14.string().optional(),
|
|
578
|
+
stateId: z14.string().optional()
|
|
638
579
|
});
|
|
639
580
|
function toSecretOutput(secret, serviceAccount) {
|
|
640
581
|
return {
|
|
@@ -642,41 +583,55 @@ function toSecretOutput(secret, serviceAccount) {
|
|
|
642
583
|
serviceAccountMeta: serviceAccount?.meta ?? null
|
|
643
584
|
};
|
|
644
585
|
}
|
|
645
|
-
var SystemSecretNames
|
|
586
|
+
var SystemSecretNames;
|
|
587
|
+
((SystemSecretNames2) => {
|
|
646
588
|
SystemSecretNames2["PulumiPassword"] = "pulumi-password";
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
589
|
+
})(SystemSecretNames ||= {});
|
|
590
|
+
// src/shared/models/project/service-account.ts
|
|
591
|
+
import { serviceAccountMetaSchema as serviceAccountMetaSchema4, z as z15 } from "@highstate/contract";
|
|
592
|
+
var serviceAccountOutputSchema = z15.object({
|
|
593
|
+
id: z15.cuid2(),
|
|
594
|
+
meta: serviceAccountMetaSchema4,
|
|
595
|
+
createdAt: z15.date(),
|
|
596
|
+
updatedAt: z15.date()
|
|
654
597
|
});
|
|
655
598
|
var serviceAccountQuerySchema = collectionQuerySchema.extend({
|
|
656
|
-
artifactId:
|
|
599
|
+
artifactId: z15.string().optional()
|
|
657
600
|
});
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
601
|
+
// src/shared/models/project/state.ts
|
|
602
|
+
import { z as z16 } from "zod";
|
|
603
|
+
var stableInstanceInputSchema = z16.object({
|
|
604
|
+
stateId: z16.string(),
|
|
605
|
+
output: z16.string(),
|
|
606
|
+
path: z16.string().optional()
|
|
661
607
|
});
|
|
662
|
-
var instanceStateEventSchema =
|
|
663
|
-
|
|
664
|
-
type:
|
|
665
|
-
state:
|
|
608
|
+
var instanceStateEventSchema = z16.discriminatedUnion("type", [
|
|
609
|
+
z16.object({
|
|
610
|
+
type: z16.literal("updated"),
|
|
611
|
+
state: z16.custom()
|
|
666
612
|
}),
|
|
667
|
-
|
|
668
|
-
type:
|
|
669
|
-
stateId:
|
|
670
|
-
patch:
|
|
613
|
+
z16.object({
|
|
614
|
+
type: z16.literal("patched"),
|
|
615
|
+
stateId: z16.string(),
|
|
616
|
+
patch: z16.custom()
|
|
671
617
|
}),
|
|
672
|
-
|
|
673
|
-
type:
|
|
674
|
-
|
|
618
|
+
z16.object({
|
|
619
|
+
type: z16.literal("patched-batch"),
|
|
620
|
+
patches: z16.array(z16.object({
|
|
621
|
+
stateId: z16.string(),
|
|
622
|
+
patch: z16.custom()
|
|
623
|
+
}))
|
|
624
|
+
}),
|
|
625
|
+
z16.object({
|
|
626
|
+
type: z16.literal("deleted"),
|
|
627
|
+
stateId: z16.string()
|
|
675
628
|
})
|
|
676
629
|
]);
|
|
677
630
|
function isVirtualGhostInstance(state) {
|
|
678
|
-
if (state.source !== "virtual")
|
|
679
|
-
|
|
631
|
+
if (state.source !== "virtual")
|
|
632
|
+
return false;
|
|
633
|
+
if (state.status === "undeployed")
|
|
634
|
+
return false;
|
|
680
635
|
return !state.evaluationState;
|
|
681
636
|
}
|
|
682
637
|
function isInstanceDeployed(state) {
|
|
@@ -694,43 +649,51 @@ var finalInstanceOperationStatuses = [
|
|
|
694
649
|
function isTransientInstanceOperationStatus(status) {
|
|
695
650
|
return !!status && !finalInstanceOperationStatuses.includes(status);
|
|
696
651
|
}
|
|
697
|
-
var workerUnitRegistrationEventSchema =
|
|
698
|
-
|
|
699
|
-
type:
|
|
700
|
-
instanceId:
|
|
701
|
-
params:
|
|
652
|
+
var workerUnitRegistrationEventSchema = z16.discriminatedUnion("type", [
|
|
653
|
+
z16.object({
|
|
654
|
+
type: z16.literal("registered"),
|
|
655
|
+
instanceId: z16.string(),
|
|
656
|
+
params: z16.record(z16.string(), z16.unknown())
|
|
702
657
|
}),
|
|
703
|
-
|
|
704
|
-
type:
|
|
705
|
-
instanceId:
|
|
658
|
+
z16.object({
|
|
659
|
+
type: z16.literal("deregistered"),
|
|
660
|
+
instanceId: z16.string()
|
|
706
661
|
})
|
|
707
662
|
]);
|
|
708
|
-
|
|
663
|
+
// src/shared/models/project/terminal.ts
|
|
664
|
+
import {
|
|
665
|
+
commonObjectMetaSchema as commonObjectMetaSchema8,
|
|
666
|
+
globalCommonObjectMetaSchema as globalCommonObjectMetaSchema2,
|
|
667
|
+
serviceAccountMetaSchema as serviceAccountMetaSchema5,
|
|
668
|
+
terminalSpecSchema
|
|
669
|
+
} from "@highstate/contract";
|
|
670
|
+
import { z as z17 } from "zod";
|
|
671
|
+
var terminalStatusSchema = z17.enum([
|
|
709
672
|
"active",
|
|
710
673
|
"unavailable"
|
|
711
674
|
]);
|
|
712
|
-
var terminalSessionOutputSchema =
|
|
713
|
-
id:
|
|
714
|
-
terminalId:
|
|
715
|
-
meta:
|
|
716
|
-
startedAt:
|
|
717
|
-
finishedAt:
|
|
675
|
+
var terminalSessionOutputSchema = z17.object({
|
|
676
|
+
id: z17.cuid2(),
|
|
677
|
+
terminalId: z17.cuid2(),
|
|
678
|
+
meta: globalCommonObjectMetaSchema2,
|
|
679
|
+
startedAt: z17.date(),
|
|
680
|
+
finishedAt: z17.date().nullable()
|
|
718
681
|
});
|
|
719
|
-
var terminalOutputSchema =
|
|
720
|
-
id:
|
|
721
|
-
name:
|
|
722
|
-
meta:
|
|
682
|
+
var terminalOutputSchema = z17.object({
|
|
683
|
+
id: z17.cuid2(),
|
|
684
|
+
name: z17.string().nullable(),
|
|
685
|
+
meta: commonObjectMetaSchema8,
|
|
723
686
|
status: terminalStatusSchema,
|
|
724
|
-
stateId:
|
|
725
|
-
serviceAccountId:
|
|
726
|
-
serviceAccountMeta:
|
|
727
|
-
createdAt:
|
|
728
|
-
updatedAt:
|
|
687
|
+
stateId: z17.string().nullable(),
|
|
688
|
+
serviceAccountId: z17.string().nullable(),
|
|
689
|
+
serviceAccountMeta: serviceAccountMetaSchema5.nullable(),
|
|
690
|
+
createdAt: z17.date(),
|
|
691
|
+
updatedAt: z17.date()
|
|
729
692
|
});
|
|
730
693
|
var terminalQuerySchema = collectionQuerySchema.extend({
|
|
731
|
-
serviceAccountId:
|
|
732
|
-
stateId:
|
|
733
|
-
artifactId:
|
|
694
|
+
serviceAccountId: z17.string().optional(),
|
|
695
|
+
stateId: z17.string().optional(),
|
|
696
|
+
artifactId: z17.string().optional()
|
|
734
697
|
});
|
|
735
698
|
function toTerminalOutput(terminal, serviceAccount) {
|
|
736
699
|
return {
|
|
@@ -744,7 +707,7 @@ function toTerminalDetailsOutput(terminal, serviceAccount) {
|
|
|
744
707
|
serviceAccountMeta: serviceAccount?.meta ?? null
|
|
745
708
|
};
|
|
746
709
|
}
|
|
747
|
-
var terminalDetailsOutputSchema =
|
|
710
|
+
var terminalDetailsOutputSchema = z17.object({
|
|
748
711
|
...terminalOutputSchema.shape,
|
|
749
712
|
spec: terminalSpecSchema
|
|
750
713
|
});
|
|
@@ -757,36 +720,44 @@ function toTerminalSessionOutput(terminal, session) {
|
|
|
757
720
|
finishedAt: session.finishedAt
|
|
758
721
|
};
|
|
759
722
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
723
|
+
// src/shared/models/project/trigger.ts
|
|
724
|
+
import { commonObjectMetaSchema as commonObjectMetaSchema9 } from "@highstate/contract";
|
|
725
|
+
import { z as z18 } from "zod";
|
|
726
|
+
var triggerOutputSchema = z18.object({
|
|
727
|
+
id: z18.cuid2(),
|
|
728
|
+
meta: commonObjectMetaSchema9,
|
|
729
|
+
name: z18.string(),
|
|
730
|
+
stateId: z18.cuid2(),
|
|
731
|
+
createdAt: z18.date(),
|
|
732
|
+
updatedAt: z18.date()
|
|
767
733
|
});
|
|
768
734
|
var triggerQuerySchema = collectionQuerySchema.extend({
|
|
769
|
-
stateId:
|
|
735
|
+
stateId: z18.string().optional()
|
|
770
736
|
});
|
|
771
|
-
|
|
772
|
-
|
|
737
|
+
// src/shared/models/project/unlock-method.ts
|
|
738
|
+
import { objectMetaSchema as objectMetaSchema4, z as z19 } from "@highstate/contract";
|
|
739
|
+
var unlockMethodType = z19.enum(["password", "passkey"]);
|
|
740
|
+
var unlockMethodMetaSchema = objectMetaSchema4.pick({
|
|
773
741
|
title: true,
|
|
774
742
|
description: true
|
|
775
743
|
}).required({ title: true });
|
|
776
|
-
var unlockMethodInputSchema =
|
|
744
|
+
var unlockMethodInputSchema = z19.object({
|
|
777
745
|
meta: unlockMethodMetaSchema,
|
|
778
746
|
type: unlockMethodType,
|
|
779
|
-
encryptedIdentity:
|
|
780
|
-
recipient:
|
|
747
|
+
encryptedIdentity: z19.string(),
|
|
748
|
+
recipient: z19.string()
|
|
781
749
|
});
|
|
782
|
-
var unlockMethodOutputSchema =
|
|
783
|
-
id:
|
|
750
|
+
var unlockMethodOutputSchema = z19.object({
|
|
751
|
+
id: z19.cuid2(),
|
|
784
752
|
type: unlockMethodType,
|
|
785
753
|
meta: unlockMethodMetaSchema,
|
|
786
|
-
recipient:
|
|
787
|
-
createdAt:
|
|
788
|
-
updatedAt:
|
|
754
|
+
recipient: z19.string(),
|
|
755
|
+
createdAt: z19.date(),
|
|
756
|
+
updatedAt: z19.date()
|
|
789
757
|
});
|
|
758
|
+
// src/shared/models/project/worker.ts
|
|
759
|
+
import { commonObjectMetaSchema as commonObjectMetaSchema10, serviceAccountMetaSchema as serviceAccountMetaSchema6 } from "@highstate/contract";
|
|
760
|
+
import { z as z20 } from "zod";
|
|
790
761
|
var MAX_WORKER_START_ATTEMPTS = 3;
|
|
791
762
|
var SHA256_PREFIX = "sha256:";
|
|
792
763
|
var SHA256_REGEX = /^[a-f0-9]{64}$/;
|
|
@@ -815,7 +786,7 @@ function getWorkerIdentity(image) {
|
|
|
815
786
|
}
|
|
816
787
|
return withoutDigest;
|
|
817
788
|
}
|
|
818
|
-
var workerVersionStatusSchema =
|
|
789
|
+
var workerVersionStatusSchema = z20.enum([
|
|
819
790
|
"unknown",
|
|
820
791
|
"starting",
|
|
821
792
|
"running",
|
|
@@ -823,27 +794,31 @@ var workerVersionStatusSchema = z$1.enum([
|
|
|
823
794
|
"stopped",
|
|
824
795
|
"error"
|
|
825
796
|
]);
|
|
826
|
-
var
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
797
|
+
var workerVersionStatusEventSchema = z20.object({
|
|
798
|
+
workerVersionId: z20.cuid2(),
|
|
799
|
+
status: workerVersionStatusSchema
|
|
800
|
+
});
|
|
801
|
+
var workerVersionOutputSchema = z20.object({
|
|
802
|
+
id: z20.cuid2(),
|
|
803
|
+
digest: z20.string(),
|
|
804
|
+
meta: commonObjectMetaSchema10,
|
|
830
805
|
status: workerVersionStatusSchema,
|
|
831
|
-
enabled:
|
|
832
|
-
apiKeyId:
|
|
806
|
+
enabled: z20.boolean(),
|
|
807
|
+
apiKeyId: z20.string(),
|
|
833
808
|
apiKeyMeta: apiKeyMetaSchema,
|
|
834
|
-
createdAt:
|
|
835
|
-
updatedAt:
|
|
809
|
+
createdAt: z20.date(),
|
|
810
|
+
updatedAt: z20.date()
|
|
836
811
|
});
|
|
837
|
-
var workerOutputSchema =
|
|
838
|
-
id:
|
|
839
|
-
identity:
|
|
840
|
-
meta:
|
|
841
|
-
serviceAccountId:
|
|
842
|
-
serviceAccountMeta:
|
|
843
|
-
createdAt:
|
|
812
|
+
var workerOutputSchema = z20.object({
|
|
813
|
+
id: z20.cuid2(),
|
|
814
|
+
identity: z20.string(),
|
|
815
|
+
meta: commonObjectMetaSchema10,
|
|
816
|
+
serviceAccountId: z20.string(),
|
|
817
|
+
serviceAccountMeta: serviceAccountMetaSchema6,
|
|
818
|
+
createdAt: z20.date()
|
|
844
819
|
});
|
|
845
820
|
var workerQuerySchema = collectionQuerySchema.extend({
|
|
846
|
-
serviceAccountId:
|
|
821
|
+
serviceAccountId: z20.string().optional()
|
|
847
822
|
});
|
|
848
823
|
function toWorkerOutput(worker, lastVersion, serviceAccount) {
|
|
849
824
|
return {
|
|
@@ -858,17 +833,119 @@ function toWorkerVersionOutput(version, apiKey) {
|
|
|
858
833
|
apiKeyMeta: apiKey.meta
|
|
859
834
|
};
|
|
860
835
|
}
|
|
861
|
-
|
|
836
|
+
// src/shared/resolvers/effective-output-type.ts
|
|
837
|
+
function resolveEffectiveOutputType(options) {
|
|
838
|
+
const visited = options.visited ?? new Set;
|
|
839
|
+
const producer = options.getInstanceContext(options.input.instanceId);
|
|
840
|
+
if (!producer) {
|
|
841
|
+
return resolveTypeByPathOrFallbackInclusion({
|
|
842
|
+
rootType: options.fallbackType,
|
|
843
|
+
path: options.input.path,
|
|
844
|
+
entities: undefined,
|
|
845
|
+
fallbackType: options.fallbackType
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
const outputSpec = producer.component.outputs[options.input.output];
|
|
849
|
+
if (!outputSpec) {
|
|
850
|
+
return resolveTypeByPathOrFallbackInclusion({
|
|
851
|
+
rootType: options.fallbackType,
|
|
852
|
+
path: options.input.path,
|
|
853
|
+
entities: producer.entities,
|
|
854
|
+
fallbackType: options.fallbackType
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
let effectiveType = outputSpec.type;
|
|
858
|
+
if (outputSpec.fromInput) {
|
|
859
|
+
const visitedKey = `${producer.instance.id}:${options.input.output}`;
|
|
860
|
+
if (!visited.has(visitedKey)) {
|
|
861
|
+
visited.add(visitedKey);
|
|
862
|
+
const forwardedInputName = outputSpec.fromInput;
|
|
863
|
+
const forwardedFallback = producer.component.inputs[forwardedInputName]?.type ?? effectiveType;
|
|
864
|
+
const hasHubInputs = (producer.instance.hubInputs?.[forwardedInputName]?.length ?? 0) > 0;
|
|
865
|
+
const hasInjectionInputs = (producer.instance.injectionInputs?.length ?? 0) > 0;
|
|
866
|
+
const directInputs = producer.instance.inputs?.[forwardedInputName] ?? [];
|
|
867
|
+
if (!hasHubInputs && !hasInjectionInputs && directInputs.length === 1) {
|
|
868
|
+
const forwardedInput = directInputs[0];
|
|
869
|
+
if (forwardedInput) {
|
|
870
|
+
effectiveType = resolveEffectiveOutputType({
|
|
871
|
+
input: forwardedInput,
|
|
872
|
+
fallbackType: forwardedFallback,
|
|
873
|
+
getInstanceContext: options.getInstanceContext,
|
|
874
|
+
visited
|
|
875
|
+
});
|
|
876
|
+
} else {
|
|
877
|
+
effectiveType = forwardedFallback;
|
|
878
|
+
}
|
|
879
|
+
} else {
|
|
880
|
+
effectiveType = forwardedFallback;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return resolveTypeByPathOrFallbackInclusion({
|
|
885
|
+
rootType: effectiveType,
|
|
886
|
+
path: options.input.path,
|
|
887
|
+
entities: producer.entities,
|
|
888
|
+
fallbackType: options.fallbackType
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
function resolveTypeByPathOrFallbackInclusion(options) {
|
|
892
|
+
const { rootType, path, entities, fallbackType } = options;
|
|
893
|
+
if (!path || !entities) {
|
|
894
|
+
return resolveTypeByImplicitInclusion(rootType, fallbackType, entities);
|
|
895
|
+
}
|
|
896
|
+
let currentType = rootType;
|
|
897
|
+
const segments = path.split(".");
|
|
898
|
+
for (const segment of segments) {
|
|
899
|
+
const entity2 = entities[currentType];
|
|
900
|
+
if (!entity2) {
|
|
901
|
+
return rootType;
|
|
902
|
+
}
|
|
903
|
+
const inclusion = entity2.inclusions?.find((inc) => inc.field === segment);
|
|
904
|
+
if (!inclusion) {
|
|
905
|
+
return rootType;
|
|
906
|
+
}
|
|
907
|
+
currentType = inclusion.type;
|
|
908
|
+
}
|
|
909
|
+
return currentType;
|
|
910
|
+
}
|
|
911
|
+
function resolveTypeByImplicitInclusion(rootType, fallbackType, entities) {
|
|
912
|
+
if (!entities) {
|
|
913
|
+
return rootType;
|
|
914
|
+
}
|
|
915
|
+
if (rootType === fallbackType) {
|
|
916
|
+
return rootType;
|
|
917
|
+
}
|
|
918
|
+
const rootEntity = entities[rootType];
|
|
919
|
+
if (!rootEntity) {
|
|
920
|
+
return rootType;
|
|
921
|
+
}
|
|
922
|
+
if (rootEntity.extensions?.includes(fallbackType)) {
|
|
923
|
+
return rootType;
|
|
924
|
+
}
|
|
925
|
+
const inclusion = rootEntity.inclusions?.find((inc) => inc.type === fallbackType);
|
|
926
|
+
if (inclusion) {
|
|
927
|
+
return fallbackType;
|
|
928
|
+
}
|
|
929
|
+
return rootType;
|
|
930
|
+
}
|
|
931
|
+
// src/shared/resolvers/graph-resolver.ts
|
|
932
|
+
import { unique } from "remeda";
|
|
933
|
+
|
|
934
|
+
class GraphResolver {
|
|
935
|
+
nodes;
|
|
936
|
+
logger;
|
|
937
|
+
outputHandler;
|
|
938
|
+
dependentSetHandler;
|
|
939
|
+
workset = new Set;
|
|
940
|
+
dependencyMap = new Map;
|
|
941
|
+
dependentMap = new Map;
|
|
942
|
+
outputMap = new Map;
|
|
862
943
|
constructor(nodes, logger, outputHandler, dependentSetHandler) {
|
|
863
944
|
this.nodes = nodes;
|
|
864
945
|
this.logger = logger;
|
|
865
946
|
this.outputHandler = outputHandler;
|
|
866
947
|
this.dependentSetHandler = dependentSetHandler;
|
|
867
948
|
}
|
|
868
|
-
workset = /* @__PURE__ */ new Set();
|
|
869
|
-
dependencyMap = /* @__PURE__ */ new Map();
|
|
870
|
-
dependentMap = /* @__PURE__ */ new Map();
|
|
871
|
-
outputMap = /* @__PURE__ */ new Map();
|
|
872
949
|
addToWorkset(nodeId) {
|
|
873
950
|
this.workset.add(nodeId);
|
|
874
951
|
}
|
|
@@ -877,17 +954,9 @@ var GraphResolver = class {
|
|
|
877
954
|
this.workset.add(nodeId);
|
|
878
955
|
}
|
|
879
956
|
}
|
|
880
|
-
/**
|
|
881
|
-
* The map of calculated outputs.
|
|
882
|
-
*/
|
|
883
957
|
get outputs() {
|
|
884
958
|
return this.outputMap;
|
|
885
959
|
}
|
|
886
|
-
/**
|
|
887
|
-
* The map of dependencies for each node.
|
|
888
|
-
*
|
|
889
|
-
* The key is the node identifier, and the value is an array of identifiers of the nodes which depend on it.
|
|
890
|
-
*/
|
|
891
960
|
get dependents() {
|
|
892
961
|
return this.dependentMap;
|
|
893
962
|
}
|
|
@@ -898,11 +967,6 @@ var GraphResolver = class {
|
|
|
898
967
|
}
|
|
899
968
|
return output;
|
|
900
969
|
}
|
|
901
|
-
/**
|
|
902
|
-
* Gets the identifiers of the nodes that depend on the given node directly.
|
|
903
|
-
*
|
|
904
|
-
* Returns an empty array if there are no dependents.
|
|
905
|
-
*/
|
|
906
970
|
getDependents(nodeId) {
|
|
907
971
|
const dependents = this.dependentMap.get(nodeId);
|
|
908
972
|
if (!dependents) {
|
|
@@ -910,11 +974,6 @@ var GraphResolver = class {
|
|
|
910
974
|
}
|
|
911
975
|
return Array.from(dependents);
|
|
912
976
|
}
|
|
913
|
-
/**
|
|
914
|
-
* Invalidates the node and all nodes that depend on it.
|
|
915
|
-
*
|
|
916
|
-
* Also adds the node to the work set for processing.
|
|
917
|
-
*/
|
|
918
977
|
invalidate(nodeId) {
|
|
919
978
|
const stack = [nodeId];
|
|
920
979
|
while (stack.length > 0) {
|
|
@@ -935,13 +994,6 @@ var GraphResolver = class {
|
|
|
935
994
|
}
|
|
936
995
|
}
|
|
937
996
|
}
|
|
938
|
-
/**
|
|
939
|
-
* Invalidates a single node without invalidating its dependents.
|
|
940
|
-
*
|
|
941
|
-
* Also adds the node to the work set for processing.
|
|
942
|
-
*
|
|
943
|
-
* Should be used with caution, as it may lead to inconsistent state if the dependents are not re-processed separately.
|
|
944
|
-
*/
|
|
945
997
|
invalidateSingle(nodeId) {
|
|
946
998
|
if (!this.nodes.has(nodeId)) {
|
|
947
999
|
return;
|
|
@@ -949,11 +1001,6 @@ var GraphResolver = class {
|
|
|
949
1001
|
this.outputMap.delete(nodeId);
|
|
950
1002
|
this.workset.add(nodeId);
|
|
951
1003
|
}
|
|
952
|
-
/**
|
|
953
|
-
* Resolves all not-resolved or invalidated nodes in the graph.
|
|
954
|
-
*
|
|
955
|
-
* The abort signal of the previous operation must be called before calling this method again.
|
|
956
|
-
*/
|
|
957
1004
|
async process(signal) {
|
|
958
1005
|
while (this.workset.size > 0) {
|
|
959
1006
|
const rootNodeId = this.workset.values().next().value;
|
|
@@ -994,7 +1041,7 @@ var GraphResolver = class {
|
|
|
994
1041
|
this.logger.warn({ nodeId }, "processing aborted, skipping output");
|
|
995
1042
|
return;
|
|
996
1043
|
}
|
|
997
|
-
const changedDependentMaps =
|
|
1044
|
+
const changedDependentMaps = new Set;
|
|
998
1045
|
const oldDependencies = this.dependencyMap.get(nodeId) ?? [];
|
|
999
1046
|
for (const depId of oldDependencies) {
|
|
1000
1047
|
const dependantSet = this.dependentMap.get(depId);
|
|
@@ -1009,7 +1056,7 @@ var GraphResolver = class {
|
|
|
1009
1056
|
for (const depId of stackItem.dependencies) {
|
|
1010
1057
|
let dependantSet = this.dependentMap.get(depId);
|
|
1011
1058
|
if (!dependantSet) {
|
|
1012
|
-
dependantSet =
|
|
1059
|
+
dependantSet = new Set;
|
|
1013
1060
|
this.dependentMap.set(depId, dependantSet);
|
|
1014
1061
|
}
|
|
1015
1062
|
dependantSet.add(nodeId);
|
|
@@ -1029,9 +1076,9 @@ var GraphResolver = class {
|
|
|
1029
1076
|
this.workset.delete(rootNodeId);
|
|
1030
1077
|
}
|
|
1031
1078
|
}
|
|
1032
|
-
}
|
|
1079
|
+
}
|
|
1033
1080
|
function getAllDependents(dependentMap, nodeId) {
|
|
1034
|
-
const result =
|
|
1081
|
+
const result = new Set;
|
|
1035
1082
|
const stack = [nodeId];
|
|
1036
1083
|
while (stack.length > 0) {
|
|
1037
1084
|
const dependents = dependentMap.get(stack.pop());
|
|
@@ -1047,7 +1094,13 @@ function getAllDependents(dependentMap, nodeId) {
|
|
|
1047
1094
|
}
|
|
1048
1095
|
return Array.from(result);
|
|
1049
1096
|
}
|
|
1050
|
-
|
|
1097
|
+
// src/shared/resolvers/input.ts
|
|
1098
|
+
import {
|
|
1099
|
+
inputKey,
|
|
1100
|
+
isUnitModel
|
|
1101
|
+
} from "@highstate/contract";
|
|
1102
|
+
import { fromEntries, mapValues as mapValues2 } from "remeda";
|
|
1103
|
+
class InputResolver extends GraphResolver {
|
|
1051
1104
|
getNodeDependencies(node) {
|
|
1052
1105
|
const dependencies = [];
|
|
1053
1106
|
if (node.kind === "hub") {
|
|
@@ -1074,6 +1127,23 @@ var InputResolver = class extends GraphResolver {
|
|
|
1074
1127
|
}
|
|
1075
1128
|
return dependencies;
|
|
1076
1129
|
}
|
|
1130
|
+
resolveOutputTypeForInput(input, fallbackType) {
|
|
1131
|
+
return resolveEffectiveOutputType({
|
|
1132
|
+
input,
|
|
1133
|
+
fallbackType,
|
|
1134
|
+
getInstanceContext: (instanceId) => {
|
|
1135
|
+
const output = this.outputs.get(`instance:${instanceId}`);
|
|
1136
|
+
if (!output || output.kind !== "instance") {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
return {
|
|
1140
|
+
instance: output.instance,
|
|
1141
|
+
component: output.component,
|
|
1142
|
+
entities: output.entities
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1077
1147
|
processNode(node) {
|
|
1078
1148
|
const getHubOutput = (input) => {
|
|
1079
1149
|
const output = this.outputs.get(`hub:${input.hubId}`);
|
|
@@ -1104,9 +1174,9 @@ var InputResolver = class extends GraphResolver {
|
|
|
1104
1174
|
};
|
|
1105
1175
|
};
|
|
1106
1176
|
if (node.kind === "hub") {
|
|
1107
|
-
const hubResult =
|
|
1177
|
+
const hubResult = new Map;
|
|
1108
1178
|
const addHubResult = (input) => {
|
|
1109
|
-
hubResult.set(
|
|
1179
|
+
hubResult.set(inputKey(input.input), input);
|
|
1110
1180
|
};
|
|
1111
1181
|
for (const input of node.hub.inputs ?? []) {
|
|
1112
1182
|
const { component } = getInstanceOutput(input);
|
|
@@ -1115,7 +1185,10 @@ var InputResolver = class extends GraphResolver {
|
|
|
1115
1185
|
this.logger.warn({ msg: "output not found in the component", input, component });
|
|
1116
1186
|
continue;
|
|
1117
1187
|
}
|
|
1118
|
-
addHubResult({
|
|
1188
|
+
addHubResult({
|
|
1189
|
+
input,
|
|
1190
|
+
type: this.resolveOutputTypeForInput(input, componentInput.type)
|
|
1191
|
+
});
|
|
1119
1192
|
}
|
|
1120
1193
|
for (const injectionInput of node.hub.injectionInputs ?? []) {
|
|
1121
1194
|
const { resolvedInputs: resolvedInputs2 } = getHubOutput(injectionInput);
|
|
@@ -1134,7 +1207,8 @@ var InputResolver = class extends GraphResolver {
|
|
|
1134
1207
|
kind: "instance",
|
|
1135
1208
|
instance: node.instance,
|
|
1136
1209
|
component: node.component,
|
|
1137
|
-
|
|
1210
|
+
entities: node.entities,
|
|
1211
|
+
resolvedInputs: mapValues2(node.instance.resolvedInputs, (inputs, inputName) => {
|
|
1138
1212
|
const componentInput = node.component.inputs[inputName];
|
|
1139
1213
|
if (!componentInput) {
|
|
1140
1214
|
this.logger.warn({
|
|
@@ -1151,14 +1225,14 @@ var InputResolver = class extends GraphResolver {
|
|
|
1151
1225
|
matchedInjectionInputs: []
|
|
1152
1226
|
};
|
|
1153
1227
|
}
|
|
1154
|
-
const resolvedInputsMap =
|
|
1228
|
+
const resolvedInputsMap = new Map;
|
|
1155
1229
|
const addInstanceResult = (inputName, input) => {
|
|
1156
1230
|
let inputs = resolvedInputsMap.get(inputName);
|
|
1157
1231
|
if (!inputs) {
|
|
1158
|
-
inputs =
|
|
1232
|
+
inputs = new Map;
|
|
1159
1233
|
resolvedInputsMap.set(inputName, inputs);
|
|
1160
1234
|
}
|
|
1161
|
-
inputs.set(
|
|
1235
|
+
inputs.set(inputKey(input.input), input);
|
|
1162
1236
|
};
|
|
1163
1237
|
const addInstanceInput = (inputName, input) => {
|
|
1164
1238
|
const componentInput = node.component.inputs[inputName];
|
|
@@ -1176,15 +1250,31 @@ var InputResolver = class extends GraphResolver {
|
|
|
1176
1250
|
return;
|
|
1177
1251
|
}
|
|
1178
1252
|
if (isUnitModel(component)) {
|
|
1179
|
-
addInstanceResult(inputName, {
|
|
1253
|
+
addInstanceResult(inputName, {
|
|
1254
|
+
input,
|
|
1255
|
+
type: this.resolveOutputTypeForInput(input, componentInput.type)
|
|
1256
|
+
});
|
|
1180
1257
|
return;
|
|
1181
1258
|
}
|
|
1182
1259
|
if (resolvedOutputs) {
|
|
1183
1260
|
for (const output of resolvedOutputs) {
|
|
1184
|
-
addInstanceResult(inputName, {
|
|
1261
|
+
addInstanceResult(inputName, {
|
|
1262
|
+
input: {
|
|
1263
|
+
...output,
|
|
1264
|
+
path: input.path ?? output.path
|
|
1265
|
+
},
|
|
1266
|
+
type: this.resolveOutputTypeForInput({
|
|
1267
|
+
instanceId: input.instanceId,
|
|
1268
|
+
output: input.output,
|
|
1269
|
+
path: input.path ?? output.path
|
|
1270
|
+
}, componentInput.type)
|
|
1271
|
+
});
|
|
1185
1272
|
}
|
|
1186
1273
|
} else {
|
|
1187
|
-
addInstanceResult(inputName, {
|
|
1274
|
+
addInstanceResult(inputName, {
|
|
1275
|
+
input,
|
|
1276
|
+
type: this.resolveOutputTypeForInput(input, componentInput.type)
|
|
1277
|
+
});
|
|
1188
1278
|
}
|
|
1189
1279
|
};
|
|
1190
1280
|
for (const [inputName, inputs] of Object.entries(node.instance.inputs ?? {})) {
|
|
@@ -1192,12 +1282,12 @@ var InputResolver = class extends GraphResolver {
|
|
|
1192
1282
|
addInstanceInput(inputName, input);
|
|
1193
1283
|
}
|
|
1194
1284
|
}
|
|
1195
|
-
const injectionInputs =
|
|
1196
|
-
const matchedInjectionInputs =
|
|
1285
|
+
const injectionInputs = new Map;
|
|
1286
|
+
const matchedInjectionInputs = new Map;
|
|
1197
1287
|
for (const injectionInput of node.instance.injectionInputs ?? []) {
|
|
1198
1288
|
const { resolvedInputs: resolvedInputs2 } = getHubOutput(injectionInput);
|
|
1199
1289
|
for (const input of resolvedInputs2) {
|
|
1200
|
-
injectionInputs.set(
|
|
1290
|
+
injectionInputs.set(inputKey(input.input), input);
|
|
1201
1291
|
}
|
|
1202
1292
|
}
|
|
1203
1293
|
for (const [inputName, componentInput] of Object.entries(node.component.inputs ?? {})) {
|
|
@@ -1206,36 +1296,35 @@ var InputResolver = class extends GraphResolver {
|
|
|
1206
1296
|
for (const hubInput of hubInputs) {
|
|
1207
1297
|
const { resolvedInputs: resolvedInputs2 } = getHubOutput(hubInput);
|
|
1208
1298
|
for (const input of resolvedInputs2) {
|
|
1209
|
-
allInputs.set(
|
|
1299
|
+
allInputs.set(inputKey(input.input), input);
|
|
1210
1300
|
}
|
|
1211
1301
|
}
|
|
1212
1302
|
for (const input of allInputs.values()) {
|
|
1213
1303
|
if (input.type === componentInput.type) {
|
|
1214
1304
|
addInstanceInput(inputName, input.input);
|
|
1215
|
-
const key =
|
|
1305
|
+
const key = inputKey(input.input);
|
|
1216
1306
|
if (injectionInputs.has(key)) {
|
|
1217
1307
|
matchedInjectionInputs.set(key, input);
|
|
1218
1308
|
}
|
|
1219
1309
|
}
|
|
1220
1310
|
}
|
|
1221
1311
|
}
|
|
1222
|
-
const resolvedInputs = fromEntries(
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
])
|
|
1227
|
-
);
|
|
1312
|
+
const resolvedInputs = fromEntries(Array.from(resolvedInputsMap.entries()).map(([inputName, inputs]) => [
|
|
1313
|
+
inputName,
|
|
1314
|
+
Array.from(inputs.values())
|
|
1315
|
+
]));
|
|
1228
1316
|
return {
|
|
1229
1317
|
kind: "instance",
|
|
1230
1318
|
instance: node.instance,
|
|
1231
1319
|
component: node.component,
|
|
1320
|
+
entities: node.entities,
|
|
1232
1321
|
resolvedInputs,
|
|
1233
1322
|
resolvedOutputs: node.instance.resolvedOutputs,
|
|
1234
1323
|
resolvedInjectionInputs: Array.from(injectionInputs.values()),
|
|
1235
1324
|
matchedInjectionInputs: Array.from(matchedInjectionInputs.values())
|
|
1236
1325
|
};
|
|
1237
1326
|
}
|
|
1238
|
-
}
|
|
1327
|
+
}
|
|
1239
1328
|
function getResolvedHubInputs(outputMap, hubId) {
|
|
1240
1329
|
const output = outputMap.get(`hub:${hubId}`);
|
|
1241
1330
|
if (!output) {
|
|
@@ -1279,22 +1368,28 @@ function getMatchedInjectionInstanceInputs(outputMap, instanceId) {
|
|
|
1279
1368
|
function getResolvedInstanceOutputs(outputMap, instanceId) {
|
|
1280
1369
|
const output = outputMap.get(`instance:${instanceId}`);
|
|
1281
1370
|
if (!output) {
|
|
1282
|
-
return
|
|
1371
|
+
return;
|
|
1283
1372
|
}
|
|
1284
1373
|
if (output.kind !== "instance") {
|
|
1285
1374
|
throw new Error("Expected instance node");
|
|
1286
1375
|
}
|
|
1287
1376
|
return output.resolvedOutputs;
|
|
1288
1377
|
}
|
|
1378
|
+
// src/shared/resolvers/input-hash.ts
|
|
1379
|
+
import { crc32 } from "@aws-crypto/crc32";
|
|
1380
|
+
import { isUnitModel as isUnitModel2 } from "@highstate/contract";
|
|
1381
|
+
import { encode } from "@msgpack/msgpack";
|
|
1382
|
+
import { Buffer } from "buffer-polyfill";
|
|
1289
1383
|
|
|
1290
1384
|
// src/shared/utils/async-batcher.ts
|
|
1291
|
-
function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs =
|
|
1385
|
+
function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs = 1000 } = {}) {
|
|
1292
1386
|
let batch = [];
|
|
1293
1387
|
let activeTimeout = null;
|
|
1294
1388
|
let maxWaitTimeout = null;
|
|
1295
1389
|
let firstCallTimestamp = null;
|
|
1296
1390
|
async function processBatch() {
|
|
1297
|
-
if (batch.length === 0)
|
|
1391
|
+
if (batch.length === 0)
|
|
1392
|
+
return;
|
|
1298
1393
|
const currentBatch = batch;
|
|
1299
1394
|
batch = [];
|
|
1300
1395
|
await fn(currentBatch);
|
|
@@ -1305,31 +1400,27 @@ function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs = 1e3 } = {}) {
|
|
|
1305
1400
|
firstCallTimestamp = null;
|
|
1306
1401
|
}
|
|
1307
1402
|
function schedule() {
|
|
1308
|
-
if (activeTimeout)
|
|
1403
|
+
if (activeTimeout)
|
|
1404
|
+
clearTimeout(activeTimeout);
|
|
1309
1405
|
activeTimeout = setTimeout(() => {
|
|
1310
1406
|
activeTimeout = null;
|
|
1311
|
-
|
|
1407
|
+
processBatch();
|
|
1312
1408
|
}, waitMs);
|
|
1313
1409
|
if (!firstCallTimestamp) {
|
|
1314
1410
|
firstCallTimestamp = Date.now();
|
|
1315
1411
|
maxWaitTimeout = setTimeout(() => {
|
|
1316
|
-
if (activeTimeout)
|
|
1412
|
+
if (activeTimeout)
|
|
1413
|
+
clearTimeout(activeTimeout);
|
|
1317
1414
|
activeTimeout = null;
|
|
1318
|
-
|
|
1415
|
+
processBatch();
|
|
1319
1416
|
}, maxWaitTimeMs);
|
|
1320
1417
|
}
|
|
1321
1418
|
}
|
|
1322
1419
|
return {
|
|
1323
|
-
/**
|
|
1324
|
-
* Add an item to the batch.
|
|
1325
|
-
*/
|
|
1326
1420
|
call(item) {
|
|
1327
1421
|
batch.push(item);
|
|
1328
1422
|
schedule();
|
|
1329
1423
|
},
|
|
1330
|
-
/**
|
|
1331
|
-
* Immediately flush the pending batch (if any).
|
|
1332
|
-
*/
|
|
1333
1424
|
async flush() {
|
|
1334
1425
|
if (activeTimeout) {
|
|
1335
1426
|
clearTimeout(activeTimeout);
|
|
@@ -1343,7 +1434,6 @@ function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs = 1e3 } = {}) {
|
|
|
1343
1434
|
}
|
|
1344
1435
|
};
|
|
1345
1436
|
}
|
|
1346
|
-
|
|
1347
1437
|
// src/shared/utils/hash.ts
|
|
1348
1438
|
function int32ToBytes(value) {
|
|
1349
1439
|
const buffer = new ArrayBuffer(4);
|
|
@@ -1351,20 +1441,13 @@ function int32ToBytes(value) {
|
|
|
1351
1441
|
view.setInt32(0, value, true);
|
|
1352
1442
|
return new Uint8Array(buffer);
|
|
1353
1443
|
}
|
|
1354
|
-
|
|
1355
1444
|
// src/shared/utils/promise-tracker.ts
|
|
1356
|
-
|
|
1357
|
-
trackedPromises =
|
|
1358
|
-
/**
|
|
1359
|
-
* Tracks a promise to ensure its rejection is handled inside the tracker's scope.
|
|
1360
|
-
*/
|
|
1445
|
+
class PromiseTracker {
|
|
1446
|
+
trackedPromises = new Set;
|
|
1361
1447
|
track(promise) {
|
|
1362
1448
|
const wrapped = promise.finally(() => this.trackedPromises.delete(promise));
|
|
1363
1449
|
this.trackedPromises.add(wrapped);
|
|
1364
1450
|
}
|
|
1365
|
-
/**
|
|
1366
|
-
* Waits for all tracked promises to resolve or reject.
|
|
1367
|
-
*/
|
|
1368
1451
|
async waitForAll() {
|
|
1369
1452
|
if (this.trackedPromises.size === 0) {
|
|
1370
1453
|
return;
|
|
@@ -1373,21 +1456,53 @@ var PromiseTracker = class {
|
|
|
1373
1456
|
this.trackedPromises.clear();
|
|
1374
1457
|
await waitAll(toTrack);
|
|
1375
1458
|
}
|
|
1376
|
-
}
|
|
1459
|
+
}
|
|
1377
1460
|
async function waitAll(promises) {
|
|
1378
1461
|
const results = await Promise.allSettled(promises);
|
|
1379
1462
|
const rejected = results.filter((p) => p.status === "rejected");
|
|
1380
1463
|
if (!rejected.length) {
|
|
1381
1464
|
return;
|
|
1382
1465
|
}
|
|
1383
|
-
throw new AggregateError(
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1466
|
+
throw new AggregateError(rejected.map((p) => p.reason), "Some promises were rejected");
|
|
1467
|
+
}
|
|
1468
|
+
// src/shared/utils/stable-json.ts
|
|
1469
|
+
function stableJsonStringify(value) {
|
|
1470
|
+
if (value === null) {
|
|
1471
|
+
return "null";
|
|
1472
|
+
}
|
|
1473
|
+
if (Array.isArray(value)) {
|
|
1474
|
+
return `[${value.map(stableJsonStringify).join(",")}]`;
|
|
1475
|
+
}
|
|
1476
|
+
switch (typeof value) {
|
|
1477
|
+
case "string":
|
|
1478
|
+
return JSON.stringify(value);
|
|
1479
|
+
case "number": {
|
|
1480
|
+
if (!Number.isFinite(value)) {
|
|
1481
|
+
throw new Error("Snapshot content contains a non-finite number");
|
|
1482
|
+
}
|
|
1483
|
+
return JSON.stringify(value);
|
|
1484
|
+
}
|
|
1485
|
+
case "boolean":
|
|
1486
|
+
return value ? "true" : "false";
|
|
1487
|
+
case "object": {
|
|
1488
|
+
const record = value;
|
|
1489
|
+
const keys = Object.keys(record).sort();
|
|
1490
|
+
const parts = [];
|
|
1491
|
+
for (const key of keys) {
|
|
1492
|
+
const item = record[key];
|
|
1493
|
+
if (item === undefined) {
|
|
1494
|
+
throw new Error("Snapshot content contains undefined");
|
|
1495
|
+
}
|
|
1496
|
+
parts.push(`${JSON.stringify(key)}:${stableJsonStringify(item)}`);
|
|
1497
|
+
}
|
|
1498
|
+
return `{${parts.join(",")}}`;
|
|
1499
|
+
}
|
|
1500
|
+
default:
|
|
1501
|
+
throw new Error(`Snapshot content contains non-JSON value of type "${typeof value}"`);
|
|
1502
|
+
}
|
|
1387
1503
|
}
|
|
1388
|
-
|
|
1389
1504
|
// src/shared/resolvers/input-hash.ts
|
|
1390
|
-
|
|
1505
|
+
class InputHashResolver extends GraphResolver {
|
|
1391
1506
|
getNodeDependencies({ resolvedInputs }) {
|
|
1392
1507
|
const dependencies = [];
|
|
1393
1508
|
for (const inputs of Object.values(resolvedInputs ?? {})) {
|
|
@@ -1402,41 +1517,35 @@ var InputHashResolver = class extends GraphResolver {
|
|
|
1402
1517
|
component,
|
|
1403
1518
|
resolvedInputs,
|
|
1404
1519
|
sourceHash,
|
|
1405
|
-
state
|
|
1520
|
+
state: state2
|
|
1406
1521
|
}) {
|
|
1407
1522
|
const selfHashSink = [];
|
|
1408
1523
|
selfHashSink.push(Buffer.from(instance.id));
|
|
1409
1524
|
selfHashSink.push(int32ToBytes(component.definitionHash));
|
|
1410
|
-
if (
|
|
1411
|
-
selfHashSink.push(int32ToBytes(
|
|
1525
|
+
if (state2?.inputHashNonce) {
|
|
1526
|
+
selfHashSink.push(int32ToBytes(state2.inputHashNonce));
|
|
1412
1527
|
}
|
|
1413
1528
|
if (instance.args) {
|
|
1414
1529
|
selfHashSink.push(encode(instance.args));
|
|
1415
1530
|
}
|
|
1416
1531
|
if (sourceHash) {
|
|
1417
1532
|
selfHashSink.push(int32ToBytes(sourceHash));
|
|
1418
|
-
} else if (
|
|
1419
|
-
this.logger.warn(
|
|
1420
|
-
{ instanceId: instance.id },
|
|
1421
|
-
"missing source hash for unit model, this may lead to incorrect input hash"
|
|
1422
|
-
);
|
|
1533
|
+
} else if (isUnitModel2(component)) {
|
|
1534
|
+
this.logger.warn({ instanceId: instance.id }, "missing source hash for unit model, this may lead to incorrect input hash");
|
|
1423
1535
|
}
|
|
1424
1536
|
const inputHashSink = [...selfHashSink];
|
|
1425
1537
|
const sortedInputs = Object.entries(resolvedInputs).sort(([a], [b]) => a.localeCompare(b));
|
|
1426
|
-
const dependencyInstanceIds =
|
|
1427
|
-
for (const [
|
|
1538
|
+
const dependencyInstanceIds = new Set;
|
|
1539
|
+
for (const [inputKey2, inputs] of sortedInputs) {
|
|
1428
1540
|
if (Object.keys(inputs).length === 0) {
|
|
1429
1541
|
continue;
|
|
1430
1542
|
}
|
|
1431
|
-
inputHashSink.push(Buffer.from(
|
|
1543
|
+
inputHashSink.push(Buffer.from(inputKey2));
|
|
1432
1544
|
const instanceIds = inputs.map((input) => input.input.instanceId).sort();
|
|
1433
1545
|
for (const instanceId of instanceIds) {
|
|
1434
1546
|
const dependency = this.outputs.get(instanceId);
|
|
1435
1547
|
if (!dependency) {
|
|
1436
|
-
this.logger.warn(
|
|
1437
|
-
{ instanceId, dependentInstanceId: instance.id },
|
|
1438
|
-
"missing dependency when calculating input hash, this may lead to incorrect input hash"
|
|
1439
|
-
);
|
|
1548
|
+
this.logger.warn({ instanceId, dependentInstanceId: instance.id }, "missing dependency when calculating input hash, this may lead to incorrect input hash");
|
|
1440
1549
|
continue;
|
|
1441
1550
|
}
|
|
1442
1551
|
inputHashSink.push(int32ToBytes(dependency.inputHash));
|
|
@@ -1449,10 +1558,7 @@ var InputHashResolver = class extends GraphResolver {
|
|
|
1449
1558
|
for (const dependencyInstanceId of sortedDependencyInstanceIds) {
|
|
1450
1559
|
const dependency = this.outputs.get(dependencyInstanceId);
|
|
1451
1560
|
if (!dependency) {
|
|
1452
|
-
this.logger.warn(
|
|
1453
|
-
{ instanceId: dependencyInstanceId, dependentInstanceId: instance.id },
|
|
1454
|
-
"missing dependency when calculating dependency output hash, this may lead to incorrect input hash"
|
|
1455
|
-
);
|
|
1561
|
+
this.logger.warn({ instanceId: dependencyInstanceId, dependentInstanceId: instance.id }, "missing dependency when calculating dependency output hash, this may lead to incorrect input hash");
|
|
1456
1562
|
continue;
|
|
1457
1563
|
}
|
|
1458
1564
|
dependencyOutputHashSink.push(int32ToBytes(dependency.outputHash));
|
|
@@ -1461,11 +1567,18 @@ var InputHashResolver = class extends GraphResolver {
|
|
|
1461
1567
|
selfHash: crc32(Buffer.concat(selfHashSink)),
|
|
1462
1568
|
inputHash: crc32(Buffer.concat(inputHashSink)),
|
|
1463
1569
|
dependencyOutputHash: crc32(Buffer.concat(dependencyOutputHashSink)),
|
|
1464
|
-
outputHash:
|
|
1570
|
+
outputHash: state2?.outputHash ?? 0
|
|
1465
1571
|
};
|
|
1466
1572
|
}
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1573
|
+
}
|
|
1574
|
+
// src/shared/resolvers/validation.ts
|
|
1575
|
+
import {
|
|
1576
|
+
isUnitModel as isUnitModel3,
|
|
1577
|
+
parseArgumentValue
|
|
1578
|
+
} from "@highstate/contract";
|
|
1579
|
+
import { Ajv } from "ajv";
|
|
1580
|
+
import styles from "ansi-styles";
|
|
1581
|
+
class ValidationResolver extends GraphResolver {
|
|
1469
1582
|
getNodeDependencies({ resolvedInputs }) {
|
|
1470
1583
|
const dependencies = [];
|
|
1471
1584
|
for (const inputs of Object.values(resolvedInputs)) {
|
|
@@ -1475,38 +1588,29 @@ var ValidationResolver = class extends GraphResolver {
|
|
|
1475
1588
|
}
|
|
1476
1589
|
return dependencies;
|
|
1477
1590
|
}
|
|
1478
|
-
processNode({ instance, component, state, resolvedInputs }) {
|
|
1591
|
+
processNode({ instance, component, state: state2, resolvedInputs }) {
|
|
1479
1592
|
const ajv = new Ajv({ strict: false });
|
|
1480
1593
|
this.logger.debug({ instanceId: instance.id }, "validating instance");
|
|
1481
1594
|
const validationErrors = [];
|
|
1482
1595
|
for (const [name, argument] of Object.entries(component.args)) {
|
|
1483
1596
|
try {
|
|
1484
1597
|
const value = parseArgumentValue(instance.args?.[name]);
|
|
1485
|
-
if (!argument.required && value ===
|
|
1598
|
+
if (!argument.required && value === undefined) {
|
|
1486
1599
|
continue;
|
|
1487
1600
|
}
|
|
1488
1601
|
if (!ajv.validate(argument.schema, value)) {
|
|
1489
1602
|
this.logger.debug({ instanceId: instance.id, argumentName: name }, "invalid argument");
|
|
1490
|
-
validationErrors.push(
|
|
1491
|
-
`Invalid argument "${styles.blueBright.open}${name}${styles.reset.close}": ` + ajv.errorsText()
|
|
1492
|
-
);
|
|
1603
|
+
validationErrors.push(`Invalid argument ` + `"${styles.blueBright.open}${name}${styles.reset.close}": ` + ajv.errorsText());
|
|
1493
1604
|
}
|
|
1494
1605
|
} catch (error) {
|
|
1495
|
-
this.logger.debug(
|
|
1496
|
-
|
|
1497
|
-
"failed to validate argument"
|
|
1498
|
-
);
|
|
1499
|
-
validationErrors.push(
|
|
1500
|
-
`Failed to validate argument "${styles.blueBright.open}${name}${styles.reset.close}": ` + (error instanceof Error ? error.message : String(error))
|
|
1501
|
-
);
|
|
1606
|
+
this.logger.debug({ instanceId: instance.id, argumentName: name, error }, "failed to validate argument");
|
|
1607
|
+
validationErrors.push(`Failed to validate argument ` + `"${styles.blueBright.open}${name}${styles.reset.close}": ` + (error instanceof Error ? error.message : String(error)));
|
|
1502
1608
|
}
|
|
1503
1609
|
}
|
|
1504
|
-
if (
|
|
1505
|
-
for (const [
|
|
1506
|
-
if (secretSchema.required && !
|
|
1507
|
-
validationErrors.push(
|
|
1508
|
-
`Missing required secret "${styles.blueBright.open}${secret}${styles.reset.close}"`
|
|
1509
|
-
);
|
|
1610
|
+
if (isUnitModel3(component)) {
|
|
1611
|
+
for (const [secret2, secretSchema] of Object.entries(component.secrets)) {
|
|
1612
|
+
if (secretSchema.required && !state2?.secretNames?.includes(secret2)) {
|
|
1613
|
+
validationErrors.push(`Missing required secret ` + `"${styles.blueBright.open}${secret2}${styles.reset.close}"`);
|
|
1510
1614
|
}
|
|
1511
1615
|
}
|
|
1512
1616
|
}
|
|
@@ -1514,10 +1618,8 @@ var ValidationResolver = class extends GraphResolver {
|
|
|
1514
1618
|
for (const input of inputs) {
|
|
1515
1619
|
const inputInstance = this.outputs.get(input.input.instanceId);
|
|
1516
1620
|
if (inputInstance?.status !== "ok") {
|
|
1517
|
-
validationErrors.push(
|
|
1518
|
-
|
|
1519
|
-
"${styles.blueBright.open}${input.input.instanceId}${styles.reset.close}" has validation errors`
|
|
1520
|
-
);
|
|
1621
|
+
validationErrors.push(`Invalid input ` + `"${styles.blueBright.open}${key}${styles.reset.close}":
|
|
1622
|
+
` + `"${styles.blueBright.open}${input.input.instanceId}${styles.reset.close}" ` + `has validation errors`);
|
|
1521
1623
|
}
|
|
1522
1624
|
}
|
|
1523
1625
|
}
|
|
@@ -1526,9 +1628,7 @@ var ValidationResolver = class extends GraphResolver {
|
|
|
1526
1628
|
continue;
|
|
1527
1629
|
}
|
|
1528
1630
|
if (!resolvedInputs[name] || !resolvedInputs[name].length) {
|
|
1529
|
-
validationErrors.push(
|
|
1530
|
-
`Missing required input "${styles.blueBright.open}${name}${styles.reset.close}" of type "${styles.greenBright.open}${input.type}${styles.reset.close}"`
|
|
1531
|
-
);
|
|
1631
|
+
validationErrors.push(`Missing required input ` + `"${styles.blueBright.open}${name}${styles.reset.close}" ` + `of type ` + `"${styles.greenBright.open}${input.type}${styles.reset.close}"`);
|
|
1532
1632
|
}
|
|
1533
1633
|
}
|
|
1534
1634
|
if (validationErrors.length === 0) {
|
|
@@ -1536,19 +1636,22 @@ var ValidationResolver = class extends GraphResolver {
|
|
|
1536
1636
|
}
|
|
1537
1637
|
const numberPrefixLength = (validationErrors.length + 1).toString().length + 2;
|
|
1538
1638
|
const formattedError = validationErrors.map((error, index) => {
|
|
1539
|
-
const lines = error.split(
|
|
1639
|
+
const lines = error.split(`
|
|
1640
|
+
`);
|
|
1540
1641
|
const prefix = `${index + 1}. `;
|
|
1541
1642
|
return lines.map((line, lineIndex) => {
|
|
1542
1643
|
const linePrefix = lineIndex === 0 ? prefix : " ".repeat(numberPrefixLength);
|
|
1543
1644
|
return `${linePrefix}${line}`;
|
|
1544
|
-
}).join(
|
|
1545
|
-
|
|
1645
|
+
}).join(`\r
|
|
1646
|
+
`);
|
|
1647
|
+
}).join(`\r
|
|
1648
|
+
`);
|
|
1546
1649
|
return {
|
|
1547
1650
|
status: "error",
|
|
1548
1651
|
errorText: formattedError
|
|
1549
1652
|
};
|
|
1550
1653
|
}
|
|
1551
|
-
}
|
|
1654
|
+
}
|
|
1552
1655
|
|
|
1553
1656
|
// src/shared/resolvers/registry.ts
|
|
1554
1657
|
var resolverFactories = {
|
|
@@ -1556,7 +1659,4 @@ var resolverFactories = {
|
|
|
1556
1659
|
InputHashResolver,
|
|
1557
1660
|
ValidationResolver
|
|
1558
1661
|
};
|
|
1559
|
-
|
|
1560
|
-
export { AccessError, BackendError, BackendUnlockMethodNotFoundError, CannotDeleteLastBackendUnlockMethodError, CannotDeleteLastUnlockMethodError, GraphResolver, InputHashResolver, InputResolver, InstanceLockLostError, InstanceLockedError, InstanceNotFoundError, InstanceStateNotFoundError, InvalidInstanceKindError, MAX_WORKER_START_ATTEMPTS, OperationNotFoundError, ProjectLockedError, ProjectNotFoundError, PromiseTracker, SystemSecretNames, ValidationResolver, WorkerVersionNotFoundError, apiKeyMetaSchema, apiKeyOutputSchema, apiKeyQuerySchema, applyLibraryUpdate, artifactOutputSchema, artifactQuerySchema, backendUnlockMethodInputSchema, backendUnlockMethodMetaSchema, codebaseLibrary, codebaseProjectModelStorage, collectionQueryResult, collectionQuerySchema, createAsyncBatcher, databaseProjectModelStorage, diffLibraries, extractDigestFromImage, finalInstanceOperationStatuses, finalOperationStatuses, forSchema, getAllDependents, getMatchedInjectionInstanceInputs, getResolvedHubInputs, getResolvedInjectionInstanceInputs, getResolvedInstanceInputs, getResolvedInstanceOutputs, getWorkerIdentity, globalProjectSpace, hasObjectMeta, hostPulumiBackend, instanceCustomStatusInputSchema, instanceLockEventSchema, instanceLockOutputSchema, instanceStateEventSchema, int32ToBytes, isFinalOperationStatus, isInstanceDeployed, isTransientInstanceOperationStatus, isTransientOperationStatus, isVirtualGhostInstance, librarySpecSchema, operationEventSchema, operationLaunchInputSchema, operationMetaSchema, operationOptionsSchema, operationOutputSchema, operationPhaseInstanceSchema, operationPhaseSchema, operationPhaseTypeSchema, operationPlanInputSchema, operationStatusSchema, operationTypeSchema, pageDetailsOutputSchema, pageOutputSchema, pageQuerySchema, projectInputSchema, projectModelEventSchema, projectModelStorageSpecSchema, projectOutputSchema, projectUnlockStateSchema, projectUnlockSuiteSchema, pulumiBackendSpecSchema, resolverFactories, secretOutputSchema, secretQuerySchema, serviceAccountOutputSchema, serviceAccountQuerySchema, stableInstanceInputSchema, terminalDetailsOutputSchema, terminalOutputSchema, terminalQuerySchema, terminalSessionOutputSchema, terminalStatusSchema, toApiKeyOutput, toPageOutput, toSecretOutput, toTerminalDetailsOutput, toTerminalOutput, toTerminalSessionOutput, toWorkerOutput, toWorkerVersionOutput, triggerOutputSchema, triggerQuerySchema, unlockMethodInputSchema, unlockMethodMetaSchema, unlockMethodOutputSchema, unlockMethodType, waitAll, workerOutputSchema, workerQuerySchema, workerUnitRegistrationEventSchema, workerVersionOutputSchema, workerVersionStatusSchema };
|
|
1561
|
-
//# sourceMappingURL=chunk-V2NILDHS.js.map
|
|
1562
|
-
//# sourceMappingURL=chunk-V2NILDHS.js.map
|
|
1662
|
+
export { librarySpecSchema, diffLibraries, applyLibraryUpdate, globalProjectSpace, codebaseLibrary, hostPulumiBackend, codebaseProjectModelStorage, databaseProjectModelStorage, projectModelStorageSpecSchema, projectInputSchema, projectOutputSchema, projectUnlockSuiteSchema, projectUnlockStateSchema, pulumiBackendSpecSchema, backendUnlockMethodMetaSchema, backendUnlockMethodInputSchema, hasObjectMeta, collectionQuerySchema, collectionQueryResult, forSchema, BackendError, AccessError, ProjectLockedError, ProjectNotFoundError, CannotDeleteLastUnlockMethodError, InstanceNotFoundError, InvalidInstanceKindError, OperationNotFoundError, InstanceLockLostError, InstanceStateNotFoundError, InstanceLockedError, WorkerVersionNotFoundError, BackendUnlockMethodNotFoundError, CannotDeleteLastBackendUnlockMethodError, apiKeyMetaSchema, apiKeyOutputSchema, apiKeyQuerySchema, toApiKeyOutput, artifactOutputSchema, artifactQuerySchema, instanceCustomStatusInputSchema, entityOutputSchema, entityQuerySchema, entitySnapshotOutputSchema, entitySnapshotListItemOutputSchema, entitySnapshotDetailsOutputSchema, entityDetailsOutputSchema, entityReferenceOutputSchema, toCommonEntityMeta, instanceLockOutputSchema, instanceLockEventSchema, projectModelEventSchema, operationPhaseTypeSchema, operationPhaseInstanceSchema, operationPhaseSchema, operationOptionsSchema, operationTypeSchema, operationStatusSchema, operationMetaSchema, operationPlanInputSchema, operationLaunchInputSchema, operationEventSchema, operationOutputSchema, finalOperationStatuses, isFinalOperationStatus, isTransientOperationStatus, pageOutputSchema, pageQuerySchema, pageDetailsOutputSchema, toPageOutput, secretOutputSchema, secretQuerySchema, toSecretOutput, SystemSecretNames, serviceAccountOutputSchema, serviceAccountQuerySchema, stableInstanceInputSchema, instanceStateEventSchema, isVirtualGhostInstance, isInstanceDeployed, finalInstanceOperationStatuses, isTransientInstanceOperationStatus, workerUnitRegistrationEventSchema, terminalStatusSchema, terminalSessionOutputSchema, terminalOutputSchema, terminalQuerySchema, toTerminalOutput, toTerminalDetailsOutput, terminalDetailsOutputSchema, toTerminalSessionOutput, triggerOutputSchema, triggerQuerySchema, unlockMethodType, unlockMethodMetaSchema, unlockMethodInputSchema, unlockMethodOutputSchema, MAX_WORKER_START_ATTEMPTS, extractDigestFromImage, getWorkerIdentity, workerVersionStatusSchema, workerVersionStatusEventSchema, workerVersionOutputSchema, workerOutputSchema, workerQuerySchema, toWorkerOutput, toWorkerVersionOutput, resolveEffectiveOutputType, GraphResolver, getAllDependents, InputResolver, getResolvedHubInputs, getResolvedInstanceInputs, getResolvedInjectionInstanceInputs, getMatchedInjectionInstanceInputs, getResolvedInstanceOutputs, createAsyncBatcher, int32ToBytes, PromiseTracker, waitAll, stableJsonStringify, InputHashResolver, ValidationResolver, resolverFactories };
|