@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,432 @@
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.UnknownProfileError = void 0;
37
+ exports.roomSpec = roomSpec;
38
+ exports.isPrivate = isPrivate;
39
+ exports.replies = replies;
40
+ exports.reacted = reacted;
41
+ exports.totalMessages = totalMessages;
42
+ exports.dms = dms;
43
+ exports.rich = rich;
44
+ exports.planTotalMessages = planTotalMessages;
45
+ exports.planTotalReplies = planTotalReplies;
46
+ exports.byKind = byKind;
47
+ exports.named = named;
48
+ exports.planFrom = planFrom;
49
+ exports.made = made;
50
+ exports.roomFacts = roomFacts;
51
+ /**
52
+ * The manifest: what will exist when seeding finishes, decided before anything is created.
53
+ *
54
+ * Tier 2. `RoomSpec` and `Plan` are readonly interfaces, and their derived PROPERTIES free
55
+ * functions, because a plain object is what crosses to the readback and to `repro.json`,
56
+ * and a class would have to be unwrapped at each of those boundaries.
57
+ */
58
+ const format_1 = require("../lib/format");
59
+ const seed_profiles_1 = require("../lib/seed-profiles");
60
+ const seed_options_1 = require("../lib/seed-options");
61
+ const errors_1 = require("../lib/errors");
62
+ const kinds_1 = require("./kinds");
63
+ const wording = __importStar(require("./wording"));
64
+ function roomSpec(values) {
65
+ return {
66
+ members: [],
67
+ messages: 0,
68
+ threads: [],
69
+ reactions: [],
70
+ parent: '',
71
+ fromMessage: -1,
72
+ replyCount: 1,
73
+ files: [],
74
+ content: [],
75
+ ...values,
76
+ };
77
+ }
78
+ function isPrivate(spec) {
79
+ return kinds_1.PRIVATE_KINDS.includes(spec.kind);
80
+ }
81
+ function replies(spec) {
82
+ return spec.threads.length * spec.replyCount;
83
+ }
84
+ function reacted(spec) {
85
+ return spec.reactions.length;
86
+ }
87
+ /**
88
+ * Messages that will exist in the room: the base ones, the replies, and the opening line
89
+ * of a discussion that was created from a message.
90
+ *
91
+ * A threaded reply IS a message in the room -- `channels.messages` returns it with a
92
+ * `tmid` -- so a count that omits it does not match what the server reports, which is
93
+ * exactly the mismatch a verifier would report as a fault.
94
+ *
95
+ * A discussion opened from a message is the same trap one level down: it arrives holding
96
+ * `ANCHOR_MESSAGES` before anyone posts into it, and leaving those out made every
97
+ * message-anchored discussion report more than planned on a perfectly good seed.
98
+ */
99
+ function totalMessages(spec) {
100
+ return (spec.messages +
101
+ replies(spec) +
102
+ spec.files.length +
103
+ (spec.fromMessage >= 0 ? kinds_1.ANCHOR_MESSAGES : 0));
104
+ }
105
+ function dms(plan) {
106
+ return plan.rooms.filter((r) => r.kind === kinds_1.DM).length;
107
+ }
108
+ /** Kept for callers that ask whether this profile does threads/reactions. */
109
+ function rich(plan) {
110
+ return plan.reactions;
111
+ }
112
+ function planTotalMessages(plan) {
113
+ return plan.rooms.reduce((sum, r) => sum + totalMessages(r), 0);
114
+ }
115
+ function planTotalReplies(plan) {
116
+ return plan.rooms.reduce((sum, r) => sum + replies(r), 0);
117
+ }
118
+ function byKind(plan) {
119
+ const out = {};
120
+ for (const r of plan.rooms)
121
+ out[r.kind] = (out[r.kind] ?? 0) + 1;
122
+ return out;
123
+ }
124
+ function named(plan, name) {
125
+ return plan.rooms.find((r) => r.name === name) ?? null;
126
+ }
127
+ /** The discussions hung off the rooms that can carry one, and the DMs between users. */
128
+ function discussionsAndDms(add, names, rooms, shape) {
129
+ const categories = [kinds_1.CHANNEL, kinds_1.PRIVATE, kinds_1.TEAM, kinds_1.TEAM_PRIVATE, kinds_1.TEAM_CHANNEL, kinds_1.TEAM_CHANNEL_PRIVATE];
130
+ const parents = categories.flatMap((kind) => rooms.filter((r) => r.kind === kind).slice(0, 1));
131
+ for (let d = 0; d < shape.discussions; d += 1) {
132
+ if (parents.length === 0)
133
+ break;
134
+ const parent = parents[d % parents.length];
135
+ // Alternating: half are opened FROM a message (which is how a support engineer usually
136
+ // makes one, and which leaves a different system message in the parent), half against
137
+ // the room itself.
138
+ add(kinds_1.DISCUSSION, wording.poolName(wording.DISCUSSION_NAMES, d, ' '), 3, Math.max(2, Math.floor(shape.messages / 4)), {
139
+ parent: parent.name,
140
+ members: parent.members.slice(0, 3),
141
+ fromMessage: d % 2 === 0 && parent.messages > 0 ? 0 : -1,
142
+ });
143
+ }
144
+ // Capped at the number of DISTINCT pairs: `im.create` for a pair that already has a room
145
+ // returns that same room, so asking for five DMs from two users produced five records
146
+ // pointing at one or two rooms -- and the verification then reported rooms as short that
147
+ // were simply the same room counted twice.
148
+ const n = names.length;
149
+ const wanted = Math.min(shape.dms, Math.floor((n * (n - 1)) / 2));
150
+ for (let i = 0; i < wanted; i += 1) {
151
+ if (n < 2)
152
+ break;
153
+ const [a, b] = wording.dmPair(names, i);
154
+ const msgs = Math.max(2, Math.floor(shape.messages / 5));
155
+ rooms.push(roomSpec({
156
+ kind: kinds_1.DM,
157
+ name: `${a}~${b}`,
158
+ members: [a, b],
159
+ messages: msgs,
160
+ replyCount: shape.replyCount,
161
+ threads: wording.threads(msgs),
162
+ reactions: shape.reactions ? wording.threads(msgs, kinds_1.REACT_EVERY) : [],
163
+ }));
164
+ }
165
+ let groups = 0;
166
+ for (let a = 0; a < names.length && groups < shape.groupDms; a += 1) {
167
+ for (let b = a + 1; b < names.length && groups < shape.groupDms; b += 1) {
168
+ for (let c = b + 1; c < names.length && groups < shape.groupDms; c += 1) {
169
+ const members = [names[a], names[b], names[c]];
170
+ const messages = Math.max(3, Math.floor(shape.messages * (shape.replyCount === 5 ? 0.15 : 0.3)));
171
+ rooms.push(roomSpec({
172
+ kind: kinds_1.GROUP_DM,
173
+ name: members.join('~'),
174
+ members,
175
+ messages,
176
+ replyCount: shape.replyCount,
177
+ threads: wording.threads(messages),
178
+ reactions: shape.reactions ? wording.threads(messages, kinds_1.REACT_EVERY) : [],
179
+ }));
180
+ groups += 1;
181
+ }
182
+ }
183
+ }
184
+ }
185
+ /** The public and private channels, and the teams with their own channels inside. */
186
+ function channelsAndTeams(add, names, rooms, shape) {
187
+ for (let i = 0; i < shape.channels; i += 1) {
188
+ add(kinds_1.CHANNEL, wording.channelName(i), 4, shape.messages);
189
+ }
190
+ for (let i = 0; i < shape.private; i += 1) {
191
+ // Fewer messages: a private room's value here is that it EXISTS and is invisible to a
192
+ // non-member, not that it is busy.
193
+ add(kinds_1.PRIVATE, wording.privateName(i), 3, Math.max(3, Math.floor(shape.messages / 2)));
194
+ }
195
+ for (let t = 0; t < shape.teams; t += 1) {
196
+ // Alternating, so any profile with two or more teams has one of each. A private team is
197
+ // a different object from a private channel -- its main room is type `p` AND it owns
198
+ // other rooms -- and only one of the two is exercised by making every team public.
199
+ const tname = wording.teamName(t);
200
+ const team = add(t % 2 === 0 ? kinds_1.TEAM : kinds_1.TEAM_PRIVATE, tname, 4, Math.max(3, Math.floor(shape.messages / 2)));
201
+ for (let c = 0; c < shape.teamChannels; c += 1) {
202
+ add(c % 2 === 0 ? kinds_1.TEAM_CHANNEL : kinds_1.TEAM_CHANNEL_PRIVATE, wording.teamChannelName(t, c), 3, Math.max(3, Math.floor(shape.messages / 2)), {
203
+ parent: tname,
204
+ members: team.members.slice(c % Math.max(1, team.members.length - 2), (c % Math.max(1, team.members.length - 2)) + 3),
205
+ });
206
+ }
207
+ }
208
+ // Everyone is already in `general`, so it is the one room where the whole user list
209
+ // authors.
210
+ rooms.push(roomSpec({
211
+ kind: kinds_1.GENERAL,
212
+ name: 'general',
213
+ members: [...names],
214
+ messages: shape.messages,
215
+ replyCount: shape.replyCount,
216
+ threads: wording.threads(shape.messages),
217
+ reactions: shape.reactions ? wording.threads(shape.messages, kinds_1.REACT_EVERY) : [],
218
+ }));
219
+ }
220
+ /**
221
+ * Turn a shape into the concrete list of rooms, in CREATION order.
222
+ *
223
+ * Order matters and is part of the manifest: a team exists before its channels, and every
224
+ * discussion's parent exists before the discussion. Sorting this list later would break
225
+ * seeding, so nothing does.
226
+ */
227
+ function build(shape, names) {
228
+ const rooms = [];
229
+ let idx = 0;
230
+ const add = (kind, name, size, messages, extra = {}) => {
231
+ const spec = roomSpec({
232
+ kind,
233
+ name,
234
+ members: wording.members(names, idx, size),
235
+ messages,
236
+ threads: wording.threads(messages),
237
+ reactions: shape.reactions ? wording.threads(messages, kinds_1.REACT_EVERY) : [],
238
+ replyCount: shape.replyCount,
239
+ ...extra,
240
+ });
241
+ rooms.push(spec);
242
+ idx += 1;
243
+ return spec;
244
+ };
245
+ channelsAndTeams(add, names, rooms, shape);
246
+ discussionsAndDms(add, names, rooms, shape);
247
+ return rooms;
248
+ }
249
+ /**
250
+ * The planner's refusal of a profile that is not one of `PROFILES`.
251
+ *
252
+ * A class of its own so a caller translates THIS refusal and nothing else -- the CLI turns
253
+ * it into its error line and the GUI into a ValidationError. It was a bare `Error`, which
254
+ * the CLI seed let through as an
255
+ * unhandled failure: a JavaScript stack, "this is unhandled", `trace: true` in the log, for
256
+ * a typo in `--profile`.
257
+ */
258
+ class UnknownProfileError extends Error {
259
+ constructor(message) {
260
+ super(message);
261
+ this.name = 'UnknownProfile';
262
+ Object.setPrototypeOf(this, new.target.prototype);
263
+ }
264
+ }
265
+ exports.UnknownProfileError = UnknownProfileError;
266
+ function planFrom(profile, overrides = {}) {
267
+ // Only `PROFILES`' own keys. An index reaches through the prototype, so
268
+ // `--profile constructor` found `Object` and built a plan of undefined counts, and the
269
+ // profile is quoted by `quotedText`.
270
+ const base = Object.hasOwn(seed_profiles_1.PROFILES, profile) ? seed_profiles_1.PROFILES[profile] : undefined;
271
+ if (base === undefined) {
272
+ throw new UnknownProfileError(`unknown seed profile ${(0, format_1.quotedText)(profile)} (want ${Object.keys(seed_profiles_1.PROFILES).join(' | ')})`);
273
+ }
274
+ const pick = (given, fallback) => given === null || given === undefined ? fallback : Math.max(0, given);
275
+ const shape = {
276
+ ...base,
277
+ users: pick(overrides.users, base.users),
278
+ channels: pick(overrides.channels, base.channels),
279
+ messages: pick(overrides.messages, base.messages),
280
+ };
281
+ const names = [];
282
+ for (let i = 0; i < shape.users; i += 1)
283
+ names.push(wording.username(i));
284
+ const selection = (0, seed_options_1.seedSelection)(overrides.scenarios, overrides.historyDays);
285
+ for (const scenario of selection.scenarios)
286
+ if (names.length < seed_options_1.SCENARIOS[scenario].minimumUsers)
287
+ throw new errors_1.ValidationError(`the ${scenario} scenario requires at least ${seed_options_1.SCENARIOS[scenario].minimumUsers} seeded users`);
288
+ const rooms = build(shape, names);
289
+ if (selection.scenarios.includes('room-states')) {
290
+ for (const [kind, name] of [
291
+ [kinds_1.READ_ONLY, 'seed-read-only'],
292
+ [kinds_1.BROADCAST, 'seed-broadcast'],
293
+ [kinds_1.ARCHIVED, 'seed-archived'],
294
+ ]) {
295
+ rooms.push(roomSpec({
296
+ kind: kind,
297
+ name: name,
298
+ members: names.slice(0, 3),
299
+ messages: 5,
300
+ replyCount: 0,
301
+ }));
302
+ }
303
+ }
304
+ if (selection.scenarios.includes('permissions')) {
305
+ rooms.push(roomSpec({
306
+ kind: kinds_1.PERMISSIONS,
307
+ name: 'seed-permissions',
308
+ members: names.slice(0, 3),
309
+ messages: 5,
310
+ replyCount: 0,
311
+ }));
312
+ }
313
+ const customEmoji = Array.from({ length: shape.emoji }, (_, i) => `houston_seed_${i + 1}`);
314
+ for (let i = 0; i < rooms.length; i += 1) {
315
+ const room = rooms[i];
316
+ if (room.members.length < 2)
317
+ rooms[i] = { ...room, threads: [], replyCount: 0, reactions: [] };
318
+ }
319
+ const fileKinds = [kinds_1.CHANNEL, kinds_1.PRIVATE, kinds_1.DISCUSSION, kinds_1.TEAM, kinds_1.TEAM_CHANNEL, kinds_1.DM];
320
+ for (let i = 0; i < shape.fileSets; i += 1) {
321
+ const room = rooms.find((r) => r.kind === fileKinds[i]);
322
+ if (room !== undefined)
323
+ rooms[rooms.indexOf(room)] = { ...room, files: ['png', 'txt', 'pdf', 'csv'] };
324
+ }
325
+ let edits = shape.edits;
326
+ let serial = 0;
327
+ const detailed = rooms.map((room) => {
328
+ const scenario = [kinds_1.READ_ONLY, kinds_1.BROADCAST, kinds_1.ARCHIVED, kinds_1.PERMISSIONS].includes(room.kind);
329
+ const content = [];
330
+ for (let i = 0; i < room.messages; i += 1) {
331
+ const author = room.kind === kinds_1.BROADCAST ? '' : (room.members[i % Math.max(1, room.members.length)] ?? '');
332
+ const others = room.members.filter((n) => n !== author);
333
+ const mention = i === 0 && !scenario ? (others[0] ?? '') : '';
334
+ const custom = customEmoji[serial % customEmoji.length];
335
+ const text = wording.conversation(room.name, i, mention, i === 0 && !scenario ? custom : '');
336
+ const actions = [];
337
+ if (room.reactions.includes(i) && others.length > 0) {
338
+ const emoji = i === 0 ? `:${custom}:` : wording.EMOJI[i % wording.EMOJI.length];
339
+ actions.push({ author: others[0], emoji });
340
+ if (others.length > 1)
341
+ actions.push({ author: others[1], emoji });
342
+ actions.push({ author: others[0], emoji: ':white_check_mark:' });
343
+ }
344
+ const editedText = edits > 0 ? `${text}\n\nUpdate: evidence attached; next checkpoint confirmed.` : '';
345
+ if (edits > 0)
346
+ edits -= 1;
347
+ const main = {
348
+ key: `main-${i}`,
349
+ kind: 'main',
350
+ author,
351
+ text,
352
+ parent: '',
353
+ reactions: actions,
354
+ pin: i === 0 && ![kinds_1.DM, kinds_1.GROUP_DM].includes(room.kind),
355
+ star: i === 0 && !scenario ? author : '',
356
+ mention,
357
+ editedText,
358
+ file: '',
359
+ };
360
+ content.push(main);
361
+ if (room.threads.includes(i)) {
362
+ for (let j = 0; j < room.replyCount; j += 1) {
363
+ content.push({
364
+ key: `reply-${i}-${j}`,
365
+ kind: 'reply',
366
+ author: others[j % Math.max(1, others.length)] ?? author,
367
+ text: wording.threadReply(room.name, i, j),
368
+ parent: main.key,
369
+ reactions: [],
370
+ pin: false,
371
+ star: '',
372
+ mention: '',
373
+ editedText: '',
374
+ file: '',
375
+ });
376
+ }
377
+ }
378
+ serial += 1;
379
+ }
380
+ for (const file of room.files)
381
+ content.push({
382
+ key: `file-${file}`,
383
+ kind: 'file',
384
+ author: room.members[0] ?? '',
385
+ text: `INC-4821 ${room.name}: sample ${file.toUpperCase()} evidence`,
386
+ parent: '',
387
+ reactions: [],
388
+ pin: false,
389
+ star: '',
390
+ mention: '',
391
+ editedText: '',
392
+ file,
393
+ });
394
+ return { ...room, content };
395
+ });
396
+ return {
397
+ profile,
398
+ users: shape.users,
399
+ channels: shape.channels,
400
+ messages: shape.messages,
401
+ reactions: shape.reactions,
402
+ rooms: detailed,
403
+ customEmoji,
404
+ ...selection,
405
+ };
406
+ }
407
+ function made(spec) {
408
+ return {
409
+ spec,
410
+ rid: '',
411
+ teamId: '',
412
+ reused: false,
413
+ messages: 0,
414
+ replies: 0,
415
+ reactions: 0,
416
+ failed: '',
417
+ messageIds: [],
418
+ };
419
+ }
420
+ function roomFacts(spec) {
421
+ return {
422
+ spec,
423
+ found: false,
424
+ rid: '',
425
+ messages: 0,
426
+ replies: 0,
427
+ reacted: 0,
428
+ threads: 0,
429
+ inTeam: true,
430
+ unreadable: '',
431
+ };
432
+ }