@coveo/thermidor-schema 1.0.0-beta.6 → 1.0.0-beta.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/README.md +32 -5
- package/dist/generated/schemas.js +1 -4
- package/dist/generated/zod3/schemas.d.ts +21498 -0
- package/dist/generated/zod3/schemas.js +1001 -0
- package/dist/zod3/index.d.ts +3 -0
- package/dist/zod3/index.js +5 -0
- package/dist/zod3-compat.d.ts +79 -0
- package/dist/zod3-compat.js +82 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -7,11 +7,7 @@ pnpm add @coveo/thermidor-schema zod
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
import {
|
|
11
|
-
CartStateSchema,
|
|
12
|
-
ProductListStateSchema,
|
|
13
|
-
type CartState,
|
|
14
|
-
} from '@coveo/thermidor-schema';
|
|
10
|
+
import {CartStateSchema, ProductListStateSchema, type CartState} from '@coveo/thermidor-schema';
|
|
15
11
|
|
|
16
12
|
const cartState: CartState = CartStateSchema.parse({items: []});
|
|
17
13
|
const productList = ProductListStateSchema.parse({products: []});
|
|
@@ -19,6 +15,37 @@ const productList = ProductListStateSchema.parse({products: []});
|
|
|
19
15
|
|
|
20
16
|
This ESM-only package currently exports renderer-neutral domain values, controller state, and action payloads. JSON Schema remains the canonical contract.
|
|
21
17
|
|
|
18
|
+
## Choosing a Zod major
|
|
19
|
+
|
|
20
|
+
The default entry point is built with **Zod 4**. A second, pre-built entry point ships the
|
|
21
|
+
same schemas constructed with **Zod 3**:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// Zod 4 (default)
|
|
25
|
+
import {PaginationStateSchema} from '@coveo/thermidor-schema';
|
|
26
|
+
|
|
27
|
+
// Zod 3
|
|
28
|
+
import {PaginationStateSchema} from '@coveo/thermidor-schema/zod3';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Use `./zod3` when something in your dependency tree is pinned to Zod 3 and inspects schema
|
|
32
|
+
internals. The A2-UI renderers are the common case: their binder resolves `{ "path": ... }`
|
|
33
|
+
data bindings by reading Zod 3 internals (`_def.typeName`, `_def.shape()`), which a Zod 4
|
|
34
|
+
schema does not expose — handing it a Zod 4 schema leaves every binding unresolved. The
|
|
35
|
+
`./zod3` build removes the need to rebuild schemas at runtime to work around that.
|
|
36
|
+
|
|
37
|
+
Both entry points are generated from the same canonical JSON Schema documents and expose an
|
|
38
|
+
identical public surface; only the Zod dialect differs. The `zod` peer range
|
|
39
|
+
(`^3.25 || ^4.4.3`) spans both, so install the major that matches the entry point you import
|
|
40
|
+
— a single Zod install is enough, since Zod 4 also ships the classic API under `zod/v3`.
|
|
41
|
+
|
|
42
|
+
> One caveat: in the `./zod3` build the _recursive_ `Product.children` field is typed
|
|
43
|
+
> loosely, because Zod 3 cannot infer through a self-referential schema. Runtime validation
|
|
44
|
+
> is unaffected, and the default Zod 4 build keeps the precise recursive type.
|
|
45
|
+
|
|
46
|
+
`@coveo/thermidor` accepts a contract from either build: its injected-contract seam reads
|
|
47
|
+
only Zod API that behaves identically across both majors.
|
|
48
|
+
|
|
22
49
|
## Status
|
|
23
50
|
|
|
24
51
|
This package is in **beta**: the contract is unstable and may change, including breaking changes, between releases. Beta versions are published to the npm `beta` dist-tag, so install them explicitly:
|
|
@@ -820,10 +820,7 @@ export const CategoryFacetActionSchema = z.union([
|
|
|
820
820
|
]);
|
|
821
821
|
export const CommerceSearchActionSchema = z.union([
|
|
822
822
|
z.object({
|
|
823
|
-
event: z.object({
|
|
824
|
-
name: z.literal('submitQuery'),
|
|
825
|
-
context: z.strictObject({ query: z.string() }),
|
|
826
|
-
}),
|
|
823
|
+
event: z.object({ name: z.literal('submitQuery'), context: z.strictObject({ query: z.string() }) }),
|
|
827
824
|
}),
|
|
828
825
|
z.object({
|
|
829
826
|
event: z.object({
|