@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,490 @@
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.paramsHelpItems = paramsHelpItems;
37
+ exports.parse = parse;
38
+ exports.scenarioNames = scenarioNames;
39
+ exports.userPath = userPath;
40
+ exports.load = load;
41
+ exports.asValidation = asValidation;
42
+ exports.loadMany = loadMany;
43
+ exports.resolve = resolve;
44
+ exports.listPresets = listPresets;
45
+ /**
46
+ * Load reproduction presets.
47
+ *
48
+ * A preset bundles Rocket.Chat env vars and backing services into a named scenario. Built-ins
49
+ * are shipped in `data/presets`; a file of the same name in `~/.houston/presets` overrides
50
+ * the built-in so users can tweak or add their own.
51
+ *
52
+ * THE BUILDER IMPORTS BELOW ARE LOAD-BEARING. The owners could register themselves on
53
+ * first use, with the registry importing each of them; here the import moves DOWNWARD into
54
+ * the loader instead: a rank-3 registry reaching up to a rank-6 builder is the edge the
55
+ * layer gate exists to forbid, and a dynamic `require()` would evade the gate rather than
56
+ * satisfy it. The check that every builder arrived stays in `registry.builders()`, which is the
57
+ * half with teeth.
58
+ */
59
+ const fs = __importStar(require("node:fs"));
60
+ const path = __importStar(require("node:path"));
61
+ const config = __importStar(require("../config"));
62
+ const errors_1 = require("../errors");
63
+ const home_1 = require("../home");
64
+ const format_1 = require("../format");
65
+ const common_1 = require("./common");
66
+ const composite_1 = require("./composite");
67
+ const keycloak_1 = require("./keycloak");
68
+ const registry = __importStar(require("./registry"));
69
+ const types_1 = require("./types");
70
+ require("./e2ee");
71
+ require("./email");
72
+ require("./ldap");
73
+ require("./livechat");
74
+ require("./multi-instance");
75
+ require("./oidc");
76
+ require("./s3-minio");
77
+ require("./saml");
78
+ require("./voice");
79
+ require("./webhooks");
80
+ /**
81
+ * `core/topology.ts`'s `DOCKER`. Spelled out rather than imported because presets is the
82
+ * lower layer and must not depend on core; the two must stay equal, which is the guarantee
83
+ * an import would have given.
84
+ */
85
+ const RUNTIME_DEFAULT = 'docker';
86
+ /**
87
+ * The items of `value`, over what a YAML read gives back: a list's items, a string's
88
+ * characters, a mapping's keys. Anything else is a TypeError, which the listing does not
89
+ * catch -- `notes: 5` ends `houston presets`, where a silent `[]` printed the catalogue --
90
+ * and `notes: abc` is three notes, not none.
91
+ */
92
+ function iterate(value) {
93
+ if (Array.isArray(value))
94
+ return value;
95
+ if (typeof value === 'string')
96
+ return Array.from(value);
97
+ if (value !== null &&
98
+ typeof value === 'object' &&
99
+ Object.getPrototypeOf(value) === Object.prototype) {
100
+ return Object.keys(value);
101
+ }
102
+ throw new TypeError((0, format_1.expectedText)('a list', value));
103
+ }
104
+ /** `value`, or `fallback` for a falsy one -- null, false, '', 0, `[]`, `{}`. */
105
+ function or_(value, fallback) {
106
+ if (value === null || value === undefined || value === false)
107
+ return fallback;
108
+ if (value === '' || value === 0)
109
+ return fallback;
110
+ if (Array.isArray(value) && value.length === 0)
111
+ return fallback;
112
+ if (typeof value === 'object' && Object.keys(value).length === 0)
113
+ return fallback;
114
+ return value;
115
+ }
116
+ /**
117
+ * The order a preset file wrote its `params_help` keys in, for every `params_help` object
118
+ * `parse` built from one.
119
+ *
120
+ * `houston presets` prints one `--set` line per key, in the order the file wrote them. A
121
+ * JavaScript object lists every integer-like key first whatever order it was written in,
122
+ * so a user file with `users`, `"10"`, `alpha` printed `--set 10` above `--set users`,
123
+ * where it belongs below it (t1-presets verifier, measured). The `Preset` shape stays the
124
+ * established one, field for field, so the order travels beside it rather than in it;
125
+ * `paramsHelpItems` is the one reader.
126
+ */
127
+ const PARAMS_HELP_ORDER = new WeakMap();
128
+ /**
129
+ * The `params_help` entries: in the order the file wrote the keys where `parse` read them from
130
+ * one, else in the object's own order -- the builders' literals, whose keys are all words.
131
+ */
132
+ function paramsHelpItems(help) {
133
+ const order = PARAMS_HELP_ORDER.get(help);
134
+ if (order === undefined)
135
+ return Object.entries(help);
136
+ return order.map((key) => [key, help[key]]);
137
+ }
138
+ /**
139
+ * Record `help`'s key order from the file's own mapping. Kept only when the ordered read
140
+ * names exactly the keys the plain one did: a key that is not a string (`? [a, b]`, or a
141
+ * `10` beside a `"10"`) stringifies differently in the two, and the object's own order is
142
+ * then the one left.
143
+ */
144
+ function rememberParamsHelpOrder(text, help) {
145
+ const own = Object.keys(help);
146
+ if (own.length === 0)
147
+ return;
148
+ const doc = (0, common_1.safeLoadOrdered)(text);
149
+ const rows = doc instanceof Map ? doc.get('params_help') : undefined;
150
+ if (!(rows instanceof Map))
151
+ return;
152
+ const keys = [...rows.keys()].map(String);
153
+ const same = keys.length === own.length &&
154
+ new Set(keys).size === keys.length &&
155
+ keys.every((key) => Object.hasOwn(help, key));
156
+ if (same)
157
+ PARAMS_HELP_ORDER.set(help, keys);
158
+ }
159
+ /**
160
+ * The preset's `env`, each value as the YAML read typed it -- the int past 2**53 exact,
161
+ * `1.0` a float, a mapping with its keys as typed -- for `compose.ts`, which writes
162
+ * each as its `str` (`toTextYaml`). The plain read turned each into what JavaScript holds,
163
+ * and the `str` of that is another value: `12345678901234567890` rounded, `1.0` spelled
164
+ * `1`, `{1: a}` as `{'1': 'a'}`. A key the plain read had to stringify keeps its plain
165
+ * value.
166
+ */
167
+ function typedEnv(text, plain) {
168
+ const env = or_(plain, {});
169
+ const doc = config.safeLoadConstructed(text);
170
+ const held = doc instanceof Map ? doc.get('env') : undefined;
171
+ if (!(held instanceof Map) || typeof env !== 'object' || Array.isArray(env))
172
+ return env;
173
+ const out = {};
174
+ for (const key of Object.keys(env)) {
175
+ // A defined property, as the reader made each: `__proto__` is a key here, not a setter.
176
+ Object.defineProperty(out, key, {
177
+ value: held.has(key) ? held.get(key) : env[key],
178
+ enumerable: true,
179
+ writable: true,
180
+ configurable: true,
181
+ });
182
+ }
183
+ return out;
184
+ }
185
+ function parse(text, source) {
186
+ const raw = or_((0, common_1.safeLoad)(text), {});
187
+ // A LIST OR A SCALAR IS NOT A PRESET. Reading a field of either is a TypeError, which
188
+ // is not a ReproError -- so one malformed file in the presets directory took out
189
+ // `houston presets`, `/api/presets` and the create dialog, and made `capabilities`
190
+ // report ZERO presets (it guards its own call with a catch-all, so the failure became
191
+ // silence).
192
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
193
+ throw new Error(`preset ${source} is ${(0, format_1.valueKind)(raw)}, not a mapping ` +
194
+ "(a preset file is a YAML mapping with a 'name' key)");
195
+ }
196
+ const doc = raw;
197
+ if (or_(doc.name, '') === '')
198
+ throw new Error(`preset ${source} is missing a 'name' field`);
199
+ const paramsHelp = or_(doc.params_help, {});
200
+ rememberParamsHelpOrder(text, paramsHelp);
201
+ return {
202
+ ...(0, types_1.emptyPreset)(String(doc.name)),
203
+ description: doc.description === undefined ? '' : String(doc.description),
204
+ env: typedEnv(text, doc.env),
205
+ services: or_(doc.services, {}),
206
+ rocketchat: or_(doc.rocketchat, {}),
207
+ dependsOn: or_(doc.depends_on, []),
208
+ // The established truth of `requires_license`, which is TRUE for a NaN -- `.nan`
209
+ // printed `[needs license]` there and nothing here until isTruthy called a NaN truthy too.
210
+ requiresLicense: (0, format_1.isTruthy)(doc.requires_license),
211
+ source,
212
+ notes: iterate(or_(doc.notes, [])).map(format_1.toTextAny),
213
+ paramsHelp,
214
+ instances: Math.trunc(Number(or_(doc.instances ?? 1, 1))),
215
+ entryService: String(or_(doc.entry_service ?? '', '')),
216
+ extra: or_(doc.extra, {}),
217
+ volumes: or_(doc.volumes, {}),
218
+ // The integer grammar (`toInt`): `ports: [abc]` is a refusal, which lists the file as
219
+ // UNREADABLE, where `Number` made it a NaN port and printed the preset.
220
+ ports: iterate(or_(doc.ports, [])).map((p) => (0, format_1.toInt)(p)),
221
+ topology: String(or_(doc.topology ?? '', '')),
222
+ };
223
+ }
224
+ /** Load builders so each can register itself with the leaf registry. */
225
+ function dynamicBuilders() {
226
+ return registry.builders();
227
+ }
228
+ /** The built-in scenario names, derived from the shipped catalogue. */
229
+ function scenarioNames() {
230
+ const dynamic = Object.keys(dynamicBuilders()).filter((name) => name !== 'multi-instance');
231
+ // No DEPLOYMENT_PRESETS exclusion: deployments are not presets here. PR #3 modelled
232
+ // "microservices" as a preset that implies Kubernetes; this branch models it as a
233
+ // DEPLOYMENT under an explicit runtime, so there is nothing in the preset catalogue to
234
+ // filter out.
235
+ const static_ = builtinStems();
236
+ return [...new Set([...dynamic, ...static_])].sort();
237
+ }
238
+ /** Built-in scenario registry; intentionally not a public plugin registry. */
239
+ function scenarioDefinitions() {
240
+ return registry.scenarios();
241
+ }
242
+ /**
243
+ * A preset name, and nothing that can be read as a path.
244
+ *
245
+ * Joining `<name>.yaml` onto the presets directory looks like it confines the lookup to
246
+ * that directory and does not: a component-by-component join DISCARDS the left operand
247
+ * when the right is absolute, so `--preset /tmp/x` resolved to `/tmp/x.yaml` and the
248
+ * presets directory was never consulted. No `..` and no existing presets dir required.
249
+ *
250
+ * That mattered because a preset is a container spec. Its `services:` is deep-merged into
251
+ * the compose document, so any readable YAML on the box became an arbitrary image with
252
+ * arbitrary bind mounts, running as whoever runs houston -- reproduced with
253
+ * `volumes: ["/:/host:ro"]`. And `preset` is not in `PRIVILEGED_CREATE_FIELDS`, so
254
+ * `POST /api/repros` is member+: on the shared server this file's own README warns about,
255
+ * any member could hand the serve process a container spec. Two lesser consequences
256
+ * travelled with it: naming another workspace's `docker-compose.yml` (valid YAML with
257
+ * `name:` and `services:`) pulled that workspace's Keycloak/MinIO/LDAP and their
258
+ * credentials into one of yours, and the three distinguishable errors made the create
259
+ * dialog a filesystem oracle.
260
+ *
261
+ * The README already says "treat preset files as code -- they can run arbitrary containers
262
+ * and mount files". That is only safe because of the sentence before it, "drop a YAML file
263
+ * in ~/.houston/presets/<name>.yaml", and that sentence was not enforced anywhere. It is
264
+ * now, at the one place every reader goes through.
265
+ *
266
+ * Node's `path.join` does NOT have that absolute-operand rule; `joinPath`, which this
267
+ * module joins with, does -- and the check is here either way, because the guarantee
268
+ * callers rely on is "a name, validated once", not "the joiner happens to be safe".
269
+ */
270
+ const NAME_RE = /^[a-z0-9][a-z0-9_-]*$/u;
271
+ /**
272
+ * The user-preset file for `name`, or refuse a name that is not a name.
273
+ *
274
+ * Validated here rather than at the call sites so `load`, `resolve` and `listPresets` all
275
+ * inherit it -- a check on two of the three is the shape this bug had in the first place.
276
+ */
277
+ function userPath(name) {
278
+ if (typeof name !== 'string' || !NAME_RE.test(name)) {
279
+ throw new Error(`${(0, format_1.quotedText)(String(name))} is not a preset name (want lower-case letters, digits, '-' ` +
280
+ `and '_', starting with a letter or digit). A preset is a YAML file in ` +
281
+ `${config.presetDir()}; it is named, never given as a path.`);
282
+ }
283
+ const base = config.presetDir();
284
+ const candidate = (0, home_1.joinPath)(base, `${name}.yaml`);
285
+ // Belt and braces: the regex already forbids '/', '\\' and '.', so this cannot trigger
286
+ // today. It is here because the regex is one edit away from being loosened, and the
287
+ // consequence of loosening it is arbitrary container specs.
288
+ try {
289
+ if (path.dirname(fs.realpathSync(candidate)) !== fs.realpathSync(base)) {
290
+ throw new Error(`preset ${(0, format_1.quotedText)(name)} resolves outside ${base}`);
291
+ }
292
+ }
293
+ catch (error) {
294
+ if (error instanceof Error && error.message.startsWith('preset '))
295
+ throw error;
296
+ // A filesystem error -- the file or the directory is simply not there yet.
297
+ }
298
+ return candidate;
299
+ }
300
+ /** The stems of the shipped `*.yaml` catalogue rows. */
301
+ function builtinStems() {
302
+ const dir = config.dataPath('presets');
303
+ return fs
304
+ .readdirSync(dir)
305
+ .filter((entry) => entry.endsWith('.yaml'))
306
+ .map((entry) => entry.slice(0, -'.yaml'.length));
307
+ }
308
+ /** Load a legacy dynamic or static preset without scenario dispatch. */
309
+ function loadNonScenario(name, params, ports) {
310
+ const builders = dynamicBuilders();
311
+ const builder = builders[name];
312
+ if (builder !== undefined)
313
+ return builder(params, ports);
314
+ const builtin = config.dataPath('presets', `${name}.yaml`);
315
+ if (!fs.existsSync(builtin) || !fs.statSync(builtin).isFile()) {
316
+ throw new Error(`unknown preset ${(0, format_1.quotedText)(name)} (run \`houston presets\` to list)`);
317
+ }
318
+ return parse(fs.readFileSync(builtin, 'utf8'), 'built-in');
319
+ }
320
+ /**
321
+ * Return a preset by name.
322
+ *
323
+ * Precedence: a user file (~/.houston/presets/<name>.yaml) wins over everything -- so
324
+ * users can override even a dynamic preset like `ldap`/`saml`. Otherwise a dynamic preset
325
+ * is built from `params`, else the built-in YAML is used.
326
+ *
327
+ * `ports` is the workspace's side ports, sparse (`common.presetPorts`): the default `{}`
328
+ * builds every preferred port, which is right for the catalogue and for validation, and
329
+ * wrong for anything that publishes or links a workspace's own.
330
+ */
331
+ function load(name, params, ports = {}) {
332
+ const given = params ?? {};
333
+ const file = userPath(name);
334
+ if (fs.existsSync(file))
335
+ return parse(fs.readFileSync(file, 'utf8'), file);
336
+ const scenario = scenarioDefinitions()[name];
337
+ if (scenario !== undefined)
338
+ return scenario.resolve(given, RUNTIME_DEFAULT, ports);
339
+ return loadNonScenario(name, given, ports);
340
+ }
341
+ /**
342
+ * `build`, with a preset's own refusal of its input made a usage error. A bad `--set`
343
+ * (`users=abc`, `tls=bogus`, `mfa=on` without an idp) or an unknown preset is a plain Error
344
+ * from the preset that met it; alone, `load`'s caller wraps it, and in a combination it
345
+ * escaped as "unhandled" -- exit 1 and a stack trace for a typo. A ReproError is already
346
+ * what it means to be.
347
+ */
348
+ function asValidation(build) {
349
+ try {
350
+ return build();
351
+ }
352
+ catch (error) {
353
+ if (error instanceof errors_1.ReproError)
354
+ throw error;
355
+ throw new errors_1.ValidationError(error instanceof Error ? error.message : String(error));
356
+ }
357
+ }
358
+ /**
359
+ * Several presets as one workspace's: each resolved for `runtime` with its own params, then
360
+ * composed (see `composite.ts`). A single name is exactly `load` or `resolve` of it.
361
+ *
362
+ * A directory composed with an SSO preset gets SSO users named apart, `sso-user1` with
363
+ * `sso-user1@example.com`: SAML merges into an existing account by email, so two stores
364
+ * sharing `user1@example.com` would quietly become one (owner decision, 2026-10-08).
365
+ */
366
+ function loadMany(names, params, runtime, overridden = new Set(), ports = {}) {
367
+ const unique = (0, composite_1.namesOf)((0, composite_1.compositeName)(names));
368
+ const apart = unique.includes('ldap');
369
+ const resolved = unique.map((name) => {
370
+ const own = { ...(params[name] ?? {}) };
371
+ if (apart && (name === 'saml' || name === 'oidc'))
372
+ own[keycloak_1.USER_PREFIX_PARAM] = 'sso-';
373
+ return asValidation(() => runtime === 'kubernetes' ? resolve(name, runtime, own, ports) : load(name, own, ports));
374
+ });
375
+ return (0, composite_1.composePresets)(resolved, overridden);
376
+ }
377
+ /**
378
+ * Resolve one preset through its built-in scenario adapter when present.
379
+ *
380
+ * `deploymentType` is an internal seam. Leaving it unset preserves the current catalogue
381
+ * behaviour and uses the preset's own declared topology. A user YAML override always wins
382
+ * and is never interpreted as a scenario.
383
+ */
384
+ function resolve(name, deploymentType, params, ports = {}) {
385
+ const given = params ?? {};
386
+ const file = userPath(name);
387
+ let preset;
388
+ if (fs.existsSync(file)) {
389
+ preset = parse(fs.readFileSync(file, 'utf8'), file);
390
+ }
391
+ else {
392
+ const scenario = scenarioDefinitions()[name];
393
+ if (scenario !== undefined) {
394
+ const target = deploymentType !== null && deploymentType !== undefined && deploymentType !== ''
395
+ ? deploymentType
396
+ : RUNTIME_DEFAULT;
397
+ return scenario.resolve(given, target, ports);
398
+ }
399
+ preset = loadNonScenario(name, given, ports);
400
+ }
401
+ // Enforced only when the preset actually declares a requirement.
402
+ if (deploymentType !== null &&
403
+ deploymentType !== undefined &&
404
+ deploymentType !== '' &&
405
+ preset.topology !== '' &&
406
+ preset.topology !== deploymentType) {
407
+ throw new Error(`preset ${(0, format_1.quotedText)(name)} declares deployment type ${(0, format_1.quotedText)(preset.topology)}, ` +
408
+ `not ${(0, format_1.quotedText)(deploymentType)}`);
409
+ }
410
+ return preset;
411
+ }
412
+ /**
413
+ * All available presets, user files shadowing built-ins, sorted by name.
414
+ *
415
+ * Three things here are the established behaviour and were not, each measured through
416
+ * `houston presets` against the frozen CLI (t1-presets). BOTH SORTS are by code point:
417
+ * user presets named `😀-emoji` and `A-fullwidth` printed in opposite orders, and of two
418
+ * files declaring one name, the one sorted last wins -- a different one here. `seen` is a
419
+ * Map: a preset named `__proto__` set a plain object's prototype and vanished from the
420
+ * list. And an unreadable file is named in the established words: the stem of a file
421
+ * called `.yaml` is `.yaml` (a leading dot is no suffix), and a read that fails says
422
+ * `<path>: Is a directory`, not Node's `EISDIR: ...`.
423
+ */
424
+ function listPresets() {
425
+ const seen = new Map();
426
+ const builtinDir = config.dataPath('presets');
427
+ for (const entry of fs.readdirSync(builtinDir)) {
428
+ if (!entry.endsWith('.yaml'))
429
+ continue;
430
+ const p = parse(fs.readFileSync(path.join(builtinDir, entry), 'utf8'), 'built-in');
431
+ seen.set(p.name, p);
432
+ }
433
+ for (const [name, build] of Object.entries(dynamicBuilders())) {
434
+ // Not listed: multi-instance is the deployment shape (`--deployment multi-instance`),
435
+ // which both front-ends offer as such. It stays loadable, for `--preset multi-instance`
436
+ // (which still works, with a hint) and for the workspaces that recorded it.
437
+ if (name === 'multi-instance')
438
+ continue;
439
+ // Default params and preferred ports, just for description/params_help: the catalogue
440
+ // names no workspace.
441
+ seen.set(name, build({}, {}));
442
+ }
443
+ const userDir = config.presetDir();
444
+ if (fs.existsSync(userDir)) {
445
+ // A directory that cannot be listed, or a presets path that is a FILE, yields no user
446
+ // presets -- the error is swallowed; `readdirSync` threw, and `houston presets`
447
+ // printed a stack where it must print the catalogue.
448
+ let entries = [];
449
+ try {
450
+ entries = fs.readdirSync(userDir);
451
+ }
452
+ catch (error) {
453
+ if (typeof error.errno !== 'number')
454
+ throw error;
455
+ }
456
+ const files = entries.filter((entry) => entry.endsWith('.yaml')).sort(format_1.compareCodePoints);
457
+ for (const entry of files) {
458
+ const file = (0, home_1.joinPath)(userDir, entry);
459
+ const stem = entry === '.yaml' ? entry : entry.slice(0, -'.yaml'.length);
460
+ // PER FILE, because one bad one used to take out the whole catalogue: this feeds
461
+ // `houston presets`, `/api/presets` and the create dialog, and `capabilities`
462
+ // swallows the exception and reports ZERO presets. A file somebody is halfway
463
+ // through writing must not do that. Reported the way `backup.listBackups` reports an
464
+ // unreadable bundle -- named, not hidden.
465
+ try {
466
+ // A strict decode: a file that is not UTF-8 is a `NotUtf8` refusal, and so
467
+ // UNREADABLE, where `readFileSync(file, 'utf8')` put a U+FFFD in and printed the box.
468
+ const p = parse((0, format_1.decodeUtf8Strict)(fs.readFileSync(file), file), file);
469
+ seen.set(p.name, p);
470
+ }
471
+ catch (error) {
472
+ // Every refusal is reported per file except a TypeError -- `toInt(null)` for
473
+ // `ports: [null]` -- which ends the command, as it always has.
474
+ if (error instanceof TypeError)
475
+ throw error;
476
+ const message = typeof error.errno === 'number'
477
+ ? (0, format_1.fileErrorText)(error, file)
478
+ : error instanceof Error
479
+ ? error.message
480
+ : String(error);
481
+ seen.set(stem, {
482
+ ...(0, types_1.emptyPreset)(stem),
483
+ description: `UNREADABLE — ${message}`,
484
+ error: message,
485
+ });
486
+ }
487
+ }
488
+ }
489
+ return [...seen.keys()].sort(format_1.compareCodePoints).map((key) => seen.get(key));
490
+ }