codexuse-cli 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -16
- package/dist/index.js +7983 -4734
- package/dist/index.js.map +1 -1
- package/package.json +5 -11
- package/dist/server/NodeSqliteClient-ColmybgR.mjs +0 -139
- package/dist/server/SqlError-Bsa-lRNq.mjs +0 -28
- package/dist/server/SqliteClient-CFZi0MEE.mjs +0 -127
- package/dist/server/index.mjs +0 -88818
- package/dist/server/open-qeX1IlWK.mjs +0 -554
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexuse-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "CodexUse CLI for profiles, Accounts Pool,
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "CodexUse CLI for profiles, Accounts Pool, licenses, and sync.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Hoang",
|
|
7
7
|
"email": "hoangmaths96@gmail.com"
|
|
@@ -19,21 +19,15 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "tsup && node scripts/
|
|
23
|
-
"typecheck": "bunx tsc --
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"ws": "^8.21.0"
|
|
27
|
-
},
|
|
28
|
-
"optionalDependencies": {
|
|
29
|
-
"node-pty": "^1.1.0"
|
|
22
|
+
"build": "tsup && node scripts/chmod.js",
|
|
23
|
+
"typecheck": "bunx tsc -b tsconfig.typecheck.json --pretty false"
|
|
30
24
|
},
|
|
25
|
+
"dependencies": {},
|
|
31
26
|
"devDependencies": {
|
|
32
27
|
"@codexuse/contracts": "workspace:*",
|
|
33
28
|
"@codexuse/runtime-app-state": "workspace:*",
|
|
34
29
|
"@codexuse/runtime-codex": "workspace:*",
|
|
35
30
|
"@codexuse/runtime-profiles": "workspace:*",
|
|
36
|
-
"@codexuse/shared": "workspace:*",
|
|
37
31
|
"tsup": "catalog:",
|
|
38
32
|
"typescript": "catalog:"
|
|
39
33
|
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { A as try_, B as get, C as flatMap, D as succeed, E as scope, F as provide, H as make$4, I as Scope, L as addFinalizer, M as void_, N as withFiber, O as sync, P as effectServices, R as Service, S as fail, T as map, U as minutes, V as getUnsafe, W as identity, _ as getCurrent, a as makeCompilerSqlite, b as as, c as get$1, g as make$2, h as die$1, i as defaultTransforms, j as uninterruptibleMask, k as tap, l as make$1, n as SqlClient, o as layer$1, r as make$3, s as unwrap, t as SafeIntegers, v as acquireUseRelease, w as gen, x as die, z as add } from "./index.mjs";
|
|
4
|
-
import { t as SqlError } from "./SqlError-Bsa-lRNq.mjs";
|
|
5
|
-
import { DatabaseSync } from "node:sqlite";
|
|
6
|
-
//#region src/persistence/NodeSqliteClient.ts
|
|
7
|
-
/**
|
|
8
|
-
* Port of `@effect/sql-sqlite-node` that uses the native `node:sqlite`
|
|
9
|
-
* bindings instead of `better-sqlite3`.
|
|
10
|
-
*
|
|
11
|
-
* @module SqliteClient
|
|
12
|
-
*/
|
|
13
|
-
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
14
|
-
const TypeId = "~local/sqlite-node/SqliteClient";
|
|
15
|
-
/**
|
|
16
|
-
* SqliteClient - Effect service tag for the sqlite SQL client.
|
|
17
|
-
*/
|
|
18
|
-
const SqliteClient = Service("t3/persistence/NodeSqliteClient");
|
|
19
|
-
/**
|
|
20
|
-
* Verify that the current Node.js version includes the `node:sqlite` APIs
|
|
21
|
-
* used by `NodeSqliteClient` — specifically `StatementSync.columns()` (added
|
|
22
|
-
* in Node 22.16.0 / 23.11.0).
|
|
23
|
-
*
|
|
24
|
-
* @see https://github.com/nodejs/node/pull/57490
|
|
25
|
-
*/
|
|
26
|
-
const checkNodeSqliteCompat = () => {
|
|
27
|
-
const parts = process.versions.node.split(".").map(Number);
|
|
28
|
-
const major = parts[0] ?? 0;
|
|
29
|
-
const minor = parts[1] ?? 0;
|
|
30
|
-
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.`);
|
|
31
|
-
return void_;
|
|
32
|
-
};
|
|
33
|
-
const makeWithDatabase = (options, openDatabase) => gen(function* () {
|
|
34
|
-
yield* checkNodeSqliteCompat();
|
|
35
|
-
const compiler = makeCompilerSqlite(options.transformQueryNames);
|
|
36
|
-
const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
|
|
37
|
-
const makeConnection = gen(function* () {
|
|
38
|
-
const scope$1 = yield* scope;
|
|
39
|
-
const db = openDatabase();
|
|
40
|
-
yield* addFinalizer(scope$1, sync(() => db.close()));
|
|
41
|
-
const statementReaderCache = /* @__PURE__ */ new WeakMap();
|
|
42
|
-
const hasRows = (statement) => {
|
|
43
|
-
const cached = statementReaderCache.get(statement);
|
|
44
|
-
if (cached !== void 0) return cached;
|
|
45
|
-
const value = statement.columns().length > 0;
|
|
46
|
-
statementReaderCache.set(statement, value);
|
|
47
|
-
return value;
|
|
48
|
-
};
|
|
49
|
-
const prepareCache = yield* make$1({
|
|
50
|
-
capacity: options.prepareCacheSize ?? 200,
|
|
51
|
-
timeToLive: options.prepareCacheTTL ?? minutes(10),
|
|
52
|
-
lookup: (sql) => try_({
|
|
53
|
-
try: () => db.prepare(sql),
|
|
54
|
-
catch: (cause) => new SqlError({
|
|
55
|
-
cause,
|
|
56
|
-
message: "Failed to prepare statement"
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
});
|
|
60
|
-
const runStatement = (statement, params, raw) => withFiber((fiber) => {
|
|
61
|
-
statement.setReadBigInts(Boolean(get(fiber.services, SafeIntegers)));
|
|
62
|
-
try {
|
|
63
|
-
if (hasRows(statement)) return succeed(statement.all(...params));
|
|
64
|
-
const result = statement.run(...params);
|
|
65
|
-
return succeed(raw ? result : []);
|
|
66
|
-
} catch (cause) {
|
|
67
|
-
return fail(new SqlError({
|
|
68
|
-
cause,
|
|
69
|
-
message: "Failed to execute statement"
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const run = (sql, params, raw = false) => flatMap(get$1(prepareCache, sql), (s) => runStatement(s, params, raw));
|
|
74
|
-
const runValues = (sql, params) => acquireUseRelease(get$1(prepareCache, sql), (statement) => try_({
|
|
75
|
-
try: () => {
|
|
76
|
-
if (hasRows(statement)) {
|
|
77
|
-
statement.setReturnArrays(true);
|
|
78
|
-
return statement.all(...params);
|
|
79
|
-
}
|
|
80
|
-
statement.run(...params);
|
|
81
|
-
return [];
|
|
82
|
-
},
|
|
83
|
-
catch: (cause) => new SqlError({
|
|
84
|
-
cause,
|
|
85
|
-
message: "Failed to execute statement"
|
|
86
|
-
})
|
|
87
|
-
}), (statement) => sync(() => {
|
|
88
|
-
if (hasRows(statement)) statement.setReturnArrays(false);
|
|
89
|
-
}));
|
|
90
|
-
return identity({
|
|
91
|
-
execute(sql, params, rowTransform) {
|
|
92
|
-
return rowTransform ? map(run(sql, params), rowTransform) : run(sql, params);
|
|
93
|
-
},
|
|
94
|
-
executeRaw(sql, params) {
|
|
95
|
-
return run(sql, params, true);
|
|
96
|
-
},
|
|
97
|
-
executeValues(sql, params) {
|
|
98
|
-
return runValues(sql, params);
|
|
99
|
-
},
|
|
100
|
-
executeUnprepared(sql, params, rowTransform) {
|
|
101
|
-
const effect = runStatement(db.prepare(sql), params ?? [], false);
|
|
102
|
-
return rowTransform ? map(effect, rowTransform) : effect;
|
|
103
|
-
},
|
|
104
|
-
executeStream(_sql, _params) {
|
|
105
|
-
return die$1("executeStream not implemented");
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
const semaphore = yield* make$2(1);
|
|
110
|
-
const connection = yield* makeConnection;
|
|
111
|
-
return yield* make$3({
|
|
112
|
-
acquirer: semaphore.withPermits(1)(succeed(connection)),
|
|
113
|
-
compiler,
|
|
114
|
-
transactionAcquirer: uninterruptibleMask((restore) => {
|
|
115
|
-
const scope = getUnsafe(getCurrent().services, Scope);
|
|
116
|
-
return as(tap(restore(semaphore.take(1)), () => addFinalizer(scope, semaphore.release(1))), connection);
|
|
117
|
-
}),
|
|
118
|
-
spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
|
|
119
|
-
transformRows
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
const make = (options) => makeWithDatabase(options, () => new DatabaseSync(options.filename, {
|
|
123
|
-
readOnly: options.readonly ?? false,
|
|
124
|
-
allowExtension: options.allowExtension ?? false
|
|
125
|
-
}));
|
|
126
|
-
const makeMemory = (config = {}) => makeWithDatabase({
|
|
127
|
-
...config,
|
|
128
|
-
filename: ":memory:",
|
|
129
|
-
readonly: false
|
|
130
|
-
}, () => {
|
|
131
|
-
return new DatabaseSync(":memory:", { allowExtension: config.allowExtension ?? false });
|
|
132
|
-
});
|
|
133
|
-
const layerConfig = (config) => effectServices(unwrap(config).asEffect().pipe(flatMap(make), map((client) => make$4(SqliteClient, client).pipe(add(SqlClient, client))))).pipe(provide(layer$1));
|
|
134
|
-
const layer = (config) => effectServices(map(make(config), (client) => make$4(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide(layer$1));
|
|
135
|
-
const layerMemory = (config = {}) => effectServices(map(makeMemory(config), (client) => make$4(SqliteClient, client).pipe(add(SqlClient, client)))).pipe(provide(layer$1));
|
|
136
|
-
//#endregion
|
|
137
|
-
export { SqliteClient, TypeId, layer, layerConfig, layerMemory };
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=NodeSqliteClient-ColmybgR.mjs.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { d as Number, f as String, m as optional, p as TaggedErrorClass, u as Defect } from "./index.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-Bsa-lRNq.mjs.map
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { A as try_, B as get, C as flatMap, D as succeed, F as provide, H as make$3, I as Scope, L as addFinalizer$1, N as withFiber, O as sync, P as effectServices, R as Service, S as fail, T as map, V as getUnsafe, W as identity, _ as getCurrent, a as makeCompilerSqlite, b as as, g as make$1, h as die, i as defaultTransforms, j as uninterruptibleMask, k as tap, n as SqlClient, o as layer$1, r as make$2, s as unwrap, t as SafeIntegers, w as gen, y as addFinalizer, z as add } from "./index.mjs";
|
|
4
|
-
import { t as SqlError } from "./SqlError-Bsa-lRNq.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-CFZi0MEE.mjs.map
|