@ledewire/browser 0.8.1 → 0.9.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 +31 -0
- package/dist/index.d.ts +1038 -33
- package/dist/index.js +125 -16
- package/dist/index.js.map +1 -1
- package/dist/ledewire.min.js +1 -1
- package/dist/ledewire.min.js.map +1 -1
- package/llms.txt +41 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ const lw = init({
|
|
|
50
50
|
| `lw.checkout` | Checkout state — what action is required next |
|
|
51
51
|
| `lw.user.spendCap` | Buyer's daily spend cap — read and update the ceiling |
|
|
52
52
|
| `lw.user.mcpKeys` | Manage buyer MCP API keys for the Ledewire MCP server |
|
|
53
|
+
| `lw.company` | Company wallets: membership, invitations, members, Machine users, top-ups |
|
|
53
54
|
| `lw.seller.content` | List, search, and get store content (API key auth) |
|
|
54
55
|
|
|
55
56
|
## Example: Fetch Google OAuth Client ID Before Sign-In
|
|
@@ -135,6 +136,36 @@ const keys = await lw.user.mcpKeys.list() // secrets never included
|
|
|
135
136
|
await lw.user.mcpKeys.revoke(keys[0].id) // to change scopes: revoke + recreate
|
|
136
137
|
```
|
|
137
138
|
|
|
139
|
+
## Example: Company Wallets
|
|
140
|
+
|
|
141
|
+
A Company is a shared wallet that pays for its members' purchases. A member
|
|
142
|
+
**never sees the Company balance**: `wallet.balance()` returns
|
|
143
|
+
`balance_cents: null`, and `remaining_cents` / `company_name` say what they may
|
|
144
|
+
still spend today and whose wallet pays. Handle `null` before rendering or
|
|
145
|
+
doing arithmetic on a balance.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const wallet = await lw.wallet.balance()
|
|
149
|
+
const label =
|
|
150
|
+
wallet.company_name !== null
|
|
151
|
+
? `${wallet.company_name} pays — ${wallet.remaining_cents ?? '∞'}c left today`
|
|
152
|
+
: `Balance: ${wallet.balance_cents}c`
|
|
153
|
+
|
|
154
|
+
// Accepting an invitation needs the token from the invitation email:
|
|
155
|
+
await lw.company.invitations.accept({ token }) // existing account
|
|
156
|
+
await lw.auth.signup({ email, password, name, company_invitation_token: token }) // new account
|
|
157
|
+
|
|
158
|
+
// Company admins: members, spend caps, Machine users, top-ups, reports
|
|
159
|
+
const { data: members } = await lw.company.members.list()
|
|
160
|
+
await lw.company.members.update(members[0].id, { daily_spend_limit_cents: 5000 })
|
|
161
|
+
const { data: pending } = await lw.company.wallet.listPendingTopUps()
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The full surface (`membership`, `invitations`, `members`, `machineUsers` with
|
|
165
|
+
`buyerKeys` / `mcpKeys`, `wallet`, `purchases`, `spend`) matches
|
|
166
|
+
[`@ledewire/node`](../node/README.md#example-company-wallets). Admin-only
|
|
167
|
+
methods throw `ForbiddenError` for a plain member.
|
|
168
|
+
|
|
138
169
|
## Example: Seller Content Discovery
|
|
139
170
|
|
|
140
171
|
Use `lw.seller.loginWithApiKey` with only the `key` to obtain a read-only token,
|