@wssto2/vue-core 0.4.25 → 0.4.26

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{AccessGate.vue_vue_type_script_setup_true_lang-DcbZBINh.js → AccessGate.vue_vue_type_script_setup_true_lang-J5HoyGNJ.js} +1 -1
  3. package/dist/{Activity-CI-l_OFl.js → Activity-B6R8Jghz.js} +2 -2
  4. package/dist/{Changes-BdR0R20V.js → Changes-BQG7IV49.js} +2 -2
  5. package/dist/{CollectionPage.vue_vue_type_script_setup_true_lang-BNM_cbXa.js → CollectionPage.vue_vue_type_script_setup_true_lang-BrbQ0Y5d.js} +1 -1
  6. package/dist/{DeadLetters-CRTeoZS1.js → DeadLetters-CJZSWjsn.js} +4 -4
  7. package/dist/{General-hdmVP72B.js → General-tsRC866T.js} +2 -2
  8. package/dist/{NewRolePage-BPeKasOp.js → NewRolePage-L57Zg1Mg.js} +2 -2
  9. package/dist/{ProfilePage-Dq9lcO5O.js → ProfilePage-B9WUrImn.js} +2 -2
  10. package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-B6g2760V.js → RoleEditor.vue_vue_type_script_setup_true_lang-Hr0WgL1K.js} +2 -2
  11. package/dist/{RolePage-BYH-0fVI.js → RolePage-uezn-Og1.js} +3 -3
  12. package/dist/{RolesPage-BRm5xDw7.js → RolesPage-DkMAJZR6.js} +2 -2
  13. package/dist/{SectionNavigator.vue_vue_type_script_setup_true_lang-BltrQnrQ.js → SectionNavigator.vue_vue_type_script_setup_true_lang-BYRc0-qh.js} +1 -1
  14. package/dist/{Sessions-B1eKG_I2.js → Sessions-BDu3nMmz.js} +2 -2
  15. package/dist/{SettingsPage-0P38Ty4w.js → SettingsPage-CA7YCy6K.js} +2 -2
  16. package/dist/{SignIn-Dp8Ji0_r.js → SignIn-DQzS20kM.js} +2 -2
  17. package/dist/{SignInPage-CiStJboK.js → SignInPage-ft3unWwX.js} +2 -2
  18. package/dist/{SignIns-Bo7R2Coi.js → SignIns-C3h_YIkc.js} +2 -2
  19. package/dist/{UserRecord-DGq_PPy1.js → UserRecord-BO5-wsYt.js} +5 -5
  20. package/dist/{UsersList-BulNu4aE.js → UsersList-D3b3DGN5.js} +4 -4
  21. package/dist/access/index.js +1 -1
  22. package/dist/app/index.js +5 -5
  23. package/dist/collection/index.js +3 -3
  24. package/dist/{contributions-DsfmDoRD.js → contributions-BVBZP5Jb.js} +1 -1
  25. package/dist/{guards-Dve61KjR.js → guards-BJZjc3FZ.js} +1 -1
  26. package/dist/{http-D_D9YbLH.js → http-BFfkA7gN.js} +1 -1
  27. package/dist/identity/index.js +1 -1
  28. package/dist/{index-BmowiT1y.js → index-BVU76sBO.js} +12 -12
  29. package/dist/{index-tnSTp0cM.js → index-C3CzOub7.js} +2 -2
  30. package/dist/{index-Yy28omu6.js → index-CvJSAsfk.js} +5 -5
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +1 -1
  33. package/dist/{navigation-Cm3iChlR.js → navigation-DpcDF0rX.js} +1 -1
  34. package/dist/{neighbors-DVN_cADL.js → neighbors-RVQ4O3Qv.js} +1 -1
  35. package/dist/notifications/index.js +1 -1
  36. package/dist/page/index.js +1 -1
  37. package/dist/platform/index.d.ts +25 -1
  38. package/dist/platform/index.js +59 -49
  39. package/dist/platform/platform.d.ts +9 -5
  40. package/dist/platform/session.d.ts +10 -0
  41. package/dist/platform/sessionUser.d.ts +8 -0
  42. package/dist/platform-PZpUkkMS.js +268 -0
  43. package/dist/router/index.js +3 -3
  44. package/dist/{sections-D-kD98vu.js → sections-CeZl-Jxg.js} +1 -1
  45. package/dist/shell/index.js +3 -3
  46. package/dist/{status-Bh3-Cg7o.js → status-8KH7PITT.js} +2 -2
  47. package/dist/testing/index.js +1 -1
  48. package/dist/testing/platform.d.ts +10 -7
  49. package/package.json +3 -2
  50. package/dist/platform-q3cjODLx.js +0 -255
@@ -1,255 +0,0 @@
1
- import { c as P } from "./client-k9euDWF4.js";
2
- import { d as k } from "./context-Ch1r4fdN.js";
3
- import { a as x, A as q } from "./error-CD7x0Jrz.js";
4
- import { shallowRef as U } from "vue";
5
- const _ = (e, n) => e.level === n.level && e.id === n.id, z = (e, n) => Object.prototype.hasOwnProperty.call(e, n);
6
- function C(e, n = {}) {
7
- const t = n.covers ?? _;
8
- function o(r) {
9
- const s = e();
10
- return !s || !z(s.permissions, r) || s.unavailable.includes(r) ? null : s.permissions[r] ?? null;
11
- }
12
- function a(r, s) {
13
- const i = o(r);
14
- return i ? s ? (i.clauses.length > 0 ? i.clauses.map((c) => c.scope) : [i.scope]).some((c) => t(c, s)) : !0 : !1;
15
- }
16
- return {
17
- get root() {
18
- return e()?.root ?? !1;
19
- },
20
- can: a,
21
- canAny: (r) => r.some((s) => a(s)),
22
- canAll: (r) => r.every((s) => a(s)),
23
- held: o
24
- };
25
- }
26
- const A = ["own", "own_location", "all"], m = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
27
- function $(e, n, t) {
28
- return !m(e) || typeof e.level != "string" ? (t.push(`${n}: expected { level: string, id?: number }`), { level: "" }) : (e.id !== void 0 && typeof e.id != "number" && t.push(`${n}.id: expected number`), typeof e.id == "number" ? { level: e.level, id: e.id } : { level: e.level });
29
- }
30
- function S(e, n, t) {
31
- return typeof e == "string" && A.includes(e) ? e : (t.push(`${n}: expected one of ${A.join(", ")}`), "own");
32
- }
33
- function I(e) {
34
- const n = [], t = {}, o = { root: !1, permissions: {}, unavailable: [] };
35
- if (!m(e)) return { snapshot: o, issues: ["access: expected an object"] };
36
- if (!m(e.permissions)) n.push("access.permissions: expected an object");
37
- else
38
- for (const [r, s] of Object.entries(e.permissions)) {
39
- const i = `access.permissions.${r}`;
40
- if (!m(s)) {
41
- n.push(`${i}: expected an object`);
42
- continue;
43
- }
44
- const u = (Array.isArray(s.clauses) ? s.clauses : []).map((c, y) => {
45
- const l = `${i}.clauses[${y}]`;
46
- if (!m(c))
47
- return n.push(`${l}: expected an object`), { scope: { level: "" }, qualifier: "own" };
48
- const f = { scope: $(c.scope, `${l}.scope`, n), qualifier: S(c.qualifier, `${l}.qualifier`, n) };
49
- return typeof c.role == "string" ? { ...f, role: c.role } : f;
50
- });
51
- t[r] = {
52
- scope: $(s.scope, `${i}.scope`, n),
53
- qualifier: S(s.qualifier, `${i}.qualifier`, n),
54
- clauses: u
55
- };
56
- }
57
- const a = e.unavailable ?? [];
58
- return (!Array.isArray(a) || !a.every((r) => typeof r == "string")) && n.push("access.unavailable: expected an array of strings"), {
59
- snapshot: {
60
- root: e.root === !0,
61
- permissions: t,
62
- unavailable: Array.isArray(a) ? a.filter((r) => typeof r == "string") : []
63
- },
64
- issues: n
65
- };
66
- }
67
- const T = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
68
- function j(e, n, t = "navigation") {
69
- return Array.isArray(e) ? e.flatMap((o, a) => {
70
- const r = `${t}[${a}]`;
71
- if (!T(o) || typeof o.i18n != "string")
72
- return n.push(`${r}: expected an object with an i18n key`), [];
73
- for (const i of ["icon", "route"])
74
- o[i] != null && typeof o[i] != "string" && n.push(`${r}.${i}: expected a string`);
75
- const s = o.children == null ? void 0 : j(o.children, n, `${r}.children`);
76
- return [
77
- {
78
- i18n: o.i18n,
79
- ...typeof o.icon == "string" && { icon: o.icon },
80
- ...typeof o.route == "string" && { route: o.route },
81
- ...s && { children: s }
82
- }
83
- ];
84
- }) : (n.push(`${t}: expected an array`), []);
85
- }
86
- const b = (e) => typeof e == "object" && e !== null && !Array.isArray(e), N = (e) => {
87
- if (b(e) && (typeof e.id == "number" || typeof e.id == "string")) return { id: e.id };
88
- throw new TypeError("expected an object with a numeric or string id");
89
- };
90
- function B(e, n = N) {
91
- const t = [];
92
- if (!b(e)) throw O(["expected an object"]);
93
- let o = null;
94
- try {
95
- o = n(e.user);
96
- } catch (u) {
97
- t.push(`user: ${u instanceof Error ? u.message : "invalid"}`);
98
- }
99
- let a = null;
100
- if (e.expires_at !== void 0 && e.expires_at !== null) {
101
- const u = typeof e.expires_at == "string" ? new Date(e.expires_at) : null;
102
- u === null || Number.isNaN(u.getTime()) ? t.push("expires_at: expected an ISO date-time string") : a = u;
103
- }
104
- let r;
105
- if (e.impersonator !== void 0 && e.impersonator !== null) {
106
- const u = e.impersonator;
107
- b(u) && (typeof u.id == "number" || typeof u.id == "string") && typeof u.name == "string" ? r = { id: u.id, name: u.name } : t.push("impersonator: expected { id, name }");
108
- }
109
- const s = I(e.access);
110
- t.push(...s.issues);
111
- const i = e.navigation === void 0 || e.navigation === null ? void 0 : j(e.navigation, t);
112
- if (o === null || t.length > 0) throw O(t);
113
- return { user: o, expiresAt: a, access: s.snapshot, ...r && { impersonator: r }, ...i && { navigation: i } };
114
- }
115
- const O = (e) => new q({ kind: "malformed", message: `Unreadable session payload: ${e.join("; ")}` });
116
- function F(e, n = {}) {
117
- const { mePath: t = "/auth/me", signOutPath: o = "/auth/logout", parseUser: a } = n;
118
- return {
119
- async load(r) {
120
- try {
121
- const { data: s } = await e.get(t, { signal: r, handleUnauthorized: !1 });
122
- return B(s, a);
123
- } catch (s) {
124
- if (x(s) && s.kind === "unauthorized") return null;
125
- throw s;
126
- }
127
- },
128
- async signOut() {
129
- try {
130
- await e.post(o, void 0, { handleUnauthorized: !1 });
131
- } catch (r) {
132
- if (!(x(r) && r.kind === "unauthorized")) throw r;
133
- }
134
- }
135
- };
136
- }
137
- function E(e) {
138
- return e.status === "authenticated" ? e : e.status === "anonymous" && e.reason === "expired" ? e.previous ?? null : null;
139
- }
140
- const w = 3e3;
141
- function H(e, n = {}) {
142
- const t = U({ status: "unknown" });
143
- let o = 0;
144
- const a = new Set(n.beforeSignOut ? [n.beforeSignOut] : []);
145
- let r = !1, s = null, i = null;
146
- function u() {
147
- o++, i?.controller.abort(), i = null;
148
- }
149
- async function c(l) {
150
- const f = new AbortController();
151
- let h;
152
- const g = new Promise((d) => {
153
- h = setTimeout(() => {
154
- f.abort(), n.onError?.(new Error(`A before-sign-out hook did not finish within ${w} ms; signing out without it.`)), d();
155
- }, w);
156
- }), v = Promise.all(
157
- [...a].map(async (d) => {
158
- try {
159
- await d(l, f.signal);
160
- } catch (p) {
161
- n.onError?.(p);
162
- }
163
- })
164
- ).then(() => {
165
- });
166
- await Promise.race([v, g]), clearTimeout(h);
167
- }
168
- function y() {
169
- if (i) return i.promise;
170
- const l = o, f = new AbortController(), h = t.value, g = E(h) !== null;
171
- g || (t.value = { status: "loading" });
172
- const v = async () => {
173
- try {
174
- const p = await e.load(f.signal);
175
- if (o !== l) return t.value;
176
- t.value = p ? { status: "authenticated", ...p } : { status: "anonymous", reason: "none" };
177
- } catch (p) {
178
- if (o !== l) return t.value;
179
- n.onError?.(p), t.value = g ? h : { status: "failed", error: p };
180
- } finally {
181
- o === l && (i = null);
182
- }
183
- return t.value;
184
- }, d = Promise.resolve().then(v);
185
- return i = { controller: f, promise: d }, d;
186
- }
187
- return {
188
- state: t,
189
- restore: () => t.value.status === "unknown" || t.value.status === "failed" ? y() : i?.promise ?? Promise.resolve(t.value),
190
- refresh: y,
191
- establish(l) {
192
- u(), t.value = { status: "authenticated", ...l };
193
- },
194
- expire() {
195
- if (t.value.status !== "authenticated") return;
196
- const { status: l, ...f } = t.value;
197
- u(), t.value = r && !t.value.impersonator ? { status: "anonymous", reason: "expired", previous: f } : { status: "anonymous", reason: "expired" }, n.onExpired?.();
198
- },
199
- signOut() {
200
- return s ?? (s = (async () => {
201
- try {
202
- const l = t.value;
203
- l.status === "authenticated" && a.size > 0 && await c(l.user), u(), t.value = { status: "anonymous", reason: "signedOut" }, await e.signOut();
204
- } finally {
205
- s = null;
206
- }
207
- })()), s;
208
- },
209
- holdExpired(l) {
210
- r = l;
211
- },
212
- onBeforeSignOut(l) {
213
- return a.add(l), () => void a.delete(l);
214
- }
215
- };
216
- }
217
- function M(e) {
218
- let n = null;
219
- const t = P({
220
- baseUrl: e.config.apiBase,
221
- transport: e.transport,
222
- headers: e.headers,
223
- credentials: e.credentials,
224
- requestId: e.requestId,
225
- async onUnauthorized() {
226
- return r.state.value.status !== "authenticated" ? "fail" : e.renewSession && (n ?? (n = e.renewSession(r, t).then(
227
- (i) => i,
228
- () => !1
229
- ).finally(() => {
230
- n = null;
231
- })), await n) ? "retry" : (r.expire(), "fail");
232
- }
233
- }), o = e.session ?? ((i) => F(i)), a = typeof o == "function" ? o(t) : o, r = H(a, { onError: e.onSessionError, onExpired: e.onSessionExpired, beforeSignOut: e.beforeSignOut }), s = C(
234
- () => E(r.state.value)?.access ?? null,
235
- { covers: e.covers }
236
- );
237
- return { config: e.config, http: t, session: r, access: s };
238
- }
239
- const [Q, G] = k("platform");
240
- function J(e, n) {
241
- e.provide(Q, n);
242
- }
243
- export {
244
- M as a,
245
- w as b,
246
- C as c,
247
- H as d,
248
- F as e,
249
- B as f,
250
- Q as g,
251
- E as h,
252
- J as i,
253
- j as p,
254
- G as u
255
- };