@highstate/contract 0.20.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
- import { z } from 'zod';
2
- export { z } from 'zod';
3
- import { sha256 } from '@noble/hashes/sha2.js';
4
- import { mapValues, pickBy, isNonNullish, uniqueBy } from 'remeda';
5
- import { parse } from 'yaml';
6
-
1
+ // @bun
7
2
  // src/entity.ts
3
+ import { z as z2 } from "zod";
4
+
5
+ // src/cuidv2d.ts
6
+ import { sha256 } from "@noble/hashes/sha2.js";
8
7
  var cuidv2DefaultLength = 24;
9
8
  function bufToBigInt(buf) {
10
9
  const bits = 8n;
@@ -24,8 +23,8 @@ function normalizeCuid2Prefix(prefix) {
24
23
  return prefix;
25
24
  }
26
25
  if (prefix >= "0" && prefix <= "9") {
27
- const digit = prefix.charCodeAt(0) - "0".charCodeAt(0);
28
- return String.fromCharCode("a".charCodeAt(0) + digit);
26
+ const digit = prefix.charCodeAt(0) - 48;
27
+ return String.fromCharCode(97 + digit);
29
28
  }
30
29
  throw new Error(`Invalid CUID prefix character: ${prefix}`);
31
30
  }
@@ -38,7 +37,7 @@ function cuidv2d(namespace, identity) {
38
37
  }
39
38
 
40
39
  // src/i18n.ts
41
- var knownAbbreviationsMap = /* @__PURE__ */ new Map();
40
+ var knownAbbreviationsMap = new Map;
42
41
  function registerKnownAbbreviations(abbreviations) {
43
42
  for (const abbr of abbreviations) {
44
43
  const lower = abbr.toLowerCase();
@@ -50,8 +49,8 @@ function registerKnownAbbreviations(abbreviations) {
50
49
  function clearKnownAbbreviations() {
51
50
  knownAbbreviationsMap.clear();
52
51
  }
53
- function camelCaseToHumanReadable(text2) {
54
- const words = text2.split(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|_|-|\./).filter((word) => word.length > 0);
52
+ function camelCaseToHumanReadable(text) {
53
+ const words = text.split(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|_|-|\./).filter((word) => word.length > 0);
55
54
  return words.map((word) => {
56
55
  const lower = word.toLowerCase();
57
56
  if (knownAbbreviationsMap.has(lower)) {
@@ -81,7 +80,7 @@ function fixJsonSchema(schema) {
81
80
  otherSchemas.push(item);
82
81
  }
83
82
  if (objectSchemas.length > 1) {
84
- const required = /* @__PURE__ */ new Set();
83
+ const required = new Set;
85
84
  const properties = {};
86
85
  let additionalProperties;
87
86
  for (const objectSchema of objectSchemas) {
@@ -97,7 +96,7 @@ function fixJsonSchema(schema) {
97
96
  if (isRecord(objectProperties)) {
98
97
  for (const [key, value] of Object.entries(objectProperties)) {
99
98
  const existing = properties[key];
100
- if (existing === void 0) {
99
+ if (existing === undefined) {
101
100
  properties[key] = value;
102
101
  continue;
103
102
  }
@@ -105,7 +104,7 @@ function fixJsonSchema(schema) {
105
104
  }
106
105
  }
107
106
  if ("additionalProperties" in objectSchema) {
108
- if (additionalProperties === void 0) {
107
+ if (additionalProperties === undefined) {
109
108
  additionalProperties = objectSchema.additionalProperties;
110
109
  } else if (additionalProperties !== objectSchema.additionalProperties) {
111
110
  additionalProperties = false;
@@ -116,7 +115,7 @@ function fixJsonSchema(schema) {
116
115
  type: "object",
117
116
  properties,
118
117
  ...required.size > 0 ? { required: Array.from(required) } : {},
119
- ...additionalProperties !== void 0 ? { additionalProperties } : { additionalProperties: false }
118
+ ...additionalProperties !== undefined ? { additionalProperties } : { additionalProperties: false }
120
119
  };
121
120
  const merged = otherSchemas.length === 0 ? mergedObjectSchema : {
122
121
  ...schema,
@@ -136,9 +135,7 @@ function fixJsonSchema(schema) {
136
135
  next.oneOf = next.oneOf.map(fixJsonSchema);
137
136
  }
138
137
  if (isRecord(next.properties)) {
139
- next.properties = Object.fromEntries(
140
- Object.entries(next.properties).map(([key, value]) => [key, fixJsonSchema(value)])
141
- );
138
+ next.properties = Object.fromEntries(Object.entries(next.properties).map(([key, value]) => [key, fixJsonSchema(value)]));
142
139
  }
143
140
  if (isRecord(next.items)) {
144
141
  next.items = fixJsonSchema(next.items);
@@ -150,58 +147,18 @@ function fixJsonSchema(schema) {
150
147
  }
151
148
  return next;
152
149
  }
150
+
151
+ // src/meta.ts
152
+ import { z } from "zod";
153
153
  var objectMetaSchema = z.object({
154
- /**
155
- * Human-readable name of the object.
156
- *
157
- * Used in UI components for better user experience.
158
- */
159
154
  title: z.string().optional(),
160
- /**
161
- * The title used globally for the object.
162
- *
163
- * For example, the title of an instance secret is "Password" which is okay
164
- * to display in the instance secret list, but when the secret is displayed in a
165
- * global secret list the name should be more descriptive, like "Proxmox Password".
166
- */
167
155
  globalTitle: z.string().optional(),
168
- /**
169
- * Description of the object.
170
- *
171
- * Provides additional context for users and developers.
172
- */
173
156
  description: z.string().optional(),
174
- /**
175
- * The color of the object.
176
- *
177
- * Used in UI components to visually distinguish objects.
178
- */
179
157
  color: z.string().optional(),
180
- /**
181
- * Primary icon identifier.
182
- *
183
- * Should reference a iconify icon name, like "mdi:server" or "gg:remote".
184
- */
185
158
  icon: z.string().optional(),
186
- /**
187
- * The color of the primary icon.
188
- */
189
159
  iconColor: z.string().optional(),
190
- /**
191
- * The URL of the custom image that should be used as the icon or avatar.
192
- */
193
160
  avatarUrl: z.string().optional(),
194
- /**
195
- * The secondary icon identifier.
196
- *
197
- * Used to provide additional context or actions related to the object.
198
- *
199
- * Should reference a iconify icon name, like "mdi:edit" or "mdi:delete".
200
- */
201
161
  secondaryIcon: z.string().optional(),
202
- /**
203
- * The color of the secondary icon.
204
- */
205
162
  secondaryIconColor: z.string().optional()
206
163
  });
207
164
  var commonObjectMetaSchema = objectMetaSchema.pick({
@@ -229,24 +186,12 @@ var serviceAccountMetaSchema = objectMetaSchema.pick({
229
186
  iconColor: true
230
187
  }).required({ title: true });
231
188
  var timestampsSchema = z.object({
232
- /**
233
- * The timestamp when the object was created.
234
- */
235
189
  createdAt: z.date(),
236
- /**
237
- * The timestamp when the object was last updated.
238
- */
239
190
  updatedAt: z.date()
240
191
  });
241
- var genericNameSchema = z.string().regex(
242
- /^[a-z][a-z0-9-.]+$/,
243
- "Name must start with a letter and can only contain lowercase letters, numbers, dashes (-) and dots (.)"
244
- ).min(2).max(64);
192
+ var genericNameSchema = z.string().regex(/^[a-z][a-z0-9-.]+$/, "Name must start with a letter and can only contain lowercase letters, numbers, dashes (-) and dots (.)").min(2).max(64);
245
193
  var versionedNameSchema = z.union([
246
194
  z.templateLiteral([genericNameSchema, z.literal("."), z.literal("v"), z.number().int().min(1)]),
247
- // to prevent TypeScript matching "proxmox.virtual-machine.v2" as
248
- // 1. "proxmox.v"
249
- // 2. "irtual-machine.v2" and thinking it should be a number
250
195
  z.templateLiteral([
251
196
  genericNameSchema,
252
197
  z.literal("."),
@@ -282,53 +227,19 @@ function parseVersionedName(name) {
282
227
  var fieldNameSchema = z.string().regex(/^[a-z][a-zA-Z0-9]+$/, "Field name must start with a letter and be in camelCase format").min(2).max(64);
283
228
 
284
229
  // src/entity.ts
285
- var entityInclusionSchema = z.object({
286
- /**
287
- * The static type of the included entity.
288
- */
230
+ var entityInclusionSchema = z2.object({
289
231
  type: versionedNameSchema,
290
- /**
291
- * Whether the included entity is required.
292
- * If false, the entity may be omitted.
293
- */
294
- required: z.boolean(),
295
- /**
296
- * Whether the included entity is multiple.
297
- */
298
- multiple: z.boolean(),
299
- /**
300
- * The name of the field where the included entity is embedded.
301
- */
302
- field: z.string()
232
+ required: z2.boolean(),
233
+ multiple: z2.boolean(),
234
+ field: z2.string()
303
235
  });
304
- var entityModelSchema = z.object({
305
- /**
306
- * The static type of the entity.
307
- */
236
+ var entityModelSchema = z2.object({
308
237
  type: versionedNameSchema,
309
- /**
310
- * The list of all extended entity types (direct and indirect).
311
- */
312
- extensions: z.string().array().optional(),
313
- /**
314
- * The list of directly extended entity types.
315
- */
316
- directExtensions: z.string().array().optional(),
317
- /**
318
- * The list of all included entities (directly or inherited from extensions).
319
- */
238
+ extensions: z2.string().array().optional(),
239
+ directExtensions: z2.string().array().optional(),
320
240
  inclusions: entityInclusionSchema.array().optional(),
321
- /**
322
- * The list of directly included entities.
323
- */
324
241
  directInclusions: entityInclusionSchema.array().optional(),
325
- /**
326
- * The JSON schema of the entity value.
327
- */
328
- schema: z.custom(),
329
- /**
330
- * The extra metadata of the entity.
331
- */
242
+ schema: z2.custom(),
332
243
  meta: objectMetaSchema.required({ title: true }).pick({
333
244
  title: true,
334
245
  description: true,
@@ -336,10 +247,7 @@ var entityModelSchema = z.object({
336
247
  icon: true,
337
248
  iconColor: true
338
249
  }),
339
- /**
340
- * The CRC32 of the entity definition.
341
- */
342
- definitionHash: z.number()
250
+ definitionHash: z2.number()
343
251
  });
344
252
  function isEntityIncludeRef(value) {
345
253
  if (typeof value !== "object" || value === null || !("entity" in value)) {
@@ -357,46 +265,38 @@ function defineEntity(options) {
357
265
  if (!options.schema) {
358
266
  throw new Error("Entity schema is required");
359
267
  }
360
- const includeRefs = Object.entries(options.includes ?? {}).map(
361
- ([field, entityRef]) => {
362
- if (isEntityIncludeRef(entityRef)) {
363
- const required = entityRef.required ?? true;
364
- const multiple = entityRef.multiple ?? false;
365
- let getEntity2;
366
- if (typeof entityRef.entity === "function") {
367
- const entity = entityRef.entity;
368
- getEntity2 = entity;
369
- } else {
370
- const entity = entityRef.entity;
371
- getEntity2 = () => entity;
372
- }
373
- return { field, required, multiple, getEntity: getEntity2 };
374
- }
375
- const getEntity = () => entityRef;
376
- return { field, required: true, multiple: false, getEntity };
377
- }
378
- );
379
- const inclusionShape = includeRefs.reduce(
380
- (shape, includeRef) => {
381
- let schema = z.lazy(() => includeRef.getEntity().schema);
382
- if (includeRef.multiple) {
383
- schema = includeRef.required ? schema.array().min(1) : schema.array().default([]);
268
+ const includeRefs = Object.entries(options.includes ?? {}).map(([field, entityRef]) => {
269
+ if (isEntityIncludeRef(entityRef)) {
270
+ const required = entityRef.required ?? true;
271
+ const multiple = entityRef.multiple ?? false;
272
+ let getEntity2;
273
+ if (typeof entityRef.entity === "function") {
274
+ const entity = entityRef.entity;
275
+ getEntity2 = entity;
384
276
  } else {
385
- schema = includeRef.required ? schema : schema.optional();
277
+ const entity = entityRef.entity;
278
+ getEntity2 = () => entity;
386
279
  }
387
- shape[includeRef.field] = schema;
388
- return shape;
389
- },
390
- {}
391
- );
392
- let finalSchema = Object.values(options.extends ?? {}).reduce(
393
- (schema, entity) => z.intersection(schema, entity.schema),
394
- options.schema
395
- );
280
+ return { field, required, multiple, getEntity: getEntity2 };
281
+ }
282
+ const getEntity = () => entityRef;
283
+ return { field, required: true, multiple: false, getEntity };
284
+ });
285
+ const inclusionShape = includeRefs.reduce((shape, includeRef) => {
286
+ let schema = z2.lazy(() => includeRef.getEntity().schema);
287
+ if (includeRef.multiple) {
288
+ schema = includeRef.required ? schema.array().min(1) : schema.array().default([]);
289
+ } else {
290
+ schema = includeRef.required ? schema : schema.optional();
291
+ }
292
+ shape[includeRef.field] = schema;
293
+ return shape;
294
+ }, {});
295
+ let finalSchema = Object.values(options.extends ?? {}).reduce((schema, entity) => z2.intersection(schema, entity.schema), options.schema);
396
296
  if (includeRefs.length > 0) {
397
- finalSchema = z.intersection(finalSchema, z.object(inclusionShape));
297
+ finalSchema = z2.intersection(finalSchema, z2.object(inclusionShape));
398
298
  }
399
- finalSchema = z.intersection(finalSchema, entityWithMetaSchema);
299
+ finalSchema = z2.intersection(finalSchema, entityWithMetaSchema);
400
300
  const directInclusions = () => includeRefs.map((includeRef) => ({
401
301
  type: includeRef.getEntity().type,
402
302
  required: includeRef.required,
@@ -424,19 +324,19 @@ function defineEntity(options) {
424
324
  schema: finalSchema,
425
325
  model: {
426
326
  type: options.type,
427
- extensions: extensions.length > 0 ? extensions : void 0,
428
- directExtensions: directExtensions.length > 0 ? directExtensions : void 0,
327
+ extensions: extensions.length > 0 ? extensions : undefined,
328
+ directExtensions: directExtensions.length > 0 ? directExtensions : undefined,
429
329
  get inclusions() {
430
330
  const incs = getInclusions();
431
- return incs.length > 0 ? incs : void 0;
331
+ return incs.length > 0 ? incs : undefined;
432
332
  },
433
333
  get directInclusions() {
434
334
  const incs = directInclusions();
435
- return incs.length > 0 ? incs : void 0;
335
+ return incs.length > 0 ? incs : undefined;
436
336
  },
437
337
  get schema() {
438
338
  if (!_schema) {
439
- const rawSchema = z.toJSONSchema(finalSchema, {
339
+ const rawSchema = z2.toJSONSchema(finalSchema, {
440
340
  target: "draft-7",
441
341
  unrepresentable: "any"
442
342
  });
@@ -448,10 +348,8 @@ function defineEntity(options) {
448
348
  ...options.meta,
449
349
  title: options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0])
450
350
  },
451
- // will be calculated by the library loader
452
351
  definitionHash: null
453
352
  }
454
- // biome-ignore lint/suspicious/noExplicitAny: we already typed return type
455
353
  };
456
354
  } catch (error) {
457
355
  throw new Error(`Failed to define entity "${options.type}"`, { cause: error });
@@ -469,22 +367,10 @@ function isAssignableTo(entity, target) {
469
367
  }
470
368
  return entity.inclusions?.some((implementation) => implementation.type === target) ?? false;
471
369
  }
472
- var entityMetaSchema = z.object({
473
- /**
474
- * The type of the entity.
475
- */
370
+ var entityMetaSchema = z2.object({
476
371
  type: versionedNameSchema,
477
- /**
478
- * The globally unique identity of the entity.
479
- *
480
- * Anonymous entities are forbidden.
481
- */
482
- identity: z.string(),
483
- /**
484
- * The IDs of the entities to reference by this entity.
485
- * Must already exist in the system (or be at least defined by this unit).
486
- */
487
- references: z.record(z.string(), z.string().array()).optional(),
372
+ identity: z2.string(),
373
+ references: z2.record(z2.string(), z2.string().array()).optional(),
488
374
  ...objectMetaSchema.pick({
489
375
  title: true,
490
376
  description: true,
@@ -492,10 +378,10 @@ var entityMetaSchema = z.object({
492
378
  iconColor: true
493
379
  }).shape
494
380
  });
495
- var entityWithMetaSchema = z.object({
381
+ var entityWithMetaSchema = z2.object({
496
382
  $meta: entityMetaSchema
497
383
  });
498
- var entityIdCache = /* @__PURE__ */ new WeakMap();
384
+ var entityIdCache = new WeakMap;
499
385
  var entityIdNamespace = "3cd37048-7c50-43a9-a2b9-ff7ff2b5ee79";
500
386
  function getEntityId(entity) {
501
387
  if (!entity.$meta) {
@@ -510,103 +396,17 @@ function getEntityId(entity) {
510
396
  entityIdCache.set(entity, id);
511
397
  return id;
512
398
  }
513
- var boundaryInput = /* @__PURE__ */ Symbol("boundaryInput");
514
- function isStableInstanceInput(value) {
515
- return typeof value === "object" && value !== null && "instanceId" in value && "output" in value && typeof value.instanceId === "string" && typeof value.output === "string";
516
- }
517
- function formatInstancePath(instance) {
518
- let result = instance.id;
519
- while (instance.parentId) {
520
- const parent = runtimeInstances.get(instance.parentId)?.instance;
521
- if (!parent) {
522
- break;
523
- }
524
- result = `${parent.id} -> ${result}`;
525
- instance = parent;
526
- }
527
- return result;
528
- }
529
- var InstanceNameConflictError = class extends Error {
530
- constructor(instanceId, firstPath, secondPath) {
531
- super(
532
- `Multiple instances produced with the same instance ID "${instanceId}":
533
- 1. ${firstPath}
534
- 2. ${secondPath}`
535
- );
536
- this.instanceId = instanceId;
537
- this.firstPath = firstPath;
538
- this.secondPath = secondPath;
539
- this.name = "InstanceNameConflictError";
540
- }
541
- };
542
- var currentInstance = null;
543
- var runtimeInstances = /* @__PURE__ */ new Map();
544
- function resetEvaluation() {
545
- runtimeInstances.clear();
546
- currentInstance = null;
547
- }
548
- function getRuntimeInstances() {
549
- return Array.from(runtimeInstances.values());
550
- }
551
- function registerInstance(component, instance, fn) {
552
- const conflicting = runtimeInstances.get(instance.id);
553
- if (conflicting) {
554
- throw new InstanceNameConflictError(
555
- instance.id,
556
- formatInstancePath(conflicting.instance),
557
- formatInstancePath(instance)
558
- );
559
- }
560
- runtimeInstances.set(instance.id, { instance, component });
561
- let previousParentInstance = null;
562
- if (currentInstance) {
563
- instance.parentId = currentInstance.id;
564
- }
565
- if (component.model.kind === "composite") {
566
- previousParentInstance = currentInstance;
567
- currentInstance = instance;
568
- }
569
- try {
570
- const rawOutputs = fn();
571
- const outputs = mapValues(rawOutputs ?? {}, (outputGroup) => {
572
- return [outputGroup].flat(2).filter(Boolean);
573
- });
574
- const toStableInputs = (outputGroup, useBoundaryFallback) => {
575
- return outputGroup.map((output) => useBoundaryFallback ? output[boundaryInput] : output).filter(isStableInstanceInput).map((output) => {
576
- return output.path ? {
577
- instanceId: output.instanceId,
578
- output: output.output,
579
- path: output.path
580
- } : {
581
- instanceId: output.instanceId,
582
- output: output.output
583
- };
584
- });
585
- };
586
- instance.resolvedOutputs = mapValues(
587
- outputs ?? {},
588
- (outputGroup) => toStableInputs(outputGroup, false)
589
- );
590
- instance.outputs = mapValues(outputs ?? {}, (outputGroup) => toStableInputs(outputGroup, true));
591
- return mapValues(rawOutputs, (rawOutputGroup, outputKey) => {
592
- const outputRefs = (outputs[outputKey] ?? []).map((output) => {
593
- if (output.provided) {
594
- output[boundaryInput] = { instanceId: instance.id, output: outputKey };
595
- }
596
- return output;
597
- });
598
- if (component.model.outputs[outputKey]?.multiple) {
599
- const multipleOutput = Array.isArray(rawOutputGroup) ? rawOutputGroup : outputRefs;
600
- multipleOutput[boundaryInput] ??= { instanceId: instance.id, output: outputKey };
601
- return multipleOutput;
602
- }
603
- return rawOutputGroup ?? outputRefs[0];
604
- });
605
- } finally {
606
- if (previousParentInstance) {
607
- currentInstance = previousParentInstance;
608
- }
609
- }
399
+ // src/instance.ts
400
+ import { z as z4 } from "zod";
401
+
402
+ // src/shared.ts
403
+ import { z as z3 } from "zod";
404
+ var componentKindSchema = z3.enum(["composite", "unit"]);
405
+ var runtimeSchema = Symbol("runtimeSchema");
406
+ var kind = Symbol("kind");
407
+ var boundaryInput = Symbol("boundaryInput");
408
+ function inputKey(input) {
409
+ return input.path ? `${input.instanceId}:${input.output}:${input.path}` : `${input.instanceId}:${input.output}`;
610
410
  }
611
411
 
612
412
  // src/instance-input.ts
@@ -614,7 +414,7 @@ function appendInputPath(currentPath, segment) {
614
414
  return currentPath ? `${currentPath}.${segment}` : segment;
615
415
  }
616
416
  function createRuntimeInputAccessor(input, boundary) {
617
- const accessorCache = input.provided ? void 0 : /* @__PURE__ */ new Map();
417
+ const accessorCache = input.provided ? undefined : new Map;
618
418
  let currentBoundary = boundary;
619
419
  return new Proxy(input, {
620
420
  get(target, property, receiver) {
@@ -700,7 +500,7 @@ function createMultipleInputAccessor(inputs, boundary) {
700
500
  return [];
701
501
  }
702
502
  const selected = input[property];
703
- if (selected === void 0 || selected === null) {
503
+ if (selected === undefined || selected === null) {
704
504
  return [];
705
505
  }
706
506
  if (Array.isArray(selected)) {
@@ -717,7 +517,7 @@ function createDeepOutputAccessor(output) {
717
517
  if (!normalizedOutput.provided) {
718
518
  return normalizedOutput;
719
519
  }
720
- const accessorCache = /* @__PURE__ */ new Map();
520
+ const accessorCache = new Map;
721
521
  return new Proxy(normalizedOutput, {
722
522
  get(target, property, receiver) {
723
523
  if (typeof property !== "string") {
@@ -730,17 +530,14 @@ function createDeepOutputAccessor(output) {
730
530
  return Reflect.get(target, property, receiver);
731
531
  }
732
532
  const cached = accessorCache.get(property);
733
- if (cached !== void 0) {
533
+ if (cached !== undefined) {
734
534
  return cached;
735
535
  }
736
536
  const providedTarget = target;
737
- const nextInput = createInput(
738
- {
739
- ...providedTarget,
740
- path: appendInputPath(providedTarget.path, property)
741
- },
742
- { boundary: providedTarget[boundaryInput] }
743
- );
537
+ const nextInput = createInput({
538
+ ...providedTarget,
539
+ path: appendInputPath(providedTarget.path, property)
540
+ }, { boundary: providedTarget[boundaryInput] });
744
541
  const resolved = createDeepOutputAccessor(nextInput);
745
542
  accessorCache.set(property, resolved);
746
543
  return resolved;
@@ -748,31 +545,236 @@ function createDeepOutputAccessor(output) {
748
545
  });
749
546
  }
750
547
 
548
+ // src/instance.ts
549
+ var positionSchema = z4.object({
550
+ x: z4.number(),
551
+ y: z4.number()
552
+ });
553
+ var instanceIdSchema = z4.templateLiteral([versionedNameSchema, ":", genericNameSchema]);
554
+ var instanceInputSchema = z4.object({
555
+ instanceId: instanceIdSchema,
556
+ output: z4.string(),
557
+ path: z4.string().optional()
558
+ });
559
+ var hubInputSchema = z4.object({
560
+ hubId: z4.string()
561
+ });
562
+ var instanceModelPatchSchema = z4.object({
563
+ args: z4.record(z4.string(), z4.unknown()).optional(),
564
+ inputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional(),
565
+ hubInputs: z4.record(z4.string(), z4.array(hubInputSchema)).optional(),
566
+ injectionInputs: z4.array(hubInputSchema).optional(),
567
+ position: positionSchema.optional()
568
+ });
569
+ var instanceModelSchema = z4.object({
570
+ id: instanceIdSchema,
571
+ kind: componentKindSchema,
572
+ type: versionedNameSchema,
573
+ name: genericNameSchema,
574
+ ...instanceModelPatchSchema.shape,
575
+ resolvedInputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional(),
576
+ parentId: instanceIdSchema.optional(),
577
+ outputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional(),
578
+ resolvedOutputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional()
579
+ });
580
+ var hubModelPatchSchema = z4.object({
581
+ position: positionSchema.optional(),
582
+ inputs: z4.array(instanceInputSchema).optional(),
583
+ injectionInputs: z4.array(hubInputSchema).optional()
584
+ });
585
+ var hubModelSchema = z4.object({
586
+ id: z4.cuid2(),
587
+ ...hubModelPatchSchema.shape
588
+ });
589
+ function parseInstanceId(instanceId) {
590
+ const parts = instanceId.split(":");
591
+ if (parts.length !== 2) {
592
+ throw new Error(`Invalid instance ID: ${instanceId}`);
593
+ }
594
+ return parts;
595
+ }
596
+ function selectInput(inputs, name) {
597
+ const groupBoundary = inputs[boundaryInput] ?? inputs[0]?.[boundaryInput];
598
+ if (inputs.length === 0 && !groupBoundary) {
599
+ throw new Error(`Cannot select input "${name}": empty input group has no boundary metadata to build a missing input reference.`);
600
+ }
601
+ const input = inputs.find((input2) => input2.provided && (input2.instanceId === name || parseInstanceId(input2.instanceId)[1] === name));
602
+ if (!input || !input.provided) {
603
+ const fallbackBoundary = groupBoundary ?? inputs.find((input2) => Boolean(input2[boundaryInput]))?.[boundaryInput] ?? inputs[0]?.[boundaryInput];
604
+ if (!fallbackBoundary) {
605
+ throw new Error(`Cannot select input "${name}": input group has no boundary metadata to build a missing input reference.`);
606
+ }
607
+ return createNonProvidedInput(fallbackBoundary);
608
+ }
609
+ const boundary = groupBoundary ?? input[boundaryInput];
610
+ return createInput(input, { boundary });
611
+ }
612
+ var HighstateSignature;
613
+ ((HighstateSignature2) => {
614
+ HighstateSignature2["Artifact"] = "d55c63ac-3174-4756-808f-f778e99af0d1";
615
+ HighstateSignature2["Yaml"] = "c857cac5-caa6-4421-b82c-e561fbce6367";
616
+ HighstateSignature2["Secret"] = "240e5789-6ae4-4b22-b9d8-87169e8b4bab";
617
+ })(HighstateSignature ||= {});
618
+ var yamlValueSchema = z4.object({
619
+ ["c857cac5-caa6-4421-b82c-e561fbce6367" /* Yaml */]: z4.literal(true),
620
+ value: z4.string()
621
+ });
622
+ var fileMetaSchema = z4.object({
623
+ name: z4.string(),
624
+ contentType: z4.string().optional(),
625
+ size: z4.number().optional(),
626
+ mode: z4.number().optional()
627
+ });
628
+ var WellKnownInstanceCustomStatus;
629
+ ((WellKnownInstanceCustomStatus2) => {
630
+ WellKnownInstanceCustomStatus2["Healthy"] = "healthy";
631
+ WellKnownInstanceCustomStatus2["Degraded"] = "degraded";
632
+ WellKnownInstanceCustomStatus2["Down"] = "down";
633
+ WellKnownInstanceCustomStatus2["Warning"] = "warning";
634
+ WellKnownInstanceCustomStatus2["Progressing"] = "progressing";
635
+ WellKnownInstanceCustomStatus2["Error"] = "error";
636
+ })(WellKnownInstanceCustomStatus ||= {});
637
+ var instanceStatusFieldValueSchema = z4.union([
638
+ z4.string(),
639
+ z4.number(),
640
+ z4.boolean(),
641
+ z4.string().array()
642
+ ]);
643
+ var instanceStatusFieldSchema = z4.object({
644
+ name: z4.string(),
645
+ meta: objectMetaSchema.pick({
646
+ title: true,
647
+ icon: true,
648
+ iconColor: true
649
+ }).required({ title: true }),
650
+ complementaryTo: z4.string().optional(),
651
+ value: instanceStatusFieldValueSchema.optional()
652
+ });
653
+ function secretSchema(schema) {
654
+ const secretType = z4.object({
655
+ ["240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */]: z4.literal(true),
656
+ value: schema
657
+ });
658
+ return z4.codec(z4.union([secretType, schema]), secretType, {
659
+ decode: (value) => typeof value === "object" && value !== null && ("240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */ in value) ? value : { ["240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */]: true, value },
660
+ encode: (value) => value
661
+ });
662
+ }
663
+ function isSecret(value) {
664
+ return typeof value === "object" && value !== null && "240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */ in value;
665
+ }
666
+ // src/unit.ts
667
+ import { mapValues as mapValues3 } from "remeda";
668
+ import { z as z6 } from "zod";
669
+
670
+ // src/component.ts
671
+ import { isNonNullish, mapValues as mapValues2, pickBy, uniqueBy } from "remeda";
672
+ import { z as z5 } from "zod";
673
+
674
+ // src/evaluation.ts
675
+ import { mapValues } from "remeda";
676
+ function isStableInstanceInput(value) {
677
+ return typeof value === "object" && value !== null && "instanceId" in value && "output" in value && typeof value.instanceId === "string" && typeof value.output === "string";
678
+ }
679
+ function formatInstancePath(instance) {
680
+ let result = instance.id;
681
+ while (instance.parentId) {
682
+ const parent = runtimeInstances.get(instance.parentId)?.instance;
683
+ if (!parent) {
684
+ break;
685
+ }
686
+ result = `${parent.id} -> ${result}`;
687
+ instance = parent;
688
+ }
689
+ return result;
690
+ }
691
+
692
+ class InstanceNameConflictError extends Error {
693
+ instanceId;
694
+ firstPath;
695
+ secondPath;
696
+ constructor(instanceId, firstPath, secondPath) {
697
+ super(`Multiple instances produced with the same instance ID "${instanceId}":
698
+ ` + `1. ${firstPath}
699
+ ` + `2. ${secondPath}`);
700
+ this.instanceId = instanceId;
701
+ this.firstPath = firstPath;
702
+ this.secondPath = secondPath;
703
+ this.name = "InstanceNameConflictError";
704
+ }
705
+ }
706
+ var currentInstance = null;
707
+ var runtimeInstances = new Map;
708
+ function resetEvaluation() {
709
+ runtimeInstances.clear();
710
+ currentInstance = null;
711
+ }
712
+ function getRuntimeInstances() {
713
+ return Array.from(runtimeInstances.values());
714
+ }
715
+ function registerInstance(component, instance, fn) {
716
+ const conflicting = runtimeInstances.get(instance.id);
717
+ if (conflicting) {
718
+ throw new InstanceNameConflictError(instance.id, formatInstancePath(conflicting.instance), formatInstancePath(instance));
719
+ }
720
+ runtimeInstances.set(instance.id, { instance, component });
721
+ let previousParentInstance = null;
722
+ if (currentInstance) {
723
+ instance.parentId = currentInstance.id;
724
+ }
725
+ if (component.model.kind === "composite") {
726
+ previousParentInstance = currentInstance;
727
+ currentInstance = instance;
728
+ }
729
+ try {
730
+ const rawOutputs = fn();
731
+ const outputs = mapValues(rawOutputs ?? {}, (outputGroup) => {
732
+ return [outputGroup].flat(2).filter(Boolean);
733
+ });
734
+ const toStableInputs = (outputGroup, useBoundaryFallback) => {
735
+ return outputGroup.map((output) => useBoundaryFallback ? output[boundaryInput] : output).filter(isStableInstanceInput).map((output) => {
736
+ return output.path ? {
737
+ instanceId: output.instanceId,
738
+ output: output.output,
739
+ path: output.path
740
+ } : {
741
+ instanceId: output.instanceId,
742
+ output: output.output
743
+ };
744
+ });
745
+ };
746
+ instance.resolvedOutputs = mapValues(outputs ?? {}, (outputGroup) => toStableInputs(outputGroup, false));
747
+ instance.outputs = mapValues(outputs ?? {}, (outputGroup) => toStableInputs(outputGroup, true));
748
+ return mapValues(rawOutputs, (rawOutputGroup, outputKey) => {
749
+ const outputRefs = (outputs[outputKey] ?? []).map((output) => {
750
+ if (output.provided) {
751
+ output[boundaryInput] = { instanceId: instance.id, output: outputKey };
752
+ }
753
+ return output;
754
+ });
755
+ if (component.model.outputs[outputKey]?.multiple) {
756
+ const multipleOutput = Array.isArray(rawOutputGroup) ? rawOutputGroup : outputRefs;
757
+ multipleOutput[boundaryInput] ??= { instanceId: instance.id, output: outputKey };
758
+ return multipleOutput;
759
+ }
760
+ return rawOutputGroup ?? outputRefs[0];
761
+ });
762
+ } finally {
763
+ if (previousParentInstance) {
764
+ currentInstance = previousParentInstance;
765
+ }
766
+ }
767
+ }
768
+
751
769
  // src/component.ts
752
- var runtimeSchema = /* @__PURE__ */ Symbol("runtimeSchema");
753
770
  var validationEnabled = true;
754
771
  function setValidationEnabled(enabled) {
755
772
  validationEnabled = enabled;
756
773
  }
757
- var componentKindSchema = z.enum(["composite", "unit"]);
758
- var componentArgumentSchema = z.object({
759
- /**
760
- * The JSON schema of the argument value.
761
- */
762
- schema: z.custom(),
763
- /**
764
- * The original Zod schema of the argument.
765
- *
766
- * Only available at runtime.
767
- */
768
- [runtimeSchema]: z.instanceof(z.ZodType).optional(),
769
- /**
770
- * Whether the argument is required.
771
- */
772
- required: z.boolean(),
773
- /**
774
- * The extra metadata of the argument.
775
- */
774
+ var componentArgumentSchema = z5.object({
775
+ schema: z5.custom(),
776
+ [runtimeSchema]: z5.instanceof(z5.ZodType).optional(),
777
+ required: z5.boolean(),
776
778
  meta: objectMetaSchema.required({ title: true }).pick({
777
779
  title: true,
778
780
  globalTitle: true,
@@ -782,57 +784,22 @@ var componentArgumentSchema = z.object({
782
784
  iconColor: true
783
785
  })
784
786
  });
785
- var componentInputSchema = z.object({
786
- /**
787
- * The type of the entity passed through the input.
788
- */
787
+ var componentInputSchema = z5.object({
789
788
  type: versionedNameSchema,
790
- /**
791
- * The input name this output type is derived from.
792
- *
793
- * If set, the output uses the referenced input as its fallback type source.
794
- */
795
789
  fromInput: fieldNameSchema.optional(),
796
- /**
797
- * Whether the input is required.
798
- */
799
- required: z.boolean(),
800
- /**
801
- * Whether the input can have multiple values.
802
- */
803
- multiple: z.boolean(),
804
- /**
805
- * The extra metadata of the input.
806
- */
790
+ required: z5.boolean(),
791
+ multiple: z5.boolean(),
807
792
  meta: objectMetaSchema.required({ title: true }).pick({
808
793
  title: true,
809
794
  description: true
810
795
  })
811
796
  });
812
- var componentModelSchema = z.object({
813
- /**
814
- * The type of the component.
815
- */
797
+ var componentModelSchema = z5.object({
816
798
  type: genericNameSchema,
817
- /**
818
- * The kind of the component.
819
- */
820
799
  kind: componentKindSchema,
821
- /**
822
- * The record of the argument schemas.
823
- */
824
- args: z.record(fieldNameSchema, componentArgumentSchema),
825
- /**
826
- * The record of the input schemas.
827
- */
828
- inputs: z.record(fieldNameSchema, componentInputSchema),
829
- /**
830
- * The record of the output schemas.
831
- */
832
- outputs: z.record(fieldNameSchema, componentInputSchema),
833
- /**
834
- * The extra metadata of the component.
835
- */
800
+ args: z5.record(fieldNameSchema, componentArgumentSchema),
801
+ inputs: z5.record(fieldNameSchema, componentInputSchema),
802
+ outputs: z5.record(fieldNameSchema, componentInputSchema),
836
803
  meta: objectMetaSchema.required({ title: true }).pick({
837
804
  title: true,
838
805
  description: true,
@@ -842,26 +809,12 @@ var componentModelSchema = z.object({
842
809
  secondaryIcon: true,
843
810
  secondaryIconColor: true
844
811
  }).extend({
845
- /**
846
- * The category of the component.
847
- *
848
- * Used to group components in the UI.
849
- */
850
- category: z.string().optional(),
851
- /**
852
- * The default name prefix for the component instances.
853
- *
854
- * Used to generate default names for the instances.
855
- */
856
- defaultNamePrefix: z.string()
812
+ category: z5.string().optional(),
813
+ defaultNamePrefix: z5.string()
857
814
  }),
858
- /**
859
- * The CRC32 of the component definition.
860
- */
861
- definitionHash: z.number()
815
+ definitionHash: z5.number()
862
816
  });
863
- var originalCreate = /* @__PURE__ */ Symbol("originalCreate");
864
- var kind = /* @__PURE__ */ Symbol("kind");
817
+ var originalCreate = Symbol("originalCreate");
865
818
  function defineComponent(options) {
866
819
  try {
867
820
  componentModelSchema.shape.type.parse(options.type);
@@ -871,21 +824,20 @@ function defineComponent(options) {
871
824
  if (!options.create) {
872
825
  throw new Error("Component create function is required");
873
826
  }
874
- const entities = /* @__PURE__ */ new Map();
827
+ const entities = new Map;
875
828
  const mapInput = createInputMapper(entities);
876
829
  const mapOutput = createOutputMapper(options.inputs, entities);
877
830
  const model = {
878
831
  type: options.type,
879
832
  kind: options[kind] ?? "composite",
880
- args: mapValues(options.args ?? {}, mapArgument),
881
- inputs: mapValues(options.inputs ?? {}, mapInput),
882
- outputs: mapValues(options.outputs ?? {}, mapOutput),
833
+ args: mapValues2(options.args ?? {}, mapArgument),
834
+ inputs: mapValues2(options.inputs ?? {}, mapInput),
835
+ outputs: mapValues2(options.outputs ?? {}, mapOutput),
883
836
  meta: {
884
837
  ...options.meta,
885
838
  title: options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0]),
886
839
  defaultNamePrefix: options.meta?.defaultNamePrefix || parseVersionedName(options.type)[0].split(".").slice(-1)[0]
887
840
  },
888
- // will be calculated by library loader
889
841
  definitionHash: null
890
842
  };
891
843
  function create(params) {
@@ -916,54 +868,48 @@ function defineComponent(options) {
916
868
  tracedInputs[key] = uniqueBy(group, inputKey);
917
869
  flatInputs[key] = uniqueBy(inputs2, runtimeInputKey);
918
870
  }
919
- return registerInstance(
920
- create,
921
- {
922
- id: instanceId,
923
- type: options.type,
924
- kind: options[kind] ?? "composite",
925
- name,
926
- args,
927
- inputs: tracedInputs,
928
- resolvedInputs: mapValues(flatInputs, (inputs2) => {
929
- return inputs2.filter((input) => input.provided).map((input) => ({
930
- instanceId: input.instanceId,
931
- output: input.output,
932
- ...input.path ? { path: input.path } : {}
933
- }));
934
- })
935
- },
936
- () => {
937
- const markedInputs = mapValues(model.inputs, (componentInput, key) => {
938
- if (!componentInput.multiple) {
939
- const input = flatInputs[key]?.[0];
940
- if (input?.provided) {
941
- return createDeepOutputAccessor({
942
- ...input,
943
- [boundaryInput]: { instanceId, output: key }
944
- });
945
- }
946
- return createNonProvidedInput({ instanceId, output: key });
947
- }
948
- const inputs2 = (flatInputs[key] ?? []).filter(isProvidedRuntimeInput).map(
949
- (input) => createDeepOutputAccessor({
871
+ return registerInstance(create, {
872
+ id: instanceId,
873
+ type: options.type,
874
+ kind: options[kind] ?? "composite",
875
+ name,
876
+ args,
877
+ inputs: tracedInputs,
878
+ resolvedInputs: mapValues2(flatInputs, (inputs2) => {
879
+ return inputs2.filter((input) => input.provided).map((input) => ({
880
+ instanceId: input.instanceId,
881
+ output: input.output,
882
+ ...input.path ? { path: input.path } : {}
883
+ }));
884
+ })
885
+ }, () => {
886
+ const markedInputs = mapValues2(model.inputs, (componentInput, key) => {
887
+ if (!componentInput.multiple) {
888
+ const input = flatInputs[key]?.[0];
889
+ if (input?.provided) {
890
+ return createDeepOutputAccessor({
950
891
  ...input,
951
892
  [boundaryInput]: { instanceId, output: key }
952
- })
953
- );
954
- const multipleBoundary = { instanceId, output: key };
955
- return createMultipleInputAccessor(inputs2, multipleBoundary);
956
- });
957
- const outputs = options.create({
958
- id: instanceId,
959
- name,
960
- args: processArgs(instanceId, create.model, args),
961
- inputs: markedInputs
962
- }) ?? {};
963
- const normalizedOutputs = normalizeCreateOutputs(outputs, model, instanceId);
964
- return withDeepOutputAccessors(normalizedOutputs, model, instanceId);
965
- }
966
- );
893
+ });
894
+ }
895
+ return createNonProvidedInput({ instanceId, output: key });
896
+ }
897
+ const inputs2 = (flatInputs[key] ?? []).filter(isProvidedRuntimeInput).map((input) => createDeepOutputAccessor({
898
+ ...input,
899
+ [boundaryInput]: { instanceId, output: key }
900
+ }));
901
+ const multipleBoundary = { instanceId, output: key };
902
+ return createMultipleInputAccessor(inputs2, multipleBoundary);
903
+ });
904
+ const outputs = options.create({
905
+ id: instanceId,
906
+ name,
907
+ args: processArgs(instanceId, create.model, args),
908
+ inputs: markedInputs
909
+ }) ?? {};
910
+ const normalizedOutputs = normalizeCreateOutputs(outputs, model, instanceId);
911
+ return withDeepOutputAccessors(normalizedOutputs, model, instanceId);
912
+ });
967
913
  function normalizeIncomingInput(input, inputName) {
968
914
  if (isStableInstanceInput2(input)) {
969
915
  return createInput(input);
@@ -977,9 +923,7 @@ function defineComponent(options) {
977
923
  };
978
924
  return createInput(runtimeInput, { boundary: inputBoundary });
979
925
  }
980
- return createNonProvidedInput(
981
- runtimeInput[boundaryInput] ?? { instanceId, output: inputName }
982
- );
926
+ return createNonProvidedInput(runtimeInput[boundaryInput] ?? { instanceId, output: inputName });
983
927
  }
984
928
  function normalizeIncomingInputGroup(inputGroup, inputName) {
985
929
  const group = [];
@@ -1024,9 +968,7 @@ function processArgs(instanceId, model, args) {
1024
968
  if (arg.schema) {
1025
969
  const result = arg[runtimeSchema].safeParse(args[key]);
1026
970
  if (!result.success) {
1027
- throw new Error(
1028
- `Invalid argument "${key}" in instance "${instanceId}": ${result.error.message}`
1029
- );
971
+ throw new Error(`Invalid argument "${key}" in instance "${instanceId}": ${result.error.message}`);
1030
972
  }
1031
973
  validatedArgs[key] = result.data;
1032
974
  } else {
@@ -1036,7 +978,7 @@ function processArgs(instanceId, model, args) {
1036
978
  return validatedArgs;
1037
979
  }
1038
980
  function withDeepOutputAccessors(outputs, model, instanceId) {
1039
- return mapValues(outputs, (outputGroup, outputName) => {
981
+ return mapValues2(outputs, (outputGroup, outputName) => {
1040
982
  const outputSpec = model.outputs[outputName];
1041
983
  if (!outputSpec) {
1042
984
  return outputGroup[0];
@@ -1068,9 +1010,7 @@ function normalizeCreateOutputGroup(outputGroup, instanceId, outputName) {
1068
1010
  };
1069
1011
  return createInput(runtimeOutput, { boundary: stableBoundary });
1070
1012
  }
1071
- return createNonProvidedInput(
1072
- runtimeOutput[boundaryInput] ?? { instanceId, output: outputName }
1073
- );
1013
+ return createNonProvidedInput(runtimeOutput[boundaryInput] ?? { instanceId, output: outputName });
1074
1014
  });
1075
1015
  }
1076
1016
  function normalizeCreateOutputs(outputs, model, instanceId) {
@@ -1086,9 +1026,7 @@ function normalizeCreateOutputs(outputs, model, instanceId) {
1086
1026
  }
1087
1027
  const normalizedGroup = normalizeCreateOutputGroup(outputGroup, instanceId, outputName);
1088
1028
  if (outputSpec.multiple && normalizedGroup.some((output) => !output.provided)) {
1089
- throw new Error(
1090
- `Multiple output "${outputName}" in instance "${instanceId}" cannot contain non-provided items`
1091
- );
1029
+ throw new Error(`Multiple output "${outputName}" in instance "${instanceId}" cannot contain non-provided items`);
1092
1030
  }
1093
1031
  if (model.kind === "unit") {
1094
1032
  if (normalizedGroup.length === 0 || normalizedGroup.some((output) => !output.provided)) {
@@ -1119,12 +1057,12 @@ function isComponent(value) {
1119
1057
  return typeof value === "function" && "model" in value;
1120
1058
  }
1121
1059
  function isSchemaOptional(schema) {
1122
- return schema.safeParse(void 0).success;
1060
+ return schema.safeParse(undefined).success;
1123
1061
  }
1124
1062
  function mapArgument(value, key) {
1125
1063
  if ("schema" in value) {
1126
1064
  return {
1127
- schema: z.toJSONSchema(value.schema, {
1065
+ schema: z5.toJSONSchema(value.schema, {
1128
1066
  target: "draft-7",
1129
1067
  io: "input",
1130
1068
  unrepresentable: "any"
@@ -1138,7 +1076,7 @@ function mapArgument(value, key) {
1138
1076
  };
1139
1077
  }
1140
1078
  return {
1141
- schema: z.toJSONSchema(value, { target: "draft-7", io: "input", unrepresentable: "any" }),
1079
+ schema: z5.toJSONSchema(value, { target: "draft-7", io: "input", unrepresentable: "any" }),
1142
1080
  [runtimeSchema]: value,
1143
1081
  required: !isSchemaOptional(value),
1144
1082
  meta: {
@@ -1185,9 +1123,7 @@ function createOutputMapper(inputs, entities) {
1185
1123
  }
1186
1124
  const sourceInput = inputs?.[value.fromInput];
1187
1125
  if (!sourceInput) {
1188
- throw new Error(
1189
- `Output "${key}" references missing input "${value.fromInput}" via fromInput.`
1190
- );
1126
+ throw new Error(`Output "${key}" references missing input "${value.fromInput}" via fromInput.`);
1191
1127
  }
1192
1128
  const mappedInput = mapInput(sourceInput, value.fromInput);
1193
1129
  return {
@@ -1205,13 +1141,13 @@ function getInstanceId(instanceType, instanceName) {
1205
1141
  return `${instanceType}:${instanceName}`;
1206
1142
  }
1207
1143
  function toFullComponentArgumentOptions(args) {
1208
- return mapValues(args, (arg) => "schema" in arg ? arg : { schema: arg });
1144
+ return mapValues2(args, (arg) => ("schema" in arg) ? arg : { schema: arg });
1209
1145
  }
1210
1146
  function toFullComponentInputOptions(inputs) {
1211
- return mapValues(inputs, (input) => "entity" in input ? input : { entity: input });
1147
+ return mapValues2(inputs, (input) => ("entity" in input) ? input : { entity: input });
1212
1148
  }
1213
1149
  function toFullComponentOutputOptions(outputs) {
1214
- return mapValues(outputs, (output) => {
1150
+ return mapValues2(outputs, (output) => {
1215
1151
  if (typeof output !== "object" || output === null) {
1216
1152
  return { entity: output };
1217
1153
  }
@@ -1265,244 +1201,19 @@ function $addInputDescription(input, description) {
1265
1201
  };
1266
1202
  }
1267
1203
 
1268
- // src/instance.ts
1269
- function inputKey(input) {
1270
- return input.path ? `${input.instanceId}:${input.output}:${input.path}` : `${input.instanceId}:${input.output}`;
1271
- }
1272
- var positionSchema = z.object({
1273
- x: z.number(),
1274
- y: z.number()
1275
- });
1276
- var instanceIdSchema = z.templateLiteral([versionedNameSchema, ":", genericNameSchema]);
1277
- var instanceInputSchema = z.object({
1278
- instanceId: instanceIdSchema,
1279
- output: z.string(),
1280
- path: z.string().optional()
1281
- });
1282
- var hubInputSchema = z.object({
1283
- hubId: z.string()
1284
- });
1285
- var instanceModelPatchSchema = z.object({
1286
- /**
1287
- * The static arguments passed to the instance.
1288
- */
1289
- args: z.record(z.string(), z.unknown()).optional(),
1290
- /**
1291
- * The direct instances passed as inputs to the instance.
1292
- */
1293
- inputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),
1294
- /**
1295
- * The resolved unit inputs for the instance.
1296
- *
1297
- * Only for computed composite instances.
1298
- */
1299
- hubInputs: z.record(z.string(), z.array(hubInputSchema)).optional(),
1300
- /**
1301
- * The inputs injected to the instance from the hubs.
1302
- *
1303
- * While `hubInputs` allows to pass hubs to distinct inputs,
1304
- * `injectionInputs` allows to pass hubs to the instance as a whole filling all inputs with matching types.
1305
- *
1306
- * Only for designer-first instances.
1307
- */
1308
- injectionInputs: z.array(hubInputSchema).optional(),
1309
- /**
1310
- * The position of the instance on the canvas.
1311
- *
1312
- * Only for designer-first instances.
1313
- */
1314
- position: positionSchema.optional()
1315
- });
1316
- var instanceModelSchema = z.object({
1317
- /**
1318
- * The id of the instance unique within the project.
1319
- *
1320
- * The format is `${instanceType}:${instanceName}`.
1321
- */
1322
- id: instanceIdSchema,
1323
- /**
1324
- * The kind of the instance.
1325
- *
1326
- * Can be either "unit" or "composite".
1327
- */
1328
- kind: componentKindSchema,
1329
- /**
1330
- * The type of the instance.
1331
- */
1332
- type: versionedNameSchema,
1333
- /**
1334
- * The name of the instance.
1335
- *
1336
- * Must be unique within instances of the same type in the project.
1337
- */
1338
- name: genericNameSchema,
1339
- ...instanceModelPatchSchema.shape,
1340
- /**
1341
- * The id of the top level parent instance.
1342
- *
1343
- * Only for child instances of the composite instances.
1344
- */
1345
- resolvedInputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),
1346
- /**
1347
- * The ID of the parent instance.
1348
- *
1349
- * Only for child instances of the composite instances.
1350
- */
1351
- parentId: instanceIdSchema.optional(),
1352
- /**
1353
- * The direct instance outputs returned by the instance as outputs.
1354
- *
1355
- * Only for computed composite instances.
1356
- */
1357
- outputs: z.record(z.string(), z.array(instanceInputSchema)).optional(),
1358
- /**
1359
- * The resolved unit outputs for the instance.
1360
- *
1361
- * Only for computed composite instances.
1362
- */
1363
- resolvedOutputs: z.record(z.string(), z.array(instanceInputSchema)).optional()
1364
- });
1365
- var hubModelPatchSchema = z.object({
1366
- /**
1367
- * The position of the hub on the canvas.
1368
- */
1369
- position: positionSchema.optional(),
1370
- /**
1371
- * The inputs of the hub.
1372
- */
1373
- inputs: z.array(instanceInputSchema).optional(),
1374
- /**
1375
- * The inputs injected to the hub from the hubs.
1376
- *
1377
- * While `inputs` allows to pass hubs to distinct inputs,
1378
- * `injectionInputs` allows to pass hubs to the hub as a whole filling all inputs with matching types.
1379
- */
1380
- injectionInputs: z.array(hubInputSchema).optional()
1381
- });
1382
- var hubModelSchema = z.object({
1383
- /**
1384
- * The id of the hub unique within the project.
1385
- */
1386
- id: z.cuid2(),
1387
- ...hubModelPatchSchema.shape
1388
- });
1389
- function parseInstanceId(instanceId) {
1390
- const parts = instanceId.split(":");
1391
- if (parts.length !== 2) {
1392
- throw new Error(`Invalid instance ID: ${instanceId}`);
1393
- }
1394
- return parts;
1395
- }
1396
- function selectInput(inputs, name) {
1397
- const groupBoundary = inputs[boundaryInput] ?? inputs[0]?.[boundaryInput];
1398
- if (inputs.length === 0 && !groupBoundary) {
1399
- throw new Error(
1400
- `Cannot select input "${name}": empty input group has no boundary metadata to build a missing input reference.`
1401
- );
1402
- }
1403
- const input = inputs.find(
1404
- (input2) => input2.provided && (input2.instanceId === name || parseInstanceId(input2.instanceId)[1] === name)
1405
- );
1406
- if (!input || !input.provided) {
1407
- const fallbackBoundary = groupBoundary ?? inputs.find((input2) => Boolean(input2[boundaryInput]))?.[boundaryInput] ?? inputs[0]?.[boundaryInput];
1408
- if (!fallbackBoundary) {
1409
- throw new Error(
1410
- `Cannot select input "${name}": input group has no boundary metadata to build a missing input reference.`
1411
- );
1412
- }
1413
- return createNonProvidedInput(fallbackBoundary);
1414
- }
1415
- const boundary = groupBoundary ?? input[boundaryInput];
1416
- return createInput(input, { boundary });
1417
- }
1418
- var HighstateSignature = /* @__PURE__ */ ((HighstateSignature2) => {
1419
- HighstateSignature2["Artifact"] = "d55c63ac-3174-4756-808f-f778e99af0d1";
1420
- HighstateSignature2["Yaml"] = "c857cac5-caa6-4421-b82c-e561fbce6367";
1421
- HighstateSignature2["Secret"] = "240e5789-6ae4-4b22-b9d8-87169e8b4bab";
1422
- return HighstateSignature2;
1423
- })(HighstateSignature || {});
1424
- var yamlValueSchema = z.object({
1425
- ["c857cac5-caa6-4421-b82c-e561fbce6367" /* Yaml */]: z.literal(true),
1426
- value: z.string()
1427
- });
1428
- var fileMetaSchema = z.object({
1429
- name: z.string(),
1430
- contentType: z.string().optional(),
1431
- size: z.number().optional(),
1432
- mode: z.number().optional()
1433
- });
1434
- var WellKnownInstanceCustomStatus = /* @__PURE__ */ ((WellKnownInstanceCustomStatus2) => {
1435
- WellKnownInstanceCustomStatus2["Healthy"] = "healthy";
1436
- WellKnownInstanceCustomStatus2["Degraded"] = "degraded";
1437
- WellKnownInstanceCustomStatus2["Down"] = "down";
1438
- WellKnownInstanceCustomStatus2["Warning"] = "warning";
1439
- WellKnownInstanceCustomStatus2["Progressing"] = "progressing";
1440
- WellKnownInstanceCustomStatus2["Error"] = "error";
1441
- return WellKnownInstanceCustomStatus2;
1442
- })(WellKnownInstanceCustomStatus || {});
1443
- var instanceStatusFieldValueSchema = z.union([
1444
- z.string(),
1445
- z.number(),
1446
- z.boolean(),
1447
- z.string().array()
1448
- ]);
1449
- var instanceStatusFieldSchema = z.object({
1450
- name: z.string(),
1451
- meta: objectMetaSchema.pick({
1452
- title: true,
1453
- icon: true,
1454
- iconColor: true
1455
- }).required({ title: true }),
1456
- complementaryTo: z.string().optional(),
1457
- value: instanceStatusFieldValueSchema.optional()
1458
- });
1459
- function secretSchema(schema) {
1460
- const secretType = z.object({
1461
- ["240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */]: z.literal(true),
1462
- value: schema
1463
- });
1464
- return z.codec(z.union([secretType, schema]), secretType, {
1465
- decode: (value) => typeof value === "object" && value !== null && "240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */ in value ? value : { ["240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */]: true, value },
1466
- encode: (value) => value
1467
- });
1468
- }
1469
- function isSecret(value) {
1470
- return typeof value === "object" && value !== null && "240e5789-6ae4-4b22-b9d8-87169e8b4bab" /* Secret */ in value;
1471
- }
1204
+ // src/unit.ts
1472
1205
  var componentSecretSchema = componentArgumentSchema.extend({
1473
- /**
1474
- * The secret cannot be modified by the user, but can be modified by the unit.
1475
- */
1476
- readonly: z.boolean(),
1477
- /**
1478
- * The secret value is computed by the unit and should not be passed to it when invoked.
1479
- */
1480
- computed: z.boolean()
1206
+ readonly: z6.boolean(),
1207
+ computed: z6.boolean()
1481
1208
  });
1482
- var unitSourceSchema = z.object({
1483
- /**
1484
- * The package where the unit implementation is located.
1485
- *
1486
- * May be both: local monorepo package or a remote NPM package.
1487
- */
1488
- package: z.string(),
1489
- /**
1490
- * The path to the unit implementation within the package.
1491
- *
1492
- * If not provided, the root of the package is assumed.
1493
- */
1494
- path: z.string().optional()
1209
+ var unitSourceSchema = z6.object({
1210
+ package: z6.string(),
1211
+ path: z6.string().optional()
1495
1212
  });
1496
- var unitModelSchema = z.object({
1213
+ var unitModelSchema = z6.object({
1497
1214
  ...componentModelSchema.shape,
1498
- /**
1499
- * The source of the unit.
1500
- */
1501
1215
  source: unitSourceSchema,
1502
- /**
1503
- * The record of the secret specs.
1504
- */
1505
- secrets: z.record(z.string(), componentSecretSchema)
1216
+ secrets: z6.record(z6.string(), componentSecretSchema)
1506
1217
  });
1507
1218
  function defineUnit(options) {
1508
1219
  if (!options.source) {
@@ -1529,7 +1240,7 @@ function defineUnit(options) {
1529
1240
  });
1530
1241
  try {
1531
1242
  component.model.source = options.source ?? {};
1532
- component.model.secrets = mapValues(options.secrets ?? {}, mapSecret);
1243
+ component.model.secrets = mapValues3(options.secrets ?? {}, mapSecret);
1533
1244
  } catch (error) {
1534
1245
  throw new Error(`Failed to map secrets for unit "${options.type}"`, { cause: error });
1535
1246
  }
@@ -1555,13 +1266,22 @@ function mapSecret(value, key) {
1555
1266
  function isUnitModel(model) {
1556
1267
  return "source" in model;
1557
1268
  }
1558
- var triggerSpecSchema = z.union([
1559
- z.object({
1560
- type: z.literal("before-destroy")
1269
+ // src/terminal.ts
1270
+ import { z as z9 } from "zod";
1271
+
1272
+ // src/pulumi.ts
1273
+ import { parse } from "yaml";
1274
+ import { z as z8 } from "zod";
1275
+
1276
+ // src/trigger.ts
1277
+ import { z as z7 } from "zod";
1278
+ var triggerSpecSchema = z7.union([
1279
+ z7.object({
1280
+ type: z7.literal("before-destroy")
1561
1281
  })
1562
1282
  ]);
1563
- var unitTriggerSchema = z.object({
1564
- name: z.string(),
1283
+ var unitTriggerSchema = z7.object({
1284
+ name: z7.string(),
1565
1285
  meta: objectMetaSchema.pick({
1566
1286
  title: true,
1567
1287
  globalTitle: true,
@@ -1569,165 +1289,85 @@ var unitTriggerSchema = z.object({
1569
1289
  icon: true,
1570
1290
  iconColor: true
1571
1291
  }).required({ title: true }),
1572
- /**
1573
- * The specification of the trigger.
1574
- *
1575
- * Defines the type of trigger and its behavior.
1576
- */
1577
1292
  spec: triggerSpecSchema
1578
1293
  });
1579
- var triggerInvocationSchema = z.object({
1580
- /**
1581
- * The name of the trigger being invoked.
1582
- */
1583
- name: z.string()
1294
+ var triggerInvocationSchema = z7.object({
1295
+ name: z7.string()
1584
1296
  });
1585
1297
 
1586
1298
  // src/pulumi.ts
1587
- var unitInputSourceSchema = z.object({
1299
+ var unitInputSourceSchema = z8.object({
1588
1300
  ...instanceInputSchema.shape
1589
1301
  });
1590
- var unitInputValueSchema = z.object({
1591
- /**
1592
- * Inline resolved value passed to the unit.
1593
- *
1594
- * The backend is responsible for resolving the correct entity snapshot value
1595
- * and applying any inclusion transformations.
1596
- */
1597
- value: z.unknown(),
1598
- /**
1599
- * Optional provenance of the value.
1600
- */
1302
+ var unitInputValueSchema = z8.object({
1303
+ value: z8.unknown(),
1601
1304
  source: unitInputSourceSchema.optional()
1602
1305
  });
1603
- var unitConfigSchema = z.object({
1604
- /**
1605
- * The ID of the instance.
1606
- */
1607
- instanceId: z.string(),
1608
- /**
1609
- * The state ID of the instance.
1610
- */
1611
- stateId: z.string(),
1612
- /**
1613
- * The record of argument values for the unit.
1614
- */
1615
- args: z.record(z.string(), z.unknown()),
1616
- /**
1617
- * The record of input references for the unit.
1618
- */
1619
- inputs: z.record(z.string(), unitInputValueSchema.array()),
1620
- /**
1621
- * The list of triggers that have been invoked for this unit.
1622
- */
1306
+ var unitConfigSchema = z8.object({
1307
+ instanceId: z8.string(),
1308
+ stateId: z8.string(),
1309
+ args: z8.record(z8.string(), z8.unknown()),
1310
+ inputs: z8.record(z8.string(), unitInputValueSchema.array()),
1623
1311
  invokedTriggers: triggerInvocationSchema.array(),
1624
- /**
1625
- * The record of secret values provided to the unit.
1626
- *
1627
- * It is stored in Pulumi stack config as a secret.
1628
- */
1629
- secretValues: z.record(z.string(), z.unknown()),
1630
- /**
1631
- * The base path for imports.
1632
- * Used to resolve dynamic dependencies in strict environments (like in pnpm node_modules isolation).
1633
- */
1634
- importBasePath: z.string()
1312
+ secretValues: z8.record(z8.string(), z8.unknown()),
1313
+ importBasePath: z8.string()
1635
1314
  });
1636
- var yamlResultCache = /* @__PURE__ */ new WeakMap();
1315
+ var yamlResultCache = new WeakMap;
1637
1316
  function parseArgumentValue(value) {
1638
1317
  const yamlResult = yamlValueSchema.safeParse(value);
1639
1318
  if (!yamlResult.success) {
1640
1319
  return value;
1641
1320
  }
1642
1321
  const existingResult = yamlResultCache.get(value);
1643
- if (existingResult !== void 0) {
1322
+ if (existingResult !== undefined) {
1644
1323
  return existingResult;
1645
1324
  }
1646
1325
  const result = parse(yamlResult.data.value);
1647
1326
  yamlResultCache.set(value, result);
1648
1327
  return result;
1649
1328
  }
1650
- var HighstateConfigKey = /* @__PURE__ */ ((HighstateConfigKey2) => {
1329
+ var HighstateConfigKey;
1330
+ ((HighstateConfigKey2) => {
1651
1331
  HighstateConfigKey2["Config"] = "highstate";
1652
- return HighstateConfigKey2;
1653
- })(HighstateConfigKey || {});
1654
- var unitArtifactId = /* @__PURE__ */ Symbol("unitArtifactId");
1655
- var unitArtifactSchema = z.object({
1656
- ["d55c63ac-3174-4756-808f-f778e99af0d1" /* Artifact */]: z.literal(true),
1657
- // only for internal use
1658
- [unitArtifactId]: z.string().optional(),
1659
- hash: z.string(),
1332
+ })(HighstateConfigKey ||= {});
1333
+ var unitArtifactId = Symbol("unitArtifactId");
1334
+ var unitArtifactSchema = z8.object({
1335
+ ["d55c63ac-3174-4756-808f-f778e99af0d1" /* Artifact */]: z8.literal(true),
1336
+ [unitArtifactId]: z8.string().optional(),
1337
+ hash: z8.string(),
1660
1338
  meta: commonObjectMetaSchema.optional()
1661
1339
  });
1662
- var fileContentSchema = z.union([
1663
- z.object({
1664
- type: z.literal("embedded"),
1665
- /**
1666
- * Whether the content is binary or not.
1667
- *
1668
- * If true, the `value` will be a base64 encoded string.
1669
- */
1670
- isBinary: z.boolean().optional(),
1671
- /**
1672
- * The content of the file.
1673
- *
1674
- * If `isBinary` is true, this will be a base64 encoded string.
1675
- */
1676
- value: z.string()
1340
+ var fileContentSchema = z8.union([
1341
+ z8.object({
1342
+ type: z8.literal("embedded"),
1343
+ isBinary: z8.boolean().optional(),
1344
+ value: z8.string()
1677
1345
  }),
1678
- z.object({
1679
- type: z.literal("embedded-secret"),
1680
- /**
1681
- * Whether the content is binary or not.
1682
- *
1683
- * If true, the `value` will be a base64 encoded string.
1684
- */
1685
- isBinary: z.boolean().optional(),
1686
- /**
1687
- * The content of the file wrapped as a Highstate secret.
1688
- *
1689
- * If `isBinary` is true, this will be a base64 encoded string.
1690
- */
1691
- value: secretSchema(z.string())
1346
+ z8.object({
1347
+ type: z8.literal("embedded-secret"),
1348
+ isBinary: z8.boolean().optional(),
1349
+ value: secretSchema(z8.string())
1692
1350
  }),
1693
- z.object({
1694
- type: z.literal("artifact"),
1351
+ z8.object({
1352
+ type: z8.literal("artifact"),
1695
1353
  ...unitArtifactSchema.shape
1696
1354
  })
1697
1355
  ]);
1698
- var fileSchema = z.object({
1356
+ var fileSchema = z8.object({
1699
1357
  meta: fileMetaSchema,
1700
1358
  content: fileContentSchema
1701
1359
  });
1702
1360
 
1703
1361
  // src/terminal.ts
1704
- var terminalSpecSchema = z.object({
1705
- /**
1706
- * The Docker image to run the terminal.
1707
- */
1708
- image: z.string(),
1709
- /**
1710
- * The command to run in the terminal.
1711
- */
1712
- command: z.string().array(),
1713
- /**
1714
- * The working directory to run the command in.
1715
- */
1716
- cwd: z.string().optional(),
1717
- /**
1718
- * The environment variables to set in the terminal.
1719
- */
1720
- env: z.record(z.string(), z.string()).optional(),
1721
- /**
1722
- * The files to mount in the terminal.
1723
- *
1724
- * The key is the path where the file will be mounted,
1725
- * and the value is the file content or a reference to an artifact.
1726
- */
1727
- files: z.record(z.string(), fileSchema).optional()
1362
+ var terminalSpecSchema = z9.object({
1363
+ image: z9.string(),
1364
+ command: z9.string().array(),
1365
+ cwd: z9.string().optional(),
1366
+ env: z9.record(z9.string(), z9.string()).optional(),
1367
+ files: z9.record(z9.string(), fileSchema).optional()
1728
1368
  });
1729
- var unitTerminalSchema = z.object({
1730
- name: z.string(),
1369
+ var unitTerminalSchema = z9.object({
1370
+ name: z9.string(),
1731
1371
  meta: objectMetaSchema.pick({
1732
1372
  title: true,
1733
1373
  globalTitle: true,
@@ -1737,24 +1377,26 @@ var unitTerminalSchema = z.object({
1737
1377
  }).required({ title: true }),
1738
1378
  spec: terminalSpecSchema
1739
1379
  });
1740
- var pageBlockSchema = z.union([
1741
- z.object({
1742
- type: z.literal("markdown"),
1743
- content: z.string()
1380
+ // src/page.ts
1381
+ import { z as z10 } from "zod";
1382
+ var pageBlockSchema = z10.union([
1383
+ z10.object({
1384
+ type: z10.literal("markdown"),
1385
+ content: z10.string()
1744
1386
  }),
1745
- z.object({
1746
- type: z.literal("qr"),
1747
- content: z.string(),
1748
- showContent: z.coerce.boolean(),
1749
- language: z.string().optional()
1387
+ z10.object({
1388
+ type: z10.literal("qr"),
1389
+ content: z10.string(),
1390
+ showContent: z10.coerce.boolean(),
1391
+ language: z10.string().optional()
1750
1392
  }),
1751
- z.object({
1752
- type: z.literal("file"),
1393
+ z10.object({
1394
+ type: z10.literal("file"),
1753
1395
  file: fileSchema
1754
1396
  })
1755
1397
  ]);
1756
- var unitPageSchema = z.object({
1757
- name: z.string(),
1398
+ var unitPageSchema = z10.object({
1399
+ name: z10.string(),
1758
1400
  meta: objectMetaSchema.pick({
1759
1401
  title: true,
1760
1402
  globalTitle: true,
@@ -1764,52 +1406,49 @@ var unitPageSchema = z.object({
1764
1406
  }).required({ title: true }),
1765
1407
  content: pageBlockSchema.array()
1766
1408
  });
1767
- var unitWorkerSchema = z.object({
1768
- name: z.string(),
1769
- image: z.string(),
1770
- params: z.record(z.string(), z.unknown())
1409
+ // src/worker.ts
1410
+ import { z as z11 } from "zod";
1411
+ var unitWorkerSchema = z11.object({
1412
+ name: z11.string(),
1413
+ image: z11.string(),
1414
+ params: z11.record(z11.string(), z11.unknown())
1771
1415
  });
1772
- var workerRunOptionsSchema = z.object({
1773
- /**
1774
- * The ID of the project for which the worker is running.
1775
- */
1776
- projectId: z.cuid2(),
1777
- /**
1778
- * The ID of the worker version.
1779
- */
1780
- workerVersionId: z.cuid2(),
1781
- /**
1782
- * The URL of the backend API to connect to.
1783
- */
1784
- apiUrl: z.url(),
1785
- /**
1786
- * The API key used to authenticate the worker with the backend.
1787
- */
1788
- apiKey: z.string()
1416
+ var workerRunOptionsSchema = z11.object({
1417
+ projectId: z11.cuid2(),
1418
+ workerVersionId: z11.cuid2(),
1419
+ apiUrl: z11.url(),
1420
+ apiKey: z11.string()
1789
1421
  });
1422
+ // src/utils.ts
1423
+ import { isNonNullish as isNonNullish2, pickBy as pickBy2 } from "remeda";
1790
1424
  function text(strings, ...values) {
1791
1425
  const stringValues = values.map(String);
1792
1426
  let result = "";
1793
- for (let i = 0; i < strings.length; i++) {
1427
+ for (let i = 0;i < strings.length; i++) {
1794
1428
  result += strings[i];
1795
1429
  if (i < stringValues.length) {
1796
1430
  const value = stringValues[i];
1797
- const lines = value.split("\n");
1431
+ const lines = value.split(`
1432
+ `);
1798
1433
  const lastLineIndentMatch = strings[i].match(/(?:^|\n)([ \t]*)$/);
1799
1434
  const indent = lastLineIndentMatch ? lastLineIndentMatch[1] : "";
1800
- result += lines.map((line, j) => j === 0 ? line : indent + line).join("\n");
1435
+ result += lines.map((line, j) => j === 0 ? line : indent + line).join(`
1436
+ `);
1801
1437
  }
1802
1438
  }
1803
1439
  return trimIndentation(result);
1804
1440
  }
1805
1441
  function trimIndentation(text2) {
1806
- const lines = text2.split("\n");
1442
+ const lines = text2.split(`
1443
+ `);
1807
1444
  const indent = lines.filter((line) => line.trim() !== "").map((line) => line.match(/^\s*/)?.[0].length ?? 0).reduce((min, indent2) => Math.min(min, indent2), Infinity);
1808
- return lines.map((line) => line.slice(indent)).join("\n").trim();
1445
+ return lines.map((line) => line.slice(indent)).join(`
1446
+ `).trim();
1809
1447
  }
1810
1448
  function bytesToHumanReadable(bytes) {
1811
1449
  const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
1812
- if (bytes === 0) return "0 Bytes";
1450
+ if (bytes === 0)
1451
+ return "0 Bytes";
1813
1452
  const i = Math.floor(Math.log(bytes) / Math.log(1024));
1814
1453
  return `${parseFloat((bytes / 1024 ** i).toFixed(2))} ${sizes[i]}`;
1815
1454
  }
@@ -1818,7 +1457,7 @@ function check(schema, value) {
1818
1457
  }
1819
1458
  function getOrCreate(map, key, createFn) {
1820
1459
  const existing = map.get(key);
1821
- if (existing !== void 0) {
1460
+ if (existing !== undefined) {
1822
1461
  return existing;
1823
1462
  }
1824
1463
  const value = createFn(key);
@@ -1826,9 +1465,100 @@ function getOrCreate(map, key, createFn) {
1826
1465
  return value;
1827
1466
  }
1828
1467
  function stripNullish(obj) {
1829
- return pickBy(obj, isNonNullish);
1468
+ return pickBy2(obj, isNonNullish2);
1830
1469
  }
1831
1470
 
1832
- export { $addArgumentDescription, $addInputDescription, $args, $inputs, $outputs, $secrets, HighstateConfigKey, HighstateSignature, InstanceNameConflictError, WellKnownInstanceCustomStatus, bytesToHumanReadable, camelCaseToHumanReadable, check, clearKnownAbbreviations, commonObjectMetaSchema, componentArgumentSchema, componentInputSchema, componentModelSchema, componentSecretSchema, createInput, createNonProvidedInput, cuidv2d, defineComponent, defineEntity, defineUnit, entityModelSchema, fieldNameSchema, fileContentSchema, fileMetaSchema, fileSchema, genericNameSchema, getEntityId, getInstanceId, getOrCreate, getRuntimeInstances, globalCommonObjectMetaSchema, hubInputSchema, hubModelPatchSchema, hubModelSchema, inputKey, instanceIdSchema, instanceInputSchema, instanceModelPatchSchema, instanceModelSchema, instanceStatusFieldSchema, instanceStatusFieldValueSchema, isAssignableTo, isComponent, isEntity, isSecret, isUnitModel, objectMetaSchema, originalCreate, pageBlockSchema, parseArgumentValue, parseInstanceId, parseVersionedName, positionSchema, registerKnownAbbreviations, resetEvaluation, runtimeSchema, secretSchema, selectInput, serviceAccountMetaSchema, setValidationEnabled, stripNullish, terminalSpecSchema, text, timestampsSchema, triggerInvocationSchema, triggerSpecSchema, trimIndentation, unitArtifactId, unitArtifactSchema, unitConfigSchema, unitInputSourceSchema, unitInputValueSchema, unitModelSchema, unitPageSchema, unitSourceSchema, unitTerminalSchema, unitTriggerSchema, unitWorkerSchema, versionedNameSchema, workerRunOptionsSchema, yamlValueSchema };
1833
- //# sourceMappingURL=index.js.map
1834
- //# sourceMappingURL=index.js.map
1471
+ // src/index.ts
1472
+ import { z as z12 } from "zod";
1473
+ export {
1474
+ z12 as z,
1475
+ yamlValueSchema,
1476
+ workerRunOptionsSchema,
1477
+ versionedNameSchema,
1478
+ unitWorkerSchema,
1479
+ unitTriggerSchema,
1480
+ unitTerminalSchema,
1481
+ unitSourceSchema,
1482
+ unitPageSchema,
1483
+ unitModelSchema,
1484
+ unitInputValueSchema,
1485
+ unitInputSourceSchema,
1486
+ unitConfigSchema,
1487
+ unitArtifactSchema,
1488
+ unitArtifactId,
1489
+ trimIndentation,
1490
+ triggerSpecSchema,
1491
+ triggerInvocationSchema,
1492
+ timestampsSchema,
1493
+ text,
1494
+ terminalSpecSchema,
1495
+ stripNullish,
1496
+ setValidationEnabled,
1497
+ serviceAccountMetaSchema,
1498
+ selectInput,
1499
+ secretSchema,
1500
+ runtimeSchema,
1501
+ resetEvaluation,
1502
+ registerKnownAbbreviations,
1503
+ positionSchema,
1504
+ parseVersionedName,
1505
+ parseInstanceId,
1506
+ parseArgumentValue,
1507
+ pageBlockSchema,
1508
+ originalCreate,
1509
+ objectMetaSchema,
1510
+ kind,
1511
+ isUnitModel,
1512
+ isSecret,
1513
+ isEntity,
1514
+ isComponent,
1515
+ isAssignableTo,
1516
+ instanceStatusFieldValueSchema,
1517
+ instanceStatusFieldSchema,
1518
+ instanceModelSchema,
1519
+ instanceModelPatchSchema,
1520
+ instanceInputSchema,
1521
+ instanceIdSchema,
1522
+ inputKey,
1523
+ hubModelSchema,
1524
+ hubModelPatchSchema,
1525
+ hubInputSchema,
1526
+ globalCommonObjectMetaSchema,
1527
+ getRuntimeInstances,
1528
+ getOrCreate,
1529
+ getInstanceId,
1530
+ getEntityId,
1531
+ genericNameSchema,
1532
+ fileSchema,
1533
+ fileMetaSchema,
1534
+ fileContentSchema,
1535
+ fieldNameSchema,
1536
+ entityModelSchema,
1537
+ defineUnit,
1538
+ defineEntity,
1539
+ defineComponent,
1540
+ cuidv2d,
1541
+ createNonProvidedInput,
1542
+ createInput,
1543
+ componentSecretSchema,
1544
+ componentModelSchema,
1545
+ componentKindSchema,
1546
+ componentInputSchema,
1547
+ componentArgumentSchema,
1548
+ commonObjectMetaSchema,
1549
+ clearKnownAbbreviations,
1550
+ check,
1551
+ camelCaseToHumanReadable,
1552
+ bytesToHumanReadable,
1553
+ boundaryInput,
1554
+ WellKnownInstanceCustomStatus,
1555
+ InstanceNameConflictError,
1556
+ HighstateSignature,
1557
+ HighstateConfigKey,
1558
+ $secrets,
1559
+ $outputs,
1560
+ $inputs,
1561
+ $args,
1562
+ $addInputDescription,
1563
+ $addArgumentDescription
1564
+ };