@skyvexsoftware/stratos-sdk 0.17.0 → 0.19.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.
@@ -0,0 +1,22 @@
1
+ import type { PluginFileAttachment } from "../types/context";
2
+ /**
3
+ * Mark a file on disk for attachment to the PIREP.
4
+ *
5
+ * Pure: it touches no filesystem and never throws. Whether the file exists and
6
+ * can be read is resolved when the submission is built, where a failure is
7
+ * already handled without costing the pilot their flight.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * ctx.flight.attachToPirepSubmission(async (sub) => {
12
+ * const receipts = await groundOps.receiptsFor(sub.flightId);
13
+ * if (!receipts.length) return null;
14
+ * return { receipts: receipts.map((r) => attachFile(r.path)) };
15
+ * });
16
+ * ```
17
+ */
18
+ export declare function attachFile(path: string, opts?: {
19
+ filename?: string;
20
+ contentType?: string;
21
+ }): PluginFileAttachment;
22
+ //# sourceMappingURL=attach-file.d.ts.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Mark a file on disk for attachment to the PIREP.
3
+ *
4
+ * Pure: it touches no filesystem and never throws. Whether the file exists and
5
+ * can be read is resolved when the submission is built, where a failure is
6
+ * already handled without costing the pilot their flight.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * ctx.flight.attachToPirepSubmission(async (sub) => {
11
+ * const receipts = await groundOps.receiptsFor(sub.flightId);
12
+ * if (!receipts.length) return null;
13
+ * return { receipts: receipts.map((r) => attachFile(r.path)) };
14
+ * });
15
+ * ```
16
+ */
17
+ export function attachFile(path, opts) {
18
+ return {
19
+ __stratosFile: true,
20
+ path,
21
+ ...(opts?.filename !== undefined ? { filename: opts.filename } : {}),
22
+ ...(opts?.contentType !== undefined
23
+ ? { contentType: opts.contentType }
24
+ : {}),
25
+ };
26
+ }
@@ -1,4 +1,5 @@
1
1
  export { createPlugin } from "./createPlugin";
2
+ export { attachFile } from "./attach-file";
2
3
  export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./server";
3
4
  export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./units";
4
5
  export type { WeightUnit, AltitudeUnit, DistanceUnit, UnitPreferences, } from "./units";
@@ -1,4 +1,5 @@
1
1
  export { createPlugin } from "./createPlugin";
2
+ export { attachFile } from "./attach-file";
2
3
  export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./server";
3
4
  export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./units";
4
5
  export { classifyAircraft } from "./aircraft";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { PluginAuthor, PluginManifest } from "./types/manifest";
2
- export type { PluginAirline, PluginAirlineAccessor, PluginAuthAccessor, PluginVaApiClient, PluginConfigStore, PluginContext, PluginDatabaseAccessor, PluginIPCRegistrar, PluginLogger, PluginServerRegistrar, PluginFlightAccessor, PluginFlightLogWriter, PluginFlightLogInput, PluginFlightLogPatch, PluginStartGuard, PluginStartContext, PluginStartDecision, PluginNotifier, PluginToastInput, BuiltInSound, PluginAlertSound, PluginDialogApi, PluginPromptApi, PluginDialogAlertInput, PluginDialogConfirmInput, PluginPromptTextInput, PluginPromptNumberInput, PluginPromptSelectInput, PluginIndicatorType, PluginIndicatorInput, PluginSelfApi, } from "./types/context";
2
+ export type { PluginAirline, PluginAirlineAccessor, PluginAuthAccessor, PluginVaApiClient, PluginConfigStore, PluginContext, PluginDatabaseAccessor, PluginIPCRegistrar, PluginLogger, PluginServerRegistrar, PluginFlightAccessor, PluginFlightLogWriter, PluginFlightLogInput, PluginFlightLogPatch, PluginStartGuard, PluginStartContext, PluginStartDecision, PluginPirepSubmissionContext, PluginPirepAttachment, PluginPirepAttachHandler, PluginFileAttachment, PluginNotifier, PluginToastInput, BuiltInSound, PluginAlertSound, PluginDialogApi, PluginPromptApi, PluginDialogAlertInput, PluginDialogConfirmInput, PluginPromptTextInput, PluginPromptNumberInput, PluginPromptSelectInput, PluginIndicatorType, PluginIndicatorInput, PluginSelfApi, } from "./types/context";
3
3
  export type { PluginNavigationHelper, PluginPilotUser, PluginToastAPI, PluginUIContext, } from "./types/context-ui";
4
4
  export type { PluginSettingType, PluginSettingOption, PluginSettingDefinition, PluginAvailableSettings, BooleanSettingDef, TextSettingDef, LongtextSettingDef, NumberSettingDef, RangeSettingDef, ListSettingDef, RadioSettingDef, DateSettingDef, JsonSettingDef, } from "./types/settings";
5
5
  export type { PluginBackgroundModule, PluginRouteComponent, PluginUIModule, } from "./types/module";
@@ -13,6 +13,7 @@ export { ADDITIONAL_FIELD_PHASES, toPhaseKey, } from "./shared-types/additional-
13
13
  export type { AdditionalFieldsConfig, FieldDelivery, } from "./shared-types/additional-fields";
14
14
  export type { FlightPlan, FlightStatus, CurrentFlight, FlightComment, PreflightCheck, PreflightCheckResult, StartFlightOptions, FlightManagerPayload, StartFlightResult, RecoverableFlight, } from "./shared-types/flight-manager";
15
15
  export { createPlugin } from "./helpers/createPlugin";
16
+ export { attachFile } from "./helpers/attach-file";
16
17
  export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./helpers/server";
17
18
  export { vaApi } from "./api/vaApi";
18
19
  export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./helpers/units";
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export { EventCategory } from "./shared-types/flight-events";
4
4
  export { ADDITIONAL_FIELD_PHASES, toPhaseKey, } from "./shared-types/additional-fields";
5
5
  // ── Helper Functions ───────────────────────────────────────────────────
6
6
  export { createPlugin } from "./helpers/createPlugin";
7
+ export { attachFile } from "./helpers/attach-file";
7
8
  export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./helpers/server";
8
9
  export { vaApi } from "./api/vaApi";
9
10
  export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./helpers/units";
@@ -162,6 +162,25 @@ export type PluginFlightAccessor = {
162
162
  * Multiple guards: the first `allow: false` wins. Returns an unsubscribe.
163
163
  */
164
164
  registerStartGuard(guard: PluginStartGuard): () => void;
165
+ /**
166
+ * Register a handler consulted while the airline PIREP is assembled, after
167
+ * every milestone capture and immediately before the body is posted.
168
+ * Whatever it returns is attached to the submission under
169
+ * `plugin_data["<your-plugin-id>"]`. Return null or undefined to attach
170
+ * nothing.
171
+ *
172
+ * Handlers are fail-open: a throw, a rejection, a timeout (3s), a
173
+ * non-object return, or a payload over 256 KB omits this plugin's key and
174
+ * the PIREP is submitted regardless.
175
+ *
176
+ * Handlers run only for `completed`, `diverted` and `crashed` flights, never
177
+ * for cancelled ones, and only when an airline is bound. If the airline
178
+ * rejects the PIREP the pilot can retry, which runs every handler again, so
179
+ * a handler must be idempotent and free of side effects. Registering more
180
+ * than one handler is allowed; their results are shallow-merged under the
181
+ * single plugin key. Returns an unsubscribe.
182
+ */
183
+ attachToPirepSubmission(handler: PluginPirepAttachHandler): () => void;
165
184
  };
166
185
  /** Context handed to a start guard. */
167
186
  export type PluginStartContext = {
@@ -178,6 +197,49 @@ export type PluginStartDecision = {
178
197
  };
179
198
  /** Guard run inside `startFlight` before the flight is created/persisted. */
180
199
  export type PluginStartGuard = (ctx: PluginStartContext) => PluginStartDecision | Promise<PluginStartDecision>;
200
+ /**
201
+ * Context handed to a PIREP submission attachment handler.
202
+ * Describes the PIREP that is about to be filed with the airline.
203
+ */
204
+ export type PluginPirepSubmissionContext = {
205
+ /** Local (core DB) flight id. */
206
+ flightId: string;
207
+ /** Skyvex flight UUID, or null if the flight was never relayed. */
208
+ stratosFlightId: string | null;
209
+ /** VA tracking id for the PIREP being filed. */
210
+ vaTrackingId: string;
211
+ /** Terminal status being filed. Cancelled flights never reach a handler. */
212
+ status: "completed" | "diverted" | "crashed";
213
+ /** The flight plan being filed. */
214
+ plan: FlightPlan;
215
+ /** Last simulator snapshot, or null when no sim is connected. */
216
+ snapshot: SimDataSnapshot | null;
217
+ };
218
+ /**
219
+ * Data to attach to the PIREP. Returning null or undefined (a bare `return;`
220
+ * included) attaches nothing for this flight.
221
+ */
222
+ export type PluginPirepAttachment = Record<string, unknown> | null | undefined;
223
+ /** Handler registered through `ctx.flight.attachToPirepSubmission`. */
224
+ export type PluginPirepAttachHandler = (ctx: PluginPirepSubmissionContext) => PluginPirepAttachment | Promise<PluginPirepAttachment>;
225
+ /**
226
+ * A file to attach to the PIREP, produced by `attachFile()`. Place one anywhere
227
+ * inside the object your handler returns; the shell lifts it out into its own
228
+ * part of a multipart submission and leaves a reference in its place.
229
+ *
230
+ * Carries a `__stratosFile` discriminator rather than relying on object
231
+ * identity, because attachments are JSON round-tripped before the shell walks
232
+ * them.
233
+ */
234
+ export type PluginFileAttachment = {
235
+ readonly __stratosFile: true;
236
+ /** Absolute path to the file on disk. */
237
+ path: string;
238
+ /** Name sent to the airline. Defaults to the basename of `path`. */
239
+ filename?: string;
240
+ /** MIME type. Defaults to a lookup on the extension, else application/octet-stream. */
241
+ contentType?: string;
242
+ };
181
243
  /**
182
244
  * Toast + sound surface. Backs `ctx.notify`.
183
245
  *
@@ -1,5 +1,5 @@
1
1
  export type { PluginAuthor, PluginManifest } from "./manifest";
2
- export type { PluginAirline, PluginAirlineAccessor, PluginAuthAccessor, PluginConfigStore, PluginContext, PluginDatabaseAccessor, PluginIPCRegistrar, PluginLogger, PluginServerRegistrar, PluginFlightAccessor, PluginFlightLogWriter, PluginFlightLogInput, PluginFlightLogPatch, PluginStartGuard, PluginStartContext, PluginStartDecision, PluginNotifier, PluginToastInput, BuiltInSound, PluginAlertSound, } from "./context";
2
+ export type { PluginAirline, PluginAirlineAccessor, PluginAuthAccessor, PluginConfigStore, PluginContext, PluginDatabaseAccessor, PluginIPCRegistrar, PluginLogger, PluginServerRegistrar, PluginFlightAccessor, PluginFlightLogWriter, PluginFlightLogInput, PluginFlightLogPatch, PluginStartGuard, PluginStartContext, PluginStartDecision, PluginPirepSubmissionContext, PluginPirepAttachment, PluginPirepAttachHandler, PluginFileAttachment, PluginNotifier, PluginToastInput, BuiltInSound, PluginAlertSound, } from "./context";
3
3
  export type { PluginNavigationHelper, PluginToastAPI, PluginUIContext, } from "./context-ui";
4
4
  export type { PluginBackgroundModule, PluginRouteComponent, PluginUIModule, } from "./module";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -44,5 +44,7 @@ export type PluginManifest = {
44
44
  availableSettings?: PluginSettingDefinition[];
45
45
  /** Whether to include source maps in the published CDN bundle. Defaults to false — source maps are stripped on approval. Set to true if you want end users to have access to source maps for debugging. */
46
46
  includeSourceMaps?: boolean;
47
+ /** Advisory: this plugin attaches files to the PIREP, which changes how flight submissions are encoded for the airline. Surfaced as a warning in the airline's plugin list; the shell does not enforce it. */
48
+ attachesFilesToPirep?: boolean;
47
49
  };
48
50
  //# sourceMappingURL=manifest.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyvexsoftware/stratos-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Plugin SDK for Stratos — types, hooks, and UI components",
5
5
  "author": {
6
6
  "name": "Skyvex Software Pty Ltd",