np-belarus 1.1.5 → 1.2.5

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Районы Беларуси. Каждый район принадлежит области (`regionId`).
3
3
  * Пара `(regionId, id)` уникальна и используется в составных внешних ключах
4
- * таблиц `np_subdistricts` и `np_places`.
4
+ * таблиц `np_subdistricts` и `np_locations`.
5
5
  */
6
6
  export declare const districts: import("drizzle-orm/pg-core").PgTableWithColumns<{
7
7
  name: "np_districts";
@@ -3,7 +3,7 @@ import { regions } from "./regions.js";
3
3
  /**
4
4
  * Районы Беларуси. Каждый район принадлежит области (`regionId`).
5
5
  * Пара `(regionId, id)` уникальна и используется в составных внешних ключах
6
- * таблиц `np_subdistricts` и `np_places`.
6
+ * таблиц `np_subdistricts` и `np_locations`.
7
7
  */
8
8
  export const districts = pgTable("np_districts", {
9
9
  /** Числовой идентификатор района, совпадает с id в np-districts.json */
@@ -1,5 +1,5 @@
1
1
  export { districts } from "./districts.js";
2
- export { places, placeTypeEnum } from "./places.js";
2
+ export { locations, locationTypeEnum } from "./locations.js";
3
3
  export { regions } from "./regions.js";
4
4
  export { subdistricts } from "./subdistricts.js";
5
- export type { PlaceType } from "./places.js";
5
+ export type { LocationType } from "./locations.js";
@@ -1,4 +1,4 @@
1
1
  export { districts } from "./districts.js";
2
- export { places, placeTypeEnum } from "./places.js";
2
+ export { locations, locationTypeEnum } from "./locations.js";
3
3
  export { regions } from "./regions.js";
4
4
  export { subdistricts } from "./subdistricts.js";
@@ -1,20 +1,19 @@
1
- /** Допустимые значения тега OpenStreetMap `place` для населённых пунктов. */
2
- declare const placeTypeValues: readonly ["city", "town", "village", "hamlet", "isolated_dwelling"];
3
- export type PlaceType = (typeof placeTypeValues)[number];
4
- export declare const placeTypeEnum: import("drizzle-orm/pg-core").PgEnum<["city", "town", "village", "hamlet", "isolated_dwelling"]>;
1
+ import { type LocationType } from "../shared/lib/location-types.js";
2
+ export type { LocationType };
3
+ export declare const locationTypeEnum: import("drizzle-orm/pg-core").PgEnum<["city", "town", "village", "hamlet", "isolated_dwelling"]>;
5
4
  /**
6
5
  * Населённые пункты Беларуси. Каждая запись ссылается на область, район
7
6
  * и (опционально) сельсовет через составные внешние ключи — это гарантирует,
8
7
  * что `districtId` принадлежит `regionId`, а `subdistrictId` — выбранному
9
8
  * району.
10
9
  */
11
- export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
12
- name: "np_places";
10
+ export declare const locations: import("drizzle-orm/pg-core").PgTableWithColumns<{
11
+ name: "np_locations";
13
12
  schema: undefined;
14
13
  columns: {
15
14
  id: import("drizzle-orm/pg-core").PgColumn<{
16
15
  name: "id";
17
- tableName: "np_places";
16
+ tableName: "np_locations";
18
17
  dataType: "number";
19
18
  columnType: "PgInteger";
20
19
  data: number;
@@ -31,7 +30,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
31
30
  }, {}, {}>;
32
31
  lon: import("drizzle-orm/pg-core").PgColumn<{
33
32
  name: "lon";
34
- tableName: "np_places";
33
+ tableName: "np_locations";
35
34
  dataType: "number";
36
35
  columnType: "PgDoublePrecision";
37
36
  data: number;
@@ -48,7 +47,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
48
47
  }, {}, {}>;
49
48
  lat: import("drizzle-orm/pg-core").PgColumn<{
50
49
  name: "lat";
51
- tableName: "np_places";
50
+ tableName: "np_locations";
52
51
  dataType: "number";
53
52
  columnType: "PgDoublePrecision";
54
53
  data: number;
@@ -65,7 +64,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
65
64
  }, {}, {}>;
66
65
  regionId: import("drizzle-orm/pg-core").PgColumn<{
67
66
  name: "region_id";
68
- tableName: "np_places";
67
+ tableName: "np_locations";
69
68
  dataType: "number";
70
69
  columnType: "PgInteger";
71
70
  data: number;
@@ -82,7 +81,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
82
81
  }, {}, {}>;
83
82
  districtId: import("drizzle-orm/pg-core").PgColumn<{
84
83
  name: "district_id";
85
- tableName: "np_places";
84
+ tableName: "np_locations";
86
85
  dataType: "number";
87
86
  columnType: "PgInteger";
88
87
  data: number;
@@ -99,7 +98,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
99
98
  }, {}, {}>;
100
99
  subdistrictId: import("drizzle-orm/pg-core").PgColumn<{
101
100
  name: "subdistrict_id";
102
- tableName: "np_places";
101
+ tableName: "np_locations";
103
102
  dataType: "number";
104
103
  columnType: "PgInteger";
105
104
  data: number;
@@ -114,9 +113,9 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
114
113
  identity: undefined;
115
114
  generated: undefined;
116
115
  }, {}, {}>;
117
- place: import("drizzle-orm/pg-core").PgColumn<{
118
- name: "place";
119
- tableName: "np_places";
116
+ locationType: import("drizzle-orm/pg-core").PgColumn<{
117
+ name: "location_type";
118
+ tableName: "np_locations";
120
119
  dataType: "string";
121
120
  columnType: "PgEnumColumn";
122
121
  data: "city" | "hamlet" | "isolated_dwelling" | "town" | "village";
@@ -133,7 +132,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
133
132
  }, {}, {}>;
134
133
  name: import("drizzle-orm/pg-core").PgColumn<{
135
134
  name: "name";
136
- tableName: "np_places";
135
+ tableName: "np_locations";
137
136
  dataType: "string";
138
137
  columnType: "PgText";
139
138
  data: string;
@@ -150,7 +149,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
150
149
  }, {}, {}>;
151
150
  nameBe: import("drizzle-orm/pg-core").PgColumn<{
152
151
  name: "name_be";
153
- tableName: "np_places";
152
+ tableName: "np_locations";
154
153
  dataType: "string";
155
154
  columnType: "PgText";
156
155
  data: string;
@@ -167,7 +166,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
167
166
  }, {}, {}>;
168
167
  nameRu: import("drizzle-orm/pg-core").PgColumn<{
169
168
  name: "name_ru";
170
- tableName: "np_places";
169
+ tableName: "np_locations";
171
170
  dataType: "string";
172
171
  columnType: "PgText";
173
172
  data: string;
@@ -184,7 +183,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
184
183
  }, {}, {}>;
185
184
  slug: import("drizzle-orm/pg-core").PgColumn<{
186
185
  name: "slug";
187
- tableName: "np_places";
186
+ tableName: "np_locations";
188
187
  dataType: "string";
189
188
  columnType: "PgVarchar";
190
189
  data: string;
@@ -203,7 +202,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
203
202
  }>;
204
203
  nameRuLemma: import("drizzle-orm/pg-core").PgColumn<{
205
204
  name: "name_ru_lemma";
206
- tableName: "np_places";
205
+ tableName: "np_locations";
207
206
  dataType: "string";
208
207
  columnType: "PgText";
209
208
  data: string;
@@ -220,7 +219,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
220
219
  }, {}, {}>;
221
220
  namePrefix: import("drizzle-orm/pg-core").PgColumn<{
222
221
  name: "name_prefix";
223
- tableName: "np_places";
222
+ tableName: "np_locations";
224
223
  dataType: "string";
225
224
  columnType: "PgText";
226
225
  data: string;
@@ -237,7 +236,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
237
236
  }, {}, {}>;
238
237
  namePrefixBe: import("drizzle-orm/pg-core").PgColumn<{
239
238
  name: "name_prefix_be";
240
- tableName: "np_places";
239
+ tableName: "np_locations";
241
240
  dataType: "string";
242
241
  columnType: "PgText";
243
242
  data: string;
@@ -254,7 +253,7 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
254
253
  }, {}, {}>;
255
254
  namePrefixRu: import("drizzle-orm/pg-core").PgColumn<{
256
255
  name: "name_prefix_ru";
257
- tableName: "np_places";
256
+ tableName: "np_locations";
258
257
  dataType: "string";
259
258
  columnType: "PgText";
260
259
  data: string;
@@ -271,24 +270,21 @@ export declare const places: import("drizzle-orm/pg-core").PgTableWithColumns<{
271
270
  }, {}, {}>;
272
271
  population: import("drizzle-orm/pg-core").PgColumn<{
273
272
  name: "population";
274
- tableName: "np_places";
275
- dataType: "string";
276
- columnType: "PgVarchar";
277
- data: string;
278
- driverParam: string;
273
+ tableName: "np_locations";
274
+ dataType: "number";
275
+ columnType: "PgInteger";
276
+ data: number;
277
+ driverParam: string | number;
279
278
  notNull: false;
280
279
  hasDefault: false;
281
280
  isPrimaryKey: false;
282
281
  isAutoincrement: false;
283
282
  hasRuntimeDefault: false;
284
- enumValues: [string, ...string[]];
283
+ enumValues: undefined;
285
284
  baseColumn: never;
286
285
  identity: undefined;
287
286
  generated: undefined;
288
- }, {}, {
289
- length: 12;
290
- }>;
287
+ }, {}, {}>;
291
288
  };
292
289
  dialect: 'pg';
293
290
  }>;
294
- export {};
@@ -1,23 +1,16 @@
1
1
  import { foreignKey, index, integer, pgEnum, pgTable, text, doublePrecision, varchar } from "drizzle-orm/pg-core";
2
+ import { locationTypes } from "../shared/lib/location-types.js";
2
3
  import { districts } from "./districts.js";
3
4
  import { subdistricts } from "./subdistricts.js";
4
- /** Допустимые значения тега OpenStreetMap `place` для населённых пунктов. */
5
- const placeTypeValues = [
6
- "city",
7
- "town",
8
- "village",
9
- "hamlet",
10
- "isolated_dwelling",
11
- ];
12
- export const placeTypeEnum = pgEnum("np_place_type", [...placeTypeValues]);
5
+ export const locationTypeEnum = pgEnum("np_location_type", [...locationTypes]);
13
6
  /**
14
7
  * Населённые пункты Беларуси. Каждая запись ссылается на область, район
15
8
  * и (опционально) сельсовет через составные внешние ключи — это гарантирует,
16
9
  * что `districtId` принадлежит `regionId`, а `subdistrictId` — выбранному
17
10
  * району.
18
11
  */
19
- export const places = pgTable("np_places", {
20
- /** Идентификатор элемента OSM, совпадает с id в np-places.json */
12
+ export const locations = pgTable("np_locations", {
13
+ /** Идентификатор элемента OSM, совпадает с id в np-locations.json */
21
14
  id: integer("id").primaryKey(),
22
15
  /** Долгота в десятичных градусах (WGS84) */
23
16
  lon: doublePrecision("lon").notNull(),
@@ -30,7 +23,7 @@ export const places = pgTable("np_places", {
30
23
  /** Идентификатор сельсовета внутри района (может отсутствовать) */
31
24
  subdistrictId: integer("subdistrict_id"),
32
25
  /** Тип населённого пункта по классификации OSM `place` */
33
- place: placeTypeEnum("place").notNull(),
26
+ locationType: locationTypeEnum("location_type").notNull(),
34
27
  /** Название населённого пункта (вариант по умолчанию) */
35
28
  name: text("name"),
36
29
  /** Название на белорусском языке */
@@ -48,17 +41,17 @@ export const places = pgTable("np_places", {
48
41
  /** Префикс на русском языке */
49
42
  namePrefixRu: text("name_prefix_ru"),
50
43
  /** Население по данным OSM */
51
- population: varchar("population", { length: 12 }),
44
+ population: integer("population"),
52
45
  }, (table) => [
53
46
  foreignKey({
54
- name: "np_places_region_district_fk",
47
+ name: "np_locations_region_district_fk",
55
48
  columns: [table.regionId, table.districtId],
56
49
  foreignColumns: [districts.regionId, districts.id],
57
50
  }),
58
51
  foreignKey({
59
- name: "np_places_region_district_subdistrict_fk",
52
+ name: "np_locations_region_district_subdistrict_fk",
60
53
  columns: [table.regionId, table.districtId, table.subdistrictId],
61
54
  foreignColumns: [subdistricts.regionId, subdistricts.districtId, subdistricts.id],
62
55
  }),
63
- index("np_places_name_ru_lemma_gin_idx").using("gin", table.nameRuLemma.op("gin_trgm_ops")),
56
+ index("np_locations_name_ru_lemma_gin_idx").using("gin", table.nameRuLemma.op("gin_trgm_ops")),
64
57
  ]);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Сельсоветы (подрайоны) Беларуси. Каждый сельсовет привязан к конкретному
3
3
  * району внутри области; тройка `(regionId, districtId, id)` уникальна и
4
- * используется в составном внешнем ключе таблицы `np_places`.
4
+ * используется в составном внешнем ключе таблицы `np_locations`.
5
5
  */
6
6
  export declare const subdistricts: import("drizzle-orm/pg-core").PgTableWithColumns<{
7
7
  name: "np_subdistricts";
@@ -3,7 +3,7 @@ import { districts } from "./districts.js";
3
3
  /**
4
4
  * Сельсоветы (подрайоны) Беларуси. Каждый сельсовет привязан к конкретному
5
5
  * району внутри области; тройка `(regionId, districtId, id)` уникальна и
6
- * используется в составном внешнем ключе таблицы `np_places`.
6
+ * используется в составном внешнем ключе таблицы `np_locations`.
7
7
  */
8
8
  export const subdistricts = pgTable("np_subdistricts", {
9
9
  /** Числовой идентификатор сельсовета, совпадает с id в np-subdistricts.json */
@@ -3,6 +3,6 @@
3
3
  * Каждый массив содержит строки, готовые к вставке через drizzle-orm.
4
4
  */
5
5
  export { districtsSeed } from "./districts.js";
6
- export { placesSeed } from "./places.js";
6
+ export { locationsSeed } from "./locations.js";
7
7
  export { regionsSeed } from "./regions.js";
8
8
  export { subdistrictsSeed } from "./subdistricts.js";
@@ -3,6 +3,6 @@
3
3
  * Каждый массив содержит строки, готовые к вставке через drizzle-orm.
4
4
  */
5
5
  export { districtsSeed } from "./districts.js";
6
- export { placesSeed } from "./places.js";
6
+ export { locationsSeed } from "./locations.js";
7
7
  export { regionsSeed } from "./regions.js";
8
8
  export { subdistrictsSeed } from "./subdistricts.js";
@@ -1,7 +1,7 @@
1
- import type { NewPlace } from "../types/tables.js";
1
+ import type { NewLocation } from "../types/tables.js";
2
2
  /**
3
- * Данные для сидирования таблицы `np_places`.
4
- * Разворачивает вложенные `names`/`names.prefix` из np-places.json
3
+ * Данные для сидирования таблицы `np_locations`.
4
+ * Разворачивает вложенные `names`/`names.prefix` из np-locations.json
5
5
  * в плоские колонки `name*`/`namePrefix*`; адрес в таблицу не попадает.
6
6
  */
7
- export declare const placesSeed: NewPlace[];
7
+ export declare const locationsSeed: NewLocation[];
@@ -0,0 +1,24 @@
1
+ import locationsData from "../data/np-locations.json" with { type: "json" };
2
+ /**
3
+ * Данные для сидирования таблицы `np_locations`.
4
+ * Разворачивает вложенные `names`/`names.prefix` из np-locations.json
5
+ * в плоские колонки `name*`/`namePrefix*`; адрес в таблицу не попадает.
6
+ */
7
+ export const locationsSeed = locationsData.map((location) => ({
8
+ id: location.id,
9
+ lon: location.lon,
10
+ lat: location.lat,
11
+ regionId: location.regionId,
12
+ districtId: location.districtId,
13
+ ...(location.subdistrictId === undefined ? {} : { subdistrictId: location.subdistrictId }),
14
+ locationType: location.locationType,
15
+ slug: location.slug,
16
+ name: location.names?.default,
17
+ nameBe: location.names?.be,
18
+ nameRu: location.names?.ru,
19
+ nameRuLemma: location.names.ruLemma,
20
+ namePrefix: location.names?.prefix?.default,
21
+ namePrefixBe: location.names?.prefix?.be,
22
+ namePrefixRu: location.names?.prefix?.ru,
23
+ population: location.population,
24
+ }));
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Допустимые значения тега OpenStreetMap `place` для населённых пунктов.
3
+ * @see https://wiki.openstreetmap.org/wiki/Key:place
4
+ */
5
+ export declare const locationTypes: readonly ["city", "town", "village", "hamlet", "isolated_dwelling"];
6
+ export type LocationType = (typeof locationTypes)[number];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Допустимые значения тега OpenStreetMap `place` для населённых пунктов.
3
+ * @see https://wiki.openstreetmap.org/wiki/Key:place
4
+ */
5
+ export const locationTypes = [
6
+ "city", // город
7
+ "town", // небольшой город или поселок
8
+ "village", // деревня или село
9
+ "hamlet", // маленькая деревня, хутор или небольшой населенный пункт
10
+ "isolated_dwelling" // отдельно стоящее жильё или усадьба вне основного населённого пункта
11
+ ];
@@ -1,2 +1,2 @@
1
- export type * from "./place.js";
1
+ export type * from "./location.js";
2
2
  export type * from "./tables.js";
@@ -1,6 +1,6 @@
1
- import type { PlaceType } from "../schema/places.js";
2
- export type { PlaceType };
3
- export interface PlaceNames {
1
+ import type { LocationType } from "../schema/locations.js";
2
+ export type { LocationType };
3
+ export interface LocationNames {
4
4
  default?: string;
5
5
  be?: string;
6
6
  ru?: string;
@@ -11,20 +11,20 @@ export interface PlaceNames {
11
11
  ru?: string;
12
12
  };
13
13
  }
14
- export interface PlaceAddress {
14
+ export interface LocationAddress {
15
15
  city?: string;
16
16
  country?: string;
17
17
  }
18
- export interface Place {
18
+ export interface Location {
19
19
  id: number;
20
20
  lon: number;
21
21
  lat: number;
22
22
  regionId: number;
23
23
  districtId: number;
24
24
  subdistrictId?: number;
25
- place: PlaceType;
25
+ locationType: LocationType;
26
26
  slug: string;
27
- names: PlaceNames;
28
- address?: PlaceAddress;
29
- population?: string;
27
+ names: LocationNames;
28
+ address?: LocationAddress;
29
+ population?: number;
30
30
  }
@@ -1,6 +1,6 @@
1
- import type { districts } from "../schema/districts.js";
2
- import type { places } from "../schema/places.js";
1
+ import type { locations } from "../schema/locations.js";
3
2
  import type { regions } from "../schema/regions.js";
3
+ import type { districts } from "../schema/districts.js";
4
4
  import type { subdistricts } from "../schema/subdistricts.js";
5
5
  export type RegionRow = typeof regions.$inferSelect;
6
6
  export type NewRegion = typeof regions.$inferInsert;
@@ -8,5 +8,5 @@ export type DistrictRow = typeof districts.$inferSelect;
8
8
  export type NewDistrict = typeof districts.$inferInsert;
9
9
  export type SubdistrictRow = typeof subdistricts.$inferSelect;
10
10
  export type NewSubdistrict = typeof subdistricts.$inferInsert;
11
- export type PlaceRow = typeof places.$inferSelect;
12
- export type NewPlace = typeof places.$inferInsert;
11
+ export type LocationRow = typeof locations.$inferSelect;
12
+ export type NewLocation = typeof locations.$inferInsert;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "np-belarus",
3
- "version": "1.1.5",
3
+ "version": "1.2.5",
4
4
  "description": "Belarus settlements and administrative divisions with PostgreSQL schemas and seed data.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Yury Samakhvalau",
@@ -50,9 +50,9 @@
50
50
  }
51
51
  },
52
52
  "scripts": {
53
- "places": "node index.ts",
54
- "validate": "node validate-places.mjs",
55
- "build": "npm run places && npm run validate",
53
+ "locations": "node index.ts",
54
+ "validate": "node validate-locations.mjs",
55
+ "build": "npm run locations && npm run validate",
56
56
  "build:package": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.package.json",
57
57
  "prepack": "npm run build:package",
58
58
  "typecheck": "tsc --noEmit"