@nivaro/react 0.3.16 → 0.3.17
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/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +1 -1
- package/dist/shared/components/chat/ChatAnalyticsView.js +2 -2
- package/dist/shared/components/pipeline/PipelineEditorView.js +1672 -1568
- package/dist/shared/lib/request-gate.js +140 -127
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { noteOwnWriteFromCommand as
|
|
2
|
-
import { noteCredentialChanged as z, isIdentityRead as
|
|
3
|
-
function
|
|
1
|
+
import { noteOwnWriteFromCommand as O } from "./own-writes.js";
|
|
2
|
+
import { noteCredentialChanged as z, isIdentityRead as M, claimIdentityCall as $, signedOutError as Z, noteSignedIn as H, isSignedOutError as U, noteUnauthorized as x } from "./signed-out.js";
|
|
3
|
+
function I(t) {
|
|
4
4
|
if (!t || typeof t != "object") return "";
|
|
5
|
-
const s = Object.entries(t).filter(([, o]) => o != null).map(([o,
|
|
5
|
+
const s = Object.entries(t).filter(([, o]) => o != null).map(([o, i]) => [o, String(i)]).sort(([o], [i]) => o < i ? -1 : o > i ? 1 : 0);
|
|
6
6
|
return s.length ? new URLSearchParams(s).toString() : "";
|
|
7
7
|
}
|
|
8
8
|
function P(t) {
|
|
9
9
|
const s = (t._method ?? "GET").toUpperCase(), o = s === "GET" || t._body === void 0 ? "" : JSON.stringify(t._body);
|
|
10
|
-
return `${s} ${t._path ?? ""} ${
|
|
10
|
+
return `${s} ${t._path ?? ""} ${I(t._params)} ${o}`;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function w(t) {
|
|
13
13
|
return (t._method ?? "GET").toUpperCase() === "GET";
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
return
|
|
15
|
+
const q = /^\/(widgets-internal\/[^/]+\/render|items\/[^/]+\/[^/]+\/child-summary|items\/[^/]+\/auto-id-preview|config-conformance\/record\/.+\/check|pipelines\/instance\/[^/]+\/owners\/batch|addendums\/summary|at-risk\/evaluate|record-views\/.+\/touch)$/;
|
|
16
|
+
function B(t) {
|
|
17
|
+
return w(t) ? !0 : (t._method ?? "GET").toUpperCase() !== "POST" ? !1 : q.test((t._path ?? "").split("?")[0]);
|
|
18
18
|
}
|
|
19
19
|
function T(t) {
|
|
20
20
|
if (t == null || typeof t != "object") return t;
|
|
@@ -24,11 +24,11 @@ function T(t) {
|
|
|
24
24
|
return t;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
function
|
|
29
|
-
return t[
|
|
27
|
+
const N = Symbol("nivaro.coalesced");
|
|
28
|
+
function F(t) {
|
|
29
|
+
return t[N] === !0;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const b = 20, W = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, K = /* @__PURE__ */ new Set(["aggregate", "export", "distinct", "resolve-paths", "batch-read"]), J = /* @__PURE__ */ new Set([
|
|
32
32
|
"fields",
|
|
33
33
|
"filter",
|
|
34
34
|
"sort",
|
|
@@ -44,29 +44,29 @@ const O = 20, F = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, W = /*
|
|
|
44
44
|
function Y(t) {
|
|
45
45
|
const s = t;
|
|
46
46
|
if ((s._method ?? "GET").toUpperCase() !== "GET") return null;
|
|
47
|
-
const o =
|
|
47
|
+
const o = W.exec(s._path ?? "");
|
|
48
48
|
if (!o) return null;
|
|
49
|
-
const [,
|
|
50
|
-
if (d !== void 0 &&
|
|
51
|
-
const m = s._params ?? {},
|
|
52
|
-
for (const [r,
|
|
53
|
-
if (
|
|
54
|
-
if (!
|
|
55
|
-
|
|
49
|
+
const [, i, d] = o;
|
|
50
|
+
if (d !== void 0 && K.has(d)) return null;
|
|
51
|
+
const m = s._params ?? {}, c = {};
|
|
52
|
+
for (const [r, u] of Object.entries(m))
|
|
53
|
+
if (u !== void 0) {
|
|
54
|
+
if (!J.has(r)) return null;
|
|
55
|
+
c[r] = u;
|
|
56
56
|
}
|
|
57
|
-
return d === void 0 ? { collection:
|
|
57
|
+
return d === void 0 ? { collection: i, query: c } : { collection: i, id: d, query: c };
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function Q(t) {
|
|
60
60
|
let s = [], o;
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
61
|
+
const i = (c) => t.request(c.command).then(c.resolve, c.reject), d = async (c) => {
|
|
62
|
+
if (c.length === 1) return i(c[0]);
|
|
63
63
|
let r;
|
|
64
64
|
try {
|
|
65
|
-
const
|
|
65
|
+
const u = await t.request({
|
|
66
66
|
_method: "POST",
|
|
67
67
|
_path: "/items/batch-read",
|
|
68
68
|
_body: {
|
|
69
|
-
reads:
|
|
69
|
+
reads: c.map((n, e) => ({
|
|
70
70
|
key: String(e),
|
|
71
71
|
collection: n.read.collection,
|
|
72
72
|
...n.read.id !== void 0 ? { id: n.read.id } : {},
|
|
@@ -74,50 +74,50 @@ function J(t) {
|
|
|
74
74
|
}))
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
-
r = Array.isArray(
|
|
77
|
+
r = Array.isArray(u == null ? void 0 : u.results) ? u.results : void 0;
|
|
78
78
|
} catch {
|
|
79
79
|
r = void 0;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
c.forEach((u, n) => {
|
|
82
82
|
const e = r == null ? void 0 : r[n];
|
|
83
83
|
if ((e == null ? void 0 : e.status) !== 200 || e === void 0) {
|
|
84
|
-
u
|
|
84
|
+
i(u);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
u.resolve(u.read.id !== void 0 ? { data: e.data } : { data: e.data, ...e.meta ?? {} });
|
|
88
88
|
});
|
|
89
89
|
}, m = () => {
|
|
90
90
|
o = void 0;
|
|
91
|
-
const
|
|
91
|
+
const c = s;
|
|
92
92
|
s = [];
|
|
93
|
-
for (let r = 0; r <
|
|
94
|
-
d(
|
|
93
|
+
for (let r = 0; r < c.length; r += b)
|
|
94
|
+
d(c.slice(r, r + b));
|
|
95
95
|
};
|
|
96
|
-
return (
|
|
96
|
+
return (c, r) => new Promise((u, n) => {
|
|
97
97
|
s.push({
|
|
98
98
|
read: r,
|
|
99
|
-
command:
|
|
100
|
-
resolve:
|
|
99
|
+
command: c,
|
|
100
|
+
resolve: u,
|
|
101
101
|
reject: n
|
|
102
102
|
}), o === void 0 && (o = setTimeout(m, 0));
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
function
|
|
105
|
+
const R = 50, V = 10, X = /^\/collections\/([A-Za-z_][A-Za-z0-9_-]{0,127})$/;
|
|
106
|
+
function ee(t) {
|
|
107
107
|
const s = t;
|
|
108
|
-
if ((s._method ?? "GET").toUpperCase() !== "GET" ||
|
|
109
|
-
const o =
|
|
108
|
+
if ((s._method ?? "GET").toUpperCase() !== "GET" || I(s._params) !== "") return null;
|
|
109
|
+
const o = X.exec(s._path ?? "");
|
|
110
110
|
return o ? o[1] : null;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function te() {
|
|
113
113
|
return Object.assign(new Error("Not found"), { status: 404, response: { error: "Not found" } });
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
let s = !0, o = [],
|
|
115
|
+
function ne(t) {
|
|
116
|
+
let s = !0, o = [], i;
|
|
117
117
|
const d = (r) => t.request(r.command).then(r.resolve, r.reject), m = async (r) => {
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
for (const
|
|
118
|
+
const u = [...new Set(r.map((a) => a.name))];
|
|
119
|
+
if (u.length === 1 || !s) {
|
|
120
|
+
for (const a of r) d(a);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
let n;
|
|
@@ -125,13 +125,13 @@ function te(t) {
|
|
|
125
125
|
n = await t.request({
|
|
126
126
|
_method: "GET",
|
|
127
127
|
_path: "/collections",
|
|
128
|
-
_params: { names:
|
|
128
|
+
_params: { names: u.join(",") }
|
|
129
129
|
});
|
|
130
|
-
} catch (
|
|
131
|
-
const h =
|
|
130
|
+
} catch (a) {
|
|
131
|
+
const h = a == null ? void 0 : a.status;
|
|
132
132
|
if (h === 400 || h === 404 || h === 405) s = !1;
|
|
133
133
|
else if (h === 429 || h !== void 0 && h >= 500) {
|
|
134
|
-
for (const p of r) p.reject(
|
|
134
|
+
for (const p of r) p.reject(a);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
n = void 0;
|
|
@@ -139,152 +139,163 @@ function te(t) {
|
|
|
139
139
|
const e = n == null ? void 0 : n.data;
|
|
140
140
|
if (!e || typeof e != "object" || Array.isArray(e)) {
|
|
141
141
|
Array.isArray(e) && (s = !1);
|
|
142
|
-
for (const
|
|
142
|
+
for (const a of r) d(a);
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
const l = e, f = new Set(Array.isArray(n == null ? void 0 : n.missing) ? n.missing : []);
|
|
146
|
-
for (const
|
|
147
|
-
Object.hasOwn(l,
|
|
148
|
-
},
|
|
149
|
-
|
|
146
|
+
for (const a of r)
|
|
147
|
+
Object.hasOwn(l, a.name) ? a.resolve({ data: T(l[a.name]) }) : f.has(a.name) ? a.reject(te()) : d(a);
|
|
148
|
+
}, c = () => {
|
|
149
|
+
i = void 0;
|
|
150
150
|
const r = o;
|
|
151
151
|
o = [];
|
|
152
|
-
const
|
|
152
|
+
const u = [], n = /* @__PURE__ */ new Map();
|
|
153
153
|
for (const e of r) {
|
|
154
154
|
let l = n.get(e.name);
|
|
155
155
|
if (!l) {
|
|
156
|
-
const f =
|
|
157
|
-
l = f &&
|
|
156
|
+
const f = u[u.length - 1], a = f ? new Set(f.map((h) => h.name)).size : R;
|
|
157
|
+
l = f && a < R ? f : [], l !== f && u.push(l), n.set(e.name, l);
|
|
158
158
|
}
|
|
159
159
|
l.push(e);
|
|
160
160
|
}
|
|
161
|
-
for (const e of
|
|
161
|
+
for (const e of u) m(e);
|
|
162
162
|
};
|
|
163
|
-
return (r,
|
|
163
|
+
return (r, u) => new Promise((n, e) => {
|
|
164
164
|
o.push({
|
|
165
|
-
name:
|
|
165
|
+
name: u,
|
|
166
166
|
command: r,
|
|
167
167
|
resolve: n,
|
|
168
168
|
reject: e
|
|
169
|
-
}),
|
|
169
|
+
}), i === void 0 && (i = setTimeout(c, V));
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
function
|
|
172
|
+
const k = 3e3, se = /^\/(collections\/[A-Za-z_][A-Za-z0-9_-]*|field-config\/[A-Za-z_][A-Za-z0-9_-]*|collection-layouts(\/active|\/summary\/[A-Za-z_][A-Za-z0-9_-]*)?|chat\/room-types|users\/me)$/, oe = /^\/(record-views|item-locks|drafts|presence|rum|comments|notifications|tasks|field-rules\/evaluate|chat\/(?!room-types)|field-config\/[^/]+\/(evaluate-visibility|evaluate-defaults|evaluate-lock|cascade|project)$|items\/(?!nivaro_|directus_)[^/]+|users\/cards$|files\/verify$)/;
|
|
173
|
+
function re(t) {
|
|
174
174
|
const s = (t._path ?? "").split("?")[0];
|
|
175
|
-
return (t._method ?? "GET").toUpperCase() === "POST" &&
|
|
175
|
+
return (t._method ?? "GET").toUpperCase() === "POST" && q.test(s) ? !0 : oe.test(s);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function ae(t) {
|
|
178
178
|
const s = t;
|
|
179
|
-
if (!
|
|
179
|
+
if (!w(s) || !se.test(s._path ?? "")) return !1;
|
|
180
180
|
const o = s._params;
|
|
181
181
|
return !(o && o.item != null && /^\/collection-layouts\/active$/.test(s._path ?? ""));
|
|
182
182
|
}
|
|
183
183
|
let y = 0;
|
|
184
|
-
function
|
|
184
|
+
function D() {
|
|
185
185
|
y++;
|
|
186
186
|
}
|
|
187
|
+
let A = 0;
|
|
188
|
+
const ie = 50, ce = /^\/items\//;
|
|
189
|
+
function ue(t, s, o, i) {
|
|
190
|
+
if (s.epoch !== i) return !1;
|
|
191
|
+
const d = t._path ?? "";
|
|
192
|
+
return !ce.test(d) || o - s.at < ie;
|
|
193
|
+
}
|
|
187
194
|
function G(t, s) {
|
|
188
195
|
return t.then(
|
|
189
|
-
(o) => (s &&
|
|
196
|
+
(o) => (s && H(), o),
|
|
190
197
|
(o) => {
|
|
191
198
|
throw U(o, s) && x(s), o;
|
|
192
199
|
}
|
|
193
200
|
);
|
|
194
201
|
}
|
|
195
|
-
function
|
|
196
|
-
if (
|
|
197
|
-
const o = /* @__PURE__ */ new Map(),
|
|
198
|
-
let
|
|
202
|
+
function me(t, s = {}) {
|
|
203
|
+
if (F(t)) return t;
|
|
204
|
+
const o = /* @__PURE__ */ new Map(), i = s.batchReads ? Q(t) : null, d = s.batchCollections === !1 ? null : ne(t), m = /* @__PURE__ */ new Map();
|
|
205
|
+
let c = y;
|
|
199
206
|
const r = (n, e, l) => {
|
|
200
207
|
if (e !== y) return;
|
|
201
|
-
|
|
208
|
+
c !== y && (m.clear(), c = y);
|
|
202
209
|
const f = Date.now();
|
|
203
|
-
for (const [
|
|
210
|
+
for (const [a, h] of m) f - h.at >= k && m.delete(a);
|
|
204
211
|
m.set(n, { at: f, epoch: e, value: l });
|
|
205
|
-
},
|
|
212
|
+
}, u = (n) => {
|
|
206
213
|
const e = n;
|
|
207
|
-
if (!
|
|
208
|
-
|
|
209
|
-
const _ = !
|
|
210
|
-
_ &&
|
|
211
|
-
const
|
|
212
|
-
|
|
214
|
+
if (!w(e)) {
|
|
215
|
+
O(e._method, e._path, e._body);
|
|
216
|
+
const _ = !re(e);
|
|
217
|
+
_ && D(), A++;
|
|
218
|
+
const S = G(t.request(n), !1).finally(() => {
|
|
219
|
+
A++;
|
|
220
|
+
});
|
|
221
|
+
return (_ ? S.finally(D) : S).then((C) => (O(e._method, e._path, e._body, C), C));
|
|
213
222
|
}
|
|
214
|
-
const l = P(e), f =
|
|
223
|
+
const l = P(e), f = ae(e);
|
|
215
224
|
if (f) {
|
|
216
225
|
const _ = m.get(l);
|
|
217
|
-
if (_ && _.epoch === y && Date.now() - _.at <
|
|
226
|
+
if (_ && _.epoch === y && Date.now() - _.at < k)
|
|
218
227
|
return Promise.resolve(T(_.value));
|
|
219
228
|
}
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
229
|
+
const a = o.get(l);
|
|
230
|
+
if (a && ue(e, a, Date.now(), A))
|
|
231
|
+
return a.p.then(T);
|
|
232
|
+
const h = M(e._method, e._path, e._params);
|
|
233
|
+
if (h && !$()) return Promise.reject(Z());
|
|
234
|
+
const p = i ? Y(e) : null, E = !p && d ? ee(e) : null, j = G(
|
|
235
|
+
p && i ? i(n, p) : E && d ? d(n, E) : t.request(n),
|
|
226
236
|
h
|
|
227
|
-
),
|
|
228
|
-
|
|
237
|
+
), L = y, g = j.then((_) => (f && r(l, L, T(_)), _)).finally(() => {
|
|
238
|
+
var _;
|
|
239
|
+
((_ = o.get(l)) == null ? void 0 : _.p) === g && o.delete(l);
|
|
229
240
|
});
|
|
230
|
-
return o.set(l, g), g;
|
|
241
|
+
return o.set(l, { p: g, at: Date.now(), epoch: A }), g;
|
|
231
242
|
};
|
|
232
243
|
return new Proxy(t, {
|
|
233
244
|
get(n, e, l) {
|
|
234
|
-
if (e === "request") return
|
|
235
|
-
if (e ===
|
|
245
|
+
if (e === "request") return u;
|
|
246
|
+
if (e === N) return !0;
|
|
236
247
|
if (e === "setToken" && typeof n.setToken == "function")
|
|
237
|
-
return (
|
|
238
|
-
n.setToken(
|
|
248
|
+
return (a) => {
|
|
249
|
+
n.setToken(a), z();
|
|
239
250
|
};
|
|
240
251
|
const f = Reflect.get(n, e, l);
|
|
241
252
|
return typeof f == "function" ? f.bind(n) : f;
|
|
242
253
|
}
|
|
243
254
|
});
|
|
244
255
|
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
256
|
+
const le = /^\/(item-locks|drafts|auth)\b/, v = /* @__PURE__ */ new Set();
|
|
257
|
+
function fe() {
|
|
247
258
|
for (const t of [...v]) t();
|
|
248
259
|
}
|
|
249
|
-
function
|
|
260
|
+
function _e(t) {
|
|
250
261
|
return t.subscribe((s) => {
|
|
251
|
-
s.type === "observerAdded" && s.query.state.fetchStatus === "fetching" && v.size !== 0 &&
|
|
262
|
+
s.type === "observerAdded" && s.query.state.fetchStatus === "fetching" && v.size !== 0 && fe();
|
|
252
263
|
});
|
|
253
264
|
}
|
|
254
|
-
function
|
|
255
|
-
let o = s.open ?? !0,
|
|
265
|
+
function pe(t, s = {}) {
|
|
266
|
+
let o = s.open ?? !0, i;
|
|
256
267
|
const d = /* @__PURE__ */ new Map(), m = () => {
|
|
257
268
|
const n = [...d.values()];
|
|
258
269
|
d.clear();
|
|
259
270
|
for (const e of n) e.release();
|
|
260
|
-
},
|
|
261
|
-
v.delete(
|
|
271
|
+
}, c = () => {
|
|
272
|
+
v.delete(c), m();
|
|
262
273
|
}, r = (n) => {
|
|
263
274
|
const e = n;
|
|
264
|
-
if (o || !
|
|
275
|
+
if (o || !B(e) || le.test(e._path ?? "")) return t.request(n);
|
|
265
276
|
const l = P(e), f = d.get(l);
|
|
266
277
|
if (f) return f.promise.then(T);
|
|
267
|
-
let
|
|
278
|
+
let a = () => {
|
|
268
279
|
};
|
|
269
280
|
const p = new Promise((E) => {
|
|
270
|
-
|
|
281
|
+
a = E;
|
|
271
282
|
}).then(() => t.request(n));
|
|
272
|
-
return d.set(l, { promise: p, release:
|
|
283
|
+
return d.set(l, { promise: p, release: a }), v.add(c), p;
|
|
273
284
|
};
|
|
274
285
|
return new Proxy(t, {
|
|
275
286
|
get(n, e, l) {
|
|
276
287
|
if (e === "request") return r;
|
|
277
288
|
if (e === "open") return o;
|
|
278
289
|
if (e === "setOpen")
|
|
279
|
-
return (
|
|
280
|
-
|
|
290
|
+
return (a) => {
|
|
291
|
+
i !== void 0 && (clearTimeout(i), i = void 0);
|
|
281
292
|
const h = o;
|
|
282
|
-
o =
|
|
293
|
+
o = a, a && !h && (v.delete(c), m());
|
|
283
294
|
};
|
|
284
295
|
if (e === "dispose")
|
|
285
296
|
return () => {
|
|
286
|
-
|
|
287
|
-
|
|
297
|
+
i === void 0 && (i = setTimeout(() => {
|
|
298
|
+
i = void 0, o = !0, v.delete(c), m();
|
|
288
299
|
}, 0));
|
|
289
300
|
};
|
|
290
301
|
const f = Reflect.get(n, e, l);
|
|
@@ -293,17 +304,19 @@ function de(t, s = {}) {
|
|
|
293
304
|
});
|
|
294
305
|
}
|
|
295
306
|
export {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
307
|
+
b as BATCH_READ_LIMIT,
|
|
308
|
+
R as COLLECTION_BATCH_LIMIT,
|
|
309
|
+
V as COLLECTION_BATCH_WINDOW_MS,
|
|
310
|
+
ie as RECORD_JOIN_MS,
|
|
311
|
+
k as SETTLED_READ_MS,
|
|
312
|
+
ee as batchableCollectionMeta,
|
|
301
313
|
Y as batchableRead,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
fe as
|
|
308
|
-
|
|
314
|
+
pe as createGatedClient,
|
|
315
|
+
D as forgetSettledReads,
|
|
316
|
+
F as isCoalesced,
|
|
317
|
+
ae as isSettledRead,
|
|
318
|
+
ue as mayJoinInflight,
|
|
319
|
+
fe as releaseGatedReads,
|
|
320
|
+
_e as releaseGatedReadsOnSharedFetch,
|
|
321
|
+
me as withGetCoalescing
|
|
309
322
|
};
|