@dialecte/scl 0.1.16 → 0.1.17

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.
@@ -22473,14 +22473,15 @@ const bt = {
22473
22473
  beforeDelete: dt
22474
22474
  };
22475
22475
  export {
22476
- X as D,
22476
+ D,
22477
22477
  bt as H,
22478
22478
  te as K,
22479
22479
  mt as R,
22480
22480
  L as S,
22481
22481
  m as U,
22482
- ye as a,
22483
- qe as b,
22484
- xe as c,
22482
+ X as a,
22483
+ ye as b,
22484
+ qe as c,
22485
+ xe as d,
22485
22486
  Z as r
22486
22487
  };
@@ -20,6 +20,9 @@ export declare function openSclDocument<CustomModules extends ExtensionModules =
20
20
  template: {
21
21
  transaction: typeof import("./extensions/template/transaction");
22
22
  };
23
+ presentation: {
24
+ query: typeof import("./extensions/presentation/query");
25
+ };
23
26
  } & CustomModules>>;
24
27
  export declare function createSclDocument<CustomModules extends ExtensionModules = Record<never, never>>(params: {
25
28
  storage: StorageOptions;
@@ -42,5 +45,8 @@ export declare function createSclDocument<CustomModules extends ExtensionModules
42
45
  template: {
43
46
  transaction: typeof import("./extensions/template/transaction");
44
47
  };
48
+ presentation: {
49
+ query: typeof import("./extensions/presentation/query");
50
+ };
45
51
  } & CustomModules>>>;
46
52
  //# sourceMappingURL=dialecte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dialecte.d.ts","sourceRoot":"","sources":["../../src/v2019C1/dialecte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtE,wBAAgB,eAAe,CAC9B,aAAa,SAAS,gBAAgB,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC5D,MAAM,EAAE;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,EAAE,aAAa,CAAA;CAAE;;;;;;;;;;;;;;;;;;oBAShE;AAED,wBAAsB,iBAAiB,CACtC,aAAa,SAAS,gBAAgB,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC5D,MAAM,EAAE;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,EAAE,aAAa,CAAA;CAAE;;;;;;;;;;;;;;;;;;qBAShE"}
1
+ {"version":3,"file":"dialecte.d.ts","sourceRoot":"","sources":["../../src/v2019C1/dialecte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtE,wBAAgB,eAAe,CAC9B,aAAa,SAAS,gBAAgB,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC5D,MAAM,EAAE;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,EAAE,aAAa,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;oBAShE;AAED,wBAAsB,iBAAiB,CACtC,aAAa,SAAS,gBAAgB,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC5D,MAAM,EAAE;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,EAAE,aAAa,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;qBAShE"}
@@ -16,5 +16,8 @@ export declare const SCL_EXTENSION_MODULES: {
16
16
  template: {
17
17
  transaction: typeof import("./template/transaction");
18
18
  };
19
+ presentation: {
20
+ query: typeof import("./presentation/query");
21
+ };
19
22
  };
20
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v2019C1/extensions/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;CAAuD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v2019C1/extensions/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAOjC,CAAA"}
@@ -1,9 +1,9 @@
1
- import { R as q, U as w, K as Z, r as C, D as J, H as U, S as R } from "../index-lHFSidP5.js";
2
- import { a as $t, b as Qt, c as zt } from "../index-lHFSidP5.js";
3
- import { isChildOf as b, stripAttributes as x } from "@dialecte/core/helpers";
4
- import { invariant as B } from "@dialecte/core/utils";
5
- import { createDialecteDocument as tt, openDialecteDocument as et, importXmlFiles as at, exportXmlFile as nt } from "@dialecte/core";
6
- async function ot(t) {
1
+ import { R as q, U as b, K as Z, D as J, r as h, a as x, H as B, S as R } from "../index-QAjOle0s.js";
2
+ import { b as Xt, c as Yt, d as Wt } from "../index-QAjOle0s.js";
3
+ import { isChildOf as w, stripAttributes as tt } from "@dialecte/core/helpers";
4
+ import { invariant as U } from "@dialecte/core/utils";
5
+ import { createDialecteDocument as et, openDialecteDocument as nt, importXmlFiles as at, exportXmlFile as ot } from "@dialecte/core";
6
+ async function it(t) {
7
7
  const a = await t.getRecordsByTagName("LNode");
8
8
  for (const e of a) {
9
9
  const n = await t.getAttribute(e, { name: "iedName" });
@@ -12,10 +12,10 @@ async function ot(t) {
12
12
  tagName: "IED",
13
13
  attributes: { name: n }
14
14
  });
15
- o || await it(t, e);
15
+ o || await st(t, e);
16
16
  }
17
17
  }
18
- async function it(t, a) {
18
+ async function st(t, a) {
19
19
  const e = await t.getChild(a, "LNodeSpecNaming");
20
20
  if (e) {
21
21
  const n = await t.getAttribute(e, { name: "sLnClass" }), o = await t.getAttribute(e, { name: "sLnInst" }), i = await t.getAttribute(e, { name: "sPrefix" });
@@ -45,7 +45,7 @@ async function it(t, a) {
45
45
  }
46
46
  });
47
47
  }
48
- async function st(t) {
48
+ async function rt(t) {
49
49
  const a = [...Object.values(q).flat(), "Private"];
50
50
  for (const e of a) {
51
51
  const n = await t.getRecordsByTagName(e);
@@ -53,33 +53,33 @@ async function st(t) {
53
53
  o.children.length === 0 && await t.delete(o);
54
54
  }
55
55
  }
56
- async function rt(t) {
57
- const a = Object.keys(w);
56
+ async function ct(t) {
57
+ const a = Object.keys(b);
58
58
  for (const e of a) {
59
- const n = w[e], o = await t.getRecordsByTagName(e);
59
+ const n = b[e], o = await t.getRecordsByTagName(e);
60
60
  for (const i of o) {
61
- let r = !1, c = !1;
62
- const u = {};
61
+ let u = !1, r = !1;
62
+ const c = {};
63
63
  for (const f of n) {
64
64
  const l = await t.getAttribute(i, {
65
65
  name: f.attribute.uuid
66
66
  });
67
67
  if (!l) continue;
68
- if (r = !0, await ct(t, l, f.target))
69
- c = !0;
68
+ if (u = !0, await ut(t, l, f.target))
69
+ r = !0;
70
70
  else {
71
- u[f.attribute.uuid] = void 0, u[f.attribute.path] = void 0;
71
+ c[f.attribute.uuid] = void 0, c[f.attribute.path] = void 0;
72
72
  for (const p of f.companions)
73
- u[p.name] = void 0;
73
+ c[p.name] = void 0;
74
74
  }
75
75
  }
76
- Object.keys(u).length > 0 && await t.update(i, { attributes: u });
76
+ Object.keys(c).length > 0 && await t.update(i, { attributes: c });
77
77
  const s = Z.has(e);
78
- r && !c && !s && await t.delete(i);
78
+ u && !r && !s && await t.delete(i);
79
79
  }
80
80
  }
81
81
  }
82
- async function ct(t, a, e) {
82
+ async function ut(t, a, e) {
83
83
  for (const n of e) {
84
84
  const [o] = await t.findByAttributes({
85
85
  tagName: n,
@@ -89,13 +89,13 @@ async function ct(t, a, e) {
89
89
  }
90
90
  return !1;
91
91
  }
92
- const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
92
+ const dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
93
93
  __proto__: null,
94
- orphanUuidRefs: rt,
95
- pruneEmptyContainers: st,
96
- resetLNode: ot
94
+ orphanUuidRefs: ct,
95
+ pruneEmptyContainers: rt,
96
+ resetLNode: it
97
97
  }, Symbol.toStringTag, { value: "Module" })), N = {
98
- transaction: ut
98
+ transaction: dt
99
99
  };
100
100
  async function H(t, a) {
101
101
  const { records: e } = a, n = {
@@ -107,16 +107,16 @@ async function H(t, a) {
107
107
  for (const o of e) {
108
108
  const i = await t.getAttribute(o, { name: "lnType" });
109
109
  if (!i) continue;
110
- const [r] = await t.findByAttributes({
110
+ const [u] = await t.findByAttributes({
111
111
  tagName: "LNodeType",
112
112
  attributes: { id: i }
113
113
  });
114
- if (B(r, {
114
+ if (U(u, {
115
115
  key: "ELEMENT_NOT_FOUND",
116
116
  detail: `LNodeType not found for lnType="${i}"`
117
- }), !y(n.lnodeTypes, i, r)) continue;
118
- const c = r.children.filter((s) => b(s, "DO")), u = await t.getRecords(c);
119
- for (const s of u) {
117
+ }), !y(n.lnodeTypes, i, u)) continue;
118
+ const r = u.children.filter((s) => w(s, "DO")), c = await t.getRecords(r);
119
+ for (const s of c) {
120
120
  if (!s) continue;
121
121
  const d = await t.getAttribute(s, { name: "type" });
122
122
  if (!d) continue;
@@ -124,7 +124,7 @@ async function H(t, a) {
124
124
  tagName: "DOType",
125
125
  attributes: { id: d }
126
126
  });
127
- f && y(n.doTypes, d, f) && await E({ query: t, parent: f, dataModelMap: n });
127
+ f && y(n.doTypes, d, f) && await D({ query: t, parent: f, dataModelMap: n });
128
128
  }
129
129
  }
130
130
  return {
@@ -137,129 +137,172 @@ async function H(t, a) {
137
137
  function y(t, a, e) {
138
138
  return t.has(a) ? !1 : (t.set(a, e), !0);
139
139
  }
140
- async function E(t) {
141
- const { query: a, parent: e, dataModelMap: n } = t, o = e.tagName === "DOType" ? await a.getRecords(e.children.filter((i) => b(i, "DA"))) : await a.getRecords(e.children.filter((i) => b(i, "BDA")));
140
+ async function D(t) {
141
+ const { query: a, parent: e, dataModelMap: n } = t, o = e.tagName === "DOType" ? await a.getRecords(e.children.filter((i) => w(i, "DA"))) : await a.getRecords(e.children.filter((i) => w(i, "BDA")));
142
142
  for (const i of o) {
143
143
  if (!i) continue;
144
- const r = await a.getAttribute(i, { name: "bType" }), c = await a.getAttribute(i, { name: "type" });
145
- if (c) {
146
- if (r === "Enum") {
147
- const [u] = await a.findByAttributes({
144
+ const u = await a.getAttribute(i, { name: "bType" }), r = await a.getAttribute(i, { name: "type" });
145
+ if (r) {
146
+ if (u === "Enum") {
147
+ const [c] = await a.findByAttributes({
148
148
  tagName: "EnumType",
149
- attributes: { id: c }
149
+ attributes: { id: r }
150
150
  });
151
- u && y(n.enumTypes, c, u);
152
- } else if (r === "Struct") {
153
- const [u] = await a.findByAttributes({
151
+ c && y(n.enumTypes, r, c);
152
+ } else if (u === "Struct") {
153
+ const [c] = await a.findByAttributes({
154
154
  tagName: "DAType",
155
- attributes: { id: c }
155
+ attributes: { id: r }
156
156
  });
157
- u && y(n.daTypes, c, u) && await E({ query: a, parent: u, dataModelMap: n });
157
+ c && y(n.daTypes, r, c) && await D({ query: a, parent: c, dataModelMap: n });
158
158
  }
159
159
  }
160
160
  }
161
161
  if (e.tagName === "DOType") {
162
- const i = e.children.filter((c) => b(c, "SDO")), r = await a.getRecords(i);
163
- for (const c of r) {
164
- const u = await a.getAttribute(c, { name: "type" });
165
- if (!u) continue;
162
+ const i = e.children.filter((r) => w(r, "SDO")), u = await a.getRecords(i);
163
+ for (const r of u) {
164
+ const c = await a.getAttribute(r, { name: "type" });
165
+ if (!c) continue;
166
166
  const [s] = await a.findByAttributes({
167
167
  tagName: "DOType",
168
- attributes: { id: u }
168
+ attributes: { id: c }
169
169
  });
170
- s && y(n.doTypes, u, s) && await E({ query: a, parent: s, dataModelMap: n });
170
+ s && y(n.doTypes, c, s) && await D({ query: a, parent: s, dataModelMap: n });
171
171
  }
172
172
  }
173
173
  }
174
- const dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
174
+ const ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
175
175
  __proto__: null,
176
176
  resolve: H
177
177
  }, Symbol.toStringTag, { value: "Module" }));
178
- async function ft(t, a) {
179
- const { sourceQuery: e, records: n } = a, o = await H(e, { records: n }), i = lt(o), r = await t.getRoot(), c = await t.ensureChild(r, {
178
+ async function lt(t, a) {
179
+ const { sourceQuery: e, records: n } = a, o = await H(e, { records: n }), i = mt(o), u = await t.getRoot(), r = await t.ensureChild(u, {
180
180
  tagName: "DataTypeTemplates",
181
181
  attributes: {}
182
182
  });
183
- for (const u of i) {
184
- const s = await e.getAttribute(u, { name: "id" });
183
+ for (const c of i) {
184
+ const s = await e.getAttribute(c, { name: "id" });
185
185
  if (!s) continue;
186
186
  const [d] = await t.findByAttributes({
187
- tagName: u.tagName,
187
+ tagName: c.tagName,
188
188
  attributes: { id: s }
189
189
  });
190
190
  if (d) continue;
191
- const f = await e.getTree(u);
192
- f && await t.deepClone(c, f);
191
+ const f = await e.getTree(c);
192
+ f && await t.deepClone(r, f);
193
193
  }
194
194
  }
195
- function lt(t) {
195
+ function mt(t) {
196
196
  return [...t.lnodeTypes, ...t.doTypes, ...t.daTypes, ...t.enumTypes];
197
197
  }
198
- const mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
198
+ const pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
199
199
  __proto__: null,
200
- extract: ft
200
+ extract: lt
201
201
  }, Symbol.toStringTag, { value: "Module" })), j = {
202
- query: dt,
203
- transaction: mt
202
+ query: ft,
203
+ transaction: pt
204
204
  };
205
205
  async function k(t) {
206
206
  const a = await t.getRecord({ tagName: "History" });
207
207
  if (!a) return [];
208
208
  const { Hitem: e = [] } = await t.findDescendants(a);
209
209
  return [...e].sort((n, o) => {
210
- const i = Number(n.attributes.find((s) => s.name === "version")?.value || 0), r = Number(o.attributes.find((s) => s.name === "version")?.value || 0);
211
- if (i !== r) return i - r;
212
- const c = Number(n.attributes.find((s) => s.name === "revision")?.value || 0), u = Number(o.attributes.find((s) => s.name === "revision")?.value || 0);
213
- return c - u;
210
+ const i = Number(n.attributes.find((s) => s.name === "version")?.value || 0), u = Number(o.attributes.find((s) => s.name === "version")?.value || 0);
211
+ if (i !== u) return i - u;
212
+ const r = Number(n.attributes.find((s) => s.name === "revision")?.value || 0), c = Number(o.attributes.find((s) => s.name === "revision")?.value || 0);
213
+ return r - c;
214
214
  });
215
215
  }
216
- async function $(t) {
216
+ async function V(t) {
217
217
  return (await k(t)).at(-1);
218
218
  }
219
- const pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
219
+ const gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
220
220
  __proto__: null,
221
- getLatestHitem: $,
221
+ getLatestHitem: V,
222
222
  getSortedHitems: k
223
223
  }, Symbol.toStringTag, { value: "Module" }));
224
- async function gt(t, a) {
225
- const { filename: e, header: n, item: o } = a, { id: i, fileType: r, nameStructure: c, version: u, tool: s } = n, { who: d, what: f, why: l } = o, m = await t.getRoot(), A = await t.getRecord({ tagName: "Header" }) ?? await t.addChild(m, {
224
+ async function yt(t, a) {
225
+ const { filename: e, header: n, item: o } = a, { id: i, fileType: u, nameStructure: r, version: c, tool: s } = n, { who: d, what: f, why: l } = o, m = await t.getRoot(), A = await t.getRecord({ tagName: "Header" }) ?? await t.addChild(m, {
226
226
  tagName: "Header",
227
227
  attributes: {
228
228
  id: i ?? e.replace(/\.[^.]+$/, "").toLowerCase().replace(/\s+/g, "_"),
229
229
  toolID: s,
230
- fileType: r,
231
- ...c ? { nameStructure: c } : {},
230
+ fileType: u,
231
+ ...r ? { nameStructure: r } : {},
232
232
  version: "0",
233
233
  revision: "1",
234
234
  uuid: crypto.randomUUID()
235
235
  }
236
- }), X = await t.getRecord({ tagName: "History" }) ?? await t.addChild(A, { tagName: "History", attributes: {} }), I = await $(t), v = I?.attributes.find((_) => _.name === "version")?.value, P = I?.attributes.find((_) => _.name === "revision")?.value, h = u === "keep" ? v ?? "0" : v ? String(Number(v) + 1) : "0", D = P ? String(Number(P) + 1) : "1";
236
+ }), X = await t.getRecord({ tagName: "History" }) ?? await t.addChild(A, { tagName: "History", attributes: {} }), O = await V(t), v = O?.attributes.find((_) => _.name === "version")?.value, P = O?.attributes.find((_) => _.name === "revision")?.value, C = c === "keep" ? v ?? "0" : v ? String(Number(v) + 1) : "0", E = P ? String(Number(P) + 1) : "1";
237
237
  await t.update(A, {
238
- attributes: { version: h, revision: D }
238
+ attributes: { version: C, revision: E }
239
239
  });
240
240
  const M = /* @__PURE__ */ new Date(), g = M.toString().split(" "), Y = M.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop(), W = `${g[0]} ${g[1]} ${g[2]} ${g[4]} ${Y} ${g[3]}`;
241
241
  await t.addChild(X, {
242
242
  tagName: "Hitem",
243
243
  attributes: {
244
- version: h,
245
- revision: D,
244
+ version: C,
245
+ revision: E,
246
246
  when: W,
247
247
  who: d,
248
248
  what: f,
249
249
  why: l
250
250
  }
251
251
  }), await t.update(A, {
252
- attributes: { version: h, revision: D }
252
+ attributes: { version: C, revision: E }
253
253
  });
254
254
  }
255
- const yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
255
+ const bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
256
256
  __proto__: null,
257
- addEntry: gt
257
+ addEntry: yt
258
258
  }, Symbol.toStringTag, { value: "Module" })), L = {
259
- query: pt,
260
- transaction: yt
259
+ query: gt,
260
+ transaction: bt
261
+ }, wt = {
262
+ LNode: ["prefix", "lnClass", "lnInst"],
263
+ LN: ["prefix", "lnClass", "inst"],
264
+ LN0: ["prefix", "lnClass", "inst"],
265
+ LDevice: ["inst"],
266
+ ConnectedAP: ["iedName", "apName"],
267
+ GSE: ["ldInst", "cbName"],
268
+ SMV: ["ldInst", "cbName"],
269
+ Private: ["type"],
270
+ EnumVal: ["ord"],
271
+ Association: ["associationID"],
272
+ ConnectivityNode: ["pathName"],
273
+ ControlRef: ["output", "outputInst"],
274
+ SourceRef: ["input", "inputInst"],
275
+ FunctionRoleContent: ["roleInst"],
276
+ Resource: ["resInst"],
277
+ Hitem: ["version", "revision"],
278
+ History: ["version", "revision"]
279
+ }, Nt = {
280
+ ConnectedAP: " / ",
281
+ GSE: "/",
282
+ SMV: "/",
283
+ Hitem: ".",
284
+ History: ".",
285
+ ControlRef: "/",
286
+ SourceRef: "/"
287
+ };
288
+ async function Tt(t, a) {
289
+ const e = await t.getRecord(a);
290
+ if (!e) return "";
291
+ const n = e.tagName, o = await t.getAnyAttributes(e), i = wt[n];
292
+ if (i) {
293
+ const s = Nt[n] ?? "", d = i.map((f) => o[f]).filter(Boolean);
294
+ return d.length > 0 ? d.join(s) : n;
295
+ }
296
+ const r = J[n]?.attributes?.identityFields, c = r?.find((s) => s === "name" || s === "id") ?? r?.[0];
297
+ return c ? o[c] || n : o.name || n;
298
+ }
299
+ const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
300
+ __proto__: null,
301
+ extractElementTitle: Tt
302
+ }, Symbol.toStringTag, { value: "Module" })), St = {
303
+ query: Rt
261
304
  };
262
- async function O(t) {
305
+ async function I(t) {
263
306
  const a = await t.getRoot(), e = await t.ensureChild(a, {
264
307
  tagName: "Substation",
265
308
  attributes: { name: "TEMPLATE" }
@@ -276,29 +319,29 @@ async function O(t) {
276
319
  Bay: o
277
320
  };
278
321
  }
279
- const wt = {
322
+ const At = {
280
323
  scope: "tree",
281
324
  attributes: ["templateUuid", "originUuid"]
282
325
  };
283
326
  async function S(t, a) {
284
- const { sourceQuery: e, ref: n, targetParent: o, omit: i, promoteRoot: r, strip: c = wt } = a, u = await e.getTree(n, { omit: i });
285
- if (!u) return;
286
- const s = r && u.tagName === r.from ? { ...u, tagName: r.to } : u;
327
+ const { sourceQuery: e, ref: n, targetParent: o, omit: i, promoteRoot: u, strip: r = At } = a, c = await e.getTree(n, { omit: i });
328
+ if (!c) return;
329
+ const s = u && c.tagName === u.from ? { ...c, tagName: u.to } : c;
287
330
  let d = s;
288
- c && (d = c.scope === "tree" ? x(s, c.attributes) : {
331
+ r && (d = r.scope === "tree" ? tt(s, r.attributes) : {
289
332
  ...s,
290
- attributes: s.attributes.filter((f) => !c.attributes.includes(f.name))
333
+ attributes: s.attributes.filter((f) => !r.attributes.includes(f.name))
291
334
  }), await t.deepClone(o, d);
292
335
  }
293
- async function bt(t, a) {
336
+ async function vt(t, a) {
294
337
  const { sourceQuery: e, scopeRef: n } = a, { LNode: o = [] } = await e.findDescendants(n, {
295
338
  collect: "LNode"
296
339
  });
297
340
  o.length > 0 && await j.transaction.extract(t, { sourceQuery: e, records: o });
298
341
  }
299
342
  async function F(t, a, e) {
300
- const o = (await t.findAncestors(a, { stopAtTagName: "Substation" })).find((r) => r.tagName in e);
301
- B(o, {
343
+ const o = (await t.findAncestors(a, { stopAtTagName: "Substation" })).find((u) => u.tagName in e);
344
+ U(o, {
302
345
  key: "ELEMENT_NOT_FOUND",
303
346
  detail: `No Substation/VoltageLevel/Bay ancestor found for ${a.tagName}`
304
347
  });
@@ -306,21 +349,21 @@ async function F(t, a, e) {
306
349
  return { tagName: i.tagName, id: i.id };
307
350
  }
308
351
  async function Q(t, a) {
309
- const { sourceQuery: e, functionRef: n, targetParentRef: o, omit: i, stripRootAttributes: r } = a, c = r?.length ? { scope: "root", attributes: [...r] } : !1;
352
+ const { sourceQuery: e, functionRef: n, targetParentRef: o, omit: i, stripRootAttributes: u } = a, r = u?.length ? { scope: "root", attributes: [...u] } : !1;
310
353
  await S(t, {
311
354
  sourceQuery: e,
312
355
  ref: n,
313
356
  targetParent: o,
314
357
  omit: i,
315
358
  promoteRoot: { from: "SubFunction", to: "Function" },
316
- strip: c
317
- }), await bt(t, { sourceQuery: e, scopeRef: n });
318
- }
319
- async function z(t, a) {
320
- const { sourceQuery: e, functionRef: n, structure: o, stripCategoriesUuid: i = !0 } = a, r = await Nt(e, n);
321
- for (const c of r) {
322
- if (await Rt(t, e, c)) continue;
323
- const s = { tagName: "FunctionCategory", id: c }, d = await F(e, s, o);
359
+ strip: r
360
+ }), await vt(t, { sourceQuery: e, scopeRef: n });
361
+ }
362
+ async function $(t, a) {
363
+ const { sourceQuery: e, functionRef: n, structure: o, stripCategoriesUuid: i = !0 } = a, u = await Ct(e, n);
364
+ for (const r of u) {
365
+ if (await _t(t, e, r)) continue;
366
+ const s = { tagName: "FunctionCategory", id: r }, d = await F(e, s, o);
324
367
  await S(t, {
325
368
  sourceQuery: e,
326
369
  ref: s,
@@ -329,21 +372,21 @@ async function z(t, a) {
329
372
  });
330
373
  }
331
374
  }
332
- async function Nt(t, a) {
333
- const e = await Tt(t, a), n = /* @__PURE__ */ new Set();
375
+ async function Ct(t, a) {
376
+ const e = await Et(t, a), n = /* @__PURE__ */ new Set();
334
377
  for (const { container: o } of e)
335
378
  o && n.add(o.id);
336
379
  return n;
337
380
  }
338
- async function Tt(t, a) {
339
- const e = await C.query.findRefsPointingTo(t, {
381
+ async function Et(t, a) {
382
+ const e = await h.query.findRefsPointingTo(t, {
340
383
  target: a,
341
384
  containerTagName: "FunctionCategory"
342
385
  }), { SubFunction: n = [] } = await t.findDescendants(a, {
343
386
  collect: "SubFunction"
344
387
  });
345
388
  for (const o of n) {
346
- const i = await C.query.findRefsPointingTo(t, {
389
+ const i = await h.query.findRefsPointingTo(t, {
347
390
  target: { tagName: "SubFunction", id: o.id },
348
391
  containerTagName: "FunctionCategory"
349
392
  });
@@ -351,7 +394,7 @@ async function Tt(t, a) {
351
394
  }
352
395
  return e;
353
396
  }
354
- async function Rt(t, a, e) {
397
+ async function _t(t, a, e) {
355
398
  const n = await a.getRecord({
356
399
  tagName: "FunctionCategory",
357
400
  id: e
@@ -365,13 +408,13 @@ async function Rt(t, a, e) {
365
408
  });
366
409
  return !!i;
367
410
  }
368
- async function V(t, a) {
369
- const { sourceQuery: e, scopeRef: n, refTagName: o, targetTagName: i } = a, r = w[o][0].attribute.uuid, c = await e.findDescendants(n, {
411
+ async function z(t, a) {
412
+ const { sourceQuery: e, scopeRef: n, refTagName: o, targetTagName: i } = a, u = b[o][0].attribute.uuid, r = await e.findDescendants(n, {
370
413
  collect: o
371
- }), { [o]: u = [] } = c, s = /* @__PURE__ */ new Set();
372
- for (const f of u) {
414
+ }), { [o]: c = [] } = r, s = /* @__PURE__ */ new Set();
415
+ for (const f of c) {
373
416
  const l = f.attributes.find(
374
- (m) => m.name === r
417
+ (m) => m.name === u
375
418
  )?.value;
376
419
  l && s.add(l);
377
420
  }
@@ -387,22 +430,22 @@ async function V(t, a) {
387
430
  }
388
431
  return d;
389
432
  }
390
- async function St(t, a) {
391
- const { sourceQuery: e, scopeRef: n, refTagName: o, targetTagName: i, targetParent: r, omit: c } = a, u = await V(t, {
433
+ async function ht(t, a) {
434
+ const { sourceQuery: e, scopeRef: n, refTagName: o, targetTagName: i, targetParent: u, omit: r } = a, c = await z(t, {
392
435
  sourceQuery: e,
393
436
  scopeRef: n,
394
437
  refTagName: o,
395
438
  targetTagName: i
396
439
  });
397
- for (const s of u)
398
- await S(t, { sourceQuery: e, ref: s, targetParent: r, omit: c });
399
- }
400
- async function At(t, a) {
401
- const { sourceQuery: e, scopeTagName: n, scopeRef: o, targetParent: i, skip: r = /* @__PURE__ */ new Set(), omit: c } = a, u = J[n].filter(
402
- (d) => d in w && !r.has(d)
403
- ), s = St;
404
- for (const d of u)
405
- for (const f of w[d])
440
+ for (const s of c)
441
+ await S(t, { sourceQuery: e, ref: s, targetParent: u, omit: r });
442
+ }
443
+ async function Dt(t, a) {
444
+ const { sourceQuery: e, scopeTagName: n, scopeRef: o, targetParent: i, skip: u = /* @__PURE__ */ new Set(), omit: r } = a, c = x[n].filter(
445
+ (d) => d in b && !u.has(d)
446
+ ), s = ht;
447
+ for (const d of c)
448
+ for (const f of b[d])
406
449
  for (const l of f.target)
407
450
  await s(t, {
408
451
  sourceQuery: e,
@@ -410,7 +453,7 @@ async function At(t, a) {
410
453
  refTagName: d,
411
454
  targetTagName: l,
412
455
  targetParent: i,
413
- omit: c
456
+ omit: r
414
457
  });
415
458
  }
416
459
  const T = [
@@ -418,7 +461,7 @@ const T = [
418
461
  "ApplicationSclRef",
419
462
  "GeneralEquipment",
420
463
  "ConductingEquipment"
421
- ], vt = [
464
+ ], Ft = [
422
465
  ...T,
423
466
  "DOS",
424
467
  "Labels",
@@ -429,17 +472,17 @@ const T = [
429
472
  "BehaviorDescription",
430
473
  "Variable"
431
474
  ];
432
- async function ht(t, a) {
475
+ async function Lt(t, a) {
433
476
  const { sourceQuery: e, applicationRef: n, structure: o } = a, i = {
434
477
  tagName: "Substation",
435
478
  id: o.Substation.id
436
- }, r = await V(t, {
479
+ }, u = await z(t, {
437
480
  sourceQuery: e,
438
481
  scopeRef: n,
439
482
  refTagName: "FunctionRef",
440
483
  targetTagName: "Function"
441
484
  });
442
- for (const s of r) {
485
+ for (const s of u) {
443
486
  const d = await F(e, s, o);
444
487
  await Q(t, {
445
488
  sourceQuery: e,
@@ -448,14 +491,14 @@ async function ht(t, a) {
448
491
  omit: T
449
492
  });
450
493
  }
451
- for (const s of r)
452
- await z(t, {
494
+ for (const s of u)
495
+ await $(t, {
453
496
  sourceQuery: e,
454
497
  functionRef: s,
455
498
  structure: o,
456
499
  stripCategoriesUuid: !1
457
500
  });
458
- await At(t, {
501
+ await Dt(t, {
459
502
  sourceQuery: e,
460
503
  scopeTagName: "Application",
461
504
  scopeRef: n,
@@ -463,33 +506,33 @@ async function ht(t, a) {
463
506
  skip: /* @__PURE__ */ new Set(["FunctionRef", "FunctionCategoryRef"]),
464
507
  omit: T
465
508
  });
466
- const u = await F(e, n, o);
467
- await S(t, { sourceQuery: e, ref: n, targetParent: u, omit: T });
509
+ const c = await F(e, n, o);
510
+ await S(t, { sourceQuery: e, ref: n, targetParent: c, omit: T });
468
511
  }
469
512
  async function G(t) {
470
513
  await N.transaction.orphanUuidRefs(t), await N.transaction.resetLNode(t), await N.transaction.pruneEmptyContainers(t);
471
514
  }
472
- async function Dt(t, a) {
473
- const { sourceQuery: e, applicationRef: n, tool: o, who: i, nameStructure: r } = a, c = await O(t), u = await t.getAttribute(n, { name: "name" }) || "Unnamed Application";
515
+ async function It(t, a) {
516
+ const { sourceQuery: e, applicationRef: n, tool: o, who: i, nameStructure: u } = a, r = await I(t), c = await t.getAttribute(n, { name: "name" }) || "Unnamed Application";
474
517
  await L.transaction.addEntry(t, {
475
- filename: `ASD_${u.replace(/\s+/g, "_")}`,
518
+ filename: `ASD_${c.replace(/\s+/g, "_")}`,
476
519
  header: {
477
520
  fileType: "ASD",
478
521
  version: "keep",
479
522
  tool: o,
480
- ...r ? { nameStructure: r } : {}
523
+ ...u ? { nameStructure: u } : {}
481
524
  },
482
525
  item: {
483
526
  who: i,
484
527
  what: "ASD initialization",
485
528
  why: "Application was extracted from a previous file"
486
529
  }
487
- }), await ht(t, { sourceQuery: e, applicationRef: n, structure: c }), await G(t);
530
+ }), await Lt(t, { sourceQuery: e, applicationRef: n, structure: r }), await G(t);
488
531
  }
489
- async function _t(t, a) {
490
- const { sourceQuery: e, functionRef: n, tool: o, who: i, nameStructure: r } = a, c = await O(t), u = {
491
- tagName: c.Substation.tagName,
492
- id: c.Substation.id
532
+ async function Ot(t, a) {
533
+ const { sourceQuery: e, functionRef: n, tool: o, who: i, nameStructure: u } = a, r = await I(t), c = {
534
+ tagName: r.Substation.tagName,
535
+ id: r.Substation.id
493
536
  }, s = await e.getAttribute(n, { name: "name" }) || "Unnamed Function";
494
537
  await L.transaction.addEntry(t, {
495
538
  filename: `FSD_${s.replace(/\s+/g, "_")}`,
@@ -497,7 +540,7 @@ async function _t(t, a) {
497
540
  fileType: "FSD",
498
541
  version: "keep",
499
542
  tool: o,
500
- ...r ? { nameStructure: r } : {}
543
+ ...u ? { nameStructure: u } : {}
501
544
  },
502
545
  item: {
503
546
  who: i,
@@ -507,42 +550,49 @@ async function _t(t, a) {
507
550
  }), await Q(t, {
508
551
  sourceQuery: e,
509
552
  functionRef: n,
510
- targetParentRef: u,
511
- omit: vt,
553
+ targetParentRef: c,
554
+ omit: Ft,
512
555
  stripRootAttributes: ["templateUuid"]
513
- }), await z(t, {
556
+ }), await $(t, {
514
557
  sourceQuery: e,
515
558
  functionRef: n,
516
- structure: c
559
+ structure: r
517
560
  }), await G(t);
518
561
  }
519
- const Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
562
+ const Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
520
563
  __proto__: null,
521
- ensureSubstationTemplateStructure: O,
522
- extractToAsd: Dt,
523
- extractToFsd: _t
524
- }, Symbol.toStringTag, { value: "Module" })), Et = {
525
- transaction: Ct
526
- }, K = { cleanUp: N, dataModel: j, history: L, reference: C, template: Et };
527
- function Mt(t) {
564
+ ensureSubstationTemplateStructure: I,
565
+ extractToAsd: It,
566
+ extractToFsd: Ot
567
+ }, Symbol.toStringTag, { value: "Module" })), Mt = {
568
+ transaction: Pt
569
+ }, K = {
570
+ cleanUp: N,
571
+ dataModel: j,
572
+ history: L,
573
+ reference: h,
574
+ template: Mt,
575
+ presentation: St
576
+ };
577
+ function Vt(t) {
528
578
  const { storage: a, extensions: e } = t;
529
- return et({
579
+ return nt({
530
580
  config: R,
531
581
  storage: a,
532
582
  extensions: { base: K, custom: e },
533
- hooks: U
583
+ hooks: B
534
584
  });
535
585
  }
536
- async function Ut(t) {
586
+ async function Qt(t) {
537
587
  const { storage: a, extensions: e } = t;
538
- return tt({
588
+ return et({
539
589
  config: R,
540
590
  storage: a,
541
591
  extensions: { base: K, custom: e },
542
- hooks: U
592
+ hooks: B
543
593
  });
544
594
  }
545
- function Bt(t) {
595
+ function $t(t) {
546
596
  const { files: a, useCustomRecordsIds: e = !1 } = t;
547
597
  return at({
548
598
  files: a,
@@ -550,9 +600,9 @@ function Bt(t) {
550
600
  useCustomRecordsIds: e
551
601
  });
552
602
  }
553
- function Ht(t) {
603
+ function zt(t) {
554
604
  const { databaseName: a, extension: e, withDownload: n, withDatabaseIds: o } = t;
555
- return nt({
605
+ return ot({
556
606
  dialecteConfig: R,
557
607
  databaseName: a,
558
608
  extension: e,
@@ -561,12 +611,12 @@ function Ht(t) {
561
611
  });
562
612
  }
563
613
  export {
564
- $t as SCL_DATABASE_CONFIG,
614
+ Xt as SCL_DATABASE_CONFIG,
565
615
  R as SCL_DIALECTE_CONFIG,
566
- Qt as SCL_IO_CONFIG,
567
- zt as SCL_NAMESPACES,
568
- Ut as createSclDocument,
569
- Ht as exportSclFile,
570
- Bt as importSclFiles,
571
- Mt as openSclDocument
616
+ Yt as SCL_IO_CONFIG,
617
+ Wt as SCL_NAMESPACES,
618
+ Qt as createSclDocument,
619
+ zt as exportSclFile,
620
+ $t as importSclFiles,
621
+ Vt as openSclDocument
572
622
  };
@@ -1,6 +1,6 @@
1
1
  import { CUSTOM_RECORD_ID_ATTRIBUTE as R, CUSTOM_RECORD_ID_ATTRIBUTE_NAME as D } from "@dialecte/core/helpers";
2
2
  import { createTestRunner as r, createTestRecordFactory as n, createXmlAssertions as a, XMLNS_DEV_NAMESPACE as o, createTestDialecte as S } from "@dialecte/core/test";
3
- import { S as e, H as t } from "../index-lHFSidP5.js";
3
+ import { S as e, H as t } from "../index-QAjOle0s.js";
4
4
  const E = 'xmlns="http://www.iec.ch/61850/2003/SCL"', _ = 'xmlns:eIEC61850-6-100="http://www.iec.ch/61850/2019/SCL/6-100"', i = `${E} ${_} ${o}`, A = r(e, t);
5
5
  async function m(s) {
6
6
  const { xmlString: c } = s;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialecte/scl",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Dialecte - SCL (Substation Configuration Language) sdk",
5
5
  "license": "MIT",
6
6
  "repository": {