@tallyui/core 3.11.0 → 3.12.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.
@@ -338,6 +338,8 @@ interface OrderCreateLine {
338
338
  regularUnitPriceMinor?: number;
339
339
  /** Version 6 recorded: the variant's attribute names and values (#495), each at most 255 characters. */
340
340
  attributes?: Record<string, string>;
341
+ /** Version 6: the names in attributes the cashier picked for the variant's "Any" option groups (#495 c/d). */
342
+ anyAttributes?: string[];
341
343
  /**
342
344
  * This line's own tax mode, when it differs from the order's `pricesIncludeTax`
343
345
  * (a price that carries its own flag, D2c). Absent means the order's flag, so
@@ -522,4 +524,4 @@ declare class CommandResultError extends Error {
522
524
  * CommandResultError naming the first bad field. */
523
525
  declare function parseCommandResult(value: unknown): CommandResult;
524
526
 
525
- export { type AnyCommandEnvelope as A, type BatchTooLargeBody as B, type CommandWarning as C, type OrderRefundResult as D, PROTOCOL_VERSION as E, type PaymentMethodKind as F, type RegisterCommandEnvelope as G, type RegisterCommandResult as H, type RegisterCommandType as I, type RegisterMovementRecordPayload as J, type RegisterMovementVoidPayload as K, type RegisterSessionAlreadyOpenData as L, MAX_COMMANDS_PER_BATCH as M, type RegisterSessionOpenPayload as N, type OrderCreateCoupon as O, PROTOCOL_HEADER as P, type RegisterSessionSupersededData as Q, type RegisterClosureSubmitPayload as R, type RegisterSessionTransitionPayload as S, isCommandBatchResponse as T, parseCommandResult as U, 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 OrderCreateCouponInvalidData as k, type OrderCreateDisplay as l, type OrderCreateEnvelope as m, type OrderCreateLine as n, type OrderCreatePayload as o, type OrderCreatePayment as p, type OrderCreateTaxRate as q, type OrderCreateTotalMismatchData as r, type OrderRefundAmountMismatchData as s, type OrderRefundEnvelope as t, type OrderRefundLine as u, type OrderRefundNoOpenSessionData as v, type OrderRefundOrderStateData as w, type OrderRefundPayload as x, type OrderRefundQuantityExceedsData as y, type OrderRefundRejectionCode as z };
527
+ export { type AnyCommandEnvelope as A, type BatchTooLargeBody as B, type CommandWarning as C, type OrderRefundResult as D, PROTOCOL_HEADER as E, PROTOCOL_VERSION as F, type RegisterCommandEnvelope as G, type RegisterCommandResult as H, type RegisterCommandType as I, type RegisterMovementRecordPayload as J, type RegisterMovementVoidPayload as K, type RegisterSessionAlreadyOpenData as L, MAX_COMMANDS_PER_BATCH as M, type RegisterSessionOpenPayload as N, type OrderCreateCoupon as O, type PaymentMethodKind as P, type RegisterSessionSupersededData as Q, type RegisterClosureSubmitPayload as R, type RegisterSessionTransitionPayload as S, isCommandBatchResponse as T, parseCommandResult as U, 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 OrderCreateCouponInvalidData as k, type OrderCreateDisplay as l, type OrderCreateEnvelope as m, type OrderCreateLine as n, type OrderCreatePayload as o, type OrderCreatePayment as p, type OrderCreateTaxRate as q, type OrderCreateTotalMismatchData as r, type OrderRefundAmountMismatchData as s, type OrderRefundEnvelope as t, type OrderRefundLine as u, type OrderRefundNoOpenSessionData as v, type OrderRefundOrderStateData as w, type OrderRefundPayload as x, type OrderRefundQuantityExceedsData as y, type OrderRefundRejectionCode 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 { C as CommandWarning } from './command-result-DmHIPt6Z.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 OrderCreateCoupon, k as OrderCreateCouponInvalidData, l as OrderCreateDisplay, m as OrderCreateEnvelope, n as OrderCreateLine, o as OrderCreatePayload, p as OrderCreatePayment, q as OrderCreateTaxRate, r as OrderCreateTotalMismatchData, s as OrderRefundAmountMismatchData, t as OrderRefundEnvelope, u as OrderRefundLine, v as OrderRefundNoOpenSessionData, w as OrderRefundOrderStateData, x as OrderRefundPayload, y as OrderRefundQuantityExceedsData, z as OrderRefundRejectionCode, D as OrderRefundResult, P as PROTOCOL_HEADER, E as PROTOCOL_VERSION, F as PaymentMethodKind, R as RegisterClosureSubmitPayload, G as RegisterCommandEnvelope, H as RegisterCommandResult, I as RegisterCommandType, J as RegisterMovementRecordPayload, K as RegisterMovementVoidPayload, L as RegisterSessionAlreadyOpenData, N as RegisterSessionOpenPayload, Q as RegisterSessionSupersededData, S as RegisterSessionTransitionPayload, T as isCommandBatchResponse, U as parseCommandResult } from './command-result-DmHIPt6Z.js';
3
+ import { P as PaymentMethodKind, C as CommandWarning } from './command-result-CrM7yjwk.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 OrderCreateCoupon, k as OrderCreateCouponInvalidData, l as OrderCreateDisplay, m as OrderCreateEnvelope, n as OrderCreateLine, o as OrderCreatePayload, p as OrderCreatePayment, q as OrderCreateTaxRate, r as OrderCreateTotalMismatchData, s as OrderRefundAmountMismatchData, t as OrderRefundEnvelope, u as OrderRefundLine, v as OrderRefundNoOpenSessionData, w as OrderRefundOrderStateData, x as OrderRefundPayload, y as OrderRefundQuantityExceedsData, z as OrderRefundRejectionCode, D as OrderRefundResult, E as PROTOCOL_HEADER, F as PROTOCOL_VERSION, R as RegisterClosureSubmitPayload, G as RegisterCommandEnvelope, H as RegisterCommandResult, I as RegisterCommandType, J as RegisterMovementRecordPayload, K as RegisterMovementVoidPayload, L as RegisterSessionAlreadyOpenData, N as RegisterSessionOpenPayload, Q as RegisterSessionSupersededData, S as RegisterSessionTransitionPayload, T as isCommandBatchResponse, U as parseCommandResult } from './command-result-CrM7yjwk.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ReactNode } from 'react';
7
7
 
@@ -426,6 +426,104 @@ declare class CustomerServiceError extends Error {
426
426
  constructor(code: 'network' | 'server' | 'invalid', message: string);
427
427
  }
428
428
 
429
+ /** A line of an order the store holds (ADR-081). Money in integer minor units of the order's currency, as the store
430
+ * records it: every amount excludes tax, and the tax is beside it.
431
+ * Each tax field is such that net + tax is the gross rounded once. */
432
+ interface StoreOrderLine {
433
+ /** The store's line id: what `OrderRefundLine.orderLineId` names. */
434
+ id: string;
435
+ /** The till's line id when a till created the line (its `clientLineId`); absent otherwise. */
436
+ clientLineId?: string;
437
+ productId?: string;
438
+ /** The sellable the till's `variantId` names (a WooCommerce variation, or the product itself when simple). */
439
+ variantId?: string;
440
+ name: string;
441
+ sku?: string;
442
+ quantity: number;
443
+ /** Before discounts, excluding tax. */
444
+ subtotalMinor: number;
445
+ subtotalTaxMinor: number;
446
+ /** After discounts, excluding tax. */
447
+ totalMinor: number;
448
+ taxMinor: number;
449
+ }
450
+ /** A fee or shipping line: excluding tax, the tax beside it. A fee may be negative.
451
+ * `taxMinor` is such that `totalMinor + taxMinor` is the gross rounded once. */
452
+ interface StoreOrderCharge {
453
+ name: string;
454
+ totalMinor: number;
455
+ taxMinor: number;
456
+ }
457
+ interface StoreOrderPayment {
458
+ /** The store's own method id, e.g. WooCommerce's `pos_cash`. */
459
+ method: string;
460
+ /** The store's name for it, e.g. "Cash". */
461
+ title?: string;
462
+ /** Set only when the method is one the till itself takes. */
463
+ kind?: PaymentMethodKind;
464
+ amountMinor: number;
465
+ }
466
+ /** A refund the store already recorded against the order. */
467
+ interface StoreOrderRefund {
468
+ id: string; /** Positive. */
469
+ amountMinor: number;
470
+ reason?: string;
471
+ }
472
+ /** An order as the store holds it, read online (ADR-081); never stored by the till. */
473
+ interface StoreOrder {
474
+ /** The store's order id: what `OrderRefundPayload.orderId` and `CommandServerRefs.orderId` carry. */
475
+ id: string;
476
+ /** The number the store shows (`CommandServerRefs.displayId`). */
477
+ reference: string;
478
+ /** The till's `PosOrder.id` when a till created the order; absent otherwise. */
479
+ clientOrderId?: string;
480
+ /** The platform's own status word (WooCommerce: `completed`, `refunded`, …); the app labels it. */
481
+ status: string;
482
+ /** ISO 8601, UTC. */
483
+ placedAt: string;
484
+ currency: string;
485
+ pricesIncludeTax: boolean;
486
+ customer: {
487
+ id?: string;
488
+ name?: string;
489
+ email?: string;
490
+ } | null;
491
+ lines: StoreOrderLine[];
492
+ fees: StoreOrderCharge[];
493
+ shipping: StoreOrderCharge[];
494
+ /** `discountMinor + discountTaxMinor` is the coupon's gross discount rounded once. */
495
+ coupons: Array<{
496
+ code: string;
497
+ discountMinor: number;
498
+ discountTaxMinor: number;
499
+ }>;
500
+ /** Tax by rate; `amountMinor` includes the rate's shipping tax. */
501
+ taxLines: Array<{
502
+ label: string;
503
+ code?: string;
504
+ ratePpm: number;
505
+ amountMinor: number;
506
+ }>;
507
+ discountMinor: number;
508
+ discountTaxMinor: number;
509
+ taxMinor: number;
510
+ totalMinor: number;
511
+ payments: StoreOrderPayment[];
512
+ refunds: StoreOrderRefund[];
513
+ }
514
+ interface ListOrdersQuery {
515
+ /** 1-based; default 1. */
516
+ page?: number;
517
+ /** 1..100; default 25. */
518
+ perPage?: number;
519
+ /** The platform's own order search. */
520
+ search?: string;
521
+ }
522
+ interface StoreOrderPage {
523
+ orders: StoreOrder[];
524
+ hasMore: boolean;
525
+ }
526
+
429
527
  /**
430
528
  * Authentication configuration for a connector.
431
529
  * Each API has wildly different auth — JWT, API keys, OAuth, etc.
@@ -678,6 +776,17 @@ interface TallyConnector {
678
776
  emailReceipt?: (context: SyncContext, orderId: string, email: string, options?: {
679
777
  saveToBilling?: boolean;
680
778
  }) => Promise<void>;
779
+ /**
780
+ * The store's orders, newest first, one page per call (ADR-081): online only, read-only. Rejects as `emailReceipt`
781
+ * does (`ConnectorUnauthorizedError` for credentials; a connector's own errors otherwise, e.g. `CustomerServiceError`).
782
+ * `undefined` when the connector has no order history.
783
+ */
784
+ listOrders?: (context: SyncContext, query?: ListOrdersQuery) => Promise<StoreOrderPage>;
785
+ /**
786
+ * The given orders by store id (ADR-081), in the order asked; an id the store does not have is left out. Online only,
787
+ * read-only; rejects as `listOrders`. `undefined` when the connector has no order history.
788
+ */
789
+ getOrders?: (context: SyncContext, ids: readonly string[]) => Promise<StoreOrder[]>;
681
790
  }
682
791
 
683
792
  /**
@@ -1544,4 +1653,4 @@ declare namespace index {
1544
1653
  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 };
1545
1654
  }
1546
1655
 
1547
- 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 Money, 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 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 };
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 };
@@ -1,5 +1,5 @@
1
- import { e as CommandError, o as OrderCreatePayload, d as CommandEnvelope, G as RegisterCommandEnvelope, A as AnyCommandEnvelope, f as CommandResult, B as BatchTooLargeBody, c as CommandBatchResponse, C as CommandWarning, H as RegisterCommandResult, z as OrderRefundRejectionCode } from '../command-result-DmHIPt6Z.js';
2
- export { g as CommandResultError, M as MAX_COMMANDS_PER_BATCH, l as OrderCreateDisplay, q as OrderCreateTaxRate, U as parseCommandResult } from '../command-result-DmHIPt6Z.js';
1
+ import { e as CommandError, o as OrderCreatePayload, d as CommandEnvelope, G as RegisterCommandEnvelope, A as AnyCommandEnvelope, f as CommandResult, B as BatchTooLargeBody, c as CommandBatchResponse, C as CommandWarning, H as RegisterCommandResult, z as OrderRefundRejectionCode } from '../command-result-CrM7yjwk.js';
2
+ export { g as CommandResultError, M as MAX_COMMANDS_PER_BATCH, l as OrderCreateDisplay, q as OrderCreateTaxRate, U as parseCommandResult } from '../command-result-CrM7yjwk.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;
@@ -177,6 +177,19 @@ function payloadShapeErrors(payload) {
177
177
  check(object(line.attributes), `${path}.attributes`, "an object");
178
178
  if (object(line.attributes)) for (const [key, value] of Object.entries(line.attributes)) check(typeof value === "string", `${path}.attributes.${key}`, "a string");
179
179
  }
180
+ const { anyAttributes: names, attributes } = line;
181
+ if (names !== void 0) check(Array.isArray(names), `${path}.anyAttributes`, "an array");
182
+ if (Array.isArray(names)) names.forEach((name, index2) => {
183
+ const at = `${path}.anyAttributes[${index2}]`;
184
+ check(typeof name === "string" && name.length > 0, at, "a non-empty string");
185
+ if (typeof name !== "string" || !name) return;
186
+ check(names.indexOf(name) === index2, at, "no duplicate name");
187
+ check(
188
+ object(attributes) && Object.hasOwn(attributes, name) && typeof attributes[name] === "string" && attributes[name].length > 0,
189
+ at,
190
+ `a key of ${path}.attributes with a non-empty value`
191
+ );
192
+ });
180
193
  });
181
194
  for (const [value, path] of payloadStrings(payload)) check(!value.includes("\0"), path, "no NUL character");
182
195
  return errors;
@@ -222,6 +235,7 @@ function payloadStrings(payload) {
222
235
  if (object(line) && object(line.attributes)) for (const [key, value] of Object.entries(line.attributes)) {
223
236
  found.push([key, `lines[${index}].attributes`, 255], [value, `lines[${index}].attributes.${key}`, 255]);
224
237
  }
238
+ if (object(line) && Array.isArray(line.anyAttributes)) line.anyAttributes.forEach((name, i) => found.push([name, `lines[${index}].anyAttributes[${i}]`, 255]));
225
239
  });
226
240
  if (object(payload.customer)) found.push([payload.customer.email, "customer.email", 254], [payload.customer.customerId, "customer.customerId", void 0]);
227
241
  found.push([payload.sessionId, "sessionId", void 0]);
@@ -420,7 +434,7 @@ function precheckCommand(envelope, supported) {
420
434
  const v6Fields = payload.coupons !== void 0 ? ["coupons"] : [];
421
435
  if (display?.coupons !== void 0) v6Fields.push("display.coupons");
422
436
  if (Array.isArray(lines)) lines.forEach((line, index) => {
423
- for (const field of ["regularUnitPriceMinor", "attributes"]) {
437
+ for (const field of ["regularUnitPriceMinor", "attributes", "anyAttributes"]) {
424
438
  if (line?.[field] !== void 0) v6Fields.push(`lines[${index}].${field}`);
425
439
  }
426
440
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/core",
3
- "version": "3.11.0",
3
+ "version": "3.12.0",
4
4
  "type": "module",
5
5
  "description": "Core interfaces, traits, and context providers for Tally UI",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -36,6 +36,9 @@ export { errorKind, type ErrorKind, type SyncNotice } from './sync-notice';
36
36
  export type { SignInErrorCode } from './sign-in';
37
37
  export { StoreSettingsError } from './store-settings';
38
38
  export { customerTraits, CustomerServiceError, type Customer, type CustomerInput } from './types/customers';
39
+ export type {
40
+ StoreOrder, StoreOrderLine, StoreOrderCharge, StoreOrderPayment, StoreOrderRefund, ListOrdersQuery, StoreOrderPage,
41
+ } from './types/orders';
39
42
  export type { StoreSettingsErrorCode, StoreSettingsChoices } from './store-settings';
40
43
 
41
44
  export type {
@@ -108,7 +108,7 @@ export function precheckCommand(envelope: Pick<AnyCommandEnvelope | ValidatedCom
108
108
  const v6Fields = payload.coupons !== undefined ? ['coupons'] : []
109
109
  if (display?.coupons !== undefined) v6Fields.push('display.coupons')
110
110
  if (Array.isArray(lines)) lines.forEach((line, index) => {
111
- for (const field of ['regularUnitPriceMinor', 'attributes'] as const) {
111
+ for (const field of ['regularUnitPriceMinor', 'attributes', 'anyAttributes'] as const) {
112
112
  if (line?.[field] !== undefined) v6Fields.push(`lines[${index}].${field}`)
113
113
  }
114
114
  })
@@ -133,6 +133,16 @@ export function payloadShapeErrors(payload: unknown): string[] {
133
133
  check(object(line.attributes), `${path}.attributes`, 'an object')
134
134
  if (object(line.attributes)) for (const [key, value] of Object.entries(line.attributes)) check(typeof value === 'string', `${path}.attributes.${key}`, 'a string')
135
135
  }
136
+ const { anyAttributes: names, attributes } = line
137
+ if (names !== undefined) check(Array.isArray(names), `${path}.anyAttributes`, 'an array')
138
+ if (Array.isArray(names)) names.forEach((name, index) => {
139
+ const at = `${path}.anyAttributes[${index}]`
140
+ check(typeof name === 'string' && name.length > 0, at, 'a non-empty string')
141
+ if (typeof name !== 'string' || !name) return
142
+ check(names.indexOf(name) === index, at, 'no duplicate name')
143
+ check(object(attributes) && Object.hasOwn(attributes, name) && typeof attributes[name] === 'string' && attributes[name].length > 0,
144
+ at, `a key of ${path}.attributes with a non-empty value`)
145
+ })
136
146
  })
137
147
  // NUL, only on strings (the checks above name any other type): Postgres text can't hold it, and the lookup keys must be clean.
138
148
  for (const [value, path] of payloadStrings(payload)) check(!value.includes('\u0000'), path, 'no NUL character')
@@ -193,6 +203,7 @@ function payloadStrings(payload: Record<string, unknown>): Array<[string, string
193
203
  if (object(line) && object(line.attributes)) for (const [key, value] of Object.entries(line.attributes)) {
194
204
  found.push([key, `lines[${index}].attributes`, 255], [value, `lines[${index}].attributes.${key}`, 255])
195
205
  }
206
+ if (object(line) && Array.isArray(line.anyAttributes)) line.anyAttributes.forEach((name, i) => found.push([name, `lines[${index}].anyAttributes[${i}]`, 255]))
196
207
  })
197
208
  if (object(payload.customer)) found.push([payload.customer.email, 'customer.email', 254], [payload.customer.customerId, 'customer.customerId', undefined])
198
209
  found.push([payload.sessionId, 'sessionId', undefined])
@@ -236,6 +236,8 @@ export interface OrderCreateLine {
236
236
  regularUnitPriceMinor?: number;
237
237
  /** Version 6 recorded: the variant's attribute names and values (#495), each at most 255 characters. */
238
238
  attributes?: Record<string, string>;
239
+ /** Version 6: the names in attributes the cashier picked for the variant's "Any" option groups (#495 c/d). */
240
+ anyAttributes?: string[];
239
241
  /**
240
242
  * This line's own tax mode, when it differs from the order's `pricesIncludeTax`
241
243
  * (a price that carries its own flag, D2c). Absent means the order's flag, so
@@ -6,6 +6,7 @@ import type { ReplicationAdapter } from './replication';
6
6
  import type { CatalogueReconcileAdapter, FingerprintReconcileAdapter, IdReconcileAdapter, StockReconcileAdapter } from './reconcile';
7
7
  import type { StoreSettings, StoreSettingsChoice } from './store-settings';
8
8
  import type { Customer, CustomerInput } from './customers';
9
+ import type { ListOrdersQuery, StoreOrder, StoreOrderPage } from './orders';
9
10
 
10
11
  /**
11
12
  * Authentication configuration for a connector.
@@ -312,4 +313,15 @@ export interface TallyConnector {
312
313
  * email receipts.
313
314
  */
314
315
  emailReceipt?: (context: SyncContext, orderId: string, email: string, options?: { saveToBilling?: boolean }) => Promise<void>;
316
+ /**
317
+ * The store's orders, newest first, one page per call (ADR-081): online only, read-only. Rejects as `emailReceipt`
318
+ * does (`ConnectorUnauthorizedError` for credentials; a connector's own errors otherwise, e.g. `CustomerServiceError`).
319
+ * `undefined` when the connector has no order history.
320
+ */
321
+ listOrders?: (context: SyncContext, query?: ListOrdersQuery) => Promise<StoreOrderPage>;
322
+ /**
323
+ * The given orders by store id (ADR-081), in the order asked; an id the store does not have is left out. Online only,
324
+ * read-only; rejects as `listOrders`. `undefined` when the connector has no order history.
325
+ */
326
+ getOrders?: (context: SyncContext, ids: readonly string[]) => Promise<StoreOrder[]>;
315
327
  }
@@ -0,0 +1,81 @@
1
+ import type { PaymentMethodKind } from './commands';
2
+
3
+ /** A line of an order the store holds (ADR-081). Money in integer minor units of the order's currency, as the store
4
+ * records it: every amount excludes tax, and the tax is beside it.
5
+ * Each tax field is such that net + tax is the gross rounded once. */
6
+ export interface StoreOrderLine {
7
+ /** The store's line id: what `OrderRefundLine.orderLineId` names. */
8
+ id: string;
9
+ /** The till's line id when a till created the line (its `clientLineId`); absent otherwise. */
10
+ clientLineId?: string;
11
+ productId?: string;
12
+ /** The sellable the till's `variantId` names (a WooCommerce variation, or the product itself when simple). */
13
+ variantId?: string;
14
+ name: string;
15
+ sku?: string;
16
+ quantity: number;
17
+ /** Before discounts, excluding tax. */
18
+ subtotalMinor: number;
19
+ subtotalTaxMinor: number;
20
+ /** After discounts, excluding tax. */
21
+ totalMinor: number;
22
+ taxMinor: number;
23
+ }
24
+
25
+ /** A fee or shipping line: excluding tax, the tax beside it. A fee may be negative.
26
+ * `taxMinor` is such that `totalMinor + taxMinor` is the gross rounded once. */
27
+ export interface StoreOrderCharge { name: string; totalMinor: number; taxMinor: number }
28
+
29
+ export interface StoreOrderPayment {
30
+ /** The store's own method id, e.g. WooCommerce's `pos_cash`. */
31
+ method: string;
32
+ /** The store's name for it, e.g. "Cash". */
33
+ title?: string;
34
+ /** Set only when the method is one the till itself takes. */
35
+ kind?: PaymentMethodKind;
36
+ amountMinor: number;
37
+ }
38
+
39
+ /** A refund the store already recorded against the order. */
40
+ export interface StoreOrderRefund { id: string; /** Positive. */ amountMinor: number; reason?: string }
41
+
42
+ /** An order as the store holds it, read online (ADR-081); never stored by the till. */
43
+ export interface StoreOrder {
44
+ /** The store's order id: what `OrderRefundPayload.orderId` and `CommandServerRefs.orderId` carry. */
45
+ id: string;
46
+ /** The number the store shows (`CommandServerRefs.displayId`). */
47
+ reference: string;
48
+ /** The till's `PosOrder.id` when a till created the order; absent otherwise. */
49
+ clientOrderId?: string;
50
+ /** The platform's own status word (WooCommerce: `completed`, `refunded`, …); the app labels it. */
51
+ status: string;
52
+ /** ISO 8601, UTC. */
53
+ placedAt: string;
54
+ currency: string;
55
+ pricesIncludeTax: boolean;
56
+ customer: { id?: string; name?: string; email?: string } | null;
57
+ lines: StoreOrderLine[];
58
+ fees: StoreOrderCharge[];
59
+ shipping: StoreOrderCharge[];
60
+ /** `discountMinor + discountTaxMinor` is the coupon's gross discount rounded once. */
61
+ coupons: Array<{ code: string; discountMinor: number; discountTaxMinor: number }>;
62
+ /** Tax by rate; `amountMinor` includes the rate's shipping tax. */
63
+ taxLines: Array<{ label: string; code?: string; ratePpm: number; amountMinor: number }>;
64
+ discountMinor: number;
65
+ discountTaxMinor: number;
66
+ taxMinor: number;
67
+ totalMinor: number;
68
+ payments: StoreOrderPayment[];
69
+ refunds: StoreOrderRefund[];
70
+ }
71
+
72
+ export interface ListOrdersQuery {
73
+ /** 1-based; default 1. */
74
+ page?: number;
75
+ /** 1..100; default 25. */
76
+ perPage?: number;
77
+ /** The platform's own order search. */
78
+ search?: string;
79
+ }
80
+
81
+ export interface StoreOrderPage { orders: StoreOrder[]; hasMore: boolean }