@timbrix/sdk 1.0.0 → 1.1.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 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;
@@ -424,11 +458,17 @@ interface InvoiceTaxInput {
424
458
  }
425
459
  interface InvoiceItemInput {
426
460
  quantity: number;
427
- description: string;
428
- unitPrice: number;
429
461
  amount: number;
430
- productKey: string;
431
- unitKey: string;
462
+ /** Existing product/service ID — mutually exclusive with `productKey`/`unitKey`/`description`/`unitPrice` (inline concept data) */
463
+ productId?: string;
464
+ /** Required unless `productId` is provided */
465
+ description?: string;
466
+ /** Required unless `productId` is provided */
467
+ unitPrice?: number;
468
+ /** Required unless `productId` is provided */
469
+ productKey?: string;
470
+ /** Required unless `productId` is provided */
471
+ unitKey?: string;
432
472
  unit?: string;
433
473
  taxObject?: string;
434
474
  taxes?: InvoiceTaxInput[];
@@ -474,6 +514,32 @@ interface Invoice {
474
514
  xml: string;
475
515
  createdAt: string;
476
516
  }
517
+ interface ListInvoicesParams {
518
+ /** Page number (1-indexed). Default: 1 */
519
+ page?: number;
520
+ /** Results per page (1-100). Default: 20 */
521
+ limit?: number;
522
+ }
523
+ interface InvoiceListItem {
524
+ id: string;
525
+ uuid: string;
526
+ serie: string;
527
+ folio: string;
528
+ /** I = Ingreso, E = Egreso, T = Traslado */
529
+ tipoComprobante: string;
530
+ rfcReceptor: string;
531
+ moneda: string;
532
+ total: number;
533
+ status: "vigente" | "cancelado";
534
+ createdAt: string;
535
+ }
536
+ interface ListInvoicesResponse {
537
+ data: InvoiceListItem[];
538
+ total: number;
539
+ page: number;
540
+ limit: number;
541
+ totalPages: number;
542
+ }
477
543
  interface TimbrixError {
478
544
  statusCode: number;
479
545
  message: string | string[];
@@ -556,10 +622,18 @@ declare class InvoicesResource {
556
622
  constructor(http: KyInstance);
557
623
  /**
558
624
  * Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
559
- * Requires an API-key-authenticated client the issuing organization is
560
- * resolved from the key, there is no organizationId parameter.
625
+ * Works with either a Supabase bearer session (internal dashboard, the
626
+ * user must be a member of `organizationId`) or an API key (external
627
+ * integrations, requires the `write:invoices` scope — the key must
628
+ * belong to `organizationId`).
561
629
  */
562
- create(data: CreateInvoiceInput): Promise<Invoice>;
630
+ create(organizationId: string, data: CreateInvoiceInput): Promise<Invoice>;
631
+ /**
632
+ * List invoices for an organization, newest first. Works with either a
633
+ * Supabase bearer session or an API key (requires the `read:invoices`
634
+ * scope), same rules as `create`.
635
+ */
636
+ list(organizationId: string, params?: ListInvoicesParams): Promise<ListInvoicesResponse>;
563
637
  }
564
638
 
565
639
  declare class OAuthResource {
@@ -679,6 +753,20 @@ declare class ProductsResource {
679
753
  * Delete a product
680
754
  */
681
755
  delete(organizationId: string, productId: string): Promise<void>;
756
+ /**
757
+ * Bulk import products/services from a CSV file (multipart/form-data,
758
+ * field name "file"). Works in both Node (18+) and browser environments,
759
+ * since both provide the global `Blob`/`File` and `FormData` APIs.
760
+ *
761
+ * Required CSV columns: description, productKey, price. Optional
762
+ * columns: unitKey (default H87), unitName, sku, taxIncluded,
763
+ * taxability, livemode. Processing is partial — valid rows are created
764
+ * even if other rows fail, and every failure is reported with its row
765
+ * number and reason.
766
+ *
767
+ * Calls POST /organizations/:organizationId/products/import
768
+ */
769
+ importCsv(organizationId: string, file: Blob | File, filename?: string): Promise<ImportProductsCsvResult>;
682
770
  }
683
771
 
684
772
  declare class SatResource {
@@ -694,6 +782,16 @@ declare class SatResource {
694
782
  * Calls GET /sat/usos-cfdi
695
783
  */
696
784
  usosCfdi(params?: ListUsosCfdiParams): Promise<UsoCfdi[]>;
785
+ /**
786
+ * Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
787
+ * Calls GET /sat/claves-prod-serv
788
+ */
789
+ searchClavesProdServ(params?: SearchClavesParams): Promise<SearchClavesProdServResult>;
790
+ /**
791
+ * Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
792
+ * Calls GET /sat/claves-unidad
793
+ */
794
+ searchClavesUnidad(params?: SearchClavesParams): Promise<SearchClavesUnidadResult>;
697
795
  }
698
796
 
699
797
  declare class UsersResource {
@@ -793,4 +891,4 @@ declare class ApiKeyAuth implements AuthStrategy {
793
891
  applyAuth(options: Options): Options;
794
892
  }
795
893
 
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 };
894
+ 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;
@@ -424,11 +458,17 @@ interface InvoiceTaxInput {
424
458
  }
425
459
  interface InvoiceItemInput {
426
460
  quantity: number;
427
- description: string;
428
- unitPrice: number;
429
461
  amount: number;
430
- productKey: string;
431
- unitKey: string;
462
+ /** Existing product/service ID — mutually exclusive with `productKey`/`unitKey`/`description`/`unitPrice` (inline concept data) */
463
+ productId?: string;
464
+ /** Required unless `productId` is provided */
465
+ description?: string;
466
+ /** Required unless `productId` is provided */
467
+ unitPrice?: number;
468
+ /** Required unless `productId` is provided */
469
+ productKey?: string;
470
+ /** Required unless `productId` is provided */
471
+ unitKey?: string;
432
472
  unit?: string;
433
473
  taxObject?: string;
434
474
  taxes?: InvoiceTaxInput[];
@@ -474,6 +514,32 @@ interface Invoice {
474
514
  xml: string;
475
515
  createdAt: string;
476
516
  }
517
+ interface ListInvoicesParams {
518
+ /** Page number (1-indexed). Default: 1 */
519
+ page?: number;
520
+ /** Results per page (1-100). Default: 20 */
521
+ limit?: number;
522
+ }
523
+ interface InvoiceListItem {
524
+ id: string;
525
+ uuid: string;
526
+ serie: string;
527
+ folio: string;
528
+ /** I = Ingreso, E = Egreso, T = Traslado */
529
+ tipoComprobante: string;
530
+ rfcReceptor: string;
531
+ moneda: string;
532
+ total: number;
533
+ status: "vigente" | "cancelado";
534
+ createdAt: string;
535
+ }
536
+ interface ListInvoicesResponse {
537
+ data: InvoiceListItem[];
538
+ total: number;
539
+ page: number;
540
+ limit: number;
541
+ totalPages: number;
542
+ }
477
543
  interface TimbrixError {
478
544
  statusCode: number;
479
545
  message: string | string[];
@@ -556,10 +622,18 @@ declare class InvoicesResource {
556
622
  constructor(http: KyInstance);
557
623
  /**
558
624
  * Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
559
- * Requires an API-key-authenticated client the issuing organization is
560
- * resolved from the key, there is no organizationId parameter.
625
+ * Works with either a Supabase bearer session (internal dashboard, the
626
+ * user must be a member of `organizationId`) or an API key (external
627
+ * integrations, requires the `write:invoices` scope — the key must
628
+ * belong to `organizationId`).
561
629
  */
562
- create(data: CreateInvoiceInput): Promise<Invoice>;
630
+ create(organizationId: string, data: CreateInvoiceInput): Promise<Invoice>;
631
+ /**
632
+ * List invoices for an organization, newest first. Works with either a
633
+ * Supabase bearer session or an API key (requires the `read:invoices`
634
+ * scope), same rules as `create`.
635
+ */
636
+ list(organizationId: string, params?: ListInvoicesParams): Promise<ListInvoicesResponse>;
563
637
  }
564
638
 
565
639
  declare class OAuthResource {
@@ -679,6 +753,20 @@ declare class ProductsResource {
679
753
  * Delete a product
680
754
  */
681
755
  delete(organizationId: string, productId: string): Promise<void>;
756
+ /**
757
+ * Bulk import products/services from a CSV file (multipart/form-data,
758
+ * field name "file"). Works in both Node (18+) and browser environments,
759
+ * since both provide the global `Blob`/`File` and `FormData` APIs.
760
+ *
761
+ * Required CSV columns: description, productKey, price. Optional
762
+ * columns: unitKey (default H87), unitName, sku, taxIncluded,
763
+ * taxability, livemode. Processing is partial — valid rows are created
764
+ * even if other rows fail, and every failure is reported with its row
765
+ * number and reason.
766
+ *
767
+ * Calls POST /organizations/:organizationId/products/import
768
+ */
769
+ importCsv(organizationId: string, file: Blob | File, filename?: string): Promise<ImportProductsCsvResult>;
682
770
  }
683
771
 
684
772
  declare class SatResource {
@@ -694,6 +782,16 @@ declare class SatResource {
694
782
  * Calls GET /sat/usos-cfdi
695
783
  */
696
784
  usosCfdi(params?: ListUsosCfdiParams): Promise<UsoCfdi[]>;
785
+ /**
786
+ * Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
787
+ * Calls GET /sat/claves-prod-serv
788
+ */
789
+ searchClavesProdServ(params?: SearchClavesParams): Promise<SearchClavesProdServResult>;
790
+ /**
791
+ * Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
792
+ * Calls GET /sat/claves-unidad
793
+ */
794
+ searchClavesUnidad(params?: SearchClavesParams): Promise<SearchClavesUnidadResult>;
697
795
  }
698
796
 
699
797
  declare class UsersResource {
@@ -793,4 +891,4 @@ declare class ApiKeyAuth implements AuthStrategy {
793
891
  applyAuth(options: Options): Options;
794
892
  }
795
893
 
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 };
894
+ 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,26 @@ var InvoicesResource = class {
215
215
  http;
216
216
  /**
217
217
  * Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
218
- * Requires an API-key-authenticated client the issuing organization is
219
- * resolved from the key, there is no organizationId parameter.
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("invoices", { json: data }).json();
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
+ return this.http.get(`organizations/${organizationId}/invoices`, {
236
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
237
+ }).json();
223
238
  }
224
239
  };
225
240
 
@@ -433,6 +448,29 @@ var ProductsResource = class {
433
448
  `organizations/${organizationId}/products/${productId}`
434
449
  );
435
450
  }
451
+ /**
452
+ * Bulk import products/services from a CSV file (multipart/form-data,
453
+ * field name "file"). Works in both Node (18+) and browser environments,
454
+ * since both provide the global `Blob`/`File` and `FormData` APIs.
455
+ *
456
+ * Required CSV columns: description, productKey, price. Optional
457
+ * columns: unitKey (default H87), unitName, sku, taxIncluded,
458
+ * taxability, livemode. Processing is partial — valid rows are created
459
+ * even if other rows fail, and every failure is reported with its row
460
+ * number and reason.
461
+ *
462
+ * Calls POST /organizations/:organizationId/products/import
463
+ */
464
+ async importCsv(organizationId, file, filename = "products.csv") {
465
+ const formData = new FormData();
466
+ formData.append("file", file, filename);
467
+ return this.http.post(`organizations/${organizationId}/products/import`, {
468
+ body: formData,
469
+ // Let fetch set the multipart Content-Type (with boundary) itself —
470
+ // unset the JSON default header inherited from the client instance.
471
+ headers: { "Content-Type": void 0 }
472
+ }).json();
473
+ }
436
474
  };
437
475
 
438
476
  // src/resources/sat.ts
@@ -464,6 +502,30 @@ var SatResource = class {
464
502
  searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
465
503
  }).json();
466
504
  }
505
+ /**
506
+ * Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
507
+ * Calls GET /sat/claves-prod-serv
508
+ */
509
+ async searchClavesProdServ(params) {
510
+ const searchParams = {};
511
+ if (params?.q) searchParams.q = params.q;
512
+ if (params?.limit !== void 0) searchParams.limit = String(params.limit);
513
+ return this.http.get("sat/claves-prod-serv", {
514
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
515
+ }).json();
516
+ }
517
+ /**
518
+ * Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
519
+ * Calls GET /sat/claves-unidad
520
+ */
521
+ async searchClavesUnidad(params) {
522
+ const searchParams = {};
523
+ if (params?.q) searchParams.q = params.q;
524
+ if (params?.limit !== void 0) searchParams.limit = String(params.limit);
525
+ return this.http.get("sat/claves-unidad", {
526
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
527
+ }).json();
528
+ }
467
529
  };
468
530
 
469
531
  // src/resources/users.ts
package/dist/index.mjs CHANGED
@@ -167,11 +167,26 @@ var InvoicesResource = class {
167
167
  http;
168
168
  /**
169
169
  * Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC.
170
- * Requires an API-key-authenticated client the issuing organization is
171
- * resolved from the key, there is no organizationId parameter.
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("invoices", { json: data }).json();
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
+ return this.http.get(`organizations/${organizationId}/invoices`, {
188
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
189
+ }).json();
175
190
  }
176
191
  };
177
192
 
@@ -385,6 +400,29 @@ var ProductsResource = class {
385
400
  `organizations/${organizationId}/products/${productId}`
386
401
  );
387
402
  }
403
+ /**
404
+ * Bulk import products/services from a CSV file (multipart/form-data,
405
+ * field name "file"). Works in both Node (18+) and browser environments,
406
+ * since both provide the global `Blob`/`File` and `FormData` APIs.
407
+ *
408
+ * Required CSV columns: description, productKey, price. Optional
409
+ * columns: unitKey (default H87), unitName, sku, taxIncluded,
410
+ * taxability, livemode. Processing is partial — valid rows are created
411
+ * even if other rows fail, and every failure is reported with its row
412
+ * number and reason.
413
+ *
414
+ * Calls POST /organizations/:organizationId/products/import
415
+ */
416
+ async importCsv(organizationId, file, filename = "products.csv") {
417
+ const formData = new FormData();
418
+ formData.append("file", file, filename);
419
+ return this.http.post(`organizations/${organizationId}/products/import`, {
420
+ body: formData,
421
+ // Let fetch set the multipart Content-Type (with boundary) itself —
422
+ // unset the JSON default header inherited from the client instance.
423
+ headers: { "Content-Type": void 0 }
424
+ }).json();
425
+ }
388
426
  };
389
427
 
390
428
  // src/resources/sat.ts
@@ -416,6 +454,30 @@ var SatResource = class {
416
454
  searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
417
455
  }).json();
418
456
  }
457
+ /**
458
+ * Search claves de producto o servicio in the SAT catalog (c_ClaveProdServ)
459
+ * Calls GET /sat/claves-prod-serv
460
+ */
461
+ async searchClavesProdServ(params) {
462
+ const searchParams = {};
463
+ if (params?.q) searchParams.q = params.q;
464
+ if (params?.limit !== void 0) searchParams.limit = String(params.limit);
465
+ return this.http.get("sat/claves-prod-serv", {
466
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
467
+ }).json();
468
+ }
469
+ /**
470
+ * Search claves de unidad de medida in the SAT catalog (c_ClaveUnidad)
471
+ * Calls GET /sat/claves-unidad
472
+ */
473
+ async searchClavesUnidad(params) {
474
+ const searchParams = {};
475
+ if (params?.q) searchParams.q = params.q;
476
+ if (params?.limit !== void 0) searchParams.limit = String(params.limit);
477
+ return this.http.get("sat/claves-unidad", {
478
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0
479
+ }).json();
480
+ }
419
481
  };
420
482
 
421
483
  // src/resources/users.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timbrix/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "TypeScript SDK for Timbrix API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",