@idm-plugin/vessel 1.0.9 → 1.1.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.
package/dist/index.js CHANGED
@@ -1,11 +1,40 @@
1
- var C = Object.defineProperty;
2
- var O = (M, u, e) => u in M ? C(M, u, { enumerable: !0, configurable: !0, writable: !0, value: e }) : M[u] = e;
3
- var q = (M, u, e) => (O(M, typeof u != "symbol" ? u + "" : u, e), e);
1
+ var L = Object.defineProperty;
2
+ var F = (p, u, e) => u in p ? L(p, u, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[u] = e;
3
+ var q = (p, u, e) => (F(p, typeof u != "symbol" ? u + "" : u, e), e);
4
4
  import Y from "got";
5
- import W from "@log4js-node/log4js-api";
6
- import p from "moment";
7
- const j = W.getLogger();
8
- class V {
5
+ import y from "moment";
6
+ function K(p) {
7
+ return p && p.__esModule && Object.prototype.hasOwnProperty.call(p, "default") ? p.default : p;
8
+ }
9
+ class W {
10
+ log() {
11
+ }
12
+ isLevelEnabled() {
13
+ return !1;
14
+ }
15
+ addContext() {
16
+ }
17
+ removeContext() {
18
+ }
19
+ clearContext() {
20
+ }
21
+ }
22
+ ["Trace", "Debug", "Info", "Warn", "Error", "Fatal", "Mark"].forEach((p) => {
23
+ W.prototype[p.toLowerCase()] = () => {
24
+ }, W.prototype[`is${p}Enabled`] = () => !1;
25
+ });
26
+ const z = () => {
27
+ try {
28
+ return require("log4js");
29
+ } catch {
30
+ return null;
31
+ }
32
+ }, V = z(), G = V ? V.getLogger : () => new W();
33
+ var B = {
34
+ getLogger: G
35
+ };
36
+ const O = /* @__PURE__ */ K(B), j = O.getLogger();
37
+ class C {
9
38
  /**
10
39
  * 解析AIS状态码
11
40
  * @param status
@@ -46,7 +75,7 @@ class V {
46
75
  return { labelCn: e, labelEn: n };
47
76
  }
48
77
  }
49
- class U extends V {
78
+ class tt extends C {
50
79
  constructor(e, n) {
51
80
  super();
52
81
  q(this, "clientId");
@@ -68,15 +97,15 @@ class U extends V {
68
97
  expiresIn: o.expires_in,
69
98
  scope: o.scope,
70
99
  jti: o.jti,
71
- issuedAt: p().utc().format()
100
+ issuedAt: y().utc().format()
72
101
  });
73
102
  }
74
103
  async realTimePosition(e, n = {}) {
75
- var h, c, f;
76
- (!this.token || p().diff(p(this.token.issuedAt), "seconds") > ((h = this.token) == null ? void 0 : h.expiresIn) - 300) && await this.authToken(n);
104
+ var h, c, l;
105
+ (!this.token || y().diff(y(this.token.issuedAt), "seconds") > ((h = this.token) == null ? void 0 : h.expiresIn) - 300) && await this.authToken(n);
77
106
  const a = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit", o = {
78
107
  headers: {
79
- Authorization: `${(c = this.token) == null ? void 0 : c.tokenType} ${(f = this.token) == null ? void 0 : f.accessToken}`
108
+ Authorization: `${(c = this.token) == null ? void 0 : c.tokenType} ${(l = this.token) == null ? void 0 : l.accessToken}`
80
109
  },
81
110
  searchParams: { mmsi: e }
82
111
  };
@@ -87,7 +116,7 @@ class U extends V {
87
116
  const t = s.data;
88
117
  for (const m in t)
89
118
  !isNaN(t[m]) && Number(t[m]) !== 1 / 0 && (t[m] = Number(t[m]));
90
- const r = p(`${t.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
119
+ const r = y(`${t.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
91
120
  return {
92
121
  mmsi: t.mmsi,
93
122
  name: t.vesselName,
@@ -114,17 +143,17 @@ class U extends V {
114
143
  };
115
144
  }
116
145
  async trajectory(e, n, a, o, s = !0, t = {}) {
117
- (!this.token || p().diff(p(this.token.issuedAt), "seconds") > this.token.expiresIn - 300) && await this.authToken(t);
118
- const r = await this.realTimePosition(e, t), i = p(n), h = p(a), c = [];
146
+ (!this.token || y().diff(y(this.token.issuedAt), "seconds") > this.token.expiresIn - 300) && await this.authToken(t);
147
+ const r = await this.realTimePosition(e, t), i = y(n), h = y(a), c = [];
119
148
  for (; h.diff(i, "day", !0) > 30; )
120
149
  await this.trajectoryIn30Day(e, i, i.clone().add(30, "day"), r, o, c, t), i.add(30, "day");
121
150
  return await this.trajectoryIn30Day(e, i, h, r, o, c, t), c;
122
151
  }
123
152
  async trajectoryIn30Day(e, n, a, o, s, t, r = {}) {
124
- var d, b, v, y, w;
153
+ var d, M, v, k, w;
125
154
  const i = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", h = {
126
155
  headers: {
127
- Authorization: `${(d = this.token) == null ? void 0 : d.tokenType} ${(b = this.token) == null ? void 0 : b.accessToken}`
156
+ Authorization: `${(d = this.token) == null ? void 0 : d.tokenType} ${(M = this.token) == null ? void 0 : M.accessToken}`
128
157
  },
129
158
  json: {
130
159
  mmsi: e,
@@ -136,12 +165,12 @@ class U extends V {
136
165
  const c = await Y.post(i, h).json();
137
166
  if (c.code)
138
167
  return j.warn("[%s] fetch trajectory failed: %j", r.requestId, i, { message: c.message, status: c.status, code: c.code }), c;
139
- let f = -1;
140
- const m = p(`${(y = (v = c.data) == null ? void 0 : v[0]) == null ? void 0 : y.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
168
+ let l = -1;
169
+ const m = y(`${(k = (v = c.data) == null ? void 0 : v[0]) == null ? void 0 : k.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
141
170
  return (w = c.data) == null || w.forEach((g) => {
142
171
  for (const S in g)
143
172
  !isNaN(g[S]) && Number(g[S]) !== 1 / 0 && (g[S] = Number(g[S]));
144
- const I = p(`${g.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), N = g.eta ? p(`${g.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00") : void 0, l = g.status, { labelCn: E, labelEn: _ } = this.parseStatus(l), R = {
173
+ const I = y(`${g.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), N = g.eta ? y(`${g.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00") : void 0, f = g.status, { labelCn: D, labelEn: _ } = this.parseStatus(f), R = {
145
174
  mmsi: g.mmsi,
146
175
  imo: o == null ? void 0 : o.imo,
147
176
  lat: g.lat,
@@ -150,21 +179,21 @@ class U extends V {
150
179
  cog: g.cog,
151
180
  hdg: g.hdg,
152
181
  draught: g.draught,
153
- status: l,
182
+ status: f,
154
183
  eta: N == null ? void 0 : N.unix(),
155
184
  destination: g.dest,
156
185
  positionTime: I.unix(),
157
- labelCn: E,
186
+ labelCn: D,
158
187
  labelEn: _,
159
188
  method: "trajectory",
160
189
  vendor: "myVessel",
161
190
  utc: I.utc().format()
162
191
  }, H = Math.floor(I.diff(m, "minute", !0) / (s || 1));
163
- H !== f && (f = H, t.push(R));
192
+ H !== l && (l = H, t.push(R));
164
193
  }), t;
165
194
  }
166
195
  }
167
- class J extends V {
196
+ class et extends C {
168
197
  constructor(e) {
169
198
  super();
170
199
  q(this, "token");
@@ -184,7 +213,7 @@ class J extends V {
184
213
  for (const m in t)
185
214
  !isNaN(t[m]) && Number(t[m]) !== 1 / 0 && (t[m] = Number(t[m]));
186
215
  t.status = t.sp > 3 ? 0 : 1;
187
- const r = t.status, { labelCn: i, labelEn: h } = this.parseStatus(r), c = p(`${t.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
216
+ const r = t.status, { labelCn: i, labelEn: h } = this.parseStatus(r), c = y(`${t.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
188
217
  return {
189
218
  mmsi: t.m,
190
219
  name: t.n,
@@ -199,7 +228,7 @@ class J extends V {
199
228
  cog: t.co,
200
229
  hdg: t.h,
201
230
  rot: isNaN(t.rot) ? 0 : t.rot,
202
- eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(t.eta) ? p(`${t.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00").unix() : void 0,
231
+ eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(t.eta) ? y(`${t.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00").unix() : void 0,
203
232
  destination: t.destination,
204
233
  positionTime: c.unix(),
205
234
  utc: c.utc().format(),
@@ -240,55 +269,55 @@ class J extends V {
240
269
  async trajectory(e, n, a, o, s = !0, t = {}) {
241
270
  var g, I, N;
242
271
  const r = await this.realTimePosition(e, t);
243
- let i = p(n);
244
- const h = p(a), c = p();
272
+ let i = y(n);
273
+ const h = y(a), c = y();
245
274
  if (s) {
246
- let l = h.diff(i, "d", !0);
247
- l < 0 ? i = h.clone().subtract(40, "d") : l < 30 ? i.subtract(10, "d") : l < 60 ? i.subtract(5, "d") : i = h.clone().subtract(80, "d"), l = c.diff(h, "d", !0), h.add(l > 10 ? 240 : l * 24, "h");
275
+ let f = h.diff(i, "d", !0);
276
+ f < 0 ? i = h.clone().subtract(40, "d") : f < 30 ? i.subtract(10, "d") : f < 60 ? i.subtract(5, "d") : i = h.clone().subtract(80, "d"), f = c.diff(h, "d", !0), h.add(f > 10 ? 240 : f * 24, "h");
248
277
  }
249
- const f = {
278
+ const l = {
250
279
  searchParams: {
251
280
  endtime: h.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),
252
281
  starttime: i.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),
253
282
  mmsi: e,
254
283
  usertoken: this.token
255
284
  }
256
- }, m = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", d = await Y.get(m, f).json();
257
- j.info("[%s] fetch trajectory from: %s - %j", t.requestId, m, f);
258
- let b;
259
- d && (b = ((I = (g = d.ships) == null ? void 0 : g.offors) == null ? void 0 : I.ship) || [], b.length || j.warn("[%s] fetch trajectory failed: %j", t.requestId, d));
285
+ }, m = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", d = await Y.get(m, l).json();
286
+ j.info("[%s] fetch trajectory from: %s - %j", t.requestId, m, l);
287
+ let M;
288
+ d && (M = ((I = (g = d.ships) == null ? void 0 : g.offors) == null ? void 0 : I.ship) || [], M.length || j.warn("[%s] fetch trajectory failed: %j", t.requestId, d));
260
289
  const v = [];
261
- let y = -1;
262
- const w = p(`${(N = b == null ? void 0 : b[0]) == null ? void 0 : N.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
263
- for (const l of b) {
264
- for (const x in l)
265
- !isNaN(l[x]) && Number(l[x]) !== 1 / 0 && (l[x] = Number(l[x]));
266
- const E = p(`${l.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
267
- l.status = l.sp > 4 ? 0 : 1;
268
- const { labelEn: _, labelCn: R } = this.parseStatus(l.status), H = {
269
- mmsi: l.m,
270
- name: l.n,
290
+ let k = -1;
291
+ const w = y(`${(N = M == null ? void 0 : M[0]) == null ? void 0 : N.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
292
+ for (const f of M) {
293
+ for (const x in f)
294
+ !isNaN(f[x]) && Number(f[x]) !== 1 / 0 && (f[x] = Number(f[x]));
295
+ const D = y(`${f.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
296
+ f.status = f.sp > 4 ? 0 : 1;
297
+ const { labelEn: _, labelCn: R } = this.parseStatus(f.status), H = {
298
+ mmsi: f.m,
299
+ name: f.n,
271
300
  imo: r == null ? void 0 : r.imo,
272
- lat: l.la,
273
- lng: l.lo,
274
- draught: l.draught,
275
- sog: l.sp,
276
- cog: l.co,
277
- hdg: l.hdg,
278
- positionTime: E.unix(),
279
- utc: E.utc().format(),
280
- status: l.status,
301
+ lat: f.la,
302
+ lng: f.lo,
303
+ draught: f.draught,
304
+ sog: f.sp,
305
+ cog: f.co,
306
+ hdg: f.hdg,
307
+ positionTime: D.unix(),
308
+ utc: D.utc().format(),
309
+ status: f.status,
281
310
  labelCn: R,
282
311
  labelEn: _,
283
312
  method: "trajectory",
284
313
  vendor: "hifleet"
285
- }, S = Math.floor(E.diff(w, "minute", !0) / (o || 1));
286
- S !== y && (y = S, v.push(H));
314
+ }, S = Math.floor(D.diff(w, "minute", !0) / (o || 1));
315
+ S !== k && (k = S, v.push(H));
287
316
  }
288
317
  return v;
289
318
  }
290
319
  }
291
- class Q extends V {
320
+ class st extends C {
292
321
  constructor(e) {
293
322
  super();
294
323
  q(this, "token");
@@ -305,9 +334,9 @@ class Q extends V {
305
334
  if (j.info("[%s] fetch realtime position from: %s - %j", n.requestId, o, a), (s == null ? void 0 : s.status) !== 0)
306
335
  return s;
307
336
  const t = s.data[0];
308
- for (const f in t)
309
- !isNaN(t[f]) && Number(t[f]) !== 1 / 0 && (t[f] = Number(t[f]));
310
- const { labelCn: r, labelEn: i } = await this.parseStatus(t.navistat), h = p.unix(t.lasttime);
337
+ for (const l in t)
338
+ !isNaN(t[l]) && Number(t[l]) !== 1 / 0 && (t[l] = Number(t[l]));
339
+ const { labelCn: r, labelEn: i } = await this.parseStatus(t.navistat), h = y.unix(t.lasttime);
311
340
  return {
312
341
  mmsi: t.ShipID,
313
342
  name: t.name,
@@ -333,7 +362,7 @@ class Q extends V {
333
362
  }
334
363
  async trajectory(e, n, a, o, s = !0, t = {}) {
335
364
  var w;
336
- const r = await this.realTimePosition(e, t), i = p(n), h = p(a), c = "https://api.shipxy.com/apicall/GetShipTrack", f = {
365
+ const r = await this.realTimePosition(e, t), i = y(n), h = y(a), c = "https://api.shipxy.com/apicall/GetShipTrack", l = {
337
366
  searchParams: {
338
367
  id: e,
339
368
  k: this.token,
@@ -342,13 +371,13 @@ class Q extends V {
342
371
  btm: i.unix(),
343
372
  etm: h.unix()
344
373
  }
345
- }, m = await Y.get(c, f).json();
346
- if (j.info("[%s] fetch trajectory from: %s - %j", t.requestId, c, f), (m == null ? void 0 : m.status) !== 0)
374
+ }, m = await Y.get(c, l).json();
375
+ if (j.info("[%s] fetch trajectory from: %s - %j", t.requestId, c, l), (m == null ? void 0 : m.status) !== 0)
347
376
  return m;
348
- const d = m == null ? void 0 : m.points, b = [], v = p.unix((w = d[0]) == null ? void 0 : w.utc);
349
- let y = -1;
377
+ const d = m == null ? void 0 : m.points, M = [], v = y.unix((w = d[0]) == null ? void 0 : w.utc);
378
+ let k = -1;
350
379
  for (const g of d) {
351
- const I = p.unix(g.utc), N = {
380
+ const I = y.unix(g.utc), N = {
352
381
  imo: r == null ? void 0 : r.imo,
353
382
  mmsi: e,
354
383
  sog: Math.round(g.sog * 3600 / 1e3 / 1852 * 100) / 100,
@@ -359,13 +388,13 @@ class Q extends V {
359
388
  utc: I.utc().format(),
360
389
  method: "trajectory",
361
390
  vendor: "shipxy"
362
- }, l = Math.floor(I.diff(v, "minute", !0) / (o || 1));
363
- l !== y && (y = l, b.push(N));
391
+ }, f = Math.floor(I.diff(v, "minute", !0) / (o || 1));
392
+ f !== k && (k = f, M.push(N));
364
393
  }
365
- return b;
394
+ return M;
366
395
  }
367
396
  }
368
- class X extends V {
397
+ class ot extends C {
369
398
  constructor(e) {
370
399
  super();
371
400
  q(this, "token");
@@ -418,7 +447,7 @@ class X extends V {
418
447
  const i = r.data[0];
419
448
  for (const d in i)
420
449
  !isNaN(i[d]) && Number(i[d]) !== 1 / 0 && (i[d] = Number(i[d]));
421
- const { labelCn: h, labelEn: c } = await this.parseStatus(i.aisNavStatus), f = p.unix(i.posTime);
450
+ const { labelCn: h, labelEn: c } = await this.parseStatus(i.aisNavStatus), l = y.unix(i.posTime);
422
451
  return {
423
452
  ...o,
424
453
  mmsi: e,
@@ -429,7 +458,7 @@ class X extends V {
429
458
  hdg: Math.round(i.heading * 100) / 100,
430
459
  rot: Math.round(i.rot * 100) / 100,
431
460
  positionTime: i.posTime,
432
- utc: f.utc().format(),
461
+ utc: l.utc().format(),
433
462
  status: i.aisNavStatus,
434
463
  labelEn: c,
435
464
  labelCn: h,
@@ -438,10 +467,10 @@ class X extends V {
438
467
  };
439
468
  }
440
469
  async trajectory(e, n, a, o, s = !0, t = {}) {
441
- const r = p(n), i = p(a), h = await this.getShipId(e), c = await this.getShipInfo(h), f = [];
470
+ const r = y(n), i = y(a), h = await this.getShipId(e), c = await this.getShipInfo(h), l = [];
442
471
  for (; i.diff(r, "day", !0) > 30; )
443
- await this.trajectoryIn30Day(h, r.unix(), r.add(30, "day").unix(), c, e, o, f);
444
- return await this.trajectoryIn30Day(h, r.unix(), i.unix(), c, e, o, f), f;
472
+ await this.trajectoryIn30Day(h, r.unix(), r.add(30, "day").unix(), c, e, o, l);
473
+ return await this.trajectoryIn30Day(h, r.unix(), i.unix(), c, e, o, l), l;
445
474
  }
446
475
  async trajectoryIn30Day(e, n, a, o, s, t, r, i = {}) {
447
476
  var v;
@@ -454,37 +483,37 @@ class X extends V {
454
483
  startTime: n,
455
484
  endTime: a
456
485
  }
457
- }, c = "https://api3.myships.com/sp/ships/position/history", f = await Y.post(c, h).json();
458
- if (j.info("[%s] fetch trajectory from: %s - %j", i.requestId, c, h), f.code !== "0")
459
- return j.warn("[%s] invoke myship trajectory failed: %j", i.requestId, f), f;
460
- const m = f.data;
461
- for (const y in m)
462
- !isNaN(m[y]) && Number(m[y]) !== 1 / 0 && (m[y] = Number(m[y]));
463
- const d = p.unix((v = m[0]) == null ? void 0 : v.posTime);
464
- let b = -1;
465
- for (const y of m) {
466
- const w = p.unix(y.posTime), g = {
486
+ }, c = "https://api3.myships.com/sp/ships/position/history", l = await Y.post(c, h).json();
487
+ if (j.info("[%s] fetch trajectory from: %s - %j", i.requestId, c, h), l.code !== "0")
488
+ return j.warn("[%s] invoke myship trajectory failed: %j", i.requestId, l), l;
489
+ const m = l.data;
490
+ for (const k in m)
491
+ !isNaN(m[k]) && Number(m[k]) !== 1 / 0 && (m[k] = Number(m[k]));
492
+ const d = y.unix((v = m[0]) == null ? void 0 : v.posTime);
493
+ let M = -1;
494
+ for (const k of m) {
495
+ const w = y.unix(k.posTime), g = {
467
496
  imo: o == null ? void 0 : o.imo,
468
497
  mmsi: s,
469
- lat: Math.round(y.lat / 1e4 / 60 * 1e5) / 1e5,
470
- lng: Math.round(y.lon / 1e4 / 60 * 1e5) / 1e5,
471
- sog: Math.round(y.sog / 10 * 100) / 100,
472
- cog: Math.round(y.cog / 10 * 100) / 100,
473
- hdg: Math.round(y.heading * 100) / 100,
474
- rot: Math.round(y.rot * 100) / 100,
498
+ lat: Math.round(k.lat / 1e4 / 60 * 1e5) / 1e5,
499
+ lng: Math.round(k.lon / 1e4 / 60 * 1e5) / 1e5,
500
+ sog: Math.round(k.sog / 10 * 100) / 100,
501
+ cog: Math.round(k.cog / 10 * 100) / 100,
502
+ hdg: Math.round(k.heading * 100) / 100,
503
+ rot: Math.round(k.rot * 100) / 100,
475
504
  positionTime: w.unix(),
476
505
  utc: w.utc().format(),
477
506
  method: "trajectory",
478
507
  vendor: "myship"
479
508
  }, I = Math.floor(w.diff(d, "minute", !0) / (t || 1));
480
- I !== b && (b = I, r.push(g));
509
+ I !== M && (M = I, r.push(g));
481
510
  }
482
511
  return r;
483
512
  }
484
513
  }
485
- const $ = W.getLogger();
486
- var K = /* @__PURE__ */ ((M) => (M.NOTICE = "NOTICE", M.WARN = "WARN", M.HEAVY = "HEAVY", M.SEVERE = "SEVERE", M.ERROR = "ERROR", M.FATAL = "FATAL", M))(K || {});
487
- class L {
514
+ const A = O.getLogger(__filename);
515
+ var U = /* @__PURE__ */ ((p) => (p.NOTICE = "NOTICE", p.WARN = "WARN", p.HEAVY = "HEAVY", p.SEVERE = "SEVERE", p.ERROR = "ERROR", p.FATAL = "FATAL", p))(U || {});
516
+ class J {
488
517
  /**
489
518
  * 解析告警规则, 多规则场景
490
519
  * @param rule
@@ -495,7 +524,7 @@ class L {
495
524
  */
496
525
  parsePrinciple(u, e = {}) {
497
526
  var t, r, i;
498
- $.info("[%s] parse rule: %s", e.requestId, u);
527
+ A.info("[%s] parse rule: %s", e.requestId, u);
499
528
  const n = new RegExp("(?<=\\[)(.+)(?=\\])", "g"), a = u.match(n) ? (t = u.match(n)) == null ? void 0 : t[0] : void 0, o = a == null ? void 0 : a.split(";");
500
529
  if (!o)
501
530
  return;
@@ -505,8 +534,8 @@ class L {
505
534
  if (h === 0 && !c)
506
535
  s.scope = o[0];
507
536
  else if (c)
508
- for (let f = 0, m = c.length; f < m; f++) {
509
- const d = this.parseRule(c[f]);
537
+ for (let l = 0, m = c.length; l < m; l++) {
538
+ const d = this.parseRule(c[l]);
510
539
  d && (s[d.level] ? d.key ? s[d.level][d == null ? void 0 : d.key] = d : s[d.level] = d : d.key ? s[d.level] = { [d == null ? void 0 : d.key]: d } : s[d.level] = d);
511
540
  }
512
541
  }
@@ -520,7 +549,7 @@ class L {
520
549
  */
521
550
  parseRule(u, e = {}) {
522
551
  var s;
523
- $.info("[%s] parse rule: %s", e.requestId, u), u = u.startsWith("[") ? u : `[${u}`, u = u.endsWith("]") ? u : `${u}]`;
552
+ A.info("[%s] parse rule: %s", e.requestId, u), u = u.startsWith("[") ? u : `[${u}`, u = u.endsWith("]") ? u : `${u}]`;
524
553
  const n = new RegExp("(?<=\\[)(.+?)(?=\\])", "g"), a = (s = u == null ? void 0 : u.match(n)) == null ? void 0 : s[0], o = a == null ? void 0 : a.split(",");
525
554
  if (o)
526
555
  return { operator: o[0], number: Number(o[1]), level: o[2], time: Number(o[3]), key: o[4] };
@@ -532,24 +561,24 @@ class L {
532
561
  * @param options
533
562
  */
534
563
  checkWeather(u, e, n = {}) {
535
- var d, b, v, y, w, g, I, N, l, E, _, R, H, S, x;
564
+ var d, M, v, k, w, g, I, N, f, D, _, R, H, S, x;
536
565
  let a = 0, o = 0, s = 0, t = 0;
537
- const r = Math.round(((b = (d = e == null ? void 0 : e.SEVERE) == null ? void 0 : d.sigWave) == null ? void 0 : b.number) * 1.6 * 100) / 100, i = (y = (v = e == null ? void 0 : e.SEVERE) == null ? void 0 : v.sigWave) == null ? void 0 : y.number, h = (g = (w = e == null ? void 0 : e.HEAVY) == null ? void 0 : w.sigWave) == null ? void 0 : g.number, c = Math.round((((N = (I = e == null ? void 0 : e.SEVERE) == null ? void 0 : I.wind) == null ? void 0 : N.number) + 2) * 100) / 100, f = (E = (l = e == null ? void 0 : e.SEVERE) == null ? void 0 : l.wind) == null ? void 0 : E.number, m = (R = (_ = e == null ? void 0 : e.HEAVY) == null ? void 0 : _.wind) == null ? void 0 : R.number;
538
- for (let A = 0; A < (u == null ? void 0 : u.length); A++) {
539
- const k = u[A], T = (S = (H = k == null ? void 0 : k.meteo) == null ? void 0 : H.wave) == null ? void 0 : S.sig, D = (x = k == null ? void 0 : k.meteo) == null ? void 0 : x.wind, P = A ? p(k.eta).diff(p(u[A - 1].eta), "hour", !0) : 0;
540
- t = P > t ? P : t, $.info("[%s] check sig.wave: %j", n.requestId, { ...T, dgThd4Wv: r, svThd4Wv: i, hvThd4Wv: h }), (T == null ? void 0 : T.height) >= r ? k.isDangerous = !0 : (T == null ? void 0 : T.height) >= i ? k.isSevere = !0 : (T == null ? void 0 : T.height) >= h && (k.isHeavy = !0), $.info("[%s] check wind: %j", n.requestId, { ...D, dgThd4Wd: c, svThd4Wd: f, hvThd4Wd: m }), (D == null ? void 0 : D.scale) >= c ? (k.isDangerous = !0, delete k.isSevere, delete k.isHeavy) : (D == null ? void 0 : D.scale) > f ? (k.isDangerous || (k.isSevere = !0), delete k.isHeavy) : (D == null ? void 0 : D.scale) === m && !k.isDangerous && !k.isSevere && (k.isHeavy = !0), a += k.isDangerous ? P : 0, o += k.isSevere ? P : 0, s += k.isHeavy ? P : 0;
566
+ const r = Math.round(((M = (d = e == null ? void 0 : e.SEVERE) == null ? void 0 : d.sigWave) == null ? void 0 : M.number) * 1.6 * 100) / 100, i = (k = (v = e == null ? void 0 : e.SEVERE) == null ? void 0 : v.sigWave) == null ? void 0 : k.number, h = (g = (w = e == null ? void 0 : e.HEAVY) == null ? void 0 : w.sigWave) == null ? void 0 : g.number, c = Math.round((((N = (I = e == null ? void 0 : e.SEVERE) == null ? void 0 : I.wind) == null ? void 0 : N.number) + 2) * 100) / 100, l = (D = (f = e == null ? void 0 : e.SEVERE) == null ? void 0 : f.wind) == null ? void 0 : D.number, m = (R = (_ = e == null ? void 0 : e.HEAVY) == null ? void 0 : _.wind) == null ? void 0 : R.number;
567
+ for (let $ = 0; $ < (u == null ? void 0 : u.length); $++) {
568
+ const b = u[$], T = (S = (H = b == null ? void 0 : b.meteo) == null ? void 0 : H.wave) == null ? void 0 : S.sig, E = (x = b == null ? void 0 : b.meteo) == null ? void 0 : x.wind, P = $ ? y(b.eta).diff(y(u[$ - 1].eta), "hour", !0) : 0;
569
+ t = P > t ? P : t, A.info("[%s] check sig.wave: %j", n.requestId, { ...T, dgThd4Wv: r, svThd4Wv: i, hvThd4Wv: h }), (T == null ? void 0 : T.height) >= r ? b.isDangerous = !0 : (T == null ? void 0 : T.height) >= i ? b.isSevere = !0 : (T == null ? void 0 : T.height) >= h && (b.isHeavy = !0), A.info("[%s] check wind: %j", n.requestId, { ...E, dgThd4Wd: c, svThd4Wd: l, hvThd4Wd: m }), (E == null ? void 0 : E.scale) >= c ? (b.isDangerous = !0, delete b.isSevere, delete b.isHeavy) : (E == null ? void 0 : E.scale) > l ? (b.isDangerous || (b.isSevere = !0), delete b.isHeavy) : (E == null ? void 0 : E.scale) === m && !b.isDangerous && !b.isSevere && (b.isHeavy = !0), a += b.isDangerous ? P : 0, o += b.isSevere ? P : 0, s += b.isHeavy ? P : 0;
541
570
  }
542
- return a = Math.round(a * 100) / 100, o = Math.round(o * 100) / 100, s = Math.round(s * 100) / 100, t = Math.round(t), { sample: u, dangerous: a, severe: o, heavy: s, step: t < 3 ? 3 : t, wind: { dgThd4Wd: c, svThd4Wd: f, hvThd4Wd: m }, sig: { dgThd4Wv: r, svThd4Wv: i, hvThd4Wv: h } };
571
+ return a = Math.round(a * 100) / 100, o = Math.round(o * 100) / 100, s = Math.round(s * 100) / 100, t = Math.round(t), { sample: u, dangerous: a, severe: o, heavy: s, step: t < 3 ? 3 : t, wind: { dgThd4Wd: c, svThd4Wd: l, hvThd4Wd: m }, sig: { dgThd4Wv: r, svThd4Wv: i, hvThd4Wv: h } };
543
572
  }
544
573
  }
545
- const Z = new L();
574
+ const nt = new J();
546
575
  export {
547
- V as AISImpl,
548
- L as AlertHelper,
549
- K as AlertLevel,
550
- J as HifleetImpl,
551
- X as MyShipImpl,
552
- U as MyVesselImpl,
553
- Q as ShipxyImpl,
554
- Z as alertHelper
576
+ C as AISImpl,
577
+ J as AlertHelper,
578
+ U as AlertLevel,
579
+ et as HifleetImpl,
580
+ ot as MyShipImpl,
581
+ tt as MyVesselImpl,
582
+ st as ShipxyImpl,
583
+ nt as alertHelper
555
584
  };
@@ -1 +1 @@
1
- (function(j,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("got"),require("@log4js-node/log4js-api"),require("moment")):typeof define=="function"&&define.amd?define(["exports","got","@log4js-node/log4js-api","moment"],y):(j=typeof globalThis<"u"?globalThis:j||self,y(j["idm-plugin-rabbitmq"]={},j.got,j["@log4js-node/log4js-api"],j.moment))})(this,function(j,y,E,g){"use strict";var U=Object.defineProperty;var J=(j,y,E)=>y in j?U(j,y,{enumerable:!0,configurable:!0,writable:!0,value:E}):j[y]=E;var A=(j,y,E)=>(J(j,typeof y!="symbol"?y+"":y,E),E);const I=E.getLogger();class V{parseStatus(p){let e,a;switch(p){case 0:e="在航(主机推动)",a="The engine is in use";break;case 1:e="锚泊",a="Anchored";break;case 2:e="失控",a="Not operated";break;case 3:e="操纵受限",a="Limited airworthiness";break;case 4:e="吃水受限",a="Limited by ship's draft";break;case 5:e="靠泊",a="Mooring";break;case 6:e="搁浅",a="Stranded";break;case 7:e="捕捞作业",a="Engaged in fishing";break;case 8:e="靠帆船提供动力",a="Sailing";break;default:e="未定义",a="Undefined"}return{labelCn:e,labelEn:a}}}class L extends V{constructor(e,a){super();A(this,"clientId");A(this,"clientSecret");A(this,"token");this.clientId=e,this.clientSecret=a}async authToken(e={}){const a="https://svc.data.myvessel.cn/ada/oauth/token",n={searchParams:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}},o=await y.post(a,n).json();I.info("[%s] fetch access token from: %s - %j",e.requestId,a,o),o.error||(this.token={accessToken:o.access_token,tokenType:o.token_type,expiresIn:o.expires_in,scope:o.scope,jti:o.jti,issuedAt:g().utc().format()})}async realTimePosition(e,a={}){var d,c,l;(!this.token||g().diff(g(this.token.issuedAt),"seconds")>((d=this.token)==null?void 0:d.expiresIn)-300)&&await this.authToken(a);const n="https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit",o={headers:{Authorization:`${(c=this.token)==null?void 0:c.tokenType} ${(l=this.token)==null?void 0:l.accessToken}`},searchParams:{mmsi:e}};I.info("[%s] fetch realtime position from: %s - %j",a.requestId,n,o);const s=await y.get(n,o).json();if(s.code)return I.warn("[%s] fetch realtime position failed: %j",a.requestId,n,{message:s.message,status:s.status,code:s.code}),s;const t=s.data;for(const u in t)!isNaN(t[u])&&Number(t[u])!==1/0&&(t[u]=Number(t[u]));const r=g(`${t.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:t.mmsi,name:t.vesselName,imo:t.imo,callSign:t.callsign,lat:t.lat,lng:t.lon,length:t.length,width:t.width,draught:t.currDraught,sog:t.sog,cog:t.cog,hdg:t.hdg,rot:t.rot,eta:t.eta,destination:t.dest,positionTime:r.unix(),status:t.status,labelCn:t.statusNameCn,labelEn:t.statusNameEn,method:"position",vendor:"myVessel",utc:r.utc().format()}}async trajectory(e,a,n,o,s=!0,t={}){(!this.token||g().diff(g(this.token.issuedAt),"seconds")>this.token.expiresIn-300)&&await this.authToken(t);const r=await this.realTimePosition(e,t),i=g(a),d=g(n),c=[];for(;d.diff(i,"day",!0)>30;)await this.trajectoryIn30Day(e,i,i.clone().add(30,"day"),r,o,c,t),i.add(30,"day");return await this.trajectoryIn30Day(e,i,d,r,o,c,t),c}async trajectoryIn30Day(e,a,n,o,s,t,r={}){var h,b,Y,k,w;const i="https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",d={headers:{Authorization:`${(h=this.token)==null?void 0:h.tokenType} ${(b=this.token)==null?void 0:b.accessToken}`},json:{mmsi:e,startTime:a.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),endTime:n.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")}};I.info("[%s] fetch trajectory from: %s - %j",r.requestId,i,d);const c=await y.post(i,d).json();if(c.code)return I.warn("[%s] fetch trajectory failed: %j",r.requestId,i,{message:c.message,status:c.status,code:c.code}),c;let l=-1;const u=g(`${(k=(Y=c.data)==null?void 0:Y[0])==null?void 0:k.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return(w=c.data)==null||w.forEach(m=>{for(const T in m)!isNaN(m[T])&&Number(m[T])!==1/0&&(m[T]=Number(m[T]));const v=g(`${m.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"),N=m.eta?g(`${m.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"):void 0,f=m.status,{labelCn:q,labelEn:R}=this.parseStatus(f),P={mmsi:m.mmsi,imo:o==null?void 0:o.imo,lat:m.lat,lng:m.lon,sog:m.sog,cog:m.cog,hdg:m.hdg,draught:m.draught,status:f,eta:N==null?void 0:N.unix(),destination:m.dest,positionTime:v.unix(),labelCn:q,labelEn:R,method:"trajectory",vendor:"myVessel",utc:v.utc().format()},x=Math.floor(v.diff(u,"minute",!0)/(s||1));x!==l&&(l=x,t.push(P))}),t}}class z extends V{constructor(e){super();A(this,"token");this.token=e}async realTimePosition(e,a={}){const n="https://api.hifleet.com/position/position/get/token",o={searchParams:{mmsi:e,usertoken:this.token}},s=await y.post(n,o).json();I.info("[%s] fetch realtime position from: %s - %j",a.requestId,n,o);const t=s==null?void 0:s.list;if(!t)return I.warn("[%s] fetch realtime position failed: %j",a.requestId,n,s),s;for(const u in t)!isNaN(t[u])&&Number(t[u])!==1/0&&(t[u]=Number(t[u]));t.status=t.sp>3?0:1;const r=t.status,{labelCn:i,labelEn:d}=this.parseStatus(r),c=g(`${t.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:t.m,name:t.n,imo:t.imonumber,callSign:t.callsign,lat:Math.round(t.la/60*1e5)/1e5,lng:Math.round(t.lo/60*1e5)/1e5,length:t.l,width:t.w,draught:t.draught,sog:t.sp,cog:t.co,hdg:t.h,rot:isNaN(t.rot)?0:t.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(t.eta)?g(`${t.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00").unix():void 0,destination:t.destination,positionTime:c.unix(),utc:c.utc().format(),status:r,labelCn:i,labelEn:d,method:"position",vendor:"hifleet"}}async search(e,a={}){let n="https://www.hifleet.com/hifleetapi/searchVesselOL.do";const o={searchParams:{keyword:e},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}};let s=await y.post(n,o).json();I.info("[%s] fetch vessel props from: %s - %j",a.requestId,n,o),s instanceof Array&&(s=s[0]);for(const r in s)!isNaN(s[r])&&Number(s[r])!==1/0&&(s[r]=Number(s[r]));const t={mmsi:s.m,name:s.n,imo:s.i,callSign:s.c,length:s.l,breadth:s.b,draught:s.dr};return n="https://www.hifleet.com/hifleetapi/sameShipSearch.do",s=await y.post(n,o).json(),I.info("[%s] fetch vessel dead weight from: %s - %j",a.requestId,n,o),s instanceof Array&&(s=s[0]),s&&(t.deadweight=Number(s.dwt)),t}async trajectory(e,a,n,o,s=!0,t={}){var m,v,N;const r=await this.realTimePosition(e,t);let i=g(a);const d=g(n),c=g();if(s){let f=d.diff(i,"d",!0);f<0?i=d.clone().subtract(40,"d"):f<30?i.subtract(10,"d"):f<60?i.subtract(5,"d"):i=d.clone().subtract(80,"d"),f=c.diff(d,"d",!0),d.add(f>10?240:f*24,"h")}const l={searchParams:{endtime:d.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),starttime:i.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),mmsi:e,usertoken:this.token}},u="https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token",h=await y.get(u,l).json();I.info("[%s] fetch trajectory from: %s - %j",t.requestId,u,l);let b;h&&(b=((v=(m=h.ships)==null?void 0:m.offors)==null?void 0:v.ship)||[],b.length||I.warn("[%s] fetch trajectory failed: %j",t.requestId,h));const Y=[];let k=-1;const w=g(`${(N=b==null?void 0:b[0])==null?void 0:N.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");for(const f of b){for(const _ in f)!isNaN(f[_])&&Number(f[_])!==1/0&&(f[_]=Number(f[_]));const q=g(`${f.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");f.status=f.sp>4?0:1;const{labelEn:R,labelCn:P}=this.parseStatus(f.status),x={mmsi:f.m,name:f.n,imo:r==null?void 0:r.imo,lat:f.la,lng:f.lo,draught:f.draught,sog:f.sp,cog:f.co,hdg:f.hdg,positionTime:q.unix(),utc:q.utc().format(),status:f.status,labelCn:P,labelEn:R,method:"trajectory",vendor:"hifleet"},T=Math.floor(q.diff(w,"minute",!0)/(o||1));T!==k&&(k=T,Y.push(x))}return Y}}class F extends V{constructor(e){super();A(this,"token");this.token=e}async realTimePosition(e,a={}){const n={searchParams:{id:e,k:this.token,enc:1}},o="https://api.shipxy.com/apicall/GetSingleShip",s=await y.get(o,n).json();if(I.info("[%s] fetch realtime position from: %s - %j",a.requestId,o,n),(s==null?void 0:s.status)!==0)return s;const t=s.data[0];for(const l in t)!isNaN(t[l])&&Number(t[l])!==1/0&&(t[l]=Number(t[l]));const{labelCn:r,labelEn:i}=await this.parseStatus(t.navistat),d=g.unix(t.lasttime);return{mmsi:t.ShipID,name:t.name,imo:t.imo,callSign:t.callsign,lat:Math.round(t.lat/1e6*1e5)/1e5,lng:Math.round(t.lon/1e6*1e5)/1e5,length:Math.round(t.length/10*100)/100,width:Math.round(t.width/10*100)/100,draught:Math.round(t.draught/1e3*100)/100,sog:Math.round(t.sog*3600/1e3/1852*100)/100,cog:Math.round(t.cog/100*100)/100,hdg:Math.round(t.hdg/100*100)/100,rot:Math.round(t.rot/100*100)/100,positionTime:t.lasttime,utc:d.utc().format(),status:t.navistat,labelEn:i,labelCn:r,method:"position",vendor:"shipxy"}}async trajectory(e,a,n,o,s=!0,t={}){var w;const r=await this.realTimePosition(e,t),i=g(a),d=g(n),c="https://api.shipxy.com/apicall/GetShipTrack",l={searchParams:{id:e,k:this.token,enc:1,cut:0,btm:i.unix(),etm:d.unix()}},u=await y.get(c,l).json();if(I.info("[%s] fetch trajectory from: %s - %j",t.requestId,c,l),(u==null?void 0:u.status)!==0)return u;const h=u==null?void 0:u.points,b=[],Y=g.unix((w=h[0])==null?void 0:w.utc);let k=-1;for(const m of h){const v=g.unix(m.utc),N={imo:r==null?void 0:r.imo,mmsi:e,sog:Math.round(m.sog*3600/1e3/1852*100)/100,cog:Math.round(m.cog/100*100)/100,lat:Math.round(m.lat/1e6*1e5)/1e5,lng:Math.round(m.lon/1e6*1e5)/1e5,positionTime:v.unix(),utc:v.utc().format(),method:"trajectory",vendor:"shipxy"},f=Math.floor(v.diff(Y,"minute",!0)/(o||1));f!==k&&(k=f,b.push(N))}return b}}class G extends V{constructor(e){super();A(this,"token");this.token=e}async getShipId(e,a={}){const n={headers:{appKey:this.token},json:{mmsiList:e}},o="https://api3.myships.com/sp/ships/getShipIdByMMSI",s=await y.post(o,n).json();return I.info("[%s] fetch ship id from: %s - %j",a.requestId,o,n),s.code!=="0"?s:s.data[0].shipId}async getShipInfo(e,a={}){const n={headers:{appKey:this.token},json:{shipId:e}},o="https://api3.myships.com/sp/ships/aissta",s=await y.post(o,n).json();if(I.info("[%s] fetch ship info from: %s - %j",a.requestId,o,n),s.code!=="0")return s;const t=s.data;let r=t.imo;return e==="407170"&&(r="9198379",I.warn("[%s] ship(%s) imo error: %s, should be %s",a.requestId,e,t.imo,r)),{mmsi:t.mmsi,name:t.shipnameEn,imo:r,callSign:t.callSign,length:t.length,width:t.breadth,draught:(t.draught||100)/10}}async realTimePosition(e,a={}){const n=await this.getShipId(e,a),o=await this.getShipInfo(n,a),s={headers:{appKey:this.token},json:{shipId:n}},t="https://api3.myships.com/sp/ships/position/latest",r=await y.post(t,s).json();I.info("[%s] fetch realtime position from: %s - %j",a.requestId,t,s);const i=r.data[0];for(const h in i)!isNaN(i[h])&&Number(i[h])!==1/0&&(i[h]=Number(i[h]));const{labelCn:d,labelEn:c}=await this.parseStatus(i.aisNavStatus),l=g.unix(i.posTime);return{...o,mmsi:e,lat:Math.round(i.lat/1e4/60*1e5)/1e5,lng:Math.round(i.lon/1e4/60*1e5)/1e5,sog:Math.round(i.sog/10*100)/100,cog:Math.round(i.cog/10*100)/100,hdg:Math.round(i.heading*100)/100,rot:Math.round(i.rot*100)/100,positionTime:i.posTime,utc:l.utc().format(),status:i.aisNavStatus,labelEn:c,labelCn:d,method:"position",vendor:"myship"}}async trajectory(e,a,n,o,s=!0,t={}){const r=g(a),i=g(n),d=await this.getShipId(e),c=await this.getShipInfo(d),l=[];for(;i.diff(r,"day",!0)>30;)await this.trajectoryIn30Day(d,r.unix(),r.add(30,"day").unix(),c,e,o,l);return await this.trajectoryIn30Day(d,r.unix(),i.unix(),c,e,o,l),l}async trajectoryIn30Day(e,a,n,o,s,t,r,i={}){var Y;const d={headers:{appKey:this.token},json:{shipId:e,startTime:a,endTime:n}},c="https://api3.myships.com/sp/ships/position/history",l=await y.post(c,d).json();if(I.info("[%s] fetch trajectory from: %s - %j",i.requestId,c,d),l.code!=="0")return I.warn("[%s] invoke myship trajectory failed: %j",i.requestId,l),l;const u=l.data;for(const k in u)!isNaN(u[k])&&Number(u[k])!==1/0&&(u[k]=Number(u[k]));const h=g.unix((Y=u[0])==null?void 0:Y.posTime);let b=-1;for(const k of u){const w=g.unix(k.posTime),m={imo:o==null?void 0:o.imo,mmsi:s,lat:Math.round(k.lat/1e4/60*1e5)/1e5,lng:Math.round(k.lon/1e4/60*1e5)/1e5,sog:Math.round(k.sog/10*100)/100,cog:Math.round(k.cog/10*100)/100,hdg:Math.round(k.heading*100)/100,rot:Math.round(k.rot*100)/100,positionTime:w.unix(),utc:w.utc().format(),method:"trajectory",vendor:"myship"},v=Math.floor(w.diff(h,"minute",!0)/(t||1));v!==b&&(b=v,r.push(m))}return r}}const O=E.getLogger();var C=(S=>(S.NOTICE="NOTICE",S.WARN="WARN",S.HEAVY="HEAVY",S.SEVERE="SEVERE",S.ERROR="ERROR",S.FATAL="FATAL",S))(C||{});class K{parsePrinciple(p,e={}){var t,r,i;O.info("[%s] parse rule: %s",e.requestId,p);const a=new RegExp("(?<=\\[)(.+)(?=\\])","g"),n=p.match(a)?(t=p.match(a))==null?void 0:t[0]:void 0,o=n==null?void 0:n.split(";");if(!o)return;const s={};for(let d=0;d<(o==null?void 0:o.length);d++){const c=(i=(r=o[d].match(a))==null?void 0:r[0])==null?void 0:i.split("],");if(d===0&&!c)s.scope=o[0];else if(c)for(let l=0,u=c.length;l<u;l++){const h=this.parseRule(c[l]);h&&(s[h.level]?h.key?s[h.level][h==null?void 0:h.key]=h:s[h.level]=h:h.key?s[h.level]={[h==null?void 0:h.key]:h}:s[h.level]=h)}}return s}parseRule(p,e={}){var s;O.info("[%s] parse rule: %s",e.requestId,p),p=p.startsWith("[")?p:`[${p}`,p=p.endsWith("]")?p:`${p}]`;const a=new RegExp("(?<=\\[)(.+?)(?=\\])","g"),n=(s=p==null?void 0:p.match(a))==null?void 0:s[0],o=n==null?void 0:n.split(",");if(o)return{operator:o[0],number:Number(o[1]),level:o[2],time:Number(o[3]),key:o[4]}}checkWeather(p,e,a={}){var h,b,Y,k,w,m,v,N,f,q,R,P,x,T,_;let n=0,o=0,s=0,t=0;const r=Math.round(((b=(h=e==null?void 0:e.SEVERE)==null?void 0:h.sigWave)==null?void 0:b.number)*1.6*100)/100,i=(k=(Y=e==null?void 0:e.SEVERE)==null?void 0:Y.sigWave)==null?void 0:k.number,d=(m=(w=e==null?void 0:e.HEAVY)==null?void 0:w.sigWave)==null?void 0:m.number,c=Math.round((((N=(v=e==null?void 0:e.SEVERE)==null?void 0:v.wind)==null?void 0:N.number)+2)*100)/100,l=(q=(f=e==null?void 0:e.SEVERE)==null?void 0:f.wind)==null?void 0:q.number,u=(P=(R=e==null?void 0:e.HEAVY)==null?void 0:R.wind)==null?void 0:P.number;for(let $=0;$<(p==null?void 0:p.length);$++){const M=p[$],H=(T=(x=M==null?void 0:M.meteo)==null?void 0:x.wave)==null?void 0:T.sig,D=(_=M==null?void 0:M.meteo)==null?void 0:_.wind,W=$?g(M.eta).diff(g(p[$-1].eta),"hour",!0):0;t=W>t?W:t,O.info("[%s] check sig.wave: %j",a.requestId,{...H,dgThd4Wv:r,svThd4Wv:i,hvThd4Wv:d}),(H==null?void 0:H.height)>=r?M.isDangerous=!0:(H==null?void 0:H.height)>=i?M.isSevere=!0:(H==null?void 0:H.height)>=d&&(M.isHeavy=!0),O.info("[%s] check wind: %j",a.requestId,{...D,dgThd4Wd:c,svThd4Wd:l,hvThd4Wd:u}),(D==null?void 0:D.scale)>=c?(M.isDangerous=!0,delete M.isSevere,delete M.isHeavy):(D==null?void 0:D.scale)>l?(M.isDangerous||(M.isSevere=!0),delete M.isHeavy):(D==null?void 0:D.scale)===u&&!M.isDangerous&&!M.isSevere&&(M.isHeavy=!0),n+=M.isDangerous?W:0,o+=M.isSevere?W:0,s+=M.isHeavy?W:0}return n=Math.round(n*100)/100,o=Math.round(o*100)/100,s=Math.round(s*100)/100,t=Math.round(t),{sample:p,dangerous:n,severe:o,heavy:s,step:t<3?3:t,wind:{dgThd4Wd:c,svThd4Wd:l,hvThd4Wd:u},sig:{dgThd4Wv:r,svThd4Wv:i,hvThd4Wv:d}}}}const B=new K;j.AISImpl=V,j.AlertHelper=K,j.AlertLevel=C,j.HifleetImpl=z,j.MyShipImpl=G,j.MyVesselImpl=L,j.ShipxyImpl=F,j.alertHelper=B,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
1
+ (function(M,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("got"),require("moment")):typeof define=="function"&&define.amd?define(["exports","got","moment"],y):(M=typeof globalThis<"u"?globalThis:M||self,y(M["idm-plugin-rabbitmq"]={},M.got,M.moment))})(this,function(M,y,l){"use strict";var Z=Object.defineProperty;var tt=(M,y,l)=>y in M?Z(M,y,{enumerable:!0,configurable:!0,writable:!0,value:l}):M[y]=l;var _=(M,y,l)=>(tt(M,typeof y!="symbol"?y+"":y,l),l);function z(k){return k&&k.__esModule&&Object.prototype.hasOwnProperty.call(k,"default")?k.default:k}class W{log(){}isLevelEnabled(){return!1}addContext(){}removeContext(){}clearContext(){}}["Trace","Debug","Info","Warn","Error","Fatal","Mark"].forEach(k=>{W.prototype[k.toLowerCase()]=()=>{},W.prototype[`is${k}Enabled`]=()=>!1});const O=(()=>{try{return require("log4js")}catch{return null}})();var G={getLogger:O?O.getLogger:()=>new W};const L=z(G),I=L.getLogger();class R{parseStatus(p){let e,a;switch(p){case 0:e="在航(主机推动)",a="The engine is in use";break;case 1:e="锚泊",a="Anchored";break;case 2:e="失控",a="Not operated";break;case 3:e="操纵受限",a="Limited airworthiness";break;case 4:e="吃水受限",a="Limited by ship's draft";break;case 5:e="靠泊",a="Mooring";break;case 6:e="搁浅",a="Stranded";break;case 7:e="捕捞作业",a="Engaged in fishing";break;case 8:e="靠帆船提供动力",a="Sailing";break;default:e="未定义",a="Undefined"}return{labelCn:e,labelEn:a}}}class B extends R{constructor(e,a){super();_(this,"clientId");_(this,"clientSecret");_(this,"token");this.clientId=e,this.clientSecret=a}async authToken(e={}){const a="https://svc.data.myvessel.cn/ada/oauth/token",n={searchParams:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}},o=await y.post(a,n).json();I.info("[%s] fetch access token from: %s - %j",e.requestId,a,o),o.error||(this.token={accessToken:o.access_token,tokenType:o.token_type,expiresIn:o.expires_in,scope:o.scope,jti:o.jti,issuedAt:l().utc().format()})}async realTimePosition(e,a={}){var d,c,f;(!this.token||l().diff(l(this.token.issuedAt),"seconds")>((d=this.token)==null?void 0:d.expiresIn)-300)&&await this.authToken(a);const n="https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit",o={headers:{Authorization:`${(c=this.token)==null?void 0:c.tokenType} ${(f=this.token)==null?void 0:f.accessToken}`},searchParams:{mmsi:e}};I.info("[%s] fetch realtime position from: %s - %j",a.requestId,n,o);const s=await y.get(n,o).json();if(s.code)return I.warn("[%s] fetch realtime position failed: %j",a.requestId,n,{message:s.message,status:s.status,code:s.code}),s;const t=s.data;for(const u in t)!isNaN(t[u])&&Number(t[u])!==1/0&&(t[u]=Number(t[u]));const r=l(`${t.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:t.mmsi,name:t.vesselName,imo:t.imo,callSign:t.callsign,lat:t.lat,lng:t.lon,length:t.length,width:t.width,draught:t.currDraught,sog:t.sog,cog:t.cog,hdg:t.hdg,rot:t.rot,eta:t.eta,destination:t.dest,positionTime:r.unix(),status:t.status,labelCn:t.statusNameCn,labelEn:t.statusNameEn,method:"position",vendor:"myVessel",utc:r.utc().format()}}async trajectory(e,a,n,o,s=!0,t={}){(!this.token||l().diff(l(this.token.issuedAt),"seconds")>this.token.expiresIn-300)&&await this.authToken(t);const r=await this.realTimePosition(e,t),i=l(a),d=l(n),c=[];for(;d.diff(i,"day",!0)>30;)await this.trajectoryIn30Day(e,i,i.clone().add(30,"day"),r,o,c,t),i.add(30,"day");return await this.trajectoryIn30Day(e,i,d,r,o,c,t),c}async trajectoryIn30Day(e,a,n,o,s,t,r={}){var h,w,Y,j,S;const i="https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",d={headers:{Authorization:`${(h=this.token)==null?void 0:h.tokenType} ${(w=this.token)==null?void 0:w.accessToken}`},json:{mmsi:e,startTime:a.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),endTime:n.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")}};I.info("[%s] fetch trajectory from: %s - %j",r.requestId,i,d);const c=await y.post(i,d).json();if(c.code)return I.warn("[%s] fetch trajectory failed: %j",r.requestId,i,{message:c.message,status:c.status,code:c.code}),c;let f=-1;const u=l(`${(j=(Y=c.data)==null?void 0:Y[0])==null?void 0:j.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return(S=c.data)==null||S.forEach(g=>{for(const N in g)!isNaN(g[N])&&Number(g[N])!==1/0&&(g[N]=Number(g[N]));const v=l(`${g.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"),T=g.eta?l(`${g.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"):void 0,m=g.status,{labelCn:D,labelEn:A}=this.parseStatus(m),P={mmsi:g.mmsi,imo:o==null?void 0:o.imo,lat:g.lat,lng:g.lon,sog:g.sog,cog:g.cog,hdg:g.hdg,draught:g.draught,status:m,eta:T==null?void 0:T.unix(),destination:g.dest,positionTime:v.unix(),labelCn:D,labelEn:A,method:"trajectory",vendor:"myVessel",utc:v.utc().format()},q=Math.floor(v.diff(u,"minute",!0)/(s||1));q!==f&&(f=q,t.push(P))}),t}}class U extends R{constructor(e){super();_(this,"token");this.token=e}async realTimePosition(e,a={}){const n="https://api.hifleet.com/position/position/get/token",o={searchParams:{mmsi:e,usertoken:this.token}},s=await y.post(n,o).json();I.info("[%s] fetch realtime position from: %s - %j",a.requestId,n,o);const t=s==null?void 0:s.list;if(!t)return I.warn("[%s] fetch realtime position failed: %j",a.requestId,n,s),s;for(const u in t)!isNaN(t[u])&&Number(t[u])!==1/0&&(t[u]=Number(t[u]));t.status=t.sp>3?0:1;const r=t.status,{labelCn:i,labelEn:d}=this.parseStatus(r),c=l(`${t.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:t.m,name:t.n,imo:t.imonumber,callSign:t.callsign,lat:Math.round(t.la/60*1e5)/1e5,lng:Math.round(t.lo/60*1e5)/1e5,length:t.l,width:t.w,draught:t.draught,sog:t.sp,cog:t.co,hdg:t.h,rot:isNaN(t.rot)?0:t.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(t.eta)?l(`${t.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00").unix():void 0,destination:t.destination,positionTime:c.unix(),utc:c.utc().format(),status:r,labelCn:i,labelEn:d,method:"position",vendor:"hifleet"}}async search(e,a={}){let n="https://www.hifleet.com/hifleetapi/searchVesselOL.do";const o={searchParams:{keyword:e},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}};let s=await y.post(n,o).json();I.info("[%s] fetch vessel props from: %s - %j",a.requestId,n,o),s instanceof Array&&(s=s[0]);for(const r in s)!isNaN(s[r])&&Number(s[r])!==1/0&&(s[r]=Number(s[r]));const t={mmsi:s.m,name:s.n,imo:s.i,callSign:s.c,length:s.l,breadth:s.b,draught:s.dr};return n="https://www.hifleet.com/hifleetapi/sameShipSearch.do",s=await y.post(n,o).json(),I.info("[%s] fetch vessel dead weight from: %s - %j",a.requestId,n,o),s instanceof Array&&(s=s[0]),s&&(t.deadweight=Number(s.dwt)),t}async trajectory(e,a,n,o,s=!0,t={}){var g,v,T;const r=await this.realTimePosition(e,t);let i=l(a);const d=l(n),c=l();if(s){let m=d.diff(i,"d",!0);m<0?i=d.clone().subtract(40,"d"):m<30?i.subtract(10,"d"):m<60?i.subtract(5,"d"):i=d.clone().subtract(80,"d"),m=c.diff(d,"d",!0),d.add(m>10?240:m*24,"h")}const f={searchParams:{endtime:d.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),starttime:i.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),mmsi:e,usertoken:this.token}},u="https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token",h=await y.get(u,f).json();I.info("[%s] fetch trajectory from: %s - %j",t.requestId,u,f);let w;h&&(w=((v=(g=h.ships)==null?void 0:g.offors)==null?void 0:v.ship)||[],w.length||I.warn("[%s] fetch trajectory failed: %j",t.requestId,h));const Y=[];let j=-1;const S=l(`${(T=w==null?void 0:w[0])==null?void 0:T.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");for(const m of w){for(const x in m)!isNaN(m[x])&&Number(m[x])!==1/0&&(m[x]=Number(m[x]));const D=l(`${m.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");m.status=m.sp>4?0:1;const{labelEn:A,labelCn:P}=this.parseStatus(m.status),q={mmsi:m.m,name:m.n,imo:r==null?void 0:r.imo,lat:m.la,lng:m.lo,draught:m.draught,sog:m.sp,cog:m.co,hdg:m.hdg,positionTime:D.unix(),utc:D.utc().format(),status:m.status,labelCn:P,labelEn:A,method:"trajectory",vendor:"hifleet"},N=Math.floor(D.diff(S,"minute",!0)/(o||1));N!==j&&(j=N,Y.push(q))}return Y}}class J extends R{constructor(e){super();_(this,"token");this.token=e}async realTimePosition(e,a={}){const n={searchParams:{id:e,k:this.token,enc:1}},o="https://api.shipxy.com/apicall/GetSingleShip",s=await y.get(o,n).json();if(I.info("[%s] fetch realtime position from: %s - %j",a.requestId,o,n),(s==null?void 0:s.status)!==0)return s;const t=s.data[0];for(const f in t)!isNaN(t[f])&&Number(t[f])!==1/0&&(t[f]=Number(t[f]));const{labelCn:r,labelEn:i}=await this.parseStatus(t.navistat),d=l.unix(t.lasttime);return{mmsi:t.ShipID,name:t.name,imo:t.imo,callSign:t.callsign,lat:Math.round(t.lat/1e6*1e5)/1e5,lng:Math.round(t.lon/1e6*1e5)/1e5,length:Math.round(t.length/10*100)/100,width:Math.round(t.width/10*100)/100,draught:Math.round(t.draught/1e3*100)/100,sog:Math.round(t.sog*3600/1e3/1852*100)/100,cog:Math.round(t.cog/100*100)/100,hdg:Math.round(t.hdg/100*100)/100,rot:Math.round(t.rot/100*100)/100,positionTime:t.lasttime,utc:d.utc().format(),status:t.navistat,labelEn:i,labelCn:r,method:"position",vendor:"shipxy"}}async trajectory(e,a,n,o,s=!0,t={}){var S;const r=await this.realTimePosition(e,t),i=l(a),d=l(n),c="https://api.shipxy.com/apicall/GetShipTrack",f={searchParams:{id:e,k:this.token,enc:1,cut:0,btm:i.unix(),etm:d.unix()}},u=await y.get(c,f).json();if(I.info("[%s] fetch trajectory from: %s - %j",t.requestId,c,f),(u==null?void 0:u.status)!==0)return u;const h=u==null?void 0:u.points,w=[],Y=l.unix((S=h[0])==null?void 0:S.utc);let j=-1;for(const g of h){const v=l.unix(g.utc),T={imo:r==null?void 0:r.imo,mmsi:e,sog:Math.round(g.sog*3600/1e3/1852*100)/100,cog:Math.round(g.cog/100*100)/100,lat:Math.round(g.lat/1e6*1e5)/1e5,lng:Math.round(g.lon/1e6*1e5)/1e5,positionTime:v.unix(),utc:v.utc().format(),method:"trajectory",vendor:"shipxy"},m=Math.floor(v.diff(Y,"minute",!0)/(o||1));m!==j&&(j=m,w.push(T))}return w}}class Q extends R{constructor(e){super();_(this,"token");this.token=e}async getShipId(e,a={}){const n={headers:{appKey:this.token},json:{mmsiList:e}},o="https://api3.myships.com/sp/ships/getShipIdByMMSI",s=await y.post(o,n).json();return I.info("[%s] fetch ship id from: %s - %j",a.requestId,o,n),s.code!=="0"?s:s.data[0].shipId}async getShipInfo(e,a={}){const n={headers:{appKey:this.token},json:{shipId:e}},o="https://api3.myships.com/sp/ships/aissta",s=await y.post(o,n).json();if(I.info("[%s] fetch ship info from: %s - %j",a.requestId,o,n),s.code!=="0")return s;const t=s.data;let r=t.imo;return e==="407170"&&(r="9198379",I.warn("[%s] ship(%s) imo error: %s, should be %s",a.requestId,e,t.imo,r)),{mmsi:t.mmsi,name:t.shipnameEn,imo:r,callSign:t.callSign,length:t.length,width:t.breadth,draught:(t.draught||100)/10}}async realTimePosition(e,a={}){const n=await this.getShipId(e,a),o=await this.getShipInfo(n,a),s={headers:{appKey:this.token},json:{shipId:n}},t="https://api3.myships.com/sp/ships/position/latest",r=await y.post(t,s).json();I.info("[%s] fetch realtime position from: %s - %j",a.requestId,t,s);const i=r.data[0];for(const h in i)!isNaN(i[h])&&Number(i[h])!==1/0&&(i[h]=Number(i[h]));const{labelCn:d,labelEn:c}=await this.parseStatus(i.aisNavStatus),f=l.unix(i.posTime);return{...o,mmsi:e,lat:Math.round(i.lat/1e4/60*1e5)/1e5,lng:Math.round(i.lon/1e4/60*1e5)/1e5,sog:Math.round(i.sog/10*100)/100,cog:Math.round(i.cog/10*100)/100,hdg:Math.round(i.heading*100)/100,rot:Math.round(i.rot*100)/100,positionTime:i.posTime,utc:f.utc().format(),status:i.aisNavStatus,labelEn:c,labelCn:d,method:"position",vendor:"myship"}}async trajectory(e,a,n,o,s=!0,t={}){const r=l(a),i=l(n),d=await this.getShipId(e),c=await this.getShipInfo(d),f=[];for(;i.diff(r,"day",!0)>30;)await this.trajectoryIn30Day(d,r.unix(),r.add(30,"day").unix(),c,e,o,f);return await this.trajectoryIn30Day(d,r.unix(),i.unix(),c,e,o,f),f}async trajectoryIn30Day(e,a,n,o,s,t,r,i={}){var Y;const d={headers:{appKey:this.token},json:{shipId:e,startTime:a,endTime:n}},c="https://api3.myships.com/sp/ships/position/history",f=await y.post(c,d).json();if(I.info("[%s] fetch trajectory from: %s - %j",i.requestId,c,d),f.code!=="0")return I.warn("[%s] invoke myship trajectory failed: %j",i.requestId,f),f;const u=f.data;for(const j in u)!isNaN(u[j])&&Number(u[j])!==1/0&&(u[j]=Number(u[j]));const h=l.unix((Y=u[0])==null?void 0:Y.posTime);let w=-1;for(const j of u){const S=l.unix(j.posTime),g={imo:o==null?void 0:o.imo,mmsi:s,lat:Math.round(j.lat/1e4/60*1e5)/1e5,lng:Math.round(j.lon/1e4/60*1e5)/1e5,sog:Math.round(j.sog/10*100)/100,cog:Math.round(j.cog/10*100)/100,hdg:Math.round(j.heading*100)/100,rot:Math.round(j.rot*100)/100,positionTime:S.unix(),utc:S.utc().format(),method:"trajectory",vendor:"myship"},v=Math.floor(S.diff(h,"minute",!0)/(t||1));v!==w&&(w=v,r.push(g))}return r}}const V=L.getLogger(__filename);var F=(k=>(k.NOTICE="NOTICE",k.WARN="WARN",k.HEAVY="HEAVY",k.SEVERE="SEVERE",k.ERROR="ERROR",k.FATAL="FATAL",k))(F||{});class K{parsePrinciple(p,e={}){var t,r,i;V.info("[%s] parse rule: %s",e.requestId,p);const a=new RegExp("(?<=\\[)(.+)(?=\\])","g"),n=p.match(a)?(t=p.match(a))==null?void 0:t[0]:void 0,o=n==null?void 0:n.split(";");if(!o)return;const s={};for(let d=0;d<(o==null?void 0:o.length);d++){const c=(i=(r=o[d].match(a))==null?void 0:r[0])==null?void 0:i.split("],");if(d===0&&!c)s.scope=o[0];else if(c)for(let f=0,u=c.length;f<u;f++){const h=this.parseRule(c[f]);h&&(s[h.level]?h.key?s[h.level][h==null?void 0:h.key]=h:s[h.level]=h:h.key?s[h.level]={[h==null?void 0:h.key]:h}:s[h.level]=h)}}return s}parseRule(p,e={}){var s;V.info("[%s] parse rule: %s",e.requestId,p),p=p.startsWith("[")?p:`[${p}`,p=p.endsWith("]")?p:`${p}]`;const a=new RegExp("(?<=\\[)(.+?)(?=\\])","g"),n=(s=p==null?void 0:p.match(a))==null?void 0:s[0],o=n==null?void 0:n.split(",");if(o)return{operator:o[0],number:Number(o[1]),level:o[2],time:Number(o[3]),key:o[4]}}checkWeather(p,e,a={}){var h,w,Y,j,S,g,v,T,m,D,A,P,q,N,x;let n=0,o=0,s=0,t=0;const r=Math.round(((w=(h=e==null?void 0:e.SEVERE)==null?void 0:h.sigWave)==null?void 0:w.number)*1.6*100)/100,i=(j=(Y=e==null?void 0:e.SEVERE)==null?void 0:Y.sigWave)==null?void 0:j.number,d=(g=(S=e==null?void 0:e.HEAVY)==null?void 0:S.sigWave)==null?void 0:g.number,c=Math.round((((T=(v=e==null?void 0:e.SEVERE)==null?void 0:v.wind)==null?void 0:T.number)+2)*100)/100,f=(D=(m=e==null?void 0:e.SEVERE)==null?void 0:m.wind)==null?void 0:D.number,u=(P=(A=e==null?void 0:e.HEAVY)==null?void 0:A.wind)==null?void 0:P.number;for(let $=0;$<(p==null?void 0:p.length);$++){const b=p[$],E=(N=(q=b==null?void 0:b.meteo)==null?void 0:q.wave)==null?void 0:N.sig,H=(x=b==null?void 0:b.meteo)==null?void 0:x.wind,C=$?l(b.eta).diff(l(p[$-1].eta),"hour",!0):0;t=C>t?C:t,V.info("[%s] check sig.wave: %j",a.requestId,{...E,dgThd4Wv:r,svThd4Wv:i,hvThd4Wv:d}),(E==null?void 0:E.height)>=r?b.isDangerous=!0:(E==null?void 0:E.height)>=i?b.isSevere=!0:(E==null?void 0:E.height)>=d&&(b.isHeavy=!0),V.info("[%s] check wind: %j",a.requestId,{...H,dgThd4Wd:c,svThd4Wd:f,hvThd4Wd:u}),(H==null?void 0:H.scale)>=c?(b.isDangerous=!0,delete b.isSevere,delete b.isHeavy):(H==null?void 0:H.scale)>f?(b.isDangerous||(b.isSevere=!0),delete b.isHeavy):(H==null?void 0:H.scale)===u&&!b.isDangerous&&!b.isSevere&&(b.isHeavy=!0),n+=b.isDangerous?C:0,o+=b.isSevere?C:0,s+=b.isHeavy?C:0}return n=Math.round(n*100)/100,o=Math.round(o*100)/100,s=Math.round(s*100)/100,t=Math.round(t),{sample:p,dangerous:n,severe:o,heavy:s,step:t<3?3:t,wind:{dgThd4Wd:c,svThd4Wd:f,hvThd4Wd:u},sig:{dgThd4Wv:r,svThd4Wv:i,hvThd4Wv:d}}}}const X=new K;M.AISImpl=R,M.AlertHelper=K,M.AlertLevel=F,M.HifleetImpl=U,M.MyShipImpl=Q,M.MyVesselImpl=B,M.ShipxyImpl=J,M.alertHelper=X,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idm-plugin/vessel",
3
3
  "private": false,
4
- "version": "1.0.9",
4
+ "version": "1.1.1",
5
5
  "description": "idm plugin for vessel",
6
6
  "type": "module",
7
7
  "keywords": [
@@ -29,7 +29,6 @@
29
29
  "dependencies": {
30
30
  "@log4js-node/log4js-api": "^1.0.2",
31
31
  "got": "11",
32
- "log4js": "^6.9.1",
33
32
  "moment": "^2.30.1"
34
33
  },
35
34
  "devDependencies": {
@@ -44,6 +43,7 @@
44
43
  "eslint-plugin-prettier": "^4.2.1",
45
44
  "jest": "^26.6.3",
46
45
  "lint-staged": "^13.1.2",
46
+ "log4js": "^6.9.1",
47
47
  "prettier": "^2.8.4",
48
48
  "sass": "^1.58.3",
49
49
  "simple-git-hooks": "^2.8.1",