@mark1russell7/service 0.8.4 → 0.8.6

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 (77) hide show
  1. package/build/{backoff-B-jGWVDm.d.ts → backoff-QTRGfkEK.d.ts} +1 -4
  2. package/build/backoff.d.ts +1 -1
  3. package/build/backoff.js +1 -2
  4. package/build/{builder-DQj3NNNc.d.ts → builder-zO48Vgoj.d.ts} +4 -11
  5. package/build/{call-context-gR8FhbF_.d.ts → call-context-DDhcVvn5.d.ts} +1 -4
  6. package/build/channel.d.ts +1 -4
  7. package/build/channel.js +1 -2
  8. package/build/{core-Dt0HEVMq.d.ts → core-BSzt4RI2.d.ts} +5 -10
  9. package/build/{dial-CSQOl-yj.d.ts → dial-ChwIcvd4.d.ts} +2 -5
  10. package/build/grpc.d.ts +5 -16
  11. package/build/grpc.js +7 -12
  12. package/build/grpc.js.map +1 -1
  13. package/build/heartbeat.d.ts +1 -4
  14. package/build/heartbeat.js +1 -2
  15. package/build/host.d.ts +10 -25
  16. package/build/host.js +21 -33
  17. package/build/host.js.map +1 -1
  18. package/build/http-client.d.ts +5 -18
  19. package/build/http-client.js +7 -13
  20. package/build/http-client.js.map +1 -1
  21. package/build/http.d.ts +4 -11
  22. package/build/http.js +6 -10
  23. package/build/http.js.map +1 -1
  24. package/build/index.d.ts +11 -24
  25. package/build/index.js +26 -43
  26. package/build/index.js.map +1 -1
  27. package/build/{knobs-D2ClI68I.js → knobs-BJcz6m01.js} +3 -5
  28. package/build/{knobs-D2ClI68I.js.map → knobs-BJcz6m01.js.map} +1 -1
  29. package/build/{lifecycle-Br0jAjTk.d.ts → lifecycle-D0J-zwZF.d.ts} +2 -15
  30. package/build/{limiter-BTgM4aXZ.js → limiter-BwGxEWpP.js} +4 -6
  31. package/build/{limiter-BTgM4aXZ.js.map → limiter-BwGxEWpP.js.map} +1 -1
  32. package/build/{limiter-D1aluA0V.d.ts → limiter-Djw39d_S.d.ts} +3 -6
  33. package/build/limiter.d.ts +3 -3
  34. package/build/limiter.js +2 -2
  35. package/build/{logger-BN2BfPgU.d.ts → logger-B6drv9w0.d.ts} +2 -17
  36. package/build/{machine-p4lENJ86.js → machine-mIW1qgEE.js} +7 -11
  37. package/build/{machine-p4lENJ86.js.map → machine-mIW1qgEE.js.map} +1 -1
  38. package/build/mongodb.d.ts +4 -15
  39. package/build/mongodb.js +6 -11
  40. package/build/mongodb.js.map +1 -1
  41. package/build/{operation-DL5RxFds.js → operation-DF73RZOI.js} +2 -3
  42. package/build/{operation-DL5RxFds.js.map → operation-DF73RZOI.js.map} +1 -1
  43. package/build/otel.d.ts +3 -6
  44. package/build/otel.js +1 -2
  45. package/build/pg.d.ts +3 -14
  46. package/build/pg.js +6 -11
  47. package/build/pg.js.map +1 -1
  48. package/build/{policy-G-Y3Meku.js → policy-B23MY52l.js} +2 -3
  49. package/build/{policy-G-Y3Meku.js.map → policy-B23MY52l.js.map} +1 -1
  50. package/build/{policy-CwYR95Sz.d.ts → policy-CBcK2XGg.d.ts} +1 -4
  51. package/build/{ports-CSr7qWrA.d.ts → ports-DZoipkSD.d.ts} +2 -5
  52. package/build/{process-DG_im2zc.js → process-Oe0Abbsm.js} +2 -3
  53. package/build/{process-DG_im2zc.js.map → process-Oe0Abbsm.js.map} +1 -1
  54. package/build/{queue-fIkOXKVG.d.ts → queue-DXdw1vLO.d.ts} +3 -8
  55. package/build/rabbitmq.d.ts +5 -16
  56. package/build/rabbitmq.js +6 -11
  57. package/build/rabbitmq.js.map +1 -1
  58. package/build/redis.d.ts +4 -17
  59. package/build/redis.js +10 -16
  60. package/build/redis.js.map +1 -1
  61. package/build/{requests-BIq9Tr4P.js → requests-DD2ALv0_.js} +6 -9
  62. package/build/{requests-BIq9Tr4P.js.map → requests-DD2ALv0_.js.map} +1 -1
  63. package/build/{retrier-Nt6r4r6R.js → retrier-BObZq10-.js} +3 -4
  64. package/build/{retrier-Nt6r4r6R.js.map → retrier-BObZq10-.js.map} +1 -1
  65. package/build/{rules-BBRopO1e.d.ts → rules-HyFCBStQ.d.ts} +1 -6
  66. package/build/rules.d.ts +1 -1
  67. package/build/rules.js +1 -2
  68. package/build/{store-1CsNoJ8O.d.ts → store-DFwFKrsB.d.ts} +2 -5
  69. package/build/testing.d.ts +5 -16
  70. package/build/testing.js +9 -15
  71. package/build/testing.js.map +1 -1
  72. package/build/{timing-DGRi3XCI.js → timing-DZl36uXs.js} +2 -3
  73. package/build/{timing-DGRi3XCI.js.map → timing-DZl36uXs.js.map} +1 -1
  74. package/build/websocket.d.ts +4 -15
  75. package/build/websocket.js +7 -12
  76. package/build/websocket.js.map +1 -1
  77. package/package.json +11 -10
package/build/host.js CHANGED
@@ -1,14 +1,15 @@
1
- import { realClock } from "./clock.js";
2
- import { s as isMessageShape } from "./process-DG_im2zc.js";
3
1
  import { backoffProblems } from "./backoff.js";
4
- import { t as retrier } from "./retrier-Nt6r4r6R.js";
2
+ import { s as isMessageShape } from "./process-Oe0Abbsm.js";
3
+ import { t as retrier } from "./retrier-BObZq10-.js";
4
+ import { realClock } from "./clock.js";
5
5
  import { convertible, isQuantity, valueIn } from "@mark1russell7/quantity";
6
6
  import { connect } from "node:net";
7
+ import { escapeAttribute } from "@mark1russell7/text";
7
8
  import { execFile, spawn } from "node:child_process";
8
9
  import { appendFile, mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
9
10
  import { homedir, userInfo } from "node:os";
10
11
  import { dirname } from "node:path";
11
- //#region src/host/ports.ts
12
+ // src/host/ports.ts
12
13
  /** This function joins the parts of a path with the separator of the platform. */
13
14
  const joinPath = (platform, ...parts) => {
14
15
  const separator = platform === "win32" ? "\\" : "/";
@@ -22,8 +23,7 @@ const joinPath = (platform, ...parts) => {
22
23
  };
23
24
  return parts.map((part, at) => trim(part, at !== 0)).filter((part, at) => at === 0 || part !== "").join(separator);
24
25
  };
25
- //#endregion
26
- //#region src/host/render.ts
26
+ // src/host/render.ts
27
27
  const NAME$1 = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
28
28
  const DAILY = /^([01]\d|2[0-3]):([0-5]\d)$/;
29
29
  /** This function tells if a text has a control character. Such a character can add a line to a unit, or break the task file. */
@@ -93,8 +93,6 @@ const systemdArg = (arg) => {
93
93
  if (escaped !== "" && !/[\s"'\\;]/.test(escaped)) return escaped;
94
94
  return `"${escaped.replace(/\\/g, () => "\\\\").replace(/"/g, () => "\\\"")}"`;
95
95
  };
96
- /** This function escapes a text for the content or an attribute of an XML element. */
97
- const xmlText = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
98
96
  /** This function gives a time as an ISO 8601 duration of Task Scheduler in whole seconds, for example `PT90S`. */
99
97
  const isoSeconds = (time) => `PT${Math.max(1, Math.ceil(valueIn(time, "s")))}S`;
100
98
  /** This function gives the interval of the repeat trigger of a task: whole minutes, 1 minute or more. */
@@ -115,7 +113,7 @@ const refuse = (spec) => {
115
113
  */
116
114
  const renderTaskXml = (spec, context) => {
117
115
  refuse(spec);
118
- const user = xmlText(context.user);
116
+ const user = escapeAttribute(context.user);
119
117
  const hidden = (spec.console ?? "hidden") === "hidden";
120
118
  const command = hidden ? context.conhost : spec.program;
121
119
  const args = (hidden ? [
@@ -147,13 +145,13 @@ const renderTaskXml = (spec, context) => {
147
145
  </ScheduleByDay>
148
146
  </CalendarTrigger>`);
149
147
  }
150
- const cwd = spec.cwd === void 0 ? "" : `\n <WorkingDirectory>${xmlText(spec.cwd)}</WorkingDirectory>`;
148
+ const cwd = spec.cwd === void 0 ? "" : `\n <WorkingDirectory>${escapeAttribute(spec.cwd)}</WorkingDirectory>`;
151
149
  const limit = spec.timeLimit === void 0 ? "PT0S" : isoSeconds(spec.timeLimit);
152
150
  return `<?xml version="1.0" encoding="UTF-16"?>
153
151
  <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
154
152
  <RegistrationInfo>
155
- <Description>${xmlText(spec.description)}</Description>
156
- <URI>\\${xmlText(spec.name)}</URI>
153
+ <Description>${escapeAttribute(spec.description)}</Description>
154
+ <URI>\\${escapeAttribute(spec.name)}</URI>
157
155
  </RegistrationInfo>
158
156
  <Triggers>
159
157
  ${triggers.join("\n")}
@@ -186,8 +184,8 @@ ${triggers.join("\n")}
186
184
  </Settings>
187
185
  <Actions Context="Author">
188
186
  <Exec>
189
- <Command>${xmlText(windowsArg(command))}</Command>
190
- <Arguments>${xmlText(args)}</Arguments>${cwd}
187
+ <Command>${escapeAttribute(windowsArg(command))}</Command>
188
+ <Arguments>${escapeAttribute(args)}</Arguments>${cwd}
191
189
  </Exec>
192
190
  </Actions>
193
191
  </Task>
@@ -243,8 +241,7 @@ const renderSystemdTimer = (spec) => {
243
241
  "WantedBy=timers.target"
244
242
  ].join("\n")}\n`;
245
243
  };
246
- //#endregion
247
- //#region src/host/processes.ts
244
+ // src/host/processes.ts
248
245
  /**
249
246
  * This margin is the time after a recorded start in which a process can start and still be the same
250
247
  * process, in milliseconds. A start time on Linux comes in ticks of 10 ms, and a step of the wall clock moves a time.
@@ -304,8 +301,7 @@ const stopTree = async (pid, ports) => {
304
301
  problem: `the signal SIGKILL did not go to the process ${pid}`
305
302
  } : { kind: "absent" };
306
303
  };
307
- //#endregion
308
- //#region src/host/lock.ts
304
+ // src/host/lock.ts
309
305
  const isMark = (value) => {
310
306
  if (typeof value !== "object" || value === null) return false;
311
307
  const { pid, startedAt } = value;
@@ -491,8 +487,7 @@ const held = (path, first, firstText, ports) => {
491
487
  })
492
488
  };
493
489
  };
494
- //#endregion
495
- //#region src/host/discovery.ts
490
+ // src/host/discovery.ts
496
491
  const isPort = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 65535;
497
492
  /** This function reads a discovery record from a text. It gives the record, or the problem as a text. */
498
493
  const parseDiscovery = (text) => {
@@ -600,8 +595,7 @@ const removeDiscovery = async (path, ports, pid = ports.self.pid) => {
600
595
  return false;
601
596
  }
602
597
  };
603
- //#endregion
604
- //#region src/host/install.ts
598
+ // src/host/install.ts
605
599
  /** This function gives the folder of the systemd user units: `$XDG_CONFIG_HOME/systemd/user`, or `~/.config/systemd/user`. */
606
600
  const unitDir = (ports) => {
607
601
  const config = ports.env["XDG_CONFIG_HOME"];
@@ -911,8 +905,7 @@ const serviceStatus = async (spec, ports, options = {}) => {
911
905
  commands: run.commands
912
906
  };
913
907
  };
914
- //#endregion
915
- //#region src/host/probes.ts
908
+ // src/host/probes.ts
916
909
  /** This function gives the problems of a probe: each value that a probe cannot use. */
917
910
  const probeProblems = (probe) => {
918
911
  if (probe.kind === "http") {
@@ -960,8 +953,7 @@ const probeOnce = async (probe, timeout, ports) => {
960
953
  };
961
954
  }
962
955
  };
963
- //#endregion
964
- //#region src/host/env.ts
956
+ // src/host/env.ts
965
957
  const KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
966
958
  /** This function reads a value in double quotes: `\n`, `\t`, `\"` and `\\` are escapes. */
967
959
  const doubleQuoted = (body) => body.replace(/\\(.)/g, (_match, char) => char === "n" ? "\n" : char === "t" ? " " : char === "r" ? "\r" : char);
@@ -1015,8 +1007,7 @@ const closingQuote = (text) => {
1015
1007
  else if (text[at] === "\"") return at;
1016
1008
  return -1;
1017
1009
  };
1018
- //#endregion
1019
- //#region src/host/logs.ts
1010
+ // src/host/logs.ts
1020
1011
  const byteLength = (chunk) => typeof chunk === "string" ? new TextEncoder().encode(chunk).length : chunk.length;
1021
1012
  /**
1022
1013
  * This function makes a rotating log on a file port. Before a write that makes the file larger than
@@ -1060,8 +1051,7 @@ const rotatingLog = (spec, files) => {
1060
1051
  }
1061
1052
  };
1062
1053
  };
1063
- //#endregion
1064
- //#region src/host/group.ts
1054
+ // src/host/group.ts
1065
1055
  /**
1066
1056
  * This restart is the default. The first wait is 1 s, and each wait after it is two times longer, to 1 min.
1067
1057
  * The jitter subtracts up to half of each wait. The count of tries goes back to 0 after 1 min ready.
@@ -1507,8 +1497,7 @@ const superviseGroup = (spec, ports, options = {}) => {
1507
1497
  }
1508
1498
  };
1509
1499
  };
1510
- //#endregion
1511
- //#region src/host/node.ts
1500
+ // src/host/node.ts
1512
1501
  const codeOf = (error) => typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
1513
1502
  const missing = (error) => codeOf(error) === "ENOENT";
1514
1503
  const nodeCommands = { run: (file, args, options = {}) => new Promise((resolve) => {
@@ -1761,7 +1750,6 @@ const nodeHostPorts = (options = {}) => {
1761
1750
  ...options.logger === void 0 ? {} : { logger: options.logger }
1762
1751
  };
1763
1752
  };
1764
- //#endregion
1765
1753
  export { DEFAULT_RESTART, START_MARGIN_MS, acquireInstanceLock, discoveryOf, groupProblems, inspectInstanceLock, installService, joinPath, lockText, nodeHostPorts, parseDiscovery, parseEnvFile, parseLockOwner, probeOnce, probeProblems, readDiscovery, removeDiscovery, renderSystemdTimer, renderSystemdUnit, renderTaskXml, rotatingLog, sameProcess, servicePaths, serviceProblems, serviceStatus, startOrder, startService, stopService, stopTree, superviseGroup, systemdArg, uninstallService, utf16le, windowsArg, writeDiscovery };
1766
1754
 
1767
1755
  //# sourceMappingURL=host.js.map