@kvs/types 2.1.1 → 2.1.4
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/lib/index.d.ts +11 -11
- package/package.json +7 -7
package/lib/index.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type StorageSchema = {
|
|
2
2
|
[index: string]: any;
|
|
3
3
|
};
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
type HasIndexSignature<T> = T extends Record<infer K, any> ? K : never;
|
|
5
|
+
export type RemoveIndex<T> = {
|
|
6
6
|
[K in keyof T as symbol extends K ? never : string extends K ? never : number extends K ? never : K]: T[K];
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type KnownKeys<T> = keyof RemoveIndex<T>;
|
|
9
9
|
/**
|
|
10
10
|
* Extract known object store names from the DB schema type.
|
|
11
11
|
*
|
|
12
12
|
* @template DBTypes DB schema type, or unknown if the DB isn't typed.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type StoreNames<DBTypes extends StorageSchema | unknown> = DBTypes extends StorageSchema ? string extends HasIndexSignature<DBTypes> ? string : KnownKeys<DBTypes> : string;
|
|
15
15
|
/**
|
|
16
16
|
* Extract database value types from the DB schema type.
|
|
17
17
|
*
|
|
18
18
|
* @template DBTypes DB schema type, or unknown if the DB isn't typed.
|
|
19
19
|
* @template StoreName Names of the object stores to get the types of.
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
22
|
-
export
|
|
21
|
+
export type StoreValue<DBTypes extends StorageSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends StorageSchema ? DBTypes[StoreName] : any;
|
|
22
|
+
export type KVS<Schema extends StorageSchema> = {
|
|
23
23
|
/**
|
|
24
24
|
* Returns the value associated to the key.
|
|
25
25
|
* If the key does not exist, returns `undefined`.
|
|
@@ -51,7 +51,7 @@ export declare type KVS<Schema extends StorageSchema> = {
|
|
|
51
51
|
dropInstance(): Promise<void>;
|
|
52
52
|
close(): Promise<void>;
|
|
53
53
|
} & AsyncIterable<[StoreNames<Schema>, StoreValue<Schema, StoreNames<Schema>>]>;
|
|
54
|
-
export
|
|
54
|
+
export type KVSOptions<Schema extends StorageSchema> = {
|
|
55
55
|
name: string;
|
|
56
56
|
version: number;
|
|
57
57
|
upgrade?({ kvs, oldVersion, newVersion }: {
|
|
@@ -62,11 +62,11 @@ export declare type KVSOptions<Schema extends StorageSchema> = {
|
|
|
62
62
|
} & {
|
|
63
63
|
[index: string]: any;
|
|
64
64
|
};
|
|
65
|
-
export
|
|
65
|
+
export type KVSConstructor<Schema extends StorageSchema> = (options: KVSOptions<Schema>) => Promise<KVS<Schema>>;
|
|
66
66
|
/**
|
|
67
67
|
* Sync Version
|
|
68
68
|
*/
|
|
69
|
-
export
|
|
69
|
+
export type KVSSync<Schema extends StorageSchema> = {
|
|
70
70
|
/**
|
|
71
71
|
* Returns the value associated to the key.
|
|
72
72
|
* If the key does not exist, returns `undefined`.
|
|
@@ -98,7 +98,7 @@ export declare type KVSSync<Schema extends StorageSchema> = {
|
|
|
98
98
|
dropInstance(): void;
|
|
99
99
|
close(): void;
|
|
100
100
|
} & Iterable<[StoreNames<Schema>, StoreValue<Schema, StoreNames<Schema>>]>;
|
|
101
|
-
export
|
|
101
|
+
export type KVSSyncOptions<Schema extends StorageSchema> = {
|
|
102
102
|
name: string;
|
|
103
103
|
version: number;
|
|
104
104
|
upgrade?({ kvs, oldVersion, newVersion }: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvs/types",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "A type definition for KVS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"types",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"trailingComma": "none"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^
|
|
49
|
-
"prettier": "^
|
|
50
|
-
"rimraf": "^
|
|
51
|
-
"tsd": "^0.
|
|
52
|
-
"typescript": "^
|
|
48
|
+
"@types/node": "^20.4.2",
|
|
49
|
+
"prettier": "^3.0.0",
|
|
50
|
+
"rimraf": "^5.0.1",
|
|
51
|
+
"tsd": "^0.28.1",
|
|
52
|
+
"typescript": "^5.1.6"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "d7a5ac9d3c859cceaa75711916bc6bb4e6cd61be"
|
|
58
58
|
}
|