Skip to content

Commit 8880295

Browse files
authored
fix: Add ActorRunPricingInfo type (#623)
1 parent 2fc5fec commit 8880295

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/resource_clients/actor.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ export interface ActorRun extends ActorRunListItem {
382382
gitBranchName?: string;
383383
usage?: ActorRunUsage;
384384
usageUsd?: ActorRunUsage;
385+
pricingInfo?: ActorRunPricingInfo;
386+
chargedEventCounts?: Record<string, number>;
385387
}
386388

387389
export interface ActorRunUsage {
@@ -428,6 +430,7 @@ export interface ActorRunOptions {
428430
timeoutSecs: number;
429431
memoryMbytes: number;
430432
diskMbytes: number;
433+
maxTotalChargeUsd?: number;
431434
}
432435

433436
export interface ActorBuildOptions {
@@ -459,3 +462,52 @@ export interface ActorDefinition {
459462
maxMemoryMbytes?: number;
460463
usesStandbyMode?: boolean;
461464
}
465+
466+
interface CommonActorPricingInfo {
467+
/** In [0, 1], fraction of pricePerUnitUsd that goes to Apify */
468+
apifyMarginPercentage: number;
469+
/** When this pricing info record has been created */
470+
createdAt: Date;
471+
/** Since when is this pricing info record effective for a given Actor */
472+
startedAt: Date;
473+
notifiedAboutFutureChangeAt?: Date;
474+
notifiedAboutChangeAt?: Date;
475+
reasonForChange?: string;
476+
}
477+
478+
export interface FreeActorPricingInfo extends CommonActorPricingInfo {
479+
pricingModel: 'FREE';
480+
}
481+
482+
export interface FlatPricePerMonthActorPricingInfo extends CommonActorPricingInfo {
483+
pricingModel: 'FLAT_PRICE_PER_MONTH';
484+
/** For how long this Actor can be used for free in trial period */
485+
trialMinutes?: number;
486+
/** Monthly flat price in USD */
487+
pricePerUnitUsd: number;
488+
}
489+
490+
export interface PricePerDatasetItemActorPricingInfo extends CommonActorPricingInfo {
491+
pricingModel: 'PRICE_PER_DATASET_ITEM';
492+
/** Name of the unit that is being charged */
493+
unitName?: string;
494+
pricePerUnitUsd: number;
495+
}
496+
497+
export interface ActorChargeEvent {
498+
eventPriceUsd: number;
499+
eventTitle: string;
500+
eventDescription?: string;
501+
}
502+
503+
export type ActorChargeEvents = Record<string, ActorChargeEvent>
504+
505+
export interface PricePerEventActorPricingInfo extends CommonActorPricingInfo {
506+
pricingModel: 'PAY_PER_EVENT';
507+
pricingPerEvent: {
508+
actorChargeEvents: ActorChargeEvents
509+
};
510+
minimalMaxTotalChargeUsd?: number;
511+
}
512+
513+
export type ActorRunPricingInfo = PricePerEventActorPricingInfo | PricePerDatasetItemActorPricingInfo | FlatPricePerMonthActorPricingInfo | FreeActorPricingInfo

0 commit comments

Comments
 (0)