commandkit 1.0.0-dev.20250702020504 → 1.0.0-dev.20250702033548
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/dist/{CommandKit-BZVEqKzs.js → CommandKit-DkPVD3wV.js} +2 -2
- package/dist/{CommandKit-BZVEqKzs.js.map → CommandKit-DkPVD3wV.js.map} +1 -1
- package/dist/CommandKit.js +2 -2
- package/dist/analytics/analytics-engine.js +2 -2
- package/dist/analytics/utils.js +2 -2
- package/dist/app/commands/AppCommandRunner.js +2 -2
- package/dist/app/commands/Context.js +2 -2
- package/dist/app/handlers/AppCommandHandler.js +2 -2
- package/dist/app/handlers/AppEventsHandler.js +2 -2
- package/dist/app/index.js +2 -2
- package/dist/app/register/CommandRegistrar.js +2 -2
- package/dist/{app-process-kobgJPMW.js → app-process-CMtPJoA5.js} +2 -2
- package/dist/{app-process-kobgJPMW.js.map → app-process-CMtPJoA5.js.map} +1 -1
- package/dist/{build-CI-WOwAi.js → build--FBgqYjI.js} +4 -4
- package/dist/{build-CI-WOwAi.js.map → build--FBgqYjI.js.map} +1 -1
- package/dist/cli/app-process.js +2 -2
- package/dist/cli/build.js +4 -4
- package/dist/cli/common.js +1 -1
- package/dist/cli/development.js +5 -5
- package/dist/cli/generators.js +1 -1
- package/dist/cli/information.js +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.js +3 -3
- package/dist/cli/production.d.ts +2 -2
- package/dist/cli/production.js +5 -5
- package/dist/cli/type-checker.js +2 -2
- package/dist/{common-DUta5JO9.js → common-Cx8Kw8DO.js} +5 -3
- package/dist/common-Cx8Kw8DO.js.map +1 -0
- package/dist/components/index.js +2 -2
- package/dist/components/v1/button/Button.js +2 -2
- package/dist/components/v1/button/ButtonKit.js +2 -2
- package/dist/components/v1/modal/Modal.js +2 -2
- package/dist/components/v1/modal/ModalKit.js +2 -2
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +2 -2
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +2 -2
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +2 -2
- package/dist/components/v1/select-menu/SelectMenu.js +2 -2
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +2 -2
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +2 -2
- package/dist/config/config.js +2 -2
- package/dist/config/default.js +2 -2
- package/dist/config/loader.js +2 -2
- package/dist/context/async-context.js +2 -2
- package/dist/context/environment.js +2 -2
- package/dist/{feature-flags-IU-pT6k_.js → feature-flags-DJcINI5E.js} +2 -2
- package/dist/{feature-flags-IU-pT6k_.js.map → feature-flags-DJcINI5E.js.map} +1 -1
- package/dist/flags/feature-flags.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/{init-D3mhxEzo.js → init-DeoDd5cK.js} +3 -3
- package/dist/{init-D3mhxEzo.js.map → init-DeoDd5cK.js.map} +1 -1
- package/dist/{init-BbVFAxJw.d.ts → init-DsaK1AfD.d.ts} +3 -3
- package/dist/kv/kv.d.ts +321 -0
- package/dist/kv/kv.js +428 -0
- package/dist/kv/kv.js.map +1 -0
- package/dist/logger/DefaultLogger.js +2 -2
- package/dist/logger/Logger.js +2 -2
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +2 -2
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +2 -2
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +2 -2
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -2
- package/dist/{type-checker-BhbQMKkv.js → type-checker-BATr8TiL.js} +2 -2
- package/dist/{type-checker-BhbQMKkv.js.map → type-checker-BATr8TiL.js.map} +1 -1
- package/dist/utils/colors.d.ts +2 -2
- package/dist/utils/dev-hooks.js +2 -2
- package/dist/utils/utilities.js +2 -2
- package/dist/{version-RmiVh92c.js → version-PfJROmx1.js} +2 -2
- package/dist/{version-RmiVh92c.js.map → version-PfJROmx1.js.map} +1 -1
- package/dist/version.js +1 -1
- package/kv.cjs +6 -0
- package/kv.d.ts +1 -0
- package/package.json +10 -3
- package/dist/common-DUta5JO9.js.map +0 -1
package/dist/kv/kv.d.ts
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { DatabaseSync } from "node:sqlite";
|
|
2
|
+
|
|
3
|
+
//#region src/kv/kv.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the KV store
|
|
7
|
+
*/
|
|
8
|
+
interface KvOptions {
|
|
9
|
+
/** Enable Write-Ahead Logging for better performance and durability */
|
|
10
|
+
enableWAL?: boolean;
|
|
11
|
+
/** Namespace for the key-value store table */
|
|
12
|
+
namespace?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A key-value store implementation using SQLite
|
|
16
|
+
*
|
|
17
|
+
* This class provides a simple, persistent key-value storage solution
|
|
18
|
+
* with support for namespaces, automatic cleanup, iteration, and expiration.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const kv = new KV('data.db');
|
|
23
|
+
* kv.set('user:123', JSON.stringify({ name: 'John', age: 30 }));
|
|
24
|
+
* const user = JSON.parse(kv.get('user:123') || '{}');
|
|
25
|
+
*
|
|
26
|
+
* // Using namespaces
|
|
27
|
+
* const userKv = kv.namespace('users');
|
|
28
|
+
* userKv.set('123', JSON.stringify({ name: 'John' }));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare class KV implements Disposable, AsyncDisposable {
|
|
32
|
+
private options;
|
|
33
|
+
private db;
|
|
34
|
+
private statements;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new KV store instance
|
|
37
|
+
*
|
|
38
|
+
* @param path - Database file path, buffer, URL, or existing DatabaseSync instance
|
|
39
|
+
* @param options - Configuration options for the KV store
|
|
40
|
+
*/
|
|
41
|
+
constructor(path: string | Buffer | URL | DatabaseSync, options?: KvOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Gets the current timestamp in milliseconds
|
|
44
|
+
*/
|
|
45
|
+
private getCurrentTime;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the database connection is open
|
|
48
|
+
*
|
|
49
|
+
* @returns `true` if the database is open, `false` otherwise
|
|
50
|
+
*/
|
|
51
|
+
isOpen(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the underlying SQLite database instance
|
|
54
|
+
*
|
|
55
|
+
* @returns The DatabaseSync instance
|
|
56
|
+
*/
|
|
57
|
+
getDatabase(): DatabaseSync;
|
|
58
|
+
/**
|
|
59
|
+
* Closes the database connection
|
|
60
|
+
*/
|
|
61
|
+
close(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Disposable implementation - closes the database when disposed
|
|
64
|
+
*/
|
|
65
|
+
[Symbol.dispose](): void;
|
|
66
|
+
/**
|
|
67
|
+
* AsyncDisposable implementation - closes the database when disposed
|
|
68
|
+
*/
|
|
69
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves a value by key
|
|
72
|
+
*
|
|
73
|
+
* @param key - The key to retrieve
|
|
74
|
+
* @returns The value associated with the key, or `undefined` if not found or expired
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const value = kv.get('my-key');
|
|
79
|
+
* if (value) {
|
|
80
|
+
* console.log('Found:', value);
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
get(key: string): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Sets a key-value pair
|
|
87
|
+
*
|
|
88
|
+
* @param key - The key to set
|
|
89
|
+
* @param value - The value to associate with the key
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* kv.set('user:123', JSON.stringify({ name: 'John' }));
|
|
94
|
+
* kv.set('counter', '42');
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
set(key: string, value: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Sets a key-value pair with expiration
|
|
100
|
+
*
|
|
101
|
+
* @param key - The key to set
|
|
102
|
+
* @param value - The value to associate with the key
|
|
103
|
+
* @param ttl - Time to live in milliseconds
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* // Set with 1 hour expiration
|
|
108
|
+
* kv.setex('session:123', 'user_data', 60 * 60 * 1000);
|
|
109
|
+
*
|
|
110
|
+
* // Set with 5 minutes expiration
|
|
111
|
+
* kv.setex('temp:data', 'cached_value', 5 * 60 * 1000);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
setex(key: string, value: string, ttl: number): void;
|
|
115
|
+
/**
|
|
116
|
+
* Sets expiration for an existing key
|
|
117
|
+
*
|
|
118
|
+
* @param key - The key to set expiration for
|
|
119
|
+
* @param ttl - Time to live in milliseconds
|
|
120
|
+
* @returns `true` if the key exists and expiration was set, `false` otherwise
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* kv.set('user:123', 'user_data');
|
|
125
|
+
*
|
|
126
|
+
* // Set 30 minute expiration
|
|
127
|
+
* if (kv.expire('user:123', 30 * 60 * 1000)) {
|
|
128
|
+
* console.log('Expiration set successfully');
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
expire(key: string, ttl: number): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Gets the time to live for a key
|
|
135
|
+
*
|
|
136
|
+
* @param key - The key to check
|
|
137
|
+
* @returns Time to live in milliseconds, or `-1` if the key doesn't exist, or `-2` if the key has no expiration
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const ttl = kv.ttl('user:123');
|
|
142
|
+
* if (ttl > 0) {
|
|
143
|
+
* console.log(`Key expires in ${ttl}ms`);
|
|
144
|
+
* } else if (ttl === -2) {
|
|
145
|
+
* console.log('Key has no expiration');
|
|
146
|
+
* } else {
|
|
147
|
+
* console.log('Key does not exist');
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
ttl(key: string): number;
|
|
152
|
+
/**
|
|
153
|
+
* Deletes a key-value pair
|
|
154
|
+
*
|
|
155
|
+
* @param key - The key to delete
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* kv.delete('user:123');
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
delete(key: string): void;
|
|
163
|
+
/**
|
|
164
|
+
* Checks if a key exists and is not expired
|
|
165
|
+
*
|
|
166
|
+
* @param key - The key to check
|
|
167
|
+
* @returns `true` if the key exists and is not expired, `false` otherwise
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* if (kv.has('user:123')) {
|
|
172
|
+
* console.log('User exists and is not expired');
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
has(key: string): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Gets all keys in the current namespace (excluding expired keys)
|
|
179
|
+
*
|
|
180
|
+
* @returns Array of all non-expired keys
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const keys = kv.keys();
|
|
185
|
+
* console.log('All keys:', keys);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
keys(): string[];
|
|
189
|
+
/**
|
|
190
|
+
* Gets all values in the current namespace (excluding expired keys)
|
|
191
|
+
*
|
|
192
|
+
* @returns Array of all non-expired values
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const values = kv.values();
|
|
197
|
+
* console.log('All values:', values);
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
values(): string[];
|
|
201
|
+
/**
|
|
202
|
+
* Gets the total number of key-value pairs in the current namespace (excluding expired keys)
|
|
203
|
+
*
|
|
204
|
+
* @returns The count of non-expired key-value pairs
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const count = kv.count();
|
|
209
|
+
* console.log(`Total entries: ${count}`);
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
count(): number;
|
|
213
|
+
/**
|
|
214
|
+
* Removes all key-value pairs from the current namespace
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* kv.clear(); // Removes all entries in current namespace
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
clear(): void;
|
|
222
|
+
/**
|
|
223
|
+
* Gets all key-value pairs as an object (excluding expired keys)
|
|
224
|
+
*
|
|
225
|
+
* @returns Object with all non-expired key-value pairs
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const all = kv.all();
|
|
230
|
+
* console.log('All entries:', all);
|
|
231
|
+
* // Output: { 'key1': 'value1', 'key2': 'value2' }
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
all(): Record<string, string>;
|
|
235
|
+
/**
|
|
236
|
+
* Gets all available namespaces (tables) in the database
|
|
237
|
+
*
|
|
238
|
+
* @returns Array of namespace names
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* const namespaces = kv.namespaces();
|
|
243
|
+
* console.log('Available namespaces:', namespaces);
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
namespaces(): string[];
|
|
247
|
+
/**
|
|
248
|
+
* Gets the current namespace name
|
|
249
|
+
*
|
|
250
|
+
* @returns The current namespace string
|
|
251
|
+
*/
|
|
252
|
+
getCurrentNamespace(): string;
|
|
253
|
+
/**
|
|
254
|
+
* Creates a new KV instance with a different namespace
|
|
255
|
+
*
|
|
256
|
+
* @param namespace - The namespace to use for the new instance
|
|
257
|
+
* @returns A new KV instance with the specified namespace
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* const userKv = kv.namespace('users');
|
|
262
|
+
* const configKv = kv.namespace('config');
|
|
263
|
+
*
|
|
264
|
+
* userKv.set('123', 'John Doe');
|
|
265
|
+
* configKv.set('theme', 'dark');
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
namespace(namespace: string): KV;
|
|
269
|
+
/**
|
|
270
|
+
* Iterator implementation for iterating over all non-expired key-value pairs
|
|
271
|
+
*
|
|
272
|
+
* @returns Iterator yielding [key, value] tuples
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* for (const [key, value] of kv) {
|
|
277
|
+
* console.log(`${key}: ${value}`);
|
|
278
|
+
* }
|
|
279
|
+
*
|
|
280
|
+
* // Or using spread operator
|
|
281
|
+
* const entries = [...kv];
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
[Symbol.iterator](): Iterator<[string, string]>;
|
|
285
|
+
/**
|
|
286
|
+
* Executes a function within a transaction
|
|
287
|
+
*
|
|
288
|
+
* @param fn - Function to execute within the transaction (can be async)
|
|
289
|
+
* @returns The result of the function
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* // Synchronous transaction
|
|
294
|
+
* kv.transaction(() => {
|
|
295
|
+
* kv.set('user:123', JSON.stringify({ name: 'John' }));
|
|
296
|
+
* kv.set('user:456', JSON.stringify({ name: 'Jane' }));
|
|
297
|
+
* // If any operation fails, all changes are rolled back
|
|
298
|
+
* });
|
|
299
|
+
*
|
|
300
|
+
* // Async transaction
|
|
301
|
+
* await kv.transaction(async () => {
|
|
302
|
+
* kv.set('user:123', JSON.stringify({ name: 'John' }));
|
|
303
|
+
* await someAsyncOperation();
|
|
304
|
+
* kv.set('user:456', JSON.stringify({ name: 'Jane' }));
|
|
305
|
+
* // If any operation fails, all changes are rolled back
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
transaction<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Opens a new KV instance
|
|
313
|
+
*
|
|
314
|
+
* @param path - Database file path, buffer, URL, or existing DatabaseSync instance
|
|
315
|
+
* @param options - Configuration options for the KV store
|
|
316
|
+
* @returns A new KV instance
|
|
317
|
+
*/
|
|
318
|
+
declare function openKV(path?: string | Buffer | URL | DatabaseSync, options?: KvOptions): KV;
|
|
319
|
+
//#endregion
|
|
320
|
+
export { KV, KvOptions, openKV };
|
|
321
|
+
//# sourceMappingURL=kv.d.ts.map
|