@dialecte/core 0.2.17 → 0.2.18

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.
@@ -8,6 +8,7 @@ export declare const XSI_NAMESPACE: {
8
8
  uri: string;
9
9
  prefix: string;
10
10
  };
11
+ export declare const XMLNS_XSI_NAMESPACE: string;
11
12
  export declare const DIALECTE_NAMESPACES: {
12
13
  dev: {
13
14
  uri: string;
@@ -1 +1 @@
1
- {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/helpers/constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,UAAU,CAAA;AAEtD,eAAO,MAAM,sBAAsB;;;CAGlC,CAAA;AAED,eAAO,MAAM,0BAA0B,QAAwE,CAAA;AAE/G,eAAO,MAAM,aAAa;;;CAGzB,CAAA;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;CAG/B,CAAA"}
1
+ {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/helpers/constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,UAAU,CAAA;AAEtD,eAAO,MAAM,sBAAsB;;;CAGlC,CAAA;AAED,eAAO,MAAM,0BAA0B,QAAwE,CAAA;AAE/G,eAAO,MAAM,aAAa;;;CAGzB,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAyD,CAAA;AAEzF,eAAO,MAAM,mBAAmB;;;;;;;;;CAG/B,CAAA"}
package/dist/helpers.js CHANGED
@@ -6,10 +6,10 @@ var t = "db-id", n = {
6
6
  }, r = `${n.prefix}:${t}`, i = {
7
7
  uri: "http://www.w3.org/2001/XMLSchema-instance",
8
8
  prefix: "xsi"
9
- }, a = {
9
+ }, a = `xmlns:${i.prefix}="${i.uri}"`, o = {
10
10
  dev: n,
11
11
  xsi: i
12
- }, o = [
12
+ }, s = [
13
13
  "id",
14
14
  "tagName",
15
15
  "namespace",
@@ -17,26 +17,23 @@ var t = "db-id", n = {
17
17
  "children",
18
18
  "parent",
19
19
  "value"
20
- ], s = [...o, "status"], c = [...s, "tree"];
21
- function l(e, t) {
20
+ ], c = [...s, "status"], l = [...c, "tree"];
21
+ function u(e, t) {
22
22
  if (typeof e != "object" || !e) return !1;
23
23
  let n = Object.keys(e);
24
24
  return t.every((t) => t in e) && n.every((e) => t.includes(e)) && n.length === t.length;
25
25
  }
26
- function u(e) {
27
- return Array.isArray(e);
28
- }
29
26
  function d(e) {
30
- return l(e, o);
27
+ return Array.isArray(e);
31
28
  }
32
29
  function f(e) {
33
- return l(e, s);
30
+ return u(e, s);
34
31
  }
35
32
  function p(e) {
36
- return l(e, c);
33
+ return u(e, c);
37
34
  }
38
- function m(e, t) {
39
- return e.tagName === t;
35
+ function m(e) {
36
+ return u(e, l);
40
37
  }
41
38
  function h(e, t) {
42
39
  return e.tagName === t;
@@ -45,14 +42,17 @@ function g(e, t) {
45
42
  return e.tagName === t;
46
43
  }
47
44
  function _(e, t) {
48
- return t.elements.includes(e);
45
+ return e.tagName === t;
49
46
  }
50
47
  function v(e, t) {
48
+ return t.elements.includes(e);
49
+ }
50
+ function y(e, t) {
51
51
  return e.attributes.some((e) => e.name === t);
52
52
  }
53
53
  //#endregion
54
54
  //#region src/helpers/converter.ts
55
- function y(e) {
55
+ function b(e) {
56
56
  return {
57
57
  id: e.id,
58
58
  tagName: e.tagName,
@@ -63,32 +63,32 @@ function y(e) {
63
63
  children: e.children
64
64
  };
65
65
  }
66
- function b(e) {
66
+ function x(e) {
67
67
  let { record: t, status: n } = e, r = n ?? ("status" in t ? t.status : "unchanged");
68
68
  return {
69
- ...y(t),
69
+ ...b(t),
70
70
  status: r
71
71
  };
72
72
  }
73
- function x(e) {
73
+ function S(e) {
74
74
  let { record: t, status: n, tree: r } = e, i = r ?? ("tree" in t ? t.tree : []);
75
75
  return {
76
- ...b({
76
+ ...x({
77
77
  record: t,
78
78
  status: n
79
79
  }),
80
80
  tree: i
81
81
  };
82
82
  }
83
- function S(e) {
83
+ function C(e) {
84
84
  let { dialecteConfig: t, tagName: n, attributes: r } = e;
85
- return u(r) ? r : Object.entries(r).map(([e, r]) => ({
85
+ return d(r) ? r : Object.entries(r).map(([e, r]) => ({
86
86
  name: e,
87
87
  value: r,
88
88
  namespace: t.definition[n]?.attributes.details[e]?.namespace || void 0
89
89
  }));
90
90
  }
91
- function C(t) {
91
+ function w(t) {
92
92
  return e(t, { detail: "The record or ref is undefined" }), {
93
93
  id: t.id,
94
94
  tagName: t.tagName
@@ -96,8 +96,8 @@ function C(t) {
96
96
  }
97
97
  //#endregion
98
98
  //#region src/helpers/standardizing.ts
99
- function w(e) {
100
- let { dialecteConfig: t, hooks: n, record: r } = e, { id: i, tagName: a, attributes: o, namespace: s, value: c } = r, l = i ?? crypto.randomUUID(), u = o ? S({
99
+ function T(e) {
100
+ let { dialecteConfig: t, hooks: n, record: r } = e, { id: i, tagName: a, attributes: o, namespace: s, value: c } = r, l = i ?? crypto.randomUUID(), u = o ? C({
101
101
  tagName: a,
102
102
  attributes: o,
103
103
  dialecteConfig: t
@@ -130,7 +130,7 @@ function w(e) {
130
130
  }
131
131
  //#endregion
132
132
  //#region src/helpers/merge-extensions.ts
133
- function T(t, n, r, i) {
133
+ function E(t, n, r, i) {
134
134
  if (!t || !n) return;
135
135
  let a = Object.keys(n).filter((e) => e in t);
136
136
  e(a.length === 0, {
@@ -138,12 +138,12 @@ function T(t, n, r, i) {
138
138
  detail: `Module "${r}" has conflicting ${i} method(s): ${a.map((e) => `"${e}"`).join(", ")}`
139
139
  });
140
140
  }
141
- function E(e) {
141
+ function D(e) {
142
142
  let t = {}, n = {}, r = [...Object.entries(e.base ?? {}), ...Object.entries(e.custom ?? {})];
143
- for (let [e, i] of r) i.query && (T(t[e], i.query, e, "query"), t[e] = {
143
+ for (let [e, i] of r) i.query && (E(t[e], i.query, e, "query"), t[e] = {
144
144
  ...t[e],
145
145
  ...i.query
146
- }), i.transaction && (T(n[e], i.transaction, e, "transaction"), n[e] = {
146
+ }), i.transaction && (E(n[e], i.transaction, e, "transaction"), n[e] = {
147
147
  ...n[e],
148
148
  ...i.transaction
149
149
  });
@@ -154,15 +154,15 @@ function E(e) {
154
154
  }
155
155
  //#endregion
156
156
  //#region src/helpers/strip-attributes.ts
157
- function D(e, t) {
157
+ function O(e, t) {
158
158
  let n = new Set(t), r = {
159
159
  ...e,
160
160
  attributes: e.attributes.filter((e) => !n.has(e.name))
161
161
  };
162
162
  return "tree" in e ? {
163
163
  ...r,
164
- tree: e.tree.map((e) => D(e, t))
164
+ tree: e.tree.map((e) => O(e, t))
165
165
  } : r;
166
166
  }
167
167
  //#endregion
168
- export { r as CUSTOM_RECORD_ID_ATTRIBUTE, t as CUSTOM_RECORD_ID_ATTRIBUTE_NAME, n as DIALECTE_DEV_NAMESPACE, a as DIALECTE_NAMESPACES, i as XSI_NAMESPACE, v as isAttributeOf, h as isChildOf, _ as isElementOf, u as isFullAttributeArray, g as isParentOf, d as isRawRecord, m as isRecordOf, f as isTrackedRecord, p as isTreeRecord, E as mergeExtensions, w as standardizeRecord, D as stripAttributes, S as toFullAttributeArray, y as toRawRecord, C as toRef, b as toTrackedRecord, x as toTreeRecord };
168
+ export { r as CUSTOM_RECORD_ID_ATTRIBUTE, t as CUSTOM_RECORD_ID_ATTRIBUTE_NAME, n as DIALECTE_DEV_NAMESPACE, o as DIALECTE_NAMESPACES, a as XMLNS_XSI_NAMESPACE, i as XSI_NAMESPACE, y as isAttributeOf, g as isChildOf, v as isElementOf, d as isFullAttributeArray, _ as isParentOf, f as isRawRecord, h as isRecordOf, p as isTrackedRecord, m as isTreeRecord, D as mergeExtensions, T as standardizeRecord, O as stripAttributes, C as toFullAttributeArray, b as toRawRecord, w as toRef, x as toTrackedRecord, S as toTreeRecord };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialecte/core",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "Dialecte - Core functionality for Dialecte SDK",
5
5
  "license": "MIT",
6
6
  "repository": {