@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
package/Message.proto ADDED
@@ -0,0 +1,40 @@
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 "MessageType.proto";
8
+ import "PartyPreferencesPayload.proto";
9
+ import "SalesOrderPayload.proto";
10
+ import "TaskStatus.proto";
11
+
12
+ // A message sent to a business. An order is a message with a SalesOrderPayload; the shopping cart
13
+ // of a customer is a message with a PartyPreferencesPayload.
14
+ // In Java the payload is a serialized string, whose type is determined by messageType; it is typed
15
+ // here. There is no payload for MONEY_TRANSFER messages in this protocol.
16
+ message Message {
17
+
18
+ Entity entity = 1;
19
+
20
+ // Id of the entity that sent this message - the User of the customer, for anything a storefront
21
+ // creates. That user is not carried by a business sync out, so a client that needs more than the
22
+ // id resolves it against a profile sync out, or against senderName and senderPhone below.
23
+ int64 senderId = 2;
24
+
25
+ MessageType messageType = 3;
26
+
27
+ TaskStatus status = 4;
28
+
29
+ // At most Constants.MESSAGE_SENDER_NAME_MAX_LENGTH
30
+ optional string senderName = 5;
31
+
32
+ // E.164 formatted phone number of the sender
33
+ optional string senderPhone = 6;
34
+
35
+ oneof payload {
36
+
37
+ SalesOrderPayload salesOrder = 7;
38
+ PartyPreferencesPayload partyPreferences = 8;
39
+ }
40
+ }
@@ -0,0 +1,23 @@
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 type of a message, which determines the type of its payload.
7
+ // Values match the ids of the corresponding Java enum entries and must never be changed.
8
+ enum MessageType {
9
+
10
+ // MoneyTransferPayload is not part of this protocol - the id is retained so that the values
11
+ // below continue to match their Java counterparts
12
+ MONEY_TRANSFER = 0;
13
+
14
+ // An order placed by a customer - the payload is a SalesOrderPayload
15
+ SALES_ORDER = 1;
16
+
17
+ // The preferences of a party, including the shopping cart - the payload is a
18
+ // PartyPreferencesPayload
19
+ PARTY_PREFERENCES = 2;
20
+
21
+ // An unknown type of message
22
+ OTHER = 32767;
23
+ }
@@ -0,0 +1,30 @@
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
+ // Status of a sales order.
7
+ // Values match the ids of the corresponding Java enum entries and must never be changed.
8
+ enum OrderStatus {
9
+
10
+ // Not started working on the order yet
11
+ NOT_STARTED = 0;
12
+
13
+ // Getting ready to start processing the order
14
+ PREPARING = 4;
15
+
16
+ // The order is being processed
17
+ PROCESSING = 8;
18
+
19
+ // The order is ready for service / delivery / pickup
20
+ READY = 12;
21
+
22
+ // The order is being served / delivered to the customer
23
+ FULFILLING = 16;
24
+
25
+ // The order has been completed successfully
26
+ FULFILLED = 20;
27
+
28
+ // The order has been cancelled
29
+ CANCELLED = 24;
30
+ }
package/Package.proto ADDED
@@ -0,0 +1,34 @@
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 "Dimensions.proto";
7
+ import "Item.proto";
8
+ import "PackageIdentifier.proto";
9
+ import "Weight.proto";
10
+
11
+ // A package (or variant) of a product: a difference in quantity, colour or size - a 500 gram
12
+ // bottle of mango pickle, for example.
13
+ // The product of a package is its Item.parentItemId. A package contains no other entity: its
14
+ // prices are the prices whose packageId is this package, and its photos are the Attachments whose
15
+ // owningEntityId is this package.
16
+ // Excluded: isLowStockWarningEnabled, lowStockLevel, storeProperties and all Translations fields.
17
+ message Package {
18
+
19
+ // Base class - carries the Entity of this package
20
+ Item item = 1;
21
+
22
+ // True if this package can be bought in variable quantities (4.2 litres of oil, for example)
23
+ bool isSoldLoose = 2;
24
+
25
+ // GTIN, barcode, etc.
26
+ int64 itemCode = 3;
27
+
28
+ // Identifiers of this package, one per kind of identifier (at most Constants.MAX_IDENTIFIERS)
29
+ repeated PackageIdentifier identifiers = 4;
30
+
31
+ Dimensions dimensions = 5;
32
+
33
+ Weight weight = 6;
34
+ }
@@ -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 "PackageIdentifierType.proto";
7
+
8
+ // An identifier of a package, and the kind of identifier it is. A protobuf map cannot be keyed by
9
+ // an enum, so the identifiers of a package are a repeated pair rather than a map.
10
+ message PackageIdentifier {
11
+
12
+ PackageIdentifierType type = 1;
13
+
14
+ // The identifier itself (at most Constants.IDENTIFIER_MAX_LENGTH)
15
+ string value = 2;
16
+ }
@@ -0,0 +1,30 @@
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 kind of identifier that a package can carry.
7
+ // The Java enum identifies these by string id rather than by number, so the values below are
8
+ // numbered here: map each one to the Java id given in its comment.
9
+ enum PackageIdentifierType {
10
+
11
+ UNSPECIFIED_PACKAGE_IDENTIFIER_TYPE = 0;
12
+
13
+ // "gtin8" - a.k.a EAN-8
14
+ GTIN_8 = 1;
15
+
16
+ // "gtin12" - a.k.a UPC or UPC-A
17
+ GTIN_12 = 2;
18
+
19
+ // "gtin13" - a.k.a EAN or EAN-13 or JAN
20
+ GTIN_13 = 3;
21
+
22
+ // "gtin14" - a.k.a ITF-14 or UCC-14
23
+ GTIN_14 = 4;
24
+
25
+ // "isbn13"
26
+ ISBN_13 = 5;
27
+
28
+ // "sku_id"
29
+ SKU_ID = 6;
30
+ }
@@ -0,0 +1,20 @@
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 "FulfillmentMode.proto";
7
+ import "ShoppingList.proto";
8
+
9
+ // The payload of a PARTY_PREFERENCES message: the preferences of a customer of a business,
10
+ // including their shopping cart. In Java the shopping list is held as a serialized string.
11
+ // Excluded: serializedUserSettings.
12
+ message PartyPreferencesPayload {
13
+
14
+ // The shopping cart of the customer: packages that have been picked but not yet ordered
15
+ ShoppingList shoppingList = 1;
16
+
17
+ // Fulfillment mode the customer last chose.
18
+ // UNSPECIFIED_FULFILLMENT_MODE means they have not chosen one.
19
+ FulfillmentMode fulfillmentMode = 2;
20
+ }
@@ -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
+ // A method by which a customer can pay a business.
7
+ // Values match the method ids of the corresponding Java enum entries and must never be changed.
8
+ enum PaymentMethod {
9
+
10
+ // India: Unified Payments Interface. Supports QR codes.
11
+ UPI = 0;
12
+
13
+ // A method that is not known to this version
14
+ OTHER_METHOD = 32767;
15
+ }
@@ -0,0 +1,17 @@
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 "PaymentMethod.proto";
7
+
8
+ // A payment method that a business accepts, and the details a customer needs in order to use it.
9
+ // Excluded: targetLedgerId.
10
+ message PaymentMethodDetail {
11
+
12
+ PaymentMethod method = 1;
13
+
14
+ // Details of this method - the UPI id of the business, for example
15
+ // (at most Constants.PAYMENT_METHOD_DATA_MAX_LENGTH)
16
+ optional string data = 2;
17
+ }
package/Price.proto ADDED
@@ -0,0 +1,28 @@
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 "Item.proto";
7
+
8
+ // The price of a package. Item.parentItemId is the id of the PriceList this price belongs to.
9
+ // A storefront is sent only the prices of the price list it sells from, and that price list, so
10
+ // every price it receives for a package can be displayed and its list can always be resolved.
11
+ // Not included because it is derived: finalPrice, which is offerPrice when that is greater than
12
+ // zero and less than regularPrice, and regularPrice otherwise.
13
+ message Price {
14
+
15
+ // Base class - carries the Entity of this price
16
+ Item item = 1;
17
+
18
+ // Id of the package this price applies to. Nothing nests in this protocol, so this is how a
19
+ // client finds the prices of a package.
20
+ int64 packageId = 2;
21
+
22
+ // The price the package is normally sold at, multiplied by Constants.AMOUNT_FACTOR
23
+ int64 regularPrice = 3;
24
+
25
+ // The price the package is on sale at, multiplied by Constants.AMOUNT_FACTOR.
26
+ // 0 means this package is not on offer. Never greater than regularPrice.
27
+ int64 offerPrice = 4;
28
+ }
@@ -0,0 +1,31 @@
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 "Item.proto";
7
+
8
+ // A named list of prices. A price list contains nothing: the prices of a price list are the
9
+ // prices whose Item.parentItemId is this price list. A price list has no parent of its own, so
10
+ // its own Item.parentItemId is 0.
11
+ //
12
+ // A business keeps at least two, created on its first catalog load with the well known ids
13
+ // Constants.DEFAULT_SALE_PRICE_LIST and Constants.DEFAULT_PURCHASE_PRICE_LIST, and may have more.
14
+ // A storefront sells from exactly one of them and is sent only that one, so that no package ever
15
+ // arrives with two prices to choose between; every Price a client receives therefore belongs to
16
+ // the single price list it also receives.
17
+ //
18
+ // This is carried rather than left as the bare Item.parentItemId of a Price for two reasons: a
19
+ // price list has a name, and a client that pushes a shopping cart back has to name the price list
20
+ // its prices came from in ShoppingList.priceListId.
21
+ //
22
+ // Excluded: isPurchasePriceList, which says whether a list holds the prices the business buys at
23
+ // rather than sells at. A purchase price list is not public and its prices are of no use to a
24
+ // customer, so a storefront is never sent one and the flag would always be false (see the
25
+ // visibility flags, which are left out for the same reason). Java keeps it in the packed category
26
+ // short, which is never sent.
27
+ message PriceList {
28
+
29
+ // Base class - carries the Entity of this price list
30
+ Item item = 1;
31
+ }
package/Product.proto ADDED
@@ -0,0 +1,42 @@
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 "Address.proto";
7
+ import "Item.proto";
8
+ import "ProductType.proto";
9
+ import "Tax.proto";
10
+
11
+ // A product (goods, service, raw material or fixed asset) in the catalog of a business.
12
+ // A product belongs to at most one product category, whose id is Item.parentItemId (0 when it
13
+ // belongs to none). A product contains no other entity: its packages are the packages whose
14
+ // Item.parentItemId is this product, and its photos are the Attachments whose owningEntityId is
15
+ // this product.
16
+ // Excluded: isDraft, forOfflineSaleOnly, isStockKeepingEnabled, isExpiryTrackingEnabled,
17
+ // storeProperties, defaultExpiry, classifications and all Translations fields.
18
+ message Product {
19
+
20
+ // Base class - carries the Entity of this product
21
+ Item item = 1;
22
+
23
+ ProductType productType = 2;
24
+
25
+ // At most Constants.PRODUCT_BRAND_MAX_LENGTH
26
+ optional string brand = 3;
27
+
28
+ // Absent means true: this product is manufactured by the business that sells it
29
+ optional bool isManufacturedByBusiness = 4;
30
+
31
+ // At most Constants.PRODUCT_MANUFACTURER_MAX_LENGTH
32
+ optional string manufacturer = 5;
33
+
34
+ Address manufacturerAddress = 6;
35
+
36
+ // Taxes that apply to this product (at most Constants.MAX_TAXES)
37
+ repeated Tax taxes = 7;
38
+
39
+ // One line bullet points about this product (at most Constants.PRODUCT_MAX_FEATURES, each at
40
+ // most Constants.PRODUCT_FEATURE_MAX_LENGTH)
41
+ repeated string features = 8;
42
+ }
@@ -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 "Item.proto";
7
+
8
+ // A category that groups products of a catalog. Its name is always set.
9
+ // A category contains nothing: the products of a category are the products whose
10
+ // Item.parentItemId is this category. A product belongs to at most one category, and a product
11
+ // whose parentItemId is 0 belongs to none.
12
+ message ProductCategory {
13
+
14
+ // Base class - carries the Entity of this category
15
+ Item item = 1;
16
+ }
@@ -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
+ // The kind of product. Values match the type ids of the corresponding Java enum entries, which are
7
+ // bit flags, and must never be changed.
8
+ enum ProductType {
9
+
10
+ UNSPECIFIED_PRODUCT_TYPE = 0;
11
+
12
+ // Tangible, sold and purchased
13
+ GOODS = 1;
14
+
15
+ // Intangible, sold
16
+ SERVICE_SOLD = 2;
17
+
18
+ // Tangible, purchased
19
+ RAW_MATERIAL = 4;
20
+
21
+ // Intangible, purchased
22
+ SERVICE_PURCHASED = 8;
23
+
24
+ // Tangible, purchased
25
+ FIXED_ASSET = 16;
26
+ }
@@ -0,0 +1,42 @@
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 request to sync out the profile of the caller: who they are, which businesses they are linked to,
7
+ // and those businesses. This is what signs an existing user in, and it is incremental, so the request
8
+ // carries a cursor per entity type and the ProfileSyncOutResponse carries only what has changed since.
9
+ //
10
+ // Who is asking is not part of this message: it is in the AuthTokens of the authorization header. That
11
+ // is also why the request names no business - a profile is not scoped to one, and the response is what
12
+ // tells the caller which businesses exist for them.
13
+ //
14
+ // There is one cursor per entity type this reads, and they are exactly the three entity types that
15
+ // Java puts in a profile database (EntityType with DbType.PROFILE that this protocol carries): USER,
16
+ // BUSINESS and BUSINESS_LINK. A business database is read by a BusinessSyncOutRequest instead, and the
17
+ // two sets of cursors never mix - an update number is only comparable within one entity type, and only
18
+ // against the same database.
19
+ //
20
+ // Each cursor below is the highest Entity.updateNumber of that entity type that this client has
21
+ // already synced out. The server sends back the entities of that type whose updateNumber is greater,
22
+ // so a client stores the highest updateNumber it receives per type and sends it back on the next call.
23
+ // Zero, the default, means this client has nothing yet and asks for everything - signing in for the
24
+ // first time therefore leaves every cursor unset.
25
+ //
26
+ // Sync out is bounded: one call returns at most Constants.SYNC_OUT_LIMIT entities across all types
27
+ // together. On receiving that many, a client must call again with its updated cursors until it
28
+ // receives fewer.
29
+ message ProfileSyncOutRequest {
30
+
31
+ // The caller themselves - entity type Constants.USER_ENTITY_TYPE_ID
32
+ int64 userUpdateNumber = 1;
33
+
34
+ // The businesses the caller is linked to - entity type Constants.BUSINESS_ENTITY_TYPE_ID.
35
+ // A Business is a profile database entity, which is why it is read here and not by a
36
+ // BusinessSyncOutRequest - that call returns the contents of one business, not the business itself.
37
+ int64 businessUpdateNumber = 2;
38
+
39
+ // The links between the caller and those businesses, each carrying the token that lets the caller
40
+ // act against one of them - entity type Constants.BUSINESS_LINK_ENTITY_TYPE_ID
41
+ int64 businessLinkUpdateNumber = 3;
42
+ }
@@ -0,0 +1,64 @@
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 "Business.proto";
7
+ import "BusinessLink.proto";
8
+ import "User.proto";
9
+
10
+ // The answer to a ProfileSyncOutRequest: who the caller is, which businesses they are linked to, and
11
+ // those businesses. This is what signs an existing user in - a client calls it with the credentials in
12
+ // the AuthTokens of the authorization header and gets back everything it needs to know about the
13
+ // customer before it reads any one business.
14
+ //
15
+ // This is the other half of the split the business sync messages leave open: a BusinessSyncOutResponse
16
+ // carries what is in a business database and therefore no User and no BusinessLink, and this carries
17
+ // what is in a profile database. Java splits them the same way, into Service.profileSyncOut and
18
+ // Service.businessSyncOut. A Business is a profile database entity and belongs here; it is also
19
+ // carried by a BusinessSyncOutResponse, so that a client that has not signed in can still learn the
20
+ // business it is showing.
21
+ //
22
+ // How a client uses it:
23
+ // 1. user who the caller is, and the addresses an order can be delivered to
24
+ // 2. businessLinks one per business the caller is linked to. Each names its business in
25
+ // BusinessLink.businessId and carries the BusinessLink.linkToken that goes into
26
+ // AuthTokens.linkToken of every later request about that business.
27
+ // 3. businesses the businesses those links name, so that a client can show the caller a list
28
+ // of shops without a call per shop. Match BusinessLink.businessId against
29
+ // Business.entity.id, not against Business.businessId.
30
+ // Nothing is nested, for the same reason nothing is nested in a business sync out: a link and the
31
+ // business it names change independently, so a tree could not say which of them a response is
32
+ // reporting.
33
+ //
34
+ // Every field is optional, as follows. A signed in caller whose profile has not changed gets a
35
+ // response with nothing in it at all, which is valid and means "nothing new".
36
+ // - user is a singular message field, so it has explicit presence: absent means the profile of the
37
+ // caller has not changed, not that there is no caller.
38
+ // - businessLinks and businesses are repeated, and a proto3 repeated field cannot be marked optional
39
+ // because it has no presence of its own. An empty array is the absent state, and means no link or
40
+ // no business has changed - it never means the caller has none. Only an arriving entity, or a
41
+ // tombstone, changes what a client holds.
42
+ //
43
+ // A tombstone works as it does in a business sync out: an entity whose
44
+ // (updateNumber & Constants.UPDATE_TYPE_MASK) equals Constants.UPDATE_TYPE_DELETED has been deleted,
45
+ // only its Entity is meaningful, and a deleted BusinessLink means the caller may no longer reach that
46
+ // business and its link token must be discarded.
47
+ //
48
+ // This sync out is incremental and bounded, exactly as the business one is: ProfileSyncOutRequest
49
+ // carries a cursor for each of the three entity types below, and one response returns at most
50
+ // Constants.SYNC_OUT_LIMIT entities across all three together. A client that receives that many
51
+ // raises each cursor to the highest updateNumber it has seen for that type and requests again, until
52
+ // it receives fewer. The response carries no cursors of its own: a client computes them from the
53
+ // entities it receives.
54
+ message ProfileSyncOutResponse {
55
+
56
+ // The caller. Absent unless their own profile has changed.
57
+ User user = 1;
58
+
59
+ // The businesses the caller is linked to, and the token for each. Empty unless a link has changed.
60
+ repeated BusinessLink businessLinks = 2;
61
+
62
+ // The businesses that the links above name. Empty unless a business has changed.
63
+ repeated Business businesses = 3;
64
+ }
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @peabody-soft/mbs-protos
2
+
3
+ The MeraBills shop wire protocol: the `.proto` files themselves, unchanged, published so any
4
+ client can install them and compile them with whatever protoc plugin its own language and
5
+ toolchain need. This directory is the single source of the protocol - the Java server also
6
+ generates from it - so the package ships these files as-is rather than a compiled form of them.
7
+
8
+ A TypeScript client, for instance, runs its own `protoc` (via `@protobuf-ts/plugin`, `ts-proto`,
9
+ or similar) against the installed package's `.proto` files. This package has no build step and no
10
+ opinion on which plugin or language a consumer uses.
11
+
12
+ ## Publish
13
+
14
+ ```
15
+ npm login
16
+ npm version <patch|minor|major>
17
+ npm publish
18
+ ```
19
+
20
+ ## Use
21
+
22
+ ```
23
+ npm install @peabody-soft/mbs-protos
24
+ ```
25
+
26
+ The `.proto` files land at `node_modules/@peabody-soft/mbs-protos/*.proto`. Point your `protoc`
27
+ `--proto_path` there.
@@ -0,0 +1,35 @@
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 packages reserved for the charge and summary lines of a shopping list. A ShoppingListItem
7
+ // whose packageId is one of these is not a catalog package and will never be found in the catalog:
8
+ // it carries a charge, a discount or the list total, and a client must label it itself.
9
+ //
10
+ // A reserved package id does not fit in an enum value, which is 32 bits, so the value below is the
11
+ // low part of the id and a client builds the whole id as
12
+ //
13
+ // id = (Constants.PACKAGE_ENTITY_TYPE_ID << Constants.ENTITY_TYPE_BIT_SHIFT) | value
14
+ //
15
+ // using 64 bit arithmetic - BigInt in TypeScript. The four ids that produces are
16
+ // 4611686018427387904, 4611686018427387905, 4611686018427387906 and 4611686018427387907
17
+ // (0x4000000000000000 to 0x4000000000000003). Conversely, a packageId is a reserved package when
18
+ // its low 56 bits are less than or equal to SERVICE_CHARGE_PACKAGE.
19
+ //
20
+ // This is a carrier for constants, not the type of any field, so zero being a real value is safe.
21
+ enum ReservedPackage {
22
+
23
+ // The total of the shopping list. Present only in a list a merchant has laid out for display;
24
+ // a storefront should prefer ShoppingList.totalAmountBeforeDiscount.
25
+ TOTAL_PACKAGE = 0;
26
+
27
+ // The discount applied to the whole shopping list
28
+ DISCOUNT_PACKAGE = 1;
29
+
30
+ // The delivery charge, added when ShoppingList.autoAddDeliveryCharge is true
31
+ DELIVERY_CHARGE_PACKAGE = 2;
32
+
33
+ // The service charge, added when ShoppingList.autoAddServiceCharge is true
34
+ SERVICE_CHARGE_PACKAGE = 3;
35
+ }
package/Role.proto ADDED
@@ -0,0 +1,44 @@
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
+ // What an entity linked to a business may do with it. This is the role of a BusinessLink.
7
+ //
8
+ // The values are the ids of the Java Role entries and must never change. Each is built from a group
9
+ // and a role within that group, (groupId << 6) | roleId, so they are not consecutive: the group is
10
+ // the upper bits and, within a group, a higher value means fewer rights. The groups are
11
+ // 0 owner, 1 employee, 2 vendor, 3 customer, 4 partner and 63 other. A client that only needs to
12
+ // know which group a role is in can compute it as (role >> 6); a client that needs the actual rights
13
+ // cannot, because the rights are not on the wire.
14
+ //
15
+ // A storefront customer is normally CUSTOMER. The other values are here so that a role a storefront
16
+ // does not expect maps to a name rather than to a number, and so that the numbering cannot drift
17
+ // from Java by having gaps filled in later.
18
+ enum Role {
19
+
20
+ // Owner group. Only a user can be in one of these roles.
21
+ PRIMARY_OWNER = 0; // Can do anything, and is the entity that is billed
22
+ OWNER = 8; // Can do anything except remove the primary owner
23
+
24
+ // Employee group. Only a user can be in one of these roles.
25
+ MANAGER = 96;
26
+ AGENT = 104;
27
+ STAFF = 112;
28
+
29
+ // Vendor group. A user or a business can be in this role.
30
+ VENDOR = 160;
31
+
32
+ // Customer group. A user or a business can be in this role, and this is the role a storefront
33
+ // customer has.
34
+ CUSTOMER = 224;
35
+
36
+ // Partner group. An entity in one of these roles has no party id.
37
+ ACCOUNTANT = 272;
38
+ AUDITOR = 280;
39
+ MENTOR = 304;
40
+
41
+ // No rights at all to the business. Also what Java returns for an id it does not recognise, so a
42
+ // client that receives this should treat the link as unusable rather than as an error.
43
+ NONE = 4095;
44
+ }
@@ -0,0 +1,37 @@
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 "FulfillmentMode.proto";
7
+ import "OrderStatus.proto";
8
+ import "ShoppingList.proto";
9
+
10
+ // The payload of a SALES_ORDER message: an order placed by a customer.
11
+ // Excluded: serviceStationNumber and dueDate.
12
+ // Payments made against an order are not part of this payload - they are payment transactions
13
+ // whose parent is the income transaction of the order.
14
+ message SalesOrderPayload {
15
+
16
+ OrderStatus status = 1;
17
+
18
+ FulfillmentMode fulfillmentMode = 2;
19
+
20
+ // What was ordered
21
+ ShoppingList shoppingList = 3;
22
+
23
+ // Total of the shopping list, multiplied by Constants.AMOUNT_FACTOR
24
+ int64 shoppingListTotal = 4;
25
+
26
+ // Number of items in the shopping list
27
+ int32 shoppingListCount = 5;
28
+
29
+ // Id of the delivery address, in User.addresses of the customer. 0 means no address.
30
+ int64 deliveryAddressId = 6;
31
+
32
+ // Time this order was created, in milliseconds since Jan 1, 1970 00:00:00 UTC
33
+ int64 creationDate = 7;
34
+
35
+ // Note from the customer (at most Constants.SALES_ORDER_NOTE_MAX_LENGTH)
36
+ optional string note = 8;
37
+ }