@stacksjs/orm 0.74.23 → 0.74.25

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.
@@ -33,10 +33,23 @@ export default defineModel({
33
33
  useApi: {
34
34
  uri: 'boards',
35
35
  routes: ['index', 'store', 'show', 'update', 'destroy'],
36
- middleware: ['auth'],
36
+ // Team-owned since #2412, so the active-team guard applies - the
37
+ // contract in tests/unit/default-team-api-scope-contract.test.ts.
38
+ middleware: ['auth', 'team'],
37
39
  },
38
40
  },
39
41
 
42
+ /*
43
+ * A board belongs to a team, which is what makes it - and everything on it -
44
+ * scopable. Without this, `Board` had no foreign key at all, so row scoping
45
+ * had nothing to resolve and withheld `store`/`update`/`destroy`: a kanban
46
+ * board with no create endpoint (stacksjs/stacks#2412).
47
+ *
48
+ * `BoardColumn` and `Label` chain to here, so this one column scopes all
49
+ * three.
50
+ */
51
+ belongsTo: ['Team'],
52
+
40
53
  hasMany: ['BoardColumn', 'Label'],
41
54
 
42
55
  attributes: {
@@ -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
  /**
@@ -40,6 +40,9 @@ export default defineModel({
40
40
  },
41
41
 
42
42
  belongsTo: ['Board'],
43
+
44
+ // Owned by whoever owns the board it sits on (stacksjs/stacks#2412).
45
+ ownership: parentOwnership('Board', 'board_id'),
43
46
  hasMany: ['Card'],
44
47
 
45
48
  attributes: {
@@ -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
  /**
@@ -39,6 +39,9 @@ export default defineModel({
39
39
 
40
40
  belongsTo: ['Board'],
41
41
 
42
+ // Owned by whoever owns the board it sits on (stacksjs/stacks#2412).
43
+ ownership: parentOwnership('Board', 'board_id'),
44
+
42
45
  attributes: {
43
46
  boardId: {
44
47
  order: 1,
@@ -7,6 +7,17 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+
11
+ /*
12
+ * A delivery policy, not a delivery. Its columns are `name`,
13
+ * `downloadLimit`, `expiryDays`, `requiresLogin` and `automaticDelivery` -
14
+ * a reusable configuration attached to what is sold, with no customer, order
15
+ * or file on it. #2412 guessed this "almost certainly belongs to an order or
16
+ * a customer"; the attributes say otherwise, so it is declared a catalog
17
+ * record and its writes want an admin gate rather than row scoping.
18
+ */
19
+ ownership: false,
20
+
10
21
  traits: {
11
22
  useUuid: true,
12
23
  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,18 @@ export default defineModel({
7
7
  primaryKey: 'id',
8
8
  autoIncrement: true,
9
9
 
10
+
11
+ /*
12
+ * Points belong to a customer. The model carried `walletId`, pointing at a
13
+ * `LoyaltyWallet` that was never built, so nothing resolved an owner and the
14
+ * writes stayed denied (stacksjs/stacks#2412). Scoping by customer is the
15
+ * additive half of that issue's second option; `walletId` is left alone
16
+ * because repointing an existing column is a data decision of its own.
17
+ */
18
+ belongsTo: ['Customer'],
19
+
20
+ ownership: customerOwnership(),
21
+
10
22
  traits: {
11
23
  useUuid: true,
12
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
  /**
@@ -34,7 +34,14 @@ export default defineModel({
34
34
  observe: true,
35
35
  },
36
36
 
37
- belongsTo: ['Auction'],
37
+ /*
38
+ * A pledge is made BY someone. It chained only to `Auction`, an unscoped
39
+ * catalog, so there was no owner to resolve and its writes stayed denied
40
+ * (stacksjs/stacks#2412).
41
+ */
42
+ belongsTo: ['Auction', 'Customer'],
43
+
44
+ ownership: customerOwnership(),
38
45
 
39
46
  indexes: [
40
47
  { name: 'pledges_auction_id_index', columns: ['auction_id'] },
@@ -18,6 +18,14 @@ export default defineModel({
18
18
  primaryKey: 'id',
19
19
  autoIncrement: true,
20
20
  belongsTo: ['PrintDevice'],
21
+
22
+ /*
23
+ * A receipt is a record OF a device, not of a customer - it chains to
24
+ * `PrintDevice`, an unscoped catalog. Saying so explicitly is the honest
25
+ * declaration; its writes want an admin gate rather than row scoping
26
+ * (stacksjs/stacks#2412).
27
+ */
28
+ ownership: false,
21
29
  traits: {
22
30
  useUuid: true,
23
31
  useTimestamps: true,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/orm",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.74.23",
5
+ "version": "0.74.25",
6
6
  "description": "The Stacks ORM integration",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -63,31 +63,31 @@
63
63
  "prepublishOnly": "bun run build"
64
64
  },
65
65
  "dependencies": {
66
- "@stacksjs/cache": "0.74.23",
67
- "@stacksjs/cli": "0.74.23",
68
- "@stacksjs/config": "0.74.23",
69
- "@stacksjs/database": "0.74.23",
70
- "@stacksjs/env": "0.74.23",
71
- "@stacksjs/error-handling": "0.74.23",
72
- "@stacksjs/events": "0.74.23",
73
- "@stacksjs/logging": "0.74.23",
74
- "@stacksjs/model-meta": "0.74.23",
75
- "@stacksjs/pagination": "0.74.23",
76
- "@stacksjs/path": "0.74.23",
77
- "@stacksjs/query-builder": "0.74.23",
78
- "@stacksjs/realtime": "0.74.23",
79
- "@stacksjs/router": "0.74.23",
80
- "@stacksjs/storage": "0.74.23",
81
- "@stacksjs/strings": "0.74.23",
66
+ "@stacksjs/cache": "0.74.25",
67
+ "@stacksjs/cli": "0.74.25",
68
+ "@stacksjs/config": "0.74.25",
69
+ "@stacksjs/database": "0.74.25",
70
+ "@stacksjs/env": "0.74.25",
71
+ "@stacksjs/error-handling": "0.74.25",
72
+ "@stacksjs/events": "0.74.25",
73
+ "@stacksjs/logging": "0.74.25",
74
+ "@stacksjs/model-meta": "0.74.25",
75
+ "@stacksjs/pagination": "0.74.25",
76
+ "@stacksjs/path": "0.74.25",
77
+ "@stacksjs/query-builder": "0.74.25",
78
+ "@stacksjs/realtime": "0.74.25",
79
+ "@stacksjs/router": "0.74.25",
80
+ "@stacksjs/storage": "0.74.25",
81
+ "@stacksjs/strings": "0.74.25",
82
82
  "@stacksjs/ts-validation": "^0.5.6",
83
- "@stacksjs/validation": "0.74.23",
84
- "bun-query-builder": "^0.2.62"
83
+ "@stacksjs/validation": "0.74.25",
84
+ "bun-query-builder": "^0.2.67"
85
85
  },
86
86
  "peerDependencies": {
87
- "@stacksjs/auth": "0.74.23",
88
- "@stacksjs/payments": "0.74.23",
89
- "@stacksjs/queue": "0.74.23",
90
- "@stacksjs/search-engine": "0.74.23",
87
+ "@stacksjs/auth": "0.74.25",
88
+ "@stacksjs/payments": "0.74.25",
89
+ "@stacksjs/queue": "0.74.25",
90
+ "@stacksjs/search-engine": "0.74.25",
91
91
  "stripe": "22.3.2"
92
92
  },
93
93
  "peerDependenciesMeta": {
@@ -108,7 +108,7 @@
108
108
  }
109
109
  },
110
110
  "devDependencies": {
111
- "@stacksjs/types": "0.74.23",
111
+ "@stacksjs/types": "0.74.25",
112
112
  "better-dx": "^0.2.24",
113
113
  "stripe": "22.3.2"
114
114
  }