@highstate/backend 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-JT4KWE3B.js → chunk-52MY2TCE.js} +348 -19
- package/dist/chunk-52MY2TCE.js.map +1 -0
- package/dist/{chunk-I7BWSAN6.js → chunk-UAWBPTDW.js} +3 -3
- package/dist/{chunk-I7BWSAN6.js.map → chunk-UAWBPTDW.js.map} +1 -1
- package/dist/highstate.manifest.json +4 -4
- package/dist/index.js +4159 -785
- package/dist/index.js.map +1 -1
- package/dist/library/worker/main.js +5 -2
- package/dist/library/worker/main.js.map +1 -1
- package/dist/shared/index.js +2 -2
- package/package.json +7 -7
- 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/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/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 +228 -68
- package/src/orchestrator/operation.update.failure.test.ts +4 -0
- package/src/orchestrator/operation.update.skip.test.ts +110 -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/local.ts +109 -85
- package/src/services.ts +52 -1
- 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 +61 -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/worker/manager.ts +97 -1
- package/dist/chunk-JT4KWE3B.js.map +0 -1
|
@@ -18,6 +18,8 @@ describe("Operation - Refresh", () => {
|
|
|
18
18
|
instanceStateService,
|
|
19
19
|
projectModelService,
|
|
20
20
|
unitExtraService,
|
|
21
|
+
entitySnapshotService,
|
|
22
|
+
unitOutputService,
|
|
21
23
|
createUnit,
|
|
22
24
|
createDeployedUnitState,
|
|
23
25
|
createOperation,
|
|
@@ -59,6 +61,8 @@ describe("Operation - Refresh", () => {
|
|
|
59
61
|
instanceStateService,
|
|
60
62
|
projectModelService,
|
|
61
63
|
unitExtraService,
|
|
64
|
+
entitySnapshotService,
|
|
65
|
+
unitOutputService,
|
|
62
66
|
logger,
|
|
63
67
|
)
|
|
64
68
|
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { InstanceId, InstanceModel, VersionedName } from "@highstate/contract"
|
|
2
2
|
import type { ArtifactService } from "../artifact"
|
|
3
3
|
import type {
|
|
4
|
+
EntitySnapshotService,
|
|
4
5
|
InstanceLockService,
|
|
5
6
|
InstanceStateService,
|
|
6
7
|
OperationService,
|
|
7
8
|
ProjectModelService,
|
|
8
9
|
SecretService,
|
|
9
10
|
UnitExtraService,
|
|
11
|
+
UnitOutputService,
|
|
10
12
|
} from "../business"
|
|
11
13
|
import type { Operation } from "../database"
|
|
12
14
|
import type { LibraryBackend } from "../library"
|
|
13
15
|
import type {
|
|
14
16
|
OperationType,
|
|
17
|
+
RawPulumiOutputs,
|
|
15
18
|
RunnerBackend,
|
|
16
19
|
UnitDestroyOptions,
|
|
17
20
|
UnitOptions,
|
|
@@ -95,11 +98,9 @@ export type RunnerTestController = {
|
|
|
95
98
|
emitError: (stateId: string, message: string) => void
|
|
96
99
|
emitCompletion: (
|
|
97
100
|
stateId: string,
|
|
98
|
-
update?:
|
|
99
|
-
Extract<UnitStateUpdate, { type: "completion" }>,
|
|
100
|
-
"type" | "unitId" | "operationType"
|
|
101
|
-
> & {
|
|
101
|
+
update?: {
|
|
102
102
|
operationType?: OperationType
|
|
103
|
+
rawOutputs?: RawPulumiOutputs | null
|
|
103
104
|
},
|
|
104
105
|
) => void
|
|
105
106
|
}
|
|
@@ -115,6 +116,8 @@ export const operationTest = test.extend<{
|
|
|
115
116
|
instanceStateService: MockedObject<InstanceStateService>
|
|
116
117
|
projectModelService: MockedObject<ProjectModelService>
|
|
117
118
|
unitExtraService: MockedObject<UnitExtraService>
|
|
119
|
+
entitySnapshotService: MockedObject<EntitySnapshotService>
|
|
120
|
+
unitOutputService: MockedObject<UnitOutputService>
|
|
118
121
|
|
|
119
122
|
createMockLibrary: () => LibraryModel
|
|
120
123
|
createUnit: (name: string, type?: VersionedName) => InstanceModel
|
|
@@ -198,18 +201,17 @@ export const operationTest = test.extend<{
|
|
|
198
201
|
const operationType =
|
|
199
202
|
update.operationType ?? lastOperationTypeByStateId.get(stateId) ?? "update"
|
|
200
203
|
|
|
204
|
+
const rawOutputs = update.rawOutputs ?? {
|
|
205
|
+
// Note: tests generally don't care about actual Pulumi outputs.
|
|
206
|
+
// Provide a non-empty object so business parsing can run if needed.
|
|
207
|
+
$test: { value: true },
|
|
208
|
+
}
|
|
209
|
+
|
|
201
210
|
getQueue(stateId).push({
|
|
202
211
|
type: "completion",
|
|
203
212
|
unitId: stateId as unknown as InstanceId,
|
|
204
213
|
operationType,
|
|
205
|
-
|
|
206
|
-
statusFields: update.statusFields ?? null,
|
|
207
|
-
terminals: update.terminals ?? null,
|
|
208
|
-
pages: update.pages ?? null,
|
|
209
|
-
triggers: update.triggers ?? null,
|
|
210
|
-
secrets: update.secrets ?? null,
|
|
211
|
-
workers: update.workers ?? null,
|
|
212
|
-
exportedArtifactIds: update.exportedArtifactIds ?? null,
|
|
214
|
+
rawOutputs,
|
|
213
215
|
})
|
|
214
216
|
},
|
|
215
217
|
}
|
|
@@ -360,6 +362,35 @@ export const operationTest = test.extend<{
|
|
|
360
362
|
await use(unitExtraService)
|
|
361
363
|
},
|
|
362
364
|
|
|
365
|
+
unitOutputService: async ({}, use) => {
|
|
366
|
+
const unitOutputService = vi.mockObject({
|
|
367
|
+
parseUnitOutputs: vi.fn().mockResolvedValue({
|
|
368
|
+
outputHash: null,
|
|
369
|
+
statusFields: null,
|
|
370
|
+
terminals: null,
|
|
371
|
+
pages: null,
|
|
372
|
+
triggers: null,
|
|
373
|
+
secrets: null,
|
|
374
|
+
workers: null,
|
|
375
|
+
exportedArtifactIds: null,
|
|
376
|
+
hasResourceHooks: false,
|
|
377
|
+
entitySnapshotError: null,
|
|
378
|
+
entitySnapshotPayload: null,
|
|
379
|
+
}),
|
|
380
|
+
} as unknown as UnitOutputService)
|
|
381
|
+
|
|
382
|
+
await use(unitOutputService)
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
entitySnapshotService: async ({}, use) => {
|
|
386
|
+
const entitySnapshotService = vi.mockObject({
|
|
387
|
+
reconstructLatestExportedOutputValues: vi.fn().mockResolvedValue(new Map()),
|
|
388
|
+
persistUnitEntitySnapshots: vi.fn().mockResolvedValue(undefined),
|
|
389
|
+
} as unknown as EntitySnapshotService)
|
|
390
|
+
|
|
391
|
+
await use(entitySnapshotService)
|
|
392
|
+
},
|
|
393
|
+
|
|
363
394
|
createMockLibrary: async ({}, use) => {
|
|
364
395
|
const createMockLibrary = (): LibraryModel => {
|
|
365
396
|
const testEntity = defineEntity({
|
|
@@ -444,6 +475,7 @@ export const operationTest = test.extend<{
|
|
|
444
475
|
status: "deployed",
|
|
445
476
|
source: "resident",
|
|
446
477
|
kind: instance.kind,
|
|
478
|
+
hasResourceHooks: false,
|
|
447
479
|
parentId: null,
|
|
448
480
|
parentInstanceId: instance.parentId ?? null,
|
|
449
481
|
selfHash: null,
|
|
@@ -492,6 +524,7 @@ export const operationTest = test.extend<{
|
|
|
492
524
|
options: {
|
|
493
525
|
forceUpdateDependencies: false,
|
|
494
526
|
ignoreDependencies: false,
|
|
527
|
+
ignoreChangedDependencies: false,
|
|
495
528
|
forceUpdateChildren: false,
|
|
496
529
|
destroyDependentInstances: true,
|
|
497
530
|
invokeDestroyTriggers: true,
|
|
@@ -564,6 +597,7 @@ export const operationTest = test.extend<{
|
|
|
564
597
|
libraryBackend,
|
|
565
598
|
instanceStateService,
|
|
566
599
|
projectModelService,
|
|
600
|
+
undefined,
|
|
567
601
|
logger,
|
|
568
602
|
)
|
|
569
603
|
}
|
|
@@ -576,9 +610,12 @@ export const operationTest = test.extend<{
|
|
|
576
610
|
const instanceByStateId = new Map<string, InstanceModel>(
|
|
577
611
|
input.instances.map(instance => [instance.id, instance]),
|
|
578
612
|
)
|
|
613
|
+
const lastStatusByStateId = new Map<string, InstanceOperationStatus>()
|
|
579
614
|
|
|
580
615
|
instanceStateService.createOperationStates.mockImplementation(async (_projectId, tuples) => {
|
|
581
616
|
return tuples.map(([opState, instancePatch]) => {
|
|
617
|
+
lastStatusByStateId.set(opState.stateId, opState.status)
|
|
618
|
+
|
|
582
619
|
return {
|
|
583
620
|
instanceId: opState.model.id,
|
|
584
621
|
...instancePatch,
|
|
@@ -602,7 +639,9 @@ export const operationTest = test.extend<{
|
|
|
602
639
|
const status =
|
|
603
640
|
typeof options.operationState?.status === "string"
|
|
604
641
|
? options.operationState.status
|
|
605
|
-
: "pending"
|
|
642
|
+
: (lastStatusByStateId.get(stateId) ?? "pending")
|
|
643
|
+
|
|
644
|
+
lastStatusByStateId.set(stateId, status)
|
|
606
645
|
|
|
607
646
|
const instance = instanceByStateId.get(stateId) ?? input.instances[0]
|
|
608
647
|
if (!instance) {
|