appwrite-utils
Version:
`appwrite-utils` is a comprehensive TypeScript library designed to streamline the development process for Appwrite projects. It provides a suite of utilities and helper functions that facilitate data manipulation, schema management, and seamless integrati
51 lines (50 loc) • 1.6 kB
JavaScript
import { z } from "zod";
import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
extendZodWithOpenApi(z);
export const AuthUserSchema = z
.object({
$id: z
.string()
.openapi({ description: "The unique identifier for the user" }),
$createdAt: z
.string()
.optional()
.openapi({ description: "Creation timestamp" }),
$updatedAt: z
.string()
.optional()
.openapi({ description: "Update timestamp" }),
name: z.string().nullish().openapi({ description: "The user's name" }),
email: z
.string()
.nullish()
.openapi({ description: "The user's email address" }),
phone: z
.string()
.nullish()
.openapi({ description: "The user's phone number" }),
prefs: z.record(z.string()).optional().default({}).openapi({
description: "User preferences, key-value pairs up to 16KB in size",
}),
labels: z
.array(z.string())
.optional()
.default([])
.openapi({ description: "User labels" }),
password: z.string().optional().openapi({
description: "Optional password, also used for the user to update their own account",
}),
})
.openapi("AuthUser");
export const AuthUserCreateSchema = AuthUserSchema.omit({
$id: true,
})
.extend({
userId: z.string().optional().openapi({
description: "Optional user ID, auto generated if not provided",
}),
password: z.string().optional().openapi({
description: "Optional password",
}),
})
.openapi("AuthUserCreate");