invoicing-sdk
Version:
Invoice SDK entry package for getting started quickly, including domain and application layers
88 lines (84 loc) • 4.95 kB
TypeScript
export { BasePDFRenderer, CustomerInfo, DEFAULT_GENERATOR_CONFIG, DEFAULT_INVOICE_NUMBER_CONFIG, DEFAULT_PDF_OPTIONS, GENERATOR_PRESETS, GermanLegalInfo, InvalidLegalInfoError, Invoice, InvoiceData, InvoiceFinancials, InvoiceIdGenerator, InvoiceNumberConfig, InvoiceNumberGenerator, InvoiceNumberGeneratorConfig, InvoiceNumberGeneratorImpl, InvoiceNumberRepository, InvoiceNumberValidator, InvoiceNumberValidatorImpl, Money, MoneyPlainObject, OrderItem, PDFGenerationError, PDFOptions, PDFRenderer, ShippingCost, ShippingCostPolicy, ShippingRateProvider, createInvoiceNumberGenerator, validateGeneratedNumber } from '@invoicing-sdk/domain';
import { RequestInvoiceDependencies, IssueInvoiceDependencies, CreateInvoiceDependencies, ListInvoicesDependencies, GetInvoiceDependencies, makeRequestInvoice, makeIssueInvoice, makeCreateInvoice, makeListInvoices, makeGetInvoice } from '@invoicing-sdk/application';
export { CreateInvoiceCommand, CreateInvoiceDependencies, CreateInvoiceResult, EventBus, EventBusConfig, EventBusError, EventHandler, EventPublishError, EventSubscription, EventSubscriptionError, GetInvoiceDependencies, GetInvoiceQuery, GetInvoiceResult, InvoiceRepository, IssueInvoiceCommand, IssueInvoiceDependencies, IssueInvoiceResult, ListInvoicesDependencies, ListInvoicesQuery, ListInvoicesResult, OrderRepository, RequestInvoiceCommand, RequestInvoiceDependencies, RequestInvoiceResult, createCreateInvoiceUseCase, createGetInvoiceUseCase, createIssueInvoiceUseCase, createListInvoicesUseCase, createRequestInvoiceUseCase, makeCreateInvoice, makeGetInvoice, makeIssueInvoice, makeListInvoices, makeRequestInvoice } from '@invoicing-sdk/application';
/**
* Invoicing SDK - Main Entry Point
*
* This package provides a convenient entry point for the invoicing system,
* re-exporting key functionality from domain and application layers with
* additional convenience functions for common use cases.
*/
/**
* All dependencies required for the complete invoicing SDK
*/
interface InvoicingSDKDependencies extends RequestInvoiceDependencies, IssueInvoiceDependencies, CreateInvoiceDependencies, ListInvoicesDependencies, GetInvoiceDependencies {
}
/**
* Complete invoicing SDK with all use cases
*/
interface InvoicingSDK {
requestInvoice: ReturnType<typeof makeRequestInvoice>;
issueInvoice: ReturnType<typeof makeIssueInvoice>;
/**
* @deprecated Use {@link issueInvoice} instead.
* Will be removed in the next major version.
*/
createInvoice: ReturnType<typeof makeCreateInvoice>;
listInvoices: ReturnType<typeof makeListInvoices>;
getInvoice: ReturnType<typeof makeGetInvoice>;
}
/**
* Factory function to create a complete invoicing SDK instance
* with all use cases configured with the provided dependencies.
*
* @param dependencies - All required dependencies for the SDK
* @returns Complete SDK instance with all use cases
*
* @example
* ```typescript
* const sdk = createInvoicingSDK({
* invoiceRepository: myInvoiceRepo,
* orderRepository: myOrderRepo,
* invoiceNumberValidator: myValidator,
* pdfRenderer: myPdfRenderer,
* invoiceNumberGenerator: myGenerator,
* });
*
* // Use the new issue invoice functionality (recommended)
* const result = await sdk.issueInvoice({ orderId: '123', invoiceNumber: 'INV-001', issuedBy: 'user' });
*
* // Use the legacy create invoice functionality (deprecated)
* const legacyResult = await sdk.createInvoice({ orderId: '123', invoiceNumber: 'INV-001', createdBy: 'user' });
* ```
*/
declare function createInvoicingSDK(dependencies: InvoicingSDKDependencies): InvoicingSDK;
/**
* Factory function to create individual use cases with their specific dependencies.
* Useful when you only need specific functionality.
*
* @example
* ```typescript
* const { requestInvoice, issueInvoice } = createUseCases({
* requestInvoice: makeRequestInvoice(requestDeps),
* issueInvoice: makeIssueInvoice(issueDeps),
* });
* ```
*/
declare function createUseCases<T extends Partial<InvoicingSDK>>(useCases: T): T;
/**
* Utility function to validate that all required dependencies are provided
* for the complete SDK. Throws descriptive errors for missing dependencies.
*
* @param dependencies - Dependencies to validate
* @throws Error if any required dependency is missing
*/
declare function validateSDKDependencies(dependencies: Partial<InvoicingSDKDependencies>): asserts dependencies is InvoicingSDKDependencies;
/**
* Safe factory function that validates dependencies before creating the SDK
*
* @param dependencies - Dependencies to validate and use
* @returns Complete SDK instance
* @throws Error if any required dependency is missing
*/
declare function createInvoicingSDKSafe(dependencies: Partial<InvoicingSDKDependencies>): InvoicingSDK;
export { type InvoicingSDK, type InvoicingSDKDependencies, createInvoicingSDK, createInvoicingSDKSafe, createUseCases, validateSDKDependencies };