@webround/commerce 0.3.14 → 0.4.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/README.md CHANGED
@@ -30,8 +30,14 @@ store: `smoke/catalog.smoke.ts`, "how a search combines".
30
30
  `ShopStore` (`createShopStore`, `shopActions`) is where the state lives: an interface of three methods (`getState`, `subscribe`, `set`), in memory by default; the same state object until
31
31
  something really changes (a change that leaves it as it was tells nobody); one that keeps it in the address bar is another implementation. `shopQuestion(catalog, storeData, state,
32
32
  context)` is the state made into a `Resource` of the cached catalog (null until the store's data is there). `/react` binds them: `useShop({ catalog, context, initial?, store?,
33
- keepPrevious? })` gives `state`, `actions`, `storeData`, `sortOptions`, `question` and `results` (`useResource`'s shape: `keepPrevious` on by default, so a listing does not empty at
34
- every click). The text of the search box is the VIEW's (what is being typed); `actions.setSearch` is what is searched (on Enter, or after a pause the component decides): every state
33
+ keepPrevious? })` gives, each by its name: `state` (what the customer chose), `actions` (what changes it), `question` (the exact `ProductSearch` the catalog is being asked: `state` made a request
34
+ with `context`), `products` and `pagination` (the answer to `question`; `undefined` until it comes), `status`/`error`/`isFetching`/`isStale`/`retry` (how asking the products stands; `keepPrevious` on by
35
+ default, so a listing does not empty at every click), and the store's data (`store`, `collections`, `tags`, `attributes`, `filters`: the lists are `[]` until it is there, `store` is `undefined` until
36
+ then) and `sortOptions`. The store's data alone is `useStoreData(catalog, langCode?)`: the same names plus `status`/`error`/`retry`, and it is the same question `useShop` asks (one request).
37
+ **What `data` is, everywhere in `/react`:** the backends wrap a list or a record as `{ data, pagination… }`; the hooks built on `useResource` (`useOrders`, `useReturnRequests`, `useMyReviews`,
38
+ `useSubscriptions`, a catalog `Resource` given to `useResource`) open that wrapper once, so `result.data` is the list or the record and every other key of the wrapper (`pagination`, `breakdown`) is a
39
+ key of the result beside it (`orders.data`, `orders.pagination`); an answer that is not wrapped (one order) is `data` as it is. The calls of the package itself (`catalog.products.search()`) still give
40
+ what the backend answered, wrapper included: that is the catalog's contract, and what the cache keeps. The text of the search box is the VIEW's (what is being typed); `actions.setSearch` is what is searched (on Enter, or after a pause the component decides): every state
35
41
  change goes back to page 1 and asks the catalog, so a keystroke must not be one.
36
42
 
37
43
  **The address** (`src/shop/address.ts`, `address-store.ts`; `useShopAddress` in `/react`): the state written in the query string and read back, so a search is a link, "back" goes back through
@@ -8,8 +8,8 @@ export interface ShopQuestion {
8
8
  resource: Resource<ProductPage>;
9
9
  }
10
10
  /**
11
- * The state of the shop made into a question of the cached catalog. It needs the store's data (its tags, collections and filters say what a state means), so until they are there there is no question:
11
+ * The state of the shop made into a question of the cached catalog. It needs the store's data (its tags, attributes, collections and filters say what a state means), so until they are there there is no question:
12
12
  * `null`. ONE place does this, so an adapter for another framework only binds what it returns.
13
13
  */
14
- export declare function shopQuestion(catalog: Pick<CachedCatalog, 'resource'>, storeData: StoreData | null | undefined, state: ShopState, context: SearchContext): ShopQuestion | null;
14
+ export declare function shopQuestion(catalog: Pick<CachedCatalog, 'resource'>, storeData: Pick<StoreData, 'tags' | 'attributes' | 'collections' | 'filters'> | null | undefined, state: ShopState, context: SearchContext): ShopQuestion | null;
15
15
  //# sourceMappingURL=question.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { toSearch } from './to-search.js';
2
2
  /**
3
- * The state of the shop made into a question of the cached catalog. It needs the store's data (its tags, collections and filters say what a state means), so until they are there there is no question:
3
+ * The state of the shop made into a question of the cached catalog. It needs the store's data (its tags, attributes, collections and filters say what a state means), so until they are there there is no question:
4
4
  * `null`. ONE place does this, so an adapter for another framework only binds what it returns.
5
5
  */
6
6
  export function shopQuestion(catalog, storeData, state, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webround/commerce",
3
- "version": "0.3.14",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",