@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.
@@ -1,13 +1,6 @@
1
- import { z, commonObjectMetaSchema, genericNameSchema, timestampsSchema, objectMetaSchema, serviceAccountMetaSchema, instanceIdSchema, instanceModelSchema, hubModelSchema, pageBlockSchema, globalCommonObjectMetaSchema, terminalSpecSchema, inputKey, isUnitModel, parseArgumentValue } from '@highstate/contract';
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 = z.discriminatedUnion("type", [
108
- z.object({
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
- z.object({
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 = z.object({
110
+ var projectInputSchema = z2.object({
122
111
  name: genericNameSchema,
123
- spaceId: z.cuid2().default(globalProjectSpace.id),
124
- modelStorageId: z.cuid2().default(codebaseProjectModelStorage.id),
125
- libraryId: z.cuid2().default(codebaseLibrary.id),
126
- pulumiBackendId: z.cuid2().default(hostPulumiBackend.id),
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 = z.object({
130
- id: z.string(),
118
+ var projectOutputSchema = z2.object({
119
+ id: z2.string(),
131
120
  name: genericNameSchema,
132
121
  meta: commonObjectMetaSchema,
133
- spaceId: z.cuid2(),
134
- modelStorageId: z.cuid2(),
135
- libraryId: z.cuid2(),
136
- pulumiBackendId: z.cuid2(),
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 = z.object({
140
- /**
141
- * The list of encrypted AGE identities that can be used to decrypt the master key of the project.
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 = z.discriminatedUnion("type", [
153
- z.object({
154
- type: z.literal("locked"),
132
+ var projectUnlockStateSchema = z2.discriminatedUnion("type", [
133
+ z2.object({
134
+ type: z2.literal("locked"),
155
135
  unlockSuite: projectUnlockSuiteSchema.optional()
156
136
  }),
157
- z.object({
158
- type: z.literal("unlocked")
137
+ z2.object({
138
+ type: z2.literal("unlocked")
159
139
  })
160
140
  ]);
161
- var pulumiBackendSpecSchema = z.discriminatedUnion("type", [
162
- z.object({
163
- /**
164
- * Use the Pulumi backend configured on the host where Highstate backend is running.
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 = z$1.object({
152
+ var backendUnlockMethodInputSchema = z4.object({
173
153
  meta: backendUnlockMethodMetaSchema,
174
- recipient: z$1.string()
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 = z$1.object({
180
- key: z$1.string(),
181
- order: z$1.enum(["asc", "desc"])
162
+ var sortBySchema = z5.object({
163
+ key: z5.string(),
164
+ order: z5.enum(["asc", "desc"])
182
165
  });
183
- var collectionQuerySchema = z$1.object({
184
- /**
185
- * The search string to filter documents by display name, description, or other text fields.
186
- */
187
- search: z$1.string().optional(),
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 z$1.object({
211
- items: z$1.array(schema),
212
- total: z$1.number().int().nonnegative()
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
- var BackendError = class extends Error {
182
+ class BackendError extends Error {
221
183
  constructor(message, cause) {
222
184
  super(message, { cause });
223
185
  this.name = "BackendError";
224
186
  }
225
- };
226
- var AccessError = class extends BackendError {
187
+ }
188
+
189
+ class AccessError extends BackendError {
227
190
  constructor(message) {
228
191
  super(message);
229
192
  this.name = "AccessError";
230
193
  }
231
- };
232
- var ProjectLockedError = class extends AccessError {
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
- var ProjectNotFoundError = class extends BackendError {
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
- var CannotDeleteLastUnlockMethodError = class extends BackendError {
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
- var InstanceNotFoundError = class extends BackendError {
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
- var InvalidInstanceKindError = class extends BackendError {
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
- var OperationNotFoundError = class extends BackendError {
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
- var InstanceLockLostError = class extends BackendError {
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
- var InstanceStateNotFoundError = class extends BackendError {
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
- var InstanceLockedError = class extends BackendError {
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
- var WorkerVersionNotFoundError = class extends BackendError {
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
- var BackendUnlockMethodNotFoundError = class extends BackendError {
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
- var CannotDeleteLastBackendUnlockMethodError = class extends BackendError {
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
- var apiKeyMetaSchema = objectMetaSchema.pick({
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 = z.object({
312
- id: z.cuid2(),
313
- meta: commonObjectMetaSchema,
314
- serviceAccountId: z.cuid2(),
289
+ var apiKeyOutputSchema = z6.object({
290
+ id: z6.cuid2(),
291
+ meta: commonObjectMetaSchema2,
292
+ serviceAccountId: z6.cuid2(),
315
293
  serviceAccountMeta: serviceAccountMetaSchema.nullable(),
316
- createdAt: z.date()
294
+ createdAt: z6.date()
317
295
  });
318
296
  var apiKeyQuerySchema = collectionQuerySchema.extend({
319
- serviceAccountId: z.string().optional()
297
+ serviceAccountId: z6.string().optional()
320
298
  });
321
299
  function toApiKeyOutput(apiKey, serviceAccount) {
322
300
  return {
@@ -324,97 +302,97 @@ function toApiKeyOutput(apiKey, serviceAccount) {
324
302
  serviceAccountMeta: serviceAccount?.meta ?? null
325
303
  };
326
304
  }
327
- var artifactOutputSchema = z$1.object({
328
- id: z$1.cuid2(),
329
- hash: z$1.string(),
330
- size: z$1.number(),
331
- meta: commonObjectMetaSchema,
332
- createdAt: z$1.date(),
333
- updatedAt: z$1.date()
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: z$1.string().optional(),
337
- serviceAccountId: z$1.string().optional(),
338
- terminalId: z$1.string().optional(),
339
- pageId: z$1.string().optional()
317
+ stateId: z7.string().optional(),
318
+ serviceAccountId: z7.string().optional(),
319
+ terminalId: z7.string().optional(),
320
+ pageId: z7.string().optional()
340
321
  });
341
- var instanceCustomStatusInputSchema = z$1.object({
342
- name: z$1.string(),
343
- meta: commonObjectMetaSchema,
344
- value: z$1.string(),
345
- message: z$1.string().optional(),
346
- order: z$1.number().min(0).max(100).optional()
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
- var rawEntityMetaSchema = z$1.object({
349
- identity: z$1.string().optional(),
350
- title: z$1.string().optional(),
351
- description: z$1.string().optional(),
352
- icon: z$1.string().optional(),
353
- iconColor: z$1.string().optional()
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()
354
341
  }).passthrough();
355
- var entityOutputSchema = z$1.object({
356
- id: z$1.string(),
357
- type: z$1.string(),
358
- identity: z$1.string(),
359
- meta: commonObjectMetaSchema,
360
- /**
361
- * The ID of the last known entity snapshot.
362
- */
363
- snapshotId: z$1.string().optional(),
364
- /**
365
- * The timestamp of the last known entity snapshot.
366
- */
367
- createdAt: z$1.date().optional()
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()
368
349
  });
369
350
  var entityQuerySchema = collectionQuerySchema.extend({
370
- type: z$1.string().optional()
351
+ type: z9.string().optional()
371
352
  });
372
- var entitySnapshotOutputSchema = z$1.object({
373
- id: z$1.string(),
374
- meta: commonObjectMetaSchema,
375
- content: z$1.unknown(),
376
- operationId: z$1.string(),
377
- stateId: z$1.string(),
378
- referencedInOutputs: z$1.string().array(),
379
- exportedInOutputs: z$1.string().array(),
380
- createdAt: z$1.date()
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()
381
362
  });
382
- var entitySnapshotListItemOutputSchema = z$1.object({
383
- id: z$1.string(),
384
- meta: commonObjectMetaSchema,
385
- operationId: z$1.string(),
386
- stateId: z$1.string(),
387
- createdAt: z$1.date()
363
+ var entitySnapshotListItemOutputSchema = z9.object({
364
+ id: z9.string(),
365
+ meta: commonObjectMetaSchema5,
366
+ operationId: z9.string(),
367
+ stateId: z9.string(),
368
+ createdAt: z9.date()
388
369
  });
389
- var entitySnapshotDetailsOutputSchema = z$1.object({
390
- entity: z$1.object({
391
- id: z$1.string(),
392
- type: z$1.string(),
393
- identity: z$1.string()
370
+ var entitySnapshotDetailsOutputSchema = z9.object({
371
+ entity: z9.object({
372
+ id: z9.string(),
373
+ type: z9.string(),
374
+ identity: z9.string()
394
375
  }),
395
376
  snapshot: entitySnapshotOutputSchema
396
377
  });
397
- var entityDetailsOutputSchema = z$1.object({
378
+ var entityDetailsOutputSchema = z9.object({
398
379
  ...entityOutputSchema.shape,
399
- /**
400
- * The last known entity snapshot.
401
- */
402
380
  lastSnapshot: entitySnapshotOutputSchema.nullable()
403
381
  });
404
- var entityReferenceOutputSchema = z$1.object({
405
- id: z$1.string(),
406
- meta: commonObjectMetaSchema,
407
- group: z$1.string(),
408
- fromSnapshotId: z$1.string(),
409
- fromEntityId: z$1.string(),
410
- fromEntityType: z$1.string(),
411
- fromEntityIdentity: z$1.string(),
412
- fromEntityMeta: commonObjectMetaSchema,
413
- toSnapshotId: z$1.string(),
414
- toEntityId: z$1.string(),
415
- toEntityType: z$1.string(),
416
- toEntityIdentity: z$1.string(),
417
- toEntityMeta: commonObjectMetaSchema
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
418
396
  });
419
397
  function toCommonEntityMeta(meta) {
420
398
  const parsedRawMeta = rawEntityMetaSchema.safeParse(meta);
@@ -430,263 +408,78 @@ function toCommonEntityMeta(meta) {
430
408
  title: "Unknown"
431
409
  };
432
410
  }
433
- var instanceLockOutputSchema = z$1.object({
434
- stateId: z$1.cuid2(),
435
- meta: commonObjectMetaSchema,
436
- acquiredAt: z$1.date()
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()
437
418
  });
438
- var instanceLockEventSchema = z$1.discriminatedUnion("type", [
439
- z$1.object({
440
- type: z$1.literal("locked"),
419
+ var instanceLockEventSchema = z10.discriminatedUnion("type", [
420
+ z10.object({
421
+ type: z10.literal("locked"),
441
422
  locks: instanceLockOutputSchema.array()
442
423
  }),
443
- z$1.object({
444
- type: z$1.literal("unlocked"),
445
- stateIds: z$1.array(z$1.string())
424
+ z10.object({
425
+ type: z10.literal("unlocked"),
426
+ stateIds: z10.array(z10.string())
446
427
  })
447
428
  ]);
448
- var projectModelEventSchema = z$1.object({
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({
449
437
  updatedInstances: instanceModelSchema.array().optional(),
450
438
  updatedHubs: hubModelSchema.array().optional(),
451
439
  updatedVirtualInstances: instanceModelSchema.array().optional(),
452
440
  updatedGhostInstances: instanceModelSchema.array().optional(),
453
441
  deletedInstanceIds: instanceIdSchema.array().optional(),
454
- deletedHubIds: z$1.string().array().optional(),
442
+ deletedHubIds: z11.string().array().optional(),
455
443
  deletedVirtualInstanceIds: instanceIdSchema.array().optional(),
456
444
  deletedGhostInstanceIds: instanceIdSchema.array().optional()
457
445
  });
458
- var operationPhaseTypeSchema = z.enum(["destroy", "preview", "update", "refresh"]);
459
- var operationPhaseInstanceSchema = z.object({
460
- /**
461
- * The ID of the instance.
462
- */
463
- id: instanceIdSchema,
464
- /**
465
- * The parent ID of the instance, either from the model or the state.
466
- */
467
- parentId: z.string().optional(),
468
- /**
469
- * Human-readable explanation of the decision.
470
- * */
471
- 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()
472
453
  });
473
- var operationPhaseSchema = z.object({
474
- /**
475
- * Type of phase being executed.
476
- */
454
+ var operationPhaseSchema = z12.object({
477
455
  type: operationPhaseTypeSchema,
478
- /**
479
- * List of instances to be processed in this phase.
480
- */
481
- instances: z.array(operationPhaseInstanceSchema)
456
+ instances: z12.array(operationPhaseInstanceSchema)
482
457
  });
483
- var operationOptionsSchema = z.object({
484
- /**
485
- * Force update all dependencies regardless of their current state.
486
- *
487
- * **Operation Behavior Impact:**
488
- * - bypasses hash-based change detection for dependency chains;
489
- * - includes **ALL** dependencies (up-to-date, out-of-date, and error states);
490
- * - traverses the entire dependency graph from requested instances.
491
- *
492
- * **Usage with other options:**
493
- * - combined with `forceUpdateChildren`: updates entire dependency tree **AND** all composite children;
494
- * - independent of `allowPartialCompositeInstanceCreation`: affects dependency traversal, not composite logic.
495
- */
496
- forceUpdateDependencies: z.boolean().default(false),
497
- /**
498
- * Ignore only changed dependencies and keep failed/undeployed prerequisites.
499
- *
500
- * **Operation Behavior Impact:**
501
- * - skips dependency inclusion when dependency is only changed;
502
- * - still includes failed or undeployed dependencies to preserve safety for missing/broken prerequisites;
503
- * - useful for targeted updates where stale-but-healthy dependencies are intentionally not traversed.
504
- *
505
- * **Usage with other options:**
506
- * - mutually exclusive with `forceUpdateDependencies`;
507
- * - mutually exclusive with `ignoreDependencies`;
508
- * - independent of child/composite inclusion options.
509
- */
510
- ignoreChangedDependencies: z.boolean().default(false),
511
- /**
512
- * Ignore all dependencies and operate only on explicitly requested instances.
513
- *
514
- * **Operation Behavior Impact:**
515
- * - skips dependency inclusion entirely, including failed and undeployed prerequisites;
516
- * - caller must explicitly include every prerequisite instance to avoid failures;
517
- * - intended for fully manual execution flows.
518
- *
519
- * **Usage with other options:**
520
- * - mutually exclusive with `forceUpdateDependencies`;
521
- * - mutually exclusive with `ignoreChangedDependencies`;
522
- * - independent of child/composite inclusion options.
523
- */
524
- ignoreDependencies: z.boolean().default(false),
525
- /**
526
- * Force update all children of composite instances regardless of their state.
527
- *
528
- * **Operation Behavior Impact:**
529
- * - overrides selective child inclusion logic for composites;
530
- * - includes **ALL** children of affected composites (up-to-date, out-of-date, and error states);
531
- * - applied after dependency traversal and parent inclusion.
532
- *
533
- * **Usage with other options:**
534
- * - combined with `forceUpdateDependencies`: creates comprehensive force-update behavior;
535
- * - overrides `allowPartialCompositeInstanceCreation`: when enabled, **ALL** children are included regardless of existence.
536
- */
537
- forceUpdateChildren: z.boolean().default(false),
538
- /**
539
- * Run only ghost cleanup destroy phase and skip update phase entirely.
540
- *
541
- * **Operation Behavior Impact:**
542
- * - applies to update operations only;
543
- * - skips update phase even if normal update candidates exist;
544
- * - keeps only ghost cleanup destroy phase for affected substantive composites.
545
- *
546
- * **Usage with other options:**
547
- * - mutually exclusive with `firstDestroyGhosts`;
548
- * - mutually exclusive with `ignoreGhosts`.
549
- */
550
- onlyDestroyGhosts: z.boolean().default(false),
551
- /**
552
- * Run ghost cleanup destroy phase before update phase.
553
- *
554
- * **Operation Behavior Impact:**
555
- * - applies to update operations only;
556
- * - keeps both phases but changes order to destroy ghosts first;
557
- * - useful when stale ghost resources should be removed prior to update execution.
558
- *
559
- * **Usage with other options:**
560
- * - mutually exclusive with `onlyDestroyGhosts`;
561
- * - mutually exclusive with `ignoreGhosts`.
562
- */
563
- firstDestroyGhosts: z.boolean().default(false),
564
- /**
565
- * Ignore ghost cleanup and skip destroy phase for ghosts.
566
- *
567
- * **Operation Behavior Impact:**
568
- * - applies to update operations only;
569
- * - disables ghost cleanup destroy phase generation;
570
- * - update phase remains unchanged.
571
- *
572
- * **Usage with other options:**
573
- * - mutually exclusive with `onlyDestroyGhosts`;
574
- * - mutually exclusive with `firstDestroyGhosts`.
575
- */
576
- ignoreGhosts: z.boolean().default(false),
577
- /**
578
- * Include dependent instances when destroying instances.
579
- *
580
- * **Operation Behavior Impact:**
581
- * - extends destroy operations to include instances that depend on the target;
582
- * - traverses the dependency graph in reverse (dependents, not dependencies);
583
- * - prevents orphaned instances that would fail without their dependencies.
584
- *
585
- * **Usage with other options:**
586
- * - works with `invokeDestroyTriggers`: ensures triggers run for all dependents;
587
- * - independent of update-related options.
588
- */
589
- destroyDependentInstances: z.boolean().default(true),
590
- /**
591
- * Execute destroy triggers when destroying instances.
592
- *
593
- * **Operation Behavior Impact:**
594
- * - affects how individual units are destroyed (triggers vs direct deletion);
595
- * - does not change which instances are selected for destruction;
596
- * - controls trigger execution during the destruction phase.
597
- *
598
- * **Usage with other options:**
599
- * - used with `destroyDependentInstances`: ensures triggers run for cascade deletions;
600
- * - independent of update-related options.
601
- */
602
- invokeDestroyTriggers: z.boolean().default(true),
603
- /**
604
- * Delete Pulumi resources that are no longer referenced in the state.
605
- *
606
- * **Operation Behavior Impact:**
607
- * - does not affect which instances are selected for operations;
608
- * - deletes orphaned Pulumi resources within individual instances.
609
- *
610
- * **Usage with other options:**
611
- * - independent of instance selection options;
612
- * - complements destroy-related options for thorough cleanup.
613
- */
614
- deleteUnreachableResources: z.boolean().default(false),
615
- /**
616
- * Force deletion of instance state even if the destroy operation fails.
617
- *
618
- * **Operation Behavior Impact:**
619
- * - forces state deletion even when destroy operations fail;
620
- * - does not affect which instances are selected for operations;
621
- * - bypasses normal destroy procedures as emergency fallback.
622
- *
623
- * **Usage with other options:**
624
- * - used with destroy-related options when normal cleanup fails;
625
- * - should be used cautiously as it can create state inconsistencies.
626
- */
627
- forceDeleteState: z.boolean().default(false),
628
- /**
629
- * Allow partial update of composite instances without requiring all outdated children.
630
- *
631
- * **Operation Behavior Impact:**
632
- * - controls whether composite operations must include all outdated children or only necessary ones;
633
- * - when `false` (default): all outdated children of substantive composites are included in operations;
634
- * - when `true`: only necessary children are included, allowing partial composite operations;
635
- * - applied during composite child traversal phase for substantive composites only.
636
- *
637
- * **Usage with other options:**
638
- * - overridden by `forceUpdateChildren`: when force is enabled, **ALL** children are included regardless;
639
- * - independent of `forceUpdateDependencies`: affects composite logic, not dependency traversal.
640
- */
641
- allowPartialCompositeInstanceUpdate: z.boolean().default(false),
642
- /**
643
- * Allow partial destruction of composite instances during cascade operations.
644
- *
645
- * **Operation Behavior Impact:**
646
- * - controls whether cascade destruction must include all children or only necessary ones;
647
- * - when `false` (default): cascade destruction includes **ALL** children of affected composites;
648
- * - when `true`: cascade destruction includes only directly dependent children;
649
- * - does not affect explicit composite destruction (always destroys all children);
650
- * - does not affect parent propagation when destroying sibling composites.
651
- *
652
- * **Usage with other options:**
653
- * - works with `destroyDependentInstances`: controls completeness of cascade destruction;
654
- * - independent of update-related options.
655
- */
656
- allowPartialCompositeInstanceDestruction: z.boolean().default(false),
657
- /**
658
- * Also refresh the state of instances during the operation.
659
- *
660
- * **Operation Behavior Impact:**
661
- * - does not change which instances are selected for operations;
662
- * - synchronizes state with actual infrastructure during the operation.
663
- *
664
- * **Usage with other options:**
665
- * - additive with dependency resolution options: refreshes all selected instances;
666
- * - works with both all operation types.
667
- */
668
- refresh: z.boolean().default(false),
669
- /**
670
- * Enable debug logging for Pulumi engine and resource providers.
671
- *
672
- * **Security Note:**
673
- * Debug mode may expose sensitive information including credentials in the logs.
674
- * Use only when absolutely necessary for troubleshooting.
675
- *
676
- * **Implementation:**
677
- * - sets Pulumi's debug option to true;
678
- * - sets TF_LOG=DEBUG environment variable for Terraform providers.
679
- */
680
- 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)
681
474
  }).partial();
682
- var operationTypeSchema = z.enum([
475
+ var operationTypeSchema = z12.enum([
683
476
  "update",
684
477
  "preview",
685
478
  "destroy",
686
479
  "recreate",
687
480
  "refresh"
688
481
  ]);
689
- var operationStatusSchema = z.enum([
482
+ var operationStatusSchema = z12.enum([
690
483
  "pending",
691
484
  "running",
692
485
  "failing",
@@ -695,38 +488,38 @@ var operationStatusSchema = z.enum([
695
488
  "cancelled",
696
489
  "cancelling"
697
490
  ]);
698
- var operationMetaSchema = objectMetaSchema.pick({
491
+ var operationMetaSchema = objectMetaSchema3.pick({
699
492
  title: true,
700
493
  description: true
701
494
  }).required({ title: true });
702
- var operationPlanInputSchema = z.object({
703
- projectId: z.string(),
495
+ var operationPlanInputSchema = z12.object({
496
+ projectId: z12.string(),
704
497
  type: operationTypeSchema,
705
- instanceIds: z.array(instanceIdSchema).min(1),
498
+ instanceIds: z12.array(instanceIdSchema2).min(1),
706
499
  options: operationOptionsSchema.partial().optional()
707
500
  });
708
501
  var operationLaunchInputSchema = operationPlanInputSchema.extend({
709
502
  meta: operationMetaSchema,
710
503
  plan: operationPhaseSchema.array().optional()
711
504
  });
712
- var operationEventSchema = z.discriminatedUnion("type", [
713
- z.object({
714
- type: z.literal("updated"),
715
- operation: z.custom()
505
+ var operationEventSchema = z12.discriminatedUnion("type", [
506
+ z12.object({
507
+ type: z12.literal("updated"),
508
+ operation: z12.custom()
716
509
  }),
717
- z.object({
718
- type: z.literal("deleted"),
719
- operationId: z.string()
510
+ z12.object({
511
+ type: z12.literal("deleted"),
512
+ operationId: z12.string()
720
513
  })
721
514
  ]);
722
- var operationOutputSchema = z.object({
723
- id: z.cuid2(),
515
+ var operationOutputSchema = z12.object({
516
+ id: z12.cuid2(),
724
517
  type: operationTypeSchema,
725
518
  status: operationStatusSchema,
726
519
  meta: operationMetaSchema,
727
- startedAt: z.date(),
728
- updatedAt: z.date(),
729
- finishedAt: z.date().nullable()
520
+ startedAt: z12.date(),
521
+ updatedAt: z12.date(),
522
+ finishedAt: z12.date().nullable()
730
523
  });
731
524
  var finalOperationStatuses = ["completed", "failed", "cancelled"];
732
525
  function isFinalOperationStatus(status) {
@@ -735,24 +528,31 @@ function isFinalOperationStatus(status) {
735
528
  function isTransientOperationStatus(status) {
736
529
  return !!status && !finalOperationStatuses.includes(status);
737
530
  }
738
- var pageOutputSchema = z$1.object({
739
- id: z$1.cuid2(),
740
- meta: commonObjectMetaSchema,
741
- name: z$1.string().nullable(),
742
- stateId: z$1.cuid2().nullable(),
743
- serviceAccountId: z$1.cuid2().nullable(),
744
- serviceAccountMeta: serviceAccountMetaSchema.nullable(),
745
- createdAt: z$1.date(),
746
- updatedAt: z$1.date()
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()
747
547
  });
748
548
  var pageQuerySchema = collectionQuerySchema.extend({
749
- serviceAccountId: z$1.string().optional(),
750
- stateId: z$1.string().optional(),
751
- artifactId: z$1.string().optional()
549
+ serviceAccountId: z13.string().optional(),
550
+ stateId: z13.string().optional(),
551
+ artifactId: z13.string().optional()
752
552
  });
753
- var pageDetailsOutputSchema = z$1.object({
553
+ var pageDetailsOutputSchema = z13.object({
754
554
  ...pageOutputSchema.shape,
755
- content: z$1.array(pageBlockSchema)
555
+ content: z13.array(pageBlockSchema)
756
556
  });
757
557
  function toPageOutput(page, serviceAccount) {
758
558
  return {
@@ -760,20 +560,22 @@ function toPageOutput(page, serviceAccount) {
760
560
  serviceAccountMeta: serviceAccount?.meta ?? null
761
561
  };
762
562
  }
763
- var secretOutputSchema = z.object({
764
- id: z.cuid2(),
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(),
765
567
  meta: globalCommonObjectMetaSchema,
766
- name: z.string().nullable(),
767
- systemName: z.string().nullable(),
768
- stateId: z.cuid2().nullable(),
769
- serviceAccountId: z.cuid2().nullable(),
770
- serviceAccountMeta: serviceAccountMetaSchema.nullable(),
771
- createdAt: z.date(),
772
- updatedAt: z.date()
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()
773
575
  });
774
576
  var secretQuerySchema = collectionQuerySchema.extend({
775
- serviceAccountId: z.string().optional(),
776
- stateId: z.string().optional()
577
+ serviceAccountId: z14.string().optional(),
578
+ stateId: z14.string().optional()
777
579
  });
778
580
  function toSecretOutput(secret, serviceAccount) {
779
581
  return {
@@ -781,51 +583,55 @@ function toSecretOutput(secret, serviceAccount) {
781
583
  serviceAccountMeta: serviceAccount?.meta ?? null
782
584
  };
783
585
  }
784
- var SystemSecretNames = /* @__PURE__ */ ((SystemSecretNames2) => {
586
+ var SystemSecretNames;
587
+ ((SystemSecretNames2) => {
785
588
  SystemSecretNames2["PulumiPassword"] = "pulumi-password";
786
- return SystemSecretNames2;
787
- })(SystemSecretNames || {});
788
- var serviceAccountOutputSchema = z.object({
789
- id: z.cuid2(),
790
- meta: serviceAccountMetaSchema,
791
- createdAt: z.date(),
792
- updatedAt: z.date()
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()
793
597
  });
794
598
  var serviceAccountQuerySchema = collectionQuerySchema.extend({
795
- artifactId: z.string().optional()
599
+ artifactId: z15.string().optional()
796
600
  });
797
- var stableInstanceInputSchema = z$1.object({
798
- stateId: z$1.string(),
799
- output: z$1.string(),
800
- path: z$1.string().optional()
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()
801
607
  });
802
- var instanceStateEventSchema = z$1.discriminatedUnion("type", [
803
- z$1.object({
804
- type: z$1.literal("updated"),
805
- state: z$1.custom()
608
+ var instanceStateEventSchema = z16.discriminatedUnion("type", [
609
+ z16.object({
610
+ type: z16.literal("updated"),
611
+ state: z16.custom()
806
612
  }),
807
- z$1.object({
808
- type: z$1.literal("patched"),
809
- stateId: z$1.string(),
810
- patch: z$1.custom()
613
+ z16.object({
614
+ type: z16.literal("patched"),
615
+ stateId: z16.string(),
616
+ patch: z16.custom()
811
617
  }),
812
- z$1.object({
813
- type: z$1.literal("patched-batch"),
814
- patches: z$1.array(
815
- z$1.object({
816
- stateId: z$1.string(),
817
- patch: z$1.custom()
818
- })
819
- )
618
+ z16.object({
619
+ type: z16.literal("patched-batch"),
620
+ patches: z16.array(z16.object({
621
+ stateId: z16.string(),
622
+ patch: z16.custom()
623
+ }))
820
624
  }),
821
- z$1.object({
822
- type: z$1.literal("deleted"),
823
- stateId: z$1.string()
625
+ z16.object({
626
+ type: z16.literal("deleted"),
627
+ stateId: z16.string()
824
628
  })
825
629
  ]);
826
630
  function isVirtualGhostInstance(state) {
827
- if (state.source !== "virtual") return false;
828
- if (state.status === "undeployed") return false;
631
+ if (state.source !== "virtual")
632
+ return false;
633
+ if (state.status === "undeployed")
634
+ return false;
829
635
  return !state.evaluationState;
830
636
  }
831
637
  function isInstanceDeployed(state) {
@@ -843,43 +649,51 @@ var finalInstanceOperationStatuses = [
843
649
  function isTransientInstanceOperationStatus(status) {
844
650
  return !!status && !finalInstanceOperationStatuses.includes(status);
845
651
  }
846
- var workerUnitRegistrationEventSchema = z$1.discriminatedUnion("type", [
847
- z$1.object({
848
- type: z$1.literal("registered"),
849
- instanceId: z$1.string(),
850
- params: z$1.record(z$1.string(), z$1.unknown())
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())
851
657
  }),
852
- z$1.object({
853
- type: z$1.literal("deregistered"),
854
- instanceId: z$1.string()
658
+ z16.object({
659
+ type: z16.literal("deregistered"),
660
+ instanceId: z16.string()
855
661
  })
856
662
  ]);
857
- var terminalStatusSchema = z$1.enum([
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([
858
672
  "active",
859
673
  "unavailable"
860
674
  ]);
861
- var terminalSessionOutputSchema = z$1.object({
862
- id: z$1.cuid2(),
863
- terminalId: z$1.cuid2(),
864
- meta: globalCommonObjectMetaSchema,
865
- startedAt: z$1.date(),
866
- finishedAt: z$1.date().nullable()
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()
867
681
  });
868
- var terminalOutputSchema = z$1.object({
869
- id: z$1.cuid2(),
870
- name: z$1.string().nullable(),
871
- meta: commonObjectMetaSchema,
682
+ var terminalOutputSchema = z17.object({
683
+ id: z17.cuid2(),
684
+ name: z17.string().nullable(),
685
+ meta: commonObjectMetaSchema8,
872
686
  status: terminalStatusSchema,
873
- stateId: z$1.string().nullable(),
874
- serviceAccountId: z$1.string().nullable(),
875
- serviceAccountMeta: serviceAccountMetaSchema.nullable(),
876
- createdAt: z$1.date(),
877
- updatedAt: z$1.date()
687
+ stateId: z17.string().nullable(),
688
+ serviceAccountId: z17.string().nullable(),
689
+ serviceAccountMeta: serviceAccountMetaSchema5.nullable(),
690
+ createdAt: z17.date(),
691
+ updatedAt: z17.date()
878
692
  });
879
693
  var terminalQuerySchema = collectionQuerySchema.extend({
880
- serviceAccountId: z$1.string().optional(),
881
- stateId: z$1.string().optional(),
882
- artifactId: z$1.string().optional()
694
+ serviceAccountId: z17.string().optional(),
695
+ stateId: z17.string().optional(),
696
+ artifactId: z17.string().optional()
883
697
  });
884
698
  function toTerminalOutput(terminal, serviceAccount) {
885
699
  return {
@@ -893,7 +707,7 @@ function toTerminalDetailsOutput(terminal, serviceAccount) {
893
707
  serviceAccountMeta: serviceAccount?.meta ?? null
894
708
  };
895
709
  }
896
- var terminalDetailsOutputSchema = z$1.object({
710
+ var terminalDetailsOutputSchema = z17.object({
897
711
  ...terminalOutputSchema.shape,
898
712
  spec: terminalSpecSchema
899
713
  });
@@ -906,36 +720,44 @@ function toTerminalSessionOutput(terminal, session) {
906
720
  finishedAt: session.finishedAt
907
721
  };
908
722
  }
909
- var triggerOutputSchema = z$1.object({
910
- id: z$1.cuid2(),
911
- meta: commonObjectMetaSchema,
912
- name: z$1.string(),
913
- stateId: z$1.cuid2(),
914
- createdAt: z$1.date(),
915
- updatedAt: z$1.date()
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()
916
733
  });
917
734
  var triggerQuerySchema = collectionQuerySchema.extend({
918
- stateId: z$1.string().optional()
735
+ stateId: z18.string().optional()
919
736
  });
920
- var unlockMethodType = z.enum(["password", "passkey"]);
921
- var unlockMethodMetaSchema = objectMetaSchema.pick({
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({
922
741
  title: true,
923
742
  description: true
924
743
  }).required({ title: true });
925
- var unlockMethodInputSchema = z.object({
744
+ var unlockMethodInputSchema = z19.object({
926
745
  meta: unlockMethodMetaSchema,
927
746
  type: unlockMethodType,
928
- encryptedIdentity: z.string(),
929
- recipient: z.string()
747
+ encryptedIdentity: z19.string(),
748
+ recipient: z19.string()
930
749
  });
931
- var unlockMethodOutputSchema = z.object({
932
- id: z.cuid2(),
750
+ var unlockMethodOutputSchema = z19.object({
751
+ id: z19.cuid2(),
933
752
  type: unlockMethodType,
934
753
  meta: unlockMethodMetaSchema,
935
- recipient: z.string(),
936
- createdAt: z.date(),
937
- updatedAt: z.date()
754
+ recipient: z19.string(),
755
+ createdAt: z19.date(),
756
+ updatedAt: z19.date()
938
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";
939
761
  var MAX_WORKER_START_ATTEMPTS = 3;
940
762
  var SHA256_PREFIX = "sha256:";
941
763
  var SHA256_REGEX = /^[a-f0-9]{64}$/;
@@ -964,7 +786,7 @@ function getWorkerIdentity(image) {
964
786
  }
965
787
  return withoutDigest;
966
788
  }
967
- var workerVersionStatusSchema = z$1.enum([
789
+ var workerVersionStatusSchema = z20.enum([
968
790
  "unknown",
969
791
  "starting",
970
792
  "running",
@@ -972,31 +794,31 @@ var workerVersionStatusSchema = z$1.enum([
972
794
  "stopped",
973
795
  "error"
974
796
  ]);
975
- var workerVersionStatusEventSchema = z$1.object({
976
- workerVersionId: z$1.cuid2(),
797
+ var workerVersionStatusEventSchema = z20.object({
798
+ workerVersionId: z20.cuid2(),
977
799
  status: workerVersionStatusSchema
978
800
  });
979
- var workerVersionOutputSchema = z$1.object({
980
- id: z$1.cuid2(),
981
- digest: z$1.string(),
982
- meta: commonObjectMetaSchema,
801
+ var workerVersionOutputSchema = z20.object({
802
+ id: z20.cuid2(),
803
+ digest: z20.string(),
804
+ meta: commonObjectMetaSchema10,
983
805
  status: workerVersionStatusSchema,
984
- enabled: z$1.boolean(),
985
- apiKeyId: z$1.string(),
806
+ enabled: z20.boolean(),
807
+ apiKeyId: z20.string(),
986
808
  apiKeyMeta: apiKeyMetaSchema,
987
- createdAt: z$1.date(),
988
- updatedAt: z$1.date()
809
+ createdAt: z20.date(),
810
+ updatedAt: z20.date()
989
811
  });
990
- var workerOutputSchema = z$1.object({
991
- id: z$1.cuid2(),
992
- identity: z$1.string(),
993
- meta: commonObjectMetaSchema,
994
- serviceAccountId: z$1.string(),
995
- serviceAccountMeta: serviceAccountMetaSchema,
996
- createdAt: z$1.date()
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()
997
819
  });
998
820
  var workerQuerySchema = collectionQuerySchema.extend({
999
- serviceAccountId: z$1.string().optional()
821
+ serviceAccountId: z20.string().optional()
1000
822
  });
1001
823
  function toWorkerOutput(worker, lastVersion, serviceAccount) {
1002
824
  return {
@@ -1011,16 +833,15 @@ function toWorkerVersionOutput(version, apiKey) {
1011
833
  apiKeyMeta: apiKey.meta
1012
834
  };
1013
835
  }
1014
-
1015
836
  // src/shared/resolvers/effective-output-type.ts
1016
837
  function resolveEffectiveOutputType(options) {
1017
- const visited = options.visited ?? /* @__PURE__ */ new Set();
838
+ const visited = options.visited ?? new Set;
1018
839
  const producer = options.getInstanceContext(options.input.instanceId);
1019
840
  if (!producer) {
1020
841
  return resolveTypeByPathOrFallbackInclusion({
1021
842
  rootType: options.fallbackType,
1022
843
  path: options.input.path,
1023
- entities: void 0,
844
+ entities: undefined,
1024
845
  fallbackType: options.fallbackType
1025
846
  });
1026
847
  }
@@ -1075,11 +896,11 @@ function resolveTypeByPathOrFallbackInclusion(options) {
1075
896
  let currentType = rootType;
1076
897
  const segments = path.split(".");
1077
898
  for (const segment of segments) {
1078
- const entity = entities[currentType];
1079
- if (!entity) {
899
+ const entity2 = entities[currentType];
900
+ if (!entity2) {
1080
901
  return rootType;
1081
902
  }
1082
- const inclusion = entity.inclusions?.find((inc) => inc.field === segment);
903
+ const inclusion = entity2.inclusions?.find((inc) => inc.field === segment);
1083
904
  if (!inclusion) {
1084
905
  return rootType;
1085
906
  }
@@ -1107,17 +928,24 @@ function resolveTypeByImplicitInclusion(rootType, fallbackType, entities) {
1107
928
  }
1108
929
  return rootType;
1109
930
  }
1110
- var GraphResolver = class {
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;
1111
943
  constructor(nodes, logger, outputHandler, dependentSetHandler) {
1112
944
  this.nodes = nodes;
1113
945
  this.logger = logger;
1114
946
  this.outputHandler = outputHandler;
1115
947
  this.dependentSetHandler = dependentSetHandler;
1116
948
  }
1117
- workset = /* @__PURE__ */ new Set();
1118
- dependencyMap = /* @__PURE__ */ new Map();
1119
- dependentMap = /* @__PURE__ */ new Map();
1120
- outputMap = /* @__PURE__ */ new Map();
1121
949
  addToWorkset(nodeId) {
1122
950
  this.workset.add(nodeId);
1123
951
  }
@@ -1126,17 +954,9 @@ var GraphResolver = class {
1126
954
  this.workset.add(nodeId);
1127
955
  }
1128
956
  }
1129
- /**
1130
- * The map of calculated outputs.
1131
- */
1132
957
  get outputs() {
1133
958
  return this.outputMap;
1134
959
  }
1135
- /**
1136
- * The map of dependencies for each node.
1137
- *
1138
- * The key is the node identifier, and the value is an array of identifiers of the nodes which depend on it.
1139
- */
1140
960
  get dependents() {
1141
961
  return this.dependentMap;
1142
962
  }
@@ -1147,11 +967,6 @@ var GraphResolver = class {
1147
967
  }
1148
968
  return output;
1149
969
  }
1150
- /**
1151
- * Gets the identifiers of the nodes that depend on the given node directly.
1152
- *
1153
- * Returns an empty array if there are no dependents.
1154
- */
1155
970
  getDependents(nodeId) {
1156
971
  const dependents = this.dependentMap.get(nodeId);
1157
972
  if (!dependents) {
@@ -1159,11 +974,6 @@ var GraphResolver = class {
1159
974
  }
1160
975
  return Array.from(dependents);
1161
976
  }
1162
- /**
1163
- * Invalidates the node and all nodes that depend on it.
1164
- *
1165
- * Also adds the node to the work set for processing.
1166
- */
1167
977
  invalidate(nodeId) {
1168
978
  const stack = [nodeId];
1169
979
  while (stack.length > 0) {
@@ -1184,13 +994,6 @@ var GraphResolver = class {
1184
994
  }
1185
995
  }
1186
996
  }
1187
- /**
1188
- * Invalidates a single node without invalidating its dependents.
1189
- *
1190
- * Also adds the node to the work set for processing.
1191
- *
1192
- * Should be used with caution, as it may lead to inconsistent state if the dependents are not re-processed separately.
1193
- */
1194
997
  invalidateSingle(nodeId) {
1195
998
  if (!this.nodes.has(nodeId)) {
1196
999
  return;
@@ -1198,11 +1001,6 @@ var GraphResolver = class {
1198
1001
  this.outputMap.delete(nodeId);
1199
1002
  this.workset.add(nodeId);
1200
1003
  }
1201
- /**
1202
- * Resolves all not-resolved or invalidated nodes in the graph.
1203
- *
1204
- * The abort signal of the previous operation must be called before calling this method again.
1205
- */
1206
1004
  async process(signal) {
1207
1005
  while (this.workset.size > 0) {
1208
1006
  const rootNodeId = this.workset.values().next().value;
@@ -1243,7 +1041,7 @@ var GraphResolver = class {
1243
1041
  this.logger.warn({ nodeId }, "processing aborted, skipping output");
1244
1042
  return;
1245
1043
  }
1246
- const changedDependentMaps = /* @__PURE__ */ new Set();
1044
+ const changedDependentMaps = new Set;
1247
1045
  const oldDependencies = this.dependencyMap.get(nodeId) ?? [];
1248
1046
  for (const depId of oldDependencies) {
1249
1047
  const dependantSet = this.dependentMap.get(depId);
@@ -1258,7 +1056,7 @@ var GraphResolver = class {
1258
1056
  for (const depId of stackItem.dependencies) {
1259
1057
  let dependantSet = this.dependentMap.get(depId);
1260
1058
  if (!dependantSet) {
1261
- dependantSet = /* @__PURE__ */ new Set();
1059
+ dependantSet = new Set;
1262
1060
  this.dependentMap.set(depId, dependantSet);
1263
1061
  }
1264
1062
  dependantSet.add(nodeId);
@@ -1278,9 +1076,9 @@ var GraphResolver = class {
1278
1076
  this.workset.delete(rootNodeId);
1279
1077
  }
1280
1078
  }
1281
- };
1079
+ }
1282
1080
  function getAllDependents(dependentMap, nodeId) {
1283
- const result = /* @__PURE__ */ new Set();
1081
+ const result = new Set;
1284
1082
  const stack = [nodeId];
1285
1083
  while (stack.length > 0) {
1286
1084
  const dependents = dependentMap.get(stack.pop());
@@ -1296,7 +1094,13 @@ function getAllDependents(dependentMap, nodeId) {
1296
1094
  }
1297
1095
  return Array.from(result);
1298
1096
  }
1299
- var InputResolver = class extends GraphResolver {
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 {
1300
1104
  getNodeDependencies(node) {
1301
1105
  const dependencies = [];
1302
1106
  if (node.kind === "hub") {
@@ -1330,7 +1134,7 @@ var InputResolver = class extends GraphResolver {
1330
1134
  getInstanceContext: (instanceId) => {
1331
1135
  const output = this.outputs.get(`instance:${instanceId}`);
1332
1136
  if (!output || output.kind !== "instance") {
1333
- return void 0;
1137
+ return;
1334
1138
  }
1335
1139
  return {
1336
1140
  instance: output.instance,
@@ -1370,7 +1174,7 @@ var InputResolver = class extends GraphResolver {
1370
1174
  };
1371
1175
  };
1372
1176
  if (node.kind === "hub") {
1373
- const hubResult = /* @__PURE__ */ new Map();
1177
+ const hubResult = new Map;
1374
1178
  const addHubResult = (input) => {
1375
1179
  hubResult.set(inputKey(input.input), input);
1376
1180
  };
@@ -1404,7 +1208,7 @@ var InputResolver = class extends GraphResolver {
1404
1208
  instance: node.instance,
1405
1209
  component: node.component,
1406
1210
  entities: node.entities,
1407
- resolvedInputs: mapValues(node.instance.resolvedInputs, (inputs, inputName) => {
1211
+ resolvedInputs: mapValues2(node.instance.resolvedInputs, (inputs, inputName) => {
1408
1212
  const componentInput = node.component.inputs[inputName];
1409
1213
  if (!componentInput) {
1410
1214
  this.logger.warn({
@@ -1421,11 +1225,11 @@ var InputResolver = class extends GraphResolver {
1421
1225
  matchedInjectionInputs: []
1422
1226
  };
1423
1227
  }
1424
- const resolvedInputsMap = /* @__PURE__ */ new Map();
1228
+ const resolvedInputsMap = new Map;
1425
1229
  const addInstanceResult = (inputName, input) => {
1426
1230
  let inputs = resolvedInputsMap.get(inputName);
1427
1231
  if (!inputs) {
1428
- inputs = /* @__PURE__ */ new Map();
1232
+ inputs = new Map;
1429
1233
  resolvedInputsMap.set(inputName, inputs);
1430
1234
  }
1431
1235
  inputs.set(inputKey(input.input), input);
@@ -1457,17 +1261,13 @@ var InputResolver = class extends GraphResolver {
1457
1261
  addInstanceResult(inputName, {
1458
1262
  input: {
1459
1263
  ...output,
1460
- // keep explicit path from the edge while preserving already-resolved output path
1461
1264
  path: input.path ?? output.path
1462
1265
  },
1463
- type: this.resolveOutputTypeForInput(
1464
- {
1465
- instanceId: input.instanceId,
1466
- output: input.output,
1467
- path: input.path ?? output.path
1468
- },
1469
- componentInput.type
1470
- )
1266
+ type: this.resolveOutputTypeForInput({
1267
+ instanceId: input.instanceId,
1268
+ output: input.output,
1269
+ path: input.path ?? output.path
1270
+ }, componentInput.type)
1471
1271
  });
1472
1272
  }
1473
1273
  } else {
@@ -1482,8 +1282,8 @@ var InputResolver = class extends GraphResolver {
1482
1282
  addInstanceInput(inputName, input);
1483
1283
  }
1484
1284
  }
1485
- const injectionInputs = /* @__PURE__ */ new Map();
1486
- const matchedInjectionInputs = /* @__PURE__ */ new Map();
1285
+ const injectionInputs = new Map;
1286
+ const matchedInjectionInputs = new Map;
1487
1287
  for (const injectionInput of node.instance.injectionInputs ?? []) {
1488
1288
  const { resolvedInputs: resolvedInputs2 } = getHubOutput(injectionInput);
1489
1289
  for (const input of resolvedInputs2) {
@@ -1509,12 +1309,10 @@ var InputResolver = class extends GraphResolver {
1509
1309
  }
1510
1310
  }
1511
1311
  }
1512
- const resolvedInputs = fromEntries(
1513
- Array.from(resolvedInputsMap.entries()).map(([inputName, inputs]) => [
1514
- inputName,
1515
- Array.from(inputs.values())
1516
- ])
1517
- );
1312
+ const resolvedInputs = fromEntries(Array.from(resolvedInputsMap.entries()).map(([inputName, inputs]) => [
1313
+ inputName,
1314
+ Array.from(inputs.values())
1315
+ ]));
1518
1316
  return {
1519
1317
  kind: "instance",
1520
1318
  instance: node.instance,
@@ -1526,7 +1324,7 @@ var InputResolver = class extends GraphResolver {
1526
1324
  matchedInjectionInputs: Array.from(matchedInjectionInputs.values())
1527
1325
  };
1528
1326
  }
1529
- };
1327
+ }
1530
1328
  function getResolvedHubInputs(outputMap, hubId) {
1531
1329
  const output = outputMap.get(`hub:${hubId}`);
1532
1330
  if (!output) {
@@ -1570,22 +1368,28 @@ function getMatchedInjectionInstanceInputs(outputMap, instanceId) {
1570
1368
  function getResolvedInstanceOutputs(outputMap, instanceId) {
1571
1369
  const output = outputMap.get(`instance:${instanceId}`);
1572
1370
  if (!output) {
1573
- return void 0;
1371
+ return;
1574
1372
  }
1575
1373
  if (output.kind !== "instance") {
1576
1374
  throw new Error("Expected instance node");
1577
1375
  }
1578
1376
  return output.resolvedOutputs;
1579
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";
1580
1383
 
1581
1384
  // src/shared/utils/async-batcher.ts
1582
- function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs = 1e3 } = {}) {
1385
+ function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs = 1000 } = {}) {
1583
1386
  let batch = [];
1584
1387
  let activeTimeout = null;
1585
1388
  let maxWaitTimeout = null;
1586
1389
  let firstCallTimestamp = null;
1587
1390
  async function processBatch() {
1588
- if (batch.length === 0) return;
1391
+ if (batch.length === 0)
1392
+ return;
1589
1393
  const currentBatch = batch;
1590
1394
  batch = [];
1591
1395
  await fn(currentBatch);
@@ -1596,31 +1400,27 @@ function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs = 1e3 } = {}) {
1596
1400
  firstCallTimestamp = null;
1597
1401
  }
1598
1402
  function schedule() {
1599
- if (activeTimeout) clearTimeout(activeTimeout);
1403
+ if (activeTimeout)
1404
+ clearTimeout(activeTimeout);
1600
1405
  activeTimeout = setTimeout(() => {
1601
1406
  activeTimeout = null;
1602
- void processBatch();
1407
+ processBatch();
1603
1408
  }, waitMs);
1604
1409
  if (!firstCallTimestamp) {
1605
1410
  firstCallTimestamp = Date.now();
1606
1411
  maxWaitTimeout = setTimeout(() => {
1607
- if (activeTimeout) clearTimeout(activeTimeout);
1412
+ if (activeTimeout)
1413
+ clearTimeout(activeTimeout);
1608
1414
  activeTimeout = null;
1609
- void processBatch();
1415
+ processBatch();
1610
1416
  }, maxWaitTimeMs);
1611
1417
  }
1612
1418
  }
1613
1419
  return {
1614
- /**
1615
- * Add an item to the batch.
1616
- */
1617
1420
  call(item) {
1618
1421
  batch.push(item);
1619
1422
  schedule();
1620
1423
  },
1621
- /**
1622
- * Immediately flush the pending batch (if any).
1623
- */
1624
1424
  async flush() {
1625
1425
  if (activeTimeout) {
1626
1426
  clearTimeout(activeTimeout);
@@ -1634,7 +1434,6 @@ function createAsyncBatcher(fn, { waitMs = 100, maxWaitTimeMs = 1e3 } = {}) {
1634
1434
  }
1635
1435
  };
1636
1436
  }
1637
-
1638
1437
  // src/shared/utils/hash.ts
1639
1438
  function int32ToBytes(value) {
1640
1439
  const buffer = new ArrayBuffer(4);
@@ -1642,20 +1441,13 @@ function int32ToBytes(value) {
1642
1441
  view.setInt32(0, value, true);
1643
1442
  return new Uint8Array(buffer);
1644
1443
  }
1645
-
1646
1444
  // src/shared/utils/promise-tracker.ts
1647
- var PromiseTracker = class {
1648
- trackedPromises = /* @__PURE__ */ new Set();
1649
- /**
1650
- * Tracks a promise to ensure its rejection is handled inside the tracker's scope.
1651
- */
1445
+ class PromiseTracker {
1446
+ trackedPromises = new Set;
1652
1447
  track(promise) {
1653
1448
  const wrapped = promise.finally(() => this.trackedPromises.delete(promise));
1654
1449
  this.trackedPromises.add(wrapped);
1655
1450
  }
1656
- /**
1657
- * Waits for all tracked promises to resolve or reject.
1658
- */
1659
1451
  async waitForAll() {
1660
1452
  if (this.trackedPromises.size === 0) {
1661
1453
  return;
@@ -1664,19 +1456,15 @@ var PromiseTracker = class {
1664
1456
  this.trackedPromises.clear();
1665
1457
  await waitAll(toTrack);
1666
1458
  }
1667
- };
1459
+ }
1668
1460
  async function waitAll(promises) {
1669
1461
  const results = await Promise.allSettled(promises);
1670
1462
  const rejected = results.filter((p) => p.status === "rejected");
1671
1463
  if (!rejected.length) {
1672
1464
  return;
1673
1465
  }
1674
- throw new AggregateError(
1675
- rejected.map((p) => p.reason),
1676
- "Some promises were rejected"
1677
- );
1466
+ throw new AggregateError(rejected.map((p) => p.reason), "Some promises were rejected");
1678
1467
  }
1679
-
1680
1468
  // src/shared/utils/stable-json.ts
1681
1469
  function stableJsonStringify(value) {
1682
1470
  if (value === null) {
@@ -1702,7 +1490,7 @@ function stableJsonStringify(value) {
1702
1490
  const parts = [];
1703
1491
  for (const key of keys) {
1704
1492
  const item = record[key];
1705
- if (item === void 0) {
1493
+ if (item === undefined) {
1706
1494
  throw new Error("Snapshot content contains undefined");
1707
1495
  }
1708
1496
  parts.push(`${JSON.stringify(key)}:${stableJsonStringify(item)}`);
@@ -1713,9 +1501,8 @@ function stableJsonStringify(value) {
1713
1501
  throw new Error(`Snapshot content contains non-JSON value of type "${typeof value}"`);
1714
1502
  }
1715
1503
  }
1716
-
1717
1504
  // src/shared/resolvers/input-hash.ts
1718
- var InputHashResolver = class extends GraphResolver {
1505
+ class InputHashResolver extends GraphResolver {
1719
1506
  getNodeDependencies({ resolvedInputs }) {
1720
1507
  const dependencies = [];
1721
1508
  for (const inputs of Object.values(resolvedInputs ?? {})) {
@@ -1730,28 +1517,25 @@ var InputHashResolver = class extends GraphResolver {
1730
1517
  component,
1731
1518
  resolvedInputs,
1732
1519
  sourceHash,
1733
- state
1520
+ state: state2
1734
1521
  }) {
1735
1522
  const selfHashSink = [];
1736
1523
  selfHashSink.push(Buffer.from(instance.id));
1737
1524
  selfHashSink.push(int32ToBytes(component.definitionHash));
1738
- if (state?.inputHashNonce) {
1739
- selfHashSink.push(int32ToBytes(state.inputHashNonce));
1525
+ if (state2?.inputHashNonce) {
1526
+ selfHashSink.push(int32ToBytes(state2.inputHashNonce));
1740
1527
  }
1741
1528
  if (instance.args) {
1742
1529
  selfHashSink.push(encode(instance.args));
1743
1530
  }
1744
1531
  if (sourceHash) {
1745
1532
  selfHashSink.push(int32ToBytes(sourceHash));
1746
- } else if (isUnitModel(component)) {
1747
- this.logger.warn(
1748
- { instanceId: instance.id },
1749
- "missing source hash for unit model, this may lead to incorrect input hash"
1750
- );
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");
1751
1535
  }
1752
1536
  const inputHashSink = [...selfHashSink];
1753
1537
  const sortedInputs = Object.entries(resolvedInputs).sort(([a], [b]) => a.localeCompare(b));
1754
- const dependencyInstanceIds = /* @__PURE__ */ new Set();
1538
+ const dependencyInstanceIds = new Set;
1755
1539
  for (const [inputKey2, inputs] of sortedInputs) {
1756
1540
  if (Object.keys(inputs).length === 0) {
1757
1541
  continue;
@@ -1761,10 +1545,7 @@ var InputHashResolver = class extends GraphResolver {
1761
1545
  for (const instanceId of instanceIds) {
1762
1546
  const dependency = this.outputs.get(instanceId);
1763
1547
  if (!dependency) {
1764
- this.logger.warn(
1765
- { instanceId, dependentInstanceId: instance.id },
1766
- "missing dependency when calculating input hash, this may lead to incorrect input hash"
1767
- );
1548
+ this.logger.warn({ instanceId, dependentInstanceId: instance.id }, "missing dependency when calculating input hash, this may lead to incorrect input hash");
1768
1549
  continue;
1769
1550
  }
1770
1551
  inputHashSink.push(int32ToBytes(dependency.inputHash));
@@ -1777,10 +1558,7 @@ var InputHashResolver = class extends GraphResolver {
1777
1558
  for (const dependencyInstanceId of sortedDependencyInstanceIds) {
1778
1559
  const dependency = this.outputs.get(dependencyInstanceId);
1779
1560
  if (!dependency) {
1780
- this.logger.warn(
1781
- { instanceId: dependencyInstanceId, dependentInstanceId: instance.id },
1782
- "missing dependency when calculating dependency output hash, this may lead to incorrect input hash"
1783
- );
1561
+ this.logger.warn({ instanceId: dependencyInstanceId, dependentInstanceId: instance.id }, "missing dependency when calculating dependency output hash, this may lead to incorrect input hash");
1784
1562
  continue;
1785
1563
  }
1786
1564
  dependencyOutputHashSink.push(int32ToBytes(dependency.outputHash));
@@ -1789,11 +1567,18 @@ var InputHashResolver = class extends GraphResolver {
1789
1567
  selfHash: crc32(Buffer.concat(selfHashSink)),
1790
1568
  inputHash: crc32(Buffer.concat(inputHashSink)),
1791
1569
  dependencyOutputHash: crc32(Buffer.concat(dependencyOutputHashSink)),
1792
- outputHash: state?.outputHash ?? 0
1570
+ outputHash: state2?.outputHash ?? 0
1793
1571
  };
1794
1572
  }
1795
- };
1796
- var ValidationResolver = class extends GraphResolver {
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 {
1797
1582
  getNodeDependencies({ resolvedInputs }) {
1798
1583
  const dependencies = [];
1799
1584
  for (const inputs of Object.values(resolvedInputs)) {
@@ -1803,38 +1588,29 @@ var ValidationResolver = class extends GraphResolver {
1803
1588
  }
1804
1589
  return dependencies;
1805
1590
  }
1806
- processNode({ instance, component, state, resolvedInputs }) {
1591
+ processNode({ instance, component, state: state2, resolvedInputs }) {
1807
1592
  const ajv = new Ajv({ strict: false });
1808
1593
  this.logger.debug({ instanceId: instance.id }, "validating instance");
1809
1594
  const validationErrors = [];
1810
1595
  for (const [name, argument] of Object.entries(component.args)) {
1811
1596
  try {
1812
1597
  const value = parseArgumentValue(instance.args?.[name]);
1813
- if (!argument.required && value === void 0) {
1598
+ if (!argument.required && value === undefined) {
1814
1599
  continue;
1815
1600
  }
1816
1601
  if (!ajv.validate(argument.schema, value)) {
1817
1602
  this.logger.debug({ instanceId: instance.id, argumentName: name }, "invalid argument");
1818
- validationErrors.push(
1819
- `Invalid argument "${styles.blueBright.open}${name}${styles.reset.close}": ` + ajv.errorsText()
1820
- );
1603
+ validationErrors.push(`Invalid argument ` + `"${styles.blueBright.open}${name}${styles.reset.close}": ` + ajv.errorsText());
1821
1604
  }
1822
1605
  } catch (error) {
1823
- this.logger.debug(
1824
- { instanceId: instance.id, argumentName: name, error },
1825
- "failed to validate argument"
1826
- );
1827
- validationErrors.push(
1828
- `Failed to validate argument "${styles.blueBright.open}${name}${styles.reset.close}": ` + (error instanceof Error ? error.message : String(error))
1829
- );
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)));
1830
1608
  }
1831
1609
  }
1832
- if (isUnitModel(component)) {
1833
- for (const [secret, secretSchema] of Object.entries(component.secrets)) {
1834
- if (secretSchema.required && !state?.secretNames?.includes(secret)) {
1835
- validationErrors.push(
1836
- `Missing required secret "${styles.blueBright.open}${secret}${styles.reset.close}"`
1837
- );
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}"`);
1838
1614
  }
1839
1615
  }
1840
1616
  }
@@ -1842,10 +1618,8 @@ var ValidationResolver = class extends GraphResolver {
1842
1618
  for (const input of inputs) {
1843
1619
  const inputInstance = this.outputs.get(input.input.instanceId);
1844
1620
  if (inputInstance?.status !== "ok") {
1845
- validationErrors.push(
1846
- `Invalid input "${styles.blueBright.open}${key}${styles.reset.close}":
1847
- "${styles.blueBright.open}${input.input.instanceId}${styles.reset.close}" has validation errors`
1848
- );
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`);
1849
1623
  }
1850
1624
  }
1851
1625
  }
@@ -1854,9 +1628,7 @@ var ValidationResolver = class extends GraphResolver {
1854
1628
  continue;
1855
1629
  }
1856
1630
  if (!resolvedInputs[name] || !resolvedInputs[name].length) {
1857
- validationErrors.push(
1858
- `Missing required input "${styles.blueBright.open}${name}${styles.reset.close}" of type "${styles.greenBright.open}${input.type}${styles.reset.close}"`
1859
- );
1631
+ validationErrors.push(`Missing required input ` + `"${styles.blueBright.open}${name}${styles.reset.close}" ` + `of type ` + `"${styles.greenBright.open}${input.type}${styles.reset.close}"`);
1860
1632
  }
1861
1633
  }
1862
1634
  if (validationErrors.length === 0) {
@@ -1864,19 +1636,22 @@ var ValidationResolver = class extends GraphResolver {
1864
1636
  }
1865
1637
  const numberPrefixLength = (validationErrors.length + 1).toString().length + 2;
1866
1638
  const formattedError = validationErrors.map((error, index) => {
1867
- const lines = error.split("\n");
1639
+ const lines = error.split(`
1640
+ `);
1868
1641
  const prefix = `${index + 1}. `;
1869
1642
  return lines.map((line, lineIndex) => {
1870
1643
  const linePrefix = lineIndex === 0 ? prefix : " ".repeat(numberPrefixLength);
1871
1644
  return `${linePrefix}${line}`;
1872
- }).join("\r\n");
1873
- }).join("\r\n");
1645
+ }).join(`\r
1646
+ `);
1647
+ }).join(`\r
1648
+ `);
1874
1649
  return {
1875
1650
  status: "error",
1876
1651
  errorText: formattedError
1877
1652
  };
1878
1653
  }
1879
- };
1654
+ }
1880
1655
 
1881
1656
  // src/shared/resolvers/registry.ts
1882
1657
  var resolverFactories = {
@@ -1884,7 +1659,4 @@ var resolverFactories = {
1884
1659
  InputHashResolver,
1885
1660
  ValidationResolver
1886
1661
  };
1887
-
1888
- 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, entityDetailsOutputSchema, entityOutputSchema, entityQuerySchema, entityReferenceOutputSchema, entitySnapshotDetailsOutputSchema, entitySnapshotListItemOutputSchema, entitySnapshotOutputSchema, 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, resolveEffectiveOutputType, resolverFactories, secretOutputSchema, secretQuerySchema, serviceAccountOutputSchema, serviceAccountQuerySchema, stableInstanceInputSchema, stableJsonStringify, terminalDetailsOutputSchema, terminalOutputSchema, terminalQuerySchema, terminalSessionOutputSchema, terminalStatusSchema, toApiKeyOutput, toCommonEntityMeta, toPageOutput, toSecretOutput, toTerminalDetailsOutput, toTerminalOutput, toTerminalSessionOutput, toWorkerOutput, toWorkerVersionOutput, triggerOutputSchema, triggerQuerySchema, unlockMethodInputSchema, unlockMethodMetaSchema, unlockMethodOutputSchema, unlockMethodType, waitAll, workerOutputSchema, workerQuerySchema, workerUnitRegistrationEventSchema, workerVersionOutputSchema, workerVersionStatusEventSchema, workerVersionStatusSchema };
1889
- //# sourceMappingURL=chunk-52MY2TCE.js.map
1890
- //# sourceMappingURL=chunk-52MY2TCE.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 };