@absolutejs/billing 0.2.0 → 0.2.2
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.js +28 -9
- package/dist/index.js.map +3 -3
- package/dist/manifest.d.ts +7 -0
- package/dist/manifest.js +9108 -0
- package/dist/manifest.js.map +125 -0
- package/dist/manifest.json +125 -0
- package/package.json +16 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": 1,
|
|
3
|
+
"identity": {
|
|
4
|
+
"accent": "#f59e0b",
|
|
5
|
+
"category": "commerce",
|
|
6
|
+
"description": "Pure cost-model substrate: `createPlan` declares a priced product (base fee, per-dimension unit prices, graduated tiers, free-tier allowances, minimum charge) and `computeInvoice` turns a usage snapshot into invoice line items — all money math in integer micros, so float drift is structurally impossible. `readProviderBalances` reads what the vendors YOU pay (Anthropic, OpenAI, Twilio, Deepgram, ElevenLabs, Apollo) say you have left or have spent, so a dashboard can reconcile your own metering against vendor truth.",
|
|
7
|
+
"docsUrl": "https://github.com/absolutejs/billing",
|
|
8
|
+
"name": "@absolutejs/billing",
|
|
9
|
+
"tagline": "Price your product and turn usage into invoices."
|
|
10
|
+
},
|
|
11
|
+
"requires": {
|
|
12
|
+
"env": [
|
|
13
|
+
{
|
|
14
|
+
"description": "Anthropic Admin API key — only needed for provider-balance reporting (spend, not balance: Anthropic exposes cost only)",
|
|
15
|
+
"docsUrl": "https://console.anthropic.com/settings/admin-keys",
|
|
16
|
+
"example": "sk-ant-admin-xxxxxxxxx",
|
|
17
|
+
"key": "ANTHROPIC_ADMIN_KEY",
|
|
18
|
+
"optional": true,
|
|
19
|
+
"secret": true
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"description": "OpenAI organization Admin key — only needed for provider-balance reporting (spend, not balance: OpenAI exposes cost only)",
|
|
23
|
+
"docsUrl": "https://platform.openai.com/settings/organization/admin-keys",
|
|
24
|
+
"example": "sk-admin-xxxxxxxxx",
|
|
25
|
+
"key": "OPENAI_ADMIN_KEY",
|
|
26
|
+
"optional": true,
|
|
27
|
+
"secret": true
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"settings": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {}
|
|
34
|
+
},
|
|
35
|
+
"wiring": [
|
|
36
|
+
{
|
|
37
|
+
"description": "Dimension keys must match the keys of the usage snapshot you price with computeInvoice.",
|
|
38
|
+
"id": "default",
|
|
39
|
+
"server": {
|
|
40
|
+
"code": "const plan = createPlan({\n\tname: 'pro',\n\tpricedDimensions: {\n\t\t// TODO: your priced dimensions, e.g.\n\t\trequests: { freeTier: 10_000, perUnitMicros: 200 }\n\t}\n});",
|
|
41
|
+
"imports": [
|
|
42
|
+
{
|
|
43
|
+
"from": "@absolutejs/billing",
|
|
44
|
+
"names": [
|
|
45
|
+
"createPlan"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"placement": "module-scope"
|
|
50
|
+
},
|
|
51
|
+
"title": "Declare your pricing plan"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"description": "Optional: read upstream vendors' own balance/quota/spend. Include only the providers you pay; each needs its credential in env.",
|
|
55
|
+
"id": "provider-balances",
|
|
56
|
+
"server": {
|
|
57
|
+
"code": "const providerBalanceConfig = {\n\tanthropic: { adminKey: ${env.ANTHROPIC_ADMIN_KEY} ?? '' },\n\topenai: { adminKey: ${env.OPENAI_ADMIN_KEY} ?? '' }\n};",
|
|
58
|
+
"imports": [],
|
|
59
|
+
"placement": "module-scope"
|
|
60
|
+
},
|
|
61
|
+
"title": "Wire vendor-balance credentials"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"tools": {
|
|
65
|
+
"explain_plan": {
|
|
66
|
+
"annotations": {
|
|
67
|
+
"readOnlyHint": true
|
|
68
|
+
},
|
|
69
|
+
"description": "Describe the app's pricing plan: base fee, per-dimension unit prices or tier tables, free-tier allowances, rounding, and minimum charge. Amounts are integer micros (1,000,000 micros = 1 currency unit). Custom function-priced dimensions are reported as 'custom'.",
|
|
70
|
+
"input": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": {}
|
|
73
|
+
},
|
|
74
|
+
"kind": "runtime"
|
|
75
|
+
},
|
|
76
|
+
"preview_invoice": {
|
|
77
|
+
"annotations": {
|
|
78
|
+
"idempotentHint": true,
|
|
79
|
+
"readOnlyHint": true
|
|
80
|
+
},
|
|
81
|
+
"description": "Dry-run an invoice: price a usage snapshot through the app's plan and return the line items and total in integer micros. Pure math — nothing is charged or stored. Usage keys must match the plan's priced dimensions.",
|
|
82
|
+
"input": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"required": [
|
|
85
|
+
"usage"
|
|
86
|
+
],
|
|
87
|
+
"properties": {
|
|
88
|
+
"periodDays": {
|
|
89
|
+
"description": "Length of the invoice period ending now, in days (default 30).",
|
|
90
|
+
"maximum": 366,
|
|
91
|
+
"minimum": 1,
|
|
92
|
+
"type": "integer"
|
|
93
|
+
},
|
|
94
|
+
"tenant": {
|
|
95
|
+
"description": "Tenant id to stamp on the preview invoice.",
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
"usage": {
|
|
99
|
+
"description": "Metered quantities keyed by dimension name, e.g. {\"requests\": 120000}.",
|
|
100
|
+
"type": "object",
|
|
101
|
+
"patternProperties": {
|
|
102
|
+
"^(.*)$": {
|
|
103
|
+
"minimum": 0,
|
|
104
|
+
"type": "number"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"kind": "runtime"
|
|
111
|
+
},
|
|
112
|
+
"provider_balances": {
|
|
113
|
+
"annotations": {
|
|
114
|
+
"openWorldHint": true,
|
|
115
|
+
"readOnlyHint": true
|
|
116
|
+
},
|
|
117
|
+
"description": "Read each configured upstream vendor's OWN reported balance, quota, or spend (Anthropic/OpenAI report spend; Twilio/Deepgram report balance; ElevenLabs/Apollo report quota). Free reporting endpoints — no per-call charge. Reports only the providers the host wired credentials for.",
|
|
118
|
+
"input": {
|
|
119
|
+
"type": "object",
|
|
120
|
+
"properties": {}
|
|
121
|
+
},
|
|
122
|
+
"kind": "runtime"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/billing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Cost-model substrate for the AbsoluteJS PaaS. createPlan declares a priced product (base fee + per-dimension unit prices + tiered / free-tier rules); computeInvoice turns a @absolutejs/metering Usage snapshot into Invoice line items in integer micros (no float drift). Pluggable invoice sinks (Stripe / etc.) live in @absolutejs/billing-adapters/*.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,13 @@
|
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"import": "./dist/index.js",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"./manifest": {
|
|
26
|
+
"types": "./dist/manifest.d.ts",
|
|
27
|
+
"import": "./dist/manifest.js",
|
|
28
|
+
"default": "./dist/manifest.js"
|
|
29
|
+
},
|
|
30
|
+
"./manifest.json": "./dist/manifest.json"
|
|
25
31
|
},
|
|
26
32
|
"publishConfig": {
|
|
27
33
|
"access": "public"
|
|
@@ -31,7 +37,7 @@
|
|
|
31
37
|
"README.md"
|
|
32
38
|
],
|
|
33
39
|
"scripts": {
|
|
34
|
-
"build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=bun && tsc --project tsconfig.build.json",
|
|
40
|
+
"build": "rm -rf dist && bun build src/index.ts src/manifest.ts --root ./src --outdir dist --sourcemap --target=bun && tsc --project tsconfig.build.json && absolute-manifest emit",
|
|
35
41
|
"test": "bun test tests/",
|
|
36
42
|
"typecheck": "tsc --noEmit",
|
|
37
43
|
"format": "prettier --write \"./**/*.{ts,json,md}\"",
|
|
@@ -54,5 +60,12 @@
|
|
|
54
60
|
"@types/bun": "^1.3.14",
|
|
55
61
|
"prettier": "^3.8.3",
|
|
56
62
|
"typescript": "^5.9.0"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@absolutejs/manifest": "^0.1.0",
|
|
66
|
+
"@sinclair/typebox": "^0.34.0"
|
|
67
|
+
},
|
|
68
|
+
"absolutejs": {
|
|
69
|
+
"manifestContract": 1
|
|
57
70
|
}
|
|
58
71
|
}
|