/** * Parse the Compose Spec JSON Schema into ParsedResult entries. * * The Compose spec defines a top-level "services", "volumes", "networks", * "configs", and "secrets" map — each value is a typed resource. * We model those as the five Compose entity types. */ export interface ComposeParseResult { typeName: string; // e.g. "Docker::Compose::Service" shortName: string; // e.g. "Service" description?: string; properties: ComposeProperty[]; isResource: boolean; } export interface ComposeProperty { name: string; type: string; description?: string; required?: boolean; enum?: string[]; } /** * Parse the Compose Spec JSON Schema buffer into ParsedResult entries. * Returns one entry per top-level Compose resource type. */ export function parseComposeSpec(_data: Buffer): ComposeParseResult[] { // The Compose spec is complex; we hand-define the five core resource types // and extract key properties from the schema for documentation/type generation. // Full deep parsing happens during codegen; here we return the structural outline. return [ { typeName: "Docker::Compose::Service", shortName: "Service", description: "A containerized service definition in Docker Compose", isResource: true, properties: [ { name: "image", type: "string", description: "Container image to use" }, { name: "build", type: "object", description: "Build configuration" }, { name: "command", type: "string | string[]", description: "Override the default command" }, { name: "entrypoint", type: "string | string[]", description: "Override the default entrypoint" }, { name: "environment", type: "Record", description: "Environment variables" }, { name: "ports", type: "string[]", description: "Published ports" }, { name: "volumes", type: "string[]", description: "Volume mounts" }, { name: "networks", type: "string[]", description: "Networks to attach" }, { name: "depends_on", // Compose `depends_on` is a oneOf: short list-form, or long form with a // wait condition (service_started/healthy/completed_successfully). type: 'string[] | Record', description: "Service dependencies (short list-form, or long form with a wait condition)", }, { name: "restart", type: "string", description: "Restart policy" }, { name: "labels", type: "Record", description: "Container labels" }, { name: "healthcheck", type: "object", description: "Health check configuration" }, { name: "deploy", type: "object", description: "Swarm deployment configuration" }, { name: "secrets", type: "string[]", description: "Secrets to expose" }, { name: "configs", type: "string[]", description: "Configs to expose" }, ], }, { typeName: "Docker::Compose::Volume", shortName: "Volume", description: "A named volume definition in Docker Compose", isResource: true, properties: [ { name: "driver", type: "string", description: "Volume driver" }, { name: "driver_opts", type: "Record", description: "Driver options" }, { name: "external", type: "boolean", description: "Whether the volume is external" }, { name: "labels", type: "Record", description: "Volume labels" }, { name: "name", type: "string", description: "Custom volume name" }, ], }, { typeName: "Docker::Compose::Network", shortName: "Network", description: "A network definition in Docker Compose", isResource: true, properties: [ { name: "driver", type: "string", description: "Network driver" }, { name: "driver_opts", type: "Record", description: "Driver options" }, { name: "external", type: "boolean", description: "Whether the network is external" }, { name: "labels", type: "Record", description: "Network labels" }, { name: "internal", type: "boolean", description: "Restrict external access" }, { name: "ipam", type: "object", description: "IP address management" }, ], }, { typeName: "Docker::Compose::Config", shortName: "Config", description: "A config definition in Docker Compose", isResource: true, properties: [ { name: "file", type: "string", description: "Path to the config file" }, { name: "external", type: "boolean", description: "Whether the config is external" }, { name: "labels", type: "Record", description: "Config labels" }, { name: "name", type: "string", description: "Custom config name" }, ], }, { typeName: "Docker::Compose::Secret", shortName: "Secret", description: "A secret definition in Docker Compose", isResource: true, properties: [ { name: "file", type: "string", description: "Path to the secret file" }, { name: "external", type: "boolean", description: "Whether the secret is external" }, { name: "labels", type: "Record", description: "Secret labels" }, { name: "name", type: "string", description: "Custom secret name" }, ], }, ]; }