feat: add billing and usage domain cores

This commit is contained in:
zn-admin committed 2026-08-13 16:27:55 +08:00
1 parent 48dd5d07c8
commit 5e60bb40e7
14 files changed
+931

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
describe("Go billing core compatibility fixture", () => {
it("freezes money, errors, idempotency, quote ordering, and exemptions", async () => {
const fixture = JSON.parse(await readFile("contracts/billing/core-v1.json", "utf8"));
expect(fixture).toMatchObject({
currency: "CNY", moneyUnit: "fen",
statuses: { insufficientBalance: 402, idempotencyConflict: 409 },
idempotencyKeys: { charge: "job-charge:{jobId}", refund: "job-refund:{jobId}" },
quote: { quantityRounding: "ceil", tiedWinner: "ambiguity_error", tierStandardFactors: "multiply", tierMarkupMultipliers: "maximum" },
exemptions: { billingDisabled: true, mockProvider: true, platformSuperAdminQuota: true }
});
});
});
+14
View File
@@ -0,0 +1,14 @@
import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
describe("Go usage core compatibility fixture", () => {
it("freezes Shanghai boundaries, exclusions, dedupe, scope, and redaction", async () => {
const fixture = JSON.parse(await readFile("contracts/usage/core-v1.json", "utf8"));
expect(fixture).toEqual({
version: 1, timeZone: "Asia/Shanghai",
excluded: { sources: ["api"], providers: ["mock"] }, dedupeKey: "jobId",
scopes: { personal: "accountId", organization_admin: "organizationId", super_admin: "all" },
organizationAdminRedaction: ["accountUsername"]
});
});
});