MonetizationOS Docs
Workflows ReferenceType Definitions

WorkflowConsumableMeter

type WorkflowConsumableMeter = {
  consume: (options?) => Promise<WorkflowMeterablePropertyEvaluation & WorkflowMeterablePropertyDefinition>;
  incrementCounter: (options?) => Promise<void>;
};

Properties

consume()

consume: (options?) => Promise<WorkflowMeterablePropertyEvaluation & WorkflowMeterablePropertyDefinition>;

Record consumption against a meter.

Parameters

ParameterTypeDescription
options?{ allowPartialConsumption?: boolean; units?: number; }-
options.allowPartialConsumption?booleanIf true, allows consuming fewer units than requested if insufficient units are available. Defaults to false. If true, check unrecordedUnitsInRequest after evaluation.
options.units?numberThe number of units to consume. Defaults to 1.

Returns

Promise<WorkflowMeterablePropertyEvaluation & WorkflowMeterablePropertyDefinition>

The updated meter evaluation after consumption.


incrementCounter()

incrementCounter: (options?) => Promise<void>;

Increment the counter backing this metered property. The counter will be incremented regardless of the usage already recorded against the meter.

Parameters

ParameterTypeDescription
options?{ units?: number; }-
options.units?numberThe number of units to increment by. Defaults to 1. Must be a non-zero positive integer if specified.

Returns

Promise<void>

Example

await features.myFeature.incrementCounter({ units: 1 })