@highstate/contract 0.17.0 → 0.19.1

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/i18n.ts","../src/meta.ts","../src/entity.ts","../src/evaluation.ts","../src/component.ts","../src/instance.ts","../src/unit.ts","../src/trigger.ts","../src/pulumi.ts","../src/terminal.ts","../src/page.ts","../src/worker.ts","../src/compaction.ts","../src/utils.ts"],"names":["text","z","outputs","mapValues","inputs","HighstateSignature","WellKnownInstanceCustomStatus","HighstateConfigKey","visitedIds","indent","pickBy","isNonNullish"],"mappings":";;;;;;;;AAAA,IAAM,qBAAA,uBAA4B,GAAA,EAAoB;AAE/C,SAAS,2BAA2B,aAAA,EAAyB;AAClE,EAAA,KAAA,MAAW,QAAQ,aAAA,EAAe;AAChC,IAAA,MAAM,KAAA,GAAQ,KAAK,WAAA,EAAY;AAC/B,IAAA,IAAI,CAAC,qBAAA,CAAsB,GAAA,CAAI,KAAK,CAAA,EAAG;AACrC,MAAA,qBAAA,CAAsB,GAAA,CAAI,OAAO,IAAI,CAAA;AAAA,IACvC;AAAA,EACF;AACF;AAEO,SAAS,uBAAA,GAA0B;AACxC,EAAA,qBAAA,CAAsB,KAAA,EAAM;AAC9B;AAEO,SAAS,yBAAyBA,KAAAA,EAAc;AAGrD,EAAA,MAAM,KAAA,GAAQA,MACX,KAAA,CAAM,qDAAqD,EAC3D,MAAA,CAAO,CAAA,IAAA,KAAQ,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AAEjC,EAAA,OAAO,KAAA,CACJ,IAAI,CAAA,IAAA,KAAQ;AACX,IAAA,MAAM,KAAA,GAAQ,KAAK,WAAA,EAAY;AAC/B,IAAA,IAAI,qBAAA,CAAsB,GAAA,CAAI,KAAK,CAAA,EAAG;AACpC,MAAA,OAAO,qBAAA,CAAsB,IAAI,KAAK,CAAA;AAAA,IACxC;AAEA,IAAA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O,SAAS,WAAA,CACd,GAAA,EACA,GAAA,EACA,QAAA,EACQ;AACR,EAAA,MAAM,QAAA,GAAW,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA;AAC5B,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,MAAM,KAAA,GAAQ,SAAS,GAAG,CAAA;AAC1B,EAAA,GAAA,CAAI,GAAA,CAAI,KAAK,KAAK,CAAA;AAClB,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,aAAgD,GAAA,EAAQ;AACtE,EAAA,OAAOC,MAAAA,CAAO,KAAKC,YAAY,CAAA;AACjC","file":"index.js","sourcesContent":["const knownAbbreviationsMap = new Map<string, string>()\n\nexport function registerKnownAbbreviations(abbreviations: string[]) {\n for (const abbr of abbreviations) {\n const lower = abbr.toLowerCase()\n if (!knownAbbreviationsMap.has(lower)) {\n knownAbbreviationsMap.set(lower, abbr)\n }\n }\n}\n\nexport function clearKnownAbbreviations() {\n knownAbbreviationsMap.clear()\n}\n\nexport function camelCaseToHumanReadable(text: string) {\n // split on: word boundaries between consecutive uppercase and lowercase letters,\n // single uppercase letters followed by lowercase, and separators\n const words = text\n .split(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|_|-|\\./)\n .filter(word => word.length > 0)\n\n return words\n .map(word => {\n const lower = word.toLowerCase()\n if (knownAbbreviationsMap.has(lower)) {\n return knownAbbreviationsMap.get(lower)\n }\n\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join(\" \")\n}\n","import { z } from \"zod\"\n\nexport const objectMetaSchema = z.object({\n /**\n * Human-readable name of the object.\n *\n * Used in UI components for better user experience.\n */\n title: z.string().optional(),\n\n /**\n * The title used globally for the object.\n *\n * For example, the title of an instance secret is \"Password\" which is okay\n * to display in the instance secret list, but when the secret is displayed in a\n * global secret list the name should be more descriptive, like \"Proxmox Password\".\n */\n globalTitle: z.string().optional(),\n\n /**\n * Description of the object.\n *\n * Provides additional context for users and developers.\n */\n description: z.string().optional(),\n\n /**\n * The color of the object.\n *\n * Used in UI components to visually distinguish objects.\n */\n color: z.string().optional(),\n\n /**\n * Primary icon identifier.\n *\n * Should reference a iconify icon name, like \"mdi:server\" or \"gg:remote\".\n */\n icon: z.string().optional(),\n\n /**\n * The color of the primary icon.\n */\n iconColor: z.string().optional(),\n\n /**\n * The URL of the custom image that should be used as the icon or avatar.\n */\n avatarUrl: z.string().optional(),\n\n /**\n * The secondary icon identifier.\n *\n * Used to provide additional context or actions related to the object.\n *\n * Should reference a iconify icon name, like \"mdi:edit\" or \"mdi:delete\".\n */\n secondaryIcon: z.string().optional(),\n\n /**\n * The color of the secondary icon.\n */\n secondaryIconColor: z.string().optional(),\n})\n\n/**\n * The schema for object metadata used in more than a half of the Highstate objects.\n *\n * Consists of `title`, `description`, `icon`, and `iconColor` fields where the `title` is required.\n */\nexport const commonObjectMetaSchema = objectMetaSchema\n .pick({\n title: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({\n title: true,\n })\n\nexport const globalCommonObjectMetaSchema = objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({\n title: true,\n })\n\nexport const serviceAccountMetaSchema = objectMetaSchema\n .pick({\n title: true,\n description: true,\n avatarUrl: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true })\n\nexport const timestampsSchema = z.object({\n /**\n * The timestamp when the object was created.\n */\n createdAt: z.date(),\n\n /**\n * The timestamp when the object was last updated.\n */\n updatedAt: z.date(),\n})\n\n/**\n * The schema for strings that represent names in Highstate.\n *\n * The name:\n * - must be alphanumeric;\n * - can include dashes (`-`) as word separators and dots (`.`) as namespace separators;\n * - must begin with a letter;\n * - must be lowercase;\n * - must include from 2 to 64 characters.\n */\nexport const genericNameSchema = z\n .string()\n .regex(\n /^[a-z][a-z0-9-.]+$/,\n \"Name must start with a letter and can only contain lowercase letters, numbers, dashes (-) and dots (.)\",\n )\n .min(2)\n .max(64)\n\nexport const versionedNameSchema = z.union([\n z.templateLiteral([genericNameSchema, z.literal(\".\"), z.literal(\"v\"), z.number().int().min(1)]),\n\n // to prevent TypeScript matching \"proxmox.virtual-machine.v2\" as\n // 1. \"proxmox.v\"\n // 2. \"irtual-machine.v2\" and thinking it should be a number\n z.templateLiteral([\n genericNameSchema,\n z.literal(\".\"),\n genericNameSchema,\n z.literal(\".\"),\n z.literal(\"v\"),\n z.number().int().min(1),\n ]),\n z.templateLiteral([\n genericNameSchema,\n z.literal(\".\"),\n genericNameSchema,\n z.literal(\".\"),\n genericNameSchema,\n z.literal(\".\"),\n z.literal(\"v\"),\n z.number().int().min(1),\n ]),\n])\n\n/**\n * Parses a versioned name into its base name and version.\n *\n * @param name The versioned name to parse.\n * @returns A tuple containing the base name and version number.\n * @throws If the name is not in the correct format or if the version is invalid.\n */\nexport function parseVersionedName(name: string): [name: string, version: number] {\n const lastDotVIndex = name.lastIndexOf(\".v\")\n if (lastDotVIndex === -1) {\n throw new Error(`Invalid versioned name: ${name}`)\n }\n\n const baseName = name.substring(0, lastDotVIndex)\n const versionPart = name.substring(lastDotVIndex + 2) // +2 to skip \".v\"\n\n const version = parseInt(versionPart, 10)\n if (Number.isNaN(version) || version < 0) {\n throw new Error(`Invalid version in versioned name: ${name}`)\n }\n\n return [baseName, version]\n}\n\n/**\n * The schema for field names in Highstate.\n *\n * The field name:\n * - must be alphanumeric;\n * - must be in camelCase;\n * - must begin with a letter;\n * - must include from 2 to 64 characters.\n */\nexport const fieldNameSchema = z\n .string()\n .regex(/^[a-z][a-zA-Z0-9]+$/, \"Field name must start with a letter and be in camelCase format\")\n .min(2)\n .max(64)\n\nexport type ObjectMeta = z.infer<typeof objectMetaSchema>\nexport type CommonObjectMeta = z.infer<typeof commonObjectMetaSchema>\nexport type GlobalCommonObjectMeta = z.infer<typeof globalCommonObjectMetaSchema>\nexport type ServiceAccountMeta = z.infer<typeof serviceAccountMetaSchema>\nexport type GenericName = z.infer<typeof genericNameSchema>\nexport type VersionedName = z.infer<typeof versionedNameSchema>\nexport type FieldName = z.infer<typeof fieldNameSchema>\n","import type { IsEmptyObject, Simplify } from \"type-fest\"\nimport type { PartialKeys } from \"./utils\"\nimport { z } from \"zod\"\nimport { camelCaseToHumanReadable } from \"./i18n\"\nimport {\n objectMetaSchema,\n parseVersionedName,\n type VersionedName,\n versionedNameSchema,\n} from \"./meta\"\n\nexport const entityInclusionSchema = z.object({\n /**\n * The static type of the included entity.\n */\n type: versionedNameSchema,\n\n /**\n * Whether the included entity is required.\n * If false, the entity may be omitted.\n */\n required: z.boolean(),\n\n /**\n * Whether the included entity is multiple.\n */\n multiple: z.boolean(),\n\n /**\n * The name of the field where the included entity is embedded.\n */\n field: z.string(),\n})\n\n/**\n * The entity is some abstract object which can be passed from one component to another through their inputs and outputs.\n * Every entity must have a type.\n * Every component inputs and outputs will reference such types and only entities of the same type can be passed.\n */\nexport const entityModelSchema = z.object({\n /**\n * The static type of the entity.\n */\n type: versionedNameSchema,\n\n /**\n * The list of all extended entity types (direct and indirect).\n */\n extensions: z.string().array().optional(),\n\n /**\n * The list of directly extended entity types.\n */\n directExtensions: z.string().array().optional(),\n\n /**\n * The list of all included entities (directly or inherited from extensions).\n */\n inclusions: entityInclusionSchema.array().optional(),\n\n /**\n * The list of directly included entities.\n */\n directInclusions: entityInclusionSchema.array().optional(),\n\n /**\n * The JSON schema of the entity value.\n */\n schema: z.custom<z.core.JSONSchema.BaseSchema>(),\n\n /**\n * The extra metadata of the entity.\n */\n meta: objectMetaSchema.required({ title: true }).pick({\n title: true,\n description: true,\n color: true,\n icon: true,\n iconColor: true,\n }),\n\n /**\n * The CRC32 of the entity definition.\n */\n definitionHash: z.number(),\n})\n\nexport type EntityInclusion = z.infer<typeof entityInclusionSchema>\nexport type EntityModel = z.infer<typeof entityModelSchema>\nexport type EntityTypes = Record<VersionedName, true>\n\nexport declare const implementedTypes: unique symbol\n\nexport type Entity<\n TType extends VersionedName = VersionedName,\n TImplementedTypes extends EntityTypes = EntityTypes,\n TSchema extends z.ZodTypeAny = z.ZodTypeAny,\n> = {\n /**\n * The static type of the entity.\n */\n type: TType\n\n /**\n * The all types implemented by this entity including its own type.\n *\n * Does not exist at runtime.\n */\n [implementedTypes]: TImplementedTypes\n\n /**\n * The zod schema of the entity value.\n */\n schema: TSchema\n\n /**\n * The model of the entity.\n */\n model: EntityModel\n}\n\ntype EntityOptions<\n TType extends VersionedName,\n TSchema extends z.ZodType,\n TExtends extends Record<string, Entity>,\n TIncludes extends Record<string, EntityIncludeRef>,\n> = {\n /**\n * The static type of the entity.\n */\n type: TType\n\n /**\n * The JSON schema of the entity value.\n */\n schema: TSchema\n\n /**\n * The extra metadata of the entity.\n */\n meta?: PartialKeys<z.infer<typeof objectMetaSchema>, \"title\">\n\n /**\n * The list of entities to extend.\n *\n * The intersection of them will be used as the base schema and then intersected again with the provided schema.\n *\n * Note: Intersection does not mean inheritance or blind property merging.\n * If two base types have field with the same name but different types,\n * the resulting type of the field will be the intersection of the two types (and most likely `never`).\n */\n extends?: TExtends\n\n /**\n * The list of entities to include.\n *\n * Inclusion is more powerful mechanism that allows to embed other entities into this entity\n * and then substitute them instead of this entity when connected to component inputs of included types.\n */\n includes?: TIncludes\n}\n\nexport type EntityIncludeRef = Entity | { entity: Entity; multiple?: boolean; required?: boolean }\n\nfunction isEntityIncludeRef(\n value: EntityIncludeRef,\n): value is { entity: Entity; multiple?: boolean; required?: boolean } {\n return typeof value === \"object\" && value !== null && \"entity\" in value\n}\n\ntype InclusionShape<TImplements extends Record<string, EntityIncludeRef>> = {\n [K in keyof TImplements]: TImplements[K] extends {\n entity: infer E\n multiple?: infer M\n required?: infer R\n }\n ? E extends Entity\n ? M extends true\n ? R extends false\n ? z.ZodOptional<z.ZodArray<E[\"schema\"]>>\n : z.ZodArray<E[\"schema\"]>\n : R extends false\n ? z.ZodOptional<E[\"schema\"]>\n : E[\"schema\"]\n : never\n : TImplements[K] extends Entity\n ? TImplements[K][\"schema\"]\n : never\n}\n\ntype AddSchemaExtensions<\n TSchema extends z.ZodTypeAny,\n TExtends extends Record<string, Entity>,\n> = TExtends extends Record<string, never>\n ? TSchema\n : IsEmptyObject<TExtends> extends true\n ? TSchema\n : {\n [K in keyof TExtends]: AddSchemaExtensions<\n z.ZodIntersection<TSchema, TExtends[K][\"schema\"]>,\n Omit<TExtends, K>\n >\n }[keyof TExtends]\n\ntype AddTypeExtensions<\n TImplementedTypes extends EntityTypes,\n TExtends extends Record<string, Entity>,\n> = TExtends extends Record<string, never>\n ? TImplementedTypes\n : IsEmptyObject<TExtends> extends true\n ? TImplementedTypes\n : {\n [K in keyof TExtends]: AddTypeExtensions<\n TImplementedTypes & TExtends[K][typeof implementedTypes],\n Omit<TExtends, K>\n >\n }[keyof TExtends]\n\ntype AddSchemaInclusions<\n TSchema extends z.ZodTypeAny,\n TImplements extends Record<string, EntityIncludeRef>,\n> = TImplements extends Record<string, never>\n ? TSchema\n : z.ZodIntersection<TSchema, z.ZodObject<InclusionShape<TImplements>>>\n\ntype AddTypeInclusions<\n TImplementedTypes extends EntityTypes,\n TImplements extends Record<string, EntityIncludeRef>,\n> = TImplements extends Record<string, never>\n ? TImplementedTypes\n : {\n [K in keyof TImplements]: TImplements[K] extends {\n entity: infer E\n }\n ? E extends Entity\n ? AddTypeInclusions<TImplementedTypes & E[typeof implementedTypes], Omit<TImplements, K>>\n : TImplementedTypes\n : TImplements[K] extends Entity\n ? AddTypeInclusions<\n TImplementedTypes & TImplements[K][typeof implementedTypes],\n Omit<TImplements, K>\n >\n : TImplementedTypes\n }[keyof TImplements]\n\nexport function defineEntity<\n TType extends VersionedName,\n TSchema extends z.ZodType,\n TExtends extends Record<string, Entity> = Record<string, never>,\n TImplements extends Record<string, EntityIncludeRef> = Record<string, never>,\n>(\n options: EntityOptions<TType, TSchema, TExtends, TImplements>,\n): Entity<\n TType,\n Simplify<AddTypeInclusions<AddTypeExtensions<{ [K in TType]: true }, TExtends>, TImplements>>,\n AddSchemaExtensions<AddSchemaInclusions<TSchema, TImplements>, TExtends>\n> {\n try {\n entityModelSchema.shape.type.parse(options.type)\n } catch (error) {\n throw new Error(`Invalid entity type \"${options.type}\"`, { cause: error })\n }\n\n if (!options.schema) {\n throw new Error(\"Entity schema is required\")\n }\n\n const includedEntities = Object.entries(options.includes ?? {}).map(([field, entityRef]) => {\n if (isEntityIncludeRef(entityRef)) {\n return {\n entity: entityRef.entity,\n inclusion: {\n type: entityRef.entity.type,\n required: entityRef.required ?? true,\n multiple: entityRef.multiple ?? false,\n field,\n },\n }\n }\n\n return {\n entity: entityRef,\n inclusion: {\n type: entityRef.type,\n required: true,\n multiple: false,\n field,\n },\n }\n })\n\n const inclusionShape = includedEntities.reduce(\n (shape, { entity, inclusion }) => {\n if (inclusion.multiple) {\n shape[inclusion.field] = inclusion.required\n ? entity.schema.array()\n : entity.schema.array().optional()\n } else {\n shape[inclusion.field] = inclusion.required ? entity.schema : entity.schema.optional()\n }\n\n return shape\n },\n {} as Record<string, z.ZodTypeAny>,\n )\n\n let finalSchema = Object.values(options.extends ?? {}).reduce(\n (schema, entity) => z.intersection(schema, entity.schema),\n options.schema as z.ZodType,\n )\n\n if (includedEntities.length > 0) {\n finalSchema = z.intersection(finalSchema, z.object(inclusionShape))\n }\n\n const directInclusions = includedEntities.map(({ inclusion }) => inclusion)\n const directExtensions = Object.values(options.extends ?? {}).map(entity => entity.type)\n\n const inclusions = Object.values(options.extends ?? {}).reduce(\n (incs, entity) => {\n if (entity.model.inclusions) {\n incs.push(...entity.model.inclusions)\n }\n\n return incs\n },\n [...directInclusions],\n )\n\n const extensions = Object.values(options.extends ?? {}).reduce((exts, entity) => {\n exts.push(...(entity.model.extensions ?? []), entity.type)\n\n return exts\n }, [] as string[])\n\n try {\n let _schema: z.core.JSONSchema.BaseSchema\n\n return {\n type: options.type,\n schema: finalSchema,\n model: {\n type: options.type,\n extensions: extensions.length > 0 ? extensions : undefined,\n directExtensions: directExtensions.length > 0 ? directExtensions : undefined,\n inclusions: inclusions.length > 0 ? inclusions : undefined,\n directInclusions: directInclusions.length > 0 ? directInclusions : undefined,\n get schema() {\n if (!_schema) {\n // TODO: forbid unrepresentable types (and find way to filter out \"undefined\" literals)\n _schema = z.toJSONSchema(finalSchema, { target: \"draft-7\", unrepresentable: \"any\" })\n }\n\n return _schema\n },\n meta: {\n ...options.meta,\n title:\n options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),\n },\n // will be calculated by the library loader\n definitionHash: null!,\n },\n // biome-ignore lint/suspicious/noExplicitAny: we already typed return type\n } as any\n } catch (error) {\n throw new Error(`Failed to define entity \"${options.type}\"`, { cause: error })\n }\n}\n\nexport function isEntity(value: unknown): value is Entity {\n return typeof value === \"object\" && value !== null && \"model\" in value\n}\n\n/**\n * Checks whether the given entity can be assigned to the target type.\n *\n * An entity is considered assignable to a target type if:\n * - The entity's type is exactly the same as the target type.\n * - The entity extends the target type (either directly or indirectly).\n * - The entity includes the target type (either directly or indirectly).\n *\n * @param entity The entity to check.\n * @param target The target versioned name to check against.\n * @returns True if the entity is assignable to the target type, false otherwise.\n */\nexport function isAssignableTo(entity: EntityModel, target: VersionedName): boolean {\n if (entity.type === target) {\n return true\n }\n\n if (entity.extensions?.includes(target)) {\n return true\n }\n\n return entity.inclusions?.some(implementation => implementation.type === target) ?? false\n}\n","import type { Component } from \"./component\"\nimport type { InstanceInput, InstanceModel } from \"./instance\"\nimport { mapValues } from \"remeda\"\n\nexport type RuntimeInstance = {\n instance: InstanceModel\n component: Component\n}\n\nexport const boundaryInput = Symbol(\"boundaryInput\")\nexport const boundaryInputs = Symbol(\"boundaryInputs\")\n\nfunction formatInstancePath(instance: InstanceModel): string {\n let result = instance.id\n while (instance.parentId) {\n const parent = runtimeInstances.get(instance.parentId)?.instance\n if (!parent) {\n break\n }\n\n result = `${parent.id} -> ${result}`\n instance = parent\n }\n\n return result\n}\n\nexport class InstanceNameConflictError extends Error {\n constructor(\n readonly instanceId: string,\n readonly firstPath: string,\n readonly secondPath: string,\n ) {\n super(\n `Multiple instances produced with the same instance ID \"${instanceId}\":\\n` +\n `1. ${firstPath}\\n` +\n `2. ${secondPath}`,\n )\n\n this.name = \"InstanceNameConflictError\"\n }\n}\n\nlet currentInstance: InstanceModel | null = null\n\nconst runtimeInstances: Map<string, RuntimeInstance> = new Map()\n\n/**\n * Resets the evaluation state, clearing all collected composite instances and runtime instances.\n */\nexport function resetEvaluation(): void {\n runtimeInstances.clear()\n currentInstance = null\n}\n\n/**\n * Returns all runtime instances collected during the evaluation.\n *\n * Note that these instances are not serializable.\n */\nexport function getRuntimeInstances(): RuntimeInstance[] {\n return Array.from(runtimeInstances.values())\n}\n\nexport function registerInstance<T>(component: Component, instance: InstanceModel, fn: () => T): T {\n const conflicting = runtimeInstances.get(instance.id)\n if (conflicting) {\n throw new InstanceNameConflictError(\n instance.id,\n formatInstancePath(conflicting.instance),\n formatInstancePath(instance),\n )\n }\n\n runtimeInstances.set(instance.id, { instance, component })\n\n let previousParentInstance: InstanceModel | null = null\n\n if (currentInstance) {\n instance.parentId = currentInstance.id\n }\n\n if (component.model.kind === \"composite\") {\n previousParentInstance = currentInstance\n currentInstance = instance\n }\n\n try {\n const outputs = fn() as Record<string, InstanceInput[]>\n\n instance.resolvedOutputs = outputs\n instance.outputs = mapValues(outputs ?? {}, outputs =>\n outputs.map(output => output[boundaryInput] ?? output),\n )\n\n // mark all outputs with the boundary input of the instance\n return mapValues(outputs, (outputs, outputKey) =>\n outputs.map(output => ({\n ...output,\n [boundaryInput]: { instanceId: instance.id, output: outputKey },\n })),\n ) as T\n } finally {\n if (previousParentInstance) {\n currentInstance = previousParentInstance\n }\n }\n}\n","/** biome-ignore-all lint/suspicious/noExplicitAny: maybe fix later */\n\nimport type { Simplify } from \"type-fest\"\nimport type { Entity, implementedTypes } from \"./entity\"\nimport type { OptionalEmptyRecords, OptionalUndefinedFields, PartialKeys } from \"./utils\"\nimport { isNonNullish, mapValues, pickBy, uniqueBy } from \"remeda\"\nimport { z } from \"zod\"\nimport { boundaryInput, boundaryInputs, registerInstance } from \"./evaluation\"\nimport { camelCaseToHumanReadable } from \"./i18n\"\nimport { type InstanceId, type InstanceInput, type InstanceInputGroup, inputKey } from \"./instance\"\nimport {\n fieldNameSchema,\n genericNameSchema,\n objectMetaSchema,\n parseVersionedName,\n type VersionedName,\n versionedNameSchema,\n} from \"./meta\"\n\nexport const runtimeSchema = Symbol(\"runtimeSchema\")\n\nlet validationEnabled = true\n\nexport function setValidationEnabled(enabled: boolean): void {\n validationEnabled = enabled\n}\n\nexport const componentKindSchema = z.enum([\"composite\", \"unit\"])\nexport type ComponentKind = z.infer<typeof componentKindSchema>\n\nexport const componentArgumentSchema = z.object({\n /**\n * The JSON schema of the argument value.\n */\n schema: z.custom<z.core.JSONSchema.BaseSchema>(),\n\n /**\n * The original Zod schema of the argument.\n *\n * Only available at runtime.\n */\n [runtimeSchema]: z.instanceof(z.ZodType).optional(),\n\n /**\n * Whether the argument is required.\n */\n required: z.boolean(),\n\n /**\n * The extra metadata of the argument.\n */\n meta: objectMetaSchema.required({ title: true }).pick({\n title: true,\n globalTitle: true,\n description: true,\n color: true,\n icon: true,\n iconColor: true,\n }),\n})\n\nexport type ComponentArgument = z.infer<typeof componentArgumentSchema>\n\nexport type FullComponentArgumentOptions = {\n schema: z.ZodType\n meta?: PartialKeys<ComponentArgument[\"meta\"], \"title\">\n}\n\nexport type ComponentArgumentOptions = z.ZodType | FullComponentArgumentOptions\n\nexport type ComponentArgumentOptionsToSchema<T extends ComponentArgumentOptions> =\n T extends FullComponentArgumentOptions ? T[\"schema\"] : T\n\nexport const componentInputSchema = z.object({\n /**\n * The type of the entity passed through the input.\n */\n type: versionedNameSchema,\n\n /**\n * Whether the input is required.\n */\n required: z.boolean(),\n\n /**\n * Whether the input can have multiple values.\n */\n multiple: z.boolean(),\n\n /**\n * The extra metadata of the input.\n */\n meta: objectMetaSchema.required({ title: true }).pick({\n title: true,\n description: true,\n }),\n})\n\nexport type ComponentInput = z.infer<typeof componentInputSchema>\n\nexport type FullComponentInputOptions = {\n entity: Entity\n required?: boolean\n multiple?: boolean\n meta?: PartialKeys<ComponentInput[\"meta\"], \"title\">\n}\n\nexport type ComponentInputOptions = Entity | FullComponentInputOptions\n\ntype ComponentInputOptionsToOutputRef<T extends ComponentInputOptions> = T extends Entity\n ? InstanceInput<T[typeof implementedTypes]>\n : T extends FullComponentInputOptions\n ? T[\"required\"] extends false\n ? T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][typeof implementedTypes]>[] | undefined\n : InstanceInput<T[\"entity\"][typeof implementedTypes]> | undefined\n : T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][typeof implementedTypes]>[]\n : InstanceInput<T[\"entity\"][typeof implementedTypes]>\n : never\n\n/**\n * The type-level specification of a component input hold by the component model.\n */\nexport type ComponentInputSpec = [entity: Entity, required: boolean, multiple: boolean]\n\nexport type ComponentInputOptionsToSpec<T extends ComponentInputOptions> = T extends Entity\n ? [T, true, false] // [Entity, required, multiple]\n : T extends FullComponentInputOptions\n ? T[\"required\"] extends false\n ? T[\"multiple\"] extends true\n ? [T[\"entity\"], false, true]\n : [T[\"entity\"], false, false]\n : T[\"multiple\"] extends true\n ? [T[\"entity\"], true, true]\n : [T[\"entity\"], true, false]\n : never\n\nexport type ComponentInputOptionsMapToSpecMap<T extends Record<string, ComponentInputOptions>> =\n T extends Record<string, never>\n ? Record<string, never>\n : { [K in keyof T]: ComponentInputOptionsToSpec<T[K]> }\n\ntype ComponentInputMapToValue<T extends Record<string, ComponentInputOptions>> =\n OptionalUndefinedFields<{\n [K in keyof T]: ComponentInputOptionsToOutputRef<T[K]>\n }>\n\ntype ComponentInputMapToReturnType<T extends Record<string, ComponentInputOptions>> =\n // biome-ignore lint/suspicious/noConfusingVoidType: this is return type\n T extends Record<string, never> ? void : ComponentInputMapToValue<T>\n\nexport type ComponentParams<\n TArgs extends Record<string, ComponentArgumentOptions>,\n TInputs extends Record<string, ComponentInputOptions>,\n> = {\n id: InstanceId\n name: string\n args: { [K in keyof TArgs]: z.infer<ComponentArgumentOptionsToSchema<TArgs[K]>> }\n inputs: ComponentInputMapToValue<TInputs>\n}\n\nexport type InputComponentParams<\n TArgs extends Record<string, unknown>,\n TInputs extends Record<string, unknown>,\n> = {\n name: string\n} & OptionalEmptyRecords<{\n args: TArgs\n inputs: TInputs\n}>\n\nexport type ComponentOptions<\n TType extends VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions>,\n TInputs extends Record<string, ComponentInputOptions>,\n TOutputs extends Record<string, ComponentInputOptions>,\n> = {\n /**\n * The type of the component.\n * Must be a valid versioned name.\n *\n * Examples: `proxmox.virtual-machine.v1`, `common.server.v1`.\n */\n type: TType\n\n /**\n * The extra metadata of the component.\n *\n * If title or defaultNamePrefix is not provided, they will be generated from the type.\n */\n meta?: PartialKeys<ComponentModel[\"meta\"], \"title\" | \"defaultNamePrefix\">\n\n /**\n * The specification of the component arguments.\n */\n args?: TArgs\n\n /**\n * The specification of the component inputs.\n */\n inputs?: TInputs\n\n /**\n * The specification of the component outputs.\n */\n outputs?: TOutputs\n\n /**\n * The create function of the component.\n *\n * It can create instances of other components and return their outputs.\n *\n * Note: All created instances must guarantee unique ids within the project.\n * Their names are not automatically prefixed with the component name,\n * so you must prefix them manually if needed or guarantee uniqueness in another way.\n */\n create: (params: ComponentParams<TArgs, TInputs>) => ComponentInputMapToReturnType<TOutputs>\n\n /**\n * For internal use only.\n */\n [kind]?: ComponentKind\n}\n\n// Models\nexport const componentModelSchema = z.object({\n /**\n * The type of the component.\n */\n type: genericNameSchema,\n\n /**\n * The kind of the component.\n */\n kind: componentKindSchema,\n\n /**\n * The record of the argument schemas.\n */\n args: z.record(fieldNameSchema, componentArgumentSchema),\n\n /**\n * The record of the input schemas.\n */\n inputs: z.record(fieldNameSchema, componentInputSchema),\n\n /**\n * The record of the output schemas.\n */\n outputs: z.record(fieldNameSchema, componentInputSchema),\n\n /**\n * The extra metadata of the component.\n */\n meta: objectMetaSchema\n .required({ title: true })\n .pick({\n title: true,\n description: true,\n color: true,\n icon: true,\n iconColor: true,\n secondaryIcon: true,\n secondaryIconColor: true,\n })\n .extend({\n /**\n * The category of the component.\n *\n * Used to group components in the UI.\n */\n category: z.string().optional(),\n\n /**\n * The default name prefix for the component instances.\n *\n * Used to generate default names for the instances.\n */\n defaultNamePrefix: z.string(),\n }),\n\n /**\n * The CRC32 of the component definition.\n */\n definitionHash: z.number(),\n})\n\nexport type ComponentModel = z.infer<typeof componentModelSchema>\n\ntype InputSpecToInputRef<T extends ComponentInputSpec> = T[1] extends true\n ? T[2] extends true\n ? InstanceInput<T[0][typeof implementedTypes]>[]\n : InstanceInput<T[0][typeof implementedTypes]>\n : T[2] extends true\n ? InstanceInput<T[0][typeof implementedTypes]>[] | undefined\n : InstanceInput<T[0][typeof implementedTypes]> | undefined\n\ntype InputSpecToOutputRef<T extends ComponentInputSpec> = T[2] extends true\n ? InstanceInput<T[0][typeof implementedTypes]>[]\n : InstanceInput<T[0][typeof implementedTypes]>\n\nexport type InputSpecMapToInputRefMap<TInputs extends Record<string, ComponentInputSpec>> =\n TInputs extends Record<string, [string, never, never]>\n ? Record<string, never>\n : { [K in keyof TInputs]: InputSpecToInputRef<TInputs[K]> }\n\nexport type OutputRefMap<TInputs extends Record<string, ComponentInputSpec>> =\n TInputs extends Record<string, [string, never, never]>\n ? Record<string, never>\n : { [K in keyof TInputs]: InputSpecToOutputRef<TInputs[K]> }\n\nexport const originalCreate = Symbol(\"originalCreate\")\nexport const kind = Symbol(\"kind\")\n\nexport type Component<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, z.ZodType> = Record<string, never>,\n TInputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n> = {\n /**\n * The type of the component.\n */\n type: TType\n\n /**\n * The non-generic model of the component.\n */\n model: ComponentModel\n\n /**\n * The entities used in the inputs or outputs of the component.\n */\n entities: Map<string, Entity>\n\n (\n context: InputComponentParams<\n { [K in keyof TArgs]: z.input<TArgs[K]> },\n InputSpecMapToInputRefMap<TInputs>\n >,\n ): OutputRefMap<TOutputs>\n\n /**\n * The original create function.\n *\n * Used to calculate the definition hash.\n */\n [originalCreate]: (params: InputComponentParams<any, any>) => any\n}\n\nexport function defineComponent<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions> = Record<string, never>,\n TInputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n>(\n options: ComponentOptions<TType, TArgs, TInputs, TOutputs>,\n): Component<\n TType,\n { [K in keyof TArgs]: ComponentArgumentOptionsToSchema<TArgs[K]> },\n { [K in keyof TInputs]: ComponentInputOptionsToSpec<TInputs[K]> },\n { [K in keyof TOutputs]: ComponentInputOptionsToSpec<TOutputs[K]> }\n> {\n try {\n componentModelSchema.shape.type.parse(options.type)\n } catch (error) {\n throw new Error(`Invalid component type \"${options.type}\"`, { cause: error })\n }\n\n if (!options.create) {\n throw new Error(\"Component create function is required\")\n }\n\n const entities = new Map<string, Entity>()\n const mapInput = createInputMapper(entities)\n\n const model: ComponentModel = {\n type: options.type,\n kind: options[kind] ?? \"composite\",\n args: mapValues(options.args ?? {}, mapArgument),\n inputs: mapValues(options.inputs ?? {}, mapInput),\n outputs: mapValues(options.outputs ?? {}, mapInput),\n meta: {\n ...options.meta,\n title: options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),\n defaultNamePrefix:\n options.meta?.defaultNamePrefix ||\n parseVersionedName(options.type)[0].split(\".\").slice(-1)[0],\n },\n // will be calculated by library loader\n definitionHash: null!,\n }\n\n function create(\n params: InputComponentParams<any, Record<string, InstanceInput | InstanceInputGroup>>,\n ): any {\n const { name, args = {}, inputs } = params\n const instanceId = getInstanceId(options.type, name)\n\n const flatInputs: Record<string, InstanceInputGroup> = {}\n const tracedInputs: Record<string, InstanceInput[]> = {}\n\n for (const [key, inputGroup] of Object.entries(inputs ?? {})) {\n if (!inputGroup) {\n continue\n }\n\n if (!Array.isArray(inputGroup)) {\n if (inputGroup[boundaryInput]) {\n tracedInputs[key] = [inputGroup[boundaryInput]]\n }\n\n flatInputs[key] = [inputGroup]\n continue\n }\n\n // merge \"boundaryInputs\" attached to array with \"boundaryInput\"s attached to individual items\n const group: InstanceInput[] = [...(inputGroup[boundaryInputs] ?? [])]\n const inputs: InstanceInput[] = []\n\n for (const item of inputGroup.flat(1)) {\n if (item[boundaryInput]) {\n group.push(item[boundaryInput])\n }\n\n inputs.push(item)\n }\n\n tracedInputs[key] = uniqueBy(group, inputKey)\n flatInputs[key] = uniqueBy(inputs, inputKey)\n }\n\n return registerInstance(\n create as unknown as Component,\n {\n id: instanceId,\n type: options.type,\n kind: options[kind] ?? \"composite\",\n name,\n args,\n inputs: tracedInputs,\n resolvedInputs: mapValues(flatInputs, inputs =>\n inputs.filter(input => !(\"provided\" in input && input.provided === false)),\n ),\n },\n () => {\n const markedInputs = mapValues(model.inputs, (componentInput, key) => {\n if (!componentInput.multiple) {\n // for single component use first available input and attach boundaryInput\n // technically, caller can pass multiple inputs or array of inputs ignoring the TypeScript restriction,\n // but we don't care about that\n const input = flatInputs[key]?.[0]\n\n if (input) {\n // return the input with boundaryInput attached\n // the input can also be \"OptionalInstanceInput\" with \"provided: false\", but this is still correct\n return { ...input, [boundaryInput]: { instanceId: instanceId, output: key } }\n }\n\n // create a new \"not provided\" input with boundaryInput attached\n return { provided: false, [boundaryInput]: { instanceId: instanceId, output: key } }\n }\n\n // then handle array of inputs\n // caller can provide array of array which will be flattened with boundaryInputs preserved\n // regardless of the number of inputs, we always attach boundaryInputs to the whole array\n const inputs = flatInputs[key] ?? []\n inputs[boundaryInputs] = [{ instanceId, output: key }]\n\n return inputs\n })\n\n const outputs: Record<string, InstanceInput[]> =\n options.create({\n id: instanceId,\n name,\n args: processArgs(instanceId, create.model, args) as any,\n inputs: markedInputs as any,\n }) ?? {}\n\n return mapValues(pickBy(outputs, isNonNullish), outputs => [outputs].flat(2))\n },\n )\n }\n\n try {\n create.entities = entities\n create.model = model\n\n create[originalCreate] = options.create\n\n return create as any\n } catch (error) {\n throw new Error(`Failed to define component \"${options.type}\"`, { cause: error })\n }\n}\n\nfunction processArgs(\n instanceId: InstanceId,\n model: ComponentModel,\n args: Record<string, unknown>,\n): Record<string, unknown> {\n if (!validationEnabled) {\n return args\n }\n\n const validatedArgs: Record<string, unknown> = {}\n\n for (const [key, arg] of Object.entries(model.args)) {\n if (arg.schema) {\n const result = arg[runtimeSchema]!.safeParse(args[key])\n\n if (!result.success) {\n throw new Error(\n `Invalid argument \"${key}\" in instance \"${instanceId}\": ${result.error.message}`,\n )\n }\n\n validatedArgs[key] = result.data\n } else {\n validatedArgs[key] = args[key]\n }\n }\n\n return validatedArgs\n}\n\n/**\n * Checks if the value is a Highstate component.\n *\n * Does not guarantee that the value is a valid component, only that it has the expected structure.\n *\n * @param value The value to check.\n * @returns True if the value is a component, false otherwise.\n */\nexport function isComponent(value: unknown): value is Component {\n return typeof value === \"function\" && \"model\" in value\n}\n\nfunction isSchemaOptional(schema: z.ZodType): boolean {\n return schema.safeParse(undefined).success\n}\n\nexport function mapArgument(value: ComponentArgumentOptions, key: string): ComponentArgument {\n if (\"schema\" in value) {\n return {\n schema: z.toJSONSchema(value.schema, {\n target: \"draft-7\",\n io: \"input\",\n unrepresentable: \"any\",\n }),\n [runtimeSchema]: value.schema,\n required: !isSchemaOptional(value.schema),\n meta: {\n ...value.meta,\n title: value.meta?.title || camelCaseToHumanReadable(key),\n },\n }\n }\n\n return {\n schema: z.toJSONSchema(value, { target: \"draft-7\", io: \"input\", unrepresentable: \"any\" }),\n [runtimeSchema]: value,\n required: !isSchemaOptional(value),\n meta: {\n title: camelCaseToHumanReadable(key),\n },\n }\n}\n\nexport function createInputMapper(entities: Map<string, Entity>) {\n return (value: ComponentInputOptions, key: string): ComponentInput => {\n if (!value) {\n throw new Error(`Input/output \"${key}\" is undefined in the component model.`)\n }\n\n if (\"entity\" in value) {\n entities.set(value.entity.type, value.entity)\n\n return {\n type: value.entity.type,\n required: value.required ?? true,\n multiple: value.multiple ?? false,\n meta: {\n ...value.meta,\n title: value.meta?.title || camelCaseToHumanReadable(key),\n },\n }\n }\n\n entities.set(value.type, value)\n\n return {\n type: value.type,\n required: true,\n multiple: false,\n meta: {\n title: camelCaseToHumanReadable(key),\n },\n }\n }\n}\n\n/**\n * Formats the instance id from the instance type and instance name.\n *\n * @param instanceType The type of the instance.\n * @param instanceName The name of the instance.\n *\n * @returns The formatted instance id.\n */\nexport function getInstanceId(instanceType: VersionedName, instanceName: string): InstanceId {\n return `${instanceType}:${instanceName}`\n}\n\nexport type ToFullComponentArgumentOptions<T extends Record<string, ComponentArgumentOptions>> =\n Simplify<{\n [K in keyof T]: T[K] extends z.ZodType ? { schema: T[K] } : T[K]\n }>\n\nexport function toFullComponentArgumentOptions<T extends Record<string, ComponentArgumentOptions>>(\n args: T,\n): ToFullComponentArgumentOptions<T> {\n return mapValues(args, arg => (\"schema\" in arg ? arg : { schema: arg })) as any\n}\n\ntype ToFullComponentInputOptions<T extends Record<string, ComponentInputOptions>> = Simplify<{\n [K in keyof T]: T[K] extends Entity ? { entity: T[K] } : T[K]\n}>\n\nfunction toFullComponentInputOptions<T extends Record<string, ComponentInputOptions>>(\n inputs: T,\n): ToFullComponentInputOptions<T> {\n return mapValues(inputs, input => (\"entity\" in input ? input : { entity: input })) as any\n}\n\n/**\n * The helper marker for component arguments.\n *\n * Helps validating arguments types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $args<T extends Record<string, ComponentArgumentOptions>>(\n args: T,\n): ToFullComponentArgumentOptions<T> {\n return toFullComponentArgumentOptions(args)\n}\n\n/**\n * The helper marker for component inputs.\n *\n * Helps validating inputs types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $inputs<T extends Record<string, ComponentInputOptions>>(\n inputs: T,\n): ToFullComponentInputOptions<T> {\n return toFullComponentInputOptions(inputs)\n}\n\n/**\n * The helper marker for component outputs.\n *\n * Helps validating outputs types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $outputs<T extends Record<string, ComponentInputOptions>>(\n outputs: T,\n): ToFullComponentInputOptions<T> {\n return toFullComponentInputOptions(outputs)\n}\n\n/**\n * Adds a description to the argument which can be both a schema or full argument options.\n *\n * Used by the compiler to inject descriptions into the argument schema.\n * You probably won't need to use it directly.\n */\nexport function $addArgumentDescription(\n argument: ComponentArgumentOptions,\n description: string,\n): FullComponentArgumentOptions {\n if (\"schema\" in argument) {\n return {\n ...argument,\n meta: {\n ...argument.meta,\n description: argument.meta?.description ?? description,\n },\n }\n }\n\n return {\n schema: argument,\n meta: {\n description: description,\n },\n }\n}\n\n/**\n * Adds a description to the input which can be both an entity or full input options.\n *\n * Used by the compiler to inject descriptions into the input schema.\n * You probably won't need to use it directly.\n */\nexport function $addInputDescription(\n input: ComponentInputOptions,\n description: string,\n): ComponentInputOptions {\n if (\"entity\" in input) {\n return {\n ...input,\n meta: {\n ...input.meta,\n description: input.meta?.description ?? description,\n },\n }\n }\n\n return {\n entity: input,\n meta: {\n description: description,\n },\n }\n}\n","import type { EntityTypes } from \"./entity\"\nimport type { boundaryInput, boundaryInputs } from \"./evaluation\"\nimport { z } from \"zod\"\nimport { componentKindSchema } from \"./component\"\nimport {\n type GenericName,\n genericNameSchema,\n objectMetaSchema,\n type VersionedName,\n versionedNameSchema,\n} from \"./meta\"\n\ndeclare const type: unique symbol\n\nexport type InstanceInput<TTypes extends EntityTypes = EntityTypes> = {\n [type]?: TTypes\n [boundaryInput]?: InstanceInput\n instanceId: InstanceId\n output: string\n}\n\nexport type OptionalInstanceInput<TTypes extends EntityTypes = EntityTypes> =\n | ({ provided: true } & InstanceInput<TTypes>)\n | { provided: false; [boundaryInput]?: InstanceInput }\n\nexport type InstanceInputGroup<TTypes extends EntityTypes = EntityTypes> =\n InstanceInput<TTypes>[] & {\n [boundaryInputs]?: InstanceInputGroup<TTypes>\n }\n\nexport function inputKey(input: InstanceInput): string {\n return `${input.instanceId}:${input.output}`\n}\n\nexport const positionSchema = z.object({\n x: z.number(),\n y: z.number(),\n})\n\nexport type Position = z.infer<typeof positionSchema>\n\nexport const instanceIdSchema = z.templateLiteral([versionedNameSchema, \":\", genericNameSchema])\n\nexport type InstanceId = z.infer<typeof instanceIdSchema>\n\nexport const instanceInputSchema = z.object({\n instanceId: instanceIdSchema,\n output: z.string(),\n})\n\nexport const hubInputSchema = z.object({\n hubId: z.string(),\n})\n\nexport type HubInput = z.infer<typeof hubInputSchema>\n\nexport const instanceModelPatchSchema = z.object({\n /**\n * The static arguments passed to the instance.\n */\n args: z.record(z.string(), z.unknown()).optional(),\n\n /**\n * The direct instances passed as inputs to the instance.\n */\n inputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n\n /**\n * The resolved unit inputs for the instance.\n *\n * Only for computed composite instances.\n */\n hubInputs: z.record(z.string(), z.array(hubInputSchema)).optional(),\n\n /**\n * The inputs injected to the instance from the hubs.\n *\n * While `hubInputs` allows to pass hubs to distinct inputs,\n * `injectionInputs` allows to pass hubs to the instance as a whole filling all inputs with matching types.\n *\n * Only for designer-first instances.\n */\n injectionInputs: z.array(hubInputSchema).optional(),\n\n /**\n * The position of the instance on the canvas.\n *\n * Only for designer-first instances.\n */\n position: positionSchema.optional(),\n})\n\nexport const instanceModelSchema = z.object({\n /**\n * The id of the instance unique within the project.\n *\n * The format is `${instanceType}:${instanceName}`.\n */\n id: instanceIdSchema,\n\n /**\n * The kind of the instance.\n *\n * Can be either \"unit\" or \"composite\".\n */\n kind: componentKindSchema,\n\n /**\n * The type of the instance.\n */\n type: versionedNameSchema,\n\n /**\n * The name of the instance.\n *\n * Must be unique within instances of the same type in the project.\n */\n name: genericNameSchema,\n\n ...instanceModelPatchSchema.shape,\n\n /**\n * The id of the top level parent instance.\n *\n * Only for child instances of the composite instances.\n */\n resolvedInputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n\n /**\n * The ID of the parent instance.\n *\n * Only for child instances of the composite instances.\n */\n parentId: instanceIdSchema.optional(),\n\n /**\n * The direct instance outputs returned by the instance as outputs.\n *\n * Only for computed composite instances.\n */\n outputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n\n /**\n * The resolved unit outputs for the instance.\n *\n * Only for computed composite instances.\n */\n resolvedOutputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n})\n\nexport type InstanceModel = z.infer<typeof instanceModelSchema>\n\nexport const hubModelPatchSchema = z.object({\n /**\n * The position of the hub on the canvas.\n */\n position: positionSchema.optional(),\n\n /**\n * The inputs of the hub.\n */\n inputs: z.array(instanceInputSchema).optional(),\n\n /**\n * The inputs injected to the hub from the hubs.\n *\n * While `inputs` allows to pass hubs to distinct inputs,\n * `injectionInputs` allows to pass hubs to the hub as a whole filling all inputs with matching types.\n */\n injectionInputs: z.array(hubInputSchema).optional(),\n})\n\nexport const hubModelSchema = z.object({\n /**\n * The id of the hub unique within the project.\n */\n id: z.cuid2(),\n\n ...hubModelPatchSchema.shape,\n})\n\nexport type InstanceModelPatch = z.infer<typeof instanceModelPatchSchema>\nexport type HubModel = z.infer<typeof hubModelSchema>\nexport type HubModelPatch = z.infer<typeof hubModelPatchSchema>\n\n/**\n * Parses the instance id into the instance type and instance name.\n *\n * @param instanceId The instance id to parse.\n *\n * @returns The instance type and instance name.\n */\nexport function parseInstanceId(\n instanceId: string,\n): [instanceType: VersionedName, instanceName: GenericName] {\n const parts = instanceId.split(\":\")\n\n if (parts.length !== 2) {\n throw new Error(`Invalid instance ID: ${instanceId}`)\n }\n\n return parts as [VersionedName, GenericName]\n}\n\nexport function findInput<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n name: string,\n): InstanceInput<T> | null {\n const matchedInputs = inputs.filter(\n input => parseInstanceId(input.instanceId)[1] === name || input.instanceId === name,\n )\n\n if (matchedInputs.length === 0) {\n return null\n }\n\n if (matchedInputs.length > 1) {\n throw new Error(\n `Multiple inputs found for \"${name}\": ${matchedInputs.map(input => input.instanceId).join(\", \")}. Specify the full instance id to disambiguate.`,\n )\n }\n\n return matchedInputs[0]\n}\n\nexport function findRequiredInput<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n name: string,\n): InstanceInput<T> {\n const input = findInput(inputs, name)\n\n if (input === null) {\n throw new Error(`Required input \"${name}\" not found.`)\n }\n\n return input\n}\n\nexport function findInputs<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n names: string[],\n): InstanceInput<T>[] {\n return names.map(name => findInput(inputs, name)).filter(Boolean) as InstanceInput<T>[]\n}\n\nexport function findRequiredInputs<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n names: string[],\n): InstanceInput<T>[] {\n return names.map(name => findRequiredInput(inputs, name))\n}\n\n/**\n * The field names that indicate special objects which Highstate understands regardless of the context.\n *\n * UUIDs are used to prevent conflicts with user-defined fields.\n */\nexport enum HighstateSignature {\n Artifact = \"d55c63ac-3174-4756-808f-f778e99af0d1\",\n Yaml = \"c857cac5-caa6-4421-b82c-e561fbce6367\",\n Id = \"348d020e-0d9e-4ae7-9415-b91af99f5339\",\n Ref = \"6d7f9da0-9cb6-496d-b72e-cf85ee4d9cf8\",\n}\n\nexport const yamlValueSchema = z.object({\n [HighstateSignature.Yaml]: z.literal(true),\n value: z.string(),\n})\n\nexport const objectWithIdSchema = z.object({\n [HighstateSignature.Id]: z.literal(true),\n id: z.number(),\n value: z.unknown(),\n})\n\nexport const objectRefSchema = z.object({\n [HighstateSignature.Ref]: z.literal(true),\n id: z.number(),\n})\n\nexport type YamlValue = z.infer<typeof yamlValueSchema>\n\nexport const fileMetaSchema = z.object({\n name: z.string(),\n contentType: z.string().optional(),\n size: z.number().optional(),\n mode: z.number().optional(),\n})\n\nexport enum WellKnownInstanceCustomStatus {\n /**\n * The instance is in a healthy state.\n */\n Healthy = \"healthy\",\n\n /**\n * The instance is in a degraded state.\n */\n Degraded = \"degraded\",\n\n /**\n * The instance is in a down state/completely broken.\n */\n Down = \"down\",\n\n /**\n * The instance is in a warning state.\n */\n Warning = \"warning\",\n\n /**\n * The instance is progressing with some external sync operation,\n * such as a deployment or a data migration.\n */\n Progressing = \"progressing\",\n\n /**\n * The instance is in an error state.\n */\n Error = \"error\",\n}\n\nexport const instanceStatusFieldValueSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.string().array(),\n])\n\nexport const instanceStatusFieldSchema = z.object({\n name: z.string(),\n\n meta: objectMetaSchema\n .pick({\n title: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n\n complementaryTo: z.string().optional(),\n value: instanceStatusFieldValueSchema.optional(),\n})\n\nexport type InstanceStatusFieldValue = z.infer<typeof instanceStatusFieldValueSchema>\nexport type InstanceStatusField = z.infer<typeof instanceStatusFieldSchema>\n","/** biome-ignore-all lint/suspicious/noExplicitAny: maybe fix later */\n\nimport type { InstanceInput } from \"./instance\"\nimport type { VersionedName } from \"./meta\"\nimport { mapValues } from \"remeda\"\nimport { z } from \"zod\"\nimport {\n type Component,\n type ComponentArgumentOptions,\n type ComponentArgumentOptionsToSchema,\n type ComponentInputOptions,\n type ComponentInputOptionsToSpec,\n type ComponentInputSpec,\n type ComponentModel,\n type ComponentOptions,\n componentArgumentSchema,\n componentModelSchema,\n defineComponent,\n type FullComponentArgumentOptions,\n kind,\n mapArgument,\n type ToFullComponentArgumentOptions,\n toFullComponentArgumentOptions,\n} from \"./component\"\n\nexport const componentSecretSchema = componentArgumentSchema.extend({\n /**\n * The secret cannot be modified by the user, but can be modified by the unit.\n */\n readonly: z.boolean(),\n\n /**\n * The secret value is computed by the unit and should not be passed to it when invoked.\n */\n computed: z.boolean(),\n})\n\nexport type ComponentSecret = z.infer<typeof componentSecretSchema>\n\nexport type FullComponentSecretOptions = FullComponentArgumentOptions & {\n readonly?: boolean\n computed?: boolean\n}\n\nexport type ComponentSecretOptions = z.ZodType | FullComponentSecretOptions\n\ntype UnitOptions<\n TType extends VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions>,\n TInputs extends Record<string, ComponentInputOptions>,\n TOutputs extends Record<string, ComponentInputOptions>,\n TSecrets extends Record<string, ComponentSecretOptions>,\n> = Omit<ComponentOptions<TType, TArgs, TInputs, TOutputs>, \"create\"> & {\n source: UnitSource\n\n secrets?: TSecrets\n}\n\nexport const unitSourceSchema = z.object({\n /**\n * The package where the unit implementation is located.\n *\n * May be both: local monorepo package or a remote NPM package.\n */\n package: z.string(),\n\n /**\n * The path to the unit implementation within the package.\n *\n * If not provided, the root of the package is assumed.\n */\n path: z.string().optional(),\n})\n\nexport const unitModelSchema = z.object({\n ...componentModelSchema.shape,\n\n /**\n * The source of the unit.\n */\n source: unitSourceSchema,\n\n /**\n * The record of the secret specs.\n */\n secrets: z.record(z.string(), componentSecretSchema),\n})\n\nexport type UnitModel = z.infer<typeof unitModelSchema>\nexport type UnitSource = z.infer<typeof unitSourceSchema>\n\ndeclare const secrets: unique symbol\n\nexport type Unit<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, z.ZodType> = Record<string, never>,\n TInputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n TSecrets extends Record<string, unknown> = Record<string, never>,\n> = Component<TType, TArgs, TInputs, TOutputs> & {\n /**\n * Holds the type of the unit secrets.\n *\n * Does not exist at runtime, only for type checking.\n */\n [secrets]: TSecrets\n\n /**\n * The model of the unit.\n */\n model: UnitModel\n}\n\nexport function defineUnit<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions> = Record<string, never>,\n TInputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n TSecrets extends Record<string, ComponentSecretOptions> = Record<string, never>,\n>(\n options: UnitOptions<TType, TArgs, TInputs, TOutputs, TSecrets>,\n): Unit<\n TType,\n { [K in keyof TArgs]: ComponentArgumentOptionsToSchema<TArgs[K]> },\n { [K in keyof TInputs]: ComponentInputOptionsToSpec<TInputs[K]> },\n { [K in keyof TOutputs]: ComponentInputOptionsToSpec<TOutputs[K]> },\n { [K in keyof TSecrets]: ComponentArgumentOptionsToSchema<TSecrets[K]> }\n> {\n if (!options.source) {\n throw new Error(\"Unit source is required\")\n }\n\n const component = defineComponent<TType, TArgs, TInputs, TOutputs>({\n ...options,\n [kind]: \"unit\",\n\n create({ id }) {\n const outputs: Record<string, InstanceInput[]> = {}\n for (const key in options.outputs ?? {}) {\n outputs[key] = [\n {\n instanceId: id,\n output: key,\n },\n ]\n }\n\n return outputs as any\n },\n }) as any\n\n try {\n component.model.source = options.source ?? {}\n component.model.secrets = mapValues(options.secrets ?? {}, mapSecret)\n } catch (error) {\n throw new Error(`Failed to map secrets for unit \"${options.type}\"`, { cause: error })\n }\n\n return component\n}\n\n/**\n * The helper marker for component secrets.\n *\n * Helps validating secrets types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $secrets<T extends Record<string, ComponentArgumentOptions>>(\n secrets: T,\n): ToFullComponentArgumentOptions<T> {\n return toFullComponentArgumentOptions(secrets)\n}\n\nfunction mapSecret(value: ComponentSecretOptions, key: string): ComponentSecret {\n if (\"schema\" in value) {\n return {\n ...mapArgument(value, key),\n readonly: value.readonly ?? false,\n computed: value.computed ?? false,\n }\n }\n\n return {\n ...mapArgument(value, key),\n readonly: false,\n computed: false,\n }\n}\n\n/**\n * Checks if the given model is a unit model.\n *\n * @param model The model to check.\n *\n * @returns `true` if the model is a unit model, `false` otherwise.\n */\nexport function isUnitModel(model: ComponentModel): model is UnitModel {\n return \"source\" in model\n}\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"./meta\"\n\nexport const triggerSpecSchema = z.union([\n z.object({\n type: z.literal(\"before-destroy\"),\n }),\n])\n\nexport type TriggerSpec = z.infer<typeof triggerSpecSchema>\n\n/**\n * Trigger schema for unit API.\n * This is what units provide - excludes id since it's set by the system.\n */\nexport const unitTriggerSchema = z.object({\n name: z.string(),\n meta: objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n\n /**\n * The specification of the trigger.\n *\n * Defines the type of trigger and its behavior.\n */\n spec: triggerSpecSchema,\n})\n\nexport type UnitTrigger = z.infer<typeof unitTriggerSchema>\n\nexport const triggerInvocationSchema = z.object({\n /**\n * The name of the trigger being invoked.\n */\n name: z.string(),\n})\n\nexport type TriggerInvocation = z.infer<typeof triggerInvocationSchema>\n","import { parse } from \"yaml\"\nimport { z } from \"zod\"\nimport { entityInclusionSchema } from \"./entity\"\nimport {\n fileMetaSchema,\n HighstateSignature,\n instanceIdSchema,\n instanceInputSchema,\n yamlValueSchema,\n} from \"./instance\"\nimport { commonObjectMetaSchema } from \"./meta\"\nimport { triggerInvocationSchema } from \"./trigger\"\n\nexport type UnitInputReference = z.infer<typeof unitInputReference>\n\nexport const unitInputReference = z.object({\n ...instanceInputSchema.shape,\n\n /**\n * The resolved inclusion needed to extract the input value.\n */\n inclusion: entityInclusionSchema.optional(),\n})\n\nexport const unitConfigSchema = z.object({\n /**\n * The ID of the instance.\n */\n instanceId: z.string(),\n\n /**\n * The record of argument values for the unit.\n */\n args: z.record(z.string(), z.unknown()),\n\n /**\n * The record of input references for the unit.\n */\n inputs: z.record(z.string(), unitInputReference.array()),\n\n /**\n * The list of triggers that have been invoked for this unit.\n */\n invokedTriggers: triggerInvocationSchema.array(),\n\n /**\n * The list of secret names that exists and provided to the unit.\n */\n secretNames: z.string().array(),\n\n /**\n * The map of instance ID to state ID in order to resolve instance references.\n */\n stateIdMap: z.record(instanceIdSchema, z.string()),\n\n /**\n * The base path for imports.\n * Used to resolve dynamic dependencies in strict environments (like in pnpm node_modules isolation).\n */\n importBasePath: z.string(),\n})\n\nexport type UnitConfig = z.infer<typeof unitConfigSchema>\n\nconst yamlResultCache = new WeakMap<object, unknown>()\n\n/**\n * Parses an argument value which can be wrapped in a YAML structure.\n *\n * @param value The value to parse.\n */\nexport function parseArgumentValue(value: unknown): unknown {\n const yamlResult = yamlValueSchema.safeParse(value)\n if (!yamlResult.success) {\n return value\n }\n\n const existingResult = yamlResultCache.get(value as object)\n if (existingResult !== undefined) {\n return existingResult\n }\n\n const result = parse(yamlResult.data.value) as unknown\n yamlResultCache.set(value as object, result)\n return result\n}\n\nexport enum HighstateConfigKey {\n Config = \"highstate\",\n Secrets = \"highstate.secrets\",\n}\n\nexport const unitArtifactId = Symbol(\"unitArtifactId\")\n\nexport const unitArtifactSchema = z.object({\n [HighstateSignature.Artifact]: z.literal(true),\n // only for internal use\n [unitArtifactId]: z.string().optional(),\n hash: z.string(),\n meta: commonObjectMetaSchema.optional(),\n})\n\nexport const fileContentSchema = z.union([\n z.object({\n type: z.literal(\"embedded\"),\n\n /**\n * Whether the content is binary or not.\n *\n * If true, the `value` will be a base64 encoded string.\n */\n isBinary: z.boolean().optional(),\n\n /**\n * The content of the file.\n *\n * If `isBinary` is true, this will be a base64 encoded string.\n */\n value: z.string(),\n }),\n z.object({\n type: z.literal(\"artifact\"),\n ...unitArtifactSchema.shape,\n }),\n])\n\nexport const fileSchema = z.object({\n meta: fileMetaSchema,\n content: fileContentSchema,\n})\n\nexport type FileMeta = z.infer<typeof fileMetaSchema>\nexport type FileContent = z.infer<typeof fileContentSchema>\nexport type UnitArtifact = z.infer<typeof unitArtifactSchema>\nexport type File = z.infer<typeof fileSchema>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"./meta\"\nimport { fileSchema } from \"./pulumi\"\n\n/**\n * Contains all the information needed to run a terminal,\n * including the image, command, working directory, environment variables, and files.\n */\nexport const terminalSpecSchema = z.object({\n /**\n * The Docker image to run the terminal.\n */\n image: z.string(),\n\n /**\n * The command to run in the terminal.\n */\n command: z.string().array(),\n\n /**\n * The working directory to run the command in.\n */\n cwd: z.string().optional(),\n\n /**\n * The environment variables to set in the terminal.\n */\n env: z.record(z.string(), z.string()).optional(),\n\n /**\n * The files to mount in the terminal.\n *\n * The key is the path where the file will be mounted,\n * and the value is the file content or a reference to an artifact.\n */\n files: z.record(z.string(), fileSchema).optional(),\n})\n\nexport type TerminalSpec = z.infer<typeof terminalSpecSchema>\n\n/**\n * Terminal schema for unit API.\n */\nexport const unitTerminalSchema = z.object({\n name: z.string(),\n meta: objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n spec: terminalSpecSchema,\n})\n\nexport type UnitTerminal = z.infer<typeof unitTerminalSchema>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"./meta\"\nimport { fileSchema } from \"./pulumi\"\n\n/**\n * Page block schema for database storage and unit API.\n */\nexport const pageBlockSchema = z.union([\n z.object({\n type: z.literal(\"markdown\"),\n content: z.string(),\n }),\n z.object({\n type: z.literal(\"qr\"),\n content: z.string(),\n showContent: z.coerce.boolean(),\n language: z.string().optional(),\n }),\n z.object({\n type: z.literal(\"file\"),\n file: fileSchema,\n }),\n])\n\nexport type PageBlock = z.infer<typeof pageBlockSchema>\n\n/**\n * Page schema for unit API.\n * This is what units provide - excludes id, instanceId and some fields from meta since those are set by the system.\n */\nexport const unitPageSchema = z.object({\n name: z.string(),\n meta: objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n content: pageBlockSchema.array(),\n})\n\nexport type UnitPage = z.infer<typeof unitPageSchema>\n","import { z } from \"zod\"\n\nexport const unitWorkerSchema = z.object({\n name: z.string(),\n image: z.string(),\n params: z.record(z.string(), z.unknown()),\n})\n\nexport type UnitWorker = z.infer<typeof unitWorkerSchema>\n\nexport const workerRunOptionsSchema = z.object({\n /**\n * The ID of the project for which the worker is running.\n */\n projectId: z.cuid2(),\n\n /**\n * The ID of the worker version.\n */\n workerVersionId: z.cuid2(),\n\n /**\n * The URL of the backend API to connect to.\n */\n apiUrl: z.url(),\n\n /**\n * The API key used to authenticate the worker with the backend.\n */\n apiKey: z.string(),\n})\n\nexport type WorkerRunOptions = z.infer<typeof workerRunOptionsSchema>\n","import { mapValues } from \"remeda\"\nimport { HighstateSignature, objectRefSchema, objectWithIdSchema } from \"./instance\"\n\nexport function compact<T>(value: T): unknown {\n const counts = new WeakMap<object, number>()\n const cyclic = new WeakSet<object>()\n const expanded = new WeakSet<object>()\n const inStack = new WeakSet<object>()\n const stack: object[] = []\n\n function countIdentities(current: unknown): void {\n if (current === null || typeof current !== \"object\") {\n return\n }\n\n counts.set(current, (counts.get(current) ?? 0) + 1)\n\n if (inStack.has(current)) {\n cyclic.add(current)\n\n for (const entry of stack) {\n cyclic.add(entry)\n }\n return\n }\n\n if (expanded.has(current)) {\n return\n }\n\n expanded.add(current)\n inStack.add(current)\n stack.push(current)\n\n if (Array.isArray(current)) {\n try {\n for (const item of current) {\n countIdentities(item)\n }\n return\n } finally {\n stack.pop()\n inStack.delete(current)\n }\n }\n\n try {\n for (const entryValue of Object.values(current)) {\n countIdentities(entryValue)\n }\n } finally {\n stack.pop()\n inStack.delete(current)\n }\n }\n\n countIdentities(value)\n\n type DefinitionSite = { parent: object; key: string | number }\n\n const ids = new WeakMap<object, number>()\n const definitionSites = new WeakMap<object, DefinitionSite>()\n let nextId = 1\n\n function ensureId(current: object): number {\n const existing = ids.get(current)\n if (existing !== undefined) {\n return existing\n }\n\n const allocated = nextId\n nextId += 1\n ids.set(current, allocated)\n return allocated\n }\n\n function assignDefinitionSitesBfs(root: unknown): void {\n if (root === null || typeof root !== \"object\") {\n return\n }\n\n const queue: Array<{ parent: object; key: string | number; value: unknown }> = []\n const expandedQueue = new WeakSet<object>()\n\n if (Array.isArray(root)) {\n for (let index = 0; index < root.length; index += 1) {\n queue.push({ parent: root, key: index, value: root[index] })\n }\n } else {\n for (const [key, entryValue] of Object.entries(root)) {\n queue.push({ parent: root, key, value: entryValue })\n }\n }\n\n while (queue.length > 0) {\n const current = queue.shift()\n if (current === undefined) {\n continue\n }\n\n if (current.value === null || typeof current.value !== \"object\") {\n continue\n }\n\n const occurrences = counts.get(current.value) ?? 0\n if (occurrences > 1 && definitionSites.get(current.value) === undefined) {\n definitionSites.set(current.value, { parent: current.parent, key: current.key })\n ensureId(current.value)\n }\n\n if (expandedQueue.has(current.value)) {\n continue\n }\n\n expandedQueue.add(current.value)\n\n if (Array.isArray(current.value)) {\n for (let index = 0; index < current.value.length; index += 1) {\n queue.push({ parent: current.value, key: index, value: current.value[index] })\n }\n continue\n }\n\n for (const [key, entryValue] of Object.entries(current.value)) {\n queue.push({ parent: current.value, key, value: entryValue })\n }\n }\n }\n\n assignDefinitionSitesBfs(value)\n\n const emitted = new WeakSet<object>()\n\n function buildTreeChildren(current: object, rootOfIdValue?: object): unknown {\n if (Array.isArray(current)) {\n return current.map(item => buildTree(item, rootOfIdValue))\n }\n\n return mapValues(current, entryValue => buildTree(entryValue, rootOfIdValue))\n }\n\n function buildTree(current: unknown, rootOfIdValue?: object): unknown {\n if (current === null || typeof current !== \"object\") {\n return current\n }\n\n // Inside an Id value, never emit nested Id wrappers.\n // Match existing real-world snapshot: do not introduce refs for nested objects\n // unless the nested object has already been defined earlier.\n if (rootOfIdValue !== undefined && emitted.has(current)) {\n const id = ids.get(current)\n if (id === undefined) {\n throw new Error(\"Compaction invariant violation: missing id for repeated object\")\n }\n\n return {\n [HighstateSignature.Ref]: true,\n id,\n }\n }\n\n // Cycles inside an Id value require defining the cyclic objects inline,\n // otherwise we would infinitely recurse.\n if (rootOfIdValue !== undefined && cyclic.has(current) && !emitted.has(current)) {\n const id = ensureId(current)\n emitted.add(current)\n\n return {\n [HighstateSignature.Id]: true,\n id,\n value: buildTreeChildren(current, current),\n }\n }\n\n return buildTreeChildren(current, rootOfIdValue)\n }\n\n function buildAt(parent: object, key: string | number, current: unknown): unknown {\n if (current === null || typeof current !== \"object\") {\n return current\n }\n\n const occurrences = counts.get(current) ?? 0\n if (occurrences <= 1) {\n if (Array.isArray(current)) {\n return current.map((item, index) => buildAt(current, index, item))\n }\n\n return mapValues(current, (entryValue, entryKey) => buildAt(current, entryKey, entryValue))\n }\n\n const site = definitionSites.get(current)\n const shouldDefineHere = site?.parent === parent && site.key === key\n\n const id = ids.get(current)\n if (id === undefined) {\n throw new Error(\"Compaction invariant violation: missing id for repeated object\")\n }\n\n if (!shouldDefineHere || emitted.has(current)) {\n return {\n [HighstateSignature.Ref]: true,\n id,\n }\n }\n\n emitted.add(current)\n\n return {\n [HighstateSignature.Id]: true,\n id,\n value: buildTreeChildren(current, current),\n }\n }\n\n // Prefer keeping the top-level value unwrapped for stability.\n if (value === null || typeof value !== \"object\") {\n return value\n }\n\n const topLevelOccurrences = counts.get(value) ?? 0\n if (topLevelOccurrences > 1) {\n const id = ensureId(value)\n emitted.add(value)\n\n return {\n [HighstateSignature.Id]: true,\n id,\n value: buildTreeChildren(value, value),\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) => buildAt(value, index, item))\n }\n\n return mapValues(value as Record<string, unknown>, (entryValue, entryKey) =>\n buildAt(value as Record<string, unknown>, entryKey, entryValue),\n )\n}\n\nexport function decompact<T>(value: unknown): T {\n const rawValuesById = new Map<number, unknown>()\n const placeholdersById = new Map<number, unknown>()\n\n function collect(current: unknown, visited: WeakSet<object>): void {\n const result = objectWithIdSchema.safeParse(current)\n if (result.success) {\n const { id } = result.data\n if (rawValuesById.has(id)) {\n throw new Error(`Duplicate compacted id ${id}`)\n }\n\n rawValuesById.set(id, result.data.value)\n collect(result.data.value, visited)\n return\n }\n\n if (current === null || current === undefined || typeof current !== \"object\") {\n return\n }\n\n if (visited.has(current)) {\n return\n }\n\n visited.add(current)\n\n if (Array.isArray(current)) {\n for (const item of current) {\n collect(item, visited)\n }\n return\n }\n\n for (const entryValue of Object.values(current)) {\n collect(entryValue, visited)\n }\n }\n\n function ensurePlaceholder(id: number): unknown {\n const existing = placeholdersById.get(id)\n if (existing !== undefined) {\n return existing\n }\n\n const raw = rawValuesById.get(id)\n if (raw === undefined) {\n throw new Error(`Unresolved compacted ref id ${id}`)\n }\n\n let placeholder: unknown\n if (raw !== null && typeof raw === \"object\") {\n placeholder = Array.isArray(raw) ? [] : {}\n } else {\n placeholder = raw\n }\n\n placeholdersById.set(id, placeholder)\n return placeholder\n }\n\n function resolve(current: unknown): unknown {\n const refResult = objectRefSchema.safeParse(current)\n if (refResult.success) {\n return ensurePlaceholder(refResult.data.id)\n }\n\n const withIdResult = objectWithIdSchema.safeParse(current)\n if (withIdResult.success) {\n return ensurePlaceholder(withIdResult.data.id)\n }\n\n if (current === null || current === undefined || typeof current !== \"object\") {\n return current\n }\n\n if (Array.isArray(current)) {\n return current.map(item => resolve(item))\n }\n\n return mapValues(current, entryValue => resolve(entryValue))\n }\n\n function fillPlaceholder(id: number, visitedIds: Set<number>): void {\n if (visitedIds.has(id)) {\n return\n }\n\n visitedIds.add(id)\n\n const raw = rawValuesById.get(id)\n if (raw === undefined) {\n throw new Error(`Unresolved compacted ref id ${id}`)\n }\n\n const placeholder = ensurePlaceholder(id)\n if (placeholder === null || typeof placeholder !== \"object\") {\n return\n }\n\n if (raw === null || typeof raw !== \"object\") {\n throw new Error(`Compaction invariant violation: id ${id} points to non-object value`)\n }\n\n const resolved = resolve(raw)\n\n if (Array.isArray(placeholder)) {\n if (!Array.isArray(resolved)) {\n throw new Error(`Compaction invariant violation: id ${id} array placeholder mismatch`)\n }\n\n placeholder.length = 0\n for (const item of resolved) {\n placeholder.push(item)\n }\n return\n }\n\n if (Array.isArray(resolved) || resolved === null || typeof resolved !== \"object\") {\n throw new Error(`Compaction invariant violation: id ${id} object placeholder mismatch`)\n }\n\n for (const [key, entryValue] of Object.entries(resolved)) {\n ;(placeholder as Record<string, unknown>)[key] = entryValue\n }\n }\n\n collect(value, new WeakSet<object>())\n\n for (const id of rawValuesById.keys()) {\n ensurePlaceholder(id)\n }\n\n const visitedIds = new Set<number>()\n for (const id of rawValuesById.keys()) {\n fillPlaceholder(id, visitedIds)\n }\n\n return resolve(value) as T\n}\n","import type { z } from \"zod\"\nimport { isNonNullish, pickBy } from \"remeda\"\n\ntype PickUndefinedKeys<T extends Record<string, unknown>> = T extends Record<string, never>\n ? never\n : Exclude<\n {\n [K in keyof T]: undefined extends T[K] ? K : never\n }[keyof T],\n undefined\n >\n\ntype AllOptionalKeys<T extends Record<string, unknown>> = T extends Record<string, never>\n ? never\n : Exclude<\n {\n [K in keyof T]: undefined extends T[K] ? K : never\n }[keyof T],\n undefined\n >\n\ntype HasRequired<T extends Record<string, unknown>> = T extends Record<string, never>\n ? false\n : [keyof T] extends [AllOptionalKeys<T>]\n ? false\n : true\n\ntype PickRecordsWithAnyRequired<T extends Record<string, Record<string, unknown>>> =\n T extends Record<string, never>\n ? never\n : Exclude<\n {\n [K in keyof T]: HasRequired<T[K]> extends true ? K : never\n }[keyof T],\n undefined\n >\n\nexport type OptionalEmptyRecords<T extends Record<string, Record<string, unknown>>> = {\n [K in Exclude<keyof T, PickRecordsWithAnyRequired<T>>]?: OptionalUndefinedFields<T[K]>\n} & {\n [K in PickRecordsWithAnyRequired<T>]: OptionalUndefinedFields<T[K]>\n}\n\nexport type OptionalUndefinedFields<T extends Record<string, unknown>> = {\n [K in PickUndefinedKeys<T>]?: T[K]\n} & {\n [K in Exclude<keyof T, PickUndefinedKeys<T>>]: T[K]\n}\n\n/**\n * Marks specific keys in a type as optional.\n *\n * @template T The type to modify.\n * @template K The keys to make optional.\n */\nexport type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\n\n/**\n * Marks specific keys in a type as required.\n *\n * @template T The type to modify.\n * @template K The keys to make required.\n */\nexport type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>\n\n/**\n * Formats a multiline string and trims the indentation.\n *\n * @param str The string to trim.\n * @returns The trimmed string.\n */\nexport function text(strings: TemplateStringsArray, ...values: unknown[]): string {\n // Convert all values to strings\n const stringValues = values.map(String)\n\n // Build full string with values interpolated\n let result = \"\"\n for (let i = 0; i < strings.length; i++) {\n result += strings[i]\n if (i < stringValues.length) {\n const value = stringValues[i]\n const lines = value.split(\"\\n\")\n const lastLineIndentMatch = strings[i].match(/(?:^|\\n)([ \\t]*)$/)\n const indent = lastLineIndentMatch ? lastLineIndentMatch[1] : \"\"\n\n result += lines.map((line, j) => (j === 0 ? line : indent + line)).join(\"\\n\")\n }\n }\n\n return trimIndentation(result)\n}\n\n/**\n * Removes the indentation from a multiline string.\n *\n * @param text The text to trim.\n * @returns The trimmed text.\n */\nexport function trimIndentation(text: string): string {\n const lines = text.split(\"\\n\")\n const indent = lines\n .filter(line => line.trim() !== \"\")\n .map(line => line.match(/^\\s*/)?.[0].length ?? 0)\n .reduce((min, indent) => Math.min(min, indent), Infinity)\n\n return lines\n .map(line => line.slice(indent))\n .join(\"\\n\")\n .trim()\n}\n\n/**\n * Converts bytes to a human-readable format.\n *\n * @param bytes The number of bytes.\n * @returns The human-readable string representation of the bytes.\n */\nexport function bytesToHumanReadable(bytes: number): string {\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\"]\n if (bytes === 0) return \"0 Bytes\"\n\n const i = Math.floor(Math.log(bytes) / Math.log(1024))\n return `${parseFloat((bytes / 1024 ** i).toFixed(2))} ${sizes[i]}`\n}\n\n/**\n * Checks if a value matches the given Zod schema and narrows the type accordingly.\n *\n * @param schema The Zod schema to check against.\n * @param value The value to check.\n * @returns `true` if the value matches the schema, `false` otherwise.\n */\nexport function check<TSchema extends z.ZodType>(\n schema: TSchema,\n value: unknown,\n): value is z.infer<TSchema> {\n return schema.safeParse(value).success\n}\n\n/**\n * Gets or creates a value in a map, using a factory function if the key does not exist.\n *\n * @param map The map to check.\n * @param key The key to look for.\n * @param createFn The function to create a new value if the key does not exist.\n * @returns The value associated with the key.\n */\nexport function getOrCreate<TKey, TValue>(\n map: Map<TKey, TValue>,\n key: TKey,\n createFn: (key: TKey) => TValue,\n): TValue {\n const existing = map.get(key)\n if (existing !== undefined) {\n return existing\n }\n\n const value = createFn(key)\n map.set(key, value)\n return value\n}\n\n/**\n * Strips nullish values from an object.\n *\n * @param obj The object to strip.\n * @returns A new object with all nullish values removed.\n */\nexport function stripNullish<T extends Record<string, unknown>>(obj: T) {\n return pickBy(obj, isNonNullish)\n}\n"]}
1
+ {"version":3,"sources":["../src/i18n.ts","../src/meta.ts","../src/entity.ts","../src/evaluation.ts","../src/component.ts","../src/instance.ts","../src/unit.ts","../src/trigger.ts","../src/pulumi.ts","../src/terminal.ts","../src/page.ts","../src/worker.ts","../src/compaction.ts","../src/utils.ts"],"names":["text","z","outputs","mapValues","inputs","HighstateSignature","WellKnownInstanceCustomStatus","HighstateConfigKey","visitedIds","indent","pickBy","isNonNullish"],"mappings":";;;;;;;;AAAA,IAAM,qBAAA,uBAA4B,GAAA,EAAoB;AAE/C,SAAS,2BAA2B,aAAA,EAAyB;AAClE,EAAA,KAAA,MAAW,QAAQ,aAAA,EAAe;AAChC,IAAA,MAAM,KAAA,GAAQ,KAAK,WAAA,EAAY;AAC/B,IAAA,IAAI,CAAC,qBAAA,CAAsB,GAAA,CAAI,KAAK,CAAA,EAAG;AACrC,MAAA,qBAAA,CAAsB,GAAA,CAAI,OAAO,IAAI,CAAA;AAAA,IACvC;AAAA,EACF;AACF;AAEO,SAAS,uBAAA,GAA0B;AACxC,EAAA,qBAAA,CAAsB,KAAA,EAAM;AAC9B;AAEO,SAAS,yBAAyBA,KAAAA,EAAc;AAGrD,EAAA,MAAM,KAAA,GAAQA,MACX,KAAA,CAAM,qDAAqD,EAC3D,MAAA,CAAO,CAAA,IAAA,KAAQ,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AAEjC,EAAA,OAAO,KAAA,CACJ,IAAI,CAAA,IAAA,KAAQ;AACX,IAAA,MAAM,KAAA,GAAQ,KAAK,WAAA,EAAY;AAC/B,IAAA,IAAI,qBAAA,CAAsB,GAAA,CAAI,KAAK,CAAA,EAAG;AACpC,MAAA,OAAO,qBAAA,CAAsB,IAAI,KAAK,CAAA;AAAA,IACxC;AAEA,IAAA,OAAO,IAAA,CAAK,OAAO,CAAC,CAAA,C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A,QAAA,EACQ;AACR,EAAA,MAAM,QAAA,GAAW,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA;AAC5B,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,MAAM,KAAA,GAAQ,SAAS,GAAG,CAAA;AAC1B,EAAA,GAAA,CAAI,GAAA,CAAI,KAAK,KAAK,CAAA;AAClB,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,aAAgD,GAAA,EAAQ;AACtE,EAAA,OAAOC,MAAAA,CAAO,KAAKC,YAAY,CAAA;AACjC","file":"index.js","sourcesContent":["const knownAbbreviationsMap = new Map<string, string>()\n\nexport function registerKnownAbbreviations(abbreviations: string[]) {\n for (const abbr of abbreviations) {\n const lower = abbr.toLowerCase()\n if (!knownAbbreviationsMap.has(lower)) {\n knownAbbreviationsMap.set(lower, abbr)\n }\n }\n}\n\nexport function clearKnownAbbreviations() {\n knownAbbreviationsMap.clear()\n}\n\nexport function camelCaseToHumanReadable(text: string) {\n // split on: word boundaries between consecutive uppercase and lowercase letters,\n // single uppercase letters followed by lowercase, and separators\n const words = text\n .split(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|_|-|\\./)\n .filter(word => word.length > 0)\n\n return words\n .map(word => {\n const lower = word.toLowerCase()\n if (knownAbbreviationsMap.has(lower)) {\n return knownAbbreviationsMap.get(lower)\n }\n\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join(\" \")\n}\n","import { z } from \"zod\"\n\nexport const objectMetaSchema = z.object({\n /**\n * Human-readable name of the object.\n *\n * Used in UI components for better user experience.\n */\n title: z.string().optional(),\n\n /**\n * The title used globally for the object.\n *\n * For example, the title of an instance secret is \"Password\" which is okay\n * to display in the instance secret list, but when the secret is displayed in a\n * global secret list the name should be more descriptive, like \"Proxmox Password\".\n */\n globalTitle: z.string().optional(),\n\n /**\n * Description of the object.\n *\n * Provides additional context for users and developers.\n */\n description: z.string().optional(),\n\n /**\n * The color of the object.\n *\n * Used in UI components to visually distinguish objects.\n */\n color: z.string().optional(),\n\n /**\n * Primary icon identifier.\n *\n * Should reference a iconify icon name, like \"mdi:server\" or \"gg:remote\".\n */\n icon: z.string().optional(),\n\n /**\n * The color of the primary icon.\n */\n iconColor: z.string().optional(),\n\n /**\n * The URL of the custom image that should be used as the icon or avatar.\n */\n avatarUrl: z.string().optional(),\n\n /**\n * The secondary icon identifier.\n *\n * Used to provide additional context or actions related to the object.\n *\n * Should reference a iconify icon name, like \"mdi:edit\" or \"mdi:delete\".\n */\n secondaryIcon: z.string().optional(),\n\n /**\n * The color of the secondary icon.\n */\n secondaryIconColor: z.string().optional(),\n})\n\n/**\n * The schema for object metadata used in more than a half of the Highstate objects.\n *\n * Consists of `title`, `description`, `icon`, and `iconColor` fields where the `title` is required.\n */\nexport const commonObjectMetaSchema = objectMetaSchema\n .pick({\n title: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({\n title: true,\n })\n\nexport const globalCommonObjectMetaSchema = objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({\n title: true,\n })\n\nexport const serviceAccountMetaSchema = objectMetaSchema\n .pick({\n title: true,\n description: true,\n avatarUrl: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true })\n\nexport const timestampsSchema = z.object({\n /**\n * The timestamp when the object was created.\n */\n createdAt: z.date(),\n\n /**\n * The timestamp when the object was last updated.\n */\n updatedAt: z.date(),\n})\n\n/**\n * The schema for strings that represent names in Highstate.\n *\n * The name:\n * - must be alphanumeric;\n * - can include dashes (`-`) as word separators and dots (`.`) as namespace separators;\n * - must begin with a letter;\n * - must be lowercase;\n * - must include from 2 to 64 characters.\n */\nexport const genericNameSchema = z\n .string()\n .regex(\n /^[a-z][a-z0-9-.]+$/,\n \"Name must start with a letter and can only contain lowercase letters, numbers, dashes (-) and dots (.)\",\n )\n .min(2)\n .max(64)\n\nexport const versionedNameSchema = z.union([\n z.templateLiteral([genericNameSchema, z.literal(\".\"), z.literal(\"v\"), z.number().int().min(1)]),\n\n // to prevent TypeScript matching \"proxmox.virtual-machine.v2\" as\n // 1. \"proxmox.v\"\n // 2. \"irtual-machine.v2\" and thinking it should be a number\n z.templateLiteral([\n genericNameSchema,\n z.literal(\".\"),\n genericNameSchema,\n z.literal(\".\"),\n z.literal(\"v\"),\n z.number().int().min(1),\n ]),\n z.templateLiteral([\n genericNameSchema,\n z.literal(\".\"),\n genericNameSchema,\n z.literal(\".\"),\n genericNameSchema,\n z.literal(\".\"),\n z.literal(\"v\"),\n z.number().int().min(1),\n ]),\n])\n\n/**\n * Parses a versioned name into its base name and version.\n *\n * @param name The versioned name to parse.\n * @returns A tuple containing the base name and version number.\n * @throws If the name is not in the correct format or if the version is invalid.\n */\nexport function parseVersionedName(name: string): [name: string, version: number] {\n const lastDotVIndex = name.lastIndexOf(\".v\")\n if (lastDotVIndex === -1) {\n throw new Error(`Invalid versioned name: ${name}`)\n }\n\n const baseName = name.substring(0, lastDotVIndex)\n const versionPart = name.substring(lastDotVIndex + 2) // +2 to skip \".v\"\n\n const version = parseInt(versionPart, 10)\n if (Number.isNaN(version) || version < 0) {\n throw new Error(`Invalid version in versioned name: ${name}`)\n }\n\n return [baseName, version]\n}\n\n/**\n * The schema for field names in Highstate.\n *\n * The field name:\n * - must be alphanumeric;\n * - must be in camelCase;\n * - must begin with a letter;\n * - must include from 2 to 64 characters.\n */\nexport const fieldNameSchema = z\n .string()\n .regex(/^[a-z][a-zA-Z0-9]+$/, \"Field name must start with a letter and be in camelCase format\")\n .min(2)\n .max(64)\n\nexport type ObjectMeta = z.infer<typeof objectMetaSchema>\nexport type CommonObjectMeta = z.infer<typeof commonObjectMetaSchema>\nexport type GlobalCommonObjectMeta = z.infer<typeof globalCommonObjectMetaSchema>\nexport type ServiceAccountMeta = z.infer<typeof serviceAccountMetaSchema>\nexport type GenericName = z.infer<typeof genericNameSchema>\nexport type VersionedName = z.infer<typeof versionedNameSchema>\nexport type FieldName = z.infer<typeof fieldNameSchema>\n","import type { IsEmptyObject, Simplify } from \"type-fest\"\nimport type { PartialKeys } from \"./utils\"\nimport { z } from \"zod\"\nimport { camelCaseToHumanReadable } from \"./i18n\"\nimport {\n objectMetaSchema,\n parseVersionedName,\n type VersionedName,\n versionedNameSchema,\n} from \"./meta\"\n\nexport const entityInclusionSchema = z.object({\n /**\n * The static type of the included entity.\n */\n type: versionedNameSchema,\n\n /**\n * Whether the included entity is required.\n * If false, the entity may be omitted.\n */\n required: z.boolean(),\n\n /**\n * Whether the included entity is multiple.\n */\n multiple: z.boolean(),\n\n /**\n * The name of the field where the included entity is embedded.\n */\n field: z.string(),\n})\n\n/**\n * The entity is some abstract object which can be passed from one component to another through their inputs and outputs.\n * Every entity must have a type.\n * Every component inputs and outputs will reference such types and only entities of the same type can be passed.\n */\nexport const entityModelSchema = z.object({\n /**\n * The static type of the entity.\n */\n type: versionedNameSchema,\n\n /**\n * The list of all extended entity types (direct and indirect).\n */\n extensions: z.string().array().optional(),\n\n /**\n * The list of directly extended entity types.\n */\n directExtensions: z.string().array().optional(),\n\n /**\n * The list of all included entities (directly or inherited from extensions).\n */\n inclusions: entityInclusionSchema.array().optional(),\n\n /**\n * The list of directly included entities.\n */\n directInclusions: entityInclusionSchema.array().optional(),\n\n /**\n * The JSON schema of the entity value.\n */\n schema: z.custom<z.core.JSONSchema.BaseSchema>(),\n\n /**\n * The extra metadata of the entity.\n */\n meta: objectMetaSchema.required({ title: true }).pick({\n title: true,\n description: true,\n color: true,\n icon: true,\n iconColor: true,\n }),\n\n /**\n * The CRC32 of the entity definition.\n */\n definitionHash: z.number(),\n})\n\nexport type EntityInclusion = z.infer<typeof entityInclusionSchema>\nexport type EntityModel = z.infer<typeof entityModelSchema>\nexport type EntityTypes = Record<VersionedName, true>\n\nexport declare const implementedTypes: unique symbol\n\nexport type Entity<\n TType extends VersionedName = VersionedName,\n TImplementedTypes extends EntityTypes = EntityTypes,\n TSchema extends z.ZodTypeAny = z.ZodTypeAny,\n> = {\n /**\n * The static type of the entity.\n */\n type: TType\n\n /**\n * The all types implemented by this entity including its own type.\n *\n * Does not exist at runtime.\n */\n [implementedTypes]: TImplementedTypes\n\n /**\n * The zod schema of the entity value.\n */\n schema: TSchema\n\n /**\n * The model of the entity.\n */\n model: EntityModel\n}\n\ntype EntityOptions<\n TType extends VersionedName,\n TSchema extends z.ZodType,\n TExtends extends Record<string, Entity>,\n TIncludes extends Record<string, EntityIncludeRef>,\n> = {\n /**\n * The static type of the entity.\n */\n type: TType\n\n /**\n * The JSON schema of the entity value.\n */\n schema: TSchema\n\n /**\n * The extra metadata of the entity.\n */\n meta?: PartialKeys<z.infer<typeof objectMetaSchema>, \"title\">\n\n /**\n * The list of entities to extend.\n *\n * The intersection of them will be used as the base schema and then intersected again with the provided schema.\n *\n * Note: Intersection does not mean inheritance or blind property merging.\n * If two base types have field with the same name but different types,\n * the resulting type of the field will be the intersection of the two types (and most likely `never`).\n */\n extends?: TExtends\n\n /**\n * The list of entities to include.\n *\n * Inclusion is more powerful mechanism that allows to embed other entities into this entity\n * and then substitute them instead of this entity when connected to component inputs of included types.\n */\n includes?: TIncludes\n}\n\nexport type EntityIncludeRef = Entity | { entity: Entity; multiple?: boolean; required?: boolean }\n\nfunction isEntityIncludeRef(\n value: EntityIncludeRef,\n): value is { entity: Entity; multiple?: boolean; required?: boolean } {\n return typeof value === \"object\" && value !== null && \"entity\" in value\n}\n\ntype InclusionShape<TImplements extends Record<string, EntityIncludeRef>> = {\n [K in keyof TImplements]: TImplements[K] extends {\n entity: infer E\n multiple?: infer M\n required?: infer R\n }\n ? E extends Entity\n ? M extends true\n ? R extends false\n ? z.ZodOptional<z.ZodArray<E[\"schema\"]>>\n : z.ZodArray<E[\"schema\"]>\n : R extends false\n ? z.ZodOptional<E[\"schema\"]>\n : E[\"schema\"]\n : never\n : TImplements[K] extends Entity\n ? TImplements[K][\"schema\"]\n : never\n}\n\ntype AddSchemaExtensions<\n TSchema extends z.ZodTypeAny,\n TExtends extends Record<string, Entity>,\n> = TExtends extends Record<string, never>\n ? TSchema\n : IsEmptyObject<TExtends> extends true\n ? TSchema\n : {\n [K in keyof TExtends]: AddSchemaExtensions<\n z.ZodIntersection<TSchema, TExtends[K][\"schema\"]>,\n Omit<TExtends, K>\n >\n }[keyof TExtends]\n\ntype AddTypeExtensions<\n TImplementedTypes extends EntityTypes,\n TExtends extends Record<string, Entity>,\n> = TExtends extends Record<string, never>\n ? TImplementedTypes\n : IsEmptyObject<TExtends> extends true\n ? TImplementedTypes\n : {\n [K in keyof TExtends]: AddTypeExtensions<\n TImplementedTypes & TExtends[K][typeof implementedTypes],\n Omit<TExtends, K>\n >\n }[keyof TExtends]\n\ntype AddSchemaInclusions<\n TSchema extends z.ZodTypeAny,\n TImplements extends Record<string, EntityIncludeRef>,\n> = TImplements extends Record<string, never>\n ? TSchema\n : z.ZodIntersection<TSchema, z.ZodObject<InclusionShape<TImplements>>>\n\ntype AddTypeInclusions<\n TImplementedTypes extends EntityTypes,\n TImplements extends Record<string, EntityIncludeRef>,\n> = TImplements extends Record<string, never>\n ? TImplementedTypes\n : {\n [K in keyof TImplements]: TImplements[K] extends {\n entity: infer E\n }\n ? E extends Entity\n ? AddTypeInclusions<TImplementedTypes & E[typeof implementedTypes], Omit<TImplements, K>>\n : TImplementedTypes\n : TImplements[K] extends Entity\n ? AddTypeInclusions<\n TImplementedTypes & TImplements[K][typeof implementedTypes],\n Omit<TImplements, K>\n >\n : TImplementedTypes\n }[keyof TImplements]\n\nexport function defineEntity<\n TType extends VersionedName,\n TSchema extends z.ZodType,\n TExtends extends Record<string, Entity> = Record<string, never>,\n TImplements extends Record<string, EntityIncludeRef> = Record<string, never>,\n>(\n options: EntityOptions<TType, TSchema, TExtends, TImplements>,\n): Entity<\n TType,\n Simplify<AddTypeInclusions<AddTypeExtensions<{ [K in TType]: true }, TExtends>, TImplements>>,\n AddSchemaExtensions<AddSchemaInclusions<TSchema, TImplements>, TExtends>\n> {\n try {\n entityModelSchema.shape.type.parse(options.type)\n } catch (error) {\n throw new Error(`Invalid entity type \"${options.type}\"`, { cause: error })\n }\n\n if (!options.schema) {\n throw new Error(\"Entity schema is required\")\n }\n\n const includedEntities = Object.entries(options.includes ?? {}).map(([field, entityRef]) => {\n if (isEntityIncludeRef(entityRef)) {\n return {\n entity: entityRef.entity,\n inclusion: {\n type: entityRef.entity.type,\n required: entityRef.required ?? true,\n multiple: entityRef.multiple ?? false,\n field,\n },\n }\n }\n\n return {\n entity: entityRef,\n inclusion: {\n type: entityRef.type,\n required: true,\n multiple: false,\n field,\n },\n }\n })\n\n const inclusionShape = includedEntities.reduce(\n (shape, { entity, inclusion }) => {\n if (inclusion.multiple) {\n shape[inclusion.field] = inclusion.required\n ? entity.schema.array()\n : entity.schema.array().optional()\n } else {\n shape[inclusion.field] = inclusion.required ? entity.schema : entity.schema.optional()\n }\n\n return shape\n },\n {} as Record<string, z.ZodTypeAny>,\n )\n\n let finalSchema = Object.values(options.extends ?? {}).reduce(\n (schema, entity) => z.intersection(schema, entity.schema),\n options.schema as z.ZodType,\n )\n\n if (includedEntities.length > 0) {\n finalSchema = z.intersection(finalSchema, z.object(inclusionShape))\n }\n\n const directInclusions = includedEntities.map(({ inclusion }) => inclusion)\n const directExtensions = Object.values(options.extends ?? {}).map(entity => entity.type)\n\n const inclusions = Object.values(options.extends ?? {}).reduce(\n (incs, entity) => {\n if (entity.model.inclusions) {\n incs.push(...entity.model.inclusions)\n }\n\n return incs\n },\n [...directInclusions],\n )\n\n const extensions = Object.values(options.extends ?? {}).reduce((exts, entity) => {\n exts.push(...(entity.model.extensions ?? []), entity.type)\n\n return exts\n }, [] as string[])\n\n try {\n let _schema: z.core.JSONSchema.BaseSchema\n\n return {\n type: options.type,\n schema: finalSchema,\n model: {\n type: options.type,\n extensions: extensions.length > 0 ? extensions : undefined,\n directExtensions: directExtensions.length > 0 ? directExtensions : undefined,\n inclusions: inclusions.length > 0 ? inclusions : undefined,\n directInclusions: directInclusions.length > 0 ? directInclusions : undefined,\n get schema() {\n if (!_schema) {\n // TODO: forbid unrepresentable types (and find way to filter out \"undefined\" literals)\n _schema = z.toJSONSchema(finalSchema, { target: \"draft-7\", unrepresentable: \"any\" })\n }\n\n return _schema\n },\n meta: {\n ...options.meta,\n title:\n options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),\n },\n // will be calculated by the library loader\n definitionHash: null!,\n },\n // biome-ignore lint/suspicious/noExplicitAny: we already typed return type\n } as any\n } catch (error) {\n throw new Error(`Failed to define entity \"${options.type}\"`, { cause: error })\n }\n}\n\nexport function isEntity(value: unknown): value is Entity {\n return typeof value === \"object\" && value !== null && \"model\" in value\n}\n\n/**\n * Checks whether the given entity can be assigned to the target type.\n *\n * An entity is considered assignable to a target type if:\n * - The entity's type is exactly the same as the target type.\n * - The entity extends the target type (either directly or indirectly).\n * - The entity includes the target type (either directly or indirectly).\n *\n * @param entity The entity to check.\n * @param target The target versioned name to check against.\n * @returns True if the entity is assignable to the target type, false otherwise.\n */\nexport function isAssignableTo(entity: EntityModel, target: VersionedName): boolean {\n if (entity.type === target) {\n return true\n }\n\n if (entity.extensions?.includes(target)) {\n return true\n }\n\n return entity.inclusions?.some(implementation => implementation.type === target) ?? false\n}\n","import type { Component } from \"./component\"\nimport type { InstanceInput, InstanceModel } from \"./instance\"\nimport { mapValues } from \"remeda\"\n\nexport type RuntimeInstance = {\n instance: InstanceModel\n component: Component\n}\n\nexport const boundaryInput = Symbol(\"boundaryInput\")\nexport const boundaryInputs = Symbol(\"boundaryInputs\")\n\nfunction formatInstancePath(instance: InstanceModel): string {\n let result = instance.id\n while (instance.parentId) {\n const parent = runtimeInstances.get(instance.parentId)?.instance\n if (!parent) {\n break\n }\n\n result = `${parent.id} -> ${result}`\n instance = parent\n }\n\n return result\n}\n\nexport class InstanceNameConflictError extends Error {\n constructor(\n readonly instanceId: string,\n readonly firstPath: string,\n readonly secondPath: string,\n ) {\n super(\n `Multiple instances produced with the same instance ID \"${instanceId}\":\\n` +\n `1. ${firstPath}\\n` +\n `2. ${secondPath}`,\n )\n\n this.name = \"InstanceNameConflictError\"\n }\n}\n\nlet currentInstance: InstanceModel | null = null\n\nconst runtimeInstances: Map<string, RuntimeInstance> = new Map()\n\n/**\n * Resets the evaluation state, clearing all collected composite instances and runtime instances.\n */\nexport function resetEvaluation(): void {\n runtimeInstances.clear()\n currentInstance = null\n}\n\n/**\n * Returns all runtime instances collected during the evaluation.\n *\n * Note that these instances are not serializable.\n */\nexport function getRuntimeInstances(): RuntimeInstance[] {\n return Array.from(runtimeInstances.values())\n}\n\nexport function registerInstance<T>(component: Component, instance: InstanceModel, fn: () => T): T {\n const conflicting = runtimeInstances.get(instance.id)\n if (conflicting) {\n throw new InstanceNameConflictError(\n instance.id,\n formatInstancePath(conflicting.instance),\n formatInstancePath(instance),\n )\n }\n\n runtimeInstances.set(instance.id, { instance, component })\n\n let previousParentInstance: InstanceModel | null = null\n\n if (currentInstance) {\n instance.parentId = currentInstance.id\n }\n\n if (component.model.kind === \"composite\") {\n previousParentInstance = currentInstance\n currentInstance = instance\n }\n\n try {\n const outputs = fn() as Record<string, InstanceInput[]>\n\n instance.resolvedOutputs = outputs\n instance.outputs = mapValues(outputs ?? {}, outputs =>\n outputs.map(output => output[boundaryInput] ?? output),\n )\n\n // mark all outputs with the boundary input of the instance\n return mapValues(outputs, (outputs, outputKey) =>\n outputs.map(output => ({\n ...output,\n [boundaryInput]: { instanceId: instance.id, output: outputKey },\n })),\n ) as T\n } finally {\n if (previousParentInstance) {\n currentInstance = previousParentInstance\n }\n }\n}\n","/** biome-ignore-all lint/suspicious/noExplicitAny: maybe fix later */\n\nimport type { Simplify } from \"type-fest\"\nimport type { Entity, implementedTypes } from \"./entity\"\nimport type { OptionalEmptyRecords, OptionalUndefinedFields, PartialKeys } from \"./utils\"\nimport { isNonNullish, mapValues, pickBy, uniqueBy } from \"remeda\"\nimport { z } from \"zod\"\nimport { boundaryInput, boundaryInputs, registerInstance } from \"./evaluation\"\nimport { camelCaseToHumanReadable } from \"./i18n\"\nimport { type InstanceId, type InstanceInput, type InstanceInputGroup, inputKey } from \"./instance\"\nimport {\n fieldNameSchema,\n genericNameSchema,\n objectMetaSchema,\n parseVersionedName,\n type VersionedName,\n versionedNameSchema,\n} from \"./meta\"\n\nexport const runtimeSchema = Symbol(\"runtimeSchema\")\n\nlet validationEnabled = true\n\nexport function setValidationEnabled(enabled: boolean): void {\n validationEnabled = enabled\n}\n\nexport const componentKindSchema = z.enum([\"composite\", \"unit\"])\nexport type ComponentKind = z.infer<typeof componentKindSchema>\n\nexport const componentArgumentSchema = z.object({\n /**\n * The JSON schema of the argument value.\n */\n schema: z.custom<z.core.JSONSchema.BaseSchema>(),\n\n /**\n * The original Zod schema of the argument.\n *\n * Only available at runtime.\n */\n [runtimeSchema]: z.instanceof(z.ZodType).optional(),\n\n /**\n * Whether the argument is required.\n */\n required: z.boolean(),\n\n /**\n * The extra metadata of the argument.\n */\n meta: objectMetaSchema.required({ title: true }).pick({\n title: true,\n globalTitle: true,\n description: true,\n color: true,\n icon: true,\n iconColor: true,\n }),\n})\n\nexport type ComponentArgument = z.infer<typeof componentArgumentSchema>\n\nexport type FullComponentArgumentOptions = {\n schema: z.ZodType\n meta?: PartialKeys<ComponentArgument[\"meta\"], \"title\">\n}\n\nexport type ComponentArgumentOptions = z.ZodType | FullComponentArgumentOptions\n\nexport type ComponentArgumentOptionsToSchema<T extends ComponentArgumentOptions> =\n T extends FullComponentArgumentOptions ? T[\"schema\"] : T\n\nexport const componentInputSchema = z.object({\n /**\n * The type of the entity passed through the input.\n */\n type: versionedNameSchema,\n\n /**\n * Whether the input is required.\n */\n required: z.boolean(),\n\n /**\n * Whether the input can have multiple values.\n */\n multiple: z.boolean(),\n\n /**\n * The extra metadata of the input.\n */\n meta: objectMetaSchema.required({ title: true }).pick({\n title: true,\n description: true,\n }),\n})\n\nexport type ComponentInput = z.infer<typeof componentInputSchema>\n\nexport type FullComponentInputOptions = {\n entity: Entity\n required?: boolean\n multiple?: boolean\n meta?: PartialKeys<ComponentInput[\"meta\"], \"title\">\n}\n\nexport type ComponentInputOptions = Entity | FullComponentInputOptions\n\ntype ComponentInputOptionsToOutputRef<T extends ComponentInputOptions> = T extends Entity\n ? InstanceInput<T[typeof implementedTypes]>\n : T extends FullComponentInputOptions\n ? T[\"required\"] extends false\n ? T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][typeof implementedTypes]>[] | undefined\n : InstanceInput<T[\"entity\"][typeof implementedTypes]> | undefined\n : T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][typeof implementedTypes]>[]\n : InstanceInput<T[\"entity\"][typeof implementedTypes]>\n : never\n\n/**\n * The type-level specification of a component input hold by the component model.\n */\nexport type ComponentInputSpec = [entity: Entity, required: boolean, multiple: boolean]\n\nexport type ComponentInputOptionsToSpec<T extends ComponentInputOptions> = T extends Entity\n ? [T, true, false] // [Entity, required, multiple]\n : T extends FullComponentInputOptions\n ? T[\"required\"] extends false\n ? T[\"multiple\"] extends true\n ? [T[\"entity\"], false, true]\n : [T[\"entity\"], false, false]\n : T[\"multiple\"] extends true\n ? [T[\"entity\"], true, true]\n : [T[\"entity\"], true, false]\n : never\n\nexport type ComponentInputOptionsMapToSpecMap<T extends Record<string, ComponentInputOptions>> =\n T extends Record<string, never>\n ? Record<string, never>\n : { [K in keyof T]: ComponentInputOptionsToSpec<T[K]> }\n\ntype ComponentInputMapToValue<T extends Record<string, ComponentInputOptions>> =\n OptionalUndefinedFields<{\n [K in keyof T]: ComponentInputOptionsToOutputRef<T[K]>\n }>\n\ntype ComponentInputMapToReturnType<T extends Record<string, ComponentInputOptions>> =\n // biome-ignore lint/suspicious/noConfusingVoidType: this is return type\n T extends Record<string, never> ? void : ComponentInputMapToValue<T>\n\nexport type ComponentParams<\n TArgs extends Record<string, ComponentArgumentOptions>,\n TInputs extends Record<string, ComponentInputOptions>,\n> = {\n id: InstanceId\n name: string\n args: { [K in keyof TArgs]: z.infer<ComponentArgumentOptionsToSchema<TArgs[K]>> }\n inputs: ComponentInputMapToValue<TInputs>\n}\n\nexport type InputComponentParams<\n TArgs extends Record<string, unknown>,\n TInputs extends Record<string, unknown>,\n> = {\n name: string\n} & OptionalEmptyRecords<{\n args: TArgs\n inputs: TInputs\n}>\n\nexport type ComponentOptions<\n TType extends VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions>,\n TInputs extends Record<string, ComponentInputOptions>,\n TOutputs extends Record<string, ComponentInputOptions>,\n> = {\n /**\n * The type of the component.\n * Must be a valid versioned name.\n *\n * Examples: `proxmox.virtual-machine.v1`, `common.server.v1`.\n */\n type: TType\n\n /**\n * The extra metadata of the component.\n *\n * If title or defaultNamePrefix is not provided, they will be generated from the type.\n */\n meta?: PartialKeys<ComponentModel[\"meta\"], \"title\" | \"defaultNamePrefix\">\n\n /**\n * The specification of the component arguments.\n */\n args?: TArgs\n\n /**\n * The specification of the component inputs.\n */\n inputs?: TInputs\n\n /**\n * The specification of the component outputs.\n */\n outputs?: TOutputs\n\n /**\n * The create function of the component.\n *\n * It can create instances of other components and return their outputs.\n *\n * Note: All created instances must guarantee unique ids within the project.\n * Their names are not automatically prefixed with the component name,\n * so you must prefix them manually if needed or guarantee uniqueness in another way.\n */\n create: (params: ComponentParams<TArgs, TInputs>) => ComponentInputMapToReturnType<TOutputs>\n\n /**\n * For internal use only.\n */\n [kind]?: ComponentKind\n}\n\n// Models\nexport const componentModelSchema = z.object({\n /**\n * The type of the component.\n */\n type: genericNameSchema,\n\n /**\n * The kind of the component.\n */\n kind: componentKindSchema,\n\n /**\n * The record of the argument schemas.\n */\n args: z.record(fieldNameSchema, componentArgumentSchema),\n\n /**\n * The record of the input schemas.\n */\n inputs: z.record(fieldNameSchema, componentInputSchema),\n\n /**\n * The record of the output schemas.\n */\n outputs: z.record(fieldNameSchema, componentInputSchema),\n\n /**\n * The extra metadata of the component.\n */\n meta: objectMetaSchema\n .required({ title: true })\n .pick({\n title: true,\n description: true,\n color: true,\n icon: true,\n iconColor: true,\n secondaryIcon: true,\n secondaryIconColor: true,\n })\n .extend({\n /**\n * The category of the component.\n *\n * Used to group components in the UI.\n */\n category: z.string().optional(),\n\n /**\n * The default name prefix for the component instances.\n *\n * Used to generate default names for the instances.\n */\n defaultNamePrefix: z.string(),\n }),\n\n /**\n * The CRC32 of the component definition.\n */\n definitionHash: z.number(),\n})\n\nexport type ComponentModel = z.infer<typeof componentModelSchema>\n\ntype InputSpecToInputRef<T extends ComponentInputSpec> = T[1] extends true\n ? T[2] extends true\n ? InstanceInput<T[0][typeof implementedTypes]>[]\n : InstanceInput<T[0][typeof implementedTypes]>\n : T[2] extends true\n ? InstanceInput<T[0][typeof implementedTypes]>[] | undefined\n : InstanceInput<T[0][typeof implementedTypes]> | undefined\n\ntype InputSpecToOutputRef<T extends ComponentInputSpec> = T[2] extends true\n ? InstanceInput<T[0][typeof implementedTypes]>[]\n : InstanceInput<T[0][typeof implementedTypes]>\n\nexport type InputSpecMapToInputRefMap<TInputs extends Record<string, ComponentInputSpec>> =\n TInputs extends Record<string, [string, never, never]>\n ? Record<string, never>\n : { [K in keyof TInputs]: InputSpecToInputRef<TInputs[K]> }\n\nexport type OutputRefMap<TInputs extends Record<string, ComponentInputSpec>> =\n TInputs extends Record<string, [string, never, never]>\n ? Record<string, never>\n : { [K in keyof TInputs]: InputSpecToOutputRef<TInputs[K]> }\n\nexport const originalCreate = Symbol(\"originalCreate\")\nexport const kind = Symbol(\"kind\")\n\nexport type Component<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, z.ZodType> = Record<string, never>,\n TInputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n> = {\n /**\n * The type of the component.\n */\n type: TType\n\n /**\n * The non-generic model of the component.\n */\n model: ComponentModel\n\n /**\n * The entities used in the inputs or outputs of the component.\n */\n entities: Map<string, Entity>\n\n (\n context: InputComponentParams<\n { [K in keyof TArgs]: z.input<TArgs[K]> },\n InputSpecMapToInputRefMap<TInputs>\n >,\n ): OutputRefMap<TOutputs>\n\n /**\n * The original create function.\n *\n * Used to calculate the definition hash.\n */\n [originalCreate]: (params: InputComponentParams<any, any>) => any\n}\n\nexport function defineComponent<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions> = Record<string, never>,\n TInputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n>(\n options: ComponentOptions<TType, TArgs, TInputs, TOutputs>,\n): Component<\n TType,\n { [K in keyof TArgs]: ComponentArgumentOptionsToSchema<TArgs[K]> },\n { [K in keyof TInputs]: ComponentInputOptionsToSpec<TInputs[K]> },\n { [K in keyof TOutputs]: ComponentInputOptionsToSpec<TOutputs[K]> }\n> {\n try {\n componentModelSchema.shape.type.parse(options.type)\n } catch (error) {\n throw new Error(`Invalid component type \"${options.type}\"`, { cause: error })\n }\n\n if (!options.create) {\n throw new Error(\"Component create function is required\")\n }\n\n const entities = new Map<string, Entity>()\n const mapInput = createInputMapper(entities)\n\n const model: ComponentModel = {\n type: options.type,\n kind: options[kind] ?? \"composite\",\n args: mapValues(options.args ?? {}, mapArgument),\n inputs: mapValues(options.inputs ?? {}, mapInput),\n outputs: mapValues(options.outputs ?? {}, mapInput),\n meta: {\n ...options.meta,\n title: options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),\n defaultNamePrefix:\n options.meta?.defaultNamePrefix ||\n parseVersionedName(options.type)[0].split(\".\").slice(-1)[0],\n },\n // will be calculated by library loader\n definitionHash: null!,\n }\n\n function create(\n params: InputComponentParams<any, Record<string, InstanceInput | InstanceInputGroup>>,\n ): any {\n const { name, args = {}, inputs } = params\n const instanceId = getInstanceId(options.type, name)\n\n const flatInputs: Record<string, InstanceInputGroup> = {}\n const tracedInputs: Record<string, InstanceInput[]> = {}\n\n for (const [key, inputGroup] of Object.entries(inputs ?? {})) {\n if (!inputGroup) {\n continue\n }\n\n if (!Array.isArray(inputGroup)) {\n if (inputGroup[boundaryInput]) {\n tracedInputs[key] = [inputGroup[boundaryInput]]\n }\n\n flatInputs[key] = [inputGroup]\n continue\n }\n\n // merge \"boundaryInputs\" attached to array with \"boundaryInput\"s attached to individual items\n const group: InstanceInput[] = [...(inputGroup[boundaryInputs] ?? [])]\n const inputs: InstanceInput[] = []\n\n for (const item of inputGroup.flat(1)) {\n if (item[boundaryInput]) {\n group.push(item[boundaryInput])\n }\n\n inputs.push(item)\n }\n\n tracedInputs[key] = uniqueBy(group, inputKey)\n flatInputs[key] = uniqueBy(inputs, inputKey)\n }\n\n return registerInstance(\n create as unknown as Component,\n {\n id: instanceId,\n type: options.type,\n kind: options[kind] ?? \"composite\",\n name,\n args,\n inputs: tracedInputs,\n resolvedInputs: mapValues(flatInputs, inputs =>\n inputs.filter(input => !(\"provided\" in input && input.provided === false)),\n ),\n },\n () => {\n const markedInputs = mapValues(model.inputs, (componentInput, key) => {\n if (!componentInput.multiple) {\n // for single component use first available input and attach boundaryInput\n // technically, caller can pass multiple inputs or array of inputs ignoring the TypeScript restriction,\n // but we don't care about that\n const input = flatInputs[key]?.[0]\n\n if (input) {\n // return the input with boundaryInput attached\n // the input can also be \"OptionalInstanceInput\" with \"provided: false\", but this is still correct\n return { ...input, [boundaryInput]: { instanceId: instanceId, output: key } }\n }\n\n // create a new \"not provided\" input with boundaryInput attached\n return { provided: false, [boundaryInput]: { instanceId: instanceId, output: key } }\n }\n\n // then handle array of inputs\n // caller can provide array of array which will be flattened with boundaryInputs preserved\n // regardless of the number of inputs, we always attach boundaryInputs to the whole array\n const inputs = flatInputs[key] ?? []\n inputs[boundaryInputs] = [{ instanceId, output: key }]\n\n return inputs\n })\n\n const outputs: Record<string, InstanceInput[]> =\n options.create({\n id: instanceId,\n name,\n args: processArgs(instanceId, create.model, args) as any,\n inputs: markedInputs as any,\n }) ?? {}\n\n return mapValues(pickBy(outputs, isNonNullish), outputs => [outputs].flat(2))\n },\n )\n }\n\n try {\n create.entities = entities\n create.model = model\n\n create[originalCreate] = options.create\n\n return create as any\n } catch (error) {\n throw new Error(`Failed to define component \"${options.type}\"`, { cause: error })\n }\n}\n\nfunction processArgs(\n instanceId: InstanceId,\n model: ComponentModel,\n args: Record<string, unknown>,\n): Record<string, unknown> {\n if (!validationEnabled) {\n return args\n }\n\n const validatedArgs: Record<string, unknown> = {}\n\n for (const [key, arg] of Object.entries(model.args)) {\n if (arg.schema) {\n const result = arg[runtimeSchema]!.safeParse(args[key])\n\n if (!result.success) {\n throw new Error(\n `Invalid argument \"${key}\" in instance \"${instanceId}\": ${result.error.message}`,\n )\n }\n\n validatedArgs[key] = result.data\n } else {\n validatedArgs[key] = args[key]\n }\n }\n\n return validatedArgs\n}\n\n/**\n * Checks if the value is a Highstate component.\n *\n * Does not guarantee that the value is a valid component, only that it has the expected structure.\n *\n * @param value The value to check.\n * @returns True if the value is a component, false otherwise.\n */\nexport function isComponent(value: unknown): value is Component {\n return typeof value === \"function\" && \"model\" in value\n}\n\nfunction isSchemaOptional(schema: z.ZodType): boolean {\n return schema.safeParse(undefined).success\n}\n\nexport function mapArgument(value: ComponentArgumentOptions, key: string): ComponentArgument {\n if (\"schema\" in value) {\n return {\n schema: z.toJSONSchema(value.schema, {\n target: \"draft-7\",\n io: \"input\",\n unrepresentable: \"any\",\n }),\n [runtimeSchema]: value.schema,\n required: !isSchemaOptional(value.schema),\n meta: {\n ...value.meta,\n title: value.meta?.title || camelCaseToHumanReadable(key),\n },\n }\n }\n\n return {\n schema: z.toJSONSchema(value, { target: \"draft-7\", io: \"input\", unrepresentable: \"any\" }),\n [runtimeSchema]: value,\n required: !isSchemaOptional(value),\n meta: {\n title: camelCaseToHumanReadable(key),\n },\n }\n}\n\nexport function createInputMapper(entities: Map<string, Entity>) {\n return (value: ComponentInputOptions, key: string): ComponentInput => {\n if (!value) {\n throw new Error(`Input/output \"${key}\" is undefined in the component model.`)\n }\n\n if (\"entity\" in value) {\n entities.set(value.entity.type, value.entity)\n\n return {\n type: value.entity.type,\n required: value.required ?? true,\n multiple: value.multiple ?? false,\n meta: {\n ...value.meta,\n title: value.meta?.title || camelCaseToHumanReadable(key),\n },\n }\n }\n\n entities.set(value.type, value)\n\n return {\n type: value.type,\n required: true,\n multiple: false,\n meta: {\n title: camelCaseToHumanReadable(key),\n },\n }\n }\n}\n\n/**\n * Formats the instance id from the instance type and instance name.\n *\n * @param instanceType The type of the instance.\n * @param instanceName The name of the instance.\n *\n * @returns The formatted instance id.\n */\nexport function getInstanceId(instanceType: VersionedName, instanceName: string): InstanceId {\n return `${instanceType}:${instanceName}`\n}\n\nexport type ToFullComponentArgumentOptions<T extends Record<string, ComponentArgumentOptions>> =\n Simplify<{\n [K in keyof T]: T[K] extends z.ZodType ? { schema: T[K] } : T[K]\n }>\n\nexport function toFullComponentArgumentOptions<T extends Record<string, ComponentArgumentOptions>>(\n args: T,\n): ToFullComponentArgumentOptions<T> {\n return mapValues(args, arg => (\"schema\" in arg ? arg : { schema: arg })) as any\n}\n\ntype ToFullComponentInputOptions<T extends Record<string, ComponentInputOptions>> = Simplify<{\n [K in keyof T]: T[K] extends Entity ? { entity: T[K] } : T[K]\n}>\n\nfunction toFullComponentInputOptions<T extends Record<string, ComponentInputOptions>>(\n inputs: T,\n): ToFullComponentInputOptions<T> {\n return mapValues(inputs, input => (\"entity\" in input ? input : { entity: input })) as any\n}\n\n/**\n * The helper marker for component arguments.\n *\n * Helps validating arguments types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $args<T extends Record<string, ComponentArgumentOptions>>(\n args: T,\n): ToFullComponentArgumentOptions<T> {\n return toFullComponentArgumentOptions(args)\n}\n\n/**\n * The helper marker for component inputs.\n *\n * Helps validating inputs types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $inputs<T extends Record<string, ComponentInputOptions>>(\n inputs: T,\n): ToFullComponentInputOptions<T> {\n return toFullComponentInputOptions(inputs)\n}\n\n/**\n * The helper marker for component outputs.\n *\n * Helps validating outputs types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $outputs<T extends Record<string, ComponentInputOptions>>(\n outputs: T,\n): ToFullComponentInputOptions<T> {\n return toFullComponentInputOptions(outputs)\n}\n\n/**\n * Adds a description to the argument which can be both a schema or full argument options.\n *\n * Used by the compiler to inject descriptions into the argument schema.\n * You probably won't need to use it directly.\n */\nexport function $addArgumentDescription(\n argument: ComponentArgumentOptions,\n description: string,\n): FullComponentArgumentOptions {\n if (\"schema\" in argument) {\n return {\n ...argument,\n meta: {\n ...argument.meta,\n description: argument.meta?.description ?? description,\n },\n }\n }\n\n return {\n schema: argument,\n meta: {\n description: description,\n },\n }\n}\n\n/**\n * Adds a description to the input which can be both an entity or full input options.\n *\n * Used by the compiler to inject descriptions into the input schema.\n * You probably won't need to use it directly.\n */\nexport function $addInputDescription(\n input: ComponentInputOptions,\n description: string,\n): ComponentInputOptions {\n if (\"entity\" in input) {\n return {\n ...input,\n meta: {\n ...input.meta,\n description: input.meta?.description ?? description,\n },\n }\n }\n\n return {\n entity: input,\n meta: {\n description: description,\n },\n }\n}\n","import type { Entity, EntityTypes } from \"./entity\"\nimport type { boundaryInput, boundaryInputs } from \"./evaluation\"\nimport { z } from \"zod\"\nimport { componentKindSchema } from \"./component\"\nimport {\n type GenericName,\n genericNameSchema,\n objectMetaSchema,\n type VersionedName,\n versionedNameSchema,\n} from \"./meta\"\n\ndeclare const type: unique symbol\n\nexport type InstanceInput<TTypes extends EntityTypes = EntityTypes> = {\n [type]?: TTypes\n [boundaryInput]?: InstanceInput\n instanceId: InstanceId\n output: string\n}\n\nexport type EntityInput<TEntity extends Entity> = TEntity extends Entity<\n VersionedName,\n infer TImplementedTypes\n>\n ? InstanceInput<TImplementedTypes>\n : never\n\nexport type OptionalInstanceInput<TTypes extends EntityTypes = EntityTypes> =\n | ({ provided: true } & InstanceInput<TTypes>)\n | { provided: false; [boundaryInput]?: InstanceInput }\n\nexport type InstanceInputGroup<TTypes extends EntityTypes = EntityTypes> =\n InstanceInput<TTypes>[] & {\n [boundaryInputs]?: InstanceInputGroup<TTypes>\n }\n\nexport function inputKey(input: InstanceInput): string {\n return `${input.instanceId}:${input.output}`\n}\n\nexport const positionSchema = z.object({\n x: z.number(),\n y: z.number(),\n})\n\nexport type Position = z.infer<typeof positionSchema>\n\nexport const instanceIdSchema = z.templateLiteral([versionedNameSchema, \":\", genericNameSchema])\n\nexport type InstanceId = z.infer<typeof instanceIdSchema>\n\nexport const instanceInputSchema = z.object({\n instanceId: instanceIdSchema,\n output: z.string(),\n})\n\nexport const hubInputSchema = z.object({\n hubId: z.string(),\n})\n\nexport type HubInput = z.infer<typeof hubInputSchema>\n\nexport const instanceModelPatchSchema = z.object({\n /**\n * The static arguments passed to the instance.\n */\n args: z.record(z.string(), z.unknown()).optional(),\n\n /**\n * The direct instances passed as inputs to the instance.\n */\n inputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n\n /**\n * The resolved unit inputs for the instance.\n *\n * Only for computed composite instances.\n */\n hubInputs: z.record(z.string(), z.array(hubInputSchema)).optional(),\n\n /**\n * The inputs injected to the instance from the hubs.\n *\n * While `hubInputs` allows to pass hubs to distinct inputs,\n * `injectionInputs` allows to pass hubs to the instance as a whole filling all inputs with matching types.\n *\n * Only for designer-first instances.\n */\n injectionInputs: z.array(hubInputSchema).optional(),\n\n /**\n * The position of the instance on the canvas.\n *\n * Only for designer-first instances.\n */\n position: positionSchema.optional(),\n})\n\nexport const instanceModelSchema = z.object({\n /**\n * The id of the instance unique within the project.\n *\n * The format is `${instanceType}:${instanceName}`.\n */\n id: instanceIdSchema,\n\n /**\n * The kind of the instance.\n *\n * Can be either \"unit\" or \"composite\".\n */\n kind: componentKindSchema,\n\n /**\n * The type of the instance.\n */\n type: versionedNameSchema,\n\n /**\n * The name of the instance.\n *\n * Must be unique within instances of the same type in the project.\n */\n name: genericNameSchema,\n\n ...instanceModelPatchSchema.shape,\n\n /**\n * The id of the top level parent instance.\n *\n * Only for child instances of the composite instances.\n */\n resolvedInputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n\n /**\n * The ID of the parent instance.\n *\n * Only for child instances of the composite instances.\n */\n parentId: instanceIdSchema.optional(),\n\n /**\n * The direct instance outputs returned by the instance as outputs.\n *\n * Only for computed composite instances.\n */\n outputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n\n /**\n * The resolved unit outputs for the instance.\n *\n * Only for computed composite instances.\n */\n resolvedOutputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),\n})\n\nexport type InstanceModel = z.infer<typeof instanceModelSchema>\n\nexport const hubModelPatchSchema = z.object({\n /**\n * The position of the hub on the canvas.\n */\n position: positionSchema.optional(),\n\n /**\n * The inputs of the hub.\n */\n inputs: z.array(instanceInputSchema).optional(),\n\n /**\n * The inputs injected to the hub from the hubs.\n *\n * While `inputs` allows to pass hubs to distinct inputs,\n * `injectionInputs` allows to pass hubs to the hub as a whole filling all inputs with matching types.\n */\n injectionInputs: z.array(hubInputSchema).optional(),\n})\n\nexport const hubModelSchema = z.object({\n /**\n * The id of the hub unique within the project.\n */\n id: z.cuid2(),\n\n ...hubModelPatchSchema.shape,\n})\n\nexport type InstanceModelPatch = z.infer<typeof instanceModelPatchSchema>\nexport type HubModel = z.infer<typeof hubModelSchema>\nexport type HubModelPatch = z.infer<typeof hubModelPatchSchema>\n\n/**\n * Parses the instance id into the instance type and instance name.\n *\n * @param instanceId The instance id to parse.\n *\n * @returns The instance type and instance name.\n */\nexport function parseInstanceId(\n instanceId: string,\n): [instanceType: VersionedName, instanceName: GenericName] {\n const parts = instanceId.split(\":\")\n\n if (parts.length !== 2) {\n throw new Error(`Invalid instance ID: ${instanceId}`)\n }\n\n return parts as [VersionedName, GenericName]\n}\n\nexport function findInput<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n name: string,\n): InstanceInput<T> | null {\n const matchedInputs = inputs.filter(\n input => parseInstanceId(input.instanceId)[1] === name || input.instanceId === name,\n )\n\n if (matchedInputs.length === 0) {\n return null\n }\n\n if (matchedInputs.length > 1) {\n throw new Error(\n `Multiple inputs found for \"${name}\": ${matchedInputs.map(input => input.instanceId).join(\", \")}. Specify the full instance id to disambiguate.`,\n )\n }\n\n return matchedInputs[0]\n}\n\nexport function findRequiredInput<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n name: string,\n): InstanceInput<T> {\n const input = findInput(inputs, name)\n\n if (input === null) {\n throw new Error(`Required input \"${name}\" not found.`)\n }\n\n return input\n}\n\nexport function findInputs<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n names: string[],\n): InstanceInput<T>[] {\n return names.map(name => findInput(inputs, name)).filter(Boolean) as InstanceInput<T>[]\n}\n\nexport function findRequiredInputs<T extends EntityTypes>(\n inputs: InstanceInput<T>[],\n names: string[],\n): InstanceInput<T>[] {\n return names.map(name => findRequiredInput(inputs, name))\n}\n\n/**\n * The field names that indicate special objects which Highstate understands regardless of the context.\n *\n * UUIDs are used to prevent conflicts with user-defined fields.\n */\nexport enum HighstateSignature {\n Artifact = \"d55c63ac-3174-4756-808f-f778e99af0d1\",\n Yaml = \"c857cac5-caa6-4421-b82c-e561fbce6367\",\n Id = \"348d020e-0d9e-4ae7-9415-b91af99f5339\",\n Ref = \"6d7f9da0-9cb6-496d-b72e-cf85ee4d9cf8\",\n}\n\nexport const yamlValueSchema = z.object({\n [HighstateSignature.Yaml]: z.literal(true),\n value: z.string(),\n})\n\nexport const objectWithIdSchema = z.object({\n [HighstateSignature.Id]: z.literal(true),\n id: z.number(),\n value: z.unknown(),\n})\n\nexport const objectRefSchema = z.object({\n [HighstateSignature.Ref]: z.literal(true),\n id: z.number(),\n})\n\nexport type YamlValue = z.infer<typeof yamlValueSchema>\n\nexport const fileMetaSchema = z.object({\n name: z.string(),\n contentType: z.string().optional(),\n size: z.number().optional(),\n mode: z.number().optional(),\n})\n\nexport enum WellKnownInstanceCustomStatus {\n /**\n * The instance is in a healthy state.\n */\n Healthy = \"healthy\",\n\n /**\n * The instance is in a degraded state.\n */\n Degraded = \"degraded\",\n\n /**\n * The instance is in a down state/completely broken.\n */\n Down = \"down\",\n\n /**\n * The instance is in a warning state.\n */\n Warning = \"warning\",\n\n /**\n * The instance is progressing with some external sync operation,\n * such as a deployment or a data migration.\n */\n Progressing = \"progressing\",\n\n /**\n * The instance is in an error state.\n */\n Error = \"error\",\n}\n\nexport const instanceStatusFieldValueSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.string().array(),\n])\n\nexport const instanceStatusFieldSchema = z.object({\n name: z.string(),\n\n meta: objectMetaSchema\n .pick({\n title: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n\n complementaryTo: z.string().optional(),\n value: instanceStatusFieldValueSchema.optional(),\n})\n\nexport type InstanceStatusFieldValue = z.infer<typeof instanceStatusFieldValueSchema>\nexport type InstanceStatusField = z.infer<typeof instanceStatusFieldSchema>\n","/** biome-ignore-all lint/suspicious/noExplicitAny: maybe fix later */\n\nimport type { InstanceInput } from \"./instance\"\nimport type { VersionedName } from \"./meta\"\nimport { mapValues } from \"remeda\"\nimport { z } from \"zod\"\nimport {\n type Component,\n type ComponentArgumentOptions,\n type ComponentArgumentOptionsToSchema,\n type ComponentInputOptions,\n type ComponentInputOptionsToSpec,\n type ComponentInputSpec,\n type ComponentModel,\n type ComponentOptions,\n componentArgumentSchema,\n componentModelSchema,\n defineComponent,\n type FullComponentArgumentOptions,\n kind,\n mapArgument,\n type ToFullComponentArgumentOptions,\n toFullComponentArgumentOptions,\n} from \"./component\"\n\nexport const componentSecretSchema = componentArgumentSchema.extend({\n /**\n * The secret cannot be modified by the user, but can be modified by the unit.\n */\n readonly: z.boolean(),\n\n /**\n * The secret value is computed by the unit and should not be passed to it when invoked.\n */\n computed: z.boolean(),\n})\n\nexport type ComponentSecret = z.infer<typeof componentSecretSchema>\n\nexport type FullComponentSecretOptions = FullComponentArgumentOptions & {\n readonly?: boolean\n computed?: boolean\n}\n\nexport type ComponentSecretOptions = z.ZodType | FullComponentSecretOptions\n\ntype UnitOptions<\n TType extends VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions>,\n TInputs extends Record<string, ComponentInputOptions>,\n TOutputs extends Record<string, ComponentInputOptions>,\n TSecrets extends Record<string, ComponentSecretOptions>,\n> = Omit<ComponentOptions<TType, TArgs, TInputs, TOutputs>, \"create\"> & {\n source: UnitSource\n\n secrets?: TSecrets\n}\n\nexport const unitSourceSchema = z.object({\n /**\n * The package where the unit implementation is located.\n *\n * May be both: local monorepo package or a remote NPM package.\n */\n package: z.string(),\n\n /**\n * The path to the unit implementation within the package.\n *\n * If not provided, the root of the package is assumed.\n */\n path: z.string().optional(),\n})\n\nexport const unitModelSchema = z.object({\n ...componentModelSchema.shape,\n\n /**\n * The source of the unit.\n */\n source: unitSourceSchema,\n\n /**\n * The record of the secret specs.\n */\n secrets: z.record(z.string(), componentSecretSchema),\n})\n\nexport type UnitModel = z.infer<typeof unitModelSchema>\nexport type UnitSource = z.infer<typeof unitSourceSchema>\n\ndeclare const secrets: unique symbol\n\nexport type Unit<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, z.ZodType> = Record<string, never>,\n TInputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputSpec> = Record<string, never>,\n TSecrets extends Record<string, unknown> = Record<string, never>,\n> = Component<TType, TArgs, TInputs, TOutputs> & {\n /**\n * Holds the type of the unit secrets.\n *\n * Does not exist at runtime, only for type checking.\n */\n [secrets]: TSecrets\n\n /**\n * The model of the unit.\n */\n model: UnitModel\n}\n\nexport function defineUnit<\n TType extends VersionedName = VersionedName,\n TArgs extends Record<string, ComponentArgumentOptions> = Record<string, never>,\n TInputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n TOutputs extends Record<string, ComponentInputOptions> = Record<string, never>,\n TSecrets extends Record<string, ComponentSecretOptions> = Record<string, never>,\n>(\n options: UnitOptions<TType, TArgs, TInputs, TOutputs, TSecrets>,\n): Unit<\n TType,\n { [K in keyof TArgs]: ComponentArgumentOptionsToSchema<TArgs[K]> },\n { [K in keyof TInputs]: ComponentInputOptionsToSpec<TInputs[K]> },\n { [K in keyof TOutputs]: ComponentInputOptionsToSpec<TOutputs[K]> },\n { [K in keyof TSecrets]: ComponentArgumentOptionsToSchema<TSecrets[K]> }\n> {\n if (!options.source) {\n throw new Error(\"Unit source is required\")\n }\n\n const component = defineComponent<TType, TArgs, TInputs, TOutputs>({\n ...options,\n [kind]: \"unit\",\n\n create({ id }) {\n const outputs: Record<string, InstanceInput[]> = {}\n for (const key in options.outputs ?? {}) {\n outputs[key] = [\n {\n instanceId: id,\n output: key,\n },\n ]\n }\n\n return outputs as any\n },\n }) as any\n\n try {\n component.model.source = options.source ?? {}\n component.model.secrets = mapValues(options.secrets ?? {}, mapSecret)\n } catch (error) {\n throw new Error(`Failed to map secrets for unit \"${options.type}\"`, { cause: error })\n }\n\n return component\n}\n\n/**\n * The helper marker for component secrets.\n *\n * Helps validating secrets types and gives the compiler a hint for generating `meta` fields.\n */\nexport function $secrets<T extends Record<string, ComponentArgumentOptions>>(\n secrets: T,\n): ToFullComponentArgumentOptions<T> {\n return toFullComponentArgumentOptions(secrets)\n}\n\nfunction mapSecret(value: ComponentSecretOptions, key: string): ComponentSecret {\n if (\"schema\" in value) {\n return {\n ...mapArgument(value, key),\n readonly: value.readonly ?? false,\n computed: value.computed ?? false,\n }\n }\n\n return {\n ...mapArgument(value, key),\n readonly: false,\n computed: false,\n }\n}\n\n/**\n * Checks if the given model is a unit model.\n *\n * @param model The model to check.\n *\n * @returns `true` if the model is a unit model, `false` otherwise.\n */\nexport function isUnitModel(model: ComponentModel): model is UnitModel {\n return \"source\" in model\n}\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"./meta\"\n\nexport const triggerSpecSchema = z.union([\n z.object({\n type: z.literal(\"before-destroy\"),\n }),\n])\n\nexport type TriggerSpec = z.infer<typeof triggerSpecSchema>\n\n/**\n * Trigger schema for unit API.\n * This is what units provide - excludes id since it's set by the system.\n */\nexport const unitTriggerSchema = z.object({\n name: z.string(),\n meta: objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n\n /**\n * The specification of the trigger.\n *\n * Defines the type of trigger and its behavior.\n */\n spec: triggerSpecSchema,\n})\n\nexport type UnitTrigger = z.infer<typeof unitTriggerSchema>\n\nexport const triggerInvocationSchema = z.object({\n /**\n * The name of the trigger being invoked.\n */\n name: z.string(),\n})\n\nexport type TriggerInvocation = z.infer<typeof triggerInvocationSchema>\n","import { parse } from \"yaml\"\nimport { z } from \"zod\"\nimport { entityInclusionSchema } from \"./entity\"\nimport {\n fileMetaSchema,\n HighstateSignature,\n instanceIdSchema,\n instanceInputSchema,\n yamlValueSchema,\n} from \"./instance\"\nimport { commonObjectMetaSchema } from \"./meta\"\nimport { triggerInvocationSchema } from \"./trigger\"\n\nexport type UnitInputReference = z.infer<typeof unitInputReference>\n\nexport const unitInputReference = z.object({\n ...instanceInputSchema.shape,\n\n /**\n * The resolved inclusion needed to extract the input value.\n */\n inclusion: entityInclusionSchema.optional(),\n})\n\nexport const unitConfigSchema = z.object({\n /**\n * The ID of the instance.\n */\n instanceId: z.string(),\n\n /**\n * The record of argument values for the unit.\n */\n args: z.record(z.string(), z.unknown()),\n\n /**\n * The record of input references for the unit.\n */\n inputs: z.record(z.string(), unitInputReference.array()),\n\n /**\n * The list of triggers that have been invoked for this unit.\n */\n invokedTriggers: triggerInvocationSchema.array(),\n\n /**\n * The list of secret names that exists and provided to the unit.\n */\n secretNames: z.string().array(),\n\n /**\n * The map of instance ID to state ID in order to resolve instance references.\n */\n stateIdMap: z.record(instanceIdSchema, z.string()),\n\n /**\n * The base path for imports.\n * Used to resolve dynamic dependencies in strict environments (like in pnpm node_modules isolation).\n */\n importBasePath: z.string(),\n})\n\nexport type UnitConfig = z.infer<typeof unitConfigSchema>\n\nconst yamlResultCache = new WeakMap<object, unknown>()\n\n/**\n * Parses an argument value which can be wrapped in a YAML structure.\n *\n * @param value The value to parse.\n */\nexport function parseArgumentValue(value: unknown): unknown {\n const yamlResult = yamlValueSchema.safeParse(value)\n if (!yamlResult.success) {\n return value\n }\n\n const existingResult = yamlResultCache.get(value as object)\n if (existingResult !== undefined) {\n return existingResult\n }\n\n const result = parse(yamlResult.data.value) as unknown\n yamlResultCache.set(value as object, result)\n return result\n}\n\nexport enum HighstateConfigKey {\n Config = \"highstate\",\n Secrets = \"highstate.secrets\",\n}\n\nexport const unitArtifactId = Symbol(\"unitArtifactId\")\n\nexport const unitArtifactSchema = z.object({\n [HighstateSignature.Artifact]: z.literal(true),\n // only for internal use\n [unitArtifactId]: z.string().optional(),\n hash: z.string(),\n meta: commonObjectMetaSchema.optional(),\n})\n\nexport const fileContentSchema = z.union([\n z.object({\n type: z.literal(\"embedded\"),\n\n /**\n * Whether the content is binary or not.\n *\n * If true, the `value` will be a base64 encoded string.\n */\n isBinary: z.boolean().optional(),\n\n /**\n * The content of the file.\n *\n * If `isBinary` is true, this will be a base64 encoded string.\n */\n value: z.string(),\n }),\n z.object({\n type: z.literal(\"artifact\"),\n ...unitArtifactSchema.shape,\n }),\n])\n\nexport const fileSchema = z.object({\n meta: fileMetaSchema,\n content: fileContentSchema,\n})\n\nexport type FileMeta = z.infer<typeof fileMetaSchema>\nexport type FileContent = z.infer<typeof fileContentSchema>\nexport type UnitArtifact = z.infer<typeof unitArtifactSchema>\nexport type File = z.infer<typeof fileSchema>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"./meta\"\nimport { fileSchema } from \"./pulumi\"\n\n/**\n * Contains all the information needed to run a terminal,\n * including the image, command, working directory, environment variables, and files.\n */\nexport const terminalSpecSchema = z.object({\n /**\n * The Docker image to run the terminal.\n */\n image: z.string(),\n\n /**\n * The command to run in the terminal.\n */\n command: z.string().array(),\n\n /**\n * The working directory to run the command in.\n */\n cwd: z.string().optional(),\n\n /**\n * The environment variables to set in the terminal.\n */\n env: z.record(z.string(), z.string()).optional(),\n\n /**\n * The files to mount in the terminal.\n *\n * The key is the path where the file will be mounted,\n * and the value is the file content or a reference to an artifact.\n */\n files: z.record(z.string(), fileSchema).optional(),\n})\n\nexport type TerminalSpec = z.infer<typeof terminalSpecSchema>\n\n/**\n * Terminal schema for unit API.\n */\nexport const unitTerminalSchema = z.object({\n name: z.string(),\n meta: objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n spec: terminalSpecSchema,\n})\n\nexport type UnitTerminal = z.infer<typeof unitTerminalSchema>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"./meta\"\nimport { fileSchema } from \"./pulumi\"\n\n/**\n * Page block schema for database storage and unit API.\n */\nexport const pageBlockSchema = z.union([\n z.object({\n type: z.literal(\"markdown\"),\n content: z.string(),\n }),\n z.object({\n type: z.literal(\"qr\"),\n content: z.string(),\n showContent: z.coerce.boolean(),\n language: z.string().optional(),\n }),\n z.object({\n type: z.literal(\"file\"),\n file: fileSchema,\n }),\n])\n\nexport type PageBlock = z.infer<typeof pageBlockSchema>\n\n/**\n * Page schema for unit API.\n * This is what units provide - excludes id, instanceId and some fields from meta since those are set by the system.\n */\nexport const unitPageSchema = z.object({\n name: z.string(),\n meta: objectMetaSchema\n .pick({\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n })\n .required({ title: true }),\n content: pageBlockSchema.array(),\n})\n\nexport type UnitPage = z.infer<typeof unitPageSchema>\n","import { z } from \"zod\"\n\nexport const unitWorkerSchema = z.object({\n name: z.string(),\n image: z.string(),\n params: z.record(z.string(), z.unknown()),\n})\n\nexport type UnitWorker = z.infer<typeof unitWorkerSchema>\n\nexport const workerRunOptionsSchema = z.object({\n /**\n * The ID of the project for which the worker is running.\n */\n projectId: z.cuid2(),\n\n /**\n * The ID of the worker version.\n */\n workerVersionId: z.cuid2(),\n\n /**\n * The URL of the backend API to connect to.\n */\n apiUrl: z.url(),\n\n /**\n * The API key used to authenticate the worker with the backend.\n */\n apiKey: z.string(),\n})\n\nexport type WorkerRunOptions = z.infer<typeof workerRunOptionsSchema>\n","import { mapValues } from \"remeda\"\nimport { HighstateSignature, objectRefSchema, objectWithIdSchema } from \"./instance\"\n\nexport function compact<T>(value: T): unknown {\n const counts = new WeakMap<object, number>()\n const cyclic = new WeakSet<object>()\n const expanded = new WeakSet<object>()\n const inStack = new WeakSet<object>()\n const stack: object[] = []\n\n function countIdentities(current: unknown): void {\n if (current === null || typeof current !== \"object\") {\n return\n }\n\n counts.set(current, (counts.get(current) ?? 0) + 1)\n\n if (inStack.has(current)) {\n cyclic.add(current)\n\n for (const entry of stack) {\n cyclic.add(entry)\n }\n return\n }\n\n if (expanded.has(current)) {\n return\n }\n\n expanded.add(current)\n inStack.add(current)\n stack.push(current)\n\n if (Array.isArray(current)) {\n try {\n for (const item of current) {\n countIdentities(item)\n }\n return\n } finally {\n stack.pop()\n inStack.delete(current)\n }\n }\n\n try {\n for (const entryValue of Object.values(current)) {\n countIdentities(entryValue)\n }\n } finally {\n stack.pop()\n inStack.delete(current)\n }\n }\n\n countIdentities(value)\n\n type DefinitionSite = { parent: object; key: string | number }\n\n const ids = new WeakMap<object, number>()\n const definitionSites = new WeakMap<object, DefinitionSite>()\n let nextId = 1\n\n function ensureId(current: object): number {\n const existing = ids.get(current)\n if (existing !== undefined) {\n return existing\n }\n\n const allocated = nextId\n nextId += 1\n ids.set(current, allocated)\n return allocated\n }\n\n function assignDefinitionSitesBfs(root: unknown): void {\n if (root === null || typeof root !== \"object\") {\n return\n }\n\n const queue: Array<{ parent: object; key: string | number; value: unknown }> = []\n const expandedQueue = new WeakSet<object>()\n\n if (Array.isArray(root)) {\n for (let index = 0; index < root.length; index += 1) {\n queue.push({ parent: root, key: index, value: root[index] })\n }\n } else {\n for (const [key, entryValue] of Object.entries(root)) {\n queue.push({ parent: root, key, value: entryValue })\n }\n }\n\n while (queue.length > 0) {\n const current = queue.shift()\n if (current === undefined) {\n continue\n }\n\n if (current.value === null || typeof current.value !== \"object\") {\n continue\n }\n\n const occurrences = counts.get(current.value) ?? 0\n if (occurrences > 1 && definitionSites.get(current.value) === undefined) {\n definitionSites.set(current.value, { parent: current.parent, key: current.key })\n ensureId(current.value)\n }\n\n if (expandedQueue.has(current.value)) {\n continue\n }\n\n expandedQueue.add(current.value)\n\n if (Array.isArray(current.value)) {\n for (let index = 0; index < current.value.length; index += 1) {\n queue.push({ parent: current.value, key: index, value: current.value[index] })\n }\n continue\n }\n\n for (const [key, entryValue] of Object.entries(current.value)) {\n queue.push({ parent: current.value, key, value: entryValue })\n }\n }\n }\n\n assignDefinitionSitesBfs(value)\n\n const emitted = new WeakSet<object>()\n\n function buildTreeChildren(current: object, rootOfIdValue?: object): unknown {\n if (Array.isArray(current)) {\n return current.map(item => buildTree(item, rootOfIdValue))\n }\n\n return mapValues(current, entryValue => buildTree(entryValue, rootOfIdValue))\n }\n\n function buildTree(current: unknown, rootOfIdValue?: object): unknown {\n if (current === null || typeof current !== \"object\") {\n return current\n }\n\n // Inside an Id value, never emit nested Id wrappers.\n // Match existing real-world snapshot: do not introduce refs for nested objects\n // unless the nested object has already been defined earlier.\n if (rootOfIdValue !== undefined && emitted.has(current)) {\n const id = ids.get(current)\n if (id === undefined) {\n throw new Error(\"Compaction invariant violation: missing id for repeated object\")\n }\n\n return {\n [HighstateSignature.Ref]: true,\n id,\n }\n }\n\n // Cycles inside an Id value require defining the cyclic objects inline,\n // otherwise we would infinitely recurse.\n if (rootOfIdValue !== undefined && cyclic.has(current) && !emitted.has(current)) {\n const id = ensureId(current)\n emitted.add(current)\n\n return {\n [HighstateSignature.Id]: true,\n id,\n value: buildTreeChildren(current, current),\n }\n }\n\n return buildTreeChildren(current, rootOfIdValue)\n }\n\n function buildAt(parent: object, key: string | number, current: unknown): unknown {\n if (current === null || typeof current !== \"object\") {\n return current\n }\n\n const occurrences = counts.get(current) ?? 0\n if (occurrences <= 1) {\n if (Array.isArray(current)) {\n return current.map((item, index) => buildAt(current, index, item))\n }\n\n return mapValues(current, (entryValue, entryKey) => buildAt(current, entryKey, entryValue))\n }\n\n const site = definitionSites.get(current)\n const shouldDefineHere = site?.parent === parent && site.key === key\n\n const id = ids.get(current)\n if (id === undefined) {\n throw new Error(\"Compaction invariant violation: missing id for repeated object\")\n }\n\n if (!shouldDefineHere || emitted.has(current)) {\n return {\n [HighstateSignature.Ref]: true,\n id,\n }\n }\n\n emitted.add(current)\n\n return {\n [HighstateSignature.Id]: true,\n id,\n value: buildTreeChildren(current, current),\n }\n }\n\n // Prefer keeping the top-level value unwrapped for stability.\n if (value === null || typeof value !== \"object\") {\n return value\n }\n\n const topLevelOccurrences = counts.get(value) ?? 0\n if (topLevelOccurrences > 1) {\n const id = ensureId(value)\n emitted.add(value)\n\n return {\n [HighstateSignature.Id]: true,\n id,\n value: buildTreeChildren(value, value),\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) => buildAt(value, index, item))\n }\n\n return mapValues(value as Record<string, unknown>, (entryValue, entryKey) =>\n buildAt(value as Record<string, unknown>, entryKey, entryValue),\n )\n}\n\nexport function decompact<T>(value: unknown): T {\n const rawValuesById = new Map<number, unknown>()\n const placeholdersById = new Map<number, unknown>()\n\n function collect(current: unknown, visited: WeakSet<object>): void {\n const result = objectWithIdSchema.safeParse(current)\n if (result.success) {\n const { id } = result.data\n if (rawValuesById.has(id)) {\n throw new Error(`Duplicate compacted id ${id}`)\n }\n\n rawValuesById.set(id, result.data.value)\n collect(result.data.value, visited)\n return\n }\n\n if (current === null || current === undefined || typeof current !== \"object\") {\n return\n }\n\n if (visited.has(current)) {\n return\n }\n\n visited.add(current)\n\n if (Array.isArray(current)) {\n for (const item of current) {\n collect(item, visited)\n }\n return\n }\n\n for (const entryValue of Object.values(current)) {\n collect(entryValue, visited)\n }\n }\n\n function ensurePlaceholder(id: number): unknown {\n const existing = placeholdersById.get(id)\n if (existing !== undefined) {\n return existing\n }\n\n const raw = rawValuesById.get(id)\n if (raw === undefined) {\n throw new Error(`Unresolved compacted ref id ${id}`)\n }\n\n let placeholder: unknown\n if (raw !== null && typeof raw === \"object\") {\n placeholder = Array.isArray(raw) ? [] : {}\n } else {\n placeholder = raw\n }\n\n placeholdersById.set(id, placeholder)\n return placeholder\n }\n\n function resolve(current: unknown): unknown {\n const refResult = objectRefSchema.safeParse(current)\n if (refResult.success) {\n return ensurePlaceholder(refResult.data.id)\n }\n\n const withIdResult = objectWithIdSchema.safeParse(current)\n if (withIdResult.success) {\n return ensurePlaceholder(withIdResult.data.id)\n }\n\n if (current === null || current === undefined || typeof current !== \"object\") {\n return current\n }\n\n if (Array.isArray(current)) {\n return current.map(item => resolve(item))\n }\n\n return mapValues(current, entryValue => resolve(entryValue))\n }\n\n function fillPlaceholder(id: number, visitedIds: Set<number>): void {\n if (visitedIds.has(id)) {\n return\n }\n\n visitedIds.add(id)\n\n const raw = rawValuesById.get(id)\n if (raw === undefined) {\n throw new Error(`Unresolved compacted ref id ${id}`)\n }\n\n const placeholder = ensurePlaceholder(id)\n if (placeholder === null || typeof placeholder !== \"object\") {\n return\n }\n\n if (raw === null || typeof raw !== \"object\") {\n throw new Error(`Compaction invariant violation: id ${id} points to non-object value`)\n }\n\n const resolved = resolve(raw)\n\n if (Array.isArray(placeholder)) {\n if (!Array.isArray(resolved)) {\n throw new Error(`Compaction invariant violation: id ${id} array placeholder mismatch`)\n }\n\n placeholder.length = 0\n for (const item of resolved) {\n placeholder.push(item)\n }\n return\n }\n\n if (Array.isArray(resolved) || resolved === null || typeof resolved !== \"object\") {\n throw new Error(`Compaction invariant violation: id ${id} object placeholder mismatch`)\n }\n\n for (const [key, entryValue] of Object.entries(resolved)) {\n ;(placeholder as Record<string, unknown>)[key] = entryValue\n }\n }\n\n collect(value, new WeakSet<object>())\n\n for (const id of rawValuesById.keys()) {\n ensurePlaceholder(id)\n }\n\n const visitedIds = new Set<number>()\n for (const id of rawValuesById.keys()) {\n fillPlaceholder(id, visitedIds)\n }\n\n return resolve(value) as T\n}\n","import type { z } from \"zod\"\nimport { isNonNullish, pickBy } from \"remeda\"\n\ntype PickUndefinedKeys<T extends Record<string, unknown>> = T extends Record<string, never>\n ? never\n : Exclude<\n {\n [K in keyof T]: undefined extends T[K] ? K : never\n }[keyof T],\n undefined\n >\n\ntype AllOptionalKeys<T extends Record<string, unknown>> = T extends Record<string, never>\n ? never\n : Exclude<\n {\n [K in keyof T]: undefined extends T[K] ? K : never\n }[keyof T],\n undefined\n >\n\ntype HasRequired<T extends Record<string, unknown>> = T extends Record<string, never>\n ? false\n : [keyof T] extends [AllOptionalKeys<T>]\n ? false\n : true\n\ntype PickRecordsWithAnyRequired<T extends Record<string, Record<string, unknown>>> =\n T extends Record<string, never>\n ? never\n : Exclude<\n {\n [K in keyof T]: HasRequired<T[K]> extends true ? K : never\n }[keyof T],\n undefined\n >\n\nexport type OptionalEmptyRecords<T extends Record<string, Record<string, unknown>>> = {\n [K in Exclude<keyof T, PickRecordsWithAnyRequired<T>>]?: OptionalUndefinedFields<T[K]>\n} & {\n [K in PickRecordsWithAnyRequired<T>]: OptionalUndefinedFields<T[K]>\n}\n\nexport type OptionalUndefinedFields<T extends Record<string, unknown>> = {\n [K in PickUndefinedKeys<T>]?: T[K]\n} & {\n [K in Exclude<keyof T, PickUndefinedKeys<T>>]: T[K]\n}\n\n/**\n * Marks specific keys in a type as optional.\n *\n * @template T The type to modify.\n * @template K The keys to make optional.\n */\nexport type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\n\n/**\n * Marks specific keys in a type as required.\n *\n * @template T The type to modify.\n * @template K The keys to make required.\n */\nexport type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>\n\n/**\n * Formats a multiline string and trims the indentation.\n *\n * @param str The string to trim.\n * @returns The trimmed string.\n */\nexport function text(strings: TemplateStringsArray, ...values: unknown[]): string {\n // Convert all values to strings\n const stringValues = values.map(String)\n\n // Build full string with values interpolated\n let result = \"\"\n for (let i = 0; i < strings.length; i++) {\n result += strings[i]\n if (i < stringValues.length) {\n const value = stringValues[i]\n const lines = value.split(\"\\n\")\n const lastLineIndentMatch = strings[i].match(/(?:^|\\n)([ \\t]*)$/)\n const indent = lastLineIndentMatch ? lastLineIndentMatch[1] : \"\"\n\n result += lines.map((line, j) => (j === 0 ? line : indent + line)).join(\"\\n\")\n }\n }\n\n return trimIndentation(result)\n}\n\n/**\n * Removes the indentation from a multiline string.\n *\n * @param text The text to trim.\n * @returns The trimmed text.\n */\nexport function trimIndentation(text: string): string {\n const lines = text.split(\"\\n\")\n const indent = lines\n .filter(line => line.trim() !== \"\")\n .map(line => line.match(/^\\s*/)?.[0].length ?? 0)\n .reduce((min, indent) => Math.min(min, indent), Infinity)\n\n return lines\n .map(line => line.slice(indent))\n .join(\"\\n\")\n .trim()\n}\n\n/**\n * Converts bytes to a human-readable format.\n *\n * @param bytes The number of bytes.\n * @returns The human-readable string representation of the bytes.\n */\nexport function bytesToHumanReadable(bytes: number): string {\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\"]\n if (bytes === 0) return \"0 Bytes\"\n\n const i = Math.floor(Math.log(bytes) / Math.log(1024))\n return `${parseFloat((bytes / 1024 ** i).toFixed(2))} ${sizes[i]}`\n}\n\n/**\n * Checks if a value matches the given Zod schema and narrows the type accordingly.\n *\n * @param schema The Zod schema to check against.\n * @param value The value to check.\n * @returns `true` if the value matches the schema, `false` otherwise.\n */\nexport function check<TSchema extends z.ZodType>(\n schema: TSchema,\n value: unknown,\n): value is z.infer<TSchema> {\n return schema.safeParse(value).success\n}\n\n/**\n * Gets or creates a value in a map, using a factory function if the key does not exist.\n *\n * @param map The map to check.\n * @param key The key to look for.\n * @param createFn The function to create a new value if the key does not exist.\n * @returns The value associated with the key.\n */\nexport function getOrCreate<TKey, TValue>(\n map: Map<TKey, TValue>,\n key: TKey,\n createFn: (key: TKey) => TValue,\n): TValue {\n const existing = map.get(key)\n if (existing !== undefined) {\n return existing\n }\n\n const value = createFn(key)\n map.set(key, value)\n return value\n}\n\n/**\n * Strips nullish values from an object.\n *\n * @param obj The object to strip.\n * @returns A new object with all nullish values removed.\n */\nexport function stripNullish<T extends Record<string, unknown>>(obj: T) {\n return pickBy(obj, isNonNullish)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highstate/contract",
3
- "version": "0.17.0",
3
+ "version": "0.19.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
package/src/instance.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { EntityTypes } from "./entity"
1
+ import type { Entity, EntityTypes } from "./entity"
2
2
  import type { boundaryInput, boundaryInputs } from "./evaluation"
3
3
  import { z } from "zod"
4
4
  import { componentKindSchema } from "./component"
@@ -19,6 +19,13 @@ export type InstanceInput<TTypes extends EntityTypes = EntityTypes> = {
19
19
  output: string
20
20
  }
21
21
 
22
+ export type EntityInput<TEntity extends Entity> = TEntity extends Entity<
23
+ VersionedName,
24
+ infer TImplementedTypes
25
+ >
26
+ ? InstanceInput<TImplementedTypes>
27
+ : never
28
+
22
29
  export type OptionalInstanceInput<TTypes extends EntityTypes = EntityTypes> =
23
30
  | ({ provided: true } & InstanceInput<TTypes>)
24
31
  | { provided: false; [boundaryInput]?: InstanceInput }