@aventara/next 1.0.0-rc.13 → 1.0.0-rc.14
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 +18 -0
- package/README.md +8 -1
- package/dist/hydration-tag.format.d.ts +5 -0
- package/dist/hydration-tag.format.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/value.dehydrator.d.ts +26 -2
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @aventara/next
|
|
2
2
|
|
|
3
|
+
## 1.0.0-rc.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0895a93: `avDehydrate` and `avHydrate` are typed: data handed from a Server Component to a Client Component as props keeps its type, with no cast.
|
|
8
|
+
|
|
9
|
+
- `avDehydrate(data)` (`@aventara/next`) returns an `AvDehydrated<T>` for data of type `T`, and `avHydrate(value)` (`@/aventara/client`) of an `AvDehydrated<T>` returns the `T`, its `Date`, `bigint`, `Uint8Array` and `AvDecimal` values included. Type an SWR `fallback` prop `AvDehydrated<T>` and pass `avHydrate(fallback)` to `SWRConfig` as it is.
|
|
10
|
+
- `AvDehydrated<T>` is new, exported by `@aventara/next` and by the `src/aventara/client.ts` that `aventara-build --client` writes; the two are one type. It is opaque: a plain object, the data itself, or the dehydrated form of another type is a compile error where an `AvDehydrated<T>` is expected.
|
|
11
|
+
- A Resource or enum named `AvDehydrated` or `avHydrate` is now emitted under a renamed identifier (`AvDehydratedModel`, `avHydrateModel`), with a warning, as other names the generated client owns are. Before, `src/aventara/client.ts`'s own declaration hid a Resource type of that name, which could not be imported from it.
|
|
12
|
+
- Read data you dehydrate through `@/aventara/universal`: `@/aventara/server` types a decimal as core's `AvDecimal`, while `avHydrate` revives it as the browser client's.
|
|
13
|
+
- Pass `avHydrate(fallback)` to `SWRConfig`, never the dehydrated value itself: SWR's `fallback` is typed `any`, so the compiler cannot catch it.
|
|
14
|
+
- `avHydrate` still takes `unknown` and returns `unknown`; `avDehydrate` of an `unknown` value returns an `AvDehydrated<unknown>`. `serializeData: avDehydrate` and `deserializeData: avHydrate` in TanStack Query are written as before.
|
|
15
|
+
- The agent skills show the SWR props pattern typed, with no cast. The frontend skill's refresh line no longer names `npx`, and says a file you edited is kept with a warning naming it, and replaced with `--force`.
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [1c5eaa3]
|
|
18
|
+
- @aventara/core@1.0.0-rc.14
|
|
19
|
+
- @aventara/mcp@1.0.0-rc.14
|
|
20
|
+
|
|
3
21
|
## 1.0.0-rc.13
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -282,7 +282,14 @@ export const Providers = ({ children }: { children: React.ReactNode }) => (
|
|
|
282
282
|
```
|
|
283
283
|
|
|
284
284
|
With SWR, pass `avDehydrate({ [key]: data })` from the Server Component and `avHydrate(fallback)` to `SWRConfig`'s
|
|
285
|
-
`fallback` in the Client Component.
|
|
285
|
+
`fallback` in the Client Component. Type that prop `AvDehydrated<T>` (from `@/aventara/client`; this package exports the
|
|
286
|
+
same type): `avDehydrate` of a `T` is an `AvDehydrated<T>` and `avHydrate` of one is the `T` again, so no cast is
|
|
287
|
+
written, and a plain object or data of another type is a compile error on the prop. Pass `avHydrate(fallback)` to
|
|
288
|
+
`SWRConfig`, never `fallback` itself: SWR's `fallback` is typed `any`, so the compiler cannot catch it. `avHydrate` also
|
|
289
|
+
takes `unknown` and answers `unknown` (TanStack Query's `deserializeData`); `avDehydrate` of an `unknown` value is an
|
|
290
|
+
`AvDehydrated<unknown>`, and it is TanStack Query's `serializeData` as it is. Read the data you dehydrate through
|
|
291
|
+
`@/aventara/universal`: `@/aventara/server`'s `avClient` types a decimal as core's `AvDecimal`, while `avHydrate` revives
|
|
292
|
+
it as the browser client's.
|
|
286
293
|
|
|
287
294
|
Importing `@/aventara/client` instead of `@/aventara/universal` in shared code opts out of running on the server: its
|
|
288
295
|
calls are refused there.
|
|
@@ -8,4 +8,9 @@ export declare const HYDRATION_FORMAT: {
|
|
|
8
8
|
readonly objectTag: "object";
|
|
9
9
|
/** The scalars a value is tagged as: those whose runtime values JSON does not carry. */
|
|
10
10
|
readonly scalarTags: readonly ["bigint", "bytes", "datetime", "decimal"];
|
|
11
|
+
/**
|
|
12
|
+
* The key of `AvDehydrated<T>`'s brand: a property of its type only, never
|
|
13
|
+
* of the value, holding the `T` the value was dehydrated from.
|
|
14
|
+
*/
|
|
15
|
+
readonly typeKey: "~avDehydrated";
|
|
11
16
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import "server-only";
|
|
|
2
2
|
export { Aventara } from "./aventara.factory.js";
|
|
3
3
|
export type { AvNextHandlers, AvNextStateContext, } from "./route-handlers.factory.js";
|
|
4
4
|
export type { AvNextAppTransaction, AvNextClientTransaction, } from "./server-operations.factory.js";
|
|
5
|
-
export { avDehydrate } from "./value.dehydrator.js";
|
|
5
|
+
export { type AvDehydrated, avDehydrate } from "./value.dehydrator.js";
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data of type `T` as `avDehydrate` sends it from the server: opaque, read
|
|
3
|
+
* back as the `T` only by `avHydrate` from `@/aventara/client`. Type a Client
|
|
4
|
+
* Component's prop with it to hand it server data with no cast.
|
|
5
|
+
*
|
|
6
|
+
* Pass `avHydrate(fallback)` on, never the dehydrated value itself: a
|
|
7
|
+
* receiver typed `any`, such as SWR's `fallback`, takes either, so the type
|
|
8
|
+
* cannot catch it.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* export function Drafts({ fallback }: { readonly fallback: AvDehydrated<{ drafts: Post[] }> }) {
|
|
12
|
+
* return <SWRConfig value={{ fallback: avHydrate(fallback) }}>…</SWRConfig>;
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export type AvDehydrated<T> = {
|
|
16
|
+
/** The type the value was dehydrated from: the type's brand, no member of the value. */
|
|
17
|
+
readonly "~avDehydrated": T;
|
|
18
|
+
};
|
|
1
19
|
/**
|
|
2
20
|
* Makes data an Aventara client answered safe to pass from the server to the
|
|
3
21
|
* browser: each `Date`, `bigint`, `Uint8Array` and decimal becomes a tagged
|
|
@@ -6,9 +24,15 @@
|
|
|
6
24
|
* plain objects are copied with their members dehydrated; any other value is
|
|
7
25
|
* returned as it is.
|
|
8
26
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
27
|
+
* Data of type `T` dehydrates to an `AvDehydrated<T>`, which `avHydrate`
|
|
28
|
+
* reads back as the `T`: pass it to a Client Component as a prop typed
|
|
29
|
+
* `AvDehydrated<T>`, such as an SWR `fallback`, and pass `avHydrate(fallback)`
|
|
30
|
+
* on in the browser, never the dehydrated value itself (SWR's `fallback` is
|
|
31
|
+
* typed `any`, so the type cannot catch it). Give it to TanStack Query as
|
|
32
|
+
* `dehydrate(queryClient, { serializeData: avDehydrate })`.
|
|
11
33
|
*
|
|
12
34
|
* @throws TypeError for a `Date` with no wire form (invalid, or a year past four digits).
|
|
13
35
|
*/
|
|
36
|
+
export declare function avDehydrate<T>(data: T): AvDehydrated<T>;
|
|
37
|
+
/** As a function typed `(data: unknown) => unknown`, such as TanStack Query's `serializeData`; a call resolves to the generic signature. */
|
|
14
38
|
export declare function avDehydrate(data: unknown): unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aventara/next",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.14",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "Next.js App Router host integration for Aventara.",
|
|
6
6
|
"type": "module",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"CHANGELOG.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@aventara/core": "1.0.0-rc.
|
|
25
|
+
"@aventara/core": "1.0.0-rc.14",
|
|
26
26
|
"server-only": "0.0.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@aventara/mcp": "1.0.0-rc.
|
|
29
|
+
"@aventara/mcp": "1.0.0-rc.14",
|
|
30
30
|
"next": ">=16.4 <17",
|
|
31
31
|
"react": "^19.0.0"
|
|
32
32
|
},
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@aventara/build": "1.0.0-rc.
|
|
57
|
-
"@aventara/client": "1.0.0-rc.
|
|
58
|
-
"@aventara/mcp": "1.0.0-rc.
|
|
59
|
-
"@aventara/testing": "1.0.0-rc.
|
|
56
|
+
"@aventara/build": "1.0.0-rc.14",
|
|
57
|
+
"@aventara/client": "1.0.0-rc.14",
|
|
58
|
+
"@aventara/mcp": "1.0.0-rc.14",
|
|
59
|
+
"@aventara/testing": "1.0.0-rc.14",
|
|
60
60
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
61
61
|
"@tanstack/react-query": "5.104.2",
|
|
62
62
|
"@types/react": "19.3.0",
|