@tallyui/core 3.17.0 → 3.19.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-CSXNXRBA.js → chunk-27L7XLTT.js} +48 -0
- package/dist/command-result-BZd1YFMP.d.ts +1956 -0
- package/dist/index.d.ts +51 -1085
- package/dist/index.js +145 -9
- package/dist/server/index.d.ts +46 -5
- package/dist/server/index.js +594 -114
- package/package.json +1 -1
- package/src/customer-display/advertisement.ts +57 -0
- package/src/customer-display/index.ts +2 -0
- package/src/customer-display/rate-limit-source.ts +40 -0
- package/src/index.ts +13 -2
- package/src/order-filters.ts +58 -0
- package/src/server/batch.ts +4 -0
- package/src/server/display-signalling/contract.ts +254 -0
- package/src/server/display-signalling/index.ts +3 -0
- package/src/server/display-signalling/memory-server.ts +250 -0
- package/src/server/index.ts +2 -0
- package/src/server/order-payload-shape.ts +25 -1
- package/src/server/versions.ts +2 -2
- package/src/tax/woocommerce/index.ts +2 -0
- package/src/tax/woocommerce/tax-location.ts +59 -0
- package/src/types/commands.ts +27 -4
- package/src/types/connector.ts +41 -7
- package/src/types/customers.ts +9 -0
- package/src/types/display-signalling.ts +123 -0
- package/src/types/index.ts +6 -1
- package/src/types/orders.ts +23 -0
- package/src/types/receipt-templates.ts +26 -0
- package/src/types/store-settings.ts +42 -1
- package/dist/command-result-CoCa8PXJ.d.ts +0 -544
package/dist/index.d.ts
CHANGED
|
@@ -1,1049 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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';
|
|
1
|
+
import { I as IceServer, D as DisplayAdvertisement, O as OrderFilterField, L as ListOrdersQuery, M as Money, P as ProductPrice, R as ResolvedPrice, V as VariantSummary, C as CommandWarning, a as ProductTraits, S as StockReconcileAdapter, b as StockLevel, c as ReplicationAdapter, d as SyncContext, T as TallyConnector, e as TraitContext, f as CustomerTraits, g as CalculateTaxesInput, h as CalculateTaxesResult, W as WooTaxRate, i as ItemizedTax, j as ResolvedTaxLocation, k as TAX_BASED_ON_META_KEY, l as TaxAddress, m as TaxBasedOn, n as TaxLocationOrder, o as normalizeTaxBasedOn, p as orderTaxLocation } from './command-result-BZd1YFMP.js';
|
|
2
|
+
export { A as AnyCommandEnvelope, q as AuthField, B as BatchTooLargeBody, r as CASHIER_PERMISSIONS, s as COMMANDS_PATH, t as CaptureMode, u as CaptureModeEntry, v as Cashier, w as CashierPermission, x as CatalogueReconcileAdapter, y as CatalogueReconcileEntry, z as CollectionSync, E as CommandBatchRequest, F as CommandBatchResponse, G as CommandEnvelope, H as CommandError, J as CommandResult, K as CommandResultError, N as CommandServerRefs, Q as CommandStatus, U as CommandType, X as ConnectivityState, Y as ConnectorAuth, Z as ConnectorSchemas, _ as ConnectorTraits, $ as Customer, a0 as CustomerAddress, a1 as CustomerInput, a2 as CustomerPage, a3 as CustomerPatch, a4 as CustomerServiceError, a5 as CustomerTaxId, a6 as DISPLAY_PAIR_CAPABILITY, a7 as DisplayRecord, a8 as DisplaySignalling, a9 as DisplaySignallingContext, aa as DisplaySignallingError, ab as DisplaySignallingErrorCode, ac as FailureClass, ad as FingerprintReconcileAdapter, ae as IdReconcileAdapter, af as MAX_COMMANDS_PER_BATCH, ag as ORDER_NOTE_MAX, ah as OrderAddress, ai as OrderCreateCoupon, aj as OrderCreateCouponInvalidData, ak as OrderCreateDisplay, al as OrderCreateEnvelope, am as OrderCreateLine, an as OrderCreatePayload, ao as OrderCreatePayment, ap as OrderCreateTaxRate, aq as OrderCreateTotalMismatchData, ar as OrderRefundAmountMismatchData, as as OrderRefundEnvelope, at as OrderRefundLine, au as OrderRefundNoOpenSessionData, av as OrderRefundOrderStateData, aw as OrderRefundPayload, ax as OrderRefundQuantityExceedsData, ay as OrderRefundRejectionCode, az as OrderRefundResult, aA as PROTOCOL_HEADER, aB as PROTOCOL_VERSION, aC as PaymentHardware, aD as PaymentKind, aE as PaymentMethodDescriptor, aF as PaymentMethodKind, aG as PaymentOfflineMode, aH as PaymentRounding, aI as PaymentTipsMode, aJ as PaymentTransport, aK as PendingPairing, aL as ProductCategory, aM as ReceiptTemplate, aN as ReceiptTemplateKind, aO as RegisterApprovalInvalidData, aP as RegisterApprovalRequiredData, aQ as RegisterClosureSubmitPayload, aR as RegisterCommandEnvelope, aS as RegisterCommandResult, aT as RegisterCommandType, aU as RegisterInfo, aV as RegisterMovementRecordPayload, aW as RegisterMovementVoidPayload, aX as RegisterSessionAlreadyOpenData, aY as RegisterSessionOpenPayload, aZ as RegisterSessionSupersededData, a_ as RegisterSessionTransitionPayload, a$ as RemoteIdEntry, b0 as ServerCapabilities, b1 as SignInResult, b2 as SignalMessage, b3 as StockStatus, b4 as StoreOrder, b5 as StoreOrderCharge, b6 as StoreOrderLine, b7 as StoreOrderPage, b8 as StoreOrderPayment, b9 as StoreOrderRefund, ba as StoreSettings, bb as StoreSettingsChoice, bc as StoreTaxRate, bd as StoreTaxRateLocation, be as TaxRounding, bf as UpdateRequired, bg as VariantOptionGroup, bh as cashierPermissions, bi as classifyFailure, bj as customerTraits, bk as defaultPaymentMethods, bl as isCashierPermission, bm as isCommandBatchResponse, bn as neutralFailureClass, bo as noResponse, bp as parseCommandResult, bq as parseInfoCapabilities, br as parseLineTax, bs as parseTaxRounding, bt as paymentMethodOf, bu as resolveCapabilities } from './command-result-BZd1YFMP.js';
|
|
5
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
4
|
import { ReactNode } from 'react';
|
|
5
|
+
import 'rxdb';
|
|
6
|
+
import 'rxjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* with its ISO 4217 currency code. Integers keep arithmetic exact, and the
|
|
11
|
-
* code travels with the amount so nothing assumes a store-wide currency.
|
|
9
|
+
* v2's default ICE list: two operators' public STUN servers, so one outage does not cost the candidate (ADR-085 d7).
|
|
12
10
|
*/
|
|
13
|
-
|
|
14
|
-
/** Integer amount in the currency's minor unit, e.g. 1250 for €12.50. */
|
|
15
|
-
amount: number;
|
|
16
|
-
/** Upper-case ISO 4217 code, e.g. 'EUR'. 'XXX' when the backend gives none. */
|
|
17
|
-
currency: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* One entry in a product's price list.
|
|
21
|
-
*
|
|
22
|
-
* `base` is the everyday price. `sale` is a temporary reduction that replaces
|
|
23
|
-
* the base price in the same currency while it applies. Backends express
|
|
24
|
-
* sales differently (WooCommerce sale_price, Medusa sale price lists, Shopify
|
|
25
|
-
* compare_at_price) and each connector maps its own form into these entries,
|
|
26
|
-
* so components never need regular/sale/on-sale flags.
|
|
27
|
-
*/
|
|
28
|
-
interface ProductPrice extends Money {
|
|
29
|
-
kind: 'base' | 'sale';
|
|
30
|
-
/** Set when the backend says so for this price; it wins over the store-level `pricesIncludeTax`. Undefined: use the store-level setting. */
|
|
31
|
-
taxInclusive?: boolean;
|
|
32
|
-
}
|
|
33
|
-
/** The price to charge, and the price it replaces when a sale applies; each keeps its source's `taxInclusive` when set. */
|
|
34
|
-
interface ResolvedPrice {
|
|
35
|
-
current: Money & {
|
|
36
|
-
taxInclusive?: boolean;
|
|
37
|
-
};
|
|
38
|
-
/** Set only when a sale price applies: the base price it replaces. */
|
|
39
|
-
was?: Money & {
|
|
40
|
-
taxInclusive?: boolean;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Backend-neutral stock state.
|
|
46
|
-
*
|
|
47
|
-
* - `in_stock`: sellable now. `quantity` is set when the backend tracks it.
|
|
48
|
-
* - `out_of_stock`: tracked and none left; not sellable.
|
|
49
|
-
* - `backorder`: none left but the backend accepts orders anyway.
|
|
50
|
-
* - `unknown`: the backend did not say.
|
|
51
|
-
*
|
|
52
|
-
* `quantity` is undefined when stock is not tracked, which is different from
|
|
53
|
-
* a tracked quantity of 0.
|
|
54
|
-
*/
|
|
55
|
-
type StockStatus = 'in_stock' | 'out_of_stock' | 'backorder' | 'unknown';
|
|
56
|
-
interface StockLevel {
|
|
57
|
-
status: StockStatus;
|
|
58
|
-
/** Units on hand, when tracked. May be negative on backorder. */
|
|
59
|
-
quantity?: number;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** A flat product category: `id` is the backend's id as a string (unique per backend), `name` its label. */
|
|
63
|
-
interface ProductCategory {
|
|
64
|
-
id: string;
|
|
65
|
-
name: string;
|
|
66
|
-
}
|
|
67
|
-
/** One purchasable variant of a product, in backend-neutral terms. */
|
|
68
|
-
interface VariantSummary {
|
|
69
|
-
/** Backend variant id; the id sent in order lines. */
|
|
70
|
-
id: string;
|
|
71
|
-
/** Variant label, e.g. 'S / White'; undefined when the backend has none. */
|
|
72
|
-
title?: string;
|
|
73
|
-
/**
|
|
74
|
-
* The variant's value in each option group, keyed by group name. A group the variant accepts any value of
|
|
75
|
-
* (WooCommerce "Any …") has no key. Undefined when the backend gives the variant no option groups.
|
|
76
|
-
*/
|
|
77
|
-
options?: Record<string, string>;
|
|
78
|
-
sku?: string;
|
|
79
|
-
/** First non-empty of the backend's barcode fields. */
|
|
80
|
-
barcode?: string;
|
|
81
|
-
prices: ProductPrice[];
|
|
82
|
-
stock: StockLevel;
|
|
83
|
-
}
|
|
84
|
-
/** One option group a product's variants are chosen by, e.g. Size with S, M and L. */
|
|
85
|
-
interface VariantOptionGroup {
|
|
86
|
-
/** The backend's id for the group, when it has one that tells apart groups with the same name. */
|
|
87
|
-
id?: string;
|
|
88
|
-
name: string;
|
|
89
|
-
/** The group's values in the backend's order. */
|
|
90
|
-
values: string[];
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Store-level facts a connector may need to interpret a raw document, for
|
|
94
|
-
* backends whose documents omit them (WooCommerce product prices carry no
|
|
95
|
-
* currency).
|
|
96
|
-
*/
|
|
97
|
-
interface TraitContext {
|
|
98
|
-
/** The store's ISO 4217 currency code. */
|
|
99
|
-
currency?: string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Product traits — the stable interface that UI components program against.
|
|
103
|
-
*
|
|
104
|
-
* Each connector implements these accessors to extract standard product data
|
|
105
|
-
* from its own schema shape. Components call these instead of reaching into
|
|
106
|
-
* the raw document, so they work identically across WooCommerce, Medusa,
|
|
107
|
-
* Vendure, Shopify, etc.
|
|
108
|
-
*
|
|
109
|
-
* The generic `Doc` type is the connector's raw RxDB document type.
|
|
110
|
-
*
|
|
111
|
-
* Price and stock are read through the backend-neutral `getPrices` and
|
|
112
|
-
* `getStock`. The older string-price and WooCommerce-style stock accessors
|
|
113
|
-
* remain for existing consumers and are deprecated.
|
|
114
|
-
*/
|
|
115
|
-
interface ProductTraits<Doc = any> {
|
|
116
|
-
/** Product display name */
|
|
117
|
-
getName: (doc: Doc) => string;
|
|
118
|
-
/** SKU / stock keeping unit */
|
|
119
|
-
getSku: (doc: Doc) => string | undefined;
|
|
120
|
-
/**
|
|
121
|
-
* The product's price list: base prices, plus sale prices while a sale
|
|
122
|
-
* applies, per currency. Pass the list to `resolvePrice` for the price to
|
|
123
|
-
* charge. For variable products this describes the default variant.
|
|
124
|
-
*/
|
|
125
|
-
getPrices: (doc: Doc, context?: TraitContext) => ProductPrice[];
|
|
126
|
-
/** Stock state of the whole product across its variants; `quantity` is the total on hand when every variant is tracked, else undefined. */
|
|
127
|
-
getStock: (doc: Doc) => StockLevel;
|
|
128
|
-
/** All purchasable variants, in id order (connectors store variants sorted by id). Optional: connectors without variant support omit it. */
|
|
129
|
-
getVariants?: (doc: Doc, context?: TraitContext) => VariantSummary[];
|
|
130
|
-
/**
|
|
131
|
-
* The option groups the product's variants are chosen by, in the backend's display order; [] when the product has
|
|
132
|
-
* none. Optional: connectors without it leave pickers to `getVariants` titles.
|
|
133
|
-
*/
|
|
134
|
-
getVariantOptions?: (doc: Doc) => VariantOptionGroup[];
|
|
135
|
-
/**
|
|
136
|
-
* The backend's tax class id for the variant `variantId`, or for the product (its default variant) when omitted.
|
|
137
|
-
* The id is a key of `StoreSettings.taxRatesPpm`; undefined means the default class. Optional: without it, every
|
|
138
|
-
* line is taxed at the default rate.
|
|
139
|
-
*/
|
|
140
|
-
getTaxClass?: (doc: Doc, variantId?: string) => string | undefined;
|
|
141
|
-
/**
|
|
142
|
-
* Whether the variant `variantId` (or the product's default variant) is taxed: 'none' means the line carries no
|
|
143
|
-
* tax. Undefined means taxable. Optional: without it, every line is taxable.
|
|
144
|
-
*/
|
|
145
|
-
getTaxStatus?: (doc: Doc, variantId?: string) => 'taxable' | 'none' | undefined;
|
|
146
|
-
/** @deprecated Use `getPrices` with `resolvePrice`. */
|
|
147
|
-
getPrice: (doc: Doc) => string | undefined;
|
|
148
|
-
/** Regular (non-sale) price. @deprecated Use `getPrices` with `resolvePrice`. */
|
|
149
|
-
getRegularPrice: (doc: Doc) => string | undefined;
|
|
150
|
-
/** Sale price, if on sale. @deprecated Use `getPrices` with `resolvePrice`. */
|
|
151
|
-
getSalePrice: (doc: Doc) => string | undefined;
|
|
152
|
-
/** Whether the product is currently on sale. @deprecated Use `getPrices` with `resolvePrice`. */
|
|
153
|
-
isOnSale: (doc: Doc) => boolean;
|
|
154
|
-
/** Primary image URL */
|
|
155
|
-
getImageUrl: (doc: Doc) => string | undefined;
|
|
156
|
-
/** All image URLs */
|
|
157
|
-
getImageUrls: (doc: Doc) => string[];
|
|
158
|
-
/** Short description / excerpt */
|
|
159
|
-
getDescription: (doc: Doc) => string | undefined;
|
|
160
|
-
/** Stock status. @deprecated Use `getStock`. */
|
|
161
|
-
getStockStatus: (doc: Doc) => 'instock' | 'outofstock' | 'onbackorder' | 'unknown';
|
|
162
|
-
/** Stock quantity (null if not tracked). @deprecated Use `getStock`. */
|
|
163
|
-
getStockQuantity: (doc: Doc) => number | null;
|
|
164
|
-
/** Whether this product has variants/variations */
|
|
165
|
-
hasVariants: (doc: Doc) => boolean;
|
|
166
|
-
/** Whether the product may be sold at the register now: published/active, not a draft, archived or disabled. */
|
|
167
|
-
isSellable: (doc: Doc) => boolean;
|
|
168
|
-
/** Number of purchasable variants; 1 for a simple product. */
|
|
169
|
-
getVariantCount: (doc: Doc) => number;
|
|
170
|
-
/** Product type (simple, variable, etc. — connector-specific but useful for UI hints) */
|
|
171
|
-
getType: (doc: Doc) => string;
|
|
172
|
-
/** Barcode / UPC / EAN */
|
|
173
|
-
getBarcode: (doc: Doc) => string | undefined;
|
|
174
|
-
/** Categories as simple label strings */
|
|
175
|
-
getCategoryNames: (doc: Doc) => string[];
|
|
176
|
-
/**
|
|
177
|
-
* The product's categories as `{ id, name }`, in the document's order, without entries that have no name.
|
|
178
|
-
* Optional: without it, the pos category helpers use `getCategoryNames` with each name as its id.
|
|
179
|
-
*/
|
|
180
|
-
getCategories?: (doc: Doc) => ProductCategory[];
|
|
181
|
-
/** The connector-specific unique ID (as string for consistency) */
|
|
182
|
-
getId: (doc: Doc) => string;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Customer traits — the stable interface that UI components program against.
|
|
187
|
-
*
|
|
188
|
-
* Each connector implements these to extract standard customer data
|
|
189
|
-
* from its own schema shape.
|
|
190
|
-
*/
|
|
191
|
-
interface CustomerTraits<Doc = any> {
|
|
192
|
-
/** Customer display name (first + last or company) */
|
|
193
|
-
getName: (doc: Doc) => string;
|
|
194
|
-
/** Email address */
|
|
195
|
-
getEmail: (doc: Doc) => string | undefined;
|
|
196
|
-
/** Phone number */
|
|
197
|
-
getPhone: (doc: Doc) => string | undefined;
|
|
198
|
-
/** One-line address summary (e.g., "123 Main St, Springfield") */
|
|
199
|
-
getAddressSummary: (doc: Doc) => string | undefined;
|
|
200
|
-
/** The connector-specific unique ID (as string for consistency) */
|
|
201
|
-
getId: (doc: Doc) => string;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Replication adapter interface for a single collection.
|
|
206
|
-
*
|
|
207
|
-
* Each connector implements this to provide pull/push handlers
|
|
208
|
-
* compatible with RxDB's replicateRxCollection protocol.
|
|
209
|
-
*
|
|
210
|
-
* CheckpointType is connector-specific (cursor, offset+timestamp, etc).
|
|
211
|
-
*/
|
|
212
|
-
interface ReplicationAdapter<RxDocType, CheckpointType = any> {
|
|
213
|
-
pull: {
|
|
214
|
-
/**
|
|
215
|
-
* Fetch documents changed since the last checkpoint.
|
|
216
|
-
* Return an empty documents array when fully caught up.
|
|
217
|
-
*/
|
|
218
|
-
handler: (lastCheckpoint: CheckpointType | undefined, batchSize: number, context: SyncContext) => Promise<{
|
|
219
|
-
documents: Array<RxDocType & {
|
|
220
|
-
_deleted: boolean;
|
|
221
|
-
}>;
|
|
222
|
-
checkpoint: CheckpointType;
|
|
223
|
-
}>;
|
|
224
|
-
/**
|
|
225
|
-
* Documents per pull page, passed to handler as batchSize. RxDB treats a
|
|
226
|
-
* shorter page as the end of the cycle. Defaults to RxDB's 100.
|
|
227
|
-
*/
|
|
228
|
-
batchSize?: number;
|
|
229
|
-
/**
|
|
230
|
-
* Fresh install only: the checkpoint this feed starts from instead of a full first pass,
|
|
231
|
-
* read before any feed runs (combinePullAdapters). Absent: a full first pass, as today.
|
|
232
|
-
*/
|
|
233
|
-
seedCheckpoint?: (context: SyncContext) => Promise<CheckpointType>;
|
|
234
|
-
/**
|
|
235
|
-
* Optional real-time event stream.
|
|
236
|
-
* Emit { documents, checkpoint } for live updates,
|
|
237
|
-
* or 'RESYNC' to trigger a full pull cycle.
|
|
238
|
-
*/
|
|
239
|
-
stream$?: Observable<RxReplicationPullStreamItem<RxDocType, CheckpointType>>;
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* A push adapter must accept the same rows twice: a cancel after a send re-sends them. A direct RxDB `pause()`
|
|
243
|
-
* before the first push starts, or RxDB 17.5 pausing a hidden non-leader tab when `multiInstance` is on
|
|
244
|
-
* (`createTallyDatabase` turns it off and refuses it), still drops the queued rows unsent (#645).
|
|
245
|
-
* `startReplication`'s own sign-in path holds instead of pausing.
|
|
246
|
-
*/
|
|
247
|
-
push?: {
|
|
248
|
-
/**
|
|
249
|
-
* Push local changes to the remote API.
|
|
250
|
-
* Return an array of conflict documents (server's version wins).
|
|
251
|
-
* Return empty array if no conflicts.
|
|
252
|
-
*/
|
|
253
|
-
handler: (changeRows: RxReplicationWriteToMasterRow<RxDocType>[], context: SyncContext) => Promise<Array<RxDocType & {
|
|
254
|
-
_deleted: boolean;
|
|
255
|
-
}>>;
|
|
256
|
-
/** Max documents per push batch. Defaults to 100. */
|
|
257
|
-
batchSize?: number;
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Re-reads stock from the backend, because replication misses stock changes
|
|
263
|
-
* that bump no product timestamp (ADR-060). The runner stores `fetchPages`
|
|
264
|
-
* output in the non-replicated `stock_levels` collection; readers merge it
|
|
265
|
-
* into a read-only view of each product with `overlay`. Nothing is written
|
|
266
|
-
* into the replicated products.
|
|
267
|
-
*/
|
|
268
|
-
interface StockReconcileAdapter<Doc = any> {
|
|
269
|
-
/** Current stock, one backend request per page, keyed as the connector chooses (variant, inventory item). */
|
|
270
|
-
fetchPages(context: SyncContext): AsyncIterable<Map<string, unknown>>;
|
|
271
|
-
/**
|
|
272
|
-
* Pure: the fields of `doc` that `stock` changes, or undefined when nothing
|
|
273
|
-
* differs. Keys absent from `stock` are left alone. The result is merged
|
|
274
|
-
* into a read-only view of the document and never written.
|
|
275
|
-
*/
|
|
276
|
-
overlay(doc: Doc, stock: Map<string, unknown>): Partial<Doc> | undefined;
|
|
277
|
-
}
|
|
278
|
-
/** Catches a deleted product or a deleted variant that replication misses (ADR-060). Nothing is written locally: `enqueue` hands disagreeing documents to a `createReconcileFeed` pull adapter instead. */
|
|
279
|
-
interface IdReconcileAdapter<Doc = any> {
|
|
280
|
-
/** Every live product with its live variant ids, one backend request per page. */
|
|
281
|
-
fetchPages(context: SyncContext): AsyncIterable<Array<{
|
|
282
|
-
id: string;
|
|
283
|
-
variantIds: string[];
|
|
284
|
-
}>>;
|
|
285
|
-
/** The variant ids a local product document lists. */
|
|
286
|
-
variantIds(doc: Doc): string[];
|
|
287
|
-
/** Hand local documents that disagree with the backend to the collection's pull (see createReconcileFeed). */
|
|
288
|
-
enqueue(entries: Array<{
|
|
289
|
-
id: string;
|
|
290
|
-
local: Doc;
|
|
291
|
-
}>): void;
|
|
292
|
-
/** Ids per `fetchByIds` request; see `CatalogueReconcileAdapter.refetchBatchSize`. */
|
|
293
|
-
refetchBatchSize?: number;
|
|
294
|
-
}
|
|
295
|
-
/** Re-delivers products whose remote fingerprint differs from the local one (ADR-060). */
|
|
296
|
-
interface FingerprintReconcileAdapter<Doc = any> {
|
|
297
|
-
/** Remote fingerprints by product id, one backend request per page. Products the backend doesn't report are left alone. */
|
|
298
|
-
fetchPages(context: SyncContext): AsyncIterable<Map<string, string>>;
|
|
299
|
-
/** The same fingerprint computed from a local product document. */
|
|
300
|
-
fingerprint(doc: Doc): string;
|
|
301
|
-
/**
|
|
302
|
-
* Hands products to the collection's pull (the reconcile feed). `refreshOnly`
|
|
303
|
-
* marks an entry so a missing product is skipped, never tombstoned: only the
|
|
304
|
-
* id reconcile, with its mass-delete brake, may delete.
|
|
305
|
-
*/
|
|
306
|
-
enqueue(entries: Array<{
|
|
307
|
-
id: string;
|
|
308
|
-
local: Doc;
|
|
309
|
-
refreshOnly?: boolean;
|
|
310
|
-
}>): void;
|
|
311
|
-
/** Ids per `fetchByIds` request; see `CatalogueReconcileAdapter.refetchBatchSize`. */
|
|
312
|
-
refetchBatchSize?: number;
|
|
313
|
-
}
|
|
314
|
-
/** One product in the catalogue listing. `key` is the local primary key, or the `matchKey` value when the adapter sets one; `remote` is whatever the connector needs to refetch it (a numeric backend id, say). */
|
|
315
|
-
interface CatalogueReconcileEntry {
|
|
316
|
-
key: string;
|
|
317
|
-
fingerprint: string;
|
|
318
|
-
remote?: unknown;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* The daily catalogue check (#248): one walk that refetches what differs and
|
|
322
|
-
* deletes only with proof. Nothing is written locally: `enqueue` hands
|
|
323
|
-
* documents to the collection's pull (the reconcile feed). `Cursor` must be
|
|
324
|
-
* JSON-serialisable, since the runner persists it to resume a stopped pass.
|
|
325
|
-
*/
|
|
326
|
-
interface CatalogueReconcileAdapter<Doc = any, Cursor = unknown> {
|
|
327
|
-
/** Remote listing, one backend request per page, from `from` (a cursor this adapter yielded earlier) or the start. */
|
|
328
|
-
fetchPages(context: SyncContext, from?: Cursor): AsyncIterable<{
|
|
329
|
-
entries: CatalogueReconcileEntry[];
|
|
330
|
-
cursor: Cursor;
|
|
331
|
-
}>;
|
|
332
|
-
/** Pure: the same fingerprint from a local document. */
|
|
333
|
-
fingerprint(doc: Doc): string;
|
|
334
|
-
/**
|
|
335
|
-
* When set, each listing entry's `key` is this value, not the local primary key (a listing that carries no
|
|
336
|
-
* primary key, such as WCPOS's fast path, #313). The runner indexes the local documents by it for the pass.
|
|
337
|
-
* A document for which it returns undefined can't be matched: it is never compared, and it is a deletion
|
|
338
|
-
* candidate, as today.
|
|
339
|
-
*/
|
|
340
|
-
matchKey?(doc: Doc): string | undefined;
|
|
341
|
-
/**
|
|
342
|
-
* Deletion proof, required: of these local documents (the ones the listing did not name), the primary keys
|
|
343
|
-
* the backend confirms gone (absent, or no longer sellable), with or without `matchKey`. One or more requests.
|
|
344
|
-
* Only confirmed keys are tombstoned; an adapter that never deletes returns none.
|
|
345
|
-
*/
|
|
346
|
-
confirmGone(locals: Doc[], context: SyncContext): Promise<string[]>;
|
|
347
|
-
/**
|
|
348
|
-
* Hand documents to the collection's pull (the reconcile feed). An entry's `key` is the local primary key when
|
|
349
|
-
* there is a local copy, and otherwise the listing's key.
|
|
350
|
-
* A `refreshOnly` entry asks the feed to fetch the document again and is never tombstoned when the fetch omits it.
|
|
351
|
-
*/
|
|
352
|
-
enqueue(entries: Array<{
|
|
353
|
-
key: string;
|
|
354
|
-
local?: Doc;
|
|
355
|
-
remote?: unknown;
|
|
356
|
-
tombstone?: boolean;
|
|
357
|
-
refreshOnly?: boolean;
|
|
358
|
-
}>): void;
|
|
359
|
-
/** Ids per `fetchByIds` request of the feed this adapter enqueues into: a page's `n` refetches take `ceil(n / refetchBatchSize)` budget slots (1 when unset). */
|
|
360
|
-
refetchBatchSize?: number;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/** What the POS needs from the store's own settings (TV4). Read once after sign-in; the app feeds all three consumers from it. */
|
|
364
|
-
interface StoreSettings {
|
|
365
|
-
/** ISO 4217, upper case (the currency prices are sold in). */
|
|
366
|
-
currency: string;
|
|
367
|
-
/** Whether the store's catalogue prices include tax. It feeds both the connector's traits and the POS TaxProvider, so the two cannot disagree. */
|
|
368
|
-
pricesIncludeTax: boolean;
|
|
369
|
-
/** Tax rates for the store's location as integer parts per million (25% = 250000), keyed by the backend's tax class; `default` applies to a product with no class. Always integers: a connector rounds a backend's decimal rate once, at its edge. Structurally the same as @tallyui/pos's TaxRateMap. */
|
|
370
|
-
taxRatesPpm: {
|
|
371
|
-
default: number;
|
|
372
|
-
[taxClass: string]: number;
|
|
373
|
-
};
|
|
374
|
-
/** The backend's tax rate name per tax class (same keys as `taxRatesPpm`, including `default`), for `per_rate_group_items`' grouping (#324). Set by a connector whose rounding groups by rate name; absent otherwise. */
|
|
375
|
-
taxRateCodes?: Record<string, string>;
|
|
376
|
-
/** WooCommerce rates already filtered to the store's tax address; the empty class uses `standard`. */
|
|
377
|
-
taxRates?: Record<string, {
|
|
378
|
-
id: number;
|
|
379
|
-
code: string;
|
|
380
|
-
label: string;
|
|
381
|
-
rate: string;
|
|
382
|
-
priority: number;
|
|
383
|
-
compound: boolean;
|
|
384
|
-
shipping: boolean;
|
|
385
|
-
}[]>;
|
|
386
|
-
taxRoundAtSubtotal?: boolean;
|
|
387
|
-
/** WooCommerce's calculate coupon discounts sequentially setting. */
|
|
388
|
-
calcDiscountsSequentially?: boolean;
|
|
389
|
-
shippingTaxClass?: string;
|
|
390
|
-
taxClassSlugs?: string[];
|
|
391
|
-
/** Connector-specific and opaque to the app: what the connector needs to price documents. The app passes it back to the connector unchanged, and never logs it. */
|
|
392
|
-
pricingContext?: Record<string, string>;
|
|
393
|
-
/** Derived, never read by `storeSettings`: the store's `ServerCapabilities.taxRounding`, which `useStoreSettings` fills in (#324). */
|
|
394
|
-
taxRounding?: TaxRounding;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Picks among several regions, countries or sales channels when the store has more than one.
|
|
398
|
-
* The app persists the choice per store, in its own settings, so it is asked once. A stored
|
|
399
|
-
* choice that no longer resolves (for example, the region was deleted) raises `choice_required`
|
|
400
|
-
* again instead of failing. Backends without the concept ignore a field.
|
|
401
|
-
*/
|
|
402
|
-
interface StoreSettingsChoice {
|
|
403
|
-
region?: string;
|
|
404
|
-
country?: string;
|
|
405
|
-
channel?: string;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/** A customer's postal address. Platform-neutral; every field optional. `country` is an ISO 3166-1 alpha-2 code. */
|
|
409
|
-
interface CustomerAddress {
|
|
410
|
-
firstName?: string;
|
|
411
|
-
lastName?: string;
|
|
412
|
-
company?: string;
|
|
413
|
-
address1?: string;
|
|
414
|
-
address2?: string;
|
|
415
|
-
city?: string;
|
|
416
|
-
state?: string;
|
|
417
|
-
postcode?: string;
|
|
418
|
-
country?: string;
|
|
419
|
-
phone?: string;
|
|
420
|
-
email?: string;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* A tax registration number (VAT, ABN, GST, EIN…). `type` is the connector's own id for the scheme; WCPOS v2's set is
|
|
424
|
-
* 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.
|
|
425
|
-
*/
|
|
426
|
-
interface CustomerTaxId {
|
|
427
|
-
type: string;
|
|
428
|
-
value: string;
|
|
429
|
-
country?: string;
|
|
430
|
-
label?: string;
|
|
431
|
-
}
|
|
432
|
-
/** A store customer, as the till shows and picks it (programme item 14). Platform-neutral. */
|
|
433
|
-
interface Customer {
|
|
434
|
-
/** The platform's id: order.create v3 sends it as `customer.customerId`. */
|
|
435
|
-
id: string;
|
|
436
|
-
/** Display name: first + last, else company, else email, else id. Never empty. */
|
|
437
|
-
name: string;
|
|
438
|
-
firstName?: string;
|
|
439
|
-
lastName?: string;
|
|
440
|
-
email?: string;
|
|
441
|
-
phone?: string;
|
|
442
|
-
company?: string;
|
|
443
|
-
billing?: CustomerAddress;
|
|
444
|
-
shipping?: CustomerAddress;
|
|
445
|
-
taxIds?: CustomerTaxId[];
|
|
446
|
-
}
|
|
447
|
-
/** What the till collects to create a customer. v1 requires an email; addresses and tax ids are optional. */
|
|
448
|
-
interface CustomerInput {
|
|
449
|
-
email: string;
|
|
450
|
-
firstName?: string;
|
|
451
|
-
lastName?: string;
|
|
452
|
-
phone?: string;
|
|
453
|
-
company?: string;
|
|
454
|
-
billing?: CustomerAddress;
|
|
455
|
-
shipping?: CustomerAddress;
|
|
456
|
-
taxIds?: CustomerTaxId[];
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* A change to an existing customer: any subset of {@link CustomerInput}. A field left out is unchanged; `billing`,
|
|
460
|
-
* `shipping` and `taxIds`, when given, replace the stored value whole (`taxIds: []` removes every tax id).
|
|
461
|
-
*/
|
|
462
|
-
type CustomerPatch = Partial<CustomerInput>;
|
|
463
|
-
declare const customerTraits: CustomerTraits<Customer>;
|
|
464
|
-
/** A customer call that failed for a reason other than credentials (credentials throw ConnectorUnauthorizedError). */
|
|
465
|
-
declare class CustomerServiceError extends Error {
|
|
466
|
-
readonly code: 'network' | 'server' | 'invalid';
|
|
467
|
-
/** The HTTP status the store answered with, when the connector has it; undefined for a network failure (no response). */
|
|
468
|
-
readonly status?: number;
|
|
469
|
-
constructor(code: 'network' | 'server' | 'invalid', message: string, options?: {
|
|
470
|
-
status?: number;
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/** A line of an order the store holds (ADR-081). Money in integer minor units of the order's currency, as the store
|
|
475
|
-
* records it: every amount excludes tax, and the tax is beside it.
|
|
476
|
-
* Each tax field is such that net + tax is the gross rounded once. */
|
|
477
|
-
interface StoreOrderLine {
|
|
478
|
-
/** The store's line id: what `OrderRefundLine.orderLineId` names. */
|
|
479
|
-
id: string;
|
|
480
|
-
/** The till's line id when a till created the line (its `clientLineId`); absent otherwise. */
|
|
481
|
-
clientLineId?: string;
|
|
482
|
-
productId?: string;
|
|
483
|
-
/** The sellable the till's `variantId` names (a WooCommerce variation, or the product itself when simple). */
|
|
484
|
-
variantId?: string;
|
|
485
|
-
name: string;
|
|
486
|
-
sku?: string;
|
|
487
|
-
quantity: number;
|
|
488
|
-
/** Before discounts, excluding tax. */
|
|
489
|
-
subtotalMinor: number;
|
|
490
|
-
subtotalTaxMinor: number;
|
|
491
|
-
/** After discounts, excluding tax. */
|
|
492
|
-
totalMinor: number;
|
|
493
|
-
taxMinor: number;
|
|
494
|
-
}
|
|
495
|
-
/** A fee or shipping line: excluding tax, the tax beside it. A fee may be negative.
|
|
496
|
-
* `taxMinor` is such that `totalMinor + taxMinor` is the gross rounded once. */
|
|
497
|
-
interface StoreOrderCharge {
|
|
498
|
-
name: string;
|
|
499
|
-
totalMinor: number;
|
|
500
|
-
taxMinor: number;
|
|
501
|
-
}
|
|
502
|
-
interface StoreOrderPayment {
|
|
503
|
-
/** The store's own method id, e.g. WooCommerce's `pos_cash`. */
|
|
504
|
-
method: string;
|
|
505
|
-
/** The store's name for it, e.g. "Cash". */
|
|
506
|
-
title?: string;
|
|
507
|
-
/** Set only when the method is one the till itself takes. */
|
|
508
|
-
kind?: PaymentMethodKind;
|
|
509
|
-
amountMinor: number;
|
|
510
|
-
}
|
|
511
|
-
/** A refund the store already recorded against the order. */
|
|
512
|
-
interface StoreOrderRefund {
|
|
513
|
-
id: string; /** Positive. */
|
|
514
|
-
amountMinor: number;
|
|
515
|
-
reason?: string;
|
|
516
|
-
}
|
|
517
|
-
/** An order as the store holds it, read online (ADR-081); never stored by the till. */
|
|
518
|
-
interface StoreOrder {
|
|
519
|
-
/** The store's order id: what `OrderRefundPayload.orderId` and `CommandServerRefs.orderId` carry. */
|
|
520
|
-
id: string;
|
|
521
|
-
/** The number the store shows (`CommandServerRefs.displayId`). */
|
|
522
|
-
reference: string;
|
|
523
|
-
/** The till's `PosOrder.id` when a till created the order; absent otherwise. */
|
|
524
|
-
clientOrderId?: string;
|
|
525
|
-
/** The platform's own status word (WooCommerce: `completed`, `refunded`, …); the app labels it. */
|
|
526
|
-
status: string;
|
|
527
|
-
/** ISO 8601, UTC. */
|
|
528
|
-
placedAt: string;
|
|
529
|
-
currency: string;
|
|
530
|
-
pricesIncludeTax: boolean;
|
|
531
|
-
customer: {
|
|
532
|
-
id?: string;
|
|
533
|
-
name?: string;
|
|
534
|
-
email?: string;
|
|
535
|
-
} | null;
|
|
536
|
-
lines: StoreOrderLine[];
|
|
537
|
-
fees: StoreOrderCharge[];
|
|
538
|
-
shipping: StoreOrderCharge[];
|
|
539
|
-
/** `discountMinor + discountTaxMinor` is the coupon's gross discount rounded once. */
|
|
540
|
-
coupons: Array<{
|
|
541
|
-
code: string;
|
|
542
|
-
discountMinor: number;
|
|
543
|
-
discountTaxMinor: number;
|
|
544
|
-
}>;
|
|
545
|
-
/** Tax by rate; `amountMinor` includes the rate's shipping tax. */
|
|
546
|
-
taxLines: Array<{
|
|
547
|
-
label: string;
|
|
548
|
-
code?: string;
|
|
549
|
-
ratePpm: number;
|
|
550
|
-
amountMinor: number;
|
|
551
|
-
}>;
|
|
552
|
-
discountMinor: number;
|
|
553
|
-
discountTaxMinor: number;
|
|
554
|
-
taxMinor: number;
|
|
555
|
-
totalMinor: number;
|
|
556
|
-
payments: StoreOrderPayment[];
|
|
557
|
-
refunds: StoreOrderRefund[];
|
|
558
|
-
}
|
|
559
|
-
interface ListOrdersQuery {
|
|
560
|
-
/** 1-based; default 1. */
|
|
561
|
-
page?: number;
|
|
562
|
-
/** 1..100; default 25. */
|
|
563
|
-
perPage?: number;
|
|
564
|
-
/** The platform's own order search. */
|
|
565
|
-
search?: string;
|
|
566
|
-
}
|
|
567
|
-
interface StoreOrderPage {
|
|
568
|
-
orders: StoreOrder[];
|
|
569
|
-
hasMore: boolean;
|
|
570
|
-
}
|
|
571
|
-
|
|
11
|
+
declare const DEFAULT_ICE_SERVERS: readonly IceServer[];
|
|
572
12
|
/**
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
13
|
+
* Reads `customerDisplay` of `GET /tally/v1/info` (ADR-085 d7, d8). Absent gives `undefined`: no second-device
|
|
14
|
+
* display. Not a plain object, or `v` other than 1, gives `undefined` and one `warn`. `iceServers` absent gives
|
|
15
|
+
* `DEFAULT_ICE_SERVERS`, `[]` is kept (LAN-only), and a refused list (a non-array, or an entry with a URL that is not
|
|
16
|
+
* `stun:`, `stuns:`, `turn:` or `turns:`, or a TURN URL without both username and credential) gives the default and
|
|
17
|
+
* one `warn`. `snapshot` is true only for `snapshot: 1`.
|
|
578
18
|
*/
|
|
579
|
-
|
|
580
|
-
type OpenEnum<Known extends string> = Known | (string & {});
|
|
581
|
-
/** What kind of money the method takes. Not the order's wire method: that is `PaymentMethodKind`. */
|
|
582
|
-
type PaymentKind = 'cash' | 'card' | 'stored_value' | 'bank_transfer' | 'other';
|
|
583
|
-
/** How the payment is taken. `manual`: the cashier records it (cash, a standalone terminal). */
|
|
584
|
-
type CaptureMode = 'manual' | 'webview' | 'server' | 'device' | 'stored_value' | 'gateway';
|
|
585
|
-
/** The transport a payment terminal is reached over. */
|
|
586
|
-
type PaymentTransport = 'bluetooth' | 'usb' | 'network' | 'tap_to_pay';
|
|
587
|
-
/** Whether a leg can be taken while the till is offline: recorded, queued to settle later, or not at all. */
|
|
588
|
-
type PaymentOfflineMode = 'record' | 'queue' | 'none';
|
|
589
|
-
/** Where a tip is entered, if anywhere. */
|
|
590
|
-
type PaymentTipsMode = 'none' | 'on_reader' | 'at_till';
|
|
591
|
-
/** The terminal hardware behind a method: readers the server lists, or transports an SDK discovers. */
|
|
592
|
-
type PaymentHardware = {
|
|
593
|
-
discovery: OpenEnum<'server'>;
|
|
594
|
-
readers: {
|
|
595
|
-
id: string;
|
|
596
|
-
label: string;
|
|
597
|
-
status: OpenEnum<'online' | 'offline'>;
|
|
598
|
-
default: boolean;
|
|
599
|
-
}[];
|
|
600
|
-
defaultReader: string | null;
|
|
601
|
-
lockToDefault: boolean;
|
|
602
|
-
} | {
|
|
603
|
-
discovery: OpenEnum<'sdk' | 'manual'>;
|
|
604
|
-
transports: {
|
|
605
|
-
transport: OpenEnum<PaymentTransport>;
|
|
606
|
-
offline: OpenEnum<PaymentOfflineMode>;
|
|
607
|
-
tips: OpenEnum<PaymentTipsMode>;
|
|
608
|
-
}[];
|
|
609
|
-
};
|
|
610
|
-
/** One way to capture a method's payments. */
|
|
611
|
-
interface CaptureModeEntry {
|
|
612
|
-
mode: OpenEnum<CaptureMode>;
|
|
613
|
-
/** The payment provider's own name, e.g. a terminal vendor; `null` for none. */
|
|
614
|
-
provider: string | null;
|
|
615
|
-
hardware: PaymentHardware | null;
|
|
616
|
-
}
|
|
617
|
-
/** Cash rounding for the method: the due amount rounds to a multiple of `incrementMinor`; `nearest` rounds half up. */
|
|
618
|
-
type PaymentRounding = {
|
|
619
|
-
incrementMinor: number;
|
|
620
|
-
mode: 'nearest' | 'up' | 'down';
|
|
621
|
-
} | null;
|
|
622
|
-
interface PaymentMethodDescriptor {
|
|
623
|
-
/** The connector's own id for the method, stable across reads. */
|
|
624
|
-
id: string;
|
|
625
|
-
/** The name the till shows. */
|
|
626
|
-
title: string;
|
|
627
|
-
kind: OpenEnum<PaymentKind>;
|
|
628
|
-
capture: CaptureModeEntry & {
|
|
629
|
-
/** Every way the method can be captured, the primary first; absent when `mode` is the only one. */
|
|
630
|
-
modes?: CaptureModeEntry[];
|
|
631
|
-
};
|
|
632
|
-
capabilities: {
|
|
633
|
-
/** `partial`: the method may take less than the balance (a split leg). */
|
|
634
|
-
amount: {
|
|
635
|
-
partial: boolean;
|
|
636
|
-
minMinor?: number;
|
|
637
|
-
maxMinor?: number;
|
|
638
|
-
};
|
|
639
|
-
/** Whether tendering more than is due gives change. */
|
|
640
|
-
change: boolean;
|
|
641
|
-
refunds: {
|
|
642
|
-
via: OpenEnum<'provider' | 'manual' | 'device' | 'none'>;
|
|
643
|
-
partial: boolean;
|
|
644
|
-
};
|
|
645
|
-
tips: OpenEnum<PaymentTipsMode>;
|
|
646
|
-
offline: OpenEnum<PaymentOfflineMode>;
|
|
647
|
-
/** Whether a taken leg can be voided. */
|
|
648
|
-
void: boolean;
|
|
649
|
-
};
|
|
650
|
-
defaults: {
|
|
651
|
-
rounding: PaymentRounding;
|
|
652
|
-
/** Whether taking the payment opens the cash drawer. */
|
|
653
|
-
openDrawer: boolean;
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
/** The descriptor of one of today's two wire methods: its `id` is the `PaymentMethodKind`. */
|
|
657
|
-
declare function paymentMethodOf(kind: PaymentMethodKind): PaymentMethodDescriptor;
|
|
658
|
-
/** Today's two methods, cash then the card terminal: what the till offers when the connector has no `paymentMethods`. */
|
|
659
|
-
declare function defaultPaymentMethods(): PaymentMethodDescriptor[];
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* A register (till) in the store's register directory (v2 parity A4). Platform-neutral: each connector maps its own
|
|
663
|
-
* register model onto it. Money is integer minor units of the store's currency.
|
|
664
|
-
* The cash variance threshold is not here: it is the store's (ADR-082, `capabilities.registerApproval`).
|
|
665
|
-
*/
|
|
666
|
-
interface RegisterInfo {
|
|
667
|
-
/** The platform's register id. */
|
|
668
|
-
id: string;
|
|
669
|
-
/** The register's display name, as the cashier picks it. */
|
|
670
|
-
name: string;
|
|
671
|
-
/** The cash the drawer should open with; absent when the store sets none. */
|
|
672
|
-
defaultFloatMinor?: number;
|
|
673
|
-
/** When the register is due to close: a local store time, `HH:MM` on a 24-hour clock; absent when the store sets none. */
|
|
674
|
-
expectedCloseTime?: string;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* The neutral POS permissions a connector resolves from its own model (v2 parity A12):
|
|
679
|
-
* - `viewReports`: Reports, and a count that shows the expected figures (not blind);
|
|
680
|
-
* - `manageClosures`: recount and close without an approver;
|
|
681
|
-
* - `approveVariance`: approve another cashier's over-threshold count;
|
|
682
|
-
* - `refund`: take refunds;
|
|
683
|
-
* - `discount`: give discounts.
|
|
684
|
-
*/
|
|
685
|
-
declare const CASHIER_PERMISSIONS: readonly ["viewReports", "manageClosures", "approveVariance", "refund", "discount"];
|
|
686
|
-
/** One of `CASHIER_PERMISSIONS`. */
|
|
687
|
-
type CashierPermission = (typeof CASHIER_PERMISSIONS)[number];
|
|
688
|
-
/** The signed-in cashier, as the connector maps the platform's user (v2 parity A12). */
|
|
689
|
-
interface Cashier {
|
|
690
|
-
/** The platform's id for the signed-in user. */
|
|
691
|
-
id: string;
|
|
692
|
-
/** The display name, as receipts and the handover show it. */
|
|
693
|
-
name: string;
|
|
694
|
-
/** What this cashier may do; a permission left out is denied. */
|
|
695
|
-
permissions: readonly CashierPermission[];
|
|
696
|
-
}
|
|
697
|
-
/** Whether `value` is one of the five permission names. */
|
|
698
|
-
declare function isCashierPermission(value: unknown): value is CashierPermission;
|
|
699
|
-
/** The known permission names in `values`, first occurrence order, without duplicates; anything else is dropped. */
|
|
700
|
-
declare function cashierPermissions(values: readonly unknown[]): CashierPermission[];
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* How well a connector's store answers (v2 parity A6, unit 34). The same three states as WCPOS v2's
|
|
704
|
-
* `EngineConnectivity`: `degraded` means the device is online but the store keeps failing.
|
|
705
|
-
*/
|
|
706
|
-
type ConnectivityState = 'online' | 'offline' | 'degraded';
|
|
707
|
-
/**
|
|
708
|
-
* A store's deliberate refusal to sync until someone updates software. `fixedBy` as in `SyncNotice`: `'till'` when
|
|
709
|
-
* this app is older than the store accepts, `'store'` when the store's software is older than the app needs.
|
|
710
|
-
* `reason` is the connector's code for it; `software`, `minVersion` and `status` only when the refusal names them.
|
|
711
|
-
*/
|
|
712
|
-
type UpdateRequired = {
|
|
713
|
-
reason: string;
|
|
714
|
-
fixedBy: 'till' | 'store';
|
|
715
|
-
software?: string;
|
|
716
|
-
minVersion?: string;
|
|
717
|
-
status?: number;
|
|
718
|
-
};
|
|
719
|
-
/** What one failed request says: about connectivity, an update-required refusal, or nothing (`null`). */
|
|
720
|
-
type FailureClass = 'offline' | 'degraded' | {
|
|
721
|
-
updateRequired: UpdateRequired;
|
|
722
|
-
} | null;
|
|
723
|
-
/**
|
|
724
|
-
* For a connector's fetch call site alone: `fetch(url, init).catch(noResponse)`. A fetch that rejects got no response,
|
|
725
|
-
* but its `TypeError` looks like one our own code throws, so the call site tags it: rethrown as a `NoResponseError`
|
|
726
|
-
* with `code: 'network'` (offline to `neutralFailureClass`) and the original as `cause`. An abort or timeout is
|
|
727
|
-
* rethrown unchanged. Code that reads the response runs after the catch, so its errors are never tagged.
|
|
728
|
-
*/
|
|
729
|
-
declare function noResponse(error: unknown): never;
|
|
730
|
-
/**
|
|
731
|
-
* The rule for a connector without `classifyFailure`: a timeout or a 5xx is `degraded`; a request that got no
|
|
732
|
-
* response (`code: 'network'`, as `noResponse` and `CustomerServiceError` set, or a no-response socket code on the
|
|
733
|
-
* error or its `cause`) is `offline`; anything else is `null`, a bare `TypeError` included, since our own code throws
|
|
734
|
-
* those too. It never answers update-required: only a connector knows its own refusal.
|
|
735
|
-
*/
|
|
736
|
-
declare function neutralFailureClass(error: unknown): FailureClass;
|
|
737
|
-
/** The connector's own `classifyFailure` when it has one (its answer is final), else `neutralFailureClass`. A method that throws gives `null`. */
|
|
738
|
-
declare function classifyFailure(connector: Pick<TallyConnector, 'classifyFailure'> | undefined, error: unknown): FailureClass;
|
|
19
|
+
declare function parseDisplayAdvertisement(value: unknown, warn?: (reason: string) => void): DisplayAdvertisement | undefined;
|
|
739
20
|
|
|
740
21
|
/**
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*/
|
|
745
|
-
interface ConnectorAuth {
|
|
746
|
-
/** Human-readable auth type for UI display */
|
|
747
|
-
type: string;
|
|
748
|
-
/** Fields required from the user to authenticate */
|
|
749
|
-
fields: AuthField[];
|
|
750
|
-
/** Build request headers from stored credentials */
|
|
751
|
-
getHeaders: (credentials: Record<string, string>) => Record<string, string>;
|
|
752
|
-
/** Optional: validate that credentials work (e.g., test API call) */
|
|
753
|
-
validate?: (credentials: Record<string, string>) => Promise<boolean>;
|
|
754
|
-
/**
|
|
755
|
-
* Exchanges a user's email and password for a credential (token) to store and pass back to getHeaders as `token`.
|
|
756
|
-
* Rejects with a `SignInError`: `invalid_credentials`, `unsupported` or `failed`.
|
|
757
|
-
*/
|
|
758
|
-
signIn?: (baseUrl: string, login: {
|
|
759
|
-
email: string;
|
|
760
|
-
password: string;
|
|
761
|
-
}, init?: {
|
|
762
|
-
signal?: AbortSignal;
|
|
763
|
-
fetch?: typeof fetch;
|
|
764
|
-
}) => Promise<SignInResult>;
|
|
765
|
-
}
|
|
766
|
-
interface SignInResult {
|
|
767
|
-
token: string;
|
|
768
|
-
/** ISO 8601, when the backend says when the token expires */
|
|
769
|
-
expiresAt?: string;
|
|
770
|
-
/** The store's contract capabilities (ADR-062), when the read was conclusive. */
|
|
771
|
-
capabilities?: ServerCapabilities;
|
|
772
|
-
}
|
|
773
|
-
/** The highest `order.create` contract version a store's server currently accepts (ADR-062). */
|
|
774
|
-
interface ServerCapabilities {
|
|
775
|
-
orderCreate: number;
|
|
776
|
-
/** The highest `register` contract version; absent or 0 means no register sync. */
|
|
777
|
-
register?: number;
|
|
778
|
-
/** The highest `order.refund` version; absent or 0 means the store takes no refunds and the app hides the action (ADR-080). */
|
|
779
|
-
orderRefund?: number;
|
|
780
|
-
/** How the store rounds tax (#287). Absent: an older server, per_order + half_away_from_zero. */
|
|
781
|
-
taxRounding?: TaxRounding;
|
|
782
|
-
/** Whether one order may carry several payments. Absent means it may: order.create's `payments` has always been a
|
|
783
|
-
* list. A WooCommerce store says false until its plugin records the list (`order_payments_list`). The app offers
|
|
784
|
-
* split tender only when this is not false. */
|
|
785
|
-
multiplePayments?: boolean;
|
|
786
|
-
/**
|
|
787
|
-
* What the store accepts for a fee's, a shipping charge's or a custom line's tax (order.create 5, ADR-075):
|
|
788
|
-
* `none` is `taxStatus: 'none'`, `classes` is a `taxClass`. Absent means neither; the UI hides what is false.
|
|
789
|
-
*/
|
|
790
|
-
lineTax?: {
|
|
791
|
-
none: boolean;
|
|
792
|
-
classes: boolean;
|
|
793
|
-
};
|
|
794
|
-
/**
|
|
795
|
-
* Whether the store accepts an order's coupons (ADR-077). Absent means it does not: the till refuses to apply a
|
|
796
|
-
* coupon. WooCommerce: true only when the woocommerce-pos plugin reports 1.9.0 or later.
|
|
797
|
-
*/
|
|
798
|
-
coupons?: boolean;
|
|
799
|
-
/**
|
|
800
|
-
* The store's register approval threshold (ADR-082 d3), from the top level of `/tally/v1/info`. With
|
|
801
|
-
* `register >= 3`, a close whose absolute cash variance is over `thresholdMinor` needs the store's approval.
|
|
802
|
-
* Absent means the store sets none, and the app's own threshold applies.
|
|
803
|
-
*/
|
|
804
|
-
registerApproval?: {
|
|
805
|
-
thresholdMinor: number;
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
/** #287, ADR-071. `custom`: the till computes as when absent; that server never emits `figures_mismatch` for subtotal or tax. */
|
|
809
|
-
type TaxRounding = {
|
|
810
|
-
granularity: 'per_order' | 'per_line_items' | 'per_rate_group_items';
|
|
811
|
-
mode: 'half_away_from_zero' | 'half_up';
|
|
812
|
-
} | {
|
|
813
|
-
granularity: 'woocommerce';
|
|
814
|
-
roundAtSubtotal: boolean;
|
|
815
|
-
} | {
|
|
816
|
-
granularity: 'custom';
|
|
817
|
-
};
|
|
818
|
-
/**
|
|
819
|
-
* Resolves the capabilities to act on: a definitive fresh read always wins,
|
|
820
|
-
* even a downgrade to 1; an inconclusive fresh read (`undefined`) keeps the
|
|
821
|
-
* last known value. The app persists `stored` with its session, the way it
|
|
822
|
-
* persists the store-settings choice, and copies the result into
|
|
823
|
-
* `SyncContext.capabilities`. `finalizeOrder` treats `undefined` as 1, which
|
|
824
|
-
* only happens when the value has never been read (ADR-062).
|
|
825
|
-
*/
|
|
826
|
-
declare function resolveCapabilities(fresh: ServerCapabilities | undefined, stored: ServerCapabilities | undefined): ServerCapabilities | undefined;
|
|
827
|
-
/**
|
|
828
|
-
* Reads the `taxRounding` of `GET /tally/v1/info` (#287): a valid value comes back without
|
|
829
|
-
* extra keys, and `custom` drops any `mode`. Absent gives `undefined`, the default. Core has
|
|
830
|
-
* no logger, so a malformed value gives `undefined` and one reason to `warn` for the caller to log.
|
|
831
|
-
*/
|
|
832
|
-
declare function parseTaxRounding(value: unknown, warn?: (reason: string) => void): TaxRounding | undefined;
|
|
833
|
-
declare function parseLineTax(value: unknown, warn?: (reason: string) => void): {
|
|
834
|
-
none: boolean;
|
|
835
|
-
classes: boolean;
|
|
836
|
-
} | undefined;
|
|
837
|
-
/**
|
|
838
|
-
* Reads a 2xx body of `GET /tally/v1/info` (ADR-062): `orderCreate` is the max of
|
|
839
|
-
* `contracts["order.create"]`, or 1 when it's missing or malformed; `register` is the max of
|
|
840
|
-
* `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287); malformed `lineTax` is ignored.
|
|
841
|
-
* malformed `registerApproval` is ignored (ADR-082).
|
|
842
|
-
* `orderRefund` is the max of `contracts["order.refund"]` when valid, otherwise absent (ADR-080).
|
|
843
|
-
* Absent `taxRounding` uses the default; a present malformed value is unknown, so settings wait.
|
|
844
|
-
* A non-object body is also unknown, not a statement of the store's defaults.
|
|
845
|
-
*/
|
|
846
|
-
declare function parseInfoCapabilities(body: unknown, warn?: (reason: string) => void): ServerCapabilities | undefined;
|
|
847
|
-
interface AuthField {
|
|
848
|
-
key: string;
|
|
849
|
-
label: string;
|
|
850
|
-
type: 'text' | 'password' | 'url';
|
|
851
|
-
placeholder?: string;
|
|
852
|
-
required?: boolean;
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Sync configuration for a collection.
|
|
856
|
-
* Defines how to fetch data from the remote API and push changes back.
|
|
857
|
-
*
|
|
858
|
-
* @deprecated Use ReplicationAdapter instead. This interface will be removed
|
|
859
|
-
* once all connectors have migrated to the RxDB replication protocol.
|
|
860
|
-
*/
|
|
861
|
-
interface CollectionSync<T = any> {
|
|
862
|
-
/** Fetch all remote IDs (for diffing against local) */
|
|
863
|
-
fetchAllIds: (context: SyncContext) => Promise<RemoteIdEntry[]>;
|
|
864
|
-
/** Fetch documents by IDs */
|
|
865
|
-
fetchByIds: (ids: string[], context: SyncContext) => Promise<T[]>;
|
|
866
|
-
/** Fetch documents modified after a given date */
|
|
867
|
-
fetchModifiedAfter?: (date: string, context: SyncContext) => Promise<T[]>;
|
|
868
|
-
/** Push a local change to the remote */
|
|
869
|
-
push?: (doc: T, context: SyncContext) => Promise<T>;
|
|
870
|
-
/** Create a new document on the remote */
|
|
871
|
-
create?: (doc: Partial<T>, context: SyncContext) => Promise<T>;
|
|
872
|
-
/** Delete a document on the remote */
|
|
873
|
-
delete?: (id: string, context: SyncContext) => Promise<void>;
|
|
874
|
-
}
|
|
875
|
-
interface RemoteIdEntry {
|
|
876
|
-
id: string;
|
|
877
|
-
dateModified?: string;
|
|
878
|
-
}
|
|
879
|
-
interface SyncContext {
|
|
880
|
-
/** Unique connector identifier (used as replication namespace) */
|
|
881
|
-
connectorId: string;
|
|
882
|
-
/** Base URL for the API */
|
|
883
|
-
baseUrl: string;
|
|
884
|
-
/** Authenticated headers */
|
|
885
|
-
headers: Record<string, string>;
|
|
886
|
-
/** Optional abort signal */
|
|
887
|
-
signal?: AbortSignal;
|
|
888
|
-
/** From `storeSettings().pricingContext`; opaque to the app; the connector prices documents with it. Never logged. */
|
|
889
|
-
pricingContext?: Record<string, string>;
|
|
890
|
-
/** The store's contract capabilities (ADR-062), copied from the sign-in result. */
|
|
891
|
-
capabilities?: ServerCapabilities;
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* Schema definitions for a connector.
|
|
895
|
-
* Each connector provides its own RxDB schemas that mirror its API shape.
|
|
896
|
-
*
|
|
897
|
-
* Each describes a server-owned, pull-replicated collection (ADR-060), so its
|
|
898
|
-
* versions never transform documents: a version bump drops and resyncs.
|
|
899
|
-
* `createTallyDatabase` drops the old documents, and `startReplication` resets
|
|
900
|
-
* the checkpoint, so the first sync after the bump downloads the collection again.
|
|
901
|
-
*/
|
|
902
|
-
interface ConnectorSchemas {
|
|
903
|
-
products: RxJsonSchema<any>;
|
|
904
|
-
[key: string]: RxJsonSchema<any>;
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* Trait implementations for a connector.
|
|
908
|
-
* These are the accessor functions that components program against.
|
|
909
|
-
*/
|
|
910
|
-
interface ConnectorTraits {
|
|
911
|
-
product: ProductTraits;
|
|
912
|
-
customer?: CustomerTraits;
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* The main connector interface.
|
|
916
|
-
* Each backend (WooCommerce, Medusa, Vendure, etc.) implements this.
|
|
22
|
+
* The key that rate-limits failed claims per source (ADR-085 d4): an IPv4 address (also IPv4-mapped `::ffff:a.b.c.d`)
|
|
23
|
+
* is itself; an IPv6 address counts by its /64, as its first four hextets expanded plus `::/64`, with a zone id
|
|
24
|
+
* dropped. Anything else is the input, trimmed. Pure.
|
|
917
25
|
*/
|
|
918
|
-
|
|
919
|
-
/** Unique identifier for this connector */
|
|
920
|
-
id: string;
|
|
921
|
-
/** Human-readable name */
|
|
922
|
-
name: string;
|
|
923
|
-
/** Description of the backend this connects to */
|
|
924
|
-
description: string;
|
|
925
|
-
/** Icon or logo URL */
|
|
926
|
-
icon?: string;
|
|
927
|
-
/** Authentication configuration */
|
|
928
|
-
auth: ConnectorAuth;
|
|
929
|
-
/** RxDB schemas for each collection */
|
|
930
|
-
schemas: ConnectorSchemas;
|
|
931
|
-
/** Trait implementations — how to extract standard data from connector-specific docs */
|
|
932
|
-
traits: ConnectorTraits;
|
|
933
|
-
/**
|
|
934
|
-
* @deprecated Use `replication` instead.
|
|
935
|
-
* Sync configuration for each collection (legacy pull-based sync).
|
|
936
|
-
*/
|
|
937
|
-
sync: {
|
|
938
|
-
products: CollectionSync;
|
|
939
|
-
[key: string]: CollectionSync;
|
|
940
|
-
};
|
|
941
|
-
/** Replication adapters for each collection (RxDB replication protocol) */
|
|
942
|
-
replication?: {
|
|
943
|
-
products?: ReplicationAdapter<any>;
|
|
944
|
-
[key: string]: ReplicationAdapter<any> | undefined;
|
|
945
|
-
};
|
|
946
|
-
/** Periodic re-reads of state that replication misses (ADR-060) */
|
|
947
|
-
reconcile?: {
|
|
948
|
-
stock?: StockReconcileAdapter;
|
|
949
|
-
ids?: IdReconcileAdapter;
|
|
950
|
-
prices?: FingerprintReconcileAdapter;
|
|
951
|
-
/** Prices the backend calculates for the sales context (price lists, sale dates), which change without a timestamp bump. */
|
|
952
|
-
calculatedPrices?: FingerprintReconcileAdapter;
|
|
953
|
-
/** The daily catalogue check (#248): refetches what differs, deletes only with proof. */
|
|
954
|
-
catalogue?: CatalogueReconcileAdapter;
|
|
955
|
-
/**
|
|
956
|
-
* The coupons' only source (ADR-077 amendment 2): a catalogue reconcile over the coupon listing, whose
|
|
957
|
-
* fingerprint carries the usage that never moves the modified time. Optional: a connector without it has no
|
|
958
|
-
* coupons, and the coupons feature is gated on it.
|
|
959
|
-
*/
|
|
960
|
-
coupons?: CatalogueReconcileAdapter;
|
|
961
|
-
};
|
|
962
|
-
/**
|
|
963
|
-
* Reads the store's own settings (TV4): currency, tax inclusivity, tax
|
|
964
|
-
* rates and a connector-specific pricing context. Read once after
|
|
965
|
-
* sign-in; the app feeds all three consumers from the result. Read-only,
|
|
966
|
-
* never writes to the store (ADR-048).
|
|
967
|
-
*/
|
|
968
|
-
storeSettings?: (context: SyncContext, choice?: StoreSettingsChoice) => Promise<StoreSettings>;
|
|
969
|
-
/**
|
|
970
|
-
* Re-reads the store's contract capabilities (ADR-062) for a session
|
|
971
|
-
* restored without signing in again — otherwise a restored session would
|
|
972
|
-
* block discounts until the cashier signed in again. `undefined` means
|
|
973
|
-
* the read was inconclusive (offline or a server error), not version 1;
|
|
974
|
-
* see `resolveCapabilities`.
|
|
975
|
-
* It may throw when the store refuses the read. Medusa throws `SignInError` (`invalid_credentials`) for a 401; its
|
|
976
|
-
* 403 gives `undefined`. Vendure throws `ConnectorUnauthorizedError` only once its sign-in probe settles the
|
|
977
|
-
* cause: `status: 401` when the session is signed out, `status: 403` when a signed-in administrator lacks the
|
|
978
|
-
* CreateOrder permission; a probe that fails gives `undefined`. Branch on the error's `code` (only
|
|
979
|
-
* `unauthorized` or `invalid_credentials` means sign in again), never on its class.
|
|
980
|
-
*/
|
|
981
|
-
capabilities?: (context: SyncContext) => Promise<ServerCapabilities | undefined>;
|
|
982
|
-
/**
|
|
983
|
-
* The payment methods the till may offer, in the order it shows them (v2 parity A2). Read-only, never writes to
|
|
984
|
-
* the store. `undefined` when the connector has none of its own: the till offers `defaultPaymentMethods()`.
|
|
985
|
-
*/
|
|
986
|
-
paymentMethods?: (context: SyncContext) => Promise<PaymentMethodDescriptor[]>;
|
|
987
|
-
/**
|
|
988
|
-
* Customer search: online only. An empty or whitespace query may list a first page of the store's customers
|
|
989
|
-
* (recent ones, or in the store's own picker order); a connector that cannot list them returns `[]`.
|
|
990
|
-
* `undefined` when the connector has no customer support.
|
|
991
|
-
*/
|
|
992
|
-
searchCustomers?: (context: SyncContext, query: string, options?: {
|
|
993
|
-
limit?: number;
|
|
994
|
-
}) => Promise<Customer[]>;
|
|
995
|
-
/** Customer creation: online only; `undefined` when the connector has no customer support. */
|
|
996
|
-
createCustomer?: (context: SyncContext, input: CustomerInput) => Promise<Customer>;
|
|
997
|
-
/**
|
|
998
|
-
* Customer edit: online only; resolves the customer as the store now has it. Rejects with
|
|
999
|
-
* `ConnectorUnauthorizedError` for credentials and `CustomerServiceError` (`invalid` for a refused patch or an id
|
|
1000
|
-
* the store does not have, `server` or `network` otherwise). `undefined` when the connector can't edit customers.
|
|
1001
|
-
*/
|
|
1002
|
-
updateCustomer?: (context: SyncContext, id: string, patch: CustomerPatch) => Promise<Customer>;
|
|
1003
|
-
/** Customer lookup: online only; `undefined` when the connector has no customer support. */
|
|
1004
|
-
getCustomer?: (context: SyncContext, id: string) => Promise<Customer | null>;
|
|
1005
|
-
/**
|
|
1006
|
-
* Emails the receipt of an order the store already has: online only, and **not idempotent** (each call sends one
|
|
1007
|
-
* email, so an app never retries it on its own after a timeout). `orderId` is the store's id from the order-create
|
|
1008
|
-
* result (`serverRefs.orderId`). `options.saveToBilling` also stores the address on the order's billing email where
|
|
1009
|
-
* the platform supports it. Rejects with `ConnectorUnauthorizedError` for credentials and `CustomerServiceError`
|
|
1010
|
-
* (`invalid` for a refused order or address, `server` or `network` otherwise). `undefined` when the connector can't
|
|
1011
|
-
* email receipts.
|
|
1012
|
-
*/
|
|
1013
|
-
emailReceipt?: (context: SyncContext, orderId: string, email: string, options?: {
|
|
1014
|
-
saveToBilling?: boolean;
|
|
1015
|
-
}) => Promise<void>;
|
|
1016
|
-
/**
|
|
1017
|
-
* The store's orders, newest first, one page per call (ADR-081): online only, read-only. Rejects as `emailReceipt`
|
|
1018
|
-
* does (`ConnectorUnauthorizedError` for credentials; a connector's own errors otherwise, e.g. `CustomerServiceError`).
|
|
1019
|
-
* `undefined` when the connector has no order history.
|
|
1020
|
-
*/
|
|
1021
|
-
listOrders?: (context: SyncContext, query?: ListOrdersQuery) => Promise<StoreOrderPage>;
|
|
1022
|
-
/**
|
|
1023
|
-
* The given orders by store id (ADR-081), in the order asked; an id the store does not have is left out. Online only,
|
|
1024
|
-
* read-only; rejects as `listOrders`. `undefined` when the connector has no order history.
|
|
1025
|
-
*/
|
|
1026
|
-
getOrders?: (context: SyncContext, ids: readonly string[]) => Promise<StoreOrder[]>;
|
|
1027
|
-
/**
|
|
1028
|
-
* The store's register directory (v2 parity A4): online only, read-only. Rejects with `ConnectorUnauthorizedError`
|
|
1029
|
-
* for credentials; a connector's own errors otherwise. `undefined` when the connector has no register directory.
|
|
1030
|
-
*/
|
|
1031
|
-
listRegisters?: (context: SyncContext) => Promise<RegisterInfo[]>;
|
|
1032
|
-
/**
|
|
1033
|
-
* The signed-in cashier and their neutral POS permissions (v2 parity A12), mapped from the platform's own roles or
|
|
1034
|
-
* capabilities. Read-only. `null` when the connector has no cashier to describe; `undefined` (no method) when the
|
|
1035
|
-
* connector has no permission model: the till then allows everything, as before (`can` in `@tallyui/pos`).
|
|
1036
|
-
* Permission names outside `CashierPermission` are dropped by `useCashier` (`cashierPermissions`).
|
|
1037
|
-
*/
|
|
1038
|
-
cashier?: (context: SyncContext) => Promise<Cashier | null>;
|
|
1039
|
-
/**
|
|
1040
|
-
* Maps one of this connector's request failures (pull, push, reconcile, online calls) to a connectivity verdict or
|
|
1041
|
-
* its own update-required refusal (v2 parity A6). Synchronous and pure. `null` when the failure says nothing about
|
|
1042
|
-
* connectivity (a validation refusal). `undefined` (no method) uses `neutralFailureClass`, which a connector's own
|
|
1043
|
-
* method may also call for the failures it does not map.
|
|
1044
|
-
*/
|
|
1045
|
-
classifyFailure?: (error: unknown) => FailureClass;
|
|
1046
|
-
}
|
|
26
|
+
declare function rateLimitSource(address: string): string;
|
|
1047
27
|
|
|
1048
28
|
/**
|
|
1049
29
|
* Why `ConnectorAuth.signIn` failed:
|
|
@@ -1133,6 +113,28 @@ declare class StoreSettingsError extends Error {
|
|
|
1133
113
|
constructor(code: StoreSettingsErrorCode, message: string, choices?: StoreSettingsChoices);
|
|
1134
114
|
}
|
|
1135
115
|
|
|
116
|
+
/** Every ListOrdersQuery filter field, in the order refusals name them. */
|
|
117
|
+
declare const ORDER_FILTER_FIELDS: readonly OrderFilterField[];
|
|
118
|
+
/** listOrders was asked to filter by fields the connector does not support (`TallyConnector.orderFilters`). */
|
|
119
|
+
declare class UnsupportedOrderFilterError extends Error {
|
|
120
|
+
readonly code = "unsupported_order_filter";
|
|
121
|
+
readonly fields: OrderFilterField[];
|
|
122
|
+
constructor(fields: OrderFilterField[]);
|
|
123
|
+
}
|
|
124
|
+
/** The filter fields a query sets (a field counts when its value is not undefined; dateRange counts when after or before is set). */
|
|
125
|
+
declare function orderFilterFields(query: ListOrdersQuery | undefined): OrderFilterField[];
|
|
126
|
+
/**
|
|
127
|
+
* Throws UnsupportedOrderFilterError naming every set field not in `supported`, in OrderFilterField order. A connector
|
|
128
|
+
* calls this first in listOrders. An empty string is a set value, so it is refused too. When `dateRange` is set and
|
|
129
|
+
* supported, it is checked with `assertOrderDateRange`.
|
|
130
|
+
*/
|
|
131
|
+
declare function assertOrderFiltersSupported(query: ListOrdersQuery | undefined, supported: readonly OrderFilterField[] | undefined): void;
|
|
132
|
+
/**
|
|
133
|
+
* Throws a TypeError for a dateRange end that is not an ISO UTC instant ending in Z, or after > before. `after` equal
|
|
134
|
+
* to `before` passes: an empty range is the caller's business.
|
|
135
|
+
*/
|
|
136
|
+
declare function assertOrderDateRange(range: ListOrdersQuery['dateRange']): void;
|
|
137
|
+
|
|
1136
138
|
/** Number of minor-unit digits for an ISO 4217 code (2 for EUR, 0 for JPY). */
|
|
1137
139
|
declare function minorUnitDigits(currency: string): number;
|
|
1138
140
|
/** The currency's symbol for a plain-English label ('€' for EUR, '$' for USD), not a full amount. */
|
|
@@ -1349,49 +351,6 @@ declare function useStockOverlayAsOf(): string | undefined;
|
|
|
1349
351
|
*/
|
|
1350
352
|
declare function useCustomerTraits(): CustomerTraits<any> | undefined;
|
|
1351
353
|
|
|
1352
|
-
interface WooTaxRate {
|
|
1353
|
-
id: number;
|
|
1354
|
-
country: string;
|
|
1355
|
-
state: string;
|
|
1356
|
-
postcode: string;
|
|
1357
|
-
city: string;
|
|
1358
|
-
postcodes: string[];
|
|
1359
|
-
cities: string[];
|
|
1360
|
-
rate: string;
|
|
1361
|
-
name: string;
|
|
1362
|
-
priority: number;
|
|
1363
|
-
compound: boolean;
|
|
1364
|
-
shipping: boolean;
|
|
1365
|
-
order: number;
|
|
1366
|
-
class: string;
|
|
1367
|
-
}
|
|
1368
|
-
interface CalculateTaxesInput {
|
|
1369
|
-
amount: number;
|
|
1370
|
-
rates: {
|
|
1371
|
-
id: number;
|
|
1372
|
-
rate: string;
|
|
1373
|
-
compound: boolean;
|
|
1374
|
-
order: number;
|
|
1375
|
-
priority?: number;
|
|
1376
|
-
[key: string]: any;
|
|
1377
|
-
}[];
|
|
1378
|
-
amountIncludesTax: boolean;
|
|
1379
|
-
dp?: number;
|
|
1380
|
-
perRatePrecision?: number;
|
|
1381
|
-
}
|
|
1382
|
-
type ItemizedTax = {
|
|
1383
|
-
id: number;
|
|
1384
|
-
total: number;
|
|
1385
|
-
[key: string]: any;
|
|
1386
|
-
};
|
|
1387
|
-
interface CalculateTaxesResult {
|
|
1388
|
-
total: number;
|
|
1389
|
-
taxes: {
|
|
1390
|
-
id: number;
|
|
1391
|
-
total: number;
|
|
1392
|
-
}[];
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
354
|
/**
|
|
1396
355
|
* Takes a price and an array of tax rates, eg: [{ id: 1, rate: '4.0000', order: 1 }]
|
|
1397
356
|
* Returns the calculated array of taxes tax, eg: [{ id: 1, total: 1.2345 }]
|
|
@@ -1534,17 +493,24 @@ declare function resolveInheritedShippingTaxClass(activeLineItems: readonly {
|
|
|
1534
493
|
declare function taxClassFromWire(value?: string | null): string;
|
|
1535
494
|
declare function taxClassToWire(value?: string | null): string;
|
|
1536
495
|
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
496
|
+
declare const index$1_CalculateTaxesInput: typeof CalculateTaxesInput;
|
|
497
|
+
declare const index$1_CalculateTaxesResult: typeof CalculateTaxesResult;
|
|
498
|
+
declare const index$1_ItemizedTax: typeof ItemizedTax;
|
|
1540
499
|
declare const index$1_NO_SHIPPING_TAX: typeof NO_SHIPPING_TAX;
|
|
500
|
+
declare const index$1_ResolvedTaxLocation: typeof ResolvedTaxLocation;
|
|
1541
501
|
declare const index$1_STANDARD_TAX_CLASS: typeof STANDARD_TAX_CLASS;
|
|
1542
|
-
|
|
502
|
+
declare const index$1_TAX_BASED_ON_META_KEY: typeof TAX_BASED_ON_META_KEY;
|
|
503
|
+
declare const index$1_TaxAddress: typeof TaxAddress;
|
|
504
|
+
declare const index$1_TaxBasedOn: typeof TaxBasedOn;
|
|
505
|
+
declare const index$1_TaxLocationOrder: typeof TaxLocationOrder;
|
|
506
|
+
declare const index$1_WooTaxRate: typeof WooTaxRate;
|
|
1543
507
|
declare const index$1_addNumberPrecision: typeof addNumberPrecision;
|
|
1544
508
|
declare const index$1_calculateTaxes: typeof calculateTaxes;
|
|
1545
509
|
declare const index$1_filterTaxRates: typeof filterTaxRates;
|
|
1546
510
|
declare const index$1_getRoundingPrecision: typeof getRoundingPrecision;
|
|
511
|
+
declare const index$1_normalizeTaxBasedOn: typeof normalizeTaxBasedOn;
|
|
1547
512
|
declare const index$1_normalizeTaxClass: typeof normalizeTaxClass;
|
|
513
|
+
declare const index$1_orderTaxLocation: typeof orderTaxLocation;
|
|
1548
514
|
declare const index$1_removeNumberPrecision: typeof removeNumberPrecision;
|
|
1549
515
|
declare const index$1_resolveInheritedShippingTaxClass: typeof resolveInheritedShippingTaxClass;
|
|
1550
516
|
declare const index$1_roundHalfDown: typeof roundHalfDown;
|
|
@@ -1555,7 +521,7 @@ declare const index$1_sumTaxes: typeof sumTaxes;
|
|
|
1555
521
|
declare const index$1_taxClassFromWire: typeof taxClassFromWire;
|
|
1556
522
|
declare const index$1_taxClassToWire: typeof taxClassToWire;
|
|
1557
523
|
declare namespace index$1 {
|
|
1558
|
-
export {
|
|
524
|
+
export { index$1_CalculateTaxesInput as CalculateTaxesInput, index$1_CalculateTaxesResult as CalculateTaxesResult, index$1_ItemizedTax as ItemizedTax, index$1_NO_SHIPPING_TAX as NO_SHIPPING_TAX, index$1_ResolvedTaxLocation as ResolvedTaxLocation, index$1_STANDARD_TAX_CLASS as STANDARD_TAX_CLASS, index$1_TAX_BASED_ON_META_KEY as TAX_BASED_ON_META_KEY, index$1_TaxAddress as TaxAddress, index$1_TaxBasedOn as TaxBasedOn, index$1_TaxLocationOrder as TaxLocationOrder, index$1_WooTaxRate as WooTaxRate, index$1_addNumberPrecision as addNumberPrecision, index$1_calculateTaxes as calculateTaxes, index$1_filterTaxRates as filterTaxRates, index$1_getRoundingPrecision as getRoundingPrecision, index$1_normalizeTaxBasedOn as normalizeTaxBasedOn, index$1_normalizeTaxClass as normalizeTaxClass, index$1_orderTaxLocation as orderTaxLocation, index$1_removeNumberPrecision as removeNumberPrecision, index$1_resolveInheritedShippingTaxClass as resolveInheritedShippingTaxClass, index$1_roundHalfDown as roundHalfDown, index$1_roundHalfUp as roundHalfUp, index$1_roundTaxTotal as roundTaxTotal, index$1_sumItemizedTaxes as sumItemizedTaxes, index$1_sumTaxes as sumTaxes, index$1_taxClassFromWire as taxClassFromWire, index$1_taxClassToWire as taxClassToWire };
|
|
1559
525
|
}
|
|
1560
526
|
|
|
1561
527
|
interface CouponLineItem {
|
|
@@ -1909,4 +875,4 @@ declare namespace index {
|
|
|
1909
875
|
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 };
|
|
1910
876
|
}
|
|
1911
877
|
|
|
1912
|
-
export {
|
|
878
|
+
export { CommandWarning, ConnectorProvider, type ConnectorProviderProps, ConnectorUnauthorizedError, CustomerTraits, DEFAULT_ICE_SERVERS, DisplayAdvertisement, type ErrorKind, IceServer, type KeyedReconcileFeedOptions, ListOrdersQuery, Money, ORDER_FILTER_FIELDS, OrderFilterField, ProductPrice, ProductTraits, type ReconcileFeed, type ReconcileFeedEntry, type ReconcileFetchEntry, ReplicationAdapter, ResolvedPrice, STOCK_LEVELS_LAST_PASS, SignInError, type SignInErrorCode, StockLevel, StockReconcileAdapter, type StoreSettingsChoices, StoreSettingsError, type StoreSettingsErrorCode, SyncContext, type SyncNotice, TallyConnector, TraitContext, UnsupportedOrderFilterError, VariantSummary, assertOrderDateRange, assertOrderFiltersSupported, combinePullAdapters, compareIds, createReconcileFeed, currencySymbol, errorKind, findVariantByCode, formatMoney, getProductStock, isRxdbRemoteVersionMismatch, knownWarnings, minorUnitDigits, moneyFromDecimalString, moneyFromMajor, moneyToMajor, orderFilterFields, parseDisplayAdvertisement, rateLimitSource, resolvePrice, resolvePriceRange, useConnector, useCustomerTraits, useProductStock, useProductTraits, useStockOverlaid, useStockOverlayAsOf, useTraitContext, withStockOverlay, index as woocommerceCoupons, index$1 as woocommerceTax };
|