run402 2.43.0 → 2.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/README.md +1 -1
- package/cli.mjs +1 -1
- package/lib/admin.mjs +22 -22
- package/lib/allowance.mjs +8 -4
- package/lib/billing.mjs +123 -125
- package/lib/operator.mjs +3 -3
- package/lib/projects.mjs +4 -4
- package/lib/sdk-errors.mjs +1 -1
- package/lib/service.mjs +1 -1
- package/lib/status.mjs +5 -5
- package/lib/tier.mjs +4 -4
- package/lib/transfer.mjs +5 -5
- package/package.json +1 -1
- package/sdk/dist/errors.d.ts +8 -8
- package/sdk/dist/errors.d.ts.map +1 -1
- package/sdk/dist/errors.js +6 -6
- package/sdk/dist/errors.js.map +1 -1
- package/sdk/dist/namespaces/admin.d.ts +15 -16
- package/sdk/dist/namespaces/admin.d.ts.map +1 -1
- package/sdk/dist/namespaces/admin.js +14 -15
- package/sdk/dist/namespaces/admin.js.map +1 -1
- package/sdk/dist/namespaces/billing.d.ts +66 -62
- package/sdk/dist/namespaces/billing.d.ts.map +1 -1
- package/sdk/dist/namespaces/billing.js +96 -106
- package/sdk/dist/namespaces/billing.js.map +1 -1
- package/sdk/dist/namespaces/operator.d.ts +3 -3
- package/sdk/dist/namespaces/operator.d.ts.map +1 -1
- package/sdk/dist/namespaces/operator.js +1 -1
- package/sdk/dist/namespaces/org.types.d.ts +2 -2
- package/sdk/dist/namespaces/org.types.js +1 -1
- package/sdk/dist/namespaces/projects.d.ts +2 -2
- package/sdk/dist/namespaces/projects.js +2 -2
- package/sdk/dist/namespaces/projects.types.d.ts +15 -15
- package/sdk/dist/namespaces/projects.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/tier.d.ts +11 -11
- package/sdk/dist/namespaces/tier.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.d.ts +8 -8
- package/sdk/dist/namespaces/transfers.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.js +3 -3
- package/sdk/dist/namespaces/transfers.js.map +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `billing` namespace —
|
|
2
|
+
* `billing` namespace — organizations and Stripe checkouts.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Organizations are addressed by their canonical `organization_id` (UUID). A
|
|
5
5
|
* wallet or email is resolved to that id through the
|
|
6
|
-
* `GET /
|
|
7
|
-
* accept any of the three identifier forms and resolve internally.
|
|
8
|
-
* reads require SIWX from a wallet linked to the
|
|
6
|
+
* `GET /orgs/v1/lookup?wallet=|?email=` lookup; `getOrganization` / `history`
|
|
7
|
+
* accept any of the three identifier forms and resolve internally. Organization
|
|
8
|
+
* reads require SIWX from a wallet linked to the organization (or matching the
|
|
9
9
|
* looked-up `?wallet`), or an admin key; email lookups are admin-only.
|
|
10
|
-
* Mutations such as link-wallet
|
|
11
|
-
*
|
|
10
|
+
* Mutations such as link-wallet, checkout creation, and auto-recharge require
|
|
11
|
+
* an org credential (or admin).
|
|
12
12
|
*/
|
|
13
13
|
import type { Client } from "../kernel.js";
|
|
14
14
|
import type { ProjectTier } from "./projects.types.js";
|
|
15
|
-
export interface
|
|
16
|
-
/** Canonical
|
|
17
|
-
|
|
15
|
+
export interface OrganizationDetail {
|
|
16
|
+
/** Canonical organization id (UUID). */
|
|
17
|
+
organization_id: string;
|
|
18
18
|
available_usd_micros: number;
|
|
19
19
|
/** Held/reserved portion of the balance; absent on gateways that predate the field. */
|
|
20
20
|
held_usd_micros?: number;
|
|
@@ -24,12 +24,6 @@ export interface BillingAccountDetail {
|
|
|
24
24
|
auto_recharge_enabled: boolean;
|
|
25
25
|
auto_recharge_threshold: number;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated Renamed to {@link BillingAccountDetail}. The account read now
|
|
29
|
-
* returns the canonical `billing_account_id` and no longer carries
|
|
30
|
-
* `identifier_type` (accounts are addressed by id, not by wallet/email).
|
|
31
|
-
*/
|
|
32
|
-
export type BillingBalance = BillingAccountDetail;
|
|
33
27
|
export interface BillingHistoryEntry {
|
|
34
28
|
id: string;
|
|
35
29
|
direction: "credit" | "debit";
|
|
@@ -43,15 +37,17 @@ export interface BillingHistoryEntry {
|
|
|
43
37
|
created_at: string;
|
|
44
38
|
}
|
|
45
39
|
export interface BillingHistoryResult {
|
|
46
|
-
/** Canonical
|
|
47
|
-
|
|
40
|
+
/** Canonical organization id (UUID) the entries belong to. */
|
|
41
|
+
organization_id: string;
|
|
48
42
|
entries: BillingHistoryEntry[];
|
|
49
43
|
}
|
|
50
44
|
export interface CreateCheckoutResult {
|
|
45
|
+
organization_id: string;
|
|
46
|
+
product: CheckoutProduct;
|
|
51
47
|
checkout_url: string;
|
|
52
48
|
topup_id: string;
|
|
53
49
|
}
|
|
54
|
-
export interface
|
|
50
|
+
export interface EmailOrganization {
|
|
55
51
|
id: string;
|
|
56
52
|
email: string;
|
|
57
53
|
email_credits_remaining: number;
|
|
@@ -65,8 +61,8 @@ export interface EmailBillingAccount {
|
|
|
65
61
|
export interface LinkWalletPoolImplications {
|
|
66
62
|
tier: ProjectTier | null;
|
|
67
63
|
projects_in_pool_count: number;
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
organization_api_calls_current: number;
|
|
65
|
+
organization_storage_bytes_current: number;
|
|
70
66
|
tier_limits: {
|
|
71
67
|
api_calls: number;
|
|
72
68
|
storage_bytes: number;
|
|
@@ -75,73 +71,81 @@ export interface LinkWalletPoolImplications {
|
|
|
75
71
|
}
|
|
76
72
|
export interface LinkWalletResult {
|
|
77
73
|
status: string;
|
|
78
|
-
|
|
74
|
+
organization_id: string;
|
|
79
75
|
wallet: string;
|
|
80
76
|
/** Present on v1.46+ gateways; undefined when the gateway predates the field. */
|
|
81
77
|
pool_implications?: LinkWalletPoolImplications;
|
|
82
78
|
}
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
export type OrganizationIdentifier = string;
|
|
80
|
+
export type CheckoutProduct = "balance_topup" | "tier" | "email_pack";
|
|
81
|
+
export type CreateCheckoutOptions = {
|
|
82
|
+
product: "balance_topup";
|
|
83
|
+
amountUsdMicros: number;
|
|
84
|
+
successUrl?: string;
|
|
85
|
+
cancelUrl?: string;
|
|
86
|
+
} | {
|
|
87
|
+
product: "tier";
|
|
88
|
+
tier: ProjectTier;
|
|
89
|
+
successUrl?: string;
|
|
90
|
+
cancelUrl?: string;
|
|
91
|
+
} | {
|
|
92
|
+
product: "email_pack";
|
|
93
|
+
successUrl?: string;
|
|
94
|
+
cancelUrl?: string;
|
|
95
|
+
};
|
|
88
96
|
export interface AutoRechargeOptions {
|
|
89
|
-
|
|
97
|
+
organizationId: string;
|
|
90
98
|
enabled: boolean;
|
|
91
99
|
threshold?: number;
|
|
92
100
|
}
|
|
93
101
|
export declare class Billing {
|
|
94
102
|
private readonly client;
|
|
95
|
-
readonly balance: (identifier:
|
|
96
|
-
readonly createEmail: (email: string) => Promise<
|
|
103
|
+
readonly balance: (identifier: OrganizationIdentifier) => Promise<OrganizationDetail>;
|
|
104
|
+
readonly createEmail: (email: string) => Promise<EmailOrganization>;
|
|
97
105
|
readonly autoRecharge: (opts: AutoRechargeOptions) => Promise<void>;
|
|
98
106
|
constructor(client: Client);
|
|
99
|
-
/** Check a
|
|
100
|
-
checkBalance(identifier:
|
|
107
|
+
/** Check a organization by organization id (UUID), wallet, or email. */
|
|
108
|
+
checkBalance(identifier: OrganizationIdentifier): Promise<OrganizationDetail>;
|
|
101
109
|
/**
|
|
102
|
-
* Read a
|
|
103
|
-
* or email. An
|
|
110
|
+
* Read a organization's financial detail by organization id (UUID), wallet,
|
|
111
|
+
* or email. An organization id reads `GET /orgs/v1/:org_id/billing`
|
|
104
112
|
* directly; a wallet/email is resolved through the
|
|
105
|
-
* `GET /
|
|
106
|
-
* wallet linked to the
|
|
113
|
+
* `GET /orgs/v1/lookup?wallet=|?email=` lookup. Requires SIWX from a
|
|
114
|
+
* wallet linked to the organization (or matching the looked-up `?wallet`), or an
|
|
107
115
|
* admin key; email lookups are admin-only.
|
|
108
116
|
*/
|
|
109
|
-
|
|
117
|
+
getOrganization(identifier: OrganizationIdentifier): Promise<OrganizationDetail>;
|
|
110
118
|
/**
|
|
111
|
-
* Resolve a wallet or email to its
|
|
112
|
-
* canonical `
|
|
113
|
-
* An
|
|
119
|
+
* Resolve a wallet or email to its organization detail — including the
|
|
120
|
+
* canonical `organization_id` — via `GET /orgs/v1/lookup?wallet=|?email=`.
|
|
121
|
+
* An org-id (UUID) argument is read directly instead. SIWX must match the
|
|
114
122
|
* `?wallet`; email lookups are admin-only.
|
|
115
123
|
*/
|
|
116
|
-
|
|
117
|
-
/** Fetch billing history by
|
|
118
|
-
history(identifier:
|
|
124
|
+
lookupOrganization(identifier: OrganizationIdentifier): Promise<OrganizationDetail>;
|
|
125
|
+
/** Fetch billing history by organization id (UUID), wallet, or email. */
|
|
126
|
+
history(identifier: OrganizationIdentifier, limit?: number): Promise<BillingHistoryResult>;
|
|
119
127
|
/**
|
|
120
|
-
* Fetch ledger history for a
|
|
121
|
-
* (UUID): a wallet/email identifier is first resolved to its
|
|
122
|
-
* lookup, then `GET /
|
|
123
|
-
* Requires SIWX from a wallet linked to the
|
|
128
|
+
* Fetch ledger history for a organization. History is keyed by organization id
|
|
129
|
+
* (UUID): a wallet/email identifier is first resolved to its organization via the
|
|
130
|
+
* lookup, then `GET /orgs/v1/:org_id/billing/history` is read.
|
|
131
|
+
* Requires SIWX from a wallet linked to the organization, or an admin key.
|
|
124
132
|
*/
|
|
125
|
-
getHistory(identifier:
|
|
126
|
-
/** Create a Stripe checkout URL
|
|
127
|
-
createCheckout(
|
|
128
|
-
/** Create an email-only (no-wallet)
|
|
129
|
-
|
|
133
|
+
getHistory(identifier: OrganizationIdentifier, limit?: number): Promise<BillingHistoryResult>;
|
|
134
|
+
/** Create a Stripe checkout URL for an organization. */
|
|
135
|
+
createCheckout(organizationId: string, checkout: CreateCheckoutOptions): Promise<CreateCheckoutResult>;
|
|
136
|
+
/** Create an email-only (no-wallet) organization. Sends a verification email. */
|
|
137
|
+
createEmailOrganization(email: string): Promise<EmailOrganization>;
|
|
130
138
|
/**
|
|
131
|
-
* Link a wallet to an existing email
|
|
132
|
-
* Stripe + x402 payments. `
|
|
133
|
-
* `
|
|
134
|
-
* `
|
|
135
|
-
* `POST /
|
|
139
|
+
* Link a wallet to an existing email organization to enable hybrid
|
|
140
|
+
* Stripe + x402 payments. `organizationId` is the canonical
|
|
141
|
+
* `organization_id` (UUID) returned by `createEmailOrganization` /
|
|
142
|
+
* `lookupOrganization`; the gateway addresses the route as
|
|
143
|
+
* `POST /orgs/v1/:org_id/wallets`. Returns the gateway
|
|
136
144
|
* response; v1.46+ gateways include a {@link LinkWalletPoolImplications}
|
|
137
145
|
* block describing the freshly-shared pool's tier, current usage, and limits
|
|
138
146
|
* so callers can warn before the merge pushes usage `over_limit`.
|
|
139
147
|
*/
|
|
140
|
-
linkWallet(
|
|
141
|
-
/** Create a Stripe checkout for a tier subscription/renewal/upgrade. */
|
|
142
|
-
tierCheckout(tier: string, identifier: AccountIdentifier): Promise<CreateCheckoutResult>;
|
|
143
|
-
/** Buy a $5 email pack (10,000 emails). */
|
|
144
|
-
buyEmailPack(identifier: AccountIdentifier): Promise<CreateCheckoutResult>;
|
|
148
|
+
linkWallet(organizationId: string, wallet: string): Promise<LinkWalletResult>;
|
|
145
149
|
/** Enable/disable email-pack auto-recharge. */
|
|
146
150
|
setAutoRecharge(opts: AutoRechargeOptions): Promise<void>;
|
|
147
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAS3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,WAAW,
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,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC;IAa5B,+CAA+C;IACzC,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBhE"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `billing` namespace —
|
|
2
|
+
* `billing` namespace — organizations and Stripe checkouts.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Organizations are addressed by their canonical `organization_id` (UUID). A
|
|
5
5
|
* wallet or email is resolved to that id through the
|
|
6
|
-
* `GET /
|
|
7
|
-
* accept any of the three identifier forms and resolve internally.
|
|
8
|
-
* reads require SIWX from a wallet linked to the
|
|
6
|
+
* `GET /orgs/v1/lookup?wallet=|?email=` lookup; `getOrganization` / `history`
|
|
7
|
+
* accept any of the three identifier forms and resolve internally. Organization
|
|
8
|
+
* reads require SIWX from a wallet linked to the organization (or matching the
|
|
9
9
|
* looked-up `?wallet`), or an admin key; email lookups are admin-only.
|
|
10
|
-
* Mutations such as link-wallet
|
|
11
|
-
*
|
|
10
|
+
* Mutations such as link-wallet, checkout creation, and auto-recharge require
|
|
11
|
+
* an org credential (or admin).
|
|
12
12
|
*/
|
|
13
13
|
import { LocalError } from "../errors.js";
|
|
14
14
|
import { assertEmailAddress, assertEvmAddress, assertNonEmptyString, assertPositiveSafeInteger, assertStringInSet, } from "../validation.js";
|
|
15
15
|
const BILLING_TIERS = ["prototype", "hobby", "team"];
|
|
16
16
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
17
17
|
/**
|
|
18
|
-
* Classify a billing identifier as a canonical
|
|
19
|
-
* wallet address, or an email. Wallets are lowercased;
|
|
18
|
+
* Classify a billing identifier as a canonical organization id (UUID), an EVM
|
|
19
|
+
* wallet address, or an email. Wallets are lowercased; organization ids and emails
|
|
20
20
|
* are returned verbatim. Throws {@link LocalError} for anything else.
|
|
21
21
|
*/
|
|
22
22
|
function classifyBillingIdentifier(identifier, context) {
|
|
23
23
|
assertNonEmptyString(identifier, "identifier", context);
|
|
24
24
|
if (UUID_RE.test(identifier)) {
|
|
25
|
-
return { kind: "
|
|
25
|
+
return { kind: "organization_id", value: identifier };
|
|
26
26
|
}
|
|
27
27
|
if (/^0x/i.test(identifier)) {
|
|
28
28
|
assertEvmAddress(identifier, "identifier", context);
|
|
@@ -31,28 +31,28 @@ function classifyBillingIdentifier(identifier, context) {
|
|
|
31
31
|
assertEmailAddress(identifier, "identifier", context);
|
|
32
32
|
return { kind: "email", value: identifier };
|
|
33
33
|
}
|
|
34
|
-
/** Read
|
|
35
|
-
function
|
|
36
|
-
return client.request(`/
|
|
34
|
+
/** Read organization billing detail by canonical id: `GET /orgs/v1/:org_id/billing`. */
|
|
35
|
+
function fetchOrganizationById(client, organizationId, context) {
|
|
36
|
+
return client.request(`/orgs/v1/${encodeURIComponent(organizationId)}/billing`, { context });
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Resolve a wallet / email to its
|
|
40
|
-
* `GET /
|
|
41
|
-
* detail shape as the by-id read, including the resolved `
|
|
39
|
+
* Resolve a wallet / email to its organization detail via the lookup endpoint
|
|
40
|
+
* `GET /orgs/v1/lookup?wallet=|?email=`. The lookup returns the same
|
|
41
|
+
* detail shape as the by-id read, including the resolved `organization_id`.
|
|
42
42
|
*/
|
|
43
|
-
function
|
|
44
|
-
return client.request(`/
|
|
43
|
+
function fetchOrganizationByLookup(client, kind, value, context) {
|
|
44
|
+
return client.request(`/orgs/v1/lookup?${kind}=${encodeURIComponent(value)}`, { context });
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Resolve any identifier form (
|
|
48
|
-
* detail.
|
|
47
|
+
* Resolve any identifier form (organization id / wallet / email) to the organization
|
|
48
|
+
* detail. Organization ids hit the canonical by-id read; wallet/email go through
|
|
49
49
|
* the `?wallet=`/`?email=` lookup. All paths send SIWX via the kernel default.
|
|
50
50
|
*/
|
|
51
|
-
async function
|
|
51
|
+
async function resolveOrganizationDetail(client, identifier, context) {
|
|
52
52
|
const id = classifyBillingIdentifier(identifier, context);
|
|
53
|
-
return id.kind === "
|
|
54
|
-
?
|
|
55
|
-
:
|
|
53
|
+
return id.kind === "organization_id"
|
|
54
|
+
? fetchOrganizationById(client, id.value, context)
|
|
55
|
+
: fetchOrganizationByLookup(client, id.kind, id.value, context);
|
|
56
56
|
}
|
|
57
57
|
function assertNonNegativeSafeInteger(value, name, context) {
|
|
58
58
|
if (!Number.isSafeInteger(value) || value < 0) {
|
|
@@ -64,24 +64,36 @@ function assertUsdMicrosAmount(value, name, context) {
|
|
|
64
64
|
throw new LocalError(`${name} must be a safe integer USD-micros amount of at least 500000 and whole-cent aligned.`, context);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
if (!
|
|
69
|
-
throw new LocalError("
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
function checkoutRequestBody(request, context) {
|
|
68
|
+
if (!request || typeof request !== "object" || Array.isArray(request)) {
|
|
69
|
+
throw new LocalError("checkout must be an object with a product.", context);
|
|
70
|
+
}
|
|
71
|
+
if (request.product === "balance_topup") {
|
|
72
|
+
assertUsdMicrosAmount(request.amountUsdMicros, "amountUsdMicros", context);
|
|
73
|
+
return {
|
|
74
|
+
product: "balance_topup",
|
|
75
|
+
amount_usd_micros: request.amountUsdMicros,
|
|
76
|
+
...(request.successUrl !== undefined ? { success_url: request.successUrl } : {}),
|
|
77
|
+
...(request.cancelUrl !== undefined ? { cancel_url: request.cancelUrl } : {}),
|
|
78
|
+
};
|
|
75
79
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
return {
|
|
80
|
+
if (request.product === "tier") {
|
|
81
|
+
assertStringInSet(request.tier, BILLING_TIERS, "tier", context);
|
|
82
|
+
return {
|
|
83
|
+
product: "tier",
|
|
84
|
+
tier: request.tier,
|
|
85
|
+
...(request.successUrl !== undefined ? { success_url: request.successUrl } : {}),
|
|
86
|
+
...(request.cancelUrl !== undefined ? { cancel_url: request.cancelUrl } : {}),
|
|
87
|
+
};
|
|
79
88
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
if (request.product === "email_pack") {
|
|
90
|
+
return {
|
|
91
|
+
product: "email_pack",
|
|
92
|
+
...(request.successUrl !== undefined ? { success_url: request.successUrl } : {}),
|
|
93
|
+
...(request.cancelUrl !== undefined ? { cancel_url: request.cancelUrl } : {}),
|
|
94
|
+
};
|
|
83
95
|
}
|
|
84
|
-
throw new LocalError("
|
|
96
|
+
throw new LocalError("product must be one of: balance_topup, tier, email_pack.", context);
|
|
85
97
|
}
|
|
86
98
|
export class Billing {
|
|
87
99
|
client;
|
|
@@ -91,53 +103,53 @@ export class Billing {
|
|
|
91
103
|
constructor(client) {
|
|
92
104
|
this.client = client;
|
|
93
105
|
this.balance = this.checkBalance.bind(this);
|
|
94
|
-
this.createEmail = this.
|
|
106
|
+
this.createEmail = this.createEmailOrganization.bind(this);
|
|
95
107
|
this.autoRecharge = this.setAutoRecharge.bind(this);
|
|
96
108
|
}
|
|
97
|
-
/** Check a
|
|
109
|
+
/** Check a organization by organization id (UUID), wallet, or email. */
|
|
98
110
|
async checkBalance(identifier) {
|
|
99
|
-
return this.
|
|
111
|
+
return this.getOrganization(identifier);
|
|
100
112
|
}
|
|
101
113
|
/**
|
|
102
|
-
* Read a
|
|
103
|
-
* or email. An
|
|
114
|
+
* Read a organization's financial detail by organization id (UUID), wallet,
|
|
115
|
+
* or email. An organization id reads `GET /orgs/v1/:org_id/billing`
|
|
104
116
|
* directly; a wallet/email is resolved through the
|
|
105
|
-
* `GET /
|
|
106
|
-
* wallet linked to the
|
|
117
|
+
* `GET /orgs/v1/lookup?wallet=|?email=` lookup. Requires SIWX from a
|
|
118
|
+
* wallet linked to the organization (or matching the looked-up `?wallet`), or an
|
|
107
119
|
* admin key; email lookups are admin-only.
|
|
108
120
|
*/
|
|
109
|
-
async
|
|
110
|
-
return
|
|
121
|
+
async getOrganization(identifier) {
|
|
122
|
+
return resolveOrganizationDetail(this.client, identifier, "checking balance");
|
|
111
123
|
}
|
|
112
124
|
/**
|
|
113
|
-
* Resolve a wallet or email to its
|
|
114
|
-
* canonical `
|
|
115
|
-
* An
|
|
125
|
+
* Resolve a wallet or email to its organization detail — including the
|
|
126
|
+
* canonical `organization_id` — via `GET /orgs/v1/lookup?wallet=|?email=`.
|
|
127
|
+
* An org-id (UUID) argument is read directly instead. SIWX must match the
|
|
116
128
|
* `?wallet`; email lookups are admin-only.
|
|
117
129
|
*/
|
|
118
|
-
async
|
|
119
|
-
return
|
|
130
|
+
async lookupOrganization(identifier) {
|
|
131
|
+
return resolveOrganizationDetail(this.client, identifier, "looking up organization");
|
|
120
132
|
}
|
|
121
|
-
/** Fetch billing history by
|
|
133
|
+
/** Fetch billing history by organization id (UUID), wallet, or email. */
|
|
122
134
|
async history(identifier, limit) {
|
|
123
135
|
return this.getHistory(identifier, limit);
|
|
124
136
|
}
|
|
125
137
|
/**
|
|
126
|
-
* Fetch ledger history for a
|
|
127
|
-
* (UUID): a wallet/email identifier is first resolved to its
|
|
128
|
-
* lookup, then `GET /
|
|
129
|
-
* Requires SIWX from a wallet linked to the
|
|
138
|
+
* Fetch ledger history for a organization. History is keyed by organization id
|
|
139
|
+
* (UUID): a wallet/email identifier is first resolved to its organization via the
|
|
140
|
+
* lookup, then `GET /orgs/v1/:org_id/billing/history` is read.
|
|
141
|
+
* Requires SIWX from a wallet linked to the organization, or an admin key.
|
|
130
142
|
*/
|
|
131
143
|
async getHistory(identifier, limit) {
|
|
132
144
|
if (limit !== undefined) {
|
|
133
145
|
assertPositiveSafeInteger(limit, "limit", "fetching billing history");
|
|
134
146
|
}
|
|
135
147
|
const id = classifyBillingIdentifier(identifier, "fetching billing history");
|
|
136
|
-
const
|
|
148
|
+
const organizationId = id.kind === "organization_id"
|
|
137
149
|
? id.value
|
|
138
|
-
: (await
|
|
139
|
-
.
|
|
140
|
-
const base = `/
|
|
150
|
+
: (await fetchOrganizationByLookup(this.client, id.kind, id.value, "fetching billing history"))
|
|
151
|
+
.organization_id;
|
|
152
|
+
const base = `/orgs/v1/${encodeURIComponent(organizationId)}/billing/history`;
|
|
141
153
|
const path = limit !== undefined
|
|
142
154
|
? `${base}?limit=${encodeURIComponent(String(limit))}`
|
|
143
155
|
: base;
|
|
@@ -145,79 +157,57 @@ export class Billing {
|
|
|
145
157
|
context: "fetching billing history",
|
|
146
158
|
});
|
|
147
159
|
}
|
|
148
|
-
/** Create a Stripe checkout URL
|
|
149
|
-
async createCheckout(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return this.client.request(
|
|
160
|
+
/** Create a Stripe checkout URL for an organization. */
|
|
161
|
+
async createCheckout(organizationId, checkout) {
|
|
162
|
+
assertNonEmptyString(organizationId, "organizationId", "creating checkout");
|
|
163
|
+
const body = checkoutRequestBody(checkout, "creating checkout");
|
|
164
|
+
return this.client.request(`/orgs/v1/${encodeURIComponent(organizationId)}/checkouts`, {
|
|
153
165
|
method: "POST",
|
|
154
|
-
body
|
|
166
|
+
body,
|
|
155
167
|
context: "creating checkout",
|
|
156
|
-
withAuth: false,
|
|
157
168
|
});
|
|
158
169
|
}
|
|
159
|
-
/** Create an email-only (no-wallet)
|
|
160
|
-
async
|
|
161
|
-
assertEmailAddress(email, "email", "creating email
|
|
162
|
-
return this.client.request("/
|
|
170
|
+
/** Create an email-only (no-wallet) organization. Sends a verification email. */
|
|
171
|
+
async createEmailOrganization(email) {
|
|
172
|
+
assertEmailAddress(email, "email", "creating email organization");
|
|
173
|
+
return this.client.request("/orgs/v1/email", {
|
|
163
174
|
method: "POST",
|
|
164
175
|
body: { email },
|
|
165
|
-
context: "creating email
|
|
176
|
+
context: "creating email organization",
|
|
166
177
|
withAuth: false,
|
|
167
178
|
});
|
|
168
179
|
}
|
|
169
180
|
/**
|
|
170
|
-
* Link a wallet to an existing email
|
|
171
|
-
* Stripe + x402 payments. `
|
|
172
|
-
* `
|
|
173
|
-
* `
|
|
174
|
-
* `POST /
|
|
181
|
+
* Link a wallet to an existing email organization to enable hybrid
|
|
182
|
+
* Stripe + x402 payments. `organizationId` is the canonical
|
|
183
|
+
* `organization_id` (UUID) returned by `createEmailOrganization` /
|
|
184
|
+
* `lookupOrganization`; the gateway addresses the route as
|
|
185
|
+
* `POST /orgs/v1/:org_id/wallets`. Returns the gateway
|
|
175
186
|
* response; v1.46+ gateways include a {@link LinkWalletPoolImplications}
|
|
176
187
|
* block describing the freshly-shared pool's tier, current usage, and limits
|
|
177
188
|
* so callers can warn before the merge pushes usage `over_limit`.
|
|
178
189
|
*/
|
|
179
|
-
async linkWallet(
|
|
180
|
-
assertNonEmptyString(
|
|
190
|
+
async linkWallet(organizationId, wallet) {
|
|
191
|
+
assertNonEmptyString(organizationId, "organizationId", "linking wallet");
|
|
181
192
|
assertEvmAddress(wallet, "wallet", "linking wallet");
|
|
182
|
-
return this.client.request(`/
|
|
193
|
+
return this.client.request(`/orgs/v1/${encodeURIComponent(organizationId)}/wallets`, {
|
|
183
194
|
method: "POST",
|
|
184
195
|
body: { wallet: wallet.toLowerCase() },
|
|
185
196
|
context: "linking wallet",
|
|
186
197
|
});
|
|
187
198
|
}
|
|
188
|
-
/** Create a Stripe checkout for a tier subscription/renewal/upgrade. */
|
|
189
|
-
async tierCheckout(tier, identifier) {
|
|
190
|
-
assertStringInSet(tier, BILLING_TIERS, "tier", "creating tier checkout");
|
|
191
|
-
const body = checkoutIdentifierBody(identifier, "creating tier checkout");
|
|
192
|
-
return this.client.request(`/billing/v1/tiers/${encodeURIComponent(tier)}/checkout`, {
|
|
193
|
-
method: "POST",
|
|
194
|
-
body,
|
|
195
|
-
context: "creating tier checkout",
|
|
196
|
-
withAuth: false,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
/** Buy a $5 email pack (10,000 emails). */
|
|
200
|
-
async buyEmailPack(identifier) {
|
|
201
|
-
const body = checkoutIdentifierBody(identifier, "creating email pack checkout");
|
|
202
|
-
return this.client.request("/billing/v1/email-packs/checkout", {
|
|
203
|
-
method: "POST",
|
|
204
|
-
body,
|
|
205
|
-
context: "creating email pack checkout",
|
|
206
|
-
withAuth: false,
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
199
|
/** Enable/disable email-pack auto-recharge. */
|
|
210
200
|
async setAutoRecharge(opts) {
|
|
201
|
+
assertNonEmptyString(opts.organizationId, "organizationId", "setting auto-recharge");
|
|
211
202
|
const body = {
|
|
212
|
-
billing_account_id: opts.billingAccountId,
|
|
213
203
|
enabled: opts.enabled,
|
|
214
204
|
};
|
|
215
205
|
if (opts.threshold !== undefined) {
|
|
216
206
|
assertNonNegativeSafeInteger(opts.threshold, "threshold", "setting auto-recharge");
|
|
217
207
|
body.threshold = opts.threshold;
|
|
218
208
|
}
|
|
219
|
-
await this.client.request(
|
|
220
|
-
method: "
|
|
209
|
+
await this.client.request(`/orgs/v1/${encodeURIComponent(opts.organizationId)}/billing/auto-recharge`, {
|
|
210
|
+
method: "PATCH",
|
|
221
211
|
body,
|
|
222
212
|
context: "setting auto-recharge",
|
|
223
213
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB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AAI;YACJ,OAAO,EAAE,uBAAuB;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -57,7 +57,7 @@ export type DevicePollResult = {
|
|
|
57
57
|
kind: "expired_token";
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* Organization overview. Forward-compatible: the gateway owns the exact shape and
|
|
61
61
|
* may add fields, so unknown keys are preserved via the index signature.
|
|
62
62
|
* `scope.kind` is `"email"` for the operator-session (email-union) and
|
|
63
63
|
* `"wallet"` for a SIWX slice.
|
|
@@ -68,7 +68,7 @@ export interface OperatorOverview {
|
|
|
68
68
|
principal?: string;
|
|
69
69
|
};
|
|
70
70
|
rollup?: Record<string, unknown>;
|
|
71
|
-
|
|
71
|
+
organizations?: unknown[];
|
|
72
72
|
wallets?: unknown[];
|
|
73
73
|
advisories?: unknown[];
|
|
74
74
|
[key: string]: unknown;
|
|
@@ -243,7 +243,7 @@ export declare class Operator {
|
|
|
243
243
|
*/
|
|
244
244
|
devicePoll(deviceCode: string): Promise<DevicePollResult>;
|
|
245
245
|
/**
|
|
246
|
-
* Fetch the
|
|
246
|
+
* Fetch the organization overview. With `opts.token` the request carries the
|
|
247
247
|
* operator-session bearer and returns the email-union; without it the request
|
|
248
248
|
* falls back to the credential provider's default auth (SIWX) and returns
|
|
249
249
|
* that wallet's slice. The CLI always passes a token (human-only surface); the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../src/namespaces/operator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAA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