@crawlee/memory-storage 3.1.5-beta.2 → 3.1.5-beta.21
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/cache-helpers.d.ts.map +1 -1
- package/cache-helpers.js +51 -31
- package/cache-helpers.js.map +1 -1
- package/fs/common.d.ts +6 -0
- package/fs/common.d.ts.map +1 -0
- package/fs/common.js +3 -0
- package/fs/common.js.map +1 -0
- package/fs/dataset/fs.d.ts +10 -0
- package/fs/dataset/fs.d.ts.map +1 -0
- package/fs/dataset/fs.js +30 -0
- package/fs/dataset/fs.js.map +1 -0
- package/fs/dataset/index.d.ts +10 -0
- package/fs/dataset/index.d.ts.map +1 -0
- package/fs/dataset/index.js +13 -0
- package/fs/dataset/index.js.map +1 -0
- package/fs/dataset/memory.d.ts +8 -0
- package/fs/dataset/memory.d.ts.map +1 -0
- package/fs/dataset/memory.js +24 -0
- package/fs/dataset/memory.js.map +1 -0
- package/fs/key-value-store/fs.d.ts +15 -0
- package/fs/key-value-store/fs.d.ts.map +1 -0
- package/fs/key-value-store/fs.js +87 -0
- package/fs/key-value-store/fs.js.map +1 -0
- package/fs/key-value-store/index.d.ts +9 -0
- package/fs/key-value-store/index.d.ts.map +1 -0
- package/fs/key-value-store/index.js +13 -0
- package/fs/key-value-store/index.js.map +1 -0
- package/fs/key-value-store/memory.d.ts +9 -0
- package/fs/key-value-store/memory.d.ts.map +1 -0
- package/fs/key-value-store/memory.js +24 -0
- package/fs/key-value-store/memory.js.map +1 -0
- package/fs/request-queue/fs.d.ts +11 -0
- package/fs/request-queue/fs.d.ts.map +1 -0
- package/fs/request-queue/fs.js +30 -0
- package/fs/request-queue/fs.js.map +1 -0
- package/fs/request-queue/index.d.ts +9 -0
- package/fs/request-queue/index.d.ts.map +1 -0
- package/fs/request-queue/index.js +13 -0
- package/fs/request-queue/index.js.map +1 -0
- package/fs/request-queue/memory.d.ts +9 -0
- package/fs/request-queue/memory.d.ts.map +1 -0
- package/fs/request-queue/memory.js +24 -0
- package/fs/request-queue/memory.js.map +1 -0
- package/package.json +8 -7
- package/resource-clients/dataset.d.ts.map +1 -1
- package/resource-clients/dataset.js +9 -12
- package/resource-clients/dataset.js.map +1 -1
- package/resource-clients/key-value-store.d.ts.map +1 -1
- package/resource-clients/key-value-store.js +15 -29
- package/resource-clients/key-value-store.js.map +1 -1
- package/resource-clients/request-queue.d.ts +0 -1
- package/resource-clients/request-queue.d.ts.map +1 -1
- package/resource-clients/request-queue.js +45 -44
- package/resource-clients/request-queue.js.map +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils.d.ts +3 -31
- package/utils.d.ts.map +1 -1
- package/utils.js.map +1 -1
- package/workers/worker-utils.d.ts +1 -0
- package/workers/worker-utils.d.ts.map +1 -1
- package/workers/worker-utils.js +2 -74
- package/workers/worker-utils.js.map +1 -1
package/cache-helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-helpers.d.ts","sourceRoot":"","sources":["../src/cache-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAM/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"cache-helpers.d.ts","sourceRoot":"","sources":["../src/cache-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAM/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQtD,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+DA+FhG;AAED,wBAAsB,oCAAoC,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4CAiJtG;AAED,wBAAsB,4BAA4B,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2CA+F9F;AAGD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/cache-helpers.js
CHANGED
|
@@ -5,6 +5,10 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const promises_1 = require("node:fs/promises");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
7
|
const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
|
|
8
|
+
const json5_1 = tslib_1.__importDefault(require("json5"));
|
|
9
|
+
const fs_1 = require("./fs/dataset/fs");
|
|
10
|
+
const fs_2 = require("./fs/key-value-store/fs");
|
|
11
|
+
const fs_3 = require("./fs/request-queue/fs");
|
|
8
12
|
const utils_1 = require("./utils");
|
|
9
13
|
const uuidRegex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
10
14
|
async function findOrCacheDatasetByPossibleId(client, entryNameOrId) {
|
|
@@ -26,7 +30,7 @@ async function findOrCacheDatasetByPossibleId(client, entryNameOrId) {
|
|
|
26
30
|
let id;
|
|
27
31
|
let name;
|
|
28
32
|
let itemCount = 0;
|
|
29
|
-
const entries = new
|
|
33
|
+
const entries = new Set();
|
|
30
34
|
let createdAt = new Date();
|
|
31
35
|
let accessedAt = new Date();
|
|
32
36
|
let modifiedAt = new Date();
|
|
@@ -36,7 +40,10 @@ async function findOrCacheDatasetByPossibleId(client, entryNameOrId) {
|
|
|
36
40
|
if (entry.name === '__metadata__.json') {
|
|
37
41
|
hasSeenMetadataFile = true;
|
|
38
42
|
// we have found the store metadata file, build out information based on it
|
|
39
|
-
const
|
|
43
|
+
const fileContent = await (0, promises_1.readFile)((0, node_path_1.resolve)(datasetDir, entry.name), 'utf8');
|
|
44
|
+
if (!fileContent)
|
|
45
|
+
continue;
|
|
46
|
+
const metadata = JSON.parse(fileContent);
|
|
40
47
|
id = metadata.id;
|
|
41
48
|
name = metadata.name;
|
|
42
49
|
itemCount = metadata.itemCount;
|
|
@@ -45,9 +52,8 @@ async function findOrCacheDatasetByPossibleId(client, entryNameOrId) {
|
|
|
45
52
|
modifiedAt = new Date(metadata.modifiedAt);
|
|
46
53
|
continue;
|
|
47
54
|
}
|
|
48
|
-
const entryContent = JSON.parse(await (0, promises_1.readFile)((0, node_path_1.resolve)(datasetDir, entry.name), 'utf8'));
|
|
49
55
|
const entryName = entry.name.split('.')[0];
|
|
50
|
-
entries.
|
|
56
|
+
entries.add(entryName);
|
|
51
57
|
if (!hasSeenMetadataFile) {
|
|
52
58
|
itemCount++;
|
|
53
59
|
}
|
|
@@ -73,9 +79,11 @@ async function findOrCacheDatasetByPossibleId(client, entryNameOrId) {
|
|
|
73
79
|
newClient.createdAt = createdAt;
|
|
74
80
|
newClient.modifiedAt = modifiedAt;
|
|
75
81
|
newClient.itemCount = itemCount;
|
|
76
|
-
for (const
|
|
82
|
+
for (const entryId of entries.values()) {
|
|
83
|
+
// We create a file system entry instead of possibly making an in-memory one to allow the pre-included data to be used on demand
|
|
84
|
+
const entry = new fs_1.DatasetFileSystemEntry({ storeDirectory: datasetDir, entityId: entryId, persistStorage: true });
|
|
77
85
|
// eslint-disable-next-line dot-notation
|
|
78
|
-
newClient['datasetEntries'].set(entryId,
|
|
86
|
+
newClient['datasetEntries'].set(entryId, entry);
|
|
79
87
|
}
|
|
80
88
|
client.datasetClientsHandled.push(newClient);
|
|
81
89
|
return newClient;
|
|
@@ -103,11 +111,15 @@ async function findOrCacheKeyValueStoreByPossibleId(client, entryNameOrId) {
|
|
|
103
111
|
let accessedAt = new Date();
|
|
104
112
|
let modifiedAt = new Date();
|
|
105
113
|
const internalRecords = new Map();
|
|
114
|
+
let hasSeenMetadataForEntry = false;
|
|
106
115
|
for await (const entry of directoryEntries) {
|
|
107
116
|
if (entry.isFile()) {
|
|
108
117
|
if (entry.name === '__metadata__.json') {
|
|
109
118
|
// we have found the store metadata file, build out information based on it
|
|
110
|
-
const
|
|
119
|
+
const fileContent = await (0, promises_1.readFile)((0, node_path_1.resolve)(keyValueStoreDir, entry.name), 'utf8');
|
|
120
|
+
if (!fileContent)
|
|
121
|
+
continue;
|
|
122
|
+
const metadata = JSON.parse(fileContent);
|
|
111
123
|
id = metadata.id;
|
|
112
124
|
name = metadata.name;
|
|
113
125
|
createdAt = new Date(metadata.createdAt);
|
|
@@ -116,8 +128,12 @@ async function findOrCacheKeyValueStoreByPossibleId(client, entryNameOrId) {
|
|
|
116
128
|
continue;
|
|
117
129
|
}
|
|
118
130
|
if (entry.name.includes('.__metadata__.')) {
|
|
131
|
+
hasSeenMetadataForEntry = true;
|
|
119
132
|
// This is an entry's metadata file, we can use it to create/extend the record
|
|
120
|
-
const
|
|
133
|
+
const fileContent = await (0, promises_1.readFile)((0, node_path_1.resolve)(keyValueStoreDir, entry.name), 'utf8');
|
|
134
|
+
if (!fileContent)
|
|
135
|
+
continue;
|
|
136
|
+
const metadata = JSON.parse(fileContent);
|
|
121
137
|
const newRecord = {
|
|
122
138
|
...internalRecords.get(metadata.key),
|
|
123
139
|
...metadata,
|
|
@@ -125,33 +141,22 @@ async function findOrCacheKeyValueStoreByPossibleId(client, entryNameOrId) {
|
|
|
125
141
|
internalRecords.set(metadata.key, newRecord);
|
|
126
142
|
continue;
|
|
127
143
|
}
|
|
144
|
+
// This is an entry in the store, we can use it to create/extend the record
|
|
128
145
|
const fileContent = await (0, promises_1.readFile)((0, node_path_1.resolve)(keyValueStoreDir, entry.name));
|
|
129
146
|
const fileExtension = (0, node_path_1.extname)(entry.name);
|
|
130
147
|
const contentType = mime_types_1.default.contentType(entry.name) || 'text/plain';
|
|
131
148
|
const extension = mime_types_1.default.extension(contentType);
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
utils_1.memoryStorageLog.warning([
|
|
135
|
-
`Key-value entry "${entry.name}" for store ${entryNameOrId} does not have a file extension, assuming it as text.`,
|
|
136
|
-
'If you want to have correct interpretation of the file, you should add a file extension to the entry.',
|
|
137
|
-
].join('\n'));
|
|
138
|
-
finalFileContent = fileContent.toString('utf8');
|
|
139
|
-
}
|
|
140
|
-
else if (contentType.includes('application/json')) {
|
|
149
|
+
// This is kept for backwards compatibility / to ignore invalid JSON files
|
|
150
|
+
if (contentType.includes('application/json')) {
|
|
141
151
|
const stringifiedJson = fileContent.toString('utf8');
|
|
142
152
|
try {
|
|
143
|
-
|
|
144
|
-
JSON.parse(stringifiedJson);
|
|
145
|
-
finalFileContent = stringifiedJson;
|
|
153
|
+
json5_1.default.parse(stringifiedJson);
|
|
146
154
|
}
|
|
147
155
|
catch {
|
|
148
156
|
utils_1.memoryStorageLog.warning(`Key-value entry "${entry.name}" for store ${entryNameOrId} has invalid JSON content and will be ignored from the store.`);
|
|
149
157
|
continue;
|
|
150
158
|
}
|
|
151
159
|
}
|
|
152
|
-
else if (contentType.includes('text/plain')) {
|
|
153
|
-
finalFileContent = fileContent.toString('utf8');
|
|
154
|
-
}
|
|
155
160
|
const nameSplit = entry.name.split('.');
|
|
156
161
|
if (fileExtension) {
|
|
157
162
|
nameSplit.pop();
|
|
@@ -160,7 +165,6 @@ async function findOrCacheKeyValueStoreByPossibleId(client, entryNameOrId) {
|
|
|
160
165
|
const newRecord = {
|
|
161
166
|
key,
|
|
162
167
|
extension,
|
|
163
|
-
value: finalFileContent,
|
|
164
168
|
contentType,
|
|
165
169
|
...internalRecords.get(key),
|
|
166
170
|
};
|
|
@@ -187,8 +191,16 @@ async function findOrCacheKeyValueStoreByPossibleId(client, entryNameOrId) {
|
|
|
187
191
|
newClient.createdAt = createdAt;
|
|
188
192
|
newClient.modifiedAt = modifiedAt;
|
|
189
193
|
for (const [key, record] of internalRecords) {
|
|
194
|
+
// We create a file system entry instead of possibly making an in-memory one to allow the pre-included data to be used on demand
|
|
195
|
+
const entry = new fs_2.KeyValueFileSystemEntry({ persistStorage: true, storeDirectory: keyValueStoreDir, writeMetadata: hasSeenMetadataForEntry });
|
|
196
|
+
// eslint-disable-next-line dot-notation
|
|
197
|
+
entry['rawRecord'] = { ...record };
|
|
198
|
+
// eslint-disable-next-line dot-notation
|
|
199
|
+
entry['filePath'] = (0, node_path_1.resolve)(keyValueStoreDir, `${record.key}.${record.extension}`);
|
|
200
|
+
// eslint-disable-next-line dot-notation
|
|
201
|
+
entry['fileMetadataPath'] = (0, node_path_1.resolve)(keyValueStoreDir, `${record.key}.__metadata__.json`);
|
|
190
202
|
// eslint-disable-next-line dot-notation
|
|
191
|
-
newClient['keyValueEntries'].set(key,
|
|
203
|
+
newClient['keyValueEntries'].set(key, entry);
|
|
192
204
|
}
|
|
193
205
|
client.keyValueStoresHandled.push(newClient);
|
|
194
206
|
return newClient;
|
|
@@ -217,13 +229,16 @@ async function findRequestQueueByPossibleId(client, entryNameOrId) {
|
|
|
217
229
|
let modifiedAt = new Date();
|
|
218
230
|
let pendingRequestCount = 0;
|
|
219
231
|
let handledRequestCount = 0;
|
|
220
|
-
const entries =
|
|
232
|
+
const entries = new Set();
|
|
221
233
|
for await (const entry of directoryEntries) {
|
|
222
234
|
if (entry.isFile()) {
|
|
223
235
|
switch (entry.name) {
|
|
224
236
|
case '__metadata__.json': {
|
|
225
237
|
// we have found the store metadata file, build out information based on it
|
|
226
|
-
const
|
|
238
|
+
const fileContent = await (0, promises_1.readFile)((0, node_path_1.resolve)(requestQueueDir, entry.name), 'utf8');
|
|
239
|
+
if (!fileContent)
|
|
240
|
+
continue;
|
|
241
|
+
const metadata = JSON.parse(fileContent);
|
|
227
242
|
id = metadata.id;
|
|
228
243
|
name = metadata.name;
|
|
229
244
|
createdAt = new Date(metadata.createdAt);
|
|
@@ -234,8 +249,8 @@ async function findRequestQueueByPossibleId(client, entryNameOrId) {
|
|
|
234
249
|
break;
|
|
235
250
|
}
|
|
236
251
|
default: {
|
|
237
|
-
const
|
|
238
|
-
entries.
|
|
252
|
+
const entryName = entry.name.split('.')[0];
|
|
253
|
+
entries.add(entryName);
|
|
239
254
|
}
|
|
240
255
|
}
|
|
241
256
|
}
|
|
@@ -261,9 +276,14 @@ async function findRequestQueueByPossibleId(client, entryNameOrId) {
|
|
|
261
276
|
newClient.modifiedAt = modifiedAt;
|
|
262
277
|
newClient.pendingRequestCount = pendingRequestCount;
|
|
263
278
|
newClient.handledRequestCount = handledRequestCount;
|
|
264
|
-
for (const
|
|
279
|
+
for (const requestId of entries) {
|
|
280
|
+
const entry = new fs_3.RequestQueueFileSystemEntry({
|
|
281
|
+
persistStorage: true,
|
|
282
|
+
requestId,
|
|
283
|
+
storeDirectory: requestQueueDir,
|
|
284
|
+
});
|
|
265
285
|
// eslint-disable-next-line dot-notation
|
|
266
|
-
newClient['requests'].set(
|
|
286
|
+
newClient['requests'].set(requestId, entry);
|
|
267
287
|
}
|
|
268
288
|
client.requestQueuesHandled.push(newClient);
|
|
269
289
|
return newClient;
|
package/cache-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-helpers.js","sourceRoot":"","sources":["../src/cache-helpers.ts"],"names":[],"mappings":";;;;AACA,+CAA6D;AAC7D,yCAA6C;AAC7C,oEAAmC;
|
|
1
|
+
{"version":3,"file":"cache-helpers.js","sourceRoot":"","sources":["../src/cache-helpers.ts"],"names":[],"mappings":";;;;AACA,+CAA6D;AAC7D,yCAA6C;AAC7C,oEAAmC;AACnC,0DAA0B;AAG1B,wCAAyD;AACzD,gDAAkE;AAClE,8CAAoE;AACpE,mCAA2C;AAE3C,MAAM,SAAS,GAAG,+DAA+D,CAAC;AAE3E,KAAK,UAAU,8BAA8B,CAAC,MAAqB,EAAE,aAAqB;IAC7F,2BAA2B;IAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,aAAa,IAAI,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAE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GAAG,mBAAmB,CAAC;IACpD,SAAS,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IAEpD,KAAK,MAAM,SAAS,IAAI,OAAO,EAAE;QAC7B,MAAM,KAAK,GAAG,IAAI,gCAA2B,CAAC;YAC1C,cAAc,EAAE,IAAI;YACpB,SAAS;YACT,cAAc,EAAE,eAAe;SAClC,CAAC,CAAC;QAEH,wCAAwC;QACxC,SAAS,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KAC/C;IAED,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE5C,OAAO,SAAS,CAAC;AACrB,CAAC;AA/FD,oEA+FC;AAED,qDAAqD;AACrD,wDAA2D;AAC3D,wEAAyE;AACzE,oEAAsE"}
|
package/fs/common.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/fs/common.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACpC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IAClB,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC"}
|
package/fs/common.js
ADDED
package/fs/common.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/fs/common.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CreateStorageImplementationOptions } from './index';
|
|
2
|
+
import type { StorageImplementation } from '../common';
|
|
3
|
+
export declare class DatasetFileSystemEntry<Data> implements StorageImplementation<Data> {
|
|
4
|
+
private filePath;
|
|
5
|
+
constructor(options: CreateStorageImplementationOptions);
|
|
6
|
+
get(): Promise<any>;
|
|
7
|
+
update(data: Data): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/fs/dataset/fs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAGvD,qBAAa,sBAAsB,CAAC,IAAI,CAAE,YAAW,qBAAqB,CAAC,IAAI,CAAC;IAC5E,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,EAAE,kCAAkC;IAIjD,GAAG;IAIH,MAAM,CAAC,IAAI,EAAE,IAAI;IAKjB,MAAM;CAGf"}
|
package/fs/dataset/fs.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatasetFileSystemEntry = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const worker_utils_1 = require("../../workers/worker-utils");
|
|
8
|
+
class DatasetFileSystemEntry {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
Object.defineProperty(this, "filePath", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
this.filePath = (0, node_path_1.resolve)(options.storeDirectory, `${options.entityId}.json`);
|
|
17
|
+
}
|
|
18
|
+
async get() {
|
|
19
|
+
return JSON.parse(await (0, promises_1.readFile)(this.filePath, 'utf-8'));
|
|
20
|
+
}
|
|
21
|
+
async update(data) {
|
|
22
|
+
await (0, fs_extra_1.ensureDir)((0, node_path_1.dirname)(this.filePath));
|
|
23
|
+
await (0, worker_utils_1.lockAndWrite)(this.filePath, data);
|
|
24
|
+
}
|
|
25
|
+
async delete() {
|
|
26
|
+
await (0, promises_1.rm)(this.filePath, { force: true });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.DatasetFileSystemEntry = DatasetFileSystemEntry;
|
|
30
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/fs/dataset/fs.ts"],"names":[],"mappings":";;;AAAA,+CAAgD;AAChD,yCAA6C;AAC7C,uCAAqC;AAGrC,6DAA0D;AAE1D,MAAa,sBAAsB;IAG/B,YAAY,OAA2C;QAFvD;;;;;WAAyB;QAGrB,IAAI,CAAC,QAAQ,GAAG,IAAA,mBAAO,EAAC,OAAO,CAAC,cAAc,EAAE,GAAG,OAAO,CAAC,QAAQ,OAAO,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAU;QACnB,MAAM,IAAA,oBAAS,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxC,MAAM,IAAA,2BAAY,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,MAAM;QACR,MAAM,IAAA,aAAE,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACJ;AAnBD,wDAmBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Dictionary } from '@crawlee/types';
|
|
2
|
+
import type { StorageImplementation } from '../common';
|
|
3
|
+
export declare function createDatasetStorageImplementation<Data extends Dictionary>(options: CreateStorageImplementationOptions): StorageImplementation<Data>;
|
|
4
|
+
export interface CreateStorageImplementationOptions {
|
|
5
|
+
persistStorage: boolean;
|
|
6
|
+
storeDirectory: string;
|
|
7
|
+
/** The actual id of the file to save */
|
|
8
|
+
entityId: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fs/dataset/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAIvD,wBAAgB,kCAAkC,CAAC,IAAI,SAAS,UAAU,EAAE,OAAO,EAAE,kCAAkC,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAMpJ;AAED,MAAM,WAAW,kCAAkC;IAC/C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDatasetStorageImplementation = void 0;
|
|
4
|
+
const fs_1 = require("./fs");
|
|
5
|
+
const memory_1 = require("./memory");
|
|
6
|
+
function createDatasetStorageImplementation(options) {
|
|
7
|
+
if (options.persistStorage) {
|
|
8
|
+
return new fs_1.DatasetFileSystemEntry(options);
|
|
9
|
+
}
|
|
10
|
+
return new memory_1.DatasetMemoryEntry();
|
|
11
|
+
}
|
|
12
|
+
exports.createDatasetStorageImplementation = createDatasetStorageImplementation;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fs/dataset/index.ts"],"names":[],"mappings":";;;AAEA,6BAA8C;AAC9C,qCAA8C;AAE9C,SAAgB,kCAAkC,CAA0B,OAA2C;IACnH,IAAI,OAAO,CAAC,cAAc,EAAE;QACxB,OAAO,IAAI,2BAAsB,CAAO,OAAO,CAAC,CAAC;KACpD;IAED,OAAO,IAAI,2BAAkB,EAAQ,CAAC;AAC1C,CAAC;AAND,gFAMC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StorageImplementation } from '../common';
|
|
2
|
+
export declare class DatasetMemoryEntry<Data> implements StorageImplementation<Data> {
|
|
3
|
+
private data;
|
|
4
|
+
get(): Promise<Data>;
|
|
5
|
+
update(data: Data): void;
|
|
6
|
+
delete(): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/fs/dataset/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,qBAAa,kBAAkB,CAAC,IAAI,CAAE,YAAW,qBAAqB,CAAC,IAAI,CAAC;IACxE,OAAO,CAAC,IAAI,CAAQ;IAEd,GAAG;IAIT,MAAM,CAAC,IAAI,EAAE,IAAI;IAIjB,MAAM;CAGT"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatasetMemoryEntry = void 0;
|
|
4
|
+
class DatasetMemoryEntry {
|
|
5
|
+
constructor() {
|
|
6
|
+
Object.defineProperty(this, "data", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: void 0
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async get() {
|
|
14
|
+
return this.data;
|
|
15
|
+
}
|
|
16
|
+
update(data) {
|
|
17
|
+
this.data = data;
|
|
18
|
+
}
|
|
19
|
+
delete() {
|
|
20
|
+
// No-op
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.DatasetMemoryEntry = DatasetMemoryEntry;
|
|
24
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/fs/dataset/memory.ts"],"names":[],"mappings":";;;AAEA,MAAa,kBAAkB;IAA/B;QACI;;;;;WAAoB;IAaxB,CAAC;IAXG,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,IAAU;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,MAAM;QACF,QAAQ;IACZ,CAAC;CACJ;AAdD,gDAcC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CreateStorageImplementationOptions } from '.';
|
|
2
|
+
import type { InternalKeyRecord } from '../../resource-clients/key-value-store';
|
|
3
|
+
import type { StorageImplementation } from '../common';
|
|
4
|
+
export declare class KeyValueFileSystemEntry implements StorageImplementation<InternalKeyRecord> {
|
|
5
|
+
private storeDirectory;
|
|
6
|
+
private writeMetadata;
|
|
7
|
+
private filePath;
|
|
8
|
+
private fileMetadataPath;
|
|
9
|
+
private rawRecord;
|
|
10
|
+
constructor(options: CreateStorageImplementationOptions);
|
|
11
|
+
get(): Promise<InternalKeyRecord>;
|
|
12
|
+
update(data: InternalKeyRecord): Promise<void>;
|
|
13
|
+
delete(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/fs/key-value-store/fs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,GAAG,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAGhF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,qBAAa,uBAAwB,YAAW,qBAAqB,CAAC,iBAAiB,CAAC;IACpF,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,aAAa,CAAU;IAE/B,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,gBAAgB,CAAU;IAClC,OAAO,CAAC,SAAS,CAAoC;gBAEzC,OAAO,EAAE,kCAAkC;IAKjD,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA0BjC,MAAM,CAAC,IAAI,EAAE,iBAAiB;IAe9B,MAAM;CAIf"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyValueFileSystemEntry = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const win32_1 = require("node:path/win32");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const worker_utils_1 = require("../../workers/worker-utils");
|
|
10
|
+
class KeyValueFileSystemEntry {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
Object.defineProperty(this, "storeDirectory", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "writeMetadata", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "filePath", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "fileMetadataPath", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "rawRecord", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
this.storeDirectory = options.storeDirectory;
|
|
43
|
+
this.writeMetadata = options.writeMetadata;
|
|
44
|
+
}
|
|
45
|
+
async get() {
|
|
46
|
+
let file;
|
|
47
|
+
try {
|
|
48
|
+
file = await (0, promises_1.readFile)(this.filePath);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
try {
|
|
52
|
+
// Try without extension
|
|
53
|
+
file = await (0, promises_1.readFile)((0, node_path_1.resolve)(this.storeDirectory, this.rawRecord.key));
|
|
54
|
+
utils_1.memoryStorageLog.warning([
|
|
55
|
+
`Key-value entry "${this.rawRecord.key}" for store ${(0, win32_1.basename)(this.storeDirectory)} does not have a file extension, assuming it as text.`,
|
|
56
|
+
'If you want to have correct interpretation of the file, you should add a file extension to the entry.',
|
|
57
|
+
].join('\n'));
|
|
58
|
+
file = file.toString('utf-8');
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// This is impossible to happen, but just in case
|
|
62
|
+
throw new Error(`Could not find file at ${this.filePath}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...this.rawRecord,
|
|
67
|
+
value: file,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async update(data) {
|
|
71
|
+
this.filePath ?? (this.filePath = (0, node_path_1.resolve)(this.storeDirectory, `${data.key}.${data.extension}`));
|
|
72
|
+
this.fileMetadataPath ?? (this.fileMetadataPath = (0, node_path_1.resolve)(this.storeDirectory, `${data.key}.__metadata__.json`));
|
|
73
|
+
const { value, ...rest } = data;
|
|
74
|
+
this.rawRecord = rest;
|
|
75
|
+
await (0, fs_extra_1.ensureDir)((0, node_path_1.dirname)(this.filePath));
|
|
76
|
+
await (0, worker_utils_1.lockAndWrite)(this.filePath, value, false);
|
|
77
|
+
if (this.writeMetadata) {
|
|
78
|
+
await (0, worker_utils_1.lockAndWrite)(this.fileMetadataPath, JSON.stringify(rest), true);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async delete() {
|
|
82
|
+
await (0, promises_1.rm)(this.filePath, { force: true });
|
|
83
|
+
await (0, promises_1.rm)(this.fileMetadataPath, { force: true });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.KeyValueFileSystemEntry = KeyValueFileSystemEntry;
|
|
87
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/fs/key-value-store/fs.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,+CAAgD;AAChD,yCAA6C;AAC7C,2CAA2C;AAG3C,uCAA+C;AAC/C,6DAA0D;AAG1D,MAAa,uBAAuB;IAQhC,YAAY,OAA2C;QAPvD;;;;;WAA+B;QAC/B;;;;;WAA+B;QAE/B;;;;;WAA0B;QAC1B;;;;;WAAkC;QAClC;;;;;WAAqD;QAGjD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,GAAG;QACL,IAAI,IAAqB,CAAC;QAE1B,IAAI;YACA,IAAI,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACxC;QAAC,MAAM;YACJ,IAAI;gBACA,wBAAwB;gBACxB,IAAI,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,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,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;SACzE;IACL,CAAC;IAED,KAAK,CAAC,MAAM;QACR,MAAM,IAAA,aAAE,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,MAAM,IAAA,aAAE,EAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;CACJ;AA1DD,0DA0DC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InternalKeyRecord } from '../../resource-clients/key-value-store';
|
|
2
|
+
import type { StorageImplementation } from '../common';
|
|
3
|
+
export declare function createKeyValueStorageImplementation(options: CreateStorageImplementationOptions): StorageImplementation<InternalKeyRecord>;
|
|
4
|
+
export interface CreateStorageImplementationOptions {
|
|
5
|
+
persistStorage: boolean;
|
|
6
|
+
storeDirectory: string;
|
|
7
|
+
writeMetadata: boolean;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fs/key-value-store/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAIvD,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,kCAAkC,GAAG,qBAAqB,CAAC,iBAAiB,CAAC,CAMzI;AAED,MAAM,WAAW,kCAAkC;IAC/C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createKeyValueStorageImplementation = void 0;
|
|
4
|
+
const fs_1 = require("./fs");
|
|
5
|
+
const memory_1 = require("./memory");
|
|
6
|
+
function createKeyValueStorageImplementation(options) {
|
|
7
|
+
if (options.persistStorage) {
|
|
8
|
+
return new fs_1.KeyValueFileSystemEntry(options);
|
|
9
|
+
}
|
|
10
|
+
return new memory_1.KeyValueMemoryEntry();
|
|
11
|
+
}
|
|
12
|
+
exports.createKeyValueStorageImplementation = createKeyValueStorageImplementation;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fs/key-value-store/index.ts"],"names":[],"mappings":";;;AAEA,6BAA+C;AAC/C,qCAA+C;AAE/C,SAAgB,mCAAmC,CAAC,OAA2C;IAC3F,IAAI,OAAO,CAAC,cAAc,EAAE;QACxB,OAAO,IAAI,4BAAuB,CAAC,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,IAAI,4BAAmB,EAAE,CAAC;AACrC,CAAC;AAND,kFAMC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InternalKeyRecord } from '../../resource-clients/key-value-store';
|
|
2
|
+
import type { StorageImplementation } from '../common';
|
|
3
|
+
export declare class KeyValueMemoryEntry implements StorageImplementation<InternalKeyRecord> {
|
|
4
|
+
private data;
|
|
5
|
+
get(): Promise<InternalKeyRecord>;
|
|
6
|
+
update(data: InternalKeyRecord): void;
|
|
7
|
+
delete(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/fs/key-value-store/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,qBAAa,mBAAoB,YAAW,qBAAqB,CAAC,iBAAiB,CAAC;IAChF,OAAO,CAAC,IAAI,CAAqB;IAE3B,GAAG;IAIT,MAAM,CAAC,IAAI,EAAE,iBAAiB;IAI9B,MAAM;CAGT"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyValueMemoryEntry = void 0;
|
|
4
|
+
class KeyValueMemoryEntry {
|
|
5
|
+
constructor() {
|
|
6
|
+
Object.defineProperty(this, "data", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: void 0
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async get() {
|
|
14
|
+
return this.data;
|
|
15
|
+
}
|
|
16
|
+
update(data) {
|
|
17
|
+
this.data = data;
|
|
18
|
+
}
|
|
19
|
+
delete() {
|
|
20
|
+
// No-op
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.KeyValueMemoryEntry = KeyValueMemoryEntry;
|
|
24
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/fs/key-value-store/memory.ts"],"names":[],"mappings":";;;AAGA,MAAa,mBAAmB;IAAhC;QACI;;;;;WAAiC;IAarC,CAAC;IAXG,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,IAAuB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,MAAM;QACF,QAAQ;IACZ,CAAC;CACJ;AAdD,kDAcC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CreateStorageImplementationOptions } from '.';
|
|
2
|
+
import type { InternalRequest } from '../../resource-clients/request-queue';
|
|
3
|
+
import type { StorageImplementation } from '../common';
|
|
4
|
+
export declare class RequestQueueFileSystemEntry implements StorageImplementation<InternalRequest> {
|
|
5
|
+
private filePath;
|
|
6
|
+
constructor(options: CreateStorageImplementationOptions);
|
|
7
|
+
get(): Promise<any>;
|
|
8
|
+
update(data: InternalRequest): Promise<void>;
|
|
9
|
+
delete(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/fs/request-queue/fs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,GAAG,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,qBAAa,2BAA4B,YAAW,qBAAqB,CAAC,eAAe,CAAC;IACtF,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,EAAE,kCAAkC;IAIjD,GAAG;IAIH,MAAM,CAAC,IAAI,EAAE,eAAe;IAK5B,MAAM;CAGf"}
|