@tolinax/ayoune-interfaces 2026.44.0 → 2026.45.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/interfaces/ICharge.d.ts +30 -0
- package/package.json +1 -1
package/interfaces/ICharge.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { IDefaultFields } from "./IDefaultFields";
|
|
2
|
+
/**
|
|
3
|
+
* Direction of a charge entry.
|
|
4
|
+
* - "inbound" = customer → Tolinax (metered usage, existing default)
|
|
5
|
+
* - "outbound" = Tolinax → third-party provider (platform cost telemetry)
|
|
6
|
+
*/
|
|
7
|
+
export type ChargeDirection = "inbound" | "outbound";
|
|
8
|
+
/**
|
|
9
|
+
* Known outbound providers. Kept as a string literal union rather than an
|
|
10
|
+
* enum so consumers can declare their own providers without a type release.
|
|
11
|
+
*/
|
|
12
|
+
export type ChargeProvider = "gcp" | "openai" | "anthropic" | "vertex" | "bitbucket" | "atlas" | "hetzner" | "cloudflare" | "npm" | string;
|
|
2
13
|
export interface ICharge extends IDefaultFields {
|
|
3
14
|
_customerID: ObjectId;
|
|
4
15
|
_product?: ObjectId;
|
|
@@ -22,4 +33,23 @@ export interface ICharge extends IDefaultFields {
|
|
|
22
33
|
dateTime?: Date;
|
|
23
34
|
billable?: boolean;
|
|
24
35
|
invoiced?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Cost-telemetry extension (2026-04-20). All fields optional; existing
|
|
38
|
+
* inbound customer charges stay untouched. For outbound charges the
|
|
39
|
+
* `direction` field flips to "outbound" and `_customerID` is set to
|
|
40
|
+
* the TOLINAX_CUSTOMERID so multi-tenant indexes keep working without
|
|
41
|
+
* special-cases.
|
|
42
|
+
*/
|
|
43
|
+
direction?: ChargeDirection;
|
|
44
|
+
provider?: ChargeProvider;
|
|
45
|
+
amountUSD?: number;
|
|
46
|
+
exchangeRate?: number;
|
|
47
|
+
/**
|
|
48
|
+
* When an outbound cost can be attributed to a specific customer (e.g.
|
|
49
|
+
* AI tokens consumed by a customer-scoped request), set this to that
|
|
50
|
+
* customer's _id. Leave undefined for platform-wide overhead.
|
|
51
|
+
*/
|
|
52
|
+
attributedCustomerID?: ObjectId;
|
|
53
|
+
/** Provider-specific payload (gcp service code, openai model, etc.). */
|
|
54
|
+
meta?: any;
|
|
25
55
|
}
|