oblien 2.7.1 → 2.8.1
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/README.md +1 -0
- package/dist/billing.d.ts +58 -17
- package/dist/billing.d.ts.map +1 -1
- package/dist/billing.js +62 -15
- package/dist/billing.js.map +1 -1
- package/dist/cli/commands/desktop.d.ts.map +1 -1
- package/dist/cli/commands/desktop.js +19 -7
- package/dist/cli/commands/desktop.js.map +1 -1
- package/dist/types/billing.d.ts +318 -23
- package/dist/types/billing.d.ts.map +1 -1
- package/dist/types/desktop.d.ts +6 -2
- package/dist/types/desktop.d.ts.map +1 -1
- package/dist/types/desktop.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/webhooks.d.ts +1 -1
- package/dist/types/webhooks.d.ts.map +1 -1
- package/docs/billing.md +166 -11
- package/docs/desktop.md +13 -7
- package/docs/namespaces.md +12 -6
- package/docs/releases/2.8.0.md +19 -0
- package/docs/releases/2.8.1.md +29 -0
- package/docs/webhooks.md +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ The client wraps every part of the platform. Each feature has a deep-dive page i
|
|
|
56
56
|
| **Desktop** | `runtime.desktop` | Live access, browser viewer and native VNC tunnel through the gateway | [docs/desktop](./docs/desktop.md) |
|
|
57
57
|
| **Pages** | `client.pages` | Deploy static files to the edge CDN with automatic TLS | [docs/pages](./docs/pages.md) |
|
|
58
58
|
| **Namespaces** | `client.namespaces` | Group workspaces; resource limits, quotas, per-namespace usage | [docs/namespaces](./docs/namespaces.md) |
|
|
59
|
+
| **Billing** | `client.billing` | Credit-funded PAYG and monthly pools, reseller subscriptions, transfer packs and saved usage comparisons | [docs/billing](./docs/billing.md) |
|
|
59
60
|
| **Domains** | `client.domain` | Slug/DNS pre-flight, route listing, SSL certs + auto-renew | [docs/domains](./docs/domains.md) |
|
|
60
61
|
| **Edge Proxy** | `client.edgeProxy` | Reverse-proxy subdomains to *verified* external upstreams | [docs/edge-proxy](./docs/edge-proxy.md) |
|
|
61
62
|
| **Edge Tunnel** | `client.edgeTunnel` | Expose a local port to the internet (ngrok-style) | [docs/edge-tunnel](./docs/edge-tunnel.md) |
|
package/dist/billing.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { HttpClient } from './http.js';
|
|
2
|
-
import type { BillingBalance, BillingCatalog, BillingDefaults, BillingDefaultsParams, BillingPolicy, BillingPolicyParams, CheckoutParams, CheckoutResponse, BillingCheckoutResponse, Entitlement, PortalParams, PortalResponse, BillingSubscriptionResponse, PreviewPlanChangeParams, BillingPlanChangeQuoteResponse, ChangePlanParams, BillingPlanChangeResponse, CancelPlanChangeParams, ResetQuotaParams, ResetQuotaResponse } from './types/billing.js';
|
|
2
|
+
import type { BillingBalance, BillingCatalog, BillingDefaults, BillingDefaultsParams, BillingPolicy, BillingPolicyParams, CheckoutParams, CheckoutResponse, BillingCheckoutResponse, Entitlement, PortalParams, PortalResponse, BillingSubscriptionResponse, PreviewPlanChangeParams, BillingPlanChangeQuoteResponse, ChangePlanParams, BillingPlanChangeResponse, CancelPlanChangeParams, ResetQuotaParams, ResetQuotaResponse, CapacityCatalog, CapacityResponse, CapacityQuoteResponse, PreviewCapacityParams, ConfirmCapacityParams, CapacityCheckoutParams, CapacityCheckoutResponse, BillingSavings } from './types/billing.js';
|
|
3
3
|
/**
|
|
4
|
-
* Billing — namespace-bound subscriptions,
|
|
4
|
+
* Billing — namespace-bound PAYG/monthly capacity, subscriptions, funding and entitlement.
|
|
5
5
|
*
|
|
6
6
|
* Oblien is the payment engine: it runs Stripe internally, meters usage, enforces
|
|
7
7
|
* quotas and suspends namespaces. You never touch Stripe and never re-implement quota
|
|
8
8
|
* math.
|
|
9
9
|
*
|
|
10
10
|
* **The namespace is the unit of billing.** Every subscription, quota, entitlement and
|
|
11
|
-
* suspension is per-namespace. The owner's wallet
|
|
11
|
+
* suspension is per-namespace. The owner's wallet funds payment; a purchased capacity
|
|
12
|
+
* pool belongs only to its namespace. That is what
|
|
12
13
|
* makes this usable for multi-tenant products: give each of your customers a namespace
|
|
13
14
|
* and they are billed independently.
|
|
14
15
|
*
|
|
@@ -35,7 +36,7 @@ import type { BillingBalance, BillingCatalog, BillingDefaults, BillingDefaultsPa
|
|
|
35
36
|
* the browser coming back. Poll {@link Billing.entitlement} or listen for
|
|
36
37
|
* `payment.succeeded`.
|
|
37
38
|
*
|
|
38
|
-
* ###
|
|
39
|
+
* ### Existing metered allowance integrations
|
|
39
40
|
*
|
|
40
41
|
* - **Mode B (above)** — Oblien hosts the payment against its own catalog. Use
|
|
41
42
|
* {@link Billing.catalog}, {@link Billing.checkout}, {@link Billing.portal}.
|
|
@@ -43,8 +44,12 @@ import type { BillingBalance, BillingCatalog, BillingDefaults, BillingDefaultsPa
|
|
|
43
44
|
* Skip checkout entirely and set the ceiling directly with {@link Billing.setPolicy}
|
|
44
45
|
* (or {@link Billing.setDefaults} for a template applied to every new namespace).
|
|
45
46
|
*
|
|
47
|
+
* Current compute uses {@link Billing.capacityCatalog}, {@link Billing.previewCapacity}
|
|
48
|
+
* and {@link Billing.confirmCapacity}; hosted monthly offers also use checkout with
|
|
49
|
+
* billingMode: 'monthly', capacity and credits: 0. See docs/billing.md for both flows.
|
|
50
|
+
*
|
|
46
51
|
* **Requires an `admin`- or `billing`-scoped API key** for everything except
|
|
47
|
-
* {@link Billing.catalog}. Namespace- and workspace-scoped tokens — the lightweight ones
|
|
52
|
+
* {@link Billing.catalog} and {@link Billing.capacityCatalog}. Namespace- and workspace-scoped tokens — the lightweight ones
|
|
48
53
|
* you hand to end-users — are refused on every billing route by design.
|
|
49
54
|
*/
|
|
50
55
|
export declare class Billing {
|
|
@@ -53,6 +58,38 @@ export declare class Billing {
|
|
|
53
58
|
constructor(client: {
|
|
54
59
|
_http: HttpClient;
|
|
55
60
|
});
|
|
61
|
+
/** Backend prices for both compute modes. Dollar amounts on quotes are cents. */
|
|
62
|
+
capacityCatalog(): Promise<CapacityCatalog>;
|
|
63
|
+
/** Paid-through coverage, effective pool, network extras and recorded savings.
|
|
64
|
+
* Omit namespace (or pass null) for personal resources. */
|
|
65
|
+
capacity(namespace?: string | null): Promise<CapacityResponse>;
|
|
66
|
+
/** Quote a new pool or a wallet-funded change. Existing Stripe subscriptions
|
|
67
|
+
* use previewPlanChange/changePlan, preserving their saved prices.
|
|
68
|
+
* Pass null as namespace for personal resources. */
|
|
69
|
+
previewCapacity(namespace: string | null, params: PreviewCapacityParams): Promise<CapacityQuoteResponse>;
|
|
70
|
+
/** Atomically redeem eligible paid wallet funds and apply the saved quote.
|
|
71
|
+
* Namespace allowance numbers are not redeemable wallet money. */
|
|
72
|
+
confirmCapacity(namespace: string | null, params: ConfirmCapacityParams): Promise<CapacityResponse>;
|
|
73
|
+
/** Open Stripe for a saved monthly quote. Read capacity or signed events for
|
|
74
|
+
* fulfillment; returning from the browser is never proof of payment. */
|
|
75
|
+
capacityCheckout(namespace: string | null, params: CapacityCheckoutParams): Promise<CapacityCheckoutResponse>;
|
|
76
|
+
cancelCapacityChange(namespace: string | null, params: ConfirmCapacityParams): Promise<CapacityResponse>;
|
|
77
|
+
/** Wallet renewal only; hosted subscriptions use cancelSubscription/resumeSubscription. */
|
|
78
|
+
setCapacityAutoRenew(namespace: string | null, params: {
|
|
79
|
+
autoRenew: boolean;
|
|
80
|
+
idempotencyKey: string;
|
|
81
|
+
}): Promise<CapacityResponse>;
|
|
82
|
+
/** A separately funded proxy-transfer pack. Confirm with confirmCapacity. */
|
|
83
|
+
previewNetworkTopup(namespace: string | null, params: {
|
|
84
|
+
unitAmount: number;
|
|
85
|
+
idempotencyKey: string;
|
|
86
|
+
}): Promise<CapacityQuoteResponse>;
|
|
87
|
+
/** Saved metering comparisons, not a forecast or a refund. Amounts are USD. */
|
|
88
|
+
savings(params?: {
|
|
89
|
+
namespace?: string;
|
|
90
|
+
workspaceId?: string;
|
|
91
|
+
month?: string;
|
|
92
|
+
}): Promise<BillingSavings>;
|
|
56
93
|
/**
|
|
57
94
|
* Plans and credit packs on offer. Public — no authentication.
|
|
58
95
|
*
|
|
@@ -67,7 +104,7 @@ export declare class Billing {
|
|
|
67
104
|
/**
|
|
68
105
|
* Create a hosted checkout bound to a namespace, and get the URL to redirect to.
|
|
69
106
|
*
|
|
70
|
-
*
|
|
107
|
+
* Catalog credit products support two kinds:
|
|
71
108
|
*
|
|
72
109
|
* - `kind: 'topup'` + `packId` — adds the pack's credits to that namespace's ceiling.
|
|
73
110
|
* Unused purchased credits survive renewal and stack, so this unblocks a namespace that
|
|
@@ -97,6 +134,8 @@ export declare class Billing {
|
|
|
97
134
|
* For reseller pricing, send `offer` instead of planTierId/packId. A $10 offer with
|
|
98
135
|
* `credits: 100` funds 1000 wallet credits at the current standard rate and grants
|
|
99
136
|
* only 100 namespace credits. The offer name/description appears in checkout.
|
|
137
|
+
* A monthly capacity offer instead uses billingMode: 'monthly', capacity,
|
|
138
|
+
* credits: 0 and no credit policy; the saved provider fee is deducted from funding.
|
|
100
139
|
* Stripe-hosted checkout with native code entry is the default. Set
|
|
101
140
|
* `allowPromotionCodes: false` to disable codes, or `checkoutMode: 'oblien'`
|
|
102
141
|
* for the custom page with scoped, capped administrator promotions.
|
|
@@ -108,7 +147,7 @@ export declare class Billing {
|
|
|
108
147
|
*/
|
|
109
148
|
checkout(params: CheckoutParams): Promise<CheckoutResponse>;
|
|
110
149
|
/** Inspect a reseller checkout bound to this owner and namespace, including net fulfillment/refund amounts. */
|
|
111
|
-
checkoutStatus(namespace: string, checkoutId: string): Promise<BillingCheckoutResponse>;
|
|
150
|
+
checkoutStatus(namespace: string | null, checkoutId: string): Promise<BillingCheckoutResponse>;
|
|
112
151
|
/**
|
|
113
152
|
* Open the hosted "manage subscription / payment method / invoices" portal.
|
|
114
153
|
*
|
|
@@ -122,23 +161,23 @@ export declare class Billing {
|
|
|
122
161
|
* @throws NotFoundError (`no_customer`) if this namespace has never checked out.
|
|
123
162
|
* @throws ConflictError (`billing_customer_conflict`) for shared legacy billing.
|
|
124
163
|
*/
|
|
125
|
-
portal(params
|
|
164
|
+
portal(params?: PortalParams): Promise<PortalResponse>;
|
|
126
165
|
/** Read this namespace's subscription, including a pending end-of-period cancellation. */
|
|
127
|
-
subscription(namespace
|
|
166
|
+
subscription(namespace?: string | null): Promise<BillingSubscriptionResponse>;
|
|
128
167
|
/** Quote a change to an existing reseller subscription. Prices come from the
|
|
129
168
|
* saved contract; upgrades retain usage and top-ups and add a prorated increase. */
|
|
130
|
-
previewPlanChange(namespace: string, params: PreviewPlanChangeParams): Promise<BillingPlanChangeQuoteResponse>;
|
|
169
|
+
previewPlanChange(namespace: string | null, params: PreviewPlanChangeParams): Promise<BillingPlanChangeQuoteResponse>;
|
|
131
170
|
/** Accept a quote. Only status=applied grants new terms; payment_pending keeps
|
|
132
171
|
* the old plan. Downgrades are scheduled for the next billing cycle. */
|
|
133
|
-
changePlan(namespace: string, params: ChangePlanParams): Promise<BillingPlanChangeResponse>;
|
|
172
|
+
changePlan(namespace: string | null, params: ChangePlanParams): Promise<BillingPlanChangeResponse>;
|
|
134
173
|
/** Reconcile your UI using the saved operation after a timeout or webhook. */
|
|
135
|
-
planChange(namespace: string, changeId: string): Promise<BillingPlanChangeResponse>;
|
|
174
|
+
planChange(namespace: string | null, changeId: string): Promise<BillingPlanChangeResponse>;
|
|
136
175
|
/** Cancel a pending downgrade (or unpaid upgrade) before it takes effect. */
|
|
137
|
-
cancelPlanChange(namespace: string, changeId: string, params: CancelPlanChangeParams): Promise<BillingPlanChangeResponse>;
|
|
176
|
+
cancelPlanChange(namespace: string | null, changeId: string, params: CancelPlanChangeParams): Promise<BillingPlanChangeResponse>;
|
|
138
177
|
/** Stop renewal at the end of the paid period. Repeat calls are safe. */
|
|
139
|
-
cancelSubscription(namespace
|
|
178
|
+
cancelSubscription(namespace?: string | null): Promise<BillingSubscriptionResponse>;
|
|
140
179
|
/** Undo scheduled cancellation before the subscription ends; no charge is created. */
|
|
141
|
-
resumeSubscription(namespace
|
|
180
|
+
resumeSubscription(namespace?: string | null): Promise<BillingSubscriptionResponse>;
|
|
142
181
|
/**
|
|
143
182
|
* Mode A: start a new allowance cycle, carrying forward unused purchased credits.
|
|
144
183
|
* Supply the same periodEnd on retry. Mode-B subscriptions renew automatically.
|
|
@@ -154,7 +193,9 @@ export declare class Billing {
|
|
|
154
193
|
* // ent.quota → { limit, used, balance } ← limit INCLUDES purchased top-ups
|
|
155
194
|
* ```
|
|
156
195
|
*
|
|
157
|
-
*
|
|
196
|
+
* A capacity contract returns billingMode, computeCovered and capacity; its quota
|
|
197
|
+
* uses null limit/balance for compatibility. Read coverage and actual pool limits.
|
|
198
|
+
* For a metered contract, quota.limit === null means no finite credit allowance.
|
|
158
199
|
*/
|
|
159
200
|
entitlement(namespace: string): Promise<Entitlement>;
|
|
160
201
|
/**
|
|
@@ -165,7 +206,7 @@ export declare class Billing {
|
|
|
165
206
|
* if (blocking) return showTopUpPrompt();
|
|
166
207
|
* ```
|
|
167
208
|
*
|
|
168
|
-
* `blocking`
|
|
209
|
+
* `blocking` reflects the applicable contract's suspension, expiry and funding. You do not
|
|
169
210
|
* have to enforce it yourself — Oblien already refuses creates, starts, resumes and
|
|
170
211
|
* wakes for a blocked namespace — but checking lets you show a useful message instead
|
|
171
212
|
* of surfacing an error.
|
package/dist/billing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,2BAA2B,EAC3B,uBAAuB,EACvB,8BAA8B,EAC9B,g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SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IAQvF;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC;IAO1C;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC;CAO3E"}
|
package/dist/billing.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Billing — namespace-bound subscriptions,
|
|
2
|
+
* Billing — namespace-bound PAYG/monthly capacity, subscriptions, funding and entitlement.
|
|
3
3
|
*
|
|
4
4
|
* Oblien is the payment engine: it runs Stripe internally, meters usage, enforces
|
|
5
5
|
* quotas and suspends namespaces. You never touch Stripe and never re-implement quota
|
|
6
6
|
* math.
|
|
7
7
|
*
|
|
8
8
|
* **The namespace is the unit of billing.** Every subscription, quota, entitlement and
|
|
9
|
-
* suspension is per-namespace. The owner's wallet
|
|
9
|
+
* suspension is per-namespace. The owner's wallet funds payment; a purchased capacity
|
|
10
|
+
* pool belongs only to its namespace. That is what
|
|
10
11
|
* makes this usable for multi-tenant products: give each of your customers a namespace
|
|
11
12
|
* and they are billed independently.
|
|
12
13
|
*
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
* the browser coming back. Poll {@link Billing.entitlement} or listen for
|
|
34
35
|
* `payment.succeeded`.
|
|
35
36
|
*
|
|
36
|
-
* ###
|
|
37
|
+
* ### Existing metered allowance integrations
|
|
37
38
|
*
|
|
38
39
|
* - **Mode B (above)** — Oblien hosts the payment against its own catalog. Use
|
|
39
40
|
* {@link Billing.catalog}, {@link Billing.checkout}, {@link Billing.portal}.
|
|
@@ -41,8 +42,12 @@
|
|
|
41
42
|
* Skip checkout entirely and set the ceiling directly with {@link Billing.setPolicy}
|
|
42
43
|
* (or {@link Billing.setDefaults} for a template applied to every new namespace).
|
|
43
44
|
*
|
|
45
|
+
* Current compute uses {@link Billing.capacityCatalog}, {@link Billing.previewCapacity}
|
|
46
|
+
* and {@link Billing.confirmCapacity}; hosted monthly offers also use checkout with
|
|
47
|
+
* billingMode: 'monthly', capacity and credits: 0. See docs/billing.md for both flows.
|
|
48
|
+
*
|
|
44
49
|
* **Requires an `admin`- or `billing`-scoped API key** for everything except
|
|
45
|
-
* {@link Billing.catalog}. Namespace- and workspace-scoped tokens — the lightweight ones
|
|
50
|
+
* {@link Billing.catalog} and {@link Billing.capacityCatalog}. Namespace- and workspace-scoped tokens — the lightweight ones
|
|
46
51
|
* you hand to end-users — are refused on every billing route by design.
|
|
47
52
|
*/
|
|
48
53
|
export class Billing {
|
|
@@ -51,6 +56,46 @@ export class Billing {
|
|
|
51
56
|
constructor(client) {
|
|
52
57
|
this._http = client._http;
|
|
53
58
|
}
|
|
59
|
+
/** Backend prices for both compute modes. Dollar amounts on quotes are cents. */
|
|
60
|
+
async capacityCatalog() {
|
|
61
|
+
return this._http.request({ method: 'GET', path: '/billing/capacity/catalog' });
|
|
62
|
+
}
|
|
63
|
+
/** Paid-through coverage, effective pool, network extras and recorded savings.
|
|
64
|
+
* Omit namespace (or pass null) for personal resources. */
|
|
65
|
+
async capacity(namespace) {
|
|
66
|
+
return this._http.request({ method: 'GET', path: '/billing/capacity', query: { namespace: namespace ?? undefined } });
|
|
67
|
+
}
|
|
68
|
+
/** Quote a new pool or a wallet-funded change. Existing Stripe subscriptions
|
|
69
|
+
* use previewPlanChange/changePlan, preserving their saved prices.
|
|
70
|
+
* Pass null as namespace for personal resources. */
|
|
71
|
+
async previewCapacity(namespace, params) {
|
|
72
|
+
return this._http.request({ method: 'POST', path: '/billing/capacity/preview', body: { ...params, namespace } });
|
|
73
|
+
}
|
|
74
|
+
/** Atomically redeem eligible paid wallet funds and apply the saved quote.
|
|
75
|
+
* Namespace allowance numbers are not redeemable wallet money. */
|
|
76
|
+
async confirmCapacity(namespace, params) {
|
|
77
|
+
return this._http.request({ method: 'POST', path: '/billing/capacity/confirm', body: { ...params, namespace } });
|
|
78
|
+
}
|
|
79
|
+
/** Open Stripe for a saved monthly quote. Read capacity or signed events for
|
|
80
|
+
* fulfillment; returning from the browser is never proof of payment. */
|
|
81
|
+
async capacityCheckout(namespace, params) {
|
|
82
|
+
return this._http.request({ method: 'POST', path: '/billing/capacity/checkout', body: { ...params, namespace } });
|
|
83
|
+
}
|
|
84
|
+
async cancelCapacityChange(namespace, params) {
|
|
85
|
+
return this._http.request({ method: 'POST', path: '/billing/capacity/change/cancel', body: { ...params, namespace } });
|
|
86
|
+
}
|
|
87
|
+
/** Wallet renewal only; hosted subscriptions use cancelSubscription/resumeSubscription. */
|
|
88
|
+
async setCapacityAutoRenew(namespace, params) {
|
|
89
|
+
return this._http.request({ method: 'POST', path: '/billing/capacity/renewal', body: { ...params, namespace } });
|
|
90
|
+
}
|
|
91
|
+
/** A separately funded proxy-transfer pack. Confirm with confirmCapacity. */
|
|
92
|
+
async previewNetworkTopup(namespace, params) {
|
|
93
|
+
return this._http.request({ method: 'POST', path: '/billing/capacity/network/preview', body: { ...params, namespace } });
|
|
94
|
+
}
|
|
95
|
+
/** Saved metering comparisons, not a forecast or a refund. Amounts are USD. */
|
|
96
|
+
async savings(params = {}) {
|
|
97
|
+
return this._http.request({ method: 'GET', path: '/billing/savings', query: params });
|
|
98
|
+
}
|
|
54
99
|
/**
|
|
55
100
|
* Plans and credit packs on offer. Public — no authentication.
|
|
56
101
|
*
|
|
@@ -70,7 +115,7 @@ export class Billing {
|
|
|
70
115
|
/**
|
|
71
116
|
* Create a hosted checkout bound to a namespace, and get the URL to redirect to.
|
|
72
117
|
*
|
|
73
|
-
*
|
|
118
|
+
* Catalog credit products support two kinds:
|
|
74
119
|
*
|
|
75
120
|
* - `kind: 'topup'` + `packId` — adds the pack's credits to that namespace's ceiling.
|
|
76
121
|
* Unused purchased credits survive renewal and stack, so this unblocks a namespace that
|
|
@@ -100,6 +145,8 @@ export class Billing {
|
|
|
100
145
|
* For reseller pricing, send `offer` instead of planTierId/packId. A $10 offer with
|
|
101
146
|
* `credits: 100` funds 1000 wallet credits at the current standard rate and grants
|
|
102
147
|
* only 100 namespace credits. The offer name/description appears in checkout.
|
|
148
|
+
* A monthly capacity offer instead uses billingMode: 'monthly', capacity,
|
|
149
|
+
* credits: 0 and no credit policy; the saved provider fee is deducted from funding.
|
|
103
150
|
* Stripe-hosted checkout with native code entry is the default. Set
|
|
104
151
|
* `allowPromotionCodes: false` to disable codes, or `checkoutMode: 'oblien'`
|
|
105
152
|
* for the custom page with scoped, capped administrator promotions.
|
|
@@ -119,7 +166,7 @@ export class Billing {
|
|
|
119
166
|
/** Inspect a reseller checkout bound to this owner and namespace, including net fulfillment/refund amounts. */
|
|
120
167
|
async checkoutStatus(namespace, checkoutId) {
|
|
121
168
|
return this._http.request({
|
|
122
|
-
method: 'GET', path: `/billing/checkout/${encodeURIComponent(checkoutId)}`, query: { namespace },
|
|
169
|
+
method: 'GET', path: `/billing/checkout/${encodeURIComponent(checkoutId)}`, query: { namespace: namespace ?? undefined },
|
|
123
170
|
});
|
|
124
171
|
}
|
|
125
172
|
/**
|
|
@@ -135,9 +182,7 @@ export class Billing {
|
|
|
135
182
|
* @throws NotFoundError (`no_customer`) if this namespace has never checked out.
|
|
136
183
|
* @throws ConflictError (`billing_customer_conflict`) for shared legacy billing.
|
|
137
184
|
*/
|
|
138
|
-
async portal(params) {
|
|
139
|
-
if (!params?.namespace?.trim())
|
|
140
|
-
throw new TypeError('billing.portal requires a namespace');
|
|
185
|
+
async portal(params = {}) {
|
|
141
186
|
return this._http.request({
|
|
142
187
|
method: 'POST',
|
|
143
188
|
path: '/billing/portal',
|
|
@@ -147,7 +192,7 @@ export class Billing {
|
|
|
147
192
|
/** Read this namespace's subscription, including a pending end-of-period cancellation. */
|
|
148
193
|
async subscription(namespace) {
|
|
149
194
|
return this._http.request({
|
|
150
|
-
method: 'GET', path: '/billing/subscription', query: { namespace },
|
|
195
|
+
method: 'GET', path: '/billing/subscription', query: { namespace: namespace ?? undefined },
|
|
151
196
|
});
|
|
152
197
|
}
|
|
153
198
|
/** Quote a change to an existing reseller subscription. Prices come from the
|
|
@@ -167,7 +212,7 @@ export class Billing {
|
|
|
167
212
|
/** Reconcile your UI using the saved operation after a timeout or webhook. */
|
|
168
213
|
async planChange(namespace, changeId) {
|
|
169
214
|
return this._http.request({
|
|
170
|
-
method: 'GET', path: `/billing/subscription/changes/${encodeURIComponent(changeId)}`, query: { namespace },
|
|
215
|
+
method: 'GET', path: `/billing/subscription/changes/${encodeURIComponent(changeId)}`, query: { namespace: namespace ?? undefined },
|
|
171
216
|
});
|
|
172
217
|
}
|
|
173
218
|
/** Cancel a pending downgrade (or unpaid upgrade) before it takes effect. */
|
|
@@ -207,13 +252,15 @@ export class Billing {
|
|
|
207
252
|
* // ent.quota → { limit, used, balance } ← limit INCLUDES purchased top-ups
|
|
208
253
|
* ```
|
|
209
254
|
*
|
|
210
|
-
*
|
|
255
|
+
* A capacity contract returns billingMode, computeCovered and capacity; its quota
|
|
256
|
+
* uses null limit/balance for compatibility. Read coverage and actual pool limits.
|
|
257
|
+
* For a metered contract, quota.limit === null means no finite credit allowance.
|
|
211
258
|
*/
|
|
212
259
|
async entitlement(namespace) {
|
|
213
260
|
return this._http.request({
|
|
214
261
|
method: 'GET',
|
|
215
262
|
path: '/billing/entitlement',
|
|
216
|
-
query: { namespace },
|
|
263
|
+
query: { namespace: namespace ?? undefined },
|
|
217
264
|
});
|
|
218
265
|
}
|
|
219
266
|
/**
|
|
@@ -224,7 +271,7 @@ export class Billing {
|
|
|
224
271
|
* if (blocking) return showTopUpPrompt();
|
|
225
272
|
* ```
|
|
226
273
|
*
|
|
227
|
-
* `blocking`
|
|
274
|
+
* `blocking` reflects the applicable contract's suspension, expiry and funding. You do not
|
|
228
275
|
* have to enforce it yourself — Oblien already refuses creates, starts, resumes and
|
|
229
276
|
* wakes for a blocked namespace — but checking lets you show a useful message instead
|
|
230
277
|
* of surfacing an error.
|
|
@@ -233,7 +280,7 @@ export class Billing {
|
|
|
233
280
|
return this._http.request({
|
|
234
281
|
method: 'GET',
|
|
235
282
|
path: '/billing/balance',
|
|
236
|
-
query: { namespace },
|
|
283
|
+
query: { namespace: namespace ?? undefined },
|
|
237
284
|
});
|
|
238
285
|
}
|
|
239
286
|
/**
|
package/dist/billing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,OAAO,OAAO;IAClB,gBAAgB;IACC,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,2BAA2B,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;+DAC2D;IAC3D,KAAK,CAAC,QAAQ,CAAC,SAAyB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,IAAI,SAAS,EAAE,EAAE,CAAC,CAAC;IACxH,CAAC;IAED;;wDAEoD;IACpD,KAAK,CAAC,eAAe,CAAC,SAAwB,EAAE,MAA6B;QAC3E,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,2BAA2B,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;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,MAAM,CAAC,SAAiB;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB;YACvC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,mBAAmB,kBAAkB,CAAC,SAAS,CAAC,EAAE;SACzD,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,SAAS,CAAC,SAAiB,EAAE,MAA2B;QAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB;YACvC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,mBAAmB,kBAAkB,CAAC,SAAS,CAAC,EAAE;YACxD,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAkB;YACzC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,mBAAmB;SAC1B,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,WAAW,CAAC,MAA6B;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAkB;YACzC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktop.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/desktop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"desktop.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/desktop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD/E"}
|
|
@@ -4,22 +4,34 @@ import { parseFlag, requireId } from './helpers.js';
|
|
|
4
4
|
export async function desktopCmd(args, flags) {
|
|
5
5
|
const action = args[0];
|
|
6
6
|
if (!action || action === '--help') {
|
|
7
|
-
console.log('Usage: oblien desktop <list|create|start|stop|delete|status|enable|disable|install|installation|credentials|ssh|vnc> <workspace-id> [session-id] [--name Work --resolution 1920x1080] [--session ID] [--port 5901]');
|
|
7
|
+
console.log('Usage: oblien desktop <list|create|update|start|stop|delete|status|enable|disable|install|installation|credentials|ssh|vnc> <workspace-id> [session-id] [--name Work --resolution 1920x1080] [--session ID] [--port 5901]');
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
if (!['list', 'create', 'start', 'stop', 'delete', 'status', 'enable', 'disable', 'install', 'installation', 'credentials', 'ssh', 'vnc'].includes(action))
|
|
10
|
+
if (!['list', 'create', 'update', 'start', 'stop', 'delete', 'status', 'enable', 'disable', 'install', 'installation', 'credentials', 'ssh', 'vnc'].includes(action))
|
|
11
11
|
throw new Error('Unknown desktop action');
|
|
12
12
|
const id = requireId(args[1], `desktop ${action} <workspace-id>`);
|
|
13
13
|
const client = buildClient(flags);
|
|
14
14
|
const sessionId = parseFlag(args.slice(2), '--session');
|
|
15
15
|
if (action === 'list')
|
|
16
16
|
return printResult(await client.workspaces.desktop.listSessions(id), flags.json);
|
|
17
|
-
if (action === 'create') {
|
|
17
|
+
if (action === 'create' || action === 'update') {
|
|
18
18
|
const name = parseFlag(args.slice(2), '--name');
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const size = parseFlag(args.slice(2), '--resolution');
|
|
20
|
+
const resolution = /^(\d+)x(\d+)$/.exec(size || '');
|
|
21
|
+
if (size && !resolution)
|
|
22
|
+
throw new Error('Use --resolution WIDTHxHEIGHT');
|
|
23
|
+
const patch = { ...(name ? { name } : {}), ...(resolution ? { resolution: { width: Number(resolution[1]), height: Number(resolution[2]) } } : {}) };
|
|
24
|
+
if (action === 'update') {
|
|
25
|
+
if (!name && !resolution)
|
|
26
|
+
throw new Error('Set --name or --resolution WIDTHxHEIGHT');
|
|
27
|
+
const selected = sessionId || requireId(args[2], 'desktop update <workspace-id> <session-id>');
|
|
28
|
+
return printResult(await client.workspaces.desktop.updateSession(id, selected, patch), flags.json);
|
|
29
|
+
}
|
|
30
|
+
if (!name)
|
|
31
|
+
throw new Error('Set --name before creating a desktop');
|
|
32
|
+
if (!resolution && (await client.workspaces.desktop.listSessions(id)).capabilities.resolution)
|
|
33
|
+
throw new Error('Set --resolution WIDTHxHEIGHT before creating a desktop');
|
|
34
|
+
return printResult(await client.workspaces.desktop.createSession(id, { ...patch, name }), flags.json);
|
|
23
35
|
}
|
|
24
36
|
if (action === 'start' || action === 'stop' || action === 'delete') {
|
|
25
37
|
const selected = sessionId || requireId(args[2], `desktop ${action} <workspace-id> <session-id>`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktop.js","sourceRoot":"","sources":["../../../src/cli/commands/desktop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpD,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAc,EAAE,KAAe;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"desktop.js","sourceRoot":"","sources":["../../../src/cli/commands/desktop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