@taggor/contract 0.0.0-stage → 0.1.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.
Files changed (339) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -2
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/artifact-keys.d.ts +169 -0
  5. package/dist/artifact-keys.d.ts.map +1 -0
  6. package/dist/artifact-keys.js +195 -0
  7. package/dist/artifact-keys.js.map +1 -0
  8. package/dist/assets.d.ts +72 -0
  9. package/dist/assets.d.ts.map +1 -0
  10. package/dist/assets.js +94 -0
  11. package/dist/assets.js.map +1 -0
  12. package/dist/bounded-path.d.ts +29 -0
  13. package/dist/bounded-path.d.ts.map +1 -0
  14. package/dist/bounded-path.js +57 -0
  15. package/dist/bounded-path.js.map +1 -0
  16. package/dist/bounded.d.ts +47 -0
  17. package/dist/bounded.d.ts.map +1 -0
  18. package/dist/bounded.js +93 -0
  19. package/dist/bounded.js.map +1 -0
  20. package/dist/build-diagnostic.d.ts +89 -0
  21. package/dist/build-diagnostic.d.ts.map +1 -0
  22. package/dist/build-diagnostic.js +91 -0
  23. package/dist/build-diagnostic.js.map +1 -0
  24. package/dist/component-types.d.ts +61 -0
  25. package/dist/component-types.d.ts.map +1 -0
  26. package/dist/component-types.js +277 -0
  27. package/dist/component-types.js.map +1 -0
  28. package/dist/consent-text.d.ts +31 -0
  29. package/dist/consent-text.d.ts.map +1 -0
  30. package/dist/consent-text.js +41 -0
  31. package/dist/consent-text.js.map +1 -0
  32. package/dist/contract-version.d.ts +150 -0
  33. package/dist/contract-version.d.ts.map +1 -0
  34. package/dist/contract-version.js +198 -0
  35. package/dist/contract-version.js.map +1 -0
  36. package/dist/credential-fields.d.ts +31 -0
  37. package/dist/credential-fields.d.ts.map +1 -0
  38. package/dist/credential-fields.js +36 -0
  39. package/dist/credential-fields.js.map +1 -0
  40. package/dist/css-tokens.d.ts +46 -0
  41. package/dist/css-tokens.d.ts.map +1 -0
  42. package/dist/css-tokens.js +189 -0
  43. package/dist/css-tokens.js.map +1 -0
  44. package/dist/css-value.d.ts +42 -0
  45. package/dist/css-value.d.ts.map +1 -0
  46. package/dist/css-value.js +78 -0
  47. package/dist/css-value.js.map +1 -0
  48. package/dist/data-api.d.ts +127 -0
  49. package/dist/data-api.d.ts.map +1 -0
  50. package/dist/data-api.js +167 -0
  51. package/dist/data-api.js.map +1 -0
  52. package/dist/denylist-keys.d.ts +19 -0
  53. package/dist/denylist-keys.d.ts.map +1 -0
  54. package/dist/denylist-keys.js +48 -0
  55. package/dist/denylist-keys.js.map +1 -0
  56. package/dist/diagnostic-catalog.d.ts +1402 -0
  57. package/dist/diagnostic-catalog.d.ts.map +1 -0
  58. package/dist/diagnostic-catalog.js +1311 -0
  59. package/dist/diagnostic-catalog.js.map +1 -0
  60. package/dist/dom-members.snapshot.d.ts +33 -0
  61. package/dist/dom-members.snapshot.d.ts.map +1 -0
  62. package/dist/dom-members.snapshot.js +760 -0
  63. package/dist/dom-members.snapshot.js.map +1 -0
  64. package/dist/early-loading.d.ts +27 -0
  65. package/dist/early-loading.d.ts.map +1 -0
  66. package/dist/early-loading.js +44 -0
  67. package/dist/early-loading.js.map +1 -0
  68. package/dist/error-catalog.d.ts +749 -0
  69. package/dist/error-catalog.d.ts.map +1 -0
  70. package/dist/error-catalog.js +720 -0
  71. package/dist/error-catalog.js.map +1 -0
  72. package/dist/executable-config.d.ts +35 -0
  73. package/dist/executable-config.d.ts.map +1 -0
  74. package/dist/executable-config.js +44 -0
  75. package/dist/executable-config.js.map +1 -0
  76. package/dist/freeze.d.ts +17 -0
  77. package/dist/freeze.d.ts.map +1 -0
  78. package/dist/freeze.js +29 -0
  79. package/dist/freeze.js.map +1 -0
  80. package/dist/gunzip.d.ts +33 -0
  81. package/dist/gunzip.d.ts.map +1 -0
  82. package/dist/gunzip.js +330 -0
  83. package/dist/gunzip.js.map +1 -0
  84. package/dist/hostname.d.ts +74 -0
  85. package/dist/hostname.d.ts.map +1 -0
  86. package/dist/hostname.js +215 -0
  87. package/dist/hostname.js.map +1 -0
  88. package/dist/human-actions.d.ts +49 -0
  89. package/dist/human-actions.d.ts.map +1 -0
  90. package/dist/human-actions.js +272 -0
  91. package/dist/human-actions.js.map +1 -0
  92. package/dist/index.d.ts +72 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.js +72 -0
  95. package/dist/index.js.map +1 -0
  96. package/dist/json-schema.d.ts +108 -0
  97. package/dist/json-schema.d.ts.map +1 -0
  98. package/dist/json-schema.js +240 -0
  99. package/dist/json-schema.js.map +1 -0
  100. package/dist/key-checksum.d.ts +33 -0
  101. package/dist/key-checksum.d.ts.map +1 -0
  102. package/dist/key-checksum.js +67 -0
  103. package/dist/key-checksum.js.map +1 -0
  104. package/dist/libraries.d.ts +60 -0
  105. package/dist/libraries.d.ts.map +1 -0
  106. package/dist/libraries.js +120 -0
  107. package/dist/libraries.js.map +1 -0
  108. package/dist/limit-catalog.d.ts +371 -0
  109. package/dist/limit-catalog.d.ts.map +1 -0
  110. package/dist/limit-catalog.js +414 -0
  111. package/dist/limit-catalog.js.map +1 -0
  112. package/dist/limits.d.ts +167 -0
  113. package/dist/limits.d.ts.map +1 -0
  114. package/dist/limits.js +175 -0
  115. package/dist/limits.js.map +1 -0
  116. package/dist/locale-tag.d.ts +21 -0
  117. package/dist/locale-tag.d.ts.map +1 -0
  118. package/dist/locale-tag.js +21 -0
  119. package/dist/locale-tag.js.map +1 -0
  120. package/dist/make-diagnostic.d.ts +74 -0
  121. package/dist/make-diagnostic.d.ts.map +1 -0
  122. package/dist/make-diagnostic.js +100 -0
  123. package/dist/make-diagnostic.js.map +1 -0
  124. package/dist/manifest-compat-diagnostics.d.ts +23 -0
  125. package/dist/manifest-compat-diagnostics.d.ts.map +1 -0
  126. package/dist/manifest-compat-diagnostics.js +150 -0
  127. package/dist/manifest-compat-diagnostics.js.map +1 -0
  128. package/dist/manifest-compat.d.ts +58 -0
  129. package/dist/manifest-compat.d.ts.map +1 -0
  130. package/dist/manifest-compat.js +377 -0
  131. package/dist/manifest-compat.js.map +1 -0
  132. package/dist/manifest.d.ts +1769 -0
  133. package/dist/manifest.d.ts.map +1 -0
  134. package/dist/manifest.js +421 -0
  135. package/dist/manifest.js.map +1 -0
  136. package/dist/metering.d.ts +126 -0
  137. package/dist/metering.d.ts.map +1 -0
  138. package/dist/metering.js +147 -0
  139. package/dist/metering.js.map +1 -0
  140. package/dist/migrate.d.ts +70 -0
  141. package/dist/migrate.d.ts.map +1 -0
  142. package/dist/migrate.js +159 -0
  143. package/dist/migrate.js.map +1 -0
  144. package/dist/names.d.ts +37 -0
  145. package/dist/names.d.ts.map +1 -0
  146. package/dist/names.js +55 -0
  147. package/dist/names.js.map +1 -0
  148. package/dist/overage-pricing.d.ts +89 -0
  149. package/dist/overage-pricing.d.ts.map +1 -0
  150. package/dist/overage-pricing.js +170 -0
  151. package/dist/overage-pricing.js.map +1 -0
  152. package/dist/plan-ids.d.ts +10 -0
  153. package/dist/plan-ids.d.ts.map +1 -0
  154. package/dist/plan-ids.js +8 -0
  155. package/dist/plan-ids.js.map +1 -0
  156. package/dist/plan-limits.d.ts +138 -0
  157. package/dist/plan-limits.d.ts.map +1 -0
  158. package/dist/plan-limits.js +112 -0
  159. package/dist/plan-limits.js.map +1 -0
  160. package/dist/plan-pricing.d.ts +145 -0
  161. package/dist/plan-pricing.d.ts.map +1 -0
  162. package/dist/plan-pricing.js +172 -0
  163. package/dist/plan-pricing.js.map +1 -0
  164. package/dist/plan-usage.d.ts +112 -0
  165. package/dist/plan-usage.d.ts.map +1 -0
  166. package/dist/plan-usage.js +134 -0
  167. package/dist/plan-usage.js.map +1 -0
  168. package/dist/preview-token.d.ts +52 -0
  169. package/dist/preview-token.d.ts.map +1 -0
  170. package/dist/preview-token.js +106 -0
  171. package/dist/preview-token.js.map +1 -0
  172. package/dist/prop-names.d.ts +51 -0
  173. package/dist/prop-names.d.ts.map +1 -0
  174. package/dist/prop-names.js +150 -0
  175. package/dist/prop-names.js.map +1 -0
  176. package/dist/prop-type-docs.d.ts +20 -0
  177. package/dist/prop-type-docs.d.ts.map +1 -0
  178. package/dist/prop-type-docs.js +89 -0
  179. package/dist/prop-type-docs.js.map +1 -0
  180. package/dist/prop-types.d.ts +97 -0
  181. package/dist/prop-types.d.ts.map +1 -0
  182. package/dist/prop-types.js +299 -0
  183. package/dist/prop-types.js.map +1 -0
  184. package/dist/props.d.ts +996 -0
  185. package/dist/props.d.ts.map +1 -0
  186. package/dist/props.js +183 -0
  187. package/dist/props.js.map +1 -0
  188. package/dist/proto-guard.d.ts +29 -0
  189. package/dist/proto-guard.d.ts.map +1 -0
  190. package/dist/proto-guard.js +79 -0
  191. package/dist/proto-guard.js.map +1 -0
  192. package/dist/runtime-errors.d.ts +42 -0
  193. package/dist/runtime-errors.d.ts.map +1 -0
  194. package/dist/runtime-errors.js +42 -0
  195. package/dist/runtime-errors.js.map +1 -0
  196. package/dist/runtime-pointers.d.ts +58 -0
  197. package/dist/runtime-pointers.d.ts.map +1 -0
  198. package/dist/runtime-pointers.js +84 -0
  199. package/dist/runtime-pointers.js.map +1 -0
  200. package/dist/secret-scan.d.ts +191 -0
  201. package/dist/secret-scan.d.ts.map +1 -0
  202. package/dist/secret-scan.js +542 -0
  203. package/dist/secret-scan.js.map +1 -0
  204. package/dist/semver.d.ts +89 -0
  205. package/dist/semver.d.ts.map +1 -0
  206. package/dist/semver.js +400 -0
  207. package/dist/semver.js.map +1 -0
  208. package/dist/server-key.d.ts +68 -0
  209. package/dist/server-key.d.ts.map +1 -0
  210. package/dist/server-key.js +150 -0
  211. package/dist/server-key.js.map +1 -0
  212. package/dist/site-manifest-keys.d.ts +107 -0
  213. package/dist/site-manifest-keys.d.ts.map +1 -0
  214. package/dist/site-manifest-keys.js +146 -0
  215. package/dist/site-manifest-keys.js.map +1 -0
  216. package/dist/site-manifest.d.ts +286 -0
  217. package/dist/site-manifest.d.ts.map +1 -0
  218. package/dist/site-manifest.js +100 -0
  219. package/dist/site-manifest.js.map +1 -0
  220. package/dist/source-archive.d.ts +119 -0
  221. package/dist/source-archive.d.ts.map +1 -0
  222. package/dist/source-archive.js +644 -0
  223. package/dist/source-archive.js.map +1 -0
  224. package/dist/source-package-corpus.d.ts +55 -0
  225. package/dist/source-package-corpus.d.ts.map +1 -0
  226. package/dist/source-package-corpus.js +303 -0
  227. package/dist/source-package-corpus.js.map +1 -0
  228. package/dist/source-package.d.ts +227 -0
  229. package/dist/source-package.d.ts.map +1 -0
  230. package/dist/source-package.js +361 -0
  231. package/dist/source-package.js.map +1 -0
  232. package/dist/source-secrets.d.ts +21 -0
  233. package/dist/source-secrets.d.ts.map +1 -0
  234. package/dist/source-secrets.js +43 -0
  235. package/dist/source-secrets.js.map +1 -0
  236. package/dist/ssr-cap.d.ts +61 -0
  237. package/dist/ssr-cap.d.ts.map +1 -0
  238. package/dist/ssr-cap.js +107 -0
  239. package/dist/ssr-cap.js.map +1 -0
  240. package/dist/ssr-kv.d.ts +18 -0
  241. package/dist/ssr-kv.d.ts.map +1 -0
  242. package/dist/ssr-kv.js +18 -0
  243. package/dist/ssr-kv.js.map +1 -0
  244. package/dist/ssr-version-ledger.d.ts +53 -0
  245. package/dist/ssr-version-ledger.d.ts.map +1 -0
  246. package/dist/ssr-version-ledger.js +88 -0
  247. package/dist/ssr-version-ledger.js.map +1 -0
  248. package/dist/style-references.d.ts +58 -0
  249. package/dist/style-references.d.ts.map +1 -0
  250. package/dist/style-references.js +241 -0
  251. package/dist/style-references.js.map +1 -0
  252. package/dist/tag-name.d.ts +87 -0
  253. package/dist/tag-name.d.ts.map +1 -0
  254. package/dist/tag-name.js +222 -0
  255. package/dist/tag-name.js.map +1 -0
  256. package/dist/tar-writer.d.ts +74 -0
  257. package/dist/tar-writer.d.ts.map +1 -0
  258. package/dist/tar-writer.js +148 -0
  259. package/dist/tar-writer.js.map +1 -0
  260. package/dist/testing.d.ts +11 -0
  261. package/dist/testing.d.ts.map +1 -0
  262. package/dist/testing.js +11 -0
  263. package/dist/testing.js.map +1 -0
  264. package/dist/text-codec.d.ts +36 -0
  265. package/dist/text-codec.d.ts.map +1 -0
  266. package/dist/text-codec.js +32 -0
  267. package/dist/text-codec.js.map +1 -0
  268. package/dist/url-value.d.ts +41 -0
  269. package/dist/url-value.d.ts.map +1 -0
  270. package/dist/url-value.js +147 -0
  271. package/dist/url-value.js.map +1 -0
  272. package/dist/usage-guard.d.ts +99 -0
  273. package/dist/usage-guard.d.ts.map +1 -0
  274. package/dist/usage-guard.js +104 -0
  275. package/dist/usage-guard.js.map +1 -0
  276. package/dist/usage-mirror.d.ts +55 -0
  277. package/dist/usage-mirror.d.ts.map +1 -0
  278. package/dist/usage-mirror.js +52 -0
  279. package/dist/usage-mirror.js.map +1 -0
  280. package/dist/value-check.d.ts +88 -0
  281. package/dist/value-check.d.ts.map +1 -0
  282. package/dist/value-check.js +279 -0
  283. package/dist/value-check.js.map +1 -0
  284. package/dist/value-patterns.d.ts +9 -0
  285. package/dist/value-patterns.d.ts.map +1 -0
  286. package/dist/value-patterns.js +17 -0
  287. package/dist/value-patterns.js.map +1 -0
  288. package/dist/value-schema.d.ts +796 -0
  289. package/dist/value-schema.d.ts.map +1 -0
  290. package/dist/value-schema.js +231 -0
  291. package/dist/value-schema.js.map +1 -0
  292. package/dist/zod-free.d.ts +59 -0
  293. package/dist/zod-free.d.ts.map +1 -0
  294. package/dist/zod-free.js +57 -0
  295. package/dist/zod-free.js.map +1 -0
  296. package/package.json +75 -3
  297. package/schema/DEPLOYED +12 -0
  298. package/schema/build-diagnostic.v1.json +63 -0
  299. package/schema/component-manifest.v1.json +1000 -0
  300. package/schema/data-api.v1.json +194 -0
  301. package/schema/library-manifest.v1.json +60 -0
  302. package/schema/published/SHA256SUMS +36 -0
  303. package/schema/published/build-diagnostic/v1.10.json +83 -0
  304. package/schema/published/build-diagnostic/v1.3.json +83 -0
  305. package/schema/published/build-diagnostic/v1.4.json +83 -0
  306. package/schema/published/build-diagnostic/v1.5.json +83 -0
  307. package/schema/published/build-diagnostic/v1.6.json +83 -0
  308. package/schema/published/build-diagnostic/v1.7.json +83 -0
  309. package/schema/published/build-diagnostic/v1.8.json +83 -0
  310. package/schema/published/build-diagnostic/v1.9.json +83 -0
  311. package/schema/published/component-manifest/v1.10.json +1443 -0
  312. package/schema/published/component-manifest/v1.3.json +1411 -0
  313. package/schema/published/component-manifest/v1.4.json +1419 -0
  314. package/schema/published/component-manifest/v1.5.json +1437 -0
  315. package/schema/published/component-manifest/v1.6.json +1437 -0
  316. package/schema/published/component-manifest/v1.7.json +1437 -0
  317. package/schema/published/component-manifest/v1.8.json +1437 -0
  318. package/schema/published/component-manifest/v1.9.json +1437 -0
  319. package/schema/published/data-api/v1.10.json +282 -0
  320. package/schema/published/data-api/v1.3.json +281 -0
  321. package/schema/published/data-api/v1.4.json +281 -0
  322. package/schema/published/data-api/v1.5.json +281 -0
  323. package/schema/published/data-api/v1.6.json +281 -0
  324. package/schema/published/data-api/v1.7.json +281 -0
  325. package/schema/published/data-api/v1.8.json +282 -0
  326. package/schema/published/data-api/v1.9.json +282 -0
  327. package/schema/published/library-manifest/v1.10.json +68 -0
  328. package/schema/published/library-manifest/v1.5.json +68 -0
  329. package/schema/published/library-manifest/v1.6.json +68 -0
  330. package/schema/published/library-manifest/v1.7.json +68 -0
  331. package/schema/published/library-manifest/v1.8.json +68 -0
  332. package/schema/published/library-manifest/v1.9.json +68 -0
  333. package/schema/published/taggor-config/v1.10.json +56 -0
  334. package/schema/published/taggor-config/v1.5.json +56 -0
  335. package/schema/published/taggor-config/v1.6.json +56 -0
  336. package/schema/published/taggor-config/v1.7.json +56 -0
  337. package/schema/published/taggor-config/v1.8.json +56 -0
  338. package/schema/published/taggor-config/v1.9.json +56 -0
  339. package/schema/taggor-config.v1.json +39 -0
@@ -0,0 +1,170 @@
1
+ /**
2
+ * The overage rate table as DATA (TAG-1629, owner decision of 2026-11-14): one row per
3
+ * (metric, paid plan, version) with the instant it starts to apply, in micro US dollars. The rows
4
+ * live in the database (`overage_rates`) and staff edits them; `OVERAGE_RATES` in `plan-pricing.ts`
5
+ * is only the seed of version 1. This module is the pure part every reader shares: the row shape,
6
+ * the lookup "which rate applies at this instant", the seed rows, and the public JSON of
7
+ * `GET /v1/pricing` with its parser (the static site reads it at build time, the portal and the
8
+ * CLI at run time). Zod-free, no I/O, no clock.
9
+ *
10
+ * Safety rule: a lookup that finds no rate answers `null`, and a `null` rate means "do not bill"
11
+ * (the callers alert); nothing here ever invents a price.
12
+ */
13
+ import { OVERAGE_METRICS } from "./limit-catalog.js";
14
+ import { OVERAGE_RATES } from "./plan-pricing.js";
15
+ /** The paid plans a rate row can name. */
16
+ export const OVERAGE_RATE_PLANS = Object.freeze(["pro", "agency"]);
17
+ /** The instant of the seed rows: the beginning of time, so the seed always applies until replaced. */
18
+ export const SEED_EFFECTIVE_FROM = new Date(0);
19
+ /**
20
+ * The rows migration 0081 seeds, built from `OVERAGE_RATES`. Output: one row per metric and paid
21
+ * plan, version 1, in the metric order. Pure.
22
+ */
23
+ export function seedRateVersions() {
24
+ return OVERAGE_METRICS.flatMap((metric) => OVERAGE_RATE_PLANS.map((plan) => ({
25
+ metric,
26
+ plan,
27
+ version: 1,
28
+ microUsdPerUnit: OVERAGE_RATES[metric].microUsdPerUnit[plan],
29
+ effectiveFrom: SEED_EFFECTIVE_FROM,
30
+ })));
31
+ }
32
+ /** The map key of a (metric, plan id) pair. */
33
+ const rateKey = (metric, planId) => [metric, planId].join(":");
34
+ /**
35
+ * Builds the table that applies at an instant from every known version.
36
+ * Inputs: the rows (any order, any number per metric and plan) and the instant. Output: the table;
37
+ * for each (metric, plan) the row with the greatest `effectiveFrom` not after `at` wins, a tie goes
38
+ * to the higher version. Errors: none. Pure.
39
+ */
40
+ export function rateTableAt(rows, at) {
41
+ const best = new Map();
42
+ for (const row of rows) {
43
+ if (row.effectiveFrom.getTime() > at.getTime())
44
+ continue;
45
+ const key = rateKey(row.metric, row.plan);
46
+ const held = best.get(key);
47
+ if (held === undefined ||
48
+ row.effectiveFrom.getTime() > held.effectiveFrom.getTime() ||
49
+ (row.effectiveFrom.getTime() === held.effectiveFrom.getTime() && row.version > held.version)) {
50
+ best.set(key, row);
51
+ }
52
+ }
53
+ const find = (metric, planId) => best.get(rateKey(metric, planId));
54
+ return {
55
+ rateOf: (metric, planId) => find(metric, planId)?.microUsdPerUnit ?? null,
56
+ versionOf: (metric, planId) => find(metric, planId)?.version ?? null,
57
+ };
58
+ }
59
+ /** The table of the seed (what every reader falls back to when the database cannot be read). */
60
+ export const SEED_RATE_TABLE = rateTableAt(seedRateVersions(), new Date());
61
+ /**
62
+ * The public pricing from every known version.
63
+ * Inputs: the rows and the instant. Output: `rates` (one per metric and plan, in force at `at`) and
64
+ * `upcoming` (versions that start later, soonest first). Pure.
65
+ */
66
+ export function publicPricingAt(rows, at) {
67
+ const table = rateTableAt(rows, at);
68
+ const toPublic = (row) => ({
69
+ metric: row.metric,
70
+ plan: row.plan,
71
+ unit: OVERAGE_RATES[row.metric].unit,
72
+ microUsdPerUnit: row.microUsdPerUnit,
73
+ version: row.version,
74
+ effectiveFrom: row.effectiveFrom.toISOString(),
75
+ });
76
+ const inForce = [];
77
+ for (const metric of OVERAGE_METRICS) {
78
+ for (const plan of OVERAGE_RATE_PLANS) {
79
+ const version = table.versionOf(metric, plan);
80
+ const row = rows.find((r) => r.metric === metric && r.plan === plan && r.version === version);
81
+ if (row !== undefined)
82
+ inForce.push(toPublic(row));
83
+ }
84
+ }
85
+ const upcoming = rows
86
+ .filter((row) => row.effectiveFrom.getTime() > at.getTime())
87
+ .sort((a, b) => a.effectiveFrom.getTime() - b.effectiveFrom.getTime())
88
+ .map(toPublic);
89
+ return { rates: inForce, upcoming };
90
+ }
91
+ /** The seed as a public pricing: the fallback of the static site when the API is down. Pure. */
92
+ export function seedPublicPricing() {
93
+ return publicPricingAt(seedRateVersions(), new Date());
94
+ }
95
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
96
+ function parseRate(value) {
97
+ if (!isRecord(value))
98
+ return null;
99
+ const { metric, plan, unit, micro_usd_per_unit: micro, version, effective_from: from } = value;
100
+ if (typeof metric !== "string" || !OVERAGE_METRICS.includes(metric)) {
101
+ return null;
102
+ }
103
+ const paidPlan = OVERAGE_RATE_PLANS.find((candidate) => candidate === plan);
104
+ if (paidPlan === undefined)
105
+ return null;
106
+ if (unit !== "unit" && unit !== "mb")
107
+ return null;
108
+ if (typeof micro !== "number" || !Number.isSafeInteger(micro) || micro < 0)
109
+ return null;
110
+ if (typeof version !== "number" || !Number.isInteger(version) || version < 1)
111
+ return null;
112
+ if (typeof from !== "string" || Number.isNaN(Date.parse(from)))
113
+ return null;
114
+ return {
115
+ metric: metric,
116
+ plan: paidPlan,
117
+ unit,
118
+ microUsdPerUnit: micro,
119
+ version,
120
+ effectiveFrom: new Date(from).toISOString(),
121
+ };
122
+ }
123
+ /**
124
+ * Parses the JSON of `GET /v1/pricing` (snake_case keys) into a `PublicPricing`.
125
+ * Inputs: the decoded body. Output: the pricing, or `null` when the shape is wrong or any metric
126
+ * and plan has no rate in force (a page must never be built from a partial table). Pure.
127
+ */
128
+ export function parsePublicPricing(body) {
129
+ if (!isRecord(body) || !Array.isArray(body["rates"]) || !Array.isArray(body["upcoming"])) {
130
+ return null;
131
+ }
132
+ const rates = body["rates"].map(parseRate);
133
+ const upcoming = body["upcoming"].map(parseRate);
134
+ if (rates.includes(null) || upcoming.includes(null))
135
+ return null;
136
+ const good = rates;
137
+ for (const metric of OVERAGE_METRICS) {
138
+ for (const plan of OVERAGE_RATE_PLANS) {
139
+ if (!good.some((r) => r.metric === metric && r.plan === plan))
140
+ return null;
141
+ }
142
+ }
143
+ return { rates: good, upcoming: upcoming };
144
+ }
145
+ /** The wire form of a public pricing (snake_case), the inverse of `parsePublicPricing`. Pure. */
146
+ export function publicPricingJson(pricing) {
147
+ const wire = (r) => ({
148
+ metric: r.metric,
149
+ plan: r.plan,
150
+ unit: r.unit,
151
+ micro_usd_per_unit: r.microUsdPerUnit,
152
+ version: r.version,
153
+ effective_from: r.effectiveFrom,
154
+ });
155
+ return { rates: pricing.rates.map(wire), upcoming: pricing.upcoming.map(wire) };
156
+ }
157
+ /**
158
+ * The rate table a public pricing describes, for the texts that read rates by metric and plan.
159
+ * Inputs: the pricing. Output: a table over `rates` (the ones in force). Pure.
160
+ */
161
+ export function rateTableOfPricing(pricing) {
162
+ return rateTableAt(pricing.rates.map((r) => ({
163
+ metric: r.metric,
164
+ plan: r.plan,
165
+ version: r.version,
166
+ microUsdPerUnit: r.microUsdPerUnit,
167
+ effectiveFrom: new Date(r.effectiveFrom),
168
+ })), new Date(8.64e15));
169
+ }
170
+ //# sourceMappingURL=overage-pricing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overage-pricing.js","sourceRoot":"","sources":["../src/overage-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAsB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAqC,MAAM,mBAAmB,CAAC;AAErF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAA0B,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAa1F,sGAAsG;AACtG,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACxC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAChC,MAAM;QACN,IAAI;QACJ,OAAO,EAAE,CAAC;QACV,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC;QAC5D,aAAa,EAAE,mBAAmB;KACnC,CAAC,CA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e,EAAE,CAAC,CAAC,eAAe;QAClC,aAAa,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC;KACzC,CAAC,CAAC,EACH,IAAI,IAAI,CAAC,OAAO,CAAC,CAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The plan ids, apart from every table that has a row per plan (TAG-1627): the limit catalog
3
+ * (`limit-catalog.ts`) and `planLimits` both need them, and neither may import the other first.
4
+ * Zod-free.
5
+ */
6
+ /** The plans. A new plan is added here, with its default in every entry of the limit catalog. */
7
+ export declare const PLAN_IDS: readonly ["free", "pro", "agency"];
8
+ /** One plan. */
9
+ export type PlanId = (typeof PLAN_IDS)[number];
10
+ //# sourceMappingURL=plan-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-ids.d.ts","sourceRoot":"","sources":["../src/plan-ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iGAAiG;AACjG,eAAO,MAAM,QAAQ,oCAAoD,CAAC;AAE1E,gBAAgB;AAChB,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The plan ids, apart from every table that has a row per plan (TAG-1627): the limit catalog
3
+ * (`limit-catalog.ts`) and `planLimits` both need them, and neither may import the other first.
4
+ * Zod-free.
5
+ */
6
+ /** The plans. A new plan is added here, with its default in every entry of the limit catalog. */
7
+ export const PLAN_IDS = Object.freeze(["free", "pro", "agency"]);
8
+ //# sourceMappingURL=plan-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-ids.js","sourceRoot":"","sources":["../src/plan-ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iGAAiG;AACjG,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU,CAAC,CAAC"}
@@ -0,0 +1,138 @@
1
+ import { PLAN_IDS, type PlanId } from "./plan-ids.js";
2
+ export { PLAN_IDS, type PlanId };
3
+ /** The plan of a workspace without one (and of every build until workspaces have plans). */
4
+ export declare const DEFAULT_PLAN_ID: PlanId;
5
+ /** What one plan allows. Sizes are bytes, durations milliseconds. */
6
+ export interface PlanLimits {
7
+ /** One whole build; past it the build fails with `BUILD_TIMEOUT`. */
8
+ readonly buildTimeoutMs: number;
9
+ /** The compressed source package. */
10
+ readonly maxSourceBytes: number;
11
+ /** Regular files in the source package. */
12
+ readonly maxFiles: number;
13
+ /** Distinct packages the component's own files import by name (`preact`, `@taggor/component`). */
14
+ readonly maxDependencies: number;
15
+ /** What visitors download: the bundle and the CSS together. */
16
+ readonly maxOutputBytes: number;
17
+ /**
18
+ * One asset file a component imports (TAG-410: an image or a WOFF2 font, as stored), at most the
19
+ * contract's `ASSET_LIMITS.assetMaxBytes`; over it the build fails with `ASSET_TOO_LARGE`.
20
+ */
21
+ readonly maxAssetBytes: number;
22
+ /** All the asset files one component imports together (TAG-410, `ASSET_TOO_LARGE`). */
23
+ readonly maxAssetsBytes: number;
24
+ /**
25
+ * Builds a workspace may queue in a rolling 7-day window (the API's `POST /builds`, decision 78):
26
+ * one limit, one window, no hourly or daily sublimit beside it (decision 79).
27
+ */
28
+ readonly buildsPerWeek: number;
29
+ /** Builds of one workspace running at once; always fewer than the container instances. */
30
+ readonly concurrentBuilds: number;
31
+ }
32
+ /** The names of the limits of a plan. */
33
+ export type PlanLimitName = keyof PlanLimits;
34
+ /**
35
+ * The limits of every plan, by plan id.
36
+ *
37
+ * Inputs: none. Output: deeply frozen rows. Errors: none. Side effects: none.
38
+ */
39
+ export declare const planLimits: Readonly<Record<PlanId, PlanLimits>>;
40
+ /**
41
+ * Whether a value names a plan.
42
+ *
43
+ * Inputs: any value. Output: `true` for a key of `planLimits` (not inherited names such as
44
+ * `constructor`). Errors: none. Side effects: none.
45
+ */
46
+ export declare function isPlanId(value: unknown): value is PlanId;
47
+ /**
48
+ * The limits of a plan, falling back to the default plan.
49
+ *
50
+ * Inputs: a plan id, or `undefined` for a workspace (or build) without one. Output: that plan's
51
+ * row, `planLimits[DEFAULT_PLAN_ID]` for `undefined` or an unknown id. Errors: none. Side
52
+ * effects: none.
53
+ */
54
+ export declare function limitsOfPlan(planId: string | undefined): {
55
+ readonly planId: PlanId;
56
+ readonly limits: PlanLimits;
57
+ };
58
+ /**
59
+ * The plan with the lowest value above `current` for one limit, so a `LIMIT_EXCEEDED` diagnostic
60
+ * can say how to raise it.
61
+ *
62
+ * Inputs: the limit, the value the build had and (for tests) the table. Output: the plan id and
63
+ * its value, or `undefined` when no plan allows more. Errors: none. Side effects: none.
64
+ */
65
+ export declare function planAbove(limit: PlanLimitName, current: number, plans?: Readonly<Record<string, PlanLimits>>): {
66
+ readonly planId: string;
67
+ readonly value: number;
68
+ } | undefined;
69
+ /**
70
+ * Whole seconds from `now` to the next UTC midnight (at least 1): the `Retry-After` of every
71
+ * per-UTC-day limit.
72
+ *
73
+ * Inputs: the current time. Output: seconds. Errors: none. Side effects: none.
74
+ */
75
+ export declare function secondsUntilNextUtcDay(now: Date): number;
76
+ /** The window of `buildsPerWeek`: a rolling 7 days (decision 78). */
77
+ export declare const BUILD_WINDOW_MS: number;
78
+ /** When a full build window frees a place, and how long a client waits for it. */
79
+ export interface BuildWindowReset {
80
+ readonly resetsAt: Date;
81
+ /** Whole seconds from now to `resetsAt`, at least 1: the `Retry-After` of the 429. */
82
+ readonly retryAfterSeconds: number;
83
+ }
84
+ /**
85
+ * When the rolling 7-day window frees one place (`POST /builds` answers 429 with
86
+ * `Retry-After: retryAfterSeconds` at the limit).
87
+ *
88
+ * Inputs: the creation moment of the build that must age out for one more to fit (the
89
+ * `used - limit + 1`-th oldest of the window; the registry finds it) and the current time.
90
+ * Output: that moment plus 7 days and the whole seconds to wait (at least 1). Errors: none. Side
91
+ * effects: none.
92
+ */
93
+ export declare function buildWindowReset(freeingBuildCreatedAt: Date, now: Date): BuildWindowReset;
94
+ /** What each plan allows a workspace to HOLD (as opposed to `PlanLimits`, what one build may use). */
95
+ export interface PlanQuotas {
96
+ /** Sites (not deleted) at once; `POST /v1/sites` answers 409 `site_quota_exceeded` past it (TAG-622). */
97
+ readonly maxSites: number;
98
+ /** Unrevoked API keys at once; `POST /v1/api-keys` answers 409 `api_key_quota_exceeded` past it (TAG-924). */
99
+ readonly activeApiKeys: number;
100
+ /**
101
+ * Unrevoked API keys one admin or member may have created at once (TAG-2293); an owner is bound
102
+ * by `activeApiKeys` only. Past it, `POST /v1/api-keys` answers 409 `api_key_quota_exceeded`.
103
+ */
104
+ readonly activeApiKeysPerCreator: number;
105
+ /**
106
+ * Places of `activeApiKeys` that only an owner may fill (TAG-2293), so no admin or member, even
107
+ * several together, can leave the owner without a place to create a key.
108
+ */
109
+ readonly ownerReservedApiKeys: number;
110
+ /**
111
+ * Components attached to one site at once (TAG-1623, decision 77); an attach past it answers 409
112
+ * `site_component_limit`. PROVISIONAL until the owner approves the plans (TAG-1602). It only
113
+ * stops a NEW attach: after a downgrade, what is attached stays served (golden rule 2). The
114
+ * highest value is the platform ceiling `SITE_MANIFEST_MAX_COMPONENTS` (site-manifest.ts).
115
+ */
116
+ readonly componentsPerSite: number;
117
+ /**
118
+ * Network origins one version may declare in `permissions.connect` (TAG-1625, the old trust
119
+ * level's `connectOrigins`); a version past it is refused with 402 `plan_limit_reached` before
120
+ * the INSERT. PROVISIONAL until the owner approves the plans (TAG-1602).
121
+ */
122
+ readonly connectOriginsPerVersion: number;
123
+ }
124
+ /**
125
+ * The quotas of every plan, by plan id; kept apart from `planLimits` because the builder wording
126
+ * (`LIMIT_EXCEEDED` diagnostics) covers every key of that one.
127
+ *
128
+ * Inputs: none. Output: deeply frozen rows. Errors: none. Side effects: none.
129
+ */
130
+ export declare const planQuotas: Readonly<Record<PlanId, PlanQuotas>>;
131
+ /**
132
+ * The quotas of a plan, falling back to the default plan.
133
+ *
134
+ * Inputs: a plan id or `undefined`. Output: that plan's row, the default plan's for `undefined` or
135
+ * an unknown id. Errors: none. Side effects: none.
136
+ */
137
+ export declare function quotasOfPlan(planId: string | undefined): PlanQuotas;
138
+ //# sourceMappingURL=plan-limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-limits.d.ts","sourceRoot":"","sources":["../src/plan-limits.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;AAEjC,4FAA4F;AAC5F,eAAO,MAAM,eAAe,EAAE,MAAe,CAAC;AAE9C,qEAAqE;AACrE,MAAM,WAAW,UAAU;IACzB,qEAAqE;IACrE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,qCAAqC;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,kGAAkG;IAClG,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,+DAA+D;IAC/D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,uFAAuF;IACvF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,0FAA0F;IAC1F,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAED,yCAAyC;AACzC,MAAM,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC;AAM7C;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAqB,CAAC;AAElF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAA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,CAAC,wBAAwB,EAAE,MAAM,CAAC;CAC3C;AAID;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAA0B,CAAC;AAEvF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAEnE"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * `planLimits` (TAG-413): the single table of what each plan allows a workspace to build. Zod-free.
3
+ *
4
+ * The builder reads it for every build (timeout, source size, files, dependencies, output size,
5
+ * asset sizes since TAG-410, builds at once) and the API reads it before queueing one (builds per
6
+ * rolling week, `POST /builds` answers 429 with `Retry-After` past it, TAG-909, TAG-1624). Billing (E16, TAG-1603) reuses the same rows for its
7
+ * entitlements, so a limit lives here once. It sits in the contract because both the API and the
8
+ * builder already depend on it, and the customer's agent sees these numbers in the
9
+ * `LIMIT_EXCEEDED` diagnostics.
10
+ *
11
+ * The values are provisional until the owner approves the plans and prices (TAG-1602): today
12
+ * there is one plan, `free`, with the limits every build already had (TAG-401, TAG-1705), so
13
+ * nothing gets stricter. The builder's platform ceilings (`BUILD_LIMIT_BOUNDS`, tuned with the
14
+ * `TAGGOR_BUILD_MAX_*` variables) still cap every plan: a plan only lowers a limit, never raises
15
+ * it past what one container instance holds.
16
+ */
17
+ import { deepFreeze } from "./freeze.js";
18
+ import { catalogRows } from "./limit-catalog.js";
19
+ import { PLAN_IDS } from "./plan-ids.js";
20
+ export { PLAN_IDS };
21
+ /** The plan of a workspace without one (and of every build until workspaces have plans). */
22
+ export const DEFAULT_PLAN_ID = "free";
23
+ // The rows come from the limit catalog (`limit-catalog.ts`), the one place that holds the numbers
24
+ // (decision 79). The types check that the catalog's `build` group is exactly `PlanLimits`.
25
+ const table = catalogRows("build");
26
+ /**
27
+ * The limits of every plan, by plan id.
28
+ *
29
+ * Inputs: none. Output: deeply frozen rows. Errors: none. Side effects: none.
30
+ */
31
+ export const planLimits = deepFreeze(table);
32
+ /**
33
+ * Whether a value names a plan.
34
+ *
35
+ * Inputs: any value. Output: `true` for a key of `planLimits` (not inherited names such as
36
+ * `constructor`). Errors: none. Side effects: none.
37
+ */
38
+ export function isPlanId(value) {
39
+ return typeof value === "string" && Object.hasOwn(planLimits, value);
40
+ }
41
+ /**
42
+ * The limits of a plan, falling back to the default plan.
43
+ *
44
+ * Inputs: a plan id, or `undefined` for a workspace (or build) without one. Output: that plan's
45
+ * row, `planLimits[DEFAULT_PLAN_ID]` for `undefined` or an unknown id. Errors: none. Side
46
+ * effects: none.
47
+ */
48
+ export function limitsOfPlan(planId) {
49
+ const id = isPlanId(planId) ? planId : DEFAULT_PLAN_ID;
50
+ return { planId: id, limits: planLimits[id] };
51
+ }
52
+ /**
53
+ * The plan with the lowest value above `current` for one limit, so a `LIMIT_EXCEEDED` diagnostic
54
+ * can say how to raise it.
55
+ *
56
+ * Inputs: the limit, the value the build had and (for tests) the table. Output: the plan id and
57
+ * its value, or `undefined` when no plan allows more. Errors: none. Side effects: none.
58
+ */
59
+ export function planAbove(limit, current, plans = planLimits) {
60
+ let best;
61
+ for (const [planId, limits] of Object.entries(plans)) {
62
+ const value = limits[limit];
63
+ if (value > current && (best === undefined || value < best.value))
64
+ best = { planId, value };
65
+ }
66
+ return best;
67
+ }
68
+ const DAY_MS = 24 * 60 * 60 * 1000;
69
+ /**
70
+ * Whole seconds from `now` to the next UTC midnight (at least 1): the `Retry-After` of every
71
+ * per-UTC-day limit.
72
+ *
73
+ * Inputs: the current time. Output: seconds. Errors: none. Side effects: none.
74
+ */
75
+ export function secondsUntilNextUtcDay(now) {
76
+ const nextMidnight = (Math.floor(now.getTime() / DAY_MS) + 1) * DAY_MS;
77
+ return Math.max(1, Math.ceil((nextMidnight - now.getTime()) / 1000));
78
+ }
79
+ /** The window of `buildsPerWeek`: a rolling 7 days (decision 78). */
80
+ export const BUILD_WINDOW_MS = 7 * DAY_MS;
81
+ /**
82
+ * When the rolling 7-day window frees one place (`POST /builds` answers 429 with
83
+ * `Retry-After: retryAfterSeconds` at the limit).
84
+ *
85
+ * Inputs: the creation moment of the build that must age out for one more to fit (the
86
+ * `used - limit + 1`-th oldest of the window; the registry finds it) and the current time.
87
+ * Output: that moment plus 7 days and the whole seconds to wait (at least 1). Errors: none. Side
88
+ * effects: none.
89
+ */
90
+ export function buildWindowReset(freeingBuildCreatedAt, now) {
91
+ const resetsAt = new Date(freeingBuildCreatedAt.getTime() + BUILD_WINDOW_MS);
92
+ const retryAfterSeconds = Math.max(1, Math.ceil((resetsAt.getTime() - now.getTime()) / 1000));
93
+ return { resetsAt, retryAfterSeconds };
94
+ }
95
+ const quotaTable = catalogRows("quota");
96
+ /**
97
+ * The quotas of every plan, by plan id; kept apart from `planLimits` because the builder wording
98
+ * (`LIMIT_EXCEEDED` diagnostics) covers every key of that one.
99
+ *
100
+ * Inputs: none. Output: deeply frozen rows. Errors: none. Side effects: none.
101
+ */
102
+ export const planQuotas = deepFreeze(quotaTable);
103
+ /**
104
+ * The quotas of a plan, falling back to the default plan.
105
+ *
106
+ * Inputs: a plan id or `undefined`. Output: that plan's row, the default plan's for `undefined` or
107
+ * an unknown id. Errors: none. Side effects: none.
108
+ */
109
+ export function quotasOfPlan(planId) {
110
+ return planQuotas[isPlanId(planId) ? planId : DEFAULT_PLAN_ID];
111
+ }
112
+ //# sourceMappingURL=plan-limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-limits.js","sourceRoot":"","sources":["../src/plan-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAe,CAAC;AAEjC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAW,MAA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I,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACvE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC;AAS1C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,qBAA2B,EAAE,GAAS;IACrE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC,CAAC;IAC7E,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAC9F,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;AACzC,CAAC;AAiCD,MAAM,UAAU,GAA+B,WAAW,CAAC,OAAO,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAyC,UAAU,CAAC,UAAU,CAAC,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,145 @@
1
+ import type { PlanId } from "./plan-limits.js";
2
+ import { type OverageMetric } from "./limit-catalog.js";
3
+ /** An amount in US dollar cents, per month and per year (billed once a year). */
4
+ export interface PlanMoney {
5
+ readonly monthly: number;
6
+ readonly annual: number;
7
+ }
8
+ /** The Agency's growth past its included sites: one more site costs money and raises two ceilings. */
9
+ export interface PlanSiteExtension {
10
+ /** Sites in the plan's price (the plan's `maxSites` quota). */
11
+ readonly includedSites: number;
12
+ /** The most sites with add-ons. */
13
+ readonly maxSites: number;
14
+ readonly extraSitePriceUsdCents: PlanMoney;
15
+ /** What each extra site adds to the monthly renders ceiling. */
16
+ readonly rendersPerExtraSite: number;
17
+ /** What each extra site adds to the monthly submissions ceiling. */
18
+ readonly submissionsPerExtraSite: number;
19
+ }
20
+ /** The price of one plan and its site extension (null when the plan has none). */
21
+ export interface PlanPricing {
22
+ readonly priceUsdCents: PlanMoney;
23
+ readonly siteExtension: PlanSiteExtension | null;
24
+ }
25
+ /** The pricing of every plan, by plan id. Frozen. */
26
+ export declare const planPricing: Readonly<Record<PlanId, PlanPricing>>;
27
+ /** A plan that pays: the only ones that can have an overage. */
28
+ export type PaidPlanId = Exclude<PlanId, "free">;
29
+ /**
30
+ * What one billed unit is: `unit` is one counted thing; `mb` is one megabyte (10^6 bytes) held at the
31
+ * average of the cycle's daily readings (storage: US$ 0,35 per GB-month is 350 micro USD per MB, a whole number).
32
+ */
33
+ export type OverageUnit = "unit" | "mb";
34
+ /**
35
+ * The price of one billed metric. Money is in micro US dollars (10^-6 USD) per unit, an integer, so
36
+ * US$ 0,02 per 1.000 renders is exactly 20 per render with no float. Free has no rate: it is cut.
37
+ */
38
+ export interface OverageRate {
39
+ readonly metric: OverageMetric;
40
+ readonly unit: OverageUnit;
41
+ readonly microUsdPerUnit: Readonly<Record<PaidPlanId, number>>;
42
+ }
43
+ /**
44
+ * THE SEED of the rate table (TAG-1629, owner 2026-11-14): the tariffs live in the database
45
+ * (`overage_rates`, versions with an effective date, edited by staff with a reason) and this table
46
+ * is only what migration 0081 inserted as version 1 and what every reader falls back to when the
47
+ * database cannot be read. A test compares it with the migration; nothing else reads it for a price.
48
+ *
49
+ * The tariffs of decision 84 (provisional, pendency 76), in micro USD per unit:
50
+ * renders US$ 0,02 per 1.000; SSR renders US$ 0,015 per 1.000; SSR version-day US$ 0,01 (no
51
+ * included amount in v1); build over the weekly limit US$ 0,01; stored submission US$ 0,25 per
52
+ * 1.000; storage US$ 0,35 per GB-month (350 per MB, on the average of the cycle's daily readings); extra site US$ 1 (Pro) and US$ 2 (Agency, the existing
53
+ * add-on price, billed on the plan subscription, so its overage rate is informational).
54
+ */
55
+ export declare const OVERAGE_RATES: Readonly<Record<OverageMetric, OverageRate>>;
56
+ /** The metrics in a fixed order (ledger and Stripe meters follow it). */
57
+ export declare const OVERAGE_METRIC_LIST: readonly OverageMetric[];
58
+ /**
59
+ * The rules around the money of an overage (decision 84, ADR 0067), numbers only:
60
+ * - `minInvoiceUsdCents`: below it the amount carries to the next month.
61
+ * - `lagHours`: the ledger bills what was counted at least this long ago, never the live count.
62
+ * - NO default spending limit (owner, 2026-11-14, TAG-1629): the customer pays what they use. A
63
+ * spending LIMIT is OPTIONAL, set by the customer or by staff, between `spendCapMinUsdCents` and
64
+ * `spendCapMaxUsdCents` (staff: `staffSpendCapMaxUsdCents`). It is a trigger, not a ceiling on the
65
+ * bill: Taggor TRIES to stop the use when the overage reaches it, WITHOUT guarantee, and what was
66
+ * really used is billed. `capNoticePercents` are the e-mails of a limit that exists.
67
+ * - Spend milestones: the customer warns themselves at amounts of overage accrued in a cycle, one
68
+ * e-mail per milestone per cycle. `spendMilestonePercents` are the named steps of the DEFAULT list
69
+ * (percent of the plan's monthly price: 50%, 100%, 200%, 500%); from there it keeps going, doubling
70
+ * from `spendMilestoneDoublingFrom` (1000%, 2000%, 4000%...) up to `maxSpendMilestones` milestones
71
+ * in all (`defaultSpendMilestonePercents`), so a runaway use keeps warning past 500% (TAG-1629
72
+ * review M4). The customer may set their own list of up to `maxSpendMilestones` amounts, each at
73
+ * most `spendMilestoneMaxUsdCents`.
74
+ * - `dunningDays`: how long an unpaid overage invoice is chased before new overage is suspended.
75
+ * - `freeCutMultiple`: Free is cut at this multiple of its number (1x, no grace).
76
+ */
77
+ export declare const OVERAGE_RULES: Readonly<{
78
+ minInvoiceUsdCents: 100;
79
+ lagHours: 48;
80
+ spendCapMinUsdCents: 100;
81
+ spendCapMaxUsdCents: 1000000;
82
+ staffSpendCapMaxUsdCents: 10000000;
83
+ capNoticePercents: readonly number[];
84
+ spendMilestonePercents: readonly number[];
85
+ spendMilestoneDoublingFrom: 1000;
86
+ maxSpendMilestones: 10;
87
+ spendMilestoneMaxUsdCents: 1000000;
88
+ dunningDays: 14;
89
+ freeCutMultiple: 1;
90
+ }>;
91
+ /**
92
+ * The DEFAULT spend milestones as percents of the plan's monthly price: the named steps, then
93
+ * doubling from `spendMilestoneDoublingFrom` until `maxSpendMilestones` are listed (50, 100, 200, 500,
94
+ * 1000, 2000, 4000, 8000, 16000, 32000). Inputs: none. Output: a new ascending list. Pure.
95
+ */
96
+ export declare function defaultSpendMilestonePercents(): readonly number[];
97
+ /**
98
+ * The rate of a metric for a paid plan.
99
+ * Inputs: a metric and a plan id. Output: micro USD per unit, or `null` for Free (it never pays an
100
+ * overage). Errors: none. No side effects.
101
+ */
102
+ export declare function overageMicroUsdPerUnit(metric: OverageMetric, planId: PlanId): number | null;
103
+ /**
104
+ * Which of the forgeable metrics are billed (TAG-1628 review M1 and L2, ADR 0067 item 8; ON since
105
+ * TAG-1629, decision 84 amendment of 2026-11-14). A render and a stored submission can be forged by
106
+ * anyone with the public site key, so they were kept off the bill until a guard existed. The owner
107
+ * decided that a customer pays what was used, so the three metrics are billed; the guard (a spike
108
+ * flag per site, `usage-guard.ts`) no longer holds anything back, it only keeps the Free plan from
109
+ * being cut by forged traffic and warns the customer of an unusual day, and the safety net for a wrong
110
+ * bill is the credit on request (runbook). The switch stays in ONE place: the billing code of the API
111
+ * derives its `OVERAGE_BILLING_FROM_*` constants from it, and the site, the portal and the CLI choose
112
+ * their wording by `isOverageMetricBilled`, so a switch changes the code and every text together. A
113
+ * gate only has an effect while the API's overage mode is not `off`. Changing it is an
114
+ * ADR-level decision, never a drive-by edit.
115
+ */
116
+ export interface OverageBillingGates {
117
+ /** The renders metric (`loader_hits`). */
118
+ readonly loaderHits: boolean;
119
+ /** The submissions metric and the storage that follows it. */
120
+ readonly submissions: boolean;
121
+ }
122
+ /** The gates as the code ships them: both on (TAG-1629); frozen, the literal types are `true`. */
123
+ export declare const OVERAGE_BILLING_GATES: Readonly<{
124
+ readonly loaderHits: true;
125
+ readonly submissions: true;
126
+ }>;
127
+ /**
128
+ * Whether the excess of a metric is billed automatically (and so spends the customer's cap, raises a
129
+ * cap notice and counts in the cost estimate). Renders when `gates.loaderHits`; submissions and
130
+ * storage when `gates.submissions`; builds, extra sites and SSR always.
131
+ * Inputs: a metric and the gates (default: as shipped). Output: a boolean. Pure.
132
+ */
133
+ export declare function isOverageMetricBilled(metric: OverageMetric, gates?: OverageBillingGates): boolean;
134
+ /**
135
+ * Whether going past a catalog limit is billed automatically today on a paid plan: the limit is
136
+ * `metered` on Pro (Agency matches) and its metric is billed (`isOverageMetricBilled`). A limit that
137
+ * is `hard` on every plan (a security or per-build cap), an unknown name and a metered limit whose
138
+ * metric's gate is off are all false. The portal and the CLI
139
+ * word a limit row with it.
140
+ * Inputs: a limit name (any string) and the gates (default: as shipped). Output: a boolean. Pure.
141
+ */
142
+ export declare function isLimitOverageBilled(name: string, gates?: OverageBillingGates): boolean;
143
+ /** The metrics billed today, in the fixed metric order: derived from the gates, never typed. */
144
+ export declare const BILLED_OVERAGE_METRICS: readonly OverageMetric[];
145
+ //# sourceMappingURL=plan-pricing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-pricing.d.ts","sourceRoot":"","sources":["../src/plan-pricing.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExF,iFAAiF;AACjF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,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