@scell/sdk 1.4.0 → 1.7.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 +92 -9
- package/dist/index.d.mts +223 -4
- package/dist/index.d.ts +223 -4
- package/dist/index.js +207 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +207 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +0 -0
- package/src/errors.ts +0 -0
- package/src/index.ts +32 -4
- 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 +0 -0
- package/src/resources/companies.ts +0 -0
- package/src/resources/credit-notes.ts +192 -0
- package/src/resources/fiscal.ts +1 -1
- package/src/resources/invoices.ts +24 -0
- package/src/resources/signatures.ts +33 -0
- package/src/resources/stats.ts +0 -0
- package/src/resources/sub-tenants.ts +0 -0
- package/src/resources/tenant-credit-notes.ts +0 -0
- package/src/resources/tenant-direct-credit-notes.ts +0 -0
- package/src/resources/tenant-direct-invoices.ts +0 -0
- package/src/resources/tenant-incoming-invoices.ts +0 -0
- package/src/resources/webhooks.ts +0 -0
- package/src/tenant-client.ts +0 -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 +0 -0
- package/src/types/common.ts +0 -0
- package/src/types/companies.ts +0 -0
- package/src/types/credit-notes.ts +57 -0
- package/src/types/fiscal.ts +0 -0
- package/src/types/index.ts +8 -0
- package/src/types/invoices.ts +0 -0
- package/src/types/signatures.ts +0 -0
- package/src/types/stats.ts +0 -0
- package/src/types/sub-tenants.ts +0 -0
- package/src/types/tenant-credit-notes.ts +0 -0
- package/src/types/tenant-invoices.ts +0 -0
- package/src/types/tenant-profile.ts +0 -0
- package/src/types/webhooks.ts +0 -0
- package/src/utils/retry.ts +0 -0
- package/src/utils/webhook-verify.ts +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1573,7 +1573,7 @@ var FiscalResource = class {
|
|
|
1573
1573
|
return this.http.post("/tenant/fiscal/rules", input, requestOptions);
|
|
1574
1574
|
}
|
|
1575
1575
|
async updateRule(id, input, requestOptions) {
|
|
1576
|
-
return this.http.
|
|
1576
|
+
return this.http.put(`/tenant/fiscal/rules/${id}`, input, requestOptions);
|
|
1577
1577
|
}
|
|
1578
1578
|
async exportRules(options, requestOptions) {
|
|
1579
1579
|
return this.http.get("/tenant/fiscal/rules/export", options, requestOptions);
|
|
@@ -2273,6 +2273,140 @@ var CompaniesResource = class {
|
|
|
2273
2273
|
}
|
|
2274
2274
|
};
|
|
2275
2275
|
|
|
2276
|
+
// src/resources/credit-notes.ts
|
|
2277
|
+
var CreditNotesResource = class {
|
|
2278
|
+
constructor(http) {
|
|
2279
|
+
this.http = http;
|
|
2280
|
+
}
|
|
2281
|
+
/**
|
|
2282
|
+
* List credit notes with optional filtering
|
|
2283
|
+
*
|
|
2284
|
+
* @param options - Filter and pagination options
|
|
2285
|
+
* @param requestOptions - Request options
|
|
2286
|
+
* @returns Paginated list of credit notes
|
|
2287
|
+
*
|
|
2288
|
+
* @example
|
|
2289
|
+
* ```typescript
|
|
2290
|
+
* const { data, meta } = await client.creditNotes.list({ per_page: 50 });
|
|
2291
|
+
* console.log(`Found ${meta.total} credit notes`);
|
|
2292
|
+
* ```
|
|
2293
|
+
*/
|
|
2294
|
+
async list(options = {}, requestOptions) {
|
|
2295
|
+
return this.http.get(
|
|
2296
|
+
"/credit-notes",
|
|
2297
|
+
options,
|
|
2298
|
+
requestOptions
|
|
2299
|
+
);
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Get a specific credit note by ID
|
|
2303
|
+
*
|
|
2304
|
+
* @param id - Credit note UUID
|
|
2305
|
+
* @param requestOptions - Request options
|
|
2306
|
+
* @returns Credit note details
|
|
2307
|
+
*
|
|
2308
|
+
* @example
|
|
2309
|
+
* ```typescript
|
|
2310
|
+
* const { data: creditNote } = await client.creditNotes.get('credit-note-uuid');
|
|
2311
|
+
* console.log('Credit note number:', creditNote.number);
|
|
2312
|
+
* ```
|
|
2313
|
+
*/
|
|
2314
|
+
async get(id, requestOptions) {
|
|
2315
|
+
return this.http.get(
|
|
2316
|
+
`/credit-notes/${id}`,
|
|
2317
|
+
void 0,
|
|
2318
|
+
requestOptions
|
|
2319
|
+
);
|
|
2320
|
+
}
|
|
2321
|
+
/**
|
|
2322
|
+
* Create a new credit note
|
|
2323
|
+
*
|
|
2324
|
+
* @param input - Credit note creation data
|
|
2325
|
+
* @param requestOptions - Request options
|
|
2326
|
+
* @returns Created credit note
|
|
2327
|
+
*
|
|
2328
|
+
* @example
|
|
2329
|
+
* ```typescript
|
|
2330
|
+
* const { data: creditNote } = await client.creditNotes.create({
|
|
2331
|
+
* invoice_id: 'invoice-uuid',
|
|
2332
|
+
* reason: 'Product returned',
|
|
2333
|
+
* items: [
|
|
2334
|
+
* { description: 'Item A', quantity: 1, unit_price: 100, tax_rate: 20, total: 120 }
|
|
2335
|
+
* ]
|
|
2336
|
+
* });
|
|
2337
|
+
* ```
|
|
2338
|
+
*/
|
|
2339
|
+
async create(input, requestOptions) {
|
|
2340
|
+
return this.http.post(
|
|
2341
|
+
"/credit-notes",
|
|
2342
|
+
input,
|
|
2343
|
+
requestOptions
|
|
2344
|
+
);
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Send a credit note
|
|
2348
|
+
*
|
|
2349
|
+
* @param id - Credit note UUID
|
|
2350
|
+
* @param requestOptions - Request options
|
|
2351
|
+
* @returns Success message
|
|
2352
|
+
*
|
|
2353
|
+
* @example
|
|
2354
|
+
* ```typescript
|
|
2355
|
+
* await client.creditNotes.send('credit-note-uuid');
|
|
2356
|
+
* ```
|
|
2357
|
+
*/
|
|
2358
|
+
async send(id, requestOptions) {
|
|
2359
|
+
return this.http.post(
|
|
2360
|
+
`/credit-notes/${id}/send`,
|
|
2361
|
+
void 0,
|
|
2362
|
+
requestOptions
|
|
2363
|
+
);
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Download credit note as PDF
|
|
2367
|
+
*
|
|
2368
|
+
* @param id - Credit note UUID
|
|
2369
|
+
* @param requestOptions - Request options
|
|
2370
|
+
* @returns ArrayBuffer containing the PDF file
|
|
2371
|
+
*
|
|
2372
|
+
* @example
|
|
2373
|
+
* ```typescript
|
|
2374
|
+
* const pdfBuffer = await client.creditNotes.download('credit-note-uuid');
|
|
2375
|
+
*
|
|
2376
|
+
* // In Node.js, save to file:
|
|
2377
|
+
* import { writeFileSync } from 'fs';
|
|
2378
|
+
* writeFileSync('credit-note.pdf', Buffer.from(pdfBuffer));
|
|
2379
|
+
* ```
|
|
2380
|
+
*/
|
|
2381
|
+
async download(id, requestOptions) {
|
|
2382
|
+
return this.http.getRaw(
|
|
2383
|
+
`/credit-notes/${id}/download`,
|
|
2384
|
+
void 0,
|
|
2385
|
+
requestOptions
|
|
2386
|
+
);
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Get remaining creditable amount for an invoice
|
|
2390
|
+
*
|
|
2391
|
+
* @param invoiceId - Invoice UUID
|
|
2392
|
+
* @param requestOptions - Request options
|
|
2393
|
+
* @returns Remaining creditable information
|
|
2394
|
+
*
|
|
2395
|
+
* @example
|
|
2396
|
+
* ```typescript
|
|
2397
|
+
* const { data } = await client.creditNotes.remainingCreditable('invoice-uuid');
|
|
2398
|
+
* console.log('Remaining:', data);
|
|
2399
|
+
* ```
|
|
2400
|
+
*/
|
|
2401
|
+
async remainingCreditable(invoiceId, requestOptions) {
|
|
2402
|
+
return this.http.get(
|
|
2403
|
+
`/invoices/${invoiceId}/remaining-creditable`,
|
|
2404
|
+
void 0,
|
|
2405
|
+
requestOptions
|
|
2406
|
+
);
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
|
|
2276
2410
|
// src/resources/invoices.ts
|
|
2277
2411
|
var InvoicesResource = class {
|
|
2278
2412
|
constructor(http) {
|
|
@@ -2588,6 +2722,25 @@ var InvoicesResource = class {
|
|
|
2588
2722
|
requestOptions
|
|
2589
2723
|
);
|
|
2590
2724
|
}
|
|
2725
|
+
/**
|
|
2726
|
+
* Submit an invoice for processing
|
|
2727
|
+
*
|
|
2728
|
+
* @param id - Invoice UUID
|
|
2729
|
+
* @param requestOptions - Request options
|
|
2730
|
+
* @returns Success message
|
|
2731
|
+
*
|
|
2732
|
+
* @example
|
|
2733
|
+
* ```typescript
|
|
2734
|
+
* await client.invoices.submit('invoice-uuid');
|
|
2735
|
+
* ```
|
|
2736
|
+
*/
|
|
2737
|
+
async submit(id, requestOptions) {
|
|
2738
|
+
return this.http.post(
|
|
2739
|
+
`/invoices/${id}/submit`,
|
|
2740
|
+
void 0,
|
|
2741
|
+
requestOptions
|
|
2742
|
+
);
|
|
2743
|
+
}
|
|
2591
2744
|
/**
|
|
2592
2745
|
* Download invoice source file as binary content
|
|
2593
2746
|
*
|
|
@@ -2808,6 +2961,34 @@ var SignaturesResource = class {
|
|
|
2808
2961
|
requestOptions
|
|
2809
2962
|
);
|
|
2810
2963
|
}
|
|
2964
|
+
/**
|
|
2965
|
+
* Get signature audit trail (JSON)
|
|
2966
|
+
*
|
|
2967
|
+
* Returns the complete history of actions on the signature:
|
|
2968
|
+
* creation, delivery, opening, signing, refusal, etc.
|
|
2969
|
+
*
|
|
2970
|
+
* @param id - Signature UUID
|
|
2971
|
+
* @param requestOptions - Request options
|
|
2972
|
+
* @returns Audit trail entries with integrity validation
|
|
2973
|
+
*
|
|
2974
|
+
* @example
|
|
2975
|
+
* ```typescript
|
|
2976
|
+
* const { data: entries, integrity_valid } = await client.signatures.auditTrail(
|
|
2977
|
+
* 'signature-uuid'
|
|
2978
|
+
* );
|
|
2979
|
+
*
|
|
2980
|
+
* if (integrity_valid) {
|
|
2981
|
+
* entries.forEach(e => console.log(e.action, e.created_at));
|
|
2982
|
+
* }
|
|
2983
|
+
* ```
|
|
2984
|
+
*/
|
|
2985
|
+
async auditTrail(id, requestOptions) {
|
|
2986
|
+
return this.http.get(
|
|
2987
|
+
`/signatures/${id}/audit-trail`,
|
|
2988
|
+
void 0,
|
|
2989
|
+
requestOptions
|
|
2990
|
+
);
|
|
2991
|
+
}
|
|
2811
2992
|
};
|
|
2812
2993
|
|
|
2813
2994
|
// src/resources/webhooks.ts
|
|
@@ -3180,6 +3361,8 @@ var ScellClient = class {
|
|
|
3180
3361
|
invoices;
|
|
3181
3362
|
/** Signature listing (read-only via dashboard) */
|
|
3182
3363
|
signatures;
|
|
3364
|
+
/** Credit notes management */
|
|
3365
|
+
creditNotes;
|
|
3183
3366
|
/**
|
|
3184
3367
|
* Create a new Scell Dashboard Client
|
|
3185
3368
|
*
|
|
@@ -3204,6 +3387,7 @@ var ScellClient = class {
|
|
|
3204
3387
|
this.webhooks = new WebhooksResource(this.http);
|
|
3205
3388
|
this.invoices = new InvoicesResource(this.http);
|
|
3206
3389
|
this.signatures = new SignaturesResource(this.http);
|
|
3390
|
+
this.creditNotes = new CreditNotesResource(this.http);
|
|
3207
3391
|
}
|
|
3208
3392
|
};
|
|
3209
3393
|
var ScellApiClient = class {
|
|
@@ -3212,12 +3396,24 @@ var ScellApiClient = class {
|
|
|
3212
3396
|
invoices;
|
|
3213
3397
|
/** Signature operations (create, download, remind, cancel) */
|
|
3214
3398
|
signatures;
|
|
3215
|
-
/**
|
|
3216
|
-
|
|
3399
|
+
/** Sub-tenant management (provision, update, list) */
|
|
3400
|
+
subTenants;
|
|
3401
|
+
/** NF525 fiscal compliance (closings, FEC, attestation) */
|
|
3402
|
+
fiscal;
|
|
3403
|
+
/** Platform statistics */
|
|
3404
|
+
stats;
|
|
3405
|
+
/** Platform billing (usage, top-up, transactions) */
|
|
3406
|
+
billing;
|
|
3407
|
+
/** Credit notes operations (create, send, download) */
|
|
3408
|
+
creditNotes;
|
|
3409
|
+
/** Tenant invoice operations (create, submit, update, delete) */
|
|
3410
|
+
tenantInvoices;
|
|
3411
|
+
/** Incoming invoice operations (list, accept, reject) */
|
|
3412
|
+
incomingInvoices;
|
|
3217
3413
|
/**
|
|
3218
3414
|
* Create a new Scell API Client
|
|
3219
3415
|
*
|
|
3220
|
-
* @param apiKey - Your API key (
|
|
3416
|
+
* @param apiKey - Your API key (sk_live_xxx or sk_test_xxx)
|
|
3221
3417
|
* @param config - Client configuration
|
|
3222
3418
|
*
|
|
3223
3419
|
* @example
|
|
@@ -3235,7 +3431,13 @@ var ScellApiClient = class {
|
|
|
3235
3431
|
this.http = new HttpClient("api-key", apiKey, config);
|
|
3236
3432
|
this.invoices = new InvoicesResource(this.http);
|
|
3237
3433
|
this.signatures = new SignaturesResource(this.http);
|
|
3238
|
-
this.
|
|
3434
|
+
this.subTenants = new SubTenantsResource(this.http);
|
|
3435
|
+
this.fiscal = new FiscalResource(this.http);
|
|
3436
|
+
this.stats = new StatsResource(this.http);
|
|
3437
|
+
this.billing = new BillingResource(this.http);
|
|
3438
|
+
this.creditNotes = new TenantCreditNotesResource(this.http);
|
|
3439
|
+
this.tenantInvoices = new TenantDirectInvoicesResource(this.http);
|
|
3440
|
+
this.incomingInvoices = new TenantIncomingInvoicesResource(this.http);
|
|
3239
3441
|
}
|
|
3240
3442
|
};
|
|
3241
3443
|
|