@ryancardin/noaa-tides-currents-mcp-server 1.0.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/.claude/settings.local.json +29 -0
- package/CLAUDE.md +71 -0
- package/Dockerfile +14 -0
- package/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -0
- package/dist/interfaces/config.d.ts +6 -0
- package/dist/interfaces/config.js +1 -0
- package/dist/interfaces/moon.d.ts +65 -0
- package/dist/interfaces/moon.js +35 -0
- package/dist/interfaces/noaa.d.ts +334 -0
- package/dist/interfaces/noaa.js +98 -0
- package/dist/interfaces/parameters.d.ts +18 -0
- package/dist/interfaces/parameters.js +5 -0
- package/dist/interfaces/sun.d.ts +103 -0
- package/dist/interfaces/sun.js +45 -0
- package/dist/mcp-server.d.ts +12 -0
- package/dist/mcp-server.js +103 -0
- package/dist/moon-phase-service.d.ts +122 -0
- package/dist/moon-phase-service.js +187 -0
- package/dist/noaa-service.d.ts +60 -0
- package/dist/noaa-service.js +159 -0
- package/dist/schemas/common.d.ts +14 -0
- package/dist/schemas/common.js +18 -0
- package/dist/schemas/dpapi.d.ts +198 -0
- package/dist/schemas/dpapi.js +89 -0
- package/dist/server/config.d.ts +9 -0
- package/dist/server/config.js +40 -0
- package/dist/server/mcp-server.d.ts +12 -0
- package/dist/server/mcp-server.js +103 -0
- package/dist/services/dpapi-service.d.ts +72 -0
- package/dist/services/dpapi-service.js +164 -0
- package/dist/services/moon-phase-service.d.ts +34 -0
- package/dist/services/moon-phase-service.js +147 -0
- package/dist/services/noaa-parameters-service.d.ts +76 -0
- package/dist/services/noaa-parameters-service.js +128 -0
- package/dist/services/noaa-service.d.ts +52 -0
- package/dist/services/noaa-service.js +151 -0
- package/dist/services/sun-service.d.ts +60 -0
- package/dist/services/sun-service.js +234 -0
- package/dist/sun-service.d.ts +184 -0
- package/dist/sun-service.js +218 -0
- package/dist/tools/derived-product-tools.d.ts +6 -0
- package/dist/tools/derived-product-tools.js +168 -0
- package/dist/tools/index.d.ts +16 -0
- package/dist/tools/index.js +36 -0
- package/dist/tools/moon-tools.d.ts +6 -0
- package/dist/tools/moon-tools.js +69 -0
- package/dist/tools/parameter-tools.d.ts +6 -0
- package/dist/tools/parameter-tools.js +77 -0
- package/dist/tools/station-tools.d.ts +6 -0
- package/dist/tools/station-tools.js +51 -0
- package/dist/tools/sun-tools.d.ts +6 -0
- package/dist/tools/sun-tools.js +109 -0
- package/dist/tools/water-tools.d.ts +6 -0
- package/dist/tools/water-tools.js +150 -0
- package/dist/types/moon.d.ts +26 -0
- package/dist/types/moon.js +14 -0
- package/dist/types/sun.d.ts +49 -0
- package/dist/types/sun.js +19 -0
- package/dist/types.d.ts +337 -0
- package/dist/types.js +98 -0
- package/package.json +56 -0
- package/smithery.yaml +16 -0
- package/src/index.ts +13 -0
- package/src/interfaces/moon.ts +44 -0
- package/src/interfaces/noaa.ts +130 -0
- package/src/interfaces/parameters.ts +20 -0
- package/src/interfaces/sun.ts +57 -0
- package/src/schemas/common.ts +23 -0
- package/src/schemas/dpapi.ts +99 -0
- package/src/server/config.ts +43 -0
- package/src/server/mcp-server.ts +135 -0
- package/src/services/dpapi-service.ts +187 -0
- package/src/services/moon-phase-service.ts +167 -0
- package/src/services/noaa-parameters-service.ts +139 -0
- package/src/services/noaa-service.ts +171 -0
- package/src/services/sun-service.ts +275 -0
- package/src/tools/derived-product-tools.ts +180 -0
- package/src/tools/index.ts +40 -0
- package/src/tools/moon-tools.ts +79 -0
- package/src/tools/parameter-tools.ts +82 -0
- package/src/tools/station-tools.ts +57 -0
- package/src/tools/sun-tools.ts +120 -0
- package/src/tools/water-tools.ts +166 -0
- package/src/types/moon.ts +27 -0
- package/src/types/sun.ts +51 -0
- package/src/types/suncalc.d.ts +110 -0
- package/test-dpapi.js +0 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FastMCP } from 'fastmcp';
|
|
3
|
+
import { NoaaService } from '../services/noaa-service.js';
|
|
4
|
+
import {
|
|
5
|
+
StationSchema,
|
|
6
|
+
UnitsSchema,
|
|
7
|
+
FormatSchema
|
|
8
|
+
} from '../schemas/common.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Register station-related tools with the MCP server
|
|
12
|
+
*/
|
|
13
|
+
export function registerStationTools(server: FastMCP, noaaService: NoaaService) {
|
|
14
|
+
// Add stations tool
|
|
15
|
+
server.addTool({
|
|
16
|
+
name: 'get_stations',
|
|
17
|
+
description: 'Get list of stations',
|
|
18
|
+
parameters: z.object({
|
|
19
|
+
type: z.string().optional().describe('Station type (waterlevels, currents, etc.)'),
|
|
20
|
+
format: z.enum(['json', 'xml']).optional().describe('Output format (json, xml)'),
|
|
21
|
+
units: UnitsSchema,
|
|
22
|
+
}),
|
|
23
|
+
execute: async (params) => {
|
|
24
|
+
try {
|
|
25
|
+
const result = await noaaService.getStations(params);
|
|
26
|
+
return JSON.stringify(result);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error instanceof Error) {
|
|
29
|
+
throw new Error(`Failed to get stations: ${error.message}`);
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Failed to get stations');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Add station details tool
|
|
37
|
+
server.addTool({
|
|
38
|
+
name: 'get_station_details',
|
|
39
|
+
description: 'Get detailed information about a station',
|
|
40
|
+
parameters: z.object({
|
|
41
|
+
station: StationSchema,
|
|
42
|
+
format: z.enum(['json', 'xml']).optional().describe('Output format (json, xml)'),
|
|
43
|
+
units: UnitsSchema,
|
|
44
|
+
}),
|
|
45
|
+
execute: async (params) => {
|
|
46
|
+
try {
|
|
47
|
+
const result = await noaaService.getStationDetails(params);
|
|
48
|
+
return JSON.stringify(result);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error instanceof Error) {
|
|
51
|
+
throw new Error(`Failed to get station details: ${error.message}`);
|
|
52
|
+
}
|
|
53
|
+
throw new Error('Failed to get station details');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { FastMCP } from 'fastmcp';
|
|
2
|
+
import { SunService } from '../services/sun-service.js';
|
|
3
|
+
import {
|
|
4
|
+
SunTimesParamsSchema,
|
|
5
|
+
SunTimesRangeParamsSchema,
|
|
6
|
+
SunPositionParamsSchema,
|
|
7
|
+
NextSunEventParamsSchema
|
|
8
|
+
} from '../interfaces/sun.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Register sun-related tools with the MCP server
|
|
12
|
+
*/
|
|
13
|
+
export function registerSunTools(server: FastMCP, sunService: SunService) {
|
|
14
|
+
// Add sun times tool
|
|
15
|
+
server.addTool({
|
|
16
|
+
name: 'get_sun_times',
|
|
17
|
+
description: 'Get sun rise/set and other sun event times for a specific date and location',
|
|
18
|
+
parameters: SunTimesParamsSchema,
|
|
19
|
+
execute: async (params) => {
|
|
20
|
+
try {
|
|
21
|
+
const result = sunService.getSunTimes(params);
|
|
22
|
+
if (params.format === 'text') {
|
|
23
|
+
let text = `Sun times for ${result.date} at latitude ${params.latitude}, longitude ${params.longitude}:\n`;
|
|
24
|
+
text += `Sunrise: ${result.sunrise || 'N/A'}\n`;
|
|
25
|
+
text += `Sunset: ${result.sunset || 'N/A'}\n`;
|
|
26
|
+
text += `Day length: ${Math.floor(result.dayLength / 60)}h ${Math.round(result.dayLength % 60)}m\n`;
|
|
27
|
+
text += `Solar noon: ${result.solarNoon || 'N/A'}\n`;
|
|
28
|
+
text += `Dawn: ${result.dawn || 'N/A'}\n`;
|
|
29
|
+
text += `Dusk: ${result.dusk || 'N/A'}\n`;
|
|
30
|
+
return text;
|
|
31
|
+
}
|
|
32
|
+
return JSON.stringify(result);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error instanceof Error) {
|
|
35
|
+
throw new Error(`Failed to get sun times: ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
throw new Error('Failed to get sun times');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Add sun times range tool
|
|
43
|
+
server.addTool({
|
|
44
|
+
name: 'get_sun_times_range',
|
|
45
|
+
description: 'Get sun rise/set and other sun event times for a date range and location',
|
|
46
|
+
parameters: SunTimesRangeParamsSchema,
|
|
47
|
+
execute: async (params) => {
|
|
48
|
+
try {
|
|
49
|
+
const results = sunService.getSunTimesRange(params);
|
|
50
|
+
if (params.format === 'text') {
|
|
51
|
+
let text = `Sun times from ${params.start_date} to ${params.end_date} at latitude ${params.latitude}, longitude ${params.longitude}:\n\n`;
|
|
52
|
+
|
|
53
|
+
results.forEach(result => {
|
|
54
|
+
text += `Date: ${result.date}\n`;
|
|
55
|
+
text += `Sunrise: ${result.sunrise || 'N/A'}\n`;
|
|
56
|
+
text += `Sunset: ${result.sunset || 'N/A'}\n`;
|
|
57
|
+
text += `Day length: ${Math.floor(result.dayLength / 60)}h ${Math.round(result.dayLength % 60)}m\n\n`;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
62
|
+
return JSON.stringify(results);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
throw new Error(`Failed to get sun times range: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
throw new Error('Failed to get sun times range');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Add sun position tool
|
|
73
|
+
server.addTool({
|
|
74
|
+
name: 'get_sun_position',
|
|
75
|
+
description: 'Get sun position information for a specific date, time, and location',
|
|
76
|
+
parameters: SunPositionParamsSchema,
|
|
77
|
+
execute: async (params) => {
|
|
78
|
+
try {
|
|
79
|
+
const result = sunService.getSunPosition(params);
|
|
80
|
+
if (params.format === 'text') {
|
|
81
|
+
let text = `Sun position for ${result.date} ${result.time} at latitude ${params.latitude}, longitude ${params.longitude}:\n`;
|
|
82
|
+
text += `Azimuth: ${result.azimuth.toFixed(2)}°\n`;
|
|
83
|
+
text += `Altitude: ${result.altitude.toFixed(2)}°\n`;
|
|
84
|
+
text += `Declination: ${result.declination.toFixed(2)}°\n`;
|
|
85
|
+
text += `Right Ascension: ${result.rightAscension.toFixed(2)}h\n`;
|
|
86
|
+
return text;
|
|
87
|
+
}
|
|
88
|
+
return JSON.stringify(result);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error instanceof Error) {
|
|
91
|
+
throw new Error(`Failed to get sun position: ${error.message}`);
|
|
92
|
+
}
|
|
93
|
+
throw new Error('Failed to get sun position');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Add next sun event tool
|
|
99
|
+
server.addTool({
|
|
100
|
+
name: 'get_next_sun_event',
|
|
101
|
+
description: 'Get the next occurrence(s) of a specific sun event',
|
|
102
|
+
parameters: NextSunEventParamsSchema,
|
|
103
|
+
execute: async (params) => {
|
|
104
|
+
try {
|
|
105
|
+
const results = sunService.getNextSunEvent(params);
|
|
106
|
+
if (params.format === 'text') {
|
|
107
|
+
return results.map(result =>
|
|
108
|
+
`Next ${result.event}: ${result.date} at ${result.time}`
|
|
109
|
+
).join('\n');
|
|
110
|
+
}
|
|
111
|
+
return JSON.stringify(results);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof Error) {
|
|
114
|
+
throw new Error(`Failed to get next sun event: ${error.message}`);
|
|
115
|
+
}
|
|
116
|
+
throw new Error('Failed to get next sun event');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FastMCP } from 'fastmcp';
|
|
3
|
+
import { NoaaService } from '../services/noaa-service.js';
|
|
4
|
+
import {
|
|
5
|
+
StationSchema,
|
|
6
|
+
DateSchema,
|
|
7
|
+
BeginDateSchema,
|
|
8
|
+
EndDateSchema,
|
|
9
|
+
RangeSchema,
|
|
10
|
+
DatumSchema,
|
|
11
|
+
UnitsSchema,
|
|
12
|
+
TimeZoneSchema,
|
|
13
|
+
FormatSchema,
|
|
14
|
+
BinSchema,
|
|
15
|
+
IntervalSchema,
|
|
16
|
+
refineDateParams,
|
|
17
|
+
dateRefinementMessage
|
|
18
|
+
} from '../schemas/common.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Register water-related tools with the MCP server
|
|
22
|
+
*/
|
|
23
|
+
export function registerWaterTools(server: FastMCP, noaaService: NoaaService) {
|
|
24
|
+
// Add water levels tool
|
|
25
|
+
server.addTool({
|
|
26
|
+
name: 'get_water_levels',
|
|
27
|
+
description: 'Get water level data for a station',
|
|
28
|
+
parameters: z.object({
|
|
29
|
+
station: StationSchema,
|
|
30
|
+
date: DateSchema,
|
|
31
|
+
begin_date: BeginDateSchema,
|
|
32
|
+
end_date: EndDateSchema,
|
|
33
|
+
range: RangeSchema,
|
|
34
|
+
datum: DatumSchema,
|
|
35
|
+
units: UnitsSchema,
|
|
36
|
+
time_zone: TimeZoneSchema,
|
|
37
|
+
format: FormatSchema,
|
|
38
|
+
}).refine(refineDateParams, { message: dateRefinementMessage }),
|
|
39
|
+
execute: async (params) => {
|
|
40
|
+
try {
|
|
41
|
+
const result = await noaaService.getWaterLevels(params);
|
|
42
|
+
return JSON.stringify(result);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error instanceof Error) {
|
|
45
|
+
throw new Error(`Failed to get water levels: ${error.message}`);
|
|
46
|
+
}
|
|
47
|
+
throw new Error('Failed to get water levels');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Add tide predictions tool
|
|
53
|
+
server.addTool({
|
|
54
|
+
name: 'get_tide_predictions',
|
|
55
|
+
description: 'Get tide prediction data',
|
|
56
|
+
parameters: z.object({
|
|
57
|
+
station: StationSchema,
|
|
58
|
+
begin_date: BeginDateSchema,
|
|
59
|
+
end_date: EndDateSchema,
|
|
60
|
+
date: DateSchema,
|
|
61
|
+
range: RangeSchema,
|
|
62
|
+
datum: DatumSchema,
|
|
63
|
+
units: UnitsSchema,
|
|
64
|
+
time_zone: TimeZoneSchema,
|
|
65
|
+
interval: IntervalSchema,
|
|
66
|
+
format: FormatSchema,
|
|
67
|
+
}).refine(refineDateParams, { message: dateRefinementMessage }),
|
|
68
|
+
execute: async (params) => {
|
|
69
|
+
try {
|
|
70
|
+
const result = await noaaService.getTidePredictions(params);
|
|
71
|
+
return JSON.stringify(result);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if (error instanceof Error) {
|
|
74
|
+
throw new Error(`Failed to get tide predictions: ${error.message}`);
|
|
75
|
+
}
|
|
76
|
+
throw new Error('Failed to get tide predictions');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Add currents tool
|
|
82
|
+
server.addTool({
|
|
83
|
+
name: 'get_currents',
|
|
84
|
+
description: 'Get currents data for a station',
|
|
85
|
+
parameters: z.object({
|
|
86
|
+
station: StationSchema,
|
|
87
|
+
date: DateSchema,
|
|
88
|
+
begin_date: BeginDateSchema,
|
|
89
|
+
end_date: EndDateSchema,
|
|
90
|
+
range: RangeSchema,
|
|
91
|
+
bin: BinSchema,
|
|
92
|
+
units: UnitsSchema,
|
|
93
|
+
time_zone: TimeZoneSchema,
|
|
94
|
+
format: FormatSchema,
|
|
95
|
+
}).refine(refineDateParams, { message: dateRefinementMessage }),
|
|
96
|
+
execute: async (params) => {
|
|
97
|
+
try {
|
|
98
|
+
const result = await noaaService.getCurrents(params);
|
|
99
|
+
return JSON.stringify(result);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error instanceof Error) {
|
|
102
|
+
throw new Error(`Failed to get currents: ${error.message}`);
|
|
103
|
+
}
|
|
104
|
+
throw new Error('Failed to get currents');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Add current predictions tool
|
|
110
|
+
server.addTool({
|
|
111
|
+
name: 'get_current_predictions',
|
|
112
|
+
description: 'Get current predictions',
|
|
113
|
+
parameters: z.object({
|
|
114
|
+
station: StationSchema,
|
|
115
|
+
date: DateSchema,
|
|
116
|
+
begin_date: BeginDateSchema,
|
|
117
|
+
end_date: EndDateSchema,
|
|
118
|
+
range: RangeSchema,
|
|
119
|
+
bin: BinSchema,
|
|
120
|
+
interval: z.string().optional().describe('Interval (MAX_SLACK or a number for minutes)'),
|
|
121
|
+
vel_type: z.enum(['speed_dir', 'default']).optional().describe('Velocity type (speed_dir or default)'),
|
|
122
|
+
units: UnitsSchema,
|
|
123
|
+
time_zone: TimeZoneSchema,
|
|
124
|
+
format: FormatSchema,
|
|
125
|
+
}).refine(refineDateParams, { message: dateRefinementMessage }),
|
|
126
|
+
execute: async (params) => {
|
|
127
|
+
try {
|
|
128
|
+
const result = await noaaService.getCurrentPredictions(params);
|
|
129
|
+
return JSON.stringify(result);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (error instanceof Error) {
|
|
132
|
+
throw new Error(`Failed to get current predictions: ${error.message}`);
|
|
133
|
+
}
|
|
134
|
+
throw new Error('Failed to get current predictions');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Add meteorological data tool
|
|
140
|
+
server.addTool({
|
|
141
|
+
name: 'get_meteorological_data',
|
|
142
|
+
description: 'Get meteorological data',
|
|
143
|
+
parameters: z.object({
|
|
144
|
+
station: StationSchema,
|
|
145
|
+
product: z.string().min(1).describe('Product (air_temperature, wind, etc.)'),
|
|
146
|
+
date: DateSchema,
|
|
147
|
+
begin_date: BeginDateSchema,
|
|
148
|
+
end_date: EndDateSchema,
|
|
149
|
+
range: RangeSchema,
|
|
150
|
+
units: UnitsSchema,
|
|
151
|
+
time_zone: TimeZoneSchema,
|
|
152
|
+
format: FormatSchema,
|
|
153
|
+
}).refine(refineDateParams, { message: dateRefinementMessage }),
|
|
154
|
+
execute: async (params) => {
|
|
155
|
+
try {
|
|
156
|
+
const result = await noaaService.getMeteorologicalData(params);
|
|
157
|
+
return JSON.stringify(result);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
if (error instanceof Error) {
|
|
160
|
+
throw new Error(`Failed to get meteorological data: ${error.message}`);
|
|
161
|
+
}
|
|
162
|
+
throw new Error('Failed to get meteorological data');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moon phase names and their approximate ranges
|
|
3
|
+
*/
|
|
4
|
+
export enum MoonPhaseName {
|
|
5
|
+
NEW_MOON = 'New Moon',
|
|
6
|
+
WAXING_CRESCENT = 'Waxing Crescent',
|
|
7
|
+
FIRST_QUARTER = 'First Quarter',
|
|
8
|
+
WAXING_GIBBOUS = 'Waxing Gibbous',
|
|
9
|
+
FULL_MOON = 'Full Moon',
|
|
10
|
+
WANING_GIBBOUS = 'Waning Gibbous',
|
|
11
|
+
LAST_QUARTER = 'Last Quarter',
|
|
12
|
+
WANING_CRESCENT = 'Waning Crescent'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Moon phase information
|
|
17
|
+
*/
|
|
18
|
+
export interface MoonPhaseInfo {
|
|
19
|
+
date: string;
|
|
20
|
+
phase: number;
|
|
21
|
+
phaseName: MoonPhaseName;
|
|
22
|
+
illumination: number;
|
|
23
|
+
age: number;
|
|
24
|
+
distance: number;
|
|
25
|
+
diameter: number;
|
|
26
|
+
isWaxing: boolean;
|
|
27
|
+
}
|
package/src/types/sun.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sun event types
|
|
3
|
+
*/
|
|
4
|
+
export enum SunEventType {
|
|
5
|
+
SUNRISE = 'sunrise',
|
|
6
|
+
SUNSET = 'sunset',
|
|
7
|
+
DAWN = 'dawn',
|
|
8
|
+
DUSK = 'dusk',
|
|
9
|
+
SOLAR_NOON = 'solarNoon',
|
|
10
|
+
NIGHT_START = 'night',
|
|
11
|
+
NIGHT_END = 'nightEnd',
|
|
12
|
+
GOLDEN_HOUR_START = 'goldenHourStart',
|
|
13
|
+
GOLDEN_HOUR_END = 'goldenHourEnd',
|
|
14
|
+
NAUTICAL_DAWN = 'nauticalDawn',
|
|
15
|
+
NAUTICAL_DUSK = 'nauticalDusk',
|
|
16
|
+
ASTRONOMICAL_DAWN = 'astronomicalDawn',
|
|
17
|
+
ASTRONOMICAL_DUSK = 'astronomicalDusk'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Sun times information
|
|
22
|
+
*/
|
|
23
|
+
export interface SunTimesInfo {
|
|
24
|
+
date: string;
|
|
25
|
+
sunrise: string | null;
|
|
26
|
+
sunset: string | null;
|
|
27
|
+
solarNoon: string | null;
|
|
28
|
+
dawn: string | null;
|
|
29
|
+
dusk: string | null;
|
|
30
|
+
nightStart: string | null;
|
|
31
|
+
nightEnd: string | null;
|
|
32
|
+
goldenHourStart: string | null;
|
|
33
|
+
goldenHourEnd: string | null;
|
|
34
|
+
nauticalDawn: string | null;
|
|
35
|
+
nauticalDusk: string | null;
|
|
36
|
+
astronomicalDawn: string | null;
|
|
37
|
+
astronomicalDusk: string | null;
|
|
38
|
+
dayLength: number; // in minutes
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Sun position information
|
|
43
|
+
*/
|
|
44
|
+
export interface SunPositionInfo {
|
|
45
|
+
date: string;
|
|
46
|
+
time: string;
|
|
47
|
+
azimuth: number;
|
|
48
|
+
altitude: number;
|
|
49
|
+
declination: number;
|
|
50
|
+
rightAscension: number;
|
|
51
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
declare module 'suncalc' {
|
|
2
|
+
export interface MoonIllumination {
|
|
3
|
+
/** fraction of moon's visible disk that is illuminated */
|
|
4
|
+
fraction: number;
|
|
5
|
+
/** moon phase (0.0-1.0) */
|
|
6
|
+
phase: number;
|
|
7
|
+
/** midpoint angle in radians of the illuminated limb of the moon reckoned eastward from the north point of the disk */
|
|
8
|
+
angle: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MoonPosition {
|
|
12
|
+
/** moon azimuth in radians */
|
|
13
|
+
azimuth: number;
|
|
14
|
+
/** moon altitude above the horizon in radians */
|
|
15
|
+
altitude: number;
|
|
16
|
+
/** distance to moon in kilometers */
|
|
17
|
+
distance: number;
|
|
18
|
+
/** parallactic angle of the moon in radians */
|
|
19
|
+
parallacticAngle: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SunPosition {
|
|
23
|
+
/** sun azimuth in radians (direction along the horizon, measured from south to west) */
|
|
24
|
+
azimuth: number;
|
|
25
|
+
/** sun altitude above the horizon in radians */
|
|
26
|
+
altitude: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SunTimes {
|
|
30
|
+
/** sunrise (top edge of the sun appears on the horizon) */
|
|
31
|
+
sunrise: Date;
|
|
32
|
+
/** sunrise ends (bottom edge of the sun touches the horizon) */
|
|
33
|
+
sunriseEnd: Date;
|
|
34
|
+
/** morning golden hour (soft light, best time for photography) starts */
|
|
35
|
+
goldenHourEnd: Date;
|
|
36
|
+
/** solar noon (sun is in the highest position) */
|
|
37
|
+
solarNoon: Date;
|
|
38
|
+
/** evening golden hour starts */
|
|
39
|
+
goldenHour: Date;
|
|
40
|
+
/** sunset starts (bottom edge of the sun touches the horizon) */
|
|
41
|
+
sunsetStart: Date;
|
|
42
|
+
/** sunset (sun disappears below the horizon, evening civil twilight starts) */
|
|
43
|
+
sunset: Date;
|
|
44
|
+
/** dusk (evening nautical twilight starts) */
|
|
45
|
+
dusk: Date;
|
|
46
|
+
/** nautical dusk (evening astronomical twilight starts) */
|
|
47
|
+
nauticalDusk: Date;
|
|
48
|
+
/** astronomical dusk (evening astronomical twilight starts) */
|
|
49
|
+
astronomicalDusk: Date;
|
|
50
|
+
/** night starts (dark enough for astronomical observations) */
|
|
51
|
+
night: Date;
|
|
52
|
+
/** nadir (darkest moment of the night, sun is in the lowest position) */
|
|
53
|
+
nadir: Date;
|
|
54
|
+
/** night ends (morning astronomical twilight starts) */
|
|
55
|
+
nightEnd: Date;
|
|
56
|
+
/** astronomical dawn (morning astronomical twilight starts) */
|
|
57
|
+
astronomicalDawn: Date;
|
|
58
|
+
/** nautical dawn (morning nautical twilight starts) */
|
|
59
|
+
nauticalDawn: Date;
|
|
60
|
+
/** dawn (morning nautical twilight ends, morning civil twilight starts) */
|
|
61
|
+
dawn: Date;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface MoonTimes {
|
|
65
|
+
/** moonrise time as Date */
|
|
66
|
+
rise: Date | null;
|
|
67
|
+
/** moonset time as Date */
|
|
68
|
+
set: Date | null;
|
|
69
|
+
/** true if the moon never rises/sets and is always above the horizon during the day */
|
|
70
|
+
alwaysUp: boolean;
|
|
71
|
+
/** true if the moon is always below the horizon */
|
|
72
|
+
alwaysDown: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Calculates sun position for a given date and latitude/longitude
|
|
77
|
+
*/
|
|
78
|
+
export function getPosition(date: Date | number, lat: number, lng: number): SunPosition;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Calculates sun times for a given date, latitude/longitude, and, optionally, the observer height (in meters) relative to the horizon
|
|
82
|
+
*/
|
|
83
|
+
export function getTimes(date: Date | number, lat: number, lng: number, height?: number): SunTimes;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns an object with the following properties:
|
|
87
|
+
* altitude: moon altitude above the horizon in radians
|
|
88
|
+
* azimuth: moon azimuth in radians
|
|
89
|
+
* distance: distance to moon in kilometers
|
|
90
|
+
* parallacticAngle: parallactic angle of the moon in radians
|
|
91
|
+
*/
|
|
92
|
+
export function getMoonPosition(date: Date | number, lat: number, lng: number): MoonPosition;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Returns an object with the following properties:
|
|
96
|
+
* fraction: illuminated fraction of the moon; varies from 0.0 (new moon) to 1.0 (full moon)
|
|
97
|
+
* phase: moon phase; varies from 0.0 to 1.0, described below
|
|
98
|
+
* angle: midpoint angle in radians of the illuminated limb of the moon reckoned eastward from the north point of the disk
|
|
99
|
+
*/
|
|
100
|
+
export function getMoonIllumination(date: Date | number): MoonIllumination;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns an object with the following properties:
|
|
104
|
+
* rise: moonrise time as Date
|
|
105
|
+
* set: moonset time as Date
|
|
106
|
+
* alwaysUp: true if the moon never rises/sets and is always above the horizon during the day
|
|
107
|
+
* alwaysDown: true if the moon is always below the horizon
|
|
108
|
+
*/
|
|
109
|
+
export function getMoonTimes(date: Date | number, lat: number, lng: number, inUTC?: boolean): MoonTimes;
|
|
110
|
+
}
|
package/test-dpapi.js
ADDED
|
File without changes
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"resolveJsonModule": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"],
|
|
14
|
+
"exclude": ["node_modules", "**/*.test.ts"]
|
|
15
|
+
}
|