@nivaro/react 0.3.62 → 0.3.63
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +66 -0
- package/dist/index.js +239 -235
- package/dist/shared/components/CollectionBrowserView.js +368 -364
- package/dist/shared/components/QualityRulesView.js +212 -138
- package/dist/shared/components/alerts/AlertManagerView.js +341 -335
- package/dist/shared/components/help-videos/library/LearningPathsPanel.js +102 -98
- package/dist/shared/components/help-videos/library/PurgeVideoDialog.js +8 -8
- package/dist/shared/components/imports/CollectionImportPanel.js +273 -247
- package/dist/shared/components/pipeline/PipelineEditorView.js +636 -632
- package/dist/shared/components/pipeline/PipelineStateOwners.js +88 -87
- package/dist/shared/lib/batch-gets.js +68 -0
- package/dist/shared/lib/request-gate.js +284 -230
- package/package.json +1 -1
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { NivaroError as H, errorBodyMessage as Z } from "@nivaro/sdk";
|
|
2
|
+
import { sharedGetLoader as x, createGetBatcher as F, isBatchableGetPath as W } from "./batch-gets.js";
|
|
3
|
+
import { isRehearsalCommand as J, noteOwnWriteFromCommand as N } from "./own-writes.js";
|
|
4
|
+
import { noteCredentialChanged as K, isIdentityRead as Y, claimIdentityCall as Q, signedOutError as V, noteSignedIn as X, isSignedOutError as ee, noteUnauthorized as te } from "./signed-out.js";
|
|
5
|
+
function M(e) {
|
|
6
|
+
if (!e || typeof e != "object") return "";
|
|
7
|
+
const t = Object.entries(e).filter(([, n]) => n != null).map(([n, c]) => [n, String(c)]).sort(([n], [c]) => n < c ? -1 : n > c ? 1 : 0);
|
|
8
|
+
return t.length ? new URLSearchParams(t).toString() : "";
|
|
7
9
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
return `${
|
|
10
|
+
function $(e) {
|
|
11
|
+
const t = (e._method ?? "GET").toUpperCase(), n = t === "GET" || e._body === void 0 ? "" : JSON.stringify(e._body);
|
|
12
|
+
return `${t} ${e._path ?? ""} ${M(e._params)} ${n}`;
|
|
11
13
|
}
|
|
12
|
-
function
|
|
13
|
-
return (
|
|
14
|
+
function S(e) {
|
|
15
|
+
return (e._method ?? "GET").toUpperCase() === "GET";
|
|
14
16
|
}
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
return
|
|
17
|
+
const O = /^\/(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)$/;
|
|
18
|
+
function ne(e) {
|
|
19
|
+
return S(e) ? !0 : (e._method ?? "GET").toUpperCase() !== "POST" ? !1 : O.test((e._path ?? "").split("?")[0]);
|
|
18
20
|
}
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
+
function T(e) {
|
|
22
|
+
if (e == null || typeof e != "object") return e;
|
|
21
23
|
try {
|
|
22
|
-
return structuredClone(
|
|
24
|
+
return structuredClone(e);
|
|
23
25
|
} catch {
|
|
24
|
-
return
|
|
26
|
+
return e;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
|
-
const
|
|
28
|
-
function
|
|
29
|
-
return
|
|
29
|
+
const L = Symbol("nivaro.coalesced");
|
|
30
|
+
function re(e) {
|
|
31
|
+
return e[L] === !0;
|
|
30
32
|
}
|
|
31
|
-
const k = 20,
|
|
33
|
+
const k = 20, se = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, oe = /* @__PURE__ */ new Set([
|
|
32
34
|
"aggregate",
|
|
33
35
|
"export",
|
|
34
36
|
"distinct",
|
|
35
37
|
"resolve-paths",
|
|
36
38
|
"batch-read",
|
|
37
39
|
"filter-check"
|
|
38
|
-
]),
|
|
40
|
+
]), ae = /* @__PURE__ */ new Set([
|
|
39
41
|
"fields",
|
|
40
42
|
"filter",
|
|
41
43
|
"sort",
|
|
@@ -48,293 +50,345 @@ const k = 20, Y = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, Q = /*
|
|
|
48
50
|
"conditions",
|
|
49
51
|
"labels"
|
|
50
52
|
]);
|
|
51
|
-
function
|
|
52
|
-
const
|
|
53
|
-
if ((
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
const [, c, d] =
|
|
57
|
-
if (d !== void 0 &&
|
|
58
|
-
const m =
|
|
59
|
-
for (const [
|
|
60
|
-
if (
|
|
61
|
-
if (!
|
|
62
|
-
u[
|
|
53
|
+
function ie(e) {
|
|
54
|
+
const t = e;
|
|
55
|
+
if ((t._method ?? "GET").toUpperCase() !== "GET") return null;
|
|
56
|
+
const n = se.exec(t._path ?? "");
|
|
57
|
+
if (!n) return null;
|
|
58
|
+
const [, c, d] = n;
|
|
59
|
+
if (d !== void 0 && oe.has(d)) return null;
|
|
60
|
+
const m = t._params ?? {}, u = {};
|
|
61
|
+
for (const [a, l] of Object.entries(m))
|
|
62
|
+
if (l !== void 0) {
|
|
63
|
+
if (!ae.has(a)) return null;
|
|
64
|
+
u[a] = l;
|
|
63
65
|
}
|
|
64
66
|
return d === void 0 ? { collection: c, query: u } : { collection: c, id: d, query: u };
|
|
65
67
|
}
|
|
66
|
-
function
|
|
67
|
-
let
|
|
68
|
-
const c = (u) =>
|
|
68
|
+
function ce(e) {
|
|
69
|
+
let t = [], n;
|
|
70
|
+
const c = (u) => e.request(u.command).then(u.resolve, u.reject), d = async (u) => {
|
|
69
71
|
if (u.length === 1) return c(u[0]);
|
|
70
|
-
let
|
|
72
|
+
let a;
|
|
71
73
|
try {
|
|
72
|
-
const
|
|
74
|
+
const l = await e.request({
|
|
73
75
|
_method: "POST",
|
|
74
76
|
_path: "/items/batch-read",
|
|
75
77
|
_body: {
|
|
76
|
-
reads: u.map((
|
|
77
|
-
key: String(
|
|
78
|
-
collection:
|
|
79
|
-
...
|
|
80
|
-
query:
|
|
78
|
+
reads: u.map((i, r) => ({
|
|
79
|
+
key: String(r),
|
|
80
|
+
collection: i.read.collection,
|
|
81
|
+
...i.read.id !== void 0 ? { id: i.read.id } : {},
|
|
82
|
+
query: i.read.query
|
|
81
83
|
}))
|
|
82
84
|
}
|
|
83
85
|
});
|
|
84
|
-
|
|
86
|
+
a = Array.isArray(l == null ? void 0 : l.results) ? l.results : void 0;
|
|
85
87
|
} catch {
|
|
86
|
-
|
|
88
|
+
a = void 0;
|
|
87
89
|
}
|
|
88
|
-
u.forEach((
|
|
89
|
-
const
|
|
90
|
-
if ((
|
|
91
|
-
|
|
90
|
+
u.forEach((l, i) => {
|
|
91
|
+
const r = a == null ? void 0 : a[i];
|
|
92
|
+
if ((r == null ? void 0 : r.status) === 404 && l.read.id !== void 0) {
|
|
93
|
+
l.reject(z());
|
|
92
94
|
return;
|
|
93
95
|
}
|
|
94
|
-
if ((
|
|
95
|
-
c(
|
|
96
|
+
if ((r == null ? void 0 : r.status) !== 200 || r === void 0) {
|
|
97
|
+
c(l);
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
|
-
|
|
100
|
+
l.resolve(l.read.id !== void 0 ? { data: r.data } : { data: r.data, ...r.meta ?? {} });
|
|
99
101
|
});
|
|
100
102
|
}, m = () => {
|
|
101
|
-
|
|
102
|
-
const u =
|
|
103
|
-
|
|
104
|
-
for (let
|
|
105
|
-
d(u.slice(
|
|
103
|
+
n = void 0;
|
|
104
|
+
const u = t;
|
|
105
|
+
t = [];
|
|
106
|
+
for (let a = 0; a < u.length; a += k)
|
|
107
|
+
d(u.slice(a, a + k));
|
|
106
108
|
};
|
|
107
|
-
return (u,
|
|
108
|
-
|
|
109
|
-
read:
|
|
109
|
+
return (u, a) => new Promise((l, i) => {
|
|
110
|
+
t.push({
|
|
111
|
+
read: a,
|
|
110
112
|
command: u,
|
|
111
|
-
resolve:
|
|
112
|
-
reject:
|
|
113
|
-
}),
|
|
113
|
+
resolve: l,
|
|
114
|
+
reject: i
|
|
115
|
+
}), n === void 0 && (n = setTimeout(m, 0));
|
|
114
116
|
});
|
|
115
117
|
}
|
|
116
|
-
const
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
if ((
|
|
120
|
-
const
|
|
121
|
-
return
|
|
118
|
+
const D = 50, ue = 10, le = /^\/collections\/([A-Za-z_][A-Za-z0-9_-]{0,127})$/;
|
|
119
|
+
function fe(e) {
|
|
120
|
+
const t = e;
|
|
121
|
+
if ((t._method ?? "GET").toUpperCase() !== "GET" || M(t._params) !== "") return null;
|
|
122
|
+
const n = le.exec(t._path ?? "");
|
|
123
|
+
return n ? n[1] : null;
|
|
122
124
|
}
|
|
123
|
-
function
|
|
125
|
+
function z() {
|
|
124
126
|
return Object.assign(new Error("Not found"), { status: 404, response: { error: "Not found" } });
|
|
125
127
|
}
|
|
126
|
-
function
|
|
127
|
-
let
|
|
128
|
-
const d = (
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
for (const
|
|
128
|
+
function de(e) {
|
|
129
|
+
let t = !0, n = [], c;
|
|
130
|
+
const d = (a) => e.request(a.command).then(a.resolve, a.reject), m = async (a) => {
|
|
131
|
+
const l = [...new Set(a.map((o) => o.name))];
|
|
132
|
+
if (l.length === 1 || !t) {
|
|
133
|
+
for (const o of a) d(o);
|
|
132
134
|
return;
|
|
133
135
|
}
|
|
134
|
-
let
|
|
136
|
+
let i;
|
|
135
137
|
try {
|
|
136
|
-
|
|
138
|
+
i = await e.request({
|
|
137
139
|
_method: "GET",
|
|
138
140
|
_path: "/collections",
|
|
139
|
-
_params: { names:
|
|
141
|
+
_params: { names: l.join(",") }
|
|
140
142
|
});
|
|
141
|
-
} catch (
|
|
142
|
-
const h =
|
|
143
|
-
if (h === 400 || h === 404 || h === 405)
|
|
143
|
+
} catch (o) {
|
|
144
|
+
const h = o == null ? void 0 : o.status;
|
|
145
|
+
if (h === 400 || h === 404 || h === 405) t = !1;
|
|
144
146
|
else if (h === 429 || h !== void 0 && h >= 500) {
|
|
145
|
-
for (const
|
|
147
|
+
for (const p of a) p.reject(o);
|
|
146
148
|
return;
|
|
147
149
|
}
|
|
148
|
-
|
|
150
|
+
i = void 0;
|
|
149
151
|
}
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
Array.isArray(
|
|
153
|
-
for (const
|
|
152
|
+
const r = i == null ? void 0 : i.data;
|
|
153
|
+
if (!r || typeof r != "object" || Array.isArray(r)) {
|
|
154
|
+
Array.isArray(r) && (t = !1);
|
|
155
|
+
for (const o of a) d(o);
|
|
154
156
|
return;
|
|
155
157
|
}
|
|
156
|
-
const
|
|
157
|
-
for (const
|
|
158
|
-
Object.hasOwn(
|
|
158
|
+
const s = r, f = new Set(Array.isArray(i == null ? void 0 : i.missing) ? i.missing : []);
|
|
159
|
+
for (const o of a)
|
|
160
|
+
Object.hasOwn(s, o.name) ? o.resolve({ data: T(s[o.name]) }) : f.has(o.name) ? o.reject(z()) : d(o);
|
|
159
161
|
}, u = () => {
|
|
160
162
|
c = void 0;
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
for (const
|
|
165
|
-
let
|
|
166
|
-
if (!
|
|
167
|
-
const f =
|
|
168
|
-
|
|
163
|
+
const a = n;
|
|
164
|
+
n = [];
|
|
165
|
+
const l = [], i = /* @__PURE__ */ new Map();
|
|
166
|
+
for (const r of a) {
|
|
167
|
+
let s = i.get(r.name);
|
|
168
|
+
if (!s) {
|
|
169
|
+
const f = l[l.length - 1], o = f ? new Set(f.map((h) => h.name)).size : D;
|
|
170
|
+
s = f && o < D ? f : [], s !== f && l.push(s), i.set(r.name, s);
|
|
169
171
|
}
|
|
170
|
-
|
|
172
|
+
s.push(r);
|
|
171
173
|
}
|
|
172
|
-
for (const
|
|
174
|
+
for (const r of l) m(r);
|
|
173
175
|
};
|
|
174
|
-
return (
|
|
175
|
-
|
|
176
|
-
name:
|
|
177
|
-
command:
|
|
178
|
-
resolve:
|
|
179
|
-
reject:
|
|
180
|
-
}), c === void 0 && (c = setTimeout(u,
|
|
176
|
+
return (a, l) => new Promise((i, r) => {
|
|
177
|
+
n.push({
|
|
178
|
+
name: l,
|
|
179
|
+
command: a,
|
|
180
|
+
resolve: i,
|
|
181
|
+
reject: r
|
|
182
|
+
}), c === void 0 && (c = setTimeout(u, ue));
|
|
181
183
|
});
|
|
182
184
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
function he(e) {
|
|
186
|
+
return !e || typeof e != "object" ? "" : "?" + new URLSearchParams(
|
|
187
|
+
Object.fromEntries(
|
|
188
|
+
Object.entries(e).filter(([, t]) => t != null).map(([t, n]) => [t, String(n)])
|
|
189
|
+
)
|
|
190
|
+
).toString();
|
|
191
|
+
}
|
|
192
|
+
function me(e) {
|
|
193
|
+
const t = e;
|
|
194
|
+
if ((t._method ?? "GET").toUpperCase() !== "GET" || t._headers && Object.keys(t._headers).length > 0) return null;
|
|
195
|
+
const n = t._path ?? "";
|
|
196
|
+
return W(n) ? n + he(t._params) : null;
|
|
197
|
+
}
|
|
198
|
+
function _e(e) {
|
|
199
|
+
if (!e) return null;
|
|
200
|
+
const t = Number(e);
|
|
201
|
+
if (Number.isFinite(t) && t >= 0) return Math.round(t * 1e3);
|
|
202
|
+
const n = Date.parse(e);
|
|
203
|
+
return Number.isFinite(n) ? Math.max(0, n - Date.now()) : null;
|
|
204
|
+
}
|
|
205
|
+
function pe(e, t) {
|
|
206
|
+
const n = t.body, c = n ?? {};
|
|
207
|
+
return new H({
|
|
208
|
+
message: Z(n) || `HTTP ${t.status}`,
|
|
209
|
+
status: t.status,
|
|
210
|
+
code: typeof c.code == "string" ? c.code : null,
|
|
211
|
+
requestId: t.request_id ?? null,
|
|
212
|
+
response: n,
|
|
213
|
+
method: "GET",
|
|
214
|
+
path: e._path,
|
|
215
|
+
retryAfterMs: _e(t.retry_after),
|
|
216
|
+
issues: c.issues
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function ye(e) {
|
|
220
|
+
const t = F({
|
|
221
|
+
post: (n) => e.request({ _method: "POST", _path: "/batch-get", _body: { reads: n } })
|
|
222
|
+
});
|
|
223
|
+
return (n, c) => (x() ?? t)(c, {
|
|
224
|
+
alone: () => e.request(n),
|
|
225
|
+
error: (d) => pe(n, d)
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
const j = 3e3, ge = /^\/(settings|roles|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)$/, Ee = /^\/(record-views|item-locks|drafts|presence|rum|analytics|session-recordings|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$|batch-get$)/;
|
|
229
|
+
function Te(e) {
|
|
230
|
+
const t = (e._path ?? "").split("?")[0];
|
|
231
|
+
return (e._method ?? "GET").toUpperCase() === "POST" && O.test(t) ? !0 : Ee.test(t);
|
|
232
|
+
}
|
|
233
|
+
function be(e) {
|
|
234
|
+
const t = e;
|
|
235
|
+
if (!S(t) || !ge.test(t._path ?? "")) return !1;
|
|
236
|
+
const n = t._params;
|
|
237
|
+
return !(n && n.item != null && /^\/collection-layouts\/active$/.test(t._path ?? ""));
|
|
187
238
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const o = s._params;
|
|
192
|
-
return !(o && o.item != null && /^\/collection-layouts\/active$/.test(s._path ?? ""));
|
|
239
|
+
let y = 0;
|
|
240
|
+
function I() {
|
|
241
|
+
y++;
|
|
193
242
|
}
|
|
194
|
-
let
|
|
195
|
-
|
|
196
|
-
|
|
243
|
+
let b = 0;
|
|
244
|
+
const ve = /^\/(presence|rum|analytics|session-recordings)(\/|$)|^\/(items\/batch-read|batch-get|users\/cards|activity\/labels)$/;
|
|
245
|
+
function Ae(e) {
|
|
246
|
+
const t = e, n = (t._path ?? "").split("?")[0];
|
|
247
|
+
return ve.test(n) ? !1 : !((t._method ?? "GET").toUpperCase() === "POST" && O.test(n) && !/\/touch$/.test(n));
|
|
197
248
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return t.config === s;
|
|
249
|
+
const we = 50, Se = /^\/items\//;
|
|
250
|
+
function Oe(e, t) {
|
|
251
|
+
return e.config === t;
|
|
202
252
|
}
|
|
203
|
-
function
|
|
204
|
-
if (
|
|
205
|
-
const d =
|
|
206
|
-
return !
|
|
253
|
+
function Ce(e, t, n, c) {
|
|
254
|
+
if (t.epoch !== c) return !1;
|
|
255
|
+
const d = e._path ?? "";
|
|
256
|
+
return !Se.test(d) || n - t.at < we;
|
|
207
257
|
}
|
|
208
|
-
function w(
|
|
209
|
-
return
|
|
210
|
-
(
|
|
211
|
-
(
|
|
212
|
-
throw
|
|
258
|
+
function w(e, t) {
|
|
259
|
+
return e.then(
|
|
260
|
+
(n) => (t && X(), n),
|
|
261
|
+
(n) => {
|
|
262
|
+
throw ee(n, t) && te(t), n;
|
|
213
263
|
}
|
|
214
264
|
);
|
|
215
265
|
}
|
|
216
|
-
function
|
|
217
|
-
if (
|
|
218
|
-
const
|
|
219
|
-
let
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
for (const [
|
|
225
|
-
|
|
226
|
-
},
|
|
227
|
-
const
|
|
228
|
-
if (!
|
|
229
|
-
const _ =
|
|
230
|
-
_ ||
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
266
|
+
function De(e, t = {}) {
|
|
267
|
+
if (re(e)) return e;
|
|
268
|
+
const n = /* @__PURE__ */ new Map(), c = t.batchReads ? ce(e) : null, d = t.batchCollections === !1 ? null : de(e), m = t.batchGets ?? t.batchReads ? ye(e) : null, u = /* @__PURE__ */ new Map();
|
|
269
|
+
let a = y;
|
|
270
|
+
const l = (r, s, f) => {
|
|
271
|
+
if (s !== y) return;
|
|
272
|
+
a !== y && (u.clear(), a = y);
|
|
273
|
+
const o = Date.now();
|
|
274
|
+
for (const [h, p] of u) o - p.at >= j && u.delete(h);
|
|
275
|
+
u.set(r, { at: o, epoch: s, value: f });
|
|
276
|
+
}, i = (r) => {
|
|
277
|
+
const s = r;
|
|
278
|
+
if (!S(s)) {
|
|
279
|
+
const _ = J(s._path, s._params);
|
|
280
|
+
_ || N(s._method, s._path, s._body);
|
|
281
|
+
const R = !Te(s);
|
|
282
|
+
R && I();
|
|
283
|
+
const G = Ae(s);
|
|
284
|
+
G && b++;
|
|
285
|
+
const P = w(e.request(r), !1).finally(() => {
|
|
286
|
+
G && b++;
|
|
235
287
|
});
|
|
236
|
-
return (
|
|
288
|
+
return (R ? P.finally(I) : P).then((q) => (_ || N(s._method, s._path, s._body, q), q));
|
|
237
289
|
}
|
|
238
|
-
if (
|
|
239
|
-
return w(
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
const _ =
|
|
243
|
-
if (_ && _.epoch ===
|
|
244
|
-
return Promise.resolve(
|
|
290
|
+
if (r._signal)
|
|
291
|
+
return w(e.request(r), !1);
|
|
292
|
+
const f = $(s), o = be(s);
|
|
293
|
+
if (o) {
|
|
294
|
+
const _ = u.get(f);
|
|
295
|
+
if (_ && _.epoch === y && Date.now() - _.at < j)
|
|
296
|
+
return Promise.resolve(T(_.value));
|
|
245
297
|
}
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
return
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
),
|
|
298
|
+
const h = n.get(f);
|
|
299
|
+
if (h && (o ? Oe(h, y) : Ce(s, h, Date.now(), b)))
|
|
300
|
+
return h.p.then(T);
|
|
301
|
+
const p = Y(s._method, s._path, s._params);
|
|
302
|
+
if (p && !Q()) return Promise.reject(V());
|
|
303
|
+
const g = c ? ie(s) : null, v = !g && d ? fe(s) : null, C = !g && !v && m && !p ? me(s) : null, B = w(
|
|
304
|
+
g && c ? c(r, g) : v && d ? d(r, v) : C && m ? m(r, C) : e.request(r),
|
|
305
|
+
p
|
|
306
|
+
), U = y, A = B.then((_) => (o && l(f, U, T(_)), _)).finally(() => {
|
|
255
307
|
var _;
|
|
256
|
-
((_ =
|
|
308
|
+
((_ = n.get(f)) == null ? void 0 : _.p) === A && n.delete(f);
|
|
257
309
|
});
|
|
258
|
-
return
|
|
310
|
+
return n.set(f, { p: A, at: Date.now(), epoch: b, config: y }), A;
|
|
259
311
|
};
|
|
260
|
-
return new Proxy(
|
|
261
|
-
get(
|
|
262
|
-
if (
|
|
263
|
-
if (
|
|
264
|
-
if (
|
|
265
|
-
return (
|
|
266
|
-
|
|
312
|
+
return new Proxy(e, {
|
|
313
|
+
get(r, s, f) {
|
|
314
|
+
if (s === "request") return i;
|
|
315
|
+
if (s === L) return !0;
|
|
316
|
+
if (s === "setToken" && typeof r.setToken == "function")
|
|
317
|
+
return (h) => {
|
|
318
|
+
r.setToken(h), K();
|
|
267
319
|
};
|
|
268
|
-
const
|
|
269
|
-
return typeof
|
|
320
|
+
const o = Reflect.get(r, s, f);
|
|
321
|
+
return typeof o == "function" ? o.bind(r) : o;
|
|
270
322
|
}
|
|
271
323
|
});
|
|
272
324
|
}
|
|
273
|
-
const
|
|
274
|
-
function
|
|
275
|
-
for (const
|
|
325
|
+
const Re = /^\/(item-locks|drafts|auth)\b/, E = /* @__PURE__ */ new Set();
|
|
326
|
+
function Ge() {
|
|
327
|
+
for (const e of [...E]) e();
|
|
276
328
|
}
|
|
277
|
-
function
|
|
278
|
-
return
|
|
279
|
-
|
|
329
|
+
function je(e) {
|
|
330
|
+
return e.subscribe((t) => {
|
|
331
|
+
t.type === "observerAdded" && t.query.state.fetchStatus === "fetching" && E.size !== 0 && Ge();
|
|
280
332
|
});
|
|
281
333
|
}
|
|
282
|
-
function
|
|
283
|
-
let
|
|
334
|
+
function Ie(e, t = {}) {
|
|
335
|
+
let n = t.open ?? !0, c;
|
|
284
336
|
const d = /* @__PURE__ */ new Map(), m = () => {
|
|
285
|
-
const
|
|
337
|
+
const i = [...d.values()];
|
|
286
338
|
d.clear();
|
|
287
|
-
for (const
|
|
339
|
+
for (const r of i) r.release();
|
|
288
340
|
}, u = () => {
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
if (f) return f.promise.then(
|
|
295
|
-
let
|
|
341
|
+
E.delete(u), m();
|
|
342
|
+
}, a = (i) => {
|
|
343
|
+
const r = i;
|
|
344
|
+
if (n || !ne(r) || Re.test(r._path ?? "")) return e.request(i);
|
|
345
|
+
const s = $(r), f = d.get(s);
|
|
346
|
+
if (f) return f.promise.then(T);
|
|
347
|
+
let o = () => {
|
|
296
348
|
};
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
}).then(() =>
|
|
300
|
-
return d.set(
|
|
349
|
+
const p = new Promise((g) => {
|
|
350
|
+
o = g;
|
|
351
|
+
}).then(() => e.request(i));
|
|
352
|
+
return d.set(s, { promise: p, release: o }), E.add(u), p;
|
|
301
353
|
};
|
|
302
|
-
return new Proxy(
|
|
303
|
-
get(
|
|
304
|
-
if (
|
|
305
|
-
if (
|
|
306
|
-
if (
|
|
307
|
-
return (
|
|
354
|
+
return new Proxy(e, {
|
|
355
|
+
get(i, r, s) {
|
|
356
|
+
if (r === "request") return a;
|
|
357
|
+
if (r === "open") return n;
|
|
358
|
+
if (r === "setOpen")
|
|
359
|
+
return (o) => {
|
|
308
360
|
c !== void 0 && (clearTimeout(c), c = void 0);
|
|
309
|
-
const h =
|
|
310
|
-
|
|
361
|
+
const h = n;
|
|
362
|
+
n = o, o && !h && (E.delete(u), m());
|
|
311
363
|
};
|
|
312
|
-
if (
|
|
364
|
+
if (r === "dispose")
|
|
313
365
|
return () => {
|
|
314
366
|
c === void 0 && (c = setTimeout(() => {
|
|
315
|
-
c = void 0,
|
|
367
|
+
c = void 0, n = !0, E.delete(u), m();
|
|
316
368
|
}, 0));
|
|
317
369
|
};
|
|
318
|
-
const f = Reflect.get(
|
|
319
|
-
return typeof f == "function" ? f.bind(
|
|
370
|
+
const f = Reflect.get(i, r, s);
|
|
371
|
+
return typeof f == "function" ? f.bind(i) : f;
|
|
320
372
|
}
|
|
321
373
|
});
|
|
322
374
|
}
|
|
323
375
|
export {
|
|
324
376
|
k as BATCH_READ_LIMIT,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
377
|
+
D as COLLECTION_BATCH_LIMIT,
|
|
378
|
+
ue as COLLECTION_BATCH_WINDOW_MS,
|
|
379
|
+
we as RECORD_JOIN_MS,
|
|
380
|
+
j as SETTLED_READ_MS,
|
|
381
|
+
fe as batchableCollectionMeta,
|
|
382
|
+
me as batchableGet,
|
|
383
|
+
ie as batchableRead,
|
|
384
|
+
Ie as createGatedClient,
|
|
385
|
+
I as forgetSettledReads,
|
|
386
|
+
re as isCoalesced,
|
|
387
|
+
be as isSettledRead,
|
|
388
|
+
Oe as mayJoinConfigInflight,
|
|
389
|
+
Ce as mayJoinInflight,
|
|
390
|
+
Ae as movesWriteEpoch,
|
|
391
|
+
Ge as releaseGatedReads,
|
|
392
|
+
je as releaseGatedReadsOnSharedFetch,
|
|
393
|
+
De as withGetCoalescing
|
|
340
394
|
};
|