@peabody-soft/mbs-model-ts 1.7.0 → 1.7.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.
@@ -1,15 +1,15 @@
1
1
  import { BadRequestException, ConflictException, InternalServerException, MethodNotAllowedException, NotFoundException, ServiceException, ServiceUnavailableException, UnauthorizedException, UpgradeRequiredException, } from "./ServiceExceptions";
2
- // Which failure a status code stands for. The classes are in ServiceExceptions.ts. The split matches
3
- // Java's HttpStatusCodes and exception package, so the table of what each code means has one home
4
- // in each client.
2
+ // Maps a status code to its exception. The classes are in ServiceExceptions.ts. The split matches
3
+ // Java's HttpStatusCodes and exception package, so each client has one table of what each code
4
+ // means.
5
5
  // Everything from 300 up (Java's HttpURLConnection.HTTP_MULT_CHOICE). A redirect counts as a
6
- // failure because this client follows none, so being sent elsewhere means the call did not happen.
6
+ // failure because this client follows none, so the call did not happen.
7
7
  export function isError(httpStatusCode) {
8
8
  return httpStatusCode >= LOWEST_ERROR_STATUS_CODE;
9
9
  }
10
- // Raises the failure a status code stands for, and does nothing for a code that is not an error.
11
- // A code with no class of its own becomes a ServiceException carrying the code, so a new server
12
- // response cannot pass as a success.
10
+ // Throws the exception for a status code, and does nothing for a code that is not an error. A code
11
+ // with no class throws a ServiceException carrying the code, so an unlisted error code cannot pass
12
+ // as a success.
13
13
  export function throwOnError(httpStatusCode, message) {
14
14
  if (!isError(httpStatusCode))
15
15
  return;
package/dist/Ids.js CHANGED
@@ -22,8 +22,7 @@ class Ids {
22
22
  }
23
23
  // A fresh id for an entity this client creates (Java Entity.getRandomLongForId): random, never
24
24
  // in 0-255, which every entity type reserves. Only the low part is drawn, as buildId masks the
25
- // rest off. It uses the cryptographic generator because a Math.random id is guessable and a
26
- // message id can be handed to a caller.
25
+ // rest off. It uses the cryptographic generator because a Math.random id is guessable.
27
26
  static getNewId(entityTypeId) {
28
27
  for (;;) {
29
28
  const bytes = new Uint8Array(8);
@@ -55,9 +54,9 @@ class Ids {
55
54
  static toOrderNumberString(orderId) {
56
55
  return (orderId & Ids.UNSIGNED_32_BIT_MASK).toString(16).toUpperCase();
57
56
  }
58
- // Where a container keeps how far its reads of one entity type have got. The blob's eTag is the
59
- // cursor the next read sends, and the blob holds nothing else. The store keeps the greater eTag,
60
- // so a cursor never drops on a stale or repeated page or a write from another tab. Written in
57
+ // The blob in which a container keeps the sync cursor of one entity type. Its eTag is the cursor
58
+ // the next read sends, and the blob holds no other data. The store keeps the greater eTag, so a
59
+ // stale or repeated page, or a write from another tab, cannot lower the cursor. It is written in
61
60
  // the batch of the page that moved it, so it cannot get ahead of the entities it describes. key
62
61
  // is one of SyncKeys.
63
62
  static getSyncCursorBlobId(key) {
package/dist/Item.js CHANGED
@@ -2,7 +2,8 @@ import Entity from "./Entity";
2
2
  // Something a business buys or sells, or a category or price of one. Mirrors the protocol's Item, embedded in each of the five real types.
3
3
  // parentItemId is the wire parent (a product's category). Entity.parent is the sync layer's containment parent (the business).
4
4
  export default class Item extends Entity {
5
- // Public because ProductCategory and PriceList add nothing of their own. The class is still abstract.
5
+ // Public because ProductCategory and PriceList declare no constructor and inherit this one. The
6
+ // class is still abstract.
6
7
  constructor(header, _name, _description, _parentItemId, _isDisabled) {
7
8
  super(header);
8
9
  this._name = _name;
@@ -20,9 +21,10 @@ export default class Item extends Entity {
20
21
  get parentItemId() {
21
22
  return this._parentItemId;
22
23
  }
23
- // True when the business has disabled this item. Unlike isPublic and Product.isDraft, it can
24
- // change after an item exists, so it is sent rather than filtered out. A product-level check does
25
- // not guarantee that every package of an otherwise visible product is enabled.
24
+ // True when the business has disabled this item. The server filters out draft and non-public
25
+ // products, but this flag can change after an item exists, so a disabled item is sent flagged. A
26
+ // product-level check does not guarantee that every package of an otherwise visible product is
27
+ // enabled.
26
28
  get isDisabled() {
27
29
  return this._isDisabled;
28
30
  }
package/dist/LiveData.js CHANGED
@@ -29,7 +29,7 @@ class LiveData {
29
29
  // Returns the function that stops this observer observing. Observing twice with the same function only observes once.
30
30
  observe(observer, notifyImmediately = false) {
31
31
  if (!this._observers.has(observer)) {
32
- // NOT_NOTIFIED means the immediate notification below has something to deliver; otherwise a new observer only hears future changes (not sticky, unlike Android LiveData).
32
+ // NOT_NOTIFIED means the immediate notification below has something to deliver; otherwise a new observer receives only future changes (not sticky, unlike Android LiveData).
33
33
  this._observers.set(observer, notifyImmediately ? LiveData.NOT_NOTIFIED : this._version);
34
34
  }
35
35
  if (notifyImmediately)
@@ -54,7 +54,7 @@ class LiveData {
54
54
  if (this._isNotificationStale)
55
55
  break; // Start again with the newer value
56
56
  if (this._observers.get(observer) === this._version)
57
- continue; // Already told
57
+ continue; // Already notified
58
58
  this._observers.set(observer, this._version);
59
59
  observer(this._holder);
60
60
  }
package/dist/Measures.js CHANGED
@@ -1,5 +1,6 @@
1
- // How big a package is and how much it weighs, grouped since a UI showing one usually shows both. Neither is an entity; both are values on the Package row.
2
- // Units are the generated proto enums. A value displays in the unit the merchant entered it in, and nothing here converts between units.
1
+ // How big a package is and how much it weighs, in one file since a UI showing one usually shows both.
2
+ // Neither is an entity; both are values on Package.
3
+ // Units are the generated proto enums. A value is shown in the unit the merchant entered it in, and nothing here converts between units.
3
4
  export class Dimensions {
4
5
  constructor(_unit, _length, _width, _height) {
5
6
  this._unit = _unit;
package/dist/Message.js CHANGED
@@ -12,7 +12,7 @@ export default class Message extends Entity {
12
12
  }
13
13
  // The customer's party id at the business (BusinessLink.partyId), not the id of their User. A
14
14
  // business sync out sends a customer only messages from their own party. senderName and
15
- // senderPhone say who it was without resolving the party.
15
+ // senderPhone identify the sender without resolving the party.
16
16
  get senderId() {
17
17
  return this._senderId;
18
18
  }
@@ -1,5 +1,6 @@
1
- // A Database that holds everything in a Map, for tests and training mode to run against with no
2
- // network. Enforces the eTag rule (write only if the new eTag is greater), so a test proves the sync is idempotent.
1
+ // A Database that holds everything in a Map, for tests and training mode, which run with no
2
+ // network. It enforces the eTag rule (a write applies only if its eTag is greater), so a test can
3
+ // check that a sync is idempotent.
3
4
  export default class MockDatabase {
4
5
  constructor() {
5
6
  this._containers = new Map();
@@ -18,14 +19,14 @@ export default class MockDatabase {
18
19
  async deleteContainer(name) {
19
20
  this._containers.delete(name);
20
21
  }
21
- // For a test that wants to look at what was stored without going through a sync
22
+ // Lets a test inspect what was stored without going through a sync
22
23
  getContainerIfPresent(name) {
23
24
  return this._containers.get(name) ?? null;
24
25
  }
25
26
  }
26
27
  export class MockContainer {
27
28
  constructor() {
28
- // Set by a test just before the write it wants to fail
29
+ // A test sets this just before the write that should fail. That write clears it.
29
30
  this.failNextWrite = false;
30
31
  // How many times write has been called, so that a test can show a sync did not write per entity
31
32
  this.writeCount = 0;
@@ -56,7 +57,7 @@ export class MockContainer {
56
57
  this._blobs.delete(id);
57
58
  return appliedCount;
58
59
  }
59
- // Greater eTag wins; a blob with no eTag (or overwriting one with none) is always written.
60
+ // The greater eTag wins. A write always applies when the incoming blob or the stored one has no eTag.
60
61
  static isNewer(incoming, stored) {
61
62
  if (stored === null)
62
63
  return true;