@blue-labs/repository-generator 2.0.0-rc.9 → 3.1.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.
@@ -0,0 +1,688 @@
1
+ import * as _ from "path";
2
+ import A from "path";
3
+ import w from "fs";
4
+ import { Properties as x, yamlBlueParse as j, BlueIdCalculator as C } from "@blue-labs/language";
5
+ import { OBJECT_CONTRACTS as L, RESERVED_ATTRIBUTES_POINTER_SEGMENTS as Y, validateAttributesAddedPointer as W, parsePointer as G, OBJECT_SCHEMA as T, validateNoCycles as q, validateStableDoesNotDependOnDev as z } from "@blue-labs/repository-contract";
6
+ import J from "fast-json-patch";
7
+ import H from "js-yaml";
8
+ const N = /* @__PURE__ */ new Set([...x.CORE_TYPES]), g = x.CORE_TYPE_NAME_TO_BLUE_ID_MAP, R = "Blue Repository", l = {
9
+ Dev: "dev",
10
+ Stable: "stable"
11
+ }, K = /* @__PURE__ */ new Set([
12
+ ".git",
13
+ ".github",
14
+ ".husky",
15
+ "node_modules",
16
+ ".nx",
17
+ ".vscode",
18
+ ".idea"
19
+ ]);
20
+ function Q(e) {
21
+ const s = w.readdirSync(e, { withFileTypes: !0 }), t = /* @__PURE__ */ new Map();
22
+ for (const n of s) {
23
+ if (!n.isDirectory() || K.has(n.name))
24
+ continue;
25
+ const r = A.join(e, n.name), o = U(r);
26
+ if (o.length !== 0)
27
+ for (const i of o) {
28
+ const c = i.endsWith(".dev.blue") ? l.Dev : l.Stable, a = X(i), u = Z(a, i), f = `${n.name}/${u}`, p = t.get(f);
29
+ if (p)
30
+ throw p.status !== c ? new Error(
31
+ `Type ${f} has both stable and dev definitions (${p.filePath} and ${i}).`
32
+ ) : new Error(
33
+ `Type ${f} is defined multiple times (${p.filePath} and ${i}).`
34
+ );
35
+ const y = ee(a, i);
36
+ t.set(f, {
37
+ packageName: n.name,
38
+ typeName: u,
39
+ status: c,
40
+ content: a,
41
+ filePath: i,
42
+ references: y
43
+ });
44
+ }
45
+ }
46
+ return t;
47
+ }
48
+ function X(e) {
49
+ const s = w.readFileSync(e, "utf8"), t = j(s);
50
+ if (!O(t))
51
+ throw new Error(`Type file ${e} must contain a YAML object.`);
52
+ return t;
53
+ }
54
+ function Z(e, s) {
55
+ if (!O(e) || typeof e.name != "string")
56
+ throw new Error(`Type file ${s} is missing required "name" field.`);
57
+ return e.name;
58
+ }
59
+ function U(e) {
60
+ const s = w.readdirSync(e, { withFileTypes: !0 }), t = [];
61
+ for (const n of s) {
62
+ if (n.isDirectory()) {
63
+ t.push(...U(A.join(e, n.name)));
64
+ continue;
65
+ }
66
+ (n.name.endsWith(".blue") || n.name.endsWith(".dev.blue")) && t.push(A.join(e, n.name));
67
+ }
68
+ return t;
69
+ }
70
+ function ee(e, s) {
71
+ const t = /* @__PURE__ */ new Set(), n = (r) => {
72
+ if (Array.isArray(r)) {
73
+ r.forEach((i) => n(i));
74
+ return;
75
+ }
76
+ if (!O(r))
77
+ return;
78
+ const o = (i) => {
79
+ if (typeof i == "string" && !N.has(i)) {
80
+ if (!i.includes("/"))
81
+ throw new Error(
82
+ `Invalid type reference "${i}" in ${s}. Use <Package>/<Type> for non-primitive references.`
83
+ );
84
+ t.add(i);
85
+ }
86
+ };
87
+ o(r.type), o(r.itemType), o(r.keyType), o(r.valueType), Object.values(r).forEach((i) => n(i));
88
+ };
89
+ return n(e), t;
90
+ }
91
+ function O(e) {
92
+ return typeof e == "object" && e !== null && !Array.isArray(e);
93
+ }
94
+ function te(e) {
95
+ const s = /* @__PURE__ */ new Map();
96
+ for (const [t, n] of e) {
97
+ const r = /* @__PURE__ */ new Set();
98
+ for (const o of n.references) {
99
+ if (!e.has(o))
100
+ throw new Error(
101
+ `Type ${t} references unknown alias ${o}. Ensure the target type exists.`
102
+ );
103
+ r.add(o);
104
+ }
105
+ s.set(t, r);
106
+ }
107
+ return s;
108
+ }
109
+ function ne(e) {
110
+ const s = [], t = /* @__PURE__ */ new Map(), n = (r, o) => {
111
+ const i = t.get(r);
112
+ if (i === "visited")
113
+ return;
114
+ if (i === "visiting") {
115
+ const a = [...o, r].join(" -> ");
116
+ throw new Error(`Circular type dependency detected: ${a}`);
117
+ }
118
+ t.set(r, "visiting"), o.push(r);
119
+ const c = e.get(r) || /* @__PURE__ */ new Set();
120
+ for (const a of c)
121
+ n(a, o);
122
+ o.pop(), t.set(r, "visited"), s.push(r);
123
+ };
124
+ for (const r of e.keys())
125
+ t.has(r) || n(r, []);
126
+ return s;
127
+ }
128
+ function re(e, s) {
129
+ const t = /* @__PURE__ */ new Map(), n = (r) => {
130
+ if (t.has(r))
131
+ return t.get(r) ?? !1;
132
+ const o = e.get(r) || /* @__PURE__ */ new Set();
133
+ for (const i of o) {
134
+ const c = s.get(i);
135
+ if (c && (c.status === l.Dev || n(i)))
136
+ return t.set(r, !0), !0;
137
+ }
138
+ return t.set(r, !1), !1;
139
+ };
140
+ for (const [r, o] of s)
141
+ if (o.status === l.Stable && n(r))
142
+ throw new Error(
143
+ `Stable type ${r} depends on a dev type. Stable types may only depend on other stable types.`
144
+ );
145
+ }
146
+ function d(e) {
147
+ return typeof e == "object" && e !== null && !Array.isArray(e);
148
+ }
149
+ function h(e) {
150
+ return d(e) ? Object.getPrototypeOf(e) === Object.prototype : !1;
151
+ }
152
+ function S(e) {
153
+ if (Array.isArray(e))
154
+ return e.map((s) => S(s));
155
+ if (h(e)) {
156
+ const s = {};
157
+ for (const [t, n] of Object.entries(e))
158
+ s[t] = S(n);
159
+ return s;
160
+ }
161
+ return e;
162
+ }
163
+ function B(e) {
164
+ return e.map((s) => ({
165
+ repositoryVersionIndex: s.repositoryVersionIndex,
166
+ typeBlueId: s.typeBlueId,
167
+ attributesAdded: [...s.attributesAdded]
168
+ }));
169
+ }
170
+ function se(e, s) {
171
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
172
+ for (const r of e) {
173
+ const o = s.get(r);
174
+ if (!o)
175
+ continue;
176
+ const i = P(
177
+ S(o.content),
178
+ t
179
+ ), c = k(i), a = N.has(o.typeName) ? oe(o.typeName) : C.INSTANCE.calculateSync(c);
180
+ t.set(r, a), n.set(r, c);
181
+ }
182
+ return { aliasToBlueId: t, aliasToPreprocessed: n };
183
+ }
184
+ function P(e, s, t = !1, n = !1) {
185
+ if (Array.isArray(e))
186
+ return e.map(
187
+ (o) => P(
188
+ o,
189
+ s,
190
+ t,
191
+ n
192
+ )
193
+ );
194
+ if (!d(e))
195
+ return e;
196
+ const r = {};
197
+ for (const [o, i] of Object.entries(e)) {
198
+ const c = n || o === L;
199
+ if ((o === "type" || o === "itemType" || o === "keyType" || o === "valueType") && typeof i == "string" && !(t && c)) {
200
+ if (N.has(i)) {
201
+ const a = g[i];
202
+ if (!a)
203
+ throw new Error(`Missing primitive BlueId for ${i}.`);
204
+ r[o] = { blueId: a };
205
+ } else {
206
+ const a = i, u = s.get(a);
207
+ if (!u)
208
+ throw new Error(`Missing BlueId for alias ${a}.`);
209
+ r[o] = { blueId: u };
210
+ }
211
+ continue;
212
+ }
213
+ r[o] = P(
214
+ i,
215
+ s,
216
+ t,
217
+ c
218
+ );
219
+ }
220
+ return r;
221
+ }
222
+ function k(e, s = !1) {
223
+ if (Array.isArray(e))
224
+ return { items: e.map((n) => k(n)) };
225
+ if (h(e)) {
226
+ if (ae(e))
227
+ return { blueId: e.blueId };
228
+ const t = ce(e), n = {};
229
+ for (const [r, o] of Object.entries(e)) {
230
+ if (M(o)) {
231
+ fe(r, t) ? n[r] = o : n[r] = V(
232
+ o
233
+ );
234
+ continue;
235
+ }
236
+ n[r] = k(
237
+ o,
238
+ t
239
+ );
240
+ }
241
+ return n;
242
+ }
243
+ return M(e) ? s ? e : V(e) : e;
244
+ }
245
+ function oe(e) {
246
+ const s = g[e];
247
+ if (!s)
248
+ throw new Error(`Missing primitive BlueId for ${e}.`);
249
+ return s;
250
+ }
251
+ function V(e) {
252
+ const s = ie(e), t = { value: e };
253
+ return s && (t.type = { blueId: s }), t;
254
+ }
255
+ function ie(e) {
256
+ return typeof e == "string" ? g.Text : typeof e == "boolean" ? g.Boolean : typeof e == "number" ? Number.isInteger(e) ? g.Integer : g.Double : null;
257
+ }
258
+ function M(e) {
259
+ return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean";
260
+ }
261
+ function ae(e) {
262
+ const s = Object.entries(e);
263
+ return s.length === 1 && s[0]?.[0] === "blueId" && typeof s[0]?.[1] == "string";
264
+ }
265
+ function ce(e) {
266
+ return Object.prototype.hasOwnProperty.call(e, "type") || Object.prototype.hasOwnProperty.call(e, "itemType") || Object.prototype.hasOwnProperty.call(e, "keyType") || Object.prototype.hasOwnProperty.call(e, "valueType");
267
+ }
268
+ const ue = /* @__PURE__ */ new Set(["name", "description", "blueId"]);
269
+ function fe(e, s) {
270
+ return !!(ue.has(e) || s && e === "value");
271
+ }
272
+ const D = new Set(Object.values(g)), pe = /* @__PURE__ */ new Set([
273
+ "type",
274
+ "itemType",
275
+ "valueType",
276
+ "keyType"
277
+ ]), le = /* @__PURE__ */ new Set(["name", "description"]), m = {
278
+ Unchanged: "unchanged",
279
+ NonBreaking: "non-breaking",
280
+ Breaking: "breaking"
281
+ };
282
+ function de(e, s, t, n, r) {
283
+ const o = J.compare(
284
+ e,
285
+ s
286
+ );
287
+ if (o.length === 0)
288
+ return { status: m.Unchanged, attributesAdded: [] };
289
+ const i = [];
290
+ let c = !1;
291
+ for (const a of o) {
292
+ if (he(a, e, r)) {
293
+ c = !0;
294
+ continue;
295
+ }
296
+ if (a.op !== "add")
297
+ return { status: m.Breaking, attributesAdded: [] };
298
+ if (!me(a))
299
+ return { status: m.Breaking, attributesAdded: [] };
300
+ i.push(a.path);
301
+ }
302
+ return i.length === 0 && !c ? {
303
+ status: m.Breaking,
304
+ attributesAdded: []
305
+ } : (i.length > 0 && ye(i, t, n), { status: m.NonBreaking, attributesAdded: i });
306
+ }
307
+ function ye(e, s, t) {
308
+ for (const n of e)
309
+ try {
310
+ W(n);
311
+ } catch (r) {
312
+ throw new Error(
313
+ `Invalid attribute pointer "${n}" for ${s}/${t}: ${r.message}`
314
+ );
315
+ }
316
+ }
317
+ function me(e) {
318
+ if (e.op !== "add")
319
+ return !1;
320
+ const s = F(e.path);
321
+ if (s.length === 0)
322
+ return !1;
323
+ const t = s.at(-1);
324
+ return t && /^\d+$/.test(t) || t && pe.has(t) || s.some(
325
+ (n) => Y.has(n)
326
+ ) ? !1 : d(e.value) ? !ge(e.value) : t ? le.has(t) : !1;
327
+ }
328
+ function F(e) {
329
+ try {
330
+ return G(e);
331
+ } catch {
332
+ return [];
333
+ }
334
+ }
335
+ function ge(e) {
336
+ const s = [e];
337
+ for (; s.length; ) {
338
+ const t = s.pop();
339
+ if (t) {
340
+ if (Object.prototype.hasOwnProperty.call(t, "value") || Object.prototype.hasOwnProperty.call(t, "items"))
341
+ return !0;
342
+ if (Object.prototype.hasOwnProperty.call(t, T)) {
343
+ const n = t[T];
344
+ if (d(n) && n.required === !0)
345
+ return !0;
346
+ }
347
+ for (const [n, r] of Object.entries(t))
348
+ n !== T && d(r) && s.push(r);
349
+ }
350
+ }
351
+ return !1;
352
+ }
353
+ function he(e, s, t) {
354
+ if (e.op !== "replace" || typeof e.path != "string")
355
+ return !1;
356
+ const n = F(e.path);
357
+ if (n.length < 2)
358
+ return !1;
359
+ const r = n.at(-1), o = n.at(-2);
360
+ if (!(r === "blueId" && o !== void 0 && (o === "type" || o === "itemType" || o === "keyType" || o === "valueType")))
361
+ return !1;
362
+ const i = be(s, n), c = typeof i == "string" ? i : d(i) && typeof i.blueId == "string" ? i.blueId : null, a = typeof e.value == "string" ? e.value : d(e.value) && typeof e.value.blueId == "string" ? e.value.blueId : null;
363
+ if (c && D.has(c) || a && D.has(a) || !c || !a)
364
+ return !1;
365
+ const u = t.get(c), f = t.get(a);
366
+ if (!u || !f)
367
+ return !1;
368
+ for (const p of u)
369
+ if (f.has(p))
370
+ return !0;
371
+ return !1;
372
+ }
373
+ function be(e, s) {
374
+ let t = e;
375
+ for (const n of s)
376
+ if (Array.isArray(t)) {
377
+ const r = Number(n);
378
+ if (Number.isNaN(r) || r < 0 || r >= t.length)
379
+ return;
380
+ t = t[r];
381
+ } else if (d(t))
382
+ t = t[n];
383
+ else
384
+ return;
385
+ return t;
386
+ }
387
+ function we(e) {
388
+ const s = /* @__PURE__ */ new Map();
389
+ if (!e)
390
+ return s;
391
+ for (const t of e.packages || []) {
392
+ if (typeof t.name != "string")
393
+ continue;
394
+ const n = /* @__PURE__ */ new Map();
395
+ for (const r of t.types || []) {
396
+ const o = r.content, i = h(o) && typeof o.name == "string" ? o.name : void 0;
397
+ i && n.set(i, r);
398
+ }
399
+ s.set(t.name, n);
400
+ }
401
+ return s;
402
+ }
403
+ function Ie(e, s) {
404
+ for (const [t, n] of s)
405
+ for (const [r, o] of n) {
406
+ const i = `${t}/${r}`;
407
+ if (!e.has(i) && o.status === l.Stable)
408
+ throw new Error(
409
+ `Stable type ${i} was removed. Breaking changes require a new logical type name.`
410
+ );
411
+ }
412
+ }
413
+ function Ee({
414
+ discovered: e,
415
+ previousTypes: s,
416
+ aliasToBlueId: t,
417
+ aliasToPreprocessed: n,
418
+ nextRepoVersionIndex: r
419
+ }) {
420
+ const o = /* @__PURE__ */ new Map(), i = ve(s, t);
421
+ for (const [c, a] of e) {
422
+ const u = t.get(c);
423
+ if (!u)
424
+ throw new Error(`Failed to compute BlueId for type ${c}.`);
425
+ const f = s.get(a.packageName)?.get(a.typeName) ?? null;
426
+ if (f && f.status === l.Stable && a.status === l.Dev)
427
+ throw new Error(
428
+ `Type ${c} was stable previously and cannot be downgraded to dev. Use a new logical name instead.`
429
+ );
430
+ const p = n.get(c) ?? a.content, y = a.status === l.Dev ? Te({ blueId: u, nextRepoVersionIndex: r, previousType: f }) : !f || f.status === l.Dev ? Ae({ blueId: u, nextRepoVersionIndex: r }) : Se({
431
+ alias: c,
432
+ blueId: u,
433
+ nextRepoVersionIndex: r,
434
+ previousType: f,
435
+ currentContent: p,
436
+ packageName: a.packageName,
437
+ typeName: a.typeName,
438
+ blueIdAliases: i
439
+ });
440
+ y.content = p, y.status = a.status;
441
+ const b = o.get(a.packageName) ?? [];
442
+ b.push(y), o.set(a.packageName, b);
443
+ }
444
+ return o;
445
+ }
446
+ function ve(e, s) {
447
+ const t = /* @__PURE__ */ new Map(), n = (r, o) => {
448
+ const i = t.get(r);
449
+ if (i) {
450
+ i.add(o);
451
+ return;
452
+ }
453
+ t.set(r, /* @__PURE__ */ new Set([o]));
454
+ };
455
+ for (const [r, o] of e)
456
+ for (const [i, c] of o) {
457
+ const a = `${r}/${i}`;
458
+ for (const u of c.versions ?? [])
459
+ typeof u.typeBlueId == "string" && n(u.typeBlueId, a);
460
+ }
461
+ for (const [r, o] of s)
462
+ n(o, r);
463
+ return t;
464
+ }
465
+ function Te({
466
+ blueId: e,
467
+ nextRepoVersionIndex: s,
468
+ previousType: t
469
+ }) {
470
+ const n = t && t.status === l.Dev ? t : null, r = n?.versions?.length === 1 ? n.versions[0] : null, o = r && r.typeBlueId === e;
471
+ return {
472
+ status: l.Dev,
473
+ content: {},
474
+ versions: o && n?.versions ? B(n.versions) : [
475
+ {
476
+ repositoryVersionIndex: s,
477
+ typeBlueId: e,
478
+ attributesAdded: []
479
+ }
480
+ ]
481
+ };
482
+ }
483
+ function Ae({
484
+ blueId: e,
485
+ nextRepoVersionIndex: s
486
+ }) {
487
+ return {
488
+ status: l.Stable,
489
+ content: {},
490
+ versions: [
491
+ {
492
+ repositoryVersionIndex: s,
493
+ typeBlueId: e,
494
+ attributesAdded: []
495
+ }
496
+ ]
497
+ };
498
+ }
499
+ function Se({
500
+ alias: e,
501
+ blueId: s,
502
+ nextRepoVersionIndex: t,
503
+ previousType: n,
504
+ currentContent: r,
505
+ packageName: o,
506
+ typeName: i,
507
+ blueIdAliases: c
508
+ }) {
509
+ if (!h(n.content))
510
+ throw new Error(
511
+ `Type ${e} has non-object content; cannot compute diff for stable versioning.`
512
+ );
513
+ const a = de(
514
+ n.content,
515
+ r,
516
+ o,
517
+ i,
518
+ c
519
+ );
520
+ if (a.status === m.Unchanged) {
521
+ const u = B(n.versions || []), f = u.at(-1);
522
+ if (f && f.typeBlueId !== s)
523
+ throw new Error(
524
+ `Type ${e} content is unchanged but BlueId differs from previous metadata.`
525
+ );
526
+ return {
527
+ status: l.Stable,
528
+ content: {},
529
+ versions: u
530
+ };
531
+ }
532
+ if (a.status === m.NonBreaking)
533
+ return {
534
+ status: l.Stable,
535
+ content: {},
536
+ versions: [
537
+ ...B(n.versions || []),
538
+ {
539
+ repositoryVersionIndex: t,
540
+ typeBlueId: s,
541
+ attributesAdded: a.attributesAdded
542
+ }
543
+ ]
544
+ };
545
+ throw new Error(
546
+ `Breaking change detected in stable type ${e}. Introduce a new type name for breaking changes.`
547
+ );
548
+ }
549
+ function Be(e) {
550
+ return Array.from(e.entries()).map(([s, t]) => ({
551
+ name: s,
552
+ types: t.map((n) => ({
553
+ ...n,
554
+ versions: [...n.versions].sort(
555
+ (r, o) => r.repositoryVersionIndex - o.repositoryVersionIndex
556
+ )
557
+ })).sort((n, r) => {
558
+ const o = h(n.content) && typeof n.content.name == "string" ? n.content.name : "", i = h(r.content) && typeof r.content.name == "string" ? r.content.name : "";
559
+ return o.localeCompare(i);
560
+ })
561
+ })).sort((s, t) => s.name.localeCompare(t.name));
562
+ }
563
+ function Pe(e) {
564
+ return C.INSTANCE.calculateSync(
565
+ e
566
+ );
567
+ }
568
+ function ke(e, s, t) {
569
+ const n = s?.repositoryVersions.at(-1), r = !n || n !== t, o = s?.repositoryVersions ? [...s.repositoryVersions] : [];
570
+ return r && o.push(t), { document: {
571
+ name: R,
572
+ packages: e,
573
+ repositoryVersions: o
574
+ }, changed: r };
575
+ }
576
+ function Ne(e, s, t) {
577
+ const n = {
578
+ name: R,
579
+ repositoryVersions: s,
580
+ packages: Re(e, t)
581
+ };
582
+ q(n), z(n);
583
+ }
584
+ function Re(e, s) {
585
+ const t = {};
586
+ for (const n of e) {
587
+ const r = Oe(n.name, s), o = {}, i = {};
588
+ for (const c of n.types) {
589
+ const a = c.versions?.[c.versions.length - 1]?.typeBlueId;
590
+ if (!a)
591
+ throw new Error(
592
+ `Type ${n.name} is missing a current BlueId in versions.`
593
+ );
594
+ const u = $e(c);
595
+ o[a] = {
596
+ status: c.status,
597
+ name: u,
598
+ versions: c.versions ?? []
599
+ }, i[a] = c.content;
600
+ }
601
+ t[n.name] = {
602
+ name: n.name,
603
+ aliases: r,
604
+ typesMeta: o,
605
+ contents: i,
606
+ schemas: {}
607
+ };
608
+ }
609
+ return t;
610
+ }
611
+ function Oe(e, s) {
612
+ const t = {}, n = `${e}/`;
613
+ return s.forEach((r, o) => {
614
+ o.startsWith(n) && (t[o] = r);
615
+ }), t;
616
+ }
617
+ function $e(e) {
618
+ const s = h(e.content) && typeof e.content.name == "string" ? e.content.name : null;
619
+ if (!s)
620
+ throw new Error('Type content is missing required "name" field.');
621
+ return s;
622
+ }
623
+ function _e(e) {
624
+ if (!w.existsSync(e))
625
+ return { previous: null };
626
+ const s = w.readFileSync(e, "utf8"), t = j(s);
627
+ if (!t || !d(t))
628
+ throw new Error("Existing BlueRepository.blue is not a valid object.");
629
+ const n = t, r = n.packages, o = n.repositoryVersions, i = Array.isArray(r) && r.every(
630
+ (p) => d(p) && typeof p.name == "string" && Array.isArray(p.types)
631
+ ), c = Array.isArray(o) && o.every((p) => typeof p == "string");
632
+ if (!i || !c)
633
+ throw new Error(
634
+ "Invalid BlueRepository.blue structure: expected { packages: BluePackage[], repositoryVersions: string[] }"
635
+ );
636
+ const a = r, u = o, f = {
637
+ name: typeof n.name == "string" ? n.name : R,
638
+ packages: a,
639
+ repositoryVersions: u
640
+ };
641
+ return { existingYaml: s, previous: f };
642
+ }
643
+ function Ve(e) {
644
+ return H.dump(e, { lineWidth: -1 });
645
+ }
646
+ function Fe(e) {
647
+ const s = _.resolve(e.repoRoot), t = _.resolve(e.blueRepositoryPath), { existingYaml: n, previous: r } = _e(t), o = Q(s), i = we(r);
648
+ Ie(o, i);
649
+ const c = te(o), a = ne(c);
650
+ re(c, o);
651
+ const { aliasToBlueId: u, aliasToPreprocessed: f } = se(
652
+ a,
653
+ o
654
+ ), p = r ? r.repositoryVersions.length : 0, y = Ee({
655
+ discovered: o,
656
+ previousTypes: i,
657
+ aliasToBlueId: u,
658
+ aliasToPreprocessed: f,
659
+ nextRepoVersionIndex: p
660
+ }), b = Be(y), E = Pe(b), { document: I, changed: v } = ke(
661
+ b,
662
+ r,
663
+ E
664
+ );
665
+ Ne(
666
+ I.packages,
667
+ I.repositoryVersions,
668
+ u
669
+ );
670
+ const $ = Ve(I);
671
+ if (r && !v && n && n !== $)
672
+ throw new Error(
673
+ "BlueRepository.blue content differs from regenerated output while RepoBlueId is unchanged. Please revert manual edits or rerun in write mode."
674
+ );
675
+ return e.verbose && console.info(
676
+ `[repository-generator] RepoBlueId: ${E} (${v ? "changed" : "unchanged"})`
677
+ ), {
678
+ document: I,
679
+ currentRepoBlueId: E,
680
+ previousRepoBlueId: r?.repositoryVersions.at(-1),
681
+ changed: v || !n,
682
+ yaml: $,
683
+ existingYaml: n
684
+ };
685
+ }
686
+ export {
687
+ Fe as g
688
+ };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./generateRepository-Dg6UVHvd.js");exports.generateRepository=e.generateRepository;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./generateRepository-BwxSxjH3.js");exports.generateRepository=e.generateRepository;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { g as r } from "./generateRepository-BAWUEf72.mjs";
1
+ import { g as r } from "./generateRepository-C2IfsNUG.mjs";
2
2
  export {
3
3
  r as generateRepository
4
4
  };
@@ -1,9 +1,9 @@
1
- import { JsonBlueValue } from '@blue-labs/language';
1
+ import { JsonValue } from '@blue-labs/shared-utils';
2
2
  import { Alias, DiscoveredType, JsonMap } from './internalTypes';
3
3
  export declare function computeBlueIds(topoOrder: Alias[], discovered: Map<Alias, DiscoveredType>): {
4
4
  aliasToBlueId: Map<Alias, string>;
5
5
  aliasToPreprocessed: Map<Alias, JsonMap>;
6
6
  };
7
- export declare function substituteAliases(content: JsonBlueValue, aliasToBlueId: Map<Alias, string>, skipContracts?: boolean, underContracts?: boolean): JsonBlueValue;
8
- export declare function normalizeForBlueId(value: JsonBlueValue, parentHasExplicitType?: boolean): JsonBlueValue;
7
+ export declare function substituteAliases(content: JsonValue, aliasToBlueId: Map<Alias, string>, skipContracts?: boolean, underContracts?: boolean): JsonValue;
8
+ export declare function normalizeForBlueId(value: JsonValue, parentHasExplicitType?: boolean): JsonValue;
9
9
  //# sourceMappingURL=blueIds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blueIds.d.ts","sourceRoot":"","sources":["../../../src/lib/core/blueIds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAIjE,wBAAgB,cAAc,CAC5B,SAAS,EAAE,KAAK,EAAE,EAClB,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,GACrC;IACD,aAAa,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClC,mBAAmB,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CAC1C,CAwBA;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,aAAa,EACtB,aAAa,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,EACjC,aAAa,UAAQ,EACrB,cAAc,UAAQ,GACrB,aAAa,CAuDf;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,qBAAqB,UAAQ,GAC5B,aAAa,CA6Cf"}
1
+ {"version":3,"file":"blueIds.d.ts","sourceRoot":"","sources":["../../../src/lib/core/blueIds.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAIjE,wBAAgB,cAAc,CAC5B,SAAS,EAAE,KAAK,EAAE,EAClB,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,GACrC;IACD,aAAa,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClC,mBAAmB,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CAC1C,CAwBA;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,EAClB,aAAa,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,EACjC,aAAa,UAAQ,EACrB,cAAc,UAAQ,GACrB,SAAS,CAuDX;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAChB,qBAAqB,UAAQ,GAC5B,SAAS,CA2CX"}