factuplan 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -129,6 +129,27 @@ const { url } = await factuplan.invoices.downloadXml('invoice-id');
129
129
  const { url } = await factuplan.invoices.downloadPdf('invoice-id');
130
130
  ```
131
131
 
132
+ ### Importar factura ya autorizada por el SRI
133
+
134
+ Si tienes una factura que ya fue autorizada directamente por el SRI (no a través de Factuplan), puedes importarla para almacenarla en tu cuenta y generar el PDF (RIDE):
135
+
136
+ ```typescript
137
+ const result = await factuplan.invoices.importByAccessKey({
138
+ accessKey: '1512202501095019440700120010020000000116488711218',
139
+ });
140
+
141
+ console.log(result.id); // ID interno del comprobante
142
+ console.log(result.accessKey); // Clave de acceso SRI
143
+ console.log(result.sequential); // Número secuencial
144
+ console.log(result.status); // 'AUTHORIZED'
145
+ console.log(result.total); // Total del comprobante
146
+
147
+ // El PDF se genera automáticamente. Descárgalo una vez listo:
148
+ const { url } = await factuplan.invoices.downloadPdf(result.id);
149
+ ```
150
+
151
+ > **Nota:** Este método no envía el comprobante al SRI ni envía correo al cliente. Solo importa y genera el PDF.
152
+
132
153
  ### Firmar y autorizar XML (Modo B)
133
154
 
134
155
  Si ya tienes tu XML generado (sin firmar), puedes enviarlo para que Factuplan lo firme con tu certificado y lo autorice ante el SRI:
package/dist/index.d.mts CHANGED
@@ -115,6 +115,10 @@ interface CreateInvoiceInput {
115
115
  paymentMethod?: string;
116
116
  additionalInfo?: Record<string, string>;
117
117
  }
118
+ interface ImportByAccessKeyInput {
119
+ /** 49-digit SRI access key (claveAcceso) of an already-authorized invoice */
120
+ accessKey: string;
121
+ }
118
122
  interface Invoice {
119
123
  id: string;
120
124
  accessKey: string;
@@ -231,6 +235,7 @@ declare class InvoicesResource {
231
235
  getStatus(id: string): Promise<InvoiceStatus>;
232
236
  downloadXml(id: string): Promise<DownloadUrlResponse>;
233
237
  downloadPdf(id: string): Promise<DownloadUrlResponse>;
238
+ importByAccessKey(input: ImportByAccessKeyInput): Promise<Invoice>;
234
239
  }
235
240
 
236
241
  type Requester$1 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
@@ -286,4 +291,4 @@ declare class RateLimitError extends FactuplanError {
286
291
  constructor(message?: string);
287
292
  }
288
293
 
289
- export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
294
+ export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
package/dist/index.d.ts CHANGED
@@ -115,6 +115,10 @@ interface CreateInvoiceInput {
115
115
  paymentMethod?: string;
116
116
  additionalInfo?: Record<string, string>;
117
117
  }
118
+ interface ImportByAccessKeyInput {
119
+ /** 49-digit SRI access key (claveAcceso) of an already-authorized invoice */
120
+ accessKey: string;
121
+ }
118
122
  interface Invoice {
119
123
  id: string;
120
124
  accessKey: string;
@@ -231,6 +235,7 @@ declare class InvoicesResource {
231
235
  getStatus(id: string): Promise<InvoiceStatus>;
232
236
  downloadXml(id: string): Promise<DownloadUrlResponse>;
233
237
  downloadPdf(id: string): Promise<DownloadUrlResponse>;
238
+ importByAccessKey(input: ImportByAccessKeyInput): Promise<Invoice>;
234
239
  }
235
240
 
236
241
  type Requester$1 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
@@ -286,4 +291,4 @@ declare class RateLimitError extends FactuplanError {
286
291
  constructor(message?: string);
287
292
  }
288
293
 
289
- export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
294
+ export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
package/dist/index.js CHANGED
@@ -104,6 +104,9 @@ var InvoicesResource = class {
104
104
  async downloadPdf(id) {
105
105
  return this.request("GET", `/developer/receipts/${id}/pdf`);
106
106
  }
107
+ async importByAccessKey(input) {
108
+ return this.request("POST", "/developer/invoices/import", input);
109
+ }
107
110
  };
108
111
 
109
112
  // src/resources/products.ts
package/dist/index.mjs CHANGED
@@ -75,6 +75,9 @@ var InvoicesResource = class {
75
75
  async downloadPdf(id) {
76
76
  return this.request("GET", `/developer/receipts/${id}/pdf`);
77
77
  }
78
+ async importByAccessKey(input) {
79
+ return this.request("POST", "/developer/invoices/import", input);
80
+ }
78
81
  };
79
82
 
80
83
  // src/resources/products.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "factuplan",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Official Factuplan SDK for JavaScript & TypeScript — Create electronic invoices for Ecuador (SRI)",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",