@stapel/listings-react 0.10.0 → 0.12.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/CHANGELOG.md +197 -0
- package/dist/api/types.d.ts +10 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/default/ListingCard.d.ts +2 -2
- package/dist/default/ListingCard.d.ts.map +1 -1
- package/dist/default/ListingCard.js +8 -2
- package/dist/default/ListingCard.js.map +1 -1
- package/dist/default/ListingComposerPage.d.ts +22 -62
- package/dist/default/ListingComposerPage.d.ts.map +1 -1
- package/dist/default/ListingComposerPage.js +228 -56
- package/dist/default/ListingComposerPage.js.map +1 -1
- package/dist/default/ListingDetailPane.d.ts +2 -2
- package/dist/default/ListingDetailPane.d.ts.map +1 -1
- package/dist/default/ListingDetailPane.js +6 -1
- package/dist/default/ListingDetailPane.js.map +1 -1
- package/dist/default/ListingSerpCard.d.ts +2 -2
- package/dist/default/ListingSerpCard.d.ts.map +1 -1
- package/dist/default/ListingSerpCard.js +7 -2
- package/dist/default/ListingSerpCard.js.map +1 -1
- package/dist/default/index.d.ts +2 -2
- package/dist/default/index.d.ts.map +1 -1
- package/dist/default/index.js +1 -1
- package/dist/default/index.js.map +1 -1
- package/dist/default/types.d.ts +21 -0
- package/dist/default/types.d.ts.map +1 -1
- package/dist/headless/ListingComposer.d.ts +11 -0
- package/dist/headless/ListingComposer.d.ts.map +1 -1
- package/dist/headless/ListingComposer.js +31 -6
- package/dist/headless/ListingComposer.js.map +1 -1
- package/dist/headless/ListingDetail.d.ts +16 -1
- package/dist/headless/ListingDetail.d.ts.map +1 -1
- package/dist/headless/ListingDetail.js +13 -4
- package/dist/headless/ListingDetail.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +4 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/keys.d.ts +10 -0
- package/dist/i18n/keys.d.ts.map +1 -1
- package/dist/i18n/keys.js +16 -0
- package/dist/i18n/keys.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +4 -0
- package/dist/i18n/ru.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/features.d.ts +90 -20
- package/dist/model/features.d.ts.map +1 -1
- package/dist/model/features.js +148 -17
- package/dist/model/features.js.map +1 -1
- package/dist/model/validation.d.ts +32 -0
- package/dist/model/validation.d.ts.map +1 -1
- package/dist/model/validation.js +82 -1
- package/dist/model/validation.js.map +1 -1
- package/dist/nav/manifest.d.ts.map +1 -1
- package/dist/nav/manifest.js +2 -0
- package/dist/nav/manifest.js.map +1 -1
- package/llms.txt +1 -1
- package/manifest.json +8 -1
- package/nav-manifest.json +3 -1
- package/package.json +7 -7
- package/src/analytics/generated/events.json +1 -1
- package/src/api/types.ts +10 -0
- package/src/default/ListingCard.tsx +17 -4
- package/src/default/ListingComposerPage.tsx +221 -36
- package/src/default/ListingDetailPane.tsx +10 -6
- package/src/default/ListingSerpCard.tsx +13 -4
- package/src/default/index.ts +7 -2
- package/src/default/types.ts +22 -0
- package/src/headless/ListingComposer.tsx +47 -6
- package/src/headless/ListingDetail.tsx +37 -10
- package/src/i18n/es.ts +5 -0
- package/src/i18n/keys.ts +17 -0
- package/src/i18n/ru.ts +5 -0
- package/src/index.ts +3 -0
- package/src/model/features.ts +253 -35
- package/src/model/validation.ts +84 -1
- package/src/nav/manifest.ts +2 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAA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M,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,aAAa,IAAI,iBAAiB,EAClC,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,OAAO,GACR,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,EAC7B,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC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mB,CAAC;AAGhE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,iBAAiB,EACjB,iCAAiC,EACjC,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,GACZ,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -74,7 +74,7 @@ export { EMPTY_LOCATION, createDraftBody, draftPatchFromValues, draftValuesFromD
|
|
|
74
74
|
// ── model: the stored feature projection ─────────────────────────────────────
|
|
75
75
|
export { asFeatureDaoList, featureFromDao, featuresDtoFromDaoList, featuresFromDaoList, unreadableFeatureCount, } from "./model/features.js";
|
|
76
76
|
// ── model: validation, the mirror and the publish-400 split ──────────────────
|
|
77
|
-
export { CATEGORY_FIELD, DEFAULT_DRAFT_LIMITS, DESCRIPTION_FIELD, IMAGES_FIELD, PRICE_FIELD, TITLE_FIELD, failedResults, isBatchValid, listingFieldErrors, mirrorDraft, mirrorListingFields, publishRefusal, } from "./model/validation.js";
|
|
77
|
+
export { CATEGORY_FIELD, DEFAULT_DRAFT_LIMITS, DESCRIPTION_FIELD, IMAGES_FIELD, LOCATION_FIELD, PRICE_FIELD, TITLE_FIELD, envelopeFieldErrors, failedResults, isBatchValid, listingFieldErrors, mirrorDraft, mirrorListingFields, publishRefusal, } from "./model/validation.js";
|
|
78
78
|
// ── model: runtime wiring, query keys, context, hooks ────────────────────────
|
|
79
79
|
export { createListingsRuntime } from "./model/runtime.js";
|
|
80
80
|
export { ListingsRuntimeContext, useListingsAnalytics, useListingsApi, useListingsRuntime, } from "./model/context.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,gFAAgF;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AA6BxB,gFAAgF;AAChF,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,EAC7B,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvF,gFAAgF;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,gFAAgF;AAChF,OAAO,EACL,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAO1B,gFAAgF;AAChF,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,gFAAgF;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,wBAAwB,EACxB,gBAA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Aa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAG9B,gFAAgF;AAChF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpE,gFAAgF;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAK9E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAQpF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKrE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAMrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,gFAAgF;AAChF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEhE,gFAAgF;AAChF,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAGxB,gFAAgF;AAChF,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,iBAAiB,EACjB,iCAAiC,EACjC,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC"}
|
package/dist/model/features.d.ts
CHANGED
|
@@ -22,31 +22,101 @@
|
|
|
22
22
|
* `order`, `title`, `badge`) are simply ignored by every formatter. Copying a
|
|
23
23
|
* hand-picked subset instead would be a list to keep in step with ten types.
|
|
24
24
|
*
|
|
25
|
-
* ── What a DAO does NOT carry, and the
|
|
25
|
+
* ── What a DAO does NOT carry, and the tables that repair it ───────────────
|
|
26
26
|
*
|
|
27
27
|
* `select`'s `options`. `SelectType.dto_to_dao` stores the chosen VALUES and
|
|
28
28
|
* the ui config, never the option table — the table lives on the CATEGORY, and
|
|
29
29
|
* not needing it is the whole point of the projection.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* value
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* `
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
31
|
+
* `formatFeatureValue` resolves an option's copy by looking the value up in
|
|
32
|
+
* `config.options`, so with no table at all it falls through to
|
|
33
|
+
* `String(value)` and the STORAGE SLUG reaches the screen: a live classified
|
|
34
|
+
* deployment printed "Condition: b-u" on its spec rows and a three-slug
|
|
35
|
+
* subtitle on its cards. (The server never had this problem: its own
|
|
36
|
+
* `format_value` has the category's config in hand.)
|
|
37
|
+
*
|
|
38
|
+
* So the split below rebuilds the table, from the best of three sources:
|
|
39
|
+
*
|
|
40
|
+
* 1. The LABEL SNAPSHOT. A `select` DAO written by a stapel-attributes that
|
|
41
|
+
* snapshots labels carries `labels`, a `string[]` positionally aligned
|
|
42
|
+
* with `value` — the same device `ref_select` has always used for its
|
|
43
|
+
* vocabulary terms, and the reason a published listing keeps printing the
|
|
44
|
+
* copy it was published with however the category is edited afterwards.
|
|
45
|
+
* 2. The CATEGORY's own option table, when the display surface has it —
|
|
46
|
+
* `GET /categories/api/v1/categories/{id}/features/` answers with
|
|
47
|
+
* `{"slug":"condition","config":{"type":"select","options":[…]}}`, labels
|
|
48
|
+
* and all. It is handed in through {@link FeatureCopySource}, because a
|
|
49
|
+
* library may not fetch another module's endpoint and a card grid has no
|
|
50
|
+
* category to fetch one FOR.
|
|
51
|
+
* 3. The IDENTITY table — `{value: v, label: v}` — for a value neither of the
|
|
52
|
+
* first two names. That is exactly the table a TRANSLATABLE catalogue
|
|
53
|
+
* would have produced, since its labels ARE its keys, so such a value
|
|
54
|
+
* still reads out of the host's bundle; a NON-translatable one keeps
|
|
55
|
+
* showing the slug. A visible `b-u` gets fixed by rung 1 or 2, and an
|
|
56
|
+
* invented "Used" ships wrong, so the floor stays the value itself.
|
|
57
|
+
*
|
|
58
|
+
* ── Which rung wins, and why that order and not the other one ──────────────
|
|
59
|
+
*
|
|
60
|
+
* The SNAPSHOT outranks the category. The snapshot is what the listing was
|
|
61
|
+
* PUBLISHED with; the category is what the catalogue says today. A category
|
|
62
|
+
* whose option copy was rewritten after a listing went live must not silently
|
|
63
|
+
* restate that listing — the person reading it is reading an advert somebody
|
|
64
|
+
* else wrote, not a form. The category outranks identity, which is the whole
|
|
65
|
+
* point: every listing published before the snapshot release, and every row
|
|
66
|
+
* written by an older server, has no snapshot to outrank it and prints its
|
|
67
|
+
* slug today.
|
|
68
|
+
*
|
|
69
|
+
* A category def that does not describe the STORED row — a different value
|
|
70
|
+
* type, or no such slug — is ignored rather than forced. A category edited
|
|
71
|
+
* from `select` to `string` is a different question, and pairing its options
|
|
72
|
+
* against this row's values would print one question's copy under another
|
|
73
|
+
* question's answer, which does not even LOOK wrong.
|
|
74
|
+
*
|
|
75
|
+
* With no category defs supplied, every rung above 1 is absent and the
|
|
76
|
+
* projection behaves exactly as it did.
|
|
77
|
+
*
|
|
78
|
+
* ── The category path is the REPAIR path, not the mechanism ────────────────
|
|
79
|
+
*
|
|
80
|
+
* The primary mechanism is the server's, and it is the snapshot: stapel-
|
|
81
|
+
* attributes writes `labels` beside a `select`'s codes exactly as it always
|
|
82
|
+
* has for `ref_select`, and stapel-listings ships a reprojection command that
|
|
83
|
+
* back-fills rows written before it. Nothing here competes with that. Rung 2
|
|
84
|
+
* exists for the three states that outlive that deploy:
|
|
85
|
+
*
|
|
86
|
+
* - a row written before the snapshot existed and not yet reprojected;
|
|
87
|
+
* - a deployment that never runs the reprojection;
|
|
88
|
+
* - a category whose option copy was edited AFTER publication — where the
|
|
89
|
+
* snapshot is deliberately the older and correct answer, which is exactly
|
|
90
|
+
* why the precedence runs the way it does above.
|
|
91
|
+
*
|
|
92
|
+
* The resulting table is then read the one way `formatFeatureValue` reads any
|
|
93
|
+
* option table — literal when the config says `translatable_options: false`,
|
|
94
|
+
* through the host's `t` otherwise, where a translatable catalogue's label IS
|
|
95
|
+
* the key and an unknown key comes back unchanged. The flag stays the ROW's:
|
|
96
|
+
* it describes how the listing's own stored config wants its copy resolved,
|
|
97
|
+
* and an unknown key resolves to itself either way.
|
|
47
98
|
*/
|
|
48
|
-
import type { FeatureValueDto } from "@stapel/attributes-react";
|
|
99
|
+
import type { FeatureDef, FeatureValueDto } from "@stapel/attributes-react";
|
|
49
100
|
import type { ListingFeatureDao, ListingFeatureView } from "../api/types.js";
|
|
101
|
+
/**
|
|
102
|
+
* The category's feature defs, for a display surface that has them.
|
|
103
|
+
*
|
|
104
|
+
* A detail page reads one listing of one category and its container usually
|
|
105
|
+
* holds that category's schema already (it is the same read the composer is
|
|
106
|
+
* given); a card grid spanning forty categories does not, and passes nothing.
|
|
107
|
+
* Optional for exactly that reason: the seam adds a source of copy, it never
|
|
108
|
+
* becomes a requirement, and a host that wires nothing keeps the behaviour it
|
|
109
|
+
* has.
|
|
110
|
+
*/
|
|
111
|
+
export interface FeatureCopySource {
|
|
112
|
+
/**
|
|
113
|
+
* The chosen category's features, as
|
|
114
|
+
* `GET /categories/api/v1/categories/{id}/features/` answers — the same
|
|
115
|
+
* `readonly FeatureDef[]` `<ListingComposerPage>` already takes. Defs are
|
|
116
|
+
* matched to stored rows by slug AND value type; anything else is ignored.
|
|
117
|
+
*/
|
|
118
|
+
readonly categoryFeatures?: readonly FeatureDef[];
|
|
119
|
+
}
|
|
50
120
|
/**
|
|
51
121
|
* One DAO row → the definition/value pair the display half consumes.
|
|
52
122
|
*
|
|
@@ -55,12 +125,12 @@ import type { ListingFeatureDao, ListingFeatureView } from "../api/types.js";
|
|
|
55
125
|
* is a malformed record, and a synthesized index would key a badge to a
|
|
56
126
|
* position that changes whenever the category does.
|
|
57
127
|
*/
|
|
58
|
-
export declare function featureFromDao(dao: ListingFeatureDao): ListingFeatureView | undefined;
|
|
128
|
+
export declare function featureFromDao(dao: ListingFeatureDao, source?: FeatureCopySource): ListingFeatureView | undefined;
|
|
59
129
|
/** A stored projection → the pairs a display component iterates. Malformed
|
|
60
130
|
* rows are dropped HERE, in one place, and counted by {@link
|
|
61
131
|
* unreadableFeatureCount} so a skin can say how many rather than pretend the
|
|
62
132
|
* listing had fewer attributes. */
|
|
63
|
-
export declare function featuresFromDaoList(daos: readonly ListingFeatureDao[] | null | undefined): readonly ListingFeatureView[];
|
|
133
|
+
export declare function featuresFromDaoList(daos: readonly ListingFeatureDao[] | null | undefined, source?: FeatureCopySource): readonly ListingFeatureView[];
|
|
64
134
|
/** How many rows of a stored projection this build could not key. */
|
|
65
135
|
export declare function unreadableFeatureCount(daos: readonly ListingFeatureDao[] | null | undefined): number;
|
|
66
136
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/model/features.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/model/features.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAyC7E;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CACnD;AAiID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,iBAAiB,EACtB,MAAM,GAAE,iBAAsB,GAC7B,kBAAkB,GAAG,SAAS,CAEhC;AAqCD;;;mCAGmC;AACnC,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI,GAAG,SAAS,EACrD,MAAM,GAAE,iBAAsB,GAC7B,SAAS,kBAAkB,EAAE,CAQ/B;AAED,qEAAqE;AACrE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI,GAAG,SAAS,GACpD,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI,GAAG,SAAS,GACpD,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAM3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,iBAAiB,EAAE,CAE7E"}
|
package/dist/model/features.js
CHANGED
|
@@ -1,31 +1,156 @@
|
|
|
1
|
-
|
|
1
|
+
import { featureType } from "@stapel/attributes-react";
|
|
2
|
+
/**
|
|
3
|
+
* Keys that belong to the DAO envelope rather than to the type's config.
|
|
4
|
+
*
|
|
5
|
+
* `labels` is deliberately NOT one of them, even though this module now reads
|
|
6
|
+
* it: `ref_select` and `ref_hierarchical_select` resolve their vocabulary
|
|
7
|
+
* terms from `config.labels` (attributes-react's `refLabels` reads the value
|
|
8
|
+
* envelope first and the config second, and this split hands the formatter a
|
|
9
|
+
* bare `{type, value}`), so envelope-ing the key would blank every term those
|
|
10
|
+
* two types print. For `select` the key is simply inert — its formatter reads
|
|
11
|
+
* `options` and nothing else — so carrying it costs a reference.
|
|
12
|
+
*/
|
|
2
13
|
const ENVELOPE = new Set(["slug", "value", "name", "order", "title", "badge"]);
|
|
3
|
-
/** The
|
|
4
|
-
*
|
|
5
|
-
*
|
|
14
|
+
/** The type whose stored `value` is a flat list of option keys rather than the
|
|
15
|
+
* things themselves, and whose copy therefore has to be repaired pairwise.
|
|
16
|
+
* `ref_select` is absent because it repairs itself: its `labels` snapshot has
|
|
17
|
+
* always been mandatory (no display package can reach a vocabulary term). */
|
|
6
18
|
const OPTION_VALUED = new Set(["select"]);
|
|
19
|
+
/**
|
|
20
|
+
* The type whose copy lives in a TREE on the category rather than in a flat
|
|
21
|
+
* table: `hierarchical_select` stores a path of option keys and
|
|
22
|
+
* `formatFeatureValue` walks `config.options` level by level to name each
|
|
23
|
+
* step, so a row without that tree prints "passenger / sedan" — the storage
|
|
24
|
+
* keys — exactly as a table-less `select` prints `b-u`.
|
|
25
|
+
*
|
|
26
|
+
* It is kept apart from {@link OPTION_VALUED} because the two repairs are not
|
|
27
|
+
* the same repair: a flat positional `labels` list cannot describe a tree, so
|
|
28
|
+
* there is nothing to merge and the category's tree is adopted whole or not at
|
|
29
|
+
* all. `formatFeatureValue` already keeps a step the tree does not contain as
|
|
30
|
+
* its raw value, so an adopted tree can only add copy, never blank one out.
|
|
31
|
+
*/
|
|
32
|
+
const TREE_VALUED = new Set(["hierarchical_select"]);
|
|
7
33
|
/** The canon's `FeatureDef.translate` vocabulary — three values, closed. */
|
|
8
34
|
function isTranslateMode(value) {
|
|
9
35
|
return value === "all" || value === "title" || value === "none";
|
|
10
36
|
}
|
|
37
|
+
function categoryDefs(source) {
|
|
38
|
+
const defs = source.categoryFeatures;
|
|
39
|
+
if (defs === undefined || defs.length === 0)
|
|
40
|
+
return undefined;
|
|
41
|
+
const index = new Map();
|
|
42
|
+
for (const def of defs) {
|
|
43
|
+
// First wins: a duplicate slug in a category is a catalogue defect, and
|
|
44
|
+
// silently preferring the last one would make the copy depend on the
|
|
45
|
+
// order the endpoint happened to serialize.
|
|
46
|
+
if (typeof def.slug === "string" && def.slug.length > 0 && !index.has(def.slug)) {
|
|
47
|
+
index.set(def.slug, def);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return index.size === 0 ? undefined : index;
|
|
51
|
+
}
|
|
11
52
|
/**
|
|
12
|
-
* The
|
|
53
|
+
* The category's definition OF THIS ROW, or `undefined`.
|
|
54
|
+
*
|
|
55
|
+
* Same slug and same value type, or it is not a definition of this row — see
|
|
56
|
+
* the module header on why a mismatch is ignored rather than forced.
|
|
57
|
+
*/
|
|
58
|
+
function categoryDefFor(dao, defs) {
|
|
59
|
+
if (defs === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
const def = defs.get(dao.slug);
|
|
62
|
+
if (def === undefined)
|
|
63
|
+
return undefined;
|
|
64
|
+
return featureType(def) === dao.type ? def : undefined;
|
|
65
|
+
}
|
|
66
|
+
/** A category def's declared option list, when it declares one. */
|
|
67
|
+
function declaredOptions(def) {
|
|
68
|
+
const raw = def?.config?.["options"];
|
|
69
|
+
return Array.isArray(raw) ? raw : undefined;
|
|
70
|
+
}
|
|
71
|
+
/** One entry of an option list → its `(value, label)` pair, when it is one. */
|
|
72
|
+
function optionPair(entry) {
|
|
73
|
+
if (entry === null || typeof entry !== "object")
|
|
74
|
+
return undefined;
|
|
75
|
+
const option = entry;
|
|
76
|
+
if (typeof option.value !== "string" || option.value.length === 0)
|
|
77
|
+
return undefined;
|
|
78
|
+
return {
|
|
79
|
+
value: option.value,
|
|
80
|
+
label: typeof option.label === "string" && option.label.length > 0 ? option.label : option.value,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The option table a stored `select` needs and does not carry — see the
|
|
85
|
+
* module header. The category's table underneath, the row's own `labels`
|
|
86
|
+
* snapshot on top, the values themselves as the floor.
|
|
87
|
+
*
|
|
88
|
+
* The alignment rule is the engine's own (`labels if len(labels) ==
|
|
89
|
+
* len(codes) else codes`): a snapshot of a different length than `value` is a
|
|
90
|
+
* snapshot of some other value list, and pairing the two anyway would print
|
|
91
|
+
* one option's copy against another option's value — worse than a slug,
|
|
92
|
+
* because it does not LOOK wrong. So a length mismatch drops the whole
|
|
93
|
+
* snapshot rather than pairing the overlap, and the row falls back to the
|
|
94
|
+
* category (or to identity). Within a usable snapshot, a missing or empty
|
|
95
|
+
* entry falls back to whatever the category, then the value itself, offers for
|
|
96
|
+
* that one pair.
|
|
13
97
|
*
|
|
14
98
|
* Returns `undefined` when there is nothing to add (another type, a config
|
|
15
|
-
* that already carries a table, a value that is not a list of strings
|
|
16
|
-
* common path allocates nothing and a DAO that
|
|
17
|
-
* exactly as it arrived
|
|
99
|
+
* that already carries a table, a value that is not a list of strings and no
|
|
100
|
+
* category table either), so the common path allocates nothing and a DAO that
|
|
101
|
+
* DOES carry options is left exactly as it arrived — a stored table is a
|
|
102
|
+
* write-time snapshot of the whole question, which is a stronger statement
|
|
103
|
+
* about this listing than either the per-value snapshot or today's category.
|
|
18
104
|
*/
|
|
19
|
-
function
|
|
105
|
+
function selectOptions(dao, config, categoryDef) {
|
|
20
106
|
if (typeof dao.type !== "string" || !OPTION_VALUED.has(dao.type))
|
|
21
107
|
return undefined;
|
|
22
108
|
if (Array.isArray(config["options"]))
|
|
23
109
|
return undefined;
|
|
24
|
-
const raw = Array.isArray(dao.value)
|
|
25
|
-
|
|
26
|
-
|
|
110
|
+
const raw = Array.isArray(dao.value)
|
|
111
|
+
? dao.value
|
|
112
|
+
: [dao.value];
|
|
113
|
+
const snapshot = dao.labels;
|
|
114
|
+
const labels = Array.isArray(snapshot) && snapshot.length === raw.length
|
|
115
|
+
? snapshot
|
|
116
|
+
: undefined;
|
|
117
|
+
// A Map so the three rungs can overwrite one another by value instead of
|
|
118
|
+
// the reader having to scan a list that carries the same value twice —
|
|
119
|
+
// `labelOf` takes the FIRST match, so a duplicate would make the losing
|
|
120
|
+
// rung win.
|
|
121
|
+
const table = new Map();
|
|
122
|
+
for (const entry of declaredOptions(categoryDef) ?? []) {
|
|
123
|
+
const pair = optionPair(entry);
|
|
124
|
+
if (pair !== undefined)
|
|
125
|
+
table.set(pair.value, pair.label);
|
|
126
|
+
}
|
|
127
|
+
raw.forEach((value, index) => {
|
|
128
|
+
if (typeof value !== "string")
|
|
129
|
+
return;
|
|
130
|
+
const label = labels?.[index];
|
|
131
|
+
if (typeof label === "string" && label.length > 0)
|
|
132
|
+
table.set(value, label);
|
|
133
|
+
else if (!table.has(value))
|
|
134
|
+
table.set(value, value);
|
|
135
|
+
});
|
|
136
|
+
if (table.size === 0)
|
|
27
137
|
return undefined;
|
|
28
|
-
return
|
|
138
|
+
return [...table].map(([value, label]) => ({ value, label }));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The category's option TREE, adopted whole for a `hierarchical_select` that
|
|
142
|
+
* stored none — see {@link TREE_VALUED}.
|
|
143
|
+
*
|
|
144
|
+
* Nothing is merged and nothing is rewritten: the tree is the category's
|
|
145
|
+
* structure, and this projection has no per-level snapshot with which to
|
|
146
|
+
* disagree about it.
|
|
147
|
+
*/
|
|
148
|
+
function adoptedTree(dao, config, categoryDef) {
|
|
149
|
+
if (typeof dao.type !== "string" || !TREE_VALUED.has(dao.type))
|
|
150
|
+
return undefined;
|
|
151
|
+
if (Array.isArray(config["options"]))
|
|
152
|
+
return undefined;
|
|
153
|
+
return declaredOptions(categoryDef);
|
|
29
154
|
}
|
|
30
155
|
/**
|
|
31
156
|
* One DAO row → the definition/value pair the display half consumes.
|
|
@@ -35,7 +160,11 @@ function synthesizedOptions(dao, config) {
|
|
|
35
160
|
* is a malformed record, and a synthesized index would key a badge to a
|
|
36
161
|
* position that changes whenever the category does.
|
|
37
162
|
*/
|
|
38
|
-
export function featureFromDao(dao) {
|
|
163
|
+
export function featureFromDao(dao, source = {}) {
|
|
164
|
+
return featureView(dao, categoryDefs(source));
|
|
165
|
+
}
|
|
166
|
+
/** The work of {@link featureFromDao}, against an already-built index. */
|
|
167
|
+
function featureView(dao, defs) {
|
|
39
168
|
if (typeof dao.slug !== "string" || dao.slug.length === 0)
|
|
40
169
|
return undefined;
|
|
41
170
|
const config = {};
|
|
@@ -43,7 +172,8 @@ export function featureFromDao(dao) {
|
|
|
43
172
|
if (!ENVELOPE.has(key))
|
|
44
173
|
config[key] = value;
|
|
45
174
|
}
|
|
46
|
-
const
|
|
175
|
+
const categoryDef = categoryDefFor(dao, defs);
|
|
176
|
+
const options = selectOptions(dao, config, categoryDef) ?? adoptedTree(dao, config, categoryDef);
|
|
47
177
|
if (options !== undefined)
|
|
48
178
|
config["options"] = options;
|
|
49
179
|
const feature = {
|
|
@@ -65,10 +195,11 @@ export function featureFromDao(dao) {
|
|
|
65
195
|
* rows are dropped HERE, in one place, and counted by {@link
|
|
66
196
|
* unreadableFeatureCount} so a skin can say how many rather than pretend the
|
|
67
197
|
* listing had fewer attributes. */
|
|
68
|
-
export function featuresFromDaoList(daos) {
|
|
198
|
+
export function featuresFromDaoList(daos, source = {}) {
|
|
199
|
+
const defs = categoryDefs(source);
|
|
69
200
|
const out = [];
|
|
70
201
|
for (const dao of daos ?? []) {
|
|
71
|
-
const view =
|
|
202
|
+
const view = featureView(dao, defs);
|
|
72
203
|
if (view !== undefined)
|
|
73
204
|
out.push(view);
|
|
74
205
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/model/features.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/model/features.ts"],"names":[],"mappings":"AAmGA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD;;;;;;;;;;GAUG;AACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/E;;;6EAG6E;AAC7E,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC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AM,UAAU,sBAAsB,CACpC,IAAqD;IAErD,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAqD;IAErD,MAAM,GAAG,GAAoC,EAAE,CAAC;IAChD,KAAK,MAAM,IAAI,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IACpE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7E,CAAC"}
|
|
@@ -73,6 +73,20 @@ export declare const TITLE_FIELD = "title";
|
|
|
73
73
|
export declare const PRICE_FIELD = "price";
|
|
74
74
|
export declare const IMAGES_FIELD = "images";
|
|
75
75
|
export declare const CATEGORY_FIELD = "category_id";
|
|
76
|
+
/** The coordinate pair, as one control: a latitude alone is not a place. */
|
|
77
|
+
export declare const LOCATION_FIELD = "location";
|
|
78
|
+
/**
|
|
79
|
+
* The composer's OWN controls, in the order the draft declares them.
|
|
80
|
+
*
|
|
81
|
+
* The mirror is a `Record`, and a record has no order worth trusting — its
|
|
82
|
+
* feature refusals happen to come first because of a spread. "Which field is
|
|
83
|
+
* the first unsatisfied one?" is a question a person asks about a FORM, so the
|
|
84
|
+
* answer is written down as a list rather than read off an object: the
|
|
85
|
+
* category (nothing else can be answered until it is chosen), then the
|
|
86
|
+
* listing's own fields, then — appended by the caller — the category's
|
|
87
|
+
* features in the order the schema declares them.
|
|
88
|
+
*/
|
|
89
|
+
export declare const LISTING_FIELD_ORDER: readonly string[];
|
|
76
90
|
/**
|
|
77
91
|
* The listing-level half of the mirror: everything that is not a feature
|
|
78
92
|
* value. Returns refusals keyed by control, empty when nothing is wrong.
|
|
@@ -116,6 +130,24 @@ export type PublishRefusal = {
|
|
|
116
130
|
* `error.400.image_required` under a feature control.
|
|
117
131
|
*/
|
|
118
132
|
export declare function publishRefusal(thrown: unknown): PublishRefusal;
|
|
133
|
+
/**
|
|
134
|
+
* A per-field refusal in the ORDINARY envelope → the control it belongs to.
|
|
135
|
+
*
|
|
136
|
+
* `save-draft` and `create` do not answer a batch: DRF's field validation
|
|
137
|
+
* raises, and stapel-core's handler folds it into one envelope carrying
|
|
138
|
+
* `params.field` — the field name, and often the ONLY thing in the response
|
|
139
|
+
* that says what went wrong, because a DRF code the registry does not know
|
|
140
|
+
* (`max_decimal_places`, say) collapses to the generic
|
|
141
|
+
* `error.400.validation_error`, whose sentence is "Validation error" and
|
|
142
|
+
* nothing else.
|
|
143
|
+
*
|
|
144
|
+
* So the field name is the payload. Put on the control, it is the difference
|
|
145
|
+
* between a red banner the person cannot act on and a red field they can.
|
|
146
|
+
* Returns `{}` for anything that names no field, or names one this composer
|
|
147
|
+
* does not draw — a banner is right for those, and a refusal routed to a
|
|
148
|
+
* control that does not exist would vanish.
|
|
149
|
+
*/
|
|
150
|
+
export declare function envelopeFieldErrors(thrown: unknown): Readonly<Record<string, FlowError>>;
|
|
119
151
|
/**
|
|
120
152
|
* A server batch → refusals keyed by CONTROL.
|
|
121
153
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/model/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,cAAc,EAAoB,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;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AAK,EAAE,qBAAqB,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;CAC3D,GACD;IACE;iEAC6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC,CAAC;AAEN;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CAoB9D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,GACd,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAiBrC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,qBAAqB,GAC3B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAErC;AAED;qEACqE;AACrE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,qBAAqB,GAC3B,SAAS,uBAAuB,EAAE,CAEpC"}
|
package/dist/model/validation.js
CHANGED
|
@@ -53,6 +53,49 @@ export const TITLE_FIELD = "title";
|
|
|
53
53
|
export const PRICE_FIELD = "price";
|
|
54
54
|
export const IMAGES_FIELD = "images";
|
|
55
55
|
export const CATEGORY_FIELD = "category_id";
|
|
56
|
+
/** The coordinate pair, as one control: a latitude alone is not a place. */
|
|
57
|
+
export const LOCATION_FIELD = "location";
|
|
58
|
+
/**
|
|
59
|
+
* The composer's OWN controls, in the order the draft declares them.
|
|
60
|
+
*
|
|
61
|
+
* The mirror is a `Record`, and a record has no order worth trusting — its
|
|
62
|
+
* feature refusals happen to come first because of a spread. "Which field is
|
|
63
|
+
* the first unsatisfied one?" is a question a person asks about a FORM, so the
|
|
64
|
+
* answer is written down as a list rather than read off an object: the
|
|
65
|
+
* category (nothing else can be answered until it is chosen), then the
|
|
66
|
+
* listing's own fields, then — appended by the caller — the category's
|
|
67
|
+
* features in the order the schema declares them.
|
|
68
|
+
*/
|
|
69
|
+
export const LISTING_FIELD_ORDER = [
|
|
70
|
+
CATEGORY_FIELD,
|
|
71
|
+
TITLE_FIELD,
|
|
72
|
+
DESCRIPTION_FIELD,
|
|
73
|
+
PRICE_FIELD,
|
|
74
|
+
LOCATION_FIELD,
|
|
75
|
+
IMAGES_FIELD,
|
|
76
|
+
];
|
|
77
|
+
/**
|
|
78
|
+
* The API's own field names → the control that holds them.
|
|
79
|
+
*
|
|
80
|
+
* The draft serializer writes `*_draft` columns, and the two coordinates are
|
|
81
|
+
* one field on screen. Without this table a per-field 400 has nowhere to land
|
|
82
|
+
* and becomes a banner nobody can act on — which is the whole of blocker C2's
|
|
83
|
+
* second half: a save refused for `lat_draft` painted "Validation error" over
|
|
84
|
+
* the footer while the location control, the only thing the person could have
|
|
85
|
+
* changed, stayed clean.
|
|
86
|
+
*/
|
|
87
|
+
const CONTROL_OF_API_FIELD = {
|
|
88
|
+
title_draft: TITLE_FIELD,
|
|
89
|
+
description_draft: DESCRIPTION_FIELD,
|
|
90
|
+
price_draft: PRICE_FIELD,
|
|
91
|
+
images_draft: IMAGES_FIELD,
|
|
92
|
+
category_id: CATEGORY_FIELD,
|
|
93
|
+
lat_draft: LOCATION_FIELD,
|
|
94
|
+
lon_draft: LOCATION_FIELD,
|
|
95
|
+
location_id_draft: LOCATION_FIELD,
|
|
96
|
+
location_label_draft: LOCATION_FIELD,
|
|
97
|
+
stock_quantity: "stockQuantity",
|
|
98
|
+
};
|
|
56
99
|
/** A client-side refusal. `status: 0` on purpose: a rule this build applied
|
|
57
100
|
* must never be indistinguishable from one that came over the wire. */
|
|
58
101
|
function mirrored(code, params = {}) {
|
|
@@ -111,7 +154,7 @@ export function mirrorListingFields(values, limits) {
|
|
|
111
154
|
const hasLat = lat !== null && lat.length > 0;
|
|
112
155
|
const hasLon = lon !== null && lon.length > 0;
|
|
113
156
|
if (hasLat !== hasLon) {
|
|
114
|
-
out[
|
|
157
|
+
out[LOCATION_FIELD] = mirrored(LISTINGS_I18N_KEYS.composeGeoIncomplete);
|
|
115
158
|
}
|
|
116
159
|
return out;
|
|
117
160
|
}
|
|
@@ -168,6 +211,44 @@ export function publishRefusal(thrown) {
|
|
|
168
211
|
}),
|
|
169
212
|
};
|
|
170
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* A per-field refusal in the ORDINARY envelope → the control it belongs to.
|
|
216
|
+
*
|
|
217
|
+
* `save-draft` and `create` do not answer a batch: DRF's field validation
|
|
218
|
+
* raises, and stapel-core's handler folds it into one envelope carrying
|
|
219
|
+
* `params.field` — the field name, and often the ONLY thing in the response
|
|
220
|
+
* that says what went wrong, because a DRF code the registry does not know
|
|
221
|
+
* (`max_decimal_places`, say) collapses to the generic
|
|
222
|
+
* `error.400.validation_error`, whose sentence is "Validation error" and
|
|
223
|
+
* nothing else.
|
|
224
|
+
*
|
|
225
|
+
* So the field name is the payload. Put on the control, it is the difference
|
|
226
|
+
* between a red banner the person cannot act on and a red field they can.
|
|
227
|
+
* Returns `{}` for anything that names no field, or names one this composer
|
|
228
|
+
* does not draw — a banner is right for those, and a refusal routed to a
|
|
229
|
+
* control that does not exist would vanish.
|
|
230
|
+
*/
|
|
231
|
+
export function envelopeFieldErrors(thrown) {
|
|
232
|
+
if (!isStapelApiError(thrown))
|
|
233
|
+
return {};
|
|
234
|
+
const named = thrown.params["field"];
|
|
235
|
+
if (typeof named !== "string" || named.length === 0)
|
|
236
|
+
return {};
|
|
237
|
+
const control = CONTROL_OF_API_FIELD[named];
|
|
238
|
+
if (control === undefined)
|
|
239
|
+
return {};
|
|
240
|
+
return {
|
|
241
|
+
[control]: {
|
|
242
|
+
code: thrown.code,
|
|
243
|
+
// `field` is the fleet's routing param; the control key is what a
|
|
244
|
+
// sentence should name, not the column the server happened to use.
|
|
245
|
+
params: { ...thrown.params, field: control },
|
|
246
|
+
status: thrown.status,
|
|
247
|
+
message: thrown.message,
|
|
248
|
+
language: thrown.language,
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
171
252
|
/**
|
|
172
253
|
* A server batch → refusals keyed by CONTROL.
|
|
173
254
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/model/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA6BrD,MAAM,CAAC,MAAM,oBAAoB,GAAuB;IACtD,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,GAAG;IACnB,QAAQ,EAAE,GAAG;IACb,SAAS,EAAE,EAAE;IACb,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEF;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAC/C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/model/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CA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AmE;YACnE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAA4B;IAE5B,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED;qEACqE;AACrE,MAAM,UAAU,aAAa,CAC3B,KAA4B;IAE5B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,mBAAmB,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/nav/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C;;iEAEiE;AACjE,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/nav/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C;;iEAEiE;AACjE,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,EAoDzC,CAAC"}
|
package/dist/nav/manifest.js
CHANGED
|
@@ -18,6 +18,7 @@ export const navEntries = [
|
|
|
18
18
|
{
|
|
19
19
|
id: "listings.compose",
|
|
20
20
|
labelKey: "listings.nav.compose",
|
|
21
|
+
shortLabelKey: "listings.nav.compose.short",
|
|
21
22
|
icon: "PlusOutlined",
|
|
22
23
|
route: { path: "/new" },
|
|
23
24
|
component: { export: "ListingComposerPage", subpath: "default" },
|
|
@@ -31,6 +32,7 @@ export const navEntries = [
|
|
|
31
32
|
// Relative path: a child of the container's `/account` layout route.
|
|
32
33
|
id: "listings.mine",
|
|
33
34
|
labelKey: "listings.nav.mine",
|
|
35
|
+
shortLabelKey: "listings.nav.mine.short",
|
|
34
36
|
icon: "ProfileOutlined",
|
|
35
37
|
route: { path: "listings" },
|
|
36
38
|
component: { export: "MyListingsPane", subpath: "default" },
|