@tallyui/core 3.0.0-next.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/index.d.ts CHANGED
@@ -272,7 +272,7 @@ interface FingerprintReconcileAdapter<Doc = any> {
272
272
  /** Ids per `fetchByIds` request; see `CatalogueReconcileAdapter.refetchBatchSize`. */
273
273
  refetchBatchSize?: number;
274
274
  }
275
- /** One product in the catalogue listing. `key` is the local primary key value; `remote` is whatever the connector needs to refetch it (a numeric backend id, say). */
275
+ /** 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). */
276
276
  interface CatalogueReconcileEntry {
277
277
  key: string;
278
278
  fingerprint: string;
@@ -293,12 +293,22 @@ interface CatalogueReconcileAdapter<Doc = any, Cursor = unknown> {
293
293
  /** Pure: the same fingerprint from a local document. */
294
294
  fingerprint(doc: Doc): string;
295
295
  /**
296
- * Deletion proof, required: of these local documents (the ones the listing did not name), the keys
297
- * the backend confirms gone (absent, or no longer sellable). One or more requests. Only confirmed
298
- * keys are tombstoned; an adapter that never deletes returns none.
296
+ * When set, each listing entry's `key` is this value, not the local primary key (a listing that carries no
297
+ * primary key, such as WCPOS's fast path, #313). The runner indexes the local documents by it for the pass.
298
+ * A document for which it returns undefined can't be matched: it is never compared, and it is a deletion
299
+ * candidate, as today.
300
+ */
301
+ matchKey?(doc: Doc): string | undefined;
302
+ /**
303
+ * Deletion proof, required: of these local documents (the ones the listing did not name), the primary keys
304
+ * the backend confirms gone (absent, or no longer sellable), with or without `matchKey`. One or more requests.
305
+ * Only confirmed keys are tombstoned; an adapter that never deletes returns none.
299
306
  */
300
307
  confirmGone(locals: Doc[], context: SyncContext): Promise<string[]>;
301
- /** Hand documents to the collection's pull (the reconcile feed). */
308
+ /**
309
+ * Hand documents to the collection's pull (the reconcile feed). An entry's `key` is the local primary key when
310
+ * there is a local copy, and otherwise the listing's key.
311
+ */
302
312
  enqueue(entries: Array<{
303
313
  key: string;
304
314
  local?: Doc;
@@ -320,6 +330,8 @@ interface StoreSettings {
320
330
  default: number;
321
331
  [taxClass: string]: number;
322
332
  };
333
+ /** 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. */
334
+ taxRateCodes?: Record<string, string>;
323
335
  /** 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. */
324
336
  pricingContext?: Record<string, string>;
325
337
  /** Derived, never read by `storeSettings`: the store's `ServerCapabilities.taxRounding`, which `useStoreSettings` fills in (#324). */
@@ -431,8 +443,9 @@ declare function parseTaxRounding(value: unknown, warn?: (reason: string) => voi
431
443
  * Reads a 2xx body of `GET /tally/v1/info` (ADR-062): `orderCreate` is the max of
432
444
  * `contracts["order.create"]`, or 1 when it's missing or malformed; `register` is the max of
433
445
  * `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287).
446
+ * Absent `taxRounding` uses the default; a present malformed value is unknown, so settings wait.
434
447
  */
435
- declare function parseInfoCapabilities(body: unknown, warn?: (reason: string) => void): ServerCapabilities;
448
+ declare function parseInfoCapabilities(body: unknown, warn?: (reason: string) => void): ServerCapabilities | undefined;
436
449
  interface AuthField {
437
450
  key: string;
438
451
  label: string;
@@ -582,13 +595,13 @@ declare class SignInError extends Error {
582
595
  constructor(code: SignInErrorCode, message: string, status?: number);
583
596
  }
584
597
 
585
- /** A backend refused the stored credentials (expired, revoked or insufficient); the app should sign in again. */
598
+ /** 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. */
586
599
  declare class ConnectorUnauthorizedError extends Error {
587
- readonly code: "unauthorized";
588
- /** Only signing in on this till fixes it, so the pull stops until `resume()` (`errorKind`). */
589
- readonly fixedBy: "till";
590
- readonly status?: number;
591
- constructor(message: string, status?: number);
600
+ readonly code: 'unauthorized' | 'forbidden';
601
+ readonly fixedBy: 'till' | 'store';
602
+ /** Set by meaning, not copied from the HTTP answer: a backend that answers both with the same code decides first (Vendure's session probe). */
603
+ readonly status: 401 | 403;
604
+ constructor(message: string, status: 401 | 403);
592
605
  }
593
606
 
594
607
  /**
@@ -745,17 +758,20 @@ declare function getProductStock<Doc>(doc: Doc, traits: ProductTraits<Doc>, adap
745
758
  *
746
759
  * `options.batchSize` sets the combined pull page size; sub-adapters' own
747
760
  * `pull.batchSize` is ignored.
761
+ * Duplicates across sub-adapters are resolved by this key, the last one winning; it defaults to `doc.id`. Pass the collection's primary key when `id` is not it (WooCommerce's uuid, #331): two documents that share an `id`, such as a product's new copy and its old copy's tombstone, must both reach the collection.
748
762
  * Pull only: a sub-adapter with `push` or `pull.stream$` throws here.
749
763
  */
750
764
  declare function combinePullAdapters<Doc>(adapters: Record<string, ReplicationAdapter<Doc, any>>, options?: {
751
765
  legacyKey?: string;
752
766
  batchSize?: number;
767
+ key?: (doc: Doc) => unknown;
753
768
  }): ReplicationAdapter<Doc, Record<string, any>>;
754
769
 
755
770
  /**
756
771
  * One queued correction, keyed by the local primary key: `key`, or `id`, its
757
- * older name. `local` is the till's copy, if it has one; `remote` is whatever
758
- * the connector needs to refetch it.
772
+ * older name. An entry without a local copy may carry the listing's key instead
773
+ * (#313). `local` is the till's copy, if it has one; `remote` is whatever the
774
+ * connector needs to refetch it.
759
775
  */
760
776
  type ReconcileFeedEntry<Doc = any> = ({
761
777
  key: string;
@@ -789,6 +805,11 @@ interface CreateReconcileFeedOptions<Doc = any> {
789
805
  interface KeyedReconcileFeedOptions<Doc = any> {
790
806
  /** The local primary key of a fetched document; fetched documents are matched to entries by it. */
791
807
  key(doc: Doc): string;
808
+ /**
809
+ * The value an entry's `remote` names this document by. An entry with no local copy whose key finds no
810
+ * fetched document is matched by it (a listing that carries no primary key, #313).
811
+ */
812
+ remote?(doc: Doc): unknown;
792
813
  /** The current documents for the entries that still exist. A document may carry `_deleted: true` (an unpublished product). */
793
814
  fetchByIds(entries: Array<ReconcileFetchEntry<Doc>>, context: SyncContext): Promise<Doc[]>;
794
815
  }
package/dist/index.js CHANGED
@@ -31,7 +31,11 @@ var maxVersion = (list) => {
31
31
  function parseInfoCapabilities(body, warn) {
32
32
  const { contracts, taxRounding } = body ?? {};
33
33
  const register = maxVersion(contracts?.register);
34
- const rounding = parseTaxRounding(taxRounding, warn);
34
+ const rounding = parseTaxRounding(taxRounding);
35
+ if (taxRounding !== void 0 && rounding === void 0) {
36
+ warn?.(`malformed taxRounding: rounding is unknown, so settings wait: ${JSON.stringify(taxRounding)}`);
37
+ return void 0;
38
+ }
35
39
  return {
36
40
  orderCreate: maxVersion(contracts?.["order.create"]) ?? 1,
37
41
  ...register !== void 0 ? { register } : {},
@@ -53,14 +57,16 @@ var SignInError = class extends Error {
53
57
 
54
58
  // src/unauthorized.ts
55
59
  var ConnectorUnauthorizedError = class extends Error {
56
- code = "unauthorized";
57
- /** Only signing in on this till fixes it, so the pull stops until `resume()` (`errorKind`). */
58
- fixedBy = "till";
60
+ code;
61
+ fixedBy;
62
+ /** Set by meaning, not copied from the HTTP answer: a backend that answers both with the same code decides first (Vendure's session probe). */
59
63
  status;
60
64
  constructor(message, status) {
61
65
  super(message);
62
66
  this.name = "ConnectorUnauthorizedError";
63
67
  this.status = status;
68
+ this.code = status === 401 ? "unauthorized" : "forbidden";
69
+ this.fixedBy = status === 401 ? "till" : "store";
64
70
  }
65
71
  };
66
72
 
@@ -329,14 +335,15 @@ function combinePullAdapters(adapters, options = {}) {
329
335
  }
330
336
  previous = seeded;
331
337
  }
332
- const byId = /* @__PURE__ */ new Map();
338
+ const keyOf2 = options.key ?? ((doc) => doc.id);
339
+ const byKey = /* @__PURE__ */ new Map();
333
340
  const checkpoint = {};
334
341
  for (const key of keys) {
335
342
  const result = await adapters[key].pull.handler(previous?.[key], batchSize, context);
336
- for (const doc of result.documents) byId.set(doc.id, doc);
343
+ for (const doc of result.documents) byKey.set(keyOf2(doc), doc);
337
344
  checkpoint[key] = { ...previous?.[key], ...result.checkpoint };
338
345
  }
339
- return { documents: [...byId.values()], checkpoint };
346
+ return { documents: [...byKey.values()], checkpoint };
340
347
  }
341
348
  }
342
349
  };
@@ -366,10 +373,17 @@ function createReconcileFeed(options) {
366
373
  const toFetch = chunk.filter((e) => !e.tombstone);
367
374
  const fetched = toFetch.length ? await fetch(toFetch, context) : [];
368
375
  const byKey = new Map(fetched.map((doc) => [docKey(doc), doc]));
376
+ const byRemote = keyed?.remote && new Map(fetched.map((doc) => [keyed.remote(doc), doc]));
377
+ const pushed = /* @__PURE__ */ new Set();
369
378
  for (const entry of chunk) {
370
- const doc = entry.tombstone ? void 0 : byKey.get(keyOf(entry));
371
- if (doc) documents.push({ ...doc, _deleted: doc._deleted ?? false });
372
- else if (!entry.refreshOnly && entry.local) documents.push({ ...entry.local, _deleted: true });
379
+ const doc = entry.tombstone ? void 0 : byKey.get(keyOf(entry)) ?? (entry.local === void 0 && entry.remote !== void 0 && byRemote ? byRemote.get(entry.remote) : void 0);
380
+ const moved = !entry.tombstone && !doc && entry.local !== void 0 && entry.remote !== void 0 && byRemote ? byRemote.get(entry.remote) : void 0;
381
+ const fetchedDoc = doc ?? moved;
382
+ if (fetchedDoc && !pushed.has(fetchedDoc)) {
383
+ documents.push({ ...fetchedDoc, _deleted: fetchedDoc._deleted ?? false });
384
+ pushed.add(fetchedDoc);
385
+ }
386
+ if (!doc && !entry.refreshOnly && entry.local) documents.push({ ...entry.local, _deleted: true });
373
387
  }
374
388
  }
375
389
  return { documents, checkpoint: { n: (lastCheckpoint?.n ?? 0) + 1 } };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/core",
3
- "version": "3.0.0-next.0",
3
+ "version": "3.0.0-next.1",
4
4
  "type": "module",
5
5
  "description": "Core interfaces, traits, and context providers for Tally UI",
6
6
  "main": "./dist/index.js",
@@ -14,11 +14,12 @@ import type { ReplicationAdapter } from '../types';
14
14
  *
15
15
  * `options.batchSize` sets the combined pull page size; sub-adapters' own
16
16
  * `pull.batchSize` is ignored.
17
+ * Duplicates across sub-adapters are resolved by this key, the last one winning; it defaults to `doc.id`. Pass the collection's primary key when `id` is not it (WooCommerce's uuid, #331): two documents that share an `id`, such as a product's new copy and its old copy's tombstone, must both reach the collection.
17
18
  * Pull only: a sub-adapter with `push` or `pull.stream$` throws here.
18
19
  */
19
20
  export function combinePullAdapters<Doc>(
20
21
  adapters: Record<string, ReplicationAdapter<Doc, any>>,
21
- options: { legacyKey?: string; batchSize?: number } = {},
22
+ options: { legacyKey?: string; batchSize?: number; key?: (doc: Doc) => unknown } = {},
22
23
  ): ReplicationAdapter<Doc, Record<string, any>> {
23
24
  const keys = Object.keys(adapters);
24
25
  for (const key of keys) {
@@ -50,7 +51,8 @@ export function combinePullAdapters<Doc>(
50
51
  }
51
52
  previous = seeded;
52
53
  }
53
- const byId = new Map<unknown, Doc & { _deleted: boolean }>();
54
+ const keyOf = options.key ?? ((doc: Doc) => (doc as { id?: unknown }).id);
55
+ const byKey = new Map<unknown, Doc & { _deleted: boolean }>();
54
56
  const checkpoint: Record<string, any> = {};
55
57
  // Call sub-adapters strictly one after another, in key order: a
56
58
  // correctness rule, not politeness. Each feed writes whole documents.
@@ -62,15 +64,15 @@ export function combinePullAdapters<Doc>(
62
64
  // it, with neither checkpoint ever revisiting the document.
63
65
  for (const key of keys) {
64
66
  const result = await adapters[key].pull.handler(previous?.[key], batchSize, context);
65
- for (const doc of result.documents) byId.set((doc as { id?: unknown }).id, doc);
67
+ for (const doc of result.documents) byKey.set(keyOf(doc), doc);
66
68
  // RxDB merges only the top level of the combined checkpoint, so merge
67
69
  // each sub-checkpoint here as it would for a single adapter. Spread
68
70
  // keeps a sub-adapter's explicit undefined (cleared pass state).
69
71
  checkpoint[key] = { ...previous?.[key], ...result.checkpoint };
70
72
  }
71
- // Each sub-adapter returns unique ids, so one full sub-page makes the
73
+ // Each sub-adapter returns unique keys, so one full sub-page makes the
72
74
  // combined page full: RxDB keeps pulling while any sub-adapter has more.
73
- return { documents: [...byId.values()], checkpoint };
75
+ return { documents: [...byKey.values()], checkpoint };
74
76
  },
75
77
  },
76
78
  };
@@ -6,8 +6,9 @@ const MAX_CHUNK = 1000;
6
6
 
7
7
  /**
8
8
  * One queued correction, keyed by the local primary key: `key`, or `id`, its
9
- * older name. `local` is the till's copy, if it has one; `remote` is whatever
10
- * the connector needs to refetch it.
9
+ * older name. An entry without a local copy may carry the listing's key instead
10
+ * (#313). `local` is the till's copy, if it has one; `remote` is whatever the
11
+ * connector needs to refetch it.
11
12
  */
12
13
  export type ReconcileFeedEntry<Doc = any> = ({ key: string; id?: undefined } | { id: string; key?: undefined }) & {
13
14
  local?: Doc;
@@ -31,6 +32,11 @@ export interface CreateReconcileFeedOptions<Doc = any> {
31
32
  export interface KeyedReconcileFeedOptions<Doc = any> {
32
33
  /** The local primary key of a fetched document; fetched documents are matched to entries by it. */
33
34
  key(doc: Doc): string;
35
+ /**
36
+ * The value an entry's `remote` names this document by. An entry with no local copy whose key finds no
37
+ * fetched document is matched by it (a listing that carries no primary key, #313).
38
+ */
39
+ remote?(doc: Doc): unknown;
34
40
  /** The current documents for the entries that still exist. A document may carry `_deleted: true` (an unpublished product). */
35
41
  fetchByIds(entries: Array<ReconcileFetchEntry<Doc>>, context: SyncContext): Promise<Doc[]>;
36
42
  }
@@ -85,14 +91,24 @@ export function createReconcileFeed<Doc = any>(
85
91
  const toFetch = chunk.filter((e) => !e.tombstone);
86
92
  const fetched = toFetch.length ? await fetch(toFetch, context) : [];
87
93
  const byKey = new Map(fetched.map((doc) => [docKey(doc), doc]));
94
+ const byRemote = keyed?.remote && new Map(fetched.map((doc) => [keyed.remote!(doc), doc]));
95
+ const pushed = new Set<Doc>();
88
96
  for (const entry of chunk) {
89
- const doc = entry.tombstone ? undefined : byKey.get(keyOf(entry));
97
+ const doc = entry.tombstone ? undefined : byKey.get(keyOf(entry))
98
+ ?? (entry.local === undefined && entry.remote !== undefined && byRemote ? byRemote.get(entry.remote) : undefined);
99
+ // The backend primary key changed (a WCPOS uuid reassigned, #331): the old copy goes and the current one arrives.
100
+ const moved = !entry.tombstone && !doc && entry.local !== undefined && entry.remote !== undefined && byRemote
101
+ ? byRemote.get(entry.remote) : undefined;
102
+ const fetchedDoc = doc ?? moved;
90
103
  // A fetched document keeps a `_deleted` the connector set (an unpublished product, #248).
91
- if (doc) documents.push({ ...doc, _deleted: (doc as { _deleted?: boolean })._deleted ?? false });
104
+ if (fetchedDoc && !pushed.has(fetchedDoc)) {
105
+ documents.push({ ...fetchedDoc, _deleted: (fetchedDoc as { _deleted?: boolean })._deleted ?? false });
106
+ pushed.add(fetchedDoc);
107
+ }
92
108
  // A refreshOnly entry (the fingerprint path) is skipped, not tombstoned, when the
93
109
  // product is missing: only the id reconcile's braked entries may delete (ADR-060).
94
110
  // An entry with no local copy has nothing to delete.
95
- else if (!entry.refreshOnly && entry.local) documents.push({ ...entry.local, _deleted: true });
111
+ if (!doc && !entry.refreshOnly && entry.local) documents.push({ ...entry.local, _deleted: true });
96
112
  }
97
113
  }
98
114
  return { documents, checkpoint: { n: (lastCheckpoint?.n ?? 0) + 1 } };
@@ -95,11 +95,16 @@ const maxVersion = (list: unknown): number | undefined => {
95
95
  * Reads a 2xx body of `GET /tally/v1/info` (ADR-062): `orderCreate` is the max of
96
96
  * `contracts["order.create"]`, or 1 when it's missing or malformed; `register` is the max of
97
97
  * `contracts.register` when valid; `taxRounding` is the top-level sibling of `contracts` (#287).
98
+ * Absent `taxRounding` uses the default; a present malformed value is unknown, so settings wait.
98
99
  */
99
- export function parseInfoCapabilities(body: unknown, warn?: (reason: string) => void): ServerCapabilities {
100
+ export function parseInfoCapabilities(body: unknown, warn?: (reason: string) => void): ServerCapabilities | undefined {
100
101
  const { contracts, taxRounding } = (body ?? {}) as { contracts?: Record<string, unknown> | null; taxRounding?: unknown };
101
102
  const register = maxVersion(contracts?.register);
102
- const rounding = parseTaxRounding(taxRounding, warn);
103
+ const rounding = parseTaxRounding(taxRounding);
104
+ if (taxRounding !== undefined && rounding === undefined) {
105
+ warn?.(`malformed taxRounding: rounding is unknown, so settings wait: ${JSON.stringify(taxRounding)}`);
106
+ return undefined;
107
+ }
103
108
  return { orderCreate: maxVersion(contracts?.['order.create']) ?? 1,
104
109
  ...(register !== undefined ? { register } : {}), ...(rounding ? { taxRounding: rounding } : {}) };
105
110
  }
@@ -46,7 +46,7 @@ export interface FingerprintReconcileAdapter<Doc = any> {
46
46
  refetchBatchSize?: number;
47
47
  }
48
48
 
49
- /** One product in the catalogue listing. `key` is the local primary key value; `remote` is whatever the connector needs to refetch it (a numeric backend id, say). */
49
+ /** 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). */
50
50
  export interface CatalogueReconcileEntry { key: string; fingerprint: string; remote?: unknown }
51
51
 
52
52
  /**
@@ -61,12 +61,22 @@ export interface CatalogueReconcileAdapter<Doc = any, Cursor = unknown> {
61
61
  /** Pure: the same fingerprint from a local document. */
62
62
  fingerprint(doc: Doc): string;
63
63
  /**
64
- * Deletion proof, required: of these local documents (the ones the listing did not name), the keys
65
- * the backend confirms gone (absent, or no longer sellable). One or more requests. Only confirmed
66
- * keys are tombstoned; an adapter that never deletes returns none.
64
+ * When set, each listing entry's `key` is this value, not the local primary key (a listing that carries no
65
+ * primary key, such as WCPOS's fast path, #313). The runner indexes the local documents by it for the pass.
66
+ * A document for which it returns undefined can't be matched: it is never compared, and it is a deletion
67
+ * candidate, as today.
68
+ */
69
+ matchKey?(doc: Doc): string | undefined;
70
+ /**
71
+ * Deletion proof, required: of these local documents (the ones the listing did not name), the primary keys
72
+ * the backend confirms gone (absent, or no longer sellable), with or without `matchKey`. One or more requests.
73
+ * Only confirmed keys are tombstoned; an adapter that never deletes returns none.
67
74
  */
68
75
  confirmGone(locals: Doc[], context: SyncContext): Promise<string[]>;
69
- /** Hand documents to the collection's pull (the reconcile feed). */
76
+ /**
77
+ * Hand documents to the collection's pull (the reconcile feed). An entry's `key` is the local primary key when
78
+ * there is a local copy, and otherwise the listing's key.
79
+ */
70
80
  enqueue(entries: Array<{ key: string; local?: Doc; remote?: unknown; tombstone?: boolean }>): void;
71
81
  /** 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). */
72
82
  refetchBatchSize?: number;
@@ -8,6 +8,8 @@ export interface StoreSettings {
8
8
  pricesIncludeTax: boolean;
9
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. */
10
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>;
11
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. */
12
14
  pricingContext?: Record<string, string>;
13
15
  /** Derived, never read by `storeSettings`: the store's `ServerCapabilities.taxRounding`, which `useStoreSettings` fills in (#324). */
@@ -1,13 +1,15 @@
1
- /** A backend refused the stored credentials (expired, revoked or insufficient); the app should sign in again. */
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
2
  export class ConnectorUnauthorizedError extends Error {
3
- readonly code = 'unauthorized' as const;
4
- /** Only signing in on this till fixes it, so the pull stops until `resume()` (`errorKind`). */
5
- readonly fixedBy = 'till' as const;
6
- readonly status?: number;
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
7
 
8
- constructor(message: string, status?: number) {
8
+ constructor(message: string, status: 401 | 403) {
9
9
  super(message);
10
10
  this.name = 'ConnectorUnauthorizedError';
11
11
  this.status = status;
12
+ this.code = status === 401 ? 'unauthorized' : 'forbidden';
13
+ this.fixedBy = status === 401 ? 'till' : 'store';
12
14
  }
13
15
  }