@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.
- package/dist/Attachment.js +2 -2
- package/dist/AttachmentBaseUrl.js +4 -4
- package/dist/AuthTokens.js +7 -7
- package/dist/Business.js +11 -10
- package/dist/BusinessIdentifier.js +3 -2
- package/dist/BusinessLink.js +3 -2
- package/dist/CartEditor.js +89 -81
- package/dist/Catalog.js +4 -4
- package/dist/Constants.js +2 -2
- package/dist/ContainerNames.js +6 -6
- package/dist/Entity.js +4 -3
- package/dist/Enums.js +2 -2
- package/dist/Exceptions.js +2 -2
- package/dist/GeneralSettings.js +9 -8
- package/dist/HttpStatusCodes.js +7 -7
- package/dist/Ids.js +4 -5
- package/dist/Item.js +6 -4
- package/dist/LiveData.js +2 -2
- package/dist/Measures.js +3 -2
- package/dist/Message.js +1 -1
- package/dist/MockDatabase.js +6 -5
- package/dist/Model.js +166 -162
- package/dist/Order.js +10 -12
- package/dist/PackageIdentifier.js +2 -2
- package/dist/Price.js +6 -5
- package/dist/PriceList.js +1 -1
- package/dist/Product.js +8 -6
- package/dist/Profile.js +15 -14
- package/dist/ProtoMap.js +159 -155
- package/dist/ServiceExceptions.js +6 -6
- package/dist/ServiceProxy.js +15 -14
- package/dist/ShoppingList.js +101 -100
- package/dist/SyncCache.js +76 -68
- package/dist/SyncKeys.js +5 -5
- package/dist/SyncState.js +14 -6
- package/dist/Tax.js +11 -10
- package/dist/TaxHelper.js +9 -8
- package/dist/TaxType.js +7 -6
- package/dist/UserProfile.js +7 -7
- package/dist/WorkingDays.js +21 -18
- package/dist/index.js +11 -8
- package/package.json +1 -1
package/dist/HttpStatusCodes.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { BadRequestException, ConflictException, InternalServerException, MethodNotAllowedException, NotFoundException, ServiceException, ServiceUnavailableException, UnauthorizedException, UpgradeRequiredException, } from "./ServiceExceptions";
|
|
2
|
-
//
|
|
3
|
-
// Java's HttpStatusCodes and exception package, so
|
|
4
|
-
//
|
|
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
|
|
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
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
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
|
|
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
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
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
|
|
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.
|
|
24
|
-
// change after an item exists, so
|
|
25
|
-
// not guarantee that every package of an otherwise visible product is
|
|
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
|
|
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
|
|
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,
|
|
2
|
-
//
|
|
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
|
|
15
|
+
// senderPhone identify the sender without resolving the party.
|
|
16
16
|
get senderId() {
|
|
17
17
|
return this._senderId;
|
|
18
18
|
}
|
package/dist/MockDatabase.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// A Database that holds everything in a Map, for tests and training mode
|
|
2
|
-
// network.
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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;
|