Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .changeset/needs-declared-dependencies.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/swift-moons-gather.md

This file was deleted.

2 changes: 2 additions & 0 deletions packages/auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @opensaas/stack-auth

## 0.36.0

## 0.35.0

## 0.34.0
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-auth",
"version": "0.35.0",
"version": "0.36.0",
"description": "Better-auth integration for OpenSaas Stack",
"type": "module",
"main": "./dist/index.js",
Expand Down
37 changes: 37 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# @opensaas/stack-cli

## 0.36.0

### Minor Changes

- [#857](https://github.com/OpenSaasAU/stack/pull/857) [`cdca174`](https://github.com/OpenSaasAU/stack/commit/cdca17444a5259cd0d3d8604a90a2cea4566cda2) Thanks [@borisno2](https://github.com/borisno2)! - Add `needs` to the base field config: a computed field can declare the immediate relations its `resolveOutput` hook depends on, so the read fetches exactly those — without widening what the caller receives (ADR-0025).

Since ADR-0024, a bare read (no caller `include`) returns a row's own columns only, so a virtual field reading `item.someRelation` silently computed over `undefined` unless a caller happened to include it. `needs` fixes that:

```typescript
Order: list({
fields: {
lineItems: relationship({ ref: 'LineItem.order', many: true }),
total: virtual({
type: 'number',
needs: ['lineItems'],
hooks: {
resolveOutput: ({ item }) =>
item.lineItems.reduce((sum, li) => sum + li.price * li.quantity, 0),
},
}),
},
})
```

The declared relation is fetched wherever the field is computed — at the root of a read and at every nested level — and is scoped through the Access Filter exactly like a caller-named relation: a dependency the session can't query is not fetched, and the hook sees nothing in its place. A field always computes on whatever it can see, so a partially-denied dependency still produces a value rather than being withheld. The relation itself is stripped from the result unless the caller named it too, for both `include` reads and fragment `query` reads.

`needs` is available on every field type, not only `virtual()`. `opensaas generate` now also validates every `needs` declaration: an entry naming a non-relationship or non-existent field, or a declaration closure that can't fit within the read-include depth cap from any starting point, fails generation with a message naming the offending field/chain rather than silently truncating at runtime.

See `docs/adr/0025-a-computed-field-declares-the-relations-it-needs.md`.

### Patch Changes

- [#859](https://github.com/OpenSaasAU/stack/pull/859) [`ebb4cd3`](https://github.com/OpenSaasAU/stack/commit/ebb4cd3515ff40f960f888e7b4147d1d089a0966) Thanks [@borisno2](https://github.com/borisno2)! - Fix `isIndexed: true` on `text`, `decimal` and `calendarDay` emitting an invalid inline `@index` attribute, producing a schema Prisma rejects with "Attribute not known: @index".
Non-unique indexes are now emitted as block-level `@@index([field])`; `isIndexed: 'unique'` is unchanged.
- Updated dependencies [[`cdca174`](https://github.com/OpenSaasAU/stack/commit/cdca17444a5259cd0d3d8604a90a2cea4566cda2), [`ebb4cd3`](https://github.com/OpenSaasAU/stack/commit/ebb4cd3515ff40f960f888e7b4147d1d089a0966)]:
- @opensaas/stack-core@0.36.0

## 0.35.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-cli",
"version": "0.35.0",
"version": "0.36.0",
"description": "CLI tools for OpenSaas Stack",
"type": "module",
"main": "./dist/index.js",
Expand Down
35 changes: 35 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# @opensaas/stack-core

## 0.36.0

### Minor Changes

- [#857](https://github.com/OpenSaasAU/stack/pull/857) [`cdca174`](https://github.com/OpenSaasAU/stack/commit/cdca17444a5259cd0d3d8604a90a2cea4566cda2) Thanks [@borisno2](https://github.com/borisno2)! - Add `needs` to the base field config: a computed field can declare the immediate relations its `resolveOutput` hook depends on, so the read fetches exactly those — without widening what the caller receives (ADR-0025).

Since ADR-0024, a bare read (no caller `include`) returns a row's own columns only, so a virtual field reading `item.someRelation` silently computed over `undefined` unless a caller happened to include it. `needs` fixes that:

```typescript
Order: list({
fields: {
lineItems: relationship({ ref: 'LineItem.order', many: true }),
total: virtual({
type: 'number',
needs: ['lineItems'],
hooks: {
resolveOutput: ({ item }) =>
item.lineItems.reduce((sum, li) => sum + li.price * li.quantity, 0),
},
}),
},
})
```

The declared relation is fetched wherever the field is computed — at the root of a read and at every nested level — and is scoped through the Access Filter exactly like a caller-named relation: a dependency the session can't query is not fetched, and the hook sees nothing in its place. A field always computes on whatever it can see, so a partially-denied dependency still produces a value rather than being withheld. The relation itself is stripped from the result unless the caller named it too, for both `include` reads and fragment `query` reads.

`needs` is available on every field type, not only `virtual()`. `opensaas generate` now also validates every `needs` declaration: an entry naming a non-relationship or non-existent field, or a declaration closure that can't fit within the read-include depth cap from any starting point, fails generation with a message naming the offending field/chain rather than silently truncating at runtime.

See `docs/adr/0025-a-computed-field-declares-the-relations-it-needs.md`.

### Patch Changes

- [#859](https://github.com/OpenSaasAU/stack/pull/859) [`ebb4cd3`](https://github.com/OpenSaasAU/stack/commit/ebb4cd3515ff40f960f888e7b4147d1d089a0966) Thanks [@borisno2](https://github.com/borisno2)! - Fix `isIndexed: true` on `text`, `decimal` and `calendarDay` emitting an invalid inline `@index` attribute, producing a schema Prisma rejects with "Attribute not known: @index".
Non-unique indexes are now emitted as block-level `@@index([field])`; `isIndexed: 'unique'` is unchanged.

## 0.35.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-core",
"version": "0.35.0",
"version": "0.36.0",
"description": "Core stack for OpenSaas - schema definition, access control, and runtime utilities",
"type": "module",
"main": "./dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/rag/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @opensaas/stack-rag

## 0.36.0

## 0.35.0

## 0.34.0
Expand Down
2 changes: 1 addition & 1 deletion packages/rag/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-rag",
"version": "0.35.0",
"version": "0.36.0",
"description": "RAG and AI embeddings integration for OpenSaas Stack",
"type": "module",
"main": "./dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/storage-s3/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @opensaas/stack-storage-s3

## 0.36.0

## 0.35.0

## 0.34.0
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-s3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-storage-s3",
"version": "0.35.0",
"version": "0.36.0",
"description": "AWS S3 storage provider for OpenSaas Stack file uploads",
"type": "module",
"exports": {
Expand Down
2 changes: 2 additions & 0 deletions packages/storage-vercel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @opensaas/stack-storage-vercel

## 0.36.0

## 0.35.0

## 0.34.0
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-vercel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-storage-vercel",
"version": "0.35.0",
"version": "0.36.0",
"description": "Vercel Blob storage provider for OpenSaas Stack file uploads",
"type": "module",
"exports": {
Expand Down
2 changes: 2 additions & 0 deletions packages/storage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @opensaas/stack-storage

## 0.36.0

## 0.35.0

## 0.34.0
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-storage",
"version": "0.35.0",
"version": "0.36.0",
"description": "File and image upload field types with pluggable storage providers for OpenSaas Stack",
"type": "module",
"exports": {
Expand Down
2 changes: 2 additions & 0 deletions packages/tiptap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @opensaas/stack-tiptap

## 0.36.0

## 0.35.0

## 0.34.0
Expand Down
2 changes: 1 addition & 1 deletion packages/tiptap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-tiptap",
"version": "0.35.0",
"version": "0.36.0",
"description": "Tiptap rich text editor integration for OpenSaas Stack",
"type": "module",
"main": "./dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @opensaas/stack-ui

## 0.36.0

## 0.35.0

## 0.34.0
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensaas/stack-ui",
"version": "0.35.0",
"version": "0.36.0",
"description": "Composable React UI components for OpenSaas Stack",
"type": "module",
"main": "./dist/index.js",
Expand Down
Loading