@beel_es/sdk 2.1.0 → 2.3.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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/http/client.ts","../src/core/defaults.ts","../src/http/headers.ts","../src/http/middleware.ts","../src/core/http-status.ts","../src/core/errors.ts","../src/core/retry.ts","../src/core/error-codes.ts","../src/http/retry-policy.ts","../src/http/retrying-fetch.ts","../src/resources/invoices.ts","../src/resources/customers.ts","../src/resources/products.ts","../src/resources/configuration.ts","../src/resources/series.ts","../src/resources/nif.ts","../src/resources/accounts.ts","../src/http/request-options.ts","../src/resources/payment-connections.ts","../src/resources/invoice-create-once.ts","../src/resources/company.ts","../src/client.ts","../src/webhooks/verifier.ts","../src/generated-webhooks/models/AccountClaimedEvent.ts","../src/generated-webhooks/models/CompanyCreatedEvent.ts","../src/generated-webhooks/models/InvoiceEmailSentEvent.ts","../src/generated-webhooks/models/InvoiceIssuedEvent.ts","../src/generated-webhooks/models/InvoicePdfGeneratedEvent.ts","../src/generated-webhooks/models/InvoiceScheduleFailedEvent.ts","../src/generated-webhooks/models/InvoiceVoidedEvent.ts","../src/generated-webhooks/models/RecurringInvoicePausedEvent.ts","../src/generated-webhooks/models/RepresentationSignedEvent.ts","../src/generated-webhooks/models/VeriFactuStatusUpdatedEvent.ts","../src/generated-webhooks/models/VeriFactuSubmissionStatus.ts","../src/generated-webhooks/models/WebhookEventType.ts","../src/builders/customer-builder.ts","../src/builders/invoice-builder.ts"],"sourcesContent":["// ── Client ─────────────────────────────────────────────\nexport { BeeL } from './client';\nexport type { BeeLConfig } from './http/client';\nexport type { RequestOptions } from './http/request-options';\n\n// ── Typed errors ───────────────────────────────────────\nexport {\n BeeLApiError,\n BeeLRateLimitError,\n BeeLValidationError,\n BeeLAuthError,\n BeeLNotFoundError,\n BeeLConflictError,\n} from './core/errors';\nexport { BeeLErrorCodes } from './core/error-codes';\nexport type { BeeLErrorCode } from './core/error-codes';\n\n// ── Webhook verification ───────────────────────────────\nexport { WebhookVerifier, WebhookVerificationError } from './webhooks/verifier';\nexport type { WebhookEvent } from './webhooks/verifier';\n\n// ── Webhook event types ────────────────────────────────\nexport type {\n WebhookEventEnvelope,\n VeriFactuStatusUpdatedEvent,\n InvoiceIssuedEvent,\n InvoiceVoidedEvent,\n InvoiceEmailSentEvent,\n InvoicePdfGeneratedEvent,\n InvoiceScheduleFailedEvent,\n RecurringInvoicePausedEvent,\n AccountClaimedEvent,\n CompanyCreatedEvent,\n RepresentationSignedEvent,\n WebhookTestEvent,\n} from './webhooks/verifier';\nexport type {\n WebhookEventDataVeriFactuStatusUpdated,\n WebhookEventDataInvoiceIssued,\n WebhookEventDataInvoiceVoided,\n WebhookEventDataInvoiceEmailSent,\n WebhookEventDataInvoicePdfGenerated,\n WebhookEventDataInvoiceScheduleFailed,\n WebhookEventDataRecurringInvoicePaused,\n WebhookEventDataAccountClaimed,\n WebhookEventDataCompanyCreated,\n WebhookEventDataRepresentationSigned,\n WebhookEventDataTest,\n} from './generated-webhooks';\nexport { VeriFactuSubmissionStatus, WebhookEventType } from './generated-webhooks';\n\n// Backwards-compatible aliases for names removed by the webhook spec regeneration\nimport type {\n WebhookEventDataVeriFactuStatusUpdated as _VeriFactuData,\n VeriFactuSubmissionStatus as _VeriFactuStatus,\n} from './generated-webhooks';\n/** @deprecated Renamed in the contract — use `WebhookEventDataVeriFactuStatusUpdated`. */\nexport type VeriFactuStatusUpdatedData = _VeriFactuData;\n/** @deprecated Renamed in the contract — use `VeriFactuSubmissionStatus`. */\nexport type VeriFactuStatus = _VeriFactuStatus;\n\n// ── Accounts & companies (multi-NIF) ───────────────────\nexport {\n AccountsResource,\n AccountScope,\n AccountMembersResource,\n AccountInvitationsResource,\n AccountWebhooksResource,\n AccountCompaniesResource,\n} from './resources/accounts';\nexport {\n CompanyScope,\n CompanyInvoicesResource,\n CompanyCustomersResource,\n CompanyProductsResource,\n CompanySeriesResource,\n CompanyRecurringInvoicesResource,\n CompanyInvoiceScheduleResource,\n} from './resources/company';\nexport { CatalogsResource } from './resources/configuration';\nexport {\n CompanyTaxConfigurationResource,\n CompanyVeriFactuConfigurationResource,\n} from './resources/company';\nexport { EXTERNAL_REF_UNIQUE_INVOICE_TYPES } from './resources/invoice-create-once';\nexport type {\n CreateInvoiceOnceRequest,\n CreateInvoiceOnceParams,\n ExternalRefUniqueInvoiceType,\n} from './resources/invoice-create-once';\nexport {\n CompanyPaymentConnectionsResource,\n CompanyPaymentEventsResource,\n} from './resources/payment-connections';\n\n// ── Builders ───────────────────────────────────────────\nexport { CustomerBuilder } from './builders/customer-builder';\nexport { InvoiceBuilder } from './builders/invoice-builder';\n\n// ── Generated types ────────────────────────────────────\nexport type { components, operations, paths } from './generated/schema';\n","import createClient from 'openapi-fetch';\nimport type { paths } from '../generated/schema';\nimport {\n DEFAULT_AUTO_IDEMPOTENCY_KEY,\n DEFAULT_BASE_URL,\n DEFAULT_MAX_RETRIES,\n DEFAULT_MAX_RETRY_DELAY_MS,\n DEFAULT_RETRY_DELAY_MS,\n} from '../core/defaults';\nimport { AUTHORIZATION_HEADER } from './headers';\nimport { createRequestMiddleware, errorMiddleware } from './middleware';\nimport { createRetryingFetch } from './retrying-fetch';\n\n/**\n * Options of `new BeeL(config)`. Only `apiKey` is required.\n *\n * **Retries and idempotency.** A call is retried automatically, up to `maxRetries` times,\n * only when sending it again can never apply it twice:\n *\n * - `429` is always retried, after `Retry-After`: the API refused the request unprocessed.\n * - `409 IDEMPOTENCY_KEY_PROCESSING` is retried with the same key after `Retry-After`.\n * - `5xx` and network errors are retried for `GET` requests and for requests that carry an\n * `Idempotency-Key` — every `POST` does, unless `autoIdempotencyKey` is `false`. A `5xx`\n * the API marks `Idempotency-Replay: true` is the stored outcome of that key and is not\n * retried: the same key would return it again.\n * - `PUT`, `PATCH` and `DELETE` without a key are not retried after a `5xx` or network error.\n *\n * Every retry of a call reuses that call's `Idempotency-Key`, so an automatic retry never\n * creates a second invoice. Two separate calls get two keys: to retry a create yourself\n * after it failed with a `5xx` or a network error, use `invoices.createOnce`, or look the\n * invoice up by `external_ref` before creating it again.\n */\nexport interface BeeLConfig {\n /** API key: `beel_sk_live_*` (production) or `beel_sk_test_*` (sandbox). */\n apiKey: string;\n /** Base URL. Default: `https://app.beel.es/api`. */\n baseUrl?: string;\n /**\n * Automatic retries after the first attempt, for the cases listed on {@link BeeLConfig}.\n * `0` disables them. Default: `3`.\n */\n maxRetries?: number;\n /** Base delay of the exponential backoff, in milliseconds. Default: `500`. */\n retryDelayMs?: number;\n /** Upper bound of any single wait between attempts, `Retry-After` included, in ms. Default: `30000`. */\n maxRetryDelayMs?: number;\n /**\n * Add one `Idempotency-Key` (a UUID) to every `POST` that does not carry its own, reused by\n * every automatic retry of that call. With `false`, a `POST` without a key is only retried\n * after a `429`. Default: `true`.\n */\n autoIdempotencyKey?: boolean;\n}\n\nexport function createBeeLClient(config: BeeLConfig) {\n const client = createClient<paths>({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n headers: {\n [AUTHORIZATION_HEADER]: `Bearer ${config.apiKey}`,\n },\n fetch: createRetryingFetch({\n maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,\n initialDelayMs: config.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS,\n maxDelayMs: config.maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS,\n }),\n });\n\n client.use(\n createRequestMiddleware({\n autoIdempotencyKey: config.autoIdempotencyKey ?? DEFAULT_AUTO_IDEMPOTENCY_KEY,\n }),\n );\n client.use(errorMiddleware);\n\n return client;\n}\n\nexport type BeeLClient = ReturnType<typeof createBeeLClient>;\n","/**\n * Default values of {@link BeeLConfig}. One place, so the client, the retry helpers, the\n * JSDoc and the README cannot disagree about them.\n */\n\n/** Production API base URL. Sandbox keys (`beel_sk_test_*`) use the same URL. */\nexport const DEFAULT_BASE_URL = 'https://app.beel.es/api';\n\n/** Automatic retries after the first attempt. `0` disables them. */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/** Base delay of the exponential backoff, in milliseconds. */\nexport const DEFAULT_RETRY_DELAY_MS = 500;\n\n/** Upper bound of any single wait between attempts, in milliseconds. */\nexport const DEFAULT_MAX_RETRY_DELAY_MS = 30_000;\n\n/** Whether the client adds an `Idempotency-Key` to every `POST` that does not carry one. */\nexport const DEFAULT_AUTO_IDEMPOTENCY_KEY = true;\n","/** HTTP header names and values the client reads or writes. */\n\n/** Request header that makes a write safe to retry. See the API's idempotency contract. */\nexport const IDEMPOTENCY_KEY_HEADER = 'Idempotency-Key';\n\n/** Response header set to `true` when the API replays the stored answer of a previous key. */\nexport const IDEMPOTENCY_REPLAY_HEADER = 'Idempotency-Replay';\n\n/** Response header with the seconds (or HTTP date) to wait before the next attempt. */\nexport const RETRY_AFTER_HEADER = 'Retry-After';\n\nexport const AUTHORIZATION_HEADER = 'Authorization';\nexport const CONTENT_TYPE_HEADER = 'Content-Type';\nexport const JSON_CONTENT_TYPE = 'application/json';\n\n/** Body sent on a write that carries none: the API rejects an empty JSON body. */\nexport const EMPTY_JSON_BODY = '{}';\n","import { randomUUID } from 'crypto';\nimport type { Middleware } from 'openapi-fetch';\nimport { throwApiError } from '../core/errors';\nimport {\n CONTENT_TYPE_HEADER,\n EMPTY_JSON_BODY,\n IDEMPOTENCY_KEY_HEADER,\n JSON_CONTENT_TYPE,\n} from './headers';\n\n/** Methods whose request must always carry a JSON body. */\nconst METHODS_WITH_JSON_BODY = new Set(['POST', 'PUT', 'PATCH']);\n\n/** Methods that receive an automatic `Idempotency-Key` when they do not carry one. */\nconst METHODS_WITH_AUTO_IDEMPOTENCY_KEY = new Set(['POST']);\n\n/** A fresh `Idempotency-Key`: a UUID, which fits the API's `^[a-zA-Z0-9_-]+$` pattern. */\nexport function newIdempotencyKey(): string {\n return randomUUID();\n}\n\nexport interface RequestMiddlewareOptions {\n /** Add an `Idempotency-Key` to every `POST` that does not carry one. */\n autoIdempotencyKey: boolean;\n}\n\n/**\n * Ensures POST/PUT/PATCH requests always have a JSON body and Content-Type, and — when\n * `autoIdempotencyKey` is on — adds one `Idempotency-Key` per call to POST requests.\n *\n * The key is set once, before the first attempt. The retrying fetch replays the same\n * request, so every automatic retry of a call carries the same key.\n */\nexport function createRequestMiddleware(options: RequestMiddlewareOptions): Middleware {\n const addKeyIfMissing = (request: Request) => {\n if (\n options.autoIdempotencyKey &&\n METHODS_WITH_AUTO_IDEMPOTENCY_KEY.has(request.method) &&\n !request.headers.has(IDEMPOTENCY_KEY_HEADER)\n ) {\n request.headers.set(IDEMPOTENCY_KEY_HEADER, newIdempotencyKey());\n }\n };\n\n return {\n async onRequest({ request }) {\n // Ensure POST/PUT/PATCH always send a JSON body (API rejects empty body)\n if (METHODS_WITH_JSON_BODY.has(request.method)) {\n const hasBody = request.headers.get(CONTENT_TYPE_HEADER)?.includes(JSON_CONTENT_TYPE);\n if (!hasBody) {\n const clone = new Request(request, {\n body: request.body ?? EMPTY_JSON_BODY,\n headers: new Headers(request.headers),\n });\n clone.headers.set(CONTENT_TYPE_HEADER, JSON_CONTENT_TYPE);\n addKeyIfMissing(clone);\n return clone;\n }\n }\n\n addKeyIfMissing(request);\n return request;\n },\n };\n}\n\n/** The request middleware with the default options. */\nexport const requestMiddleware: Middleware = createRequestMiddleware({ autoIdempotencyKey: true });\n\n/**\n * Maps non-2xx responses to typed BeeLApiError subclasses. It sees the final response only:\n * the retrying fetch has already spent the retries by then.\n */\nexport const errorMiddleware: Middleware = {\n async onResponse({ response }) {\n if (!response.ok) {\n const body = await response.json().catch(() => null);\n throwApiError(response.status, body);\n }\n return response;\n },\n};\n","/** HTTP status codes the SDK maps or reacts to. */\nexport const HttpStatus = {\n UNAUTHORIZED: 401,\n FORBIDDEN: 403,\n NOT_FOUND: 404,\n CONFLICT: 409,\n UNPROCESSABLE_ENTITY: 422,\n TOO_MANY_REQUESTS: 429,\n /** First status of the 5xx range: the server failed, not the request. */\n SERVER_ERROR_MIN: 500,\n} as const;\n\n/** Whether `status` is a 5xx. */\nexport function isServerErrorStatus(status: number): boolean {\n return status >= HttpStatus.SERVER_ERROR_MIN;\n}\n","import { HttpStatus } from './http-status';\n\n/** Seconds a {@link BeeLRateLimitError} waits when the body does not say `retry_after`. */\nconst DEFAULT_RATE_LIMIT_RETRY_AFTER_SECONDS = 60;\n\n/**\n * Base error for every non-2xx answer of the BeeL API. The client throws it (or one of its\n * subclasses) from any resource method; a network failure is thrown as the platform's own\n * `fetch` error instead.\n *\n * @example\n * ```typescript\n * try {\n * await company.invoices.issue(invoiceId);\n * } catch (error) {\n * if (error instanceof BeeLApiError) console.error(error.statusCode, error.apiCode, error.requestId);\n * throw error;\n * }\n * ```\n */\nexport class BeeLApiError extends Error {\n /** HTTP status of the response. */\n public readonly statusCode: number;\n /**\n * Stable code of the error class. On the base class it is the API's `error.code`; the\n * subclasses keep a fixed generic value (`CONFLICT`, `NOT_FOUND`…) for backward\n * compatibility. Read {@link apiCode} for the API's specific code.\n */\n public readonly code: string;\n /**\n * The `error.code` the API answered with, verbatim — for example\n * `INVOICE_DUPLICATE_EXTERNAL_REFERENCE`. Equal to {@link code} when the response did not\n * carry one. See {@link BeeLErrorCodes} for the codes this SDK reacts to.\n */\n public readonly apiCode: string;\n /** `error.details` of the response, when the API sent any. */\n public readonly details?: Record<string, string>;\n /** `meta.request_id` of the response. Quote it when you contact support. */\n public readonly requestId?: string;\n\n constructor(\n message: string,\n statusCode: number,\n code: string,\n details?: Record<string, string>,\n requestId?: string,\n apiCode?: string,\n ) {\n super(message);\n this.name = 'BeeLApiError';\n this.statusCode = statusCode;\n this.code = code;\n this.apiCode = apiCode ?? code;\n this.details = details;\n this.requestId = requestId;\n }\n}\n\n/** `429`: rate limit exceeded. Retried automatically, see `maxRetries`. */\nexport class BeeLRateLimitError extends BeeLApiError {\n /** Seconds the API asked to wait before the next request. */\n public readonly retryAfterSeconds: number;\n\n constructor(message: string, retryAfterSeconds: number, requestId?: string, apiCode?: string) {\n super(message, HttpStatus.TOO_MANY_REQUESTS, 'RATE_LIMIT_EXCEEDED', undefined, requestId, apiCode);\n this.name = 'BeeLRateLimitError';\n this.retryAfterSeconds = retryAfterSeconds;\n }\n}\n\n/** `422`: validation or business rule error. `details` names the offending fields. */\nexport class BeeLValidationError extends BeeLApiError {\n constructor(\n message: string,\n details?: Record<string, string>,\n requestId?: string,\n apiCode?: string,\n ) {\n super(message, HttpStatus.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY', details, requestId, apiCode);\n this.name = 'BeeLValidationError';\n }\n}\n\n/** `401` / `403`: the API key is missing or invalid, or lacks access to the resource. */\nexport class BeeLAuthError extends BeeLApiError {\n constructor(message: string, statusCode: 401 | 403, requestId?: string, apiCode?: string) {\n super(\n message,\n statusCode,\n statusCode === HttpStatus.UNAUTHORIZED ? 'UNAUTHORIZED' : 'FORBIDDEN',\n undefined,\n requestId,\n apiCode,\n );\n this.name = 'BeeLAuthError';\n }\n}\n\n/** `404`: the resource does not exist. */\nexport class BeeLNotFoundError extends BeeLApiError {\n constructor(message: string, requestId?: string, apiCode?: string) {\n super(message, HttpStatus.NOT_FOUND, 'NOT_FOUND', undefined, requestId, apiCode);\n this.name = 'BeeLNotFoundError';\n }\n}\n\n/**\n * `409`: conflict — for example `INVOICE_DUPLICATE_EXTERNAL_REFERENCE` or an\n * `Idempotency-Key` reused with another body. Branch on {@link BeeLApiError.apiCode}.\n */\nexport class BeeLConflictError extends BeeLApiError {\n constructor(\n message: string,\n requestId?: string,\n apiCode?: string,\n details?: Record<string, string>,\n ) {\n super(message, HttpStatus.CONFLICT, 'CONFLICT', details, requestId, apiCode);\n this.name = 'BeeLConflictError';\n }\n}\n\n/**\n * Maps a raw HTTP error response to a typed BeeLApiError subclass.\n */\nexport function throwApiError(status: number, body: unknown): never {\n const parsed = body as Record<string, any> | null;\n const errorData = parsed?.error ?? parsed;\n const message = errorData?.message ?? `API error ${status}`;\n const apiCode: string | undefined = errorData?.code;\n const details = errorData?.details;\n const requestId = parsed?.meta?.request_id;\n\n switch (status) {\n case HttpStatus.UNAUTHORIZED:\n case HttpStatus.FORBIDDEN:\n throw new BeeLAuthError(message, status as 401 | 403, requestId, apiCode);\n case HttpStatus.NOT_FOUND:\n throw new BeeLNotFoundError(message, requestId, apiCode);\n case HttpStatus.CONFLICT:\n throw new BeeLConflictError(message, requestId, apiCode, details);\n case HttpStatus.UNPROCESSABLE_ENTITY:\n throw new BeeLValidationError(message, details, requestId, apiCode);\n case HttpStatus.TOO_MANY_REQUESTS: {\n const retryAfter = errorData?.retry_after ?? DEFAULT_RATE_LIMIT_RETRY_AFTER_SECONDS;\n throw new BeeLRateLimitError(message, retryAfter, requestId, apiCode);\n }\n default:\n throw new BeeLApiError(message, status, apiCode ?? 'UNKNOWN', details, requestId);\n }\n}\n","import { BeeLApiError, BeeLRateLimitError } from './errors';\nimport { isServerErrorStatus } from './http-status';\nimport {\n DEFAULT_MAX_RETRIES,\n DEFAULT_MAX_RETRY_DELAY_MS,\n DEFAULT_RETRY_DELAY_MS,\n} from './defaults';\n\nconst MS_PER_SECOND = 1000;\n\nexport interface RetryOptions {\n /** Retries after the first attempt. */\n maxRetries: number;\n /** Base delay of the exponential backoff, in milliseconds. */\n initialDelayMs: number;\n /** Upper bound of any single wait, in milliseconds. */\n maxDelayMs: number;\n}\n\nconst DEFAULT_RETRY_OPTIONS: RetryOptions = {\n maxRetries: DEFAULT_MAX_RETRIES,\n initialDelayMs: DEFAULT_RETRY_DELAY_MS,\n maxDelayMs: DEFAULT_MAX_RETRY_DELAY_MS,\n};\n\n/**\n * Resolves after `ms` milliseconds. With a `signal`, rejects with its reason as soon as it\n * aborts, and clears the timer so it does not keep the process alive.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(signal.reason);\n return;\n }\n const onAbort = () => {\n clearTimeout(timer);\n reject(signal!.reason);\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n\n/**\n * Exponential backoff with jitter: `initialDelayMs × 2^attempt` plus up to one\n * `initialDelayMs` of random jitter, capped at `maxDelayMs`.\n *\n * @param attempt - Zero-based index of the retry about to happen.\n * @param options - Base and cap of the backoff.\n * @param random - Source of jitter in `[0, 1)`; injectable for tests.\n */\nexport function computeBackoffDelayMs(\n attempt: number,\n options: Pick<RetryOptions, 'initialDelayMs' | 'maxDelayMs'>,\n random: () => number = Math.random,\n): number {\n const exponentialDelay = options.initialDelayMs * Math.pow(2, attempt);\n const jitter = random() * options.initialDelayMs;\n return Math.min(exponentialDelay + jitter, options.maxDelayMs);\n}\n\nfunction isRetryable(error: unknown): boolean {\n if (error instanceof BeeLRateLimitError) return true;\n if (error instanceof BeeLApiError) return isServerErrorStatus(error.statusCode);\n return false;\n}\n\nfunction getDelay(error: unknown, attempt: number, options: RetryOptions): number {\n // For rate limit errors, use the server-provided retry-after\n if (error instanceof BeeLRateLimitError) {\n return error.retryAfterSeconds * MS_PER_SECOND;\n }\n return computeBackoffDelayMs(attempt, options);\n}\n\n/**\n * Wraps an async function with automatic retries.\n * Retries on 429 (rate limit) and 5xx (server errors).\n * Does NOT retry on 4xx client errors (400, 401, 403, 404, 422).\n *\n * The HTTP client does not use this helper: its retries live in `http/retrying-fetch.ts`,\n * which also knows whether a request is safe to replay.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n options: Partial<RetryOptions> = {},\n): Promise<T> {\n const opts = { ...DEFAULT_RETRY_OPTIONS, ...options };\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n\n if (attempt >= opts.maxRetries || !isRetryable(error)) {\n throw error;\n }\n\n await sleep(getDelay(error, attempt, opts));\n }\n }\n\n throw lastError;\n}\n","/**\n * `error.code` values of the API that the SDK itself reacts to. Compare them with\n * {@link BeeLApiError.apiCode}. The full catalogue lives in the API reference\n * (https://docs.beel.es); these are the ones this package has behaviour for.\n */\nexport const BeeLErrorCodes = {\n /**\n * `409`: a live standard or simplified invoice with the same `external_ref` already exists\n * in this environment. Look it up with `invoices.list({ external_ref })`.\n */\n INVOICE_DUPLICATE_EXTERNAL_REFERENCE: 'INVOICE_DUPLICATE_EXTERNAL_REFERENCE',\n /**\n * `409`: the first request with this `Idempotency-Key` is still being processed. Retry with\n * the same key after `Retry-After`; the client does so automatically.\n */\n IDEMPOTENCY_KEY_PROCESSING: 'IDEMPOTENCY_KEY_PROCESSING',\n /** `409`: the `Idempotency-Key` was already used with a different body. Use a new key. */\n IDEMPOTENCY_KEY_MISMATCH: 'IDEMPOTENCY_KEY_MISMATCH',\n} as const;\n\n/** One of the {@link BeeLErrorCodes} values. */\nexport type BeeLErrorCode = (typeof BeeLErrorCodes)[keyof typeof BeeLErrorCodes];\n","import { computeBackoffDelayMs, type RetryOptions } from '../core/retry';\nimport { BeeLErrorCodes } from '../core/error-codes';\nimport { HttpStatus, isServerErrorStatus } from '../core/http-status';\nimport { IDEMPOTENCY_KEY_HEADER, IDEMPOTENCY_REPLAY_HEADER, RETRY_AFTER_HEADER } from './headers';\n\nconst MS_PER_SECOND = 1000;\n\n/** Methods that never change state, so replaying them is always safe. */\nconst READ_ONLY_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);\n\n/** Wait the API documents for `IDEMPOTENCY_KEY_PROCESSING` when `Retry-After` is absent. */\nconst IDEMPOTENCY_PROCESSING_DEFAULT_WAIT_MS = 2 * MS_PER_SECOND;\n\n/** What one attempt produced: a response, or the error `fetch` rejected with. */\nexport type AttemptOutcome = { response: Response } | { error: unknown };\n\n/** Whether to try again, and after how long. */\nexport type RetryDecision = { retry: false } | { retry: true; delayMs: number };\n\nconst NO_RETRY: RetryDecision = { retry: false };\n\n/**\n * Whether sending `request` again can never apply its operation twice: it is read-only, or\n * it carries an `Idempotency-Key`, which makes the API replay the first outcome instead of\n * running the operation again.\n */\nexport function isReplaySafe(request: Request): boolean {\n return READ_ONLY_METHODS.has(request.method) || request.headers.has(IDEMPOTENCY_KEY_HEADER);\n}\n\n/**\n * Parses `Retry-After` (delta-seconds or an HTTP date) into milliseconds from `now`.\n * Returns `undefined` when the header is absent or unreadable.\n */\nexport function parseRetryAfterMs(value: string | null, now: number = Date.now()): number | undefined {\n if (value === null || value.trim() === '') return undefined;\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * MS_PER_SECOND);\n const date = Date.parse(value);\n return Number.isNaN(date) ? undefined : Math.max(0, date - now);\n}\n\nfunction isAbort(error: unknown): boolean {\n return error instanceof Error && error.name === 'AbortError';\n}\n\nasync function errorCodeOf(response: Response): Promise<string | undefined> {\n const body = await response.clone().json().catch(() => null);\n return body?.error?.code;\n}\n\n/**\n * Decides whether the client retries an attempt. The rules, in order:\n *\n * 1. `429` — always, after `Retry-After`: the API rejected the request before running it.\n * 2. `409 IDEMPOTENCY_KEY_PROCESSING` — the first request with this key is still in flight;\n * the same key is retried after `Retry-After`.\n * 3. `5xx` — only when {@link isReplaySafe}, and never for a response the API marks with\n * `Idempotency-Replay: true`: that is the stored outcome of the key, and replaying it\n * again would return the same `5xx`.\n * 4. A network error (`fetch` rejected) — only when {@link isReplaySafe}.\n * 5. Anything else — no retry.\n *\n * Never once the request's signal has aborted (caller abort or `timeoutMs`). Every wait is\n * capped at `maxDelayMs`.\n */\nexport async function decideRetry(\n request: Request,\n outcome: AttemptOutcome,\n attempt: number,\n options: Pick<RetryOptions, 'initialDelayMs' | 'maxDelayMs'>,\n): Promise<RetryDecision> {\n const backoff = () => computeBackoffDelayMs(attempt, options);\n const capped = (delayMs: number): RetryDecision => ({\n retry: true,\n delayMs: Math.min(delayMs, options.maxDelayMs),\n });\n\n if (request.signal?.aborted) return NO_RETRY;\n\n if ('error' in outcome) {\n if (isAbort(outcome.error) || !isReplaySafe(request)) return NO_RETRY;\n return capped(backoff());\n }\n\n const { response } = outcome;\n const retryAfterMs = parseRetryAfterMs(response.headers.get(RETRY_AFTER_HEADER));\n\n if (response.status === HttpStatus.TOO_MANY_REQUESTS) {\n return capped(retryAfterMs ?? backoff());\n }\n\n if (\n response.status === HttpStatus.CONFLICT &&\n request.headers.has(IDEMPOTENCY_KEY_HEADER) &&\n (await errorCodeOf(response)) === BeeLErrorCodes.IDEMPOTENCY_KEY_PROCESSING\n ) {\n return capped(retryAfterMs ?? IDEMPOTENCY_PROCESSING_DEFAULT_WAIT_MS);\n }\n\n if (isServerErrorStatus(response.status)) {\n const isStoredReplay = response.headers.get(IDEMPOTENCY_REPLAY_HEADER) === 'true';\n if (isStoredReplay || !isReplaySafe(request)) return NO_RETRY;\n return capped(retryAfterMs ?? backoff());\n }\n\n return NO_RETRY;\n}\n","import { sleep as defaultSleep, type RetryOptions } from '../core/retry';\nimport { decideRetry, type AttemptOutcome } from './retry-policy';\n\n/** The subset of `fetch` the client calls. */\nexport type FetchLike = (request: Request, init?: RequestInit) => Promise<Response>;\n\nexport interface RetryingFetchDependencies {\n /** Performs one attempt. Defaults to the global `fetch`, looked up on every call. */\n fetch?: FetchLike;\n /** Waits between attempts; rejects when the signal aborts. Injectable so tests do not sleep. */\n sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;\n}\n\nconst globalFetch: FetchLike = (request, init) => globalThis.fetch(request, init);\n\n/** Releases the body of an attempt that will not be returned, so its socket is freed. */\nasync function discard(response: Response): Promise<void> {\n await response.body?.cancel().catch(() => undefined);\n}\n\n/**\n * Wraps `fetch` with the SDK's automatic retries (see `decideRetry` for when). Every attempt\n * sends a clone of the same `Request`, so a retry carries the very same headers — the\n * `Idempotency-Key` included — and body as the first attempt.\n *\n * It returns the last response, successful or not, and leaves mapping a non-2xx to a typed\n * error to the error middleware. It rethrows the last network error. An aborted request\n * signal stops it at once, between attempts too, with the signal's reason.\n */\nexport function createRetryingFetch(\n options: RetryOptions,\n dependencies: RetryingFetchDependencies = {},\n): FetchLike {\n const attemptFetch = dependencies.fetch ?? globalFetch;\n const wait = dependencies.sleep ?? defaultSleep;\n\n return async (request, init) => {\n for (let attempt = 0; ; attempt++) {\n let outcome: AttemptOutcome;\n try {\n outcome = { response: await attemptFetch(request.clone(), init) };\n } catch (error) {\n outcome = { error };\n }\n\n const decision =\n attempt < options.maxRetries\n ? await decideRetry(request, outcome, attempt, options)\n : ({ retry: false } as const);\n\n if (!decision.retry) {\n if ('error' in outcome) throw outcome.error;\n return outcome.response;\n }\n\n if ('response' in outcome) await discard(outcome.response);\n await wait(decision.delayMs, request.signal ?? undefined);\n }\n };\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype Invoice = components['schemas']['Invoice'];\ntype Pagination = components['schemas']['Pagination'];\ntype ListParams = operations['listInvoices']['parameters']['query'];\n\n/**\n * Invoices of the focused company, on the flat `/v1/invoices` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).invoices` instead.\n */\nexport class InvoicesResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List invoices with optional filters and pagination.\n *\n * @param params - Filters and pagination.\n * @returns The page of `invoices` and its `pagination`.\n *\n * @example\n * const { invoices, pagination } = await beel.invoices.list({ status: 'ISSUED', limit: 20 });\n */\n async list(params?: ListParams) {\n const { data } = await this.client.GET('/v1/invoices', { params: { query: params } });\n return data!.data as { invoices: Invoice[]; pagination: Pagination };\n }\n\n /**\n * Create a new invoice. An idempotency key is automatically added.\n *\n * @param body - Type, recipient and lines.\n * @returns The created invoice.\n *\n * @example\n * const invoice = await beel.invoices.create({\n * type: 'STANDARD',\n * recipient: { customer_id: 'uuid' },\n * lines: [{ description: 'Service', quantity: 1, unit_price: 100, discount_percentage: 0 }],\n * });\n */\n async create(body: components['schemas']['CreateInvoiceRequest']) {\n const { data } = await this.client.POST('/v1/invoices', { body });\n return data!.data as Invoice;\n }\n\n /**\n * Get an invoice by ID.\n *\n * @param id - Invoice UUID.\n * @returns The invoice.\n */\n async get(id: string) {\n const { data } = await this.client.GET('/v1/invoices/{invoice_id}', { params: { path: { invoice_id: id } } });\n return data!.data as Invoice;\n }\n\n /**\n * Update a draft invoice. Only draft invoices can be updated.\n *\n * @param id - Invoice UUID.\n * @param body - The draft's new content.\n * @returns The updated invoice.\n */\n async update(id: string, body: components['schemas']['UpdateInvoiceRequest']) {\n const { data } = await this.client.PUT('/v1/invoices/{invoice_id}', { params: { path: { invoice_id: id } }, body });\n return data!.data as Invoice;\n }\n\n /**\n * Delete a draft invoice. Only draft invoices can be deleted.\n *\n * @param id - Invoice UUID.\n */\n async delete(id: string) {\n await this.client.DELETE('/v1/invoices/{invoice_id}', { params: { path: { invoice_id: id } } });\n }\n\n /**\n * Duplicate an invoice, optionally into a different series.\n *\n * @param id - Invoice UUID.\n * @param options - `series_id` and `notes` of the copy.\n * @returns The new draft.\n */\n async duplicate(id: string, options?: { series_id?: string; notes?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/duplicate', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data as Invoice;\n }\n\n /**\n * Issue a draft invoice. Assigns an invoice number and triggers VeriFactu submission.\n *\n * @param id - Invoice UUID.\n * @param options - `wait_for_pdf: true` to wait for the PDF.\n * @returns The issued invoice.\n */\n async issue(id: string, options?: { wait_for_pdf?: boolean }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/issue', { params: { path: { invoice_id: id }, query: options } });\n return data!.data as Invoice;\n }\n\n /**\n * Mark an invoice as paid.\n *\n * @param id - Invoice UUID.\n * @param options - `payment_date` (default: today) and `payment_method`.\n * @returns The paid invoice.\n */\n async markPaid(id: string, options?: { payment_date?: string; payment_method?: any }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/mark-paid', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data as Invoice;\n }\n\n /**\n * Mark an invoice as sent (e.g. delivered by other means).\n *\n * @param id - Invoice UUID.\n * @param options - `sent_at`.\n * @returns The sent invoice.\n */\n async markSent(id: string, options?: { sent_at?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/mark-sent', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data as Invoice;\n }\n\n /**\n * Revert a paid/sent invoice back to issued status.\n *\n * @param id - Invoice UUID.\n * @returns The invoice, back in `ISSUED`.\n */\n async revertToIssued(id: string) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/revert-to-issued', { params: { path: { invoice_id: id } } });\n return data!.data as Invoice;\n }\n\n /**\n * Void an issued invoice. Requires a reason (min 10 chars).\n *\n * @param id - Invoice UUID.\n * @param params - `reason` (min 10 characters) and optional `void_date`.\n * @returns The voided invoice.\n *\n * @example\n * await beel.invoices.void('id', { reason: 'Duplicate invoice sent in error' });\n */\n async void(id: string, params: { reason: string; void_date?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/void', { params: { path: { invoice_id: id } }, body: params as any });\n return data!.data as Invoice;\n }\n\n /**\n * Create a corrective invoice that references the original.\n *\n * @param id - UUID of the issued invoice to correct.\n * @param body - Rectification type, code, reason and lines.\n * @returns The corrective invoice.\n */\n async createCorrective(id: string, body: components['schemas']['CreateCorrectiveInvoiceRequest']) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/corrective', { params: { path: { invoice_id: id } }, body });\n return data!.data as Invoice;\n }\n\n /**\n * Schedule a draft invoice to be issued on a future date.\n *\n * @param id - UUID of the draft.\n * @param params - `scheduled_for` and optional `action`.\n * @returns The scheduled invoice.\n */\n async schedule(id: string, params: { scheduled_for: string; action?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/schedule', { params: { path: { invoice_id: id } }, body: params as any });\n return data!.data as Invoice;\n }\n\n /**\n * Cancel a scheduled invoice, returning it to draft.\n *\n * @param id - Invoice UUID.\n * @returns The invoice, back in draft.\n */\n async unschedule(id: string) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/unschedule', { params: { path: { invoice_id: id } } });\n return data!.data as Invoice;\n }\n\n /**\n * Change the scheduled date of a scheduled invoice.\n *\n * @param id - Invoice UUID.\n * @param params - New `scheduled_for`.\n * @returns The rescheduled invoice.\n */\n async reschedule(id: string, params: { scheduled_for: string }) {\n const { data } = await this.client.PATCH('/v1/invoices/{invoice_id}/reschedule', { params: { path: { invoice_id: id } }, body: params as any });\n return data!.data as Invoice;\n }\n\n /**\n * Get a pre-signed URL to download the invoice PDF.\n * The URL expires in 5 minutes. Use `beel.downloadPdf(id)` for a simpler Buffer download.\n *\n * @param id - Invoice UUID.\n * @returns `download_url`, `expires_in_seconds` and `file_name`.\n */\n async getPdf(id: string) {\n const { data } = await this.client.GET('/v1/invoices/{invoice_id}/pdf', { params: { path: { invoice_id: id } } });\n return data!.data as { download_url: string; expires_in_seconds: number; file_name: string };\n }\n\n /**\n * Send an invoice by email. Uses the customer's email by default.\n *\n * @param id - Invoice UUID.\n * @param options - Recipients, subject and message.\n * @returns The delivery record.\n */\n async sendEmail(id: string, options?: { to?: string[]; cc?: string[]; subject?: string; message?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/send', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype Customer = components['schemas']['Customer'];\ntype Pagination = components['schemas']['Pagination'];\ntype ListParams = operations['listCustomers']['parameters']['query'];\n\n/**\n * Customers of the focused company, on the flat `/v1/customers` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).customers` instead.\n */\nexport class CustomersResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List customers with optional filters and pagination.\n *\n * @param params - Filters and pagination.\n * @returns The page of `customers` and its `pagination`.\n *\n * @example\n * const { customers, pagination } = await beel.customers.list({ search: 'Acme', limit: 10 });\n */\n async list(params?: ListParams) {\n const { data } = await this.client.GET('/v1/customers', { params: { query: params } });\n return data!.data as { customers: Customer[]; pagination: Pagination };\n }\n\n /**\n * Create a new customer.\n *\n * @param body - Legal name, NIF and address.\n * @returns The created customer.\n *\n * @example\n * const customer = await beel.customers.create({\n * legal_name: 'Acme SL',\n * nif: 'B12345678',\n * address: { street: 'Calle Mayor', number: '1', postal_code: '28001', city: 'Madrid', province: 'Madrid', country: 'Spain', country_code: 'ES' },\n * });\n */\n async create(body: components['schemas']['CreateCustomerRequest']) {\n const { data } = await this.client.POST('/v1/customers', { body });\n return data!.data as Customer;\n }\n\n /**\n * Get a customer by ID.\n *\n * @param id - Customer UUID.\n * @returns The customer.\n */\n async get(id: string) {\n const { data } = await this.client.GET('/v1/customers/{customer_id}', { params: { path: { customer_id: id } } });\n return data!.data as Customer;\n }\n\n /**\n * Update a customer. Only provided fields are changed.\n *\n * @param id - Customer UUID.\n * @param body - Fields to change.\n * @returns The updated customer.\n */\n async update(id: string, body: components['schemas']['UpdateCustomerRequest']) {\n const { data } = await this.client.PUT('/v1/customers/{customer_id}', { params: { path: { customer_id: id } }, body });\n return data!.data as Customer;\n }\n\n /**\n * Deactivate (soft-delete) a customer.\n *\n * @param id - Customer UUID.\n */\n async deactivate(id: string) {\n await this.client.DELETE('/v1/customers/{customer_id}', { params: { path: { customer_id: id } } });\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype Product = components['schemas']['Product'];\ntype Pagination = components['schemas']['Pagination'];\ntype ListParams = operations['listProducts']['parameters']['query'];\n\n/**\n * Products of the focused company, on the flat `/v1/products` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).products` instead.\n */\nexport class ProductsResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List products with optional filters and pagination.\n *\n * @param params - Filters and pagination.\n * @returns The page of `products` and its `pagination`.\n *\n * @example\n * const { products, pagination } = await beel.products.list({ category: 'SERVICE' });\n */\n async list(params?: ListParams) {\n const { data } = await this.client.GET('/v1/products', { params: { query: params } });\n return data!.data as { products: Product[]; pagination: Pagination };\n }\n\n /**\n * Create a new product or service.\n *\n * @param body - Name, category, price and main tax.\n * @returns The created product.\n *\n * @example\n * const product = await beel.products.create({\n * name: 'Consulting',\n * code: 'CONS-001',\n * category: 'SERVICE',\n * default_price: 100,\n * main_tax: { type: 'IVA', percentage: 21 },\n * });\n */\n async create(body: components['schemas']['CreateProductRequest']) {\n const { data } = await this.client.POST('/v1/products', { body });\n return data!.data as Product;\n }\n\n /**\n * Get a product by ID.\n *\n * @param id - Product UUID.\n * @returns The product.\n */\n async get(id: string) {\n const { data } = await this.client.GET('/v1/products/{product_id}', { params: { path: { product_id: id } } });\n return data!.data as Product;\n }\n\n /**\n * Update a product. Only provided fields are changed.\n *\n * @param id - Product UUID.\n * @param body - Fields to change.\n * @returns The updated product.\n */\n async update(id: string, body: components['schemas']['UpdateProductRequest']) {\n const { data } = await this.client.PUT('/v1/products/{product_id}', { params: { path: { product_id: id } }, body });\n return data!.data as Product;\n }\n\n /**\n * Delete a product permanently.\n *\n * @param id - Product UUID.\n */\n async delete(id: string) {\n await this.client.DELETE('/v1/products/{product_id}', { params: { path: { product_id: id } } });\n }\n\n /**\n * Search products by name or code. Returns up to `limit` results.\n *\n * @param q - Text to search in name or code.\n * @param limit - Maximum results.\n * @returns The matching products, as a bare array.\n *\n * @example\n * const results = await beel.products.search('consulting', 5);\n */\n async search(q: string, limit?: number) {\n const { data } = await this.client.GET('/v1/products/search', { params: { query: { q, limit } } });\n return data!.data as Product[];\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components } from '../generated/schema';\n\n/**\n * Account-wide configuration on the flat `/v1/configuration/*` routes.\n *\n * @deprecated The contract deprecates these routes. Use\n * `beel.company(companyId).taxConfiguration`, `beel.company(companyId).verifactuConfiguration`\n * and {@link CatalogsResource} (`beel.catalogs`) instead.\n */\nexport class ConfigurationResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * Get the tax configuration (default VAT, IRPF…) of the focused company.\n *\n * @returns The tax configuration.\n */\n async getTaxConfig() {\n const { data } = await this.client.GET('/v1/configuration/taxes');\n return data!.data;\n }\n\n /**\n * Replace the tax configuration of the focused company.\n *\n * @param body - The complete tax configuration.\n * @returns The stored configuration.\n */\n async updateTaxConfig(body: any) {\n const { data } = await this.client.PUT('/v1/configuration/taxes', { body });\n return data!.data;\n }\n\n /**\n * Tax types the API accepts (IVA/IGIC rates, IRPF types, equivalence surcharges).\n *\n * @returns The tax types catalog.\n */\n async getTaxTypes() {\n const { data } = await this.client.GET('/v1/configuration/tax-types');\n return data!.data;\n }\n\n /**\n * Invoice customization options (templates, colors…).\n *\n * @returns The customization options.\n */\n async getInvoiceCustomizationOptions() {\n const { data } = await this.client.GET('/v1/configuration/invoice-customization-options');\n return data!.data;\n }\n\n /**\n * Update the preferred language of the signed-in person.\n *\n * @param language - `es`, `en` or `ca`.\n * @returns The updated preferences.\n */\n async updateLanguage(language: string) {\n const { data } = await this.client.PUT('/v1/configuration/language', { body: { language } as any });\n return data!.data;\n }\n\n /**\n * Get the VeriFactu configuration of the focused company.\n *\n * @returns The VeriFactu configuration.\n */\n async getVerifactu() {\n const { data } = await this.client.GET('/v1/configuration/verifactu');\n return data!.data;\n }\n\n /**\n * Update the VeriFactu configuration of the focused company.\n *\n * @param body - `{ enabled }`.\n * @returns The updated configuration.\n */\n async updateVerifactu(body: any) {\n const { data } = await this.client.PUT('/v1/configuration/verifactu', { body });\n return data!.data;\n }\n}\n\n/**\n * Account-wide catalogs, the credential's identity and personal preferences, on their\n * canonical paths. Reach it as `beel.catalogs`.\n *\n * These replace the `/v1/configuration/*` reads on {@link ConfigurationResource},\n * whose flat routes are deprecated.\n */\nexport class CatalogsResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * Who the API key belongs to: its `account_id` — the starting point to list the\n * account's companies — plus the person's email, name and language, and the credential.\n * Needs no scope, so it also confirms that a key works.\n *\n * @returns The identity of the credential.\n *\n * @example\n * ```typescript\n * const { account_id } = await beel.catalogs.identity();\n * const { companies } = await beel.account(account_id).companies.list();\n * ```\n */\n async identity() {\n const { data } = await this.client.GET('/v1/me/identity');\n return data!.data as components['schemas']['MyIdentity'];\n }\n\n /**\n * Tax types the API accepts. Canonical form of `configuration/tax-types`.\n *\n * @returns The tax types catalog.\n */\n async taxTypes() {\n const { data } = await this.client.GET('/v1/tax-types');\n return data!.data;\n }\n\n /**\n * Invoice PDF templates and customization options. Canonical form of the `configuration` read.\n *\n * @returns The customization options.\n */\n async invoiceCustomizationOptions() {\n const { data } = await this.client.GET('/v1/invoice-customization-options');\n return data!.data;\n }\n\n /**\n * Update the signed-in person's preferences. Canonical form of\n * `PUT /v1/configuration/language`: the language belongs to the person, not to a company.\n *\n * @param body - Preferences to change, e.g. `{ language: 'es' }`.\n * @returns The updated preferences.\n */\n async updateMe(body: components['schemas']['UpdateMeRequest']) {\n const { data } = await this.client.PATCH('/v1/me', { body });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\n\n/**\n * Invoice series of the focused company, on the flat `/v1/configuration/series` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).series` instead.\n */\nexport class SeriesResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List all invoice series. Optionally filter by active status.\n *\n * @param active - Only active (`true`) or inactive (`false`) series; all when omitted.\n * @returns The series.\n *\n * @example\n * const series = await beel.series.list();\n * const activeSeries = await beel.series.list(true);\n */\n async list(active?: boolean) {\n const { data } = await this.client.GET('/v1/configuration/series', {\n params: { query: active !== undefined ? { active } : undefined },\n });\n return data!.data;\n }\n\n /**\n * Create a new invoice series (e.g. \"A-2026\", \"RECT\").\n *\n * @param body - Code, name and format.\n * @returns The created series.\n */\n async create(body: any) {\n const { data } = await this.client.POST('/v1/configuration/series', { body });\n return data!.data;\n }\n\n /**\n * Update a series (name, description, etc.).\n *\n * @param id - Series UUID.\n * @param body - Fields to change.\n * @returns The updated series.\n */\n async update(id: string, body: any) {\n const { data } = await this.client.PUT('/v1/configuration/series/{series_id}', {\n params: { path: { series_id: id } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Delete an invoice series. Only empty series can be deleted.\n *\n * @param id - Series UUID.\n */\n async delete(id: string) {\n await this.client.DELETE('/v1/configuration/series/{series_id}', {\n params: { path: { series_id: id } },\n });\n }\n\n /**\n * Set a series as the default for new invoices.\n *\n * @param id - Series UUID.\n * @returns The series.\n */\n async setDefault(id: string) {\n const { data } = await this.client.POST('/v1/configuration/series/{series_id}/default', {\n params: { path: { series_id: id } },\n });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\n\n/**\n * NIF validation against the AEAT register. Reach it as `beel.nif`.\n */\nexport class NifResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * Validate a Spanish NIF/CIF against the AEAT tax registry.\n *\n * @param nif - The NIF/CIF to validate.\n * @returns Whether it is valid and, when the register knows it, its holder's name.\n *\n * @example\n * const result = await beel.nif.validate('B12345678');\n * console.log(result.valid, result.name);\n */\n async validate(nif: string) {\n const { data } = await this.client.POST('/v1/nif/validate', { body: { nif } as any });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype ManagedAccountSummary = components['schemas']['ManagedAccountSummary'];\ntype ProvisionAccountResult = components['schemas']['ProvisionAccountResult'];\ntype AccountMember = components['schemas']['AccountMember'];\ntype Invitation = components['schemas']['Invitation'];\ntype WebhookSubscription = components['schemas']['WebhookSubscription'];\ntype ProvisioningUsage = components['schemas']['ProvisioningUsage'];\ntype CompanyData = components['schemas']['CompanyData'];\ntype Pagination = components['schemas']['Pagination'];\n\n/**\n * Accounts you provisioned and manage (multi-account provisioning for platforms and\n * advisory firms). Reach it as `beel.accounts`; scope one with `beel.account(accountId)`.\n *\n * Every method rejects with a `BeeLApiError` subclass when the API answers non-2xx.\n *\n * @example\n * ```typescript\n * const { accounts } = await beel.accounts.list();\n * const account = beel.accounts.scope(accounts[0].account_id);\n * const members = await account.members.list();\n * ```\n */\nexport class AccountsResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List the accounts you provisioned, newest first. Cursor-paginated: pass the\n * `next_cursor` of one page as `cursor` of the next until it is `null`.\n *\n * @param params - `status`, `external_ref` (exact), `limit`, `cursor`.\n * @returns The `accounts` of the page and `next_cursor`.\n */\n async list(params?: operations['listAccounts']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts', { params: { query: params } });\n return data!.data as { accounts: ManagedAccountSummary[]; next_cursor?: string | null };\n }\n\n /**\n * Provision a new managed account. Idempotent by `external_ref`: sending the same one\n * again returns the same account. Answers with the provisioning result — the account id,\n * its status and, when one is issued, the claim link — not with the account summary.\n *\n * @param body - `external_ref` and the holder's details.\n * @returns `account_id`, `status` and the claim link state.\n */\n async provision(body: operations['provisionAccount']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts', { body });\n return data!.data as ProvisionAccountResult;\n }\n\n /**\n * Get a managed account.\n *\n * @param accountId - Account UUID.\n * @returns The account summary.\n */\n async get(accountId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}', {\n params: { path: { account_id: accountId } },\n });\n return data!.data as ManagedAccountSummary;\n }\n\n /**\n * Alias of `beel.account(accountId)`: the operations scoped to one account.\n *\n * @param accountId - Account UUID.\n * @returns The account scope. No request is made.\n */\n scope(accountId: string): AccountScope {\n return new AccountScope(this.client, accountId);\n }\n}\n\n/**\n * Operations scoped to one account: its companies (NIFs), members, invitations, webhooks\n * and usage. Reach it as `beel.account(accountId)`.\n *\n * @example\n * ```typescript\n * const { companies } = await beel.account('account-uuid').companies.list();\n * const company = beel.company(companies[0].id!);\n * ```\n */\nexport class AccountScope {\n /** Members of the account and their per-company grants. */\n readonly members: AccountMembersResource;\n /** Invitations to join the account. */\n readonly invitations: AccountInvitationsResource;\n /** Webhook subscriptions of the account. */\n readonly webhooks: AccountWebhooksResource;\n /** Companies (NIFs) of the account — where company ids come from. */\n readonly companies: AccountCompaniesResource;\n\n constructor(private client: BeeLClient, readonly accountId: string) {\n this.members = new AccountMembersResource(client, accountId);\n this.invitations = new AccountInvitationsResource(client, accountId);\n this.webhooks = new AccountWebhooksResource(client, accountId);\n this.companies = new AccountCompaniesResource(client, accountId);\n }\n\n private path() {\n return { account_id: this.accountId };\n }\n\n /**\n * Get the account summary.\n *\n * @returns The account summary.\n */\n async get() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}', { params: { path: this.path() } });\n return data!.data as ManagedAccountSummary;\n }\n\n /**\n * Provisioning usage counters for billing: provisioned accounts and NIFs.\n *\n * @returns `provisioned_accounts` and `nifs`.\n */\n async usage() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/usage', { params: { path: this.path() } });\n return data!.data as ProvisioningUsage;\n }\n\n /**\n * Change the access level you keep over this account. Raising it is only possible while\n * the account is unclaimed.\n *\n * @param body - The new `access_level`.\n */\n async changeAccessLevel(body: NonNullable<operations['changeManagedAccountAccessLevel']['requestBody']>['content']['application/json']) {\n await this.client.PATCH('/v1/accounts/{account_id}/access-level', {\n params: { path: this.path() },\n body,\n });\n }\n\n /**\n * End your management of this account: you lose access, and the holder keeps the\n * account, its NIFs and its invoices.\n */\n async endManagement() {\n await this.client.DELETE('/v1/accounts/{account_id}/management', { params: { path: this.path() } });\n }\n\n /**\n * Issue a single-use claim token so the account's holder can take ownership.\n *\n * @param body - `email` when the account has no holder yet; omit to re-issue.\n * @returns `claim_token`, `claim_url` and `expires_at`.\n */\n async createClaimToken(body?: NonNullable<operations['createAccountClaimToken']['requestBody']>['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/claim-tokens', {\n params: { path: this.path() },\n body: body ?? {},\n });\n return data!.data;\n }\n\n /**\n * Make an existing member the account's owner. Repeatable: it states the desired owner.\n *\n * @param body - The member that becomes owner.\n */\n async setOwner(body: operations['putAccountOwner']['requestBody']['content']['application/json']) {\n await this.client.PUT('/v1/accounts/{account_id}/owner', {\n params: { path: this.path() },\n body,\n });\n }\n}\n\n/**\n * Members of an account and their per-company grants. Reach it as\n * `beel.account(accountId).members`.\n */\nexport class AccountMembersResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the account's members.\n *\n * @returns The members (`data.members` of the response), as an array.\n */\n async list() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/members', {\n params: { path: { account_id: this.accountId } },\n });\n return (data!.data as { members: AccountMember[] }).members;\n }\n\n /**\n * Get one member.\n *\n * @param memberId - Member UUID.\n * @returns The member.\n */\n async get(memberId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/members/{member_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n });\n return data!.data as AccountMember;\n }\n\n /**\n * Change a member's account role.\n *\n * @param memberId - Member UUID.\n * @param body - The new `account_role`.\n * @returns The updated member.\n */\n async update(memberId: string, body: operations['patchAccountMember']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/accounts/{account_id}/members/{member_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n body,\n });\n return data!.data as AccountMember;\n }\n\n /**\n * Remove a member from the account.\n *\n * @param memberId - Member UUID.\n */\n async remove(memberId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/members/{member_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n });\n }\n\n /**\n * List a member's per-company grants.\n *\n * @param memberId - Member UUID.\n * @returns The `grants` and their `pagination`.\n */\n async listGrants(memberId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/members/{member_id}/grants', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n });\n return data!.data;\n }\n\n /**\n * Grant a member access to one company, or replace the grant it has.\n *\n * @param memberId - Member UUID.\n * @param companyId - Company UUID.\n * @param body - The `access_level` to grant.\n * @returns The grant.\n */\n async putGrant(\n memberId: string,\n companyId: string,\n body: operations['putAccountMemberGrant']['requestBody']['content']['application/json'],\n ) {\n const { data } = await this.client.PUT('/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Revoke a member's access to one company.\n *\n * @param memberId - Member UUID.\n * @param companyId - Company UUID.\n */\n async removeGrant(memberId: string, companyId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },\n });\n }\n}\n\n/** Invitations to join an account. Reach it as `beel.account(accountId).invitations`. */\nexport class AccountInvitationsResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the account's invitations.\n *\n * @returns The invitations.\n */\n async list() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/invitations', {\n params: { path: { account_id: this.accountId } },\n });\n return data!.data;\n }\n\n /**\n * Invite someone to join the account.\n *\n * @param body - `invited_email` and the `account_role` to grant.\n * @returns The invitation.\n */\n async create(body: operations['createAccountInvitation']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/invitations', {\n params: { path: { account_id: this.accountId } },\n body,\n });\n return data!.data as Invitation;\n }\n\n /**\n * Get one invitation.\n *\n * @param invitationId - Invitation UUID.\n * @returns The invitation.\n */\n async get(invitationId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/invitations/{invitation_id}', {\n params: { path: { account_id: this.accountId, invitation_id: invitationId } },\n });\n return data!.data;\n }\n\n /**\n * Revoke a `PENDING` invitation, so its link stops working.\n *\n * @param invitationId - Invitation UUID.\n */\n async revoke(invitationId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/invitations/{invitation_id}', {\n params: { path: { account_id: this.accountId, invitation_id: invitationId } },\n });\n }\n}\n\n/**\n * Webhook subscriptions of an account. Reach it as `beel.account(accountId).webhooks`;\n * verify deliveries with `WebhookVerifier`.\n */\nexport class AccountWebhooksResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the webhook subscriptions.\n *\n * @param params - Pagination.\n * @returns The `webhooks` and their `pagination`.\n */\n async list(params?: operations['listAccountWebhookSubscriptions']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/webhooks', {\n params: { path: { account_id: this.accountId }, query: params },\n });\n return data!.data as { webhooks?: WebhookSubscription[]; pagination?: Pagination };\n }\n\n /**\n * Subscribe an HTTPS endpoint to events.\n *\n * @param body - `url` and the `events` to receive.\n * @returns The subscription, with its signing secret.\n */\n async create(body: operations['createAccountWebhookSubscription']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks', {\n params: { path: { account_id: this.accountId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Get one webhook subscription.\n *\n * @param webhookId - Subscription UUID.\n * @returns The subscription.\n */\n async get(webhookId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/webhooks/{webhook_id}', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n return data!.data as WebhookSubscription;\n }\n\n /**\n * Update a webhook subscription. Only the fields present in `body` change.\n *\n * @param webhookId - Subscription UUID.\n * @param body - Fields to change.\n * @returns The updated subscription.\n */\n async update(webhookId: string, body: operations['patchAccountWebhookSubscription']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/accounts/{account_id}/webhooks/{webhook_id}', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n body,\n });\n return data!.data as WebhookSubscription;\n }\n\n /**\n * Delete a webhook subscription.\n *\n * @param webhookId - Subscription UUID.\n */\n async delete(webhookId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/webhooks/{webhook_id}', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n }\n\n /**\n * Send a test event to the endpoint. Test deliveries carry `test: true`.\n *\n * @param webhookId - Subscription UUID.\n * @returns The outcome of the delivery.\n */\n async test(webhookId: string) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks/{webhook_id}/test', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n return data!.data;\n }\n\n /**\n * Rotate the signing secret. The old secret stops working immediately.\n *\n * @param webhookId - Subscription UUID.\n * @returns The subscription with its new secret.\n */\n async rotateSecret(webhookId: string) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks/{webhook_id}/secret', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n return data!.data;\n }\n\n /**\n * List the delivery attempts of a subscription.\n *\n * @param webhookId - Subscription UUID.\n * @param params - Filters and pagination.\n * @returns The deliveries.\n */\n async listDeliveries(webhookId: string, params?: operations['listAccountWebhookDeliveries']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId }, query: params },\n });\n return data!.data;\n }\n\n /**\n * Retry a failed delivery.\n *\n * @param webhookId - Subscription UUID.\n * @param deliveryId - Delivery UUID.\n * @returns The new delivery attempt.\n */\n async retryDelivery(webhookId: string, deliveryId: string) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries/{delivery_id}/retry', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId, delivery_id: deliveryId } },\n });\n return data!.data;\n }\n}\n\n/**\n * Companies (NIFs) of an account — where the `companyId` of `beel.company(companyId)`\n * comes from. Reach it as `beel.account(accountId).companies`.\n */\nexport class AccountCompaniesResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the account's companies, primary first. Always paginated (20 by default).\n *\n * @param params - `search`, `include`, `page`, `limit`.\n * @returns The `companies` of the page and its `pagination`.\n *\n * @example\n * ```typescript\n * const { account_id } = await beel.catalogs.identity();\n * const { companies } = await beel.account(account_id).companies.list({ search: 'B12345678' });\n * const company = beel.company(companies[0].id!);\n * ```\n */\n async list(params?: operations['listCompanies']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/companies', {\n params: { path: { account_id: this.accountId }, query: params },\n });\n // The collection is wrapped: `data.companies` + `data.pagination`, not a bare array.\n return {\n companies: (data!.data?.companies ?? []) as CompanyData[],\n pagination: data!.data?.pagination as Pagination | undefined,\n };\n }\n\n /**\n * Register a new company (NIF) under the account.\n *\n * @param body - NIF, legal name, entity type and address.\n * @returns The created company.\n */\n async create(body: components['schemas']['CreateCompanyRequest']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/companies', {\n params: { path: { account_id: this.accountId } },\n body,\n });\n return data!.data as CompanyData;\n }\n\n /**\n * Per-company invoice stats: how many fiscal documents each issued, and when last.\n *\n * @returns One entry per company.\n */\n async stats() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/companies/stats', {\n params: { path: { account_id: this.accountId } },\n });\n return data!.data;\n }\n}\n","import { IDEMPOTENCY_KEY_HEADER } from './headers';\n\n/**\n * Per-call options, accepted as the last argument of the `company.invoices` methods.\n *\n * @example\n * ```typescript\n * await company.invoices.create(body, undefined, {\n * idempotencyKey: `order-${order.id}`,\n * timeoutMs: 15_000,\n * });\n * ```\n */\nexport interface RequestOptions {\n /**\n * `Idempotency-Key` of this call, instead of the automatic one: letters, digits, `_` and\n * `-`, up to 255 characters. Every automatic retry of the call reuses it. Persist it with\n * your order to retry the same operation later: within 24 hours the API replays the first\n * `2xx` or `5xx` answer instead of running the operation again.\n */\n idempotencyKey?: string;\n /** Aborts the call — the automatic retries and the waits between them included. */\n signal?: AbortSignal;\n /** Aborts the call after this many milliseconds, automatic retries included. */\n timeoutMs?: number;\n}\n\n/** The part of openapi-fetch's per-request init that {@link RequestOptions} maps to. */\nexport interface RequestInitOverrides {\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\ntype AbortSignalWithAny = typeof AbortSignal & { any?: (signals: AbortSignal[]) => AbortSignal };\n\n/** An `AbortSignal` that aborts as soon as any of `signals` does. */\nexport function anySignal(signals: AbortSignal[]): AbortSignal {\n const native = (AbortSignal as AbortSignalWithAny).any;\n if (native) return native(signals);\n\n const controller = new AbortController();\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n break;\n }\n signal.addEventListener('abort', () => controller.abort(signal.reason), { once: true });\n }\n return controller.signal;\n}\n\nfunction signalOf(options: RequestOptions): AbortSignal | undefined {\n const signals: AbortSignal[] = [];\n if (options.signal) signals.push(options.signal);\n if (options.timeoutMs !== undefined) signals.push(AbortSignal.timeout(options.timeoutMs));\n if (signals.length <= 1) return signals[0];\n return anySignal(signals);\n}\n\n/**\n * Maps {@link RequestOptions} to the `headers` and `signal` of one openapi-fetch call.\n * Returns an empty object when there are no options, so it can always be spread.\n */\nexport function toRequestInit(options?: RequestOptions): RequestInitOverrides {\n if (!options) return {};\n const init: RequestInitOverrides = {};\n if (options.idempotencyKey !== undefined) {\n init.headers = { [IDEMPOTENCY_KEY_HEADER]: options.idempotencyKey };\n }\n const signal = signalOf(options);\n if (signal) init.signal = signal;\n return init;\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype ManagedPaymentConnection = components['schemas']['ManagedPaymentConnection'];\ntype CompanyPaymentConnection = components['schemas']['CompanyPaymentConnection'];\ntype ManagedPaymentEvent = components['schemas']['ManagedPaymentEvent'];\ntype Pagination = components['schemas']['Pagination'];\ntype PaymentEventCounts = components['schemas']['PaymentEventCounts'];\n\n/**\n * Payment connections of a company (NIF): the Stripe Connect link whose charges\n * auto-generate invoices under that NIF.\n *\n * A connection is addressed by **its own UUID**, not by the provider slug — a NIF can\n * hold several connections of the same provider, so the slug does not name one. Take\n * `id` from {@link list}. The slug only appears when you *start* an authorization.\n *\n * @example\n * ```typescript\n * const company = beel.company('company-uuid');\n * const { connections } = await company.paymentConnections.list();\n * const events = await company.paymentConnections.events(connections[0].id).list({\n * needs_action: true,\n * });\n * ```\n */\nexport class CompanyPaymentConnectionsResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n private path() {\n return { company_id: this.companyId };\n }\n\n /**\n * Every payment connection of this company.\n *\n * @returns The `connections`.\n */\n async list() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/payment-connections', {\n params: { path: this.path() },\n });\n return data!.data as { connections: ManagedPaymentConnection[] };\n }\n\n /**\n * Start an authorization and get the URL where the NIF's holder approves it.\n *\n * This is the one place the provider slug is used — currently only `stripe`.\n *\n * @param body - `{ provider: 'stripe' }`, plus the return URL when needed.\n * @returns The `authorization_url` to send the NIF's holder to.\n */\n async authorize(\n body: components['schemas']['InitiatePaymentConnectionRequest'],\n ): Promise<{ authorization_url: string }> {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/authorizations',\n { params: { path: this.path() }, body },\n );\n return data!.data as { authorization_url: string };\n }\n\n /**\n * Update the settings of one connection, addressed by its UUID.\n *\n * @param connectionId - Connection UUID, from {@link list}.\n * @param body - Settings to change.\n * @returns The updated connection.\n */\n async update(\n connectionId: string,\n body: components['schemas']['UpdateCompanyPaymentConnectionRequest'],\n ) {\n const { data } = await this.client.PATCH(\n '/v1/companies/{company_id}/payment-connections/{connection_id}',\n { params: { path: { ...this.path(), connection_id: connectionId } }, body },\n );\n return data!.data as CompanyPaymentConnection;\n }\n\n /**\n * Disconnect one connection. Tokens are revoked and auto-invoicing stops;\n * already-issued invoices are untouched.\n *\n * @param connectionId - Connection UUID.\n */\n async disconnect(connectionId: string): Promise<void> {\n await this.client.DELETE('/v1/companies/{company_id}/payment-connections/{connection_id}', {\n params: { path: { ...this.path(), connection_id: connectionId } },\n });\n }\n\n /**\n * The payment events of one connection — where you audit what did and didn't invoice.\n *\n * @param connectionId - Connection UUID.\n * @returns The events resource of that connection. No request is made.\n */\n events(connectionId: string) {\n return new CompanyPaymentEventsResource(this.client, this.companyId, connectionId);\n }\n}\n\n/**\n * Payment events received through a connection, and the recovery levers for the ones\n * that did not produce an invoice. Reach it as\n * `beel.company(companyId).paymentConnections.events(connectionId)`.\n */\nexport class CompanyPaymentEventsResource {\n constructor(\n private client: BeeLClient,\n private companyId: string,\n private connectionId: string,\n ) {}\n\n private path() {\n return { company_id: this.companyId, connection_id: this.connectionId };\n }\n\n /**\n * Events of the connection, most recent first. Nothing is hidden by default:\n * skipped events, duplicates and disputes are all returned — narrow with the\n * filters. `charges_only` returns one row per money movement instead.\n *\n * @param params - Filters (`needs_action`, `charges_only`…) and pagination.\n * @returns The `events`, their `pagination` and `counts`.\n */\n async list(params?: operations['listCompanyPaymentEvents']['parameters']['query']) {\n const { data } = await this.client.GET(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events',\n { params: { path: this.path(), query: params } },\n );\n return data!.data as {\n events: ManagedPaymentEvent[];\n pagination?: Pagination;\n counts?: PaymentEventCounts;\n };\n }\n\n /**\n * Get one event.\n *\n * @param eventId - Event UUID.\n * @returns The event.\n */\n async get(eventId: string) {\n const { data } = await this.client.GET(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Reprocess an event whose automatic invoicing didn't complete, applying the NIF's\n * **current** configuration. Only retryable states qualify and the retry budget is\n * finite: otherwise `400`.\n *\n * @param eventId - Event UUID.\n * @returns The event after the retry.\n */\n async retry(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/retry',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Build a **draft** invoice from an event that couldn't be invoiced automatically,\n * so you can review it before issuing.\n *\n * @param eventId - Event UUID.\n * @returns The draft's `invoice_id`.\n */\n async draft(eventId: string): Promise<{ invoice_id: string }> {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/draft',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as { invoice_id: string };\n }\n\n /**\n * Mark an event as dealt with outside the automatic flow.\n *\n * @param eventId - Event UUID.\n * @returns The resolved event.\n */\n async resolve(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/resolve',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Discard an event so it stops asking for attention. Reversible with {@link restore}.\n *\n * @param eventId - Event UUID.\n * @returns The discarded event.\n */\n async discard(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/discard',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Bring a discarded event back into the list.\n *\n * @param eventId - Event UUID.\n * @returns The restored event.\n */\n async restore(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/restore',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n}\n","import type { components, operations } from '../generated/schema';\nimport { BeeLApiError, BeeLConflictError } from '../core/errors';\nimport { BeeLErrorCodes } from '../core/error-codes';\nimport { isServerErrorStatus } from '../core/http-status';\n\ntype Invoice = components['schemas']['Invoice'];\ntype CreateInvoiceRequest = components['schemas']['CreateInvoiceRequest'];\ntype InvoiceType = components['schemas']['InvoiceType'];\n\n/**\n * Invoice types whose `external_ref` the API keeps unique: at most one live (not deleted)\n * invoice of these types per reference and environment, whatever its status — a `VOIDED`\n * one included. Correctives are exempt, and proformas are not covered.\n */\nexport const EXTERNAL_REF_UNIQUE_INVOICE_TYPES = ['STANDARD', 'SIMPLIFIED'] as const satisfies readonly InvoiceType[];\n\n/** Invoice types {@link createInvoiceOnce} accepts. */\nexport type ExternalRefUniqueInvoiceType = (typeof EXTERNAL_REF_UNIQUE_INVOICE_TYPES)[number];\n\n/**\n * Body of `invoices.createOnce`: a `CreateInvoiceRequest` whose `type` is `STANDARD` or\n * `SIMPLIFIED` and whose `external_ref` is required — it is what makes the call safe to repeat.\n */\nexport type CreateInvoiceOnceRequest = Omit<CreateInvoiceRequest, 'type' | 'external_ref'> & {\n type: ExternalRefUniqueInvoiceType;\n external_ref: string;\n};\n\n/** Query of `invoices.createOnce`: the same as `invoices.create`. */\nexport type CreateInvoiceOnceParams = operations['createCompanyInvoice']['parameters']['query'];\n\n/** The two calls {@link createInvoiceOnce} is built on, bound to one company. */\nexport interface CreateInvoiceOnceOperations {\n /** Invoices of the company whose `external_ref` equals `externalRef` exactly. */\n listByExternalRef(externalRef: string): Promise<Invoice[]>;\n /** Creates the invoice, with the client's automatic `Idempotency-Key` and retries. */\n create(body: CreateInvoiceRequest, params?: CreateInvoiceOnceParams): Promise<Invoice>;\n}\n\n/** Thrown before any request when the body has no usable `external_ref`. */\nexport const MISSING_EXTERNAL_REF_MESSAGE =\n 'invoices.createOnce requires a non-empty `external_ref`: it is the key that makes the call safe to repeat.';\n\n/** Thrown before any request when the body asks for a type the uniqueness does not cover. */\nexport const UNSUPPORTED_TYPE_MESSAGE =\n 'invoices.createOnce only creates STANDARD or SIMPLIFIED invoices: the API keeps `external_ref` unique for those types only.';\n\nfunction holdsTheReference(invoice: Invoice): boolean {\n return (EXTERNAL_REF_UNIQUE_INVOICE_TYPES as readonly InvoiceType[]).includes(invoice.type);\n}\n\n/** The live invoice that holds `externalRef`, or `undefined` when there is none. */\nasync function findHolder(operations: CreateInvoiceOnceOperations, externalRef: string) {\n const invoices = await operations.listByExternalRef(externalRef);\n return invoices.find(holdsTheReference);\n}\n\n/** A `409 INVOICE_DUPLICATE_EXTERNAL_REFERENCE`: another call already created the invoice. */\nfunction isDuplicateReference(error: unknown): boolean {\n return (\n error instanceof BeeLConflictError &&\n error.apiCode === BeeLErrorCodes.INVOICE_DUPLICATE_EXTERNAL_REFERENCE\n );\n}\n\n/**\n * Whether the create may have taken effect although it did not answer 2xx: a network error,\n * a `5xx`, or a `409 IDEMPOTENCY_KEY_PROCESSING` still pending after the automatic retries.\n */\nfunction isUnknownOutcome(error: unknown): boolean {\n if (!(error instanceof BeeLApiError)) return true;\n if (isServerErrorStatus(error.statusCode)) return true;\n return error instanceof BeeLConflictError && error.apiCode === BeeLErrorCodes.IDEMPOTENCY_KEY_PROCESSING;\n}\n\n/**\n * Creates the invoice for `body.external_ref` unless it already exists, and returns the one\n * invoice that holds that reference:\n *\n * 1. Looks the reference up; if a standard or simplified invoice holds it, returns that one.\n * 2. Otherwise creates it (with the client's `Idempotency-Key`, reused by its retries).\n * 3. On `409 INVOICE_DUPLICATE_EXTERNAL_REFERENCE` (a concurrent call won), or when the\n * outcome is unknown (network error, `5xx`), looks the reference up again and returns the\n * invoice if it exists. If it does not, the original error is thrown: nothing was\n * created, and calling again is safe.\n *\n * The API's unique index on `external_ref` is what guarantees a single invoice; this\n * function turns that guarantee into \"return the existing one\" instead of an error.\n */\nexport async function createInvoiceOnce(\n operations: CreateInvoiceOnceOperations,\n body: CreateInvoiceOnceRequest,\n params?: CreateInvoiceOnceParams,\n): Promise<Invoice> {\n if (typeof body.external_ref !== 'string' || body.external_ref.trim() === '') {\n throw new TypeError(MISSING_EXTERNAL_REF_MESSAGE);\n }\n if (!(EXTERNAL_REF_UNIQUE_INVOICE_TYPES as readonly string[]).includes(body.type)) {\n throw new TypeError(UNSUPPORTED_TYPE_MESSAGE);\n }\n\n const existing = await findHolder(operations, body.external_ref);\n if (existing) return existing;\n\n try {\n return await operations.create(body, params);\n } catch (error) {\n if (!isDuplicateReference(error) && !isUnknownOutcome(error)) throw error;\n const holder = await findHolder(operations, body.external_ref).catch(() => undefined);\n if (holder) return holder;\n throw error;\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\nimport { toRequestInit, type RequestOptions } from '../http/request-options';\nimport { CompanyPaymentConnectionsResource } from './payment-connections';\nimport {\n createInvoiceOnce,\n type CreateInvoiceOnceParams,\n type CreateInvoiceOnceRequest,\n} from './invoice-create-once';\n\ntype Invoice = components['schemas']['Invoice'];\ntype Customer = components['schemas']['Customer'];\ntype Product = components['schemas']['Product'];\ntype CompanyData = components['schemas']['CompanyData'];\ntype Pagination = components['schemas']['Pagination'];\n\n/**\n * Operations scoped to a single company (NIF). This is the explicit multi-NIF surface:\n * the company is addressed in the path, so no session focus or `BeeL-Active-Company`\n * header is needed. Get one with `beel.company(companyId)`; list the ids with\n * `beel.account(accountId).companies.list()`.\n *\n * Every method rejects with a `BeeLApiError` subclass when the API answers non-2xx.\n *\n * @example\n * ```typescript\n * const company = beel.company('company-uuid');\n * const invoice = await company.invoices.create({ ... });\n * await company.invoices.issue(invoice.id);\n * ```\n */\nexport class CompanyScope {\n /** Invoices of this company: create, issue, void, correct, list, PDF, email. */\n readonly invoices: CompanyInvoicesResource;\n /** Customers of this company. */\n readonly customers: CompanyCustomersResource;\n /** Products and services of this company. */\n readonly products: CompanyProductsResource;\n /** Invoice series (numbering) of this company. */\n readonly series: CompanySeriesResource;\n /** Recurring invoice templates of this company. */\n readonly recurringInvoices: CompanyRecurringInvoicesResource;\n /** Payment provider connections (Stripe) that auto-generate invoices under this NIF. */\n readonly paymentConnections: CompanyPaymentConnectionsResource;\n /** Default taxes of this company. */\n readonly taxConfiguration: CompanyTaxConfigurationResource;\n /** Whether this NIF submits its invoices to AEAT under VeriFactu. */\n readonly verifactuConfiguration: CompanyVeriFactuConfigurationResource;\n\n constructor(private client: BeeLClient, readonly companyId: string) {\n this.invoices = new CompanyInvoicesResource(client, companyId);\n this.customers = new CompanyCustomersResource(client, companyId);\n this.products = new CompanyProductsResource(client, companyId);\n this.series = new CompanySeriesResource(client, companyId);\n this.recurringInvoices = new CompanyRecurringInvoicesResource(client, companyId);\n this.paymentConnections = new CompanyPaymentConnectionsResource(client, companyId);\n this.taxConfiguration = new CompanyTaxConfigurationResource(client, companyId);\n this.verifactuConfiguration = new CompanyVeriFactuConfigurationResource(client, companyId);\n }\n\n private path() {\n return { company_id: this.companyId };\n }\n\n /**\n * Get the company: its fiscal identity, address and settings.\n *\n * @param params - Optional query of `getCompanyById` (e.g. `include`).\n * @returns The company.\n */\n async get(params?: operations['getCompanyById']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}', {\n params: { path: this.path(), query: params },\n });\n return data!.data as CompanyData;\n }\n\n /**\n * Update the company's data. Only the fields present in `body` change.\n *\n * @param body - Fields to change.\n * @returns The updated company.\n */\n async update(body: components['schemas']['UpdateCompanyRequest']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}', {\n params: { path: this.path() },\n body,\n });\n return data!.data as CompanyData;\n }\n\n /**\n * Remove the company from its account. Blocked for the primary NIF, a NIF active in Live,\n * or one holding Live invoices.\n */\n async delete() {\n await this.client.DELETE('/v1/companies/{company_id}', { params: { path: this.path() } });\n }\n\n /**\n * Fiscal summary of the company for a period: taxable base, VAT and IRPF aggregates.\n *\n * @param params - `start_date` and `end_date` (both or neither; default: the current month).\n * @returns The aggregates of the period.\n */\n async fiscalSummary(params?: operations['getCompanyFiscalSummary']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/fiscal-summary', {\n params: { path: this.path(), query: params },\n });\n return data!.data as components['schemas']['FiscalSummaryResponse'];\n }\n\n /**\n * Whether the company can issue invoices now, and what blocks it if not.\n *\n * @returns `ready` plus the list of `blockers`.\n */\n async issuingReadiness() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/issuing-readiness', {\n params: { path: this.path() },\n });\n return data!.data as components['schemas']['IssuingReadinessData'];\n }\n}\n\n/**\n * Invoice lifecycle of one company: create a draft (or issue it directly), issue, void,\n * correct, list and read, PDF and email. Reach it as `beel.company(companyId).invoices`.\n *\n * A create, issue, void or corrective carries an automatic `Idempotency-Key`, reused by the\n * client's automatic retries. To retry a create yourself safely, use {@link createOnce}.\n */\nexport class CompanyInvoicesResource {\n /** Scheduled issuing of one invoice: read, set or clear it. */\n readonly schedule: CompanyInvoiceScheduleResource;\n\n constructor(private client: BeeLClient, private companyId: string) {\n this.schedule = new CompanyInvoiceScheduleResource(client, companyId);\n }\n\n /**\n * Derive a new draft invoice from an existing one — the canonical form of `duplicate`.\n * The source invoice is not modified.\n *\n * @param body - `from_invoice_id`, and optionally the `series_id` of the copy.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The new draft invoice.\n */\n async derive(body: components['schemas']['CreateInvoiceDerivationRequest'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/derivations', {\n ...toRequestInit(options),\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data as Invoice;\n }\n\n private path(): { company_id: string };\n private path<T extends Record<string, string>>(rest: T): { company_id: string } & T;\n private path(rest?: Record<string, string>) {\n return { company_id: this.companyId, ...rest };\n }\n\n /**\n * List the company's invoices, paginated, with filters: status, type, customer, dates,\n * `external_ref` (exact match), VeriFactu status and more.\n *\n * @param params - Filters and pagination (`page`, `limit`).\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The page of `invoices` and its `pagination`.\n *\n * @example\n * ```typescript\n * const { invoices } = await company.invoices.list({ external_ref: 'ORD-2026-0042' });\n * ```\n */\n async list(params?: operations['listCompanyInvoices']['parameters']['query'], options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices', {\n ...toRequestInit(options),\n params: { path: this.path(), query: params },\n });\n return data!.data as { invoices: Invoice[]; pagination: Pagination };\n }\n\n /**\n * Create an invoice: a `DRAFT` by default, or numbered and issued in the same call with\n * `options.issue_directly: true`. `CORRECTIVE` is not accepted here: use\n * {@link createCorrective}.\n *\n * One call sends one `Idempotency-Key`, reused by the client's automatic retries, so\n * those never duplicate the invoice. A second call is a new operation: to repeat a create\n * whose outcome you do not know, use {@link createOnce}.\n *\n * @param body - Type, recipient and lines; `external_ref` to tie it to your order.\n * @param params - `wait_for_pdf`, when issuing directly.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The created invoice. With VeriFactu, `verifactu.submission_status` starts `PENDING`.\n *\n * @example\n * ```typescript\n * const invoice = await company.invoices.create({\n * type: 'STANDARD',\n * recipient: { customer_id: 'customer-uuid' },\n * lines: [{\n * description: 'Consulting', quantity: 1, unit_price: 100,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' },\n * }],\n * external_ref: 'ORD-2026-0042',\n * });\n * ```\n */\n async create(\n body: components['schemas']['CreateInvoiceRequest'],\n params?: operations['createCompanyInvoice']['parameters']['query'],\n options?: RequestOptions,\n ) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices', {\n ...toRequestInit(options),\n params: { path: this.path(), query: params },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Create a standard or simplified invoice once per `external_ref`, safe to call again\n * after any failure. It looks the reference up first and returns the invoice that already\n * holds it; otherwise it creates one. If the create answers\n * `409 INVOICE_DUPLICATE_EXTERNAL_REFERENCE`, or its outcome is unknown (network error,\n * `5xx`), it looks the reference up again and returns the invoice it finds.\n *\n * The returned invoice may be one created earlier, in any status (`VOIDED` included):\n * compare its fields if that matters to you.\n *\n * @param body - A `CreateInvoiceRequest` with `type` `STANDARD` or `SIMPLIFIED` and a\n * non-empty `external_ref`.\n * @param params - `wait_for_pdf`, when issuing directly.\n * @param options - `idempotencyKey` for the create; `signal` and `timeoutMs` for the whole\n * sequence of calls.\n * @returns The one invoice that holds `body.external_ref`.\n * @throws {TypeError} Before any request, when `external_ref` is empty or `type` is not\n * `STANDARD`/`SIMPLIFIED`.\n * @throws {BeeLApiError} The create's error when no invoice holds the reference\n * afterwards — nothing was created, so calling again is safe.\n *\n * @example\n * ```typescript\n * const invoice = await company.invoices.createOnce({\n * type: 'STANDARD',\n * external_ref: order.id,\n * recipient: { customer_id: order.customerId },\n * lines: [{ description: 'Order', quantity: 1, unit_price: 100,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' } }],\n * options: { issue_directly: true },\n * });\n * ```\n */\n async createOnce(\n body: CreateInvoiceOnceRequest,\n params?: CreateInvoiceOnceParams,\n options?: RequestOptions,\n ) {\n // One signal for the whole sequence, so `timeoutMs` bounds lookup + create + lookup.\n const { signal } = toRequestInit({ signal: options?.signal, timeoutMs: options?.timeoutMs });\n return createInvoiceOnce(\n {\n listByExternalRef: async (externalRef) =>\n (await this.list({ external_ref: externalRef }, { signal })).invoices,\n create: (request, query) =>\n this.create(request, query, { signal, idempotencyKey: options?.idempotencyKey }),\n },\n body,\n params,\n );\n }\n\n /**\n * Get one invoice, including its `status` and its `verifactu` block\n * (`submission_status`, `qr_url`, `error_code`…).\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The invoice.\n */\n async get(invoiceId: string, options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices/{invoice_id}', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n return data!.data as Invoice;\n }\n\n /**\n * Update a `DRAFT` or `SCHEDULED` invoice (or an `ACTIVE` proforma). Only the fields\n * present in `body` change; an issued invoice is amended with a corrective instead.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - Fields to change.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The updated invoice.\n */\n async update(invoiceId: string, body: operations['patchCompanyInvoice']['requestBody']['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/invoices/{invoice_id}', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Delete a draft invoice. Deleting frees its `external_ref` for a new invoice.\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n */\n async delete(invoiceId: string, options?: RequestOptions) {\n await this.client.DELETE('/v1/companies/{company_id}/invoices/{invoice_id}', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n }\n\n /**\n * Issue a draft: assigns its definitive number and makes it immutable. PDF generation and\n * the VeriFactu submission happen after the response.\n *\n * @param invoiceId - UUID of the draft.\n * @param params - `wait_for_pdf: true` to wait for the PDF before answering.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The issued invoice.\n */\n async issue(invoiceId: string, params?: operations['issueCompanyInvoice']['parameters']['query'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/issue', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }), query: params },\n });\n return data!.data as Invoice;\n }\n\n /**\n * Void an invoice issued by mistake. The document is kept and its number never reused. If\n * the operation did happen but the invoice is wrong, use {@link createCorrective}.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - `reason`; `issued_in_error: true` is required once it was sent or paid.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The voided invoice.\n */\n async void(invoiceId: string, body: NonNullable<operations['voidCompanyInvoice']['requestBody']>['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/void', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Create a corrective invoice (rectificativa) for an issued invoice.\n *\n * @param invoiceId - UUID of the issued invoice to correct.\n * @param body - `rectification_type` (`TOTAL`/`PARTIAL`), `rectification_code` (`R1`–`R5`),\n * `reason` and, for `PARTIAL`, the correcting `lines`.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The corrective invoice.\n *\n * @example\n * ```typescript\n * const corrective = await company.invoices.createCorrective('invoice-uuid', {\n * rectification_type: 'PARTIAL',\n * rectification_code: 'R1',\n * reason: 'Discount agreed with the customer after the sale',\n * lines: [{ description: 'Discount', quantity: -1, unit_price: 10,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' } }],\n * });\n * ```\n */\n async createCorrective(\n invoiceId: string,\n body: operations['createCompanyCorrectiveInvoice']['requestBody']['content']['application/json'],\n options?: RequestOptions,\n ) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/corrective', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Convert a proforma into an invoice.\n *\n * @param invoiceId - UUID of the proforma.\n * @param body - Optional overrides for the new invoice.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The new invoice.\n */\n async convertToInvoice(\n invoiceId: string,\n body?: NonNullable<operations['convertCompanyProformaToInvoice']['requestBody']>['content']['application/json'],\n options?: RequestOptions,\n ) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/convert-to-invoice', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Issue a full invoice in exchange for one or more issued simplified invoices, when the\n * customer asks for an invoice with their details. It is not a corrective: the simplified\n * invoices become `VOIDED` with `void_cause: 'EXCHANGED'`, and the new `STANDARD` invoice\n * lists them in `replaced_invoice_ids`.\n *\n * @param body - `simplified_invoice_ids` and the identified `recipient`.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The new standard invoice.\n *\n * @example\n * ```typescript\n * const invoice = await company.invoices.createSimplifiedExchange({\n * simplified_invoice_ids: ['simplified-uuid'],\n * recipient: { customer_id: 'customer-uuid' },\n * });\n * ```\n */\n async createSimplifiedExchange(body: components['schemas']['CreateSimplifiedExchangeRequest'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/simplified-exchanges', {\n ...toRequestInit(options),\n params: { path: this.path() },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * The VeriFactu records of an invoice, oldest first: its registration and, if it was\n * voided, its cancellation. An invoice never submitted answers with an empty list.\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The records (`data.records` of the response), each with its own `submission_status`.\n */\n async verifactuRecords(invoiceId: string, options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices/{invoice_id}/verifactu-records', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n return data!.data!.records as components['schemas']['VeriFactuRecord'][];\n }\n\n /**\n * Set the commercial status: `PAID` (from `ISSUED`, `SENT`, `OVERDUE`), `SENT` (from\n * `ISSUED`) or back to `ISSUED` (from `SENT`). Issuing and voiding have their own methods.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - Target `status` and, for `PAID`, the payment details.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The updated invoice.\n */\n async setStatus(invoiceId: string, body: operations['setCompanyInvoiceStatus']['requestBody']['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/invoices/{invoice_id}/status', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Get a short-lived download URL for the invoice PDF.\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns `download_url`, `expires_in_seconds` and `file_name`.\n */\n async getPdf(invoiceId: string, options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices/{invoice_id}/pdf', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Send the invoice by email with its PDF. Without recipients, the customer's addresses are used.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - Optional recipients, subject and message.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The delivery record.\n */\n async send(invoiceId: string, body: NonNullable<operations['sendCompanyInvoice']['requestBody']>['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/send', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data;\n }\n}\n\n/**\n * Scheduled issuing of one invoice: read it, set it, clear it. Reach it as\n * `beel.company(companyId).invoices.schedule`.\n */\nexport class CompanyInvoiceScheduleResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * Get the schedule of an invoice.\n *\n * @param invoiceId - Invoice UUID.\n * @returns `scheduled_for` and `generation_mode`.\n */\n async get(invoiceId: string) {\n const { data } = await this.client.GET(\n '/v1/companies/{company_id}/invoices/{invoice_id}/schedule',\n { params: { path: { company_id: this.companyId, invoice_id: invoiceId } } },\n );\n return data!.data;\n }\n\n /**\n * Set or move the schedule. One `PUT` replaces the three legacy calls\n * (`schedule`, `reschedule`, `unschedule`): setting it again moves it.\n *\n * @param invoiceId - UUID of a draft invoice.\n * @param body - `scheduled_for` date and what to do then.\n * @returns The scheduled invoice.\n */\n async set(invoiceId: string, body: components['schemas']['SetInvoiceScheduleRequest']) {\n const { data } = await this.client.PUT(\n '/v1/companies/{company_id}/invoices/{invoice_id}/schedule',\n { params: { path: { company_id: this.companyId, invoice_id: invoiceId } }, body },\n );\n return data!.data;\n }\n\n /**\n * Clear the schedule, returning the invoice to a plain draft — the canonical form of\n * `unschedule`. Idempotent.\n *\n * @param invoiceId - Invoice UUID.\n */\n async clear(invoiceId: string): Promise<void> {\n await this.client.DELETE('/v1/companies/{company_id}/invoices/{invoice_id}/schedule', {\n params: { path: { company_id: this.companyId, invoice_id: invoiceId } },\n });\n }\n}\n\n/** Customers of one company. Reach it as `beel.company(companyId).customers`. */\nexport class CompanyCustomersResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * List the company's customers, paginated and searchable.\n *\n * @param params - Filters and pagination.\n * @returns The page of `customers` and its `pagination`.\n */\n async list(params?: operations['listCompanyCustomers']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/customers', {\n params: { path: { company_id: this.companyId }, query: params },\n });\n return data!.data as { customers: Customer[]; pagination: Pagination };\n }\n\n /**\n * Create a customer.\n *\n * @param body - Legal name, NIF (or alternative id) and address.\n * @returns The created customer.\n */\n async create(body: components['schemas']['CreateCustomerRequest']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/customers', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data as Customer;\n }\n\n /**\n * Create several customers in one call.\n *\n * @param body - The customers, and whether it is a dry run.\n * @returns Per-customer results and totals.\n */\n async createBulk(body: operations['createCompanyCustomersBulk']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/customers/bulk', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Get one customer.\n *\n * @param customerId - Customer UUID.\n * @returns The customer.\n */\n async get(customerId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/customers/{customer_id}', {\n params: { path: { company_id: this.companyId, customer_id: customerId } },\n });\n return data!.data as Customer;\n }\n\n /**\n * Update a customer. Only the fields present in `body` change.\n *\n * @param customerId - Customer UUID.\n * @param body - Fields to change.\n * @returns The updated customer.\n */\n async update(customerId: string, body: operations['patchCompanyCustomer']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/customers/{customer_id}', {\n params: { path: { company_id: this.companyId, customer_id: customerId } },\n body,\n });\n return data!.data as Customer;\n }\n\n /**\n * Delete a customer that has no invoices. Its NIF (or alternative id) is released for a\n * new customer.\n *\n * @param customerId - Customer UUID.\n */\n async delete(customerId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/customers/{customer_id}', {\n params: { path: { company_id: this.companyId, customer_id: customerId } },\n });\n }\n}\n\n/** Products and services of one company. Reach it as `beel.company(companyId).products`. */\nexport class CompanyProductsResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * List the company's products, paginated and searchable.\n *\n * @param params - Filters and pagination.\n * @returns The page of `products` and its `pagination`.\n */\n async list(params?: operations['listCompanyProducts']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/products', {\n params: { path: { company_id: this.companyId }, query: params },\n });\n return data!.data as { products: Product[]; pagination: Pagination };\n }\n\n /**\n * Create a product or service.\n *\n * @param body - Name, category, price and main tax.\n * @returns The created product.\n */\n async create(body: components['schemas']['CreateProductRequest']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/products', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data as Product;\n }\n\n /**\n * Get one product.\n *\n * @param productId - Product UUID.\n * @returns The product.\n */\n async get(productId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/products/{product_id}', {\n params: { path: { company_id: this.companyId, product_id: productId } },\n });\n return data!.data as Product;\n }\n\n /**\n * Update a product. Only the fields present in `body` change.\n *\n * @param productId - Product UUID.\n * @param body - Fields to change.\n * @returns The updated product.\n */\n async update(productId: string, body: operations['patchCompanyProduct']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/products/{product_id}', {\n params: { path: { company_id: this.companyId, product_id: productId } },\n body,\n });\n return data!.data as Product;\n }\n\n /**\n * Delete a product from the catalog. Existing invoice lines are unaffected.\n *\n * @param productId - Product UUID.\n */\n async delete(productId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/products/{product_id}', {\n params: { path: { company_id: this.companyId, product_id: productId } },\n });\n }\n}\n\n/**\n * Invoice series (numbering) of one company. Each series numbers one `document_type`.\n * Reach it as `beel.company(companyId).series`.\n */\nexport class CompanySeriesResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * List the company's series.\n *\n * @param params - Filters; `page`/`limit` to paginate.\n * @returns The `series`, and `pagination` when you paginated.\n */\n async list(params?: operations['listCompanySeries']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/series', {\n params: { path: { company_id: this.companyId }, query: params },\n });\n return data!.data;\n }\n\n /**\n * Create a series.\n *\n * @param body - Code, name, format and the `document_type` it numbers.\n * @returns The created series.\n */\n async create(body: operations['createCompanySeries']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/series', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Update a series. Only the fields present in `body` change.\n *\n * @param seriesId - Series UUID.\n * @param body - Fields to change.\n * @returns The updated series.\n */\n async update(seriesId: string, body: operations['patchCompanySeries']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/series/{series_id}', {\n params: { path: { company_id: this.companyId, series_id: seriesId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Delete (soft-delete) a series. Its code stays taken, since issued invoices carry it.\n *\n * @param seriesId - Series UUID.\n */\n async delete(seriesId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/series/{series_id}', {\n params: { path: { company_id: this.companyId, series_id: seriesId } },\n });\n }\n\n /**\n * The current default series per document type.\n *\n * @returns One entry per document type, saying whether a default exists.\n */\n async getDefaults() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/series/defaults', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Ensure a default series exists per document type, creating the missing ones.\n * Idempotent.\n *\n * @returns The default series.\n */\n async ensureDefaults() {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/series/defaults', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Mark a series as the default for its document type.\n *\n * @param seriesId - Series UUID.\n * @returns The series.\n */\n async setDefault(seriesId: string) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/series/{series_id}/default', {\n params: { path: { company_id: this.companyId, series_id: seriesId } },\n });\n return data!.data;\n }\n}\n\n/**\n * Recurring invoice templates of one company. Reach it as\n * `beel.company(companyId).recurringInvoices`.\n */\nexport class CompanyRecurringInvoicesResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n private path(): { company_id: string };\n private path<T extends Record<string, string>>(rest: T): { company_id: string } & T;\n private path(rest?: Record<string, string>) {\n return { company_id: this.companyId, ...rest };\n }\n\n /**\n * List the recurring invoices.\n *\n * @param params - Filters and pagination.\n * @returns The page of `recurring_invoices` and its `pagination`.\n */\n async list(params?: operations['listCompanyRecurringInvoices']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices', {\n params: { path: this.path(), query: params },\n });\n return data!.data;\n }\n\n /**\n * Create a recurring invoice template.\n *\n * @param body - Frequency, schedule, recipient and lines.\n * @returns The recurring invoice.\n */\n async create(body: operations['createCompanyRecurringInvoice']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/recurring-invoices', {\n params: { path: this.path() },\n body,\n });\n return data!.data;\n }\n\n /**\n * Get one recurring invoice.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The recurring invoice.\n */\n async get(recurringInvoiceId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Update a recurring invoice. Only the fields present in `body` change.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @param body - Fields to change.\n * @returns The updated recurring invoice.\n */\n async update(\n recurringInvoiceId: string,\n body: operations['patchCompanyRecurringInvoice']['requestBody']['content']['application/json'],\n ) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n body,\n });\n return data!.data;\n }\n\n /**\n * Delete a recurring invoice and cancel its pending generations. Invoices it already\n * generated are kept.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n */\n async delete(recurringInvoiceId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n }\n\n /**\n * Pause, resume or end the template.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @param body - Target `status` (e.g. `PAUSED`, `ACTIVE`).\n * @returns The updated recurring invoice.\n */\n async setStatus(\n recurringInvoiceId: string,\n body: operations['setCompanyRecurringInvoiceStatus']['requestBody']['content']['application/json'],\n ) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/status', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n body,\n });\n return data!.data;\n }\n\n /**\n * Skip the next scheduled occurrence.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The recurring invoice with its next date moved.\n */\n async skip(recurringInvoiceId: string) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/skip', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Generate the next invoice now instead of waiting for the schedule.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The generated `invoice_id` and the `next_generation` date.\n */\n async generateNow(recurringInvoiceId: string) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/generate', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Preview the next invoice the template will generate.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The invoice as it would be generated.\n */\n async nextOccurrence(recurringInvoiceId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/next-occurrence', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * The generation history of the template: generated, skipped and failed occurrences.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @param params - Pagination.\n * @returns The `history` entries.\n */\n async history(recurringInvoiceId: string, params?: operations['getCompanyRecurringInvoiceHistory']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/history', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }), query: params },\n });\n return data!.data;\n }\n}\n\n/**\n * Tax defaults of one company (main tax, IRPF, equivalence surcharge). The canonical\n * replacement for the account-wide `beel.configuration.getTaxConfig()`, whose flat route is\n * deprecated. Reach it as `beel.company(companyId).taxConfiguration`.\n */\nexport class CompanyTaxConfigurationResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * Get the tax configuration.\n *\n * @returns The company's tax defaults.\n */\n async get() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/tax-configuration', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Replace the tax configuration — this is a `PUT`, not a merge: send the whole state.\n *\n * @param body - The complete tax configuration.\n * @returns The stored configuration.\n */\n async update(body: components['schemas']['UpdateTaxConfigurationRequest']) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/tax-configuration', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n}\n\n/**\n * VeriFactu configuration of one company. The canonical replacement for\n * `beel.configuration.getVerifactu()`, whose flat route is deprecated. Reach it as\n * `beel.company(companyId).verifactuConfiguration`.\n *\n * Whether an invoice reaches AEAT is a fact of this NIF resolved at issue time, not a\n * per-invoice choice: `enabled` is the only writable field. Everything else — `status`,\n * `nif_status`, `signed`, `activated`, `pdf_generated` — is resolved server-side. The\n * outcome of each invoice is on the invoice itself: `invoice.verifactu.submission_status`.\n */\nexport class CompanyVeriFactuConfigurationResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * Get the VeriFactu configuration of this NIF.\n *\n * @returns `enabled` and the server-resolved state of the NIF.\n */\n async get() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/verifactu-configuration', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Turn VeriFactu on or off for this NIF. `enabled` is the only field you can write.\n *\n * @param body - `{ enabled }`.\n * @returns The updated configuration.\n */\n async update(body: components['schemas']['UpdateVeriFactuConfigurationRequest']) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/verifactu-configuration', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n}\n","import { createBeeLClient, type BeeLConfig } from './http/client';\nimport { InvoicesResource } from './resources/invoices';\nimport { CustomersResource } from './resources/customers';\nimport { ProductsResource } from './resources/products';\nimport { ConfigurationResource, CatalogsResource } from './resources/configuration';\nimport { SeriesResource } from './resources/series';\nimport { NifResource } from './resources/nif';\nimport { AccountsResource, AccountScope } from './resources/accounts';\nimport { CompanyScope } from './resources/company';\n\n/**\n * The BeeL API client. Create one per API key and reuse it; it holds no global state.\n * Address a company with {@link company} and an account with {@link account}.\n *\n * Requests are retried automatically when it is safe — see `BeeLConfig` — and every `POST`\n * carries an `Idempotency-Key` that those retries reuse.\n *\n * @example\n * ```typescript\n * import { BeeL } from '@beel_es/sdk';\n *\n * const beel = new BeeL({ apiKey: process.env.BEEL_API_KEY! });\n *\n * const invoice = await beel.company('company-uuid').invoices.create({\n * type: 'STANDARD',\n * recipient: { customer_id: 'customer-uuid' },\n * lines: [{\n * description: 'Service', quantity: 1, unit_price: 100,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' },\n * }],\n * });\n * ```\n */\nexport class BeeL {\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).invoices` instead. */\n readonly invoices: InvoicesResource;\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).customers` instead. */\n readonly customers: CustomersResource;\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).products` instead. */\n readonly products: ProductsResource;\n /** @deprecated Session-focus configuration endpoints are deprecated in the API contract. Use the company-scoped equivalents on `beel.company(companyId)`. */\n readonly configuration: ConfigurationResource;\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).series` instead. */\n readonly series: SeriesResource;\n /** Account-wide catalogs, the credential's identity and personal preferences. */\n readonly catalogs: CatalogsResource;\n /** NIF validation against the AEAT register. */\n readonly nif: NifResource;\n /** Accounts you manage (multi-account provisioning: members, invitations, webhooks, companies). */\n readonly accounts: AccountsResource;\n\n /**\n * The typed client underneath, for any endpoint this SDK does not wrap yet.\n *\n * A new route reaches the generated types as soon as the contract is synced, but its\n * ergonomic wrapper is written by hand — so without this you would have to wait for a\n * release to call it. Here you can call it today, and still typed: the path, its\n * parameters and the body are checked against the contract, a wrong one does not\n * compile. What you give up is the sugar (grouping, unwrapping of `data`, the\n * builders) and the naming stability the wrappers provide.\n *\n * Retries, the `Authorization` header and `Idempotency-Key` still apply: it is the\n * same client the resources use, middleware included. That includes error handling: a\n * non-2xx answer is **thrown** as a `BeeLApiError` subclass, so `raw` calls never resolve\n * with openapi-fetch's `{ error }`; `data` is always the successful body.\n *\n * @example\n * ```typescript\n * const { data } = await beel.raw.GET('/v1/companies/{company_id}/invoice-customization', {\n * params: { path: { company_id: 'uuid' } },\n * });\n * ```\n */\n readonly raw: ReturnType<typeof createBeeLClient>;\n\n constructor(config: BeeLConfig) {\n const client = createBeeLClient(config);\n this.raw = client;\n this.invoices = new InvoicesResource(client);\n this.customers = new CustomersResource(client);\n this.products = new ProductsResource(client);\n this.configuration = new ConfigurationResource(client);\n this.catalogs = new CatalogsResource(client);\n this.series = new SeriesResource(client);\n this.nif = new NifResource(client);\n this.accounts = new AccountsResource(client);\n }\n\n /**\n * Returns a facade scoped to one company (NIF) — the explicit multi-NIF surface.\n * All operations address the company in the path, no session focus needed. No request\n * is made; get the ids from `beel.account(accountId).companies.list()`.\n *\n * @param companyId - Company UUID (not its NIF).\n * @returns The company scope.\n *\n * @example\n * ```typescript\n * const company = beel.company('company-uuid');\n * const { invoices } = await company.invoices.list({ status: 'ISSUED' });\n * ```\n */\n company(companyId: string): CompanyScope {\n return new CompanyScope(this.raw, companyId);\n }\n\n /**\n * Returns a facade scoped to one account — companies, members, invitations, account\n * webhooks, usage. Symmetric with {@link company}. No request is made; your own account\n * id is `(await beel.catalogs.identity()).account_id`.\n *\n * @param accountId - Account UUID.\n * @returns The account scope.\n *\n * @example\n * ```typescript\n * const account = beel.account('account-uuid');\n * const members = await account.members.list();\n * ```\n */\n account(accountId: string): AccountScope {\n return new AccountScope(this.raw, accountId);\n }\n\n /**\n * Download an invoice PDF as a Buffer.\n *\n * @deprecated Relies on the deprecated session-focus PDF endpoint. Use\n * `beel.company(companyId).invoices.getPdf(invoiceId)` and fetch `download_url` instead.\n *\n * @param invoiceId - Invoice UUID.\n * @returns The PDF bytes and its file name.\n * @throws {Error} When downloading the file fails.\n *\n * @example\n * ```typescript\n * const { buffer, fileName } = await beel.downloadPdf('invoice-uuid');\n * fs.writeFileSync(fileName, buffer);\n * ```\n */\n async downloadPdf(invoiceId: string): Promise<{ buffer: Buffer; fileName: string }> {\n const pdf = await this.invoices.getPdf(invoiceId);\n const response = await fetch(pdf.download_url);\n if (!response.ok) throw new Error(`Failed to download PDF: ${response.status}`);\n const arrayBuffer = await response.arrayBuffer();\n return { buffer: Buffer.from(arrayBuffer), fileName: pdf.file_name };\n }\n}\n","import { createHmac, timingSafeEqual } from 'crypto';\n\n/**\n * Webhook signature verification for BeeL webhooks\n * \n * Every webhook delivery includes a `BeeL-Signature` header that must be verified\n * to ensure the webhook came from BeeL and hasn't been tampered with.\n * \n * ## Security Requirements\n * \n * 1. **Always verify** the signature before processing the webhook\n * 2. **Use constant-time comparison** to prevent timing attacks\n * 3. **Reject old events** (older than 5 minutes)\n * 4. **Use raw request body** (before parsing JSON)\n * \n * ## Header Format\n * \n * ```\n * BeeL-Signature: t=1741362026,v1=3c4f7a2e1b9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f\n * ```\n * \n * Where:\n * - `t` = Unix timestamp when the webhook was sent\n * - `v1` = HMAC-SHA256 signature of the payload\n * \n * @example Express.js\n * ```typescript\n * import express from 'express';\n * import { WebhookVerifier } from '@beel_es/sdk';\n * \n * const verifier = new WebhookVerifier('your_webhook_secret');\n * \n * app.post('/webhooks/beel', express.raw({ type: 'application/json' }), (req, res) => {\n * const signature = req.headers['beel-signature'] as string;\n * const rawBody = req.body.toString('utf8');\n * \n * try {\n * const event = verifier.verify(rawBody, signature);\n * \n * if (event.type === 'verifactu.status.updated') {\n * console.log('VeriFactu status:', event.data.new_status);\n * if (event.data.new_status === 'ACCEPTED') {\n * console.log('QR URL:', event.data.qr_url);\n * }\n * }\n * \n * res.status(200).send('OK');\n * } catch (error) {\n * console.error('Invalid webhook:', error.message);\n * res.status(400).send('Invalid signature');\n * }\n * });\n * ```\n */\nexport class WebhookVerifier {\n private readonly secret: string;\n private readonly toleranceSeconds: number;\n \n /**\n * Creates a new WebhookVerifier\n * \n * @param secret - Your webhook secret from BeeL dashboard\n * @param toleranceSeconds - Maximum age of webhook events (default: 300 = 5 minutes)\n */\n constructor(secret: string, toleranceSeconds: number = 300) {\n if (!secret || secret.trim().length === 0) {\n throw new Error('Webhook secret is required');\n }\n this.secret = secret;\n this.toleranceSeconds = toleranceSeconds;\n }\n \n /**\n * Verify a webhook signature and return the parsed event\n * \n * @param rawBody - Raw request body (string or Buffer, before JSON parsing)\n * @param signatureHeader - Value of the `BeeL-Signature` header\n * @returns Parsed webhook event\n * @throws {WebhookVerificationError} If signature is invalid or event is too old\n * \n * @example Basic usage\n * ```typescript\n * const verifier = new WebhookVerifier('your_secret');\n * const event = verifier.verify(rawBody, signature);\n * \n * if (event.test) return; // a \"Send test\" delivery carries a synthetic `data`\n * if (event.type === 'verifactu.status.updated') {\n * console.log('Invoice:', event.data.invoice_number);\n * console.log('Status:', event.data.new_status);\n * }\n * ```\n */\n verify<T extends WebhookEvent = WebhookEvent>(\n rawBody: string | Buffer,\n signatureHeader: string | undefined\n ): T {\n if (!signatureHeader) {\n throw new WebhookVerificationError('Missing BeeL-Signature header');\n }\n \n // Parse signature header\n const { timestamp, signature } = this.parseSignatureHeader(signatureHeader);\n \n // Check timestamp tolerance\n const now = Math.floor(Date.now() / 1000);\n const age = Math.abs(now - timestamp);\n \n if (age > this.toleranceSeconds) {\n throw new WebhookVerificationError(\n `Webhook timestamp too old (${age}s ago, max ${this.toleranceSeconds}s allowed)`\n );\n }\n \n // Verify signature\n const bodyString = Buffer.isBuffer(rawBody) ? rawBody.toString('utf8') : rawBody;\n const expectedSignature = this.computeSignature(timestamp, bodyString);\n \n if (!this.secureCompare(signature, expectedSignature)) {\n throw new WebhookVerificationError('Invalid webhook signature');\n }\n \n // Parse and return event\n try {\n return JSON.parse(bodyString);\n } catch (error) {\n throw new WebhookVerificationError('Invalid JSON in webhook body');\n }\n }\n \n /**\n * Parse the BeeL-Signature header\n * \n * Format: `t=1741362026,v1=3c4f7a2e...`\n */\n private parseSignatureHeader(header: string): { timestamp: number; signature: string } {\n const parts = header.split(',');\n let timestamp: number | undefined;\n let signature: string | undefined;\n \n for (const part of parts) {\n const [key, value] = part.split('=', 2);\n if (key === 't') {\n timestamp = parseInt(value, 10);\n } else if (key === 'v1') {\n signature = value;\n }\n }\n \n if (!timestamp || !signature) {\n throw new WebhookVerificationError(\n 'Invalid signature header format (expected: t=timestamp,v1=signature)'\n );\n }\n \n if (isNaN(timestamp)) {\n throw new WebhookVerificationError('Invalid timestamp in signature header');\n }\n \n return { timestamp, signature };\n }\n \n /**\n * Compute HMAC-SHA256 signature\n * \n * Algorithm:\n * 1. Build signed payload: `{timestamp}.{raw_body}`\n * 2. Compute: HMAC-SHA256(secret, signed_payload)\n * 3. Return hex digest\n */\n private computeSignature(timestamp: number, body: string): string {\n const signedPayload = `${timestamp}.${body}`;\n return createHmac('sha256', this.secret)\n .update(signedPayload, 'utf8')\n .digest('hex');\n }\n \n /**\n * Constant-time string comparison to prevent timing attacks\n */\n private secureCompare(a: string, b: string): boolean {\n if (a.length !== b.length) {\n return false;\n }\n \n const bufferA = Buffer.from(a, 'utf8');\n const bufferB = Buffer.from(b, 'utf8');\n \n return timingSafeEqual(bufferA, bufferB);\n }\n}\n\n/**\n * Webhook verification error\n */\nexport class WebhookVerificationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'WebhookVerificationError';\n }\n}\n\n/**\n * Webhook event types, built from the generated webhook contract\n * (`npm run generate:webhooks`, from openapi/webhook-receiver-api.yaml).\n *\n * The generator emits each event as the envelope intersected with its own one-member\n * `type` enum. The envelope already types `type` as the full `WebhookEventType` enum, and\n * two different enums never intersect, so every generated event collapsed to `never` and\n * `if (event.type === '...')` narrowed to nothing. These are the same shapes, rebuilt on\n * the envelope without its `type`, with `type` as the string literal the API sends.\n */\nimport type {\n WebhookEventEnvelope as GeneratedEnvelope,\n WebhookEventDataVeriFactuStatusUpdated,\n WebhookEventDataInvoiceIssued,\n WebhookEventDataInvoiceVoided,\n WebhookEventDataInvoiceEmailSent,\n WebhookEventDataInvoicePdfGenerated,\n WebhookEventDataInvoiceScheduleFailed,\n WebhookEventDataRecurringInvoicePaused,\n WebhookEventDataAccountClaimed,\n WebhookEventDataCompanyCreated,\n WebhookEventDataRepresentationSigned,\n WebhookEventDataTest,\n WebhookEventType,\n} from '../generated-webhooks';\n\n/** Fields every delivery carries, whatever its type. */\nexport type WebhookEventEnvelope = Omit<GeneratedEnvelope, 'type'> & { type: `${WebhookEventType}` };\n\n/** A real (non-test) event of type `K` carrying `D`. */\ntype BusinessEvent<K extends `${WebhookEventType}`, D> = Omit<GeneratedEnvelope, 'type' | 'test'> & {\n type: K;\n /** Absent or `false` on a real event; see `WebhookTestEvent`. */\n test?: false | null;\n data: D;\n};\n\n/** `verifactu.status.updated`: AEAT answered for an invoice's VeriFactu record (`new_status`, `qr_url`…). */\nexport type VeriFactuStatusUpdatedEvent = BusinessEvent<'verifactu.status.updated', WebhookEventDataVeriFactuStatusUpdated>;\n/** `invoice.issued`: an invoice was issued. */\nexport type InvoiceIssuedEvent = BusinessEvent<'invoice.issued', WebhookEventDataInvoiceIssued>;\n/** `invoice.voided`: an invoice was voided. */\nexport type InvoiceVoidedEvent = BusinessEvent<'invoice.voided', WebhookEventDataInvoiceVoided>;\n/** `invoice.email.sent`: an invoice email was accepted by the email provider. */\nexport type InvoiceEmailSentEvent = BusinessEvent<'invoice.email.sent', WebhookEventDataInvoiceEmailSent>;\n/** `invoice.pdf.generated`: the PDF of an invoice is ready. */\nexport type InvoicePdfGeneratedEvent = BusinessEvent<'invoice.pdf.generated', WebhookEventDataInvoicePdfGenerated>;\n/** `invoice.schedule_failed`: a scheduled invoice could not be processed. */\nexport type InvoiceScheduleFailedEvent = BusinessEvent<'invoice.schedule_failed', WebhookEventDataInvoiceScheduleFailed>;\n/** `recurring_invoice.paused`: a recurring invoice was paused. */\nexport type RecurringInvoicePausedEvent = BusinessEvent<'recurring_invoice.paused', WebhookEventDataRecurringInvoicePaused>;\n/** `account.claimed`: the holder of a provisioned account took ownership. */\nexport type AccountClaimedEvent = BusinessEvent<'account.claimed', WebhookEventDataAccountClaimed>;\n/** `company.created`: a company (NIF) was created. */\nexport type CompanyCreatedEvent = BusinessEvent<'company.created', WebhookEventDataCompanyCreated>;\n/** `representation.signed`: a representation document was signed. */\nexport type RepresentationSignedEvent = BusinessEvent<'representation.signed', WebhookEventDataRepresentationSigned>;\n\n/**\n * A delivery sent with \"Send test\": `test` is `true` and `data` is a synthetic message,\n * whatever `type` says. Check `event.test` before narrowing on `event.type`.\n */\nexport type WebhookTestEvent = Omit<GeneratedEnvelope, 'type' | 'test'> & {\n type: `${WebhookEventType}`;\n test: true;\n data: WebhookEventDataTest;\n};\n\n/**\n * Union type of all possible webhook events\n */\nexport type WebhookEvent =\n | VeriFactuStatusUpdatedEvent\n | InvoiceIssuedEvent\n | InvoiceVoidedEvent\n | InvoiceEmailSentEvent\n | InvoicePdfGeneratedEvent\n | InvoiceScheduleFailedEvent\n | RecurringInvoicePausedEvent\n | AccountClaimedEvent\n | CompanyCreatedEvent\n | RepresentationSignedEvent\n | WebhookTestEvent;\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataAccountClaimed } from './WebhookEventDataAccountClaimed';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type AccountClaimedEvent = (WebhookEventEnvelope & {\n type?: AccountClaimedEvent.type;\n data: WebhookEventDataAccountClaimed;\n});\nexport namespace AccountClaimedEvent {\n export enum type {\n ACCOUNT_CLAIMED = 'account.claimed',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataCompanyCreated } from './WebhookEventDataCompanyCreated';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type CompanyCreatedEvent = (WebhookEventEnvelope & {\n type?: CompanyCreatedEvent.type;\n data: WebhookEventDataCompanyCreated;\n});\nexport namespace CompanyCreatedEvent {\n export enum type {\n COMPANY_CREATED = 'company.created',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceEmailSent } from './WebhookEventDataInvoiceEmailSent';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceEmailSentEvent = (WebhookEventEnvelope & {\n type?: InvoiceEmailSentEvent.type;\n data: WebhookEventDataInvoiceEmailSent;\n});\nexport namespace InvoiceEmailSentEvent {\n export enum type {\n INVOICE_EMAIL_SENT = 'invoice.email.sent',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceIssued } from './WebhookEventDataInvoiceIssued';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceIssuedEvent = (WebhookEventEnvelope & {\n type?: InvoiceIssuedEvent.type;\n data: WebhookEventDataInvoiceIssued;\n});\nexport namespace InvoiceIssuedEvent {\n export enum type {\n INVOICE_ISSUED = 'invoice.issued',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoicePdfGenerated } from './WebhookEventDataInvoicePdfGenerated';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoicePdfGeneratedEvent = (WebhookEventEnvelope & {\n type?: InvoicePdfGeneratedEvent.type;\n data: WebhookEventDataInvoicePdfGenerated;\n});\nexport namespace InvoicePdfGeneratedEvent {\n export enum type {\n INVOICE_PDF_GENERATED = 'invoice.pdf.generated',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceScheduleFailed } from './WebhookEventDataInvoiceScheduleFailed';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceScheduleFailedEvent = (WebhookEventEnvelope & {\n type?: InvoiceScheduleFailedEvent.type;\n data: WebhookEventDataInvoiceScheduleFailed;\n});\nexport namespace InvoiceScheduleFailedEvent {\n export enum type {\n INVOICE_SCHEDULE_FAILED = 'invoice.schedule_failed',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceVoided } from './WebhookEventDataInvoiceVoided';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceVoidedEvent = (WebhookEventEnvelope & {\n type?: InvoiceVoidedEvent.type;\n data: WebhookEventDataInvoiceVoided;\n});\nexport namespace InvoiceVoidedEvent {\n export enum type {\n INVOICE_VOIDED = 'invoice.voided',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataRecurringInvoicePaused } from './WebhookEventDataRecurringInvoicePaused';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type RecurringInvoicePausedEvent = (WebhookEventEnvelope & {\n type?: RecurringInvoicePausedEvent.type;\n data: WebhookEventDataRecurringInvoicePaused;\n});\nexport namespace RecurringInvoicePausedEvent {\n export enum type {\n RECURRING_INVOICE_PAUSED = 'recurring_invoice.paused',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataRepresentationSigned } from './WebhookEventDataRepresentationSigned';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type RepresentationSignedEvent = (WebhookEventEnvelope & {\n type?: RepresentationSignedEvent.type;\n data: WebhookEventDataRepresentationSigned;\n});\nexport namespace RepresentationSignedEvent {\n export enum type {\n REPRESENTATION_SIGNED = 'representation.signed',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataVeriFactuStatusUpdated } from './WebhookEventDataVeriFactuStatusUpdated';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type VeriFactuStatusUpdatedEvent = (WebhookEventEnvelope & {\n type?: VeriFactuStatusUpdatedEvent.type;\n data: WebhookEventDataVeriFactuStatusUpdated;\n});\nexport namespace VeriFactuStatusUpdatedEvent {\n export enum type {\n VERIFACTU_STATUS_UPDATED = 'verifactu.status.updated',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\n/**\n * VeriFactu registration status. Every value is also a value of `verifactu.submission_status`\n * on the invoice resource, so a status read from a webhook can be fed straight back into the\n * `verifactu_status` filter of `GET /v1/companies/{company_id}/invoices`. The API has one more\n * value, `NOT_SUBMITTED`, for a record that was never submitted, which is therefore never\n * sent in a webhook.\n * - `PENDING` — queued or submitted, awaiting a final AEAT response. Includes a temporary\n * AEAT server error that BeeL. is retrying.\n * - `ACCEPTED` — accepted by the AEAT (with or without non-blocking remarks).\n * - `VOIDED` — cancellation record accepted by the AEAT.\n * - `REJECTED` — rejected by the AEAT, or the record never made it there.\n *\n */\nexport enum VeriFactuSubmissionStatus {\n PENDING = 'PENDING',\n ACCEPTED = 'ACCEPTED',\n VOIDED = 'VOIDED',\n REJECTED = 'REJECTED',\n}\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\n/**\n * Canonical set of event types BeeL. can deliver. Subscribe to the ones your\n * integration cares about via `POST /v1/webhooks` in the Public API.\n *\n */\nexport enum WebhookEventType {\n VERIFACTU_STATUS_UPDATED = 'verifactu.status.updated',\n INVOICE_ISSUED = 'invoice.issued',\n INVOICE_EMAIL_SENT = 'invoice.email.sent',\n INVOICE_PDF_GENERATED = 'invoice.pdf.generated',\n INVOICE_VOIDED = 'invoice.voided',\n RECURRING_INVOICE_PAUSED = 'recurring_invoice.paused',\n INVOICE_SCHEDULE_FAILED = 'invoice.schedule_failed',\n ACCOUNT_CLAIMED = 'account.claimed',\n COMPANY_CREATED = 'company.created',\n REPRESENTATION_SIGNED = 'representation.signed',\n}\n","import type { components } from '../generated/schema';\n\ntype CreateCustomerRequest = components['schemas']['CreateCustomerRequest'];\ntype Address = components['schemas']['Address'];\n\n/**\n * Fluent builder for the body of `customers.create`. It builds the request object only;\n * send it with `beel.company(companyId).customers.create(builder.build())`.\n *\n * @example\n * ```typescript\n * const customer = CustomerBuilder.create()\n * .name('Acme Corporation SL')\n * .nif('B12345678')\n * .email('contact@acme.com')\n * .address('Calle Mayor', '1', '28001', 'Madrid', 'Madrid', 'Spain')\n * .build();\n * ```\n */\nexport class CustomerBuilder {\n private _name?: string;\n private _nif?: string;\n private _email?: string;\n private _phone?: string;\n private _address?: Address;\n private _notes?: string;\n\n private constructor() {}\n\n /**\n * Start a new builder.\n *\n * @returns An empty customer builder.\n */\n static create(): CustomerBuilder {\n return new CustomerBuilder();\n }\n\n /**\n * Legal name of the customer. Required.\n *\n * @param name - Legal name.\n * @returns This builder.\n */\n name(name: string): this {\n this._name = name;\n return this;\n }\n\n /**\n * NIF/CIF of the customer. Required.\n *\n * @param nif - Spanish tax id.\n * @returns This builder.\n */\n nif(nif: string): this {\n this._nif = nif;\n return this;\n }\n\n /**\n * Contact email.\n *\n * @param email - Email address.\n * @returns This builder.\n */\n email(email: string): this {\n this._email = email;\n return this;\n }\n\n /**\n * Contact phone: 9 to 20 characters of digits, spaces, dashes, parentheses and a leading `+`.\n *\n * @param phone - Phone number.\n * @returns This builder.\n */\n phone(phone: string): this {\n this._phone = phone;\n return this;\n }\n\n /**\n * Fiscal address. Required.\n *\n * @param street - Street name.\n * @param number - Street number.\n * @param postalCode - Postal code.\n * @param city - City.\n * @param province - Province.\n * @param country - Country name.\n * @param countryCode - ISO 3166-1 alpha-2 code. Default: `ES`.\n * @returns This builder.\n */\n address(street: string, number: string, postalCode: string, city: string, province: string, country: string, countryCode: string = 'ES'): this {\n this._address = { street, number, postal_code: postalCode, city, province, country, country_code: countryCode };\n return this;\n }\n\n /**\n * Internal notes about the customer.\n *\n * @param notes - Free text.\n * @returns This builder.\n */\n notes(notes: string): this {\n this._notes = notes;\n return this;\n }\n\n /**\n * Build the request body.\n *\n * @returns The `CreateCustomerRequest`.\n * @throws {Error} When the name, NIF or address is missing.\n */\n build(): CreateCustomerRequest {\n if (!this._name || this._name.trim().length === 0) throw new Error('Legal name is required');\n if (!this._nif || this._nif.trim().length === 0) throw new Error('NIF/CIF is required');\n if (!this._address) throw new Error('Address is required');\n\n return {\n legal_name: this._name,\n nif: this._nif,\n email: this._email,\n phone: this._phone,\n address: this._address,\n notes: this._notes,\n };\n }\n}\n","import type { components } from '../generated/schema';\n\ntype CreateInvoiceRequest = components['schemas']['CreateInvoiceRequest'];\ntype InvoiceType = components['schemas']['InvoiceType'];\ntype Recipient = components['schemas']['Recipient'];\ntype InvoiceLine = CreateInvoiceRequest['lines'][number];\ntype LineMainTax = NonNullable<InvoiceLine['main_tax']>;\n\n/** Line type of the lines `addLine` builds: a regular line with its own tax. */\nconst NORMAL_LINE_TYPE = 'NORMAL' satisfies InvoiceLine['line_type'];\n\n/** Default of `addLine`'s `discountPercentage`. */\nconst NO_DISCOUNT = 0;\n\n/** `Date` → `YYYY-MM-DD`, the date format of the API. */\nfunction toIsoDate(date: string | Date): string {\n return date instanceof Date ? date.toISOString().split('T')[0] : date;\n}\n\n/**\n * Fluent builder for the body of `invoices.create`. It builds the request object only; send\n * it with `beel.company(companyId).invoices.create(builder.build())`.\n *\n * The API requires a `main_tax` on every `NORMAL` line (`422 LINE_MAIN_TAX_REQUIRED`\n * otherwise): set it once with {@link mainTax}, or per line in {@link addLine}.\n *\n * @example\n * ```typescript\n * const request = InvoiceBuilder.create()\n * .forCustomer('customer-uuid')\n * .mainTax({ type: 'IVA', percentage: 21, regime_key: '01' })\n * .addLine('Consulting services', 10, 85.5)\n * .build();\n * const invoice = await beel.company(companyId).invoices.create(request);\n * ```\n */\nexport class InvoiceBuilder {\n private _type: InvoiceType = 'STANDARD';\n private _operationDate?: string;\n private _dueDate?: string;\n private _customerId?: string;\n private _lines: InvoiceLine[] = [];\n private _notes?: string;\n private _seriesId?: string;\n private _metadata?: Record<string, any>;\n private _mainTax?: LineMainTax;\n\n private constructor() {}\n\n /**\n * Start a new builder.\n *\n * @returns An empty `STANDARD` invoice builder.\n */\n static create(): InvoiceBuilder {\n return new InvoiceBuilder();\n }\n\n /**\n * Set the invoice type. Default: `STANDARD`.\n *\n * @param type - `STANDARD`, `SIMPLIFIED` or `PROFORMA` (correctives use `createCorrective`).\n * @returns This builder.\n */\n type(type: InvoiceType): this {\n this._type = type;\n return this;\n }\n\n /**\n * Invoice a registered customer.\n *\n * @param customerId - Customer UUID.\n * @returns This builder.\n */\n forCustomer(customerId: string): this {\n this._customerId = customerId;\n return this;\n }\n\n /**\n * Date the operation took place, when it differs from the issue date.\n *\n * @param date - A `Date` or a `YYYY-MM-DD` string.\n * @returns This builder.\n */\n operationDate(date: string | Date): this {\n this._operationDate = toIsoDate(date);\n return this;\n }\n\n /**\n * Payment due date.\n *\n * @param date - A `Date` or a `YYYY-MM-DD` string.\n * @returns This builder.\n */\n dueDate(date: string | Date): this {\n this._dueDate = toIsoDate(date);\n return this;\n }\n\n /**\n * Main tax applied to every line added with {@link addLine} after this call, unless the\n * line passes its own.\n *\n * @param tax - For example `{ type: 'IVA', percentage: 21, regime_key: '01' }`.\n * @returns This builder.\n */\n mainTax(tax: LineMainTax): this {\n this._mainTax = tax;\n return this;\n }\n\n /**\n * Add a `NORMAL` line.\n *\n * @param description - What is invoiced.\n * @param quantity - Units.\n * @param unitPrice - Price per unit before taxes.\n * @param discountPercentage - Discount, 0–100. Default: `0`.\n * @param mainTax - Tax of this line; defaults to the one set with {@link mainTax}. The API\n * rejects a `NORMAL` line without one.\n * @returns This builder.\n */\n addLine(\n description: string,\n quantity: number,\n unitPrice: number,\n discountPercentage: number = NO_DISCOUNT,\n mainTax?: LineMainTax,\n ): this {\n const tax = mainTax ?? this._mainTax;\n this._lines.push({\n line_type: NORMAL_LINE_TYPE,\n description,\n quantity,\n unit_price: unitPrice,\n discount_percentage: discountPercentage,\n ...(tax ? { main_tax: tax } : {}),\n });\n return this;\n }\n\n /**\n * Add a line exactly as given — any line type or pricing mode.\n *\n * @param line - A line of `CreateInvoiceRequest`.\n * @returns This builder.\n */\n addLineObject(line: InvoiceLine): this {\n this._lines.push(line);\n return this;\n }\n\n /**\n * Notes printed on the invoice.\n *\n * @param notes - Free text.\n * @returns This builder.\n */\n notes(notes: string): this {\n this._notes = notes;\n return this;\n }\n\n /**\n * Number the invoice in this series instead of the default one.\n *\n * @param id - Series UUID.\n * @returns This builder.\n */\n series(id: string): this {\n this._seriesId = id;\n return this;\n }\n\n /**\n * Your own key/value pairs, filterable when listing.\n *\n * @param data - Metadata to store with the invoice.\n * @returns This builder.\n */\n metadata(data: Record<string, any>): this {\n this._metadata = data;\n return this;\n }\n\n /**\n * Build the request body.\n *\n * @returns The `CreateInvoiceRequest`.\n * @throws {Error} When there is no customer or no line.\n */\n build(): CreateInvoiceRequest {\n if (!this._customerId) throw new Error('Customer ID is required');\n if (this._lines.length === 0) throw new Error('At least one invoice line is required');\n\n const recipient: Recipient = { customer_id: this._customerId };\n\n return {\n type: this._type,\n operation_date: this._operationDate,\n due_date: this._dueDate,\n recipient,\n lines: this._lines,\n notes: this._notes,\n series_id: this._seriesId,\n metadata: this._metadata,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;;;ACMlB,IAAM,mBAAmB;AAGzB,IAAM,sBAAsB;AAG5B,IAAM,yBAAyB;AAG/B,IAAM,6BAA6B;AAGnC,IAAM,+BAA+B;;;ACfrC,IAAM,yBAAyB;AAG/B,IAAM,4BAA4B;AAGlC,IAAM,qBAAqB;AAE3B,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB;AAC5B,IAAM,oBAAoB;AAG1B,IAAM,kBAAkB;;;AChB/B,oBAA2B;;;ACCpB,IAAM,aAAa;AAAA,EACxB,cAAc;AAAA,EACd,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,mBAAmB;AAAA;AAAA,EAEnB,kBAAkB;AACpB;AAGO,SAAS,oBAAoB,QAAyB;AAC3D,SAAO,UAAU,WAAW;AAC9B;;;ACZA,IAAM,yCAAyC;AAiBxC,IAAM,eAAN,cAA2B,MAAM;AAAA,EAoBtC,YACE,SACA,YACA,MACA,SACA,WACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,SAAK,UAAU,WAAW;AAC1B,SAAK,UAAU;AACf,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,qBAAN,cAAiC,aAAa;AAAA,EAInD,YAAY,SAAiB,mBAA2B,WAAoB,SAAkB;AAC5F,UAAM,SAAS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ACxC,SAAK,YAAY;AACjB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAA8B;AAC5B,QAAI,CAAC,KAAK,YAAa,OAAM,IAAI,MAAM,yBAAyB;AAChE,QAAI,KAAK,OAAO,WAAW,EAAG,OAAM,IAAI,MAAM,uCAAuC;AAErF,UAAM,YAAuB,EAAE,aAAa,KAAK,YAAY;AAE7D,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,gBAAgB,KAAK;AAAA,MACrB,UAAU,KAAK;AAAA,MACf;AAAA,MACA,OAAO,KAAK;AAAA,MACZ,OAAO,KAAK;AAAA,MACZ,WAAW,KAAK;AAAA,MAChB,UAAU,KAAK;AAAA,IACjB;AAAA,EACF;AACF;","names":["createClient","import_crypto","AccountClaimedEvent","type","CompanyCreatedEvent","type","InvoiceEmailSentEvent","type","InvoiceIssuedEvent","type","InvoicePdfGeneratedEvent","type","InvoiceScheduleFailedEvent","type","InvoiceVoidedEvent","type","RecurringInvoicePausedEvent","type","RepresentationSignedEvent","type","VeriFactuStatusUpdatedEvent","type","VeriFactuSubmissionStatus","WebhookEventType"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/http/client.ts","../src/core/defaults.ts","../src/http/headers.ts","../src/http/middleware.ts","../src/core/http-status.ts","../src/core/errors.ts","../src/core/retry.ts","../src/core/error-codes.ts","../src/http/retry-policy.ts","../src/http/retrying-fetch.ts","../src/resources/invoices.ts","../src/resources/customers.ts","../src/resources/products.ts","../src/resources/configuration.ts","../src/resources/series.ts","../src/resources/nif.ts","../src/resources/accounts.ts","../src/http/request-options.ts","../src/resources/payment-connections.ts","../src/resources/invoice-create-once.ts","../src/resources/company.ts","../src/client.ts","../src/webhooks/verifier.ts","../src/generated-webhooks/models/AccountClaimedEvent.ts","../src/generated-webhooks/models/CompanyCreatedEvent.ts","../src/generated-webhooks/models/InvoiceEmailSentEvent.ts","../src/generated-webhooks/models/InvoiceIssuedEvent.ts","../src/generated-webhooks/models/InvoicePdfGeneratedEvent.ts","../src/generated-webhooks/models/InvoiceScheduleFailedEvent.ts","../src/generated-webhooks/models/InvoiceVoidedEvent.ts","../src/generated-webhooks/models/RecurringInvoicePausedEvent.ts","../src/generated-webhooks/models/RepresentationSignedEvent.ts","../src/generated-webhooks/models/VeriFactuRecordOperation.ts","../src/generated-webhooks/models/VeriFactuStatusUpdatedEvent.ts","../src/generated-webhooks/models/VeriFactuSubmissionStatus.ts","../src/generated-webhooks/models/WebhookEventType.ts","../src/builders/customer-builder.ts","../src/builders/invoice-builder.ts"],"sourcesContent":["// ── Client ─────────────────────────────────────────────\nexport { BeeL } from './client';\nexport type { BeeLConfig } from './http/client';\nexport type { RequestOptions } from './http/request-options';\n\n// ── Typed errors ───────────────────────────────────────\nexport {\n BeeLApiError,\n BeeLRateLimitError,\n BeeLValidationError,\n BeeLAuthError,\n BeeLNotFoundError,\n BeeLConflictError,\n} from './core/errors';\nexport { BeeLErrorCodes } from './core/error-codes';\nexport type { BeeLErrorCode } from './core/error-codes';\n\n// ── Webhook verification ───────────────────────────────\nexport { WebhookVerifier, WebhookVerificationError } from './webhooks/verifier';\nexport type { WebhookEvent } from './webhooks/verifier';\n\n// ── Webhook event types ────────────────────────────────\nexport type {\n WebhookEventEnvelope,\n VeriFactuStatusUpdatedEvent,\n InvoiceIssuedEvent,\n InvoiceVoidedEvent,\n InvoiceEmailSentEvent,\n InvoicePdfGeneratedEvent,\n InvoiceScheduleFailedEvent,\n RecurringInvoicePausedEvent,\n AccountClaimedEvent,\n CompanyCreatedEvent,\n RepresentationSignedEvent,\n WebhookTestEvent,\n} from './webhooks/verifier';\nexport type {\n WebhookEventDataVeriFactuStatusUpdated,\n WebhookEventDataInvoiceIssued,\n WebhookEventDataInvoiceVoided,\n WebhookEventDataInvoiceEmailSent,\n WebhookEventDataInvoicePdfGenerated,\n WebhookEventDataInvoiceScheduleFailed,\n WebhookEventDataRecurringInvoicePaused,\n WebhookEventDataAccountClaimed,\n WebhookEventDataCompanyCreated,\n WebhookEventDataRepresentationSigned,\n WebhookEventDataTest,\n} from './generated-webhooks';\nexport { VeriFactuRecordOperation, VeriFactuSubmissionStatus, WebhookEventType } from './generated-webhooks';\n\n// Backwards-compatible aliases for names removed by the webhook spec regeneration\nimport type {\n WebhookEventDataVeriFactuStatusUpdated as _VeriFactuData,\n VeriFactuSubmissionStatus as _VeriFactuStatus,\n} from './generated-webhooks';\n/** @deprecated Renamed in the contract — use `WebhookEventDataVeriFactuStatusUpdated`. */\nexport type VeriFactuStatusUpdatedData = _VeriFactuData;\n/** @deprecated Renamed in the contract — use `VeriFactuSubmissionStatus`. */\nexport type VeriFactuStatus = _VeriFactuStatus;\n\n// ── Accounts & companies (multi-NIF) ───────────────────\nexport {\n AccountsResource,\n AccountScope,\n AccountMembersResource,\n AccountInvitationsResource,\n AccountWebhooksResource,\n AccountCompaniesResource,\n} from './resources/accounts';\nexport {\n CompanyScope,\n CompanyInvoicesResource,\n CompanyCustomersResource,\n CompanyProductsResource,\n CompanySeriesResource,\n CompanyRecurringInvoicesResource,\n CompanyInvoiceScheduleResource,\n} from './resources/company';\nexport { CatalogsResource } from './resources/configuration';\nexport {\n CompanyTaxConfigurationResource,\n CompanyVeriFactuConfigurationResource,\n} from './resources/company';\nexport { EXTERNAL_REF_UNIQUE_INVOICE_TYPES } from './resources/invoice-create-once';\nexport type {\n CreateInvoiceOnceRequest,\n CreateInvoiceOnceParams,\n ExternalRefUniqueInvoiceType,\n} from './resources/invoice-create-once';\nexport {\n CompanyPaymentConnectionsResource,\n CompanyPaymentEventsResource,\n} from './resources/payment-connections';\n\n// ── Builders ───────────────────────────────────────────\nexport { CustomerBuilder } from './builders/customer-builder';\nexport { InvoiceBuilder } from './builders/invoice-builder';\n\n// ── Generated types ────────────────────────────────────\nexport type { components, operations, paths } from './generated/schema';\n","import createClient from 'openapi-fetch';\nimport type { paths } from '../generated/schema';\nimport {\n DEFAULT_AUTO_IDEMPOTENCY_KEY,\n DEFAULT_BASE_URL,\n DEFAULT_MAX_RETRIES,\n DEFAULT_MAX_RETRY_DELAY_MS,\n DEFAULT_RETRY_DELAY_MS,\n} from '../core/defaults';\nimport { AUTHORIZATION_HEADER } from './headers';\nimport { createRequestMiddleware, errorMiddleware } from './middleware';\nimport { createRetryingFetch } from './retrying-fetch';\n\n/**\n * Options of `new BeeL(config)`. Only `apiKey` is required.\n *\n * **Retries and idempotency.** A call is retried automatically, up to `maxRetries` times,\n * only when sending it again can never apply it twice:\n *\n * - `429` is always retried, after `Retry-After`: the API refused the request unprocessed.\n * - `409 IDEMPOTENCY_KEY_PROCESSING` is retried with the same key after `Retry-After`.\n * - `5xx` and network errors are retried for `GET` requests and for requests that carry an\n * `Idempotency-Key` — every `POST` does, unless `autoIdempotencyKey` is `false`. A `5xx`\n * the API marks `Idempotency-Replay: true` is the stored outcome of that key and is not\n * retried: the same key would return it again.\n * - `PUT`, `PATCH` and `DELETE` without a key are not retried after a `5xx` or network error.\n *\n * Every retry of a call reuses that call's `Idempotency-Key`, so an automatic retry never\n * creates a second invoice. Two separate calls get two keys: to retry a create yourself\n * after it failed with a `5xx` or a network error, use `invoices.createOnce`, or look the\n * invoice up by `external_ref` before creating it again.\n */\nexport interface BeeLConfig {\n /** API key: `beel_sk_live_*` (production) or `beel_sk_test_*` (sandbox). */\n apiKey: string;\n /** Base URL. Default: `https://app.beel.es/api`. */\n baseUrl?: string;\n /**\n * Automatic retries after the first attempt, for the cases listed on {@link BeeLConfig}.\n * `0` disables them. Default: `3`.\n */\n maxRetries?: number;\n /** Base delay of the exponential backoff, in milliseconds. Default: `500`. */\n retryDelayMs?: number;\n /** Upper bound of any single wait between attempts, `Retry-After` included, in ms. Default: `30000`. */\n maxRetryDelayMs?: number;\n /**\n * Add one `Idempotency-Key` (a UUID) to every `POST` that does not carry its own, reused by\n * every automatic retry of that call. With `false`, a `POST` without a key is only retried\n * after a `429`. Default: `true`.\n */\n autoIdempotencyKey?: boolean;\n}\n\nexport function createBeeLClient(config: BeeLConfig) {\n const client = createClient<paths>({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n headers: {\n [AUTHORIZATION_HEADER]: `Bearer ${config.apiKey}`,\n },\n fetch: createRetryingFetch({\n maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,\n initialDelayMs: config.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS,\n maxDelayMs: config.maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS,\n }),\n });\n\n client.use(\n createRequestMiddleware({\n autoIdempotencyKey: config.autoIdempotencyKey ?? DEFAULT_AUTO_IDEMPOTENCY_KEY,\n }),\n );\n client.use(errorMiddleware);\n\n return client;\n}\n\nexport type BeeLClient = ReturnType<typeof createBeeLClient>;\n","/**\n * Default values of {@link BeeLConfig}. One place, so the client, the retry helpers, the\n * JSDoc and the README cannot disagree about them.\n */\n\n/** Production API base URL. Sandbox keys (`beel_sk_test_*`) use the same URL. */\nexport const DEFAULT_BASE_URL = 'https://app.beel.es/api';\n\n/** Automatic retries after the first attempt. `0` disables them. */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/** Base delay of the exponential backoff, in milliseconds. */\nexport const DEFAULT_RETRY_DELAY_MS = 500;\n\n/** Upper bound of any single wait between attempts, in milliseconds. */\nexport const DEFAULT_MAX_RETRY_DELAY_MS = 30_000;\n\n/** Whether the client adds an `Idempotency-Key` to every `POST` that does not carry one. */\nexport const DEFAULT_AUTO_IDEMPOTENCY_KEY = true;\n","/** HTTP header names and values the client reads or writes. */\n\n/** Request header that makes a write safe to retry. See the API's idempotency contract. */\nexport const IDEMPOTENCY_KEY_HEADER = 'Idempotency-Key';\n\n/** Response header set to `true` when the API replays the stored answer of a previous key. */\nexport const IDEMPOTENCY_REPLAY_HEADER = 'Idempotency-Replay';\n\n/** Response header with the seconds (or HTTP date) to wait before the next attempt. */\nexport const RETRY_AFTER_HEADER = 'Retry-After';\n\nexport const AUTHORIZATION_HEADER = 'Authorization';\nexport const CONTENT_TYPE_HEADER = 'Content-Type';\nexport const JSON_CONTENT_TYPE = 'application/json';\n\n/** Body sent on a write that carries none: the API rejects an empty JSON body. */\nexport const EMPTY_JSON_BODY = '{}';\n","import { randomUUID } from 'crypto';\nimport type { Middleware } from 'openapi-fetch';\nimport { throwApiError } from '../core/errors';\nimport {\n CONTENT_TYPE_HEADER,\n EMPTY_JSON_BODY,\n IDEMPOTENCY_KEY_HEADER,\n JSON_CONTENT_TYPE,\n} from './headers';\n\n/** Methods whose request must always carry a JSON body. */\nconst METHODS_WITH_JSON_BODY = new Set(['POST', 'PUT', 'PATCH']);\n\n/** Methods that receive an automatic `Idempotency-Key` when they do not carry one. */\nconst METHODS_WITH_AUTO_IDEMPOTENCY_KEY = new Set(['POST']);\n\n/** A fresh `Idempotency-Key`: a UUID, which fits the API's `^[a-zA-Z0-9_-]+$` pattern. */\nexport function newIdempotencyKey(): string {\n return randomUUID();\n}\n\nexport interface RequestMiddlewareOptions {\n /** Add an `Idempotency-Key` to every `POST` that does not carry one. */\n autoIdempotencyKey: boolean;\n}\n\n/**\n * Ensures POST/PUT/PATCH requests always have a JSON body and Content-Type, and — when\n * `autoIdempotencyKey` is on — adds one `Idempotency-Key` per call to POST requests.\n *\n * The key is set once, before the first attempt. The retrying fetch replays the same\n * request, so every automatic retry of a call carries the same key.\n */\nexport function createRequestMiddleware(options: RequestMiddlewareOptions): Middleware {\n const addKeyIfMissing = (request: Request) => {\n if (\n options.autoIdempotencyKey &&\n METHODS_WITH_AUTO_IDEMPOTENCY_KEY.has(request.method) &&\n !request.headers.has(IDEMPOTENCY_KEY_HEADER)\n ) {\n request.headers.set(IDEMPOTENCY_KEY_HEADER, newIdempotencyKey());\n }\n };\n\n return {\n async onRequest({ request }) {\n // Ensure POST/PUT/PATCH always send a JSON body (API rejects empty body)\n if (METHODS_WITH_JSON_BODY.has(request.method)) {\n const hasBody = request.headers.get(CONTENT_TYPE_HEADER)?.includes(JSON_CONTENT_TYPE);\n if (!hasBody) {\n const clone = new Request(request, {\n body: request.body ?? EMPTY_JSON_BODY,\n headers: new Headers(request.headers),\n });\n clone.headers.set(CONTENT_TYPE_HEADER, JSON_CONTENT_TYPE);\n addKeyIfMissing(clone);\n return clone;\n }\n }\n\n addKeyIfMissing(request);\n return request;\n },\n };\n}\n\n/** The request middleware with the default options. */\nexport const requestMiddleware: Middleware = createRequestMiddleware({ autoIdempotencyKey: true });\n\n/**\n * Maps non-2xx responses to typed BeeLApiError subclasses. It sees the final response only:\n * the retrying fetch has already spent the retries by then.\n */\nexport const errorMiddleware: Middleware = {\n async onResponse({ response }) {\n if (!response.ok) {\n const body = await response.json().catch(() => null);\n throwApiError(response.status, body);\n }\n return response;\n },\n};\n","/** HTTP status codes the SDK maps or reacts to. */\nexport const HttpStatus = {\n UNAUTHORIZED: 401,\n FORBIDDEN: 403,\n NOT_FOUND: 404,\n CONFLICT: 409,\n UNPROCESSABLE_ENTITY: 422,\n TOO_MANY_REQUESTS: 429,\n /** First status of the 5xx range: the server failed, not the request. */\n SERVER_ERROR_MIN: 500,\n} as const;\n\n/** Whether `status` is a 5xx. */\nexport function isServerErrorStatus(status: number): boolean {\n return status >= HttpStatus.SERVER_ERROR_MIN;\n}\n","import { HttpStatus } from './http-status';\n\n/** Seconds a {@link BeeLRateLimitError} waits when the body does not say `retry_after`. */\nconst DEFAULT_RATE_LIMIT_RETRY_AFTER_SECONDS = 60;\n\n/**\n * Base error for every non-2xx answer of the BeeL API. The client throws it (or one of its\n * subclasses) from any resource method; a network failure is thrown as the platform's own\n * `fetch` error instead.\n *\n * @example\n * ```typescript\n * try {\n * await company.invoices.issue(invoiceId);\n * } catch (error) {\n * if (error instanceof BeeLApiError) console.error(error.statusCode, error.apiCode, error.requestId);\n * throw error;\n * }\n * ```\n */\nexport class BeeLApiError extends Error {\n /** HTTP status of the response. */\n public readonly statusCode: number;\n /**\n * Stable code of the error class. On the base class it is the API's `error.code`; the\n * subclasses keep a fixed generic value (`CONFLICT`, `NOT_FOUND`…) for backward\n * compatibility. Read {@link apiCode} for the API's specific code.\n */\n public readonly code: string;\n /**\n * The `error.code` the API answered with, verbatim — for example\n * `INVOICE_DUPLICATE_EXTERNAL_REFERENCE`. Equal to {@link code} when the response did not\n * carry one. See {@link BeeLErrorCodes} for the codes this SDK reacts to.\n */\n public readonly apiCode: string;\n /** `error.details` of the response, when the API sent any. */\n public readonly details?: Record<string, string>;\n /** `meta.request_id` of the response. Quote it when you contact support. */\n public readonly requestId?: string;\n\n constructor(\n message: string,\n statusCode: number,\n code: string,\n details?: Record<string, string>,\n requestId?: string,\n apiCode?: string,\n ) {\n super(message);\n this.name = 'BeeLApiError';\n this.statusCode = statusCode;\n this.code = code;\n this.apiCode = apiCode ?? code;\n this.details = details;\n this.requestId = requestId;\n }\n}\n\n/** `429`: rate limit exceeded. Retried automatically, see `maxRetries`. */\nexport class BeeLRateLimitError extends BeeLApiError {\n /** Seconds the API asked to wait before the next request. */\n public readonly retryAfterSeconds: number;\n\n constructor(message: string, retryAfterSeconds: number, requestId?: string, apiCode?: string) {\n super(message, HttpStatus.TOO_MANY_REQUESTS, 'RATE_LIMIT_EXCEEDED', undefined, requestId, apiCode);\n this.name = 'BeeLRateLimitError';\n this.retryAfterSeconds = retryAfterSeconds;\n }\n}\n\n/** `422`: validation or business rule error. `details` names the offending fields. */\nexport class BeeLValidationError extends BeeLApiError {\n constructor(\n message: string,\n details?: Record<string, string>,\n requestId?: string,\n apiCode?: string,\n ) {\n super(message, HttpStatus.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY', details, requestId, apiCode);\n this.name = 'BeeLValidationError';\n }\n}\n\n/** `401` / `403`: the API key is missing or invalid, or lacks access to the resource. */\nexport class BeeLAuthError extends BeeLApiError {\n constructor(message: string, statusCode: 401 | 403, requestId?: string, apiCode?: string) {\n super(\n message,\n statusCode,\n statusCode === HttpStatus.UNAUTHORIZED ? 'UNAUTHORIZED' : 'FORBIDDEN',\n undefined,\n requestId,\n apiCode,\n );\n this.name = 'BeeLAuthError';\n }\n}\n\n/** `404`: the resource does not exist. */\nexport class BeeLNotFoundError extends BeeLApiError {\n constructor(message: string, requestId?: string, apiCode?: string) {\n super(message, HttpStatus.NOT_FOUND, 'NOT_FOUND', undefined, requestId, apiCode);\n this.name = 'BeeLNotFoundError';\n }\n}\n\n/**\n * `409`: conflict — for example `INVOICE_DUPLICATE_EXTERNAL_REFERENCE` or an\n * `Idempotency-Key` reused with another body. Branch on {@link BeeLApiError.apiCode}.\n */\nexport class BeeLConflictError extends BeeLApiError {\n constructor(\n message: string,\n requestId?: string,\n apiCode?: string,\n details?: Record<string, string>,\n ) {\n super(message, HttpStatus.CONFLICT, 'CONFLICT', details, requestId, apiCode);\n this.name = 'BeeLConflictError';\n }\n}\n\n/**\n * Maps a raw HTTP error response to a typed BeeLApiError subclass.\n */\nexport function throwApiError(status: number, body: unknown): never {\n const parsed = body as Record<string, any> | null;\n const errorData = parsed?.error ?? parsed;\n const message = errorData?.message ?? `API error ${status}`;\n const apiCode: string | undefined = errorData?.code;\n const details = errorData?.details;\n const requestId = parsed?.meta?.request_id;\n\n switch (status) {\n case HttpStatus.UNAUTHORIZED:\n case HttpStatus.FORBIDDEN:\n throw new BeeLAuthError(message, status as 401 | 403, requestId, apiCode);\n case HttpStatus.NOT_FOUND:\n throw new BeeLNotFoundError(message, requestId, apiCode);\n case HttpStatus.CONFLICT:\n throw new BeeLConflictError(message, requestId, apiCode, details);\n case HttpStatus.UNPROCESSABLE_ENTITY:\n throw new BeeLValidationError(message, details, requestId, apiCode);\n case HttpStatus.TOO_MANY_REQUESTS: {\n const retryAfter = errorData?.retry_after ?? DEFAULT_RATE_LIMIT_RETRY_AFTER_SECONDS;\n throw new BeeLRateLimitError(message, retryAfter, requestId, apiCode);\n }\n default:\n throw new BeeLApiError(message, status, apiCode ?? 'UNKNOWN', details, requestId);\n }\n}\n","import { BeeLApiError, BeeLRateLimitError } from './errors';\nimport { isServerErrorStatus } from './http-status';\nimport {\n DEFAULT_MAX_RETRIES,\n DEFAULT_MAX_RETRY_DELAY_MS,\n DEFAULT_RETRY_DELAY_MS,\n} from './defaults';\n\nconst MS_PER_SECOND = 1000;\n\nexport interface RetryOptions {\n /** Retries after the first attempt. */\n maxRetries: number;\n /** Base delay of the exponential backoff, in milliseconds. */\n initialDelayMs: number;\n /** Upper bound of any single wait, in milliseconds. */\n maxDelayMs: number;\n}\n\nconst DEFAULT_RETRY_OPTIONS: RetryOptions = {\n maxRetries: DEFAULT_MAX_RETRIES,\n initialDelayMs: DEFAULT_RETRY_DELAY_MS,\n maxDelayMs: DEFAULT_MAX_RETRY_DELAY_MS,\n};\n\n/**\n * Resolves after `ms` milliseconds. With a `signal`, rejects with its reason as soon as it\n * aborts, and clears the timer so it does not keep the process alive.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(signal.reason);\n return;\n }\n const onAbort = () => {\n clearTimeout(timer);\n reject(signal!.reason);\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n\n/**\n * Exponential backoff with jitter: `initialDelayMs × 2^attempt` plus up to one\n * `initialDelayMs` of random jitter, capped at `maxDelayMs`.\n *\n * @param attempt - Zero-based index of the retry about to happen.\n * @param options - Base and cap of the backoff.\n * @param random - Source of jitter in `[0, 1)`; injectable for tests.\n */\nexport function computeBackoffDelayMs(\n attempt: number,\n options: Pick<RetryOptions, 'initialDelayMs' | 'maxDelayMs'>,\n random: () => number = Math.random,\n): number {\n const exponentialDelay = options.initialDelayMs * Math.pow(2, attempt);\n const jitter = random() * options.initialDelayMs;\n return Math.min(exponentialDelay + jitter, options.maxDelayMs);\n}\n\nfunction isRetryable(error: unknown): boolean {\n if (error instanceof BeeLRateLimitError) return true;\n if (error instanceof BeeLApiError) return isServerErrorStatus(error.statusCode);\n return false;\n}\n\nfunction getDelay(error: unknown, attempt: number, options: RetryOptions): number {\n // For rate limit errors, use the server-provided retry-after\n if (error instanceof BeeLRateLimitError) {\n return error.retryAfterSeconds * MS_PER_SECOND;\n }\n return computeBackoffDelayMs(attempt, options);\n}\n\n/**\n * Wraps an async function with automatic retries.\n * Retries on 429 (rate limit) and 5xx (server errors).\n * Does NOT retry on 4xx client errors (400, 401, 403, 404, 422).\n *\n * The HTTP client does not use this helper: its retries live in `http/retrying-fetch.ts`,\n * which also knows whether a request is safe to replay.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n options: Partial<RetryOptions> = {},\n): Promise<T> {\n const opts = { ...DEFAULT_RETRY_OPTIONS, ...options };\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n\n if (attempt >= opts.maxRetries || !isRetryable(error)) {\n throw error;\n }\n\n await sleep(getDelay(error, attempt, opts));\n }\n }\n\n throw lastError;\n}\n","/**\n * `error.code` values of the API that the SDK itself reacts to. Compare them with\n * {@link BeeLApiError.apiCode}. The full catalogue lives in the API reference\n * (https://docs.beel.es); these are the ones this package has behaviour for.\n */\nexport const BeeLErrorCodes = {\n /**\n * `409`: a live standard or simplified invoice with the same `external_ref` already exists\n * in this environment. Look it up with `invoices.list({ external_ref })`.\n */\n INVOICE_DUPLICATE_EXTERNAL_REFERENCE: 'INVOICE_DUPLICATE_EXTERNAL_REFERENCE',\n /**\n * `409`: the first request with this `Idempotency-Key` is still being processed. Retry with\n * the same key after `Retry-After`; the client does so automatically.\n */\n IDEMPOTENCY_KEY_PROCESSING: 'IDEMPOTENCY_KEY_PROCESSING',\n /** `409`: the `Idempotency-Key` was already used with a different body. Use a new key. */\n IDEMPOTENCY_KEY_MISMATCH: 'IDEMPOTENCY_KEY_MISMATCH',\n} as const;\n\n/** One of the {@link BeeLErrorCodes} values. */\nexport type BeeLErrorCode = (typeof BeeLErrorCodes)[keyof typeof BeeLErrorCodes];\n","import { computeBackoffDelayMs, type RetryOptions } from '../core/retry';\nimport { BeeLErrorCodes } from '../core/error-codes';\nimport { HttpStatus, isServerErrorStatus } from '../core/http-status';\nimport { IDEMPOTENCY_KEY_HEADER, IDEMPOTENCY_REPLAY_HEADER, RETRY_AFTER_HEADER } from './headers';\n\nconst MS_PER_SECOND = 1000;\n\n/** Methods that never change state, so replaying them is always safe. */\nconst READ_ONLY_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);\n\n/** Wait the API documents for `IDEMPOTENCY_KEY_PROCESSING` when `Retry-After` is absent. */\nconst IDEMPOTENCY_PROCESSING_DEFAULT_WAIT_MS = 2 * MS_PER_SECOND;\n\n/** What one attempt produced: a response, or the error `fetch` rejected with. */\nexport type AttemptOutcome = { response: Response } | { error: unknown };\n\n/** Whether to try again, and after how long. */\nexport type RetryDecision = { retry: false } | { retry: true; delayMs: number };\n\nconst NO_RETRY: RetryDecision = { retry: false };\n\n/**\n * Whether sending `request` again can never apply its operation twice: it is read-only, or\n * it carries an `Idempotency-Key`, which makes the API replay the first outcome instead of\n * running the operation again.\n */\nexport function isReplaySafe(request: Request): boolean {\n return READ_ONLY_METHODS.has(request.method) || request.headers.has(IDEMPOTENCY_KEY_HEADER);\n}\n\n/**\n * Parses `Retry-After` (delta-seconds or an HTTP date) into milliseconds from `now`.\n * Returns `undefined` when the header is absent or unreadable.\n */\nexport function parseRetryAfterMs(value: string | null, now: number = Date.now()): number | undefined {\n if (value === null || value.trim() === '') return undefined;\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * MS_PER_SECOND);\n const date = Date.parse(value);\n return Number.isNaN(date) ? undefined : Math.max(0, date - now);\n}\n\nfunction isAbort(error: unknown): boolean {\n return error instanceof Error && error.name === 'AbortError';\n}\n\nasync function errorCodeOf(response: Response): Promise<string | undefined> {\n const body = await response.clone().json().catch(() => null);\n return body?.error?.code;\n}\n\n/**\n * Decides whether the client retries an attempt. The rules, in order:\n *\n * 1. `429` — always, after `Retry-After`: the API rejected the request before running it.\n * 2. `409 IDEMPOTENCY_KEY_PROCESSING` — the first request with this key is still in flight;\n * the same key is retried after `Retry-After`.\n * 3. `5xx` — only when {@link isReplaySafe}, and never for a response the API marks with\n * `Idempotency-Replay: true`: that is the stored outcome of the key, and replaying it\n * again would return the same `5xx`.\n * 4. A network error (`fetch` rejected) — only when {@link isReplaySafe}.\n * 5. Anything else — no retry.\n *\n * Never once the request's signal has aborted (caller abort or `timeoutMs`). Every wait is\n * capped at `maxDelayMs`.\n */\nexport async function decideRetry(\n request: Request,\n outcome: AttemptOutcome,\n attempt: number,\n options: Pick<RetryOptions, 'initialDelayMs' | 'maxDelayMs'>,\n): Promise<RetryDecision> {\n const backoff = () => computeBackoffDelayMs(attempt, options);\n const capped = (delayMs: number): RetryDecision => ({\n retry: true,\n delayMs: Math.min(delayMs, options.maxDelayMs),\n });\n\n if (request.signal?.aborted) return NO_RETRY;\n\n if ('error' in outcome) {\n if (isAbort(outcome.error) || !isReplaySafe(request)) return NO_RETRY;\n return capped(backoff());\n }\n\n const { response } = outcome;\n const retryAfterMs = parseRetryAfterMs(response.headers.get(RETRY_AFTER_HEADER));\n\n if (response.status === HttpStatus.TOO_MANY_REQUESTS) {\n return capped(retryAfterMs ?? backoff());\n }\n\n if (\n response.status === HttpStatus.CONFLICT &&\n request.headers.has(IDEMPOTENCY_KEY_HEADER) &&\n (await errorCodeOf(response)) === BeeLErrorCodes.IDEMPOTENCY_KEY_PROCESSING\n ) {\n return capped(retryAfterMs ?? IDEMPOTENCY_PROCESSING_DEFAULT_WAIT_MS);\n }\n\n if (isServerErrorStatus(response.status)) {\n const isStoredReplay = response.headers.get(IDEMPOTENCY_REPLAY_HEADER) === 'true';\n if (isStoredReplay || !isReplaySafe(request)) return NO_RETRY;\n return capped(retryAfterMs ?? backoff());\n }\n\n return NO_RETRY;\n}\n","import { sleep as defaultSleep, type RetryOptions } from '../core/retry';\nimport { decideRetry, type AttemptOutcome } from './retry-policy';\n\n/** The subset of `fetch` the client calls. */\nexport type FetchLike = (request: Request, init?: RequestInit) => Promise<Response>;\n\nexport interface RetryingFetchDependencies {\n /** Performs one attempt. Defaults to the global `fetch`, looked up on every call. */\n fetch?: FetchLike;\n /** Waits between attempts; rejects when the signal aborts. Injectable so tests do not sleep. */\n sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;\n}\n\nconst globalFetch: FetchLike = (request, init) => globalThis.fetch(request, init);\n\n/** Releases the body of an attempt that will not be returned, so its socket is freed. */\nasync function discard(response: Response): Promise<void> {\n await response.body?.cancel().catch(() => undefined);\n}\n\n/**\n * Wraps `fetch` with the SDK's automatic retries (see `decideRetry` for when). Every attempt\n * sends a clone of the same `Request`, so a retry carries the very same headers — the\n * `Idempotency-Key` included — and body as the first attempt.\n *\n * It returns the last response, successful or not, and leaves mapping a non-2xx to a typed\n * error to the error middleware. It rethrows the last network error. An aborted request\n * signal stops it at once, between attempts too, with the signal's reason.\n */\nexport function createRetryingFetch(\n options: RetryOptions,\n dependencies: RetryingFetchDependencies = {},\n): FetchLike {\n const attemptFetch = dependencies.fetch ?? globalFetch;\n const wait = dependencies.sleep ?? defaultSleep;\n\n return async (request, init) => {\n for (let attempt = 0; ; attempt++) {\n let outcome: AttemptOutcome;\n try {\n outcome = { response: await attemptFetch(request.clone(), init) };\n } catch (error) {\n outcome = { error };\n }\n\n const decision =\n attempt < options.maxRetries\n ? await decideRetry(request, outcome, attempt, options)\n : ({ retry: false } as const);\n\n if (!decision.retry) {\n if ('error' in outcome) throw outcome.error;\n return outcome.response;\n }\n\n if ('response' in outcome) await discard(outcome.response);\n await wait(decision.delayMs, request.signal ?? undefined);\n }\n };\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype Invoice = components['schemas']['Invoice'];\ntype Pagination = components['schemas']['Pagination'];\ntype ListParams = operations['listInvoices']['parameters']['query'];\n\n/**\n * Invoices of the focused company, on the flat `/v1/invoices` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).invoices` instead.\n */\nexport class InvoicesResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List invoices with optional filters and pagination.\n *\n * @param params - Filters and pagination.\n * @returns The page of `invoices` and its `pagination`.\n *\n * @example\n * const { invoices, pagination } = await beel.invoices.list({ status: 'ISSUED', limit: 20 });\n */\n async list(params?: ListParams) {\n const { data } = await this.client.GET('/v1/invoices', { params: { query: params } });\n return data!.data as { invoices: Invoice[]; pagination: Pagination };\n }\n\n /**\n * Create a new invoice. An idempotency key is automatically added.\n *\n * @param body - Type, recipient and lines.\n * @returns The created invoice.\n *\n * @example\n * const invoice = await beel.invoices.create({\n * type: 'STANDARD',\n * recipient: { customer_id: 'uuid' },\n * lines: [{ description: 'Service', quantity: 1, unit_price: 100, discount_percentage: 0 }],\n * });\n */\n async create(body: components['schemas']['CreateInvoiceRequest']) {\n const { data } = await this.client.POST('/v1/invoices', { body });\n return data!.data as Invoice;\n }\n\n /**\n * Get an invoice by ID.\n *\n * @param id - Invoice UUID.\n * @returns The invoice.\n */\n async get(id: string) {\n const { data } = await this.client.GET('/v1/invoices/{invoice_id}', { params: { path: { invoice_id: id } } });\n return data!.data as Invoice;\n }\n\n /**\n * Update a draft invoice. Only draft invoices can be updated.\n *\n * @param id - Invoice UUID.\n * @param body - The draft's new content.\n * @returns The updated invoice.\n */\n async update(id: string, body: components['schemas']['UpdateInvoiceRequest']) {\n const { data } = await this.client.PUT('/v1/invoices/{invoice_id}', { params: { path: { invoice_id: id } }, body });\n return data!.data as Invoice;\n }\n\n /**\n * Delete a draft invoice. Only draft invoices can be deleted.\n *\n * @param id - Invoice UUID.\n */\n async delete(id: string) {\n await this.client.DELETE('/v1/invoices/{invoice_id}', { params: { path: { invoice_id: id } } });\n }\n\n /**\n * Duplicate an invoice, optionally into a different series.\n *\n * @param id - Invoice UUID.\n * @param options - `series_id` and `notes` of the copy.\n * @returns The new draft.\n */\n async duplicate(id: string, options?: { series_id?: string; notes?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/duplicate', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data as Invoice;\n }\n\n /**\n * Issue a draft invoice. Assigns an invoice number and triggers VeriFactu submission.\n *\n * @param id - Invoice UUID.\n * @param options - `wait_for_pdf: true` to wait for the PDF.\n * @returns The issued invoice.\n */\n async issue(id: string, options?: { wait_for_pdf?: boolean }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/issue', { params: { path: { invoice_id: id }, query: options } });\n return data!.data as Invoice;\n }\n\n /**\n * Mark an invoice as paid.\n *\n * @param id - Invoice UUID.\n * @param options - `payment_date` (default: today) and `payment_method`.\n * @returns The paid invoice.\n */\n async markPaid(id: string, options?: { payment_date?: string; payment_method?: any }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/mark-paid', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data as Invoice;\n }\n\n /**\n * Mark an invoice as sent (e.g. delivered by other means).\n *\n * @param id - Invoice UUID.\n * @param options - `sent_at`.\n * @returns The sent invoice.\n */\n async markSent(id: string, options?: { sent_at?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/mark-sent', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data as Invoice;\n }\n\n /**\n * Revert a paid/sent invoice back to issued status.\n *\n * @param id - Invoice UUID.\n * @returns The invoice, back in `ISSUED`.\n */\n async revertToIssued(id: string) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/revert-to-issued', { params: { path: { invoice_id: id } } });\n return data!.data as Invoice;\n }\n\n /**\n * Void an issued invoice. Requires a reason (min 10 chars).\n *\n * @param id - Invoice UUID.\n * @param params - `reason` (min 10 characters) and optional `void_date`.\n * @returns The voided invoice.\n *\n * @example\n * await beel.invoices.void('id', { reason: 'Duplicate invoice sent in error' });\n */\n async void(id: string, params: { reason: string; void_date?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/void', { params: { path: { invoice_id: id } }, body: params as any });\n return data!.data as Invoice;\n }\n\n /**\n * Create a corrective invoice that references the original.\n *\n * @param id - UUID of the issued invoice to correct.\n * @param body - Rectification type, code, reason and lines.\n * @returns The corrective invoice.\n */\n async createCorrective(id: string, body: components['schemas']['CreateCorrectiveInvoiceRequest']) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/corrective', { params: { path: { invoice_id: id } }, body });\n return data!.data as Invoice;\n }\n\n /**\n * Schedule a draft invoice to be issued on a future date.\n *\n * @param id - UUID of the draft.\n * @param params - `scheduled_for` and optional `action`.\n * @returns The scheduled invoice.\n */\n async schedule(id: string, params: { scheduled_for: string; action?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/schedule', { params: { path: { invoice_id: id } }, body: params as any });\n return data!.data as Invoice;\n }\n\n /**\n * Cancel a scheduled invoice, returning it to draft.\n *\n * @param id - Invoice UUID.\n * @returns The invoice, back in draft.\n */\n async unschedule(id: string) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/unschedule', { params: { path: { invoice_id: id } } });\n return data!.data as Invoice;\n }\n\n /**\n * Change the scheduled date of a scheduled invoice.\n *\n * @param id - Invoice UUID.\n * @param params - New `scheduled_for`.\n * @returns The rescheduled invoice.\n */\n async reschedule(id: string, params: { scheduled_for: string }) {\n const { data } = await this.client.PATCH('/v1/invoices/{invoice_id}/reschedule', { params: { path: { invoice_id: id } }, body: params as any });\n return data!.data as Invoice;\n }\n\n /**\n * Get a pre-signed URL to download the invoice PDF.\n * The URL expires in 5 minutes. Use `beel.downloadPdf(id)` for a simpler Buffer download.\n *\n * @param id - Invoice UUID.\n * @returns `download_url`, `expires_in_seconds` and `file_name`.\n */\n async getPdf(id: string) {\n const { data } = await this.client.GET('/v1/invoices/{invoice_id}/pdf', { params: { path: { invoice_id: id } } });\n return data!.data as { download_url: string; expires_in_seconds: number; file_name: string };\n }\n\n /**\n * Send an invoice by email. Uses the customer's email by default.\n *\n * @param id - Invoice UUID.\n * @param options - Recipients, subject and message.\n * @returns The delivery record.\n */\n async sendEmail(id: string, options?: { to?: string[]; cc?: string[]; subject?: string; message?: string }) {\n const { data } = await this.client.POST('/v1/invoices/{invoice_id}/send', { params: { path: { invoice_id: id } }, body: options as any });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype Customer = components['schemas']['Customer'];\ntype Pagination = components['schemas']['Pagination'];\ntype ListParams = operations['listCustomers']['parameters']['query'];\n\n/**\n * Customers of the focused company, on the flat `/v1/customers` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).customers` instead.\n */\nexport class CustomersResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List customers with optional filters and pagination.\n *\n * @param params - Filters and pagination.\n * @returns The page of `customers` and its `pagination`.\n *\n * @example\n * const { customers, pagination } = await beel.customers.list({ search: 'Acme', limit: 10 });\n */\n async list(params?: ListParams) {\n const { data } = await this.client.GET('/v1/customers', { params: { query: params } });\n return data!.data as { customers: Customer[]; pagination: Pagination };\n }\n\n /**\n * Create a new customer.\n *\n * @param body - Legal name, NIF and address.\n * @returns The created customer.\n *\n * @example\n * const customer = await beel.customers.create({\n * legal_name: 'Acme SL',\n * nif: 'B12345678',\n * address: { street: 'Calle Mayor', number: '1', postal_code: '28001', city: 'Madrid', province: 'Madrid', country: 'Spain', country_code: 'ES' },\n * });\n */\n async create(body: components['schemas']['CreateCustomerRequest']) {\n const { data } = await this.client.POST('/v1/customers', { body });\n return data!.data as Customer;\n }\n\n /**\n * Get a customer by ID.\n *\n * @param id - Customer UUID.\n * @returns The customer.\n */\n async get(id: string) {\n const { data } = await this.client.GET('/v1/customers/{customer_id}', { params: { path: { customer_id: id } } });\n return data!.data as Customer;\n }\n\n /**\n * Update a customer. Only provided fields are changed.\n *\n * @param id - Customer UUID.\n * @param body - Fields to change.\n * @returns The updated customer.\n */\n async update(id: string, body: components['schemas']['UpdateCustomerRequest']) {\n const { data } = await this.client.PUT('/v1/customers/{customer_id}', { params: { path: { customer_id: id } }, body });\n return data!.data as Customer;\n }\n\n /**\n * Deactivate (soft-delete) a customer.\n *\n * @param id - Customer UUID.\n */\n async deactivate(id: string) {\n await this.client.DELETE('/v1/customers/{customer_id}', { params: { path: { customer_id: id } } });\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype Product = components['schemas']['Product'];\ntype Pagination = components['schemas']['Pagination'];\ntype ListParams = operations['listProducts']['parameters']['query'];\n\n/**\n * Products of the focused company, on the flat `/v1/products` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).products` instead.\n */\nexport class ProductsResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List products with optional filters and pagination.\n *\n * @param params - Filters and pagination.\n * @returns The page of `products` and its `pagination`.\n *\n * @example\n * const { products, pagination } = await beel.products.list({ category: 'SERVICE' });\n */\n async list(params?: ListParams) {\n const { data } = await this.client.GET('/v1/products', { params: { query: params } });\n return data!.data as { products: Product[]; pagination: Pagination };\n }\n\n /**\n * Create a new product or service.\n *\n * @param body - Name, category, price and main tax.\n * @returns The created product.\n *\n * @example\n * const product = await beel.products.create({\n * name: 'Consulting',\n * code: 'CONS-001',\n * category: 'SERVICE',\n * default_price: 100,\n * main_tax: { type: 'IVA', percentage: 21 },\n * });\n */\n async create(body: components['schemas']['CreateProductRequest']) {\n const { data } = await this.client.POST('/v1/products', { body });\n return data!.data as Product;\n }\n\n /**\n * Get a product by ID.\n *\n * @param id - Product UUID.\n * @returns The product.\n */\n async get(id: string) {\n const { data } = await this.client.GET('/v1/products/{product_id}', { params: { path: { product_id: id } } });\n return data!.data as Product;\n }\n\n /**\n * Update a product. Only provided fields are changed.\n *\n * @param id - Product UUID.\n * @param body - Fields to change.\n * @returns The updated product.\n */\n async update(id: string, body: components['schemas']['UpdateProductRequest']) {\n const { data } = await this.client.PUT('/v1/products/{product_id}', { params: { path: { product_id: id } }, body });\n return data!.data as Product;\n }\n\n /**\n * Delete a product permanently.\n *\n * @param id - Product UUID.\n */\n async delete(id: string) {\n await this.client.DELETE('/v1/products/{product_id}', { params: { path: { product_id: id } } });\n }\n\n /**\n * Search products by name or code. Returns up to `limit` results.\n *\n * @param q - Text to search in name or code.\n * @param limit - Maximum results.\n * @returns The matching products, as a bare array.\n *\n * @example\n * const results = await beel.products.search('consulting', 5);\n */\n async search(q: string, limit?: number) {\n const { data } = await this.client.GET('/v1/products/search', { params: { query: { q, limit } } });\n return data!.data as Product[];\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components } from '../generated/schema';\n\n/**\n * Account-wide configuration on the flat `/v1/configuration/*` routes.\n *\n * @deprecated The contract deprecates these routes. Use\n * `beel.company(companyId).taxConfiguration`, `beel.company(companyId).verifactuConfiguration`\n * and {@link CatalogsResource} (`beel.catalogs`) instead.\n */\nexport class ConfigurationResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * Get the tax configuration (default VAT, IRPF…) of the focused company.\n *\n * @returns The tax configuration.\n */\n async getTaxConfig() {\n const { data } = await this.client.GET('/v1/configuration/taxes');\n return data!.data;\n }\n\n /**\n * Replace the tax configuration of the focused company.\n *\n * @param body - The complete tax configuration.\n * @returns The stored configuration.\n */\n async updateTaxConfig(body: any) {\n const { data } = await this.client.PUT('/v1/configuration/taxes', { body });\n return data!.data;\n }\n\n /**\n * Tax types the API accepts (IVA/IGIC rates, IRPF types, equivalence surcharges).\n *\n * @returns The tax types catalog.\n */\n async getTaxTypes() {\n const { data } = await this.client.GET('/v1/configuration/tax-types');\n return data!.data;\n }\n\n /**\n * Invoice customization options (templates, colors…).\n *\n * @returns The customization options.\n */\n async getInvoiceCustomizationOptions() {\n const { data } = await this.client.GET('/v1/configuration/invoice-customization-options');\n return data!.data;\n }\n\n /**\n * Update the preferred language of the signed-in person.\n *\n * @param language - `es`, `en` or `ca`.\n * @returns The updated preferences.\n */\n async updateLanguage(language: string) {\n const { data } = await this.client.PUT('/v1/configuration/language', { body: { language } as any });\n return data!.data;\n }\n\n /**\n * Get the VeriFactu configuration of the focused company.\n *\n * @returns The VeriFactu configuration.\n */\n async getVerifactu() {\n const { data } = await this.client.GET('/v1/configuration/verifactu');\n return data!.data;\n }\n\n /**\n * Update the VeriFactu configuration of the focused company.\n *\n * @param body - `{ enabled }`.\n * @returns The updated configuration.\n */\n async updateVerifactu(body: any) {\n const { data } = await this.client.PUT('/v1/configuration/verifactu', { body });\n return data!.data;\n }\n}\n\n/**\n * Account-wide catalogs, the credential's identity and personal preferences, on their\n * canonical paths. Reach it as `beel.catalogs`.\n *\n * These replace the `/v1/configuration/*` reads on {@link ConfigurationResource},\n * whose flat routes are deprecated.\n */\nexport class CatalogsResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * Who the API key belongs to: its `account_id` — the starting point to list the\n * account's companies — plus the person's email, name and language, and the credential.\n * Needs no scope, so it also confirms that a key works.\n *\n * @returns The identity of the credential.\n *\n * @example\n * ```typescript\n * const { account_id } = await beel.catalogs.identity();\n * const { companies } = await beel.account(account_id).companies.list();\n * ```\n */\n async identity() {\n const { data } = await this.client.GET('/v1/me/identity');\n return data!.data as components['schemas']['MyIdentity'];\n }\n\n /**\n * Tax types the API accepts. Canonical form of `configuration/tax-types`.\n *\n * @returns The tax types catalog.\n */\n async taxTypes() {\n const { data } = await this.client.GET('/v1/tax-types');\n return data!.data;\n }\n\n /**\n * Invoice PDF templates and customization options. Canonical form of the `configuration` read.\n *\n * @returns The customization options.\n */\n async invoiceCustomizationOptions() {\n const { data } = await this.client.GET('/v1/invoice-customization-options');\n return data!.data;\n }\n\n /**\n * Update the signed-in person's preferences. Canonical form of\n * `PUT /v1/configuration/language`: the language belongs to the person, not to a company.\n *\n * @param body - Preferences to change, e.g. `{ language: 'es' }`.\n * @returns The updated preferences.\n */\n async updateMe(body: components['schemas']['UpdateMeRequest']) {\n const { data } = await this.client.PATCH('/v1/me', { body });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\n\n/**\n * Invoice series of the focused company, on the flat `/v1/configuration/series` routes.\n *\n * @deprecated The contract deprecates the session-focus routes. Use `beel.company(companyId).series` instead.\n */\nexport class SeriesResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List all invoice series. Optionally filter by active status.\n *\n * @param active - Only active (`true`) or inactive (`false`) series; all when omitted.\n * @returns The series.\n *\n * @example\n * const series = await beel.series.list();\n * const activeSeries = await beel.series.list(true);\n */\n async list(active?: boolean) {\n const { data } = await this.client.GET('/v1/configuration/series', {\n params: { query: active !== undefined ? { active } : undefined },\n });\n return data!.data;\n }\n\n /**\n * Create a new invoice series (e.g. \"A-2026\", \"RECT\").\n *\n * @param body - Code, name and format.\n * @returns The created series.\n */\n async create(body: any) {\n const { data } = await this.client.POST('/v1/configuration/series', { body });\n return data!.data;\n }\n\n /**\n * Update a series (name, description, etc.).\n *\n * @param id - Series UUID.\n * @param body - Fields to change.\n * @returns The updated series.\n */\n async update(id: string, body: any) {\n const { data } = await this.client.PUT('/v1/configuration/series/{series_id}', {\n params: { path: { series_id: id } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Delete an invoice series. Only empty series can be deleted.\n *\n * @param id - Series UUID.\n */\n async delete(id: string) {\n await this.client.DELETE('/v1/configuration/series/{series_id}', {\n params: { path: { series_id: id } },\n });\n }\n\n /**\n * Set a series as the default for new invoices.\n *\n * @param id - Series UUID.\n * @returns The series.\n */\n async setDefault(id: string) {\n const { data } = await this.client.POST('/v1/configuration/series/{series_id}/default', {\n params: { path: { series_id: id } },\n });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\n\n/**\n * NIF validation against the AEAT register. Reach it as `beel.nif`.\n */\nexport class NifResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * Validate a Spanish NIF/CIF against the AEAT tax registry.\n *\n * @param nif - The NIF/CIF to validate.\n * @returns Whether it is valid and, when the register knows it, its holder's name.\n *\n * @example\n * const result = await beel.nif.validate('B12345678');\n * console.log(result.valid, result.name);\n */\n async validate(nif: string) {\n const { data } = await this.client.POST('/v1/nif/validate', { body: { nif } as any });\n return data!.data;\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype ManagedAccountSummary = components['schemas']['ManagedAccountSummary'];\ntype ProvisionAccountResult = components['schemas']['ProvisionAccountResult'];\ntype AccountMember = components['schemas']['AccountMember'];\ntype Invitation = components['schemas']['Invitation'];\ntype WebhookSubscription = components['schemas']['WebhookSubscription'];\ntype ProvisioningUsage = components['schemas']['ProvisioningUsage'];\ntype CompanyData = components['schemas']['CompanyData'];\ntype Pagination = components['schemas']['Pagination'];\n\n/**\n * Accounts you provisioned and manage (multi-account provisioning for platforms and\n * advisory firms). Reach it as `beel.accounts`; scope one with `beel.account(accountId)`.\n *\n * Every method rejects with a `BeeLApiError` subclass when the API answers non-2xx.\n *\n * @example\n * ```typescript\n * const { accounts } = await beel.accounts.list();\n * const account = beel.accounts.scope(accounts[0].account_id);\n * const members = await account.members.list();\n * ```\n */\nexport class AccountsResource {\n constructor(private client: BeeLClient) {}\n\n /**\n * List the accounts you provisioned, newest first. Cursor-paginated: pass the\n * `next_cursor` of one page as `cursor` of the next until it is `null`.\n *\n * @param params - `status`, `external_ref` (exact), `limit`, `cursor`.\n * @returns The `accounts` of the page and `next_cursor`.\n */\n async list(params?: operations['listAccounts']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts', { params: { query: params } });\n return data!.data as { accounts: ManagedAccountSummary[]; next_cursor?: string | null };\n }\n\n /**\n * Provision a new managed account. Idempotent by `external_ref`: sending the same one\n * again returns the same account. Answers with the provisioning result — the account id,\n * its status and, when one is issued, the claim link — not with the account summary.\n *\n * @param body - `external_ref` and the holder's details.\n * @returns `account_id`, `status` and the claim link state.\n */\n async provision(body: operations['provisionAccount']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts', { body });\n return data!.data as ProvisionAccountResult;\n }\n\n /**\n * Get a managed account.\n *\n * @param accountId - Account UUID.\n * @returns The account summary.\n */\n async get(accountId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}', {\n params: { path: { account_id: accountId } },\n });\n return data!.data as ManagedAccountSummary;\n }\n\n /**\n * Alias of `beel.account(accountId)`: the operations scoped to one account.\n *\n * @param accountId - Account UUID.\n * @returns The account scope. No request is made.\n */\n scope(accountId: string): AccountScope {\n return new AccountScope(this.client, accountId);\n }\n}\n\n/**\n * Operations scoped to one account: its companies (NIFs), members, invitations, webhooks\n * and usage. Reach it as `beel.account(accountId)`.\n *\n * @example\n * ```typescript\n * const { companies } = await beel.account('account-uuid').companies.list();\n * const company = beel.company(companies[0].id!);\n * ```\n */\nexport class AccountScope {\n /** Members of the account and their per-company grants. */\n readonly members: AccountMembersResource;\n /** Invitations to join the account. */\n readonly invitations: AccountInvitationsResource;\n /** Webhook subscriptions of the account. */\n readonly webhooks: AccountWebhooksResource;\n /** Companies (NIFs) of the account — where company ids come from. */\n readonly companies: AccountCompaniesResource;\n\n constructor(private client: BeeLClient, readonly accountId: string) {\n this.members = new AccountMembersResource(client, accountId);\n this.invitations = new AccountInvitationsResource(client, accountId);\n this.webhooks = new AccountWebhooksResource(client, accountId);\n this.companies = new AccountCompaniesResource(client, accountId);\n }\n\n private path() {\n return { account_id: this.accountId };\n }\n\n /**\n * Get the account summary.\n *\n * @returns The account summary.\n */\n async get() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}', { params: { path: this.path() } });\n return data!.data as ManagedAccountSummary;\n }\n\n /**\n * Provisioning usage counters for billing: provisioned accounts and NIFs.\n *\n * @returns `provisioned_accounts` and `nifs`.\n */\n async usage() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/usage', { params: { path: this.path() } });\n return data!.data as ProvisioningUsage;\n }\n\n /**\n * Change the access level you keep over this account. Raising it is only possible while\n * the account is unclaimed.\n *\n * @param body - The new `access_level`.\n */\n async changeAccessLevel(body: NonNullable<operations['changeManagedAccountAccessLevel']['requestBody']>['content']['application/json']) {\n await this.client.PATCH('/v1/accounts/{account_id}/access-level', {\n params: { path: this.path() },\n body,\n });\n }\n\n /**\n * End your management of this account: you lose access, and the holder keeps the\n * account, its NIFs and its invoices.\n */\n async endManagement() {\n await this.client.DELETE('/v1/accounts/{account_id}/management', { params: { path: this.path() } });\n }\n\n /**\n * Issue a single-use claim token so the account's holder can take ownership.\n *\n * @param body - `email` when the account has no holder yet; omit to re-issue.\n * @returns `claim_token`, `claim_url` and `expires_at`.\n */\n async createClaimToken(body?: NonNullable<operations['createAccountClaimToken']['requestBody']>['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/claim-tokens', {\n params: { path: this.path() },\n body: body ?? {},\n });\n return data!.data;\n }\n\n /**\n * Make an existing member the account's owner. Repeatable: it states the desired owner.\n *\n * @param body - The member that becomes owner.\n */\n async setOwner(body: operations['putAccountOwner']['requestBody']['content']['application/json']) {\n await this.client.PUT('/v1/accounts/{account_id}/owner', {\n params: { path: this.path() },\n body,\n });\n }\n}\n\n/**\n * Members of an account and their per-company grants. Reach it as\n * `beel.account(accountId).members`.\n */\nexport class AccountMembersResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the account's members.\n *\n * @returns The members (`data.members` of the response), as an array.\n */\n async list() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/members', {\n params: { path: { account_id: this.accountId } },\n });\n return (data!.data as { members: AccountMember[] }).members;\n }\n\n /**\n * Get one member.\n *\n * @param memberId - Member UUID.\n * @returns The member.\n */\n async get(memberId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/members/{member_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n });\n return data!.data as AccountMember;\n }\n\n /**\n * Change a member's account role.\n *\n * @param memberId - Member UUID.\n * @param body - The new `account_role`.\n * @returns The updated member.\n */\n async update(memberId: string, body: operations['patchAccountMember']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/accounts/{account_id}/members/{member_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n body,\n });\n return data!.data as AccountMember;\n }\n\n /**\n * Remove a member from the account.\n *\n * @param memberId - Member UUID.\n */\n async remove(memberId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/members/{member_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n });\n }\n\n /**\n * List a member's per-company grants.\n *\n * @param memberId - Member UUID.\n * @returns The `grants` and their `pagination`.\n */\n async listGrants(memberId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/members/{member_id}/grants', {\n params: { path: { account_id: this.accountId, member_id: memberId } },\n });\n return data!.data;\n }\n\n /**\n * Grant a member access to one company, or replace the grant it has.\n *\n * @param memberId - Member UUID.\n * @param companyId - Company UUID.\n * @param body - The `access_level` to grant.\n * @returns The grant.\n */\n async putGrant(\n memberId: string,\n companyId: string,\n body: operations['putAccountMemberGrant']['requestBody']['content']['application/json'],\n ) {\n const { data } = await this.client.PUT('/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Revoke a member's access to one company.\n *\n * @param memberId - Member UUID.\n * @param companyId - Company UUID.\n */\n async removeGrant(memberId: string, companyId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/members/{member_id}/grants/{company_id}', {\n params: { path: { account_id: this.accountId, member_id: memberId, company_id: companyId } },\n });\n }\n}\n\n/** Invitations to join an account. Reach it as `beel.account(accountId).invitations`. */\nexport class AccountInvitationsResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the account's invitations.\n *\n * @returns The invitations.\n */\n async list() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/invitations', {\n params: { path: { account_id: this.accountId } },\n });\n return data!.data;\n }\n\n /**\n * Invite someone to join the account.\n *\n * @param body - `invited_email` and the `account_role` to grant.\n * @returns The invitation.\n */\n async create(body: operations['createAccountInvitation']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/invitations', {\n params: { path: { account_id: this.accountId } },\n body,\n });\n return data!.data as Invitation;\n }\n\n /**\n * Get one invitation.\n *\n * @param invitationId - Invitation UUID.\n * @returns The invitation.\n */\n async get(invitationId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/invitations/{invitation_id}', {\n params: { path: { account_id: this.accountId, invitation_id: invitationId } },\n });\n return data!.data;\n }\n\n /**\n * Revoke a `PENDING` invitation, so its link stops working.\n *\n * @param invitationId - Invitation UUID.\n */\n async revoke(invitationId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/invitations/{invitation_id}', {\n params: { path: { account_id: this.accountId, invitation_id: invitationId } },\n });\n }\n}\n\n/**\n * Webhook subscriptions of an account. Reach it as `beel.account(accountId).webhooks`;\n * verify deliveries with `WebhookVerifier`.\n */\nexport class AccountWebhooksResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the webhook subscriptions.\n *\n * @param params - Pagination.\n * @returns The `webhooks` and their `pagination`.\n */\n async list(params?: operations['listAccountWebhookSubscriptions']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/webhooks', {\n params: { path: { account_id: this.accountId }, query: params },\n });\n return data!.data as { webhooks?: WebhookSubscription[]; pagination?: Pagination };\n }\n\n /**\n * Subscribe an HTTPS endpoint to events.\n *\n * @param body - `url` and the `events` to receive.\n * @returns The subscription, with its signing secret.\n */\n async create(body: operations['createAccountWebhookSubscription']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks', {\n params: { path: { account_id: this.accountId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Get one webhook subscription.\n *\n * @param webhookId - Subscription UUID.\n * @returns The subscription.\n */\n async get(webhookId: string) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/webhooks/{webhook_id}', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n return data!.data as WebhookSubscription;\n }\n\n /**\n * Update a webhook subscription. Only the fields present in `body` change.\n *\n * @param webhookId - Subscription UUID.\n * @param body - Fields to change.\n * @returns The updated subscription.\n */\n async update(webhookId: string, body: operations['patchAccountWebhookSubscription']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/accounts/{account_id}/webhooks/{webhook_id}', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n body,\n });\n return data!.data as WebhookSubscription;\n }\n\n /**\n * Delete a webhook subscription.\n *\n * @param webhookId - Subscription UUID.\n */\n async delete(webhookId: string) {\n await this.client.DELETE('/v1/accounts/{account_id}/webhooks/{webhook_id}', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n }\n\n /**\n * Send a test event to the endpoint. Test deliveries carry `test: true`.\n *\n * @param webhookId - Subscription UUID.\n * @returns The outcome of the delivery.\n */\n async test(webhookId: string) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks/{webhook_id}/test', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n return data!.data;\n }\n\n /**\n * Rotate the signing secret. The old secret stops working immediately.\n *\n * @param webhookId - Subscription UUID.\n * @returns The subscription with its new secret.\n */\n async rotateSecret(webhookId: string) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks/{webhook_id}/secret', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId } },\n });\n return data!.data;\n }\n\n /**\n * List the delivery attempts of a subscription.\n *\n * @param webhookId - Subscription UUID.\n * @param params - Filters and pagination.\n * @returns The deliveries.\n */\n async listDeliveries(webhookId: string, params?: operations['listAccountWebhookDeliveries']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId }, query: params },\n });\n return data!.data;\n }\n\n /**\n * Retry a failed delivery.\n *\n * @param webhookId - Subscription UUID.\n * @param deliveryId - Delivery UUID.\n * @returns The new delivery attempt.\n */\n async retryDelivery(webhookId: string, deliveryId: string) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries/{delivery_id}/retry', {\n params: { path: { account_id: this.accountId, webhook_id: webhookId, delivery_id: deliveryId } },\n });\n return data!.data;\n }\n}\n\n/**\n * Companies (NIFs) of an account — where the `companyId` of `beel.company(companyId)`\n * comes from. Reach it as `beel.account(accountId).companies`.\n */\nexport class AccountCompaniesResource {\n constructor(private client: BeeLClient, private accountId: string) {}\n\n /**\n * List the account's companies, primary first. Always paginated (20 by default).\n *\n * @param params - `search`, `include`, `page`, `limit`.\n * @returns The `companies` of the page and its `pagination`.\n *\n * @example\n * ```typescript\n * const { account_id } = await beel.catalogs.identity();\n * const { companies } = await beel.account(account_id).companies.list({ search: 'B12345678' });\n * const company = beel.company(companies[0].id!);\n * ```\n */\n async list(params?: operations['listCompanies']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/companies', {\n params: { path: { account_id: this.accountId }, query: params },\n });\n // The collection is wrapped: `data.companies` + `data.pagination`, not a bare array.\n return {\n companies: (data!.data?.companies ?? []) as CompanyData[],\n pagination: data!.data?.pagination as Pagination | undefined,\n };\n }\n\n /**\n * Register a new company (NIF) under the account.\n *\n * @param body - NIF, legal name, entity type and address.\n * @returns The created company.\n */\n async create(body: components['schemas']['CreateCompanyRequest']) {\n const { data } = await this.client.POST('/v1/accounts/{account_id}/companies', {\n params: { path: { account_id: this.accountId } },\n body,\n });\n return data!.data as CompanyData;\n }\n\n /**\n * Per-company invoice stats: how many fiscal documents each issued, and when last.\n *\n * @returns One entry per company.\n */\n async stats() {\n const { data } = await this.client.GET('/v1/accounts/{account_id}/companies/stats', {\n params: { path: { account_id: this.accountId } },\n });\n return data!.data;\n }\n}\n","import { IDEMPOTENCY_KEY_HEADER } from './headers';\n\n/**\n * Per-call options, accepted as the last argument of the `company.invoices` methods.\n *\n * @example\n * ```typescript\n * await company.invoices.create(body, undefined, {\n * idempotencyKey: `order-${order.id}`,\n * timeoutMs: 15_000,\n * });\n * ```\n */\nexport interface RequestOptions {\n /**\n * `Idempotency-Key` of this call, instead of the automatic one: letters, digits, `_` and\n * `-`, up to 255 characters. Every automatic retry of the call reuses it. Persist it with\n * your order to retry the same operation later: within 24 hours the API replays the first\n * `2xx` or `5xx` answer instead of running the operation again.\n */\n idempotencyKey?: string;\n /** Aborts the call — the automatic retries and the waits between them included. */\n signal?: AbortSignal;\n /** Aborts the call after this many milliseconds, automatic retries included. */\n timeoutMs?: number;\n}\n\n/** The part of openapi-fetch's per-request init that {@link RequestOptions} maps to. */\nexport interface RequestInitOverrides {\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\ntype AbortSignalWithAny = typeof AbortSignal & { any?: (signals: AbortSignal[]) => AbortSignal };\n\n/** An `AbortSignal` that aborts as soon as any of `signals` does. */\nexport function anySignal(signals: AbortSignal[]): AbortSignal {\n const native = (AbortSignal as AbortSignalWithAny).any;\n if (native) return native(signals);\n\n const controller = new AbortController();\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n break;\n }\n signal.addEventListener('abort', () => controller.abort(signal.reason), { once: true });\n }\n return controller.signal;\n}\n\nfunction signalOf(options: RequestOptions): AbortSignal | undefined {\n const signals: AbortSignal[] = [];\n if (options.signal) signals.push(options.signal);\n if (options.timeoutMs !== undefined) signals.push(AbortSignal.timeout(options.timeoutMs));\n if (signals.length <= 1) return signals[0];\n return anySignal(signals);\n}\n\n/**\n * Maps {@link RequestOptions} to the `headers` and `signal` of one openapi-fetch call.\n * Returns an empty object when there are no options, so it can always be spread.\n */\nexport function toRequestInit(options?: RequestOptions): RequestInitOverrides {\n if (!options) return {};\n const init: RequestInitOverrides = {};\n if (options.idempotencyKey !== undefined) {\n init.headers = { [IDEMPOTENCY_KEY_HEADER]: options.idempotencyKey };\n }\n const signal = signalOf(options);\n if (signal) init.signal = signal;\n return init;\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\n\ntype ManagedPaymentConnection = components['schemas']['ManagedPaymentConnection'];\ntype CompanyPaymentConnection = components['schemas']['CompanyPaymentConnection'];\ntype ManagedPaymentEvent = components['schemas']['ManagedPaymentEvent'];\ntype Pagination = components['schemas']['Pagination'];\ntype PaymentEventCounts = components['schemas']['PaymentEventCounts'];\n\n/**\n * Payment connections of a company (NIF): the Stripe Connect link whose charges\n * auto-generate invoices under that NIF.\n *\n * A connection is addressed by **its own UUID**, not by the provider slug — a NIF can\n * hold several connections of the same provider, so the slug does not name one. Take\n * `id` from {@link list}. The slug only appears when you *start* an authorization.\n *\n * @example\n * ```typescript\n * const company = beel.company('company-uuid');\n * const { connections } = await company.paymentConnections.list();\n * const events = await company.paymentConnections.events(connections[0].id).list({\n * needs_action: true,\n * });\n * ```\n */\nexport class CompanyPaymentConnectionsResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n private path() {\n return { company_id: this.companyId };\n }\n\n /**\n * Every payment connection of this company.\n *\n * @returns The `connections`.\n */\n async list() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/payment-connections', {\n params: { path: this.path() },\n });\n return data!.data as { connections: ManagedPaymentConnection[] };\n }\n\n /**\n * Start an authorization and get the URL where the NIF's holder approves it.\n *\n * This is the one place the provider slug is used — currently only `stripe`.\n *\n * @param body - `{ provider: 'stripe' }`, plus the return URL when needed.\n * @returns The `authorization_url` to send the NIF's holder to.\n */\n async authorize(\n body: components['schemas']['InitiatePaymentConnectionRequest'],\n ): Promise<{ authorization_url: string }> {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/authorizations',\n { params: { path: this.path() }, body },\n );\n return data!.data as { authorization_url: string };\n }\n\n /**\n * Update the settings of one connection, addressed by its UUID.\n *\n * @param connectionId - Connection UUID, from {@link list}.\n * @param body - Settings to change.\n * @returns The updated connection.\n */\n async update(\n connectionId: string,\n body: components['schemas']['UpdateCompanyPaymentConnectionRequest'],\n ) {\n const { data } = await this.client.PATCH(\n '/v1/companies/{company_id}/payment-connections/{connection_id}',\n { params: { path: { ...this.path(), connection_id: connectionId } }, body },\n );\n return data!.data as CompanyPaymentConnection;\n }\n\n /**\n * Disconnect one connection. Tokens are revoked and auto-invoicing stops;\n * already-issued invoices are untouched.\n *\n * @param connectionId - Connection UUID.\n */\n async disconnect(connectionId: string): Promise<void> {\n await this.client.DELETE('/v1/companies/{company_id}/payment-connections/{connection_id}', {\n params: { path: { ...this.path(), connection_id: connectionId } },\n });\n }\n\n /**\n * The payment events of one connection — where you audit what did and didn't invoice.\n *\n * @param connectionId - Connection UUID.\n * @returns The events resource of that connection. No request is made.\n */\n events(connectionId: string) {\n return new CompanyPaymentEventsResource(this.client, this.companyId, connectionId);\n }\n}\n\n/**\n * Payment events received through a connection, and the recovery levers for the ones\n * that did not produce an invoice. Reach it as\n * `beel.company(companyId).paymentConnections.events(connectionId)`.\n */\nexport class CompanyPaymentEventsResource {\n constructor(\n private client: BeeLClient,\n private companyId: string,\n private connectionId: string,\n ) {}\n\n private path() {\n return { company_id: this.companyId, connection_id: this.connectionId };\n }\n\n /**\n * Events of the connection, most recent first. Nothing is hidden by default:\n * skipped events, duplicates and disputes are all returned — narrow with the\n * filters. `charges_only` returns one row per money movement instead.\n *\n * @param params - Filters (`needs_action`, `charges_only`…) and pagination.\n * @returns The `events`, their `pagination` and `counts`.\n */\n async list(params?: operations['listCompanyPaymentEvents']['parameters']['query']) {\n const { data } = await this.client.GET(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events',\n { params: { path: this.path(), query: params } },\n );\n return data!.data as {\n events: ManagedPaymentEvent[];\n pagination?: Pagination;\n counts?: PaymentEventCounts;\n };\n }\n\n /**\n * Get one event.\n *\n * @param eventId - Event UUID.\n * @returns The event.\n */\n async get(eventId: string) {\n const { data } = await this.client.GET(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Reprocess an event whose automatic invoicing didn't complete, applying the NIF's\n * **current** configuration. Only retryable states qualify and the retry budget is\n * finite: otherwise `400`.\n *\n * @param eventId - Event UUID.\n * @returns The event after the retry.\n */\n async retry(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/retry',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Build a **draft** invoice from an event that couldn't be invoiced automatically,\n * so you can review it before issuing.\n *\n * @param eventId - Event UUID.\n * @returns The draft's `invoice_id`.\n */\n async draft(eventId: string): Promise<{ invoice_id: string }> {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/draft',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as { invoice_id: string };\n }\n\n /**\n * Mark an event as dealt with outside the automatic flow.\n *\n * @param eventId - Event UUID.\n * @returns The resolved event.\n */\n async resolve(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/resolve',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Discard an event so it stops asking for attention. Reversible with {@link restore}.\n *\n * @param eventId - Event UUID.\n * @returns The discarded event.\n */\n async discard(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/discard',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n\n /**\n * Bring a discarded event back into the list.\n *\n * @param eventId - Event UUID.\n * @returns The restored event.\n */\n async restore(eventId: string) {\n const { data } = await this.client.POST(\n '/v1/companies/{company_id}/payment-connections/{connection_id}/events/{event_id}/restore',\n { params: { path: { ...this.path(), event_id: eventId } } },\n );\n return data!.data as ManagedPaymentEvent;\n }\n}\n","import type { components, operations } from '../generated/schema';\nimport { BeeLApiError, BeeLConflictError } from '../core/errors';\nimport { BeeLErrorCodes } from '../core/error-codes';\nimport { isServerErrorStatus } from '../core/http-status';\n\ntype Invoice = components['schemas']['Invoice'];\ntype CreateInvoiceRequest = components['schemas']['CreateInvoiceRequest'];\ntype InvoiceType = components['schemas']['InvoiceType'];\n\n/**\n * Invoice types whose `external_ref` the API keeps unique: at most one live (not deleted)\n * invoice of these types per reference and environment, whatever its status — a `VOIDED`\n * one included. Correctives are exempt, and proformas are not covered.\n */\nexport const EXTERNAL_REF_UNIQUE_INVOICE_TYPES = ['STANDARD', 'SIMPLIFIED'] as const satisfies readonly InvoiceType[];\n\n/** Invoice types {@link createInvoiceOnce} accepts. */\nexport type ExternalRefUniqueInvoiceType = (typeof EXTERNAL_REF_UNIQUE_INVOICE_TYPES)[number];\n\n/**\n * Body of `invoices.createOnce`: a `CreateInvoiceRequest` whose `type` is `STANDARD` or\n * `SIMPLIFIED` and whose `external_ref` is required — it is what makes the call safe to repeat.\n */\nexport type CreateInvoiceOnceRequest = Omit<CreateInvoiceRequest, 'type' | 'external_ref'> & {\n type: ExternalRefUniqueInvoiceType;\n external_ref: string;\n};\n\n/** Query of `invoices.createOnce`: the same as `invoices.create`. */\nexport type CreateInvoiceOnceParams = operations['createCompanyInvoice']['parameters']['query'];\n\n/** The two calls {@link createInvoiceOnce} is built on, bound to one company. */\nexport interface CreateInvoiceOnceOperations {\n /** Invoices of the company whose `external_ref` equals `externalRef` exactly. */\n listByExternalRef(externalRef: string): Promise<Invoice[]>;\n /** Creates the invoice, with the client's automatic `Idempotency-Key` and retries. */\n create(body: CreateInvoiceRequest, params?: CreateInvoiceOnceParams): Promise<Invoice>;\n}\n\n/** Thrown before any request when the body has no usable `external_ref`. */\nexport const MISSING_EXTERNAL_REF_MESSAGE =\n 'invoices.createOnce requires a non-empty `external_ref`: it is the key that makes the call safe to repeat.';\n\n/** Thrown before any request when the body asks for a type the uniqueness does not cover. */\nexport const UNSUPPORTED_TYPE_MESSAGE =\n 'invoices.createOnce only creates STANDARD or SIMPLIFIED invoices: the API keeps `external_ref` unique for those types only.';\n\nfunction holdsTheReference(invoice: Invoice): boolean {\n return (EXTERNAL_REF_UNIQUE_INVOICE_TYPES as readonly InvoiceType[]).includes(invoice.type);\n}\n\n/** The live invoice that holds `externalRef`, or `undefined` when there is none. */\nasync function findHolder(operations: CreateInvoiceOnceOperations, externalRef: string) {\n const invoices = await operations.listByExternalRef(externalRef);\n return invoices.find(holdsTheReference);\n}\n\n/** A `409 INVOICE_DUPLICATE_EXTERNAL_REFERENCE`: another call already created the invoice. */\nfunction isDuplicateReference(error: unknown): boolean {\n return (\n error instanceof BeeLConflictError &&\n error.apiCode === BeeLErrorCodes.INVOICE_DUPLICATE_EXTERNAL_REFERENCE\n );\n}\n\n/**\n * Whether the create may have taken effect although it did not answer 2xx: a network error,\n * a `5xx`, or a `409 IDEMPOTENCY_KEY_PROCESSING` still pending after the automatic retries.\n */\nfunction isUnknownOutcome(error: unknown): boolean {\n if (!(error instanceof BeeLApiError)) return true;\n if (isServerErrorStatus(error.statusCode)) return true;\n return error instanceof BeeLConflictError && error.apiCode === BeeLErrorCodes.IDEMPOTENCY_KEY_PROCESSING;\n}\n\n/**\n * Creates the invoice for `body.external_ref` unless it already exists, and returns the one\n * invoice that holds that reference:\n *\n * 1. Looks the reference up; if a standard or simplified invoice holds it, returns that one.\n * 2. Otherwise creates it (with the client's `Idempotency-Key`, reused by its retries).\n * 3. On `409 INVOICE_DUPLICATE_EXTERNAL_REFERENCE` (a concurrent call won), or when the\n * outcome is unknown (network error, `5xx`), looks the reference up again and returns the\n * invoice if it exists. If it does not, the original error is thrown: nothing was\n * created, and calling again is safe.\n *\n * The API's unique index on `external_ref` is what guarantees a single invoice; this\n * function turns that guarantee into \"return the existing one\" instead of an error.\n */\nexport async function createInvoiceOnce(\n operations: CreateInvoiceOnceOperations,\n body: CreateInvoiceOnceRequest,\n params?: CreateInvoiceOnceParams,\n): Promise<Invoice> {\n if (typeof body.external_ref !== 'string' || body.external_ref.trim() === '') {\n throw new TypeError(MISSING_EXTERNAL_REF_MESSAGE);\n }\n if (!(EXTERNAL_REF_UNIQUE_INVOICE_TYPES as readonly string[]).includes(body.type)) {\n throw new TypeError(UNSUPPORTED_TYPE_MESSAGE);\n }\n\n const existing = await findHolder(operations, body.external_ref);\n if (existing) return existing;\n\n try {\n return await operations.create(body, params);\n } catch (error) {\n if (!isDuplicateReference(error) && !isUnknownOutcome(error)) throw error;\n const holder = await findHolder(operations, body.external_ref).catch(() => undefined);\n if (holder) return holder;\n throw error;\n }\n}\n","import type { BeeLClient } from '../http/client';\nimport type { components, operations } from '../generated/schema';\nimport { toRequestInit, type RequestOptions } from '../http/request-options';\nimport { CompanyPaymentConnectionsResource } from './payment-connections';\nimport {\n createInvoiceOnce,\n type CreateInvoiceOnceParams,\n type CreateInvoiceOnceRequest,\n} from './invoice-create-once';\n\ntype Invoice = components['schemas']['Invoice'];\ntype Customer = components['schemas']['Customer'];\ntype Product = components['schemas']['Product'];\ntype CompanyData = components['schemas']['CompanyData'];\ntype Pagination = components['schemas']['Pagination'];\n\n/**\n * Operations scoped to a single company (NIF). This is the explicit multi-NIF surface:\n * the company is addressed in the path, so no session focus or `BeeL-Active-Company`\n * header is needed. Get one with `beel.company(companyId)`; list the ids with\n * `beel.account(accountId).companies.list()`.\n *\n * Every method rejects with a `BeeLApiError` subclass when the API answers non-2xx.\n *\n * @example\n * ```typescript\n * const company = beel.company('company-uuid');\n * const invoice = await company.invoices.create({ ... });\n * await company.invoices.issue(invoice.id);\n * ```\n */\nexport class CompanyScope {\n /** Invoices of this company: create, issue, void, correct, list, PDF, email. */\n readonly invoices: CompanyInvoicesResource;\n /** Customers of this company. */\n readonly customers: CompanyCustomersResource;\n /** Products and services of this company. */\n readonly products: CompanyProductsResource;\n /** Invoice series (numbering) of this company. */\n readonly series: CompanySeriesResource;\n /** Recurring invoice templates of this company. */\n readonly recurringInvoices: CompanyRecurringInvoicesResource;\n /** Payment provider connections (Stripe) that auto-generate invoices under this NIF. */\n readonly paymentConnections: CompanyPaymentConnectionsResource;\n /** Default taxes of this company. */\n readonly taxConfiguration: CompanyTaxConfigurationResource;\n /** Whether this NIF submits its invoices to AEAT under VeriFactu. */\n readonly verifactuConfiguration: CompanyVeriFactuConfigurationResource;\n\n constructor(private client: BeeLClient, readonly companyId: string) {\n this.invoices = new CompanyInvoicesResource(client, companyId);\n this.customers = new CompanyCustomersResource(client, companyId);\n this.products = new CompanyProductsResource(client, companyId);\n this.series = new CompanySeriesResource(client, companyId);\n this.recurringInvoices = new CompanyRecurringInvoicesResource(client, companyId);\n this.paymentConnections = new CompanyPaymentConnectionsResource(client, companyId);\n this.taxConfiguration = new CompanyTaxConfigurationResource(client, companyId);\n this.verifactuConfiguration = new CompanyVeriFactuConfigurationResource(client, companyId);\n }\n\n private path() {\n return { company_id: this.companyId };\n }\n\n /**\n * Get the company: its fiscal identity, address and settings.\n *\n * @param params - Optional query of `getCompanyById` (e.g. `include`).\n * @returns The company.\n */\n async get(params?: operations['getCompanyById']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}', {\n params: { path: this.path(), query: params },\n });\n return data!.data as CompanyData;\n }\n\n /**\n * Update the company's data. Only the fields present in `body` change.\n *\n * @param body - Fields to change.\n * @returns The updated company.\n */\n async update(body: components['schemas']['UpdateCompanyRequest']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}', {\n params: { path: this.path() },\n body,\n });\n return data!.data as CompanyData;\n }\n\n /**\n * Remove the company from its account. Blocked for the primary NIF, a NIF active in Live,\n * or one holding Live invoices.\n */\n async delete() {\n await this.client.DELETE('/v1/companies/{company_id}', { params: { path: this.path() } });\n }\n\n /**\n * Fiscal summary of the company for a period: taxable base, VAT and IRPF aggregates.\n *\n * @param params - `start_date` and `end_date` (both or neither; default: the current month).\n * @returns The aggregates of the period.\n */\n async fiscalSummary(params?: operations['getCompanyFiscalSummary']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/fiscal-summary', {\n params: { path: this.path(), query: params },\n });\n return data!.data as components['schemas']['FiscalSummaryResponse'];\n }\n\n /**\n * Whether the company can issue invoices now, and what blocks it if not.\n *\n * @returns `ready` plus the list of `blockers`.\n */\n async issuingReadiness() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/issuing-readiness', {\n params: { path: this.path() },\n });\n return data!.data as components['schemas']['IssuingReadinessData'];\n }\n}\n\n/**\n * Invoice lifecycle of one company: create a draft (or issue it directly), issue, void,\n * correct, list and read, PDF and email. Reach it as `beel.company(companyId).invoices`.\n *\n * A create, issue, void or corrective carries an automatic `Idempotency-Key`, reused by the\n * client's automatic retries. To retry a create yourself safely, use {@link createOnce}.\n */\nexport class CompanyInvoicesResource {\n /** Scheduled issuing of one invoice: read, set or clear it. */\n readonly schedule: CompanyInvoiceScheduleResource;\n\n constructor(private client: BeeLClient, private companyId: string) {\n this.schedule = new CompanyInvoiceScheduleResource(client, companyId);\n }\n\n /**\n * Derive a new draft invoice from an existing one — the canonical form of `duplicate`.\n * The source invoice is not modified.\n *\n * @param body - `from_invoice_id`, and optionally the `series_id` of the copy.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The new draft invoice.\n */\n async derive(body: components['schemas']['CreateInvoiceDerivationRequest'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/derivations', {\n ...toRequestInit(options),\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data as Invoice;\n }\n\n private path(): { company_id: string };\n private path<T extends Record<string, string>>(rest: T): { company_id: string } & T;\n private path(rest?: Record<string, string>) {\n return { company_id: this.companyId, ...rest };\n }\n\n /**\n * List the company's invoices, paginated, with filters: status, type, customer, dates,\n * `external_ref` (exact match), VeriFactu status and more.\n *\n * @param params - Filters and pagination (`page`, `limit`).\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The page of `invoices` and its `pagination`.\n *\n * @example\n * ```typescript\n * const { invoices } = await company.invoices.list({ external_ref: 'ORD-2026-0042' });\n * ```\n */\n async list(params?: operations['listCompanyInvoices']['parameters']['query'], options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices', {\n ...toRequestInit(options),\n params: { path: this.path(), query: params },\n });\n return data!.data as { invoices: Invoice[]; pagination: Pagination };\n }\n\n /**\n * Create an invoice: a `DRAFT` by default, or numbered and issued in the same call with\n * `options.issue_directly: true`. `CORRECTIVE` is not accepted here: use\n * {@link createCorrective}.\n *\n * One call sends one `Idempotency-Key`, reused by the client's automatic retries, so\n * those never duplicate the invoice. A second call is a new operation: to repeat a create\n * whose outcome you do not know, use {@link createOnce}.\n *\n * @param body - Type, recipient and lines; `external_ref` to tie it to your order.\n * @param params - `wait_for_pdf`, when issuing directly.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The created invoice. With VeriFactu, `verifactu.submission_status` starts `PENDING`.\n *\n * @example\n * ```typescript\n * const invoice = await company.invoices.create({\n * type: 'STANDARD',\n * recipient: { customer_id: 'customer-uuid' },\n * lines: [{\n * description: 'Consulting', quantity: 1, unit_price: 100,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' },\n * }],\n * external_ref: 'ORD-2026-0042',\n * });\n * ```\n */\n async create(\n body: components['schemas']['CreateInvoiceRequest'],\n params?: operations['createCompanyInvoice']['parameters']['query'],\n options?: RequestOptions,\n ) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices', {\n ...toRequestInit(options),\n params: { path: this.path(), query: params },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Create a standard or simplified invoice once per `external_ref`, safe to call again\n * after any failure. It looks the reference up first and returns the invoice that already\n * holds it; otherwise it creates one. If the create answers\n * `409 INVOICE_DUPLICATE_EXTERNAL_REFERENCE`, or its outcome is unknown (network error,\n * `5xx`), it looks the reference up again and returns the invoice it finds.\n *\n * The returned invoice may be one created earlier, in any status (`VOIDED` included):\n * compare its fields if that matters to you.\n *\n * @param body - A `CreateInvoiceRequest` with `type` `STANDARD` or `SIMPLIFIED` and a\n * non-empty `external_ref`.\n * @param params - `wait_for_pdf`, when issuing directly.\n * @param options - `idempotencyKey` for the create; `signal` and `timeoutMs` for the whole\n * sequence of calls.\n * @returns The one invoice that holds `body.external_ref`.\n * @throws {TypeError} Before any request, when `external_ref` is empty or `type` is not\n * `STANDARD`/`SIMPLIFIED`.\n * @throws {BeeLApiError} The create's error when no invoice holds the reference\n * afterwards — nothing was created, so calling again is safe.\n *\n * @example\n * ```typescript\n * const invoice = await company.invoices.createOnce({\n * type: 'STANDARD',\n * external_ref: order.id,\n * recipient: { customer_id: order.customerId },\n * lines: [{ description: 'Order', quantity: 1, unit_price: 100,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' } }],\n * options: { issue_directly: true },\n * });\n * ```\n */\n async createOnce(\n body: CreateInvoiceOnceRequest,\n params?: CreateInvoiceOnceParams,\n options?: RequestOptions,\n ) {\n // One signal for the whole sequence, so `timeoutMs` bounds lookup + create + lookup.\n const { signal } = toRequestInit({ signal: options?.signal, timeoutMs: options?.timeoutMs });\n return createInvoiceOnce(\n {\n listByExternalRef: async (externalRef) =>\n (await this.list({ external_ref: externalRef }, { signal })).invoices,\n create: (request, query) =>\n this.create(request, query, { signal, idempotencyKey: options?.idempotencyKey }),\n },\n body,\n params,\n );\n }\n\n /**\n * Get one invoice, including its `status` and its `verifactu` block\n * (`submission_status`, `qr_url`, `error_code`…).\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The invoice.\n */\n async get(invoiceId: string, options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices/{invoice_id}', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n return data!.data as Invoice;\n }\n\n /**\n * Update a `DRAFT` or `SCHEDULED` invoice (or an `ACTIVE` proforma). Only the fields\n * present in `body` change; an issued invoice is amended with a corrective instead.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - Fields to change.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The updated invoice.\n */\n async update(invoiceId: string, body: operations['patchCompanyInvoice']['requestBody']['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/invoices/{invoice_id}', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Delete a draft invoice. Deleting frees its `external_ref` for a new invoice.\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n */\n async delete(invoiceId: string, options?: RequestOptions) {\n await this.client.DELETE('/v1/companies/{company_id}/invoices/{invoice_id}', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n }\n\n /**\n * Issue a draft: assigns its definitive number and makes it immutable. PDF generation and\n * the VeriFactu submission happen after the response.\n *\n * @param invoiceId - UUID of the draft.\n * @param params - `wait_for_pdf: true` to wait for the PDF before answering.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The issued invoice.\n */\n async issue(invoiceId: string, params?: operations['issueCompanyInvoice']['parameters']['query'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/issue', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }), query: params },\n });\n return data!.data as Invoice;\n }\n\n /**\n * Void an invoice issued by mistake. The document is kept and its number never reused. If\n * the operation did happen but the invoice is wrong, use {@link createCorrective}.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - `reason`; `issued_in_error: true` is required once it was sent or paid.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The voided invoice.\n */\n async void(invoiceId: string, body: NonNullable<operations['voidCompanyInvoice']['requestBody']>['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/void', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Create a corrective invoice (rectificativa) for an issued invoice.\n *\n * @param invoiceId - UUID of the issued invoice to correct.\n * @param body - `rectification_type` (`TOTAL`/`PARTIAL`), `rectification_code` (`R1`–`R5`),\n * `reason` and, for `PARTIAL`, the correcting `lines`.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The corrective invoice.\n *\n * @example\n * ```typescript\n * const corrective = await company.invoices.createCorrective('invoice-uuid', {\n * rectification_type: 'PARTIAL',\n * rectification_code: 'R1',\n * reason: 'Discount agreed with the customer after the sale',\n * lines: [{ description: 'Discount', quantity: -1, unit_price: 10,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' } }],\n * });\n * ```\n */\n async createCorrective(\n invoiceId: string,\n body: operations['createCompanyCorrectiveInvoice']['requestBody']['content']['application/json'],\n options?: RequestOptions,\n ) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/corrective', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Convert a proforma into an invoice.\n *\n * @param invoiceId - UUID of the proforma.\n * @param body - Optional overrides for the new invoice.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The new invoice.\n */\n async convertToInvoice(\n invoiceId: string,\n body?: NonNullable<operations['convertCompanyProformaToInvoice']['requestBody']>['content']['application/json'],\n options?: RequestOptions,\n ) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/convert-to-invoice', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Issue a full invoice in exchange for one or more issued simplified invoices, when the\n * customer asks for an invoice with their details. It is not a corrective: the simplified\n * invoices become `VOIDED` with `void_cause: 'EXCHANGED'`, and the new `STANDARD` invoice\n * lists them in `replaced_invoice_ids`.\n *\n * @param body - `simplified_invoice_ids` and the identified `recipient`.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The new standard invoice.\n *\n * @example\n * ```typescript\n * const invoice = await company.invoices.createSimplifiedExchange({\n * simplified_invoice_ids: ['simplified-uuid'],\n * recipient: { customer_id: 'customer-uuid' },\n * });\n * ```\n */\n async createSimplifiedExchange(body: components['schemas']['CreateSimplifiedExchangeRequest'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/simplified-exchanges', {\n ...toRequestInit(options),\n params: { path: this.path() },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * The VeriFactu records of an invoice, oldest first: its registration and, if it was\n * voided, its cancellation. An invoice never submitted answers with an empty list.\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The records (`data.records` of the response), each with its own `submission_status`.\n */\n async verifactuRecords(invoiceId: string, options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices/{invoice_id}/verifactu-records', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n return data!.data!.records as components['schemas']['VeriFactuRecord'][];\n }\n\n /**\n * Set the commercial status: `PAID` (from `ISSUED`, `SENT`, `OVERDUE`), `SENT` (from\n * `ISSUED`) or back to `ISSUED` (from `SENT`). Issuing and voiding have their own methods.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - Target `status` and, for `PAID`, the payment details.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The updated invoice.\n */\n async setStatus(invoiceId: string, body: operations['setCompanyInvoiceStatus']['requestBody']['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/invoices/{invoice_id}/status', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data as Invoice;\n }\n\n /**\n * Get a short-lived download URL for the invoice PDF.\n *\n * @param invoiceId - Invoice UUID.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns `download_url`, `expires_in_seconds` and `file_name`.\n */\n async getPdf(invoiceId: string, options?: RequestOptions) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/invoices/{invoice_id}/pdf', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Send the invoice by email with its PDF. Without recipients, the customer's addresses are used.\n *\n * @param invoiceId - Invoice UUID.\n * @param body - Optional recipients, subject and message.\n * @param options - Per-call `idempotencyKey`, `signal` and `timeoutMs`.\n * @returns The delivery record.\n */\n async send(invoiceId: string, body: NonNullable<operations['sendCompanyInvoice']['requestBody']>['content']['application/json'], options?: RequestOptions) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/invoices/{invoice_id}/send', {\n ...toRequestInit(options),\n params: { path: this.path({ invoice_id: invoiceId }) },\n body,\n });\n return data!.data;\n }\n}\n\n/**\n * Scheduled issuing of one invoice: read it, set it, clear it. Reach it as\n * `beel.company(companyId).invoices.schedule`.\n */\nexport class CompanyInvoiceScheduleResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * Get the schedule of an invoice.\n *\n * @param invoiceId - Invoice UUID.\n * @returns `scheduled_for` and `generation_mode`.\n */\n async get(invoiceId: string) {\n const { data } = await this.client.GET(\n '/v1/companies/{company_id}/invoices/{invoice_id}/schedule',\n { params: { path: { company_id: this.companyId, invoice_id: invoiceId } } },\n );\n return data!.data;\n }\n\n /**\n * Set or move the schedule. One `PUT` replaces the three legacy calls\n * (`schedule`, `reschedule`, `unschedule`): setting it again moves it.\n *\n * @param invoiceId - UUID of a draft invoice.\n * @param body - `scheduled_for` date and what to do then.\n * @returns The scheduled invoice.\n */\n async set(invoiceId: string, body: components['schemas']['SetInvoiceScheduleRequest']) {\n const { data } = await this.client.PUT(\n '/v1/companies/{company_id}/invoices/{invoice_id}/schedule',\n { params: { path: { company_id: this.companyId, invoice_id: invoiceId } }, body },\n );\n return data!.data;\n }\n\n /**\n * Clear the schedule, returning the invoice to a plain draft — the canonical form of\n * `unschedule`. Idempotent.\n *\n * @param invoiceId - Invoice UUID.\n */\n async clear(invoiceId: string): Promise<void> {\n await this.client.DELETE('/v1/companies/{company_id}/invoices/{invoice_id}/schedule', {\n params: { path: { company_id: this.companyId, invoice_id: invoiceId } },\n });\n }\n}\n\n/** Customers of one company. Reach it as `beel.company(companyId).customers`. */\nexport class CompanyCustomersResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * List the company's customers, paginated and searchable.\n *\n * @param params - Filters and pagination.\n * @returns The page of `customers` and its `pagination`.\n */\n async list(params?: operations['listCompanyCustomers']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/customers', {\n params: { path: { company_id: this.companyId }, query: params },\n });\n return data!.data as { customers: Customer[]; pagination: Pagination };\n }\n\n /**\n * Create a customer.\n *\n * @param body - Legal name, NIF (or alternative id) and address.\n * @returns The created customer.\n */\n async create(body: components['schemas']['CreateCustomerRequest']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/customers', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data as Customer;\n }\n\n /**\n * Create several customers in one call.\n *\n * @param body - The customers, and whether it is a dry run.\n * @returns Per-customer results and totals.\n */\n async createBulk(body: operations['createCompanyCustomersBulk']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/customers/bulk', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Get one customer.\n *\n * @param customerId - Customer UUID.\n * @returns The customer.\n */\n async get(customerId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/customers/{customer_id}', {\n params: { path: { company_id: this.companyId, customer_id: customerId } },\n });\n return data!.data as Customer;\n }\n\n /**\n * Update a customer. Only the fields present in `body` change.\n *\n * @param customerId - Customer UUID.\n * @param body - Fields to change.\n * @returns The updated customer.\n */\n async update(customerId: string, body: operations['patchCompanyCustomer']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/customers/{customer_id}', {\n params: { path: { company_id: this.companyId, customer_id: customerId } },\n body,\n });\n return data!.data as Customer;\n }\n\n /**\n * Delete a customer that has no invoices. Its NIF (or alternative id) is released for a\n * new customer.\n *\n * @param customerId - Customer UUID.\n */\n async delete(customerId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/customers/{customer_id}', {\n params: { path: { company_id: this.companyId, customer_id: customerId } },\n });\n }\n}\n\n/** Products and services of one company. Reach it as `beel.company(companyId).products`. */\nexport class CompanyProductsResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * List the company's products, paginated and searchable.\n *\n * @param params - Filters and pagination.\n * @returns The page of `products` and its `pagination`.\n */\n async list(params?: operations['listCompanyProducts']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/products', {\n params: { path: { company_id: this.companyId }, query: params },\n });\n return data!.data as { products: Product[]; pagination: Pagination };\n }\n\n /**\n * Create a product or service.\n *\n * @param body - Name, category, price and main tax.\n * @returns The created product.\n */\n async create(body: components['schemas']['CreateProductRequest']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/products', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data as Product;\n }\n\n /**\n * Get one product.\n *\n * @param productId - Product UUID.\n * @returns The product.\n */\n async get(productId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/products/{product_id}', {\n params: { path: { company_id: this.companyId, product_id: productId } },\n });\n return data!.data as Product;\n }\n\n /**\n * Update a product. Only the fields present in `body` change.\n *\n * @param productId - Product UUID.\n * @param body - Fields to change.\n * @returns The updated product.\n */\n async update(productId: string, body: operations['patchCompanyProduct']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/products/{product_id}', {\n params: { path: { company_id: this.companyId, product_id: productId } },\n body,\n });\n return data!.data as Product;\n }\n\n /**\n * Delete a product from the catalog. Existing invoice lines are unaffected.\n *\n * @param productId - Product UUID.\n */\n async delete(productId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/products/{product_id}', {\n params: { path: { company_id: this.companyId, product_id: productId } },\n });\n }\n}\n\n/**\n * Invoice series (numbering) of one company. Each series numbers one `document_type`.\n * Reach it as `beel.company(companyId).series`.\n */\nexport class CompanySeriesResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * List the company's series.\n *\n * @param params - Filters; `page`/`limit` to paginate.\n * @returns The `series`, and `pagination` when you paginated.\n */\n async list(params?: operations['listCompanySeries']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/series', {\n params: { path: { company_id: this.companyId }, query: params },\n });\n return data!.data;\n }\n\n /**\n * Create a series.\n *\n * @param body - Code, name, format and the `document_type` it numbers.\n * @returns The created series.\n */\n async create(body: operations['createCompanySeries']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/series', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Update a series. Only the fields present in `body` change.\n *\n * @param seriesId - Series UUID.\n * @param body - Fields to change.\n * @returns The updated series.\n */\n async update(seriesId: string, body: operations['patchCompanySeries']['requestBody']['content']['application/json']) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/series/{series_id}', {\n params: { path: { company_id: this.companyId, series_id: seriesId } },\n body,\n });\n return data!.data;\n }\n\n /**\n * Delete (soft-delete) a series. Its code stays taken, since issued invoices carry it.\n *\n * @param seriesId - Series UUID.\n */\n async delete(seriesId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/series/{series_id}', {\n params: { path: { company_id: this.companyId, series_id: seriesId } },\n });\n }\n\n /**\n * The current default series per document type.\n *\n * @returns One entry per document type, saying whether a default exists.\n */\n async getDefaults() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/series/defaults', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Ensure a default series exists per document type, creating the missing ones.\n * Idempotent.\n *\n * @returns The default series.\n */\n async ensureDefaults() {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/series/defaults', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Mark a series as the default for its document type.\n *\n * @param seriesId - Series UUID.\n * @returns The series.\n */\n async setDefault(seriesId: string) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/series/{series_id}/default', {\n params: { path: { company_id: this.companyId, series_id: seriesId } },\n });\n return data!.data;\n }\n}\n\n/**\n * Recurring invoice templates of one company. Reach it as\n * `beel.company(companyId).recurringInvoices`.\n */\nexport class CompanyRecurringInvoicesResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n private path(): { company_id: string };\n private path<T extends Record<string, string>>(rest: T): { company_id: string } & T;\n private path(rest?: Record<string, string>) {\n return { company_id: this.companyId, ...rest };\n }\n\n /**\n * List the recurring invoices.\n *\n * @param params - Filters and pagination.\n * @returns The page of `recurring_invoices` and its `pagination`.\n */\n async list(params?: operations['listCompanyRecurringInvoices']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices', {\n params: { path: this.path(), query: params },\n });\n return data!.data;\n }\n\n /**\n * Create a recurring invoice template.\n *\n * @param body - Frequency, schedule, recipient and lines.\n * @returns The recurring invoice.\n */\n async create(body: operations['createCompanyRecurringInvoice']['requestBody']['content']['application/json']) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/recurring-invoices', {\n params: { path: this.path() },\n body,\n });\n return data!.data;\n }\n\n /**\n * Get one recurring invoice.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The recurring invoice.\n */\n async get(recurringInvoiceId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Update a recurring invoice. Only the fields present in `body` change.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @param body - Fields to change.\n * @returns The updated recurring invoice.\n */\n async update(\n recurringInvoiceId: string,\n body: operations['patchCompanyRecurringInvoice']['requestBody']['content']['application/json'],\n ) {\n const { data } = await this.client.PATCH('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n body,\n });\n return data!.data;\n }\n\n /**\n * Delete a recurring invoice and cancel its pending generations. Invoices it already\n * generated are kept.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n */\n async delete(recurringInvoiceId: string) {\n await this.client.DELETE('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n }\n\n /**\n * Pause, resume or end the template.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @param body - Target `status` (e.g. `PAUSED`, `ACTIVE`).\n * @returns The updated recurring invoice.\n */\n async setStatus(\n recurringInvoiceId: string,\n body: operations['setCompanyRecurringInvoiceStatus']['requestBody']['content']['application/json'],\n ) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/status', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n body,\n });\n return data!.data;\n }\n\n /**\n * Skip the next scheduled occurrence.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The recurring invoice with its next date moved.\n */\n async skip(recurringInvoiceId: string) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/skip', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Generate the next invoice now instead of waiting for the schedule.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The generated `invoice_id` and the `next_generation` date.\n */\n async generateNow(recurringInvoiceId: string) {\n const { data } = await this.client.POST('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/generate', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * Preview the next invoice the template will generate.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @returns The invoice as it would be generated.\n */\n async nextOccurrence(recurringInvoiceId: string) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/next-occurrence', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }) },\n });\n return data!.data;\n }\n\n /**\n * The generation history of the template: generated, skipped and failed occurrences.\n *\n * @param recurringInvoiceId - Recurring invoice UUID.\n * @param params - Pagination.\n * @returns The `history` entries.\n */\n async history(recurringInvoiceId: string, params?: operations['getCompanyRecurringInvoiceHistory']['parameters']['query']) {\n const { data } = await this.client.GET('/v1/companies/{company_id}/recurring-invoices/{recurring_invoice_id}/history', {\n params: { path: this.path({ recurring_invoice_id: recurringInvoiceId }), query: params },\n });\n return data!.data;\n }\n}\n\n/**\n * Tax defaults of one company (main tax, IRPF, equivalence surcharge). The canonical\n * replacement for the account-wide `beel.configuration.getTaxConfig()`, whose flat route is\n * deprecated. Reach it as `beel.company(companyId).taxConfiguration`.\n */\nexport class CompanyTaxConfigurationResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * Get the tax configuration.\n *\n * @returns The company's tax defaults.\n */\n async get() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/tax-configuration', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Replace the tax configuration — this is a `PUT`, not a merge: send the whole state.\n *\n * @param body - The complete tax configuration.\n * @returns The stored configuration.\n */\n async update(body: components['schemas']['UpdateTaxConfigurationRequest']) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/tax-configuration', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n}\n\n/**\n * VeriFactu configuration of one company. The canonical replacement for\n * `beel.configuration.getVerifactu()`, whose flat route is deprecated. Reach it as\n * `beel.company(companyId).verifactuConfiguration`.\n *\n * Whether an invoice reaches AEAT is a fact of this NIF resolved at issue time, not a\n * per-invoice choice: `enabled` is the only writable field. Everything else — `status`,\n * `nif_status`, `signed`, `activated`, `pdf_generated` — is resolved server-side. The\n * outcome of each invoice is on the invoice itself: `invoice.verifactu.submission_status`.\n */\nexport class CompanyVeriFactuConfigurationResource {\n constructor(private client: BeeLClient, private companyId: string) {}\n\n /**\n * Get the VeriFactu configuration of this NIF.\n *\n * @returns `enabled` and the server-resolved state of the NIF.\n */\n async get() {\n const { data } = await this.client.GET('/v1/companies/{company_id}/verifactu-configuration', {\n params: { path: { company_id: this.companyId } },\n });\n return data!.data;\n }\n\n /**\n * Turn VeriFactu on or off for this NIF. `enabled` is the only field you can write.\n *\n * @param body - `{ enabled }`.\n * @returns The updated configuration.\n */\n async update(body: components['schemas']['UpdateVeriFactuConfigurationRequest']) {\n const { data } = await this.client.PUT('/v1/companies/{company_id}/verifactu-configuration', {\n params: { path: { company_id: this.companyId } },\n body,\n });\n return data!.data;\n }\n}\n","import { createBeeLClient, type BeeLConfig } from './http/client';\nimport { InvoicesResource } from './resources/invoices';\nimport { CustomersResource } from './resources/customers';\nimport { ProductsResource } from './resources/products';\nimport { ConfigurationResource, CatalogsResource } from './resources/configuration';\nimport { SeriesResource } from './resources/series';\nimport { NifResource } from './resources/nif';\nimport { AccountsResource, AccountScope } from './resources/accounts';\nimport { CompanyScope } from './resources/company';\n\n/**\n * The BeeL API client. Create one per API key and reuse it; it holds no global state.\n * Address a company with {@link company} and an account with {@link account}.\n *\n * Requests are retried automatically when it is safe — see `BeeLConfig` — and every `POST`\n * carries an `Idempotency-Key` that those retries reuse.\n *\n * @example\n * ```typescript\n * import { BeeL } from '@beel_es/sdk';\n *\n * const beel = new BeeL({ apiKey: process.env.BEEL_API_KEY! });\n *\n * const invoice = await beel.company('company-uuid').invoices.create({\n * type: 'STANDARD',\n * recipient: { customer_id: 'customer-uuid' },\n * lines: [{\n * description: 'Service', quantity: 1, unit_price: 100,\n * main_tax: { type: 'IVA', percentage: 21, regime_key: '01' },\n * }],\n * });\n * ```\n */\nexport class BeeL {\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).invoices` instead. */\n readonly invoices: InvoicesResource;\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).customers` instead. */\n readonly customers: CustomersResource;\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).products` instead. */\n readonly products: ProductsResource;\n /** @deprecated Session-focus configuration endpoints are deprecated in the API contract. Use the company-scoped equivalents on `beel.company(companyId)`. */\n readonly configuration: ConfigurationResource;\n /** @deprecated Session-focus endpoints are deprecated in the API contract. Use `beel.company(companyId).series` instead. */\n readonly series: SeriesResource;\n /** Account-wide catalogs, the credential's identity and personal preferences. */\n readonly catalogs: CatalogsResource;\n /** NIF validation against the AEAT register. */\n readonly nif: NifResource;\n /** Accounts you manage (multi-account provisioning: members, invitations, webhooks, companies). */\n readonly accounts: AccountsResource;\n\n /**\n * The typed client underneath, for any endpoint this SDK does not wrap yet.\n *\n * A new route reaches the generated types as soon as the contract is synced, but its\n * ergonomic wrapper is written by hand — so without this you would have to wait for a\n * release to call it. Here you can call it today, and still typed: the path, its\n * parameters and the body are checked against the contract, a wrong one does not\n * compile. What you give up is the sugar (grouping, unwrapping of `data`, the\n * builders) and the naming stability the wrappers provide.\n *\n * Retries, the `Authorization` header and `Idempotency-Key` still apply: it is the\n * same client the resources use, middleware included. That includes error handling: a\n * non-2xx answer is **thrown** as a `BeeLApiError` subclass, so `raw` calls never resolve\n * with openapi-fetch's `{ error }`; `data` is always the successful body.\n *\n * @example\n * ```typescript\n * const { data } = await beel.raw.GET('/v1/companies/{company_id}/invoice-customization', {\n * params: { path: { company_id: 'uuid' } },\n * });\n * ```\n */\n readonly raw: ReturnType<typeof createBeeLClient>;\n\n constructor(config: BeeLConfig) {\n const client = createBeeLClient(config);\n this.raw = client;\n this.invoices = new InvoicesResource(client);\n this.customers = new CustomersResource(client);\n this.products = new ProductsResource(client);\n this.configuration = new ConfigurationResource(client);\n this.catalogs = new CatalogsResource(client);\n this.series = new SeriesResource(client);\n this.nif = new NifResource(client);\n this.accounts = new AccountsResource(client);\n }\n\n /**\n * Returns a facade scoped to one company (NIF) — the explicit multi-NIF surface.\n * All operations address the company in the path, no session focus needed. No request\n * is made; get the ids from `beel.account(accountId).companies.list()`.\n *\n * @param companyId - Company UUID (not its NIF).\n * @returns The company scope.\n *\n * @example\n * ```typescript\n * const company = beel.company('company-uuid');\n * const { invoices } = await company.invoices.list({ status: 'ISSUED' });\n * ```\n */\n company(companyId: string): CompanyScope {\n return new CompanyScope(this.raw, companyId);\n }\n\n /**\n * Returns a facade scoped to one account — companies, members, invitations, account\n * webhooks, usage. Symmetric with {@link company}. No request is made; your own account\n * id is `(await beel.catalogs.identity()).account_id`.\n *\n * @param accountId - Account UUID.\n * @returns The account scope.\n *\n * @example\n * ```typescript\n * const account = beel.account('account-uuid');\n * const members = await account.members.list();\n * ```\n */\n account(accountId: string): AccountScope {\n return new AccountScope(this.raw, accountId);\n }\n\n /**\n * Download an invoice PDF as a Buffer.\n *\n * @deprecated Relies on the deprecated session-focus PDF endpoint. Use\n * `beel.company(companyId).invoices.getPdf(invoiceId)` and fetch `download_url` instead.\n *\n * @param invoiceId - Invoice UUID.\n * @returns The PDF bytes and its file name.\n * @throws {Error} When downloading the file fails.\n *\n * @example\n * ```typescript\n * const { buffer, fileName } = await beel.downloadPdf('invoice-uuid');\n * fs.writeFileSync(fileName, buffer);\n * ```\n */\n async downloadPdf(invoiceId: string): Promise<{ buffer: Buffer; fileName: string }> {\n const pdf = await this.invoices.getPdf(invoiceId);\n const response = await fetch(pdf.download_url);\n if (!response.ok) throw new Error(`Failed to download PDF: ${response.status}`);\n const arrayBuffer = await response.arrayBuffer();\n return { buffer: Buffer.from(arrayBuffer), fileName: pdf.file_name };\n }\n}\n","import { createHmac, timingSafeEqual } from 'crypto';\n\n/**\n * Webhook signature verification for BeeL webhooks\n * \n * Every webhook delivery includes a `BeeL-Signature` header that must be verified\n * to ensure the webhook came from BeeL and hasn't been tampered with.\n * \n * ## Security Requirements\n * \n * 1. **Always verify** the signature before processing the webhook\n * 2. **Use constant-time comparison** to prevent timing attacks\n * 3. **Reject old events** (older than 5 minutes)\n * 4. **Use raw request body** (before parsing JSON)\n * \n * ## Header Format\n * \n * ```\n * BeeL-Signature: t=1741362026,v1=3c4f7a2e1b9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f\n * ```\n * \n * Where:\n * - `t` = Unix timestamp when the webhook was sent\n * - `v1` = HMAC-SHA256 signature of the payload\n * \n * @example Express.js\n * ```typescript\n * import express from 'express';\n * import { WebhookVerifier } from '@beel_es/sdk';\n * \n * const verifier = new WebhookVerifier('your_webhook_secret');\n * \n * app.post('/webhooks/beel', express.raw({ type: 'application/json' }), (req, res) => {\n * const signature = req.headers['beel-signature'] as string;\n * const rawBody = req.body.toString('utf8');\n * \n * try {\n * const event = verifier.verify(rawBody, signature);\n * \n * if (event.type === 'verifactu.status.updated') {\n * console.log('VeriFactu status:', event.data.new_status);\n * if (event.data.new_status === 'ACCEPTED') {\n * console.log('QR URL:', event.data.qr_url);\n * }\n * }\n * \n * res.status(200).send('OK');\n * } catch (error) {\n * console.error('Invalid webhook:', error.message);\n * res.status(400).send('Invalid signature');\n * }\n * });\n * ```\n */\nexport class WebhookVerifier {\n private readonly secret: string;\n private readonly toleranceSeconds: number;\n \n /**\n * Creates a new WebhookVerifier\n * \n * @param secret - Your webhook secret from BeeL dashboard\n * @param toleranceSeconds - Maximum age of webhook events (default: 300 = 5 minutes)\n */\n constructor(secret: string, toleranceSeconds: number = 300) {\n if (!secret || secret.trim().length === 0) {\n throw new Error('Webhook secret is required');\n }\n this.secret = secret;\n this.toleranceSeconds = toleranceSeconds;\n }\n \n /**\n * Verify a webhook signature and return the parsed event\n * \n * @param rawBody - Raw request body (string or Buffer, before JSON parsing)\n * @param signatureHeader - Value of the `BeeL-Signature` header\n * @returns Parsed webhook event\n * @throws {WebhookVerificationError} If signature is invalid or event is too old\n * \n * @example Basic usage\n * ```typescript\n * const verifier = new WebhookVerifier('your_secret');\n * const event = verifier.verify(rawBody, signature);\n * \n * if (event.test) return; // a \"Send test\" delivery carries a synthetic `data`\n * if (event.type === 'verifactu.status.updated') {\n * console.log('Invoice:', event.data.invoice_number);\n * console.log('Status:', event.data.new_status);\n * }\n * ```\n */\n verify<T extends WebhookEvent = WebhookEvent>(\n rawBody: string | Buffer,\n signatureHeader: string | undefined\n ): T {\n if (!signatureHeader) {\n throw new WebhookVerificationError('Missing BeeL-Signature header');\n }\n \n // Parse signature header\n const { timestamp, signature } = this.parseSignatureHeader(signatureHeader);\n \n // Check timestamp tolerance\n const now = Math.floor(Date.now() / 1000);\n const age = Math.abs(now - timestamp);\n \n if (age > this.toleranceSeconds) {\n throw new WebhookVerificationError(\n `Webhook timestamp too old (${age}s ago, max ${this.toleranceSeconds}s allowed)`\n );\n }\n \n // Verify signature\n const bodyString = Buffer.isBuffer(rawBody) ? rawBody.toString('utf8') : rawBody;\n const expectedSignature = this.computeSignature(timestamp, bodyString);\n \n if (!this.secureCompare(signature, expectedSignature)) {\n throw new WebhookVerificationError('Invalid webhook signature');\n }\n \n // Parse and return event\n try {\n return JSON.parse(bodyString);\n } catch (error) {\n throw new WebhookVerificationError('Invalid JSON in webhook body');\n }\n }\n \n /**\n * Parse the BeeL-Signature header\n * \n * Format: `t=1741362026,v1=3c4f7a2e...`\n */\n private parseSignatureHeader(header: string): { timestamp: number; signature: string } {\n const parts = header.split(',');\n let timestamp: number | undefined;\n let signature: string | undefined;\n \n for (const part of parts) {\n const [key, value] = part.split('=', 2);\n if (key === 't') {\n timestamp = parseInt(value, 10);\n } else if (key === 'v1') {\n signature = value;\n }\n }\n \n if (!timestamp || !signature) {\n throw new WebhookVerificationError(\n 'Invalid signature header format (expected: t=timestamp,v1=signature)'\n );\n }\n \n if (isNaN(timestamp)) {\n throw new WebhookVerificationError('Invalid timestamp in signature header');\n }\n \n return { timestamp, signature };\n }\n \n /**\n * Compute HMAC-SHA256 signature\n * \n * Algorithm:\n * 1. Build signed payload: `{timestamp}.{raw_body}`\n * 2. Compute: HMAC-SHA256(secret, signed_payload)\n * 3. Return hex digest\n */\n private computeSignature(timestamp: number, body: string): string {\n const signedPayload = `${timestamp}.${body}`;\n return createHmac('sha256', this.secret)\n .update(signedPayload, 'utf8')\n .digest('hex');\n }\n \n /**\n * Constant-time string comparison to prevent timing attacks\n */\n private secureCompare(a: string, b: string): boolean {\n if (a.length !== b.length) {\n return false;\n }\n \n const bufferA = Buffer.from(a, 'utf8');\n const bufferB = Buffer.from(b, 'utf8');\n \n return timingSafeEqual(bufferA, bufferB);\n }\n}\n\n/**\n * Webhook verification error\n */\nexport class WebhookVerificationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'WebhookVerificationError';\n }\n}\n\n/**\n * Webhook event types, built from the generated webhook contract\n * (`npm run generate:webhooks`, from openapi/webhook-receiver-api.yaml).\n *\n * The generator emits each event as the envelope intersected with its own one-member\n * `type` enum. The envelope already types `type` as the full `WebhookEventType` enum, and\n * two different enums never intersect, so every generated event collapsed to `never` and\n * `if (event.type === '...')` narrowed to nothing. These are the same shapes, rebuilt on\n * the envelope without its `type`, with `type` as the string literal the API sends.\n */\nimport type {\n WebhookEventEnvelope as GeneratedEnvelope,\n WebhookEventDataVeriFactuStatusUpdated,\n WebhookEventDataInvoiceIssued,\n WebhookEventDataInvoiceVoided,\n WebhookEventDataInvoiceEmailSent,\n WebhookEventDataInvoicePdfGenerated,\n WebhookEventDataInvoiceScheduleFailed,\n WebhookEventDataRecurringInvoicePaused,\n WebhookEventDataAccountClaimed,\n WebhookEventDataCompanyCreated,\n WebhookEventDataRepresentationSigned,\n WebhookEventDataTest,\n WebhookEventType,\n} from '../generated-webhooks';\n\n/** Fields every delivery carries, whatever its type. */\nexport type WebhookEventEnvelope = Omit<GeneratedEnvelope, 'type'> & { type: `${WebhookEventType}` };\n\n/** A real (non-test) event of type `K` carrying `D`. */\ntype BusinessEvent<K extends `${WebhookEventType}`, D> = Omit<GeneratedEnvelope, 'type' | 'test'> & {\n type: K;\n /** Absent or `false` on a real event; see `WebhookTestEvent`. */\n test?: false | null;\n data: D;\n};\n\n/** `verifactu.status.updated`: AEAT answered for an invoice's VeriFactu record (`new_status`, `qr_url`…). */\nexport type VeriFactuStatusUpdatedEvent = BusinessEvent<'verifactu.status.updated', WebhookEventDataVeriFactuStatusUpdated>;\n/** `invoice.issued`: an invoice was issued. */\nexport type InvoiceIssuedEvent = BusinessEvent<'invoice.issued', WebhookEventDataInvoiceIssued>;\n/** `invoice.voided`: an invoice was voided. */\nexport type InvoiceVoidedEvent = BusinessEvent<'invoice.voided', WebhookEventDataInvoiceVoided>;\n/** `invoice.email.sent`: an invoice email was accepted by the email provider. */\nexport type InvoiceEmailSentEvent = BusinessEvent<'invoice.email.sent', WebhookEventDataInvoiceEmailSent>;\n/** `invoice.pdf.generated`: the PDF of an invoice is ready. */\nexport type InvoicePdfGeneratedEvent = BusinessEvent<'invoice.pdf.generated', WebhookEventDataInvoicePdfGenerated>;\n/** `invoice.schedule_failed`: a scheduled invoice could not be processed. */\nexport type InvoiceScheduleFailedEvent = BusinessEvent<'invoice.schedule_failed', WebhookEventDataInvoiceScheduleFailed>;\n/** `recurring_invoice.paused`: a recurring invoice was paused. */\nexport type RecurringInvoicePausedEvent = BusinessEvent<'recurring_invoice.paused', WebhookEventDataRecurringInvoicePaused>;\n/** `account.claimed`: the holder of a provisioned account took ownership. */\nexport type AccountClaimedEvent = BusinessEvent<'account.claimed', WebhookEventDataAccountClaimed>;\n/** `company.created`: a company (NIF) was created. */\nexport type CompanyCreatedEvent = BusinessEvent<'company.created', WebhookEventDataCompanyCreated>;\n/** `representation.signed`: a representation document was signed. */\nexport type RepresentationSignedEvent = BusinessEvent<'representation.signed', WebhookEventDataRepresentationSigned>;\n\n/**\n * A delivery sent with \"Send test\": `test` is `true` and `data` is a synthetic message,\n * whatever `type` says. Check `event.test` before narrowing on `event.type`.\n */\nexport type WebhookTestEvent = Omit<GeneratedEnvelope, 'type' | 'test'> & {\n type: `${WebhookEventType}`;\n test: true;\n data: WebhookEventDataTest;\n};\n\n/**\n * Union type of all possible webhook events\n */\nexport type WebhookEvent =\n | VeriFactuStatusUpdatedEvent\n | InvoiceIssuedEvent\n | InvoiceVoidedEvent\n | InvoiceEmailSentEvent\n | InvoicePdfGeneratedEvent\n | InvoiceScheduleFailedEvent\n | RecurringInvoicePausedEvent\n | AccountClaimedEvent\n | CompanyCreatedEvent\n | RepresentationSignedEvent\n | WebhookTestEvent;\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataAccountClaimed } from './WebhookEventDataAccountClaimed';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type AccountClaimedEvent = (WebhookEventEnvelope & {\n type?: AccountClaimedEvent.type;\n data: WebhookEventDataAccountClaimed;\n});\nexport namespace AccountClaimedEvent {\n export enum type {\n ACCOUNT_CLAIMED = 'account.claimed',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataCompanyCreated } from './WebhookEventDataCompanyCreated';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type CompanyCreatedEvent = (WebhookEventEnvelope & {\n type?: CompanyCreatedEvent.type;\n data: WebhookEventDataCompanyCreated;\n});\nexport namespace CompanyCreatedEvent {\n export enum type {\n COMPANY_CREATED = 'company.created',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceEmailSent } from './WebhookEventDataInvoiceEmailSent';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceEmailSentEvent = (WebhookEventEnvelope & {\n type?: InvoiceEmailSentEvent.type;\n data: WebhookEventDataInvoiceEmailSent;\n});\nexport namespace InvoiceEmailSentEvent {\n export enum type {\n INVOICE_EMAIL_SENT = 'invoice.email.sent',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceIssued } from './WebhookEventDataInvoiceIssued';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceIssuedEvent = (WebhookEventEnvelope & {\n type?: InvoiceIssuedEvent.type;\n data: WebhookEventDataInvoiceIssued;\n});\nexport namespace InvoiceIssuedEvent {\n export enum type {\n INVOICE_ISSUED = 'invoice.issued',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoicePdfGenerated } from './WebhookEventDataInvoicePdfGenerated';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoicePdfGeneratedEvent = (WebhookEventEnvelope & {\n type?: InvoicePdfGeneratedEvent.type;\n data: WebhookEventDataInvoicePdfGenerated;\n});\nexport namespace InvoicePdfGeneratedEvent {\n export enum type {\n INVOICE_PDF_GENERATED = 'invoice.pdf.generated',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceScheduleFailed } from './WebhookEventDataInvoiceScheduleFailed';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceScheduleFailedEvent = (WebhookEventEnvelope & {\n type?: InvoiceScheduleFailedEvent.type;\n data: WebhookEventDataInvoiceScheduleFailed;\n});\nexport namespace InvoiceScheduleFailedEvent {\n export enum type {\n INVOICE_SCHEDULE_FAILED = 'invoice.schedule_failed',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataInvoiceVoided } from './WebhookEventDataInvoiceVoided';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type InvoiceVoidedEvent = (WebhookEventEnvelope & {\n type?: InvoiceVoidedEvent.type;\n data: WebhookEventDataInvoiceVoided;\n});\nexport namespace InvoiceVoidedEvent {\n export enum type {\n INVOICE_VOIDED = 'invoice.voided',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataRecurringInvoicePaused } from './WebhookEventDataRecurringInvoicePaused';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type RecurringInvoicePausedEvent = (WebhookEventEnvelope & {\n type?: RecurringInvoicePausedEvent.type;\n data: WebhookEventDataRecurringInvoicePaused;\n});\nexport namespace RecurringInvoicePausedEvent {\n export enum type {\n RECURRING_INVOICE_PAUSED = 'recurring_invoice.paused',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataRepresentationSigned } from './WebhookEventDataRepresentationSigned';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type RepresentationSignedEvent = (WebhookEventEnvelope & {\n type?: RepresentationSignedEvent.type;\n data: WebhookEventDataRepresentationSigned;\n});\nexport namespace RepresentationSignedEvent {\n export enum type {\n REPRESENTATION_SIGNED = 'representation.signed',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\n/**\n * Which record changed status: the invoice's registration or, if it was voided, its\n * cancellation. The same value as `operation` in the invoice's `verifactu-records`.\n *\n * * `REGISTRATION` — registration of the invoice.\n * * `VOID` — cancellation of a previously registered invoice.\n *\n */\nexport enum VeriFactuRecordOperation {\n REGISTRATION = 'REGISTRATION',\n VOID = 'VOID',\n}\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\nimport type { WebhookEventDataVeriFactuStatusUpdated } from './WebhookEventDataVeriFactuStatusUpdated';\nimport type { WebhookEventEnvelope } from './WebhookEventEnvelope';\nexport type VeriFactuStatusUpdatedEvent = (WebhookEventEnvelope & {\n type?: VeriFactuStatusUpdatedEvent.type;\n data: WebhookEventDataVeriFactuStatusUpdated;\n});\nexport namespace VeriFactuStatusUpdatedEvent {\n export enum type {\n VERIFACTU_STATUS_UPDATED = 'verifactu.status.updated',\n }\n}\n\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\n/**\n * VeriFactu registration status. Every value is also a value of `verifactu.submission_status`\n * on the invoice resource, so a status read from a webhook can be fed straight back into the\n * `verifactu_status` filter of `GET /v1/companies/{company_id}/invoices`. The API has one more\n * value, `NOT_SUBMITTED`, for a record that was never submitted, which is therefore never\n * sent in a webhook. New values may be added over time: treat any value you do not recognise\n * as an unknown status.\n *\n * * `PENDING` — queued, AEAT has not answered yet. A temporary AEAT server error also\n * stays `PENDING`: BeeL. retries it automatically, and it only becomes `REJECTED` if the\n * retries run out. So does a submission that failed because of a technical problem on\n * BeeL.'s side: BeeL. submits it again once the problem is fixed. Do not void it or issue\n * another invoice for it.\n * * `ACCEPTED` — accepted by AEAT without remarks.\n * * `ACCEPTED_WITH_ERRORS` — accepted by AEAT, which also reported errors in the record\n * (see `error_code` / `error_message`). The record stands, but the data AEAT flagged\n * must be reviewed. Do not treat it as a clean `ACCEPTED`.\n * * `VOIDED` — a cancellation record was accepted by AEAT.\n * * `REJECTED` — rejected by AEAT, or the submission was rejected by the provider\n * before reaching AEAT (see `error_code` / `error_message`).\n *\n */\nexport enum VeriFactuSubmissionStatus {\n PENDING = 'PENDING',\n ACCEPTED = 'ACCEPTED',\n ACCEPTED_WITH_ERRORS = 'ACCEPTED_WITH_ERRORS',\n VOIDED = 'VOIDED',\n REJECTED = 'REJECTED',\n}\n","/* generated using openapi-typescript-codegen -- do not edit */\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\n/**\n * Canonical set of event types BeeL. can deliver. Subscribe to the ones your\n * integration cares about via `POST /v1/webhooks` in the Public API.\n *\n */\nexport enum WebhookEventType {\n VERIFACTU_STATUS_UPDATED = 'verifactu.status.updated',\n INVOICE_ISSUED = 'invoice.issued',\n INVOICE_EMAIL_SENT = 'invoice.email.sent',\n INVOICE_PDF_GENERATED = 'invoice.pdf.generated',\n INVOICE_VOIDED = 'invoice.voided',\n RECURRING_INVOICE_PAUSED = 'recurring_invoice.paused',\n INVOICE_SCHEDULE_FAILED = 'invoice.schedule_failed',\n ACCOUNT_CLAIMED = 'account.claimed',\n COMPANY_CREATED = 'company.created',\n REPRESENTATION_SIGNED = 'representation.signed',\n}\n","import type { components } from '../generated/schema';\n\ntype CreateCustomerRequest = components['schemas']['CreateCustomerRequest'];\ntype Address = components['schemas']['Address'];\n\n/**\n * Fluent builder for the body of `customers.create`. It builds the request object only;\n * send it with `beel.company(companyId).customers.create(builder.build())`.\n *\n * @example\n * ```typescript\n * const customer = CustomerBuilder.create()\n * .name('Acme Corporation SL')\n * .nif('B12345678')\n * .email('contact@acme.com')\n * .address('Calle Mayor', '1', '28001', 'Madrid', 'Madrid', 'Spain')\n * .build();\n * ```\n */\nexport class CustomerBuilder {\n private _name?: string;\n private _nif?: string;\n private _email?: string;\n private _phone?: string;\n private _address?: Address;\n private _notes?: string;\n\n private constructor() {}\n\n /**\n * Start a new builder.\n *\n * @returns An empty customer builder.\n */\n static create(): CustomerBuilder {\n return new CustomerBuilder();\n }\n\n /**\n * Legal name of the customer. Required.\n *\n * @param name - Legal name.\n * @returns This builder.\n */\n name(name: string): this {\n this._name = name;\n return this;\n }\n\n /**\n * NIF/CIF of the customer. Required.\n *\n * @param nif - Spanish tax id.\n * @returns This builder.\n */\n nif(nif: string): this {\n this._nif = nif;\n return this;\n }\n\n /**\n * Contact email.\n *\n * @param email - Email address.\n * @returns This builder.\n */\n email(email: string): this {\n this._email = email;\n return this;\n }\n\n /**\n * Contact phone: 9 to 20 characters of digits, spaces, dashes, parentheses and a leading `+`.\n *\n * @param phone - Phone number.\n * @returns This builder.\n */\n phone(phone: string): this {\n this._phone = phone;\n return this;\n }\n\n /**\n * Fiscal address. Required.\n *\n * @param street - Street name.\n * @param number - Street number.\n * @param postalCode - Postal code.\n * @param city - City.\n * @param province - Province.\n * @param country - Country name.\n * @param countryCode - ISO 3166-1 alpha-2 code. Default: `ES`.\n * @returns This builder.\n */\n address(street: string, number: string, postalCode: string, city: string, province: string, country: string, countryCode: string = 'ES'): this {\n this._address = { street, number, postal_code: postalCode, city, province, country, country_code: countryCode };\n return this;\n }\n\n /**\n * Internal notes about the customer.\n *\n * @param notes - Free text.\n * @returns This builder.\n */\n notes(notes: string): this {\n this._notes = notes;\n return this;\n }\n\n /**\n * Build the request body.\n *\n * @returns The `CreateCustomerRequest`.\n * @throws {Error} When the name, NIF or address is missing.\n */\n build(): CreateCustomerRequest {\n if (!this._name || this._name.trim().length === 0) throw new Error('Legal name is required');\n if (!this._nif || this._nif.trim().length === 0) throw new Error('NIF/CIF is required');\n if (!this._address) throw new Error('Address is required');\n\n return {\n legal_name: this._name,\n nif: this._nif,\n email: this._email,\n phone: this._phone,\n address: this._address,\n notes: this._notes,\n };\n }\n}\n","import type { components } from '../generated/schema';\n\ntype CreateInvoiceRequest = components['schemas']['CreateInvoiceRequest'];\ntype InvoiceType = components['schemas']['InvoiceType'];\ntype Recipient = components['schemas']['Recipient'];\ntype InvoiceLine = CreateInvoiceRequest['lines'][number];\ntype LineMainTax = NonNullable<InvoiceLine['main_tax']>;\n\n/** Line type of the lines `addLine` builds: a regular line with its own tax. */\nconst NORMAL_LINE_TYPE = 'NORMAL' satisfies InvoiceLine['line_type'];\n\n/** Default of `addLine`'s `discountPercentage`. */\nconst NO_DISCOUNT = 0;\n\n/** `Date` → `YYYY-MM-DD`, the date format of the API. */\nfunction toIsoDate(date: string | Date): string {\n return date instanceof Date ? date.toISOString().split('T')[0] : date;\n}\n\n/**\n * Fluent builder for the body of `invoices.create`. It builds the request object only; send\n * it with `beel.company(companyId).invoices.create(builder.build())`.\n *\n * The API requires a `main_tax` on every `NORMAL` line (`422 LINE_MAIN_TAX_REQUIRED`\n * otherwise): set it once with {@link mainTax}, or per line in {@link addLine}.\n *\n * @example\n * ```typescript\n * const request = InvoiceBuilder.create()\n * .forCustomer('customer-uuid')\n * .mainTax({ type: 'IVA', percentage: 21, regime_key: '01' })\n * .addLine('Consulting services', 10, 85.5)\n * .build();\n * const invoice = await beel.company(companyId).invoices.create(request);\n * ```\n */\nexport class InvoiceBuilder {\n private _type: InvoiceType = 'STANDARD';\n private _operationDate?: string;\n private _dueDate?: string;\n private _customerId?: string;\n private _lines: InvoiceLine[] = [];\n private _notes?: string;\n private _seriesId?: string;\n private _metadata?: Record<string, any>;\n private _mainTax?: LineMainTax;\n\n private constructor() {}\n\n /**\n * Start a new builder.\n *\n * @returns An empty `STANDARD` invoice builder.\n */\n static create(): InvoiceBuilder {\n return new InvoiceBuilder();\n }\n\n /**\n * Set the invoice type. Default: `STANDARD`.\n *\n * @param type - `STANDARD`, `SIMPLIFIED` or `PROFORMA` (correctives use `createCorrective`).\n * @returns This builder.\n */\n type(type: InvoiceType): this {\n this._type = type;\n return this;\n }\n\n /**\n * Invoice a registered customer.\n *\n * @param customerId - Customer UUID.\n * @returns This builder.\n */\n forCustomer(customerId: string): this {\n this._customerId = customerId;\n return this;\n }\n\n /**\n * Date the operation took place, when it differs from the issue date.\n *\n * @param date - A `Date` or a `YYYY-MM-DD` string.\n * @returns This builder.\n */\n operationDate(date: string | Date): this {\n this._operationDate = toIsoDate(date);\n return this;\n }\n\n /**\n * Payment due date.\n *\n * @param date - A `Date` or a `YYYY-MM-DD` string.\n * @returns This builder.\n */\n dueDate(date: string | Date): this {\n this._dueDate = toIsoDate(date);\n return this;\n }\n\n /**\n * Main tax applied to every line added with {@link addLine} after this call, unless the\n * line passes its own.\n *\n * @param tax - For example `{ type: 'IVA', percentage: 21, regime_key: '01' }`.\n * @returns This builder.\n */\n mainTax(tax: LineMainTax): this {\n this._mainTax = tax;\n return this;\n }\n\n /**\n * Add a `NORMAL` line.\n *\n * @param description - What is invoiced.\n * @param quantity - Units.\n * @param unitPrice - Price per unit before taxes.\n * @param discountPercentage - Discount, 0–100. Default: `0`.\n * @param mainTax - Tax of this line; defaults to the one set with {@link mainTax}. The API\n * rejects a `NORMAL` line without one.\n * @returns This builder.\n */\n addLine(\n description: string,\n quantity: number,\n unitPrice: number,\n discountPercentage: number = NO_DISCOUNT,\n mainTax?: LineMainTax,\n ): this {\n const tax = mainTax ?? this._mainTax;\n this._lines.push({\n line_type: NORMAL_LINE_TYPE,\n description,\n quantity,\n unit_price: unitPrice,\n discount_percentage: discountPercentage,\n ...(tax ? { main_tax: tax } : {}),\n });\n return this;\n }\n\n /**\n * Add a line exactly as given — any line type or pricing mode.\n *\n * @param line - A line of `CreateInvoiceRequest`.\n * @returns This builder.\n */\n addLineObject(line: InvoiceLine): this {\n this._lines.push(line);\n return this;\n }\n\n /**\n * Notes printed on the invoice.\n *\n * @param notes - Free text.\n * @returns This builder.\n */\n notes(notes: string): this {\n this._notes = notes;\n return this;\n }\n\n /**\n * Number the invoice in this series instead of the default one.\n *\n * @param id - Series UUID.\n * @returns This builder.\n */\n series(id: string): this {\n this._seriesId = id;\n return this;\n }\n\n /**\n * Your own key/value pairs, filterable when listing.\n *\n * @param data - Metadata to store with the invoice.\n * @returns This builder.\n */\n metadata(data: Record<string, any>): this {\n this._metadata = data;\n return this;\n }\n\n /**\n * Build the request body.\n *\n * @returns The `CreateInvoiceRequest`.\n * @throws {Error} When there is no customer or no line.\n */\n build(): CreateInvoiceRequest {\n if (!this._customerId) throw new Error('Customer ID is required');\n if (this._lines.length === 0) throw new Error('At least one invoice line is required');\n\n const recipient: Recipient = { customer_id: this._customerId };\n\n return {\n type: this._type,\n operation_date: this._operationDate,\n due_date: this._dueDate,\n recipient,\n lines: this._lines,\n notes: this._notes,\n series_id: this._seriesId,\n metadata: this._metadata,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAyB;;;ACMlB,IAAM,mBAAmB;AAGzB,IAAM,sBAAsB;AAG5B,IAAM,yBAAyB;AAG/B,IAAM,6BAA6B;AAGnC,IAAM,+BAA+B;;;ACfrC,IAAM,yBAAyB;AAG/B,IAAM,4BAA4B;AAGlC,IAAM,qBAAqB;AAE3B,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB;AAC5B,IAAM,oBAAoB;AAG1B,IAAM,kBAAkB;;;AChB/B,oBAA2B;;;ACCpB,IAAM,aAAa;AAAA,EACxB,cAAc;AAAA,EACd,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,mBAAmB;AAAA;AAAA,EAEnB,kBAAkB;AACpB;AAGO,SAAS,oBAAoB,QAAyB;AAC3D,SAAO,UAAU,WAAW;AAC9B;;;ACZA,IAAM,yCAAyC;AAiBxC,IAAM,eAAN,cAA2B,MAAM;AAAA,EAoBtC,YACE,SACA,YACA,MACA,SACA,WACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,OAAO;AACZ,SAAK,UAAU,WAAW;AAC1B,SAAK,UAAU;AACf,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,qBAAN,cAAiC,aAAa;AAAA,EAInD,YAAY,SAAiB,mBAA2B,WAAoB,SAAkB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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,IAAkB;AACvB,SAAK,YAAY;AACjB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAS,MAAiC;AACxC,SAAK,YAAY;AACjB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAA8B;AAC5B,QAAI,CAAC,KAAK,YAAa,OAAM,IAAI,MAAM,yBAAyB;AAChE,QAAI,KAAK,OAAO,WAAW,EAAG,OAAM,IAAI,MAAM,uCAAuC;AAErF,UAAM,YAAuB,EAAE,aAAa,KAAK,YAAY;AAE7D,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,gBAAgB,KAAK;AAAA,MACrB,UAAU,KAAK;AAAA,MACf;AAAA,MACA,OAAO,KAAK;AAAA,MACZ,OAAO,KAAK;AAAA,MACZ,WAAW,KAAK;AAAA,MAChB,UAAU,KAAK;AAAA,IACjB;AAAA,EACF;AACF;","names":["createClient","import_crypto","AccountClaimedEvent","type","CompanyCreatedEvent","type","InvoiceEmailSentEvent","type","InvoiceIssuedEvent","type","InvoicePdfGeneratedEvent","type","InvoiceScheduleFailedEvent","type","InvoiceVoidedEvent","type","RecurringInvoicePausedEvent","type","RepresentationSignedEvent","type","VeriFactuRecordOperation","VeriFactuStatusUpdatedEvent","type","VeriFactuSubmissionStatus","WebhookEventType"]}