@rocket.chat/houston 0.27.0-next.3 → 2.1.9

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 (294) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +109 -15
  3. package/bin/houston +62 -0
  4. package/data/docs/ARCHITECTURE.md +387 -0
  5. package/data/docs/automation.md +107 -0
  6. package/data/docs/e2ee.md +76 -0
  7. package/data/docs/eks.md +258 -0
  8. package/data/docs/gui.md +282 -0
  9. package/data/docs/guide.md +642 -0
  10. package/data/docs/kubernetes.md +138 -0
  11. package/data/docs/loadtest.md +264 -0
  12. package/data/docs/troubleshooting.md +203 -0
  13. package/data/docs/upgrading.md +84 -0
  14. package/data/docs/voice.md +253 -0
  15. package/data/iam/engineer-policy.json +11 -0
  16. package/data/iam/engineer-rbac.yaml +42 -0
  17. package/data/iam/operator-policy.json +211 -0
  18. package/data/loadtest/badbot.js +22 -0
  19. package/data/loadtest/common.js +170 -0
  20. package/data/loadtest/custom.js +20 -0
  21. package/data/loadtest/journey.js +58 -0
  22. package/data/loadtest/login.js +18 -0
  23. package/data/loadtest/messages.js +13 -0
  24. package/data/loadtest/mixed.js +57 -0
  25. package/data/loadtest/read.js +12 -0
  26. package/data/loadtest/webhook.js +20 -0
  27. package/data/monitoring/houston-logs.json +98 -0
  28. package/data/monitoring/k6-loadtest.json +610 -0
  29. package/data/monitoring/mongodb-exporter.json +3007 -0
  30. package/data/monitoring/node-exporter-full.json +16114 -0
  31. package/data/monitoring/rocketchat-metrics.json +6471 -0
  32. package/data/presets/airgapped.yaml +16 -0
  33. package/data/presets/default.yaml +9 -0
  34. package/data/seed/avatar-0.png +0 -0
  35. package/data/seed/avatar-1.png +0 -0
  36. package/data/seed/avatar-2.png +0 -0
  37. package/data/seed/avatar-3.png +0 -0
  38. package/data/seed/avatar-4.png +0 -0
  39. package/data/seed/avatar-5.png +0 -0
  40. package/data/seed/avatar-6.png +0 -0
  41. package/data/seed/avatar-7.png +0 -0
  42. package/data/seed/seed-metrics.csv +3 -0
  43. package/data/seed/seed-preview.png +0 -0
  44. package/data/seed/seed-report.pdf +32 -0
  45. package/data/seed/seed-runbook.txt +3 -0
  46. package/data/skill/SKILL.md +399 -0
  47. package/data/versions.yaml +55 -0
  48. package/data/voice/freeswitch/drachtio.xml +52 -0
  49. package/data/voice/freeswitch/public.xml +87 -0
  50. package/data/webui/app.css +2003 -0
  51. package/data/webui/index.html +678 -0
  52. package/data/webui/js/api.js +561 -0
  53. package/data/webui/js/boot.js +44 -0
  54. package/data/webui/js/clusters-tail.js +1377 -0
  55. package/data/webui/js/clusters.js +896 -0
  56. package/data/webui/js/create.js +276 -0
  57. package/data/webui/js/detail.js +507 -0
  58. package/data/webui/js/jobs.js +636 -0
  59. package/data/webui/js/logs.js +634 -0
  60. package/data/webui/js/main.js +14 -0
  61. package/data/webui/js/options.js +408 -0
  62. package/data/webui/js/people.js +438 -0
  63. package/data/webui/js/perf.js +303 -0
  64. package/data/webui/js/render.js +438 -0
  65. package/data/webui/js/shared.js +3 -0
  66. package/data/webui/js/state.js +583 -0
  67. package/data/webui/js/theme.js +123 -0
  68. package/data/webui/js/util.js +584 -0
  69. package/dist/cli/app.js +593 -0
  70. package/dist/cli/capabilities.js +76 -0
  71. package/dist/cli/cell-widths.js +495 -0
  72. package/dist/cli/entry.js +10 -0
  73. package/dist/cli/error-panel.js +492 -0
  74. package/dist/cli/handlers/actor.js +84 -0
  75. package/dist/cli/handlers/https.js +614 -0
  76. package/dist/cli/handlers/prompt.js +299 -0
  77. package/dist/cli/handlers/users.js +226 -0
  78. package/dist/cli/handlers.js +3694 -0
  79. package/dist/cli/help.js +183 -0
  80. package/dist/cli/index.js +15 -0
  81. package/dist/cli/perf.js +814 -0
  82. package/dist/cli/render.js +254 -0
  83. package/dist/cli/serve.js +858 -0
  84. package/dist/cli/spec-data.js +2599 -0
  85. package/dist/cli/spec-types.js +8 -0
  86. package/dist/cli/usage-error.js +520 -0
  87. package/dist/cli/wire.js +70 -0
  88. package/dist/core/audit.js +346 -0
  89. package/dist/core/backup-compat.js +85 -0
  90. package/dist/core/backup.js +1639 -0
  91. package/dist/core/cluster.js +1398 -0
  92. package/dist/core/configimport.js +345 -0
  93. package/dist/core/data.js +267 -0
  94. package/dist/core/database-of.js +82 -0
  95. package/dist/core/diagnose.js +159 -0
  96. package/dist/core/doctor.js +1518 -0
  97. package/dist/core/edge/acme.js +338 -0
  98. package/dist/core/edge/engine.js +500 -0
  99. package/dist/core/edge/networks.js +174 -0
  100. package/dist/core/edge/paths.js +107 -0
  101. package/dist/core/edge/routes.js +251 -0
  102. package/dist/core/edge/routeyml.js +195 -0
  103. package/dist/core/edge/runtime.js +493 -0
  104. package/dist/core/edge/spec.js +305 -0
  105. package/dist/core/edge/types.js +202 -0
  106. package/dist/core/eks-docs.js +135 -0
  107. package/dist/core/eks.js +2240 -0
  108. package/dist/core/envvars.js +562 -0
  109. package/dist/core/eventlog.js +541 -0
  110. package/dist/core/firstrun.js +153 -0
  111. package/dist/core/journal.js +694 -0
  112. package/dist/core/kube/ask.js +231 -0
  113. package/dist/core/kube/capabilities.js +269 -0
  114. package/dist/core/kube/certmanager.js +452 -0
  115. package/dist/core/kube/chart.js +413 -0
  116. package/dist/core/kube/cluster.js +196 -0
  117. package/dist/core/kube/context.js +545 -0
  118. package/dist/core/kube/endpoints.js +448 -0
  119. package/dist/core/kube/exec.js +195 -0
  120. package/dist/core/kube/forward.js +732 -0
  121. package/dist/core/kube/grafana-ingress.js +110 -0
  122. package/dist/core/kube/ingress.js +218 -0
  123. package/dist/core/kube/manifests.js +361 -0
  124. package/dist/core/kube/monitoring.js +768 -0
  125. package/dist/core/kube/names.js +237 -0
  126. package/dist/core/kube/namespace.js +678 -0
  127. package/dist/core/kube/operator.js +941 -0
  128. package/dist/core/kube/probe.js +202 -0
  129. package/dist/core/kube/reachability.js +163 -0
  130. package/dist/core/kube/release.js +439 -0
  131. package/dist/core/kube/replicaset.js +180 -0
  132. package/dist/core/kube/scale.js +398 -0
  133. package/dist/core/kube/status.js +633 -0
  134. package/dist/core/kube/tools.js +238 -0
  135. package/dist/core/kube/transfer.js +173 -0
  136. package/dist/core/kube/workspace.js +423 -0
  137. package/dist/core/lifecycle/admin.js +64 -0
  138. package/dist/core/lifecycle/create-docker.js +1549 -0
  139. package/dist/core/lifecycle/create-k8s.js +960 -0
  140. package/dist/core/lifecycle/destroy.js +339 -0
  141. package/dist/core/lifecycle/inspect.js +636 -0
  142. package/dist/core/lifecycle/naming.js +298 -0
  143. package/dist/core/lifecycle/notes.js +862 -0
  144. package/dist/core/lifecycle/ownership.js +313 -0
  145. package/dist/core/lifecycle/payload.js +401 -0
  146. package/dist/core/lifecycle/ports.js +388 -0
  147. package/dist/core/lifecycle/preconditions.js +367 -0
  148. package/dist/core/lifecycle/pruning.js +551 -0
  149. package/dist/core/lifecycle/ready.js +818 -0
  150. package/dist/core/lifecycle/request.js +510 -0
  151. package/dist/core/lifecycle/seeding.js +281 -0
  152. package/dist/core/lifecycle/sizing.js +392 -0
  153. package/dist/core/lifecycle/state.js +286 -0
  154. package/dist/core/lifecycle/tlsplan.js +704 -0
  155. package/dist/core/lifecycle/types.js +232 -0
  156. package/dist/core/loadtest.js +1051 -0
  157. package/dist/core/migrate.js +612 -0
  158. package/dist/core/monitor.js +494 -0
  159. package/dist/core/postready.js +976 -0
  160. package/dist/core/promote.js +804 -0
  161. package/dist/core/rcapi.js +1336 -0
  162. package/dist/core/recovery.js +75 -0
  163. package/dist/core/runner/engine.js +394 -0
  164. package/dist/core/runner/host.js +298 -0
  165. package/dist/core/runner/locks.js +129 -0
  166. package/dist/core/runner/paths.js +173 -0
  167. package/dist/core/runner/ports.js +172 -0
  168. package/dist/core/runner/queries.js +612 -0
  169. package/dist/core/runner/record.js +563 -0
  170. package/dist/core/scaleseed.js +271 -0
  171. package/dist/core/seed-db.js +208 -0
  172. package/dist/core/sessions.js +472 -0
  173. package/dist/core/skill.js +326 -0
  174. package/dist/core/sso-identities.js +172 -0
  175. package/dist/core/sso.js +703 -0
  176. package/dist/core/tls-local.js +311 -0
  177. package/dist/core/tls.js +878 -0
  178. package/dist/core/topology.js +482 -0
  179. package/dist/core/upgrade.js +877 -0
  180. package/dist/core/users.js +739 -0
  181. package/dist/lib/audit.js +100 -0
  182. package/dist/lib/close-matches.js +238 -0
  183. package/dist/lib/compose.js +672 -0
  184. package/dist/lib/config.js +1398 -0
  185. package/dist/lib/context.js +18 -0
  186. package/dist/lib/errors.js +305 -0
  187. package/dist/lib/events.js +208 -0
  188. package/dist/lib/float-text.js +126 -0
  189. package/dist/lib/format.js +1320 -0
  190. package/dist/lib/home.js +325 -0
  191. package/dist/lib/journal.js +122 -0
  192. package/dist/lib/json-text.js +733 -0
  193. package/dist/lib/jsonout.js +382 -0
  194. package/dist/lib/lock.js +516 -0
  195. package/dist/lib/login-name.js +202 -0
  196. package/dist/lib/map-limit.js +29 -0
  197. package/dist/lib/mkdir-parents.js +90 -0
  198. package/dist/lib/mongo-kernel.js +67 -0
  199. package/dist/lib/monitoring.js +492 -0
  200. package/dist/lib/platform-name.js +59 -0
  201. package/dist/lib/presets/common.js +390 -0
  202. package/dist/lib/presets/composite.js +326 -0
  203. package/dist/lib/presets/e2ee.js +143 -0
  204. package/dist/lib/presets/email.js +172 -0
  205. package/dist/lib/presets/guides.js +27 -0
  206. package/dist/lib/presets/index.js +490 -0
  207. package/dist/lib/presets/keycloak.js +371 -0
  208. package/dist/lib/presets/ldap.js +1285 -0
  209. package/dist/lib/presets/livechat.js +220 -0
  210. package/dist/lib/presets/multi-instance.js +124 -0
  211. package/dist/lib/presets/oidc.js +161 -0
  212. package/dist/lib/presets/public.js +496 -0
  213. package/dist/lib/presets/registry.js +64 -0
  214. package/dist/lib/presets/s3-minio.js +300 -0
  215. package/dist/lib/presets/saml.js +149 -0
  216. package/dist/lib/presets/scenario.js +51 -0
  217. package/dist/lib/presets/types.js +86 -0
  218. package/dist/lib/presets/voice-pbx.js +320 -0
  219. package/dist/lib/presets/voice.js +345 -0
  220. package/dist/lib/presets/webhooks.js +182 -0
  221. package/dist/lib/redact.js +106 -0
  222. package/dist/lib/seed-options.js +68 -0
  223. package/dist/lib/seed-profiles.js +59 -0
  224. package/dist/lib/targz.js +1383 -0
  225. package/dist/lib/teammode.js +25 -0
  226. package/dist/lib/tempdir.js +162 -0
  227. package/dist/lib/unicode-tables.js +2335 -0
  228. package/dist/lib/version-spec.js +357 -0
  229. package/dist/lib/versions.js +463 -0
  230. package/dist/lib/yaml-dump.js +1361 -0
  231. package/dist/perf/baseline.js +168 -0
  232. package/dist/perf/constrain.js +299 -0
  233. package/dist/perf/k6.js +235 -0
  234. package/dist/perf/mongoprof.js +171 -0
  235. package/dist/perf/rcmetrics.js +191 -0
  236. package/dist/perf/report.js +386 -0
  237. package/dist/perf/resources.js +236 -0
  238. package/dist/perf/slo.js +111 -0
  239. package/dist/perf/timeline.js +187 -0
  240. package/dist/perf/timings.js +85 -0
  241. package/dist/perf/verdict.js +201 -0
  242. package/dist/seams/aws-cli.js +126 -0
  243. package/dist/seams/docker-cli.js +280 -0
  244. package/dist/seams/exec.js +861 -0
  245. package/dist/seams/fs/lock.js +528 -0
  246. package/dist/seams/kubectl.js +83 -0
  247. package/dist/seams/rc-http.js +921 -0
  248. package/dist/seed/apply.js +190 -0
  249. package/dist/seed/assets.js +76 -0
  250. package/dist/seed/check.js +391 -0
  251. package/dist/seed/client.js +172 -0
  252. package/dist/seed/executor.js +726 -0
  253. package/dist/seed/history.js +281 -0
  254. package/dist/seed/kinds.js +91 -0
  255. package/dist/seed/plan.js +432 -0
  256. package/dist/seed/receipt.js +339 -0
  257. package/dist/seed/repairs.js +75 -0
  258. package/dist/seed/verification.js +363 -0
  259. package/dist/seed/wording.js +248 -0
  260. package/dist/web/app.js +326 -0
  261. package/dist/web/jobs.js +510 -0
  262. package/dist/web/route-deps.js +211 -0
  263. package/dist/web/route-table.js +213 -0
  264. package/dist/web/routes/backup.js +244 -0
  265. package/dist/web/routes/clusters.js +303 -0
  266. package/dist/web/routes/data.js +187 -0
  267. package/dist/web/routes/edge.js +82 -0
  268. package/dist/web/routes/index.js +63 -0
  269. package/dist/web/routes/jobs.js +95 -0
  270. package/dist/web/routes/logs.js +297 -0
  271. package/dist/web/routes/meta.js +191 -0
  272. package/dist/web/routes/people.js +151 -0
  273. package/dist/web/routes/perf.js +95 -0
  274. package/dist/web/routes/repros.js +550 -0
  275. package/dist/web/routes/session.js +361 -0
  276. package/dist/web/routes/spa.js +198 -0
  277. package/dist/web/security.js +475 -0
  278. package/dist/web/signin.js +246 -0
  279. package/package.json +70 -32
  280. package/.eslintrc +0 -94
  281. package/.swcrc +0 -18
  282. package/dist/bin.js +0 -3
  283. package/dist/cli.js +0 -184
  284. package/dist/commands/createBranch.js +0 -194
  285. package/dist/outputCI.js +0 -59
  286. package/src/bin.js +0 -4
  287. package/src/cli.ts +0 -25
  288. package/src/commands/createBranch.ts +0 -28
  289. package/src/outputCI.ts +0 -12
  290. package/src-old/logs.js +0 -323
  291. package/src-old/md.js +0 -191
  292. package/src-old/release-table.js +0 -60
  293. package/src-old/set-version.js +0 -614
  294. package/src-old/utils.js +0 -15
@@ -0,0 +1,862 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.noteGroup = noteGroup;
37
+ exports.flattenNotes = flattenNotes;
38
+ exports.localUrlNote = localUrlNote;
39
+ exports.scenarioGroup = scenarioGroup;
40
+ exports.kubernetesHttpsGroup = kubernetesHttpsGroup;
41
+ exports.mongoGroupAndSharedNotes = mongoGroupAndSharedNotes;
42
+ exports.kubernetesMongoGroup = kubernetesMongoGroup;
43
+ exports.forwardAndReachNotes = forwardAndReachNotes;
44
+ exports.lookAtWhatIsInside = lookAtWhatIsInside;
45
+ exports.openTheWayIn = openTheWayIn;
46
+ exports.howToWorkWithIt = howToWorkWithIt;
47
+ exports.kubernetesNoteGroups = kubernetesNoteGroups;
48
+ exports.composeNoteGroups = composeNoteGroups;
49
+ exports.inboxUrl = inboxUrl;
50
+ exports.webhooksGroup = webhooksGroup;
51
+ exports.premiumSignIn = premiumSignIn;
52
+ exports.oauthNeedsHttps = oauthNeedsHttps;
53
+ exports.loginPresetOf = loginPresetOf;
54
+ exports.signInGate = signInGate;
55
+ exports.signInGroup = signInGroup;
56
+ exports.noteGroupsOf = noteGroupsOf;
57
+ /**
58
+ * The prose a workspace carries: what it is, how to reach it, what to do next.
59
+ *
60
+ * Every note is built here and rendered by whoever asked -- the CLI prints them, the GUI puts
61
+ * them in a panel -- so nothing in this module may reach for the terminal UI.
62
+ *
63
+ * `noteGroup` is the one constructor; a group with no rows is dropped by
64
+ * `noteGroupsOf`'s callers, so a builder can return an empty group rather than branching
65
+ * at every call site.
66
+ */
67
+ const fs = __importStar(require("node:fs"));
68
+ const path = __importStar(require("node:path"));
69
+ const composite_1 = require("../../lib/presets/composite");
70
+ const config = __importStar(require("../../lib/config"));
71
+ const monitoring_1 = require("../../lib/monitoring");
72
+ const format_1 = require("../../lib/format");
73
+ const presets = __importStar(require("../../lib/presets/index"));
74
+ const public_1 = require("../../lib/presets/public");
75
+ const versions_1 = require("../../lib/versions");
76
+ const version_spec_1 = require("../../lib/version-spec");
77
+ const certmanager_1 = require("../kube/certmanager");
78
+ const forward_1 = require("../kube/forward");
79
+ const names_1 = require("../kube/names");
80
+ const monitoring_2 = require("../kube/monitoring");
81
+ const status_1 = require("../kube/status");
82
+ const operator_1 = require("../kube/operator");
83
+ const exec_1 = require("../kube/exec");
84
+ const paths = __importStar(require("../runner/paths"));
85
+ const record_1 = require("../runner/record");
86
+ const tls_1 = require("../tls");
87
+ const topology = __importStar(require("../topology"));
88
+ const common_1 = require("../../lib/presets/common");
89
+ function noteGroup(title, { rows = [], body = [], commands = [], kind = '', guides = [], } = {}) {
90
+ return {
91
+ title,
92
+ kind,
93
+ rows: rows.map((row) => [String(row[0]), row[1]]),
94
+ body: [...body],
95
+ commands: [...commands],
96
+ guides: guides.map((one) => structuredClone(one)),
97
+ };
98
+ }
99
+ /** `text` padded on the right to `width`, counted in CODE POINTS, not UTF-16 units. */
100
+ function padRight(text, width) {
101
+ const length = [...text].length;
102
+ return length >= width ? text : text + ' '.repeat(width - length);
103
+ }
104
+ /**
105
+ * The groups as the flat string list every existing consumer expects.
106
+ *
107
+ * Indentation is the contract the flat form already had and the CLI and the browser both
108
+ * parse: a four-space line is something to paste. `key: value` rows become that same
109
+ * shape so a terminal reader sees a list rather than a table it has no way to draw.
110
+ */
111
+ function flattenNotes(groups) {
112
+ const out = [];
113
+ for (const group of groups) {
114
+ const rows = group.rows;
115
+ if (rows.length > 0) {
116
+ const width = Math.max(...rows.map(([key]) => [...String(key)].length));
117
+ out.push(`${group.title}:`);
118
+ out.push(...rows.map(([key, value]) => ` ${padRight(String(key), width)} ${String(value)}`));
119
+ }
120
+ else if (group.title) {
121
+ out.push(`${group.title}:`);
122
+ }
123
+ out.push(...group.body);
124
+ out.push(...group.commands.map((command) => ` ${command}`));
125
+ }
126
+ return out;
127
+ }
128
+ /** Truthiness, as a function -- `unknown` may not appear in a conditional. */
129
+ function isTruthy(value) {
130
+ if (value === null || value === undefined || value === false)
131
+ return false;
132
+ if (typeof value === 'string')
133
+ return value !== '';
134
+ if (typeof value === 'number')
135
+ return value !== 0;
136
+ if (Array.isArray(value))
137
+ return value.length > 0;
138
+ if (typeof value === 'object')
139
+ return Object.keys(value).length > 0;
140
+ return true;
141
+ }
142
+ /** Whether the value is an integer -- and `true`/`false` are not, deliberately. */
143
+ function isInt(value) {
144
+ return typeof value === 'number' && Number.isInteger(value);
145
+ }
146
+ function bag(value) {
147
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
148
+ ? value
149
+ : {};
150
+ }
151
+ /** The URL's hostname, or "" when it has none. */
152
+ function urlHostname(value) {
153
+ if (!value)
154
+ return '';
155
+ try {
156
+ return new URL(value).hostname;
157
+ }
158
+ catch {
159
+ // A scheme-less string has no hostname, and `new URL` throws on it: the same answer,
160
+ // "".
161
+ return '';
162
+ }
163
+ }
164
+ /**
165
+ * Correct `localhost` in a preset's own browser URLs, when it is wrong.
166
+ *
167
+ * `ldap` prints phpLDAPadmin, `s3_minio` its console, `email` Mailpit's inbox, `livechat`
168
+ * a demo page -- all browser URLs, all written when the browser was assumed to be on the
169
+ * docker host. On a workspace bound wide or given a public URL it is not, and `localhost`
170
+ * then names the reader's own machine.
171
+ *
172
+ * KEYED ON THE NOTES THEMSELVES, which the first version got wrong: it fired whenever a
173
+ * preset had side-service ports, so a `saml` workspace whose `idp_host` had already put
174
+ * the real host in every line was told "the URLs above say localhost". They did not.
175
+ */
176
+ function localUrlNote(meta, scenario) {
177
+ const extra = bag(meta.extra);
178
+ const body = scenario.flatMap((group) => group.body);
179
+ // `://localhost`, not the bare word: an HTTPS workspace's own name may be
180
+ // `<name>.houston.localhost`, and its UIs' public paths are not what this corrects.
181
+ if (!body.some((line) => /:\/\/localhost[:/]/u.test(line)))
182
+ return [];
183
+ let ports = (Array.isArray(extra.sidecar_ports) ? extra.sidecar_ports : []).filter(isInt);
184
+ // Over HTTPS most UIs moved to paths of the name and their ports serve them no more:
185
+ // offer only the ports a note still gives (livechat's cross-origin demo page).
186
+ if ((0, public_1.publicPathsOf)(extra).length > 0) {
187
+ const given = new Set([...body.join('\n').matchAll(/:\/\/localhost:(\d+)/gu)].map((match) => Number(match[1])));
188
+ ports = ports.filter((port) => given.has(port));
189
+ }
190
+ const bindHost = (0, format_1.toText)(extra.bind_host);
191
+ const advertised = (0, format_1.toText)(extra.advertised_url);
192
+ if (ports.length === 0 || !(advertised || !['', '127.0.0.1', 'localhost'].includes(bindHost))) {
193
+ return [];
194
+ }
195
+ // BOUND TO ONE ADDRESS, the ports are published there alone, and houston calls the
196
+ // workspace by it (`callHost`): `localhost` answers nothing, on this box either.
197
+ const direct = urlHostname(meta.rootUrl);
198
+ const only = direct !== '' && direct !== 'localhost' ? direct : '';
199
+ const host = only || urlHostname(advertised) || '<this-box>';
200
+ const shown = [...ports].sort((a, b) => a - b).slice(0, 4);
201
+ const urls = shown.map((port) => `http://${host}:${String(port)}`).join(', ');
202
+ return [
203
+ noteGroup("Reaching this preset's own pages", {
204
+ body: [
205
+ only
206
+ ? 'The URLs above say `localhost`, which answers nothing here or anywhere else. ' +
207
+ `Use ${host} instead: ${urls}.`
208
+ : 'The URLs above say `localhost`, which names whichever machine the browser ' +
209
+ `is on. From anywhere but this box, use ${host} instead: ${urls}.`,
210
+ `Those ports are published on ${bindHost || '127.0.0.1'}, so they are ` +
211
+ 'reachable only as far as that bind allows.',
212
+ ],
213
+ }),
214
+ ];
215
+ }
216
+ /**
217
+ * The preset's own prose as the leading group. Empty for a plain workspace.
218
+ *
219
+ * DERIVED on every read, not remembered from the create. They used to be built once and
220
+ * frozen into `repro.json`, so the "What works here" note told people `backup` had no
221
+ * Kubernetes path for three releases after it grew one -- and the fix only reached
222
+ * workspaces created after it.
223
+ */
224
+ function scenarioGroup(meta) {
225
+ const name = (meta.preset || '').trim();
226
+ if (!name || name === 'default')
227
+ return [];
228
+ const extra = bag(meta.extra);
229
+ const params = bag(extra.params);
230
+ const names = (0, composite_1.namesOf)(name);
231
+ let pre;
232
+ try {
233
+ // The SAME resolution the create used, per runtime: a scenario yields native
234
+ // manifests on Kubernetes and a compose service on Docker, and its notes follow the
235
+ // shape it was built in. A composed workspace merges its presets as the create did,
236
+ // into ONE group, so a reader that renders the first scenario group shows them all.
237
+ // On the workspace's OWN ports, which the create gave it: the registry's are another's.
238
+ const runtime = topology.ofMeta(meta);
239
+ const ports = (0, record_1.sidePortsOf)(meta);
240
+ if (names.length > 1) {
241
+ pre = presets.loadMany(names, bag(extra.preset_params), runtime, new Set(Object.keys(bag(extra.env))), ports);
242
+ }
243
+ else {
244
+ pre =
245
+ runtime === topology.KUBERNETES
246
+ ? presets.resolve(name, topology.KUBERNETES, params, ports)
247
+ : presets.load(name, params, ports);
248
+ }
249
+ // Over HTTPS the create served the preset's own UIs at paths of the name, and moved
250
+ // their notes there (`lib/presets/public.ts`); derive them the way it did.
251
+ if (meta.publicUrl && (0, public_1.publicPathsOf)(extra).length > 0) {
252
+ pre = (0, public_1.withPublicUrl)(pre, meta.publicUrl, runtime);
253
+ }
254
+ }
255
+ catch {
256
+ // A preset file removed after the create. This runs on a READ path (`info`, the GUI
257
+ // panel), and a workspace whose preset is no longer loadable still has to be able to
258
+ // describe itself rather than answer 500.
259
+ return [];
260
+ }
261
+ const edited = editedFiles(meta.name, pre);
262
+ const notes = [
263
+ ...pre.notes,
264
+ ...(edited.length > 0
265
+ ? [
266
+ 'Edited lab files (kept by up --force; delete one and run up --force for the default): ' +
267
+ edited.join(', '),
268
+ ]
269
+ : []),
270
+ ];
271
+ if (notes.length === 0)
272
+ return [];
273
+ // kind="scenario", not a title the panel has to recognise by its prefix.
274
+ return [
275
+ noteGroup(`Preset · ${(0, composite_1.presetsLabel)(pre.name)}`, {
276
+ kind: 'scenario',
277
+ body: notes,
278
+ // A YAML preset has no guide: the card then reads these notes as it always has.
279
+ guides: pre.guides.length === names.length ? pre.guides : [],
280
+ }),
281
+ ];
282
+ }
283
+ /** The kept files (a lab dialplan) whose copy in the workspace is not the preset's default. */
284
+ function editedFiles(name, pre) {
285
+ const stock = new Map(pre.files);
286
+ return (pre.keepFiles ?? []).filter((file) => {
287
+ try {
288
+ return fs.readFileSync(path.join(paths.workspace(name), file), 'utf8') !== stock.get(file);
289
+ }
290
+ catch {
291
+ return false; // absent or unreadable: a read path says nothing rather than fail
292
+ }
293
+ });
294
+ }
295
+ /**
296
+ * The HTTPS card for a Kubernetes workspace: where TLS actually terminates.
297
+ *
298
+ * On Compose the edge holds the certificate as a file; here it holds nothing for this
299
+ * name -- it matches the SNI and forwards raw TCP, and the certificate is a
300
+ * `kubernetes.io/tls` Secret that cert-manager filled from an annotation on the chart's
301
+ * own Ingress.
302
+ */
303
+ function kubernetesHttpsGroup(meta, extra, ns) {
304
+ const local = (0, format_1.toText)(extra.tls) !== tls_1.MODE_ACME;
305
+ const endpoint = (0, format_1.toText)(extra.ingress_endpoint);
306
+ const issuer = local ? certmanager_1.CA_ISSUER : certmanager_1.ACME_ISSUER;
307
+ const body = [
308
+ `${meta.publicUrl} is served by the chart's own Ingress in ${ns}. TLS ` +
309
+ `terminates IN THE CLUSTER, from the Secret ${(0, certmanager_1.tlsSecretFor)(meta.name)} ` +
310
+ 'that cert-manager issued -- so the failure modes a customer hits (a wrong ' +
311
+ 'secretName, an expired Certificate, an annotation naming a missing issuer) ' +
312
+ 'are the real ones here.',
313
+ ];
314
+ if (endpoint) {
315
+ body.push('The edge does not decrypt this name: it matches the SNI and forwards ' +
316
+ `raw TCP to ${endpoint}. Nothing about the certificate is the edge's, and ` +
317
+ '`houston edge logs` will not mention it.');
318
+ }
319
+ body.push(local
320
+ ? 'A locally-issued certificate: run `houston trust-ca` once and the browser ' +
321
+ 'accepts it, on every workspace on this box.'
322
+ : "A publicly trusted certificate from Let's Encrypt, obtained by cert-manager " +
323
+ "over the http-01 challenge. Renewal is cert-manager's, not the edge's.");
324
+ return [
325
+ noteGroup('HTTPS', {
326
+ body,
327
+ commands: [
328
+ `kubectl -n ${ns} describe certificate ${(0, certmanager_1.tlsSecretFor)(meta.name)}`,
329
+ `kubectl describe clusterissuer ${issuer}`,
330
+ `houston tls-status --name ${meta.name}`,
331
+ ],
332
+ }),
333
+ ];
334
+ }
335
+ /**
336
+ * What to say about a MongoDB this workspace did not create and must not delete.
337
+ *
338
+ * There is no "reachable at <url>" note any more: the summary panel prints the URL
339
+ * immediately above these notes, so the note was the fourth copy of one string on one
340
+ * screen. What is NOT said anywhere else is what a non-loopback bind means.
341
+ */
342
+ function sharedMongoNotes() {
343
+ // Reserved for the wording the previous implementation kept here. It is deliberately
344
+ // empty: every sentence that used to live in it was either moved to the panel or
345
+ // withdrawn, and an empty function is the honest record of that.
346
+ }
347
+ /** The MongoDB group itself, and the notes about a database this workspace does not own. */
348
+ function mongoGroupAndSharedNotes(extra, meta, ns) {
349
+ let mongoGroup;
350
+ let shared;
351
+ if (extra.mongo_managed_by === 'operator') {
352
+ mongoGroup = noteGroup('MongoDB', {
353
+ rows: [
354
+ ['Version', meta.mongoTag],
355
+ ['Image', (0, format_1.toText)(extra.mongo_image)],
356
+ ['Managed by', 'the official operator'],
357
+ ['Authentication', 'SCRAM'],
358
+ ],
359
+ });
360
+ shared = [
361
+ noteGroup('The MongoDB operator is shared', {
362
+ body: [
363
+ `One install in ${operator_1.OPERATOR_NAMESPACE} watches every namespace, ` +
364
+ 'rather than one per workspace as the official guide shows. Its CRDs ' +
365
+ 'are cluster-scoped, so a second per-workspace install would collide ' +
366
+ `on them. Nothing of it lives in ${ns} except the database, its Secrets ` +
367
+ 'and its ServiceAccount.',
368
+ ],
369
+ commands: [
370
+ `kubectl -n ${operator_1.OPERATOR_NAMESPACE} get pods`,
371
+ `kubectl -n ${ns} get mongodbcommunity`,
372
+ ],
373
+ }),
374
+ ];
375
+ }
376
+ else {
377
+ mongoGroup = noteGroup('MongoDB', {
378
+ rows: [
379
+ ['Version', meta.mongoTag],
380
+ ['Image', (0, format_1.toText)(extra.mongo_image)],
381
+ ['Managed by', 'a plain StatefulSet'],
382
+ ['Authentication', 'none'],
383
+ ],
384
+ body: [
385
+ "This path is houston's own: the official guide documents only the " +
386
+ 'operator, which needs MongoDB ' +
387
+ `${operator_1.OPERATOR_MIN_MONGO.map(String).join('.')}+. Add ` +
388
+ '`--mongo-operator` for the documented path, with authentication.',
389
+ ],
390
+ });
391
+ shared = [];
392
+ }
393
+ sharedMongoNotes();
394
+ return [mongoGroup, shared];
395
+ }
396
+ /**
397
+ * Where MongoDB came from, which decides what a reader can do about it: the operator's
398
+ * CRD, a StatefulSet houston made, or a shared one somebody else owns.
399
+ */
400
+ function kubernetesMongoGroup(bindHost, extra, meta, ns) {
401
+ // The port-forward carries the bind host: a workspace created with `--bind 0.0.0.0`
402
+ // needs `--address 0.0.0.0` to come back the same way.
403
+ const addr = bindHost === '' || bindHost === '127.0.0.1' || bindHost === 'localhost'
404
+ ? ''
405
+ : `--address ${bindHost} `;
406
+ const [mongoGroup, shared] = mongoGroupAndSharedNotes(extra, meta, ns);
407
+ return [addr, mongoGroup, shared];
408
+ }
409
+ /** A port-forward that has died, and an address other machines can use. */
410
+ async function forwardAndReachNotes(addr, bindHost, extra, meta, ns, port, root) {
411
+ let forward = [];
412
+ const recordedPid = extra.port_forward_pid;
413
+ if (ns &&
414
+ typeof recordedPid === 'number' &&
415
+ recordedPid !== 0 &&
416
+ !(await (0, forward_1.forwardAlive)(recordedPid, { namespace: ns, hostPort: port }))) {
417
+ forward = [
418
+ noteGroup('The URL is not published right now', {
419
+ body: [
420
+ `No port-forward is running for this workspace, so ${root} will not ` +
421
+ 'answer -- a forward dies with its pod, and houston does not keep one ' +
422
+ 'alive in the background. This says nothing about Rocket.Chat itself; ' +
423
+ 'the pods may be perfectly healthy.',
424
+ ],
425
+ commands: [
426
+ `houston ready --name ${meta.name}`,
427
+ `houston start --name ${meta.name} # if it is stopped`,
428
+ ],
429
+ }),
430
+ ];
431
+ }
432
+ let reach = [];
433
+ if (addr) {
434
+ reach = [
435
+ noteGroup('Reachable from other machines', {
436
+ body: [
437
+ `This workspace publishes on ${bindHost}, so it answers at ` +
438
+ `http://<this-box>:${String(port)} from anything that can route here -- and it ` +
439
+ `runs ${config.ADMIN_USERNAME}/${meta.adminPassword || config.ADMIN_PASSWORD}. Keep it off ` +
440
+ 'untrusted networks.',
441
+ ],
442
+ }),
443
+ ];
444
+ }
445
+ return [forward, reach];
446
+ }
447
+ /** Step 3: the read-only commands, which are the ones a support case runs. */
448
+ function lookAtWhatIsInside(ns, release) {
449
+ return noteGroup('3 · Look at what is inside', {
450
+ body: [
451
+ 'What is running, what Rocket.Chat is saying, and the values the release ' +
452
+ 'was installed with:',
453
+ ],
454
+ commands: [
455
+ `kubectl -n ${ns} get pods`,
456
+ `kubectl -n ${ns} logs -l app.kubernetes.io/name=rocketchat -f`,
457
+ `helm -n ${ns} get values ${release}`,
458
+ ],
459
+ });
460
+ }
461
+ /** Step 2: the port-forward, which is tied to a pod and dies with it. */
462
+ function openTheWayIn(ns, release, root, port, addr) {
463
+ return noteGroup('2 · Open the way in', {
464
+ body: [
465
+ 'Rocket.Chat is reached through a port-forward, which is tied to its pod ' +
466
+ `and dies with it. This is the one houston started, so run it again, in a shell ` +
467
+ `on the machine running houston, if ${root} stops answering:`,
468
+ ],
469
+ commands: [
470
+ `kubectl -n ${ns} port-forward ${addr}deployment/${release}-rocketchat ${String(port)}:3000`,
471
+ ],
472
+ });
473
+ }
474
+ /**
475
+ * The three numbered steps a support engineer follows on this runtime.
476
+ *
477
+ * Different enough from Compose's that one set of words would serve neither. THE ORDER
478
+ * IS THE SEQUENCE somebody has to perform: the export has to come before every other
479
+ * line, and the port-forward before anything that reaches Rocket.Chat itself, so the
480
+ * three groups read top to bottom as: point your tools here, open the way in, then look
481
+ * at what is inside.
482
+ */
483
+ function howToWorkWithIt(meta, ns, context, release, root, port, addr, shared) {
484
+ return [
485
+ // WHICH kubeconfig, and it is not the same answer on both clusters. houston keeps its
486
+ // own only for the cluster it CREATED. The note said "export KUBECONFIG=<houston's
487
+ // own>" unconditionally -- wrong three ways on an adopted cluster.
488
+ (0, names_1.isOurs)(context)
489
+ ? noteGroup('1 · Point kubectl and helm at this cluster', {
490
+ body: [
491
+ 'These commands run in a shell on the machine running houston. houston keeps ' +
492
+ 'its own kubeconfig so creating a cluster cannot move the ' +
493
+ 'context you were using. A bare `kubectl` will not see this workspace ' +
494
+ 'until it is pointed here, and every command below assumes it:',
495
+ ],
496
+ commands: [`export KUBECONFIG=${(0, exec_1.ownedKubeconfig)()}`],
497
+ })
498
+ : noteGroup("1 · Point kubectl at this workspace's cluster", {
499
+ // houston never moves kubectl's current context (a build puts it back where it
500
+ // was), so the commands below reach this cluster only once it is pointed here.
501
+ // "Every command below runs against '<context>'" and "# expect <context>" read as
502
+ // a promise that was false on any box whose kubectl pointed somewhere else.
503
+ body: [
504
+ 'This workspace lives in an existing cluster, so there is nothing to ' +
505
+ 'export -- houston used the kubeconfig the machine running houston already ' +
506
+ 'has and wrote none of its own. The commands below run in a shell there and ' +
507
+ 'use kubectl’s current context; point it ' +
508
+ `at '${context}' first, or add \`--context ${context}\` to each of them.`,
509
+ ],
510
+ commands: [
511
+ `kubectl config current-context # if it is not ${context}: kubectl config use-context ${context}`,
512
+ ],
513
+ }),
514
+ openTheWayIn(ns, release, root, port, addr),
515
+ // HTTPS, WHICH THIS RUNTIME'S NOTES SAID NOTHING ABOUT, and it must NOT reuse the
516
+ // Compose wording: that card names the edge as the terminator, which is false here.
517
+ ...(meta.publicUrl ? kubernetesHttpsGroup(meta, bag(meta.extra), ns) : []),
518
+ lookAtWhatIsInside(ns, release),
519
+ // After the three steps, not before them: it carries two `kubectl` lines, and nothing
520
+ // that needs the kubeconfig may appear above the export that sets it.
521
+ ...shared,
522
+ ];
523
+ }
524
+ /** What a Kubernetes workspace is and how to reach it, from its record. */
525
+ async function kubernetesNoteGroups(meta) {
526
+ const extra = bag(meta.extra);
527
+ const ns = (0, format_1.toText)(extra.namespace) || meta.project || '';
528
+ const release = (0, format_1.toText)(extra.release) || names_1.RELEASE;
529
+ const context = (0, format_1.toText)(extra[config.EXTRA_CONTEXT]) || names_1.CONTEXT;
530
+ const micro = String(topology.axesOfMeta(meta).deployment ?? '') === topology.MICROSERVICES;
531
+ // COUNTED, not predicted: what the chart runs differs by chart version, and a fixed "5"
532
+ // stood beside a chart-7.0.2 monolith's two pods (and "about 5" beside nine). A cluster
533
+ // that does not answer gives no pods, and then nothing is counted rather than guessed.
534
+ const pods = await (0, status_1.podRows)(meta.name, { context });
535
+ const running = pods.filter((pod) => pod.state === 'running').length;
536
+ const podsRow = pods.length === 0
537
+ ? 'not counted: the cluster did not answer'
538
+ : `${String(pods.length)} in its namespace, ` +
539
+ `${running === pods.length ? 'all' : String(running)} running`;
540
+ const bindHost = (0, format_1.toText)(extra.bind_host);
541
+ const port = meta.hostPort || 3000;
542
+ const root = meta.rootUrl || `http://localhost:${String(port)}`;
543
+ const [addr, mongoGroup, shared] = kubernetesMongoGroup(bindHost, extra, meta, ns);
544
+ const [forward, reach] = await forwardAndReachNotes(addr, bindHost, extra, meta, ns, port, root);
545
+ // A managed cluster by the name a person knows, its region and its kind; the ARN is
546
+ // what a command needs and the summary carries it as `context`. And the one fact about
547
+ // a managed cluster nothing on the workspace said: it bills whether or not this runs.
548
+ const managed = /^arn:aws:eks:/u.test(context);
549
+ const clusterRow = managed
550
+ ? `${context.split('/').pop() ?? context} · ${context.split(':')[3] ?? ''} · EKS`
551
+ : context;
552
+ return [
553
+ noteGroup('Kubernetes', {
554
+ rows: [
555
+ ['Cluster', clusterRow],
556
+ ['Namespace', ns],
557
+ ['Shape', micro ? 'microservices' : 'monolith'],
558
+ ['Pods', podsRow],
559
+ // Said, not refused: a license can be added after the workspace is up.
560
+ ...(micro && (extra.licensed !== true || extra.license_status === 'refused')
561
+ ? [
562
+ [
563
+ 'License',
564
+ 'microservices are an Enterprise feature: without an Enterprise license, every ' +
565
+ 'Rocket.Chat replica after the first stops ("Enterprise license not found"). ' +
566
+ 'Add one with `--license` or in Rocket.Chat under Workspace > Subscription.',
567
+ ],
568
+ ]
569
+ : []),
570
+ ...(managed
571
+ ? [
572
+ [
573
+ 'Costs',
574
+ 'the cluster bills by the hour whether or not this workspace runs — ' +
575
+ '`houston cluster overview` on the machine running houston prices it, ' +
576
+ "as the GUI's Clusters page does",
577
+ ],
578
+ ]
579
+ : []),
580
+ ],
581
+ }),
582
+ mongoGroup,
583
+ ...forward,
584
+ ...reach,
585
+ ...webhooksGroup(meta),
586
+ ...howToWorkWithIt(meta, ns, context, release, root, port, addr, shared),
587
+ noteGroup('Monitoring', {
588
+ rows: isTruthy(extra.monitoring)
589
+ ? [
590
+ [
591
+ 'Grafana',
592
+ (0, monitoring_1.grafanaUrl)(isTruthy(extra.tls) ? meta.publicUrl : '', true, (0, record_1.grafanaPortOf)(meta)),
593
+ ],
594
+ ['Login', 'admin/admin; anonymous Viewer'],
595
+ ]
596
+ : [],
597
+ body: [
598
+ 'Prometheus and Grafana are shared by the cluster, not installed per ' +
599
+ `workspace: this puts one stack in ${monitoring_2.MONITORING_NAMESPACE}, and \`--off\` ` +
600
+ 'leaves it up while any other workspace still wants it.',
601
+ ],
602
+ commands: [`houston monitor --name ${meta.name}`],
603
+ }),
604
+ // This used to say "logs, stats and backup have no Kubernetes path yet". Two of the
605
+ // three were right and backup was not, so a stale note cost a capability that already
606
+ // existed -- which is why this is derived and not read back out of a record.
607
+ noteGroup('What works here', {
608
+ body: [
609
+ '`logs`, `stats`, `env`, `upgrade`, `backup`, `restore`, `seed`, ' +
610
+ '`monitor`, `api`, `pat` and `token` all work on this runtime. `stats` ' +
611
+ 'needs metrics-server in the cluster and says so if it is missing; ' +
612
+ '`env --set` refuses and hands over the `helm upgrade` that changes a ' +
613
+ 'value.',
614
+ ],
615
+ }),
616
+ ];
617
+ }
618
+ /**
619
+ * The add-ons a Compose workspace gained, each as its own group.
620
+ *
621
+ * Same three sources the create appended to the flat list -- the scenario, the edge, the
622
+ * monitoring stack -- so this changes their shape and not one word of their content.
623
+ */
624
+ function composeNoteGroups(meta) {
625
+ const extra = bag(meta.extra);
626
+ const groups = [];
627
+ if (isTruthy(extra.edge) && meta.publicUrl) {
628
+ groups.push(noteGroup('HTTPS', {
629
+ body: [
630
+ `served by the edge at ${meta.publicUrl}`,
631
+ 'the edge holds :443 for the whole box; this workspace publishes none',
632
+ ],
633
+ }));
634
+ }
635
+ if (isTruthy(extra.monitoring)) {
636
+ const publicUrl = isTruthy(extra.tls) ? meta.publicUrl : '';
637
+ groups.push(noteGroup('Monitoring', {
638
+ body: (0, monitoring_1.notes)((0, monitoring_1.grafanaUrl)(publicUrl, !!publicUrl, (0, record_1.grafanaPortOf)(meta)), (0, record_1.prometheusPortOf)(meta)),
639
+ }));
640
+ }
641
+ groups.push(...webhooksGroup(meta));
642
+ return groups;
643
+ }
644
+ /**
645
+ * The webhook inbox's page, at the session the receiver chose, on the port the workspace
646
+ * holds; '' until post-ready recorded the session. The one place the address is composed:
647
+ * the links row and the Webhooks group both read it. The host is the record's own root
648
+ * URL's, which the create composed from the bind (`request.callHost`): the side ports are
649
+ * published where Rocket.Chat's is.
650
+ */
651
+ function inboxUrl(meta) {
652
+ const session = bag(bag(meta.extra).webhooks).session;
653
+ if (typeof session !== 'string' || session === '' || !(0, composite_1.namesOf)(meta.preset).includes('webhooks')) {
654
+ return '';
655
+ }
656
+ const port = (0, common_1.presetPorts)('webhooks', (0, record_1.sidePortsOf)(meta))[0];
657
+ if (port === undefined)
658
+ return '';
659
+ const host = urlHostname(meta.rootUrl) || 'localhost';
660
+ return `http://${host}:${String(port)}/s/${encodeURIComponent(session)}`;
661
+ }
662
+ /**
663
+ * What the webhooks preset's post-ready recorded: the inbox page and the incoming hook as
664
+ * places (the line shape the panel turns into a link row), the curl to paste, where the
665
+ * Omnichannel webhook points, and what capture=all repointed. Absent until a ready run
666
+ * wrote `extra.webhooks`. The inbox link is the same the links row carries: the session
667
+ * the receiver chose, on the port the workspace holds.
668
+ */
669
+ function webhooksGroup(meta) {
670
+ const hooks = bag(bag(meta.extra).webhooks);
671
+ if (Object.keys(hooks).length === 0)
672
+ return [];
673
+ const text = (value) => (typeof value === 'string' ? value : '');
674
+ const base = (0, record_1.externalUrl)(meta).replace(/\/+$/u, '');
675
+ const incoming = text(hooks.incoming);
676
+ const omnichannel = text(hooks.omnichannel);
677
+ const body = [];
678
+ const commands = [];
679
+ const inbox = inboxUrl(meta);
680
+ if (inbox !== '') {
681
+ body.push(`Webhook inbox (every outgoing integration call and Omnichannel event lands here): ${inbox}`);
682
+ }
683
+ if (incoming !== '') {
684
+ body.push(`Incoming hook (POST JSON {"text": …}; posts as rocket.cat in #general): ${base}${incoming}`);
685
+ commands.push(`curl -s -X POST -H 'Content-Type: application/json' -d '{"text":"hello from a webhook"}' ${base}${incoming}`);
686
+ }
687
+ body.push(`Outgoing: '${text(hooks.outgoing_name) || config.WEBHOOKS_OUTGOING}' posts every public-channel message to the inbox; Admin → Workspace → Integrations → History shows each attempt.`);
688
+ // A customer's URL is a FACT in a row, never prose: the panel links a URL in prose, and a
689
+ // click on the customer's real endpoint is a request to it.
690
+ const rows = [];
691
+ if (omnichannel.startsWith(`${config.WEBHOOKS_RECEIVER}/`)) {
692
+ // capture=all keeps the URL it replaced in ?from=, as it does for an integration.
693
+ let from;
694
+ try {
695
+ from = new URL(omnichannel).searchParams.get('from') ?? '';
696
+ }
697
+ catch {
698
+ from = '';
699
+ }
700
+ if (from !== '')
701
+ rows.push(['Omnichannel webhook', `at the inbox — was ${from}`]);
702
+ else
703
+ body.push('Omnichannel webhook: at the inbox (/omnichannel; fires once Omnichannel is on).');
704
+ }
705
+ else if (omnichannel === '') {
706
+ body.push('Omnichannel webhook: not set.');
707
+ }
708
+ else {
709
+ rows.push([
710
+ 'Omnichannel webhook',
711
+ `left at ${omnichannel} (--set capture=all repoints it at the inbox)`,
712
+ ]);
713
+ }
714
+ for (const one of Array.isArray(hooks.captured) ? hooks.captured : []) {
715
+ const entry = bag(one);
716
+ const from = Array.isArray(entry.from) ? entry.from.map(String) : [];
717
+ rows.push([
718
+ 'Repointed at the inbox (capture=all)',
719
+ `${text(entry.name)} — was ${from.join(', ') || 'unknown'}`,
720
+ ]);
721
+ }
722
+ return [noteGroup('Webhooks', { rows, body, commands })];
723
+ }
724
+ /** A release 9.0 or later; a build tag (develop, pr-N) is not knowable here, so no. */
725
+ function from900(rcVersion) {
726
+ return (0, versions_1.isValidVersion)(rcVersion) && ((0, version_spec_1.parseVersion)(rcVersion).release[0] ?? 0) >= 9;
727
+ }
728
+ /** Whether the preset signs in through a Custom OAuth provider: oidc, and ldap's idp=oidc. */
729
+ const signsInByOauth = (pre) => pre.postReady.some((action) => action.action === 'create_oauth_provider');
730
+ /**
731
+ * The sign-ins a login preset gets refused on Rocket.Chat 9 without a licence, or null. 9.0.0
732
+ * registers `LDAP_Enable`, SAML's enable setting and every Custom OAuth one with a licence
733
+ * module (PRs #41643, #42477), and `settings.addCustomOAuth` refuses without
734
+ * `oauth-enterprise`. Read off what the preset sets up, not its name: ldap's idp=saml and
735
+ * idp=oidc sign in through SAML and Custom OAuth too. The create's warning and the workspace's
736
+ * notes both say it from here. `has` is the modules Rocket.Chat said its license turns on.
737
+ */
738
+ function premiumSignIn(pre, rcVersion, has = []) {
739
+ if (!from900(rcVersion))
740
+ return null;
741
+ // EACH MEMBER of a composed name. Compose passed the preset it built, `email+ldap` or
742
+ // `ldap+multi-instance`, which matched nothing -- so Docker never warned for a combination
743
+ // while Kubernetes, passing the members, did.
744
+ const names = (0, composite_1.namesOf)(pre.name);
745
+ const all = [];
746
+ if (names.includes('ldap'))
747
+ all.push(['LDAP', 'ldap-enterprise']);
748
+ if (pre.postReady.some((action) => action.action === 'saml_idp_cert'))
749
+ all.push(['SAML', 'saml-enterprise']);
750
+ if (signsInByOauth(pre))
751
+ all.push(['Custom OAuth', 'oauth-enterprise']);
752
+ const gated = all.filter(([, mod]) => !has.includes(mod));
753
+ if (gated.length === 0)
754
+ return null;
755
+ return {
756
+ kinds: gated.map(([kind]) => kind).join(' and '),
757
+ modules: gated.map(([, mod]) => mod).join(' and '),
758
+ through: names.filter((name) => ['ldap', 'saml', 'oidc'].includes(name)).join(' and '),
759
+ };
760
+ }
761
+ /**
762
+ * Whether Rocket.Chat needs HTTPS for this workspace's sign-in. 9.0 moved Custom OAuth to
763
+ * Passport, whose session cookie is `secure` in a production build
764
+ * (`server/configuration/configurePassport.ts`): over plain http it is never set, and the
765
+ * callback returns to the login page with no error logged. Measured on 9.0.0 with a licence:
766
+ * the same workspace signed in over HTTPS and not over http; 8.9.1 signed in over both.
767
+ */
768
+ function oauthNeedsHttps(pre, rcVersion) {
769
+ return from900(rcVersion) && signsInByOauth(pre);
770
+ }
771
+ /** A workspace's preset as `premiumSignIn` reads it: its name and the post-ready it was built with. */
772
+ function loginPresetOf(meta) {
773
+ const recorded = bag(meta.extra).post_ready;
774
+ return {
775
+ name: meta.preset,
776
+ postReady: Array.isArray(recorded) ? recorded : [],
777
+ };
778
+ }
779
+ /**
780
+ * The sign-in Rocket.Chat 9 refuses this workspace for lack of a license, as the record knows
781
+ * it; `asked` is whether that comes from Rocket.Chat's own answer rather than the create's flags.
782
+ */
783
+ function signInGate(meta) {
784
+ const extra = bag(meta.extra);
785
+ const pre = loginPresetOf(meta);
786
+ // What Rocket.Chat said its license turns on, when `ready` last asked, beats what the create
787
+ // was given: a license added later in Administration lifts the gate, and a registration token
788
+ // that brought no license does not.
789
+ const asked = Array.isArray(extra.license_modules)
790
+ ? extra.license_modules.filter((m) => typeof m === 'string')
791
+ : null;
792
+ const gate = asked !== null
793
+ ? premiumSignIn(pre, meta.rcVersion, asked)
794
+ : extra.licensed === true || extra.registered === true
795
+ ? null
796
+ : premiumSignIn(pre, meta.rcVersion);
797
+ return gate === null ? null : { ...gate, asked: asked !== null };
798
+ }
799
+ /**
800
+ * What Rocket.Chat 9 asks of this workspace's sign-in: a licence, and HTTPS for Custom OAuth.
801
+ * The create warns once in a log that scrolls away; this says it again on every `info` and in
802
+ * the GUI's panel, from the record. Worded for both front-ends, as the voice preset's notes are.
803
+ */
804
+ function signInGroup(meta) {
805
+ const pre = loginPresetOf(meta);
806
+ const body = [];
807
+ const gate = signInGate(meta);
808
+ if (gate !== null) {
809
+ body.push(`Rocket.Chat 9.0 and later refuse ${gate.kinds} sign-in without a Premium plan (a ` +
810
+ `license carrying ${gate.modules}), and ` +
811
+ (gate.asked
812
+ ? 'Rocket.Chat had no such license when houston last asked it'
813
+ : "this workspace's record shows neither a license nor a registration token") +
814
+ `: sign-in through the ${gate.through} preset is refused.`, 'To test it with one, add the license in Rocket.Chat under Administration → Subscription ' +
815
+ "(it applies at once, without a restart), then run the preset's setup again: " +
816
+ `\`houston ready --name ${meta.name}\` (in the GUI: take it down, then bring it up). ` +
817
+ 'That also asks Rocket.Chat again, and this note goes once the license is there.');
818
+ }
819
+ if (oauthNeedsHttps(pre, meta.rcVersion)) {
820
+ const https = (0, record_1.externalUrl)(meta).startsWith('https:');
821
+ const [major, minor] = (0, version_spec_1.parseVersion)(meta.rcVersion).release;
822
+ if (major === 9 && minor === 0 && !(https && !meta.publicUrl)) {
823
+ // houston's HTTPS hands Rocket.Chat an absolute token path, which 9.0.x joins onto the
824
+ // provider URL (`customOAuth.ts` at 9.0.0); a proxy of the user's own leaves it relative.
825
+ body.push("Rocket.Chat 9.0 cannot finish this OAuth sign-in through houston: over plain http the 'Keycloak " +
826
+ "(OIDC)' sign-in returns to the login page, and over houston's HTTPS (`--https`, " +
827
+ '`--domain`) the callback answers 500, because 9.0 joins the full token address ' +
828
+ 'houston gives it onto the provider URL (fixed in 9.1.0, RocketChat/Rocket.Chat#43062). ' +
829
+ 'To test this sign-in, use 8.9, or 9.1.0 or later, or a TLS proxy of your own ' +
830
+ '(`--root-url https://<name>`).');
831
+ // First: a license alone does not make it work here, so the license advice comes after.
832
+ body.unshift(body.pop());
833
+ }
834
+ else if (!https) {
835
+ const rebuild = `\`houston up --name ${meta.name} --version ${meta.rcVersion} --force\``;
836
+ body.push('Rocket.Chat 9.0 and later sign in through OAuth only over HTTPS, and this workspace is ' +
837
+ "plain http: the 'Keycloak (OIDC)' sign-in returns to the login page. Rebuild it with " +
838
+ `HTTPS, keeping its data: ${rebuild} with \`--https\` (a browser on the machine ` +
839
+ 'running houston) or `--domain <name>` (in the GUI: create it again under this name, ' +
840
+ 'with an HTTPS choice and "Rebuild it from these settings, keeping its data").');
841
+ }
842
+ else if (meta.publicUrl && (0, format_1.toText)(bag(meta.extra).tls) === tls_1.MODE_LOCAL) {
843
+ body.push('Rocket.Chat 9.0 and later sign in through OAuth only over HTTPS. This workspace is ' +
844
+ `served at ${meta.publicUrl} on houston's local certificate, which opens only in a ` +
845
+ 'browser on the machine running houston, once `houston trust-ca` has run there. To ' +
846
+ 'sign in from another computer, create it with a public name instead (`--domain`; in ' +
847
+ "the GUI, HTTPS: Let's Encrypt).");
848
+ }
849
+ }
850
+ return body.length > 0 ? [noteGroup('Signing in on Rocket.Chat 9', { body })] : [];
851
+ }
852
+ /** Every group this workspace has, scenario first. The one entry point. */
853
+ async function noteGroupsOf(meta) {
854
+ const scenario = scenarioGroup(meta);
855
+ const signIn = signInGroup(meta);
856
+ if (topology.ofMeta(meta) === topology.KUBERNETES) {
857
+ // Not corrected here: a Kubernetes workspace is reached through a port-forward the
858
+ // reader runs themselves, so `localhost` is genuinely their localhost.
859
+ return [...scenario, ...signIn, ...(await kubernetesNoteGroups(meta))];
860
+ }
861
+ return [...scenario, ...signIn, ...composeNoteGroups(meta), ...localUrlNote(meta, scenario)];
862
+ }