@opensaas/stack-core 0.44.0-alpha.5 → 0.44.0-alpha.7
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 +1051 -0
- package/dist/.build-hash +1 -1
- package/dist/access/actor.d.ts +56 -0
- package/dist/access/actor.d.ts.map +1 -0
- package/dist/access/actor.js +66 -0
- package/dist/access/actor.js.map +1 -0
- package/dist/access/decide-advertisement.d.ts +55 -0
- package/dist/access/decide-advertisement.d.ts.map +1 -0
- package/dist/access/decide-advertisement.js +125 -0
- package/dist/access/decide-advertisement.js.map +1 -0
- package/dist/access/declared-dependencies.d.ts +4 -89
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +14 -84
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +2 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +2 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +1 -24
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +0 -35
- package/dist/access/engine.js.map +1 -1
- package/dist/access/field-access.d.ts +43 -19
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +206 -185
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/index.d.ts +5 -6
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -7
- package/dist/access/index.js.map +1 -1
- package/dist/access/rule-item.d.ts +42 -0
- package/dist/access/rule-item.d.ts.map +1 -0
- package/dist/access/rule-item.js +215 -0
- package/dist/access/rule-item.js.map +1 -0
- package/dist/access/session-vocabulary.d.ts +124 -0
- package/dist/access/session-vocabulary.d.ts.map +1 -0
- package/dist/access/session-vocabulary.js +366 -0
- package/dist/access/session-vocabulary.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +6 -0
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +19 -2
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +66 -0
- package/dist/access/types.d.ts.map +1 -1
- package/dist/access/vocabulary-filter-specs.d.ts +17 -0
- package/dist/access/vocabulary-filter-specs.d.ts.map +1 -0
- package/dist/access/vocabulary-filter-specs.js +27 -0
- package/dist/access/vocabulary-filter-specs.js.map +1 -0
- package/dist/client-safe.d.ts +8 -0
- package/dist/client-safe.d.ts.map +1 -0
- package/dist/client-safe.js +8 -0
- package/dist/client-safe.js.map +1 -0
- package/dist/config/field-kind.d.ts +7 -21
- package/dist/config/field-kind.d.ts.map +1 -1
- package/dist/config/field-kind.js +8 -5
- package/dist/config/field-kind.js.map +1 -1
- package/dist/config/has-access-gate.d.ts +20 -0
- package/dist/config/has-access-gate.d.ts.map +1 -0
- package/dist/config/has-access-gate.js +26 -0
- package/dist/config/has-access-gate.js.map +1 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +8 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/list-view-keys.d.ts +5 -0
- package/dist/config/list-view-keys.d.ts.map +1 -0
- package/dist/config/list-view-keys.js +18 -0
- package/dist/config/list-view-keys.js.map +1 -0
- package/dist/config/mcp-default-tools.d.ts +3 -0
- package/dist/config/mcp-default-tools.d.ts.map +1 -0
- package/dist/config/mcp-default-tools.js +14 -0
- package/dist/config/mcp-default-tools.js.map +1 -0
- package/dist/config/mcp-tool-names.d.ts +2 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -1
- package/dist/config/mcp-tool-names.js +17 -5
- package/dist/config/mcp-tool-names.js.map +1 -1
- package/dist/config/nav-count.d.ts +8 -16
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +20 -32
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +6 -0
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/preset-views.d.ts +22 -0
- package/dist/config/preset-views.d.ts.map +1 -0
- package/dist/config/preset-views.js +46 -0
- package/dist/config/preset-views.js.map +1 -0
- package/dist/config/row-action-availability.d.ts +4 -0
- package/dist/config/row-action-availability.d.ts.map +1 -0
- package/dist/config/row-action-availability.js +20 -0
- package/dist/config/row-action-availability.js.map +1 -0
- package/dist/config/types.d.ts +409 -34
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/engine-context.d.ts +2 -0
- package/dist/context/engine-context.d.ts.map +1 -1
- package/dist/context/engine-context.js +8 -0
- package/dist/context/engine-context.js.map +1 -1
- package/dist/context/hook-pipeline.d.ts +6 -1
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +6 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +10 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +217 -94
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +28 -21
- package/dist/context/junction.d.ts.map +1 -1
- package/dist/context/junction.js +74 -69
- package/dist/context/junction.js.map +1 -1
- package/dist/context/plugin-field-write.d.ts.map +1 -1
- package/dist/context/plugin-field-write.js +19 -25
- package/dist/context/plugin-field-write.js.map +1 -1
- package/dist/context/process-lifetime.d.ts +8 -0
- package/dist/context/process-lifetime.d.ts.map +1 -0
- package/dist/context/process-lifetime.js +14 -0
- package/dist/context/process-lifetime.js.map +1 -0
- package/dist/context/relationship-input.d.ts +2 -15
- package/dist/context/relationship-input.d.ts.map +1 -1
- package/dist/context/relationship-input.js +44 -85
- package/dist/context/relationship-input.js.map +1 -1
- package/dist/context/transaction-boundary.d.ts +3 -2
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +17 -2
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +5 -19
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +54 -92
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/context/write-target.d.ts +52 -0
- package/dist/context/write-target.d.ts.map +1 -0
- package/dist/context/write-target.js +118 -0
- package/dist/context/write-target.js.map +1 -0
- package/dist/contract/dependencies.d.ts +24 -10
- package/dist/contract/dependencies.d.ts.map +1 -1
- package/dist/contract/dependencies.js +120 -80
- package/dist/contract/dependencies.js.map +1 -1
- package/dist/contract/derive.d.ts +6 -11
- package/dist/contract/derive.d.ts.map +1 -1
- package/dist/contract/derive.js +256 -211
- package/dist/contract/derive.js.map +1 -1
- package/dist/contract/fixtures/contract-configs.d.ts +5 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -1
- package/dist/contract/fixtures/contract-configs.js +21 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -1
- package/dist/contract/id-boundary.js +1 -1
- package/dist/contract/id-boundary.js.map +1 -1
- package/dist/contract/prisma.js +2 -2
- package/dist/contract/prisma.js.map +1 -1
- package/dist/contract/strategy.d.ts +13 -0
- package/dist/contract/strategy.d.ts.map +1 -0
- package/dist/contract/strategy.js +38 -0
- package/dist/contract/strategy.js.map +1 -0
- package/dist/db/client-alias.d.ts +12 -0
- package/dist/db/client-alias.d.ts.map +1 -0
- package/dist/db/client-alias.js +8 -0
- package/dist/db/client-alias.js.map +1 -0
- package/dist/extend.d.ts +2 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +12 -14
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +217 -67
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +43 -25
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +107 -38
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +7 -5
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +6 -14
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +112 -20
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +271 -52
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/parse.d.ts +70 -26
- package/dist/filter/parse.d.ts.map +1 -1
- package/dist/filter/parse.js +212 -79
- package/dist/filter/parse.js.map +1 -1
- package/dist/filter/record-id.d.ts +19 -0
- package/dist/filter/record-id.d.ts.map +1 -0
- package/dist/filter/record-id.js +37 -0
- package/dist/filter/record-id.js.map +1 -0
- package/dist/filter/serialize.d.ts +45 -19
- package/dist/filter/serialize.d.ts.map +1 -1
- package/dist/filter/serialize.js +146 -50
- package/dist/filter/serialize.js.map +1 -1
- package/dist/filter/types.d.ts +132 -21
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/types.js +2 -11
- package/dist/filter/types.js.map +1 -1
- package/dist/hooks/index.d.ts +6 -3
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +38 -8
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +11 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +8 -8
- package/dist/internal.js.map +1 -1
- package/dist/lib/database-errors.d.ts +2 -1
- package/dist/lib/database-errors.d.ts.map +1 -1
- package/dist/lib/database-errors.js +5 -4
- package/dist/lib/database-errors.js.map +1 -1
- package/dist/mcp/advertise.d.ts +5 -13
- package/dist/mcp/advertise.d.ts.map +1 -1
- package/dist/mcp/advertise.js +7 -22
- package/dist/mcp/advertise.js.map +1 -1
- package/dist/mcp/arguments.d.ts.map +1 -1
- package/dist/mcp/arguments.js +8 -11
- package/dist/mcp/arguments.js.map +1 -1
- package/dist/mcp/field-schema.d.ts +4 -15
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +50 -69
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +111 -18
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +231 -87
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/procedure-tools.d.ts +63 -0
- package/dist/mcp/procedure-tools.d.ts.map +1 -0
- package/dist/mcp/procedure-tools.js +139 -0
- package/dist/mcp/procedure-tools.js.map +1 -0
- package/dist/mcp/projection.d.ts +6 -5
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +33 -38
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/reachability.d.ts +13 -0
- package/dist/mcp/reachability.d.ts.map +1 -0
- package/dist/mcp/reachability.js +51 -0
- package/dist/mcp/reachability.js.map +1 -0
- package/dist/mcp/relation-member.d.ts +15 -0
- package/dist/mcp/relation-member.d.ts.map +1 -0
- package/dist/mcp/relation-member.js +50 -0
- package/dist/mcp/relation-member.js.map +1 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.js +12 -24
- package/dist/mcp/where-id-boundary.js.map +1 -1
- package/dist/mcp/where-reachability.d.ts +10 -0
- package/dist/mcp/where-reachability.d.ts.map +1 -0
- package/dist/mcp/where-reachability.js +88 -0
- package/dist/mcp/where-reachability.js.map +1 -0
- package/dist/members/claims.d.ts +71 -0
- package/dist/members/claims.d.ts.map +1 -0
- package/dist/members/claims.js +199 -0
- package/dist/members/claims.js.map +1 -0
- package/dist/members/list-members.d.ts +87 -0
- package/dist/members/list-members.d.ts.map +1 -0
- package/dist/members/list-members.js +250 -0
- package/dist/members/list-members.js.map +1 -0
- package/dist/procedures/client.d.ts +163 -0
- package/dist/procedures/client.d.ts.map +1 -0
- package/dist/procedures/client.js +152 -0
- package/dist/procedures/client.js.map +1 -0
- package/dist/procedures/codes.d.ts +23 -0
- package/dist/procedures/codes.d.ts.map +1 -0
- package/dist/procedures/codes.js +46 -0
- package/dist/procedures/codes.js.map +1 -0
- package/dist/procedures/context-face.d.ts +4 -0
- package/dist/procedures/context-face.d.ts.map +1 -0
- package/dist/procedures/context-face.js +31 -0
- package/dist/procedures/context-face.js.map +1 -0
- package/dist/procedures/failures.d.ts +31 -0
- package/dist/procedures/failures.d.ts.map +1 -0
- package/dist/procedures/failures.js +51 -0
- package/dist/procedures/failures.js.map +1 -0
- package/dist/procedures/http.d.ts +114 -0
- package/dist/procedures/http.d.ts.map +1 -0
- package/dist/procedures/http.js +224 -0
- package/dist/procedures/http.js.map +1 -0
- package/dist/procedures/index.d.ts +7 -0
- package/dist/procedures/index.d.ts.map +1 -0
- package/dist/procedures/index.js +11 -0
- package/dist/procedures/index.js.map +1 -0
- package/dist/procedures/procedure.d.ts +204 -0
- package/dist/procedures/procedure.d.ts.map +1 -0
- package/dist/procedures/procedure.js +123 -0
- package/dist/procedures/procedure.js.map +1 -0
- package/dist/procedures/result.d.ts +42 -0
- package/dist/procedures/result.d.ts.map +1 -0
- package/dist/procedures/result.js +51 -0
- package/dist/procedures/result.js.map +1 -0
- package/dist/procedures/run.d.ts +36 -0
- package/dist/procedures/run.d.ts.map +1 -0
- package/dist/procedures/run.js +76 -0
- package/dist/procedures/run.js.map +1 -0
- package/dist/procedures/server.d.ts +131 -0
- package/dist/procedures/server.d.ts.map +1 -0
- package/dist/procedures/server.js +115 -0
- package/dist/procedures/server.js.map +1 -0
- package/dist/procedures/validate.d.ts +60 -0
- package/dist/procedures/validate.d.ts.map +1 -0
- package/dist/procedures/validate.js +254 -0
- package/dist/procedures/validate.js.map +1 -0
- package/dist/procedures/web-session.d.ts +12 -0
- package/dist/procedures/web-session.d.ts.map +1 -0
- package/dist/procedures/web-session.js +35 -0
- package/dist/procedures/web-session.js.map +1 -0
- package/dist/query/relationship-options.d.ts +8 -0
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +18 -4
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/binding.d.ts +84 -0
- package/dist/secured/binding.d.ts.map +1 -0
- package/dist/secured/binding.js +52 -0
- package/dist/secured/binding.js.map +1 -0
- package/dist/secured/declared-branch.d.ts +11 -0
- package/dist/secured/declared-branch.d.ts.map +1 -0
- package/dist/secured/declared-branch.js +17 -0
- package/dist/secured/declared-branch.js.map +1 -0
- package/dist/secured/field-visibility.d.ts +56 -0
- package/dist/secured/field-visibility.d.ts.map +1 -0
- package/dist/secured/field-visibility.js +624 -0
- package/dist/secured/field-visibility.js.map +1 -0
- package/dist/secured/include.d.ts +77 -37
- package/dist/secured/include.d.ts.map +1 -1
- package/dist/secured/include.js +228 -122
- package/dist/secured/include.js.map +1 -1
- package/dist/secured/lock.d.ts +8 -2
- package/dist/secured/lock.d.ts.map +1 -1
- package/dist/secured/lock.js +44 -15
- package/dist/secured/lock.js.map +1 -1
- package/dist/secured/lower.d.ts.map +1 -1
- package/dist/secured/lower.js +15 -4
- package/dist/secured/lower.js.map +1 -1
- package/dist/secured/read.d.ts +13 -52
- package/dist/secured/read.d.ts.map +1 -1
- package/dist/secured/read.js +88 -614
- package/dist/secured/read.js.map +1 -1
- package/dist/secured/select.d.ts +0 -24
- package/dist/secured/select.d.ts.map +1 -1
- package/dist/secured/select.js +60 -153
- package/dist/secured/select.js.map +1 -1
- package/dist/secured/vocabulary.d.ts +13 -1
- package/dist/secured/vocabulary.d.ts.map +1 -1
- package/dist/secured/vocabulary.js +173 -83
- package/dist/secured/vocabulary.js.map +1 -1
- package/dist/testing/untyped-rule.d.ts +8 -0
- package/dist/testing/untyped-rule.d.ts.map +1 -0
- package/dist/testing/untyped-rule.js +4 -0
- package/dist/testing/untyped-rule.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rows.d.ts +18 -1
- package/dist/types/rows.d.ts.map +1 -1
- package/dist/validation/config-refusal.d.ts +3 -1
- package/dist/validation/config-refusal.d.ts.map +1 -1
- package/dist/validation/database-config.d.ts +1 -15
- package/dist/validation/database-config.d.ts.map +1 -1
- package/dist/validation/database-config.js +32 -1
- package/dist/validation/database-config.js.map +1 -1
- package/dist/validation/default-value.d.ts.map +1 -1
- package/dist/validation/default-value.js +3 -8
- package/dist/validation/default-value.js.map +1 -1
- package/dist/validation/extension-packs.d.ts.map +1 -1
- package/dist/validation/extension-packs.js +1 -0
- package/dist/validation/extension-packs.js.map +1 -1
- package/dist/validation/field-config.d.ts +3 -2
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +3 -1
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +2 -1
- package/dist/validation/field-names.d.ts.map +1 -1
- package/dist/validation/field-names.js +76 -63
- package/dist/validation/field-names.js.map +1 -1
- package/dist/validation/identifier-names.d.ts +1 -0
- package/dist/validation/identifier-names.d.ts.map +1 -1
- package/dist/validation/identifier-names.js +17 -9
- package/dist/validation/identifier-names.js.map +1 -1
- package/dist/validation/needs-closure.d.ts +30 -14
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +184 -31
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts.map +1 -1
- package/dist/validation/relations.js +11 -0
- package/dist/validation/relations.js.map +1 -1
- package/dist/validation/schema.d.ts +4 -3
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +8 -6
- package/dist/validation/schema.js.map +1 -1
- package/package.json +26 -10
- package/dist/access/field-visibility.d.ts +0 -58
- package/dist/access/field-visibility.d.ts.map +0 -1
- package/dist/access/field-visibility.js +0 -383
- package/dist/access/field-visibility.js.map +0 -1
- package/dist/access/query-validation.d.ts +0 -30
- package/dist/access/query-validation.d.ts.map +0 -1
- package/dist/access/query-validation.js +0 -49
- package/dist/access/query-validation.js.map +0 -1
- package/dist/access/system-fields.d.ts +0 -2
- package/dist/access/system-fields.d.ts.map +0 -1
- package/dist/access/system-fields.js +0 -7
- package/dist/access/system-fields.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,1056 @@
|
|
|
1
1
|
# @opensaas/stack-core
|
|
2
2
|
|
|
3
|
+
## 0.44.0-alpha.7
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2559](https://github.com/OpenSaasAU/stack/pull/2559) [`9ead1d9`](https://github.com/OpenSaasAU/stack/commit/9ead1d9233bde5ce9c5396fd56b43227cbeabd7a) Thanks [@borisno2](https://github.com/borisno2)! - Every session a host builds carries an actor, so access rules and hooks can tell a person on the web from an agent acting for one
|
|
8
|
+
|
|
9
|
+
`session.actor` is a reserved key. The procedure HTTP host sets a human actor and the MCP handler sets an agent actor. Only a host can set it: an `actor` no host created, whether from a token claim, a session provider, a `getSession` result or an object application code passes to `getContext` or `withSession`, is removed before the session reaches an access rule or a hook, and reads as absent.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import type { AccessControl } from '@opensaas/stack-core'
|
|
13
|
+
|
|
14
|
+
// { kind: 'human', userId, via: 'web' }
|
|
15
|
+
const humansOnly: AccessControl = ({ session }) => session?.actor?.kind === 'human'
|
|
16
|
+
|
|
17
|
+
// { kind: 'agent', clientId, onBehalfOf, via: 'mcp' }
|
|
18
|
+
const trustedAgent: AccessControl = ({ session }) =>
|
|
19
|
+
session?.actor?.kind === 'agent' && session.actor.clientId === 'my-first-party-client'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
An agent's session keeps the user's `userId`, so rules that scope by it still limit the agent to what that user can do. A session no host built (`getContext(session)` in a server component, `withSession`, a test context) has no actor, and an absent actor is never human: check `=== 'human'` or `=== 'agent'`, never `!== 'agent'`. The actor is the same frozen object in access rules, hooks, `sudo()` and `context.transaction()`.
|
|
23
|
+
|
|
24
|
+
`context.session` is now a frozen shallow copy of the session you pass, so assigning to it (`context.session.role = …`) throws. The object you passed is not frozen or changed. Rebinding it (`context.session = …`) throws `TypeError` on every context, including the ones hooks, access rules and `context.transaction()` callbacks receive.
|
|
25
|
+
|
|
26
|
+
A session must therefore be plain data, or an instance of a class with no private (`#`) fields and no methods that write to it. The copy keeps the prototype but never runs the constructor, so a `Map`, `Date` or array session, or a class reading private state, no longer works.
|
|
27
|
+
|
|
28
|
+
**This can break an existing custom MCP session provider.** `McpSession` now requires `clientId`, the OAuth client id the provider verified. A provider that returns a session without one fails to compile, and at runtime every request it authenticates is answered `500`, with the missing field named in the server log (`401` stays the answer for no session). Return the client the credential was issued to, read from the part the authorization server controls and never from a custom claim:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import type { McpSessionProvider } from '@opensaas/stack-core/mcp'
|
|
32
|
+
|
|
33
|
+
declare function verifyToken(
|
|
34
|
+
request: Request,
|
|
35
|
+
): Promise<{ subject: string; clientId: string; scopes: string[] } | null>
|
|
36
|
+
|
|
37
|
+
export const getSession: McpSessionProvider = async (request) => {
|
|
38
|
+
const verified = await verifyToken(request)
|
|
39
|
+
if (verified === null) return null
|
|
40
|
+
return { userId: verified.subject, clientId: verified.clientId, scopes: verified.scopes }
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`createBetterAuthMcpAdapter` needs no change in your app: it now carries the verified token's `azp` as `clientId` and refuses a token without one. `clientId` and `actor` are no longer usable as custom claim names or flat session fields over MCP.
|
|
45
|
+
|
|
46
|
+
A context built under `withMcpAuth` carries the agent actor too: `mcpSessionToContextSession` now returns `{ userId, actor }`. For a custom provider, `mcpContextSession` from `@opensaas/stack-core/mcp` builds the session the MCP handler builds.
|
|
47
|
+
|
|
48
|
+
Other changes that can affect an app:
|
|
49
|
+
|
|
50
|
+
- `createProcedureHandler` fails a call with `INTERNAL` when `getSession` resolves a session with no usable `userId`, because it cannot say who is acting. `userId` must be an own property holding a non-empty string or a finite number. With `@opensaas/stack-auth`, `authPlugin({ sessionFields })` must include `userId` for an app that serves procedures; nothing refuses a config without it at startup, and the reported error names the fix.
|
|
51
|
+
- `sessionFields` naming `actor` is refused when the auth instance is created, and by `getSessionFromAuth`.
|
|
52
|
+
- `Session` now declares `actor`, so a `Session` augmentation must not redeclare it, and a rule annotated with an inline all-optional session type (`{ session: { role?: string } | null }`) no longer accepts `Session`. Annotate with `Session` or `AccessControl`.
|
|
53
|
+
|
|
54
|
+
- [#2553](https://github.com/OpenSaasAU/stack/pull/2553) [`299fd83`](https://github.com/OpenSaasAU/stack/commit/299fd83a50593f4e8eee0265253b750964fd2327) Thanks [@borisno2](https://github.com/borisno2)! - A procedure can run several operations atomically and throw a named failure that rolls them back.
|
|
55
|
+
|
|
56
|
+
`run` opens no transaction of its own. Wrap the writes that must succeed together in `context.transaction`; its context is narrowed like the procedure's own (no `sudo`, `unsafe`, `withSession` or `serverAction`, at runtime as well as in the type) and keeps `.forUpdate()` and `advisoryLock`. Declare the outcomes a caller should handle in `failures`, and throw what `fail` constructs:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import * as z from 'zod'
|
|
60
|
+
import { procedure } from '@/.opensaas/procedures'
|
|
61
|
+
|
|
62
|
+
export const bookSlot = procedure({
|
|
63
|
+
description: 'Book a place in a slot',
|
|
64
|
+
input: z.object({ slotId: z.string() }),
|
|
65
|
+
output: z.object({ bookingId: z.string() }),
|
|
66
|
+
failures: { SLOT_FULL: 'The slot has no places left', NO_SLOT: 'No such slot' },
|
|
67
|
+
access: ({ session }) => session !== null,
|
|
68
|
+
expose: ['web'],
|
|
69
|
+
run: async ({ input, context, fail }) =>
|
|
70
|
+
context.transaction(async (tx) => {
|
|
71
|
+
const held = await tx.db.Slot.where({ id: { equals: input.slotId } })
|
|
72
|
+
.forUpdate()
|
|
73
|
+
.first()
|
|
74
|
+
if (held === null) throw fail('NO_SLOT')
|
|
75
|
+
|
|
76
|
+
const booking = await tx.db.Booking.create({ data: { slotId: input.slotId } })
|
|
77
|
+
const slot = await tx.db.Slot.where({ id: { equals: input.slotId } }).first()
|
|
78
|
+
const { taken } = await tx.db.Booking.where({ slotId: { equals: input.slotId } }).aggregate(
|
|
79
|
+
(aggregate) => ({ taken: aggregate.count() }),
|
|
80
|
+
)
|
|
81
|
+
// Thrown after the write: the booking is rolled back.
|
|
82
|
+
if (booking === null || slot === null || taken > slot.capacity) throw fail('SLOT_FULL')
|
|
83
|
+
return { bookingId: booking.id }
|
|
84
|
+
}),
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`fail` accepts only the codes the procedure declares, so an undeclared code is a compile error, and `ProcedureResultOf<typeof bookSlot>` exposes the declared codes beside the reserved ones. Over HTTP a declared failure answers 200 with `{ success: false, error: { code, message } }`; `VALIDATION` stays 400 with field errors and `RETRY` and `CONFLICT` stay 409. Nothing retries a `RETRY` automatically: it reports that the transaction rolled back, not that work outside it was undone.
|
|
89
|
+
|
|
90
|
+
Things to know:
|
|
91
|
+
|
|
92
|
+
- `throw` a failure. One returned from `run` or from a transaction callback is treated as thrown, so it still rolls the transaction back and answers its code.
|
|
93
|
+
- A code is upper-case letters, digits and `_`. Declaring a reserved code (`UNAUTHENTICATED`, `DENIED`, `INVALID_INPUT`, `VALIDATION`, `RETRY`, `CONFLICT`, `INTERNAL`) is a compile error and is refused when the procedure is defined.
|
|
94
|
+
- Output is parsed after `run` returns, so output that fails its schema is `INTERNAL` and does not undo a transaction that already committed.
|
|
95
|
+
- A defined procedure's `access` and `run` now take the application context (`{ context }` and `{ input, context }`) and narrow it themselves. This only matters to code that called them directly instead of going through a host.
|
|
96
|
+
|
|
97
|
+
See ADR-0086.
|
|
98
|
+
|
|
99
|
+
- [#2549](https://github.com/OpenSaasAU/stack/pull/2549) [`d7d8b10`](https://github.com/OpenSaasAU/stack/commit/d7d8b1039447305165ffbd1e302f6a320fa93b1a) Thanks [@borisno2](https://github.com/borisno2)! - Bulk actions run in one transaction, and the selection bar behaves like Row actions
|
|
100
|
+
|
|
101
|
+
A Bulk action's handler now runs inside one transaction, with its `context` bound
|
|
102
|
+
to it, so a handler that throws part way rolls back every write it made. Keep slow
|
|
103
|
+
external calls out of the handler, since they hold the transaction open.
|
|
104
|
+
|
|
105
|
+
In the list view, a Bulk action that cannot reach the server says the result is
|
|
106
|
+
unknown and refreshes. The selection bar is disabled while one runs, and the table
|
|
107
|
+
stays on the current page afterwards. The status line can be dismissed. A refused
|
|
108
|
+
row delete says it may already be gone, or the session may not have access.
|
|
109
|
+
|
|
110
|
+
Confirmations now pluralise by English rules ("Delete 2 categories"). A list with
|
|
111
|
+
an irregular plural sets `ui.plural`:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const Person = list({ fields: { name: text() }, ui: { plural: 'People' } })
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- [#2549](https://github.com/OpenSaasAU/stack/pull/2549) [`d7d8b10`](https://github.com/OpenSaasAU/stack/commit/d7d8b1039447305165ffbd1e302f6a320fa93b1a) Thanks [@borisno2](https://github.com/borisno2)! - Brand the admin, name lists in the plural, and theme under a strict CSP
|
|
118
|
+
|
|
119
|
+
`ui.brand` sets the name, and an optional logo, that the admin shows in place of
|
|
120
|
+
"OpenSaas Admin":
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
export default config({
|
|
124
|
+
db: { provider: 'postgresql' },
|
|
125
|
+
lists: {},
|
|
126
|
+
ui: { brand: { name: 'Acme Console', logo: '/acme.svg' } },
|
|
127
|
+
})
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Lists are now named in the plural in the sidebar, on list pages, on the
|
|
131
|
+
dashboard and in "Back to …" links, using `ui.plural` when a list sets one.
|
|
132
|
+
|
|
133
|
+
`AdminUI` takes a `nonce` for the inline style that carries `ui.theme`. The sidebar
|
|
134
|
+
no longer marks a list active on another list whose URL starts with its own
|
|
135
|
+
(`/post` on `/post-tag`).
|
|
136
|
+
|
|
137
|
+
- [#2431](https://github.com/OpenSaasAU/stack/pull/2431) [`6422e97`](https://github.com/OpenSaasAU/stack/commit/6422e97c0a5e22a3ae19c5cb2fbe9a076feee34e) Thanks [@borisno2](https://github.com/borisno2)! - Add client-safe entry points so `next build --webpack` builds the admin
|
|
138
|
+
|
|
139
|
+
A `'use client'` module that imported from `@opensaas/stack-core` or `@opensaas/stack-ui` pulled the
|
|
140
|
+
server graph into the browser bundle, and webpack refused it (`UnhandledSchemeError: node:async_hooks`).
|
|
141
|
+
Turbopack tolerated the same graph, so only `next build --webpack` failed. The admin's own client
|
|
142
|
+
components now import from two new entries that reach nothing server-side:
|
|
143
|
+
|
|
144
|
+
- `@opensaas/stack-core/client-safe` — `getUrlKey`, `getListKeyFromUrl`, `resolveListKeyFromUrl` and the
|
|
145
|
+
filter-query helpers (`parseFilterQuery`, `serializeFilterQuery`, `recordIdFilterToken`, …). The root
|
|
146
|
+
entry still exports the same bindings.
|
|
147
|
+
- `@opensaas/stack-ui/cells` — the cell components and `registerCellComponent`.
|
|
148
|
+
|
|
149
|
+
A field-registration module in your app should import from these, never from a package root:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
// lib/register-fields.ts
|
|
153
|
+
'use client'
|
|
154
|
+
|
|
155
|
+
// Before: pulled AdminUI and the server graph into the client bundle
|
|
156
|
+
// import { registerFieldComponent } from '@opensaas/stack-ui'
|
|
157
|
+
import { registerFieldComponent } from '@opensaas/stack-ui/fields'
|
|
158
|
+
import { registerCellComponent } from '@opensaas/stack-ui/cells'
|
|
159
|
+
import { getUrlKey } from '@opensaas/stack-core/client-safe'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The rag and tiptap registration modules now do the same.
|
|
163
|
+
|
|
164
|
+
- [#2562](https://github.com/OpenSaasAU/stack/pull/2562) [`76fce00`](https://github.com/OpenSaasAU/stack/commit/76fce00b7ea85b0ac2af8d4f979757d1600912e9) Thanks [@borisno2](https://github.com/borisno2)! - Add `createServerCaller`, the in-process host for procedures, and a session-resolved context for server components
|
|
165
|
+
|
|
166
|
+
Server actions call procedures without passing an identity, and server components read through a context whose session comes from the request. Neither takes a session: `getSession` takes no argument and runs on every call, and the session it resolves carries the same human actor the HTTP host sets.
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// lib/server.ts
|
|
170
|
+
import { createServerCaller } from '@opensaas/stack-core/procedures'
|
|
171
|
+
import { config, getContext } from '@/.opensaas/context'
|
|
172
|
+
import { procedures } from '@/lib/procedures' // declared with `satisfies ProcedureRegistry<Context>`
|
|
173
|
+
import { getSession } from '@/lib/auth'
|
|
174
|
+
|
|
175
|
+
const server = createServerCaller({ procedures, config: await config, getContext, getSession })
|
|
176
|
+
|
|
177
|
+
export const callProcedure = server.call
|
|
178
|
+
export const getServerContext = server.context
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// app/posts/actions.ts
|
|
183
|
+
'use server'
|
|
184
|
+
|
|
185
|
+
import { redirect } from 'next/navigation'
|
|
186
|
+
import { callProcedure } from '@/lib/server'
|
|
187
|
+
|
|
188
|
+
export async function createPost(formData: FormData) {
|
|
189
|
+
const result = await callProcedure('createPost', { title: String(formData.get('title')) })
|
|
190
|
+
if (!result.success) return result.error
|
|
191
|
+
redirect(`/posts/${result.data.id}`)
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The caller performs no cookie or `Origin` check. In a server action the protection is Next's own server-action `Origin` check, and only that; a route handler that calls `call` for a mutation must be non-`GET` and check the origin itself (or use `createProcedureHandler`), and outside a request `getSession` must resolve `null`, since any session it resolves is acted on as a human on the web.
|
|
196
|
+
|
|
197
|
+
`call` runs the HTTP host's pipeline (exposure, access, input and output parsing, declared failures, redaction) and resolves to the same result, typed per procedure. Only procedures exposed to `'web'` are callable; any other name is `INTERNAL` and reported. A `redirect()` or `notFound()` thrown by the session resolver, the access rule or `run` reaches the framework in-process, and is `INTERNAL` over HTTP.
|
|
198
|
+
|
|
199
|
+
- [#2425](https://github.com/OpenSaasAU/stack/pull/2425) [`bc97369`](https://github.com/OpenSaasAU/stack/commit/bc973693857be40587c0c6903557cf32fe118ce5) Thanks [@borisno2](https://github.com/borisno2)! - Resolve Session vocabulary answers lazily, one question at a time
|
|
200
|
+
|
|
201
|
+
A list's Session vocabulary no longer resolves every rule of the list on the first ask. Each answer (an operation, a field's `read`/`create`/`update`, `filterable`, `sortable`) is asked only when a consumer needs it, and is memoised on its own for the context's life, so asking a related list's `query` and one field's `filterable` asks only those two rules. The whole vocabulary is assembled from the same answers, so no rule is asked twice per context.
|
|
202
|
+
|
|
203
|
+
The admin's list view filter labels, Relationship table column labels and link controls, item form relationship options and operation gates ask a related list only the questions they need.
|
|
204
|
+
|
|
205
|
+
`resolveNavCounts` behaviour changes:
|
|
206
|
+
|
|
207
|
+
- A list whose vocabulary read fails is now omitted and logged instead of rejecting the whole call.
|
|
208
|
+
- A framework's control flow (`redirect()`, `notFound()`) raised by a list's count call (`aggregate`) was previously caught, logged and the badge dropped; it now propagates out of `resolveNavCounts`, as control flow from the vocabulary read already did.
|
|
209
|
+
|
|
210
|
+
- [#2547](https://github.com/OpenSaasAU/stack/pull/2547) [`878c2ca`](https://github.com/OpenSaasAU/stack/commit/878c2ca8c30b0f7862ce71d639af00bacca7fa6d) Thanks [@borisno2](https://github.com/borisno2)! - Define an application action once as a procedure and call it over HTTP.
|
|
211
|
+
|
|
212
|
+
`opensaas generate` now writes `.opensaas/procedures.ts`, a `procedure` builder typed to your own `Context`. Keep procedures in a registry module of your own (never in `opensaas.config.ts`) and serve it with `createProcedureHandler` from `@opensaas/stack-core/procedures`:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
// lib/procedures.ts
|
|
216
|
+
import * as z from 'zod'
|
|
217
|
+
import { procedure } from '@/.opensaas/procedures'
|
|
218
|
+
|
|
219
|
+
export const procedures = {
|
|
220
|
+
createPost: procedure({
|
|
221
|
+
description: 'Create a draft post authored by the caller',
|
|
222
|
+
input: z.object({ title: z.string().min(1) }),
|
|
223
|
+
output: z.object({ id: z.string(), title: z.string() }),
|
|
224
|
+
access: ({ session }) => session !== null,
|
|
225
|
+
expose: ['web'],
|
|
226
|
+
run: async ({ input, context }) => {
|
|
227
|
+
const post = await context.db.Post.create({ data: { title: input.title } })
|
|
228
|
+
if (post === null) throw new Error('Post was not created')
|
|
229
|
+
return post
|
|
230
|
+
},
|
|
231
|
+
}),
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// app/api/procedures/[name]/route.ts
|
|
235
|
+
import { createProcedureHandler } from '@opensaas/stack-core/procedures'
|
|
236
|
+
import { getContext } from '@/.opensaas/context'
|
|
237
|
+
import { procedures } from '@/lib/procedures'
|
|
238
|
+
import { auth } from '@/lib/auth'
|
|
239
|
+
|
|
240
|
+
export const POST = createProcedureHandler({
|
|
241
|
+
procedures,
|
|
242
|
+
getContext,
|
|
243
|
+
getSession: async (request) => {
|
|
244
|
+
const result = await auth.api.getSession({ headers: request.headers })
|
|
245
|
+
return result ? { userId: result.user.id } : null
|
|
246
|
+
},
|
|
247
|
+
allowedOrigins: ['http://localhost:3000'],
|
|
248
|
+
})
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
A caller POSTs JSON to `/api/procedures/<name>`. A call that reaches the procedure pipeline gets `{ success: true, data }` or `{ success: false, error: { code, message, fieldErrors? } }`. Transport failures do not use that envelope: 404 (unknown or unexposed name), 405 (not `POST`), 413 (body too large) and 415 (not `application/json`) answer `{ error: "<message>" }` with `error` as a string, so branch on the status first. Description, input, output, access and a non-empty `expose` are required. `run` receives `db`, `session`, `storage` and `plugins` only. A cookie request must come from an allowed origin, any `Authorization` header is refused, and unknown and unexposed names both answer 404. A default `z.object` output schema removes keys it does not declare and a strict one refuses them; a schema that does neither returns whatever `run` returned, and refusing such schemas when the host is created is [#2535](https://github.com/OpenSaasAU/stack/issues/2535). See ADR-0086.
|
|
252
|
+
|
|
253
|
+
- [#2420](https://github.com/OpenSaasAU/stack/pull/2420) [`4374e65`](https://github.com/OpenSaasAU/stack/commit/4374e651496547cafd7094fbd8330620b088a2ff) Thanks [@borisno2](https://github.com/borisno2)! - `checkFieldAccess` and `isListQueryStaticallyDenied` are gone from core's entry points, nav counts read the Session vocabulary, and the vocabulary rethrows only real framework control flow
|
|
254
|
+
|
|
255
|
+
The admin reads the Session vocabulary instead of evaluating access rules itself, so the field-access evaluator leaves `@opensaas/stack-core/internal`, and `isListQueryStaticallyDenied` leaves the root entry point.
|
|
256
|
+
|
|
257
|
+
`resolveNavCounts` counts a list only where the session's vocabulary does not deny `query`. A `query` rule returning `null` or `undefined` now shows no nav count instead of a `0`, and a context that resolves no vocabulary counts nothing.
|
|
258
|
+
|
|
259
|
+
A rule that throws while the vocabulary or MCP decides what to advertise is rethrown only when it is framework control flow: a string `digest` starting with one of Next.js's control-flow prefixes (`NEXT_REDIRECT`, `NEXT_HTTP_ERROR_FALLBACK`, `NEXT_NOT_FOUND`, `DYNAMIC_SERVER_USAGE`, `BAILOUT_TO_CLIENT_SIDE_RENDERING`, `HANGING_PROMISE_REJECTION`, `NEXT_PRERENDER_INTERRUPTED`), or React's postpone. As Next's `unstable_rethrow` does, an `Error` whose `cause` chain reaches one of those has that cause rethrown, so a rule wrapping `redirect()` in `new Error(message, { cause })` still redirects. Any other throw, including one carrying an unrelated `digest` or an unrelated `cause`, denies that answer and logs a warning.
|
|
260
|
+
|
|
261
|
+
`isHookOnlyField(field)` is added to `@opensaas/stack-core/internal`, so the admin marks a Hook-only field without reading its `access` itself.
|
|
262
|
+
|
|
263
|
+
- [#2516](https://github.com/OpenSaasAU/stack/pull/2516) [`9f17366`](https://github.com/OpenSaasAU/stack/commit/9f17366402cb263793d2a38c8ca52791ed79be1b) Thanks [@borisno2](https://github.com/borisno2)! - `needs` takes an object form that reaches any depth, so a computed field over a chain of relations no longer reads per row (ADR-0085).
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
label: virtual({
|
|
267
|
+
type: 'string',
|
|
268
|
+
needs: { enrolment: { student: true, classTerm: ['class', 'term'] } },
|
|
269
|
+
hooks: {
|
|
270
|
+
resolveOutput: ({ item }) => `${item.enrolment?.student?.name ?? ''}`,
|
|
271
|
+
},
|
|
272
|
+
})
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
A column takes `true`. A relation takes `true` for its rows' stored columns, or an array or object for exactly what is named beneath it. Every hop keeps its list's `query` access. The array form still reaches one hop.
|
|
276
|
+
|
|
277
|
+
- A synthetic back-relation (`from_<List>_<field>`) is accepted as a key in either form.
|
|
278
|
+
- `pnpm generate` warns when an array form names a relation whose list has a computed field with relation `needs` of its own, and prints the object form.
|
|
279
|
+
- A hook is handed shallow copies of its declared rows, carrying no relation it did not declare and each multi-column field under its own key in place of its part columns.
|
|
280
|
+
- A field `read` rule sees one hop: a relation on a related row is withheld.
|
|
281
|
+
|
|
282
|
+
Re-run `pnpm generate` after adopting it.
|
|
283
|
+
|
|
284
|
+
- [#2566](https://github.com/OpenSaasAU/stack/pull/2566) [`e06f639`](https://github.com/OpenSaasAU/stack/commit/e06f639fb3099b71586771008bdf0be5f9a5f93d) Thanks [@borisno2](https://github.com/borisno2)! - Serve procedures as MCP tools
|
|
285
|
+
|
|
286
|
+
Pass the procedure registry to `createMcpHandlers`, and each procedure whose `expose` names `'mcp'` becomes a tool named after it, with its description and its input schema as JSON Schema. A call runs the same pipeline as `createProcedureHandler` under the agent's session, and the tool result's text is the result envelope as JSON (`{ success, data }` or `{ success: false, error: { code, message, fieldErrors? } }`), with `isError` set on a failure. A procedure not exposed to `'mcp'` answers as an unknown tool.
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
import * as z from 'zod'
|
|
290
|
+
import { createMcpHandlers } from '@opensaas/stack-core/mcp'
|
|
291
|
+
import { procedure } from '@/.opensaas/procedures'
|
|
292
|
+
|
|
293
|
+
const publishPost = procedure({
|
|
294
|
+
description: 'Publish one of your draft posts',
|
|
295
|
+
input: z.object({ postId: z.string() }),
|
|
296
|
+
output: z.object({ id: z.string() }),
|
|
297
|
+
access: ({ session }) => session !== null,
|
|
298
|
+
expose: ['web', 'mcp'],
|
|
299
|
+
scopes: ['posts:publish'], // omitted: requires mcp.scopes.write; [] requires none
|
|
300
|
+
run: async ({ input, context }) => {
|
|
301
|
+
const post = await context.db.Post.update({
|
|
302
|
+
where: { id: input.postId },
|
|
303
|
+
data: { status: 'published' },
|
|
304
|
+
})
|
|
305
|
+
if (post === null) throw new Error('Post was not published')
|
|
306
|
+
return post
|
|
307
|
+
},
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
export const { GET, POST, DELETE } = createMcpHandlers({
|
|
311
|
+
config: await config,
|
|
312
|
+
getSession,
|
|
313
|
+
getContext,
|
|
314
|
+
procedures: { publishPost },
|
|
315
|
+
onUnexpectedProcedureError: (error, name) => console.error(name, error),
|
|
316
|
+
})
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
A procedure is listed only when the token holds its scopes and its access rule admits the session, and both are checked again on every call; a missing scope is `DENIED` with the scope named. The registry is checked when the handlers are created, and an MCP-exposed procedure's input must be an object at its top level. With `procedures`, the context type is inferred from the registry, so the generated `getContext` and `procedure` builder type-check together.
|
|
320
|
+
|
|
321
|
+
- [#2546](https://github.com/OpenSaasAU/stack/pull/2546) [`a2598d5`](https://github.com/OpenSaasAU/stack/commit/a2598d5613274027b3c9500ad99f4b352547cecf) Thanks [@borisno2](https://github.com/borisno2)! - MCP write tools are now opt-in per list. This changes a default.
|
|
322
|
+
|
|
323
|
+
Enabling MCP gives each list its `list_<list>_query` tool and no generated `create`, `update` or `delete` tool. A list enables each write tool deliberately in its own `mcp.tools`; a write tool it has not enabled is neither listed nor callable (`Unknown tool`). An enabled tool still runs the list's access control, hooks and scopes. Custom and plugin tools are unchanged.
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
Post: list({
|
|
327
|
+
fields: { title: text() },
|
|
328
|
+
mcp: { tools: { create: true, update: true } }, // delete stays off
|
|
329
|
+
})
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
`mcp.defaultTools` now takes `read` only. A config setting `create`, `update` or `delete` there, even to `false`, is refused by `config()` and `createMcpHandlers` with an error naming `lists.<List>.mcp.tools.<operation>`. `config()` refuses it even when `mcp.enabled` is not `true`, so an app with MCP switched off and the old `defaultTools` shape must remove those keys too.
|
|
333
|
+
|
|
334
|
+
To keep a list's write tools, move them onto the list:
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
// Before
|
|
338
|
+
mcp: { enabled: true, defaultTools: { read: true, create: true, update: true, delete: true } }
|
|
339
|
+
|
|
340
|
+
// After
|
|
341
|
+
mcp: { enabled: true, defaultTools: { read: true } }
|
|
342
|
+
// and on each list agents may write to:
|
|
343
|
+
Post: list({ fields: { /* ... */ }, mcp: { tools: { create: true, update: true, delete: true } } })
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
- [#2549](https://github.com/OpenSaasAU/stack/pull/2549) [`d7d8b10`](https://github.com/OpenSaasAU/stack/commit/d7d8b1039447305165ffbd1e302f6a320fa93b1a) Thanks [@borisno2](https://github.com/borisno2)! - Relationship tables page in place, link only unlinked records, and can undo an unlink
|
|
347
|
+
|
|
348
|
+
A to-many table on the item page now pages through its rows: the footer reads
|
|
349
|
+
"Showing 11–20 of 42 rows" with Previous and Next, driven by a `<field>Page`
|
|
350
|
+
URL parameter, so each table keeps its own page. `ui.itemView.take` is the page size.
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
posts: relationship({ ref: 'Post.author', many: true, ui: { itemView: { take: 20 } } })
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
"Link" now offers only records not already linked to this one. The
|
|
357
|
+
`relationshipOptions` server action takes `linkableFor`, the parent row's id,
|
|
358
|
+
and leaves out records already linked to that row, through a foreign key or a
|
|
359
|
+
junction list:
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
await context.serverAction({
|
|
363
|
+
listKey: 'Author',
|
|
364
|
+
action: 'relationshipOptions',
|
|
365
|
+
field: 'posts',
|
|
366
|
+
linkableFor: authorId,
|
|
367
|
+
})
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Each row's label cell links to the related record, so rows open from the
|
|
371
|
+
keyboard. Each ✕ is named for its row ("Unlink “Hello world”"). Unlinking shows
|
|
372
|
+
Undo, and the delete confirmation names the row it deletes.
|
|
373
|
+
|
|
374
|
+
- [#2415](https://github.com/OpenSaasAU/stack/pull/2415) [`59e8d70`](https://github.com/OpenSaasAU/stack/commit/59e8d70029aa90c01373aa8600a665bc538523ce) Thanks [@borisno2](https://github.com/borisno2)! - The Session vocabulary can answer its row-dependent write questions for one stored row
|
|
375
|
+
|
|
376
|
+
A consumer naming one row by its id now gets the vocabulary with each `'row-dependent'` write answer resolved for that row, against the stored row, as the write decides: core reads the row by identity exactly as an update does before it decides (every column, no relation), then answers a field's `update` against it as the row's guarded `item`, and the list's `update` and `delete` by the same target resolution a write runs (a filter-returning rule allows only a row its filter matches). A rule reaching for a relation the stored row does not carry answers deny, as the write does, and a row that is not there answers every row-dependent write question deny. A field's `read` is not resolved per row: Field Visibility decides it on each read, against the row that read delivers, so a row-dependent `read` stays `'row-dependent'`. `allow` and `deny` answers pass through without their rules being asked again, a rule that reads the payload stays `'row-dependent'`, and a rule that throws answers deny and is logged. It is disclosure only; the write still decides.
|
|
377
|
+
|
|
378
|
+
It is internal plumbing on the engine context (`_sessionVocabularyForItem(listKey, id)`), which `@opensaas/stack-ui` reads for the admin edit form and for `serializeFieldConfigs(context, listKey, 'update', item)`.
|
|
379
|
+
|
|
380
|
+
- [#2428](https://github.com/OpenSaasAU/stack/pull/2428) [`21bce38`](https://github.com/OpenSaasAU/stack/commit/21bce381ec8a4459bd591c3651962c4d6b21f646) Thanks [@borisno2](https://github.com/borisno2)! - Make the framework control-flow rethrow predicate injectable
|
|
381
|
+
|
|
382
|
+
A new `isFrameworkControlFlow` config option recognises a host framework's control flow thrown from inside an access rule, so the Session vocabulary, MCP's advertised vocabulary and the admin's nav counts let it propagate instead of folding it into a logged deny. It is OR'ed with the built-in recognition of Next.js's digests and React's postpone, and the `cause` walk applies to both. A predicate that throws recognises nothing and is reported once, so a rule's own throw still denies.
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
export default config({
|
|
386
|
+
db: { provider: 'postgresql' },
|
|
387
|
+
lists: {},
|
|
388
|
+
isFrameworkControlFlow: (thrown) => thrown instanceof Response,
|
|
389
|
+
})
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
`opensaas generate` now wires Next.js's own `unstable_rethrow` into `.opensaas/context.ts` when the project's `package.json` declares `next`, so new Next control-flow signals are recognised without waiting for core to learn their digests. It is imported lazily, so the bundle still loads under plain Node, where it keeps the built-in recognition. Re-run `pnpm generate` to pick it up. A project without `next` gets the same context as before.
|
|
393
|
+
|
|
394
|
+
- [#2452](https://github.com/OpenSaasAU/stack/pull/2452) [`dc6ae19`](https://github.com/OpenSaasAU/stack/commit/dc6ae1999ef9b4e02573f308dc8f69f03dabbd8b) Thanks [@borisno2](https://github.com/borisno2)! - Junction-edge detection, the delegate's singleton shape and write-field ownership now ask the List member resolver, so a context built over a config whose list or member names `opensaas generate` refuses throws generate's own error at construction. Generate still runs further checks that context construction does not.
|
|
395
|
+
|
|
396
|
+
**Migrating:** a test or script that builds a context over a hand-written config with names `opensaas generate` would refuse (for example a camelCase list key, or a list-only to-many) now fails at `getContext`/`createTestContext`. Fix the config so `pnpm generate` accepts it.
|
|
397
|
+
|
|
398
|
+
- [#2418](https://github.com/OpenSaasAU/stack/pull/2418) [`4c5d2d2`](https://github.com/OpenSaasAU/stack/commit/4c5d2d275e667287b1ae5443dfb8b41902c84b48) Thanks [@borisno2](https://github.com/borisno2)! - The admin list view reads the Session vocabulary for everything it offers
|
|
399
|
+
|
|
400
|
+
The column picker, default columns, Preset views and the Filter builder offer only fields the session can read, sorting follows each field's `sortable` answer, and a field with `isFilterable: false` is absent from every place a filter can be built. A row-dependent readable field stays shown but is neither filterable nor sortable (ADR-0031). Count links and filter-chip labels read the related list's vocabulary, so a related list whose `query` rule returns `false`, `null` or `undefined` gets no link and no label lookup.
|
|
401
|
+
|
|
402
|
+
A session denied the list's `query` now sees an explicit "can't be shown here" state instead of an empty table, and keeps the Create button when it may still create (a write-only inbox). A Preset view's search drops every token naming a field the session cannot filter by (a never-readable or row-dependent field, or `isFilterable: false`), and a context that resolves no Session vocabulary shows the list's "could not be loaded" state instead of failing the page.
|
|
403
|
+
|
|
404
|
+
`collectFilterSpecs`, `buildListFilterWhere`, `collectFilterSuggestions` and `isFieldFilterableById` now answer from the context's Session vocabulary, which builds each Filter spec once per request: a `read` rule or a spec builder that throws denies that one field and is logged instead of failing the list. They answer for the context's own session and config, so `FilterAccessArgs` no longer takes a `session`, and `listConfig` and `config` must be the context's own. A context core did not build gets no specs and no throw:
|
|
405
|
+
|
|
406
|
+
```ts
|
|
407
|
+
const specs = await collectFilterSpecs(listConfig, 'Post', config, { context })
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
A throw carrying a string `digest` (Next.js's `redirect()`, `notFound()` and dynamic-usage bailouts) now propagates out of the Session vocabulary and the MCP vocabulary instead of being treated as a deny, so a rule that redirects still redirects.
|
|
411
|
+
|
|
412
|
+
The internal `_orderableKeys` context member and `collectUnreadableFields` are removed; read `context._sessionVocabulary(listKey)` instead (`fields.get(key)?.sortable`, `fields.get(key)?.read`).
|
|
413
|
+
|
|
414
|
+
- [#2449](https://github.com/OpenSaasAU/stack/pull/2449) [`e2e18be`](https://github.com/OpenSaasAU/stack/commit/e2e18be4812600f83c924e62d1ece0b05ee0f180) Thanks [@borisno2](https://github.com/borisno2)! - The Write Pipeline's ownership, singleton and part-column checks ask the List member resolver instead of re-deriving them from the config.
|
|
415
|
+
|
|
416
|
+
- Writes on a config whose list or member names `opensaas generate` refuses now throw generate's own error.
|
|
417
|
+
- Under sudo, a Synthetic back-relation key whose value is `undefined` is now refused as undeclared, like any other unknown key.
|
|
418
|
+
- `RelationTargetMissingError` is removed from `@opensaas/stack-core`: a `connect` to an undeclared list now fails with generate's refusal, so the error could no longer be thrown.
|
|
419
|
+
|
|
420
|
+
**Migrating:** remove any `instanceof RelationTargetMissingError` checks. The same mistake (a relationship whose `ref` names a list that does not exist) is now refused by `pnpm generate`, with a message naming the list and field, before any context is built.
|
|
421
|
+
|
|
422
|
+
- [#2412](https://github.com/OpenSaasAU/stack/pull/2412) [`ad85f09`](https://github.com/OpenSaasAU/stack/commit/ad85f095916eae5500e6e6b7e77e1ccbff24fa36) Thanks [@borisno2](https://github.com/borisno2)! - Add the Session vocabulary: one answer, per list and context, for what a session may be told ahead of any request (ADR-0084)
|
|
423
|
+
|
|
424
|
+
A context core built carries an internal `_sessionVocabulary(listKey)` member. It answers each field's read, create and update as `'allow'`, `'deny'` or `'row-dependent'`, each list operation by the engine's own rule (no rule, `null` and `undefined` deny; `true` or a filter allows), and whether each field is filterable and sortable. System fields (`id`, and automatic `createdAt`/`updatedAt`) have entries too, readable and never writable. A computed field and a relationship side that does not own the foreign key are never writable, and a hook-only field's writes stay denied under sudo. On a singleton list, `delete` is denied for every session, sudo included, and no field is filterable or sortable. A rule that throws, or a field rule that returns a filter, answers deny for that one question and is logged, so one broken rule never takes the rest of the list with it. Each context resolves with its own session and connection, once per list, and keeps the answer for its life: a write's transaction-bound hook context and its `afterTransaction` context each have their own, and a `resolveOutput` hook shares the answer of the read that ran it:
|
|
425
|
+
|
|
426
|
+
```ts
|
|
427
|
+
import { engineContextOf } from '@opensaas/stack-core'
|
|
428
|
+
|
|
429
|
+
const vocabulary = await engineContextOf(context)._sessionVocabulary?.('Post')
|
|
430
|
+
vocabulary?.operations.update // 'allow' | 'deny' | 'row-dependent'
|
|
431
|
+
vocabulary?.fields.get('title') // { read, create, update, filterable, sortable, relationship }
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
- [#2469](https://github.com/OpenSaasAU/stack/pull/2469) [`2f48eab`](https://github.com/OpenSaasAU/stack/commit/2f48eab7d64911588624fe7e66741c0c0ba540a9) Thanks [@borisno2](https://github.com/borisno2)! - Add `@opensaas/stack-core/db-client`, the server-only subpath for `resolveRuntimeConnection`, and deprecate `@opensaas/stack-core/client`
|
|
435
|
+
|
|
436
|
+
`/client` sat beside `/client-safe` and read as browser-safe, but it reaches `pg`. `opensaas generate` now emits the new subpath in `.opensaas/context.ts`. `/client` still resolves to the same bindings, marked `@deprecated`, and is removed at the next major.
|
|
437
|
+
|
|
438
|
+
Migration — regenerate (`pnpm generate`) and update any hand-written import:
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
// Before
|
|
442
|
+
import { resolveRuntimeConnection } from '@opensaas/stack-core/client'
|
|
443
|
+
|
|
444
|
+
// After
|
|
445
|
+
import { resolveRuntimeConnection } from '@opensaas/stack-core/db-client'
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
- [#2462](https://github.com/OpenSaasAU/stack/pull/2462) [`5621a97`](https://github.com/OpenSaasAU/stack/commit/5621a977d4d13104c72d5166301ab8a3d2c535e7) Thanks [@relationship({](https://github.com/relationship({), [@relationship({](https://github.com/relationship({)! - `opensaas generate` refuses a computed (virtual) or multi-column field keyed like another field's foreign-key or part column
|
|
449
|
+
|
|
450
|
+
Such a field used to be accepted and then win every name lookup, so the foreign-key or part column it shadowed could not be named in `where`, `orderBy` or `select`. Generate, `deriveContract` and the List member resolver now refuse it with the same message, naming the list, both fields and the fix. A stored field keyed like another field's part column, already refused, now gets the same named message (reason `part-column-collision`):
|
|
451
|
+
|
|
452
|
+
```
|
|
453
|
+
List "Post": fields.authorId collides with the foreign-key column "authorId" that fields.author derives for its relationship. Rename fields.authorId, or remove it and read the key through fields.author.
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Migration: rename the virtual or multi-column field.
|
|
457
|
+
|
|
458
|
+
```ts
|
|
459
|
+
// Before: refused by generate
|
|
460
|
+
Post: list({
|
|
461
|
+
fields: {
|
|
462
|
+
ref: 'Author' }),
|
|
463
|
+
authorId: virtual({ type: 'string', hooks: { resolveOutput: () => '' } }),
|
|
464
|
+
},
|
|
465
|
+
})
|
|
466
|
+
|
|
467
|
+
// After
|
|
468
|
+
Post: list({
|
|
469
|
+
fields: {
|
|
470
|
+
ref: 'Author' }),
|
|
471
|
+
authorLabel: virtual({ type: 'string', hooks: { resolveOutput: () => '' } }),
|
|
472
|
+
},
|
|
473
|
+
})
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
- [#2482](https://github.com/OpenSaasAU/stack/pull/2482) [`bab30df`](https://github.com/OpenSaasAU/stack/commit/bab30dfe01663f03ba49717d5c3d688ef0792f42) Thanks [@borisno2](https://github.com/borisno2)! - Require `assembleColumns` on every multi-column field
|
|
477
|
+
|
|
478
|
+
A field whose `getContractField` returns `{ kind: 'columns' }` must now supply `assembleColumns`. Without it the field had no value under its own key, so `.select()` returned nothing for it, a `needs` entry naming it gave the hook nothing, and MCP advertised a field it never returned. `opensaas generate` now refuses such a config, and so does building a context over it; each names the list, the field and the member. Generate reports:
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
Profile.avatar (type "avatar") is missing assembleColumns()
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
and context construction throws:
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
Field "Profile.avatar" (type "avatar") is not self-contained: it does not declare assembleColumns(). ...
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
Migration: supply `assembleColumns` on any `kind: 'columns'` field.
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
493
|
+
import type { BaseFieldConfig, TypeInfo } from '@opensaas/stack-core/extend'
|
|
494
|
+
import { z } from 'zod'
|
|
495
|
+
|
|
496
|
+
const avatar: BaseFieldConfig<TypeInfo> = {
|
|
497
|
+
type: 'avatar',
|
|
498
|
+
outputType: '{ filename: string; filesize: number } | null',
|
|
499
|
+
getZodSchema: () => z.object({ filename: z.string(), filesize: z.number() }).nullable(),
|
|
500
|
+
getContractField: () => ({
|
|
501
|
+
kind: 'columns',
|
|
502
|
+
columns: [
|
|
503
|
+
{ name: 'avatar_filename', type: { pack: 'pg', type: 'text' }, nullable: true },
|
|
504
|
+
{ name: 'avatar_filesize', type: { pack: 'pg', type: 'int' }, nullable: true },
|
|
505
|
+
],
|
|
506
|
+
}),
|
|
507
|
+
assembleColumns: (_fieldName, row) =>
|
|
508
|
+
row.avatar_filename === null
|
|
509
|
+
? null
|
|
510
|
+
: { filename: row.avatar_filename, filesize: row.avatar_filesize },
|
|
511
|
+
splitColumns: (_fieldName, value) => {
|
|
512
|
+
const parts = typeof value === 'object' && value !== null ? value : {}
|
|
513
|
+
return {
|
|
514
|
+
avatar_filename: 'filename' in parts ? parts.filename : null,
|
|
515
|
+
avatar_filesize: 'filesize' in parts ? parts.filesize : null,
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
}
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
`image()`/`file()` in multi-column mode and `embedding()` already supply it.
|
|
522
|
+
|
|
523
|
+
- [#2561](https://github.com/OpenSaasAU/stack/pull/2561) [`df9191f`](https://github.com/OpenSaasAU/stack/commit/df9191f4b8f9810cc25280a822b8786d03cca3cd) Thanks [@borisno2](https://github.com/borisno2)! - Call procedures from the browser with a typed client.
|
|
524
|
+
|
|
525
|
+
`createProcedureClient` from the new `@opensaas/stack-core/procedures/client` entry calls the HTTP host with the name, the input and the result inferred from your registry. Give it the registry's **type**: the import is erased, so the entry is safe in a `'use client'` module and no server code reaches the bundle.
|
|
526
|
+
|
|
527
|
+
Declare the registry with `satisfies`, which keeps each procedure's own type:
|
|
528
|
+
|
|
529
|
+
```typescript
|
|
530
|
+
// lib/procedures.ts
|
|
531
|
+
import type { ProcedureRegistry } from '@opensaas/stack-core/procedures'
|
|
532
|
+
import type { Context } from '@/.opensaas/types'
|
|
533
|
+
|
|
534
|
+
export const procedures = { createPost, bookSlot } satisfies ProcedureRegistry<Context>
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
```typescript
|
|
538
|
+
// components/book.ts
|
|
539
|
+
'use client'
|
|
540
|
+
|
|
541
|
+
import { createProcedureClient } from '@opensaas/stack-core/procedures/client'
|
|
542
|
+
import type { procedures } from '@/lib/procedures'
|
|
543
|
+
|
|
544
|
+
const call = createProcedureClient<typeof procedures>()
|
|
545
|
+
|
|
546
|
+
export async function book(slotId: string): Promise<string> {
|
|
547
|
+
const result = await call('bookSlot', { slotId })
|
|
548
|
+
if (result.success) return `Booked ${result.data.bookingId}`
|
|
549
|
+
switch (result.error.code) {
|
|
550
|
+
case 'SLOT_FULL':
|
|
551
|
+
return 'That slot is full'
|
|
552
|
+
case 'transport':
|
|
553
|
+
return 'Could not reach the server'
|
|
554
|
+
default:
|
|
555
|
+
return result.error.message
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
An unknown procedure name or a renamed input field is a compile error (and a registry type that admits any name, an annotated one or a missing type argument, leaves no name callable), and `error.code` is the union of the reserved codes, the codes that procedure declares and `'transport'`. A call never throws: a request the client did not send (an input JSON cannot carry, or a name no host serves), a request that was never answered, a refusal from the host before the pipeline ran (404, 405, 413, 415) and a response that is not a procedure result all resolve to `{ success: false, error: { code: 'transport', reason, status?, message } }` with `reason` `'unsent'`, `'network'`, `'refused'` or `'malformed'`. The client never retries, `RETRY` included, sends no `Authorization` header, and sends the input as given: leaving it out sends an empty body, which is allowed only where the input schema accepts `undefined`. Options are `baseUrl` (default `/api/procedures`), `credentials` (default `'same-origin'`) and `fetch`. A host on the page's own origin needs nothing more. A host on another origin also needs the application to answer the CORS preflight and add the CORS headers itself, since the host sends none. See ADR-0086.
|
|
561
|
+
|
|
562
|
+
- [#2552](https://github.com/OpenSaasAU/stack/pull/2552) [`6e9c64f`](https://github.com/OpenSaasAU/stack/commit/6e9c64f6afa74705ac5f5a34a5d13829ff4ba4ac) Thanks [@borisno2](https://github.com/borisno2)! - Refuse unsafe procedure definitions when the host is created.
|
|
563
|
+
|
|
564
|
+
`createProcedureHandler` now throws `ProcedureHostError`, naming the procedure, the offending part and the fix, for:
|
|
565
|
+
|
|
566
|
+
- an `input` or `output` schema that does not convert to JSON Schema on its own side (dates, bigints, output transforms, `z.undefined()`, `z.void()`)
|
|
567
|
+
- the open-ended shapes Zod provides, at any depth: `z.any()`, `z.unknown()`, `z.json()`, a loose object, a `z.looseRecord` or a `z.record` of `any`/`unknown`; and an output object with a `.catchall()`. A hand-written schema that accepts as much is not recognised
|
|
568
|
+
- `z.file()`, which a JSON body cannot carry
|
|
569
|
+
- a `config` option that is not a resolved config, such as an un-awaited promise
|
|
570
|
+
- a name matching the reserved `list_<list>_<operation>` pattern of generated MCP tools
|
|
571
|
+
- a name a list custom tool or a plugin-registered MCP tool already carries, when the host is given the config
|
|
572
|
+
|
|
573
|
+
```typescript
|
|
574
|
+
// app/api/procedures/[name]/route.ts
|
|
575
|
+
import { createProcedureHandler } from '@opensaas/stack-core/procedures'
|
|
576
|
+
import config from '@/opensaas.config'
|
|
577
|
+
import { getContext } from '@/.opensaas/context'
|
|
578
|
+
import { procedures } from '@/lib/procedures'
|
|
579
|
+
import { getSession } from '@/lib/auth'
|
|
580
|
+
|
|
581
|
+
export const POST = createProcedureHandler({
|
|
582
|
+
procedures,
|
|
583
|
+
config: await config, // optional: adds the custom and plugin tool name check
|
|
584
|
+
getContext,
|
|
585
|
+
getSession: (request) => getSession(request.headers),
|
|
586
|
+
allowedOrigins: ['http://localhost:3000'],
|
|
587
|
+
})
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
A procedure that takes no input uses `z.object({}).optional()`, one that returns nothing uses `z.null()`, and a date travels as `z.iso.datetime()`. The checks are also exported for other hosts: `assertProcedureRegistry`, `assertProcedureSchemas` and `assertProcedureNamesAvailable`.
|
|
591
|
+
|
|
592
|
+
### Patch Changes
|
|
593
|
+
|
|
594
|
+
- [#2488](https://github.com/OpenSaasAU/stack/pull/2488) [`ae613f9`](https://github.com/OpenSaasAU/stack/commit/ae613f9fce8b76eaeb93354e527ad041504cb965) Thanks [@borisno2](https://github.com/borisno2)! - `tx.advisoryLock()` now poisons its transaction when the lock statement fails, so a caught failure still rolls back with the original cause.
|
|
595
|
+
|
|
596
|
+
- [#2522](https://github.com/OpenSaasAU/stack/pull/2522) [`7cb1192`](https://github.com/OpenSaasAU/stack/commit/7cb1192bc538049ec8f3cd91233a89daf9baafdf) Thanks [@borisno2](https://github.com/borisno2)! - Fix `bigInt` writes given a number or numeric string failing with a raw encode error; validation's coerced bigint now reaches the write.
|
|
597
|
+
|
|
598
|
+
- [#2471](https://github.com/OpenSaasAU/stack/pull/2471) [`4b768f2`](https://github.com/OpenSaasAU/stack/commit/4b768f232d8fed6af88b292e469e05ffb5203983) Thanks [@borisno2](https://github.com/borisno2)! - Internal restructuring: every write return now goes through Field Visibility's read funnel and carries the visible-row brand.
|
|
599
|
+
|
|
600
|
+
- [#2451](https://github.com/OpenSaasAU/stack/pull/2451) [`28ff344`](https://github.com/OpenSaasAU/stack/commit/28ff34407741a466cafd21048a8e385b7800652e) Thanks [@borisno2](https://github.com/borisno2)! - Contract derivation, the constraint map and generate-time field-name validation read names and foreign-key ownership from the List member table; the contract is unchanged.
|
|
601
|
+
A `db.indexes`/`db.foreignKeys` entry naming a field with a `computed` descriptor is now refused by name at generate.
|
|
602
|
+
|
|
603
|
+
- [#2490](https://github.com/OpenSaasAU/stack/pull/2490) [`05e83be`](https://github.com/OpenSaasAU/stack/commit/05e83bed1ce8abc38675036b5eea7da32e97dcbb) Thanks [@borisno2](https://github.com/borisno2)! - The Filter builder reads numeric dates in the viewer's locale order, and a date-only `lte`/range end on a timestamp covers its whole UTC day.
|
|
604
|
+
|
|
605
|
+
- [#2511](https://github.com/OpenSaasAU/stack/pull/2511) [`c97bea7`](https://github.com/OpenSaasAU/stack/commit/c97bea7e07a22467c1d348b45f7b5295a204a147) Thanks [@borisno2](https://github.com/borisno2)! - A declared field named `constructor`, `toString` or `hasOwnProperty` no longer breaks its list, `__proto__` is refused at generate, a foreign-key/part-column collision names a remedy that works, and a singleton's MCP `query` refuses a `where`.
|
|
606
|
+
|
|
607
|
+
- [#2528](https://github.com/OpenSaasAU/stack/pull/2528) [`0fe5094`](https://github.com/OpenSaasAU/stack/commit/0fe5094a919b42fb256722ec111b6d5d3d30c885) Thanks [@borisno2](https://github.com/borisno2)! - Fix admin list filters that made the read throw: integer and bigInt values outside the column range and NUL bytes now match nothing, a search too long for the where limit raises `FilterTooLongError`, and the list error panel offers "Clear filters" when the request carried a search.
|
|
608
|
+
|
|
609
|
+
- [#2543](https://github.com/OpenSaasAU/stack/pull/2543) [`ba3e7ae`](https://github.com/OpenSaasAU/stack/commit/ba3e7ae4127ceea26f1bc8699c385da1412c444c) Thanks [@borisno2](https://github.com/borisno2)! - A field's `afterOperation` hook now runs on create and update only when the field is in the write, matching `beforeOperation`. Delete still runs every field's hook, and `afterTransaction` stays ungated.
|
|
610
|
+
|
|
611
|
+
- [#2480](https://github.com/OpenSaasAU/stack/pull/2480) [`846f622`](https://github.com/OpenSaasAU/stack/commit/846f622c7e2f080c1d746f7ccd284fba214f5b6a) Thanks [@borisno2](https://github.com/borisno2)! - Fix part columns of a multi-column field without `assembleColumns` reaching a session the field's own `read` rule denies.
|
|
612
|
+
|
|
613
|
+
- [#2523](https://github.com/OpenSaasAU/stack/pull/2523) [`e790bf1`](https://github.com/OpenSaasAU/stack/commit/e790bf10fe4853fa65df5bf76ec2a4ae6bfda649) Thanks [@borisno2](https://github.com/borisno2)! - `pnpm generate` now refuses configs that fail at apply: a `db.foreignKeys` entry referencing a partial unique, repeating another entry's columns, or pairing mismatched column types; constraint names over 63 bytes; and an index name shared across lists or equal to a table name.
|
|
614
|
+
|
|
615
|
+
- [#2529](https://github.com/OpenSaasAU/stack/pull/2529) [`2867a27`](https://github.com/OpenSaasAU/stack/commit/2867a279c54d2bea13b3cccdddea7630dc403426) Thanks [@borisno2](https://github.com/borisno2)! - The admin hides nav entries and dashboard cards for lists the session cannot query, and an item page renders read-only with no Save or Delete when a filter-returning `update`/`delete` rule does not match the row. The session vocabulary now answers `'row-dependent'` for a filter-returning `update` or `delete` rule.
|
|
616
|
+
|
|
617
|
+
- [#2521](https://github.com/OpenSaasAU/stack/pull/2521) [`db8a224`](https://github.com/OpenSaasAU/stack/commit/db8a224028dcd92dc878c27f81df508069360d79) Thanks [@borisno2](https://github.com/borisno2)! - Fix a write through a leaked transaction context firing `beforeTransaction` but never `afterTransaction`; a flush enqueued after the registry drained now runs immediately with the rolled-back outcome.
|
|
618
|
+
|
|
619
|
+
- [#2474](https://github.com/OpenSaasAU/stack/pull/2474) [`9774d08`](https://github.com/OpenSaasAU/stack/commit/9774d082befd990e392748487bab65fbd916c27c) Thanks [@borisno2](https://github.com/borisno2)! - Internal restructuring: Field Visibility gains a single traversal for reads and write returns with no relation nodes, behind an internal switch that defaults to the existing walks.
|
|
620
|
+
|
|
621
|
+
- [#2494](https://github.com/OpenSaasAU/stack/pull/2494) [`5501533`](https://github.com/OpenSaasAU/stack/commit/5501533d6a6bd03e22fd8b6bcba95193ce0cf5fa) Thanks [@borisno2](https://github.com/borisno2)! - MCP: write schemas omit relations into lists whose read tool is off, a non-string tool name returns `-32602`, and `ping` answers an empty result.
|
|
622
|
+
|
|
623
|
+
- [#2514](https://github.com/OpenSaasAU/stack/pull/2514) [`f188f16`](https://github.com/OpenSaasAU/stack/commit/f188f16f01c73358e6bd79587ff5f9a8ba8a7c64) Thanks [@borisno2](https://github.com/borisno2)! - MCP per-list scopes now apply through relations (`fields`, `where`, `orderBy`, `connect`), and `create`/`update` return only the `id` to a token without the list's read scope or read tool.
|
|
624
|
+
|
|
625
|
+
- [#2518](https://github.com/OpenSaasAU/stack/pull/2518) [`dd3a77f`](https://github.com/OpenSaasAU/stack/commit/dd3a77f35ceff097fe397a56ce43839a58af2cc5) Thanks [@borisno2](https://github.com/borisno2)! - MCP `where`: a throwing `query` rule on an unnamed list no longer fails the query, `__proto__` is refused like on `context.db`, and `in`/`notIn` length and over-deep `AND` get the named cap refusal first.
|
|
626
|
+
|
|
627
|
+
- [#2475](https://github.com/OpenSaasAU/stack/pull/2475) [`756558e`](https://github.com/OpenSaasAU/stack/commit/756558eee7b8723827ff8770f0b346b43b4bd895) Thanks [@borisno2](https://github.com/borisno2)! - Internal restructuring: Field Visibility's single traversal now also handles reads with plain includes, behind the same internal switch, which still defaults to the existing walks.
|
|
628
|
+
|
|
629
|
+
- [#2470](https://github.com/OpenSaasAU/stack/pull/2470) [`df46667`](https://github.com/OpenSaasAU/stack/commit/df466677dd0d9a1b3de7cda12cd3901e656b8b3a) Thanks [@borisno2](https://github.com/borisno2)! - Internal restructuring: Field Visibility's tests now run through the secured surface, and its field-strip step drops an unused depth parameter.
|
|
630
|
+
|
|
631
|
+
- [#2468](https://github.com/OpenSaasAU/stack/pull/2468) [`94e8358`](https://github.com/OpenSaasAU/stack/commit/94e8358c069e34b96ee2f75e9581029572abbe59) Thanks [@borisno2](https://github.com/borisno2)! - Cover the delete path's Session vocabulary clear with a test.
|
|
632
|
+
|
|
633
|
+
- [#2444](https://github.com/OpenSaasAU/stack/pull/2444) [`6840f89`](https://github.com/OpenSaasAU/stack/commit/6840f89e366f6e52bbe0612628169db6f83fd566) Thanks [@borisno2](https://github.com/borisno2)! - Add an internal List member resolver that answers, once per list, what each usable name on a list is. No call site uses it yet.
|
|
634
|
+
|
|
635
|
+
- [#2426](https://github.com/OpenSaasAU/stack/pull/2426) [`a4dcb7e`](https://github.com/OpenSaasAU/stack/commit/a4dcb7e45a3aadab0251121d566520cee027b654) Thanks [@borisno2](https://github.com/borisno2)! - Fix the session vocabulary keeping stale answers: a successful write or committed transaction clears it, `rawOpensaasContext` keeps nothing, and a `resolveOutput` hook no longer waits on its own pending answer.
|
|
636
|
+
|
|
637
|
+
- [#2447](https://github.com/OpenSaasAU/stack/pull/2447) [`dff4310`](https://github.com/OpenSaasAU/stack/commit/dff4310b1cbf901f9ba401b85f33b0200fd81179) Thanks [@borisno2](https://github.com/borisno2)! - MCP asks the List member resolver which names a `where`, `orderBy`, write `data` and singleton read accept, and refuses a config `generate` refuses when its handlers are created.
|
|
638
|
+
|
|
639
|
+
- [#2466](https://github.com/OpenSaasAU/stack/pull/2466) [`5bd3fc6`](https://github.com/OpenSaasAU/stack/commit/5bd3fc6cd474acc1fea2cffa94d85209ddc913a6) Thanks [@borisno2](https://github.com/borisno2)! - A failed declared-rows fetch for a caller-shaped include now poisons its transaction owner, as every other engine read does.
|
|
640
|
+
|
|
641
|
+
- [#2424](https://github.com/OpenSaasAU/stack/pull/2424) [`565c4ca`](https://github.com/OpenSaasAU/stack/commit/565c4ca5de288b8c54cf2e3b5c811b44e913bf47) Thanks [@borisno2](https://github.com/borisno2)! - The engine context answers whether a singleton's row is stored, so `serializeItemForForm` can read a singleton without triggering `get()`'s auto-create.
|
|
642
|
+
|
|
643
|
+
- [#2478](https://github.com/OpenSaasAU/stack/pull/2478) [`1b45d87`](https://github.com/OpenSaasAU/stack/commit/1b45d877684393fb2dd61ac53ac3e4176fb5b322) Thanks [@borisno2](https://github.com/borisno2)! - Internal restructuring: Field Visibility has one implementation, its single traversal; the old walks, the switch between them and the comparison harness are deleted.
|
|
644
|
+
|
|
645
|
+
- [#2541](https://github.com/OpenSaasAU/stack/pull/2541) [`514a492`](https://github.com/OpenSaasAU/stack/commit/514a492e1d6c4f6c9f926f800c000e79a498f02c) Thanks [@borisno2](https://github.com/borisno2)! - `create`/`update` now throw `ValidationError` when `data` isn't an object, and a list `resolveInput` returning a non-object is rejected instead of silently dropping the payload.
|
|
646
|
+
|
|
647
|
+
- [#2472](https://github.com/OpenSaasAU/stack/pull/2472) [`5850dd6`](https://github.com/OpenSaasAU/stack/commit/5850dd64bbbda381027f344044ebc803cac76958) Thanks [@borisno2](https://github.com/borisno2)! - Internal restructuring: Field Visibility is one module, driven by the resolved read plan alone, and no longer imports the context module.
|
|
648
|
+
|
|
649
|
+
- [#2530](https://github.com/OpenSaasAU/stack/pull/2530) [`999eeae`](https://github.com/OpenSaasAU/stack/commit/999eeaeb595196b96f3068303812db790af9c370) Thanks [@borisno2](https://github.com/borisno2)! - Fix a concurrent first `tx.db.<Singleton>.get()` in two transactions aborting the loser's transaction: the auto-create now takes a transaction-scoped advisory lock and re-reads first.
|
|
650
|
+
|
|
651
|
+
- [#2463](https://github.com/OpenSaasAU/stack/pull/2463) [`a66e95e`](https://github.com/OpenSaasAU/stack/commit/a66e95e1fdbf6fe902b70b3ecd346084647e70cf) Thanks [@borisno2](https://github.com/borisno2)! - The dependency table, synthetic back-relation lookup, multi-column read assembly and singleton checks read from the List member table, so generated contracts and tables are unchanged.
|
|
652
|
+
A multi-column field is now assembled from its `columns` descriptor even without `getColumnNames`, and Field Visibility always resolves the list it reads, so a denied multi-column field's raw part columns never pass through.
|
|
653
|
+
|
|
654
|
+
- [#2448](https://github.com/OpenSaasAU/stack/pull/2448) [`b3120a1`](https://github.com/OpenSaasAU/stack/commit/b3120a1d6cc843ae53a7865a5d7e8696a3b3c935) Thanks [@borisno2](https://github.com/borisno2)! - Fix `select()` silently dropping a foreign key the list does not own ([#2388](https://github.com/OpenSaasAU/stack/issues/2388)), `distinct`/`distinctOn` refusing one it does own ([#2389](https://github.com/OpenSaasAU/stack/issues/2389)), and an undeclared `createdAt`/`updatedAt` on a list without timestamps being treated as a system field instead of an unknown name ([#2390](https://github.com/OpenSaasAU/stack/issues/2390)).
|
|
655
|
+
|
|
656
|
+
- [#2476](https://github.com/OpenSaasAU/stack/pull/2476) [`d417e3a`](https://github.com/OpenSaasAU/stack/commit/d417e3a4a1fef505587b6f83edcc6568e9db82e7) Thanks [@borisno2](https://github.com/borisno2)! - refactor(core): the single Field Visibility traversal handles reductions, caller-shaped declared relations and row-lock re-reads, with no hand-off to the old walks ([#2410](https://github.com/OpenSaasAU/stack/issues/2410))
|
|
657
|
+
|
|
658
|
+
## 0.44.0-alpha.6
|
|
659
|
+
|
|
660
|
+
### Minor Changes
|
|
661
|
+
|
|
662
|
+
- [#2201](https://github.com/OpenSaasAU/stack/pull/2201) [`0933b4b`](https://github.com/OpenSaasAU/stack/commit/0933b4bb6e19f56a2629623c3e5facb28fe8af73) Thanks [@dependabot](https://github.com/apps/dependabot)! - Upgrade to Prisma ORM 8.0.0-rc.22 and the `prisma` CLI to 8.0.0-rc.30
|
|
663
|
+
|
|
664
|
+
The stack's date and time columns are unchanged: `timestamp()` and `calendarDay()` keep reading and writing ISO strings, and `contract.json` is byte-identical. Prisma ORM now refuses to run from two installed copies, so every `@prisma/orm-*` package and the `prisma` CLI must move together:
|
|
665
|
+
|
|
666
|
+
```json
|
|
667
|
+
{
|
|
668
|
+
"dependencies": { "@prisma/orm-postgres": "8.0.0-rc.22" },
|
|
669
|
+
"devDependencies": { "prisma": "8.0.0-rc.30" }
|
|
670
|
+
}
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
Then run `pnpm generate` and commit what it writes. A project using `ragPlugin` or another pgvector declaration gets a new head for `migrations/pgvector/`: run `prisma db migrate` on each database to move the pack's marker.
|
|
674
|
+
|
|
675
|
+
- [#2270](https://github.com/OpenSaasAU/stack/pull/2270) [`e5ab353`](https://github.com/OpenSaasAU/stack/commit/e5ab353d7ec1d13c3cc73042deb8744ed95caeb2) Thanks [@borisno2](https://github.com/borisno2)! - The list filter grammar and the Filter builder gain OR groups (ADR-0083)
|
|
676
|
+
|
|
677
|
+
`?search=` reads `(a OR b)` as an OR group: rows matching any of its tokens, ANDed with the rest of the query and, as always, with the access filter. Groups do not nest.
|
|
678
|
+
|
|
679
|
+
```
|
|
680
|
+
(status:draft OR author:#0190a3c2-…) views:>100
|
|
681
|
+
(views:1..5 OR title:"Ada (Countess)")
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
**What changes meaning.** Only a matched group: `(` directly before the first token, uppercase `OR` between tokens, and `)` directly after the last, with no member word holding an unquoted parenthesis of its own. Everything else keeps the meaning it had: `a OR b` without parentheses, a lowercase `(a or b)`, a quoted `"OR"`, `(a)`, `-(a OR b)`, unmatched parentheses, nested groups, and a group-like run with a parenthesised word inside, such as `(see OR note(1) later)`, are still free-text words. A URL that already held a matched `(a OR b)` used to search for three words, and now matches either side.
|
|
685
|
+
|
|
686
|
+
Each token in a group maps exactly as it would on its own, negation included. A token in a group that cannot map — an unknown field, one the session cannot read, a value the field rejects — stays in place as its free-text alternative and is never dropped; a negated one searches its literal word and is never negated.
|
|
687
|
+
|
|
688
|
+
Core: `FilterTerm` is now `FilterToken | FilterGroup` (`{ kind: 'group', tokens }`), and `filterTermTokens`, `filterQueryTokens` and `FILTER_GROUP_KEYWORD` are exported. Code that read `parseFilterQuery(q).terms` as tokens flattens them:
|
|
689
|
+
|
|
690
|
+
```ts
|
|
691
|
+
import { filterQueryTokens, parseFilterQuery } from '@opensaas/stack-core'
|
|
692
|
+
|
|
693
|
+
for (const token of filterQueryTokens(parseFilterQuery(search))) {
|
|
694
|
+
// every token, inside groups too
|
|
695
|
+
}
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
UI: chips are joined by **and** / **or** connector buttons. Clicking an **and** joins two chips into a group, drawn as one bordered unit; clicking an **or** splits it. Typing `or ` after a filter adds an alternative to it, which is exactly one filter. Typing `draft or priya` searches for those words by default, as the URL reads them, and offers the whole group as the next suggestion. Typing or pasting `(draft OR priya)` applies that group. A "between" chip whose ends cannot be written as `a..b` stays a `>=`/`<=` pair, and the builder refuses to put it in a group. The list view's zero-results "Remove … to see N rows" counts an OR group as one term and removes it whole, and a column funnel adds its filter outside any group. A group left with one member stops being a group, and the "a second `is` replaces the first" rule applies outside groups only. New `data-slot`s: `filter-builder-group`, `filter-builder-connector` and `filter-builder-alternative`, with matching `group` and `connector` entries in `FilterBuilderClassNames`.
|
|
699
|
+
|
|
700
|
+
- [#2266](https://github.com/OpenSaasAU/stack/pull/2266) [`245ed13`](https://github.com/OpenSaasAU/stack/commit/245ed137dc768fafd83eb777bdc602af29ae0889) Thanks [@borisno2](https://github.com/borisno2)! - Look up a relationship record in the Filter builder and filter to exactly that record
|
|
701
|
+
|
|
702
|
+
Choosing a to-one relationship field in the admin list's Filter builder now lists the first page of its records and searches them as you type. Picking one writes `field:#id`: the chip shows the record's Item label while the URL carries its id. Picking under "does not contain" writes `-field:#id`, and a typed `field:#a,#b` matches either record; their chips show the labels too. Typing without picking still writes label text, shown as "contains". A `#id` the related list cannot hold is shown as the free text the list searches for. A to-many count Cell links to the other list filtered to that row, so an admin can go from an author to all their posts.
|
|
703
|
+
|
|
704
|
+
```text
|
|
705
|
+
/admin/post?search=author:#0190a3c2-7b1e-7000-8000-000000000001
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
`FilterSpec` gains an optional `toIdCondition(id)`, and `FilterFieldSuggestion` an optional `matchesById`. The built-in to-one relationship lowers `#id` through the relation, never the foreign key column, so the related list's `query` access applies and a record the session cannot read matches nothing. The id is parsed with `parseListId` for the related list's id strategy, and an id it cannot hold degrades to free text:
|
|
709
|
+
|
|
710
|
+
```ts
|
|
711
|
+
getFilterSpec: (fieldName, listKey, config) => ({
|
|
712
|
+
// ...
|
|
713
|
+
toIdCondition: (id) => {
|
|
714
|
+
const parsed = parseListId(config, 'User', id)
|
|
715
|
+
return parsed.ok ? { [fieldName]: { some: { id: { equals: parsed.value } } } } : null
|
|
716
|
+
},
|
|
717
|
+
})
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
Core exports `filterTokenRecordId(token)`, `filterValueRecordId(value)`, `recordIdFilterToken(field, id, negated?)` and `isFieldFilterableById(...)`, and the `relationshipOptions` server action answers `{ options, searched }`, where `searched` says whether `search` narrowed the options. `FilterBuilder` takes optional `listKey`, `serverAction` and `recordLabels` props, and the list view resolves the labels server-side through the secured context. Without a `serverAction`, a relationship field takes typed label text only. Cells receive an optional `href`.
|
|
721
|
+
|
|
722
|
+
Meaning change: on a field with `toIdCondition`, an unquoted value starting with `#` is now an id. A bookmarked `author:#abc` that used to mean "author's label contains #abc" now means the record with id `abc`, or free text when `abc` is not a valid id. Quote it (`author:"#abc"`) to keep the label search.
|
|
723
|
+
|
|
724
|
+
- [#2232](https://github.com/OpenSaasAU/stack/pull/2232) [`fa03c43`](https://github.com/OpenSaasAU/stack/commit/fa03c4313851a5f2caf016190843bb8a21f15f41) Thanks [@borisno2](https://github.com/borisno2)! - A field's `read` rule now denies when it reaches for a relation the row does not carry, closing a count, a `combine` of counts or an absent relation making a rule fail open.
|
|
725
|
+
|
|
726
|
+
This changes what rules see. A relation the read did not deliver whole — not included, narrowed by the caller with `where`, `limit`, `offset`, `orderBy`, `select` or a nested `include`, or reduced to counts with no rows — is withheld, and reading it denies that rule. A foreign key's rule takes the same decision on the same rows as every other rule on the row.
|
|
727
|
+
|
|
728
|
+
```typescript
|
|
729
|
+
const notes = relationship({
|
|
730
|
+
ref: 'Note.ticket',
|
|
731
|
+
many: true,
|
|
732
|
+
access: { read: ({ item }) => !item.notes?.some((note) => note.private) },
|
|
733
|
+
})
|
|
734
|
+
|
|
735
|
+
await context.db.Ticket.include('notes').all() // decides on the rows, as before
|
|
736
|
+
await context.db.Ticket.include('notes', (rows) => rows.count()).all() // denies, and used to pass
|
|
737
|
+
await context.db.Ticket.include('notes', (rows) => rows.limit(10)).all() // denies, and used to pass
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
- A rule that throws the `TypeError` of reading it, like `item.logs.length`, denies rather than failing the read, so the admin item view renders where it showed "Item not found". The section says it can't be shown, and the list view shows no count, rather than a false empty or `0`.
|
|
741
|
+
- An included to-one the related list's access left out is withheld, not `null`, so `!item.owner?.banned` no longer grants under `include('owner')`. `null` on a to-one with no foreign key set is a real answer. The inverse side of a one-to-one has no column to tell the two apart, so a rule reading it denies whenever the related list's access can leave a row out, even where there is no row. Rules that never read a relation, like an ownership check, are unaffected.
|
|
742
|
+
- A rule that catches a throw from `item` is now row-dependent, so `select` and `where` can no longer open it.
|
|
743
|
+
- A rule that enumerates or spreads `item` denies on a row withholding any relation, and a rule that writes through `item` denies and changes nothing. Use `toSorted()` rather than `sort()` on a relation.
|
|
744
|
+
- Everything a rule can see of a related list is what the session can see, so never grant on an absence there. Grant on a row the session can see, or keep the fact in a column on the row that only rises. See "What a read rule sees" in the access control docs and ADR-0082.
|
|
745
|
+
|
|
746
|
+
- [#2258](https://github.com/OpenSaasAU/stack/pull/2258) [`fb1a7a6`](https://github.com/OpenSaasAU/stack/commit/fb1a7a63429586f3ead4fbd9ab506e9aa9b50847) Thanks [@borisno2](https://github.com/borisno2)! - Core owns one structured filter query, with a parser and serialiser that are true inverses (ADR-0083)
|
|
747
|
+
|
|
748
|
+
Breaking: `FilterToken` drops `value` and `raw` for `kind`, `negated`, `values` and `quoted`, and `parseFilterQuery`, `serializeFilterQuery` and `buildFilterWhere` now take or return a `FilterQuery`. `@opensaas/stack-ui` removes `queryToState`, `stateToQuery`, `FilterRow` and `FilterBuilderState`.
|
|
749
|
+
|
|
750
|
+
Migrating from the removed UI helpers and the old token shape:
|
|
751
|
+
|
|
752
|
+
```ts
|
|
753
|
+
// Before
|
|
754
|
+
import { queryToState, stateToQuery } from '@opensaas/stack-ui'
|
|
755
|
+
const state = queryToState(search)
|
|
756
|
+
const next = stateToQuery(state)
|
|
757
|
+
token.value
|
|
758
|
+
|
|
759
|
+
// After
|
|
760
|
+
import {
|
|
761
|
+
isFieldConditionToken,
|
|
762
|
+
parseFilterQuery,
|
|
763
|
+
serializeFilterQuery,
|
|
764
|
+
} from '@opensaas/stack-core'
|
|
765
|
+
const query = parseFilterQuery(search)
|
|
766
|
+
const rows = query.terms.filter((token) => isFieldConditionToken(token, operatorsFor))
|
|
767
|
+
const next = serializeFilterQuery(query)
|
|
768
|
+
token.values[0]
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
`parseFilterQuery` returns a `FilterQuery`, an AND of terms, and `serializeFilterQuery` and `buildFilterWhere` take one. The grammar is today's: a parsed token is never negated and carries exactly one value, and a leading `-` or a `,` is part of the value. The parser never throws, and for every query it returns, `parseFilterQuery(serializeFilterQuery(query))` gives that query back, with `quoted` set where the serialiser had to quote. `isEmptyFilterToken` and `isFieldConditionToken` are exported so callers share the engine's rules for which tokens filter nothing and which map through a field.
|
|
772
|
+
|
|
773
|
+
```ts
|
|
774
|
+
import { parseFilterQuery, serializeFilterQuery } from '@opensaas/stack-core'
|
|
775
|
+
|
|
776
|
+
const query = parseFilterQuery('title:"Ada \\"the Countess\\"" "status:draft"')
|
|
777
|
+
// query.terms[0]: { kind: 'token', field: 'title', operator: 'eq', negated: false,
|
|
778
|
+
// values: ['Ada "the Countess"'], quoted: true }
|
|
779
|
+
// query.terms[1]: { kind: 'token', field: null, ..., values: ['status:draft'], quoted: true }
|
|
780
|
+
serializeFilterQuery(query) // 'title:"Ada \\"the Countess\\"" "status:draft"'
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
Two round-trip defects are fixed: an embedded quote is written as `\"` inside a quoted value, and a quoted `"status:draft"` stays a free-text word instead of coming back as a `status` filter.
|
|
784
|
+
|
|
785
|
+
Some existing `?search=` URLs now read differently:
|
|
786
|
+
|
|
787
|
+
- Inside a quoted value, `\"` is a literal quote and `\\` a literal backslash, so a quoted value containing either reads differently. A value the old serialiser wrote ending in a backslash, `name:"my dir\" beta`, no longer closes its quote.
|
|
788
|
+
- Every whitespace character, including a non-breaking space, separates tokens.
|
|
789
|
+
|
|
790
|
+
`serializeFilterQuery` now writes every term, so a token with an empty value is written as `field:` or `""` instead of being dropped. Remove empty tokens before serialising, with `isEmptyFilterToken`, when the result should not carry them. It also quotes a value containing a comma or any whitespace, and a free-text word starting with `-`, so `title:a,b` is written `title:"a,b"` with the same meaning.
|
|
791
|
+
|
|
792
|
+
`FilterBuilder` builds on core's parser and serialiser directly. Its props are unchanged. It keeps an unchanged query in the order it was written and never writes an empty row or empty token into the URL.
|
|
793
|
+
|
|
794
|
+
- [#2265](https://github.com/OpenSaasAU/stack/pull/2265) [`d348bba`](https://github.com/OpenSaasAU/stack/commit/d348bba8c21c466b1d0fa4645b12ca757be7c02f) Thanks [@!](https://github.com/!)! - The list filter grammar gains "is not", "is any of" and "is empty" (ADR-0083)
|
|
795
|
+
|
|
796
|
+
`?search=` now reads a leading `-` as negation, a comma list as several values and `field:!` as "is empty":
|
|
797
|
+
|
|
798
|
+
```
|
|
799
|
+
-category:product # is not product, rows with no category included
|
|
800
|
+
status:draft,review # is any of
|
|
801
|
+
-author:! # is empty / is not empty
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
The engine composes `NOT` and `OR` around each field's existing `toCondition`, so a third-party field gets negation and any-of with no changes. To offer "is empty", a Filter spec states what empty means with the new optional `empty` member:
|
|
805
|
+
|
|
806
|
+
```ts
|
|
807
|
+
getFilterSpec: (fieldName) => ({
|
|
808
|
+
operators: ['eq'],
|
|
809
|
+
toCondition: (operator, value) =>
|
|
810
|
+
operator === 'eq' ? { [fieldName]: { equals: value } } : null,
|
|
811
|
+
empty: { [fieldName]: { equals: null } },
|
|
812
|
+
suggestions: { valueSource: { kind: 'none' } },
|
|
813
|
+
})
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
Every core field that can be empty sets it, and `collectFilterSuggestions` reports it as `canBeEmpty: true`. A negated token is ORed with the field's `empty` condition, so "is not" keeps the rows with no value, unless the spec's new optional `negation` says `NOT` alone already does (`'includesEmpty'`, as on a to-one relationship) or only restates another condition (`'redundant'`, as on a to-many count, where the builder then offers no "is not"). A token that cannot map in any part is searched as one free-text word, the new `filterTokenFreeTextWord(token)`, which is also what its chip shows. A positive token searches its values with the field name dropped (`status:draft,bogus` searches `draft,bogus`); a negated one searches its whole literal and is never negated (`-secret:x` on a field the session cannot read searches `-secret:x`).
|
|
817
|
+
|
|
818
|
+
`FilterToken` now carries its quoting per value — `values: Array<{ text, quoted }>` replaces `values: string[]` and the token-level `quoted` — and its `operator` is a `FilterTokenOperator` (`FilterOperator | 'empty'`). `isFieldConditionToken` takes a lookup returning `{ operators, canBeEmpty }`, so a `FilterFieldSuggestion` can be passed straight in. The comparison prefixes are exported once as `FILTER_OPERATOR_PREFIXES` and `FILTER_COMPARISON_PREFIXES`.
|
|
819
|
+
|
|
820
|
+
The Filter builder offers "is not" / "does not contain", "is any of" (a multi-select list building one chip) and "is empty" / "is not empty" where the field can be empty, reads phrases such as `status is not draft`, `views != 3` and `author is empty`, and hydrates each shape from the URL as a chip. It adds the `filter-builder-option-check` slot, and an "is empty" chip renders no `filter-builder-chip-value` part.
|
|
821
|
+
|
|
822
|
+
- [#2264](https://github.com/OpenSaasAU/stack/pull/2264) [`00ffa44`](https://github.com/OpenSaasAU/stack/commit/00ffa44bc8143783cb073ecb807f710028ae553d) Thanks [@borisno2](https://github.com/borisno2)! - Replace the list view's Filter builder row form with a single filter bar
|
|
823
|
+
|
|
824
|
+
The Filter builder is now one bar where an admin types and suggestions build the
|
|
825
|
+
`?search=` query. Focusing it lists every filterable field; typing suggests
|
|
826
|
+
matching fields, config-enumerated values (`draft` offers "Status is Draft"),
|
|
827
|
+
plain phrases such as `views > 5000` or `status is draft`, and always a free-text
|
|
828
|
+
search. Choosing a field goes straight to its values, and Tab or a click switches
|
|
829
|
+
the condition. Each committed Filter token becomes a chip that can be edited by
|
|
830
|
+
clicking it, removed singly or cleared with the rest. Every commit applies at
|
|
831
|
+
once through `router.push` inside a transition, so the rows stay visible and Back
|
|
832
|
+
steps through changes; there is no Apply button, and partly typed text never
|
|
833
|
+
navigates. `/` focuses the bar, the arrows and Backspace select and remove chips,
|
|
834
|
+
and Esc cancels. The bar is a labelled combobox using `aria-activedescendant`.
|
|
835
|
+
|
|
836
|
+
`FilterBuilder` keeps its `suggestions`, `defaultValue` and `onApply` props, and
|
|
837
|
+
gains optional `label` and `resultCount`:
|
|
838
|
+
|
|
839
|
+
```tsx
|
|
840
|
+
<FilterBuilder
|
|
841
|
+
suggestions={suggestions}
|
|
842
|
+
defaultValue={search}
|
|
843
|
+
onApply={(query) => router.push(`?search=${encodeURIComponent(query)}`)}
|
|
844
|
+
label="Filter posts"
|
|
845
|
+
resultCount={total}
|
|
846
|
+
/>
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
`filter-builder` stays the root `data-slot`. Removed slots: `filter-builder-conditions`,
|
|
850
|
+
`filter-builder-condition`, `filter-builder-field`, `filter-builder-operator`,
|
|
851
|
+
`filter-builder-value`, `filter-builder-remove`, `filter-builder-form`,
|
|
852
|
+
`filter-builder-search`, `filter-builder-search-clear`, `filter-builder-add` and
|
|
853
|
+
`filter-builder-apply`, with their `classNames` keys (`conditions`, `condition`,
|
|
854
|
+
`field`, `operator`, `value`, `remove`, `form`, `search`, `add`, `apply`). Added
|
|
855
|
+
slots: `filter-builder-bar`, `filter-builder-chip`, `filter-builder-chip-field`,
|
|
856
|
+
`filter-builder-chip-condition`, `filter-builder-chip-value`,
|
|
857
|
+
`filter-builder-chip-remove`, `filter-builder-draft`, `filter-builder-input`,
|
|
858
|
+
`filter-builder-progress`, `filter-builder-menu`, `filter-builder-menu-conditions`,
|
|
859
|
+
`filter-builder-menu-condition`, `filter-builder-option` and `filter-builder-hint`,
|
|
860
|
+
with `classNames` keys `bar`, `chip`, `chipRemove`, `draft`, `input`, `menu`,
|
|
861
|
+
`option` and `hint`. `filter-builder-clear` remains. `PopoverAnchor` is now
|
|
862
|
+
exported from the primitives.
|
|
863
|
+
|
|
864
|
+
A Filter spec can state the shape a typed value must take, so the builder
|
|
865
|
+
explains a value that does not fit instead of applying it as free text. The
|
|
866
|
+
built-in numeric, date and to-many relationship fields declare one:
|
|
867
|
+
|
|
868
|
+
```ts
|
|
869
|
+
getFilterSpec: (fieldName) => ({
|
|
870
|
+
operators: ['eq', 'gt', 'gte', 'lt', 'lte'],
|
|
871
|
+
toCondition: (operator, value) => /* … */,
|
|
872
|
+
suggestions: {
|
|
873
|
+
valueSource: { kind: 'none' },
|
|
874
|
+
valueFormat: { pattern: '^-?\\d+$', description: 'takes a whole number' },
|
|
875
|
+
},
|
|
876
|
+
})
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
`collectFilterSuggestions` passes it on as `FilterFieldSuggestion.valueFormat`,
|
|
880
|
+
and `FilterValueFormat` is exported from the root and `/extend` entry points.
|
|
881
|
+
|
|
882
|
+
Each built-in field's `toCondition` tests the same `RegExp` its `valueFormat`
|
|
883
|
+
declares, so the hint and the engine agree, and `valueFormat.operators` gives an
|
|
884
|
+
operator its own pattern (`FilterValuePattern`, exported beside
|
|
885
|
+
`FilterValueFormat`). A to-many relationship declares `eq` and `gt` with `0` and
|
|
886
|
+
`gte` with `1`. A calendar day naming a month or day that does not exist
|
|
887
|
+
(`2026-13-01`, `2026-02-31`) degrades to free text instead of reaching Postgres.
|
|
888
|
+
A timestamp still takes anything `Date` parses and declares no `valueFormat`.
|
|
889
|
+
|
|
890
|
+
- [#2269](https://github.com/OpenSaasAU/stack/pull/2269) [`3b25a56`](https://github.com/OpenSaasAU/stack/commit/3b25a567086b032cad28c50bd6eb1713d445c63d) Thanks [@borisno2](https://github.com/borisno2)! - Add `filterSuggestionsOf(specs)`, which turns Filter specs already collected with `collectFilterSpecs` into the Filter builder's suggestions, so a caller that also builds a `where` from those specs evaluates each field's `read` rule once.
|
|
891
|
+
|
|
892
|
+
```ts
|
|
893
|
+
import {
|
|
894
|
+
buildFilterWhere,
|
|
895
|
+
collectFilterSpecs,
|
|
896
|
+
filterSuggestionsOf,
|
|
897
|
+
parseFilterQuery,
|
|
898
|
+
} from '@opensaas/stack-core'
|
|
899
|
+
|
|
900
|
+
const specs = await collectFilterSpecs(listConfig, 'Post', config, { session, context })
|
|
901
|
+
const suggestions = filterSuggestionsOf(specs)
|
|
902
|
+
const where = buildFilterWhere(parseFilterQuery(search), specs)
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
- [#2260](https://github.com/OpenSaasAU/stack/pull/2260) [`93fd6c9`](https://github.com/OpenSaasAU/stack/commit/93fd6c9f4fe136b0a987ffdf436566de9f50b1ba) Thanks [@borisno2](https://github.com/borisno2)! - Add Row actions to the admin list view
|
|
906
|
+
|
|
907
|
+
Each row now has a menu with the built-in Edit, Copy link and Delete (confirmed through `ConfirmDialog`), and the row title links to the item page. The previous per-row Edit link moves into that menu. A list declares its own actions under `ui.listView.rowActions`, each with a key unique within the list (`config()` throws on a duplicate):
|
|
908
|
+
|
|
909
|
+
```ts
|
|
910
|
+
ui: {
|
|
911
|
+
listView: {
|
|
912
|
+
rowActions: [
|
|
913
|
+
{
|
|
914
|
+
key: 'publish',
|
|
915
|
+
label: 'Publish now',
|
|
916
|
+
icon: 'send',
|
|
917
|
+
hasAccess: ({ session }) => session !== null,
|
|
918
|
+
isAvailable: ({ item }) => item.status !== 'published',
|
|
919
|
+
handler: async ({ id, context }) => {
|
|
920
|
+
const post = await context.db.Post.update({ where: { id }, data: { status: 'published' } })
|
|
921
|
+
return { message: post ? 'Published' : 'Not published' }
|
|
922
|
+
},
|
|
923
|
+
},
|
|
924
|
+
],
|
|
925
|
+
},
|
|
926
|
+
}
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
`hasAccess` is resolved once per request and the synchronous `isAvailable` per row on the server, over a read in the same shape dispatch re-reads the row in; only the available keys reach the client, and handlers never do. Running one dispatches the new `serverAction` operation `{ action: 'rowAction', key, id }`, which re-checks `hasAccess` before touching the row (a refused session never takes a lock), then opens a transaction, takes a row lock on the row (`.forUpdate()`), re-reads it through the secured context and re-runs `isAvailable` before the handler runs. The list view and dispatch evaluate `isAvailable` through one helper: a throw, or a result that is not a boolean (a Promise from an async check), is logged and treated as unavailable in both. The handler runs inside that transaction with a transaction-bound `context`, so its writes commit atomically with the checks and a throw rolls them back; a concurrent dispatch of a one-shot action waits on the lock and then answers "not run". The lock is held while the handler runs, so keep slow external calls short or make them after it returns. The handler's `id` is the list's own id type (`RowActionContext<TypeInfo>['id']`, a `number` on an `int autoincrement` list). A missing, denied or no-longer-eligible row, or a `hasAccess` or `isAvailable` that throws, answers `{ rowAction: false, error: 'This action was not run' }` alike. Outcomes appear in the list's status line; a dispatch that fails in transit reports an unknown result and refreshes the list.
|
|
930
|
+
|
|
931
|
+
`@opensaas/stack-ui/primitives` gains a `DropdownMenu` primitive on the existing Radix dependency, with `dropdown-menu-*` slots. The list view adds the `row-actions-trigger` and `row-title-link` slots.
|
|
932
|
+
|
|
933
|
+
- [#2268](https://github.com/OpenSaasAU/stack/pull/2268) [`4bf2987`](https://github.com/OpenSaasAU/stack/commit/4bf2987f8cf6ffcf3626a41c5953bbadfbc256c4) Thanks [@borisno2](https://github.com/borisno2)! - Add Preset views to the admin list view
|
|
934
|
+
|
|
935
|
+
A list declares named starting points under `ui.listView.presets`. They show as tabs above the Filter builder, after an implicit "All" tab, with no counts. Each key must be non-empty and unique within the list (`config()` throws otherwise):
|
|
936
|
+
|
|
937
|
+
```ts
|
|
938
|
+
import { quoteFilterValue } from '@opensaas/stack-core'
|
|
939
|
+
|
|
940
|
+
ui: {
|
|
941
|
+
listView: {
|
|
942
|
+
presets: [
|
|
943
|
+
{
|
|
944
|
+
key: 'my-drafts',
|
|
945
|
+
label: 'My drafts',
|
|
946
|
+
search: ({ session }) => `status:draft author:#${session?.userId ?? ''}`,
|
|
947
|
+
sort: { field: 'title', direction: 'asc' }, // optional
|
|
948
|
+
hasAccess: ({ session }) => typeof session?.userId === 'string', // optional
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
key: 'named-for-me',
|
|
952
|
+
label: 'Named for me',
|
|
953
|
+
search: ({ session }) => `title:${quoteFilterValue(session?.name ?? '')}`,
|
|
954
|
+
},
|
|
955
|
+
],
|
|
956
|
+
},
|
|
957
|
+
}
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
`search` is a `?search=` query or a function of the session, and is resolved on the server for every request. It runs through the same filter engine and secured context as a typed query, so a preset only narrows. `sort` goes through the same check as `?sort=`. Only each tab's `key` and `label` cross to the client.
|
|
961
|
+
|
|
962
|
+
`author:#<id>` matches exactly the session's own records. The new `quoteFilterValue(text)` export from `@opensaas/stack-core` quotes any other value built from data, so it always reads back as exactly one filter value.
|
|
963
|
+
|
|
964
|
+
`?preset=<key>` opens a preset, so a shared link resolves against the recipient's session. The first change to the filter, sort, columns or page size writes the preset out as `?search=` and `?sort=` and drops `?preset=`, leaving the rows on screen unchanged. An unknown key, or one whose `hasAccess` does not return `true`, shows the plain list. An open preset with no rows says so by its label rather than echoing its query.
|
|
965
|
+
|
|
966
|
+
`ListView` takes a new `preset` prop (`AdminUI` reads it from `?preset=`), and `ListViewClient` takes `presets` and `activePreset`. The tabs carry the `preset-tabs` and `preset-tab` slots.
|
|
967
|
+
|
|
968
|
+
- [#2267](https://github.com/OpenSaasAU/stack/pull/2267) [`202f957`](https://github.com/OpenSaasAU/stack/commit/202f95732d7a639ef1e9a4b77c222720b3c0a158) Thanks [@borisno2](https://github.com/borisno2)! - Filter numbers and dates by range, with date presets that follow the admin's time zone
|
|
969
|
+
|
|
970
|
+
`field:a..b` is an inclusive range in one token. `parseFilterQuery` reads it as a token with `operator: 'range'` and the two bounds as its `values`, and `serializeFilterQuery` writes it back unchanged. Any field whose Filter spec accepts both `gte` and `lte` takes a range with nothing more to declare: the engine lowers each bound through the field's own `toCondition`, and a range with a bound the field does not take degrades to free text. On a field that takes no range, `field:a..b` keeps its old meaning, that field's `eq` on the literal `a..b`, so `title:wait...what` still means "title contains wait...what". `-field:a..b` excludes the range, composed like any other negation, so it keeps the rows with no value; a range that cannot map is searched as its literal and never negated. A list is never a range: `field:a..b,c` is "any of" the literal values.
|
|
971
|
+
|
|
972
|
+
```
|
|
973
|
+
views:1000..5000
|
|
974
|
+
publishedAt:2026-11-02T00:00:00.000+11:00..2026-11-08T23:59:59.999+11:00
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
In a URL, encode the `+` of an offset as `%2B`: `?search=publishedAt:2026-11-02T00:00:00.000%2B11:00..2026-11-08T23:59:59.999%2B11:00`.
|
|
978
|
+
|
|
979
|
+
`FilterTokenOperator` gains `'range'` (`FilterOperator | 'empty' | 'range'`), whose two `values` are the bounds, and core exports `supportsFilterRange`, `filterTokenOperators` and `effectiveFilterToken`. A Filter spec may state `suggestions.datePicker` (`'day'` or `'instant'`) to get date inputs and presets in the Filter builder; `calendarDay()` declares `'day'` and `timestamp()` declares `'instant'`:
|
|
980
|
+
|
|
981
|
+
```ts
|
|
982
|
+
getFilterSpec: (fieldName) => ({
|
|
983
|
+
operators: ['gte', 'lte'],
|
|
984
|
+
toCondition: (operator, value) => {
|
|
985
|
+
const date = new Date(value)
|
|
986
|
+
return Number.isNaN(date.getTime()) ? null : { [fieldName]: { [operator]: date } }
|
|
987
|
+
},
|
|
988
|
+
suggestions: { valueSource: { kind: 'none' }, datePicker: 'instant' },
|
|
989
|
+
})
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
The Filter builder offers a "between" condition beside "is not", "is any of" and "is empty", typed as `1000-5000`, `1000 to 5000` or `1000..5000`, or picked with date inputs. Date fields add presets (Today, Last 7 days, Last 30 days, This month, Last month, This year) that write absolute dates, shown on the chip. A timestamp is written as ISO instants in the browser's offset with the end day inclusive, whether its dates are picked, typed or pasted; a calendar day stays plain `YYYY-MM-DD`. On a field with date inputs, Tab moves into them and Alt+← → switches the condition. Pasted `>=` and `<=` tokens on one field read back as one chip while the URL keeps both tokens. `FilterBuilder` gains a `dates` slot (`filter-builder-dates`).
|
|
993
|
+
|
|
994
|
+
### Patch Changes
|
|
995
|
+
|
|
996
|
+
- [#2393](https://github.com/OpenSaasAU/stack/pull/2393) [`bf9aac3`](https://github.com/OpenSaasAU/stack/commit/bf9aac34f50453ad250f09415f97eff031b4e928) Thanks [@borisno2](https://github.com/borisno2)! - Bump Prisma to 8.0.0-rc.23 (CLI 8.0.0-rc.33); decimal columns use the renamed `numericStringColumn` helper.
|
|
997
|
+
|
|
998
|
+
- [#2217](https://github.com/OpenSaasAU/stack/pull/2217) [`eaeee36`](https://github.com/OpenSaasAU/stack/commit/eaeee363778e5717371720deec7c4518dfaa80e1) Thanks [@borisno2](https://github.com/borisno2)! - Fix `create`, `update` and `delete` throwing or returning a wrong value on a list whose computed field declares a relation in `needs`; a write now returns that field exactly as `first()` does.
|
|
999
|
+
|
|
1000
|
+
- [#2328](https://github.com/OpenSaasAU/stack/pull/2328) [`7e396ee`](https://github.com/OpenSaasAU/stack/commit/7e396ee4bfa750a71023644b2bfbc42ba4bfc185) Thanks [@borisno2](https://github.com/borisno2)! - Writes of values a column cannot hold (out-of-range integers and bigints, overflowing or non-numeric decimals, impossible calendar days, NUL bytes, null into NOT NULL columns) now throw `ValidationError` instead of an opaque `DatabaseError`.
|
|
1001
|
+
|
|
1002
|
+
- [#2350](https://github.com/OpenSaasAU/stack/pull/2350) [`98e7ab2`](https://github.com/OpenSaasAU/stack/commit/98e7ab274b009274d0b10e8cc2c3493490096930) Thanks [@borisno2](https://github.com/borisno2)! - Field-level `beforeOperation` now fires for a multi-column field on create and update ([#2161](https://github.com/OpenSaasAU/stack/issues/2161)). List and field hooks now see the logical key in `resolvedData` rather than the split physical columns.
|
|
1003
|
+
|
|
1004
|
+
- [#2218](https://github.com/OpenSaasAU/stack/pull/2218) [`357f9bb`](https://github.com/OpenSaasAU/stack/commit/357f9bbf16499fd1d7da1a02e5c9370d60ae661a) Thanks [@borisno2](https://github.com/borisno2)! - Fix optional JSON, select and text admin fields not clearing to `null`; `json()` now refuses a `null` for a NOT NULL column with an error on the field.
|
|
1005
|
+
A hook on an optional text field now receives `null`, not `''`, when it's emptied in the admin, so an `=== ''` check no longer fires. Guard with `typeof value === 'string'`, not `?.`, which turns `null` into `undefined` and silently drops the write.
|
|
1006
|
+
|
|
1007
|
+
- [#2195](https://github.com/OpenSaasAU/stack/pull/2195) [`ddb9e8c`](https://github.com/OpenSaasAU/stack/commit/ddb9e8cdbf67e42467ec3fec98f22c037f2a5de2) Thanks [@borisno2](https://github.com/borisno2)! - Root `update` locks `FOR NO KEY UPDATE`, fixing the deadlock between racers that insert a child and update its parent.
|
|
1008
|
+
A transaction that then needs `FOR UPDATE` on that row, or changes a column in a unique index, can now deadlock with a racer holding its foreign-key lock (ADR-0078).
|
|
1009
|
+
|
|
1010
|
+
- [#2346](https://github.com/OpenSaasAU/stack/pull/2346) [`3308acc`](https://github.com/OpenSaasAU/stack/commit/3308acc8871bf40f1603c4f00c9919a39596b66f) Thanks [@borisno2](https://github.com/borisno2)! - Fix `update` and `delete` failing for the life of the process when another Next bundle built the client first; the row lock now binds plain values instead of a bundle-local `ParamRef`.
|
|
1011
|
+
|
|
1012
|
+
- [#2329](https://github.com/OpenSaasAU/stack/pull/2329) [`7f48687`](https://github.com/OpenSaasAU/stack/commit/7f4868750f71b779af228052e4deaa68505fe3a2) Thanks [@borisno2](https://github.com/borisno2)! - MCP endpoint: GET and DELETE now return 405 with `Allow: POST`, and a malformed JSON body returns a JSON-RPC -32700 parse error with status 400 instead of 500.
|
|
1013
|
+
|
|
1014
|
+
- [#2351](https://github.com/OpenSaasAU/stack/pull/2351) [`75ca96c`](https://github.com/OpenSaasAU/stack/commit/75ca96cbb3c18cb94fbb0e2d538287cb57436ad2) Thanks [@borisno2](https://github.com/borisno2)! - MCP: a relation into a list whose read tool is off or whose `mcp.enabled` is false is no longer selectable, connectable, or filterable through its foreign-key column, and `orderBy` refuses it too.
|
|
1015
|
+
|
|
1016
|
+
- [#2361](https://github.com/OpenSaasAU/stack/pull/2361) [`17c7ed8`](https://github.com/OpenSaasAU/stack/commit/17c7ed8276a2d2ea99cca471b39800f45e8bd4ba) Thanks [@borisno2](https://github.com/borisno2)! - Fix MCP `list_<singleton>_query` failing with an internal error; it now reads the singleton through `get()` and returns `{ items: [row], count: 1 }`.
|
|
1017
|
+
|
|
1018
|
+
- [#2208](https://github.com/OpenSaasAU/stack/pull/2208) [`0dd7eb4`](https://github.com/OpenSaasAU/stack/commit/0dd7eb4b4a9e5b3ec338b39f8ca83e135de36480) Thanks [@borisno2](https://github.com/borisno2)! - Fix a caller-shaped `combine()` rows branch, or an MCP `count` beside `take: 0`, bypassing a relationship's own `read` rule and revealing the count.
|
|
1019
|
+
A `combine()` with a rows branch now strips as the plain include does.
|
|
1020
|
+
|
|
1021
|
+
- [#2209](https://github.com/OpenSaasAU/stack/pull/2209) [`4a8b631`](https://github.com/OpenSaasAU/stack/commit/4a8b631e7dcfb3bf5e3eb118193722b2e31d842e) Thanks [@borisno2](https://github.com/borisno2)! - Fix `opensaas generate` failing with "gen is not defined" when a config uses the `cuid` id strategy and no list uses `uuid7`, `cuid2` or `updatedAt`
|
|
1022
|
+
|
|
1023
|
+
- [#2359](https://github.com/OpenSaasAU/stack/pull/2359) [`0433dd7`](https://github.com/OpenSaasAU/stack/commit/0433dd77232da5d658dcd04682b6bc2627ab7504) Thanks [@borisno2](https://github.com/borisno2)! - Document that plugin services are not transactional and that a service called from a hook takes the hook's `context` to join its transaction ([#2165](https://github.com/OpenSaasAU/stack/issues/2165)).
|
|
1024
|
+
|
|
1025
|
+
- [#2349](https://github.com/OpenSaasAU/stack/pull/2349) [`57e6e08`](https://github.com/OpenSaasAU/stack/commit/57e6e08c9785f24ccdba3a809cf1368a4aac9866) Thanks [@borisno2](https://github.com/borisno2)! - Classify a deadlock victim (SQLSTATE `40P01`) as `SerializationFailure`, so `isSerializationFailure` matches it and a retry loop can act on it.
|
|
1026
|
+
|
|
1027
|
+
- [#2289](https://github.com/OpenSaasAU/stack/pull/2289) [`cb7e21d`](https://github.com/OpenSaasAU/stack/commit/cb7e21d153d26ee5edb9c4566c9f393891e3e62b) Thanks [@borisno2](https://github.com/borisno2)! - The admin list's column picker, `?columns=` and default columns omit a field whose `read` rule denies the session for every row, matching the MCP vocabulary.
|
|
1028
|
+
|
|
1029
|
+
- [#2143](https://github.com/OpenSaasAU/stack/pull/2143) [`a854243`](https://github.com/OpenSaasAU/stack/commit/a85424322701f3db9682b0f54acdc51bee404912) Thanks [@borisno2](https://github.com/borisno2)! - MCP `where` relation predicates into a list with `mcp.enabled: false`, `mcp.tools.read: false` or denied query access are now refused as an unknown key.
|
|
1030
|
+
|
|
1031
|
+
- [#2353](https://github.com/OpenSaasAU/stack/pull/2353) [`b195e11`](https://github.com/OpenSaasAU/stack/commit/b195e1174f96323c1a8f7dc9429cc570a8fd7151) Thanks [@borisno2](https://github.com/borisno2)! - A field `read` rule that calls `structuredClone` on a nested value now denies instead of failing the write with `DataCloneError`.
|
|
1032
|
+
|
|
1033
|
+
- [#2332](https://github.com/OpenSaasAU/stack/pull/2332) [`6269806`](https://github.com/OpenSaasAU/stack/commit/62698062fed9caf9640d2be03c3f25d4aba0e765) Thanks [@borisno2](https://github.com/borisno2)! - `opensaas generate` now refuses a `db.provider` other than `'postgresql'`, a stray `db.url`, a lower-case list key, and a relationship ref to an undeclared list (naming the list and field).
|
|
1034
|
+
|
|
1035
|
+
- [#2211](https://github.com/OpenSaasAU/stack/pull/2211) [`af04b65`](https://github.com/OpenSaasAU/stack/commit/af04b65745d55e0e174c2b95b04f0577651f0861) Thanks [@borisno2](https://github.com/borisno2)! - Fix admin lists emptying on a sort the column cannot take: sorting now follows the ORM's own `order` answer per column, and `orderBy` refuses a virtual or multi-column field as a `ValidationError`.
|
|
1036
|
+
A failed list read now shows an error state rather than the first-run empty state.
|
|
1037
|
+
|
|
1038
|
+
- [#2282](https://github.com/OpenSaasAU/stack/pull/2282) [`369cbf4`](https://github.com/OpenSaasAU/stack/commit/369cbf426c944e91c867e1957969876e37a7bbe2) Thanks [@borisno2](https://github.com/borisno2)! - A hand-built top-level `range` filter token whose bounds cannot be written `a..b` now filters exactly as its serialised URL does.
|
|
1039
|
+
|
|
1040
|
+
- [#2275](https://github.com/OpenSaasAU/stack/pull/2275) [`491c0dc`](https://github.com/OpenSaasAU/stack/commit/491c0dcb96e4bd3ee8d89a8174da27767a01657f) Thanks [@borisno2](https://github.com/borisno2)! - Row and bulk actions now run only when `hasAccess` returns exactly `true`, the same rule as the menu; a truthy non-`true` value or a throwing check is refused.
|
|
1041
|
+
|
|
1042
|
+
- [#2277](https://github.com/OpenSaasAU/stack/pull/2277) [`94ea1ee`](https://github.com/OpenSaasAU/stack/commit/94ea1ee342effcecb0b639ab0b2e1d686514b402) Thanks [@borisno2](https://github.com/borisno2)! - Document that `BulkAction.hasAccess` and `RowAction.hasAccess` show and run an action only on a literal `true`; anything else, or a throw, hides and refuses it.
|
|
1043
|
+
|
|
1044
|
+
- [#2335](https://github.com/OpenSaasAU/stack/pull/2335) [`1ac5cfc`](https://github.com/OpenSaasAU/stack/commit/1ac5cfc3cabd17e3ebd0214e0d927521bdcfd0e6) Thanks [@borisno2](https://github.com/borisno2)! - A timestamp `is <date>` filter now matches the whole day: core treats a date-only `eq` value as that UTC day, and the Filter builder turns any date-only input (e.g. `8/4/2026`) into the same local-day range as `YYYY-MM-DD` (fixes [#2310](https://github.com/OpenSaasAU/stack/issues/2310)).
|
|
1045
|
+
|
|
1046
|
+
- [#2363](https://github.com/OpenSaasAU/stack/pull/2363) [`9024abb`](https://github.com/OpenSaasAU/stack/commit/9024abb407260db26703fe5ad011bba54252be14) Thanks [@borisno2](https://github.com/borisno2)! - Item forms, the singleton editor, relationship tables and preset searches no longer send never-readable fields the session also cannot write to the client, and preset searches drop tokens naming never-readable fields ([#2292](https://github.com/OpenSaasAU/stack/issues/2292)). A never-readable but writable field stays as a write-only control, per the triage decision.
|
|
1047
|
+
|
|
1048
|
+
- [#2356](https://github.com/OpenSaasAU/stack/pull/2356) [`f9b3b4e`](https://github.com/OpenSaasAU/stack/commit/f9b3b4e562bd2716bce4678382e83b7854723d8b) Thanks [@borisno2](https://github.com/borisno2)! - Fix a field with `isFilterable: false` breaking free-text search: it now has no Filter spec, so it is skipped by bare-word search and the Filter builder.
|
|
1049
|
+
|
|
1050
|
+
- [#2239](https://github.com/OpenSaasAU/stack/pull/2239) [`ca51e67`](https://github.com/OpenSaasAU/stack/commit/ca51e67ed52a803cfeac60b2084c5409c7815f5a) Thanks [@borisno2](https://github.com/borisno2)! - An `update`/`delete` operation rule and a field `update` rule that reach for a relation the write did not deliver now deny instead of reading absence as permission ([#2233](https://github.com/OpenSaasAU/stack/issues/2233)). A rule that enumerates `item` (spread, `Object.keys`) on a list with a relationship denies too.
|
|
1051
|
+
|
|
1052
|
+
- [#2360](https://github.com/OpenSaasAU/stack/pull/2360) [`2c93980`](https://github.com/OpenSaasAU/stack/commit/2c93980b42e65a235bb3731aee975ab1329bdfe2) Thanks [@borisno2](https://github.com/borisno2)! - Accept the zoneless ISO string a `Timestamp` column reads back on write-back; document that zoneless columns need a UTC database session.
|
|
1053
|
+
|
|
3
1054
|
## 0.44.0-alpha.5
|
|
4
1055
|
|
|
5
1056
|
### Patch Changes
|