@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.
Files changed (57) hide show
  1. package/Address.proto +36 -0
  2. package/AddressList.proto +18 -0
  3. package/AddressType.proto +11 -0
  4. package/Attachment.proto +48 -0
  5. package/AttachmentType.proto +56 -0
  6. package/AuthTokens.proto +51 -0
  7. package/AuthenticationMethod.proto +21 -0
  8. package/Business.proto +32 -0
  9. package/BusinessIdentifier.proto +16 -0
  10. package/BusinessIdentifierType.proto +30 -0
  11. package/BusinessLink.proto +59 -0
  12. package/BusinessSyncInRequest.proto +42 -0
  13. package/BusinessSyncInResponse.proto +23 -0
  14. package/BusinessSyncOutRequest.proto +100 -0
  15. package/BusinessSyncOutResponse.proto +109 -0
  16. package/Configuration.proto +26 -0
  17. package/Constants.proto +217 -0
  18. package/DimensionUnit.proto +15 -0
  19. package/Dimensions.proto +18 -0
  20. package/Entity.proto +45 -0
  21. package/FulfillmentMode.proto +21 -0
  22. package/GeneralSettings.proto +56 -0
  23. package/Item.proto +26 -0
  24. package/LICENCE +661 -0
  25. package/Message.proto +40 -0
  26. package/MessageType.proto +23 -0
  27. package/OrderStatus.proto +30 -0
  28. package/Package.proto +34 -0
  29. package/PackageIdentifier.proto +16 -0
  30. package/PackageIdentifierType.proto +30 -0
  31. package/PartyPreferencesPayload.proto +20 -0
  32. package/PaymentMethod.proto +15 -0
  33. package/PaymentMethodDetail.proto +17 -0
  34. package/Price.proto +28 -0
  35. package/PriceList.proto +31 -0
  36. package/Product.proto +42 -0
  37. package/ProductCategory.proto +16 -0
  38. package/ProductType.proto +26 -0
  39. package/ProfileSyncOutRequest.proto +42 -0
  40. package/ProfileSyncOutResponse.proto +64 -0
  41. package/README.md +27 -0
  42. package/ReservedPackage.proto +35 -0
  43. package/Role.proto +44 -0
  44. package/SalesOrderPayload.proto +37 -0
  45. package/ShoppingList.proto +57 -0
  46. package/ShoppingListItem.proto +53 -0
  47. package/TaskStatus.proto +13 -0
  48. package/Tax.proto +16 -0
  49. package/TaxType.proto +13 -0
  50. package/UrlAndToken.proto +57 -0
  51. package/User.proto +36 -0
  52. package/Weight.proto +14 -0
  53. package/WeightUnit.proto +15 -0
  54. package/WorkingDays.proto +26 -0
  55. package/WorkingHours.proto +19 -0
  56. package/WorkingHoursRange.proto +22 -0
  57. package/package.json +25 -0
@@ -0,0 +1,57 @@
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 "ShoppingListItem.proto";
7
+
8
+ // A list of packages being bought - a customer's shopping cart, or the contents of an order.
9
+ // In Java the items are serialized into a base64 string; they are typed here.
10
+ // Excluded: transactionTime.
11
+ // Not included because they are computed from the fields below: totalAmount (=
12
+ // totalAmountBeforeDiscount - discount), totalTax (the sum of the taxes of the existing items) and
13
+ // itemCount (= existingItemCount + deletedItemCount). isSaved and the change listener are Java
14
+ // bookkeeping and are not part of this protocol.
15
+ message ShoppingList {
16
+
17
+ // True once the customer is done editing this list, after which the business may edit it.
18
+ // Only a final list can have deleted items. This flag is never unset.
19
+ bool isFinal = 1;
20
+
21
+ // True when the delivery charge is carried as an item of its own, with the package id
22
+ // ReservedPackage.DELIVERY_CHARGE_PACKAGE, rather than being added to the total
23
+ bool autoAddDeliveryCharge = 2;
24
+
25
+ // The same, for ReservedPackage.SERVICE_CHARGE_PACKAGE
26
+ bool autoAddServiceCharge = 3;
27
+
28
+ // Id of the inventory location the items are drawn from. 0 is the default location.
29
+ int32 inventoryLocationId = 4;
30
+
31
+ // Id of the PriceList the prices of the items came from - the one price list a
32
+ // BusinessSyncOutResponse carries. A client creating a cart that has none yet sends the id built
33
+ // from Constants.DEFAULT_SALE_PRICE_LIST.
34
+ int64 priceListId = 5;
35
+
36
+ // Sum of the final prices of the existing items, multiplied by Constants.AMOUNT_FACTOR.
37
+ // This total is authoritative: it is computed with the rounding rules of PriceCalculation, which
38
+ // a client is not expected to reproduce. Display it minus the discount below, rather than adding
39
+ // the items up.
40
+ int64 totalAmountBeforeDiscount = 6;
41
+
42
+ // Discount on the whole list, multiplied by Constants.AMOUNT_FACTOR
43
+ int64 discount = 7;
44
+
45
+ // Number of existing items - set even when the items themselves are not sent
46
+ int32 existingItemCount = 8;
47
+
48
+ // Number of deleted items - set even when the items themselves are not sent
49
+ int32 deletedItemCount = 9;
50
+
51
+ // The items in this list (this list and the deleted items below hold at most
52
+ // Constants.SHOPPING_LIST_MAX_ITEMS items in all)
53
+ repeated ShoppingListItem existingItems = 10;
54
+
55
+ // Items that were in this list when it was made final, and have since been deleted or replaced
56
+ repeated ShoppingListItem deletedItems = 11;
57
+ }
@@ -0,0 +1,53 @@
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 "Tax.proto";
7
+
8
+ // A line item in a shopping list: the package being bought, how much of it, and at what price.
9
+ // Excluded: batches.
10
+ // Not included because they are computed from the fields below and are not stored in Java:
11
+ // taxes amounts, totalTax and finalPrice (= (unitPrice x quantity) + taxes thereon - discount).
12
+ message ShoppingListItem {
13
+
14
+ // Id of the package being bought. Four ids are reserved for charge and summary lines rather
15
+ // than catalog packages, and will not be found in the catalog - see ReservedPackage, which
16
+ // gives those ids and how to build them. A client must label those lines itself.
17
+ int64 packageId = 1;
18
+
19
+ // Quantity, multiplied by Constants.QUANTITY_FACTOR. 1.5 kg is stored as 1500.
20
+ int32 quantity = 2;
21
+
22
+ // Price of one unit of the package, multiplied by Constants.AMOUNT_FACTOR.
23
+ // This is the offer price when the package is on offer.
24
+ int64 unitPrice = 3;
25
+
26
+ // Position of this item in the shopping list (0 to Constants.SHOPPING_LIST_ITEM_MAX_ORDER)
27
+ int32 shoppingListOrder = 4;
28
+
29
+ // True if this item was created before the shopping list was made final
30
+ bool isOriginal = 5;
31
+
32
+ // True if this item has been deleted or replaced after the shopping list was made final
33
+ bool isModified = 6;
34
+
35
+ bool isStockKeepingRequired = 7;
36
+
37
+ // Discount in the unit price (regularPrice - offerPrice of the package), multiplied by
38
+ // Constants.AMOUNT_FACTOR
39
+ int64 priceDiscount = 8;
40
+
41
+ // Discount applied to the total price of this line item, including taxes, multiplied by
42
+ // Constants.AMOUNT_FACTOR
43
+ int64 discount = 9;
44
+
45
+ // Taxes that apply to this line item (at most Constants.MAX_TAXES)
46
+ repeated Tax taxes = 10;
47
+
48
+ // Number of minutes after purchase when this item expires. 0 means it does not expire.
49
+ int32 expiry = 11;
50
+
51
+ // At most Constants.SHOPPING_LIST_ITEM_DESCRIPTION_MAX_LENGTH
52
+ optional string description = 12;
53
+ }
@@ -0,0 +1,13 @@
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
+ // Processing status of a message.
7
+ // Values match the ids of the corresponding Java enum entries and must never be changed.
8
+ enum TaskStatus {
9
+
10
+ NOT_YET_PROCESSED = 0;
11
+ COMPLETED = 1;
12
+ REJECTED = 2;
13
+ }
package/Tax.proto ADDED
@@ -0,0 +1,16 @@
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 "TaxType.proto";
7
+
8
+ // A tax and the rate at which it applies. Replaces the parallel taxCodes / taxRates arrays in Java.
9
+ message Tax {
10
+
11
+ // Exposed instead of the raw tax code
12
+ TaxType type = 1;
13
+
14
+ // Tax rate, multiplied by Constants.TAX_RATE_FACTOR. 18% is stored as 1800.
15
+ int32 rate = 2;
16
+ }
package/TaxType.proto ADDED
@@ -0,0 +1,13 @@
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
+ // A tax that applies to a product or to a line item.
7
+ // Values match the Java tax codes, which are unique within a country: the country of the business
8
+ // that owns the item is needed to interpret them.
9
+ enum TaxType {
10
+
11
+ // India: Goods and Services Tax
12
+ GST = 0;
13
+ }
@@ -0,0 +1,57 @@
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
+ // Where a set of files is, the shared access signature that authorizes reading them, and the moment
7
+ // both stop working. This is the Java UrlAndToken of the repository client: what
8
+ // Service.createAttachmentSasUrl returns, and what BlobClient builds every blob url from.
9
+ //
10
+ // This protocol uses it for one thing - BusinessSyncOutResponse.attachmentBaseUrl, the container
11
+ // that holds the photos of a business. It is a value and not an entity: it has no Entity, no id and
12
+ // no update number, because it is generated per caller on demand and stored nowhere. It cannot be
13
+ // deleted either, so there is no tombstone for it; it only expires.
14
+ //
15
+ // A client builds the url of one file the way BlobClient.createBlobUrl does, by putting the storage
16
+ // file name of the attachment in the path and the token in the query string:
17
+ //
18
+ // resourceUrl + "/" + storage file name + "?" + sasToken
19
+ //
20
+ // The storage file name is derived from the attachment rather than sent - Attachment says how it is
21
+ // built. The container is flat: every file sits directly under resourceUrl, so a storage file name
22
+ // must never be turned into a path of its own.
23
+ //
24
+ // What the token grants is only what a storefront needs, and this is what a server must keep true
25
+ // when it fills this in. CloudDb.createAttachmentSasUrl grants read, grants create only to a caller
26
+ // with Right.ATTACHMENTS_MODIFY, and grants nothing else - no write, no delete, and no list, so
27
+ // holding this cannot be used to enumerate the container. A storefront customer has none of those
28
+ // rights and must be given the read only signature of the public container; the private container
29
+ // requires attachment rights and must never be handed to a storefront.
30
+ //
31
+ // The token is a credential: anyone holding it can read the files of that container until it
32
+ // expires, so it must not be logged. Unlike AuthTokens.userToken and BusinessLink.linkToken, which
33
+ // must never appear in a url, this one is meant to be in a url - a browser fetching an image can
34
+ // pass it no other way. It is safe there because it is scoped to one container, read only, and
35
+ // short lived.
36
+ message UrlAndToken {
37
+
38
+ // The url of the container the files are in - Java UrlAndToken.mResourceUrl, serialized as "ru".
39
+ // Always https, and never with a trailing slash or a query string of its own.
40
+ string resourceUrl = 1;
41
+
42
+ // The shared access signature that authorizes reading a file of that container, ready to use as a
43
+ // query string ("sv=...&se=...&sig=...") and without the leading question mark - Java
44
+ // UrlAndToken.mSasToken, serialized as "st". A client appends it as it is; it never parses or
45
+ // rebuilds it.
46
+ string sasToken = 2;
47
+
48
+ // When the two fields above stop working, in milliseconds since Jan 1, 1970 UTC - Java
49
+ // UrlAndToken.mExpiryUtcMillis, serialized as "ex". After this, every url built from them is
50
+ // refused by storage, so a client stops using them and asks for new ones - see
51
+ // BusinessSyncOutRequest.attachmentBaseUrlExpiry, which is where a client sends this value back.
52
+ //
53
+ // A client must treat this as reached Constants.ATTACHMENT_BASE_URL_EXPIRY_MARGIN before it
54
+ // actually is, the way UrlAndTokenFetcher.isTokenInvalid does, so that a url it is about to build
55
+ // cannot expire between building and fetching.
56
+ int64 expiry = 3;
57
+ }
package/User.proto ADDED
@@ -0,0 +1,36 @@
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 "Entity.proto";
8
+
9
+ // A user of MeraBills. A customer of a business is represented by a User.
10
+ //
11
+ // A user lives in a profile database, not in a business database, so it is carried by a
12
+ // ProfileSyncOutResponse and not by a BusinessSyncOutResponse, the way Java splits
13
+ // Service.profileSyncOut from Service.businessSyncOut. Do not add it to the business sync out: a
14
+ // client reads the caller once, by signing in, and then reads each business separately.
15
+ //
16
+ // Excluded: referralDetails, isCallingUser and all Translations fields.
17
+ // Not included because it is derived: formattedName (firstName + " " + lastName).
18
+ message User {
19
+
20
+ Entity entity = 1;
21
+
22
+ // At most Constants.USER_NAME_MAX_LENGTH
23
+ string firstName = 2;
24
+
25
+ // At most Constants.USER_NAME_MAX_LENGTH
26
+ optional string lastName = 3;
27
+
28
+ // E.164 formatted mobile phone number
29
+ string mobilePhoneNumber = 4;
30
+
31
+ // Delivery addresses of this user, and the id of the default one
32
+ AddressList addresses = 5;
33
+
34
+ // BCP 47 / ISO 639 language code (at most Constants.USER_LANGUAGE_CODE_MAX_LENGTH)
35
+ optional string preferredLanguageCode = 6;
36
+ }
package/Weight.proto ADDED
@@ -0,0 +1,14 @@
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 "WeightUnit.proto";
7
+
8
+ // The weight of a package. The value is greater than zero.
9
+ message Weight {
10
+
11
+ WeightUnit unit = 1;
12
+
13
+ float value = 2;
14
+ }
@@ -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 weight of a package is expressed.
7
+ // Values match the ids of the corresponding Java enum entries and must never be changed.
8
+ enum WeightUnit {
9
+
10
+ GRAMS = 0;
11
+ MILLIGRAMS = 1;
12
+ KILOGRAMS = 2;
13
+ OUNCES = 3;
14
+ POUNDS = 4;
15
+ }
@@ -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 "WorkingHours.proto";
7
+
8
+ // The days of the week on which a business works, and the hours it works on each of them.
9
+ // Not included because it is derived: includesAllDaysOfWeek, isWorkingDay, isOpenAllDay and
10
+ // isOpenAt.
11
+ message WorkingDays {
12
+
13
+ // Up to Constants.DAYS_IN_WEEK values: index 0 is Sunday, 1 is Monday ... 6 is Saturday.
14
+ // A value of true means the business works on that day. A missing value is false. An absent
15
+ // WorkingDays means the business works on every day of the week, which is the Java default.
16
+ repeated bool days = 1;
17
+
18
+ // The working hours of each day, indexed exactly as days above: entry 0 is Sunday. Up to
19
+ // Constants.DAYS_IN_WEEK entries, and fewer - or none at all - is normal.
20
+ //
21
+ // An entry that is missing, or that is present with no ranges, means work goes on all day long on
22
+ // that day. So an empty workingHours means the business works round the clock on each of its
23
+ // working days. Hours are only meaningful on a day whose days entry is true; on any other day
24
+ // they must be ignored.
25
+ repeated WorkingHours workingHours = 2;
26
+ }
@@ -0,0 +1,19 @@
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 "WorkingHoursRange.proto";
7
+
8
+ // The working hours of a single day.
9
+ // Not included because they are computed: rangeCount, isAllDay and contains.
10
+ message WorkingHours {
11
+
12
+ // The stretches of the day that are worked (at most Constants.WORKING_HOURS_MAX_RANGES). They do
13
+ // not overlap, they are ordered by openMinute, and two of them never touch - a range closing
14
+ // exactly when the next opens is sent as one unbroken range.
15
+ //
16
+ // No ranges at all means work goes on all day long, which is also what a range covering the whole
17
+ // day would mean.
18
+ repeated WorkingHoursRange ranges = 1;
19
+ }
@@ -0,0 +1,22 @@
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
+ // A single stretch of working hours within one day, in minutes after local midnight. The times are
7
+ // local to the business, not UTC, and this protocol carries no time zone: a client that wants to
8
+ // know whether the business is open now has to use the time zone of the business address.
9
+ //
10
+ // A range never spans midnight. Work that goes on past midnight is two ranges: one closing at
11
+ // Constants.MINUTES_PER_DAY on one day, and one opening at 0 on the day after.
12
+ // Not included because they are computed: isAllDay, contains and overlaps.
13
+ message WorkingHoursRange {
14
+
15
+ // Minute at which work starts, from 0 to Constants.MINUTES_PER_DAY - 1. This minute is worked.
16
+ int32 openMinute = 1;
17
+
18
+ // Minute at which work stops, from 1 to Constants.MINUTES_PER_DAY, and always greater than
19
+ // openMinute. This minute is not worked, so Constants.MINUTES_PER_DAY means work stops at
20
+ // midnight.
21
+ int32 closeMinute = 2;
22
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@peabody-soft/mbs-protos",
3
+ "version": "1.0.0",
4
+ "description": "The MeraBills shop wire protocol",
5
+ "author": "Peabody Soft",
6
+ "license": "AGPL-3.0-or-later",
7
+ "homepage": "https://merabills.com",
8
+ "keywords": [
9
+ "MeraBills",
10
+ "MeraBills Shop",
11
+ "Peabody Soft",
12
+ "ProtoBuf"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "files": [
18
+ "*.proto",
19
+ "!Prompt.txt"
20
+ ],
21
+ "scripts": {
22
+ "publish:protos": "npm publish",
23
+ "publish:protos:dry-run": "npm publish --dry-run"
24
+ }
25
+ }