Skip to content

fix: support tiered actor pricing types - #970

Open
AkhilTrivediX wants to merge 1 commit into
apify:masterfrom
AkhilTrivediX:agent/support-tiered-pricing-types
Open

fix: support tiered actor pricing types#970
AkhilTrivediX wants to merge 1 commit into
apify:masterfrom
AkhilTrivediX:agent/support-tiered-pricing-types

Conversation

@AkhilTrivediX

Copy link
Copy Markdown

Summary

  • add typed tier entries for pay-per-event and per-dataset-item Actor pricing
  • make flat price fields optional when the API returns tiered pricing instead
  • align required event and unit fields with the current API shape
  • cover a tiered-only pricing response with a focused regression test

Why

Tiered pricing responses do not include a flat price. The previous types required those absent fields and did not expose the tier maps, which made valid API responses difficult to model safely.

Closes #927

Validation

  • corepack pnpm build:node
  • corepack pnpm vitest run test/pricing_types.test.ts
  • corepack pnpm lint
  • corepack pnpm exec oxfmt --check src/resource_clients/actor.ts test/pricing_types.test.ts
  • git diff --check

@barjin barjin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @AkhilTrivediX , the changes look fine to me (looking at the API spec). Some of the optional -> required type changes could potentially be breaking, but these are required in the spec as well (so the changes are imo rather fixes).

The questions below are rather for other reviewers. Cheers!

cc @michael-apify could you please take a look from the billing POV?

Comment on lines +9 to +11
eventTieredPricingUsd: {
STARTER: { tieredEventPriceUsd: 0.01 },
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the tiered pricing, do we need all the tiers (STARTER, SILVER...) to be populated, or can we have a partial response like this?

vdusek added a commit that referenced this pull request Aug 3, 2026
The pricing union transfers wholesale. The spec models it as a `oneOf` with a `pricingModel`
discriminator and an OpenAPI 3.1 `const` per variant, so `openapi-typescript` emits literal
types and the published union keeps narrowing exactly as before -- no override needed. That also
brings tiered pricing in: `PricePerDatasetItemActorPricingInfo.tieredPricing` and
`ActorChargeEvent.eventTieredPricingUsd`, which overlaps what #970 adds by hand against master.

`ActorDefinition.output` is the one field of the definition the spec still omits, so it is the
whole of ActorDefinitionSpecGaps. Its `readme`, `input` and `changelog` keep the `| null` the
spec drops -- they are paths into the Actor's source tree and the API reports `null` for a file
that is absent, which is what the hand-written definition already recorded.

`Actor.versions` is excluded from the width guard on purpose. It re-points at the discriminated
`ActorVersion` union, which is deliberately narrower than the spec's flat `Version`, so the
one-directional assignability rule does not apply to it.

BREAKING CHANGE: Actor, ActorStats, ActorStandby, ActorDefaultRunOptions, ActorExampleRunInput,
ActorTaggedBuild, ActorTaggedBuilds, ActorDefinition, ActorChargeEvent, ActorCollectionListItem
and the four pricing-info shapes now follow the spec's nullability and optionality.
Actor.actorStandby loses the `& { isEnabled: boolean }` intersection and gains `| null`;
Actor.deploymentKey and actorPermissionLevel become optional; Actor.description, title,
seoTitle, seoDescription, isDeprecated, exampleRunInput and taggedBuilds gain `| null`; every
field of ActorStats becomes optional; every field of ActorDefaultRunOptions becomes optional;
ActorExampleRunInput.body and contentType become optional; ActorTaggedBuilds values may be
`null`; ActorDefinition.actorSpecification, name and version become optional;
ActorChargeEvent.eventDescription becomes required while eventPriceUsd becomes optional;
FlatPricePerMonthActorPricingInfo.trialMinutes and
PricePerDatasetItemActorPricingInfo.unitName become required, while the latter's
pricePerUnitUsd becomes optional. Newly exposed: Actor.pictureUrl, standbyUrl, notice,
isCritical, isGeneric, isSourceCodeHidden and hasNoDataset; ActorStats.actorReviewCount,
actorReviewRating, bookmarkCount and publicActorRunStats30Days;
ActorDefaultRunOptions.maxItems and forcePermissionLevel; ActorDefinition.defaultMemoryMbytes;
ActorTaggedBuild.buildNumberInt; ActorChargeEvent.isPrimaryEvent and isOneTimeEvent;
ActorCollectionListItem.title and stats; and the TieredPricingPerDatasetItem and
TieredPricingPerEvent types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pricing types are stale: missing tiered pay-per-event and tiered pay-per-result, plus a wrong required flag

4 participants