@aigne/sqlite 0.1.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/CHANGELOG.md +8 -0
- package/LICENSE.md +93 -0
- package/lib/cjs/index.browser.d.ts +3 -0
- package/lib/cjs/index.browser.js +16 -0
- package/lib/cjs/index.d.ts +4 -0
- package/lib/cjs/index.js +42 -0
- package/lib/cjs/index.node.d.ts +3 -0
- package/lib/cjs/index.node.js +7 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/type.d.ts +52 -0
- package/lib/cjs/type.js +14 -0
- package/lib/esm/index.browser.d.ts +3 -0
- package/lib/esm/index.browser.js +13 -0
- package/lib/esm/index.d.ts +4 -0
- package/lib/esm/index.js +6 -0
- package/lib/esm/index.node.d.ts +3 -0
- package/lib/esm/index.node.js +4 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/type.d.ts +52 -0
- package/lib/esm/type.js +11 -0
- package/package.json +67 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.1.0](https://github.com/AIGNE-io/aigne-framework/compare/sqlite-v0.0.1...sqlite-v0.1.0) (2025-05-29)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* add memory agents support for client agent ([#139](https://github.com/AIGNE-io/aigne-framework/issues/139)) ([57044fa](https://github.com/AIGNE-io/aigne-framework/commit/57044fa87b8abcba395cd05f941d6d312ab65764))
|
package/LICENSE.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
Elastic License 2.0
|
2
|
+
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
4
|
+
|
5
|
+
## Acceptance
|
6
|
+
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
8
|
+
|
9
|
+
## Copyright License
|
10
|
+
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
14
|
+
the limitations and conditions below.
|
15
|
+
|
16
|
+
## Limitations
|
17
|
+
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
19
|
+
service, where the service provides users with access to any substantial set of
|
20
|
+
the features or functionality of the software.
|
21
|
+
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
24
|
+
software that is protected by the license key.
|
25
|
+
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
27
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
28
|
+
to applicable law.
|
29
|
+
|
30
|
+
## Patents
|
31
|
+
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
37
|
+
the software. If you or your company make any written claim that the software
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
41
|
+
company.
|
42
|
+
|
43
|
+
## Notices
|
44
|
+
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
46
|
+
also gets a copy of these terms.
|
47
|
+
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
49
|
+
software prominent notices stating that you have modified the software.
|
50
|
+
|
51
|
+
## No Other Rights
|
52
|
+
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
54
|
+
these terms.
|
55
|
+
|
56
|
+
## Termination
|
57
|
+
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
64
|
+
to terminate automatically and permanently.
|
65
|
+
|
66
|
+
## No Liability
|
67
|
+
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
71
|
+
legal claim.*
|
72
|
+
|
73
|
+
## Definitions
|
74
|
+
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
76
|
+
software the licensor makes available under these terms, including any portion
|
77
|
+
of it.
|
78
|
+
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
80
|
+
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
83
|
+
are under the control of, or are under common control with that
|
84
|
+
organization. **control** means ownership of substantially all the assets of an
|
85
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
86
|
+
otherwise. Control can be direct or indirect.
|
87
|
+
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
89
|
+
these terms.
|
90
|
+
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
92
|
+
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.initDatabase = initDatabase;
|
4
|
+
const sqlite_proxy_1 = require("drizzle-orm/sqlite-proxy");
|
5
|
+
// @ts-ignore sqlocal does not support commonjs, but we can use it in the browser with ESM module
|
6
|
+
const drizzle_1 = require("sqlocal/drizzle");
|
7
|
+
async function initDatabase({ url = ":memory:", } = {}) {
|
8
|
+
const init = Promise.withResolvers();
|
9
|
+
const { driver } = new drizzle_1.SQLocalDrizzle({
|
10
|
+
databasePath: url,
|
11
|
+
onConnect: () => init.resolve(),
|
12
|
+
});
|
13
|
+
await init.promise;
|
14
|
+
const db = (0, sqlite_proxy_1.drizzle)(driver);
|
15
|
+
return db;
|
16
|
+
}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export interface InitDatabaseOptions {
|
2
|
+
url?: string;
|
3
|
+
}
|
4
|
+
export declare function initDatabase(options?: InitDatabaseOptions): Promise<import("drizzle-orm/libsql/driver-core.js").LibSQLDatabase<Record<string, never>> | import("drizzle-orm/sqlite-proxy/driver.js").SqliteRemoteDatabase<Record<string, never>>>;
|
package/lib/cjs/index.js
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.initDatabase = initDatabase;
|
37
|
+
async function initDatabase(options) {
|
38
|
+
if (typeof window === "undefined") {
|
39
|
+
return Promise.resolve().then(() => __importStar(require("./index.node.js"))).then((m) => m.initDatabase(options));
|
40
|
+
}
|
41
|
+
return Promise.resolve().then(() => __importStar(require("./index.browser.js"))).then((m) => m.initDatabase(options));
|
42
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.initDatabase = initDatabase;
|
4
|
+
const libsql_1 = require("drizzle-orm/libsql");
|
5
|
+
async function initDatabase({ url = ":memory:", } = {}) {
|
6
|
+
return (0, libsql_1.drizzle)(url);
|
7
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"type": "commonjs"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
export declare const json: {
|
2
|
+
(): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
3
|
+
name: "";
|
4
|
+
dataType: "custom";
|
5
|
+
columnType: "SQLiteCustomColumn";
|
6
|
+
data: unknown;
|
7
|
+
driverParam: string;
|
8
|
+
enumValues: undefined;
|
9
|
+
}>;
|
10
|
+
<TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
11
|
+
name: "";
|
12
|
+
dataType: "custom";
|
13
|
+
columnType: "SQLiteCustomColumn";
|
14
|
+
data: unknown;
|
15
|
+
driverParam: string;
|
16
|
+
enumValues: undefined;
|
17
|
+
}>;
|
18
|
+
<TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
19
|
+
name: TName;
|
20
|
+
dataType: "custom";
|
21
|
+
columnType: "SQLiteCustomColumn";
|
22
|
+
data: unknown;
|
23
|
+
driverParam: string;
|
24
|
+
enumValues: undefined;
|
25
|
+
}>;
|
26
|
+
};
|
27
|
+
export declare const datetime: {
|
28
|
+
(): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
29
|
+
name: "";
|
30
|
+
dataType: "custom";
|
31
|
+
columnType: "SQLiteCustomColumn";
|
32
|
+
data: Date;
|
33
|
+
driverParam: string;
|
34
|
+
enumValues: undefined;
|
35
|
+
}>;
|
36
|
+
<TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
37
|
+
name: "";
|
38
|
+
dataType: "custom";
|
39
|
+
columnType: "SQLiteCustomColumn";
|
40
|
+
data: Date;
|
41
|
+
driverParam: string;
|
42
|
+
enumValues: undefined;
|
43
|
+
}>;
|
44
|
+
<TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
45
|
+
name: TName;
|
46
|
+
dataType: "custom";
|
47
|
+
columnType: "SQLiteCustomColumn";
|
48
|
+
data: Date;
|
49
|
+
driverParam: string;
|
50
|
+
enumValues: undefined;
|
51
|
+
}>;
|
52
|
+
};
|
package/lib/cjs/type.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.datetime = exports.json = void 0;
|
4
|
+
const sqlite_core_1 = require("drizzle-orm/sqlite-core");
|
5
|
+
exports.json = (0, sqlite_core_1.customType)({
|
6
|
+
dataType: () => "json",
|
7
|
+
fromDriver: (value) => JSON.parse(value),
|
8
|
+
toDriver: (value) => JSON.stringify(value),
|
9
|
+
});
|
10
|
+
exports.datetime = (0, sqlite_core_1.customType)({
|
11
|
+
dataType: () => "datetime",
|
12
|
+
fromDriver: (value) => new Date(value),
|
13
|
+
toDriver: (value) => value.toISOString(),
|
14
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { drizzle } from "drizzle-orm/sqlite-proxy";
|
2
|
+
// @ts-ignore sqlocal does not support commonjs, but we can use it in the browser with ESM module
|
3
|
+
import { SQLocalDrizzle } from "sqlocal/drizzle";
|
4
|
+
export async function initDatabase({ url = ":memory:", } = {}) {
|
5
|
+
const init = Promise.withResolvers();
|
6
|
+
const { driver } = new SQLocalDrizzle({
|
7
|
+
databasePath: url,
|
8
|
+
onConnect: () => init.resolve(),
|
9
|
+
});
|
10
|
+
await init.promise;
|
11
|
+
const db = drizzle(driver);
|
12
|
+
return db;
|
13
|
+
}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export interface InitDatabaseOptions {
|
2
|
+
url?: string;
|
3
|
+
}
|
4
|
+
export declare function initDatabase(options?: InitDatabaseOptions): Promise<import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> | import("drizzle-orm/sqlite-proxy").SqliteRemoteDatabase<Record<string, never>>>;
|
package/lib/esm/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"type": "module"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
export declare const json: {
|
2
|
+
(): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
3
|
+
name: "";
|
4
|
+
dataType: "custom";
|
5
|
+
columnType: "SQLiteCustomColumn";
|
6
|
+
data: unknown;
|
7
|
+
driverParam: string;
|
8
|
+
enumValues: undefined;
|
9
|
+
}>;
|
10
|
+
<TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
11
|
+
name: "";
|
12
|
+
dataType: "custom";
|
13
|
+
columnType: "SQLiteCustomColumn";
|
14
|
+
data: unknown;
|
15
|
+
driverParam: string;
|
16
|
+
enumValues: undefined;
|
17
|
+
}>;
|
18
|
+
<TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
19
|
+
name: TName;
|
20
|
+
dataType: "custom";
|
21
|
+
columnType: "SQLiteCustomColumn";
|
22
|
+
data: unknown;
|
23
|
+
driverParam: string;
|
24
|
+
enumValues: undefined;
|
25
|
+
}>;
|
26
|
+
};
|
27
|
+
export declare const datetime: {
|
28
|
+
(): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
29
|
+
name: "";
|
30
|
+
dataType: "custom";
|
31
|
+
columnType: "SQLiteCustomColumn";
|
32
|
+
data: Date;
|
33
|
+
driverParam: string;
|
34
|
+
enumValues: undefined;
|
35
|
+
}>;
|
36
|
+
<TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
37
|
+
name: "";
|
38
|
+
dataType: "custom";
|
39
|
+
columnType: "SQLiteCustomColumn";
|
40
|
+
data: Date;
|
41
|
+
driverParam: string;
|
42
|
+
enumValues: undefined;
|
43
|
+
}>;
|
44
|
+
<TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/sqlite-core").SQLiteCustomColumnBuilder<{
|
45
|
+
name: TName;
|
46
|
+
dataType: "custom";
|
47
|
+
columnType: "SQLiteCustomColumn";
|
48
|
+
data: Date;
|
49
|
+
driverParam: string;
|
50
|
+
enumValues: undefined;
|
51
|
+
}>;
|
52
|
+
};
|
package/lib/esm/type.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import { customType } from "drizzle-orm/sqlite-core";
|
2
|
+
export const json = customType({
|
3
|
+
dataType: () => "json",
|
4
|
+
fromDriver: (value) => JSON.parse(value),
|
5
|
+
toDriver: (value) => JSON.stringify(value),
|
6
|
+
});
|
7
|
+
export const datetime = customType({
|
8
|
+
dataType: () => "datetime",
|
9
|
+
fromDriver: (value) => new Date(value),
|
10
|
+
toDriver: (value) => value.toISOString(),
|
11
|
+
});
|
package/package.json
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
{
|
2
|
+
"name": "@aigne/sqlite",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "AIGNE SQLite database library for building AI-powered applications",
|
5
|
+
"publishConfig": {
|
6
|
+
"access": "public"
|
7
|
+
},
|
8
|
+
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
9
|
+
"homepage": "https://github.com/AIGNE-io/aigne-framework",
|
10
|
+
"license": "Elastic-2.0",
|
11
|
+
"repository": {
|
12
|
+
"type": "git",
|
13
|
+
"url": "git+https://github.com/AIGNE-io/aigne-framework"
|
14
|
+
},
|
15
|
+
"files": [
|
16
|
+
"lib/cjs",
|
17
|
+
"lib/esm",
|
18
|
+
"LICENSE",
|
19
|
+
"README.md",
|
20
|
+
"CHANGELOG.md"
|
21
|
+
],
|
22
|
+
"type": "module",
|
23
|
+
"types": "./lib/esm/index.d.ts",
|
24
|
+
"exports": {
|
25
|
+
".": {
|
26
|
+
"browser": "./lib/esm/index.browser.js",
|
27
|
+
"node": {
|
28
|
+
"require": "./lib/cjs/index.node.js",
|
29
|
+
"import": "./lib/esm/index.node.js"
|
30
|
+
},
|
31
|
+
"default": "./lib/esm/index.js",
|
32
|
+
"types": "./lib/esm/index.d.ts"
|
33
|
+
},
|
34
|
+
"./type.js": {
|
35
|
+
"require": "./lib/cjs/type.js",
|
36
|
+
"default": "./lib/esm/type.js",
|
37
|
+
"types": "./lib/esm/type.d.ts"
|
38
|
+
}
|
39
|
+
},
|
40
|
+
"typesVersions": {
|
41
|
+
"*": {
|
42
|
+
"type.js": [
|
43
|
+
"./lib/esm/type.d.ts"
|
44
|
+
]
|
45
|
+
}
|
46
|
+
},
|
47
|
+
"dependencies": {
|
48
|
+
"@libsql/client": "^0.15.7",
|
49
|
+
"drizzle-orm": "^0.43.1",
|
50
|
+
"sqlocal": "^0.14.1"
|
51
|
+
},
|
52
|
+
"devDependencies": {
|
53
|
+
"@types/bun": "^1.2.12",
|
54
|
+
"@types/node": "^22.15.15",
|
55
|
+
"npm-run-all": "^4.1.5",
|
56
|
+
"rimraf": "^6.0.1",
|
57
|
+
"typescript": "^5.8.3"
|
58
|
+
},
|
59
|
+
"scripts": {
|
60
|
+
"lint": "tsc --noEmit",
|
61
|
+
"build": "tsc --build scripts/tsconfig.build.json",
|
62
|
+
"clean": "rimraf lib test/coverage",
|
63
|
+
"test": "bun test",
|
64
|
+
"test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text",
|
65
|
+
"postbuild": "echo '{\"type\": \"module\"}' > lib/esm/package.json && echo '{\"type\": \"commonjs\"}' > lib/cjs/package.json"
|
66
|
+
}
|
67
|
+
}
|