@aigne/afs-history 1.2.0 → 1.3.0-beta
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 +14 -0
- package/lib/cjs/index.d.ts +10 -17
- package/lib/cjs/index.js +11 -18
- package/lib/cjs/storage/index.d.ts +5 -13
- package/lib/cjs/storage/index.js +7 -22
- package/lib/cjs/storage/type.d.ts +1 -0
- package/lib/cjs/storage/type.js +9 -0
- package/lib/dts/index.d.ts +10 -17
- package/lib/dts/storage/index.d.ts +5 -15
- package/lib/dts/storage/type.d.ts +1 -0
- package/lib/esm/index.d.ts +10 -17
- package/lib/esm/index.js +11 -18
- package/lib/esm/storage/index.d.ts +5 -15
- package/lib/esm/storage/index.js +5 -19
- package/lib/esm/storage/type.d.ts +1 -0
- package/lib/esm/storage/type.js +8 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@
|
|
|
6
6
|
* dependencies
|
|
7
7
|
* @aigne/afs bumped to 1.2.0
|
|
8
8
|
|
|
9
|
+
## [1.3.0-beta](https://github.com/AIGNE-io/aigne-framework/compare/afs-history-v1.2.0...afs-history-v1.3.0-beta) (2026-01-20)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **afs:** add @aigne/afs-utils package ([#927](https://github.com/AIGNE-io/aigne-framework/issues/927)) ([3922635](https://github.com/AIGNE-io/aigne-framework/commit/3922635981aab4578607c5bf1fb882c8e45725ce))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Dependencies
|
|
18
|
+
|
|
19
|
+
* The following workspace dependencies were updated
|
|
20
|
+
* dependencies
|
|
21
|
+
* @aigne/afs-utils bumped to 1.0.0
|
|
22
|
+
|
|
9
23
|
## [1.2.0](https://github.com/AIGNE-io/aigne-framework/compare/afs-history-v1.2.0-beta.12...afs-history-v1.2.0) (2026-01-16)
|
|
10
24
|
|
|
11
25
|
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type AFSAccessMode, type AFSDeleteOptions, type AFSDeleteResult, type AFSListOptions, type AFSListResult, type AFSModule, type AFSModuleLoadParams, type AFSReadOptions, type AFSReadResult, type AFSRoot, type AFSWriteEntryPayload, type AFSWriteOptions, type AFSWriteResult } from "@aigne/afs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { type AFSStorage, type AFSStorageSQLiteOptions } from "./storage/index.js";
|
|
4
4
|
export * from "./storage/index.js";
|
|
5
5
|
export interface AFSHistoryOptions {
|
|
6
|
-
storage?:
|
|
6
|
+
storage?: AFSStorage | AFSStorageSQLiteOptions;
|
|
7
7
|
/**
|
|
8
8
|
* Access mode for this module.
|
|
9
9
|
* @default "readwrite"
|
|
@@ -11,26 +11,19 @@ export interface AFSHistoryOptions {
|
|
|
11
11
|
accessMode?: AFSAccessMode;
|
|
12
12
|
}
|
|
13
13
|
export declare class AFSHistory implements AFSModule {
|
|
14
|
-
static schema(): z.ZodObject<{
|
|
15
|
-
storage: z.
|
|
16
|
-
url: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
url?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
url?: string | undefined;
|
|
21
|
-
}>>;
|
|
14
|
+
static schema(): z.ZodEffects<z.ZodObject<{
|
|
15
|
+
storage: z.ZodType<any, z.ZodTypeDef, any>;
|
|
22
16
|
accessMode: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
|
|
23
17
|
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
storage?:
|
|
25
|
-
url?: string | undefined;
|
|
26
|
-
} | undefined;
|
|
18
|
+
storage?: any;
|
|
27
19
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
28
20
|
}, {
|
|
29
|
-
storage?:
|
|
30
|
-
url?: string | undefined;
|
|
31
|
-
} | undefined;
|
|
21
|
+
storage?: any;
|
|
32
22
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
33
|
-
}
|
|
23
|
+
}>, {
|
|
24
|
+
storage?: any;
|
|
25
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
26
|
+
}, any>;
|
|
34
27
|
static load({ parsed }: AFSModuleLoadParams): Promise<AFSHistory>;
|
|
35
28
|
constructor(options?: AFSHistoryOptions);
|
|
36
29
|
readonly name: string;
|
package/lib/cjs/index.js
CHANGED
|
@@ -16,22 +16,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.AFSHistory = void 0;
|
|
18
18
|
const afs_1 = require("@aigne/afs");
|
|
19
|
+
const index_js_1 = require("@aigne/afs-utils/zod/index.js");
|
|
19
20
|
const uuid_1 = require("@aigne/uuid");
|
|
20
21
|
const radix3_1 = require("radix3");
|
|
21
22
|
const ufo_1 = require("ufo");
|
|
22
23
|
const zod_1 = require("zod");
|
|
23
|
-
const
|
|
24
|
+
const index_js_2 = require("./storage/index.js");
|
|
24
25
|
__exportStar(require("./storage/index.js"), exports);
|
|
25
|
-
const
|
|
26
|
-
url: zod_1.z.string().describe("Database URL for storage")
|
|
27
|
-
});
|
|
28
|
-
const afsHistoryOptionsSchema =
|
|
29
|
-
|
|
30
|
-
return v;
|
|
31
|
-
}
|
|
32
|
-
return { ...v, accessMode: v.accessMode || v.access_mode };
|
|
33
|
-
}, zod_1.z.object({
|
|
34
|
-
storage: sharedAFSStorageOptionsSchema.optional(),
|
|
26
|
+
const afsStorageOptionsSchema = (0, index_js_1.camelize)(zod_1.z.object({
|
|
27
|
+
url: (0, index_js_1.optionalize)(zod_1.z.string().describe("Database URL for storage")),
|
|
28
|
+
}));
|
|
29
|
+
const afsHistoryOptionsSchema = (0, index_js_1.camelize)(zod_1.z.object({
|
|
30
|
+
storage: (0, index_js_1.optionalize)(zod_1.z.union([zod_1.z.custom((v) => (0, index_js_2.isAFSStorage)(v)), afsStorageOptionsSchema])),
|
|
35
31
|
accessMode: afs_1.accessModeSchema,
|
|
36
32
|
}));
|
|
37
33
|
class AFSHistory {
|
|
@@ -43,10 +39,10 @@ class AFSHistory {
|
|
|
43
39
|
return new AFSHistory(valid);
|
|
44
40
|
}
|
|
45
41
|
constructor(options) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
(0, index_js_1.zodParse)((0, index_js_1.optionalize)(afsHistoryOptionsSchema), options);
|
|
43
|
+
this.storage = (0, index_js_2.isAFSStorage)(options?.storage)
|
|
44
|
+
? options.storage
|
|
45
|
+
: new index_js_2.AFSStorageSQLite(this, options?.storage);
|
|
50
46
|
this.accessMode = options?.accessMode ?? "readwrite";
|
|
51
47
|
}
|
|
52
48
|
name = "history";
|
|
@@ -276,6 +272,3 @@ class AFSHistory {
|
|
|
276
272
|
}
|
|
277
273
|
exports.AFSHistory = AFSHistory;
|
|
278
274
|
const _typeCheck = AFSHistory;
|
|
279
|
-
function preprocessSchema(fn, schema) {
|
|
280
|
-
return zod_1.z.preprocess(fn, schema);
|
|
281
|
-
}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import type { AFSEntry, AFSModule } from "@aigne/afs";
|
|
2
|
-
import { initDatabase } from "@aigne/sqlite";
|
|
3
2
|
import type { AFSStorage, AFSStorageCreateOptions, AFSStorageCreatePayload, AFSStorageDeleteOptions, AFSStorageListOptions, AFSStorageReadOptions } from "./type.js";
|
|
4
3
|
export * from "./type.js";
|
|
5
|
-
export interface
|
|
4
|
+
export interface AFSStorageSQLiteOptions {
|
|
6
5
|
url?: string;
|
|
7
6
|
}
|
|
8
|
-
export declare class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get db(): Promise<import("drizzle-orm/sqlite-proxy/driver.js").SqliteRemoteDatabase<Record<string, never>>>;
|
|
13
|
-
withModule(module: AFSModule): AFSStorage;
|
|
14
|
-
}
|
|
15
|
-
export declare class AFSStorageWithModule implements AFSStorage {
|
|
16
|
-
private db;
|
|
17
|
-
private module;
|
|
18
|
-
constructor(db: ReturnType<typeof initDatabase>, module: AFSModule);
|
|
7
|
+
export declare class AFSStorageSQLite implements AFSStorage {
|
|
8
|
+
module: AFSModule;
|
|
9
|
+
options?: AFSStorageSQLiteOptions | undefined;
|
|
10
|
+
constructor(module: AFSModule, options?: AFSStorageSQLiteOptions | undefined);
|
|
19
11
|
private _tables?;
|
|
20
12
|
private get tables();
|
|
21
13
|
list(options?: AFSStorageListOptions): Promise<{
|
package/lib/cjs/storage/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.AFSStorageSQLite = void 0;
|
|
18
18
|
const sqlite_1 = require("@aigne/sqlite");
|
|
19
19
|
const migrate_js_1 = require("./migrate.js");
|
|
20
20
|
const compact_js_1 = require("./models/compact.js");
|
|
@@ -22,32 +22,17 @@ const entries_js_1 = require("./models/entries.js");
|
|
|
22
22
|
const memory_js_1 = require("./models/memory.js");
|
|
23
23
|
__exportStar(require("./type.js"), exports);
|
|
24
24
|
const DEFAULT_AFS_STORAGE_LIST_LIMIT = 10;
|
|
25
|
-
class
|
|
26
|
-
options;
|
|
27
|
-
constructor(options) {
|
|
28
|
-
this.options = options;
|
|
29
|
-
}
|
|
30
|
-
_db;
|
|
31
|
-
get db() {
|
|
32
|
-
this._db ??= (0, sqlite_1.initDatabase)({ url: this.options?.url });
|
|
33
|
-
return this._db;
|
|
34
|
-
}
|
|
35
|
-
withModule(module) {
|
|
36
|
-
return new AFSStorageWithModule(this.db, module);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.SharedAFSStorage = SharedAFSStorage;
|
|
40
|
-
class AFSStorageWithModule {
|
|
41
|
-
db;
|
|
25
|
+
class AFSStorageSQLite {
|
|
42
26
|
module;
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
options;
|
|
28
|
+
constructor(module, options) {
|
|
45
29
|
this.module = module;
|
|
30
|
+
this.options = options;
|
|
46
31
|
}
|
|
47
32
|
_tables;
|
|
48
33
|
get tables() {
|
|
49
34
|
if (!this._tables) {
|
|
50
|
-
this._tables = this.
|
|
35
|
+
this._tables = (0, sqlite_1.initDatabase)({ url: this.options?.url }).then((db) => (0, migrate_js_1.migrate)(db, this.module).then(() => ({
|
|
51
36
|
db,
|
|
52
37
|
entries: (0, entries_js_1.entriesTable)(this.module),
|
|
53
38
|
compact: (0, compact_js_1.compactTable)(this.module),
|
|
@@ -130,4 +115,4 @@ class AFSStorageWithModule {
|
|
|
130
115
|
return { deletedCount: result.length };
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
|
-
exports.
|
|
118
|
+
exports.AFSStorageSQLite = AFSStorageSQLite;
|
package/lib/cjs/storage/type.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAFSStorage = isAFSStorage;
|
|
4
|
+
function isAFSStorage(value) {
|
|
5
|
+
return (!!value &&
|
|
6
|
+
typeof value === "object" &&
|
|
7
|
+
typeof value.create === "function" &&
|
|
8
|
+
typeof value.list === "function" &&
|
|
9
|
+
typeof value.read === "function" &&
|
|
10
|
+
typeof value.delete === "function");
|
|
11
|
+
}
|
package/lib/dts/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type AFSAccessMode, type AFSDeleteOptions, type AFSDeleteResult, type AFSListOptions, type AFSListResult, type AFSModule, type AFSModuleLoadParams, type AFSReadOptions, type AFSReadResult, type AFSRoot, type AFSWriteEntryPayload, type AFSWriteOptions, type AFSWriteResult } from "@aigne/afs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { type AFSStorage, type AFSStorageSQLiteOptions } from "./storage/index.js";
|
|
4
4
|
export * from "./storage/index.js";
|
|
5
5
|
export interface AFSHistoryOptions {
|
|
6
|
-
storage?:
|
|
6
|
+
storage?: AFSStorage | AFSStorageSQLiteOptions;
|
|
7
7
|
/**
|
|
8
8
|
* Access mode for this module.
|
|
9
9
|
* @default "readwrite"
|
|
@@ -11,26 +11,19 @@ export interface AFSHistoryOptions {
|
|
|
11
11
|
accessMode?: AFSAccessMode;
|
|
12
12
|
}
|
|
13
13
|
export declare class AFSHistory implements AFSModule {
|
|
14
|
-
static schema(): z.ZodObject<{
|
|
15
|
-
storage: z.
|
|
16
|
-
url: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
url?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
url?: string | undefined;
|
|
21
|
-
}>>;
|
|
14
|
+
static schema(): z.ZodEffects<z.ZodObject<{
|
|
15
|
+
storage: z.ZodType<any, z.ZodTypeDef, any>;
|
|
22
16
|
accessMode: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
|
|
23
17
|
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
storage?:
|
|
25
|
-
url?: string | undefined;
|
|
26
|
-
} | undefined;
|
|
18
|
+
storage?: any;
|
|
27
19
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
28
20
|
}, {
|
|
29
|
-
storage?:
|
|
30
|
-
url?: string | undefined;
|
|
31
|
-
} | undefined;
|
|
21
|
+
storage?: any;
|
|
32
22
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
33
|
-
}
|
|
23
|
+
}>, {
|
|
24
|
+
storage?: any;
|
|
25
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
26
|
+
}, any>;
|
|
34
27
|
static load({ parsed }: AFSModuleLoadParams): Promise<AFSHistory>;
|
|
35
28
|
constructor(options?: AFSHistoryOptions);
|
|
36
29
|
readonly name: string;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import type { AFSEntry, AFSModule } from "@aigne/afs";
|
|
2
|
-
import { initDatabase } from "@aigne/sqlite";
|
|
3
2
|
import type { AFSStorage, AFSStorageCreateOptions, AFSStorageCreatePayload, AFSStorageDeleteOptions, AFSStorageListOptions, AFSStorageReadOptions } from "./type.js";
|
|
4
3
|
export * from "./type.js";
|
|
5
|
-
export interface
|
|
4
|
+
export interface AFSStorageSQLiteOptions {
|
|
6
5
|
url?: string;
|
|
7
6
|
}
|
|
8
|
-
export declare class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get db(): Promise<import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> & {
|
|
13
|
-
vacuum?: () => Promise<void>;
|
|
14
|
-
}>;
|
|
15
|
-
withModule(module: AFSModule): AFSStorage;
|
|
16
|
-
}
|
|
17
|
-
export declare class AFSStorageWithModule implements AFSStorage {
|
|
18
|
-
private db;
|
|
19
|
-
private module;
|
|
20
|
-
constructor(db: ReturnType<typeof initDatabase>, module: AFSModule);
|
|
7
|
+
export declare class AFSStorageSQLite implements AFSStorage {
|
|
8
|
+
module: AFSModule;
|
|
9
|
+
options?: AFSStorageSQLiteOptions | undefined;
|
|
10
|
+
constructor(module: AFSModule, options?: AFSStorageSQLiteOptions | undefined);
|
|
21
11
|
private _tables?;
|
|
22
12
|
private get tables();
|
|
23
13
|
list(options?: AFSStorageListOptions): Promise<{
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type AFSAccessMode, type AFSDeleteOptions, type AFSDeleteResult, type AFSListOptions, type AFSListResult, type AFSModule, type AFSModuleLoadParams, type AFSReadOptions, type AFSReadResult, type AFSRoot, type AFSWriteEntryPayload, type AFSWriteOptions, type AFSWriteResult } from "@aigne/afs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { type AFSStorage, type AFSStorageSQLiteOptions } from "./storage/index.js";
|
|
4
4
|
export * from "./storage/index.js";
|
|
5
5
|
export interface AFSHistoryOptions {
|
|
6
|
-
storage?:
|
|
6
|
+
storage?: AFSStorage | AFSStorageSQLiteOptions;
|
|
7
7
|
/**
|
|
8
8
|
* Access mode for this module.
|
|
9
9
|
* @default "readwrite"
|
|
@@ -11,26 +11,19 @@ export interface AFSHistoryOptions {
|
|
|
11
11
|
accessMode?: AFSAccessMode;
|
|
12
12
|
}
|
|
13
13
|
export declare class AFSHistory implements AFSModule {
|
|
14
|
-
static schema(): z.ZodObject<{
|
|
15
|
-
storage: z.
|
|
16
|
-
url: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
url?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
url?: string | undefined;
|
|
21
|
-
}>>;
|
|
14
|
+
static schema(): z.ZodEffects<z.ZodObject<{
|
|
15
|
+
storage: z.ZodType<any, z.ZodTypeDef, any>;
|
|
22
16
|
accessMode: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
|
|
23
17
|
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
storage?:
|
|
25
|
-
url?: string | undefined;
|
|
26
|
-
} | undefined;
|
|
18
|
+
storage?: any;
|
|
27
19
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
28
20
|
}, {
|
|
29
|
-
storage?:
|
|
30
|
-
url?: string | undefined;
|
|
31
|
-
} | undefined;
|
|
21
|
+
storage?: any;
|
|
32
22
|
accessMode?: "readonly" | "readwrite" | undefined;
|
|
33
|
-
}
|
|
23
|
+
}>, {
|
|
24
|
+
storage?: any;
|
|
25
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
26
|
+
}, any>;
|
|
34
27
|
static load({ parsed }: AFSModuleLoadParams): Promise<AFSHistory>;
|
|
35
28
|
constructor(options?: AFSHistoryOptions);
|
|
36
29
|
readonly name: string;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { accessModeSchema, } from "@aigne/afs";
|
|
2
|
+
import { camelize, optionalize, zodParse } from "@aigne/afs-utils/zod/index.js";
|
|
2
3
|
import { v7 } from "@aigne/uuid";
|
|
3
4
|
import { createRouter } from "radix3";
|
|
4
5
|
import { joinURL } from "ufo";
|
|
5
6
|
import { z } from "zod";
|
|
6
|
-
import {
|
|
7
|
+
import { AFSStorageSQLite, isAFSStorage, } from "./storage/index.js";
|
|
7
8
|
export * from "./storage/index.js";
|
|
8
|
-
const
|
|
9
|
-
url: z.string().describe("Database URL for storage")
|
|
10
|
-
});
|
|
11
|
-
const afsHistoryOptionsSchema =
|
|
12
|
-
|
|
13
|
-
return v;
|
|
14
|
-
}
|
|
15
|
-
return { ...v, accessMode: v.accessMode || v.access_mode };
|
|
16
|
-
}, z.object({
|
|
17
|
-
storage: sharedAFSStorageOptionsSchema.optional(),
|
|
9
|
+
const afsStorageOptionsSchema = camelize(z.object({
|
|
10
|
+
url: optionalize(z.string().describe("Database URL for storage")),
|
|
11
|
+
}));
|
|
12
|
+
const afsHistoryOptionsSchema = camelize(z.object({
|
|
13
|
+
storage: optionalize(z.union([z.custom((v) => isAFSStorage(v)), afsStorageOptionsSchema])),
|
|
18
14
|
accessMode: accessModeSchema,
|
|
19
15
|
}));
|
|
20
16
|
export class AFSHistory {
|
|
@@ -26,10 +22,10 @@ export class AFSHistory {
|
|
|
26
22
|
return new AFSHistory(valid);
|
|
27
23
|
}
|
|
28
24
|
constructor(options) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
zodParse(optionalize(afsHistoryOptionsSchema), options);
|
|
26
|
+
this.storage = isAFSStorage(options?.storage)
|
|
27
|
+
? options.storage
|
|
28
|
+
: new AFSStorageSQLite(this, options?.storage);
|
|
33
29
|
this.accessMode = options?.accessMode ?? "readwrite";
|
|
34
30
|
}
|
|
35
31
|
name = "history";
|
|
@@ -258,6 +254,3 @@ export class AFSHistory {
|
|
|
258
254
|
}
|
|
259
255
|
}
|
|
260
256
|
const _typeCheck = AFSHistory;
|
|
261
|
-
function preprocessSchema(fn, schema) {
|
|
262
|
-
return z.preprocess(fn, schema);
|
|
263
|
-
}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import type { AFSEntry, AFSModule } from "@aigne/afs";
|
|
2
|
-
import { initDatabase } from "@aigne/sqlite";
|
|
3
2
|
import type { AFSStorage, AFSStorageCreateOptions, AFSStorageCreatePayload, AFSStorageDeleteOptions, AFSStorageListOptions, AFSStorageReadOptions } from "./type.js";
|
|
4
3
|
export * from "./type.js";
|
|
5
|
-
export interface
|
|
4
|
+
export interface AFSStorageSQLiteOptions {
|
|
6
5
|
url?: string;
|
|
7
6
|
}
|
|
8
|
-
export declare class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get db(): Promise<import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> & {
|
|
13
|
-
vacuum?: () => Promise<void>;
|
|
14
|
-
}>;
|
|
15
|
-
withModule(module: AFSModule): AFSStorage;
|
|
16
|
-
}
|
|
17
|
-
export declare class AFSStorageWithModule implements AFSStorage {
|
|
18
|
-
private db;
|
|
19
|
-
private module;
|
|
20
|
-
constructor(db: ReturnType<typeof initDatabase>, module: AFSModule);
|
|
7
|
+
export declare class AFSStorageSQLite implements AFSStorage {
|
|
8
|
+
module: AFSModule;
|
|
9
|
+
options?: AFSStorageSQLiteOptions | undefined;
|
|
10
|
+
constructor(module: AFSModule, options?: AFSStorageSQLiteOptions | undefined);
|
|
21
11
|
private _tables?;
|
|
22
12
|
private get tables();
|
|
23
13
|
list(options?: AFSStorageListOptions): Promise<{
|
package/lib/esm/storage/index.js
CHANGED
|
@@ -5,31 +5,17 @@ import { entriesTable } from "./models/entries.js";
|
|
|
5
5
|
import { memoryTable } from "./models/memory.js";
|
|
6
6
|
export * from "./type.js";
|
|
7
7
|
const DEFAULT_AFS_STORAGE_LIST_LIMIT = 10;
|
|
8
|
-
export class
|
|
9
|
-
options;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
this.options = options;
|
|
12
|
-
}
|
|
13
|
-
_db;
|
|
14
|
-
get db() {
|
|
15
|
-
this._db ??= initDatabase({ url: this.options?.url });
|
|
16
|
-
return this._db;
|
|
17
|
-
}
|
|
18
|
-
withModule(module) {
|
|
19
|
-
return new AFSStorageWithModule(this.db, module);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export class AFSStorageWithModule {
|
|
23
|
-
db;
|
|
8
|
+
export class AFSStorageSQLite {
|
|
24
9
|
module;
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
options;
|
|
11
|
+
constructor(module, options) {
|
|
27
12
|
this.module = module;
|
|
13
|
+
this.options = options;
|
|
28
14
|
}
|
|
29
15
|
_tables;
|
|
30
16
|
get tables() {
|
|
31
17
|
if (!this._tables) {
|
|
32
|
-
this._tables = this.
|
|
18
|
+
this._tables = initDatabase({ url: this.options?.url }).then((db) => migrate(db, this.module).then(() => ({
|
|
33
19
|
db,
|
|
34
20
|
entries: entriesTable(this.module),
|
|
35
21
|
compact: compactTable(this.module),
|
package/lib/esm/storage/type.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/afs-history",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-beta",
|
|
4
4
|
"description": "AIGNE AFS module for managing chat history",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -51,8 +51,9 @@
|
|
|
51
51
|
"radix3": "^1.1.2",
|
|
52
52
|
"ufo": "^1.6.1",
|
|
53
53
|
"zod": "^3.25.67",
|
|
54
|
-
"@aigne/
|
|
55
|
-
"@aigne/
|
|
54
|
+
"@aigne/sqlite": "^0.4.9",
|
|
55
|
+
"@aigne/afs-utils": "^1.0.0",
|
|
56
|
+
"@aigne/afs": "^1.4.0"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"@types/bun": "^1.2.22",
|