@timbrix/sdk 1.0.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/dist/index.d.mts +116 -8
- package/dist/index.d.ts +116 -8
- package/dist/index.js +68 -4
- package/dist/index.mjs +68 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -408,6 +408,40 @@ interface ListUsosCfdiParams {
|
|
|
408
408
|
tipoPersona?: TipoPersona;
|
|
409
409
|
regimen?: string;
|
|
410
410
|
}
|
|
411
|
+
interface ClaveProdServ {
|
|
412
|
+
codigo: string;
|
|
413
|
+
descripcion: string;
|
|
414
|
+
incluyeIvaTrasladado: boolean;
|
|
415
|
+
incluyeIepsTrasladado: boolean;
|
|
416
|
+
}
|
|
417
|
+
interface ClaveUnidad {
|
|
418
|
+
codigo: string;
|
|
419
|
+
nombre: string;
|
|
420
|
+
descripcion: string;
|
|
421
|
+
simbolo?: string | null;
|
|
422
|
+
}
|
|
423
|
+
interface SearchClavesParams {
|
|
424
|
+
q?: string;
|
|
425
|
+
limit?: number;
|
|
426
|
+
}
|
|
427
|
+
interface SearchClavesProdServResult {
|
|
428
|
+
data: ClaveProdServ[];
|
|
429
|
+
total: number;
|
|
430
|
+
}
|
|
431
|
+
interface SearchClavesUnidadResult {
|
|
432
|
+
data: ClaveUnidad[];
|
|
433
|
+
total: number;
|
|
434
|
+
}
|
|
435
|
+
interface ImportProductsCsvRowError {
|
|
436
|
+
row: number;
|
|
437
|
+
message: string;
|
|
438
|
+
}
|
|
439
|
+
interface ImportProductsCsvResult {
|
|
440
|
+
totalRows: number;
|
|
441
|
+
successCount: number;
|
|
442
|
+
errorCount: number;
|
|
443
|
+
errors: ImportProductsCsvRowError[];
|
|
444
|
+
}
|
|
411
445
|
interface InvoiceCustomerInput {
|
|
412
446
|
legalName: string;
|
|
413
447
|
taxId: string;
|
|
@@ -421,14 +455,22 @@ interface InvoiceTaxInput {
|
|
|
421
455
|
rate?: string;
|
|
422
456
|
base?: number;
|
|
423
457
|
amount?: number;
|
|
458
|
+
/** true = retención, false/omitted = traslado */
|
|
459
|
+
withholding?: boolean;
|
|
424
460
|
}
|
|
425
461
|
interface InvoiceItemInput {
|
|
426
462
|
quantity: number;
|
|
427
|
-
description: string;
|
|
428
|
-
unitPrice: number;
|
|
429
463
|
amount: number;
|
|
430
|
-
productKey
|
|
431
|
-
|
|
464
|
+
/** Existing product/service ID — mutually exclusive with `productKey`/`unitKey`/`description`/`unitPrice` (inline concept data) */
|
|
465
|
+
productId?: string;
|
|
466
|
+
/** Required unless `productId` is provided */
|
|
467
|
+
description?: string;
|
|
468
|
+
/** Required unless `productId` is provided */
|
|
469
|
+
unitPrice?: number;
|
|
470
|
+
/** Required unless `productId` is provided */
|
|
471
|
+
productKey?: string;
|
|
472
|
+
/** Required unless `productId` is provided */
|
|
473
|
+
unitKey?: string;
|
|
432
474
|
unit?: string;
|
|
433
475
|
taxObject?: string;
|
|
434
476
|
taxes?: InvoiceTaxInput[];
|
|
@@ -436,6 +478,8 @@ interface InvoiceItemInput {
|
|
|
436
478
|
interface CreateInvoiceInput {
|
|
437
479
|
/** Ingreso, Egreso, or Traslado — default: I */
|
|
438
480
|
type?: "I" | "E" | "T";
|
|
481
|
+
/** Required when type is "E" — UUID fiscal of the original Ingreso CFDI */
|
|
482
|
+
relatedInvoiceUuid?: string;
|
|
439
483
|
series: string;
|
|
440
484
|
folioNumber: string;
|
|
441
485
|
date: string;
|
|
@@ -467,6 +511,8 @@ interface Invoice {
|
|
|
467
511
|
id: string;
|
|
468
512
|
uuid: string;
|
|
469
513
|
status: "valid";
|
|
514
|
+
/** I = Ingreso, E = Egreso, T = Traslado */
|
|
515
|
+
type: "I" | "E" | "T";
|
|
470
516
|
series: string;
|
|
471
517
|
folioNumber: string;
|
|
472
518
|
total: number;
|
|
@@ -474,6 +520,36 @@ interface Invoice {
|
|
|
474
520
|
xml: string;
|
|
475
521
|
createdAt: string;
|
|
476
522
|
}
|
|
523
|
+
interface ListInvoicesParams {
|
|
524
|
+
/** Page number (1-indexed). Default: 1 */
|
|
525
|
+
page?: number;
|
|
526
|
+
/** Results per page (1-100). Default: 20 */
|
|
527
|
+
limit?: number;
|
|
528
|
+
/** Filter by tipo de comprobante */
|
|
529
|
+
type?: "I" | "E" | "T";
|
|
530
|
+
/** Filter by status */
|
|
531
|
+
status?: "vigente" | "cancelado";
|
|
532
|
+
}
|
|
533
|
+
interface InvoiceListItem {
|
|
534
|
+
id: string;
|
|
535
|
+
uuid: string;
|
|
536
|
+
serie: string;
|
|
537
|
+
folio: string;
|
|
538
|
+
/** I = Ingreso, E = Egreso, T = Traslado */
|
|
539
|
+
tipoComprobante: string;
|
|
540
|
+
rfcReceptor: string;
|
|
541
|
+
moneda: string;
|
|
542
|
+
total: number;
|
|
543
|
+
status: "vigente" | "cancelado";
|
|
544
|
+
createdAt: string;
|
|
545
|
+
}
|
|
546
|
+
interface ListInvoicesResponse {
|
|
547
|
+
data: InvoiceListItem[];
|
|
548
|
+
total: number;
|
|
549
|
+
page: number;
|
|
550
|
+
limit: number;
|
|
551
|
+
totalPages: number;
|
|
552
|
+
}
|
|
477
553
|
interface TimbrixError {
|
|
478
554
|
statusCode: number;
|
|
479
555
|
message: string | string[];
|
|
@@ -556,10 +632,18 @@ declare class InvoicesResource {
|
|
|
556
632
|
constructor(http: KyInstance);
|
|
557
633
|
/**
|
|
558
634
|
* Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
|
|
559
|
-
*
|
|
560
|
-
*
|
|
635
|
+
* Works with either a Supabase bearer session (internal dashboard, the
|
|
636
|
+
* user must be a member of `organizationId`) or an API key (external
|
|
637
|
+
* integrations, requires the `write:invoices` scope — the key must
|
|
638
|
+
* belong to `organizationId`).
|
|
561
639
|
*/
|
|
562
|
-
create(data: CreateInvoiceInput): Promise<Invoice>;
|
|
640
|
+
create(organizationId: string, data: CreateInvoiceInput): Promise<Invoice>;
|
|
641
|
+
/**
|
|
642
|
+
* List invoices for an organization, newest first. Works with either a
|
|
643
|
+
* Supabase bearer session or an API key (requires the `read:invoices`
|
|
644
|
+
* scope), same rules as `create`.
|
|
645
|
+
*/
|
|
646
|
+
list(organizationId: string, params?: ListInvoicesParams): Promise<ListInvoicesResponse>;
|
|
563
647
|
}
|
|
564
648
|
|
|
565
649
|
declare class OAuthResource {
|
|
@@ -679,6 +763,20 @@ declare class ProductsResource {
|
|
|
679
763
|
* Delete a product
|
|
680
764
|
*/
|
|
681
765
|
delete(organizationId: string, productId: string): Promise<void>;
|
|
766
|
+
/**
|
|
767
|
+
* Bulk import products/services from a CSV file (multipart/form-data,
|
|
768
|
+
* field name "file"). Works in both Node (18+) and browser environments,
|
|
769
|
+
* since both provide the global `Blob`/`File` and `FormData` APIs.
|
|
770
|
+
*
|
|
771
|
+
* Required CSV columns: description, productKey, price. Optional
|
|
772
|
+
* columns: unitKey (default H87), unitName, sku, taxIncluded,
|
|
773
|
+
* taxability, livemode. Processing is partial — valid rows are created
|
|
774
|
+
* even if other rows fail, and every failure is reported with its row
|
|
775
|
+
* number and reason.
|
|
776
|
+
*
|
|
777
|
+
* Calls POST /organizations/:organizationId/products/import
|
|
778
|
+
*/
|
|
779
|
+
importCsv(organizationId: string, file: Blob | File, filename?: string): Promise<ImportProductsCsvResult>;
|
|
682
780
|
}
|
|
683
781
|
|
|
684
782
|
declare class SatResource {
|
|
@@ -694,6 +792,16 @@ declare class SatResource {
|
|
|
694
792
|
* Calls GET /sat/usos-cfdi
|
|
695
793
|
*/
|
|
696
794
|
usosCfdi(params?: ListUsosCfdiParams): Promise<UsoCfdi[]>;
|
|
795
|
+
/**
|
|
796
|
+
* Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
|
|
797
|
+
* Calls GET /sat/claves-prod-serv
|
|
798
|
+
*/
|
|
799
|
+
searchClavesProdServ(params?: SearchClavesParams): Promise<SearchClavesProdServResult>;
|
|
800
|
+
/**
|
|
801
|
+
* Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
|
|
802
|
+
* Calls GET /sat/claves-unidad
|
|
803
|
+
*/
|
|
804
|
+
searchClavesUnidad(params?: SearchClavesParams): Promise<SearchClavesUnidadResult>;
|
|
697
805
|
}
|
|
698
806
|
|
|
699
807
|
declare class UsersResource {
|
|
@@ -793,4 +901,4 @@ declare class ApiKeyAuth implements AuthStrategy {
|
|
|
793
901
|
applyAuth(options: Options): Options;
|
|
794
902
|
}
|
|
795
903
|
|
|
796
|
-
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateInvoiceInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type InviteMemberInput, type Invoice, type InvoiceCustomerInput, type InvoiceItemInput, type InvoiceTaxInput, InvoicesResource, type LegalAddress, type ListProductsFilters, type ListRegimenesParams, type ListUsosCfdiParams, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, type RegimenFiscal, SatResource, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TipoPersona, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type UsoCfdi, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
|
904
|
+
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type ClaveProdServ, type ClaveUnidad, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateInvoiceInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type ImportProductsCsvResult, type ImportProductsCsvRowError, type InviteMemberInput, type Invoice, type InvoiceCustomerInput, type InvoiceItemInput, type InvoiceListItem, type InvoiceTaxInput, InvoicesResource, type LegalAddress, type ListInvoicesParams, type ListInvoicesResponse, type ListProductsFilters, type ListRegimenesParams, type ListUsosCfdiParams, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, type RegimenFiscal, SatResource, type SearchClavesParams, type SearchClavesProdServResult, type SearchClavesUnidadResult, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TipoPersona, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type UsoCfdi, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -408,6 +408,40 @@ interface ListUsosCfdiParams {
|
|
|
408
408
|
tipoPersona?: TipoPersona;
|
|
409
409
|
regimen?: string;
|
|
410
410
|
}
|
|
411
|
+
interface ClaveProdServ {
|
|
412
|
+
codigo: string;
|
|
413
|
+
descripcion: string;
|
|
414
|
+
incluyeIvaTrasladado: boolean;
|
|
415
|
+
incluyeIepsTrasladado: boolean;
|
|
416
|
+
}
|
|
417
|
+
interface ClaveUnidad {
|
|
418
|
+
codigo: string;
|
|
419
|
+
nombre: string;
|
|
420
|
+
descripcion: string;
|
|
421
|
+
simbolo?: string | null;
|
|
422
|
+
}
|
|
423
|
+
interface SearchClavesParams {
|
|
424
|
+
q?: string;
|
|
425
|
+
limit?: number;
|
|
426
|
+
}
|
|
427
|
+
interface SearchClavesProdServResult {
|
|
428
|
+
data: ClaveProdServ[];
|
|
429
|
+
total: number;
|
|
430
|
+
}
|
|
431
|
+
interface SearchClavesUnidadResult {
|
|
432
|
+
data: ClaveUnidad[];
|
|
433
|
+
total: number;
|
|
434
|
+
}
|
|
435
|
+
interface ImportProductsCsvRowError {
|
|
436
|
+
row: number;
|
|
437
|
+
message: string;
|
|
438
|
+
}
|
|
439
|
+
interface ImportProductsCsvResult {
|
|
440
|
+
totalRows: number;
|
|
441
|
+
successCount: number;
|
|
442
|
+
errorCount: number;
|
|
443
|
+
errors: ImportProductsCsvRowError[];
|
|
444
|
+
}
|
|
411
445
|
interface InvoiceCustomerInput {
|
|
412
446
|
legalName: string;
|
|
413
447
|
taxId: string;
|
|
@@ -421,14 +455,22 @@ interface InvoiceTaxInput {
|
|
|
421
455
|
rate?: string;
|
|
422
456
|
base?: number;
|
|
423
457
|
amount?: number;
|
|
458
|
+
/** true = retención, false/omitted = traslado */
|
|
459
|
+
withholding?: boolean;
|
|
424
460
|
}
|
|
425
461
|
interface InvoiceItemInput {
|
|
426
462
|
quantity: number;
|
|
427
|
-
description: string;
|
|
428
|
-
unitPrice: number;
|
|
429
463
|
amount: number;
|
|
430
|
-
productKey
|
|
431
|
-
|
|
464
|
+
/** Existing product/service ID — mutually exclusive with `productKey`/`unitKey`/`description`/`unitPrice` (inline concept data) */
|
|
465
|
+
productId?: string;
|
|
466
|
+
/** Required unless `productId` is provided */
|
|
467
|
+
description?: string;
|
|
468
|
+
/** Required unless `productId` is provided */
|
|
469
|
+
unitPrice?: number;
|
|
470
|
+
/** Required unless `productId` is provided */
|
|
471
|
+
productKey?: string;
|
|
472
|
+
/** Required unless `productId` is provided */
|
|
473
|
+
unitKey?: string;
|
|
432
474
|
unit?: string;
|
|
433
475
|
taxObject?: string;
|
|
434
476
|
taxes?: InvoiceTaxInput[];
|
|
@@ -436,6 +478,8 @@ interface InvoiceItemInput {
|
|
|
436
478
|
interface CreateInvoiceInput {
|
|
437
479
|
/** Ingreso, Egreso, or Traslado — default: I */
|
|
438
480
|
type?: "I" | "E" | "T";
|
|
481
|
+
/** Required when type is "E" — UUID fiscal of the original Ingreso CFDI */
|
|
482
|
+
relatedInvoiceUuid?: string;
|
|
439
483
|
series: string;
|
|
440
484
|
folioNumber: string;
|
|
441
485
|
date: string;
|
|
@@ -467,6 +511,8 @@ interface Invoice {
|
|
|
467
511
|
id: string;
|
|
468
512
|
uuid: string;
|
|
469
513
|
status: "valid";
|
|
514
|
+
/** I = Ingreso, E = Egreso, T = Traslado */
|
|
515
|
+
type: "I" | "E" | "T";
|
|
470
516
|
series: string;
|
|
471
517
|
folioNumber: string;
|
|
472
518
|
total: number;
|
|
@@ -474,6 +520,36 @@ interface Invoice {
|
|
|
474
520
|
xml: string;
|
|
475
521
|
createdAt: string;
|
|
476
522
|
}
|
|
523
|
+
interface ListInvoicesParams {
|
|
524
|
+
/** Page number (1-indexed). Default: 1 */
|
|
525
|
+
page?: number;
|
|
526
|
+
/** Results per page (1-100). Default: 20 */
|
|
527
|
+
limit?: number;
|
|
528
|
+
/** Filter by tipo de comprobante */
|
|
529
|
+
type?: "I" | "E" | "T";
|
|
530
|
+
/** Filter by status */
|
|
531
|
+
status?: "vigente" | "cancelado";
|
|
532
|
+
}
|
|
533
|
+
interface InvoiceListItem {
|
|
534
|
+
id: string;
|
|
535
|
+
uuid: string;
|
|
536
|
+
serie: string;
|
|
537
|
+
folio: string;
|
|
538
|
+
/** I = Ingreso, E = Egreso, T = Traslado */
|
|
539
|
+
tipoComprobante: string;
|
|
540
|
+
rfcReceptor: string;
|
|
541
|
+
moneda: string;
|
|
542
|
+
total: number;
|
|
543
|
+
status: "vigente" | "cancelado";
|
|
544
|
+
createdAt: string;
|
|
545
|
+
}
|
|
546
|
+
interface ListInvoicesResponse {
|
|
547
|
+
data: InvoiceListItem[];
|
|
548
|
+
total: number;
|
|
549
|
+
page: number;
|
|
550
|
+
limit: number;
|
|
551
|
+
totalPages: number;
|
|
552
|
+
}
|
|
477
553
|
interface TimbrixError {
|
|
478
554
|
statusCode: number;
|
|
479
555
|
message: string | string[];
|
|
@@ -556,10 +632,18 @@ declare class InvoicesResource {
|
|
|
556
632
|
constructor(http: KyInstance);
|
|
557
633
|
/**
|
|
558
634
|
* Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
|
|
559
|
-
*
|
|
560
|
-
*
|
|
635
|
+
* Works with either a Supabase bearer session (internal dashboard, the
|
|
636
|
+
* user must be a member of `organizationId`) or an API key (external
|
|
637
|
+
* integrations, requires the `write:invoices` scope — the key must
|
|
638
|
+
* belong to `organizationId`).
|
|
561
639
|
*/
|
|
562
|
-
create(data: CreateInvoiceInput): Promise<Invoice>;
|
|
640
|
+
create(organizationId: string, data: CreateInvoiceInput): Promise<Invoice>;
|
|
641
|
+
/**
|
|
642
|
+
* List invoices for an organization, newest first. Works with either a
|
|
643
|
+
* Supabase bearer session or an API key (requires the `read:invoices`
|
|
644
|
+
* scope), same rules as `create`.
|
|
645
|
+
*/
|
|
646
|
+
list(organizationId: string, params?: ListInvoicesParams): Promise<ListInvoicesResponse>;
|
|
563
647
|
}
|
|
564
648
|
|
|
565
649
|
declare class OAuthResource {
|
|
@@ -679,6 +763,20 @@ declare class ProductsResource {
|
|
|
679
763
|
* Delete a product
|
|
680
764
|
*/
|
|
681
765
|
delete(organizationId: string, productId: string): Promise<void>;
|
|
766
|
+
/**
|
|
767
|
+
* Bulk import products/services from a CSV file (multipart/form-data,
|
|
768
|
+
* field name "file"). Works in both Node (18+) and browser environments,
|
|
769
|
+
* since both provide the global `Blob`/`File` and `FormData` APIs.
|
|
770
|
+
*
|
|
771
|
+
* Required CSV columns: description, productKey, price. Optional
|
|
772
|
+
* columns: unitKey (default H87), unitName, sku, taxIncluded,
|
|
773
|
+
* taxability, livemode. Processing is partial — valid rows are created
|
|
774
|
+
* even if other rows fail, and every failure is reported with its row
|
|
775
|
+
* number and reason.
|
|
776
|
+
*
|
|
777
|
+
* Calls POST /organizations/:organizationId/products/import
|
|
778
|
+
*/
|
|
779
|
+
importCsv(organizationId: string, file: Blob | File, filename?: string): Promise<ImportProductsCsvResult>;
|
|
682
780
|
}
|
|
683
781
|
|
|
684
782
|
declare class SatResource {
|
|
@@ -694,6 +792,16 @@ declare class SatResource {
|
|
|
694
792
|
* Calls GET /sat/usos-cfdi
|
|
695
793
|
*/
|
|
696
794
|
usosCfdi(params?: ListUsosCfdiParams): Promise<UsoCfdi[]>;
|
|
795
|
+
/**
|
|
796
|
+
* Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
|
|
797
|
+
* Calls GET /sat/claves-prod-serv
|
|
798
|
+
*/
|
|
799
|
+
searchClavesProdServ(params?: SearchClavesParams): Promise<SearchClavesProdServResult>;
|
|
800
|
+
/**
|
|
801
|
+
* Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
|
|
802
|
+
* Calls GET /sat/claves-unidad
|
|
803
|
+
*/
|
|
804
|
+
searchClavesUnidad(params?: SearchClavesParams): Promise<SearchClavesUnidadResult>;
|
|
697
805
|
}
|
|
698
806
|
|
|
699
807
|
declare class UsersResource {
|
|
@@ -793,4 +901,4 @@ declare class ApiKeyAuth implements AuthStrategy {
|
|
|
793
901
|
applyAuth(options: Options): Options;
|
|
794
902
|
}
|
|
795
903
|
|
|
796
|
-
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateInvoiceInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type InviteMemberInput, type Invoice, type InvoiceCustomerInput, type InvoiceItemInput, type InvoiceTaxInput, InvoicesResource, type LegalAddress, type ListProductsFilters, type ListRegimenesParams, type ListUsosCfdiParams, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, type RegimenFiscal, SatResource, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TipoPersona, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type UsoCfdi, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
|
904
|
+
export { type ApiKey, ApiKeyAuth, type ApiKeyScope, type ApiKeyStats, type ApiKeyValidateResponse, ApiKeysResource, type AuthMode, AuthResource, type AuthStrategy, BearerAuth, type ClaveProdServ, type ClaveUnidad, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCustomerInput, type CreateInvoiceInput, type CreateOAuthAppInput, type CreateOrganizationInput, type CreateProductInput, type CreateWebhookInput, type Customer, type CustomerAddress, CustomersResource, type ExchangeCodeInput, type GenerateTokenInput, type ImportProductsCsvResult, type ImportProductsCsvRowError, type InviteMemberInput, type Invoice, type InvoiceCustomerInput, type InvoiceItemInput, type InvoiceListItem, type InvoiceTaxInput, InvoicesResource, type LegalAddress, type ListInvoicesParams, type ListInvoicesResponse, type ListProductsFilters, type ListRegimenesParams, type ListUsosCfdiParams, type LoginInput, type LoginResponse, type OAuthApp, type OAuthAppWithSecret, OAuthResource, type OAuthScope, type OAuthToken, type Organization, type OrganizationDetails, type OrganizationInvite, type OrganizationMember, type OrganizationRole, OrganizationsResource, type Product, type ProductTax, ProductsResource, type RefreshTokenInput, type RegimenFiscal, SatResource, type SearchClavesParams, type SearchClavesProdServResult, type SearchClavesUnidadResult, Timbrix, type TimbrixConfig, type TimbrixError, type TimbrixUser, type TipoPersona, type TokenResponse, type UpdateApiKeyInput, type UpdateCustomerInput, type UpdateLegalDataInput, type UpdateMemberRoleInput, type UpdateOAuthAppInput, type UpdateOrganizationInput, type UpdateProductInput, type UpdateWebhookInput, UsersResource, type UsoCfdi, type ValidateCertificateResponse, type Webhook, type WebhookDelivery, type WebhookEvent, WebhooksResource };
|
package/dist/index.js
CHANGED
|
@@ -215,11 +215,28 @@ var InvoicesResource = class {
|
|
|
215
215
|
http;
|
|
216
216
|
/**
|
|
217
217
|
* Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
|
|
218
|
-
*
|
|
219
|
-
*
|
|
218
|
+
* Works with either a Supabase bearer session (internal dashboard, the
|
|
219
|
+
* user must be a member of `organizationId`) or an API key (external
|
|
220
|
+
* integrations, requires the `write:invoices` scope — the key must
|
|
221
|
+
* belong to `organizationId`).
|
|
220
222
|
*/
|
|
221
|
-
async create(data) {
|
|
222
|
-
return this.http.post(
|
|
223
|
+
async create(organizationId, data) {
|
|
224
|
+
return this.http.post(`organizations/${organizationId}/invoices`, { json: data }).json();
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* List invoices for an organization, newest first. Works with either a
|
|
228
|
+
* Supabase bearer session or an API key (requires the `read:invoices`
|
|
229
|
+
* scope), same rules as `create`.
|
|
230
|
+
*/
|
|
231
|
+
async list(organizationId, params) {
|
|
232
|
+
const searchParams = {};
|
|
233
|
+
if (params?.page !== void 0) searchParams.page = String(params.page);
|
|
234
|
+
if (params?.limit !== void 0) searchParams.limit = String(params.limit);
|
|
235
|
+
if (params?.type !== void 0) searchParams.type = params.type;
|
|
236
|
+
if (params?.status !== void 0) searchParams.status = params.status;
|
|
237
|
+
return this.http.get(`organizations/${organizationId}/invoices`, {
|
|
238
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
239
|
+
}).json();
|
|
223
240
|
}
|
|
224
241
|
};
|
|
225
242
|
|
|
@@ -433,6 +450,29 @@ var ProductsResource = class {
|
|
|
433
450
|
`organizations/${organizationId}/products/${productId}`
|
|
434
451
|
);
|
|
435
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Bulk import products/services from a CSV file (multipart/form-data,
|
|
455
|
+
* field name "file"). Works in both Node (18+) and browser environments,
|
|
456
|
+
* since both provide the global `Blob`/`File` and `FormData` APIs.
|
|
457
|
+
*
|
|
458
|
+
* Required CSV columns: description, productKey, price. Optional
|
|
459
|
+
* columns: unitKey (default H87), unitName, sku, taxIncluded,
|
|
460
|
+
* taxability, livemode. Processing is partial — valid rows are created
|
|
461
|
+
* even if other rows fail, and every failure is reported with its row
|
|
462
|
+
* number and reason.
|
|
463
|
+
*
|
|
464
|
+
* Calls POST /organizations/:organizationId/products/import
|
|
465
|
+
*/
|
|
466
|
+
async importCsv(organizationId, file, filename = "products.csv") {
|
|
467
|
+
const formData = new FormData();
|
|
468
|
+
formData.append("file", file, filename);
|
|
469
|
+
return this.http.post(`organizations/${organizationId}/products/import`, {
|
|
470
|
+
body: formData,
|
|
471
|
+
// Let fetch set the multipart Content-Type (with boundary) itself —
|
|
472
|
+
// unset the JSON default header inherited from the client instance.
|
|
473
|
+
headers: { "Content-Type": void 0 }
|
|
474
|
+
}).json();
|
|
475
|
+
}
|
|
436
476
|
};
|
|
437
477
|
|
|
438
478
|
// src/resources/sat.ts
|
|
@@ -464,6 +504,30 @@ var SatResource = class {
|
|
|
464
504
|
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
465
505
|
}).json();
|
|
466
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
|
|
509
|
+
* Calls GET /sat/claves-prod-serv
|
|
510
|
+
*/
|
|
511
|
+
async searchClavesProdServ(params) {
|
|
512
|
+
const searchParams = {};
|
|
513
|
+
if (params?.q) searchParams.q = params.q;
|
|
514
|
+
if (params?.limit !== void 0) searchParams.limit = String(params.limit);
|
|
515
|
+
return this.http.get("sat/claves-prod-serv", {
|
|
516
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
517
|
+
}).json();
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
|
|
521
|
+
* Calls GET /sat/claves-unidad
|
|
522
|
+
*/
|
|
523
|
+
async searchClavesUnidad(params) {
|
|
524
|
+
const searchParams = {};
|
|
525
|
+
if (params?.q) searchParams.q = params.q;
|
|
526
|
+
if (params?.limit !== void 0) searchParams.limit = String(params.limit);
|
|
527
|
+
return this.http.get("sat/claves-unidad", {
|
|
528
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
529
|
+
}).json();
|
|
530
|
+
}
|
|
467
531
|
};
|
|
468
532
|
|
|
469
533
|
// src/resources/users.ts
|
package/dist/index.mjs
CHANGED
|
@@ -167,11 +167,28 @@ var InvoicesResource = class {
|
|
|
167
167
|
http;
|
|
168
168
|
/**
|
|
169
169
|
* Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
|
|
170
|
-
*
|
|
171
|
-
*
|
|
170
|
+
* Works with either a Supabase bearer session (internal dashboard, the
|
|
171
|
+
* user must be a member of `organizationId`) or an API key (external
|
|
172
|
+
* integrations, requires the `write:invoices` scope — the key must
|
|
173
|
+
* belong to `organizationId`).
|
|
172
174
|
*/
|
|
173
|
-
async create(data) {
|
|
174
|
-
return this.http.post(
|
|
175
|
+
async create(organizationId, data) {
|
|
176
|
+
return this.http.post(`organizations/${organizationId}/invoices`, { json: data }).json();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* List invoices for an organization, newest first. Works with either a
|
|
180
|
+
* Supabase bearer session or an API key (requires the `read:invoices`
|
|
181
|
+
* scope), same rules as `create`.
|
|
182
|
+
*/
|
|
183
|
+
async list(organizationId, params) {
|
|
184
|
+
const searchParams = {};
|
|
185
|
+
if (params?.page !== void 0) searchParams.page = String(params.page);
|
|
186
|
+
if (params?.limit !== void 0) searchParams.limit = String(params.limit);
|
|
187
|
+
if (params?.type !== void 0) searchParams.type = params.type;
|
|
188
|
+
if (params?.status !== void 0) searchParams.status = params.status;
|
|
189
|
+
return this.http.get(`organizations/${organizationId}/invoices`, {
|
|
190
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
191
|
+
}).json();
|
|
175
192
|
}
|
|
176
193
|
};
|
|
177
194
|
|
|
@@ -385,6 +402,29 @@ var ProductsResource = class {
|
|
|
385
402
|
`organizations/${organizationId}/products/${productId}`
|
|
386
403
|
);
|
|
387
404
|
}
|
|
405
|
+
/**
|
|
406
|
+
* Bulk import products/services from a CSV file (multipart/form-data,
|
|
407
|
+
* field name "file"). Works in both Node (18+) and browser environments,
|
|
408
|
+
* since both provide the global `Blob`/`File` and `FormData` APIs.
|
|
409
|
+
*
|
|
410
|
+
* Required CSV columns: description, productKey, price. Optional
|
|
411
|
+
* columns: unitKey (default H87), unitName, sku, taxIncluded,
|
|
412
|
+
* taxability, livemode. Processing is partial — valid rows are created
|
|
413
|
+
* even if other rows fail, and every failure is reported with its row
|
|
414
|
+
* number and reason.
|
|
415
|
+
*
|
|
416
|
+
* Calls POST /organizations/:organizationId/products/import
|
|
417
|
+
*/
|
|
418
|
+
async importCsv(organizationId, file, filename = "products.csv") {
|
|
419
|
+
const formData = new FormData();
|
|
420
|
+
formData.append("file", file, filename);
|
|
421
|
+
return this.http.post(`organizations/${organizationId}/products/import`, {
|
|
422
|
+
body: formData,
|
|
423
|
+
// Let fetch set the multipart Content-Type (with boundary) itself —
|
|
424
|
+
// unset the JSON default header inherited from the client instance.
|
|
425
|
+
headers: { "Content-Type": void 0 }
|
|
426
|
+
}).json();
|
|
427
|
+
}
|
|
388
428
|
};
|
|
389
429
|
|
|
390
430
|
// src/resources/sat.ts
|
|
@@ -416,6 +456,30 @@ var SatResource = class {
|
|
|
416
456
|
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
417
457
|
}).json();
|
|
418
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
|
|
461
|
+
* Calls GET /sat/claves-prod-serv
|
|
462
|
+
*/
|
|
463
|
+
async searchClavesProdServ(params) {
|
|
464
|
+
const searchParams = {};
|
|
465
|
+
if (params?.q) searchParams.q = params.q;
|
|
466
|
+
if (params?.limit !== void 0) searchParams.limit = String(params.limit);
|
|
467
|
+
return this.http.get("sat/claves-prod-serv", {
|
|
468
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
469
|
+
}).json();
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
|
|
473
|
+
* Calls GET /sat/claves-unidad
|
|
474
|
+
*/
|
|
475
|
+
async searchClavesUnidad(params) {
|
|
476
|
+
const searchParams = {};
|
|
477
|
+
if (params?.q) searchParams.q = params.q;
|
|
478
|
+
if (params?.limit !== void 0) searchParams.limit = String(params.limit);
|
|
479
|
+
return this.http.get("sat/claves-unidad", {
|
|
480
|
+
searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
|
|
481
|
+
}).json();
|
|
482
|
+
}
|
|
419
483
|
};
|
|
420
484
|
|
|
421
485
|
// src/resources/users.ts
|