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
61 lines (56 loc) • 1.69 kB
text/typescript
import { z } from "zod";
import {
stringAttributeSchema,
type StringAttribute,
} from "../schemas/stringAttribute.js";
import {
integerAttributeSchema,
type IntegerAttribute,
} from "../schemas/integerAttribute.js";
import {
doubleAttributeSchema,
floatAttributeSchema,
type DoubleAttribute,
type FloatAttribute,
} from "../schemas/doubleAttribute.js";
import {
booleanAttributeSchema,
type BooleanAttribute,
} from "../schemas/booleanAttribute.js";
import {
datetimeAttributeSchema,
type DatetimeAttribute,
} from "../schemas/datetimeAttribute.js";
import {
emailAttributeSchema,
type EmailAttribute,
} from "../schemas/emailAttribute.js";
import { ipAttributeSchema, type IpAttribute } from "../schemas/ipAttribute.js";
import {
urlAttributeSchema,
type UrlAttribute,
} from "../schemas/urlAttribute.js";
import {
enumAttributeSchema,
type EnumAttribute,
} from "../schemas/enumAttribute.js";
import {
relationshipAttributeSchema,
type RelationshipAttribute,
} from "../schemas/relationshipAttribute.js";
export const attributeSchema = z.discriminatedUnion("type", [
stringAttributeSchema,
integerAttributeSchema,
doubleAttributeSchema, // Preferred double type
floatAttributeSchema, // Backwards compatibility for float type
booleanAttributeSchema,
datetimeAttributeSchema,
emailAttributeSchema,
ipAttributeSchema,
urlAttributeSchema,
enumAttributeSchema,
relationshipAttributeSchema,
]);
export type Attribute = z.infer<typeof attributeSchema>;
export const attributesSchema = z.array(attributeSchema);
export type Attributes = z.infer<typeof attributesSchema>;