import { z } from 'zod'; export const bundleSchemaVersionSchema = z.literal(1); export const bundleTargetSchema = z.enum([ 'cursor', 'agents', 'claude', 'copilot', ]); export const bundleArtifactMetadataSchema = z.object({ kind: z.enum([ 'manifest', 'tokens', 'design-system', 'readme', 'helper', 'component', ]), key: z.string().min(1), label: z.string().min(1), path: z.string().min(1), etag: z.string().min(1), updatedAt: z.string().datetime(), target: bundleTargetSchema.optional(), componentId: z.string().optional(), contentType: z.enum(['application/json', 'text/markdown']), }); const bundleManifestRelationSchema = z.object({ type: z.string().min(1), componentId: z.string().min(1), name: z.string().min(1), }); const bundleManifestCompoundChildSchema = z.object({ componentId: z.string().min(1), name: z.string().min(1), }); export const bundleManifestComponentEntrySchema = z.object({ componentId: z.string().min(1), file: z.string().min(1), name: z.string().min(1), publicSlug: z.string().nullable(), tier: z.enum(['core', 'composition']), category: z.string().min(1), status: z.string().min(1), description: z.string(), propCount: z.number().int().nonnegative(), hasExamples: z.boolean(), hasCompoundChildren: z.boolean(), relations: z.array(bundleManifestRelationSchema), compoundChildren: z.array(bundleManifestCompoundChildSchema), }); export const bundleManifestSchema = z.object({ schemaVersion: bundleSchemaVersionSchema, catalogRevision: z.string().min(1), catalogUpdatedAt: z.string().datetime(), org: z.object({ id: z.string().min(1), name: z.string().min(1), slug: z.string().min(1), }), designSystem: z.object({ name: z.string().min(1), packageName: z.string().nullable(), importPath: z.string().nullable(), }), sourceBinding: z.object({ bindingId: z.string().min(1), projectId: z.string().min(1), projectName: z.string().min(1), repoFullName: z.string().min(1), resolution: z.enum(['explicit', 'auto']), }), totalComponents: z.number().int().nonnegative(), totalTokens: z.number().int().nonnegative(), tokenCategories: z.record(z.string(), z.number().int().nonnegative()), components: z.record(z.string(), bundleManifestComponentEntrySchema), }); const bundleTokenEntrySchema = z.object({ name: z.string().min(1), path: z.array(z.string().min(1)), category: z.string().min(1), value: z.string(), type: z.string().optional(), description: z.string().optional(), }); export const bundleTokenFileSchema = z.object({ schemaVersion: bundleSchemaVersionSchema, catalogRevision: z.string().min(1), catalogUpdatedAt: z.string().datetime(), categories: z.record( z.string(), z.object({ count: z.number().int().nonnegative(), tokens: z.array(bundleTokenEntrySchema), }), ), flat: z.array(bundleTokenEntrySchema), }); export const bundleComponentShardSchema = z.object({ schemaVersion: bundleSchemaVersionSchema, catalogRevision: z.string().min(1), catalogUpdatedAt: z.string().datetime(), componentId: z.string().min(1), file: z.string().min(1), component: z.object({ componentKey: z.string().min(1), publicRef: z.string().min(1), publicId: z.string().nullable(), publicSlug: z.string().nullable(), isCanonical: z.boolean().optional(), name: z.string().min(1), tier: z.enum(['core', 'composition']), category: z.string().min(1), status: z.string().min(1), description: z.string(), usageGuidance: z.string(), dos: z.array(z.string()), donts: z.array(z.string()), props: z.record(z.string(), z.unknown()), relations: z.array(z.record(z.string(), z.unknown())), compoundChildren: z.array(bundleManifestCompoundChildSchema), examples: z.array(z.record(z.string(), z.unknown())), source: z.literal('design-system'), sourcePath: z.string().optional(), sourceRepoFullName: z.string().optional(), parentComponentName: z.string().optional(), parentComponentKey: z.string().optional(), }), }); export type BundleSchemaVersion = z.infer; export type BundleTarget = z.infer; export type BundleArtifactMetadata = z.infer< typeof bundleArtifactMetadataSchema >; export type BundleManifestComponentEntry = z.infer< typeof bundleManifestComponentEntrySchema >; export type BundleManifest = z.infer; export type BundleComponentShard = z.infer; export type BundleTokenFile = z.infer;