@graphty/graphty-element 2.6.2 → 3.0.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/ai.js +3 -3
- package/dist/catalog.js +53 -54
- package/dist/chunks/{AiManager-4iQpsJW1.js → AiManager-Bhh0rR_p.js} +706 -655
- package/dist/chunks/GraphSession-DPoTaT3b.js +21175 -0
- package/dist/chunks/{GraphtyLogger-B_O67a6c.js → GraphtyLogger-BtcBJQPL.js} +1 -1
- package/dist/chunks/{VoiceInputAdapter-Cc6mHXTI.js → VoiceInputAdapter-CdLsJ_nG.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-BLa89LXn.js → XRPivotCameraController-CiLJ9Gz6.js} +2 -2
- package/dist/chunks/algorithms-qij74zEN.js +6811 -0
- package/dist/chunks/{capability-check-Am2zliFj.js → capability-check-BbgTejS3.js} +1 -1
- package/dist/chunks/definePalette-BYt2Llxs.js +1333 -0
- package/dist/chunks/fields-5uVC1Pll.js +4999 -0
- package/dist/chunks/{format-detection-BHwrAVzW.js → format-detection-FKaDMshR.js} +1 -1
- package/dist/chunks/{index-BkBLbvui.js → index-Cc_6D9hV.js} +6034 -7127
- package/dist/chunks/interpolation-Dk206AhZ.js +105 -0
- package/dist/chunks/paletteRegistry-De3CGdst.js +357 -0
- package/dist/chunks/parse-SVp77JbE.js +669 -0
- package/dist/chunks/{pluginRegistry-Bs8bEkz9.js → pluginRegistry-Ddfl6Mv2.js} +27 -24
- package/dist/chunks/{registry-BdGvyZou.js → registry-CgMqldp4.js} +1 -1
- package/dist/chunks/{DataSource-BL2UzPff.js → sources-BbAJCDIH.js} +279 -108
- package/dist/commands.d.ts +128 -19
- package/dist/commands.js +49 -1
- package/dist/custom-elements.json +1 -1
- package/dist/extend.d.ts +10 -2
- package/dist/extend.js +64 -57
- package/dist/graphty-catalog.json +6 -3
- package/dist/graphty.bundle.js +267177 -240648
- package/dist/graphty.js +84 -78
- package/dist/index.d.ts +4 -0
- package/dist/logging.js +2 -2
- package/dist/schema.js +70 -71
- package/dist/session.d.ts +5 -6
- package/dist/session.js +40 -86
- package/dist/src/Edge.d.ts +31 -67
- package/dist/src/Graph.d.ts +335 -77
- package/dist/src/Node.d.ts +36 -3
- package/dist/src/NodeBehavior.d.ts +28 -0
- package/dist/src/Styles.d.ts +15 -4
- package/dist/src/acceleration/AccelerationController.d.ts +8 -0
- package/dist/src/acceleration/narrow.d.ts +9 -1
- package/dist/src/acceleration/types.d.ts +10 -0
- package/dist/src/ai/AiController.d.ts +12 -0
- package/dist/src/ai/AiManager.d.ts +7 -0
- package/dist/src/ai/commands/AlgorithmCommands.d.ts +1 -1
- package/dist/src/ai/commands/LayoutCommands.d.ts +1 -1
- package/dist/src/ai/commands/StyleCommands.d.ts +1 -1
- package/dist/src/ai/commands/types.d.ts +20 -1
- package/dist/src/algorithms/Algorithm.d.ts +21 -4
- package/dist/src/algorithms/BFSAlgorithm.d.ts +0 -9
- package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +0 -14
- package/dist/src/algorithms/DFSAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/LeidenAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/metrics/fields.d.ts +23 -1
- package/dist/src/algorithms/utils/graphUtils.d.ts +13 -1
- package/dist/src/catalog/paletteRegistry.d.ts +4 -4
- package/dist/src/catalog/registry.d.ts +3 -2
- package/dist/src/catalog/types.d.ts +18 -1
- package/dist/src/config/GraphStyle.d.ts +1 -1
- package/dist/src/config/StyleTemplate.d.ts +2 -2
- package/dist/src/config/xr-config-schema.d.ts +4 -4
- package/dist/src/data/CSVDataSource.d.ts +77 -22
- package/dist/src/data/ErrorAggregator.d.ts +5 -0
- package/dist/src/data/GEXFDataSource.d.ts +12 -61
- package/dist/src/data/GraphMLDataSource.d.ts +3 -44
- package/dist/src/data/GraphStore.d.ts +322 -15
- package/dist/src/data/JsonDataSource.d.ts +43 -1
- package/dist/src/data/graph-io-import.d.ts +89 -0
- package/dist/src/data/graph-io-records.d.ts +64 -0
- package/dist/src/data/lane.d.ts +23 -0
- package/dist/src/data/positions.d.ts +13 -0
- package/dist/src/data/seedPosition.d.ts +16 -0
- package/dist/src/errors/GraphtyError.d.ts +3 -1
- package/dist/src/errors/codes.d.ts +23 -0
- package/dist/src/events.d.ts +12 -0
- package/dist/src/graphty-element.d.ts +149 -54
- package/dist/src/input/types.d.ts +2 -0
- package/dist/src/layout/D3GraphLayoutEngine.d.ts +17 -3
- package/dist/src/layout/FixedLayoutEngine.d.ts +20 -4
- package/dist/src/layout/KamadaKawaiLayoutEngine.d.ts +6 -0
- package/dist/src/layout/LayoutEngine.d.ts +214 -116
- package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -3
- package/dist/src/layout/SimulationLayoutEngine.d.ts +8 -3
- package/dist/src/managers/AlgorithmManager.d.ts +24 -5
- package/dist/src/managers/DataManager.d.ts +258 -181
- package/dist/src/managers/EventManager.d.ts +5 -2
- package/dist/src/managers/GraphContext.d.ts +7 -0
- package/dist/src/managers/InputManager.d.ts +11 -0
- package/dist/src/managers/LayoutManager.d.ts +129 -50
- package/dist/src/managers/RenderManager.d.ts +14 -1
- package/dist/src/managers/UpdateManager.d.ts +20 -0
- package/dist/src/screenshot/ScreenshotCapture.d.ts +1 -1
- package/dist/src/session/GraphSession.d.ts +83 -6
- package/dist/src/session/commands/algo.d.ts +169 -0
- package/dist/src/session/commands/config.d.ts +45 -0
- package/dist/src/session/commands/data.d.ts +178 -0
- package/dist/src/session/commands/doors.d.ts +93 -0
- package/dist/src/session/commands/index.d.ts +20 -0
- package/dist/src/session/commands/layout.d.ts +104 -0
- package/dist/src/session/commands/positions.d.ts +30 -0
- package/dist/src/session/commands/sets.d.ts +113 -0
- package/dist/src/session/commands/style.d.ts +92 -0
- package/dist/src/session/commands/view.d.ts +57 -0
- package/dist/src/session/commands/visibility.d.ts +41 -0
- package/dist/src/session/data.d.ts +131 -4
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/planning.d.ts +25 -8
- package/dist/src/session/project/Dispatcher.d.ts +905 -0
- package/dist/src/session/project/History.d.ts +382 -0
- package/dist/src/session/project/arrangement.d.ts +247 -0
- package/dist/src/session/project/derive.d.ts +132 -0
- package/dist/src/session/project/digest.d.ts +33 -0
- package/dist/src/session/project/draft.d.ts +194 -0
- package/dist/src/session/project/graphOps.d.ts +304 -0
- package/dist/src/session/project/ingest.d.ts +364 -0
- package/dist/src/session/project/state.d.ts +145 -0
- package/dist/src/session/project/strict.d.ts +68 -0
- package/dist/src/session/results/RunResult.d.ts +48 -0
- package/dist/src/session/results/statistics.d.ts +20 -0
- package/dist/src/session/runs/Run.d.ts +80 -4
- package/dist/src/session/runs/RunsApi.d.ts +23 -6
- package/dist/src/session/runs/types.d.ts +25 -6
- package/dist/src/session/scope/ElementMask.d.ts +14 -0
- package/dist/src/session/scope/ScopeApi.d.ts +3 -22
- package/dist/src/session/scope/spaces.d.ts +29 -0
- package/dist/src/session/sealed.d.ts +22 -0
- package/dist/src/session/selection/SelectionApi.d.ts +14 -4
- package/dist/src/session/sets/SetsApi.d.ts +13 -5
- package/dist/src/session/sets/store.d.ts +54 -53
- package/dist/src/session/sets/types.d.ts +5 -2
- package/dist/src/session/styles/Layer.d.ts +5 -0
- package/dist/src/session/styles/StylesApi.d.ts +68 -17
- package/dist/src/session/styles/autoApply.d.ts +64 -53
- package/dist/src/session/styles/index.d.ts +3 -3
- package/dist/src/session/styles/predicate.d.ts +7 -0
- package/dist/src/session/styles/repaint.d.ts +16 -1
- package/dist/src/session/styles/sources.d.ts +1 -1
- package/dist/src/session/types.d.ts +625 -54
- package/dist/src/session/visibility/VisibilityApi.d.ts +38 -18
- package/dist/src/session/visibility/filter.d.ts +10 -0
- package/dist/src/simple/defineAlgorithm.d.ts +28 -0
- package/dist/src/simple/defineLayout.d.ts +35 -0
- package/dist/src/simple/defineLogDestination.d.ts +31 -0
- package/dist/src/simple/definePalette.d.ts +26 -0
- package/dist/src/simple/definition.d.ts +106 -0
- package/dist/src/simple/options.d.ts +33 -0
- package/dist/src/simple/source.d.ts +49 -0
- package/dist/src/simple/types.d.ts +366 -0
- package/dist/src/simple/view.d.ts +107 -0
- package/dist/webgpu.js +2 -2
- package/package.json +10 -12
- package/dist/chunks/GraphSession-BhuHSXIo.js +0 -12819
- package/dist/chunks/GraphStyle-Cwr55SAE.js +0 -65
- package/dist/chunks/algorithms-BJ6DQMOe.js +0 -3777
- package/dist/chunks/detect-fyuVnlCT.js +0 -88
- package/dist/chunks/interpolation-DY-PNpqX.js +0 -43
- package/dist/chunks/optionsFromZod-CKMYSwTz.js +0 -3636
- package/dist/chunks/paletteRegistry-BCFSwJGK.js +0 -1196
- package/dist/chunks/parse-BMTqt4SS.js +0 -3658
- package/dist/src/data/csv-variant-detection.d.ts +0 -29
- package/dist/src/data/ingest.d.ts +0 -104
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { z as
|
|
2
|
-
import * as
|
|
3
|
-
import { F as
|
|
4
|
-
import { b as
|
|
5
|
-
import { G as
|
|
6
|
-
|
|
1
|
+
import { z as L } from "zod/v4";
|
|
2
|
+
import * as N from "zod/v4/core";
|
|
3
|
+
import { F as P, p as U } from "./paletteRegistry-De3CGdst.js";
|
|
4
|
+
import { b as B } from "./GraphtyLogger-BtcBJQPL.js";
|
|
5
|
+
import { G as C, S as V } from "./pluginRegistry-Ddfl6Mv2.js";
|
|
6
|
+
import { INVALID_INDEX as S } from "@graphty/graph-format";
|
|
7
|
+
import { N as H, Q as z, B as q } from "./fields-5uVC1Pll.js";
|
|
8
|
+
class W {
|
|
7
9
|
/**
|
|
8
10
|
* Creates a new ErrorAggregator instance.
|
|
9
11
|
* @param maxErrors - Maximum number of errors to collect before stopping
|
|
@@ -25,8 +27,8 @@ class S {
|
|
|
25
27
|
const r = this.errorsByCategory.get(t);
|
|
26
28
|
if (r && r.push(e), e.field) {
|
|
27
29
|
this.errorsByField.has(e.field) || this.errorsByField.set(e.field, []);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
+
const d = this.errorsByField.get(e.field);
|
|
31
|
+
d && d.push(e);
|
|
30
32
|
}
|
|
31
33
|
return !0;
|
|
32
34
|
}
|
|
@@ -37,6 +39,13 @@ class S {
|
|
|
37
39
|
getErrorCount() {
|
|
38
40
|
return this.errors.length;
|
|
39
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the number of errors this aggregator collects before it stops
|
|
44
|
+
* @returns The error limit
|
|
45
|
+
*/
|
|
46
|
+
getErrorLimit() {
|
|
47
|
+
return this.maxErrors;
|
|
48
|
+
}
|
|
40
49
|
/**
|
|
41
50
|
* Check if error limit has been reached
|
|
42
51
|
* @returns True if the maximum error count has been reached
|
|
@@ -58,9 +67,9 @@ class S {
|
|
|
58
67
|
getSummary() {
|
|
59
68
|
const e = this.errors.length;
|
|
60
69
|
let t, r = 0;
|
|
61
|
-
for (const [
|
|
62
|
-
|
|
63
|
-
const { message:
|
|
70
|
+
for (const [c, g] of this.errorsByCategory.entries())
|
|
71
|
+
g.length > r && (r = g.length, t = c);
|
|
72
|
+
const { message: d, suggestion: f } = this.generateUserFriendlyMessage(
|
|
64
73
|
e,
|
|
65
74
|
t,
|
|
66
75
|
this.errorsByCategory,
|
|
@@ -70,8 +79,8 @@ class S {
|
|
|
70
79
|
totalErrors: e,
|
|
71
80
|
categories: new Map(this.errorsByCategory),
|
|
72
81
|
primaryCategory: t,
|
|
73
|
-
message:
|
|
74
|
-
suggestion:
|
|
82
|
+
message: d,
|
|
83
|
+
suggestion: f
|
|
75
84
|
};
|
|
76
85
|
}
|
|
77
86
|
/**
|
|
@@ -99,16 +108,16 @@ Suggestion: ${e.suggestion}`), t;
|
|
|
99
108
|
`, t += `${"=".repeat(50)}
|
|
100
109
|
|
|
101
110
|
`;
|
|
102
|
-
for (const [r,
|
|
103
|
-
t += `${r.toUpperCase()} (${
|
|
111
|
+
for (const [r, d] of this.errorsByCategory.entries()) {
|
|
112
|
+
t += `${r.toUpperCase()} (${d.length} errors):
|
|
104
113
|
`;
|
|
105
|
-
const
|
|
106
|
-
for (const
|
|
107
|
-
const
|
|
108
|
-
t += ` - ${
|
|
114
|
+
const f = d.slice(0, 10);
|
|
115
|
+
for (const c of f) {
|
|
116
|
+
const g = c.line !== void 0 ? ` [line ${c.line}]` : "", h = c.field ? ` [field: ${c.field}]` : "";
|
|
117
|
+
t += ` - ${c.message}${g}${h}
|
|
109
118
|
`;
|
|
110
119
|
}
|
|
111
|
-
|
|
120
|
+
d.length > 10 && (t += ` ... and ${d.length - 10} more
|
|
112
121
|
`), t += `
|
|
113
122
|
`;
|
|
114
123
|
}
|
|
@@ -128,21 +137,21 @@ Suggestion: ${e.suggestion}`), t;
|
|
|
128
137
|
* @param errorsByField - Errors grouped by field name
|
|
129
138
|
* @returns Object containing user-friendly message and optional suggestion
|
|
130
139
|
*/
|
|
131
|
-
generateUserFriendlyMessage(e, t, r,
|
|
140
|
+
generateUserFriendlyMessage(e, t, r, d) {
|
|
132
141
|
if (e === 0)
|
|
133
142
|
return { message: "No errors" };
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const
|
|
137
|
-
return { message:
|
|
143
|
+
const f = r.get("missing-column")?.length ?? 0, c = r.get("parse-error")?.length ?? 0, g = r.get("validation-error")?.length ?? 0, h = r.get("missing-value")?.length ?? 0;
|
|
144
|
+
if (f > 0) {
|
|
145
|
+
const l = Array.from(d.keys()), p = `Found ${e} errors (${f} missing column errors)`, $ = l.length > 0 ? `Check that your data has the required columns: ${l.join(", ")}` : "Check that your data has the required columns (e.g., 'source', 'target' for edges)";
|
|
146
|
+
return { message: p, suggestion: $ };
|
|
138
147
|
}
|
|
139
|
-
if (
|
|
148
|
+
if (c > e * 0.5)
|
|
140
149
|
return { message: `Found ${e} errors (mostly parsing errors)`, suggestion: "Check your file format and encoding. Common issues: incorrect delimiter, malformed quotes, or encoding problems (try UTF-8)" };
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
return { message:
|
|
150
|
+
if (h > 0) {
|
|
151
|
+
const l = Array.from(d.keys()), p = `Found ${e} errors (${h} missing required values)`, $ = l.length > 0 ? `Check that rows have values for: ${l.join(", ")}` : "Check that rows have all required values";
|
|
152
|
+
return { message: p, suggestion: $ };
|
|
144
153
|
}
|
|
145
|
-
return
|
|
154
|
+
return g > 0 ? { message: `Found ${e} errors (${g} validation errors)`, suggestion: "Check that your data values match the expected format and types" } : t && t !== "unknown" ? {
|
|
146
155
|
message: `Found ${e} errors (mostly ${t} errors)`,
|
|
147
156
|
suggestion: "See detailed error report for more information"
|
|
148
157
|
} : {
|
|
@@ -151,7 +160,7 @@ Suggestion: ${e.suggestion}`), t;
|
|
|
151
160
|
};
|
|
152
161
|
}
|
|
153
162
|
}
|
|
154
|
-
const
|
|
163
|
+
const I = new V("format"), j = /* @__PURE__ */ new Set([
|
|
155
164
|
"data",
|
|
156
165
|
"file",
|
|
157
166
|
"url",
|
|
@@ -164,55 +173,55 @@ const f = new C("format"), k = /* @__PURE__ */ new Set([
|
|
|
164
173
|
"edgeSrcIdPath",
|
|
165
174
|
"edgeDstIdPath"
|
|
166
175
|
]);
|
|
167
|
-
function
|
|
168
|
-
throw new
|
|
176
|
+
function E(n, e) {
|
|
177
|
+
throw new C({
|
|
169
178
|
code: "E_BAD_COMMAND",
|
|
170
179
|
message: e,
|
|
171
180
|
source: "registry",
|
|
172
|
-
details: { kind: "format", field:
|
|
181
|
+
details: { kind: "format", field: n }
|
|
173
182
|
});
|
|
174
183
|
}
|
|
175
|
-
function
|
|
176
|
-
(e === null || typeof e != "object") &&
|
|
184
|
+
function G(n, e) {
|
|
185
|
+
(e === null || typeof e != "object") && E(
|
|
177
186
|
"descriptor",
|
|
178
|
-
`the format "${
|
|
187
|
+
`the format "${n}" registered no description, so nothing could offer it: declare \`static descriptor: FormatDescriptor\` on the class`
|
|
179
188
|
);
|
|
180
189
|
const t = e;
|
|
181
|
-
t.id !==
|
|
190
|
+
t.id !== n && E(
|
|
182
191
|
"descriptor.id",
|
|
183
|
-
`the reader registered as "${
|
|
184
|
-
), (!Array.isArray(t.extensions) || t.extensions.length === 0) &&
|
|
192
|
+
`the reader registered as "${n}" describes itself as "${String(t.id)}"; one format has one name, and the two halves disagreeing is how a catalogue entry comes to name a reader nothing registered`
|
|
193
|
+
), (!Array.isArray(t.extensions) || t.extensions.length === 0) && E(
|
|
185
194
|
"descriptor.extensions",
|
|
186
|
-
`the format "${
|
|
195
|
+
`the format "${n}" claims no file extension, so no file could ever be recognised as it`
|
|
187
196
|
);
|
|
188
197
|
for (const r of t.extensions)
|
|
189
|
-
(typeof r != "string" || !r.startsWith(".") || r !== r.toLowerCase()) &&
|
|
198
|
+
(typeof r != "string" || !r.startsWith(".") || r !== r.toLowerCase()) && E(
|
|
190
199
|
"descriptor.extensions",
|
|
191
|
-
`the format "${
|
|
200
|
+
`the format "${n}" claims the extension ${JSON.stringify(r)}; an extension is a lower-case string beginning with a dot, because that is what a file name is compared against`
|
|
192
201
|
);
|
|
193
|
-
return (!Array.isArray(t.mimeTypes) || t.mimeTypes.length === 0) &&
|
|
202
|
+
return (!Array.isArray(t.mimeTypes) || t.mimeTypes.length === 0) && E(
|
|
194
203
|
"descriptor.mimeTypes",
|
|
195
|
-
`the format "${
|
|
196
|
-
), t.canExport === !0 &&
|
|
204
|
+
`the format "${n}" declares no media type, which is what a file picker filters on`
|
|
205
|
+
), t.canExport === !0 && E(
|
|
197
206
|
"descriptor.canExport",
|
|
198
|
-
`the format "${
|
|
207
|
+
`the format "${n}" says it can be written, and there is nowhere to register a writer: a "Save as" menu built from the catalogue would offer a format nothing can save`
|
|
199
208
|
), e;
|
|
200
209
|
}
|
|
201
|
-
function
|
|
210
|
+
function x(n, e) {
|
|
202
211
|
if (e !== void 0)
|
|
203
|
-
return typeof e != "function" &&
|
|
212
|
+
return typeof e != "function" && E(
|
|
204
213
|
"detect",
|
|
205
|
-
`the format "${
|
|
214
|
+
`the format "${n}" declares a \`static detect\` that is not a function, so no file could be sniffed`
|
|
206
215
|
), e;
|
|
207
216
|
}
|
|
208
|
-
const
|
|
217
|
+
const F = class F {
|
|
209
218
|
/**
|
|
210
219
|
* Creates a new DataSource instance.
|
|
211
220
|
* @param errorLimit - Maximum number of errors before stopping data processing
|
|
212
221
|
* @param chunkSize - Number of nodes to process per chunk
|
|
213
222
|
*/
|
|
214
|
-
constructor(e = 100, t =
|
|
215
|
-
this.edgeSchema = null, this.nodeSchema = null, this.declaration = null, this.errorAggregator = new
|
|
223
|
+
constructor(e = 100, t = F.DEFAULT_CHUNK_SIZE) {
|
|
224
|
+
this.edgeSchema = null, this.nodeSchema = null, this.declaration = null, this.errorAggregator = new W(e), this.chunkSize = t;
|
|
216
225
|
}
|
|
217
226
|
/**
|
|
218
227
|
* Standardized error message templates
|
|
@@ -238,54 +247,54 @@ const u = class u {
|
|
|
238
247
|
async fetchWithRetry(e, t = 3, r = 3e4) {
|
|
239
248
|
if (e.startsWith("data:"))
|
|
240
249
|
return await fetch(e);
|
|
241
|
-
let
|
|
242
|
-
for (let
|
|
250
|
+
let d;
|
|
251
|
+
for (let f = 0; f < t; f++)
|
|
243
252
|
try {
|
|
244
|
-
const
|
|
245
|
-
|
|
253
|
+
const c = new AbortController(), g = setTimeout(() => {
|
|
254
|
+
c.abort();
|
|
246
255
|
}, r);
|
|
247
256
|
try {
|
|
248
|
-
const
|
|
249
|
-
if (clearTimeout(
|
|
250
|
-
|
|
251
|
-
const { status:
|
|
252
|
-
throw
|
|
257
|
+
const h = await fetch(e, { signal: c.signal });
|
|
258
|
+
if (clearTimeout(g), !h.ok) {
|
|
259
|
+
d = h.status;
|
|
260
|
+
const { status: l } = h;
|
|
261
|
+
throw l >= 400 && l < 500 && l !== 408 && l !== 429 ? new C({
|
|
253
262
|
code: "E_FETCH_FAILED",
|
|
254
|
-
message: `Failed to fetch from ${e}: HTTP ${
|
|
263
|
+
message: `Failed to fetch from ${e}: HTTP ${l}`,
|
|
255
264
|
source: "data",
|
|
256
265
|
recoverable: !1,
|
|
257
|
-
details: { url: e, attempts:
|
|
258
|
-
}) : new Error(`HTTP error! status: ${
|
|
266
|
+
details: { url: e, attempts: f + 1, status: l }
|
|
267
|
+
}) : new Error(`HTTP error! status: ${l}`);
|
|
259
268
|
}
|
|
260
|
-
return
|
|
261
|
-
} catch (
|
|
262
|
-
throw clearTimeout(
|
|
269
|
+
return h;
|
|
270
|
+
} catch (h) {
|
|
271
|
+
throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${r}ms`) : h;
|
|
263
272
|
}
|
|
264
|
-
} catch (
|
|
265
|
-
if (
|
|
266
|
-
throw
|
|
267
|
-
if (
|
|
268
|
-
const
|
|
269
|
-
throw new
|
|
273
|
+
} catch (c) {
|
|
274
|
+
if (c instanceof C)
|
|
275
|
+
throw c;
|
|
276
|
+
if (f === t - 1) {
|
|
277
|
+
const l = c instanceof Error ? c.message : String(c);
|
|
278
|
+
throw new C({
|
|
270
279
|
code: "E_FETCH_FAILED",
|
|
271
|
-
message: `Failed to fetch from ${e} after ${t} attempts: ${
|
|
280
|
+
message: `Failed to fetch from ${e} after ${t} attempts: ${l}`,
|
|
272
281
|
source: "data",
|
|
273
282
|
// A server that was down, a network that dropped: the same call unchanged
|
|
274
283
|
// could succeed later, which is exactly what this flag is for.
|
|
275
284
|
recoverable: !0,
|
|
276
|
-
details: { url: e, attempts: t, status:
|
|
277
|
-
cause:
|
|
285
|
+
details: { url: e, attempts: t, status: d },
|
|
286
|
+
cause: c
|
|
278
287
|
});
|
|
279
288
|
}
|
|
280
|
-
const
|
|
281
|
-
await new Promise((
|
|
289
|
+
const h = Math.pow(2, f) * 1e3;
|
|
290
|
+
await new Promise((l) => setTimeout(l, h));
|
|
282
291
|
}
|
|
283
|
-
throw new
|
|
292
|
+
throw new C({
|
|
284
293
|
code: "E_FETCH_FAILED",
|
|
285
294
|
message: `Failed to fetch from ${e} after ${t} attempts`,
|
|
286
295
|
source: "data",
|
|
287
296
|
recoverable: !0,
|
|
288
|
-
details: { url: e, attempts: t, status:
|
|
297
|
+
details: { url: e, attempts: t, status: d }
|
|
289
298
|
});
|
|
290
299
|
}
|
|
291
300
|
/**
|
|
@@ -325,10 +334,10 @@ const u = class u {
|
|
|
325
334
|
* `E_OPTION_RANGE` for a value it would not accept.
|
|
326
335
|
*/
|
|
327
336
|
resolveOptions(e) {
|
|
328
|
-
const r = this.constructor.descriptor?.options ?? [],
|
|
329
|
-
for (const [
|
|
330
|
-
(
|
|
331
|
-
return
|
|
337
|
+
const r = this.constructor.descriptor?.options ?? [], d = new Set(r.map((c) => c.name)), f = {};
|
|
338
|
+
for (const [c, g] of Object.entries(e))
|
|
339
|
+
(d.has(c) || !j.has(c)) && (f[c] = g);
|
|
340
|
+
return B(r, f, { kind: "format", id: this.type });
|
|
332
341
|
}
|
|
333
342
|
/**
|
|
334
343
|
* Shared chunking helper
|
|
@@ -386,14 +395,14 @@ const u = class u {
|
|
|
386
395
|
for await (const e of this.sourceFetchData()) {
|
|
387
396
|
const t = [];
|
|
388
397
|
if (this.nodeSchema)
|
|
389
|
-
for (const
|
|
390
|
-
await this.dataValidator(this.nodeSchema,
|
|
398
|
+
for (const d of e.nodes)
|
|
399
|
+
await this.dataValidator(this.nodeSchema, d) && t.push(d);
|
|
391
400
|
else
|
|
392
401
|
t.push(...e.nodes);
|
|
393
402
|
const r = [];
|
|
394
403
|
if (this.edgeSchema)
|
|
395
|
-
for (const
|
|
396
|
-
await this.dataValidator(this.edgeSchema,
|
|
404
|
+
for (const d of e.edges)
|
|
405
|
+
await this.dataValidator(this.edgeSchema, d) && r.push(d);
|
|
397
406
|
else
|
|
398
407
|
r.push(...e.edges);
|
|
399
408
|
if ((t.length > 0 || r.length > 0) && (yield { nodes: t, edges: r }), this.errorAggregator.hasReachedLimit())
|
|
@@ -409,11 +418,11 @@ const u = class u {
|
|
|
409
418
|
* @returns Promise resolving to true if validation succeeds, false otherwise
|
|
410
419
|
*/
|
|
411
420
|
async dataValidator(e, t) {
|
|
412
|
-
const r = await
|
|
421
|
+
const r = await N.safeParseAsync(e, t);
|
|
413
422
|
if (!r.success) {
|
|
414
|
-
const
|
|
423
|
+
const d = L.prettifyError(r.error);
|
|
415
424
|
return this.errorAggregator.addError({
|
|
416
|
-
message: `Validation failed: ${
|
|
425
|
+
message: `Validation failed: ${d}`,
|
|
417
426
|
category: "validation-error"
|
|
418
427
|
}), !1;
|
|
419
428
|
}
|
|
@@ -451,28 +460,28 @@ const u = class u {
|
|
|
451
460
|
*/
|
|
452
461
|
static register(e, t) {
|
|
453
462
|
const { type: r } = e;
|
|
454
|
-
if ((typeof r != "string" || r === "") &&
|
|
463
|
+
if ((typeof r != "string" || r === "") && E(
|
|
455
464
|
"type",
|
|
456
465
|
"a data source registers under the name in its `static type`, and this class declares none"
|
|
457
|
-
),
|
|
458
|
-
if (
|
|
459
|
-
throw new
|
|
466
|
+
), P.some((f) => f.id === r)) {
|
|
467
|
+
if (I.hasOwn(r))
|
|
468
|
+
throw new C({
|
|
460
469
|
code: "E_DUPLICATE_PLUGIN",
|
|
461
470
|
message: `"${r}" is a format the element ships and already reads, and a built-in name may not be taken: a document that named it yesterday has to mean the same thing today`,
|
|
462
471
|
source: "registry",
|
|
463
472
|
details: { kind: "format", name: r, builtIn: !0 }
|
|
464
473
|
});
|
|
465
|
-
return
|
|
474
|
+
return I.set(r, e), e;
|
|
466
475
|
}
|
|
467
|
-
const
|
|
468
|
-
return
|
|
476
|
+
const d = x(r, e.detect);
|
|
477
|
+
return U(
|
|
469
478
|
{
|
|
470
|
-
descriptor:
|
|
479
|
+
descriptor: G(r, e.descriptor),
|
|
471
480
|
type: r,
|
|
472
|
-
...
|
|
481
|
+
...d === void 0 ? {} : { detect: d }
|
|
473
482
|
},
|
|
474
483
|
t
|
|
475
|
-
),
|
|
484
|
+
), I.set(r, e), e;
|
|
476
485
|
}
|
|
477
486
|
/**
|
|
478
487
|
* Turn a plain object into a record the element ingests.
|
|
@@ -508,7 +517,7 @@ const u = class u {
|
|
|
508
517
|
* @returns A new data source instance or null if type not found
|
|
509
518
|
*/
|
|
510
519
|
static get(e, t = {}) {
|
|
511
|
-
const r =
|
|
520
|
+
const r = I.get(e);
|
|
512
521
|
return r ? new r(t) : null;
|
|
513
522
|
}
|
|
514
523
|
/**
|
|
@@ -523,12 +532,174 @@ const u = class u {
|
|
|
523
532
|
* ```
|
|
524
533
|
*/
|
|
525
534
|
static getRegisteredTypes() {
|
|
526
|
-
return Array.from(
|
|
535
|
+
return Array.from(I.keys()).sort();
|
|
527
536
|
}
|
|
528
537
|
};
|
|
529
|
-
|
|
530
|
-
let
|
|
538
|
+
F.DEFAULT_CHUNK_SIZE = 1e3;
|
|
539
|
+
let M = F;
|
|
540
|
+
function de(n) {
|
|
541
|
+
return {
|
|
542
|
+
indexOf: (e) => n.ids.indexOf(e),
|
|
543
|
+
idOf: (e) => n.ids.idOf(e)
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function X(n) {
|
|
547
|
+
const e = n.edges.byRole("id");
|
|
548
|
+
return {
|
|
549
|
+
indexOf: (t) => {
|
|
550
|
+
const r = z(t);
|
|
551
|
+
return r === S ? S : n.edgeIndexOf(r);
|
|
552
|
+
},
|
|
553
|
+
idOf: (t) => {
|
|
554
|
+
const r = e !== null && e.isSet(t) ? e.value(t) : void 0;
|
|
555
|
+
return H(typeof r == "number" ? r : S);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
const D = "data.";
|
|
560
|
+
function K(n, e, t) {
|
|
561
|
+
if (t === "source")
|
|
562
|
+
return n.ids.idOf(n.edgeSource(e));
|
|
563
|
+
if (t === "target")
|
|
564
|
+
return n.ids.idOf(n.edgeTarget(e));
|
|
565
|
+
}
|
|
566
|
+
const O = `${q}.`, R = Object.freeze({ kind: "none", key: "", runId: "", field: "" });
|
|
567
|
+
function Z(n) {
|
|
568
|
+
if (n.startsWith(O)) {
|
|
569
|
+
const t = n.indexOf(".", O.length), r = t === -1 ? "" : n.slice(O.length, t), d = t === -1 ? "" : n.slice(t + 1);
|
|
570
|
+
return r === "" || d === "" || d.includes(".") ? R : { kind: "result", key: "", runId: r, field: d };
|
|
571
|
+
}
|
|
572
|
+
const e = n.startsWith(D) ? n.slice(D.length) : n;
|
|
573
|
+
return e === "" ? R : { kind: "attribute", key: e, runId: "", field: "" };
|
|
574
|
+
}
|
|
575
|
+
const J = new Uint32Array(0);
|
|
576
|
+
function Q(n) {
|
|
577
|
+
const e = X(n);
|
|
578
|
+
return {
|
|
579
|
+
graph: n,
|
|
580
|
+
nodeCount: n.nodeCount,
|
|
581
|
+
edgeCount: n.edgeCount,
|
|
582
|
+
mintEdgeId: (t) => e.idOf(t),
|
|
583
|
+
edgeIds: null,
|
|
584
|
+
nodeColumns: /* @__PURE__ */ new Map(),
|
|
585
|
+
edgeColumns: /* @__PURE__ */ new Map(),
|
|
586
|
+
nodeMeasured: /* @__PURE__ */ new Map(),
|
|
587
|
+
edgeMeasured: /* @__PURE__ */ new Map()
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function Y(n) {
|
|
591
|
+
if (n === null)
|
|
592
|
+
return null;
|
|
593
|
+
const e = n.meta.default;
|
|
594
|
+
return { column: n, defaultPresent: e != null };
|
|
595
|
+
}
|
|
596
|
+
function ee(n, e) {
|
|
597
|
+
if (!(e < 0 || e >= n.column.length))
|
|
598
|
+
return n.column.value(e);
|
|
599
|
+
}
|
|
600
|
+
function te(n, e) {
|
|
601
|
+
return n.column.isSet(e) ? !0 : n.defaultPresent && e >= 0 && e < n.column.length;
|
|
602
|
+
}
|
|
603
|
+
function k(n) {
|
|
604
|
+
return n != null;
|
|
605
|
+
}
|
|
606
|
+
function ce(n) {
|
|
607
|
+
const { snapshot: e, records: t } = n, r = n.results, d = /* @__PURE__ */ new Map();
|
|
608
|
+
let f = null;
|
|
609
|
+
const c = () => {
|
|
610
|
+
const s = e();
|
|
611
|
+
return (f === null || f.graph !== s) && (f = Q(s)), f;
|
|
612
|
+
}, g = (s) => {
|
|
613
|
+
const o = d.get(s);
|
|
614
|
+
if (o !== void 0)
|
|
615
|
+
return o;
|
|
616
|
+
const a = Z(s);
|
|
617
|
+
return d.set(s, a), a;
|
|
618
|
+
}, h = (s, o, a) => {
|
|
619
|
+
const i = o === "node" ? s.nodeColumns : s.edgeColumns, u = i.get(a);
|
|
620
|
+
if (u !== void 0)
|
|
621
|
+
return u;
|
|
622
|
+
const m = o === "node" ? s.graph.nodes : s.graph.edges, y = Y(m.get(a));
|
|
623
|
+
return i.set(a, y), y;
|
|
624
|
+
}, l = (s, o) => {
|
|
625
|
+
s.edgeIds ??= new Array(s.edgeCount);
|
|
626
|
+
const a = s.edgeIds[o];
|
|
627
|
+
if (a !== void 0)
|
|
628
|
+
return a;
|
|
629
|
+
const i = s.mintEdgeId(o);
|
|
630
|
+
return s.edgeIds[o] = i, i;
|
|
631
|
+
}, p = (s, o, a, i) => {
|
|
632
|
+
const u = r?.(i);
|
|
633
|
+
if (u !== void 0)
|
|
634
|
+
return o === "node" ? a >= 0 && a < s.nodeCount ? u.node(s.graph.ids.idOf(a)) : void 0 : a >= 0 && a < s.edgeCount ? u.edge(l(s, a)) : void 0;
|
|
635
|
+
}, $ = (s, o, a, i) => o === "edge" ? a < 0 || a >= s.edgeCount ? void 0 : A(s, o, a, i) ?? K(s.graph, a, i) : A(s, o, a, i), A = (s, o, a, i) => {
|
|
636
|
+
const u = h(s, o, i);
|
|
637
|
+
if (u !== null)
|
|
638
|
+
return ee(u, a);
|
|
639
|
+
if (t !== void 0) {
|
|
640
|
+
if (o === "edge")
|
|
641
|
+
return t.edgeAttributes(a)?.[i];
|
|
642
|
+
if (!(a < 0 || a >= s.nodeCount))
|
|
643
|
+
return t.nodeAttributes(a, s.graph.ids.idOf(a))?.[i];
|
|
644
|
+
}
|
|
645
|
+
}, b = (s, o, a) => {
|
|
646
|
+
const i = g(a);
|
|
647
|
+
if (i.kind === "none")
|
|
648
|
+
return;
|
|
649
|
+
const u = c();
|
|
650
|
+
return i.kind === "result" ? p(u, s, o, i.runId)?.[i.field] : $(u, s, o, i.key);
|
|
651
|
+
}, T = (s, o, a) => {
|
|
652
|
+
const i = g(a);
|
|
653
|
+
if (i.kind === "none")
|
|
654
|
+
return !1;
|
|
655
|
+
const u = c();
|
|
656
|
+
if (i.kind === "result")
|
|
657
|
+
return k(p(u, s, o, i.runId)?.[i.field]);
|
|
658
|
+
if (s === "edge" && (i.key === "source" || i.key === "target"))
|
|
659
|
+
return k($(u, s, o, i.key));
|
|
660
|
+
const m = h(u, s, i.key);
|
|
661
|
+
return m !== null ? te(m, o) : k($(u, s, o, i.key));
|
|
662
|
+
}, _ = (s, o, a, i) => {
|
|
663
|
+
if (i === void 0)
|
|
664
|
+
return J;
|
|
665
|
+
const u = o === "node" ? s.nodeCount : s.edgeCount, m = o === "node" ? (w) => i.node(s.graph.ids.idOf(w)) : (w) => i.edge(l(s, w)), y = new Uint32Array(u);
|
|
666
|
+
let v = 0;
|
|
667
|
+
for (let w = 0; w < u; w++)
|
|
668
|
+
k(m(w)?.[a.field]) && (y[v] = w, v++);
|
|
669
|
+
return v === u ? y : y.slice(0, v);
|
|
670
|
+
};
|
|
671
|
+
return {
|
|
672
|
+
nodeValue: (s, o) => b("node", s, o),
|
|
673
|
+
edgeValue: (s, o) => b("edge", s, o),
|
|
674
|
+
nodeHas: (s, o) => T("node", s, o),
|
|
675
|
+
edgeHas: (s, o) => T("edge", s, o),
|
|
676
|
+
nodeIdOf: (s) => c().graph.ids.idOf(s),
|
|
677
|
+
edgeIdOf: (s) => {
|
|
678
|
+
const o = c();
|
|
679
|
+
return l(o, s);
|
|
680
|
+
},
|
|
681
|
+
measured: (s, o) => {
|
|
682
|
+
const a = g(s);
|
|
683
|
+
if (a.kind !== "result")
|
|
684
|
+
return;
|
|
685
|
+
const i = c(), u = o === "node" ? i.nodeMeasured : i.edgeMeasured, m = r?.(a.runId), y = u.get(s);
|
|
686
|
+
if (y !== void 0 && y.result === m)
|
|
687
|
+
return y.indices;
|
|
688
|
+
const v = _(i, o, a, m);
|
|
689
|
+
return u.set(s, { result: m, indices: v }), v;
|
|
690
|
+
},
|
|
691
|
+
topCut: (s, o, a) => {
|
|
692
|
+
const i = g(s), u = i.kind === "result" ? r?.(i.runId) : void 0, m = u?.fields.find((y) => y.name === i.field);
|
|
693
|
+
if (!(u === void 0 || m?.kind !== o || m.type !== "number" && m.type !== "integer"))
|
|
694
|
+
return u.top(i.field, a).entries.at(-1)?.value;
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
}
|
|
531
698
|
export {
|
|
532
|
-
|
|
533
|
-
|
|
699
|
+
M as D,
|
|
700
|
+
W as E,
|
|
701
|
+
K as a,
|
|
702
|
+
ce as c,
|
|
703
|
+
X as e,
|
|
704
|
+
de as n
|
|
534
705
|
};
|