@peabody-soft/mbs-model-ts 1.1.0 → 1.2.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/dist/Model.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export default class Model {
|
|
|
21
21
|
setBusinessId(businessId: string): Promise<void>;
|
|
22
22
|
updateCart(shoppingList: ShoppingList): Promise<void>;
|
|
23
23
|
updateCartLocalOnly(shoppingList: ShoppingList): Promise<void>;
|
|
24
|
-
createOrder(fulfillmentMode: proto_FulfillmentMode, deliveryAddressId: bigint, deliveryAddress: Address | null, note: string | null): Promise<void>;
|
|
24
|
+
createOrder(orderId: bigint, fulfillmentMode: proto_FulfillmentMode, deliveryAddressId: bigint, deliveryAddress: Address | null, note: string | null): Promise<void>;
|
|
25
25
|
private beginSignIn;
|
|
26
26
|
private pushBusinessMessages;
|
|
27
27
|
private storeCart;
|
package/dist/Model.js
CHANGED
|
@@ -143,9 +143,14 @@ class Model {
|
|
|
143
143
|
// Places an order for what is in the cart, and empties it - the list is used up becoming the
|
|
144
144
|
// order, as Java SalesOrderViewModel.saveChanges does on MODE_CREATE. Takes no shopping list
|
|
145
145
|
// itself for that reason: the cart is the order.
|
|
146
|
+
// orderId is the caller's to mint, with Ids.getNewId(Constants.MESSAGE_ENTITY_TYPE_ID) - not
|
|
147
|
+
// minted here - so that a caller holds it before the call is made: to find the order once placed
|
|
148
|
+
// without a server-assigned id to wait for, and to retry a call a NetworkConnectionException left
|
|
149
|
+
// unresolved by sending the same id again rather than placing a second order, the same guarantee
|
|
150
|
+
// getPartyPreferencesMessageId gives a cart.
|
|
146
151
|
// A delivery must name an address, either an id from this customer's own list or a full address
|
|
147
152
|
// sent directly - see requireDeliveryAddress.
|
|
148
|
-
async createOrder(fulfillmentMode, deliveryAddressId, deliveryAddress, note) {
|
|
153
|
+
async createOrder(orderId, fulfillmentMode, deliveryAddressId, deliveryAddress, note) {
|
|
149
154
|
const target = this.requireCustomerOfBusiness();
|
|
150
155
|
// Read from the store, not the published Business, so the order reflects the cart as the
|
|
151
156
|
// server last confirmed it, not a value some observer may still hold
|
|
@@ -159,7 +164,7 @@ class Model {
|
|
|
159
164
|
// Order and emptied cart in one request: two calls could leave a customer with an order placed
|
|
160
165
|
// but a cart still full, if the second one failed
|
|
161
166
|
await this.pushBusinessMessages(target, [
|
|
162
|
-
ProtoMap.buildOrderMessage(
|
|
167
|
+
ProtoMap.buildOrderMessage(orderId, target.senderId, shoppingList, fulfillmentMode, deliveryAddressId, deliveryAddress, note, now),
|
|
163
168
|
ProtoMap.buildCartMessage(Ids.getPartyPreferencesMessageId(target.businessLink.id), cartMessage, target.senderId, null, now),
|
|
164
169
|
]);
|
|
165
170
|
}
|
|
@@ -21,51 +21,43 @@ export interface BusinessSyncOutRequest {
|
|
|
21
21
|
* @generated from protobuf field: string businessId = 1
|
|
22
22
|
*/
|
|
23
23
|
businessId: string;
|
|
24
|
-
/**
|
|
25
|
-
* Id of the store this client keeps; never Constants.MASTER_DB_ID or another reserved id. The
|
|
26
|
-
* server leaves out entities whose Entity.updateInfo matches this, so a client does not get its
|
|
27
|
-
* own writes back, and this same id goes into every entity a client pushes in a BusinessSyncInRequest.
|
|
28
|
-
*
|
|
29
|
-
* @generated from protobuf field: int64 clientDatabaseId = 2
|
|
30
|
-
*/
|
|
31
|
-
clientDatabaseId: bigint;
|
|
32
24
|
/**
|
|
33
25
|
* Cursor for the Business entity (Constants.BUSINESS_ENTITY_TYPE_ID). Separate from, and never
|
|
34
26
|
* mixed with, ProfileSyncOutRequest.businessUpdateNumber.
|
|
35
27
|
*
|
|
36
|
-
* @generated from protobuf field: int64 businessUpdateNumber =
|
|
28
|
+
* @generated from protobuf field: int64 businessUpdateNumber = 2
|
|
37
29
|
*/
|
|
38
30
|
businessUpdateNumber: bigint;
|
|
39
31
|
/**
|
|
40
32
|
* Cursor for photos of the business, its products and its packages (Constants.ATTACHMENT_ENTITY_TYPE_ID).
|
|
41
33
|
*
|
|
42
|
-
* @generated from protobuf field: int64 attachmentUpdateNumber =
|
|
34
|
+
* @generated from protobuf field: int64 attachmentUpdateNumber = 3
|
|
43
35
|
*/
|
|
44
36
|
attachmentUpdateNumber: bigint;
|
|
45
37
|
/**
|
|
46
38
|
* The UrlAndToken.expiry of the attachment base url this client is holding, sent back unchanged;
|
|
47
39
|
* 0 means it holds none. A time, not a cursor - it does not rise monotonically.
|
|
48
40
|
*
|
|
49
|
-
* @generated from protobuf field: int64 attachmentBaseUrlExpiry =
|
|
41
|
+
* @generated from protobuf field: int64 attachmentBaseUrlExpiry = 4
|
|
50
42
|
*/
|
|
51
43
|
attachmentBaseUrlExpiry: bigint;
|
|
52
44
|
/**
|
|
53
45
|
* Cursor for the business's settings (Constants.CONFIGURATION_ENTITY_TYPE_ID).
|
|
54
46
|
*
|
|
55
|
-
* @generated from protobuf field: int64 configurationUpdateNumber =
|
|
47
|
+
* @generated from protobuf field: int64 configurationUpdateNumber = 5
|
|
56
48
|
*/
|
|
57
49
|
configurationUpdateNumber: bigint;
|
|
58
50
|
/**
|
|
59
51
|
* Cursor for the customer's orders and shopping cart (Constants.MESSAGE_ENTITY_TYPE_ID).
|
|
60
52
|
*
|
|
61
|
-
* @generated from protobuf field: int64 messageUpdateNumber =
|
|
53
|
+
* @generated from protobuf field: int64 messageUpdateNumber = 6
|
|
62
54
|
*/
|
|
63
55
|
messageUpdateNumber: bigint;
|
|
64
56
|
/**
|
|
65
57
|
* Cursor for the whole catalog - product categories, products, packages, price lists and prices,
|
|
66
58
|
* which all share this one cursor (Constants.ITEM_ENTITY_TYPE_ID).
|
|
67
59
|
*
|
|
68
|
-
* @generated from protobuf field: int64 itemUpdateNumber =
|
|
60
|
+
* @generated from protobuf field: int64 itemUpdateNumber = 7
|
|
69
61
|
*/
|
|
70
62
|
itemUpdateNumber: bigint;
|
|
71
63
|
}
|
|
@@ -7,19 +7,17 @@ class BusinessSyncOutRequest$Type extends MessageType {
|
|
|
7
7
|
constructor() {
|
|
8
8
|
super("com.merabills.storefront.BusinessSyncOutRequest", [
|
|
9
9
|
{ no: 1, name: "businessId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
10
|
-
{ no: 2, name: "
|
|
11
|
-
{ no: 3, name: "
|
|
12
|
-
{ no: 4, name: "
|
|
13
|
-
{ no: 5, name: "
|
|
14
|
-
{ no: 6, name: "
|
|
15
|
-
{ no: 7, name: "
|
|
16
|
-
{ no: 8, name: "itemUpdateNumber", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ }
|
|
10
|
+
{ no: 2, name: "businessUpdateNumber", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
11
|
+
{ no: 3, name: "attachmentUpdateNumber", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
12
|
+
{ no: 4, name: "attachmentBaseUrlExpiry", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
13
|
+
{ no: 5, name: "configurationUpdateNumber", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
14
|
+
{ no: 6, name: "messageUpdateNumber", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
|
15
|
+
{ no: 7, name: "itemUpdateNumber", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ }
|
|
17
16
|
]);
|
|
18
17
|
}
|
|
19
18
|
create(value) {
|
|
20
19
|
const message = globalThis.Object.create((this.messagePrototype));
|
|
21
20
|
message.businessId = "";
|
|
22
|
-
message.clientDatabaseId = 0n;
|
|
23
21
|
message.businessUpdateNumber = 0n;
|
|
24
22
|
message.attachmentUpdateNumber = 0n;
|
|
25
23
|
message.attachmentBaseUrlExpiry = 0n;
|
|
@@ -38,25 +36,22 @@ class BusinessSyncOutRequest$Type extends MessageType {
|
|
|
38
36
|
case /* string businessId */ 1:
|
|
39
37
|
message.businessId = reader.string();
|
|
40
38
|
break;
|
|
41
|
-
case /* int64
|
|
42
|
-
message.clientDatabaseId = reader.int64().toBigInt();
|
|
43
|
-
break;
|
|
44
|
-
case /* int64 businessUpdateNumber */ 3:
|
|
39
|
+
case /* int64 businessUpdateNumber */ 2:
|
|
45
40
|
message.businessUpdateNumber = reader.int64().toBigInt();
|
|
46
41
|
break;
|
|
47
|
-
case /* int64 attachmentUpdateNumber */
|
|
42
|
+
case /* int64 attachmentUpdateNumber */ 3:
|
|
48
43
|
message.attachmentUpdateNumber = reader.int64().toBigInt();
|
|
49
44
|
break;
|
|
50
|
-
case /* int64 attachmentBaseUrlExpiry */
|
|
45
|
+
case /* int64 attachmentBaseUrlExpiry */ 4:
|
|
51
46
|
message.attachmentBaseUrlExpiry = reader.int64().toBigInt();
|
|
52
47
|
break;
|
|
53
|
-
case /* int64 configurationUpdateNumber */
|
|
48
|
+
case /* int64 configurationUpdateNumber */ 5:
|
|
54
49
|
message.configurationUpdateNumber = reader.int64().toBigInt();
|
|
55
50
|
break;
|
|
56
|
-
case /* int64 messageUpdateNumber */
|
|
51
|
+
case /* int64 messageUpdateNumber */ 6:
|
|
57
52
|
message.messageUpdateNumber = reader.int64().toBigInt();
|
|
58
53
|
break;
|
|
59
|
-
case /* int64 itemUpdateNumber */
|
|
54
|
+
case /* int64 itemUpdateNumber */ 7:
|
|
60
55
|
message.itemUpdateNumber = reader.int64().toBigInt();
|
|
61
56
|
break;
|
|
62
57
|
default:
|
|
@@ -74,27 +69,24 @@ class BusinessSyncOutRequest$Type extends MessageType {
|
|
|
74
69
|
/* string businessId = 1; */
|
|
75
70
|
if (message.businessId !== "")
|
|
76
71
|
writer.tag(1, WireType.LengthDelimited).string(message.businessId);
|
|
77
|
-
/* int64
|
|
78
|
-
if (message.clientDatabaseId !== 0n)
|
|
79
|
-
writer.tag(2, WireType.Varint).int64(message.clientDatabaseId);
|
|
80
|
-
/* int64 businessUpdateNumber = 3; */
|
|
72
|
+
/* int64 businessUpdateNumber = 2; */
|
|
81
73
|
if (message.businessUpdateNumber !== 0n)
|
|
82
|
-
writer.tag(
|
|
83
|
-
/* int64 attachmentUpdateNumber =
|
|
74
|
+
writer.tag(2, WireType.Varint).int64(message.businessUpdateNumber);
|
|
75
|
+
/* int64 attachmentUpdateNumber = 3; */
|
|
84
76
|
if (message.attachmentUpdateNumber !== 0n)
|
|
85
|
-
writer.tag(
|
|
86
|
-
/* int64 attachmentBaseUrlExpiry =
|
|
77
|
+
writer.tag(3, WireType.Varint).int64(message.attachmentUpdateNumber);
|
|
78
|
+
/* int64 attachmentBaseUrlExpiry = 4; */
|
|
87
79
|
if (message.attachmentBaseUrlExpiry !== 0n)
|
|
88
|
-
writer.tag(
|
|
89
|
-
/* int64 configurationUpdateNumber =
|
|
80
|
+
writer.tag(4, WireType.Varint).int64(message.attachmentBaseUrlExpiry);
|
|
81
|
+
/* int64 configurationUpdateNumber = 5; */
|
|
90
82
|
if (message.configurationUpdateNumber !== 0n)
|
|
91
|
-
writer.tag(
|
|
92
|
-
/* int64 messageUpdateNumber =
|
|
83
|
+
writer.tag(5, WireType.Varint).int64(message.configurationUpdateNumber);
|
|
84
|
+
/* int64 messageUpdateNumber = 6; */
|
|
93
85
|
if (message.messageUpdateNumber !== 0n)
|
|
94
|
-
writer.tag(
|
|
95
|
-
/* int64 itemUpdateNumber =
|
|
86
|
+
writer.tag(6, WireType.Varint).int64(message.messageUpdateNumber);
|
|
87
|
+
/* int64 itemUpdateNumber = 7; */
|
|
96
88
|
if (message.itemUpdateNumber !== 0n)
|
|
97
|
-
writer.tag(
|
|
89
|
+
writer.tag(7, WireType.Varint).int64(message.itemUpdateNumber);
|
|
98
90
|
let u = options.writeUnknownFields;
|
|
99
91
|
if (u !== false)
|
|
100
92
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peabody-soft/mbs-model-ts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "MeraBills storefront client-side model (TypeScript)",
|
|
5
5
|
"author": "Peabody Soft",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript": "^7.0.2"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@peabody-soft/mbs-protos": "^1.
|
|
52
|
+
"@peabody-soft/mbs-protos": "^1.9.0",
|
|
53
53
|
"@protobuf-ts/runtime": "^2.11.1"
|
|
54
54
|
}
|
|
55
55
|
}
|