@stacksjs/defaults 0.70.322 → 0.70.324
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.
|
@@ -32,17 +32,40 @@ export default defineModel({
|
|
|
32
32
|
belongsTo: ['Product', 'Customer'],
|
|
33
33
|
|
|
34
34
|
attributes: {
|
|
35
|
+
/**
|
|
36
|
+
* One to five stars, or absent.
|
|
37
|
+
*
|
|
38
|
+
* A review is a rating, a written comment, or both, and which of those a
|
|
39
|
+
* shop asks for is the shop's decision - some want a star out of a
|
|
40
|
+
* one-tap prompt, some want prose from a verified buyer, most want either.
|
|
41
|
+
* `required()` here made the first and third impossible: a comment with no
|
|
42
|
+
* star failed validation, so a store that wanted written feedback had to
|
|
43
|
+
* invent a rating to carry it and then filter that invention back out of
|
|
44
|
+
* its own averages.
|
|
45
|
+
*
|
|
46
|
+
* The column has always been nullable; only this rule disagreed. Null means
|
|
47
|
+
* "not rated" and is excluded from an average rather than counted as zero -
|
|
48
|
+
* see `fetchStats` in commerce/products/reviews.
|
|
49
|
+
*
|
|
50
|
+
* `store()` enforces the other half of the rule: a review with neither a
|
|
51
|
+
* rating nor content is not a review, and is rejected there because a
|
|
52
|
+
* cross-field check cannot be expressed on a single attribute.
|
|
53
|
+
*/
|
|
35
54
|
rating: {
|
|
36
55
|
order: 3,
|
|
37
56
|
fillable: true,
|
|
38
57
|
validation: {
|
|
39
|
-
rule: schema.number().
|
|
58
|
+
rule: schema.number().min(1).max(5),
|
|
40
59
|
message: {
|
|
41
60
|
min: 'Rating must be at least 1',
|
|
42
61
|
max: 'Rating cannot be more than 5',
|
|
43
62
|
},
|
|
44
63
|
},
|
|
45
|
-
|
|
64
|
+
// Roughly one in six is a comment with no star, so seeded data exercises
|
|
65
|
+
// the unrated path rather than only ever the happy one.
|
|
66
|
+
factory: faker => faker.datatype.boolean({ probability: 0.84 })
|
|
67
|
+
? faker.number.int({ min: 1, max: 5 })
|
|
68
|
+
: null,
|
|
46
69
|
},
|
|
47
70
|
|
|
48
71
|
title: {
|
|
@@ -66,7 +89,11 @@ export default defineModel({
|
|
|
66
89
|
max: 'Review content must have a maximum of 2000 characters',
|
|
67
90
|
},
|
|
68
91
|
},
|
|
69
|
-
|
|
92
|
+
// And roughly one in five is a bare star with nothing written, which is
|
|
93
|
+
// what a one-tap rating prompt produces.
|
|
94
|
+
factory: faker => faker.datatype.boolean({ probability: 0.8 })
|
|
95
|
+
? faker.lorem.paragraphs({ min: 1, max: 3 })
|
|
96
|
+
: '',
|
|
70
97
|
},
|
|
71
98
|
|
|
72
99
|
isVerifiedPurchase: {
|
package/ide/vscode/package.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.324",
|
|
6
6
|
"description": "The complete managed Stacks application scaffold, including runtime defaults, AI guidance, editor metadata, and npm-backed project support files.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|