@septkit/shell-lib 0.0.3 → 0.0.5
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/constants.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +158 -2
- package/dist/shell-context.d.ts +13 -0
- package/dist/types/api.d.ts +1 -2
- package/package.json +3 -2
package/dist/constants.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export type * from './types';
|
|
2
|
-
export { LIBRARY_DB_PREFIX, TEMP_DOCUMENT_PREFIX } from './constants';
|
|
2
|
+
export { LIBRARY_DB_PREFIX, TEMP_DOCUMENT_PREFIX, TEMP_PROJECT_PREFIX } from './constants';
|
|
3
|
+
export { setShellContext, clearShellContext, getProject, getActiveDocumentId, getCommands, } from './shell-context';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,160 @@
|
|
|
1
1
|
//#region src/constants.ts
|
|
2
|
-
var e = "SET-LIBRARY-", t = "TEMP-"
|
|
2
|
+
var e = "SET-LIBRARY-", t = "TEMP-", n = "TEMP-PROJECT-", r = {
|
|
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
|
+
ELEMENT_NOT_FOUND: {
|
|
40
|
+
code: "D2001",
|
|
41
|
+
message: "Element not found"
|
|
42
|
+
},
|
|
43
|
+
ROOT_NOT_FOUND: {
|
|
44
|
+
code: "D2002",
|
|
45
|
+
message: "Root element not found"
|
|
46
|
+
},
|
|
47
|
+
DUPLICATE_ID: {
|
|
48
|
+
code: "D2003",
|
|
49
|
+
message: "Duplicate element ID"
|
|
50
|
+
},
|
|
51
|
+
ELEMENT_TAGNAME_MISMATCH: {
|
|
52
|
+
code: "D2004",
|
|
53
|
+
message: "Element tagName does not match the expected type"
|
|
54
|
+
},
|
|
55
|
+
INVALID_PARENT_CHILD: {
|
|
56
|
+
code: "D3001",
|
|
57
|
+
message: "Invalid parent-child relationship"
|
|
58
|
+
},
|
|
59
|
+
INVALID_ATTRIBUTE: {
|
|
60
|
+
code: "D3002",
|
|
61
|
+
message: "Invalid attribute for element"
|
|
62
|
+
},
|
|
63
|
+
PROTECTED_ROOT: {
|
|
64
|
+
code: "D3003",
|
|
65
|
+
message: "Root element cannot be deleted"
|
|
66
|
+
},
|
|
67
|
+
REQUIRED_ATTRIBUTE_MISSING: {
|
|
68
|
+
code: "D3004",
|
|
69
|
+
message: "Required attribute is missing"
|
|
70
|
+
},
|
|
71
|
+
ALREADY_COMMITTED: {
|
|
72
|
+
code: "D4001",
|
|
73
|
+
message: "Transaction already committed"
|
|
74
|
+
},
|
|
75
|
+
ALREADY_FAILED: {
|
|
76
|
+
code: "D4002",
|
|
77
|
+
message: "Transaction already failed"
|
|
78
|
+
},
|
|
79
|
+
DATABASE_COMMIT_ERROR: {
|
|
80
|
+
code: "D4003",
|
|
81
|
+
message: "An error occurred while committing changes to the database"
|
|
82
|
+
},
|
|
83
|
+
CONCURRENT_TRANSACTION: {
|
|
84
|
+
code: "D4004",
|
|
85
|
+
message: "A transaction is already in progress. Concurrent transactions are not supported yet — serialize them or implement a transaction queue."
|
|
86
|
+
},
|
|
87
|
+
EXPORT_ROOT_NOT_FOUND: {
|
|
88
|
+
code: "D5001",
|
|
89
|
+
message: "Root element not found in records during export"
|
|
90
|
+
},
|
|
91
|
+
EXPORT_ORPHAN_CHILD_REF: {
|
|
92
|
+
code: "D5002",
|
|
93
|
+
message: "Parent references non-existent child record"
|
|
94
|
+
},
|
|
95
|
+
EXTENSION_METHOD_COLLISION: {
|
|
96
|
+
code: "D6001",
|
|
97
|
+
message: "Extension method name collision detected"
|
|
98
|
+
},
|
|
99
|
+
UNKNOWN_CONFIG_KEY: {
|
|
100
|
+
code: "D7001",
|
|
101
|
+
message: "Unknown config key"
|
|
102
|
+
},
|
|
103
|
+
DOCUMENT_NOT_REGISTERED: {
|
|
104
|
+
code: "D7002",
|
|
105
|
+
message: "Document not registered in project"
|
|
106
|
+
},
|
|
107
|
+
PROJECT_NOT_OPENED: {
|
|
108
|
+
code: "D7003",
|
|
109
|
+
message: "Project not opened"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function i(e, t) {
|
|
113
|
+
let n = r[e], i = {
|
|
114
|
+
code: n.code,
|
|
115
|
+
key: e,
|
|
116
|
+
message: t.message ?? n.message,
|
|
117
|
+
detail: t.detail,
|
|
118
|
+
method: a((/* @__PURE__ */ Error()).stack),
|
|
119
|
+
ref: t.ref,
|
|
120
|
+
cause: t.cause
|
|
121
|
+
}, o = Error(t.detail);
|
|
122
|
+
throw o.cause = i, o;
|
|
123
|
+
}
|
|
124
|
+
function a(e) {
|
|
125
|
+
if (!e) return "unknown";
|
|
126
|
+
let t = e.split("\n").slice(1).find((e) => !/\b(throwDialecteError|assert)\b/.test(e));
|
|
127
|
+
if (!t) return "unknown";
|
|
128
|
+
let n = t.match(/\bat\s+(\S+)\s+\(([^)]+)\)/), r = n?.[1], i = n?.[2];
|
|
129
|
+
if (!i || !r) return r ?? "unknown";
|
|
130
|
+
let a = i.match(/(\w[\w-]*\/src\/[^?:]+)/);
|
|
131
|
+
return a ? `${a[1].replace(/\.[^/.]+$/, "")}::${r}` : r;
|
|
132
|
+
}
|
|
133
|
+
function o(e, t) {
|
|
134
|
+
if (e) return;
|
|
135
|
+
let { detail: n, key: r = "ASSERTION_FAILED", ref: a } = t;
|
|
136
|
+
i(r, {
|
|
137
|
+
detail: n,
|
|
138
|
+
ref: a
|
|
139
|
+
});
|
|
140
|
+
}
|
|
3
141
|
//#endregion
|
|
4
|
-
|
|
142
|
+
//#region src/shell-context.ts
|
|
143
|
+
var s = null;
|
|
144
|
+
function c(e) {
|
|
145
|
+
s = e;
|
|
146
|
+
}
|
|
147
|
+
function l() {
|
|
148
|
+
s = null;
|
|
149
|
+
}
|
|
150
|
+
function u() {
|
|
151
|
+
return o(s, { detail: "getProject: shell context not set. Call setShellContext(api) before app.mount()." }), s.project;
|
|
152
|
+
}
|
|
153
|
+
function d() {
|
|
154
|
+
return o(s, { detail: "getActiveDocumentId: shell context not set. Call setShellContext(api) before app.mount()." }), s.activeDocumentId;
|
|
155
|
+
}
|
|
156
|
+
function f() {
|
|
157
|
+
return o(s, { detail: "getCommands: shell context not set. Call setShellContext(api) before app.mount()." }), s.commands;
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
export { e as LIBRARY_DB_PREFIX, t as TEMP_DOCUMENT_PREFIX, n as TEMP_PROJECT_PREFIX, l as clearShellContext, d as getActiveDocumentId, f as getCommands, u as getProject, c as setShellContext };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Scl } from '@dialecte/scl/v2019C1';
|
|
2
|
+
import { Observable, ShellCommands } from './types/api';
|
|
3
|
+
interface ShellContext {
|
|
4
|
+
project: Scl.Project;
|
|
5
|
+
activeDocumentId: Observable<string>;
|
|
6
|
+
commands: ShellCommands;
|
|
7
|
+
}
|
|
8
|
+
export declare function setShellContext(ctx: ShellContext): void;
|
|
9
|
+
export declare function clearShellContext(): void;
|
|
10
|
+
export declare function getProject(): Scl.Project;
|
|
11
|
+
export declare function getActiveDocumentId(): Observable<string>;
|
|
12
|
+
export declare function getCommands(): ShellCommands;
|
|
13
|
+
export {};
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Scl } from '@dialecte/scl/v2019C1';
|
|
2
2
|
export interface ShellCommands {
|
|
3
|
-
activateDocument: (documentId: string) => void
|
|
3
|
+
activateDocument: (documentId: string) => Promise<void>;
|
|
4
4
|
switchProject: (projectName: string) => Promise<void>;
|
|
5
5
|
onDocumentsChanged: (listener: () => void) => () => void;
|
|
6
6
|
}
|
|
7
7
|
export interface Observable<T> {
|
|
8
8
|
readonly value: T | undefined;
|
|
9
|
-
emit(newValue: T | undefined): void;
|
|
10
9
|
subscribe(listener: (value: T | undefined, prev: T | undefined) => void): () => void;
|
|
11
10
|
}
|
|
12
11
|
export interface ExtensionAPI {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@septkit/shell-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dialecte/
|
|
23
|
+
"@dialecte/core": "^0.2.12",
|
|
24
|
+
"@dialecte/scl": "^0.2.8"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"oxlint": "~1.6.0",
|