@dialecte/scl 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dialecte.config-BkqCz0VE.js → index-BsKA2oVp.js} +1162 -595
- package/dist/v2019C1/index.js +15 -589
- package/dist/v2019C1/test/hydrated-test.d.ts +44 -2
- package/dist/v2019C1/test/hydrated-test.d.ts.map +1 -1
- package/dist/v2019C1/test/hydrated-test.types.d.ts +4 -3
- package/dist/v2019C1/test/hydrated-test.types.d.ts.map +1 -1
- package/dist/v2019C1/test.js +22 -17
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toRawRecord as
|
|
2
|
-
import { invariant as
|
|
3
|
-
const
|
|
1
|
+
import { toRawRecord as p, isElementOf as M, isChildOf as I, stripAttributes as Ce } from "@dialecte/core/helpers";
|
|
2
|
+
import { invariant as F } from "@dialecte/core/utils";
|
|
3
|
+
const ge = [
|
|
4
4
|
"AccessControl",
|
|
5
5
|
"AccessPoint",
|
|
6
6
|
"Address",
|
|
@@ -211,7 +211,7 @@ const H = [
|
|
|
211
211
|
"VariableRef",
|
|
212
212
|
"Voltage",
|
|
213
213
|
"VoltageLevel"
|
|
214
|
-
],
|
|
214
|
+
], ve = {
|
|
215
215
|
AccessControl: [],
|
|
216
216
|
AccessPoint: [
|
|
217
217
|
"Text",
|
|
@@ -779,7 +779,7 @@ const H = [
|
|
|
779
779
|
"ProcessResources",
|
|
780
780
|
"Variable"
|
|
781
781
|
]
|
|
782
|
-
},
|
|
782
|
+
}, Te = {
|
|
783
783
|
AccessControl: ["LDevice"],
|
|
784
784
|
AccessPoint: ["IED"],
|
|
785
785
|
Address: ["ConnectedAP", "GSE", "SMV"],
|
|
@@ -3255,7 +3255,7 @@ const H = [
|
|
|
3255
3255
|
"VariableRef",
|
|
3256
3256
|
"Voltage"
|
|
3257
3257
|
]
|
|
3258
|
-
},
|
|
3258
|
+
}, he = {
|
|
3259
3259
|
AccessControl: ["AccessPoint", "IED", "LDevice", "SCL", "Server"],
|
|
3260
3260
|
AccessPoint: ["IED", "SCL"],
|
|
3261
3261
|
Address: ["Communication", "ConnectedAP", "GSE", "SCL", "SMV", "SubNetwork"],
|
|
@@ -4933,13 +4933,13 @@ const H = [
|
|
|
4933
4933
|
],
|
|
4934
4934
|
Voltage: ["Line", "Process", "SCL", "Substation", "VoltageLevel"],
|
|
4935
4935
|
VoltageLevel: ["Process", "SCL", "Substation"]
|
|
4936
|
-
},
|
|
4936
|
+
}, Ne = "SCL", Ie = [
|
|
4937
4937
|
"Communication",
|
|
4938
4938
|
"DataTypeTemplates",
|
|
4939
4939
|
"Header",
|
|
4940
4940
|
"History",
|
|
4941
4941
|
"SCL"
|
|
4942
|
-
],
|
|
4942
|
+
], Q = {
|
|
4943
4943
|
AccessControl: {},
|
|
4944
4944
|
AccessPoint: {
|
|
4945
4945
|
clock: "",
|
|
@@ -6256,7 +6256,7 @@ const H = [
|
|
|
6256
6256
|
templateUuid: "",
|
|
6257
6257
|
uuid: ""
|
|
6258
6258
|
}
|
|
6259
|
-
},
|
|
6259
|
+
}, G = {
|
|
6260
6260
|
AccessControl: {
|
|
6261
6261
|
tag: "AccessControl",
|
|
6262
6262
|
namespace: { prefix: "", uri: "http://www.iec.ch/61850/2003/SCL" },
|
|
@@ -21145,133 +21145,133 @@ const H = [
|
|
|
21145
21145
|
]
|
|
21146
21146
|
}
|
|
21147
21147
|
};
|
|
21148
|
-
async function
|
|
21149
|
-
const { childRecord:
|
|
21150
|
-
if (
|
|
21148
|
+
async function we(e) {
|
|
21149
|
+
const { childRecord: a, parentRecord: t, query: i } = e;
|
|
21150
|
+
if (a.namespace.prefix === P.namespaces.default.prefix)
|
|
21151
21151
|
return [];
|
|
21152
|
-
const n = t.tagName === "Private",
|
|
21153
|
-
if (!n && !
|
|
21152
|
+
const n = t.tagName === "Private", r = t.namespace.prefix === P.namespaces.default.prefix;
|
|
21153
|
+
if (!n && !r)
|
|
21154
21154
|
return [];
|
|
21155
|
-
const
|
|
21155
|
+
const s = t.children.find((l) => l.tagName === "Private"), u = {
|
|
21156
21156
|
...t,
|
|
21157
|
-
children: t.children.filter((
|
|
21157
|
+
children: t.children.filter((l) => l.id !== a.id)
|
|
21158
21158
|
};
|
|
21159
|
-
return n ?
|
|
21160
|
-
existingPrivateRef:
|
|
21159
|
+
return n ? De({ parentRecord: t, childRecord: a, query: i }) : s ? Fe({
|
|
21160
|
+
existingPrivateRef: s,
|
|
21161
21161
|
parentRecord: t,
|
|
21162
|
-
updatedParentRecord:
|
|
21163
|
-
childRecord:
|
|
21162
|
+
updatedParentRecord: u,
|
|
21163
|
+
childRecord: a,
|
|
21164
21164
|
query: i
|
|
21165
21165
|
}) : (await i.findAncestors(t)).some(
|
|
21166
|
-
(
|
|
21167
|
-
(
|
|
21166
|
+
(l) => l.tagName === "Private" && l.attributes.some(
|
|
21167
|
+
(d) => d.name === "type" && d.value === a.namespace.prefix
|
|
21168
21168
|
)
|
|
21169
|
-
) ? [] :
|
|
21169
|
+
) ? [] : ye({ parentRecord: t, updatedParentRecord: u, childRecord: a });
|
|
21170
21170
|
}
|
|
21171
|
-
async function
|
|
21172
|
-
const { parentRecord:
|
|
21171
|
+
async function De(e) {
|
|
21172
|
+
const { parentRecord: a, childRecord: t, query: i } = e, n = a;
|
|
21173
21173
|
if (t.parent?.id === n.id && t.parent?.tagName === "Private")
|
|
21174
21174
|
return [];
|
|
21175
|
-
const
|
|
21176
|
-
|
|
21175
|
+
const r = await Y({ privateId: n.id, query: i });
|
|
21176
|
+
F(r, {
|
|
21177
21177
|
detail: "Latest private record not found",
|
|
21178
21178
|
key: "ELEMENT_NOT_FOUND"
|
|
21179
21179
|
});
|
|
21180
|
-
const { childRecord:
|
|
21181
|
-
privateRecord:
|
|
21180
|
+
const { childRecord: s, privateRecord: u } = j({
|
|
21181
|
+
privateRecord: r,
|
|
21182
21182
|
childRecord: t
|
|
21183
21183
|
});
|
|
21184
21184
|
return [
|
|
21185
21185
|
{
|
|
21186
21186
|
status: "updated",
|
|
21187
|
-
oldRecord:
|
|
21188
|
-
newRecord:
|
|
21187
|
+
oldRecord: p(t),
|
|
21188
|
+
newRecord: p(s)
|
|
21189
21189
|
},
|
|
21190
21190
|
{
|
|
21191
21191
|
status: "updated",
|
|
21192
|
-
oldRecord:
|
|
21193
|
-
newRecord:
|
|
21192
|
+
oldRecord: p(r),
|
|
21193
|
+
newRecord: p(u)
|
|
21194
21194
|
}
|
|
21195
21195
|
];
|
|
21196
21196
|
}
|
|
21197
|
-
async function
|
|
21198
|
-
const { existingPrivateRef:
|
|
21199
|
-
privateId:
|
|
21200
|
-
query:
|
|
21197
|
+
async function Fe(e) {
|
|
21198
|
+
const { existingPrivateRef: a, parentRecord: t, updatedParentRecord: i, childRecord: n, query: r } = e, s = await Y({
|
|
21199
|
+
privateId: a.id,
|
|
21200
|
+
query: r
|
|
21201
21201
|
});
|
|
21202
|
-
if (
|
|
21202
|
+
if (F(s, {
|
|
21203
21203
|
detail: "Latest private record not found",
|
|
21204
21204
|
key: "ELEMENT_NOT_FOUND"
|
|
21205
|
-
}), !
|
|
21206
|
-
(
|
|
21205
|
+
}), !s.attributes.some(
|
|
21206
|
+
(l) => l.name === "type" && l.value === n.namespace.prefix
|
|
21207
21207
|
)) return [];
|
|
21208
|
-
const { childRecord: c, privateRecord:
|
|
21209
|
-
privateRecord:
|
|
21208
|
+
const { childRecord: c, privateRecord: o } = j({
|
|
21209
|
+
privateRecord: s,
|
|
21210
21210
|
childRecord: n
|
|
21211
21211
|
});
|
|
21212
21212
|
return [
|
|
21213
21213
|
{
|
|
21214
21214
|
status: "updated",
|
|
21215
|
-
oldRecord:
|
|
21216
|
-
newRecord:
|
|
21215
|
+
oldRecord: p(n),
|
|
21216
|
+
newRecord: p(c)
|
|
21217
21217
|
},
|
|
21218
21218
|
{
|
|
21219
21219
|
status: "updated",
|
|
21220
|
-
oldRecord:
|
|
21221
|
-
newRecord:
|
|
21220
|
+
oldRecord: p(s),
|
|
21221
|
+
newRecord: p(o)
|
|
21222
21222
|
},
|
|
21223
21223
|
{
|
|
21224
21224
|
status: "updated",
|
|
21225
|
-
oldRecord:
|
|
21226
|
-
newRecord:
|
|
21225
|
+
oldRecord: p(t),
|
|
21226
|
+
newRecord: p(i)
|
|
21227
21227
|
}
|
|
21228
21228
|
];
|
|
21229
21229
|
}
|
|
21230
|
-
function
|
|
21231
|
-
const { parentRecord:
|
|
21230
|
+
function ye(e) {
|
|
21231
|
+
const { parentRecord: a, updatedParentRecord: t, childRecord: i } = e, n = {
|
|
21232
21232
|
id: crypto.randomUUID(),
|
|
21233
21233
|
tagName: "Private",
|
|
21234
21234
|
namespace: P.namespaces.default,
|
|
21235
21235
|
attributes: [{ name: "type", value: i.namespace.prefix }],
|
|
21236
21236
|
value: "",
|
|
21237
|
-
parent: { id:
|
|
21237
|
+
parent: { id: a.id, tagName: a.tagName },
|
|
21238
21238
|
children: [{ id: i.id, tagName: i.tagName }]
|
|
21239
|
-
},
|
|
21239
|
+
}, r = {
|
|
21240
21240
|
...i,
|
|
21241
21241
|
parent: { id: n.id, tagName: "Private" }
|
|
21242
|
-
},
|
|
21242
|
+
}, s = {
|
|
21243
21243
|
...t,
|
|
21244
21244
|
children: [...t.children, { id: n.id, tagName: "Private" }]
|
|
21245
21245
|
};
|
|
21246
21246
|
return [
|
|
21247
|
-
{ status: "created", oldRecord: void 0, newRecord:
|
|
21247
|
+
{ status: "created", oldRecord: void 0, newRecord: p(n) },
|
|
21248
21248
|
{
|
|
21249
21249
|
status: "updated",
|
|
21250
|
-
oldRecord:
|
|
21251
|
-
newRecord:
|
|
21250
|
+
oldRecord: p(i),
|
|
21251
|
+
newRecord: p(r)
|
|
21252
21252
|
},
|
|
21253
21253
|
{
|
|
21254
21254
|
status: "updated",
|
|
21255
|
-
oldRecord:
|
|
21256
|
-
newRecord:
|
|
21255
|
+
oldRecord: p(a),
|
|
21256
|
+
newRecord: p(s)
|
|
21257
21257
|
}
|
|
21258
21258
|
];
|
|
21259
21259
|
}
|
|
21260
|
-
async function
|
|
21261
|
-
const { privateId:
|
|
21262
|
-
return await t.getRecord({ id:
|
|
21260
|
+
async function Y(e) {
|
|
21261
|
+
const { privateId: a, query: t } = e;
|
|
21262
|
+
return await t.getRecord({ id: a, tagName: "Private" });
|
|
21263
21263
|
}
|
|
21264
|
-
function
|
|
21265
|
-
const { privateRecord:
|
|
21264
|
+
function j(e) {
|
|
21265
|
+
const { privateRecord: a, childRecord: t } = e, i = {
|
|
21266
21266
|
...t,
|
|
21267
|
-
parent: { id:
|
|
21267
|
+
parent: { id: a.id, tagName: "Private" }
|
|
21268
21268
|
}, n = {
|
|
21269
|
-
...
|
|
21270
|
-
children: [...
|
|
21269
|
+
...a,
|
|
21270
|
+
children: [...a.children, { id: t.id, tagName: t.tagName }]
|
|
21271
21271
|
};
|
|
21272
21272
|
return { childRecord: i, privateRecord: n };
|
|
21273
21273
|
}
|
|
21274
|
-
const
|
|
21274
|
+
const $ = {
|
|
21275
21275
|
// Transparent - do not contribute a path segment
|
|
21276
21276
|
AccessPoint: { type: "transparent" },
|
|
21277
21277
|
Server: { type: "transparent" },
|
|
@@ -21329,17 +21329,17 @@ const y = {
|
|
|
21329
21329
|
PowerSystemRelation: { type: "name" },
|
|
21330
21330
|
Variable: { type: "name" },
|
|
21331
21331
|
Process: { type: "name" }
|
|
21332
|
-
},
|
|
21333
|
-
Object.values(
|
|
21334
|
-
switch (
|
|
21332
|
+
}, qe = ["lnClass", "prefix", "inst", "lnInst"], xe = new Set(
|
|
21333
|
+
Object.values($).flatMap((e) => {
|
|
21334
|
+
switch (e.type) {
|
|
21335
21335
|
case "transparent":
|
|
21336
21336
|
return [];
|
|
21337
21337
|
case "name":
|
|
21338
21338
|
return ["name"];
|
|
21339
21339
|
case "lnClass":
|
|
21340
|
-
return [...
|
|
21340
|
+
return [...qe];
|
|
21341
21341
|
case "attribute":
|
|
21342
|
-
return [
|
|
21342
|
+
return [e.attr];
|
|
21343
21343
|
case "sourceRef":
|
|
21344
21344
|
return ["input", "inputInst", "pDA"];
|
|
21345
21345
|
case "controlRef":
|
|
@@ -21347,308 +21347,308 @@ const y = {
|
|
|
21347
21347
|
}
|
|
21348
21348
|
})
|
|
21349
21349
|
);
|
|
21350
|
-
function
|
|
21351
|
-
switch (
|
|
21350
|
+
function Oe(e) {
|
|
21351
|
+
switch (e.type) {
|
|
21352
21352
|
case "transparent":
|
|
21353
21353
|
return () => null;
|
|
21354
21354
|
case "name": {
|
|
21355
|
-
const
|
|
21355
|
+
const a = e.separator ?? "/";
|
|
21356
21356
|
return (t) => {
|
|
21357
|
-
const i =
|
|
21358
|
-
return i ? { segment: i, separator:
|
|
21357
|
+
const i = R(t, "name");
|
|
21358
|
+
return i ? { segment: i, separator: a } : null;
|
|
21359
21359
|
};
|
|
21360
21360
|
}
|
|
21361
21361
|
case "lnClass":
|
|
21362
|
-
return (
|
|
21363
|
-
const t =
|
|
21362
|
+
return (a) => {
|
|
21363
|
+
const t = R(a, "lnClass");
|
|
21364
21364
|
if (!t) return null;
|
|
21365
|
-
const i =
|
|
21365
|
+
const i = R(a, "prefix") ?? "", n = R(a, "inst") ?? R(a, "lnInst") ?? "";
|
|
21366
21366
|
return { segment: `${i}${t}${n}`, separator: "/" };
|
|
21367
21367
|
};
|
|
21368
21368
|
case "attribute":
|
|
21369
|
-
return (
|
|
21370
|
-
const t =
|
|
21371
|
-
return t ? { segment: t, separator:
|
|
21369
|
+
return (a) => {
|
|
21370
|
+
const t = R(a, e.attr);
|
|
21371
|
+
return t ? { segment: t, separator: e.separator } : null;
|
|
21372
21372
|
};
|
|
21373
21373
|
case "sourceRef":
|
|
21374
|
-
return (
|
|
21375
|
-
const t =
|
|
21374
|
+
return (a) => {
|
|
21375
|
+
const t = R(a, "input");
|
|
21376
21376
|
if (!t) return null;
|
|
21377
21377
|
let i = t;
|
|
21378
|
-
const n =
|
|
21378
|
+
const n = R(a, "inputInst");
|
|
21379
21379
|
n && n !== "1" && (i += `(${n})`);
|
|
21380
|
-
const
|
|
21381
|
-
return
|
|
21380
|
+
const r = R(a, "pDA");
|
|
21381
|
+
return r && (i += `.${r}`), { segment: i, separator: "." };
|
|
21382
21382
|
};
|
|
21383
21383
|
case "controlRef":
|
|
21384
|
-
return (
|
|
21385
|
-
const t =
|
|
21384
|
+
return (a) => {
|
|
21385
|
+
const t = R(a, "output");
|
|
21386
21386
|
if (!t) return null;
|
|
21387
21387
|
let i = t;
|
|
21388
|
-
const n =
|
|
21388
|
+
const n = R(a, "outputInst");
|
|
21389
21389
|
return n && n !== "1" && (i += `(${n})`), { segment: i, separator: "." };
|
|
21390
21390
|
};
|
|
21391
21391
|
}
|
|
21392
21392
|
}
|
|
21393
|
-
const
|
|
21394
|
-
Object.entries(
|
|
21393
|
+
const Ee = Object.fromEntries(
|
|
21394
|
+
Object.entries($).map(([e, a]) => [e, Oe(a)])
|
|
21395
21395
|
);
|
|
21396
|
-
function
|
|
21397
|
-
const
|
|
21398
|
-
return
|
|
21396
|
+
function A(e) {
|
|
21397
|
+
const a = Ee[e.tagName];
|
|
21398
|
+
return a ? a(e) : null;
|
|
21399
21399
|
}
|
|
21400
|
-
function
|
|
21401
|
-
const { record:
|
|
21402
|
-
for (const
|
|
21403
|
-
const
|
|
21404
|
-
|
|
21400
|
+
function J(e) {
|
|
21401
|
+
const { record: a, ancestry: t } = e, i = [];
|
|
21402
|
+
for (const r of t) {
|
|
21403
|
+
const s = A(r);
|
|
21404
|
+
s && i.push({ ...s, ref: { tagName: r.tagName, id: r.id } });
|
|
21405
21405
|
}
|
|
21406
|
-
const n =
|
|
21407
|
-
return n && i.push({ ...n, ref: { tagName:
|
|
21406
|
+
const n = A(a);
|
|
21407
|
+
return n && i.push({ ...n, ref: { tagName: a.tagName, id: a.id } }), i.length === 0 ? null : { path: ee(i), segments: i };
|
|
21408
21408
|
}
|
|
21409
|
-
function
|
|
21410
|
-
return
|
|
21409
|
+
function R(e, a) {
|
|
21410
|
+
return e.attributes.find((t) => t.name === a)?.value;
|
|
21411
21411
|
}
|
|
21412
|
-
function
|
|
21413
|
-
let
|
|
21414
|
-
for (let t = 1; t <
|
|
21415
|
-
|
|
21416
|
-
return
|
|
21412
|
+
function ee(e) {
|
|
21413
|
+
let a = e[0].segment;
|
|
21414
|
+
for (let t = 1; t < e.length; t++)
|
|
21415
|
+
a += e[t].separator + e[t].segment;
|
|
21416
|
+
return a;
|
|
21417
21417
|
}
|
|
21418
|
-
async function
|
|
21419
|
-
const t = await
|
|
21418
|
+
async function te(e, a) {
|
|
21419
|
+
const t = await e.getRecord(a);
|
|
21420
21420
|
if (!t) return null;
|
|
21421
|
-
const i = await
|
|
21422
|
-
return
|
|
21423
|
-
record:
|
|
21424
|
-
ancestry: i.map(
|
|
21421
|
+
const i = await e.findAncestors(a, { order: "top-down" });
|
|
21422
|
+
return J({
|
|
21423
|
+
record: p(t),
|
|
21424
|
+
ancestry: i.map(p)
|
|
21425
21425
|
});
|
|
21426
21426
|
}
|
|
21427
|
-
function
|
|
21428
|
-
if (!
|
|
21429
|
-
const
|
|
21427
|
+
function ae(e) {
|
|
21428
|
+
if (!e) return [];
|
|
21429
|
+
const a = [];
|
|
21430
21430
|
let t = "", i = "/";
|
|
21431
|
-
for (const n of
|
|
21432
|
-
n === "/" || n === "." ? (t &&
|
|
21433
|
-
return t &&
|
|
21431
|
+
for (const n of e)
|
|
21432
|
+
n === "/" || n === "." ? (t && a.push({ segment: t, separator: i }), i = n, t = "") : t += n;
|
|
21433
|
+
return t && a.push({ segment: t, separator: i }), a;
|
|
21434
21434
|
}
|
|
21435
|
-
function
|
|
21436
|
-
const
|
|
21437
|
-
if (i === -1) return { path:
|
|
21438
|
-
const n = t.substring(0, i),
|
|
21439
|
-
return { path: [...
|
|
21435
|
+
function ie(e) {
|
|
21436
|
+
const a = e.split("/"), t = a[a.length - 1], i = t.indexOf(".");
|
|
21437
|
+
if (i === -1) return { path: e };
|
|
21438
|
+
const n = t.substring(0, i), r = t.substring(i + 1);
|
|
21439
|
+
return { path: [...a.slice(0, -1), n].join("/"), qualifier: r || void 0 };
|
|
21440
21440
|
}
|
|
21441
|
-
function
|
|
21442
|
-
return !
|
|
21441
|
+
function ne(e, a, t, i) {
|
|
21442
|
+
return !e || e === b.unsupported ? null : e === b.direct ? { lookupKey: t } : e === b.iedAddress ? Ve(t, i) : e === b.lnode ? ke(t) : e === b.behaviorDescription ? Ze(a, t, i) : null;
|
|
21443
21443
|
}
|
|
21444
|
-
function
|
|
21445
|
-
const { path:
|
|
21446
|
-
return { lookupKey:
|
|
21444
|
+
function ke(e) {
|
|
21445
|
+
const { path: a, qualifier: t } = ie(e);
|
|
21446
|
+
return { lookupKey: a, qualifier: t };
|
|
21447
21447
|
}
|
|
21448
|
-
function
|
|
21449
|
-
if (
|
|
21450
|
-
const t =
|
|
21448
|
+
function Ve(e, a) {
|
|
21449
|
+
if (a) {
|
|
21450
|
+
const t = Be(a);
|
|
21451
21451
|
if (t)
|
|
21452
|
-
return { lookupKey:
|
|
21452
|
+
return { lookupKey: e, fallbackLookupKey: `${t}/${e}` };
|
|
21453
21453
|
}
|
|
21454
|
-
return { lookupKey:
|
|
21454
|
+
return { lookupKey: e };
|
|
21455
21455
|
}
|
|
21456
|
-
function
|
|
21456
|
+
function Ze(e, a, t) {
|
|
21457
21457
|
if (!t) return null;
|
|
21458
|
-
const i =
|
|
21458
|
+
const i = Me(t);
|
|
21459
21459
|
if (!i) return null;
|
|
21460
|
-
if (
|
|
21461
|
-
return { lookupKey: i, qualifier:
|
|
21462
|
-
if (
|
|
21463
|
-
const n =
|
|
21460
|
+
if (e === "dataName")
|
|
21461
|
+
return { lookupKey: i, qualifier: a };
|
|
21462
|
+
if (e === "inputName" || e === "outputName") {
|
|
21463
|
+
const n = Ge(a);
|
|
21464
21464
|
return { lookupKey: `${i}.${n}` };
|
|
21465
21465
|
}
|
|
21466
21466
|
return null;
|
|
21467
21467
|
}
|
|
21468
|
-
function
|
|
21469
|
-
let
|
|
21470
|
-
for (let i =
|
|
21471
|
-
if (
|
|
21472
|
-
|
|
21468
|
+
function Me(e) {
|
|
21469
|
+
let a = -1;
|
|
21470
|
+
for (let i = e.length - 1; i >= 0; i--)
|
|
21471
|
+
if (e[i].tagName === "BehaviorDescription") {
|
|
21472
|
+
a = i;
|
|
21473
21473
|
break;
|
|
21474
21474
|
}
|
|
21475
|
-
if (
|
|
21475
|
+
if (a === -1) return null;
|
|
21476
21476
|
const t = [];
|
|
21477
|
-
for (let i = 0; i <
|
|
21478
|
-
const n =
|
|
21477
|
+
for (let i = 0; i < a; i++) {
|
|
21478
|
+
const n = A(e[i]);
|
|
21479
21479
|
n && t.push(n);
|
|
21480
21480
|
}
|
|
21481
|
-
return t.length === 0 ? null :
|
|
21481
|
+
return t.length === 0 ? null : ee(t);
|
|
21482
21482
|
}
|
|
21483
|
-
function
|
|
21484
|
-
const
|
|
21485
|
-
return
|
|
21483
|
+
function Ge(e) {
|
|
21484
|
+
const a = e.indexOf("("), t = e.indexOf(".");
|
|
21485
|
+
return a !== -1 ? e.substring(0, a) : t !== -1 ? e.substring(0, t) : e;
|
|
21486
21486
|
}
|
|
21487
|
-
function
|
|
21488
|
-
for (let
|
|
21489
|
-
if (a
|
|
21490
|
-
return a
|
|
21487
|
+
function Be(e) {
|
|
21488
|
+
for (let a = e.length - 1; a >= 0; a--)
|
|
21489
|
+
if (e[a].tagName === "LNode")
|
|
21490
|
+
return e[a].attributes.find((t) => t.name === "iedName")?.value ?? null;
|
|
21491
21491
|
return null;
|
|
21492
21492
|
}
|
|
21493
|
-
async function
|
|
21494
|
-
const { reference: t, target: i } =
|
|
21493
|
+
async function re(e, a) {
|
|
21494
|
+
const { reference: t, target: i } = a, n = Ue(t.tagName, i.tagName);
|
|
21495
21495
|
if (!n) return null;
|
|
21496
|
-
const
|
|
21497
|
-
if (
|
|
21498
|
-
if (
|
|
21499
|
-
const c = await
|
|
21500
|
-
return c ?
|
|
21496
|
+
const r = n.resolution;
|
|
21497
|
+
if (r === b.unsupported) return null;
|
|
21498
|
+
if (r === b.behaviorDescription) {
|
|
21499
|
+
const c = await e.getRecord(i);
|
|
21500
|
+
return c ? A(p(c))?.segment ?? null : null;
|
|
21501
21501
|
}
|
|
21502
|
-
const
|
|
21503
|
-
if (!
|
|
21504
|
-
const
|
|
21505
|
-
if (
|
|
21506
|
-
const c = await
|
|
21507
|
-
if (!c) return
|
|
21508
|
-
const
|
|
21509
|
-
if (!
|
|
21510
|
-
const { qualifier:
|
|
21511
|
-
return
|
|
21502
|
+
const s = await te(e, i);
|
|
21503
|
+
if (!s) return null;
|
|
21504
|
+
const u = s.path;
|
|
21505
|
+
if (r === b.lnode) {
|
|
21506
|
+
const c = await e.getRecord(t);
|
|
21507
|
+
if (!c) return u;
|
|
21508
|
+
const o = c.attributes.find((d) => d.name === n.attribute.path)?.value;
|
|
21509
|
+
if (!o) return u;
|
|
21510
|
+
const { qualifier: l } = ie(o);
|
|
21511
|
+
return l ? `${u}.${l}` : u;
|
|
21512
21512
|
}
|
|
21513
|
-
return
|
|
21513
|
+
return u;
|
|
21514
21514
|
}
|
|
21515
|
-
function
|
|
21516
|
-
const t = m[
|
|
21517
|
-
return t ? t.find((i) => i.target.includes(
|
|
21515
|
+
function Ue(e, a) {
|
|
21516
|
+
const t = m[e];
|
|
21517
|
+
return t ? t.find((i) => i.target.includes(a)) ?? null : null;
|
|
21518
21518
|
}
|
|
21519
|
-
async function
|
|
21520
|
-
const i =
|
|
21519
|
+
async function ze(e, a, t) {
|
|
21520
|
+
const i = _e(a.tagName, t);
|
|
21521
21521
|
if (!i) return;
|
|
21522
|
-
const n =
|
|
21522
|
+
const n = a.attributes.find((d) => d.name === t)?.value;
|
|
21523
21523
|
if (!n) return;
|
|
21524
|
-
let
|
|
21525
|
-
(i.resolution ===
|
|
21526
|
-
const
|
|
21524
|
+
let r;
|
|
21525
|
+
(i.resolution === b.behaviorDescription || i.resolution === b.iedAddress) && (r = (await e.findAncestors(a, { order: "top-down" })).map((f) => p(f)));
|
|
21526
|
+
const s = ne(
|
|
21527
21527
|
i.resolution,
|
|
21528
21528
|
t,
|
|
21529
21529
|
n,
|
|
21530
|
-
|
|
21530
|
+
r
|
|
21531
21531
|
);
|
|
21532
|
-
if (!
|
|
21533
|
-
const
|
|
21534
|
-
if (
|
|
21535
|
-
const c =
|
|
21536
|
-
query:
|
|
21532
|
+
if (!s) return;
|
|
21533
|
+
const u = ae(s.lookupKey);
|
|
21534
|
+
if (u.length === 0) return;
|
|
21535
|
+
const c = u[u.length - 1], o = u.slice(0, -1), l = await Xe({
|
|
21536
|
+
query: e,
|
|
21537
21537
|
targets: i.target,
|
|
21538
21538
|
segment: c,
|
|
21539
|
-
expectedAncestry:
|
|
21539
|
+
expectedAncestry: o
|
|
21540
21540
|
});
|
|
21541
|
-
if (
|
|
21542
|
-
return { record:
|
|
21541
|
+
if (l)
|
|
21542
|
+
return { record: l, qualifier: s.qualifier };
|
|
21543
21543
|
}
|
|
21544
|
-
function
|
|
21545
|
-
const t = m[
|
|
21544
|
+
function _e(e, a) {
|
|
21545
|
+
const t = m[e];
|
|
21546
21546
|
if (t)
|
|
21547
|
-
return t.find((i) => i.attribute.path ===
|
|
21547
|
+
return t.find((i) => i.attribute.path === a);
|
|
21548
21548
|
}
|
|
21549
|
-
const
|
|
21550
|
-
|
|
21551
|
-
),
|
|
21549
|
+
const He = new Set(
|
|
21550
|
+
G.LNode.attributes.details.lnClass.facets.enumeration
|
|
21551
|
+
), We = {
|
|
21552
21552
|
LNode: "lnInst",
|
|
21553
21553
|
LN: "inst",
|
|
21554
21554
|
LN0: "inst"
|
|
21555
21555
|
};
|
|
21556
|
-
function
|
|
21557
|
-
for (let
|
|
21558
|
-
const t =
|
|
21559
|
-
if (
|
|
21556
|
+
function Ke(e) {
|
|
21557
|
+
for (let a = 0; a <= e.length - 4; a++) {
|
|
21558
|
+
const t = e.substring(a, a + 4);
|
|
21559
|
+
if (He.has(t))
|
|
21560
21560
|
return {
|
|
21561
|
-
prefix:
|
|
21561
|
+
prefix: e.substring(0, a),
|
|
21562
21562
|
lnClass: t,
|
|
21563
|
-
inst:
|
|
21563
|
+
inst: e.substring(a + 4)
|
|
21564
21564
|
};
|
|
21565
21565
|
}
|
|
21566
21566
|
return null;
|
|
21567
21567
|
}
|
|
21568
|
-
async function
|
|
21569
|
-
const { query:
|
|
21570
|
-
for (const
|
|
21571
|
-
const
|
|
21572
|
-
if (
|
|
21573
|
-
const
|
|
21574
|
-
query:
|
|
21575
|
-
tagName:
|
|
21568
|
+
async function Xe(e) {
|
|
21569
|
+
const { query: a, targets: t, segment: i, expectedAncestry: n } = e;
|
|
21570
|
+
for (const r of t) {
|
|
21571
|
+
const s = We[r];
|
|
21572
|
+
if (s) {
|
|
21573
|
+
const u = await Qe({
|
|
21574
|
+
query: a,
|
|
21575
|
+
tagName: r,
|
|
21576
21576
|
segment: i,
|
|
21577
|
-
instAttr:
|
|
21577
|
+
instAttr: s,
|
|
21578
21578
|
expectedAncestry: n
|
|
21579
21579
|
});
|
|
21580
|
-
if (
|
|
21580
|
+
if (u) return u;
|
|
21581
21581
|
} else {
|
|
21582
|
-
const
|
|
21583
|
-
query:
|
|
21584
|
-
tagName:
|
|
21582
|
+
const u = await Ye({
|
|
21583
|
+
query: a,
|
|
21584
|
+
tagName: r,
|
|
21585
21585
|
segment: i,
|
|
21586
21586
|
expectedAncestry: n
|
|
21587
21587
|
});
|
|
21588
|
-
if (
|
|
21588
|
+
if (u) return u;
|
|
21589
21589
|
}
|
|
21590
21590
|
}
|
|
21591
21591
|
}
|
|
21592
|
-
async function
|
|
21593
|
-
const { query:
|
|
21594
|
-
if (!
|
|
21595
|
-
const
|
|
21592
|
+
async function Qe(e) {
|
|
21593
|
+
const { query: a, tagName: t, segment: i, instAttr: n, expectedAncestry: r } = e, s = Ke(i.segment);
|
|
21594
|
+
if (!s) return;
|
|
21595
|
+
const u = await a.findByAttributes({
|
|
21596
21596
|
tagName: t,
|
|
21597
|
-
attributes: { lnClass:
|
|
21597
|
+
attributes: { lnClass: s.lnClass }
|
|
21598
21598
|
});
|
|
21599
|
-
for (const c of
|
|
21600
|
-
const
|
|
21601
|
-
if (!(
|
|
21599
|
+
for (const c of u) {
|
|
21600
|
+
const o = c.attributes.find((d) => d.name === "prefix")?.value ?? "", l = c.attributes.find((d) => d.name === n)?.value ?? "";
|
|
21601
|
+
if (!(o !== s.prefix || l !== s.inst) && await se(a, c, r))
|
|
21602
21602
|
return c;
|
|
21603
21603
|
}
|
|
21604
21604
|
}
|
|
21605
|
-
async function
|
|
21606
|
-
const { query:
|
|
21607
|
-
for (const
|
|
21608
|
-
const
|
|
21609
|
-
if (!(!
|
|
21610
|
-
return
|
|
21605
|
+
async function Ye(e) {
|
|
21606
|
+
const { query: a, tagName: t, segment: i, expectedAncestry: n } = e, r = await a.getRecordsByTagName(t);
|
|
21607
|
+
for (const s of r) {
|
|
21608
|
+
const u = A(p(s));
|
|
21609
|
+
if (!(!u || u.segment !== i.segment) && await se(a, s, n))
|
|
21610
|
+
return s;
|
|
21611
21611
|
}
|
|
21612
21612
|
}
|
|
21613
|
-
async function
|
|
21613
|
+
async function se(e, a, t) {
|
|
21614
21614
|
if (t.length === 0) return !0;
|
|
21615
|
-
const i = await
|
|
21616
|
-
for (let
|
|
21617
|
-
const
|
|
21618
|
-
|
|
21615
|
+
const i = await e.findAncestors(a), n = [];
|
|
21616
|
+
for (let r = i.length - 1; r >= 0; r--) {
|
|
21617
|
+
const s = A(p(i[r]));
|
|
21618
|
+
s && n.push(s);
|
|
21619
21619
|
}
|
|
21620
|
-
return n.length !== t.length ? !1 : n.every((
|
|
21620
|
+
return n.length !== t.length ? !1 : n.every((r, s) => r.segment === t[s].segment);
|
|
21621
21621
|
}
|
|
21622
|
-
async function
|
|
21623
|
-
const t =
|
|
21622
|
+
async function je(e, a) {
|
|
21623
|
+
const t = ae(a);
|
|
21624
21624
|
if (t.length === 0) return;
|
|
21625
|
-
const i = await
|
|
21626
|
-
return
|
|
21627
|
-
query:
|
|
21625
|
+
const i = await e.getRoot();
|
|
21626
|
+
return k({
|
|
21627
|
+
query: e,
|
|
21628
21628
|
current: i,
|
|
21629
21629
|
segments: t,
|
|
21630
21630
|
index: 0
|
|
21631
21631
|
});
|
|
21632
21632
|
}
|
|
21633
|
-
async function
|
|
21634
|
-
const { query:
|
|
21633
|
+
async function k(e) {
|
|
21634
|
+
const { query: a, current: t, segments: i, index: n } = e;
|
|
21635
21635
|
if (n >= i.length) return t;
|
|
21636
|
-
const
|
|
21637
|
-
if (
|
|
21638
|
-
const
|
|
21639
|
-
for (const c of
|
|
21636
|
+
const r = t.children ?? [];
|
|
21637
|
+
if (r.length === 0) return;
|
|
21638
|
+
const s = await a.getRecords(r), u = i[n];
|
|
21639
|
+
for (const c of s) {
|
|
21640
21640
|
if (!c) continue;
|
|
21641
|
-
const
|
|
21642
|
-
if (!
|
|
21643
|
-
const
|
|
21644
|
-
if (
|
|
21641
|
+
const o = A(p(c));
|
|
21642
|
+
if (!o) {
|
|
21643
|
+
const l = await k({ query: a, current: c, segments: i, index: n });
|
|
21644
|
+
if (l) return l;
|
|
21645
21645
|
continue;
|
|
21646
21646
|
}
|
|
21647
|
-
if (
|
|
21648
|
-
return
|
|
21647
|
+
if (o.segment === u.segment && o.separator === u.separator)
|
|
21648
|
+
return k({ query: a, current: c, segments: i, index: n + 1 });
|
|
21649
21649
|
}
|
|
21650
21650
|
}
|
|
21651
|
-
const
|
|
21651
|
+
const b = {
|
|
21652
21652
|
direct: "direct",
|
|
21653
21653
|
lnode: "lnode",
|
|
21654
21654
|
iedAddress: "ied-address",
|
|
@@ -21945,26 +21945,26 @@ const f = {
|
|
|
21945
21945
|
}
|
|
21946
21946
|
]
|
|
21947
21947
|
};
|
|
21948
|
-
function
|
|
21949
|
-
const
|
|
21950
|
-
for (const [t, i] of Object.entries(
|
|
21948
|
+
function $e(e) {
|
|
21949
|
+
const a = {};
|
|
21950
|
+
for (const [t, i] of Object.entries(e))
|
|
21951
21951
|
for (const n of i) {
|
|
21952
|
-
const
|
|
21953
|
-
for (const
|
|
21954
|
-
const
|
|
21955
|
-
|
|
21952
|
+
const r = a[n.resolution] ??= /* @__PURE__ */ new Map();
|
|
21953
|
+
for (const s of n.target) {
|
|
21954
|
+
const u = r.get(s) ?? [];
|
|
21955
|
+
u.push({
|
|
21956
21956
|
refTagName: t,
|
|
21957
21957
|
uuidAttr: n.attribute.uuid,
|
|
21958
21958
|
pathAttr: n.attribute.path
|
|
21959
|
-
}),
|
|
21959
|
+
}), r.set(s, u);
|
|
21960
21960
|
}
|
|
21961
21961
|
}
|
|
21962
|
-
return
|
|
21962
|
+
return a;
|
|
21963
21963
|
}
|
|
21964
|
-
function
|
|
21965
|
-
const
|
|
21966
|
-
for (const [t, i] of Object.entries(
|
|
21967
|
-
|
|
21964
|
+
function Je(e) {
|
|
21965
|
+
const a = /* @__PURE__ */ new Map();
|
|
21966
|
+
for (const [t, i] of Object.entries(e))
|
|
21967
|
+
a.set(
|
|
21968
21968
|
t,
|
|
21969
21969
|
i.map((n) => ({
|
|
21970
21970
|
uuidAttr: n.attribute.uuid,
|
|
@@ -21973,255 +21973,255 @@ function ve(a) {
|
|
|
21973
21973
|
targetTagNames: n.target
|
|
21974
21974
|
}))
|
|
21975
21975
|
);
|
|
21976
|
-
return
|
|
21976
|
+
return a;
|
|
21977
21977
|
}
|
|
21978
|
-
const
|
|
21979
|
-
|
|
21980
|
-
|
|
21981
|
-
|
|
21982
|
-
|
|
21983
|
-
],
|
|
21978
|
+
const ue = $e(m), ce = [
|
|
21979
|
+
b.direct,
|
|
21980
|
+
b.lnode,
|
|
21981
|
+
b.iedAddress,
|
|
21982
|
+
b.behaviorDescription
|
|
21983
|
+
], et = Je(m);
|
|
21984
21984
|
[
|
|
21985
21985
|
...new Set(
|
|
21986
21986
|
Object.values(m).flatMap(
|
|
21987
|
-
(
|
|
21987
|
+
(e) => e.map((a) => a.attribute.uuid)
|
|
21988
21988
|
)
|
|
21989
21989
|
)
|
|
21990
21990
|
];
|
|
21991
|
-
const
|
|
21991
|
+
const oe = /* @__PURE__ */ new Set(["SourceRef", "ControlRef", "DOS", "SDS", "DAS", "InputVar", "OutputVar", "ProcessEcho"]), tt = {
|
|
21992
21992
|
FunctionCatRef: ["SubCategory", "FunctionCategory"],
|
|
21993
21993
|
PowerSystemRelation: ["PowerSystemRelations"],
|
|
21994
21994
|
Resource: ["ProcessResource", "ProcessResources"],
|
|
21995
21995
|
VariableApplyTo: ["Variable"]
|
|
21996
21996
|
};
|
|
21997
|
-
async function
|
|
21998
|
-
const { target: t, containerTagName: i } =
|
|
21997
|
+
async function at(e, a) {
|
|
21998
|
+
const { target: t, containerTagName: i } = a, n = await e.getRecord(t);
|
|
21999
21999
|
if (!n) return [];
|
|
22000
|
-
const
|
|
22001
|
-
if (!
|
|
22002
|
-
const
|
|
22003
|
-
if (
|
|
22004
|
-
const
|
|
22005
|
-
for (const c of
|
|
22006
|
-
if (!
|
|
22007
|
-
const
|
|
22000
|
+
const r = n.attributes.find((c) => c.name === "uuid")?.value;
|
|
22001
|
+
if (!r) return [];
|
|
22002
|
+
const s = it(n.tagName);
|
|
22003
|
+
if (s.length === 0) return [];
|
|
22004
|
+
const u = [];
|
|
22005
|
+
for (const c of s) {
|
|
22006
|
+
if (!M(c.refTagName, P)) continue;
|
|
22007
|
+
const o = await e.findByAttributes({
|
|
22008
22008
|
tagName: c.refTagName,
|
|
22009
|
-
attributes: { [c.uuidAttr]:
|
|
22009
|
+
attributes: { [c.uuidAttr]: r }
|
|
22010
22010
|
});
|
|
22011
|
-
for (const
|
|
22012
|
-
const
|
|
22013
|
-
|
|
22011
|
+
for (const l of o) {
|
|
22012
|
+
const d = i ? await nt(e, l, i) : void 0;
|
|
22013
|
+
u.push({ ref: l, container: d });
|
|
22014
22014
|
}
|
|
22015
22015
|
}
|
|
22016
|
-
return
|
|
22016
|
+
return u;
|
|
22017
22017
|
}
|
|
22018
|
-
function
|
|
22019
|
-
const
|
|
22020
|
-
for (const t of
|
|
22021
|
-
const i =
|
|
22022
|
-
i &&
|
|
22018
|
+
function it(e) {
|
|
22019
|
+
const a = [];
|
|
22020
|
+
for (const t of ce) {
|
|
22021
|
+
const i = ue[t].get(e);
|
|
22022
|
+
i && a.push(...i);
|
|
22023
22023
|
}
|
|
22024
|
-
return
|
|
22024
|
+
return a;
|
|
22025
22025
|
}
|
|
22026
|
-
async function
|
|
22027
|
-
return (await
|
|
22026
|
+
async function nt(e, a, t) {
|
|
22027
|
+
return (await e.findAncestors(a, { stopAtTagName: t })).find((n) => n.tagName === t);
|
|
22028
22028
|
}
|
|
22029
|
-
const
|
|
22029
|
+
const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22030
22030
|
__proto__: null,
|
|
22031
|
-
buildElementPath:
|
|
22032
|
-
buildReferencePath:
|
|
22033
|
-
findRefsPointingTo:
|
|
22034
|
-
resolveElementPath:
|
|
22035
|
-
resolveReferencePath:
|
|
22036
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
22037
|
-
query:
|
|
22031
|
+
buildElementPath: te,
|
|
22032
|
+
buildReferencePath: re,
|
|
22033
|
+
findRefsPointingTo: at,
|
|
22034
|
+
resolveElementPath: je,
|
|
22035
|
+
resolveReferencePath: ze
|
|
22036
|
+
}, Symbol.toStringTag, { value: "Module" })), T = {
|
|
22037
|
+
query: rt
|
|
22038
22038
|
};
|
|
22039
|
-
async function
|
|
22040
|
-
const { uuid:
|
|
22041
|
-
if (!
|
|
22042
|
-
const
|
|
22043
|
-
for (const
|
|
22044
|
-
if (
|
|
22039
|
+
async function B(e) {
|
|
22040
|
+
const { uuid: a, entry: t, target: i, query: n } = e;
|
|
22041
|
+
if (!M(t.refTagName, P)) return [];
|
|
22042
|
+
const r = await n.getRecordsByTagName(t.refTagName), s = [];
|
|
22043
|
+
for (const u of r) {
|
|
22044
|
+
if (u.attributes.find(
|
|
22045
22045
|
(S) => S.name === t.uuidAttr
|
|
22046
|
-
)?.value !==
|
|
22047
|
-
const
|
|
22048
|
-
if (!
|
|
22046
|
+
)?.value !== a) continue;
|
|
22047
|
+
const o = { tagName: u.tagName, id: u.id }, l = await T.query.buildReferencePath(n, { reference: o, target: i });
|
|
22048
|
+
if (!l || u.attributes.find(
|
|
22049
22049
|
(S) => S.name === t.pathAttr
|
|
22050
|
-
)?.value ===
|
|
22051
|
-
const
|
|
22052
|
-
(S) => S.name === t.pathAttr ? { ...S, value:
|
|
22050
|
+
)?.value === l) continue;
|
|
22051
|
+
const f = u.attributes.map(
|
|
22052
|
+
(S) => S.name === t.pathAttr ? { ...S, value: l } : S
|
|
22053
22053
|
);
|
|
22054
|
-
|
|
22054
|
+
s.push({
|
|
22055
22055
|
status: "updated",
|
|
22056
|
-
oldRecord:
|
|
22057
|
-
newRecord:
|
|
22056
|
+
oldRecord: p(u),
|
|
22057
|
+
newRecord: p({ ...u, attributes: f })
|
|
22058
22058
|
});
|
|
22059
22059
|
}
|
|
22060
|
-
return
|
|
22060
|
+
return s;
|
|
22061
22061
|
}
|
|
22062
|
-
function
|
|
22063
|
-
const
|
|
22064
|
-
for (const t of
|
|
22065
|
-
const i =
|
|
22066
|
-
i &&
|
|
22062
|
+
function U(e) {
|
|
22063
|
+
const a = [];
|
|
22064
|
+
for (const t of ce) {
|
|
22065
|
+
const i = ue[t].get(e);
|
|
22066
|
+
i && a.push(...i);
|
|
22067
22067
|
}
|
|
22068
|
-
return
|
|
22068
|
+
return a;
|
|
22069
22069
|
}
|
|
22070
|
-
async function
|
|
22071
|
-
const { childRecord:
|
|
22070
|
+
async function st(e) {
|
|
22071
|
+
const { childRecord: a, query: t } = e, i = await ut({ childRecord: a, query: t }), n = await lt({ childRecord: a, query: t });
|
|
22072
22072
|
return [...i, ...n];
|
|
22073
22073
|
}
|
|
22074
|
-
async function
|
|
22075
|
-
const { childRecord:
|
|
22074
|
+
async function ut(e) {
|
|
22075
|
+
const { childRecord: a, query: t } = e, i = et.get(a.tagName);
|
|
22076
22076
|
if (!i?.length) return [];
|
|
22077
22077
|
const n = [];
|
|
22078
|
-
for (const
|
|
22079
|
-
const
|
|
22080
|
-
|
|
22078
|
+
for (const r of i) {
|
|
22079
|
+
const s = await ct({ childRecord: a, pair: r, query: t });
|
|
22080
|
+
s && n.push(s);
|
|
22081
22081
|
}
|
|
22082
22082
|
return n;
|
|
22083
22083
|
}
|
|
22084
|
-
async function
|
|
22085
|
-
const { childRecord:
|
|
22084
|
+
async function ct(e) {
|
|
22085
|
+
const { childRecord: a, pair: t, query: i } = e, n = a.attributes.find((l) => l.name === t.uuidAttr)?.value;
|
|
22086
22086
|
if (!n) return null;
|
|
22087
|
-
const
|
|
22087
|
+
const r = await ot({
|
|
22088
22088
|
uuidValue: n,
|
|
22089
22089
|
targetTagNames: t.targetTagNames,
|
|
22090
22090
|
query: i
|
|
22091
22091
|
});
|
|
22092
|
-
if (!
|
|
22093
|
-
const
|
|
22092
|
+
if (!r) return null;
|
|
22093
|
+
const s = { tagName: a.tagName, id: a.id }, u = { tagName: r.tagName, id: r.id }, c = await re(i, { reference: s, target: u });
|
|
22094
22094
|
if (!c) return null;
|
|
22095
|
-
const
|
|
22096
|
-
(
|
|
22095
|
+
const o = a.attributes.map(
|
|
22096
|
+
(l) => l.name === t.pathAttr ? { ...l, value: c } : l
|
|
22097
22097
|
);
|
|
22098
22098
|
return {
|
|
22099
22099
|
status: "updated",
|
|
22100
|
-
oldRecord:
|
|
22100
|
+
oldRecord: a,
|
|
22101
22101
|
newRecord: {
|
|
22102
|
-
...
|
|
22103
|
-
attributes:
|
|
22102
|
+
...a,
|
|
22103
|
+
attributes: o
|
|
22104
22104
|
}
|
|
22105
22105
|
};
|
|
22106
22106
|
}
|
|
22107
|
-
async function
|
|
22108
|
-
const { uuidValue:
|
|
22107
|
+
async function ot(e) {
|
|
22108
|
+
const { uuidValue: a, targetTagNames: t, query: i } = e;
|
|
22109
22109
|
for (const n of t) {
|
|
22110
|
-
if (!
|
|
22111
|
-
const
|
|
22112
|
-
(
|
|
22110
|
+
if (!M(n, P)) continue;
|
|
22111
|
+
const s = (await i.getRecordsByTagName(n)).find(
|
|
22112
|
+
(u) => u.attributes.find((c) => c.name === "uuid")?.value === a
|
|
22113
22113
|
);
|
|
22114
|
-
if (
|
|
22114
|
+
if (s) return { tagName: s.tagName, id: s.id };
|
|
22115
22115
|
}
|
|
22116
22116
|
return null;
|
|
22117
22117
|
}
|
|
22118
|
-
async function
|
|
22119
|
-
const { childRecord:
|
|
22118
|
+
async function lt(e) {
|
|
22119
|
+
const { childRecord: a, query: t } = e, i = a.attributes.find((u) => u.name === "uuid")?.value;
|
|
22120
22120
|
if (!i) return [];
|
|
22121
|
-
const n =
|
|
22121
|
+
const n = U(a.tagName);
|
|
22122
22122
|
if (n.length === 0) return [];
|
|
22123
|
-
const
|
|
22124
|
-
for (const
|
|
22125
|
-
const c = await
|
|
22126
|
-
|
|
22123
|
+
const r = { tagName: a.tagName, id: a.id }, s = [];
|
|
22124
|
+
for (const u of n) {
|
|
22125
|
+
const c = await B({ uuid: i, entry: u, target: r, query: t });
|
|
22126
|
+
s.push(...c);
|
|
22127
22127
|
}
|
|
22128
|
-
return
|
|
22128
|
+
return s;
|
|
22129
22129
|
}
|
|
22130
|
-
async function
|
|
22131
|
-
const { childRecord:
|
|
22132
|
-
return [...n, ...
|
|
22130
|
+
async function dt(e) {
|
|
22131
|
+
const { childRecord: a, parentRecord: t, query: i } = e, n = await we({ childRecord: a, parentRecord: t, query: i }), r = await st({ childRecord: a, query: i });
|
|
22132
|
+
return [...n, ...r];
|
|
22133
22133
|
}
|
|
22134
|
-
async function
|
|
22135
|
-
const { cumulativeCloneMappings:
|
|
22134
|
+
async function pt(e) {
|
|
22135
|
+
const { cumulativeCloneMappings: a, query: t } = e, { uuidMap: i, uuidToRef: n } = await St(a, t);
|
|
22136
22136
|
if (i.size === 0) return [];
|
|
22137
|
-
const
|
|
22138
|
-
for (const { target:
|
|
22139
|
-
const
|
|
22140
|
-
|
|
22137
|
+
const r = [];
|
|
22138
|
+
for (const { target: s } of a) {
|
|
22139
|
+
const u = await mt({ target: s, uuidMap: i, uuidToRef: n, query: t });
|
|
22140
|
+
u && r.push(u);
|
|
22141
22141
|
}
|
|
22142
|
-
return
|
|
22142
|
+
return r;
|
|
22143
22143
|
}
|
|
22144
|
-
async function
|
|
22144
|
+
async function St(e, a) {
|
|
22145
22145
|
const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
22146
|
-
for (const { source: n, target:
|
|
22147
|
-
await
|
|
22146
|
+
for (const { source: n, target: r } of e)
|
|
22147
|
+
await ft({ source: n, target: r, query: a, uuidMap: t, uuidToRef: i });
|
|
22148
22148
|
return { uuidMap: t, uuidToRef: i };
|
|
22149
22149
|
}
|
|
22150
|
-
async function
|
|
22151
|
-
const { source:
|
|
22152
|
-
if (!
|
|
22153
|
-
const
|
|
22154
|
-
!
|
|
22150
|
+
async function ft(e) {
|
|
22151
|
+
const { source: a, target: t, query: i, uuidMap: n, uuidToRef: r } = e, s = await i.getRecord(t);
|
|
22152
|
+
if (!s) return;
|
|
22153
|
+
const u = a.attributes.find((o) => o.name === "uuid")?.value, c = s.attributes.find((o) => o.name === "uuid")?.value;
|
|
22154
|
+
!u || !c || (n.set(u, c), r.set(c, { tagName: s.tagName, id: s.id }));
|
|
22155
22155
|
}
|
|
22156
|
-
async function
|
|
22157
|
-
const { target:
|
|
22158
|
-
if (!(
|
|
22159
|
-
const
|
|
22160
|
-
if (!
|
|
22161
|
-
const
|
|
22162
|
-
let c = [...
|
|
22163
|
-
for (const
|
|
22164
|
-
const
|
|
22165
|
-
pair:
|
|
22166
|
-
tagName:
|
|
22167
|
-
refId:
|
|
22156
|
+
async function mt(e) {
|
|
22157
|
+
const { target: a, uuidMap: t, uuidToRef: i, query: n } = e, r = a.tagName;
|
|
22158
|
+
if (!(r in m)) return null;
|
|
22159
|
+
const s = await n.getRecord(a);
|
|
22160
|
+
if (!s) return null;
|
|
22161
|
+
const u = m[r];
|
|
22162
|
+
let c = [...s.attributes], o = !1;
|
|
22163
|
+
for (const l of u) {
|
|
22164
|
+
const d = await bt({
|
|
22165
|
+
pair: l,
|
|
22166
|
+
tagName: r,
|
|
22167
|
+
refId: s.id,
|
|
22168
22168
|
updatedAttributes: c,
|
|
22169
22169
|
uuidMap: t,
|
|
22170
22170
|
uuidToRef: i,
|
|
22171
22171
|
query: n
|
|
22172
22172
|
});
|
|
22173
|
-
|
|
22173
|
+
d && (c = d, o = !0);
|
|
22174
22174
|
}
|
|
22175
|
-
return
|
|
22175
|
+
return o ? {
|
|
22176
22176
|
status: "updated",
|
|
22177
|
-
oldRecord:
|
|
22178
|
-
newRecord:
|
|
22177
|
+
oldRecord: p(s),
|
|
22178
|
+
newRecord: p({ ...s, attributes: c })
|
|
22179
22179
|
} : null;
|
|
22180
22180
|
}
|
|
22181
|
-
async function
|
|
22182
|
-
const { pair:
|
|
22183
|
-
let
|
|
22184
|
-
const c =
|
|
22181
|
+
async function bt(e) {
|
|
22182
|
+
const { pair: a, tagName: t, refId: i, uuidMap: n, uuidToRef: r, query: s } = e;
|
|
22183
|
+
let u = [...e.updatedAttributes];
|
|
22184
|
+
const c = u.find((S) => S.name === a.attribute.uuid)?.value;
|
|
22185
22185
|
if (!c) return null;
|
|
22186
|
-
const
|
|
22187
|
-
if (!
|
|
22188
|
-
let
|
|
22189
|
-
const
|
|
22190
|
-
|
|
22191
|
-
const
|
|
22192
|
-
attributes:
|
|
22193
|
-
pathAttrName:
|
|
22194
|
-
newUuid:
|
|
22195
|
-
uuidToRef:
|
|
22186
|
+
const o = n.get(c);
|
|
22187
|
+
if (!o) return null;
|
|
22188
|
+
let l = !1;
|
|
22189
|
+
const d = Rt(u, a.attribute.uuid, c, o);
|
|
22190
|
+
d && (u = d, l = !0);
|
|
22191
|
+
const f = await Lt({
|
|
22192
|
+
attributes: u,
|
|
22193
|
+
pathAttrName: a.attribute.path,
|
|
22194
|
+
newUuid: o,
|
|
22195
|
+
uuidToRef: r,
|
|
22196
22196
|
tagName: t,
|
|
22197
22197
|
refId: i,
|
|
22198
|
-
query:
|
|
22198
|
+
query: s
|
|
22199
22199
|
});
|
|
22200
|
-
return
|
|
22200
|
+
return f && (u = f, l = !0), l ? u : null;
|
|
22201
22201
|
}
|
|
22202
|
-
function
|
|
22203
|
-
return i === t ? null :
|
|
22202
|
+
function Rt(e, a, t, i) {
|
|
22203
|
+
return i === t ? null : e.map((n) => n.name === a ? { ...n, value: i } : n);
|
|
22204
22204
|
}
|
|
22205
|
-
async function
|
|
22206
|
-
const { attributes:
|
|
22205
|
+
async function Lt(e) {
|
|
22206
|
+
const { attributes: a, pathAttrName: t, newUuid: i, uuidToRef: n, tagName: r, refId: s, query: u } = e, c = n.get(i);
|
|
22207
22207
|
if (!c) return null;
|
|
22208
|
-
const
|
|
22209
|
-
reference: { tagName:
|
|
22208
|
+
const o = await T.query.buildReferencePath(u, {
|
|
22209
|
+
reference: { tagName: r, id: s },
|
|
22210
22210
|
target: { tagName: c.tagName, id: c.id }
|
|
22211
22211
|
});
|
|
22212
|
-
return !
|
|
22212
|
+
return !o || a.find((d) => d.name === t)?.value === o ? null : a.map((d) => d.name === t ? { ...d, value: o } : d);
|
|
22213
22213
|
}
|
|
22214
|
-
async function
|
|
22215
|
-
return
|
|
22214
|
+
async function At(e) {
|
|
22215
|
+
return pt(e);
|
|
22216
22216
|
}
|
|
22217
|
-
function
|
|
22218
|
-
const { record:
|
|
22219
|
-
if (!("uuid" in n.attributes.details) || i.find((
|
|
22220
|
-
const c = n.attributes.details.uuid?.namespace,
|
|
22217
|
+
function Pt(e) {
|
|
22218
|
+
const { record: a } = e, { tagName: t, attributes: i } = a, n = P.definition[t];
|
|
22219
|
+
if (!("uuid" in n.attributes.details) || i.find((l) => l.name === "uuid")?.value) return a;
|
|
22220
|
+
const c = n.attributes.details.uuid?.namespace, o = i.filter((l) => l.name !== "uuid");
|
|
22221
22221
|
return {
|
|
22222
|
-
...
|
|
22222
|
+
...a,
|
|
22223
22223
|
attributes: [
|
|
22224
|
-
...
|
|
22224
|
+
...o,
|
|
22225
22225
|
{
|
|
22226
22226
|
name: "uuid",
|
|
22227
22227
|
value: crypto.randomUUID(),
|
|
@@ -22230,240 +22230,240 @@ function _e(a) {
|
|
|
22230
22230
|
]
|
|
22231
22231
|
};
|
|
22232
22232
|
}
|
|
22233
|
-
function
|
|
22234
|
-
return
|
|
22233
|
+
function Ct(e) {
|
|
22234
|
+
return Pt(e);
|
|
22235
22235
|
}
|
|
22236
|
-
async function
|
|
22237
|
-
const { oldRecord:
|
|
22238
|
-
if (
|
|
22239
|
-
const
|
|
22240
|
-
for (const c of
|
|
22241
|
-
const
|
|
22242
|
-
n.push(...
|
|
22236
|
+
async function gt(e) {
|
|
22237
|
+
const { oldRecord: a, newRecord: t, query: i } = e, n = [], r = t.attributes.find((s) => s.name === "uuid")?.value;
|
|
22238
|
+
if (r) {
|
|
22239
|
+
const s = U(t.tagName), u = { tagName: t.tagName, id: t.id };
|
|
22240
|
+
for (const c of s) {
|
|
22241
|
+
const o = await B({ uuid: r, entry: c, target: u, query: i });
|
|
22242
|
+
n.push(...o);
|
|
22243
22243
|
}
|
|
22244
22244
|
}
|
|
22245
|
-
if (
|
|
22246
|
-
const
|
|
22247
|
-
n.push(...
|
|
22245
|
+
if (vt(a, t)) {
|
|
22246
|
+
const s = await Tt({ newRecord: t, query: i });
|
|
22247
|
+
n.push(...s);
|
|
22248
22248
|
}
|
|
22249
22249
|
return n;
|
|
22250
22250
|
}
|
|
22251
|
-
function
|
|
22252
|
-
for (const t of
|
|
22253
|
-
const i =
|
|
22251
|
+
function vt(e, a) {
|
|
22252
|
+
for (const t of xe) {
|
|
22253
|
+
const i = e.attributes.find((r) => r.name === t)?.value, n = a.attributes.find((r) => r.name === t)?.value;
|
|
22254
22254
|
if (i !== n) return !0;
|
|
22255
22255
|
}
|
|
22256
22256
|
return !1;
|
|
22257
22257
|
}
|
|
22258
|
-
async function
|
|
22259
|
-
const { newRecord:
|
|
22260
|
-
for (const
|
|
22261
|
-
for (const
|
|
22262
|
-
if (
|
|
22263
|
-
const c = await t.any.getAttribute(
|
|
22258
|
+
async function Tt(e) {
|
|
22259
|
+
const { newRecord: a, query: t } = e, i = { tagName: a.tagName, id: a.id }, n = await t.findDescendants(i), r = [];
|
|
22260
|
+
for (const s of Object.values(n))
|
|
22261
|
+
for (const u of s) {
|
|
22262
|
+
if (u.id === a.id) continue;
|
|
22263
|
+
const c = await t.any.getAttribute(u, { name: "uuid" });
|
|
22264
22264
|
if (!c) continue;
|
|
22265
|
-
const
|
|
22266
|
-
if (
|
|
22267
|
-
const
|
|
22268
|
-
for (const
|
|
22269
|
-
const
|
|
22270
|
-
|
|
22265
|
+
const o = U(u.tagName);
|
|
22266
|
+
if (o.length === 0) continue;
|
|
22267
|
+
const l = { tagName: u.tagName, id: u.id };
|
|
22268
|
+
for (const d of o) {
|
|
22269
|
+
const f = await B({ uuid: c, entry: d, target: l, query: t });
|
|
22270
|
+
r.push(...f);
|
|
22271
22271
|
}
|
|
22272
22272
|
}
|
|
22273
|
-
return
|
|
22273
|
+
return r;
|
|
22274
22274
|
}
|
|
22275
|
-
async function
|
|
22276
|
-
return
|
|
22275
|
+
async function ht(e) {
|
|
22276
|
+
return gt(e);
|
|
22277
22277
|
}
|
|
22278
|
-
function
|
|
22279
|
-
const { record:
|
|
22278
|
+
function Nt(e) {
|
|
22279
|
+
const { record: a } = e;
|
|
22280
22280
|
let t = !0;
|
|
22281
|
-
|
|
22282
|
-
const i =
|
|
22281
|
+
a.tagName === "Private" && !a.tree.length && (t = !1);
|
|
22282
|
+
const i = a.attributes.filter(
|
|
22283
22283
|
(n) => n.name !== "uuid"
|
|
22284
22284
|
);
|
|
22285
22285
|
return {
|
|
22286
22286
|
shouldBeCloned: t,
|
|
22287
22287
|
transformedRecord: {
|
|
22288
|
-
...
|
|
22288
|
+
...a,
|
|
22289
22289
|
attributes: i
|
|
22290
22290
|
}
|
|
22291
22291
|
};
|
|
22292
22292
|
}
|
|
22293
|
-
async function
|
|
22294
|
-
const { record:
|
|
22295
|
-
if (await
|
|
22296
|
-
const
|
|
22297
|
-
for (const
|
|
22298
|
-
const c = await
|
|
22299
|
-
|
|
22293
|
+
async function It(e) {
|
|
22294
|
+
const { record: a, query: t } = e, i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
22295
|
+
if (await le({ record: a, query: t, ids: i, uuids: n }), n.size === 0) return [];
|
|
22296
|
+
const r = [], s = Object.keys(m);
|
|
22297
|
+
for (const u of s) {
|
|
22298
|
+
const c = await wt({ refTagName: u, subtreeIds: i, subtreeUuids: n, query: t });
|
|
22299
|
+
r.push(...c);
|
|
22300
22300
|
}
|
|
22301
|
-
return
|
|
22301
|
+
return r;
|
|
22302
22302
|
}
|
|
22303
|
-
async function
|
|
22304
|
-
const { refTagName:
|
|
22305
|
-
for (const c of
|
|
22303
|
+
async function wt(e) {
|
|
22304
|
+
const { refTagName: a, subtreeIds: t, subtreeUuids: i, query: n } = e, r = m[a], s = await n.getRecordsByTagName(a), u = [];
|
|
22305
|
+
for (const c of s) {
|
|
22306
22306
|
if (t.has(c.id)) continue;
|
|
22307
|
-
const
|
|
22308
|
-
|
|
22307
|
+
const o = await Dt({ refTagName: a, refRecord: c, refPairs: r, subtreeUuids: i, query: n });
|
|
22308
|
+
u.push(...o);
|
|
22309
22309
|
}
|
|
22310
|
-
return
|
|
22310
|
+
return u;
|
|
22311
22311
|
}
|
|
22312
|
-
async function
|
|
22313
|
-
const { refTagName:
|
|
22314
|
-
return
|
|
22312
|
+
async function Dt(e) {
|
|
22313
|
+
const { refTagName: a, refRecord: t, refPairs: i, subtreeUuids: n, query: r } = e, s = Ft({ refPairs: i, refRecord: t, subtreeUuids: n });
|
|
22314
|
+
return s.size === 0 ? [] : oe.has(a) ? [yt(t, s)] : qt(t, r);
|
|
22315
22315
|
}
|
|
22316
|
-
function
|
|
22317
|
-
const { refPairs:
|
|
22318
|
-
for (const
|
|
22319
|
-
const
|
|
22320
|
-
(
|
|
22316
|
+
function Ft(e) {
|
|
22317
|
+
const { refPairs: a, refRecord: t, subtreeUuids: i } = e, n = /* @__PURE__ */ new Set();
|
|
22318
|
+
for (const r of a) {
|
|
22319
|
+
const s = t.attributes.find(
|
|
22320
|
+
(u) => u.name === r.attribute.uuid
|
|
22321
22321
|
)?.value;
|
|
22322
|
-
if (!(!
|
|
22323
|
-
n.add(
|
|
22324
|
-
for (const
|
|
22325
|
-
n.add(
|
|
22322
|
+
if (!(!s || !i.has(s))) {
|
|
22323
|
+
n.add(r.attribute.uuid), n.add(r.attribute.path);
|
|
22324
|
+
for (const u of r.companions)
|
|
22325
|
+
n.add(u.name);
|
|
22326
22326
|
}
|
|
22327
22327
|
}
|
|
22328
22328
|
return n;
|
|
22329
22329
|
}
|
|
22330
|
-
function
|
|
22331
|
-
const t =
|
|
22332
|
-
(i) => !
|
|
22330
|
+
function yt(e, a) {
|
|
22331
|
+
const t = e.attributes.filter(
|
|
22332
|
+
(i) => !a.has(i.name)
|
|
22333
22333
|
);
|
|
22334
22334
|
return {
|
|
22335
22335
|
status: "updated",
|
|
22336
|
-
oldRecord:
|
|
22337
|
-
newRecord:
|
|
22336
|
+
oldRecord: p(e),
|
|
22337
|
+
newRecord: p({ ...e, attributes: t })
|
|
22338
22338
|
};
|
|
22339
22339
|
}
|
|
22340
|
-
async function
|
|
22340
|
+
async function qt(e, a) {
|
|
22341
22341
|
const t = [
|
|
22342
|
-
{ status: "deleted", oldRecord:
|
|
22342
|
+
{ status: "deleted", oldRecord: p(e), newRecord: void 0 }
|
|
22343
22343
|
];
|
|
22344
|
-
if (
|
|
22345
|
-
const i = await
|
|
22344
|
+
if (e.parent) {
|
|
22345
|
+
const i = await a.getRecord(e.parent);
|
|
22346
22346
|
if (i) {
|
|
22347
22347
|
const n = {
|
|
22348
22348
|
...i,
|
|
22349
|
-
children: i.children.filter((
|
|
22349
|
+
children: i.children.filter((r) => r.id !== e.id)
|
|
22350
22350
|
};
|
|
22351
22351
|
t.push({
|
|
22352
22352
|
status: "updated",
|
|
22353
|
-
oldRecord:
|
|
22354
|
-
newRecord:
|
|
22353
|
+
oldRecord: p(i),
|
|
22354
|
+
newRecord: p(n)
|
|
22355
22355
|
});
|
|
22356
22356
|
}
|
|
22357
22357
|
}
|
|
22358
22358
|
return t;
|
|
22359
22359
|
}
|
|
22360
|
-
async function
|
|
22361
|
-
const { record:
|
|
22362
|
-
i.add(
|
|
22363
|
-
const
|
|
22364
|
-
|
|
22365
|
-
for (const
|
|
22366
|
-
const
|
|
22367
|
-
|
|
22360
|
+
async function le(e) {
|
|
22361
|
+
const { record: a, query: t, ids: i, uuids: n } = e;
|
|
22362
|
+
i.add(a.id);
|
|
22363
|
+
const r = a.attributes.find((s) => s.name === "uuid")?.value;
|
|
22364
|
+
r && n.add(r);
|
|
22365
|
+
for (const s of a.children) {
|
|
22366
|
+
const u = await t.getRecord(s);
|
|
22367
|
+
u && await le({ record: u, query: t, ids: i, uuids: n });
|
|
22368
22368
|
}
|
|
22369
22369
|
}
|
|
22370
|
-
async function
|
|
22371
|
-
return
|
|
22370
|
+
async function xt(e) {
|
|
22371
|
+
return It(e);
|
|
22372
22372
|
}
|
|
22373
|
-
function
|
|
22374
|
-
const
|
|
22373
|
+
function Ot() {
|
|
22374
|
+
const e = /* @__PURE__ */ new Map(), a = [], t = [];
|
|
22375
22375
|
return {
|
|
22376
|
-
beforeImportRecord: (
|
|
22377
|
-
const { record:
|
|
22378
|
-
if (
|
|
22379
|
-
const S =
|
|
22380
|
-
S &&
|
|
22381
|
-
}
|
|
22382
|
-
if (!
|
|
22383
|
-
const
|
|
22384
|
-
for (const S of
|
|
22385
|
-
const
|
|
22386
|
-
(
|
|
22376
|
+
beforeImportRecord: (r) => {
|
|
22377
|
+
const { record: s, ancestry: u } = r, { tagName: c } = s, o = Zt(s);
|
|
22378
|
+
if (o && Vt.has(c)) {
|
|
22379
|
+
const S = J({ record: s, ancestry: u });
|
|
22380
|
+
S && e.set(S.path, o);
|
|
22381
|
+
}
|
|
22382
|
+
if (!kt.has(c)) return;
|
|
22383
|
+
const f = m[c];
|
|
22384
|
+
for (const S of f) {
|
|
22385
|
+
const L = s.attributes.find(
|
|
22386
|
+
(C) => C.name === S.attribute.path
|
|
22387
22387
|
)?.value;
|
|
22388
|
-
if (!
|
|
22389
|
-
(
|
|
22388
|
+
if (!L || s.attributes.find(
|
|
22389
|
+
(C) => C.name === S.attribute.uuid
|
|
22390
22390
|
)?.value) continue;
|
|
22391
|
-
const
|
|
22392
|
-
if (!
|
|
22393
|
-
S.resolution ===
|
|
22391
|
+
const N = ne(S.resolution, S.attribute.path, L, u);
|
|
22392
|
+
if (!N) {
|
|
22393
|
+
S.resolution === b.unsupported && t.push({
|
|
22394
22394
|
type: "unsupported-xpath-reference",
|
|
22395
|
-
recordId:
|
|
22395
|
+
recordId: s.id,
|
|
22396
22396
|
details: {
|
|
22397
22397
|
elementTag: c,
|
|
22398
22398
|
pathAttribute: S.attribute.path,
|
|
22399
22399
|
uuidAttribute: S.attribute.uuid,
|
|
22400
|
-
pathValue:
|
|
22400
|
+
pathValue: L
|
|
22401
22401
|
}
|
|
22402
22402
|
});
|
|
22403
22403
|
continue;
|
|
22404
22404
|
}
|
|
22405
|
-
|
|
22406
|
-
recordId:
|
|
22405
|
+
a.push({
|
|
22406
|
+
recordId: s.id,
|
|
22407
22407
|
elementTag: c,
|
|
22408
22408
|
uuidAttributeName: S.attribute.uuid,
|
|
22409
|
-
pathValue:
|
|
22410
|
-
lookupKey:
|
|
22411
|
-
fallbackLookupKey:
|
|
22409
|
+
pathValue: L,
|
|
22410
|
+
lookupKey: N.lookupKey,
|
|
22411
|
+
fallbackLookupKey: N.fallbackLookupKey
|
|
22412
22412
|
});
|
|
22413
22413
|
}
|
|
22414
22414
|
},
|
|
22415
22415
|
afterImport: async () => {
|
|
22416
|
-
const
|
|
22417
|
-
for (const
|
|
22418
|
-
const c =
|
|
22416
|
+
const r = [], s = [...t];
|
|
22417
|
+
for (const u of a) {
|
|
22418
|
+
const c = e.get(u.lookupKey) ?? (u.fallbackLookupKey ? e.get(u.fallbackLookupKey) : void 0);
|
|
22419
22419
|
if (!c) {
|
|
22420
|
-
|
|
22420
|
+
s.push({
|
|
22421
22421
|
type: "unresolved-reference",
|
|
22422
|
-
recordId:
|
|
22422
|
+
recordId: u.recordId,
|
|
22423
22423
|
details: {
|
|
22424
|
-
elementTag:
|
|
22425
|
-
uuidAttribute:
|
|
22426
|
-
pathValue:
|
|
22427
|
-
triedKeys:
|
|
22424
|
+
elementTag: u.elementTag,
|
|
22425
|
+
uuidAttribute: u.uuidAttributeName,
|
|
22426
|
+
pathValue: u.pathValue,
|
|
22427
|
+
triedKeys: u.fallbackLookupKey ? [u.lookupKey, u.fallbackLookupKey] : [u.lookupKey]
|
|
22428
22428
|
}
|
|
22429
22429
|
});
|
|
22430
22430
|
continue;
|
|
22431
22431
|
}
|
|
22432
|
-
|
|
22433
|
-
recordId:
|
|
22434
|
-
attributes: [{ name:
|
|
22432
|
+
r.push({
|
|
22433
|
+
recordId: u.recordId,
|
|
22434
|
+
attributes: [{ name: u.uuidAttributeName, value: c }]
|
|
22435
22435
|
});
|
|
22436
22436
|
}
|
|
22437
|
-
return
|
|
22438
|
-
updates:
|
|
22439
|
-
warnings:
|
|
22437
|
+
return e.clear(), a.length = 0, t.length = 0, {
|
|
22438
|
+
updates: r,
|
|
22439
|
+
warnings: s.length > 0 ? s : void 0
|
|
22440
22440
|
};
|
|
22441
22441
|
}
|
|
22442
22442
|
};
|
|
22443
22443
|
}
|
|
22444
|
-
const
|
|
22445
|
-
Object.entries(
|
|
22446
|
-
),
|
|
22447
|
-
Object.values(m).flatMap((
|
|
22444
|
+
const Et = new Set(
|
|
22445
|
+
Object.entries(Q).filter(([, e]) => "uuid" in e).map(([e]) => e)
|
|
22446
|
+
), kt = new Set(Object.keys(m)), Vt = new Set(
|
|
22447
|
+
Object.values(m).flatMap((e) => e.flatMap((a) => a.target))
|
|
22448
22448
|
);
|
|
22449
|
-
function
|
|
22450
|
-
if (!
|
|
22451
|
-
const
|
|
22452
|
-
if (
|
|
22449
|
+
function Zt(e) {
|
|
22450
|
+
if (!Et.has(e.tagName)) return;
|
|
22451
|
+
const a = e.attributes.find((i) => i.name === "uuid");
|
|
22452
|
+
if (a) return a.value;
|
|
22453
22453
|
const t = crypto.randomUUID();
|
|
22454
|
-
return
|
|
22454
|
+
return e.attributes.push({ name: "uuid", value: t }), t;
|
|
22455
22455
|
}
|
|
22456
|
-
const
|
|
22457
|
-
beforeClone:
|
|
22458
|
-
afterStandardizedRecord:
|
|
22459
|
-
afterCreated:
|
|
22460
|
-
afterDeepClone:
|
|
22461
|
-
afterUpdated:
|
|
22462
|
-
beforeDelete:
|
|
22463
|
-
},
|
|
22456
|
+
const ga = {
|
|
22457
|
+
beforeClone: Nt,
|
|
22458
|
+
afterStandardizedRecord: Ct,
|
|
22459
|
+
afterCreated: dt,
|
|
22460
|
+
afterDeepClone: At,
|
|
22461
|
+
afterUpdated: ht,
|
|
22462
|
+
beforeDelete: xt
|
|
22463
|
+
}, Mt = Ot(), Gt = {
|
|
22464
22464
|
supportedFileExtensions: [".fsd", ".asd", ".ssd", ".scd", ".isd", ".xml"],
|
|
22465
|
-
hooks:
|
|
22466
|
-
},
|
|
22465
|
+
hooks: Mt
|
|
22466
|
+
}, Bt = {
|
|
22467
22467
|
recordSchema: {
|
|
22468
22468
|
primaryKey: "id",
|
|
22469
22469
|
indexes: ["tagName", "parent.id", "parent.tagName"],
|
|
@@ -22482,37 +22482,604 @@ const Rt = {
|
|
|
22482
22482
|
}
|
|
22483
22483
|
}
|
|
22484
22484
|
}
|
|
22485
|
-
},
|
|
22485
|
+
}, Ut = {
|
|
22486
22486
|
default: { uri: "http://www.iec.ch/61850/2003/SCL", prefix: "" },
|
|
22487
22487
|
v2019C1: {
|
|
22488
22488
|
uri: "http://www.iec.ch/61850/2019/SCL/6-100",
|
|
22489
22489
|
prefix: "eIEC61850-6-100"
|
|
22490
22490
|
}
|
|
22491
22491
|
}, P = {
|
|
22492
|
-
rootElementName:
|
|
22493
|
-
singletonElements:
|
|
22492
|
+
rootElementName: Ne,
|
|
22493
|
+
singletonElements: Ie,
|
|
22494
22494
|
transparentElements: ["Private"],
|
|
22495
|
-
elements:
|
|
22496
|
-
namespaces:
|
|
22497
|
-
attributes:
|
|
22498
|
-
children:
|
|
22499
|
-
parents:
|
|
22495
|
+
elements: ge,
|
|
22496
|
+
namespaces: Ut,
|
|
22497
|
+
attributes: Q,
|
|
22498
|
+
children: ve,
|
|
22499
|
+
parents: Te,
|
|
22500
22500
|
descendants: X,
|
|
22501
|
-
ancestors:
|
|
22502
|
-
database:
|
|
22503
|
-
io:
|
|
22504
|
-
definition:
|
|
22501
|
+
ancestors: he,
|
|
22502
|
+
database: Bt,
|
|
22503
|
+
io: Gt,
|
|
22504
|
+
definition: G
|
|
22505
|
+
};
|
|
22506
|
+
async function zt(e) {
|
|
22507
|
+
const a = await e.getRecordsByTagName("LNode");
|
|
22508
|
+
for (const t of a) {
|
|
22509
|
+
const i = await e.getAttribute(t, { name: "iedName" });
|
|
22510
|
+
if (!i || i === "None") continue;
|
|
22511
|
+
const [n] = await e.findByAttributes({
|
|
22512
|
+
tagName: "IED",
|
|
22513
|
+
attributes: { name: i }
|
|
22514
|
+
});
|
|
22515
|
+
n || await _t(e, t);
|
|
22516
|
+
}
|
|
22517
|
+
}
|
|
22518
|
+
async function _t(e, a) {
|
|
22519
|
+
const t = await e.getChild(a, "LNodeSpecNaming");
|
|
22520
|
+
if (t) {
|
|
22521
|
+
const i = await e.getAttribute(t, { name: "sLnClass" }), n = await e.getAttribute(t, { name: "sLnInst" }), r = await e.getAttribute(t, { name: "sPrefix" });
|
|
22522
|
+
await e.update(t, {
|
|
22523
|
+
attributes: { sIedName: "None", sLdInst: void 0 }
|
|
22524
|
+
}), await e.update(a, {
|
|
22525
|
+
attributes: {
|
|
22526
|
+
iedName: "None",
|
|
22527
|
+
ldInst: void 0,
|
|
22528
|
+
lnUuid: void 0,
|
|
22529
|
+
templateUuid: void 0,
|
|
22530
|
+
lnClass: i || void 0,
|
|
22531
|
+
lnInst: n || void 0,
|
|
22532
|
+
prefix: r || void 0
|
|
22533
|
+
}
|
|
22534
|
+
});
|
|
22535
|
+
} else
|
|
22536
|
+
await e.update(a, {
|
|
22537
|
+
attributes: {
|
|
22538
|
+
iedName: "None",
|
|
22539
|
+
ldInst: void 0,
|
|
22540
|
+
lnUuid: void 0,
|
|
22541
|
+
templateUuid: void 0,
|
|
22542
|
+
lnClass: void 0,
|
|
22543
|
+
lnInst: void 0,
|
|
22544
|
+
prefix: void 0
|
|
22545
|
+
}
|
|
22546
|
+
});
|
|
22547
|
+
}
|
|
22548
|
+
async function Ht(e) {
|
|
22549
|
+
const a = [...Object.values(tt).flat(), "Private"];
|
|
22550
|
+
for (const t of a) {
|
|
22551
|
+
const i = await e.getRecordsByTagName(t);
|
|
22552
|
+
for (const n of i)
|
|
22553
|
+
n.children.length === 0 && await e.delete(n);
|
|
22554
|
+
}
|
|
22555
|
+
}
|
|
22556
|
+
async function Wt(e) {
|
|
22557
|
+
const a = Object.keys(m);
|
|
22558
|
+
for (const t of a) {
|
|
22559
|
+
const i = m[t], n = await e.getRecordsByTagName(t);
|
|
22560
|
+
for (const r of n) {
|
|
22561
|
+
let s = !1, u = !1;
|
|
22562
|
+
const c = {};
|
|
22563
|
+
for (const d of i) {
|
|
22564
|
+
const f = await e.getAttribute(r, {
|
|
22565
|
+
name: d.attribute.uuid
|
|
22566
|
+
});
|
|
22567
|
+
if (!f) continue;
|
|
22568
|
+
if (s = !0, await Kt(e, f, d.target))
|
|
22569
|
+
u = !0;
|
|
22570
|
+
else {
|
|
22571
|
+
c[d.attribute.uuid] = void 0, c[d.attribute.path] = void 0;
|
|
22572
|
+
for (const L of d.companions)
|
|
22573
|
+
c[L.name] = void 0;
|
|
22574
|
+
}
|
|
22575
|
+
}
|
|
22576
|
+
Object.keys(c).length > 0 && await e.update(r, { attributes: c });
|
|
22577
|
+
const o = oe.has(t);
|
|
22578
|
+
s && !u && !o && await e.delete(r);
|
|
22579
|
+
}
|
|
22580
|
+
}
|
|
22581
|
+
}
|
|
22582
|
+
async function Kt(e, a, t) {
|
|
22583
|
+
for (const i of t) {
|
|
22584
|
+
const [n] = await e.findByAttributes({
|
|
22585
|
+
tagName: i,
|
|
22586
|
+
attributes: { uuid: a }
|
|
22587
|
+
});
|
|
22588
|
+
if (n) return !0;
|
|
22589
|
+
}
|
|
22590
|
+
return !1;
|
|
22591
|
+
}
|
|
22592
|
+
const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22593
|
+
__proto__: null,
|
|
22594
|
+
orphanUuidRefs: Wt,
|
|
22595
|
+
pruneEmptyContainers: Ht,
|
|
22596
|
+
resetLNode: zt
|
|
22597
|
+
}, Symbol.toStringTag, { value: "Module" })), w = {
|
|
22598
|
+
transaction: Xt
|
|
22599
|
+
};
|
|
22600
|
+
async function de(e, a) {
|
|
22601
|
+
const { records: t } = a, i = {
|
|
22602
|
+
lnodeTypes: /* @__PURE__ */ new Map(),
|
|
22603
|
+
doTypes: /* @__PURE__ */ new Map(),
|
|
22604
|
+
daTypes: /* @__PURE__ */ new Map(),
|
|
22605
|
+
enumTypes: /* @__PURE__ */ new Map()
|
|
22606
|
+
};
|
|
22607
|
+
for (const n of t) {
|
|
22608
|
+
const r = await e.getAttribute(n, { name: "lnType" });
|
|
22609
|
+
if (!r) continue;
|
|
22610
|
+
const [s] = await e.findByAttributes({
|
|
22611
|
+
tagName: "LNodeType",
|
|
22612
|
+
attributes: { id: r }
|
|
22613
|
+
});
|
|
22614
|
+
if (F(s, {
|
|
22615
|
+
key: "ELEMENT_NOT_FOUND",
|
|
22616
|
+
detail: `LNodeType not found for lnType="${r}"`
|
|
22617
|
+
}), !v(i.lnodeTypes, r, s)) continue;
|
|
22618
|
+
const u = s.children.filter((o) => I(o, "DO")), c = await e.getRecords(u);
|
|
22619
|
+
for (const o of c) {
|
|
22620
|
+
if (!o) continue;
|
|
22621
|
+
const l = await e.getAttribute(o, { name: "type" });
|
|
22622
|
+
if (!l) continue;
|
|
22623
|
+
const [d] = await e.findByAttributes({
|
|
22624
|
+
tagName: "DOType",
|
|
22625
|
+
attributes: { id: l }
|
|
22626
|
+
});
|
|
22627
|
+
d && v(i.doTypes, l, d) && await V({ query: e, parent: d, dataModelMap: i });
|
|
22628
|
+
}
|
|
22629
|
+
}
|
|
22630
|
+
return {
|
|
22631
|
+
lnodeTypes: Array.from(i.lnodeTypes.values()),
|
|
22632
|
+
doTypes: Array.from(i.doTypes.values()),
|
|
22633
|
+
daTypes: Array.from(i.daTypes.values()),
|
|
22634
|
+
enumTypes: Array.from(i.enumTypes.values())
|
|
22635
|
+
};
|
|
22636
|
+
}
|
|
22637
|
+
function v(e, a, t) {
|
|
22638
|
+
return e.has(a) ? !1 : (e.set(a, t), !0);
|
|
22639
|
+
}
|
|
22640
|
+
async function V(e) {
|
|
22641
|
+
const { query: a, parent: t, dataModelMap: i } = e, n = t.tagName === "DOType" ? await a.getRecords(t.children.filter((r) => I(r, "DA"))) : await a.getRecords(t.children.filter((r) => I(r, "BDA")));
|
|
22642
|
+
for (const r of n) {
|
|
22643
|
+
if (!r) continue;
|
|
22644
|
+
const s = await a.getAttribute(r, { name: "bType" }), u = await a.getAttribute(r, { name: "type" });
|
|
22645
|
+
if (u) {
|
|
22646
|
+
if (s === "Enum") {
|
|
22647
|
+
const [c] = await a.findByAttributes({
|
|
22648
|
+
tagName: "EnumType",
|
|
22649
|
+
attributes: { id: u }
|
|
22650
|
+
});
|
|
22651
|
+
c && v(i.enumTypes, u, c);
|
|
22652
|
+
} else if (s === "Struct") {
|
|
22653
|
+
const [c] = await a.findByAttributes({
|
|
22654
|
+
tagName: "DAType",
|
|
22655
|
+
attributes: { id: u }
|
|
22656
|
+
});
|
|
22657
|
+
c && v(i.daTypes, u, c) && await V({ query: a, parent: c, dataModelMap: i });
|
|
22658
|
+
}
|
|
22659
|
+
}
|
|
22660
|
+
}
|
|
22661
|
+
if (t.tagName === "DOType") {
|
|
22662
|
+
const r = t.children.filter((u) => I(u, "SDO")), s = await a.getRecords(r);
|
|
22663
|
+
for (const u of s) {
|
|
22664
|
+
const c = await a.getAttribute(u, { name: "type" });
|
|
22665
|
+
if (!c) continue;
|
|
22666
|
+
const [o] = await a.findByAttributes({
|
|
22667
|
+
tagName: "DOType",
|
|
22668
|
+
attributes: { id: c }
|
|
22669
|
+
});
|
|
22670
|
+
o && v(i.doTypes, c, o) && await V({ query: a, parent: o, dataModelMap: i });
|
|
22671
|
+
}
|
|
22672
|
+
}
|
|
22673
|
+
}
|
|
22674
|
+
const Qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22675
|
+
__proto__: null,
|
|
22676
|
+
resolve: de
|
|
22677
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
22678
|
+
async function Yt(e, a) {
|
|
22679
|
+
const { sourceQuery: t, records: i } = a, n = await de(t, { records: i }), r = jt(n), s = await e.getRoot(), u = await e.ensureChild(s, {
|
|
22680
|
+
tagName: "DataTypeTemplates",
|
|
22681
|
+
attributes: {}
|
|
22682
|
+
});
|
|
22683
|
+
for (const c of r) {
|
|
22684
|
+
const o = await t.getAttribute(c, { name: "id" });
|
|
22685
|
+
if (!o) continue;
|
|
22686
|
+
const [l] = await e.findByAttributes({
|
|
22687
|
+
tagName: c.tagName,
|
|
22688
|
+
attributes: { id: o }
|
|
22689
|
+
});
|
|
22690
|
+
if (l) continue;
|
|
22691
|
+
const d = await t.getTree(c);
|
|
22692
|
+
d && await e.deepClone(u, d);
|
|
22693
|
+
}
|
|
22694
|
+
}
|
|
22695
|
+
function jt(e) {
|
|
22696
|
+
return [...e.lnodeTypes, ...e.doTypes, ...e.daTypes, ...e.enumTypes];
|
|
22697
|
+
}
|
|
22698
|
+
const $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22699
|
+
__proto__: null,
|
|
22700
|
+
extract: Yt
|
|
22701
|
+
}, Symbol.toStringTag, { value: "Module" })), pe = {
|
|
22702
|
+
query: Qt,
|
|
22703
|
+
transaction: $t
|
|
22704
|
+
};
|
|
22705
|
+
async function Se(e) {
|
|
22706
|
+
const a = await e.getRecord({ tagName: "History" });
|
|
22707
|
+
if (!a) return [];
|
|
22708
|
+
const { Hitem: t = [] } = await e.findDescendants(a, { collect: "Hitem" });
|
|
22709
|
+
function i(r, s) {
|
|
22710
|
+
return Number(r.attributes.find((u) => u.name === s)?.value || 0);
|
|
22711
|
+
}
|
|
22712
|
+
return [...t].sort((r, s) => {
|
|
22713
|
+
const u = i(r, "version") - i(s, "version");
|
|
22714
|
+
return u !== 0 ? u : i(r, "revision") - i(s, "revision");
|
|
22715
|
+
});
|
|
22716
|
+
}
|
|
22717
|
+
async function fe(e) {
|
|
22718
|
+
return (await Se(e)).at(-1);
|
|
22719
|
+
}
|
|
22720
|
+
const Jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22721
|
+
__proto__: null,
|
|
22722
|
+
getLatestHitem: fe,
|
|
22723
|
+
getSortedHitems: Se
|
|
22724
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
22725
|
+
async function ea(e, a) {
|
|
22726
|
+
const { filename: t, header: i, item: n } = a, { id: r, fileType: s, nameStructure: u, version: c, tool: o } = i, { who: l, what: d, why: f } = n, S = await e.getRoot(), h = await e.getRecord({ tagName: "Header" }) ?? await e.addChild(S, {
|
|
22727
|
+
tagName: "Header",
|
|
22728
|
+
attributes: {
|
|
22729
|
+
id: r ?? t.replace(/\.[^.]+$/, "").toLowerCase().replace(/\s+/g, "_"),
|
|
22730
|
+
toolID: o,
|
|
22731
|
+
fileType: s,
|
|
22732
|
+
...u ? { nameStructure: u } : {},
|
|
22733
|
+
version: "0",
|
|
22734
|
+
revision: "1",
|
|
22735
|
+
uuid: crypto.randomUUID()
|
|
22736
|
+
}
|
|
22737
|
+
}), C = await e.getRecord({ tagName: "History" }) ?? await e.addChild(h, { tagName: "History", attributes: {} }), H = await fe(e), q = H?.attributes.find((E) => E.name === "version")?.value, W = H?.attributes.find((E) => E.name === "revision")?.value, x = c === "keep" ? q ?? "0" : q ? String(Number(q) + 1) : "0", O = W ? String(Number(W) + 1) : "1";
|
|
22738
|
+
await e.update(h, {
|
|
22739
|
+
attributes: { version: x, revision: O }
|
|
22740
|
+
});
|
|
22741
|
+
const K = /* @__PURE__ */ new Date(), g = K.toString().split(" "), Ae = K.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop(), Pe = `${g[0]} ${g[1]} ${g[2]} ${g[4]} ${Ae} ${g[3]}`;
|
|
22742
|
+
await e.addChild(C, {
|
|
22743
|
+
tagName: "Hitem",
|
|
22744
|
+
attributes: {
|
|
22745
|
+
version: x,
|
|
22746
|
+
revision: O,
|
|
22747
|
+
when: Pe,
|
|
22748
|
+
who: l,
|
|
22749
|
+
what: d,
|
|
22750
|
+
why: f
|
|
22751
|
+
}
|
|
22752
|
+
}), await e.update(h, {
|
|
22753
|
+
attributes: { version: x, revision: O }
|
|
22754
|
+
});
|
|
22755
|
+
}
|
|
22756
|
+
const ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22757
|
+
__proto__: null,
|
|
22758
|
+
addEntry: ea
|
|
22759
|
+
}, Symbol.toStringTag, { value: "Module" })), z = {
|
|
22760
|
+
query: Jt,
|
|
22761
|
+
transaction: ta
|
|
22762
|
+
}, aa = {
|
|
22763
|
+
LNode: ["prefix", "lnClass", "lnInst"],
|
|
22764
|
+
LN: ["prefix", "lnClass", "inst"],
|
|
22765
|
+
LN0: ["prefix", "lnClass", "inst"],
|
|
22766
|
+
LDevice: ["inst"],
|
|
22767
|
+
ConnectedAP: ["iedName", "apName"],
|
|
22768
|
+
GSE: ["ldInst", "cbName"],
|
|
22769
|
+
SMV: ["ldInst", "cbName"],
|
|
22770
|
+
Private: ["type"],
|
|
22771
|
+
EnumVal: ["ord"],
|
|
22772
|
+
Association: ["associationID"],
|
|
22773
|
+
ConnectivityNode: ["pathName"],
|
|
22774
|
+
ControlRef: ["output", "outputInst"],
|
|
22775
|
+
SourceRef: ["input", "inputInst"],
|
|
22776
|
+
FunctionRoleContent: ["roleInst"],
|
|
22777
|
+
Resource: ["resInst"],
|
|
22778
|
+
Hitem: ["version", "revision"],
|
|
22779
|
+
History: ["version", "revision"]
|
|
22780
|
+
}, ia = {
|
|
22781
|
+
ConnectedAP: " / ",
|
|
22782
|
+
GSE: "/",
|
|
22783
|
+
SMV: "/",
|
|
22784
|
+
Hitem: ".",
|
|
22785
|
+
History: ".",
|
|
22786
|
+
ControlRef: "/",
|
|
22787
|
+
SourceRef: "/"
|
|
22788
|
+
};
|
|
22789
|
+
async function na(e, a) {
|
|
22790
|
+
const t = await e.getRecord(a);
|
|
22791
|
+
if (!t) return "";
|
|
22792
|
+
const i = t.tagName, n = await e.any.getAttributes(t), r = aa[i];
|
|
22793
|
+
if (r) {
|
|
22794
|
+
const o = ia[i] ?? "", l = r.map((d) => n[d]).filter(Boolean);
|
|
22795
|
+
return l.length > 0 ? l.join(o) : i;
|
|
22796
|
+
}
|
|
22797
|
+
const u = G[i]?.attributes?.identityFields, c = u?.find((o) => o === "name" || o === "id") ?? u?.[0];
|
|
22798
|
+
return c ? n[c] || i : n.name || i;
|
|
22799
|
+
}
|
|
22800
|
+
const ra = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22801
|
+
__proto__: null,
|
|
22802
|
+
extractElementTitle: na
|
|
22803
|
+
}, Symbol.toStringTag, { value: "Module" })), sa = {
|
|
22804
|
+
query: ra
|
|
22805
|
+
};
|
|
22806
|
+
async function _(e) {
|
|
22807
|
+
const a = await e.getRoot(), t = await e.ensureChild(a, {
|
|
22808
|
+
tagName: "Substation",
|
|
22809
|
+
attributes: { name: "TEMPLATE" }
|
|
22810
|
+
}), i = await e.ensureChild(t, {
|
|
22811
|
+
tagName: "VoltageLevel",
|
|
22812
|
+
attributes: { name: "TEMPLATE" }
|
|
22813
|
+
}), n = await e.ensureChild(i, {
|
|
22814
|
+
tagName: "Bay",
|
|
22815
|
+
attributes: { name: "TEMPLATE" }
|
|
22816
|
+
});
|
|
22817
|
+
return {
|
|
22818
|
+
Substation: t,
|
|
22819
|
+
VoltageLevel: i,
|
|
22820
|
+
Bay: n
|
|
22821
|
+
};
|
|
22822
|
+
}
|
|
22823
|
+
const ua = {
|
|
22824
|
+
scope: "tree",
|
|
22825
|
+
attributes: ["templateUuid", "originUuid"]
|
|
22826
|
+
};
|
|
22827
|
+
async function y(e, a) {
|
|
22828
|
+
const { sourceQuery: t, ref: i, targetParent: n, omit: r, promoteRoot: s, strip: u = ua } = a, c = await t.getTree(i, { omit: r });
|
|
22829
|
+
if (!c) return;
|
|
22830
|
+
const o = s && c.tagName === s.from ? { ...c, tagName: s.to } : c;
|
|
22831
|
+
let l = o;
|
|
22832
|
+
u && (l = u.scope === "tree" ? Ce(o, u.attributes) : {
|
|
22833
|
+
...o,
|
|
22834
|
+
attributes: o.attributes.filter((d) => !u.attributes.includes(d.name))
|
|
22835
|
+
}), await e.deepClone(n, l);
|
|
22836
|
+
}
|
|
22837
|
+
async function ca(e, a) {
|
|
22838
|
+
const { sourceQuery: t, scopeRef: i } = a, { LNode: n = [] } = await t.findDescendants(i, {
|
|
22839
|
+
collect: "LNode"
|
|
22840
|
+
});
|
|
22841
|
+
n.length > 0 && await pe.transaction.extract(e, { sourceQuery: t, records: n });
|
|
22842
|
+
}
|
|
22843
|
+
async function Z(e, a, t) {
|
|
22844
|
+
const n = (await e.findAncestors(a, { stopAtTagName: "Substation" })).find((s) => s.tagName in t);
|
|
22845
|
+
F(n, {
|
|
22846
|
+
key: "ELEMENT_NOT_FOUND",
|
|
22847
|
+
detail: `No Substation/VoltageLevel/Bay ancestor found for ${a.tagName}`
|
|
22848
|
+
});
|
|
22849
|
+
const r = t[n.tagName];
|
|
22850
|
+
return { tagName: r.tagName, id: r.id };
|
|
22851
|
+
}
|
|
22852
|
+
async function me(e, a) {
|
|
22853
|
+
const { sourceQuery: t, functionRef: i, targetParentRef: n, omit: r, stripRootAttributes: s } = a, u = s?.length ? { scope: "root", attributes: [...s] } : !1;
|
|
22854
|
+
await y(e, {
|
|
22855
|
+
sourceQuery: t,
|
|
22856
|
+
ref: i,
|
|
22857
|
+
targetParent: n,
|
|
22858
|
+
omit: r,
|
|
22859
|
+
promoteRoot: { from: "SubFunction", to: "Function" },
|
|
22860
|
+
strip: u
|
|
22861
|
+
}), await ca(e, { sourceQuery: t, scopeRef: i });
|
|
22862
|
+
}
|
|
22863
|
+
async function be(e, a) {
|
|
22864
|
+
const { sourceQuery: t, functionRef: i, structure: n, stripCategoriesUuid: r = !0 } = a, s = await oa(t, i);
|
|
22865
|
+
for (const u of s) {
|
|
22866
|
+
if (await da(e, t, u)) continue;
|
|
22867
|
+
const o = { tagName: "FunctionCategory", id: u }, l = await Z(t, o, n);
|
|
22868
|
+
await y(e, {
|
|
22869
|
+
sourceQuery: t,
|
|
22870
|
+
ref: o,
|
|
22871
|
+
targetParent: l,
|
|
22872
|
+
...r ? {} : { strip: !1 }
|
|
22873
|
+
});
|
|
22874
|
+
}
|
|
22875
|
+
}
|
|
22876
|
+
async function oa(e, a) {
|
|
22877
|
+
const t = await la(e, a), i = /* @__PURE__ */ new Set();
|
|
22878
|
+
for (const { container: n } of t)
|
|
22879
|
+
n && i.add(n.id);
|
|
22880
|
+
return i;
|
|
22881
|
+
}
|
|
22882
|
+
async function la(e, a) {
|
|
22883
|
+
const t = await T.query.findRefsPointingTo(e, {
|
|
22884
|
+
target: a,
|
|
22885
|
+
containerTagName: "FunctionCategory"
|
|
22886
|
+
}), { SubFunction: i = [] } = await e.findDescendants(a, {
|
|
22887
|
+
collect: "SubFunction"
|
|
22888
|
+
});
|
|
22889
|
+
for (const n of i) {
|
|
22890
|
+
const r = await T.query.findRefsPointingTo(e, {
|
|
22891
|
+
target: { tagName: "SubFunction", id: n.id },
|
|
22892
|
+
containerTagName: "FunctionCategory"
|
|
22893
|
+
});
|
|
22894
|
+
t.push(...r);
|
|
22895
|
+
}
|
|
22896
|
+
return t;
|
|
22897
|
+
}
|
|
22898
|
+
async function da(e, a, t) {
|
|
22899
|
+
const i = await a.getRecord({
|
|
22900
|
+
tagName: "FunctionCategory",
|
|
22901
|
+
id: t
|
|
22902
|
+
});
|
|
22903
|
+
if (!i) return !1;
|
|
22904
|
+
const n = await a.getAttribute(i, { name: "name" });
|
|
22905
|
+
if (!n) return !1;
|
|
22906
|
+
const [r] = await e.findByAttributes({
|
|
22907
|
+
tagName: "FunctionCategory",
|
|
22908
|
+
attributes: { name: n }
|
|
22909
|
+
});
|
|
22910
|
+
return !!r;
|
|
22911
|
+
}
|
|
22912
|
+
async function Re(e, a) {
|
|
22913
|
+
const { sourceQuery: t, scopeRef: i, refTagName: n, targetTagName: r } = a, s = m[n][0].attribute.uuid, u = await t.findDescendants(i, {
|
|
22914
|
+
collect: n
|
|
22915
|
+
}), { [n]: c = [] } = u, o = /* @__PURE__ */ new Set();
|
|
22916
|
+
for (const d of c) {
|
|
22917
|
+
const f = d.attributes.find(
|
|
22918
|
+
(S) => S.name === s
|
|
22919
|
+
)?.value;
|
|
22920
|
+
f && o.add(f);
|
|
22921
|
+
}
|
|
22922
|
+
const l = [];
|
|
22923
|
+
for (const d of o) {
|
|
22924
|
+
const f = { uuid: d }, [S] = await e.findByAttributes({ tagName: r, attributes: f });
|
|
22925
|
+
if (S) continue;
|
|
22926
|
+
const [L] = await t.findByAttributes({
|
|
22927
|
+
tagName: r,
|
|
22928
|
+
attributes: f
|
|
22929
|
+
});
|
|
22930
|
+
L && l.push({ tagName: r, id: L.id });
|
|
22931
|
+
}
|
|
22932
|
+
return l;
|
|
22933
|
+
}
|
|
22934
|
+
async function pa(e, a) {
|
|
22935
|
+
const { sourceQuery: t, scopeRef: i, refTagName: n, targetTagName: r, targetParent: s, omit: u } = a, c = await Re(e, {
|
|
22936
|
+
sourceQuery: t,
|
|
22937
|
+
scopeRef: i,
|
|
22938
|
+
refTagName: n,
|
|
22939
|
+
targetTagName: r
|
|
22940
|
+
});
|
|
22941
|
+
for (const o of c)
|
|
22942
|
+
await y(e, { sourceQuery: t, ref: o, targetParent: s, omit: u });
|
|
22943
|
+
}
|
|
22944
|
+
async function Sa(e, a) {
|
|
22945
|
+
const { sourceQuery: t, scopeTagName: i, scopeRef: n, targetParent: r, skip: s = /* @__PURE__ */ new Set(), omit: u } = a, c = X[i].filter(
|
|
22946
|
+
(l) => l in m && !s.has(l)
|
|
22947
|
+
), o = pa;
|
|
22948
|
+
for (const l of c)
|
|
22949
|
+
for (const d of m[l])
|
|
22950
|
+
for (const f of d.target)
|
|
22951
|
+
await o(e, {
|
|
22952
|
+
sourceQuery: t,
|
|
22953
|
+
scopeRef: n,
|
|
22954
|
+
refTagName: l,
|
|
22955
|
+
targetTagName: f,
|
|
22956
|
+
targetParent: r,
|
|
22957
|
+
omit: u
|
|
22958
|
+
});
|
|
22959
|
+
}
|
|
22960
|
+
const D = [
|
|
22961
|
+
"FunctionSclRef",
|
|
22962
|
+
"ApplicationSclRef",
|
|
22963
|
+
"GeneralEquipment",
|
|
22964
|
+
"ConductingEquipment"
|
|
22965
|
+
], fa = [
|
|
22966
|
+
...D,
|
|
22967
|
+
"DOS",
|
|
22968
|
+
"Labels",
|
|
22969
|
+
"LNodeInputs",
|
|
22970
|
+
"LNodeOutputs",
|
|
22971
|
+
"ProcessResources",
|
|
22972
|
+
"PowerSystemRelations",
|
|
22973
|
+
"BehaviorDescription",
|
|
22974
|
+
"Variable"
|
|
22975
|
+
];
|
|
22976
|
+
async function ma(e, a) {
|
|
22977
|
+
const { sourceQuery: t, applicationRef: i, structure: n } = a, r = {
|
|
22978
|
+
tagName: "Substation",
|
|
22979
|
+
id: n.Substation.id
|
|
22980
|
+
}, s = await Re(e, {
|
|
22981
|
+
sourceQuery: t,
|
|
22982
|
+
scopeRef: i,
|
|
22983
|
+
refTagName: "FunctionRef",
|
|
22984
|
+
targetTagName: "Function"
|
|
22985
|
+
});
|
|
22986
|
+
for (const o of s) {
|
|
22987
|
+
const l = await Z(t, o, n);
|
|
22988
|
+
await me(e, {
|
|
22989
|
+
sourceQuery: t,
|
|
22990
|
+
functionRef: o,
|
|
22991
|
+
targetParentRef: l,
|
|
22992
|
+
omit: D
|
|
22993
|
+
});
|
|
22994
|
+
}
|
|
22995
|
+
for (const o of s)
|
|
22996
|
+
await be(e, {
|
|
22997
|
+
sourceQuery: t,
|
|
22998
|
+
functionRef: o,
|
|
22999
|
+
structure: n,
|
|
23000
|
+
stripCategoriesUuid: !1
|
|
23001
|
+
});
|
|
23002
|
+
await Sa(e, {
|
|
23003
|
+
sourceQuery: t,
|
|
23004
|
+
scopeTagName: "Application",
|
|
23005
|
+
scopeRef: i,
|
|
23006
|
+
targetParent: r,
|
|
23007
|
+
skip: /* @__PURE__ */ new Set(["FunctionRef", "FunctionCategoryRef"]),
|
|
23008
|
+
omit: D
|
|
23009
|
+
});
|
|
23010
|
+
const c = await Z(t, i, n);
|
|
23011
|
+
await y(e, { sourceQuery: t, ref: i, targetParent: c, omit: D });
|
|
23012
|
+
}
|
|
23013
|
+
async function Le(e) {
|
|
23014
|
+
await w.transaction.orphanUuidRefs(e), await w.transaction.resetLNode(e), await w.transaction.pruneEmptyContainers(e);
|
|
23015
|
+
}
|
|
23016
|
+
async function ba(e, a) {
|
|
23017
|
+
const { sourceQuery: t, applicationRef: i, tool: n, who: r, nameStructure: s } = a, u = await _(e), c = await e.getAttribute(i, { name: "name" }) || "Unnamed Application";
|
|
23018
|
+
await z.transaction.addEntry(e, {
|
|
23019
|
+
filename: `ASD_${c.replace(/\s+/g, "_")}`,
|
|
23020
|
+
header: {
|
|
23021
|
+
fileType: "ASD",
|
|
23022
|
+
version: "keep",
|
|
23023
|
+
tool: n,
|
|
23024
|
+
...s ? { nameStructure: s } : {}
|
|
23025
|
+
},
|
|
23026
|
+
item: {
|
|
23027
|
+
who: r,
|
|
23028
|
+
what: "ASD initialization",
|
|
23029
|
+
why: "Application was extracted from a previous file"
|
|
23030
|
+
}
|
|
23031
|
+
}), await ma(e, { sourceQuery: t, applicationRef: i, structure: u }), await Le(e);
|
|
23032
|
+
}
|
|
23033
|
+
async function Ra(e, a) {
|
|
23034
|
+
const { sourceQuery: t, functionRef: i, tool: n, who: r, nameStructure: s } = a, u = await _(e), c = {
|
|
23035
|
+
tagName: u.Substation.tagName,
|
|
23036
|
+
id: u.Substation.id
|
|
23037
|
+
}, o = await t.getAttribute(i, { name: "name" }) || "Unnamed Function";
|
|
23038
|
+
await z.transaction.addEntry(e, {
|
|
23039
|
+
filename: `FSD_${o.replace(/\s+/g, "_")}`,
|
|
23040
|
+
header: {
|
|
23041
|
+
fileType: "FSD",
|
|
23042
|
+
version: "keep",
|
|
23043
|
+
tool: n,
|
|
23044
|
+
...s ? { nameStructure: s } : {}
|
|
23045
|
+
},
|
|
23046
|
+
item: {
|
|
23047
|
+
who: r,
|
|
23048
|
+
what: "FSD initialization",
|
|
23049
|
+
why: "Function was extracted from a previous file"
|
|
23050
|
+
}
|
|
23051
|
+
}), await me(e, {
|
|
23052
|
+
sourceQuery: t,
|
|
23053
|
+
functionRef: i,
|
|
23054
|
+
targetParentRef: c,
|
|
23055
|
+
omit: fa,
|
|
23056
|
+
stripRootAttributes: ["templateUuid"]
|
|
23057
|
+
}), await be(e, {
|
|
23058
|
+
sourceQuery: t,
|
|
23059
|
+
functionRef: i,
|
|
23060
|
+
structure: u
|
|
23061
|
+
}), await Le(e);
|
|
23062
|
+
}
|
|
23063
|
+
const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
23064
|
+
__proto__: null,
|
|
23065
|
+
ensureSubstationTemplateStructure: _,
|
|
23066
|
+
extractToAsd: ba,
|
|
23067
|
+
extractToFsd: Ra
|
|
23068
|
+
}, Symbol.toStringTag, { value: "Module" })), Aa = {
|
|
23069
|
+
transaction: La
|
|
23070
|
+
}, va = {
|
|
23071
|
+
cleanUp: w,
|
|
23072
|
+
dataModel: pe,
|
|
23073
|
+
history: z,
|
|
23074
|
+
reference: T,
|
|
23075
|
+
template: Aa,
|
|
23076
|
+
presentation: sa
|
|
22505
23077
|
};
|
|
22506
23078
|
export {
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
|
|
22511
|
-
|
|
22512
|
-
|
|
22513
|
-
X as a,
|
|
22514
|
-
dt as b,
|
|
22515
|
-
lt as c,
|
|
22516
|
-
pt as d,
|
|
22517
|
-
z as r
|
|
23079
|
+
ga as H,
|
|
23080
|
+
Bt as S,
|
|
23081
|
+
P as a,
|
|
23082
|
+
va as b,
|
|
23083
|
+
Gt as c,
|
|
23084
|
+
Ut as d
|
|
22518
23085
|
};
|