@rise-maritime/keelson-js 0.6.0-alpha.232.dev.1 → 0.6.0-alpha.255.dev.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.
Files changed (37) hide show
  1. package/dist/index.d.ts +8 -8
  2. package/dist/interfaces/Route.d.ts +24 -0
  3. package/dist/interfaces/Route.js +57 -2
  4. package/dist/interfaces/ScenarioControl.d.ts +3 -96
  5. package/dist/interfaces/ScenarioControl.js +37 -394
  6. package/dist/interfaces/VehicleSimulatorControl.d.ts +83 -0
  7. package/dist/interfaces/VehicleSimulatorControl.js +293 -1
  8. package/dist/interfaces/serviceRegistry.d.ts +8 -8
  9. package/dist/payloads/ChecklistEvent.d.ts +178 -0
  10. package/dist/payloads/ChecklistEvent.js +539 -0
  11. package/dist/payloads/ChecklistEvidence.d.ts +79 -0
  12. package/dist/payloads/ChecklistEvidence.js +287 -0
  13. package/dist/payloads/ChecklistPresence.d.ts +68 -0
  14. package/dist/payloads/ChecklistPresence.js +286 -0
  15. package/dist/payloads/ChecklistProcedure.d.ts +81 -0
  16. package/dist/payloads/ChecklistProcedure.js +364 -0
  17. package/dist/payloads/ChecklistState.d.ts +283 -0
  18. package/dist/payloads/ChecklistState.js +1100 -0
  19. package/dist/payloads/EnvelopeExceedance.d.ts +216 -0
  20. package/dist/payloads/EnvelopeExceedance.js +461 -0
  21. package/dist/payloads/Route.d.ts +24 -0
  22. package/dist/payloads/Route.js +57 -2
  23. package/dist/payloads/RouteExecution.d.ts +81 -1
  24. package/dist/payloads/RouteExecution.js +215 -1
  25. package/dist/payloads/ScenarioEvent.d.ts +90 -0
  26. package/dist/payloads/ScenarioEvent.js +294 -0
  27. package/dist/payloads/ScenarioTickAck.d.ts +95 -0
  28. package/dist/payloads/ScenarioTickAck.js +239 -0
  29. package/dist/payloads/index.foxglove.d.ts +1 -1
  30. package/dist/payloads/index.foxglove.js +1 -1
  31. package/dist/payloads/index.google.protobuf.d.ts +1 -1
  32. package/dist/payloads/index.google.protobuf.js +1 -1
  33. package/dist/payloads/index.keelson.d.ts +9 -1
  34. package/dist/payloads/index.keelson.js +9 -1
  35. package/dist/qos.json +13 -1
  36. package/dist/subjects.json +9 -1
  37. package/package.json +1 -1
@@ -0,0 +1,216 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ import { EnvelopeBound, RouteRef } from "./Route";
3
+ /**
4
+ * The record that an operational envelope limit was breached, that the system
5
+ * noticed, and what it did about it.
6
+ *
7
+ * Companion to `RouteExecution.envelope_limits`, and deliberately separate from
8
+ * it. That one is the live standing — "are we outside the envelope now" — and
9
+ * is an ephemeral 1 Hz snapshot that storage_manager does not persist. This is
10
+ * the durable half: the audit record a readiness assessment is written from.
11
+ *
12
+ * The three timestamps are the reason this message exists. Constraint
13
+ * monitoring latency is two distinct questions:
14
+ *
15
+ * detected_at - crossed_at how long before the system noticed
16
+ * responded_at - detected_at how long before it acted
17
+ *
18
+ * A system can notice instantly and act slowly, or run a slow detector into a
19
+ * fast reaction. One timestamp cannot tell those apart, and neither can a
20
+ * boolean sampled at 1 Hz.
21
+ *
22
+ * Not folded into `Alarm`: an alarm is an operator notification, and a limit
23
+ * crossed and handled autonomously raises none — which is exactly the case an
24
+ * assessment most wants evidence of. Tying the record to the alarm path would
25
+ * lose it.
26
+ *
27
+ * -- KEY LAYOUT --------------------------------------------------------------
28
+ *
29
+ * {base_path}/@v0/{entity_id}/pubsub/envelope_exceedance/{voyage_id}/{exceedance_id}
30
+ *
31
+ * Voyage first because that is what an assessment correlates by: one wildcard
32
+ * read returns every breach of one sailing. Both tokens are single by
33
+ * construction, so a `.../envelope_exceedance/* /*` storage covers them; a
34
+ * composite id in either position publishes without error and never persists.
35
+ *
36
+ * There is no separate `state/` key tree — durability is a router
37
+ * `storage_manager` responsibility, not a payload or key-space one, exactly as
38
+ * protocol-specification.md section 6.3 states for the route family.
39
+ *
40
+ * -- EMISSION MODEL ----------------------------------------------------------
41
+ *
42
+ * One record per state change, and AT LEAST TWO per breach: one when it is
43
+ * detected, one when it clears. A response applied or escalated part-way
44
+ * through is a state change and emits one of its own.
45
+ *
46
+ * EVERY RECORD IS A FULL RESTATEMENT. `crossed_at`, `detected_at`,
47
+ * `limit_value`, `measured_value`, `responses`, `responded_at` and everything
48
+ * identifying the breach are repeated on every subsequent record carrying the
49
+ * same `exceedance_id`.
50
+ *
51
+ * That rule is what makes the key safe. The store keeps the last value per key,
52
+ * so a closing record that omitted the opening one's fields would silently
53
+ * destroy the latency evidence this message exists to carry — the one thing no
54
+ * consumer could reconstruct. Restating instead means the key always holds the
55
+ * most COMPLETE record rather than merely the most recent, and a late joiner
56
+ * reading the storage gets the whole breach in one value.
57
+ */
58
+ export interface EnvelopeExceedance {
59
+ $type: "keelson.EnvelopeExceedance";
60
+ /**
61
+ * When this record was emitted. Distinct from every timestamp below, which
62
+ * describe the breach rather than the reporting of it.
63
+ */
64
+ timestamp: Date | undefined;
65
+ /**
66
+ * Unique breach identifier (UUID). Also the trailing key segment, and stable
67
+ * across every record of the same breach, so a consumer pairs the opening and
68
+ * closing records without matching on limit and time.
69
+ */
70
+ exceedanceId: string;
71
+ /**
72
+ * The RouteInfo field the limit came from, e.g. "max_wind_gust_mps".
73
+ *
74
+ * A STRING ON PURPOSE, not an enum. We do not yet know whether limits are
75
+ * named by RouteInfo field, by a context-scoped id, or by something a
76
+ * capability declaration defines — that is the open question in #226. An enum
77
+ * frozen before it settles would have to be reserved and replaced; a
78
+ * documented naming convention costs nothing to change. Revisit when #226
79
+ * decides what an operational envelope is.
80
+ */
81
+ limitId: string;
82
+ /**
83
+ * The voyage this breach happened on, and the leading key segment.
84
+ *
85
+ * NOT optional, and not derivable from `route_ref`: a RouteRef identifies the
86
+ * plan edition, not the sailing. The same route sailed twice produces records
87
+ * that can only be attributed to a voyage by guessing at time windows, and
88
+ * voyage is the primary correlation key an assessment reads by.
89
+ *
90
+ * A producer with no voyage has nothing to key on, so it has no business
91
+ * publishing this subject — an empty value yields an unaddressable key.
92
+ */
93
+ voyageId: string;
94
+ /**
95
+ * The route edition the limit was read from. An edition rather than a bare
96
+ * route_id because a route bumped mid-voyage may carry different limits, and
97
+ * a breach is only interpretable against the ones actually in force.
98
+ */
99
+ routeRef?: RouteRef | undefined;
100
+ /**
101
+ * The leg being sailed, named by the waypoint it leaves — the same stable-id
102
+ * convention RouteExecution uses. Never an index: an index means a different
103
+ * leg the moment a waypoint is inserted.
104
+ */
105
+ legFromWaypointId?: string | undefined;
106
+ /**
107
+ * Identifies the limit set in force when this breach was judged, so a
108
+ * recorded message can be replayed against the rules that were actually
109
+ * applied — the same provenance pair OperationalAuthority carries as
110
+ * `policy_id` / `policy_config_digest`, for the same reason.
111
+ *
112
+ * This matters more here than it looks. If the envelope turns out to vary
113
+ * with context (#226), a recorded 8 m/s breach cannot distinguish the right
114
+ * limit correctly applied from a stale one wrongly applied — and the second
115
+ * is a monitoring failure this record exists to catch. Without the digest the
116
+ * record can only be replayed against whatever the envelope says TODAY.
117
+ */
118
+ envelopeId?: string | undefined;
119
+ envelopeConfigDigest?: Uint8Array | undefined;
120
+ /**
121
+ * When the measurement actually crossed the limit. `optional` because a
122
+ * producer sampling at an interval knows when it *saw* the crossing, not
123
+ * when it happened; publishing an interpolated guess as a measured instant
124
+ * would corrupt the latency figure this message exists to support.
125
+ */
126
+ crossedAt?: Date | undefined;
127
+ /** When the system determined the limit was breached. */
128
+ detectedAt: Date | undefined;
129
+ /** The limit, and the measurement that breached it. */
130
+ limitValue: number;
131
+ /**
132
+ * The value AT DETECTION — the reading the verdict was actually taken on, at
133
+ * the instant `detected_at` names.
134
+ *
135
+ * Deliberately not the value at crossing: `crossed_at` is optional precisely
136
+ * because a producer sampling at an interval often cannot know the crossing
137
+ * instant, and a value it cannot time is not evidence. This one is always
138
+ * timed, by the timestamp beside it.
139
+ */
140
+ measuredValue: number;
141
+ /**
142
+ * Which side of `limit_value` counts as a breach. Without it `peak_value`
143
+ * below has no meaning — see EnvelopeBound in Route.proto.
144
+ */
145
+ bound: EnvelopeBound;
146
+ /**
147
+ * The most extreme value reached before the breach cleared: the HIGHEST under
148
+ * ENVELOPE_BOUND_UPPER, the LOWEST under ENVELOPE_BOUND_LOWER. Set on the
149
+ * closing record; a breach that peaked far past the limit is a different
150
+ * finding from one that grazed it.
151
+ */
152
+ peakValue?: number | undefined;
153
+ /**
154
+ * Everything done in response, not just the first or the most severe. Real
155
+ * reactions compound — a breach can be alerted AND speed-limited — and a
156
+ * scalar would have forced a producer to pick one and discard the rest, in
157
+ * the one message written to be read back as evidence.
158
+ *
159
+ * RESPONSE_NONE is a MEMBER of this list, never an empty list. Deciding not
160
+ * to act is a finding; an empty `responses` is a producer that never filled
161
+ * the field in, and an assessment must be able to tell those apart.
162
+ */
163
+ responses: EnvelopeExceedance_Response[];
164
+ /**
165
+ * When the response was applied. Absent while none has been. On a compound
166
+ * response this is when the FIRST of them was applied — it is the endpoint of
167
+ * the reaction-latency measurement, and reaction latency is measured to the
168
+ * moment something happened.
169
+ */
170
+ respondedAt?: Date | undefined;
171
+ /**
172
+ * When the measurement returned inside the limit. Absent while the breach is
173
+ * still open, so an open exceedance is distinguishable from one whose closing
174
+ * record was lost — without a consumer having to invent a timeout.
175
+ */
176
+ clearedAt?: Date | undefined;
177
+ }
178
+ export declare enum EnvelopeExceedance_Response {
179
+ RESPONSE_UNSPECIFIED = 0,
180
+ /**
181
+ * RESPONSE_NONE - Observed, and no action taken. A value rather than an absence on
182
+ * purpose: "we saw it and chose not to act" is a finding, and must not be
183
+ * indistinguishable from a producer that never filled the field in.
184
+ */
185
+ RESPONSE_NONE = 1,
186
+ /** RESPONSE_ALERTED - operator notified */
187
+ RESPONSE_ALERTED = 2,
188
+ RESPONSE_SPEED_LIMIT = 3,
189
+ RESPONSE_REROUTE = 4,
190
+ RESPONSE_HOLD = 5,
191
+ RESPONSE_ABORT = 6,
192
+ UNRECOGNIZED = -1
193
+ }
194
+ export declare function envelopeExceedance_ResponseFromJSON(object: any): EnvelopeExceedance_Response;
195
+ export declare function envelopeExceedance_ResponseToJSON(object: EnvelopeExceedance_Response): string;
196
+ export declare const EnvelopeExceedance: MessageFns<EnvelopeExceedance, "keelson.EnvelopeExceedance">;
197
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
198
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
199
+ [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]>;
200
+ } : Partial<T>;
201
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
202
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
203
+ [K in keyof P]: Exact<P[K], I[K]>;
204
+ } & {
205
+ [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never;
206
+ };
207
+ interface MessageFns<T, V extends string> {
208
+ readonly $type: V;
209
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
210
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
211
+ fromJSON(object: any): T;
212
+ toJSON(message: T): unknown;
213
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
214
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
215
+ }
216
+ export {};
@@ -0,0 +1,461 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.6.1
5
+ // protoc v6.30.2
6
+ // source: EnvelopeExceedance.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.EnvelopeExceedance = exports.envelopeExceedance_ResponseToJSON = exports.envelopeExceedance_ResponseFromJSON = exports.EnvelopeExceedance_Response = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ const Route_1 = require("./Route");
12
+ const timestamp_1 = require("./google/protobuf/timestamp");
13
+ const typeRegistry_1 = require("./typeRegistry");
14
+ var EnvelopeExceedance_Response;
15
+ (function (EnvelopeExceedance_Response) {
16
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["RESPONSE_UNSPECIFIED"] = 0] = "RESPONSE_UNSPECIFIED";
17
+ /**
18
+ * RESPONSE_NONE - Observed, and no action taken. A value rather than an absence on
19
+ * purpose: "we saw it and chose not to act" is a finding, and must not be
20
+ * indistinguishable from a producer that never filled the field in.
21
+ */
22
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["RESPONSE_NONE"] = 1] = "RESPONSE_NONE";
23
+ /** RESPONSE_ALERTED - operator notified */
24
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["RESPONSE_ALERTED"] = 2] = "RESPONSE_ALERTED";
25
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["RESPONSE_SPEED_LIMIT"] = 3] = "RESPONSE_SPEED_LIMIT";
26
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["RESPONSE_REROUTE"] = 4] = "RESPONSE_REROUTE";
27
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["RESPONSE_HOLD"] = 5] = "RESPONSE_HOLD";
28
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["RESPONSE_ABORT"] = 6] = "RESPONSE_ABORT";
29
+ EnvelopeExceedance_Response[EnvelopeExceedance_Response["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
30
+ })(EnvelopeExceedance_Response || (exports.EnvelopeExceedance_Response = EnvelopeExceedance_Response = {}));
31
+ function envelopeExceedance_ResponseFromJSON(object) {
32
+ switch (object) {
33
+ case 0:
34
+ case "RESPONSE_UNSPECIFIED":
35
+ return EnvelopeExceedance_Response.RESPONSE_UNSPECIFIED;
36
+ case 1:
37
+ case "RESPONSE_NONE":
38
+ return EnvelopeExceedance_Response.RESPONSE_NONE;
39
+ case 2:
40
+ case "RESPONSE_ALERTED":
41
+ return EnvelopeExceedance_Response.RESPONSE_ALERTED;
42
+ case 3:
43
+ case "RESPONSE_SPEED_LIMIT":
44
+ return EnvelopeExceedance_Response.RESPONSE_SPEED_LIMIT;
45
+ case 4:
46
+ case "RESPONSE_REROUTE":
47
+ return EnvelopeExceedance_Response.RESPONSE_REROUTE;
48
+ case 5:
49
+ case "RESPONSE_HOLD":
50
+ return EnvelopeExceedance_Response.RESPONSE_HOLD;
51
+ case 6:
52
+ case "RESPONSE_ABORT":
53
+ return EnvelopeExceedance_Response.RESPONSE_ABORT;
54
+ case -1:
55
+ case "UNRECOGNIZED":
56
+ default:
57
+ return EnvelopeExceedance_Response.UNRECOGNIZED;
58
+ }
59
+ }
60
+ exports.envelopeExceedance_ResponseFromJSON = envelopeExceedance_ResponseFromJSON;
61
+ function envelopeExceedance_ResponseToJSON(object) {
62
+ switch (object) {
63
+ case EnvelopeExceedance_Response.RESPONSE_UNSPECIFIED:
64
+ return "RESPONSE_UNSPECIFIED";
65
+ case EnvelopeExceedance_Response.RESPONSE_NONE:
66
+ return "RESPONSE_NONE";
67
+ case EnvelopeExceedance_Response.RESPONSE_ALERTED:
68
+ return "RESPONSE_ALERTED";
69
+ case EnvelopeExceedance_Response.RESPONSE_SPEED_LIMIT:
70
+ return "RESPONSE_SPEED_LIMIT";
71
+ case EnvelopeExceedance_Response.RESPONSE_REROUTE:
72
+ return "RESPONSE_REROUTE";
73
+ case EnvelopeExceedance_Response.RESPONSE_HOLD:
74
+ return "RESPONSE_HOLD";
75
+ case EnvelopeExceedance_Response.RESPONSE_ABORT:
76
+ return "RESPONSE_ABORT";
77
+ case EnvelopeExceedance_Response.UNRECOGNIZED:
78
+ default:
79
+ return "UNRECOGNIZED";
80
+ }
81
+ }
82
+ exports.envelopeExceedance_ResponseToJSON = envelopeExceedance_ResponseToJSON;
83
+ function createBaseEnvelopeExceedance() {
84
+ return {
85
+ $type: "keelson.EnvelopeExceedance",
86
+ timestamp: undefined,
87
+ exceedanceId: "",
88
+ limitId: "",
89
+ voyageId: "",
90
+ routeRef: undefined,
91
+ legFromWaypointId: undefined,
92
+ envelopeId: undefined,
93
+ envelopeConfigDigest: undefined,
94
+ crossedAt: undefined,
95
+ detectedAt: undefined,
96
+ limitValue: 0,
97
+ measuredValue: 0,
98
+ bound: 0,
99
+ peakValue: undefined,
100
+ responses: [],
101
+ respondedAt: undefined,
102
+ clearedAt: undefined,
103
+ };
104
+ }
105
+ exports.EnvelopeExceedance = {
106
+ $type: "keelson.EnvelopeExceedance",
107
+ encode(message, writer = new wire_1.BinaryWriter()) {
108
+ if (message.timestamp !== undefined) {
109
+ timestamp_1.Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).join();
110
+ }
111
+ if (message.exceedanceId !== "") {
112
+ writer.uint32(18).string(message.exceedanceId);
113
+ }
114
+ if (message.limitId !== "") {
115
+ writer.uint32(26).string(message.limitId);
116
+ }
117
+ if (message.voyageId !== "") {
118
+ writer.uint32(114).string(message.voyageId);
119
+ }
120
+ if (message.routeRef !== undefined) {
121
+ Route_1.RouteRef.encode(message.routeRef, writer.uint32(34).fork()).join();
122
+ }
123
+ if (message.legFromWaypointId !== undefined) {
124
+ writer.uint32(42).string(message.legFromWaypointId);
125
+ }
126
+ if (message.envelopeId !== undefined) {
127
+ writer.uint32(122).string(message.envelopeId);
128
+ }
129
+ if (message.envelopeConfigDigest !== undefined) {
130
+ writer.uint32(130).bytes(message.envelopeConfigDigest);
131
+ }
132
+ if (message.crossedAt !== undefined) {
133
+ timestamp_1.Timestamp.encode(toTimestamp(message.crossedAt), writer.uint32(50).fork()).join();
134
+ }
135
+ if (message.detectedAt !== undefined) {
136
+ timestamp_1.Timestamp.encode(toTimestamp(message.detectedAt), writer.uint32(58).fork()).join();
137
+ }
138
+ if (message.limitValue !== 0) {
139
+ writer.uint32(69).float(message.limitValue);
140
+ }
141
+ if (message.measuredValue !== 0) {
142
+ writer.uint32(77).float(message.measuredValue);
143
+ }
144
+ if (message.bound !== 0) {
145
+ writer.uint32(136).int32(message.bound);
146
+ }
147
+ if (message.peakValue !== undefined) {
148
+ writer.uint32(85).float(message.peakValue);
149
+ }
150
+ writer.uint32(90).fork();
151
+ for (const v of message.responses) {
152
+ writer.int32(v);
153
+ }
154
+ writer.join();
155
+ if (message.respondedAt !== undefined) {
156
+ timestamp_1.Timestamp.encode(toTimestamp(message.respondedAt), writer.uint32(98).fork()).join();
157
+ }
158
+ if (message.clearedAt !== undefined) {
159
+ timestamp_1.Timestamp.encode(toTimestamp(message.clearedAt), writer.uint32(106).fork()).join();
160
+ }
161
+ return writer;
162
+ },
163
+ decode(input, length) {
164
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
165
+ let end = length === undefined ? reader.len : reader.pos + length;
166
+ const message = createBaseEnvelopeExceedance();
167
+ while (reader.pos < end) {
168
+ const tag = reader.uint32();
169
+ switch (tag >>> 3) {
170
+ case 1: {
171
+ if (tag !== 10) {
172
+ break;
173
+ }
174
+ message.timestamp = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
175
+ continue;
176
+ }
177
+ case 2: {
178
+ if (tag !== 18) {
179
+ break;
180
+ }
181
+ message.exceedanceId = reader.string();
182
+ continue;
183
+ }
184
+ case 3: {
185
+ if (tag !== 26) {
186
+ break;
187
+ }
188
+ message.limitId = reader.string();
189
+ continue;
190
+ }
191
+ case 14: {
192
+ if (tag !== 114) {
193
+ break;
194
+ }
195
+ message.voyageId = reader.string();
196
+ continue;
197
+ }
198
+ case 4: {
199
+ if (tag !== 34) {
200
+ break;
201
+ }
202
+ message.routeRef = Route_1.RouteRef.decode(reader, reader.uint32());
203
+ continue;
204
+ }
205
+ case 5: {
206
+ if (tag !== 42) {
207
+ break;
208
+ }
209
+ message.legFromWaypointId = reader.string();
210
+ continue;
211
+ }
212
+ case 15: {
213
+ if (tag !== 122) {
214
+ break;
215
+ }
216
+ message.envelopeId = reader.string();
217
+ continue;
218
+ }
219
+ case 16: {
220
+ if (tag !== 130) {
221
+ break;
222
+ }
223
+ message.envelopeConfigDigest = reader.bytes();
224
+ continue;
225
+ }
226
+ case 6: {
227
+ if (tag !== 50) {
228
+ break;
229
+ }
230
+ message.crossedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
231
+ continue;
232
+ }
233
+ case 7: {
234
+ if (tag !== 58) {
235
+ break;
236
+ }
237
+ message.detectedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
238
+ continue;
239
+ }
240
+ case 8: {
241
+ if (tag !== 69) {
242
+ break;
243
+ }
244
+ message.limitValue = reader.float();
245
+ continue;
246
+ }
247
+ case 9: {
248
+ if (tag !== 77) {
249
+ break;
250
+ }
251
+ message.measuredValue = reader.float();
252
+ continue;
253
+ }
254
+ case 17: {
255
+ if (tag !== 136) {
256
+ break;
257
+ }
258
+ message.bound = reader.int32();
259
+ continue;
260
+ }
261
+ case 10: {
262
+ if (tag !== 85) {
263
+ break;
264
+ }
265
+ message.peakValue = reader.float();
266
+ continue;
267
+ }
268
+ case 11: {
269
+ if (tag === 88) {
270
+ message.responses.push(reader.int32());
271
+ continue;
272
+ }
273
+ if (tag === 90) {
274
+ const end2 = reader.uint32() + reader.pos;
275
+ while (reader.pos < end2) {
276
+ message.responses.push(reader.int32());
277
+ }
278
+ continue;
279
+ }
280
+ break;
281
+ }
282
+ case 12: {
283
+ if (tag !== 98) {
284
+ break;
285
+ }
286
+ message.respondedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
287
+ continue;
288
+ }
289
+ case 13: {
290
+ if (tag !== 106) {
291
+ break;
292
+ }
293
+ message.clearedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
294
+ continue;
295
+ }
296
+ }
297
+ if ((tag & 7) === 4 || tag === 0) {
298
+ break;
299
+ }
300
+ reader.skip(tag & 7);
301
+ }
302
+ return message;
303
+ },
304
+ fromJSON(object) {
305
+ return {
306
+ $type: exports.EnvelopeExceedance.$type,
307
+ timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
308
+ exceedanceId: isSet(object.exceedanceId) ? globalThis.String(object.exceedanceId) : "",
309
+ limitId: isSet(object.limitId) ? globalThis.String(object.limitId) : "",
310
+ voyageId: isSet(object.voyageId) ? globalThis.String(object.voyageId) : "",
311
+ routeRef: isSet(object.routeRef) ? Route_1.RouteRef.fromJSON(object.routeRef) : undefined,
312
+ legFromWaypointId: isSet(object.legFromWaypointId) ? globalThis.String(object.legFromWaypointId) : undefined,
313
+ envelopeId: isSet(object.envelopeId) ? globalThis.String(object.envelopeId) : undefined,
314
+ envelopeConfigDigest: isSet(object.envelopeConfigDigest)
315
+ ? bytesFromBase64(object.envelopeConfigDigest)
316
+ : undefined,
317
+ crossedAt: isSet(object.crossedAt) ? fromJsonTimestamp(object.crossedAt) : undefined,
318
+ detectedAt: isSet(object.detectedAt) ? fromJsonTimestamp(object.detectedAt) : undefined,
319
+ limitValue: isSet(object.limitValue) ? globalThis.Number(object.limitValue) : 0,
320
+ measuredValue: isSet(object.measuredValue) ? globalThis.Number(object.measuredValue) : 0,
321
+ bound: isSet(object.bound) ? (0, Route_1.envelopeBoundFromJSON)(object.bound) : 0,
322
+ peakValue: isSet(object.peakValue) ? globalThis.Number(object.peakValue) : undefined,
323
+ responses: globalThis.Array.isArray(object?.responses)
324
+ ? object.responses.map((e) => envelopeExceedance_ResponseFromJSON(e))
325
+ : [],
326
+ respondedAt: isSet(object.respondedAt) ? fromJsonTimestamp(object.respondedAt) : undefined,
327
+ clearedAt: isSet(object.clearedAt) ? fromJsonTimestamp(object.clearedAt) : undefined,
328
+ };
329
+ },
330
+ toJSON(message) {
331
+ const obj = {};
332
+ if (message.timestamp !== undefined) {
333
+ obj.timestamp = message.timestamp.toISOString();
334
+ }
335
+ if (message.exceedanceId !== "") {
336
+ obj.exceedanceId = message.exceedanceId;
337
+ }
338
+ if (message.limitId !== "") {
339
+ obj.limitId = message.limitId;
340
+ }
341
+ if (message.voyageId !== "") {
342
+ obj.voyageId = message.voyageId;
343
+ }
344
+ if (message.routeRef !== undefined) {
345
+ obj.routeRef = Route_1.RouteRef.toJSON(message.routeRef);
346
+ }
347
+ if (message.legFromWaypointId !== undefined) {
348
+ obj.legFromWaypointId = message.legFromWaypointId;
349
+ }
350
+ if (message.envelopeId !== undefined) {
351
+ obj.envelopeId = message.envelopeId;
352
+ }
353
+ if (message.envelopeConfigDigest !== undefined) {
354
+ obj.envelopeConfigDigest = base64FromBytes(message.envelopeConfigDigest);
355
+ }
356
+ if (message.crossedAt !== undefined) {
357
+ obj.crossedAt = message.crossedAt.toISOString();
358
+ }
359
+ if (message.detectedAt !== undefined) {
360
+ obj.detectedAt = message.detectedAt.toISOString();
361
+ }
362
+ if (message.limitValue !== 0) {
363
+ obj.limitValue = message.limitValue;
364
+ }
365
+ if (message.measuredValue !== 0) {
366
+ obj.measuredValue = message.measuredValue;
367
+ }
368
+ if (message.bound !== 0) {
369
+ obj.bound = (0, Route_1.envelopeBoundToJSON)(message.bound);
370
+ }
371
+ if (message.peakValue !== undefined) {
372
+ obj.peakValue = message.peakValue;
373
+ }
374
+ if (message.responses?.length) {
375
+ obj.responses = message.responses.map((e) => envelopeExceedance_ResponseToJSON(e));
376
+ }
377
+ if (message.respondedAt !== undefined) {
378
+ obj.respondedAt = message.respondedAt.toISOString();
379
+ }
380
+ if (message.clearedAt !== undefined) {
381
+ obj.clearedAt = message.clearedAt.toISOString();
382
+ }
383
+ return obj;
384
+ },
385
+ create(base) {
386
+ return exports.EnvelopeExceedance.fromPartial(base ?? {});
387
+ },
388
+ fromPartial(object) {
389
+ const message = createBaseEnvelopeExceedance();
390
+ message.timestamp = object.timestamp ?? undefined;
391
+ message.exceedanceId = object.exceedanceId ?? "";
392
+ message.limitId = object.limitId ?? "";
393
+ message.voyageId = object.voyageId ?? "";
394
+ message.routeRef = (object.routeRef !== undefined && object.routeRef !== null)
395
+ ? Route_1.RouteRef.fromPartial(object.routeRef)
396
+ : undefined;
397
+ message.legFromWaypointId = object.legFromWaypointId ?? undefined;
398
+ message.envelopeId = object.envelopeId ?? undefined;
399
+ message.envelopeConfigDigest = object.envelopeConfigDigest ?? undefined;
400
+ message.crossedAt = object.crossedAt ?? undefined;
401
+ message.detectedAt = object.detectedAt ?? undefined;
402
+ message.limitValue = object.limitValue ?? 0;
403
+ message.measuredValue = object.measuredValue ?? 0;
404
+ message.bound = object.bound ?? 0;
405
+ message.peakValue = object.peakValue ?? undefined;
406
+ message.responses = object.responses?.map((e) => e) || [];
407
+ message.respondedAt = object.respondedAt ?? undefined;
408
+ message.clearedAt = object.clearedAt ?? undefined;
409
+ return message;
410
+ },
411
+ };
412
+ typeRegistry_1.messageTypeRegistry.set(exports.EnvelopeExceedance.$type, exports.EnvelopeExceedance);
413
+ function bytesFromBase64(b64) {
414
+ if (globalThis.Buffer) {
415
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
416
+ }
417
+ else {
418
+ const bin = globalThis.atob(b64);
419
+ const arr = new Uint8Array(bin.length);
420
+ for (let i = 0; i < bin.length; ++i) {
421
+ arr[i] = bin.charCodeAt(i);
422
+ }
423
+ return arr;
424
+ }
425
+ }
426
+ function base64FromBytes(arr) {
427
+ if (globalThis.Buffer) {
428
+ return globalThis.Buffer.from(arr).toString("base64");
429
+ }
430
+ else {
431
+ const bin = [];
432
+ arr.forEach((byte) => {
433
+ bin.push(globalThis.String.fromCharCode(byte));
434
+ });
435
+ return globalThis.btoa(bin.join(""));
436
+ }
437
+ }
438
+ function toTimestamp(date) {
439
+ const seconds = Math.trunc(date.getTime() / 1000);
440
+ const nanos = (date.getTime() % 1000) * 1000000;
441
+ return { $type: "google.protobuf.Timestamp", seconds, nanos };
442
+ }
443
+ function fromTimestamp(t) {
444
+ let millis = (t.seconds || 0) * 1000;
445
+ millis += (t.nanos || 0) / 1000000;
446
+ return new globalThis.Date(millis);
447
+ }
448
+ function fromJsonTimestamp(o) {
449
+ if (o instanceof globalThis.Date) {
450
+ return o;
451
+ }
452
+ else if (typeof o === "string") {
453
+ return new globalThis.Date(o);
454
+ }
455
+ else {
456
+ return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
457
+ }
458
+ }
459
+ function isSet(value) {
460
+ return value !== null && value !== undefined;
461
+ }