@noxickon/onyx 6.4.0 → 6.6.0
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/components/DataTable/DataTable.d.ts +7 -5
- package/dist/components/DataTable/DataTable.js +546 -367
- package/dist/components/DataTable/DataTable.styles.d.ts +21 -3
- package/dist/components/DataTable/DataTable.styles.js +13 -2
- package/dist/components/DataTable/DataTable.types.d.ts +29 -1
- package/dist/components/DataTable/index.d.ts +4 -2
- package/dist/components/DataTable/index.js +10 -8
- package/dist/connect/executors/connectExecutor.d.ts +3 -0
- package/dist/connect/executors/connectExecutor.js +21 -0
- package/dist/connect/executors/connectExecutor.types.d.ts +8 -0
- package/dist/connect/executors/errorDetails.d.ts +9 -0
- package/dist/connect/executors/errorDetails.js +21 -0
- package/dist/connect/index.d.ts +4 -0
- package/dist/connect/schemas/error_details_pb.d.ts +62 -0
- package/dist/connect/schemas/error_details_pb.js +5 -0
- package/dist/connect.js +3 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useQuery/index.d.ts +2 -0
- package/dist/hooks/useQuery/useQuery.d.ts +3 -0
- package/dist/hooks/useQuery/useQuery.js +53 -0
- package/dist/hooks/useQuery/useQuery.types.d.ts +12 -0
- package/dist/hooks.js +12 -11
- package/dist/index.js +21 -21
- package/dist/rest/executors/OxRestError.d.ts +5 -0
- package/dist/rest/executors/OxRestError.js +10 -0
- package/dist/rest/executors/restExecutor.js +91 -83
- package/dist/rest/index.d.ts +1 -0
- package/dist/rest.js +3 -2
- package/package.json +15 -1
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
import { formErrors as e } from "../../hooks/useForm/useForm.js";
|
|
2
|
+
import { OxRestError as t } from "./OxRestError.js";
|
|
2
3
|
//#region src/rest/executors/restExecutor.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
var n = (e) => typeof Blob < "u" && e instanceof Blob, r = (e) => typeof FileList < "u" && e instanceof FileList;
|
|
5
|
+
function i(e) {
|
|
6
|
+
return n(e) || r(e) ? !0 : Array.isArray(e) ? e.some((e) => i(e)) : typeof e == "object" && e ? Object.values(e).some((e) => i(e)) : !1;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
e.append(
|
|
8
|
+
function a(e, t, i) {
|
|
9
|
+
if (i !== void 0) {
|
|
10
|
+
if (i === null) {
|
|
11
|
+
e.append(t, "");
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
|
-
if (
|
|
14
|
-
e.append(
|
|
14
|
+
if (n(i)) {
|
|
15
|
+
e.append(t, i);
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
|
-
if (
|
|
18
|
-
[...
|
|
18
|
+
if (r(i)) {
|
|
19
|
+
[...i].forEach((n, r) => a(e, `${t}[${r}]`, n));
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
|
-
if (Array.isArray(
|
|
22
|
-
|
|
22
|
+
if (Array.isArray(i)) {
|
|
23
|
+
i.forEach((n, r) => a(e, `${t}[${r}]`, n));
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
if (
|
|
26
|
-
e.append(
|
|
26
|
+
if (i instanceof Date) {
|
|
27
|
+
e.append(t, i.toISOString());
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
if (typeof
|
|
30
|
-
for (let [
|
|
30
|
+
if (typeof i == "object") {
|
|
31
|
+
for (let [n, r] of Object.entries(i)) a(e, `${t}[${n}]`, r);
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
|
-
if (typeof
|
|
34
|
-
e.append(
|
|
34
|
+
if (typeof i == "boolean") {
|
|
35
|
+
e.append(t, i ? "1" : "0");
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
|
-
e.append(
|
|
38
|
+
e.append(t, String(i));
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
+
function o(e) {
|
|
41
42
|
let t = new FormData();
|
|
42
|
-
for (let [n, r] of Object.entries(e))
|
|
43
|
+
for (let [n, r] of Object.entries(e)) a(t, n, r);
|
|
43
44
|
return t;
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function s(e) {
|
|
46
47
|
let t = new URLSearchParams(), n = (e, r) => {
|
|
47
48
|
if (!(r == null || r === "")) {
|
|
48
49
|
if (Array.isArray(r)) {
|
|
@@ -60,94 +61,101 @@ function o(e) {
|
|
|
60
61
|
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
61
62
|
return t.toString();
|
|
62
63
|
}
|
|
63
|
-
var
|
|
64
|
-
function
|
|
65
|
-
let
|
|
66
|
-
if (
|
|
67
|
-
return e(
|
|
64
|
+
var c = (e, t) => e !== 422 || typeof t != "object" || !t ? null : t.errors ?? t;
|
|
65
|
+
function l(n, r, i) {
|
|
66
|
+
let a = i(n, r);
|
|
67
|
+
if (a === null) throw new t(n, r);
|
|
68
|
+
return e(a);
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
var u = (e) => e?.includes("application/json") === !0 || e?.includes("application/problem+json") === !0;
|
|
71
|
+
function d(e, t) {
|
|
72
|
+
if (t.length === 0) return null;
|
|
73
|
+
if (u(e)) return JSON.parse(t);
|
|
74
|
+
try {
|
|
75
|
+
return JSON.parse(t);
|
|
76
|
+
} catch {
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
|
-
function
|
|
73
|
-
let { onProgress: u, signal:
|
|
74
|
-
return new Promise((
|
|
75
|
-
if (
|
|
76
|
-
|
|
80
|
+
function f(e, n, r, i, a, s, c) {
|
|
81
|
+
let { onProgress: u, signal: f } = c;
|
|
82
|
+
return new Promise((c, p) => {
|
|
83
|
+
if (f.aborted) {
|
|
84
|
+
p(new DOMException("Aborted", "AbortError"));
|
|
77
85
|
return;
|
|
78
86
|
}
|
|
79
|
-
let
|
|
80
|
-
|
|
81
|
-
for (let [e, t] of Object.entries(
|
|
82
|
-
let
|
|
83
|
-
|
|
87
|
+
let m = new XMLHttpRequest();
|
|
88
|
+
m.open(e, n), m.withCredentials = a;
|
|
89
|
+
for (let [e, t] of Object.entries(i)) m.setRequestHeader(e, t);
|
|
90
|
+
let h = () => m.abort();
|
|
91
|
+
f.addEventListener("abort", h), m.upload.addEventListener("progress", (e) => {
|
|
84
92
|
let t = {
|
|
85
93
|
loaded: e.loaded,
|
|
86
94
|
total: e.lengthComputable ? e.total : void 0,
|
|
87
95
|
percentage: e.lengthComputable ? Math.round(e.loaded * 100 / e.total) : void 0
|
|
88
96
|
};
|
|
89
97
|
u?.(t);
|
|
90
|
-
}),
|
|
91
|
-
|
|
92
|
-
}),
|
|
93
|
-
|
|
94
|
-
}),
|
|
95
|
-
|
|
98
|
+
}), m.addEventListener("abort", () => {
|
|
99
|
+
f.removeEventListener("abort", h), p(new DOMException("Aborted", "AbortError"));
|
|
100
|
+
}), m.addEventListener("error", () => {
|
|
101
|
+
f.removeEventListener("abort", h), p(/* @__PURE__ */ Error("Network request failed"));
|
|
102
|
+
}), m.addEventListener("load", () => {
|
|
103
|
+
f.removeEventListener("abort", h);
|
|
96
104
|
let e;
|
|
97
105
|
try {
|
|
98
|
-
e =
|
|
106
|
+
e = d(m.getResponseHeader("Content-Type"), m.responseText);
|
|
99
107
|
} catch (e) {
|
|
100
|
-
|
|
108
|
+
p(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to parse response"));
|
|
101
109
|
return;
|
|
102
110
|
}
|
|
103
|
-
if (
|
|
111
|
+
if (m.status === 422) {
|
|
104
112
|
try {
|
|
105
|
-
|
|
113
|
+
c(l(422, e, s));
|
|
106
114
|
} catch (e) {
|
|
107
|
-
|
|
115
|
+
p(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to map validation error"));
|
|
108
116
|
}
|
|
109
117
|
return;
|
|
110
118
|
}
|
|
111
|
-
if (
|
|
112
|
-
|
|
119
|
+
if (m.status < 200 || m.status >= 300) {
|
|
120
|
+
p(new t(m.status, e));
|
|
113
121
|
return;
|
|
114
122
|
}
|
|
115
|
-
|
|
116
|
-
}),
|
|
123
|
+
c(e);
|
|
124
|
+
}), m.send(o(r));
|
|
117
125
|
});
|
|
118
126
|
}
|
|
119
|
-
function
|
|
120
|
-
let { credentials:
|
|
121
|
-
return async (
|
|
122
|
-
let { method:
|
|
123
|
-
if (!
|
|
124
|
-
let
|
|
125
|
-
if (!
|
|
126
|
-
if (
|
|
127
|
-
let e =
|
|
128
|
-
method:
|
|
129
|
-
headers:
|
|
130
|
-
credentials:
|
|
131
|
-
signal:
|
|
132
|
-
}),
|
|
133
|
-
if (
|
|
134
|
-
if (!
|
|
135
|
-
return
|
|
127
|
+
function p(e, n = {}) {
|
|
128
|
+
let { credentials: r = "same-origin", forceFormData: a = !1, headers: o, parseErrors: u } = n, p = u ?? c;
|
|
129
|
+
return async (n) => {
|
|
130
|
+
let { method: c = "post", payload: u, signal: m, url: h } = n, g = h ?? e;
|
|
131
|
+
if (!g) throw Error("restExecutor: no url provided (pass it to restExecutor or to the method)");
|
|
132
|
+
let _ = c.toUpperCase(), v = _ === "GET" || _ === "HEAD", y = typeof o == "function" ? o(u) : o ?? {};
|
|
133
|
+
if (!v && (a || i(u))) return f(_, g, u, y, r === "include", p, n);
|
|
134
|
+
if (v) {
|
|
135
|
+
let e = s(u), n = await fetch(e ? `${g}?${e}` : g, {
|
|
136
|
+
method: _,
|
|
137
|
+
headers: y,
|
|
138
|
+
credentials: r,
|
|
139
|
+
signal: m
|
|
140
|
+
}), i = d(n.headers.get("Content-Type"), await n.text());
|
|
141
|
+
if (n.status === 422) return l(422, i, p);
|
|
142
|
+
if (!n.ok) throw new t(n.status, i);
|
|
143
|
+
return i;
|
|
136
144
|
}
|
|
137
|
-
let
|
|
138
|
-
method:
|
|
145
|
+
let b = await fetch(g, {
|
|
146
|
+
method: _,
|
|
139
147
|
headers: {
|
|
140
148
|
"Content-Type": "application/json",
|
|
141
|
-
...
|
|
149
|
+
...y
|
|
142
150
|
},
|
|
143
|
-
body: JSON.stringify(
|
|
144
|
-
credentials:
|
|
145
|
-
signal:
|
|
146
|
-
}),
|
|
147
|
-
if (
|
|
148
|
-
if (!
|
|
149
|
-
return
|
|
151
|
+
body: JSON.stringify(u),
|
|
152
|
+
credentials: r,
|
|
153
|
+
signal: m
|
|
154
|
+
}), x = d(b.headers.get("Content-Type"), await b.text());
|
|
155
|
+
if (b.status === 422) return l(422, x, p);
|
|
156
|
+
if (!b.ok) throw new t(b.status, x);
|
|
157
|
+
return x;
|
|
150
158
|
};
|
|
151
159
|
}
|
|
152
160
|
//#endregion
|
|
153
|
-
export {
|
|
161
|
+
export { p as restExecutor };
|
package/dist/rest/index.d.ts
CHANGED
package/dist/rest.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { OxRestError as e } from "./rest/executors/OxRestError.js";
|
|
2
|
+
import { restExecutor as t } from "./rest/executors/restExecutor.js";
|
|
3
|
+
export { e as OxRestError, t as restExecutor };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noxickon/onyx",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"types": "./dist/rest/index.d.ts",
|
|
27
27
|
"import": "./dist/rest.js"
|
|
28
28
|
},
|
|
29
|
+
"./connect": {
|
|
30
|
+
"types": "./dist/connect/index.d.ts",
|
|
31
|
+
"import": "./dist/connect.js"
|
|
32
|
+
},
|
|
29
33
|
"./graphql": {
|
|
30
34
|
"types": "./dist/graphql/index.d.ts",
|
|
31
35
|
"import": "./dist/graphql.js"
|
|
@@ -68,6 +72,8 @@
|
|
|
68
72
|
},
|
|
69
73
|
"peerDependencies": {
|
|
70
74
|
"@apollo/client": "^4.2.3",
|
|
75
|
+
"@bufbuild/protobuf": "^2.7.0",
|
|
76
|
+
"@connectrpc/connect": "^2.0.0",
|
|
71
77
|
"@tiptap/extension-placeholder": "^3.0.0",
|
|
72
78
|
"@tiptap/pm": "^3.0.0",
|
|
73
79
|
"@tiptap/react": "^3.0.0",
|
|
@@ -83,6 +89,12 @@
|
|
|
83
89
|
"@apollo/client": {
|
|
84
90
|
"optional": true
|
|
85
91
|
},
|
|
92
|
+
"@bufbuild/protobuf": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"@connectrpc/connect": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
86
98
|
"graphql": {
|
|
87
99
|
"optional": true
|
|
88
100
|
},
|
|
@@ -119,7 +131,9 @@
|
|
|
119
131
|
},
|
|
120
132
|
"devDependencies": {
|
|
121
133
|
"@apollo/client": "^4.2.3",
|
|
134
|
+
"@bufbuild/protobuf": "^2.12.1",
|
|
122
135
|
"@chromatic-com/storybook": "^5.0.0",
|
|
136
|
+
"@connectrpc/connect": "^2.1.2",
|
|
123
137
|
"@eslint-react/eslint-plugin": "^5.9.0",
|
|
124
138
|
"@eslint/js": "^10.0.0",
|
|
125
139
|
"@noxickon/codex": "^4.0.4",
|