{"version":3,"file":"index12.cjs","sources":["../src/schemas/relationships.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Entity Relationship\n * \n * Represents a typed relationship between entities using URIs as coordinates.\n * URIs follow the pattern: redaksjon://{type}/{id}\n * \n * Examples:\n *   - redaksjon://person/pete_wagner\n *   - redaksjon://company/acme-corp\n *   - redaksjon://term/kubernetes\n *   - redaksjon://project/protokoll\n */\nexport const EntityRelationshipSchema = z.object({\n    /**\n     * The URI of the related entity\n     * Format: redaksjon://{type}/{id}\n     */\n    uri: z.string().regex(\n        /^redaksjon:\\/\\/[a-z]+\\/[a-zA-Z0-9._-]+$/,\n        { message: 'URI must be in format: redaksjon://{type}/{id}' }\n    ),\n    \n    /**\n     * The type of relationship (freeform)\n     * Examples: \"works_at\", \"manages\", \"related_to\", \"depends_on\", \"part_of\"\n     */\n    relationship: z.string(),\n    \n    /**\n     * Optional notes about this relationship\n     */\n    notes: z.string().optional(),\n    \n    /**\n     * Optional metadata\n     */\n    metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport type EntityRelationship = z.infer<typeof EntityRelationshipSchema>;\n\n/**\n * Relationships field for all entities\n * Array of typed relationships to other entities\n */\nexport const RelationshipsSchema = z.array(EntityRelationshipSchema).optional();\n\n/**\n * Helper function to create a relationship URI\n */\nexport function createEntityUri(type: string, id: string): string {\n    return `redaksjon://${type}/${id}`;\n}\n\n/**\n * Helper function to parse a relationship URI\n */\nexport function parseEntityUri(uri: string): { type: string; id: string } | null {\n    const match = uri.match(/^redaksjon:\\/\\/([a-z]+)\\/([a-zA-Z0-9._-]+)$/);\n    if (!match) return null;\n    return {\n        type: match[1],\n        id: match[2],\n    };\n}\n\n/**\n * Helper function to create a relationship\n */\nexport function createRelationship(\n    targetType: string,\n    targetId: string,\n    relationship: string,\n    notes?: string,\n    metadata?: Record<string, unknown>\n): EntityRelationship {\n    return {\n        uri: createEntityUri(targetType, targetId),\n        relationship,\n        notes,\n        metadata,\n    };\n}\n"],"names":["z"],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