@outfitter/state 0.2.2 → 0.2.3
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/index.d.ts +32 -32
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -23,18 +23,18 @@ import { NotFoundError, Result, StorageError, ValidationError } from "@outfitter
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
interface Cursor {
|
|
26
|
+
/** Unix timestamp (ms) when this cursor was created */
|
|
27
|
+
readonly createdAt: number;
|
|
28
|
+
/** Unix timestamp (ms) when this cursor expires (computed from createdAt + ttl) */
|
|
29
|
+
readonly expiresAt?: number;
|
|
26
30
|
/** Unique identifier for this cursor (UUID format) */
|
|
27
31
|
readonly id: string;
|
|
28
|
-
/** Current position/offset in the result set (zero-based) */
|
|
29
|
-
readonly position: number;
|
|
30
32
|
/** Optional user-defined metadata associated with this cursor */
|
|
31
33
|
readonly metadata?: Record<string, unknown>;
|
|
34
|
+
/** Current position/offset in the result set (zero-based) */
|
|
35
|
+
readonly position: number;
|
|
32
36
|
/** Time-to-live in milliseconds (optional, omitted if cursor never expires) */
|
|
33
37
|
readonly ttl?: number;
|
|
34
|
-
/** Unix timestamp (ms) when this cursor expires (computed from createdAt + ttl) */
|
|
35
|
-
readonly expiresAt?: number;
|
|
36
|
-
/** Unix timestamp (ms) when this cursor was created */
|
|
37
|
-
readonly createdAt: number;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Options for creating a pagination cursor.
|
|
@@ -56,10 +56,10 @@ interface Cursor {
|
|
|
56
56
|
interface CreateCursorOptions {
|
|
57
57
|
/** Custom cursor ID (UUID generated if not provided) */
|
|
58
58
|
id?: string;
|
|
59
|
-
/** Starting position in the result set (must be non-negative) */
|
|
60
|
-
position: number;
|
|
61
59
|
/** User-defined metadata to associate with the cursor */
|
|
62
60
|
metadata?: Record<string, unknown>;
|
|
61
|
+
/** Starting position in the result set (must be non-negative) */
|
|
62
|
+
position: number;
|
|
63
63
|
/** Time-to-live in milliseconds (cursor never expires if omitted) */
|
|
64
64
|
ttl?: number;
|
|
65
65
|
}
|
|
@@ -92,10 +92,14 @@ interface CreateCursorOptions {
|
|
|
92
92
|
*/
|
|
93
93
|
interface CursorStore {
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @param cursor - The cursor to store (replaces existing if same ID)
|
|
95
|
+
* Remove all cursors from the store.
|
|
97
96
|
*/
|
|
98
|
-
|
|
97
|
+
clear(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Delete a cursor by ID.
|
|
100
|
+
* @param id - The cursor ID to delete (no-op if not found)
|
|
101
|
+
*/
|
|
102
|
+
delete(id: string): void;
|
|
99
103
|
/**
|
|
100
104
|
* Retrieve a cursor by ID.
|
|
101
105
|
* @param id - The cursor ID to look up
|
|
@@ -109,15 +113,6 @@ interface CursorStore {
|
|
|
109
113
|
*/
|
|
110
114
|
has(id: string): boolean;
|
|
111
115
|
/**
|
|
112
|
-
* Delete a cursor by ID.
|
|
113
|
-
* @param id - The cursor ID to delete (no-op if not found)
|
|
114
|
-
*/
|
|
115
|
-
delete(id: string): void;
|
|
116
|
-
/**
|
|
117
|
-
* Remove all cursors from the store.
|
|
118
|
-
*/
|
|
119
|
-
clear(): void;
|
|
120
|
-
/**
|
|
121
116
|
* List all cursor IDs in the store (including expired).
|
|
122
117
|
* @returns Array of cursor IDs
|
|
123
118
|
*/
|
|
@@ -127,6 +122,11 @@ interface CursorStore {
|
|
|
127
122
|
* @returns Number of cursors that were pruned
|
|
128
123
|
*/
|
|
129
124
|
prune(): number;
|
|
125
|
+
/**
|
|
126
|
+
* Save or update a cursor in the store.
|
|
127
|
+
* @param cursor - The cursor to store (replaces existing if same ID)
|
|
128
|
+
*/
|
|
129
|
+
set(cursor: Cursor): void;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* A cursor store with namespace isolation.
|
|
@@ -198,17 +198,17 @@ interface PersistentStoreOptions {
|
|
|
198
198
|
* ```
|
|
199
199
|
*/
|
|
200
200
|
interface PersistentStore extends CursorStore {
|
|
201
|
+
/**
|
|
202
|
+
* Dispose of the store and cleanup resources.
|
|
203
|
+
* Call this when the store is no longer needed.
|
|
204
|
+
*/
|
|
205
|
+
dispose(): void;
|
|
201
206
|
/**
|
|
202
207
|
* Flush all in-memory cursors to disk.
|
|
203
208
|
* Uses atomic write (temp file + rename) to prevent corruption.
|
|
204
209
|
* @returns Promise that resolves when write is complete
|
|
205
210
|
*/
|
|
206
211
|
flush(): Promise<void>;
|
|
207
|
-
/**
|
|
208
|
-
* Dispose of the store and cleanup resources.
|
|
209
|
-
* Call this when the store is no longer needed.
|
|
210
|
-
*/
|
|
211
|
-
dispose(): void;
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* Create a new pagination cursor.
|
|
@@ -503,6 +503,11 @@ declare const DEFAULT_PAGE_LIMIT = 25;
|
|
|
503
503
|
* ```
|
|
504
504
|
*/
|
|
505
505
|
interface PaginationStore {
|
|
506
|
+
/**
|
|
507
|
+
* Delete a cursor by ID.
|
|
508
|
+
* @param id - The cursor ID to delete
|
|
509
|
+
*/
|
|
510
|
+
delete(id: string): void;
|
|
506
511
|
/**
|
|
507
512
|
* Get a cursor by ID.
|
|
508
513
|
* @param id - The cursor ID to look up
|
|
@@ -515,11 +520,6 @@ interface PaginationStore {
|
|
|
515
520
|
* @param cursor - The cursor to store
|
|
516
521
|
*/
|
|
517
522
|
set(id: string, cursor: Cursor): void;
|
|
518
|
-
/**
|
|
519
|
-
* Delete a cursor by ID.
|
|
520
|
-
* @param id - The cursor ID to delete
|
|
521
|
-
*/
|
|
522
|
-
delete(id: string): void;
|
|
523
523
|
}
|
|
524
524
|
/**
|
|
525
525
|
* Get the default pagination store (module-level singleton).
|
|
@@ -568,10 +568,10 @@ declare function createPaginationStore(): PaginationStore;
|
|
|
568
568
|
* @typeParam T - The type of items being paginated
|
|
569
569
|
*/
|
|
570
570
|
interface PaginationResult<T> {
|
|
571
|
-
/** The items in the current page */
|
|
572
|
-
page: T[];
|
|
573
571
|
/** The cursor for the next page, or null if this is the last page */
|
|
574
572
|
nextCursor: Cursor | null;
|
|
573
|
+
/** The items in the current page */
|
|
574
|
+
page: T[];
|
|
575
575
|
}
|
|
576
576
|
/**
|
|
577
577
|
* Extract a page of items based on cursor position.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outfitter/state",
|
|
3
3
|
"description": "Pagination cursor persistence and state management for Outfitter",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
"lint:fix": "biome lint --write ./src",
|
|
25
25
|
"test": "bun test",
|
|
26
26
|
"typecheck": "tsc --noEmit",
|
|
27
|
-
"clean": "rm -rf dist"
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"prepublishOnly": "bun ../../scripts/check-publish-manifest.ts"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@outfitter/contracts": "0.4.
|
|
31
|
-
"@outfitter/types": "0.2.
|
|
31
|
+
"@outfitter/contracts": "0.4.1",
|
|
32
|
+
"@outfitter/types": "0.2.3"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/bun": "latest",
|