polystore 0.21.2 → 0.22.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/index.d.ts +11 -11
- package/index.js +189 -189
- package/package.json +61 -56
- package/readme.md +92 -58
- package/src/plugins/better-auth/index.d.ts +18 -0
- package/src/plugins/better-auth/index.js +27 -0
- package/src/plugins/express/index.d.ts +20 -0
- package/src/{integrations/express.js → plugins/express/index.js} +3 -3
- package/src/plugins/hono-sessions/index.d.ts +15 -0
- package/src/{integrations/hono-sessions.js → plugins/hono-sessions/index.js} +3 -3
- package/src/integrations/express.d.ts +0 -307
- package/src/integrations/hono-sessions.d.ts +0 -299
package/index.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ type StoreData<T extends Serializable = Serializable> = {
|
|
|
11
11
|
type Serializable = string | number | boolean | null | (Serializable | null)[] | {
|
|
12
12
|
[key: string]: Serializable | null;
|
|
13
13
|
};
|
|
14
|
-
interface
|
|
14
|
+
interface AdapterExpires {
|
|
15
15
|
TYPE: string;
|
|
16
16
|
HAS_EXPIRATION: true;
|
|
17
17
|
promise?: Promise<any>;
|
|
18
|
-
test?: (
|
|
18
|
+
test?: (raw: any) => boolean;
|
|
19
19
|
get<T extends Serializable>(key: string): Promise<T | null> | T | null;
|
|
20
20
|
set<T extends Serializable>(key: string, value: T, expires?: Expires): Promise<any> | any;
|
|
21
21
|
iterate<T extends Serializable>(prefix: string): AsyncGenerator<[string, T], void, unknown> | Generator<[string, T], void, unknown>;
|
|
@@ -30,11 +30,11 @@ interface ClientExpires {
|
|
|
30
30
|
clearAll?(): Promise<any> | any;
|
|
31
31
|
close?(): Promise<any> | any;
|
|
32
32
|
}
|
|
33
|
-
interface
|
|
33
|
+
interface AdapterNonExpires {
|
|
34
34
|
TYPE: string;
|
|
35
35
|
HAS_EXPIRATION: false;
|
|
36
36
|
promise?: Promise<any>;
|
|
37
|
-
test?: (
|
|
37
|
+
test?: (raw: any) => boolean;
|
|
38
38
|
get<T extends Serializable>(key: string): Promise<StoreData<T> | null> | StoreData<T> | null;
|
|
39
39
|
set<T extends Serializable>(key: string, value: StoreData<T> | null, ttl?: Expires): Promise<any> | any;
|
|
40
40
|
iterate<T extends Serializable>(prefix: string): AsyncGenerator<[string, StoreData<T>], void, unknown> | Generator<[string, StoreData<T>], void, unknown>;
|
|
@@ -50,16 +50,16 @@ interface ClientNonExpires {
|
|
|
50
50
|
clearAll?(): Promise<any> | any;
|
|
51
51
|
close?(): Promise<any> | any;
|
|
52
52
|
}
|
|
53
|
-
type
|
|
53
|
+
type Adapter = AdapterExpires | AdapterNonExpires;
|
|
54
54
|
|
|
55
55
|
declare class Store<TD extends Serializable = Serializable> {
|
|
56
56
|
#private;
|
|
57
57
|
PREFIX: Prefix;
|
|
58
58
|
EXPIRES: Expires;
|
|
59
|
-
promise: Promise<
|
|
60
|
-
|
|
59
|
+
promise: Promise<Adapter> | null;
|
|
60
|
+
adapter: Adapter;
|
|
61
61
|
type: string;
|
|
62
|
-
constructor(
|
|
62
|
+
constructor(adapterInput?: any, options?: Options);
|
|
63
63
|
/**
|
|
64
64
|
* Save the data on an autogenerated key, can add expiration as well:
|
|
65
65
|
*
|
|
@@ -141,7 +141,7 @@ declare class Store<TD extends Serializable = Serializable> {
|
|
|
141
141
|
*/
|
|
142
142
|
delete(key: string): Promise<string>;
|
|
143
143
|
/**
|
|
144
|
-
* An iterator that goes through all of the key:value pairs in the
|
|
144
|
+
* An iterator that goes through all of the key:value pairs in the store
|
|
145
145
|
*
|
|
146
146
|
* ```js
|
|
147
147
|
* for await (const [key, value] of store) {
|
|
@@ -283,6 +283,6 @@ declare class Store<TD extends Serializable = Serializable> {
|
|
|
283
283
|
close(): Promise<void>;
|
|
284
284
|
}
|
|
285
285
|
declare function createStore(): Store<Serializable>;
|
|
286
|
-
declare function createStore<T extends Serializable = Serializable>(
|
|
286
|
+
declare function createStore<T extends Serializable = Serializable>(adapter?: any, options?: Options): Store<T>;
|
|
287
287
|
|
|
288
|
-
export { type
|
|
288
|
+
export { type Adapter, type Serializable, Store, createStore as default };
|