@stacksjs/orm 0.72.16 → 0.72.17
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/dist/index.d.ts +97 -97
- package/dist/models/Activity.ts +95 -0
- package/dist/models/AnalyticsEvent.ts +70 -0
- package/dist/models/Automation.ts +23 -0
- package/dist/models/AutomationRun.ts +26 -0
- package/dist/models/Board.ts +104 -0
- package/dist/models/BoardColumn.ts +88 -0
- package/dist/models/Campaign.ts +321 -0
- package/dist/models/CampaignSend.ts +191 -0
- package/dist/models/CampaignVariant.ts +25 -0
- package/dist/models/Card.ts +118 -0
- package/dist/models/CardComment.ts +68 -0
- package/dist/models/Comment.ts +109 -0
- package/dist/models/CommunicationSuppression.ts +22 -0
- package/dist/models/ConsentEvent.ts +30 -0
- package/dist/models/Content/Author.ts +109 -0
- package/dist/models/Content/Menu.ts +56 -0
- package/dist/models/Content/MenuItem.ts +91 -0
- package/dist/models/Content/Page.ts +205 -0
- package/dist/models/Content/PageRevision.ts +86 -0
- package/dist/models/Content/Post.ts +230 -0
- package/dist/models/Content/Redirect.ts +80 -0
- package/dist/models/Deployment.ts +117 -0
- package/dist/models/EmailIdempotency.ts +64 -0
- package/dist/models/EmailList.ts +134 -0
- package/dist/models/EmailListSubscriber.ts +91 -0
- package/dist/models/EmailSuppression.ts +52 -0
- package/dist/models/EmailWebhookEvent.ts +51 -0
- package/dist/models/Error.ts +77 -0
- package/dist/models/FailedJob.ts +84 -0
- package/dist/models/Forms/Form.ts +91 -0
- package/dist/models/Forms/FormField.ts +127 -0
- package/dist/models/Forms/FormSubmission.ts +114 -0
- package/dist/models/Job.ts +69 -0
- package/dist/models/Label.ts +67 -0
- package/dist/models/Log.ts +134 -0
- package/dist/models/MagicLinkToken.ts +97 -0
- package/dist/models/MailPreference.ts +213 -0
- package/dist/models/Notification.ts +68 -0
- package/dist/models/NotificationDelivery.ts +102 -0
- package/dist/models/PaymentMethod.ts +98 -0
- package/dist/models/PaymentProduct.ts +91 -0
- package/dist/models/PaymentTransaction.ts +78 -0
- package/dist/models/QueryLog.ts +182 -0
- package/dist/models/README.md +31 -0
- package/dist/models/Release.ts +90 -0
- package/dist/models/Request.ts +133 -0
- package/dist/models/SenderDomain.ts +22 -0
- package/dist/models/Site.ts +112 -0
- package/dist/models/SiteDomain.ts +74 -0
- package/dist/models/SmsOptOut.ts +65 -0
- package/dist/models/SocialAccount.ts +70 -0
- package/dist/models/SocialPost.ts +144 -0
- package/dist/models/Subscriber.ts +89 -0
- package/dist/models/SubscriberEmail.ts +55 -0
- package/dist/models/Subscription.ts +153 -0
- package/dist/models/Tag.ts +105 -0
- package/dist/models/Team.ts +75 -0
- package/dist/models/TeamInvitation.ts +159 -0
- package/dist/models/TeamMember.ts +88 -0
- package/dist/models/UsageEvent.ts +24 -0
- package/dist/models/User.ts +142 -0
- package/dist/models/commerce/Auction.ts +173 -0
- package/dist/models/commerce/AuctionItem.ts +204 -0
- package/dist/models/commerce/Bid.ts +129 -0
- package/dist/models/commerce/Cart.ts +140 -0
- package/dist/models/commerce/CartItem.ts +138 -0
- package/dist/models/commerce/Category.ts +125 -0
- package/dist/models/commerce/Coupon.ts +186 -0
- package/dist/models/commerce/Customer.ts +132 -0
- package/dist/models/commerce/DeliveryRoute.ts +127 -0
- package/dist/models/commerce/DeliveryStop.ts +166 -0
- package/dist/models/commerce/DigitalDelivery.ts +106 -0
- package/dist/models/commerce/Driver.ts +168 -0
- package/dist/models/commerce/DriverPing.ts +103 -0
- package/dist/models/commerce/GiftCard.ts +195 -0
- package/dist/models/commerce/LicenseKey.ts +89 -0
- package/dist/models/commerce/LoyaltyPoint.ts +108 -0
- package/dist/models/commerce/LoyaltyReward.ts +129 -0
- package/dist/models/commerce/Manufacturer.ts +90 -0
- package/dist/models/commerce/Order.ts +198 -0
- package/dist/models/commerce/OrderIdempotency.ts +34 -0
- package/dist/models/commerce/OrderItem.ts +51 -0
- package/dist/models/commerce/Payment.ts +182 -0
- package/dist/models/commerce/Pledge.ts +112 -0
- package/dist/models/commerce/PrintDevice.ts +120 -0
- package/dist/models/commerce/Product.ts +153 -0
- package/dist/models/commerce/ProductUnit.ts +113 -0
- package/dist/models/commerce/ProductVariant.ts +111 -0
- package/dist/models/commerce/Receipt.ts +144 -0
- package/dist/models/commerce/Review.ts +171 -0
- package/dist/models/commerce/ShippingMethod.ts +102 -0
- package/dist/models/commerce/ShippingRate.ts +79 -0
- package/dist/models/commerce/ShippingZone.ts +116 -0
- package/dist/models/commerce/TaxRate.ts +167 -0
- package/dist/models/commerce/Transaction.ts +127 -0
- package/dist/models/commerce/WaitlistProduct.ts +151 -0
- package/dist/models/commerce/WaitlistRestaurant.ts +189 -0
- package/dist/models/realtime/Websocket.ts +78 -0
- package/dist/password-policy.ts +46 -0
- package/package.json +4 -4
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { defineModel } from '@stacksjs/orm'
|
|
2
|
+
import { schema } from '@stacksjs/validation'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One lot in an auction.
|
|
6
|
+
*
|
|
7
|
+
* Every money column is integer cents. A benefit auction adds several hundred
|
|
8
|
+
* bids together and reports the total to a board; floats lose that argument.
|
|
9
|
+
*/
|
|
10
|
+
export default defineModel({
|
|
11
|
+
name: 'AuctionItem',
|
|
12
|
+
table: 'auction_items',
|
|
13
|
+
primaryKey: 'id',
|
|
14
|
+
autoIncrement: true,
|
|
15
|
+
|
|
16
|
+
traits: {
|
|
17
|
+
useUuid: true,
|
|
18
|
+
useTimestamps: true,
|
|
19
|
+
|
|
20
|
+
useSearch: {
|
|
21
|
+
displayable: ['id', 'lotNumber', 'title', 'status', 'startingBid', 'donorName'],
|
|
22
|
+
searchable: ['title', 'description', 'donorName', 'category'],
|
|
23
|
+
sortable: ['lotNumber', 'startingBid', 'closesAt'],
|
|
24
|
+
filterable: ['status', 'category'],
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
useApi: {
|
|
28
|
+
uri: 'auction-items',
|
|
29
|
+
middleware: { read: ['auth'], write: ['auth'] },
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
observe: true,
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
belongsTo: ['Auction'],
|
|
36
|
+
hasMany: ['Bid'],
|
|
37
|
+
|
|
38
|
+
indexes: [
|
|
39
|
+
{ name: 'auction_items_auction_id_index', columns: ['auction_id'] },
|
|
40
|
+
{ name: 'auction_items_status_index', columns: ['status'] },
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
attributes: {
|
|
44
|
+
lotNumber: {
|
|
45
|
+
order: 1,
|
|
46
|
+
fillable: true,
|
|
47
|
+
validation: {
|
|
48
|
+
rule: schema.number().required().min(1),
|
|
49
|
+
message: {
|
|
50
|
+
required: 'Lot number is required',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
factory: faker => faker.number.int({ min: 1, max: 120 }),
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
title: {
|
|
57
|
+
order: 2,
|
|
58
|
+
fillable: true,
|
|
59
|
+
validation: {
|
|
60
|
+
rule: schema.string().required().max(160),
|
|
61
|
+
message: {
|
|
62
|
+
required: 'Title is required',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
factory: faker => faker.commerce.productName(),
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
description: {
|
|
69
|
+
order: 3,
|
|
70
|
+
fillable: true,
|
|
71
|
+
validation: {
|
|
72
|
+
rule: schema.string(),
|
|
73
|
+
},
|
|
74
|
+
factory: faker => faker.lorem.paragraph(),
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
imageUrl: {
|
|
78
|
+
order: 4,
|
|
79
|
+
fillable: true,
|
|
80
|
+
validation: {
|
|
81
|
+
rule: schema.string().max(500),
|
|
82
|
+
},
|
|
83
|
+
factory: () => '',
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
category: {
|
|
87
|
+
order: 5,
|
|
88
|
+
fillable: true,
|
|
89
|
+
validation: {
|
|
90
|
+
rule: schema.string().max(60),
|
|
91
|
+
},
|
|
92
|
+
factory: faker => faker.helpers.arrayElement(['experiences', 'travel', 'dining', 'sports', 'art', 'services']),
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
/** Who donated the lot. It goes on the tax letter and the thank-you note. */
|
|
96
|
+
donorName: {
|
|
97
|
+
order: 6,
|
|
98
|
+
fillable: true,
|
|
99
|
+
validation: {
|
|
100
|
+
rule: schema.string().max(160),
|
|
101
|
+
},
|
|
102
|
+
factory: faker => faker.company.name(),
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* What the lot is worth, in cents. Drives the sell-through report and the
|
|
107
|
+
* "paid over value" number the development office cares about.
|
|
108
|
+
*/
|
|
109
|
+
fairMarketValue: {
|
|
110
|
+
order: 7,
|
|
111
|
+
fillable: true,
|
|
112
|
+
validation: {
|
|
113
|
+
rule: schema.number().min(0),
|
|
114
|
+
},
|
|
115
|
+
factory: faker => faker.number.int({ min: 5000, max: 200000 }),
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
startingBid: {
|
|
119
|
+
order: 8,
|
|
120
|
+
fillable: true,
|
|
121
|
+
validation: {
|
|
122
|
+
rule: schema.number().required().min(0),
|
|
123
|
+
message: {
|
|
124
|
+
required: 'Starting bid is required',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
factory: faker => faker.number.int({ min: 2500, max: 50000 }),
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A fixed increment for this lot, in cents. Null - the normal case - means
|
|
132
|
+
* the auction-wide ladder applies, which steps bigger as the money gets
|
|
133
|
+
* bigger.
|
|
134
|
+
*/
|
|
135
|
+
minIncrement: {
|
|
136
|
+
order: 9,
|
|
137
|
+
fillable: true,
|
|
138
|
+
validation: {
|
|
139
|
+
rule: schema.number().min(0),
|
|
140
|
+
},
|
|
141
|
+
factory: () => null,
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
/** Bid at or above this and the lot sells immediately. */
|
|
145
|
+
buyNowPrice: {
|
|
146
|
+
order: 10,
|
|
147
|
+
fillable: true,
|
|
148
|
+
validation: {
|
|
149
|
+
rule: schema.number().min(0),
|
|
150
|
+
},
|
|
151
|
+
factory: () => null,
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
/** Below this the lot passes rather than selling. */
|
|
155
|
+
reservePrice: {
|
|
156
|
+
order: 11,
|
|
157
|
+
fillable: true,
|
|
158
|
+
validation: {
|
|
159
|
+
rule: schema.number().min(0),
|
|
160
|
+
},
|
|
161
|
+
factory: () => null,
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
status: {
|
|
165
|
+
default: 'open',
|
|
166
|
+
order: 12,
|
|
167
|
+
fillable: true,
|
|
168
|
+
validation: {
|
|
169
|
+
rule: schema.enum(['open', 'closed', 'sold', 'passed']).required(),
|
|
170
|
+
},
|
|
171
|
+
factory: () => 'open',
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A per-lot close, so a gala can stagger its sections and the room is not
|
|
176
|
+
* asked to watch a hundred lots end at once. Null falls back to the
|
|
177
|
+
* auction's own close. Anti-snipe extensions are written here.
|
|
178
|
+
*/
|
|
179
|
+
closesAt: {
|
|
180
|
+
order: 13,
|
|
181
|
+
fillable: true,
|
|
182
|
+
validation: {
|
|
183
|
+
rule: schema.date(),
|
|
184
|
+
},
|
|
185
|
+
factory: () => null,
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
/** How many times anti-snipe has already extended this lot. */
|
|
189
|
+
extensionCount: {
|
|
190
|
+
default: 0,
|
|
191
|
+
order: 14,
|
|
192
|
+
fillable: false,
|
|
193
|
+
validation: {
|
|
194
|
+
rule: schema.number().min(0),
|
|
195
|
+
},
|
|
196
|
+
factory: () => 0,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
dashboard: {
|
|
201
|
+
icon: 'i-hugeicons-package',
|
|
202
|
+
label: 'Lots',
|
|
203
|
+
},
|
|
204
|
+
} as const)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineModel } from '@stacksjs/orm'
|
|
2
|
+
import { schema } from '@stacksjs/validation'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One bid on one lot.
|
|
6
|
+
*
|
|
7
|
+
* Bidders are identified by name and email rather than by a user account: a
|
|
8
|
+
* benefit auction is bid on by grandparents on borrowed phones, and requiring
|
|
9
|
+
* a signup between them and their paddle costs the school real money.
|
|
10
|
+
*
|
|
11
|
+
* `maxAmount` is the private proxy ceiling. It must never be selected into a
|
|
12
|
+
* template or an API response - the whole mechanism depends on nobody being
|
|
13
|
+
* able to see how far the other side is willing to go. `hidden` keeps it out of
|
|
14
|
+
* the generated CRUD responses; the queries in `@stacksjs/auctions` that feed
|
|
15
|
+
* the public catalogue select columns explicitly for the same reason.
|
|
16
|
+
*/
|
|
17
|
+
export default defineModel({
|
|
18
|
+
name: 'Bid',
|
|
19
|
+
table: 'bids',
|
|
20
|
+
primaryKey: 'id',
|
|
21
|
+
autoIncrement: true,
|
|
22
|
+
|
|
23
|
+
traits: {
|
|
24
|
+
useUuid: true,
|
|
25
|
+
useTimestamps: true,
|
|
26
|
+
|
|
27
|
+
useSearch: {
|
|
28
|
+
displayable: ['id', 'bidderName', 'amount', 'status', 'placedAt'],
|
|
29
|
+
searchable: ['bidderName', 'bidderEmail'],
|
|
30
|
+
sortable: ['placedAt', 'amount'],
|
|
31
|
+
filterable: ['status'],
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// Read is authenticated: the bid history of a lot is staff information
|
|
35
|
+
// while the auction is live. Writes never come through generated CRUD -
|
|
36
|
+
// a bid has to go through the engine, so the app owns that route.
|
|
37
|
+
useApi: {
|
|
38
|
+
uri: 'bids',
|
|
39
|
+
routes: ['index', 'show'],
|
|
40
|
+
middleware: ['auth'],
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
observe: true,
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
belongsTo: ['Auction', 'AuctionItem'],
|
|
47
|
+
|
|
48
|
+
indexes: [
|
|
49
|
+
{ name: 'bids_auction_item_id_index', columns: ['auction_item_id'] },
|
|
50
|
+
{ name: 'bids_auction_id_index', columns: ['auction_id'] },
|
|
51
|
+
{ name: 'bids_bidder_email_index', columns: ['bidder_email'] },
|
|
52
|
+
{ name: 'bids_status_index', columns: ['status'] },
|
|
53
|
+
],
|
|
54
|
+
|
|
55
|
+
attributes: {
|
|
56
|
+
bidderName: {
|
|
57
|
+
order: 1,
|
|
58
|
+
fillable: true,
|
|
59
|
+
validation: {
|
|
60
|
+
rule: schema.string().required().max(160),
|
|
61
|
+
message: {
|
|
62
|
+
required: 'Your name is required',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
factory: faker => faker.person.fullName(),
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
bidderEmail: {
|
|
69
|
+
order: 2,
|
|
70
|
+
fillable: true,
|
|
71
|
+
validation: {
|
|
72
|
+
rule: schema.string().email().required(),
|
|
73
|
+
message: {
|
|
74
|
+
required: 'Your email is required',
|
|
75
|
+
email: 'That does not look like an email address',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
factory: faker => faker.internet.email().toLowerCase(),
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
/** The public number: what this bidder is currently committed to, in cents. */
|
|
82
|
+
amount: {
|
|
83
|
+
order: 3,
|
|
84
|
+
fillable: true,
|
|
85
|
+
validation: {
|
|
86
|
+
rule: schema.number().required().min(1),
|
|
87
|
+
message: {
|
|
88
|
+
required: 'A bid amount is required',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
factory: faker => faker.number.int({ min: 5000, max: 200000 }),
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/** The private ceiling, in cents. Null means "this amount only". */
|
|
95
|
+
maxAmount: {
|
|
96
|
+
order: 4,
|
|
97
|
+
fillable: true,
|
|
98
|
+
hidden: true,
|
|
99
|
+
validation: {
|
|
100
|
+
rule: schema.number().min(1),
|
|
101
|
+
},
|
|
102
|
+
factory: () => null,
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
status: {
|
|
106
|
+
default: 'leading',
|
|
107
|
+
order: 5,
|
|
108
|
+
fillable: true,
|
|
109
|
+
validation: {
|
|
110
|
+
rule: schema.enum(['leading', 'outbid', 'won', 'lost', 'invalid']).required(),
|
|
111
|
+
},
|
|
112
|
+
factory: () => 'outbid',
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
placedAt: {
|
|
116
|
+
order: 6,
|
|
117
|
+
fillable: true,
|
|
118
|
+
validation: {
|
|
119
|
+
rule: schema.date().required(),
|
|
120
|
+
},
|
|
121
|
+
factory: faker => faker.date.recent().toISOString(),
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
dashboard: {
|
|
126
|
+
icon: 'i-hugeicons-hand-pointing-right-01',
|
|
127
|
+
label: 'Bids',
|
|
128
|
+
},
|
|
129
|
+
} as const)
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { defineModel } from '@stacksjs/orm'
|
|
2
|
+
import { schema } from '@stacksjs/validation'
|
|
3
|
+
|
|
4
|
+
export default defineModel({
|
|
5
|
+
name: 'Cart',
|
|
6
|
+
table: 'carts',
|
|
7
|
+
primaryKey: 'id',
|
|
8
|
+
autoIncrement: true,
|
|
9
|
+
|
|
10
|
+
traits: {
|
|
11
|
+
useUuid: true,
|
|
12
|
+
useTimestamps: true,
|
|
13
|
+
useSearch: {
|
|
14
|
+
displayable: ['id', 'customerId', 'status', 'totalItems', 'subtotal', 'total', 'expiresAt'],
|
|
15
|
+
searchable: ['id', 'customerId', 'status'],
|
|
16
|
+
sortable: ['createdAt', 'updatedAt', 'expiresAt', 'total'],
|
|
17
|
+
filterable: ['status', 'customerId'],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
useSeeder: {
|
|
21
|
+
count: 10,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
useApi: {
|
|
25
|
+
uri: 'carts',
|
|
26
|
+
middleware: ['auth'],
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
observe: true,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
hasMany: ['CartItem'],
|
|
33
|
+
belongsTo: ['Customer', 'Coupon'],
|
|
34
|
+
|
|
35
|
+
attributes: {
|
|
36
|
+
status: {
|
|
37
|
+
default: 'active',
|
|
38
|
+
order: 1,
|
|
39
|
+
fillable: true,
|
|
40
|
+
validation: {
|
|
41
|
+
rule: schema.enum(['active', 'abandoned', 'converted', 'expired']),
|
|
42
|
+
},
|
|
43
|
+
factory: faker => faker.helpers.arrayElement(['active', 'abandoned', 'converted', 'expired']),
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
totalItems: {
|
|
47
|
+
default: 0,
|
|
48
|
+
order: 2,
|
|
49
|
+
fillable: true,
|
|
50
|
+
validation: {
|
|
51
|
+
rule: schema.number().min(0),
|
|
52
|
+
},
|
|
53
|
+
factory: faker => faker.number.int({ min: 0, max: 20 }),
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
subtotal: {
|
|
57
|
+
default: 0,
|
|
58
|
+
order: 3,
|
|
59
|
+
fillable: true,
|
|
60
|
+
validation: {
|
|
61
|
+
rule: schema.number().min(0),
|
|
62
|
+
},
|
|
63
|
+
factory: faker => faker.number.int({ min: 0, max: 1000 }),
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
taxAmount: {
|
|
67
|
+
default: 0,
|
|
68
|
+
order: 4,
|
|
69
|
+
fillable: true,
|
|
70
|
+
validation: {
|
|
71
|
+
rule: schema.number().min(0),
|
|
72
|
+
},
|
|
73
|
+
factory: faker => faker.number.int({ min: 0, max: 200 }),
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
discountAmount: {
|
|
77
|
+
default: 0,
|
|
78
|
+
order: 5,
|
|
79
|
+
fillable: true,
|
|
80
|
+
validation: {
|
|
81
|
+
rule: schema.number().min(0),
|
|
82
|
+
},
|
|
83
|
+
factory: faker => faker.number.int({ min: 0, max: 100 }),
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
total: {
|
|
87
|
+
default: 0,
|
|
88
|
+
order: 6,
|
|
89
|
+
fillable: true,
|
|
90
|
+
validation: {
|
|
91
|
+
rule: schema.number().min(0),
|
|
92
|
+
},
|
|
93
|
+
factory: faker => faker.number.int({ min: 0, max: 1200 }),
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
expiresAt: {
|
|
97
|
+
order: 7,
|
|
98
|
+
fillable: true,
|
|
99
|
+
validation: {
|
|
100
|
+
rule: schema.timestamp().required(),
|
|
101
|
+
},
|
|
102
|
+
factory: (faker) => {
|
|
103
|
+
const date = faker.date.past()
|
|
104
|
+
return date.toISOString().slice(0, 19).replace('T', ' ')
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
currency: {
|
|
109
|
+
default: 'USD',
|
|
110
|
+
order: 8,
|
|
111
|
+
fillable: true,
|
|
112
|
+
validation: {
|
|
113
|
+
rule: schema.string().max(3),
|
|
114
|
+
},
|
|
115
|
+
factory: faker => faker.helpers.arrayElement(['USD', 'EUR', 'GBP', 'JPY', 'AUD']),
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
notes: {
|
|
119
|
+
order: 9,
|
|
120
|
+
fillable: true,
|
|
121
|
+
validation: {
|
|
122
|
+
rule: schema.string().max(1000),
|
|
123
|
+
},
|
|
124
|
+
factory: faker => faker.lorem.sentence(),
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
appliedCouponId: {
|
|
128
|
+
order: 10,
|
|
129
|
+
fillable: true,
|
|
130
|
+
validation: {
|
|
131
|
+
rule: schema.string().required(),
|
|
132
|
+
},
|
|
133
|
+
factory: () => 'test-coupon-id',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
dashboard: {
|
|
138
|
+
highlight: true,
|
|
139
|
+
},
|
|
140
|
+
} as const)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { defineModel } from '@stacksjs/orm'
|
|
2
|
+
import { schema } from '@stacksjs/validation'
|
|
3
|
+
|
|
4
|
+
export default defineModel({
|
|
5
|
+
name: 'CartItem',
|
|
6
|
+
table: 'cart_items',
|
|
7
|
+
primaryKey: 'id',
|
|
8
|
+
autoIncrement: true,
|
|
9
|
+
|
|
10
|
+
traits: {
|
|
11
|
+
useUuid: true,
|
|
12
|
+
useTimestamps: true,
|
|
13
|
+
useSearch: {
|
|
14
|
+
displayable: ['id', 'cartId', 'productId', 'quantity', 'unitPrice', 'totalPrice'],
|
|
15
|
+
searchable: ['id', 'cartId', 'productId'],
|
|
16
|
+
sortable: ['createdAt', 'updatedAt', 'quantity', 'unitPrice'],
|
|
17
|
+
filterable: ['cartId', 'productId'],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
useSeeder: {
|
|
21
|
+
count: 50,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
useApi: {
|
|
25
|
+
uri: 'cart-items',
|
|
26
|
+
middleware: ['auth'],
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
observe: true,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
belongsTo: ['Cart'],
|
|
33
|
+
|
|
34
|
+
attributes: {
|
|
35
|
+
quantity: {
|
|
36
|
+
order: 1,
|
|
37
|
+
fillable: true,
|
|
38
|
+
validation: {
|
|
39
|
+
rule: schema.number().required().min(1),
|
|
40
|
+
},
|
|
41
|
+
factory: faker => faker.number.int({ min: 1, max: 10 }),
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
unitPrice: {
|
|
45
|
+
order: 2,
|
|
46
|
+
fillable: true,
|
|
47
|
+
validation: {
|
|
48
|
+
rule: schema.number().required().min(0),
|
|
49
|
+
},
|
|
50
|
+
factory: faker => faker.number.int({ min: 1, max: 1000 }),
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
totalPrice: {
|
|
54
|
+
order: 3,
|
|
55
|
+
fillable: true,
|
|
56
|
+
validation: {
|
|
57
|
+
rule: schema.number().required().min(0),
|
|
58
|
+
},
|
|
59
|
+
factory: faker => faker.number.int({ min: 1, max: 1000 }),
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
taxRate: {
|
|
63
|
+
order: 4,
|
|
64
|
+
fillable: true,
|
|
65
|
+
validation: {
|
|
66
|
+
rule: schema.number().min(0).max(100),
|
|
67
|
+
},
|
|
68
|
+
factory: faker => faker.number.int({ min: 0, max: 20 }),
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
taxAmount: {
|
|
72
|
+
order: 5,
|
|
73
|
+
fillable: true,
|
|
74
|
+
validation: {
|
|
75
|
+
rule: schema.number().min(0),
|
|
76
|
+
},
|
|
77
|
+
factory: faker => faker.number.int({ min: 0, max: 50 }),
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
discountPercentage: {
|
|
81
|
+
order: 6,
|
|
82
|
+
fillable: true,
|
|
83
|
+
validation: {
|
|
84
|
+
rule: schema.number().min(0).max(100),
|
|
85
|
+
},
|
|
86
|
+
factory: faker => faker.number.int({ min: 0, max: 50 }),
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
discountAmount: {
|
|
90
|
+
order: 7,
|
|
91
|
+
fillable: true,
|
|
92
|
+
validation: {
|
|
93
|
+
rule: schema.number().min(0),
|
|
94
|
+
},
|
|
95
|
+
factory: faker => faker.number.int({ min: 0, max: 25 }),
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
productName: {
|
|
99
|
+
order: 8,
|
|
100
|
+
fillable: true,
|
|
101
|
+
validation: {
|
|
102
|
+
rule: schema.string().required().max(255),
|
|
103
|
+
},
|
|
104
|
+
factory: faker => faker.commerce.productName(),
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
productSku: {
|
|
108
|
+
order: 9,
|
|
109
|
+
fillable: true,
|
|
110
|
+
validation: {
|
|
111
|
+
rule: schema.string().max(100),
|
|
112
|
+
},
|
|
113
|
+
factory: faker => faker.string.alphanumeric(10),
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
productImage: {
|
|
117
|
+
order: 10,
|
|
118
|
+
fillable: true,
|
|
119
|
+
validation: {
|
|
120
|
+
rule: schema.string().max(255),
|
|
121
|
+
},
|
|
122
|
+
factory: faker => faker.image.url(),
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
notes: {
|
|
126
|
+
order: 11,
|
|
127
|
+
fillable: true,
|
|
128
|
+
validation: {
|
|
129
|
+
rule: schema.string().max(500),
|
|
130
|
+
},
|
|
131
|
+
factory: faker => faker.lorem.sentence(),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
dashboard: {
|
|
136
|
+
highlight: true,
|
|
137
|
+
},
|
|
138
|
+
} as const)
|