apps 0.0.1-beta.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 (135) hide show
  1. package/README.md +191 -0
  2. package/check-publish.mjs +10 -0
  3. package/framework-reference.json +1 -0
  4. package/js/chunk-22WRQZT7.js +389 -0
  5. package/js/chunk-2OTCEKL2.js +29480 -0
  6. package/js/chunk-36DNRFZQ.js +34 -0
  7. package/js/chunk-3ANFZFCV.js +1799 -0
  8. package/js/chunk-7JXHF5IF.js +138 -0
  9. package/js/chunk-BCSNKUAC.js +0 -0
  10. package/js/chunk-BKVL7XAJ.js +47 -0
  11. package/js/chunk-BPEFS4YF.js +1323 -0
  12. package/js/chunk-C24KEZXR.js +59 -0
  13. package/js/chunk-D6BKYP2L.js +877 -0
  14. package/js/chunk-EP6AEUZO.js +19 -0
  15. package/js/chunk-HP7E42X6.js +1719 -0
  16. package/js/chunk-KWTCHVLT.js +284 -0
  17. package/js/chunk-LOKGDT6B.js +28 -0
  18. package/js/chunk-MLKGABMK.js +9 -0
  19. package/js/chunk-OWD2YICM.js +2486 -0
  20. package/js/chunk-Q2FD5IBM.js +899 -0
  21. package/js/chunk-R6JMJSVT.js +590 -0
  22. package/js/chunk-SBKHUC5L.js +56 -0
  23. package/js/chunk-VFUZI3NY.js +75 -0
  24. package/js/chunk-W7Q5EOTS.js +4375 -0
  25. package/js/chunk-WIDTG42X.js +171 -0
  26. package/js/chunk-X3YBZCJW.js +246 -0
  27. package/js/chunk-YDR4CPJA.js +2357 -0
  28. package/js/client.js +1023 -0
  29. package/js/contracts.js +163 -0
  30. package/js/effect.js +44 -0
  31. package/js/graphql.js +392 -0
  32. package/js/host.js +193 -0
  33. package/js/index.js +284 -0
  34. package/js/mcp/effect.js +23 -0
  35. package/js/mcp/stdio.js +123 -0
  36. package/js/mcp.js +37 -0
  37. package/js/openapi.js +246 -0
  38. package/js/operations/approval.js +9 -0
  39. package/js/react.js +37 -0
  40. package/js/storage/facet.js +546 -0
  41. package/js/ui/auth/contracts.js +19 -0
  42. package/js/ui/auth.js +28 -0
  43. package/js/ui/contracts.js +24 -0
  44. package/js/ui/serving.js +286 -0
  45. package/package.json +116 -0
  46. package/runtime.json +1 -0
  47. package/types/app-data/src/contracts/database.d.ts +193 -0
  48. package/types/app-data/src/implementation/cursor.d.ts +10 -0
  49. package/types/app-data/src/implementation/index-key.d.ts +7 -0
  50. package/types/app-data/src/implementation/promise.d.ts +68 -0
  51. package/types/app-data/src/implementation/range.d.ts +8 -0
  52. package/types/app-data/src/implementation/schema.d.ts +33 -0
  53. package/types/app-data/src/implementation/sqlite.d.ts +11 -0
  54. package/types/app-data/src/index.d.ts +4 -0
  55. package/types/apps/src/approval.d.ts +10 -0
  56. package/types/apps/src/client.d.ts +5 -0
  57. package/types/apps/src/contracts/app.d.ts +58 -0
  58. package/types/apps/src/contracts/approval.d.ts +14 -0
  59. package/types/apps/src/contracts/context.d.ts +25 -0
  60. package/types/apps/src/contracts/elicitation.d.ts +86 -0
  61. package/types/apps/src/contracts/graphql.d.ts +102 -0
  62. package/types/apps/src/contracts/host.d.ts +568 -0
  63. package/types/apps/src/contracts/http.d.ts +20 -0
  64. package/types/apps/src/contracts/live.d.ts +26 -0
  65. package/types/apps/src/contracts/mcp.d.ts +93 -0
  66. package/types/apps/src/contracts/openapi.d.ts +105 -0
  67. package/types/apps/src/contracts/operations.d.ts +30 -0
  68. package/types/apps/src/contracts/optimistic.d.ts +22 -0
  69. package/types/apps/src/contracts/provider.d.ts +96 -0
  70. package/types/apps/src/contracts/schedules.d.ts +51 -0
  71. package/types/apps/src/contracts/schema.d.ts +20 -0
  72. package/types/apps/src/contracts/storage.d.ts +68 -0
  73. package/types/apps/src/contracts/tools.d.ts +11 -0
  74. package/types/apps/src/contracts/ui-auth.d.ts +28 -0
  75. package/types/apps/src/contracts/ui.d.ts +90 -0
  76. package/types/apps/src/contracts/webhook-protocol.d.ts +102 -0
  77. package/types/apps/src/contracts/webhooks.d.ts +53 -0
  78. package/types/apps/src/contracts/workflows.d.ts +277 -0
  79. package/types/apps/src/effect.d.ts +10 -0
  80. package/types/apps/src/facet.d.ts +5 -0
  81. package/types/apps/src/graphql.d.ts +10 -0
  82. package/types/apps/src/host.d.ts +16 -0
  83. package/types/apps/src/implementation/account-operations.d.ts +32 -0
  84. package/types/apps/src/implementation/app.d.ts +40 -0
  85. package/types/apps/src/implementation/authoring.d.ts +12 -0
  86. package/types/apps/src/implementation/elicitation.d.ts +103 -0
  87. package/types/apps/src/implementation/graphql.d.ts +5 -0
  88. package/types/apps/src/implementation/host.d.ts +3 -0
  89. package/types/apps/src/implementation/http.d.ts +5 -0
  90. package/types/apps/src/implementation/live.d.ts +18 -0
  91. package/types/apps/src/implementation/mcp-call.d.ts +19 -0
  92. package/types/apps/src/implementation/mcp-client.d.ts +50 -0
  93. package/types/apps/src/implementation/mcp-stdio.d.ts +4 -0
  94. package/types/apps/src/implementation/mcp-tools.d.ts +6 -0
  95. package/types/apps/src/implementation/mcp.d.ts +4 -0
  96. package/types/apps/src/implementation/openapi-request.d.ts +11 -0
  97. package/types/apps/src/implementation/openapi.d.ts +5 -0
  98. package/types/apps/src/implementation/operations.d.ts +65 -0
  99. package/types/apps/src/implementation/optimistic.d.ts +30 -0
  100. package/types/apps/src/implementation/protocol-operations.d.ts +24 -0
  101. package/types/apps/src/implementation/provider.d.ts +16 -0
  102. package/types/apps/src/implementation/query-commit.d.ts +10 -0
  103. package/types/apps/src/implementation/schedules.d.ts +16 -0
  104. package/types/apps/src/implementation/schema.d.ts +93 -0
  105. package/types/apps/src/implementation/storage.d.ts +13 -0
  106. package/types/apps/src/implementation/ui-auth.d.ts +13 -0
  107. package/types/apps/src/implementation/ui-client.d.ts +16 -0
  108. package/types/apps/src/implementation/ui-errors.d.ts +2 -0
  109. package/types/apps/src/implementation/ui-serving.d.ts +16 -0
  110. package/types/apps/src/implementation/ui-watch.d.ts +2 -0
  111. package/types/apps/src/implementation/webhooks.d.ts +29 -0
  112. package/types/apps/src/implementation/workflow-context.d.ts +8 -0
  113. package/types/apps/src/implementation/workflow-rpc.d.ts +5 -0
  114. package/types/apps/src/implementation/workflows.d.ts +27 -0
  115. package/types/apps/src/index.d.ts +58 -0
  116. package/types/apps/src/mcp-stdio.d.ts +8 -0
  117. package/types/apps/src/mcp.d.ts +10 -0
  118. package/types/apps/src/openapi.d.ts +10 -0
  119. package/types/apps/src/react.d.ts +7 -0
  120. package/types/apps/src/ui-auth.d.ts +3 -0
  121. package/types/apps/src/ui-serving.d.ts +3 -0
  122. package/types/telemetry/src/browser-operations.d.ts +16 -0
  123. package/types/telemetry/src/browser-performance.d.ts +11 -0
  124. package/types/telemetry/src/browser-request-timing.d.ts +2 -0
  125. package/types/telemetry/src/browser.d.ts +27 -0
  126. package/types/telemetry/src/config.d.ts +83 -0
  127. package/types/telemetry/src/context.d.ts +14 -0
  128. package/types/telemetry/src/index.d.ts +9 -0
  129. package/types/telemetry/src/layer.d.ts +7 -0
  130. package/types/telemetry/src/measurements.d.ts +8 -0
  131. package/types/telemetry/src/pending-span.d.ts +7 -0
  132. package/types/telemetry/src/relay.d.ts +28 -0
  133. package/types/telemetry/src/span-attributes.d.ts +29 -0
  134. package/types/telemetry/src/trace-context.d.ts +20 -0
  135. package/types/telemetry/src/transport.d.ts +6 -0
@@ -0,0 +1,546 @@
1
+ import {
2
+ SqlClient,
3
+ defaultTransforms,
4
+ layer,
5
+ make as make3,
6
+ makeCompilerSqlite
7
+ } from "../chunk-D6BKYP2L.js";
8
+ import {
9
+ makeSqliteDatabase
10
+ } from "../chunk-R6JMJSVT.js";
11
+ import "../chunk-7JXHF5IF.js";
12
+ import {
13
+ Defect,
14
+ Effect_exports,
15
+ Scope,
16
+ Semaphore_exports,
17
+ Service,
18
+ String,
19
+ TaggedError2 as TaggedError,
20
+ Union,
21
+ add,
22
+ addFinalizer,
23
+ as,
24
+ asVoid,
25
+ assignProperty2 as assignProperty,
26
+ callback,
27
+ catchCauseFilter2 as catchCauseFilter,
28
+ die,
29
+ effectContext,
30
+ fail3 as fail,
31
+ fail4 as fail2,
32
+ fail5 as fail3,
33
+ findDefect,
34
+ flatten,
35
+ fromIteratorSucceed,
36
+ gen,
37
+ getCurrent,
38
+ getOption,
39
+ getUnsafe,
40
+ hasProperty,
41
+ identity,
42
+ isFailure2 as isFailure,
43
+ make,
44
+ make5 as make2,
45
+ map3 as map,
46
+ mapArray,
47
+ onExit,
48
+ optional,
49
+ promise,
50
+ provide2 as provide,
51
+ provideContext,
52
+ succeed4 as succeed,
53
+ suspend,
54
+ suspend2,
55
+ tap,
56
+ try_2 as try_,
57
+ uninterruptibleMask,
58
+ void_,
59
+ withFiber
60
+ } from "../chunk-2OTCEKL2.js";
61
+ import "../chunk-MLKGABMK.js";
62
+
63
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/sql/SqlError.js
64
+ var TypeId = "~effect/sql/SqlError";
65
+ var ReasonTypeId = "~effect/sql/SqlError/Reason";
66
+ var ReasonFields = {
67
+ cause: /* @__PURE__ */ Defect(),
68
+ message: /* @__PURE__ */ optional(String),
69
+ operation: /* @__PURE__ */ optional(String)
70
+ };
71
+ var ConnectionError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/ConnectionError")("ConnectionError", ReasonFields)) {
72
+ /**
73
+ * Marks this value as a structured SQL error reason for runtime guards.
74
+ *
75
+ * @since 4.0.0
76
+ */
77
+ [ReasonTypeId] = ReasonTypeId;
78
+ /**
79
+ * Indicates whether retrying the failed SQL operation may succeed.
80
+ *
81
+ * @since 4.0.0
82
+ */
83
+ get isRetryable() {
84
+ return true;
85
+ }
86
+ };
87
+ var AuthenticationError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/AuthenticationError")("AuthenticationError", ReasonFields)) {
88
+ /**
89
+ * Marks this value as a structured SQL error reason for runtime guards.
90
+ *
91
+ * @since 4.0.0
92
+ */
93
+ [ReasonTypeId] = ReasonTypeId;
94
+ /**
95
+ * Indicates whether retrying the failed SQL operation may succeed.
96
+ *
97
+ * @since 4.0.0
98
+ */
99
+ get isRetryable() {
100
+ return false;
101
+ }
102
+ };
103
+ var AuthorizationError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/AuthorizationError")("AuthorizationError", ReasonFields)) {
104
+ /**
105
+ * Marks this value as a structured SQL error reason for runtime guards.
106
+ *
107
+ * @since 4.0.0
108
+ */
109
+ [ReasonTypeId] = ReasonTypeId;
110
+ /**
111
+ * Indicates whether retrying the failed SQL operation may succeed.
112
+ *
113
+ * @since 4.0.0
114
+ */
115
+ get isRetryable() {
116
+ return false;
117
+ }
118
+ };
119
+ var SqlSyntaxError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/SqlSyntaxError")("SqlSyntaxError", ReasonFields)) {
120
+ /**
121
+ * Marks this value as a structured SQL error reason for runtime guards.
122
+ *
123
+ * @since 4.0.0
124
+ */
125
+ [ReasonTypeId] = ReasonTypeId;
126
+ /**
127
+ * Indicates whether retrying the failed SQL operation may succeed.
128
+ *
129
+ * @since 4.0.0
130
+ */
131
+ get isRetryable() {
132
+ return false;
133
+ }
134
+ };
135
+ var UniqueViolationFields = {
136
+ ...ReasonFields,
137
+ constraint: String
138
+ };
139
+ var UniqueViolation = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/UniqueViolation")("UniqueViolation", UniqueViolationFields)) {
140
+ /**
141
+ * Marks this value as a structured SQL error reason for runtime guards.
142
+ *
143
+ * @since 4.0.0
144
+ */
145
+ [ReasonTypeId] = ReasonTypeId;
146
+ /**
147
+ * Indicates whether retrying the failed SQL operation may succeed.
148
+ *
149
+ * @since 4.0.0
150
+ */
151
+ get isRetryable() {
152
+ return false;
153
+ }
154
+ };
155
+ var ConstraintError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/ConstraintError")("ConstraintError", ReasonFields)) {
156
+ /**
157
+ * Marks this value as a structured SQL error reason for runtime guards.
158
+ *
159
+ * @since 4.0.0
160
+ */
161
+ [ReasonTypeId] = ReasonTypeId;
162
+ /**
163
+ * Indicates whether retrying the failed SQL operation may succeed.
164
+ *
165
+ * @since 4.0.0
166
+ */
167
+ get isRetryable() {
168
+ return false;
169
+ }
170
+ };
171
+ var DeadlockError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/DeadlockError")("DeadlockError", ReasonFields)) {
172
+ /**
173
+ * Marks this value as a structured SQL error reason for runtime guards.
174
+ *
175
+ * @since 4.0.0
176
+ */
177
+ [ReasonTypeId] = ReasonTypeId;
178
+ /**
179
+ * Indicates whether retrying the failed SQL operation may succeed.
180
+ *
181
+ * @since 4.0.0
182
+ */
183
+ get isRetryable() {
184
+ return true;
185
+ }
186
+ };
187
+ var SerializationError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/SerializationError")("SerializationError", ReasonFields)) {
188
+ /**
189
+ * Marks this value as a structured SQL error reason for runtime guards.
190
+ *
191
+ * @since 4.0.0
192
+ */
193
+ [ReasonTypeId] = ReasonTypeId;
194
+ /**
195
+ * Indicates whether retrying the failed SQL operation may succeed.
196
+ *
197
+ * @since 4.0.0
198
+ */
199
+ get isRetryable() {
200
+ return true;
201
+ }
202
+ };
203
+ var LockTimeoutError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/LockTimeoutError")("LockTimeoutError", ReasonFields)) {
204
+ /**
205
+ * Marks this value as a structured SQL error reason for runtime guards.
206
+ *
207
+ * @since 4.0.0
208
+ */
209
+ [ReasonTypeId] = ReasonTypeId;
210
+ /**
211
+ * Indicates whether retrying the failed SQL operation may succeed.
212
+ *
213
+ * @since 4.0.0
214
+ */
215
+ get isRetryable() {
216
+ return true;
217
+ }
218
+ };
219
+ var StatementTimeoutError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/StatementTimeoutError")("StatementTimeoutError", ReasonFields)) {
220
+ /**
221
+ * Marks this value as a structured SQL error reason for runtime guards.
222
+ *
223
+ * @since 4.0.0
224
+ */
225
+ [ReasonTypeId] = ReasonTypeId;
226
+ /**
227
+ * Indicates whether retrying the failed SQL operation may succeed.
228
+ *
229
+ * @since 4.0.0
230
+ */
231
+ get isRetryable() {
232
+ return true;
233
+ }
234
+ };
235
+ var UnknownError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError/UnknownError")("UnknownError", ReasonFields)) {
236
+ /**
237
+ * Marks this value as a structured SQL error reason for runtime guards.
238
+ *
239
+ * @since 4.0.0
240
+ */
241
+ [ReasonTypeId] = ReasonTypeId;
242
+ /**
243
+ * Indicates whether retrying the failed SQL operation may succeed.
244
+ *
245
+ * @since 4.0.0
246
+ */
247
+ get isRetryable() {
248
+ return false;
249
+ }
250
+ };
251
+ var SqlErrorReason = /* @__PURE__ */ Union([ConnectionError, AuthenticationError, AuthorizationError, SqlSyntaxError, UniqueViolation, ConstraintError, DeadlockError, SerializationError, LockTimeoutError, StatementTimeoutError, UnknownError]);
252
+ var SqlError = class extends (/* @__PURE__ */ TaggedError("effect/sql/SqlError")("SqlError", {
253
+ reason: SqlErrorReason
254
+ })) {
255
+ /**
256
+ * Marks this value as the top-level SQL error wrapper for runtime guards.
257
+ *
258
+ * @since 4.0.0
259
+ */
260
+ [TypeId] = TypeId;
261
+ /**
262
+ * Exposes the structured SQL reason as the JavaScript error cause.
263
+ *
264
+ * @since 4.0.0
265
+ */
266
+ cause = this.reason;
267
+ /**
268
+ * Uses the reason message when present, otherwise falls back to the reason tag.
269
+ *
270
+ * @since 4.0.0
271
+ */
272
+ get message() {
273
+ return this.reason.message || this.reason._tag;
274
+ }
275
+ /**
276
+ * Delegates retryability to the underlying SQL error reason.
277
+ *
278
+ * @since 4.0.0
279
+ */
280
+ get isRetryable() {
281
+ return this.reason.isRetryable;
282
+ }
283
+ };
284
+ var sqliteCodeFromCause = (cause) => {
285
+ if (!hasProperty(cause, "code")) {
286
+ return void 0;
287
+ }
288
+ const code = cause.code;
289
+ return typeof code === "string" || typeof code === "number" ? code : void 0;
290
+ };
291
+ var sqliteNumericCodeFromCause = (cause) => {
292
+ const code = sqliteCodeFromCause(cause);
293
+ if (typeof code === "number") {
294
+ return code;
295
+ }
296
+ if (!hasProperty(cause, "errno")) {
297
+ return void 0;
298
+ }
299
+ const errno = cause.errno;
300
+ return typeof errno === "number" ? errno : void 0;
301
+ };
302
+ var matchesSqliteNumericCode = (cause, expected) => {
303
+ const code = sqliteCodeFromCause(cause);
304
+ if (code === expected) {
305
+ return true;
306
+ }
307
+ if (!hasProperty(cause, "errno")) {
308
+ return false;
309
+ }
310
+ return cause.errno === expected;
311
+ };
312
+ var matchesSqliteCode = (code, expected) => code === expected || code.startsWith(expected + "_");
313
+ var UNKNOWN_CONSTRAINT = "unknown";
314
+ var SQLITE_CONSTRAINT_UNIQUE = "SQLITE_CONSTRAINT_UNIQUE";
315
+ var SQLITE_CONSTRAINT_UNIQUE_CODE = 2067;
316
+ var normalizeConstraintIdentifier = (identifier) => {
317
+ if (typeof identifier !== "string") {
318
+ return UNKNOWN_CONSTRAINT;
319
+ }
320
+ const trimmed = identifier.trim();
321
+ return trimmed.length === 0 ? UNKNOWN_CONSTRAINT : trimmed;
322
+ };
323
+ var sqliteUniqueConstraintFromCause = (cause) => {
324
+ if (hasProperty(cause, "constraint")) {
325
+ return normalizeConstraintIdentifier(cause.constraint);
326
+ }
327
+ if (!hasProperty(cause, "message")) {
328
+ return UNKNOWN_CONSTRAINT;
329
+ }
330
+ const message = cause.message;
331
+ if (typeof message !== "string") {
332
+ return UNKNOWN_CONSTRAINT;
333
+ }
334
+ const prefix = "UNIQUE constraint failed:";
335
+ const index = message.indexOf(prefix);
336
+ return index === -1 ? UNKNOWN_CONSTRAINT : normalizeConstraintIdentifier(message.slice(index + prefix.length));
337
+ };
338
+ var classifySqliteError = (cause, {
339
+ message,
340
+ operation
341
+ } = {}) => {
342
+ const props = {
343
+ cause,
344
+ message,
345
+ operation
346
+ };
347
+ const code = sqliteCodeFromCause(cause);
348
+ const numericCode = sqliteNumericCodeFromCause(cause);
349
+ if (code === SQLITE_CONSTRAINT_UNIQUE || matchesSqliteNumericCode(cause, SQLITE_CONSTRAINT_UNIQUE_CODE)) {
350
+ return new UniqueViolation({
351
+ ...props,
352
+ constraint: sqliteUniqueConstraintFromCause(cause)
353
+ });
354
+ }
355
+ if (typeof code === "string") {
356
+ if (matchesSqliteCode(code, "SQLITE_AUTH")) {
357
+ return new AuthenticationError(props);
358
+ }
359
+ if (matchesSqliteCode(code, "SQLITE_PERM")) {
360
+ return new AuthorizationError(props);
361
+ }
362
+ if (matchesSqliteCode(code, "SQLITE_CONSTRAINT")) {
363
+ return new ConstraintError(props);
364
+ }
365
+ if (matchesSqliteCode(code, "SQLITE_BUSY") || matchesSqliteCode(code, "SQLITE_LOCKED")) {
366
+ return new LockTimeoutError(props);
367
+ }
368
+ if (matchesSqliteCode(code, "SQLITE_CANTOPEN")) {
369
+ return new ConnectionError(props);
370
+ }
371
+ }
372
+ if (typeof numericCode === "number") {
373
+ const code2 = numericCode & 255;
374
+ switch (code2) {
375
+ case 23:
376
+ return new AuthenticationError(props);
377
+ case 3:
378
+ return new AuthorizationError(props);
379
+ case 19:
380
+ return new ConstraintError(props);
381
+ case 5:
382
+ case 6:
383
+ return new LockTimeoutError(props);
384
+ case 14:
385
+ return new ConnectionError(props);
386
+ default:
387
+ return new UnknownError(props);
388
+ }
389
+ }
390
+ return new UnknownError(props);
391
+ };
392
+
393
+ // ../../node_modules/.bun/@effect+sql-sqlite-do@https+++pkg.pr.new+Effect-TS+effect+@effect+sql-sqlite-do@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d+e4138e778cda3d8b/node_modules/@effect/sql-sqlite-do/dist/SqliteClient.js
394
+ var ATTR_DB_SYSTEM_NAME = "db.system.name";
395
+ var classifyError = (cause, message, operation) => classifySqliteError(cause, {
396
+ message,
397
+ operation
398
+ });
399
+ var TypeId2 = "~@effect/sql-sqlite-do/SqliteClient";
400
+ var SqliteClient = /* @__PURE__ */ Service("@effect/sql-sqlite-do/SqliteClient");
401
+ var SqliteTransaction = /* @__PURE__ */ Service("@effect/sql-sqlite-do/SqliteClient/SqliteTransaction");
402
+ var unsupportedTransaction = (message, operation) => new SqlError({
403
+ reason: new UnknownError({
404
+ cause: new Error(message),
405
+ message,
406
+ operation
407
+ })
408
+ });
409
+ var makeUnsupportedWithTransaction = (message) => (_effect) => fail2(unsupportedTransaction(message, "transaction"));
410
+ var makeStorageBackedWithTransaction = (storage, connection, semaphore) => (effect) => withFiber((fiber) => {
411
+ const services = fiber.context;
412
+ const connOption = getOption(services, SqliteTransaction);
413
+ if (connOption._tag === "Some" && connOption.value[0] !== connection) {
414
+ return fail2(unsupportedTransaction("Transactions cannot use a connection from a different SQLite client", "transaction"));
415
+ }
416
+ const depth = connOption._tag === "Some" ? connOption.value[1] + 1 : 0;
417
+ const effectWithTxn = provideContext(effect, add(services, SqliteTransaction, [connection, depth]));
418
+ const transaction = callback((resume) => {
419
+ let interrupted = false;
420
+ const promise2 = storage.transaction((txn) => new Promise((resolve) => {
421
+ if (interrupted) return resolve();
422
+ resume(onExit(effectWithTxn, (exit) => {
423
+ if (isFailure(exit)) {
424
+ txn.rollback();
425
+ }
426
+ resolve();
427
+ return flatten(promise(() => promise2));
428
+ }));
429
+ })).then(() => void_, (cause) => {
430
+ const exit = fail(new SqlError({
431
+ reason: classifyError(cause, "Failed transaction", "transaction")
432
+ }));
433
+ resume(exit);
434
+ return exit;
435
+ });
436
+ return suspend(() => {
437
+ interrupted = true;
438
+ return asVoid(promise(() => promise2));
439
+ });
440
+ });
441
+ return connOption._tag === "Some" ? transaction : semaphore.withPermits(1)(transaction);
442
+ });
443
+ var make4 = (options) => gen(function* () {
444
+ const compiler = makeCompilerSqlite(options.transformQueryNames);
445
+ const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
446
+ const db = options.storage?.sql ?? options.db;
447
+ if (db === void 0) {
448
+ return yield* die("SqliteClient.make requires either a Durable Object storage or sql storage");
449
+ }
450
+ const sqlStorage = db;
451
+ const makeConnection = gen(function* () {
452
+ function* runIterator(sql, params = []) {
453
+ const cursor = sqlStorage.exec(sql, ...params);
454
+ const columns = cursor.columnNames;
455
+ for (const result of cursor.raw()) {
456
+ const obj = {};
457
+ for (let i = 0; i < columns.length; i++) {
458
+ const value = result[i];
459
+ assignProperty(obj, columns[i], value instanceof ArrayBuffer ? new Uint8Array(value) : value);
460
+ }
461
+ yield obj;
462
+ }
463
+ }
464
+ const runStatement = (sql, params = []) => try_({
465
+ try: () => Array.from(runIterator(sql, params)),
466
+ catch: (cause) => new SqlError({
467
+ reason: classifyError(cause, "Failed to execute statement", "execute")
468
+ })
469
+ });
470
+ const runValues = (sql, params = []) => try_({
471
+ try: () => Array.from(sqlStorage.exec(sql, ...params).raw(), (row) => {
472
+ for (let i = 0; i < row.length; i++) {
473
+ const value = row[i];
474
+ if (value instanceof ArrayBuffer) {
475
+ row[i] = new Uint8Array(value);
476
+ }
477
+ }
478
+ return row;
479
+ }),
480
+ catch: (cause) => new SqlError({
481
+ reason: classifyError(cause, "Failed to execute statement", "execute")
482
+ })
483
+ });
484
+ return identity({
485
+ execute(sql, params, transformRows2) {
486
+ return transformRows2 ? map(runStatement(sql, params), transformRows2) : runStatement(sql, params);
487
+ },
488
+ executeRaw(sql, params) {
489
+ return runStatement(sql, params);
490
+ },
491
+ executeValues(sql, params) {
492
+ return runValues(sql, params);
493
+ },
494
+ executeValuesUnprepared(sql, params) {
495
+ return runValues(sql, params);
496
+ },
497
+ executeUnprepared(sql, params, transformRows2) {
498
+ return transformRows2 ? map(runStatement(sql, params), transformRows2) : runStatement(sql, params);
499
+ },
500
+ executeStream(sql, params, transformRows2) {
501
+ return suspend2(() => {
502
+ const iterator = runIterator(sql, params);
503
+ return fromIteratorSucceed(iterator, 128);
504
+ }).pipe(catchCauseFilter(findDefect, (defect) => fail3(new SqlError({
505
+ reason: classifyError(defect, "Failed to execute statement", "execute")
506
+ }))), transformRows2 ? mapArray((chunk) => transformRows2(chunk)) : identity);
507
+ }
508
+ });
509
+ });
510
+ const semaphore = yield* make2(1);
511
+ const connection = yield* makeConnection;
512
+ const acquirer = semaphore.withPermits(1)(succeed(connection));
513
+ const transactionAcquirer = uninterruptibleMask((restore) => {
514
+ const fiber = getCurrent();
515
+ const scope = getUnsafe(fiber.context, Scope);
516
+ return as(tap(restore(semaphore.take(1)), () => addFinalizer(scope, semaphore.release(1))), connection);
517
+ });
518
+ const client = yield* make3({
519
+ acquirer,
520
+ compiler,
521
+ transactionAcquirer,
522
+ transactionService: SqliteTransaction,
523
+ spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
524
+ transformRows
525
+ });
526
+ return Object.assign(client, {
527
+ [TypeId2]: TypeId2,
528
+ config: options,
529
+ withTransaction: options.storage ? makeStorageBackedWithTransaction(options.storage, connection, semaphore) : makeUnsupportedWithTransaction("Transactions require Durable Object storage; pass ctx.storage as the storage option")
530
+ });
531
+ });
532
+ var layer2 = (config) => effectContext(map(make4(config), (client) => make(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide(layer));
533
+
534
+ // src/facet.ts
535
+ var facetStorage = (storage) => {
536
+ const transactions = Semaphore_exports.makeUnsafe(1);
537
+ const run = (write) => (schema, work) => Effect_exports.gen(function* () {
538
+ const sql = yield* SqlClient;
539
+ const database = yield* makeSqliteDatabase({ sql, schema, crypto });
540
+ return yield* database[write ? "mutate" : "read"](work);
541
+ }).pipe(Effect_exports.provide(layer2({ storage })), transactions.withPermits(1));
542
+ return { read: run(false), mutate: run(true) };
543
+ };
544
+ export {
545
+ facetStorage
546
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ AppReturnPath,
3
+ AppSignInApi,
4
+ AppSignInCallback,
5
+ AppSignInCode,
6
+ AppSignInId
7
+ } from "../../chunk-SBKHUC5L.js";
8
+ import "../../chunk-3ANFZFCV.js";
9
+ import "../../chunk-W7Q5EOTS.js";
10
+ import "../../chunk-36DNRFZQ.js";
11
+ import "../../chunk-2OTCEKL2.js";
12
+ import "../../chunk-MLKGABMK.js";
13
+ export {
14
+ AppReturnPath,
15
+ AppSignInApi,
16
+ AppSignInCallback,
17
+ AppSignInCode,
18
+ AppSignInId
19
+ };
package/js/ui/auth.js ADDED
@@ -0,0 +1,28 @@
1
+ import {
2
+ appPrivateHeaders,
3
+ appSignInPage,
4
+ appSignInScript
5
+ } from "../chunk-BKVL7XAJ.js";
6
+ import {
7
+ AppReturnPath,
8
+ AppSignInApi,
9
+ AppSignInCallback,
10
+ AppSignInCode,
11
+ AppSignInId
12
+ } from "../chunk-SBKHUC5L.js";
13
+ import "../chunk-3ANFZFCV.js";
14
+ import "../chunk-VFUZI3NY.js";
15
+ import "../chunk-W7Q5EOTS.js";
16
+ import "../chunk-36DNRFZQ.js";
17
+ import "../chunk-2OTCEKL2.js";
18
+ import "../chunk-MLKGABMK.js";
19
+ export {
20
+ AppReturnPath,
21
+ AppSignInApi,
22
+ AppSignInCallback,
23
+ AppSignInCode,
24
+ AppSignInId,
25
+ appPrivateHeaders,
26
+ appSignInPage,
27
+ appSignInScript
28
+ };
@@ -0,0 +1,24 @@
1
+ import {
2
+ AppUiApi,
3
+ UiContext,
4
+ UiDeploymentChanged,
5
+ UiFailed,
6
+ UiForbidden,
7
+ UiOperation,
8
+ UiSnapshot,
9
+ UiUnauthorized
10
+ } from "../chunk-3ANFZFCV.js";
11
+ import "../chunk-W7Q5EOTS.js";
12
+ import "../chunk-36DNRFZQ.js";
13
+ import "../chunk-2OTCEKL2.js";
14
+ import "../chunk-MLKGABMK.js";
15
+ export {
16
+ AppUiApi,
17
+ UiContext,
18
+ UiDeploymentChanged,
19
+ UiFailed,
20
+ UiForbidden,
21
+ UiOperation,
22
+ UiSnapshot,
23
+ UiUnauthorized
24
+ };