@tallyui/core 2.0.0 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-C4PWPOKO.js +18 -0
- package/dist/commands-BW4YYgRG.d.ts +306 -0
- package/dist/index.d.ts +247 -130
- package/dist/index.js +210 -22
- package/dist/rxdb/index.d.ts +5 -9
- package/dist/server/index.d.ts +213 -0
- package/dist/server/index.js +591 -0
- package/package.json +8 -2
- package/src/commands.ts +1 -1
- package/src/context/connector-context.tsx +30 -1
- package/src/index.ts +17 -5
- package/src/known-warnings.ts +77 -0
- package/src/replication/combine.ts +13 -7
- package/src/replication/reconcile-feed.ts +73 -20
- package/src/rxdb/read-fresh.ts +3 -7
- package/src/rxdb/watch-fresh.ts +2 -2
- package/src/rxdb-remote-version-mismatch.ts +30 -0
- package/src/server/__fixtures__/fingerprint-vectors.json +139 -0
- package/src/server/__fixtures__/order-create-v3.json +97 -0
- package/src/server/batch-outcome.ts +19 -0
- package/src/server/batch.ts +112 -0
- package/src/server/command-result.ts +138 -0
- package/src/server/fingerprint.ts +18 -0
- package/src/server/fiscal-figures.ts +84 -0
- package/src/server/index.ts +20 -0
- package/src/server/money.ts +34 -0
- package/src/server/order-payload-shape.ts +112 -0
- package/src/server/register-figures.ts +32 -0
- package/src/server/register-outcome.ts +12 -0
- package/src/server/register-payload-shape.ts +86 -0
- package/src/server/rejection-codes.ts +49 -0
- package/src/server/total-warnings.ts +10 -0
- package/src/server/versions.ts +9 -0
- package/src/sync-notice.ts +26 -0
- package/src/types/commands.ts +138 -9
- package/src/types/connector.ts +63 -1
- package/src/types/customers.ts +26 -0
- package/src/types/index.ts +9 -2
- package/src/types/reconcile.ts +40 -0
- package/src/types/replication.ts +6 -0
- package/src/types/store-settings.ts +6 -0
- package/src/types/traits/product.ts +7 -0
- package/src/unauthorized.ts +15 -0
package/src/types/replication.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface ReplicationAdapter<RxDocType, CheckpointType = any> {
|
|
|
26
26
|
checkpoint: CheckpointType;
|
|
27
27
|
}>;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Documents per pull page, passed to handler as batchSize. RxDB treats a
|
|
31
|
+
* shorter page as the end of the cycle. Defaults to RxDB's 100.
|
|
32
|
+
*/
|
|
33
|
+
batchSize?: number;
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
* Fresh install only: the checkpoint this feed starts from instead of a full first pass,
|
|
31
37
|
* read before any feed runs (combinePullAdapters). Absent: a full first pass, as today.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { TaxRounding } from './connector';
|
|
2
|
+
|
|
1
3
|
/** What the POS needs from the store's own settings (TV4). Read once after sign-in; the app feeds all three consumers from it. */
|
|
2
4
|
export interface StoreSettings {
|
|
3
5
|
/** ISO 4217, upper case (the currency prices are sold in). */
|
|
@@ -6,8 +8,12 @@ export interface StoreSettings {
|
|
|
6
8
|
pricesIncludeTax: boolean;
|
|
7
9
|
/** 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. */
|
|
8
10
|
taxRatesPpm: { default: number; [taxClass: string]: number };
|
|
11
|
+
/** 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. */
|
|
12
|
+
taxRateCodes?: Record<string, string>;
|
|
9
13
|
/** 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. */
|
|
10
14
|
pricingContext?: Record<string, string>;
|
|
15
|
+
/** Derived, never read by `storeSettings`: the store's `ServerCapabilities.taxRounding`, which `useStoreSettings` fills in (#324). */
|
|
16
|
+
taxRounding?: TaxRounding;
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
/**
|
|
@@ -58,6 +58,13 @@ export interface ProductTraits<Doc = any> {
|
|
|
58
58
|
/** All purchasable variants, in id order (connectors store variants sorted by id). Optional: connectors without variant support omit it. */
|
|
59
59
|
getVariants?: (doc: Doc, context?: TraitContext) => VariantSummary[];
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* The backend's tax class id for the variant `variantId`, or for the product (its default variant) when omitted.
|
|
63
|
+
* The id is a key of `StoreSettings.taxRatesPpm`; undefined means the default class. Optional: without it, every
|
|
64
|
+
* line is taxed at the default rate.
|
|
65
|
+
*/
|
|
66
|
+
getTaxClass?: (doc: Doc, variantId?: string) => string | undefined;
|
|
67
|
+
|
|
61
68
|
/** @deprecated Use `getPrices` with `resolvePrice`. */
|
|
62
69
|
getPrice: (doc: Doc) => string | undefined;
|
|
63
70
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 401 needs sign-in again (`unauthorized`, till); 403 is signed in but not allowed (`forbidden`, store). A 403 pull retries on the store schedule; apps must not sign out. */
|
|
2
|
+
export class ConnectorUnauthorizedError extends Error {
|
|
3
|
+
readonly code: 'unauthorized' | 'forbidden';
|
|
4
|
+
readonly fixedBy: 'till' | 'store';
|
|
5
|
+
/** Set by meaning, not copied from the HTTP answer: a backend that answers both with the same code decides first (Vendure's session probe). */
|
|
6
|
+
readonly status: 401 | 403;
|
|
7
|
+
|
|
8
|
+
constructor(message: string, status: 401 | 403) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'ConnectorUnauthorizedError';
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.code = status === 401 ? 'unauthorized' : 'forbidden';
|
|
13
|
+
this.fixedBy = status === 401 ? 'till' : 'store';
|
|
14
|
+
}
|
|
15
|
+
}
|