@substrat-run/contracts 0.207.0 → 0.208.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/money.d.ts +6 -0
- package/dist/money.d.ts.map +1 -1
- package/dist/money.js +15 -0
- package/dist/money.js.map +1 -1
- package/dist/platform-usage.d.ts +251 -0
- package/dist/platform-usage.d.ts.map +1 -0
- package/dist/platform-usage.js +221 -0
- package/dist/platform-usage.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export * from './lifecycle.js';
|
|
|
88
88
|
export * from './client-context.js';
|
|
89
89
|
export * from './model-usage.js';
|
|
90
90
|
export * from './markup.js';
|
|
91
|
+
export * from './platform-usage.js';
|
|
91
92
|
export * from './seam.js';
|
|
92
93
|
export * from './signals.js';
|
|
93
94
|
export * from './mcp.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAElC,OAAO,EACL,4BAA4B,EAC5B,mCAAmC,EACnC,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,i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7B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -90,6 +90,7 @@ export * from './lifecycle.js';
|
|
|
90
90
|
export * from './client-context.js';
|
|
91
91
|
export * from './model-usage.js';
|
|
92
92
|
export * from './markup.js';
|
|
93
|
+
export * from './platform-usage.js';
|
|
93
94
|
export * from './seam.js';
|
|
94
95
|
export * from './signals.js';
|
|
95
96
|
export * from './mcp.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,kFAAkF;AAClF,OAAO,EACL,4BAA4B,EAC5B,mCAAmC,EACnC,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,eA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cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
package/dist/money.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export type Money = z.infer<typeof money>;
|
|
|
11
11
|
/** quantity × unit price, half-up at 6 dp. Both args are decimal strings. */
|
|
12
12
|
export declare function mulDecimal(qty: string, amount: string): string;
|
|
13
13
|
export declare function addDecimal(a: string, b: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* a × b ÷ divisor, half-up at 6 dp, rounded once at the end. For a rate quoted per many units
|
|
16
|
+
* (USD per million rows): dividing either side first would round a small quantity to zero.
|
|
17
|
+
* `divisor` is a positive integer.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mulDivDecimal(a: string, b: string, divisor: number | bigint): string;
|
|
14
20
|
export declare function compareDecimal(a: string, b: string): -1 | 0 | 1;
|
|
15
21
|
export declare function moneyOf(amount: string, currency: string): Money;
|
|
16
22
|
export declare function addMoney(a: Money, b: Money): Money;
|
package/dist/money.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,YAAY,wDAGC,CAAC;AAC3B,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,WAAW,uDAGC,CAAC;AAC1B,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,KAAK;;;iBAGhB,CAAC;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AA0B1C,6EAA6E;AAC7E,wBAAgB,UAAU,CA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a,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAQpF;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAG/D;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAE/D;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,KAAK,CAKlD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,GAAG,KAAK,CAE7D"}
|
package/dist/money.js
CHANGED
|
@@ -45,6 +45,21 @@ export function mulDecimal(qty, amount) {
|
|
|
45
45
|
export function addDecimal(a, b) {
|
|
46
46
|
return fromMicro(toMicro(a) + toMicro(b));
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* a × b ÷ divisor, half-up at 6 dp, rounded once at the end. For a rate quoted per many units
|
|
50
|
+
* (USD per million rows): dividing either side first would round a small quantity to zero.
|
|
51
|
+
* `divisor` is a positive integer.
|
|
52
|
+
*/
|
|
53
|
+
export function mulDivDecimal(a, b, divisor) {
|
|
54
|
+
const d = BigInt(divisor);
|
|
55
|
+
if (d <= 0n)
|
|
56
|
+
throw new RangeError(`divisor must be a positive integer, got ${String(divisor)}`);
|
|
57
|
+
const product = toMicro(a) * toMicro(b);
|
|
58
|
+
const sign = product < 0n ? -1n : 1n;
|
|
59
|
+
const abs = product < 0n ? -product : product;
|
|
60
|
+
const den = SCALE * d;
|
|
61
|
+
return fromMicro(sign * ((abs + den / 2n) / den));
|
|
62
|
+
}
|
|
48
63
|
export function compareDecimal(a, b) {
|
|
49
64
|
const [ma, mb] = [toMicro(a), toMicro(b)];
|
|
50
65
|
return ma < mb ? -1 : ma >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AAC;QAC9B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,SAAgB;IACpD,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform usage, priced (#3316): what a team's apps used of Cloudflare, per day, and what it
|
|
3
|
+
* would cost at the platform's price.
|
|
4
|
+
*
|
|
5
|
+
* - **Cost** is the attributed quantity at Cloudflare's list price (`CLOUDFLARE_LIST_RATES`),
|
|
6
|
+
* before the account's included allowances, as the #3316 measurement priced it.
|
|
7
|
+
* - **Price** is cost × (1 + markup), the markup read from the schedule in force on each day
|
|
8
|
+
* (`priceCostRows`, `markup.ts`).
|
|
9
|
+
* - A tenant sees the price only (`tenantPlatformUsage`). Staff see cost, markup and price side
|
|
10
|
+
* by side, plus what no tenant is charged for (`staffPlatformCosts`).
|
|
11
|
+
*
|
|
12
|
+
* Every figure is a decimal string computed with the contracts helpers, never a float.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { type CostDimension } from './control-plane.js';
|
|
16
|
+
/** The billed dimensions platform usage reports: Cloudflare's, in the order a reader scans them. */
|
|
17
|
+
export declare const PLATFORM_USAGE_DIMENSIONS: readonly ["rows-written", "rows-read", "storage", "requests", "cpu", "do-requests", "duration"];
|
|
18
|
+
export type PlatformUsageDimension = (typeof PLATFORM_USAGE_DIMENSIONS)[number];
|
|
19
|
+
/**
|
|
20
|
+
* One list rate: `usd` per `per` units of the dimension's quantity. Quantities are in the unit
|
|
21
|
+
* `platformQuantityOf` reports: requests, CPU milliseconds, Durable Object requests, GB-seconds,
|
|
22
|
+
* rows, and bytes stored on the day (storage is quoted per GB-month and charged per day, so a
|
|
23
|
+
* day's storage costs `bytes × usd / (per × days in that month)`).
|
|
24
|
+
*/
|
|
25
|
+
export interface ListRate {
|
|
26
|
+
dimension: PlatformUsageDimension;
|
|
27
|
+
usd: string;
|
|
28
|
+
per: number;
|
|
29
|
+
unit: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Cloudflare's list prices for Workers and SQLite-backed Durable Objects, dated like the markup
|
|
33
|
+
* schedule: a change is a new entry with the UTC day it takes effect, so a past day keeps the
|
|
34
|
+
* price it was billed at. The figures are the public price list, the ones #3316's first
|
|
35
|
+
* measurement used.
|
|
36
|
+
*/
|
|
37
|
+
export declare const CLOUDFLARE_LIST_RATES: readonly {
|
|
38
|
+
effectiveFrom: string;
|
|
39
|
+
rates: readonly ListRate[];
|
|
40
|
+
}[];
|
|
41
|
+
/** The list rates in force on `day`, or none before the first entry. */
|
|
42
|
+
export declare function listRatesOn(day: string): readonly ListRate[];
|
|
43
|
+
/**
|
|
44
|
+
* The billed dimension each rollup dimension is charged as, or null for one Cloudflare does not
|
|
45
|
+
* bill on SQLite-backed objects: their writes are billed as rows written, so the storage write
|
|
46
|
+
* units the analytics also report would count them twice.
|
|
47
|
+
*/
|
|
48
|
+
export declare const COST_DIMENSION_BILLED: Readonly<Record<CostDimension, PlatformUsageDimension | null>>;
|
|
49
|
+
/** A rollup quantity in its billed unit: CPU µs become ms; every other unit is kept. */
|
|
50
|
+
export declare function platformQuantityOf(dimension: CostDimension, quantity: string): string;
|
|
51
|
+
/** A quantity's cost at list price on `day`, USD; null when no rate is in force for it. */
|
|
52
|
+
export declare function listCostOf(dimension: PlatformUsageDimension, quantity: string, day: string): string | null;
|
|
53
|
+
/** The key each dimension's figure has in a quantities object: an identifier, so a generated client can name it bare. */
|
|
54
|
+
export declare const QUANTITY_KEY: {
|
|
55
|
+
readonly 'rows-written': 'rowsWritten';
|
|
56
|
+
readonly 'rows-read': 'rowsRead';
|
|
57
|
+
readonly storage: 'storage';
|
|
58
|
+
readonly requests: 'requests';
|
|
59
|
+
readonly cpu: 'cpu';
|
|
60
|
+
readonly 'do-requests': 'doRequests';
|
|
61
|
+
readonly duration: 'duration';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The quantities behind a figure, in each dimension's billed unit (`ListRate.unit`). `storage` is
|
|
65
|
+
* bytes stored on a day; over several days it is their sum, byte-days, which a reader divides by
|
|
66
|
+
* the days read for the average stored.
|
|
67
|
+
*/
|
|
68
|
+
export declare const platformQuantities: z.ZodObject<{
|
|
69
|
+
rowsWritten: z.ZodString;
|
|
70
|
+
rowsRead: z.ZodString;
|
|
71
|
+
storage: z.ZodString;
|
|
72
|
+
requests: z.ZodString;
|
|
73
|
+
cpu: z.ZodString;
|
|
74
|
+
doRequests: z.ZodString;
|
|
75
|
+
duration: z.ZodString;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type PlatformQuantities = z.infer<typeof platformQuantities>;
|
|
78
|
+
/**
|
|
79
|
+
* How much of the window the cost rollup has read. `not-read`: no day yet (the daily pass has
|
|
80
|
+
* not run, or has not reached these days), so an empty page says nothing about usage. `empty`:
|
|
81
|
+
* days were read and the team used nothing on them. `partial`: some days are still unread.
|
|
82
|
+
*/
|
|
83
|
+
export declare const platformUsageState: z.ZodEnum<{
|
|
84
|
+
complete: "complete";
|
|
85
|
+
empty: "empty";
|
|
86
|
+
"not-read": "not-read";
|
|
87
|
+
partial: "partial";
|
|
88
|
+
}>;
|
|
89
|
+
export type PlatformUsageState = z.infer<typeof platformUsageState>;
|
|
90
|
+
/**
|
|
91
|
+
* `GET /tenants/:tenantId/platform-usage` (#3316): what the team's apps used of the platform,
|
|
92
|
+
* per closed UTC day, and what it would cost at the platform's price. PRICE ONLY: neither the
|
|
93
|
+
* platform's cost nor its markup is in this shape. Nothing is charged yet (`chargedUsd` is 0).
|
|
94
|
+
*/
|
|
95
|
+
export declare const tenantPlatformUsage: z.ZodObject<{
|
|
96
|
+
since: z.ZodString;
|
|
97
|
+
until: z.ZodString;
|
|
98
|
+
readAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
|
|
99
|
+
state: z.ZodEnum<{
|
|
100
|
+
complete: "complete";
|
|
101
|
+
empty: "empty";
|
|
102
|
+
"not-read": "not-read";
|
|
103
|
+
partial: "partial";
|
|
104
|
+
}>;
|
|
105
|
+
readDays: z.ZodNumber;
|
|
106
|
+
totalDays: z.ZodNumber;
|
|
107
|
+
lastReadAt: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "Instant", "out">>;
|
|
108
|
+
wouldCostUsd: z.ZodString;
|
|
109
|
+
liveWouldCostUsd: z.ZodString;
|
|
110
|
+
previewWouldCostUsd: z.ZodString;
|
|
111
|
+
chargedUsd: z.ZodLiteral<"0">;
|
|
112
|
+
quantities: z.ZodObject<{
|
|
113
|
+
rowsWritten: z.ZodString;
|
|
114
|
+
rowsRead: z.ZodString;
|
|
115
|
+
storage: z.ZodString;
|
|
116
|
+
requests: z.ZodString;
|
|
117
|
+
cpu: z.ZodString;
|
|
118
|
+
doRequests: z.ZodString;
|
|
119
|
+
duration: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
apps: z.ZodArray<z.ZodObject<{
|
|
122
|
+
vertical: z.ZodNullable<z.ZodString>;
|
|
123
|
+
kind: z.ZodEnum<{
|
|
124
|
+
live: "live";
|
|
125
|
+
preview: "preview";
|
|
126
|
+
}>;
|
|
127
|
+
wouldCostUsd: z.ZodString;
|
|
128
|
+
quantities: z.ZodObject<{
|
|
129
|
+
rowsWritten: z.ZodString;
|
|
130
|
+
rowsRead: z.ZodString;
|
|
131
|
+
storage: z.ZodString;
|
|
132
|
+
requests: z.ZodString;
|
|
133
|
+
cpu: z.ZodString;
|
|
134
|
+
doRequests: z.ZodString;
|
|
135
|
+
duration: z.ZodString;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
}, z.core.$strip>>;
|
|
138
|
+
days: z.ZodArray<z.ZodObject<{
|
|
139
|
+
day: z.ZodString;
|
|
140
|
+
read: z.ZodBoolean;
|
|
141
|
+
wouldCostUsd: z.ZodNullable<z.ZodString>;
|
|
142
|
+
liveWouldCostUsd: z.ZodNullable<z.ZodString>;
|
|
143
|
+
previewWouldCostUsd: z.ZodNullable<z.ZodString>;
|
|
144
|
+
quantities: z.ZodNullable<z.ZodObject<{
|
|
145
|
+
rowsWritten: z.ZodString;
|
|
146
|
+
rowsRead: z.ZodString;
|
|
147
|
+
storage: z.ZodString;
|
|
148
|
+
requests: z.ZodString;
|
|
149
|
+
cpu: z.ZodString;
|
|
150
|
+
doRequests: z.ZodString;
|
|
151
|
+
duration: z.ZodString;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
byApp: z.ZodArray<z.ZodObject<{
|
|
154
|
+
vertical: z.ZodNullable<z.ZodString>;
|
|
155
|
+
kind: z.ZodEnum<{
|
|
156
|
+
live: "live";
|
|
157
|
+
preview: "preview";
|
|
158
|
+
}>;
|
|
159
|
+
wouldCostUsd: z.ZodString;
|
|
160
|
+
}, z.core.$strip>>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
truncated: z.ZodBoolean;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
export type TenantPlatformUsage = z.infer<typeof tenantPlatformUsage>;
|
|
165
|
+
/**
|
|
166
|
+
* `GET /meters/platform-costs` (#3316), staff only: per tenant and per day, the attributed cost,
|
|
167
|
+
* the markup and the price; each tenant's costliest verticals and its preview share; and the
|
|
168
|
+
* unattributed residual (`unmapped`, `platform`, `unknown`), which has a cost and no price.
|
|
169
|
+
*/
|
|
170
|
+
export declare const staffPlatformCosts: z.ZodObject<{
|
|
171
|
+
since: z.ZodString;
|
|
172
|
+
until: z.ZodString;
|
|
173
|
+
readAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
|
|
174
|
+
state: z.ZodEnum<{
|
|
175
|
+
complete: "complete";
|
|
176
|
+
empty: "empty";
|
|
177
|
+
"not-read": "not-read";
|
|
178
|
+
partial: "partial";
|
|
179
|
+
}>;
|
|
180
|
+
readDays: z.ZodNumber;
|
|
181
|
+
totalDays: z.ZodNumber;
|
|
182
|
+
lastReadAt: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "Instant", "out">>;
|
|
183
|
+
days: z.ZodArray<z.ZodObject<{
|
|
184
|
+
day: z.ZodString;
|
|
185
|
+
read: z.ZodBoolean;
|
|
186
|
+
readAt: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "Instant", "out">>;
|
|
187
|
+
error: z.ZodNullable<z.ZodString>;
|
|
188
|
+
}, z.core.$strip>>;
|
|
189
|
+
rates: z.ZodArray<z.ZodObject<{
|
|
190
|
+
dimension: z.ZodEnum<{
|
|
191
|
+
"build-time": "build-time";
|
|
192
|
+
cpu: "cpu";
|
|
193
|
+
"do-requests": "do-requests";
|
|
194
|
+
duration: "duration";
|
|
195
|
+
"model-calls": "model-calls";
|
|
196
|
+
requests: "requests";
|
|
197
|
+
"rows-read": "rows-read";
|
|
198
|
+
"rows-written": "rows-written";
|
|
199
|
+
storage: "storage";
|
|
200
|
+
}>;
|
|
201
|
+
usd: z.ZodString;
|
|
202
|
+
per: z.ZodNumber;
|
|
203
|
+
unit: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
totals: z.ZodObject<{
|
|
206
|
+
costUsd: z.ZodString;
|
|
207
|
+
markupUsd: z.ZodNullable<z.ZodString>;
|
|
208
|
+
priceUsd: z.ZodNullable<z.ZodString>;
|
|
209
|
+
previewCostUsd: z.ZodString;
|
|
210
|
+
residualCostUsd: z.ZodString;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
tenants: z.ZodArray<z.ZodObject<{
|
|
213
|
+
costUsd: z.ZodString;
|
|
214
|
+
markupUsd: z.ZodNullable<z.ZodString>;
|
|
215
|
+
priceUsd: z.ZodNullable<z.ZodString>;
|
|
216
|
+
previewCostUsd: z.ZodString;
|
|
217
|
+
tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
|
|
218
|
+
topVerticals: z.ZodArray<z.ZodObject<{
|
|
219
|
+
costUsd: z.ZodString;
|
|
220
|
+
markupUsd: z.ZodNullable<z.ZodString>;
|
|
221
|
+
priceUsd: z.ZodNullable<z.ZodString>;
|
|
222
|
+
previewCostUsd: z.ZodString;
|
|
223
|
+
vertical: z.ZodNullable<z.ZodString>;
|
|
224
|
+
}, z.core.$strip>>;
|
|
225
|
+
days: z.ZodArray<z.ZodObject<{
|
|
226
|
+
costUsd: z.ZodString;
|
|
227
|
+
markupUsd: z.ZodNullable<z.ZodString>;
|
|
228
|
+
priceUsd: z.ZodNullable<z.ZodString>;
|
|
229
|
+
previewCostUsd: z.ZodString;
|
|
230
|
+
day: z.ZodString;
|
|
231
|
+
}, z.core.$strip>>;
|
|
232
|
+
}, z.core.$strip>>;
|
|
233
|
+
residual: z.ZodObject<{
|
|
234
|
+
unmapped: z.ZodString;
|
|
235
|
+
platform: z.ZodString;
|
|
236
|
+
unknown: z.ZodString;
|
|
237
|
+
costUsd: z.ZodString;
|
|
238
|
+
days: z.ZodArray<z.ZodObject<{
|
|
239
|
+
unmapped: z.ZodString;
|
|
240
|
+
platform: z.ZodString;
|
|
241
|
+
unknown: z.ZodString;
|
|
242
|
+
day: z.ZodString;
|
|
243
|
+
costUsd: z.ZodString;
|
|
244
|
+
}, z.core.$strip>>;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
truncated: z.ZodBoolean;
|
|
247
|
+
}, z.core.$strip>;
|
|
248
|
+
export type StaffPlatformCosts = z.infer<typeof staffPlatformCosts>;
|
|
249
|
+
/** Re-exported for the fold: the attributions a residual splits by. */
|
|
250
|
+
export declare const RESIDUAL_ATTRIBUTIONS: readonly ["unmapped", "platform", "unknown"];
|
|
251
|
+
//# sourceMappingURL=platform-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-usage.d.ts","sourceRoot":"","sources":["../src/platform-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK/F,oGAAoG;AACpG,eAAO,MAAM,yBAAyB,iGAQS,CAAC;AAChD,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,sBAAsB,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,EAajG,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,QAAQ,EAAE,CAU5D;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,sBAAsB,GAAG,IAAI,CAAC,CAOhG,CAAC;AAEF,wFAAwF;AACxF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErF;AAOD,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK1G;AAiBD,yHAAyH;AACzH,eAAO,MAAM,YAAY;6BACP,aAAa;0BAChB,UAAU;sBACd,SAAS;uBACR,UAAU;kBACf,KAAK;4BACK,YAAY;uBACjB,UAAU;CACqC,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;iBAA6B,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;EAAuD,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAiBpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+B9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAkBtE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgC7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,8CAAoG,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform usage, priced (#3316): what a team's apps used of Cloudflare, per day, and what it
|
|
3
|
+
* would cost at the platform's price.
|
|
4
|
+
*
|
|
5
|
+
* - **Cost** is the attributed quantity at Cloudflare's list price (`CLOUDFLARE_LIST_RATES`),
|
|
6
|
+
* before the account's included allowances, as the #3316 measurement priced it.
|
|
7
|
+
* - **Price** is cost × (1 + markup), the markup read from the schedule in force on each day
|
|
8
|
+
* (`priceCostRows`, `markup.ts`).
|
|
9
|
+
* - A tenant sees the price only (`tenantPlatformUsage`). Staff see cost, markup and price side
|
|
10
|
+
* by side, plus what no tenant is charged for (`staffPlatformCosts`).
|
|
11
|
+
*
|
|
12
|
+
* Every figure is a decimal string computed with the contracts helpers, never a float.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { costAttribution, costQuantity, utcDay } from './control-plane.js';
|
|
16
|
+
import { instant, tenantId } from './ids.js';
|
|
17
|
+
import { billedDimension, usageKind } from './markup.js';
|
|
18
|
+
import { mulDivDecimal } from './money.js';
|
|
19
|
+
/** The billed dimensions platform usage reports: Cloudflare's, in the order a reader scans them. */
|
|
20
|
+
export const PLATFORM_USAGE_DIMENSIONS = [
|
|
21
|
+
'rows-written',
|
|
22
|
+
'rows-read',
|
|
23
|
+
'storage',
|
|
24
|
+
'requests',
|
|
25
|
+
'cpu',
|
|
26
|
+
'do-requests',
|
|
27
|
+
'duration',
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Cloudflare's list prices for Workers and SQLite-backed Durable Objects, dated like the markup
|
|
31
|
+
* schedule: a change is a new entry with the UTC day it takes effect, so a past day keeps the
|
|
32
|
+
* price it was billed at. The figures are the public price list, the ones #3316's first
|
|
33
|
+
* measurement used.
|
|
34
|
+
*/
|
|
35
|
+
export const CLOUDFLARE_LIST_RATES = [
|
|
36
|
+
{
|
|
37
|
+
effectiveFrom: '2000-01-01',
|
|
38
|
+
rates: [
|
|
39
|
+
{ dimension: 'requests', usd: '0.30', per: 1_000_000, unit: 'requests' },
|
|
40
|
+
{ dimension: 'cpu', usd: '0.02', per: 1_000_000, unit: 'CPU ms' },
|
|
41
|
+
{ dimension: 'do-requests', usd: '0.15', per: 1_000_000, unit: 'Durable Object requests' },
|
|
42
|
+
{ dimension: 'duration', usd: '12.50', per: 1_000_000, unit: 'GB-s' },
|
|
43
|
+
{ dimension: 'rows-read', usd: '0.001', per: 1_000_000, unit: 'rows read' },
|
|
44
|
+
{ dimension: 'rows-written', usd: '1.00', per: 1_000_000, unit: 'rows written' },
|
|
45
|
+
{ dimension: 'storage', usd: '0.20', per: 1_000_000_000, unit: 'bytes per month' },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
/** The list rates in force on `day`, or none before the first entry. */
|
|
50
|
+
export function listRatesOn(day) {
|
|
51
|
+
let found = [];
|
|
52
|
+
let from = '';
|
|
53
|
+
for (const entry of CLOUDFLARE_LIST_RATES) {
|
|
54
|
+
if (entry.effectiveFrom <= day && entry.effectiveFrom >= from) {
|
|
55
|
+
found = entry.rates;
|
|
56
|
+
from = entry.effectiveFrom;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return found;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The billed dimension each rollup dimension is charged as, or null for one Cloudflare does not
|
|
63
|
+
* bill on SQLite-backed objects: their writes are billed as rows written, so the storage write
|
|
64
|
+
* units the analytics also report would count them twice.
|
|
65
|
+
*/
|
|
66
|
+
export const COST_DIMENSION_BILLED = {
|
|
67
|
+
worker_cpu_us: 'cpu',
|
|
68
|
+
do_requests: 'do-requests',
|
|
69
|
+
do_rows_read: 'rows-read',
|
|
70
|
+
do_rows_written: 'rows-written',
|
|
71
|
+
do_storage_write_units: null,
|
|
72
|
+
do_duration_gb_s: 'duration',
|
|
73
|
+
};
|
|
74
|
+
/** A rollup quantity in its billed unit: CPU µs become ms; every other unit is kept. */
|
|
75
|
+
export function platformQuantityOf(dimension, quantity) {
|
|
76
|
+
return dimension === 'worker_cpu_us' ? mulDivDecimal(quantity, '1', 1000) : quantity;
|
|
77
|
+
}
|
|
78
|
+
function daysInMonth(day) {
|
|
79
|
+
const [y, m] = day.split('-').map(Number);
|
|
80
|
+
return new Date(Date.UTC(y, m, 0)).getUTCDate();
|
|
81
|
+
}
|
|
82
|
+
/** A quantity's cost at list price on `day`, USD; null when no rate is in force for it. */
|
|
83
|
+
export function listCostOf(dimension, quantity, day) {
|
|
84
|
+
const rate = listRatesOn(day).find((r) => r.dimension === dimension);
|
|
85
|
+
if (!rate)
|
|
86
|
+
return null;
|
|
87
|
+
const per = dimension === 'storage' ? BigInt(rate.per) * BigInt(daysInMonth(day)) : rate.per;
|
|
88
|
+
return mulDivDecimal(quantity, rate.usd, per);
|
|
89
|
+
}
|
|
90
|
+
const usd = costQuantity;
|
|
91
|
+
/** One figure per reported dimension, keyed by `QUANTITY_KEY`. */
|
|
92
|
+
function perDimension(value) {
|
|
93
|
+
return z.object({
|
|
94
|
+
rowsWritten: value,
|
|
95
|
+
rowsRead: value,
|
|
96
|
+
storage: value,
|
|
97
|
+
requests: value,
|
|
98
|
+
cpu: value,
|
|
99
|
+
doRequests: value,
|
|
100
|
+
duration: value,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** The key each dimension's figure has in a quantities object: an identifier, so a generated client can name it bare. */
|
|
104
|
+
export const QUANTITY_KEY = {
|
|
105
|
+
'rows-written': 'rowsWritten',
|
|
106
|
+
'rows-read': 'rowsRead',
|
|
107
|
+
storage: 'storage',
|
|
108
|
+
requests: 'requests',
|
|
109
|
+
cpu: 'cpu',
|
|
110
|
+
'do-requests': 'doRequests',
|
|
111
|
+
duration: 'duration',
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* The quantities behind a figure, in each dimension's billed unit (`ListRate.unit`). `storage` is
|
|
115
|
+
* bytes stored on a day; over several days it is their sum, byte-days, which a reader divides by
|
|
116
|
+
* the days read for the average stored.
|
|
117
|
+
*/
|
|
118
|
+
export const platformQuantities = perDimension(costQuantity);
|
|
119
|
+
/**
|
|
120
|
+
* How much of the window the cost rollup has read. `not-read`: no day yet (the daily pass has
|
|
121
|
+
* not run, or has not reached these days), so an empty page says nothing about usage. `empty`:
|
|
122
|
+
* days were read and the team used nothing on them. `partial`: some days are still unread.
|
|
123
|
+
*/
|
|
124
|
+
export const platformUsageState = z.enum(['not-read', 'empty', 'partial', 'complete']);
|
|
125
|
+
const coverage = {
|
|
126
|
+
since: utcDay,
|
|
127
|
+
until: utcDay,
|
|
128
|
+
readAt: instant,
|
|
129
|
+
state: platformUsageState,
|
|
130
|
+
/** Days in the window the cost rollup has read. Only those are counted. */
|
|
131
|
+
readDays: z.number().int().nonnegative(),
|
|
132
|
+
totalDays: z.number().int().positive(),
|
|
133
|
+
/** The latest successful read of a day in the window. */
|
|
134
|
+
lastReadAt: instant.nullable(),
|
|
135
|
+
};
|
|
136
|
+
/** One app (a vertical, or none for usage that names none) of one kind. */
|
|
137
|
+
const appKey = { vertical: z.string().min(1).nullable(), kind: usageKind };
|
|
138
|
+
/**
|
|
139
|
+
* `GET /tenants/:tenantId/platform-usage` (#3316): what the team's apps used of the platform,
|
|
140
|
+
* per closed UTC day, and what it would cost at the platform's price. PRICE ONLY: neither the
|
|
141
|
+
* platform's cost nor its markup is in this shape. Nothing is charged yet (`chargedUsd` is 0).
|
|
142
|
+
*/
|
|
143
|
+
export const tenantPlatformUsage = z.object({
|
|
144
|
+
...coverage,
|
|
145
|
+
/** What the window would cost at the platform's price. */
|
|
146
|
+
wouldCostUsd: usd,
|
|
147
|
+
liveWouldCostUsd: usd,
|
|
148
|
+
previewWouldCostUsd: usd,
|
|
149
|
+
/** What is charged for it: nothing, while platform usage is shown before it is billed. */
|
|
150
|
+
chargedUsd: z.literal('0'),
|
|
151
|
+
quantities: platformQuantities,
|
|
152
|
+
/** Per app and kind over the window, costliest first. */
|
|
153
|
+
apps: z.array(z.object({
|
|
154
|
+
...appKey,
|
|
155
|
+
wouldCostUsd: usd,
|
|
156
|
+
quantities: platformQuantities,
|
|
157
|
+
})),
|
|
158
|
+
/** Every day of the window, oldest first. An unread day carries nulls, never zeros. */
|
|
159
|
+
days: z.array(z.object({
|
|
160
|
+
day: utcDay,
|
|
161
|
+
read: z.boolean(),
|
|
162
|
+
wouldCostUsd: usd.nullable(),
|
|
163
|
+
liveWouldCostUsd: usd.nullable(),
|
|
164
|
+
previewWouldCostUsd: usd.nullable(),
|
|
165
|
+
quantities: platformQuantities.nullable(),
|
|
166
|
+
byApp: z.array(z.object({ ...appKey, wouldCostUsd: usd })),
|
|
167
|
+
})),
|
|
168
|
+
/** A source capped its rows, so request or storage figures are a lower bound. */
|
|
169
|
+
truncated: z.boolean(),
|
|
170
|
+
});
|
|
171
|
+
/** Cost, markup (price − cost) and price side by side. Markup and price are null where no markup row is in force. */
|
|
172
|
+
const priced = {
|
|
173
|
+
costUsd: usd,
|
|
174
|
+
markupUsd: usd.nullable(),
|
|
175
|
+
priceUsd: usd.nullable(),
|
|
176
|
+
/** The part of `costUsd` that previews ran up. */
|
|
177
|
+
previewCostUsd: usd,
|
|
178
|
+
};
|
|
179
|
+
/** What is in the rollup but charged to no tenant, by why (`costAttribution`). */
|
|
180
|
+
const residualSplit = {
|
|
181
|
+
unmapped: usd,
|
|
182
|
+
platform: usd,
|
|
183
|
+
unknown: usd,
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* `GET /meters/platform-costs` (#3316), staff only: per tenant and per day, the attributed cost,
|
|
187
|
+
* the markup and the price; each tenant's costliest verticals and its preview share; and the
|
|
188
|
+
* unattributed residual (`unmapped`, `platform`, `unknown`), which has a cost and no price.
|
|
189
|
+
*/
|
|
190
|
+
export const staffPlatformCosts = z.object({
|
|
191
|
+
...coverage,
|
|
192
|
+
/** The cost rollup's record of each day in the window that it tried. */
|
|
193
|
+
days: z.array(z.object({
|
|
194
|
+
day: utcDay,
|
|
195
|
+
read: z.boolean(),
|
|
196
|
+
readAt: instant.nullable(),
|
|
197
|
+
error: z.string().nullable(),
|
|
198
|
+
})),
|
|
199
|
+
/** The list rates in force on `until`, the basis of every cost here. */
|
|
200
|
+
rates: z.array(z.object({ dimension: billedDimension, usd, per: z.number().int().positive(), unit: z.string() })),
|
|
201
|
+
totals: z.object({ ...priced, residualCostUsd: usd }),
|
|
202
|
+
/** Costliest first. */
|
|
203
|
+
tenants: z.array(z.object({
|
|
204
|
+
tenantId,
|
|
205
|
+
...priced,
|
|
206
|
+
/** The tenant's costliest verticals over the window, at most five. */
|
|
207
|
+
topVerticals: z.array(z.object({ vertical: z.string().min(1).nullable(), ...priced })),
|
|
208
|
+
/** The days it used anything, oldest first. */
|
|
209
|
+
days: z.array(z.object({ day: utcDay, ...priced })),
|
|
210
|
+
})),
|
|
211
|
+
residual: z.object({
|
|
212
|
+
costUsd: usd,
|
|
213
|
+
...residualSplit,
|
|
214
|
+
days: z.array(z.object({ day: utcDay, costUsd: usd, ...residualSplit })),
|
|
215
|
+
}),
|
|
216
|
+
/** A source capped its rows, so request or storage figures are a lower bound. */
|
|
217
|
+
truncated: z.boolean(),
|
|
218
|
+
});
|
|
219
|
+
/** Re-exported for the fold: the attributions a residual splits by. */
|
|
220
|
+
export const RESIDUAL_ATTRIBUTIONS = ['unmapped', 'platform', 'unknown'];
|
|
221
|
+
//# sourceMappingURL=platform-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-usage.js","sourceRoot":"","sources":["../src/platform-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAsB,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,oGAAoG;AACpG,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,cAAc;IACd,WAAW;IACX,SAAS;IACT,UAAU;IACV,KAAK;IACL,aAAa;IACb,UAAU;CACmC,CAAC;AAgBhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqE;IACrG;QACE,aAAa,EAAE,YAAY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,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;KACpD,CAAC,CACH;IACD,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,OAAO,EAAE,GAAG;QACZ,GAAG,aAAa;QAChB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC,CAAC;KACzE,CAAC;IACF,iFAAiF;IACjF,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;CACvB,CAAC,CAAC;AAGH,uEAAuE;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,CAA+D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.208.0",
|
|
4
4
|
"description": "Substrat kernel contract schemas — Zod is the source of truth (master plan D-22); OAS/JSON Schema are emitted artifacts",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|