@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.
- package/README.md +6 -0
- package/dist/bin/blue-repo-generator.js +1 -1
- package/dist/bin/blue-repo-generator.mjs +1 -1
- package/dist/{generateRepository-B7eem2l_.mjs → generateRepository-BIy5RMGX.mjs} +370 -311
- package/dist/generateRepository-n6pGl-dC.js +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/core/ExpressionPreserver.d.ts +1 -1
- package/dist/lib/core/blueIds.d.ts +1 -1
- package/dist/lib/core/blueIds.d.ts.map +1 -1
- package/dist/lib/core/builtinRuntimeTypes.d.ts +2 -0
- package/dist/lib/core/builtinRuntimeTypes.d.ts.map +1 -0
- package/dist/lib/core/constants.d.ts +3 -1
- package/dist/lib/core/constants.d.ts.map +1 -1
- package/dist/lib/core/discovery.d.ts.map +1 -1
- package/dist/lib/core/internalTypes.d.ts +1 -1
- package/dist/lib/core/mergingProcessor.d.ts +1 -1
- package/dist/lib/core/repoDoc.d.ts.map +1 -1
- package/dist/lib/core/repositoryContent.d.ts +5 -0
- package/dist/lib/core/repositoryContent.d.ts.map +1 -0
- package/dist/lib/core/utils.d.ts +1 -1
- package/dist/lib/core/versions.d.ts.map +1 -1
- package/dist/lib/generateRepository.d.ts.map +1 -1
- package/dist/lib/types.d.ts +2 -2
- package/package.json +4 -4
- package/dist/generateRepository-DUT9zf8k.js +0 -1
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as j from "path";
|
|
2
|
+
import $ from "path";
|
|
3
3
|
import A from "fs";
|
|
4
|
-
import { Properties as G, yamlBlueParse as
|
|
5
|
-
import { OBJECT_CONTRACTS as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
const
|
|
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
|
-
},
|
|
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
|
|
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() ||
|
|
42
|
+
if (!t.isDirectory() || ye.has(t.name))
|
|
24
43
|
continue;
|
|
25
|
-
const o =
|
|
44
|
+
const o = $.join(e, t.name), s = J(o);
|
|
26
45
|
if (s.length !== 0)
|
|
27
|
-
for (const
|
|
28
|
-
const c =
|
|
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 ${
|
|
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 ${
|
|
52
|
+
`Type ${u} is defined multiple times (${l.filePath} and ${i}).`
|
|
34
53
|
);
|
|
35
|
-
const y =
|
|
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:
|
|
41
|
-
filePath:
|
|
59
|
+
content: a,
|
|
60
|
+
filePath: i,
|
|
42
61
|
references: y
|
|
43
62
|
});
|
|
44
63
|
}
|
|
45
64
|
}
|
|
46
65
|
return n;
|
|
47
66
|
}
|
|
48
|
-
function
|
|
49
|
-
const r = A.readFileSync(e, "utf8"), n =
|
|
50
|
-
if (!
|
|
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
|
|
55
|
-
if (!
|
|
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
|
|
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(...
|
|
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(
|
|
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
|
|
89
|
+
function we(e, r) {
|
|
71
90
|
const n = /* @__PURE__ */ new Set(), t = (o) => {
|
|
72
91
|
if (Array.isArray(o)) {
|
|
73
|
-
o.forEach((
|
|
92
|
+
o.forEach((i) => t(i));
|
|
74
93
|
return;
|
|
75
94
|
}
|
|
76
|
-
if (!
|
|
95
|
+
if (!P(o))
|
|
77
96
|
return;
|
|
78
|
-
const s = (
|
|
79
|
-
if (typeof
|
|
80
|
-
if (!
|
|
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 "${
|
|
101
|
+
`Invalid type reference "${i}" in ${r}. Use <Package>/<Type> for non-primitive references.`
|
|
83
102
|
);
|
|
84
|
-
n.add(
|
|
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((
|
|
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
|
|
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
|
|
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
|
|
147
|
+
function ve(e) {
|
|
110
148
|
const r = [], n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = [], s = /* @__PURE__ */ new Set();
|
|
111
|
-
let
|
|
112
|
-
const c = (
|
|
113
|
-
n.set(
|
|
114
|
-
for (const u of e.get(
|
|
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
|
-
|
|
155
|
+
a,
|
|
118
156
|
Math.min(
|
|
119
|
-
t.get(
|
|
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
|
-
|
|
127
|
-
Math.min(t.get(
|
|
164
|
+
a,
|
|
165
|
+
Math.min(t.get(a) ?? 0, n.get(u) ?? 0)
|
|
128
166
|
);
|
|
129
167
|
}
|
|
130
|
-
if (t.get(
|
|
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 ===
|
|
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
|
|
141
|
-
n.has(
|
|
178
|
+
for (const a of e.keys())
|
|
179
|
+
n.has(a) || c(a);
|
|
142
180
|
return r;
|
|
143
181
|
}
|
|
144
|
-
function
|
|
145
|
-
const r =
|
|
146
|
-
r.forEach((c,
|
|
147
|
-
c.forEach((f) => n.set(f,
|
|
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,
|
|
189
|
+
(c, a) => t.set(a, /* @__PURE__ */ new Set())
|
|
152
190
|
);
|
|
153
|
-
for (const [c,
|
|
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
|
|
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(),
|
|
199
|
+
const o = [], s = /* @__PURE__ */ new Set(), i = (c) => {
|
|
162
200
|
if (!s.has(c)) {
|
|
163
201
|
s.add(c);
|
|
164
|
-
for (const
|
|
165
|
-
a
|
|
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
|
-
|
|
208
|
+
i(c);
|
|
171
209
|
return o.map((c) => r[c] ?? []);
|
|
172
210
|
}
|
|
173
|
-
function
|
|
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
|
|
181
|
-
for (const c of
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
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
|
|
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 (
|
|
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
|
|
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
|
|
219
|
-
class
|
|
256
|
+
const Ae = /^\$\{([\s\S]*)\}$/;
|
|
257
|
+
class Se {
|
|
220
258
|
process(r, n) {
|
|
221
259
|
const t = n.getValue();
|
|
222
|
-
if (
|
|
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 (
|
|
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
|
|
238
|
-
return typeof e != "string" || !
|
|
239
|
-
}
|
|
240
|
-
function
|
|
241
|
-
return new
|
|
242
|
-
new
|
|
243
|
-
new
|
|
244
|
-
new
|
|
245
|
-
new
|
|
246
|
-
new
|
|
247
|
-
new
|
|
248
|
-
new
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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 (
|
|
261
|
-
|
|
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 &&
|
|
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
|
|
287
|
-
const n =
|
|
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
|
|
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
|
|
309
|
-
return e ===
|
|
356
|
+
function ke(e) {
|
|
357
|
+
return e === K || /^this#\d+$/.test(e);
|
|
310
358
|
}
|
|
311
|
-
function
|
|
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,
|
|
325
|
-
const c = t || s ===
|
|
326
|
-
if ((s === "type" || s === "itemType" || s === "keyType" || s === "valueType") && typeof
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
if (!
|
|
330
|
-
throw new Error(`Missing primitive BlueId for ${
|
|
331
|
-
o[s] = { blueId:
|
|
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
|
|
381
|
+
const a = i, f = r(a);
|
|
334
382
|
if (!f)
|
|
335
|
-
throw new Error(`Missing BlueId for alias ${
|
|
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
|
-
|
|
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
|
|
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:
|
|
405
|
+
const { node: i, storageContent: c } = R(
|
|
358
406
|
r,
|
|
359
407
|
(g) => t.get(g),
|
|
360
408
|
s.blue
|
|
361
|
-
),
|
|
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),
|
|
414
|
+
t.set(e, l), o.set(e, y), a || s.contentByBlueId.set(l, y), s.blue.registerBlueIds({ [e]: l });
|
|
367
415
|
}
|
|
368
|
-
function
|
|
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
|
|
424
|
+
const i = new Set(e), c = /* @__PURE__ */ new Map();
|
|
377
425
|
e.forEach((d, p) => c.set(d, p));
|
|
378
|
-
const
|
|
379
|
-
const p =
|
|
426
|
+
const a = e.map((d) => {
|
|
427
|
+
const p = C(r, d), { node: b } = R(
|
|
380
428
|
p,
|
|
381
|
-
(
|
|
429
|
+
(h) => i.has(h) ? K : t.get(h),
|
|
382
430
|
s.blue
|
|
383
431
|
);
|
|
384
432
|
return {
|
|
385
433
|
alias: d,
|
|
386
|
-
preliminaryBlueId:
|
|
434
|
+
preliminaryBlueId: q.calculateBlueIdAllowingCyclicPlaceholdersSync(b)
|
|
387
435
|
};
|
|
388
436
|
});
|
|
389
|
-
|
|
437
|
+
Ve(a), a.sort(Oe);
|
|
390
438
|
const f = /* @__PURE__ */ new Map();
|
|
391
|
-
|
|
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 =
|
|
444
|
+
const p = C(r, d), b = R(
|
|
397
445
|
p,
|
|
398
|
-
(
|
|
399
|
-
if (!
|
|
400
|
-
return t.get(
|
|
401
|
-
const
|
|
402
|
-
if (
|
|
403
|
-
throw new Error(`Failed to resolve cyclic reference ${
|
|
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 =
|
|
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
|
-
|
|
471
|
+
Ce(s.contentByBlueId, l);
|
|
424
472
|
return;
|
|
425
473
|
}
|
|
426
|
-
const y =
|
|
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 =
|
|
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
|
-
}),
|
|
437
|
-
s.contentByBlueId.set(
|
|
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
|
|
442
|
-
t.set(d,
|
|
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
|
|
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
|
|
452
|
-
const t =
|
|
499
|
+
function R(e, r, n) {
|
|
500
|
+
const t = _(
|
|
453
501
|
S(e.content),
|
|
454
502
|
r
|
|
455
|
-
)
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
|
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
|
|
523
|
+
function Re(e, r, n, t) {
|
|
468
524
|
const o = /* @__PURE__ */ new Map();
|
|
469
525
|
for (const s of e) {
|
|
470
|
-
const
|
|
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
|
|
529
|
+
const a = X(
|
|
474
530
|
n,
|
|
475
|
-
|
|
531
|
+
i,
|
|
476
532
|
c.storageContent
|
|
477
533
|
);
|
|
478
|
-
if (!
|
|
534
|
+
if (!a)
|
|
479
535
|
return null;
|
|
480
|
-
o.set(s,
|
|
536
|
+
o.set(s, a);
|
|
481
537
|
}
|
|
482
538
|
return o;
|
|
483
539
|
}
|
|
484
|
-
function
|
|
540
|
+
function X(e, r, n) {
|
|
485
541
|
const t = e.get(r.packageName)?.get(r.typeName), o = t?.versions?.at(-1)?.typeBlueId;
|
|
486
|
-
|
|
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(
|
|
489
|
-
};
|
|
549
|
+
content: S(s)
|
|
550
|
+
} : null;
|
|
490
551
|
}
|
|
491
|
-
function
|
|
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 =
|
|
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
|
|
500
|
-
|
|
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
|
|
504
|
-
if (c.index !==
|
|
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 ${
|
|
567
|
+
`Cyclic repository content for ${t} is missing index ${a}.`
|
|
507
568
|
);
|
|
508
569
|
return c.content;
|
|
509
570
|
});
|
|
510
|
-
e.set(t,
|
|
571
|
+
e.set(t, i);
|
|
511
572
|
}
|
|
512
573
|
}
|
|
513
|
-
function
|
|
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
|
|
585
|
+
function Oe(e, r) {
|
|
525
586
|
return e.preliminaryBlueId < r.preliminaryBlueId ? -1 : e.preliminaryBlueId > r.preliminaryBlueId ? 1 : 0;
|
|
526
587
|
}
|
|
527
|
-
function
|
|
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) =>
|
|
532
|
-
if (
|
|
533
|
-
if (!
|
|
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] &&
|
|
598
|
+
(o, s) => o === t[s] && V(e[o], r[o])
|
|
538
599
|
);
|
|
539
600
|
}
|
|
540
601
|
return !1;
|
|
541
602
|
}
|
|
542
|
-
function
|
|
543
|
-
const r =
|
|
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(
|
|
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
|
-
]),
|
|
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
|
|
559
|
-
const s =
|
|
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:
|
|
565
|
-
const
|
|
625
|
+
return { status: E.Unchanged, attributesAdded: [] };
|
|
626
|
+
const i = [];
|
|
566
627
|
let c = !1;
|
|
567
|
-
for (const
|
|
568
|
-
if (
|
|
628
|
+
for (const a of s) {
|
|
629
|
+
if (Ge(a, e, o)) {
|
|
569
630
|
c = !0;
|
|
570
631
|
continue;
|
|
571
632
|
}
|
|
572
|
-
if (
|
|
573
|
-
return { status:
|
|
574
|
-
if (!
|
|
575
|
-
return { status:
|
|
576
|
-
|
|
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
|
|
579
|
-
status:
|
|
639
|
+
return i.length === 0 && !c ? {
|
|
640
|
+
status: E.Breaking,
|
|
580
641
|
attributesAdded: []
|
|
581
|
-
} : (
|
|
642
|
+
} : (i.length > 0 && Le(i, n, t), { status: E.NonBreaking, attributesAdded: i });
|
|
582
643
|
}
|
|
583
|
-
function
|
|
644
|
+
function Le(e, r, n) {
|
|
584
645
|
for (const t of e)
|
|
585
646
|
try {
|
|
586
|
-
|
|
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
|
|
654
|
+
function Fe(e) {
|
|
594
655
|
if (e.op !== "add")
|
|
595
656
|
return !1;
|
|
596
|
-
const r =
|
|
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 &&
|
|
601
|
-
(t) =>
|
|
602
|
-
) ? !1 : I(e.value) ? !
|
|
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
|
|
665
|
+
function Z(e) {
|
|
605
666
|
try {
|
|
606
|
-
return
|
|
667
|
+
return ce(e);
|
|
607
668
|
} catch {
|
|
608
669
|
return [];
|
|
609
670
|
}
|
|
610
671
|
}
|
|
611
|
-
function
|
|
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,
|
|
619
|
-
const t = n[
|
|
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 !==
|
|
685
|
+
t !== k && I(o) && r.push(o);
|
|
625
686
|
}
|
|
626
687
|
}
|
|
627
688
|
return !1;
|
|
628
689
|
}
|
|
629
|
-
function
|
|
690
|
+
function Ge(e, r, n) {
|
|
630
691
|
if (e.op !== "replace" || typeof e.path != "string")
|
|
631
692
|
return !1;
|
|
632
|
-
const t =
|
|
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
|
|
639
|
-
if (c && F.has(c) ||
|
|
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(
|
|
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
|
|
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
|
|
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,
|
|
673
|
-
|
|
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
|
|
740
|
+
function Je(e, r) {
|
|
680
741
|
for (const [n, t] of r)
|
|
681
742
|
for (const [o, s] of t) {
|
|
682
|
-
const
|
|
683
|
-
if (!e.has(
|
|
743
|
+
const i = `${n}/${o}`;
|
|
744
|
+
if (!e.has(i) && s.status === m.Stable)
|
|
684
745
|
throw new Error(
|
|
685
|
-
`Stable type ${
|
|
746
|
+
`Stable type ${i} was removed. Breaking changes require a new logical type name.`
|
|
686
747
|
);
|
|
687
748
|
}
|
|
688
749
|
}
|
|
689
|
-
function
|
|
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(),
|
|
697
|
-
for (const [c,
|
|
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(
|
|
702
|
-
if (u && u.status === m.Stable &&
|
|
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) ??
|
|
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:
|
|
713
|
-
typeName:
|
|
714
|
-
blueIdAliases:
|
|
773
|
+
packageName: a.packageName,
|
|
774
|
+
typeName: a.typeName,
|
|
775
|
+
blueIdAliases: i
|
|
715
776
|
});
|
|
716
|
-
y.content = l, y.status =
|
|
717
|
-
const g = s.get(
|
|
718
|
-
g.push(y), s.set(
|
|
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
|
|
783
|
+
function Ke(e, r) {
|
|
723
784
|
const n = /* @__PURE__ */ new Map(), t = (o, s) => {
|
|
724
|
-
const
|
|
725
|
-
if (
|
|
726
|
-
|
|
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 [
|
|
733
|
-
const
|
|
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,
|
|
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
|
|
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 ?
|
|
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
|
|
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
|
|
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:
|
|
843
|
+
typeName: i,
|
|
783
844
|
blueIdAliases: c
|
|
784
845
|
}) {
|
|
785
|
-
if (!
|
|
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
|
|
790
|
-
t.content
|
|
850
|
+
const a = N(
|
|
851
|
+
t.content
|
|
852
|
+
), f = Ue(
|
|
853
|
+
a,
|
|
791
854
|
o,
|
|
792
855
|
s,
|
|
793
|
-
|
|
856
|
+
i,
|
|
794
857
|
c
|
|
795
858
|
);
|
|
796
|
-
if (
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
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:
|
|
868
|
+
versions: u
|
|
806
869
|
};
|
|
807
870
|
}
|
|
808
|
-
if (
|
|
871
|
+
if (f.status === E.NonBreaking)
|
|
809
872
|
return {
|
|
810
873
|
status: m.Stable,
|
|
811
874
|
content: {},
|
|
812
875
|
versions: [
|
|
813
|
-
...
|
|
876
|
+
...M(t.versions || []),
|
|
814
877
|
{
|
|
815
878
|
repositoryVersionIndex: n,
|
|
816
879
|
typeBlueId: r,
|
|
817
|
-
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
|
|
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 =
|
|
835
|
-
return s.localeCompare(
|
|
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
|
|
840
|
-
return
|
|
902
|
+
function Y(e) {
|
|
903
|
+
return q.INSTANCE.calculateAllowingCyclicPlaceholdersSync(
|
|
841
904
|
e
|
|
842
905
|
);
|
|
843
906
|
}
|
|
844
|
-
function
|
|
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:
|
|
910
|
+
name: x,
|
|
848
911
|
packages: e,
|
|
849
912
|
repositoryVersions: s
|
|
850
913
|
}, changed: o };
|
|
851
914
|
}
|
|
852
|
-
function
|
|
915
|
+
function tt(e, r, n) {
|
|
853
916
|
const t = {
|
|
854
|
-
name:
|
|
917
|
+
name: x,
|
|
855
918
|
repositoryVersions: r,
|
|
856
|
-
packages:
|
|
919
|
+
packages: nt(e, n)
|
|
857
920
|
};
|
|
858
|
-
|
|
921
|
+
ue(t);
|
|
859
922
|
}
|
|
860
|
-
function
|
|
923
|
+
function nt(e, r) {
|
|
861
924
|
const n = {};
|
|
862
925
|
for (const t of e) {
|
|
863
|
-
const o =
|
|
926
|
+
const o = rt(t.name, r), s = {}, i = {};
|
|
864
927
|
for (const c of t.types) {
|
|
865
|
-
const
|
|
866
|
-
if (!
|
|
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 =
|
|
871
|
-
s[
|
|
933
|
+
const f = ot(c);
|
|
934
|
+
s[a] = {
|
|
872
935
|
status: c.status,
|
|
873
936
|
name: f,
|
|
874
937
|
versions: c.versions ?? []
|
|
875
|
-
}, a
|
|
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:
|
|
944
|
+
contents: i,
|
|
882
945
|
schemas: {}
|
|
883
946
|
};
|
|
884
947
|
}
|
|
885
948
|
return n;
|
|
886
949
|
}
|
|
887
|
-
function
|
|
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
|
|
894
|
-
const r =
|
|
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
|
|
962
|
+
function st(e) {
|
|
900
963
|
if (!A.existsSync(e))
|
|
901
964
|
return { previous: null };
|
|
902
|
-
const r = A.readFileSync(e, "utf8"), n =
|
|
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,
|
|
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 (!
|
|
971
|
+
if (!i || !c)
|
|
909
972
|
throw new Error(
|
|
910
973
|
"Invalid BlueRepository.blue structure: expected { packages: BluePackage[], repositoryVersions: string[] }"
|
|
911
974
|
);
|
|
912
|
-
const
|
|
913
|
-
name: typeof t.name == "string" ? t.name :
|
|
914
|
-
packages:
|
|
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
|
|
920
|
-
return
|
|
982
|
+
function it(e) {
|
|
983
|
+
return le.dump(e, { lineWidth: -1 });
|
|
921
984
|
}
|
|
922
|
-
function
|
|
923
|
-
const r =
|
|
924
|
-
|
|
925
|
-
const c =
|
|
926
|
-
|
|
927
|
-
const { aliasToBlueId: f, aliasToStorageContent: u } =
|
|
928
|
-
|
|
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
|
-
|
|
932
|
-
), l = o ? o.repositoryVersions.length : 0, y =
|
|
994
|
+
i
|
|
995
|
+
), l = o ? o.repositoryVersions.length : 0, y = ze({
|
|
933
996
|
discovered: s,
|
|
934
|
-
previousTypes:
|
|
997
|
+
previousTypes: i,
|
|
935
998
|
aliasToBlueId: f,
|
|
936
999
|
aliasToStorageContent: u,
|
|
937
1000
|
nextRepoVersionIndex: l
|
|
938
|
-
}), g =
|
|
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
|
-
|
|
1004
|
+
B
|
|
942
1005
|
);
|
|
943
|
-
|
|
1006
|
+
tt(
|
|
944
1007
|
d.packages,
|
|
945
1008
|
d.repositoryVersions,
|
|
946
1009
|
f
|
|
947
1010
|
);
|
|
948
|
-
const b =
|
|
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: ${
|
|
1013
|
+
`[repository-generator] RepoBlueId: ${B} (${p ? "changed" : "unchanged"})`
|
|
955
1014
|
), {
|
|
956
1015
|
document: d,
|
|
957
|
-
currentRepoBlueId:
|
|
1016
|
+
currentRepoBlueId: B,
|
|
958
1017
|
previousRepoBlueId: o?.repositoryVersions.at(-1),
|
|
959
|
-
changed: p || !
|
|
1018
|
+
changed: p || !h,
|
|
960
1019
|
yaml: b,
|
|
961
1020
|
existingYaml: t
|
|
962
1021
|
};
|
|
963
1022
|
}
|
|
964
|
-
function
|
|
1023
|
+
function at(e, r) {
|
|
965
1024
|
return JSON.stringify(e) === JSON.stringify(r);
|
|
966
1025
|
}
|
|
967
1026
|
export {
|
|
968
|
-
|
|
1027
|
+
yt as g
|
|
969
1028
|
};
|