@tallyui/core 3.12.0 → 3.14.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/{chunk-UFWXJAMF.js → chunk-CSXNXRBA.js} +2 -0
- package/dist/{command-result-CrM7yjwk.d.ts → command-result-CoCa8PXJ.d.ts} +22 -5
- package/dist/index.d.ts +248 -6
- package/dist/index.js +76 -4
- package/dist/server/index.d.ts +8 -6
- package/dist/server/index.js +11 -3
- package/package.json +1 -1
- package/src/commands.ts +2 -0
- package/src/connectivity.ts +41 -0
- package/src/index.ts +11 -2
- package/src/server/batch.ts +1 -0
- package/src/server/index.ts +1 -1
- package/src/server/order-payload-shape.ts +5 -1
- package/src/server/register-outcome.ts +2 -0
- package/src/server/register-payload-shape.ts +4 -0
- package/src/server/rejection-codes.ts +1 -2
- package/src/server/versions.ts +4 -1
- package/src/types/cashier.ts +32 -0
- package/src/types/commands.ts +17 -4
- package/src/types/connector.ts +61 -4
- package/src/types/customers.ts +32 -3
- package/src/types/index.ts +1 -0
- package/src/types/payment-methods.ts +103 -0
- package/src/types/registers.ts +15 -0
|
@@ -3,6 +3,7 @@ var COMMANDS_PATH = "/tally/v1/commands";
|
|
|
3
3
|
var PROTOCOL_HEADER = "X-Tally-Protocol";
|
|
4
4
|
var PROTOCOL_VERSION = 1;
|
|
5
5
|
var MAX_COMMANDS_PER_BATCH = 50;
|
|
6
|
+
var ORDER_NOTE_MAX = 1e3;
|
|
6
7
|
function isCommandBatchResponse(value) {
|
|
7
8
|
return typeof value === "object" && value !== null && "results" in value && Array.isArray(value.results) && value.results.every(
|
|
8
9
|
(result) => typeof result === "object" && result !== null && "id" in result && typeof result.id === "string" && "status" in result && (result.status === "applied" || result.status === "duplicate" || result.status === "rejected")
|
|
@@ -179,6 +180,7 @@ export {
|
|
|
179
180
|
PROTOCOL_HEADER,
|
|
180
181
|
PROTOCOL_VERSION,
|
|
181
182
|
MAX_COMMANDS_PER_BATCH,
|
|
183
|
+
ORDER_NOTE_MAX,
|
|
182
184
|
isCommandBatchResponse,
|
|
183
185
|
CommandResultError,
|
|
184
186
|
parseCommandResult
|
|
@@ -6,8 +6,9 @@ interface CommandEnvelope<P = unknown> {
|
|
|
6
6
|
type: CommandType;
|
|
7
7
|
/** 3 when the order carries ADR-065's `display` and `taxByRate` (the store accepts 3), else 2 when discounted, else 1;
|
|
8
8
|
* 4 is 3 with every `discountMinor` tax-exclusive, built only when capped at 4 or more (#286).
|
|
9
|
-
* 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
10
|
-
|
|
9
|
+
* 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
10
|
+
* 7 is 6 plus the sale's `note` (ADR-083), sent only for an order that has one. */
|
|
11
|
+
version: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
11
12
|
payload: P;
|
|
12
13
|
createdAt: string;
|
|
13
14
|
deviceId: string;
|
|
@@ -83,10 +84,11 @@ interface OrderRefundOrderStateData {
|
|
|
83
84
|
interface OrderRefundNoOpenSessionData {
|
|
84
85
|
sessionId: string;
|
|
85
86
|
}
|
|
86
|
-
/** An order.create envelope: 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
87
|
+
/** An order.create envelope: 5 is 4 plus fees, shipping and custom lines (ADR-075), sent only for an order that has one.
|
|
88
|
+
* 7 is 6 plus the sale's note (ADR-083). */
|
|
87
89
|
type OrderCreateEnvelope = CommandEnvelope<OrderCreatePayload> & {
|
|
88
90
|
type: 'order.create';
|
|
89
|
-
version: 1 | 2 | 3 | 4 | 5 | 6;
|
|
91
|
+
version: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
90
92
|
};
|
|
91
93
|
/** Outcome of processing a command. */
|
|
92
94
|
type CommandStatus = 'applied' | 'duplicate' | 'rejected';
|
|
@@ -269,6 +271,16 @@ interface RegisterSessionSupersededData {
|
|
|
269
271
|
deviceName?: string;
|
|
270
272
|
newSessionId?: string;
|
|
271
273
|
}
|
|
274
|
+
/** error.data for register_approval_required (ADR-082 d6): variance is counted − tillExpected for each key of counted. */
|
|
275
|
+
interface RegisterApprovalRequiredData {
|
|
276
|
+
sessionId: string;
|
|
277
|
+
thresholdMinor: number;
|
|
278
|
+
variance: Record<string, number>;
|
|
279
|
+
}
|
|
280
|
+
/** error.data for register_approval_invalid (ADR-082 d6). */
|
|
281
|
+
interface RegisterApprovalInvalidData {
|
|
282
|
+
reason: 'unknown' | 'expired' | 'used' | 'session_mismatch' | 'variance_mismatch';
|
|
283
|
+
}
|
|
272
284
|
interface RegisterSessionTransitionPayload {
|
|
273
285
|
sessionId: string;
|
|
274
286
|
status: 'open' | 'counting' | 'closed';
|
|
@@ -303,6 +315,7 @@ interface RegisterClosureSubmitPayload {
|
|
|
303
315
|
closedAt: string;
|
|
304
316
|
closedBy?: string;
|
|
305
317
|
approvedBy?: string;
|
|
318
|
+
/** Register v3 only (ADR-082): the store's approval proof, opaque; never parsed, logged or stored in the Z. */ approval?: string;
|
|
306
319
|
tillExpected: Record<string, number>;
|
|
307
320
|
counted: Record<string, number>;
|
|
308
321
|
periodSalesTotalMinor: number;
|
|
@@ -484,6 +497,8 @@ interface OrderCreatePayload {
|
|
|
484
497
|
locationId?: string;
|
|
485
498
|
/** Version 3+: the register session the sale was taken for, stamped or late (ADR-032). A late sale names the session that refused its stamp; the server tells the two apart by the session's closure `orderIds`. Absent when the sale had no session. */
|
|
486
499
|
sessionId?: string;
|
|
500
|
+
/** Version 7 (ADR-083): the sale's note, 1 to ORDER_NOTE_MAX UTF-16 units; omitted when the sale has none. */
|
|
501
|
+
note?: string;
|
|
487
502
|
}
|
|
488
503
|
/** Batch of commands submitted to the server. */
|
|
489
504
|
interface CommandBatchRequest<E extends AnyCommandEnvelope = CommandEnvelope> {
|
|
@@ -508,6 +523,8 @@ declare const PROTOCOL_HEADER = "X-Tally-Protocol";
|
|
|
508
523
|
declare const PROTOCOL_VERSION = 1;
|
|
509
524
|
/** The ADR-038 batch limit; a server answers more with 413 and a BatchTooLargeBody. */
|
|
510
525
|
declare const MAX_COMMANDS_PER_BATCH = 50;
|
|
526
|
+
/** The longest order.create `note` (version 7, ADR-083), in UTF-16 code units. WCPOS v2's order note has no cap; this bounds the wire. */
|
|
527
|
+
declare const ORDER_NOTE_MAX = 1000;
|
|
511
528
|
/**
|
|
512
529
|
* True if `value` has the shape of a CommandBatchResponse: an object with a
|
|
513
530
|
* `results` array whose every entry has a string `id` and a `status` of
|
|
@@ -524,4 +541,4 @@ declare class CommandResultError extends Error {
|
|
|
524
541
|
* CommandResultError naming the first bad field. */
|
|
525
542
|
declare function parseCommandResult(value: unknown): CommandResult;
|
|
526
543
|
|
|
527
|
-
export { type AnyCommandEnvelope as A, type BatchTooLargeBody as B, type CommandWarning as C, type
|
|
544
|
+
export { type AnyCommandEnvelope as A, type BatchTooLargeBody as B, type CommandWarning as C, type OrderRefundRejectionCode as D, type OrderRefundResult as E, PROTOCOL_HEADER as F, PROTOCOL_VERSION as G, type RegisterApprovalRequiredData as H, type RegisterClosureSubmitPayload as I, type RegisterCommandEnvelope as J, type RegisterCommandResult as K, type RegisterCommandType as L, MAX_COMMANDS_PER_BATCH as M, type RegisterMovementRecordPayload as N, ORDER_NOTE_MAX as O, type PaymentMethodKind as P, type RegisterMovementVoidPayload as Q, type RegisterApprovalInvalidData as R, type RegisterSessionAlreadyOpenData as S, type RegisterSessionOpenPayload as T, type RegisterSessionSupersededData as U, type RegisterSessionTransitionPayload as V, isCommandBatchResponse as W, parseCommandResult as X, COMMANDS_PATH as a, type CommandBatchRequest as b, type CommandBatchResponse as c, type CommandEnvelope as d, type CommandError as e, type CommandResult as f, CommandResultError as g, type CommandServerRefs as h, type CommandStatus as i, type CommandType as j, type OrderCreateCoupon as k, type OrderCreateCouponInvalidData as l, type OrderCreateDisplay as m, type OrderCreateEnvelope as n, type OrderCreateLine as o, type OrderCreatePayload as p, type OrderCreatePayment as q, type OrderCreateTaxRate as r, type OrderCreateTotalMismatchData as s, type OrderRefundAmountMismatchData as t, type OrderRefundEnvelope as u, type OrderRefundLine as v, type OrderRefundNoOpenSessionData as w, type OrderRefundOrderStateData as x, type OrderRefundPayload as y, type OrderRefundQuantityExceedsData as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RxReplicationPullStreamItem, RxReplicationWriteToMasterRow, RxJsonSchema } from 'rxdb';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { P as PaymentMethodKind, C as CommandWarning } from './command-result-
|
|
4
|
-
export { A as AnyCommandEnvelope, B as BatchTooLargeBody, a as COMMANDS_PATH, b as CommandBatchRequest, c as CommandBatchResponse, d as CommandEnvelope, e as CommandError, f as CommandResult, g as CommandResultError, h as CommandServerRefs, i as CommandStatus, j as CommandType, M as MAX_COMMANDS_PER_BATCH, O as
|
|
3
|
+
import { P as PaymentMethodKind, C as CommandWarning } from './command-result-CoCa8PXJ.js';
|
|
4
|
+
export { A as AnyCommandEnvelope, B as BatchTooLargeBody, a as COMMANDS_PATH, b as CommandBatchRequest, c as CommandBatchResponse, d as CommandEnvelope, e as CommandError, f as CommandResult, g as CommandResultError, h as CommandServerRefs, i as CommandStatus, j as CommandType, M as MAX_COMMANDS_PER_BATCH, O as ORDER_NOTE_MAX, k as OrderCreateCoupon, l as OrderCreateCouponInvalidData, m as OrderCreateDisplay, n as OrderCreateEnvelope, o as OrderCreateLine, p as OrderCreatePayload, q as OrderCreatePayment, r as OrderCreateTaxRate, s as OrderCreateTotalMismatchData, t as OrderRefundAmountMismatchData, u as OrderRefundEnvelope, v as OrderRefundLine, w as OrderRefundNoOpenSessionData, x as OrderRefundOrderStateData, y as OrderRefundPayload, z as OrderRefundQuantityExceedsData, D as OrderRefundRejectionCode, E as OrderRefundResult, F as PROTOCOL_HEADER, G as PROTOCOL_VERSION, R as RegisterApprovalInvalidData, H as RegisterApprovalRequiredData, I as RegisterClosureSubmitPayload, J as RegisterCommandEnvelope, K as RegisterCommandResult, L as RegisterCommandType, N as RegisterMovementRecordPayload, Q as RegisterMovementVoidPayload, S as RegisterSessionAlreadyOpenData, T as RegisterSessionOpenPayload, U as RegisterSessionSupersededData, V as RegisterSessionTransitionPayload, W as isCommandBatchResponse, X as parseCommandResult } from './command-result-CoCa8PXJ.js';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
|
@@ -399,6 +399,30 @@ interface StoreSettingsChoice {
|
|
|
399
399
|
channel?: string;
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
+
/** A customer's postal address. Platform-neutral; every field optional. `country` is an ISO 3166-1 alpha-2 code. */
|
|
403
|
+
interface CustomerAddress {
|
|
404
|
+
firstName?: string;
|
|
405
|
+
lastName?: string;
|
|
406
|
+
company?: string;
|
|
407
|
+
address1?: string;
|
|
408
|
+
address2?: string;
|
|
409
|
+
city?: string;
|
|
410
|
+
state?: string;
|
|
411
|
+
postcode?: string;
|
|
412
|
+
country?: string;
|
|
413
|
+
phone?: string;
|
|
414
|
+
email?: string;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* A tax registration number (VAT, ABN, GST, EIN…). `type` is the connector's own id for the scheme; WCPOS v2's set is
|
|
418
|
+
* eu_vat, gb_vat, au_abn, br_cpf, br_cnpj, in_gst, it_cf, it_piva, es_nif, ar_cuit, sa_vat, ca_gst_hst, us_ein, other.
|
|
419
|
+
*/
|
|
420
|
+
interface CustomerTaxId {
|
|
421
|
+
type: string;
|
|
422
|
+
value: string;
|
|
423
|
+
country?: string;
|
|
424
|
+
label?: string;
|
|
425
|
+
}
|
|
402
426
|
/** A store customer, as the till shows and picks it (programme item 14). Platform-neutral. */
|
|
403
427
|
interface Customer {
|
|
404
428
|
/** The platform's id: order.create v3 sends it as `customer.customerId`. */
|
|
@@ -410,20 +434,35 @@ interface Customer {
|
|
|
410
434
|
email?: string;
|
|
411
435
|
phone?: string;
|
|
412
436
|
company?: string;
|
|
437
|
+
billing?: CustomerAddress;
|
|
438
|
+
shipping?: CustomerAddress;
|
|
439
|
+
taxIds?: CustomerTaxId[];
|
|
413
440
|
}
|
|
414
|
-
/** What the till collects to create a customer. v1 requires an email. */
|
|
441
|
+
/** What the till collects to create a customer. v1 requires an email; addresses and tax ids are optional. */
|
|
415
442
|
interface CustomerInput {
|
|
416
443
|
email: string;
|
|
417
444
|
firstName?: string;
|
|
418
445
|
lastName?: string;
|
|
419
446
|
phone?: string;
|
|
420
447
|
company?: string;
|
|
448
|
+
billing?: CustomerAddress;
|
|
449
|
+
shipping?: CustomerAddress;
|
|
450
|
+
taxIds?: CustomerTaxId[];
|
|
421
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* A change to an existing customer: any subset of {@link CustomerInput}. A field left out is unchanged; `billing`,
|
|
454
|
+
* `shipping` and `taxIds`, when given, replace the stored value whole (`taxIds: []` removes every tax id).
|
|
455
|
+
*/
|
|
456
|
+
type CustomerPatch = Partial<CustomerInput>;
|
|
422
457
|
declare const customerTraits: CustomerTraits<Customer>;
|
|
423
458
|
/** A customer call that failed for a reason other than credentials (credentials throw ConnectorUnauthorizedError). */
|
|
424
459
|
declare class CustomerServiceError extends Error {
|
|
425
460
|
readonly code: 'network' | 'server' | 'invalid';
|
|
426
|
-
|
|
461
|
+
/** The HTTP status the store answered with, when the connector has it; undefined for a network failure (no response). */
|
|
462
|
+
readonly status?: number;
|
|
463
|
+
constructor(code: 'network' | 'server' | 'invalid', message: string, options?: {
|
|
464
|
+
status?: number;
|
|
465
|
+
});
|
|
427
466
|
}
|
|
428
467
|
|
|
429
468
|
/** A line of an order the store holds (ADR-081). Money in integer minor units of the order's currency, as the store
|
|
@@ -524,6 +563,166 @@ interface StoreOrderPage {
|
|
|
524
563
|
hasMore: boolean;
|
|
525
564
|
}
|
|
526
565
|
|
|
566
|
+
/**
|
|
567
|
+
* A payment method the till can offer, backend-neutral (a port of WCPOS v2's Payments Contract
|
|
568
|
+
* v1 descriptor, `order-math/src/payments/types.ts`). A connector maps its own model into it:
|
|
569
|
+
* WooCommerce gateways, Medusa payment providers, Vendure payment methods. Amounts are integer
|
|
570
|
+
* minor units of the store currency. Open vocabularies keep values this build has never seen, so
|
|
571
|
+
* the till can show such a method disabled instead of dropping it.
|
|
572
|
+
*/
|
|
573
|
+
/** A known value, or any other string this build does not know yet. */
|
|
574
|
+
type OpenEnum<Known extends string> = Known | (string & {});
|
|
575
|
+
/** What kind of money the method takes. Not the order's wire method: that is `PaymentMethodKind`. */
|
|
576
|
+
type PaymentKind = 'cash' | 'card' | 'stored_value' | 'bank_transfer' | 'other';
|
|
577
|
+
/** How the payment is taken. `manual`: the cashier records it (cash, a standalone terminal). */
|
|
578
|
+
type CaptureMode = 'manual' | 'webview' | 'server' | 'device' | 'stored_value' | 'gateway';
|
|
579
|
+
/** The transport a payment terminal is reached over. */
|
|
580
|
+
type PaymentTransport = 'bluetooth' | 'usb' | 'network' | 'tap_to_pay';
|
|
581
|
+
/** Whether a leg can be taken while the till is offline: recorded, queued to settle later, or not at all. */
|
|
582
|
+
type PaymentOfflineMode = 'record' | 'queue' | 'none';
|
|
583
|
+
/** Where a tip is entered, if anywhere. */
|
|
584
|
+
type PaymentTipsMode = 'none' | 'on_reader' | 'at_till';
|
|
585
|
+
/** The terminal hardware behind a method: readers the server lists, or transports an SDK discovers. */
|
|
586
|
+
type PaymentHardware = {
|
|
587
|
+
discovery: OpenEnum<'server'>;
|
|
588
|
+
readers: {
|
|
589
|
+
id: string;
|
|
590
|
+
label: string;
|
|
591
|
+
status: OpenEnum<'online' | 'offline'>;
|
|
592
|
+
default: boolean;
|
|
593
|
+
}[];
|
|
594
|
+
defaultReader: string | null;
|
|
595
|
+
lockToDefault: boolean;
|
|
596
|
+
} | {
|
|
597
|
+
discovery: OpenEnum<'sdk' | 'manual'>;
|
|
598
|
+
transports: {
|
|
599
|
+
transport: OpenEnum<PaymentTransport>;
|
|
600
|
+
offline: OpenEnum<PaymentOfflineMode>;
|
|
601
|
+
tips: OpenEnum<PaymentTipsMode>;
|
|
602
|
+
}[];
|
|
603
|
+
};
|
|
604
|
+
/** One way to capture a method's payments. */
|
|
605
|
+
interface CaptureModeEntry {
|
|
606
|
+
mode: OpenEnum<CaptureMode>;
|
|
607
|
+
/** The payment provider's own name, e.g. a terminal vendor; `null` for none. */
|
|
608
|
+
provider: string | null;
|
|
609
|
+
hardware: PaymentHardware | null;
|
|
610
|
+
}
|
|
611
|
+
/** Cash rounding for the method: the due amount rounds to a multiple of `incrementMinor`; `nearest` rounds half up. */
|
|
612
|
+
type PaymentRounding = {
|
|
613
|
+
incrementMinor: number;
|
|
614
|
+
mode: 'nearest' | 'up' | 'down';
|
|
615
|
+
} | null;
|
|
616
|
+
interface PaymentMethodDescriptor {
|
|
617
|
+
/** The connector's own id for the method, stable across reads. */
|
|
618
|
+
id: string;
|
|
619
|
+
/** The name the till shows. */
|
|
620
|
+
title: string;
|
|
621
|
+
kind: OpenEnum<PaymentKind>;
|
|
622
|
+
capture: CaptureModeEntry & {
|
|
623
|
+
/** Every way the method can be captured, the primary first; absent when `mode` is the only one. */
|
|
624
|
+
modes?: CaptureModeEntry[];
|
|
625
|
+
};
|
|
626
|
+
capabilities: {
|
|
627
|
+
/** `partial`: the method may take less than the balance (a split leg). */
|
|
628
|
+
amount: {
|
|
629
|
+
partial: boolean;
|
|
630
|
+
minMinor?: number;
|
|
631
|
+
maxMinor?: number;
|
|
632
|
+
};
|
|
633
|
+
/** Whether tendering more than is due gives change. */
|
|
634
|
+
change: boolean;
|
|
635
|
+
refunds: {
|
|
636
|
+
via: OpenEnum<'provider' | 'manual' | 'device' | 'none'>;
|
|
637
|
+
partial: boolean;
|
|
638
|
+
};
|
|
639
|
+
tips: OpenEnum<PaymentTipsMode>;
|
|
640
|
+
offline: OpenEnum<PaymentOfflineMode>;
|
|
641
|
+
/** Whether a taken leg can be voided. */
|
|
642
|
+
void: boolean;
|
|
643
|
+
};
|
|
644
|
+
defaults: {
|
|
645
|
+
rounding: PaymentRounding;
|
|
646
|
+
/** Whether taking the payment opens the cash drawer. */
|
|
647
|
+
openDrawer: boolean;
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
/** The descriptor of one of today's two wire methods: its `id` is the `PaymentMethodKind`. */
|
|
651
|
+
declare function paymentMethodOf(kind: PaymentMethodKind): PaymentMethodDescriptor;
|
|
652
|
+
/** Today's two methods, cash then the card terminal: what the till offers when the connector has no `paymentMethods`. */
|
|
653
|
+
declare function defaultPaymentMethods(): PaymentMethodDescriptor[];
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* A register (till) in the store's register directory (v2 parity A4). Platform-neutral: each connector maps its own
|
|
657
|
+
* register model onto it. Money is integer minor units of the store's currency.
|
|
658
|
+
* The cash variance threshold is not here: it is the store's (ADR-082, `capabilities.registerApproval`).
|
|
659
|
+
*/
|
|
660
|
+
interface RegisterInfo {
|
|
661
|
+
/** The platform's register id. */
|
|
662
|
+
id: string;
|
|
663
|
+
/** The register's display name, as the cashier picks it. */
|
|
664
|
+
name: string;
|
|
665
|
+
/** The cash the drawer should open with; absent when the store sets none. */
|
|
666
|
+
defaultFloatMinor?: number;
|
|
667
|
+
/** When the register is due to close: a local store time, `HH:MM` on a 24-hour clock; absent when the store sets none. */
|
|
668
|
+
expectedCloseTime?: string;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* The neutral POS permissions a connector resolves from its own model (v2 parity A12):
|
|
673
|
+
* - `viewReports`: Reports, and a count that shows the expected figures (not blind);
|
|
674
|
+
* - `manageClosures`: recount and close without an approver;
|
|
675
|
+
* - `approveVariance`: approve another cashier's over-threshold count;
|
|
676
|
+
* - `refund`: take refunds;
|
|
677
|
+
* - `discount`: give discounts.
|
|
678
|
+
*/
|
|
679
|
+
declare const CASHIER_PERMISSIONS: readonly ["viewReports", "manageClosures", "approveVariance", "refund", "discount"];
|
|
680
|
+
/** One of `CASHIER_PERMISSIONS`. */
|
|
681
|
+
type CashierPermission = (typeof CASHIER_PERMISSIONS)[number];
|
|
682
|
+
/** The signed-in cashier, as the connector maps the platform's user (v2 parity A12). */
|
|
683
|
+
interface Cashier {
|
|
684
|
+
/** The platform's id for the signed-in user. */
|
|
685
|
+
id: string;
|
|
686
|
+
/** The display name, as receipts and the handover show it. */
|
|
687
|
+
name: string;
|
|
688
|
+
/** What this cashier may do; a permission left out is denied. */
|
|
689
|
+
permissions: readonly CashierPermission[];
|
|
690
|
+
}
|
|
691
|
+
/** Whether `value` is one of the five permission names. */
|
|
692
|
+
declare function isCashierPermission(value: unknown): value is CashierPermission;
|
|
693
|
+
/** The known permission names in `values`, first occurrence order, without duplicates; anything else is dropped. */
|
|
694
|
+
declare function cashierPermissions(values: readonly unknown[]): CashierPermission[];
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* How well a connector's store answers (v2 parity A6, unit 34). The same three states as WCPOS v2's
|
|
698
|
+
* `EngineConnectivity`: `degraded` means the device is online but the store keeps failing.
|
|
699
|
+
*/
|
|
700
|
+
type ConnectivityState = 'online' | 'offline' | 'degraded';
|
|
701
|
+
/**
|
|
702
|
+
* A store's deliberate refusal to sync until someone updates software. `fixedBy` as in `SyncNotice`: `'till'` when
|
|
703
|
+
* this app is older than the store accepts, `'store'` when the store's software is older than the app needs.
|
|
704
|
+
* `reason` is the connector's code for it; `software`, `minVersion` and `status` only when the refusal names them.
|
|
705
|
+
*/
|
|
706
|
+
type UpdateRequired = {
|
|
707
|
+
reason: string;
|
|
708
|
+
fixedBy: 'till' | 'store';
|
|
709
|
+
software?: string;
|
|
710
|
+
minVersion?: string;
|
|
711
|
+
status?: number;
|
|
712
|
+
};
|
|
713
|
+
/** What one failed request says: about connectivity, an update-required refusal, or nothing (`null`). */
|
|
714
|
+
type FailureClass = 'offline' | 'degraded' | {
|
|
715
|
+
updateRequired: UpdateRequired;
|
|
716
|
+
} | null;
|
|
717
|
+
/**
|
|
718
|
+
* The rule for a connector without `classifyFailure`: a timeout or a 5xx is `degraded`, a request that got no
|
|
719
|
+
* response (a fetch's `TypeError`, or a `network` code as `CustomerServiceError` has) is `offline`, anything else is
|
|
720
|
+
* `null`. It never answers update-required: only a connector knows its own refusal.
|
|
721
|
+
*/
|
|
722
|
+
declare function neutralFailureClass(error: unknown): FailureClass;
|
|
723
|
+
/** The connector's own `classifyFailure` when it has one (its answer is final), else `neutralFailureClass`. A method that throws gives `null`. */
|
|
724
|
+
declare function classifyFailure(connector: Pick<TallyConnector, 'classifyFailure'> | undefined, error: unknown): FailureClass;
|
|
725
|
+
|
|
527
726
|
/**
|
|
528
727
|
* Authentication configuration for a connector.
|
|
529
728
|
* Each API has wildly different auth — JWT, API keys, OAuth, etc.
|
|
@@ -583,6 +782,14 @@ interface ServerCapabilities {
|
|
|
583
782
|
* coupon. WooCommerce: true only when the woocommerce-pos plugin reports 1.9.0 or later.
|
|
584
783
|
*/
|
|
585
784
|
coupons?: boolean;
|
|
785
|
+
/**
|
|
786
|
+
* The store's register approval threshold (ADR-082 d3), from the top level of `/tally/v1/info`. With
|
|
787
|
+
* `register >= 3`, a close whose absolute cash variance is over `thresholdMinor` needs the store's approval.
|
|
788
|
+
* Absent means the store sets none, and the app's own threshold applies.
|
|
789
|
+
*/
|
|
790
|
+
registerApproval?: {
|
|
791
|
+
thresholdMinor: number;
|
|
792
|
+
};
|
|
586
793
|
}
|
|
587
794
|
/** #287, ADR-071. `custom`: the till computes as when absent; that server never emits `figures_mismatch` for subtotal or tax. */
|
|
588
795
|
type TaxRounding = {
|
|
@@ -617,6 +824,7 @@ declare function parseLineTax(value: unknown, warn?: (reason: string) => void):
|
|
|
617
824
|
* Reads a 2xx body of `GET /tally/v1/info` (ADR-062): `orderCreate` is the max of
|
|
618
825
|
* `contracts["order.create"]`, or 1 when it's missing or malformed; `register` is the max of
|
|
619
826
|
* `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287); malformed `lineTax` is ignored.
|
|
827
|
+
* malformed `registerApproval` is ignored (ADR-082).
|
|
620
828
|
* `orderRefund` is the max of `contracts["order.refund"]` when valid, otherwise absent (ADR-080).
|
|
621
829
|
* Absent `taxRounding` uses the default; a present malformed value is unknown, so settings wait.
|
|
622
830
|
* A non-object body is also unknown, not a statement of the store's defaults.
|
|
@@ -757,12 +965,27 @@ interface TallyConnector {
|
|
|
757
965
|
* `unauthorized` or `invalid_credentials` means sign in again), never on its class.
|
|
758
966
|
*/
|
|
759
967
|
capabilities?: (context: SyncContext) => Promise<ServerCapabilities | undefined>;
|
|
760
|
-
/**
|
|
968
|
+
/**
|
|
969
|
+
* The payment methods the till may offer, in the order it shows them (v2 parity A2). Read-only, never writes to
|
|
970
|
+
* the store. `undefined` when the connector has none of its own: the till offers `defaultPaymentMethods()`.
|
|
971
|
+
*/
|
|
972
|
+
paymentMethods?: (context: SyncContext) => Promise<PaymentMethodDescriptor[]>;
|
|
973
|
+
/**
|
|
974
|
+
* Customer search: online only. An empty or whitespace query may list a first page of the store's customers
|
|
975
|
+
* (recent ones, or in the store's own picker order); a connector that cannot list them returns `[]`.
|
|
976
|
+
* `undefined` when the connector has no customer support.
|
|
977
|
+
*/
|
|
761
978
|
searchCustomers?: (context: SyncContext, query: string, options?: {
|
|
762
979
|
limit?: number;
|
|
763
980
|
}) => Promise<Customer[]>;
|
|
764
981
|
/** Customer creation: online only; `undefined` when the connector has no customer support. */
|
|
765
982
|
createCustomer?: (context: SyncContext, input: CustomerInput) => Promise<Customer>;
|
|
983
|
+
/**
|
|
984
|
+
* Customer edit: online only; resolves the customer as the store now has it. Rejects with
|
|
985
|
+
* `ConnectorUnauthorizedError` for credentials and `CustomerServiceError` (`invalid` for a refused patch or an id
|
|
986
|
+
* the store does not have, `server` or `network` otherwise). `undefined` when the connector can't edit customers.
|
|
987
|
+
*/
|
|
988
|
+
updateCustomer?: (context: SyncContext, id: string, patch: CustomerPatch) => Promise<Customer>;
|
|
766
989
|
/** Customer lookup: online only; `undefined` when the connector has no customer support. */
|
|
767
990
|
getCustomer?: (context: SyncContext, id: string) => Promise<Customer | null>;
|
|
768
991
|
/**
|
|
@@ -787,6 +1010,25 @@ interface TallyConnector {
|
|
|
787
1010
|
* read-only; rejects as `listOrders`. `undefined` when the connector has no order history.
|
|
788
1011
|
*/
|
|
789
1012
|
getOrders?: (context: SyncContext, ids: readonly string[]) => Promise<StoreOrder[]>;
|
|
1013
|
+
/**
|
|
1014
|
+
* The store's register directory (v2 parity A4): online only, read-only. Rejects with `ConnectorUnauthorizedError`
|
|
1015
|
+
* for credentials; a connector's own errors otherwise. `undefined` when the connector has no register directory.
|
|
1016
|
+
*/
|
|
1017
|
+
listRegisters?: (context: SyncContext) => Promise<RegisterInfo[]>;
|
|
1018
|
+
/**
|
|
1019
|
+
* The signed-in cashier and their neutral POS permissions (v2 parity A12), mapped from the platform's own roles or
|
|
1020
|
+
* capabilities. Read-only. `null` when the connector has no cashier to describe; `undefined` (no method) when the
|
|
1021
|
+
* connector has no permission model: the till then allows everything, as before (`can` in `@tallyui/pos`).
|
|
1022
|
+
* Permission names outside `CashierPermission` are dropped by `useCashier` (`cashierPermissions`).
|
|
1023
|
+
*/
|
|
1024
|
+
cashier?: (context: SyncContext) => Promise<Cashier | null>;
|
|
1025
|
+
/**
|
|
1026
|
+
* Maps one of this connector's request failures (pull, push, reconcile, online calls) to a connectivity verdict or
|
|
1027
|
+
* its own update-required refusal (v2 parity A6). Synchronous and pure. `null` when the failure says nothing about
|
|
1028
|
+
* connectivity (a validation refusal). `undefined` (no method) uses `neutralFailureClass`, which a connector's own
|
|
1029
|
+
* method may also call for the failures it does not map.
|
|
1030
|
+
*/
|
|
1031
|
+
classifyFailure?: (error: unknown) => FailureClass;
|
|
790
1032
|
}
|
|
791
1033
|
|
|
792
1034
|
/**
|
|
@@ -1653,4 +1895,4 @@ declare namespace index {
|
|
|
1653
1895
|
export { type index_CouponContext as CouponContext, type index_CouponDiscountConfig as CouponDiscountConfig, type index_CouponInput as CouponInput, type index_CouponLineInput as CouponLineInput, type index_CouponRejection as CouponRejection, type index_CouponRejectionCode as CouponRejectionCode, type index_CouponValidationContext as CouponValidationContext, type index_EngineWarning as EngineWarning, type index_LineItemInput as LineItemInput, type index_OrderTotals as OrderTotals, type index_RecalculateInput as RecalculateInput, type index_RecalculateResult as RecalculateResult, type index_TaxRateInput as TaxRateInput, type index_ValidationResult as ValidationResult, index_calculateOrderTotals as calculateOrderTotals, index_enrichCategoriesWithAncestors as enrichCategoriesWithAncestors, index_recalculateCoupons as recalculateCoupons, index_toCouponConfigs as toCouponConfigs, index_validateCoupon as validateCoupon };
|
|
1654
1896
|
}
|
|
1655
1897
|
|
|
1656
|
-
export { type AuthField, type CatalogueReconcileAdapter, type CatalogueReconcileEntry, type CollectionSync, CommandWarning, type ConnectorAuth, ConnectorProvider, type ConnectorProviderProps, type ConnectorSchemas, type ConnectorTraits, ConnectorUnauthorizedError, type Customer, type CustomerInput, CustomerServiceError, type CustomerTraits, type ErrorKind, type FingerprintReconcileAdapter, type IdReconcileAdapter, type KeyedReconcileFeedOptions, type ListOrdersQuery, type Money, PaymentMethodKind, type ProductCategory, type ProductPrice, type ProductTraits, type ReconcileFeed, type ReconcileFeedEntry, type ReconcileFetchEntry, type RemoteIdEntry, type ReplicationAdapter, type ResolvedPrice, STOCK_LEVELS_LAST_PASS, type ServerCapabilities, SignInError, type SignInErrorCode, type SignInResult, type StockLevel, type StockReconcileAdapter, type StockStatus, type StoreOrder, type StoreOrderCharge, type StoreOrderLine, type StoreOrderPage, type StoreOrderPayment, type StoreOrderRefund, type StoreSettings, type StoreSettingsChoice, type StoreSettingsChoices, StoreSettingsError, type StoreSettingsErrorCode, type SyncContext, type SyncNotice, type TallyConnector, type TaxRounding, type TraitContext, type VariantOptionGroup, type VariantSummary, combinePullAdapters, compareIds, createReconcileFeed, currencySymbol, customerTraits, errorKind, findVariantByCode, formatMoney, getProductStock, isRxdbRemoteVersionMismatch, knownWarnings, minorUnitDigits, moneyFromDecimalString, moneyFromMajor, moneyToMajor, parseInfoCapabilities, parseLineTax, parseTaxRounding, resolveCapabilities, resolvePrice, resolvePriceRange, useConnector, useCustomerTraits, useProductStock, useProductTraits, useStockOverlaid, useStockOverlayAsOf, useTraitContext, withStockOverlay, index as woocommerceCoupons, index$1 as woocommerceTax };
|
|
1898
|
+
export { type AuthField, CASHIER_PERMISSIONS, type CaptureMode, type CaptureModeEntry, type Cashier, type CashierPermission, type CatalogueReconcileAdapter, type CatalogueReconcileEntry, type CollectionSync, CommandWarning, type ConnectivityState, type ConnectorAuth, ConnectorProvider, type ConnectorProviderProps, type ConnectorSchemas, type ConnectorTraits, ConnectorUnauthorizedError, type Customer, type CustomerAddress, type CustomerInput, type CustomerPatch, CustomerServiceError, type CustomerTaxId, type CustomerTraits, type ErrorKind, type FailureClass, type FingerprintReconcileAdapter, type IdReconcileAdapter, type KeyedReconcileFeedOptions, type ListOrdersQuery, type Money, type PaymentHardware, type PaymentKind, type PaymentMethodDescriptor, PaymentMethodKind, type PaymentOfflineMode, type PaymentRounding, type PaymentTipsMode, type PaymentTransport, type ProductCategory, type ProductPrice, type ProductTraits, type ReconcileFeed, type ReconcileFeedEntry, type ReconcileFetchEntry, type RegisterInfo, type RemoteIdEntry, type ReplicationAdapter, type ResolvedPrice, STOCK_LEVELS_LAST_PASS, type ServerCapabilities, SignInError, type SignInErrorCode, type SignInResult, type StockLevel, type StockReconcileAdapter, type StockStatus, type StoreOrder, type StoreOrderCharge, type StoreOrderLine, type StoreOrderPage, type StoreOrderPayment, type StoreOrderRefund, type StoreSettings, type StoreSettingsChoice, type StoreSettingsChoices, StoreSettingsError, type StoreSettingsErrorCode, type SyncContext, type SyncNotice, type TallyConnector, type TaxRounding, type TraitContext, type UpdateRequired, type VariantOptionGroup, type VariantSummary, cashierPermissions, classifyFailure, combinePullAdapters, compareIds, createReconcileFeed, currencySymbol, customerTraits, defaultPaymentMethods, errorKind, findVariantByCode, formatMoney, getProductStock, isCashierPermission, isRxdbRemoteVersionMismatch, knownWarnings, minorUnitDigits, moneyFromDecimalString, moneyFromMajor, moneyToMajor, neutralFailureClass, parseInfoCapabilities, parseLineTax, parseTaxRounding, paymentMethodOf, resolveCapabilities, resolvePrice, resolvePriceRange, useConnector, useCustomerTraits, useProductStock, useProductTraits, useStockOverlaid, useStockOverlayAsOf, useTraitContext, withStockOverlay, index as woocommerceCoupons, index$1 as woocommerceTax };
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
COMMANDS_PATH,
|
|
3
3
|
CommandResultError,
|
|
4
4
|
MAX_COMMANDS_PER_BATCH,
|
|
5
|
+
ORDER_NOTE_MAX,
|
|
5
6
|
PROTOCOL_HEADER,
|
|
6
7
|
PROTOCOL_VERSION,
|
|
7
8
|
isCommandBatchResponse,
|
|
8
9
|
parseCommandResult
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CSXNXRBA.js";
|
|
10
11
|
import {
|
|
11
12
|
__export
|
|
12
13
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -39,6 +40,15 @@ function parseLineTax(value, warn) {
|
|
|
39
40
|
warn?.("ignoring a malformed lineTax");
|
|
40
41
|
return void 0;
|
|
41
42
|
}
|
|
43
|
+
function parseRegisterApproval(value, warn) {
|
|
44
|
+
if (value === void 0) return void 0;
|
|
45
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
46
|
+
const { thresholdMinor } = value;
|
|
47
|
+
if (typeof thresholdMinor === "number" && Number.isSafeInteger(thresholdMinor) && thresholdMinor >= 0) return { thresholdMinor };
|
|
48
|
+
}
|
|
49
|
+
warn?.("ignoring a malformed registerApproval");
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
42
52
|
var maxVersion = (list) => {
|
|
43
53
|
const valid = Array.isArray(list) ? list.filter((v) => typeof v === "number" && Number.isSafeInteger(v) && v > 0) : [];
|
|
44
54
|
return valid.length > 0 ? Math.max(...valid) : void 0;
|
|
@@ -48,7 +58,7 @@ function parseInfoCapabilities(body, warn) {
|
|
|
48
58
|
warn?.("non-object info body: capabilities unknown");
|
|
49
59
|
return void 0;
|
|
50
60
|
}
|
|
51
|
-
const { contracts, taxRounding, lineTax } = body;
|
|
61
|
+
const { contracts, taxRounding, lineTax, registerApproval } = body;
|
|
52
62
|
const register = maxVersion(contracts?.register);
|
|
53
63
|
const orderRefund = maxVersion(contracts?.["order.refund"]);
|
|
54
64
|
const rounding = parseTaxRounding(taxRounding);
|
|
@@ -57,12 +67,14 @@ function parseInfoCapabilities(body, warn) {
|
|
|
57
67
|
return void 0;
|
|
58
68
|
}
|
|
59
69
|
const parsedLineTax = parseLineTax(lineTax, warn);
|
|
70
|
+
const parsed = parseRegisterApproval(registerApproval, warn);
|
|
60
71
|
return {
|
|
61
72
|
orderCreate: maxVersion(contracts?.["order.create"]) ?? 1,
|
|
62
73
|
...orderRefund !== void 0 ? { orderRefund } : {},
|
|
63
74
|
...register !== void 0 ? { register } : {},
|
|
64
75
|
...rounding ? { taxRounding: rounding } : {},
|
|
65
|
-
...parsedLineTax ? { lineTax: parsedLineTax } : {}
|
|
76
|
+
...parsedLineTax ? { lineTax: parsedLineTax } : {},
|
|
77
|
+
...parsed ? { registerApproval: parsed } : {}
|
|
66
78
|
};
|
|
67
79
|
}
|
|
68
80
|
|
|
@@ -115,6 +127,24 @@ function errorKind(error) {
|
|
|
115
127
|
return (fixedBy === "till" || fixedBy === "store") && typeof code === "string" ? fixedBy : "transient";
|
|
116
128
|
}
|
|
117
129
|
|
|
130
|
+
// src/connectivity.ts
|
|
131
|
+
function neutralFailureClass(error) {
|
|
132
|
+
if (typeof error !== "object" || error === null) return null;
|
|
133
|
+
const { name, code, status } = error;
|
|
134
|
+
if (name === "AbortError" || name === "TimeoutError" || code === "timeout") return "degraded";
|
|
135
|
+
if (typeof status === "number" && status >= 500) return "degraded";
|
|
136
|
+
if (name === "TypeError" || code === "network") return "offline";
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
function classifyFailure(connector, error) {
|
|
140
|
+
if (!connector?.classifyFailure) return neutralFailureClass(error);
|
|
141
|
+
try {
|
|
142
|
+
return connector.classifyFailure(error);
|
|
143
|
+
} catch {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
118
148
|
// src/store-settings.ts
|
|
119
149
|
var StoreSettingsError = class extends Error {
|
|
120
150
|
code;
|
|
@@ -136,13 +166,47 @@ var customerTraits = {
|
|
|
136
166
|
getAddressSummary: () => void 0
|
|
137
167
|
};
|
|
138
168
|
var CustomerServiceError = class extends Error {
|
|
139
|
-
constructor(code, message) {
|
|
169
|
+
constructor(code, message, options) {
|
|
140
170
|
super(message);
|
|
141
171
|
this.code = code;
|
|
142
172
|
this.name = "CustomerServiceError";
|
|
173
|
+
this.status = options?.status;
|
|
143
174
|
}
|
|
175
|
+
/** The HTTP status the store answered with, when the connector has it; undefined for a network failure (no response). */
|
|
176
|
+
status;
|
|
144
177
|
};
|
|
145
178
|
|
|
179
|
+
// src/types/payment-methods.ts
|
|
180
|
+
function paymentMethodOf(kind) {
|
|
181
|
+
return {
|
|
182
|
+
id: kind,
|
|
183
|
+
title: kind === "cash" ? "Cash" : "Card terminal",
|
|
184
|
+
kind: kind === "cash" ? "cash" : "card",
|
|
185
|
+
capture: { mode: "manual", provider: null, hardware: null },
|
|
186
|
+
capabilities: {
|
|
187
|
+
amount: { partial: true },
|
|
188
|
+
change: kind === "cash",
|
|
189
|
+
refunds: { via: "manual", partial: true },
|
|
190
|
+
tips: "none",
|
|
191
|
+
offline: "record",
|
|
192
|
+
void: true
|
|
193
|
+
},
|
|
194
|
+
defaults: { rounding: null, openDrawer: kind === "cash" }
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function defaultPaymentMethods() {
|
|
198
|
+
return [paymentMethodOf("cash"), paymentMethodOf("external")];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/types/cashier.ts
|
|
202
|
+
var CASHIER_PERMISSIONS = ["viewReports", "manageClosures", "approveVariance", "refund", "discount"];
|
|
203
|
+
function isCashierPermission(value) {
|
|
204
|
+
return CASHIER_PERMISSIONS.includes(value);
|
|
205
|
+
}
|
|
206
|
+
function cashierPermissions(values) {
|
|
207
|
+
return [...new Set(values.filter(isCashierPermission))];
|
|
208
|
+
}
|
|
209
|
+
|
|
146
210
|
// src/money.ts
|
|
147
211
|
var digitsCache = /* @__PURE__ */ new Map();
|
|
148
212
|
function minorUnitDigits(currency) {
|
|
@@ -1751,26 +1815,32 @@ function toCouponConfigs(codes, coupons) {
|
|
|
1751
1815
|
return couponConfigs;
|
|
1752
1816
|
}
|
|
1753
1817
|
export {
|
|
1818
|
+
CASHIER_PERMISSIONS,
|
|
1754
1819
|
COMMANDS_PATH,
|
|
1755
1820
|
CommandResultError,
|
|
1756
1821
|
ConnectorProvider,
|
|
1757
1822
|
ConnectorUnauthorizedError,
|
|
1758
1823
|
CustomerServiceError,
|
|
1759
1824
|
MAX_COMMANDS_PER_BATCH,
|
|
1825
|
+
ORDER_NOTE_MAX,
|
|
1760
1826
|
PROTOCOL_HEADER,
|
|
1761
1827
|
PROTOCOL_VERSION,
|
|
1762
1828
|
STOCK_LEVELS_LAST_PASS,
|
|
1763
1829
|
SignInError,
|
|
1764
1830
|
StoreSettingsError,
|
|
1831
|
+
cashierPermissions,
|
|
1832
|
+
classifyFailure,
|
|
1765
1833
|
combinePullAdapters,
|
|
1766
1834
|
compareIds,
|
|
1767
1835
|
createReconcileFeed,
|
|
1768
1836
|
currencySymbol,
|
|
1769
1837
|
customerTraits,
|
|
1838
|
+
defaultPaymentMethods,
|
|
1770
1839
|
errorKind,
|
|
1771
1840
|
findVariantByCode,
|
|
1772
1841
|
formatMoney,
|
|
1773
1842
|
getProductStock,
|
|
1843
|
+
isCashierPermission,
|
|
1774
1844
|
isCommandBatchResponse,
|
|
1775
1845
|
isRxdbRemoteVersionMismatch,
|
|
1776
1846
|
knownWarnings,
|
|
@@ -1778,10 +1848,12 @@ export {
|
|
|
1778
1848
|
moneyFromDecimalString,
|
|
1779
1849
|
moneyFromMajor,
|
|
1780
1850
|
moneyToMajor,
|
|
1851
|
+
neutralFailureClass,
|
|
1781
1852
|
parseCommandResult,
|
|
1782
1853
|
parseInfoCapabilities,
|
|
1783
1854
|
parseLineTax,
|
|
1784
1855
|
parseTaxRounding,
|
|
1856
|
+
paymentMethodOf,
|
|
1785
1857
|
resolveCapabilities,
|
|
1786
1858
|
resolvePrice,
|
|
1787
1859
|
resolvePriceRange,
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as CommandError,
|
|
2
|
-
export { g as CommandResultError, M as MAX_COMMANDS_PER_BATCH,
|
|
1
|
+
import { e as CommandError, p as OrderCreatePayload, d as CommandEnvelope, J as RegisterCommandEnvelope, A as AnyCommandEnvelope, f as CommandResult, B as BatchTooLargeBody, c as CommandBatchResponse, C as CommandWarning, K as RegisterCommandResult, D as OrderRefundRejectionCode } from '../command-result-CoCa8PXJ.js';
|
|
2
|
+
export { g as CommandResultError, M as MAX_COMMANDS_PER_BATCH, O as ORDER_NOTE_MAX, m as OrderCreateDisplay, r as OrderCreateTaxRate, X as parseCommandResult } from '../command-result-CoCa8PXJ.js';
|
|
3
3
|
|
|
4
4
|
/** ISO 4217 minor-unit exponent as resolved by Intl (which rejects malformed codes); depends on the runtime's ICU data. */
|
|
5
5
|
declare function currencyDecimals(currency: string): number;
|
|
@@ -26,7 +26,7 @@ declare function commandFingerprint(envelope: {
|
|
|
26
26
|
declare function payloadShapeErrors(payload: unknown): string[];
|
|
27
27
|
/** Length-bound errors of an order.create payload, e.g. ['lines[0].title: expected at most 255
|
|
28
28
|
* characters']; [] when every string is within its bound, at most ten. Bounds in UTF-16 code units:
|
|
29
|
-
* `customer.email` 254, v5 ids 36 and class/sku/method 64, other strings 255 (`customerId` and `sessionId` keep theirs in
|
|
29
|
+
* `note` ORDER_NOTE_MAX (1000), `customer.email` 254, v5 ids 36 and class/sku/method 64, other strings 255 (`customerId` and `sessionId` keep theirs in
|
|
30
30
|
* payloadShapeErrors); only strings are checked. A plugin calls it through precheckCommand, after
|
|
31
31
|
* its replay lookup, so a bound tightened later never turns an applied command's resend into
|
|
32
32
|
* `invalid_payload`. */
|
|
@@ -43,6 +43,9 @@ declare function fiscalFiguresErrors(payload: OrderCreatePayloadV3): string[];
|
|
|
43
43
|
* supports (#297). A server passes its own lists to `precheckCommand`, and its /info advertises them, gated by its
|
|
44
44
|
* own check (Front desk, 2026-09-30): 4 (#286) is 3 with every discountMinor tax-exclusive, and a plugin
|
|
45
45
|
* advertises it only once it handles it.
|
|
46
|
+
* 5 (ADR-075) adds fees, shipping and custom lines; 6 (ADR-077) adds coupons, regular prices, line
|
|
47
|
+
* attributes and Any picks (#495); a plugin advertises each only once it handles it.
|
|
48
|
+
* 7 (ADR-083) adds the sale note.
|
|
46
49
|
*/
|
|
47
50
|
declare const SUPPORTED_ORDER_CREATE_VERSIONS: readonly number[];
|
|
48
51
|
/** The till's capability for the contract versions shared by all five register commands; a server passes its own. */
|
|
@@ -165,7 +168,7 @@ declare function deriveSessionFigures(input: {
|
|
|
165
168
|
};
|
|
166
169
|
declare function deriveVariance(counted: Record<string, number>, expected: Record<string, number>): Record<string, number>;
|
|
167
170
|
|
|
168
|
-
type RegisterConflictCode = 'register_session_already_open' | 'register_session_superseded' | 'register_supersede_forbidden' | 'register_session_closed' | 'register_closure_exists' | 'register_closure_number_invalid';
|
|
171
|
+
type RegisterConflictCode = 'register_session_already_open' | 'register_session_superseded' | 'register_supersede_forbidden' | 'register_session_closed' | 'register_closure_exists' | 'register_closure_number_invalid' | 'register_approval_required' | 'register_approval_invalid';
|
|
169
172
|
type RegisterOutcome = {
|
|
170
173
|
kind: 'ok';
|
|
171
174
|
register: RegisterCommandResult;
|
|
@@ -178,8 +181,7 @@ type RegisterOutcome = {
|
|
|
178
181
|
message: string;
|
|
179
182
|
};
|
|
180
183
|
|
|
181
|
-
/** Every error.code a plugin may put on a rejected result (ADR-038 and its amendments, ADR-068)
|
|
182
|
-
* except `register_approval_required`, which arrives with registers c2c. */
|
|
184
|
+
/** Every error.code a plugin may put on a rejected result (ADR-038 and its amendments, ADR-068, ADR-082). */
|
|
183
185
|
type CommandRejectionCode = 'invalid_payload' | 'unsupported_version' | 'idempotency_mismatch' | 'store_configuration' | 'platform_error' | 'insufficient_stock' | 'unsupported_tax_mode' | 'internal_error' | 'coupon_invalid' | 'total_mismatch' | OrderRejectionCode | RegisterConflictCode | OrderRefundRejectionCode;
|
|
184
186
|
/**
|
|
185
187
|
* The rejected result for a platform-native error the plugin has judged permanent (a replay would fail
|