@dork-labs/cloud-api 0.83.0 → 0.88.0
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.
- package/README.md +210 -22
- package/dist/billing.d.ts +225 -12
- package/dist/billing.d.ts.map +1 -1
- package/dist/billing.js +159 -36
- package/dist/billing.js.map +1 -1
- package/dist/connections.d.ts +19 -0
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +16 -0
- package/dist/connections.js.map +1 -1
- package/dist/display.d.ts +172 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +431 -0
- package/dist/display.js.map +1 -0
- package/dist/primitives.d.ts +63 -0
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +78 -1
- package/dist/primitives.js.map +1 -1
- package/dist/problem.d.ts +22 -0
- package/dist/problem.d.ts.map +1 -1
- package/dist/problem.js +26 -2
- package/dist/problem.js.map +1 -1
- package/dist/remote.d.ts +151 -1
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +163 -8
- package/dist/remote.js.map +1 -1
- package/dist/routes.d.ts +16 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +16 -1
- package/dist/routes.js.map +1 -1
- package/dist/seats.d.ts +43 -2
- package/dist/seats.d.ts.map +1 -1
- package/dist/seats.js +29 -3
- package/dist/seats.js.map +1 -1
- package/fixtures/v1/billing/balance-denominated.json +20 -0
- package/fixtures/v1/billing/entitlements-denominated.json +38 -0
- package/fixtures/v1/billing/nudge-denominated.json +13 -0
- package/fixtures/v1/billing/offers-empty.json +3 -0
- package/fixtures/v1/billing/offers.json +48 -0
- package/fixtures/v1/billing/price-list-cache-rates.json +19 -0
- package/fixtures/v1/billing/statement-itemised.json +35 -0
- package/fixtures/v1/billing/usage-denominated.json +25 -0
- package/fixtures/v1/index.json +20 -0
- package/fixtures/v1/problem/malformed-identifier.json +7 -0
- package/fixtures/v1/problem/malformed-request.json +7 -0
- package/fixtures/v1/remote/credential-with-hosts.json +8 -0
- package/fixtures/v1/remote/designation-current.json +5 -0
- package/fixtures/v1/remote/designation-none.json +5 -0
- package/fixtures/v1/remote/events-batch-spans.json +15 -0
- package/fixtures/v1/remote/events-batch.json +5 -0
- package/fixtures/v1/remote/status-open-with-instance.json +10 -0
- package/fixtures/v1/remote/usage-fresh.json +17 -0
- package/fixtures/v1/remote/usage.json +39 -0
- package/fixtures/v1/seats/agent-approved-claim.json +8 -0
- package/fixtures/v1/seats/agent-pending-claim.json +9 -0
- package/package.json +5 -1
package/dist/display.js
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@dork-labs/cloud-api/display` — one way to render a Cloud amount for a person.
|
|
3
|
+
*
|
|
4
|
+
* Every amount on the wire is an exact integer count of micro-units carried as
|
|
5
|
+
* a string, and a response names its unit in `denomination`: the currency the
|
|
6
|
+
* micro-units are millionths of, and how many micro-units one credit is. This
|
|
7
|
+
* module turns an amount and that denomination into text, by the kind of
|
|
8
|
+
* figure it is:
|
|
9
|
+
*
|
|
10
|
+
* - a **position** (what someone has or may still spend) rounds down to whole
|
|
11
|
+
* credits, so no page shows credit that cannot be spent;
|
|
12
|
+
* - a **charge** (what someone spent, was charged or is held for) rounds half
|
|
13
|
+
* away from zero to whole credits, and a non-zero amount under half a credit
|
|
14
|
+
* reads as less than one credit;
|
|
15
|
+
* - a **rate** (a price per unit of something) is never rounded;
|
|
16
|
+
* - **money** rounds to the currency's minor unit, half away from zero, and a
|
|
17
|
+
* non-zero amount that rounds to zero reads as less than the smallest unit;
|
|
18
|
+
* - a **cap** (a money limit) rounds down, so a limit never reads higher than
|
|
19
|
+
* the one enforced.
|
|
20
|
+
*
|
|
21
|
+
* Rules this module keeps, so two clients can never disagree:
|
|
22
|
+
*
|
|
23
|
+
* - **No scale lives here.** The credit scale comes from the served
|
|
24
|
+
* denomination on every call. A missing or malformed denomination, or a
|
|
25
|
+
* malformed amount, returns `null`: never a guess.
|
|
26
|
+
* - **No amount becomes a JavaScript number.** Every digit is produced with
|
|
27
|
+
* `BigInt`. `Intl.NumberFormat` is asked only for a currency's symbol, where
|
|
28
|
+
* the symbol sits, and how many minor-unit digits the currency has. No
|
|
29
|
+
* amount is ever handed to `Intl`.
|
|
30
|
+
* - **No dependencies**, not even the contract's own schemas, so a renderer
|
|
31
|
+
* can import this without Zod.
|
|
32
|
+
*
|
|
33
|
+
* Numbers are grouped the way `en-US` groups them. Localised formatting is a
|
|
34
|
+
* separate, later change. The package README lists every rule with worked
|
|
35
|
+
* examples.
|
|
36
|
+
*
|
|
37
|
+
* @packageDocumentation
|
|
38
|
+
*/
|
|
39
|
+
const INTEGER_STRING = /^-?(0|[1-9][0-9]*)$/;
|
|
40
|
+
const POSITIVE_INTEGER_STRING = /^[1-9][0-9]*$/;
|
|
41
|
+
const CURRENCY_CODE = /^[A-Z]{3}$/;
|
|
42
|
+
/** How many decimal digits a micro-unit is below the major unit. */
|
|
43
|
+
const MICRO_DIGITS = 6;
|
|
44
|
+
const MICRO_PER_MAJOR = BigInt(10) ** BigInt(MICRO_DIGITS);
|
|
45
|
+
const ZERO = BigInt(0);
|
|
46
|
+
const ONE = BigInt(1);
|
|
47
|
+
const TWO = BigInt(2);
|
|
48
|
+
const TEN = BigInt(10);
|
|
49
|
+
/**
|
|
50
|
+
* Floor division: the quotient rounded toward negative infinity.
|
|
51
|
+
*
|
|
52
|
+
* @param dividend - Any integer.
|
|
53
|
+
* @param divisor - A positive integer.
|
|
54
|
+
*/
|
|
55
|
+
export function floorDiv(dividend, divisor) {
|
|
56
|
+
const quotient = dividend / divisor;
|
|
57
|
+
return dividend % divisor !== ZERO && dividend < ZERO ? quotient - ONE : quotient;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The quotient rounded to the nearest integer, a tie going away from zero.
|
|
61
|
+
*
|
|
62
|
+
* @param dividend - Any integer.
|
|
63
|
+
* @param divisor - A positive integer.
|
|
64
|
+
*/
|
|
65
|
+
export function roundHalfAwayFromZero(dividend, divisor) {
|
|
66
|
+
const magnitude = dividend < ZERO ? -dividend : dividend;
|
|
67
|
+
let quotient = magnitude / divisor;
|
|
68
|
+
if ((magnitude % divisor) * TWO >= divisor)
|
|
69
|
+
quotient += ONE;
|
|
70
|
+
return dividend < ZERO ? -quotient : quotient;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reads an amount string, or `null` when it is not a base-10 integer string.
|
|
74
|
+
*
|
|
75
|
+
* @param micro - The amount as it came off the wire.
|
|
76
|
+
*/
|
|
77
|
+
function parseAmount(micro) {
|
|
78
|
+
if (typeof micro !== 'string' || !INTEGER_STRING.test(micro))
|
|
79
|
+
return null;
|
|
80
|
+
return BigInt(micro);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Reads the served credit scale, or `null` when the denomination is missing or
|
|
84
|
+
* malformed.
|
|
85
|
+
*
|
|
86
|
+
* @param denomination - The response's `denomination`.
|
|
87
|
+
*/
|
|
88
|
+
function parseScale(denomination) {
|
|
89
|
+
if (typeof denomination !== 'object' || denomination === null)
|
|
90
|
+
return null;
|
|
91
|
+
const { microPerCredit } = denomination;
|
|
92
|
+
if (typeof microPerCredit !== 'string' || !POSITIVE_INTEGER_STRING.test(microPerCredit)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
if (currencyOf(denomination) === null)
|
|
96
|
+
return null;
|
|
97
|
+
return BigInt(microPerCredit);
|
|
98
|
+
}
|
|
99
|
+
const currencyShapes = new Map();
|
|
100
|
+
/**
|
|
101
|
+
* Learns how a currency is written in `en-US`, without formatting any amount.
|
|
102
|
+
*
|
|
103
|
+
* `formatToParts(0)` gives the symbol and which side of the digits it sits on;
|
|
104
|
+
* `resolvedOptions()` gives the minor-unit digits. Cached per code.
|
|
105
|
+
*
|
|
106
|
+
* @param currency - An ISO 4217 code.
|
|
107
|
+
*/
|
|
108
|
+
function shapeOf(currency) {
|
|
109
|
+
const cached = currencyShapes.get(currency);
|
|
110
|
+
if (cached !== undefined)
|
|
111
|
+
return cached;
|
|
112
|
+
let shape = null;
|
|
113
|
+
try {
|
|
114
|
+
const format = new Intl.NumberFormat('en-US', { style: 'currency', currency });
|
|
115
|
+
const parts = format.formatToParts(0);
|
|
116
|
+
const numeric = new Set(['integer', 'group', 'decimal', 'fraction']);
|
|
117
|
+
const first = parts.findIndex((part) => numeric.has(part.type));
|
|
118
|
+
let last = -1;
|
|
119
|
+
parts.forEach((part, index) => {
|
|
120
|
+
if (numeric.has(part.type))
|
|
121
|
+
last = index;
|
|
122
|
+
});
|
|
123
|
+
const minorDigits = format.resolvedOptions().maximumFractionDigits ?? 0;
|
|
124
|
+
if (first >= 0 && minorDigits >= 0 && minorDigits <= MICRO_DIGITS) {
|
|
125
|
+
const text = (slice) => slice
|
|
126
|
+
.filter((part) => part.type !== 'minusSign' && part.type !== 'plusSign')
|
|
127
|
+
.map((part) => part.value)
|
|
128
|
+
.join('');
|
|
129
|
+
shape = {
|
|
130
|
+
prefix: text(parts.slice(0, first)),
|
|
131
|
+
suffix: text(parts.slice(last + 1)),
|
|
132
|
+
minorDigits,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
shape = null;
|
|
138
|
+
}
|
|
139
|
+
currencyShapes.set(currency, shape);
|
|
140
|
+
return shape;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Reads the currency of a denomination, or `null` when it is missing, not
|
|
144
|
+
* three capital letters, or refused by this runtime's `Intl`. A well-formed
|
|
145
|
+
* code `Intl` does not know is still written, with the code as its symbol.
|
|
146
|
+
*
|
|
147
|
+
* @param denomination - A response's `denomination`, or just `{ currency }`.
|
|
148
|
+
*/
|
|
149
|
+
function currencyOf(denomination) {
|
|
150
|
+
if (typeof denomination !== 'object' || denomination === null)
|
|
151
|
+
return null;
|
|
152
|
+
const { currency } = denomination;
|
|
153
|
+
if (typeof currency !== 'string' || !CURRENCY_CODE.test(currency))
|
|
154
|
+
return null;
|
|
155
|
+
return shapeOf(currency);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Groups the digits of a non-negative integer the way `en-US` does.
|
|
159
|
+
*
|
|
160
|
+
* @param value - A non-negative integer.
|
|
161
|
+
*/
|
|
162
|
+
function group(value) {
|
|
163
|
+
const digits = value.toString();
|
|
164
|
+
let out = '';
|
|
165
|
+
for (let index = 0; index < digits.length; index += 1) {
|
|
166
|
+
if (index > 0 && (digits.length - index) % 3 === 0)
|
|
167
|
+
out += ',';
|
|
168
|
+
out += digits[index];
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Writes `numerator / 10^scaleDigits` exactly, grouped, with at least
|
|
174
|
+
* `minFraction` decimals and no trailing zero beyond them.
|
|
175
|
+
*
|
|
176
|
+
* @param numerator - A non-negative integer.
|
|
177
|
+
* @param scaleDigits - How many decimal places the numerator is scaled by.
|
|
178
|
+
* @param minFraction - The fewest decimals to show.
|
|
179
|
+
*/
|
|
180
|
+
function decimal(numerator, scaleDigits, minFraction) {
|
|
181
|
+
const unit = TEN ** BigInt(scaleDigits);
|
|
182
|
+
const whole = numerator / unit;
|
|
183
|
+
let fraction = scaleDigits > 0 ? (numerator % unit).toString().padStart(scaleDigits, '0') : '';
|
|
184
|
+
while (fraction.length > minFraction && fraction.endsWith('0'))
|
|
185
|
+
fraction = fraction.slice(0, -1);
|
|
186
|
+
return fraction.length > 0 ? `${group(whole)}.${fraction}` : group(whole);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Writes an integer credit count with its sign, never as a negative zero.
|
|
190
|
+
*
|
|
191
|
+
* @param value - Whole credits.
|
|
192
|
+
*/
|
|
193
|
+
function signedCredits(value) {
|
|
194
|
+
return value < ZERO ? `-${group(-value)}` : group(value);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Writes a count of minor units as money.
|
|
198
|
+
*
|
|
199
|
+
* @param minor - The amount in the currency's minor units.
|
|
200
|
+
* @param shape - How the currency is written.
|
|
201
|
+
* @param whole - Whether to drop the minor digits (the exact amount is whole).
|
|
202
|
+
*/
|
|
203
|
+
function writeMoney(minor, shape, whole) {
|
|
204
|
+
const magnitude = minor < ZERO ? -minor : minor;
|
|
205
|
+
const digits = whole
|
|
206
|
+
? group(magnitude / TEN ** BigInt(shape.minorDigits))
|
|
207
|
+
: decimal(magnitude, shape.minorDigits, shape.minorDigits);
|
|
208
|
+
const sign = minor < ZERO ? '-' : '';
|
|
209
|
+
return `${sign}${shape.prefix}${digits}${shape.suffix}`;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The shared money rule, with the rounding as a parameter.
|
|
213
|
+
*
|
|
214
|
+
* @param micro - The amount string.
|
|
215
|
+
* @param currency - The response's `denomination`, or just `{ currency }`.
|
|
216
|
+
* @param round - How to turn micro-units into minor units.
|
|
217
|
+
*/
|
|
218
|
+
function money(micro, currency, round) {
|
|
219
|
+
const amount = parseAmount(micro);
|
|
220
|
+
const shape = currencyOf(currency);
|
|
221
|
+
if (amount === null || shape === null)
|
|
222
|
+
return null;
|
|
223
|
+
const microPerMinor = TEN ** BigInt(MICRO_DIGITS - shape.minorDigits);
|
|
224
|
+
const minor = round(amount, microPerMinor);
|
|
225
|
+
if (minor === ZERO && amount !== ZERO) {
|
|
226
|
+
const smallest = writeMoney(ONE, shape, shape.minorDigits === 0);
|
|
227
|
+
return amount < ZERO ? `-<${smallest}` : `<${smallest}`;
|
|
228
|
+
}
|
|
229
|
+
// Whole means the EXACT amount is a whole major unit, so a rounded figure
|
|
230
|
+
// keeps its minor digits and never reads as more exact than it is.
|
|
231
|
+
return writeMoney(minor, shape, amount % MICRO_PER_MAJOR === ZERO);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Renders what a person has or may still spend: whole credits, rounded toward
|
|
235
|
+
* negative infinity, so it never shows credit that cannot be spent.
|
|
236
|
+
*
|
|
237
|
+
* @param micro - The amount string, in micro-units.
|
|
238
|
+
* @param denomination - The response's `denomination`.
|
|
239
|
+
* @returns The grouped credit count, or `null` for a malformed amount or denomination.
|
|
240
|
+
*/
|
|
241
|
+
export function formatPosition(micro, denomination) {
|
|
242
|
+
const amount = parseAmount(micro);
|
|
243
|
+
const scale = parseScale(denomination);
|
|
244
|
+
if (amount === null || scale === null)
|
|
245
|
+
return null;
|
|
246
|
+
return signedCredits(floorDiv(amount, scale));
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Renders what a person spent, was charged or is held for: whole credits,
|
|
250
|
+
* rounded half away from zero. Zero reads as zero; a non-zero amount that rounds
|
|
251
|
+
* to zero reads as less than one credit, with a minus sign when negative.
|
|
252
|
+
*
|
|
253
|
+
* @param micro - The amount string, in micro-units.
|
|
254
|
+
* @param denomination - The response's `denomination`.
|
|
255
|
+
* @returns The grouped credit count, or `null` for a malformed amount or denomination.
|
|
256
|
+
*/
|
|
257
|
+
export function formatCharge(micro, denomination) {
|
|
258
|
+
const amount = parseAmount(micro);
|
|
259
|
+
const scale = parseScale(denomination);
|
|
260
|
+
if (amount === null || scale === null)
|
|
261
|
+
return null;
|
|
262
|
+
if (amount === ZERO)
|
|
263
|
+
return '0';
|
|
264
|
+
const credits = roundHalfAwayFromZero(amount, scale);
|
|
265
|
+
if (credits === ZERO)
|
|
266
|
+
return amount < ZERO ? '-<1' : '<1';
|
|
267
|
+
return signedCredits(credits);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Renders a price per unit of something in credits, never rounded: every
|
|
271
|
+
* significant digit, trailing zeros trimmed.
|
|
272
|
+
*
|
|
273
|
+
* A scale with a prime factor other than two or five cannot write every
|
|
274
|
+
* amount as a finite decimal. Such an amount returns `null` rather than a
|
|
275
|
+
* rounded figure.
|
|
276
|
+
*
|
|
277
|
+
* @param micro - The amount string, in micro-units.
|
|
278
|
+
* @param denomination - The response's `denomination`.
|
|
279
|
+
* @returns The exact credit figure, or `null` when it cannot be written exactly or the input is malformed.
|
|
280
|
+
*/
|
|
281
|
+
export function formatRate(micro, denomination) {
|
|
282
|
+
const amount = parseAmount(micro);
|
|
283
|
+
const scale = parseScale(denomination);
|
|
284
|
+
if (amount === null || scale === null)
|
|
285
|
+
return null;
|
|
286
|
+
// amount / scale is a finite decimal exactly when, after cancelling, the
|
|
287
|
+
// denominator has only twos and fives. Find the power of ten that clears it.
|
|
288
|
+
let digits = 0;
|
|
289
|
+
let numerator = amount < ZERO ? -amount : amount;
|
|
290
|
+
let power = ONE;
|
|
291
|
+
while ((numerator * power) % scale !== ZERO) {
|
|
292
|
+
digits += 1;
|
|
293
|
+
power *= TEN;
|
|
294
|
+
if (digits > scale.toString().length * 4)
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
numerator = (numerator * power) / scale;
|
|
298
|
+
const text = decimal(numerator, digits, 0);
|
|
299
|
+
return amount < ZERO ? `-${text}` : text;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Renders money: rounded to the currency's minor unit, half away from zero.
|
|
303
|
+
* An amount that is exactly a whole major unit prints without minor digits;
|
|
304
|
+
* any other prints with all of them. A non-zero amount that rounds to zero
|
|
305
|
+
* reads as less than the smallest unit.
|
|
306
|
+
*
|
|
307
|
+
* Money needs no credit scale, so a bare `{ currency }` is enough.
|
|
308
|
+
*
|
|
309
|
+
* @param micro - The amount string, in micro-units of the currency.
|
|
310
|
+
* @param currency - The response's `denomination`, or just `{ currency }`.
|
|
311
|
+
* @returns The money text, or `null` for a malformed amount or currency.
|
|
312
|
+
*/
|
|
313
|
+
export function formatMoney(micro, currency) {
|
|
314
|
+
return money(micro, currency, roundHalfAwayFromZero);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Renders a money limit: the money rule, rounded toward negative infinity, so
|
|
318
|
+
* a limit never reads higher than the one enforced.
|
|
319
|
+
*
|
|
320
|
+
* @param micro - The amount string, in micro-units of the currency.
|
|
321
|
+
* @param currency - The response's `denomination`, or just `{ currency }`.
|
|
322
|
+
* @returns The money text, or `null` for a malformed amount or currency.
|
|
323
|
+
*/
|
|
324
|
+
export function formatCap(micro, currency) {
|
|
325
|
+
return money(micro, currency, floorDiv);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Renders a price in money, never rounded: the exact amount, with at least the
|
|
329
|
+
* currency's minor digits.
|
|
330
|
+
*
|
|
331
|
+
* @param micro - The amount string, in micro-units of the currency.
|
|
332
|
+
* @param currency - The response's `denomination`, or just `{ currency }`.
|
|
333
|
+
* @returns The money text, or `null` for a malformed amount or currency.
|
|
334
|
+
*/
|
|
335
|
+
export function formatMoneyRate(micro, currency) {
|
|
336
|
+
const amount = parseAmount(micro);
|
|
337
|
+
const shape = currencyOf(currency);
|
|
338
|
+
if (amount === null || shape === null)
|
|
339
|
+
return null;
|
|
340
|
+
const magnitude = amount < ZERO ? -amount : amount;
|
|
341
|
+
const sign = amount < ZERO ? '-' : '';
|
|
342
|
+
return `${sign}${shape.prefix}${decimal(magnitude, MICRO_DIGITS, shape.minorDigits)}${shape.suffix}`;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Renders a credit figure with its money value beside it:
|
|
346
|
+
* `<credits> credits (<money>)`, with the singular for exactly one credit.
|
|
347
|
+
*
|
|
348
|
+
* For a position or a charge the money is worked out from the ROUNDED credit
|
|
349
|
+
* count times the served scale, never separately from the exact amount, so the
|
|
350
|
+
* two figures always agree. A charge under one credit reads as less than one
|
|
351
|
+
* credit, beside less than the money of one credit. A rate is exact on both
|
|
352
|
+
* sides.
|
|
353
|
+
*
|
|
354
|
+
* @param micro - The amount string, in micro-units.
|
|
355
|
+
* @param denomination - The response's `denomination`.
|
|
356
|
+
* @param kind - How the credit figure is rounded.
|
|
357
|
+
* @returns The text, or `null` for a malformed amount or denomination.
|
|
358
|
+
*/
|
|
359
|
+
export function formatCreditsWithMoney(micro, denomination, kind) {
|
|
360
|
+
const amount = parseAmount(micro);
|
|
361
|
+
const scale = parseScale(denomination);
|
|
362
|
+
if (amount === null || scale === null)
|
|
363
|
+
return null;
|
|
364
|
+
const label = (credits) => credits === '1' || credits === '-1' ? `${credits} credit` : `${credits} credits`;
|
|
365
|
+
if (kind === 'rate') {
|
|
366
|
+
const credits = formatRate(micro, denomination);
|
|
367
|
+
const price = formatMoneyRate(micro, denomination);
|
|
368
|
+
if (credits === null || price === null)
|
|
369
|
+
return null;
|
|
370
|
+
return `${label(credits)} (${price})`;
|
|
371
|
+
}
|
|
372
|
+
let credits;
|
|
373
|
+
if (kind === 'position') {
|
|
374
|
+
credits = floorDiv(amount, scale);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
credits = amount === ZERO ? ZERO : roundHalfAwayFromZero(amount, scale);
|
|
378
|
+
if (credits === ZERO && amount !== ZERO) {
|
|
379
|
+
const oneCredit = formatMoney(scale.toString(), denomination);
|
|
380
|
+
if (oneCredit === null)
|
|
381
|
+
return null;
|
|
382
|
+
// One credit may itself be under the smallest money unit, in which case
|
|
383
|
+
// it already reads as less than that unit and needs no second marker.
|
|
384
|
+
const under = oneCredit.startsWith('<') ? oneCredit : `<${oneCredit}`;
|
|
385
|
+
return amount < ZERO ? `-<1 credit (-${under})` : `<1 credit (${under})`;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const price = formatMoney((credits * scale).toString(), denomination);
|
|
389
|
+
if (price === null)
|
|
390
|
+
return null;
|
|
391
|
+
return `${label(signedCredits(credits))} (${price})`;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Renders a total the only honest way: the exact sum of the lines, rounded once
|
|
395
|
+
* by the kind of what it totals. Never the sum of rounded lines, so a total may
|
|
396
|
+
* differ from its rounded lines by a credit or two, and it is the total that
|
|
397
|
+
* matches what was charged.
|
|
398
|
+
*
|
|
399
|
+
* @param lines - The exact amount strings being totalled.
|
|
400
|
+
* @param denomination - The response's `denomination` (or `{ currency }` for money and cap).
|
|
401
|
+
* @param kind - How the total is rounded.
|
|
402
|
+
* @returns The total's text, or `null` when any line or the denomination is malformed.
|
|
403
|
+
*/
|
|
404
|
+
export function formatTotal(lines, denomination, kind) {
|
|
405
|
+
let sum = ZERO;
|
|
406
|
+
for (const line of lines) {
|
|
407
|
+
const amount = parseAmount(line);
|
|
408
|
+
if (amount === null)
|
|
409
|
+
return null;
|
|
410
|
+
sum += amount;
|
|
411
|
+
}
|
|
412
|
+
const total = sum.toString();
|
|
413
|
+
// The credit kinds read the scale off the denomination and return null
|
|
414
|
+
// without one, so a bare currency is safe to pass through.
|
|
415
|
+
const scaled = denomination;
|
|
416
|
+
switch (kind) {
|
|
417
|
+
case 'position':
|
|
418
|
+
return formatPosition(total, scaled);
|
|
419
|
+
case 'charge':
|
|
420
|
+
return formatCharge(total, scaled);
|
|
421
|
+
case 'rate':
|
|
422
|
+
return formatRate(total, scaled);
|
|
423
|
+
case 'money':
|
|
424
|
+
return formatMoney(total, denomination);
|
|
425
|
+
case 'cap':
|
|
426
|
+
return formatCap(total, denomination);
|
|
427
|
+
default:
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAqCH,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAC7C,MAAM,uBAAuB,GAAG,eAAe,CAAC;AAChD,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,oEAAoE;AACpE,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MA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AEvB,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACjC,GAAG,IAAI,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7B,uEAAuE;IACvE,2DAA2D;IAC3D,MAAM,MAAM,GAAG,YAAiC,CAAC;IACjD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU;YACb,OAAO,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACvC,KAAK,QAAQ;YACX,OAAO,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrC,KAAK,MAAM;YACT,OAAO,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACnC,KAAK,OAAO;YACV,OAAO,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC1C,KAAK,KAAK;YACR,OAAO,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACxC;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/dist/primitives.d.ts
CHANGED
|
@@ -51,6 +51,69 @@ export declare const MicroAmountSchema: z.ZodString;
|
|
|
51
51
|
* here.
|
|
52
52
|
*/
|
|
53
53
|
export declare const PositiveMicroAmountSchema: z.ZodString;
|
|
54
|
+
/**
|
|
55
|
+
* The metadata key that says what kind of amount a field carries.
|
|
56
|
+
*
|
|
57
|
+
* Set with `.meta()` on {@link MoneyMicroSchema} and {@link CreditMicroSchema},
|
|
58
|
+
* so it reaches the generated JSON Schema as an `amountKind` keyword as well as
|
|
59
|
+
* the runtime registry (`z.globalRegistry.get(schema)`). A renderer reads it to
|
|
60
|
+
* decide whether an amount is shown as money or as credits.
|
|
61
|
+
*/
|
|
62
|
+
export declare const AMOUNT_KIND_META: "amountKind";
|
|
63
|
+
/**
|
|
64
|
+
* The two kinds of amount this contract carries.
|
|
65
|
+
*
|
|
66
|
+
* Mechanism, not catalog: it says how an amount is counted, never what anybody
|
|
67
|
+
* bought.
|
|
68
|
+
*/
|
|
69
|
+
export declare const AmountKindSchema: z.ZodEnum<{
|
|
70
|
+
money: "money";
|
|
71
|
+
credit: "credit";
|
|
72
|
+
}>;
|
|
73
|
+
/** What an amount counts. */
|
|
74
|
+
export type AmountKind = z.infer<typeof AmountKindSchema>;
|
|
75
|
+
/**
|
|
76
|
+
* An amount of money, as an exact integer count of micro-units carried as a
|
|
77
|
+
* string.
|
|
78
|
+
*
|
|
79
|
+
* The same wire shape and the same TypeScript type as {@link MicroAmountSchema};
|
|
80
|
+
* only the description and the {@link AMOUNT_KIND_META} mark differ. Render it
|
|
81
|
+
* in the response's `denomination.currency`, never as credits.
|
|
82
|
+
*/
|
|
83
|
+
export declare const MoneyMicroSchema: z.ZodString;
|
|
84
|
+
/**
|
|
85
|
+
* A strictly positive amount of money: the shape of an amount a purchase is
|
|
86
|
+
* made of.
|
|
87
|
+
*
|
|
88
|
+
* The same wire shape as {@link PositiveMicroAmountSchema}, marked as money.
|
|
89
|
+
*/
|
|
90
|
+
export declare const PositiveMoneyMicroSchema: z.ZodString;
|
|
91
|
+
/**
|
|
92
|
+
* An amount of credits, as an exact integer count of micro-units carried as a
|
|
93
|
+
* string.
|
|
94
|
+
*
|
|
95
|
+
* The same wire shape and the same TypeScript type as {@link MicroAmountSchema};
|
|
96
|
+
* only the description and the {@link AMOUNT_KIND_META} mark differ. Divide by
|
|
97
|
+
* the response's `denomination.microPerCredit` to get credits. The scale is
|
|
98
|
+
* served, never assumed: this package publishes no value for it.
|
|
99
|
+
*/
|
|
100
|
+
export declare const CreditMicroSchema: z.ZodString;
|
|
101
|
+
/**
|
|
102
|
+
* The unit a response's amounts are in: which currency the micro-units are
|
|
103
|
+
* millionths of, and how many of them one credit is.
|
|
104
|
+
*
|
|
105
|
+
* Served by the service at runtime on every response that carries an amount.
|
|
106
|
+
* This package publishes no value for either field, and a client never
|
|
107
|
+
* hard-codes one. A response without it came from an older service; a client
|
|
108
|
+
* that receives none shows that it could not read the amount rather than
|
|
109
|
+
* guessing a unit.
|
|
110
|
+
*/
|
|
111
|
+
export declare const DenominationSchema: z.ZodObject<{
|
|
112
|
+
currency: z.ZodString;
|
|
113
|
+
microPerCredit: z.ZodString;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
/** The unit a response's amounts are in. */
|
|
116
|
+
export type Denomination = z.infer<typeof DenominationSchema>;
|
|
54
117
|
/**
|
|
55
118
|
* A value returned once and never again.
|
|
56
119
|
*
|
package/dist/primitives.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAG,CAAU,CAAC;AAEvC,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,EAAG,KAAc,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAG,eAAwB,CAAC;AAE5D,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,QAAuB,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,kBAEmC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,aAGkE,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,aAQ3B,CAAC;AAEJ;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,aAQnC,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,aAK3B,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,YAAY,aAG6D,CAAC;AAEvF,kEAAkE;AAClE,eAAO,MAA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CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,4FAQzD"}
|
package/dist/primitives.js
CHANGED
|
@@ -44,7 +44,7 @@ export const IdSchema = z
|
|
|
44
44
|
export const MicroAmountSchema = z
|
|
45
45
|
.string()
|
|
46
46
|
.regex(/^-?(0|[1-9][0-9]*)$/, 'must be a base-10 integer count of micro-units carried as a string')
|
|
47
|
-
.describe('An exact integer count of micro-units, carried as a string so no value goes through a JavaScript number.');
|
|
47
|
+
.describe('An exact integer count of micro-units, carried as a string so no value goes through a JavaScript number. A micro-unit is a millionth of the major unit of the currency the response names.');
|
|
48
48
|
/**
|
|
49
49
|
* A strictly positive integer count of micro-units carried as a string.
|
|
50
50
|
*
|
|
@@ -62,6 +62,83 @@ export const PositiveMicroAmountSchema = z
|
|
|
62
62
|
.string()
|
|
63
63
|
.regex(/^[1-9][0-9]*$/, 'must be a positive base-10 integer count of micro-units carried as a string')
|
|
64
64
|
.describe('A strictly positive exact integer count of micro-units, carried as a string so no amount goes through a JavaScript number.');
|
|
65
|
+
/**
|
|
66
|
+
* The metadata key that says what kind of amount a field carries.
|
|
67
|
+
*
|
|
68
|
+
* Set with `.meta()` on {@link MoneyMicroSchema} and {@link CreditMicroSchema},
|
|
69
|
+
* so it reaches the generated JSON Schema as an `amountKind` keyword as well as
|
|
70
|
+
* the runtime registry (`z.globalRegistry.get(schema)`). A renderer reads it to
|
|
71
|
+
* decide whether an amount is shown as money or as credits.
|
|
72
|
+
*/
|
|
73
|
+
export const AMOUNT_KIND_META = 'amountKind';
|
|
74
|
+
/**
|
|
75
|
+
* The two kinds of amount this contract carries.
|
|
76
|
+
*
|
|
77
|
+
* Mechanism, not catalog: it says how an amount is counted, never what anybody
|
|
78
|
+
* bought.
|
|
79
|
+
*/
|
|
80
|
+
export const AmountKindSchema = z
|
|
81
|
+
.enum(['money', 'credit'])
|
|
82
|
+
.describe('What an amount counts: money paid, refunded, offered or capped, or credits held, spent or priced.');
|
|
83
|
+
const INTEGER_STRING = /^-?(0|[1-9][0-9]*)$/;
|
|
84
|
+
const POSITIVE_INTEGER_STRING = /^[1-9][0-9]*$/;
|
|
85
|
+
/**
|
|
86
|
+
* An amount of money, as an exact integer count of micro-units carried as a
|
|
87
|
+
* string.
|
|
88
|
+
*
|
|
89
|
+
* The same wire shape and the same TypeScript type as {@link MicroAmountSchema};
|
|
90
|
+
* only the description and the {@link AMOUNT_KIND_META} mark differ. Render it
|
|
91
|
+
* in the response's `denomination.currency`, never as credits.
|
|
92
|
+
*/
|
|
93
|
+
export const MoneyMicroSchema = z
|
|
94
|
+
.string()
|
|
95
|
+
.regex(INTEGER_STRING, 'must be a base-10 integer count of micro-units carried as a string')
|
|
96
|
+
.describe("An exact integer count of micro-units of the response's currency: money paid, refunded, offered or capped.")
|
|
97
|
+
.meta({ [AMOUNT_KIND_META]: 'money' });
|
|
98
|
+
/**
|
|
99
|
+
* A strictly positive amount of money: the shape of an amount a purchase is
|
|
100
|
+
* made of.
|
|
101
|
+
*
|
|
102
|
+
* The same wire shape as {@link PositiveMicroAmountSchema}, marked as money.
|
|
103
|
+
*/
|
|
104
|
+
export const PositiveMoneyMicroSchema = z
|
|
105
|
+
.string()
|
|
106
|
+
.regex(POSITIVE_INTEGER_STRING, 'must be a positive base-10 integer count of micro-units carried as a string')
|
|
107
|
+
.describe('A strictly positive exact integer count of micro-units of money to be paid, in the currency the service names.')
|
|
108
|
+
.meta({ [AMOUNT_KIND_META]: 'money' });
|
|
109
|
+
/**
|
|
110
|
+
* An amount of credits, as an exact integer count of micro-units carried as a
|
|
111
|
+
* string.
|
|
112
|
+
*
|
|
113
|
+
* The same wire shape and the same TypeScript type as {@link MicroAmountSchema};
|
|
114
|
+
* only the description and the {@link AMOUNT_KIND_META} mark differ. Divide by
|
|
115
|
+
* the response's `denomination.microPerCredit` to get credits. The scale is
|
|
116
|
+
* served, never assumed: this package publishes no value for it.
|
|
117
|
+
*/
|
|
118
|
+
export const CreditMicroSchema = z
|
|
119
|
+
.string()
|
|
120
|
+
.regex(INTEGER_STRING, 'must be a base-10 integer count of micro-units carried as a string')
|
|
121
|
+
.describe("An exact integer count of micro-units of the response's currency, counted as credits: divide by the response's denomination.microPerCredit to get credits.")
|
|
122
|
+
.meta({ [AMOUNT_KIND_META]: 'credit' });
|
|
123
|
+
/**
|
|
124
|
+
* The unit a response's amounts are in: which currency the micro-units are
|
|
125
|
+
* millionths of, and how many of them one credit is.
|
|
126
|
+
*
|
|
127
|
+
* Served by the service at runtime on every response that carries an amount.
|
|
128
|
+
* This package publishes no value for either field, and a client never
|
|
129
|
+
* hard-codes one. A response without it came from an older service; a client
|
|
130
|
+
* that receives none shows that it could not read the amount rather than
|
|
131
|
+
* guessing a unit.
|
|
132
|
+
*/
|
|
133
|
+
export const DenominationSchema = z
|
|
134
|
+
.object({
|
|
135
|
+
currency: z
|
|
136
|
+
.string()
|
|
137
|
+
.regex(/^[A-Z]{3}$/, 'must be an ISO 4217 currency code')
|
|
138
|
+
.describe('An ISO 4217 code. Rendered, never enumerated.'),
|
|
139
|
+
microPerCredit: PositiveMicroAmountSchema.describe('How many micro-units of currency one credit is. Served by the service; a client never hard-codes it.'),
|
|
140
|
+
})
|
|
141
|
+
.describe('The unit these amounts are in: the currency their micro-units are millionths of, and how many micro-units one credit is.');
|
|
65
142
|
/**
|
|
66
143
|
* A value returned once and never again.
|
|
67
144
|
*
|
package/dist/primitives.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAU,CAAC;AAEvC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAc,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAwB,CAAC;AAE5D,kEAAkE;AAClE,MAAM,CA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