@maria_rcks/t1code 0.0.6 → 0.0.8

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 (112) hide show
  1. package/dist/index.mjs +29786 -1040
  2. package/dist/server/BunPTY-tfevpp75.js +114 -0
  3. package/dist/server/NodePTY-shw8pxrb.js +115 -0
  4. package/dist/server/NodeSqliteClient-1zz4vbn2.js +180 -0
  5. package/dist/server/SqliteClient-53018gfq.js +147 -0
  6. package/dist/server/index-313s4ptc.js +18 -0
  7. package/dist/server/index-8anfbrkb.js +844 -0
  8. package/dist/server/index-9kq36ye2.js +584 -0
  9. package/dist/server/index-jgecjkfd.js +34490 -0
  10. package/dist/server/index-wckvcay0.js +48 -0
  11. package/dist/server/index-wrajk4wc.js +523 -0
  12. package/dist/server/index-z7xpvjdt.js +247 -0
  13. package/dist/server/index.js +56202 -0
  14. package/dist/server/node_modules/node-pty/LICENSE +69 -0
  15. package/dist/server/node_modules/node-pty/README.md +165 -0
  16. package/dist/server/node_modules/node-pty/lib/conpty_console_list_agent.js +16 -0
  17. package/dist/server/node_modules/node-pty/lib/conpty_console_list_agent.js.map +1 -0
  18. package/dist/server/node_modules/node-pty/lib/eventEmitter2.js +47 -0
  19. package/dist/server/node_modules/node-pty/lib/eventEmitter2.js.map +1 -0
  20. package/dist/server/node_modules/node-pty/lib/eventEmitter2.test.js +30 -0
  21. package/dist/server/node_modules/node-pty/lib/eventEmitter2.test.js.map +1 -0
  22. package/dist/server/node_modules/node-pty/lib/index.js +52 -0
  23. package/dist/server/node_modules/node-pty/lib/index.js.map +1 -0
  24. package/dist/server/node_modules/node-pty/lib/interfaces.js +7 -0
  25. package/dist/server/node_modules/node-pty/lib/interfaces.js.map +1 -0
  26. package/dist/server/node_modules/node-pty/lib/shared/conout.js +11 -0
  27. package/dist/server/node_modules/node-pty/lib/shared/conout.js.map +1 -0
  28. package/dist/server/node_modules/node-pty/lib/terminal.js +190 -0
  29. package/dist/server/node_modules/node-pty/lib/terminal.js.map +1 -0
  30. package/dist/server/node_modules/node-pty/lib/terminal.test.js +139 -0
  31. package/dist/server/node_modules/node-pty/lib/terminal.test.js.map +1 -0
  32. package/dist/server/node_modules/node-pty/lib/testUtils.test.js +28 -0
  33. package/dist/server/node_modules/node-pty/lib/testUtils.test.js.map +1 -0
  34. package/dist/server/node_modules/node-pty/lib/types.js +7 -0
  35. package/dist/server/node_modules/node-pty/lib/types.js.map +1 -0
  36. package/dist/server/node_modules/node-pty/lib/unixTerminal.js +346 -0
  37. package/dist/server/node_modules/node-pty/lib/unixTerminal.js.map +1 -0
  38. package/dist/server/node_modules/node-pty/lib/unixTerminal.test.js +351 -0
  39. package/dist/server/node_modules/node-pty/lib/unixTerminal.test.js.map +1 -0
  40. package/dist/server/node_modules/node-pty/lib/utils.js +39 -0
  41. package/dist/server/node_modules/node-pty/lib/utils.js.map +1 -0
  42. package/dist/server/node_modules/node-pty/lib/windowsConoutConnection.js +125 -0
  43. package/dist/server/node_modules/node-pty/lib/windowsConoutConnection.js.map +1 -0
  44. package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.js +320 -0
  45. package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.js.map +1 -0
  46. package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.test.js +90 -0
  47. package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.test.js.map +1 -0
  48. package/dist/server/node_modules/node-pty/lib/windowsTerminal.js +199 -0
  49. package/dist/server/node_modules/node-pty/lib/windowsTerminal.js.map +1 -0
  50. package/dist/server/node_modules/node-pty/lib/windowsTerminal.test.js +219 -0
  51. package/dist/server/node_modules/node-pty/lib/windowsTerminal.test.js.map +1 -0
  52. package/dist/server/node_modules/node-pty/lib/worker/conoutSocketWorker.js +22 -0
  53. package/dist/server/node_modules/node-pty/lib/worker/conoutSocketWorker.js.map +1 -0
  54. package/dist/server/node_modules/node-pty/package.json +64 -0
  55. package/dist/server/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  56. package/dist/server/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  57. package/dist/server/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  58. package/dist/server/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  59. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
  60. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
  61. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
  62. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty.pdb +0 -0
  63. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  64. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
  65. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/pty.node +0 -0
  66. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/pty.pdb +0 -0
  67. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
  68. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
  69. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
  70. package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty.pdb +0 -0
  71. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  72. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  73. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  74. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty.pdb +0 -0
  75. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  76. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
  77. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
  78. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/pty.pdb +0 -0
  79. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
  80. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.pdb +0 -0
  81. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
  82. package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty.pdb +0 -0
  83. package/dist/server/node_modules/node-pty/typings/node-pty.d.ts +211 -0
  84. package/package.json +1 -7
  85. package/dist/server/BunPTY-3FAOkA1C.cjs +0 -91
  86. package/dist/server/BunPTY-3FAOkA1C.cjs.map +0 -1
  87. package/dist/server/BunPTY-B9Pc7ndx.mjs +0 -91
  88. package/dist/server/BunPTY-B9Pc7ndx.mjs.map +0 -1
  89. package/dist/server/NodePTY-CZNVLBpq.mjs +0 -85
  90. package/dist/server/NodePTY-CZNVLBpq.mjs.map +0 -1
  91. package/dist/server/NodePTY-CbnaoLlj.cjs +0 -86
  92. package/dist/server/NodePTY-CbnaoLlj.cjs.map +0 -1
  93. package/dist/server/NodeSqliteClient-C5fYhtpO.cjs +0 -147
  94. package/dist/server/NodeSqliteClient-C5fYhtpO.cjs.map +0 -1
  95. package/dist/server/NodeSqliteClient-COEUidVC.mjs +0 -143
  96. package/dist/server/NodeSqliteClient-COEUidVC.mjs.map +0 -1
  97. package/dist/server/SqlError-7DUB2NkG.mjs +0 -43
  98. package/dist/server/SqlError-7DUB2NkG.mjs.map +0 -1
  99. package/dist/server/SqlError-CAzXmpza.cjs +0 -48
  100. package/dist/server/SqlError-CAzXmpza.cjs.map +0 -1
  101. package/dist/server/SqliteClient-BMlcF9O1.cjs +0 -133
  102. package/dist/server/SqliteClient-BMlcF9O1.cjs.map +0 -1
  103. package/dist/server/SqliteClient-MZci3yRi.mjs +0 -129
  104. package/dist/server/SqliteClient-MZci3yRi.mjs.map +0 -1
  105. package/dist/server/index.cjs +0 -102183
  106. package/dist/server/index.cjs.map +0 -1
  107. package/dist/server/index.mjs +0 -102127
  108. package/dist/server/index.mjs.map +0 -1
  109. package/dist/server/open-BGXDmMPQ.cjs +0 -501
  110. package/dist/server/open-BGXDmMPQ.cjs.map +0 -1
  111. package/dist/server/open-BvXvp1QV.mjs +0 -492
  112. package/dist/server/open-BvXvp1QV.mjs.map +0 -1
@@ -0,0 +1,844 @@
1
+ import {
2
+ Clock,
3
+ EffectProto,
4
+ ParentSpan,
5
+ Reference,
6
+ Scope,
7
+ Service,
8
+ TracerTimingEnabled,
9
+ add,
10
+ addFinalizer1 as addFinalizer,
11
+ close,
12
+ constUndefined,
13
+ effect,
14
+ endSpan,
15
+ ensuring,
16
+ evaluate,
17
+ exit,
18
+ failCauseUnsafe,
19
+ flatMap1 as flatMap,
20
+ flow,
21
+ fnUntraced1 as fnUntraced,
22
+ fromQueue,
23
+ gen1 as gen,
24
+ get,
25
+ getOption,
26
+ hasProperty,
27
+ hash,
28
+ identifier,
29
+ isSuccess1 as isSuccess,
30
+ make3 as make,
31
+ make6 as make2,
32
+ makeSpanScoped,
33
+ makeSpanUnsafe,
34
+ map6 as map,
35
+ match,
36
+ offerUnsafe,
37
+ onExit1 as onExit,
38
+ orDie,
39
+ provide,
40
+ provideService,
41
+ provideServices,
42
+ runForkWith,
43
+ runIn,
44
+ scoped,
45
+ serviceOption,
46
+ services,
47
+ servicesWith1 as servicesWith,
48
+ succeed4 as succeed,
49
+ suspend1 as suspend,
50
+ sync1 as sync,
51
+ tap,
52
+ uninterruptibleMask1 as uninterruptibleMask,
53
+ unwrap1 as unwrap,
54
+ useSpan,
55
+ void_1 as void_,
56
+ withFiber1 as withFiber
57
+ } from "./index-jgecjkfd.js";
58
+
59
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/reactivity/Reactivity.js
60
+ class Reactivity extends (/* @__PURE__ */ Service()("effect/reactivity/Reactivity")) {
61
+ }
62
+ var make3 = /* @__PURE__ */ sync(() => {
63
+ const handlers = new Map;
64
+ const invalidateUnsafe = (keys) => {
65
+ keysToHashes(keys, (hash2) => {
66
+ const set = handlers.get(hash2);
67
+ if (set === undefined)
68
+ return;
69
+ set.forEach((run) => run());
70
+ });
71
+ };
72
+ const invalidate = (keys) => servicesWith((services2) => {
73
+ const pending = services2.mapUnsafe.get(PendingInvalidation.key);
74
+ if (pending) {
75
+ keysToHashes(keys, (hash2) => {
76
+ pending.add(hash2);
77
+ });
78
+ } else {
79
+ invalidateUnsafe(keys);
80
+ }
81
+ return void_;
82
+ });
83
+ const mutation = (keys, effect2) => tap(effect2, invalidate(keys));
84
+ const registerUnsafe = (keys, handler) => {
85
+ const resolvedKeys = [];
86
+ keysToHashes(keys, (hash2) => {
87
+ resolvedKeys.push(hash2);
88
+ let set = handlers.get(hash2);
89
+ if (set === undefined) {
90
+ set = new Set;
91
+ handlers.set(hash2, set);
92
+ }
93
+ set.add(handler);
94
+ });
95
+ return () => {
96
+ for (let i = 0;i < resolvedKeys.length; i++) {
97
+ const set = handlers.get(resolvedKeys[i]);
98
+ set.delete(handler);
99
+ if (set.size === 0) {
100
+ handlers.delete(resolvedKeys[i]);
101
+ }
102
+ }
103
+ };
104
+ };
105
+ const query = (keys, effect2) => gen(function* () {
106
+ const services2 = yield* services();
107
+ const scope = get(services2, Scope);
108
+ const results = yield* make2();
109
+ const runFork = flow(runForkWith(services2), runIn(scope));
110
+ let running = false;
111
+ let pending = false;
112
+ const handleExit = (exit2) => {
113
+ if (exit2._tag === "Failure") {
114
+ failCauseUnsafe(results, exit2.cause);
115
+ } else {
116
+ offerUnsafe(results, exit2.value);
117
+ }
118
+ if (pending) {
119
+ pending = false;
120
+ runFork(effect2).addObserver(handleExit);
121
+ } else {
122
+ running = false;
123
+ }
124
+ };
125
+ function run() {
126
+ if (running) {
127
+ pending = true;
128
+ return;
129
+ }
130
+ running = true;
131
+ runFork(effect2).addObserver(handleExit);
132
+ }
133
+ const cancel = registerUnsafe(keys, run);
134
+ yield* addFinalizer(scope, sync(cancel));
135
+ run();
136
+ return results;
137
+ });
138
+ const stream = (tables, effect2) => query(tables, effect2).pipe(map(fromQueue), unwrap);
139
+ const withBatch = (effect2) => suspend(() => {
140
+ const pending = new Set;
141
+ return effect2.pipe(provideService(PendingInvalidation, pending), onExit((_) => sync(() => {
142
+ pending.forEach((hash2) => {
143
+ const set = handlers.get(hash2);
144
+ if (set === undefined)
145
+ return;
146
+ set.forEach((run) => run());
147
+ });
148
+ })));
149
+ });
150
+ return Reactivity.of({
151
+ mutation,
152
+ query,
153
+ stream,
154
+ invalidateUnsafe,
155
+ invalidate,
156
+ registerUnsafe,
157
+ withBatch
158
+ });
159
+ });
160
+
161
+ class PendingInvalidation extends (/* @__PURE__ */ Service()("effect/reactivity/Reactivity/PendingInvalidation")) {
162
+ }
163
+ var layer = /* @__PURE__ */ effect(Reactivity)(make3);
164
+ function stringOrHash(u) {
165
+ switch (typeof u) {
166
+ case "string":
167
+ case "number":
168
+ case "bigint":
169
+ case "boolean":
170
+ return String(u);
171
+ default:
172
+ return hash(u);
173
+ }
174
+ }
175
+ var keysToHashes = (keys, f) => {
176
+ if (Array.isArray(keys)) {
177
+ for (let i = 0;i < keys.length; i++) {
178
+ f(stringOrHash(keys[i]));
179
+ }
180
+ return;
181
+ }
182
+ for (const key in keys) {
183
+ f(key);
184
+ const ids = keys[key];
185
+ for (let i = 0;i < ids.length; i++) {
186
+ f(`${key}:${stringOrHash(ids[i])}`);
187
+ }
188
+ }
189
+ };
190
+
191
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/sql/Statement.js
192
+ var FragmentTypeId = "~effect/sql/Fragment";
193
+ var fragment = (segments) => ({
194
+ [FragmentTypeId]: FragmentTypeId,
195
+ segments
196
+ });
197
+ var CurrentTransformer = /* @__PURE__ */ Reference("effect/sql/CurrentTransformer", {
198
+ defaultValue: constUndefined
199
+ });
200
+ var isFragment = (u) => hasProperty(u, FragmentTypeId);
201
+ var literal = (value, params) => ({
202
+ _tag: "Literal",
203
+ value,
204
+ params
205
+ });
206
+ var identifier2 = (value) => ({
207
+ _tag: "Identifier",
208
+ value
209
+ });
210
+ var parameter = (value) => ({
211
+ _tag: "Parameter",
212
+ value
213
+ });
214
+ var arrayHelper = (value) => ({
215
+ _tag: "ArrayHelper",
216
+ value
217
+ });
218
+ var RecordInsertHelperProto = {
219
+ _tag: "RecordInsertHelper",
220
+ returning(sql) {
221
+ const self = Object.create(Object.getPrototypeOf(this));
222
+ Object.assign(self, this, {
223
+ returningIdentifier: sql
224
+ });
225
+ return self;
226
+ }
227
+ };
228
+ var recordInsertHelper = (value) => Object.assign(Object.create(RecordInsertHelperProto), {
229
+ value,
230
+ returningIdentifier: undefined
231
+ });
232
+ var RecordUpdateHelperProto = {
233
+ ...RecordInsertHelperProto,
234
+ _tag: "RecordUpdateHelper"
235
+ };
236
+ var recordUpdateHelper = (value, alias) => Object.assign(Object.create(RecordUpdateHelperProto), {
237
+ value,
238
+ alias,
239
+ returningIdentifier: undefined
240
+ });
241
+ var RecordUpdateHelperSingleProto = {
242
+ ...RecordInsertHelperProto,
243
+ _tag: "RecordUpdateHelperSingle"
244
+ };
245
+ var recordUpdateHelperSingle = (value, omit) => Object.assign(Object.create(RecordUpdateHelperSingleProto), {
246
+ value,
247
+ omit,
248
+ returningIdentifier: undefined
249
+ });
250
+ var make4 = (acquirer, compiler, spanAttributes, transformRows) => {
251
+ const cache = transformRows === undefined ? constructorCache.noTransforms : constructorCache.transforms;
252
+ if (cache.has(acquirer)) {
253
+ return cache.get(acquirer);
254
+ }
255
+ const self = Object.assign(function sql(strings, ...args) {
256
+ if (typeof strings === "string") {
257
+ return identifier2(strings);
258
+ } else if (Array.isArray(strings) && "raw" in strings) {
259
+ return statement(acquirer, compiler, strings, args, spanAttributes, transformRows);
260
+ }
261
+ throw "absurd";
262
+ }, {
263
+ unsafe(sql, params) {
264
+ return makeUnsafe([literal(sql, params)], acquirer, compiler, spanAttributes, transformRows);
265
+ },
266
+ literal(sql) {
267
+ return fragment([literal(sql)]);
268
+ },
269
+ in: in_,
270
+ insert(value) {
271
+ return recordInsertHelper(Array.isArray(value) ? value : [value]);
272
+ },
273
+ update(value, omit) {
274
+ return recordUpdateHelperSingle(value, omit ?? []);
275
+ },
276
+ updateValues(value, alias) {
277
+ return recordUpdateHelper(value, alias);
278
+ },
279
+ and,
280
+ or,
281
+ csv,
282
+ join,
283
+ onDialect(options) {
284
+ return options[compiler.dialect]();
285
+ },
286
+ onDialectOrElse(options) {
287
+ return options[compiler.dialect] !== undefined ? options[compiler.dialect]() : options.orElse();
288
+ }
289
+ });
290
+ cache.set(acquirer, self);
291
+ return self;
292
+ };
293
+ var constructorCache = {
294
+ transforms: /* @__PURE__ */ new WeakMap,
295
+ noTransforms: /* @__PURE__ */ new WeakMap
296
+ };
297
+ var statement = (acquirer, compiler, strings, args, spanAttributes, transformRows) => {
298
+ const segments = strings[0].length > 0 ? [literal(strings[0])] : [];
299
+ for (let i = 0;i < args.length; i++) {
300
+ const arg = args[i];
301
+ if (isFragment(arg)) {
302
+ segments.push(...arg.segments);
303
+ } else if (isSegment(arg)) {
304
+ segments.push(arg);
305
+ } else {
306
+ segments.push(parameter(arg));
307
+ }
308
+ if (strings[i + 1].length > 0) {
309
+ segments.push(literal(strings[i + 1]));
310
+ }
311
+ }
312
+ return makeUnsafe(segments, acquirer, compiler, spanAttributes, transformRows);
313
+ };
314
+ function join(lit, addParens = true, fallback = "") {
315
+ const literalStatement = literal(lit);
316
+ const fallbackFragment = fragment([literal(fallback)]);
317
+ return (clauses) => {
318
+ if (clauses.length === 0) {
319
+ return fallbackFragment;
320
+ } else if (clauses.length === 1) {
321
+ return fragment(convertLiteralOrFragment(clauses[0]));
322
+ }
323
+ const segments = [];
324
+ if (addParens) {
325
+ segments.push(literal("("));
326
+ }
327
+ segments.push.apply(segments, convertLiteralOrFragment(clauses[0]));
328
+ for (let i = 1;i < clauses.length; i++) {
329
+ segments.push(literalStatement);
330
+ segments.push.apply(segments, convertLiteralOrFragment(clauses[i]));
331
+ }
332
+ if (addParens) {
333
+ segments.push(literal(")"));
334
+ }
335
+ return fragment(segments);
336
+ };
337
+ }
338
+ var and = /* @__PURE__ */ join(" AND ", true, "1=1");
339
+ var or = /* @__PURE__ */ join(" OR ", true, "1=1");
340
+ var csv = function(...args) {
341
+ if (args[args.length - 1].length === 0) {
342
+ return emptyFragment;
343
+ }
344
+ if (args.length === 1) {
345
+ return csvRaw(args[0]);
346
+ }
347
+ return fragment([literal(`${args[0]} `), ...csvRaw(args[1]).segments]);
348
+ };
349
+ var csvRaw = /* @__PURE__ */ join(",", false);
350
+ var emptyFragment = /* @__PURE__ */ fragment([/* @__PURE__ */ literal("")]);
351
+ var makeCompiler = (options) => {
352
+ const self = Object.create(CompilerProto);
353
+ self.options = options;
354
+ self.dialect = options.dialect;
355
+ self.disableTransforms = false;
356
+ return self;
357
+ };
358
+ var statementCacheSymbol = /* @__PURE__ */ Symbol.for("effect/unstable/sql/Statement/statementCache");
359
+ var statementCacheNoTransformSymbol = /* @__PURE__ */ Symbol.for("effect/unstable/sql/Statement/statementCacheNoTransform");
360
+ var CompilerProto = {
361
+ compile(statement2, withoutTransform = false, placeholderOverride) {
362
+ const opts = this.options;
363
+ withoutTransform = withoutTransform || this.disableTransforms;
364
+ const cacheSymbol = withoutTransform ? statementCacheNoTransformSymbol : statementCacheSymbol;
365
+ if (cacheSymbol in statement2) {
366
+ return statement2[cacheSymbol];
367
+ }
368
+ const segments = statement2.segments;
369
+ const len = segments.length;
370
+ let sql = "";
371
+ const binds = [];
372
+ let placeholderCount = 0;
373
+ const placeholder = placeholderOverride ?? ((u) => opts.placeholder(++placeholderCount, u));
374
+ const placeholderNoIncrement = (u) => opts.placeholder(placeholderCount, u);
375
+ const placeholders = makePlaceholdersArray(placeholder);
376
+ for (let i = 0;i < len; i++) {
377
+ const segment = segments[i];
378
+ switch (segment._tag) {
379
+ case "Literal": {
380
+ sql += segment.value;
381
+ if (segment.params) {
382
+ binds.push.apply(binds, segment.params);
383
+ }
384
+ break;
385
+ }
386
+ case "Identifier": {
387
+ sql += opts.onIdentifier(segment.value, withoutTransform);
388
+ break;
389
+ }
390
+ case "Parameter": {
391
+ sql += placeholder(segment.value);
392
+ binds.push(segment.value);
393
+ break;
394
+ }
395
+ case "ArrayHelper": {
396
+ sql += `(${placeholders(segment.value)})`;
397
+ binds.push.apply(binds, segment.value);
398
+ break;
399
+ }
400
+ case "RecordInsertHelper": {
401
+ const keys = Object.keys(segment.value[0]);
402
+ if (opts.onInsert) {
403
+ const values = new Array(segment.value.length);
404
+ let placeholders2 = "";
405
+ for (let i2 = 0;i2 < segment.value.length; i2++) {
406
+ const row = new Array(keys.length);
407
+ values[i2] = row;
408
+ placeholders2 += i2 === 0 ? "(" : ",(";
409
+ for (let j = 0;j < keys.length; j++) {
410
+ const key = keys[j];
411
+ const value = segment.value[i2][key];
412
+ const primitive = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform);
413
+ row[j] = primitive;
414
+ placeholders2 += j === 0 ? placeholder(value) : `,${placeholder(value)}`;
415
+ }
416
+ placeholders2 += ")";
417
+ }
418
+ const [s, b] = opts.onInsert(keys.map((_) => opts.onIdentifier(_, withoutTransform)), placeholders2, values, typeof segment.returningIdentifier === "string" ? [segment.returningIdentifier, []] : segment.returningIdentifier ? this.compile(segment.returningIdentifier, withoutTransform, placeholder) : undefined);
419
+ sql += s;
420
+ binds.push.apply(binds, b);
421
+ } else {
422
+ let placeholders2 = "";
423
+ for (let i2 = 0;i2 < segment.value.length; i2++) {
424
+ placeholders2 += i2 === 0 ? "(" : ",(";
425
+ for (let j = 0;j < keys.length; j++) {
426
+ const value = segment.value[i2][keys[j]];
427
+ const primitive = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform);
428
+ binds.push(primitive);
429
+ placeholders2 += j === 0 ? placeholder(value) : `,${placeholder(value)}`;
430
+ }
431
+ placeholders2 += ")";
432
+ }
433
+ sql += `${generateColumns(keys, opts.onIdentifier, withoutTransform)} VALUES ${placeholders2}`;
434
+ if (typeof segment.returningIdentifier === "string") {
435
+ sql += ` RETURNING ${segment.returningIdentifier}`;
436
+ } else if (segment.returningIdentifier) {
437
+ sql += " RETURNING ";
438
+ const [s, b] = this.compile(segment.returningIdentifier, withoutTransform, placeholder);
439
+ sql += s;
440
+ binds.push.apply(binds, b);
441
+ }
442
+ }
443
+ break;
444
+ }
445
+ case "RecordUpdateHelperSingle": {
446
+ let keys = Object.keys(segment.value);
447
+ if (segment.omit.length > 0) {
448
+ keys = keys.filter((key) => !segment.omit.includes(key));
449
+ }
450
+ if (opts.onRecordUpdateSingle) {
451
+ const [s, b] = opts.onRecordUpdateSingle(keys.map((_) => opts.onIdentifier(_, withoutTransform)), keys.map((key) => extractPrimitive(segment.value[key], opts.onCustom, placeholderNoIncrement, withoutTransform)), typeof segment.returningIdentifier === "string" ? [segment.returningIdentifier, []] : segment.returningIdentifier ? this.compile(segment.returningIdentifier, withoutTransform, placeholder) : undefined);
452
+ sql += s;
453
+ binds.push.apply(binds, b);
454
+ } else {
455
+ for (let i2 = 0, len2 = keys.length;i2 < len2; i2++) {
456
+ const column = opts.onIdentifier(keys[i2], withoutTransform);
457
+ if (i2 === 0) {
458
+ sql += `${column} = ${placeholder(segment.value[keys[i2]])}`;
459
+ } else {
460
+ sql += `, ${column} = ${placeholder(segment.value[keys[i2]])}`;
461
+ }
462
+ binds.push(extractPrimitive(segment.value[keys[i2]], opts.onCustom, placeholderNoIncrement, withoutTransform));
463
+ }
464
+ if (typeof segment.returningIdentifier === "string") {
465
+ if (this.dialect === "mssql") {
466
+ sql += ` OUTPUT ${segment.returningIdentifier === "*" ? "INSERTED.*" : segment.returningIdentifier}`;
467
+ } else {
468
+ sql += ` RETURNING ${segment.returningIdentifier}`;
469
+ }
470
+ } else if (segment.returningIdentifier) {
471
+ sql += this.dialect === "mssql" ? " OUTPUT " : " RETURNING ";
472
+ const [s, b] = this.compile(segment.returningIdentifier, withoutTransform, placeholder);
473
+ sql += s;
474
+ binds.push.apply(binds, b);
475
+ }
476
+ }
477
+ break;
478
+ }
479
+ case "RecordUpdateHelper": {
480
+ const keys = Object.keys(segment.value[0]);
481
+ const values = new Array(segment.value.length);
482
+ let placeholders2 = "";
483
+ for (let i2 = 0;i2 < segment.value.length; i2++) {
484
+ const row = new Array(keys.length);
485
+ values[i2] = row;
486
+ placeholders2 += i2 === 0 ? "(" : ",(";
487
+ for (let j = 0;j < keys.length; j++) {
488
+ const key = keys[j];
489
+ const value = segment.value[i2][key];
490
+ row[j] = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform);
491
+ placeholders2 += j === 0 ? placeholder(value) : `,${placeholder(value)}`;
492
+ }
493
+ placeholders2 += ")";
494
+ }
495
+ const [s, b] = opts.onRecordUpdate(placeholders2, segment.alias, generateColumns(keys, opts.onIdentifier, withoutTransform), values, typeof segment.returningIdentifier === "string" ? [segment.returningIdentifier, []] : segment.returningIdentifier ? this.compile(segment.returningIdentifier, withoutTransform, placeholder) : undefined);
496
+ sql += s;
497
+ binds.push.apply(binds, b);
498
+ break;
499
+ }
500
+ case "Custom": {
501
+ const [s, b] = opts.onCustom(segment, placeholder, withoutTransform);
502
+ sql += s;
503
+ binds.push.apply(binds, b);
504
+ break;
505
+ }
506
+ }
507
+ }
508
+ const result = [sql, binds];
509
+ if (placeholderOverride !== undefined) {
510
+ return result;
511
+ }
512
+ return statement2[cacheSymbol] = result;
513
+ },
514
+ get withoutTransform() {
515
+ const self = Object.create(CompilerProto);
516
+ Object.assign(self, this, {
517
+ disableTransforms: true
518
+ });
519
+ return self;
520
+ }
521
+ };
522
+ var makeCompilerSqlite = (transform) => makeCompiler({
523
+ dialect: "sqlite",
524
+ placeholder(_) {
525
+ return "?";
526
+ },
527
+ onIdentifier: transform ? function(value, withoutTransform) {
528
+ return withoutTransform ? escapeSqlite(value) : escapeSqlite(transform(value));
529
+ } : escapeSqlite,
530
+ onRecordUpdate() {
531
+ return ["", []];
532
+ },
533
+ onCustom() {
534
+ return ["", []];
535
+ }
536
+ });
537
+ function defaultEscape(c) {
538
+ const re = new RegExp(c, "g");
539
+ const double = c + c;
540
+ const dot = c + "." + c;
541
+ return function(str) {
542
+ return c + str.replace(re, double).replace(/\./g, dot) + c;
543
+ };
544
+ }
545
+ var defaultTransforms = (transformer, nested = true) => {
546
+ const transformValue = (value) => {
547
+ if (Array.isArray(value)) {
548
+ if (value.length === 0 || value[0].constructor !== Object) {
549
+ return value;
550
+ }
551
+ return array(value);
552
+ } else if (value?.constructor === Object) {
553
+ return transformObject(value);
554
+ }
555
+ return value;
556
+ };
557
+ const transformObject = (obj) => {
558
+ const newObj = {};
559
+ for (const key in obj) {
560
+ newObj[transformer(key)] = transformValue(obj[key]);
561
+ }
562
+ return newObj;
563
+ };
564
+ const transformArrayNested = (rows) => {
565
+ const newRows = new Array(rows.length);
566
+ for (let i = 0, len = rows.length;i < len; i++) {
567
+ const row = rows[i];
568
+ if (Array.isArray(row)) {
569
+ newRows[i] = transformArrayNested(row);
570
+ } else {
571
+ const obj = {};
572
+ for (const key in row) {
573
+ obj[transformer(key)] = transformValue(row[key]);
574
+ }
575
+ newRows[i] = obj;
576
+ }
577
+ }
578
+ return newRows;
579
+ };
580
+ const transformArray = (rows) => {
581
+ const newRows = new Array(rows.length);
582
+ for (let i = 0, len = rows.length;i < len; i++) {
583
+ const row = rows[i];
584
+ if (Array.isArray(row)) {
585
+ newRows[i] = transformArray(row);
586
+ } else {
587
+ const obj = {};
588
+ for (const key in row) {
589
+ obj[transformer(key)] = row[key];
590
+ }
591
+ newRows[i] = obj;
592
+ }
593
+ }
594
+ return newRows;
595
+ };
596
+ const array = nested ? transformArrayNested : transformArray;
597
+ return {
598
+ value: transformValue,
599
+ object: transformObject,
600
+ array
601
+ };
602
+ };
603
+ var ATTR_DB_OPERATION_NAME = "db.operation.name";
604
+ var ATTR_DB_QUERY_TEXT = "db.query.text";
605
+ var makeUnsafe = (segments, acquirer, compiler, spanAttributes, transformRows) => {
606
+ const self = Object.create(StatementProto);
607
+ self.segments = segments;
608
+ self.acquirer = acquirer;
609
+ self.compiler = compiler;
610
+ self.spanAttributes = spanAttributes;
611
+ self.transformRows = transformRows;
612
+ return self;
613
+ };
614
+ var StatementProto = {
615
+ ...EffectProto,
616
+ [identifier]: "Statement",
617
+ [FragmentTypeId]: FragmentTypeId,
618
+ withConnection(operation, f, withoutTransform = false) {
619
+ return useSpan("sql.execute", {
620
+ kind: "client"
621
+ }, (span) => this.withConnectionSpan(operation, f, withoutTransform, span));
622
+ },
623
+ withConnectionSpan(operation, f, withoutTransform, span) {
624
+ return withStatement(this, span, (statement2) => {
625
+ const [sql, params] = statement2.compile(withoutTransform);
626
+ for (const [key, value] of this.spanAttributes) {
627
+ span.attribute(key, value);
628
+ }
629
+ span.attribute(ATTR_DB_OPERATION_NAME, operation);
630
+ span.attribute(ATTR_DB_QUERY_TEXT, sql);
631
+ return scoped(flatMap(this.acquirer, (_) => f(_, sql, params)));
632
+ });
633
+ },
634
+ get withoutTransform() {
635
+ return this.withConnection("executeWithoutTransform", (connection, sql, params) => connection.execute(sql, params, undefined), true);
636
+ },
637
+ get raw() {
638
+ return this.withConnection("executeRaw", (connection, sql, params) => connection.executeRaw(sql, params), true);
639
+ },
640
+ get stream() {
641
+ const self = this;
642
+ return unwrap(flatMap(makeSpanScoped("sql.execute", {
643
+ kind: "client"
644
+ }), (span) => withStatement(self, span, (statement2) => {
645
+ const [sql, params] = statement2.compile();
646
+ for (const [key, value] of self.spanAttributes) {
647
+ span.attribute(key, value);
648
+ }
649
+ span.attribute(ATTR_DB_OPERATION_NAME, "executeStream");
650
+ span.attribute(ATTR_DB_QUERY_TEXT, sql);
651
+ return map(self.acquirer, (_) => _.executeStream(sql, params, self.transformRows));
652
+ })));
653
+ },
654
+ get values() {
655
+ return this.withConnection("executeValues", (connection, sql, params) => connection.executeValues(sql, params));
656
+ },
657
+ get unprepared() {
658
+ const self = this;
659
+ return self.withConnection("executeUnprepared", (connection, sql, params) => connection.executeUnprepared(sql, params, self.transformRows));
660
+ },
661
+ compile(withoutTransform) {
662
+ return this.compiler.compile(this, withoutTransform ?? false);
663
+ },
664
+ [evaluate](fiber) {
665
+ const span = makeSpanUnsafe(fiber, "sql.execute", {
666
+ kind: "client"
667
+ });
668
+ const clock = fiber.getRef(Clock);
669
+ const timingEnabled = fiber.getRef(TracerTimingEnabled);
670
+ return onExit(this.withConnectionSpan("execute", (connection, sql, params) => connection.execute(sql, params, this.transformRows), false, span), (exit2) => endSpan(span, exit2, clock, timingEnabled));
671
+ },
672
+ toJSON() {
673
+ const [sql, params] = this.compile();
674
+ return {
675
+ _id: "Statement",
676
+ segments: this.segments,
677
+ sql,
678
+ params
679
+ };
680
+ }
681
+ };
682
+ var withStatement = (self, span, f) => withFiber((fiber) => {
683
+ const transform = fiber.getRef(CurrentTransformer);
684
+ if (transform === undefined) {
685
+ return f(self);
686
+ }
687
+ return flatMap(transform(self, make4(self.acquirer, self.compiler, self.spanAttributes, self.transformRows), fiber, span), f);
688
+ });
689
+ var isSegment = (u) => {
690
+ if (!hasProperty(u, "_tag")) {
691
+ return false;
692
+ }
693
+ switch (u._tag) {
694
+ case "Literal":
695
+ case "Parameter":
696
+ case "ArrayHelper":
697
+ case "RecordInsertHelper":
698
+ case "RecordUpdateHelper":
699
+ case "RecordUpdateHelperSingle":
700
+ case "Identifier":
701
+ case "Custom":
702
+ return true;
703
+ default:
704
+ return false;
705
+ }
706
+ };
707
+ function convertLiteralOrFragment(clause) {
708
+ if (typeof clause === "string") {
709
+ return [literal(clause)];
710
+ }
711
+ return clause.segments;
712
+ }
713
+ var makePlaceholdersArray = (evaluate2) => (values) => {
714
+ if (values.length === 0) {
715
+ return "";
716
+ }
717
+ let result = evaluate2(values[0]);
718
+ for (let i = 1;i < values.length; i++) {
719
+ result += `,${evaluate2(values[i])}`;
720
+ }
721
+ return result;
722
+ };
723
+ var generateColumns = (keys, escape, withoutTransform) => {
724
+ if (keys.length === 0) {
725
+ return "()";
726
+ }
727
+ let str = `(${escape(keys[0], withoutTransform)}`;
728
+ for (let i = 1;i < keys.length; i++) {
729
+ str += `,${escape(keys[i], withoutTransform)}`;
730
+ }
731
+ return str + ")";
732
+ };
733
+ var extractPrimitive = (value, onCustom, placeholder, withoutTransform) => {
734
+ if (value === undefined) {
735
+ return null;
736
+ } else if (isFragment(value)) {
737
+ const head = value.segments[0];
738
+ if (head._tag === "Custom") {
739
+ const compiled = onCustom(head, placeholder, withoutTransform);
740
+ return compiled[1][0] ?? null;
741
+ } else if (head._tag === "Parameter") {
742
+ return head.value;
743
+ }
744
+ return null;
745
+ }
746
+ return value;
747
+ };
748
+ var escapeSqlite = /* @__PURE__ */ defaultEscape('"');
749
+ function in_() {
750
+ if (arguments.length === 1) {
751
+ return arrayHelper(arguments[0]);
752
+ }
753
+ const column = arguments[0];
754
+ const values = arguments[1];
755
+ return values.length === 0 ? neverFragment : fragment([identifier2(column), literal(" IN "), arrayHelper(values)]);
756
+ }
757
+ var neverFragment = /* @__PURE__ */ fragment([/* @__PURE__ */ literal("1=0")]);
758
+
759
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/sql/SqlClient.js
760
+ var TypeId = "~effect/sql/SqlClient";
761
+ var SqlClient = /* @__PURE__ */ Service("effect/sql/SqlClient");
762
+ var make5 = /* @__PURE__ */ fnUntraced(function* (options) {
763
+ const getConnection = flatMap(serviceOption(TransactionConnection), match({
764
+ onNone: () => options.acquirer,
765
+ onSome: ([conn]) => succeed(conn)
766
+ }));
767
+ const beginTransaction = options.beginTransaction ?? "BEGIN";
768
+ const commit = options.commit ?? "COMMIT";
769
+ const savepoint = options.savepoint ?? ((name) => `SAVEPOINT ${name}`);
770
+ const rollback = options.rollback ?? "ROLLBACK";
771
+ const rollbackSavepoint = options.rollbackSavepoint ?? ((name) => `ROLLBACK TO SAVEPOINT ${name}`);
772
+ const transactionAcquirer = options.transactionAcquirer ?? options.acquirer;
773
+ const withTransaction = makeWithTransaction({
774
+ transactionService: TransactionConnection,
775
+ spanAttributes: options.spanAttributes,
776
+ acquireConnection: flatMap(make(), (scope) => map(provide(transactionAcquirer, scope), (conn) => [scope, conn])),
777
+ begin: (conn) => conn.executeUnprepared(beginTransaction, [], undefined),
778
+ savepoint: (conn, id) => conn.executeUnprepared(savepoint(`effect_sql_${id}`), [], undefined),
779
+ commit: (conn) => conn.executeUnprepared(commit, [], undefined),
780
+ rollback: (conn) => conn.executeUnprepared(rollback, [], undefined),
781
+ rollbackSavepoint: (conn, id) => conn.executeUnprepared(rollbackSavepoint(`effect_sql_${id}`), [], undefined)
782
+ });
783
+ const reactivity = yield* Reactivity;
784
+ const client = Object.assign(make4(getConnection, options.compiler, options.spanAttributes, options.transformRows), {
785
+ [TypeId]: TypeId,
786
+ safe: undefined,
787
+ withTransaction,
788
+ reserve: transactionAcquirer,
789
+ withoutTransforms() {
790
+ if (options.transformRows === undefined) {
791
+ return this;
792
+ }
793
+ const statement2 = make4(getConnection, options.compiler.withoutTransform, options.spanAttributes, undefined);
794
+ const client2 = Object.assign(statement2, {
795
+ ...this,
796
+ ...statement2
797
+ });
798
+ client2.safe = client2;
799
+ client2.withoutTransforms = () => client2;
800
+ return client2;
801
+ },
802
+ reactive: options.reactiveQueue ? (keys, effect2) => options.reactiveQueue(keys, effect2).pipe(map(fromQueue), unwrap) : reactivity.stream,
803
+ reactiveMailbox: options.reactiveQueue ?? reactivity.query
804
+ });
805
+ client.safe = client;
806
+ return client;
807
+ });
808
+ var makeWithTransaction = (options) => (effect2) => uninterruptibleMask((restore) => useSpan("sql.transaction", {
809
+ kind: "client"
810
+ }, (span) => withFiber((fiber) => {
811
+ for (const [key, value] of options.spanAttributes) {
812
+ span.attribute(key, value);
813
+ }
814
+ const services2 = fiber.services;
815
+ const clock = fiber.getRef(Clock);
816
+ const connOption = getOption(services2, options.transactionService);
817
+ const conn = connOption._tag === "Some" ? succeed([undefined, connOption.value[0]]) : options.acquireConnection;
818
+ const id = connOption._tag === "Some" ? connOption.value[1] + 1 : 0;
819
+ return flatMap(conn, ([scope, conn2]) => (id === 0 ? options.begin(conn2) : options.savepoint(conn2, id)).pipe(flatMap(() => provideServices(restore(effect2), add(services2, options.transactionService, [conn2, id]).pipe(add(ParentSpan, span)))), exit, flatMap((exit2) => {
820
+ let effect3;
821
+ if (isSuccess(exit2)) {
822
+ if (id === 0) {
823
+ span.event("db.transaction.commit", clock.currentTimeNanosUnsafe());
824
+ effect3 = orDie(options.commit(conn2));
825
+ } else {
826
+ span.event("db.transaction.savepoint", clock.currentTimeNanosUnsafe());
827
+ effect3 = void_;
828
+ }
829
+ } else {
830
+ span.event("db.transaction.rollback", clock.currentTimeNanosUnsafe());
831
+ effect3 = orDie(id > 0 ? options.rollbackSavepoint(conn2, id) : options.rollback(conn2));
832
+ }
833
+ const withScope = scope !== undefined ? ensuring(effect3, close(scope, exit2)) : effect3;
834
+ return flatMap(withScope, () => exit2);
835
+ })));
836
+ })));
837
+
838
+ class TransactionConnection extends (/* @__PURE__ */ Service()("effect/sql/SqlClient/TransactionConnection")) {
839
+ }
840
+ var SafeIntegers = /* @__PURE__ */ Reference("effect/sql/SqlClient/SafeIntegers", {
841
+ defaultValue: () => false
842
+ });
843
+
844
+ export { layer, makeCompilerSqlite, defaultTransforms, SqlClient, make5 as make, SafeIntegers };