Skip to content
Merged
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
59 changes: 8 additions & 51 deletions samples/sveltekit/src/zenstack/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,18 @@
/* eslint-disable */

import { type SchemaType as $Schema } from "./schema-lite";
import type {
FindManyArgs as $FindManyArgs,
FindUniqueArgs as $FindUniqueArgs,
FindFirstArgs as $FindFirstArgs,
ExistsArgs as $ExistsArgs,
CreateArgs as $CreateArgs,
CreateManyArgs as $CreateManyArgs,
CreateManyAndReturnArgs as $CreateManyAndReturnArgs,
UpdateArgs as $UpdateArgs,
UpdateManyArgs as $UpdateManyArgs,
UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs,
UpsertArgs as $UpsertArgs,
DeleteArgs as $DeleteArgs,
DeleteManyArgs as $DeleteManyArgs,
CountArgs as $CountArgs,
AggregateArgs as $AggregateArgs,
GroupByArgs as $GroupByArgs,
WhereInput as $WhereInput,
SelectInput as $SelectInput,
IncludeInput as $IncludeInput,
OmitInput as $OmitInput,
QueryOptions as $QueryOptions,
} from "@zenstackhq/orm";
import type {
SimplifiedPlainResult as $Result,
SelectIncludeOmit as $SelectIncludeOmit,
} from "@zenstackhq/orm";
import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, ExistsArgs as $ExistsArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, QueryOptions as $QueryOptions } from "@zenstackhq/orm";
import type { SimplifiedPlainResult as $Result, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm";
export type UserFindManyArgs = $FindManyArgs<$Schema, "User">;
export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">;
export type UserFindFirstArgs = $FindFirstArgs<$Schema, "User">;
export type UserExistsArgs = $ExistsArgs<$Schema, "User">;
export type UserCreateArgs = $CreateArgs<$Schema, "User">;
export type UserCreateManyArgs = $CreateManyArgs<$Schema, "User">;
export type UserCreateManyAndReturnArgs = $CreateManyAndReturnArgs<
$Schema,
"User"
>;
export type UserCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "User">;
export type UserUpdateArgs = $UpdateArgs<$Schema, "User">;
export type UserUpdateManyArgs = $UpdateManyArgs<$Schema, "User">;
export type UserUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<
$Schema,
"User"
>;
export type UserUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "User">;
export type UserUpsertArgs = $UpsertArgs<$Schema, "User">;
export type UserDeleteArgs = $DeleteArgs<$Schema, "User">;
export type UserDeleteManyArgs = $DeleteManyArgs<$Schema, "User">;
Expand All @@ -59,26 +28,17 @@ export type UserWhereInput = $WhereInput<$Schema, "User">;
export type UserSelect = $SelectInput<$Schema, "User">;
export type UserInclude = $IncludeInput<$Schema, "User">;
export type UserOmit = $OmitInput<$Schema, "User">;
export type UserGetPayload<
Args extends $SelectIncludeOmit<$Schema, "User", true>,
Options extends $QueryOptions<$Schema> = $QueryOptions<$Schema>,
> = $Result<$Schema, "User", Args, Options>;
export type UserGetPayload<Args extends $SelectIncludeOmit<$Schema, "User", true>, Options extends $QueryOptions<$Schema> = $QueryOptions<$Schema>> = $Result<$Schema, "User", Args, Options>;
export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">;
export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">;
export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">;
export type PostExistsArgs = $ExistsArgs<$Schema, "Post">;
export type PostCreateArgs = $CreateArgs<$Schema, "Post">;
export type PostCreateManyArgs = $CreateManyArgs<$Schema, "Post">;
export type PostCreateManyAndReturnArgs = $CreateManyAndReturnArgs<
$Schema,
"Post"
>;
export type PostCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Post">;
export type PostUpdateArgs = $UpdateArgs<$Schema, "Post">;
export type PostUpdateManyArgs = $UpdateManyArgs<$Schema, "Post">;
export type PostUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<
$Schema,
"Post"
>;
export type PostUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Post">;
export type PostUpsertArgs = $UpsertArgs<$Schema, "Post">;
export type PostDeleteArgs = $DeleteArgs<$Schema, "Post">;
export type PostDeleteManyArgs = $DeleteManyArgs<$Schema, "Post">;
Expand All @@ -89,7 +49,4 @@ export type PostWhereInput = $WhereInput<$Schema, "Post">;
export type PostSelect = $SelectInput<$Schema, "Post">;
export type PostInclude = $IncludeInput<$Schema, "Post">;
export type PostOmit = $OmitInput<$Schema, "Post">;
export type PostGetPayload<
Args extends $SelectIncludeOmit<$Schema, "Post", true>,
Options extends $QueryOptions<$Schema> = $QueryOptions<$Schema>,
> = $Result<$Schema, "Post", Args, Options>;
export type PostGetPayload<Args extends $SelectIncludeOmit<$Schema, "Post", true>, Options extends $QueryOptions<$Schema> = $QueryOptions<$Schema>> = $Result<$Schema, "Post", Args, Options>;
218 changes: 107 additions & 111 deletions samples/sveltekit/src/zenstack/schema-lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,118 +7,114 @@

import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema";
export class SchemaType implements SchemaDef {
provider = {
type: "sqlite",
} as const;
models = {
User: {
name: "User",
fields: {
id: {
name: "id",
type: "String",
id: true,
default: ExpressionUtils.call("cuid"),
provider = {
type: "sqlite"
} as const;
models = {
User: {
name: "User",
fields: {
id: {
name: "id",
type: "String",
id: true,
default: ExpressionUtils.call("cuid")
},
createdAt: {
name: "createdAt",
type: "DateTime",
default: ExpressionUtils.call("now")
},
updatedAt: {
name: "updatedAt",
type: "DateTime",
updatedAt: true
},
email: {
name: "email",
type: "String",
unique: true
},
name: {
name: "name",
type: "String",
optional: true
},
posts: {
name: "posts",
type: "Post",
array: true,
relation: { opposite: "author" }
}
},
idFields: ["id"],
uniqueFields: {
id: { type: "String" },
email: { type: "String" }
}
},
createdAt: {
name: "createdAt",
type: "DateTime",
default: ExpressionUtils.call("now"),
Post: {
name: "Post",
fields: {
id: {
name: "id",
type: "String",
id: true,
default: ExpressionUtils.call("cuid")
},
createdAt: {
name: "createdAt",
type: "DateTime",
default: ExpressionUtils.call("now")
},
updatedAt: {
name: "updatedAt",
type: "DateTime",
updatedAt: true
},
title: {
name: "title",
type: "String"
},
published: {
name: "published",
type: "Boolean",
default: false
},
author: {
name: "author",
type: "User",
relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" }
},
authorId: {
name: "authorId",
type: "String",
foreignKeyFor: [
"author"
]
}
},
idFields: ["id"],
uniqueFields: {
id: { type: "String" }
}
}
} as const;
authType = "User" as const;
procedures = {
signUp: {
params: {
email: { name: "email", type: "String" }
},
returnType: "User",
mutation: true
},
updatedAt: {
name: "updatedAt",
type: "DateTime",
updatedAt: true,
},
email: {
name: "email",
type: "String",
unique: true,
},
name: {
name: "name",
type: "String",
optional: true,
},
posts: {
name: "posts",
type: "Post",
array: true,
relation: { opposite: "author" },
},
},
idFields: ["id"],
uniqueFields: {
id: { type: "String" },
email: { type: "String" },
},
},
Post: {
name: "Post",
fields: {
id: {
name: "id",
type: "String",
id: true,
default: ExpressionUtils.call("cuid"),
},
createdAt: {
name: "createdAt",
type: "DateTime",
default: ExpressionUtils.call("now"),
},
updatedAt: {
name: "updatedAt",
type: "DateTime",
updatedAt: true,
},
title: {
name: "title",
type: "String",
},
published: {
name: "published",
type: "Boolean",
default: false,
},
author: {
name: "author",
type: "User",
relation: {
opposite: "posts",
fields: ["authorId"],
references: ["id"],
onUpdate: "Cascade",
onDelete: "Cascade",
},
},
authorId: {
name: "authorId",
type: "String",
foreignKeyFor: ["author"],
},
},
idFields: ["id"],
uniqueFields: {
id: { type: "String" },
},
},
} as const;
authType = "User" as const;
procedures = {
signUp: {
params: {
email: { name: "email", type: "String" },
},
returnType: "User",
mutation: true,
},
listPublicPosts: {
params: {},
returnType: "Post",
returnArray: true,
},
} as const;
plugins = {};
listPublicPosts: {
params: {},
returnType: "Post",
returnArray: true
}
} as const;
plugins = {};
}
export const schema = new SchemaType();
Loading
Loading