@scell/sdk 1.2.0 → 1.5.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/LICENSE +0 -0
- package/README.md +61 -2
- package/dist/index.d.mts +2353 -236
- package/dist/index.d.ts +2353 -236
- package/dist/index.js +1308 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1308 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +3 -1
- package/src/errors.ts +0 -0
- package/src/index.ts +42 -2
- package/src/resources/api-keys.ts +0 -0
- package/src/resources/auth.ts +0 -0
- package/src/resources/balance.ts +0 -0
- package/src/resources/billing.ts +49 -0
- package/src/resources/companies.ts +0 -0
- package/src/resources/fiscal.ts +128 -0
- package/src/resources/invoices.ts +0 -0
- package/src/resources/signatures.ts +33 -0
- package/src/resources/stats.ts +29 -0
- package/src/resources/sub-tenants.ts +41 -0
- package/src/resources/tenant-credit-notes.ts +301 -0
- package/src/resources/tenant-direct-credit-notes.ts +360 -0
- package/src/resources/tenant-direct-invoices.ts +424 -0
- package/src/resources/tenant-incoming-invoices.ts +429 -0
- package/src/resources/webhooks.ts +0 -0
- package/src/tenant-client.ts +105 -0
- package/src/types/api-keys.ts +0 -0
- package/src/types/auth.ts +0 -0
- package/src/types/balance.ts +0 -0
- package/src/types/billing.ts +73 -0
- package/src/types/common.ts +0 -0
- package/src/types/companies.ts +0 -0
- package/src/types/fiscal.ts +251 -0
- package/src/types/index.ts +103 -0
- package/src/types/invoices.ts +0 -0
- package/src/types/signatures.ts +0 -0
- package/src/types/stats.ts +37 -0
- package/src/types/sub-tenants.ts +57 -0
- package/src/types/tenant-credit-notes.ts +128 -0
- package/src/types/tenant-invoices.ts +390 -0
- package/src/types/tenant-profile.ts +51 -0
- package/src/types/webhooks.ts +0 -0
- package/src/utils/retry.ts +0 -0
- package/src/utils/webhook-verify.ts +0 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant Invoices types
|
|
3
|
+
*
|
|
4
|
+
* Types for multi-tenant invoice operations including direct invoices,
|
|
5
|
+
* incoming invoices, and credit notes.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
Address,
|
|
12
|
+
CurrencyCode,
|
|
13
|
+
DateString,
|
|
14
|
+
DateTimeString,
|
|
15
|
+
PaginationOptions,
|
|
16
|
+
Siren,
|
|
17
|
+
Siret,
|
|
18
|
+
UUID,
|
|
19
|
+
} from './common.js';
|
|
20
|
+
import type { InvoiceFormat, InvoiceLine, InvoiceLineInput, InvoiceStatus } from './invoices.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Invoice direction for tenant operations
|
|
24
|
+
*/
|
|
25
|
+
export type TenantInvoiceDirection = 'outgoing' | 'incoming';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Buyer information for direct invoice creation
|
|
29
|
+
*/
|
|
30
|
+
export interface TenantInvoiceBuyer {
|
|
31
|
+
/** Buyer company name */
|
|
32
|
+
company_name: string;
|
|
33
|
+
/** SIREN number (9 digits) - optional */
|
|
34
|
+
siren?: Siren | undefined;
|
|
35
|
+
/** SIRET number (14 digits) - optional */
|
|
36
|
+
siret?: Siret | undefined;
|
|
37
|
+
/** VAT number - optional */
|
|
38
|
+
vat_number?: string | undefined;
|
|
39
|
+
/** Buyer address */
|
|
40
|
+
address: Address;
|
|
41
|
+
/** Buyer email for notifications */
|
|
42
|
+
email: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Seller information for incoming invoice creation
|
|
47
|
+
*/
|
|
48
|
+
export interface TenantInvoiceSeller {
|
|
49
|
+
/** Seller company name */
|
|
50
|
+
company_name: string;
|
|
51
|
+
/** SIREN number (9 digits) - required, validated with Luhn algorithm */
|
|
52
|
+
siren: Siren;
|
|
53
|
+
/** SIRET number (14 digits) - optional */
|
|
54
|
+
siret?: Siret | undefined;
|
|
55
|
+
/** VAT number - optional */
|
|
56
|
+
vat_number?: string | undefined;
|
|
57
|
+
/** Seller address */
|
|
58
|
+
address: Address;
|
|
59
|
+
/** Seller email */
|
|
60
|
+
email: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Input for creating a tenant direct invoice
|
|
65
|
+
*
|
|
66
|
+
* Direct invoices are outgoing invoices created by a tenant
|
|
67
|
+
* that are billed directly to an external buyer (not a sub-tenant).
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const params: CreateTenantDirectInvoiceParams = {
|
|
72
|
+
* company_id: 'company-uuid',
|
|
73
|
+
* buyer: {
|
|
74
|
+
* company_name: 'Client SARL',
|
|
75
|
+
* siret: '12345678901234',
|
|
76
|
+
* address: {
|
|
77
|
+
* line1: '123 Rue Example',
|
|
78
|
+
* postal_code: '75001',
|
|
79
|
+
* city: 'Paris',
|
|
80
|
+
* country: 'FR'
|
|
81
|
+
* },
|
|
82
|
+
* email: 'contact@client.com'
|
|
83
|
+
* },
|
|
84
|
+
* lines: [{
|
|
85
|
+
* description: 'Consulting services',
|
|
86
|
+
* quantity: 10,
|
|
87
|
+
* unit_price: 100,
|
|
88
|
+
* tax_rate: 20,
|
|
89
|
+
* total_ht: 1000,
|
|
90
|
+
* total_tax: 200,
|
|
91
|
+
* total_ttc: 1200
|
|
92
|
+
* }],
|
|
93
|
+
* issue_date: '2026-01-26'
|
|
94
|
+
* };
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export interface CreateTenantDirectInvoiceParams {
|
|
98
|
+
/** Company UUID issuing the invoice */
|
|
99
|
+
company_id: UUID;
|
|
100
|
+
/** Buyer information */
|
|
101
|
+
buyer: TenantInvoiceBuyer;
|
|
102
|
+
/** Invoice line items */
|
|
103
|
+
lines: InvoiceLineInput[];
|
|
104
|
+
/** Issue date (YYYY-MM-DD) - defaults to today */
|
|
105
|
+
issue_date?: DateString | undefined;
|
|
106
|
+
/** Due date (YYYY-MM-DD) */
|
|
107
|
+
due_date?: DateString | undefined;
|
|
108
|
+
/** Currency code (ISO 4217) - defaults to EUR */
|
|
109
|
+
currency?: CurrencyCode | undefined;
|
|
110
|
+
/** Notes or comments on the invoice */
|
|
111
|
+
notes?: string | undefined;
|
|
112
|
+
/** Custom metadata */
|
|
113
|
+
metadata?: Record<string, unknown> | undefined;
|
|
114
|
+
/** Output format for the invoice */
|
|
115
|
+
output_format?: InvoiceFormat | undefined;
|
|
116
|
+
/** External reference ID */
|
|
117
|
+
external_id?: string | undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Input for creating a tenant direct credit note
|
|
122
|
+
*
|
|
123
|
+
* Direct credit notes are linked to direct invoices and allow
|
|
124
|
+
* partial or total refunds.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const params: CreateTenantDirectCreditNoteParams = {
|
|
129
|
+
* invoice_id: 'invoice-uuid',
|
|
130
|
+
* reason: 'Product returned - damaged item',
|
|
131
|
+
* type: 'partial',
|
|
132
|
+
* items: [{ invoice_line_id: 'line-uuid', quantity: 2 }]
|
|
133
|
+
* };
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export interface CreateTenantDirectCreditNoteParams {
|
|
137
|
+
/** Invoice UUID to credit */
|
|
138
|
+
invoice_id: UUID;
|
|
139
|
+
/** Reason for the credit note */
|
|
140
|
+
reason: string;
|
|
141
|
+
/** Type: 'partial' or 'total' */
|
|
142
|
+
type: 'partial' | 'total';
|
|
143
|
+
/** Items to credit (required for partial credit notes) */
|
|
144
|
+
items?: TenantCreditNoteItemInput[] | undefined;
|
|
145
|
+
/** Custom metadata */
|
|
146
|
+
metadata?: Record<string, unknown> | undefined;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Credit note item input
|
|
151
|
+
*/
|
|
152
|
+
export interface TenantCreditNoteItemInput {
|
|
153
|
+
/** Invoice line ID to credit */
|
|
154
|
+
invoice_line_id: UUID;
|
|
155
|
+
/** Quantity to credit (defaults to full line quantity) */
|
|
156
|
+
quantity?: number | undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Input for creating an incoming invoice for a sub-tenant
|
|
161
|
+
*
|
|
162
|
+
* Incoming invoices represent invoices received by a sub-tenant
|
|
163
|
+
* from an external supplier.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const params: CreateIncomingInvoiceParams = {
|
|
168
|
+
* invoice_number: 'SUPP-2026-001',
|
|
169
|
+
* company_id: 'company-uuid',
|
|
170
|
+
* seller: {
|
|
171
|
+
* company_name: 'Supplier Corp',
|
|
172
|
+
* siren: '123456789',
|
|
173
|
+
* address: {
|
|
174
|
+
* line1: '456 Avenue Fournisseur',
|
|
175
|
+
* postal_code: '69001',
|
|
176
|
+
* city: 'Lyon',
|
|
177
|
+
* country: 'FR'
|
|
178
|
+
* },
|
|
179
|
+
* email: 'invoices@supplier.com'
|
|
180
|
+
* },
|
|
181
|
+
* lines: [{
|
|
182
|
+
* description: 'Raw materials',
|
|
183
|
+
* quantity: 100,
|
|
184
|
+
* unit_price: 5,
|
|
185
|
+
* tax_rate: 20,
|
|
186
|
+
* total_ht: 500,
|
|
187
|
+
* total_tax: 100,
|
|
188
|
+
* total_ttc: 600
|
|
189
|
+
* }],
|
|
190
|
+
* issue_date: '2026-01-20',
|
|
191
|
+
* total_ht: 500,
|
|
192
|
+
* total_ttc: 600
|
|
193
|
+
* };
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export interface CreateIncomingInvoiceParams {
|
|
197
|
+
/** Supplier's invoice number */
|
|
198
|
+
invoice_number: string;
|
|
199
|
+
/** Company UUID receiving the invoice */
|
|
200
|
+
company_id: UUID;
|
|
201
|
+
/** Seller (supplier) information */
|
|
202
|
+
seller: TenantInvoiceSeller;
|
|
203
|
+
/** Invoice line items */
|
|
204
|
+
lines: InvoiceLineInput[];
|
|
205
|
+
/** Issue date (YYYY-MM-DD) */
|
|
206
|
+
issue_date: DateString;
|
|
207
|
+
/** Due date (YYYY-MM-DD) */
|
|
208
|
+
due_date?: DateString | undefined;
|
|
209
|
+
/** Total excluding tax */
|
|
210
|
+
total_ht: number;
|
|
211
|
+
/** Total including tax */
|
|
212
|
+
total_ttc: number;
|
|
213
|
+
/** Currency code (ISO 4217) - defaults to EUR */
|
|
214
|
+
currency?: CurrencyCode | undefined;
|
|
215
|
+
/** External reference ID */
|
|
216
|
+
external_id?: string | undefined;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Input for updating a tenant invoice
|
|
221
|
+
*
|
|
222
|
+
* Only invoices in 'draft' status can be updated.
|
|
223
|
+
*/
|
|
224
|
+
export interface UpdateTenantInvoiceParams {
|
|
225
|
+
/** Updated buyer information */
|
|
226
|
+
buyer?: Partial<TenantInvoiceBuyer> | undefined;
|
|
227
|
+
/** Updated line items (replaces all existing lines) */
|
|
228
|
+
lines?: InvoiceLineInput[] | undefined;
|
|
229
|
+
/** Updated due date */
|
|
230
|
+
due_date?: DateString | undefined;
|
|
231
|
+
/** Updated notes */
|
|
232
|
+
notes?: string | undefined;
|
|
233
|
+
/** Updated metadata */
|
|
234
|
+
metadata?: Record<string, unknown> | undefined;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Input for updating a tenant credit note
|
|
239
|
+
*
|
|
240
|
+
* Only credit notes in 'draft' status can be updated.
|
|
241
|
+
*/
|
|
242
|
+
export interface UpdateTenantCreditNoteParams {
|
|
243
|
+
/** Updated reason */
|
|
244
|
+
reason?: string | undefined;
|
|
245
|
+
/** Updated items (for partial credit notes) */
|
|
246
|
+
items?: TenantCreditNoteItemInput[] | undefined;
|
|
247
|
+
/** Updated metadata */
|
|
248
|
+
metadata?: Record<string, unknown> | undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Filter options for tenant invoice listing
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* const filters: TenantInvoiceFilters = {
|
|
257
|
+
* status: 'validated',
|
|
258
|
+
* direction: 'outgoing',
|
|
259
|
+
* date_from: '2026-01-01',
|
|
260
|
+
* date_to: '2026-01-31',
|
|
261
|
+
* per_page: 50
|
|
262
|
+
* };
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export interface TenantInvoiceFilters extends PaginationOptions {
|
|
266
|
+
/** Search in invoice number, buyer/seller name */
|
|
267
|
+
search?: string | undefined;
|
|
268
|
+
/** Filter by status (single or multiple) */
|
|
269
|
+
status?: InvoiceStatus | InvoiceStatus[] | undefined;
|
|
270
|
+
/** Filter by direction */
|
|
271
|
+
direction?: TenantInvoiceDirection | undefined;
|
|
272
|
+
/** Filter invoices from this date (YYYY-MM-DD) */
|
|
273
|
+
date_from?: DateString | undefined;
|
|
274
|
+
/** Filter invoices to this date (YYYY-MM-DD) */
|
|
275
|
+
date_to?: DateString | undefined;
|
|
276
|
+
/** Filter by buyer SIRET */
|
|
277
|
+
buyer_siret?: Siret | undefined;
|
|
278
|
+
/** Filter by seller SIRET */
|
|
279
|
+
seller_siret?: Siret | undefined;
|
|
280
|
+
/** Minimum total amount (TTC) */
|
|
281
|
+
min_amount?: number | undefined;
|
|
282
|
+
/** Maximum total amount (TTC) */
|
|
283
|
+
max_amount?: number | undefined;
|
|
284
|
+
/** Sort field */
|
|
285
|
+
sort?: string | undefined;
|
|
286
|
+
/** Sort order */
|
|
287
|
+
order?: 'asc' | 'desc' | undefined;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Filter options for tenant credit note listing
|
|
292
|
+
*/
|
|
293
|
+
export interface TenantCreditNoteFilters extends PaginationOptions {
|
|
294
|
+
/** Filter by status */
|
|
295
|
+
status?: 'draft' | 'sent' | 'cancelled' | undefined;
|
|
296
|
+
/** Filter credit notes from this date (YYYY-MM-DD) */
|
|
297
|
+
date_from?: DateString | undefined;
|
|
298
|
+
/** Filter credit notes to this date (YYYY-MM-DD) */
|
|
299
|
+
date_to?: DateString | undefined;
|
|
300
|
+
/** Sort field */
|
|
301
|
+
sort?: string | undefined;
|
|
302
|
+
/** Sort order */
|
|
303
|
+
order?: 'asc' | 'desc' | undefined;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Tenant Invoice entity
|
|
308
|
+
*
|
|
309
|
+
* Extended invoice entity with tenant-specific fields.
|
|
310
|
+
*/
|
|
311
|
+
export interface TenantInvoice {
|
|
312
|
+
id: UUID;
|
|
313
|
+
external_id: string | null;
|
|
314
|
+
invoice_number: string;
|
|
315
|
+
direction: TenantInvoiceDirection;
|
|
316
|
+
output_format: InvoiceFormat;
|
|
317
|
+
issue_date: DateString;
|
|
318
|
+
due_date: DateString | null;
|
|
319
|
+
currency: CurrencyCode;
|
|
320
|
+
total_ht: number;
|
|
321
|
+
total_tax: number;
|
|
322
|
+
total_ttc: number;
|
|
323
|
+
seller: {
|
|
324
|
+
siret: Siret | null;
|
|
325
|
+
siren: Siren | null;
|
|
326
|
+
name: string;
|
|
327
|
+
address: Address;
|
|
328
|
+
email?: string | undefined;
|
|
329
|
+
};
|
|
330
|
+
buyer: {
|
|
331
|
+
siret: Siret | null;
|
|
332
|
+
siren: Siren | null;
|
|
333
|
+
name: string;
|
|
334
|
+
address: Address;
|
|
335
|
+
email?: string | undefined;
|
|
336
|
+
};
|
|
337
|
+
lines: InvoiceLine[] | null;
|
|
338
|
+
status: InvoiceStatus;
|
|
339
|
+
status_message: string | null;
|
|
340
|
+
notes: string | null;
|
|
341
|
+
metadata: Record<string, unknown> | null;
|
|
342
|
+
tenant_id: UUID;
|
|
343
|
+
sub_tenant_id: UUID | null;
|
|
344
|
+
company_id: UUID;
|
|
345
|
+
created_at: DateTimeString;
|
|
346
|
+
updated_at: DateTimeString;
|
|
347
|
+
validated_at: DateTimeString | null;
|
|
348
|
+
paid_at: DateTimeString | null;
|
|
349
|
+
payment_reference: string | null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Tenant Credit Note entity
|
|
354
|
+
*/
|
|
355
|
+
export interface TenantCreditNote {
|
|
356
|
+
id: UUID;
|
|
357
|
+
credit_note_number: string;
|
|
358
|
+
invoice_id: UUID;
|
|
359
|
+
tenant_id: UUID;
|
|
360
|
+
sub_tenant_id: UUID | null;
|
|
361
|
+
status: 'draft' | 'sent' | 'cancelled';
|
|
362
|
+
type: 'partial' | 'total';
|
|
363
|
+
reason: string;
|
|
364
|
+
subtotal: number;
|
|
365
|
+
tax_amount: number;
|
|
366
|
+
total: number;
|
|
367
|
+
currency: CurrencyCode;
|
|
368
|
+
buyer_name: string | null;
|
|
369
|
+
buyer_siret: Siret | null;
|
|
370
|
+
seller_name: string | null;
|
|
371
|
+
seller_siret: Siret | null;
|
|
372
|
+
issue_date: DateString;
|
|
373
|
+
metadata: Record<string, unknown> | null;
|
|
374
|
+
created_at: DateTimeString;
|
|
375
|
+
updated_at: DateTimeString;
|
|
376
|
+
items: TenantCreditNoteItem[] | null;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Tenant Credit Note Item
|
|
381
|
+
*/
|
|
382
|
+
export interface TenantCreditNoteItem {
|
|
383
|
+
id: UUID;
|
|
384
|
+
invoice_line_id: UUID | null;
|
|
385
|
+
description: string;
|
|
386
|
+
quantity: number;
|
|
387
|
+
unit_price: number;
|
|
388
|
+
tax_rate: number;
|
|
389
|
+
total: number;
|
|
390
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant Profile Types
|
|
3
|
+
*
|
|
4
|
+
* Types for tenant profile and identity API.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface TenantProfile {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
siret?: string;
|
|
15
|
+
siren?: string;
|
|
16
|
+
address?: TenantAddress | null;
|
|
17
|
+
kyb_status?: string;
|
|
18
|
+
environment?: string;
|
|
19
|
+
created_at?: string;
|
|
20
|
+
updated_at?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface TenantAddress {
|
|
24
|
+
line1: string;
|
|
25
|
+
line2?: string;
|
|
26
|
+
postal_code: string;
|
|
27
|
+
city: string;
|
|
28
|
+
country?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface UpdateTenantProfileInput {
|
|
32
|
+
name?: string;
|
|
33
|
+
email?: string;
|
|
34
|
+
phone?: string;
|
|
35
|
+
address?: TenantAddress;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface TenantBalance {
|
|
39
|
+
credits: number;
|
|
40
|
+
currency: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TenantQuickStats {
|
|
44
|
+
invoices_this_month: number;
|
|
45
|
+
credit_notes_this_month: number;
|
|
46
|
+
signatures_this_month: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface RegenerateKeyResult {
|
|
50
|
+
tenant_key: string;
|
|
51
|
+
}
|
package/src/types/webhooks.ts
CHANGED
|
File without changes
|
package/src/utils/retry.ts
CHANGED
|
File without changes
|
|
File without changes
|