Skip to content
Closed
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
6 changes: 6 additions & 0 deletions packages/runtime/src/utils/type-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export type JsonValue = string | number | boolean | null | JsonObject | JsonArra
export type JsonObject = { [key: string]: JsonValue };
export type JsonArray = Array<JsonValue>;

/**
* Returns an object containing the provided code string as the `code` property.
*
* @param code - The string to assign to the `code` property
* @returns An object with a single `code` property set to the input string
*/
export function call(code: string) {
return { code };
}
Expand Down
10 changes: 10 additions & 0 deletions packages/runtime/test/typing/verify-typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ async function main() {
enums();
}

/**
* Demonstrates various user query operations using the ZenStackClient, including filtering, selecting, omitting, and including nested relations.
*
* Executes and logs results for single and multiple user queries, nested relation selections, computed fields, pagination, ordering, distinct, and cursor-based queries. Also verifies TypeScript type safety for invalid query combinations and field access.
*/
async function find() {
const user1 = await client.user.findFirst({
where: {
Expand Down Expand Up @@ -188,6 +193,11 @@ async function find() {
console.log(u.posts[0]?.author?.email);
}

/**
* Demonstrates various create operations for users, profiles, regions, posts, and tags using the ZenStackClient.
*
* This includes single and batch creation, nested relation creation, compound key connections, and many-to-many associations. Also tests error scenarios for required fields and invalid relation usage.
*/
async function create() {
await client.user.create({
// @ts-expect-error email is required
Expand Down