From cad7b5b6dc4ebe523b39f0c5a95cdaf4ca83d3f8 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Sun, 22 Sep 2024 23:06:43 -0700 Subject: [PATCH 1/2] docs: v2.6.0 release --- docs/reference/plugins/trpc.md | 10 ++++++++++ docs/reference/plugins/zod.md | 1 + 2 files changed, 11 insertions(+) diff --git a/docs/reference/plugins/trpc.md b/docs/reference/plugins/trpc.md index e8ee4409..21123db6 100644 --- a/docs/reference/plugins/trpc.md +++ b/docs/reference/plugins/trpc.md @@ -101,6 +101,16 @@ export const trpc = createTRPCNext({ }); ``` +:::info +If your generated trpc procedures are installed at a non-top-level path, you can specify the path with the second type parameter of the `createTRPCNext` or `createTRPCReact` function. + +```ts +// if the generated procedures are installed at `/crud` under the router tree +export const trpc = createTRPCNext({ + ... +}); +::: + ### Example Here's an example with a blogging app: diff --git a/docs/reference/plugins/zod.md b/docs/reference/plugins/zod.md index f081cd21..3f2b6419 100644 --- a/docs/reference/plugins/zod.md +++ b/docs/reference/plugins/zod.md @@ -157,6 +157,7 @@ This plugin is built-in to ZenStack and does not need to be installed separately | compile | Boolean | If the generated TS code should be compiled to JS | No | true | | preserveTsFiles | Boolean | If the generated TS files should be preserved (after compiled to JS) | No | true if `compile` is set to false, otherwise false | | noUncheckedInput | Boolean | Disables schema generation for Prisma's ["Unchecked"](https://github.com/prisma/prisma/discussions/10121#discussioncomment-1621254) input types | No | false | +| mode | String | Controls if the generated schemas should reject, strict, or passthrough unknown fields. Possible values: "strict", "strip", "passthrough" | No | "strict" | :::info When the `generateModels` option is used to specify a list of models to generate, the plugin will also recursively traverse and include all models that are referenced by the specified models. This can result in more code being generated than you expect. From 1df1e5f4707a696110fb1f3740d50baafb780800 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Sat, 12 Oct 2024 13:10:18 -0700 Subject: [PATCH 2/2] doc: mark "output" option to-be-duplicated for core plugins --- docs/reference/plugins/enhancer.md | 27 +++++++++++++++------------ docs/reference/plugins/zod.md | 20 +++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/docs/reference/plugins/enhancer.md b/docs/reference/plugins/enhancer.md index ff015b7c..e3bae22f 100644 --- a/docs/reference/plugins/enhancer.md +++ b/docs/reference/plugins/enhancer.md @@ -31,16 +31,19 @@ This plugin is built-in to ZenStack and does not need to be installed separately | Name | Type | Description | Required | Default | | ------ | ------ | ---------------- | -------- | -------------------------- | -| output | String | Output directory (relative to the path of ZModel) | No | node_modules/.zenstack | -| compile | Boolean | If the generated TS code should be compiled to JS | No | true | -| preserveTsFiles | Boolean | If the generated TS files should be preserved (after compiled to JS) | No | true if `compile` is set to false, otherwise false | - -### Example - -```zmodel title='/schema.zmodel' -plugin enhancer { - provider = '@core/enhancer' - output = 'src/lib/zenstack' - compile = false -} +| output | String | Output directory (relative to the path of ZModel). This option will be deprecated in future releases in favor of the "--output" CLI option of `zenstack generate`. | No | node_modules/.zenstack | +| preserveTsFiles | Boolean | If the generated TS files should be preserved (after compiled to JS) | No | false | + +### Custom output directory and compilation options + +You can use the "--output" option of the `zenstack generate` CLI to specify a custom output location for the generated enhancer code: + +```bash +zenstack generate --output src/lib/zenstack +``` + +If you want to have the code generated as TypeScript (instead of compiled to JavaScript), you can add the "--no-compile" option: + +```bash +zenstack generate --no-compile --output src/lib/zenstack ``` diff --git a/docs/reference/plugins/zod.md b/docs/reference/plugins/zod.md index 3f2b6419..39145cdc 100644 --- a/docs/reference/plugins/zod.md +++ b/docs/reference/plugins/zod.md @@ -151,11 +151,11 @@ This plugin is built-in to ZenStack and does not need to be installed separately | Name | Type | Description | Required | Default | | ------ | ------ | ---------------- | -------- | -------------------------- | -| output | String | Output directory (relative to the path of ZModel) | No | node_modules/.zenstack/zod | +| output | String | Output directory (relative to the path of ZModel). This option will be deprecated in future releases in favor of the "--output" CLI option of `zenstack generate`. | No | node_modules/.zenstack/zod | | modelOnly | Boolean | Only generate schemas for the models, but not for the Prisma CRUD input arguments | No | false | | generateModels | String, String[] | Array or comma separated string for the models to generate routers for. | No | All models | | compile | Boolean | If the generated TS code should be compiled to JS | No | true | -| preserveTsFiles | Boolean | If the generated TS files should be preserved (after compiled to JS) | No | true if `compile` is set to false, otherwise false | +| preserveTsFiles | Boolean | If the generated TS files should be preserved (after compiled to JS) | No | false | | noUncheckedInput | Boolean | Disables schema generation for Prisma's ["Unchecked"](https://github.com/prisma/prisma/discussions/10121#discussioncomment-1621254) input types | No | false | | mode | String | Controls if the generated schemas should reject, strict, or passthrough unknown fields. Possible values: "strict", "strip", "passthrough" | No | "strict" | @@ -181,12 +181,14 @@ import { PostCreateSchema } from '@zenstackhq/runtime/zod/models'; PostCreateSchema.parse(data); ``` -You can turn off the `compile` option and use a custom `output` location if you want the generated Zod schema to be compiled along with your own Typescript project: +You can use the "--output" option of the `zenstack generate` CLI to specify a custom output location for the generated Zod schemas: -```zmodel title='/schema.zmodel' -plugin zod { - provider = '@core/zod' - output = 'src/lib/zod' - compile = false -} +```bash +zenstack generate --output src/lib/zenstack +``` + +If you want to have the code generated as TypeScript (instead of compiled to JavaScript), you can add the "--no-compile" option: + +```bash +zenstack generate --no-compile --output src/lib/zenstack ```