@supacloud/compiler 0.52.2 → 0.53.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/cli.js CHANGED
@@ -17126,11 +17126,6 @@ ${source.text}`;
17126
17126
  }
17127
17127
  var init_fixes = () => {};
17128
17128
 
17129
- // src/delivery-files.ts
17130
- var init_delivery_files2 = __esm(() => {
17131
- init_delivery_files();
17132
- });
17133
-
17134
17129
  // node_modules/@supacloud/delivery/src/application-release.ts
17135
17130
  var ApplicationIdSchema, ApplicationReleaseIdSchema, ApplicationReleaseRecordSchema;
17136
17131
  var init_application_release = __esm(() => {
@@ -17314,20 +17309,20 @@ var init_application_deploy_plan = __esm(() => {
17314
17309
  });
17315
17310
 
17316
17311
  // node_modules/@supacloud/delivery/src/application-deploy-operation.ts
17317
- var closed6, sha256, nullableActivation, ApplicationDeployWebReleaseSchema, ApplicationDeployRequestSchema, ApplicationBackendReceiptSchema, ApplicationDeployResultSchema;
17312
+ var closed5, sha256, nullableActivation, ApplicationDeployWebReleaseSchema, ApplicationDeployRequestSchema, ApplicationBackendReceiptSchema, ApplicationDeployResultSchema;
17318
17313
  var init_application_deploy_operation = __esm(() => {
17319
17314
  init_build();
17320
17315
  init_value2();
17321
17316
  init_application_activation();
17322
17317
  init_application_configuration();
17323
17318
  init_application_release();
17324
- closed6 = { additionalProperties: false };
17319
+ closed5 = { additionalProperties: false };
17325
17320
  sha256 = ApplicationReleaseIdSchema;
17326
17321
  nullableActivation = Union([ApplicationActivationIdSchema, Null()]);
17327
17322
  ApplicationDeployWebReleaseSchema = _Object_({
17328
17323
  deployment_id: String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }),
17329
17324
  release_id: sha256
17330
- }, closed6);
17325
+ }, closed5);
17331
17326
  ApplicationDeployRequestSchema = _Object_({
17332
17327
  mutation_id: ApplicationActivationIdSchema,
17333
17328
  release_id: sha256,
@@ -17336,7 +17331,7 @@ var init_application_deploy_operation = __esm(() => {
17336
17331
  expected_plan_sha256: Optional(sha256),
17337
17332
  approved_migration_digest: Optional(sha256),
17338
17333
  web_release: Optional(ApplicationDeployWebReleaseSchema)
17339
- }, closed6);
17334
+ }, closed5);
17340
17335
  ApplicationBackendReceiptSchema = _Object_({
17341
17336
  schema: Literal("supacloud.application-backend-receipt.v1"),
17342
17337
  project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
@@ -17352,7 +17347,7 @@ var init_application_deploy_operation = __esm(() => {
17352
17347
  applied_versions: _Array_(String2({ pattern: "^\\d{1,20}$" }), { uniqueItems: true }),
17353
17348
  schema_reloaded: Boolean2(),
17354
17349
  postgrest_healthy: Boolean2()
17355
- }, closed6);
17350
+ }, closed5);
17356
17351
  ApplicationDeployResultSchema = _Object_({
17357
17352
  schema: Literal("supacloud.application-deploy.v1"),
17358
17353
  project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
@@ -17373,8 +17368,8 @@ var init_application_deploy_operation = __esm(() => {
17373
17368
  release_id: sha256,
17374
17369
  activation_id: ApplicationActivationIdSchema,
17375
17370
  replayed: Boolean2()
17376
- }, closed6))
17377
- }, closed6);
17371
+ }, closed5))
17372
+ }, closed5);
17378
17373
  });
17379
17374
 
17380
17375
  // node_modules/@supacloud/delivery/src/application-history.ts
@@ -17421,7 +17416,12 @@ var init_application_history = __esm(() => {
17421
17416
  });
17422
17417
 
17423
17418
  // node_modules/@supacloud/delivery/src/application-preview.ts
17424
- var phaseStatus, closed7, ApplicationPreviewReceiptSchema;
17419
+ function applicationPreviewBranchRef(previewId) {
17420
+ if (!/^[a-f0-9-]{8,64}$/.test(previewId))
17421
+ throw new Error("Invalid preview ID");
17422
+ return `pv${previewId.replace(/-/g, "").slice(0, 18)}`;
17423
+ }
17424
+ var phaseStatus, closed6, ApplicationPreviewReceiptSchema;
17425
17425
  var init_application_preview = __esm(() => {
17426
17426
  init_build();
17427
17427
  init_value2();
@@ -17434,7 +17434,7 @@ var init_application_preview = __esm(() => {
17434
17434
  Literal("failed"),
17435
17435
  Literal("cleaned")
17436
17436
  ]);
17437
- closed7 = { additionalProperties: false };
17437
+ closed6 = { additionalProperties: false };
17438
17438
  ApplicationPreviewReceiptSchema = _Object_({
17439
17439
  schema: Literal("supacloud.application-preview.v1"),
17440
17440
  preview_id: String2({ pattern: "^[a-f0-9-]{8,64}$" }),
@@ -17454,46 +17454,50 @@ var init_application_preview = __esm(() => {
17454
17454
  Literal("cleaned")
17455
17455
  ]),
17456
17456
  resources: _Object_({
17457
- build_artifact: _Object_({ status: phaseStatus, release_id: ApplicationReleaseIdSchema }, closed7),
17457
+ build_artifact: _Object_({ status: phaseStatus, release_id: ApplicationReleaseIdSchema }, closed6),
17458
17458
  database_branch: _Object_({
17459
17459
  status: phaseStatus,
17460
17460
  branch_ref: String2({ pattern: "^[A-Za-z0-9_-]{1,20}$" }),
17461
17461
  data_mode: Union([Literal("schema_only"), Literal("full_clone")])
17462
- }, closed7),
17462
+ }, closed6),
17463
17463
  queue_namespace: _Object_({
17464
17464
  status: phaseStatus,
17465
17465
  namespace: String2({ minLength: 1, maxLength: 128 })
17466
- }, closed7),
17466
+ }, closed6),
17467
17467
  storage_namespace: _Object_({
17468
17468
  status: phaseStatus,
17469
17469
  namespace: String2({ minLength: 1, maxLength: 128 })
17470
- }, closed7),
17470
+ }, closed6),
17471
17471
  test_secret: _Object_({
17472
17472
  status: phaseStatus,
17473
17473
  name: String2({ minLength: 1, maxLength: 128 }),
17474
17474
  value_issued: Literal(false)
17475
- }, closed7),
17475
+ }, closed6),
17476
17476
  configuration_revision: _Object_({
17477
17477
  status: phaseStatus,
17478
17478
  configuration_id: Union([ApplicationConfigurationIdSchema, Null()])
17479
- }, closed7),
17479
+ }, closed6),
17480
17480
  application_activation: _Object_({
17481
17481
  status: phaseStatus,
17482
17482
  activation_id: Union([ApplicationActivationIdSchema, Null()])
17483
- }, closed7),
17483
+ }, closed6),
17484
+ functions: Optional(_Object_({
17485
+ status: phaseStatus,
17486
+ slugs: _Array_(String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }), { maxItems: 64 })
17487
+ }, closed6)),
17484
17488
  smoke_test: _Object_({
17485
17489
  status: phaseStatus,
17486
17490
  checks: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 32 }),
17487
17491
  passed: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 32 }),
17488
17492
  failed: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 32 })
17489
- }, closed7)
17490
- }, closed7),
17493
+ }, closed6)
17494
+ }, closed6),
17491
17495
  cleanup: _Object_({
17492
17496
  required: Boolean2(),
17493
17497
  completed: Boolean2(),
17494
17498
  error: Union([String2({ minLength: 1, maxLength: 128 }), Null()])
17495
- }, closed7)
17496
- }, closed7);
17499
+ }, closed6)
17500
+ }, closed6);
17497
17501
  });
17498
17502
 
17499
17503
  // node_modules/@supacloud/delivery/src/application-release-transfer.ts
@@ -17529,13 +17533,13 @@ var init_application_release_transfer = __esm(() => {
17529
17533
  });
17530
17534
 
17531
17535
  // node_modules/@supacloud/delivery/src/deployment-evidence.ts
17532
- var closed8, sha2562, isoDate, status, evidenceStatus, DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1", DatabaseProviderSchema, componentName, DeploymentComponentEvidenceSchema, DeploymentEvidenceSchema;
17536
+ var closed7, sha2562, isoDate, status, evidenceStatus, DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1", DatabaseProviderSchema, componentName, DeploymentComponentEvidenceSchema, DeploymentEvidenceSchema;
17533
17537
  var init_deployment_evidence = __esm(() => {
17534
17538
  init_build();
17535
17539
  init_value2();
17536
17540
  init_application_configuration();
17537
17541
  init_application_release();
17538
- closed8 = { additionalProperties: false };
17542
+ closed7 = { additionalProperties: false };
17539
17543
  sha2562 = String2({ pattern: "^[a-f0-9]{64}$" });
17540
17544
  isoDate = String2({ minLength: 20, maxLength: 40 });
17541
17545
  status = Union([
@@ -17561,19 +17565,19 @@ var init_deployment_evidence = __esm(() => {
17561
17565
  Literal("not-proven"),
17562
17566
  Literal("failed")
17563
17567
  ])
17564
- }, closed8),
17568
+ }, closed7),
17565
17569
  backup: _Object_({
17566
17570
  status,
17567
17571
  latest_success_at: Union([isoDate, Null()]),
17568
17572
  freshness_seconds: Union([Integer({ minimum: 0 }), Null()])
17569
- }, closed8),
17573
+ }, closed7),
17570
17574
  recovery: _Object_({
17571
17575
  status,
17572
17576
  drill_id: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
17573
17577
  rpo_seconds: Union([Integer({ minimum: 0 }), Null()]),
17574
17578
  rto_seconds: Union([Integer({ minimum: 0 }), Null()])
17575
- }, closed8)
17576
- }, closed8);
17579
+ }, closed7)
17580
+ }, closed7);
17577
17581
  componentName = Union([
17578
17582
  Literal("management-api"),
17579
17583
  Literal("web-console"),
@@ -17591,7 +17595,7 @@ var init_deployment_evidence = __esm(() => {
17591
17595
  status,
17592
17596
  health_check: Union([String2({ minLength: 1, maxLength: 256 }), Null()]),
17593
17597
  checked_at: Union([isoDate, Null()])
17594
- }, closed8);
17598
+ }, closed7);
17595
17599
  DeploymentEvidenceSchema = _Object_({
17596
17600
  schema: Literal(DEPLOYMENT_EVIDENCE_SCHEMA),
17597
17601
  status: evidenceStatus,
@@ -17600,33 +17604,33 @@ var init_deployment_evidence = __esm(() => {
17600
17604
  project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
17601
17605
  application_id: ApplicationIdSchema,
17602
17606
  environment_id: ApplicationIdSchema
17603
- }, closed8),
17607
+ }, closed7),
17604
17608
  source: _Object_({
17605
17609
  commit_sha: Union([String2({ pattern: "^[0-9a-f]{7,64}$" }), Null()]),
17606
17610
  manifest_sha256: sha2562,
17607
17611
  contract_schema: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
17608
17612
  environment_binding_version: Union([sha2562, Null()])
17609
- }, closed8),
17613
+ }, closed7),
17610
17614
  database: DatabaseProviderSchema,
17611
17615
  components: _Array_(DeploymentComponentEvidenceSchema, { minItems: 1, maxItems: 32 }),
17612
17616
  activation: _Object_({
17613
17617
  release_id: ApplicationReleaseIdSchema,
17614
17618
  configuration_id: ApplicationConfigurationIdSchema,
17615
17619
  activation_id: ApplicationConfigurationIdSchema
17616
- }, closed8),
17620
+ }, closed7),
17617
17621
  health: _Object_({
17618
17622
  status,
17619
17623
  checked_at: Union([isoDate, Null()]),
17620
17624
  authenticated_smoke: status
17621
- }, closed8),
17625
+ }, closed7),
17622
17626
  rollback: _Object_({
17623
17627
  release_id: Union([ApplicationReleaseIdSchema, Null()]),
17624
17628
  configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
17625
17629
  status: Union([Literal("ready"), Literal("not-ready"), Literal("unknown")]),
17626
17630
  result: Union([status, Null()])
17627
- }, closed8),
17631
+ }, closed7),
17628
17632
  notes: _Array_(String2({ minLength: 1, maxLength: 512 }), { maxItems: 32 })
17629
- }, closed8);
17633
+ }, closed7);
17630
17634
  });
17631
17635
 
17632
17636
  // node_modules/@supacloud/delivery/src/delivery-tuple.ts
@@ -17660,14 +17664,14 @@ var init_delivery_tuple = __esm(() => {
17660
17664
  });
17661
17665
 
17662
17666
  // node_modules/@supacloud/delivery/src/contract-matrix.ts
17663
- var closed9, sha2564, generation, versions, CONTRACT_MATRIX_SCHEMA = "supacloud.consumer-contract-matrix.v1", FA_CONTRACT_SCENARIOS, ConsumerContractMatrixSchema;
17667
+ var closed8, sha2564, generation, versions, CONTRACT_MATRIX_SCHEMA = "supacloud.consumer-contract-matrix.v1", FA_CONTRACT_SCENARIOS, ConsumerContractMatrixSchema;
17664
17668
  var init_contract_matrix = __esm(() => {
17665
17669
  init_build();
17666
17670
  init_value2();
17667
- closed9 = { additionalProperties: false };
17671
+ closed8 = { additionalProperties: false };
17668
17672
  sha2564 = String2({ pattern: "^[a-f0-9]{64}$" });
17669
17673
  generation = Union([Literal("old"), Literal("new")]);
17670
- versions = _Object_({ old: sha2564, new: sha2564 }, closed9);
17674
+ versions = _Object_({ old: sha2564, new: sha2564 }, closed8);
17671
17675
  FA_CONTRACT_SCENARIOS = [
17672
17676
  "missing-display-field",
17673
17677
  "missing-authority-field",
@@ -17681,7 +17685,7 @@ var init_contract_matrix = __esm(() => {
17681
17685
  customer: Literal("xigu-fa"),
17682
17686
  baseline_tuple_sha256: sha2564,
17683
17687
  candidate_tuple_sha256: sha2564,
17684
- artifacts: _Object_({ frontend: versions, functions: versions, database: versions }, closed9),
17688
+ artifacts: _Object_({ frontend: versions, functions: versions, database: versions }, closed8),
17685
17689
  cases: _Array_(_Object_({
17686
17690
  frontend: generation,
17687
17691
  functions: generation,
@@ -17689,20 +17693,20 @@ var init_contract_matrix = __esm(() => {
17689
17693
  scenarios: _Array_(_Object_({
17690
17694
  name: Enum(FA_CONTRACT_SCENARIOS),
17691
17695
  expected: Union([Literal("compatible"), Literal("blocked-safely")])
17692
- }, closed9), { minItems: FA_CONTRACT_SCENARIOS.length, maxItems: FA_CONTRACT_SCENARIOS.length })
17693
- }, closed9), { minItems: 8, maxItems: 8 })
17694
- }, closed9);
17696
+ }, closed8), { minItems: FA_CONTRACT_SCENARIOS.length, maxItems: FA_CONTRACT_SCENARIOS.length })
17697
+ }, closed8), { minItems: 8, maxItems: 8 })
17698
+ }, closed8);
17695
17699
  });
17696
17700
 
17697
17701
  // node_modules/@supacloud/delivery/src/fa-stability.ts
17698
- var closed10, hash3, label, timestamp2, count2, environment2, FA_REQUIRED_ACCEPTANCE, FA_BUSINESS_OPERATIONS, operation, proof, FaBusinessObservationSchema, FaServiceObjectivesSchema, FaStabilityEvidenceSchema;
17702
+ var closed9, hash3, label, timestamp2, count2, environment2, FA_REQUIRED_ACCEPTANCE, FA_BUSINESS_OPERATIONS, operation, proof, FaBusinessObservationSchema, FaServiceObjectivesSchema, FaStabilityEvidenceSchema;
17699
17703
  var init_fa_stability = __esm(() => {
17700
17704
  init_build();
17701
17705
  init_value2();
17702
17706
  init_delivery_files();
17703
17707
  init_contract_matrix();
17704
17708
  init_delivery_tuple();
17705
- closed10 = { additionalProperties: false };
17709
+ closed9 = { additionalProperties: false };
17706
17710
  hash3 = String2({ pattern: "^[a-f0-9]{64}$" });
17707
17711
  label = String2({ minLength: 1, maxLength: 256, pattern: "\\S" });
17708
17712
  timestamp2 = String2({ minLength: 24, maxLength: 24 });
@@ -17725,7 +17729,7 @@ var init_fa_stability = __esm(() => {
17725
17729
  proof = _Object_({
17726
17730
  path: String2({ pattern: "^[A-Za-z0-9_-][A-Za-z0-9_./-]{0,255}$" }),
17727
17731
  sha256: hash3
17728
- }, closed10);
17732
+ }, closed9);
17729
17733
  FaBusinessObservationSchema = _Object_({
17730
17734
  id: String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }),
17731
17735
  tuple_sha256: hash3,
@@ -17735,7 +17739,7 @@ var init_fa_stability = __esm(() => {
17735
17739
  outcome: Enum(["success", "failure", "timeout", "unknown"]),
17736
17740
  attempts: Integer({ minimum: 1, maximum: 1000 }),
17737
17741
  rollbacks: count2
17738
- }, closed10);
17742
+ }, closed9);
17739
17743
  FaServiceObjectivesSchema = _Object_({
17740
17744
  status: Literal("approved"),
17741
17745
  owner: label,
@@ -17751,8 +17755,8 @@ var init_fa_stability = __esm(() => {
17751
17755
  minimum_samples: Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
17752
17756
  availability_percent: Number2({ exclusiveMinimum: 0, maximum: 100 }),
17753
17757
  p95_ms: Number2({ exclusiveMinimum: 0, maximum: Number.MAX_SAFE_INTEGER })
17754
- }, closed10), { minItems: FA_BUSINESS_OPERATIONS.length, maxItems: FA_BUSINESS_OPERATIONS.length })
17755
- }, closed10);
17758
+ }, closed9), { minItems: FA_BUSINESS_OPERATIONS.length, maxItems: FA_BUSINESS_OPERATIONS.length })
17759
+ }, closed9);
17756
17760
  FaStabilityEvidenceSchema = _Object_({
17757
17761
  schema: Literal("supacloud.fa-stability-evidence.v1"),
17758
17762
  environment: environment2,
@@ -17778,7 +17782,7 @@ var init_fa_stability = __esm(() => {
17778
17782
  passed: Boolean2(),
17779
17783
  measured_at: timestamp2,
17780
17784
  proof
17781
- }, closed10), { minItems: 10, maxItems: 10 }),
17785
+ }, closed9), { minItems: 10, maxItems: 10 }),
17782
17786
  matrix: _Array_(_Object_({
17783
17787
  combination: label,
17784
17788
  scenario: label,
@@ -17787,14 +17791,14 @@ var init_fa_stability = __esm(() => {
17787
17791
  passed: Boolean2(),
17788
17792
  measured_at: timestamp2,
17789
17793
  proof
17790
- }, closed10), { minItems: 48, maxItems: 48 }),
17794
+ }, closed9), { minItems: 48, maxItems: 48 }),
17791
17795
  observation: proof,
17792
- alert: _Object_({ route: label, acknowledged_by: label, delivered_at: timestamp2 }, closed10)
17793
- }, closed10);
17796
+ alert: _Object_({ route: label, acknowledged_by: label, delivered_at: timestamp2 }, closed9)
17797
+ }, closed9);
17794
17798
  });
17795
17799
 
17796
17800
  // node_modules/@supacloud/delivery/src/application-promotion.ts
17797
- var closed11, projectRef2, sha2565, nullableActivation2, nullableDigest, observation, blocker, ApplicationPromotionPlanSchema;
17801
+ var closed10, projectRef2, sha2565, nullableActivation2, nullableDigest, observation, blocker, ApplicationPromotionPlanSchema;
17798
17802
  var init_application_promotion = __esm(() => {
17799
17803
  init_build();
17800
17804
  init_value2();
@@ -17802,7 +17806,7 @@ var init_application_promotion = __esm(() => {
17802
17806
  init_application_activation();
17803
17807
  init_application_configuration();
17804
17808
  init_application_release();
17805
- closed11 = { additionalProperties: false };
17809
+ closed10 = { additionalProperties: false };
17806
17810
  projectRef2 = String2({ pattern: "^[a-z0-9-]{1,20}$" });
17807
17811
  sha2565 = ApplicationReleaseIdSchema;
17808
17812
  nullableActivation2 = Union([ApplicationActivationIdSchema, Null()]);
@@ -17839,7 +17843,7 @@ var init_application_promotion = __esm(() => {
17839
17843
  environment_id: ApplicationIdSchema,
17840
17844
  release_id: sha2565,
17841
17845
  ...observation
17842
- }, closed11),
17846
+ }, closed10),
17843
17847
  target: _Object_({
17844
17848
  candidate_release_id: sha2565,
17845
17849
  current_release_id: Union([sha2565, Null()]),
@@ -17847,18 +17851,18 @@ var init_application_promotion = __esm(() => {
17847
17851
  configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
17848
17852
  configuration: Union([ApplicationConfigurationViewSchema, Null()]),
17849
17853
  ...observation
17850
- }, closed11),
17854
+ }, closed10),
17851
17855
  migrations: _Object_({
17852
17856
  ledger_digest: sha2565,
17853
17857
  ledger_compatible: Boolean2(),
17854
17858
  project_migrations_applied: Boolean2(),
17855
17859
  pending_versions: _Array_(String2({ pattern: "^\\d{1,20}$" }), { maxItems: 4096, uniqueItems: true }),
17856
17860
  operator_provisioning_required: Boolean2()
17857
- }, closed11),
17861
+ }, closed10),
17858
17862
  backup: _Object_({
17859
17863
  required: Boolean2(),
17860
17864
  confirmed: Literal(false)
17861
- }, closed11),
17865
+ }, closed10),
17862
17866
  action: Union([Literal("promote"), Literal("no-op"), Literal("blocked")]),
17863
17867
  blockers: _Array_(Enum([...blocker]), {
17864
17868
  maxItems: blocker.length,
@@ -17867,7 +17871,7 @@ var init_application_promotion = __esm(() => {
17867
17871
  steps: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 8, uniqueItems: true }),
17868
17872
  execution_performed: Literal(false),
17869
17873
  data_recovery: Literal("separate-required")
17870
- }, closed11);
17874
+ }, closed10);
17871
17875
  });
17872
17876
 
17873
17877
  // node_modules/@supacloud/delivery/src/application-runtime-identity.ts
@@ -18024,6 +18028,11 @@ var init_src = __esm(() => {
18024
18028
  init_release_contract();
18025
18029
  });
18026
18030
 
18031
+ // src/delivery-files.ts
18032
+ var init_delivery_files2 = __esm(() => {
18033
+ init_delivery_files();
18034
+ });
18035
+
18027
18036
  // src/delivery-migration-archive.ts
18028
18037
  var init_delivery_migration_archive2 = __esm(() => {
18029
18038
  init_src();
@@ -18140,7 +18149,7 @@ var init_release_evidence = __esm(() => {
18140
18149
  });
18141
18150
 
18142
18151
  // src/release-evidence-cli.ts
18143
- import { resolve as resolve23 } from "node:path";
18152
+ import { resolve as resolve24 } from "node:path";
18144
18153
  async function runReleaseEvidenceCommand(args) {
18145
18154
  try {
18146
18155
  const values = new Map;
@@ -18164,7 +18173,7 @@ async function runReleaseEvidenceCommand(args) {
18164
18173
  if (!manifest || !target || manifest.length > 4096 || !/^[a-z][a-z0-9-]{0,62}$/.test(target)) {
18165
18174
  throw new ReleaseEvidenceError("RELEASE_EVIDENCE_INVALID");
18166
18175
  }
18167
- const evidence = await createReleaseEvidence(resolve23(manifest), target);
18176
+ const evidence = await createReleaseEvidence(resolve24(manifest), target);
18168
18177
  console.log(json ? JSON.stringify(evidence, null, 2) : formatReleaseEvidence(evidence));
18169
18178
  } catch (error) {
18170
18179
  console.error(`Error: ${error instanceof ReleaseEvidenceError ? error.code : "RELEASE_EVIDENCE_INVALID"}`);
@@ -18176,15 +18185,15 @@ var init_release_evidence_cli = __esm(() => {
18176
18185
  });
18177
18186
 
18178
18187
  // src/database-contracts.ts
18179
- import { createHash as createHash12 } from "node:crypto";
18180
- import { mkdir as mkdir5, readFile as readFile13 } from "node:fs/promises";
18181
- import { dirname as dirname11, relative as relative12, resolve as resolve24 } from "node:path";
18188
+ import { createHash as createHash13 } from "node:crypto";
18189
+ import { mkdir as mkdir5, readFile as readFile14 } from "node:fs/promises";
18190
+ import { dirname as dirname11, relative as relative13, resolve as resolve25 } from "node:path";
18182
18191
  import * as ts18 from "@typescript/typescript6";
18183
18192
  function hash4(value) {
18184
- return createHash12("sha256").update(value).digest("hex");
18193
+ return createHash13("sha256").update(value).digest("hex");
18185
18194
  }
18186
18195
  function importPath(out, path) {
18187
- const value = relative12(out, path).replaceAll("\\", "/").replace(/\.(?:d\.)?[cm]?ts$/, "");
18196
+ const value = relative13(out, path).replaceAll("\\", "/").replace(/\.(?:d\.)?[cm]?ts$/, "");
18188
18197
  return value.startsWith(".") ? value : `./${value}`;
18189
18198
  }
18190
18199
  function parseDatabaseContractsOptions(value, directory) {
@@ -18206,19 +18215,19 @@ function parseDatabaseContractsOptions(value, directory) {
18206
18215
  throw new TypeError("migrations must be an ordered list of SQL files");
18207
18216
  }
18208
18217
  return {
18209
- rootDir: resolve24(directory, field("rootDir")),
18210
- outDir: resolve24(directory, field("outDir")),
18211
- postgrestTypes: resolve24(directory, field("postgrestTypes")),
18212
- drizzleSchema: resolve24(directory, field("drizzleSchema")),
18218
+ rootDir: resolve25(directory, field("rootDir")),
18219
+ outDir: resolve25(directory, field("outDir")),
18220
+ postgrestTypes: resolve25(directory, field("postgrestTypes")),
18221
+ drizzleSchema: resolve25(directory, field("drizzleSchema")),
18213
18222
  role: field("role"),
18214
- graphql: { ...graphql, schema: resolve24(directory, graphql.schema) },
18215
- migrations: migrations.map((file) => resolve24(directory, file))
18223
+ graphql: { ...graphql, schema: resolve25(directory, graphql.schema) },
18224
+ migrations: migrations.map((file) => resolve25(directory, file))
18216
18225
  };
18217
18226
  }
18218
18227
  async function generateDatabaseContracts(options, check = false) {
18219
- const rootDir = resolve24(options.rootDir), outDir = resolve24(options.outDir);
18220
- const postgrestTypes = resolve24(rootDir, options.postgrestTypes), drizzleSchema = resolve24(rootDir, options.drizzleSchema);
18221
- const snapshot = await readFile13(postgrestTypes, "utf8");
18228
+ const rootDir = resolve25(options.rootDir), outDir = resolve25(options.outDir);
18229
+ const postgrestTypes = resolve25(rootDir, options.postgrestTypes), drizzleSchema = resolve25(rootDir, options.drizzleSchema);
18230
+ const snapshot = await readFile14(postgrestTypes, "utf8");
18222
18231
  const syntax = ts18.createSourceFile(postgrestTypes, snapshot, ts18.ScriptTarget.Latest, true);
18223
18232
  const database = syntax.statements.find((node) => (ts18.isTypeAliasDeclaration(node) || ts18.isInterfaceDeclaration(node)) && node.name.text === "Database" && node.modifiers?.some((modifier) => modifier.kind === ts18.SyntaxKind.ExportKeyword));
18224
18233
  if (!database)
@@ -18245,8 +18254,8 @@ async function generateDatabaseContracts(options, check = false) {
18245
18254
  }
18246
18255
  const inputs = {};
18247
18256
  const addInput = async (path) => {
18248
- const absolute = resolve24(rootDir, path);
18249
- inputs[relative12(rootDir, absolute).replaceAll("\\", "/")] = hash4(await readFile13(absolute, "utf8"));
18257
+ const absolute = resolve25(rootDir, path);
18258
+ inputs[relative13(rootDir, absolute).replaceAll("\\", "/")] = hash4(await readFile14(absolute, "utf8"));
18250
18259
  };
18251
18260
  await addInput(postgrestTypes);
18252
18261
  await addInput(drizzleSchema);
@@ -18262,8 +18271,8 @@ async function generateDatabaseContracts(options, check = false) {
18262
18271
  if (!source.isDeclarationFile && !source.fileName.includes("/node_modules/"))
18263
18272
  await addInput(source.fileName);
18264
18273
  }
18265
- await addInput(resolve24(rootDir, options.graphql.schema));
18266
- if (new Set(options.migrations.map((path) => resolve24(rootDir, path))).size !== options.migrations.length) {
18274
+ await addInput(resolve25(rootDir, options.graphql.schema));
18275
+ if (new Set(options.migrations.map((path) => resolve25(rootDir, path))).size !== options.migrations.length) {
18267
18276
  throw new Error("Duplicate migration in database contracts configuration");
18268
18277
  }
18269
18278
  for (const path of options.migrations)
@@ -18284,17 +18293,17 @@ async function generateDatabaseContracts(options, check = false) {
18284
18293
  version: 1,
18285
18294
  role: options.role,
18286
18295
  inputs: Object.fromEntries(Object.entries(inputs).sort(([a], [b]) => a.localeCompare(b))),
18287
- migrationOrder: options.migrations.map((path) => relative12(rootDir, resolve24(rootDir, path)).replaceAll("\\", "/")),
18296
+ migrationOrder: options.migrations.map((path) => relative13(rootDir, resolve25(rootDir, path)).replaceAll("\\", "/")),
18288
18297
  outputs: Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b)).map(([file, text]) => [file, hash4(text)]))
18289
18298
  };
18290
18299
  files["database.manifest.json"] = JSON.stringify(manifest, null, 2) + `
18291
18300
  `;
18292
18301
  const mismatches = [];
18293
18302
  for (const [file, content] of Object.entries(files)) {
18294
- const path = resolve24(outDir, file);
18303
+ const path = resolve25(outDir, file);
18295
18304
  let current;
18296
18305
  try {
18297
- current = await readFile13(path, "utf8");
18306
+ current = await readFile14(path, "utf8");
18298
18307
  } catch (error) {
18299
18308
  if (!(error instanceof Error && ("code" in error) && error.code === "ENOENT"))
18300
18309
  throw error;
@@ -18305,13 +18314,13 @@ async function generateDatabaseContracts(options, check = false) {
18305
18314
  if (!check) {
18306
18315
  await mkdir5(outDir, { recursive: true });
18307
18316
  for (const [file, content] of Object.entries(files))
18308
- await writeFileIfChanged(resolve24(outDir, file), content);
18317
+ await writeFileIfChanged(resolve25(outDir, file), content);
18309
18318
  }
18310
18319
  return { upToDate: mismatches.length === 0, mismatches, written: check ? [] : mismatches, manifest };
18311
18320
  }
18312
18321
  async function runDatabaseContractsFile(path, check = false) {
18313
- const absolute = resolve24(path);
18314
- const value = JSON.parse(await readFile13(absolute, "utf8"));
18322
+ const absolute = resolve25(path);
18323
+ const value = JSON.parse(await readFile14(absolute, "utf8"));
18315
18324
  return generateDatabaseContracts(parseDatabaseContractsOptions(value, dirname11(absolute)), check);
18316
18325
  }
18317
18326
  var init_database_contracts = __esm(() => {
@@ -18321,8 +18330,8 @@ var init_database_contracts = __esm(() => {
18321
18330
  });
18322
18331
 
18323
18332
  // src/graphql-schema.ts
18324
- import { mkdir as mkdir6, readFile as readFile14 } from "node:fs/promises";
18325
- import { dirname as dirname12, resolve as resolve25 } from "node:path";
18333
+ import { mkdir as mkdir6, readFile as readFile15 } from "node:fs/promises";
18334
+ import { dirname as dirname12, resolve as resolve26 } from "node:path";
18326
18335
  async function pullGraphqlSchema(options) {
18327
18336
  assertGraphqlOptions({ schema: options.output });
18328
18337
  const endpoint = new URL(options.url);
@@ -18362,7 +18371,7 @@ async function pullGraphqlSchema(options) {
18362
18371
  throw new Error("GraphQL schema export failed. Verify caller grants and enable introspection only in the intended development environment.");
18363
18372
  }
18364
18373
  const schema = lexicographicSortSchema(buildClientSchema(data));
18365
- const path = resolve25(options.output);
18374
+ const path = resolve26(options.output);
18366
18375
  const content = path.endsWith(".json") ? JSON.stringify(introspectionFromSchema(schema), null, 2) + `
18367
18376
  ` : `# GENERATED BY supacloud-compiler graphql-schema. DO NOT EDIT.
18368
18377
  # Database First: change database declarations, apply migrations, then re-export for the intended role.
@@ -18370,7 +18379,7 @@ async function pullGraphqlSchema(options) {
18370
18379
  `;
18371
18380
  let previous;
18372
18381
  try {
18373
- previous = await readFile14(path, "utf8");
18382
+ previous = await readFile15(path, "utf8");
18374
18383
  } catch (error) {
18375
18384
  if (!(error instanceof Error && ("code" in error) && error.code === "ENOENT"))
18376
18385
  throw error;
@@ -18390,8 +18399,8 @@ var init_graphql_schema = __esm(() => {
18390
18399
  });
18391
18400
 
18392
18401
  // src/cli.ts
18393
- import { resolve as resolve26 } from "node:path";
18394
- import { readFile as readFile15 } from "node:fs/promises";
18402
+ import { resolve as resolve27 } from "node:path";
18403
+ import { readFile as readFile16 } from "node:fs/promises";
18395
18404
 
18396
18405
  // src/analyze.ts
18397
18406
  import { createHash as createHash3 } from "node:crypto";
@@ -23933,6 +23942,431 @@ function compileOptionsFromConfig(config, cwd = process.cwd()) {
23933
23942
  // src/cli.ts
23934
23943
  init_fixes();
23935
23944
 
23945
+ // src/preview-fix-loop.ts
23946
+ init_src();
23947
+ import { createHash as createHash10 } from "node:crypto";
23948
+ import { lstat as lstat3, readdir as readdir4, readFile as readFile6, realpath as realpath4, writeFile as writeFile4 } from "node:fs/promises";
23949
+ import { basename as basename2, isAbsolute as isAbsolute5, join as join9, relative as relative10, resolve as resolve15, sep as sep10 } from "node:path";
23950
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
23951
+ init_execution_context();
23952
+ init_fixes();
23953
+ var PREVIEW_DEPLOY_RECEIPT_SCHEMA = "supacloud.preview-deploy-receipt.v1";
23954
+ var PREVIEW_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
23955
+ var PROJECT_REF = /^[a-z0-9-]{1,20}$/;
23956
+ var RESOURCE_ID = /^[A-Za-z0-9_-]{1,64}$/;
23957
+ var RELATIVE_FILE = /^(?!\/)(?!\.\.(?:\/|$))(?!.*\/\.\.(?:\/|$))[A-Za-z0-9_./-]{1,240}$/;
23958
+ var MAX_FILES = 200;
23959
+ var MAX_FILE_BYTES = 1048576;
23960
+ var EVENTS_FILE = "preview-execution-events.json";
23961
+ var RECEIPT_FILE = "preview-deploy-receipt.json";
23962
+
23963
+ class PreviewFixError extends Error {
23964
+ code;
23965
+ constructor(code) {
23966
+ super(code);
23967
+ this.code = code;
23968
+ this.name = "PreviewFixError";
23969
+ }
23970
+ }
23971
+ function fail(code) {
23972
+ throw new PreviewFixError(code);
23973
+ }
23974
+ function inside2(parent, child) {
23975
+ const fromParent = relative10(parent, child);
23976
+ return fromParent === "" || !isAbsolute5(fromParent) && fromParent !== ".." && !fromParent.startsWith(`..${sep10}`);
23977
+ }
23978
+ async function realDirectory(path) {
23979
+ const resolved = resolve15(path);
23980
+ let stat;
23981
+ try {
23982
+ stat = await lstat3(resolved);
23983
+ } catch {
23984
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
23985
+ }
23986
+ if (!stat.isDirectory() || stat.isSymbolicLink())
23987
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
23988
+ const real = await realpath4(resolved);
23989
+ if (real !== resolved)
23990
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
23991
+ return real;
23992
+ }
23993
+ async function treeDigest(root) {
23994
+ const files = [];
23995
+ async function walk(directory) {
23996
+ if (files.length > MAX_FILES)
23997
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
23998
+ for (const entry of await readdir4(directory, { withFileTypes: true })) {
23999
+ if (entry.isSymbolicLink() || entry.name === "." || entry.name === ".." || entry.name.includes("..")) {
24000
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
24001
+ }
24002
+ const path = join9(directory, entry.name);
24003
+ if (entry.isDirectory()) {
24004
+ if (entry.name === "node_modules")
24005
+ continue;
24006
+ await walk(path);
24007
+ } else if (entry.isFile()) {
24008
+ const stat = await lstat3(path);
24009
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_FILE_BYTES)
24010
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
24011
+ files.push(path);
24012
+ } else {
24013
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
24014
+ }
24015
+ }
24016
+ }
24017
+ await walk(root);
24018
+ if (files.length > MAX_FILES)
24019
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
24020
+ const hash = createHash10("sha256");
24021
+ for (const file of files.sort()) {
24022
+ hash.update(relative10(root, file));
24023
+ hash.update("\x00");
24024
+ hash.update(await readFile6(file));
24025
+ hash.update("\x00");
24026
+ }
24027
+ return hash.digest("hex");
24028
+ }
24029
+ function identity2(input, branchRef) {
24030
+ if (!PREVIEW_ID.test(input.previewId) || !PROJECT_REF.test(input.projectRef) || !RESOURCE_ID.test(input.applicationId) || !RESOURCE_ID.test(input.environmentId) || input.property !== "transaction" && input.property !== "idempotency" || input.value !== "required" && input.value !== "none") {
24031
+ fail("PREVIEW_FIX_POLICY_REQUIRED");
24032
+ }
24033
+ if (applicationPreviewBranchRef(input.previewId) !== branchRef)
24034
+ fail("PREVIEW_FIX_IDENTITY_MISMATCH");
24035
+ }
24036
+ function matchingFix(diagnostics, property) {
24037
+ const errors = diagnostics.filter((diagnostic) => diagnostic.severity === "error");
24038
+ const matches = errors.filter((diagnostic) => diagnostic.code === "invalid-command-mode" && diagnostic.fix?.type === "set_command_mode" && diagnostic.fix.property === property && typeof diagnostic.file === "string" && RELATIVE_FILE.test(diagnostic.file) && diagnostic.errorCode === "SC4012");
24039
+ const [match] = matches;
24040
+ if (errors.length !== 1 || matches.length !== 1 || !match?.fix || match.fix.type !== "set_command_mode") {
24041
+ return fail("PREVIEW_FIX_DIAGNOSIS_REQUIRED");
24042
+ }
24043
+ return match.fix;
24044
+ }
24045
+ function record5(value, keys) {
24046
+ if (!value || typeof value !== "object" || Array.isArray(value))
24047
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24048
+ const entry = value;
24049
+ const present = Object.keys(entry);
24050
+ if (present.length !== keys.length || keys.some((key) => !Object.prototype.hasOwnProperty.call(entry, key))) {
24051
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24052
+ }
24053
+ return entry;
24054
+ }
24055
+ function text3(value, pattern) {
24056
+ if (typeof value !== "string" || !pattern.test(value))
24057
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24058
+ return value;
24059
+ }
24060
+ function stringList(value) {
24061
+ if (!Array.isArray(value) || value.length > 32 || value.some((item) => typeof item !== "string" || !/^[A-Za-z0-9_.:-]{1,128}$/.test(item))) {
24062
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24063
+ }
24064
+ return [...value];
24065
+ }
24066
+ function parsePreviewDeployReceipt(value) {
24067
+ const root = record5(value, [
24068
+ "schema",
24069
+ "deployed",
24070
+ "published",
24071
+ "live",
24072
+ "target",
24073
+ "preview_id",
24074
+ "project_ref",
24075
+ "application_id",
24076
+ "environment_id",
24077
+ "branch_ref",
24078
+ "artifact_sha256",
24079
+ "status",
24080
+ "graph",
24081
+ "change",
24082
+ "diagnosis",
24083
+ "test",
24084
+ "timeline",
24085
+ "production"
24086
+ ]);
24087
+ if (root.schema !== PREVIEW_DEPLOY_RECEIPT_SCHEMA || root.deployed !== false || root.published !== false || root.live !== false || root.target !== "preview" || root.status !== "recorded") {
24088
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24089
+ }
24090
+ const graph = record5(root.graph, ["modules", "command", "transaction"]);
24091
+ const change = record5(root.change, ["file", "written"]);
24092
+ const diagnosis = record5(root.diagnosis, ["code", "errorCode", "file"]);
24093
+ const test = record5(root.test, ["operation", "ok"]);
24094
+ const timeline = record5(root.timeline, ["requestId", "operation", "handler", "failed", "complete", "missingStages"]);
24095
+ const production = record5(root.production, ["written", "approval", "graphRead"]);
24096
+ if (change.written !== true || test.ok !== true || timeline.handler !== "succeeded" || timeline.failed !== false || typeof timeline.complete !== "boolean" || production.written !== false || production.approval !== "required" || production.graphRead !== true || graph.transaction !== "required" && graph.transaction !== "none") {
24097
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24098
+ }
24099
+ const previewId = text3(root.preview_id, PREVIEW_ID);
24100
+ const branchRef = text3(root.branch_ref, /^pv[a-f0-9]{18}$/);
24101
+ if (applicationPreviewBranchRef(previewId) !== branchRef)
24102
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24103
+ return {
24104
+ schema: PREVIEW_DEPLOY_RECEIPT_SCHEMA,
24105
+ deployed: false,
24106
+ published: false,
24107
+ live: false,
24108
+ target: "preview",
24109
+ preview_id: previewId,
24110
+ project_ref: text3(root.project_ref, PROJECT_REF),
24111
+ application_id: text3(root.application_id, RESOURCE_ID),
24112
+ environment_id: text3(root.environment_id, RESOURCE_ID),
24113
+ branch_ref: branchRef,
24114
+ artifact_sha256: text3(root.artifact_sha256, /^[a-f0-9]{64}$/),
24115
+ status: "recorded",
24116
+ graph: {
24117
+ modules: stringList(graph.modules),
24118
+ command: text3(graph.command, /^[A-Za-z0-9_.:-]{1,128}$/),
24119
+ transaction: graph.transaction
24120
+ },
24121
+ change: { file: text3(change.file, RELATIVE_FILE), written: true },
24122
+ diagnosis: {
24123
+ code: text3(diagnosis.code, /^[a-z0-9-]{1,64}$/),
24124
+ errorCode: text3(diagnosis.errorCode, /^SC[0-9]{4}$/),
24125
+ file: text3(diagnosis.file, RELATIVE_FILE)
24126
+ },
24127
+ test: { operation: text3(test.operation, /^[A-Za-z0-9_.:-]{1,128}$/), ok: true },
24128
+ timeline: {
24129
+ requestId: text3(timeline.requestId, /^[A-Za-z0-9._:-]{1,256}$/),
24130
+ operation: text3(timeline.operation, /^[A-Za-z0-9_.:-]{1,128}$/),
24131
+ handler: "succeeded",
24132
+ failed: false,
24133
+ complete: timeline.complete,
24134
+ missingStages: stringList(timeline.missingStages)
24135
+ },
24136
+ production: { written: false, approval: "required", graphRead: true }
24137
+ };
24138
+ }
24139
+ async function writeInside(root, name, contents) {
24140
+ if (name !== EVENTS_FILE && name !== RECEIPT_FILE)
24141
+ return fail("PREVIEW_FIX_ROOT_UNSUPPORTED");
24142
+ const path = join9(root, name);
24143
+ if (!inside2(root, path))
24144
+ return fail("PRODUCTION_APPROVAL_REQUIRED");
24145
+ await writeFile4(path, contents, { encoding: "utf8", flag: "wx", mode: 420 });
24146
+ }
24147
+ async function runPreviewFixLoop(input) {
24148
+ const branchRef = basename2(resolve15(input.previewRoot));
24149
+ identity2(input, branchRef);
24150
+ const productionRoot = await realDirectory(input.productionRoot);
24151
+ const previewRoot = await realDirectory(input.previewRoot);
24152
+ if (basename2(previewRoot) !== branchRef || productionRoot === previewRoot || inside2(productionRoot, previewRoot) || inside2(previewRoot, productionRoot)) {
24153
+ return fail("PREVIEW_FIX_IDENTITY_MISMATCH");
24154
+ }
24155
+ const productionBefore = await treeDigest(productionRoot);
24156
+ let previewGraph;
24157
+ let productionGraph;
24158
+ try {
24159
+ previewGraph = await analyzeProject(previewRoot);
24160
+ productionGraph = await analyzeProject(productionRoot);
24161
+ } catch (error) {
24162
+ if (error instanceof PreviewFixError)
24163
+ throw error;
24164
+ return fail("PREVIEW_FIX_DIAGNOSIS_REQUIRED");
24165
+ }
24166
+ if (!productionGraph.modules)
24167
+ return fail("PREVIEW_FIX_DIAGNOSIS_REQUIRED");
24168
+ const fix = matchingFix(previewGraph.diagnostics ?? [], input.property);
24169
+ const chosen = { ...fix, value: input.value };
24170
+ const previewed = await applyDiagnosticFix(chosen, { rootDir: previewRoot });
24171
+ if (!previewed.changed || !inside2(previewRoot, previewed.file))
24172
+ return fail("PREVIEW_FIX_DIAGNOSIS_REQUIRED");
24173
+ const applied = await applyDiagnosticFix(chosen, { rootDir: previewRoot, dryRun: false });
24174
+ if (!applied.changed || !inside2(previewRoot, applied.file))
24175
+ return fail("PRODUCTION_APPROVAL_REQUIRED");
24176
+ if (await treeDigest(productionRoot) !== productionBefore)
24177
+ return fail("PRODUCTION_APPROVAL_REQUIRED");
24178
+ const compiled = await compileProject({ rootDir: previewRoot, outDir: join9(previewRoot, "generated") });
24179
+ const command = compiled.graph.modules.flatMap((module) => module.commands).find((item) => item.className === fix.command);
24180
+ const policyApplied = input.property === "transaction" ? command?.transaction === input.value : command?.idempotency === input.value;
24181
+ if (compiled.diagnostics.some((diagnostic) => diagnostic.severity === "error") || !command || !policyApplied) {
24182
+ return fail("PREVIEW_FIX_COMPILE_FAILED");
24183
+ }
24184
+ const sourceFile = join9(previewRoot, fix.targetFile);
24185
+ const sourceReal = await realpath4(sourceFile).catch(() => fail("PREVIEW_FIX_INVOKE_FAILED"));
24186
+ if (!inside2(previewRoot, sourceReal))
24187
+ return fail("PRODUCTION_APPROVAL_REQUIRED");
24188
+ const started = performance.now();
24189
+ try {
24190
+ const child = Bun.spawn([
24191
+ process.versions.bun ? process.execPath : "bun",
24192
+ "--no-env-file",
24193
+ "-e",
24194
+ [
24195
+ "const imported = await import(process.argv[1]);",
24196
+ "const ctor = imported[process.argv[2]];",
24197
+ 'if (typeof ctor !== "function") process.exit(2);',
24198
+ "const instance = new ctor();",
24199
+ 'if (typeof instance.execute !== "function") process.exit(3);',
24200
+ "const output = await instance.execute();",
24201
+ 'process.exit(output && typeof output === "object" && output.ok === true ? 0 : 4);'
24202
+ ].join(`
24203
+ `),
24204
+ "--",
24205
+ pathToFileURL2(sourceReal).href,
24206
+ fix.command
24207
+ ], {
24208
+ cwd: previewRoot,
24209
+ env: { PATH: process.env.PATH ?? "" },
24210
+ stdout: "ignore",
24211
+ stderr: "ignore"
24212
+ });
24213
+ const timer = setTimeout(() => child.kill(), 1e4);
24214
+ const status = await child.exited.finally(() => clearTimeout(timer));
24215
+ if (status !== 0)
24216
+ return fail("PREVIEW_FIX_INVOKE_FAILED");
24217
+ } catch (error) {
24218
+ if (error instanceof PreviewFixError)
24219
+ throw error;
24220
+ return fail("PREVIEW_FIX_INVOKE_FAILED");
24221
+ }
24222
+ const durationMs = Math.max(0, performance.now() - started);
24223
+ const requestId = `preview-${input.previewId}`;
24224
+ const events = {
24225
+ version: 1,
24226
+ events: [
24227
+ { kind: "command", operation: command.name, stage: "handler", phase: "started", requestId, attempt: 1 },
24228
+ { kind: "command", operation: command.name, stage: "handler", phase: "succeeded", requestId, attempt: 1, durationMs }
24229
+ ]
24230
+ };
24231
+ await writeInside(previewRoot, EVENTS_FILE, `${JSON.stringify(events)}
24232
+ `);
24233
+ const eventsPath = join9(previewRoot, EVENTS_FILE);
24234
+ let pack;
24235
+ try {
24236
+ pack = createExecutionContextPack(compiled.graph, command.name, await readExecutionMetadata(eventsPath), requestId);
24237
+ } catch {
24238
+ return fail("PREVIEW_FIX_TIMELINE_UNAVAILABLE");
24239
+ }
24240
+ const entry = pack.timeline.find((item) => item.kind === "command" && item.operation === command.name);
24241
+ const attempt = entry?.attempts[0];
24242
+ const handler = attempt?.stages.find((stage) => stage.stage === "handler" && stage.phase === "succeeded");
24243
+ if (!entry || !attempt || !handler || attempt.failed || pack.requestId !== requestId) {
24244
+ return fail("PREVIEW_FIX_TIMELINE_UNAVAILABLE");
24245
+ }
24246
+ const artifactPath = join9(previewRoot, "generated", "application.ts");
24247
+ const artifactReal = await realpath4(artifactPath).catch(() => fail("PREVIEW_FIX_COMPILE_FAILED"));
24248
+ if (!inside2(previewRoot, artifactReal))
24249
+ return fail("PRODUCTION_APPROVAL_REQUIRED");
24250
+ const artifact = await readFile6(artifactReal);
24251
+ const receipt = parsePreviewDeployReceipt({
24252
+ schema: PREVIEW_DEPLOY_RECEIPT_SCHEMA,
24253
+ deployed: false,
24254
+ published: false,
24255
+ live: false,
24256
+ target: "preview",
24257
+ preview_id: input.previewId,
24258
+ project_ref: input.projectRef,
24259
+ application_id: input.applicationId,
24260
+ environment_id: input.environmentId,
24261
+ branch_ref: branchRef,
24262
+ artifact_sha256: createHash10("sha256").update(artifact).digest("hex"),
24263
+ status: "recorded",
24264
+ graph: {
24265
+ modules: compiled.graph.modules.map((module) => module.name),
24266
+ command: command.name,
24267
+ transaction: command.transaction
24268
+ },
24269
+ change: { file: relative10(previewRoot, applied.file), written: true },
24270
+ diagnosis: { code: "invalid-command-mode", errorCode: "SC4012", file: fix.targetFile },
24271
+ test: { operation: command.name, ok: true },
24272
+ timeline: {
24273
+ requestId,
24274
+ operation: command.name,
24275
+ handler: "succeeded",
24276
+ failed: false,
24277
+ complete: attempt.complete,
24278
+ missingStages: attempt.missingStages
24279
+ },
24280
+ production: { written: false, approval: "required", graphRead: true }
24281
+ });
24282
+ await writeInside(previewRoot, RECEIPT_FILE, `${JSON.stringify(receipt, null, 2)}
24283
+ `);
24284
+ if (await treeDigest(productionRoot) !== productionBefore)
24285
+ return fail("PRODUCTION_APPROVAL_REQUIRED");
24286
+ const written = parsePreviewDeployReceipt(JSON.parse(await readFile6(join9(previewRoot, RECEIPT_FILE), "utf8")));
24287
+ if (written.deployed !== false || written.production.written !== false)
24288
+ return fail("PREVIEW_FIX_RECEIPT_INVALID");
24289
+ return written;
24290
+ }
24291
+
24292
+ // src/preview-fix-cli.ts
24293
+ var FLAGS = [
24294
+ "--production",
24295
+ "--preview",
24296
+ "--preview-id",
24297
+ "--project-ref",
24298
+ "--application-id",
24299
+ "--environment-id",
24300
+ "--property",
24301
+ "--value"
24302
+ ];
24303
+ function fail2(code) {
24304
+ console.error(`Error: ${code}`);
24305
+ process.exitCode = 1;
24306
+ throw new Error(code);
24307
+ }
24308
+ async function runPreviewFixCommand(args) {
24309
+ try {
24310
+ const values = new Map;
24311
+ let json = false;
24312
+ for (let index = 0;index < args.length; index++) {
24313
+ const option = args[index];
24314
+ if (option === "--json") {
24315
+ if (json)
24316
+ fail2("PREVIEW_FIX_POLICY_REQUIRED");
24317
+ json = true;
24318
+ continue;
24319
+ }
24320
+ if (!FLAGS.includes(option))
24321
+ fail2("PREVIEW_FIX_POLICY_REQUIRED");
24322
+ const value = args[++index];
24323
+ if (!value || value.startsWith("-") || values.has(option) || /[\u0000-\u001f\u007f]/.test(value) || value.length > 4096) {
24324
+ fail2("PREVIEW_FIX_POLICY_REQUIRED");
24325
+ }
24326
+ values.set(option, value);
24327
+ }
24328
+ const required = FLAGS.map((flag) => values.get(flag));
24329
+ if (required.some((value) => value === undefined))
24330
+ fail2("PREVIEW_FIX_POLICY_REQUIRED");
24331
+ const [productionRoot, previewRoot, previewId, projectRef, applicationId, environmentId, property, value] = required;
24332
+ if (property !== "transaction" && property !== "idempotency" || value !== "required" && value !== "none") {
24333
+ fail2("PREVIEW_FIX_POLICY_REQUIRED");
24334
+ }
24335
+ const input = {
24336
+ productionRoot,
24337
+ previewRoot,
24338
+ previewId,
24339
+ projectRef,
24340
+ applicationId,
24341
+ environmentId,
24342
+ property,
24343
+ value
24344
+ };
24345
+ const receipt = await runPreviewFixLoop(input);
24346
+ if (json) {
24347
+ console.log(JSON.stringify(receipt, null, 2));
24348
+ return;
24349
+ }
24350
+ console.log([
24351
+ "preview-fix recorded",
24352
+ ` preview: ${receipt.preview_id}`,
24353
+ ` branch: ${receipt.branch_ref}`,
24354
+ ` diagnosis: ${receipt.diagnosis.errorCode}`,
24355
+ ` test: ${receipt.test.operation} ok`,
24356
+ " deployed: false",
24357
+ " published: false",
24358
+ " production written: false",
24359
+ " production approval: required"
24360
+ ].join(`
24361
+ `));
24362
+ } catch (error) {
24363
+ if (process.exitCode === 1)
24364
+ return;
24365
+ console.error(`Error: ${error instanceof PreviewFixError ? error.code : "PREVIEW_FIX_FAILED"}`);
24366
+ process.exitCode = 1;
24367
+ }
24368
+ }
24369
+
23936
24370
  // src/diagnostics.ts
23937
24371
  function createDiagnosticReport(diagnostics) {
23938
24372
  return { format: 1, entries: diagnostics.map((diagnostic) => {
@@ -23990,7 +24424,7 @@ async function createEditorCodeActions(diagnostics, options = {}) {
23990
24424
  init_graphql_options();
23991
24425
 
23992
24426
  // src/delivery-plan.ts
23993
- import { createHash as createHash10 } from "node:crypto";
24427
+ import { createHash as createHash11 } from "node:crypto";
23994
24428
  init_feature();
23995
24429
  init_validate();
23996
24430
  var compare2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
@@ -24223,7 +24657,7 @@ function createDeliveryPlan(graph, input, validation) {
24223
24657
  deploymentReady: false,
24224
24658
  targets: [...targets.values()].sort((a, b) => compare2(a.name, b.name))
24225
24659
  };
24226
- const topologyDigest = createHash10("sha256").update(JSON.stringify(topology)).digest("hex");
24660
+ const topologyDigest = createHash11("sha256").update(JSON.stringify(topology)).digest("hex");
24227
24661
  return parseDeliveryPlanResult({
24228
24662
  ok: true,
24229
24663
  plan: { ...topology, topologyDigest },
@@ -24258,9 +24692,9 @@ function formatDeliveryPlan(result) {
24258
24692
  }
24259
24693
 
24260
24694
  // src/delivery-build.ts
24261
- import { mkdir as mkdir3, mkdtemp, readFile as readFile7, realpath as realpath4, rename as rename4, rm as rm2 } from "node:fs/promises";
24695
+ import { mkdir as mkdir3, mkdtemp, readFile as readFile8, realpath as realpath5, rename as rename4, rm as rm2 } from "node:fs/promises";
24262
24696
  import { readFileSync as readFileSync3 } from "node:fs";
24263
- import { dirname as dirname9, join as join10, relative as relative10, resolve as resolve17, sep as sep10 } from "node:path";
24697
+ import { dirname as dirname9, join as join11, relative as relative11, resolve as resolve18, sep as sep11 } from "node:path";
24264
24698
  import * as ts16 from "@typescript/typescript6";
24265
24699
 
24266
24700
  // src/delivery-build-schema.ts
@@ -24301,8 +24735,8 @@ function renderDeliveryTarget(graph, target, options) {
24301
24735
  // src/delivery-bundle.ts
24302
24736
  init_delivery_files2();
24303
24737
  import { isBuiltin } from "node:module";
24304
- import { readFile as readFile6 } from "node:fs/promises";
24305
- import { join as join9, resolve as resolve15 } from "node:path";
24738
+ import { readFile as readFile7 } from "node:fs/promises";
24739
+ import { join as join10, resolve as resolve16 } from "node:path";
24306
24740
  import * as ts15 from "@typescript/typescript6";
24307
24741
 
24308
24742
  // src/delivery-imports.ts
@@ -24391,7 +24825,7 @@ function staticDeliveryImports(path, contents) {
24391
24825
  // src/delivery-bundle-protocol.ts
24392
24826
  init_build();
24393
24827
  init_value2();
24394
- var closed5 = { additionalProperties: false };
24828
+ var closed11 = { additionalProperties: false };
24395
24829
  var requestSchema = _Object_({
24396
24830
  parentPid: Integer({ minimum: 1 }),
24397
24831
  name: String2(),
@@ -24399,15 +24833,15 @@ var requestSchema = _Object_({
24399
24833
  project: String2(),
24400
24834
  generatedDirectory: String2(),
24401
24835
  options: DeliveryOptionsSchema
24402
- }, closed5);
24836
+ }, closed11);
24403
24837
  var responseSchema = Union([
24404
24838
  _Object_({
24405
24839
  ok: Literal(true),
24406
24840
  files: _Array_(Tuple([DeliveryFilePathSchema, String2({ pattern: "^[A-Za-z0-9+/]*={0,2}$" })])),
24407
24841
  inputs: _Array_(Tuple([String2(), String2({ pattern: "^[a-f0-9]{64}$" })])),
24408
24842
  runtimeImports: _Array_(String2())
24409
- }, closed5),
24410
- _Object_({ ok: Literal(false) }, closed5)
24843
+ }, closed11),
24844
+ _Object_({ ok: Literal(false) }, closed11)
24411
24845
  ]);
24412
24846
  function parseDeliveryBundleRequest(input) {
24413
24847
  if (!Check2(requestSchema, input))
@@ -24422,7 +24856,7 @@ function parseDeliveryBundleResponse(input) {
24422
24856
 
24423
24857
  // src/delivery-bundle.ts
24424
24858
  async function bundleDeliveryTarget(name, code, project, generatedDirectory, options) {
24425
- const worker = join9(import.meta.dir, `delivery-bundle-worker.${import.meta.path.endsWith(".ts") ? "ts" : "js"}`);
24859
+ const worker = join10(import.meta.dir, `delivery-bundle-worker.${import.meta.path.endsWith(".ts") ? "ts" : "js"}`);
24426
24860
  const environment = {};
24427
24861
  for (const name of ["PATH", "HOME", "TMPDIR", "TMP", "TEMP", "SystemRoot"]) {
24428
24862
  const value = process.env[name];
@@ -24479,7 +24913,7 @@ async function bundleDeliveryTarget(name, code, project, generatedDirectory, opt
24479
24913
  async function bundleDeliveryTargetInProcess(name, code, project, generatedDirectory, options) {
24480
24914
  const inputs = new Map;
24481
24915
  const workingDirectory = process.cwd();
24482
- const entry = resolve15(generatedDirectory, `delivery-${name}.ts`);
24916
+ const entry = resolve16(generatedDirectory, `delivery-${name}.ts`);
24483
24917
  const entryPattern = new RegExp(`^${entry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`);
24484
24918
  const result = await Bun.build({
24485
24919
  entrypoints: [entry],
@@ -24501,8 +24935,8 @@ async function bundleDeliveryTargetInProcess(name, code, project, generatedDirec
24501
24935
  build.onLoad({ filter: /.*/, namespace: "file" }, async (args) => {
24502
24936
  if (args.path === entry)
24503
24937
  return { contents: code, loader: "ts" };
24504
- const bytes = await readFile6(args.path);
24505
- inputs.set(resolve15(args.path), digest(bytes));
24938
+ const bytes = await readFile7(args.path);
24939
+ inputs.set(resolve16(args.path), digest(bytes));
24506
24940
  return { contents: staticDeliveryImports(args.path, bytes), loader: args.loader };
24507
24941
  });
24508
24942
  }
@@ -24512,7 +24946,7 @@ async function bundleDeliveryTargetInProcess(name, code, project, generatedDirec
24512
24946
  throw new Error("Independent bundle failed or has no dependency metadata.");
24513
24947
  const runtimeImports = new Set;
24514
24948
  for (const [path, metadata] of Object.entries(result.metafile.inputs)) {
24515
- if (resolve15(workingDirectory, path) !== entry && !inputs.has(resolve15(workingDirectory, path))) {
24949
+ if (resolve16(workingDirectory, path) !== entry && !inputs.has(resolve16(workingDirectory, path))) {
24516
24950
  throw new Error("Bundler reported an input that was not captured by the delivery snapshot.");
24517
24951
  }
24518
24952
  for (const imported of metadata.imports) {
@@ -24547,7 +24981,7 @@ async function bundleDeliveryTargetInProcess(name, code, project, generatedDirec
24547
24981
  if (!files.has("bundle/index.js"))
24548
24982
  throw new Error("Independent bundle has no index.js entrypoint.");
24549
24983
  for (const [path, hash] of inputs) {
24550
- if (digest(await readFile6(path)) !== hash)
24984
+ if (digest(await readFile7(path)) !== hash)
24551
24985
  throw new Error("Source changed during bundling; retry the build.");
24552
24986
  }
24553
24987
  return { files, inputs, runtimeImports: [...runtimeImports].sort() };
@@ -24898,14 +25332,14 @@ export default deliveryFunctionDefault;
24898
25332
 
24899
25333
  // src/delivery-migrations.ts
24900
25334
  init_delivery_files2();
24901
- import { resolve as resolve16 } from "node:path";
25335
+ import { resolve as resolve17 } from "node:path";
24902
25336
  async function prepareDeliveryMigrations(project, generatedRoot, declarations = []) {
24903
25337
  const entries = [];
24904
25338
  const files = new Map;
24905
25339
  const inputs = new Map;
24906
25340
  let totalBytes = 0;
24907
25341
  for (const declaration of [...declarations].sort((a, b) => BigInt(a.version) < BigInt(b.version) ? -1 : BigInt(a.version) > BigInt(b.version) ? 1 : 0)) {
24908
- const source = resolve16(project, declaration.source);
25342
+ const source = resolve17(project, declaration.source);
24909
25343
  if (!inside(project, source) || inside(generatedRoot, source))
24910
25344
  throw new Error("Invalid migration source.");
24911
25345
  const bytes = await readBoundedOwned(project, source, 1048576);
@@ -24956,27 +25390,27 @@ async function buildDeliveryProject(options, delivery) {
24956
25390
  const settings = parseDeliveryOptions(delivery);
24957
25391
  if (typeof Bun === "undefined")
24958
25392
  throw new Error("Independent delivery builds require Bun.");
24959
- const configPath = ts16.findConfigFile(resolve17(options.rootDir), ts16.sys.fileExists);
25393
+ const configPath = ts16.findConfigFile(resolve18(options.rootDir), ts16.sys.fileExists);
24960
25394
  if (!configPath)
24961
25395
  throw new Error("Independent delivery builds require a project tsconfig.json.");
24962
25396
  const lexicalProject = dirname9(configPath);
24963
- const project = await realpath4(lexicalProject);
24964
- const sourceRoot = await realpath4(options.rootDir);
25397
+ const project = await realpath5(lexicalProject);
25398
+ const sourceRoot = await realpath5(options.rootDir);
24965
25399
  if (!inside(project, sourceRoot))
24966
25400
  throw new Error("Application sources must be inside the project.");
24967
- const requested = resolve17(options.outDir, "delivery");
25401
+ const requested = resolve18(options.outDir, "delivery");
24968
25402
  if (!inside(lexicalProject, requested))
24969
25403
  throw new Error("Output must be inside the application project.");
24970
- const buildRoot = resolve17(project, relative10(lexicalProject, requested));
24971
- const generatedRoot = resolve17(project, relative10(lexicalProject, options.outDir));
25404
+ const buildRoot = resolve18(project, relative11(lexicalProject, requested));
25405
+ const generatedRoot = resolve18(project, relative11(lexicalProject, options.outDir));
24972
25406
  if (inside(generatedRoot, sourceRoot))
24973
25407
  throw new Error("Output must not contain the application source root.");
24974
25408
  const configInputs = new Map;
24975
- const parsedConfig = ts16.getParsedCommandLineOfConfigFile(await realpath4(configPath), {}, {
25409
+ const parsedConfig = ts16.getParsedCommandLineOfConfigFile(await realpath5(configPath), {}, {
24976
25410
  ...ts16.sys,
24977
25411
  readFile(path) {
24978
25412
  const contents = readFileSync3(path, "utf8");
24979
- configInputs.set(resolve17(path), digest(contents));
25413
+ configInputs.set(resolve18(path), digest(contents));
24980
25414
  return contents;
24981
25415
  },
24982
25416
  onUnRecoverableConfigFileDiagnostic() {
@@ -25014,7 +25448,7 @@ async function buildDeliveryProject(options, delivery) {
25014
25448
  if (!target || (kind === "worker" ? target.kind !== "jobs" : target.kind === "jobs")) {
25015
25449
  throw new Error("Delivery host kind does not match its target.");
25016
25450
  }
25017
- const path = resolve17(sourceRoot, app.source);
25451
+ const path = resolve18(sourceRoot, app.source);
25018
25452
  if (inside(generatedRoot, path) || !/\.[cm]?ts$/.test(path))
25019
25453
  throw new Error("Hosts require application TypeScript source.");
25020
25454
  hosts.set(app.target, { path, kind, hash: digest(await readOwned(sourceRoot, path)) });
@@ -25025,7 +25459,7 @@ async function buildDeliveryProject(options, delivery) {
25025
25459
  continue;
25026
25460
  if (hosts.has(target.name))
25027
25461
  throw new Error("Duplicate delivery application host.");
25028
- const path = resolve17(sourceRoot, target.function.entrypoint);
25462
+ const path = resolve18(sourceRoot, target.function.entrypoint);
25029
25463
  if (inside(generatedRoot, path) || !/\.[cm]?ts$/.test(path)) {
25030
25464
  throw new Error("Function hosts require application TypeScript source.");
25031
25465
  }
@@ -25035,10 +25469,10 @@ async function buildDeliveryProject(options, delivery) {
25035
25469
  const migrations = await prepareDeliveryMigrations(project, generatedRoot, settings.build?.migrations);
25036
25470
  phase = "output-ownership";
25037
25471
  output = await reserveOutput(project, buildRoot);
25038
- const objectRoot = join10(output.path, "objects");
25472
+ const objectRoot = join11(output.path, "objects");
25039
25473
  await noLinks(output.path, objectRoot);
25040
25474
  await mkdir3(objectRoot, { recursive: true });
25041
- const pointer = join10(output.path, "delivery.manifest.json");
25475
+ const pointer = join11(output.path, "delivery.manifest.json");
25042
25476
  const previous = await exists(pointer) ? parseDeliveryBuildManifest(JSON.parse(new TextDecoder().decode(await readOwned(output.path, pointer)))) : undefined;
25043
25477
  const objects = [];
25044
25478
  const candidates = [];
@@ -25059,14 +25493,14 @@ async function buildDeliveryProject(options, delivery) {
25059
25493
  let directory = project;
25060
25494
  while (true) {
25061
25495
  for (const name of ["package.json", "bun.lock", "bun.lockb", "package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bunfig.toml", "tsconfig.json"]) {
25062
- const path = join10(directory, name);
25496
+ const path = join11(directory, name);
25063
25497
  if (await exists(path)) {
25064
- const bytes = await readFile7(path);
25498
+ const bytes = await readFile8(path);
25065
25499
  const before = snapshots.get(path);
25066
25500
  if (before !== undefined && before !== digest(bytes))
25067
25501
  throw new Error("Configuration changed during analysis; retry.");
25068
25502
  snapshots.set(path, digest(bytes));
25069
- configuration[relative10(project, path).split(sep10).join("/")] = digest(bytes);
25503
+ configuration[relative11(project, path).split(sep11).join("/")] = digest(bytes);
25070
25504
  }
25071
25505
  }
25072
25506
  const parent = dirname9(directory);
@@ -25078,13 +25512,13 @@ async function buildDeliveryProject(options, delivery) {
25078
25512
  producer,
25079
25513
  bun: Bun.version,
25080
25514
  revision: Bun.revision,
25081
- compiler: digest(canonical2(Object.fromEntries([...await sourceInventory(import.meta.dir, join10(import.meta.dir, "node_modules"))].map(([path, hash]) => [relative10(import.meta.dir, path), hash]))))
25515
+ compiler: digest(canonical2(Object.fromEntries([...await sourceInventory(import.meta.dir, join11(import.meta.dir, "node_modules"))].map(([path, hash]) => [relative11(import.meta.dir, path), hash]))))
25082
25516
  };
25083
25517
  for (const target of planned.plan.targets) {
25084
25518
  phase = `target:${target.name}`;
25085
- const stage = await mkdtemp(join10(objectRoot, ".build-"));
25519
+ const stage = await mkdtemp(join11(objectRoot, ".build-"));
25086
25520
  temporary.push(stage);
25087
- const generatedDirectory = join10(objectRoot, "0".repeat(64), "generated");
25521
+ const generatedDirectory = join11(objectRoot, "0".repeat(64), "generated");
25088
25522
  const host = hosts.get(target.name);
25089
25523
  const standaloneFunction = target.kind === "function" && target.modules.length === 0;
25090
25524
  const rendered = standaloneFunction ? undefined : renderDeliveryTarget(checked.graph, target, {
@@ -25098,7 +25532,7 @@ async function buildDeliveryProject(options, delivery) {
25098
25532
  if (standaloneFunction) {
25099
25533
  if (target.function === undefined)
25100
25534
  throw new Error("Function target requires an entrypoint descriptor.");
25101
- const entrypointPath = resolve17(sourceRoot, target.function.entrypoint);
25535
+ const entrypointPath = resolve18(sourceRoot, target.function.entrypoint);
25102
25536
  if (inside(generatedRoot, entrypointPath) || !/\.[cm]?ts$/.test(entrypointPath)) {
25103
25537
  throw new Error("Standalone Function entrypoints require application TypeScript source.");
25104
25538
  }
@@ -25126,7 +25560,7 @@ async function buildDeliveryProject(options, delivery) {
25126
25560
  const program = ts16.createProgram({
25127
25561
  rootNames: [
25128
25562
  ...parsedConfig.fileNames.filter((path) => !inside(generatedRoot, path)),
25129
- ...Object.keys(generated).map((name) => join10(stage, "generated", name))
25563
+ ...Object.keys(generated).map((name) => join11(stage, "generated", name))
25130
25564
  ],
25131
25565
  options: { ...parsedConfig.options, rootDir: project },
25132
25566
  ...parsedConfig.projectReferences ? { projectReferences: parsedConfig.projectReferences } : {}
@@ -25176,7 +25610,7 @@ async function buildDeliveryProject(options, delivery) {
25176
25610
  }));
25177
25611
  const assetInputs = {};
25178
25612
  for (const asset of assets.filter((asset) => asset.target === target.name)) {
25179
- const path = resolve17(sourceRoot, asset.source);
25613
+ const path = resolve18(sourceRoot, asset.source);
25180
25614
  const bytes = await readOwned(sourceRoot, path);
25181
25615
  const hash = digest(bytes);
25182
25616
  const previousHash = snapshots.get(path);
@@ -25199,7 +25633,7 @@ async function buildDeliveryProject(options, delivery) {
25199
25633
  workerApplication: workerApplications.find((app) => app.target === target.name),
25200
25634
  assets: assets.filter((asset) => asset.target === target.name)
25201
25635
  },
25202
- inputs: Object.fromEntries([...bundled.inputs].map(([path, hash]) => [relative10(project, path).split(sep10).join("/"), hash])),
25636
+ inputs: Object.fromEntries([...bundled.inputs].map(([path, hash]) => [relative11(project, path).split(sep11).join("/"), hash])),
25203
25637
  assets: assetInputs,
25204
25638
  ...migrations.entries.length ? { migrations: migrations.entries } : {}
25205
25639
  }));
@@ -25220,7 +25654,7 @@ async function buildDeliveryProject(options, delivery) {
25220
25654
  if (canonical2(Object.fromEntries(sources)) !== canonical2(Object.fromEntries(await sourceInventory(sourceRoot, generatedRoot))))
25221
25655
  throw new Error("Application sources changed during analysis; retry.");
25222
25656
  for (const [path, hash] of snapshots) {
25223
- if (digest(await readFile7(path)) !== hash)
25657
+ if (digest(await readFile8(path)) !== hash)
25224
25658
  throw new Error("Build inputs changed before publication; retry.");
25225
25659
  }
25226
25660
  const manifest = parseDeliveryBuildManifest({
@@ -25239,7 +25673,7 @@ async function buildDeliveryProject(options, delivery) {
25239
25673
  });
25240
25674
  phase = "artifact-integrity";
25241
25675
  for (const candidate of candidates) {
25242
- const destination = join10(objectRoot, candidate.object.objectId);
25676
+ const destination = join11(objectRoot, candidate.object.objectId);
25243
25677
  await noLinks(output.path, destination);
25244
25678
  if (await exists(destination) && canonical2(await artifactInventory(destination)) !== canonical2(candidate.object.files)) {
25245
25679
  throw new Error("An immutable artifact was modified. Refusing to overwrite it.");
@@ -25247,10 +25681,10 @@ async function buildDeliveryProject(options, delivery) {
25247
25681
  }
25248
25682
  const written = [];
25249
25683
  for (const candidate of candidates) {
25250
- const destination = join10(objectRoot, candidate.object.objectId);
25684
+ const destination = join11(objectRoot, candidate.object.objectId);
25251
25685
  if (!await exists(destination)) {
25252
25686
  await rename4(candidate.path, destination);
25253
- written.push(...candidate.object.files.map((file) => join10(destination, file.path)));
25687
+ written.push(...candidate.object.files.map((file) => join11(destination, file.path)));
25254
25688
  }
25255
25689
  }
25256
25690
  phase = "manifest-publication";
@@ -25290,14 +25724,14 @@ async function buildDeliveryProject(options, delivery) {
25290
25724
  }
25291
25725
 
25292
25726
  // src/migrations.ts
25293
- import { rename as rename5, readFile as readFile9, writeFile as writeFile4, rm as rm3 } from "node:fs/promises";
25294
- import { relative as relative11, resolve as resolve19 } from "node:path";
25727
+ import { rename as rename5, readFile as readFile10, writeFile as writeFile5, rm as rm3 } from "node:fs/promises";
25728
+ import { relative as relative12, resolve as resolve20 } from "node:path";
25295
25729
  import * as ts17 from "@typescript/typescript6";
25296
25730
 
25297
25731
  // src/migration-policy.ts
25298
- import { readFile as readFile8 } from "node:fs/promises";
25732
+ import { readFile as readFile9 } from "node:fs/promises";
25299
25733
  import { readFileSync as readFileSync4 } from "node:fs";
25300
- import { resolve as resolve18 } from "node:path";
25734
+ import { resolve as resolve19 } from "node:path";
25301
25735
 
25302
25736
  // src/migration-app-version.ts
25303
25737
  var MIGRATION_APP_VERSION = "0.35.0";
@@ -25330,7 +25764,7 @@ async function checkMigrationDependencies(rootDir) {
25330
25764
  const problems = [];
25331
25765
  for (const [name, expected] of Object.entries(migrationDependencies())) {
25332
25766
  try {
25333
- const manifest = JSON.parse(await readFile8(resolve18(rootDir, "node_modules", name, "package.json"), "utf8"));
25767
+ const manifest = JSON.parse(await readFile9(resolve19(rootDir, "node_modules", name, "package.json"), "utf8"));
25334
25768
  if (!manifest || typeof manifest !== "object" || !("name" in manifest) || manifest.name !== name || !("version" in manifest) || manifest.version !== expected) {
25335
25769
  problems.push(`${name}: requires tested installed version ${expected}`);
25336
25770
  }
@@ -25435,7 +25869,7 @@ function resolveStaticObjectLiteral2(input, checker, seen = new Set) {
25435
25869
  return;
25436
25870
  }
25437
25871
  function displayFile(rootDir, fileName) {
25438
- const path = relative11(rootDir, fileName);
25872
+ const path = relative12(rootDir, fileName);
25439
25873
  return path && !path.startsWith("..") ? path : fileName;
25440
25874
  }
25441
25875
  function createMigrationProgram(fileNames, sourceOverrides, rootDir) {
@@ -25445,10 +25879,10 @@ function createMigrationProgram(fileNames, sourceOverrides, rootDir) {
25445
25879
  const fileExists = host.fileExists.bind(host);
25446
25880
  const readFile = host.readFile.bind(host);
25447
25881
  const currentDirectory = host.getCurrentDirectory.bind(host);
25448
- host.fileExists = (fileName) => sourceOverrides.has(resolve19(fileName)) || fileExists(fileName);
25449
- host.readFile = (fileName) => sourceOverrides.get(resolve19(fileName)) ?? readFile(fileName);
25882
+ host.fileExists = (fileName) => sourceOverrides.has(resolve20(fileName)) || fileExists(fileName);
25883
+ host.readFile = (fileName) => sourceOverrides.get(resolve20(fileName)) ?? readFile(fileName);
25450
25884
  host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
25451
- const source = sourceOverrides.get(resolve19(fileName));
25885
+ const source = sourceOverrides.get(resolve20(fileName));
25452
25886
  return source === undefined ? getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) : ts17.createSourceFile(fileName, source, languageVersion, true);
25453
25887
  };
25454
25888
  host.getCurrentDirectory = () => rootDir ?? currentDirectory();
@@ -25474,7 +25908,7 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
25474
25908
  issues.push(issue);
25475
25909
  };
25476
25910
  for (const sourceFile of sourceFiles) {
25477
- const sourcePath = resolve19(sourceFile.fileName);
25911
+ const sourcePath = resolve20(sourceFile.fileName);
25478
25912
  if (!includedFiles.has(sourcePath))
25479
25913
  continue;
25480
25914
  const visit = (node) => {
@@ -25482,7 +25916,7 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
25482
25916
  const options = node.arguments[1];
25483
25917
  const object = options && resolveStaticObjectLiteral2(options, checker);
25484
25918
  if (object) {
25485
- const objectPath = resolve19(object.getSourceFile().fileName);
25919
+ const objectPath = resolve20(object.getSourceFile().fileName);
25486
25920
  const properties = routeResponseProperties(object);
25487
25921
  if (properties.response) {
25488
25922
  if (!includedFiles.has(objectPath)) {
@@ -25525,13 +25959,13 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
25525
25959
  line: lineOf2(sourceFile, response)
25526
25960
  });
25527
25961
  } else {
25528
- const replacements = replacementsByFile.get(resolve19(sourceFile.fileName)) ?? [];
25962
+ const replacements = replacementsByFile.get(resolve20(sourceFile.fileName)) ?? [];
25529
25963
  replacements.push({
25530
25964
  start: response.getStart(sourceFile),
25531
25965
  end: response.getEnd(),
25532
25966
  text: `responses: { 200: ${response.initializer.getText(sourceFile)} }`
25533
25967
  });
25534
- replacementsByFile.set(resolve19(sourceFile.fileName), replacements);
25968
+ replacementsByFile.set(resolve20(sourceFile.fileName), replacements);
25535
25969
  }
25536
25970
  }
25537
25971
  return { replacementsByFile, issues };
@@ -25544,7 +25978,7 @@ function applyReplacements(source, replacements) {
25544
25978
  return content;
25545
25979
  }
25546
25980
  function migrateRouteResponse(source, fileName) {
25547
- const absoluteFile = resolve19(fileName);
25981
+ const absoluteFile = resolve20(fileName);
25548
25982
  const sourceOverrides = new Map([[absoluteFile, source]]);
25549
25983
  const program = createMigrationProgram([absoluteFile], sourceOverrides);
25550
25984
  const sourceFile = program.getSourceFile(absoluteFile);
@@ -25560,7 +25994,7 @@ function migrateRouteResponse(source, fileName) {
25560
25994
  }]
25561
25995
  };
25562
25996
  }
25563
- const plan = planRouteResponseMigration([sourceFile], program.getTypeChecker(), resolve19("."), new Set([absoluteFile]));
25997
+ const plan = planRouteResponseMigration([sourceFile], program.getTypeChecker(), resolve20("."), new Set([absoluteFile]));
25564
25998
  const replacements = plan.replacementsByFile.get(absoluteFile) ?? [];
25565
25999
  return {
25566
26000
  changed: replacements.length > 0,
@@ -25570,7 +26004,7 @@ function migrateRouteResponse(source, fileName) {
25570
26004
  };
25571
26005
  }
25572
26006
  function migrateRouteResponseProject(files, rootDir, sourceByPath) {
25573
- const absoluteFiles = files.map((file) => resolve19(file));
26007
+ const absoluteFiles = files.map((file) => resolve20(file));
25574
26008
  const program = createMigrationProgram(absoluteFiles, sourceByPath, rootDir);
25575
26009
  const sourceFiles = absoluteFiles.map((file) => program.getSourceFile(file)).filter((file) => file !== undefined);
25576
26010
  const plan = planRouteResponseMigration(sourceFiles, program.getTypeChecker(), rootDir, new Set(absoluteFiles));
@@ -25583,11 +26017,11 @@ function migrateRouteResponseProject(files, rootDir, sourceByPath) {
25583
26017
  changed: replacements.length > 0,
25584
26018
  content: applyReplacements(source, replacements),
25585
26019
  replacements: replacements.length,
25586
- issues: plan.issues.filter((issue) => resolve19(rootDir, issue.file) === file)
26020
+ issues: plan.issues.filter((issue) => resolve20(rootDir, issue.file) === file)
25587
26021
  });
25588
26022
  }
25589
26023
  for (const issue of plan.issues) {
25590
- const path = resolve19(rootDir, issue.file);
26024
+ const path = resolve20(rootDir, issue.file);
25591
26025
  if (!results.has(path) && sourceByPath.has(path)) {
25592
26026
  results.set(path, {
25593
26027
  changed: false,
@@ -25618,14 +26052,14 @@ var SUPACLOUD_MIGRATIONS = [
25618
26052
  async function writeAtomically(path, content) {
25619
26053
  const temporary = `${path}.supacloud-migrate-${process.pid}-${crypto.randomUUID()}`;
25620
26054
  try {
25621
- await writeFile4(temporary, content, "utf8");
26055
+ await writeFile5(temporary, content, "utf8");
25622
26056
  await rename5(temporary, path);
25623
26057
  } finally {
25624
26058
  await rm3(temporary, { force: true });
25625
26059
  }
25626
26060
  }
25627
26061
  async function migrateProject(options) {
25628
- const rootDir = resolve19(options.rootDir);
26062
+ const rootDir = resolve20(options.rootDir);
25629
26063
  let migrations = SUPACLOUD_MIGRATIONS;
25630
26064
  const preflightIssues = [];
25631
26065
  if (options.fromVersion !== undefined || options.toVersion !== undefined) {
@@ -25681,7 +26115,7 @@ async function migrateProject(options) {
25681
26115
  }
25682
26116
  };
25683
26117
  for (const filePath of files) {
25684
- sourceByPath.set(resolve19(filePath), await readFile9(filePath, "utf8"));
26118
+ sourceByPath.set(resolve20(filePath), await readFile10(filePath, "utf8"));
25685
26119
  }
25686
26120
  const originalSources = new Map(sourceByPath);
25687
26121
  const writtenFiles = new Set;
@@ -25690,8 +26124,8 @@ async function migrateProject(options) {
25690
26124
  if (projectResults)
25691
26125
  appendIssues(projectResults.issues);
25692
26126
  for (const filePath of files) {
25693
- const absoluteFile = resolve19(filePath);
25694
- const file = relative11(rootDir, absoluteFile) || absoluteFile;
26127
+ const absoluteFile = resolve20(filePath);
26128
+ const file = relative12(rootDir, absoluteFile) || absoluteFile;
25695
26129
  const before = sourceByPath.get(absoluteFile);
25696
26130
  if (before === undefined)
25697
26131
  continue;
@@ -25716,7 +26150,7 @@ async function migrateProject(options) {
25716
26150
  const written = [];
25717
26151
  try {
25718
26152
  for (const [path, content] of pendingWrites) {
25719
- if (await readFile9(path, "utf8") !== originalSources.get(path)) {
26153
+ if (await readFile10(path, "utf8") !== originalSources.get(path)) {
25720
26154
  throw new Error(`Source changed during migration: ${path}`);
25721
26155
  }
25722
26156
  await writeAtomically(path, content);
@@ -25728,7 +26162,7 @@ async function migrateProject(options) {
25728
26162
  for (const path of written.reverse()) {
25729
26163
  try {
25730
26164
  const original = originalSources.get(path);
25731
- if (original === undefined || await readFile9(path, "utf8") !== pendingWrites.get(path)) {
26165
+ if (original === undefined || await readFile10(path, "utf8") !== pendingWrites.get(path)) {
25732
26166
  throw new Error("File changed after migration; refusing to overwrite concurrent edits");
25733
26167
  }
25734
26168
  await writeAtomically(path, original);
@@ -25739,7 +26173,7 @@ async function migrateProject(options) {
25739
26173
  }
25740
26174
  }
25741
26175
  }
25742
- const changedFiles = options.write && issues.length > 0 ? [...writtenFiles].map((file) => relative11(rootDir, file)) : [...new Set(results.filter((result) => result.changed && result.issues.length === 0).map((result) => result.file))];
26176
+ const changedFiles = options.write && issues.length > 0 ? [...writtenFiles].map((file) => relative12(rootDir, file)) : [...new Set(results.filter((result) => result.changed && result.issues.length === 0).map((result) => result.file))];
25743
26177
  return {
25744
26178
  write: options.write === true,
25745
26179
  migrations: migrations.map(({ id, from, to, description }) => ({ id, from, to, description })),
@@ -25750,14 +26184,14 @@ async function migrateProject(options) {
25750
26184
  }
25751
26185
 
25752
26186
  // src/migration-assess.ts
25753
- import { createHash as createHash11 } from "node:crypto";
25754
- import { readFile as readFile11 } from "node:fs/promises";
25755
- import { join as join11, resolve as resolve21 } from "node:path";
26187
+ import { createHash as createHash12 } from "node:crypto";
26188
+ import { readFile as readFile12 } from "node:fs/promises";
26189
+ import { join as join12, resolve as resolve22 } from "node:path";
25756
26190
 
25757
26191
  // src/openapi-tools.ts
25758
- import { mkdir as mkdir4, readFile as readFile10, rename as rename6, unlink as unlink3, writeFile as writeFile5 } from "node:fs/promises";
25759
- import { dirname as dirname10, resolve as resolve20 } from "node:path";
25760
- import { pathToFileURL as pathToFileURL2 } from "node:url";
26192
+ import { mkdir as mkdir4, readFile as readFile11, rename as rename6, unlink as unlink3, writeFile as writeFile6 } from "node:fs/promises";
26193
+ import { dirname as dirname10, resolve as resolve21 } from "node:path";
26194
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
25761
26195
 
25762
26196
  class OpenApiDocumentError extends Error {
25763
26197
  code = "OPENAPI_DOCUMENT_INVALID";
@@ -26147,7 +26581,7 @@ function serializeOpenApiJson(document, space = 2) {
26147
26581
  }
26148
26582
  async function readOpenApiJson(path) {
26149
26583
  try {
26150
- const value = JSON.parse(await readFile10(resolve20(path), "utf8"));
26584
+ const value = JSON.parse(await readFile11(resolve21(path), "utf8"));
26151
26585
  return parseOpenApiDocument(value);
26152
26586
  } catch (error) {
26153
26587
  if (error instanceof OpenApiDocumentError)
@@ -26156,16 +26590,16 @@ async function readOpenApiJson(path) {
26156
26590
  }
26157
26591
  }
26158
26592
  async function writeOpenApiJson(document, outputPath, space = 2) {
26159
- const path = resolve20(outputPath);
26593
+ const path = resolve21(outputPath);
26160
26594
  const content = serializeOpenApiJson(document, space);
26161
26595
  await mkdir4(dirname10(path), { recursive: true });
26162
26596
  try {
26163
- if (await readFile10(path, "utf8") === content)
26597
+ if (await readFile11(path, "utf8") === content)
26164
26598
  return { path, written: false };
26165
26599
  } catch {}
26166
26600
  const temporaryPath = `${path}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
26167
26601
  try {
26168
- await writeFile5(temporaryPath, content, "utf8");
26602
+ await writeFile6(temporaryPath, content, "utf8");
26169
26603
  await rename6(temporaryPath, path);
26170
26604
  } catch (error) {
26171
26605
  await unlink3(temporaryPath).catch(() => {
@@ -26177,7 +26611,7 @@ async function writeOpenApiJson(document, outputPath, space = 2) {
26177
26611
  }
26178
26612
  async function loadGeneratedOpenApiDocument(modulePath) {
26179
26613
  try {
26180
- const moduleUrl = pathToFileURL2(resolve20(modulePath));
26614
+ const moduleUrl = pathToFileURL3(resolve21(modulePath));
26181
26615
  moduleUrl.searchParams.set("supacloud-openapi-export", "1");
26182
26616
  const loaded = await import(moduleUrl.href);
26183
26617
  if (!isRecord(loaded))
@@ -26447,17 +26881,17 @@ function validRpcInventory(value, commandInventory) {
26447
26881
  });
26448
26882
  }
26449
26883
  async function sha2566(path) {
26450
- return createHash11("sha256").update(await readFile11(path)).digest("hex");
26884
+ return createHash12("sha256").update(await readFile12(path)).digest("hex");
26451
26885
  }
26452
26886
  function overallStatus(findings) {
26453
26887
  return findings.reduce((current, finding) => STATUS_PRIORITY[finding.status] > STATUS_PRIORITY[current] ? finding.status : current, "compatible");
26454
26888
  }
26455
26889
  async function assessMigration(options) {
26456
- const projectDir = resolve21(options.projectDir);
26890
+ const projectDir = resolve22(options.projectDir);
26457
26891
  const compile = {
26458
26892
  ...options.compile,
26459
- rootDir: resolve21(options.compile.rootDir),
26460
- outDir: resolve21(options.compile.outDir)
26893
+ rootDir: resolve22(options.compile.rootDir),
26894
+ outDir: resolve22(options.compile.outDir)
26461
26895
  };
26462
26896
  const findings = [];
26463
26897
  const dependencyProblems = await checkMigrationDependencies(projectDir);
@@ -26508,13 +26942,13 @@ async function assessMigration(options) {
26508
26942
  remediation: "Verify the project source, configuration and installed dependencies, then reassess."
26509
26943
  });
26510
26944
  }
26511
- const contractsManifestPath = join11(compile.outDir, "contracts.manifest.json");
26945
+ const contractsManifestPath = join12(compile.outDir, "contracts.manifest.json");
26512
26946
  let contractsManifest = {
26513
26947
  path: contractsManifestPath,
26514
26948
  present: false
26515
26949
  };
26516
26950
  try {
26517
- const parsed = JSON.parse(await readFile11(contractsManifestPath, "utf8"));
26951
+ const parsed = JSON.parse(await readFile12(contractsManifestPath, "utf8"));
26518
26952
  if (!isRecord2(parsed) || parsed["version"] !== 1 || !validJobInventory(parsed["jobs"]) || !validCommandInventory(parsed["commands"]) || !Array.isArray(parsed["routes"]) || !validRpcInventory(parsed["rpc"], parsed["commands"]) || !validFeatureInventory(parsed["features"], parsed["jobs"], parsed["commands"], parsed["routes"], parsed["rpc"])) {
26519
26953
  throw new Error("invalid manifest");
26520
26954
  }
@@ -26545,8 +26979,8 @@ async function assessMigration(options) {
26545
26979
  }
26546
26980
  let openApi;
26547
26981
  if (options.baselineOpenApiPath && options.currentOpenApiPath) {
26548
- const baselinePath = resolve21(projectDir, options.baselineOpenApiPath);
26549
- const currentPath = resolve21(projectDir, options.currentOpenApiPath);
26982
+ const baselinePath = resolve22(projectDir, options.baselineOpenApiPath);
26983
+ const currentPath = resolve22(projectDir, options.currentOpenApiPath);
26550
26984
  try {
26551
26985
  const diff = diffOpenApiDocuments(await readOpenApiJson(baselinePath), await readOpenApiJson(currentPath));
26552
26986
  openApi = {
@@ -26628,8 +27062,8 @@ function formatMigrationAssessment(result) {
26628
27062
 
26629
27063
  // src/graphql-governance.ts
26630
27064
  init_graphql_schema_hashes();
26631
- import { readFile as readFile12 } from "node:fs/promises";
26632
- import { resolve as resolve22 } from "node:path";
27065
+ import { readFile as readFile13 } from "node:fs/promises";
27066
+ import { resolve as resolve23 } from "node:path";
26633
27067
  import {
26634
27068
  buildClientSchema as buildClientSchema2,
26635
27069
  buildSchema as buildSchema2,
@@ -26649,8 +27083,8 @@ function schemaFromSource(source, path = "schema.graphql") {
26649
27083
  return buildSchema2(source);
26650
27084
  }
26651
27085
  async function readGraphqlSchema(path) {
26652
- const absolute = resolve22(path);
26653
- const source = await readFile12(absolute, "utf8");
27086
+ const absolute = resolve23(path);
27087
+ const source = await readFile13(absolute, "utf8");
26654
27088
  const hashes = graphqlSchemaHashes(source);
26655
27089
  return { path: absolute, source, schema: schemaFromSource(source, absolute), ...hashes };
26656
27090
  }
@@ -26911,6 +27345,7 @@ Usage:
26911
27345
  supacloud-compiler graph [rootDir] [options]
26912
27346
  supacloud-compiler explain <name> [rootDir] [options]
26913
27347
  supacloud-compiler context <name> [rootDir] [options]
27348
+ supacloud-compiler preview-fix --production <dir> --preview <dir> --preview-id <uuid> --project-ref <ref> --application-id <id> --environment-id <id> --property transaction|idempotency --value required|none [--json]
26914
27349
  supacloud-compiler dev-context [rootDir] [options]
26915
27350
  supacloud-compiler environment-bindings [rootDir] [options]
26916
27351
  supacloud-compiler release-evidence --delivery-manifest <file> --delivery-target <name> [--json]
@@ -26936,6 +27371,7 @@ Commands:
26936
27371
  graph Print the discovered application graph
26937
27372
  explain Explain a module, provider, or external token
26938
27373
  context Extract an AI-sized module context pack
27374
+ preview-fix Edit, compile, invoke, and record a timeline inside one isolated preview. Does not deploy or write production.
26939
27375
  dev-context Print the read-only application development context for tooling/console/MCP consumers
26940
27376
  environment-bindings Resolve static per-environment resource bindings without credentials
26941
27377
  release-evidence Summarize one immutable target without loading project configuration
@@ -27009,11 +27445,11 @@ async function runGraphqlGovernanceCommand(args) {
27009
27445
  if (!schemaPath || documentPaths.length === 0)
27010
27446
  throw new Error("graphql compatibility requires --schema and at least one --documents");
27011
27447
  const schema = await readGraphqlSchema(schemaPath);
27012
- const documents = await Promise.all(documentPaths.map(async (path) => ({ path, source: await readFile15(resolve26(path), "utf8") })));
27448
+ const documents = await Promise.all(documentPaths.map(async (path) => ({ path, source: await readFile16(resolve27(path), "utf8") })));
27013
27449
  let policy = {};
27014
27450
  const policyPath = one("--policy");
27015
27451
  if (policyPath)
27016
- policy = JSON.parse(await readFile15(resolve26(policyPath), "utf8"));
27452
+ policy = JSON.parse(await readFile16(resolve27(policyPath), "utf8"));
27017
27453
  const report = checkGraphqlCompatibility(schema.schema, documents, policy);
27018
27454
  const result = {
27019
27455
  ok: report.ok,
@@ -27049,7 +27485,7 @@ async function runGraphqlGovernanceCommand(args) {
27049
27485
  throw new Error("--role must use name=schema");
27050
27486
  const role = value.slice(0, separator);
27051
27487
  const path = value.slice(separator + 1);
27052
- return { role, path, source: await readFile15(resolve26(path), "utf8") };
27488
+ return { role, path, source: await readFile16(resolve27(path), "utf8") };
27053
27489
  }));
27054
27490
  const result = createRoleSnapshotReport(roles);
27055
27491
  console.log(JSON.stringify(result, null, 2));
@@ -27068,6 +27504,10 @@ async function run() {
27068
27504
  const command = args[0];
27069
27505
  if (await runGraphqlGovernanceCommand(args))
27070
27506
  return;
27507
+ if (command === "preview-fix") {
27508
+ await runPreviewFixCommand(args.slice(1));
27509
+ return;
27510
+ }
27071
27511
  if (command === "release-evidence") {
27072
27512
  await Promise.resolve().then(() => init_release_evidence_cli());
27073
27513
  await runReleaseEvidenceCommand(args.slice(1));
@@ -27319,7 +27759,7 @@ async function run() {
27319
27759
  throw new Error("Build context requires a manifest, target, subject, events, request ID and --json");
27320
27760
  }
27321
27761
  try {
27322
- const pack = await createDeliveryExecutionContextPack(contextManifest, contextTarget, query, await readExecutionMetadata(resolve26(executionEventsPath)), executionRequestId);
27762
+ const pack = await createDeliveryExecutionContextPack(contextManifest, contextTarget, query, await readExecutionMetadata(resolve27(executionEventsPath)), executionRequestId);
27323
27763
  console.log(JSON.stringify(pack, null, 2));
27324
27764
  } catch (error) {
27325
27765
  console.log(JSON.stringify({
@@ -27338,7 +27778,7 @@ async function run() {
27338
27778
  const currentPath = openApiDiffPaths[1];
27339
27779
  if (!basePath || !currentPath)
27340
27780
  throw new Error("openapi-diff requires two JSON file paths");
27341
- const result = diffOpenApiDocuments(await readOpenApiJson(resolve26(process.cwd(), basePath)), await readOpenApiJson(resolve26(process.cwd(), currentPath)));
27781
+ const result = diffOpenApiDocuments(await readOpenApiJson(resolve27(process.cwd(), basePath)), await readOpenApiJson(resolve27(process.cwd(), currentPath)));
27342
27782
  console.log(json ? JSON.stringify(result, null, 2) : formatOpenApiDiff(result));
27343
27783
  if (!result.ok)
27344
27784
  process.exitCode = 1;
@@ -27353,8 +27793,8 @@ async function run() {
27353
27793
  if (!modulePath || !outputPath)
27354
27794
  throw new Error("openapi-export requires an OpenAPI module and output path");
27355
27795
  const result = await exportGeneratedOpenApiJson({
27356
- modulePath: resolve26(process.cwd(), modulePath),
27357
- outputPath: resolve26(process.cwd(), outputPath),
27796
+ modulePath: resolve27(process.cwd(), modulePath),
27797
+ outputPath: resolve27(process.cwd(), outputPath),
27358
27798
  ...openApiExportSpace === undefined ? {} : { space: openApiExportSpace }
27359
27799
  });
27360
27800
  console.log(json ? JSON.stringify({ ok: true, ...result }, null, 2) : result.written ? `OpenAPI JSON written: ${result.path}` : `OpenAPI JSON matches: ${result.path}`);
@@ -27362,7 +27802,7 @@ async function run() {
27362
27802
  }
27363
27803
  if (command === "migrate") {
27364
27804
  const result = await migrateProject({
27365
- rootDir: rootDir ? resolve26(process.cwd(), rootDir) : process.cwd(),
27805
+ rootDir: rootDir ? resolve27(process.cwd(), rootDir) : process.cwd(),
27366
27806
  write: !dryRun,
27367
27807
  ...fromVersion === undefined ? {} : { fromVersion },
27368
27808
  ...toVersion === undefined ? {} : { toVersion }
@@ -27400,8 +27840,8 @@ async function run() {
27400
27840
  if (checkSchema && command !== "graphql-schema")
27401
27841
  throw new Error("--check is only supported by graphql-schema");
27402
27842
  const defaults = resolveSupacloudConfig(loadedConfig, process.cwd());
27403
- const resolvedRoot = rootDir ? resolve26(process.cwd(), rootDir) : defaults.rootDir;
27404
- const resolvedOut = outDir ? resolve26(process.cwd(), outDir) : defaults.outDir;
27843
+ const resolvedRoot = rootDir ? resolve27(process.cwd(), rootDir) : defaults.rootDir;
27844
+ const resolvedOut = outDir ? resolve27(process.cwd(), outDir) : defaults.outDir;
27405
27845
  const configured = compileOptionsFromConfig({
27406
27846
  ...loadedConfig,
27407
27847
  root: resolvedRoot,
@@ -27420,7 +27860,7 @@ async function run() {
27420
27860
  let delivery = loadedConfig.delivery;
27421
27861
  if (deliveryPath !== undefined) {
27422
27862
  try {
27423
- delivery = JSON.parse(await readFile15(resolve26(process.cwd(), deliveryPath), "utf8"));
27863
+ delivery = JSON.parse(await readFile16(resolve27(process.cwd(), deliveryPath), "utf8"));
27424
27864
  } catch {
27425
27865
  throw new DeliveryConfigurationError;
27426
27866
  }
@@ -27478,7 +27918,7 @@ ${item.suggestion ?? ""}`).join(`
27478
27918
  } else if (command === "fix") {
27479
27919
  if (!query)
27480
27920
  throw new Error("fix requires a JSON file containing one DiagnosticFix");
27481
- const input = JSON.parse(await readFile15(resolve26(process.cwd(), query), "utf8"));
27921
+ const input = JSON.parse(await readFile16(resolve27(process.cwd(), query), "utf8"));
27482
27922
  const envelope = input && typeof input === "object" && "fix" in input;
27483
27923
  if (envelope && (typeof input.expectedSourceHash !== "string" || !/^[a-f0-9]{64}$/.test(input.expectedSourceHash))) {
27484
27924
  throw new Error("Editor fix requires the source hash from its validated preview");
@@ -27619,7 +28059,7 @@ Source change detected; compiling...`);
27619
28059
  process.exitCode = 1;
27620
28060
  return;
27621
28061
  }
27622
- const file = resolve26(rootDir ? resolve26(process.cwd(), rootDir) : process.cwd(), bindingsFile ?? "supacloud.environments.json");
28062
+ const file = resolve27(rootDir ? resolve27(process.cwd(), rootDir) : process.cwd(), bindingsFile ?? "supacloud.environments.json");
27623
28063
  try {
27624
28064
  const document = await readEnvironmentBindingsFile(file);
27625
28065
  const graph = await analyzeProject(resolvedRoot);
@@ -27654,7 +28094,7 @@ Source change detected; compiling...`);
27654
28094
  try {
27655
28095
  const result = await checkProject(compileDefaults);
27656
28096
  if (executionEventsPath && executionRequestId) {
27657
- const pack = createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, query, await readExecutionMetadata(resolve26(process.cwd(), executionEventsPath)), executionRequestId);
28097
+ const pack = createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, query, await readExecutionMetadata(resolve27(process.cwd(), executionEventsPath)), executionRequestId);
27658
28098
  console.log(JSON.stringify(pack, null, 2));
27659
28099
  return;
27660
28100
  }