@peabody-soft/mbs-protos 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/Address.proto +36 -0
- package/AddressList.proto +18 -0
- package/AddressType.proto +11 -0
- package/Attachment.proto +48 -0
- package/AttachmentType.proto +56 -0
- package/AuthTokens.proto +51 -0
- package/AuthenticationMethod.proto +21 -0
- package/Business.proto +32 -0
- package/BusinessIdentifier.proto +16 -0
- package/BusinessIdentifierType.proto +30 -0
- package/BusinessLink.proto +59 -0
- package/BusinessSyncInRequest.proto +42 -0
- package/BusinessSyncInResponse.proto +23 -0
- package/BusinessSyncOutRequest.proto +100 -0
- package/BusinessSyncOutResponse.proto +109 -0
- package/Configuration.proto +26 -0
- package/Constants.proto +217 -0
- package/DimensionUnit.proto +15 -0
- package/Dimensions.proto +18 -0
- package/Entity.proto +45 -0
- package/FulfillmentMode.proto +21 -0
- package/GeneralSettings.proto +56 -0
- package/Item.proto +26 -0
- package/LICENCE +661 -0
- package/Message.proto +40 -0
- package/MessageType.proto +23 -0
- package/OrderStatus.proto +30 -0
- package/Package.proto +34 -0
- package/PackageIdentifier.proto +16 -0
- package/PackageIdentifierType.proto +30 -0
- package/PartyPreferencesPayload.proto +20 -0
- package/PaymentMethod.proto +15 -0
- package/PaymentMethodDetail.proto +17 -0
- package/Price.proto +28 -0
- package/PriceList.proto +31 -0
- package/Product.proto +42 -0
- package/ProductCategory.proto +16 -0
- package/ProductType.proto +26 -0
- package/ProfileSyncOutRequest.proto +42 -0
- package/ProfileSyncOutResponse.proto +64 -0
- package/README.md +27 -0
- package/ReservedPackage.proto +35 -0
- package/Role.proto +44 -0
- package/SalesOrderPayload.proto +37 -0
- package/ShoppingList.proto +57 -0
- package/ShoppingListItem.proto +53 -0
- package/TaskStatus.proto +13 -0
- package/Tax.proto +16 -0
- package/TaxType.proto +13 -0
- package/UrlAndToken.proto +57 -0
- package/User.proto +36 -0
- package/Weight.proto +14 -0
- package/WeightUnit.proto +15 -0
- package/WorkingDays.proto +26 -0
- package/WorkingHours.proto +19 -0
- package/WorkingHoursRange.proto +22 -0
- package/package.json +25 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
import "Attachment.proto";
|
|
7
|
+
import "Business.proto";
|
|
8
|
+
import "Configuration.proto";
|
|
9
|
+
import "Message.proto";
|
|
10
|
+
import "Package.proto";
|
|
11
|
+
import "Price.proto";
|
|
12
|
+
import "PriceList.proto";
|
|
13
|
+
import "Product.proto";
|
|
14
|
+
import "ProductCategory.proto";
|
|
15
|
+
import "UrlAndToken.proto";
|
|
16
|
+
|
|
17
|
+
// The answer to a BusinessSyncOutRequest: the entities of one business that have changed since the
|
|
18
|
+
// update numbers the request carried, one field per entity type, the way Database.syncOut returns its
|
|
19
|
+
// two dimensional array of entities. Nothing is nested, and no entity contains another, because an
|
|
20
|
+
// incremental sync sends only what changed - a tree could not say which of its collections are
|
|
21
|
+
// complete, where a deleted entity belongs, or that a product has moved to another category.
|
|
22
|
+
//
|
|
23
|
+
// The five repeated item types, the attachments, the configurations and the messages are what Java
|
|
24
|
+
// keeps in a business database (EntityType with DbType.BUSINESS). The Business below is not: like the
|
|
25
|
+
// User and the BusinessLink, it is a profile database entity. It is carried here anyway, because a
|
|
26
|
+
// client that has not signed in has no profile sync out to read it from and would otherwise not know
|
|
27
|
+
// the name or the country of the business it is showing. The User and the BusinessLink are not, because
|
|
28
|
+
// an anonymous client has neither.
|
|
29
|
+
//
|
|
30
|
+
// A type of which there can only ever be one is a single message rather than an array, so that its
|
|
31
|
+
// presence carries the same "changed or not" information an array carries by being empty: the
|
|
32
|
+
// request names one business.
|
|
33
|
+
//
|
|
34
|
+
// Every field below is an entity of that business except one: attachmentBaseUrl is a value, and the
|
|
35
|
+
// only thing here that a client does not put in its cache and does not count against
|
|
36
|
+
// Constants.SYNC_OUT_LIMIT. It answers BusinessSyncOutRequest.attachmentBaseUrlExpiry rather than an
|
|
37
|
+
// update number, it can never be a tombstone, and it says where the files of the attachments are
|
|
38
|
+
// rather than what has changed.
|
|
39
|
+
//
|
|
40
|
+
// A client reconstructs the hierarchy itself, from the ids the entities carry:
|
|
41
|
+
// Business the business the request named
|
|
42
|
+
// Configuration its settings, by Entity.id
|
|
43
|
+
// Attachment its owner is owningEntityId - a business, a product or a package. Its
|
|
44
|
+
// file is under attachmentBaseUrl, under the storage file name that
|
|
45
|
+
// Attachment says how to build.
|
|
46
|
+
// Message its sender is senderId, which names a User of the profile database
|
|
47
|
+
// ProductCategory a category of the catalog
|
|
48
|
+
// Product its category is Item.parentItemId, or none when that is 0
|
|
49
|
+
// Package its product is Item.parentItemId
|
|
50
|
+
// PriceList the price list the business sells from. It has no parent, and there is
|
|
51
|
+
// only ever one of it in a response.
|
|
52
|
+
// Price its package is packageId; its price list is Item.parentItemId
|
|
53
|
+
// Process the arrays in the order they are declared below: a parent always arrives in an earlier
|
|
54
|
+
// array than its children, so nothing has to be resolved twice.
|
|
55
|
+
//
|
|
56
|
+
// An entity may be a tombstone rather than a value: when
|
|
57
|
+
// (updateNumber & Constants.UPDATE_TYPE_MASK) == Constants.UPDATE_TYPE_DELETED the entity has been
|
|
58
|
+
// deleted and the client must drop it and everything it owned. Only the Entity of a tombstone is
|
|
59
|
+
// meaningful.
|
|
60
|
+
//
|
|
61
|
+
// An entity type that has not changed is simply absent - an empty array, or an unset business.
|
|
62
|
+
// Absence says nothing about the entities of that type a client already holds; only an entity that
|
|
63
|
+
// arrives, or a tombstone, changes anything. So a client keeps its previous update number for an
|
|
64
|
+
// absent type.
|
|
65
|
+
//
|
|
66
|
+
// One response carries at most Constants.SYNC_OUT_LIMIT entities across all arrays together. On
|
|
67
|
+
// receiving that many, a client raises each update number to the highest it has seen for that type
|
|
68
|
+
// and requests again, until it receives fewer.
|
|
69
|
+
//
|
|
70
|
+
// Java keys its array of arrays by table entity type id. The five item types below share the item
|
|
71
|
+
// table, and therefore BusinessSyncOutRequest.itemUpdateNumber, but are separate arrays here because a
|
|
72
|
+
// protobuf repeated field cannot hold a mixture of types.
|
|
73
|
+
message BusinessSyncOutResponse {
|
|
74
|
+
|
|
75
|
+
// The business named by the request. Absent unless it has changed. Also carried, along with the
|
|
76
|
+
// links to it, by a ProfileSyncOutResponse - the same entity from two calls, each with its own
|
|
77
|
+
// cursor.
|
|
78
|
+
Business business = 1;
|
|
79
|
+
|
|
80
|
+
// Photos of the business, its products and its packages
|
|
81
|
+
repeated Attachment attachments = 2;
|
|
82
|
+
|
|
83
|
+
// Where the files of those photos are, and the token that authorizes reading them.
|
|
84
|
+
//
|
|
85
|
+
// Absent when the expiry in BusinessSyncOutRequest.attachmentBaseUrlExpiry is still further away
|
|
86
|
+
// than Constants.ATTACHMENT_BASE_URL_EXPIRY_MARGIN, which means the one the client holds is good
|
|
87
|
+
// and is to be kept. So, unlike an absent entity array, absence here is not "nothing changed" but
|
|
88
|
+
// "what you have still works". A client that holds none sends zero and always gets one back.
|
|
89
|
+
//
|
|
90
|
+
// This is not per attachment: one container holds the files of every attachment of the business,
|
|
91
|
+
// so one of these serves the whole response and every attachment already cached. A client
|
|
92
|
+
// therefore stores it once, against the business, and not against a photo.
|
|
93
|
+
UrlAndToken attachmentBaseUrl = 3;
|
|
94
|
+
|
|
95
|
+
// The settings of the business. An array because a business can have more than one public
|
|
96
|
+
// configuration, even though only the general settings are typed today.
|
|
97
|
+
repeated Configuration configurations = 4;
|
|
98
|
+
|
|
99
|
+
// The orders of the customer, and their shopping cart
|
|
100
|
+
repeated Message messages = 5;
|
|
101
|
+
|
|
102
|
+
// Item entities, in the order a client needs them: a category before its products, a product
|
|
103
|
+
// before its packages, and both a package and a price list before the prices that name them
|
|
104
|
+
repeated ProductCategory productCategories = 6;
|
|
105
|
+
repeated Product products = 7;
|
|
106
|
+
repeated Package packages = 8;
|
|
107
|
+
repeated PriceList priceLists = 9;
|
|
108
|
+
repeated Price prices = 10;
|
|
109
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
import "Entity.proto";
|
|
7
|
+
import "GeneralSettings.proto";
|
|
8
|
+
|
|
9
|
+
// A setting of a business, and its value. In Java the value is a serialized string whose meaning is
|
|
10
|
+
// determined by the id of the configuration; it is typed here, the same way a Message payload is.
|
|
11
|
+
//
|
|
12
|
+
// Which configuration this is is its Entity.id. Only public configurations - those with an id at or
|
|
13
|
+
// above Configuration.MIN_PUBLIC_CONFIGURATION_ID - are ever sent to a storefront, and of those
|
|
14
|
+
// only the general settings, whose id is 0x0D10000000000000 (941252322120433664). A client does not
|
|
15
|
+
// need that id: it switches on which member of data is set.
|
|
16
|
+
message Configuration {
|
|
17
|
+
|
|
18
|
+
Entity entity = 1;
|
|
19
|
+
|
|
20
|
+
oneof data {
|
|
21
|
+
|
|
22
|
+
// The publicly visible settings of the business, held in the configuration whose id is
|
|
23
|
+
// Configuration.MIN_PUBLIC_CONFIGURATION_ID
|
|
24
|
+
GeneralSettings generalSettings = 2;
|
|
25
|
+
}
|
|
26
|
+
}
|
package/Constants.proto
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
// The limits, scaling factors and other constants that the values in this protocol obey, so that a
|
|
7
|
+
// client can read them programmatically instead of hard coding them. Protobuf has no constants, so
|
|
8
|
+
// they are enum values; every value below is the Java constant of the same meaning, named after it
|
|
9
|
+
// or after the message and field it applies to. Aliases are allowed because several unrelated
|
|
10
|
+
// constants share a value. This is a carrier for constants, not the type of any field.
|
|
11
|
+
//
|
|
12
|
+
// Lengths are in characters, and are maximums unless the name says otherwise. Counts are maximums.
|
|
13
|
+
// An enum value is a signed 32 bit integer, so three kinds of Java constant cannot appear here:
|
|
14
|
+
// - Transaction.MAX_AMOUNT (17,592,186,044,415), which is the largest amount this protocol can
|
|
15
|
+
// carry.
|
|
16
|
+
// - Entity.ID_MASK (0x00FFFFFFFFFFFFFF) and Entity.PARTITION_ID_MASK (0xFF00FFFFFFFFFFFF). Both
|
|
17
|
+
// are derived from the shifts below: ID_MASK is (1 << ENTITY_TYPE_BIT_SHIFT) - 1.
|
|
18
|
+
// - The Entity.NAME_* short codes ("id", "ua", "un", "cr", ...), which are strings, and which
|
|
19
|
+
// name fields of the Java JSON serialization rather than anything in this protocol.
|
|
20
|
+
enum Constants {
|
|
21
|
+
|
|
22
|
+
option allow_alias = true;
|
|
23
|
+
|
|
24
|
+
UNSPECIFIED_CONSTANT = 0;
|
|
25
|
+
|
|
26
|
+
// Scaling factors. An amount, a price or a discount is multiplied by AMOUNT_FACTOR, a quantity
|
|
27
|
+
// by QUANTITY_FACTOR, and a tax rate by TAX_RATE_FACTOR.
|
|
28
|
+
AMOUNT_FACTOR = 1000;
|
|
29
|
+
QUANTITY_FACTOR = 1000;
|
|
30
|
+
TAX_RATE_FACTOR = 10000;
|
|
31
|
+
|
|
32
|
+
// User.firstName, User.lastName
|
|
33
|
+
USER_NAME_MAX_LENGTH = 32;
|
|
34
|
+
|
|
35
|
+
// User.preferredLanguageCode
|
|
36
|
+
USER_LANGUAGE_CODE_MAX_LENGTH = 8;
|
|
37
|
+
|
|
38
|
+
// Business.businessId
|
|
39
|
+
BUSINESS_ID_MIN_LENGTH = 4;
|
|
40
|
+
BUSINESS_ID_MAX_LENGTH = 64;
|
|
41
|
+
|
|
42
|
+
// Business.displayName
|
|
43
|
+
BUSINESS_DISPLAY_NAME_MIN_LENGTH = 4;
|
|
44
|
+
BUSINESS_DISPLAY_NAME_MAX_LENGTH = 64;
|
|
45
|
+
|
|
46
|
+
// Item.name and Item.description, of a product, category, package, price or price list
|
|
47
|
+
ITEM_NAME_MAX_LENGTH = 128;
|
|
48
|
+
ITEM_DESCRIPTION_MAX_LENGTH = 512;
|
|
49
|
+
|
|
50
|
+
// Product.brand, Product.manufacturer
|
|
51
|
+
PRODUCT_BRAND_MAX_LENGTH = 32;
|
|
52
|
+
PRODUCT_MANUFACTURER_MAX_LENGTH = 32;
|
|
53
|
+
|
|
54
|
+
// Product.taxes and ShoppingListItem.taxes
|
|
55
|
+
MAX_TAXES = 4;
|
|
56
|
+
|
|
57
|
+
// Product.features
|
|
58
|
+
PRODUCT_MAX_FEATURES = 5;
|
|
59
|
+
PRODUCT_FEATURE_MAX_LENGTH = 255;
|
|
60
|
+
|
|
61
|
+
// Package.identifiers and GeneralSettings.businessIdentifiers
|
|
62
|
+
MAX_IDENTIFIERS = 8;
|
|
63
|
+
|
|
64
|
+
// PackageIdentifier.value and BusinessIdentifier.value
|
|
65
|
+
IDENTIFIER_MAX_LENGTH = 24;
|
|
66
|
+
|
|
67
|
+
// Attachment.fileHash - the exact size of an MD5 hash, not a maximum
|
|
68
|
+
ATTACHMENT_FILE_HASH_SIZE_BYTES = 16;
|
|
69
|
+
|
|
70
|
+
// Attachment.fileExtension, Attachment.fileName
|
|
71
|
+
ATTACHMENT_FILE_EXTENSION_MAX_LENGTH = 4;
|
|
72
|
+
ATTACHMENT_FILE_NAME_MAX_LENGTH = 16;
|
|
73
|
+
|
|
74
|
+
// Message.senderName
|
|
75
|
+
MESSAGE_SENDER_NAME_MAX_LENGTH = 65;
|
|
76
|
+
|
|
77
|
+
// SalesOrderPayload.note
|
|
78
|
+
SALES_ORDER_NOTE_MAX_LENGTH = 120;
|
|
79
|
+
|
|
80
|
+
// ShoppingList.existingItems and ShoppingList.deletedItems, counted together
|
|
81
|
+
SHOPPING_LIST_MAX_ITEMS = 200;
|
|
82
|
+
|
|
83
|
+
// ShoppingListItem.description
|
|
84
|
+
SHOPPING_LIST_ITEM_DESCRIPTION_MAX_LENGTH = 64;
|
|
85
|
+
|
|
86
|
+
// ShoppingListItem.shoppingListOrder, which starts at zero
|
|
87
|
+
SHOPPING_LIST_ITEM_MAX_ORDER = 255;
|
|
88
|
+
|
|
89
|
+
// AddressList.addresses
|
|
90
|
+
MAX_ADDRESSES = 32;
|
|
91
|
+
|
|
92
|
+
// The fields of an Address
|
|
93
|
+
ADDRESS_UNIT_NUMBER_MAX_LENGTH = 16;
|
|
94
|
+
ADDRESS_COMMUNITY_MAX_LENGTH = 32;
|
|
95
|
+
ADDRESS_LINE2_MAX_LENGTH = 64;
|
|
96
|
+
ADDRESS_CITY_MAX_LENGTH = 32;
|
|
97
|
+
ADDRESS_STATE_MAX_LENGTH = 32;
|
|
98
|
+
ADDRESS_PIN_CODE_MAX_LENGTH = 16;
|
|
99
|
+
|
|
100
|
+
// GeneralSettings.paymentMethodDetails, GeneralSettings.storeTagline
|
|
101
|
+
MAX_PAYMENT_METHODS = 8;
|
|
102
|
+
STORE_TAGLINE_MAX_LENGTH = 64;
|
|
103
|
+
|
|
104
|
+
// GeneralSettings.deliveryRadiusKms - this value means there is no limit on the distance
|
|
105
|
+
NO_RESTRICTIONS_DELIVERY_DISTANCE = 0;
|
|
106
|
+
|
|
107
|
+
// PaymentMethodDetail.data
|
|
108
|
+
PAYMENT_METHOD_DATA_MAX_LENGTH = 320;
|
|
109
|
+
|
|
110
|
+
// WorkingDays.days and WorkingDays.workingHours
|
|
111
|
+
DAYS_IN_WEEK = 7;
|
|
112
|
+
|
|
113
|
+
// WorkingHours.ranges (WorkingHours.MAX_RANGES)
|
|
114
|
+
WORKING_HOURS_MAX_RANGES = 8;
|
|
115
|
+
|
|
116
|
+
// The bound on WorkingHoursRange.openMinute and closeMinute, and the value of closeMinute that
|
|
117
|
+
// means work stops at midnight (DateTimeHelper.MINUTES_PER_DAY)
|
|
118
|
+
MINUTES_PER_DAY = 1440;
|
|
119
|
+
|
|
120
|
+
// The layout of an Entity.id: the most significant byte is the entity type and the byte below it
|
|
121
|
+
// is the partition id, so the id of an entity of type t with the low part n is
|
|
122
|
+
// (t << ENTITY_TYPE_BIT_SHIFT) | n. Use 64 bit arithmetic - BigInt in TypeScript - for a shift.
|
|
123
|
+
ENTITY_TYPE_BIT_SHIFT = 56;
|
|
124
|
+
PARTITION_ID_SHIFT = 48;
|
|
125
|
+
|
|
126
|
+
// The entity type ids that appear in this protocol, so that a client can tell what an id refers
|
|
127
|
+
// to: (id >> ENTITY_TYPE_BIT_SHIFT) is one of these. The ids of the five item types below all
|
|
128
|
+
// belong to the item table, which is what BusinessSyncOutRequest.itemUpdateNumber tracks.
|
|
129
|
+
// These ids are stable and must never be changed or re-used.
|
|
130
|
+
//
|
|
131
|
+
// The first three ids below belong to the profile database and the rest to a business database,
|
|
132
|
+
// which is what decides where each is read from: a ProfileSyncOutRequest has a cursor for USER,
|
|
133
|
+
// BUSINESS and BUSINESS_LINK, and a BusinessSyncOutRequest for ATTACHMENT, CONFIGURATION, MESSAGE
|
|
134
|
+
// and ITEM. BUSINESS is the one type both calls carry, because a client that has not signed in has
|
|
135
|
+
// no profile sync out to read it from; the two cursors over it are separate and must not be mixed.
|
|
136
|
+
// Ids of the profile types turn up in a business sync out even so - Message.senderId is a user id.
|
|
137
|
+
USER_ENTITY_TYPE_ID = 1;
|
|
138
|
+
BUSINESS_ENTITY_TYPE_ID = 2;
|
|
139
|
+
BUSINESS_LINK_ENTITY_TYPE_ID = 3;
|
|
140
|
+
ATTACHMENT_ENTITY_TYPE_ID = 12;
|
|
141
|
+
CONFIGURATION_ENTITY_TYPE_ID = 13;
|
|
142
|
+
MESSAGE_ENTITY_TYPE_ID = 14;
|
|
143
|
+
ITEM_ENTITY_TYPE_ID = 15;
|
|
144
|
+
PACKAGE_ENTITY_TYPE_ID = 64;
|
|
145
|
+
PRODUCT_ENTITY_TYPE_ID = 65;
|
|
146
|
+
PRODUCT_CATEGORY_ENTITY_TYPE_ID = 66;
|
|
147
|
+
PRICE_ENTITY_TYPE_ID = 67;
|
|
148
|
+
PRICE_LIST_ENTITY_TYPE_ID = 68;
|
|
149
|
+
|
|
150
|
+
// The last two bits of Entity.updateNumber are the update type: updateNumber & UPDATE_TYPE_MASK
|
|
151
|
+
// is one of the three values below. UPDATE_TYPE_DELETED means the entity has been deleted, and
|
|
152
|
+
// an incremental sync out is the only place a client sees one.
|
|
153
|
+
UPDATE_TYPE_MASK = 3;
|
|
154
|
+
UPDATE_TYPE_MAX_VALUE = 3;
|
|
155
|
+
UPDATE_TYPE_CREATED = 1;
|
|
156
|
+
UPDATE_TYPE_MODIFIED = 2;
|
|
157
|
+
UPDATE_TYPE_DELETED = 3;
|
|
158
|
+
|
|
159
|
+
// Entity ids that are never assigned to a real entity. ENTITY_ID_NULL is what a field holds when
|
|
160
|
+
// it refers to nothing.
|
|
161
|
+
ENTITY_ID_NULL = 0;
|
|
162
|
+
ENTITY_ID_UTILITIES = 1;
|
|
163
|
+
ENTITY_ID_UNASSIGNED = 255;
|
|
164
|
+
|
|
165
|
+
// The two price lists every business is created with (PriceList.DEFAULT_SALE_PRICE_LIST_ID and
|
|
166
|
+
// PriceList.DEFAULT_PURCHASE_PRICE_LIST_ID). They are well known rather than assigned, so that
|
|
167
|
+
// every device computes the same id for them; the ids from 0 to 255 above are reserved for
|
|
168
|
+
// exactly this.
|
|
169
|
+
//
|
|
170
|
+
// A whole entity id does not fit in an enum value, which is 32 bits, so the values below are the
|
|
171
|
+
// low parts and a client builds each id as
|
|
172
|
+
//
|
|
173
|
+
// id = (PRICE_LIST_ENTITY_TYPE_ID << ENTITY_TYPE_BIT_SHIFT) | value
|
|
174
|
+
//
|
|
175
|
+
// using 64 bit arithmetic - BigInt in TypeScript. That gives 4899916394579099648 for the sale
|
|
176
|
+
// list and 4899916394579099649 for the purchase one (0x4400000000000000 and
|
|
177
|
+
// 0x4400000000000001).
|
|
178
|
+
//
|
|
179
|
+
// A storefront needs the sale one: it is the price list a business sells from unless it has been
|
|
180
|
+
// given another, and a client that pushes a shopping cart back has to put a price list id in
|
|
181
|
+
// ShoppingList.priceListId. The purchase list is here only so that a client can recognise the id
|
|
182
|
+
// and know that it is not a selling price; it is not public, so a storefront is never sent it.
|
|
183
|
+
DEFAULT_SALE_PRICE_LIST = 0;
|
|
184
|
+
DEFAULT_PURCHASE_PRICE_LIST = 1;
|
|
185
|
+
|
|
186
|
+
// The earliest valid Entity.createdAt / updatedAt, in milliseconds since Jan 1, 1970 UTC. Default
|
|
187
|
+
// entities are created with this time so that a copy from another device always wins a sync.
|
|
188
|
+
DEFAULT_ENTITY_CREATED_AT = 1;
|
|
189
|
+
|
|
190
|
+
// Milliseconds by which a client clock is allowed to differ from the server clock. A time in this
|
|
191
|
+
// protocol can be up to this far ahead of the reading of the client clock.
|
|
192
|
+
MAX_CLOCK_SKEW = 900000;
|
|
193
|
+
|
|
194
|
+
// How long before UrlAndToken.expiry the url and token of
|
|
195
|
+
// BusinessSyncOutResponse.attachmentBaseUrl must be treated as already expired, in milliseconds.
|
|
196
|
+
// A client stops using them this early so that a url it is about to build cannot expire between
|
|
197
|
+
// building and fetching, and a server renews them this early so that a client always has a working
|
|
198
|
+
// one - the margin UrlAndTokenFetcher.isTokenInvalid applies.
|
|
199
|
+
ATTACHMENT_BASE_URL_EXPIRY_MARGIN = 300000;
|
|
200
|
+
|
|
201
|
+
// The database id of the server (Database.MASTER_DB_ID), which is what Entity.updateInfo holds
|
|
202
|
+
// for an entity the server itself last changed. It is not a valid id for a client store, so a
|
|
203
|
+
// client that keeps one has an id of its own that is never this.
|
|
204
|
+
MASTER_DB_ID = 0;
|
|
205
|
+
|
|
206
|
+
// Largest number of entities one sync out returns, in all entity types together
|
|
207
|
+
// (Database.SYNC_OUT_LIMIT). A client that gets this many must sync out again with the update
|
|
208
|
+
// numbers it has just received, until it gets fewer.
|
|
209
|
+
SYNC_OUT_LIMIT = 5000;
|
|
210
|
+
|
|
211
|
+
// Entity.state and the Java attribute numbering of an entity. Neither the state nor the
|
|
212
|
+
// attribute numbers are part of this protocol; the constants are here for completeness.
|
|
213
|
+
STATE_MAX_LENGTH = 131072;
|
|
214
|
+
ENTITY_ATTRIBUTE_COUNT = 5;
|
|
215
|
+
ATTRIBUTE_NUMBER_ID = 1;
|
|
216
|
+
ATTRIBUTE_NUMBER_UPDATE_INFO = 3;
|
|
217
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
// Unit in which the dimensions of a package are expressed.
|
|
7
|
+
// Values match the ids of the corresponding Java enum entries and must never be changed.
|
|
8
|
+
enum DimensionUnit {
|
|
9
|
+
|
|
10
|
+
CENTIMETERS = 0;
|
|
11
|
+
MILLIMETERS = 1;
|
|
12
|
+
METERS = 2;
|
|
13
|
+
INCHES = 3;
|
|
14
|
+
FEET = 4;
|
|
15
|
+
}
|
package/Dimensions.proto
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
import "DimensionUnit.proto";
|
|
7
|
+
|
|
8
|
+
// The dimensions of a package. All three values are greater than zero.
|
|
9
|
+
message Dimensions {
|
|
10
|
+
|
|
11
|
+
DimensionUnit unit = 1;
|
|
12
|
+
|
|
13
|
+
float length = 2;
|
|
14
|
+
|
|
15
|
+
float width = 3;
|
|
16
|
+
|
|
17
|
+
float height = 4;
|
|
18
|
+
}
|
package/Entity.proto
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
// Base of most entities in the MeraBills data model.
|
|
7
|
+
// Excluded: propertyBag and state.
|
|
8
|
+
// Not included because they are derived from the fields below: partitionId and the entity type
|
|
9
|
+
// (both encoded in the most significant bits of id), updateType and isDeleted (the last two bits
|
|
10
|
+
// of updateNumber).
|
|
11
|
+
message Entity {
|
|
12
|
+
|
|
13
|
+
// Globally unique id of this entity. The most significant byte holds the entity type.
|
|
14
|
+
// Ids use the whole 64 bit range: a client must keep them as a string or a big integer, never
|
|
15
|
+
// as a JavaScript number.
|
|
16
|
+
int64 id = 1;
|
|
17
|
+
|
|
18
|
+
// Last updated time, in milliseconds since Jan 1, 1970 00:00:00 UTC
|
|
19
|
+
int64 updatedAt = 2;
|
|
20
|
+
|
|
21
|
+
// Id of the database in which this entity was last updated. Constants.MASTER_DB_ID is the
|
|
22
|
+
// server; a client that keeps a store of its own has a non-zero id, and that id is what it puts
|
|
23
|
+
// here.
|
|
24
|
+
//
|
|
25
|
+
// This is what stops a sync echoing: a sync out compares this against
|
|
26
|
+
// BusinessSyncOutRequest.clientDatabaseId and does not return the changes that database itself
|
|
27
|
+
// made, on the assumption that it already has them. So a client sets this on every entity of a
|
|
28
|
+
// BusinessSyncInRequest, to the same id it sends as clientDatabaseId, and a sync in stores what
|
|
29
|
+
// arrives - unlike updateNumber, which the receiving database always replaces with one of its
|
|
30
|
+
// own. A client that leaves it Constants.MASTER_DB_ID is claiming the server made the change,
|
|
31
|
+
// and will be sent its own writes back on the next sync out.
|
|
32
|
+
//
|
|
33
|
+
// Only the entities of a business database carry one - the attachments, configurations, messages
|
|
34
|
+
// and items. It is 0 on the profile entities of this protocol (User, Business and BusinessLink),
|
|
35
|
+
// which are never stamped with it, because other profile entity types reuse this column for
|
|
36
|
+
// something else entirely.
|
|
37
|
+
int64 updateInfo = 3;
|
|
38
|
+
|
|
39
|
+
// Monotonically increasing update number - only meaningful within a single database.
|
|
40
|
+
// The last two bits hold the update type (01 = created, 10 = modified, 11 = deleted).
|
|
41
|
+
int64 updateNumber = 4;
|
|
42
|
+
|
|
43
|
+
// Creation time, in milliseconds since Jan 1, 1970 00:00:00 UTC
|
|
44
|
+
int64 createdAt = 5;
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
// How an order is handed over to the customer. Values match the ids of the corresponding Java enum
|
|
7
|
+
// entries, which are bit flags, and must never be changed.
|
|
8
|
+
enum FulfillmentMode {
|
|
9
|
+
|
|
10
|
+
// Java has no zero value: it treats a fulfillment mode of zero as not set
|
|
11
|
+
UNSPECIFIED_FULFILLMENT_MODE = 0;
|
|
12
|
+
|
|
13
|
+
// The customer will pick up the order
|
|
14
|
+
PICK_UP = 1;
|
|
15
|
+
|
|
16
|
+
// The order needs to be delivered to the customer
|
|
17
|
+
DELIVERY = 2;
|
|
18
|
+
|
|
19
|
+
// The order will be received by the customer on the premises, with full service
|
|
20
|
+
IN_STORE_SERVICE = 4;
|
|
21
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
import "AddressList.proto";
|
|
7
|
+
import "BusinessIdentifier.proto";
|
|
8
|
+
import "FulfillmentMode.proto";
|
|
9
|
+
import "PaymentMethodDetail.proto";
|
|
10
|
+
import "WorkingDays.proto";
|
|
11
|
+
|
|
12
|
+
// The publicly visible settings of a business: its tagline, how customers can reach it, how orders
|
|
13
|
+
// are fulfilled and how they can be paid for. This is not an entity: it is the value of the public
|
|
14
|
+
// Configuration entity of the business, and it arrives inside one.
|
|
15
|
+
// Excluded: onlineShoppingEnabled, and the fields of the StoreSettings base class (authToken,
|
|
16
|
+
// authTokenExpiry, lastSuccessfulSync and fees).
|
|
17
|
+
// Not included because it is a constant: overdueAfterMillis.
|
|
18
|
+
message GeneralSettings {
|
|
19
|
+
|
|
20
|
+
// Payment methods this business accepts (at most Constants.MAX_PAYMENT_METHODS)
|
|
21
|
+
repeated PaymentMethodDetail paymentMethodDetails = 1;
|
|
22
|
+
|
|
23
|
+
// E.164 formatted phone number that customers can call
|
|
24
|
+
optional string customerServicePhone = 2;
|
|
25
|
+
|
|
26
|
+
// True if the customer service phone number can be reached on WhatsApp
|
|
27
|
+
bool isWhatsAppSupported = 3;
|
|
28
|
+
|
|
29
|
+
// True if the customer service phone number can be reached by SMS
|
|
30
|
+
bool isSmsSupported = 4;
|
|
31
|
+
|
|
32
|
+
// Addresses of this business, and the id of its default (main) address
|
|
33
|
+
AddressList businessAddresses = 5;
|
|
34
|
+
|
|
35
|
+
// Identifiers of this business, one per kind of identifier (at most Constants.MAX_IDENTIFIERS)
|
|
36
|
+
repeated BusinessIdentifier businessIdentifiers = 6;
|
|
37
|
+
|
|
38
|
+
// Fulfillment modes this business offers. Exposed instead of the bit mask used in Java.
|
|
39
|
+
repeated FulfillmentMode fulfillmentModes = 7;
|
|
40
|
+
|
|
41
|
+
// Charge for delivering an order, multiplied by Constants.AMOUNT_FACTOR
|
|
42
|
+
int64 deliveryCharge = 8;
|
|
43
|
+
|
|
44
|
+
// Order total at or above which delivery is free, multiplied by Constants.AMOUNT_FACTOR.
|
|
45
|
+
// 0 means delivery is never free.
|
|
46
|
+
int64 freeDeliveryTotal = 9;
|
|
47
|
+
|
|
48
|
+
// Distance, in kilometres, within which this business delivers.
|
|
49
|
+
// Constants.NO_RESTRICTIONS_DELIVERY_DISTANCE (0) means there is no limit.
|
|
50
|
+
int32 deliveryRadiusKms = 10;
|
|
51
|
+
|
|
52
|
+
// One line description of this business (at most Constants.STORE_TAGLINE_MAX_LENGTH)
|
|
53
|
+
optional string storeTagline = 11;
|
|
54
|
+
|
|
55
|
+
WorkingDays workingDays = 12;
|
|
56
|
+
}
|
package/Item.proto
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package com.merabills.storefront;
|
|
3
|
+
option java_multiple_files = true;
|
|
4
|
+
option java_package = "com.merabills.server.core.generated";
|
|
5
|
+
|
|
6
|
+
import "Entity.proto";
|
|
7
|
+
|
|
8
|
+
// Something that a business buys or sells, or a category or price thereof.
|
|
9
|
+
// Excluded: isPublic, isDisabled, keyValues and all Translations fields.
|
|
10
|
+
message Item {
|
|
11
|
+
|
|
12
|
+
Entity entity = 1;
|
|
13
|
+
|
|
14
|
+
// Id of the parent of this item - the category of a product, the product of a package, or the
|
|
15
|
+
// price list of a price - or 0 when this item has no parent. Nothing nests in this protocol, so
|
|
16
|
+
// this is how a client rebuilds the catalog: group the products of a BusinessSyncOutResponse by this
|
|
17
|
+
// id to get the products of each category, and the packages by this id to get the packages of
|
|
18
|
+
// each product.
|
|
19
|
+
int64 parentItemId = 2;
|
|
20
|
+
|
|
21
|
+
// At most Constants.ITEM_NAME_MAX_LENGTH
|
|
22
|
+
string name = 3;
|
|
23
|
+
|
|
24
|
+
// At most Constants.ITEM_DESCRIPTION_MAX_LENGTH
|
|
25
|
+
optional string description = 4;
|
|
26
|
+
}
|