@scell/sdk 1.0.0 → 1.4.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/dist/index.mjs CHANGED
@@ -275,6 +275,8 @@ var HttpClient = class {
275
275
  };
276
276
  if (this.authMode === "bearer") {
277
277
  headers["Authorization"] = `Bearer ${this.authToken}`;
278
+ } else if (this.authMode === "tenant-key") {
279
+ headers["X-Tenant-Key"] = this.authToken;
278
280
  } else {
279
281
  headers["X-API-Key"] = this.authToken;
280
282
  }
@@ -401,6 +403,1315 @@ var HttpClient = class {
401
403
  ...options
402
404
  });
403
405
  }
406
+ /**
407
+ * GET request that returns raw binary data as ArrayBuffer
408
+ *
409
+ * Use this for downloading files (PDF, XML, etc.)
410
+ *
411
+ * @param path - API endpoint path
412
+ * @param query - Query parameters
413
+ * @param options - Request options
414
+ * @returns ArrayBuffer containing the file content
415
+ */
416
+ async getRaw(path, query, options) {
417
+ const url = this.buildUrl(path, query);
418
+ const requestHeaders = this.buildHeaders(options?.headers);
419
+ const requestTimeout = options?.timeout ?? this.timeout;
420
+ delete requestHeaders["Content-Type"];
421
+ requestHeaders["Accept"] = "*/*";
422
+ const controller = new AbortController();
423
+ const timeoutId = setTimeout(() => controller.abort(), requestTimeout);
424
+ if (options?.signal) {
425
+ options.signal.addEventListener("abort", () => controller.abort());
426
+ }
427
+ try {
428
+ const response = await this.fetchFn(url, {
429
+ method: "GET",
430
+ headers: requestHeaders,
431
+ signal: controller.signal
432
+ });
433
+ clearTimeout(timeoutId);
434
+ if (!response.ok) {
435
+ const contentType = response.headers.get("Content-Type") ?? "";
436
+ let responseBody;
437
+ if (contentType.includes("application/json")) {
438
+ responseBody = await response.json();
439
+ } else {
440
+ responseBody = await response.text();
441
+ }
442
+ parseApiError(response.status, responseBody, response.headers);
443
+ }
444
+ return response.arrayBuffer();
445
+ } catch (error) {
446
+ clearTimeout(timeoutId);
447
+ if (error instanceof Error) {
448
+ if (error.name === "AbortError") {
449
+ throw new ScellTimeoutError(
450
+ `Request timed out after ${requestTimeout}ms`
451
+ );
452
+ }
453
+ if (error.name === "TypeError" && error.message.includes("fetch")) {
454
+ throw new ScellNetworkError("Network request failed", error);
455
+ }
456
+ }
457
+ throw error;
458
+ }
459
+ }
460
+ };
461
+
462
+ // src/resources/tenant-direct-invoices.ts
463
+ var TenantDirectInvoicesResource = class {
464
+ constructor(http) {
465
+ this.http = http;
466
+ }
467
+ /**
468
+ * Create a new direct invoice
469
+ *
470
+ * Creates an outgoing invoice from the tenant to an external buyer.
471
+ * The invoice will be generated in the specified format (Factur-X by default).
472
+ *
473
+ * @param params - Invoice creation parameters
474
+ * @param requestOptions - Optional request configuration
475
+ * @returns Created invoice
476
+ *
477
+ * @example
478
+ * ```typescript
479
+ * const { data: invoice } = await client.directInvoices.create({
480
+ * company_id: 'company-uuid',
481
+ * buyer: {
482
+ * company_name: 'Acme Corporation',
483
+ * siret: '98765432109876',
484
+ * address: {
485
+ * line1: '456 Avenue Business',
486
+ * postal_code: '69001',
487
+ * city: 'Lyon',
488
+ * country: 'FR'
489
+ * },
490
+ * email: 'accounts@acme.com'
491
+ * },
492
+ * lines: [{
493
+ * description: 'Monthly subscription',
494
+ * quantity: 1,
495
+ * unit_price: 299,
496
+ * tax_rate: 20,
497
+ * total_ht: 299,
498
+ * total_tax: 59.80,
499
+ * total_ttc: 358.80
500
+ * }],
501
+ * issue_date: '2026-01-26',
502
+ * due_date: '2026-02-26',
503
+ * notes: 'Thank you for your business!'
504
+ * });
505
+ *
506
+ * console.log('Invoice created:', invoice.invoice_number);
507
+ * ```
508
+ */
509
+ async create(params, requestOptions) {
510
+ return this.http.post(
511
+ "/tenant/invoices",
512
+ params,
513
+ requestOptions
514
+ );
515
+ }
516
+ /**
517
+ * List all direct invoices
518
+ *
519
+ * Returns a paginated list of direct invoices created by the tenant.
520
+ * Supports filtering by status, date range, buyer, and amount.
521
+ *
522
+ * @param filters - Filter and pagination options
523
+ * @param requestOptions - Optional request configuration
524
+ * @returns Paginated list of invoices
525
+ *
526
+ * @example
527
+ * ```typescript
528
+ * // List all validated invoices
529
+ * const { data: invoices, meta } = await client.directInvoices.list({
530
+ * status: 'validated',
531
+ * per_page: 50
532
+ * });
533
+ *
534
+ * console.log(`Found ${meta.total} validated invoices`);
535
+ *
536
+ * // Filter by date range
537
+ * const januaryInvoices = await client.directInvoices.list({
538
+ * date_from: '2026-01-01',
539
+ * date_to: '2026-01-31'
540
+ * });
541
+ *
542
+ * // Search by buyer
543
+ * const acmeInvoices = await client.directInvoices.list({
544
+ * search: 'Acme'
545
+ * });
546
+ * ```
547
+ */
548
+ async list(filters = {}, requestOptions) {
549
+ const query = {
550
+ ...filters,
551
+ status: Array.isArray(filters.status) ? filters.status.join(",") : filters.status
552
+ };
553
+ return this.http.get(
554
+ "/tenant/invoices",
555
+ query,
556
+ requestOptions
557
+ );
558
+ }
559
+ /**
560
+ * Get a specific direct invoice by ID
561
+ *
562
+ * @param invoiceId - Invoice UUID
563
+ * @param requestOptions - Optional request configuration
564
+ * @returns Invoice details
565
+ *
566
+ * @example
567
+ * ```typescript
568
+ * const { data: invoice } = await client.directInvoices.get('invoice-uuid');
569
+ *
570
+ * console.log('Invoice:', invoice.invoice_number);
571
+ * console.log('Status:', invoice.status);
572
+ * console.log('Total:', invoice.total_ttc, invoice.currency);
573
+ * ```
574
+ */
575
+ async get(invoiceId, requestOptions) {
576
+ return this.http.get(
577
+ `/tenant/invoices/${invoiceId}`,
578
+ void 0,
579
+ requestOptions
580
+ );
581
+ }
582
+ /**
583
+ * Update a direct invoice
584
+ *
585
+ * Only invoices in 'draft' status can be updated.
586
+ * Once validated or sent, invoices become immutable.
587
+ *
588
+ * @param invoiceId - Invoice UUID
589
+ * @param params - Update parameters
590
+ * @param requestOptions - Optional request configuration
591
+ * @returns Updated invoice
592
+ *
593
+ * @example
594
+ * ```typescript
595
+ * const { data: invoice } = await client.directInvoices.update(
596
+ * 'invoice-uuid',
597
+ * {
598
+ * due_date: '2026-03-15',
599
+ * notes: 'Updated payment terms'
600
+ * }
601
+ * );
602
+ *
603
+ * console.log('Invoice updated:', invoice.due_date);
604
+ * ```
605
+ */
606
+ async update(invoiceId, params, requestOptions) {
607
+ return this.http.patch(
608
+ `/tenant/invoices/${invoiceId}`,
609
+ params,
610
+ requestOptions
611
+ );
612
+ }
613
+ /**
614
+ * Delete a direct invoice
615
+ *
616
+ * Only invoices in 'draft' status can be deleted.
617
+ * Validated or sent invoices cannot be deleted for audit trail compliance.
618
+ *
619
+ * @param invoiceId - Invoice UUID
620
+ * @param requestOptions - Optional request configuration
621
+ *
622
+ * @example
623
+ * ```typescript
624
+ * await client.directInvoices.delete('draft-invoice-uuid');
625
+ * console.log('Invoice deleted successfully');
626
+ * ```
627
+ */
628
+ async delete(invoiceId, requestOptions) {
629
+ return this.http.delete(
630
+ `/tenant/invoices/${invoiceId}`,
631
+ requestOptions
632
+ );
633
+ }
634
+ /**
635
+ * Validate a direct invoice
636
+ *
637
+ * Validates the invoice, generates the electronic invoice file,
638
+ * and changes status from 'draft' to 'validated'.
639
+ *
640
+ * @param invoiceId - Invoice UUID
641
+ * @param requestOptions - Optional request configuration
642
+ * @returns Validated invoice
643
+ *
644
+ * @example
645
+ * ```typescript
646
+ * const { data: invoice } = await client.directInvoices.validate('invoice-uuid');
647
+ * console.log('Invoice validated:', invoice.status); // 'validated'
648
+ * console.log('Validated at:', invoice.validated_at);
649
+ * ```
650
+ */
651
+ async validate(invoiceId, requestOptions) {
652
+ return this.http.post(
653
+ `/tenant/invoices/${invoiceId}/validate`,
654
+ void 0,
655
+ requestOptions
656
+ );
657
+ }
658
+ /**
659
+ * Send a direct invoice to the buyer
660
+ *
661
+ * Sends the validated invoice to the buyer via email.
662
+ * The invoice must be in 'validated' status.
663
+ *
664
+ * @param invoiceId - Invoice UUID
665
+ * @param requestOptions - Optional request configuration
666
+ * @returns Updated invoice
667
+ *
668
+ * @example
669
+ * ```typescript
670
+ * const { data: invoice } = await client.directInvoices.send('invoice-uuid');
671
+ * console.log('Invoice sent to:', invoice.buyer.email);
672
+ * ```
673
+ */
674
+ async send(invoiceId, requestOptions) {
675
+ return this.http.post(
676
+ `/tenant/invoices/${invoiceId}/send`,
677
+ void 0,
678
+ requestOptions
679
+ );
680
+ }
681
+ /**
682
+ * Download invoice as PDF
683
+ *
684
+ * Downloads the electronic invoice file as a PDF (Factur-X).
685
+ *
686
+ * @param invoiceId - Invoice UUID
687
+ * @param requestOptions - Optional request configuration
688
+ * @returns ArrayBuffer containing the PDF file
689
+ *
690
+ * @example
691
+ * ```typescript
692
+ * // Download invoice PDF
693
+ * const pdfBuffer = await client.directInvoices.download('invoice-uuid');
694
+ *
695
+ * // In Node.js, save to file:
696
+ * import { writeFileSync } from 'fs';
697
+ * writeFileSync('invoice.pdf', Buffer.from(pdfBuffer));
698
+ *
699
+ * // In browser, trigger download:
700
+ * const blob = new Blob([pdfBuffer], { type: 'application/pdf' });
701
+ * const url = URL.createObjectURL(blob);
702
+ * const a = document.createElement('a');
703
+ * a.href = url;
704
+ * a.download = 'invoice.pdf';
705
+ * a.click();
706
+ * ```
707
+ */
708
+ async download(invoiceId, requestOptions) {
709
+ return this.http.getRaw(
710
+ `/tenant/invoices/${invoiceId}/download`,
711
+ void 0,
712
+ requestOptions
713
+ );
714
+ }
715
+ /**
716
+ * Download invoice XML
717
+ *
718
+ * Downloads the electronic invoice XML (UBL/CII format).
719
+ *
720
+ * @param invoiceId - Invoice UUID
721
+ * @param requestOptions - Optional request configuration
722
+ * @returns ArrayBuffer containing the XML file
723
+ *
724
+ * @example
725
+ * ```typescript
726
+ * const xmlBuffer = await client.directInvoices.downloadXml('invoice-uuid');
727
+ * const xmlString = new TextDecoder().decode(xmlBuffer);
728
+ * console.log('XML:', xmlString);
729
+ * ```
730
+ */
731
+ async downloadXml(invoiceId, requestOptions) {
732
+ return this.http.getRaw(
733
+ `/tenant/invoices/${invoiceId}/download`,
734
+ { format: "xml" },
735
+ requestOptions
736
+ );
737
+ }
738
+ /**
739
+ * Bulk create multiple invoices
740
+ */
741
+ async bulkCreate(invoices, requestOptions) {
742
+ return this.http.post(
743
+ "/tenant/invoices/bulk",
744
+ { invoices },
745
+ requestOptions
746
+ );
747
+ }
748
+ /**
749
+ * Bulk submit multiple invoices
750
+ */
751
+ async bulkSubmit(invoiceIds, requestOptions) {
752
+ return this.http.post(
753
+ "/tenant/invoices/bulk-submit",
754
+ { invoice_ids: invoiceIds },
755
+ requestOptions
756
+ );
757
+ }
758
+ /**
759
+ * Get status of multiple invoices
760
+ */
761
+ async bulkStatus(invoiceIds, requestOptions) {
762
+ return this.http.post(
763
+ "/tenant/invoices/bulk-status",
764
+ { invoice_ids: invoiceIds },
765
+ requestOptions
766
+ );
767
+ }
768
+ };
769
+
770
+ // src/resources/tenant-direct-credit-notes.ts
771
+ var TenantDirectCreditNotesResource = class {
772
+ constructor(http) {
773
+ this.http = http;
774
+ }
775
+ /**
776
+ * Create a new credit note for a direct invoice
777
+ *
778
+ * Creates a credit note (avoir) linked to a direct invoice.
779
+ * - For partial credit notes, specify the items and quantities to credit.
780
+ * - For total credit notes, all items are automatically credited.
781
+ *
782
+ * @param params - Credit note creation parameters
783
+ * @param requestOptions - Optional request configuration
784
+ * @returns Created credit note
785
+ *
786
+ * @example
787
+ * ```typescript
788
+ * // Partial credit note
789
+ * const { data: creditNote } = await client.directCreditNotes.create({
790
+ * invoice_id: 'invoice-uuid',
791
+ * reason: 'Returned items',
792
+ * type: 'partial',
793
+ * items: [
794
+ * { invoice_line_id: 'line-1-uuid', quantity: 2 },
795
+ * { invoice_line_id: 'line-2-uuid', quantity: 1 }
796
+ * ]
797
+ * });
798
+ *
799
+ * // Total credit note (cancels entire invoice)
800
+ * const { data: totalCreditNote } = await client.directCreditNotes.create({
801
+ * invoice_id: 'invoice-uuid',
802
+ * reason: 'Invoice issued in error',
803
+ * type: 'total'
804
+ * });
805
+ *
806
+ * console.log('Credit note number:', creditNote.credit_note_number);
807
+ * console.log('Amount:', creditNote.total, creditNote.currency);
808
+ * ```
809
+ */
810
+ async create(params, requestOptions) {
811
+ return this.http.post(
812
+ "/tenant/credit-notes",
813
+ params,
814
+ requestOptions
815
+ );
816
+ }
817
+ /**
818
+ * List all direct credit notes
819
+ *
820
+ * Returns a paginated list of credit notes for direct invoices.
821
+ *
822
+ * @param filters - Filter and pagination options
823
+ * @param requestOptions - Optional request configuration
824
+ * @returns Paginated list of credit notes
825
+ *
826
+ * @example
827
+ * ```typescript
828
+ * // List all sent credit notes
829
+ * const { data: creditNotes, meta } = await client.directCreditNotes.list({
830
+ * status: 'sent',
831
+ * per_page: 50
832
+ * });
833
+ *
834
+ * console.log(`Found ${meta.total} sent credit notes`);
835
+ *
836
+ * // Filter by date range
837
+ * const januaryCreditNotes = await client.directCreditNotes.list({
838
+ * date_from: '2026-01-01',
839
+ * date_to: '2026-01-31'
840
+ * });
841
+ * ```
842
+ */
843
+ async list(filters = {}, requestOptions) {
844
+ return this.http.get(
845
+ "/tenant/credit-notes",
846
+ filters,
847
+ requestOptions
848
+ );
849
+ }
850
+ /**
851
+ * Get a specific credit note by ID
852
+ *
853
+ * @param creditNoteId - Credit note UUID
854
+ * @param requestOptions - Optional request configuration
855
+ * @returns Credit note details
856
+ *
857
+ * @example
858
+ * ```typescript
859
+ * const { data: creditNote } = await client.directCreditNotes.get('credit-note-uuid');
860
+ *
861
+ * console.log('Credit note:', creditNote.credit_note_number);
862
+ * console.log('Status:', creditNote.status);
863
+ * console.log('Reason:', creditNote.reason);
864
+ * console.log('Total:', creditNote.total, creditNote.currency);
865
+ * ```
866
+ */
867
+ async get(creditNoteId, requestOptions) {
868
+ return this.http.get(
869
+ `/tenant/credit-notes/${creditNoteId}`,
870
+ void 0,
871
+ requestOptions
872
+ );
873
+ }
874
+ /**
875
+ * Update a credit note
876
+ *
877
+ * Only credit notes in 'draft' status can be updated.
878
+ *
879
+ * @param creditNoteId - Credit note UUID
880
+ * @param params - Update parameters
881
+ * @param requestOptions - Optional request configuration
882
+ * @returns Updated credit note
883
+ *
884
+ * @example
885
+ * ```typescript
886
+ * const { data: creditNote } = await client.directCreditNotes.update(
887
+ * 'credit-note-uuid',
888
+ * {
889
+ * reason: 'Updated reason: Customer complaint resolved',
890
+ * items: [
891
+ * { invoice_line_id: 'line-uuid', quantity: 3 }
892
+ * ]
893
+ * }
894
+ * );
895
+ * ```
896
+ */
897
+ async update(creditNoteId, params, requestOptions) {
898
+ return this.http.patch(
899
+ `/tenant/credit-notes/${creditNoteId}`,
900
+ params,
901
+ requestOptions
902
+ );
903
+ }
904
+ /**
905
+ * Delete a credit note
906
+ *
907
+ * Only credit notes in 'draft' status can be deleted.
908
+ *
909
+ * @param creditNoteId - Credit note UUID
910
+ * @param requestOptions - Optional request configuration
911
+ *
912
+ * @example
913
+ * ```typescript
914
+ * await client.directCreditNotes.delete('draft-credit-note-uuid');
915
+ * console.log('Credit note deleted');
916
+ * ```
917
+ */
918
+ async delete(creditNoteId, requestOptions) {
919
+ return this.http.delete(
920
+ `/tenant/credit-notes/${creditNoteId}`,
921
+ requestOptions
922
+ );
923
+ }
924
+ /**
925
+ * Send a credit note
926
+ *
927
+ * Validates and sends the credit note, changing status from 'draft' to 'sent'.
928
+ *
929
+ * @param creditNoteId - Credit note UUID
930
+ * @param requestOptions - Optional request configuration
931
+ * @returns Sent credit note
932
+ *
933
+ * @example
934
+ * ```typescript
935
+ * const { data: creditNote } = await client.directCreditNotes.send('credit-note-uuid');
936
+ * console.log('Credit note sent:', creditNote.status); // 'sent'
937
+ * ```
938
+ */
939
+ async send(creditNoteId, requestOptions) {
940
+ return this.http.post(
941
+ `/tenant/credit-notes/${creditNoteId}/send`,
942
+ void 0,
943
+ requestOptions
944
+ );
945
+ }
946
+ /**
947
+ * Download credit note as PDF
948
+ *
949
+ * @param creditNoteId - Credit note UUID
950
+ * @param requestOptions - Optional request configuration
951
+ * @returns ArrayBuffer containing the PDF file
952
+ *
953
+ * @example
954
+ * ```typescript
955
+ * const pdfBuffer = await client.directCreditNotes.download('credit-note-uuid');
956
+ *
957
+ * // In Node.js:
958
+ * import { writeFileSync } from 'fs';
959
+ * writeFileSync('credit-note.pdf', Buffer.from(pdfBuffer));
960
+ *
961
+ * // In browser:
962
+ * const blob = new Blob([pdfBuffer], { type: 'application/pdf' });
963
+ * const url = URL.createObjectURL(blob);
964
+ * window.open(url);
965
+ * ```
966
+ */
967
+ async download(creditNoteId, requestOptions) {
968
+ return this.http.getRaw(
969
+ `/tenant/credit-notes/${creditNoteId}/download`,
970
+ void 0,
971
+ requestOptions
972
+ );
973
+ }
974
+ /**
975
+ * Get remaining creditable amount for a direct invoice
976
+ *
977
+ * Returns information about how much can still be credited,
978
+ * including line-by-line breakdown.
979
+ *
980
+ * @param invoiceId - Invoice UUID
981
+ * @param requestOptions - Optional request configuration
982
+ * @returns Remaining creditable information
983
+ *
984
+ * @example
985
+ * ```typescript
986
+ * const remaining = await client.directCreditNotes.remainingCreditable('invoice-uuid');
987
+ *
988
+ * console.log('Invoice total:', remaining.invoice_total);
989
+ * console.log('Already credited:', remaining.credited_total);
990
+ * console.log('Can still credit:', remaining.remaining_total);
991
+ *
992
+ * // Check per-line
993
+ * remaining.lines.forEach(line => {
994
+ * if (line.remaining_quantity > 0) {
995
+ * console.log(`${line.description}: ${line.remaining_quantity} units remaining`);
996
+ * }
997
+ * });
998
+ * ```
999
+ */
1000
+ async remainingCreditable(invoiceId, requestOptions) {
1001
+ return this.http.get(
1002
+ `/tenant/invoices/${invoiceId}/remaining-creditable`,
1003
+ void 0,
1004
+ requestOptions
1005
+ );
1006
+ }
1007
+ };
1008
+
1009
+ // src/resources/tenant-incoming-invoices.ts
1010
+ var TenantIncomingInvoicesResource = class {
1011
+ constructor(http) {
1012
+ this.http = http;
1013
+ }
1014
+ /**
1015
+ * Create a new incoming invoice for a sub-tenant
1016
+ *
1017
+ * Creates a purchase invoice received by a sub-tenant from an external supplier.
1018
+ * The seller's SIREN is validated using the Luhn algorithm.
1019
+ *
1020
+ * @param subTenantId - Sub-tenant UUID
1021
+ * @param params - Invoice creation parameters
1022
+ * @param requestOptions - Optional request configuration
1023
+ * @returns Created invoice
1024
+ *
1025
+ * @example
1026
+ * ```typescript
1027
+ * const { data: invoice } = await client.incomingInvoices.create(
1028
+ * 'sub-tenant-uuid',
1029
+ * {
1030
+ * invoice_number: 'SUPP-2026-001',
1031
+ * company_id: 'company-uuid',
1032
+ * seller: {
1033
+ * company_name: 'Acme Supplies',
1034
+ * siren: '123456789',
1035
+ * siret: '12345678901234',
1036
+ * vat_number: 'FR12123456789',
1037
+ * address: {
1038
+ * line1: '123 Industrial Park',
1039
+ * postal_code: '31000',
1040
+ * city: 'Toulouse',
1041
+ * country: 'FR'
1042
+ * },
1043
+ * email: 'billing@acme-supplies.com'
1044
+ * },
1045
+ * lines: [
1046
+ * {
1047
+ * description: 'Widget A - Bulk order',
1048
+ * quantity: 500,
1049
+ * unit_price: 2.50,
1050
+ * tax_rate: 20,
1051
+ * total_ht: 1250,
1052
+ * total_tax: 250,
1053
+ * total_ttc: 1500
1054
+ * }
1055
+ * ],
1056
+ * issue_date: '2026-01-15',
1057
+ * due_date: '2026-02-15',
1058
+ * total_ht: 1250,
1059
+ * total_ttc: 1500
1060
+ * }
1061
+ * );
1062
+ *
1063
+ * console.log('Incoming invoice created:', invoice.invoice_number);
1064
+ * ```
1065
+ */
1066
+ async create(subTenantId, params, requestOptions) {
1067
+ return this.http.post(
1068
+ `/tenant/sub-tenants/${subTenantId}/incoming-invoices`,
1069
+ params,
1070
+ requestOptions
1071
+ );
1072
+ }
1073
+ /**
1074
+ * List incoming invoices for a sub-tenant
1075
+ *
1076
+ * Returns a paginated list of purchase invoices received by the sub-tenant.
1077
+ *
1078
+ * @param subTenantId - Sub-tenant UUID
1079
+ * @param filters - Filter and pagination options
1080
+ * @param requestOptions - Optional request configuration
1081
+ * @returns Paginated list of invoices
1082
+ *
1083
+ * @example
1084
+ * ```typescript
1085
+ * // List all pending invoices
1086
+ * const { data: invoices, meta } = await client.incomingInvoices.listForSubTenant(
1087
+ * 'sub-tenant-uuid',
1088
+ * { status: 'pending', per_page: 50 }
1089
+ * );
1090
+ *
1091
+ * console.log(`Found ${meta.total} pending invoices to review`);
1092
+ *
1093
+ * // Filter by supplier
1094
+ * const acmeInvoices = await client.incomingInvoices.listForSubTenant(
1095
+ * 'sub-tenant-uuid',
1096
+ * { seller_siret: '12345678901234' }
1097
+ * );
1098
+ * ```
1099
+ */
1100
+ async listForSubTenant(subTenantId, filters = {}, requestOptions) {
1101
+ const query = {
1102
+ ...filters,
1103
+ status: Array.isArray(filters.status) ? filters.status.join(",") : filters.status
1104
+ };
1105
+ return this.http.get(
1106
+ `/tenant/sub-tenants/${subTenantId}/incoming-invoices`,
1107
+ query,
1108
+ requestOptions
1109
+ );
1110
+ }
1111
+ /**
1112
+ * Get a specific incoming invoice by ID
1113
+ *
1114
+ * @param invoiceId - Invoice UUID
1115
+ * @param requestOptions - Optional request configuration
1116
+ * @returns Invoice details
1117
+ *
1118
+ * @example
1119
+ * ```typescript
1120
+ * const { data: invoice } = await client.incomingInvoices.get('invoice-uuid');
1121
+ *
1122
+ * console.log('Invoice from:', invoice.seller.name);
1123
+ * console.log('Status:', invoice.status);
1124
+ * console.log('Amount:', invoice.total_ttc, invoice.currency);
1125
+ * ```
1126
+ */
1127
+ async get(invoiceId, requestOptions) {
1128
+ return this.http.get(
1129
+ `/tenant/incoming-invoices/${invoiceId}`,
1130
+ void 0,
1131
+ requestOptions
1132
+ );
1133
+ }
1134
+ /**
1135
+ * Accept an incoming invoice
1136
+ *
1137
+ * Marks the invoice as accepted, indicating approval for payment.
1138
+ * Optionally specify an expected payment date.
1139
+ *
1140
+ * @param invoiceId - Invoice UUID
1141
+ * @param input - Optional acceptance details
1142
+ * @param requestOptions - Optional request configuration
1143
+ * @returns Updated invoice
1144
+ *
1145
+ * @example
1146
+ * ```typescript
1147
+ * // Accept with payment date
1148
+ * const { data: invoice } = await client.incomingInvoices.accept(
1149
+ * 'invoice-uuid',
1150
+ * {
1151
+ * payment_date: '2026-02-15',
1152
+ * note: 'Approved by CFO'
1153
+ * }
1154
+ * );
1155
+ *
1156
+ * console.log('Invoice accepted:', invoice.status); // 'accepted'
1157
+ *
1158
+ * // Simple acceptance
1159
+ * await client.incomingInvoices.accept('invoice-uuid');
1160
+ * ```
1161
+ */
1162
+ async accept(invoiceId, input, requestOptions) {
1163
+ return this.http.post(
1164
+ `/tenant/incoming-invoices/${invoiceId}/accept`,
1165
+ input,
1166
+ requestOptions
1167
+ );
1168
+ }
1169
+ /**
1170
+ * Reject an incoming invoice
1171
+ *
1172
+ * Marks the invoice as rejected with a reason and optional code.
1173
+ *
1174
+ * @param invoiceId - Invoice UUID
1175
+ * @param reason - Reason for rejection
1176
+ * @param code - Optional standardized rejection code
1177
+ * @param requestOptions - Optional request configuration
1178
+ * @returns Updated invoice
1179
+ *
1180
+ * @example
1181
+ * ```typescript
1182
+ * const { data: invoice } = await client.incomingInvoices.reject(
1183
+ * 'invoice-uuid',
1184
+ * 'Amount does not match purchase order PO-2026-042',
1185
+ * 'incorrect_amount'
1186
+ * );
1187
+ *
1188
+ * console.log('Invoice rejected:', invoice.status); // 'rejected'
1189
+ * ```
1190
+ */
1191
+ async reject(invoiceId, reason, code, requestOptions) {
1192
+ const input = { reason };
1193
+ if (code) {
1194
+ input.reason_code = code;
1195
+ }
1196
+ return this.http.post(
1197
+ `/tenant/incoming-invoices/${invoiceId}/reject`,
1198
+ input,
1199
+ requestOptions
1200
+ );
1201
+ }
1202
+ /**
1203
+ * Mark an incoming invoice as paid
1204
+ *
1205
+ * Records payment information for an accepted invoice.
1206
+ * This is a mandatory step in the French e-invoicing lifecycle.
1207
+ *
1208
+ * @param invoiceId - Invoice UUID
1209
+ * @param input - Optional payment details
1210
+ * @param requestOptions - Optional request configuration
1211
+ * @returns Updated invoice with payment information
1212
+ *
1213
+ * @example
1214
+ * ```typescript
1215
+ * // Mark as paid with details
1216
+ * const { data: invoice } = await client.incomingInvoices.markPaid(
1217
+ * 'invoice-uuid',
1218
+ * {
1219
+ * payment_reference: 'VIR-2026-0150',
1220
+ * paid_at: '2026-02-14T14:30:00Z',
1221
+ * note: 'Payment via bank transfer'
1222
+ * }
1223
+ * );
1224
+ *
1225
+ * console.log('Invoice paid:', invoice.status); // 'paid'
1226
+ * console.log('Payment ref:', invoice.payment_reference);
1227
+ *
1228
+ * // Simple mark as paid (current date)
1229
+ * await client.incomingInvoices.markPaid('invoice-uuid');
1230
+ * ```
1231
+ */
1232
+ async markPaid(invoiceId, input, requestOptions) {
1233
+ return this.http.post(
1234
+ `/tenant/incoming-invoices/${invoiceId}/mark-paid`,
1235
+ input,
1236
+ requestOptions
1237
+ );
1238
+ }
1239
+ /**
1240
+ * Delete an incoming invoice
1241
+ *
1242
+ * Only invoices in 'pending' status can be deleted.
1243
+ *
1244
+ * @param invoiceId - Invoice UUID
1245
+ * @param requestOptions - Optional request configuration
1246
+ *
1247
+ * @example
1248
+ * ```typescript
1249
+ * await client.incomingInvoices.delete('pending-invoice-uuid');
1250
+ * console.log('Incoming invoice deleted');
1251
+ * ```
1252
+ */
1253
+ async delete(invoiceId, requestOptions) {
1254
+ return this.http.delete(
1255
+ `/tenant/incoming-invoices/${invoiceId}`,
1256
+ requestOptions
1257
+ );
1258
+ }
1259
+ /**
1260
+ * Download incoming invoice as PDF
1261
+ *
1262
+ * @param invoiceId - Invoice UUID
1263
+ * @param requestOptions - Optional request configuration
1264
+ * @returns ArrayBuffer containing the PDF file
1265
+ *
1266
+ * @example
1267
+ * ```typescript
1268
+ * const pdfBuffer = await client.incomingInvoices.download('invoice-uuid');
1269
+ *
1270
+ * // Save to file (Node.js)
1271
+ * import { writeFileSync } from 'fs';
1272
+ * writeFileSync('supplier-invoice.pdf', Buffer.from(pdfBuffer));
1273
+ * ```
1274
+ */
1275
+ async download(invoiceId, requestOptions) {
1276
+ return this.http.getRaw(
1277
+ `/tenant/incoming-invoices/${invoiceId}/download`,
1278
+ void 0,
1279
+ requestOptions
1280
+ );
1281
+ }
1282
+ };
1283
+
1284
+ // src/resources/tenant-credit-notes.ts
1285
+ var TenantCreditNotesResource = class {
1286
+ constructor(http) {
1287
+ this.http = http;
1288
+ }
1289
+ /**
1290
+ * List credit notes for a sub-tenant
1291
+ *
1292
+ * @param subTenantId - Sub-tenant UUID
1293
+ * @param options - Filter and pagination options
1294
+ * @param requestOptions - Request options
1295
+ * @returns Paginated list of credit notes
1296
+ *
1297
+ * @example
1298
+ * ```typescript
1299
+ * const { data, meta } = await client.tenantCreditNotes.list('sub-tenant-uuid', {
1300
+ * status: 'sent',
1301
+ * date_from: '2024-01-01',
1302
+ * per_page: 50
1303
+ * });
1304
+ * console.log(`Found ${meta.total} credit notes`);
1305
+ * ```
1306
+ */
1307
+ async list(subTenantId, options = {}, requestOptions) {
1308
+ return this.http.get(
1309
+ `/tenant/sub-tenants/${subTenantId}/credit-notes`,
1310
+ options,
1311
+ requestOptions
1312
+ );
1313
+ }
1314
+ /**
1315
+ * Create a new credit note for a sub-tenant invoice
1316
+ *
1317
+ * @param subTenantId - Sub-tenant UUID
1318
+ * @param input - Credit note creation data
1319
+ * @param requestOptions - Request options
1320
+ * @returns Created credit note
1321
+ *
1322
+ * @example
1323
+ * ```typescript
1324
+ * // Create a partial credit note
1325
+ * const { data: creditNote } = await client.tenantCreditNotes.create(
1326
+ * 'sub-tenant-uuid',
1327
+ * {
1328
+ * invoice_id: 'invoice-uuid',
1329
+ * reason: 'Product returned - damaged item',
1330
+ * type: 'partial',
1331
+ * items: [
1332
+ * { invoice_line_id: 'line-uuid-1', quantity: 2 }
1333
+ * ]
1334
+ * }
1335
+ * );
1336
+ *
1337
+ * // Create a total credit note
1338
+ * const { data: totalCreditNote } = await client.tenantCreditNotes.create(
1339
+ * 'sub-tenant-uuid',
1340
+ * {
1341
+ * invoice_id: 'invoice-uuid',
1342
+ * reason: 'Order cancelled',
1343
+ * type: 'total'
1344
+ * }
1345
+ * );
1346
+ * ```
1347
+ */
1348
+ async create(subTenantId, input, requestOptions) {
1349
+ return this.http.post(
1350
+ `/tenant/sub-tenants/${subTenantId}/credit-notes`,
1351
+ input,
1352
+ requestOptions
1353
+ );
1354
+ }
1355
+ /**
1356
+ * Get a specific credit note by ID
1357
+ *
1358
+ * @param creditNoteId - Credit note UUID
1359
+ * @param requestOptions - Request options
1360
+ * @returns Credit note details
1361
+ *
1362
+ * @example
1363
+ * ```typescript
1364
+ * const { data: creditNote } = await client.tenantCreditNotes.get('credit-note-uuid');
1365
+ * console.log('Credit note number:', creditNote.credit_note_number);
1366
+ * console.log('Total:', creditNote.total, creditNote.currency);
1367
+ * ```
1368
+ */
1369
+ async get(creditNoteId, requestOptions) {
1370
+ return this.http.get(
1371
+ `/tenant/credit-notes/${creditNoteId}`,
1372
+ void 0,
1373
+ requestOptions
1374
+ );
1375
+ }
1376
+ /**
1377
+ * Update a credit note
1378
+ *
1379
+ * Only credit notes in 'draft' status can be updated.
1380
+ *
1381
+ * @param creditNoteId - Credit note UUID
1382
+ * @param input - Update data
1383
+ * @param requestOptions - Request options
1384
+ * @returns Updated credit note
1385
+ *
1386
+ * @example
1387
+ * ```typescript
1388
+ * const { data: creditNote } = await client.tenantCreditNotes.update(
1389
+ * 'credit-note-uuid',
1390
+ * {
1391
+ * reason: 'Updated reason: Customer complaint resolved',
1392
+ * items: [
1393
+ * { invoice_line_id: 'line-uuid', quantity: 3 }
1394
+ * ]
1395
+ * }
1396
+ * );
1397
+ * console.log('Credit note updated:', creditNote.reason);
1398
+ * ```
1399
+ */
1400
+ async update(creditNoteId, input, requestOptions) {
1401
+ return this.http.patch(
1402
+ `/tenant/credit-notes/${creditNoteId}`,
1403
+ input,
1404
+ requestOptions
1405
+ );
1406
+ }
1407
+ /**
1408
+ * Send a credit note
1409
+ *
1410
+ * Changes the status from 'draft' to 'sent'.
1411
+ *
1412
+ * @param creditNoteId - Credit note UUID
1413
+ * @param requestOptions - Request options
1414
+ * @returns Updated credit note
1415
+ *
1416
+ * @example
1417
+ * ```typescript
1418
+ * const { data: sentCreditNote } = await client.tenantCreditNotes.send('credit-note-uuid');
1419
+ * console.log('Status:', sentCreditNote.status); // 'sent'
1420
+ * ```
1421
+ */
1422
+ async send(creditNoteId, requestOptions) {
1423
+ return this.http.post(
1424
+ `/tenant/credit-notes/${creditNoteId}/send`,
1425
+ void 0,
1426
+ requestOptions
1427
+ );
1428
+ }
1429
+ /**
1430
+ * Delete a credit note (draft only)
1431
+ *
1432
+ * Only credit notes with status 'draft' can be deleted.
1433
+ *
1434
+ * @param creditNoteId - Credit note UUID
1435
+ * @param requestOptions - Request options
1436
+ *
1437
+ * @example
1438
+ * ```typescript
1439
+ * await client.tenantCreditNotes.delete('credit-note-uuid');
1440
+ * ```
1441
+ */
1442
+ async delete(creditNoteId, requestOptions) {
1443
+ return this.http.delete(
1444
+ `/tenant/credit-notes/${creditNoteId}`,
1445
+ requestOptions
1446
+ );
1447
+ }
1448
+ /**
1449
+ * Download credit note as PDF
1450
+ *
1451
+ * @param creditNoteId - Credit note UUID
1452
+ * @param requestOptions - Request options
1453
+ * @returns ArrayBuffer containing the PDF file
1454
+ *
1455
+ * @example
1456
+ * ```typescript
1457
+ * // Download credit note PDF
1458
+ * const pdfBuffer = await client.tenantCreditNotes.download('credit-note-uuid');
1459
+ *
1460
+ * // In Node.js, save to file:
1461
+ * import { writeFileSync } from 'fs';
1462
+ * writeFileSync('credit-note.pdf', Buffer.from(pdfBuffer));
1463
+ *
1464
+ * // In browser, trigger download:
1465
+ * const blob = new Blob([pdfBuffer], { type: 'application/pdf' });
1466
+ * const url = URL.createObjectURL(blob);
1467
+ * const a = document.createElement('a');
1468
+ * a.href = url;
1469
+ * a.download = 'credit-note.pdf';
1470
+ * a.click();
1471
+ * ```
1472
+ */
1473
+ async download(creditNoteId, requestOptions) {
1474
+ return this.http.getRaw(
1475
+ `/tenant/credit-notes/${creditNoteId}/download`,
1476
+ void 0,
1477
+ requestOptions
1478
+ );
1479
+ }
1480
+ /**
1481
+ * Get remaining creditable amount for an invoice
1482
+ *
1483
+ * Returns information about how much can still be credited for an invoice,
1484
+ * including per-line breakdown.
1485
+ *
1486
+ * @param invoiceId - Invoice UUID
1487
+ * @param requestOptions - Request options
1488
+ * @returns Remaining creditable information
1489
+ *
1490
+ * @example
1491
+ * ```typescript
1492
+ * const remaining = await client.tenantCreditNotes.remainingCreditable('invoice-uuid');
1493
+ *
1494
+ * console.log('Invoice total:', remaining.invoice_total);
1495
+ * console.log('Already credited:', remaining.credited_total);
1496
+ * console.log('Remaining to credit:', remaining.remaining_total);
1497
+ *
1498
+ * // Check remaining quantity per line
1499
+ * remaining.lines.forEach(line => {
1500
+ * console.log(`${line.description}: ${line.remaining_quantity} remaining`);
1501
+ * });
1502
+ * ```
1503
+ */
1504
+ async remainingCreditable(invoiceId, requestOptions) {
1505
+ return this.http.get(
1506
+ `/tenant/invoices/${invoiceId}/remaining-creditable`,
1507
+ void 0,
1508
+ requestOptions
1509
+ );
1510
+ }
1511
+ };
1512
+
1513
+ // src/resources/fiscal.ts
1514
+ var FiscalResource = class {
1515
+ constructor(http) {
1516
+ this.http = http;
1517
+ }
1518
+ async compliance(requestOptions) {
1519
+ return this.http.get("/tenant/fiscal/compliance", void 0, requestOptions);
1520
+ }
1521
+ async integrity(options = {}, requestOptions) {
1522
+ return this.http.get("/tenant/fiscal/integrity", options, requestOptions);
1523
+ }
1524
+ async integrityHistory(options = {}, requestOptions) {
1525
+ return this.http.get("/tenant/fiscal/integrity/history", options, requestOptions);
1526
+ }
1527
+ async integrityForDate(date, requestOptions) {
1528
+ return this.http.get(`/tenant/fiscal/integrity/${date}`, void 0, requestOptions);
1529
+ }
1530
+ async closings(options = {}, requestOptions) {
1531
+ return this.http.get("/tenant/fiscal/closings", options, requestOptions);
1532
+ }
1533
+ async performDailyClosing(input = {}, requestOptions) {
1534
+ return this.http.post("/tenant/fiscal/closings/daily", input, requestOptions);
1535
+ }
1536
+ async fecExport(options, requestOptions) {
1537
+ return this.http.get("/tenant/fiscal/fec", options, requestOptions);
1538
+ }
1539
+ async fecDownload(options, requestOptions) {
1540
+ return this.http.getRaw("/tenant/fiscal/fec", { ...options, download: true }, requestOptions);
1541
+ }
1542
+ async attestation(year, requestOptions) {
1543
+ return this.http.get(`/tenant/fiscal/attestation/${year}`, void 0, requestOptions);
1544
+ }
1545
+ async attestationDownload(year, requestOptions) {
1546
+ return this.http.getRaw(`/tenant/fiscal/attestation/${year}/download`, void 0, requestOptions);
1547
+ }
1548
+ async entries(options = {}, requestOptions) {
1549
+ return this.http.get("/tenant/fiscal/entries", options, requestOptions);
1550
+ }
1551
+ async killSwitchStatus(requestOptions) {
1552
+ return this.http.get("/tenant/fiscal/kill-switch/status", void 0, requestOptions);
1553
+ }
1554
+ async killSwitchActivate(input, requestOptions) {
1555
+ return this.http.post("/tenant/fiscal/kill-switch/activate", input, requestOptions);
1556
+ }
1557
+ async killSwitchDeactivate(requestOptions) {
1558
+ return this.http.post("/tenant/fiscal/kill-switch/deactivate", void 0, requestOptions);
1559
+ }
1560
+ async anchors(options = {}, requestOptions) {
1561
+ return this.http.get("/tenant/fiscal/anchors", options, requestOptions);
1562
+ }
1563
+ async rules(options = {}, requestOptions) {
1564
+ return this.http.get("/tenant/fiscal/rules", options, requestOptions);
1565
+ }
1566
+ async ruleDetail(key, requestOptions) {
1567
+ return this.http.get(`/tenant/fiscal/rules/${key}`, void 0, requestOptions);
1568
+ }
1569
+ async ruleHistory(key, requestOptions) {
1570
+ return this.http.get(`/tenant/fiscal/rules/${key}/history`, void 0, requestOptions);
1571
+ }
1572
+ async createRule(input, requestOptions) {
1573
+ return this.http.post("/tenant/fiscal/rules", input, requestOptions);
1574
+ }
1575
+ async updateRule(id, input, requestOptions) {
1576
+ return this.http.post(`/tenant/fiscal/rules/${id}`, input, requestOptions);
1577
+ }
1578
+ async exportRules(options, requestOptions) {
1579
+ return this.http.get("/tenant/fiscal/rules/export", options, requestOptions);
1580
+ }
1581
+ async replayRules(input, requestOptions) {
1582
+ return this.http.post("/tenant/fiscal/rules/replay", input, requestOptions);
1583
+ }
1584
+ async forensicExport(options, requestOptions) {
1585
+ return this.http.get("/tenant/fiscal/forensic-export", options, requestOptions);
1586
+ }
1587
+ };
1588
+
1589
+ // src/resources/billing.ts
1590
+ var BillingResource = class {
1591
+ constructor(http) {
1592
+ this.http = http;
1593
+ }
1594
+ async invoices(options = {}, requestOptions) {
1595
+ return this.http.get("/tenant/billing/invoices", options, requestOptions);
1596
+ }
1597
+ async showInvoice(invoiceId, requestOptions) {
1598
+ return this.http.get(`/tenant/billing/invoices/${invoiceId}`, void 0, requestOptions);
1599
+ }
1600
+ async downloadInvoice(invoiceId, requestOptions) {
1601
+ return this.http.getRaw(`/tenant/billing/invoices/${invoiceId}/download`, void 0, requestOptions);
1602
+ }
1603
+ async usage(options = {}, requestOptions) {
1604
+ return this.http.get("/tenant/billing/usage", options, requestOptions);
1605
+ }
1606
+ async topUp(input, requestOptions) {
1607
+ return this.http.post("/tenant/billing/top-up", input, requestOptions);
1608
+ }
1609
+ async confirmTopUp(input, requestOptions) {
1610
+ return this.http.post("/tenant/billing/top-up/confirm", input, requestOptions);
1611
+ }
1612
+ async transactions(options = {}, requestOptions) {
1613
+ return this.http.get("/tenant/billing/transactions", options, requestOptions);
1614
+ }
1615
+ };
1616
+
1617
+ // src/resources/stats.ts
1618
+ var StatsResource = class {
1619
+ constructor(http) {
1620
+ this.http = http;
1621
+ }
1622
+ async overview(options = {}, requestOptions) {
1623
+ return this.http.get("/tenant/stats/overview", options, requestOptions);
1624
+ }
1625
+ async monthly(options = {}, requestOptions) {
1626
+ return this.http.get("/tenant/stats/monthly", options, requestOptions);
1627
+ }
1628
+ async subTenantOverview(subTenantId, options = {}, requestOptions) {
1629
+ return this.http.get(`/tenant/sub-tenants/${subTenantId}/stats/overview`, options, requestOptions);
1630
+ }
1631
+ };
1632
+
1633
+ // src/resources/sub-tenants.ts
1634
+ var SubTenantsResource = class {
1635
+ constructor(http) {
1636
+ this.http = http;
1637
+ }
1638
+ async list(options = {}, requestOptions) {
1639
+ return this.http.get("/tenant/sub-tenants", options, requestOptions);
1640
+ }
1641
+ async create(input, requestOptions) {
1642
+ return this.http.post("/tenant/sub-tenants", input, requestOptions);
1643
+ }
1644
+ async get(id, requestOptions) {
1645
+ return this.http.get(`/tenant/sub-tenants/${id}`, void 0, requestOptions);
1646
+ }
1647
+ async update(id, input, requestOptions) {
1648
+ return this.http.patch(`/tenant/sub-tenants/${id}`, input, requestOptions);
1649
+ }
1650
+ async delete(id, requestOptions) {
1651
+ return this.http.delete(`/tenant/sub-tenants/${id}`, requestOptions);
1652
+ }
1653
+ async findByExternalId(externalId, requestOptions) {
1654
+ return this.http.get(`/tenant/sub-tenants/by-external-id/${externalId}`, void 0, requestOptions);
1655
+ }
1656
+ };
1657
+
1658
+ // src/tenant-client.ts
1659
+ var ScellTenantClient = class {
1660
+ http;
1661
+ /** Direct invoices resource */
1662
+ directInvoices;
1663
+ /** Direct credit notes resource */
1664
+ directCreditNotes;
1665
+ /** Incoming invoices resource */
1666
+ incomingInvoices;
1667
+ /** Sub-tenant credit notes resource */
1668
+ subTenantCreditNotes;
1669
+ /** Fiscal compliance resource (LF 2026) */
1670
+ fiscal;
1671
+ /** Billing resource */
1672
+ billing;
1673
+ /** Stats resource */
1674
+ stats;
1675
+ /** Sub-tenants resource */
1676
+ subTenants;
1677
+ /**
1678
+ * Create a new Scell Tenant Client
1679
+ *
1680
+ * @param tenantKey - Your tenant API key (from dashboard)
1681
+ * @param config - Optional client configuration
1682
+ */
1683
+ constructor(tenantKey, config = {}) {
1684
+ this.http = new HttpClient("tenant-key", tenantKey, config);
1685
+ this.directInvoices = new TenantDirectInvoicesResource(this.http);
1686
+ this.directCreditNotes = new TenantDirectCreditNotesResource(this.http);
1687
+ this.incomingInvoices = new TenantIncomingInvoicesResource(this.http);
1688
+ this.subTenantCreditNotes = new TenantCreditNotesResource(this.http);
1689
+ this.fiscal = new FiscalResource(this.http);
1690
+ this.billing = new BillingResource(this.http);
1691
+ this.stats = new StatsResource(this.http);
1692
+ this.subTenants = new SubTenantsResource(this.http);
1693
+ }
1694
+ // ── Tenant Profile Methods ──────────────────────────────
1695
+ /** Get tenant profile */
1696
+ async me(requestOptions) {
1697
+ return this.http.get("/tenant/me", void 0, requestOptions);
1698
+ }
1699
+ /** Update tenant profile */
1700
+ async updateProfile(input, requestOptions) {
1701
+ return this.http.post("/tenant/me", input, requestOptions);
1702
+ }
1703
+ /** Get tenant balance */
1704
+ async balance(requestOptions) {
1705
+ return this.http.get("/tenant/balance", void 0, requestOptions);
1706
+ }
1707
+ /** Get quick stats */
1708
+ async quickStats(requestOptions) {
1709
+ return this.http.get("/tenant/stats", void 0, requestOptions);
1710
+ }
1711
+ /** Regenerate tenant key */
1712
+ async regenerateKey(requestOptions) {
1713
+ return this.http.post("/tenant/regenerate-key", void 0, requestOptions);
1714
+ }
404
1715
  };
405
1716
 
406
1717
  // src/resources/api-keys.ts
@@ -1135,6 +2446,188 @@ var InvoicesResource = class {
1135
2446
  async convert(input, requestOptions) {
1136
2447
  return this.http.post("/invoices/convert", input, requestOptions);
1137
2448
  }
2449
+ /**
2450
+ * List incoming invoices (from suppliers)
2451
+ *
2452
+ * Returns invoices where your company is the buyer.
2453
+ *
2454
+ * @param params - Filter and pagination options
2455
+ * @param requestOptions - Request options
2456
+ * @returns Paginated list of incoming invoices
2457
+ *
2458
+ * @example
2459
+ * ```typescript
2460
+ * // List all incoming invoices
2461
+ * const { data, meta } = await client.invoices.incoming({
2462
+ * status: 'pending',
2463
+ * per_page: 50
2464
+ * });
2465
+ * console.log(`Found ${meta.total} incoming invoices`);
2466
+ *
2467
+ * // Filter by seller
2468
+ * const fromSupplier = await client.invoices.incoming({
2469
+ * seller_siret: '12345678901234'
2470
+ * });
2471
+ * ```
2472
+ */
2473
+ async incoming(params = {}, requestOptions) {
2474
+ return this.http.get(
2475
+ "/invoices/incoming",
2476
+ params,
2477
+ requestOptions
2478
+ );
2479
+ }
2480
+ /**
2481
+ * Accept an incoming invoice
2482
+ *
2483
+ * Mark an incoming invoice as accepted, optionally specifying a payment date.
2484
+ *
2485
+ * @param id - Invoice UUID
2486
+ * @param data - Optional acceptance data
2487
+ * @param requestOptions - Request options
2488
+ * @returns Updated invoice
2489
+ *
2490
+ * @example
2491
+ * ```typescript
2492
+ * // Accept with payment date
2493
+ * const { data: invoice } = await client.invoices.accept('invoice-uuid', {
2494
+ * payment_date: '2024-02-15',
2495
+ * note: 'Approved by accounting'
2496
+ * });
2497
+ *
2498
+ * // Simple acceptance
2499
+ * await client.invoices.accept('invoice-uuid');
2500
+ * ```
2501
+ */
2502
+ async accept(id, data, requestOptions) {
2503
+ return this.http.post(
2504
+ `/invoices/${id}/accept`,
2505
+ data,
2506
+ requestOptions
2507
+ );
2508
+ }
2509
+ /**
2510
+ * Reject an incoming invoice
2511
+ *
2512
+ * Mark an incoming invoice as rejected with a reason.
2513
+ *
2514
+ * @param id - Invoice UUID
2515
+ * @param data - Rejection details
2516
+ * @param requestOptions - Request options
2517
+ * @returns Updated invoice
2518
+ *
2519
+ * @example
2520
+ * ```typescript
2521
+ * const { data: invoice } = await client.invoices.reject('invoice-uuid', {
2522
+ * reason: 'Invoice amount does not match purchase order',
2523
+ * reason_code: 'incorrect_amount'
2524
+ * });
2525
+ * ```
2526
+ */
2527
+ async reject(id, data, requestOptions) {
2528
+ return this.http.post(
2529
+ `/invoices/${id}/reject`,
2530
+ data,
2531
+ requestOptions
2532
+ );
2533
+ }
2534
+ /**
2535
+ * Dispute an incoming invoice
2536
+ *
2537
+ * Open a dispute on an incoming invoice for resolution.
2538
+ *
2539
+ * @param id - Invoice UUID
2540
+ * @param data - Dispute details
2541
+ * @param requestOptions - Request options
2542
+ * @returns Updated invoice
2543
+ *
2544
+ * @example
2545
+ * ```typescript
2546
+ * const { data: invoice } = await client.invoices.dispute('invoice-uuid', {
2547
+ * reason: 'Billed amount exceeds agreed price',
2548
+ * dispute_type: 'amount_dispute',
2549
+ * expected_amount: 950.00
2550
+ * });
2551
+ * ```
2552
+ */
2553
+ async dispute(id, data, requestOptions) {
2554
+ return this.http.post(
2555
+ `/invoices/${id}/dispute`,
2556
+ data,
2557
+ requestOptions
2558
+ );
2559
+ }
2560
+ /**
2561
+ * Mark an incoming invoice as paid
2562
+ *
2563
+ * This is a mandatory step in the French e-invoicing lifecycle for incoming invoices.
2564
+ * Once marked as paid, the invoice status changes to 'paid' and payment details are recorded.
2565
+ *
2566
+ * @param id - Invoice UUID
2567
+ * @param data - Optional payment details (reference, date, note)
2568
+ * @param requestOptions - Request options
2569
+ * @returns Updated invoice with payment information
2570
+ *
2571
+ * @example
2572
+ * ```typescript
2573
+ * // Mark as paid with payment details
2574
+ * const { data: invoice } = await client.invoices.markPaid('invoice-uuid', {
2575
+ * payment_reference: 'VIR-2026-0124',
2576
+ * paid_at: '2026-01-24T10:30:00Z',
2577
+ * note: 'Payment received via bank transfer'
2578
+ * });
2579
+ *
2580
+ * // Simple mark as paid (uses current date/time)
2581
+ * await client.invoices.markPaid('invoice-uuid');
2582
+ * ```
2583
+ */
2584
+ async markPaid(id, data, requestOptions) {
2585
+ return this.http.post(
2586
+ `/invoices/${id}/mark-paid`,
2587
+ data,
2588
+ requestOptions
2589
+ );
2590
+ }
2591
+ /**
2592
+ * Download invoice source file as binary content
2593
+ *
2594
+ * Downloads the original invoice file (PDF with embedded XML for Factur-X,
2595
+ * or standalone XML for UBL/CII formats).
2596
+ *
2597
+ * @param id - Invoice UUID
2598
+ * @param format - File format to download: 'pdf' (default) or 'xml'
2599
+ * @param requestOptions - Request options
2600
+ * @returns ArrayBuffer containing the file content
2601
+ *
2602
+ * @example
2603
+ * ```typescript
2604
+ * // Download invoice as PDF (Factur-X)
2605
+ * const pdfBuffer = await client.invoices.downloadFile('invoice-uuid');
2606
+ *
2607
+ * // In Node.js, save to file:
2608
+ * import { writeFileSync } from 'fs';
2609
+ * writeFileSync('invoice.pdf', Buffer.from(pdfBuffer));
2610
+ *
2611
+ * // Download XML version (UBL/CII)
2612
+ * const xmlBuffer = await client.invoices.downloadFile('invoice-uuid', 'xml');
2613
+ * writeFileSync('invoice.xml', Buffer.from(xmlBuffer));
2614
+ *
2615
+ * // In browser, trigger download:
2616
+ * const blob = new Blob([pdfBuffer], { type: 'application/pdf' });
2617
+ * const url = URL.createObjectURL(blob);
2618
+ * const a = document.createElement('a');
2619
+ * a.href = url;
2620
+ * a.download = 'invoice.pdf';
2621
+ * a.click();
2622
+ * ```
2623
+ */
2624
+ async downloadFile(id, format = "pdf", requestOptions) {
2625
+ return this.http.getRaw(
2626
+ `/invoices/${id}/download`,
2627
+ { format },
2628
+ requestOptions
2629
+ );
2630
+ }
1138
2631
  };
1139
2632
 
1140
2633
  // src/resources/signatures.ts
@@ -1719,6 +3212,8 @@ var ScellApiClient = class {
1719
3212
  invoices;
1720
3213
  /** Signature operations (create, download, remind, cancel) */
1721
3214
  signatures;
3215
+ /** Tenant credit notes operations (create, send, download) */
3216
+ tenantCreditNotes;
1722
3217
  /**
1723
3218
  * Create a new Scell API Client
1724
3219
  *
@@ -1740,9 +3235,10 @@ var ScellApiClient = class {
1740
3235
  this.http = new HttpClient("api-key", apiKey, config);
1741
3236
  this.invoices = new InvoicesResource(this.http);
1742
3237
  this.signatures = new SignaturesResource(this.http);
3238
+ this.tenantCreditNotes = new TenantCreditNotesResource(this.http);
1743
3239
  }
1744
3240
  };
1745
3241
 
1746
- export { ScellApiClient, ScellAuth, ScellAuthenticationError, ScellAuthorizationError, ScellClient, ScellError, ScellInsufficientBalanceError, ScellNetworkError, ScellNotFoundError, ScellRateLimitError, ScellServerError, ScellTimeoutError, ScellValidationError, ScellWebhooks, createRetryWrapper, withRetry };
3242
+ export { ScellApiClient, ScellAuth, ScellAuthenticationError, ScellAuthorizationError, ScellClient, ScellError, ScellInsufficientBalanceError, ScellNetworkError, ScellNotFoundError, ScellRateLimitError, ScellServerError, ScellTenantClient, ScellTimeoutError, ScellValidationError, ScellWebhooks, createRetryWrapper, withRetry };
1747
3243
  //# sourceMappingURL=index.mjs.map
1748
3244
  //# sourceMappingURL=index.mjs.map