@crawlee/core 3.0.0-alpha.2 → 3.0.0-alpha.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.
Files changed (162) hide show
  1. package/dist/LICENSE.md +201 -0
  2. package/{README.md → dist/README.md} +0 -0
  3. package/dist/autoscaling/autoscaled_pool.d.ts +286 -0
  4. package/dist/autoscaling/autoscaled_pool.d.ts.map +1 -0
  5. package/dist/autoscaling/autoscaled_pool.js +624 -0
  6. package/dist/autoscaling/autoscaled_pool.js.map +1 -0
  7. package/dist/autoscaling/index.d.ts +4 -0
  8. package/dist/autoscaling/index.d.ts.map +1 -0
  9. package/dist/autoscaling/index.js +7 -0
  10. package/dist/autoscaling/index.js.map +1 -0
  11. package/dist/autoscaling/snapshotter.d.ts +193 -0
  12. package/dist/autoscaling/snapshotter.d.ts.map +1 -0
  13. package/dist/autoscaling/snapshotter.js +377 -0
  14. package/dist/autoscaling/snapshotter.js.map +1 -0
  15. package/dist/autoscaling/system_status.d.ts +181 -0
  16. package/dist/autoscaling/system_status.d.ts.map +1 -0
  17. package/dist/autoscaling/system_status.js +194 -0
  18. package/dist/autoscaling/system_status.js.map +1 -0
  19. package/dist/cache_container.d.ts +18 -0
  20. package/dist/cache_container.d.ts.map +1 -0
  21. package/dist/cache_container.js +42 -0
  22. package/dist/cache_container.js.map +1 -0
  23. package/dist/configuration.d.ts +150 -0
  24. package/dist/configuration.d.ts.map +1 -0
  25. package/dist/configuration.js +284 -0
  26. package/dist/configuration.js.map +1 -0
  27. package/dist/constants.d.ts +3 -0
  28. package/dist/constants.d.ts.map +1 -0
  29. package/dist/constants.js +6 -0
  30. package/dist/constants.js.map +1 -0
  31. package/dist/crawlers/crawler_commons.d.ts +23 -0
  32. package/dist/crawlers/crawler_commons.d.ts.map +1 -0
  33. package/dist/crawlers/crawler_commons.js +3 -0
  34. package/dist/crawlers/crawler_commons.js.map +1 -0
  35. package/dist/crawlers/crawler_extension.d.ts +11 -0
  36. package/dist/crawlers/crawler_extension.d.ts.map +1 -0
  37. package/dist/crawlers/crawler_extension.js +30 -0
  38. package/dist/crawlers/crawler_extension.js.map +1 -0
  39. package/dist/crawlers/crawler_utils.d.ts +25 -0
  40. package/dist/crawlers/crawler_utils.d.ts.map +1 -0
  41. package/dist/crawlers/crawler_utils.js +72 -0
  42. package/dist/crawlers/crawler_utils.js.map +1 -0
  43. package/dist/crawlers/index.d.ts +5 -0
  44. package/dist/crawlers/index.d.ts.map +1 -0
  45. package/dist/crawlers/index.js +8 -0
  46. package/dist/crawlers/index.js.map +1 -0
  47. package/dist/crawlers/statistics.d.ts +147 -0
  48. package/dist/crawlers/statistics.d.ts.map +1 -0
  49. package/dist/crawlers/statistics.js +360 -0
  50. package/dist/crawlers/statistics.js.map +1 -0
  51. package/dist/enqueue_links/enqueue_links.d.ts +138 -0
  52. package/dist/enqueue_links/enqueue_links.d.ts.map +1 -0
  53. package/dist/enqueue_links/enqueue_links.js +123 -0
  54. package/dist/enqueue_links/enqueue_links.js.map +1 -0
  55. package/dist/enqueue_links/index.d.ts +3 -0
  56. package/dist/enqueue_links/index.d.ts.map +1 -0
  57. package/dist/enqueue_links/index.js +6 -0
  58. package/dist/enqueue_links/index.js.map +1 -0
  59. package/dist/enqueue_links/shared.d.ts +60 -0
  60. package/dist/enqueue_links/shared.d.ts.map +1 -0
  61. package/dist/enqueue_links/shared.js +148 -0
  62. package/dist/enqueue_links/shared.js.map +1 -0
  63. package/dist/errors.d.ts +8 -0
  64. package/dist/errors.d.ts.map +1 -0
  65. package/dist/errors.js +12 -0
  66. package/dist/errors.js.map +1 -0
  67. package/dist/events/event_manager.d.ts +41 -0
  68. package/dist/events/event_manager.d.ts.map +1 -0
  69. package/dist/events/event_manager.js +103 -0
  70. package/dist/events/event_manager.js.map +1 -0
  71. package/dist/events/index.d.ts +3 -0
  72. package/dist/events/index.d.ts.map +1 -0
  73. package/dist/events/index.js +6 -0
  74. package/dist/events/index.js.map +1 -0
  75. package/dist/events/local_event_manager.d.ts +32 -0
  76. package/dist/events/local_event_manager.d.ts.map +1 -0
  77. package/dist/events/local_event_manager.js +114 -0
  78. package/dist/events/local_event_manager.js.map +1 -0
  79. package/dist/index.d.ts +14 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +17 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/index.mjs +63 -0
  84. package/dist/log.d.ts +3 -0
  85. package/dist/log.d.ts.map +1 -0
  86. package/dist/log.js +12 -0
  87. package/dist/log.js.map +1 -0
  88. package/dist/package.json +82 -0
  89. package/dist/proxy_configuration.d.ts +181 -0
  90. package/dist/proxy_configuration.d.ts.map +1 -0
  91. package/dist/proxy_configuration.js +209 -0
  92. package/dist/proxy_configuration.js.map +1 -0
  93. package/dist/request.d.ts +174 -0
  94. package/dist/request.d.ts.map +1 -0
  95. package/dist/request.js +270 -0
  96. package/dist/request.js.map +1 -0
  97. package/dist/serialization.d.ts +33 -0
  98. package/dist/serialization.d.ts.map +1 -0
  99. package/dist/serialization.js +146 -0
  100. package/dist/serialization.js.map +1 -0
  101. package/dist/session_pool/errors.d.ts +8 -0
  102. package/dist/session_pool/errors.d.ts.map +1 -0
  103. package/dist/session_pool/errors.js +20 -0
  104. package/dist/session_pool/errors.js.map +1 -0
  105. package/dist/session_pool/events.d.ts +3 -0
  106. package/dist/session_pool/events.d.ts.map +1 -0
  107. package/dist/session_pool/events.js +6 -0
  108. package/dist/session_pool/events.js.map +1 -0
  109. package/dist/session_pool/index.d.ts +6 -0
  110. package/dist/session_pool/index.d.ts.map +1 -0
  111. package/dist/session_pool/index.js +9 -0
  112. package/dist/session_pool/index.js.map +1 -0
  113. package/dist/session_pool/session.d.ts +212 -0
  114. package/dist/session_pool/session.d.ts.map +1 -0
  115. package/dist/session_pool/session.js +360 -0
  116. package/dist/session_pool/session.js.map +1 -0
  117. package/dist/session_pool/session_pool.d.ts +222 -0
  118. package/dist/session_pool/session_pool.d.ts.map +1 -0
  119. package/dist/session_pool/session_pool.js +389 -0
  120. package/dist/session_pool/session_pool.js.map +1 -0
  121. package/dist/session_pool/session_utils.d.ts +9 -0
  122. package/dist/session_pool/session_utils.d.ts.map +1 -0
  123. package/dist/session_pool/session_utils.js +19 -0
  124. package/dist/session_pool/session_utils.js.map +1 -0
  125. package/dist/storages/dataset.d.ts +358 -0
  126. package/dist/storages/dataset.d.ts.map +1 -0
  127. package/dist/storages/dataset.js +415 -0
  128. package/dist/storages/dataset.js.map +1 -0
  129. package/dist/storages/index.d.ts +7 -0
  130. package/dist/storages/index.d.ts.map +1 -0
  131. package/dist/storages/index.js +11 -0
  132. package/dist/storages/index.js.map +1 -0
  133. package/dist/storages/key_value_store.d.ts +242 -0
  134. package/dist/storages/key_value_store.d.ts.map +1 -0
  135. package/dist/storages/key_value_store.js +319 -0
  136. package/dist/storages/key_value_store.js.map +1 -0
  137. package/dist/storages/request_list.d.ts +461 -0
  138. package/dist/storages/request_list.d.ts.map +1 -0
  139. package/dist/storages/request_list.js +715 -0
  140. package/dist/storages/request_list.js.map +1 -0
  141. package/dist/storages/request_queue.d.ts +312 -0
  142. package/dist/storages/request_queue.d.ts.map +1 -0
  143. package/dist/storages/request_queue.js +708 -0
  144. package/dist/storages/request_queue.js.map +1 -0
  145. package/dist/storages/storage.d.ts +260 -0
  146. package/dist/storages/storage.d.ts.map +1 -0
  147. package/dist/storages/storage.js +3 -0
  148. package/dist/storages/storage.js.map +1 -0
  149. package/dist/storages/storage_manager.d.ts +40 -0
  150. package/dist/storages/storage_manager.d.ts.map +1 -0
  151. package/dist/storages/storage_manager.js +119 -0
  152. package/dist/storages/storage_manager.js.map +1 -0
  153. package/dist/tsconfig.build.tsbuildinfo +1 -0
  154. package/dist/typedefs.d.ts +12 -0
  155. package/dist/typedefs.d.ts.map +1 -0
  156. package/dist/typedefs.js +15 -0
  157. package/dist/typedefs.js.map +1 -0
  158. package/dist/validators.d.ts +21 -0
  159. package/dist/validators.d.ts.map +1 -0
  160. package/dist/validators.js +26 -0
  161. package/dist/validators.js.map +1 -0
  162. package/package.json +11 -10
@@ -0,0 +1,242 @@
1
+ import { Configuration } from '../configuration';
2
+ import { Awaitable } from '../typedefs';
3
+ import { StorageManagerOptions } from './storage_manager';
4
+ import { StorageClient } from './storage';
5
+ /**
6
+ * Helper function to possibly stringify value if options.contentType is not set.
7
+ *
8
+ * @ignore
9
+ */
10
+ export declare const maybeStringify: <T>(value: T, options: {
11
+ contentType?: string;
12
+ }) => T;
13
+ /**
14
+ * The `KeyValueStore` class represents a key-value store, a simple data storage that is used
15
+ * for saving and reading data records or files. Each data record is
16
+ * represented by a unique key and associated with a MIME content type. Key-value stores are ideal
17
+ * for saving screenshots, actor inputs and outputs, web pages, PDFs or to persist the state of crawlers.
18
+ *
19
+ * Do not instantiate this class directly, use the
20
+ * {@link KeyValueStore.open} function instead.
21
+ *
22
+ * Each actor run is associated with a default key-value store, which is created exclusively
23
+ * for the run. By convention, the actor input and output are stored into the
24
+ * default key-value store under the `INPUT` and `OUTPUT` key, respectively.
25
+ * Typically, input and output are JSON files, although it can be any other format.
26
+ * To access the default key-value store directly, you can use the
27
+ * {@link Actor.getValue} and {@link Actor.setValue} convenience functions.
28
+ *
29
+ * To access the input, you can also use the {@link Actor.getInput} convenience function.
30
+ *
31
+ * `KeyValueStore` stores its data either on local disk or in the Apify cloud,
32
+ * depending on whether the [`APIFY_IS_AT_HOME`](/docs/guides/environment-variables#apify_is_at_home)
33
+ * environment variable is set.
34
+ *
35
+ * If the `APIFY_LOCAL_STORAGE_DIR` environment variable is set, the data is stored in
36
+ * the local directory in the following files:
37
+ * ```
38
+ * {APIFY_LOCAL_STORAGE_DIR}/key_value_stores/{STORE_ID}/{INDEX}.{EXT}
39
+ * ```
40
+ * Note that `{STORE_ID}` is the name or ID of the key-value store. The default key-value store has ID: `default`,
41
+ * unless you override it by setting the `APIFY_DEFAULT_KEY_VALUE_STORE_ID` environment variable.
42
+ * The `{KEY}` is the key of the record and `{EXT}` corresponds to the MIME content type of the data value.
43
+ *
44
+ * If the [`APIFY_TOKEN`](/docs/guides/environment-variables#apify_token) environment variable is set but
45
+ * [`APIFY_LOCAL_STORAGE_DIR`](/docs/guides/environment-variables#apify_local_storage_dir) not,
46
+ * the data is stored in the [Apify Key-value store](https://docs.apify.com/storage/key-value-store)
47
+ * cloud storage. Note that you can force usage of the cloud storage also by passing the `forceCloud`
48
+ * option to {@link KeyValueStore.open} function, even if the
49
+ * [`APIFY_LOCAL_STORAGE_DIR`](/docs/guides/environment-variables#apify_local_storage_dir) variable is set.
50
+ *
51
+ * **Example usage:**
52
+ *
53
+ * ```javascript
54
+ * // Get actor input from the default key-value store.
55
+ * const input = await Actor.getInput();
56
+ * // Get some value from the default key-value store.
57
+ * const otherValue = await Actor.getValue('my-key');
58
+ *
59
+ * // Write actor output to the default key-value store.
60
+ * await Actor.setValue('OUTPUT', { myResult: 123 });
61
+ *
62
+ * // Open a named key-value store
63
+ * const store = await KeyValueStore.open('some-name');
64
+ *
65
+ * // Write a record. JavaScript object is automatically converted to JSON,
66
+ * // strings and binary buffers are stored as they are
67
+ * await store.setValue('some-key', { foo: 'bar' });
68
+ *
69
+ * // Read a record. Note that JSON is automatically parsed to a JavaScript object,
70
+ * // text data returned as a string and other data is returned as binary buffer
71
+ * const value = await store.getValue('some-key');
72
+ *
73
+ * // Drop (delete) the store
74
+ * await store.drop();
75
+ * ```
76
+ * @category Result Stores
77
+ */
78
+ export declare class KeyValueStore {
79
+ readonly config: Configuration;
80
+ readonly id: string;
81
+ readonly name?: string;
82
+ private client;
83
+ /**
84
+ * @internal
85
+ */
86
+ constructor(options: KeyValueStoreOptions, config?: Configuration);
87
+ /**
88
+ * Gets a value from the key-value store.
89
+ *
90
+ * The function returns a `Promise` that resolves to the record value,
91
+ * whose JavaScript type depends on the MIME content type of the record.
92
+ * Records with the `application/json`
93
+ * content type are automatically parsed and returned as a JavaScript object.
94
+ * Similarly, records with `text/plain` content types are returned as a string.
95
+ * For all other content types, the value is returned as a raw
96
+ * [`Buffer`](https://nodejs.org/api/buffer.html) instance.
97
+ *
98
+ * If the record does not exist, the function resolves to `null`.
99
+ *
100
+ * To save or delete a value in the key-value store, use the
101
+ * {@link KeyValueStore.setValue} function.
102
+ *
103
+ * **Example usage:**
104
+ *
105
+ * ```javascript
106
+ * const store = await KeyValueStore.open();
107
+ * const buffer = await store.getValue('screenshot1.png');
108
+ * ```
109
+ * @param key
110
+ * Unique key of the record. It can be at most 256 characters long and only consist
111
+ * of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
112
+ * @returns
113
+ * Returns a promise that resolves to an object, string
114
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
115
+ * on the MIME content type of the record.
116
+ */
117
+ getValue<T = unknown>(key: string): Promise<T | null>;
118
+ /**
119
+ * Saves or deletes a record in the key-value store.
120
+ * The function returns a promise that resolves once the record has been saved or deleted.
121
+ *
122
+ * **Example usage:**
123
+ *
124
+ * ```javascript
125
+ * const store = await KeyValueStore.open();
126
+ * await store.setValue('OUTPUT', { foo: 'bar' });
127
+ * ```
128
+ *
129
+ * Beware that the key can be at most 256 characters long and only contain the following characters: `a-zA-Z0-9!-_.'()`
130
+ *
131
+ * By default, `value` is converted to JSON and stored with the
132
+ * `application/json; charset=utf-8` MIME content type.
133
+ * To store the value with another content type, pass it in the options as follows:
134
+ * ```javascript
135
+ * const store = await KeyValueStore.open('my-text-store');
136
+ * await store.setValue('RESULTS', 'my text data', { contentType: 'text/plain' });
137
+ * ```
138
+ * If you set custom content type, `value` must be either a string or
139
+ * [`Buffer`](https://nodejs.org/api/buffer.html), otherwise an error will be thrown.
140
+ *
141
+ * If `value` is `null`, the record is deleted instead. Note that the `setValue()` function succeeds
142
+ * regardless whether the record existed or not.
143
+ *
144
+ * To retrieve a value from the key-value store, use the
145
+ * {@link KeyValueStore.getValue} function.
146
+ *
147
+ * **IMPORTANT:** Always make sure to use the `await` keyword when calling `setValue()`,
148
+ * otherwise the actor process might finish before the value is stored!
149
+ *
150
+ * @param key
151
+ * Unique key of the record. It can be at most 256 characters long and only consist
152
+ * of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
153
+ * @param value
154
+ * Record data, which can be one of the following values:
155
+ * - If `null`, the record in the key-value store is deleted.
156
+ * - If no `options.contentType` is specified, `value` can be any JavaScript object and it will be stringified to JSON.
157
+ * - If `options.contentType` is set, `value` is taken as is and it must be a `String` or [`Buffer`](https://nodejs.org/api/buffer.html).
158
+ * For any other value an error will be thrown.
159
+ * @param [options] Record options.
160
+ */
161
+ setValue<T>(key: string, value: T | null, options?: RecordOptions): Promise<void>;
162
+ /**
163
+ * Removes the key-value store either from the Apify cloud storage or from the local directory,
164
+ * depending on the mode of operation.
165
+ */
166
+ drop(): Promise<void>;
167
+ /**
168
+ * Returns a URL for the given key that may be used to publicly
169
+ * access the value in the remote key-value store.
170
+ */
171
+ getPublicUrl(key: string): string;
172
+ /**
173
+ * Iterates over key-value store keys, yielding each in turn to an `iteratee` function.
174
+ * Each invocation of `iteratee` is called with three arguments: `(key, index, info)`, where `key`
175
+ * is the record key, `index` is a zero-based index of the key in the current iteration
176
+ * (regardless of `options.exclusiveStartKey`) and `info` is an object that contains a single property `size`
177
+ * indicating size of the record in bytes.
178
+ *
179
+ * If the `iteratee` function returns a Promise then it is awaited before the next call.
180
+ * If it throws an error, the iteration is aborted and the `forEachKey` function throws the error.
181
+ *
182
+ * **Example usage**
183
+ * ```javascript
184
+ * const keyValueStore = await KeyValueStore.open();
185
+ * await keyValueStore.forEachKey(async (key, index, info) => {
186
+ * console.log(`Key at ${index}: ${key} has size ${info.size}`);
187
+ * });
188
+ * ```
189
+ *
190
+ * @param iteratee A function that is called for every key in the key-value store.
191
+ * @param [options] All `forEachKey()` parameters.
192
+ */
193
+ forEachKey(iteratee: KeyConsumer, options?: KeyValueStoreIteratorOptions): Promise<void>;
194
+ private _forEachKey;
195
+ /**
196
+ * Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
197
+ *
198
+ * Key-value stores are used to store records or files, along with their MIME content type.
199
+ * The records are stored and retrieved using a unique key.
200
+ * The actual data is stored either on a local filesystem or in the Apify cloud.
201
+ *
202
+ * For more details and code examples, see the {@link KeyValueStore} class.
203
+ *
204
+ * @param [storeIdOrName]
205
+ * ID or name of the key-value store to be opened. If `null` or `undefined`,
206
+ * the function returns the default key-value store associated with the actor run.
207
+ * @param [options] Storage manager options.
208
+ */
209
+ static open(storeIdOrName?: string | null, options?: StorageManagerOptions): Promise<KeyValueStore>;
210
+ }
211
+ /**
212
+ * User-function used in the {@link KeyValueStore.forEachKey} method.
213
+ */
214
+ export interface KeyConsumer {
215
+ /**
216
+ * @param key Current {KeyValue} key being processed.
217
+ * @param index Position of the current key in {@link KeyValueStore}.
218
+ * @param info Information about the current {@link KeyValueStore} entry.
219
+ * @param info.size Size of the value associated with the current key in bytes.
220
+ */
221
+ (key: string, index: number, info: {
222
+ size: number;
223
+ }): Awaitable<void>;
224
+ }
225
+ export interface KeyValueStoreOptions {
226
+ id: string;
227
+ name?: string;
228
+ client: StorageClient;
229
+ }
230
+ export interface RecordOptions {
231
+ /**
232
+ * Specifies a custom MIME content type of the record.
233
+ */
234
+ contentType?: string;
235
+ }
236
+ export interface KeyValueStoreIteratorOptions {
237
+ /**
238
+ * All keys up to this one (including) are skipped from the result.
239
+ */
240
+ exclusiveStartKey?: string;
241
+ }
242
+ //# sourceMappingURL=key_value_store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key_value_store.d.ts","sourceRoot":"","sources":["../../src/storages/key_value_store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AACpD,OAAO,EAAkB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,cAA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AE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;CACzE;AAED,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeyValueStore = exports.maybeStringify = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const consts_1 = require("@apify/consts");
6
+ const utilities_1 = require("@apify/utilities");
7
+ const ow_1 = tslib_1.__importStar(require("ow"));
8
+ const configuration_1 = require("../configuration");
9
+ const storage_manager_1 = require("./storage_manager");
10
+ /**
11
+ * Helper function to possibly stringify value if options.contentType is not set.
12
+ *
13
+ * @ignore
14
+ */
15
+ const maybeStringify = (value, options) => {
16
+ // If contentType is missing, value will be stringified to JSON
17
+ if (options.contentType === null || options.contentType === undefined) {
18
+ options.contentType = 'application/json; charset=utf-8';
19
+ try {
20
+ // Format JSON to simplify debugging, the overheads with compression is negligible
21
+ value = (0, utilities_1.jsonStringifyExtended)(value, null, 2);
22
+ }
23
+ catch (e) {
24
+ const error = e;
25
+ // Give more meaningful error message
26
+ if (error.message?.indexOf('Invalid string length') >= 0) {
27
+ error.message = 'Object is too large';
28
+ }
29
+ throw new Error(`The "value" parameter cannot be stringified to JSON: ${error.message}`);
30
+ }
31
+ if (value === undefined) {
32
+ throw new Error('The "value" parameter was stringified to JSON and returned undefined. '
33
+ + 'Make sure you\'re not trying to stringify an undefined value.');
34
+ }
35
+ }
36
+ return value;
37
+ };
38
+ exports.maybeStringify = maybeStringify;
39
+ /**
40
+ * The `KeyValueStore` class represents a key-value store, a simple data storage that is used
41
+ * for saving and reading data records or files. Each data record is
42
+ * represented by a unique key and associated with a MIME content type. Key-value stores are ideal
43
+ * for saving screenshots, actor inputs and outputs, web pages, PDFs or to persist the state of crawlers.
44
+ *
45
+ * Do not instantiate this class directly, use the
46
+ * {@link KeyValueStore.open} function instead.
47
+ *
48
+ * Each actor run is associated with a default key-value store, which is created exclusively
49
+ * for the run. By convention, the actor input and output are stored into the
50
+ * default key-value store under the `INPUT` and `OUTPUT` key, respectively.
51
+ * Typically, input and output are JSON files, although it can be any other format.
52
+ * To access the default key-value store directly, you can use the
53
+ * {@link Actor.getValue} and {@link Actor.setValue} convenience functions.
54
+ *
55
+ * To access the input, you can also use the {@link Actor.getInput} convenience function.
56
+ *
57
+ * `KeyValueStore` stores its data either on local disk or in the Apify cloud,
58
+ * depending on whether the [`APIFY_IS_AT_HOME`](/docs/guides/environment-variables#apify_is_at_home)
59
+ * environment variable is set.
60
+ *
61
+ * If the `APIFY_LOCAL_STORAGE_DIR` environment variable is set, the data is stored in
62
+ * the local directory in the following files:
63
+ * ```
64
+ * {APIFY_LOCAL_STORAGE_DIR}/key_value_stores/{STORE_ID}/{INDEX}.{EXT}
65
+ * ```
66
+ * Note that `{STORE_ID}` is the name or ID of the key-value store. The default key-value store has ID: `default`,
67
+ * unless you override it by setting the `APIFY_DEFAULT_KEY_VALUE_STORE_ID` environment variable.
68
+ * The `{KEY}` is the key of the record and `{EXT}` corresponds to the MIME content type of the data value.
69
+ *
70
+ * If the [`APIFY_TOKEN`](/docs/guides/environment-variables#apify_token) environment variable is set but
71
+ * [`APIFY_LOCAL_STORAGE_DIR`](/docs/guides/environment-variables#apify_local_storage_dir) not,
72
+ * the data is stored in the [Apify Key-value store](https://docs.apify.com/storage/key-value-store)
73
+ * cloud storage. Note that you can force usage of the cloud storage also by passing the `forceCloud`
74
+ * option to {@link KeyValueStore.open} function, even if the
75
+ * [`APIFY_LOCAL_STORAGE_DIR`](/docs/guides/environment-variables#apify_local_storage_dir) variable is set.
76
+ *
77
+ * **Example usage:**
78
+ *
79
+ * ```javascript
80
+ * // Get actor input from the default key-value store.
81
+ * const input = await Actor.getInput();
82
+ * // Get some value from the default key-value store.
83
+ * const otherValue = await Actor.getValue('my-key');
84
+ *
85
+ * // Write actor output to the default key-value store.
86
+ * await Actor.setValue('OUTPUT', { myResult: 123 });
87
+ *
88
+ * // Open a named key-value store
89
+ * const store = await KeyValueStore.open('some-name');
90
+ *
91
+ * // Write a record. JavaScript object is automatically converted to JSON,
92
+ * // strings and binary buffers are stored as they are
93
+ * await store.setValue('some-key', { foo: 'bar' });
94
+ *
95
+ * // Read a record. Note that JSON is automatically parsed to a JavaScript object,
96
+ * // text data returned as a string and other data is returned as binary buffer
97
+ * const value = await store.getValue('some-key');
98
+ *
99
+ * // Drop (delete) the store
100
+ * await store.drop();
101
+ * ```
102
+ * @category Result Stores
103
+ */
104
+ class KeyValueStore {
105
+ /**
106
+ * @internal
107
+ */
108
+ constructor(options, config = configuration_1.Configuration.getGlobalConfig()) {
109
+ Object.defineProperty(this, "config", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: config
114
+ });
115
+ Object.defineProperty(this, "id", {
116
+ enumerable: true,
117
+ configurable: true,
118
+ writable: true,
119
+ value: void 0
120
+ });
121
+ Object.defineProperty(this, "name", {
122
+ enumerable: true,
123
+ configurable: true,
124
+ writable: true,
125
+ value: void 0
126
+ });
127
+ Object.defineProperty(this, "client", {
128
+ enumerable: true,
129
+ configurable: true,
130
+ writable: true,
131
+ value: void 0
132
+ });
133
+ this.id = options.id;
134
+ this.name = options.name;
135
+ this.client = options.client.keyValueStore(this.id);
136
+ }
137
+ /**
138
+ * Gets a value from the key-value store.
139
+ *
140
+ * The function returns a `Promise` that resolves to the record value,
141
+ * whose JavaScript type depends on the MIME content type of the record.
142
+ * Records with the `application/json`
143
+ * content type are automatically parsed and returned as a JavaScript object.
144
+ * Similarly, records with `text/plain` content types are returned as a string.
145
+ * For all other content types, the value is returned as a raw
146
+ * [`Buffer`](https://nodejs.org/api/buffer.html) instance.
147
+ *
148
+ * If the record does not exist, the function resolves to `null`.
149
+ *
150
+ * To save or delete a value in the key-value store, use the
151
+ * {@link KeyValueStore.setValue} function.
152
+ *
153
+ * **Example usage:**
154
+ *
155
+ * ```javascript
156
+ * const store = await KeyValueStore.open();
157
+ * const buffer = await store.getValue('screenshot1.png');
158
+ * ```
159
+ * @param key
160
+ * Unique key of the record. It can be at most 256 characters long and only consist
161
+ * of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
162
+ * @returns
163
+ * Returns a promise that resolves to an object, string
164
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
165
+ * on the MIME content type of the record.
166
+ */
167
+ async getValue(key) {
168
+ (0, ow_1.default)(key, ow_1.default.string.nonEmpty);
169
+ const record = await this.client.getRecord(key);
170
+ return record?.value ?? null;
171
+ }
172
+ /**
173
+ * Saves or deletes a record in the key-value store.
174
+ * The function returns a promise that resolves once the record has been saved or deleted.
175
+ *
176
+ * **Example usage:**
177
+ *
178
+ * ```javascript
179
+ * const store = await KeyValueStore.open();
180
+ * await store.setValue('OUTPUT', { foo: 'bar' });
181
+ * ```
182
+ *
183
+ * Beware that the key can be at most 256 characters long and only contain the following characters: `a-zA-Z0-9!-_.'()`
184
+ *
185
+ * By default, `value` is converted to JSON and stored with the
186
+ * `application/json; charset=utf-8` MIME content type.
187
+ * To store the value with another content type, pass it in the options as follows:
188
+ * ```javascript
189
+ * const store = await KeyValueStore.open('my-text-store');
190
+ * await store.setValue('RESULTS', 'my text data', { contentType: 'text/plain' });
191
+ * ```
192
+ * If you set custom content type, `value` must be either a string or
193
+ * [`Buffer`](https://nodejs.org/api/buffer.html), otherwise an error will be thrown.
194
+ *
195
+ * If `value` is `null`, the record is deleted instead. Note that the `setValue()` function succeeds
196
+ * regardless whether the record existed or not.
197
+ *
198
+ * To retrieve a value from the key-value store, use the
199
+ * {@link KeyValueStore.getValue} function.
200
+ *
201
+ * **IMPORTANT:** Always make sure to use the `await` keyword when calling `setValue()`,
202
+ * otherwise the actor process might finish before the value is stored!
203
+ *
204
+ * @param key
205
+ * Unique key of the record. It can be at most 256 characters long and only consist
206
+ * of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
207
+ * @param value
208
+ * Record data, which can be one of the following values:
209
+ * - If `null`, the record in the key-value store is deleted.
210
+ * - If no `options.contentType` is specified, `value` can be any JavaScript object and it will be stringified to JSON.
211
+ * - If `options.contentType` is set, `value` is taken as is and it must be a `String` or [`Buffer`](https://nodejs.org/api/buffer.html).
212
+ * For any other value an error will be thrown.
213
+ * @param [options] Record options.
214
+ */
215
+ async setValue(key, value, options = {}) {
216
+ (0, ow_1.default)(key, 'key', ow_1.default.string.nonEmpty);
217
+ (0, ow_1.default)(key, ow_1.default.string.validate((k) => ({
218
+ validator: ow_1.default.isValid(k, ow_1.default.string.matches(consts_1.KEY_VALUE_STORE_KEY_REGEX)),
219
+ message: 'The "key" argument must be at most 256 characters long and only contain the following characters: a-zA-Z0-9!-_.\'()',
220
+ })));
221
+ if (options.contentType && !ow_1.default.isValid(value, ow_1.default.any(ow_1.default.string, ow_1.default.buffer))) {
222
+ throw new ow_1.ArgumentError('The "value" parameter must be a String or Buffer when "options.contentType" is specified.', this.setValue);
223
+ }
224
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
225
+ contentType: ow_1.default.optional.string.nonEmpty,
226
+ }));
227
+ // Make copy of options, don't update what user passed.
228
+ const optionsCopy = { ...options };
229
+ // In this case delete the record.
230
+ if (value === null)
231
+ return this.client.deleteRecord(key);
232
+ value = (0, exports.maybeStringify)(value, optionsCopy);
233
+ return this.client.setRecord({
234
+ key,
235
+ value,
236
+ contentType: optionsCopy.contentType,
237
+ });
238
+ }
239
+ /**
240
+ * Removes the key-value store either from the Apify cloud storage or from the local directory,
241
+ * depending on the mode of operation.
242
+ */
243
+ async drop() {
244
+ await this.client.delete();
245
+ const manager = new storage_manager_1.StorageManager(KeyValueStore, this.config);
246
+ manager.closeStorage(this);
247
+ }
248
+ /**
249
+ * Returns a URL for the given key that may be used to publicly
250
+ * access the value in the remote key-value store.
251
+ */
252
+ getPublicUrl(key) {
253
+ // FIXME how should this work? should we remove this method or provide a way to configure the base url?
254
+ return `https://api.apify.com/v2/key-value-stores/${this.id}/records/${key}`;
255
+ }
256
+ /**
257
+ * Iterates over key-value store keys, yielding each in turn to an `iteratee` function.
258
+ * Each invocation of `iteratee` is called with three arguments: `(key, index, info)`, where `key`
259
+ * is the record key, `index` is a zero-based index of the key in the current iteration
260
+ * (regardless of `options.exclusiveStartKey`) and `info` is an object that contains a single property `size`
261
+ * indicating size of the record in bytes.
262
+ *
263
+ * If the `iteratee` function returns a Promise then it is awaited before the next call.
264
+ * If it throws an error, the iteration is aborted and the `forEachKey` function throws the error.
265
+ *
266
+ * **Example usage**
267
+ * ```javascript
268
+ * const keyValueStore = await KeyValueStore.open();
269
+ * await keyValueStore.forEachKey(async (key, index, info) => {
270
+ * console.log(`Key at ${index}: ${key} has size ${info.size}`);
271
+ * });
272
+ * ```
273
+ *
274
+ * @param iteratee A function that is called for every key in the key-value store.
275
+ * @param [options] All `forEachKey()` parameters.
276
+ */
277
+ async forEachKey(iteratee, options = {}) {
278
+ return this._forEachKey(iteratee, options);
279
+ }
280
+ async _forEachKey(iteratee, options = {}, index = 0) {
281
+ const { exclusiveStartKey } = options;
282
+ (0, ow_1.default)(iteratee, ow_1.default.function);
283
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
284
+ exclusiveStartKey: ow_1.default.optional.string,
285
+ }));
286
+ const response = await this.client.listKeys({ exclusiveStartKey });
287
+ const { nextExclusiveStartKey, isTruncated, items } = response;
288
+ for (const item of items) {
289
+ await iteratee(item.key, index++, { size: item.size });
290
+ }
291
+ return isTruncated
292
+ ? this._forEachKey(iteratee, { exclusiveStartKey: nextExclusiveStartKey }, index)
293
+ : undefined; // [].forEach() returns undefined.
294
+ }
295
+ /**
296
+ * Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
297
+ *
298
+ * Key-value stores are used to store records or files, along with their MIME content type.
299
+ * The records are stored and retrieved using a unique key.
300
+ * The actual data is stored either on a local filesystem or in the Apify cloud.
301
+ *
302
+ * For more details and code examples, see the {@link KeyValueStore} class.
303
+ *
304
+ * @param [storeIdOrName]
305
+ * ID or name of the key-value store to be opened. If `null` or `undefined`,
306
+ * the function returns the default key-value store associated with the actor run.
307
+ * @param [options] Storage manager options.
308
+ */
309
+ static async open(storeIdOrName, options = {}) {
310
+ (0, ow_1.default)(storeIdOrName, ow_1.default.optional.string);
311
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
312
+ config: ow_1.default.optional.object.instanceOf(configuration_1.Configuration),
313
+ }));
314
+ const manager = new storage_manager_1.StorageManager(KeyValueStore, options.config);
315
+ return manager.openStorage(storeIdOrName);
316
+ }
317
+ }
318
+ exports.KeyValueStore = KeyValueStore;
319
+ //# sourceMappingURL=key_value_store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key_value_store.js","sourceRoot":"","sources":["../../src/storages/key_value_store.ts"],"names":[],"mappings":";;;;AAAA,0CAA0D;AAC1D,gDAAyD;AACzD,iDAAuC;AACvC,oDAAiD;AAEjD,uDAA0E;AAG1E;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAI,KAAQ,EAAE,OAAiC,EAAE,EAAE;IAC7E,+DAA+D;IAC/D,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE;QACnE,OAAO,CAAC,WAAW,GAAG,iCAAiC,CAAC;QAExD,IAAI;YACA,kFAAkF;YAClF,KAAK,GAAG,IAAA,iCAAqB,EAAC,KAAmB,EAAE,IAAI,EAAE,CAAC,CAAiB,CAAC;SAC/E;QAAC,OAAO,CAAC,EAAE;YACR,MA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