@konstit/dne 0.0.2 → 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.
- package/README.md +215 -13
- package/data/dne.bin +0 -0
- package/dist/bairro.d.ts +27 -0
- package/dist/bairro.js +9 -0
- package/dist/bairro.js.map +1 -0
- package/dist/binary-db-errors.d.ts +56 -0
- package/dist/binary-db-errors.js +68 -0
- package/dist/binary-db-errors.js.map +1 -0
- package/dist/binary-db-format.d.ts +192 -0
- package/dist/binary-db-format.js +250 -0
- package/dist/binary-db-format.js.map +1 -0
- package/dist/binary-db-reader.d.ts +114 -0
- package/dist/binary-db-reader.js +700 -0
- package/dist/binary-db-reader.js.map +1 -0
- package/dist/cep.d.ts +50 -0
- package/dist/cep.js +184 -0
- package/dist/cep.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.js +55 -33
- package/dist/index.js.map +29 -16
- package/dist/library.d.ts +10 -0
- package/dist/library.js +8 -0
- package/dist/library.js.map +1 -0
- package/dist/schema.d.ts +88 -0
- package/dist/schema.js +233 -0
- package/dist/schema.js.map +1 -0
- package/dist/settings.d.ts +34 -0
- package/dist/settings.js +35 -0
- package/dist/settings.js.map +1 -0
- package/dist/sqlite-db-errors.d.ts +40 -0
- package/dist/sqlite-db-errors.js +54 -0
- package/dist/sqlite-db-errors.js.map +1 -0
- package/dist/sqlite-db-reader.d.ts +130 -0
- package/dist/sqlite-db-reader.js +307 -0
- package/dist/sqlite-db-reader.js.map +1 -0
- package/dist/sqlite-db-schema.d.ts +49 -0
- package/dist/sqlite-db-schema.js +115 -0
- package/dist/sqlite-db-schema.js.map +1 -0
- package/dist/types.d.ts +90 -0
- package/dist/types.js +49 -0
- package/dist/types.js.map +1 -0
- package/package.json +17 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Public binary reader, format constants, file helpers, errors, and neighborhood types. */
|
|
2
|
+
export * from './binary-db-reader.ts';
|
|
3
|
+
/** SQLite reader and its typed errors. */
|
|
4
|
+
export { DneDatabaseClosedError, DneDatabaseDataError, DneDatabaseError, type DneDatabaseErrorCode, DneDatabaseIOError, DneDatabaseQueryError, DneDatabaseReader, DneDatabaseSchemaError, } from './sqlite-db-reader.ts';
|
|
5
|
+
/** CEP helpers and address records shared by both readers. */
|
|
6
|
+
export { CEP_RANGES, cepToU32, formatCep, normalizeCep, ufForCep } from './cep.ts';
|
|
7
|
+
export type { DneRow, LoadMetadata, UF } from './types.ts';
|
|
8
|
+
export { parseUF } from './types.ts';
|
|
9
|
+
/** Descriptive locality classification and postal coding status returned by CEP lookups. */
|
|
10
|
+
export type { LocalidadeSituacao, LocalidadeTipo } from './schema.ts';
|
package/dist/library.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Public binary reader, format constants, file helpers, errors, and neighborhood types. */
|
|
2
|
+
export * from "./binary-db-reader.js";
|
|
3
|
+
/** SQLite reader and its typed errors. */
|
|
4
|
+
export { DneDatabaseClosedError, DneDatabaseDataError, DneDatabaseError, DneDatabaseIOError, DneDatabaseQueryError, DneDatabaseReader, DneDatabaseSchemaError, } from "./sqlite-db-reader.js";
|
|
5
|
+
/** CEP helpers and address records shared by both readers. */
|
|
6
|
+
export { CEP_RANGES, cepToU32, formatCep, normalizeCep, ufForCep } from "./cep.js";
|
|
7
|
+
export { parseUF } from "./types.js";
|
|
8
|
+
//# sourceMappingURL=library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,cAAc,uBAAuB,CAAC;AACtC,0CAA0C;AAC1C,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAEhB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,8DAA8D;AAC9D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnF,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Logical schema revision recorded in load metadata to invalidate outdated imports. */
|
|
2
|
+
export declare const DATABASE_SCHEMA_VERSION = "4";
|
|
3
|
+
/** DNE locality codes in the order used by the binary format: municipality, district, village. */
|
|
4
|
+
export declare const LOCALIDADE_TIPO_CODIGOS: readonly ["M", "D", "P"];
|
|
5
|
+
/** Original `LOC_IN_TIPO_LOC` values retained in DNE imports and SQLite storage. */
|
|
6
|
+
export type LocalidadeTipoCodigo = (typeof LOCALIDADE_TIPO_CODIGOS)[number];
|
|
7
|
+
/** Original `LOC_IN_SIT` values retained in DNE imports and SQLite storage. */
|
|
8
|
+
export type LocalidadeSituacaoCodigo = 0 | 1 | 2 | 3;
|
|
9
|
+
/** Descriptive locality types in the same order as `LOCALIDADE_TIPO_CODIGOS`. */
|
|
10
|
+
export declare const LOCALIDADE_TIPOS: readonly ["municipio", "distrito", "povoado"];
|
|
11
|
+
/** Descriptive classification of the originating locality returned by CEP lookups. */
|
|
12
|
+
export type LocalidadeTipo = (typeof LOCALIDADE_TIPOS)[number];
|
|
13
|
+
/** Descriptive postal coding statuses indexed by the original `LOC_IN_SIT` code. */
|
|
14
|
+
export declare const LOCALIDADE_SITUACOES: readonly ["sem_codificacao_por_logradouro", "codificada_por_logradouro", "inserida_na_codificacao_por_logradouro", "em_codificacao_por_logradouro"];
|
|
15
|
+
/** Postal coding status of the originating locality returned by CEP lookups. */
|
|
16
|
+
export type LocalidadeSituacao = (typeof LOCALIDADE_SITUACOES)[number];
|
|
17
|
+
/** SQLite column declaration used to generate the unified database schema. */
|
|
18
|
+
export type ColumnDefinition = {
|
|
19
|
+
/** Trusted SQL expression inserted into a CHECK constraint; not user-supplied SQL. */
|
|
20
|
+
check?: string;
|
|
21
|
+
/** SQL comment describing the stored value. */
|
|
22
|
+
comment?: string;
|
|
23
|
+
/** Physical column name, quoted when generating SQL. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** SQLite storage affinity. */
|
|
26
|
+
type: 'TEXT' | 'INTEGER';
|
|
27
|
+
/** Includes the column in the table's primary key and implies NOT NULL. */
|
|
28
|
+
primaryKey?: boolean;
|
|
29
|
+
/** Rejects SQL NULL values when enabled. */
|
|
30
|
+
notNull?: boolean;
|
|
31
|
+
/** Optional foreign key, using a physical table name and its referenced column. */
|
|
32
|
+
references?: {
|
|
33
|
+
table: string;
|
|
34
|
+
column: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/** Describes a DNE source file or the generated unified SQLite table. */
|
|
38
|
+
export type TableDefinition = {
|
|
39
|
+
/** Physical table name after applying any caller-provided override. */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Stable logical name used to identify the source and apply overrides. */
|
|
42
|
+
originalName: string;
|
|
43
|
+
/** Output columns; source-only definitions may have an empty array. */
|
|
44
|
+
columns: ColumnDefinition[];
|
|
45
|
+
/** Source filename pattern; null disables file matching and omission derives it from `originalName`. */
|
|
46
|
+
fileGlob?: string | null;
|
|
47
|
+
/** Maps logical source fields to zero-based positions in an @-delimited record. */
|
|
48
|
+
sourceFields?: Readonly<Record<string, number>>;
|
|
49
|
+
/** Marks the generated CEP table, which has no corresponding source file. */
|
|
50
|
+
unifiedTable?: boolean;
|
|
51
|
+
/** Stores a table directly in its primary-key B-tree without a separate rowid. */
|
|
52
|
+
withoutRowid?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/** Maps stable logical table names to caller-selected physical table names. */
|
|
55
|
+
export type TableNameMap = Record<string, string>;
|
|
56
|
+
/**
|
|
57
|
+
* Creates independently mutable source and output schema definitions.
|
|
58
|
+
* @param tableNames - Optional physical-name overrides keyed by the original table name.
|
|
59
|
+
* @returns New table, column, and source-field objects for this invocation.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildSchema(tableNames?: TableNameMap): TableDefinition[];
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves the generated CEP table from a schema.
|
|
64
|
+
* @param schema - Source and output table definitions.
|
|
65
|
+
* @returns The first definition marked as the unified table, without copying it.
|
|
66
|
+
* @throws {Error} If the schema has no unified table.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getUnifiedTable(schema: readonly TableDefinition[]): TableDefinition;
|
|
69
|
+
/**
|
|
70
|
+
* Lists persisted tables in parent-before-child creation and insertion order.
|
|
71
|
+
* @param schema - Source and output table definitions returned by `buildSchema`.
|
|
72
|
+
* @returns Definitions with output columns; source-only definitions are excluded.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getStoredTables(schema: readonly TableDefinition[]): TableDefinition[];
|
|
75
|
+
/**
|
|
76
|
+
* Resolves the source filename pattern for a table.
|
|
77
|
+
* @param table - Source or output table definition.
|
|
78
|
+
* @returns The explicit or derived uppercase TXT pattern, or null for a generated table.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getTableFilesGlob(table: TableDefinition): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Resolves logical source fields to their positions in a delimited record.
|
|
83
|
+
* @param table - Definition containing a source-field mapping.
|
|
84
|
+
* @param fields - Field names in the desired output order.
|
|
85
|
+
* @returns Zero-based indexes in the same order as `fields`.
|
|
86
|
+
* @throws {Error} If the mapping or any requested field is missing.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getSourceFieldIndexes(table: TableDefinition, fields: readonly string[]): number[];
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/** Logical schema revision recorded in load metadata to invalidate outdated imports. */
|
|
2
|
+
export const DATABASE_SCHEMA_VERSION = '4';
|
|
3
|
+
/** DNE locality codes in the order used by the binary format: municipality, district, village. */
|
|
4
|
+
export const LOCALIDADE_TIPO_CODIGOS = ['M', 'D', 'P'];
|
|
5
|
+
/** Descriptive locality types in the same order as `LOCALIDADE_TIPO_CODIGOS`. */
|
|
6
|
+
export const LOCALIDADE_TIPOS = ['municipio', 'distrito', 'povoado'];
|
|
7
|
+
/** Descriptive postal coding statuses indexed by the original `LOC_IN_SIT` code. */
|
|
8
|
+
export const LOCALIDADE_SITUACOES = [
|
|
9
|
+
'sem_codificacao_por_logradouro',
|
|
10
|
+
'codificada_por_logradouro',
|
|
11
|
+
'inserida_na_codificacao_por_logradouro',
|
|
12
|
+
'em_codificacao_por_logradouro',
|
|
13
|
+
];
|
|
14
|
+
const baseTables = [
|
|
15
|
+
{
|
|
16
|
+
name: 'log_localidade',
|
|
17
|
+
originalName: 'log_localidade',
|
|
18
|
+
sourceFields: {
|
|
19
|
+
locNu: 0,
|
|
20
|
+
uf: 1,
|
|
21
|
+
nome: 2,
|
|
22
|
+
cep: 3,
|
|
23
|
+
situacao: 4,
|
|
24
|
+
tipo: 5,
|
|
25
|
+
locNuSub: 6,
|
|
26
|
+
munNu: 8,
|
|
27
|
+
},
|
|
28
|
+
columns: [],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'log_bairro',
|
|
32
|
+
originalName: 'log_bairro',
|
|
33
|
+
sourceFields: {
|
|
34
|
+
baiNu: 0,
|
|
35
|
+
uf: 1,
|
|
36
|
+
locNu: 2,
|
|
37
|
+
bairro: 3,
|
|
38
|
+
abreviado: 4,
|
|
39
|
+
},
|
|
40
|
+
columns: [],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'log_faixa_bairro',
|
|
44
|
+
originalName: 'log_faixa_bairro',
|
|
45
|
+
sourceFields: { baiNu: 0, cepInicial: 1, cepFinal: 2 },
|
|
46
|
+
columns: [],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'log_cpc',
|
|
50
|
+
originalName: 'log_cpc',
|
|
51
|
+
sourceFields: {
|
|
52
|
+
uf: 1,
|
|
53
|
+
locNu: 2,
|
|
54
|
+
nome: 3,
|
|
55
|
+
endereco: 4,
|
|
56
|
+
cep: 5,
|
|
57
|
+
},
|
|
58
|
+
columns: [],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'log_logradouro',
|
|
62
|
+
originalName: 'log_logradouro',
|
|
63
|
+
fileGlob: 'LOG_LOGRADOURO_*.TXT',
|
|
64
|
+
sourceFields: {
|
|
65
|
+
uf: 1,
|
|
66
|
+
locNu: 2,
|
|
67
|
+
baiNuIni: 3,
|
|
68
|
+
logNo: 5,
|
|
69
|
+
cep: 7,
|
|
70
|
+
tloTx: 8,
|
|
71
|
+
logStaTlo: 9,
|
|
72
|
+
},
|
|
73
|
+
columns: [],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'log_grande_usuario',
|
|
77
|
+
originalName: 'log_grande_usuario',
|
|
78
|
+
sourceFields: {
|
|
79
|
+
uf: 1,
|
|
80
|
+
locNu: 2,
|
|
81
|
+
baiNu: 3,
|
|
82
|
+
nome: 5,
|
|
83
|
+
endereco: 6,
|
|
84
|
+
cep: 7,
|
|
85
|
+
},
|
|
86
|
+
columns: [],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'log_unid_oper',
|
|
90
|
+
originalName: 'log_unid_oper',
|
|
91
|
+
sourceFields: {
|
|
92
|
+
uf: 1,
|
|
93
|
+
locNu: 2,
|
|
94
|
+
baiNu: 3,
|
|
95
|
+
nome: 5,
|
|
96
|
+
endereco: 6,
|
|
97
|
+
cep: 7,
|
|
98
|
+
},
|
|
99
|
+
columns: [],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'bairros',
|
|
103
|
+
originalName: 'bairros',
|
|
104
|
+
fileGlob: null,
|
|
105
|
+
columns: [
|
|
106
|
+
{ name: 'bairro_id', type: 'INTEGER', primaryKey: true, check: 'bairro_id > 0' },
|
|
107
|
+
{ name: 'localidade_id', type: 'INTEGER', notNull: true, check: 'localidade_id > 0' },
|
|
108
|
+
{ name: 'uf', type: 'TEXT', notNull: true },
|
|
109
|
+
{ name: 'nome', type: 'TEXT', notNull: true },
|
|
110
|
+
{ name: 'nome_abreviado', type: 'TEXT' },
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'bairro_faixas',
|
|
115
|
+
originalName: 'bairro_faixas',
|
|
116
|
+
fileGlob: null,
|
|
117
|
+
withoutRowid: true,
|
|
118
|
+
columns: [
|
|
119
|
+
{ name: 'bairro_id', type: 'INTEGER', primaryKey: true, references: { table: 'bairros', column: 'bairro_id' } },
|
|
120
|
+
{
|
|
121
|
+
name: 'cep_inicial',
|
|
122
|
+
type: 'TEXT',
|
|
123
|
+
primaryKey: true,
|
|
124
|
+
check: 'length(cep_inicial) = 8 AND cep_inicial NOT GLOB \'*[^0-9]*\'',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'cep_final',
|
|
128
|
+
type: 'TEXT',
|
|
129
|
+
primaryKey: true,
|
|
130
|
+
check: 'length(cep_final) = 8 AND cep_final NOT GLOB \'*[^0-9]*\' AND cep_inicial <= cep_final',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'cep_unificado',
|
|
136
|
+
originalName: 'cep_unificado',
|
|
137
|
+
fileGlob: null,
|
|
138
|
+
unifiedTable: true,
|
|
139
|
+
columns: [
|
|
140
|
+
{
|
|
141
|
+
name: 'cep',
|
|
142
|
+
type: 'TEXT',
|
|
143
|
+
primaryKey: true,
|
|
144
|
+
comment: 'Contém somente os oito dígitos do CEP, sem separadores.',
|
|
145
|
+
},
|
|
146
|
+
{ name: 'logradouro', type: 'TEXT' },
|
|
147
|
+
{ name: 'complemento', type: 'TEXT' },
|
|
148
|
+
{ name: 'bairro_id', type: 'INTEGER', references: { table: 'bairros', column: 'bairro_id' } },
|
|
149
|
+
{
|
|
150
|
+
name: 'localidade_nome',
|
|
151
|
+
type: 'TEXT',
|
|
152
|
+
comment: 'Original district or village name for a locality-wide CEP.',
|
|
153
|
+
check: 'localidade_nome IS NULL OR (bairro_id IS NULL AND localidade_tipo IN (\'D\', \'P\'))',
|
|
154
|
+
},
|
|
155
|
+
{ name: 'municipio', type: 'TEXT', notNull: true },
|
|
156
|
+
{ name: 'municipio_cod_ibge', type: 'INTEGER', notNull: true },
|
|
157
|
+
{ name: 'uf', type: 'TEXT', notNull: true },
|
|
158
|
+
{ name: 'nome', type: 'TEXT' },
|
|
159
|
+
{ name: 'localidade_situacao', type: 'INTEGER', notNull: true, check: 'localidade_situacao IN (0, 1, 2, 3)' },
|
|
160
|
+
{ name: 'localidade_tipo', type: 'TEXT', notNull: true, check: 'localidade_tipo IN (\'M\', \'D\', \'P\')' },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
/**
|
|
165
|
+
* Creates independently mutable source and output schema definitions.
|
|
166
|
+
* @param tableNames - Optional physical-name overrides keyed by the original table name.
|
|
167
|
+
* @returns New table, column, and source-field objects for this invocation.
|
|
168
|
+
*/
|
|
169
|
+
export function buildSchema(tableNames = {}) {
|
|
170
|
+
return baseTables.map((table) => ({
|
|
171
|
+
...table,
|
|
172
|
+
name: tableNames[table.originalName] ?? table.name,
|
|
173
|
+
columns: table.columns.map((column) => ({
|
|
174
|
+
...column,
|
|
175
|
+
...(column.references
|
|
176
|
+
? { references: { ...column.references, table: tableNames[column.references.table] ?? column.references.table } }
|
|
177
|
+
: {}),
|
|
178
|
+
})),
|
|
179
|
+
sourceFields: table.sourceFields ? { ...table.sourceFields } : undefined,
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Retrieves the generated CEP table from a schema.
|
|
184
|
+
* @param schema - Source and output table definitions.
|
|
185
|
+
* @returns The first definition marked as the unified table, without copying it.
|
|
186
|
+
* @throws {Error} If the schema has no unified table.
|
|
187
|
+
*/
|
|
188
|
+
export function getUnifiedTable(schema) {
|
|
189
|
+
const table = schema.find((candidate) => candidate.unifiedTable);
|
|
190
|
+
if (!table) {
|
|
191
|
+
throw new Error('Unified schema table not found');
|
|
192
|
+
}
|
|
193
|
+
return table;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Lists persisted tables in parent-before-child creation and insertion order.
|
|
197
|
+
* @param schema - Source and output table definitions returned by `buildSchema`.
|
|
198
|
+
* @returns Definitions with output columns; source-only definitions are excluded.
|
|
199
|
+
*/
|
|
200
|
+
export function getStoredTables(schema) {
|
|
201
|
+
return schema.filter((table) => table.columns.length > 0);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Resolves the source filename pattern for a table.
|
|
205
|
+
* @param table - Source or output table definition.
|
|
206
|
+
* @returns The explicit or derived uppercase TXT pattern, or null for a generated table.
|
|
207
|
+
*/
|
|
208
|
+
export function getTableFilesGlob(table) {
|
|
209
|
+
if (table.unifiedTable || table.fileGlob === null) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
return table.fileGlob ?? `${table.originalName.toUpperCase()}.TXT`;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Resolves logical source fields to their positions in a delimited record.
|
|
216
|
+
* @param table - Definition containing a source-field mapping.
|
|
217
|
+
* @param fields - Field names in the desired output order.
|
|
218
|
+
* @returns Zero-based indexes in the same order as `fields`.
|
|
219
|
+
* @throws {Error} If the mapping or any requested field is missing.
|
|
220
|
+
*/
|
|
221
|
+
export function getSourceFieldIndexes(table, fields) {
|
|
222
|
+
if (!table.sourceFields) {
|
|
223
|
+
throw new Error(`Source fields for table '${table.originalName}' not found`);
|
|
224
|
+
}
|
|
225
|
+
return fields.map((field) => {
|
|
226
|
+
const index = table.sourceFields?.[field];
|
|
227
|
+
if (index === undefined) {
|
|
228
|
+
throw new Error(`Source field '${field}' for table '${table.originalName}' not found`);
|
|
229
|
+
}
|
|
230
|
+
return index;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
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C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,gBAAgB,KAAK,CAAC,YAAY,aAAa,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Executable name used in CLI output. */
|
|
2
|
+
export declare const BINARY_NAME = "dne";
|
|
3
|
+
/** Default local SQLite database filename. */
|
|
4
|
+
export declare const SQLITE_FILE_NAME = "dne.db";
|
|
5
|
+
/** Default physical table name for unified CEP rows. */
|
|
6
|
+
export declare const SQLITE_CEP_TABLE_NAME = "dne";
|
|
7
|
+
/** Table storing neighborhoods under their original DNE identifiers. */
|
|
8
|
+
export declare const SQLITE_BAIRROS_TABLE_NAME = "bairros";
|
|
9
|
+
/** Table storing the distinct CEP intervals assigned to each neighborhood. */
|
|
10
|
+
export declare const SQLITE_BAIRRO_FAIXAS_TABLE_NAME = "bairro_faixas";
|
|
11
|
+
/** Table storing string-valued import provenance and quality metadata. */
|
|
12
|
+
export declare const SQLITE_METADATA_TABLE_NAME = "edne_metadata";
|
|
13
|
+
/** SQLite database page size in bytes for generated files. */
|
|
14
|
+
export declare const SQLITE_PAGE_SIZE = 32768;
|
|
15
|
+
/** SQLite cache-size pragma; the negative value specifies kibibytes rather than pages. */
|
|
16
|
+
export declare const SQLITE_CACHE_SIZE = -200000;
|
|
17
|
+
/** Maximum number of CEP rows bound in one batched INSERT statement. */
|
|
18
|
+
export declare const SQLITE_INSERT_BATCH_SIZE = 1000;
|
|
19
|
+
/** Default Correios e-DNE source archive URL. */
|
|
20
|
+
export declare const EDNE_DOWNLOAD_URL = "https://www2.correios.com.br/sistemas/edne/download/eDNE_Basico.zip";
|
|
21
|
+
/** Maximum number of simultaneous byte-range download workers. */
|
|
22
|
+
export declare const HTTP_FETCH_CONCURRENCY = 8;
|
|
23
|
+
/** Target byte-range size in bytes for parallel downloads. */
|
|
24
|
+
export declare const HTTP_FETCH_CHUNK_SIZE: number;
|
|
25
|
+
/** Default timeout per HTTP attempt in milliseconds. */
|
|
26
|
+
export declare const HTTP_FETCH_TIMEOUT_MS = 30000;
|
|
27
|
+
/** Default retry count after the initial HTTP attempt. */
|
|
28
|
+
export declare const HTTP_FETCH_MAX_RETRIES = 2;
|
|
29
|
+
/** Initial exponential-backoff delay in milliseconds. */
|
|
30
|
+
export declare const HTTP_FETCH_RETRY_BASE_DELAY_MS = 100;
|
|
31
|
+
/** Maximum exponential-backoff delay in milliseconds. */
|
|
32
|
+
export declare const HTTP_FETCH_RETRY_MAX_DELAY_MS = 1000;
|
|
33
|
+
/** Maximum delay honored from a Retry-After response header, in milliseconds. */
|
|
34
|
+
export declare const HTTP_FETCH_RETRY_AFTER_MAX_MS = 2000;
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Executable name used in CLI output. */
|
|
2
|
+
export const BINARY_NAME = 'dne';
|
|
3
|
+
/** Default local SQLite database filename. */
|
|
4
|
+
export const SQLITE_FILE_NAME = 'dne.db';
|
|
5
|
+
/** Default physical table name for unified CEP rows. */
|
|
6
|
+
export const SQLITE_CEP_TABLE_NAME = 'dne';
|
|
7
|
+
/** Table storing neighborhoods under their original DNE identifiers. */
|
|
8
|
+
export const SQLITE_BAIRROS_TABLE_NAME = 'bairros';
|
|
9
|
+
/** Table storing the distinct CEP intervals assigned to each neighborhood. */
|
|
10
|
+
export const SQLITE_BAIRRO_FAIXAS_TABLE_NAME = 'bairro_faixas';
|
|
11
|
+
/** Table storing string-valued import provenance and quality metadata. */
|
|
12
|
+
export const SQLITE_METADATA_TABLE_NAME = 'edne_metadata';
|
|
13
|
+
/** SQLite database page size in bytes for generated files. */
|
|
14
|
+
export const SQLITE_PAGE_SIZE = 32768; // 32KiB
|
|
15
|
+
/** SQLite cache-size pragma; the negative value specifies kibibytes rather than pages. */
|
|
16
|
+
export const SQLITE_CACHE_SIZE = -200000; // ~195 MiB; negative means cache size in KiB not pages
|
|
17
|
+
/** Maximum number of CEP rows bound in one batched INSERT statement. */
|
|
18
|
+
export const SQLITE_INSERT_BATCH_SIZE = 1000;
|
|
19
|
+
/** Default Correios e-DNE source archive URL. */
|
|
20
|
+
export const EDNE_DOWNLOAD_URL = 'https://www2.correios.com.br/sistemas/edne/download/eDNE_Basico.zip';
|
|
21
|
+
/** Maximum number of simultaneous byte-range download workers. */
|
|
22
|
+
export const HTTP_FETCH_CONCURRENCY = 8;
|
|
23
|
+
/** Target byte-range size in bytes for parallel downloads. */
|
|
24
|
+
export const HTTP_FETCH_CHUNK_SIZE = 2 * 1024 * 1024; // 2MB
|
|
25
|
+
/** Default timeout per HTTP attempt in milliseconds. */
|
|
26
|
+
export const HTTP_FETCH_TIMEOUT_MS = 30_000;
|
|
27
|
+
/** Default retry count after the initial HTTP attempt. */
|
|
28
|
+
export const HTTP_FETCH_MAX_RETRIES = 2;
|
|
29
|
+
/** Initial exponential-backoff delay in milliseconds. */
|
|
30
|
+
export const HTTP_FETCH_RETRY_BASE_DELAY_MS = 100;
|
|
31
|
+
/** Maximum exponential-backoff delay in milliseconds. */
|
|
32
|
+
export const HTTP_FETCH_RETRY_MAX_DELAY_MS = 1_000;
|
|
33
|
+
/** Maximum delay honored from a Retry-After response header, in milliseconds. */
|
|
34
|
+
export const HTTP_FETCH_RETRY_AFTER_MAX_MS = 2_000;
|
|
35
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,8CAA8C;AAC9C,MAAM,CAAC,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' | 'INVALID_DATA' | 'QUERY_ERROR' | 'READER_CLOSED';
|
|
3
|
+
/** Base class for failures exposed by the SQLite reader and its file helpers. */
|
|
4
|
+
export declare abstract class DneDatabaseError extends Error {
|
|
5
|
+
/** Identifies the failure without requiring callers to parse its message. */
|
|
6
|
+
abstract readonly code: DneDatabaseErrorCode;
|
|
7
|
+
/** Preserves the original SQLite or filesystem failure in `cause`, when provided. */
|
|
8
|
+
protected constructor(message: string, options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
/** A SQLite connection could not be opened, configured, or closed. */
|
|
11
|
+
export declare class DneDatabaseIOError extends DneDatabaseError {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly code = "IO_ERROR";
|
|
14
|
+
/** Creates an access error for the caller's database path. */
|
|
15
|
+
constructor(path: string, options?: ErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
/** The database lacks the schema required for normalized address lookup. */
|
|
18
|
+
export declare class DneDatabaseSchemaError extends DneDatabaseError {
|
|
19
|
+
readonly code = "INVALID_SCHEMA";
|
|
20
|
+
/** Describes the missing schema feature and how to rebuild the database. */
|
|
21
|
+
constructor(message: string, options?: ErrorOptions);
|
|
22
|
+
}
|
|
23
|
+
/** A stored address contains invalid locality indicators. */
|
|
24
|
+
export declare class DneDatabaseDataError extends DneDatabaseError {
|
|
25
|
+
readonly code = "INVALID_DATA";
|
|
26
|
+
/** Describes invalid stored data, preserving a decoding cause when available. */
|
|
27
|
+
constructor(message: string, options?: ErrorOptions);
|
|
28
|
+
}
|
|
29
|
+
/** SQLite could not prepare or execute a read operation. */
|
|
30
|
+
export declare class DneDatabaseQueryError extends DneDatabaseError {
|
|
31
|
+
readonly code = "QUERY_ERROR";
|
|
32
|
+
/** Preserves the diagnostic message and native SQLite failure in `cause`. */
|
|
33
|
+
constructor(message: string, options?: ErrorOptions);
|
|
34
|
+
}
|
|
35
|
+
/** An operation was attempted after the reader closed its connection. */
|
|
36
|
+
export declare class DneDatabaseClosedError extends DneDatabaseError {
|
|
37
|
+
readonly code = "READER_CLOSED";
|
|
38
|
+
/** Creates an error for any read operation attempted after `close()`. */
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Base class for failures exposed by the SQLite reader and its file helpers. */
|
|
2
|
+
export class DneDatabaseError extends Error {
|
|
3
|
+
/** Preserves the original SQLite or filesystem failure in `cause`, when provided. */
|
|
4
|
+
constructor(message, options) {
|
|
5
|
+
super(message, options);
|
|
6
|
+
this.name = new.target.name;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** A SQLite connection could not be opened, configured, or closed. */
|
|
10
|
+
export class DneDatabaseIOError extends DneDatabaseError {
|
|
11
|
+
path;
|
|
12
|
+
code = 'IO_ERROR';
|
|
13
|
+
/** Creates an access error for the caller's database path. */
|
|
14
|
+
constructor(path, options) {
|
|
15
|
+
super(`Unable to access SQLite database: ${path}`, options);
|
|
16
|
+
this.path = path;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** The database lacks the schema required for normalized address lookup. */
|
|
20
|
+
export class DneDatabaseSchemaError extends DneDatabaseError {
|
|
21
|
+
code = 'INVALID_SCHEMA';
|
|
22
|
+
/** Describes the missing schema feature and how to rebuild the database. */
|
|
23
|
+
// biome-ignore lint/complexity/noUselessConstructor: Exposes the protected base constructor as a public API.
|
|
24
|
+
constructor(message, options) {
|
|
25
|
+
super(message, options);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** A stored address contains invalid locality indicators. */
|
|
29
|
+
export class DneDatabaseDataError extends DneDatabaseError {
|
|
30
|
+
code = 'INVALID_DATA';
|
|
31
|
+
/** Describes invalid stored data, preserving a decoding cause when available. */
|
|
32
|
+
// biome-ignore lint/complexity/noUselessConstructor: Exposes the protected base constructor as a public API.
|
|
33
|
+
constructor(message, options) {
|
|
34
|
+
super(message, options);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** SQLite could not prepare or execute a read operation. */
|
|
38
|
+
export class DneDatabaseQueryError extends DneDatabaseError {
|
|
39
|
+
code = 'QUERY_ERROR';
|
|
40
|
+
/** Preserves the diagnostic message and native SQLite failure in `cause`. */
|
|
41
|
+
// biome-ignore lint/complexity/noUselessConstructor: Exposes the protected base constructor as a public API.
|
|
42
|
+
constructor(message, options) {
|
|
43
|
+
super(message, options);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** An operation was attempted after the reader closed its connection. */
|
|
47
|
+
export class DneDatabaseClosedError extends DneDatabaseError {
|
|
48
|
+
code = 'READER_CLOSED';
|
|
49
|
+
/** Creates an error for any read operation attempted after `close()`. */
|
|
50
|
+
constructor() {
|
|
51
|
+
super('SQLite database is closed');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=sqlite-db-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-db-errors.js","sourceRoot":"","sources":["../src/sqlite-db-errors.ts"],"names":[],"mappings":"AAGA,iFAAiF;AACjF,MAAM,OAAgB,gBAAiB,SAAQ,KAAK;IAIlD,qFAAqF;IACrF,YAAsB,OAAe,EAAE,OAAsB;QAC3D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAED,sEAAsE;AACtE,MAAM,OAAO,kBAAmB,SAAQ,gBAAgB;IAIjC;IAHZ,IAAI,GAAG,UAAU,CAAC;IAE3B,8DAA8D;IAC9D,YAAqB,IAAY,EAAE,OAAsB;QACvD,KAAK,CAAC,qCAAqC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QADzC,SAAI,GAAJ,IAAI,CAAQ;IAEjC,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,OAAO,sBAAuB,SAAQ,gBAAgB;IACjD,IAAI,GAAG,gBAAgB,CAAC;IAEjC,4EAA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