@loaders.gl/core 5.0.0-beta.6 → 5.0.0-beta.8
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/arrow-geometry/geojson-table.cjs +26 -15
- package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
- package/dist/arrow-geometry/geojson-table.d.ts +8 -1
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +18 -9
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/cluster-source.cjs +78 -8
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/dist.dev.js +354 -319
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +187 -179
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.d.ts.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
- package/dist/index.cjs +351 -281
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/create-data-source.d.ts +14 -9
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +55 -45
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +11 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +3 -2
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +3 -3
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +14 -18
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +7 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +11 -64
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +5 -3
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +12 -7
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +5 -3
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +14 -3
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +5 -3
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +8 -6
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +5 -3
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +26 -15
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts +4 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +43 -40
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +1 -1
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +2 -37
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +2 -63
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +11 -0
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
- package/dist/lib/loader-utils/native-arrow.js +52 -0
- package/dist/lib/loader-utils/native-arrow.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.js +2 -2
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +21 -10
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/loader-utils/index.cjs +143 -42
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +2 -2
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts +24 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +32 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +5 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +13 -5
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +5 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +27 -20
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +3 -3
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +15 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +102 -27
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/source-types.d.ts +5 -5
- package/dist/loader-utils/source-types.d.ts.map +1 -1
- package/dist/loader-utils/source-types.js +5 -1
- package/dist/loader-utils/source-types.js.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/polyfills/index.cjs +3 -2
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +2 -2
- package/dist/polyfills/index.js.map +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +110 -0
- package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
- package/dist/scan/arrow-execution/expressions.d.ts +9 -0
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
- package/dist/scan/arrow-execution/expressions.js +60 -0
- package/dist/scan/arrow-execution/expressions.js.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +15 -3
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +2 -2
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +2 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +10 -2
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/index.cjs +21 -6
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +1 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +1 -7
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -307
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-progressive.cjs +191 -0
- package/dist/scan/query-progressive.cjs.map +7 -0
- package/dist/scan/query-progressive.d.ts +39 -0
- package/dist/scan/query-progressive.d.ts.map +1 -0
- package/dist/scan/query-progressive.js +174 -0
- package/dist/scan/query-progressive.js.map +1 -0
- package/dist/scan/query.cjs +143 -22
- package/dist/scan/query.cjs.map +3 -3
- package/dist/scan/query.d.ts +27 -9
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +180 -18
- package/dist/scan/query.js.map +1 -1
- package/dist/schema-utils/index.cjs +262 -241
- package/dist/schema-utils/index.cjs.map +2 -2
- package/dist/schema-utils/index.d.ts +1 -0
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +1 -0
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +28 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +26 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +12 -4
- package/dist/vector-table-scan-source.cjs.map +1 -1
- package/dist/worker-utils/index.cjs +49 -9
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +2 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/package.json +8 -7
- package/src/arrow-geometry/geojson-table.ts +27 -17
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
- package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
- package/src/index.ts +1 -1
- package/src/lib/api/create-data-source.ts +136 -58
- package/src/lib/api/encode.ts +14 -3
- package/src/lib/api/load-in-batches.ts +15 -7
- package/src/lib/api/load-loader.ts +21 -20
- package/src/lib/api/load.ts +49 -121
- package/src/lib/api/parse-file.ts +42 -23
- package/src/lib/api/parse-in-batches.ts +49 -12
- package/src/lib/api/parse-sync.ts +37 -19
- package/src/lib/api/parse.ts +51 -30
- package/src/lib/api/select-loader.ts +56 -53
- package/src/lib/api/select-source.ts +7 -1
- package/src/lib/loader-utils/loggers.ts +2 -70
- package/src/lib/loader-utils/native-arrow.ts +70 -0
- package/src/lib/loader-utils/option-defaults.ts +2 -2
- package/src/lib/loader-utils/option-utils.ts +21 -10
- package/src/loader-utils/index.ts +2 -1
- package/src/loader-utils/lib/log-utils/log.ts +39 -1
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +18 -8
- package/src/loader-utils/lib/scan-utils/table-query.ts +10 -1
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +36 -25
- package/src/loader-utils/lib/sources/data-source.ts +3 -3
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +16 -1
- package/src/loader-utils/loader-types.ts +168 -43
- package/src/loader-utils/source-types.ts +12 -6
- package/src/polyfills/index.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +86 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +19 -3
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +8 -367
- package/src/scan/query-progressive.ts +231 -0
- package/src/scan/query.ts +247 -24
- package/src/schema-utils/index.ts +5 -0
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +58 -0
- package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
- package/src/worker-utils/lib/library-utils/library-utils.ts +2 -1
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
- package/dist/scan/parse-sql-query.cjs +0 -70
- package/dist/scan/parse-sql-query.cjs.map +0 -7
- package/dist/scan/parse-sql-query.d.ts +0 -5
- package/dist/scan/parse-sql-query.d.ts.map +0 -1
- package/dist/scan/parse-sql-query.js +0 -49
- package/dist/scan/parse-sql-query.js.map +0 -1
- package/dist/scan/parse-sql-select.cjs +0 -215
- package/dist/scan/parse-sql-select.cjs.map +0 -7
- package/dist/scan/parse-sql-select.d.ts +0 -38
- package/dist/scan/parse-sql-select.d.ts.map +0 -1
- package/dist/scan/parse-sql-select.js +0 -208
- package/dist/scan/parse-sql-select.js.map +0 -1
- package/src/scan/parse-sql-query.ts +0 -53
- package/src/scan/parse-sql-select.ts +0 -220
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ArrowTable, ArrowTableBatch, Table, TableBatch} from '@loaders.gl/core/schema';
|
|
6
|
+
import {convertArrowToTable} from './convert-arrow-table';
|
|
7
|
+
|
|
8
|
+
/** Table layouts supported by the Arrow wrapper adapters. */
|
|
9
|
+
type ArrowTableShape = Exclude<Table['shape'], 'geojson-table'>;
|
|
10
|
+
|
|
11
|
+
/** A converted layout retaining the input wrapper's additional properties. */
|
|
12
|
+
type ConvertedArrowTable<Input, Shape extends ArrowTableShape> = Omit<
|
|
13
|
+
Input,
|
|
14
|
+
'shape' | 'data' | 'schema'
|
|
15
|
+
> &
|
|
16
|
+
Extract<Table, {shape: Shape}>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Converts an Arrow wrapper while preserving its schema and additional metadata.
|
|
20
|
+
* Returns the original wrapper for Arrow output. Other layouts use the existing
|
|
21
|
+
* Arrow conversion semantics, inferring a schema only when the wrapper omits it.
|
|
22
|
+
* @param table Arrow table wrapper.
|
|
23
|
+
* @param shape Requested table layout.
|
|
24
|
+
* @returns Converted table with the input wrapper's metadata.
|
|
25
|
+
*/
|
|
26
|
+
export function convertArrowTable<Input extends ArrowTable, Shape extends ArrowTableShape>(
|
|
27
|
+
table: Input,
|
|
28
|
+
shape: Shape
|
|
29
|
+
): ConvertedArrowTable<Input, Shape>;
|
|
30
|
+
export function convertArrowTable(table: ArrowTable, shape: ArrowTableShape): Table {
|
|
31
|
+
if (shape === table.shape) {
|
|
32
|
+
return table;
|
|
33
|
+
}
|
|
34
|
+
const converted = convertArrowToTable(table.data, shape);
|
|
35
|
+
return {
|
|
36
|
+
...table,
|
|
37
|
+
...converted,
|
|
38
|
+
schema: table.schema ?? converted.schema
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Converts an Arrow batch while retaining length, batch type, progress and metadata.
|
|
44
|
+
* Returns the original batch for Arrow output. Does not combine or buffer batches.
|
|
45
|
+
* @param batch Arrow table batch.
|
|
46
|
+
* @param shape Requested table layout.
|
|
47
|
+
* @returns Converted batch with the input batch's metadata.
|
|
48
|
+
*/
|
|
49
|
+
export function convertArrowTableBatch<
|
|
50
|
+
Input extends ArrowTableBatch,
|
|
51
|
+
Shape extends ArrowTableShape
|
|
52
|
+
>(
|
|
53
|
+
batch: Input,
|
|
54
|
+
shape: Shape
|
|
55
|
+
): ConvertedArrowTable<Input, Shape> & Extract<TableBatch, {shape: Shape}> {
|
|
56
|
+
return convertArrowTable(batch, shape) as ConvertedArrowTable<Input, Shape> &
|
|
57
|
+
Extract<TableBatch, {shape: Shape}>;
|
|
58
|
+
}
|
|
@@ -17,7 +17,7 @@ export function convertToObjectRow(
|
|
|
17
17
|
}
|
|
18
18
|
} else {
|
|
19
19
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
20
|
-
const columnName = `column
|
|
20
|
+
const columnName = `column${i + 1}`;
|
|
21
21
|
objectRow[columnName] = arrayRow[i];
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -47,7 +47,7 @@ export function convertToArrayRow(
|
|
|
47
47
|
export function inferHeadersFromArrayRow(arrayRow: unknown[]) {
|
|
48
48
|
const headers: string[] = [];
|
|
49
49
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
50
|
-
const columnName = `column
|
|
50
|
+
const columnName = `column${i + 1}`;
|
|
51
51
|
headers.push(columnName);
|
|
52
52
|
}
|
|
53
53
|
return headers;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
/* global importScripts */
|
|
6
|
+
import {log as loaderLog} from './../../../loader-utils/lib/log-utils/log';
|
|
6
7
|
import {isBrowser, isWorker} from '../env-utils/globals';
|
|
7
8
|
import {assert} from '../env-utils/assert';
|
|
8
9
|
import {VERSION} from '../env-utils/version';
|
|
@@ -190,7 +191,7 @@ async function loadLibraryFromFile(libraryUrl: string, moduleLibraryUrl: string)
|
|
|
190
191
|
// ignore
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
+
loaderLog.error(String(error))();
|
|
194
195
|
return null;
|
|
195
196
|
}
|
|
196
197
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
/* eslint-disable no-console */
|
|
6
|
+
import {log as loaderLog} from './../../../loader-utils/lib/log-utils/log';
|
|
6
7
|
import {getAvailablePort} from './process-utils';
|
|
7
8
|
|
|
8
9
|
type NodeChildProcess = import('child_process').ChildProcess;
|
|
@@ -44,7 +45,7 @@ const DEFAULT_PROPS: ChildProcessProxyProps = {
|
|
|
44
45
|
autoPort: true,
|
|
45
46
|
wait: 2000,
|
|
46
47
|
onSuccess: processProxy => {
|
|
47
|
-
|
|
48
|
+
loaderLog.log(0, `Started ${processProxy.props.command}`)();
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
51
|
|
|
@@ -91,7 +92,7 @@ export default class ChildProcessProxy {
|
|
|
91
92
|
resolve({});
|
|
92
93
|
});
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
loaderLog.log(0, `Spawning ${props.command} ${props.arguments.join(' ')}`)();
|
|
95
96
|
if (props.spawn?.shell) {
|
|
96
97
|
throw new Error('ChildProcessProxy does not support shell execution');
|
|
97
98
|
}
|
|
@@ -104,22 +105,22 @@ export default class ChildProcessProxy {
|
|
|
104
105
|
this.childProcess = childProcess;
|
|
105
106
|
|
|
106
107
|
childProcess.stdout?.on('data', data => {
|
|
107
|
-
|
|
108
|
+
loaderLog.log(0, data.toString())();
|
|
108
109
|
});
|
|
109
110
|
childProcess.stderr?.on('data', data => {
|
|
110
|
-
|
|
111
|
+
loaderLog.log(0, `Child process wrote to stderr: "${data}".`)();
|
|
111
112
|
if (!props.ignoreStderr) {
|
|
112
113
|
this._clearTimeout();
|
|
113
114
|
reject(new Error(data));
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
117
|
childProcess.on('error', error => {
|
|
117
|
-
|
|
118
|
+
loaderLog.log(0, `Child process errored with ${error}`)();
|
|
118
119
|
this._clearTimeout();
|
|
119
120
|
reject(error);
|
|
120
121
|
});
|
|
121
122
|
childProcess.on('close', code => {
|
|
122
|
-
|
|
123
|
+
loaderLog.log(0, `Child process exited with ${code}`)();
|
|
123
124
|
this.childProcess = null;
|
|
124
125
|
this._clearTimeout();
|
|
125
126
|
resolve({});
|
|
@@ -145,7 +146,7 @@ export default class ChildProcessProxy {
|
|
|
145
146
|
// eslint-disable-next-line no-process-exit
|
|
146
147
|
process.exit(statusCode);
|
|
147
148
|
} catch (error) {
|
|
148
|
-
|
|
149
|
+
loaderLog.error(String((error as Error).message || error))();
|
|
149
150
|
// eslint-disable-next-line no-process-exit
|
|
150
151
|
process.exit(1);
|
|
151
152
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// SPDX-License-Identifier: MIT
|
|
7
7
|
// Copyright (c) vis.gl contributors
|
|
8
8
|
|
|
9
|
+
import {log as loaderLog} from './../../../loader-utils/lib/log-utils/log';
|
|
9
10
|
import type {WorkerObject, WorkerOptions} from '../../types';
|
|
10
11
|
import {assert} from '../env-utils/assert';
|
|
11
12
|
import {isBrowser} from '../env-utils/globals';
|
|
@@ -121,8 +122,8 @@ function warnIfUsingNpmTagFallback(worker: WorkerObject, url: string): void {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
warnedWorkerVersionFallbacks.add(workerId);
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
|
|
126
|
+
loaderLog.warn(
|
|
126
127
|
`loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`
|
|
127
|
-
);
|
|
128
|
+
)();
|
|
128
129
|
}
|
|
@@ -72,10 +72,5 @@ function getLoadableWorkerURLFromSource(workerSource: string): string {
|
|
|
72
72
|
*/
|
|
73
73
|
function buildScriptSource(workerUrl: string): string {
|
|
74
74
|
return `\
|
|
75
|
-
|
|
76
|
-
importScripts('${workerUrl}');
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error(error);
|
|
79
|
-
throw error;
|
|
80
|
-
}`;
|
|
75
|
+
importScripts('${workerUrl}');`;
|
|
81
76
|
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/scan/parse-sql-query.ts
|
|
21
|
-
var parse_sql_query_exports = {};
|
|
22
|
-
__export(parse_sql_query_exports, {
|
|
23
|
-
parseSQLQuery: () => parseSQLQuery
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(parse_sql_query_exports);
|
|
26
|
-
var import_parse_sql_predicate = require("./parse-sql-predicate.cjs");
|
|
27
|
-
var import_parse_sql_select = require("./parse-sql-select.cjs");
|
|
28
|
-
function parseSQLQuery(sql) {
|
|
29
|
-
const reader = new import_parse_sql_select.SQLQueryReader(sql);
|
|
30
|
-
if (reader.takeKeyword("SHOW")) {
|
|
31
|
-
let request;
|
|
32
|
-
if (reader.takeKeyword("SOURCES")) request = { command: "showSources" };
|
|
33
|
-
else {
|
|
34
|
-
reader.expectKeyword("TABLES");
|
|
35
|
-
request = reader.takeKeyword("FROM") ? { command: "showTables", from: reader.identifier() } : { command: "showTables" };
|
|
36
|
-
}
|
|
37
|
-
reader.end();
|
|
38
|
-
return request;
|
|
39
|
-
}
|
|
40
|
-
if (reader.takeKeyword("DESCRIBE")) {
|
|
41
|
-
const source = reader.identifier();
|
|
42
|
-
const from = reader.takeSymbol(".") ? { source, table: reader.identifier() } : source;
|
|
43
|
-
reader.end();
|
|
44
|
-
return { command: "describe", from };
|
|
45
|
-
}
|
|
46
|
-
return (0, import_parse_sql_select.parseSQLSelect)(sql, {
|
|
47
|
-
parseWhere: (expression) => {
|
|
48
|
-
const predicate = (0, import_parse_sql_predicate.parseSQLPredicate)(expression);
|
|
49
|
-
validateColumnReferences(predicate);
|
|
50
|
-
return predicate;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function validateColumnReferences(predicate) {
|
|
55
|
-
if (predicate.op === "and" || predicate.op === "or") {
|
|
56
|
-
predicate.args.forEach(validateColumnReferences);
|
|
57
|
-
} else if (predicate.op === "not") validateColumnReferences(predicate.args[0]);
|
|
58
|
-
else {
|
|
59
|
-
const property = predicate.args[0];
|
|
60
|
-
if (!property.quoted && property.property.includes("."))
|
|
61
|
-
throw new Error(
|
|
62
|
-
"Qualified WHERE columns are not supported; quote literal column names containing dots."
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
-
0 && (module.exports = {
|
|
68
|
-
parseSQLQuery
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=parse-sql-query.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/scan/parse-sql-query.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {TableQuery} from '@loaders.gl/core/loader-utils';\nimport {parseSQLPredicate} from './parse-sql-predicate';\nimport type {BoundSQLPredicate, SQLPredicateProperty} from './sql-predicate-types';\nimport type {SQLCatalogQuery} from './sql-catalog';\nimport {parseSQLSelect, SQLQueryReader} from './parse-sql-select';\n\n/** Parses the supported SELECT subset or SHOW SOURCES, SHOW TABLES and DESCRIBE commands. */\nexport function parseSQLQuery(sql: string): TableQuery | SQLCatalogQuery {\n const reader = new SQLQueryReader(sql);\n if (reader.takeKeyword('SHOW')) {\n let request: SQLCatalogQuery;\n if (reader.takeKeyword('SOURCES')) request = {command: 'showSources'};\n else {\n reader.expectKeyword('TABLES');\n request = reader.takeKeyword('FROM')\n ? {command: 'showTables', from: reader.identifier()}\n : {command: 'showTables'};\n }\n reader.end();\n return request;\n }\n if (reader.takeKeyword('DESCRIBE')) {\n const source = reader.identifier();\n const from = reader.takeSymbol('.') ? {source, table: reader.identifier()} : source;\n reader.end();\n return {command: 'describe', from};\n }\n return parseSQLSelect(sql, {\n parseWhere: expression => {\n const predicate = parseSQLPredicate(expression);\n validateColumnReferences(predicate);\n return predicate;\n }\n });\n}\n\n/** Keeps table qualification distinct from literal dotted source-column names. */\nfunction validateColumnReferences(predicate: BoundSQLPredicate): void {\n if (predicate.op === 'and' || predicate.op === 'or') {\n predicate.args.forEach(validateColumnReferences);\n } else if (predicate.op === 'not') validateColumnReferences(predicate.args[0]);\n else {\n const property = predicate.args[0] as SQLPredicateProperty;\n if (!property.quoted && property.property.includes('.'))\n throw new Error(\n 'Qualified WHERE columns are not supported; quote literal column names containing dots.'\n );\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,iCAAgC;AAGhC,8BAA6C;AAGtC,SAAS,cAAc,KAA2C;AACvE,QAAM,SAAS,IAAI,uCAAe,GAAG;AACrC,MAAI,OAAO,YAAY,MAAM,GAAG;AAC9B,QAAI;AACJ,QAAI,OAAO,YAAY,SAAS,EAAG,WAAU,EAAC,SAAS,cAAa;AAAA,SAC/D;AACH,aAAO,cAAc,QAAQ;AAC7B,gBAAU,OAAO,YAAY,MAAM,IAC/B,EAAC,SAAS,cAAc,MAAM,OAAO,WAAW,EAAC,IACjD,EAAC,SAAS,aAAY;AAAA,IAC5B;AACA,WAAO,IAAI;AACX,WAAO;AAAA,EACT;AACA,MAAI,OAAO,YAAY,UAAU,GAAG;AAClC,UAAM,SAAS,OAAO,WAAW;AACjC,UAAM,OAAO,OAAO,WAAW,GAAG,IAAI,EAAC,QAAQ,OAAO,OAAO,WAAW,EAAC,IAAI;AAC7E,WAAO,IAAI;AACX,WAAO,EAAC,SAAS,YAAY,KAAI;AAAA,EACnC;AACA,aAAO,wCAAe,KAAK;AAAA,IACzB,YAAY,gBAAc;AACxB,YAAM,gBAAY,8CAAkB,UAAU;AAC9C,+BAAyB,SAAS;AAClC,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAGA,SAAS,yBAAyB,WAAoC;AACpE,MAAI,UAAU,OAAO,SAAS,UAAU,OAAO,MAAM;AACnD,cAAU,KAAK,QAAQ,wBAAwB;AAAA,EACjD,WAAW,UAAU,OAAO,MAAO,0BAAyB,UAAU,KAAK,CAAC,CAAC;AAAA,OACxE;AACH,UAAM,WAAW,UAAU,KAAK,CAAC;AACjC,QAAI,CAAC,SAAS,UAAU,SAAS,SAAS,SAAS,GAAG;AACpD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,EACJ;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { TableQuery } from '@loaders.gl/core/loader-utils';
|
|
2
|
-
import type { SQLCatalogQuery } from "./sql-catalog.js";
|
|
3
|
-
/** Parses the supported SELECT subset or SHOW SOURCES, SHOW TABLES and DESCRIBE commands. */
|
|
4
|
-
export declare function parseSQLQuery(sql: string): TableQuery | SQLCatalogQuery;
|
|
5
|
-
//# sourceMappingURL=parse-sql-query.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-sql-query.d.ts","sourceRoot":"","sources":["../../src/scan/parse-sql-query.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAG9D,OAAO,KAAK,EAAC,eAAe,EAAC,yBAAsB;AAGnD,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,CA2BvE"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { parseSQLPredicate } from "./parse-sql-predicate.js";
|
|
5
|
-
import { parseSQLSelect, SQLQueryReader } from "./parse-sql-select.js";
|
|
6
|
-
/** Parses the supported SELECT subset or SHOW SOURCES, SHOW TABLES and DESCRIBE commands. */
|
|
7
|
-
export function parseSQLQuery(sql) {
|
|
8
|
-
const reader = new SQLQueryReader(sql);
|
|
9
|
-
if (reader.takeKeyword('SHOW')) {
|
|
10
|
-
let request;
|
|
11
|
-
if (reader.takeKeyword('SOURCES'))
|
|
12
|
-
request = { command: 'showSources' };
|
|
13
|
-
else {
|
|
14
|
-
reader.expectKeyword('TABLES');
|
|
15
|
-
request = reader.takeKeyword('FROM')
|
|
16
|
-
? { command: 'showTables', from: reader.identifier() }
|
|
17
|
-
: { command: 'showTables' };
|
|
18
|
-
}
|
|
19
|
-
reader.end();
|
|
20
|
-
return request;
|
|
21
|
-
}
|
|
22
|
-
if (reader.takeKeyword('DESCRIBE')) {
|
|
23
|
-
const source = reader.identifier();
|
|
24
|
-
const from = reader.takeSymbol('.') ? { source, table: reader.identifier() } : source;
|
|
25
|
-
reader.end();
|
|
26
|
-
return { command: 'describe', from };
|
|
27
|
-
}
|
|
28
|
-
return parseSQLSelect(sql, {
|
|
29
|
-
parseWhere: expression => {
|
|
30
|
-
const predicate = parseSQLPredicate(expression);
|
|
31
|
-
validateColumnReferences(predicate);
|
|
32
|
-
return predicate;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/** Keeps table qualification distinct from literal dotted source-column names. */
|
|
37
|
-
function validateColumnReferences(predicate) {
|
|
38
|
-
if (predicate.op === 'and' || predicate.op === 'or') {
|
|
39
|
-
predicate.args.forEach(validateColumnReferences);
|
|
40
|
-
}
|
|
41
|
-
else if (predicate.op === 'not')
|
|
42
|
-
validateColumnReferences(predicate.args[0]);
|
|
43
|
-
else {
|
|
44
|
-
const property = predicate.args[0];
|
|
45
|
-
if (!property.quoted && property.property.includes('.'))
|
|
46
|
-
throw new Error('Qualified WHERE columns are not supported; quote literal column names containing dots.');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=parse-sql-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-sql-query.js","sourceRoot":"","sources":["../../src/scan/parse-sql-query.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAGpC,O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UAAU,CAAC,CAAC;YAChD,wBAAwB,CAAC,SAAS,CAAC,CAAC;YACpC,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,SAAS,wBAAwB,CAAC,SAA4B;IAC5D,IAAI,SAAS,CAAC,EAAE,KAAK,KAAK,IAAI,SAAS,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;QACpD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACnD,CAAC;SAAM,IAAI,SAAS,CAAC,EAAE,KAAK,KAAK;QAAE,wBAAwB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1E,CAAC;QACJ,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAyB,CAAC;QAC3D,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;YACrD,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/scan/parse-sql-select.ts
|
|
21
|
-
var parse_sql_select_exports = {};
|
|
22
|
-
__export(parse_sql_select_exports, {
|
|
23
|
-
SQLQueryReader: () => SQLQueryReader,
|
|
24
|
-
parseSQLSelect: () => parseSQLSelect
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(parse_sql_select_exports);
|
|
27
|
-
var MAXIMUM_SQL_LENGTH = 65536;
|
|
28
|
-
var MAXIMUM_SELECT_TOKENS = 4096;
|
|
29
|
-
var RESERVED_WORDS = /* @__PURE__ */ new Set([
|
|
30
|
-
"SELECT",
|
|
31
|
-
"FROM",
|
|
32
|
-
"WHERE",
|
|
33
|
-
"LIMIT",
|
|
34
|
-
"AS",
|
|
35
|
-
"TRUE",
|
|
36
|
-
"FALSE",
|
|
37
|
-
"NULL",
|
|
38
|
-
"ALL",
|
|
39
|
-
"AND",
|
|
40
|
-
"OR",
|
|
41
|
-
"NOT",
|
|
42
|
-
"IN",
|
|
43
|
-
"IS",
|
|
44
|
-
"DISTINCT",
|
|
45
|
-
"ORDER",
|
|
46
|
-
"GROUP",
|
|
47
|
-
"HAVING",
|
|
48
|
-
"OFFSET",
|
|
49
|
-
"JOIN",
|
|
50
|
-
"UNION"
|
|
51
|
-
]);
|
|
52
|
-
function parseSQLSelect(sql, options = {}) {
|
|
53
|
-
const reader = new SQLQueryReader(sql);
|
|
54
|
-
reader.expectKeyword("SELECT");
|
|
55
|
-
let select;
|
|
56
|
-
if (!reader.takeSymbol("*")) {
|
|
57
|
-
select = [];
|
|
58
|
-
do {
|
|
59
|
-
const column = reader.identifier();
|
|
60
|
-
select.push(reader.takeKeyword("AS") ? { column, as: reader.identifier() } : column);
|
|
61
|
-
} while (reader.takeSymbol(","));
|
|
62
|
-
}
|
|
63
|
-
let from;
|
|
64
|
-
if (reader.takeKeyword("FROM")) {
|
|
65
|
-
const source = reader.identifier();
|
|
66
|
-
from = reader.takeSymbol(".") ? { source, table: reader.identifier() } : source;
|
|
67
|
-
if (!source.trim() || typeof from === "object" && !from.table.trim())
|
|
68
|
-
throw new Error("SQL FROM requires non-empty names.");
|
|
69
|
-
}
|
|
70
|
-
let where;
|
|
71
|
-
if (reader.takeKeyword("WHERE")) {
|
|
72
|
-
if (typeof options.parseWhere !== "function")
|
|
73
|
-
throw new Error(
|
|
74
|
-
"parseSQLSelect requires parseWhere for WHERE; use parseSQLQuery for built-in predicate support."
|
|
75
|
-
);
|
|
76
|
-
where = options.parseWhere(reader.whereExpression());
|
|
77
|
-
if (!where || typeof where !== "object" || Array.isArray(where))
|
|
78
|
-
throw new Error("SQL WHERE parser must return a predicate.");
|
|
79
|
-
}
|
|
80
|
-
let limit;
|
|
81
|
-
if (reader.takeKeyword("LIMIT")) limit = reader.limit();
|
|
82
|
-
reader.end();
|
|
83
|
-
return {
|
|
84
|
-
...select ? { select } : {},
|
|
85
|
-
...from === void 0 ? {} : { from },
|
|
86
|
-
...where ? { where } : {},
|
|
87
|
-
...limit === void 0 ? {} : { limit }
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
var SQLQueryReader = class {
|
|
91
|
-
/** Original SQL, retained for exact WHERE substring extraction. */
|
|
92
|
-
sql;
|
|
93
|
-
/** Current character offset. */
|
|
94
|
-
position = 0;
|
|
95
|
-
/** Number of consumed structural tokens. */
|
|
96
|
-
tokens = 0;
|
|
97
|
-
/** Rejects empty or oversized statements before scanning. */
|
|
98
|
-
constructor(sql) {
|
|
99
|
-
if (typeof sql !== "string" || !sql.trim() || sql.length > MAXIMUM_SQL_LENGTH)
|
|
100
|
-
throw new Error("SQL query requires a non-empty statement of at most 65536 characters.");
|
|
101
|
-
this.sql = sql;
|
|
102
|
-
}
|
|
103
|
-
/** Consumes one mandatory keyword. */
|
|
104
|
-
expectKeyword(keyword) {
|
|
105
|
-
if (!this.takeKeyword(keyword)) throw new Error(`SQL query expected ${keyword}.`);
|
|
106
|
-
}
|
|
107
|
-
/** Consumes an unquoted keyword without folding identifier names. */
|
|
108
|
-
takeKeyword(keyword) {
|
|
109
|
-
this.skipWhitespace();
|
|
110
|
-
const match = /^[A-Za-z_][A-Za-z0-9_]*/.exec(this.sql.slice(this.position));
|
|
111
|
-
if (match?.[0].toUpperCase() !== keyword) return false;
|
|
112
|
-
this.position += match[0].length;
|
|
113
|
-
this.countToken();
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
/** Consumes a punctuation token. */
|
|
117
|
-
takeSymbol(symbol) {
|
|
118
|
-
this.skipWhitespace();
|
|
119
|
-
if (this.sql[this.position] !== symbol) return false;
|
|
120
|
-
this.position++;
|
|
121
|
-
this.countToken();
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
/** Reads one literal identifier, including doubled double-quote escapes. */
|
|
125
|
-
identifier() {
|
|
126
|
-
this.skipWhitespace();
|
|
127
|
-
this.countToken();
|
|
128
|
-
if (this.sql[this.position] === '"') {
|
|
129
|
-
this.position++;
|
|
130
|
-
let value = "";
|
|
131
|
-
while (this.position < this.sql.length) {
|
|
132
|
-
const character = this.sql[this.position++];
|
|
133
|
-
if (character !== '"') value += character;
|
|
134
|
-
else if (this.sql[this.position] === '"') {
|
|
135
|
-
value += '"';
|
|
136
|
-
this.position++;
|
|
137
|
-
} else {
|
|
138
|
-
if (!value.length) throw new Error("SQL identifiers must not be empty.");
|
|
139
|
-
return value;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
throw new Error("SQL query contains an unterminated quoted identifier.");
|
|
143
|
-
}
|
|
144
|
-
const match = /^[A-Za-z_][A-Za-z0-9_]*/.exec(this.sql.slice(this.position));
|
|
145
|
-
if (!match || RESERVED_WORDS.has(match[0].toUpperCase()))
|
|
146
|
-
throw new Error("SQL query expected a column, alias, source, or table identifier.");
|
|
147
|
-
this.position += match[0].length;
|
|
148
|
-
return match[0];
|
|
149
|
-
}
|
|
150
|
-
/** Finds a top-level LIMIT/terminator without interpreting quoted predicate contents. */
|
|
151
|
-
whereExpression() {
|
|
152
|
-
this.skipWhitespace();
|
|
153
|
-
const start = this.position;
|
|
154
|
-
let quote = "";
|
|
155
|
-
let depth = 0;
|
|
156
|
-
while (this.position < this.sql.length) {
|
|
157
|
-
const character = this.sql[this.position];
|
|
158
|
-
if (quote) {
|
|
159
|
-
if (character === quote) {
|
|
160
|
-
if (this.sql[this.position + 1] === quote) {
|
|
161
|
-
this.position += 2;
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
quote = "";
|
|
165
|
-
}
|
|
166
|
-
} else if (character === '"' || character === "'") quote = character;
|
|
167
|
-
else if (this.sql.startsWith("--", this.position) || this.sql.startsWith("/*", this.position))
|
|
168
|
-
throw new Error("SQL comments are not supported.");
|
|
169
|
-
else if (character === "(") {
|
|
170
|
-
if (++depth > 64) throw new Error("SQL query exceeds its predicate nesting limit.");
|
|
171
|
-
} else if (character === ")") {
|
|
172
|
-
if (--depth < 0) throw new Error("SQL query contains unbalanced parentheses.");
|
|
173
|
-
} else if (depth === 0 && (character === ";" || this.sql.slice(this.position, this.position + 5).toUpperCase() === "LIMIT" && !/[A-Za-z0-9_.:]/.test(this.sql[this.position - 1] || "") && !/[A-Za-z0-9_.:]/.test(this.sql[this.position + 5] || "")))
|
|
174
|
-
break;
|
|
175
|
-
this.position++;
|
|
176
|
-
}
|
|
177
|
-
if (quote || depth) throw new Error("SQL query contains an unterminated predicate.");
|
|
178
|
-
const expression = this.sql.slice(start, this.position).trim();
|
|
179
|
-
if (!expression) throw new Error("SQL WHERE requires a predicate.");
|
|
180
|
-
return expression;
|
|
181
|
-
}
|
|
182
|
-
/** Reads a non-negative safe integer row limit. */
|
|
183
|
-
limit() {
|
|
184
|
-
this.skipWhitespace();
|
|
185
|
-
const match = /^\d+/.exec(this.sql.slice(this.position));
|
|
186
|
-
if (!match) throw new Error("SQL LIMIT requires a non-negative safe integer.");
|
|
187
|
-
this.position += match[0].length;
|
|
188
|
-
const value = Number(match[0]);
|
|
189
|
-
if (!Number.isSafeInteger(value))
|
|
190
|
-
throw new Error("SQL LIMIT requires a non-negative safe integer.");
|
|
191
|
-
return value;
|
|
192
|
-
}
|
|
193
|
-
/** Requires one complete statement with at most one trailing semicolon. */
|
|
194
|
-
end() {
|
|
195
|
-
this.takeSymbol(";");
|
|
196
|
-
this.skipWhitespace();
|
|
197
|
-
if (this.position !== this.sql.length)
|
|
198
|
-
throw new Error(`Unsupported SQL query syntax at character ${this.position}.`);
|
|
199
|
-
}
|
|
200
|
-
/** Skips whitespace without altering quoted identifiers. */
|
|
201
|
-
skipWhitespace() {
|
|
202
|
-
while (this.position < this.sql.length && /\s/.test(this.sql[this.position])) this.position++;
|
|
203
|
-
}
|
|
204
|
-
/** Bounds large projection lists independently of predicate parsing. */
|
|
205
|
-
countToken() {
|
|
206
|
-
if (++this.tokens > MAXIMUM_SELECT_TOKENS)
|
|
207
|
-
throw new Error("SQL query exceeds its structural token limit.");
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
211
|
-
0 && (module.exports = {
|
|
212
|
-
SQLQueryReader,
|
|
213
|
-
parseSQLSelect
|
|
214
|
-
});
|
|
215
|
-
//# sourceMappingURL=parse-sql-select.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/scan/parse-sql-select.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n ColumnarPredicate,\n TableQuery,\n TableSelection,\n TableReference\n} from '@loaders.gl/core/loader-utils';\n\nconst MAXIMUM_SQL_LENGTH = 65536;\nconst MAXIMUM_SELECT_TOKENS = 4096;\nconst RESERVED_WORDS = new Set([\n 'SELECT',\n 'FROM',\n 'WHERE',\n 'LIMIT',\n 'AS',\n 'TRUE',\n 'FALSE',\n 'NULL',\n 'ALL',\n 'AND',\n 'OR',\n 'NOT',\n 'IN',\n 'IS',\n 'DISTINCT',\n 'ORDER',\n 'GROUP',\n 'HAVING',\n 'OFFSET',\n 'JOIN',\n 'UNION'\n]);\n\n/** Optional WHERE support for the independently tree-shakeable structural parser. */\nexport type SQLSelectParserOptions = Readonly<{\n /** Converts a WHERE expression to the portable predicate vocabulary. Omission rejects WHERE. */\n parseWhere?: (expression: string) => ColumnarPredicate;\n}>;\n\n/** Parses SELECT columns/AS aliases, optional FROM, and LIMIT; WHERE requires a supplied parser. */\nexport function parseSQLSelect(sql: string, options: SQLSelectParserOptions = {}): TableQuery {\n const reader = new SQLQueryReader(sql);\n reader.expectKeyword('SELECT');\n let select: TableSelection[] | undefined;\n if (!reader.takeSymbol('*')) {\n select = [];\n do {\n const column = reader.identifier();\n select.push(reader.takeKeyword('AS') ? {column, as: reader.identifier()} : column);\n } while (reader.takeSymbol(','));\n }\n let from: TableReference | undefined;\n if (reader.takeKeyword('FROM')) {\n const source = reader.identifier();\n from = reader.takeSymbol('.') ? {source, table: reader.identifier()} : source;\n if (!source.trim() || (typeof from === 'object' && !from.table.trim()))\n throw new Error('SQL FROM requires non-empty names.');\n }\n let where: ColumnarPredicate | undefined;\n if (reader.takeKeyword('WHERE')) {\n if (typeof options.parseWhere !== 'function')\n throw new Error(\n 'parseSQLSelect requires parseWhere for WHERE; use parseSQLQuery for built-in predicate support.'\n );\n where = options.parseWhere(reader.whereExpression());\n if (!where || typeof where !== 'object' || Array.isArray(where))\n throw new Error('SQL WHERE parser must return a predicate.');\n }\n let limit: number | undefined;\n if (reader.takeKeyword('LIMIT')) limit = reader.limit();\n reader.end();\n return {\n ...(select ? {select} : {}),\n ...(from === undefined ? {} : {from}),\n ...(where ? {where} : {}),\n ...(limit === undefined ? {} : {limit})\n };\n}\n\n/** Small bounded scanner shared by structural and predicate-enabled SELECT parsing. */\nexport class SQLQueryReader {\n /** Original SQL, retained for exact WHERE substring extraction. */\n private readonly sql: string;\n /** Current character offset. */\n private position = 0;\n /** Number of consumed structural tokens. */\n private tokens = 0;\n\n /** Rejects empty or oversized statements before scanning. */\n constructor(sql: string) {\n if (typeof sql !== 'string' || !sql.trim() || sql.length > MAXIMUM_SQL_LENGTH)\n throw new Error('SQL query requires a non-empty statement of at most 65536 characters.');\n this.sql = sql;\n }\n\n /** Consumes one mandatory keyword. */\n expectKeyword(keyword: string): void {\n if (!this.takeKeyword(keyword)) throw new Error(`SQL query expected ${keyword}.`);\n }\n\n /** Consumes an unquoted keyword without folding identifier names. */\n takeKeyword(keyword: string): boolean {\n this.skipWhitespace();\n const match = /^[A-Za-z_][A-Za-z0-9_]*/.exec(this.sql.slice(this.position));\n if (match?.[0].toUpperCase() !== keyword) return false;\n this.position += match[0].length;\n this.countToken();\n return true;\n }\n\n /** Consumes a punctuation token. */\n takeSymbol(symbol: string): boolean {\n this.skipWhitespace();\n if (this.sql[this.position] !== symbol) return false;\n this.position++;\n this.countToken();\n return true;\n }\n\n /** Reads one literal identifier, including doubled double-quote escapes. */\n identifier(): string {\n this.skipWhitespace();\n this.countToken();\n if (this.sql[this.position] === '\"') {\n this.position++;\n let value = '';\n while (this.position < this.sql.length) {\n const character = this.sql[this.position++];\n if (character !== '\"') value += character;\n else if (this.sql[this.position] === '\"') {\n value += '\"';\n this.position++;\n } else {\n if (!value.length) throw new Error('SQL identifiers must not be empty.');\n return value;\n }\n }\n throw new Error('SQL query contains an unterminated quoted identifier.');\n }\n const match = /^[A-Za-z_][A-Za-z0-9_]*/.exec(this.sql.slice(this.position));\n if (!match || RESERVED_WORDS.has(match[0].toUpperCase()))\n throw new Error('SQL query expected a column, alias, source, or table identifier.');\n this.position += match[0].length;\n return match[0];\n }\n\n /** Finds a top-level LIMIT/terminator without interpreting quoted predicate contents. */\n whereExpression(): string {\n this.skipWhitespace();\n const start = this.position;\n let quote = '';\n let depth = 0;\n while (this.position < this.sql.length) {\n const character = this.sql[this.position];\n if (quote) {\n if (character === quote) {\n if (this.sql[this.position + 1] === quote) {\n this.position += 2;\n continue;\n }\n quote = '';\n }\n } else if (character === '\"' || character === \"'\") quote = character;\n else if (this.sql.startsWith('--', this.position) || this.sql.startsWith('/*', this.position))\n throw new Error('SQL comments are not supported.');\n else if (character === '(') {\n if (++depth > 64) throw new Error('SQL query exceeds its predicate nesting limit.');\n } else if (character === ')') {\n if (--depth < 0) throw new Error('SQL query contains unbalanced parentheses.');\n } else if (\n depth === 0 &&\n (character === ';' ||\n (this.sql.slice(this.position, this.position + 5).toUpperCase() === 'LIMIT' &&\n !/[A-Za-z0-9_.:]/.test(this.sql[this.position - 1] || '') &&\n !/[A-Za-z0-9_.:]/.test(this.sql[this.position + 5] || '')))\n )\n break;\n this.position++;\n }\n if (quote || depth) throw new Error('SQL query contains an unterminated predicate.');\n const expression = this.sql.slice(start, this.position).trim();\n if (!expression) throw new Error('SQL WHERE requires a predicate.');\n return expression;\n }\n\n /** Reads a non-negative safe integer row limit. */\n limit(): number {\n this.skipWhitespace();\n const match = /^\\d+/.exec(this.sql.slice(this.position));\n if (!match) throw new Error('SQL LIMIT requires a non-negative safe integer.');\n this.position += match[0].length;\n const value = Number(match[0]);\n if (!Number.isSafeInteger(value))\n throw new Error('SQL LIMIT requires a non-negative safe integer.');\n return value;\n }\n\n /** Requires one complete statement with at most one trailing semicolon. */\n end(): void {\n this.takeSymbol(';');\n this.skipWhitespace();\n if (this.position !== this.sql.length)\n throw new Error(`Unsupported SQL query syntax at character ${this.position}.`);\n }\n\n /** Skips whitespace without altering quoted identifiers. */\n private skipWhitespace(): void {\n while (this.position < this.sql.length && /\\s/.test(this.sql[this.position])) this.position++;\n }\n\n /** Bounds large projection lists independently of predicate parsing. */\n private countToken(): void {\n if (++this.tokens > MAXIMUM_SELECT_TOKENS)\n throw new Error('SQL query exceeds its structural token limit.');\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;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Q,aAAmB;AACzB,QAAI,EAAE,KAAK,SAAS;AAClB,YAAM,IAAI,MAAM,+CAA+C;AAAA,EACnE;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ColumnarPredicate, TableQuery } from '@loaders.gl/core/loader-utils';
|
|
2
|
-
/** Optional WHERE support for the independently tree-shakeable structural parser. */
|
|
3
|
-
export type SQLSelectParserOptions = Readonly<{
|
|
4
|
-
/** Converts a WHERE expression to the portable predicate vocabulary. Omission rejects WHERE. */
|
|
5
|
-
parseWhere?: (expression: string) => ColumnarPredicate;
|
|
6
|
-
}>;
|
|
7
|
-
/** Parses SELECT columns/AS aliases, optional FROM, and LIMIT; WHERE requires a supplied parser. */
|
|
8
|
-
export declare function parseSQLSelect(sql: string, options?: SQLSelectParserOptions): TableQuery;
|
|
9
|
-
/** Small bounded scanner shared by structural and predicate-enabled SELECT parsing. */
|
|
10
|
-
export declare class SQLQueryReader {
|
|
11
|
-
/** Original SQL, retained for exact WHERE substring extraction. */
|
|
12
|
-
private readonly sql;
|
|
13
|
-
/** Current character offset. */
|
|
14
|
-
private position;
|
|
15
|
-
/** Number of consumed structural tokens. */
|
|
16
|
-
private tokens;
|
|
17
|
-
/** Rejects empty or oversized statements before scanning. */
|
|
18
|
-
constructor(sql: string);
|
|
19
|
-
/** Consumes one mandatory keyword. */
|
|
20
|
-
expectKeyword(keyword: string): void;
|
|
21
|
-
/** Consumes an unquoted keyword without folding identifier names. */
|
|
22
|
-
takeKeyword(keyword: string): boolean;
|
|
23
|
-
/** Consumes a punctuation token. */
|
|
24
|
-
takeSymbol(symbol: string): boolean;
|
|
25
|
-
/** Reads one literal identifier, including doubled double-quote escapes. */
|
|
26
|
-
identifier(): string;
|
|
27
|
-
/** Finds a top-level LIMIT/terminator without interpreting quoted predicate contents. */
|
|
28
|
-
whereExpression(): string;
|
|
29
|
-
/** Reads a non-negative safe integer row limit. */
|
|
30
|
-
limit(): number;
|
|
31
|
-
/** Requires one complete statement with at most one trailing semicolon. */
|
|
32
|
-
end(): void;
|
|
33
|
-
/** Skips whitespace without altering quoted identifiers. */
|
|
34
|
-
private skipWhitespace;
|
|
35
|
-
/** Bounds large projection lists independently of predicate parsing. */
|
|
36
|
-
private countToken;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=parse-sql-select.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-sql-select.d.ts","sourceRoot":"","sources":["../../src/scan/parse-sql-select.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EAGX,MAAM,+BAA+B,CAAC;AA4BvC,qFAAqF;AACrF,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,gGAAgG;IAChG,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,iBAAiB,CAAC;CACxD,CAAC,CAAC;AAEH,oGAAoG;AACpG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,UAAU,CAqC5F;AAED,uFAAuF;AACvF,qBAAa,cAAc;IACzB,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAK;IACrB,4CAA4C;IAC5C,OAAO,CAAC,MAAM,CAAK;IAEnB,6DAA6D;gBACjD,GAAG,EAAE,MAAM;IAMvB,sCAAsC;IACtC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIpC,qEAAqE;IACrE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IASrC,oCAAoC;IACpC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAQnC,4EAA4E;IAC5E,UAAU,IAAI,MAAM;IA0BpB,yFAAyF;IACzF,eAAe,IAAI,MAAM;IAsCzB,mDAAmD;IACnD,KAAK,IAAI,MAAM;IAWf,2EAA2E;IAC3E,GAAG,IAAI,IAAI;IAOX,4DAA4D;IAC5D,OAAO,CAAC,cAAc;IAItB,wEAAwE;IACxE,OAAO,CAAC,UAAU;CAInB"}
|