apify 3.7.3-beta.77 → 3.7.3-beta.78

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.
@@ -12,6 +12,10 @@ export interface ChargeOptions {
12
12
  * @default 1
13
13
  */
14
14
  count?: number;
15
+ /**
16
+ * An idempotency key to prevent multiple unintended charges.
17
+ */
18
+ idempotencyKey?: string;
15
19
  }
16
20
  export interface ChargeResult {
17
21
  /**
@@ -101,7 +105,7 @@ export declare class ChargingManager {
101
105
  *
102
106
  * @param options The name of the event to charge for and the number of events to be charged.
103
107
  */
104
- charge({ eventName, count }: ChargeOptions): Promise<ChargeResult>;
108
+ charge({ eventName, count, idempotencyKey }: ChargeOptions): Promise<ChargeResult>;
105
109
  /**
106
110
  * Get the number of events with given name that the Actor has charged for so far.
107
111
  */
package/dist/charging.js CHANGED
@@ -245,7 +245,7 @@ class ChargingManager {
245
245
  *
246
246
  * @param options The name of the event to charge for and the number of events to be charged.
247
247
  */
248
- async charge({ eventName, count = 1 }) {
248
+ async charge({ eventName, count = 1, idempotencyKey }) {
249
249
  var _a;
250
250
  const calculateChargeableWithinLimit = () => Object.fromEntries(Object.keys(this.pricingInfo).map((name) => [name, this.calculateMaxEventChargeCountWithinLimit(name)]));
251
251
  if (!this.isPayPerEvent) {
@@ -300,7 +300,7 @@ class ChargingManager {
300
300
  // the platform handles them automatically based on dataset writes.
301
301
  }
302
302
  else if (this.pricingInfo[eventName] !== undefined) {
303
- await this.apifyClient.run(this.actorRunId).charge({ eventName, count: chargedCount });
303
+ await this.apifyClient.run(this.actorRunId).charge({ eventName, count: chargedCount, idempotencyKey });
304
304
  }
305
305
  else {
306
306
  log_1.default.warning(`Attempting to charge for an unknown event '${eventName}'`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify",
3
- "version": "3.7.3-beta.77",
3
+ "version": "3.7.3-beta.78",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=16.0.0"