@squawk/fix-data
Advanced tools
| /** | ||
| * @packageDocumentation | ||
| * Browser / edge entry point. Asynchronously fetches, decompresses, and | ||
| * parses the bundled `data/fixes.json.gz` snapshot using Web Streams | ||
| * (`DecompressionStream`) and the global `fetch`. Works in every evergreen | ||
| * browser, Cloudflare Workers, Deno Deploy, and Node 22+. | ||
| * | ||
| * Node consumers should use the default {@link "."} entry point instead, | ||
| * which performs the same work synchronously at module load time. | ||
| */ | ||
| import type { FixDataset } from './node.js'; | ||
| /** | ||
| * Options for {@link loadUsBundledFixes}. | ||
| */ | ||
| export interface LoadFixDatasetOptions { | ||
| /** | ||
| * URL of the gzipped dataset file. Defaults to a path resolved relative to | ||
| * this module's `import.meta.url`, which works under any modern ESM bundler | ||
| * when the package is installed normally. Override this to host the file | ||
| * on your own CDN or to provide a custom test fixture. | ||
| */ | ||
| url?: string | URL; | ||
| /** | ||
| * Custom fetch implementation. Defaults to the global `fetch`. Useful for | ||
| * tests, edge runtimes that need a configured fetcher, or environments | ||
| * with a non-standard fetch. | ||
| */ | ||
| fetch?: typeof globalThis.fetch; | ||
| } | ||
| /** | ||
| * Asynchronously loads, decompresses, and parses the bundled fix | ||
| * dataset. Returns the same `FixDataset` shape as the Node entry point | ||
| * exports as `usBundledFixes`. | ||
| * | ||
| * Handles servers that advertise transport-level gzip via | ||
| * `Content-Encoding: gzip` (in which case `fetch()` decodes the body | ||
| * automatically) as well as servers that serve the `.gz` as opaque bytes. | ||
| * | ||
| * ```typescript | ||
| * import { loadUsBundledFixes } from '@squawk/fix-data/browser'; | ||
| * import { createFixResolver } from '@squawk/fixes'; | ||
| * | ||
| * const dataset = await loadUsBundledFixes(); | ||
| * const resolver = createFixResolver({ data: dataset.records }); | ||
| * ``` | ||
| * | ||
| * To host the asset on your own CDN or to override the URL for any other | ||
| * reason, pass an explicit `url`: | ||
| * | ||
| * ```typescript | ||
| * const dataset = await loadUsBundledFixes({ | ||
| * url: 'https://your-cdn.example/fixes.json.gz', | ||
| * }); | ||
| * ``` | ||
| */ | ||
| export declare function loadUsBundledFixes(options?: LoadFixDatasetOptions): Promise<FixDataset>; | ||
| //# sourceMappingURL=browser.d.ts.map |
| {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,WAAW,CAAC;AAalE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2B7F"} |
| /** | ||
| * @packageDocumentation | ||
| * Browser / edge entry point. Asynchronously fetches, decompresses, and | ||
| * parses the bundled `data/fixes.json.gz` snapshot using Web Streams | ||
| * (`DecompressionStream`) and the global `fetch`. Works in every evergreen | ||
| * browser, Cloudflare Workers, Deno Deploy, and Node 22+. | ||
| * | ||
| * Node consumers should use the default {@link "."} entry point instead, | ||
| * which performs the same work synchronously at module load time. | ||
| */ | ||
| /** | ||
| * Asynchronously loads, decompresses, and parses the bundled fix | ||
| * dataset. Returns the same `FixDataset` shape as the Node entry point | ||
| * exports as `usBundledFixes`. | ||
| * | ||
| * Handles servers that advertise transport-level gzip via | ||
| * `Content-Encoding: gzip` (in which case `fetch()` decodes the body | ||
| * automatically) as well as servers that serve the `.gz` as opaque bytes. | ||
| * | ||
| * ```typescript | ||
| * import { loadUsBundledFixes } from '@squawk/fix-data/browser'; | ||
| * import { createFixResolver } from '@squawk/fixes'; | ||
| * | ||
| * const dataset = await loadUsBundledFixes(); | ||
| * const resolver = createFixResolver({ data: dataset.records }); | ||
| * ``` | ||
| * | ||
| * To host the asset on your own CDN or to override the URL for any other | ||
| * reason, pass an explicit `url`: | ||
| * | ||
| * ```typescript | ||
| * const dataset = await loadUsBundledFixes({ | ||
| * url: 'https://your-cdn.example/fixes.json.gz', | ||
| * }); | ||
| * ``` | ||
| */ | ||
| export async function loadUsBundledFixes(options) { | ||
| const url = options?.url ?? new URL('../data/fixes.json.gz', import.meta.url); | ||
| const fetchImpl = options?.fetch ?? globalThis.fetch; | ||
| const res = await fetchImpl(url); | ||
| if (!res.ok) { | ||
| throw new Error(`Failed to fetch fix dataset from ${String(url)}: ${res.status} ${res.statusText}`); | ||
| } | ||
| if (res.body === null) { | ||
| throw new Error(`Response body is null for ${String(url)}`); | ||
| } | ||
| const transportEncoded = res.headers.get('content-encoding')?.toLowerCase().includes('gzip') ?? false; | ||
| const stream = transportEncoded | ||
| ? res.body | ||
| : res.body.pipeThrough(new DecompressionStream('gzip')); | ||
| const text = await new Response(stream).text(); | ||
| const raw = JSON.parse(text); | ||
| return { | ||
| properties: raw.meta, | ||
| records: raw.records, | ||
| }; | ||
| } |
| /** | ||
| * @packageDocumentation | ||
| * Node entry point. Synchronously reads, decompresses, and parses the | ||
| * bundled `data/fixes.json.gz` snapshot at module load time, then exposes | ||
| * the result as a single eager constant. Suitable for server-side Node | ||
| * consumers. | ||
| * | ||
| * Browser and edge consumers should use the {@link "./browser"} entry point | ||
| * instead, which performs the same work asynchronously via `fetch` and | ||
| * `DecompressionStream`. | ||
| */ | ||
| import type { Fix } from '@squawk/types'; | ||
| /** | ||
| * Metadata properties attached to the fix dataset describing | ||
| * the FAA NASR data vintage and build provenance. | ||
| */ | ||
| export interface FixDatasetProperties { | ||
| /** ISO 8601 timestamp of when the dataset was generated. */ | ||
| generatedAt: string; | ||
| /** NASR cycle effective date (e.g. "2026-01-22"). */ | ||
| nasrCycleDate: string; | ||
| /** Total number of fix records in the dataset. */ | ||
| recordCount: number; | ||
| } | ||
| /** | ||
| * A pre-processed array of Fix records with attached metadata | ||
| * about the build provenance and NASR cycle. | ||
| */ | ||
| export interface FixDataset { | ||
| /** Metadata about the dataset build. */ | ||
| properties: FixDatasetProperties; | ||
| /** Fix records. */ | ||
| records: Fix[]; | ||
| } | ||
| /** | ||
| * Pre-processed snapshot of fix/waypoint data derived from the FAA NASR | ||
| * 28-day subscription cycle. | ||
| * | ||
| * Contains fix identification, location, usage category, ARTCC assignment, | ||
| * chart associations, and navaid relationships for every non-CNF named fix | ||
| * and waypoint published by the FAA. Includes selected Canadian, Mexican, | ||
| * Caribbean, and Pacific fixes that participate in US operations; their | ||
| * `state` field is undefined while `country` is populated with a two-letter | ||
| * code and `icaoRegionCode` reflects the foreign region (e.g. `CY` for | ||
| * Canada). | ||
| * | ||
| * Pass the `records` array directly to `createFixResolver()` from | ||
| * `@squawk/fixes` for zero-config lookups: | ||
| * | ||
| * ```typescript | ||
| * import { usBundledFixes } from '@squawk/fix-data'; | ||
| * import { createFixResolver } from '@squawk/fixes'; | ||
| * | ||
| * const resolver = createFixResolver({ data: usBundledFixes.records }); | ||
| * ``` | ||
| */ | ||
| export declare const usBundledFixes: FixDataset; | ||
| //# sourceMappingURL=node.d.ts.map |
| {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMzC;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,UAAU,EAAE,oBAAoB,CAAC;IACjC,mBAAmB;IACnB,OAAO,EAAE,GAAG,EAAE,CAAC;CAChB;AAgBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,EAAE,UAG5B,CAAC"} |
+43
| /** | ||
| * @packageDocumentation | ||
| * Node entry point. Synchronously reads, decompresses, and parses the | ||
| * bundled `data/fixes.json.gz` snapshot at module load time, then exposes | ||
| * the result as a single eager constant. Suitable for server-side Node | ||
| * consumers. | ||
| * | ||
| * Browser and edge consumers should use the {@link "./browser"} entry point | ||
| * instead, which performs the same work asynchronously via `fetch` and | ||
| * `DecompressionStream`. | ||
| */ | ||
| import { readFileSync } from 'node:fs'; | ||
| import { gunzipSync } from 'node:zlib'; | ||
| import { resolve, dirname } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| const dataPath = resolve(dirname(fileURLToPath(import.meta.url)), '../data/fixes.json.gz'); | ||
| const raw = JSON.parse(gunzipSync(readFileSync(dataPath)).toString('utf-8')); | ||
| /** | ||
| * Pre-processed snapshot of fix/waypoint data derived from the FAA NASR | ||
| * 28-day subscription cycle. | ||
| * | ||
| * Contains fix identification, location, usage category, ARTCC assignment, | ||
| * chart associations, and navaid relationships for every non-CNF named fix | ||
| * and waypoint published by the FAA. Includes selected Canadian, Mexican, | ||
| * Caribbean, and Pacific fixes that participate in US operations; their | ||
| * `state` field is undefined while `country` is populated with a two-letter | ||
| * code and `icaoRegionCode` reflects the foreign region (e.g. `CY` for | ||
| * Canada). | ||
| * | ||
| * Pass the `records` array directly to `createFixResolver()` from | ||
| * `@squawk/fixes` for zero-config lookups: | ||
| * | ||
| * ```typescript | ||
| * import { usBundledFixes } from '@squawk/fix-data'; | ||
| * import { createFixResolver } from '@squawk/fixes'; | ||
| * | ||
| * const resolver = createFixResolver({ data: usBundledFixes.records }); | ||
| * ``` | ||
| */ | ||
| export const usBundledFixes = { | ||
| properties: raw.meta, | ||
| records: raw.records, | ||
| }; |
+7
-43
@@ -1,47 +0,11 @@ | ||
| import type { Fix } from '@squawk/types'; | ||
| /** | ||
| * Metadata properties attached to the fix dataset describing | ||
| * the FAA NASR data vintage and build provenance. | ||
| */ | ||
| export interface FixDatasetProperties { | ||
| /** ISO 8601 timestamp of when the dataset was generated. */ | ||
| generatedAt: string; | ||
| /** NASR cycle effective date (e.g. "2026-01-22"). */ | ||
| nasrCycleDate: string; | ||
| /** Total number of fix records in the dataset. */ | ||
| recordCount: number; | ||
| } | ||
| /** | ||
| * A pre-processed array of Fix records with attached metadata | ||
| * about the build provenance and NASR cycle. | ||
| */ | ||
| export interface FixDataset { | ||
| /** Metadata about the dataset build. */ | ||
| properties: FixDatasetProperties; | ||
| /** Fix records. */ | ||
| records: Fix[]; | ||
| } | ||
| /** | ||
| * Pre-processed snapshot of fix/waypoint data derived from the FAA NASR | ||
| * 28-day subscription cycle. | ||
| * @packageDocumentation | ||
| * Pre-processed FAA NASR fix/waypoint snapshot for use with `@squawk/fixes`. | ||
| * | ||
| * Contains fix identification, location, usage category, ARTCC assignment, | ||
| * chart associations, and navaid relationships for every non-CNF named fix | ||
| * and waypoint published by the FAA. Includes selected Canadian, Mexican, | ||
| * Caribbean, and Pacific fixes that participate in US operations; their | ||
| * `state` field is undefined while `country` is populated with a two-letter | ||
| * code and `icaoRegionCode` reflects the foreign region (e.g. `CY` for | ||
| * Canada). | ||
| * | ||
| * Pass the `records` array directly to `createFixResolver()` from | ||
| * `@squawk/fixes` for zero-config lookups: | ||
| * | ||
| * ```typescript | ||
| * import { usBundledFixes } from '@squawk/fix-data'; | ||
| * import { createFixResolver } from '@squawk/fixes'; | ||
| * | ||
| * const resolver = createFixResolver({ data: usBundledFixes.records }); | ||
| * ``` | ||
| * The package root re-exports the Node entry point. Browser and edge | ||
| * consumers should import from `@squawk/fix-data/browser` instead, which | ||
| * exposes an async loader (`loadUsBundledFixes`) that uses `fetch` and | ||
| * `DecompressionStream` rather than `node:fs`. | ||
| */ | ||
| export declare const usBundledFixes: FixDataset; | ||
| export * from './node.js'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAmD,MAAM,eAAe,CAAC;AA+E1F;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,UAAU,EAAE,oBAAoB,CAAC;IACjC,mBAAmB;IACnB,OAAO,EAAE,GAAG,EAAE,CAAC;CAChB;AA8DD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,EAAE,UAO5B,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,WAAW,CAAC"} |
+7
-85
@@ -1,88 +0,10 @@ | ||
| import { readFileSync } from 'node:fs'; | ||
| import { gunzipSync } from 'node:zlib'; | ||
| import { resolve, dirname } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| /** | ||
| * Expands a compact navaid association into the full interface. | ||
| */ | ||
| function expandNavaidAssociation(c) { | ||
| return { | ||
| navaidId: c.nid, | ||
| navaidType: c.ntp, | ||
| bearingDeg: c.brg, | ||
| distanceNm: c.dst, | ||
| }; | ||
| } | ||
| /** | ||
| * Expands a compact fix record into the full Fix interface. | ||
| */ | ||
| function expandFix(c) { | ||
| const fix = { | ||
| identifier: c.id, | ||
| icaoRegionCode: c.icao, | ||
| country: c.ctry, | ||
| lat: c.lat, | ||
| lon: c.lon, | ||
| useCode: c.uc, | ||
| pitch: c.pit === true, | ||
| catch: c.cat === true, | ||
| suaAtcaa: c.sua === true, | ||
| chartTypes: c.cht ?? [], | ||
| navaidAssociations: c.nav ? c.nav.map(expandNavaidAssociation) : [], | ||
| }; | ||
| if (c.st !== undefined) { | ||
| fix.state = c.st; | ||
| } | ||
| if (c.hart !== undefined) { | ||
| fix.highArtccId = c.hart; | ||
| } | ||
| if (c.lart !== undefined) { | ||
| fix.lowArtccId = c.lart; | ||
| } | ||
| if (c.mra !== undefined) { | ||
| fix.minimumReceptionAltitudeFt = c.mra; | ||
| } | ||
| if (c.cmp !== undefined) { | ||
| fix.compulsory = c.cmp; | ||
| } | ||
| if (c.pid !== undefined) { | ||
| fix.previousIdentifier = c.pid; | ||
| } | ||
| if (c.rmk !== undefined) { | ||
| fix.chartingRemark = c.rmk; | ||
| } | ||
| return fix; | ||
| } | ||
| const dataPath = resolve(dirname(fileURLToPath(import.meta.url)), '../data/fixes.json.gz'); | ||
| const raw = JSON.parse(gunzipSync(readFileSync(dataPath)).toString('utf-8')); | ||
| const records = raw.records.map(expandFix); | ||
| /** | ||
| * Pre-processed snapshot of fix/waypoint data derived from the FAA NASR | ||
| * 28-day subscription cycle. | ||
| * @packageDocumentation | ||
| * Pre-processed FAA NASR fix/waypoint snapshot for use with `@squawk/fixes`. | ||
| * | ||
| * Contains fix identification, location, usage category, ARTCC assignment, | ||
| * chart associations, and navaid relationships for every non-CNF named fix | ||
| * and waypoint published by the FAA. Includes selected Canadian, Mexican, | ||
| * Caribbean, and Pacific fixes that participate in US operations; their | ||
| * `state` field is undefined while `country` is populated with a two-letter | ||
| * code and `icaoRegionCode` reflects the foreign region (e.g. `CY` for | ||
| * Canada). | ||
| * | ||
| * Pass the `records` array directly to `createFixResolver()` from | ||
| * `@squawk/fixes` for zero-config lookups: | ||
| * | ||
| * ```typescript | ||
| * import { usBundledFixes } from '@squawk/fix-data'; | ||
| * import { createFixResolver } from '@squawk/fixes'; | ||
| * | ||
| * const resolver = createFixResolver({ data: usBundledFixes.records }); | ||
| * ``` | ||
| * The package root re-exports the Node entry point. Browser and edge | ||
| * consumers should import from `@squawk/fix-data/browser` instead, which | ||
| * exposes an async loader (`loadUsBundledFixes`) that uses `fetch` and | ||
| * `DecompressionStream` rather than `node:fs`. | ||
| */ | ||
| export const usBundledFixes = { | ||
| properties: { | ||
| generatedAt: raw.meta.generatedAt, | ||
| nasrCycleDate: raw.meta.nasrCycleDate, | ||
| recordCount: raw.meta.recordCount, | ||
| }, | ||
| records, | ||
| }; | ||
| export * from './node.js'; |
+13
-7
| { | ||
| "name": "@squawk/fix-data", | ||
| "version": "0.5.2", | ||
| "version": "0.6.0", | ||
| "type": "module", | ||
@@ -18,9 +18,15 @@ "description": "Pre-processed FAA NASR fix/waypoint snapshot for use with @squawk/fixes", | ||
| "typedocMain": "src/index.ts", | ||
| "main": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "main": "./dist/node.js", | ||
| "types": "./dist/node.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js" | ||
| } | ||
| "types": "./dist/node.d.ts", | ||
| "browser": "./dist/browser.js", | ||
| "import": "./dist/node.js" | ||
| }, | ||
| "./browser": { | ||
| "types": "./dist/browser.d.ts", | ||
| "import": "./dist/browser.js" | ||
| }, | ||
| "./data/fixes.json.gz": "./data/fixes.json.gz" | ||
| }, | ||
@@ -36,3 +42,3 @@ "files": [ | ||
| "lint": "tsc --noEmit && eslint src", | ||
| "lint:pack": "publint && attw --pack . --profile esm-only" | ||
| "lint:pack": "publint && attw --pack . --profile esm-only --exclude-entrypoints \"./data/fixes.json.gz\"" | ||
| }, | ||
@@ -39,0 +45,0 @@ "dependencies": { |
+34
-0
@@ -49,2 +49,36 @@ <h1><img src="../../assets/squawk-logo.svg" alt="squawk logo" width="48" height="48" style="vertical-align: middle"> @squawk/fix-data</h1> | ||
| ## Browser / SPA usage | ||
| For browsers, edge runtimes (Cloudflare Workers, Deno Deploy), and any other | ||
| environment without `node:fs`, import the async loader from the `/browser` | ||
| subpath. It fetches and decompresses the bundled `.gz` using Web Streams | ||
| (`DecompressionStream`) and the global `fetch`. | ||
| ```typescript | ||
| import { loadUsBundledFixes } from '@squawk/fix-data/browser'; | ||
| import { createFixResolver } from '@squawk/fixes'; | ||
| const dataset = await loadUsBundledFixes(); | ||
| const resolver = createFixResolver({ data: dataset.records }); | ||
| ``` | ||
| The default URL is resolved relative to this module's `import.meta.url`, | ||
| which works under any modern ESM bundler when the package is installed | ||
| normally. | ||
| To host the asset on your own CDN, to use a bundler-resolved (hashed) | ||
| asset URL, or to override the URL for any other reason, pass an explicit | ||
| `url`: | ||
| ```typescript | ||
| import { loadUsBundledFixes } from '@squawk/fix-data/browser'; | ||
| const dataset = await loadUsBundledFixes({ | ||
| url: 'https://your-cdn.example/fixes.json.gz', | ||
| }); | ||
| ``` | ||
| The loader also accepts a custom `fetch` implementation, which is useful in | ||
| tests or in edge environments that need a configured fetcher. | ||
| ## Data format | ||
@@ -51,0 +85,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Network access
Supply chain riskThis module accesses the network.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
1829379
5.35%12
100%233
73.88%111
44.16%5
Infinity%