@highstate/contract 0.9.20 → 0.9.21

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 CHANGED
@@ -201,7 +201,7 @@ function defineEntity(options) {
201
201
  ...options.meta,
202
202
  title: options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0])
203
203
  },
204
- // biome-ignore lint/style/noNonNullAssertion: will be calculated by the library loader
204
+ // will be calculated by the library loader
205
205
  definitionHash: null
206
206
  }
207
207
  };
@@ -417,7 +417,7 @@ function defineComponent(options) {
417
417
  title: options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),
418
418
  defaultNamePrefix: options.meta?.defaultNamePrefix || parseVersionedName(options.type)[0].split(".").slice(-1)[0]
419
419
  },
420
- // biome-ignore lint/style/noNonNullAssertion: will be calculated by library loader
420
+ // will be calculated by library loader
421
421
  definitionHash: null
422
422
  };
423
423
  function create(params) {
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/terminal.ts","../src/page.ts","../src/trigger.ts","../src/worker.ts","../src/utils.ts","../src/pulumi.ts"],"names":["text","z","outputs","mapValues","inputs","HighstateSignature","WellKnownInstanceCustomStatus","secrets","indent","pickBy","isNonNullish","HighstateConfigKey"],"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,SA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CAAE,MAAA,CAAO,gBAAA,EAAkBA,CAAAA,CAAE,QAAQ;AACnD,CAAC;AAID,IAAM,eAAA,uBAAsB,OAAA,EAAyB;AAO9C,SAAS,mBAAmB,KAAA,EAAyB;AAC1D,EAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,SAAA,CAAU,KAAK,CAAA;AAClD,EAAA,IAAI,CAAC,WAAW,OAAA,EAAS;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,cAAA,GAAiB,eAAA,CAAgB,GAAA,CAAI,KAAe,CAAA;AAC1D,EAAA,IAAI,mBAAmB,MAAA,EAAW;AAChC,IAAA,OAAO,cAAA;AAAA,EACT;AAEA,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA;AAC1C,EAAA,eAAA,CAAgB,GAAA,CAAI,OAAiB,MAAM,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT;AAEO,IAAK,kBAAA,qBAAAU,mBAAAA,KAAL;AACL,EAAAA,oBAAA,QAAA,CAAA,GAAS,WAAA;AACT,EAAAA,oBAAA,SAAA,CAAA,GAAU,mBAAA;AAFA,EAAA,OAAAA,mBAAAA;AAAA,CAAA,EAAA,kBAAA,IAAA,EAAA","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(/^[a-z][a-z0-9-_.]+$/)\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 < 1) {\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]+$/)\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 { 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\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 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 EntityModel = z.infer<typeof entityModelSchema>\n\nexport type Entity<\n TType extends VersionedName = VersionedName,\n TSchema extends z.ZodType = z.ZodType,\n> = {\n /**\n * The static type of the entity.\n */\n type: TType\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<TType extends VersionedName, TSchema extends z.ZodType> = {\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\nexport function defineEntity<TType extends VersionedName, TSchema extends z.ZodType>(\n options: EntityOptions<TType, TSchema>,\n): Entity<TType, TSchema> {\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 try {\n return {\n type: options.type,\n schema: options.schema,\n model: {\n type: options.type,\n schema: z.toJSONSchema(options.schema, { target: \"draft-7\" }),\n meta: {\n ...options.meta,\n title:\n options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),\n },\n // biome-ignore lint/style/noNonNullAssertion: will be calculated by the library loader\n definitionHash: null!,\n },\n }\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","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 } 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[\"type\"]>\n : T extends FullComponentInputOptions\n ? T[\"required\"] extends false\n ? T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][\"type\"]>[] | undefined\n : InstanceInput<T[\"entity\"][\"type\"]> | undefined\n : T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][\"type\"]>[]\n : InstanceInput<T[\"entity\"][\"type\"]>\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 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: VersionedName\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][\"type\"]>[]\n : InstanceInput<T[0][\"type\"]>\n : T[2] extends true\n ? InstanceInput<T[0][\"type\"]>[] | undefined\n : InstanceInput<T[0][\"type\"]> | undefined\n\ntype InputSpecToOutputRef<T extends ComponentInputSpec> = T[2] extends true\n ? InstanceInput<T[0][\"type\"]>[]\n : InstanceInput<T[0][\"type\"]>\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 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 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 * The create function of the component.\n *\n * Used to create instances of the component.\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 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<TArgs, TInputs, TOutputs>,\n): Component<\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 // biome-ignore lint/style/noNonNullAssertion: 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 // biome-ignore lint/style/noNonNullAssertion: the schema is always defined at runtime\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, { target: \"draft-7\", io: \"input\" }),\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\" }),\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 { boundaryInput, boundaryInputs } from \"./evaluation\"\nimport { z } from \"zod\"\nimport { componentKindSchema } from \"./component\"\nimport {\n commonObjectMetaSchema,\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<TType extends string = string> = {\n [type]?: TType\n [boundaryInput]?: InstanceInput\n instanceId: InstanceId\n output: string\n}\n\nexport type OptionalInstanceInput<TType extends string = string> =\n | ({ provided: true } & InstanceInput<TType>)\n | { provided: false; [boundaryInput]?: InstanceInput }\n\nexport type InstanceInputGroup<TType extends string = string> = InstanceInput<TType>[] & {\n [boundaryInputs]?: InstanceInputGroup<TType>\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 string>(\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 string>(\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 string>(\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 string>(\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}\n\nexport const yamlValueSchema = z.object({\n [HighstateSignature.Yaml]: z.literal(true),\n value: z.string(),\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 const unitArtifactSchema = z.object({\n [HighstateSignature.Artifact]: z.literal(true),\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\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 { 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 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<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\nconst secrets = Symbol(\"secrets\")\n\nexport type Unit<\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<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 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<TArgs, TInputs, TOutputs, TSecrets>,\n): Unit<\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<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 { fileSchema } from \"./instance\"\nimport { objectMetaSchema } from \"./meta\"\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 { fileSchema } from \"./instance\"\nimport { objectMetaSchema } from \"./meta\"\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\"\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 { 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","// TODO: refactor this shit\n\nimport 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.input<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","import { parse } from \"yaml\"\nimport { z } from \"zod\"\nimport { instanceIdSchema, instanceInputSchema, yamlValueSchema } from \"./instance\"\nimport { triggerInvocationSchema } from \"./trigger\"\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(), instanceInputSchema.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\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"]}
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/terminal.ts","../src/page.ts","../src/trigger.ts","../src/worker.ts","../src/utils.ts","../src/pulumi.ts"],"names":["text","z","outputs","mapValues","inputs","HighstateSignature","WellKnownInstanceCustomStatus","secrets","indent","pickBy","isNonNullish","HighstateConfigKey"],"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,KAA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,GAAiB,eAAA,CAAgB,GAAA,CAAI,KAAe,CAAA;AAC1D,EAAA,IAAI,mBAAmB,MAAA,EAAW;AAChC,IAAA,OAAO,cAAA;AAAA,EACT;AAEA,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA;AAC1C,EAAA,eAAA,CAAgB,GAAA,CAAI,OAAiB,MAAM,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT;AAEO,IAAK,kBAAA,qBAAAU,mBAAAA,KAAL;AACL,EAAAA,oBAAA,QAAA,CAAA,GAAS,WAAA;AACT,EAAAA,oBAAA,SAAA,CAAA,GAAU,mBAAA;AAFA,EAAA,OAAAA,mBAAAA;AAAA,CAAA,EAAA,kBAAA,IAAA,EAAA","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(/^[a-z][a-z0-9-_.]+$/)\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 < 1) {\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]+$/)\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 { 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\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 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 EntityModel = z.infer<typeof entityModelSchema>\n\nexport type Entity<\n TType extends VersionedName = VersionedName,\n TSchema extends z.ZodType = z.ZodType,\n> = {\n /**\n * The static type of the entity.\n */\n type: TType\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<TType extends VersionedName, TSchema extends z.ZodType> = {\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\nexport function defineEntity<TType extends VersionedName, TSchema extends z.ZodType>(\n options: EntityOptions<TType, TSchema>,\n): Entity<TType, TSchema> {\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 try {\n return {\n type: options.type,\n schema: options.schema,\n model: {\n type: options.type,\n schema: z.toJSONSchema(options.schema, { target: \"draft-7\" }),\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 }\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","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 } 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[\"type\"]>\n : T extends FullComponentInputOptions\n ? T[\"required\"] extends false\n ? T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][\"type\"]>[] | undefined\n : InstanceInput<T[\"entity\"][\"type\"]> | undefined\n : T[\"multiple\"] extends true\n ? InstanceInput<T[\"entity\"][\"type\"]>[]\n : InstanceInput<T[\"entity\"][\"type\"]>\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 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: VersionedName\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][\"type\"]>[]\n : InstanceInput<T[0][\"type\"]>\n : T[2] extends true\n ? InstanceInput<T[0][\"type\"]>[] | undefined\n : InstanceInput<T[0][\"type\"]> | undefined\n\ntype InputSpecToOutputRef<T extends ComponentInputSpec> = T[2] extends true\n ? InstanceInput<T[0][\"type\"]>[]\n : InstanceInput<T[0][\"type\"]>\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 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 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 * The create function of the component.\n *\n * Used to create instances of the component.\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 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<TArgs, TInputs, TOutputs>,\n): Component<\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, { target: \"draft-7\", io: \"input\" }),\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\" }),\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 { boundaryInput, boundaryInputs } from \"./evaluation\"\nimport { z } from \"zod\"\nimport { componentKindSchema } from \"./component\"\nimport {\n commonObjectMetaSchema,\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<TType extends string = string> = {\n [type]?: TType\n [boundaryInput]?: InstanceInput\n instanceId: InstanceId\n output: string\n}\n\nexport type OptionalInstanceInput<TType extends string = string> =\n | ({ provided: true } & InstanceInput<TType>)\n | { provided: false; [boundaryInput]?: InstanceInput }\n\nexport type InstanceInputGroup<TType extends string = string> = InstanceInput<TType>[] & {\n [boundaryInputs]?: InstanceInputGroup<TType>\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 string>(\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 string>(\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 string>(\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 string>(\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}\n\nexport const yamlValueSchema = z.object({\n [HighstateSignature.Yaml]: z.literal(true),\n value: z.string(),\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 const unitArtifactSchema = z.object({\n [HighstateSignature.Artifact]: z.literal(true),\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\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 { 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 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<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\nconst secrets = Symbol(\"secrets\")\n\nexport type Unit<\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<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 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<TArgs, TInputs, TOutputs, TSecrets>,\n): Unit<\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<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 { fileSchema } from \"./instance\"\nimport { objectMetaSchema } from \"./meta\"\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 { fileSchema } from \"./instance\"\nimport { objectMetaSchema } from \"./meta\"\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\"\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 { 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","// TODO: refactor this shit\n\nimport 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.input<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","import { parse } from \"yaml\"\nimport { z } from \"zod\"\nimport { instanceIdSchema, instanceInputSchema, yamlValueSchema } from \"./instance\"\nimport { triggerInvocationSchema } from \"./trigger\"\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(), instanceInputSchema.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\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highstate/contract",
3
- "version": "0.9.20",
3
+ "version": "0.9.21",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -25,7 +25,10 @@
25
25
  },
26
26
  "scripts": {
27
27
  "build": "highstate build",
28
- "test": "vitest run"
28
+ "test": "vitest run",
29
+ "typecheck": "tsgo --noEmit --skipLibCheck",
30
+ "biome": "biome check --write --unsafe --error-on-warnings",
31
+ "biome:check": "biome check --error-on-warnings"
29
32
  },
30
33
  "dependencies": {
31
34
  "@paralleldrive/cuid2": "^2.2.2",
@@ -35,9 +38,11 @@
35
38
  "zod": "^4.0.5"
36
39
  },
37
40
  "devDependencies": {
41
+ "@biomejs/biome": "2.2.0",
42
+ "@typescript/native-preview": "^7.0.0-dev.20250920.1",
38
43
  "@vitest/coverage-v8": "2.1.8",
39
44
  "highstate-cli-bootstrap": "patch:@highstate/cli@npm%3A0.9.16#~/.yarn/patches/@highstate-cli-npm-0.9.16-e03b564691.patch",
40
45
  "vitest": "^3.2.4"
41
46
  },
42
- "gitHead": "4bf9183450c2c6f51d6a99d77efc379ff5c7b7ef"
47
+ "gitHead": "390ff15c0e0076822a682f9d4e19260942a8d6c2"
43
48
  }
package/src/component.ts CHANGED
@@ -384,7 +384,7 @@ export function defineComponent<
384
384
  options.meta?.defaultNamePrefix ||
385
385
  parseVersionedName(options.type)[0].split(".").slice(-1)[0],
386
386
  },
387
- // biome-ignore lint/style/noNonNullAssertion: will be calculated by library loader
387
+ // will be calculated by library loader
388
388
  definitionHash: null!,
389
389
  }
390
390
 
@@ -505,7 +505,6 @@ function processArgs(
505
505
 
506
506
  for (const [key, arg] of Object.entries(model.args)) {
507
507
  if (arg.schema) {
508
- // biome-ignore lint/style/noNonNullAssertion: the schema is always defined at runtime
509
508
  const result = arg[runtimeSchema]!.safeParse(args[key])
510
509
 
511
510
  if (!result.success) {
package/src/entity.ts CHANGED
@@ -105,7 +105,7 @@ export function defineEntity<TType extends VersionedName, TSchema extends z.ZodT
105
105
  title:
106
106
  options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),
107
107
  },
108
- // biome-ignore lint/style/noNonNullAssertion: will be calculated by the library loader
108
+ // will be calculated by the library loader
109
109
  definitionHash: null!,
110
110
  },
111
111
  }
package/src/meta.spec.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { describe, it, expect } from "vitest"
1
+ import { describe, expect, it } from "vitest"
2
2
  import { parseVersionedName } from "./meta"
3
3
 
4
4
  describe("parseVersionedName", () => {