@dialecte/core 0.2.14 → 0.2.15

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,177 @@
1
+ //#region src/errors/codes.ts
2
+ var e = {
3
+ UNKNOWN: {
4
+ code: "D0001",
5
+ message: "An unknown error occurred"
6
+ },
7
+ ASSERTION_FAILED: {
8
+ code: "D0002",
9
+ message: "Assertion failed"
10
+ },
11
+ STORE_CONNECTION_FAILED: {
12
+ code: "D1001",
13
+ message: "Failed to open database"
14
+ },
15
+ STORE_COMMIT_FAILED: {
16
+ code: "D1002",
17
+ message: "Failed to commit changes"
18
+ },
19
+ STORE_RECORD_NOT_FOUND: {
20
+ code: "D1003",
21
+ message: "Record not found in database"
22
+ },
23
+ STORE_BULK_ADD_FAILED: {
24
+ code: "D1004",
25
+ message: "Failed to add records to database"
26
+ },
27
+ STORE_BULK_UPDATE_FAILED: {
28
+ code: "D1005",
29
+ message: "Failed to update records in database"
30
+ },
31
+ STORE_DELETE_FAILED: {
32
+ code: "D1006",
33
+ message: "Failed to delete records from database"
34
+ },
35
+ STORE_NOT_WRITABLE: {
36
+ code: "D1007",
37
+ message: "Store is not writable"
38
+ },
39
+ STORE_BLOB_NOT_FOUND: {
40
+ code: "D1008",
41
+ message: "Blob not found"
42
+ },
43
+ ELEMENT_NOT_FOUND: {
44
+ code: "D2001",
45
+ message: "Element not found"
46
+ },
47
+ ROOT_NOT_FOUND: {
48
+ code: "D2002",
49
+ message: "Root element not found"
50
+ },
51
+ DUPLICATE_ID: {
52
+ code: "D2003",
53
+ message: "Duplicate element ID"
54
+ },
55
+ ELEMENT_TAGNAME_MISMATCH: {
56
+ code: "D2004",
57
+ message: "Element tagName does not match the expected type"
58
+ },
59
+ INVALID_PARENT_CHILD: {
60
+ code: "D3001",
61
+ message: "Invalid parent-child relationship"
62
+ },
63
+ INVALID_ATTRIBUTE: {
64
+ code: "D3002",
65
+ message: "Invalid attribute for element"
66
+ },
67
+ PROTECTED_ROOT: {
68
+ code: "D3003",
69
+ message: "Root element cannot be deleted"
70
+ },
71
+ REQUIRED_ATTRIBUTE_MISSING: {
72
+ code: "D3004",
73
+ message: "Required attribute is missing"
74
+ },
75
+ UNIQUE_CONSTRAINT_VIOLATION: {
76
+ code: "D3005",
77
+ message: "Value is already used within its scope"
78
+ },
79
+ ALREADY_COMMITTED: {
80
+ code: "D4001",
81
+ message: "Transaction already committed"
82
+ },
83
+ ALREADY_FAILED: {
84
+ code: "D4002",
85
+ message: "Transaction already failed"
86
+ },
87
+ DATABASE_COMMIT_ERROR: {
88
+ code: "D4003",
89
+ message: "An error occurred while committing changes to the database"
90
+ },
91
+ CONCURRENT_TRANSACTION: {
92
+ code: "D4004",
93
+ message: "A transaction is already in progress. Concurrent transactions are not supported yet — serialize them or implement a transaction queue."
94
+ },
95
+ EXPORT_ROOT_NOT_FOUND: {
96
+ code: "D5001",
97
+ message: "Root element not found in records during export"
98
+ },
99
+ EXPORT_ORPHAN_CHILD_REF: {
100
+ code: "D5002",
101
+ message: "Parent references non-existent child record"
102
+ },
103
+ EXTENSION_METHOD_COLLISION: {
104
+ code: "D6001",
105
+ message: "Extension method name collision detected"
106
+ },
107
+ UNKNOWN_CONFIG_KEY: {
108
+ code: "D7001",
109
+ message: "Unknown config key"
110
+ },
111
+ DOCUMENT_NOT_REGISTERED: {
112
+ code: "D7002",
113
+ message: "Document not registered in project"
114
+ },
115
+ PROJECT_NOT_OPENED: {
116
+ code: "D7003",
117
+ message: "Project not opened"
118
+ },
119
+ BLOB_NOT_FOUND: {
120
+ code: "D7004",
121
+ message: "Blob not found in store"
122
+ }
123
+ };
124
+ //#endregion
125
+ //#region src/errors/errors.ts
126
+ function t(t, r) {
127
+ let i = e[t], a = {
128
+ code: i.code,
129
+ key: t,
130
+ message: r.message ?? i.message,
131
+ detail: r.detail,
132
+ method: n((/* @__PURE__ */ Error()).stack),
133
+ ref: r.ref,
134
+ cause: r.cause
135
+ }, o = Error(r.detail);
136
+ throw o.cause = a, o;
137
+ }
138
+ function n(e) {
139
+ if (!e) return "unknown";
140
+ let t = e.split("\n").slice(1).find((e) => !/\b(throwDialecteError|assert)\b/.test(e));
141
+ if (!t) return "unknown";
142
+ let n = t.match(/\bat\s+(\S+)\s+\(([^)]+)\)/), r = n?.[1], i = n?.[2];
143
+ if (!i || !r) return r ?? "unknown";
144
+ let a = i.match(/(\w[\w-]*\/src\/[^?:]+)/);
145
+ return a ? `${a[1].replace(/\.[^/.]+$/, "")}::${r}` : r;
146
+ }
147
+ //#endregion
148
+ //#region src/utils/invariant.ts
149
+ function r(e, n) {
150
+ if (e) return;
151
+ let { detail: r, key: i = "ASSERTION_FAILED", ref: a } = n;
152
+ t(i, {
153
+ detail: r,
154
+ ref: a
155
+ });
156
+ }
157
+ //#endregion
158
+ //#region src/utils/save-to-disk.ts
159
+ async function i(e) {
160
+ let { data: t, filename: n, pickerType: r } = e;
161
+ if ("showSaveFilePicker" in window) try {
162
+ let e = await (await window.showSaveFilePicker({
163
+ suggestedName: n,
164
+ ...r ? { types: [r] } : {}
165
+ })).createWritable();
166
+ await e.write(t), await e.close();
167
+ return;
168
+ } catch (e) {
169
+ if (e.name === "AbortError") return;
170
+ console.error("Save failed:", e);
171
+ return;
172
+ }
173
+ let i = URL.createObjectURL(t), a = document.createElement("a");
174
+ a.href = i, a.download = n, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i);
175
+ }
176
+ //#endregion
177
+ export { e as i, r as n, t as r, i as t };
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './utils/index'
1
+ export * from './utils/index.js'
2
2
  export {}
package/dist/utils.js CHANGED
@@ -1,23 +1,2 @@
1
- import { i as w } from "./invariant-CqEgHr3M.js";
2
- async function s(c) {
3
- const { data: r, filename: t, pickerType: o } = c;
4
- if ("showSaveFilePicker" in window)
5
- try {
6
- const i = await (await window.showSaveFilePicker({
7
- suggestedName: t,
8
- ...o ? { types: [o] } : {}
9
- })).createWritable();
10
- await i.write(r), await i.close();
11
- return;
12
- } catch (a) {
13
- if (a.name === "AbortError") return;
14
- console.error("Save failed:", a);
15
- return;
16
- }
17
- const n = URL.createObjectURL(r), e = document.createElement("a");
18
- e.href = n, e.download = t, document.body.appendChild(e), e.click(), e.remove(), URL.revokeObjectURL(n);
19
- }
20
- export {
21
- w as invariant,
22
- s as saveToDisk
23
- };
1
+ import { n as e, t } from "./utils-B_-lXlpE.js";
2
+ export { e as invariant, t as saveToDisk };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialecte/core",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Dialecte - Core functionality for Dialecte SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -56,26 +56,24 @@
56
56
  "xml-formatter": "^3.6.7"
57
57
  },
58
58
  "devDependencies": {
59
- "@tsconfig/node22": "^22.0.2",
60
- "@types/node": "^22.15.32",
59
+ "@tsconfig/node24": "^24.0.4",
60
+ "@types/node": "^24.12.4",
61
61
  "@types/sax": "^1.2.7",
62
- "@vitest/browser": "^4.1.8",
63
62
  "@vitest/browser-playwright": "^4.1.8",
64
63
  "@xmldom/xmldom": "^0.8.11",
65
64
  "husky": "^9.1.7",
66
65
  "jiti": "^2.4.2",
67
66
  "npm-run-all2": "^8.0.4",
68
- "oxfmt": "^0.38.0",
69
- "oxlint": "^1.60.0",
70
- "oxlint-tsgolint": "^0.21.1",
67
+ "oxfmt": "^0.53.0",
68
+ "oxlint": "^1.68.0",
69
+ "oxlint-tsgolint": "^0.23.0",
71
70
  "playwright": "^1.60.0",
72
- "tsx": "^4.21.0",
73
- "typescript": "^5.9.3",
74
- "vite": "^7.3.1",
75
- "vite-plugin-dts": "^4.5.4",
76
- "vitepress": "^2.0.0-alpha.16",
77
- "vitepress-plugin-llms": "^1.11.1",
78
- "vitest": "^4.1.8",
79
- "vitest-browser-vue": "^1.0.0"
71
+ "tsx": "^4.22.4",
72
+ "typescript": "^6.0.3",
73
+ "vite": "^8.0.16",
74
+ "vite-plugin-dts": "^5.0.2",
75
+ "vitepress": "^2.0.0-alpha.17",
76
+ "vitepress-plugin-llms": "^1.13.1",
77
+ "vitest": "^4.1.8"
80
78
  }
81
79
  }