@crawlee/types 4.0.0-beta.8 → 4.0.0-beta.81

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/storages.d.ts CHANGED
@@ -11,16 +11,13 @@ export interface QueueOperationInfo {
11
11
  /** The ID of the added request */
12
12
  requestId: string;
13
13
  }
14
- export interface DatasetCollectionClientOptions {
15
- storageDir: string;
16
- }
17
- export interface DatasetCollectionData {
18
- id: string;
19
- name?: string;
20
- createdAt: Date;
21
- modifiedAt: Date;
22
- accessedAt: Date;
23
- }
14
+ /**
15
+ * A single page of items returned by {@link DatasetBackend.getData}.
16
+ *
17
+ * Datasets paginate by offset, so a page is self-describing via `total` / `offset` / `limit`: a
18
+ * frontend assembling all pages knows it has reached the end once `offset + items.length >= total`.
19
+ * The cursor-based counterpart for key-value stores is {@link KeyValueStoreListKeysResult}.
20
+ */
24
21
  export interface PaginatedList<Data> {
25
22
  /** Total count of entries in the dataset. */
26
23
  total: number;
@@ -35,20 +32,7 @@ export interface PaginatedList<Data> {
35
32
  /** Dataset entries based on chosen format parameter. */
36
33
  items: Data[];
37
34
  }
38
- export interface Dataset extends DatasetCollectionData {
39
- itemCount: number;
40
- }
41
- /**
42
- * Dataset collection client.
43
- */
44
- export interface DatasetCollectionClient {
45
- list(): Promise<PaginatedList<Dataset>>;
46
- getOrCreate(name?: string): Promise<DatasetCollectionData>;
47
- }
48
- export interface DatasetClientUpdateOptions {
49
- name?: string;
50
- }
51
- export interface DatasetClientListOptions {
35
+ export interface DatasetBackendListOptions {
52
36
  desc?: boolean;
53
37
  limit?: number;
54
38
  offset?: number;
@@ -60,162 +44,158 @@ export interface DatasetInfo {
60
44
  modifiedAt: Date;
61
45
  accessedAt: Date;
62
46
  itemCount: number;
63
- actId?: string;
64
- actRunId?: string;
65
- }
66
- export interface DatasetStats {
67
- readCount?: number;
68
- writeCount?: number;
69
- deleteCount?: number;
70
- storageBytes?: number;
71
- }
72
- export interface DatasetClient<Data extends Dictionary = Dictionary> {
73
- get(): Promise<DatasetInfo | undefined>;
74
- update(newFields: DatasetClientUpdateOptions): Promise<Partial<DatasetInfo>>;
75
- delete(): Promise<void>;
76
- downloadItems(...args: unknown[]): Promise<Buffer>;
77
- listItems(options?: DatasetClientListOptions): Promise<PaginatedList<Data>>;
78
- pushItems(items: Data | Data[] | string | string[]): Promise<void>;
79
47
  }
80
- export interface KeyValueStoreStats {
81
- readCount?: number;
82
- writeCount?: number;
83
- deleteCount?: number;
84
- listCount?: number;
85
- storageBytes?: number;
48
+ export interface DatasetBackend<Data extends Dictionary = Dictionary> {
49
+ /**
50
+ * Returns metadata about the dataset (id, name, timestamps, item count, etc.).
51
+ *
52
+ * Implementations should throw if the underlying storage no longer exists
53
+ * (e.g. it was deleted externally). This method should never return stale data
54
+ * for a storage that has been removed.
55
+ */
56
+ getMetadata(): Promise<DatasetInfo>;
57
+ /** Remove the dataset and all its data. */
58
+ drop(): Promise<void>;
59
+ /** Remove all items from the dataset but keep the dataset itself. */
60
+ purge(): Promise<void>;
61
+ /** Add items to the dataset. */
62
+ pushData(items: Data[]): Promise<void>;
63
+ /** Fetch a page of items from the dataset. */
64
+ getData(options?: DatasetBackendListOptions): Promise<PaginatedList<Data>>;
86
65
  }
87
66
  export interface KeyValueStoreInfo {
88
67
  id: string;
89
68
  name?: string;
90
- userId?: string;
91
69
  createdAt: Date;
92
70
  modifiedAt: Date;
93
71
  accessedAt: Date;
94
- actId?: string;
95
- actRunId?: string;
96
- stats?: KeyValueStoreStats;
97
72
  }
98
73
  /**
99
- * Key-value store collection client.
74
+ * The value a serialized record carries on the way *into* a storage backend (`setValue`).
75
+ *
76
+ * The `KeyValueStore` frontend has already serialized by this point, so it is a pre-serialized
77
+ * string, raw bytes (`Buffer` / `ArrayBuffer` / typed array), or a stream the client drains.
78
+ */
79
+ export type KeyValueStoreRecordInputValue = Buffer | ArrayBuffer | ArrayBufferView | string | NodeJS.ReadableStream | ReadableStream;
80
+ /**
81
+ * A record as returned by a storage backend (`getValue`).
82
+ *
83
+ * Storage backends are byte transports: they persist and return bytes verbatim and never serialize
84
+ * or parse. Interpretation is the `KeyValueStore` frontend's job (it parses according to the content
85
+ * type via `parseValue`). The value is therefore always raw bytes — a `Buffer` (Node) or an
86
+ * `ArrayBuffer` (browser backends).
100
87
  */
101
- export interface KeyValueStoreCollectionClient {
102
- list(): Promise<PaginatedList<KeyValueStoreInfo>>;
103
- getOrCreate(name?: string): Promise<KeyValueStoreInfo>;
104
- }
105
88
  export interface KeyValueStoreRecord {
106
89
  key: string;
107
- value: any;
90
+ value: Buffer | ArrayBuffer;
108
91
  contentType?: string;
109
92
  }
110
- export interface KeyValueStoreRecordOptions {
111
- timeoutSecs?: number;
112
- doNotRetryTimeouts?: boolean;
113
- }
114
- export interface KeyValueStoreClientUpdateOptions {
115
- name?: string;
93
+ /**
94
+ * A record passed to a storage backend for writing (`setValue`). Like {@link KeyValueStoreRecord} but
95
+ * with the lenient, pre-serialized {@link KeyValueStoreRecordInputValue} for the value.
96
+ */
97
+ export interface KeyValueStoreInputRecord {
98
+ key: string;
99
+ value: KeyValueStoreRecordInputValue;
100
+ contentType?: string;
116
101
  }
117
- export interface KeyValueStoreClientListOptions {
118
- limit?: number;
102
+ export interface KeyValueStoreListKeysOptions {
103
+ /** If set, only keys that start with this prefix are returned. */
104
+ prefix?: string;
105
+ /** All keys up to this one are skipped from the result. */
119
106
  exclusiveStartKey?: string;
107
+ /** Maximum number of keys to return. */
108
+ limit?: number;
120
109
  }
121
110
  export interface KeyValueStoreItemData {
122
111
  key: string;
123
112
  size: number;
113
+ /** The MIME content type the record was stored with, if known. */
114
+ contentType: string;
124
115
  }
125
- export interface KeyValueStoreClientListData {
116
+ /**
117
+ * A single page of keys returned by {@link KeyValueStoreBackend.listKeys}.
118
+ *
119
+ * This mirrors {@link PaginatedList} (the shape returned by {@link DatasetBackend.getData}) so that
120
+ * both listing operations on the storage backend layer return a self-describing page. The difference
121
+ * is the pagination model: datasets are offset-based (`total` / `offset`), whereas key-value stores
122
+ * are cursor-based. A frontend assembling all pages should therefore not guess "is this the last
123
+ * page?" from `items.length < limit` — it should rely on {@link isTruncated} and resume from
124
+ * {@link nextExclusiveStartKey}.
125
+ */
126
+ export interface KeyValueStoreListKeysResult {
127
+ /** Keys returned on this page. */
128
+ items: KeyValueStoreItemData[];
129
+ /** Number of keys returned on this page (`items.length`). */
126
130
  count: number;
131
+ /** Maximum number of keys requested for this page. */
127
132
  limit: number;
133
+ /** The `exclusiveStartKey` that produced this page, if any. */
128
134
  exclusiveStartKey?: string;
135
+ /** `true` if there are more keys beyond this page. When `true`, {@link nextExclusiveStartKey} is set. */
129
136
  isTruncated: boolean;
137
+ /** Cursor to pass as the next call's `exclusiveStartKey`, or `undefined` when {@link isTruncated} is `false`. */
130
138
  nextExclusiveStartKey?: string;
131
- items: KeyValueStoreItemData[];
132
- }
133
- export interface KeyValueStoreClientGetRecordOptions {
134
- buffer?: boolean;
135
- stream?: boolean;
136
139
  }
137
140
  /**
138
141
  * Key-value Store client.
139
142
  */
140
- export interface KeyValueStoreClient {
141
- get(): Promise<KeyValueStoreInfo | undefined>;
142
- update(newFields: KeyValueStoreClientUpdateOptions): Promise<Partial<KeyValueStoreInfo>>;
143
- delete(): Promise<void>;
144
- listKeys(options?: KeyValueStoreClientListOptions): Promise<KeyValueStoreClientListData>;
143
+ export interface KeyValueStoreBackend {
144
+ /**
145
+ * Returns metadata about the key-value store (id, name, timestamps, etc.).
146
+ *
147
+ * Implementations should throw if the underlying storage no longer exists
148
+ * (e.g. it was deleted externally). This method should never return stale data
149
+ * for a storage that has been removed.
150
+ */
151
+ getMetadata(): Promise<KeyValueStoreInfo>;
152
+ /** Remove the key-value store and all its data. */
153
+ drop(): Promise<void>;
154
+ /** Remove all records from the store but keep the store itself. */
155
+ purge(): Promise<void>;
156
+ /**
157
+ * Get a record by key. Returns the raw bytes plus content type, or `undefined` if not found.
158
+ *
159
+ * Clients are byte transports and must not parse the body — the `KeyValueStore` frontend
160
+ * interprets it according to the content type.
161
+ */
162
+ getValue(key: string): Promise<KeyValueStoreRecord | undefined>;
163
+ /** Set a record value. */
164
+ setValue(record: KeyValueStoreInputRecord): Promise<void>;
165
+ /** Delete a record by key. */
166
+ deleteValue(key: string): Promise<void>;
167
+ /**
168
+ * List a single page of keys in the store. Returns at most `limit` keys starting after
169
+ * `exclusiveStartKey`, wrapped in a self-describing page.
170
+ *
171
+ * Like {@link DatasetBackend.getData}, this returns one page rather than the whole collection;
172
+ * assembling all pages (e.g. for `KeyValueStore.keys()`) is the frontend's job. The result carries
173
+ * a cursor (`isTruncated` / `nextExclusiveStartKey`) so the frontend can paginate deterministically
174
+ * instead of inferring the end from `items.length < limit`.
175
+ */
176
+ listKeys(options?: KeyValueStoreListKeysOptions): Promise<KeyValueStoreListKeysResult>;
177
+ /** Get the public URL for a record, or `undefined` if unavailable. */
178
+ getPublicUrl(key: string): Promise<string | undefined>;
179
+ /** Check whether a record with the given key exists. */
145
180
  recordExists(key: string): Promise<boolean>;
146
- getRecord(key: string, options?: KeyValueStoreClientGetRecordOptions): Promise<KeyValueStoreRecord | undefined>;
147
- setRecord(record: KeyValueStoreRecord, options?: KeyValueStoreRecordOptions): Promise<void>;
148
- deleteRecord(key: string): Promise<void>;
149
- }
150
- export interface RequestQueueStats {
151
- readCount?: number;
152
- writeCount?: number;
153
- deleteCount?: number;
154
- headItemReadCount?: number;
155
- storageBytes?: number;
156
181
  }
157
182
  export interface RequestQueueInfo {
158
183
  id: string;
159
184
  name?: string;
160
- userId?: string;
161
185
  createdAt: Date;
162
186
  modifiedAt: Date;
163
187
  accessedAt: Date;
164
- expireAt?: string;
165
188
  totalRequestCount: number;
166
189
  handledRequestCount: number;
167
190
  pendingRequestCount: number;
168
- actId?: string;
169
- actRunId?: string;
170
- hadMultipleClients?: boolean;
171
- stats?: RequestQueueStats;
172
191
  }
173
192
  /**
174
- * Request queue collection client.
193
+ * Options for request-queue operations that add or return requests to the queue
194
+ * ({@link RequestQueueBackend.addBatchOfRequests}, {@link RequestQueueBackend.reclaimRequest}).
175
195
  */
176
- export interface RequestQueueCollectionClient {
177
- list(): Promise<PaginatedList<RequestQueueInfo>>;
178
- getOrCreate(name: string): Promise<RequestQueueInfo>;
179
- }
180
- export interface RequestQueueHeadItem {
181
- id: string;
182
- retryCount: number;
183
- uniqueKey: string;
184
- url: string;
185
- method: AllowedHttpMethods;
186
- }
187
- export interface QueueHead {
188
- limit: number;
189
- queueModifiedAt: Date;
190
- hadMultipleClients?: boolean;
191
- items: RequestQueueHeadItem[];
192
- }
193
- export interface ListOptions {
194
- /**
195
- * @default 100
196
- */
197
- limit?: number;
198
- }
199
- export interface ListAndLockOptions extends ListOptions {
200
- lockSecs: number;
201
- }
202
- export interface ListAndLockHeadResult extends QueueHead {
203
- lockSecs: number;
204
- queueHasLockedRequests?: boolean;
205
- }
206
- export interface ProlongRequestLockOptions {
207
- lockSecs: number;
208
- forefront?: boolean;
209
- }
210
- export interface ProlongRequestLockResult {
211
- lockExpiresAt: Date;
212
- }
213
- export interface DeleteRequestLockOptions {
214
- forefront?: boolean;
215
- }
216
- export interface RequestOptions {
196
+ export interface RequestQueueOperationOptions {
197
+ /** Place the affected request(s) at the beginning of the queue so they are processed sooner. */
217
198
  forefront?: boolean;
218
- [k: string]: unknown;
219
199
  }
220
200
  export interface RequestSchema {
221
201
  id?: string;
@@ -249,45 +229,189 @@ export interface BatchAddRequestsResult {
249
229
  processedRequests: ProcessedRequest[];
250
230
  unprocessedRequests: UnprocessedRequest[];
251
231
  }
252
- export interface RequestQueueClient {
253
- get(): Promise<RequestQueueInfo | undefined>;
254
- update(newFields: {
255
- name?: string;
256
- }): Promise<Partial<RequestQueueInfo> | undefined>;
257
- delete(): Promise<void>;
258
- listHead(options?: ListOptions): Promise<QueueHead>;
259
- addRequest(request: RequestSchema, options?: RequestOptions): Promise<QueueOperationInfo>;
260
- batchAddRequests(requests: RequestSchema[], options?: RequestOptions): Promise<BatchAddRequestsResult>;
261
- getRequest(id: string): Promise<RequestOptions | undefined>;
262
- updateRequest(request: UpdateRequestSchema, options?: RequestOptions): Promise<QueueOperationInfo>;
263
- deleteRequest(id: string): Promise<unknown>;
264
- listAndLockHead(options: ListAndLockOptions): Promise<ListAndLockHeadResult>;
265
- prolongRequestLock(id: string, options: ProlongRequestLockOptions): Promise<ProlongRequestLockResult>;
266
- deleteRequestLock(id: string, options?: DeleteRequestLockOptions): Promise<void>;
267
- }
268
- export interface RequestQueueOptions {
269
- clientKey?: string;
270
- timeoutSecs?: number;
271
- }
272
- export interface SetStatusMessageOptions {
273
- isStatusMessageTerminal?: boolean;
274
- level?: 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR';
232
+ /**
233
+ * Operations on a single request queue.
234
+ *
235
+ * A backend implementation owns all request bookkeeping (pending, in-progress, handled). Any
236
+ * coordination required between multiple distributed clients accessing the same queue (e.g. request
237
+ * locking on the Apify platform) is an internal concern of the implementation and is not exposed on
238
+ * this interface.
239
+ */
240
+ export interface RequestQueueBackend {
241
+ /**
242
+ * Returns metadata about the request queue (id, name, timestamps, request counts, etc.).
243
+ *
244
+ * Implementations should throw if the underlying storage no longer exists
245
+ * (e.g. it was deleted externally). This method should never return stale data
246
+ * for a storage that has been removed.
247
+ */
248
+ getMetadata(): Promise<RequestQueueInfo>;
249
+ /** Remove the request queue and all its data. */
250
+ drop(): Promise<void>;
251
+ /** Remove all requests from the queue but keep the queue itself. */
252
+ purge(): Promise<void>;
253
+ /**
254
+ * Add a batch of requests to the queue.
255
+ *
256
+ * Each request is deduplicated by its `uniqueKey`. Duplicates are reported in the result
257
+ * but not re-added. With `forefront`, requests are placed at the beginning of the queue so
258
+ * they are processed sooner.
259
+ */
260
+ addBatchOfRequests(requests: RequestSchema[], options?: RequestQueueOperationOptions): Promise<BatchAddRequestsResult>;
261
+ /**
262
+ * Retrieve a request from the queue by its `uniqueKey`, or `undefined` if it does not exist.
263
+ */
264
+ getRequest(uniqueKey: string): Promise<UpdateRequestSchema | undefined>;
265
+ /**
266
+ * Return the next request in the queue to be processed, or `undefined` if there are currently no
267
+ * pending requests.
268
+ *
269
+ * The returned request is marked as in-progress; it will not be returned again until it is
270
+ * either reclaimed via {@link reclaimRequest} or marked as handled via {@link markRequestAsHandled}.
271
+ *
272
+ * An `undefined` return value does not mean processing is finished — only that there are no pending
273
+ * requests right now. Use {@link isEmpty} (together with the frontend's knowledge of pending
274
+ * add operations) to determine whether the queue is truly finished.
275
+ */
276
+ fetchNextRequest(): Promise<UpdateRequestSchema | undefined>;
277
+ /**
278
+ * Mark a request previously returned by {@link fetchNextRequest} as handled.
279
+ *
280
+ * Handled requests are never returned again by {@link fetchNextRequest}. Returns information
281
+ * about the operation, or `undefined` if the request was not in progress.
282
+ *
283
+ * An `undefined` result is a no-op, not an error: the request is simply not something this client is
284
+ * currently processing, so nothing is changed and the request is never added to the queue as a side
285
+ * effect. (Marking an already-handled request is idempotent and still returns operation info with
286
+ * `wasAlreadyHandled: true` rather than `undefined`.)
287
+ */
288
+ markRequestAsHandled(request: UpdateRequestSchema): Promise<QueueOperationInfo | undefined>;
289
+ /**
290
+ * Reclaim a failed request back to the queue so it can be processed again by a later call to
291
+ * {@link fetchNextRequest}. With `forefront`, the request is returned to the beginning of the
292
+ * queue. Returns information about the operation, or `undefined` if the request was not in progress.
293
+ *
294
+ * The request is expected to already be present in the queue (it should have been obtained via
295
+ * {@link fetchNextRequest}); reclaiming releases its lock rather than inserting it. An `undefined` result
296
+ * is a no-op, not an error: the request is simply not something this client is currently processing,
297
+ * so nothing is changed and the request is never added to the queue as a side effect. Use
298
+ * {@link addBatchOfRequests} to insert a new request.
299
+ */
300
+ reclaimRequest(request: UpdateRequestSchema, options?: RequestQueueOperationOptions): Promise<QueueOperationInfo | undefined>;
301
+ /**
302
+ * Resolves to `true` if the next call to {@link fetchNextRequest} would return `undefined` — i.e. there
303
+ * are no pending requests to fetch right now.
304
+ *
305
+ * Requests that are currently in progress (fetched but not yet handled or reclaimed, including
306
+ * requests locked by other clients sharing the same queue) are **not** counted. An empty queue
307
+ * therefore does not mean crawling is finished — those in-progress requests may still be reclaimed,
308
+ * and background tasks may still add more requests. Use {@link isFinished} to detect completion.
309
+ */
310
+ isEmpty(): Promise<boolean>;
311
+ /**
312
+ * Resolves to `true` only when there is no outstanding work left in the queue at all — i.e. there
313
+ * are no pending requests to fetch **and** no requests currently in progress (fetched but not yet
314
+ * handled or reclaimed, including requests locked by other clients sharing the same queue).
315
+ *
316
+ * This is the strong counterpart of {@link isEmpty}: a queue whose only remaining requests are in
317
+ * progress is empty (nothing to fetch) but not finished (that work might still be reclaimed). It is
318
+ * the building block for determining whether crawling is done — though a frontend may still need to
319
+ * account for its own pending background add operations on top of this.
320
+ */
321
+ isFinished(): Promise<boolean>;
322
+ /**
323
+ * Tells the client how long (in seconds) a consumer expects to hold a request fetched via
324
+ * {@link fetchNextRequest} before marking it handled or reclaiming it — typically the consumer's
325
+ * request-processing timeout plus some padding.
326
+ *
327
+ * A client that coordinates consumers via locking uses this to keep the request reserved for at least
328
+ * this long, so that a long-running consumer does not have its request handed out again while it is
329
+ * still being processed. Clients that do not lock may ignore it.
330
+ */
331
+ setExpectedRequestProcessingTimeSecs?(secs: number): Promise<void>;
275
332
  }
276
333
  /**
277
- * Represents a storage capable of working with datasets, KV stores and request queues.
334
+ * Identifies a storage by its ID, name, or alias. At most one may be provided.
335
+ *
336
+ * - `{ id }` — open a pre-existing storage by its unique ID.
337
+ * - `{ name }` — open or create a globally named storage (persists across runs).
338
+ * - `{ alias }` — open or create a run-scoped unnamed storage identified by this alias.
339
+ * The alias is used locally (e.g. as a directory name or cache key) but the storage
340
+ * itself has no persistent name. Use this for non-default unnamed storages.
341
+ * - `{}` / omitted — open the default storage.
342
+ */
343
+ export type StorageIdentifier = {
344
+ id: string;
345
+ name?: never;
346
+ alias?: never;
347
+ } | {
348
+ id?: never;
349
+ name: string;
350
+ alias?: never;
351
+ } | {
352
+ id?: never;
353
+ name?: never;
354
+ alias: string;
355
+ } | {
356
+ id?: never;
357
+ name?: never;
358
+ alias?: never;
359
+ };
360
+ /**
361
+ * Represents a storage backend capable of working with datasets, key-value stores and request queues.
362
+ *
363
+ * A new storage backend needs to implement 4 classes:
364
+ * - `StorageBackend` - the factory that creates sub-backends
365
+ * - `DatasetBackend` - operations on a single dataset
366
+ * - `KeyValueStoreBackend` - operations on a single key-value store
367
+ * - `RequestQueueBackend` - operations on a single request queue
368
+ *
369
+ * The `StorageBackend` acts as an async factory: each `create*` method either opens an existing
370
+ * storage or creates a new one, returning a sub-backend bound to that storage instance.
278
371
  */
279
- export interface StorageClient {
280
- datasets(): DatasetCollectionClient;
281
- dataset(id: string): DatasetClient;
282
- keyValueStores(): KeyValueStoreCollectionClient;
283
- keyValueStore(id: string): KeyValueStoreClient;
284
- requestQueues(): RequestQueueCollectionClient;
285
- requestQueue(id: string, options?: RequestQueueOptions): RequestQueueClient;
372
+ export interface StorageBackend {
373
+ /**
374
+ * Create (or open) a dataset backend.
375
+ * If `id` is provided, opens the dataset with that ID.
376
+ * If `name` is provided, opens an existing dataset with that name or creates a new one.
377
+ * If neither is provided, opens or creates the default dataset.
378
+ */
379
+ createDatasetBackend(options?: StorageIdentifier): Promise<DatasetBackend>;
380
+ /**
381
+ * Create (or open) a key-value store backend.
382
+ * If `id` is provided, opens the key-value store with that ID.
383
+ * If `name` is provided, opens an existing store with that name or creates a new one.
384
+ * If neither is provided, opens or creates the default key-value store.
385
+ */
386
+ createKeyValueStoreBackend(options?: StorageIdentifier): Promise<KeyValueStoreBackend>;
387
+ /**
388
+ * Create (or open) a request queue backend.
389
+ * If `id` is provided, opens the request queue with that ID.
390
+ * If `name` is provided, opens an existing queue with that name or creates a new one.
391
+ * If neither is provided, opens or creates the default request queue.
392
+ */
393
+ createRequestQueueBackend(options?: StorageIdentifier): Promise<RequestQueueBackend>;
394
+ /**
395
+ * Check whether a storage with the given ID exists.
396
+ *
397
+ * Used internally to resolve ambiguous `idOrName` strings passed to `Dataset.open()`,
398
+ * `KeyValueStore.open()`, and `RequestQueue.open()`.
399
+ */
400
+ storageExists?(id: string, type: 'Dataset' | 'KeyValueStore' | 'RequestQueue'): Promise<boolean>;
401
+ /**
402
+ * Return an opaque key that uniquely identifies this storage backend instance.
403
+ *
404
+ * The key is used by `StorageInstanceManager` to partition the storage cache per-backend,
405
+ * so that two storages with the same name but backed by different clients
406
+ * (e.g. a local `MemoryStorageBackend` and a cloud `ApifyClient`) are cached as separate instances.
407
+ *
408
+ * When not provided, the fallback uses the client's constructor name, so different
409
+ * `StorageBackend` implementations automatically get separate cache partitions.
410
+ */
411
+ getStorageBackendCacheKey?(): string;
286
412
  purge?(): Promise<void>;
287
413
  teardown?(): Promise<void>;
288
- setStatusMessage?(message: string, options?: SetStatusMessageOptions): Promise<void>;
289
414
  stats?: {
290
415
  rateLimitErrors: number[];
291
416
  };
292
417
  }
293
- //# sourceMappingURL=storages.d.ts.map
package/storages.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=storages.js.map
@@ -4,5 +4,4 @@ export type Dictionary<T = any> = Record<PropertyKey, T>;
4
4
  export type Constructor<T = unknown> = new (...args: any[]) => T;
5
5
  /** @ignore */
6
6
  export type Awaitable<T> = T | PromiseLike<T>;
7
- export type AllowedHttpMethods = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'CONNECT' | 'PATCH';
8
- //# sourceMappingURL=utility-types.d.ts.map
7
+ export type AllowedHttpMethods = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'CONNECT' | 'PATCH' | 'get' | 'head' | 'post' | 'put' | 'delete' | 'trace' | 'options' | 'connect' | 'patch';
package/utility-types.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=utility-types.js.map
package/browser.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,MAAM;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,QAAQ,CAAC;IAChD;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAChC,GAAG,IAAI,MAAM,CAAC;IACd,OAAO,IAAI,UAAU,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;CAC5C"}
package/browser.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":""}
package/index.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
package/storages.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"storages.d.ts","sourceRoot":"","sources":["../src/storages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAC/B,6DAA6D;IAC7D,iBAAiB,EAAE,OAAO,CAAC;IAE3B,0DAA0D;IAC1D,iBAAiB,EAAE,OAAO,CAAC;IAE3B,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC3C,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,aAAa,CAAC,IAAI;IAC/B,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wDAAwD;IACxD,KAAK,EAAE,IAAI,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,OAAQ,SAAQ,qBAAqB;IAClD,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CA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