@fedify/mysql 2.5.0-dev.2811 → 2.5.0-dev.2822
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 +105 -0
- package/dist/kv.cjs +286 -118
- package/dist/kv.d.cts +55 -11
- package/dist/kv.d.ts +55 -11
- package/dist/kv.js +286 -118
- package/package.json +3 -3
package/dist/kv.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { KvKey,
|
|
2
|
+
import { AtomicKvStore, KvKey, KvStoreCasEntry, KvStoreListEntry, KvStoreSetEntry, KvStoreSetOptions } from "@fedify/fedify";
|
|
3
3
|
|
|
4
4
|
//#region src/kv.d.ts
|
|
5
5
|
interface MysqlQueryable {
|
|
@@ -10,6 +10,7 @@ interface MysqlPoolConnection extends MysqlQueryable {
|
|
|
10
10
|
commit(): Promise<void>;
|
|
11
11
|
rollback(): Promise<void>;
|
|
12
12
|
release(): void;
|
|
13
|
+
destroy(): void;
|
|
13
14
|
}
|
|
14
15
|
interface MysqlPool extends MysqlQueryable {
|
|
15
16
|
getConnection(): Promise<MysqlPoolConnection>;
|
|
@@ -28,7 +29,8 @@ interface MysqlKvStoreOptions {
|
|
|
28
29
|
*/
|
|
29
30
|
readonly tableName?: string;
|
|
30
31
|
/**
|
|
31
|
-
* Whether the table has been
|
|
32
|
+
* Whether the table has been created. `false` by default. With `true`,
|
|
33
|
+
* initialization skips DDL but still validates the InnoDB schema.
|
|
32
34
|
* @default `false`
|
|
33
35
|
* @since 2.1.0
|
|
34
36
|
*/
|
|
@@ -43,7 +45,27 @@ interface MysqlKvStoreOptions {
|
|
|
43
45
|
readonly expireCleanupRate?: number;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
48
|
+
* An atomic key-value store backed by an InnoDB table on MySQL or MariaDB.
|
|
49
|
+
*
|
|
50
|
+
* All keys in one primary database/table share an atomic scope. Batches have
|
|
51
|
+
* at most 1,000 entries and serialized keys at most 768 Unicode code points;
|
|
52
|
+
* server packet and resource limits also apply. Values use JSON serialization
|
|
53
|
+
* and decoded structural equality (`isEqual`); object member order is ignored.
|
|
54
|
+
* Do not mutate expected values while a CAS is pending.
|
|
55
|
+
*
|
|
56
|
+
* TTLs are truncated to safe integer microseconds (approximately ±285 years),
|
|
57
|
+
* evaluated using one server cutoff per attempt. Calendar units use the local
|
|
58
|
+
* current date for conversion. Omitted TTL clears the previous expiry.
|
|
59
|
+
*
|
|
60
|
+
* Use a normal mysql2 pool with autocommit enabled, object rows, default type
|
|
61
|
+
* casting, and the same fixed-offset or UTC session time zone on every client.
|
|
62
|
+
* Caller-owned transactions, replica routing, concurrent schema changes,
|
|
63
|
+
* `NO_BACKSLASH_ESCAPES`, and disabled InnoDB gap locking are unsupported.
|
|
64
|
+
* Initialization checks the schema even with `initialized: true`.
|
|
65
|
+
*
|
|
66
|
+
* Deadlocks and MariaDB snapshot conflicts retry up to five total attempts.
|
|
67
|
+
* Other failures reject; a failed commit response can leave its outcome
|
|
68
|
+
* unknown. Atomicity does not promise crash durability or external effects.
|
|
47
69
|
*
|
|
48
70
|
* @example
|
|
49
71
|
* ```ts
|
|
@@ -61,7 +83,7 @@ interface MysqlKvStoreOptions {
|
|
|
61
83
|
*
|
|
62
84
|
* @since 2.1.0
|
|
63
85
|
*/
|
|
64
|
-
declare class MysqlKvStore implements
|
|
86
|
+
declare class MysqlKvStore implements AtomicKvStore {
|
|
65
87
|
#private;
|
|
66
88
|
/**
|
|
67
89
|
* Creates a new MySQL key-value store.
|
|
@@ -71,33 +93,55 @@ declare class MysqlKvStore implements KvStore {
|
|
|
71
93
|
*/
|
|
72
94
|
constructor(pool: MysqlPool, options?: MysqlKvStoreOptions);
|
|
73
95
|
/**
|
|
74
|
-
* {@inheritDoc
|
|
96
|
+
* {@inheritDoc AtomicKvStore.get}
|
|
75
97
|
* @since 2.1.0
|
|
76
98
|
*/
|
|
77
99
|
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
|
78
100
|
/**
|
|
79
|
-
* {@inheritDoc
|
|
101
|
+
* {@inheritDoc AtomicKvStore.set}
|
|
80
102
|
* @since 2.1.0
|
|
81
103
|
*/
|
|
82
|
-
set(key: KvKey, value: unknown, options?: KvStoreSetOptions
|
|
104
|
+
set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
|
|
83
105
|
/**
|
|
84
|
-
* {@inheritDoc
|
|
106
|
+
* {@inheritDoc AtomicKvStore.delete}
|
|
85
107
|
* @since 2.1.0
|
|
86
108
|
*/
|
|
87
109
|
delete(key: KvKey): Promise<void>;
|
|
88
110
|
/**
|
|
89
|
-
* {@inheritDoc
|
|
111
|
+
* {@inheritDoc AtomicKvStore.cas}
|
|
90
112
|
* @since 2.1.0
|
|
91
113
|
*/
|
|
92
114
|
cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
|
|
93
115
|
/**
|
|
94
|
-
* {@inheritDoc
|
|
116
|
+
* {@inheritDoc AtomicKvStore.getMany}
|
|
117
|
+
* @since 2.5.0
|
|
118
|
+
*/
|
|
119
|
+
getMany<T = unknown>(keys: readonly KvKey[]): Promise<(T | undefined)[]>;
|
|
120
|
+
/**
|
|
121
|
+
* {@inheritDoc AtomicKvStore.setMany}
|
|
122
|
+
* @since 2.5.0
|
|
123
|
+
*/
|
|
124
|
+
setMany(entries: readonly KvStoreSetEntry[]): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* {@inheritDoc AtomicKvStore.deleteMany}
|
|
127
|
+
* @since 2.5.0
|
|
128
|
+
*/
|
|
129
|
+
deleteMany(keys: readonly KvKey[]): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* {@inheritDoc AtomicKvStore.casMany}
|
|
132
|
+
* @since 2.5.0
|
|
133
|
+
*/
|
|
134
|
+
casMany(entries: readonly KvStoreCasEntry[]): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* {@inheritDoc AtomicKvStore.list}
|
|
95
137
|
* @since 2.1.0
|
|
96
138
|
*/
|
|
97
139
|
list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
|
|
98
140
|
/**
|
|
99
141
|
* Creates the table used by the key-value store if it does not already exist.
|
|
100
|
-
*
|
|
142
|
+
* Validates the existing schema, including when `initialized: true` was
|
|
143
|
+
* supplied. Successful initialization is cached until {@link MysqlKvStore.drop}.
|
|
144
|
+
* Initialization and dropping must not overlap store operations.
|
|
101
145
|
*
|
|
102
146
|
* @since 2.1.0
|
|
103
147
|
*/
|
package/dist/kv.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { KvKey,
|
|
2
|
+
import { AtomicKvStore, KvKey, KvStoreCasEntry, KvStoreListEntry, KvStoreSetEntry, KvStoreSetOptions } from "@fedify/fedify";
|
|
3
3
|
|
|
4
4
|
//#region src/kv.d.ts
|
|
5
5
|
interface MysqlQueryable {
|
|
@@ -10,6 +10,7 @@ interface MysqlPoolConnection extends MysqlQueryable {
|
|
|
10
10
|
commit(): Promise<void>;
|
|
11
11
|
rollback(): Promise<void>;
|
|
12
12
|
release(): void;
|
|
13
|
+
destroy(): void;
|
|
13
14
|
}
|
|
14
15
|
interface MysqlPool extends MysqlQueryable {
|
|
15
16
|
getConnection(): Promise<MysqlPoolConnection>;
|
|
@@ -28,7 +29,8 @@ interface MysqlKvStoreOptions {
|
|
|
28
29
|
*/
|
|
29
30
|
readonly tableName?: string;
|
|
30
31
|
/**
|
|
31
|
-
* Whether the table has been
|
|
32
|
+
* Whether the table has been created. `false` by default. With `true`,
|
|
33
|
+
* initialization skips DDL but still validates the InnoDB schema.
|
|
32
34
|
* @default `false`
|
|
33
35
|
* @since 2.1.0
|
|
34
36
|
*/
|
|
@@ -43,7 +45,27 @@ interface MysqlKvStoreOptions {
|
|
|
43
45
|
readonly expireCleanupRate?: number;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
48
|
+
* An atomic key-value store backed by an InnoDB table on MySQL or MariaDB.
|
|
49
|
+
*
|
|
50
|
+
* All keys in one primary database/table share an atomic scope. Batches have
|
|
51
|
+
* at most 1,000 entries and serialized keys at most 768 Unicode code points;
|
|
52
|
+
* server packet and resource limits also apply. Values use JSON serialization
|
|
53
|
+
* and decoded structural equality (`isEqual`); object member order is ignored.
|
|
54
|
+
* Do not mutate expected values while a CAS is pending.
|
|
55
|
+
*
|
|
56
|
+
* TTLs are truncated to safe integer microseconds (approximately ±285 years),
|
|
57
|
+
* evaluated using one server cutoff per attempt. Calendar units use the local
|
|
58
|
+
* current date for conversion. Omitted TTL clears the previous expiry.
|
|
59
|
+
*
|
|
60
|
+
* Use a normal mysql2 pool with autocommit enabled, object rows, default type
|
|
61
|
+
* casting, and the same fixed-offset or UTC session time zone on every client.
|
|
62
|
+
* Caller-owned transactions, replica routing, concurrent schema changes,
|
|
63
|
+
* `NO_BACKSLASH_ESCAPES`, and disabled InnoDB gap locking are unsupported.
|
|
64
|
+
* Initialization checks the schema even with `initialized: true`.
|
|
65
|
+
*
|
|
66
|
+
* Deadlocks and MariaDB snapshot conflicts retry up to five total attempts.
|
|
67
|
+
* Other failures reject; a failed commit response can leave its outcome
|
|
68
|
+
* unknown. Atomicity does not promise crash durability or external effects.
|
|
47
69
|
*
|
|
48
70
|
* @example
|
|
49
71
|
* ```ts
|
|
@@ -61,7 +83,7 @@ interface MysqlKvStoreOptions {
|
|
|
61
83
|
*
|
|
62
84
|
* @since 2.1.0
|
|
63
85
|
*/
|
|
64
|
-
declare class MysqlKvStore implements
|
|
86
|
+
declare class MysqlKvStore implements AtomicKvStore {
|
|
65
87
|
#private;
|
|
66
88
|
/**
|
|
67
89
|
* Creates a new MySQL key-value store.
|
|
@@ -71,33 +93,55 @@ declare class MysqlKvStore implements KvStore {
|
|
|
71
93
|
*/
|
|
72
94
|
constructor(pool: MysqlPool, options?: MysqlKvStoreOptions);
|
|
73
95
|
/**
|
|
74
|
-
* {@inheritDoc
|
|
96
|
+
* {@inheritDoc AtomicKvStore.get}
|
|
75
97
|
* @since 2.1.0
|
|
76
98
|
*/
|
|
77
99
|
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
|
78
100
|
/**
|
|
79
|
-
* {@inheritDoc
|
|
101
|
+
* {@inheritDoc AtomicKvStore.set}
|
|
80
102
|
* @since 2.1.0
|
|
81
103
|
*/
|
|
82
|
-
set(key: KvKey, value: unknown, options?: KvStoreSetOptions
|
|
104
|
+
set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
|
|
83
105
|
/**
|
|
84
|
-
* {@inheritDoc
|
|
106
|
+
* {@inheritDoc AtomicKvStore.delete}
|
|
85
107
|
* @since 2.1.0
|
|
86
108
|
*/
|
|
87
109
|
delete(key: KvKey): Promise<void>;
|
|
88
110
|
/**
|
|
89
|
-
* {@inheritDoc
|
|
111
|
+
* {@inheritDoc AtomicKvStore.cas}
|
|
90
112
|
* @since 2.1.0
|
|
91
113
|
*/
|
|
92
114
|
cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
|
|
93
115
|
/**
|
|
94
|
-
* {@inheritDoc
|
|
116
|
+
* {@inheritDoc AtomicKvStore.getMany}
|
|
117
|
+
* @since 2.5.0
|
|
118
|
+
*/
|
|
119
|
+
getMany<T = unknown>(keys: readonly KvKey[]): Promise<(T | undefined)[]>;
|
|
120
|
+
/**
|
|
121
|
+
* {@inheritDoc AtomicKvStore.setMany}
|
|
122
|
+
* @since 2.5.0
|
|
123
|
+
*/
|
|
124
|
+
setMany(entries: readonly KvStoreSetEntry[]): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* {@inheritDoc AtomicKvStore.deleteMany}
|
|
127
|
+
* @since 2.5.0
|
|
128
|
+
*/
|
|
129
|
+
deleteMany(keys: readonly KvKey[]): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* {@inheritDoc AtomicKvStore.casMany}
|
|
132
|
+
* @since 2.5.0
|
|
133
|
+
*/
|
|
134
|
+
casMany(entries: readonly KvStoreCasEntry[]): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* {@inheritDoc AtomicKvStore.list}
|
|
95
137
|
* @since 2.1.0
|
|
96
138
|
*/
|
|
97
139
|
list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
|
|
98
140
|
/**
|
|
99
141
|
* Creates the table used by the key-value store if it does not already exist.
|
|
100
|
-
*
|
|
142
|
+
* Validates the existing schema, including when `initialized: true` was
|
|
143
|
+
* supplied. Successful initialization is cached until {@link MysqlKvStore.drop}.
|
|
144
|
+
* Initialization and dropping must not overlap store operations.
|
|
101
145
|
*
|
|
102
146
|
* @since 2.1.0
|
|
103
147
|
*/
|