pocketbase-zod-schema 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/cli/index.cjs +3383 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +30 -0
- package/dist/cli/index.d.ts +30 -0
- package/dist/cli/index.js +3331 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/migrate.cjs +3380 -0
- package/dist/cli/migrate.cjs.map +1 -0
- package/dist/cli/migrate.d.cts +1 -0
- package/dist/cli/migrate.d.ts +1 -0
- package/dist/cli/migrate.js +3353 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli/utils/index.cjs +540 -0
- package/dist/cli/utils/index.cjs.map +1 -0
- package/dist/cli/utils/index.d.cts +232 -0
- package/dist/cli/utils/index.d.ts +232 -0
- package/dist/cli/utils/index.js +487 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/enums.cjs +19 -0
- package/dist/enums.cjs.map +1 -0
- package/dist/enums.d.cts +6 -0
- package/dist/enums.d.ts +6 -0
- package/dist/enums.js +17 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.cjs +4900 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +4726 -0
- package/dist/index.js.map +1 -0
- package/dist/migration/analyzer.cjs +1267 -0
- package/dist/migration/analyzer.cjs.map +1 -0
- package/dist/migration/analyzer.d.cts +186 -0
- package/dist/migration/analyzer.d.ts +186 -0
- package/dist/migration/analyzer.js +1232 -0
- package/dist/migration/analyzer.js.map +1 -0
- package/dist/migration/diff.cjs +557 -0
- package/dist/migration/diff.cjs.map +1 -0
- package/dist/migration/diff.d.cts +291 -0
- package/dist/migration/diff.d.ts +291 -0
- package/dist/migration/diff.js +534 -0
- package/dist/migration/diff.js.map +1 -0
- package/dist/migration/generator.cjs +778 -0
- package/dist/migration/generator.cjs.map +1 -0
- package/dist/migration/generator.d.cts +225 -0
- package/dist/migration/generator.d.ts +225 -0
- package/dist/migration/generator.js +737 -0
- package/dist/migration/generator.js.map +1 -0
- package/dist/migration/index.cjs +3390 -0
- package/dist/migration/index.cjs.map +1 -0
- package/dist/migration/index.d.cts +103 -0
- package/dist/migration/index.d.ts +103 -0
- package/dist/migration/index.js +3265 -0
- package/dist/migration/index.js.map +1 -0
- package/dist/migration/snapshot.cjs +609 -0
- package/dist/migration/snapshot.cjs.map +1 -0
- package/dist/migration/snapshot.d.cts +167 -0
- package/dist/migration/snapshot.d.ts +167 -0
- package/dist/migration/snapshot.js +575 -0
- package/dist/migration/snapshot.js.map +1 -0
- package/dist/migration/utils/index.cjs +672 -0
- package/dist/migration/utils/index.cjs.map +1 -0
- package/dist/migration/utils/index.d.cts +207 -0
- package/dist/migration/utils/index.d.ts +207 -0
- package/dist/migration/utils/index.js +641 -0
- package/dist/migration/utils/index.js.map +1 -0
- package/dist/mutator.cjs +427 -0
- package/dist/mutator.cjs.map +1 -0
- package/dist/mutator.d.cts +190 -0
- package/dist/mutator.d.ts +190 -0
- package/dist/mutator.js +425 -0
- package/dist/mutator.js.map +1 -0
- package/dist/permissions-ZHafVSIx.d.cts +71 -0
- package/dist/permissions-ZHafVSIx.d.ts +71 -0
- package/dist/schema.cjs +430 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +316 -0
- package/dist/schema.d.ts +316 -0
- package/dist/schema.js +396 -0
- package/dist/schema.js.map +1 -0
- package/dist/types-BbTgmg6H.d.cts +91 -0
- package/dist/types-z1Dkjg8m.d.ts +91 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +14 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/user-jS1aYoeD.d.cts +123 -0
- package/dist/user-jS1aYoeD.d.ts +123 -0
- package/package.json +165 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/migration/utils/pluralize.ts","../../../src/migration/utils/relation-detector.ts","../../../src/migration/utils/type-mapper.ts"],"names":["z"],"mappings":";;;AAQA,IAAM,aAAA,GAAwC;AAAA;AAAA,EAE5C,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,UAAA;AAAA,EACP,KAAA,EAAO,UAAA;AAAA,EACP,GAAA,EAAK,KAAA;AAAA,EACL,GAAA,EAAK,KAAA;AAAA,EACL,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,MAAA;AAAA,EACN,KAAA,EAAO,MAAA;AAAA,EACP,KAAA,EAAO,MAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,YAAA;AAAA,EACV,OAAA,EAAS,WAAA;AAAA,EACT,OAAA,EAAS,WAAA;AAAA,EACT,IAAA,EAAM,QAAA;AAAA,EACN,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,WAAA;AAAA,EACT,OAAA,EAAS,WAAA;AAAA,EACT,KAAA,EAAO,SAAA;AAAA,EACP,KAAA,EAAO,SAAA;AAAA,EACP,KAAA,EAAO,SAAA;AAAA,EACP,KAAA,EAAO,SAAA;AAAA,EACP,MAAA,EAAQ,UAAA;AAAA,EACR,MAAA,EAAQ,UAAA;AAAA,EACR,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,YAAA;AAAA;AAAA,EAGV,IAAA,EAAM,OAAA;AAAA,EACN,IAAA,EA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EAAA,MAAM,IAAA,GAAO,sBAAA,CAAuB,OAAA,EAAS,SAAS,CAAA;AACtD,EAAA,MAAM,UAAA,GAAa,YAAY,OAAO,CAAA;AACtC,EAAA,MAAM,OAAA,GAAU,iCAAiC,OAAO,CAAA;AAExD,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * Collection name pluralization utilities\n */\n\n/**\n * Special case pluralization rules\n * Maps singular forms to their plural forms\n */\nconst SPECIAL_CASES: Record<string, string> = {\n // Common irregular plurals\n person: \"people\",\n Person: \"People\",\n child: \"children\",\n Child: \"Children\",\n man: \"men\",\n Man: \"Men\",\n woman: \"women\",\n Woman: \"Women\",\n tooth: \"teeth\",\n Tooth: \"Teeth\",\n foot: \"feet\",\n Foot: \"Feet\",\n mouse: \"mice\",\n Mouse: \"Mice\",\n goose: \"geese\",\n Goose: \"Geese\",\n\n // Words ending in -y\n category: \"categories\",\n Category: \"Categories\",\n company: \"companies\",\n Company: \"Companies\",\n city: \"cities\",\n City: \"Cities\",\n country: \"countries\",\n Country: \"Countries\",\n story: \"stories\",\n Story: \"Stories\",\n party: \"parties\",\n Party: \"Parties\",\n family: \"families\",\n Family: \"Families\",\n activity: \"activities\",\n Activity: \"Activities\",\n priority: \"priorities\",\n Priority: \"Priorities\",\n\n // Words ending in -f or -fe\n life: \"lives\",\n Life: \"Lives\",\n wife: \"wives\",\n Wife: \"Wives\",\n knife: \"knives\",\n Knife: \"Knives\",\n leaf: \"leaves\",\n Leaf: \"Leaves\",\n shelf: \"shelves\",\n Shelf: \"Shelves\",\n half: \"halves\",\n Half: \"Halves\",\n\n // Words ending in -is\n analysis: \"analyses\",\n Analysis: \"Analyses\",\n basis: \"bases\",\n Basis: \"Bases\",\n crisis: \"crises\",\n Crisis: \"Crises\",\n thesis: \"theses\",\n Thesis: \"Theses\",\n\n // Words ending in -us\n cactus: \"cacti\",\n Cactus: \"Cacti\",\n focus: \"foci\",\n Focus: \"Foci\",\n fungus: \"fungi\",\n Fungus: \"Fungi\",\n nucleus: \"nuclei\",\n Nucleus: \"Nuclei\",\n radius: \"radii\",\n Radius: \"Radii\",\n\n // Words ending in -on\n phenomenon: \"phenomena\",\n Phenomenon: \"Phenomena\",\n criterion: \"criteria\",\n Criterion: \"Criteria\",\n\n // Words ending in -um\n datum: \"data\",\n Datum: \"Data\",\n medium: \"media\",\n Medium: \"Media\",\n curriculum: \"curricula\",\n Curriculum: \"Curricula\",\n\n // Unchanged plurals\n sheep: \"sheep\",\n Sheep: \"Sheep\",\n deer: \"deer\",\n Deer: \"Deer\",\n fish: \"fish\",\n Fish: \"Fish\",\n species: \"species\",\n Species: \"Species\",\n series: \"series\",\n Series: \"Series\",\n};\n\n/**\n * Pluralizes a singular noun to its plural form\n * Handles special cases and common English pluralization rules\n *\n * @param singular - The singular form of the noun\n * @returns The plural form of the noun\n */\nexport function pluralize(singular: string): string {\n // Check special cases first (before checking if already plural)\n if (SPECIAL_CASES[singular]) {\n return SPECIAL_CASES[singular];\n }\n\n // Check if it's already plural (ends with 's' and is longer than 3 chars)\n if (singular.length > 3 && singular.endsWith(\"s\") && !singular.endsWith(\"ss\")) {\n // Could already be plural, return as-is\n return singular;\n }\n\n // Preserve case for the transformation\n const lowerSingular = singular.toLowerCase();\n\n let plural: string;\n\n // Rule 1: Words ending in -s, -ss, -sh, -ch, -x, -z -> add -es\n if (/(?:s|ss|sh|ch|x|z)$/.test(lowerSingular)) {\n plural = singular + \"es\";\n }\n // Rule 2: Words ending in consonant + y -> change y to ies\n else if (/[^aeiou]y$/.test(lowerSingular)) {\n plural = singular.slice(0, -1) + \"ies\";\n }\n // Rule 3: Words ending in consonant + o -> add -es\n else if (/[^aeiou]o$/.test(lowerSingular)) {\n plural = singular + \"es\";\n }\n // Rule 4: Words ending in -f or -fe -> change to -ves\n else if (/fe?$/.test(lowerSingular)) {\n if (lowerSingular.endsWith(\"fe\")) {\n plural = singular.slice(0, -2) + \"ves\";\n } else {\n plural = singular.slice(0, -1) + \"ves\";\n }\n }\n // Rule 5: Default -> add -s\n else {\n plural = singular + \"s\";\n }\n\n return plural;\n}\n\n/**\n * Converts a singular entity name to a collection name\n * This is an alias for pluralize for better semantic clarity\n *\n * @param entityName - The singular entity name (e.g., \"User\", \"Project\")\n * @returns The collection name (e.g., \"Users\", \"Projects\")\n */\nexport function toCollectionName(entityName: string): string {\n return pluralize(entityName);\n}\n\n/**\n * Attempts to singularize a plural noun (reverse of pluralize)\n * Note: This is a best-effort implementation and may not handle all edge cases\n *\n * @param plural - The plural form of the noun\n * @returns The singular form of the noun\n */\nexport function singularize(plural: string): string {\n // Check reverse special cases\n for (const [singular, pluralForm] of Object.entries(SPECIAL_CASES)) {\n if (pluralForm === plural) {\n return singular;\n }\n }\n\n const lower = plural.toLowerCase();\n\n // Rule 1: Words ending in -ies -> change to -y\n if (lower.endsWith(\"ies\") && plural.length > 3) {\n return plural.slice(0, -3) + \"y\";\n }\n\n // Rule 2: Words ending in -ves -> change to -f or -fe\n if (lower.endsWith(\"ves\")) {\n // Try -fe first (more common)\n return plural.slice(0, -3) + \"fe\";\n }\n\n // Rule 3: Words ending in -ses, -shes, -ches, -xes, -zes -> remove -es\n if (/(?:ses|shes|ches|xes|zes)$/.test(lower)) {\n return plural.slice(0, -2);\n }\n\n // Rule 4: Words ending in -s -> remove -s\n if (lower.endsWith(\"s\") && plural.length > 1) {\n return plural.slice(0, -1);\n }\n\n // Default: return as-is\n return plural;\n}\n","/**\n * Relation field detection utilities\n */\n\nimport { z } from \"zod\";\nimport { pluralize } from \"./pluralize\";\n\n/**\n * Detects if a field is a single relation based on naming convention\n * Single relation: field name matches a collection name (e.g., \"User\" -> \"Users\" collection)\n */\nexport function isSingleRelationField(fieldName: string, zodType: z.ZodTypeAny): boolean {\n // Unwrap optional/nullable/default\n let unwrappedType = zodType;\n if (zodType instanceof z.ZodOptional) {\n unwrappedType = zodType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodNullable) {\n unwrappedType = unwrappedType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodDefault) {\n unwrappedType = unwrappedType._def.innerType;\n }\n\n // Must be a string type\n if (!(unwrappedType instanceof z.ZodString)) {\n return false;\n }\n\n // Field name should start with uppercase (convention for entity references)\n // and not be a common string field name\n const startsWithUppercase = /^[A-Z]/.test(fieldName);\n\n // Exclude common string fields that start with uppercase\n const commonStringFields = [\"Title\", \"Name\", \"Description\", \"Content\", \"Summary\", \"Status\", \"Type\"];\n const isCommonField = commonStringFields.includes(fieldName);\n\n return startsWithUppercase && !isCommonField;\n}\n\n/**\n * Detects if a field is a multiple relation based on naming convention\n * Multiple relation: field name is an array of strings ending with entity name\n * (e.g., \"SubscriberUsers\" -> \"Users\" collection)\n */\nexport function isMultipleRelationField(fieldName: string, zodType: z.ZodTypeAny): boolean {\n // Unwrap optional/nullable/default\n let unwrappedType = zodType;\n if (zodType instanceof z.ZodOptional) {\n unwrappedType = zodType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodNullable) {\n unwrappedType = unwrappedType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodDefault) {\n unwrappedType = unwrappedType._def.innerType;\n }\n\n // Must be an array type\n if (!(unwrappedType instanceof z.ZodArray)) {\n return false;\n }\n\n // Element type must be string\n const elementType = unwrappedType._def.type;\n if (!(elementType instanceof z.ZodString)) {\n return false;\n }\n\n // Field name should contain an uppercase letter (entity reference pattern)\n const hasUppercase = /[A-Z]/.test(fieldName);\n\n return hasUppercase;\n}\n\n/**\n * Resolves the target collection name from a relation field name\n * Examples:\n * - \"User\" -> \"Users\"\n * - \"SubscriberUsers\" -> \"Users\"\n * - \"Author\" -> \"Authors\"\n * - \"Category\" -> \"Categories\"\n */\nexport function resolveTargetCollection(fieldName: string): string {\n // For single relations, the field name is typically the entity name\n // For multiple relations, extract the entity name from the end\n\n // Check if field name ends with a known plural entity name\n // Common patterns: \"SubscriberUsers\", \"RelatedPosts\", \"Tags\"\n\n // Try to find the entity name by looking for uppercase letters\n const matches = fieldName.match(/[A-Z][a-z]+/g);\n\n if (!matches || matches.length === 0) {\n // Fallback: pluralize the entire field name\n return pluralize(fieldName);\n }\n\n // Take the last matched entity name (e.g., \"Users\" from \"SubscriberUsers\")\n const entityName = matches[matches.length - 1];\n\n // Pluralize the entity name to get collection name\n return pluralize(entityName);\n}\n\n/**\n * Detects if a field is any type of relation (single or multiple)\n */\nexport function isRelationField(fieldName: string, zodType: z.ZodTypeAny): boolean {\n return isSingleRelationField(fieldName, zodType) || isMultipleRelationField(fieldName, zodType);\n}\n\n/**\n * Gets the maximum number of relations allowed for a relation field\n * Returns 1 for single relations, or the max constraint for multiple relations\n */\nexport function getMaxSelect(fieldName: string, zodType: z.ZodTypeAny): number {\n if (isSingleRelationField(fieldName, zodType)) {\n return 1;\n }\n\n if (isMultipleRelationField(fieldName, zodType)) {\n // Unwrap to get to the array type\n let unwrappedType = zodType;\n if (zodType instanceof z.ZodOptional) {\n unwrappedType = zodType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodNullable) {\n unwrappedType = unwrappedType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodDefault) {\n unwrappedType = unwrappedType._def.innerType;\n }\n\n if (unwrappedType instanceof z.ZodArray) {\n // Access the checks array from the array definition\n const arrayDef = unwrappedType._def;\n if (arrayDef.maxLength) {\n return arrayDef.maxLength.value;\n }\n // Default to 999 for multiple relations without explicit max\n return 999;\n }\n }\n\n return 1;\n}\n\n/**\n * Gets the minimum number of relations required for a relation field\n */\nexport function getMinSelect(fieldName: string, zodType: z.ZodTypeAny): number | undefined {\n if (!isMultipleRelationField(fieldName, zodType)) {\n return undefined;\n }\n\n // Unwrap to get to the array type\n let unwrappedType = zodType;\n if (zodType instanceof z.ZodOptional) {\n unwrappedType = zodType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodNullable) {\n unwrappedType = unwrappedType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodDefault) {\n unwrappedType = unwrappedType._def.innerType;\n }\n\n if (unwrappedType instanceof z.ZodArray) {\n // Access the minLength from the array definition\n const arrayDef = unwrappedType._def;\n if (arrayDef.minLength) {\n return arrayDef.minLength.value;\n }\n }\n\n return undefined;\n}\n","/**\n * Zod to PocketBase type mapping utilities\n *\n * This module provides comprehensive mapping between Zod schema types\n * and PocketBase field types, including support for all PocketBase field types:\n * - text, email, url, editor\n * - number, bool\n * - date, autodate\n * - select (single/multiple)\n * - relation (single/multiple)\n * - file (single/multiple)\n * - json\n * - geoPoint\n */\n\nimport { z } from \"zod\";\nimport type { PocketBaseFieldType } from \"../types\";\n\n/**\n * All supported PocketBase field types\n */\nexport const POCKETBASE_FIELD_TYPES: readonly PocketBaseFieldType[] = [\n \"text\",\n \"email\",\n \"url\",\n \"number\",\n \"bool\",\n \"date\",\n \"select\",\n \"relation\",\n \"file\",\n \"json\",\n \"editor\",\n \"geoPoint\",\n \"autodate\",\n] as const;\n\n/**\n * Field type metadata for documentation and validation\n */\nexport interface FieldTypeInfo {\n type: PocketBaseFieldType;\n description: string;\n zodTypes: string[];\n supportsMultiple: boolean;\n}\n\n/**\n * Metadata about each PocketBase field type\n */\nexport const FIELD_TYPE_INFO: Record<PocketBaseFieldType, FieldTypeInfo> = {\n text: {\n type: \"text\",\n description: \"Plain text field\",\n zodTypes: [\"ZodString\"],\n supportsMultiple: false,\n },\n email: {\n type: \"email\",\n description: \"Email address field with validation\",\n zodTypes: [\"ZodString with email()\"],\n supportsMultiple: false,\n },\n url: {\n type: \"url\",\n description: \"URL field with validation\",\n zodTypes: [\"ZodString with url()\"],\n supportsMultiple: false,\n },\n editor: {\n type: \"editor\",\n description: \"Rich text editor field\",\n zodTypes: [\"ZodString\"],\n supportsMultiple: false,\n },\n number: {\n type: \"number\",\n description: \"Numeric field (integer or float)\",\n zodTypes: [\"ZodNumber\"],\n supportsMultiple: false,\n },\n bool: {\n type: \"bool\",\n description: \"Boolean field\",\n zodTypes: [\"ZodBoolean\"],\n supportsMultiple: false,\n },\n date: {\n type: \"date\",\n description: \"Date/datetime field\",\n zodTypes: [\"ZodDate\", \"ZodString with datetime format\"],\n supportsMultiple: false,\n },\n autodate: {\n type: \"autodate\",\n description: \"Auto-managed date field (created/updated)\",\n zodTypes: [\"ZodString\"],\n supportsMultiple: false,\n },\n select: {\n type: \"select\",\n description: \"Single or multiple select from predefined values\",\n zodTypes: [\"ZodEnum\", \"ZodArray<ZodEnum>\"],\n supportsMultiple: true,\n },\n relation: {\n type: \"relation\",\n description: \"Reference to another collection\",\n zodTypes: [\"ZodString\", \"ZodArray<ZodString>\"],\n supportsMultiple: true,\n },\n file: {\n type: \"file\",\n description: \"File upload field\",\n zodTypes: [\"File\", \"ZodArray<File>\"],\n supportsMultiple: true,\n },\n json: {\n type: \"json\",\n description: \"JSON data field\",\n zodTypes: [\"ZodRecord\", \"ZodObject\", \"ZodArray\"],\n supportsMultiple: false,\n },\n geoPoint: {\n type: \"geoPoint\",\n description: \"Geographic coordinates (lon, lat)\",\n zodTypes: [\"ZodObject with lon/lat\"],\n supportsMultiple: false,\n },\n};\n\n/**\n * Maps Zod string types to PocketBase field types\n */\nexport function mapZodStringType(zodType: z.ZodString): PocketBaseFieldType {\n const checks = (zodType as any)._def.checks || [];\n\n // Check for email validation\n const hasEmail = checks.some((check: any) => check.kind === \"email\");\n if (hasEmail) {\n return \"email\";\n }\n\n // Check for URL validation\n const hasUrl = checks.some((check: any) => check.kind === \"url\");\n if (hasUrl) {\n return \"url\";\n }\n\n // Check for datetime validation (could be date field)\n const hasDatetime = checks.some((check: any) => check.kind === \"datetime\");\n if (hasDatetime) {\n return \"date\";\n }\n\n // Default to text\n return \"text\";\n}\n\n/**\n * Maps Zod number types to PocketBase number type\n */\nexport function mapZodNumberType(_zodType: z.ZodNumber): PocketBaseFieldType {\n return \"number\";\n}\n\n/**\n * Maps Zod boolean types to PocketBase bool type\n */\nexport function mapZodBooleanType(_zodType: z.ZodBoolean): PocketBaseFieldType {\n return \"bool\";\n}\n\n/**\n * Maps Zod enum types to PocketBase select type\n */\nexport function mapZodEnumType(_zodType: z.ZodEnum<any>): PocketBaseFieldType {\n return \"select\";\n}\n\n/**\n * Maps Zod array types to appropriate PocketBase types\n * Arrays of strings could be relations or file fields depending on context\n */\nexport function mapZodArrayType(zodType: z.ZodArray<any>, _fieldName: string): PocketBaseFieldType {\n const elementType = zodType._def.type;\n\n // Check if it's an array of File instances (file upload)\n if (elementType instanceof z.ZodType) {\n const typeName = elementType._def.typeName;\n if (typeName === \"ZodType\" && (elementType as any)._def?.innerType?.name === \"File\") {\n return \"file\";\n }\n }\n\n // Check for instanceof File\n if (elementType._def?.typeName === \"ZodType\") {\n const checks = (elementType as any)._def?.checks || [];\n const isFileInstance = checks.some(\n (check: any) => check.kind === \"instanceof\" || (elementType as any)._def?.innerType?.name === \"File\"\n );\n if (isFileInstance) {\n return \"file\";\n }\n }\n\n // Array of strings - could be relation (will be determined by relation detector)\n if (elementType instanceof z.ZodString) {\n return \"relation\";\n }\n\n // Default to JSON for other array types\n return \"json\";\n}\n\n/**\n * Maps Zod date types to PocketBase date type\n */\nexport function mapZodDateType(_zodType: z.ZodDate): PocketBaseFieldType {\n return \"date\";\n}\n\n/**\n * Maps Zod record/object types to PocketBase JSON type\n */\nexport function mapZodRecordType(_zodType: z.ZodRecord | z.ZodObject<any>): PocketBaseFieldType {\n return \"json\";\n}\n\n/**\n * Main type mapping function that determines PocketBase field type from Zod type\n */\nexport function mapZodTypeToPocketBase(zodType: z.ZodTypeAny, fieldName: string): PocketBaseFieldType {\n // Handle optional and nullable types by unwrapping\n let unwrappedType = zodType;\n\n if (zodType instanceof z.ZodOptional) {\n unwrappedType = zodType._def.innerType;\n }\n\n if (unwrappedType instanceof z.ZodNullable) {\n unwrappedType = unwrappedType._def.innerType;\n }\n\n if (unwrappedType instanceof z.ZodDefault) {\n unwrappedType = unwrappedType._def.innerType;\n }\n\n // Check for ZodEffects (which is what z.instanceof() creates)\n if ((unwrappedType as any)._def?.typeName === \"ZodEffects\") {\n const effect = (unwrappedType as any)._def?.effect;\n\n // z.instanceof(File) creates a refinement effect\n // We need to check if this is a File instance check\n // The field name 'avatar', 'image', 'file', 'attachment' etc. are hints\n if (effect?.type === \"refinement\") {\n // Common file field names\n const fileFieldNames = [\"avatar\", \"image\", \"file\", \"attachment\", \"photo\", \"picture\", \"document\", \"upload\"];\n if (fileFieldNames.some((name) => fieldName.toLowerCase().includes(name))) {\n return \"file\";\n }\n }\n }\n\n // Check for instanceof File (z.instanceof(File)) - legacy check\n if ((unwrappedType as any)._def?.typeName === \"ZodType\") {\n const checks = (unwrappedType as any)._def?.checks || [];\n const innerType = (unwrappedType as any)._def?.innerType;\n\n // Check if it's instanceof File\n if (innerType?.name === \"File\" || checks.some((check: any) => check.kind === \"instanceof\")) {\n return \"file\";\n }\n }\n\n // Map based on Zod type\n if (unwrappedType instanceof z.ZodString) {\n return mapZodStringType(unwrappedType);\n }\n\n if (unwrappedType instanceof z.ZodNumber) {\n return mapZodNumberType(unwrappedType);\n }\n\n if (unwrappedType instanceof z.ZodBoolean) {\n return mapZodBooleanType(unwrappedType);\n }\n\n if (unwrappedType instanceof z.ZodEnum) {\n return mapZodEnumType(unwrappedType);\n }\n\n if (unwrappedType instanceof z.ZodArray) {\n return mapZodArrayType(unwrappedType, fieldName);\n }\n\n if (unwrappedType instanceof z.ZodDate) {\n return mapZodDateType(unwrappedType);\n }\n\n if (unwrappedType instanceof z.ZodRecord || unwrappedType instanceof z.ZodObject) {\n return mapZodRecordType(unwrappedType);\n }\n\n // Default to text for unknown types\n return \"text\";\n}\n\n/**\n * Extracts field options from Zod type (min, max, pattern, etc.)\n */\nexport function extractFieldOptions(zodType: z.ZodTypeAny): Record<string, any> {\n const options: Record<string, any> = {};\n\n // Unwrap optional/nullable/default\n let unwrappedType = zodType;\n if (zodType instanceof z.ZodOptional) {\n unwrappedType = zodType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodNullable) {\n unwrappedType = unwrappedType._def.innerType;\n }\n if (unwrappedType instanceof z.ZodDefault) {\n unwrappedType = unwrappedType._def.innerType;\n }\n\n const checks = (unwrappedType as any)._def?.checks || [];\n\n // Extract string constraints\n if (unwrappedType instanceof z.ZodString) {\n for (const check of checks) {\n if (check.kind === \"min\") {\n options.min = check.value;\n }\n if (check.kind === \"max\") {\n options.max = check.value;\n }\n if (check.kind === \"regex\") {\n options.pattern = check.regex.source;\n }\n }\n }\n\n // Extract number constraints\n if (unwrappedType instanceof z.ZodNumber) {\n for (const check of checks) {\n if (check.kind === \"min\") {\n options.min = check.value;\n }\n if (check.kind === \"max\") {\n options.max = check.value;\n }\n }\n }\n\n // Extract enum values\n if (unwrappedType instanceof z.ZodEnum) {\n options.values = unwrappedType._def.values;\n }\n\n // Extract array constraints\n if (unwrappedType instanceof z.ZodArray) {\n const arrayChecks = (unwrappedType as any)._def?.checks || [];\n for (const check of arrayChecks) {\n if (check.kind === \"min\") {\n options.minSelect = check.value;\n }\n if (check.kind === \"max\") {\n options.maxSelect = check.value;\n }\n }\n }\n\n return options;\n}\n\n/**\n * Determines if a Zod field is required (not optional)\n */\nexport function isFieldRequired(zodType: z.ZodTypeAny): boolean {\n // Check if it's optional\n if (zodType instanceof z.ZodOptional) {\n return false;\n }\n\n // Check if it has a default value (makes it optional)\n if (zodType instanceof z.ZodDefault) {\n return false;\n }\n\n // Check for nullable (in PocketBase context, nullable means optional)\n if (zodType instanceof z.ZodNullable) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Unwraps a Zod type to get the inner type\n * Handles optional, nullable, and default wrappers\n */\nexport function unwrapZodType(zodType: z.ZodTypeAny): z.ZodTypeAny {\n let unwrapped = zodType;\n\n if (unwrapped instanceof z.ZodOptional) {\n unwrapped = unwrapped._def.innerType;\n }\n\n if (unwrapped instanceof z.ZodNullable) {\n unwrapped = unwrapped._def.innerType;\n }\n\n if (unwrapped instanceof z.ZodDefault) {\n unwrapped = unwrapped._def.innerType;\n }\n\n return unwrapped;\n}\n\n/**\n * Gets the default value from a Zod type if it has one\n */\nexport function getDefaultValue(zodType: z.ZodTypeAny): any {\n if (zodType instanceof z.ZodDefault) {\n return zodType._def.defaultValue();\n }\n return undefined;\n}\n\n/**\n * Checks if a Zod type is an array type\n */\nexport function isArrayType(zodType: z.ZodTypeAny): boolean {\n const unwrapped = unwrapZodType(zodType);\n return unwrapped instanceof z.ZodArray;\n}\n\n/**\n * Gets the element type of an array Zod type\n */\nexport function getArrayElementType(zodType: z.ZodTypeAny): z.ZodTypeAny | null {\n const unwrapped = unwrapZodType(zodType);\n if (unwrapped instanceof z.ZodArray) {\n return unwrapped._def.type;\n }\n return null;\n}\n\n/**\n * Checks if a Zod type represents a geo point (object with lon/lat)\n */\nexport function isGeoPointType(zodType: z.ZodTypeAny): boolean {\n const unwrapped = unwrapZodType(zodType);\n if (!(unwrapped instanceof z.ZodObject)) {\n return false;\n }\n\n const shape = unwrapped._def.shape();\n const hasLon = \"lon\" in shape && shape.lon instanceof z.ZodNumber;\n const hasLat = \"lat\" in shape && shape.lat instanceof z.ZodNumber;\n\n return hasLon && hasLat;\n}\n\n/**\n * Complete field options extracted from a Zod type\n */\nexport interface ExtractedFieldOptions {\n min?: number;\n max?: number;\n pattern?: string;\n values?: string[];\n minSelect?: number;\n maxSelect?: number;\n mimeTypes?: string[];\n maxSize?: number;\n thumbs?: string[];\n}\n\n/**\n * Extracts comprehensive field options from Zod type\n * Includes all constraints that can be mapped to PocketBase field options\n */\nexport function extractComprehensiveFieldOptions(zodType: z.ZodTypeAny): ExtractedFieldOptions {\n const options: ExtractedFieldOptions = {};\n const unwrapped = unwrapZodType(zodType);\n const checks = (unwrapped as any)._def?.checks || [];\n\n // Extract string constraints\n if (unwrapped instanceof z.ZodString) {\n for (const check of checks) {\n if (check.kind === \"min\") {\n options.min = check.value;\n }\n if (check.kind === \"max\") {\n options.max = check.value;\n }\n if (check.kind === \"regex\") {\n options.pattern = check.regex.source;\n }\n }\n }\n\n // Extract number constraints\n if (unwrapped instanceof z.ZodNumber) {\n for (const check of checks) {\n if (check.kind === \"min\") {\n options.min = check.value;\n }\n if (check.kind === \"max\") {\n options.max = check.value;\n }\n }\n }\n\n // Extract enum values\n if (unwrapped instanceof z.ZodEnum) {\n options.values = unwrapped._def.values;\n }\n\n // Extract array constraints\n if (unwrapped instanceof z.ZodArray) {\n const arrayDef = unwrapped._def;\n if (arrayDef.minLength) {\n options.minSelect = arrayDef.minLength.value;\n }\n if (arrayDef.maxLength) {\n options.maxSelect = arrayDef.maxLength.value;\n }\n\n // Check for enum element type\n const elementType = arrayDef.type;\n if (elementType instanceof z.ZodEnum) {\n options.values = elementType._def.values;\n }\n }\n\n return options;\n}\n\n/**\n * Determines if a field should be treated as an editor field\n * based on field name conventions\n */\nexport function isEditorField(fieldName: string): boolean {\n const editorFieldNames = [\n \"content\",\n \"body\",\n \"description\",\n \"bio\",\n \"about\",\n \"summary\",\n \"notes\",\n \"details\",\n \"html\",\n \"richtext\",\n \"editor\",\n ];\n return editorFieldNames.some((name) => fieldName.toLowerCase().includes(name));\n}\n\n/**\n * Determines if a field should be treated as a file field\n * based on field name conventions\n */\nexport function isFileFieldByName(fieldName: string): boolean {\n const fileFieldNames = [\n \"avatar\",\n \"image\",\n \"file\",\n \"attachment\",\n \"photo\",\n \"picture\",\n \"document\",\n \"upload\",\n \"thumbnail\",\n \"cover\",\n \"banner\",\n \"logo\",\n \"icon\",\n \"media\",\n ];\n return fileFieldNames.some((name) => fieldName.toLowerCase().includes(name));\n}\n\n/**\n * Gets the PocketBase field type with additional context\n */\nexport interface FieldTypeResult {\n type: PocketBaseFieldType;\n isMultiple: boolean;\n options: ExtractedFieldOptions;\n}\n\n/**\n * Comprehensive type mapping that returns full field information\n */\nexport function getFieldTypeInfo(zodType: z.ZodTypeAny, fieldName: string): FieldTypeResult {\n const type = mapZodTypeToPocketBase(zodType, fieldName);\n const isMultiple = isArrayType(zodType);\n const options = extractComprehensiveFieldOptions(zodType);\n\n return {\n type,\n isMultiple,\n options,\n };\n}\n"]}
|
package/dist/mutator.cjs
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/schema/base.ts
|
|
6
|
+
var baseSchema = {
|
|
7
|
+
id: zod.z.string().describe("unique id"),
|
|
8
|
+
collectionId: zod.z.string().describe("collection id"),
|
|
9
|
+
collectionName: zod.z.string().describe("collection name"),
|
|
10
|
+
expand: zod.z.record(zod.z.any()).describe("expandable fields")
|
|
11
|
+
};
|
|
12
|
+
({
|
|
13
|
+
...baseSchema,
|
|
14
|
+
created: zod.z.string().describe("creation timestamp"),
|
|
15
|
+
updated: zod.z.string().describe("last update timestamp")
|
|
16
|
+
});
|
|
17
|
+
({
|
|
18
|
+
...baseSchema,
|
|
19
|
+
thumbnailURL: zod.z.string().optional(),
|
|
20
|
+
imageFiles: zod.z.array(zod.z.string())
|
|
21
|
+
});
|
|
22
|
+
({
|
|
23
|
+
imageFiles: zod.z.array(zod.z.instanceof(File))
|
|
24
|
+
});
|
|
25
|
+
function withPermissions(schema, config) {
|
|
26
|
+
const metadata = {
|
|
27
|
+
permissions: config
|
|
28
|
+
};
|
|
29
|
+
return schema.describe(JSON.stringify(metadata));
|
|
30
|
+
}
|
|
31
|
+
function withIndexes(schema, indexes) {
|
|
32
|
+
let existingMetadata = {};
|
|
33
|
+
if (schema.description) {
|
|
34
|
+
try {
|
|
35
|
+
existingMetadata = JSON.parse(schema.description);
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const metadata = {
|
|
40
|
+
...existingMetadata,
|
|
41
|
+
indexes
|
|
42
|
+
};
|
|
43
|
+
return schema.describe(JSON.stringify(metadata));
|
|
44
|
+
}
|
|
45
|
+
var UserInputSchema = zod.z.object({
|
|
46
|
+
name: zod.z.string().min(2, "Name must be longer").optional(),
|
|
47
|
+
email: zod.z.string().email(),
|
|
48
|
+
password: zod.z.string().min(8, "Password must be at least 8 characters"),
|
|
49
|
+
passwordConfirm: zod.z.string(),
|
|
50
|
+
avatar: zod.z.instanceof(File).optional()
|
|
51
|
+
});
|
|
52
|
+
var UserDatabaseSchema = zod.z.object({
|
|
53
|
+
name: zod.z.string().min(2, "Name must be longer").optional(),
|
|
54
|
+
email: zod.z.string().email(),
|
|
55
|
+
password: zod.z.string().min(8, "Password must be at least 8 characters"),
|
|
56
|
+
avatar: zod.z.instanceof(File).optional()
|
|
57
|
+
});
|
|
58
|
+
withIndexes(
|
|
59
|
+
withPermissions(UserDatabaseSchema.extend(baseSchema), {
|
|
60
|
+
// Users can list other users (for mentions, user search, etc.)
|
|
61
|
+
listRule: "id = @request.auth.id",
|
|
62
|
+
// Users can view their own profile
|
|
63
|
+
viewRule: "id = @request.auth.id",
|
|
64
|
+
// Anyone can create an account (sign up)
|
|
65
|
+
createRule: "",
|
|
66
|
+
// Users can only update their own profile
|
|
67
|
+
updateRule: "id = @request.auth.id",
|
|
68
|
+
// Users can only delete their own account
|
|
69
|
+
deleteRule: "id = @request.auth.id",
|
|
70
|
+
// Users can only manage their own account (change email, password, etc.)
|
|
71
|
+
manageRule: "id = @request.auth.id"
|
|
72
|
+
}),
|
|
73
|
+
[
|
|
74
|
+
// Email should be unique for authentication
|
|
75
|
+
"CREATE UNIQUE INDEX idx_users_email ON users (email)",
|
|
76
|
+
// Index on name for user search and sorting
|
|
77
|
+
"CREATE INDEX idx_users_name ON users (name)"
|
|
78
|
+
]
|
|
79
|
+
);
|
|
80
|
+
var BaseMutator = class {
|
|
81
|
+
pb;
|
|
82
|
+
// Define a default property that subclasses will override
|
|
83
|
+
options = {
|
|
84
|
+
expand: [],
|
|
85
|
+
filter: [],
|
|
86
|
+
sort: []
|
|
87
|
+
};
|
|
88
|
+
constructor(pb, options) {
|
|
89
|
+
this.pb = pb;
|
|
90
|
+
this.initializeOptions();
|
|
91
|
+
if (options) {
|
|
92
|
+
this.overrideOptions(options);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
initializeOptions() {
|
|
96
|
+
this.options = this.setDefaults();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Initialize options with class-specific defaults
|
|
100
|
+
* Subclasses should override this instead of directly setting options
|
|
101
|
+
*/
|
|
102
|
+
setDefaults() {
|
|
103
|
+
return {
|
|
104
|
+
expand: [],
|
|
105
|
+
filter: [],
|
|
106
|
+
sort: []
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Merge provided options with current options
|
|
111
|
+
*/
|
|
112
|
+
overrideOptions(newOptions) {
|
|
113
|
+
if (newOptions.expand !== void 0) {
|
|
114
|
+
this.options.expand = newOptions.expand;
|
|
115
|
+
}
|
|
116
|
+
if (newOptions.filter !== void 0) {
|
|
117
|
+
this.options.filter = newOptions.filter;
|
|
118
|
+
}
|
|
119
|
+
if (newOptions.sort !== void 0) {
|
|
120
|
+
this.options.sort = newOptions.sort;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
toSnakeCase(str) {
|
|
124
|
+
return str.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Create a new entity
|
|
128
|
+
*/
|
|
129
|
+
async create(input) {
|
|
130
|
+
try {
|
|
131
|
+
const data = await this.validateInput(input);
|
|
132
|
+
const record = await this.entityCreate(data);
|
|
133
|
+
return await this.processRecord(record);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
return this.errorWrapper(error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Update an existing entity
|
|
140
|
+
*/
|
|
141
|
+
async update(id, input) {
|
|
142
|
+
try {
|
|
143
|
+
const record = await this.entityUpdate(id, input);
|
|
144
|
+
return await this.processRecord(record);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
return this.errorWrapper(error);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Create or update entity (upsert)
|
|
151
|
+
*/
|
|
152
|
+
async upsert(input) {
|
|
153
|
+
if (input?.id) {
|
|
154
|
+
return await this.update(input.id, input);
|
|
155
|
+
}
|
|
156
|
+
return await this.create(input);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get entity by ID
|
|
160
|
+
*/
|
|
161
|
+
async getById(id, expand) {
|
|
162
|
+
try {
|
|
163
|
+
const record = await this.entityGetById(id, expand);
|
|
164
|
+
return await this.processRecord(record);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
return this.handleError(error, { allowNotFound: true });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get first entity by filter
|
|
171
|
+
*/
|
|
172
|
+
async getFirstByFilter(filter, expand, sort) {
|
|
173
|
+
try {
|
|
174
|
+
const record = await this.entityGetFirstByFilter(filter, expand, sort);
|
|
175
|
+
return await this.processRecord(record);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return this.handleError(error, { allowNotFound: true });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get list of entities
|
|
182
|
+
*/
|
|
183
|
+
async getList(page = 1, perPage = 100, filter, sort, expand) {
|
|
184
|
+
try {
|
|
185
|
+
const result = await this.entityGetList(page, perPage, filter, sort, expand);
|
|
186
|
+
return await this.processListResult(result);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
return this.errorWrapper(error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Delete entity by ID
|
|
193
|
+
*/
|
|
194
|
+
async delete(id) {
|
|
195
|
+
try {
|
|
196
|
+
return await this.entityDelete(id);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
return this.handleError(error, { returnValue: false });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Process a single record before returning it
|
|
203
|
+
* Can be overridden to handle special cases like mapped entities
|
|
204
|
+
*/
|
|
205
|
+
async processRecord(record) {
|
|
206
|
+
return record;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Process a list result before returning it
|
|
210
|
+
* Can be overridden to handle special cases like mapped entities
|
|
211
|
+
*/
|
|
212
|
+
async processListResult(result) {
|
|
213
|
+
const processedItems = await Promise.all(result.items.map((item) => this.processRecord(item)));
|
|
214
|
+
return {
|
|
215
|
+
...result,
|
|
216
|
+
items: processedItems
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Prepare expand parameter
|
|
221
|
+
* Combines default expands with provided expands
|
|
222
|
+
*/
|
|
223
|
+
prepareExpand(expand) {
|
|
224
|
+
if (!this.options.expand.length && !expand) {
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
let expandArray = [...this.options.expand];
|
|
228
|
+
if (expand) {
|
|
229
|
+
if (typeof expand === "string") {
|
|
230
|
+
expandArray = expandArray.concat(expand.split(",").map((e) => e.trim()));
|
|
231
|
+
} else {
|
|
232
|
+
expandArray = expandArray.concat(expand);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const uniqueExpands = [...new Set(expandArray)].filter((e) => e !== "" && e !== void 0);
|
|
236
|
+
if (!uniqueExpands.length) {
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
return uniqueExpands.join(",");
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Prepare filter parameter
|
|
243
|
+
* Combines default filters with provided filters
|
|
244
|
+
*/
|
|
245
|
+
prepareFilter(filter) {
|
|
246
|
+
if (!this.options.filter.length && !filter) {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
let filterArray = [...this.options.filter];
|
|
250
|
+
if (filter) {
|
|
251
|
+
if (typeof filter === "string") {
|
|
252
|
+
if (filter) filterArray.push(filter);
|
|
253
|
+
} else {
|
|
254
|
+
filterArray = filterArray.concat(filter);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const validFilters = filterArray.filter((f) => f !== "" && f !== void 0);
|
|
258
|
+
if (!validFilters.length) {
|
|
259
|
+
return void 0;
|
|
260
|
+
}
|
|
261
|
+
return validFilters.join("&&");
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Prepare sort parameter
|
|
265
|
+
* Uses provided sort or falls back to default sort
|
|
266
|
+
*/
|
|
267
|
+
prepareSort(sort) {
|
|
268
|
+
if (sort && sort !== "") {
|
|
269
|
+
return sort;
|
|
270
|
+
}
|
|
271
|
+
if (this.options.sort.length) {
|
|
272
|
+
const validSorts = this.options.sort.filter((s) => s !== "" && s !== void 0);
|
|
273
|
+
if (validSorts.length) {
|
|
274
|
+
return validSorts.join(",");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return void 0;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Perform the actual create operation
|
|
281
|
+
*/
|
|
282
|
+
async entityCreate(data) {
|
|
283
|
+
return await this.getCollection().create(data);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Perform the actual update operation
|
|
287
|
+
*/
|
|
288
|
+
async entityUpdate(id, data) {
|
|
289
|
+
return await this.getCollection().update(id, data);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Perform the actual getById operation
|
|
293
|
+
*/
|
|
294
|
+
async entityGetById(id, expand) {
|
|
295
|
+
const finalExpand = this.prepareExpand(expand);
|
|
296
|
+
const options = finalExpand ? { expand: finalExpand } : {};
|
|
297
|
+
return await this.getCollection().getOne(id, options);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Perform the actual getFirstByFilter operation
|
|
301
|
+
*/
|
|
302
|
+
async entityGetFirstByFilter(filter, expand, sort) {
|
|
303
|
+
const finalFilter = this.prepareFilter(filter);
|
|
304
|
+
const finalExpand = this.prepareExpand(expand);
|
|
305
|
+
const finalSort = this.prepareSort(sort);
|
|
306
|
+
const options = {};
|
|
307
|
+
if (finalExpand) options.expand = finalExpand;
|
|
308
|
+
if (finalSort) options.sort = finalSort;
|
|
309
|
+
return await this.getCollection().getFirstListItem(finalFilter || "", options);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Perform the actual getList operation
|
|
313
|
+
* Returns a list result with items of type T
|
|
314
|
+
*/
|
|
315
|
+
async entityGetList(page, perPage, filter, sort, expand) {
|
|
316
|
+
const finalFilter = this.prepareFilter(filter);
|
|
317
|
+
const finalExpand = this.prepareExpand(expand);
|
|
318
|
+
const finalSort = this.prepareSort(sort);
|
|
319
|
+
const options = {};
|
|
320
|
+
if (finalFilter) options.filter = finalFilter;
|
|
321
|
+
if (finalExpand) options.expand = finalExpand;
|
|
322
|
+
if (finalSort) options.sort = finalSort;
|
|
323
|
+
return await this.getCollection().getList(page, perPage, options);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Perform the actual delete operation
|
|
327
|
+
*/
|
|
328
|
+
async entityDelete(id) {
|
|
329
|
+
await this.getCollection().delete(id);
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Error handler for common errors
|
|
334
|
+
* @param error The error to handle
|
|
335
|
+
* @param options Handler options
|
|
336
|
+
* @returns The value to return if the error is handled, or throws if not handled
|
|
337
|
+
*/
|
|
338
|
+
handleError(error, options = { logError: true }) {
|
|
339
|
+
const { allowNotFound = false, returnValue, logError = true } = options;
|
|
340
|
+
if (logError) {
|
|
341
|
+
console.error(`Error in ${this.constructor.name}:`, error);
|
|
342
|
+
}
|
|
343
|
+
if (allowNotFound && this.isNotFoundError(error)) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
if (returnValue !== void 0) {
|
|
347
|
+
return returnValue;
|
|
348
|
+
}
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Check if an error is a "not found" error
|
|
353
|
+
*/
|
|
354
|
+
isNotFoundError(error) {
|
|
355
|
+
return error instanceof Error && (error.message.includes("404") || error.message.toLowerCase().includes("not found"));
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Standard error handling wrapper (legacy method, consider using handleError instead)
|
|
359
|
+
*/
|
|
360
|
+
errorWrapper(error) {
|
|
361
|
+
console.error(`Error in ${this.constructor.name}:`, error);
|
|
362
|
+
throw error;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Subscribe to changes on a specific record
|
|
366
|
+
* @param id The ID of the record to subscribe to
|
|
367
|
+
* @param callback Function to call when changes occur
|
|
368
|
+
* @param expand Optional expand parameters
|
|
369
|
+
* @returns Promise that resolves to an unsubscribe function
|
|
370
|
+
*/
|
|
371
|
+
async subscribeToRecord(id, callback, expand) {
|
|
372
|
+
const finalExpand = this.prepareExpand(expand);
|
|
373
|
+
const options = finalExpand ? { expand: finalExpand } : {};
|
|
374
|
+
return this.getCollection().subscribe(id, callback, options);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Subscribe to changes on the entire collection
|
|
378
|
+
* @param callback Function to call when changes occur
|
|
379
|
+
* @param expand Optional expand parameters
|
|
380
|
+
* @returns Promise that resolves to an unsubscribe function
|
|
381
|
+
*/
|
|
382
|
+
async subscribeToCollection(callback, expand) {
|
|
383
|
+
const finalExpand = this.prepareExpand(expand);
|
|
384
|
+
const options = finalExpand ? { expand: finalExpand } : {};
|
|
385
|
+
return this.getCollection().subscribe("*", callback, options);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Unsubscribe from a specific record's changes
|
|
389
|
+
* @param id The ID of the record to unsubscribe from
|
|
390
|
+
*/
|
|
391
|
+
unsubscribeFromRecord(id) {
|
|
392
|
+
this.getCollection().unsubscribe(id);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Unsubscribe from collection-wide changes
|
|
396
|
+
*/
|
|
397
|
+
unsubscribeFromCollection() {
|
|
398
|
+
this.getCollection().unsubscribe("*");
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Unsubscribe from all subscriptions in this collection
|
|
402
|
+
*/
|
|
403
|
+
unsubscribeAll() {
|
|
404
|
+
this.getCollection().unsubscribe();
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
// src/mutator/userMutator.ts
|
|
409
|
+
var UserMutator = class extends BaseMutator {
|
|
410
|
+
setDefaults() {
|
|
411
|
+
return {
|
|
412
|
+
expand: [],
|
|
413
|
+
filter: [],
|
|
414
|
+
sort: ["-updated"]
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
getCollection() {
|
|
418
|
+
return this.pb.collection("Projects");
|
|
419
|
+
}
|
|
420
|
+
async validateInput(input) {
|
|
421
|
+
return UserInputSchema.parse(input);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
exports.UserMutator = UserMutator;
|
|
426
|
+
//# sourceMappingURL=mutator.cjs.map
|
|
427
|
+
//# sourceMappingURL=mutator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema/base.ts","../src/schema/user.ts","../src/mutator/baseMutator.ts","../src/mutator/userMutator.ts"],"names":["z"],"mappings":";;;;;AAOO,IAAM,UAAA,GAAa;AAAA,EACxB,EAAA,EAAIA,KAAA,CAAE,MAAA,EAAO,CAAE,SAAS,WAAW,CAAA;AAAA,EACnC,YAAA,EAAcA,KAAA,CAAE,MAAA,EAAO,CAAE,SAAS,eAAe,CAAA;AAAA,EACjD,cAAA,EAAgBA,KAAA,CAAE,MAAA,EAAO,CAAE,SAAS,iBAAiB,CAAA;AAAA,EACrD,MAAA,EAAQA,MAAE,MAAA,CAAOA,KAAA,CAAE,KAAK,CAAA,CAAE,SAAS,mBAAmB;AACxD,CAAA;CAMwC;AAAA,EACtC,GAAG,UAAA;AAAA,EACH,OAAA,EAASA,KAAA,CAAE,MAAA,EAAO,CAAE,SAAS,oBAAoB,CAAA;AAAA,EACjD,OAAA,EAASA,KAAA,CAAE,MAAA,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EAAC;AAAA,MACT,QAAQ,EAAC;AAAA,MACT,IAAA,EAAM,CAAC,UAAU;AAAA,KACnB;AAAA,EACF;AAAA,EAEU,aAAA,GAAgB;AACxB,IAAA,OAAO,IAAA,CAAK,EAAA,CAAG,UAAA,CAAW,UAAU,CAAA;AAAA,EACtC;AAAA,EAEA,MAAgB,cAAc,KAAA,EAAsB;AAClD,IAAA,OAAO,eAAA,CAAgB,MAAM,KAAK,CAAA;AAAA,EACpC;AACF","file":"mutator.cjs","sourcesContent":["import { z } from \"zod\";\nimport type { PermissionSchema, PermissionTemplateConfig } from \"./permissions\";\n\n/**\n * Base schema fields that PocketBase automatically adds to all records\n * These fields are managed by PocketBase and should not be set manually\n */\nexport const baseSchema = {\n id: z.string().describe(\"unique id\"),\n collectionId: z.string().describe(\"collection id\"),\n collectionName: z.string().describe(\"collection name\"),\n expand: z.record(z.any()).describe(\"expandable fields\"),\n};\n\n/**\n * Extended base schema with timestamp fields\n * Includes created and updated autodate fields\n */\nexport const baseSchemaWithTimestamps = {\n ...baseSchema,\n created: z.string().describe(\"creation timestamp\"),\n updated: z.string().describe(\"last update timestamp\"),\n};\n\n/**\n * Base schema for image file collections\n * Extends base schema with thumbnail URL and image files array\n */\nexport const baseImageFileSchema = {\n ...baseSchema,\n thumbnailURL: z.string().optional(),\n imageFiles: z.array(z.string()),\n};\n\n/**\n * Input schema for image file uploads\n * Used in forms where users upload File objects\n * Requires Node.js 20+ or browser environment with File API\n */\nexport const inputImageFileSchema = {\n imageFiles: z.array(z.instanceof(File)),\n};\n\n/**\n * Helper constant for omitting image files from schemas\n * Used with Zod's .omit() method\n */\nexport const omitImageFilesSchema = {\n imageFiles: true,\n} as const;\n\n// ============================================================================\n// Common PocketBase Field Type Patterns\n// ============================================================================\n\n/**\n * Creates a text field schema with optional constraints\n * @param options - Optional constraints for the text field\n */\nexport function textField(options?: { min?: number; max?: number; pattern?: RegExp }) {\n let schema = z.string();\n if (options?.min !== undefined) schema = schema.min(options.min);\n if (options?.max !== undefined) schema = schema.max(options.max);\n if (options?.pattern !== undefined) schema = schema.regex(options.pattern);\n return schema;\n}\n\n/**\n * Creates an email field schema\n * Maps to PocketBase 'email' field type\n */\nexport function emailField() {\n return z.string().email();\n}\n\n/**\n * Creates a URL field schema\n * Maps to PocketBase 'url' field type\n */\nexport function urlField() {\n return z.string().url();\n}\n\n/**\n * Creates a number field schema with optional constraints\n * @param options - Optional constraints for the number field\n */\nexport function numberField(options?: { min?: number; max?: number }) {\n let schema = z.number();\n if (options?.min !== undefined) schema = schema.min(options.min);\n if (options?.max !== undefined) schema = schema.max(options.max);\n return schema;\n}\n\n/**\n * Creates a boolean field schema\n * Maps to PocketBase 'bool' field type\n */\nexport function boolField() {\n return z.boolean();\n}\n\n/**\n * Creates a date field schema\n * Maps to PocketBase 'date' field type\n */\nexport function dateField() {\n return z.date();\n}\n\n/**\n * Creates a select field schema from enum values\n * Maps to PocketBase 'select' field type\n * @param values - Array of allowed string values\n */\nexport function selectField<T extends [string, ...string[]]>(values: T) {\n return z.enum(values);\n}\n\n/**\n * Creates a JSON field schema\n * Maps to PocketBase 'json' field type\n * @param schema - Optional Zod schema for the JSON structure\n */\nexport function jsonField<T extends z.ZodTypeAny>(schema?: T) {\n return schema ?? z.record(z.any());\n}\n\n/**\n * Creates a single file field schema for form input\n * Maps to PocketBase 'file' field type with maxSelect=1\n * Requires Node.js 20+ or browser environment with File API\n */\nexport function fileField() {\n return z.instanceof(File);\n}\n\n/**\n * Creates a multiple file field schema for form input\n * Maps to PocketBase 'file' field type with maxSelect>1\n * Requires Node.js 20+ or browser environment with File API\n * @param options - Optional constraints for the file field\n */\nexport function filesField(options?: { min?: number; max?: number }) {\n let schema = z.array(z.instanceof(File));\n if (options?.min !== undefined) schema = schema.min(options.min);\n if (options?.max !== undefined) schema = schema.max(options.max);\n return schema;\n}\n\n/**\n * Creates a single relation field schema\n * Maps to PocketBase 'relation' field type with maxSelect=1\n * Field name should start with uppercase to be detected as relation\n */\nexport function relationField() {\n return z.string();\n}\n\n/**\n * Creates a multiple relation field schema\n * Maps to PocketBase 'relation' field type with maxSelect>1\n * Field name should contain uppercase to be detected as relation\n * @param options - Optional constraints for the relation field\n */\nexport function relationsField(options?: { min?: number; max?: number }) {\n let schema = z.array(z.string());\n if (options?.min !== undefined) schema = schema.min(options.min);\n if (options?.max !== undefined) schema = schema.max(options.max);\n return schema;\n}\n\n/**\n * Creates an editor field schema (rich text)\n * Maps to PocketBase 'editor' field type\n */\nexport function editorField() {\n return z.string();\n}\n\n/**\n * Creates a geo point field schema\n * Maps to PocketBase 'geoPoint' field type\n */\nexport function geoPointField() {\n return z.object({\n lon: z.number(),\n lat: z.number(),\n });\n}\n\n/**\n * Attach permission metadata to a Zod schema\n *\n * This helper function allows you to define PocketBase API rules alongside your\n * entity schema definitions. The permissions are stored as metadata using Zod's\n * describe() method and will be extracted during migration generation.\n *\n * @param schema - The Zod schema to attach permissions to\n * @param config - Either a PermissionTemplateConfig (for template-based permissions)\n * or a PermissionSchema (for custom permissions)\n * @returns The schema with permission metadata attached\n *\n * @example\n * // Using a template\n * const ProjectSchema = withPermissions(\n * z.object({ title: z.string(), User: z.string() }),\n * { template: 'owner-only', ownerField: 'User' }\n * );\n *\n * @example\n * // Using custom rules\n * const ProjectSchema = withPermissions(\n * z.object({ title: z.string() }),\n * { listRule: '@request.auth.id != \"\"', viewRule: '' }\n * );\n *\n * @example\n * // Using template with custom rule overrides\n * const ProjectSchema = withPermissions(\n * z.object({ title: z.string(), User: z.string() }),\n * {\n * template: 'owner-only',\n * ownerField: 'User',\n * customRules: { listRule: '@request.auth.id != \"\"' }\n * }\n * );\n */\nexport function withPermissions<T extends z.ZodTypeAny>(\n schema: T,\n config: PermissionTemplateConfig | PermissionSchema\n): T {\n // Create metadata object with permissions config directly\n // The PermissionAnalyzer will handle resolving templates vs direct schemas\n const metadata = {\n permissions: config,\n };\n\n // Attach permission metadata to schema using Zod's describe() method\n // The metadata is serialized as JSON and stored in the schema's description\n return schema.describe(JSON.stringify(metadata)) as T;\n}\n\n/**\n * Attach index definitions to a Zod schema\n *\n * This helper function allows you to define PocketBase indexes alongside your\n * entity schema definitions. The indexes are stored as metadata using Zod's\n * describe() method and will be extracted during migration generation.\n *\n * @param schema - The Zod schema to attach indexes to\n * @param indexes - Array of PocketBase index SQL statements\n * @returns The schema with index metadata attached\n *\n * @example\n * // Define indexes for a user schema\n * const UserSchema = withIndexes(\n * withPermissions(\n * z.object({ name: z.string(), email: z.string().email() }),\n * userPermissions\n * ),\n * [\n * 'CREATE UNIQUE INDEX idx_users_email ON users (email)',\n * 'CREATE INDEX idx_users_name ON users (name)'\n * ]\n * );\n *\n * @example\n * // Single index\n * const ProjectSchema = withIndexes(\n * ProjectDatabaseSchema,\n * ['CREATE INDEX idx_projects_status ON projects (status)']\n * );\n */\nexport function withIndexes<T extends z.ZodTypeAny>(schema: T, indexes: string[]): T {\n // Extract existing metadata if present\n let existingMetadata: any = {};\n\n if (schema.description) {\n try {\n existingMetadata = JSON.parse(schema.description);\n } catch {\n // If description is not JSON, ignore it\n }\n }\n\n // Merge indexes with existing metadata\n const metadata = {\n ...existingMetadata,\n indexes,\n };\n\n // Attach metadata to schema using Zod's describe() method\n return schema.describe(JSON.stringify(metadata)) as T;\n}\n","import { z } from \"zod\";\nimport { baseSchema, withIndexes, withPermissions } from \"./base\";\n\n/** -- User Collections -- */\n// Input schema for forms (includes passwordConfirm for validation)\nexport const UserInputSchema = z.object({\n name: z.string().min(2, \"Name must be longer\").optional(),\n email: z.string().email(),\n password: z.string().min(8, \"Password must be at least 8 characters\"),\n passwordConfirm: z.string(),\n avatar: z.instanceof(File).optional(),\n});\n\n// Database schema (excludes passwordConfirm, includes avatar as file field)\nconst UserDatabaseSchema = z.object({\n name: z.string().min(2, \"Name must be longer\").optional(),\n email: z.string().email(),\n password: z.string().min(8, \"Password must be at least 8 characters\"),\n avatar: z.instanceof(File).optional(),\n});\n\n// Apply permissions and indexes for auth collection\n// Users can view all profiles, but only manage their own\nexport const UserSchema = withIndexes(\n withPermissions(UserDatabaseSchema.extend(baseSchema), {\n // Users can list other users (for mentions, user search, etc.)\n listRule: \"id = @request.auth.id\",\n // Users can view their own profile\n viewRule: \"id = @request.auth.id\",\n // Anyone can create an account (sign up)\n createRule: \"\",\n // Users can only update their own profile\n updateRule: \"id = @request.auth.id\",\n // Users can only delete their own account\n deleteRule: \"id = @request.auth.id\",\n // Users can only manage their own account (change email, password, etc.)\n manageRule: \"id = @request.auth.id\",\n }),\n [\n // Email should be unique for authentication\n \"CREATE UNIQUE INDEX idx_users_email ON users (email)\",\n // Index on name for user search and sorting\n \"CREATE INDEX idx_users_name ON users (name)\",\n ]\n);\n","import {\n RecordService,\n type ListResult,\n type RecordListOptions,\n type RecordModel,\n type RecordOptions,\n type RecordSubscribeOptions,\n type RecordSubscription,\n type UnsubscribeFunc,\n} from \"pocketbase\";\nimport type { TypedPocketBase } from \"../types\";\n\nexport interface MutatorOptions {\n expand: string[];\n filter: string[];\n sort: string[];\n}\n\n// T represents the output model type that extends RecordModel\n// InputType represents the input type for creation operations\nexport abstract class BaseMutator<T extends RecordModel, InputType> {\n protected pb: TypedPocketBase;\n\n // Define a default property that subclasses will override\n protected options: MutatorOptions = {\n expand: [],\n filter: [],\n sort: [],\n };\n\n constructor(pb: TypedPocketBase, options?: Partial<MutatorOptions>) {\n this.pb = pb;\n\n // Initialize with default options first\n this.initializeOptions();\n if (options) {\n this.overrideOptions(options);\n }\n }\n\n private initializeOptions(): void {\n this.options = this.setDefaults();\n }\n /**\n * Initialize options with class-specific defaults\n * Subclasses should override this instead of directly setting options\n */\n protected setDefaults(): MutatorOptions {\n return {\n expand: [],\n filter: [],\n sort: [],\n };\n }\n\n /**\n * Merge provided options with current options\n */\n protected overrideOptions(newOptions: Partial<MutatorOptions>): void {\n if (newOptions.expand !== undefined) {\n this.options.expand = newOptions.expand;\n }\n if (newOptions.filter !== undefined) {\n this.options.filter = newOptions.filter;\n }\n if (newOptions.sort !== undefined) {\n this.options.sort = newOptions.sort;\n }\n }\n\n /**\n * Get the collection instance\n */\n protected abstract getCollection(): RecordService<T>;\n\n toSnakeCase(str: string): string {\n return str\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n /**\n * Create a new entity\n */\n async create(input: InputType): Promise<T> {\n try {\n const data = await this.validateInput(input);\n const record = await this.entityCreate(data);\n return await this.processRecord(record);\n } catch (error) {\n return this.errorWrapper(error);\n }\n }\n\n /**\n * Update an existing entity\n */\n async update(id: string, input: Partial<T>): Promise<T> {\n try {\n const record = await this.entityUpdate(id, input);\n return await this.processRecord(record);\n } catch (error) {\n return this.errorWrapper(error);\n }\n }\n\n /**\n * Create or update entity (upsert)\n */\n async upsert(input: InputType & { id?: string }): Promise<T> {\n if (input?.id) {\n return await this.update(input.id, input as Partial<T>);\n }\n\n // Implementations should override this method if they need\n // more specific upsert logic like checking for existing entities\n return await this.create(input);\n }\n\n /**\n * Get entity by ID\n */\n async getById(id: string, expand?: string | string[]): Promise<T | null> {\n try {\n const record = await this.entityGetById(id, expand);\n return await this.processRecord(record);\n } catch (error) {\n return this.handleError(error, { allowNotFound: true });\n }\n }\n\n /**\n * Get first entity by filter\n */\n async getFirstByFilter(filter: string | string[], expand?: string | string[], sort?: string): Promise<T | null> {\n try {\n const record = await this.entityGetFirstByFilter(filter, expand, sort);\n return await this.processRecord(record);\n } catch (error) {\n return this.handleError(error, { allowNotFound: true });\n }\n }\n\n /**\n * Get list of entities\n */\n async getList(\n page = 1,\n perPage = 100,\n filter?: string | string[],\n sort?: string,\n expand?: string | string[]\n ): Promise<ListResult<T>> {\n try {\n const result = await this.entityGetList(page, perPage, filter, sort, expand);\n return await this.processListResult(result);\n } catch (error) {\n return this.errorWrapper(error);\n }\n }\n\n /**\n * Delete entity by ID\n */\n async delete(id: string): Promise<boolean> {\n try {\n return await this.entityDelete(id);\n } catch (error) {\n return this.handleError(error, { returnValue: false });\n }\n }\n\n /**\n * Process a single record before returning it\n * Can be overridden to handle special cases like mapped entities\n */\n protected async processRecord(record: T): Promise<T> {\n return record;\n }\n\n /**\n * Process a list result before returning it\n * Can be overridden to handle special cases like mapped entities\n */\n protected async processListResult(result: ListResult<T>): Promise<ListResult<T>> {\n // Process each item in the list\n const processedItems = await Promise.all(result.items.map((item) => this.processRecord(item)));\n\n return {\n ...result,\n items: processedItems,\n };\n }\n\n /**\n * Prepare expand parameter\n * Combines default expands with provided expands\n */\n protected prepareExpand(expand?: string | string[]): string | undefined {\n // Handle empty defaults case\n if (!this.options.expand.length && !expand) {\n return undefined;\n }\n\n // Convert all inputs to arrays for easy processing\n let expandArray: string[] = [...this.options.expand];\n\n if (expand) {\n // If expand is a string, split it and add the parts\n if (typeof expand === \"string\") {\n expandArray = expandArray.concat(expand.split(\",\").map((e) => e.trim()));\n }\n // If expand is already an array, concatenate\n else {\n expandArray = expandArray.concat(expand);\n }\n }\n\n // Filter out duplicates, empty strings, and undefined values\n const uniqueExpands = [...new Set(expandArray)].filter((e) => e !== \"\" && e !== undefined);\n\n // If no valid expands, return undefined\n if (!uniqueExpands.length) {\n return undefined;\n }\n\n // Join with comma and space\n return uniqueExpands.join(\",\");\n }\n\n /**\n * Prepare filter parameter\n * Combines default filters with provided filters\n */\n protected prepareFilter(filter?: string | string[]): string | undefined {\n // Handle empty case\n if (!this.options.filter.length && !filter) {\n return undefined;\n }\n\n // Convert all inputs to arrays for easy processing\n let filterArray: string[] = [...this.options.filter];\n\n if (filter) {\n // If filter is a string, add it as is (it might contain && already)\n if (typeof filter === \"string\") {\n if (filter) filterArray.push(filter);\n }\n // If filter is an array, concatenate\n else {\n filterArray = filterArray.concat(filter);\n }\n }\n\n // Filter out empty strings and undefined values\n const validFilters = filterArray.filter((f) => f !== \"\" && f !== undefined);\n\n // If no valid filters, return undefined\n if (!validFilters.length) {\n return undefined;\n }\n\n // Join with AND operator\n return validFilters.join(\"&&\");\n }\n\n /**\n * Prepare sort parameter\n * Uses provided sort or falls back to default sort\n */\n protected prepareSort(sort?: string): string | undefined {\n // If explicit sort is provided and not empty, use it (overriding defaults)\n if (sort && sort !== \"\") {\n return sort;\n }\n\n // If no explicit sort but we have defaults\n if (this.options.sort.length) {\n // Filter out empty and undefined values\n const validSorts = this.options.sort.filter((s) => s !== \"\" && s !== undefined);\n\n // If we have valid sort items after filtering\n if (validSorts.length) {\n return validSorts.join(\",\");\n }\n }\n\n // No sort specified\n return undefined;\n }\n\n /**\n * Perform the actual create operation\n */\n protected async entityCreate(data: InputType): Promise<T> {\n return await this.getCollection().create(data as Record<string, any>);\n }\n\n /**\n * Perform the actual update operation\n */\n protected async entityUpdate(id: string, data: Partial<T>): Promise<T> {\n return await this.getCollection().update(id, data);\n }\n\n /**\n * Perform the actual getById operation\n */\n protected async entityGetById(id: string, expand?: string | string[]): Promise<T> {\n const finalExpand = this.prepareExpand(expand);\n const options: RecordOptions = finalExpand ? { expand: finalExpand } : {};\n return await this.getCollection().getOne(id, options);\n }\n\n /**\n * Perform the actual getFirstByFilter operation\n */\n protected async entityGetFirstByFilter(\n filter: string | string[],\n expand?: string | string[],\n sort?: string\n ): Promise<T> {\n const finalFilter = this.prepareFilter(filter);\n const finalExpand = this.prepareExpand(expand);\n const finalSort = this.prepareSort(sort);\n\n const options: RecordListOptions = {};\n if (finalExpand) options.expand = finalExpand;\n if (finalSort) options.sort = finalSort;\n\n return await this.getCollection().getFirstListItem(finalFilter || \"\", options);\n }\n\n /**\n * Perform the actual getList operation\n * Returns a list result with items of type T\n */\n protected async entityGetList(\n page: number,\n perPage: number,\n filter?: string | string[],\n sort?: string,\n expand?: string | string[]\n ): Promise<ListResult<T>> {\n const finalFilter = this.prepareFilter(filter);\n const finalExpand = this.prepareExpand(expand);\n const finalSort = this.prepareSort(sort);\n\n const options: RecordListOptions = {};\n if (finalFilter) options.filter = finalFilter;\n if (finalExpand) options.expand = finalExpand;\n if (finalSort) options.sort = finalSort;\n\n return await this.getCollection().getList(page, perPage, options);\n }\n\n /**\n * Perform the actual delete operation\n */\n protected async entityDelete(id: string): Promise<boolean> {\n await this.getCollection().delete(id);\n return true;\n }\n\n /**\n * Error handler for common errors\n * @param error The error to handle\n * @param options Handler options\n * @returns The value to return if the error is handled, or throws if not handled\n */\n protected handleError<R>(\n error: any,\n options: {\n allowNotFound?: boolean;\n returnValue?: R;\n logError?: boolean;\n } = { logError: true }\n ): R {\n const { allowNotFound = false, returnValue, logError = true } = options;\n\n // Log the error if requested\n if (logError) {\n console.error(`Error in ${this.constructor.name}:`, error);\n }\n\n // Handle 404 errors if allowed\n if (allowNotFound && this.isNotFoundError(error)) {\n return null as R;\n }\n\n // Return specified value or rethrow\n if (returnValue !== undefined) {\n return returnValue;\n }\n\n // Rethrow the error\n throw error;\n }\n\n /**\n * Check if an error is a \"not found\" error\n */\n protected isNotFoundError(error: any): boolean {\n return (\n error instanceof Error && (error.message.includes(\"404\") || error.message.toLowerCase().includes(\"not found\"))\n );\n }\n\n /**\n * Standard error handling wrapper (legacy method, consider using handleError instead)\n */\n protected errorWrapper(error: any): never {\n console.error(`Error in ${this.constructor.name}:`, error);\n throw error;\n }\n\n /**\n * Validate input data before creating/updating\n * Should be implemented by child classes\n */\n protected abstract validateInput(input: InputType): Promise<InputType>;\n\n /**\n * Subscribe to changes on a specific record\n * @param id The ID of the record to subscribe to\n * @param callback Function to call when changes occur\n * @param expand Optional expand parameters\n * @returns Promise that resolves to an unsubscribe function\n */\n async subscribeToRecord(\n id: string,\n callback: (data: RecordSubscription<T>) => void,\n expand?: string | string[]\n ): Promise<UnsubscribeFunc> {\n const finalExpand = this.prepareExpand(expand);\n const options: RecordSubscribeOptions = finalExpand ? { expand: finalExpand } : {};\n\n return this.getCollection().subscribe(id, callback, options);\n }\n\n /**\n * Subscribe to changes on the entire collection\n * @param callback Function to call when changes occur\n * @param expand Optional expand parameters\n * @returns Promise that resolves to an unsubscribe function\n */\n async subscribeToCollection(\n callback: (data: RecordSubscription<T>) => void,\n expand?: string | string[]\n ): Promise<UnsubscribeFunc> {\n const finalExpand = this.prepareExpand(expand);\n const options: RecordSubscribeOptions = finalExpand ? { expand: finalExpand } : {};\n\n return this.getCollection().subscribe(\"*\", callback, options);\n }\n\n /**\n * Unsubscribe from a specific record's changes\n * @param id The ID of the record to unsubscribe from\n */\n unsubscribeFromRecord(id: string): void {\n this.getCollection().unsubscribe(id);\n }\n\n /**\n * Unsubscribe from collection-wide changes\n */\n unsubscribeFromCollection(): void {\n this.getCollection().unsubscribe(\"*\");\n }\n\n /**\n * Unsubscribe from all subscriptions in this collection\n */\n unsubscribeAll(): void {\n this.getCollection().unsubscribe();\n }\n}\n","import { UserInputSchema } from \"../schema\";\nimport type { UserInputType, UserType } from \"../types\";\nimport { BaseMutator, type MutatorOptions } from \"./baseMutator\";\n\nexport class UserMutator extends BaseMutator<UserType, UserInputType> {\n protected setDefaults(): MutatorOptions {\n return {\n expand: [],\n filter: [],\n sort: [\"-updated\"],\n };\n }\n\n protected getCollection() {\n return this.pb.collection(\"Projects\");\n }\n\n protected async validateInput(input: UserInputType) {\n return UserInputSchema.parse(input);\n }\n}\n"]}
|