codexuse-cli 2.5.5 → 3.0.1
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/README.md +2 -1
- package/dist/index.js +7615 -8943
- package/dist/index.js.map +1 -1
- package/dist/server/NodeSqliteClient-BMOt9qz2.mjs +140 -0
- package/dist/server/SqlClient-CB8oPtuH.mjs +28101 -0
- package/dist/server/SqlError-3qccgSvc.mjs +28 -0
- package/dist/server/SqliteClient-ChChXcv_.mjs +127 -0
- package/dist/server/index.mjs +52469 -0
- package/dist/server/open-BM96ykXl.mjs +554 -0
- package/package.json +16 -5
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { C as Defect, F as String, L as TaggedErrorClass, N as Number, _t as optional } from "./SqlClient-CB8oPtuH.mjs";
|
|
4
|
+
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/sql/SqlError.js
|
|
5
|
+
/**
|
|
6
|
+
* @since 4.0.0
|
|
7
|
+
*/
|
|
8
|
+
const TypeId = "~effect/sql/SqlError";
|
|
9
|
+
/**
|
|
10
|
+
* @since 4.0.0
|
|
11
|
+
*/
|
|
12
|
+
var SqlError = class extends TaggedErrorClass("effect/sql/SqlError")("SqlError", {
|
|
13
|
+
cause: Defect,
|
|
14
|
+
message: /* @__PURE__ */ optional(String)
|
|
15
|
+
}) {
|
|
16
|
+
/**
|
|
17
|
+
* @since 4.0.0
|
|
18
|
+
*/
|
|
19
|
+
[TypeId] = TypeId;
|
|
20
|
+
};
|
|
21
|
+
TaggedErrorClass("effect/sql/ResultLengthMismatch")("ResultLengthMismatch", {
|
|
22
|
+
expected: Number,
|
|
23
|
+
actual: Number
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { SqlError as t };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=SqlError-3qccgSvc.mjs.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { Fn as getCurrent, Gi as addFinalizer$1, Ii as effectServices, Or as gen, Qn as addFinalizer, Rr as map, Rt as die, Ts as identity, Wi as Scope, _ as unwrap, _r as fail, a as makeCompilerSqlite, ao as add, bi as uninterruptibleMask, br as flatMap, ci as succeed, co as getUnsafe, di as sync, fi as tap, hn as make$1, i as defaultTransforms, io as Service, lo as make$3, n as SqlClient, nr as as, o as layer$1, r as make$2, so as get, t as SafeIntegers, vi as try_, wi as withFiber, zi as provide } from "./SqlClient-CB8oPtuH.mjs";
|
|
4
|
+
import { t as SqlError } from "./SqlError-3qccgSvc.mjs";
|
|
5
|
+
import { Database } from "bun:sqlite";
|
|
6
|
+
//#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
|
|
7
|
+
/**
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
11
|
+
/**
|
|
12
|
+
* @category type ids
|
|
13
|
+
* @since 1.0.0
|
|
14
|
+
*/
|
|
15
|
+
const TypeId = "~@effect/sql-sqlite-bun/SqliteClient";
|
|
16
|
+
/**
|
|
17
|
+
* @category tags
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
const SqliteClient = /* @__PURE__ */ Service("@effect/sql-sqlite-bun/Client");
|
|
21
|
+
/**
|
|
22
|
+
* @category constructor
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
25
|
+
const make = (options) => gen(function* () {
|
|
26
|
+
const compiler = makeCompilerSqlite(options.transformQueryNames);
|
|
27
|
+
const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
|
|
28
|
+
const makeConnection = gen(function* () {
|
|
29
|
+
const db = new Database(options.filename, {
|
|
30
|
+
readonly: options.readonly,
|
|
31
|
+
readwrite: options.readwrite ?? true,
|
|
32
|
+
create: options.create ?? true
|
|
33
|
+
});
|
|
34
|
+
yield* addFinalizer(() => sync(() => db.close()));
|
|
35
|
+
if (options.disableWAL !== true) db.run("PRAGMA journal_mode = WAL;");
|
|
36
|
+
const run = (sql, params = []) => withFiber((fiber) => {
|
|
37
|
+
const statement = db.query(sql);
|
|
38
|
+
const useSafeIntegers = get(fiber.services, SafeIntegers);
|
|
39
|
+
statement.safeIntegers(useSafeIntegers);
|
|
40
|
+
try {
|
|
41
|
+
return succeed(statement.all(...params) ?? []);
|
|
42
|
+
} catch (cause) {
|
|
43
|
+
return fail(new SqlError({
|
|
44
|
+
cause,
|
|
45
|
+
message: "Failed to execute statement"
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const runValues = (sql, params = []) => withFiber((fiber) => {
|
|
50
|
+
const statement = db.query(sql);
|
|
51
|
+
const useSafeIntegers = get(fiber.services, SafeIntegers);
|
|
52
|
+
statement.safeIntegers(useSafeIntegers);
|
|
53
|
+
try {
|
|
54
|
+
return succeed(statement.values(...params) ?? []);
|
|
55
|
+
} catch (cause) {
|
|
56
|
+
return fail(new SqlError({
|
|
57
|
+
cause,
|
|
58
|
+
message: "Failed to execute statement"
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return identity({
|
|
63
|
+
execute(sql, params, transformRows) {
|
|
64
|
+
return transformRows ? map(run(sql, params), transformRows) : run(sql, params);
|
|
65
|
+
},
|
|
66
|
+
executeRaw(sql, params) {
|
|
67
|
+
return run(sql, params);
|
|
68
|
+
},
|
|
69
|
+
executeValues(sql, params) {
|
|
70
|
+
return runValues(sql, params);
|
|
71
|
+
},
|
|
72
|
+
executeUnprepared(sql, params, transformRows) {
|
|
73
|
+
return this.execute(sql, params, transformRows);
|
|
74
|
+
},
|
|
75
|
+
executeStream(_sql, _params) {
|
|
76
|
+
return die("executeStream not implemented");
|
|
77
|
+
},
|
|
78
|
+
export: try_({
|
|
79
|
+
try: () => db.serialize(),
|
|
80
|
+
catch: (cause) => new SqlError({
|
|
81
|
+
cause,
|
|
82
|
+
message: "Failed to export database"
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
85
|
+
loadExtension: (path) => try_({
|
|
86
|
+
try: () => db.loadExtension(path),
|
|
87
|
+
catch: (cause) => new SqlError({
|
|
88
|
+
cause,
|
|
89
|
+
message: "Failed to load extension"
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
const semaphore = yield* make$1(1);
|
|
95
|
+
const connection = yield* makeConnection;
|
|
96
|
+
const acquirer = semaphore.withPermits(1)(succeed(connection));
|
|
97
|
+
const transactionAcquirer = uninterruptibleMask((restore) => {
|
|
98
|
+
const scope = getUnsafe(getCurrent().services, Scope);
|
|
99
|
+
return as(tap(restore(semaphore.take(1)), () => addFinalizer$1(scope, semaphore.release(1))), connection);
|
|
100
|
+
});
|
|
101
|
+
return Object.assign(yield* make$2({
|
|
102
|
+
acquirer,
|
|
103
|
+
compiler,
|
|
104
|
+
transactionAcquirer,
|
|
105
|
+
spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
|
|
106
|
+
transformRows
|
|
107
|
+
}), {
|
|
108
|
+
[TypeId]: TypeId,
|
|
109
|
+
config: options,
|
|
110
|
+
export: flatMap(acquirer, (_) => _.export),
|
|
111
|
+
loadExtension: (path) => flatMap(acquirer, (_) => _.loadExtension(path))
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* @category layers
|
|
116
|
+
* @since 1.0.0
|
|
117
|
+
*/
|
|
118
|
+
const layerConfig = (config) => effectServices(unwrap(config).asEffect().pipe(flatMap(make), map((client) => make$3(SqliteClient, client).pipe(add(SqlClient, client))))).pipe(provide(layer$1));
|
|
119
|
+
/**
|
|
120
|
+
* @category layers
|
|
121
|
+
* @since 1.0.0
|
|
122
|
+
*/
|
|
123
|
+
const layer = (config) => effectServices(map(make(config), (client) => make$3(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide(layer$1));
|
|
124
|
+
//#endregion
|
|
125
|
+
export { SqliteClient, TypeId, layer, layerConfig, make };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=SqliteClient-ChChXcv_.mjs.map
|