@nshiab/simple-data-analysis-core 0.0.26 → 0.1.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 (117) hide show
  1. package/esm/class/SimpleDB.d.ts +3 -8
  2. package/esm/class/SimpleDB.d.ts.map +1 -1
  3. package/esm/class/SimpleDB.js +8 -10
  4. package/esm/class/SimpleTable.d.ts +61 -51
  5. package/esm/class/SimpleTable.d.ts.map +1 -1
  6. package/esm/class/SimpleTable.js +132 -188
  7. package/esm/helpers/convertForJS.js +1 -1
  8. package/esm/helpers/findGeoColumn.js +2 -2
  9. package/esm/helpers/hasGeometryColumn.js +1 -1
  10. package/esm/helpers/logData.d.ts.map +1 -1
  11. package/esm/helpers/logData.js +7 -2
  12. package/esm/helpers/parseTypes.d.ts +1 -1
  13. package/esm/helpers/parseTypes.d.ts.map +1 -1
  14. package/esm/helpers/parseTypes.js +3 -1
  15. package/esm/helpers/setDbProps.d.ts +1 -1
  16. package/esm/helpers/setDbProps.d.ts.map +1 -1
  17. package/esm/helpers/setDbProps.js +5 -9
  18. package/esm/helpers/unifyColumns.d.ts +0 -2
  19. package/esm/helpers/unifyColumns.d.ts.map +1 -1
  20. package/esm/helpers/unifyColumns.js +2 -6
  21. package/esm/helpers/writeGeoData.d.ts.map +1 -1
  22. package/esm/helpers/writeGeoData.js +11 -41
  23. package/esm/helpers/writeIndexes.d.ts +3 -0
  24. package/esm/helpers/writeIndexes.d.ts.map +1 -0
  25. package/esm/helpers/writeIndexes.js +16 -0
  26. package/esm/methods/bm25.d.ts.map +1 -1
  27. package/esm/methods/bm25.js +1 -1
  28. package/esm/methods/cache.js +1 -1
  29. package/esm/methods/distanceQuery.d.ts.map +1 -1
  30. package/esm/methods/distanceQuery.js +4 -2
  31. package/esm/methods/fuzzyJoin.d.ts.map +1 -1
  32. package/esm/methods/fuzzyJoin.js +1 -6
  33. package/esm/methods/getGeoData.d.ts.map +1 -1
  34. package/esm/methods/getGeoData.js +1 -10
  35. package/esm/methods/getNbRows.d.ts +3 -1
  36. package/esm/methods/getNbRows.d.ts.map +1 -1
  37. package/esm/methods/getNbRows.js +5 -5
  38. package/esm/methods/join.d.ts.map +1 -1
  39. package/esm/methods/join.js +1 -7
  40. package/esm/methods/joinGeo.d.ts.map +1 -1
  41. package/esm/methods/joinGeo.js +1 -14
  42. package/esm/methods/joinGeoQuery.js +1 -1
  43. package/esm/methods/randomPointQuery.d.ts.map +1 -1
  44. package/esm/methods/randomPointQuery.js +60 -22
  45. package/esm/methods/summarizeQuery.js +1 -1
  46. package/esm/methods/writeGeoDataQuery.js +2 -2
  47. package/package.json +2 -2
  48. package/script/class/SimpleDB.d.ts +3 -8
  49. package/script/class/SimpleDB.d.ts.map +1 -1
  50. package/script/class/SimpleDB.js +8 -10
  51. package/script/class/SimpleTable.d.ts +61 -51
  52. package/script/class/SimpleTable.d.ts.map +1 -1
  53. package/script/class/SimpleTable.js +132 -188
  54. package/script/helpers/convertForJS.js +1 -1
  55. package/script/helpers/findGeoColumn.js +2 -2
  56. package/script/helpers/hasGeometryColumn.js +1 -1
  57. package/script/helpers/logData.d.ts.map +1 -1
  58. package/script/helpers/logData.js +7 -2
  59. package/script/helpers/parseTypes.d.ts +1 -1
  60. package/script/helpers/parseTypes.d.ts.map +1 -1
  61. package/script/helpers/parseTypes.js +3 -1
  62. package/script/helpers/setDbProps.d.ts +1 -1
  63. package/script/helpers/setDbProps.d.ts.map +1 -1
  64. package/script/helpers/setDbProps.js +5 -9
  65. package/script/helpers/unifyColumns.d.ts +0 -2
  66. package/script/helpers/unifyColumns.d.ts.map +1 -1
  67. package/script/helpers/unifyColumns.js +2 -6
  68. package/script/helpers/writeGeoData.d.ts.map +1 -1
  69. package/script/helpers/writeGeoData.js +11 -41
  70. package/script/helpers/writeIndexes.d.ts +3 -0
  71. package/script/helpers/writeIndexes.d.ts.map +1 -0
  72. package/script/helpers/writeIndexes.js +19 -0
  73. package/script/methods/bm25.d.ts.map +1 -1
  74. package/script/methods/bm25.js +1 -1
  75. package/script/methods/cache.js +1 -1
  76. package/script/methods/distanceQuery.d.ts.map +1 -1
  77. package/script/methods/distanceQuery.js +4 -2
  78. package/script/methods/fuzzyJoin.d.ts.map +1 -1
  79. package/script/methods/fuzzyJoin.js +1 -6
  80. package/script/methods/getGeoData.d.ts.map +1 -1
  81. package/script/methods/getGeoData.js +1 -10
  82. package/script/methods/getNbRows.d.ts +3 -1
  83. package/script/methods/getNbRows.d.ts.map +1 -1
  84. package/script/methods/getNbRows.js +5 -5
  85. package/script/methods/join.d.ts.map +1 -1
  86. package/script/methods/join.js +1 -7
  87. package/script/methods/joinGeo.d.ts.map +1 -1
  88. package/script/methods/joinGeo.js +1 -14
  89. package/script/methods/joinGeoQuery.js +1 -1
  90. package/script/methods/randomPointQuery.d.ts.map +1 -1
  91. package/script/methods/randomPointQuery.js +60 -22
  92. package/script/methods/summarizeQuery.js +1 -1
  93. package/script/methods/writeGeoDataQuery.js +2 -2
  94. package/esm/helpers/getProjection.d.ts +0 -3
  95. package/esm/helpers/getProjection.d.ts.map +0 -1
  96. package/esm/helpers/getProjection.js +0 -25
  97. package/esm/helpers/getProjectionParquet.d.ts +0 -3
  98. package/esm/helpers/getProjectionParquet.d.ts.map +0 -1
  99. package/esm/helpers/getProjectionParquet.js +0 -24
  100. package/esm/helpers/shouldFlipBeforeExport.d.ts +0 -2
  101. package/esm/helpers/shouldFlipBeforeExport.d.ts.map +0 -1
  102. package/esm/helpers/shouldFlipBeforeExport.js +0 -3
  103. package/esm/helpers/writeProjectionsAndIndexes.d.ts +0 -3
  104. package/esm/helpers/writeProjectionsAndIndexes.d.ts.map +0 -1
  105. package/esm/helpers/writeProjectionsAndIndexes.js +0 -29
  106. package/script/helpers/getProjection.d.ts +0 -3
  107. package/script/helpers/getProjection.d.ts.map +0 -1
  108. package/script/helpers/getProjection.js +0 -31
  109. package/script/helpers/getProjectionParquet.d.ts +0 -3
  110. package/script/helpers/getProjectionParquet.d.ts.map +0 -1
  111. package/script/helpers/getProjectionParquet.js +0 -30
  112. package/script/helpers/shouldFlipBeforeExport.d.ts +0 -2
  113. package/script/helpers/shouldFlipBeforeExport.d.ts.map +0 -1
  114. package/script/helpers/shouldFlipBeforeExport.js +0 -6
  115. package/script/helpers/writeProjectionsAndIndexes.d.ts +0 -3
  116. package/script/helpers/writeProjectionsAndIndexes.d.ts.map +0 -1
  117. package/script/helpers/writeProjectionsAndIndexes.js +0 -32
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProjection.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAGjD,wBAA8B,aAAa,CACzC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,mBAiCb"}
@@ -1,25 +0,0 @@
1
- import mergeOptions from "./mergeOptions.js";
2
- import queryDB from "./queryDB.js";
3
- import cleanPath from "./cleanPath.js";
4
- export default async function getProjection(simpleDB, file) {
5
- // Load spatial may not be necessary if we change how this works
6
- const queryResult = await queryDB(simpleDB, `INSTALL spatial;
7
- LOAD spatial;
8
- SELECT layers[1].geometry_fields[1].crs.proj4 as proj4 FROM st_read_meta('${cleanPath(file)}')`, mergeOptions(simpleDB, {
9
- table: null,
10
- method: "getProjection()",
11
- parameters: { file },
12
- returnDataFrom: "query",
13
- }));
14
- if (!queryResult) {
15
- throw new Error("No queryResults");
16
- }
17
- const proj4 = queryResult[0].proj4;
18
- if (proj4 === null) {
19
- return "UNKNOWN";
20
- }
21
- if (typeof proj4 !== "string") {
22
- throw new Error(`Expected proj4 to be a string, got ${typeof proj4}`);
23
- }
24
- return proj4;
25
- }
@@ -1,3 +0,0 @@
1
- import type SimpleTable from "../class/SimpleTable.js";
2
- export default function getProjectionParquet(SimpleTable: SimpleTable, file: string): Promise<any>;
3
- //# sourceMappingURL=getProjectionParquet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProjectionParquet.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjectionParquet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAKvD,wBAA8B,oBAAoB,CAChD,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,gBA+Bb"}
@@ -1,24 +0,0 @@
1
- import cleanPath from "./cleanPath.js";
2
- import mergeOptions from "./mergeOptions.js";
3
- import queryDB from "./queryDB.js";
4
- export default async function getProjectionParquet(SimpleTable, file) {
5
- const queryResult = await queryDB(SimpleTable, `SELECT * FROM parquet_kv_metadata('${cleanPath(file)}');`, mergeOptions(SimpleTable, {
6
- table: SimpleTable.name,
7
- method: "getProjectionParquet()",
8
- parameters: { file },
9
- returnDataFrom: "query",
10
- }));
11
- if (!queryResult) {
12
- throw new Error(`Could not get metadata from parquet file: ${file}`);
13
- }
14
- const projection = queryResult.find((d) => {
15
- return d.key?.toString() === "projections";
16
- });
17
- if (!projection || projection.value === null) {
18
- console.warn(`\nCould not get projection from parquet file: ${file}\n`);
19
- return {};
20
- }
21
- else {
22
- return JSON.parse(projection.value.replaceAll("\\x22", '"'));
23
- }
24
- }
@@ -1,2 +0,0 @@
1
- export default function shouldFlipBeforeExport(projection: string): boolean;
2
- //# sourceMappingURL=shouldFlipBeforeExport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shouldFlipBeforeExport.d.ts","sourceRoot":"","sources":["../../src/helpers/shouldFlipBeforeExport.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,UAAU,EAAE,MAAM,WAEhE"}
@@ -1,3 +0,0 @@
1
- export default function shouldFlipBeforeExport(projection) {
2
- return projection.includes("proj=latlong");
3
- }
@@ -1,3 +0,0 @@
1
- import type { SimpleDB } from "../index.js";
2
- export default function writeProjectionsAndIndexes(simpleDB: SimpleDB, extension: string, file: string): void;
3
- //# sourceMappingURL=writeProjectionsAndIndexes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeProjectionsAndIndexes.d.ts","sourceRoot":"","sources":["../../src/helpers/writeProjectionsAndIndexes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,QA+Bb"}
@@ -1,29 +0,0 @@
1
- import { existsSync, rmSync, writeFileSync } from "node:fs";
2
- export default function writeProjectionsAndIndexes(simpleDB, extension, file) {
3
- const allProjections = {};
4
- for (const table of simpleDB.tables) {
5
- if (Object.keys(table.projections).length > 0) {
6
- allProjections[table.name] = table.projections;
7
- }
8
- }
9
- const allProjectionsFile = `${file.replace(`.${extension}`, "")}_projections.json`;
10
- if (existsSync(allProjectionsFile)) {
11
- rmSync(allProjectionsFile);
12
- }
13
- if (Object.keys(allProjections).length > 0) {
14
- writeFileSync(allProjectionsFile, JSON.stringify(allProjections));
15
- }
16
- const allIndexes = {};
17
- for (const table of simpleDB.tables) {
18
- if (table.indexes.length > 0) {
19
- allIndexes[table.name] = table.indexes;
20
- }
21
- }
22
- const allIndexesFile = `${file.replace(`.${extension}`, "")}_indexes.json`;
23
- if (existsSync(allIndexesFile)) {
24
- rmSync(allIndexesFile);
25
- }
26
- if (Object.keys(allIndexes).length > 0) {
27
- writeFileSync(allIndexesFile, JSON.stringify(allIndexes));
28
- }
29
- }
@@ -1,3 +0,0 @@
1
- import type SimpleDB from "../class/SimpleDB.js";
2
- export default function getProjection(simpleDB: SimpleDB, file: string): Promise<string>;
3
- //# sourceMappingURL=getProjection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProjection.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAGjD,wBAA8B,aAAa,CACzC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,mBAiCb"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = getProjection;
7
- const mergeOptions_js_1 = __importDefault(require("./mergeOptions.js"));
8
- const queryDB_js_1 = __importDefault(require("./queryDB.js"));
9
- const cleanPath_js_1 = __importDefault(require("./cleanPath.js"));
10
- async function getProjection(simpleDB, file) {
11
- // Load spatial may not be necessary if we change how this works
12
- const queryResult = await (0, queryDB_js_1.default)(simpleDB, `INSTALL spatial;
13
- LOAD spatial;
14
- SELECT layers[1].geometry_fields[1].crs.proj4 as proj4 FROM st_read_meta('${(0, cleanPath_js_1.default)(file)}')`, (0, mergeOptions_js_1.default)(simpleDB, {
15
- table: null,
16
- method: "getProjection()",
17
- parameters: { file },
18
- returnDataFrom: "query",
19
- }));
20
- if (!queryResult) {
21
- throw new Error("No queryResults");
22
- }
23
- const proj4 = queryResult[0].proj4;
24
- if (proj4 === null) {
25
- return "UNKNOWN";
26
- }
27
- if (typeof proj4 !== "string") {
28
- throw new Error(`Expected proj4 to be a string, got ${typeof proj4}`);
29
- }
30
- return proj4;
31
- }
@@ -1,3 +0,0 @@
1
- import type SimpleTable from "../class/SimpleTable.js";
2
- export default function getProjectionParquet(SimpleTable: SimpleTable, file: string): Promise<any>;
3
- //# sourceMappingURL=getProjectionParquet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProjectionParquet.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjectionParquet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAKvD,wBAA8B,oBAAoB,CAChD,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,gBA+Bb"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = getProjectionParquet;
7
- const cleanPath_js_1 = __importDefault(require("./cleanPath.js"));
8
- const mergeOptions_js_1 = __importDefault(require("./mergeOptions.js"));
9
- const queryDB_js_1 = __importDefault(require("./queryDB.js"));
10
- async function getProjectionParquet(SimpleTable, file) {
11
- const queryResult = await (0, queryDB_js_1.default)(SimpleTable, `SELECT * FROM parquet_kv_metadata('${(0, cleanPath_js_1.default)(file)}');`, (0, mergeOptions_js_1.default)(SimpleTable, {
12
- table: SimpleTable.name,
13
- method: "getProjectionParquet()",
14
- parameters: { file },
15
- returnDataFrom: "query",
16
- }));
17
- if (!queryResult) {
18
- throw new Error(`Could not get metadata from parquet file: ${file}`);
19
- }
20
- const projection = queryResult.find((d) => {
21
- return d.key?.toString() === "projections";
22
- });
23
- if (!projection || projection.value === null) {
24
- console.warn(`\nCould not get projection from parquet file: ${file}\n`);
25
- return {};
26
- }
27
- else {
28
- return JSON.parse(projection.value.replaceAll("\\x22", '"'));
29
- }
30
- }
@@ -1,2 +0,0 @@
1
- export default function shouldFlipBeforeExport(projection: string): boolean;
2
- //# sourceMappingURL=shouldFlipBeforeExport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shouldFlipBeforeExport.d.ts","sourceRoot":"","sources":["../../src/helpers/shouldFlipBeforeExport.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,UAAU,EAAE,MAAM,WAEhE"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = shouldFlipBeforeExport;
4
- function shouldFlipBeforeExport(projection) {
5
- return projection.includes("proj=latlong");
6
- }
@@ -1,3 +0,0 @@
1
- import type { SimpleDB } from "../index.js";
2
- export default function writeProjectionsAndIndexes(simpleDB: SimpleDB, extension: string, file: string): void;
3
- //# sourceMappingURL=writeProjectionsAndIndexes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeProjectionsAndIndexes.d.ts","sourceRoot":"","sources":["../../src/helpers/writeProjectionsAndIndexes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,QA+Bb"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = writeProjectionsAndIndexes;
4
- const node_fs_1 = require("node:fs");
5
- function writeProjectionsAndIndexes(simpleDB, extension, file) {
6
- const allProjections = {};
7
- for (const table of simpleDB.tables) {
8
- if (Object.keys(table.projections).length > 0) {
9
- allProjections[table.name] = table.projections;
10
- }
11
- }
12
- const allProjectionsFile = `${file.replace(`.${extension}`, "")}_projections.json`;
13
- if ((0, node_fs_1.existsSync)(allProjectionsFile)) {
14
- (0, node_fs_1.rmSync)(allProjectionsFile);
15
- }
16
- if (Object.keys(allProjections).length > 0) {
17
- (0, node_fs_1.writeFileSync)(allProjectionsFile, JSON.stringify(allProjections));
18
- }
19
- const allIndexes = {};
20
- for (const table of simpleDB.tables) {
21
- if (table.indexes.length > 0) {
22
- allIndexes[table.name] = table.indexes;
23
- }
24
- }
25
- const allIndexesFile = `${file.replace(`.${extension}`, "")}_indexes.json`;
26
- if ((0, node_fs_1.existsSync)(allIndexesFile)) {
27
- (0, node_fs_1.rmSync)(allIndexesFile);
28
- }
29
- if (Object.keys(allIndexes).length > 0) {
30
- (0, node_fs_1.writeFileSync)(allIndexesFile, JSON.stringify(allIndexes));
31
- }
32
- }