Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: generate prettified code, ignore generated code in watch mode
- Loading branch information
1 parent
ad5ef4f
commit 7887d5d
Showing
12 changed files
with
142 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
import { z } from "stainless"; | ||
import { PostType as __symbol_PostType } from "./create"; | ||
export const Query: z.ZodTypeAny = z.object({ include: z.includes(z.lazy(() => __symbol_PostType), 3).optional() }); | ||
export const Query: z.ZodTypeAny = z.object({ | ||
include: z | ||
.includes( | ||
z.lazy(() => __symbol_PostType), | ||
3 | ||
) | ||
.optional(), | ||
}); | ||
export const Body: z.ZodTypeAny = z.object({ body: z.string() }); | ||
export const PostType: z.ZodTypeAny = z.any(); | ||
export const post__api_posts: any = { query: z.lazy(() => Query), body: z.lazy(() => Body), response: z.lazy(() => __symbol_PostType) }; | ||
export const post__api_posts: any = { | ||
query: z.lazy(() => Query), | ||
body: z.lazy(() => Body), | ||
response: z.lazy(() => __symbol_PostType), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
import { z } from "stainless"; | ||
import { IncludableUserSchema, SelectableUserSchema, IncludableCommentsSchema, IncludableCommentsFieldSchema } from "../../../api/posts/models"; | ||
import { | ||
IncludableUserSchema, | ||
SelectableUserSchema, | ||
IncludableCommentsSchema, | ||
IncludableCommentsFieldSchema, | ||
} from "../../../api/posts/models"; | ||
import { prisma } from "../../../libs/prismadb"; | ||
export const PostType: z.ZodTypeAny = z.object({ id: z.string().uuid(), body: z.string(), createdAt: z.date(), updatedAt: z.date(), userId: z.string().uuid(), likedIds: z.array(z.string().uuid()), image: z.string().nullable().optional(), user: z.lazy(() => IncludableUserSchema), user_fields: z.lazy(() => SelectableUserSchema), comments: z.lazy(() => IncludableCommentsSchema), comments_field: z.lazy(() => IncludableCommentsFieldSchema) }).prismaModel(prisma.post); | ||
export const PostType: z.ZodTypeAny = z | ||
.object({ | ||
id: z.string().uuid(), | ||
body: z.string(), | ||
createdAt: z.date(), | ||
updatedAt: z.date(), | ||
userId: z.string().uuid(), | ||
likedIds: z.array(z.string().uuid()), | ||
image: z.string().nullable().optional(), | ||
user: z.lazy(() => IncludableUserSchema), | ||
user_fields: z.lazy(() => SelectableUserSchema), | ||
comments: z.lazy(() => IncludableCommentsSchema), | ||
comments_field: z.lazy(() => IncludableCommentsFieldSchema), | ||
}) | ||
.prismaModel(prisma.post); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
import { z } from "stainless"; | ||
import { PostType as __symbol_PostType } from "./retrieve"; | ||
import { prisma } from "../../../libs/prismadb"; | ||
export const Query: z.ZodTypeAny = z.object({ include: z.includes(z.lazy(() => __symbol_PostType), 3).optional(), select: z.selects(z.lazy(() => __symbol_PostType), 3).optional() }); | ||
export const Path: z.ZodTypeAny = z.object({ post: z.string().prismaModelLoader(prisma.post) }); | ||
export const Query: z.ZodTypeAny = z.object({ | ||
include: z | ||
.includes( | ||
z.lazy(() => __symbol_PostType), | ||
3 | ||
) | ||
.optional(), | ||
select: z | ||
.selects( | ||
z.lazy(() => __symbol_PostType), | ||
3 | ||
) | ||
.optional(), | ||
}); | ||
export const Path: z.ZodTypeAny = z.object({ | ||
post: z.string().prismaModelLoader(prisma.post), | ||
}); | ||
export const PostType: z.ZodTypeAny = z.any(); | ||
export const get__api_posts_$post$: any = { query: z.lazy(() => Query), path: z.lazy(() => Path), response: z.lazy(() => __symbol_PostType) }; | ||
export const get__api_posts_$post$: any = { | ||
query: z.lazy(() => Query), | ||
path: z.lazy(() => Path), | ||
response: z.lazy(() => __symbol_PostType), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
export const typeSchemas = { "post /api/posts": () => import("./api/posts/create").then(mod => mod.post__api_posts), "get /api/posts/{post}": () => import("./api/posts/retrieve").then(mod => mod.get__api_posts_$post$) }; | ||
export const typeSchemas = { | ||
"post /api/posts": () => | ||
import("./api/posts/create").then((mod) => mod.post__api_posts), | ||
"get /api/posts/{post}": () => | ||
import("./api/posts/retrieve").then((mod) => mod.get__api_posts_$post$), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { promisify } from "util"; | ||
import path from "path"; | ||
import resolve from "resolve"; | ||
import defaultPrettier from "prettier"; | ||
|
||
export async function format( | ||
source: string, | ||
filepath: string | ||
): Promise<string> { | ||
let prettier = defaultPrettier; | ||
|
||
try { | ||
const prettierPath = await promisify<string | undefined>((cb) => | ||
resolve("prettier", { basedir: path.dirname(filepath) }, cb) | ||
)(); | ||
if (prettierPath) { | ||
prettier = await import(prettierPath); | ||
} | ||
} catch (error) {} | ||
|
||
const config = await prettier.resolveConfig(filepath); | ||
return prettier.format(source, config || { filepath }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.