MCPcopy Create free account
hub / github.com/apache/maka / decodeUsageRange

Function decodeUsageRange

packages/runtime-host/src/protocol/usage-pricing.ts:669–676  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

667}
668
669function decodeUsageRange(value: unknown): UsageQuery['range'] {
670 if (value === '24h' || value === '7d' || value === '30d' || value === 'all') return value;
671 const range = requireExactRecord(value, 'usage range', ['from', 'to']);
672 const from = nonnegativeFinite(range.from, 'usage range from');
673 const to = nonnegativeFinite(range.to, 'usage range to');
674 if (from > to) throw invalidProtocolFrame('Invalid usage range');
675 return { from, to };
676}
677
678function decodeUsageStatus(value: unknown): NonNullable<UsageQuery['status']> {
679 if (value === 'success' || value === 'error' || value === 'aborted' || value === 'all') {

Callers 2

decodeLlmUsageQueryFunction · 0.85
decodeToolUsageQueryFunction · 0.85

Calls 3

nonnegativeFiniteFunction · 0.85
invalidProtocolFrameFunction · 0.85
requireExactRecordFunction · 0.70

Tested by

no test coverage detected