@beel_es/sdk 1.1.0 → 1.2.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 +73 -4
- package/dist/index.d.mts +23183 -6153
- package/dist/index.d.ts +23183 -6153
- package/dist/index.js +756 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +742 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -32,23 +32,92 @@ import { BeeL } from '@beel_es/sdk';
|
|
|
32
32
|
|
|
33
33
|
const beel = new BeeL({ apiKey: 'beel_sk_live_...' });
|
|
34
34
|
|
|
35
|
+
// Address a company (NIF) explicitly — the recommended multi-NIF surface
|
|
36
|
+
const company = beel.company('company-uuid');
|
|
37
|
+
|
|
35
38
|
// Create a draft invoice
|
|
36
|
-
const invoice = await
|
|
39
|
+
const invoice = await company.invoices.create({
|
|
37
40
|
type: 'STANDARD',
|
|
38
41
|
recipient: { customer_id: 'customer-uuid' },
|
|
39
42
|
lines: [
|
|
40
|
-
{ description: 'Consulting', quantity: 1, unit_price: 100, discount_percentage: 0 },
|
|
43
|
+
{ line_type: 'NORMAL', description: 'Consulting', quantity: 1, unit_price: 100, discount_percentage: 0 },
|
|
41
44
|
],
|
|
42
45
|
});
|
|
43
46
|
|
|
44
47
|
console.log(invoice.id); // UUID assigned immediately
|
|
45
48
|
|
|
46
49
|
// Issue it to assign an invoice number and trigger VeriFactu
|
|
47
|
-
const issued = await
|
|
50
|
+
const issued = await company.invoices.issue(invoice.id);
|
|
48
51
|
console.log(issued.invoice_number); // e.g. "A-2026/0001"
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
##
|
|
54
|
+
## Companies (multi-NIF)
|
|
55
|
+
|
|
56
|
+
Every operation on `beel.company(companyId)` addresses the company in the URL path, so it
|
|
57
|
+
works with any number of NIFs and never depends on a session focus:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const company = beel.company('company-uuid');
|
|
61
|
+
|
|
62
|
+
// Invoices — full lifecycle
|
|
63
|
+
const { invoices, pagination } = await company.invoices.list({ status: 'ISSUED' });
|
|
64
|
+
await company.invoices.issue('invoice-uuid');
|
|
65
|
+
await company.invoices.void('invoice-uuid', { reason: 'Billing error' });
|
|
66
|
+
await company.invoices.createCorrective('invoice-uuid', { ... });
|
|
67
|
+
const pdf = await company.invoices.getPdf('invoice-uuid');
|
|
68
|
+
|
|
69
|
+
// Customers, products, series
|
|
70
|
+
const customer = await company.customers.create({ ... });
|
|
71
|
+
const product = await company.products.create({ ... });
|
|
72
|
+
await company.series.ensureDefaults(); // idempotent seeding of the typed default series
|
|
73
|
+
|
|
74
|
+
// Recurring invoices
|
|
75
|
+
await company.recurringInvoices.create({ ... });
|
|
76
|
+
await company.recurringInvoices.setStatus('rec-uuid', { status: 'PAUSED' });
|
|
77
|
+
|
|
78
|
+
// Company health
|
|
79
|
+
const summary = await company.fiscalSummary({ year: 2026 });
|
|
80
|
+
const readiness = await company.issuingReadiness();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Accounts (managed accounts, members & webhooks)
|
|
84
|
+
|
|
85
|
+
For integrators managing several accounts (provisioning, gestorías, platforms):
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// List and provision managed accounts
|
|
89
|
+
const { accounts } = await beel.accounts.list();
|
|
90
|
+
const created = await beel.accounts.provision({ external_ref: 'client-42' });
|
|
91
|
+
|
|
92
|
+
// Scope to one account
|
|
93
|
+
const account = beel.account(created.account_id);
|
|
94
|
+
|
|
95
|
+
// Companies (NIFs) under the account
|
|
96
|
+
const { companies } = await account.companies.list();
|
|
97
|
+
await account.companies.create({ nif: 'B12345678', ... });
|
|
98
|
+
|
|
99
|
+
// Members, roles and per-company grants
|
|
100
|
+
const members = await account.members.list();
|
|
101
|
+
await account.members.putGrant('member-id', 'company-id', { permissions: [...] });
|
|
102
|
+
|
|
103
|
+
// Invitations
|
|
104
|
+
await account.invitations.create({ invited_email: 'user@example.com', account_role: 'MEMBER' });
|
|
105
|
+
|
|
106
|
+
// Account-scoped webhooks
|
|
107
|
+
const webhook = await account.webhooks.create({ url: 'https://...', events: ['invoice.issued'] });
|
|
108
|
+
await account.webhooks.test(webhook.id);
|
|
109
|
+
await account.webhooks.rotateSecret(webhook.id);
|
|
110
|
+
|
|
111
|
+
// Usage & ownership
|
|
112
|
+
const usage = await account.usage();
|
|
113
|
+
await account.createClaimToken(); // let the end user claim the account
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Resources (deprecated session-focus surface)
|
|
117
|
+
|
|
118
|
+
> **Deprecated:** the API contract marks the whole session-focus surface (`beel.invoices`,
|
|
119
|
+
> `beel.customers`, `beel.products`, `beel.series`, `beel.configuration`) as deprecated.
|
|
120
|
+
> Prefer the company-scoped equivalents above. These keep working during the sunset window.
|
|
52
121
|
|
|
53
122
|
```typescript
|
|
54
123
|
// Invoices
|