@peabody-soft/mbs-model-ts 1.6.0 → 1.7.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.
@@ -100,7 +100,8 @@ class GeneralSettings {
100
100
  // Whether the business has turned online shopping on. The server does not refuse a business that
101
101
  // has not. Model does, with a NotFoundException, after reading everything it is sent, when the
102
102
  // settings it holds do not say so or it holds none (see Model.setBusinessId). Also false for
103
- // GeneralSettings.EMPTY.
103
+ // GeneralSettings.EMPTY. It is the only thing about what a business sells that closes it: one with
104
+ // nothing a customer can buy is open, with an empty catalog.
104
105
  get onlineShoppingEnabled() {
105
106
  return this._onlineShoppingEnabled;
106
107
  }
package/dist/Model.js CHANGED
@@ -294,9 +294,10 @@ class Model {
294
294
  // if not linked (see requireBusinessLink).
295
295
  // Throws NotFoundException when the business cannot be opened, on a first read or a later one (a
296
296
  // business can stop being open after it was cached). The server says so when it does not exist,
297
- // is deleted, or does not allow customers to join. Online shopping off, or nothing to buy, is
298
- // decided here (see syncBusinessContainer). The cache is kept, except that a business that is no
299
- // longer the one the businessId names is replaced by the one that is.
297
+ // is deleted, or does not allow customers to join. Online shopping off is decided here (see
298
+ // syncBusinessContainer). Having nothing to buy does not: that business is open, with an empty
299
+ // catalog. The cache is kept, except that a business that is no longer the one the businessId
300
+ // names is replaced by the one that is.
300
301
  // isStartedOver marks the one self-call, when the link the profile found for the businessId is of
301
302
  // a business that no longer has it. The profile is read again and this starts over from it.
302
303
  async businessSyncIn(isStartedOver = false) {
@@ -393,8 +394,9 @@ class Model {
393
394
  // from a re-read profile (see businessSyncIn). Otherwise this answers true.
394
395
  // 2. Online shopping is on in the general settings (no settings means off). The server does not
395
396
  // refuse a business for this, so this throws NotFoundException.
396
- // 3. The business has something to buy: an enabled product, not sold only offline, with a priced
397
- // package. Otherwise it throws NotFoundException too.
397
+ // Nothing more is asked of a business. One with nothing a customer can buy (no product that is
398
+ // enabled, not sold only offline, and has a priced package) is open: it is published with an empty
399
+ // catalog, and a UI tells its customers there is nothing to buy.
398
400
  async syncBusinessContainer(containerName, businessId, businessEntityId, firstAuthTokens) {
399
401
  const cache = Model.getCache();
400
402
  const cached = await cache.readBusiness(containerName);
@@ -454,18 +456,12 @@ class Model {
454
456
  this.publishBusiness(null);
455
457
  throw new NotFoundException("The business has not turned online shopping on");
456
458
  }
457
- // What the container holds now, built once for this check and the publish below. When the read
458
- // changed nothing, it is the one built from the cache.
459
- const business = isPublishedStale ? Model.buildPublishable(held) : cachedBusiness;
460
- if (business !== null && business.catalog.productCount === 0) {
461
- // A shop with nothing to buy is not found and not shown, even if the cache published it
462
- this.publishBusiness(null);
463
- throw new NotFoundException("The business has nothing that a customer can buy");
464
- }
465
459
  // A read the store took nothing from re-renders nobody: the cache was published above, and
466
- // nothing here changes what a later read answers
460
+ // nothing here changes what a later read answers.
461
+ // A business with nothing a customer can buy is published like any other. It is open, and says
462
+ // so with an empty catalog (Catalog.productCount), which a UI words for its customers.
467
463
  if (isPublishedStale)
468
- this.publish(business);
464
+ this.publishBusiness(held);
469
465
  // What is published now was read to the end, is the business the businessId names, and is open
470
466
  this._isPublishedBusinessVetted = true;
471
467
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peabody-soft/mbs-model-ts",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "MeraBills storefront client-side model (TypeScript)",
5
5
  "author": "Peabody Soft",
6
6
  "license": "AGPL-3.0-or-later",