@stacksjs/orm 0.74.1 → 0.74.2

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.
Files changed (53) hide show
  1. package/dist/auto-crud.d.ts +30 -0
  2. package/dist/generate-database-schema.d.ts +1 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +9 -9
  5. package/dist/migration-tables.d.ts +18 -0
  6. package/dist/models/AnalyticsEvent.ts +5 -0
  7. package/dist/models/Content/Menu.ts +5 -1
  8. package/dist/models/Content/MenuItem.ts +6 -1
  9. package/dist/models/Content/Page.ts +5 -1
  10. package/dist/models/Content/Post.ts +5 -1
  11. package/dist/models/Content/Redirect.ts +5 -1
  12. package/dist/models/EmailIdempotency.ts +5 -0
  13. package/dist/models/EmailList.ts +6 -0
  14. package/dist/models/EmailSuppression.ts +5 -0
  15. package/dist/models/EmailWebhookEvent.ts +5 -0
  16. package/dist/models/Forms/Form.ts +5 -1
  17. package/dist/models/Forms/FormField.ts +6 -1
  18. package/dist/models/MailPreference.ts +5 -0
  19. package/dist/models/Request.ts +5 -0
  20. package/dist/models/SiteDomain.ts +5 -1
  21. package/dist/models/Tag.ts +6 -0
  22. package/dist/models/Team.ts +6 -1
  23. package/dist/models/User.ts +6 -1
  24. package/dist/models/commerce/Auction.ts +6 -0
  25. package/dist/models/commerce/AuctionItem.ts +6 -0
  26. package/dist/models/commerce/Cart.ts +6 -1
  27. package/dist/models/commerce/CartItem.ts +6 -1
  28. package/dist/models/commerce/Category.ts +6 -0
  29. package/dist/models/commerce/Coupon.ts +6 -0
  30. package/dist/models/commerce/DeliveryRoute.ts +6 -1
  31. package/dist/models/commerce/DeliveryStop.ts +6 -1
  32. package/dist/models/commerce/GiftCard.ts +6 -1
  33. package/dist/models/commerce/LicenseKey.ts +6 -1
  34. package/dist/models/commerce/LoyaltyReward.ts +6 -0
  35. package/dist/models/commerce/Manufacturer.ts +6 -0
  36. package/dist/models/commerce/Order.ts +6 -1
  37. package/dist/models/commerce/Payment.ts +6 -1
  38. package/dist/models/commerce/PrintDevice.ts +6 -0
  39. package/dist/models/commerce/Product.ts +6 -0
  40. package/dist/models/commerce/ProductUnit.ts +6 -0
  41. package/dist/models/commerce/ProductVariant.ts +6 -0
  42. package/dist/models/commerce/Review.ts +6 -1
  43. package/dist/models/commerce/ShippingMethod.ts +6 -0
  44. package/dist/models/commerce/ShippingRate.ts +6 -0
  45. package/dist/models/commerce/ShippingZone.ts +6 -0
  46. package/dist/models/commerce/TaxRate.ts +6 -0
  47. package/dist/models/commerce/Transaction.ts +6 -1
  48. package/dist/models/commerce/WaitlistProduct.ts +6 -1
  49. package/dist/models/commerce/WaitlistRestaurant.ts +6 -1
  50. package/dist/models/realtime/Websocket.ts +5 -0
  51. package/dist/ownership.d.ts +96 -0
  52. package/dist/routes.js +1 -1
  53. package/package.json +21 -21
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, siteOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -20,6 +20,10 @@ export default defineModel({
20
20
  },
21
21
  ],
22
22
 
23
+ // Owned through the site, which belongs to a team, so the owner is the set of
24
+ // site ids the caller's team owns rather than a single id (stacksjs/stacks#2375).
25
+ ownership: siteOwnership(),
26
+
23
27
  traits: {
24
28
  useTimestamps: true,
25
29
  useApi: {
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, parentOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -11,6 +11,11 @@ export default defineModel({
11
11
  primaryKey: 'id',
12
12
  autoIncrement: true,
13
13
 
14
+ // No owner of its own: these rows are owned by whoever owns the menu's site, and so its team
15
+ // (stacksjs/stacks#2375). Resolved through the parent so it follows any change
16
+ // to how Menu decides ownership.
17
+ ownership: parentOwnership('Menu', 'menu_id'),
18
+
14
19
  traits: {
15
20
  useTimestamps: true,
16
21
  useApi: {
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, siteOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -28,6 +28,10 @@ export default defineModel({
28
28
  },
29
29
  ],
30
30
 
31
+ // Owned through the site, which belongs to a team, so the owner is the set of
32
+ // site ids the caller's team owns rather than a single id (stacksjs/stacks#2375).
33
+ ownership: siteOwnership(),
34
+
31
35
  traits: {
32
36
  useUuid: true,
33
37
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, siteOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,10 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // Owned through the site, which belongs to a team, so the owner is the set of
11
+ // site ids the caller's team owns rather than a single id (stacksjs/stacks#2375).
12
+ ownership: siteOwnership(),
13
+
10
14
  traits: {
11
15
  useUuid: true,
12
16
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, siteOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -21,6 +21,10 @@ export default defineModel({
21
21
  },
22
22
  ],
23
23
 
24
+ // Owned through the site, which belongs to a team, so the owner is the set of
25
+ // site ids the caller's team owns rather than a single id (stacksjs/stacks#2375).
26
+ ownership: siteOwnership(),
27
+
24
28
  traits: {
25
29
  useTimestamps: true,
26
30
  useApi: {
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // An infrastructure table: rows are written by the system, not on behalf of a
11
+ // caller, so no row has a per-caller owner to scope by. Writes are gated by
12
+ // `middleware` instead. Declared rather than left silent (stacksjs/stacks#2375).
13
+ ownership: false,
14
+
10
15
  traits: {
11
16
  useTimestamps: true,
12
17
  useApi: {
@@ -8,6 +8,12 @@ export default defineModel({
8
8
  autoIncrement: true,
9
9
  hasMany: ['EmailListSubscriber', 'Campaign', 'CampaignSend'],
10
10
 
11
+ // A reference table: no row here has a per-caller owner, so there is nothing
12
+ // to scope by and writes are an administrative concern gated by `middleware`.
13
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
14
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
15
+ ownership: false,
16
+
11
17
  traits: {
12
18
  useUuid: true,
13
19
  useTimestamps: true,
@@ -15,6 +15,11 @@ export default defineModel({
15
15
  },
16
16
  ],
17
17
 
18
+ // An infrastructure table: rows are written by the system, not on behalf of a
19
+ // caller, so no row has a per-caller owner to scope by. Writes are gated by
20
+ // `middleware` instead. Declared rather than left silent (stacksjs/stacks#2375).
21
+ ownership: false,
22
+
18
23
  traits: {
19
24
  useTimestamps: true,
20
25
  useApi: {
@@ -15,6 +15,11 @@ export default defineModel({
15
15
  },
16
16
  ],
17
17
 
18
+ // An infrastructure table: rows are written by the system, not on behalf of a
19
+ // caller, so no row has a per-caller owner to scope by. Writes are gated by
20
+ // `middleware` instead. Declared rather than left silent (stacksjs/stacks#2375).
21
+ ownership: false,
22
+
18
23
  traits: {
19
24
  useTimestamps: true,
20
25
  useApi: {
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, siteOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -23,6 +23,10 @@ export default defineModel({
23
23
  },
24
24
  ],
25
25
 
26
+ // Owned through the site, which belongs to a team, so the owner is the set of
27
+ // site ids the caller's team owns rather than a single id (stacksjs/stacks#2375).
28
+ ownership: siteOwnership(),
29
+
26
30
  traits: {
27
31
  useUuid: true,
28
32
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, parentOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -21,6 +21,11 @@ export default defineModel({
21
21
  },
22
22
  ],
23
23
 
24
+ // No owner of its own: these rows are owned by whoever owns the form's site, and so its team
25
+ // (stacksjs/stacks#2375). Resolved through the parent so it follows any change
26
+ // to how Form decides ownership.
27
+ ownership: parentOwnership('Form', 'form_id'),
28
+
24
29
  traits: {
25
30
  useTimestamps: true,
26
31
  useApi: {
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // An infrastructure table: rows are written by the system, not on behalf of a
11
+ // caller, so no row has a per-caller owner to scope by. Writes are gated by
12
+ // `middleware` instead. Declared rather than left silent (stacksjs/stacks#2375).
13
+ ownership: false,
14
+
10
15
  traits: {
11
16
  useTimestamps: true,
12
17
  useApi: {
@@ -22,6 +22,11 @@ export default defineModel({
22
22
  },
23
23
  ],
24
24
 
25
+ // An infrastructure table: rows are written by the system, not on behalf of a
26
+ // caller, so no row has a per-caller owner to scope by. Writes are gated by
27
+ // `middleware` instead. Declared rather than left silent (stacksjs/stacks#2375).
28
+ ownership: false,
29
+
25
30
  traits: {
26
31
  useTimestamps: true,
27
32
  useSoftDeletes: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, siteOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -14,6 +14,10 @@ export default defineModel({
14
14
  primaryKey: 'id',
15
15
  autoIncrement: true,
16
16
 
17
+ // Owned through the site, which belongs to a team, so the owner is the set of
18
+ // site ids the caller's team owns rather than a single id (stacksjs/stacks#2375).
19
+ ownership: siteOwnership(),
20
+
17
21
  traits: {
18
22
  useTimestamps: true,
19
23
  observe: true, // domain changes clear the host-resolution cache
@@ -25,6 +25,12 @@ export default defineModel({
25
25
  primaryKey: 'id',
26
26
  autoIncrement: true,
27
27
 
28
+ // A reference table: no row here has a per-caller owner, so there is nothing
29
+ // to scope by and writes are an administrative concern gated by `middleware`.
30
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
31
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
32
+ ownership: false,
33
+
28
34
  traits: {
29
35
  useUuid: true,
30
36
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, teamMembershipOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // The owner column is the primary key: a caller may write the team they are
11
+ // actually a member of, resolved by the same auth path every other
12
+ // team-scoped model uses (stacksjs/stacks#2375).
13
+ ownership: teamMembershipOwnership(),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -1,5 +1,5 @@
1
1
  import type { Attributes } from '@stacksjs/types'
2
- import { defineModel } from '@stacksjs/orm'
2
+ import { defineModel, selfOwnership } from '@stacksjs/orm'
3
3
  import { makeHash } from '@stacksjs/security'
4
4
  // soon, these will be auto-imported
5
5
  import { schema } from '@stacksjs/validation'
@@ -19,6 +19,11 @@ export default defineModel({
19
19
  },
20
20
  ],
21
21
 
22
+ // A caller may write their own row and no other (stacksjs/stacks#2375). The
23
+ // owner column IS the primary key here, so without this `User` is the worst
24
+ // case the issue describes: an authenticated caller able to PATCH any user.
25
+ ownership: selfOwnership(),
26
+
22
27
  traits: {
23
28
  useAuth: {
24
29
  usePasskey: true,
@@ -17,6 +17,12 @@ export default defineModel({
17
17
  primaryKey: 'id',
18
18
  autoIncrement: true,
19
19
 
20
+ // A reference table: no row here has a per-caller owner, so there is nothing
21
+ // to scope by and writes are an administrative concern gated by `middleware`.
22
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
23
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
24
+ ownership: false,
25
+
20
26
  traits: {
21
27
  useUuid: true,
22
28
  useTimestamps: true,
@@ -13,6 +13,12 @@ export default defineModel({
13
13
  primaryKey: 'id',
14
14
  autoIncrement: true,
15
15
 
16
+ // A reference table: no row here has a per-caller owner, so there is nothing
17
+ // to scope by and writes are an administrative concern gated by `middleware`.
18
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
19
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
20
+ ownership: false,
21
+
16
22
  traits: {
17
23
  useUuid: true,
18
24
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { customerOwnership, defineModel } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // Rows belong to the caller's customer record, one hop from the user
11
+ // (stacksjs/stacks#2375). Without this the generated writes are reachable by
12
+ // any authenticated caller for any row.
13
+ ownership: customerOwnership(),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, parentOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // No owner of its own: these rows are owned by whoever owns the cart's customer
11
+ // (stacksjs/stacks#2375). Resolved through the parent so it follows any change
12
+ // to how Cart decides ownership.
13
+ ownership: parentOwnership('Cart', 'cart_id'),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -8,6 +8,12 @@ export default defineModel({
8
8
  primaryKey: 'id',
9
9
  autoIncrement: true,
10
10
 
11
+ // A reference table: no row here has a per-caller owner, so there is nothing
12
+ // to scope by and writes are an administrative concern gated by `middleware`.
13
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
14
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
15
+ ownership: false,
16
+
11
17
  traits: {
12
18
  useUuid: true,
13
19
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, parentOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // No owner of its own: these rows are owned by whoever owns the courier, who is a user
11
+ // (stacksjs/stacks#2375). Resolved through the parent so it follows any change
12
+ // to how Courier decides ownership.
13
+ ownership: parentOwnership('Courier', 'courier_id'),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, parentOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  /**
@@ -18,6 +18,11 @@ export default defineModel({
18
18
  primaryKey: 'id',
19
19
  autoIncrement: true,
20
20
 
21
+ // No owner of its own: these rows are owned by whoever owns the order's customer
22
+ // (stacksjs/stacks#2375). Resolved through the parent so it follows any change
23
+ // to how Order decides ownership.
24
+ ownership: parentOwnership('Order', 'order_id'),
25
+
21
26
  traits: {
22
27
  useUuid: true,
23
28
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { customerOwnership, defineModel } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // Rows belong to the caller's customer record, one hop from the user
11
+ // (stacksjs/stacks#2375). Without this the generated writes are reachable by
12
+ // any authenticated caller for any row.
13
+ ownership: customerOwnership(),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { customerOwnership, defineModel } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // Rows belong to the caller's customer record, one hop from the user
11
+ // (stacksjs/stacks#2375). Without this the generated writes are reachable by
12
+ // any authenticated caller for any row.
13
+ ownership: customerOwnership(),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { customerOwnership, defineModel } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // Rows belong to the caller's customer record, one hop from the user
11
+ // (stacksjs/stacks#2375). Without this the generated writes are reachable by
12
+ // any authenticated caller for any row.
13
+ ownership: customerOwnership(),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { customerOwnership, defineModel } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // Rows belong to the caller's customer record, one hop from the user
11
+ // (stacksjs/stacks#2375). Without this the generated writes are reachable by
12
+ // any authenticated caller for any row.
13
+ ownership: customerOwnership(),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
  hasMany: ['Receipt'],
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { customerOwnership, defineModel } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // Rows belong to the caller's customer record, one hop from the user
11
+ // (stacksjs/stacks#2375). Without this the generated writes are reachable by
12
+ // any authenticated caller for any row.
13
+ ownership: customerOwnership(),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -7,6 +7,12 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // A reference table: no row here has a per-caller owner, so there is nothing
11
+ // to scope by and writes are an administrative concern gated by `middleware`.
12
+ // Declared rather than left silent so `security.api.rowScoping: 'deny'` can
13
+ // tell "considered" from "nobody thought about it" (stacksjs/stacks#2375).
14
+ ownership: false,
15
+
10
16
  traits: {
11
17
  useUuid: true,
12
18
  useTimestamps: true,
@@ -1,4 +1,4 @@
1
- import { defineModel } from '@stacksjs/orm'
1
+ import { defineModel, parentOwnership } from '@stacksjs/orm'
2
2
  import { schema } from '@stacksjs/validation'
3
3
 
4
4
  export default defineModel({
@@ -7,6 +7,11 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+ // No owner of its own: these rows are owned by whoever owns the order's customer
11
+ // (stacksjs/stacks#2375). Resolved through the parent so it follows any change
12
+ // to how Order decides ownership.
13
+ ownership: parentOwnership('Order', 'order_id'),
14
+
10
15
  traits: {
11
16
  useUuid: true,
12
17
  useTimestamps: true,