@blue-labs/repository-generator 4.1.1 → 5.0.0-rc.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.
@@ -1,14 +1,33 @@
1
- import * as D from "path";
2
- import k from "path";
1
+ import * as j from "path";
2
+ import $ from "path";
3
3
  import A from "fs";
4
- import { Properties as G, yamlBlueParse as q, MergingProcessors as B, Blue as j, createNodeProvider as H, BlueNode as X, BlueIdCalculator as Z } from "@blue-labs/language";
5
- import { OBJECT_CONTRACTS as Q, RESERVED_ATTRIBUTES_POINTER_SEGMENTS as ee, validateAttributesAddedPointer as te, parsePointer as ne, OBJECT_SCHEMA as T, validateStableDoesNotDependOnDev as re } from "@blue-labs/repository-contract";
6
- import oe from "fast-json-patch";
7
- import se from "js-yaml";
8
- const V = /* @__PURE__ */ new Set([...G.CORE_TYPES]), x = G.CORE_TYPE_NAME_TO_BLUE_ID_MAP, O = "Blue Repository", m = {
4
+ import { BUILTIN_RUNTIME_TYPE_NAME_TO_BLUE_ID_MAP as Q, Properties as G, yamlBlueParse as W, MergingProcessors as v, canonicalizeRepositoryContent as ee, BUILTIN_RUNTIME_TYPE_CONTENT_BY_BLUE_ID as te, Blue as U, createNodeProvider as ne, BlueNode as re, NodeProviderWrapper as oe, BlueIdCalculator as q } from "@blue-labs/language";
5
+ import { OBJECT_CONTRACTS as se, RESERVED_ATTRIBUTES_POINTER_SEGMENTS as ie, validateAttributesAddedPointer as ae, parsePointer as ce, OBJECT_SCHEMA as k, validateStableDoesNotDependOnDev as ue } from "@blue-labs/repository-contract";
6
+ import fe from "fast-json-patch";
7
+ import le from "js-yaml";
8
+ const T = {
9
+ ...G.CORE_TYPE_NAME_TO_BLUE_ID_MAP,
10
+ ...Q
11
+ }, O = new Set(Object.keys(T)), de = /* @__PURE__ */ new Set([
12
+ ...G.BASIC_TYPES
13
+ ]), pe = /* @__PURE__ */ new Set([
14
+ "name",
15
+ "description",
16
+ "type",
17
+ "itemType",
18
+ "keyType",
19
+ "valueType",
20
+ "value",
21
+ "items",
22
+ "blueId",
23
+ "blue",
24
+ "schema",
25
+ "mergePolicy",
26
+ "contracts"
27
+ ]), x = "Blue Repository", m = {
9
28
  Dev: "dev",
10
29
  Stable: "stable"
11
- }, ie = /* @__PURE__ */ new Set([
30
+ }, ye = /* @__PURE__ */ new Set([
12
31
  ".git",
13
32
  ".github",
14
33
  ".husky",
@@ -17,81 +36,100 @@ const V = /* @__PURE__ */ new Set([...G.CORE_TYPES]), x = G.CORE_TYPE_NAME_TO_BL
17
36
  ".vscode",
18
37
  ".idea"
19
38
  ]);
20
- function ae(e) {
39
+ function ge(e) {
21
40
  const r = A.readdirSync(e, { withFileTypes: !0 }), n = /* @__PURE__ */ new Map();
22
41
  for (const t of r) {
23
- if (!t.isDirectory() || ie.has(t.name))
42
+ if (!t.isDirectory() || ye.has(t.name))
24
43
  continue;
25
- const o = k.join(e, t.name), s = W(o);
44
+ const o = $.join(e, t.name), s = J(o);
26
45
  if (s.length !== 0)
27
- for (const a of s) {
28
- const c = a.endsWith(".dev.blue") ? m.Dev : m.Stable, i = ce(a), f = ue(i, a), u = `${t.name}/${f}`, l = n.get(u);
46
+ for (const i of s) {
47
+ const c = i.endsWith(".dev.blue") ? m.Dev : m.Stable, a = me(i), f = he(a, i), u = `${t.name}/${f}`, l = n.get(u);
29
48
  if (l)
30
49
  throw l.status !== c ? new Error(
31
- `Type ${u} has both stable and dev definitions (${l.filePath} and ${a}).`
50
+ `Type ${u} has both stable and dev definitions (${l.filePath} and ${i}).`
32
51
  ) : new Error(
33
- `Type ${u} is defined multiple times (${l.filePath} and ${a}).`
52
+ `Type ${u} is defined multiple times (${l.filePath} and ${i}).`
34
53
  );
35
- const y = fe(i, a);
54
+ const y = we(a, i);
36
55
  n.set(u, {
37
56
  packageName: t.name,
38
57
  typeName: f,
39
58
  status: c,
40
- content: i,
41
- filePath: a,
59
+ content: a,
60
+ filePath: i,
42
61
  references: y
43
62
  });
44
63
  }
45
64
  }
46
65
  return n;
47
66
  }
48
- function ce(e) {
49
- const r = A.readFileSync(e, "utf8"), n = q(r);
50
- if (!C(n))
67
+ function me(e) {
68
+ const r = A.readFileSync(e, "utf8"), n = W(r);
69
+ if (!P(n))
51
70
  throw new Error(`Type file ${e} must contain a YAML object.`);
52
- return n;
71
+ return Ie(n), n;
53
72
  }
54
- function ue(e, r) {
55
- if (!C(e) || typeof e.name != "string")
73
+ function he(e, r) {
74
+ if (!P(e) || typeof e.name != "string")
56
75
  throw new Error(`Type file ${r} is missing required "name" field.`);
57
76
  return e.name;
58
77
  }
59
- function W(e) {
78
+ function J(e) {
60
79
  const r = A.readdirSync(e, { withFileTypes: !0 }), n = [];
61
80
  for (const t of r) {
62
81
  if (t.isDirectory()) {
63
- n.push(...W(k.join(e, t.name)));
82
+ n.push(...J($.join(e, t.name)));
64
83
  continue;
65
84
  }
66
- (t.name.endsWith(".blue") || t.name.endsWith(".dev.blue")) && n.push(k.join(e, t.name));
85
+ (t.name.endsWith(".blue") || t.name.endsWith(".dev.blue")) && n.push($.join(e, t.name));
67
86
  }
68
87
  return n;
69
88
  }
70
- function fe(e, r) {
89
+ function we(e, r) {
71
90
  const n = /* @__PURE__ */ new Set(), t = (o) => {
72
91
  if (Array.isArray(o)) {
73
- o.forEach((a) => t(a));
92
+ o.forEach((i) => t(i));
74
93
  return;
75
94
  }
76
- if (!C(o))
95
+ if (!P(o))
77
96
  return;
78
- const s = (a) => {
79
- if (typeof a == "string" && !V.has(a)) {
80
- if (!a.includes("/"))
97
+ const s = (i) => {
98
+ if (typeof i == "string" && !O.has(i)) {
99
+ if (!i.includes("/"))
81
100
  throw new Error(
82
- `Invalid type reference "${a}" in ${r}. Use <Package>/<Type> for non-primitive references.`
101
+ `Invalid type reference "${i}" in ${r}. Use <Package>/<Type> for non-primitive references.`
83
102
  );
84
- n.add(a);
103
+ n.add(i);
85
104
  }
86
105
  };
87
- s(o.type), s(o.itemType), s(o.keyType), s(o.valueType), Object.values(o).forEach((a) => t(a));
106
+ s(o.type), s(o.itemType), s(o.keyType), s(o.valueType), Object.values(o).forEach((i) => t(i));
88
107
  };
89
108
  return t(e), n;
90
109
  }
91
- function C(e) {
110
+ function Ie(e) {
111
+ const r = (n) => {
112
+ if (Array.isArray(n)) {
113
+ n.forEach((t) => r(t));
114
+ return;
115
+ }
116
+ if (P(n)) {
117
+ if (typeof n.type == "string" && de.has(n.type)) {
118
+ const t = Object.keys(n).find(
119
+ (o) => !pe.has(o)
120
+ );
121
+ if (t !== void 0)
122
+ throw new Error(`"${t}" is not an allowed fields here`);
123
+ }
124
+ Object.entries(n).filter(([t]) => t !== "schema").forEach(([, t]) => r(t));
125
+ }
126
+ };
127
+ r(e);
128
+ }
129
+ function P(e) {
92
130
  return typeof e == "object" && e !== null && !Array.isArray(e);
93
131
  }
94
- function le(e) {
132
+ function be(e) {
95
133
  const r = /* @__PURE__ */ new Map();
96
134
  for (const [n, t] of e) {
97
135
  const o = /* @__PURE__ */ new Set();
@@ -106,81 +144,81 @@ function le(e) {
106
144
  }
107
145
  return r;
108
146
  }
109
- function de(e) {
147
+ function ve(e) {
110
148
  const r = [], n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = [], s = /* @__PURE__ */ new Set();
111
- let a = 0;
112
- const c = (i) => {
113
- n.set(i, a), t.set(i, a), a += 1, o.push(i), s.add(i);
114
- for (const u of e.get(i) ?? []) {
149
+ let i = 0;
150
+ const c = (a) => {
151
+ n.set(a, i), t.set(a, i), i += 1, o.push(a), s.add(a);
152
+ for (const u of e.get(a) ?? []) {
115
153
  if (!n.has(u)) {
116
154
  c(u), t.set(
117
- i,
155
+ a,
118
156
  Math.min(
119
- t.get(i) ?? 0,
157
+ t.get(a) ?? 0,
120
158
  t.get(u) ?? 0
121
159
  )
122
160
  );
123
161
  continue;
124
162
  }
125
163
  s.has(u) && t.set(
126
- i,
127
- Math.min(t.get(i) ?? 0, n.get(u) ?? 0)
164
+ a,
165
+ Math.min(t.get(a) ?? 0, n.get(u) ?? 0)
128
166
  );
129
167
  }
130
- if (t.get(i) !== n.get(i))
168
+ if (t.get(a) !== n.get(a))
131
169
  return;
132
170
  const f = [];
133
171
  for (; o.length > 0; ) {
134
172
  const u = o.pop();
135
- if (!u || (s.delete(u), f.push(u), u === i))
173
+ if (!u || (s.delete(u), f.push(u), u === a))
136
174
  break;
137
175
  }
138
176
  r.push(f.sort((u, l) => u.localeCompare(l)));
139
177
  };
140
- for (const i of e.keys())
141
- n.has(i) || c(i);
178
+ for (const a of e.keys())
179
+ n.has(a) || c(a);
142
180
  return r;
143
181
  }
144
- function pe(e) {
145
- const r = de(e), n = /* @__PURE__ */ new Map();
146
- r.forEach((c, i) => {
147
- c.forEach((f) => n.set(f, i));
182
+ function Ee(e) {
183
+ const r = ve(e), n = /* @__PURE__ */ new Map();
184
+ r.forEach((c, a) => {
185
+ c.forEach((f) => n.set(f, a));
148
186
  });
149
187
  const t = /* @__PURE__ */ new Map();
150
188
  r.forEach(
151
- (c, i) => t.set(i, /* @__PURE__ */ new Set())
189
+ (c, a) => t.set(a, /* @__PURE__ */ new Set())
152
190
  );
153
- for (const [c, i] of e) {
191
+ for (const [c, a] of e) {
154
192
  const f = n.get(c);
155
193
  if (f !== void 0)
156
- for (const u of i) {
194
+ for (const u of a) {
157
195
  const l = n.get(u);
158
196
  l !== void 0 && l !== f && t.get(f)?.add(l);
159
197
  }
160
198
  }
161
- const o = [], s = /* @__PURE__ */ new Set(), a = (c) => {
199
+ const o = [], s = /* @__PURE__ */ new Set(), i = (c) => {
162
200
  if (!s.has(c)) {
163
201
  s.add(c);
164
- for (const i of t.get(c) ?? [])
165
- a(i);
202
+ for (const a of t.get(c) ?? [])
203
+ i(a);
166
204
  o.push(c);
167
205
  }
168
206
  };
169
207
  for (const c of t.keys())
170
- a(c);
208
+ i(c);
171
209
  return o.map((c) => r[c] ?? []);
172
210
  }
173
- function ye(e, r) {
211
+ function Be(e, r) {
174
212
  const n = /* @__PURE__ */ new Map(), t = (o, s = /* @__PURE__ */ new Set()) => {
175
213
  if (n.has(o))
176
214
  return n.get(o) ?? !1;
177
215
  if (s.has(o))
178
216
  return !1;
179
217
  s.add(o);
180
- const a = e.get(o) || /* @__PURE__ */ new Set();
181
- for (const c of a) {
182
- const i = r.get(c);
183
- if (i && (i.status === m.Dev || t(c, s)))
218
+ const i = e.get(o) || /* @__PURE__ */ new Set();
219
+ for (const c of i) {
220
+ const a = r.get(c);
221
+ if (a && (a.status === m.Dev || t(c, s)))
184
222
  return s.delete(o), n.set(o, !0), !0;
185
223
  }
186
224
  return s.delete(o), n.set(o, !1), !1;
@@ -194,13 +232,13 @@ function ye(e, r) {
194
232
  function I(e) {
195
233
  return typeof e == "object" && e !== null && !Array.isArray(e);
196
234
  }
197
- function h(e) {
235
+ function w(e) {
198
236
  return I(e) ? Object.getPrototypeOf(e) === Object.prototype : !1;
199
237
  }
200
238
  function S(e) {
201
239
  if (Array.isArray(e))
202
240
  return e.map((r) => S(r));
203
- if (h(e)) {
241
+ if (w(e)) {
204
242
  const r = {};
205
243
  for (const [n, t] of Object.entries(e))
206
244
  r[n] = S(t);
@@ -208,18 +246,18 @@ function S(e) {
208
246
  }
209
247
  return e;
210
248
  }
211
- function P(e) {
249
+ function M(e) {
212
250
  return e.map((r) => ({
213
251
  repositoryVersionIndex: r.repositoryVersionIndex,
214
252
  typeBlueId: r.typeBlueId,
215
253
  attributesAdded: [...r.attributesAdded]
216
254
  }));
217
255
  }
218
- const ge = /^\$\{([\s\S]*)\}$/;
219
- class me {
256
+ const Ae = /^\$\{([\s\S]*)\}$/;
257
+ class Se {
220
258
  process(r, n) {
221
259
  const t = n.getValue();
222
- if (U(t)) {
260
+ if (L(t)) {
223
261
  const o = n.clone();
224
262
  return o.setValue(t), o.setProperties(void 0), o.setItems(void 0), o.setType(void 0), o;
225
263
  }
@@ -227,38 +265,48 @@ class me {
227
265
  }
228
266
  postProcess(r, n) {
229
267
  const t = n.getValue();
230
- if (U(t) && r.getValue() !== t) {
268
+ if (L(t) && r.getValue() !== t) {
231
269
  const o = r.clone();
232
270
  return o.setValue(t), o;
233
271
  }
234
272
  return r;
235
273
  }
236
274
  }
237
- function U(e) {
238
- return typeof e != "string" || !ge.test(e) ? !1 : e.indexOf("${") === e.lastIndexOf("${");
239
- }
240
- function he() {
241
- return new B.SequentialMergingProcessor([
242
- new B.ValuePropagator(),
243
- new me(),
244
- new B.TypeAssigner(),
245
- new B.ListProcessor(),
246
- new B.DictionaryProcessor(),
247
- new B.MetadataPropagator(),
248
- new B.BasicTypesVerifier()
275
+ function L(e) {
276
+ return typeof e != "string" || !Ae.test(e) ? !1 : e.indexOf("${") === e.lastIndexOf("${");
277
+ }
278
+ function Te() {
279
+ return new v.SequentialMergingProcessor([
280
+ new v.ValuePropagator(),
281
+ new Se(),
282
+ new v.TypeAssigner(),
283
+ new v.ListProcessor(),
284
+ new v.DictionaryProcessor(),
285
+ new v.MetadataPropagator(),
286
+ new v.BasicTypesVerifier()
249
287
  ]);
250
288
  }
251
- const Y = "00000000000000000000000000000000000000000000";
252
- function we(e, r, n, t) {
253
- const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = new j(), i = H((l) => be(l) ? [new X().setReferenceBlueId(l)] : Ie(a, l).map(
254
- (y) => c.jsonValueToNode(y)
255
- )), u = { blue: new j({
256
- nodeProvider: i,
257
- mergingProcessor: he()
258
- }), contentByBlueId: a };
289
+ function z(e) {
290
+ return ee(e);
291
+ }
292
+ function N(e) {
293
+ return z(e);
294
+ }
295
+ const K = "00000000000000000000000000000000000000000000";
296
+ function Pe(e, r, n, t) {
297
+ const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = new Map(
298
+ Object.entries(te)
299
+ ), c = new U(), a = ne((l) => ke(l) ? [new re().setReferenceBlueId(l)] : Ne(i, l).map(
300
+ (y) => c.jsonValueToNode(
301
+ z(y)
302
+ )
303
+ )), u = { blue: new U({
304
+ nodeProvider: oe.unverified(a),
305
+ mergingProcessor: Te()
306
+ }), contentByBlueId: i };
259
307
  for (const l of e) {
260
- if (Ee(l, n)) {
261
- ve({
308
+ if (_e(l, n)) {
309
+ Me({
262
310
  component: l,
263
311
  discovered: r,
264
312
  previousTypes: t,
@@ -272,7 +320,7 @@ function we(e, r, n, t) {
272
320
  if (!y)
273
321
  continue;
274
322
  const g = r.get(y);
275
- g && Be({
323
+ g && $e({
276
324
  alias: y,
277
325
  type: g,
278
326
  previousTypes: t,
@@ -283,8 +331,8 @@ function we(e, r, n, t) {
283
331
  }
284
332
  return { aliasToBlueId: o, aliasToStorageContent: s };
285
333
  }
286
- function Ie(e, r) {
287
- const n = J(r);
334
+ function Ne(e, r) {
335
+ const n = H(r);
288
336
  if (n === void 0)
289
337
  return [];
290
338
  const t = e.get(n.baseBlueId);
@@ -297,7 +345,7 @@ function Ie(e, r) {
297
345
  const o = t[n.index];
298
346
  return o === void 0 ? [] : [o];
299
347
  }
300
- function J(e) {
348
+ function H(e) {
301
349
  const r = e.indexOf("#");
302
350
  if (r === -1)
303
351
  return { baseBlueId: e };
@@ -305,13 +353,13 @@ function J(e) {
305
353
  if (!(!Number.isInteger(o) || o < 0))
306
354
  return { baseBlueId: n, index: o };
307
355
  }
308
- function be(e) {
309
- return e === Y || /^this#\d+$/.test(e);
356
+ function ke(e) {
357
+ return e === K || /^this#\d+$/.test(e);
310
358
  }
311
- function $(e, r, n = !1, t = !1) {
359
+ function _(e, r, n = !1, t = !1) {
312
360
  if (Array.isArray(e))
313
361
  return e.map(
314
- (s) => $(
362
+ (s) => _(
315
363
  s,
316
364
  r,
317
365
  n,
@@ -321,24 +369,24 @@ function $(e, r, n = !1, t = !1) {
321
369
  if (!I(e))
322
370
  return e;
323
371
  const o = {};
324
- for (const [s, a] of Object.entries(e)) {
325
- const c = t || s === Q;
326
- if ((s === "type" || s === "itemType" || s === "keyType" || s === "valueType") && typeof a == "string" && !(n && c)) {
327
- if (V.has(a)) {
328
- const i = x[a];
329
- if (!i)
330
- throw new Error(`Missing primitive BlueId for ${a}.`);
331
- o[s] = { blueId: i };
372
+ for (const [s, i] of Object.entries(e)) {
373
+ const c = t || s === se;
374
+ if ((s === "type" || s === "itemType" || s === "keyType" || s === "valueType") && typeof i == "string" && !(n && c)) {
375
+ if (O.has(i)) {
376
+ const a = T[i];
377
+ if (!a)
378
+ throw new Error(`Missing primitive BlueId for ${i}.`);
379
+ o[s] = { blueId: a };
332
380
  } else {
333
- const i = a, f = r(i);
381
+ const a = i, f = r(a);
334
382
  if (!f)
335
- throw new Error(`Missing BlueId for alias ${i}.`);
383
+ throw new Error(`Missing BlueId for alias ${a}.`);
336
384
  o[s] = { blueId: f };
337
385
  }
338
386
  continue;
339
387
  }
340
- o[s] = $(
341
- a,
388
+ o[s] = _(
389
+ i,
342
390
  r,
343
391
  n,
344
392
  c
@@ -346,7 +394,7 @@ function $(e, r, n = !1, t = !1) {
346
394
  }
347
395
  return o;
348
396
  }
349
- function Be({
397
+ function $e({
350
398
  alias: e,
351
399
  type: r,
352
400
  previousTypes: n,
@@ -354,18 +402,18 @@ function Be({
354
402
  aliasToStorageContent: o,
355
403
  context: s
356
404
  }) {
357
- const { node: a, storageContent: c } = N(
405
+ const { node: i, storageContent: c } = R(
358
406
  r,
359
407
  (g) => t.get(g),
360
408
  s.blue
361
- ), i = V.has(r.typeName), f = i ? Pe(r.typeName) : s.blue.calculateBlueIdSync(a), u = K(
409
+ ), a = O.has(r.typeName), f = a ? xe(r.typeName) : s.blue.calculateBlueIdSync(i), u = X(
362
410
  n,
363
411
  r,
364
412
  c
365
413
  ), l = u?.blueId ?? f, y = u?.content ?? c;
366
- t.set(e, l), o.set(e, y), i || s.contentByBlueId.set(l, y), s.blue.registerBlueIds({ [e]: l });
414
+ t.set(e, l), o.set(e, y), a || s.contentByBlueId.set(l, y), s.blue.registerBlueIds({ [e]: l });
367
415
  }
368
- function ve({
416
+ function Me({
369
417
  component: e,
370
418
  discovered: r,
371
419
  previousTypes: n,
@@ -373,41 +421,41 @@ function ve({
373
421
  aliasToStorageContent: o,
374
422
  context: s
375
423
  }) {
376
- const a = new Set(e), c = /* @__PURE__ */ new Map();
424
+ const i = new Set(e), c = /* @__PURE__ */ new Map();
377
425
  e.forEach((d, p) => c.set(d, p));
378
- const i = e.map((d) => {
379
- const p = M(r, d), { node: b } = N(
426
+ const a = e.map((d) => {
427
+ const p = C(r, d), { node: b } = R(
380
428
  p,
381
- (w) => a.has(w) ? Y : t.get(w),
429
+ (h) => i.has(h) ? K : t.get(h),
382
430
  s.blue
383
431
  );
384
432
  return {
385
433
  alias: d,
386
- preliminaryBlueId: s.blue.calculateBlueIdSync(b)
434
+ preliminaryBlueId: q.calculateBlueIdAllowingCyclicPlaceholdersSync(b)
387
435
  };
388
436
  });
389
- Te(i), i.sort(ke);
437
+ Ve(a), a.sort(Oe);
390
438
  const f = /* @__PURE__ */ new Map();
391
- i.forEach(({ alias: d }, p) => {
439
+ a.forEach(({ alias: d }, p) => {
392
440
  f.set(d, p);
393
441
  });
394
442
  const u = /* @__PURE__ */ new Map();
395
443
  for (const d of e) {
396
- const p = M(r, d), b = N(
444
+ const p = C(r, d), b = R(
397
445
  p,
398
- (w) => {
399
- if (!a.has(w))
400
- return t.get(w);
401
- const _ = f.get(w);
402
- if (_ === void 0)
403
- throw new Error(`Failed to resolve cyclic reference ${w}.`);
404
- return `this#${_}`;
446
+ (h) => {
447
+ if (!i.has(h))
448
+ return t.get(h);
449
+ const D = f.get(h);
450
+ if (D === void 0)
451
+ throw new Error(`Failed to resolve cyclic reference ${h}.`);
452
+ return `this#${D}`;
405
453
  },
406
454
  s.blue
407
455
  );
408
456
  u.set(d, b);
409
457
  }
410
- const l = Ae(
458
+ const l = Re(
411
459
  e,
412
460
  r,
413
461
  n,
@@ -420,97 +468,110 @@ function ve({
420
468
  throw new Error(`Failed to preserve cyclic BlueId for type ${d}.`);
421
469
  t.set(d, p.blueId), o.set(d, p.content), s.blue.registerBlueIds({ [d]: p.blueId });
422
470
  }
423
- Se(s.contentByBlueId, l);
471
+ Ce(s.contentByBlueId, l);
424
472
  return;
425
473
  }
426
- const y = i.map(({ alias: d }) => {
474
+ const y = a.map(({ alias: d }) => {
427
475
  const p = u.get(d);
428
476
  if (!p)
429
477
  throw new Error(`Failed to build cyclic content for type ${d}.`);
430
478
  return p.node;
431
- }), g = i.map(({ alias: d }) => {
479
+ }), g = a.map(({ alias: d }) => {
432
480
  const p = u.get(d);
433
481
  if (!p)
434
482
  throw new Error(`Failed to build cyclic content for type ${d}.`);
435
483
  return p.storageContent;
436
- }), E = s.blue.calculateBlueIdSync(y);
437
- s.contentByBlueId.set(E, g), i.forEach(({ alias: d }, p) => {
484
+ }), B = s.blue.calculateBlueIdSync(y);
485
+ s.contentByBlueId.set(B, g), a.forEach(({ alias: d }, p) => {
438
486
  const b = u.get(d);
439
487
  if (!b)
440
488
  throw new Error(`Failed to build cyclic content for type ${d}.`);
441
- const w = `${E}#${p}`;
442
- t.set(d, w), o.set(d, b.storageContent), s.blue.registerBlueIds({ [d]: w });
489
+ const h = `${B}#${p}`;
490
+ t.set(d, h), o.set(d, b.storageContent), s.blue.registerBlueIds({ [d]: h });
443
491
  });
444
492
  }
445
- function Ee(e, r) {
493
+ function _e(e, r) {
446
494
  if (e.length > 1)
447
495
  return !0;
448
496
  const n = e[0];
449
497
  return n ? r.get(n)?.has(n) ?? !1 : !1;
450
498
  }
451
- function N(e, r, n) {
452
- const t = $(
499
+ function R(e, r, n) {
500
+ const t = _(
453
501
  S(e.content),
454
502
  r
455
- ), o = n.jsonValueToNode(t);
456
- return {
457
- node: o,
458
- storageContent: n.nodeToJson(o, "official")
459
- };
503
+ );
504
+ try {
505
+ const o = n.jsonValueToNode(t), s = N(
506
+ n.nodeToJson(o, "official")
507
+ );
508
+ return {
509
+ node: o,
510
+ storageContent: s
511
+ };
512
+ } catch (o) {
513
+ const s = o instanceof Error ? o.message : "Unknown error encountered.";
514
+ throw new Error(`Failed to build ${e.filePath}: ${s}`);
515
+ }
460
516
  }
461
- function M(e, r) {
517
+ function C(e, r) {
462
518
  const n = e.get(r);
463
519
  if (!n)
464
520
  throw new Error(`Unknown type alias ${r}.`);
465
521
  return n;
466
522
  }
467
- function Ae(e, r, n, t) {
523
+ function Re(e, r, n, t) {
468
524
  const o = /* @__PURE__ */ new Map();
469
525
  for (const s of e) {
470
- const a = M(r, s), c = t.get(s);
526
+ const i = C(r, s), c = t.get(s);
471
527
  if (!c)
472
528
  throw new Error(`Failed to build cyclic content for type ${s}.`);
473
- const i = K(
529
+ const a = X(
474
530
  n,
475
- a,
531
+ i,
476
532
  c.storageContent
477
533
  );
478
- if (!i)
534
+ if (!a)
479
535
  return null;
480
- o.set(s, i);
536
+ o.set(s, a);
481
537
  }
482
538
  return o;
483
539
  }
484
- function K(e, r, n) {
540
+ function X(e, r, n) {
485
541
  const t = e.get(r.packageName)?.get(r.typeName), o = t?.versions?.at(-1)?.typeBlueId;
486
- return !o || !t || !h(t.content) || !R(t.content, n) ? null : {
542
+ if (!o || !t || !w(t.content))
543
+ return null;
544
+ const s = N(
545
+ t.content
546
+ );
547
+ return V(s, n) ? {
487
548
  blueId: o,
488
- content: S(t.content)
489
- };
549
+ content: S(s)
550
+ } : null;
490
551
  }
491
- function Se(e, r) {
552
+ function Ce(e, r) {
492
553
  const n = /* @__PURE__ */ new Map();
493
554
  for (const { blueId: t, content: o } of r.values()) {
494
- const s = J(t);
555
+ const s = H(t);
495
556
  if (!s || s.index === void 0) {
496
557
  e.set(t, o);
497
558
  continue;
498
559
  }
499
- const a = n.get(s.baseBlueId) ?? [];
500
- a.push({ index: s.index, content: o }), n.set(s.baseBlueId, a);
560
+ const i = n.get(s.baseBlueId) ?? [];
561
+ i.push({ index: s.index, content: o }), n.set(s.baseBlueId, i);
501
562
  }
502
563
  for (const [t, o] of n) {
503
- const a = [...o].sort((c, i) => c.index - i.index).map((c, i) => {
504
- if (c.index !== i)
564
+ const i = [...o].sort((c, a) => c.index - a.index).map((c, a) => {
565
+ if (c.index !== a)
505
566
  throw new Error(
506
- `Cyclic repository content for ${t} is missing index ${i}.`
567
+ `Cyclic repository content for ${t} is missing index ${a}.`
507
568
  );
508
569
  return c.content;
509
570
  });
510
- e.set(t, a);
571
+ e.set(t, i);
511
572
  }
512
573
  }
513
- function Te(e) {
574
+ function Ve(e) {
514
575
  const r = /* @__PURE__ */ new Map();
515
576
  for (const n of e) {
516
577
  const t = r.get(n.preliminaryBlueId);
@@ -521,124 +582,124 @@ function Te(e) {
521
582
  r.set(n.preliminaryBlueId, n.alias);
522
583
  }
523
584
  }
524
- function ke(e, r) {
585
+ function Oe(e, r) {
525
586
  return e.preliminaryBlueId < r.preliminaryBlueId ? -1 : e.preliminaryBlueId > r.preliminaryBlueId ? 1 : 0;
526
587
  }
527
- function R(e, r) {
588
+ function V(e, r) {
528
589
  if (e === r)
529
590
  return !0;
530
591
  if (Array.isArray(e) || Array.isArray(r))
531
- return !Array.isArray(e) || !Array.isArray(r) || e.length !== r.length ? !1 : e.every((n, t) => R(n, r[t]));
532
- if (h(e) || h(r)) {
533
- if (!h(e) || !h(r))
592
+ return !Array.isArray(e) || !Array.isArray(r) || e.length !== r.length ? !1 : e.every((n, t) => V(n, r[t]));
593
+ if (w(e) || w(r)) {
594
+ if (!w(e) || !w(r))
534
595
  return !1;
535
596
  const n = Object.keys(e).sort(), t = Object.keys(r).sort();
536
597
  return n.length !== t.length ? !1 : n.every(
537
- (o, s) => o === t[s] && R(e[o], r[o])
598
+ (o, s) => o === t[s] && V(e[o], r[o])
538
599
  );
539
600
  }
540
601
  return !1;
541
602
  }
542
- function Pe(e) {
543
- const r = x[e];
603
+ function xe(e) {
604
+ const r = T[e];
544
605
  if (!r)
545
606
  throw new Error(`Missing primitive BlueId for ${e}.`);
546
607
  return r;
547
608
  }
548
- const F = new Set(Object.values(x)), $e = /* @__PURE__ */ new Set([
609
+ const F = new Set(Object.values(T)), De = /* @__PURE__ */ new Set([
549
610
  "type",
550
611
  "itemType",
551
612
  "valueType",
552
613
  "keyType"
553
- ]), Ne = /* @__PURE__ */ new Set(["name", "description"]), v = {
614
+ ]), je = /* @__PURE__ */ new Set(["name", "description"]), E = {
554
615
  Unchanged: "unchanged",
555
616
  NonBreaking: "non-breaking",
556
617
  Breaking: "breaking"
557
618
  };
558
- function Me(e, r, n, t, o) {
559
- const s = oe.compare(
619
+ function Ue(e, r, n, t, o) {
620
+ const s = fe.compare(
560
621
  e,
561
622
  r
562
623
  );
563
624
  if (s.length === 0)
564
- return { status: v.Unchanged, attributesAdded: [] };
565
- const a = [];
625
+ return { status: E.Unchanged, attributesAdded: [] };
626
+ const i = [];
566
627
  let c = !1;
567
- for (const i of s) {
568
- if (Oe(i, e, o)) {
628
+ for (const a of s) {
629
+ if (Ge(a, e, o)) {
569
630
  c = !0;
570
631
  continue;
571
632
  }
572
- if (i.op !== "add")
573
- return { status: v.Breaking, attributesAdded: [] };
574
- if (!Ve(i))
575
- return { status: v.Breaking, attributesAdded: [] };
576
- a.push(i.path);
633
+ if (a.op !== "add")
634
+ return { status: E.Breaking, attributesAdded: [] };
635
+ if (!Fe(a))
636
+ return { status: E.Breaking, attributesAdded: [] };
637
+ i.push(a.path);
577
638
  }
578
- return a.length === 0 && !c ? {
579
- status: v.Breaking,
639
+ return i.length === 0 && !c ? {
640
+ status: E.Breaking,
580
641
  attributesAdded: []
581
- } : (a.length > 0 && Re(a, n, t), { status: v.NonBreaking, attributesAdded: a });
642
+ } : (i.length > 0 && Le(i, n, t), { status: E.NonBreaking, attributesAdded: i });
582
643
  }
583
- function Re(e, r, n) {
644
+ function Le(e, r, n) {
584
645
  for (const t of e)
585
646
  try {
586
- te(t);
647
+ ae(t);
587
648
  } catch (o) {
588
649
  throw new Error(
589
650
  `Invalid attribute pointer "${t}" for ${r}/${n}: ${o.message}`
590
651
  );
591
652
  }
592
653
  }
593
- function Ve(e) {
654
+ function Fe(e) {
594
655
  if (e.op !== "add")
595
656
  return !1;
596
- const r = z(e.path);
657
+ const r = Z(e.path);
597
658
  if (r.length === 0)
598
659
  return !1;
599
660
  const n = r.at(-1);
600
- return n && /^\d+$/.test(n) || n && $e.has(n) || r.some(
601
- (t) => ee.has(t)
602
- ) ? !1 : I(e.value) ? !xe(e.value) : n ? Ne.has(n) : !1;
661
+ return n && /^\d+$/.test(n) || n && De.has(n) || r.some(
662
+ (t) => ie.has(t)
663
+ ) ? !1 : I(e.value) ? !Ye(e.value) : n ? je.has(n) : !1;
603
664
  }
604
- function z(e) {
665
+ function Z(e) {
605
666
  try {
606
- return ne(e);
667
+ return ce(e);
607
668
  } catch {
608
669
  return [];
609
670
  }
610
671
  }
611
- function xe(e) {
672
+ function Ye(e) {
612
673
  const r = [e];
613
674
  for (; r.length; ) {
614
675
  const n = r.pop();
615
676
  if (n) {
616
677
  if (Object.prototype.hasOwnProperty.call(n, "value") || Object.prototype.hasOwnProperty.call(n, "items"))
617
678
  return !0;
618
- if (Object.prototype.hasOwnProperty.call(n, T)) {
619
- const t = n[T];
679
+ if (Object.prototype.hasOwnProperty.call(n, k)) {
680
+ const t = n[k];
620
681
  if (I(t) && t.required === !0)
621
682
  return !0;
622
683
  }
623
684
  for (const [t, o] of Object.entries(n))
624
- t !== T && I(o) && r.push(o);
685
+ t !== k && I(o) && r.push(o);
625
686
  }
626
687
  }
627
688
  return !1;
628
689
  }
629
- function Oe(e, r, n) {
690
+ function Ge(e, r, n) {
630
691
  if (e.op !== "replace" || typeof e.path != "string")
631
692
  return !1;
632
- const t = z(e.path);
693
+ const t = Z(e.path);
633
694
  if (t.length < 2)
634
695
  return !1;
635
696
  const o = t.at(-1), s = t.at(-2);
636
697
  if (!(o === "blueId" && s !== void 0 && (s === "type" || s === "itemType" || s === "keyType" || s === "valueType")))
637
698
  return !1;
638
- const a = Ce(r, t), c = typeof a == "string" ? a : I(a) && typeof a.blueId == "string" ? a.blueId : null, i = typeof e.value == "string" ? e.value : I(e.value) && typeof e.value.blueId == "string" ? e.value.blueId : null;
639
- if (c && F.has(c) || i && F.has(i) || !c || !i)
699
+ const i = We(r, t), c = typeof i == "string" ? i : I(i) && typeof i.blueId == "string" ? i.blueId : null, a = typeof e.value == "string" ? e.value : I(e.value) && typeof e.value.blueId == "string" ? e.value.blueId : null;
700
+ if (c && F.has(c) || a && F.has(a) || !c || !a)
640
701
  return !1;
641
- const f = n.get(c), u = n.get(i);
702
+ const f = n.get(c), u = n.get(a);
642
703
  if (!f || !u)
643
704
  return !1;
644
705
  for (const l of f)
@@ -646,7 +707,7 @@ function Oe(e, r, n) {
646
707
  return !0;
647
708
  return !1;
648
709
  }
649
- function Ce(e, r) {
710
+ function We(e, r) {
650
711
  let n = e;
651
712
  for (const t of r)
652
713
  if (Array.isArray(n)) {
@@ -660,7 +721,7 @@ function Ce(e, r) {
660
721
  return;
661
722
  return n;
662
723
  }
663
- function _e(e) {
724
+ function qe(e) {
664
725
  const r = /* @__PURE__ */ new Map();
665
726
  if (!e)
666
727
  return r;
@@ -669,76 +730,76 @@ function _e(e) {
669
730
  continue;
670
731
  const t = /* @__PURE__ */ new Map();
671
732
  for (const o of n.types || []) {
672
- const s = o.content, a = h(s) && typeof s.name == "string" ? s.name : void 0;
673
- a && t.set(a, o);
733
+ const s = o.content, i = w(s) ? N(s) : s, c = w(i) && typeof i.name == "string" ? i.name : void 0;
734
+ c && t.set(c, { ...o, content: i });
674
735
  }
675
736
  r.set(n.name, t);
676
737
  }
677
738
  return r;
678
739
  }
679
- function De(e, r) {
740
+ function Je(e, r) {
680
741
  for (const [n, t] of r)
681
742
  for (const [o, s] of t) {
682
- const a = `${n}/${o}`;
683
- if (!e.has(a) && s.status === m.Stable)
743
+ const i = `${n}/${o}`;
744
+ if (!e.has(i) && s.status === m.Stable)
684
745
  throw new Error(
685
- `Stable type ${a} was removed. Breaking changes require a new logical type name.`
746
+ `Stable type ${i} was removed. Breaking changes require a new logical type name.`
686
747
  );
687
748
  }
688
749
  }
689
- function je({
750
+ function ze({
690
751
  discovered: e,
691
752
  previousTypes: r,
692
753
  aliasToBlueId: n,
693
754
  aliasToStorageContent: t,
694
755
  nextRepoVersionIndex: o
695
756
  }) {
696
- const s = /* @__PURE__ */ new Map(), a = Ue(r, n);
697
- for (const [c, i] of e) {
757
+ const s = /* @__PURE__ */ new Map(), i = Ke(r, n);
758
+ for (const [c, a] of e) {
698
759
  const f = n.get(c);
699
760
  if (!f)
700
761
  throw new Error(`Failed to compute BlueId for type ${c}.`);
701
- const u = r.get(i.packageName)?.get(i.typeName) ?? null;
702
- if (u && u.status === m.Stable && i.status === m.Dev)
762
+ const u = r.get(a.packageName)?.get(a.typeName) ?? null;
763
+ if (u && u.status === m.Stable && a.status === m.Dev)
703
764
  throw new Error(
704
765
  `Type ${c} was stable previously and cannot be downgraded to dev. Use a new logical name instead.`
705
766
  );
706
- const l = t.get(c) ?? i.content, y = i.status === m.Dev ? Fe({ blueId: f, nextRepoVersionIndex: o, previousType: u }) : !u || u.status === m.Dev ? Le({ blueId: f, nextRepoVersionIndex: o }) : Ge({
767
+ const l = t.get(c) ?? a.content, y = a.status === m.Dev ? He({ blueId: f, nextRepoVersionIndex: o, previousType: u }) : !u || u.status === m.Dev ? Xe({ blueId: f, nextRepoVersionIndex: o }) : Ze({
707
768
  alias: c,
708
769
  blueId: f,
709
770
  nextRepoVersionIndex: o,
710
771
  previousType: u,
711
772
  currentContent: l,
712
- packageName: i.packageName,
713
- typeName: i.typeName,
714
- blueIdAliases: a
773
+ packageName: a.packageName,
774
+ typeName: a.typeName,
775
+ blueIdAliases: i
715
776
  });
716
- y.content = l, y.status = i.status;
717
- const g = s.get(i.packageName) ?? [];
718
- g.push(y), s.set(i.packageName, g);
777
+ y.content = l, y.status = a.status;
778
+ const g = s.get(a.packageName) ?? [];
779
+ g.push(y), s.set(a.packageName, g);
719
780
  }
720
781
  return s;
721
782
  }
722
- function Ue(e, r) {
783
+ function Ke(e, r) {
723
784
  const n = /* @__PURE__ */ new Map(), t = (o, s) => {
724
- const a = n.get(o);
725
- if (a) {
726
- a.add(s);
785
+ const i = n.get(o);
786
+ if (i) {
787
+ i.add(s);
727
788
  return;
728
789
  }
729
790
  n.set(o, /* @__PURE__ */ new Set([s]));
730
791
  };
731
792
  for (const [o, s] of e)
732
- for (const [a, c] of s) {
733
- const i = `${o}/${a}`;
793
+ for (const [i, c] of s) {
794
+ const a = `${o}/${i}`;
734
795
  for (const f of c.versions ?? [])
735
- typeof f.typeBlueId == "string" && t(f.typeBlueId, i);
796
+ typeof f.typeBlueId == "string" && t(f.typeBlueId, a);
736
797
  }
737
798
  for (const [o, s] of r)
738
799
  t(s, o);
739
800
  return n;
740
801
  }
741
- function Fe({
802
+ function He({
742
803
  blueId: e,
743
804
  nextRepoVersionIndex: r,
744
805
  previousType: n
@@ -747,7 +808,7 @@ function Fe({
747
808
  return {
748
809
  status: m.Dev,
749
810
  content: {},
750
- versions: s && t?.versions ? P(t.versions) : [
811
+ versions: s && t?.versions ? M(t.versions) : [
751
812
  {
752
813
  repositoryVersionIndex: r,
753
814
  typeBlueId: e,
@@ -756,7 +817,7 @@ function Fe({
756
817
  ]
757
818
  };
758
819
  }
759
- function Le({
820
+ function Xe({
760
821
  blueId: e,
761
822
  nextRepoVersionIndex: r
762
823
  }) {
@@ -772,49 +833,51 @@ function Le({
772
833
  ]
773
834
  };
774
835
  }
775
- function Ge({
836
+ function Ze({
776
837
  alias: e,
777
838
  blueId: r,
778
839
  nextRepoVersionIndex: n,
779
840
  previousType: t,
780
841
  currentContent: o,
781
842
  packageName: s,
782
- typeName: a,
843
+ typeName: i,
783
844
  blueIdAliases: c
784
845
  }) {
785
- if (!h(t.content))
846
+ if (!w(t.content))
786
847
  throw new Error(
787
848
  `Type ${e} has non-object content; cannot compute diff for stable versioning.`
788
849
  );
789
- const i = Me(
790
- t.content,
850
+ const a = N(
851
+ t.content
852
+ ), f = Ue(
853
+ a,
791
854
  o,
792
855
  s,
793
- a,
856
+ i,
794
857
  c
795
858
  );
796
- if (i.status === v.Unchanged) {
797
- const f = P(t.versions || []), u = f.at(-1);
798
- if (u && u.typeBlueId !== r)
859
+ if (f.status === E.Unchanged) {
860
+ const u = M(t.versions || []), l = u.at(-1);
861
+ if (l && l.typeBlueId !== r)
799
862
  throw new Error(
800
863
  `Type ${e} content is unchanged but BlueId differs from previous metadata.`
801
864
  );
802
865
  return {
803
866
  status: m.Stable,
804
867
  content: {},
805
- versions: f
868
+ versions: u
806
869
  };
807
870
  }
808
- if (i.status === v.NonBreaking)
871
+ if (f.status === E.NonBreaking)
809
872
  return {
810
873
  status: m.Stable,
811
874
  content: {},
812
875
  versions: [
813
- ...P(t.versions || []),
876
+ ...M(t.versions || []),
814
877
  {
815
878
  repositoryVersionIndex: n,
816
879
  typeBlueId: r,
817
- attributesAdded: i.attributesAdded
880
+ attributesAdded: f.attributesAdded
818
881
  }
819
882
  ]
820
883
  };
@@ -822,7 +885,7 @@ function Ge({
822
885
  `Breaking change detected in stable type ${e}. Introduce a new type name for breaking changes.`
823
886
  );
824
887
  }
825
- function qe(e) {
888
+ function Qe(e) {
826
889
  return Array.from(e.entries()).map(([r, n]) => ({
827
890
  name: r,
828
891
  types: n.map((t) => ({
@@ -831,139 +894,135 @@ function qe(e) {
831
894
  (o, s) => o.repositoryVersionIndex - s.repositoryVersionIndex
832
895
  )
833
896
  })).sort((t, o) => {
834
- const s = h(t.content) && typeof t.content.name == "string" ? t.content.name : "", a = h(o.content) && typeof o.content.name == "string" ? o.content.name : "";
835
- return s.localeCompare(a);
897
+ const s = w(t.content) && typeof t.content.name == "string" ? t.content.name : "", i = w(o.content) && typeof o.content.name == "string" ? o.content.name : "";
898
+ return s.localeCompare(i);
836
899
  })
837
900
  })).sort((r, n) => r.name.localeCompare(n.name));
838
901
  }
839
- function L(e) {
840
- return Z.INSTANCE.calculateSync(
902
+ function Y(e) {
903
+ return q.INSTANCE.calculateAllowingCyclicPlaceholdersSync(
841
904
  e
842
905
  );
843
906
  }
844
- function We(e, r, n) {
907
+ function et(e, r, n) {
845
908
  const t = r?.repositoryVersions.at(-1), o = !t || t !== n, s = r?.repositoryVersions ? [...r.repositoryVersions] : [];
846
909
  return o && s.push(n), { document: {
847
- name: O,
910
+ name: x,
848
911
  packages: e,
849
912
  repositoryVersions: s
850
913
  }, changed: o };
851
914
  }
852
- function Ye(e, r, n) {
915
+ function tt(e, r, n) {
853
916
  const t = {
854
- name: O,
917
+ name: x,
855
918
  repositoryVersions: r,
856
- packages: Je(e, n)
919
+ packages: nt(e, n)
857
920
  };
858
- re(t);
921
+ ue(t);
859
922
  }
860
- function Je(e, r) {
923
+ function nt(e, r) {
861
924
  const n = {};
862
925
  for (const t of e) {
863
- const o = Ke(t.name, r), s = {}, a = {};
926
+ const o = rt(t.name, r), s = {}, i = {};
864
927
  for (const c of t.types) {
865
- const i = c.versions?.[c.versions.length - 1]?.typeBlueId;
866
- if (!i)
928
+ const a = c.versions?.[c.versions.length - 1]?.typeBlueId;
929
+ if (!a)
867
930
  throw new Error(
868
931
  `Type ${t.name} is missing a current BlueId in versions.`
869
932
  );
870
- const f = ze(c);
871
- s[i] = {
933
+ const f = ot(c);
934
+ s[a] = {
872
935
  status: c.status,
873
936
  name: f,
874
937
  versions: c.versions ?? []
875
- }, a[i] = c.content;
938
+ }, i[a] = c.content;
876
939
  }
877
940
  n[t.name] = {
878
941
  name: t.name,
879
942
  aliases: o,
880
943
  typesMeta: s,
881
- contents: a,
944
+ contents: i,
882
945
  schemas: {}
883
946
  };
884
947
  }
885
948
  return n;
886
949
  }
887
- function Ke(e, r) {
950
+ function rt(e, r) {
888
951
  const n = {}, t = `${e}/`;
889
952
  return r.forEach((o, s) => {
890
953
  s.startsWith(t) && (n[s] = o);
891
954
  }), n;
892
955
  }
893
- function ze(e) {
894
- const r = h(e.content) && typeof e.content.name == "string" ? e.content.name : null;
956
+ function ot(e) {
957
+ const r = w(e.content) && typeof e.content.name == "string" ? e.content.name : null;
895
958
  if (!r)
896
959
  throw new Error('Type content is missing required "name" field.');
897
960
  return r;
898
961
  }
899
- function He(e) {
962
+ function st(e) {
900
963
  if (!A.existsSync(e))
901
964
  return { previous: null };
902
- const r = A.readFileSync(e, "utf8"), n = q(r);
965
+ const r = A.readFileSync(e, "utf8"), n = W(r);
903
966
  if (!n || !I(n))
904
967
  throw new Error("Existing BlueRepository.blue is not a valid object.");
905
- const t = n, o = t.packages, s = t.repositoryVersions, a = Array.isArray(o) && o.every(
968
+ const t = n, o = t.packages, s = t.repositoryVersions, i = Array.isArray(o) && o.every(
906
969
  (l) => I(l) && typeof l.name == "string" && Array.isArray(l.types)
907
970
  ), c = Array.isArray(s) && s.every((l) => typeof l == "string");
908
- if (!a || !c)
971
+ if (!i || !c)
909
972
  throw new Error(
910
973
  "Invalid BlueRepository.blue structure: expected { packages: BluePackage[], repositoryVersions: string[] }"
911
974
  );
912
- const i = o, f = s, u = {
913
- name: typeof t.name == "string" ? t.name : O,
914
- packages: i,
975
+ const a = o, f = s, u = {
976
+ name: typeof t.name == "string" ? t.name : x,
977
+ packages: a,
915
978
  repositoryVersions: f
916
979
  };
917
980
  return { existingYaml: r, previous: u };
918
981
  }
919
- function Xe(e) {
920
- return se.dump(e, { lineWidth: -1 });
982
+ function it(e) {
983
+ return le.dump(e, { lineWidth: -1 });
921
984
  }
922
- function st(e) {
923
- const r = D.resolve(e.repoRoot), n = D.resolve(e.blueRepositoryPath), { existingYaml: t, previous: o } = He(n), s = ae(r), a = _e(o);
924
- De(s, a);
925
- const c = le(s), i = pe(c);
926
- ye(c, s);
927
- const { aliasToBlueId: f, aliasToStorageContent: u } = we(
928
- i,
985
+ function yt(e) {
986
+ const r = j.resolve(e.repoRoot), n = j.resolve(e.blueRepositoryPath), { existingYaml: t, previous: o } = st(n), s = ge(r), i = qe(o);
987
+ Je(s, i);
988
+ const c = be(s), a = Ee(c);
989
+ Be(c, s);
990
+ const { aliasToBlueId: f, aliasToStorageContent: u } = Pe(
991
+ a,
929
992
  s,
930
993
  c,
931
- a
932
- ), l = o ? o.repositoryVersions.length : 0, y = je({
994
+ i
995
+ ), l = o ? o.repositoryVersions.length : 0, y = ze({
933
996
  discovered: s,
934
- previousTypes: a,
997
+ previousTypes: i,
935
998
  aliasToBlueId: f,
936
999
  aliasToStorageContent: u,
937
1000
  nextRepoVersionIndex: l
938
- }), g = qe(y), E = o && Ze(o.packages, g) ? o.repositoryVersions.at(-1) ?? L(g) : L(g), { document: d, changed: p } = We(
1001
+ }), g = Qe(y), B = o && at(o.packages, g) ? o.repositoryVersions.at(-1) ?? Y(g) : Y(g), { document: d, changed: p } = et(
939
1002
  g,
940
1003
  o,
941
- E
1004
+ B
942
1005
  );
943
- Ye(
1006
+ tt(
944
1007
  d.packages,
945
1008
  d.repositoryVersions,
946
1009
  f
947
1010
  );
948
- const b = Xe(d);
949
- if (o && !p && t && t !== b)
950
- throw new Error(
951
- "BlueRepository.blue content differs from regenerated output while RepoBlueId is unchanged. Please revert manual edits or rerun in write mode."
952
- );
1011
+ const b = it(d), h = t !== void 0 && t === b;
953
1012
  return e.verbose && console.info(
954
- `[repository-generator] RepoBlueId: ${E} (${p ? "changed" : "unchanged"})`
1013
+ `[repository-generator] RepoBlueId: ${B} (${p ? "changed" : "unchanged"})`
955
1014
  ), {
956
1015
  document: d,
957
- currentRepoBlueId: E,
1016
+ currentRepoBlueId: B,
958
1017
  previousRepoBlueId: o?.repositoryVersions.at(-1),
959
- changed: p || !t,
1018
+ changed: p || !h,
960
1019
  yaml: b,
961
1020
  existingYaml: t
962
1021
  };
963
1022
  }
964
- function Ze(e, r) {
1023
+ function at(e, r) {
965
1024
  return JSON.stringify(e) === JSON.stringify(r);
966
1025
  }
967
1026
  export {
968
- st as g
1027
+ yt as g
969
1028
  };