@crawlee/fs-storage-native 0.1.3 → 0.1.5-beta.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 +98 -78
- package/index.js +555 -729
- package/lib.d.ts +5 -24
- package/lib.js +11 -15
- package/package.json +15 -7
package/index.d.ts
CHANGED
|
@@ -73,95 +73,115 @@ export interface AddRequestsResponse {
|
|
|
73
73
|
processedRequests: ProcessedRequest[];
|
|
74
74
|
unprocessedRequests: UnprocessedRequest[];
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
// The following `interface` declarations merge with the napi-generated `declare class`es
|
|
78
|
+
// further down in this file, adding the JS-side wrappers defined in `lib.js` directly onto
|
|
79
|
+
// the class signatures.
|
|
80
|
+
|
|
81
|
+
export interface DatasetItemIterator {
|
|
82
|
+
[Symbol.asyncIterator](): AsyncIterator<Record<string, unknown>>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface KvsKeyIterator {
|
|
86
|
+
[Symbol.asyncIterator](): AsyncIterator<KeyValueStoreRecordMetadata>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface FileSystemKeyValueStoreClient {
|
|
90
|
+
/** Get a value as a ReadableStream of bytes. Returns null if the key doesn't exist. */
|
|
91
|
+
getValueStream(key: string): Promise<KeyValueStoreStreamRecord | null>;
|
|
92
|
+
/** Set a value from a ReadableStream. Consumes the entire stream and writes atomically. */
|
|
93
|
+
setValueStream(
|
|
94
|
+
key: string,
|
|
95
|
+
stream: ReadableStream<Uint8Array>,
|
|
96
|
+
contentType?: string | null,
|
|
97
|
+
): Promise<void>;
|
|
98
|
+
}
|
|
76
99
|
export declare class DatasetItemIterator {
|
|
77
|
-
|
|
78
|
-
|
|
100
|
+
/** Fetch the next item. Returns null when iteration is exhausted. */
|
|
101
|
+
next(): Promise<Record<string, unknown> | null>
|
|
79
102
|
}
|
|
80
103
|
|
|
81
104
|
export declare class FileSystemDatasetClient {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
limit?: number | undefined | null,
|
|
97
|
-
desc?: boolean | undefined | null,
|
|
98
|
-
skipEmpty?: boolean | undefined | null,
|
|
99
|
-
): Promise<DatasetItemsListPage>;
|
|
100
|
-
iterateItems(
|
|
101
|
-
offset?: number | undefined | null,
|
|
102
|
-
limit?: number | undefined | null,
|
|
103
|
-
desc?: boolean | undefined | null,
|
|
104
|
-
skipEmpty?: boolean | undefined | null,
|
|
105
|
-
pageSize?: number | undefined | null,
|
|
106
|
-
): Promise<DatasetItemIterator>;
|
|
105
|
+
static open(id?: string | undefined | null, name?: string | undefined | null, alias?: string | undefined | null, storageDir?: string | undefined | null, useTestClock?: boolean | undefined | null): Promise<FileSystemDatasetClient>
|
|
106
|
+
/**
|
|
107
|
+
* Advance the client's clock by `millis` milliseconds. Only usable when
|
|
108
|
+
* the client was opened with `useTestClock: true`; throws otherwise.
|
|
109
|
+
*/
|
|
110
|
+
advanceClockForTesting(millis: number): void
|
|
111
|
+
get pathToDataset(): string
|
|
112
|
+
get pathToMetadata(): string
|
|
113
|
+
getMetadata(): Promise<DatasetMetadata>
|
|
114
|
+
dropStorage(): Promise<void>
|
|
115
|
+
purge(): Promise<void>
|
|
116
|
+
pushData(data: Record<string, unknown> | Record<string, unknown>[]): Promise<void>
|
|
117
|
+
getData(offset?: number | undefined | null, limit?: number | undefined | null, desc?: boolean | undefined | null, skipEmpty?: boolean | undefined | null): Promise<DatasetItemsListPage>
|
|
118
|
+
iterateItems(offset?: number | undefined | null, limit?: number | undefined | null, desc?: boolean | undefined | null, skipEmpty?: boolean | undefined | null, pageSize?: number | undefined | null): Promise<DatasetItemIterator>
|
|
107
119
|
}
|
|
108
120
|
|
|
109
121
|
export declare class FileSystemKeyValueStoreClient {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
pageSize?: number | undefined | null,
|
|
130
|
-
): Promise<KvsKeyIterator>;
|
|
131
|
-
getPublicUrl(key: string): Promise<string>;
|
|
132
|
-
recordExists(key: string): Promise<boolean>;
|
|
122
|
+
static open(id?: string | undefined | null, name?: string | undefined | null, alias?: string | undefined | null, storageDir?: string | undefined | null, useTestClock?: boolean | undefined | null): Promise<FileSystemKeyValueStoreClient>
|
|
123
|
+
/**
|
|
124
|
+
* Advance the client's clock by `millis` milliseconds. Only usable when
|
|
125
|
+
* the client was opened with `useTestClock: true`; throws otherwise.
|
|
126
|
+
*/
|
|
127
|
+
advanceClockForTesting(millis: number): void
|
|
128
|
+
get pathToKvs(): string
|
|
129
|
+
get pathToMetadata(): string
|
|
130
|
+
getMetadata(): Promise<KeyValueStoreMetadata>
|
|
131
|
+
dropStorage(): Promise<void>
|
|
132
|
+
purge(): Promise<void>
|
|
133
|
+
/** Get a record by key. Returns the raw value bytes as a Buffer. */
|
|
134
|
+
getValue(key: string): Promise<KeyValueStoreRecord | null>
|
|
135
|
+
/** Set a value from a Buffer. */
|
|
136
|
+
setValue(key: string, value: Buffer, contentType?: string | undefined | null): Promise<void>
|
|
137
|
+
deleteValue(key: string): Promise<void>
|
|
138
|
+
iterateKeys(exclusiveStartKey?: string | undefined | null, limit?: number | undefined | null, pageSize?: number | undefined | null): Promise<KvsKeyIterator>
|
|
139
|
+
getPublicUrl(key: string): Promise<string>
|
|
140
|
+
recordExists(key: string): Promise<boolean>
|
|
133
141
|
}
|
|
134
142
|
|
|
135
143
|
export declare class FileSystemRequestQueueClient {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Open a request queue.
|
|
146
|
+
*
|
|
147
|
+
* `useTestClock`: see `advanceClockForTesting` below.
|
|
148
|
+
*
|
|
149
|
+
* `assumeSoleOwner` (default `false`): controls how locks on disk are
|
|
150
|
+
* treated at open time. With `false` (the safe default), any future-dated
|
|
151
|
+
* `orderNo` is respected as a potential live peer's lock — crashed peers'
|
|
152
|
+
* locks expire naturally on the wall clock. With `true`, the caller
|
|
153
|
+
* asserts nothing else is using this queue and any in-progress locks are
|
|
154
|
+
* reclaimed immediately, so a request whose previous run died is
|
|
155
|
+
* instantly re-fetchable. Set to `true` only if you know you're the sole
|
|
156
|
+
* consumer; otherwise you risk two peers processing the same request.
|
|
157
|
+
*/
|
|
158
|
+
static open(id?: string | undefined | null, name?: string | undefined | null, alias?: string | undefined | null, storageDir?: string | undefined | null, useTestClock?: boolean | undefined | null, assumeSoleOwner?: boolean | undefined | null): Promise<FileSystemRequestQueueClient>
|
|
159
|
+
/**
|
|
160
|
+
* Advance the client's clock by `millis` milliseconds. Only usable when
|
|
161
|
+
* the client was opened with `useTestClock: true`; throws otherwise.
|
|
162
|
+
*
|
|
163
|
+
* This is the hook that lets JS tests using `vi.useFakeTimers()` exercise
|
|
164
|
+
* lock-expiry behavior — fake JS timers don't reach into native code, so
|
|
165
|
+
* the test must drive the Rust-side clock explicitly via this method.
|
|
166
|
+
*/
|
|
167
|
+
advanceClockForTesting(millis: number): void
|
|
168
|
+
get pathToRq(): string
|
|
169
|
+
get pathToMetadata(): string
|
|
170
|
+
getMetadata(): Promise<RequestQueueMetadata>
|
|
171
|
+
dropStorage(): Promise<void>
|
|
172
|
+
purge(): Promise<void>
|
|
173
|
+
addBatchOfRequests(requests: Record<string, unknown>[], forefront?: boolean | undefined | null): Promise<AddRequestsResponse>
|
|
174
|
+
getRequest(uniqueKey: string): Promise<Record<string, unknown> | null>
|
|
175
|
+
fetchNextRequest(): Promise<Record<string, unknown> | null>
|
|
176
|
+
markRequestAsHandled(request: Record<string, unknown>): Promise<ProcessedRequest | null>
|
|
177
|
+
reclaimRequest(request: Record<string, unknown>, forefront?: boolean | undefined | null): Promise<ProcessedRequest | null>
|
|
178
|
+
isEmpty(): Promise<boolean>
|
|
179
|
+
isFinished(): Promise<boolean>
|
|
180
|
+
setExpectedRequestProcessingTime(secs: number): Promise<void>
|
|
181
|
+
persistState(): Promise<void>
|
|
162
182
|
}
|
|
163
183
|
|
|
164
184
|
export declare class KvsKeyIterator {
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
/** Fetch the next key metadata entry. Returns null when iteration is exhausted. */
|
|
186
|
+
next(): Promise<KeyValueStoreRecordMetadata | null>
|
|
167
187
|
}
|