xmlui 0.9.74 → 0.9.76
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/lib/{apiInterceptorWorker-DXW_XKKI.mjs → apiInterceptorWorker-DH8wqOVq.mjs} +1382 -1919
- package/dist/lib/{index-D1pmdW3I.mjs → index-mdlNmhj_.mjs} +7717 -7683
- package/dist/lib/initMock-BXQ0HzU7.mjs +565 -0
- package/dist/lib/xmlui-parser.d.ts +1 -0
- package/dist/lib/xmlui.d.ts +20 -2
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/{apiInterceptorWorker-BFjqjbag.mjs → apiInterceptorWorker-Bb5-fQup.mjs} +1258 -1795
- package/dist/metadata/{collectedComponentMetadata-BVLAibj_.mjs → collectedComponentMetadata-CWaLbEQz.mjs} +9509 -9475
- package/dist/metadata/initMock-BLnKtG1C.mjs +565 -0
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +113 -113
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/components/Charts/BarChart/BarChart.js +13 -9
- package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +4 -3
- package/dist/scripts/src/components/FormItem/FormItem.js +2 -2
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +0 -1
- package/dist/scripts/src/components/TreeDisplay/TreeDisplay.js +1 -1
- package/dist/scripts/src/components-core/RestApiProxy.js +11 -3
- package/dist/scripts/src/components-core/action/APICall.js +2 -2
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +42 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +63 -22
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +3 -6
- package/dist/scripts/src/components-core/interception/initMock.js +20 -0
- package/dist/scripts/src/components-core/loader/DataLoader.js +4 -2
- package/dist/scripts/src/components-core/rendering/Container.js +3 -0
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +1 -1
- package/dist/scripts/src/syntax/grammar.tmLanguage.json +1 -1
- package/dist/standalone/xmlui-standalone.es.d.ts +21 -3
- package/dist/standalone/xmlui-standalone.umd.js +267 -267
- package/package.json +1 -1
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
import { delay as D, HttpResponse as g, matchRequestUrl as E } from "msw";
|
|
2
|
+
import { isArray as N, isObject as U, mapValues as T } from "lodash-es";
|
|
3
|
+
import { r as M, g as $, d as F, m as O, a as B, o as A, T as x } from "./index-mdlNmhj_.mjs";
|
|
4
|
+
import q from "dexie";
|
|
5
|
+
var k = /* @__PURE__ */ ((e) => (e[e.Continue = 100] = "Continue", e[e.SwitchingProtocols = 101] = "SwitchingProtocols", e[e.Processing = 102] = "Processing", e[e.EarlyHints = 103] = "EarlyHints", e[e.Ok = 200] = "Ok", e[e.Created = 201] = "Created", e[e.Accepted = 202] = "Accepted", e[e.NonAuthoritativeInformation = 203] = "NonAuthoritativeInformation", e[e.NoContent = 204] = "NoContent", e[e.ResetContent = 205] = "ResetContent", e[e.PartialContent = 206] = "PartialContent", e[e.MultiStatus = 207] = "MultiStatus", e[e.AlreadyReported = 208] = "AlreadyReported", e[e.ImUsed = 226] = "ImUsed", e[e.MultipleChoices = 300] = "MultipleChoices", e[e.MovedPermanently = 301] = "MovedPermanently", e[e.Found = 302] = "Found", e[e.SeeOther = 303] = "SeeOther", e[e.NotModified = 304] = "NotModified", e[e.UseProxy = 305] = "UseProxy", e[e.Unused = 306] = "Unused", e[e.TemporaryRedirect = 307] = "TemporaryRedirect", e[e.PermanentRedirect = 308] = "PermanentRedirect", e[e.BadRequest = 400] = "BadRequest", e[e.Unauthorized = 401] = "Unauthorized", e[e.PaymentRequired = 402] = "PaymentRequired", e[e.Forbidden = 403] = "Forbidden", e[e.NotFound = 404] = "NotFound", e[e.MethodNotAllowed = 405] = "MethodNotAllowed", e[e.NotAcceptable = 406] = "NotAcceptable", e[e.ProxyAuthenticationRequired = 407] = "ProxyAuthenticationRequired", e[e.RequestTimeout = 408] = "RequestTimeout", e[e.Conflict = 409] = "Conflict", e[e.Gone = 410] = "Gone", e[e.LengthRequired = 411] = "LengthRequired", e[e.PreconditionFailed = 412] = "PreconditionFailed", e[e.PayloadTooLarge = 413] = "PayloadTooLarge", e[e.UriTooLong = 414] = "UriTooLong", e[e.UnsupportedMediaType = 415] = "UnsupportedMediaType", e[e.RangeNotSatisfiable = 416] = "RangeNotSatisfiable", e[e.ExpectationFailed = 417] = "ExpectationFailed", e[e.ImATeapot = 418] = "ImATeapot", e[e.MisdirectedRequest = 421] = "MisdirectedRequest", e[e.UnprocessableEntity = 422] = "UnprocessableEntity", e[e.Locked = 423] = "Locked", e[e.FailedDependency = 424] = "FailedDependency", e[e.TooEarly = 425] = "TooEarly", e[e.UpgradeRequired = 426] = "UpgradeRequired", e[e.PreconditionRequired = 428] = "PreconditionRequired", e[e.TooManyRequests = 429] = "TooManyRequests", e[e.RequestHeaderFieldsTooLarge = 431] = "RequestHeaderFieldsTooLarge", e[e.UnavailableForLegalReasons = 451] = "UnavailableForLegalReasons", e[e.InternalServerError = 500] = "InternalServerError", e[e.NotImplemented = 501] = "NotImplemented", e[e.BadGateway = 502] = "BadGateway", e[e.ServiceUnavailable = 503] = "ServiceUnavailable", e[e.GatewayTimeout = 504] = "GatewayTimeout", e[e.HttpVersionNotSupported = 505] = "HttpVersionNotSupported", e[e.VariantAlsoNegotiates = 506] = "VariantAlsoNegotiates", e[e.InsufficientStorage = 507] = "InsufficientStorage", e[e.LoopDetected = 508] = "LoopDetected", e[e.NotExtended = 510] = "NotExtended", e[e.NetworkAuthenticationRequired = 511] = "NetworkAuthenticationRequired", e))(k || {});
|
|
6
|
+
class m extends Error {
|
|
7
|
+
constructor(r, n) {
|
|
8
|
+
super((n == null ? void 0 : n.message) || "Not found"), this.details = n, this.status = r, Object.setPrototypeOf(this, m.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
class p extends m {
|
|
12
|
+
constructor(r) {
|
|
13
|
+
super(404, r), Object.setPrototypeOf(this, p.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class v extends m {
|
|
17
|
+
constructor(r) {
|
|
18
|
+
super(401, r), Object.setPrototypeOf(this, v.prototype);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class P extends m {
|
|
22
|
+
constructor(r) {
|
|
23
|
+
super(409, r), Object.setPrototypeOf(this, P.prototype);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function b(e) {
|
|
27
|
+
let r;
|
|
28
|
+
return e && (typeof e == "string" ? r = {
|
|
29
|
+
message: e
|
|
30
|
+
} : r = e), r;
|
|
31
|
+
}
|
|
32
|
+
const L = {
|
|
33
|
+
NotFound404: (e) => new p(b(e)),
|
|
34
|
+
Unauthorized401: (e) => new v(b(e)),
|
|
35
|
+
HttpError: (e, r) => new m(e, b(r)),
|
|
36
|
+
Conflict409: (e) => new P(b(e))
|
|
37
|
+
}, j = {
|
|
38
|
+
getDate: (e) => e ? new Date(e) : /* @__PURE__ */ new Date()
|
|
39
|
+
}, I = (e, r) => N(e) ? e.map((n) => I(n, r)) : U(e) ? T(e, (n) => I(n, r)) : r(e);
|
|
40
|
+
class z {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.cookies = {};
|
|
43
|
+
}
|
|
44
|
+
setCookie(r, n) {
|
|
45
|
+
this.cookies[r] = n;
|
|
46
|
+
}
|
|
47
|
+
getCookieHeader() {
|
|
48
|
+
const r = [];
|
|
49
|
+
return Object.entries(this.cookies).forEach(([n, i]) => {
|
|
50
|
+
Array.isArray(i) ? i.forEach((s) => r.push(["Set-Cookie", `${n}=${s}`])) : r.push(["Set-Cookie", `${n}=${i}`]);
|
|
51
|
+
}), new Headers(r);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class V {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.headers = {};
|
|
57
|
+
}
|
|
58
|
+
setHeader(r, n) {
|
|
59
|
+
this.headers[r] = n;
|
|
60
|
+
}
|
|
61
|
+
getHeaders() {
|
|
62
|
+
const r = [];
|
|
63
|
+
return Object.entries(this.headers).forEach(([n, i]) => {
|
|
64
|
+
r.push([n, i]);
|
|
65
|
+
}), new Headers(r);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class G {
|
|
69
|
+
constructor(r, n, i) {
|
|
70
|
+
this.definition = r, this.db = n, this.authService = i, this.apiStateHash = {}, this.resolvedHelpers = I(r.helpers, (s) => typeof s == "string" ? (...a) => this.runFn(s, ...a) : s), r.initialize && this.runFn(r.initialize);
|
|
71
|
+
}
|
|
72
|
+
async executeOperation(r, n, i, s) {
|
|
73
|
+
var t;
|
|
74
|
+
const a = (t = this.definition.operations) == null ? void 0 : t[r];
|
|
75
|
+
if (!a)
|
|
76
|
+
throw new Error(`Unknown backend operation: ${r}`);
|
|
77
|
+
return await this.runFn(a, n, i, s);
|
|
78
|
+
}
|
|
79
|
+
async runFn(r, ...n) {
|
|
80
|
+
var a, t, h, w, c, u, o;
|
|
81
|
+
let i = {
|
|
82
|
+
...this.resolvedHelpers,
|
|
83
|
+
$db: this.db,
|
|
84
|
+
$state: this.apiStateHash,
|
|
85
|
+
$authService: this.authService,
|
|
86
|
+
$env: j,
|
|
87
|
+
$loggedInUser: this.authService.getLoggedInUser(),
|
|
88
|
+
$pathParams: (a = n[0]) == null ? void 0 : a.pathParams,
|
|
89
|
+
$queryParams: (t = n[0]) == null ? void 0 : t.queryParams,
|
|
90
|
+
$requestBody: (h = n[0]) == null ? void 0 : h.requestBody,
|
|
91
|
+
$cookies: (w = n[0]) == null ? void 0 : w.cookies,
|
|
92
|
+
$requestHeaders: (c = n[0]) == null ? void 0 : c.requestHeaders,
|
|
93
|
+
$cookieService: n[1],
|
|
94
|
+
//TODO really ugly, temporary solution
|
|
95
|
+
$headerService: n[2]
|
|
96
|
+
//TODO really ugly, temporary solution
|
|
97
|
+
};
|
|
98
|
+
const s = J({
|
|
99
|
+
localContext: i,
|
|
100
|
+
eventArgs: n,
|
|
101
|
+
appContext: {
|
|
102
|
+
...B,
|
|
103
|
+
...O,
|
|
104
|
+
delay: F,
|
|
105
|
+
Errors: L,
|
|
106
|
+
createFile: (...y) => new File(y[0], y[1], y[2]),
|
|
107
|
+
getDate: $
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return await M(r, s), (o = (u = s.mainThread) == null ? void 0 : u.blocks) != null && o.length ? s.mainThread.blocks[s.mainThread.blocks.length - 1].returnValue : void 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function J(e) {
|
|
114
|
+
return {
|
|
115
|
+
mainThread: {
|
|
116
|
+
childThreads: [],
|
|
117
|
+
blocks: [{ vars: {} }],
|
|
118
|
+
loops: [],
|
|
119
|
+
breakLabelValue: -1
|
|
120
|
+
},
|
|
121
|
+
...e
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
class l {
|
|
125
|
+
constructor(r) {
|
|
126
|
+
this.list = [];
|
|
127
|
+
for (const n of r)
|
|
128
|
+
this.list.push(n);
|
|
129
|
+
}
|
|
130
|
+
get length() {
|
|
131
|
+
return this.list.length;
|
|
132
|
+
}
|
|
133
|
+
toArray() {
|
|
134
|
+
return this.list.slice(0);
|
|
135
|
+
}
|
|
136
|
+
at(r) {
|
|
137
|
+
if (r < 0 || r > this.list.length - 1)
|
|
138
|
+
throw new Error(`Index (${r}) is out of range [0..${Math.max(this.list.length - 1, 0)}]`);
|
|
139
|
+
return this.list[r];
|
|
140
|
+
}
|
|
141
|
+
all() {
|
|
142
|
+
return new l(this.list);
|
|
143
|
+
}
|
|
144
|
+
async single(r) {
|
|
145
|
+
const n = await this.where(r);
|
|
146
|
+
if (n.length === 0)
|
|
147
|
+
throw new Error("No items found with the specified predicate");
|
|
148
|
+
if (n.length > 1)
|
|
149
|
+
throw new Error("Multiple items found with the specified predicate");
|
|
150
|
+
return n.at(0);
|
|
151
|
+
}
|
|
152
|
+
async singleOrDefault(r, n) {
|
|
153
|
+
const i = await this.where(r);
|
|
154
|
+
if (i.length === 0)
|
|
155
|
+
return n;
|
|
156
|
+
if (i.length > 1)
|
|
157
|
+
throw new Error("Multiple items found with the specified predicate");
|
|
158
|
+
return i.at(0);
|
|
159
|
+
}
|
|
160
|
+
async where(r) {
|
|
161
|
+
return new l(await this.whereAsArray(r));
|
|
162
|
+
}
|
|
163
|
+
async whereAsArray(r) {
|
|
164
|
+
const n = await Promise.all(this.list.map(r ?? (async () => !0)));
|
|
165
|
+
return this.list.filter((i, s) => n[s]);
|
|
166
|
+
}
|
|
167
|
+
async orderBy(...r) {
|
|
168
|
+
return new l(await A(this.list, ...r));
|
|
169
|
+
}
|
|
170
|
+
async orderByAsArray(...r) {
|
|
171
|
+
return await A(this.list, ...r);
|
|
172
|
+
}
|
|
173
|
+
async groupBy(r) {
|
|
174
|
+
return new l(await this.groupByAsArray(r));
|
|
175
|
+
}
|
|
176
|
+
async groupByAsArray(r) {
|
|
177
|
+
const n = /* @__PURE__ */ new Map();
|
|
178
|
+
for (const s of this.list) {
|
|
179
|
+
const a = await r(s), t = n.get(a);
|
|
180
|
+
t === void 0 ? n.set(a, [s]) : t.push(s);
|
|
181
|
+
}
|
|
182
|
+
const i = [];
|
|
183
|
+
for (const [s, a] of n.entries())
|
|
184
|
+
i.push({ key: s, items: a });
|
|
185
|
+
return i;
|
|
186
|
+
}
|
|
187
|
+
async distinct(r) {
|
|
188
|
+
r ?? (r = async (i) => i);
|
|
189
|
+
const n = /* @__PURE__ */ new Set();
|
|
190
|
+
for (const i of this.list)
|
|
191
|
+
n.add(await r(i));
|
|
192
|
+
return new l(n.values());
|
|
193
|
+
}
|
|
194
|
+
async distinctAsArray(r) {
|
|
195
|
+
return (await this.distinct(r)).toArray();
|
|
196
|
+
}
|
|
197
|
+
async maxValue(r = "id", n) {
|
|
198
|
+
let i = n ? (await new l(this.list).where(n)).toArray() : this.list;
|
|
199
|
+
return i = await A(i, (s) => s[r], !0), i.length === 0 ? void 0 : i[0][r];
|
|
200
|
+
}
|
|
201
|
+
async skip(r) {
|
|
202
|
+
return new l(this.list.slice(r));
|
|
203
|
+
}
|
|
204
|
+
async take(r) {
|
|
205
|
+
return new l(this.list.slice(0, r));
|
|
206
|
+
}
|
|
207
|
+
async skipTake(r, n) {
|
|
208
|
+
return new l(this.list.slice(r, n + r));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
class K {
|
|
212
|
+
constructor(r, n = {}, i) {
|
|
213
|
+
this.tables = r, this.initialData = n, this.config = i, this.db = null, this.getItems = (s) => this.getDb().table(s).toArray(), this.findItems = async (s, a) => {
|
|
214
|
+
const t = await this.getItems(s), h = await Promise.all(t.map(a));
|
|
215
|
+
return t.filter((w, c) => h[c]);
|
|
216
|
+
}, this.getItem = async (s, a) => {
|
|
217
|
+
const t = await this.getItems(s), h = await Promise.all(t.map(a));
|
|
218
|
+
return t.find((w, c) => h[c]);
|
|
219
|
+
}, this.getItemById = async (s, a) => await this.getItem(s, async (t) => t.id + "" == a + ""), this.deleteItems = async (s, a) => {
|
|
220
|
+
}, this.insertItem = async (s, a) => {
|
|
221
|
+
const t = await this.getDb().table(s).add(a);
|
|
222
|
+
return this.getItemById(s, t);
|
|
223
|
+
}, this.updateItem = async (s, a) => (await this.getDb().table(s).update(a.id, a), await this.getItemById(s, a.id));
|
|
224
|
+
}
|
|
225
|
+
getDb() {
|
|
226
|
+
if (this.db === null)
|
|
227
|
+
throw new Error("Db is not initialized yet");
|
|
228
|
+
return this.db;
|
|
229
|
+
}
|
|
230
|
+
async initialize() {
|
|
231
|
+
var t, h, w;
|
|
232
|
+
const r = typeof this.initialData == "function" ? await this.initialData() : this.initialData, n = {}, i = /* @__PURE__ */ new Set();
|
|
233
|
+
this.tables ? this.tables.forEach((c) => {
|
|
234
|
+
const u = [];
|
|
235
|
+
c.pk.length === 1 ? u.push(c.pk[0]) : u.push(`[${c.pk.join("+")}]`), c.indexes && u.push(...c.indexes), n[c.name] = u.join(", "), i.add(c.name);
|
|
236
|
+
}) : Object.entries(r).forEach(([c]) => {
|
|
237
|
+
n[c] = "++id", i.add(c);
|
|
238
|
+
});
|
|
239
|
+
const s = ((t = this.config) == null ? void 0 : t.version) !== void 0 && typeof ((h = this.config) == null ? void 0 : h.version) == "number" ? (w = this.config) == null ? void 0 : w.version : 1, a = await this.dropDbOnVersionChange(s);
|
|
240
|
+
this.db = this.createDbInstance(), this.db.version(s).stores(n), a && await Promise.all(
|
|
241
|
+
Object.entries(r).map(async ([c, u]) => {
|
|
242
|
+
try {
|
|
243
|
+
await this.getDb().table(c).bulkAdd(u);
|
|
244
|
+
} catch (o) {
|
|
245
|
+
console.error(o);
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
), i.forEach((c) => {
|
|
249
|
+
this[`$${c}`] = W(this.getDb().table(c));
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
createDbInstance() {
|
|
253
|
+
var r;
|
|
254
|
+
return new q(((r = this.config) == null ? void 0 : r.database) ?? "defaultIndexDb");
|
|
255
|
+
}
|
|
256
|
+
async dropDbOnVersionChange(r) {
|
|
257
|
+
const n = this.createDbInstance();
|
|
258
|
+
return await q.exists(n.name) ? (await n.open(), n.verno !== r ? (await n.delete(), !0) : (n.close(), !1)) : !0;
|
|
259
|
+
}
|
|
260
|
+
// --- This method signifies that a section of operations is executed in a transaction
|
|
261
|
+
async transaction(r) {
|
|
262
|
+
if (!this.db) return;
|
|
263
|
+
const n = this.db.tables;
|
|
264
|
+
await this.db.transaction("rw", n, r);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async function W(e) {
|
|
268
|
+
const r = () => e.db.table(e.name), n = async (i) => {
|
|
269
|
+
const s = await e.toArray(), a = await Promise.all(s.map(i ?? (async () => !0)));
|
|
270
|
+
return s.filter((t, h) => a[h]);
|
|
271
|
+
};
|
|
272
|
+
return {
|
|
273
|
+
native: r,
|
|
274
|
+
insert: async (i) => {
|
|
275
|
+
const s = await e.add(i);
|
|
276
|
+
return r().get(s);
|
|
277
|
+
},
|
|
278
|
+
update: async (i) => (await e.update(i.id, i), r().get(i.id)),
|
|
279
|
+
save: async (i) => {
|
|
280
|
+
const s = await e.put(i);
|
|
281
|
+
return e.get(s);
|
|
282
|
+
},
|
|
283
|
+
deleteById: async (i) => {
|
|
284
|
+
await e.delete(i);
|
|
285
|
+
},
|
|
286
|
+
byId: async (i) => {
|
|
287
|
+
if (i == null)
|
|
288
|
+
return null;
|
|
289
|
+
let s = i;
|
|
290
|
+
return e.schema.primKey.src === "++id" && (s = Number(i)), e.get(s);
|
|
291
|
+
},
|
|
292
|
+
toArray: async () => await e.toArray(),
|
|
293
|
+
single: async (i) => await new l(await e.toArray()).single(i),
|
|
294
|
+
singleOrDefault: async (i, s) => await new l(await e.toArray()).singleOrDefault(
|
|
295
|
+
i,
|
|
296
|
+
s
|
|
297
|
+
),
|
|
298
|
+
where: async (i) => new l(await n(i)),
|
|
299
|
+
whereAsArray: async (i) => await n(i),
|
|
300
|
+
orderBy: async (...i) => await new l(await e.toArray()).orderBy(...i),
|
|
301
|
+
orderByAsArray: async (...i) => await new l(await e.toArray()).orderByAsArray(...i),
|
|
302
|
+
groupBy: async (i) => await new l(await e.toArray()).groupBy(i),
|
|
303
|
+
groupByAsArray: async (i) => await new l(await e.toArray()).groupByAsArray(i),
|
|
304
|
+
distinct: async (i) => await new l(await e.toArray()).distinct(i),
|
|
305
|
+
distinctAsArray: async (i) => await new l(await e.toArray()).distinctAsArray(i),
|
|
306
|
+
maxValue: async (i = "id", s) => await new l(await e.toArray()).maxValue(i, s),
|
|
307
|
+
skip: async (i) => await new l(await e.toArray()).skip(i),
|
|
308
|
+
take: async (i) => await new l(await e.toArray()).take(i),
|
|
309
|
+
skipTake: async (i, s) => await new l(await e.toArray()).skipTake(i, s)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function R(e, r) {
|
|
313
|
+
if (!r) return e;
|
|
314
|
+
const n = { ...e };
|
|
315
|
+
return Object.keys(e).forEach((i) => {
|
|
316
|
+
if (!(i in r)) return;
|
|
317
|
+
const s = e[i], a = typeof s;
|
|
318
|
+
switch (r[i]) {
|
|
319
|
+
case "integer":
|
|
320
|
+
switch (a) {
|
|
321
|
+
case "number":
|
|
322
|
+
n[i] = Math.round(s);
|
|
323
|
+
break;
|
|
324
|
+
case "string":
|
|
325
|
+
n[i] = parseInt(s, 10);
|
|
326
|
+
break;
|
|
327
|
+
case "boolean":
|
|
328
|
+
n[i] = s ? 1 : 0;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
case "float":
|
|
333
|
+
case "real":
|
|
334
|
+
case "double":
|
|
335
|
+
switch (a) {
|
|
336
|
+
case "number":
|
|
337
|
+
n[i] = s;
|
|
338
|
+
break;
|
|
339
|
+
case "string":
|
|
340
|
+
n[i] = parseFloat(s);
|
|
341
|
+
break;
|
|
342
|
+
case "boolean":
|
|
343
|
+
n[i] = s ? 1 : 0;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
break;
|
|
347
|
+
case "boolean":
|
|
348
|
+
switch (a) {
|
|
349
|
+
case "string":
|
|
350
|
+
switch (s.toLowerCase()) {
|
|
351
|
+
case "true":
|
|
352
|
+
case "yes":
|
|
353
|
+
case "on":
|
|
354
|
+
n[i] = !0;
|
|
355
|
+
break;
|
|
356
|
+
case "false":
|
|
357
|
+
case "no":
|
|
358
|
+
case "off":
|
|
359
|
+
n[i] = !1;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
break;
|
|
363
|
+
case "number":
|
|
364
|
+
n[i] = !!s;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
}), n;
|
|
370
|
+
}
|
|
371
|
+
class Q {
|
|
372
|
+
constructor(r, n = {}, i) {
|
|
373
|
+
this.tables = r, this.initialData = n, this.config = i;
|
|
374
|
+
}
|
|
375
|
+
getItems(r) {
|
|
376
|
+
throw new Error("Method not implemented.");
|
|
377
|
+
}
|
|
378
|
+
getItem(r, n) {
|
|
379
|
+
throw new Error("Method not implemented.");
|
|
380
|
+
}
|
|
381
|
+
getItemById(r, n) {
|
|
382
|
+
throw new Error("Method not implemented.");
|
|
383
|
+
}
|
|
384
|
+
deleteItems(r, n) {
|
|
385
|
+
throw new Error("Method not implemented.");
|
|
386
|
+
}
|
|
387
|
+
insertItem(r, n) {
|
|
388
|
+
throw new Error("Method not implemented.");
|
|
389
|
+
}
|
|
390
|
+
updateItem(r, n) {
|
|
391
|
+
throw new Error("Method not implemented.");
|
|
392
|
+
}
|
|
393
|
+
async initialize() {
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function X(...e) {
|
|
397
|
+
const r = {};
|
|
398
|
+
for (const n of e) {
|
|
399
|
+
if (!U(n))
|
|
400
|
+
throw new TypeError("All arguments must be of type object");
|
|
401
|
+
const i = new Headers(n);
|
|
402
|
+
for (const [s, a] of i.entries())
|
|
403
|
+
a === void 0 || a === "undefined" ? delete r[s] : r[s] = a;
|
|
404
|
+
}
|
|
405
|
+
return new Headers(r);
|
|
406
|
+
}
|
|
407
|
+
class Y {
|
|
408
|
+
constructor(r) {
|
|
409
|
+
const n = JSON.parse(sessionStorage.getItem("session-logged-in-user"));
|
|
410
|
+
this.loggedInUser = n || (r == null ? void 0 : r.defaultLoggedInUser);
|
|
411
|
+
}
|
|
412
|
+
login(r) {
|
|
413
|
+
this.loggedInUser = r, sessionStorage.setItem("session-logged-in-user", JSON.stringify(r));
|
|
414
|
+
}
|
|
415
|
+
logout() {
|
|
416
|
+
this.loggedInUser = null, sessionStorage.removeItem("session-logged-in-user");
|
|
417
|
+
}
|
|
418
|
+
getCookieToken() {
|
|
419
|
+
return sessionStorage.getItem("session-anonymous-token");
|
|
420
|
+
}
|
|
421
|
+
setCookieToken(r) {
|
|
422
|
+
sessionStorage.setItem("session-anonymous-token", r);
|
|
423
|
+
}
|
|
424
|
+
getLoggedInUser() {
|
|
425
|
+
return this.loggedInUser;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
async function Z(e) {
|
|
429
|
+
var r, n;
|
|
430
|
+
switch (e.type) {
|
|
431
|
+
case "in-memory":
|
|
432
|
+
return new Q((r = e.schemaDescriptor) == null ? void 0 : r.tables, e.initialData, e.config);
|
|
433
|
+
default:
|
|
434
|
+
const i = new K(
|
|
435
|
+
(n = e.schemaDescriptor) == null ? void 0 : n.tables,
|
|
436
|
+
e.initialData,
|
|
437
|
+
e.config
|
|
438
|
+
);
|
|
439
|
+
return await i.initialize(), i;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
class _ {
|
|
443
|
+
// public id = crypto.randomUUID();
|
|
444
|
+
constructor(r) {
|
|
445
|
+
this.apiDef = r, this.backend = null;
|
|
446
|
+
}
|
|
447
|
+
async initialize() {
|
|
448
|
+
const r = {};
|
|
449
|
+
Object.entries(this.apiDef.operations || {}).forEach(([a, t]) => {
|
|
450
|
+
r[a] = t.handler;
|
|
451
|
+
});
|
|
452
|
+
const n = await Z(this.apiDef), i = new Y(this.apiDef.auth), s = {
|
|
453
|
+
operations: r,
|
|
454
|
+
initialize: this.apiDef.initialize,
|
|
455
|
+
helpers: this.apiDef.helpers
|
|
456
|
+
};
|
|
457
|
+
this.backend = new G(s, n, i);
|
|
458
|
+
}
|
|
459
|
+
getOperations() {
|
|
460
|
+
return this.apiDef.operations || {};
|
|
461
|
+
}
|
|
462
|
+
getApiUrl() {
|
|
463
|
+
return this.apiDef.apiUrl || "";
|
|
464
|
+
}
|
|
465
|
+
// Use the "msw" package to execute the interceptor operation
|
|
466
|
+
async executeOperation(r, n, i, s) {
|
|
467
|
+
var u;
|
|
468
|
+
if (this.backend === null)
|
|
469
|
+
throw new Error("Interceptor not initialized");
|
|
470
|
+
const a = (u = this.apiDef.operations) == null ? void 0 : u[r];
|
|
471
|
+
if (!a)
|
|
472
|
+
throw new Error(`Unknown API interceptor operation: ${r}`);
|
|
473
|
+
let t;
|
|
474
|
+
try {
|
|
475
|
+
if (a.requestShape === "formData") {
|
|
476
|
+
const o = await n.formData(), y = {};
|
|
477
|
+
for (const f of o.keys()) {
|
|
478
|
+
const d = o.getAll(f);
|
|
479
|
+
d.length === 1 ? y[f] = d[0] : y[f] = d;
|
|
480
|
+
}
|
|
481
|
+
t = y;
|
|
482
|
+
} else a.requestShape === "blob" ? t = await n.blob() : t = await n.json();
|
|
483
|
+
} catch {
|
|
484
|
+
}
|
|
485
|
+
const h = this.convertRequestParams(
|
|
486
|
+
{
|
|
487
|
+
pathParams: s,
|
|
488
|
+
queryParams: Object.fromEntries(new URL(n.url).searchParams),
|
|
489
|
+
requestBody: t,
|
|
490
|
+
cookies: i,
|
|
491
|
+
requestHeaders: Object.fromEntries(n.headers.entries()) || {}
|
|
492
|
+
},
|
|
493
|
+
a
|
|
494
|
+
);
|
|
495
|
+
this.apiDef.artificialDelay === void 0 ? await D("real") : this.apiDef.artificialDelay !== 0 && await D(this.apiDef.artificialDelay);
|
|
496
|
+
const w = new z(), c = new V();
|
|
497
|
+
try {
|
|
498
|
+
const o = await this.backend.executeOperation(
|
|
499
|
+
r,
|
|
500
|
+
h,
|
|
501
|
+
w,
|
|
502
|
+
c
|
|
503
|
+
), y = o == null, f = a.successStatusCode ?? (y ? k.NoContent : k.Ok), d = X(w.getCookieHeader(), c.getHeaders());
|
|
504
|
+
return o instanceof File ? (d.append("Content-type", o.type), d.append("Content-Length", o.size + ""), d.append(
|
|
505
|
+
"Content-Disposition",
|
|
506
|
+
`attachment; filename="${o.name}"; filename*=utf-8''${o.name}`
|
|
507
|
+
), g.arrayBuffer(await o.arrayBuffer(), {
|
|
508
|
+
headers: d,
|
|
509
|
+
status: f
|
|
510
|
+
})) : y ? new g(null, {
|
|
511
|
+
headers: d,
|
|
512
|
+
status: f
|
|
513
|
+
}) : g.json(o, {
|
|
514
|
+
headers: d,
|
|
515
|
+
status: f
|
|
516
|
+
});
|
|
517
|
+
} catch (o) {
|
|
518
|
+
return console.error(o), o instanceof x && o.errorObject instanceof m ? g.json(o.errorObject.details, {
|
|
519
|
+
headers: w.getCookieHeader(),
|
|
520
|
+
status: o.errorObject.status
|
|
521
|
+
}) : g.json(
|
|
522
|
+
{ message: o == null ? void 0 : o.message },
|
|
523
|
+
{
|
|
524
|
+
headers: w.getCookieHeader(),
|
|
525
|
+
status: k.InternalServerError
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
// Ensures that type path and query params are converted according to the operation definition
|
|
531
|
+
convertRequestParams(r, n) {
|
|
532
|
+
return {
|
|
533
|
+
...r,
|
|
534
|
+
pathParams: R(r.pathParams, n.pathParamTypes),
|
|
535
|
+
queryParams: R(r.queryParams, n.queryParamTypes)
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
hasMockForRequest(r, n) {
|
|
539
|
+
return this.getMockForRequest(r, n) !== void 0;
|
|
540
|
+
}
|
|
541
|
+
getMockForRequest(r, n) {
|
|
542
|
+
return Object.entries(this.getOperations()).find(([i, s]) => !!(E(new URL(r, window.location.href), `${this.getApiUrl()}${s.url}`, `${window.location.href}`).matches && (n.method || "get").toLowerCase() === s.method.toLowerCase()));
|
|
543
|
+
}
|
|
544
|
+
async executeMockedFetch(r, n) {
|
|
545
|
+
const i = this.getMockForRequest(r, n);
|
|
546
|
+
if (!i)
|
|
547
|
+
throw new Error(`No mock found for request: ${r} with options: ${JSON.stringify(n)}`);
|
|
548
|
+
const [s, a] = i, t = E(new URL(r, window.location.href), `${this.getApiUrl()}${a.url}`, `${window.location.href}`);
|
|
549
|
+
return this.executeOperation(s, new Request(r, n), S(), t.params);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function S() {
|
|
553
|
+
const e = document.cookie;
|
|
554
|
+
return e === "" ? {} : e.split("; ").reduce((i, s) => {
|
|
555
|
+
const [a, t] = s.split("=");
|
|
556
|
+
return i[decodeURIComponent(a)] = decodeURIComponent(t), i;
|
|
557
|
+
}, {});
|
|
558
|
+
}
|
|
559
|
+
const ne = async (e) => {
|
|
560
|
+
const r = new _(e);
|
|
561
|
+
return await r.initialize(), r;
|
|
562
|
+
};
|
|
563
|
+
export {
|
|
564
|
+
ne as initMock
|
|
565
|
+
};
|
package/dist/lib/xmlui.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { ForwardedRef } from 'react';
|
|
|
7
7
|
import { ForwardRefExoticComponent } from 'react';
|
|
8
8
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
9
9
|
import { NavigateOptions } from 'react-router-dom';
|
|
10
|
+
import { PathParams } from 'msw';
|
|
10
11
|
import { QueryClient } from '@tanstack/react-query';
|
|
11
12
|
import { ReactNode } from 'react';
|
|
12
13
|
import { RefAttributes } from 'react';
|
|
@@ -14,6 +15,7 @@ import { RefObject } from 'react';
|
|
|
14
15
|
import { Renderable } from 'react-hot-toast';
|
|
15
16
|
import { Root } from 'react-dom/client';
|
|
16
17
|
import { SetupWorker } from 'msw/browser';
|
|
18
|
+
import { StrictRequest } from 'msw';
|
|
17
19
|
import { To } from 'react-router-dom';
|
|
18
20
|
import { Toast } from 'react-hot-toast';
|
|
19
21
|
import { ToastOptions } from 'react-hot-toast';
|
|
@@ -24,6 +26,7 @@ declare interface ActionExecutionContext {
|
|
|
24
26
|
state: ContainerState;
|
|
25
27
|
getCurrentState: () => ContainerState;
|
|
26
28
|
appContext: AppContextObject;
|
|
29
|
+
apiInstance?: ApiInterceptor;
|
|
27
30
|
lookupAction: LookupAsyncFnInner;
|
|
28
31
|
navigate: any;
|
|
29
32
|
location: any;
|
|
@@ -35,6 +38,20 @@ declare type AlignmentOptions = (typeof alignmentOptionValues)[number];
|
|
|
35
38
|
|
|
36
39
|
declare const alignmentOptionValues: readonly ["start", "center", "end"];
|
|
37
40
|
|
|
41
|
+
declare class ApiInterceptor {
|
|
42
|
+
private readonly apiDef;
|
|
43
|
+
private backend;
|
|
44
|
+
constructor(apiDef: ApiInterceptorDefinition);
|
|
45
|
+
initialize(): Promise<void>;
|
|
46
|
+
getOperations(): Record<string, InterceptorOperationDef>;
|
|
47
|
+
getApiUrl(): string;
|
|
48
|
+
executeOperation(operationId: string, req: StrictRequest<any> | null, cookies: Record<string, string | Array<string>>, params: PathParams<string>): Promise<Response>;
|
|
49
|
+
private convertRequestParams;
|
|
50
|
+
hasMockForRequest(url: string, options: RequestInit): boolean;
|
|
51
|
+
private getMockForRequest;
|
|
52
|
+
executeMockedFetch(url: string, options: RequestInit): Promise<Response>;
|
|
53
|
+
}
|
|
54
|
+
|
|
38
55
|
export declare type ApiInterceptorDefinition = {
|
|
39
56
|
type?: string;
|
|
40
57
|
config?: Record<string, any>;
|
|
@@ -46,13 +63,13 @@ export declare type ApiInterceptorDefinition = {
|
|
|
46
63
|
initialize?: string;
|
|
47
64
|
operations?: Record<string, InterceptorOperationDef>;
|
|
48
65
|
auth?: AuthDefinition;
|
|
66
|
+
useWorker?: boolean;
|
|
49
67
|
};
|
|
50
68
|
|
|
51
|
-
export declare function ApiInterceptorProvider({ interceptor, children,
|
|
69
|
+
export declare function ApiInterceptorProvider({ interceptor, children, parentInterceptorContext, waitForApiInterceptor, }: {
|
|
52
70
|
interceptor?: ApiInterceptorDefinition;
|
|
53
71
|
children: ReactNode;
|
|
54
72
|
apiWorker?: SetupWorker;
|
|
55
|
-
useHashBasedRouting?: boolean;
|
|
56
73
|
parentInterceptorContext?: IApiInterceptorContext;
|
|
57
74
|
waitForApiInterceptor?: boolean;
|
|
58
75
|
}): JSX_2.Element;
|
|
@@ -744,6 +761,7 @@ declare interface IApiInterceptorContext {
|
|
|
744
761
|
initialized: boolean;
|
|
745
762
|
forceInitialize: () => void;
|
|
746
763
|
interceptorWorker: SetupWorker | null;
|
|
764
|
+
apiInstance: ApiInterceptor | null;
|
|
747
765
|
}
|
|
748
766
|
|
|
749
767
|
declare interface IAppLayoutContext {
|
package/dist/lib/xmlui.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { y as e, A as t, B as o, E as r, I as n, L as p, H as u, N as i, z as l, i as C, h as d, S as m, b as x, k as T, l as c, D as S, F as A, G as g, V as h, C as v, c as B, e as I, f as L, w as b, j as k, p as y, s as E, t as M, K as V, n as f, q as H, M as N, v as R, J as D, u as U, x as X } from "./index-
|
|
1
|
+
import { y as e, A as t, B as o, E as r, I as n, L as p, H as u, N as i, z as l, i as C, h as d, S as m, b as x, k as T, l as c, D as S, F as A, G as g, V as h, C as v, c as B, e as I, f as L, w as b, j as k, p as y, s as E, t as M, K as V, n as f, q as H, M as N, v as R, J as D, u as U, x as X } from "./index-mdlNmhj_.mjs";
|
|
2
2
|
import { X as q } from "./xmlui-serializer-jEIItW8v.mjs";
|
|
3
3
|
export {
|
|
4
4
|
e as ApiInterceptorProvider,
|