@peabody-soft/mbs-model-ts 1.0.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.
- package/LICENCE +661 -0
- package/dist/Address.d.ts +33 -0
- package/dist/Address.js +97 -0
- package/dist/Attachment.d.ts +16 -0
- package/dist/Attachment.js +49 -0
- package/dist/AttachmentBaseUrl.d.ts +11 -0
- package/dist/AttachmentBaseUrl.js +41 -0
- package/dist/AuthTokens.d.ts +13 -0
- package/dist/AuthTokens.js +30 -0
- package/dist/Business.d.ts +44 -0
- package/dist/Business.js +87 -0
- package/dist/BusinessIdentifier.d.ts +8 -0
- package/dist/BusinessIdentifier.js +14 -0
- package/dist/BusinessLink.d.ts +21 -0
- package/dist/BusinessLink.js +61 -0
- package/dist/BusinessProfile.d.ts +11 -0
- package/dist/BusinessProfile.js +27 -0
- package/dist/CartEditor.d.ts +59 -0
- package/dist/CartEditor.js +324 -0
- package/dist/Catalog.d.ts +28 -0
- package/dist/Catalog.js +115 -0
- package/dist/Constants.d.ts +10 -0
- package/dist/Constants.js +43 -0
- package/dist/ContainerNames.d.ts +2 -0
- package/dist/ContainerNames.js +21 -0
- package/dist/Database.d.ts +15 -0
- package/dist/Database.js +1 -0
- package/dist/Entity.d.ts +27 -0
- package/dist/Entity.js +69 -0
- package/dist/Enums.d.ts +16 -0
- package/dist/Enums.js +18 -0
- package/dist/Exceptions.d.ts +4 -0
- package/dist/Exceptions.js +8 -0
- package/dist/GeneralSettings.d.ts +46 -0
- package/dist/GeneralSettings.js +99 -0
- package/dist/HttpStatusCodes.d.ts +2 -0
- package/dist/HttpStatusCodes.js +34 -0
- package/dist/Ids.d.ts +17 -0
- package/dist/Ids.js +78 -0
- package/dist/Item.d.ts +12 -0
- package/dist/Item.js +30 -0
- package/dist/LatLong.d.ts +7 -0
- package/dist/LatLong.js +17 -0
- package/dist/LiveData.d.ts +30 -0
- package/dist/LiveData.js +76 -0
- package/dist/Measures.d.ts +20 -0
- package/dist/Measures.js +34 -0
- package/dist/Message.d.ts +16 -0
- package/dist/Message.js +32 -0
- package/dist/MockDatabase.d.ts +19 -0
- package/dist/MockDatabase.js +73 -0
- package/dist/Model.d.ts +63 -0
- package/dist/Model.js +629 -0
- package/dist/Order.d.ts +31 -0
- package/dist/Order.js +70 -0
- package/dist/Package.d.ts +25 -0
- package/dist/Package.js +52 -0
- package/dist/PackageIdentifier.d.ts +8 -0
- package/dist/PackageIdentifier.js +14 -0
- package/dist/PaymentMethodDetail.d.ts +8 -0
- package/dist/PaymentMethodDetail.js +17 -0
- package/dist/Photo.d.ts +11 -0
- package/dist/Photo.js +29 -0
- package/dist/Price.d.ts +17 -0
- package/dist/Price.js +52 -0
- package/dist/PriceList.d.ts +3 -0
- package/dist/PriceList.js +5 -0
- package/dist/Product.d.ts +33 -0
- package/dist/Product.js +84 -0
- package/dist/ProductCategory.d.ts +10 -0
- package/dist/ProductCategory.js +18 -0
- package/dist/Profile.d.ts +20 -0
- package/dist/Profile.js +55 -0
- package/dist/ProtoMap.d.ts +71 -0
- package/dist/ProtoMap.js +1126 -0
- package/dist/Routes.d.ts +7 -0
- package/dist/Routes.js +12 -0
- package/dist/Service.d.ts +16 -0
- package/dist/Service.js +1 -0
- package/dist/ServiceExceptions.d.ts +40 -0
- package/dist/ServiceExceptions.js +84 -0
- package/dist/ServiceProxy.d.ts +25 -0
- package/dist/ServiceProxy.js +117 -0
- package/dist/ShoppingList.d.ts +64 -0
- package/dist/ShoppingList.js +188 -0
- package/dist/SyncCache.d.ts +28 -0
- package/dist/SyncCache.js +137 -0
- package/dist/SyncKeys.d.ts +5 -0
- package/dist/SyncKeys.js +41 -0
- package/dist/SyncState.d.ts +8 -0
- package/dist/SyncState.js +30 -0
- package/dist/Tax.d.ts +10 -0
- package/dist/Tax.js +30 -0
- package/dist/UserProfile.d.ts +16 -0
- package/dist/UserProfile.js +40 -0
- package/dist/WorkingDays.d.ts +33 -0
- package/dist/WorkingDays.js +121 -0
- package/dist/generated/Address.d.ts +77 -0
- package/dist/generated/Address.js +110 -0
- package/dist/generated/AddressList.d.ts +39 -0
- package/dist/generated/AddressList.js +60 -0
- package/dist/generated/AddressType.d.ts +15 -0
- package/dist/generated/AddressType.js +20 -0
- package/dist/generated/Attachment.d.ts +66 -0
- package/dist/generated/Attachment.js +89 -0
- package/dist/generated/AttachmentType.d.ts +154 -0
- package/dist/generated/AttachmentType.js +159 -0
- package/dist/generated/AuthTokens.d.ts +56 -0
- package/dist/generated/AuthTokens.js +74 -0
- package/dist/generated/AuthenticationMethod.d.ts +24 -0
- package/dist/generated/AuthenticationMethod.js +29 -0
- package/dist/generated/Business.d.ts +54 -0
- package/dist/generated/Business.js +75 -0
- package/dist/generated/BusinessIdentifier.d.ts +36 -0
- package/dist/generated/BusinessIdentifier.js +60 -0
- package/dist/generated/BusinessIdentifierType.d.ts +49 -0
- package/dist/generated/BusinessIdentifierType.js +54 -0
- package/dist/generated/BusinessLink.d.ts +76 -0
- package/dist/generated/BusinessLink.js +99 -0
- package/dist/generated/BusinessSyncInRequest.d.ts +42 -0
- package/dist/generated/BusinessSyncInRequest.js +60 -0
- package/dist/generated/BusinessSyncInResponse.d.ts +42 -0
- package/dist/generated/BusinessSyncInResponse.js +60 -0
- package/dist/generated/BusinessSyncOutRequest.d.ts +82 -0
- package/dist/generated/BusinessSyncOutRequest.js +107 -0
- package/dist/generated/BusinessSyncOutResponse.d.ts +106 -0
- package/dist/generated/BusinessSyncOutResponse.js +139 -0
- package/dist/generated/Configuration.d.ts +48 -0
- package/dist/generated/Configuration.js +63 -0
- package/dist/generated/Constants.d.ts +474 -0
- package/dist/generated/Constants.js +479 -0
- package/dist/generated/CreateUserRequest.d.ts +37 -0
- package/dist/generated/CreateUserRequest.js +59 -0
- package/dist/generated/DimensionUnit.d.ts +28 -0
- package/dist/generated/DimensionUnit.js +33 -0
- package/dist/generated/Dimensions.d.ts +41 -0
- package/dist/generated/Dimensions.js +76 -0
- package/dist/generated/Entity.d.ts +62 -0
- package/dist/generated/Entity.js +83 -0
- package/dist/generated/FulfillmentMode.d.ts +32 -0
- package/dist/generated/FulfillmentMode.js +37 -0
- package/dist/generated/GeneralSettings.d.ts +141 -0
- package/dist/generated/GeneralSettings.js +186 -0
- package/dist/generated/Item.d.ts +54 -0
- package/dist/generated/Item.js +82 -0
- package/dist/generated/LatLong.d.ts +36 -0
- package/dist/generated/LatLong.js +59 -0
- package/dist/generated/Message.d.ts +80 -0
- package/dist/generated/Message.js +114 -0
- package/dist/generated/MessageType.d.ts +34 -0
- package/dist/generated/MessageType.js +39 -0
- package/dist/generated/OrderStatus.d.ts +50 -0
- package/dist/generated/OrderStatus.js +55 -0
- package/dist/generated/Package.d.ts +63 -0
- package/dist/generated/Package.js +92 -0
- package/dist/generated/PackageIdentifier.d.ts +36 -0
- package/dist/generated/PackageIdentifier.js +60 -0
- package/dist/generated/PackageIdentifierType.d.ts +49 -0
- package/dist/generated/PackageIdentifierType.js +54 -0
- package/dist/generated/PartyPreferencesPayload.d.ts +41 -0
- package/dist/generated/PartyPreferencesPayload.js +60 -0
- package/dist/generated/PaymentMethod.d.ts +20 -0
- package/dist/generated/PaymentMethod.js +25 -0
- package/dist/generated/PaymentMethodDetail.d.ts +37 -0
- package/dist/generated/PaymentMethodDetail.js +59 -0
- package/dist/generated/Price.d.ts +52 -0
- package/dist/generated/Price.js +75 -0
- package/dist/generated/PriceList.d.ts +34 -0
- package/dist/generated/PriceList.js +51 -0
- package/dist/generated/Product.d.ts +77 -0
- package/dist/generated/Product.js +106 -0
- package/dist/generated/ProductCategory.d.ts +32 -0
- package/dist/generated/ProductCategory.js +51 -0
- package/dist/generated/ProductType.d.ts +42 -0
- package/dist/generated/ProductType.js +47 -0
- package/dist/generated/ProfileSyncOutRequest.d.ts +51 -0
- package/dist/generated/ProfileSyncOutRequest.js +75 -0
- package/dist/generated/ProfileSyncOutResponse.d.ts +56 -0
- package/dist/generated/ProfileSyncOutResponse.js +77 -0
- package/dist/generated/ReservedPackage.d.ts +34 -0
- package/dist/generated/ReservedPackage.js +39 -0
- package/dist/generated/Role.d.ts +71 -0
- package/dist/generated/Role.js +76 -0
- package/dist/generated/SalesOrderPayload.d.ts +85 -0
- package/dist/generated/SalesOrderPayload.js +123 -0
- package/dist/generated/ShoppingList.d.ts +99 -0
- package/dist/generated/ShoppingList.js +132 -0
- package/dist/generated/ShoppingListItem.d.ts +102 -0
- package/dist/generated/ShoppingListItem.js +139 -0
- package/dist/generated/TaskStatus.d.ts +20 -0
- package/dist/generated/TaskStatus.js +25 -0
- package/dist/generated/Tax.d.ts +37 -0
- package/dist/generated/Tax.js +60 -0
- package/dist/generated/TaxType.d.ts +25 -0
- package/dist/generated/TaxType.js +30 -0
- package/dist/generated/UrlAndToken.d.ts +54 -0
- package/dist/generated/UrlAndToken.js +67 -0
- package/dist/generated/User.d.ts +63 -0
- package/dist/generated/User.js +89 -0
- package/dist/generated/Weight.d.ts +33 -0
- package/dist/generated/Weight.js +60 -0
- package/dist/generated/WeightUnit.d.ts +28 -0
- package/dist/generated/WeightUnit.js +33 -0
- package/dist/generated/WorkingDays.d.ts +42 -0
- package/dist/generated/WorkingDays.js +68 -0
- package/dist/generated/WorkingHours.d.ts +33 -0
- package/dist/generated/WorkingHours.js +52 -0
- package/dist/generated/WorkingHoursRange.d.ts +42 -0
- package/dist/generated/WorkingHoursRange.js +59 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +60 -0
- package/package.json +55 -0
package/dist/Enums.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { AddressType } from "./generated/AddressType";
|
|
2
|
+
export { AttachmentType } from "./generated/AttachmentType";
|
|
3
|
+
export { AuthenticationMethod } from "./generated/AuthenticationMethod";
|
|
4
|
+
export { BusinessIdentifierType } from "./generated/BusinessIdentifierType";
|
|
5
|
+
export { DimensionUnit } from "./generated/DimensionUnit";
|
|
6
|
+
export { FulfillmentMode } from "./generated/FulfillmentMode";
|
|
7
|
+
export { MessageType } from "./generated/MessageType";
|
|
8
|
+
export { OrderStatus } from "./generated/OrderStatus";
|
|
9
|
+
export { PackageIdentifierType } from "./generated/PackageIdentifierType";
|
|
10
|
+
export { PaymentMethod } from "./generated/PaymentMethod";
|
|
11
|
+
export { ProductType } from "./generated/ProductType";
|
|
12
|
+
export { ReservedPackage } from "./generated/ReservedPackage";
|
|
13
|
+
export { Role } from "./generated/Role";
|
|
14
|
+
export { TaskStatus } from "./generated/TaskStatus";
|
|
15
|
+
export { TaxType } from "./generated/TaxType";
|
|
16
|
+
export { WeightUnit } from "./generated/WeightUnit";
|
package/dist/Enums.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Every enum of the protocol, re-exported under its own name so their Java-defined numeric ids
|
|
2
|
+
// have only one place to be wrong, and this file records which enums are part of the library's surface.
|
|
3
|
+
export { AddressType } from "./generated/AddressType";
|
|
4
|
+
export { AttachmentType } from "./generated/AttachmentType";
|
|
5
|
+
export { AuthenticationMethod } from "./generated/AuthenticationMethod";
|
|
6
|
+
export { BusinessIdentifierType } from "./generated/BusinessIdentifierType";
|
|
7
|
+
export { DimensionUnit } from "./generated/DimensionUnit";
|
|
8
|
+
export { FulfillmentMode } from "./generated/FulfillmentMode";
|
|
9
|
+
export { MessageType } from "./generated/MessageType";
|
|
10
|
+
export { OrderStatus } from "./generated/OrderStatus";
|
|
11
|
+
export { PackageIdentifierType } from "./generated/PackageIdentifierType";
|
|
12
|
+
export { PaymentMethod } from "./generated/PaymentMethod";
|
|
13
|
+
export { ProductType } from "./generated/ProductType";
|
|
14
|
+
export { ReservedPackage } from "./generated/ReservedPackage";
|
|
15
|
+
export { Role } from "./generated/Role";
|
|
16
|
+
export { TaskStatus } from "./generated/TaskStatus";
|
|
17
|
+
export { TaxType } from "./generated/TaxType";
|
|
18
|
+
export { WeightUnit } from "./generated/WeightUnit";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The two failures this library raises; both are programming errors, not conditions a UI recovers
|
|
2
|
+
// from (a sync failure surfaces as a rejected promise instead).
|
|
3
|
+
// A caller passed something this library cannot work with
|
|
4
|
+
export class InvalidArgumentException extends Error {
|
|
5
|
+
}
|
|
6
|
+
// A caller did something in an order this library does not allow
|
|
7
|
+
export class IllegalOperationException extends Error {
|
|
8
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FulfillmentMode as proto_FulfillmentMode } from "./generated/FulfillmentMode";
|
|
2
|
+
import { AddressList } from "./Address";
|
|
3
|
+
import BusinessIdentifier from "./BusinessIdentifier";
|
|
4
|
+
import LatLong from "./LatLong";
|
|
5
|
+
import PaymentMethodDetail from "./PaymentMethodDetail";
|
|
6
|
+
import Tax from "./Tax";
|
|
7
|
+
import WorkingDays from "./WorkingDays";
|
|
8
|
+
export default class GeneralSettings {
|
|
9
|
+
private readonly _paymentMethodDetails;
|
|
10
|
+
private readonly _customerServicePhone;
|
|
11
|
+
private readonly _isWhatsAppSupported;
|
|
12
|
+
private readonly _isSmsSupported;
|
|
13
|
+
private readonly _businessAddresses;
|
|
14
|
+
private readonly _businessIdentifiers;
|
|
15
|
+
private readonly _fulfillmentModes;
|
|
16
|
+
private readonly _deliveryCharge;
|
|
17
|
+
private readonly _deliveryChargeTaxes;
|
|
18
|
+
private readonly _freeDeliveryTotal;
|
|
19
|
+
private readonly _deliveryRadiusKilometres;
|
|
20
|
+
private readonly _storeTagline;
|
|
21
|
+
private readonly _workingDays;
|
|
22
|
+
private readonly _primaryStoreLocation;
|
|
23
|
+
private readonly _googleBusinessCategoryId;
|
|
24
|
+
private readonly _googleBusinessCategoryName;
|
|
25
|
+
private readonly _onlineStoreThemeId;
|
|
26
|
+
static fromScaledValues(paymentMethodDetails: ReadonlyArray<PaymentMethodDetail>, customerServicePhone: string | null, isWhatsAppSupported: boolean, isSmsSupported: boolean, businessAddresses: AddressList, businessIdentifiers: ReadonlyArray<BusinessIdentifier>, fulfillmentModes: ReadonlyArray<proto_FulfillmentMode>, scaledDeliveryCharge: bigint, deliveryChargeTaxes: ReadonlyArray<Tax>, scaledFreeDeliveryTotal: bigint, deliveryRadiusKilometres: number, storeTagline: string | null, workingDays: WorkingDays, primaryStoreLocation: LatLong | null, googleBusinessCategoryId: string | null, googleBusinessCategoryName: string | null, onlineStoreThemeId: string | null): GeneralSettings;
|
|
27
|
+
constructor(_paymentMethodDetails: ReadonlyArray<PaymentMethodDetail>, _customerServicePhone: string | null, _isWhatsAppSupported: boolean, _isSmsSupported: boolean, _businessAddresses: AddressList, _businessIdentifiers: ReadonlyArray<BusinessIdentifier>, _fulfillmentModes: ReadonlyArray<proto_FulfillmentMode>, _deliveryCharge: number, _deliveryChargeTaxes: ReadonlyArray<Tax>, _freeDeliveryTotal: number, _deliveryRadiusKilometres: number, _storeTagline: string | null, _workingDays: WorkingDays, _primaryStoreLocation: LatLong | null, _googleBusinessCategoryId: string | null, _googleBusinessCategoryName: string | null, _onlineStoreThemeId: string | null);
|
|
28
|
+
get paymentMethodDetails(): ReadonlyArray<PaymentMethodDetail>;
|
|
29
|
+
get customerServicePhone(): string | null;
|
|
30
|
+
get isWhatsAppSupported(): boolean;
|
|
31
|
+
get isSmsSupported(): boolean;
|
|
32
|
+
get businessAddresses(): AddressList;
|
|
33
|
+
get businessIdentifiers(): ReadonlyArray<BusinessIdentifier>;
|
|
34
|
+
get fulfillmentModes(): ReadonlyArray<proto_FulfillmentMode>;
|
|
35
|
+
get deliveryCharge(): number;
|
|
36
|
+
get deliveryChargeTaxes(): ReadonlyArray<Tax>;
|
|
37
|
+
get freeDeliveryTotal(): number;
|
|
38
|
+
get deliveryRadiusKilometres(): number;
|
|
39
|
+
get storeTagline(): string | null;
|
|
40
|
+
get workingDays(): WorkingDays;
|
|
41
|
+
get primaryStoreLocation(): LatLong | null;
|
|
42
|
+
get googleBusinessCategoryId(): string | null;
|
|
43
|
+
get googleBusinessCategoryName(): string | null;
|
|
44
|
+
get onlineStoreThemeId(): string | null;
|
|
45
|
+
static readonly EMPTY: GeneralSettings;
|
|
46
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AddressList } from "./Address";
|
|
2
|
+
import { amountFromScaledValue } from "./Constants";
|
|
3
|
+
import WorkingDays from "./WorkingDays";
|
|
4
|
+
// The publicly visible settings of a business: tagline, contact info, location, fulfillment,
|
|
5
|
+
// payment and delivery options, and how its online store is presented.
|
|
6
|
+
// Not an entity - it's the value unwrapped from the one public Configuration a storefront is sent; merchant-only fields are excluded.
|
|
7
|
+
class GeneralSettings {
|
|
8
|
+
// Only ProtoMap calls this: it is the one place that sees amounts still multiplied by
|
|
9
|
+
// Constants.AMOUNT_FACTOR.
|
|
10
|
+
static fromScaledValues(paymentMethodDetails, customerServicePhone, isWhatsAppSupported, isSmsSupported, businessAddresses, businessIdentifiers, fulfillmentModes, scaledDeliveryCharge, deliveryChargeTaxes, scaledFreeDeliveryTotal, deliveryRadiusKilometres, storeTagline, workingDays, primaryStoreLocation, googleBusinessCategoryId, googleBusinessCategoryName, onlineStoreThemeId) {
|
|
11
|
+
return new GeneralSettings(paymentMethodDetails, customerServicePhone, isWhatsAppSupported, isSmsSupported, businessAddresses, businessIdentifiers, fulfillmentModes, amountFromScaledValue(scaledDeliveryCharge), deliveryChargeTaxes, amountFromScaledValue(scaledFreeDeliveryTotal), deliveryRadiusKilometres, storeTagline, workingDays, primaryStoreLocation, googleBusinessCategoryId, googleBusinessCategoryName, onlineStoreThemeId);
|
|
12
|
+
}
|
|
13
|
+
constructor(_paymentMethodDetails, _customerServicePhone, _isWhatsAppSupported, _isSmsSupported, _businessAddresses, _businessIdentifiers, _fulfillmentModes, _deliveryCharge, _deliveryChargeTaxes, _freeDeliveryTotal, _deliveryRadiusKilometres, _storeTagline, _workingDays, _primaryStoreLocation, _googleBusinessCategoryId, _googleBusinessCategoryName, _onlineStoreThemeId) {
|
|
14
|
+
this._paymentMethodDetails = _paymentMethodDetails;
|
|
15
|
+
this._customerServicePhone = _customerServicePhone;
|
|
16
|
+
this._isWhatsAppSupported = _isWhatsAppSupported;
|
|
17
|
+
this._isSmsSupported = _isSmsSupported;
|
|
18
|
+
this._businessAddresses = _businessAddresses;
|
|
19
|
+
this._businessIdentifiers = _businessIdentifiers;
|
|
20
|
+
this._fulfillmentModes = _fulfillmentModes;
|
|
21
|
+
this._deliveryCharge = _deliveryCharge;
|
|
22
|
+
this._deliveryChargeTaxes = _deliveryChargeTaxes;
|
|
23
|
+
this._freeDeliveryTotal = _freeDeliveryTotal;
|
|
24
|
+
this._deliveryRadiusKilometres = _deliveryRadiusKilometres;
|
|
25
|
+
this._storeTagline = _storeTagline;
|
|
26
|
+
this._workingDays = _workingDays;
|
|
27
|
+
this._primaryStoreLocation = _primaryStoreLocation;
|
|
28
|
+
this._googleBusinessCategoryId = _googleBusinessCategoryId;
|
|
29
|
+
this._googleBusinessCategoryName = _googleBusinessCategoryName;
|
|
30
|
+
this._onlineStoreThemeId = _onlineStoreThemeId;
|
|
31
|
+
}
|
|
32
|
+
get paymentMethodDetails() {
|
|
33
|
+
return this._paymentMethodDetails;
|
|
34
|
+
}
|
|
35
|
+
// E.164 formatted, and null when the business has published no number
|
|
36
|
+
get customerServicePhone() {
|
|
37
|
+
return this._customerServicePhone;
|
|
38
|
+
}
|
|
39
|
+
get isWhatsAppSupported() {
|
|
40
|
+
return this._isWhatsAppSupported;
|
|
41
|
+
}
|
|
42
|
+
get isSmsSupported() {
|
|
43
|
+
return this._isSmsSupported;
|
|
44
|
+
}
|
|
45
|
+
get businessAddresses() {
|
|
46
|
+
return this._businessAddresses;
|
|
47
|
+
}
|
|
48
|
+
get businessIdentifiers() {
|
|
49
|
+
return this._businessIdentifiers;
|
|
50
|
+
}
|
|
51
|
+
// The modes this business offers, as a list rather than Java's bit mask. Empty means none published, not none offered.
|
|
52
|
+
get fulfillmentModes() {
|
|
53
|
+
return this._fulfillmentModes;
|
|
54
|
+
}
|
|
55
|
+
get deliveryCharge() {
|
|
56
|
+
return this._deliveryCharge;
|
|
57
|
+
}
|
|
58
|
+
// The taxes on the delivery charge, which are the business's own and not a product's - at most
|
|
59
|
+
// Constants.MAX_TAXES of them. Empty means the charge is untaxed.
|
|
60
|
+
get deliveryChargeTaxes() {
|
|
61
|
+
return this._deliveryChargeTaxes;
|
|
62
|
+
}
|
|
63
|
+
// Order total at or above which delivery is free. Zero means never free, not always free.
|
|
64
|
+
get freeDeliveryTotal() {
|
|
65
|
+
return this._freeDeliveryTotal;
|
|
66
|
+
}
|
|
67
|
+
// Constants.NO_RESTRICTIONS_DELIVERY_DISTANCE (zero) means there is no limit
|
|
68
|
+
get deliveryRadiusKilometres() {
|
|
69
|
+
return this._deliveryRadiusKilometres;
|
|
70
|
+
}
|
|
71
|
+
get storeTagline() {
|
|
72
|
+
return this._storeTagline;
|
|
73
|
+
}
|
|
74
|
+
// Absent working days default to WorkingDays.ALL_DAYS (Java's default), never left null here.
|
|
75
|
+
get workingDays() {
|
|
76
|
+
return this._workingDays;
|
|
77
|
+
}
|
|
78
|
+
// Where this business is: the coordinates of the first of businessAddresses. Null when the
|
|
79
|
+
// business has not published them.
|
|
80
|
+
get primaryStoreLocation() {
|
|
81
|
+
return this._primaryStoreLocation;
|
|
82
|
+
}
|
|
83
|
+
// What kind of business this is, as its Google Business Profile category - "Bakery", say. The
|
|
84
|
+
// name is the one to show; the id is the stable one to match on.
|
|
85
|
+
get googleBusinessCategoryId() {
|
|
86
|
+
return this._googleBusinessCategoryId;
|
|
87
|
+
}
|
|
88
|
+
get googleBusinessCategoryName() {
|
|
89
|
+
return this._googleBusinessCategoryName;
|
|
90
|
+
}
|
|
91
|
+
// Which of a storefront's own themes this business picked. The themes are the storefront's, so
|
|
92
|
+
// what an id means is its business and not this library's; null when none was picked.
|
|
93
|
+
get onlineStoreThemeId() {
|
|
94
|
+
return this._onlineStoreThemeId;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// A business with no published public settings, used instead of null so every field is already the protocol's empty value.
|
|
98
|
+
GeneralSettings.EMPTY = new GeneralSettings(Object.freeze([]), null, false, false, AddressList.EMPTY, Object.freeze([]), Object.freeze([]), 0, Object.freeze([]), 0, 0, null, WorkingDays.ALL_DAYS, null, null, null, null);
|
|
99
|
+
export default GeneralSettings;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BadRequestException, ConflictException, InternalServerException, MethodNotAllowedException, NotFoundException, ServiceException, ServiceUnavailableException, UnauthorizedException, UpgradeRequiredException, } from "./ServiceExceptions";
|
|
2
|
+
// Which failure a status code stands for, and nothing else - the classes themselves are in
|
|
3
|
+
// ServiceExceptions.ts. Split the same way Java splits HttpStatusCodes from its exception package,
|
|
4
|
+
// so that the one table saying "401 means this" has a single home in each client.
|
|
5
|
+
// Everything from 300 up, this being Java's HttpURLConnection.HTTP_MULT_CHOICE. A redirect counts as
|
|
6
|
+
// a failure because this client asks for one route and follows nothing, so being sent elsewhere
|
|
7
|
+
// means the call did not happen.
|
|
8
|
+
export function isError(httpStatusCode) {
|
|
9
|
+
return httpStatusCode >= LOWEST_ERROR_STATUS_CODE;
|
|
10
|
+
}
|
|
11
|
+
// Raises the failure a status code stands for, and does nothing at all for one that is not an error.
|
|
12
|
+
// A code with no class of its own is still a ServiceException carrying the code, so a server that
|
|
13
|
+
// starts answering something new cannot slip past as a success.
|
|
14
|
+
export function throwOnError(httpStatusCode, message) {
|
|
15
|
+
if (!isError(httpStatusCode))
|
|
16
|
+
return;
|
|
17
|
+
const create = EXCEPTIONS.get(httpStatusCode);
|
|
18
|
+
if (create === undefined)
|
|
19
|
+
throw new ServiceException(httpStatusCode, message);
|
|
20
|
+
throw create(message);
|
|
21
|
+
}
|
|
22
|
+
const LOWEST_ERROR_STATUS_CODE = 300;
|
|
23
|
+
// Java builds this by reflection over a map of classes; here each entry constructs its own, because
|
|
24
|
+
// a constructor reached through a type is what keeps this checked at compile time.
|
|
25
|
+
const EXCEPTIONS = new Map([
|
|
26
|
+
[BadRequestException.STATUS_CODE, (message) => new BadRequestException(message)],
|
|
27
|
+
[UnauthorizedException.STATUS_CODE, (message) => new UnauthorizedException(message)],
|
|
28
|
+
[NotFoundException.STATUS_CODE, (message) => new NotFoundException(message)],
|
|
29
|
+
[MethodNotAllowedException.STATUS_CODE, (message) => new MethodNotAllowedException(message)],
|
|
30
|
+
[ConflictException.STATUS_CODE, (message) => new ConflictException(message)],
|
|
31
|
+
[UpgradeRequiredException.STATUS_CODE, (message) => new UpgradeRequiredException(message)],
|
|
32
|
+
[InternalServerException.STATUS_CODE, (message) => new InternalServerException(message)],
|
|
33
|
+
[ServiceUnavailableException.STATUS_CODE, (message) => new ServiceUnavailableException(message)],
|
|
34
|
+
]);
|
package/dist/Ids.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default class Ids {
|
|
2
|
+
static getEntityTypeId(id: bigint): number;
|
|
3
|
+
static getLowPart(id: bigint): bigint;
|
|
4
|
+
static buildId(entityTypeId: number, lowPart: bigint): bigint;
|
|
5
|
+
static getPartyPreferencesMessageId(businessLinkId: bigint): bigint;
|
|
6
|
+
static getNewId(entityTypeId: number): bigint;
|
|
7
|
+
static isReservedPackageId(packageId: bigint): boolean;
|
|
8
|
+
static toStorageHexString(id: bigint): string;
|
|
9
|
+
static toOrderNumberString(orderId: bigint): string;
|
|
10
|
+
static readonly ENTITY_TYPE_BIT_SHIFT: bigint;
|
|
11
|
+
static readonly ID_MASK: bigint;
|
|
12
|
+
static readonly GENERAL_SETTINGS_CONFIGURATION_ID: bigint;
|
|
13
|
+
static readonly ATTACHMENT_BASE_URL_BLOB_ID: bigint;
|
|
14
|
+
static readonly AUTH_TOKENS_BLOB_ID: bigint;
|
|
15
|
+
private static readonly UNSIGNED_64_BIT_MASK;
|
|
16
|
+
private static readonly UNSIGNED_32_BIT_MASK;
|
|
17
|
+
}
|
package/dist/Ids.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Constants as proto_Constants } from "./generated/Constants";
|
|
2
|
+
import { ReservedPackage as proto_ReservedPackage } from "./generated/ReservedPackage";
|
|
3
|
+
// Everything this library knows about entity id layout. Ids are built/read only here, since a 64-bit shift written in number arithmetic silently loses the entity type.
|
|
4
|
+
// Some ids below are not entity ids but local-store blob ids; they're negative, which can never collide with a real id (whose sign bit is always clear).
|
|
5
|
+
class Ids {
|
|
6
|
+
// The most significant byte of an id: one of the *_ENTITY_TYPE_ID values of Constants.
|
|
7
|
+
static getEntityTypeId(id) {
|
|
8
|
+
return Number((id >> Ids.ENTITY_TYPE_BIT_SHIFT) & 0xffn);
|
|
9
|
+
}
|
|
10
|
+
// Everything below the entity type: partition id plus id within the partition.
|
|
11
|
+
static getLowPart(id) {
|
|
12
|
+
return id & Ids.ID_MASK;
|
|
13
|
+
}
|
|
14
|
+
static buildId(entityTypeId, lowPart) {
|
|
15
|
+
return (BigInt(entityTypeId) << Ids.ENTITY_TYPE_BIT_SHIFT) | (lowPart & Ids.ID_MASK);
|
|
16
|
+
}
|
|
17
|
+
// Where the cart of one membership lives: the business link id with the entity type swapped for
|
|
18
|
+
// the message one, which is Java Message.getPartyPreferencesMessageId. Derived rather than
|
|
19
|
+
// assigned so that a client always knows the id of its own cart without having been told it - a
|
|
20
|
+
// sync in answers with an update number and no id, so a cart the server named could not be stored
|
|
21
|
+
// here at all. One link therefore has one cart, and creating it twice is impossible by
|
|
22
|
+
// construction rather than by a check.
|
|
23
|
+
static getPartyPreferencesMessageId(businessLinkId) {
|
|
24
|
+
return Ids.buildId(proto_Constants.MESSAGE_ENTITY_TYPE_ID, Ids.getLowPart(businessLinkId));
|
|
25
|
+
}
|
|
26
|
+
// A fresh id for an entity this client is creating, to the rules of Java
|
|
27
|
+
// Entity.getRandomLongForId: random, and never in 0-255, which every entity type reserves. Only
|
|
28
|
+
// the low part is drawn, since buildId masks the rest off anyway, and it is drawn from the
|
|
29
|
+
// cryptographic generator rather than Math.random - an id is guessable otherwise, and a message id
|
|
30
|
+
// is a thing a caller could be handed.
|
|
31
|
+
static getNewId(entityTypeId) {
|
|
32
|
+
for (;;) {
|
|
33
|
+
const bytes = new Uint8Array(8);
|
|
34
|
+
crypto.getRandomValues(bytes);
|
|
35
|
+
let lowPart = 0n;
|
|
36
|
+
for (const byte of bytes)
|
|
37
|
+
lowPart = (lowPart << 8n) | BigInt(byte);
|
|
38
|
+
lowPart &= Ids.ID_MASK;
|
|
39
|
+
if (lowPart > BigInt(proto_Constants.ENTITY_ID_UNASSIGNED))
|
|
40
|
+
return Ids.buildId(entityTypeId, lowPart);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// The charge/summary lines of a shopping list carry one of these instead of a real catalog package id.
|
|
44
|
+
static isReservedPackageId(packageId) {
|
|
45
|
+
return (Ids.getEntityTypeId(packageId) === proto_Constants.PACKAGE_ENTITY_TYPE_ID &&
|
|
46
|
+
Ids.getLowPart(packageId) <= BigInt(proto_ReservedPackage.SERVICE_CHARGE_PACKAGE));
|
|
47
|
+
}
|
|
48
|
+
// 16 upper-case hex digits, zero-padded, no 0x prefix - the attachment blob file name format (case sensitive).
|
|
49
|
+
// Masked to 64 bits first so a negative bigint prints as Java's unsigned twos complement instead of with a minus sign.
|
|
50
|
+
static toStorageHexString(id) {
|
|
51
|
+
return (id & Ids.UNSIGNED_64_BIT_MASK).toString(16).toUpperCase().padStart(16, "0");
|
|
52
|
+
}
|
|
53
|
+
// The number an order is shown under: the least significant 32 bits of the id of the message
|
|
54
|
+
// carrying it, as upper-case hex, not zero-padded. That is Java MessageBuilder.formatId, and it
|
|
55
|
+
// has to match character for character - the merchant app shows the same order under the same
|
|
56
|
+
// number, and a customer quoting one over the phone is the whole point of having it. An order
|
|
57
|
+
// number is therefore derived and not a field of the protocol.
|
|
58
|
+
// Java narrows with a cast to signed int and formats with %X, which prints the unsigned 32-bit
|
|
59
|
+
// twos complement; masking here answers the same string without the sign getting in the way.
|
|
60
|
+
// The merchant app prefixes the word "Order"; whether to do that is a UI's decision, not this one.
|
|
61
|
+
static toOrderNumberString(orderId) {
|
|
62
|
+
return (orderId & Ids.UNSIGNED_32_BIT_MASK).toString(16).toUpperCase();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
Ids.ENTITY_TYPE_BIT_SHIFT = BigInt(proto_Constants.ENTITY_TYPE_BIT_SHIFT);
|
|
66
|
+
// Everything an id holds below its entity type; not in Constants.proto since 64 bits don't fit an enum value.
|
|
67
|
+
Ids.ID_MASK = (1n << BigInt(proto_Constants.ENTITY_TYPE_BIT_SHIFT)) - 1n;
|
|
68
|
+
// The configuration holding a business's public settings - the only one sent to a storefront (Java Configuration.MIN_PUBLIC_CONFIGURATION_ID).
|
|
69
|
+
Ids.GENERAL_SETTINGS_CONFIGURATION_ID = 0x0d10000000000000n;
|
|
70
|
+
// A price list id is built by Constants.buildPriceListId rather than named here: which built-in
|
|
71
|
+
// lists exist is a fact of the protocol, and only their low parts are constants of it.
|
|
72
|
+
// Where a business container keeps that business's attachment base url; its eTag is that url's expiry.
|
|
73
|
+
Ids.ATTACHMENT_BASE_URL_BLOB_ID = -1n;
|
|
74
|
+
// Where a container keeps the credentials that sign its calls - see AuthTokens. Written with a null eTag, since a reissued token is not a later version of an earlier one: the latest simply wins.
|
|
75
|
+
Ids.AUTH_TOKENS_BLOB_ID = -2n;
|
|
76
|
+
Ids.UNSIGNED_64_BIT_MASK = (1n << 64n) - 1n;
|
|
77
|
+
Ids.UNSIGNED_32_BIT_MASK = (1n << 32n) - 1n;
|
|
78
|
+
export default Ids;
|
package/dist/Item.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Entity, { EntityHeader } from "./Entity";
|
|
2
|
+
export default abstract class Item extends Entity {
|
|
3
|
+
private readonly _name;
|
|
4
|
+
private readonly _description;
|
|
5
|
+
private readonly _parentItemId;
|
|
6
|
+
private readonly _isDisabled;
|
|
7
|
+
constructor(header: EntityHeader, _name: string, _description: string | null, _parentItemId: bigint, _isDisabled: boolean);
|
|
8
|
+
get name(): string;
|
|
9
|
+
get description(): string | null;
|
|
10
|
+
get parentItemId(): bigint;
|
|
11
|
+
get isDisabled(): boolean;
|
|
12
|
+
}
|
package/dist/Item.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Entity from "./Entity";
|
|
2
|
+
// Something a business buys or sells, or a category or a price thereof - mirrors the protocol's Item, embedded in each of the five real types.
|
|
3
|
+
// parentItemId is the wire parent (e.g. a product's category), distinct from Entity.parent, the sync layer's containment parent (e.g. the business).
|
|
4
|
+
export default class Item extends Entity {
|
|
5
|
+
// Public rather than protected since ProductCategory/PriceList add nothing of their own; the class stays abstract, so still uninstantiable directly.
|
|
6
|
+
constructor(header, _name, _description, _parentItemId, _isDisabled) {
|
|
7
|
+
super(header);
|
|
8
|
+
this._name = _name;
|
|
9
|
+
this._description = _description;
|
|
10
|
+
this._parentItemId = _parentItemId;
|
|
11
|
+
this._isDisabled = _isDisabled;
|
|
12
|
+
}
|
|
13
|
+
get name() {
|
|
14
|
+
return this._name;
|
|
15
|
+
}
|
|
16
|
+
get description() {
|
|
17
|
+
return this._description;
|
|
18
|
+
}
|
|
19
|
+
// Constants.ENTITY_ID_NULL when this item has no parent (e.g. an uncategorized product, or a price list).
|
|
20
|
+
get parentItemId() {
|
|
21
|
+
return this._parentItemId;
|
|
22
|
+
}
|
|
23
|
+
// True when the business has disabled this item. Unlike isPublic and Product.isDraft, this can
|
|
24
|
+
// change after an item exists, so it is sent rather than filtered out once and for all - a
|
|
25
|
+
// product-level filter (Catalog.getCustomerVisibleProducts) does not, by itself, guarantee that
|
|
26
|
+
// every package of an otherwise visible product is itself enabled.
|
|
27
|
+
get isDisabled() {
|
|
28
|
+
return this._isDisabled;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/LatLong.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// A point on Earth. Not an entity - a value on GeneralSettings, where it is the business's own
|
|
2
|
+
// location. Degrees, and nothing here converts or formats them: whether that becomes a map pin, a
|
|
3
|
+
// distance or a link is a UI's decision.
|
|
4
|
+
export default class LatLong {
|
|
5
|
+
constructor(_latitude, _longitude) {
|
|
6
|
+
this._latitude = _latitude;
|
|
7
|
+
this._longitude = _longitude;
|
|
8
|
+
}
|
|
9
|
+
// Between Constants.MIN_LATITUDE and Constants.MAX_LATITUDE
|
|
10
|
+
get latitude() {
|
|
11
|
+
return this._latitude;
|
|
12
|
+
}
|
|
13
|
+
// Between Constants.MIN_LONGITUDE and Constants.MAX_LONGITUDE
|
|
14
|
+
get longitude() {
|
|
15
|
+
return this._longitude;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default class LiveData<TValue> implements Observable<TValue>, UpdatableLiveData<TValue> {
|
|
2
|
+
constructor(value: TValue);
|
|
3
|
+
get value(): TValue;
|
|
4
|
+
private set value(value);
|
|
5
|
+
get holder(): StateHolder<TValue>;
|
|
6
|
+
get observerCount(): number;
|
|
7
|
+
observe(observer: Observer<TValue>, notifyImmediately?: boolean): () => void;
|
|
8
|
+
unobserve(observer: Observer<TValue>): void;
|
|
9
|
+
private notifyObservers;
|
|
10
|
+
private static readonly NOT_NOTIFIED;
|
|
11
|
+
private readonly _observers;
|
|
12
|
+
private _holder;
|
|
13
|
+
private _version;
|
|
14
|
+
private _isNotifying;
|
|
15
|
+
private _isNotificationStale;
|
|
16
|
+
}
|
|
17
|
+
export declare class StateHolder<TValue> {
|
|
18
|
+
readonly value: TValue;
|
|
19
|
+
constructor(value: TValue);
|
|
20
|
+
}
|
|
21
|
+
export type Observer<TValue> = (holder: StateHolder<TValue>) => void;
|
|
22
|
+
export interface Observable<TValue> {
|
|
23
|
+
get value(): TValue;
|
|
24
|
+
get holder(): StateHolder<TValue>;
|
|
25
|
+
observe(observer: Observer<TValue>, notifyImmediately?: boolean): () => void;
|
|
26
|
+
unobserve(observer: Observer<TValue>): void;
|
|
27
|
+
}
|
|
28
|
+
export interface UpdatableLiveData<TValue> {
|
|
29
|
+
set value(value: TValue);
|
|
30
|
+
}
|
package/dist/LiveData.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// A value that notifies its observers whenever it is set - the Android LiveData of this library, what every storefront UI binds to.
|
|
2
|
+
// Deliberately skips LifecycleOwner and onActive/onInactive (no web equivalent / no need), and differs from mbl-model's Observations:
|
|
3
|
+
// observe() returns its own unobserve function, holder gives a stable snapshot for React, observers are a Map for O(1) removal, and a value set mid-notification restarts rather than interleaves.
|
|
4
|
+
class LiveData {
|
|
5
|
+
constructor(value) {
|
|
6
|
+
this._observers = new Map();
|
|
7
|
+
this._version = 0;
|
|
8
|
+
this._isNotifying = false;
|
|
9
|
+
this._isNotificationStale = false;
|
|
10
|
+
this._holder = new StateHolder(value);
|
|
11
|
+
}
|
|
12
|
+
get value() {
|
|
13
|
+
return this._holder.value;
|
|
14
|
+
}
|
|
15
|
+
// Private - only the sync layer (via an UpdatableLiveData cast) can set the value; a UI can only read/observe.
|
|
16
|
+
set value(value) {
|
|
17
|
+
// Always replaces the holder and notifies, even with the same reference - the interior may have changed and this class can't tell.
|
|
18
|
+
++this._version;
|
|
19
|
+
this._holder = new StateHolder(value);
|
|
20
|
+
this.notifyObservers();
|
|
21
|
+
}
|
|
22
|
+
// The current value, wrapped so its identity changes exactly once per notification; use this instead of value for reference-equality snapshot comparisons.
|
|
23
|
+
get holder() {
|
|
24
|
+
return this._holder;
|
|
25
|
+
}
|
|
26
|
+
get observerCount() {
|
|
27
|
+
return this._observers.size;
|
|
28
|
+
}
|
|
29
|
+
// Returns the function that stops this observer observing. Observing twice with the same function only observes once.
|
|
30
|
+
observe(observer, notifyImmediately = false) {
|
|
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).
|
|
33
|
+
this._observers.set(observer, notifyImmediately ? LiveData.NOT_NOTIFIED : this._version);
|
|
34
|
+
}
|
|
35
|
+
if (notifyImmediately)
|
|
36
|
+
this.notifyObservers();
|
|
37
|
+
return () => this.unobserve(observer);
|
|
38
|
+
}
|
|
39
|
+
unobserve(observer) {
|
|
40
|
+
this._observers.delete(observer);
|
|
41
|
+
}
|
|
42
|
+
notifyObservers() {
|
|
43
|
+
if (this._isNotifying) {
|
|
44
|
+
// An observer set a value while being notified; mark stale so the running notification restarts with the newer value instead of nesting.
|
|
45
|
+
this._isNotificationStale = true;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this._isNotifying = true;
|
|
49
|
+
try {
|
|
50
|
+
do {
|
|
51
|
+
this._isNotificationStale = false;
|
|
52
|
+
// Safe to mutate the Map during iteration: an entry added during the loop is reached, one removed is skipped.
|
|
53
|
+
for (const observer of this._observers.keys()) {
|
|
54
|
+
if (this._isNotificationStale)
|
|
55
|
+
break; // Start again with the newer value
|
|
56
|
+
if (this._observers.get(observer) === this._version)
|
|
57
|
+
continue; // Already told
|
|
58
|
+
this._observers.set(observer, this._version);
|
|
59
|
+
observer(this._holder);
|
|
60
|
+
}
|
|
61
|
+
} while (this._isNotificationStale);
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
this._isNotifying = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Lower than the version of any value, so that an observer marked with it is always notified
|
|
69
|
+
LiveData.NOT_NOTIFIED = -1;
|
|
70
|
+
export default LiveData;
|
|
71
|
+
// Wraps a value so every notification carries a new object, since React ignores a setState call whose argument is the object it already holds.
|
|
72
|
+
export class StateHolder {
|
|
73
|
+
constructor(value) {
|
|
74
|
+
this.value = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DimensionUnit as proto_DimensionUnit } from "./generated/DimensionUnit";
|
|
2
|
+
import { WeightUnit as proto_WeightUnit } from "./generated/WeightUnit";
|
|
3
|
+
export declare class Dimensions {
|
|
4
|
+
private readonly _unit;
|
|
5
|
+
private readonly _length;
|
|
6
|
+
private readonly _width;
|
|
7
|
+
private readonly _height;
|
|
8
|
+
constructor(_unit: proto_DimensionUnit, _length: number, _width: number, _height: number);
|
|
9
|
+
get unit(): proto_DimensionUnit;
|
|
10
|
+
get length(): number;
|
|
11
|
+
get width(): number;
|
|
12
|
+
get height(): number;
|
|
13
|
+
}
|
|
14
|
+
export declare class Weight {
|
|
15
|
+
private readonly _unit;
|
|
16
|
+
private readonly _value;
|
|
17
|
+
constructor(_unit: proto_WeightUnit, _value: number);
|
|
18
|
+
get unit(): proto_WeightUnit;
|
|
19
|
+
get value(): number;
|
|
20
|
+
}
|
package/dist/Measures.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// How big a package is, and how much it weighs - grouped together 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, so a value displays in whatever unit the merchant entered it in; nothing here converts between units.
|
|
3
|
+
export class Dimensions {
|
|
4
|
+
constructor(_unit, _length, _width, _height) {
|
|
5
|
+
this._unit = _unit;
|
|
6
|
+
this._length = _length;
|
|
7
|
+
this._width = _width;
|
|
8
|
+
this._height = _height;
|
|
9
|
+
}
|
|
10
|
+
get unit() {
|
|
11
|
+
return this._unit;
|
|
12
|
+
}
|
|
13
|
+
get length() {
|
|
14
|
+
return this._length;
|
|
15
|
+
}
|
|
16
|
+
get width() {
|
|
17
|
+
return this._width;
|
|
18
|
+
}
|
|
19
|
+
get height() {
|
|
20
|
+
return this._height;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class Weight {
|
|
24
|
+
constructor(_unit, _value) {
|
|
25
|
+
this._unit = _unit;
|
|
26
|
+
this._value = _value;
|
|
27
|
+
}
|
|
28
|
+
get unit() {
|
|
29
|
+
return this._unit;
|
|
30
|
+
}
|
|
31
|
+
get value() {
|
|
32
|
+
return this._value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MessageType as proto_MessageType } from "./generated/MessageType";
|
|
2
|
+
import { TaskStatus as proto_TaskStatus } from "./generated/TaskStatus";
|
|
3
|
+
import Entity, { EntityHeader } from "./Entity";
|
|
4
|
+
export default abstract class Message extends Entity {
|
|
5
|
+
private readonly _senderId;
|
|
6
|
+
private readonly _messageType;
|
|
7
|
+
private readonly _taskStatus;
|
|
8
|
+
private readonly _senderName;
|
|
9
|
+
private readonly _senderPhone;
|
|
10
|
+
protected constructor(header: EntityHeader, _senderId: bigint, _messageType: proto_MessageType, _taskStatus: proto_TaskStatus, _senderName: string | null, _senderPhone: string | null);
|
|
11
|
+
get senderId(): bigint;
|
|
12
|
+
get messageType(): proto_MessageType;
|
|
13
|
+
get taskStatus(): proto_TaskStatus;
|
|
14
|
+
get senderName(): string | null;
|
|
15
|
+
get senderPhone(): string | null;
|
|
16
|
+
}
|
package/dist/Message.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Entity from "./Entity";
|
|
2
|
+
// Something a customer sent to a business: an order (sales order) or a shopping cart (party preferences) - the two payloads this library understands.
|
|
3
|
+
// A business entity despite being customer-authored, since Java authorizes the message table via Right.MESSAGES_MODIFY against the business.
|
|
4
|
+
export default class Message extends Entity {
|
|
5
|
+
constructor(header, _senderId, _messageType, _taskStatus, _senderName, _senderPhone) {
|
|
6
|
+
super(header);
|
|
7
|
+
this._senderId = _senderId;
|
|
8
|
+
this._messageType = _messageType;
|
|
9
|
+
this._taskStatus = _taskStatus;
|
|
10
|
+
this._senderName = _senderName;
|
|
11
|
+
this._senderPhone = _senderPhone;
|
|
12
|
+
}
|
|
13
|
+
// The customer's User id; a business sync out doesn't carry it, so it's resolvable only against a profile sync out.
|
|
14
|
+
// senderName/senderPhone below are the fallback a UI shows meanwhile, and all an anonymous client ever has.
|
|
15
|
+
get senderId() {
|
|
16
|
+
return this._senderId;
|
|
17
|
+
}
|
|
18
|
+
get messageType() {
|
|
19
|
+
return this._messageType;
|
|
20
|
+
}
|
|
21
|
+
// How far the business has got with this message. Named after its enum, not the wire field "status", to avoid clashing with Order.status.
|
|
22
|
+
get taskStatus() {
|
|
23
|
+
return this._taskStatus;
|
|
24
|
+
}
|
|
25
|
+
get senderName() {
|
|
26
|
+
return this._senderName;
|
|
27
|
+
}
|
|
28
|
+
// E.164 formatted
|
|
29
|
+
get senderPhone() {
|
|
30
|
+
return this._senderPhone;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Database, { Container, StoredBlob } from "./Database";
|
|
2
|
+
export default class MockDatabase implements Database {
|
|
3
|
+
getContainer(name: string): Promise<Container>;
|
|
4
|
+
getContainerNames(): Promise<ReadonlyArray<string>>;
|
|
5
|
+
deleteContainer(name: string): Promise<void>;
|
|
6
|
+
getContainerIfPresent(name: string): MockContainer | null;
|
|
7
|
+
private readonly _containers;
|
|
8
|
+
}
|
|
9
|
+
export declare class MockContainer implements Container {
|
|
10
|
+
read(id: bigint): Promise<StoredBlob | null>;
|
|
11
|
+
readAll(): Promise<ReadonlyArray<StoredBlob>>;
|
|
12
|
+
write(blobs: ReadonlyArray<StoredBlob>, deletes: ReadonlyArray<bigint>): Promise<number>;
|
|
13
|
+
private static isNewer;
|
|
14
|
+
get size(): number;
|
|
15
|
+
has(id: bigint): boolean;
|
|
16
|
+
failNextWrite: boolean;
|
|
17
|
+
writeCount: number;
|
|
18
|
+
private readonly _blobs;
|
|
19
|
+
}
|