Sign In

@squawk/procedure-data

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@squawk/procedure-data - npm Package Compare versions

Comparing version
0.5.2
to
0.6.0
+57
dist/browser.d.ts
/**
* @packageDocumentation
* Browser / edge entry point. Asynchronously fetches, decompresses, and
* parses the bundled `data/procedures.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 { ProcedureDataset } from './node.js';
/**
* Options for {@link loadUsBundledProcedures}.
*/
export interface LoadProcedureDatasetOptions {
/**
* 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 procedure
* dataset. Returns the same `ProcedureDataset` shape as the Node entry
* point exports as `usBundledProcedures`.
*
* 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 { loadUsBundledProcedures } from '@squawk/procedure-data/browser';
* import { createProcedureResolver } from '@squawk/procedures';
*
* const dataset = await loadUsBundledProcedures();
* const resolver = createProcedureResolver({ 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 loadUsBundledProcedures({
* url: 'https://your-cdn.example/procedures.json.gz',
* });
* ```
*/
export declare function loadUsBundledProcedures(options?: LoadProcedureDatasetOptions): Promise<ProcedureDataset>;
//# sourceMappingURL=browser.d.ts.map
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAA8B,MAAM,WAAW,CAAC;AAa9E;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;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,uBAAuB,CAC3C,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CA2B3B"}
/**
* @packageDocumentation
* Browser / edge entry point. Asynchronously fetches, decompresses, and
* parses the bundled `data/procedures.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 procedure
* dataset. Returns the same `ProcedureDataset` shape as the Node entry
* point exports as `usBundledProcedures`.
*
* 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 { loadUsBundledProcedures } from '@squawk/procedure-data/browser';
* import { createProcedureResolver } from '@squawk/procedures';
*
* const dataset = await loadUsBundledProcedures();
* const resolver = createProcedureResolver({ 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 loadUsBundledProcedures({
* url: 'https://your-cdn.example/procedures.json.gz',
* });
* ```
*/
export async function loadUsBundledProcedures(options) {
const url = options?.url ?? new URL('../data/procedures.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 procedure 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/procedures.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 { Procedure } from '@squawk/types';
/**
* Metadata properties attached to the procedure dataset describing the
* FAA CIFP data vintage and build provenance.
*/
export interface ProcedureDatasetProperties {
/** ISO 8601 timestamp of when the dataset was generated. */
generatedAt: string;
/** CIFP cycle effective date in `YYYY-MM-DD` (e.g. "2026-03-25"). */
cifpCycleDate: string;
/** Total number of procedure records in the dataset. */
recordCount: number;
/** Number of Standard Instrument Departure (SID) procedures. */
sidCount: number;
/** Number of Standard Terminal Arrival Route (STAR) procedures. */
starCount: number;
/** Number of Instrument Approach Procedure (IAP) procedures. */
iapCount: number;
/** Total leg count across all common routes, transitions, and missed approaches. */
legCount: number;
}
/**
* A pre-processed array of {@link Procedure} records together with
* metadata about the build provenance and CIFP cycle.
*/
export interface ProcedureDataset {
/** Metadata about the dataset build. */
properties: ProcedureDatasetProperties;
/** Procedure records. */
records: Procedure[];
}
/**
* Pre-processed snapshot of US instrument procedure data derived from
* the FAA CIFP (Coded Instrument Flight Procedures) 28-day cycle.
*
* Contains Standard Instrument Departures (SIDs), Standard Terminal
* Arrival Routes (STARs), and Instrument Approach Procedures (IAPs) in
* the unified ARINC 424 leg model, including path terminators,
* altitude and speed constraints, recommended navaids, RNP values, and
* FAF / MAP / IAF / FACF flags.
*
* Pass the `records` array directly to `createProcedureResolver()` from
* `@squawk/procedures` for zero-config lookups:
*
* ```typescript
* import { usBundledProcedures } from '@squawk/procedure-data';
* import { createProcedureResolver } from '@squawk/procedures';
*
* const resolver = createProcedureResolver({ data: usBundledProcedures.records });
* ```
*/
export declare const usBundledProcedures: ProcedureDataset;
//# sourceMappingURL=node.d.ts.map
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM/C;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,UAAU,EAAE,0BAA0B,CAAC;IACvC,yBAAyB;IACzB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAgBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBAGjC,CAAC"}
/**
* @packageDocumentation
* Node entry point. Synchronously reads, decompresses, and parses the
* bundled `data/procedures.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/procedures.json.gz');
const raw = JSON.parse(gunzipSync(readFileSync(dataPath)).toString('utf-8'));
/**
* Pre-processed snapshot of US instrument procedure data derived from
* the FAA CIFP (Coded Instrument Flight Procedures) 28-day cycle.
*
* Contains Standard Instrument Departures (SIDs), Standard Terminal
* Arrival Routes (STARs), and Instrument Approach Procedures (IAPs) in
* the unified ARINC 424 leg model, including path terminators,
* altitude and speed constraints, recommended navaids, RNP values, and
* FAF / MAP / IAF / FACF flags.
*
* Pass the `records` array directly to `createProcedureResolver()` from
* `@squawk/procedures` for zero-config lookups:
*
* ```typescript
* import { usBundledProcedures } from '@squawk/procedure-data';
* import { createProcedureResolver } from '@squawk/procedures';
*
* const resolver = createProcedureResolver({ data: usBundledProcedures.records });
* ```
*/
export const usBundledProcedures = {
properties: raw.meta,
records: raw.records,
};
+8
-49

@@ -1,53 +0,12 @@

import type { Procedure } from '@squawk/types';
/**
* Metadata properties attached to the procedure dataset describing the
* FAA CIFP data vintage and build provenance.
*/
export interface ProcedureDatasetProperties {
/** ISO 8601 timestamp of when the dataset was generated. */
generatedAt: string;
/** CIFP cycle effective date in `YYYY-MM-DD` (e.g. "2026-03-25"). */
cifpCycleDate: string;
/** Total number of procedure records in the dataset. */
recordCount: number;
/** Number of Standard Instrument Departure (SID) procedures. */
sidCount: number;
/** Number of Standard Terminal Arrival Route (STAR) procedures. */
starCount: number;
/** Number of Instrument Approach Procedure (IAP) procedures. */
iapCount: number;
/** Total leg count across all common routes, transitions, and missed approaches. */
legCount: number;
}
/**
* A pre-processed array of {@link Procedure} records together with
* metadata about the build provenance and CIFP cycle.
*/
export interface ProcedureDataset {
/** Metadata about the dataset build. */
properties: ProcedureDatasetProperties;
/** Procedure records. */
records: Procedure[];
}
/**
* Pre-processed snapshot of US instrument procedure data derived from
* the FAA CIFP (Coded Instrument Flight Procedures) 28-day cycle.
* @packageDocumentation
* Pre-processed FAA CIFP procedure snapshot (SIDs, STARs, IAPs) for use
* with `@squawk/procedures`.
*
* Contains Standard Instrument Departures (SIDs), Standard Terminal
* Arrival Routes (STARs), and Instrument Approach Procedures (IAPs) in
* the unified ARINC 424 leg model, including path terminators,
* altitude and speed constraints, recommended navaids, RNP values, and
* FAF / MAP / IAF / FACF flags.
*
* Pass the `records` array directly to `createProcedureResolver()` from
* `@squawk/procedures` for zero-config lookups:
*
* ```typescript
* import { usBundledProcedures } from '@squawk/procedure-data';
* import { createProcedureResolver } from '@squawk/procedures';
*
* const resolver = createProcedureResolver({ data: usBundledProcedures.records });
* ```
* The package root re-exports the Node entry point. Browser and edge
* consumers should import from `@squawk/procedure-data/browser` instead,
* which exposes an async loader (`loadUsBundledProcedures`) that uses
* `fetch` and `DecompressionStream` rather than `node:fs`.
*/
export declare const usBundledProcedures: ProcedureDataset;
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":"AAIA,OAAO,KAAK,EAIV,SAAS,EASV,MAAM,eAAe,CAAC;AAmKvB;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,UAAU,EAAE,0BAA0B,CAAC;IACvC,yBAAyB;IACzB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AA0KD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBAWjC,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,WAAW,CAAC"}

@@ -1,195 +0,11 @@

import { readFileSync } from 'node:fs';
import { gunzipSync } from 'node:zlib';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
/**
* Expands a compact altitude constraint into the full interface.
*/
function expandAltitudeConstraint(c) {
const ac = {
descriptor: c.d,
primaryFt: c.p,
};
if (c.s !== undefined) {
ac.secondaryFt = c.s;
}
return ac;
}
/**
* Expands a compact speed constraint into the full interface.
*/
function expandSpeedConstraint(c) {
return { descriptor: c.d, speedKt: c.s };
}
/**
* Expands a compact leg into the full {@link ProcedureLeg} interface.
*/
function expandLeg(c) {
const leg = { pathTerminator: c.pt };
if (c.fi !== undefined) {
leg.fixIdentifier = c.fi;
}
if (c.cat !== undefined) {
leg.category = c.cat;
}
if (c.lat !== undefined) {
leg.lat = c.lat;
}
if (c.lon !== undefined) {
leg.lon = c.lon;
}
if (c.ir !== undefined) {
leg.icaoRegionCode = c.ir;
}
if (c.ac !== undefined) {
leg.altitudeConstraint = expandAltitudeConstraint(c.ac);
}
if (c.sc !== undefined) {
leg.speedConstraint = expandSpeedConstraint(c.sc);
}
if (c.crs !== undefined) {
leg.courseDeg = c.crs;
}
if (c.ct === 1) {
leg.courseIsTrue = true;
}
if (c.dist !== undefined) {
leg.distanceNm = c.dist;
}
if (c.hold !== undefined) {
leg.holdTimeMin = c.hold;
}
if (c.rn !== undefined) {
leg.recommendedNavaid = c.rn;
}
if (c.rnIr !== undefined) {
leg.recommendedNavaidIcaoRegionCode = c.rnIr;
}
if (c.th !== undefined) {
leg.thetaDeg = c.th;
}
if (c.rh !== undefined) {
leg.rhoNm = c.rh;
}
if (c.rnp !== undefined) {
leg.rnpNm = c.rnp;
}
if (c.td !== undefined) {
leg.turnDirection = c.td;
}
if (c.ar !== undefined) {
leg.arcRadiusNm = c.ar;
}
if (c.cf !== undefined) {
leg.centerFix = c.cf;
}
if (c.cfIr !== undefined) {
leg.centerFixIcaoRegionCode = c.cfIr;
}
if (c.iaf === 1) {
leg.isInitialApproachFix = true;
}
if (c.ifx === 1) {
leg.isIntermediateFix = true;
}
if (c.faf === 1) {
leg.isFinalApproachFix = true;
}
if (c.facf === 1) {
leg.isFinalApproachCourseFix = true;
}
if (c.map === 1) {
leg.isMissedApproachPoint = true;
}
if (c.fo === 1) {
leg.isFlyover = true;
}
return leg;
}
/**
* Expands a compact transition into the full interface.
*/
function expandTransition(c) {
return {
name: c.nm,
legs: c.lg.map(expandLeg),
};
}
/**
* Expands a compact common route into the full interface.
*/
function expandCommonRoute(c) {
const route = {
legs: c.lg.map(expandLeg),
airports: c.apt,
};
if (c.rw !== undefined) {
route.runway = c.rw;
}
return route;
}
/**
* Expands a compact missed approach into the full interface.
*/
function expandMissedApproach(c) {
return { legs: c.lg.map(expandLeg) };
}
/**
* Expands a compact procedure record into the full {@link Procedure}
* interface, populating IAP-specific fields when present.
*/
function expandProcedure(c) {
const p = {
name: c.nm,
identifier: c.id,
type: c.tp,
airports: c.apt,
commonRoutes: c.cr.map(expandCommonRoute),
transitions: c.tr.map(expandTransition),
};
if (c.at !== undefined) {
p.approachType = c.at;
}
if (c.rw !== undefined) {
p.runway = c.rw;
}
if (c.ma !== undefined) {
p.missedApproach = expandMissedApproach(c.ma);
}
return p;
}
const dataPath = resolve(dirname(fileURLToPath(import.meta.url)), '../data/procedures.json.gz');
const raw = JSON.parse(gunzipSync(readFileSync(dataPath)).toString('utf-8'));
const records = raw.records.map(expandProcedure);
/**
* Pre-processed snapshot of US instrument procedure data derived from
* the FAA CIFP (Coded Instrument Flight Procedures) 28-day cycle.
* @packageDocumentation
* Pre-processed FAA CIFP procedure snapshot (SIDs, STARs, IAPs) for use
* with `@squawk/procedures`.
*
* Contains Standard Instrument Departures (SIDs), Standard Terminal
* Arrival Routes (STARs), and Instrument Approach Procedures (IAPs) in
* the unified ARINC 424 leg model, including path terminators,
* altitude and speed constraints, recommended navaids, RNP values, and
* FAF / MAP / IAF / FACF flags.
*
* Pass the `records` array directly to `createProcedureResolver()` from
* `@squawk/procedures` for zero-config lookups:
*
* ```typescript
* import { usBundledProcedures } from '@squawk/procedure-data';
* import { createProcedureResolver } from '@squawk/procedures';
*
* const resolver = createProcedureResolver({ data: usBundledProcedures.records });
* ```
* The package root re-exports the Node entry point. Browser and edge
* consumers should import from `@squawk/procedure-data/browser` instead,
* which exposes an async loader (`loadUsBundledProcedures`) that uses
* `fetch` and `DecompressionStream` rather than `node:fs`.
*/
export const usBundledProcedures = {
properties: {
generatedAt: raw.meta.generatedAt,
cifpCycleDate: raw.meta.cifpCycleDate,
recordCount: raw.meta.recordCount,
sidCount: raw.meta.sidCount,
starCount: raw.meta.starCount,
iapCount: raw.meta.iapCount,
legCount: raw.meta.legCount,
},
records,
};
export * from './node.js';
{
"name": "@squawk/procedure-data",
"version": "0.5.2",
"version": "0.6.0",
"type": "module",

@@ -18,9 +18,15 @@ "description": "Pre-processed FAA CIFP procedure snapshot (SIDs, STARs, IAPs) for use with @squawk/procedures",

"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/procedures.json.gz": "./data/procedures.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/procedures.json.gz\""
},

@@ -39,0 +45,0 @@ "dependencies": {

@@ -55,2 +55,36 @@ <h1><img src="../../assets/squawk-logo.svg" alt="squawk logo" width="48" height="48" style="vertical-align: middle">&nbsp; @squawk/procedure-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 { loadUsBundledProcedures } from '@squawk/procedure-data/browser';
import { createProcedureResolver } from '@squawk/procedures';
const dataset = await loadUsBundledProcedures();
const resolver = createProcedureResolver({ 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 { loadUsBundledProcedures } from '@squawk/procedure-data/browser';
const dataset = await loadUsBundledProcedures({
url: 'https://your-cdn.example/procedures.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

@@ -57,0 +91,0 @@

Sorry, the diff of this file is not supported yet