hekireki 0.40.0 → 0.41.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.
Files changed (82) hide show
  1. package/dist/bin/activerecord.js +1 -1
  2. package/dist/bin/ajv.js +1 -1
  3. package/dist/bin/arktype.js +1 -1
  4. package/dist/bin/atlas.js +1 -1
  5. package/dist/bin/django.js +1 -1
  6. package/dist/bin/drizzle.js +1 -1
  7. package/dist/bin/ecto.js +1 -1
  8. package/dist/bin/efcore.js +1 -1
  9. package/dist/bin/effect.js +1 -1
  10. package/dist/bin/eloquent.js +1 -1
  11. package/dist/bin/er.js +1 -1
  12. package/dist/bin/exposed.js +1 -1
  13. package/dist/bin/gorm.js +1 -1
  14. package/dist/bin/hekireki.js +6 -7
  15. package/dist/bin/kysely.js +1 -1
  16. package/dist/bin/openapi.js +1 -1
  17. package/dist/bin/pydantic.js +1 -1
  18. package/dist/bin/sea-orm.js +1 -1
  19. package/dist/bin/seed.js +1 -1
  20. package/dist/bin/sqlalchemy.js +1 -1
  21. package/dist/bin/typebox.js +1 -1
  22. package/dist/bin/valibot.js +1 -1
  23. package/dist/bin/zod.js +1 -1
  24. package/dist/{bin-CVNnCHYf.js → bin-T1le3lMh.js} +80 -49
  25. package/dist/{discover-BJMo8i2-.js → discover-BaDQsKnF.js} +1 -1
  26. package/dist/{migrate-BhCE-YSd.js → migrate-2xlj7ayX.js} +2 -2
  27. package/dist/{plan-D9axVHFD.js → plan-B8PRmVdV.js} +2 -2
  28. package/dist/{run-Be-2eG1y.js → run-BQlJs4wi.js} +3 -3
  29. package/dist/{sql-FGRCF9o4.js → sql-izRRI1Bi.js} +1 -1
  30. package/dist/{start-9gS-ABI-.js → start-C7m4KyUz.js} +234 -730
  31. package/dist/studio/assets/{chip-5pFaNmwL.js → chip-D4JuozFz.js} +1 -1
  32. package/dist/studio/assets/client-DTRYUhbF.js +2 -0
  33. package/dist/studio/assets/{code-block-B1wLRka8.js → code-block-B7oBDy4S.js} +1 -1
  34. package/dist/studio/assets/confirm-dialog-DgDjONHy.js +1 -0
  35. package/dist/studio/assets/{copy-DvJVuM56.js → copy-CO4Wewxa.js} +1 -1
  36. package/dist/studio/assets/{copy-button-D4zjbBc-.js → copy-button-DDzfUcsZ.js} +1 -1
  37. package/dist/studio/assets/{dist-DEp-MbCs.js → dist-gV8lABSq.js} +1 -1
  38. package/dist/studio/assets/{docs-Cg9xqNoX.js → docs-DyJ-qhu9.js} +1 -1
  39. package/dist/studio/assets/{enums._name-BhNYpcT7.js → enums._name-CcIWxnq0.js} +1 -1
  40. package/dist/studio/assets/field-icon-DwOxCe9v.js +55 -0
  41. package/dist/studio/assets/hooks-6J-1786l.js +2 -0
  42. package/dist/studio/assets/index-D2cpa83b.js +15 -0
  43. package/dist/studio/assets/index-Dn9oYAy5.css +2 -0
  44. package/dist/studio/assets/labels-BrdjOFB0.js +2 -0
  45. package/dist/studio/assets/{lazyRouteComponent-TkAX4iEA.js → lazyRouteComponent-CzElNsBd.js} +1 -1
  46. package/dist/studio/assets/lu-BwZ0uwaH.js +7 -0
  47. package/dist/studio/assets/marked-text-CRUtsVYt.js +3 -0
  48. package/dist/studio/assets/models._name-Drem1hqS.js +1 -0
  49. package/dist/studio/assets/{monaco-DFkSQFp9.js → monaco-CKCcdl6_.js} +1 -1
  50. package/dist/studio/assets/{monaco-BoT_UVCW.js → monaco-Doo5FK2W.js} +1 -1
  51. package/dist/studio/assets/{not-found-CTsERB3d.js → not-found-KT_nPOAU.js} +1 -1
  52. package/dist/studio/assets/{prisma-DZMNzXN7.js → prisma-4lQKwVn6.js} +1 -1
  53. package/dist/studio/assets/result-table-DY7sKJQq.js +1 -0
  54. package/dist/studio/assets/routes-D6hrrw5V.js +1 -0
  55. package/dist/studio/assets/{schema-gate-CXYSsT5T.js → schema-gate-Dq2l2Sh6.js} +1 -1
  56. package/dist/studio/assets/{schema-view-wADoyIFc.js → schema-view-CnitOLrD.js} +2 -2
  57. package/dist/studio/assets/sql-CjIkv--0.js +6 -0
  58. package/dist/studio/assets/table-BxRDQMeA.js +1 -0
  59. package/dist/studio/assets/tabs-BwlFa2ot.js +1 -0
  60. package/dist/studio/assets/useFormValidation-DifOycKN.js +1 -0
  61. package/dist/studio/assets/{useMatch-wXiBv0wx.js → useMatch-D2UWqcDy.js} +1 -1
  62. package/dist/studio/assets/useMultipleSelectionState-2b0OEWtf.js +1 -0
  63. package/dist/studio/index.html +10 -11
  64. package/package.json +12 -12
  65. package/dist/studio/assets/client-Cn44j_II.js +0 -2
  66. package/dist/studio/assets/confirm-dialog-C84-yLfM.js +0 -1
  67. package/dist/studio/assets/field-icon-j33Axyq4.js +0 -55
  68. package/dist/studio/assets/hooks-vFvEnsyJ.js +0 -2
  69. package/dist/studio/assets/index-6aoNJjln.css +0 -2
  70. package/dist/studio/assets/index-Cjy--gYX.js +0 -11
  71. package/dist/studio/assets/labels-Db1CHOpt.js +0 -2
  72. package/dist/studio/assets/lu-CUfSReIi.js +0 -7
  73. package/dist/studio/assets/marked-text-BNzjDVlk.js +0 -3
  74. package/dist/studio/assets/models._name-BgiyfSuj.js +0 -1
  75. package/dist/studio/assets/result-table-zFoiQlAu.js +0 -1
  76. package/dist/studio/assets/routes-Dpy0uL8H.js +0 -1
  77. package/dist/studio/assets/search-field-Dshrbbug.js +0 -5
  78. package/dist/studio/assets/sql-0uoTjX3O.js +0 -6
  79. package/dist/studio/assets/table-5cZklaSq.js +0 -1
  80. package/dist/studio/assets/tabs-B7UQa0vf.js +0 -1
  81. package/dist/studio/assets/useFormValidation-D0dsTzOi.js +0 -1
  82. package/dist/studio/assets/useMultipleSelectionState-CyThblbT.js +0 -1
@@ -1,10 +1,10 @@
1
1
  import { a as readBytes, c as removePath, i as makeDirectory, l as watch, n as fileStamp, o as readDirectory, r as isDirectory, s as readFile, t as exists, u as writeFile$1 } from "./file-BAVQ-zst.js";
2
- import { c as InvalidInputError, d as ServerListenError, f as UnknownFileError, g as PRISMA_FILE_URI, h as MIGRATIONS_POLL_MS, l as SchemaLoadError, m as FORBIDDEN_HOST_MESSAGE, n as ClientUnavailableError, o as FileWriteError, p as UnknownModelError, r as ContractViolationError, s as FormatError, t as ClientQueryError, u as SchemaParseError, v as STUDIO_HOSTNAME, x as readPrismaConfig } from "./bin/hekireki.js";
2
+ import { _ as STUDIO_HOSTNAME, a as FileWriteError, b as readPrismaConfig, c as SchemaLoadError, d as UnknownFileError, f as UnknownModelError, h as PRISMA_FILE_URI, l as SchemaParseError, m as MIGRATIONS_POLL_MS, n as ClientUnavailableError, o as FormatError, p as FORBIDDEN_HOST_MESSAGE, s as InvalidInputError, t as ClientQueryError, u as ServerListenError } from "./bin/hekireki.js";
3
3
  import { R as fmt, k as isLoopbackHostname } from "./prisma-model-DFq7AQgV.js";
4
4
  import { n as makeSchema, t as makeAnalysisSchema } from "./schema-CfxnFLAw.js";
5
- import { A as makeRow, B as toTsType, C as columnName, D as tableColumns, E as makeEnumReadValues, F as makeSqlParams, H as MigrateDatabaseError, I as makeClientQuery, L as splitStatements, M as makeGeneratedFields, N as makeClientTouched, O as tableName, P as makeClientResult, R as literalDataType, S as makeUpdateStatement, T as makeColumnValues, U as MigrateEngineError, V as MigrateConfigError, W as MigrationNotFoundError, _ as openSqliteCopy, a as makePlan, b as makeInsertStatement, c as checkOpened, d as DECISIONS_FILE, f as readDecisions, g as openShadowDatabase, h as openMysqlCopy, j as makeDocs, k as makeBindValue, m as connectDatabase, p as writeDecisions, u as introspectDatabase, v as makeCountStatement, w as keyFields, x as makeSelectStatement, y as makeDeleteStatement, z as sqliteAffinity } from "./plan-D9axVHFD.js";
6
- import { C as parseSchema, _ as readConfigUrl, c as stringLiteral, f as makePostgresSchema, h as withTypeScriptImports, i as formatSql, o as qualifiedName, s as quoteIdentifier, u as environmentVariable, w as readSchemaFiles$1 } from "./sql-FGRCF9o4.js";
7
- import { n as clientSource, r as discoverClient, t as ADAPTERS } from "./discover-BJMo8i2-.js";
5
+ import { A as makeRow, B as toTsType, C as columnName, D as tableColumns, E as makeEnumReadValues, F as makeSqlParams, H as MigrateDatabaseError, I as makeClientQuery, L as splitStatements, M as makeGeneratedFields, N as makeClientTouched, O as tableName, P as makeClientResult, R as literalDataType, S as makeUpdateStatement, T as makeColumnValues, U as MigrateEngineError, V as MigrateConfigError, W as MigrationNotFoundError, _ as openSqliteCopy, a as makePlan, b as makeInsertStatement, c as checkOpened, d as DECISIONS_FILE, f as readDecisions, g as openShadowDatabase, h as openMysqlCopy, j as makeDocs, k as makeBindValue, m as connectDatabase, p as writeDecisions, u as introspectDatabase, v as makeCountStatement, w as keyFields, x as makeSelectStatement, y as makeDeleteStatement, z as sqliteAffinity } from "./plan-B8PRmVdV.js";
6
+ import { C as parseSchema, _ as readConfigUrl, c as stringLiteral, f as makePostgresSchema, h as withTypeScriptImports, i as formatSql, o as qualifiedName, s as quoteIdentifier, u as environmentVariable, w as readSchemaFiles$1 } from "./sql-izRRI1Bi.js";
7
+ import { n as clientSource, r as discoverClient, t as ADAPTERS } from "./discover-BaDQsKnF.js";
8
8
  import { createRequire } from "node:module";
9
9
  import { Clock, Duration, Effect, Match, Option, Ref, Schedule, Semaphore, Stream } from "effect";
10
10
  import path from "node:path";
@@ -9357,10 +9357,7 @@ function watchMigrations(input) {
9357
9357
  function readClientStatus() {
9358
9358
  return Effect.gen(function* () {
9359
9359
  const state = studio().state;
9360
- const status = yield* studio().client.status(state.snapshot().files);
9361
- const result = ClientStatusSchema.safeParse(status);
9362
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9363
- return result.data;
9360
+ return yield* studio().client.status(state.snapshot().files);
9364
9361
  });
9365
9362
  }
9366
9363
  z$1.object({ query: z$1.string().trim().min(1).brand().meta({
@@ -9385,7 +9382,7 @@ function analyzeClientQuery(input) {
9385
9382
  models: models.map((model) => model.name),
9386
9383
  now
9387
9384
  });
9388
- const analysis = {
9385
+ return {
9389
9386
  calls: query.calls.map(({ model, operation, write, range }) => ({
9390
9387
  model,
9391
9388
  operation,
@@ -9399,9 +9396,6 @@ function analyzeClientQuery(input) {
9399
9396
  }),
9400
9397
  diagnostics: query.diagnostics
9401
9398
  };
9402
- const result = ClientAnalysisSchema.safeParse(analysis);
9403
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9404
- return result.data;
9405
9399
  });
9406
9400
  }
9407
9401
  z$1.object({ query: z$1.string().trim().min(1).brand().meta({
@@ -9426,7 +9420,7 @@ z$1.object({ query: z$1.string().trim().min(1).brand().meta({
9426
9420
  * Note over U: read the text into calls (domain)
9427
9421
  * U->>C: run(calls)
9428
9422
  * C-->>U: value, query events / ClientUnavailableError / ClientQueryError
9429
- * Note over U: value as JSON, first CLIENT_ROW_LIMIT rows → validate against ClientResult
9423
+ * Note over U: value as JSON, first CLIENT_ROW_LIMIT rows
9430
9424
  * ```
9431
9425
  *
9432
9426
  * @param input - the query text
@@ -9452,7 +9446,7 @@ function runClientQuery(input) {
9452
9446
  });
9453
9447
  const ran = yield* client.run(snapshot.files, query);
9454
9448
  const formatted = yield* Effect.forEach(ran.queries, (event) => formatSql(event.sql, db.status.dialect));
9455
- const clientResult = {
9449
+ return {
9456
9450
  ...makeClientResult({
9457
9451
  value: ran.value,
9458
9452
  limit: 500
@@ -9465,9 +9459,6 @@ function runClientQuery(input) {
9465
9459
  })),
9466
9460
  durationMs: Math.round(ran.durationMs * 10) / 10
9467
9461
  };
9468
- const result = ClientResultSchema.safeParse(clientResult);
9469
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9470
- return result.data;
9471
9462
  });
9472
9463
  }
9473
9464
  /**
@@ -9491,12 +9482,10 @@ function previewClientQuery(input) {
9491
9482
  message: `${write.model}.${write.operation} writes: its SQL shows when it is run`
9492
9483
  });
9493
9484
  const ran = yield* runClientQuery(input);
9494
- const result = ClientPreviewSchema.safeParse({
9485
+ return {
9495
9486
  queries: ran.queries,
9496
9487
  durationMs: ran.durationMs
9497
- });
9498
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9499
- return result.data;
9488
+ };
9500
9489
  });
9501
9490
  }
9502
9491
  z$1.object({
@@ -9524,10 +9513,7 @@ z$1.object({
9524
9513
  function completeClientQuery(input) {
9525
9514
  return Effect.gen(function* () {
9526
9515
  const state = studio().state;
9527
- const items = yield* studio().client.typescript.complete(state.snapshot().files, input.query, input.offset);
9528
- const result = ClientCompletionsSchema.safeParse({ items });
9529
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9530
- return result.data;
9516
+ return { items: yield* studio().client.typescript.complete(state.snapshot().files, input.query, input.offset) };
9531
9517
  });
9532
9518
  }
9533
9519
  z$1.object({
@@ -9560,10 +9546,7 @@ z$1.object({
9560
9546
  function detailClientCompletion(input) {
9561
9547
  return Effect.gen(function* () {
9562
9548
  const state = studio().state;
9563
- const detail = yield* studio().client.typescript.detail(state.snapshot().files, input.query, input.offset, input.name);
9564
- const result = ClientCompletionDetailSchema.safeParse(detail);
9565
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9566
- return result.data;
9549
+ return yield* studio().client.typescript.detail(state.snapshot().files, input.query, input.offset, input.name);
9567
9550
  });
9568
9551
  }
9569
9552
  /**
@@ -9575,10 +9558,7 @@ function detailClientCompletion(input) {
9575
9558
  function hoverClientQuery(input) {
9576
9559
  return Effect.gen(function* () {
9577
9560
  const state = studio().state;
9578
- const hover = yield* studio().client.typescript.hover(state.snapshot().files, input.query, input.offset);
9579
- const result = ClientHoverSchema.safeParse(hover);
9580
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9581
- return result.data;
9561
+ return yield* studio().client.typescript.hover(state.snapshot().files, input.query, input.offset);
9582
9562
  });
9583
9563
  }
9584
9564
  /**
@@ -9590,10 +9570,7 @@ function hoverClientQuery(input) {
9590
9570
  function signatureClientQuery(input) {
9591
9571
  return Effect.gen(function* () {
9592
9572
  const state = studio().state;
9593
- const help = yield* studio().client.typescript.signature(state.snapshot().files, input.query, input.offset);
9594
- const result = ClientSignatureHelpSchema.safeParse(help);
9595
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9596
- return result.data;
9573
+ return yield* studio().client.typescript.signature(state.snapshot().files, input.query, input.offset);
9597
9574
  });
9598
9575
  }
9599
9576
  z$1.object({ query: z$1.string().trim().min(1).brand().meta({
@@ -9612,10 +9589,7 @@ z$1.object({ query: z$1.string().trim().min(1).brand().meta({
9612
9589
  function checkClientQuery(input) {
9613
9590
  return Effect.gen(function* () {
9614
9591
  const state = studio().state;
9615
- const diagnostics = yield* studio().client.typescript.check(state.snapshot().files, input.query);
9616
- const result = ClientTypeDiagnosticsSchema.safeParse({ diagnostics });
9617
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9618
- return result.data;
9592
+ return { diagnostics: yield* studio().client.typescript.check(state.snapshot().files, input.query) };
9619
9593
  });
9620
9594
  }
9621
9595
  z$1.object({ query: z$1.string().trim().min(1).brand().meta({
@@ -9633,10 +9607,7 @@ z$1.object({ query: z$1.string().trim().min(1).brand().meta({
9633
9607
  */
9634
9608
  function formatClientQuery(input) {
9635
9609
  return Effect.gen(function* () {
9636
- const text = yield* fmt(input.query);
9637
- const result = ClientFormattedSchema.safeParse({ text: text.trimEnd() });
9638
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9639
- return result.data;
9610
+ return { text: (yield* fmt(input.query)).trimEnd() };
9640
9611
  });
9641
9612
  }
9642
9613
  // src/studio/server/usecases/database.ts
@@ -9646,12 +9617,7 @@ function formatClientQuery(input) {
9646
9617
  * @returns whether a database is open, which dialect and where the URL came from
9647
9618
  */
9648
9619
  function readDbStatus() {
9649
- return Effect.gen(function* () {
9650
- const db = studio().db;
9651
- const result = DbStatusSchema.safeParse(db.status);
9652
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9653
- return result.data;
9654
- });
9620
+ return Effect.sync(() => studio().db.status);
9655
9621
  }
9656
9622
  /**
9657
9623
  * Row count of every model that has a table; models without one are left out rather than failing the whole answer.
@@ -9669,13 +9635,10 @@ function readCounts() {
9669
9635
  columns: [],
9670
9636
  search: ""
9671
9637
  })).pipe(Effect.option), { concurrency: 4 });
9672
- const counts = Object.fromEntries(models.flatMap((model, index) => {
9638
+ return { counts: Object.fromEntries(models.flatMap((model, index) => {
9673
9639
  const count = counted[index];
9674
9640
  return count !== void 0 && Option.isSome(count) ? [[model.name, Number(count.value.rows[0]?.count ?? 0) || 0]] : [];
9675
- }));
9676
- const result = CountsSchema.safeParse({ counts });
9677
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9678
- return result.data;
9641
+ })) };
9679
9642
  });
9680
9643
  }
9681
9644
  z$1.object({
@@ -9760,7 +9723,7 @@ function readRows(input) {
9760
9723
  columns,
9761
9724
  search: page.search
9762
9725
  }))]);
9763
- const rows = {
9726
+ return {
9764
9727
  rows: selected.rows.map((row) => makeRow({
9765
9728
  row,
9766
9729
  columnToField,
@@ -9772,9 +9735,6 @@ function readRows(input) {
9772
9735
  key,
9773
9736
  columns: fields.map((f) => f.name)
9774
9737
  };
9775
- const result = RowsSchema.safeParse(rows);
9776
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9777
- return result.data;
9778
9738
  });
9779
9739
  }
9780
9740
  z$1.object({
@@ -9811,7 +9771,7 @@ function insertRow(input) {
9811
9771
  model,
9812
9772
  row: input.values
9813
9773
  }) });
9814
- const affected = { affected: (yield* driver.query(makeInsertStatement({
9774
+ return { affected: (yield* driver.query(makeInsertStatement({
9815
9775
  dialect: driver.dialect,
9816
9776
  table: tableName({ model }),
9817
9777
  values: makeColumnValues({
@@ -9824,9 +9784,6 @@ function insertRow(input) {
9824
9784
  enums: state.snapshot().schema?.enums ?? []
9825
9785
  })
9826
9786
  }))).rowCount };
9827
- const result = AffectedSchema.safeParse(affected);
9828
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9829
- return result.data;
9830
9787
  });
9831
9788
  }
9832
9789
  z$1.object({
@@ -9875,7 +9832,7 @@ function updateRow(input) {
9875
9832
  });
9876
9833
  const driver = yield* studio().db.driver;
9877
9834
  const enums = state.snapshot().schema?.enums ?? [];
9878
- const affected = { affected: (yield* driver.query(makeUpdateStatement({
9835
+ return { affected: (yield* driver.query(makeUpdateStatement({
9879
9836
  dialect: driver.dialect,
9880
9837
  table: tableName({ model }),
9881
9838
  where: makeColumnValues({
@@ -9891,9 +9848,6 @@ function updateRow(input) {
9891
9848
  enums
9892
9849
  })
9893
9850
  }))).rowCount };
9894
- const result = AffectedSchema.safeParse(affected);
9895
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9896
- return result.data;
9897
9851
  });
9898
9852
  }
9899
9853
  z$1.object({
@@ -9931,7 +9885,7 @@ function deleteRow(input) {
9931
9885
  });
9932
9886
  const driver = yield* studio().db.driver;
9933
9887
  const enums = state.snapshot().schema?.enums ?? [];
9934
- const affected = { affected: (yield* driver.query(makeDeleteStatement({
9888
+ return { affected: (yield* driver.query(makeDeleteStatement({
9935
9889
  dialect: driver.dialect,
9936
9890
  table: tableName({ model }),
9937
9891
  where: makeColumnValues({
@@ -9941,9 +9895,6 @@ function deleteRow(input) {
9941
9895
  enums
9942
9896
  })
9943
9897
  }))).rowCount };
9944
- const result = AffectedSchema.safeParse(affected);
9945
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
9946
- return result.data;
9947
9898
  });
9948
9899
  }
9949
9900
  const Cell = z$1.union([
@@ -10008,7 +9959,7 @@ function runSql(input) {
10008
9959
  rows: [],
10009
9960
  rowCount: 0
10010
9961
  };
10011
- const sqlResult = {
9962
+ return {
10012
9963
  columns: executed.columns,
10013
9964
  rows: executed.rows.slice(0, 500).map((row) => makeRow({
10014
9965
  row,
@@ -10017,9 +9968,6 @@ function runSql(input) {
10017
9968
  rowCount: executed.rowCount,
10018
9969
  durationMs: Math.round((performance.now() - started) * 10) / 10
10019
9970
  };
10020
- const result = SqlResultSchema.safeParse(sqlResult);
10021
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
10022
- return result.data;
10023
9971
  });
10024
9972
  }
10025
9973
  /**
@@ -10044,14 +9992,11 @@ function explainSql(input) {
10044
9992
  sql: first,
10045
9993
  params
10046
9994
  });
10047
- const plan = {
9995
+ return {
10048
9996
  dialect: driver.dialect,
10049
9997
  nodes: explained.nodes,
10050
9998
  raw: explained.raw
10051
9999
  };
10052
- const result = PlanSchema.safeParse(plan);
10053
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
10054
- return result.data;
10055
10000
  });
10056
10001
  }
10057
10002
  z$1.object({ sql: z$1.string().trim().min(1).brand().meta({
@@ -10069,37 +10014,25 @@ z$1.object({ sql: z$1.string().trim().min(1).brand().meta({
10069
10014
  * @returns the data-flow graph, lineage, row type, parameters and diagnostics of each statement
10070
10015
  */
10071
10016
  function analyzeSql(input) {
10072
- return Effect.gen(function* () {
10017
+ return Effect.sync(() => {
10073
10018
  const state = studio().state;
10074
10019
  const db = studio().db;
10075
10020
  const schema = state.snapshot().schema;
10076
- const analysis = analyze(input.sql, makeAnalysisSchema({
10021
+ return analyze(input.sql, makeAnalysisSchema({
10077
10022
  dialect: db.status.dialect,
10078
10023
  provider: schema?.provider ?? null,
10079
10024
  models: schema?.models ?? []
10080
10025
  }));
10081
- const result = AnalysisSchema.safeParse(analysis);
10082
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
10083
- return result.data;
10084
10026
  });
10085
10027
  }
10086
10028
  // src/studio/server/usecases/docs.ts
10087
- const checked$1 = /* @__PURE__ */ new WeakMap();
10088
10029
  /**
10089
10030
  * The documentation of the last schema that parsed: models with their client operations, and the client API types.
10090
10031
  *
10091
- * @returns the docs, checked against the Docs contract
10032
+ * @returns the docs as the state holds them
10092
10033
  */
10093
10034
  function readDocs() {
10094
- return Effect.gen(function* () {
10095
- const docs = studio().state.docs();
10096
- const kept = checked$1.get(docs);
10097
- if (kept !== void 0) return kept;
10098
- const result = DocsSchema.safeParse(docs);
10099
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
10100
- checked$1.set(docs, result.data);
10101
- return result.data;
10102
- });
10035
+ return Effect.sync(() => studio().state.docs());
10103
10036
  }
10104
10037
  // src/migrate/domain/backup.ts
10105
10038
  /**
@@ -11123,19 +11056,16 @@ function session() {
11123
11056
  function readMigrateStatus() {
11124
11057
  return Effect.gen(function* () {
11125
11058
  const opened = yield* session();
11126
- const status = yield* migrationStatus({
11127
- engine: opened.engine,
11128
- driver: opened.driver,
11129
- migrations: opened.migrations,
11130
- files: opened.files,
11131
- configDir: opened.schemaDir
11132
- });
11133
- const result = MigrateStatusSchema.safeParse({
11134
- ...status,
11059
+ return {
11060
+ ...yield* migrationStatus({
11061
+ engine: opened.engine,
11062
+ driver: opened.driver,
11063
+ migrations: opened.migrations,
11064
+ files: opened.files,
11065
+ configDir: opened.schemaDir
11066
+ }),
11135
11067
  migrationsDir: opened.migrationsDir
11136
- });
11137
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11138
- return result.data;
11068
+ };
11139
11069
  }).pipe(Effect.provide(layer));
11140
11070
  }
11141
11071
  /**
@@ -11146,14 +11076,11 @@ function readMigrateStatus() {
11146
11076
  function readMigrateDiff() {
11147
11077
  return Effect.gen(function* () {
11148
11078
  const opened = yield* session();
11149
- const diff = yield* migrationDiff({
11079
+ return yield* migrationDiff({
11150
11080
  engine: opened.engine,
11151
11081
  files: opened.files,
11152
11082
  configDir: opened.schemaDir
11153
11083
  });
11154
- const result = MigrateDiffSchema.safeParse(diff);
11155
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11156
- return result.data;
11157
11084
  }).pipe(Effect.provide(layer));
11158
11085
  }
11159
11086
  z$1.object({
@@ -11216,7 +11143,7 @@ function planMigration(input) {
11216
11143
  readOnly: false
11217
11144
  });
11218
11145
  const plan = makePlan(report, diff.sql, input.batch ?? null);
11219
- const result = MigratePlanSchema.safeParse({
11146
+ return {
11220
11147
  name: migrationName({
11221
11148
  at: /* @__PURE__ */ new Date(),
11222
11149
  name: input.name ?? "migration"
@@ -11227,9 +11154,7 @@ function planMigration(input) {
11227
11154
  sql: preview.sql
11228
11155
  })),
11229
11156
  notes: diff.drift ? plan.notes : ["The database already matches the schema: there is nothing to migrate."]
11230
- });
11231
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11232
- return result.data;
11157
+ };
11233
11158
  }).pipe(Effect.provide(layer));
11234
11159
  }
11235
11160
  z$1.object({ statements: z$1.array(z$1.string()).readonly().meta({
@@ -11244,13 +11169,10 @@ z$1.object({ statements: z$1.array(z$1.string()).readonly().meta({
11244
11169
  */
11245
11170
  function applyMigrationStatements(input) {
11246
11171
  return Effect.gen(function* () {
11247
- const applied = yield* applyStatements({
11172
+ return yield* applyStatements({
11248
11173
  driver: yield* studio().db.driver,
11249
11174
  statements: input.statements
11250
11175
  });
11251
- const result = ApplyResultSchema.safeParse(applied);
11252
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11253
- return result.data;
11254
11176
  });
11255
11177
  }
11256
11178
  z$1.object({
@@ -11276,18 +11198,15 @@ function createMigration(input) {
11276
11198
  at: /* @__PURE__ */ new Date(),
11277
11199
  name: input.name
11278
11200
  });
11279
- const written = yield* writeMigration({
11280
- baseDir: opened.migrationsDir,
11281
- name,
11282
- sql: input.sql,
11283
- provider: opened.driver.dialect
11284
- });
11285
- const result = CreatedMigrationSchema.safeParse({
11201
+ return {
11286
11202
  name,
11287
- file: written.file
11288
- });
11289
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11290
- return result.data;
11203
+ file: (yield* writeMigration({
11204
+ baseDir: opened.migrationsDir,
11205
+ name,
11206
+ sql: input.sql,
11207
+ provider: opened.driver.dialect
11208
+ })).file
11209
+ };
11291
11210
  }).pipe(Effect.provide(layer));
11292
11211
  }
11293
11212
  z$1.object({ name: z$1.string().meta({
@@ -11320,13 +11239,10 @@ function recordMigrationApplied(input) {
11320
11239
  function deployMigrations() {
11321
11240
  return Effect.gen(function* () {
11322
11241
  const opened = yield* session();
11323
- const deployed = yield* applyPendingMigrations({
11242
+ return yield* applyPendingMigrations({
11324
11243
  engine: opened.engine,
11325
11244
  migrations: opened.migrations
11326
11245
  });
11327
- const result = DeployedSchema.safeParse(deployed);
11328
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11329
- return result.data;
11330
11246
  }).pipe(Effect.provide(layer));
11331
11247
  }
11332
11248
  /**
@@ -11353,7 +11269,7 @@ function readMigrationDecisions() {
11353
11269
  return Effect.gen(function* () {
11354
11270
  const opened = yield* session();
11355
11271
  const decisions = yield* readDecisions(path.join(opened.schemaDir, DECISIONS_FILE));
11356
- const result = MigrationDecisionsSchema.safeParse({
11272
+ return {
11357
11273
  file: path.join(opened.schemaDir, DECISIONS_FILE),
11358
11274
  decisions: decisions.map((decision) => decision.value === null ? {
11359
11275
  kind: decision.kind,
@@ -11367,9 +11283,7 @@ function readMigrationDecisions() {
11367
11283
  choice: decision.choice,
11368
11284
  value: decision.value
11369
11285
  })
11370
- });
11371
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11372
- return result.data;
11286
+ };
11373
11287
  }).pipe(Effect.provide(layer));
11374
11288
  }
11375
11289
  z$1.object({ decisions: z$1.array(z$1.object({
@@ -11404,16 +11318,13 @@ z$1.object({ decisions: z$1.array(z$1.object({
11404
11318
  function writeMigrationDecisions(input) {
11405
11319
  return Effect.gen(function* () {
11406
11320
  const opened = yield* session();
11407
- const file = yield* writeDecisions({
11408
- file: path.join(opened.schemaDir, DECISIONS_FILE),
11409
- decisions: input.decisions
11410
- });
11411
- const result = MigrationDecisionsSchema.safeParse({
11412
- file,
11321
+ return {
11322
+ file: yield* writeDecisions({
11323
+ file: path.join(opened.schemaDir, DECISIONS_FILE),
11324
+ decisions: input.decisions
11325
+ }),
11413
11326
  decisions: input.decisions
11414
- });
11415
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11416
- return result.data;
11327
+ };
11417
11328
  }).pipe(Effect.provide(layer));
11418
11329
  }
11419
11330
  /**
@@ -11425,15 +11336,12 @@ function writeMigrationDecisions(input) {
11425
11336
  function readMigrateBaseline() {
11426
11337
  return Effect.gen(function* () {
11427
11338
  const opened = yield* session();
11428
- const candidates = yield* baselineCandidates({
11339
+ return { candidates: yield* baselineCandidates({
11429
11340
  engine: opened.engine,
11430
11341
  migrations: opened.migrations,
11431
11342
  files: opened.files,
11432
11343
  configDir: opened.schemaDir
11433
- });
11434
- const result = MigrateBaselineSchema.safeParse({ candidates });
11435
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11436
- return result.data;
11344
+ }) };
11437
11345
  }).pipe(Effect.provide(layer));
11438
11346
  }
11439
11347
  /**
@@ -11475,13 +11383,11 @@ function readMigrationFile(input) {
11475
11383
  name: input.migrationName,
11476
11384
  baseDir: opened.migrationsDir
11477
11385
  });
11478
- const result = MigrationFileSchema.safeParse({
11386
+ return {
11479
11387
  name: directory.path,
11480
11388
  file: path.join(opened.migrationsDir, directory.path, directory.migrationFile.path),
11481
11389
  sql: directory.migrationFile.content.value
11482
- });
11483
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11484
- return result.data;
11390
+ };
11485
11391
  }).pipe(Effect.provide(layer));
11486
11392
  }
11487
11393
  z$1.object({ steps: z$1.array(z$1.array(z$1.string()).readonly()).readonly().meta({ description: "Each step's statements, in the order they run." }) }).readonly().meta({ description: "The steps of a plan, to rehearse" });
@@ -11496,7 +11402,7 @@ z$1.object({ steps: z$1.array(z$1.array(z$1.string()).readonly()).readonly().met
11496
11402
  function rehearse(input) {
11497
11403
  return Effect.gen(function* () {
11498
11404
  const opened = yield* session();
11499
- const rehearsal = yield* rehearseMigration({
11405
+ return yield* rehearseMigration({
11500
11406
  driver: opened.driver,
11501
11407
  steps: input.steps,
11502
11408
  files: opened.files,
@@ -11511,9 +11417,6 @@ function rehearse(input) {
11511
11417
  cwd: process.cwd()
11512
11418
  })
11513
11419
  }).pipe(Effect.catchTag("DatabaseError", (error) => Effect.fail(new MigrateDatabaseError({ message: error.cause }))));
11514
- const result = RehearsalSchema.safeParse(rehearsal);
11515
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11516
- return result.data;
11517
11420
  }).pipe(Effect.provide(layer));
11518
11421
  }
11519
11422
  /**
@@ -11523,14 +11426,11 @@ function rehearse(input) {
11523
11426
  */
11524
11427
  function readTableCounts() {
11525
11428
  return Effect.gen(function* () {
11526
- const counted = yield* countTables(yield* studio().db.driver).pipe(Effect.catchTag("DatabaseError", (error) => Effect.fail(new MigrateDatabaseError({ message: error.cause }))));
11527
- const result = TableCountsSchema.safeParse({ tables: counted.map((one) => ({
11429
+ return { tables: (yield* countTables(yield* studio().db.driver).pipe(Effect.catchTag("DatabaseError", (error) => Effect.fail(new MigrateDatabaseError({ message: error.cause }))))).map((one) => ({
11528
11430
  table: one.table,
11529
11431
  before: null,
11530
11432
  after: one.rows
11531
- })) });
11532
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11533
- return result.data;
11433
+ })) };
11534
11434
  });
11535
11435
  }
11536
11436
  /**
@@ -11541,13 +11441,10 @@ function readTableCounts() {
11541
11441
  function readBackups() {
11542
11442
  return Effect.gen(function* () {
11543
11443
  const opened = yield* session();
11544
- const backups = yield* listBackups({
11444
+ return { backups: yield* listBackups({
11545
11445
  driver: opened.driver,
11546
11446
  schemaDir: opened.schemaDir
11547
- });
11548
- const result = BackupsSchema.safeParse({ backups });
11549
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11550
- return result.data;
11447
+ }) };
11551
11448
  }).pipe(Effect.provide(layer));
11552
11449
  }
11553
11450
  /**
@@ -11562,17 +11459,14 @@ function takeBackup() {
11562
11459
  driver: opened.driver,
11563
11460
  schemaDir: opened.schemaDir
11564
11461
  });
11565
- const backups = yield* listBackups({
11462
+ return (yield* listBackups({
11566
11463
  driver: opened.driver,
11567
11464
  schemaDir: opened.schemaDir
11568
- });
11569
- const result = BackupSchema.safeParse(backups.find((one) => one.name === taken.name) ?? {
11465
+ })).find((one) => one.name === taken.name) ?? {
11570
11466
  ...taken,
11571
11467
  size: null,
11572
11468
  restorable: false
11573
- });
11574
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11575
- return result.data;
11469
+ };
11576
11470
  }).pipe(Effect.catchTags({
11577
11471
  DatabaseError: (error) => Effect.fail(new MigrateDatabaseError({ message: error.cause })),
11578
11472
  PlatformError: (error) => Effect.fail(new MigrateConfigError({ message: error.message }))
@@ -11649,14 +11543,11 @@ z$1.object({
11649
11543
  * files so relations across files are completed too.
11650
11544
  *
11651
11545
  * @param input - the text and its file
11652
- * @returns the edits, checked against the Formatted contract
11546
+ * @returns the edits
11653
11547
  */
11654
11548
  function formatText(input) {
11655
11549
  return Effect.gen(function* () {
11656
- const edits = yield* formatSchema(yield* workspaceOf(input));
11657
- const result = FormattedSchema.safeParse({ edits });
11658
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11659
- return result.data;
11550
+ return { edits: yield* formatSchema(yield* workspaceOf(input)) };
11660
11551
  });
11661
11552
  }
11662
11553
  z$1.object({
@@ -11684,14 +11575,11 @@ z$1.object({
11684
11575
  function lintText(input) {
11685
11576
  return Effect.gen(function* () {
11686
11577
  const state = studio().state;
11687
- const diagnostics = yield* lintSchema({
11578
+ return { diagnostics: yield* lintSchema({
11688
11579
  files: state.snapshot().files,
11689
11580
  path: input.path,
11690
11581
  text: input.text
11691
- });
11692
- const result = DiagnosticsSchema.safeParse({ diagnostics });
11693
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11694
- return result.data;
11582
+ }) };
11695
11583
  });
11696
11584
  }
11697
11585
  z$1.object({
@@ -11711,14 +11599,11 @@ z$1.object({
11711
11599
  * The blocks of the text as the language server's document outline lists them.
11712
11600
  *
11713
11601
  * @param input - the text and its file
11714
- * @returns the symbols, checked against the Symbols contract
11602
+ * @returns the symbols
11715
11603
  */
11716
11604
  function symbolsOf(input) {
11717
11605
  return Effect.gen(function* () {
11718
- const symbols = yield* symbolsOfSchema(yield* workspaceOf(input));
11719
- const result = SymbolsSchema.safeParse({ symbols });
11720
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11721
- return result.data;
11606
+ return { symbols: yield* symbolsOfSchema(yield* workspaceOf(input)) };
11722
11607
  });
11723
11608
  }
11724
11609
  z$1.object({
@@ -11759,15 +11644,12 @@ z$1.object({
11759
11644
  */
11760
11645
  function completeAt(input) {
11761
11646
  return Effect.gen(function* () {
11762
- const items = yield* completeSchema({
11647
+ return { items: yield* completeSchema({
11763
11648
  ...yield* workspaceOf(input),
11764
11649
  line: input.line,
11765
11650
  character: input.character,
11766
11651
  triggerCharacter: input.triggerCharacter ?? null
11767
- });
11768
- const result = CompletionsSchema.safeParse({ items });
11769
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11770
- return result.data;
11652
+ }) };
11771
11653
  });
11772
11654
  }
11773
11655
  z$1.object({
@@ -11799,18 +11681,15 @@ z$1.object({
11799
11681
  * What the Prisma language server says about the symbol at the position.
11800
11682
  *
11801
11683
  * @param input - the text and the position
11802
- * @returns the hover contents and range, checked against the Hover contract
11684
+ * @returns the hover contents and range
11803
11685
  */
11804
11686
  function hoverAt(input) {
11805
11687
  return Effect.gen(function* () {
11806
- const hover = yield* hoverSchema({
11688
+ return yield* hoverSchema({
11807
11689
  ...yield* workspaceOf(input),
11808
11690
  line: input.line,
11809
11691
  character: input.character
11810
11692
  });
11811
- const result = HoverSchema.safeParse(hover);
11812
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11813
- return result.data;
11814
11693
  });
11815
11694
  }
11816
11695
  z$1.object({
@@ -11842,18 +11721,15 @@ z$1.object({
11842
11721
  * Where the model, enum or type referenced at the position is declared.
11843
11722
  *
11844
11723
  * @param input - the text and the position
11845
- * @returns the declaration locations, checked against the Definition contract
11724
+ * @returns the declaration locations
11846
11725
  */
11847
11726
  function defineAt(input) {
11848
11727
  return Effect.gen(function* () {
11849
- const locations = yield* defineSchema({
11728
+ return { locations: yield* defineSchema({
11850
11729
  ...yield* workspaceOf(input),
11851
11730
  line: input.line,
11852
11731
  character: input.character
11853
- });
11854
- const result = DefinitionSchema.safeParse({ locations });
11855
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11856
- return result.data;
11732
+ }) };
11857
11733
  });
11858
11734
  }
11859
11735
  z$1.object({
@@ -11885,18 +11761,15 @@ z$1.object({
11885
11761
  * Every place the symbol at the position is used, across the loaded files.
11886
11762
  *
11887
11763
  * @param input - the text and the position
11888
- * @returns the reference locations, checked against the References contract
11764
+ * @returns the reference locations
11889
11765
  */
11890
11766
  function referencesAt(input) {
11891
11767
  return Effect.gen(function* () {
11892
- const locations = yield* referencesSchema({
11768
+ return { locations: yield* referencesSchema({
11893
11769
  ...yield* workspaceOf(input),
11894
11770
  line: input.line,
11895
11771
  character: input.character
11896
- });
11897
- const result = ReferencesSchema.safeParse({ locations });
11898
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11899
- return result.data;
11772
+ }) };
11900
11773
  });
11901
11774
  }
11902
11775
  z$1.object({
@@ -11933,19 +11806,16 @@ z$1.object({
11933
11806
  * The edits that rename the model or enum at the position everywhere it is used.
11934
11807
  *
11935
11808
  * @param input - the text, the position and the new name
11936
- * @returns the edits per file, checked against the Rename contract
11809
+ * @returns the edits per file
11937
11810
  */
11938
11811
  function renameAt(input) {
11939
11812
  return Effect.gen(function* () {
11940
- const changes = yield* renameSchema({
11813
+ return { changes: yield* renameSchema({
11941
11814
  ...yield* workspaceOf(input),
11942
11815
  line: input.line,
11943
11816
  character: input.character,
11944
11817
  newName: input.newName
11945
- });
11946
- const result = RenameSchema.safeParse({ changes });
11947
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
11948
- return result.data;
11818
+ }) };
11949
11819
  });
11950
11820
  }
11951
11821
  z$1.object({
@@ -12037,37 +11907,25 @@ z$1.object({
12037
11907
  * The quick fixes the Prisma language server offers for the diagnostics in the range.
12038
11908
  *
12039
11909
  * @param input - the text, the range and the diagnostics in it
12040
- * @returns the fixes, checked against the CodeActions contract
11910
+ * @returns the fixes
12041
11911
  */
12042
11912
  function codeActionsAt(input) {
12043
11913
  return Effect.gen(function* () {
12044
- const actions = yield* codeActionsSchema({
11914
+ return { actions: yield* codeActionsSchema({
12045
11915
  ...yield* workspaceOf(input),
12046
11916
  range: input.range,
12047
11917
  diagnostics: input.diagnostics
12048
- });
12049
- const result = CodeActionsSchema.safeParse({ actions });
12050
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
12051
- return result.data;
11918
+ }) };
12052
11919
  });
12053
11920
  }
12054
11921
  // src/studio/server/usecases/schema.ts
12055
- const checked = /* @__PURE__ */ new WeakMap();
12056
11922
  /**
12057
11923
  * The current snapshot: the last valid schema, the current Prisma error and the files on disk.
12058
11924
  *
12059
- * @returns the snapshot, checked against the Snapshot contract
11925
+ * @returns the snapshot as the state holds it
12060
11926
  */
12061
11927
  function readSnapshot() {
12062
- return Effect.gen(function* () {
12063
- const snapshot = studio().state.snapshot();
12064
- const kept = checked.get(snapshot);
12065
- if (kept !== void 0) return kept;
12066
- const result = SnapshotSchema.safeParse(snapshot);
12067
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
12068
- checked.set(snapshot, result.data);
12069
- return result.data;
12070
- });
11928
+ return Effect.sync(() => studio().state.snapshot());
12071
11929
  }
12072
11930
  /**
12073
11931
  * When the snapshot and the migrations directory last changed: what the event stream polls.
@@ -12089,12 +11947,7 @@ function readUpdatedAt() {
12089
11947
  * @returns the fresh snapshot
12090
11948
  */
12091
11949
  function reloadSnapshot() {
12092
- return Effect.gen(function* () {
12093
- const state = studio().state;
12094
- const result = SnapshotSchema.safeParse(yield* state.reload());
12095
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
12096
- return result.data;
12097
- }).pipe(Effect.provide(layer));
11950
+ return studio().state.reload().pipe(Effect.provide(layer));
12098
11951
  }
12099
11952
  z$1.object({
12100
11953
  path: z$1.string().min(1).brand().meta({
@@ -12143,12 +11996,18 @@ function writeFile(input) {
12143
11996
  path: known.path,
12144
11997
  content: input.content
12145
11998
  });
12146
- const result = SnapshotSchema.safeParse(yield* state.reload());
12147
- if (!result.success) return yield* new ContractViolationError({ message: result.error.message });
12148
- return result.data;
11999
+ return yield* state.reload();
12149
12000
  }).pipe(Effect.provide(layer));
12150
12001
  }
12151
12002
  // src/studio/server/handlers/schema.ts
12003
+ const checked$1 = /* @__PURE__ */ new WeakMap();
12004
+ function checkSnapshot(snapshot) {
12005
+ const kept = checked$1.get(snapshot);
12006
+ if (kept !== void 0) return kept;
12007
+ const parsed = SnapshotSchema.parse(snapshot);
12008
+ checked$1.set(snapshot, parsed);
12009
+ return parsed;
12010
+ }
12152
12011
  /**
12153
12012
  * `GET /schema` handler. The current snapshot: the last valid schema, the current Prisma error and
12154
12013
  * the files on disk.
@@ -12162,19 +12021,9 @@ function writeFile(input) {
12162
12021
  * H->>U: readSnapshot()
12163
12022
  * U-->>H: Snapshot
12164
12023
  * H-->>C: 200 Snapshot
12165
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12166
12024
  * ```
12167
12025
  */
12168
- const getSchemaRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readSnapshot(), {
12169
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12170
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12171
- type: "/problems/internal-server-error",
12172
- title: "Internal Server Error",
12173
- status: 500,
12174
- detail: "An unexpected error occurred.",
12175
- instance: c.req.path
12176
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12177
- }));
12026
+ const getSchemaRouteHandler = (c) => Effect.runPromise(Effect.map(readSnapshot(), (value) => c.json(checkSnapshot(value), 200)));
12178
12027
  /**
12179
12028
  * `POST /schema/reload` handler. Re-read and re-parse the schema from disk (the watcher does this
12180
12029
  * on its own after every save).
@@ -12188,19 +12037,9 @@ const getSchemaRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readSn
12188
12037
  * H->>U: reloadSnapshot()
12189
12038
  * U-->>H: Snapshot
12190
12039
  * H-->>C: 200 Snapshot
12191
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12192
12040
  * ```
12193
12041
  */
12194
- const postSchemaReloadRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(reloadSnapshot(), {
12195
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12196
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12197
- type: "/problems/internal-server-error",
12198
- title: "Internal Server Error",
12199
- status: 500,
12200
- detail: "An unexpected error occurred.",
12201
- instance: c.req.path
12202
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12203
- }));
12042
+ const postSchemaReloadRouteHandler = (c) => Effect.runPromise(Effect.map(reloadSnapshot(), (value) => c.json(checkSnapshot(value), 200)));
12204
12043
  /**
12205
12044
  * `PUT /schema/files` handler. Write one schema file back to disk and reload, so the returned
12206
12045
  * snapshot reflects the edit. Only a path listed in `Snapshot.files` can be written (404
@@ -12215,7 +12054,7 @@ const postSchemaReloadRouteHandler = (c) => Effect.runPromise(Effect.matchEffect
12215
12054
  * H->>U: writeFile()
12216
12055
  * U-->>H: Snapshot
12217
12056
  * H-->>C: 200 Snapshot
12218
- * Note over H: on failure, Match.tag: UnknownFileError -> 404 / FileWriteError -> 422 / ContractViolationError -> 500
12057
+ * Note over H: on failure, Match.tag: UnknownFileError -> 404 / FileWriteError -> 422
12219
12058
  * ```
12220
12059
  */
12221
12060
  const putSchemaFilesRouteHandler = (c) => {
@@ -12224,7 +12063,7 @@ const putSchemaFilesRouteHandler = (c) => {
12224
12063
  path: data.path,
12225
12064
  content: data.content
12226
12065
  }), {
12227
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12066
+ onSuccess: (value) => Effect.succeed(c.json(checkSnapshot(value), 200)),
12228
12067
  onFailure: (error) => Match.value(error).pipe(Match.tag("UnknownFileError", ({ path }) => Effect.succeed(c.json({
12229
12068
  type: "/problems/not-found",
12230
12069
  title: "Not Found",
@@ -12241,13 +12080,7 @@ const putSchemaFilesRouteHandler = (c) => {
12241
12080
  field: "path",
12242
12081
  message: cause
12243
12082
  }]
12244
- }, 422, { "Content-Type": "application/problem+json" })))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12245
- type: "/problems/internal-server-error",
12246
- title: "Internal Server Error",
12247
- status: 500,
12248
- detail: "An unexpected error occurred.",
12249
- instance: c.req.path
12250
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12083
+ }, 422, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12251
12084
  }));
12252
12085
  };
12253
12086
  /**
@@ -12334,19 +12167,9 @@ const getSchemaEventsRouteHandler = (c) => streamSSE(c, async (stream) => {
12334
12167
  * H->>U: readDbStatus()
12335
12168
  * U-->>H: DbStatus
12336
12169
  * H-->>C: 200 DbStatus
12337
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12338
12170
  * ```
12339
12171
  */
12340
- const getDbRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readDbStatus(), {
12341
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12342
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12343
- type: "/problems/internal-server-error",
12344
- title: "Internal Server Error",
12345
- status: 500,
12346
- detail: "An unexpected error occurred.",
12347
- instance: c.req.path
12348
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12349
- }));
12172
+ const getDbRouteHandler = (c) => Effect.runPromise(Effect.map(readDbStatus(), (value) => c.json(DbStatusSchema.parse(value), 200)));
12350
12173
  /**
12351
12174
  * `GET /db/counts` handler. Row count of every model that has a table; a model whose count fails is
12352
12175
  * left out.
@@ -12360,24 +12183,18 @@ const getDbRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readDbStat
12360
12183
  * H->>U: readCounts()
12361
12184
  * U-->>H: Counts
12362
12185
  * H-->>C: 200 Counts
12363
- * Note over H: on failure, Match.tag: DatabaseUnavailableError -> 503 / ContractViolationError -> 500
12186
+ * Note over H: on failure, Match.tag: DatabaseUnavailableError -> 503
12364
12187
  * ```
12365
12188
  */
12366
12189
  const getDbCountsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readCounts(), {
12367
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12190
+ onSuccess: (value) => Effect.succeed(c.json(CountsSchema.parse(value), 200)),
12368
12191
  onFailure: (error) => Match.value(error).pipe(Match.tag("DatabaseUnavailableError", ({ reason }) => Effect.succeed(c.json({
12369
12192
  type: "/problems/service-unavailable",
12370
12193
  title: "Service Unavailable",
12371
12194
  status: 503,
12372
12195
  detail: reason,
12373
12196
  instance: c.req.path
12374
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12375
- type: "/problems/internal-server-error",
12376
- title: "Internal Server Error",
12377
- status: 500,
12378
- detail: "An unexpected error occurred.",
12379
- instance: c.req.path
12380
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12197
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
12381
12198
  }));
12382
12199
  /**
12383
12200
  * `GET /db/rows/{modelName}` handler. One page of a model's rows, keyed by field name, ordered by
@@ -12392,7 +12209,7 @@ const getDbCountsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(read
12392
12209
  * H->>U: readRows()
12393
12210
  * U-->>H: Rows
12394
12211
  * H-->>C: 200 Rows
12395
- * Note over H: on failure, Match.tag: UnknownModelError -> 404 / DatabaseUnavailableError -> 503 / DatabaseError -> 503 / ContractViolationError -> 500
12212
+ * Note over H: on failure, Match.tag: UnknownModelError -> 404 / DatabaseUnavailableError -> 503 / DatabaseError -> 503
12396
12213
  * ```
12397
12214
  */
12398
12215
  const getDbRowsModelNameRouteHandler = (c) => {
@@ -12401,7 +12218,7 @@ const getDbRowsModelNameRouteHandler = (c) => {
12401
12218
  ...c.req.valid("query")
12402
12219
  };
12403
12220
  return Effect.runPromise(Effect.matchEffect(readRows(data), {
12404
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12221
+ onSuccess: (value) => Effect.succeed(c.json(RowsSchema.parse(value), 200)),
12405
12222
  onFailure: (error) => Match.value(error).pipe(Match.tag("UnknownModelError", ({ model }) => Effect.succeed(c.json({
12406
12223
  type: "/problems/not-found",
12407
12224
  title: "Not Found",
@@ -12420,13 +12237,7 @@ const getDbRowsModelNameRouteHandler = (c) => {
12420
12237
  status: 503,
12421
12238
  detail: cause,
12422
12239
  instance: c.req.path
12423
- }, 503, { "Content-Type": "application/problem+json" })))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12424
- type: "/problems/internal-server-error",
12425
- title: "Internal Server Error",
12426
- status: 500,
12427
- detail: "An unexpected error occurred.",
12428
- instance: c.req.path
12429
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12240
+ }, 503, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12430
12241
  }));
12431
12242
  };
12432
12243
  /**
@@ -12442,7 +12253,7 @@ const getDbRowsModelNameRouteHandler = (c) => {
12442
12253
  * H->>U: insertRow()
12443
12254
  * U-->>H: Affected
12444
12255
  * H-->>C: 200 Affected
12445
- * Note over H: on failure, Match.tag: UnknownModelError -> 404 / DatabaseUnavailableError -> 503 / DatabaseError -> 503 / ContractViolationError -> 500
12256
+ * Note over H: on failure, Match.tag: UnknownModelError -> 404 / DatabaseUnavailableError -> 503 / DatabaseError -> 503
12446
12257
  * ```
12447
12258
  */
12448
12259
  const postDbRowsModelNameRouteHandler = (c) => {
@@ -12454,7 +12265,7 @@ const postDbRowsModelNameRouteHandler = (c) => {
12454
12265
  modelName: data.modelName,
12455
12266
  values: data.values
12456
12267
  }), {
12457
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12268
+ onSuccess: (value) => Effect.succeed(c.json(AffectedSchema.parse(value), 200)),
12458
12269
  onFailure: (error) => Match.value(error).pipe(Match.tag("UnknownModelError", ({ model }) => Effect.succeed(c.json({
12459
12270
  type: "/problems/not-found",
12460
12271
  title: "Not Found",
@@ -12473,13 +12284,7 @@ const postDbRowsModelNameRouteHandler = (c) => {
12473
12284
  status: 503,
12474
12285
  detail: cause,
12475
12286
  instance: c.req.path
12476
- }, 503, { "Content-Type": "application/problem+json" })))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12477
- type: "/problems/internal-server-error",
12478
- title: "Internal Server Error",
12479
- status: 500,
12480
- detail: "An unexpected error occurred.",
12481
- instance: c.req.path
12482
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12287
+ }, 503, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12483
12288
  }));
12484
12289
  };
12485
12290
  /**
@@ -12495,7 +12300,7 @@ const postDbRowsModelNameRouteHandler = (c) => {
12495
12300
  * H->>U: updateRow()
12496
12301
  * U-->>H: Affected
12497
12302
  * H-->>C: 200 Affected
12498
- * Note over H: on failure, Match.tag: UnknownModelError -> 404 / InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 503 / ContractViolationError -> 500
12303
+ * Note over H: on failure, Match.tag: UnknownModelError -> 404 / InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 503
12499
12304
  * ```
12500
12305
  */
12501
12306
  const patchDbRowsModelNameRouteHandler = (c) => {
@@ -12508,7 +12313,7 @@ const patchDbRowsModelNameRouteHandler = (c) => {
12508
12313
  where: data.where,
12509
12314
  values: data.values
12510
12315
  }), {
12511
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12316
+ onSuccess: (value) => Effect.succeed(c.json(AffectedSchema.parse(value), 200)),
12512
12317
  onFailure: (error) => Match.value(error).pipe(Match.tag("UnknownModelError", ({ model }) => Effect.succeed(c.json({
12513
12318
  type: "/problems/not-found",
12514
12319
  title: "Not Found",
@@ -12537,13 +12342,7 @@ const patchDbRowsModelNameRouteHandler = (c) => {
12537
12342
  status: 503,
12538
12343
  detail: cause,
12539
12344
  instance: c.req.path
12540
- }, 503, { "Content-Type": "application/problem+json" })))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12541
- type: "/problems/internal-server-error",
12542
- title: "Internal Server Error",
12543
- status: 500,
12544
- detail: "An unexpected error occurred.",
12545
- instance: c.req.path
12546
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12345
+ }, 503, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12547
12346
  }));
12548
12347
  };
12549
12348
  /**
@@ -12558,7 +12357,7 @@ const patchDbRowsModelNameRouteHandler = (c) => {
12558
12357
  * H->>U: deleteRow()
12559
12358
  * U-->>H: Affected
12560
12359
  * H-->>C: 200 Affected
12561
- * Note over H: on failure, Match.tag: UnknownModelError -> 404 / InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 503 / ContractViolationError -> 500
12360
+ * Note over H: on failure, Match.tag: UnknownModelError -> 404 / InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 503
12562
12361
  * ```
12563
12362
  */
12564
12363
  const deleteDbRowsModelNameRouteHandler = (c) => {
@@ -12570,7 +12369,7 @@ const deleteDbRowsModelNameRouteHandler = (c) => {
12570
12369
  modelName: data.modelName,
12571
12370
  where: data.where
12572
12371
  }), {
12573
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12372
+ onSuccess: (value) => Effect.succeed(c.json(AffectedSchema.parse(value), 200)),
12574
12373
  onFailure: (error) => Match.value(error).pipe(Match.tag("UnknownModelError", ({ model }) => Effect.succeed(c.json({
12575
12374
  type: "/problems/not-found",
12576
12375
  title: "Not Found",
@@ -12599,13 +12398,7 @@ const deleteDbRowsModelNameRouteHandler = (c) => {
12599
12398
  status: 503,
12600
12399
  detail: cause,
12601
12400
  instance: c.req.path
12602
- }, 503, { "Content-Type": "application/problem+json" })))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12603
- type: "/problems/internal-server-error",
12604
- title: "Internal Server Error",
12605
- status: 500,
12606
- detail: "An unexpected error occurred.",
12607
- instance: c.req.path
12608
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12401
+ }, 503, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12609
12402
  }));
12610
12403
  };
12611
12404
  /**
@@ -12621,7 +12414,7 @@ const deleteDbRowsModelNameRouteHandler = (c) => {
12621
12414
  * H->>U: runSql()
12622
12415
  * U-->>H: SqlResult
12623
12416
  * H-->>C: 200 SqlResult
12624
- * Note over H: on failure, Match.tag: InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 422 / ContractViolationError -> 500
12417
+ * Note over H: on failure, Match.tag: InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 422
12625
12418
  * ```
12626
12419
  */
12627
12420
  const postDbSqlRouteHandler = (c) => {
@@ -12630,7 +12423,7 @@ const postDbSqlRouteHandler = (c) => {
12630
12423
  sql: data.sql,
12631
12424
  params: data.params ?? []
12632
12425
  }), {
12633
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12426
+ onSuccess: (value) => Effect.succeed(c.json(SqlResultSchema.parse(value), 200)),
12634
12427
  onFailure: (error) => Match.value(error).pipe(Match.tag("InvalidInputError", ({ field, message }) => Effect.succeed(c.json({
12635
12428
  type: "/problems/validation-failed",
12636
12429
  title: "Validation Failed",
@@ -12657,13 +12450,7 @@ const postDbSqlRouteHandler = (c) => {
12657
12450
  field: "sql",
12658
12451
  message: cause
12659
12452
  }]
12660
- }, 422, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12661
- type: "/problems/internal-server-error",
12662
- title: "Internal Server Error",
12663
- status: 500,
12664
- detail: "An unexpected error occurred.",
12665
- instance: c.req.path
12666
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12453
+ }, 422, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
12667
12454
  }));
12668
12455
  };
12669
12456
  /**
@@ -12679,21 +12466,11 @@ const postDbSqlRouteHandler = (c) => {
12679
12466
  * H->>U: analyzeSql()
12680
12467
  * U-->>H: Analysis
12681
12468
  * H-->>C: 200 Analysis
12682
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12683
12469
  * ```
12684
12470
  */
12685
12471
  const postDbAnalyzeRouteHandler = (c) => {
12686
12472
  const data = c.req.valid("json");
12687
- return Effect.runPromise(Effect.matchEffect(analyzeSql({ sql: data.sql }), {
12688
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12689
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12690
- type: "/problems/internal-server-error",
12691
- title: "Internal Server Error",
12692
- status: 500,
12693
- detail: "An unexpected error occurred.",
12694
- instance: c.req.path
12695
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12696
- }));
12473
+ return Effect.runPromise(Effect.map(analyzeSql({ sql: data.sql }), (value) => c.json(AnalysisSchema.parse(value), 200)));
12697
12474
  };
12698
12475
  /**
12699
12476
  * `POST /db/explain` handler. The execution plan the database chooses for the first statement of
@@ -12708,7 +12485,7 @@ const postDbAnalyzeRouteHandler = (c) => {
12708
12485
  * H->>U: explainSql()
12709
12486
  * U-->>H: Plan
12710
12487
  * H-->>C: 200 Plan
12711
- * Note over H: on failure, Match.tag: InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 422 / ContractViolationError -> 500
12488
+ * Note over H: on failure, Match.tag: InvalidInputError -> 422 / DatabaseUnavailableError -> 503 / DatabaseError -> 422
12712
12489
  * ```
12713
12490
  */
12714
12491
  const postDbExplainRouteHandler = (c) => {
@@ -12717,7 +12494,7 @@ const postDbExplainRouteHandler = (c) => {
12717
12494
  sql: data.sql,
12718
12495
  params: data.params ?? []
12719
12496
  }), {
12720
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12497
+ onSuccess: (value) => Effect.succeed(c.json(PlanSchema.parse(value), 200)),
12721
12498
  onFailure: (error) => Match.value(error).pipe(Match.tag("InvalidInputError", ({ field, message }) => Effect.succeed(c.json({
12722
12499
  type: "/problems/validation-failed",
12723
12500
  title: "Validation Failed",
@@ -12744,13 +12521,7 @@ const postDbExplainRouteHandler = (c) => {
12744
12521
  field: "sql",
12745
12522
  message: cause
12746
12523
  }]
12747
- }, 422, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12748
- type: "/problems/internal-server-error",
12749
- title: "Internal Server Error",
12750
- status: 500,
12751
- detail: "An unexpected error occurred.",
12752
- instance: c.req.path
12753
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12524
+ }, 422, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
12754
12525
  }));
12755
12526
  };
12756
12527
  // src/studio/server/handlers/prisma.ts
@@ -12766,7 +12537,7 @@ const postDbExplainRouteHandler = (c) => {
12766
12537
  * H->>U: formatText()
12767
12538
  * U-->>H: Formatted
12768
12539
  * H-->>C: 200 Formatted
12769
- * Note over H: on failure, Match.tag: FormatError -> 422 / ContractViolationError -> 500
12540
+ * Note over H: on failure, Match.tag: FormatError -> 422
12770
12541
  * ```
12771
12542
  */
12772
12543
  const postPrismaFormatRouteHandler = (c) => {
@@ -12775,7 +12546,7 @@ const postPrismaFormatRouteHandler = (c) => {
12775
12546
  text: data.text,
12776
12547
  path: data.path
12777
12548
  }), {
12778
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12549
+ onSuccess: (value) => Effect.succeed(c.json(FormattedSchema.parse(value), 200)),
12779
12550
  onFailure: (error) => Match.value(error).pipe(Match.tag("FormatError", ({ cause }) => Effect.succeed(c.json({
12780
12551
  type: "/problems/validation-failed",
12781
12552
  title: "Validation Failed",
@@ -12786,13 +12557,7 @@ const postPrismaFormatRouteHandler = (c) => {
12786
12557
  field: "text",
12787
12558
  message: cause
12788
12559
  }]
12789
- }, 422, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12790
- type: "/problems/internal-server-error",
12791
- title: "Internal Server Error",
12792
- status: 500,
12793
- detail: "An unexpected error occurred.",
12794
- instance: c.req.path
12795
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12560
+ }, 422, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
12796
12561
  }));
12797
12562
  };
12798
12563
  /**
@@ -12808,24 +12573,14 @@ const postPrismaFormatRouteHandler = (c) => {
12808
12573
  * H->>U: lintText()
12809
12574
  * U-->>H: Diagnostics
12810
12575
  * H-->>C: 200 Diagnostics
12811
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12812
12576
  * ```
12813
12577
  */
12814
12578
  const postPrismaLintRouteHandler = (c) => {
12815
12579
  const data = c.req.valid("json");
12816
- return Effect.runPromise(Effect.matchEffect(lintText({
12580
+ return Effect.runPromise(Effect.map(lintText({
12817
12581
  path: data.path,
12818
12582
  text: data.text
12819
- }), {
12820
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12821
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12822
- type: "/problems/internal-server-error",
12823
- title: "Internal Server Error",
12824
- status: 500,
12825
- detail: "An unexpected error occurred.",
12826
- instance: c.req.path
12827
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12828
- }));
12583
+ }), (value) => c.json(DiagnosticsSchema.parse(value), 200)));
12829
12584
  };
12830
12585
  /**
12831
12586
  * `POST /prisma/complete` handler. Completions the Prisma language server offers at a cursor
@@ -12840,27 +12595,17 @@ const postPrismaLintRouteHandler = (c) => {
12840
12595
  * H->>U: completeAt()
12841
12596
  * U-->>H: Completions
12842
12597
  * H-->>C: 200 Completions
12843
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12844
12598
  * ```
12845
12599
  */
12846
12600
  const postPrismaCompleteRouteHandler = (c) => {
12847
12601
  const data = c.req.valid("json");
12848
- return Effect.runPromise(Effect.matchEffect(completeAt({
12602
+ return Effect.runPromise(Effect.map(completeAt({
12849
12603
  text: data.text,
12850
12604
  path: data.path,
12851
12605
  line: data.line,
12852
12606
  character: data.character,
12853
12607
  triggerCharacter: data.triggerCharacter
12854
- }), {
12855
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12856
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12857
- type: "/problems/internal-server-error",
12858
- title: "Internal Server Error",
12859
- status: 500,
12860
- detail: "An unexpected error occurred.",
12861
- instance: c.req.path
12862
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12863
- }));
12608
+ }), (value) => c.json(CompletionsSchema.parse(value), 200)));
12864
12609
  };
12865
12610
  /**
12866
12611
  * `POST /prisma/hover` handler. What the Prisma language server says about the symbol at a cursor
@@ -12875,26 +12620,16 @@ const postPrismaCompleteRouteHandler = (c) => {
12875
12620
  * H->>U: hoverAt()
12876
12621
  * U-->>H: Hover
12877
12622
  * H-->>C: 200 Hover
12878
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12879
12623
  * ```
12880
12624
  */
12881
12625
  const postPrismaHoverRouteHandler = (c) => {
12882
12626
  const data = c.req.valid("json");
12883
- return Effect.runPromise(Effect.matchEffect(hoverAt({
12627
+ return Effect.runPromise(Effect.map(hoverAt({
12884
12628
  text: data.text,
12885
12629
  path: data.path,
12886
12630
  line: data.line,
12887
12631
  character: data.character
12888
- }), {
12889
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12890
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12891
- type: "/problems/internal-server-error",
12892
- title: "Internal Server Error",
12893
- status: 500,
12894
- detail: "An unexpected error occurred.",
12895
- instance: c.req.path
12896
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12897
- }));
12632
+ }), (value) => c.json(HoverSchema.parse(value), 200)));
12898
12633
  };
12899
12634
  /**
12900
12635
  * `POST /prisma/definition` handler. Where the model, enum or type referenced at a cursor position
@@ -12909,26 +12644,16 @@ const postPrismaHoverRouteHandler = (c) => {
12909
12644
  * H->>U: defineAt()
12910
12645
  * U-->>H: Definition
12911
12646
  * H-->>C: 200 Definition
12912
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12913
12647
  * ```
12914
12648
  */
12915
12649
  const postPrismaDefinitionRouteHandler = (c) => {
12916
12650
  const data = c.req.valid("json");
12917
- return Effect.runPromise(Effect.matchEffect(defineAt({
12651
+ return Effect.runPromise(Effect.map(defineAt({
12918
12652
  text: data.text,
12919
12653
  path: data.path,
12920
12654
  line: data.line,
12921
12655
  character: data.character
12922
- }), {
12923
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12924
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12925
- type: "/problems/internal-server-error",
12926
- title: "Internal Server Error",
12927
- status: 500,
12928
- detail: "An unexpected error occurred.",
12929
- instance: c.req.path
12930
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12931
- }));
12656
+ }), (value) => c.json(DefinitionSchema.parse(value), 200)));
12932
12657
  };
12933
12658
  /**
12934
12659
  * `POST /prisma/rename` handler. The edits that rename the model or enum at a cursor position
@@ -12943,27 +12668,17 @@ const postPrismaDefinitionRouteHandler = (c) => {
12943
12668
  * H->>U: renameAt()
12944
12669
  * U-->>H: Rename
12945
12670
  * H-->>C: 200 Rename
12946
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12947
12671
  * ```
12948
12672
  */
12949
12673
  const postPrismaRenameRouteHandler = (c) => {
12950
12674
  const data = c.req.valid("json");
12951
- return Effect.runPromise(Effect.matchEffect(renameAt({
12675
+ return Effect.runPromise(Effect.map(renameAt({
12952
12676
  text: data.text,
12953
12677
  path: data.path,
12954
12678
  line: data.line,
12955
12679
  character: data.character,
12956
12680
  newName: data.newName
12957
- }), {
12958
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12959
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12960
- type: "/problems/internal-server-error",
12961
- title: "Internal Server Error",
12962
- status: 500,
12963
- detail: "An unexpected error occurred.",
12964
- instance: c.req.path
12965
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12966
- }));
12681
+ }), (value) => c.json(RenameSchema.parse(value), 200)));
12967
12682
  };
12968
12683
  /**
12969
12684
  * `POST /prisma/code-actions` handler. The quick fixes the Prisma language server offers for the
@@ -12978,26 +12693,16 @@ const postPrismaRenameRouteHandler = (c) => {
12978
12693
  * H->>U: codeActionsAt()
12979
12694
  * U-->>H: CodeActions
12980
12695
  * H-->>C: 200 CodeActions
12981
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
12982
12696
  * ```
12983
12697
  */
12984
12698
  const postPrismaCodeActionsRouteHandler = (c) => {
12985
12699
  const data = c.req.valid("json");
12986
- return Effect.runPromise(Effect.matchEffect(codeActionsAt({
12700
+ return Effect.runPromise(Effect.map(codeActionsAt({
12987
12701
  text: data.text,
12988
12702
  path: data.path,
12989
12703
  range: data.range,
12990
12704
  diagnostics: data.diagnostics
12991
- }), {
12992
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12993
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
12994
- type: "/problems/internal-server-error",
12995
- title: "Internal Server Error",
12996
- status: 500,
12997
- detail: "An unexpected error occurred.",
12998
- instance: c.req.path
12999
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13000
- }));
12705
+ }), (value) => c.json(CodeActionsSchema.parse(value), 200)));
13001
12706
  };
13002
12707
  /**
13003
12708
  * `POST /prisma/symbols` handler. The blocks of the text, as the language server's document outline
@@ -13012,24 +12717,14 @@ const postPrismaCodeActionsRouteHandler = (c) => {
13012
12717
  * H->>U: symbolsOf()
13013
12718
  * U-->>H: Symbols
13014
12719
  * H-->>C: 200 Symbols
13015
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
13016
12720
  * ```
13017
12721
  */
13018
12722
  const postPrismaSymbolsRouteHandler = (c) => {
13019
12723
  const data = c.req.valid("json");
13020
- return Effect.runPromise(Effect.matchEffect(symbolsOf({
12724
+ return Effect.runPromise(Effect.map(symbolsOf({
13021
12725
  text: data.text,
13022
12726
  path: data.path
13023
- }), {
13024
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13025
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13026
- type: "/problems/internal-server-error",
13027
- title: "Internal Server Error",
13028
- status: 500,
13029
- detail: "An unexpected error occurred.",
13030
- instance: c.req.path
13031
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13032
- }));
12727
+ }), (value) => c.json(SymbolsSchema.parse(value), 200)));
13033
12728
  };
13034
12729
  /**
13035
12730
  * `POST /prisma/references` handler. Every place the symbol at a cursor position is used, across
@@ -13044,28 +12739,26 @@ const postPrismaSymbolsRouteHandler = (c) => {
13044
12739
  * H->>U: referencesAt()
13045
12740
  * U-->>H: References
13046
12741
  * H-->>C: 200 References
13047
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
13048
12742
  * ```
13049
12743
  */
13050
12744
  const postPrismaReferencesRouteHandler = (c) => {
13051
12745
  const data = c.req.valid("json");
13052
- return Effect.runPromise(Effect.matchEffect(referencesAt({
12746
+ return Effect.runPromise(Effect.map(referencesAt({
13053
12747
  text: data.text,
13054
12748
  path: data.path,
13055
12749
  line: data.line,
13056
12750
  character: data.character
13057
- }), {
13058
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13059
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13060
- type: "/problems/internal-server-error",
13061
- title: "Internal Server Error",
13062
- status: 500,
13063
- detail: "An unexpected error occurred.",
13064
- instance: c.req.path
13065
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13066
- }));
12751
+ }), (value) => c.json(ReferencesSchema.parse(value), 200)));
13067
12752
  };
13068
12753
  // src/studio/server/handlers/docs.ts
12754
+ const checked = /* @__PURE__ */ new WeakMap();
12755
+ function checkDocs(docs) {
12756
+ const kept = checked.get(docs);
12757
+ if (kept !== void 0) return kept;
12758
+ const parsed = DocsSchema.parse(docs);
12759
+ checked.set(docs, parsed);
12760
+ return parsed;
12761
+ }
13069
12762
  /**
13070
12763
  * `GET /docs` handler. The documentation of the last schema that parsed: models, operations and
13071
12764
  * client API types.
@@ -13079,19 +12772,9 @@ const postPrismaReferencesRouteHandler = (c) => {
13079
12772
  * H->>U: readDocs()
13080
12773
  * U-->>H: Docs
13081
12774
  * H-->>C: 200 Docs
13082
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
13083
12775
  * ```
13084
12776
  */
13085
- const getDocsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readDocs(), {
13086
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13087
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13088
- type: "/problems/internal-server-error",
13089
- title: "Internal Server Error",
13090
- status: 500,
13091
- detail: "An unexpected error occurred.",
13092
- instance: c.req.path
13093
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13094
- }));
12777
+ const getDocsRouteHandler = (c) => Effect.runPromise(Effect.map(readDocs(), (value) => c.json(checkDocs(value), 200)));
13095
12778
  // src/studio/server/handlers/client.ts
13096
12779
  /**
13097
12780
  * `GET /client` handler. Load the project's Prisma Client, the first time it is asked for, and say
@@ -13106,19 +12789,9 @@ const getDocsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readDocs
13106
12789
  * H->>U: readClientStatus()
13107
12790
  * U-->>H: ClientStatus
13108
12791
  * H-->>C: 200 ClientStatus
13109
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
13110
12792
  * ```
13111
12793
  */
13112
- const getClientRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readClientStatus(), {
13113
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13114
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13115
- type: "/problems/internal-server-error",
13116
- title: "Internal Server Error",
13117
- status: 500,
13118
- detail: "An unexpected error occurred.",
13119
- instance: c.req.path
13120
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13121
- }));
12794
+ const getClientRouteHandler = (c) => Effect.runPromise(Effect.map(readClientStatus(), (value) => c.json(ClientStatusSchema.parse(value), 200)));
13122
12795
  /**
13123
12796
  * `POST /client/analyze` handler. Read the query against the schema's models, without running it:
13124
12797
  * its calls and its problems.
@@ -13132,21 +12805,11 @@ const getClientRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readCl
13132
12805
  * H->>U: analyzeClientQuery()
13133
12806
  * U-->>H: ClientAnalysis
13134
12807
  * H-->>C: 200 ClientAnalysis
13135
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
13136
12808
  * ```
13137
12809
  */
13138
12810
  const postClientAnalyzeRouteHandler = (c) => {
13139
12811
  const data = c.req.valid("json");
13140
- return Effect.runPromise(Effect.matchEffect(analyzeClientQuery({ query: data.query }), {
13141
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13142
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13143
- type: "/problems/internal-server-error",
13144
- title: "Internal Server Error",
13145
- status: 500,
13146
- detail: "An unexpected error occurred.",
13147
- instance: c.req.path
13148
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13149
- }));
12812
+ return Effect.runPromise(Effect.map(analyzeClientQuery({ query: data.query }), (value) => c.json(ClientAnalysisSchema.parse(value), 200)));
13150
12813
  };
13151
12814
  /**
13152
12815
  * `POST /client/run` handler. Run the query through the project's Prisma Client and return its
@@ -13161,13 +12824,13 @@ const postClientAnalyzeRouteHandler = (c) => {
13161
12824
  * H->>U: runClientQuery()
13162
12825
  * U-->>H: ClientResult
13163
12826
  * H-->>C: 200 ClientResult
13164
- * Note over H: on failure, Match.tag: InvalidInputError -> 422 / ClientQueryError -> 422 / ClientUnavailableError -> 503 / ContractViolationError -> 500
12827
+ * Note over H: on failure, Match.tag: InvalidInputError -> 422 / ClientQueryError -> 422 / ClientUnavailableError -> 503
13165
12828
  * ```
13166
12829
  */
13167
12830
  const postClientRunRouteHandler = (c) => {
13168
12831
  const data = c.req.valid("json");
13169
12832
  return Effect.runPromise(Effect.matchEffect(runClientQuery({ query: data.query }), {
13170
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12833
+ onSuccess: (value) => Effect.succeed(c.json(ClientResultSchema.parse(value), 200)),
13171
12834
  onFailure: (error) => Match.value(error).pipe(Match.tag("InvalidInputError", ({ field, message }) => Effect.succeed(c.json({
13172
12835
  type: "/problems/validation-failed",
13173
12836
  title: "Validation Failed",
@@ -13194,13 +12857,7 @@ const postClientRunRouteHandler = (c) => {
13194
12857
  status: 503,
13195
12858
  detail: reason,
13196
12859
  instance: c.req.path
13197
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13198
- type: "/problems/internal-server-error",
13199
- title: "Internal Server Error",
13200
- status: 500,
13201
- detail: "An unexpected error occurred.",
13202
- instance: c.req.path
13203
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12860
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13204
12861
  }));
13205
12862
  };
13206
12863
  /**
@@ -13216,7 +12873,7 @@ const postClientRunRouteHandler = (c) => {
13216
12873
  * H->>U: completeClientQuery()
13217
12874
  * U-->>H: ClientCompletions
13218
12875
  * H-->>C: 200 ClientCompletions
13219
- * Note over H: on failure, Match.tag: ClientUnavailableError -> 503 / ContractViolationError -> 500
12876
+ * Note over H: on failure, Match.tag: ClientUnavailableError -> 503
13220
12877
  * ```
13221
12878
  */
13222
12879
  const postClientCompleteRouteHandler = (c) => {
@@ -13225,20 +12882,14 @@ const postClientCompleteRouteHandler = (c) => {
13225
12882
  query: data.query,
13226
12883
  offset: data.offset
13227
12884
  }), {
13228
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12885
+ onSuccess: (value) => Effect.succeed(c.json(ClientCompletionsSchema.parse(value), 200)),
13229
12886
  onFailure: (error) => Match.value(error).pipe(Match.tag("ClientUnavailableError", ({ reason }) => Effect.succeed(c.json({
13230
12887
  type: "/problems/service-unavailable",
13231
12888
  title: "Service Unavailable",
13232
12889
  status: 503,
13233
12890
  detail: reason,
13234
12891
  instance: c.req.path
13235
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13236
- type: "/problems/internal-server-error",
13237
- title: "Internal Server Error",
13238
- status: 500,
13239
- detail: "An unexpected error occurred.",
13240
- instance: c.req.path
13241
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12892
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13242
12893
  }));
13243
12894
  };
13244
12895
  /**
@@ -13253,7 +12904,7 @@ const postClientCompleteRouteHandler = (c) => {
13253
12904
  * H->>U: detailClientCompletion()
13254
12905
  * U-->>H: ClientCompletionDetail
13255
12906
  * H-->>C: 200 ClientCompletionDetail
13256
- * Note over H: on failure, Match.tag: ClientUnavailableError -> 503 / ContractViolationError -> 500
12907
+ * Note over H: on failure, Match.tag: ClientUnavailableError -> 503
13257
12908
  * ```
13258
12909
  */
13259
12910
  const postClientCompleteDetailRouteHandler = (c) => {
@@ -13263,20 +12914,14 @@ const postClientCompleteDetailRouteHandler = (c) => {
13263
12914
  offset: data.offset,
13264
12915
  name: data.name
13265
12916
  }), {
13266
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12917
+ onSuccess: (value) => Effect.succeed(c.json(ClientCompletionDetailSchema.parse(value), 200)),
13267
12918
  onFailure: (error) => Match.value(error).pipe(Match.tag("ClientUnavailableError", ({ reason }) => Effect.succeed(c.json({
13268
12919
  type: "/problems/service-unavailable",
13269
12920
  title: "Service Unavailable",
13270
12921
  status: 503,
13271
12922
  detail: reason,
13272
12923
  instance: c.req.path
13273
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13274
- type: "/problems/internal-server-error",
13275
- title: "Internal Server Error",
13276
- status: 500,
13277
- detail: "An unexpected error occurred.",
13278
- instance: c.req.path
13279
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12924
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13280
12925
  }));
13281
12926
  };
13282
12927
  /**
@@ -13291,7 +12936,7 @@ const postClientCompleteDetailRouteHandler = (c) => {
13291
12936
  * H->>U: hoverClientQuery()
13292
12937
  * U-->>H: ClientHover
13293
12938
  * H-->>C: 200 ClientHover
13294
- * Note over H: on failure, Match.tag: ClientUnavailableError -> 503 / ContractViolationError -> 500
12939
+ * Note over H: on failure, Match.tag: ClientUnavailableError -> 503
13295
12940
  * ```
13296
12941
  */
13297
12942
  const postClientHoverRouteHandler = (c) => {
@@ -13300,20 +12945,14 @@ const postClientHoverRouteHandler = (c) => {
13300
12945
  query: data.query,
13301
12946
  offset: data.offset
13302
12947
  }), {
13303
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12948
+ onSuccess: (value) => Effect.succeed(c.json(ClientHoverSchema.parse(value), 200)),
13304
12949
  onFailure: (error) => Match.value(error).pipe(Match.tag("ClientUnavailableError", ({ reason }) => Effect.succeed(c.json({
13305
12950
  type: "/problems/service-unavailable",
13306
12951
  title: "Service Unavailable",
13307
12952
  status: 503,
13308
12953
  detail: reason,
13309
12954
  instance: c.req.path
13310
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13311
- type: "/problems/internal-server-error",
13312
- title: "Internal Server Error",
13313
- status: 500,
13314
- detail: "An unexpected error occurred.",
13315
- instance: c.req.path
13316
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12955
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13317
12956
  }));
13318
12957
  };
13319
12958
  /**
@@ -13328,7 +12967,7 @@ const postClientHoverRouteHandler = (c) => {
13328
12967
  * H->>U: signatureClientQuery()
13329
12968
  * U-->>H: ClientSignatureHelp
13330
12969
  * H-->>C: 200 ClientSignatureHelp
13331
- * Note over H: on failure, Match.tag: ClientUnavailableError -> 503 / ContractViolationError -> 500
12970
+ * Note over H: on failure, Match.tag: ClientUnavailableError -> 503
13332
12971
  * ```
13333
12972
  */
13334
12973
  const postClientSignatureRouteHandler = (c) => {
@@ -13337,20 +12976,14 @@ const postClientSignatureRouteHandler = (c) => {
13337
12976
  query: data.query,
13338
12977
  offset: data.offset
13339
12978
  }), {
13340
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
12979
+ onSuccess: (value) => Effect.succeed(c.json(ClientSignatureHelpSchema.parse(value), 200)),
13341
12980
  onFailure: (error) => Match.value(error).pipe(Match.tag("ClientUnavailableError", ({ reason }) => Effect.succeed(c.json({
13342
12981
  type: "/problems/service-unavailable",
13343
12982
  title: "Service Unavailable",
13344
12983
  status: 503,
13345
12984
  detail: reason,
13346
12985
  instance: c.req.path
13347
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13348
- type: "/problems/internal-server-error",
13349
- title: "Internal Server Error",
13350
- status: 500,
13351
- detail: "An unexpected error occurred.",
13352
- instance: c.req.path
13353
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
12986
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13354
12987
  }));
13355
12988
  };
13356
12989
  /**
@@ -13366,26 +12999,20 @@ const postClientSignatureRouteHandler = (c) => {
13366
12999
  * H->>U: checkClientQuery()
13367
13000
  * U-->>H: ClientTypeDiagnostics
13368
13001
  * H-->>C: 200 ClientTypeDiagnostics
13369
- * Note over H: on failure, Match.tag: ClientUnavailableError -> 503 / ContractViolationError -> 500
13002
+ * Note over H: on failure, Match.tag: ClientUnavailableError -> 503
13370
13003
  * ```
13371
13004
  */
13372
13005
  const postClientCheckRouteHandler = (c) => {
13373
13006
  const data = c.req.valid("json");
13374
13007
  return Effect.runPromise(Effect.matchEffect(checkClientQuery({ query: data.query }), {
13375
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13008
+ onSuccess: (value) => Effect.succeed(c.json(ClientTypeDiagnosticsSchema.parse(value), 200)),
13376
13009
  onFailure: (error) => Match.value(error).pipe(Match.tag("ClientUnavailableError", ({ reason }) => Effect.succeed(c.json({
13377
13010
  type: "/problems/service-unavailable",
13378
13011
  title: "Service Unavailable",
13379
13012
  status: 503,
13380
13013
  detail: reason,
13381
13014
  instance: c.req.path
13382
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13383
- type: "/problems/internal-server-error",
13384
- title: "Internal Server Error",
13385
- status: 500,
13386
- detail: "An unexpected error occurred.",
13387
- instance: c.req.path
13388
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13015
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13389
13016
  }));
13390
13017
  };
13391
13018
  /**
@@ -13401,13 +13028,13 @@ const postClientCheckRouteHandler = (c) => {
13401
13028
  * H->>U: formatClientQuery()
13402
13029
  * U-->>H: ClientFormatted
13403
13030
  * H-->>C: 200 ClientFormatted
13404
- * Note over H: on failure, Match.tag: FormatError -> 422 / ContractViolationError -> 500
13031
+ * Note over H: on failure, Match.tag: FormatError -> 422
13405
13032
  * ```
13406
13033
  */
13407
13034
  const postClientFormatRouteHandler = (c) => {
13408
13035
  const data = c.req.valid("json");
13409
13036
  return Effect.runPromise(Effect.matchEffect(formatClientQuery({ query: data.query }), {
13410
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13037
+ onSuccess: (value) => Effect.succeed(c.json(ClientFormattedSchema.parse(value), 200)),
13411
13038
  onFailure: (error) => Match.value(error).pipe(Match.tag("FormatError", ({ message }) => Effect.succeed(c.json({
13412
13039
  type: "/problems/validation-failed",
13413
13040
  title: "Validation Failed",
@@ -13418,13 +13045,7 @@ const postClientFormatRouteHandler = (c) => {
13418
13045
  field: "query",
13419
13046
  message
13420
13047
  }]
13421
- }, 422, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13422
- type: "/problems/internal-server-error",
13423
- title: "Internal Server Error",
13424
- status: 500,
13425
- detail: "An unexpected error occurred.",
13426
- instance: c.req.path
13427
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13048
+ }, 422, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13428
13049
  }));
13429
13050
  };
13430
13051
  /**
@@ -13440,13 +13061,13 @@ const postClientFormatRouteHandler = (c) => {
13440
13061
  * H->>U: previewClientQuery()
13441
13062
  * U-->>H: ClientPreview
13442
13063
  * H-->>C: 200 ClientPreview
13443
- * Note over H: on failure, Match.tag: InvalidInputError -> 422 / ClientQueryError -> 422 / ClientUnavailableError -> 503 / ContractViolationError -> 500
13064
+ * Note over H: on failure, Match.tag: InvalidInputError -> 422 / ClientQueryError -> 422 / ClientUnavailableError -> 503
13444
13065
  * ```
13445
13066
  */
13446
13067
  const postClientPreviewRouteHandler = (c) => {
13447
13068
  const data = c.req.valid("json");
13448
13069
  return Effect.runPromise(Effect.matchEffect(previewClientQuery({ query: data.query }), {
13449
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13070
+ onSuccess: (value) => Effect.succeed(c.json(ClientPreviewSchema.parse(value), 200)),
13450
13071
  onFailure: (error) => Match.value(error).pipe(Match.tag("InvalidInputError", ({ field, message }) => Effect.succeed(c.json({
13451
13072
  type: "/problems/validation-failed",
13452
13073
  title: "Validation Failed",
@@ -13473,13 +13094,7 @@ const postClientPreviewRouteHandler = (c) => {
13473
13094
  status: 503,
13474
13095
  detail: reason,
13475
13096
  instance: c.req.path
13476
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13477
- type: "/problems/internal-server-error",
13478
- title: "Internal Server Error",
13479
- status: 500,
13480
- detail: "An unexpected error occurred.",
13481
- instance: c.req.path
13482
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13097
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13483
13098
  }));
13484
13099
  };
13485
13100
  // src/studio/server/handlers/migrate.ts
@@ -13496,11 +13111,11 @@ const postClientPreviewRouteHandler = (c) => {
13496
13111
  * H->>U: readMigrateStatus()
13497
13112
  * U-->>H: MigrateStatus
13498
13113
  * H-->>C: 200 MigrateStatus
13499
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13114
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13500
13115
  * ```
13501
13116
  */
13502
13117
  const getMigrateRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readMigrateStatus(), {
13503
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13118
+ onSuccess: (value) => Effect.succeed(c.json(MigrateStatusSchema.parse(value), 200)),
13504
13119
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13505
13120
  type: "/problems/service-unavailable",
13506
13121
  title: "Service Unavailable",
@@ -13519,13 +13134,7 @@ const getMigrateRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readM
13519
13134
  status: 503,
13520
13135
  detail: message,
13521
13136
  instance: c.req.path
13522
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13523
- type: "/problems/internal-server-error",
13524
- title: "Internal Server Error",
13525
- status: 500,
13526
- detail: "An unexpected error occurred.",
13527
- instance: c.req.path
13528
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13137
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13529
13138
  }));
13530
13139
  /**
13531
13140
  * `GET /migrate/diff` handler. The migration that would take the database to the schema, as Prisma
@@ -13540,11 +13149,11 @@ const getMigrateRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readM
13540
13149
  * H->>U: readMigrateDiff()
13541
13150
  * U-->>H: MigrateDiff
13542
13151
  * H-->>C: 200 MigrateDiff
13543
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13152
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13544
13153
  * ```
13545
13154
  */
13546
13155
  const getMigrateDiffRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readMigrateDiff(), {
13547
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13156
+ onSuccess: (value) => Effect.succeed(c.json(MigrateDiffSchema.parse(value), 200)),
13548
13157
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13549
13158
  type: "/problems/service-unavailable",
13550
13159
  title: "Service Unavailable",
@@ -13563,13 +13172,7 @@ const getMigrateDiffRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(r
13563
13172
  status: 503,
13564
13173
  detail: message,
13565
13174
  instance: c.req.path
13566
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13567
- type: "/problems/internal-server-error",
13568
- title: "Internal Server Error",
13569
- status: 500,
13570
- detail: "An unexpected error occurred.",
13571
- instance: c.req.path
13572
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13175
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13573
13176
  }));
13574
13177
  /**
13575
13178
  * `POST /migrate/plan` handler. The migration laid out as steps that can be run one at a time, the
@@ -13584,11 +13187,11 @@ const getMigrateDiffRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(r
13584
13187
  * H->>U: planMigration()
13585
13188
  * U-->>H: MigratePlan
13586
13189
  * H-->>C: 200 MigratePlan
13587
- * Note over H: on failure, Match.tag: MigrateConfigError -> 422 / MigrateDatabaseError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13190
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 422 / MigrateDatabaseError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13588
13191
  * ```
13589
13192
  */
13590
13193
  const postMigratePlanRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(planMigration(c.req.valid("json")), {
13591
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13194
+ onSuccess: (value) => Effect.succeed(c.json(MigratePlanSchema.parse(value), 200)),
13592
13195
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13593
13196
  type: "/problems/validation-failed",
13594
13197
  title: "Validation Failed",
@@ -13617,13 +13220,7 @@ const postMigratePlanRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(
13617
13220
  status: 503,
13618
13221
  detail: message,
13619
13222
  instance: c.req.path
13620
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13621
- type: "/problems/internal-server-error",
13622
- title: "Internal Server Error",
13623
- status: 500,
13624
- detail: "An unexpected error occurred.",
13625
- instance: c.req.path
13626
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13223
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13627
13224
  }));
13628
13225
  /**
13629
13226
  * `POST /migrate/apply` handler. Runs the statements one at a time and stops at the first the
@@ -13639,24 +13236,18 @@ const postMigratePlanRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(
13639
13236
  * H->>U: applyMigrationStatements()
13640
13237
  * U-->>H: ApplyResult
13641
13238
  * H-->>C: 200 ApplyResult
13642
- * Note over H: on failure, Match.tag: DatabaseUnavailableError -> 503 / ContractViolationError -> 500
13239
+ * Note over H: on failure, Match.tag: DatabaseUnavailableError -> 503
13643
13240
  * ```
13644
13241
  */
13645
13242
  const postMigrateApplyRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(applyMigrationStatements(c.req.valid("json")), {
13646
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13243
+ onSuccess: (value) => Effect.succeed(c.json(ApplyResultSchema.parse(value), 200)),
13647
13244
  onFailure: (error) => Match.value(error).pipe(Match.tag("DatabaseUnavailableError", ({ reason }) => Effect.succeed(c.json({
13648
13245
  type: "/problems/service-unavailable",
13649
13246
  title: "Service Unavailable",
13650
13247
  status: 503,
13651
13248
  detail: reason,
13652
13249
  instance: c.req.path
13653
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13654
- type: "/problems/internal-server-error",
13655
- title: "Internal Server Error",
13656
- status: 500,
13657
- detail: "An unexpected error occurred.",
13658
- instance: c.req.path
13659
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13250
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13660
13251
  }));
13661
13252
  /**
13662
13253
  * `POST /migrate/migrations` handler. Writes a migration.sql to the migrations directory, so Prisma
@@ -13671,11 +13262,11 @@ const postMigrateApplyRouteHandler = (c) => Effect.runPromise(Effect.matchEffect
13671
13262
  * H->>U: createMigration()
13672
13263
  * U-->>H: CreatedMigration
13673
13264
  * H-->>C: 200 CreatedMigration
13674
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13265
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13675
13266
  * ```
13676
13267
  */
13677
13268
  const postMigrateMigrationsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(createMigration(c.req.valid("json")), {
13678
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13269
+ onSuccess: (value) => Effect.succeed(c.json(CreatedMigrationSchema.parse(value), 200)),
13679
13270
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13680
13271
  type: "/problems/service-unavailable",
13681
13272
  title: "Service Unavailable",
@@ -13694,13 +13285,7 @@ const postMigrateMigrationsRouteHandler = (c) => Effect.runPromise(Effect.matchE
13694
13285
  status: 503,
13695
13286
  detail: message,
13696
13287
  instance: c.req.path
13697
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13698
- type: "/problems/internal-server-error",
13699
- title: "Internal Server Error",
13700
- status: 500,
13701
- detail: "An unexpected error occurred.",
13702
- instance: c.req.path
13703
- }, 500, { "Content-Type": "application/problem+json" })))), Match.orElse((failure) => Effect.succeed(c.json({
13288
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.orElse((failure) => Effect.succeed(c.json({
13704
13289
  type: "/problems/validation-failed",
13705
13290
  title: "Validation Failed",
13706
13291
  status: 422,
@@ -13726,7 +13311,7 @@ const postMigrateMigrationsRouteHandler = (c) => Effect.runPromise(Effect.matchE
13726
13311
  * H->>U: recordMigrationApplied()
13727
13312
  * U-->>H: MigrateStatus
13728
13313
  * H-->>C: 200 MigrateStatus
13729
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13314
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13730
13315
  * ```
13731
13316
  */
13732
13317
  const postMigrateMigrationsAppliedRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(recordMigrationApplied(c.req.valid("json")), {
@@ -13749,13 +13334,7 @@ const postMigrateMigrationsAppliedRouteHandler = (c) => Effect.runPromise(Effect
13749
13334
  status: 503,
13750
13335
  detail: message,
13751
13336
  instance: c.req.path
13752
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13753
- type: "/problems/internal-server-error",
13754
- title: "Internal Server Error",
13755
- status: 500,
13756
- detail: "An unexpected error occurred.",
13757
- instance: c.req.path
13758
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13337
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13759
13338
  }));
13760
13339
  /**
13761
13340
  * `POST /migrate/migrations/rolled-back` handler. Records a migration as rolled back, for one that
@@ -13771,7 +13350,7 @@ const postMigrateMigrationsAppliedRouteHandler = (c) => Effect.runPromise(Effect
13771
13350
  * H->>U: recordMigrationRolledBack()
13772
13351
  * U-->>H: MigrateStatus
13773
13352
  * H-->>C: 200 MigrateStatus
13774
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13353
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13775
13354
  * ```
13776
13355
  */
13777
13356
  const postMigrateMigrationsRolledBackRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(recordMigrationRolledBack(c.req.valid("json")), {
@@ -13794,13 +13373,7 @@ const postMigrateMigrationsRolledBackRouteHandler = (c) => Effect.runPromise(Eff
13794
13373
  status: 503,
13795
13374
  detail: message,
13796
13375
  instance: c.req.path
13797
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13798
- type: "/problems/internal-server-error",
13799
- title: "Internal Server Error",
13800
- status: 500,
13801
- detail: "An unexpected error occurred.",
13802
- instance: c.req.path
13803
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13376
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13804
13377
  }));
13805
13378
  /**
13806
13379
  * `POST /migrate/deploy` handler. Applies every migration the database has not run yet, as `prisma
@@ -13815,11 +13388,11 @@ const postMigrateMigrationsRolledBackRouteHandler = (c) => Effect.runPromise(Eff
13815
13388
  * H->>U: deployMigrations()
13816
13389
  * U-->>H: Deployed
13817
13390
  * H-->>C: 200 Deployed
13818
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13391
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13819
13392
  * ```
13820
13393
  */
13821
13394
  const postMigrateDeployRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(deployMigrations(), {
13822
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13395
+ onSuccess: (value) => Effect.succeed(c.json(DeployedSchema.parse(value), 200)),
13823
13396
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13824
13397
  type: "/problems/service-unavailable",
13825
13398
  title: "Service Unavailable",
@@ -13838,13 +13411,7 @@ const postMigrateDeployRouteHandler = (c) => Effect.runPromise(Effect.matchEffec
13838
13411
  status: 503,
13839
13412
  detail: message,
13840
13413
  instance: c.req.path
13841
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13842
- type: "/problems/internal-server-error",
13843
- title: "Internal Server Error",
13844
- status: 500,
13845
- detail: "An unexpected error occurred.",
13846
- instance: c.req.path
13847
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13414
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13848
13415
  }));
13849
13416
  /**
13850
13417
  * `GET /migrate/decisions` handler. What has been decided on the page about the checks, as Studio
@@ -13859,11 +13426,11 @@ const postMigrateDeployRouteHandler = (c) => Effect.runPromise(Effect.matchEffec
13859
13426
  * H->>U: readMigrationDecisions()
13860
13427
  * U-->>H: MigrationDecisions
13861
13428
  * H-->>C: 200 MigrationDecisions
13862
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13429
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13863
13430
  * ```
13864
13431
  */
13865
13432
  const getMigrateDecisionsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readMigrationDecisions(), {
13866
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13433
+ onSuccess: (value) => Effect.succeed(c.json(MigrationDecisionsSchema.parse(value), 200)),
13867
13434
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13868
13435
  type: "/problems/service-unavailable",
13869
13436
  title: "Service Unavailable",
@@ -13882,13 +13449,7 @@ const getMigrateDecisionsRouteHandler = (c) => Effect.runPromise(Effect.matchEff
13882
13449
  status: 503,
13883
13450
  detail: message,
13884
13451
  instance: c.req.path
13885
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13886
- type: "/problems/internal-server-error",
13887
- title: "Internal Server Error",
13888
- status: 500,
13889
- detail: "An unexpected error occurred.",
13890
- instance: c.req.path
13891
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13452
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13892
13453
  }));
13893
13454
  /**
13894
13455
  * `PUT /migrate/decisions` handler. Keeps the decisions, so the same plan is made the next time the
@@ -13904,11 +13465,11 @@ const getMigrateDecisionsRouteHandler = (c) => Effect.runPromise(Effect.matchEff
13904
13465
  * H->>U: writeMigrationDecisions()
13905
13466
  * U-->>H: MigrationDecisions
13906
13467
  * H-->>C: 200 MigrationDecisions
13907
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13468
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13908
13469
  * ```
13909
13470
  */
13910
13471
  const putMigrateDecisionsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(writeMigrationDecisions(c.req.valid("json")), {
13911
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13472
+ onSuccess: (value) => Effect.succeed(c.json(MigrationDecisionsSchema.parse(value), 200)),
13912
13473
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13913
13474
  type: "/problems/service-unavailable",
13914
13475
  title: "Service Unavailable",
@@ -13927,13 +13488,7 @@ const putMigrateDecisionsRouteHandler = (c) => Effect.runPromise(Effect.matchEff
13927
13488
  status: 503,
13928
13489
  detail: message,
13929
13490
  instance: c.req.path
13930
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13931
- type: "/problems/internal-server-error",
13932
- title: "Internal Server Error",
13933
- status: 500,
13934
- detail: "An unexpected error occurred.",
13935
- instance: c.req.path
13936
- }, 500, { "Content-Type": "application/problem+json" })))), Match.orElse((failure) => Effect.succeed(c.json({
13491
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.orElse((failure) => Effect.succeed(c.json({
13937
13492
  type: "/problems/validation-failed",
13938
13493
  title: "Validation Failed",
13939
13494
  status: 422,
@@ -13959,11 +13514,11 @@ const putMigrateDecisionsRouteHandler = (c) => Effect.runPromise(Effect.matchEff
13959
13514
  * H->>U: readMigrateBaseline()
13960
13515
  * U-->>H: MigrateBaseline
13961
13516
  * H-->>C: 200 MigrateBaseline
13962
- * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13517
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
13963
13518
  * ```
13964
13519
  */
13965
13520
  const getMigrateBaselineRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readMigrateBaseline(), {
13966
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13521
+ onSuccess: (value) => Effect.succeed(c.json(MigrateBaselineSchema.parse(value), 200)),
13967
13522
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
13968
13523
  type: "/problems/service-unavailable",
13969
13524
  title: "Service Unavailable",
@@ -13982,13 +13537,7 @@ const getMigrateBaselineRouteHandler = (c) => Effect.runPromise(Effect.matchEffe
13982
13537
  status: 503,
13983
13538
  detail: message,
13984
13539
  instance: c.req.path
13985
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
13986
- type: "/problems/internal-server-error",
13987
- title: "Internal Server Error",
13988
- status: 500,
13989
- detail: "An unexpected error occurred.",
13990
- instance: c.req.path
13991
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13540
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
13992
13541
  }));
13993
13542
  /**
13994
13543
  * `POST /migrate/baseline` handler. Baselines the database: records the migration named and every
@@ -14003,7 +13552,7 @@ const getMigrateBaselineRouteHandler = (c) => Effect.runPromise(Effect.matchEffe
14003
13552
  * H->>U: baselineDatabase()
14004
13553
  * U-->>H: MigrateStatus
14005
13554
  * H-->>C: 200 MigrateStatus
14006
- * Note over H: on failure, Match.tag: MigrateConfigError -> 422 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13555
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 422 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
14007
13556
  * ```
14008
13557
  */
14009
13558
  const postMigrateBaselineRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(baselineDatabase(c.req.valid("json")), {
@@ -14030,13 +13579,7 @@ const postMigrateBaselineRouteHandler = (c) => Effect.runPromise(Effect.matchEff
14030
13579
  status: 503,
14031
13580
  detail: message,
14032
13581
  instance: c.req.path
14033
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
14034
- type: "/problems/internal-server-error",
14035
- title: "Internal Server Error",
14036
- status: 500,
14037
- detail: "An unexpected error occurred.",
14038
- instance: c.req.path
14039
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13582
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
14040
13583
  }));
14041
13584
  /**
14042
13585
  * `GET /migrate/migrations/{migrationName}` handler. The migration.sql of one migration of the
@@ -14051,11 +13594,11 @@ const postMigrateBaselineRouteHandler = (c) => Effect.runPromise(Effect.matchEff
14051
13594
  * H->>U: readMigrationFile()
14052
13595
  * U-->>H: MigrationFile
14053
13596
  * H-->>C: 200 MigrationFile
14054
- * Note over H: on failure, Match.tag: MigrationNotFoundError -> 404 / MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503 / ContractViolationError -> 500
13597
+ * Note over H: on failure, Match.tag: MigrationNotFoundError -> 404 / MigrateConfigError -> 503 / DatabaseUnavailableError -> 503 / MigrateEngineError -> 503
14055
13598
  * ```
14056
13599
  */
14057
13600
  const getMigrateMigrationsMigrationNameRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readMigrationFile(c.req.valid("param")), {
14058
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13601
+ onSuccess: (value) => Effect.succeed(c.json(MigrationFileSchema.parse(value), 200)),
14059
13602
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrationNotFoundError", ({ name, baseDir }) => Effect.succeed(c.json({
14060
13603
  type: "/problems/not-found",
14061
13604
  title: "Not Found",
@@ -14080,13 +13623,7 @@ const getMigrateMigrationsMigrationNameRouteHandler = (c) => Effect.runPromise(E
14080
13623
  status: 503,
14081
13624
  detail: message,
14082
13625
  instance: c.req.path
14083
- }, 503, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
14084
- type: "/problems/internal-server-error",
14085
- title: "Internal Server Error",
14086
- status: 500,
14087
- detail: "An unexpected error occurred.",
14088
- instance: c.req.path
14089
- }, 500, { "Content-Type": "application/problem+json" })))), Match.exhaustive)
13626
+ }, 503, { "Content-Type": "application/problem+json" }))), Match.exhaustive)
14090
13627
  }));
14091
13628
  /**
14092
13629
  * `POST /migrate/rehearse` handler. The migration run for real and taken back, to see before it
@@ -14102,18 +13639,11 @@ const getMigrateMigrationsMigrationNameRouteHandler = (c) => Effect.runPromise(E
14102
13639
  * H->>U: rehearse()
14103
13640
  * U-->>H: Rehearsal
14104
13641
  * H-->>C: 200 Rehearsal
14105
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
14106
13642
  * ```
14107
13643
  */
14108
13644
  const postMigrateRehearseRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(rehearse(c.req.valid("json")), {
14109
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
14110
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
14111
- type: "/problems/internal-server-error",
14112
- title: "Internal Server Error",
14113
- status: 500,
14114
- detail: "An unexpected error occurred.",
14115
- instance: c.req.path
14116
- }, 500, { "Content-Type": "application/problem+json" })))), Match.orElse((failure) => Effect.succeed(c.json({
13645
+ onSuccess: (value) => Effect.succeed(c.json(RehearsalSchema.parse(value), 200)),
13646
+ onFailure: (error) => Match.value(error).pipe(Match.orElse((failure) => Effect.succeed(c.json({
14117
13647
  type: "/problems/service-unavailable",
14118
13648
  title: "Service Unavailable",
14119
13649
  status: 503,
@@ -14134,18 +13664,11 @@ const postMigrateRehearseRouteHandler = (c) => Effect.runPromise(Effect.matchEff
14134
13664
  * H->>U: readTableCounts()
14135
13665
  * U-->>H: TableCounts
14136
13666
  * H-->>C: 200 TableCounts
14137
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
14138
13667
  * ```
14139
13668
  */
14140
13669
  const getMigrateTablesRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readTableCounts(), {
14141
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
14142
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
14143
- type: "/problems/internal-server-error",
14144
- title: "Internal Server Error",
14145
- status: 500,
14146
- detail: "An unexpected error occurred.",
14147
- instance: c.req.path
14148
- }, 500, { "Content-Type": "application/problem+json" })))), Match.orElse((failure) => Effect.succeed(c.json({
13670
+ onSuccess: (value) => Effect.succeed(c.json(TableCountsSchema.parse(value), 200)),
13671
+ onFailure: (error) => Match.value(error).pipe(Match.orElse((failure) => Effect.succeed(c.json({
14149
13672
  type: "/problems/service-unavailable",
14150
13673
  title: "Service Unavailable",
14151
13674
  status: 503,
@@ -14165,18 +13688,11 @@ const getMigrateTablesRouteHandler = (c) => Effect.runPromise(Effect.matchEffect
14165
13688
  * H->>U: readBackups()
14166
13689
  * U-->>H: Backups
14167
13690
  * H-->>C: 200 Backups
14168
- * Note over H: on failure, Match.tag: ContractViolationError -> 500
14169
13691
  * ```
14170
13692
  */
14171
13693
  const getMigrateBackupsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(readBackups(), {
14172
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
14173
- onFailure: (error) => Match.value(error).pipe(Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
14174
- type: "/problems/internal-server-error",
14175
- title: "Internal Server Error",
14176
- status: 500,
14177
- detail: "An unexpected error occurred.",
14178
- instance: c.req.path
14179
- }, 500, { "Content-Type": "application/problem+json" })))), Match.orElse((failure) => Effect.succeed(c.json({
13694
+ onSuccess: (value) => Effect.succeed(c.json(BackupsSchema.parse(value), 200)),
13695
+ onFailure: (error) => Match.value(error).pipe(Match.orElse((failure) => Effect.succeed(c.json({
14180
13696
  type: "/problems/service-unavailable",
14181
13697
  title: "Service Unavailable",
14182
13698
  status: 503,
@@ -14196,11 +13712,11 @@ const getMigrateBackupsRouteHandler = (c) => Effect.runPromise(Effect.matchEffec
14196
13712
  * H->>U: takeBackup()
14197
13713
  * U-->>H: Backup
14198
13714
  * H-->>C: 200 Backup
14199
- * Note over H: on failure, Match.tag: MigrateConfigError -> 422 / ContractViolationError -> 500
13715
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 422
14200
13716
  * ```
14201
13717
  */
14202
13718
  const postMigrateBackupsRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(takeBackup(), {
14203
- onSuccess: (value) => Effect.succeed(c.json(value, 200)),
13719
+ onSuccess: (value) => Effect.succeed(c.json(BackupSchema.parse(value), 200)),
14204
13720
  onFailure: (error) => Match.value(error).pipe(Match.tag("MigrateConfigError", ({ message }) => Effect.succeed(c.json({
14205
13721
  type: "/problems/validation-failed",
14206
13722
  title: "Validation Failed",
@@ -14211,13 +13727,7 @@ const postMigrateBackupsRouteHandler = (c) => Effect.runPromise(Effect.matchEffe
14211
13727
  field: "backup",
14212
13728
  message
14213
13729
  }]
14214
- }, 422, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
14215
- type: "/problems/internal-server-error",
14216
- title: "Internal Server Error",
14217
- status: 500,
14218
- detail: "An unexpected error occurred.",
14219
- instance: c.req.path
14220
- }, 500, { "Content-Type": "application/problem+json" })))), Match.orElse((failure) => Effect.succeed(c.json({
13730
+ }, 422, { "Content-Type": "application/problem+json" }))), Match.orElse((failure) => Effect.succeed(c.json({
14221
13731
  type: "/problems/service-unavailable",
14222
13732
  title: "Service Unavailable",
14223
13733
  status: 503,
@@ -14238,7 +13748,7 @@ const postMigrateBackupsRouteHandler = (c) => Effect.runPromise(Effect.matchEffe
14238
13748
  * H->>U: restoreFromBackup()
14239
13749
  * U-->>H: MigrateStatus
14240
13750
  * H-->>C: 200 MigrateStatus
14241
- * Note over H: on failure, Match.tag: MigrateConfigError -> 422 / ContractViolationError -> 500
13751
+ * Note over H: on failure, Match.tag: MigrateConfigError -> 422
14242
13752
  * ```
14243
13753
  */
14244
13754
  const postMigrateBackupsRestoreRouteHandler = (c) => Effect.runPromise(Effect.matchEffect(restoreFromBackup(c.req.valid("json")), {
@@ -14253,13 +13763,7 @@ const postMigrateBackupsRestoreRouteHandler = (c) => Effect.runPromise(Effect.ma
14253
13763
  field: "name",
14254
13764
  message
14255
13765
  }]
14256
- }, 422, { "Content-Type": "application/problem+json" }))), Match.tag("ContractViolationError", ({ message }) => Effect.logError("contract violation", message).pipe(Effect.as(c.json({
14257
- type: "/problems/internal-server-error",
14258
- title: "Internal Server Error",
14259
- status: 500,
14260
- detail: "An unexpected error occurred.",
14261
- instance: c.req.path
14262
- }, 500, { "Content-Type": "application/problem+json" })))), Match.orElse((failure) => Effect.succeed(c.json({
13766
+ }, 422, { "Content-Type": "application/problem+json" }))), Match.orElse((failure) => Effect.succeed(c.json({
14263
13767
  type: "/problems/service-unavailable",
14264
13768
  title: "Service Unavailable",
14265
13769
  status: 503,