@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.
Files changed (84) hide show
  1. package/lib/env.ts +30 -0
  2. package/lib/index.ts +2 -0
  3. package/{sdk → lib/sdk}/build-bdc.ts +343 -298
  4. package/{sdk → lib/sdk}/client.ts +24 -38
  5. package/{sdk → lib/sdk}/common.ts +1 -1
  6. package/{sdk → lib/sdk}/data-collection.ts +2 -2
  7. package/{sdk → lib/sdk}/download.ts +19 -15
  8. package/{sdk → lib/sdk}/filing-dates.ts +3 -3
  9. package/{sdk → lib/sdk}/filing-landscape.ts +12 -24
  10. package/lib/sdk/index.ts +14 -0
  11. package/{sdk → lib/sdk}/list-files.ts +2 -2
  12. package/{sdk → lib/sdk}/nearest-infrastructure.ts +5 -5
  13. package/lib/sdk/parsing.ts +157 -0
  14. package/{sdk → lib/sdk}/plausibility.ts +43 -29
  15. package/out/env.d.ts +24 -0
  16. package/out/env.d.ts.map +1 -0
  17. package/out/env.js +28 -0
  18. package/out/env.js.map +1 -0
  19. package/out/index.d.ts +2 -2
  20. package/out/index.d.ts.map +1 -1
  21. package/out/index.js +2 -2
  22. package/out/index.js.map +1 -1
  23. package/out/schema.d.ts.map +1 -1
  24. package/out/schema.js.map +1 -1
  25. package/out/sdk/build-bdc.d.ts +32 -25
  26. package/out/sdk/build-bdc.d.ts.map +1 -1
  27. package/out/sdk/build-bdc.js +255 -219
  28. package/out/sdk/build-bdc.js.map +1 -1
  29. package/out/sdk/buildings.d.ts.map +1 -1
  30. package/out/sdk/buildings.js.map +1 -1
  31. package/out/sdk/client.d.ts +7 -7
  32. package/out/sdk/client.d.ts.map +1 -1
  33. package/out/sdk/client.js +17 -29
  34. package/out/sdk/client.js.map +1 -1
  35. package/out/sdk/common.d.ts +1 -1
  36. package/out/sdk/common.d.ts.map +1 -1
  37. package/out/sdk/common.js.map +1 -1
  38. package/out/sdk/data-collection.d.ts +2 -2
  39. package/out/sdk/data-collection.d.ts.map +1 -1
  40. package/out/sdk/data-collection.js.map +1 -1
  41. package/out/sdk/download.d.ts +4 -3
  42. package/out/sdk/download.d.ts.map +1 -1
  43. package/out/sdk/download.js +12 -13
  44. package/out/sdk/download.js.map +1 -1
  45. package/out/sdk/filing-dates.d.ts +3 -3
  46. package/out/sdk/filing-dates.d.ts.map +1 -1
  47. package/out/sdk/filing-dates.js +1 -1
  48. package/out/sdk/filing-dates.js.map +1 -1
  49. package/out/sdk/filing-landscape.d.ts +4 -4
  50. package/out/sdk/filing-landscape.d.ts.map +1 -1
  51. package/out/sdk/filing-landscape.js +9 -19
  52. package/out/sdk/filing-landscape.js.map +1 -1
  53. package/out/sdk/index.d.ts +14 -14
  54. package/out/sdk/index.d.ts.map +1 -1
  55. package/out/sdk/index.js +14 -14
  56. package/out/sdk/index.js.map +1 -1
  57. package/out/sdk/list-files.d.ts +2 -2
  58. package/out/sdk/list-files.d.ts.map +1 -1
  59. package/out/sdk/list-files.js +1 -1
  60. package/out/sdk/list-files.js.map +1 -1
  61. package/out/sdk/location.d.ts.map +1 -1
  62. package/out/sdk/location.js.map +1 -1
  63. package/out/sdk/nearest-infrastructure.d.ts +4 -4
  64. package/out/sdk/nearest-infrastructure.d.ts.map +1 -1
  65. package/out/sdk/nearest-infrastructure.js +2 -2
  66. package/out/sdk/nearest-infrastructure.js.map +1 -1
  67. package/out/sdk/parsing.d.ts +66 -28
  68. package/out/sdk/parsing.d.ts.map +1 -1
  69. package/out/sdk/parsing.js +103 -70
  70. package/out/sdk/parsing.js.map +1 -1
  71. package/out/sdk/plausibility.d.ts +32 -14
  72. package/out/sdk/plausibility.d.ts.map +1 -1
  73. package/out/sdk/plausibility.js +15 -20
  74. package/out/sdk/plausibility.js.map +1 -1
  75. package/out/sdk/technologies.d.ts.map +1 -1
  76. package/out/sdk/technologies.js.map +1 -1
  77. package/package.json +164 -22
  78. package/index.ts +0 -2
  79. package/sdk/index.ts +0 -14
  80. package/sdk/parsing.ts +0 -124
  81. /package/{schema.ts → lib/schema.ts} +0 -0
  82. /package/{sdk → lib/sdk}/buildings.ts +0 -0
  83. /package/{sdk → lib/sdk}/location.ts +0 -0
  84. /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