@maria_rcks/t1code 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +29526 -872
- package/dist/server/BunPTY-tfevpp75.js +114 -0
- package/dist/server/NodePTY-shw8pxrb.js +115 -0
- package/dist/server/NodeSqliteClient-1zz4vbn2.js +180 -0
- package/dist/server/SqliteClient-53018gfq.js +147 -0
- package/dist/server/index-313s4ptc.js +18 -0
- package/dist/server/index-8anfbrkb.js +844 -0
- package/dist/server/index-9kq36ye2.js +584 -0
- package/dist/server/index-jgecjkfd.js +34490 -0
- package/dist/server/index-wckvcay0.js +48 -0
- package/dist/server/index-wrajk4wc.js +523 -0
- package/dist/server/index-z7xpvjdt.js +247 -0
- package/dist/server/index.js +56202 -0
- package/dist/server/node_modules/node-pty/LICENSE +69 -0
- package/dist/server/node_modules/node-pty/README.md +165 -0
- package/dist/server/node_modules/node-pty/lib/conpty_console_list_agent.js +16 -0
- package/dist/server/node_modules/node-pty/lib/conpty_console_list_agent.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/eventEmitter2.js +47 -0
- package/dist/server/node_modules/node-pty/lib/eventEmitter2.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/eventEmitter2.test.js +30 -0
- package/dist/server/node_modules/node-pty/lib/eventEmitter2.test.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/index.js +52 -0
- package/dist/server/node_modules/node-pty/lib/index.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/interfaces.js +7 -0
- package/dist/server/node_modules/node-pty/lib/interfaces.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/shared/conout.js +11 -0
- package/dist/server/node_modules/node-pty/lib/shared/conout.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/terminal.js +190 -0
- package/dist/server/node_modules/node-pty/lib/terminal.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/terminal.test.js +139 -0
- package/dist/server/node_modules/node-pty/lib/terminal.test.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/testUtils.test.js +28 -0
- package/dist/server/node_modules/node-pty/lib/testUtils.test.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/types.js +7 -0
- package/dist/server/node_modules/node-pty/lib/types.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/unixTerminal.js +346 -0
- package/dist/server/node_modules/node-pty/lib/unixTerminal.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/unixTerminal.test.js +351 -0
- package/dist/server/node_modules/node-pty/lib/unixTerminal.test.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/utils.js +39 -0
- package/dist/server/node_modules/node-pty/lib/utils.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/windowsConoutConnection.js +125 -0
- package/dist/server/node_modules/node-pty/lib/windowsConoutConnection.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.js +320 -0
- package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.test.js +90 -0
- package/dist/server/node_modules/node-pty/lib/windowsPtyAgent.test.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/windowsTerminal.js +199 -0
- package/dist/server/node_modules/node-pty/lib/windowsTerminal.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/windowsTerminal.test.js +219 -0
- package/dist/server/node_modules/node-pty/lib/windowsTerminal.test.js.map +1 -0
- package/dist/server/node_modules/node-pty/lib/worker/conoutSocketWorker.js +22 -0
- package/dist/server/node_modules/node-pty/lib/worker/conoutSocketWorker.js.map +1 -0
- package/dist/server/node_modules/node-pty/package.json +64 -0
- package/dist/server/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/pty.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/pty.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-arm64/winpty.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/pty.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.pdb +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
- package/dist/server/node_modules/node-pty/prebuilds/win32-x64/winpty.pdb +0 -0
- package/dist/server/node_modules/node-pty/typings/node-pty.d.ts +211 -0
- package/package.json +1 -7
- package/dist/server/BunPTY-3FAOkA1C.cjs +0 -91
- package/dist/server/BunPTY-3FAOkA1C.cjs.map +0 -1
- package/dist/server/BunPTY-B9Pc7ndx.mjs +0 -91
- package/dist/server/BunPTY-B9Pc7ndx.mjs.map +0 -1
- package/dist/server/NodePTY-CZNVLBpq.mjs +0 -85
- package/dist/server/NodePTY-CZNVLBpq.mjs.map +0 -1
- package/dist/server/NodePTY-CbnaoLlj.cjs +0 -86
- package/dist/server/NodePTY-CbnaoLlj.cjs.map +0 -1
- package/dist/server/NodeSqliteClient-C5fYhtpO.cjs +0 -147
- package/dist/server/NodeSqliteClient-C5fYhtpO.cjs.map +0 -1
- package/dist/server/NodeSqliteClient-COEUidVC.mjs +0 -143
- package/dist/server/NodeSqliteClient-COEUidVC.mjs.map +0 -1
- package/dist/server/SqlError-7DUB2NkG.mjs +0 -43
- package/dist/server/SqlError-7DUB2NkG.mjs.map +0 -1
- package/dist/server/SqlError-CAzXmpza.cjs +0 -48
- package/dist/server/SqlError-CAzXmpza.cjs.map +0 -1
- package/dist/server/SqliteClient-BMlcF9O1.cjs +0 -133
- package/dist/server/SqliteClient-BMlcF9O1.cjs.map +0 -1
- package/dist/server/SqliteClient-MZci3yRi.mjs +0 -129
- package/dist/server/SqliteClient-MZci3yRi.mjs.map +0 -1
- package/dist/server/index.cjs +0 -102183
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.mjs +0 -102127
- package/dist/server/index.mjs.map +0 -1
- package/dist/server/open-BGXDmMPQ.cjs +0 -501
- package/dist/server/open-BGXDmMPQ.cjs.map +0 -1
- package/dist/server/open-BvXvp1QV.mjs +0 -492
- package/dist/server/open-BvXvp1QV.mjs.map +0 -1
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { $ as identity, A as map, B as void_, C as as, D as flatMap, E as fail, F as succeed, G as Scope, I as sync, J as add, K as addFinalizer, L as tap, P as scope, Q as minutes, R as try_, T as die, U as effectServices, V as withFiber, W as provide, X as getUnsafe, Y as get, Z as make$4, a as defaultTransforms, b as getCurrent, c as unwrap, i as make$3, k as gen, l as get$1, n as SafeIntegers, o as makeCompilerSqlite, q as Service, r as SqlClient, s as layer$1, u as make$1, v as die$1, x as acquireUseRelease, y as make$2, z as uninterruptibleMask } from "./index.mjs";
|
|
4
|
-
import { t as SqlError } from "./SqlError-7DUB2NkG.mjs";
|
|
5
|
-
import { DatabaseSync } from "node:sqlite";
|
|
6
|
-
|
|
7
|
-
//#region src/persistence/NodeSqliteClient.ts
|
|
8
|
-
/**
|
|
9
|
-
* Port of `@effect/sql-sqlite-node` that uses the native `node:sqlite`
|
|
10
|
-
* bindings instead of `better-sqlite3`.
|
|
11
|
-
*
|
|
12
|
-
* @module SqliteClient
|
|
13
|
-
*/
|
|
14
|
-
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
15
|
-
const TypeId = "~local/sqlite-node/SqliteClient";
|
|
16
|
-
/**
|
|
17
|
-
* SqliteClient - Effect service tag for the sqlite SQL client.
|
|
18
|
-
*/
|
|
19
|
-
const SqliteClient = Service("t3/persistence/NodeSqliteClient");
|
|
20
|
-
/**
|
|
21
|
-
* Verify that the current Node.js version includes the `node:sqlite` APIs
|
|
22
|
-
* used by `NodeSqliteClient` — specifically `StatementSync.columns()` (added
|
|
23
|
-
* in Node 22.16.0 / 23.11.0).
|
|
24
|
-
*
|
|
25
|
-
* @see https://github.com/nodejs/node/pull/57490
|
|
26
|
-
*/
|
|
27
|
-
const checkNodeSqliteCompat = () => {
|
|
28
|
-
const parts = process.versions.node.split(".").map(Number);
|
|
29
|
-
const major = parts[0] ?? 0;
|
|
30
|
-
const minor = parts[1] ?? 0;
|
|
31
|
-
if (!(major === 22 && minor >= 16 || major === 23 && minor >= 11 || major >= 24)) return die(`Node.js ${process.versions.node} is missing required node:sqlite APIs (StatementSync.columns). Upgrade to Node.js >=22.16, >=23.11, or >=24.`);
|
|
32
|
-
return void_;
|
|
33
|
-
};
|
|
34
|
-
const makeWithDatabase = (options, openDatabase) => gen(function* () {
|
|
35
|
-
yield* checkNodeSqliteCompat();
|
|
36
|
-
const compiler = makeCompilerSqlite(options.transformQueryNames);
|
|
37
|
-
const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
|
|
38
|
-
const makeConnection = gen(function* () {
|
|
39
|
-
const scope$1 = yield* scope;
|
|
40
|
-
const db = openDatabase();
|
|
41
|
-
yield* addFinalizer(scope$1, sync(() => db.close()));
|
|
42
|
-
const statementReaderCache = /* @__PURE__ */ new WeakMap();
|
|
43
|
-
const hasRows = (statement) => {
|
|
44
|
-
const cached = statementReaderCache.get(statement);
|
|
45
|
-
if (cached !== void 0) return cached;
|
|
46
|
-
const value = statement.columns().length > 0;
|
|
47
|
-
statementReaderCache.set(statement, value);
|
|
48
|
-
return value;
|
|
49
|
-
};
|
|
50
|
-
const prepareCache = yield* make$1({
|
|
51
|
-
capacity: options.prepareCacheSize ?? 200,
|
|
52
|
-
timeToLive: options.prepareCacheTTL ?? minutes(10),
|
|
53
|
-
lookup: (sql) => try_({
|
|
54
|
-
try: () => db.prepare(sql),
|
|
55
|
-
catch: (cause) => new SqlError({
|
|
56
|
-
cause,
|
|
57
|
-
message: "Failed to prepare statement"
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
});
|
|
61
|
-
const runStatement = (statement, params, raw) => withFiber((fiber) => {
|
|
62
|
-
statement.setReadBigInts(Boolean(get(fiber.services, SafeIntegers)));
|
|
63
|
-
try {
|
|
64
|
-
if (hasRows(statement)) return succeed(statement.all(...params));
|
|
65
|
-
const result = statement.run(...params);
|
|
66
|
-
return succeed(raw ? result : []);
|
|
67
|
-
} catch (cause) {
|
|
68
|
-
return fail(new SqlError({
|
|
69
|
-
cause,
|
|
70
|
-
message: "Failed to execute statement"
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
const run = (sql, params, raw = false) => flatMap(get$1(prepareCache, sql), (s) => runStatement(s, params, raw));
|
|
75
|
-
const runValues = (sql, params) => acquireUseRelease(get$1(prepareCache, sql), (statement) => try_({
|
|
76
|
-
try: () => {
|
|
77
|
-
if (hasRows(statement)) {
|
|
78
|
-
statement.setReturnArrays(true);
|
|
79
|
-
return statement.all(...params);
|
|
80
|
-
}
|
|
81
|
-
statement.run(...params);
|
|
82
|
-
return [];
|
|
83
|
-
},
|
|
84
|
-
catch: (cause) => new SqlError({
|
|
85
|
-
cause,
|
|
86
|
-
message: "Failed to execute statement"
|
|
87
|
-
})
|
|
88
|
-
}), (statement) => sync(() => {
|
|
89
|
-
if (hasRows(statement)) statement.setReturnArrays(false);
|
|
90
|
-
}));
|
|
91
|
-
return identity({
|
|
92
|
-
execute(sql, params, rowTransform) {
|
|
93
|
-
return rowTransform ? map(run(sql, params), rowTransform) : run(sql, params);
|
|
94
|
-
},
|
|
95
|
-
executeRaw(sql, params) {
|
|
96
|
-
return run(sql, params, true);
|
|
97
|
-
},
|
|
98
|
-
executeValues(sql, params) {
|
|
99
|
-
return runValues(sql, params);
|
|
100
|
-
},
|
|
101
|
-
executeUnprepared(sql, params, rowTransform) {
|
|
102
|
-
const effect = runStatement(db.prepare(sql), params ?? [], false);
|
|
103
|
-
return rowTransform ? map(effect, rowTransform) : effect;
|
|
104
|
-
},
|
|
105
|
-
executeStream(_sql, _params) {
|
|
106
|
-
return die$1("executeStream not implemented");
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
const semaphore = yield* make$2(1);
|
|
111
|
-
const connection = yield* makeConnection;
|
|
112
|
-
const acquirer = semaphore.withPermits(1)(succeed(connection));
|
|
113
|
-
const transactionAcquirer = uninterruptibleMask((restore) => {
|
|
114
|
-
const fiber = getCurrent();
|
|
115
|
-
const scope = getUnsafe(fiber.services, Scope);
|
|
116
|
-
return as(tap(restore(semaphore.take(1)), () => addFinalizer(scope, semaphore.release(1))), connection);
|
|
117
|
-
});
|
|
118
|
-
return yield* make$3({
|
|
119
|
-
acquirer,
|
|
120
|
-
compiler,
|
|
121
|
-
transactionAcquirer,
|
|
122
|
-
spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
|
|
123
|
-
transformRows
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
const make = (options) => makeWithDatabase(options, () => new DatabaseSync(options.filename, {
|
|
127
|
-
readOnly: options.readonly ?? false,
|
|
128
|
-
allowExtension: options.allowExtension ?? false
|
|
129
|
-
}));
|
|
130
|
-
const makeMemory = (config = {}) => makeWithDatabase({
|
|
131
|
-
...config,
|
|
132
|
-
filename: ":memory:",
|
|
133
|
-
readonly: false
|
|
134
|
-
}, () => {
|
|
135
|
-
return new DatabaseSync(":memory:", { allowExtension: config.allowExtension ?? false });
|
|
136
|
-
});
|
|
137
|
-
const layerConfig = (config) => effectServices(unwrap(config).asEffect().pipe(flatMap(make), map((client) => make$4(SqliteClient, client).pipe(add(SqlClient, client))))).pipe(provide(layer$1));
|
|
138
|
-
const layer = (config) => effectServices(map(make(config), (client) => make$4(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide(layer$1));
|
|
139
|
-
const layerMemory = (config = {}) => effectServices(map(makeMemory(config), (client) => make$4(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide(layer$1));
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
export { SqliteClient, TypeId, layer, layerConfig, layerMemory };
|
|
143
|
-
//# sourceMappingURL=NodeSqliteClient-COEUidVC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSqliteClient-COEUidVC.mjs","names":["ServiceMap.Service","Effect.die","Effect.void","Effect.gen","Statement.makeCompilerSqlite","Statement.defaultTransforms","scope","Effect.scope","Scope.addFinalizer","Effect.sync","Cache.make","Duration.minutes","Effect.try","Effect.withFiber","ServiceMap.get","Client.SafeIntegers","Effect.succeed","Effect.fail","Effect.flatMap","Cache.get","Effect.acquireUseRelease","Effect.map","Stream.die","Semaphore.make","Effect.uninterruptibleMask","Fiber.getCurrent","ServiceMap.getUnsafe","Scope.Scope","Effect.as","Effect.tap","Client.make","Layer.effectServices","Config.unwrap","ServiceMap.make","ServiceMap.add","Client.SqlClient","Layer.provide","Reactivity.layer"],"sources":["../src/persistence/NodeSqliteClient.ts"],"sourcesContent":["/**\n * Port of `@effect/sql-sqlite-node` that uses the native `node:sqlite`\n * bindings instead of `better-sqlite3`.\n *\n * @module SqliteClient\n */\nimport { DatabaseSync, type StatementSync } from \"node:sqlite\";\n\nimport * as Cache from \"effect/Cache\";\nimport * as Config from \"effect/Config\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Fiber from \"effect/Fiber\";\nimport { identity } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as Scope from \"effect/Scope\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport * as ServiceMap from \"effect/ServiceMap\";\nimport * as Stream from \"effect/Stream\";\nimport * as Reactivity from \"effect/unstable/reactivity/Reactivity\";\nimport * as Client from \"effect/unstable/sql/SqlClient\";\nimport type { Connection } from \"effect/unstable/sql/SqlConnection\";\nimport { SqlError } from \"effect/unstable/sql/SqlError\";\nimport * as Statement from \"effect/unstable/sql/Statement\";\n\nconst ATTR_DB_SYSTEM_NAME = \"db.system.name\";\n\nexport const TypeId: TypeId = \"~local/sqlite-node/SqliteClient\";\n\nexport type TypeId = \"~local/sqlite-node/SqliteClient\";\n\n/**\n * SqliteClient - Effect service tag for the sqlite SQL client.\n */\nexport const SqliteClient = ServiceMap.Service<Client.SqlClient>(\"t3/persistence/NodeSqliteClient\");\n\nexport interface SqliteClientConfig {\n readonly filename: string;\n readonly readonly?: boolean | undefined;\n readonly allowExtension?: boolean | undefined;\n readonly prepareCacheSize?: number | undefined;\n readonly prepareCacheTTL?: Duration.Input | undefined;\n readonly spanAttributes?: Record<string, unknown> | undefined;\n readonly transformResultNames?: ((str: string) => string) | undefined;\n readonly transformQueryNames?: ((str: string) => string) | undefined;\n}\n\nexport interface SqliteMemoryClientConfig extends Omit<\n SqliteClientConfig,\n \"filename\" | \"readonly\"\n> {}\n\n/**\n * Verify that the current Node.js version includes the `node:sqlite` APIs\n * used by `NodeSqliteClient` — specifically `StatementSync.columns()` (added\n * in Node 22.16.0 / 23.11.0).\n *\n * @see https://github.com/nodejs/node/pull/57490\n */\nconst checkNodeSqliteCompat = () => {\n const parts = process.versions.node.split(\".\").map(Number);\n const major = parts[0] ?? 0;\n const minor = parts[1] ?? 0;\n const supported = (major === 22 && minor >= 16) || (major === 23 && minor >= 11) || major >= 24;\n\n if (!supported) {\n return Effect.die(\n `Node.js ${process.versions.node} is missing required node:sqlite APIs ` +\n `(StatementSync.columns). Upgrade to Node.js >=22.16, >=23.11, or >=24.`,\n );\n }\n return Effect.void;\n};\n\nconst makeWithDatabase = (\n options: SqliteClientConfig,\n openDatabase: () => DatabaseSync,\n): Effect.Effect<Client.SqlClient, never, Scope.Scope | Reactivity.Reactivity> =>\n Effect.gen(function* () {\n yield* checkNodeSqliteCompat();\n\n const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);\n const transformRows = options.transformResultNames\n ? Statement.defaultTransforms(options.transformResultNames).array\n : undefined;\n\n const makeConnection = Effect.gen(function* () {\n const scope = yield* Effect.scope;\n const db = openDatabase();\n yield* Scope.addFinalizer(\n scope,\n Effect.sync(() => db.close()),\n );\n\n const statementReaderCache = new WeakMap<StatementSync, boolean>();\n const hasRows = (statement: StatementSync): boolean => {\n const cached = statementReaderCache.get(statement);\n if (cached !== undefined) {\n return cached;\n }\n const value = statement.columns().length > 0;\n statementReaderCache.set(statement, value);\n return value;\n };\n\n const prepareCache = yield* Cache.make({\n capacity: options.prepareCacheSize ?? 200,\n timeToLive: options.prepareCacheTTL ?? Duration.minutes(10),\n lookup: (sql: string) =>\n Effect.try({\n try: () => db.prepare(sql),\n catch: (cause) => new SqlError({ cause, message: \"Failed to prepare statement\" }),\n }),\n });\n\n const runStatement = (\n statement: StatementSync,\n params: ReadonlyArray<unknown>,\n raw: boolean,\n ) =>\n Effect.withFiber<ReadonlyArray<any>, SqlError>((fiber) => {\n statement.setReadBigInts(Boolean(ServiceMap.get(fiber.services, Client.SafeIntegers)));\n try {\n if (hasRows(statement)) {\n return Effect.succeed(statement.all(...(params as any)));\n }\n const result = statement.run(...(params as any));\n return Effect.succeed(raw ? (result as unknown as ReadonlyArray<any>) : []);\n } catch (cause) {\n return Effect.fail(new SqlError({ cause, message: \"Failed to execute statement\" }));\n }\n });\n\n const run = (sql: string, params: ReadonlyArray<unknown>, raw = false) =>\n Effect.flatMap(Cache.get(prepareCache, sql), (s) => runStatement(s, params, raw));\n\n const runValues = (sql: string, params: ReadonlyArray<unknown>) =>\n Effect.acquireUseRelease(\n Cache.get(prepareCache, sql),\n (statement) =>\n Effect.try({\n try: () => {\n if (hasRows(statement)) {\n statement.setReturnArrays(true);\n // Safe to cast to array after we've setReturnArrays(true)\n return statement.all(...(params as any)) as unknown as ReadonlyArray<\n ReadonlyArray<unknown>\n >;\n }\n statement.run(...(params as any));\n return [];\n },\n catch: (cause) => new SqlError({ cause, message: \"Failed to execute statement\" }),\n }),\n (statement) =>\n Effect.sync(() => {\n if (hasRows(statement)) {\n statement.setReturnArrays(false);\n }\n }),\n );\n\n return identity<Connection>({\n execute(sql, params, rowTransform) {\n return rowTransform ? Effect.map(run(sql, params), rowTransform) : run(sql, params);\n },\n executeRaw(sql, params) {\n return run(sql, params, true);\n },\n executeValues(sql, params) {\n return runValues(sql, params);\n },\n executeUnprepared(sql, params, rowTransform) {\n const effect = runStatement(db.prepare(sql), params ?? [], false);\n return rowTransform ? Effect.map(effect, rowTransform) : effect;\n },\n executeStream(_sql, _params) {\n return Stream.die(\"executeStream not implemented\");\n },\n });\n });\n\n const semaphore = yield* Semaphore.make(1);\n const connection = yield* makeConnection;\n\n const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));\n const transactionAcquirer = Effect.uninterruptibleMask((restore) => {\n const fiber = Fiber.getCurrent()!;\n const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope);\n return Effect.as(\n Effect.tap(restore(semaphore.take(1)), () =>\n Scope.addFinalizer(scope, semaphore.release(1)),\n ),\n connection,\n );\n });\n\n return yield* Client.make({\n acquirer,\n compiler,\n transactionAcquirer,\n spanAttributes: [\n ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []),\n [ATTR_DB_SYSTEM_NAME, \"sqlite\"],\n ],\n transformRows,\n });\n });\n\nconst make = (\n options: SqliteClientConfig,\n): Effect.Effect<Client.SqlClient, never, Scope.Scope | Reactivity.Reactivity> =>\n makeWithDatabase(\n options,\n () =>\n new DatabaseSync(options.filename, {\n readOnly: options.readonly ?? false,\n allowExtension: options.allowExtension ?? false,\n }),\n );\n\nconst makeMemory = (\n config: SqliteMemoryClientConfig = {},\n): Effect.Effect<Client.SqlClient, never, Scope.Scope | Reactivity.Reactivity> =>\n makeWithDatabase(\n {\n ...config,\n filename: \":memory:\",\n readonly: false,\n },\n () => {\n const database = new DatabaseSync(\":memory:\", {\n allowExtension: config.allowExtension ?? false,\n });\n return database;\n },\n );\n\nexport const layerConfig = (\n config: Config.Wrap<SqliteClientConfig>,\n): Layer.Layer<Client.SqlClient, Config.ConfigError> =>\n Layer.effectServices(\n Config.unwrap(config)\n .asEffect()\n .pipe(\n Effect.flatMap(make),\n Effect.map((client) =>\n ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client)),\n ),\n ),\n ).pipe(Layer.provide(Reactivity.layer));\n\nexport const layer = (config: SqliteClientConfig): Layer.Layer<Client.SqlClient> =>\n Layer.effectServices(\n Effect.map(make(config), (client) =>\n ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client)),\n ),\n ).pipe(Layer.provide(Reactivity.layer));\n\nexport const layerMemory = (config: SqliteMemoryClientConfig = {}): Layer.Layer<Client.SqlClient> =>\n Layer.effectServices(\n Effect.map(makeMemory(config), (client) =>\n ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client)),\n ),\n ).pipe(Layer.provide(Reactivity.layer));\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAM,sBAAsB;AAE5B,MAAa,SAAiB;;;;AAO9B,MAAa,eAAeA,QAAqC,kCAAkC;;;;;;;;AAyBnG,MAAM,8BAA8B;CAClC,MAAM,QAAQ,QAAQ,SAAS,KAAK,MAAM,IAAI,CAAC,IAAI,OAAO;CAC1D,MAAM,QAAQ,MAAM,MAAM;CAC1B,MAAM,QAAQ,MAAM,MAAM;AAG1B,KAAI,EAFe,UAAU,MAAM,SAAS,MAAQ,UAAU,MAAM,SAAS,MAAO,SAAS,IAG3F,QAAOC,IACL,WAAW,QAAQ,SAAS,KAAK,8GAElC;AAEH,QAAOC;;AAGT,MAAM,oBACJ,SACA,iBAEAC,IAAW,aAAa;AACtB,QAAO,uBAAuB;CAE9B,MAAM,WAAWC,mBAA6B,QAAQ,oBAAoB;CAC1E,MAAM,gBAAgB,QAAQ,uBAC1BC,kBAA4B,QAAQ,qBAAqB,CAAC,QAC1D;CAEJ,MAAM,iBAAiBF,IAAW,aAAa;EAC7C,MAAMG,UAAQ,OAAOC;EACrB,MAAM,KAAK,cAAc;AACzB,SAAOC,aACLF,SACAG,WAAkB,GAAG,OAAO,CAAC,CAC9B;EAED,MAAM,uCAAuB,IAAI,SAAiC;EAClE,MAAM,WAAW,cAAsC;GACrD,MAAM,SAAS,qBAAqB,IAAI,UAAU;AAClD,OAAI,WAAW,OACb,QAAO;GAET,MAAM,QAAQ,UAAU,SAAS,CAAC,SAAS;AAC3C,wBAAqB,IAAI,WAAW,MAAM;AAC1C,UAAO;;EAGT,MAAM,eAAe,OAAOC,OAAW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ACV,KACCd,QAAe,KAAK,EACpBG,KAAY,WACVY,OAAgB,cAAc,OAAO,CAAC,KAAKC,IAAeC,WAAkB,OAAO,CAAC,CACrF,CACF,CACJ,CAAC,KAAKC,QAAcC,QAAiB,CAAC;AAEzC,MAAa,SAAS,WACpBN,eACEV,IAAW,KAAK,OAAO,GAAG,WACxBY,OAAgB,cAAc,OAAO,CAAC,KAAKC,IAAeC,WAAkB,OAAO,CAAC,CACrF,CACF,CAAC,KAAKC,QAAcC,QAAiB,CAAC;AAEzC,MAAa,eAAe,SAAmC,EAAE,KAC/DN,eACEV,IAAW,WAAW,OAAO,GAAG,WAC9BY,OAAgB,cAAc,OAAO,CAAC,KAAKC,IAAeC,WAAkB,OAAO,CAAC,CACrF,CACF,CAAC,KAAKC,QAAcC,QAAiB,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { d as Defect, f as Number, h as optional, m as TaggedErrorClass, p as String } from "./index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/sql/SqlError.js
|
|
6
|
-
/**
|
|
7
|
-
* @since 4.0.0
|
|
8
|
-
*/
|
|
9
|
-
const TypeId = "~effect/sql/SqlError";
|
|
10
|
-
/**
|
|
11
|
-
* @since 4.0.0
|
|
12
|
-
*/
|
|
13
|
-
var SqlError = class extends TaggedErrorClass("effect/sql/SqlError")("SqlError", {
|
|
14
|
-
cause: Defect,
|
|
15
|
-
message: /* @__PURE__ */ optional(String)
|
|
16
|
-
}) {
|
|
17
|
-
/**
|
|
18
|
-
* @since 4.0.0
|
|
19
|
-
*/
|
|
20
|
-
[TypeId] = TypeId;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* @since 4.0.0
|
|
24
|
-
*/
|
|
25
|
-
var ResultLengthMismatch = class extends TaggedErrorClass("effect/sql/ResultLengthMismatch")("ResultLengthMismatch", {
|
|
26
|
-
expected: Number,
|
|
27
|
-
actual: Number
|
|
28
|
-
}) {
|
|
29
|
-
/**
|
|
30
|
-
* @since 4.0.0
|
|
31
|
-
*/
|
|
32
|
-
[TypeId] = TypeId;
|
|
33
|
-
/**
|
|
34
|
-
* @since 4.0.0
|
|
35
|
-
*/
|
|
36
|
-
get message() {
|
|
37
|
-
return `Expected ${this.expected} results but got ${this.actual}`;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { SqlError as t };
|
|
43
|
-
//# sourceMappingURL=SqlError-7DUB2NkG.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqlError-7DUB2NkG.mjs","names":["Schema.TaggedErrorClass","Schema.Defect","Schema.String","Schema.Number"],"sources":["../../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/sql/SqlError.js"],"sourcesContent":["/**\n * @since 4.0.0\n */\nimport * as Schema from \"../../Schema.js\";\nconst TypeId = \"~effect/sql/SqlError\";\n/**\n * @since 4.0.0\n */\nexport class SqlError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError\")(\"SqlError\", {\n cause: Schema.Defect,\n message: /*#__PURE__*/Schema.optional(Schema.String)\n}) {\n /**\n * @since 4.0.0\n */\n [TypeId] = TypeId;\n}\n/**\n * @since 4.0.0\n */\nexport class ResultLengthMismatch extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/ResultLengthMismatch\")(\"ResultLengthMismatch\", {\n expected: Schema.Number,\n actual: Schema.Number\n}) {\n /**\n * @since 4.0.0\n */\n [TypeId] = TypeId;\n /**\n * @since 4.0.0\n */\n get message() {\n return `Expected ${this.expected} results but got ${this.actual}`;\n }\n}\n//# sourceMappingURL=SqlError.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAIA,MAAM,SAAS;;;;AAIf,IAAa,WAAb,cAA2CA,iBAAwB,sBAAsB,CAAC,YAAY;CACpG,OAAOC;CACP,SAAsB,yBAAgBC,OAAc;CACrD,CAAC,CAAC;;;;CAID,CAAC,UAAU;;;;;AAKb,IAAa,uBAAb,cAAuDF,iBAAwB,kCAAkC,CAAC,wBAAwB;CACxI,UAAUG;CACV,QAAQA;CACT,CAAC,CAAC;;;;CAID,CAAC,UAAU;;;;CAIX,IAAI,UAAU;AACZ,SAAO,YAAY,KAAK,SAAS,mBAAmB,KAAK"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const require_index = require('./index.cjs');
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/sql/SqlError.js
|
|
6
|
-
/**
|
|
7
|
-
* @since 4.0.0
|
|
8
|
-
*/
|
|
9
|
-
const TypeId = "~effect/sql/SqlError";
|
|
10
|
-
/**
|
|
11
|
-
* @since 4.0.0
|
|
12
|
-
*/
|
|
13
|
-
var SqlError = class extends require_index.TaggedErrorClass("effect/sql/SqlError")("SqlError", {
|
|
14
|
-
cause: require_index.Defect,
|
|
15
|
-
message: /* @__PURE__ */ require_index.optional(require_index.String)
|
|
16
|
-
}) {
|
|
17
|
-
/**
|
|
18
|
-
* @since 4.0.0
|
|
19
|
-
*/
|
|
20
|
-
[TypeId] = TypeId;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* @since 4.0.0
|
|
24
|
-
*/
|
|
25
|
-
var ResultLengthMismatch = class extends require_index.TaggedErrorClass("effect/sql/ResultLengthMismatch")("ResultLengthMismatch", {
|
|
26
|
-
expected: require_index.Number,
|
|
27
|
-
actual: require_index.Number
|
|
28
|
-
}) {
|
|
29
|
-
/**
|
|
30
|
-
* @since 4.0.0
|
|
31
|
-
*/
|
|
32
|
-
[TypeId] = TypeId;
|
|
33
|
-
/**
|
|
34
|
-
* @since 4.0.0
|
|
35
|
-
*/
|
|
36
|
-
get message() {
|
|
37
|
-
return `Expected ${this.expected} results but got ${this.actual}`;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
Object.defineProperty(exports, 'SqlError', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return SqlError;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=SqlError-CAzXmpza.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqlError-CAzXmpza.cjs","names":[],"sources":["../../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/sql/SqlError.js"],"sourcesContent":["/**\n * @since 4.0.0\n */\nimport * as Schema from \"../../Schema.js\";\nconst TypeId = \"~effect/sql/SqlError\";\n/**\n * @since 4.0.0\n */\nexport class SqlError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError\")(\"SqlError\", {\n cause: Schema.Defect,\n message: /*#__PURE__*/Schema.optional(Schema.String)\n}) {\n /**\n * @since 4.0.0\n */\n [TypeId] = TypeId;\n}\n/**\n * @since 4.0.0\n */\nexport class ResultLengthMismatch extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/ResultLengthMismatch\")(\"ResultLengthMismatch\", {\n expected: Schema.Number,\n actual: Schema.Number\n}) {\n /**\n * @since 4.0.0\n */\n [TypeId] = TypeId;\n /**\n * @since 4.0.0\n */\n get message() {\n return `Expected ${this.expected} results but got ${this.actual}`;\n }\n}\n//# sourceMappingURL=SqlError.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAIA,MAAM,SAAS;;;;AAIf,IAAa,WAAb,6CAAmE,sBAAsB,CAAC,YAAY;CACpG;CACA,SAAsB,4DAA8B;CACrD,CAAC,CAAC;;;;CAID,CAAC,UAAU;;;;;AAKb,IAAa,uBAAb,6CAA+E,kCAAkC,CAAC,wBAAwB;CACxI;CACA;CACD,CAAC,CAAC;;;;CAID,CAAC,UAAU;;;;CAIX,IAAI,UAAU;AACZ,SAAO,YAAY,KAAK,SAAS,mBAAmB,KAAK"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const require_index = require('./index.cjs');
|
|
4
|
-
const require_SqlError = require('./SqlError-CAzXmpza.cjs');
|
|
5
|
-
let bun_sqlite = require("bun:sqlite");
|
|
6
|
-
|
|
7
|
-
//#region ../../node_modules/.bun/@effect+sql-sqlite-bun@https+++pkg.pr.new+Effect-TS+effect-smol+@effect+sql-sqlite-bun@8881a9b+eecd35a1726d7096/node_modules/@effect/sql-sqlite-bun/dist/SqliteClient.js
|
|
8
|
-
/**
|
|
9
|
-
* @since 1.0.0
|
|
10
|
-
*/
|
|
11
|
-
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
12
|
-
/**
|
|
13
|
-
* @category type ids
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
*/
|
|
16
|
-
const TypeId = "~@effect/sql-sqlite-bun/SqliteClient";
|
|
17
|
-
/**
|
|
18
|
-
* @category tags
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
*/
|
|
21
|
-
const SqliteClient = /* @__PURE__ */ require_index.Service("@effect/sql-sqlite-bun/Client");
|
|
22
|
-
/**
|
|
23
|
-
* @category constructor
|
|
24
|
-
* @since 1.0.0
|
|
25
|
-
*/
|
|
26
|
-
const make = (options) => require_index.gen(function* () {
|
|
27
|
-
const compiler = require_index.makeCompilerSqlite(options.transformQueryNames);
|
|
28
|
-
const transformRows = options.transformResultNames ? require_index.defaultTransforms(options.transformResultNames).array : void 0;
|
|
29
|
-
const makeConnection = require_index.gen(function* () {
|
|
30
|
-
const db = new bun_sqlite.Database(options.filename, {
|
|
31
|
-
readonly: options.readonly,
|
|
32
|
-
readwrite: options.readwrite ?? true,
|
|
33
|
-
create: options.create ?? true
|
|
34
|
-
});
|
|
35
|
-
yield* require_index.addFinalizer(() => require_index.sync(() => db.close()));
|
|
36
|
-
if (options.disableWAL !== true) db.run("PRAGMA journal_mode = WAL;");
|
|
37
|
-
const run = (sql, params = []) => require_index.withFiber((fiber) => {
|
|
38
|
-
const statement = db.query(sql);
|
|
39
|
-
const useSafeIntegers = require_index.get$1(fiber.services, require_index.SafeIntegers);
|
|
40
|
-
statement.safeIntegers(useSafeIntegers);
|
|
41
|
-
try {
|
|
42
|
-
return require_index.succeed(statement.all(...params) ?? []);
|
|
43
|
-
} catch (cause) {
|
|
44
|
-
return require_index.fail(new require_SqlError.SqlError({
|
|
45
|
-
cause,
|
|
46
|
-
message: "Failed to execute statement"
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const runValues = (sql, params = []) => require_index.withFiber((fiber) => {
|
|
51
|
-
const statement = db.query(sql);
|
|
52
|
-
const useSafeIntegers = require_index.get$1(fiber.services, require_index.SafeIntegers);
|
|
53
|
-
statement.safeIntegers(useSafeIntegers);
|
|
54
|
-
try {
|
|
55
|
-
return require_index.succeed(statement.values(...params) ?? []);
|
|
56
|
-
} catch (cause) {
|
|
57
|
-
return require_index.fail(new require_SqlError.SqlError({
|
|
58
|
-
cause,
|
|
59
|
-
message: "Failed to execute statement"
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return require_index.identity({
|
|
64
|
-
execute(sql, params, transformRows) {
|
|
65
|
-
return transformRows ? require_index.map(run(sql, params), transformRows) : run(sql, params);
|
|
66
|
-
},
|
|
67
|
-
executeRaw(sql, params) {
|
|
68
|
-
return run(sql, params);
|
|
69
|
-
},
|
|
70
|
-
executeValues(sql, params) {
|
|
71
|
-
return runValues(sql, params);
|
|
72
|
-
},
|
|
73
|
-
executeUnprepared(sql, params, transformRows) {
|
|
74
|
-
return this.execute(sql, params, transformRows);
|
|
75
|
-
},
|
|
76
|
-
executeStream(_sql, _params) {
|
|
77
|
-
return require_index.die("executeStream not implemented");
|
|
78
|
-
},
|
|
79
|
-
export: require_index.try_({
|
|
80
|
-
try: () => db.serialize(),
|
|
81
|
-
catch: (cause) => new require_SqlError.SqlError({
|
|
82
|
-
cause,
|
|
83
|
-
message: "Failed to export database"
|
|
84
|
-
})
|
|
85
|
-
}),
|
|
86
|
-
loadExtension: (path) => require_index.try_({
|
|
87
|
-
try: () => db.loadExtension(path),
|
|
88
|
-
catch: (cause) => new require_SqlError.SqlError({
|
|
89
|
-
cause,
|
|
90
|
-
message: "Failed to load extension"
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
const semaphore = yield* require_index.make$2(1);
|
|
96
|
-
const connection = yield* makeConnection;
|
|
97
|
-
const acquirer = semaphore.withPermits(1)(require_index.succeed(connection));
|
|
98
|
-
const transactionAcquirer = require_index.uninterruptibleMask((restore) => {
|
|
99
|
-
const fiber = require_index.getCurrent();
|
|
100
|
-
const scope = require_index.getUnsafe(fiber.services, require_index.Scope);
|
|
101
|
-
return require_index.as(require_index.tap(restore(semaphore.take(1)), () => require_index.addFinalizer$1(scope, semaphore.release(1))), connection);
|
|
102
|
-
});
|
|
103
|
-
return Object.assign(yield* require_index.make({
|
|
104
|
-
acquirer,
|
|
105
|
-
compiler,
|
|
106
|
-
transactionAcquirer,
|
|
107
|
-
spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
|
|
108
|
-
transformRows
|
|
109
|
-
}), {
|
|
110
|
-
[TypeId]: TypeId,
|
|
111
|
-
config: options,
|
|
112
|
-
export: require_index.flatMap(acquirer, (_) => _.export),
|
|
113
|
-
loadExtension: (path) => require_index.flatMap(acquirer, (_) => _.loadExtension(path))
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
/**
|
|
117
|
-
* @category layers
|
|
118
|
-
* @since 1.0.0
|
|
119
|
-
*/
|
|
120
|
-
const layerConfig = (config) => require_index.effectServices(require_index.unwrap(config).asEffect().pipe(require_index.flatMap(make), require_index.map((client) => require_index.make$3(SqliteClient, client).pipe(require_index.add(require_index.SqlClient, client))))).pipe(require_index.provide(require_index.layer));
|
|
121
|
-
/**
|
|
122
|
-
* @category layers
|
|
123
|
-
* @since 1.0.0
|
|
124
|
-
*/
|
|
125
|
-
const layer = (config) => require_index.effectServices(require_index.map(make(config), (client) => require_index.make$3(SqliteClient, client).pipe(require_index.add(require_index.SqlClient, client)))).pipe(require_index.provide(require_index.layer));
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
exports.SqliteClient = SqliteClient;
|
|
129
|
-
exports.TypeId = TypeId;
|
|
130
|
-
exports.layer = layer;
|
|
131
|
-
exports.layerConfig = layerConfig;
|
|
132
|
-
exports.make = make;
|
|
133
|
-
//# sourceMappingURL=SqliteClient-BMlcF9O1.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient-BMlcF9O1.cjs","names":["Database","SqlError","identity"],"sources":["../../../node_modules/.bun/@effect+sql-sqlite-bun@https+++pkg.pr.new+Effect-TS+effect-smol+@effect+sql-sqlite-bun@8881a9b+eecd35a1726d7096/node_modules/@effect/sql-sqlite-bun/dist/SqliteClient.js"],"sourcesContent":["/**\n * @since 1.0.0\n */\nimport { Database } from \"bun:sqlite\";\nimport * as Config from \"effect/Config\";\nimport * as Effect from \"effect/Effect\";\nimport * as Fiber from \"effect/Fiber\";\nimport { identity } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as Scope from \"effect/Scope\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport * as ServiceMap from \"effect/ServiceMap\";\nimport * as Stream from \"effect/Stream\";\nimport * as Reactivity from \"effect/unstable/reactivity/Reactivity\";\nimport * as Client from \"effect/unstable/sql/SqlClient\";\nimport { SqlError } from \"effect/unstable/sql/SqlError\";\nimport * as Statement from \"effect/unstable/sql/Statement\";\nconst ATTR_DB_SYSTEM_NAME = \"db.system.name\";\n/**\n * @category type ids\n * @since 1.0.0\n */\nexport const TypeId = \"~@effect/sql-sqlite-bun/SqliteClient\";\n/**\n * @category tags\n * @since 1.0.0\n */\nexport const SqliteClient = /*#__PURE__*/ServiceMap.Service(\"@effect/sql-sqlite-bun/Client\");\n/**\n * @category constructor\n * @since 1.0.0\n */\nexport const make = options => Effect.gen(function* () {\n const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);\n const transformRows = options.transformResultNames ? Statement.defaultTransforms(options.transformResultNames).array : undefined;\n const makeConnection = Effect.gen(function* () {\n const db = new Database(options.filename, {\n readonly: options.readonly,\n readwrite: options.readwrite ?? true,\n create: options.create ?? true\n });\n yield* Effect.addFinalizer(() => Effect.sync(() => db.close()));\n if (options.disableWAL !== true) {\n db.run(\"PRAGMA journal_mode = WAL;\");\n }\n const run = (sql, params = []) => Effect.withFiber(fiber => {\n const statement = db.query(sql);\n const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);\n // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627\n statement.safeIntegers(useSafeIntegers);\n try {\n return Effect.succeed(statement.all(...params) ?? []);\n } catch (cause) {\n return Effect.fail(new SqlError({\n cause,\n message: \"Failed to execute statement\"\n }));\n }\n });\n const runValues = (sql, params = []) => Effect.withFiber(fiber => {\n const statement = db.query(sql);\n const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);\n // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627\n statement.safeIntegers(useSafeIntegers);\n try {\n return Effect.succeed(statement.values(...params) ?? []);\n } catch (cause) {\n return Effect.fail(new SqlError({\n cause,\n message: \"Failed to execute statement\"\n }));\n }\n });\n return identity({\n execute(sql, params, transformRows) {\n return transformRows ? Effect.map(run(sql, params), transformRows) : run(sql, params);\n },\n executeRaw(sql, params) {\n return run(sql, params);\n },\n executeValues(sql, params) {\n return runValues(sql, params);\n },\n executeUnprepared(sql, params, transformRows) {\n return this.execute(sql, params, transformRows);\n },\n executeStream(_sql, _params) {\n return Stream.die(\"executeStream not implemented\");\n },\n export: Effect.try({\n try: () => db.serialize(),\n catch: cause => new SqlError({\n cause,\n message: \"Failed to export database\"\n })\n }),\n loadExtension: path => Effect.try({\n try: () => db.loadExtension(path),\n catch: cause => new SqlError({\n cause,\n message: \"Failed to load extension\"\n })\n })\n });\n });\n const semaphore = yield* Semaphore.make(1);\n const connection = yield* makeConnection;\n const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));\n const transactionAcquirer = Effect.uninterruptibleMask(restore => {\n const fiber = Fiber.getCurrent();\n const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope);\n return Effect.as(Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))), connection);\n });\n return Object.assign(yield* Client.make({\n acquirer,\n compiler,\n transactionAcquirer,\n spanAttributes: [...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), [ATTR_DB_SYSTEM_NAME, \"sqlite\"]],\n transformRows\n }), {\n [TypeId]: TypeId,\n config: options,\n export: Effect.flatMap(acquirer, _ => _.export),\n loadExtension: path => Effect.flatMap(acquirer, _ => _.loadExtension(path))\n });\n});\n/**\n * @category layers\n * @since 1.0.0\n */\nexport const layerConfig = config => Layer.effectServices(Config.unwrap(config).asEffect().pipe(Effect.flatMap(make), Effect.map(client => ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client))))).pipe(Layer.provide(Reactivity.layer));\n/**\n * @category layers\n * @since 1.0.0\n */\nexport const layer = config => Layer.effectServices(Effect.map(make(config), client => ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));\n//# sourceMappingURL=SqliteClient.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;AAiBA,MAAM,sBAAsB;;;;;AAK5B,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AKxQ,MAAa,SAAQ,0DAA0C,KAAK,OAAO,GAAE,gCAA0B,cAAc,OAAO,CAAC,gDAAsC,OAAO,CAAC,CAAC,CAAC,CAAC,+CAAoC,CAAC"}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { $ as identity, A as map, C as as, D as flatMap, E as fail, F as succeed, G as Scope, I as sync, J as add, K as addFinalizer$1, L as tap, R as try_, S as addFinalizer, U as effectServices, V as withFiber, W as provide, X as getUnsafe, Y as get, Z as make$3, a as defaultTransforms, b as getCurrent, c as unwrap, i as make$2, k as gen, n as SafeIntegers, o as makeCompilerSqlite, q as Service, r as SqlClient, s as layer$1, v as die, y as make$1, z as uninterruptibleMask } from "./index.mjs";
|
|
4
|
-
import { t as SqlError } from "./SqlError-7DUB2NkG.mjs";
|
|
5
|
-
import { Database } from "bun:sqlite";
|
|
6
|
-
|
|
7
|
-
//#region ../../node_modules/.bun/@effect+sql-sqlite-bun@https+++pkg.pr.new+Effect-TS+effect-smol+@effect+sql-sqlite-bun@8881a9b+eecd35a1726d7096/node_modules/@effect/sql-sqlite-bun/dist/SqliteClient.js
|
|
8
|
-
/**
|
|
9
|
-
* @since 1.0.0
|
|
10
|
-
*/
|
|
11
|
-
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
12
|
-
/**
|
|
13
|
-
* @category type ids
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
*/
|
|
16
|
-
const TypeId = "~@effect/sql-sqlite-bun/SqliteClient";
|
|
17
|
-
/**
|
|
18
|
-
* @category tags
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
*/
|
|
21
|
-
const SqliteClient = /* @__PURE__ */ Service("@effect/sql-sqlite-bun/Client");
|
|
22
|
-
/**
|
|
23
|
-
* @category constructor
|
|
24
|
-
* @since 1.0.0
|
|
25
|
-
*/
|
|
26
|
-
const make = (options) => gen(function* () {
|
|
27
|
-
const compiler = makeCompilerSqlite(options.transformQueryNames);
|
|
28
|
-
const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
|
|
29
|
-
const makeConnection = gen(function* () {
|
|
30
|
-
const db = new Database(options.filename, {
|
|
31
|
-
readonly: options.readonly,
|
|
32
|
-
readwrite: options.readwrite ?? true,
|
|
33
|
-
create: options.create ?? true
|
|
34
|
-
});
|
|
35
|
-
yield* addFinalizer(() => sync(() => db.close()));
|
|
36
|
-
if (options.disableWAL !== true) db.run("PRAGMA journal_mode = WAL;");
|
|
37
|
-
const run = (sql, params = []) => withFiber((fiber) => {
|
|
38
|
-
const statement = db.query(sql);
|
|
39
|
-
const useSafeIntegers = get(fiber.services, SafeIntegers);
|
|
40
|
-
statement.safeIntegers(useSafeIntegers);
|
|
41
|
-
try {
|
|
42
|
-
return succeed(statement.all(...params) ?? []);
|
|
43
|
-
} catch (cause) {
|
|
44
|
-
return fail(new SqlError({
|
|
45
|
-
cause,
|
|
46
|
-
message: "Failed to execute statement"
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const runValues = (sql, params = []) => withFiber((fiber) => {
|
|
51
|
-
const statement = db.query(sql);
|
|
52
|
-
const useSafeIntegers = get(fiber.services, SafeIntegers);
|
|
53
|
-
statement.safeIntegers(useSafeIntegers);
|
|
54
|
-
try {
|
|
55
|
-
return succeed(statement.values(...params) ?? []);
|
|
56
|
-
} catch (cause) {
|
|
57
|
-
return fail(new SqlError({
|
|
58
|
-
cause,
|
|
59
|
-
message: "Failed to execute statement"
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return identity({
|
|
64
|
-
execute(sql, params, transformRows) {
|
|
65
|
-
return transformRows ? map(run(sql, params), transformRows) : run(sql, params);
|
|
66
|
-
},
|
|
67
|
-
executeRaw(sql, params) {
|
|
68
|
-
return run(sql, params);
|
|
69
|
-
},
|
|
70
|
-
executeValues(sql, params) {
|
|
71
|
-
return runValues(sql, params);
|
|
72
|
-
},
|
|
73
|
-
executeUnprepared(sql, params, transformRows) {
|
|
74
|
-
return this.execute(sql, params, transformRows);
|
|
75
|
-
},
|
|
76
|
-
executeStream(_sql, _params) {
|
|
77
|
-
return die("executeStream not implemented");
|
|
78
|
-
},
|
|
79
|
-
export: try_({
|
|
80
|
-
try: () => db.serialize(),
|
|
81
|
-
catch: (cause) => new SqlError({
|
|
82
|
-
cause,
|
|
83
|
-
message: "Failed to export database"
|
|
84
|
-
})
|
|
85
|
-
}),
|
|
86
|
-
loadExtension: (path) => try_({
|
|
87
|
-
try: () => db.loadExtension(path),
|
|
88
|
-
catch: (cause) => new SqlError({
|
|
89
|
-
cause,
|
|
90
|
-
message: "Failed to load extension"
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
const semaphore = yield* make$1(1);
|
|
96
|
-
const connection = yield* makeConnection;
|
|
97
|
-
const acquirer = semaphore.withPermits(1)(succeed(connection));
|
|
98
|
-
const transactionAcquirer = uninterruptibleMask((restore) => {
|
|
99
|
-
const fiber = getCurrent();
|
|
100
|
-
const scope = getUnsafe(fiber.services, Scope);
|
|
101
|
-
return as(tap(restore(semaphore.take(1)), () => addFinalizer$1(scope, semaphore.release(1))), connection);
|
|
102
|
-
});
|
|
103
|
-
return Object.assign(yield* make$2({
|
|
104
|
-
acquirer,
|
|
105
|
-
compiler,
|
|
106
|
-
transactionAcquirer,
|
|
107
|
-
spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
|
|
108
|
-
transformRows
|
|
109
|
-
}), {
|
|
110
|
-
[TypeId]: TypeId,
|
|
111
|
-
config: options,
|
|
112
|
-
export: flatMap(acquirer, (_) => _.export),
|
|
113
|
-
loadExtension: (path) => flatMap(acquirer, (_) => _.loadExtension(path))
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
/**
|
|
117
|
-
* @category layers
|
|
118
|
-
* @since 1.0.0
|
|
119
|
-
*/
|
|
120
|
-
const layerConfig = (config) => effectServices(unwrap(config).asEffect().pipe(flatMap(make), map((client) => make$3(SqliteClient, client).pipe(add(SqlClient, client))))).pipe(provide(layer$1));
|
|
121
|
-
/**
|
|
122
|
-
* @category layers
|
|
123
|
-
* @since 1.0.0
|
|
124
|
-
*/
|
|
125
|
-
const layer = (config) => effectServices(map(make(config), (client) => make$3(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide(layer$1));
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
export { SqliteClient, TypeId, layer, layerConfig, make };
|
|
129
|
-
//# sourceMappingURL=SqliteClient-MZci3yRi.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient-MZci3yRi.mjs","names":["Effect.gen","Statement.makeCompilerSqlite","Statement.defaultTransforms","Effect.addFinalizer","Effect.sync","Effect.withFiber","ServiceMap.get","Client.SafeIntegers","Effect.succeed","Effect.fail","Effect.map","Stream.die","Effect.try","Semaphore.make","Effect.uninterruptibleMask","Fiber.getCurrent","ServiceMap.getUnsafe","Scope.Scope","Effect.as","Effect.tap","Scope.addFinalizer","Client.make","Effect.flatMap","Layer.effectServices","Config.unwrap","ServiceMap.make","ServiceMap.add","Client.SqlClient","Layer.provide","Reactivity.layer"],"sources":["../../../node_modules/.bun/@effect+sql-sqlite-bun@https+++pkg.pr.new+Effect-TS+effect-smol+@effect+sql-sqlite-bun@8881a9b+eecd35a1726d7096/node_modules/@effect/sql-sqlite-bun/dist/SqliteClient.js"],"sourcesContent":["/**\n * @since 1.0.0\n */\nimport { Database } from \"bun:sqlite\";\nimport * as Config from \"effect/Config\";\nimport * as Effect from \"effect/Effect\";\nimport * as Fiber from \"effect/Fiber\";\nimport { identity } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as Scope from \"effect/Scope\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport * as ServiceMap from \"effect/ServiceMap\";\nimport * as Stream from \"effect/Stream\";\nimport * as Reactivity from \"effect/unstable/reactivity/Reactivity\";\nimport * as Client from \"effect/unstable/sql/SqlClient\";\nimport { SqlError } from \"effect/unstable/sql/SqlError\";\nimport * as Statement from \"effect/unstable/sql/Statement\";\nconst ATTR_DB_SYSTEM_NAME = \"db.system.name\";\n/**\n * @category type ids\n * @since 1.0.0\n */\nexport const TypeId = \"~@effect/sql-sqlite-bun/SqliteClient\";\n/**\n * @category tags\n * @since 1.0.0\n */\nexport const SqliteClient = /*#__PURE__*/ServiceMap.Service(\"@effect/sql-sqlite-bun/Client\");\n/**\n * @category constructor\n * @since 1.0.0\n */\nexport const make = options => Effect.gen(function* () {\n const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);\n const transformRows = options.transformResultNames ? Statement.defaultTransforms(options.transformResultNames).array : undefined;\n const makeConnection = Effect.gen(function* () {\n const db = new Database(options.filename, {\n readonly: options.readonly,\n readwrite: options.readwrite ?? true,\n create: options.create ?? true\n });\n yield* Effect.addFinalizer(() => Effect.sync(() => db.close()));\n if (options.disableWAL !== true) {\n db.run(\"PRAGMA journal_mode = WAL;\");\n }\n const run = (sql, params = []) => Effect.withFiber(fiber => {\n const statement = db.query(sql);\n const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);\n // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627\n statement.safeIntegers(useSafeIntegers);\n try {\n return Effect.succeed(statement.all(...params) ?? []);\n } catch (cause) {\n return Effect.fail(new SqlError({\n cause,\n message: \"Failed to execute statement\"\n }));\n }\n });\n const runValues = (sql, params = []) => Effect.withFiber(fiber => {\n const statement = db.query(sql);\n const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);\n // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627\n statement.safeIntegers(useSafeIntegers);\n try {\n return Effect.succeed(statement.values(...params) ?? []);\n } catch (cause) {\n return Effect.fail(new SqlError({\n cause,\n message: \"Failed to execute statement\"\n }));\n }\n });\n return identity({\n execute(sql, params, transformRows) {\n return transformRows ? Effect.map(run(sql, params), transformRows) : run(sql, params);\n },\n executeRaw(sql, params) {\n return run(sql, params);\n },\n executeValues(sql, params) {\n return runValues(sql, params);\n },\n executeUnprepared(sql, params, transformRows) {\n return this.execute(sql, params, transformRows);\n },\n executeStream(_sql, _params) {\n return Stream.die(\"executeStream not implemented\");\n },\n export: Effect.try({\n try: () => db.serialize(),\n catch: cause => new SqlError({\n cause,\n message: \"Failed to export database\"\n })\n }),\n loadExtension: path => Effect.try({\n try: () => db.loadExtension(path),\n catch: cause => new SqlError({\n cause,\n message: \"Failed to load extension\"\n })\n })\n });\n });\n const semaphore = yield* Semaphore.make(1);\n const connection = yield* makeConnection;\n const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));\n const transactionAcquirer = Effect.uninterruptibleMask(restore => {\n const fiber = Fiber.getCurrent();\n const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope);\n return Effect.as(Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))), connection);\n });\n return Object.assign(yield* Client.make({\n acquirer,\n compiler,\n transactionAcquirer,\n spanAttributes: [...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), [ATTR_DB_SYSTEM_NAME, \"sqlite\"]],\n transformRows\n }), {\n [TypeId]: TypeId,\n config: options,\n export: Effect.flatMap(acquirer, _ => _.export),\n loadExtension: path => Effect.flatMap(acquirer, _ => _.loadExtension(path))\n });\n});\n/**\n * @category layers\n * @since 1.0.0\n */\nexport const layerConfig = config => Layer.effectServices(Config.unwrap(config).asEffect().pipe(Effect.flatMap(make), Effect.map(client => ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client))))).pipe(Layer.provide(Reactivity.layer));\n/**\n * @category layers\n * @since 1.0.0\n */\nexport const layer = config => Layer.effectServices(Effect.map(make(config), client => ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.Sq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