@highstate/contract 0.16.0 → 0.17.0

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,4 +1,4 @@
1
- import z5, { z } from 'zod';
1
+ import { z } from 'zod';
2
2
  export { z } from 'zod';
3
3
  import { mapValues, pickBy, isNonNullish, uniqueBy } from 'remeda';
4
4
  import { parse } from 'yaml';
@@ -116,7 +116,10 @@ var timestampsSchema = z.object({
116
116
  */
117
117
  updatedAt: z.date()
118
118
  });
119
- var genericNameSchema = z.string().regex(/^[a-z][a-z0-9-_.]+$/).min(2).max(64);
119
+ var genericNameSchema = z.string().regex(
120
+ /^[a-z][a-z0-9-.]+$/,
121
+ "Name must start with a letter and can only contain lowercase letters, numbers, dashes (-) and dots (.)"
122
+ ).min(2).max(64);
120
123
  var versionedNameSchema = z.union([
121
124
  z.templateLiteral([genericNameSchema, z.literal("."), z.literal("v"), z.number().int().min(1)]),
122
125
  // to prevent TypeScript matching "proxmox.virtual-machine.v2" as
@@ -154,14 +157,49 @@ function parseVersionedName(name) {
154
157
  }
155
158
  return [baseName, version];
156
159
  }
157
- var fieldNameSchema = z.string().regex(/^[a-z][a-zA-Z0-9]+$/).min(2).max(64);
160
+ 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);
158
161
 
159
162
  // src/entity.ts
163
+ var entityInclusionSchema = z.object({
164
+ /**
165
+ * The static type of the included entity.
166
+ */
167
+ type: versionedNameSchema,
168
+ /**
169
+ * Whether the included entity is required.
170
+ * If false, the entity may be omitted.
171
+ */
172
+ required: z.boolean(),
173
+ /**
174
+ * Whether the included entity is multiple.
175
+ */
176
+ multiple: z.boolean(),
177
+ /**
178
+ * The name of the field where the included entity is embedded.
179
+ */
180
+ field: z.string()
181
+ });
160
182
  var entityModelSchema = z.object({
161
183
  /**
162
184
  * The static type of the entity.
163
185
  */
164
186
  type: versionedNameSchema,
187
+ /**
188
+ * The list of all extended entity types (direct and indirect).
189
+ */
190
+ extensions: z.string().array().optional(),
191
+ /**
192
+ * The list of directly extended entity types.
193
+ */
194
+ directExtensions: z.string().array().optional(),
195
+ /**
196
+ * The list of all included entities (directly or inherited from extensions).
197
+ */
198
+ inclusions: entityInclusionSchema.array().optional(),
199
+ /**
200
+ * The list of directly included entities.
201
+ */
202
+ directInclusions: entityInclusionSchema.array().optional(),
165
203
  /**
166
204
  * The JSON schema of the entity value.
167
205
  */
@@ -181,6 +219,9 @@ var entityModelSchema = z.object({
181
219
  */
182
220
  definitionHash: z.number()
183
221
  });
222
+ function isEntityIncludeRef(value) {
223
+ return typeof value === "object" && value !== null && "entity" in value;
224
+ }
184
225
  function defineEntity(options) {
185
226
  try {
186
227
  entityModelSchema.shape.type.parse(options.type);
@@ -190,13 +231,78 @@ function defineEntity(options) {
190
231
  if (!options.schema) {
191
232
  throw new Error("Entity schema is required");
192
233
  }
234
+ const includedEntities = Object.entries(options.includes ?? {}).map(([field, entityRef]) => {
235
+ if (isEntityIncludeRef(entityRef)) {
236
+ return {
237
+ entity: entityRef.entity,
238
+ inclusion: {
239
+ type: entityRef.entity.type,
240
+ required: entityRef.required ?? true,
241
+ multiple: entityRef.multiple ?? false,
242
+ field
243
+ }
244
+ };
245
+ }
246
+ return {
247
+ entity: entityRef,
248
+ inclusion: {
249
+ type: entityRef.type,
250
+ required: true,
251
+ multiple: false,
252
+ field
253
+ }
254
+ };
255
+ });
256
+ const inclusionShape = includedEntities.reduce(
257
+ (shape, { entity, inclusion }) => {
258
+ if (inclusion.multiple) {
259
+ shape[inclusion.field] = inclusion.required ? entity.schema.array() : entity.schema.array().optional();
260
+ } else {
261
+ shape[inclusion.field] = inclusion.required ? entity.schema : entity.schema.optional();
262
+ }
263
+ return shape;
264
+ },
265
+ {}
266
+ );
267
+ let finalSchema = Object.values(options.extends ?? {}).reduce(
268
+ (schema, entity) => z.intersection(schema, entity.schema),
269
+ options.schema
270
+ );
271
+ if (includedEntities.length > 0) {
272
+ finalSchema = z.intersection(finalSchema, z.object(inclusionShape));
273
+ }
274
+ const directInclusions = includedEntities.map(({ inclusion }) => inclusion);
275
+ const directExtensions = Object.values(options.extends ?? {}).map((entity) => entity.type);
276
+ const inclusions = Object.values(options.extends ?? {}).reduce(
277
+ (incs, entity) => {
278
+ if (entity.model.inclusions) {
279
+ incs.push(...entity.model.inclusions);
280
+ }
281
+ return incs;
282
+ },
283
+ [...directInclusions]
284
+ );
285
+ const extensions = Object.values(options.extends ?? {}).reduce((exts, entity) => {
286
+ exts.push(...entity.model.extensions ?? [], entity.type);
287
+ return exts;
288
+ }, []);
193
289
  try {
290
+ let _schema;
194
291
  return {
195
292
  type: options.type,
196
- schema: options.schema,
293
+ schema: finalSchema,
197
294
  model: {
198
295
  type: options.type,
199
- schema: z.toJSONSchema(options.schema, { target: "draft-7" }),
296
+ extensions: extensions.length > 0 ? extensions : void 0,
297
+ directExtensions: directExtensions.length > 0 ? directExtensions : void 0,
298
+ inclusions: inclusions.length > 0 ? inclusions : void 0,
299
+ directInclusions: directInclusions.length > 0 ? directInclusions : void 0,
300
+ get schema() {
301
+ if (!_schema) {
302
+ _schema = z.toJSONSchema(finalSchema, { target: "draft-7", unrepresentable: "any" });
303
+ }
304
+ return _schema;
305
+ },
200
306
  meta: {
201
307
  ...options.meta,
202
308
  title: options.meta?.title || camelCaseToHumanReadable(parseVersionedName(options.type)[0])
@@ -204,6 +310,7 @@ function defineEntity(options) {
204
310
  // will be calculated by the library loader
205
311
  definitionHash: null
206
312
  }
313
+ // biome-ignore lint/suspicious/noExplicitAny: we already typed return type
207
314
  };
208
315
  } catch (error) {
209
316
  throw new Error(`Failed to define entity "${options.type}"`, { cause: error });
@@ -212,6 +319,15 @@ function defineEntity(options) {
212
319
  function isEntity(value) {
213
320
  return typeof value === "object" && value !== null && "model" in value;
214
321
  }
322
+ function isAssignableTo(entity, target) {
323
+ if (entity.type === target) {
324
+ return true;
325
+ }
326
+ if (entity.extensions?.includes(target)) {
327
+ return true;
328
+ }
329
+ return entity.inclusions?.some((implementation) => implementation.type === target) ?? false;
330
+ }
215
331
  var boundaryInput = Symbol("boundaryInput");
216
332
  var boundaryInputs = Symbol("boundaryInputs");
217
333
  function formatInstancePath(instance) {
@@ -522,7 +638,11 @@ function isSchemaOptional(schema) {
522
638
  function mapArgument(value, key) {
523
639
  if ("schema" in value) {
524
640
  return {
525
- schema: z.toJSONSchema(value.schema, { target: "draft-7", io: "input" }),
641
+ schema: z.toJSONSchema(value.schema, {
642
+ target: "draft-7",
643
+ io: "input",
644
+ unrepresentable: "any"
645
+ }),
526
646
  [runtimeSchema]: value.schema,
527
647
  required: !isSchemaOptional(value.schema),
528
648
  meta: {
@@ -532,7 +652,7 @@ function mapArgument(value, key) {
532
652
  };
533
653
  }
534
654
  return {
535
- schema: z.toJSONSchema(value, { target: "draft-7", io: "input" }),
655
+ schema: z.toJSONSchema(value, { target: "draft-7", io: "input", unrepresentable: "any" }),
536
656
  [runtimeSchema]: value,
537
657
  required: !isSchemaOptional(value),
538
658
  meta: {
@@ -778,12 +898,23 @@ function findRequiredInputs(inputs, names) {
778
898
  var HighstateSignature = /* @__PURE__ */ ((HighstateSignature2) => {
779
899
  HighstateSignature2["Artifact"] = "d55c63ac-3174-4756-808f-f778e99af0d1";
780
900
  HighstateSignature2["Yaml"] = "c857cac5-caa6-4421-b82c-e561fbce6367";
901
+ HighstateSignature2["Id"] = "348d020e-0d9e-4ae7-9415-b91af99f5339";
902
+ HighstateSignature2["Ref"] = "6d7f9da0-9cb6-496d-b72e-cf85ee4d9cf8";
781
903
  return HighstateSignature2;
782
904
  })(HighstateSignature || {});
783
905
  var yamlValueSchema = z.object({
784
906
  ["c857cac5-caa6-4421-b82c-e561fbce6367" /* Yaml */]: z.literal(true),
785
907
  value: z.string()
786
908
  });
909
+ var objectWithIdSchema = z.object({
910
+ ["348d020e-0d9e-4ae7-9415-b91af99f5339" /* Id */]: z.literal(true),
911
+ id: z.number(),
912
+ value: z.unknown()
913
+ });
914
+ var objectRefSchema = z.object({
915
+ ["6d7f9da0-9cb6-496d-b72e-cf85ee4d9cf8" /* Ref */]: z.literal(true),
916
+ id: z.number()
917
+ });
787
918
  var fileMetaSchema = z.object({
788
919
  name: z.string(),
789
920
  contentType: z.string().optional(),
@@ -819,27 +950,27 @@ var componentSecretSchema = componentArgumentSchema.extend({
819
950
  /**
820
951
  * The secret cannot be modified by the user, but can be modified by the unit.
821
952
  */
822
- readonly: z5.boolean(),
953
+ readonly: z.boolean(),
823
954
  /**
824
955
  * The secret value is computed by the unit and should not be passed to it when invoked.
825
956
  */
826
- computed: z5.boolean()
957
+ computed: z.boolean()
827
958
  });
828
- var unitSourceSchema = z5.object({
959
+ var unitSourceSchema = z.object({
829
960
  /**
830
961
  * The package where the unit implementation is located.
831
962
  *
832
963
  * May be both: local monorepo package or a remote NPM package.
833
964
  */
834
- package: z5.string(),
965
+ package: z.string(),
835
966
  /**
836
967
  * The path to the unit implementation within the package.
837
968
  *
838
969
  * If not provided, the root of the package is assumed.
839
970
  */
840
- path: z5.string().optional()
971
+ path: z.string().optional()
841
972
  });
842
- var unitModelSchema = z5.object({
973
+ var unitModelSchema = z.object({
843
974
  ...componentModelSchema.shape,
844
975
  /**
845
976
  * The source of the unit.
@@ -848,7 +979,7 @@ var unitModelSchema = z5.object({
848
979
  /**
849
980
  * The record of the secret specs.
850
981
  */
851
- secrets: z5.record(z5.string(), componentSecretSchema)
982
+ secrets: z.record(z.string(), componentSecretSchema)
852
983
  });
853
984
  function defineUnit(options) {
854
985
  if (!options.source) {
@@ -878,8 +1009,8 @@ function defineUnit(options) {
878
1009
  }
879
1010
  return component;
880
1011
  }
881
- function $secrets(secrets2) {
882
- return toFullComponentArgumentOptions(secrets2);
1012
+ function $secrets(secrets) {
1013
+ return toFullComponentArgumentOptions(secrets);
883
1014
  }
884
1015
  function mapSecret(value, key) {
885
1016
  if ("schema" in value) {
@@ -927,6 +1058,13 @@ var triggerInvocationSchema = z.object({
927
1058
  });
928
1059
 
929
1060
  // src/pulumi.ts
1061
+ var unitInputReference = z.object({
1062
+ ...instanceInputSchema.shape,
1063
+ /**
1064
+ * The resolved inclusion needed to extract the input value.
1065
+ */
1066
+ inclusion: entityInclusionSchema.optional()
1067
+ });
930
1068
  var unitConfigSchema = z.object({
931
1069
  /**
932
1070
  * The ID of the instance.
@@ -939,7 +1077,7 @@ var unitConfigSchema = z.object({
939
1077
  /**
940
1078
  * The record of input references for the unit.
941
1079
  */
942
- inputs: z.record(z.string(), instanceInputSchema.array()),
1080
+ inputs: z.record(z.string(), unitInputReference.array()),
943
1081
  /**
944
1082
  * The list of triggers that have been invoked for this unit.
945
1083
  */
@@ -1098,6 +1236,301 @@ var workerRunOptionsSchema = z.object({
1098
1236
  */
1099
1237
  apiKey: z.string()
1100
1238
  });
1239
+ function compact(value) {
1240
+ const counts = /* @__PURE__ */ new WeakMap();
1241
+ const cyclic = /* @__PURE__ */ new WeakSet();
1242
+ const expanded = /* @__PURE__ */ new WeakSet();
1243
+ const inStack = /* @__PURE__ */ new WeakSet();
1244
+ const stack = [];
1245
+ function countIdentities(current) {
1246
+ if (current === null || typeof current !== "object") {
1247
+ return;
1248
+ }
1249
+ counts.set(current, (counts.get(current) ?? 0) + 1);
1250
+ if (inStack.has(current)) {
1251
+ cyclic.add(current);
1252
+ for (const entry of stack) {
1253
+ cyclic.add(entry);
1254
+ }
1255
+ return;
1256
+ }
1257
+ if (expanded.has(current)) {
1258
+ return;
1259
+ }
1260
+ expanded.add(current);
1261
+ inStack.add(current);
1262
+ stack.push(current);
1263
+ if (Array.isArray(current)) {
1264
+ try {
1265
+ for (const item of current) {
1266
+ countIdentities(item);
1267
+ }
1268
+ return;
1269
+ } finally {
1270
+ stack.pop();
1271
+ inStack.delete(current);
1272
+ }
1273
+ }
1274
+ try {
1275
+ for (const entryValue of Object.values(current)) {
1276
+ countIdentities(entryValue);
1277
+ }
1278
+ } finally {
1279
+ stack.pop();
1280
+ inStack.delete(current);
1281
+ }
1282
+ }
1283
+ countIdentities(value);
1284
+ const ids = /* @__PURE__ */ new WeakMap();
1285
+ const definitionSites = /* @__PURE__ */ new WeakMap();
1286
+ let nextId = 1;
1287
+ function ensureId(current) {
1288
+ const existing = ids.get(current);
1289
+ if (existing !== void 0) {
1290
+ return existing;
1291
+ }
1292
+ const allocated = nextId;
1293
+ nextId += 1;
1294
+ ids.set(current, allocated);
1295
+ return allocated;
1296
+ }
1297
+ function assignDefinitionSitesBfs(root) {
1298
+ if (root === null || typeof root !== "object") {
1299
+ return;
1300
+ }
1301
+ const queue = [];
1302
+ const expandedQueue = /* @__PURE__ */ new WeakSet();
1303
+ if (Array.isArray(root)) {
1304
+ for (let index = 0; index < root.length; index += 1) {
1305
+ queue.push({ parent: root, key: index, value: root[index] });
1306
+ }
1307
+ } else {
1308
+ for (const [key, entryValue] of Object.entries(root)) {
1309
+ queue.push({ parent: root, key, value: entryValue });
1310
+ }
1311
+ }
1312
+ while (queue.length > 0) {
1313
+ const current = queue.shift();
1314
+ if (current === void 0) {
1315
+ continue;
1316
+ }
1317
+ if (current.value === null || typeof current.value !== "object") {
1318
+ continue;
1319
+ }
1320
+ const occurrences = counts.get(current.value) ?? 0;
1321
+ if (occurrences > 1 && definitionSites.get(current.value) === void 0) {
1322
+ definitionSites.set(current.value, { parent: current.parent, key: current.key });
1323
+ ensureId(current.value);
1324
+ }
1325
+ if (expandedQueue.has(current.value)) {
1326
+ continue;
1327
+ }
1328
+ expandedQueue.add(current.value);
1329
+ if (Array.isArray(current.value)) {
1330
+ for (let index = 0; index < current.value.length; index += 1) {
1331
+ queue.push({ parent: current.value, key: index, value: current.value[index] });
1332
+ }
1333
+ continue;
1334
+ }
1335
+ for (const [key, entryValue] of Object.entries(current.value)) {
1336
+ queue.push({ parent: current.value, key, value: entryValue });
1337
+ }
1338
+ }
1339
+ }
1340
+ assignDefinitionSitesBfs(value);
1341
+ const emitted = /* @__PURE__ */ new WeakSet();
1342
+ function buildTreeChildren(current, rootOfIdValue) {
1343
+ if (Array.isArray(current)) {
1344
+ return current.map((item) => buildTree(item, rootOfIdValue));
1345
+ }
1346
+ return mapValues(current, (entryValue) => buildTree(entryValue, rootOfIdValue));
1347
+ }
1348
+ function buildTree(current, rootOfIdValue) {
1349
+ if (current === null || typeof current !== "object") {
1350
+ return current;
1351
+ }
1352
+ if (rootOfIdValue !== void 0 && emitted.has(current)) {
1353
+ const id = ids.get(current);
1354
+ if (id === void 0) {
1355
+ throw new Error("Compaction invariant violation: missing id for repeated object");
1356
+ }
1357
+ return {
1358
+ ["6d7f9da0-9cb6-496d-b72e-cf85ee4d9cf8" /* Ref */]: true,
1359
+ id
1360
+ };
1361
+ }
1362
+ if (rootOfIdValue !== void 0 && cyclic.has(current) && !emitted.has(current)) {
1363
+ const id = ensureId(current);
1364
+ emitted.add(current);
1365
+ return {
1366
+ ["348d020e-0d9e-4ae7-9415-b91af99f5339" /* Id */]: true,
1367
+ id,
1368
+ value: buildTreeChildren(current, current)
1369
+ };
1370
+ }
1371
+ return buildTreeChildren(current, rootOfIdValue);
1372
+ }
1373
+ function buildAt(parent, key, current) {
1374
+ if (current === null || typeof current !== "object") {
1375
+ return current;
1376
+ }
1377
+ const occurrences = counts.get(current) ?? 0;
1378
+ if (occurrences <= 1) {
1379
+ if (Array.isArray(current)) {
1380
+ return current.map((item, index) => buildAt(current, index, item));
1381
+ }
1382
+ return mapValues(current, (entryValue, entryKey) => buildAt(current, entryKey, entryValue));
1383
+ }
1384
+ const site = definitionSites.get(current);
1385
+ const shouldDefineHere = site?.parent === parent && site.key === key;
1386
+ const id = ids.get(current);
1387
+ if (id === void 0) {
1388
+ throw new Error("Compaction invariant violation: missing id for repeated object");
1389
+ }
1390
+ if (!shouldDefineHere || emitted.has(current)) {
1391
+ return {
1392
+ ["6d7f9da0-9cb6-496d-b72e-cf85ee4d9cf8" /* Ref */]: true,
1393
+ id
1394
+ };
1395
+ }
1396
+ emitted.add(current);
1397
+ return {
1398
+ ["348d020e-0d9e-4ae7-9415-b91af99f5339" /* Id */]: true,
1399
+ id,
1400
+ value: buildTreeChildren(current, current)
1401
+ };
1402
+ }
1403
+ if (value === null || typeof value !== "object") {
1404
+ return value;
1405
+ }
1406
+ const topLevelOccurrences = counts.get(value) ?? 0;
1407
+ if (topLevelOccurrences > 1) {
1408
+ const id = ensureId(value);
1409
+ emitted.add(value);
1410
+ return {
1411
+ ["348d020e-0d9e-4ae7-9415-b91af99f5339" /* Id */]: true,
1412
+ id,
1413
+ value: buildTreeChildren(value, value)
1414
+ };
1415
+ }
1416
+ if (Array.isArray(value)) {
1417
+ return value.map((item, index) => buildAt(value, index, item));
1418
+ }
1419
+ return mapValues(
1420
+ value,
1421
+ (entryValue, entryKey) => buildAt(value, entryKey, entryValue)
1422
+ );
1423
+ }
1424
+ function decompact(value) {
1425
+ const rawValuesById = /* @__PURE__ */ new Map();
1426
+ const placeholdersById = /* @__PURE__ */ new Map();
1427
+ function collect(current, visited) {
1428
+ const result = objectWithIdSchema.safeParse(current);
1429
+ if (result.success) {
1430
+ const { id } = result.data;
1431
+ if (rawValuesById.has(id)) {
1432
+ throw new Error(`Duplicate compacted id ${id}`);
1433
+ }
1434
+ rawValuesById.set(id, result.data.value);
1435
+ collect(result.data.value, visited);
1436
+ return;
1437
+ }
1438
+ if (current === null || current === void 0 || typeof current !== "object") {
1439
+ return;
1440
+ }
1441
+ if (visited.has(current)) {
1442
+ return;
1443
+ }
1444
+ visited.add(current);
1445
+ if (Array.isArray(current)) {
1446
+ for (const item of current) {
1447
+ collect(item, visited);
1448
+ }
1449
+ return;
1450
+ }
1451
+ for (const entryValue of Object.values(current)) {
1452
+ collect(entryValue, visited);
1453
+ }
1454
+ }
1455
+ function ensurePlaceholder(id) {
1456
+ const existing = placeholdersById.get(id);
1457
+ if (existing !== void 0) {
1458
+ return existing;
1459
+ }
1460
+ const raw = rawValuesById.get(id);
1461
+ if (raw === void 0) {
1462
+ throw new Error(`Unresolved compacted ref id ${id}`);
1463
+ }
1464
+ let placeholder;
1465
+ if (raw !== null && typeof raw === "object") {
1466
+ placeholder = Array.isArray(raw) ? [] : {};
1467
+ } else {
1468
+ placeholder = raw;
1469
+ }
1470
+ placeholdersById.set(id, placeholder);
1471
+ return placeholder;
1472
+ }
1473
+ function resolve(current) {
1474
+ const refResult = objectRefSchema.safeParse(current);
1475
+ if (refResult.success) {
1476
+ return ensurePlaceholder(refResult.data.id);
1477
+ }
1478
+ const withIdResult = objectWithIdSchema.safeParse(current);
1479
+ if (withIdResult.success) {
1480
+ return ensurePlaceholder(withIdResult.data.id);
1481
+ }
1482
+ if (current === null || current === void 0 || typeof current !== "object") {
1483
+ return current;
1484
+ }
1485
+ if (Array.isArray(current)) {
1486
+ return current.map((item) => resolve(item));
1487
+ }
1488
+ return mapValues(current, (entryValue) => resolve(entryValue));
1489
+ }
1490
+ function fillPlaceholder(id, visitedIds2) {
1491
+ if (visitedIds2.has(id)) {
1492
+ return;
1493
+ }
1494
+ visitedIds2.add(id);
1495
+ const raw = rawValuesById.get(id);
1496
+ if (raw === void 0) {
1497
+ throw new Error(`Unresolved compacted ref id ${id}`);
1498
+ }
1499
+ const placeholder = ensurePlaceholder(id);
1500
+ if (placeholder === null || typeof placeholder !== "object") {
1501
+ return;
1502
+ }
1503
+ if (raw === null || typeof raw !== "object") {
1504
+ throw new Error(`Compaction invariant violation: id ${id} points to non-object value`);
1505
+ }
1506
+ const resolved = resolve(raw);
1507
+ if (Array.isArray(placeholder)) {
1508
+ if (!Array.isArray(resolved)) {
1509
+ throw new Error(`Compaction invariant violation: id ${id} array placeholder mismatch`);
1510
+ }
1511
+ placeholder.length = 0;
1512
+ for (const item of resolved) {
1513
+ placeholder.push(item);
1514
+ }
1515
+ return;
1516
+ }
1517
+ if (Array.isArray(resolved) || resolved === null || typeof resolved !== "object") {
1518
+ throw new Error(`Compaction invariant violation: id ${id} object placeholder mismatch`);
1519
+ }
1520
+ for (const [key, entryValue] of Object.entries(resolved)) {
1521
+ placeholder[key] = entryValue;
1522
+ }
1523
+ }
1524
+ collect(value, /* @__PURE__ */ new WeakSet());
1525
+ for (const id of rawValuesById.keys()) {
1526
+ ensurePlaceholder(id);
1527
+ }
1528
+ const visitedIds = /* @__PURE__ */ new Set();
1529
+ for (const id of rawValuesById.keys()) {
1530
+ fillPlaceholder(id, visitedIds);
1531
+ }
1532
+ return resolve(value);
1533
+ }
1101
1534
  function text(strings, ...values) {
1102
1535
  const stringValues = values.map(String);
1103
1536
  let result = "";
@@ -1140,6 +1573,6 @@ function stripNullish(obj) {
1140
1573
  return pickBy(obj, isNonNullish);
1141
1574
  }
1142
1575
 
1143
- export { $addArgumentDescription, $addInputDescription, $args, $inputs, $outputs, $secrets, HighstateConfigKey, HighstateSignature, InstanceNameConflictError, WellKnownInstanceCustomStatus, bytesToHumanReadable, camelCaseToHumanReadable, check, clearKnownAbbreviations, commonObjectMetaSchema, componentArgumentSchema, componentInputSchema, componentModelSchema, componentSecretSchema, defineComponent, defineEntity, defineUnit, entityModelSchema, fieldNameSchema, fileContentSchema, fileMetaSchema, fileSchema, findInput, findInputs, findRequiredInput, findRequiredInputs, genericNameSchema, getInstanceId, getOrCreate, getRuntimeInstances, globalCommonObjectMetaSchema, hubInputSchema, hubModelPatchSchema, hubModelSchema, inputKey, instanceIdSchema, instanceInputSchema, instanceModelPatchSchema, instanceModelSchema, instanceStatusFieldSchema, instanceStatusFieldValueSchema, isComponent, isEntity, isUnitModel, objectMetaSchema, originalCreate, pageBlockSchema, parseArgumentValue, parseInstanceId, parseVersionedName, positionSchema, registerKnownAbbreviations, resetEvaluation, runtimeSchema, serviceAccountMetaSchema, setValidationEnabled, stripNullish, terminalSpecSchema, text, timestampsSchema, triggerInvocationSchema, triggerSpecSchema, trimIndentation, unitArtifactId, unitArtifactSchema, unitConfigSchema, unitModelSchema, unitPageSchema, unitSourceSchema, unitTerminalSchema, unitTriggerSchema, unitWorkerSchema, versionedNameSchema, workerRunOptionsSchema, yamlValueSchema };
1576
+ export { $addArgumentDescription, $addInputDescription, $args, $inputs, $outputs, $secrets, HighstateConfigKey, HighstateSignature, InstanceNameConflictError, WellKnownInstanceCustomStatus, bytesToHumanReadable, camelCaseToHumanReadable, check, clearKnownAbbreviations, commonObjectMetaSchema, compact, componentArgumentSchema, componentInputSchema, componentModelSchema, componentSecretSchema, decompact, defineComponent, defineEntity, defineUnit, entityModelSchema, fieldNameSchema, fileContentSchema, fileMetaSchema, fileSchema, findInput, findInputs, findRequiredInput, findRequiredInputs, genericNameSchema, getInstanceId, getOrCreate, getRuntimeInstances, globalCommonObjectMetaSchema, hubInputSchema, hubModelPatchSchema, hubModelSchema, inputKey, instanceIdSchema, instanceInputSchema, instanceModelPatchSchema, instanceModelSchema, instanceStatusFieldSchema, instanceStatusFieldValueSchema, isAssignableTo, isComponent, isEntity, isUnitModel, objectMetaSchema, objectRefSchema, objectWithIdSchema, originalCreate, pageBlockSchema, parseArgumentValue, parseInstanceId, parseVersionedName, positionSchema, registerKnownAbbreviations, resetEvaluation, runtimeSchema, serviceAccountMetaSchema, setValidationEnabled, stripNullish, terminalSpecSchema, text, timestampsSchema, triggerInvocationSchema, triggerSpecSchema, trimIndentation, unitArtifactId, unitArtifactSchema, unitConfigSchema, unitInputReference, unitModelSchema, unitPageSchema, unitSourceSchema, unitTerminalSchema, unitTriggerSchema, unitWorkerSchema, versionedNameSchema, workerRunOptionsSchema, yamlValueSchema };
1144
1577
  //# sourceMappingURL=index.js.map
1145
1578
  //# sourceMappingURL=index.js.map