@mailwoman/bdc 9.1.0 → 9.3.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/lib/env.ts +30 -0
- package/lib/index.ts +2 -0
- package/{sdk → lib/sdk}/build-bdc.ts +343 -298
- package/{sdk → lib/sdk}/client.ts +24 -38
- package/{sdk → lib/sdk}/common.ts +1 -1
- package/{sdk → lib/sdk}/data-collection.ts +2 -2
- package/{sdk → lib/sdk}/download.ts +19 -15
- package/{sdk → lib/sdk}/filing-dates.ts +3 -3
- package/{sdk → lib/sdk}/filing-landscape.ts +12 -24
- package/lib/sdk/index.ts +14 -0
- package/{sdk → lib/sdk}/list-files.ts +2 -2
- package/{sdk → lib/sdk}/nearest-infrastructure.ts +5 -5
- package/lib/sdk/parsing.ts +157 -0
- package/{sdk → lib/sdk}/plausibility.ts +43 -29
- package/out/env.d.ts +24 -0
- package/out/env.d.ts.map +1 -0
- package/out/env.js +28 -0
- package/out/env.js.map +1 -0
- package/out/index.d.ts +2 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -2
- package/out/index.js.map +1 -1
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js.map +1 -1
- package/out/sdk/build-bdc.d.ts +32 -25
- package/out/sdk/build-bdc.d.ts.map +1 -1
- package/out/sdk/build-bdc.js +255 -219
- package/out/sdk/build-bdc.js.map +1 -1
- package/out/sdk/buildings.d.ts.map +1 -1
- package/out/sdk/buildings.js.map +1 -1
- package/out/sdk/client.d.ts +7 -7
- package/out/sdk/client.d.ts.map +1 -1
- package/out/sdk/client.js +17 -29
- package/out/sdk/client.js.map +1 -1
- package/out/sdk/common.d.ts +1 -1
- package/out/sdk/common.d.ts.map +1 -1
- package/out/sdk/common.js.map +1 -1
- package/out/sdk/data-collection.d.ts +2 -2
- package/out/sdk/data-collection.d.ts.map +1 -1
- package/out/sdk/data-collection.js.map +1 -1
- package/out/sdk/download.d.ts +4 -3
- package/out/sdk/download.d.ts.map +1 -1
- package/out/sdk/download.js +12 -13
- package/out/sdk/download.js.map +1 -1
- package/out/sdk/filing-dates.d.ts +3 -3
- package/out/sdk/filing-dates.d.ts.map +1 -1
- package/out/sdk/filing-dates.js +1 -1
- package/out/sdk/filing-dates.js.map +1 -1
- package/out/sdk/filing-landscape.d.ts +4 -4
- package/out/sdk/filing-landscape.d.ts.map +1 -1
- package/out/sdk/filing-landscape.js +9 -19
- package/out/sdk/filing-landscape.js.map +1 -1
- package/out/sdk/index.d.ts +14 -14
- package/out/sdk/index.d.ts.map +1 -1
- package/out/sdk/index.js +14 -14
- package/out/sdk/index.js.map +1 -1
- package/out/sdk/list-files.d.ts +2 -2
- package/out/sdk/list-files.d.ts.map +1 -1
- package/out/sdk/list-files.js +1 -1
- package/out/sdk/list-files.js.map +1 -1
- package/out/sdk/location.d.ts.map +1 -1
- package/out/sdk/location.js.map +1 -1
- package/out/sdk/nearest-infrastructure.d.ts +4 -4
- package/out/sdk/nearest-infrastructure.d.ts.map +1 -1
- package/out/sdk/nearest-infrastructure.js +2 -2
- package/out/sdk/nearest-infrastructure.js.map +1 -1
- package/out/sdk/parsing.d.ts +66 -28
- package/out/sdk/parsing.d.ts.map +1 -1
- package/out/sdk/parsing.js +103 -70
- package/out/sdk/parsing.js.map +1 -1
- package/out/sdk/plausibility.d.ts +32 -14
- package/out/sdk/plausibility.d.ts.map +1 -1
- package/out/sdk/plausibility.js +15 -20
- package/out/sdk/plausibility.js.map +1 -1
- package/out/sdk/technologies.d.ts.map +1 -1
- package/out/sdk/technologies.js.map +1 -1
- package/package.json +164 -22
- package/index.ts +0 -2
- package/sdk/index.ts +0 -14
- package/sdk/parsing.ts +0 -124
- /package/{schema.ts → lib/schema.ts} +0 -0
- /package/{sdk → lib/sdk}/buildings.ts +0 -0
- /package/{sdk → lib/sdk}/location.ts +0 -0
- /package/{sdk → lib/sdk}/technologies.ts +0 -0
package/sdk/parsing.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software.
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file FCC BDC availability CSV byte-level parser.
|
|
6
|
-
*
|
|
7
|
-
* Re-homed from Nexus's `sync/fcc/bdc/parsing.ts` (relicense-by-copy, no provenance headers): the same
|
|
8
|
-
* byte-scanning generator over the FCC's 12-column availability CSV — see the Nexus `RawBSLAvailabilityRow`
|
|
9
|
-
* tuple (`sync/fcc/bdc/block-aggregator.ts`) for the column order this scan assumes: frn, provider_id,
|
|
10
|
-
* brand_name, location_id, technology, max_advertised_download_speed, max_advertised_upload_speed,
|
|
11
|
-
* low_latency, business_residential_code, state_usps, block_geoid, h3_res8_id. Changed only where the
|
|
12
|
-
* pre-registered 2a decisions require: `geoid` (column 10, `block_geoid`) decodes to an ASCII string
|
|
13
|
-
* instead of staying a raw `Uint8Array` slice (decision 3), and `location_id` (column 3) stays a string
|
|
14
|
-
* instead of `parseInt`ing it, preserving leading zeros (decision 1). `business_residential_code` is
|
|
15
|
-
* likewise decoded to its ASCII string here — the Nexus original kept only the field's first raw byte as
|
|
16
|
-
* a bare `number`, which this port's `BDCAvailabilityRow` shape doesn't call for.
|
|
17
|
-
*
|
|
18
|
-
* Columns 0-2 (frn, provider_id, brand_name) and 9, 11 (state_usps, h3_res8_id) are scanned over but
|
|
19
|
-
* never sliced into the output record: `provider_id` comes from the `providerID` parameter instead (the
|
|
20
|
-
* FCC partitions availability files per provider, so the caller already knows it), and FRN/brand/state/H3
|
|
21
|
-
* join concerns are out of scope for 2a (decision 8 — provider identity is a 2c registry-join seam).
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import type { ProviderID } from "./common.ts"
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Byte values this scanner switches on.
|
|
28
|
-
*
|
|
29
|
-
* Local to this file — no generic newline-delimited-file utility exists elsewhere in the repo to import. Nexus's
|
|
30
|
-
* equivalent (`LineDelimitedCharacter`) lived in `@isp.nexus/sdk/files`, a workspace this port doesn't carry over, and
|
|
31
|
-
* repo convention forbids TS `enum` anyway (`erasableSyntaxOnly`).
|
|
32
|
-
*/
|
|
33
|
-
const CSVByte = {
|
|
34
|
-
Newline: 10,
|
|
35
|
-
Comma: 44,
|
|
36
|
-
DoubleQuote: 34,
|
|
37
|
-
One: 49,
|
|
38
|
-
} as const
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* A single parsed row of FCC BDC availability data.
|
|
42
|
-
*
|
|
43
|
-
* @see {@linkcode takeAvailabilityLine}
|
|
44
|
-
*/
|
|
45
|
-
export interface BDCAvailabilityRow {
|
|
46
|
-
provider_id: number
|
|
47
|
-
/**
|
|
48
|
-
* Kept as a string — the FCC's `location_id` values are zero-padded 10-digit strings; `parseInt`ing would lose
|
|
49
|
-
* leading zeros (2a decision 1).
|
|
50
|
-
*/
|
|
51
|
-
location_id: string
|
|
52
|
-
technology_code: number
|
|
53
|
-
max_advertised_download_speed: number
|
|
54
|
-
max_advertised_upload_speed: number
|
|
55
|
-
low_latency: 0 | 1
|
|
56
|
-
business_residential_code: string
|
|
57
|
-
/**
|
|
58
|
-
* Decoded to an ASCII string at the parse boundary (2a decision 3) — joins `TIGERBlockTable.GEOID` (note: uppercase
|
|
59
|
-
* column on that side).
|
|
60
|
-
*/
|
|
61
|
-
geoid: string
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Given a buffer containing FCC BDC availability CSV data, yield each data row (the header row is skipped) as a
|
|
66
|
-
* {@linkcode BDCAvailabilityRow}.
|
|
67
|
-
*
|
|
68
|
-
* A byte-level scan, not a general CSV parser: it tracks comma/newline byte positions directly and only toggles
|
|
69
|
-
* quote-awareness via a running double-quote count (an odd count means the scanner is currently inside a quoted field,
|
|
70
|
-
* so a comma there isn't a column delimiter) — matching the Nexus original's approach for this specific, known-shaped
|
|
71
|
-
* 12-column file rather than reaching for a general CSV library.
|
|
72
|
-
*/
|
|
73
|
-
export function* takeAvailabilityLine(csvBuffer: Buffer, providerID: ProviderID): Iterable<BDCAvailabilityRow> {
|
|
74
|
-
// Skip the header row.
|
|
75
|
-
let byteIndex = csvBuffer.indexOf(CSVByte.Newline) + 1
|
|
76
|
-
const contentDelimiters = new Uint32Array(12) // 12 columns
|
|
77
|
-
contentDelimiters[0] = byteIndex
|
|
78
|
-
let delimiterIndex = 1
|
|
79
|
-
let doubleQuoteCount = 0
|
|
80
|
-
|
|
81
|
-
while (byteIndex < csvBuffer.length) {
|
|
82
|
-
const byte = csvBuffer[byteIndex]
|
|
83
|
-
|
|
84
|
-
if (byte === CSVByte.DoubleQuote) {
|
|
85
|
-
doubleQuoteCount++
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (byte === CSVByte.Comma && doubleQuoteCount % 2 === 0) {
|
|
89
|
-
contentDelimiters[delimiterIndex] = byteIndex
|
|
90
|
-
|
|
91
|
-
delimiterIndex++
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (byte === CSVByte.Newline) {
|
|
95
|
-
contentDelimiters[delimiterIndex] = CSVByte.Newline
|
|
96
|
-
const slices: Buffer[] = []
|
|
97
|
-
|
|
98
|
-
// Skip columns 0-2 (frn, provider_id, brand_name) — see the file header for why.
|
|
99
|
-
for (let i = 3; i < contentDelimiters.length; i++) {
|
|
100
|
-
const start = contentDelimiters[i]! + 1
|
|
101
|
-
const end = contentDelimiters[i + 1]
|
|
102
|
-
|
|
103
|
-
slices.push(csvBuffer.subarray(start, end))
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const record: BDCAvailabilityRow = {
|
|
107
|
-
provider_id: providerID,
|
|
108
|
-
location_id: slices[0]!.toString("ascii"),
|
|
109
|
-
technology_code: Number.parseInt(slices[1]!.toString(), 10),
|
|
110
|
-
max_advertised_download_speed: Number.parseInt(slices[2]!.toString(), 10),
|
|
111
|
-
max_advertised_upload_speed: Number.parseInt(slices[3]!.toString(), 10),
|
|
112
|
-
low_latency: slices[4]![0] === CSVByte.One ? 1 : 0,
|
|
113
|
-
business_residential_code: slices[5]!.toString("ascii"),
|
|
114
|
-
geoid: slices[7]!.toString("ascii"),
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
yield record
|
|
118
|
-
delimiterIndex = 1
|
|
119
|
-
doubleQuoteCount = 0
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
byteIndex++
|
|
123
|
-
}
|
|
124
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|