text-to-map 1.1.6 → 1.1.7
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/bin/knex.d.ts +1 -0
- package/dist/bin/knex.js +20 -0
- package/dist/db/db.d.ts +1 -1
- package/dist/db/db.js +2 -7
- package/dist/db/founders.js +1 -1
- package/dist/db/schools.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/bin/knex.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { disconnectKnex, getKnexDb } from "../db/db";
|
|
11
|
+
function main() {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const knex = getKnexDb();
|
|
14
|
+
yield knex.schema.alterTable("school_founder", (table) => {
|
|
15
|
+
table.unique(["school_izo", "founder_id"]);
|
|
16
|
+
});
|
|
17
|
+
yield disconnectKnex();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
main();
|
package/dist/db/db.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const nonEmptyOrNull: (value: string) => string | null;
|
|
|
21
21
|
* Efficiently insert multiple rows. If preventDuplicatesByFirstColumn is true, the first
|
|
22
22
|
* column should be unique (PK or UNIQUE).
|
|
23
23
|
*/
|
|
24
|
-
export declare const insertMultipleRows: (rows: string[][], table: string, columnNames: string[], preventDuplicates?: boolean
|
|
24
|
+
export declare const insertMultipleRows: (rows: string[][], table: string, columnNames: string[], preventDuplicates?: boolean) => Promise<number>;
|
|
25
25
|
/**
|
|
26
26
|
* Insert a single row and return the autoincremented ID.
|
|
27
27
|
*/
|
package/dist/db/db.js
CHANGED
|
@@ -115,17 +115,12 @@ export const nonEmptyOrNull = (value) => {
|
|
|
115
115
|
* Efficiently insert multiple rows. If preventDuplicatesByFirstColumn is true, the first
|
|
116
116
|
* column should be unique (PK or UNIQUE).
|
|
117
117
|
*/
|
|
118
|
-
export const insertMultipleRows = (rows, table, columnNames, preventDuplicates = true
|
|
118
|
+
export const insertMultipleRows = (rows, table, columnNames, preventDuplicates = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
119
|
if (rows.length === 0) {
|
|
120
120
|
return 0;
|
|
121
121
|
}
|
|
122
122
|
const insertPlaceholders = generate2DPlaceholders(columnNames.length, rows.length);
|
|
123
|
-
|
|
124
|
-
keyColumns = [columnNames[0]];
|
|
125
|
-
}
|
|
126
|
-
const onConfict = preventDuplicates
|
|
127
|
-
? `ON CONFLICT (${keyColumns.join(", ")}) DO NOTHING`
|
|
128
|
-
: "";
|
|
123
|
+
const onConfict = preventDuplicates ? `ON CONFLICT DO NOTHING` : "";
|
|
129
124
|
yield getKnexDb().raw(`INSERT INTO ${table} (${columnNames.join(",")}) VALUES ${insertPlaceholders} ${onConfict}`, rows.flat());
|
|
130
125
|
return rows.length;
|
|
131
126
|
});
|
package/dist/db/founders.js
CHANGED
|
@@ -86,7 +86,7 @@ export const insertFounders = (founders) => __awaiter(void 0, void 0, void 0, fu
|
|
|
86
86
|
schoolFounderConnectionData.push([school.izo, founderId]);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
const insertedConnections = yield insertMultipleRows(schoolFounderConnectionData, "school_founder", ["school_izo", "founder_id"], true
|
|
89
|
+
const insertedConnections = yield insertMultipleRows(schoolFounderConnectionData, "school_founder", ["school_izo", "founder_id"], true);
|
|
90
90
|
return insertedFounders + insertedConnections;
|
|
91
91
|
});
|
|
92
92
|
const getCityOfSchool = (izo) => __awaiter(void 0, void 0, void 0, function* () {
|
package/dist/db/schools.js
CHANGED
|
@@ -38,7 +38,7 @@ export const insertSchools = (schools) => __awaiter(void 0, void 0, void 0, func
|
|
|
38
38
|
// plus filter out duplicate locations (same address id + izo)
|
|
39
39
|
for (const location of locations) {
|
|
40
40
|
try {
|
|
41
|
-
insertedLocations += yield insertMultipleRows([location], "school_location", ["school_izo", "address_point_id"], true
|
|
41
|
+
insertedLocations += yield insertMultipleRows([location], "school_location", ["school_izo", "address_point_id"], true);
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
44
|
console.log(`Cannot add location with RUIAN code ${location[1]} (school IZO = ${location[0]}): code does not exist.`);
|
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"name": "text-to-map",
|
|
55
55
|
"description": "Text To Map usiluje o lepší, strojově zpracovatelné využití částí vyhlášek s výčtem ulic a dalších lokací. Jde o rozšiřitelnou sadu konceptů a nástrojů, které zajistí hladký převod výčtu ulic a jejich rozsahů v lidsky srozumitelném jazyce do strojově zpracovatelného, uchopitelného formátu.",
|
|
56
|
-
"version": "1.1.
|
|
56
|
+
"version": "1.1.7",
|
|
57
57
|
"main": "dist/index.js",
|
|
58
58
|
"types": "dist/index.d.ts",
|
|
59
59
|
"files": [
|