np-belarus 1.1.5 → 1.2.6

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.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Связи drizzle для вложенных выборок `with`. На DDL не влияют —
3
+ * нужны только в schema-объекте при создании `drizzle()`.
4
+ *
5
+ * Канонические паттерны:
6
+ * - область → районы → точки (с сельсоветом, если есть):
7
+ * `regions.findMany( { with: { districts: { with: { locations: { with: { subdistrict: true } } } } } } )`
8
+ * - область → районы → сельсоветы:
9
+ * `regions.findMany( { with: { districts: { with: { subdistricts: true } } } } )`
10
+ * - сельсовет → точки: `subdistricts.findMany( { with: { locations: true } } )`
11
+ * - точка → район + область + сельсовет:
12
+ * `locations.findMany( { with: { district: true, region: true, subdistrict: true } } )`
13
+ */
14
+ /** Область → её районы. */
15
+ export declare const regionsRelations: import("drizzle-orm").Relations<"np_regions", {
16
+ districts: import("drizzle-orm").Many<"np_districts">;
17
+ }>;
18
+ /** Район → область, сельсоветы и населённые пункты. */
19
+ export declare const districtsRelations: import("drizzle-orm").Relations<"np_districts", {
20
+ region: import("drizzle-orm").One<"np_regions", true>;
21
+ subdistricts: import("drizzle-orm").Many<"np_subdistricts">;
22
+ locations: import("drizzle-orm").Many<"np_locations">;
23
+ }>;
24
+ /**
25
+ * Сельсовет → район и населённые пункты.
26
+ * Связь с районом составная: `(regionId, districtId)` —
27
+ * район уникален только внутри своей области.
28
+ */
29
+ export declare const subdistrictsRelations: import("drizzle-orm").Relations<"np_subdistricts", {
30
+ district: import("drizzle-orm").One<"np_districts", true>;
31
+ locations: import("drizzle-orm").Many<"np_locations">;
32
+ }>;
33
+ /**
34
+ * Населённый пункт → область, район и сельсовет.
35
+ * - `region` — прямой join по `regionId`; прямого FK в БД нет,
36
+ * консистентность гарантирована составным FK через `district`.
37
+ * - `district` и `subdistrict` — составные FK (массивы fields/references).
38
+ * - `subdistrict` опционален: у части точек `subdistrictId` равен NULL,
39
+ * тогда связь возвращает `null`.
40
+ */
41
+ export declare const locationsRelations: import("drizzle-orm").Relations<"np_locations", {
42
+ region: import("drizzle-orm").One<"np_regions", true>;
43
+ district: import("drizzle-orm").One<"np_districts", true>;
44
+ subdistrict: import("drizzle-orm").One<"np_subdistricts", false>;
45
+ }>;
@@ -0,0 +1,66 @@
1
+ import { relations } from "drizzle-orm";
2
+ import { districts } from "../schema/districts.js";
3
+ import { locations } from "../schema/locations.js";
4
+ import { regions } from "../schema/regions.js";
5
+ import { subdistricts } from "../schema/subdistricts.js";
6
+ /**
7
+ * Связи drizzle для вложенных выборок `with`. На DDL не влияют —
8
+ * нужны только в schema-объекте при создании `drizzle()`.
9
+ *
10
+ * Канонические паттерны:
11
+ * - область → районы → точки (с сельсоветом, если есть):
12
+ * `regions.findMany( { with: { districts: { with: { locations: { with: { subdistrict: true } } } } } } )`
13
+ * - область → районы → сельсоветы:
14
+ * `regions.findMany( { with: { districts: { with: { subdistricts: true } } } } )`
15
+ * - сельсовет → точки: `subdistricts.findMany( { with: { locations: true } } )`
16
+ * - точка → район + область + сельсовет:
17
+ * `locations.findMany( { with: { district: true, region: true, subdistrict: true } } )`
18
+ */
19
+ /** Область → её районы. */
20
+ export const regionsRelations = relations(regions, ({ many }) => ({
21
+ districts: many(districts),
22
+ }));
23
+ /** Район → область, сельсоветы и населённые пункты. */
24
+ export const districtsRelations = relations(districts, ({ one, many }) => ({
25
+ region: one(regions, {
26
+ fields: [districts.regionId],
27
+ references: [regions.id],
28
+ }),
29
+ subdistricts: many(subdistricts),
30
+ locations: many(locations),
31
+ }));
32
+ /**
33
+ * Сельсовет → район и населённые пункты.
34
+ * Связь с районом составная: `(regionId, districtId)` —
35
+ * район уникален только внутри своей области.
36
+ */
37
+ export const subdistrictsRelations = relations(subdistricts, ({ one, many }) => ({
38
+ district: one(districts, {
39
+ // составной FK: массивы fields/references для composite key
40
+ fields: [subdistricts.regionId, subdistricts.districtId],
41
+ references: [districts.regionId, districts.id],
42
+ }),
43
+ locations: many(locations),
44
+ }));
45
+ /**
46
+ * Населённый пункт → область, район и сельсовет.
47
+ * - `region` — прямой join по `regionId`; прямого FK в БД нет,
48
+ * консистентность гарантирована составным FK через `district`.
49
+ * - `district` и `subdistrict` — составные FK (массивы fields/references).
50
+ * - `subdistrict` опционален: у части точек `subdistrictId` равен NULL,
51
+ * тогда связь возвращает `null`.
52
+ */
53
+ export const locationsRelations = relations(locations, ({ one }) => ({
54
+ region: one(regions, {
55
+ fields: [locations.regionId],
56
+ references: [regions.id],
57
+ }),
58
+ district: one(districts, {
59
+ fields: [locations.regionId, locations.districtId],
60
+ references: [districts.regionId, districts.id],
61
+ }),
62
+ subdistrict: one(subdistricts, {
63
+ fields: [locations.regionId, locations.districtId, locations.subdistrictId],
64
+ references: [subdistricts.regionId, subdistricts.districtId, subdistricts.id],
65
+ }),
66
+ }));
@@ -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";
@@ -109,6 +109,23 @@ export declare const districts: import("drizzle-orm/pg-core").PgTableWithColumns
109
109
  identity: undefined;
110
110
  generated: undefined;
111
111
  }, {}, {}>;
112
+ archived: import("drizzle-orm/pg-core").PgColumn<{
113
+ name: "archived";
114
+ tableName: "np_districts";
115
+ dataType: "boolean";
116
+ columnType: "PgBoolean";
117
+ data: boolean;
118
+ driverParam: boolean;
119
+ notNull: true;
120
+ hasDefault: true;
121
+ isPrimaryKey: false;
122
+ isAutoincrement: false;
123
+ hasRuntimeDefault: false;
124
+ enumValues: undefined;
125
+ baseColumn: never;
126
+ identity: undefined;
127
+ generated: undefined;
128
+ }, {}, {}>;
112
129
  };
113
130
  dialect: 'pg';
114
131
  }>;
@@ -1,9 +1,9 @@
1
- import { foreignKey, integer, pgTable, text, unique } from "drizzle-orm/pg-core";
1
+ import { boolean, foreignKey, integer, pgTable, text, unique } from "drizzle-orm/pg-core";
2
2
  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 */
@@ -20,6 +20,8 @@ export const districts = pgTable("np_districts", {
20
20
  nameRu: text("name_ru").notNull(),
21
21
  /** Slug, созданный из русского названия района */
22
22
  slug: text("slug").notNull(),
23
+ /** В архиве: отсутствовала в данных при последнем сидировании */
24
+ archived: boolean("archived").notNull().default(false),
23
25
  }, (table) => [
24
26
  unique("np_districts_region_id_id_unique").on(table.regionId, table.id),
25
27
  ]);
@@ -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,38 @@ 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
+ }, {}, {}>;
288
+ archived: import("drizzle-orm/pg-core").PgColumn<{
289
+ name: "archived";
290
+ tableName: "np_locations";
291
+ dataType: "boolean";
292
+ columnType: "PgBoolean";
293
+ data: boolean;
294
+ driverParam: boolean;
295
+ notNull: true;
296
+ hasDefault: true;
297
+ isPrimaryKey: false;
298
+ isAutoincrement: false;
299
+ hasRuntimeDefault: false;
300
+ enumValues: undefined;
301
+ baseColumn: never;
302
+ identity: undefined;
303
+ generated: undefined;
304
+ }, {}, {}>;
291
305
  };
292
306
  dialect: 'pg';
293
307
  }>;
294
- export {};
@@ -1,23 +1,16 @@
1
- import { foreignKey, index, integer, pgEnum, pgTable, text, doublePrecision, varchar } from "drizzle-orm/pg-core";
1
+ import { foreignKey, index, integer, pgEnum, pgTable, text, doublePrecision, varchar, boolean } 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,19 @@ 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"),
45
+ /** В архиве: отсутствовала в данных при последнем сидировании */
46
+ archived: boolean("archived").notNull().default(false),
52
47
  }, (table) => [
53
48
  foreignKey({
54
- name: "np_places_region_district_fk",
49
+ name: "np_locations_region_district_fk",
55
50
  columns: [table.regionId, table.districtId],
56
51
  foreignColumns: [districts.regionId, districts.id],
57
52
  }),
58
53
  foreignKey({
59
- name: "np_places_region_district_subdistrict_fk",
54
+ name: "np_locations_region_district_subdistrict_fk",
60
55
  columns: [table.regionId, table.districtId, table.subdistrictId],
61
56
  foreignColumns: [subdistricts.regionId, subdistricts.districtId, subdistricts.id],
62
57
  }),
63
- index("np_places_name_ru_lemma_gin_idx").using("gin", table.nameRuLemma.op("gin_trgm_ops")),
58
+ index("np_locations_name_ru_lemma_gin_idx").using("gin", table.nameRuLemma.op("gin_trgm_ops")),
64
59
  ]);
@@ -92,6 +92,23 @@ export declare const regions: import("drizzle-orm/pg-core").PgTableWithColumns<{
92
92
  identity: undefined;
93
93
  generated: undefined;
94
94
  }, {}, {}>;
95
+ archived: import("drizzle-orm/pg-core").PgColumn<{
96
+ name: "archived";
97
+ tableName: "np_regions";
98
+ dataType: "boolean";
99
+ columnType: "PgBoolean";
100
+ data: boolean;
101
+ driverParam: boolean;
102
+ notNull: true;
103
+ hasDefault: true;
104
+ isPrimaryKey: false;
105
+ isAutoincrement: false;
106
+ hasRuntimeDefault: false;
107
+ enumValues: undefined;
108
+ baseColumn: never;
109
+ identity: undefined;
110
+ generated: undefined;
111
+ }, {}, {}>;
95
112
  };
96
113
  dialect: 'pg';
97
114
  }>;
@@ -1,4 +1,4 @@
1
- import { integer, pgTable, text } from "drizzle-orm/pg-core";
1
+ import { boolean, integer, pgTable, text } from "drizzle-orm/pg-core";
2
2
  /**
3
3
  * Области Беларуси (включая Минск как отдельную запись с id = 0).
4
4
  * Имена хранятся в трёх вариантах: `name` — по умолчанию/белорусская орфография,
@@ -15,4 +15,6 @@ export const regions = pgTable("np_regions", {
15
15
  nameRu: text("name_ru").notNull(),
16
16
  /** Slug, созданный из русского названия области */
17
17
  slug: text("slug").notNull(),
18
+ /** В архиве: отсутствовала в данных при последнем сидировании */
19
+ archived: boolean("archived").notNull().default(false),
18
20
  });
@@ -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";
@@ -126,6 +126,23 @@ export declare const subdistricts: import("drizzle-orm/pg-core").PgTableWithColu
126
126
  identity: undefined;
127
127
  generated: undefined;
128
128
  }, {}, {}>;
129
+ archived: import("drizzle-orm/pg-core").PgColumn<{
130
+ name: "archived";
131
+ tableName: "np_subdistricts";
132
+ dataType: "boolean";
133
+ columnType: "PgBoolean";
134
+ data: boolean;
135
+ driverParam: boolean;
136
+ notNull: true;
137
+ hasDefault: true;
138
+ isPrimaryKey: false;
139
+ isAutoincrement: false;
140
+ hasRuntimeDefault: false;
141
+ enumValues: undefined;
142
+ baseColumn: never;
143
+ identity: undefined;
144
+ generated: undefined;
145
+ }, {}, {}>;
129
146
  };
130
147
  dialect: 'pg';
131
148
  }>;
@@ -1,9 +1,9 @@
1
- import { foreignKey, integer, pgTable, text, unique } from "drizzle-orm/pg-core";
1
+ import { boolean, foreignKey, integer, pgTable, text, unique } from "drizzle-orm/pg-core";
2
2
  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 */
@@ -20,6 +20,8 @@ export const subdistricts = pgTable("np_subdistricts", {
20
20
  nameRu: text("name_ru").notNull(),
21
21
  /** Slug, созданный из русского названия сельсовета */
22
22
  slug: text("slug").notNull(),
23
+ /** В архиве: отсутствовала в данных при последнем сидировании */
24
+ archived: boolean("archived").notNull().default(false),
23
25
  }, (table) => [
24
26
  foreignKey({
25
27
  name: "np_subdistricts_region_district_fk",
@@ -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";