apps 0.0.1-beta.34 → 0.0.1-beta.36

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 (91) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-OX233L7N.js → chunk-4U2VUDET.js} +2 -2
  3. package/js/{chunk-HW3DPBZR.js → chunk-556EWA6P.js} +3 -2
  4. package/js/{chunk-UMCMZFXW.js → chunk-73AV3JVU.js} +1 -1
  5. package/js/{chunk-QKVZGWGZ.js → chunk-A2NN45C7.js} +7 -7
  6. package/js/{chunk-6ZJ2H6P4.js → chunk-A4O72Z3A.js} +298 -190
  7. package/js/{chunk-FBBXFFFJ.js → chunk-BI45HZWM.js} +2 -2
  8. package/js/{chunk-DXGWKNTQ.js → chunk-BI6R577B.js} +2 -2
  9. package/js/{chunk-QUEPZ67T.js → chunk-BKJDZYK7.js} +3 -3
  10. package/js/{chunk-QZD2RZ4S.js → chunk-CZLCA2O4.js} +8 -8
  11. package/js/{chunk-IU6OK5G2.js → chunk-ENJCQWVF.js} +3 -3
  12. package/js/{chunk-DASNNAP4.js → chunk-HDAQBRT5.js} +391 -14
  13. package/js/{chunk-EXGKN554.js → chunk-IJQ5LE74.js} +9805 -9254
  14. package/js/{chunk-5JVNM3CQ.js → chunk-IU7CCCUC.js} +12 -12
  15. package/js/{chunk-Q7Q5JTRW.js → chunk-JU7F4PRK.js} +2 -2
  16. package/js/{chunk-CJY5X26R.js → chunk-KOOJUMLR.js} +86 -50
  17. package/js/{chunk-ETLILMHY.js → chunk-KZFV3WCJ.js} +21 -19
  18. package/js/{chunk-ZOY7PDMI.js → chunk-NHCFIWN5.js} +1 -1
  19. package/js/chunk-NHUHTWAF.js +0 -0
  20. package/js/{chunk-QYM4STZW.js → chunk-PHO7HXTC.js} +149 -353
  21. package/js/{chunk-O3OAFU7Q.js → chunk-POOIHRPF.js} +2 -2
  22. package/js/{chunk-AUFVX4KM.js → chunk-RSNZDT4L.js} +2 -2
  23. package/js/{chunk-EPUWF4ZG.js → chunk-SRB2WDU7.js} +3 -3
  24. package/js/{chunk-MFHUR5SB.js → chunk-TADLIUEU.js} +4 -4
  25. package/js/{chunk-5OM6HBNU.js → chunk-UBAKWXAJ.js} +20 -29
  26. package/js/chunk-V5DWGYRK.js +268 -0
  27. package/js/{chunk-MYH3QZ4L.js → chunk-WAGGHNWH.js} +23 -15
  28. package/js/{chunk-GZ4UHXRT.js → chunk-WDBUOIWV.js} +3 -3
  29. package/js/{chunk-PUBNIORL.js → chunk-WMVTBHGK.js} +2 -2
  30. package/js/{chunk-DSUKW6KJ.js → chunk-XEXUHXC3.js} +296 -174
  31. package/js/{chunk-6KG4DZD7.js → chunk-Y3XN4X4Q.js} +1 -1
  32. package/js/{chunk-UKMIHP2G.js → chunk-YW333DH3.js} +4 -4
  33. package/js/{chunk-O4QOPXQT.js → chunk-ZQWDOHEO.js} +31 -24
  34. package/js/client.js +12 -11
  35. package/js/contracts.js +14 -11
  36. package/js/effect.js +23 -21
  37. package/js/graphql.js +25 -23
  38. package/js/host.js +23 -21
  39. package/js/index.js +16 -14
  40. package/js/mcp/effect.js +25 -23
  41. package/js/mcp/stdio.js +25 -23
  42. package/js/mcp.js +27 -25
  43. package/js/openapi.js +22 -21
  44. package/js/react.js +3 -3
  45. package/js/skills/effect.js +6 -5
  46. package/js/skills.js +60 -45
  47. package/js/storage/facet.js +19 -345
  48. package/js/ui/auth/contracts.js +2 -2
  49. package/js/ui/auth.js +5 -5
  50. package/js/ui/contracts.js +6 -5
  51. package/js/ui/serving.js +10 -9
  52. package/package.json +3 -3
  53. package/runtime.json +1 -1
  54. package/types/app-data/src/implementation/sqlite.d.ts +1 -1
  55. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  56. package/types/apps/src/contracts/host.d.ts +10 -6
  57. package/types/apps/src/contracts/mcp.d.ts +6 -1
  58. package/types/apps/src/contracts/openapi.d.ts +1 -1
  59. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  60. package/types/apps/src/contracts/protocols/1.d.ts +12 -5
  61. package/types/apps/src/contracts/protocols/2.d.ts +5 -5
  62. package/types/apps/src/contracts/protocols/3.d.ts +5 -6
  63. package/types/apps/src/contracts/protocols/4.d.ts +5 -6
  64. package/types/apps/src/contracts/protocols/5.d.ts +7 -7
  65. package/types/apps/src/contracts/protocols/6.d.ts +7 -7
  66. package/types/apps/src/contracts/protocols/7.d.ts +7 -7
  67. package/types/apps/src/contracts/protocols/8.d.ts +17 -6
  68. package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
  69. package/types/apps/src/contracts/skills.d.ts +5 -0
  70. package/types/apps/src/contracts/ui.d.ts +1 -1
  71. package/types/apps/src/implementation/failure-detail.d.ts +4 -3
  72. package/types/apps/src/implementation/live.d.ts +2 -2
  73. package/types/apps/src/implementation/mcp-client.d.ts +1 -1
  74. package/types/apps/src/implementation/mcp.d.ts +1 -1
  75. package/types/apps/src/implementation/network.d.ts +1 -1
  76. package/types/apps/src/implementation/openapi-compile.d.ts +1 -1
  77. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  78. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  79. package/types/apps/src/implementation/router-catalog.d.ts +2 -3
  80. package/types/apps/src/implementation/skills.d.ts +8 -8
  81. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  82. package/types/apps/src/implementation/ui-client.d.ts +1 -1
  83. package/types/apps/src/implementation/ui-serving.d.ts +1 -1
  84. package/types/apps/src/react.d.ts +1 -1
  85. package/types/apps/src/skills.d.ts +2 -1
  86. package/types/telemetry/src/browser-operations.d.ts +1 -1
  87. package/types/telemetry/src/browser.d.ts +2 -2
  88. package/types/telemetry/src/layer.d.ts +2 -2
  89. package/types/telemetry/src/relay.d.ts +2 -2
  90. package/types/telemetry/src/transport.d.ts +1 -1
  91. package/types/utils/src/api-error.d.ts +1 -1
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Schema_exports
3
- } from "./chunk-EXGKN554.js";
3
+ } from "./chunk-IJQ5LE74.js";
4
4
 
5
5
  // src/contracts/schema.ts
6
6
  var JsonValue = Schema_exports.Json;
7
7
  var JsonObject = Schema_exports.Record(Schema_exports.String, JsonValue);
8
8
  var AccountId = Schema_exports.String.pipe(
9
- Schema_exports.check(Schema_exports.isStartsWith("acc_"), Schema_exports.isMinLength(5)),
9
+ Schema_exports.check(Schema_exports.isStartingWith("acc_"), Schema_exports.isMinLength(5)),
10
10
  Schema_exports.brand("acc")
11
11
  );
12
12
  var HttpUrl = Schema_exports.String.check(
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  AccountId
3
- } from "./chunk-FBBXFFFJ.js";
3
+ } from "./chunk-BI45HZWM.js";
4
4
  import {
5
5
  Schema_exports
6
- } from "./chunk-EXGKN554.js";
6
+ } from "./chunk-IJQ5LE74.js";
7
7
 
8
8
  // src/contracts/failure.ts
9
9
  var maxFailureMessageLength = 2048;
@@ -3,15 +3,15 @@ import {
3
3
  RouterKey,
4
4
  RouterMeta,
5
5
  reservedRouterKeys
6
- } from "./chunk-DSUKW6KJ.js";
6
+ } from "./chunk-XEXUHXC3.js";
7
7
  import {
8
8
  decoderOf,
9
9
  schemaArgument
10
- } from "./chunk-O3OAFU7Q.js";
10
+ } from "./chunk-POOIHRPF.js";
11
11
  import {
12
12
  Effect_exports,
13
13
  Schema_exports
14
- } from "./chunk-EXGKN554.js";
14
+ } from "./chunk-IJQ5LE74.js";
15
15
 
16
16
  // src/implementation/authoring.ts
17
17
  var NativeCallback = /* @__PURE__ */ Symbol("apps.NativeCallback");
@@ -1,34 +1,34 @@
1
1
  import {
2
2
  promiseTable
3
- } from "./chunk-5JVNM3CQ.js";
3
+ } from "./chunk-IU7CCCUC.js";
4
4
  import {
5
5
  declaredOperations,
6
6
  fromPromise,
7
7
  nativeOperation,
8
8
  nativeRouter
9
- } from "./chunk-QUEPZ67T.js";
9
+ } from "./chunk-BKJDZYK7.js";
10
10
  import {
11
11
  ScheduleTiming
12
- } from "./chunk-DSUKW6KJ.js";
12
+ } from "./chunk-XEXUHXC3.js";
13
13
  import {
14
14
  DatabaseSchema
15
- } from "./chunk-UMCMZFXW.js";
15
+ } from "./chunk-73AV3JVU.js";
16
16
  import {
17
17
  decoderOf,
18
18
  isSchema,
19
19
  schemaArgument,
20
20
  storageFieldOf
21
- } from "./chunk-O3OAFU7Q.js";
21
+ } from "./chunk-POOIHRPF.js";
22
22
  import {
23
23
  AppStorageUnavailable
24
- } from "./chunk-6KG4DZD7.js";
24
+ } from "./chunk-Y3XN4X4Q.js";
25
25
  import {
26
26
  JsonValue
27
- } from "./chunk-FBBXFFFJ.js";
27
+ } from "./chunk-BI45HZWM.js";
28
28
  import {
29
29
  Effect_exports,
30
30
  Schema_exports
31
- } from "./chunk-EXGKN554.js";
31
+ } from "./chunk-IJQ5LE74.js";
32
32
 
33
33
  // src/contracts/http.ts
34
34
  var ResponseStatusError = class extends Schema_exports.TaggedError()(
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  ProviderError,
3
3
  maxUpstreamMessageLength
4
- } from "./chunk-DXGWKNTQ.js";
4
+ } from "./chunk-BI6R577B.js";
5
5
  import {
6
6
  AccountId
7
- } from "./chunk-FBBXFFFJ.js";
7
+ } from "./chunk-BI45HZWM.js";
8
8
  import {
9
9
  Option_exports,
10
10
  Schema_exports
11
- } from "./chunk-EXGKN554.js";
11
+ } from "./chunk-IJQ5LE74.js";
12
12
 
13
13
  // src/implementation/upstream-error.ts
14
14
  var ErrorToken = Schema_exports.String.check(Schema_exports.isPattern(/^[A-Za-z0-9._-]{1,128}$/));
@@ -1,13 +1,18 @@
1
1
  import {
2
2
  Clock,
3
+ Defect,
3
4
  ParentSpan,
4
5
  Prototype,
5
6
  Reference,
6
7
  Scope,
7
8
  Service,
9
+ String as String2,
10
+ TaggedError2 as TaggedError,
8
11
  TracerTimingEnabled,
12
+ Union,
9
13
  add,
10
14
  addFinalizer,
15
+ andThen,
11
16
  assignProperty,
12
17
  close,
13
18
  constUndefined,
@@ -16,6 +21,7 @@ import {
16
21
  dual,
17
22
  effect,
18
23
  endSpan,
24
+ failCause,
19
25
  failCauseUnsafe,
20
26
  flatMap2 as flatMap,
21
27
  flow,
@@ -31,15 +37,17 @@ import {
31
37
  identity,
32
38
  isSuccess2 as isSuccess,
33
39
  make3 as make,
34
- make4 as make2,
40
+ make5 as make2,
35
41
  makeSpanScoped,
36
42
  makeSpanUnsafe,
37
43
  makeUnsafe3 as makeUnsafe,
38
44
  map3 as map,
39
45
  match,
40
46
  offerUnsafe,
47
+ onError,
41
48
  onExit,
42
49
  onExitPrimitive,
50
+ optional,
43
51
  orDie,
44
52
  provide,
45
53
  provideContext,
@@ -58,9 +66,9 @@ import {
58
66
  useSpan,
59
67
  void_2 as void_,
60
68
  withFiber
61
- } from "./chunk-EXGKN554.js";
69
+ } from "./chunk-IJQ5LE74.js";
62
70
 
63
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/Reactivity.js
71
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/reactivity/Reactivity.js
64
72
  var TypeId = "~effect/reactivity/Reactivity";
65
73
  var Reactivity = /* @__PURE__ */ Service("effect/reactivity/Reactivity");
66
74
  var make3 = /* @__PURE__ */ sync(() => {
@@ -108,9 +116,9 @@ var make3 = /* @__PURE__ */ sync(() => {
108
116
  };
109
117
  const query = (keys, effect2) => gen(function* () {
110
118
  const services = yield* context();
111
- const scope = get(services, Scope);
119
+ const scope2 = get(services, Scope);
112
120
  const results = yield* make2();
113
- const runFork = flow(runForkWith(services), runIn(scope));
121
+ const runFork = flow(runForkWith(services), runIn(scope2));
114
122
  let running = false;
115
123
  let pending = false;
116
124
  const handleExit = (exit) => {
@@ -135,7 +143,7 @@ var make3 = /* @__PURE__ */ sync(() => {
135
143
  runFork(effect2).addObserver(handleExit);
136
144
  }
137
145
  const cancel = registerUnsafe(keys, run);
138
- yield* addFinalizer(scope, sync(cancel));
146
+ yield* addFinalizer(scope2, sync(cancel));
139
147
  run();
140
148
  return results;
141
149
  });
@@ -193,7 +201,363 @@ var keysToHashes = (keys, f) => {
193
201
  }
194
202
  };
195
203
 
196
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/sql/Statement.js
204
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/sql/SqlError.js
205
+ var TypeId2 = "~effect/sql/SqlError";
206
+ var ReasonTypeId = "~effect/sql/SqlError/Reason";
207
+ var ReasonFields = {
208
+ cause: /* @__PURE__ */ Defect(),
209
+ message: /* @__PURE__ */ optional(String2),
210
+ operation: /* @__PURE__ */ optional(String2)
211
+ };
212
+ var ConnectionError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/ConnectionError")("ConnectionError", ReasonFields)) {
213
+ /**
214
+ * Marks this value as a structured SQL error reason for runtime guards.
215
+ *
216
+ * @stability unstable
217
+ * @since 4.0.0
218
+ */
219
+ [ReasonTypeId] = ReasonTypeId;
220
+ /**
221
+ * Indicates whether retrying the failed SQL operation may succeed.
222
+ *
223
+ * @stability unstable
224
+ * @since 4.0.0
225
+ */
226
+ get isRetryable() {
227
+ return true;
228
+ }
229
+ };
230
+ var AuthenticationError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/AuthenticationError")("AuthenticationError", ReasonFields)) {
231
+ /**
232
+ * Marks this value as a structured SQL error reason for runtime guards.
233
+ *
234
+ * @stability unstable
235
+ * @since 4.0.0
236
+ */
237
+ [ReasonTypeId] = ReasonTypeId;
238
+ /**
239
+ * Indicates whether retrying the failed SQL operation may succeed.
240
+ *
241
+ * @stability unstable
242
+ * @since 4.0.0
243
+ */
244
+ get isRetryable() {
245
+ return false;
246
+ }
247
+ };
248
+ var AuthorizationError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/AuthorizationError")("AuthorizationError", ReasonFields)) {
249
+ /**
250
+ * Marks this value as a structured SQL error reason for runtime guards.
251
+ *
252
+ * @stability unstable
253
+ * @since 4.0.0
254
+ */
255
+ [ReasonTypeId] = ReasonTypeId;
256
+ /**
257
+ * Indicates whether retrying the failed SQL operation may succeed.
258
+ *
259
+ * @stability unstable
260
+ * @since 4.0.0
261
+ */
262
+ get isRetryable() {
263
+ return false;
264
+ }
265
+ };
266
+ var SqlSyntaxError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/SqlSyntaxError")("SqlSyntaxError", ReasonFields)) {
267
+ /**
268
+ * Marks this value as a structured SQL error reason for runtime guards.
269
+ *
270
+ * @stability unstable
271
+ * @since 4.0.0
272
+ */
273
+ [ReasonTypeId] = ReasonTypeId;
274
+ /**
275
+ * Indicates whether retrying the failed SQL operation may succeed.
276
+ *
277
+ * @stability unstable
278
+ * @since 4.0.0
279
+ */
280
+ get isRetryable() {
281
+ return false;
282
+ }
283
+ };
284
+ var UniqueViolationFields = {
285
+ ...ReasonFields,
286
+ constraint: String2
287
+ };
288
+ var UniqueViolation = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/UniqueViolation")("UniqueViolation", UniqueViolationFields)) {
289
+ /**
290
+ * Marks this value as a structured SQL error reason for runtime guards.
291
+ *
292
+ * @stability unstable
293
+ * @since 4.0.0
294
+ */
295
+ [ReasonTypeId] = ReasonTypeId;
296
+ /**
297
+ * Indicates whether retrying the failed SQL operation may succeed.
298
+ *
299
+ * @stability unstable
300
+ * @since 4.0.0
301
+ */
302
+ get isRetryable() {
303
+ return false;
304
+ }
305
+ };
306
+ var ConstraintError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/ConstraintError")("ConstraintError", ReasonFields)) {
307
+ /**
308
+ * Marks this value as a structured SQL error reason for runtime guards.
309
+ *
310
+ * @stability unstable
311
+ * @since 4.0.0
312
+ */
313
+ [ReasonTypeId] = ReasonTypeId;
314
+ /**
315
+ * Indicates whether retrying the failed SQL operation may succeed.
316
+ *
317
+ * @stability unstable
318
+ * @since 4.0.0
319
+ */
320
+ get isRetryable() {
321
+ return false;
322
+ }
323
+ };
324
+ var DeadlockError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/DeadlockError")("DeadlockError", ReasonFields)) {
325
+ /**
326
+ * Marks this value as a structured SQL error reason for runtime guards.
327
+ *
328
+ * @stability unstable
329
+ * @since 4.0.0
330
+ */
331
+ [ReasonTypeId] = ReasonTypeId;
332
+ /**
333
+ * Indicates whether retrying the failed SQL operation may succeed.
334
+ *
335
+ * @stability unstable
336
+ * @since 4.0.0
337
+ */
338
+ get isRetryable() {
339
+ return true;
340
+ }
341
+ };
342
+ var SerializationError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/SerializationError")("SerializationError", ReasonFields)) {
343
+ /**
344
+ * Marks this value as a structured SQL error reason for runtime guards.
345
+ *
346
+ * @stability unstable
347
+ * @since 4.0.0
348
+ */
349
+ [ReasonTypeId] = ReasonTypeId;
350
+ /**
351
+ * Indicates whether retrying the failed SQL operation may succeed.
352
+ *
353
+ * @stability unstable
354
+ * @since 4.0.0
355
+ */
356
+ get isRetryable() {
357
+ return true;
358
+ }
359
+ };
360
+ var LockTimeoutError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/LockTimeoutError")("LockTimeoutError", ReasonFields)) {
361
+ /**
362
+ * Marks this value as a structured SQL error reason for runtime guards.
363
+ *
364
+ * @stability unstable
365
+ * @since 4.0.0
366
+ */
367
+ [ReasonTypeId] = ReasonTypeId;
368
+ /**
369
+ * Indicates whether retrying the failed SQL operation may succeed.
370
+ *
371
+ * @stability unstable
372
+ * @since 4.0.0
373
+ */
374
+ get isRetryable() {
375
+ return true;
376
+ }
377
+ };
378
+ var StatementTimeoutError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/StatementTimeoutError")("StatementTimeoutError", ReasonFields)) {
379
+ /**
380
+ * Marks this value as a structured SQL error reason for runtime guards.
381
+ *
382
+ * @stability unstable
383
+ * @since 4.0.0
384
+ */
385
+ [ReasonTypeId] = ReasonTypeId;
386
+ /**
387
+ * Indicates whether retrying the failed SQL operation may succeed.
388
+ *
389
+ * @stability unstable
390
+ * @since 4.0.0
391
+ */
392
+ get isRetryable() {
393
+ return true;
394
+ }
395
+ };
396
+ var UnknownError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/UnknownError")("UnknownError", ReasonFields)) {
397
+ /**
398
+ * Marks this value as a structured SQL error reason for runtime guards.
399
+ *
400
+ * @stability unstable
401
+ * @since 4.0.0
402
+ */
403
+ [ReasonTypeId] = ReasonTypeId;
404
+ /**
405
+ * Indicates whether retrying the failed SQL operation may succeed.
406
+ *
407
+ * @stability unstable
408
+ * @since 4.0.0
409
+ */
410
+ get isRetryable() {
411
+ return false;
412
+ }
413
+ };
414
+ var SqlErrorReason = /* @__PURE__ */ Union([ConnectionError, AuthenticationError, AuthorizationError, SqlSyntaxError, UniqueViolation, ConstraintError, DeadlockError, SerializationError, LockTimeoutError, StatementTimeoutError, UnknownError]);
415
+ var SqlError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError")("SqlError", {
416
+ reason: SqlErrorReason
417
+ })) {
418
+ /**
419
+ * Marks this value as the top-level SQL error wrapper for runtime guards.
420
+ *
421
+ * @stability unstable
422
+ * @since 4.0.0
423
+ */
424
+ [TypeId2] = TypeId2;
425
+ /**
426
+ * Exposes the structured SQL reason as the JavaScript error cause.
427
+ *
428
+ * @stability unstable
429
+ * @since 4.0.0
430
+ */
431
+ cause = this.reason;
432
+ /**
433
+ * Uses the reason message when present, otherwise falls back to the reason tag.
434
+ *
435
+ * @stability unstable
436
+ * @since 4.0.0
437
+ */
438
+ get message() {
439
+ return this.reason.message || this.reason._tag;
440
+ }
441
+ /**
442
+ * Delegates retryability to the underlying SQL error reason.
443
+ *
444
+ * @stability unstable
445
+ * @since 4.0.0
446
+ */
447
+ get isRetryable() {
448
+ return this.reason.isRetryable;
449
+ }
450
+ };
451
+ var sqliteCodeFromCause = (cause) => {
452
+ if (!hasProperty(cause, "code")) {
453
+ return void 0;
454
+ }
455
+ const code = cause.code;
456
+ return typeof code === "string" || typeof code === "number" ? code : void 0;
457
+ };
458
+ var sqliteNumericCodeFromCause = (cause) => {
459
+ const code = sqliteCodeFromCause(cause);
460
+ if (typeof code === "number") {
461
+ return code;
462
+ }
463
+ if (!hasProperty(cause, "errno")) {
464
+ return void 0;
465
+ }
466
+ const errno = cause.errno;
467
+ return typeof errno === "number" ? errno : void 0;
468
+ };
469
+ var matchesSqliteNumericCode = (cause, expected) => {
470
+ const code = sqliteCodeFromCause(cause);
471
+ if (code === expected) {
472
+ return true;
473
+ }
474
+ if (!hasProperty(cause, "errno")) {
475
+ return false;
476
+ }
477
+ return cause.errno === expected;
478
+ };
479
+ var matchesSqliteCode = (code, expected) => code === expected || code.startsWith(expected + "_");
480
+ var UNKNOWN_CONSTRAINT = "unknown";
481
+ var SQLITE_CONSTRAINT_UNIQUE = "SQLITE_CONSTRAINT_UNIQUE";
482
+ var SQLITE_CONSTRAINT_UNIQUE_CODE = 2067;
483
+ var normalizeConstraintIdentifier = (identifier2) => {
484
+ if (typeof identifier2 !== "string") {
485
+ return UNKNOWN_CONSTRAINT;
486
+ }
487
+ const trimmed = identifier2.trim();
488
+ return trimmed.length === 0 ? UNKNOWN_CONSTRAINT : trimmed;
489
+ };
490
+ var sqliteUniqueConstraintFromCause = (cause) => {
491
+ if (hasProperty(cause, "constraint")) {
492
+ return normalizeConstraintIdentifier(cause.constraint);
493
+ }
494
+ if (!hasProperty(cause, "message")) {
495
+ return UNKNOWN_CONSTRAINT;
496
+ }
497
+ const message = cause.message;
498
+ if (typeof message !== "string") {
499
+ return UNKNOWN_CONSTRAINT;
500
+ }
501
+ const prefix = "UNIQUE constraint failed:";
502
+ const index = message.indexOf(prefix);
503
+ return index === -1 ? UNKNOWN_CONSTRAINT : normalizeConstraintIdentifier(message.slice(index + prefix.length));
504
+ };
505
+ var classifySqliteError = (cause, {
506
+ message,
507
+ operation
508
+ } = {}) => {
509
+ const props = {
510
+ cause,
511
+ message,
512
+ operation
513
+ };
514
+ const code = sqliteCodeFromCause(cause);
515
+ const numericCode = sqliteNumericCodeFromCause(cause);
516
+ if (code === SQLITE_CONSTRAINT_UNIQUE || matchesSqliteNumericCode(cause, SQLITE_CONSTRAINT_UNIQUE_CODE)) {
517
+ return new UniqueViolation({
518
+ ...props,
519
+ constraint: sqliteUniqueConstraintFromCause(cause)
520
+ });
521
+ }
522
+ if (typeof code === "string") {
523
+ if (matchesSqliteCode(code, "SQLITE_AUTH")) {
524
+ return new AuthenticationError(props);
525
+ }
526
+ if (matchesSqliteCode(code, "SQLITE_PERM")) {
527
+ return new AuthorizationError(props);
528
+ }
529
+ if (matchesSqliteCode(code, "SQLITE_CONSTRAINT")) {
530
+ return new ConstraintError(props);
531
+ }
532
+ if (matchesSqliteCode(code, "SQLITE_BUSY") || matchesSqliteCode(code, "SQLITE_LOCKED")) {
533
+ return new LockTimeoutError(props);
534
+ }
535
+ if (matchesSqliteCode(code, "SQLITE_CANTOPEN")) {
536
+ return new ConnectionError(props);
537
+ }
538
+ }
539
+ if (typeof numericCode === "number") {
540
+ const code2 = numericCode & 255;
541
+ switch (code2) {
542
+ case 23:
543
+ return new AuthenticationError(props);
544
+ case 3:
545
+ return new AuthorizationError(props);
546
+ case 19:
547
+ return new ConstraintError(props);
548
+ case 5:
549
+ case 6:
550
+ return new LockTimeoutError(props);
551
+ case 14:
552
+ return new ConnectionError(props);
553
+ default:
554
+ return new UnknownError(props);
555
+ }
556
+ }
557
+ return new UnknownError(props);
558
+ };
559
+
560
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/sql/Statement.js
197
561
  var FragmentTypeId = "~effect/sql/Statement/Fragment";
198
562
  var fragment = (segments) => ({
199
563
  [FragmentTypeId]: FragmentTypeId,
@@ -773,8 +1137,8 @@ function in_() {
773
1137
  }
774
1138
  var neverFragment = /* @__PURE__ */ fragment([/* @__PURE__ */ literal("1=0")]);
775
1139
 
776
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/sql/SqlClient.js
777
- var TypeId2 = "~effect/sql/SqlClient";
1140
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/sql/SqlClient.js
1141
+ var TypeId3 = "~effect/sql/SqlClient";
778
1142
  var SqlClient = /* @__PURE__ */ Service("effect/sql/SqlClient");
779
1143
  var clientIdCounter = 0;
780
1144
  var transactionSemaphoreIdCounter = 0;
@@ -787,6 +1151,7 @@ var make5 = /* @__PURE__ */ fnUntraced(function* (options) {
787
1151
  const beginTransaction = options.beginTransaction ?? "BEGIN";
788
1152
  const commit = options.commit ?? "COMMIT";
789
1153
  const savepoint = options.savepoint ?? ((name) => `SAVEPOINT ${name}`);
1154
+ const releaseSavepoint = options.releaseSavepoint;
790
1155
  const rollback = options.rollback ?? "ROLLBACK";
791
1156
  const rollbackSavepoint = options.rollbackSavepoint ?? ((name) => `ROLLBACK TO SAVEPOINT ${name}`);
792
1157
  const transactionAcquirer = options.transactionAcquirer ?? options.acquirer;
@@ -794,10 +1159,12 @@ var make5 = /* @__PURE__ */ fnUntraced(function* (options) {
794
1159
  const withTransaction = makeWithTransaction({
795
1160
  transactionService,
796
1161
  spanAttributes: options.spanAttributes,
797
- acquireConnection: flatMap(make(), (scope) => map(provide(transactionAcquirer, scope), (conn) => [scope, conn])),
1162
+ acquireConnection: flatMap(make(), (scope2) => provide(transactionAcquirer, scope2).pipe(onError((cause) => close(scope2, failCause(cause))), map((conn) => [scope2, conn]))),
798
1163
  begin: (conn) => control(conn, beginTransaction),
799
1164
  savepoint: (conn, id) => control(conn, savepoint(`effect_sql_${id}`)),
800
- commit: (conn) => control(conn, commit),
1165
+ releaseSavepoint: releaseSavepoint ? (conn, id) => control(conn, releaseSavepoint(`effect_sql_${id}`)) : void 0,
1166
+ commit: typeof commit === "string" ? (conn) => control(conn, commit) : commit,
1167
+ onCommitFailure: options.onCommitFailure,
801
1168
  rollback: (conn) => control(conn, rollback),
802
1169
  rollbackSavepoint: (conn, id) => control(conn, rollbackSavepoint(`effect_sql_${id}`))
803
1170
  });
@@ -807,7 +1174,7 @@ var make5 = /* @__PURE__ */ fnUntraced(function* (options) {
807
1174
  onSome: ([conn]) => f(conn)
808
1175
  }));
809
1176
  const client = Object.assign(make4(getConnection, options.compiler, options.spanAttributes, options.transformRows, borrower), {
810
- [TypeId2]: TypeId2,
1177
+ [TypeId3]: TypeId3,
811
1178
  safe: void 0,
812
1179
  withTransaction,
813
1180
  transactionService,
@@ -844,12 +1211,16 @@ var makeWithTransaction = (options) => {
844
1211
  const connOption = getOption(services, options.transactionService);
845
1212
  const conn = connOption._tag === "Some" ? succeed([void 0, connOption.value[0]]) : options.acquireConnection;
846
1213
  const id = connOption._tag === "Some" ? connOption.value[1] + 1 : 0;
847
- const transaction = flatMap(conn, ([scope, conn2]) => (id === 0 ? options.begin(conn2) : options.savepoint(conn2, id)).pipe(flatMap(() => onExitPrimitive(provideContext(restore(effect2), services.pipe(add(options.transactionService, [conn2, id]), add(transactionSemaphore, makeUnsafe(1)), add(ParentSpan, span))), (exit) => {
1214
+ const transaction = flatMap(conn, ([scope2, conn2]) => (id === 0 ? options.begin(conn2) : options.savepoint(conn2, id)).pipe(flatMap(() => onExitPrimitive(provideContext(restore(effect2), services.pipe(add(options.transactionService, [conn2, id]), add(transactionSemaphore, makeUnsafe(1)), add(ParentSpan, span))), (exit) => {
848
1215
  let effect3;
849
1216
  if (isSuccess(exit)) {
850
1217
  if (id === 0) {
851
1218
  span.event("db.transaction.commit", clock.currentTimeNanosUnsafe());
1219
+ const onCommitFailure = options.onCommitFailure;
852
1220
  effect3 = orDie(options.commit(conn2));
1221
+ if (onCommitFailure) {
1222
+ effect3 = onError(effect3, () => orDie(onCommitFailure(conn2)));
1223
+ }
853
1224
  } else {
854
1225
  span.event("db.transaction.savepoint", clock.currentTimeNanosUnsafe());
855
1226
  effect3 = void_;
@@ -858,8 +1229,11 @@ var makeWithTransaction = (options) => {
858
1229
  span.event("db.transaction.rollback", clock.currentTimeNanosUnsafe());
859
1230
  effect3 = orDie(id > 0 ? options.rollbackSavepoint(conn2, id) : options.rollback(conn2));
860
1231
  }
1232
+ if (id > 0 && options.releaseSavepoint) {
1233
+ effect3 = andThen(effect3, orDie(options.releaseSavepoint(conn2, id)));
1234
+ }
861
1235
  return flatMap(effect3, () => exit);
862
- }, true)), scope ? (eff) => onExitPrimitive(eff, (exit) => close(scope, exit), true) : identity));
1236
+ }, true)), scope2 ? (eff) => onExitPrimitive(eff, (exit) => close(scope2, exit), true) : identity));
863
1237
  return id === 0 ? transaction : getUnsafe(services, transactionSemaphore).withPermit(transaction);
864
1238
  })));
865
1239
  };
@@ -870,6 +1244,9 @@ export {
870
1244
  mutation,
871
1245
  invalidate,
872
1246
  layer,
1247
+ UnknownError,
1248
+ SqlError,
1249
+ classifySqliteError,
873
1250
  makeCompilerSqlite,
874
1251
  defaultTransforms,
875
1252
  SqlClient,