@classytic/ledger 0.9.1 → 0.10.1

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.
@@ -1,2 +1,2 @@
1
- import { a as EntryReversedNotification, c as PeriodLockedNotification, i as SourceRef, l as ReconciliationMismatchNotification, n as SourceBridge, o as NotificationBridge, r as SourceBridgeContext, s as NotificationBridgeContext, t as LedgerBridges, u as ExchangeRateBridge } from "../index-Dih0lM65.mjs";
1
+ import { a as EntryReversedNotification, c as PeriodLockedNotification, i as SourceRef, l as ReconciliationMismatchNotification, n as SourceBridge, o as NotificationBridge, r as SourceBridgeContext, s as NotificationBridgeContext, t as LedgerBridges, u as ExchangeRateBridge } from "../index-Bl0gP9lD.mjs";
2
2
  export { EntryReversedNotification, ExchangeRateBridge, LedgerBridges, NotificationBridge, NotificationBridgeContext, PeriodLockedNotification, ReconciliationMismatchNotification, SourceBridge, SourceBridgeContext, SourceRef };
@@ -109,7 +109,7 @@ function classifyDuplicateKey(err) {
109
109
  let keyPattern = e.keyPattern;
110
110
  if (!keyPattern && Array.isArray(e.writeErrors)) keyPattern = e.writeErrors.find((w) => w?.code === 11e3)?.keyPattern;
111
111
  if (!keyPattern && wrappedMsgMatch) {
112
- const fields = wrappedMsgMatch[1].split(",").map((f) => f.trim()).filter(Boolean);
112
+ const fields = wrappedMsgMatch[1]?.split(",").map((f) => f.trim()).filter(Boolean);
113
113
  keyPattern = Object.fromEntries(fields.map((f) => [f, 1]));
114
114
  }
115
115
  return {
@@ -1,2 +1,3 @@
1
- import { C as EntryReversedPayload, D as ReconciliationUnmatchedPayload, E as ReconciliationMatchedPayload, O as LEDGER_EVENTS, S as EntryPostedPayload, T as JournalSeededPayload, _ as AccountBulkCreatedPayload, a as OutboxOwnershipError, b as EntryCreatedPayload, c as InProcessLedgerBus, d as createEvent, f as DomainEvent, g as PublishManyResult, h as EventTransport, i as OutboxFailOptions, k as LedgerEventName, l as InProcessLedgerBusOptions, m as EventLogger, n as OutboxClaimOptions, o as OutboxStore, p as EventHandler, r as OutboxErrorInfo, s as OutboxWriteOptions, t as OutboxAcknowledgeOptions, u as EventContext, v as AccountSeededPayload, w as EntryUnpostedPayload, x as EntryDuplicatedPayload, y as EntryArchivedPayload } from "../outbox-store-UYC4eZpI.mjs";
2
- export { type AccountBulkCreatedPayload, type AccountSeededPayload, type DomainEvent, type EntryArchivedPayload, type EntryCreatedPayload, type EntryDuplicatedPayload, type EntryPostedPayload, type EntryReversedPayload, type EntryUnpostedPayload, type EventContext, type EventHandler, type EventLogger, type EventTransport, InProcessLedgerBus, type InProcessLedgerBusOptions, type JournalSeededPayload, LEDGER_EVENTS, type LedgerEventName, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, type PublishManyResult, type ReconciliationMatchedPayload, type ReconciliationUnmatchedPayload, createEvent };
1
+ import { $ as ReconciliationUnmatchedPayload, A as LedgerEventDefinition, B as InProcessLedgerBusOptions, C as EntryPostedPayloadSchema, D as EntryUnpostedPayloadSchema, E as EntryUnposted, F as ReconciliationUnmatched, G as EntryArchivedPayload, H as createEvent, I as ReconciliationUnmatchedPayloadSchema, J as EntryPostedPayload, K as EntryCreatedPayload, L as ledgerEventDefinitions, M as LedgerEventSchema, N as ReconciliationMatched, O as JournalSeeded, P as ReconciliationMatchedPayloadSchema, Q as ReconciliationMatchedPayload, R as EventLogger, S as EntryPosted, T as EntryReversedPayloadSchema, U as AccountBulkCreatedPayload, V as EventContext, W as AccountSeededPayload, X as EntryUnpostedPayload, Y as EntryReversedPayload, Z as JournalSeededPayload, _ as EntryArchivedPayloadSchema, a as OutboxFailOptions, b as EntryDuplicated, c as OutboxFailurePolicy, d as OutboxWriteOptions, et as LEDGER_EVENTS, f as AccountBulkCreated, g as EntryArchived, h as AccountSeededPayloadSchema, i as OutboxErrorInfo, j as LedgerEventPayloadOf, k as JournalSeededPayloadSchema, l as OutboxOwnershipError, m as AccountSeeded, n as OutboxAcknowledgeOptions, o as OutboxFailureContext, p as AccountBulkCreatedPayloadSchema, q as EntryDuplicatedPayload, r as OutboxClaimOptions, s as OutboxFailureDecision, t as InvalidOutboxEventError, tt as LedgerEventName, u as OutboxStore, v as EntryCreated, w as EntryReversed, x as EntryDuplicatedPayloadSchema, y as EntryCreatedPayloadSchema, z as InProcessLedgerBus } from "../outbox-store-BcCiHMPw.mjs";
2
+ import { DomainEvent, EventHandler, EventTransport, PublishManyResult } from "@classytic/primitives/events";
3
+ export { AccountBulkCreated, type AccountBulkCreatedPayload, type AccountBulkCreatedPayloadSchema, AccountSeeded, type AccountSeededPayload, type AccountSeededPayloadSchema, type DomainEvent, EntryArchived, type EntryArchivedPayload, type EntryArchivedPayloadSchema, EntryCreated, type EntryCreatedPayload, type EntryCreatedPayloadSchema, EntryDuplicated, type EntryDuplicatedPayload, type EntryDuplicatedPayloadSchema, EntryPosted, type EntryPostedPayload, type EntryPostedPayloadSchema, EntryReversed, type EntryReversedPayload, type EntryReversedPayloadSchema, EntryUnposted, type EntryUnpostedPayload, type EntryUnpostedPayloadSchema, type EventContext, type EventHandler, type EventLogger, type EventTransport, InProcessLedgerBus, type InProcessLedgerBusOptions, InvalidOutboxEventError, JournalSeeded, type JournalSeededPayload, type JournalSeededPayloadSchema, LEDGER_EVENTS, type LedgerEventDefinition, type LedgerEventName, type LedgerEventPayloadOf, type LedgerEventSchema, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, type PublishManyResult, ReconciliationMatched, type ReconciliationMatchedPayload, type ReconciliationMatchedPayloadSchema, ReconciliationUnmatched, type ReconciliationUnmatchedPayload, type ReconciliationUnmatchedPayloadSchema, createEvent, ledgerEventDefinitions };
@@ -1,2 +1,2 @@
1
- import { i as LEDGER_EVENTS, n as InProcessLedgerBus, r as createEvent, t as OutboxOwnershipError } from "../outbox-store-DQbL-KYT.mjs";
2
- export { InProcessLedgerBus, LEDGER_EVENTS, OutboxOwnershipError, createEvent };
1
+ import { _ as LEDGER_EVENTS, a as EntryArchived, c as EntryPosted, d as JournalSeeded, f as ReconciliationMatched, g as createEvent, h as InProcessLedgerBus, i as AccountSeeded, l as EntryReversed, m as ledgerEventDefinitions, n as OutboxOwnershipError, o as EntryCreated, p as ReconciliationUnmatched, r as AccountBulkCreated, s as EntryDuplicated, t as InvalidOutboxEventError, u as EntryUnposted } from "../outbox-store-BbKdQ2eT.mjs";
2
+ export { AccountBulkCreated, AccountSeeded, EntryArchived, EntryCreated, EntryDuplicated, EntryPosted, EntryReversed, EntryUnposted, InProcessLedgerBus, InvalidOutboxEventError, JournalSeeded, LEDGER_EVENTS, OutboxOwnershipError, ReconciliationMatched, ReconciliationUnmatched, createEvent, ledgerEventDefinitions };
@@ -1,4 +1,4 @@
1
- import { a as IdempotencyConflictError, i as Errors, t as AccountingError } from "./errors-BI5k4iak.mjs";
1
+ import { a as IdempotencyConflictError, i as Errors, t as AccountingError } from "./errors-vXd932rB.mjs";
2
2
  //#region src/plugins/double-entry.plugin.ts
3
3
  function doubleEntryPlugin(options = {}) {
4
4
  const { onlyOnPost = true, JournalEntryModel, AccountModel, orgField } = options;
@@ -161,9 +161,9 @@ interface SourceBridge {
161
161
  //#region src/bridges/index.d.ts
162
162
  /** Collected bridges exposed as `engine.bridges`. All optional per PACKAGE_RULES §23. */
163
163
  interface LedgerBridges {
164
- source?: SourceBridge;
165
- notification?: NotificationBridge;
166
- exchangeRate?: ExchangeRateBridge;
164
+ source?: SourceBridge | undefined;
165
+ notification?: NotificationBridge | undefined;
166
+ exchangeRate?: ExchangeRateBridge | undefined;
167
167
  }
168
168
  //#endregion
169
169
  export { EntryReversedNotification as a, PeriodLockedNotification as c, SourceRef as i, ReconciliationMismatchNotification as l, SourceBridge as n, NotificationBridge as o, SourceBridgeContext as r, NotificationBridgeContext as s, LedgerBridges as t, ExchangeRateBridge as u };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,16 @@
1
- import { a as EntryReversedNotification, c as PeriodLockedNotification, i as SourceRef, l as ReconciliationMismatchNotification, n as SourceBridge, o as NotificationBridge, r as SourceBridgeContext, s as NotificationBridgeContext, t as LedgerBridges, u as ExchangeRateBridge } from "./index-Dih0lM65.mjs";
1
+ import { a as EntryReversedNotification, c as PeriodLockedNotification, i as SourceRef, l as ReconciliationMismatchNotification, n as SourceBridge, o as NotificationBridge, r as SourceBridgeContext, s as NotificationBridgeContext, t as LedgerBridges, u as ExchangeRateBridge } from "./index-Bl0gP9lD.mjs";
2
2
  import { _ as TaxMetadata, a as Cents, c as DateRange, d as JournalType, f as MainType, g as TaxDetail, h as StatementType, i as CategoryKey, l as EntryState, m as ObjectId, n as CashFlowCategory, o as Currency, p as NormalBalance, s as DateOption, t as AccountType, u as JournalItem, v as TotalAccountOp } from "./core-DwjkrRkJ.mjs";
3
3
  import { S as isValidCategory, a as getJournalTypeCodes, b as isBalanceSheet, c as CURRENCIES, d as isValidCurrency, f as CATEGORIES, i as getJournalType, l as getCurrency, n as JOURNAL_TYPES, o as isValidJournalType, p as CATEGORY_KEYS, r as getCustomJournalTypes, s as registerJournalType, t as JOURNAL_CODES, u as getMinorUnit, x as isIncomeStatement, y as getNormalBalance } from "./journals-DUpWwFt1.mjs";
4
4
  import { i as defineCountryPack, n as CountryPackInput, r as JournalTemplate, t as CountryPack } from "./index-08IpHhrU.mjs";
5
- import { C as EntryReversedPayload, D as ReconciliationUnmatchedPayload, E as ReconciliationMatchedPayload, O as LEDGER_EVENTS, S as EntryPostedPayload, T as JournalSeededPayload, _ as AccountBulkCreatedPayload, a as OutboxOwnershipError, b as EntryCreatedPayload, c as InProcessLedgerBus, d as createEvent, f as DomainEvent, g as PublishManyResult, h as EventTransport, i as OutboxFailOptions, k as LedgerEventName, l as InProcessLedgerBusOptions, m as EventLogger, n as OutboxClaimOptions, o as OutboxStore, p as EventHandler, r as OutboxErrorInfo, s as OutboxWriteOptions, t as OutboxAcknowledgeOptions, u as EventContext, v as AccountSeededPayload, w as EntryUnpostedPayload, x as EntryDuplicatedPayload, y as EntryArchivedPayload } from "./outbox-store-UYC4eZpI.mjs";
5
+ import { $ as ReconciliationUnmatchedPayload, A as LedgerEventDefinition, B as InProcessLedgerBusOptions, E as EntryUnposted, F as ReconciliationUnmatched, G as EntryArchivedPayload, H as createEvent, J as EntryPostedPayload, K as EntryCreatedPayload, L as ledgerEventDefinitions, M as LedgerEventSchema, N as ReconciliationMatched, O as JournalSeeded, Q as ReconciliationMatchedPayload, R as EventLogger, S as EntryPosted, U as AccountBulkCreatedPayload, V as EventContext, W as AccountSeededPayload, X as EntryUnpostedPayload, Y as EntryReversedPayload, Z as JournalSeededPayload, a as OutboxFailOptions, b as EntryDuplicated, c as OutboxFailurePolicy, d as OutboxWriteOptions, et as LEDGER_EVENTS, f as AccountBulkCreated, g as EntryArchived, i as OutboxErrorInfo, j as LedgerEventPayloadOf, l as OutboxOwnershipError, m as AccountSeeded, n as OutboxAcknowledgeOptions, o as OutboxFailureContext, q as EntryDuplicatedPayload, r as OutboxClaimOptions, s as OutboxFailureDecision, t as InvalidOutboxEventError, tt as LedgerEventName, u as OutboxStore, v as EntryCreated, w as EntryReversed, z as InProcessLedgerBus } from "./outbox-store-BcCiHMPw.mjs";
6
6
  import { _ as PopulatedJournalEntry, a as exportToCsv, h as FlatJournalRow, i as quickbooksFieldMap, m as ExportFieldMap, p as ExportField, r as universalFieldMap, t as flattenJournalEntries } from "./index-J-XIbXH-.mjs";
7
7
  import { Money, abs, add, allocate, equals, format, formatPlain, fromDecimal, isNegative, isPositive, isValid, isZero, max, min, multiply, negate, parseCents, percentage, round, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal } from "./money.mjs";
8
8
  import { $ as AgedBalanceParams, A as generateDimensionBreakdown, B as BalanceSheetReport, D as DimensionBreakdownParams, E as DimensionBreakdownOptions, F as BudgetVsActualReport, G as IncomeStatementReport, H as CashFlowSection, I as BudgetVsActualRow, J as ReportCategory, K as LedgerEntry, L as generateBudgetVsActual, M as generateCashFlow, N as BudgetVsActualOptions, O as DimensionBreakdownReport, P as BudgetVsActualParams, Q as AgedBalanceOptions, T as reopenFiscalPeriod, U as GeneralLedgerAccount, V as CashFlowReport, W as GeneralLedgerReport, X as TrialBalanceReport, Y as ReportGroup, Z as TrialBalanceRow, a as RevaluationReport, at as Logger, b as generateGeneralLedger, c as RevaluationRate, d as computeRevaluation, et as AgedBalanceReport, f as PartnerLedgerLine, g as generatePartnerLedger, h as PartnerLedgerReport, i as RevaluationParams, it as generateAgedBalance, k as DimensionBreakdownRow, l as RevaluationResult, m as PartnerLedgerParams, n as generateTrialBalance, nt as AgedBucketConfig, o as generateRevaluation, ot as defaultLogger, p as PartnerLedgerOptions, q as ReportAccount, r as RevaluationOptions, rt as DEFAULT_BUCKETS, s as AccountForeignBalance, tt as AgedBalanceRow, u as buildRevaluationEntry, v as generateIncomeStatement, w as closeFiscalPeriod, z as generateBalanceSheet } from "./trial-balance-DyNm5bFu.mjs";
9
9
  import { A as OpenItem, C as AccountRepository, D as JournalItemRef, E as JournalEntryRepository, F as SeedOptions, I as SeedResult, M as ReconciliationRepository, N as ReverseOptions, O as JournalRepository, P as ReverseResult, S as creditLimitPlugin, T as BulkCreateResult, _ as FxRealizationPluginOptions, a as dailyLockPlugin, b as doubleEntryPlugin, c as periodResolver, d as LockAccountSelector, f as LockHit, g as idempotencyPlugin, i as FiscalLockPluginOptions, j as PostOptions, k as MatchInput, l as createLockPlugin, m as LockResolverContext, n as watermarkResolver, o as fiscalLockPlugin, p as LockResolver, r as DailyLockPluginOptions, s as PeriodResolverOptions, t as WatermarkResolverOptions, u as CreateLockPluginOptions, v as fxRealizationPlugin, w as BulkCreateInput, x as CreditLimitPluginOptions } from "./index-ClLwzNRF.mjs";
10
+ import { DomainEvent, EventHandler, EventTransport, EventTransport as EventTransport$1, PublishManyResult } from "@classytic/primitives/events";
10
11
  import { PaginationConfig, PluginFunction, PluginType, QueryParser, QueryParserOptions, Repository } from "@classytic/mongokit";
11
12
  import { ClientSession, Connection, Model } from "mongoose";
13
+ import { TenantConfig } from "@classytic/primitives/tenant";
12
14
 
13
15
  //#region src/plugins/immutable-guard.plugin.d.ts
14
16
  interface ImmutableGuardOptions {
@@ -126,79 +128,97 @@ declare function classifyDuplicateKey(err: unknown): {
126
128
  //#region src/types/engine.d.ts
127
129
  /** Mongokit plugins to install per repository (composes with engine built-ins). */
128
130
  interface LedgerRepositoryPlugins {
129
- account?: PluginType[];
130
- journalEntry?: PluginType[];
131
- fiscalPeriod?: PluginType[];
132
- budget?: PluginType[];
133
- reconciliation?: PluginType[];
134
- journal?: PluginType[];
131
+ account?: PluginType[] | undefined;
132
+ journalEntry?: PluginType[] | undefined;
133
+ fiscalPeriod?: PluginType[] | undefined;
134
+ budget?: PluginType[] | undefined;
135
+ reconciliation?: PluginType[] | undefined;
136
+ journal?: PluginType[] | undefined;
135
137
  }
136
138
  /** Pagination caps per repository. Omit a key to use mongokit defaults. */
137
139
  interface LedgerPaginationConfig {
138
- account?: PaginationConfig;
139
- journalEntry?: PaginationConfig;
140
- fiscalPeriod?: PaginationConfig;
141
- budget?: PaginationConfig;
142
- reconciliation?: PaginationConfig;
143
- journal?: PaginationConfig;
140
+ account?: PaginationConfig | undefined;
141
+ journalEntry?: PaginationConfig | undefined;
142
+ fiscalPeriod?: PaginationConfig | undefined;
143
+ budget?: PaginationConfig | undefined;
144
+ reconciliation?: PaginationConfig | undefined;
145
+ journal?: PaginationConfig | undefined;
144
146
  }
145
- /** Multi-tenant configuration */
146
- interface MultiTenantConfig {
147
- /** Field name for the organization reference (e.g., 'business', 'organization', 'company') */
148
- orgField: string;
149
- /** Mongoose model name the org field references (e.g., 'Business', 'Organization') */
150
- orgRef: string;
147
+ /**
148
+ * Multi-tenant configuration.
149
+ *
150
+ * Extends `@classytic/primitives/tenant` `TenantConfig` — field names match
151
+ * across primitives, mongokit's `MultiTenantOptions`, and ledger so hosts
152
+ * don't learn three shapes for the same idea. Ledger tightens the
153
+ * primitives' optional `tenantField` and `ref` into required (ledger has
154
+ * no sensible default — the host must name its organization collection).
155
+ */
156
+ interface MultiTenantConfig extends TenantConfig {
157
+ /**
158
+ * Field name for the organization reference (e.g., 'business',
159
+ * 'organization', 'company'). Required — ledger has no default here.
160
+ */
161
+ tenantField: string;
162
+ /**
163
+ * Mongoose model name the tenant field references (e.g., 'Business',
164
+ * 'Organization'). Required.
165
+ */
166
+ ref: string;
151
167
  /**
152
- * Enable mongokit's `multiTenantPlugin` on every ledger repository. The plugin
153
- * injects the tenant filter at POLICY priority (before cache/audit) whenever
154
- * `ctx.organizationId` is present on a call. When `false` (default), only
155
- * manual `orgField` filters inside domain verbs enforce scoping.
168
+ * Enable mongokit's `multiTenantPlugin` on every ledger repository. The
169
+ * plugin injects the tenant filter at POLICY priority (before cache/audit)
170
+ * whenever `ctx.organizationId` is present on a call. When `false`
171
+ * (default), only manual `tenantField` filters inside domain verbs enforce
172
+ * scoping.
156
173
  *
157
174
  * Recommended: `true` for new hosts. Keep `false` if your app has not yet
158
175
  * migrated to context-based scoping.
159
176
  */
160
- plugin?: boolean;
177
+ plugin?: boolean | undefined;
161
178
  /**
162
179
  * Fail closed when `ctx.organizationId` is missing on a plugin-scoped call.
163
180
  * Only applies when `plugin: true`. Default: `false` (skip injection when
164
181
  * context is empty — matches historical ledger behavior).
182
+ *
183
+ * Note: this is *plugin-level* fail-closed; the schema-level required flag
184
+ * on the tenant field is always `true` when multi-tenant is on.
165
185
  */
166
- required?: boolean;
186
+ required?: boolean | undefined;
167
187
  }
168
188
  /** Options passed to schema factory functions */
169
189
  interface SchemaOptions {
170
190
  /** Add recommended indexes (default: true) */
171
- indexes?: boolean;
191
+ indexes?: boolean | undefined;
172
192
  /** Extra Mongoose schema fields to merge in */
173
- extraFields?: Record<string, unknown>;
193
+ extraFields?: Record<string, unknown> | undefined;
174
194
  /** Extra indexes to add */
175
195
  extraIndexes?: Array<{
176
196
  fields: Record<string, 1 | -1>;
177
- options?: Record<string, unknown>;
178
- }>;
197
+ options?: Record<string, unknown> | undefined;
198
+ }> | undefined;
179
199
  }
180
200
  /** Journal entry schema-specific options */
181
201
  interface JournalSchemaOptions extends SchemaOptions {
182
202
  /** Auto-generate reference numbers (default: true) */
183
- autoReference?: boolean;
203
+ autoReference?: boolean | undefined;
184
204
  /** Enable text search index on reference + label (default: true) */
185
- textSearch?: boolean;
205
+ textSearch?: boolean | undefined;
186
206
  /** Extra Mongoose schema fields to merge into the JournalItem subdocument */
187
- extraItemFields?: Record<string, unknown>;
207
+ extraItemFields?: Record<string, unknown> | undefined;
188
208
  }
189
209
  /** Audit trail configuration */
190
210
  interface AuditConfig {
191
211
  /** Track actor (user) who performs each operation (post, reverse, approve) */
192
- trackActor?: boolean;
212
+ trackActor?: boolean | undefined;
193
213
  }
194
214
  /** Strictness rules for the ledger */
195
215
  interface StrictnessConfig {
196
216
  /** If true, unpost() is disabled — correction only via reverse() (immutable ledger) */
197
- immutable?: boolean;
217
+ immutable?: boolean | undefined;
198
218
  /** If true, actorId is required on post/reverse/unpost operations */
199
- requireActor?: boolean;
219
+ requireActor?: boolean | undefined;
200
220
  /** If true, entries must have approvedBy/approvedAt set before posting */
201
- requireApproval?: boolean;
221
+ requireApproval?: boolean | undefined;
202
222
  }
203
223
  /**
204
224
  * Multi-currency configuration.
@@ -222,19 +242,19 @@ interface MultiCurrencyConfig {
222
242
  /** Enable multi-currency fields on schemas */
223
243
  enabled: boolean;
224
244
  /** Allowed foreign currency codes. If omitted, any ISO 4217 code is accepted. */
225
- currencies?: readonly string[];
245
+ currencies?: readonly string[] | undefined;
226
246
  }
227
247
  /**
228
248
  * Override default model names. Useful when you want to avoid collisions
229
249
  * with existing models or use custom naming conventions.
230
250
  */
231
251
  interface ModelNames {
232
- account?: string;
233
- journalEntry?: string;
234
- fiscalPeriod?: string;
235
- budget?: string;
236
- reconciliation?: string;
237
- journal?: string;
252
+ account?: string | undefined;
253
+ journalEntry?: string | undefined;
254
+ fiscalPeriod?: string | undefined;
255
+ budget?: string | undefined;
256
+ reconciliation?: string | undefined;
257
+ journal?: string | undefined;
238
258
  }
239
259
  /** Main engine configuration */
240
260
  interface AccountingEngineConfig {
@@ -244,61 +264,61 @@ interface AccountingEngineConfig {
244
264
  */
245
265
  mongoose: Connection;
246
266
  /** Override default model names (e.g. 'Account' → 'GLAccount') */
247
- modelNames?: ModelNames;
267
+ modelNames?: ModelNames | undefined;
248
268
  /** Extra fields / indexes per model */
249
269
  schemaOptions?: {
250
- account?: SchemaOptions;
251
- journalEntry?: JournalSchemaOptions;
252
- fiscalPeriod?: SchemaOptions;
253
- budget?: SchemaOptions;
254
- reconciliation?: SchemaOptions;
255
- journal?: SchemaOptions;
256
- };
270
+ account?: SchemaOptions | undefined;
271
+ journalEntry?: JournalSchemaOptions | undefined;
272
+ fiscalPeriod?: SchemaOptions | undefined;
273
+ budget?: SchemaOptions | undefined;
274
+ reconciliation?: SchemaOptions | undefined;
275
+ journal?: SchemaOptions | undefined;
276
+ } | undefined;
257
277
  /** Country pack providing account types, tax codes, and templates */
258
278
  country: CountryPack;
259
279
  /** Default ISO 4217 currency code — the functional/base currency (e.g., 'CAD', 'BDT') */
260
280
  currency: string;
261
281
  /** Multi-tenant configuration. Omit for single-tenant apps. */
262
- multiTenant?: MultiTenantConfig;
282
+ multiTenant?: MultiTenantConfig | undefined;
263
283
  /** Multi-currency support. Omit for single-currency apps. */
264
- multiCurrency?: MultiCurrencyConfig;
284
+ multiCurrency?: MultiCurrencyConfig | undefined;
265
285
  /** Fiscal year start month (1-12, default: 1 = January) */
266
- fiscalYearStartMonth?: number;
286
+ fiscalYearStartMonth?: number | undefined;
267
287
  /**
268
288
  * The retained earnings account code (e.g. '3600' CA, '3310' BD).
269
289
  * Overrides the country pack value. See CountryPack.retainedEarningsAccountCode.
270
290
  */
271
- retainedEarningsAccountCode?: string;
291
+ retainedEarningsAccountCode?: string | undefined;
272
292
  /** Display code for the "Previous Years Retained Earnings" line. Overrides country pack. */
273
- retainedEarningsDisplayCode?: string;
293
+ retainedEarningsDisplayCode?: string | undefined;
274
294
  /** Display code for current year net income line. Overrides country pack. */
275
- currentYearEarningsCode?: string;
295
+ currentYearEarningsCode?: string | undefined;
276
296
  /** Logger instance. Defaults to console-based logger. */
277
- logger?: Logger;
297
+ logger?: Logger | undefined;
278
298
  /** Audit trail configuration */
279
- audit?: AuditConfig;
299
+ audit?: AuditConfig | undefined;
280
300
  /** Enable built-in idempotency key field on journal entries */
281
- idempotency?: boolean;
301
+ idempotency?: boolean | undefined;
282
302
  /**
283
303
  * TTL in seconds for idempotency records — stale replay keys auto-expire
284
304
  * via a partial TTL index so they don't collide with legitimate reuse
285
305
  * after the window closes. Default: 86400 (24h). Matches Stripe / Saleor
286
306
  * convention. Only applies when `idempotency: true`.
287
307
  */
288
- idempotencyTtlSeconds?: number;
308
+ idempotencyTtlSeconds?: number | undefined;
289
309
  /**
290
310
  * Automatically call `Model.syncIndexes()` on every managed model right
291
311
  * after the engine boots. Ensures new partial/TTL indexes (0.9.0+) are
292
312
  * present in MongoDB before the first write. Default: `false` — hosts
293
313
  * that run migrations themselves should leave this off.
294
314
  */
295
- syncIndexes?: boolean;
315
+ syncIndexes?: boolean | undefined;
296
316
  /** Strictness rules for the ledger */
297
- strictness?: StrictnessConfig;
317
+ strictness?: StrictnessConfig | undefined;
298
318
  /** Mongokit plugins to install per repository. */
299
- plugins?: LedgerRepositoryPlugins;
319
+ plugins?: LedgerRepositoryPlugins | undefined;
300
320
  /** Pagination caps per repository. */
301
- pagination?: LedgerPaginationConfig;
321
+ pagination?: LedgerPaginationConfig | undefined;
302
322
  /**
303
323
  * Mongoose type for the multi-tenant field on all ledger schemas.
304
324
  *
@@ -315,14 +335,14 @@ interface AccountingEngineConfig {
315
335
  * `multiTenant.plugin: true`. Schema-level type switching is applied
316
336
  * by the models factory when it supports dynamic type declaration.
317
337
  */
318
- tenantFieldType?: 'objectId' | 'string';
338
+ tenantFieldType?: 'objectId' | 'string' | undefined;
319
339
  /**
320
340
  * Optional event transport — structurally identical to `@classytic/arc`'s
321
341
  * `EventTransport`. Drop in any arc transport (Memory, Redis, Kafka, BullMQ)
322
342
  * or provide a custom one. When omitted, the engine uses an in-process bus
323
343
  * (`InProcessLedgerBus`) that is NOT suitable for multi-instance deployments.
324
344
  */
325
- eventTransport?: EventTransport;
345
+ eventTransport?: EventTransport$1 | undefined;
326
346
  /**
327
347
  * Optional host-owned outbox store — structurally identical to
328
348
  * `@classytic/arc`'s `OutboxStore`. When provided, domain events are
@@ -336,13 +356,13 @@ interface AccountingEngineConfig {
336
356
  * host picks `MongoOutboxStore` (arc), a SQL store, a Redis store,
337
357
  * etc. See `src/events/outbox-store.ts` for the interface contract.
338
358
  */
339
- outboxStore?: OutboxStore;
359
+ outboxStore?: OutboxStore | undefined;
340
360
  /**
341
361
  * Host-provided bridges for external integrations (source resolution,
342
362
  * notifications). All bridges and all methods are optional — features
343
363
  * degrade gracefully when a bridge is missing.
344
364
  */
345
- bridges?: LedgerBridges;
365
+ bridges?: LedgerBridges | undefined;
346
366
  }
347
367
  //#endregion
348
368
  //#region src/models/factory.d.ts
@@ -380,7 +400,7 @@ interface LedgerRepositories {
380
400
  * consumers without events/bridges see no behavioral change.
381
401
  */
382
402
  interface LedgerRepositoryIntegrations {
383
- events?: EventTransport;
403
+ events?: EventTransport$1;
384
404
  bridges?: LedgerBridges;
385
405
  outboxStore?: OutboxStore;
386
406
  }
@@ -699,7 +719,7 @@ declare class AccountingEngine {
699
719
  * `InProcessLedgerBus` (suitable for single-instance deployments only).
700
720
  * Subscribe with glob patterns: `ledger:entry.*`, `ledger:reconciliation.*`, `*`.
701
721
  */
702
- readonly events: EventTransport;
722
+ readonly events: EventTransport$1;
703
723
  /**
704
724
  * Host-provided bridges. Empty object when none supplied. Callers should
705
725
  * optional-chain every method (`engine.bridges.source?.resolve?.(...)`).
@@ -1049,4 +1069,4 @@ interface PostingResult {
1049
1069
  idempotencyKeys?: string[];
1050
1070
  }
1051
1071
  //#endregion
1052
- export { type AccountBulkCreatedPayload, type AccountCode, type AccountForeignBalance, type AccountRepository, type AccountSeededPayload, type AccountSummary, type AccountType, AccountingEngine, type AccountingEngineConfig, AccountingError, type ActorContext, type AgedBalanceOptions, type AgedBalanceParams, type AgedBalanceReport, type AgedBalanceRow, type AgedBucketConfig, type AuditConfig, type BalanceSheetReport, type BudgetVsActualOptions, type BudgetVsActualParams, type BudgetVsActualReport, type BudgetVsActualRow, type BulkCreateInput, type BulkCreateResult, CATEGORIES, CATEGORY_KEYS, CURRENCIES, type CashFlowCategory, type CashFlowReport, type CashFlowSection, type CategoryKey, type Cents, ConcurrencyError, type CountryPack, type CountryPackInput, type CreateLockPluginOptions, type CreditLimitPluginOptions, type Currency, DEFAULT_BUCKETS, type DailyLockPluginOptions, type DateOption, type DateRange, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type DimensionDefinition, type DomainEvent, DuplicateReferenceError, type EntryArchivedPayload, type EntryCreatedPayload, type EntryDuplicatedPayload, type EntryPostedPayload, type EntryReversedNotification, type EntryReversedPayload, type EntryState, type EntryUnpostedPayload, Errors, type EventContext, type EventHandler, type EventLogger, type EventTransport, type ExchangeRateBridge, type ExportField, type ExportFieldMap, type FieldError, type FiscalLockPluginOptions, type FiscalPeriodSummary, type FlatJournalRow, type FxRealizationPluginOptions, type GeneralLedgerAccount, type GeneralLedgerReport, IdempotencyConflictError, type ImmutableGuardOptions, ImmutableViolationError, InProcessLedgerBus, type InProcessLedgerBusOptions, type IncomeStatementReport, type IntrospectAPI, JOURNAL_CODES, JOURNAL_TYPES, type JournalEntryRepository, type JournalItem, type JournalItemRef, type JournalRepository, type JournalSchemaOptions, type JournalSeededPayload, type JournalTemplate, type JournalType, LEDGER_EVENTS, type LedgerBridges, type LedgerEntry, type LedgerEventName, type LedgerModels, type LedgerPaginationConfig, type LedgerRepositories, type LedgerRepositoryPlugins, type LockAccountSelector, type LockHit, type LockResolver, type LockResolverContext, type Logger, type MainType, type MatchHookContext, type MatchHookItem, type MatchInput, type ModelNames, Money, type MultiCurrencyConfig, type MultiTenantConfig, type NormalBalance, type NotificationBridge, type NotificationBridgeContext, type OpenItem, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, type PartnerLedgerLine, type PartnerLedgerOptions, type PartnerLedgerParams, type PartnerLedgerReport, type PeriodLockedNotification, type PeriodResolverOptions, type PopulatedJournalEntry, type PostOptions, type PostingContract, type PostingResult, type PublishManyResult, type ReconciliationMatchedPayload, type ReconciliationMismatchNotification, type ReconciliationRepository, type ReconciliationUnmatchedPayload, type RecordAPI, type RecordAdjustmentInput, type RecordAdjustmentLine, type RecordExpenseInput, type RecordOptions, type RecordPaymentInput, type RecordSaleInput, type RecordTransferInput, type ReportAccount, type ReportCategory, type ReportDescriptor, type ReportGroup, type ResolvedModelNames, type RevaluationOptions, type RevaluationParams, type RevaluationRate, type RevaluationReport, type RevaluationResult, type ReverseOptions, type ReverseResult, type SchemaOptions, type SeedOptions, type SeedResult, type Cents$1 as SemanticCents, type SessionResult, type SourceBridge, type SourceBridgeContext, type SourceRef, type StatementType, type StrictnessConfig, type SubledgerJournalItem, type SubledgerPostingInput, type TaxDetail, type TaxMetadata, type TotalAccountOp, type TrialBalanceReport, type TrialBalanceRow, type UnmatchHookContext, type WatermarkResolverOptions, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, classifyDuplicateKey, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountingEngine, createEvent, createLockPlugin, createModels, createRepositories, creditLimitPlugin, dailyLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, fxRealizationPlugin, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generatePartnerLedger, generateRevaluation, generateTrialBalance, getCurrency, getCustomJournalTypes, getDateRange, getFiscalYearStart, getJournalType, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, immutableGuardPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, multiply, parseCents, percentage, periodResolver, quickbooksFieldMap, registerJournalType, reopenFiscalPeriod, resolveModelNames, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, watermarkResolver };
1072
+ export { AccountBulkCreated, type AccountBulkCreatedPayload, type AccountCode, type AccountForeignBalance, type AccountRepository, AccountSeeded, type AccountSeededPayload, type AccountSummary, type AccountType, AccountingEngine, type AccountingEngineConfig, AccountingError, type ActorContext, type AgedBalanceOptions, type AgedBalanceParams, type AgedBalanceReport, type AgedBalanceRow, type AgedBucketConfig, type AuditConfig, type BalanceSheetReport, type BudgetVsActualOptions, type BudgetVsActualParams, type BudgetVsActualReport, type BudgetVsActualRow, type BulkCreateInput, type BulkCreateResult, CATEGORIES, CATEGORY_KEYS, CURRENCIES, type CashFlowCategory, type CashFlowReport, type CashFlowSection, type CategoryKey, type Cents, ConcurrencyError, type CountryPack, type CountryPackInput, type CreateLockPluginOptions, type CreditLimitPluginOptions, type Currency, DEFAULT_BUCKETS, type DailyLockPluginOptions, type DateOption, type DateRange, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type DimensionDefinition, type DomainEvent, DuplicateReferenceError, EntryArchived, type EntryArchivedPayload, EntryCreated, type EntryCreatedPayload, EntryDuplicated, type EntryDuplicatedPayload, EntryPosted, type EntryPostedPayload, EntryReversed, type EntryReversedNotification, type EntryReversedPayload, type EntryState, EntryUnposted, type EntryUnpostedPayload, Errors, type EventContext, type EventHandler, type EventLogger, type EventTransport, type ExchangeRateBridge, type ExportField, type ExportFieldMap, type FieldError, type FiscalLockPluginOptions, type FiscalPeriodSummary, type FlatJournalRow, type FxRealizationPluginOptions, type GeneralLedgerAccount, type GeneralLedgerReport, IdempotencyConflictError, type ImmutableGuardOptions, ImmutableViolationError, InProcessLedgerBus, type InProcessLedgerBusOptions, type IncomeStatementReport, type IntrospectAPI, InvalidOutboxEventError, JOURNAL_CODES, JOURNAL_TYPES, type JournalEntryRepository, type JournalItem, type JournalItemRef, type JournalRepository, type JournalSchemaOptions, JournalSeeded, type JournalSeededPayload, type JournalTemplate, type JournalType, LEDGER_EVENTS, type LedgerBridges, type LedgerEntry, type LedgerEventDefinition, type LedgerEventName, type LedgerEventPayloadOf, type LedgerEventSchema, type LedgerModels, type LedgerPaginationConfig, type LedgerRepositories, type LedgerRepositoryPlugins, type LockAccountSelector, type LockHit, type LockResolver, type LockResolverContext, type Logger, type MainType, type MatchHookContext, type MatchHookItem, type MatchInput, type ModelNames, Money, type MultiCurrencyConfig, type MultiTenantConfig, type NormalBalance, type NotificationBridge, type NotificationBridgeContext, type OpenItem, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, type PartnerLedgerLine, type PartnerLedgerOptions, type PartnerLedgerParams, type PartnerLedgerReport, type PeriodLockedNotification, type PeriodResolverOptions, type PopulatedJournalEntry, type PostOptions, type PostingContract, type PostingResult, type PublishManyResult, ReconciliationMatched, type ReconciliationMatchedPayload, type ReconciliationMismatchNotification, type ReconciliationRepository, ReconciliationUnmatched, type ReconciliationUnmatchedPayload, type RecordAPI, type RecordAdjustmentInput, type RecordAdjustmentLine, type RecordExpenseInput, type RecordOptions, type RecordPaymentInput, type RecordSaleInput, type RecordTransferInput, type ReportAccount, type ReportCategory, type ReportDescriptor, type ReportGroup, type ResolvedModelNames, type RevaluationOptions, type RevaluationParams, type RevaluationRate, type RevaluationReport, type RevaluationResult, type ReverseOptions, type ReverseResult, type SchemaOptions, type SeedOptions, type SeedResult, type Cents$1 as SemanticCents, type SessionResult, type SourceBridge, type SourceBridgeContext, type SourceRef, type StatementType, type StrictnessConfig, type SubledgerJournalItem, type SubledgerPostingInput, type TaxDetail, type TaxMetadata, type TotalAccountOp, type TrialBalanceReport, type TrialBalanceRow, type UnmatchHookContext, type WatermarkResolverOptions, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, classifyDuplicateKey, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountingEngine, createEvent, createLockPlugin, createModels, createRepositories, creditLimitPlugin, dailyLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, fxRealizationPlugin, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generatePartnerLedger, generateRevaluation, generateTrialBalance, getCurrency, getCustomJournalTypes, getDateRange, getFiscalYearStart, getJournalType, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, immutableGuardPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, ledgerEventDefinitions, multiply, parseCents, percentage, periodResolver, quickbooksFieldMap, registerJournalType, reopenFiscalPeriod, resolveModelNames, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, watermarkResolver };