@matdata/yasgui-explain-plugin 0.0.0-stage → 1.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.
Files changed (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +90 -2
  3. package/dist/ExplainPlugin.d.ts +64 -0
  4. package/dist/ExplainPlugin.d.ts.map +1 -0
  5. package/dist/algebra/print.d.ts +21 -0
  6. package/dist/algebra/print.d.ts.map +1 -0
  7. package/dist/algebra/terms.d.ts +18 -0
  8. package/dist/algebra/terms.d.ts.map +1 -0
  9. package/dist/algebra/translate.d.ts +19 -0
  10. package/dist/algebra/translate.d.ts.map +1 -0
  11. package/dist/engines/blazegraph.d.ts +12 -0
  12. package/dist/engines/blazegraph.d.ts.map +1 -0
  13. package/dist/engines/graphdb.d.ts +23 -0
  14. package/dist/engines/graphdb.d.ts.map +1 -0
  15. package/dist/engines/index.d.ts +23 -0
  16. package/dist/engines/index.d.ts.map +1 -0
  17. package/dist/engines/neptune.d.ts +11 -0
  18. package/dist/engines/neptune.d.ts.map +1 -0
  19. package/dist/engines/qlever.d.ts +35 -0
  20. package/dist/engines/qlever.d.ts.map +1 -0
  21. package/dist/engines/stardog.d.ts +14 -0
  22. package/dist/engines/stardog.d.ts.map +1 -0
  23. package/dist/host.d.ts +24 -0
  24. package/dist/host.d.ts.map +1 -0
  25. package/dist/icons.d.ts +22 -0
  26. package/dist/icons.d.ts.map +1 -0
  27. package/dist/index.d.ts +17 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/render.d.ts +46 -0
  30. package/dist/render.d.ts.map +1 -0
  31. package/dist/settings.d.ts +11 -0
  32. package/dist/settings.d.ts.map +1 -0
  33. package/dist/types.d.ts +141 -0
  34. package/dist/types.d.ts.map +1 -0
  35. package/dist/yasgui-explain-plugin.cjs.js +20519 -0
  36. package/dist/yasgui-explain-plugin.cjs.js.map +7 -0
  37. package/dist/yasgui-explain-plugin.css +354 -0
  38. package/dist/yasgui-explain-plugin.esm.js +20513 -0
  39. package/dist/yasgui-explain-plugin.esm.js.map +7 -0
  40. package/dist/yasgui-explain-plugin.min.css +1 -0
  41. package/dist/yasgui-explain-plugin.min.js +146 -0
  42. package/dist/yasgui-explain-plugin.min.js.map +7 -0
  43. package/package.json +71 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,91 @@
1
- # Temporary Holding Version
1
+ # YASGUI Explain Plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/@matdata/yasgui-explain-plugin.svg)](https://www.npmjs.com/package/@matdata/yasgui-explain-plugin)
4
+ [![CI](https://github.com/Matdata-eu/yasgui-explain-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/Matdata-eu/yasgui-explain-plugin/actions/workflows/ci.yml)
5
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
6
+
7
+ An **Explain** result view for [YASGUI](https://github.com/TriplyDB/Yasgui) and [MatGUI](https://github.com/Matdata-eu/MatGUI) that shows how a SPARQL query is executed:
8
+
9
+ - **Execution plan**: the operations the triple store ran for your query, with the rows and the time of each, asked from the endpoint after the query completed. Supported engines: QLever, GraphDB, Stardog, Blazegraph and Amazon Neptune.
10
+ - **Algebra**: the query translated to SPARQL algebra (section 18 of the SPARQL specification), computed in the browser for any endpoint, as a collapsible tree and as the s-expression used by ARQ and the specification.
11
+
12
+ **[Live demo](https://matdata-eu.github.io/yasgui-explain-plugin/)**
13
+
14
+ ![Execution plan of a QLever query, with the time of each operation](https://raw.githubusercontent.com/Matdata-eu/yasgui-explain-plugin/main/docs/explain-qlever.png)
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @matdata/yasgui-explain-plugin
20
+ ```
21
+
22
+ Or from a CDN:
23
+
24
+ ```html
25
+ <script src="https://unpkg.com/@matdata/yasgui-explain-plugin/dist/yasgui-explain-plugin.min.js"></script>
26
+ <link rel="stylesheet" href="https://unpkg.com/@matdata/yasgui-explain-plugin/dist/yasgui-explain-plugin.min.css" />
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```javascript
32
+ import Yasgui from '@matdata/yasgui';
33
+ import ExplainPlugin from '@matdata/yasgui-explain-plugin';
34
+ import '@matdata/yasgui-explain-plugin/dist/yasgui-explain-plugin.css';
35
+
36
+ Yasgui.Yasr.registerPlugin('Explain', ExplainPlugin);
37
+
38
+ const yasgui = new Yasgui(document.getElementById('yasgui'), {
39
+ yasr: { pluginOrder: ['Table', 'response', 'Explain'] },
40
+ });
41
+ ```
42
+
43
+ With the CDN build, the plugin registers itself as `Explain` when `Yasgui` is a global; otherwise register `YasguiExplainPlugin` yourself.
44
+
45
+ Run a query, then open the **Explain** tab. The algebra is there at once. The plan is fetched from the endpoint with one background request, when the plugin knows which engine the endpoint runs; pick the engine in the **Engine** list when it is not recognised from the URL. The choice is remembered per endpoint.
46
+
47
+ ## Engines
48
+
49
+ | Engine | How the plan is asked | What you get |
50
+ |---|---|---|
51
+ | QLever | the query again, with `Accept: application/qlever-results+json` (served from QLever's cache) | the operation tree with the time, rows and cache status of each operation, and the slowest one highlighted |
52
+ | GraphDB | the query with `FROM <http://www.ontotext.com/explain>` | the plan as text: the order of the patterns and the estimated sizes |
53
+ | Stardog | `/{db}/explain` with `profile=true` | the profiled plan as text: rows, wall time and memory per operator |
54
+ | Blazegraph | the query with `explain=details` | Blazegraph's explain page, in a sandboxed frame |
55
+ | Neptune | the query with `explain=details` | Neptune's explain table as text |
56
+
57
+ Virtuoso, Jena Fuseki, Oxigraph, RDF4J and Comunica publish no plan over the SPARQL protocol: the view then shows the algebra only.
58
+
59
+ Only MatGUI's YASR runs the plan request with the authentication and request settings of the tab. In other hosts the plugin sends the request itself, without them. Stardog, Blazegraph and Neptune need extra request parameters, which MatGUI passes on from version 6.9 (`yasr.hostApi.queryRequest`); older hosts send those requests directly too.
60
+
61
+ ## Options
62
+
63
+ Options go in the plugin constructor, or in `yasr.config.plugins.Explain.dynamicConfig`:
64
+
65
+ | Option | Default | Meaning |
66
+ |---|---|---|
67
+ | `engine` | detect | Force an engine (`qlever`, `graphdb`, `stardog`, `blazegraph`, `neptune`) or `none` for every endpoint |
68
+ | `engines` | all | The engines offered in the list, in order |
69
+ | `autoFetch` | `true` | Fetch the plan when the view opens; with `false`, the Refresh button does |
70
+ | `getQuery` | the host's query link | A function returning the query text |
71
+ | `getEndpoint` | the host's query link | A function returning the endpoint URL |
72
+ | `baseIRI` | `http://base/` | Base for relative IRIs in the algebra |
73
+ | `requestPlan` | the host or `fetch` | `(request, signal) => Promise<response>` to send the plan request yourself |
74
+
75
+ The plugin also exports `translate(query)`, `toTree(algebra, prefixes)`, `toSExpression(algebra, prefixes)` and `detectEngine(url)` for use outside YASR.
76
+
77
+ ## Development
78
+
79
+ ```bash
80
+ npm install
81
+ npm run dev # demo at http://localhost:5173
82
+ npm test
83
+ npm run build # dist/
84
+ npm run build:demo # demo/dist, published to GitHub Pages
85
+ ```
86
+
87
+ The demo opens on a QLever endpoint, with buttons for public QLever, GraphDB, Blazegraph and Stardog endpoints; the sample buttons show recorded plans without an endpoint (`?sample=qlever|graphdb|stardog`).
88
+
89
+ ## License
90
+
91
+ Apache-2.0
@@ -0,0 +1,64 @@
1
+ /**
2
+ * YASGUI Explain plugin
3
+ *
4
+ * A YASR result view with two parts:
5
+ * - the execution plan of the query, asked from the endpoint's engine with one
6
+ * background request after the query ran (QLever, GraphDB, Stardog,
7
+ * Blazegraph, Neptune), and
8
+ * - the SPARQL algebra of the query, computed in the browser for any endpoint.
9
+ */
10
+ import type { ExplainPluginOptions, Yasr } from './types';
11
+ export declare class ExplainPlugin {
12
+ priority: number;
13
+ label: string;
14
+ helpReference: string;
15
+ private yasr;
16
+ private options;
17
+ private container;
18
+ private hostToolbarNodes;
19
+ private abortController;
20
+ /** Plans already fetched, by engine, endpoint and query */
21
+ private planCache;
22
+ private planState;
23
+ private planSection;
24
+ private algebra;
25
+ private algebraError;
26
+ private algebraText;
27
+ private query;
28
+ private endpoint;
29
+ constructor(yasr: Yasr, options?: ExplainPluginOptions);
30
+ /** Change options after construction; the next draw uses them */
31
+ setOptions(options: Partial<ExplainPluginOptions>): void;
32
+ static get label(): string;
33
+ static get priority(): number;
34
+ getIcon(): Element | undefined;
35
+ /** The view is useful for any response, including failed ones: the algebra never needs results */
36
+ canHandleResults(): boolean;
37
+ private getPluginName;
38
+ private getOptions;
39
+ /** The prefixes of the query (and of the host), with the usual RDF ones as a fallback */
40
+ private getPrefixes;
41
+ private readQueryAndEndpoint;
42
+ private serverHeader;
43
+ private resolveEngine;
44
+ draw(): void;
45
+ private drawToolbar;
46
+ private drawPlanSection;
47
+ private fetchPlan;
48
+ /** Send the plan request through the host (with the tab's settings) or, failing that, directly */
49
+ private runRequest;
50
+ private showPlan;
51
+ private addTreeActions;
52
+ private drawAlgebraSection;
53
+ /** YASR's download button saves the plan and the algebra as text */
54
+ download(filename?: string): {
55
+ getData: () => string;
56
+ contentType: string;
57
+ filename: string;
58
+ title: string;
59
+ } | undefined;
60
+ private cleanup;
61
+ destroy(): void;
62
+ }
63
+ export default ExplainPlugin;
64
+ //# sourceMappingURL=ExplainPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExplainPlugin.d.ts","sourceRoot":"","sources":["../src/ExplainPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAGV,oBAAoB,EAIpB,IAAI,EACL,MAAM,SAAS,CAAC;AAmCjB,qBAAa,aAAa;IACxB,QAAQ,SAAK;IACb,KAAK,SAAa;IAClB,aAAa,SAAgE;IAE7E,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,eAAe,CAAgC;IACvD,2DAA2D;IAC3D,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,WAAW,CAA2C;IAC9D,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,QAAQ,CAAqB;gBAEzB,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,oBAAyB;IAK1D,iEAAiE;IACjE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;IAIxD,MAAM,KAAK,KAAK,IAAI,MAAM,CAEzB;IAED,MAAM,KAAK,QAAQ,IAAI,MAAM,CAE5B;IAED,OAAO,IAAI,OAAO,GAAG,SAAS;IAM9B,kGAAkG;IAClG,gBAAgB,IAAI,OAAO;IAI3B,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,UAAU;IAQlB,yFAAyF;IACzF,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,aAAa;IAKrB,IAAI,IAAI,IAAI;IAuBZ,OAAO,CAAC,WAAW;IAiEnB,OAAO,CAAC,eAAe;YA2CT,SAAS;IAkDvB,kGAAkG;YACpF,UAAU;IAoCxB,OAAO,CAAC,QAAQ;IAwBhB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,kBAAkB;IA6B1B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM;;;;;;IAyB1B,OAAO,CAAC,OAAO;IAUf,OAAO,IAAI,IAAI;CAIhB;AAoBD,eAAe,aAAa,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Two views of an algebra expression: a tree for the screen, and the
3
+ * s-expression text (the notation of ARQ and the SPARQL specification
4
+ * examples) for copying into issues and documentation.
5
+ */
6
+ import { type Prefixes } from './terms';
7
+ /** One node of the algebra tree shown on screen */
8
+ export interface AlgebraNode {
9
+ /** The operator, e.g. "project" */
10
+ operator: string;
11
+ /** Its arguments on the same line, e.g. "?s ?n" */
12
+ args?: string;
13
+ /** Lines below the operator, e.g. the triples of a bgp */
14
+ details?: string[];
15
+ children: AlgebraNode[];
16
+ }
17
+ /** Build the screen tree of an algebra expression */
18
+ export declare function toTree(algebra: any, prefixes?: Prefixes): AlgebraNode;
19
+ /** The s-expression of an algebra expression, in the style of ARQ's `qparse --print=op` */
20
+ export declare function toSExpression(algebra: any, prefixes?: Prefixes): string;
21
+ //# sourceMappingURL=print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../src/algebra/print.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoD,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1F,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAUD,qDAAqD;AACrD,wBAAgB,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAE,QAAa,GAAG,WAAW,CAqJzE;AAmBD,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAE,QAAa,GAAG,MAAM,CAI3E"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Printing RDF/JS terms, expressions and property paths in SPARQL syntax,
3
+ * with IRIs shortened by the prefixes of the query.
4
+ */
5
+ export interface Prefixes {
6
+ [prefix: string]: string;
7
+ }
8
+ /** Shorten an IRI with the longest matching prefix, else write it in angle brackets */
9
+ export declare function printIri(iri: string, prefixes?: Prefixes): string;
10
+ /** An RDF/JS term as SPARQL text */
11
+ export declare function printTerm(term: any, prefixes?: Prefixes): string;
12
+ /** A triple or quad pattern as `?s <p> ?o` (a non-default graph is appended as `@ <g>`) */
13
+ export declare function printQuad(quad: any, prefixes?: Prefixes): string;
14
+ /** A property path in SPARQL syntax */
15
+ export declare function printPath(path: any, prefixes?: Prefixes, parent?: 'alt' | 'seq' | 'unary' | undefined): string;
16
+ /** An expression in SPARQL-like prefix notation, e.g. `(> ?o 3)` or `(count ?o)` */
17
+ export declare function printExpression(expression: any, prefixes?: Prefixes): string;
18
+ //# sourceMappingURL=terms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terms.d.ts","sourceRoot":"","sources":["../../src/algebra/terms.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,QAAQ;IACvB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAKD,uFAAuF;AACvF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAa,GAAG,MAAM,CAWrE;AAED,oCAAoC;AACpC,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAE,QAAa,GAAG,MAAM,CAgCpE;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAE,QAAa,GAAG,MAAM,CASpE;AAcD,uCAAuC;AACvC,wBAAgB,SAAS,CACvB,IAAI,EAAE,GAAG,EACT,QAAQ,GAAE,QAAa,EACvB,MAAM,GAAE,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,SAAqB,GACtD,MAAM,CA8BR;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,GAAE,QAAa,GAAG,MAAM,CAgChF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * From query text to SPARQL algebra, with traqula (the comunica parser and
3
+ * algebra transformer for SPARQL 1.2).
4
+ */
5
+ export type Algebra = any;
6
+ export interface TranslateOptions {
7
+ /** Base IRI for relative IRIs; a placeholder is used when the query has none */
8
+ baseIRI?: string;
9
+ }
10
+ /** The base used when the query has no BASE: relative IRIs then print as `<http://base/...>` */
11
+ export declare const DEFAULT_BASE_IRI = "http://base/";
12
+ export declare class AlgebraError extends Error {
13
+ constructor(message: string);
14
+ }
15
+ /** Translate a query to its algebra, or throw an AlgebraError with the parser's message */
16
+ export declare function translate(query: string, options?: TranslateOptions): Algebra;
17
+ /** The parser's messages list every token it expected; keep the readable head */
18
+ export declare function cleanParseMessage(error: unknown): string;
19
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/algebra/translate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAID,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAqBhF;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAexD"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Blazegraph
3
+ *
4
+ * With the `explain` request parameter, Blazegraph answers with an HTML page
5
+ * instead of the results: the query, its abstract syntax tree, the operator
6
+ * plan and, with `explain=details`, a table of statistics per operator. The
7
+ * plugin shows that page in a sandboxed frame.
8
+ */
9
+ import type { Engine, Plan } from '../types';
10
+ export declare function parseBlazegraphResponse(body: string, contentType: string | undefined): Plan;
11
+ export declare const blazegraph: Engine;
12
+ //# sourceMappingURL=blazegraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blazegraph.d.ts","sourceRoot":"","sources":["../../src/engines/blazegraph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAY3F;AAED,eAAO,MAAM,UAAU,EAAE,MAYxB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Ontotext GraphDB
3
+ *
4
+ * GraphDB explains a query when it reads from the pseudo graph
5
+ * `onto:explain` (http://www.ontotext.com/explain): the response is then the
6
+ * plan as text, with the chosen order of the triple patterns and the estimated
7
+ * collection sizes, instead of the results. RDF4J shares the `/repositories/`
8
+ * URL layout but has no explain, so the request fails there.
9
+ */
10
+ import type { Engine, Plan } from '../types';
11
+ export declare const EXPLAIN_GRAPH = "http://www.ontotext.com/explain";
12
+ /**
13
+ * Add `FROM <onto:explain>` to a query. The clause goes right before the
14
+ * WHERE keyword (or the group graph pattern when WHERE is omitted), skipping
15
+ * comments, strings and IRIs so the words inside them are left alone.
16
+ */
17
+ export declare function addExplainGraph(query: string): string;
18
+ /** Offset of the first WHERE keyword or, without one, of the first `{` after the query form */
19
+ export declare function findWhereOffset(query: string): number;
20
+ /** The plan is text, but some clients get it wrapped in a SPARQL result: unwrap it */
21
+ export declare function parseGraphdbResponse(body: string, contentType: string | undefined): Plan;
22
+ export declare const graphdb: Engine;
23
+ //# sourceMappingURL=graphdb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphdb.d.ts","sourceRoot":"","sources":["../../src/engines/graphdb.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,aAAa,oCAAoC,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQrD;AAED,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA0DrD;AAmBD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAgCxF;AAED,eAAO,MAAM,OAAO,EAAE,MAerB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The engines the plugin can ask for an execution plan, and how to tell which
3
+ * one an endpoint runs.
4
+ */
5
+ import type { Engine, EngineChoice, EngineId } from '../types';
6
+ export declare const ENGINES: Record<EngineId, Engine>;
7
+ export declare const ENGINE_IDS: EngineId[];
8
+ export declare function isEngineId(value: unknown): value is EngineId;
9
+ export declare function isEngineChoice(value: unknown): value is EngineChoice;
10
+ /**
11
+ * Guess the engine behind an endpoint from its URL and, when the host exposes
12
+ * them, the response headers of the last query. Undefined when nothing matches:
13
+ * the user can then pick the engine by hand.
14
+ */
15
+ export declare function detectEngine(endpoint: string | undefined, serverHeader?: string | null): EngineId | undefined;
16
+ /** How the engine was chosen, for the toolbar */
17
+ export interface ResolvedEngine {
18
+ engine: Engine | undefined;
19
+ /** "stored" when the user picked it, "detected" when guessed, "none" when neither */
20
+ source: 'stored' | 'detected' | 'forced' | 'none';
21
+ }
22
+ export declare function resolveEngine(choice: EngineChoice, endpoint: string | undefined, serverHeader?: string | null, forced?: EngineChoice): ResolvedEngine;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engines/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAO/D,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAqD,CAAC;AAEnG,eAAO,MAAM,UAAU,EAAE,QAAQ,EAA8D,CAAC;AAEhG,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAC3B,QAAQ,GAAG,SAAS,CA6BtB;AAED,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,qFAAqF;IACrF,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;CACnD;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAC5B,MAAM,CAAC,EAAE,YAAY,GACpB,cAAc,CAShB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Amazon Neptune
3
+ *
4
+ * Neptune explains a query with the `explain` request parameter
5
+ * (`explain=details` adds the estimates and the time per operator). The
6
+ * response is a text table, one row per operator.
7
+ */
8
+ import type { Engine, Plan } from '../types';
9
+ export declare function parseNeptuneResponse(body: string, contentType: string | undefined): Plan;
10
+ export declare const neptune: Engine;
11
+ //# sourceMappingURL=neptune.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neptune.d.ts","sourceRoot":"","sources":["../../src/engines/neptune.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAsBxF;AAED,eAAO,MAAM,OAAO,EAAE,MAWrB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * QLever (https://github.com/ad-freiburg/qlever)
3
+ *
4
+ * With `Accept: application/qlever-results+json`, QLever returns its results
5
+ * together with `runtimeInformation`: the tree of operations it executed, with
6
+ * the time and the number of rows of each. The plugin re-sends the query with
7
+ * that Accept header once the user's query has completed: QLever answers from
8
+ * its result cache, and cached operations keep their original times in their
9
+ * details.
10
+ */
11
+ import type { Engine, Plan, PlanNode } from '../types';
12
+ /** A node of QLever's `query_execution_tree` (newer) or `runtimeInformation` (older) */
13
+ interface QleverNode {
14
+ description?: string;
15
+ operation_time?: number;
16
+ total_time?: number;
17
+ result_rows?: number;
18
+ result_cols?: number;
19
+ column_names?: string[];
20
+ cache_status?: string;
21
+ was_cached?: boolean;
22
+ status?: string;
23
+ estimated_size?: number;
24
+ estimated_operation_cost?: number;
25
+ estimated_column_multiplicities?: number[];
26
+ details?: Record<string, unknown>;
27
+ children?: QleverNode[];
28
+ }
29
+ /** Convert one QLever node (and its children) to a plan node */
30
+ export declare function toPlanNode(node: QleverNode): PlanNode;
31
+ /** Parse a `application/qlever-results+json` response into a plan */
32
+ export declare function parseQleverResponse(body: string): Plan;
33
+ export declare const qlever: Engine;
34
+ export {};
35
+ //# sourceMappingURL=qlever.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qlever.d.ts","sourceRoot":"","sources":["../../src/engines/qlever.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIvD,wFAAwF;AACxF,UAAU,UAAU;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,+BAA+B,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAeD,gEAAgE;AAChE,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,CAsCrD;AAQD,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAyCtD;AAED,eAAO,MAAM,MAAM,EAAE,MAYpB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Stardog
3
+ *
4
+ * Stardog explains a query on `GET|POST /{db}/explain` with the same `query`
5
+ * parameter as `/{db}/query`. With `profile=true` the plan carries the actual
6
+ * rows, wall time and memory of each operator; without it only estimates.
7
+ * The response is the plan as text.
8
+ */
9
+ import type { Engine, Plan } from '../types';
10
+ /** `https://host:5820/mydb/query` becomes `https://host:5820/mydb/explain` */
11
+ export declare function explainUrl(endpoint: string): string;
12
+ export declare function parseStardogResponse(body: string): Plan;
13
+ export declare const stardog: Engine;
14
+ //# sourceMappingURL=stardog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stardog.d.ts","sourceRoot":"","sources":["../../src/engines/stardog.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE7C,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOnD;AAOD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAiBvD;AAED,eAAO,MAAM,OAAO,EAAE,MAgBrB,CAAC"}
package/dist/host.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Feature detection for the YASR host API
3
+ *
4
+ * Newer YASR versions (MatGUI) offer a toolbar slot and pass extra request
5
+ * options to background queries. Older ones don't: the plugin then draws its
6
+ * own toolbar and, when a request needs options the host can't pass, sends
7
+ * the request itself without the tab's authentication.
8
+ */
9
+ import type { Yasr } from './types';
10
+ /** The host's plugin toolbar slot, or null when the host has none */
11
+ export declare function getHostToolbar(yasr: Yasr | null | undefined): HTMLDivElement | null;
12
+ /** True when `yasr.executeQuery` passes `extraArgs` and `endpoint` to the request */
13
+ export declare function hasHostRequestOptions(yasr: Yasr | null | undefined): boolean;
14
+ /** True when the host runs background queries with the tab's settings */
15
+ export declare function hasHostExecuteQuery(yasr: Yasr | null | undefined): boolean;
16
+ /**
17
+ * The current query and endpoint, read from the host's plain query link
18
+ * (`endpoint?query=...&default-graph-uri=...`).
19
+ */
20
+ export declare function readQueryLink(yasr: Yasr | null | undefined): {
21
+ query?: string;
22
+ endpoint?: string;
23
+ };
24
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc,GAAG,IAAI,CASnF;AAED,qFAAqF;AACrF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE5E;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE1E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAiBA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Inline Lucide icons (https://lucide.dev, ISC licence)
3
+ *
4
+ * Only the few icons the plugin needs are inlined, so there is no icon font
5
+ * or runtime dependency. They are stroke icons drawn in `currentColor`.
6
+ */
7
+ declare const ICON_PATHS: {
8
+ readonly 'list-tree': string;
9
+ readonly 'chevron-down': "<path d=\"m6 9 6 6 6-6\"/>";
10
+ readonly 'chevron-right': "<path d=\"m9 18 6-6-6-6\"/>";
11
+ readonly copy: string;
12
+ readonly 'rotate-ccw': "<path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><path d=\"M3 3v5h5\"/>";
13
+ readonly 'unfold-vertical': string;
14
+ readonly 'fold-vertical': string;
15
+ };
16
+ export type IconName = keyof typeof ICON_PATHS;
17
+ /** SVG markup of a Lucide icon (decorative: hidden from assistive technology) */
18
+ export declare function iconSvg(name: IconName, size?: number, strokeWidth?: number): string;
19
+ /** A Lucide icon as a DOM element */
20
+ export declare function icon(name: IconName, size?: number, strokeWidth?: number): SVGElement;
21
+ export {};
22
+ //# sourceMappingURL=icons.d.ts.map