UNPKG

appwrite-utils

Version:

`appwrite-utils` is a comprehensive TypeScript library designed to streamline the development process for Appwrite projects. Version 1.0.0 aligns with the YAML-first architecture of `appwrite-utils-cli`, providing enhanced integration capabilities and rob

64 lines (63 loc) 1.95 kB
import { z } from "zod"; import { importDefSchemas } from "./importDef.js"; import { attributeSchema } from "./attribute.js"; import { indexSchema } from "./index.js"; export const CollectionSchema = z.object({ name: z.string().describe("The name of the collection"), $id: z .string() .optional() .describe("The ID of the collection, auto generated if not provided"), enabled: z .boolean() .default(true) .optional() .describe("Whether the collection is enabled or not"), documentSecurity: z .boolean() .default(false) .optional() .describe("Whether document security is enabled or not"), $createdAt: z.string(), $updatedAt: z.string(), $permissions: z .array(z.object({ permission: z.string(), target: z.string(), })) .optional() .default([]) .describe("The permissions of the collection"), attributes: z .array(attributeSchema) .default([]) .describe("The attributes of the collection"), indexes: z .array(indexSchema) .optional() .default([]) .describe("The indexes of the collection") .transform((value) => { return value.map((index) => { if (index.orders) { return { ...index, orders: index.orders.filter((order) => order !== null), }; } return index; }); }), importDefs: importDefSchemas.optional().default([]), databaseId: z .string() .optional() .describe("The ID of the database the collection belongs to"), }); export const CollectionCreateSchema = CollectionSchema.omit({ $createdAt: true, $updatedAt: true, }); export const CollectionsSchema = z .array(CollectionCreateSchema) .describe("An array of collections to create");