@crawlee/fs-storage-native 0.1.3 → 0.1.5
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 +84 -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,101 @@ 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
|
-
setExpectedRequestProcessingTime(secs: number): Promise<void>;
|
|
161
|
-
persistState(): Promise<void>;
|
|
144
|
+
static open(id?: string | undefined | null, name?: string | undefined | null, alias?: string | undefined | null, storageDir?: string | undefined | null, useTestClock?: boolean | undefined | null): Promise<FileSystemRequestQueueClient>
|
|
145
|
+
/**
|
|
146
|
+
* Advance the client's clock by `millis` milliseconds. Only usable when
|
|
147
|
+
* the client was opened with `useTestClock: true`; throws otherwise.
|
|
148
|
+
*
|
|
149
|
+
* This is the hook that lets JS tests using `vi.useFakeTimers()` exercise
|
|
150
|
+
* lock-expiry behavior — fake JS timers don't reach into native code, so
|
|
151
|
+
* the test must drive the Rust-side clock explicitly via this method.
|
|
152
|
+
*/
|
|
153
|
+
advanceClockForTesting(millis: number): void
|
|
154
|
+
get pathToRq(): string
|
|
155
|
+
get pathToMetadata(): string
|
|
156
|
+
getMetadata(): Promise<RequestQueueMetadata>
|
|
157
|
+
dropStorage(): Promise<void>
|
|
158
|
+
purge(): Promise<void>
|
|
159
|
+
addBatchOfRequests(requests: Record<string, unknown>[], forefront?: boolean | undefined | null): Promise<AddRequestsResponse>
|
|
160
|
+
getRequest(uniqueKey: string): Promise<Record<string, unknown> | null>
|
|
161
|
+
fetchNextRequest(): Promise<Record<string, unknown> | null>
|
|
162
|
+
markRequestAsHandled(request: Record<string, unknown>): Promise<ProcessedRequest | null>
|
|
163
|
+
reclaimRequest(request: Record<string, unknown>, forefront?: boolean | undefined | null): Promise<ProcessedRequest | null>
|
|
164
|
+
isEmpty(): Promise<boolean>
|
|
165
|
+
isFinished(): Promise<boolean>
|
|
166
|
+
setExpectedRequestProcessingTime(secs: number): Promise<void>
|
|
167
|
+
persistState(): Promise<void>
|
|
162
168
|
}
|
|
163
169
|
|
|
164
170
|
export declare class KvsKeyIterator {
|
|
165
|
-
|
|
166
|
-
|
|
171
|
+
/** Fetch the next key metadata entry. Returns null when iteration is exhausted. */
|
|
172
|
+
next(): Promise<KeyValueStoreRecordMetadata | null>
|
|
167
173
|
}
|