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