@ingissa/navcore-types 1.0.1

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.
@@ -0,0 +1,73 @@
1
+ /**
2
+ * CustomRouteBuilder — Types for building custom routes
3
+ *
4
+ * Build routes with unlimited waypoints, GPX/GeoJSON import/export,
5
+ * and configurable chunking strategies.
6
+ */
7
+ import type { Coord } from './core';
8
+ /** Options when adding a waypoint */
9
+ export interface WaypointOptions {
10
+ /** Whether this is a silent waypoint (no instruction generated) */
11
+ silent?: boolean;
12
+ /** Optional name/label for the waypoint */
13
+ name?: string;
14
+ }
15
+ /** How to connect waypoints when building */
16
+ export interface BuildOptions {
17
+ /** Connection mode between waypoints */
18
+ connectionMode?: 'ROUTED' | 'STRAIGHT' | 'MIXED';
19
+ /** Chunk overlap strategy for multi-segment API calls */
20
+ chunkStrategy?: 'OVERLAP_1' | 'OVERLAP_2';
21
+ /** Maximum waypoints per API call (provider-specific, default 25) */
22
+ maxWaypointsPerChunk?: number;
23
+ }
24
+ /** A waypoint in the custom route */
25
+ export interface CustomWaypoint {
26
+ id: string;
27
+ coord: Coord;
28
+ options?: WaypointOptions;
29
+ }
30
+ /** The built custom route */
31
+ export interface CustomRoute {
32
+ /** Full stitched geometry */
33
+ geometry: Coord[];
34
+ /** Individual waypoints */
35
+ waypoints: CustomWaypoint[];
36
+ /** Total distance in metres */
37
+ distance: number;
38
+ /** Total duration in seconds */
39
+ duration: number;
40
+ }
41
+ /** GeoJSON FeatureCollection (minimal typing for zero-dep constraint) */
42
+ export interface FeatureCollection {
43
+ type: 'FeatureCollection';
44
+ features: Array<{
45
+ type: 'Feature';
46
+ geometry: {
47
+ type: string;
48
+ coordinates: Coord[] | Coord;
49
+ };
50
+ properties: Record<string, unknown>;
51
+ }>;
52
+ }
53
+ /** The builder interface */
54
+ export interface CustomRouteBuilderInterface {
55
+ /** Add a waypoint at the end of the route */
56
+ addWaypoint(coord: Coord, options?: WaypointOptions): string;
57
+ /** Insert a waypoint after an existing one */
58
+ insertWaypoint(coord: Coord, afterId: string): string;
59
+ /** Remove a waypoint by ID */
60
+ removeWaypoint(id: string): void;
61
+ /** Move an existing waypoint to a new coordinate */
62
+ moveWaypoint(id: string, newCoord: Coord): void;
63
+ /** Build the route using the configured directions provider */
64
+ build(options?: BuildOptions): Promise<CustomRoute>;
65
+ /** Import waypoints from a GPX string */
66
+ fromGPX(gpxString: string): void;
67
+ /** Import waypoints from a GeoJSON FeatureCollection */
68
+ fromGeoJSON(geojson: FeatureCollection): void;
69
+ /** Export the current route as GeoJSON */
70
+ toGeoJSON(): FeatureCollection;
71
+ /** Export the current route as GPX */
72
+ toGPX(): string;
73
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * CustomRouteBuilder — Types for building custom routes
3
+ *
4
+ * Build routes with unlimited waypoints, GPX/GeoJSON import/export,
5
+ * and configurable chunking strategies.
6
+ */
7
+ export {};
package/dist/core.d.ts ADDED
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Core types used throughout the NavCore SDK.
3
+ */
4
+ /** [longitude, latitude] — Mapbox/GeoJSON order */
5
+ export type Coord = [number, number];
6
+ /** GPS update from the device */
7
+ export interface NavGpsUpdate {
8
+ coord: Coord;
9
+ accuracy: number | null;
10
+ bearing: number | null;
11
+ speed: number;
12
+ timestamp: number;
13
+ }
14
+ /** Full navigation engine state snapshot */
15
+ export interface NavCoreState {
16
+ snappedCoord: Coord | null;
17
+ ghostCoord: Coord | null;
18
+ rawGpsCoord: Coord | null;
19
+ bearing: number;
20
+ rawGpsBearing: number | null;
21
+ routeIndex: number;
22
+ anchorRouteIndex: number | null;
23
+ distanceToRoute: number;
24
+ corridor: number;
25
+ confidence: number;
26
+ isOffRoute: boolean;
27
+ navFsmState: string;
28
+ progressIndex: number;
29
+ hasArrived: boolean;
30
+ rejoinCandidate: {
31
+ coord: Coord;
32
+ index: number;
33
+ } | null;
34
+ confidenceCone: {
35
+ center: Coord;
36
+ bearing: number;
37
+ angle: number;
38
+ length: number;
39
+ } | null;
40
+ alertState: 'NONE' | 'DEVIATING' | 'RECALCULATING' | 'REJOINING' | 'REJOINED';
41
+ detourMode: 'NONE' | 'FREE' | 'COMMITTED';
42
+ detourCommitProgress: number;
43
+ distanceToNextInstruction: number | null;
44
+ distanceToDestination: number | null;
45
+ nextInstrIdx: number | null;
46
+ nextInstructionIndex: number | null;
47
+ isGpsStale: boolean;
48
+ gpsAgeMs: number;
49
+ currentSpeed: number;
50
+ licenseStatus: NavLicenseInfo;
51
+ stability?: {
52
+ oscillation: number;
53
+ drift: number;
54
+ jump: number;
55
+ };
56
+ }
57
+ /** Navigation lifecycle states */
58
+ export type NavLifecycleState = 'IDLE' | 'OVERVIEW' | 'APPROACHING_ROUTE' | 'ON_ROUTE' | 'DEVIATING' | 'OFF_ROUTE' | 'REROUTING' | 'REJOINING' | 'REJOINED' | 'FAILED';
59
+ /** License validation status */
60
+ export type LicenseStatus = 'VALID' | 'INVALID' | 'EXPIRED' | 'MISSING';
61
+ /** License info returned by the engine */
62
+ export interface NavLicenseInfo {
63
+ plan: 'free' | 'pro' | 'ai';
64
+ limitations: string[];
65
+ }
66
+ /** Engine configuration (all optional with defaults) */
67
+ export interface NavOptions {
68
+ baseCorridorMeters?: number;
69
+ speedFactor?: number;
70
+ maxCorridorMeters?: number;
71
+ gpsAccuracyFactor?: number;
72
+ offRouteConfirmMs?: number;
73
+ rejoinConfirmMs?: number;
74
+ rejoinCooldownMs?: number;
75
+ startupGraceMs?: number;
76
+ betaCorrection?: number;
77
+ gpsAgeCapSeconds?: number;
78
+ gpsStaleMs?: number;
79
+ drMaxAgeMs?: number;
80
+ detourCommitMs?: number;
81
+ bearingSmoothingAlpha?: number;
82
+ detourBearingThreshold?: number;
83
+ lookAheadSeconds?: number;
84
+ minLookAheadMeters?: number;
85
+ maxLookAheadMeters?: number;
86
+ arrivalThresholdMeters?: number;
87
+ isCircuit?: boolean;
88
+ kalmanQ?: number;
89
+ kalmanRBase?: number;
90
+ licenseKey?: string;
91
+ }
92
+ /** Navigation instruction (turn-by-turn step) */
93
+ export interface NavInstruction {
94
+ location: Coord;
95
+ geometryIndex: number;
96
+ text?: string;
97
+ instruction?: string;
98
+ cumulativeOffset?: number;
99
+ }
100
+ /** Deviation event emitted when vehicle goes off-route */
101
+ export interface DeviationEvent {
102
+ anchorIndex: number;
103
+ ghostCoord: Coord;
104
+ rejoinTarget: {
105
+ coordinates: Coord;
106
+ index: number;
107
+ };
108
+ }
109
+ /** Alert event emitted on state changes */
110
+ export interface AlertEvent {
111
+ type: NavCoreState['alertState'];
112
+ message: string | null;
113
+ }
114
+ /** Feature key for license gating */
115
+ export type FeatureKey = 'advanced_snapping' | 'dead_reckoning' | 'route_offset' | 'progress_tracking' | 'advanced_bearing' | 'compound_deviation' | 'nav_ai';
116
+ /** Route snapping result */
117
+ export interface SnapResult {
118
+ idx: number;
119
+ dist: number;
120
+ proj: Coord;
121
+ }
122
+ /** Dead reckoning prediction */
123
+ export interface DRPrediction {
124
+ predictedCoord: Coord;
125
+ isActive: boolean;
126
+ ageMs: number;
127
+ }
128
+ /** Dead reckoning anchor point */
129
+ export interface DRAnchor {
130
+ coord: Coord;
131
+ idx: number;
132
+ ts: number;
133
+ }
134
+ /** Line style for renderer adapters */
135
+ export interface LineStyle {
136
+ color?: string;
137
+ width?: number;
138
+ opacity?: number;
139
+ dashPattern?: number[];
140
+ }
141
+ /** Camera target for renderer adapters */
142
+ export interface CameraTarget {
143
+ coord: Coord;
144
+ bearing: number;
145
+ zoom?: number;
146
+ pitch?: number;
147
+ }
package/dist/core.js ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Core types used throughout the NavCore SDK.
3
+ */
4
+ export {};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * DirectionsProvider — Data source contract
3
+ *
4
+ * Any directions API (Mapbox, OSRM, Valhalla, or a custom server)
5
+ * implements this interface to provide routing data to NavCore.
6
+ *
7
+ * The provider MUST handle waypoint chunking internally if the
8
+ * underlying API has waypoint limits. NavCore imposes no limit.
9
+ */
10
+ import type { Coord } from './core';
11
+ /** Options for route calculation */
12
+ export interface RouteOptions {
13
+ /** Driving profile: 'driving' | 'driving-traffic' | 'cycling' | 'walking' */
14
+ profile?: string;
15
+ /** Request alternatives */
16
+ alternatives?: boolean;
17
+ /** Include step-by-step instructions */
18
+ steps?: boolean;
19
+ /** Geometry format: 'geojson' | 'polyline' | 'polyline6' */
20
+ geometries?: string;
21
+ /** Route overview level: 'full' | 'simplified' | 'false' */
22
+ overview?: string;
23
+ /** Language code for instructions (e.g. 'en', 'fr', 'nl') */
24
+ language?: string;
25
+ }
26
+ /** A single route leg between two waypoints */
27
+ export interface RouteLeg {
28
+ distance: number;
29
+ duration: number;
30
+ steps?: RouteStep[];
31
+ }
32
+ /** A single step within a leg */
33
+ export interface RouteStep {
34
+ distance: number;
35
+ duration: number;
36
+ geometry: Coord[];
37
+ maneuver: {
38
+ type: string;
39
+ modifier?: string;
40
+ location: Coord;
41
+ bearing_before: number;
42
+ bearing_after: number;
43
+ instruction?: string;
44
+ };
45
+ name?: string;
46
+ }
47
+ /** Complete route result from a directions provider */
48
+ export interface RouteResult {
49
+ /** Full route geometry */
50
+ geometry: Coord[];
51
+ /** Total distance in metres */
52
+ distance: number;
53
+ /** Total duration in seconds */
54
+ duration: number;
55
+ /** Individual legs */
56
+ legs: RouteLeg[];
57
+ /** Raw provider response (for debugging) */
58
+ raw?: unknown;
59
+ }
60
+ /** The provider interface */
61
+ export interface DirectionsProvider {
62
+ /**
63
+ * Calculate a route through the given waypoints.
64
+ * Must handle chunking internally if the provider has waypoint limits.
65
+ */
66
+ getRoute(waypoints: Coord[], options?: RouteOptions): Promise<RouteResult>;
67
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * DirectionsProvider — Data source contract
3
+ *
4
+ * Any directions API (Mapbox, OSRM, Valhalla, or a custom server)
5
+ * implements this interface to provide routing data to NavCore.
6
+ *
7
+ * The provider MUST handle waypoint chunking internally if the
8
+ * underlying API has waypoint limits. NavCore imposes no limit.
9
+ */
10
+ export {};
package/dist/exam.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * ExamInstruction — Klaroways-specific extension
3
+ *
4
+ * Extends the base NavInstruction with exam-specific scoring fields,
5
+ * trigger conditions, and mandatory/optional classification.
6
+ */
7
+ import type { NavInstruction } from './core';
8
+ /** Actions the examiner evaluates */
9
+ export type ExamAction = 'MIRROR_CHECK' | 'SIGNAL' | 'OBSERVATION' | 'SPEED_REDUCE' | 'BLIND_SPOT_CHECK' | 'YIELD' | 'FULL_STOP' | 'LANE_POSITION';
10
+ /** Condition that must be met for the instruction to trigger */
11
+ export interface TriggerCondition {
12
+ minSpeedKmh?: number;
13
+ maxSpeedKmh?: number;
14
+ timeOfDay?: {
15
+ from: string;
16
+ to: string;
17
+ };
18
+ }
19
+ /** Exam instruction extending the base navigation instruction */
20
+ export interface ExamInstruction extends NavInstruction {
21
+ /** The action being evaluated */
22
+ examAction: ExamAction;
23
+ /** Points awarded/deducted for this instruction */
24
+ pointValue: number;
25
+ /** Whether this instruction is mandatory (failure = immediate fail) */
26
+ mandatory: boolean;
27
+ /** Optional note for the examiner */
28
+ examNote?: string;
29
+ /** Condition gating when this instruction activates */
30
+ triggerCondition?: TriggerCondition;
31
+ /** Multilingual instruction group ID (from Convex backend) */
32
+ instructionGroupId?: string;
33
+ }
34
+ /** Hazard zone definition for exam routes */
35
+ export interface ExamHazardZone {
36
+ /** Center coordinate of the hazard zone */
37
+ center: [number, number];
38
+ /** Radius in metres */
39
+ radiusM: number;
40
+ /** Type of hazard */
41
+ type: 'SCHOOL_ZONE' | 'HOSPITAL' | 'PEDESTRIAN_CROSSING' | 'TRAM_TRACKS' | 'RESIDENTIAL';
42
+ /** Required actions within this zone */
43
+ requiredActions: ExamAction[];
44
+ /** Maximum allowed speed in km/h */
45
+ maxSpeedKmh?: number;
46
+ }
package/dist/exam.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * ExamInstruction — Klaroways-specific extension
3
+ *
4
+ * Extends the base NavInstruction with exam-specific scoring fields,
5
+ * trigger conditions, and mandatory/optional classification.
6
+ */
7
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @navcore/types — Shared type definitions
3
+ *
4
+ * This package contains all public interfaces and types for the NavCore SDK.
5
+ * It has ZERO runtime dependencies.
6
+ */
7
+ export * from './core';
8
+ export * from './renderer';
9
+ export * from './directions';
10
+ export * from './builder';
11
+ export * from './exam';
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @navcore/types — Shared type definitions
3
+ *
4
+ * This package contains all public interfaces and types for the NavCore SDK.
5
+ * It has ZERO runtime dependencies.
6
+ */
7
+ export * from './core';
8
+ export * from './renderer';
9
+ export * from './directions';
10
+ export * from './builder';
11
+ export * from './exam';
@@ -0,0 +1,43 @@
1
+ /**
2
+ * NavCoreRenderer — Adapter contract
3
+ *
4
+ * Any map renderer (Mapbox, MapLibre, Leaflet, or a headless test harness)
5
+ * implements this interface to receive rendering commands from NavCore.
6
+ *
7
+ * NavCore NEVER depends on a specific renderer — adapters depend on core,
8
+ * core never depends on adapters.
9
+ */
10
+ import type { Coord, LineStyle, CameraTarget } from './core';
11
+ export interface NavCoreRenderer {
12
+ /** Update the vehicle marker position and rotation */
13
+ setVehiclePosition(coord: Coord, bearing: number): void;
14
+ /** Draw or update the main route polyline */
15
+ setRouteGeometry(coords: Coord[], style?: LineStyle): void;
16
+ /** Draw or clear the detour/reroute polyline */
17
+ setDetourGeometry(coords: Coord[] | null, style?: LineStyle): void;
18
+ /** Show or hide the ghost vehicle (on-route projection when off-route) */
19
+ setGhostPosition(coord: Coord | null, bearing: number): void;
20
+ /** Set the camera center, bearing, and optional zoom */
21
+ setCameraTarget(coord: Coord, bearing: number, zoom?: number): void;
22
+ /** Animate the camera to a target over durationMs */
23
+ animateCamera(target: CameraTarget, durationMs: number): void;
24
+ /** Teardown — release all map resources */
25
+ destroy(): void;
26
+ }
27
+ /**
28
+ * HeadlessRenderer — No-op implementation for CI/CD testing.
29
+ * Records all calls for assertion in integration tests.
30
+ */
31
+ export declare class HeadlessRenderer implements NavCoreRenderer {
32
+ readonly calls: Array<{
33
+ method: string;
34
+ args: unknown[];
35
+ }>;
36
+ setVehiclePosition(coord: Coord, bearing: number): void;
37
+ setRouteGeometry(coords: Coord[], style?: LineStyle): void;
38
+ setDetourGeometry(coords: Coord[] | null, style?: LineStyle): void;
39
+ setGhostPosition(coord: Coord | null, bearing: number): void;
40
+ setCameraTarget(coord: Coord, bearing: number, zoom?: number): void;
41
+ animateCamera(target: CameraTarget, durationMs: number): void;
42
+ destroy(): void;
43
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * NavCoreRenderer — Adapter contract
3
+ *
4
+ * Any map renderer (Mapbox, MapLibre, Leaflet, or a headless test harness)
5
+ * implements this interface to receive rendering commands from NavCore.
6
+ *
7
+ * NavCore NEVER depends on a specific renderer — adapters depend on core,
8
+ * core never depends on adapters.
9
+ */
10
+ /**
11
+ * HeadlessRenderer — No-op implementation for CI/CD testing.
12
+ * Records all calls for assertion in integration tests.
13
+ */
14
+ export class HeadlessRenderer {
15
+ constructor() {
16
+ this.calls = [];
17
+ }
18
+ setVehiclePosition(coord, bearing) {
19
+ this.calls.push({ method: 'setVehiclePosition', args: [coord, bearing] });
20
+ }
21
+ setRouteGeometry(coords, style) {
22
+ this.calls.push({ method: 'setRouteGeometry', args: [coords, style] });
23
+ }
24
+ setDetourGeometry(coords, style) {
25
+ this.calls.push({ method: 'setDetourGeometry', args: [coords, style] });
26
+ }
27
+ setGhostPosition(coord, bearing) {
28
+ this.calls.push({ method: 'setGhostPosition', args: [coord, bearing] });
29
+ }
30
+ setCameraTarget(coord, bearing, zoom) {
31
+ this.calls.push({ method: 'setCameraTarget', args: [coord, bearing, zoom] });
32
+ }
33
+ animateCamera(target, durationMs) {
34
+ this.calls.push({ method: 'animateCamera', args: [target, durationMs] });
35
+ }
36
+ destroy() {
37
+ this.calls.push({ method: 'destroy', args: [] });
38
+ }
39
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@ingissa/navcore-types",
3
+ "version": "1.0.1",
4
+ "description": "Shared type definitions for the NavCore SDK ecosystem.",
5
+ "author": "Ingissa <8abnav@gmail.com>",
6
+ "license": "MIT",
7
+ "homepage": "https://navcore-web.vercel.app/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ingissa/ingissa-navcore-examples.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ingissa/ingissa-navcore-examples/issues"
14
+ },
15
+ "main": "dist/index.js",
16
+ "module": "dist/index.mjs",
17
+ "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.mjs",
22
+ "require": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "sideEffects": false,
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "engines": {
33
+ "node": ">=16"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.build.json",
37
+ "prepublishOnly": "npm run build"
38
+ }
39
+ }