@dialecte/core 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,144 @@
1
+ import { i as h } from "./index-DWV6tSGF.js";
2
+ const C = "db-id", O = {
3
+ uri: "http://dialecte.dev/XML/DEV",
4
+ prefix: "dev"
5
+ }, j = `${O.prefix}:${C}`, R = [
6
+ "id",
7
+ "tagName",
8
+ "namespace",
9
+ "attributes",
10
+ "children",
11
+ "parent",
12
+ "value"
13
+ ], E = [...R, "status"], S = [...E, "tree"];
14
+ function d(e, t) {
15
+ if (typeof e != "object" || e === null)
16
+ return !1;
17
+ const a = Object.keys(e);
18
+ return t.every((n) => n in e) && a.every((n) => t.includes(n)) && a.length === t.length;
19
+ }
20
+ function y(e) {
21
+ return Array.isArray(e);
22
+ }
23
+ function F(e) {
24
+ return d(e, R);
25
+ }
26
+ function K(e) {
27
+ return d(e, E);
28
+ }
29
+ function V(e) {
30
+ return d(e, S);
31
+ }
32
+ function Y(e, t) {
33
+ return e.tagName === t;
34
+ }
35
+ function w(e, t) {
36
+ return e.tagName === t;
37
+ }
38
+ function B(e, t) {
39
+ return e.tagName === t;
40
+ }
41
+ function L(e, t) {
42
+ return t.elements.includes(e);
43
+ }
44
+ function P(e, t) {
45
+ return e.attributes.some((a) => a.name === t);
46
+ }
47
+ function I(e) {
48
+ return {
49
+ id: e.id,
50
+ tagName: e.tagName,
51
+ namespace: e.namespace,
52
+ attributes: e.attributes,
53
+ value: e.value,
54
+ parent: e.parent,
55
+ children: e.children
56
+ };
57
+ }
58
+ function x(e) {
59
+ const { record: t, status: a } = e, n = a ?? ("status" in t ? t.status : "unchanged");
60
+ return {
61
+ ...I(t),
62
+ status: n
63
+ };
64
+ }
65
+ function $(e) {
66
+ const { record: t, status: a, tree: n } = e, i = n ?? ("tree" in t ? t.tree : []);
67
+ return {
68
+ ...x({ record: t, status: a }),
69
+ tree: i
70
+ };
71
+ }
72
+ function M(e) {
73
+ const { dialecteConfig: t, tagName: a, attributes: n } = e;
74
+ return y(n) ? n : Object.entries(n).map(
75
+ ([i, s]) => ({
76
+ name: i,
77
+ value: s,
78
+ namespace: t.definition[a]?.attributes.details[i]?.namespace || void 0
79
+ })
80
+ );
81
+ }
82
+ function q(e) {
83
+ return h(e, {
84
+ detail: "The record or ref is undefined"
85
+ }), {
86
+ id: e.id,
87
+ tagName: e.tagName
88
+ };
89
+ }
90
+ function Q(e) {
91
+ const { dialecteConfig: t, hooks: a, record: n } = e, { id: i, tagName: s, attributes: l, namespace: b, value: A } = n, T = i ?? crypto.randomUUID(), o = l ? M({ tagName: s, attributes: l, dialecteConfig: t }) : [], f = {
92
+ id: T,
93
+ tagName: s,
94
+ attributes: o,
95
+ namespace: b ?? {
96
+ prefix: "prefixNeededForNotSupportedNamespace",
97
+ uri: "uriNeededForNotSupportedNamespace"
98
+ },
99
+ value: A ?? "",
100
+ parent: n.parent ?? null,
101
+ children: n.children ?? []
102
+ };
103
+ if (!t.elements.includes(s)) return f;
104
+ const m = t.definition[s].attributes.sequence, c = t.definition[s].attributes.details, g = m.flatMap((r) => {
105
+ const D = c[r].required, N = c[r]?.namespace || void 0, p = o.find((_) => _.name === r)?.value ?? (D ? c[r]?.default ?? "" : c[r]?.default);
106
+ return p === void 0 ? [] : [
107
+ {
108
+ name: r,
109
+ value: p,
110
+ namespace: N
111
+ }
112
+ ];
113
+ }), v = o.filter(
114
+ (r) => "namespace" in r && r.namespace != null && !m.includes(r.name)
115
+ );
116
+ let u = {
117
+ ...f,
118
+ namespace: t.definition[s].namespace,
119
+ attributes: [...g, ...v]
120
+ };
121
+ return a?.afterStandardizedRecord && (u = a.afterStandardizedRecord({
122
+ record: u
123
+ })), u;
124
+ }
125
+ export {
126
+ j as C,
127
+ O as D,
128
+ C as a,
129
+ w as b,
130
+ L as c,
131
+ y as d,
132
+ B as e,
133
+ F as f,
134
+ Y as g,
135
+ K as h,
136
+ P as i,
137
+ V as j,
138
+ I as k,
139
+ q as l,
140
+ x as m,
141
+ $ as n,
142
+ Q as s,
143
+ M as t
144
+ };
@@ -3,14 +3,14 @@ import { Project } from '../project';
3
3
  import { Document, Context } from '../document';
4
4
  import { AnyDialecteConfig, TransactionHooks } from '../types';
5
5
  type TestDialecteConfig = typeof TEST_DIALECTE_CONFIG;
6
- export type TestFile<GenericConfig extends AnyDialecteConfig> = {
6
+ export type TestDocument<GenericConfig extends AnyDialecteConfig> = {
7
7
  documentId: string;
8
8
  document: Document<GenericConfig>;
9
9
  };
10
10
  export type TestProjectResult<GenericConfig extends AnyDialecteConfig> = {
11
11
  project: Project<GenericConfig>;
12
- source: TestFile<GenericConfig>;
13
- target?: TestFile<GenericConfig>;
12
+ source: TestDocument<GenericConfig>;
13
+ target?: TestDocument<GenericConfig>;
14
14
  };
15
15
  /**
16
16
  * Spin up a Project with source (and optionally target) file imported.
@@ -1 +1 @@
1
- {"version":3,"file":"create-test-dialecte.d.ts","sourceRoot":"","sources":["../../src/test/create-test-dialecte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAElE,KAAK,kBAAkB,GAAG,OAAO,oBAAoB,CAAA;AAErD,MAAM,MAAM,QAAQ,CAAC,aAAa,SAAS,iBAAiB,IAAI;IAC/D,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,iBAAiB,CAAC,aAAa,SAAS,iBAAiB,IAAI;IACxE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAyC,CAAA;AAElE,wBAAgB,gBAAgB,CAAC,aAAa,SAAS,iBAAiB,EACvE,cAAc,EAAE,aAAa,EAC7B,KAAK,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACrC,UAAU,CAAC,aAAa,CAAC,CAM3B"}
package/dist/test.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { expect as m, it as p } from "vitest";
2
- import { x as D, b as L, d as T } from "./project-ChrJXVyu.js";
3
- import { D as w, s as g, o as O, n as M } from "./merge-extensions-DQKNUthU.js";
4
- function h(B) {
2
+ import { x as w, b as D, d as L } from "./project-q_8UeLBc.js";
3
+ import { D as T, s as g, n as O, m as M } from "./standardizing-FTZoR5RH.js";
4
+ function v(B) {
5
5
  const e = k(B);
6
6
  if (e.length === 0)
7
7
  return [B];
@@ -76,7 +76,7 @@ function y(B) {
76
76
  U({ xmlDocument: e, xpath: a, nsResolver: r });
77
77
  }
78
78
  function I(B) {
79
- const { xmlDocument: e, xpath: t, nsResolver: r } = B, a = h(t);
79
+ const { xmlDocument: e, xpath: t, nsResolver: r } = B, a = v(t);
80
80
  let C = null, A = 0;
81
81
  for (let s = 0; s < a.length; s++) {
82
82
  const _ = a[s], c = e.evaluate(
@@ -107,13 +107,13 @@ ${C ? x({ xml: C.outerHTML }) : "(none)"}`;
107
107
  function x(B) {
108
108
  const { xml: e } = B;
109
109
  try {
110
- return D(e, { indentation: " ", collapseContent: !0 });
110
+ return w(e, { indentation: " ", collapseContent: !0 });
111
111
  } catch {
112
112
  return e;
113
113
  }
114
114
  }
115
115
  function U(B) {
116
- const { xmlDocument: e, xpath: t, nsResolver: r } = B, a = h(t);
116
+ const { xmlDocument: e, xpath: t, nsResolver: r } = B, a = v(t);
117
117
  if (a.length > 1) {
118
118
  let s = null;
119
119
  for (let _ = 0; _ < a.length - 1; _++) {
@@ -155,7 +155,7 @@ const d = {
155
155
  uri: "http://dialecte.dev/XML/DEFAULT",
156
156
  prefix: ""
157
157
  },
158
- dev: w,
158
+ dev: T,
159
159
  ext: {
160
160
  uri: "http://dialecte.dev/XML/DEV-EXT",
161
161
  prefix: "ext"
@@ -1563,19 +1563,18 @@ const d = {
1563
1563
  io: K,
1564
1564
  definition: Y
1565
1565
  };
1566
- async function v(B) {
1566
+ async function E(B) {
1567
1567
  const {
1568
1568
  sourceXml: e,
1569
1569
  targetXml: t,
1570
1570
  dialecteConfig: r = l,
1571
1571
  hooks: a
1572
- } = B, C = `test-${crypto.randomUUID()}`, A = await T.open({
1573
- name: C,
1572
+ } = B, C = `test-${crypto.randomUUID()}`, A = await new L({
1574
1573
  configs: { default: r },
1575
1574
  defaultConfigKey: "default",
1576
1575
  storage: { type: "local" },
1577
1576
  hooks: a
1578
- }), s = await A.import(
1577
+ }).open(C), s = await A.import(
1579
1578
  new File([e], "source.xml", { type: "text/xml" }),
1580
1579
  { useCustomRecordsIds: !0 }
1581
1580
  ), _ = {
@@ -1596,7 +1595,7 @@ async function v(B) {
1596
1595
  return { project: A, source: _, target: i };
1597
1596
  }
1598
1597
  async function ce(B) {
1599
- const { databaseName: e, dialecteConfig: t, documentId: r } = B, a = new L(e, {
1598
+ const { databaseName: e, dialecteConfig: t, documentId: r } = B, a = new D(e, {
1600
1599
  recordSchema: t.database.recordSchema
1601
1600
  });
1602
1601
  return await a.open(), {
@@ -1607,8 +1606,8 @@ async function ce(B) {
1607
1606
  stagedOperations: []
1608
1607
  };
1609
1608
  }
1610
- const E = crypto.randomUUID.bind(crypto);
1611
- function b() {
1609
+ const b = crypto.randomUUID.bind(crypto);
1610
+ function X() {
1612
1611
  let B = 0;
1613
1612
  return function() {
1614
1613
  return `${B++}`;
@@ -1625,17 +1624,19 @@ function Z(B) {
1625
1624
  });
1626
1625
  for (const [s, _] of Object.entries(e))
1627
1626
  (_.only ? p.only : p)(s, async () => {
1628
- crypto.randomUUID = E;
1629
- const { project: c, source: n, target: u } = await v({
1627
+ crypto.randomUUID = b;
1628
+ const { project: c, source: n, target: u } = await E({
1630
1629
  sourceXml: _.sourceXml,
1631
1630
  targetXml: _.targetXml,
1632
1631
  dialecteConfig: a,
1633
1632
  hooks: r
1634
1633
  });
1635
1634
  try {
1636
- crypto.randomUUID = b();
1637
- const o = await t({ testCase: _, source: n.document, target: u?.document }), X = o?.assertOn ?? "source", q = o?.withDatabaseIds ?? !0, S = X === "target" ? u.documentId : n.documentId, { xmlDocument: f } = await c.export(S, { withDatabaseIds: q });
1638
- _.expectedQueries?.length && C({ xmlDocument: f, queries: _.expectedQueries }), _.unexpectedQueries?.length && A({ xmlDocument: f, queries: _.unexpectedQueries });
1635
+ crypto.randomUUID = X();
1636
+ const o = await t({ testCase: _, source: n.document, target: u?.document }), q = o?.assertOn ?? "source", S = o?.withDatabaseIds ?? !0, f = q === "target" ? u?.documentId : n.documentId;
1637
+ if (!f) throw new Error("documentId required for export");
1638
+ const { xmlDocument: h } = await c.export(f, { withDatabaseIds: S });
1639
+ _.expectedQueries?.length && C({ xmlDocument: h, queries: _.expectedQueries }), _.unexpectedQueries?.length && A({ xmlDocument: h, queries: _.unexpectedQueries });
1639
1640
  } finally {
1640
1641
  await c.destroy();
1641
1642
  }
@@ -1650,15 +1651,15 @@ function J(B) {
1650
1651
  } = B;
1651
1652
  for (const [C, A] of Object.entries(e))
1652
1653
  (A.only ? p.only : p)(C, async () => {
1653
- crypto.randomUUID = E;
1654
- const { project: _, source: i, target: c } = await v({
1654
+ crypto.randomUUID = b;
1655
+ const { project: _, source: i, target: c } = await E({
1655
1656
  sourceXml: A.sourceXml,
1656
1657
  targetXml: A.targetXml,
1657
1658
  dialecteConfig: a,
1658
1659
  hooks: r
1659
1660
  });
1660
1661
  try {
1661
- crypto.randomUUID = b(), await t({ testCase: A, source: i.document, target: c?.document });
1662
+ crypto.randomUUID = X(), await t({ testCase: A, source: i.document, target: c?.document });
1662
1663
  } finally {
1663
1664
  await _.destroy();
1664
1665
  }
@@ -1703,13 +1704,13 @@ export {
1703
1704
  se as XMLNS_EXT_NAMESPACE,
1704
1705
  V as assertExpectedElementQueries,
1705
1706
  y as assertUnexpectedElementQueries,
1706
- b as createMockRandomUUID,
1707
+ X as createMockRandomUUID,
1707
1708
  ce as createTestContext,
1708
- v as createTestProject,
1709
+ E as createTestProject,
1709
1710
  ne as createTestRecord,
1710
1711
  Be as createTestRecordFactory,
1711
1712
  te as createTestRunner,
1712
1713
  R as createXmlAssertions,
1713
1714
  ie as runTestCases,
1714
- h as splitXpathIntoSteps
1715
+ v as splitXpathIntoSteps
1715
1716
  };
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as r } from "./index-C2WRi-6U.js";
1
+ import { i as r } from "./index-DWV6tSGF.js";
2
2
  export {
3
3
  r as invariant
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialecte/core",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Dialecte - Core functionality for Dialecte SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,172 +0,0 @@
1
- import { i as E } from "./index-C2WRi-6U.js";
2
- const D = "db-id", v = {
3
- uri: "http://dialecte.dev/XML/DEV",
4
- prefix: "dev"
5
- }, $ = `${v.prefix}:${D}`, b = [
6
- "id",
7
- "tagName",
8
- "namespace",
9
- "attributes",
10
- "children",
11
- "parent",
12
- "value"
13
- ], A = [...b, "status"], S = [...A, "tree"];
14
- function d(e, t) {
15
- if (typeof e != "object" || e === null)
16
- return !1;
17
- const n = Object.keys(e);
18
- return t.every((a) => a in e) && n.every((a) => t.includes(a)) && n.length === t.length;
19
- }
20
- function I(e) {
21
- return Array.isArray(e);
22
- }
23
- function z(e) {
24
- return d(e, b);
25
- }
26
- function F(e) {
27
- return d(e, A);
28
- }
29
- function K(e) {
30
- return d(e, S);
31
- }
32
- function L(e, t) {
33
- return e.tagName === t;
34
- }
35
- function V(e, t) {
36
- return e.tagName === t;
37
- }
38
- function Y(e, t) {
39
- return e.tagName === t;
40
- }
41
- function w(e, t) {
42
- return t.elements.includes(e);
43
- }
44
- function B(e, t) {
45
- return e.attributes.some((n) => n.name === t);
46
- }
47
- function M(e) {
48
- return {
49
- id: e.id,
50
- tagName: e.tagName,
51
- namespace: e.namespace,
52
- attributes: e.attributes,
53
- value: e.value,
54
- parent: e.parent,
55
- children: e.children
56
- };
57
- }
58
- function j(e) {
59
- const { record: t, status: n } = e, a = n ?? ("status" in t ? t.status : "unchanged");
60
- return {
61
- ...M(t),
62
- status: a
63
- };
64
- }
65
- function P(e) {
66
- const { record: t, status: n, tree: a } = e, r = a ?? ("tree" in t ? t.tree : []);
67
- return {
68
- ...j({ record: t, status: n }),
69
- tree: r
70
- };
71
- }
72
- function k(e) {
73
- const { dialecteConfig: t, tagName: n, attributes: a } = e;
74
- return I(a) ? a : Object.entries(a).map(
75
- ([r, s]) => ({
76
- name: r,
77
- value: s,
78
- namespace: t.definition[n]?.attributes.details[r]?.namespace || void 0
79
- })
80
- );
81
- }
82
- function X(e) {
83
- return E(e, {
84
- detail: "The record or ref is undefined"
85
- }), {
86
- id: e.id,
87
- tagName: e.tagName
88
- };
89
- }
90
- function G(e) {
91
- const { dialecteConfig: t, hooks: n, record: a } = e, { id: r, tagName: s, attributes: l, namespace: O, value: g } = a, N = r ?? crypto.randomUUID(), c = l ? k({ tagName: s, attributes: l, dialecteConfig: t }) : [], f = {
92
- id: N,
93
- tagName: s,
94
- attributes: c,
95
- namespace: O ?? {
96
- prefix: "prefixNeededForNotSupportedNamespace",
97
- uri: "uriNeededForNotSupportedNamespace"
98
- },
99
- value: g ?? "",
100
- parent: a.parent ?? null,
101
- children: a.children ?? []
102
- };
103
- if (!t.elements.includes(s)) return f;
104
- const m = t.definition[s].attributes.sequence, o = t.definition[s].attributes.details, T = m.flatMap((i) => {
105
- const h = o[i].required, _ = o[i]?.namespace || void 0, p = c.find((C) => C.name === i)?.value ?? (h ? o[i]?.default ?? "" : o[i]?.default);
106
- return p === void 0 ? [] : [
107
- {
108
- name: i,
109
- value: p,
110
- namespace: _
111
- }
112
- ];
113
- }), y = c.filter(
114
- (i) => "namespace" in i && i.namespace != null && !m.includes(i.name)
115
- );
116
- let u = {
117
- ...f,
118
- namespace: t.definition[s].namespace,
119
- attributes: [...T, ...y]
120
- };
121
- return n?.afterStandardizedRecord && (u = n.afterStandardizedRecord({
122
- record: u
123
- })), u;
124
- }
125
- function R(e, t, n, a) {
126
- if (!e || !t) return;
127
- const r = Object.keys(t).filter((s) => s in e);
128
- E(r.length === 0, {
129
- key: "EXTENSION_METHOD_COLLISION",
130
- detail: `Module "${n}" has conflicting ${a} method(s): ${r.map((s) => `"${s}"`).join(", ")}`
131
- });
132
- }
133
- function H(e) {
134
- const t = {}, n = {}, a = [
135
- ...Object.entries(e.base ?? {}),
136
- ...Object.entries(e.custom ?? {})
137
- ];
138
- for (const [r, s] of a)
139
- s.query && (R(
140
- t[r],
141
- s.query,
142
- r,
143
- "query"
144
- ), t[r] = { ...t[r], ...s.query }), s.transaction && (R(
145
- n[r],
146
- s.transaction,
147
- r,
148
- "transaction"
149
- ), n[r] = { ...n[r], ...s.transaction });
150
- return { query: t, transaction: n };
151
- }
152
- export {
153
- $ as C,
154
- v as D,
155
- D as a,
156
- V as b,
157
- w as c,
158
- I as d,
159
- Y as e,
160
- z as f,
161
- L as g,
162
- F as h,
163
- B as i,
164
- K as j,
165
- M as k,
166
- X as l,
167
- H as m,
168
- j as n,
169
- P as o,
170
- G as s,
171
- k as t
172
- };