@paprflare/tally 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,478 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Tally's HTTP layer is not a reliable signal of success. A failed voucher
5
+ * import still comes back as HTTP 200 with a <LINEERROR> buried in the body.
6
+ * Network failures, XML parse failures, and Tally-side rejections are three
7
+ * different failure classes with three different recovery strategies (retry,
8
+ * fix-your-builder-bug, fix-your-data) — so we keep them as distinct codes
9
+ * instead of collapsing everything into a generic Error.
10
+ */
11
+ type TallyErrorCode = "NETWORK_ERROR" | "TIMEOUT" | "PARSE_ERROR" | "TALLY_REJECTED" | "VALIDATION_ERROR" | "NOT_FOUND" | "UNKNOWN";
12
+ interface TallyError {
13
+ code: TallyErrorCode;
14
+ message: string;
15
+ /** Raw <LINEERROR> text from Tally, when code === "TALLY_REJECTED" */
16
+ tallyMessage?: string;
17
+ /** The XML request body that produced this error, kept for debugging/logging */
18
+ requestXml?: string;
19
+ /** The raw XML response body, when one was received */
20
+ responseXml?: string;
21
+ /** Underlying cause (e.g. an AxiosError, a ZodError), for stack traces */
22
+ cause?: unknown;
23
+ }
24
+ type Result<T, E = TallyError> = {
25
+ ok: true;
26
+ value: T;
27
+ } | {
28
+ ok: false;
29
+ error: E;
30
+ };
31
+ declare function ok<T>(value: T): Result<T, never>;
32
+ declare function err<E = TallyError>(error: E): Result<never, E>;
33
+ declare function tallyError(code: TallyErrorCode, message: string, extra?: Partial<Omit<TallyError, "code" | "message">>): TallyError;
34
+ /** Narrow a Result to its value, or throw — for callers who'd rather not
35
+ * thread Result through their own code. Named unwrap (not "get") so misuse
36
+ * is obvious at the call site. */
37
+ declare function unwrap<T>(result: Result<T, TallyError>): T;
38
+ interface TallyConfig {
39
+ host: string;
40
+ port: number;
41
+ /** Defaults to false; set true only for instances behind TLS termination */
42
+ https?: boolean;
43
+ /** Defaults to the active company in Tally if omitted */
44
+ company?: string;
45
+ /** Request timeout in ms; Tally can be slow on large COLLECTION exports */
46
+ timeoutMs?: number;
47
+ /** Retries on NETWORK_ERROR/TIMEOUT only — never on TALLY_REJECTED */
48
+ retries?: number;
49
+ }
50
+
51
+ declare const LedgerInputSchema: z.ZodObject<{
52
+ name: z.ZodString;
53
+ group: z.ZodString;
54
+ gstin: z.ZodOptional<z.ZodString>;
55
+ openingBalance: z.ZodOptional<z.ZodNumber>;
56
+ openingBalanceType: z.ZodOptional<z.ZodEnum<{
57
+ Debit: "Debit";
58
+ Credit: "Credit";
59
+ }>>;
60
+ address: z.ZodOptional<z.ZodArray<z.ZodString>>;
61
+ state: z.ZodOptional<z.ZodString>;
62
+ pincode: z.ZodOptional<z.ZodString>;
63
+ email: z.ZodOptional<z.ZodString>;
64
+ phone: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strip>;
66
+ type LedgerInput = z.infer<typeof LedgerInputSchema>;
67
+ declare const LedgerSchema: z.ZodObject<{
68
+ name: z.ZodString;
69
+ guid: z.ZodString;
70
+ group: z.ZodString;
71
+ gstin: z.ZodOptional<z.ZodString>;
72
+ closingBalance: z.ZodOptional<z.ZodNumber>;
73
+ state: z.ZodOptional<z.ZodString>;
74
+ }, z.core.$strip>;
75
+ type Ledger = z.infer<typeof LedgerSchema>;
76
+ declare const StockItemSchema: z.ZodObject<{
77
+ name: z.ZodString;
78
+ guid: z.ZodString;
79
+ unit: z.ZodString;
80
+ closingQty: z.ZodOptional<z.ZodNumber>;
81
+ closingValue: z.ZodOptional<z.ZodNumber>;
82
+ hsnCode: z.ZodOptional<z.ZodString>;
83
+ gstRate: z.ZodOptional<z.ZodNumber>;
84
+ }, z.core.$strip>;
85
+ type StockItem = z.infer<typeof StockItemSchema>;
86
+ declare const StockItemInputSchema: z.ZodObject<{
87
+ name: z.ZodString;
88
+ group: z.ZodDefault<z.ZodString>;
89
+ unit: z.ZodString;
90
+ hsnCode: z.ZodOptional<z.ZodString>;
91
+ gstRate: z.ZodOptional<z.ZodNumber>;
92
+ openingQty: z.ZodOptional<z.ZodNumber>;
93
+ openingRate: z.ZodOptional<z.ZodNumber>;
94
+ }, z.core.$strip>;
95
+ type StockItemInput = z.infer<typeof StockItemInputSchema>;
96
+ declare const CompanySchema: z.ZodObject<{
97
+ name: z.ZodString;
98
+ guid: z.ZodString;
99
+ startingFrom: z.ZodOptional<z.ZodString>;
100
+ endingAt: z.ZodOptional<z.ZodString>;
101
+ }, z.core.$strip>;
102
+ type Company = z.infer<typeof CompanySchema>;
103
+ declare const OutstandingEntrySchema: z.ZodObject<{
104
+ ledgerName: z.ZodString;
105
+ voucherNumber: z.ZodString;
106
+ voucherDate: z.ZodCoercedDate<unknown>;
107
+ dueDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
108
+ pendingAmount: z.ZodNumber;
109
+ overdueDays: z.ZodOptional<z.ZodNumber>;
110
+ }, z.core.$strip>;
111
+ type OutstandingEntry = z.infer<typeof OutstandingEntrySchema>;
112
+
113
+ declare const lineItemSchema: z.ZodObject<{
114
+ stockItem: z.ZodString;
115
+ quantity: z.ZodNumber;
116
+ rate: z.ZodNumber;
117
+ amount: z.ZodOptional<z.ZodNumber>;
118
+ }, z.core.$strip>;
119
+ type LineItem = z.infer<typeof lineItemSchema>;
120
+ declare const SalesVoucherInputSchema: z.ZodObject<{
121
+ party: z.ZodString;
122
+ items: z.ZodArray<z.ZodObject<{
123
+ stockItem: z.ZodString;
124
+ quantity: z.ZodNumber;
125
+ rate: z.ZodNumber;
126
+ amount: z.ZodOptional<z.ZodNumber>;
127
+ }, z.core.$strip>>;
128
+ salesLedger: z.ZodDefault<z.ZodString>;
129
+ taxes: z.ZodOptional<z.ZodArray<z.ZodObject<{
130
+ ledger: z.ZodString;
131
+ amount: z.ZodNumber;
132
+ }, z.core.$strip>>>;
133
+ date: z.ZodCoercedDate<unknown>;
134
+ narration: z.ZodOptional<z.ZodString>;
135
+ voucherNumber: z.ZodOptional<z.ZodString>;
136
+ reference: z.ZodOptional<z.ZodString>;
137
+ voucherType: z.ZodLiteral<"Sales">;
138
+ }, z.core.$strip>;
139
+ type SalesVoucherInput = z.infer<typeof SalesVoucherInputSchema>;
140
+ declare const PurchaseVoucherInputSchema: z.ZodObject<{
141
+ party: z.ZodString;
142
+ items: z.ZodArray<z.ZodObject<{
143
+ stockItem: z.ZodString;
144
+ quantity: z.ZodNumber;
145
+ rate: z.ZodNumber;
146
+ amount: z.ZodOptional<z.ZodNumber>;
147
+ }, z.core.$strip>>;
148
+ purchaseLedger: z.ZodDefault<z.ZodString>;
149
+ taxes: z.ZodOptional<z.ZodArray<z.ZodObject<{
150
+ ledger: z.ZodString;
151
+ amount: z.ZodNumber;
152
+ }, z.core.$strip>>>;
153
+ date: z.ZodCoercedDate<unknown>;
154
+ narration: z.ZodOptional<z.ZodString>;
155
+ voucherNumber: z.ZodOptional<z.ZodString>;
156
+ reference: z.ZodOptional<z.ZodString>;
157
+ voucherType: z.ZodLiteral<"Purchase">;
158
+ }, z.core.$strip>;
159
+ type PurchaseVoucherInput = z.infer<typeof PurchaseVoucherInputSchema>;
160
+ declare const PaymentVoucherInputSchema: z.ZodObject<{
161
+ debitLedger: z.ZodString;
162
+ creditLedger: z.ZodString;
163
+ amount: z.ZodNumber;
164
+ date: z.ZodCoercedDate<unknown>;
165
+ narration: z.ZodOptional<z.ZodString>;
166
+ voucherNumber: z.ZodOptional<z.ZodString>;
167
+ reference: z.ZodOptional<z.ZodString>;
168
+ voucherType: z.ZodLiteral<"Payment">;
169
+ }, z.core.$strip>;
170
+ type PaymentVoucherInput = z.infer<typeof PaymentVoucherInputSchema>;
171
+ declare const ReceiptVoucherInputSchema: z.ZodObject<{
172
+ debitLedger: z.ZodString;
173
+ creditLedger: z.ZodString;
174
+ amount: z.ZodNumber;
175
+ date: z.ZodCoercedDate<unknown>;
176
+ narration: z.ZodOptional<z.ZodString>;
177
+ voucherNumber: z.ZodOptional<z.ZodString>;
178
+ reference: z.ZodOptional<z.ZodString>;
179
+ voucherType: z.ZodLiteral<"Receipt">;
180
+ }, z.core.$strip>;
181
+ type ReceiptVoucherInput = z.infer<typeof ReceiptVoucherInputSchema>;
182
+ declare const JournalVoucherInputSchema: z.ZodObject<{
183
+ entries: z.ZodArray<z.ZodObject<{
184
+ ledger: z.ZodString;
185
+ type: z.ZodEnum<{
186
+ Debit: "Debit";
187
+ Credit: "Credit";
188
+ }>;
189
+ amount: z.ZodNumber;
190
+ }, z.core.$strip>>;
191
+ date: z.ZodCoercedDate<unknown>;
192
+ narration: z.ZodOptional<z.ZodString>;
193
+ voucherNumber: z.ZodOptional<z.ZodString>;
194
+ reference: z.ZodOptional<z.ZodString>;
195
+ voucherType: z.ZodLiteral<"Journal">;
196
+ }, z.core.$strip>;
197
+ type JournalVoucherInput = z.infer<typeof JournalVoucherInputSchema>;
198
+ declare const VoucherInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
199
+ party: z.ZodString;
200
+ items: z.ZodArray<z.ZodObject<{
201
+ stockItem: z.ZodString;
202
+ quantity: z.ZodNumber;
203
+ rate: z.ZodNumber;
204
+ amount: z.ZodOptional<z.ZodNumber>;
205
+ }, z.core.$strip>>;
206
+ salesLedger: z.ZodDefault<z.ZodString>;
207
+ taxes: z.ZodOptional<z.ZodArray<z.ZodObject<{
208
+ ledger: z.ZodString;
209
+ amount: z.ZodNumber;
210
+ }, z.core.$strip>>>;
211
+ date: z.ZodCoercedDate<unknown>;
212
+ narration: z.ZodOptional<z.ZodString>;
213
+ voucherNumber: z.ZodOptional<z.ZodString>;
214
+ reference: z.ZodOptional<z.ZodString>;
215
+ voucherType: z.ZodLiteral<"Sales">;
216
+ }, z.core.$strip>, z.ZodObject<{
217
+ party: z.ZodString;
218
+ items: z.ZodArray<z.ZodObject<{
219
+ stockItem: z.ZodString;
220
+ quantity: z.ZodNumber;
221
+ rate: z.ZodNumber;
222
+ amount: z.ZodOptional<z.ZodNumber>;
223
+ }, z.core.$strip>>;
224
+ purchaseLedger: z.ZodDefault<z.ZodString>;
225
+ taxes: z.ZodOptional<z.ZodArray<z.ZodObject<{
226
+ ledger: z.ZodString;
227
+ amount: z.ZodNumber;
228
+ }, z.core.$strip>>>;
229
+ date: z.ZodCoercedDate<unknown>;
230
+ narration: z.ZodOptional<z.ZodString>;
231
+ voucherNumber: z.ZodOptional<z.ZodString>;
232
+ reference: z.ZodOptional<z.ZodString>;
233
+ voucherType: z.ZodLiteral<"Purchase">;
234
+ }, z.core.$strip>, z.ZodObject<{
235
+ debitLedger: z.ZodString;
236
+ creditLedger: z.ZodString;
237
+ amount: z.ZodNumber;
238
+ date: z.ZodCoercedDate<unknown>;
239
+ narration: z.ZodOptional<z.ZodString>;
240
+ voucherNumber: z.ZodOptional<z.ZodString>;
241
+ reference: z.ZodOptional<z.ZodString>;
242
+ voucherType: z.ZodLiteral<"Payment">;
243
+ }, z.core.$strip>, z.ZodObject<{
244
+ debitLedger: z.ZodString;
245
+ creditLedger: z.ZodString;
246
+ amount: z.ZodNumber;
247
+ date: z.ZodCoercedDate<unknown>;
248
+ narration: z.ZodOptional<z.ZodString>;
249
+ voucherNumber: z.ZodOptional<z.ZodString>;
250
+ reference: z.ZodOptional<z.ZodString>;
251
+ voucherType: z.ZodLiteral<"Receipt">;
252
+ }, z.core.$strip>], "voucherType">;
253
+ type VoucherInput = SalesVoucherInput | PurchaseVoucherInput | PaymentVoucherInput | ReceiptVoucherInput | JournalVoucherInput;
254
+ /** Exhaustiveness helper: pass an unreachable VoucherInput here in a
255
+ * `default` switch branch — if a new voucher type is added to the union
256
+ * without updating the builder, this fails to compile instead of failing at
257
+ * runtime in front of a customer. */
258
+ declare function assertNever(x: never): never;
259
+ interface VoucherCreateResult {
260
+ voucherNumber: string;
261
+ guid: string;
262
+ alteredOn: Date;
263
+ }
264
+
265
+ /**
266
+ * Tally's XML is XML-shaped but not XML-clean. Two encoding quirks matter
267
+ * enough to centralize here rather than handle ad hoc in every builder:
268
+ *
269
+ * 1. Standard XML entities (&, <, >, ", ') still need escaping — Tally's
270
+ * parser is otherwise normal on that front.
271
+ * 2. Tally has its own non-standard "empty but present" marker, &#4;, used
272
+ * in some master-import contexts to distinguish "field omitted" from
273
+ * "field explicitly cleared". We expose escapeXml() for normal text and
274
+ * leave &#4; as an explicit opt-in (EMPTY_MARKER) so builders don't emit
275
+ * it by accident.
276
+ */
277
+ declare const EMPTY_MARKER = "&#4;";
278
+ declare function escapeXml(value: string): string;
279
+ /** Tally dates are YYYYMMDD with no separators, always. */
280
+ declare function formatTallyDate(date: Date): string;
281
+ /**
282
+ * Tally renders negative ledger amounts as a sign on the number, but which
283
+ * sign means debit vs credit flips depending on whether you're looking at a
284
+ * Sales-side or Purchase-side ledger entry. Rather than push that
285
+ * ambiguity onto every builder, callers pass an explicit `isDebit` flag and
286
+ * this function produces the signed string Tally expects: debit entries are
287
+ * positive, credit entries are negative, full stop, at the wire level.
288
+ */
289
+ declare function formatSignedAmount(amount: number, isDebit: boolean): string;
290
+ type EnvelopeRequestType = "Import Data" | "Export Data";
291
+ interface EnvelopeOptions {
292
+ requestType: EnvelopeRequestType;
293
+ /** "Vouchers" | "Masters" | "Collection" | "Company" — Tally's REPORTNAME/ID context */
294
+ id: string;
295
+ company?: string;
296
+ staticVariables?: Record<string, string>;
297
+ }
298
+ /**
299
+ * Wraps an inner payload in Tally's outer envelope. This is the one place
300
+ * both sublanguages meet — everything sublanguage-specific lives in the
301
+ * builders that call this, not in here.
302
+ *
303
+ * Import (write) requests use <IMPORTDATA> and carry the actual master/
304
+ * voucher XML inside <REQUESTDATA>. Export (read/collection) requests use
305
+ * <EXPORTDATA> and have no REQUESTDATA section at all — the field list comes
306
+ * from the report/collection definition Tally already knows about via
307
+ * REPORTNAME, not from anything we send. Passing bodyXml on an export
308
+ * request is a no-op by design, not an oversight.
309
+ */
310
+ declare function buildEnvelope(options: EnvelopeOptions, bodyXml?: string): string;
311
+
312
+ /**
313
+ * Tally master imports are wrapped in a TALLYMESSAGE envelope, with the
314
+ * object's NAME duplicated as both an XML attribute on the tag (how Tally
315
+ * identifies *which* object this is, for upsert-by-name semantics) and as a
316
+ * <NAME> child element (how Tally reads the field value). Forgetting either
317
+ * one is a common hand-rolled-XML bug this builder exists to make
318
+ * impossible.
319
+ */
320
+ declare function buildCreateLedgerXml(input: LedgerInput): string;
321
+ declare function buildCreateStockItemXml(input: StockItemInput): string;
322
+
323
+ /**
324
+ * The exhaustive switch: TypeScript will refuse to compile this file if a
325
+ * sixth voucher type is added to VoucherInput without a matching case here —
326
+ * that's the whole point of routing every variant through assertNever in
327
+ * the default branch instead of leaving it untyped.
328
+ */
329
+ declare function buildVoucherXml(input: VoucherInput): string;
330
+
331
+ /**
332
+ * Export requests don't carry a request body the way imports do — the field
333
+ * list comes from Tally's built-in report/collection names. We pin to
334
+ * Tally's native report names rather than hand-rolling TDL collection
335
+ * definitions, which keeps this builder simple at the cost of being unable
336
+ * to add custom fields. (A custom-TDL collection layer is a reasonable
337
+ * Phase 2 addition once the basic reads are solid.)
338
+ */
339
+ declare function buildGetCompaniesXml(): string;
340
+ declare function buildGetLedgersXml(company?: string): string;
341
+ declare function buildGetStockItemsXml(company?: string): string;
342
+ declare function buildGetOutstandingXml(company?: string): string;
343
+ declare function buildPingXml(): string;
344
+
345
+ /**
346
+ * Parses a response to an Import Data request (createLedger, createVoucher,
347
+ * etc). Two-pass by design: first parse the XML unconditionally, then
348
+ * inspect the parsed tree for error markers. We never string-match on raw
349
+ * XML for "LINEERROR" — that breaks the moment Tally changes whitespace or
350
+ * attribute order, which it does between versions.
351
+ */
352
+ declare function parseImportResponse(rawXml: string): Result<VoucherCreateResult, TallyError>;
353
+
354
+ declare function parseLedgerCollection(rawXml: string): Result<Ledger[], TallyError>;
355
+ declare function parseStockItemCollection(rawXml: string): Result<StockItem[], TallyError>;
356
+ declare function parseCompanyCollection(rawXml: string): Result<Company[], TallyError>;
357
+ declare function parseOutstandingCollection(rawXml: string): Result<OutstandingEntry[], TallyError>;
358
+
359
+ declare class Tally {
360
+ private readonly transport;
361
+ private readonly company?;
362
+ constructor(config: TallyConfig);
363
+ ping(): Promise<Result<true, TallyError>>;
364
+ getCompanies(): Promise<Result<Company[], TallyError>>;
365
+ getLedgers(): Promise<Result<Ledger[], TallyError>>;
366
+ /** Alias matching the original product sketch's naming. */
367
+ getCustomers(): Promise<Result<Ledger[], TallyError>>;
368
+ getStockItems(): Promise<Result<StockItem[], TallyError>>;
369
+ getOutstanding(): Promise<Result<OutstandingEntry[], TallyError>>;
370
+ createLedger(input: LedgerInput): Promise<Result<VoucherCreateResult, TallyError>>;
371
+ createStockItem(input: StockItemInput): Promise<Result<VoucherCreateResult, TallyError>>;
372
+ createVoucher(input: VoucherInput): Promise<Result<VoucherCreateResult, TallyError>>;
373
+ /**
374
+ * Convenience wrapper matching the original sketch's `createInvoice()`
375
+ * signature — expands into a full SalesVoucherInput (voucherType: "Sales")
376
+ * before going through the same validated path as createVoucher(). Kept
377
+ * separate from createVoucher() because "invoice" maps to a Sales voucher
378
+ * specifically, and spelling that out here means callers coming from
379
+ * other invoicing tools (Stripe, Zoho) don't need to know Tally's
380
+ * voucherType vocabulary at all.
381
+ */
382
+ createInvoice(input: {
383
+ customer: string;
384
+ date: Date;
385
+ items: SalesVoucherInput["items"];
386
+ salesLedger?: string;
387
+ taxes?: SalesVoucherInput["taxes"];
388
+ reference?: string;
389
+ narration?: string;
390
+ }): Promise<Result<VoucherCreateResult, TallyError>>;
391
+ /**
392
+ * Returns JSON-Schema-shaped tool definitions (derived from the same Zod
393
+ * schemas used for validation, so the agent-facing contract can never
394
+ * drift from what the SDK actually accepts) for OpenAI-style function
395
+ * calling, LangGraph, Mastra, or a hand-rolled MCP server. Each `handler`
396
+ * closes over `this`, so a caller can wire these straight into an agent
397
+ * framework's tool registry without writing adapter glue.
398
+ */
399
+ tools(): readonly [{
400
+ readonly name: "getCustomers";
401
+ readonly description: "List all Sundry Debtor ledgers (customers) in the active Tally company.";
402
+ readonly parameters: z.ZodObject<{}, z.core.$strip>;
403
+ readonly handler: () => Promise<Result<{
404
+ name: string;
405
+ guid: string;
406
+ group: string;
407
+ gstin?: string | undefined;
408
+ closingBalance?: number | undefined;
409
+ state?: string | undefined;
410
+ }[], TallyError>>;
411
+ }, {
412
+ readonly name: "getOutstanding";
413
+ readonly description: "Get outstanding (unpaid) receivable bills across all customers.";
414
+ readonly parameters: z.ZodObject<{}, z.core.$strip>;
415
+ readonly handler: () => Promise<Result<{
416
+ ledgerName: string;
417
+ voucherNumber: string;
418
+ voucherDate: Date;
419
+ pendingAmount: number;
420
+ dueDate?: Date | undefined;
421
+ overdueDays?: number | undefined;
422
+ }[], TallyError>>;
423
+ }, {
424
+ readonly name: "createInvoice";
425
+ readonly description: "Create a sales invoice for a customer with one or more line items.";
426
+ readonly parameters: z.ZodObject<{
427
+ customer: z.ZodString;
428
+ date: z.ZodCoercedDate<unknown>;
429
+ items: z.ZodArray<z.ZodObject<{
430
+ stockItem: z.ZodString;
431
+ quantity: z.ZodNumber;
432
+ rate: z.ZodNumber;
433
+ }, z.core.$strip>>;
434
+ }, z.core.$strip>;
435
+ readonly handler: (args: {
436
+ customer: string;
437
+ date: Date;
438
+ items: SalesVoucherInput["items"];
439
+ }) => Promise<Result<VoucherCreateResult, TallyError>>;
440
+ }, {
441
+ readonly name: "createLedger";
442
+ readonly description: "Create a new ledger account (e.g. a new customer or supplier) in Tally.";
443
+ readonly parameters: z.ZodObject<{
444
+ name: z.ZodString;
445
+ group: z.ZodString;
446
+ gstin: z.ZodOptional<z.ZodString>;
447
+ openingBalance: z.ZodOptional<z.ZodNumber>;
448
+ openingBalanceType: z.ZodOptional<z.ZodEnum<{
449
+ Debit: "Debit";
450
+ Credit: "Credit";
451
+ }>>;
452
+ address: z.ZodOptional<z.ZodArray<z.ZodString>>;
453
+ state: z.ZodOptional<z.ZodString>;
454
+ pincode: z.ZodOptional<z.ZodString>;
455
+ email: z.ZodOptional<z.ZodString>;
456
+ phone: z.ZodOptional<z.ZodString>;
457
+ }, z.core.$strip>;
458
+ readonly handler: (args: LedgerInput) => Promise<Result<VoucherCreateResult, TallyError>>;
459
+ }];
460
+ }
461
+
462
+ /**
463
+ * Tally's HTTP-XML server takes every request as a raw XML POST body to the
464
+ * root path — there's no REST routing, no headers carrying semantics, just
465
+ * "post some XML, get some XML back". That makes this transport layer
466
+ * unusually thin: its only real job is turning network-level failures
467
+ * (DNS, connection refused, timeout) into typed errors and retrying *only*
468
+ * those — never retrying a request that reached Tally and got a real
469
+ * response, because Tally-side rejections aren't transient.
470
+ */
471
+ declare class TallyTransport {
472
+ private readonly config;
473
+ private readonly retries;
474
+ constructor(config: TallyConfig);
475
+ send(requestXml: string): Promise<Result<string, TallyError>>;
476
+ }
477
+
478
+ export { type Company, CompanySchema, EMPTY_MARKER, type EnvelopeOptions, type EnvelopeRequestType, type JournalVoucherInput, JournalVoucherInputSchema, type Ledger, type LedgerInput, LedgerInputSchema, LedgerSchema, type LineItem, type OutstandingEntry, OutstandingEntrySchema, type PaymentVoucherInput, PaymentVoucherInputSchema, type PurchaseVoucherInput, PurchaseVoucherInputSchema, type ReceiptVoucherInput, ReceiptVoucherInputSchema, type Result, type SalesVoucherInput, SalesVoucherInputSchema, type StockItem, type StockItemInput, StockItemInputSchema, StockItemSchema, Tally, type TallyConfig, type TallyError, type TallyErrorCode, TallyTransport, type VoucherCreateResult, type VoucherInput, VoucherInputSchema, assertNever, buildCreateLedgerXml, buildCreateStockItemXml, buildEnvelope, buildGetCompaniesXml, buildGetLedgersXml, buildGetOutstandingXml, buildGetStockItemsXml, buildPingXml, buildVoucherXml, err, escapeXml, formatSignedAmount, formatTallyDate, ok, parseCompanyCollection, parseImportResponse, parseLedgerCollection, parseOutstandingCollection, parseStockItemCollection, tallyError, unwrap };