@solidxai/core 0.1.22-beta.4 → 0.1.22

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 (126) hide show
  1. package/CHANGELOG.md +808 -0
  2. package/dist/controllers/admin-embed.controller.d.ts +5 -0
  3. package/dist/controllers/admin-embed.controller.d.ts.map +1 -0
  4. package/dist/controllers/admin-embed.controller.js +58 -0
  5. package/dist/controllers/admin-embed.controller.js.map +1 -0
  6. package/dist/controllers/agent-registry.controller.d.ts +1 -7
  7. package/dist/controllers/agent-registry.controller.d.ts.map +1 -1
  8. package/dist/controllers/agent-registry.controller.js +1 -1
  9. package/dist/controllers/agent-session.controller.d.ts +1 -1
  10. package/dist/controllers/agent-session.controller.d.ts.map +1 -1
  11. package/dist/controllers/agent-session.controller.js +25 -3
  12. package/dist/controllers/agent-session.controller.js.map +1 -1
  13. package/dist/controllers/authentication.controller.d.ts +12 -1
  14. package/dist/controllers/authentication.controller.d.ts.map +1 -1
  15. package/dist/controllers/authentication.controller.js +26 -2
  16. package/dist/controllers/authentication.controller.js.map +1 -1
  17. package/dist/guards/access-token.guard.d.ts +3 -1
  18. package/dist/guards/access-token.guard.d.ts.map +1 -1
  19. package/dist/guards/access-token.guard.js +11 -2
  20. package/dist/guards/access-token.guard.js.map +1 -1
  21. package/dist/interfaces/active-user-data.interface.d.ts +1 -0
  22. package/dist/interfaces/active-user-data.interface.d.ts.map +1 -1
  23. package/dist/interfaces/active-user-data.interface.js.map +1 -1
  24. package/dist/resources/admin-embed/solid-admin-embed.js +133 -0
  25. package/dist/seeders/seed-data/solid-core-metadata.json +99 -2
  26. package/dist/services/agent-hub-process-manager.service.d.ts +13 -1
  27. package/dist/services/agent-hub-process-manager.service.d.ts.map +1 -1
  28. package/dist/services/agent-hub-process-manager.service.js +10 -2
  29. package/dist/services/agent-hub-process-manager.service.js.map +1 -1
  30. package/dist/services/agent-registry.service.d.ts +1 -7
  31. package/dist/services/agent-registry.service.d.ts.map +1 -1
  32. package/dist/services/agent-registry.service.js +5 -1
  33. package/dist/services/agent-registry.service.js.map +1 -1
  34. package/dist/services/api-key-portal-session.spec.d.ts +2 -0
  35. package/dist/services/api-key-portal-session.spec.d.ts.map +1 -0
  36. package/dist/services/api-key-portal-session.spec.js +71 -0
  37. package/dist/services/api-key-portal-session.spec.js.map +1 -0
  38. package/dist/services/api-key.service.d.ts +12 -0
  39. package/dist/services/api-key.service.d.ts.map +1 -1
  40. package/dist/services/api-key.service.js +58 -0
  41. package/dist/services/api-key.service.js.map +1 -1
  42. package/dist/services/authentication.service.d.ts +1 -0
  43. package/dist/services/authentication.service.d.ts.map +1 -1
  44. package/dist/services/authentication.service.js +14 -1
  45. package/dist/services/authentication.service.js.map +1 -1
  46. package/dist/services/settings/default-settings-provider.service.d.ts +4 -4
  47. package/dist/services/settings/default-settings-provider.service.js +2 -2
  48. package/dist/services/settings/default-settings-provider.service.js.map +1 -1
  49. package/dist/solid-core.module.d.ts.map +1 -1
  50. package/dist/solid-core.module.js +2 -0
  51. package/dist/solid-core.module.js.map +1 -1
  52. package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
  53. package/dist/testing/adapters/ui/playwright-adapter.js +3 -1
  54. package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
  55. package/dist/testing/contracts/runtime-context.types.d.ts +7 -0
  56. package/dist/testing/contracts/runtime-context.types.d.ts.map +1 -1
  57. package/dist/testing/contracts/runtime-context.types.js.map +1 -1
  58. package/dist/testing/core/interpolation.d.ts.map +1 -1
  59. package/dist/testing/core/interpolation.js +14 -2
  60. package/dist/testing/core/interpolation.js.map +1 -1
  61. package/dist/testing/core/step-data.d.ts +5 -0
  62. package/dist/testing/core/step-data.d.ts.map +1 -0
  63. package/dist/testing/core/step-data.js +14 -0
  64. package/dist/testing/core/step-data.js.map +1 -0
  65. package/dist/testing/core/step-data.spec.d.ts +2 -0
  66. package/dist/testing/core/step-data.spec.d.ts.map +1 -0
  67. package/dist/testing/core/step-data.spec.js +48 -0
  68. package/dist/testing/core/step-data.spec.js.map +1 -0
  69. package/dist/testing/core/testing-engine.d.ts.map +1 -1
  70. package/dist/testing/core/testing-engine.js +13 -8
  71. package/dist/testing/core/testing-engine.js.map +1 -1
  72. package/dist/testing/reporter/lifecycle-events.types.d.ts +2 -1
  73. package/dist/testing/reporter/lifecycle-events.types.d.ts.map +1 -1
  74. package/dist/testing/reporter/lifecycle-events.types.js.map +1 -1
  75. package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts +2 -1
  76. package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts.map +1 -1
  77. package/dist/testing/reporter/lifecycle-webhook-reporter.js +1 -0
  78. package/dist/testing/reporter/lifecycle-webhook-reporter.js.map +1 -1
  79. package/dist/testing/reporter/reporter.types.d.ts +2 -1
  80. package/dist/testing/reporter/reporter.types.d.ts.map +1 -1
  81. package/dist/testing/reporter/reporter.types.js.map +1 -1
  82. package/dist/testing/runner/run-from-metadata.d.ts.map +1 -1
  83. package/dist/testing/runner/run-from-metadata.js +39 -9
  84. package/dist/testing/runner/run-from-metadata.js.map +1 -1
  85. package/dist/testing/runner/run-from-metadata.spec.js +29 -0
  86. package/dist/testing/runner/run-from-metadata.spec.js.map +1 -1
  87. package/dist/testing/runner/scenario-graph.d.ts +9 -0
  88. package/dist/testing/runner/scenario-graph.d.ts.map +1 -1
  89. package/dist/testing/runner/scenario-graph.js +47 -13
  90. package/dist/testing/runner/scenario-graph.js.map +1 -1
  91. package/dist/testing/steps/ui/navigation.step.d.ts.map +1 -1
  92. package/dist/testing/steps/ui/navigation.step.js +4 -1
  93. package/dist/testing/steps/ui/navigation.step.js.map +1 -1
  94. package/dist/testing/steps/util/random.step.d.ts.map +1 -1
  95. package/dist/testing/steps/util/random.step.js +4 -1
  96. package/dist/testing/steps/util/random.step.js.map +1 -1
  97. package/package.json +1 -1
  98. package/resources/admin-embed/solid-admin-embed.js +133 -0
  99. package/src/controllers/admin-embed.controller.ts +34 -0
  100. package/src/controllers/agent-session.controller.ts +19 -3
  101. package/src/controllers/authentication.controller.ts +20 -1
  102. package/src/guards/access-token.guard.ts +11 -1
  103. package/src/interfaces/active-user-data.interface.ts +3 -0
  104. package/src/seeders/seed-data/solid-core-metadata.json +100 -3
  105. package/src/services/agent-hub-process-manager.service.ts +12 -2
  106. package/src/services/agent-registry.service.ts +4 -1
  107. package/src/services/api-key-portal-session.spec.ts +75 -0
  108. package/src/services/api-key.service.ts +61 -0
  109. package/src/services/authentication.service.ts +16 -2
  110. package/src/services/settings/default-settings-provider.service.ts +2 -2
  111. package/src/solid-core.module.ts +2 -0
  112. package/src/testing/adapters/ui/playwright-adapter.ts +5 -1
  113. package/src/testing/contracts/runtime-context.types.ts +16 -0
  114. package/src/testing/core/interpolation.ts +11 -2
  115. package/src/testing/core/step-data.spec.ts +59 -0
  116. package/src/testing/core/step-data.ts +14 -0
  117. package/src/testing/core/testing-engine.ts +6 -1
  118. package/src/testing/reporter/lifecycle-events.types.ts +3 -1
  119. package/src/testing/reporter/lifecycle-webhook-reporter.ts +3 -1
  120. package/src/testing/reporter/reporter.types.ts +3 -1
  121. package/src/testing/runner/run-from-metadata.spec.ts +33 -0
  122. package/src/testing/runner/run-from-metadata.ts +53 -16
  123. package/src/testing/runner/scenario-graph.ts +55 -12
  124. package/src/testing/steps/ui/navigation.step.ts +4 -1
  125. package/src/testing/steps/util/random.step.ts +4 -1
  126. package/src/entities/media-migration-plan.md +0 -20
@@ -2109,6 +2109,15 @@ export class AuthenticationService {
2109
2109
  };
2110
2110
  }
2111
2111
 
2112
+ async generatePortalAccessToken(user: User, apiKeyId: number, expiresIn: number) {
2113
+ return this.signToken<Partial<ActiveUserData>>(user.id, expiresIn, {
2114
+ username: user.username,
2115
+ email: user.email,
2116
+ roles: user.roles.map((role) => role.name),
2117
+ portalApiKeyId: apiKeyId,
2118
+ });
2119
+ }
2120
+
2112
2121
  async generateAccessToken(user: User, sessionId?: string, deviceKey?: string) {
2113
2122
  // const userRoleNames = user.roles.map((role) => role.name).join(';')
2114
2123
  const userRoleNames = user.roles.map((role) => role.name);
@@ -2832,8 +2841,9 @@ export class AuthenticationService {
2832
2841
  // Get the refresh token for a user from refresh token storage. The bucket
2833
2842
  // is named by the access token's own deviceKey claim; absent for
2834
2843
  // single-slot sessions, which resolves to the same key as before.
2835
- const refreshTokenState =
2836
- await this.refreshTokenIdsStorage.getCurrentRefreshTokenState(
2844
+ const refreshTokenState = activeUser.portalApiKeyId
2845
+ ? null
2846
+ : await this.refreshTokenIdsStorage.getCurrentRefreshTokenState(
2837
2847
  user.id,
2838
2848
  activeUser.deviceKey,
2839
2849
  );
@@ -2864,6 +2874,10 @@ export class AuthenticationService {
2864
2874
  activeUser: ActiveUserData,
2865
2875
  rawAccessToken: string,
2866
2876
  ): Promise<{ ssoCode: string }> {
2877
+ if (activeUser.portalApiKeyId) {
2878
+ throw new ForbiddenException('An embedded session cannot create an SSO session');
2879
+ }
2880
+
2867
2881
  const refreshTokenState =
2868
2882
  await this.refreshTokenIdsStorage.getCurrentRefreshTokenState(
2869
2883
  activeUser.sub,
@@ -450,12 +450,12 @@ const getSolidCoreSettings = (isProd: boolean) =>
450
450
  moduleName: "solid-core",
451
451
  key: "solidAgentEnabled",
452
452
  value: process.env.SOLIDX_AGENT_ENABLED === "true",
453
- level: SettingLevel.SystemAdminReadonly,
453
+ level: SettingLevel.SystemAdminEditable,
454
454
  label: "SolidX Agent Enabled",
455
455
  group: "ai-settings",
456
456
  sortOrder: 40,
457
457
  controlType: "boolean",
458
- helpText: "Shows the floating SolidX Agent launcher in the admin UI for users with the agent:invoke permission.",
458
+ helpText: "Shows the floating SolidX Agent launcher in the admin UI for users with the agent:invoke permission. Starts from SOLIDX_AGENT_ENABLED in .env; once changed here, this value is used.",
459
459
  },
460
460
  {
461
461
  moduleName: "solid-core",
@@ -520,6 +520,7 @@ import { AgentHumanRequest } from "./entities/agent-human-request.entity";
520
520
  import { AgentConfigVersion } from "./entities/agent-config-version.entity";
521
521
  import { AgentRegistryController } from "./controllers/agent-registry.controller";
522
522
  import { AgentEmbedController } from './controllers/agent-embed.controller';
523
+ import { AdminEmbedController } from './controllers/admin-embed.controller';
523
524
  import { AgentToolRegistryController } from "./controllers/agent-tool-registry.controller";
524
525
  import { AgentSkillRegistryController } from "./controllers/agent-skill-registry.controller";
525
526
  import { AgentHubTagController } from "./controllers/agent-hub-tag.controller";
@@ -773,6 +774,7 @@ import { AgentToolRegistryService } from "./services/agent-tool-registry.service
773
774
  SecretController,
774
775
  AgentRegistryController,
775
776
  AgentEmbedController,
777
+ AdminEmbedController,
776
778
  AgentToolRegistryController,
777
779
  AgentSkillRegistryController,
778
780
  AgentHubTagController,
@@ -160,7 +160,11 @@ export class PlaywrightAdapter {
160
160
  }
161
161
  this.context = await this.browser.newContext({
162
162
  ...contextViewportOptions(this.viewport),
163
- ...(this.videoDir ? { recordVideo: { dir: this.videoDir } } : {}),
163
+ // At the viewport's own size: without `size` Playwright scales the recording down to fit 800x800, so a 1920x1080
164
+ // run was recorded at about 800x450 and its text was unreadable.
165
+ ...(this.videoDir
166
+ ? { recordVideo: { dir: this.videoDir, size: this.viewport ? { width: this.viewport.width, height: this.viewport.height } : { width: 1280, height: 720 } } }
167
+ : {}),
164
168
  ...(storageState ? { storageState } : {}),
165
169
  });
166
170
  this.context.setDefaultTimeout(this.defaultTimeoutMs);
@@ -49,6 +49,22 @@ export interface TestContext {
49
49
  * (`steps[3].when`, `steps[5].then[1]`). Heal reports use it to address the step.
50
50
  */
51
51
  stepPath?: string;
52
+ /** Values the current step generated or extracted, reported with its result. Reset for every step. */
53
+ stepData?: StepDataUsed[];
54
+ }
55
+
56
+ /**
57
+ * A value a step made up or pulled out while it ran, so a run's results show the data it actually used: a
58
+ * `${random:...}` token or `util.random` value, or the text a `match` regex extracted (`| match:` or
59
+ * `ui.storeText`'s `match`). Values from secrets are never recorded.
60
+ */
61
+ export interface StepDataUsed {
62
+ kind: "random" | "match";
63
+ /** What produced it, e.g. `${random:emailAddress}`, `random:firstName`, `match:(\d{6})`. */
64
+ source: string;
65
+ value: string;
66
+ /** The resource name the step saved the value under, when it has one. */
67
+ saveAs?: string;
52
68
  }
53
69
 
54
70
  /**
@@ -4,6 +4,7 @@ import { resolveNow } from "./dates";
4
4
  import { parseCallToken } from "./call-args";
5
5
  import { parseRandomToken, randomDataFor } from "./random-data";
6
6
  import { findTokens, splitOutsideQuotes } from "./token-scan";
7
+ import { recordStepData } from "./step-data";
7
8
 
8
9
  function getByPath(obj: Record<string, any>, path: string): unknown {
9
10
  if (!path) return undefined;
@@ -175,11 +176,15 @@ function applyTransform(value: unknown, name: string, arg: string | undefined):
175
176
  function resolveTokenWithTransforms(token: string, ctx: TestContext): TokenResolution {
176
177
  // Split outside quotes, so a quoted `|` in an argument is not a transform.
177
178
  const [first, ...transforms] = splitOutsideQuotes(token, "|");
179
+ const base = first.trim();
178
180
  if (!transforms.length) {
179
- return resolveToken(token, ctx);
181
+ const resolved = resolveToken(token, ctx);
182
+ if (base.startsWith(RANDOM_PREFIX)) recordStepData(ctx, { kind: "random", source: `\${${token}}`, value: resolved.value });
183
+ return resolved;
180
184
  }
181
- const resolved = resolveToken(first.trim(), ctx);
185
+ const resolved = resolveToken(base, ctx);
182
186
  let value = resolved.value;
187
+ let matched = false;
183
188
  for (const rawTransform of transforms) {
184
189
  const t = rawTransform.trim();
185
190
  if (!t) continue;
@@ -187,7 +192,11 @@ function resolveTokenWithTransforms(token: string, ctx: TestContext): TokenResol
187
192
  const name = (colon === -1 ? t : t.slice(0, colon)).trim();
188
193
  const arg = colon === -1 ? undefined : t.slice(colon + 1).trim();
189
194
  value = applyTransform(value, name, arg);
195
+ if (name === "match") matched = true;
190
196
  }
197
+ // A value taken from a secret stays out of the report, even after a transform.
198
+ if (base.startsWith(RANDOM_PREFIX)) recordStepData(ctx, { kind: "random", source: `\${${token.trim()}}`, value });
199
+ else if (matched && !base.startsWith(SECRET_PREFIX)) recordStepData(ctx, { kind: "match", source: `\${${token.trim()}}`, value });
191
200
  return { value, raw: false };
192
201
  }
193
202
 
@@ -0,0 +1,59 @@
1
+ // Purpose: a run's results show the data its steps made up or pulled out — `${random:...}` tokens, `util.random`
2
+ // values and `match` extractions — on the step that used them, and never a secret.
3
+
4
+ import type { TestContext } from "../contracts/runtime-context.types";
5
+ import { RandomDataRegistry } from "./random-data";
6
+ import { SimpleResourceStore } from "./resource-store";
7
+ import { StepRegistry } from "./step-registry";
8
+ import { TestingEngine } from "./testing-engine";
9
+ import { registerUtilSteps } from "../steps/util";
10
+
11
+ function setup() {
12
+ const ended: any[] = [];
13
+ const registry = new StepRegistry();
14
+ registerUtilSteps(registry);
15
+ registry.register("test.echo", async (_ctx, step) => step.with);
16
+ const ctx = {
17
+ scenarioId: "spec",
18
+ scenarioType: "api",
19
+ params: {},
20
+ resources: new SimpleResourceStore(),
21
+ randomData: new RandomDataRegistry(),
22
+ secrets: { "app-otp-line": "Your code is 482913" },
23
+ reporter: { onStepStart: () => undefined, onStepEnd: (args: any) => ended.push(args) } as any,
24
+ } as TestContext;
25
+ return { engine: new TestingEngine(registry), ctx, ended };
26
+ }
27
+
28
+ describe("data used by a step", () => {
29
+ it("reports a util.random value with its saveAs name", async () => {
30
+ const { engine, ctx, ended } = setup();
31
+
32
+ const value = await engine.runStep("given" as any, { op: "util.random", with: { generator: "emailAddress" }, saveAs: "email" } as any, ctx);
33
+
34
+ expect(ended[0].data).toEqual([{ kind: "random", source: "random:emailAddress", value, saveAs: "email" }]);
35
+ });
36
+
37
+ it("reports inline random tokens and match transforms, on the step that resolved them only", async () => {
38
+ const { engine, ctx, ended } = setup();
39
+ ctx.resources.set("sms", "OTP 7731 is valid for 5 minutes");
40
+
41
+ const out: any = await engine.runStep("when" as any, { op: "test.echo", with: { name: "${random:firstName}", otp: "${res:sms | match:(\\d+)}" } } as any, ctx);
42
+ await engine.runStep("then" as any, { op: "test.echo", with: { plain: "${res:sms}" } } as any, ctx);
43
+
44
+ expect(ended[0].data).toEqual([
45
+ { kind: "random", source: "${random:firstName}", value: out.name },
46
+ { kind: "match", source: "${res:sms | match:(\\d+)}", value: "7731" },
47
+ ]);
48
+ expect(ended[1].data).toBeUndefined();
49
+ });
50
+
51
+ it("never reports a value taken from a secret", async () => {
52
+ const { engine, ctx, ended } = setup();
53
+
54
+ const out: any = await engine.runStep("when" as any, { op: "test.echo", with: { otp: "${secret:app-otp-line | match:(\\d+)}" } } as any, ctx);
55
+
56
+ expect(out.otp).toBe("482913");
57
+ expect(ended[0].data).toBeUndefined();
58
+ });
59
+ });
@@ -0,0 +1,14 @@
1
+ import type { StepDataUsed, TestContext } from "../contracts/runtime-context.types";
2
+
3
+ /** Longest value kept in a step's report; generated data is short, so this only guards against a whole page of text. */
4
+ const MAX_VALUE_LENGTH = 500;
5
+
6
+ /** Adds a value the current step generated or extracted to its report (see {@link StepDataUsed}). */
7
+ export function recordStepData(ctx: TestContext, entry: Omit<StepDataUsed, "value"> & { value: unknown }): void {
8
+ if (!ctx.stepData) return;
9
+ const text = typeof entry.value === "string" ? entry.value : JSON.stringify(entry.value) ?? String(entry.value);
10
+ ctx.stepData.push({
11
+ ...entry,
12
+ value: text.length > MAX_VALUE_LENGTH ? `${text.slice(0, MAX_VALUE_LENGTH)}…` : text,
13
+ });
14
+ }
@@ -165,7 +165,8 @@ export class TestingEngine {
165
165
  }
166
166
 
167
167
  const durationMs = Date.now() - scenarioStart;
168
- ctx.ui?.recordScenario({
168
+ // Only browser scenarios are in the run video: an API scenario shows nothing in it, so it gets no place there.
169
+ if (scenario.type === "ui") ctx.ui?.recordScenario({
169
170
  scenarioId: scenario.id,
170
171
  name: scenario.name,
171
172
  attempt,
@@ -251,6 +252,7 @@ export class TestingEngine {
251
252
  let result: unknown;
252
253
 
253
254
  ctx.stepPath = stepPath;
255
+ ctx.stepData = [];
254
256
  reporter.onStepStart({ scenarioId: ctx.scenarioId, phase, step, stepPath, ...(setup ? { setup } : {}) });
255
257
 
256
258
  try {
@@ -277,6 +279,8 @@ export class TestingEngine {
277
279
  const durationMs = Date.now() - stepStart;
278
280
  // Taken for every mobile step so the figure never carries over; only a slow one is worth reporting.
279
281
  const slowestCallMs = ctx.mobile?.takeSlowestCallMs() ?? 0;
282
+ const data = ctx.stepData ?? [];
283
+ ctx.stepData = undefined;
280
284
  reporter.onStepEnd({
281
285
  scenarioId: ctx.scenarioId,
282
286
  phase,
@@ -286,6 +290,7 @@ export class TestingEngine {
286
290
  durationMs,
287
291
  stepPath,
288
292
  ...(slowestCallMs >= SLOW_CALL_REPORT_MS ? { slowestCallMs } : {}),
293
+ ...(data.length ? { data } : {}),
289
294
  ...(setup ? { setup } : {}),
290
295
  });
291
296
  }
@@ -1,4 +1,4 @@
1
- import type { HealEvent } from "../contracts/runtime-context.types";
1
+ import type { HealEvent, StepDataUsed } from "../contracts/runtime-context.types";
2
2
  import type { ScenarioType } from "../contracts/testing-metadata.types";
3
3
 
4
4
  /**
@@ -40,6 +40,8 @@ export interface StepResultData {
40
40
  stepPath?: string;
41
41
  /** Mobile only: the longest single device lookup in the step, reported when it was slow (a stalled device). */
42
42
  slowestCallMs?: number;
43
+ /** Random values the step generated and text its `match` regexes extracted, so the results show the data used. */
44
+ data?: StepDataUsed[];
43
45
  /** Set for a step that ran as setup for the scenario ("reset", "login"), not as one of its own. */
44
46
  setup?: string;
45
47
  ok: boolean;
@@ -11,7 +11,7 @@ import type {
11
11
  StepResultData,
12
12
  } from "./lifecycle-events.types";
13
13
  import type { OpStep, ScenarioSpec, ScenarioType } from "../contracts/testing-metadata.types";
14
- import type { StepPhase } from "../contracts/runtime-context.types";
14
+ import type { StepDataUsed, StepPhase } from "../contracts/runtime-context.types";
15
15
  import type { ScenarioResult, ScenarioSkipInfo } from "./reporter.types";
16
16
 
17
17
  /**
@@ -160,6 +160,7 @@ export class LifecycleWebhookReporter extends ConsoleReporter {
160
160
  durationMs: number;
161
161
  stepPath?: string;
162
162
  slowestCallMs?: number;
163
+ data?: StepDataUsed[];
163
164
  setup?: string;
164
165
  }): void {
165
166
  super.onStepEnd(args);
@@ -169,6 +170,7 @@ export class LifecycleWebhookReporter extends ConsoleReporter {
169
170
  name: args.step.name,
170
171
  ...(args.stepPath ? { stepPath: args.stepPath } : {}),
171
172
  ...(args.slowestCallMs ? { slowestCallMs: args.slowestCallMs } : {}),
173
+ ...(args.data?.length ? { data: args.data } : {}),
172
174
  ...(args.setup ? { setup: args.setup } : {}),
173
175
  ok: args.ok,
174
176
  durationMs: args.durationMs,
@@ -1,4 +1,4 @@
1
- import type { HealEvent, StepPhase } from "../contracts/runtime-context.types";
1
+ import type { HealEvent, StepDataUsed, StepPhase } from "../contracts/runtime-context.types";
2
2
  import type { OpStep, ScenarioSpec, ScenarioType } from "../contracts/testing-metadata.types";
3
3
  import type { SolidTestSpecResult } from "../contracts/test-spec.types";
4
4
 
@@ -49,6 +49,8 @@ export interface Reporter {
49
49
  stepPath?: string;
50
50
  /** Mobile only: the longest single device lookup in the step, when it was slow enough to matter (a stalled device). */
51
51
  slowestCallMs?: number;
52
+ /** Random values the step generated and text its `match` regexes extracted. */
53
+ data?: StepDataUsed[];
52
54
  setup?: string;
53
55
  }): void;
54
56
  onSpecResult?(args: {
@@ -171,6 +171,39 @@ describe("runFromMetadata with dependsOn", () => {
171
171
  expect(run.args).toMatchObject({ ok: false, total: 4, passed: 1, failed: 1, skipped: 2 });
172
172
  });
173
173
 
174
+ it("fails only a scenario whose restoreFrom names an unknown scenario, skips what needs it, and runs the rest", async () => {
175
+ const events: Event[] = [];
176
+ await expect(
177
+ runFromMetadata({
178
+ scenarios: [
179
+ pass("login"),
180
+ pass("workspace", { restoreFrom: "ui-login" }),
181
+ pass("after-workspace", { dependsOn: ["workspace"] }),
182
+ pass("other", { dependsOn: ["login"] }),
183
+ ],
184
+ reporter: recordingReporter(events),
185
+ }),
186
+ ).rejects.toThrow(/restores from unknown scenario "ui-login"/);
187
+ expect(events.filter((e) => e.type !== "run")).toEqual([
188
+ expect.objectContaining({ type: "end", id: "workspace", ok: false }),
189
+ { type: "skip", id: "after-workspace", dependency: "workspace" },
190
+ expect.objectContaining({ type: "end", id: "login", ok: true }),
191
+ expect.objectContaining({ type: "end", id: "other", ok: true }),
192
+ ]);
193
+ const run = events.find((e) => e.type === "run") as { args: RunEndArgs };
194
+ expect(run.args).toMatchObject({ ok: false, total: 4, passed: 2, failed: 1, skipped: 1 });
195
+ });
196
+
197
+ it("reports a broken scenario only when the run selected it or something that needs it", async () => {
198
+ const events: Event[] = [];
199
+ await runFromMetadata({
200
+ scenarios: [pass("login"), pass("workspace", { dependsOn: ["ghost"] })],
201
+ scenarioIds: ["login"],
202
+ reporter: recordingReporter(events),
203
+ });
204
+ expect(events.filter((e) => e.type !== "run").map((e) => `${e.type}:${(e as any).id}`)).toEqual(["end:login"]);
205
+ });
206
+
174
207
  it("runs a selected scenario's dependencies first", async () => {
175
208
  const events: Event[] = [];
176
209
  await runFromMetadata({
@@ -32,14 +32,32 @@ import {
32
32
  orderByDependencies,
33
33
  expandRestoreFrom,
34
34
  sessionSourceFor,
35
+ splitUnrunnable,
35
36
  usesDependencies,
36
37
  validateSessions,
38
+ type UnrunnableScenario,
37
39
  } from "./scenario-graph";
38
40
 
39
41
  /**
40
42
  * Give a scenario the browser context its `session` asks for. `justStarted` skips a
41
43
  * redundant context swap when the browser was opened for this very scenario.
42
44
  */
45
+ /**
46
+ * The scenarios set aside as unrunnable that this run reports: the ones it selected, plus the broken ones they wait on
47
+ * (so a skip names a failure the run shows). Broken ones first, so each skip follows the failure that caused it.
48
+ */
49
+ function selectedUnrunnable(unrunnable: UnrunnableScenario[], selected: Array<{ id: string }>): UnrunnableScenario[] {
50
+ const byId = new Map(unrunnable.map((u) => [u.scenario.id, u]));
51
+ const keep = new Set<string>();
52
+ for (const { id } of selected) {
53
+ for (let at = byId.get(id); at && !keep.has(at.scenario.id); at = at.blockedBy ? byId.get(at.blockedBy) : undefined) {
54
+ keep.add(at.scenario.id);
55
+ }
56
+ }
57
+ const kept = unrunnable.filter((u) => keep.has(u.scenario.id));
58
+ return [...kept.filter((u) => u.error), ...kept.filter((u) => !u.error)];
59
+ }
60
+
43
61
  async function prepareSession(
44
62
  ui: UiAdapter,
45
63
  scenario: ScenarioSpec,
@@ -166,16 +184,18 @@ export async function runFromMetadata(opts: RunnerOptions): Promise<void> {
166
184
  const { reset: resetScenario, rest: unexpandedScenarios } = splitResetScenario(
167
185
  opts.scenarios ?? opts.metadata?.testing?.scenarios ?? [],
168
186
  );
187
+ // A scenario whose restoreFrom or dependsOn names a scenario that is not there cannot run, nor can what needs it. They
188
+ // are reported as failed / skipped below instead of stopping the run before the others start.
189
+ const { runnable, unrunnable } = splitUnrunnable(unexpandedScenarios, resetScenario?.id);
169
190
  // restoreFrom becomes dependsOn + session: restore + saveSession on its source, so the rest of the run sees only those.
170
- const allScenarios = expandRestoreFrom(unexpandedScenarios, resetScenario?.id);
171
- const selected = expandWithDependencies(
172
- allScenarios,
173
- filterScenarios(allScenarios, {
174
- scenarioIds: opts.scenarioIds,
175
- includeTags: opts.includeTags,
176
- skipScenarioIds: opts.skipScenarioIds,
177
- }),
178
- );
191
+ const allScenarios = expandRestoreFrom(runnable, resetScenario?.id);
192
+ const filterOptions = {
193
+ scenarioIds: opts.scenarioIds,
194
+ includeTags: opts.includeTags,
195
+ skipScenarioIds: opts.skipScenarioIds,
196
+ };
197
+ const selected = expandWithDependencies(allScenarios, filterScenarios(allScenarios, filterOptions));
198
+ const notRunnable = selectedUnrunnable(unrunnable, filterScenarios(unrunnable.map((u) => u.scenario), filterOptions));
179
199
  // Without dependsOn/session settings a run keeps its original contract: file order,
180
200
  // one shared browser context, stop at the first failure.
181
201
  const dependencyMode = usesDependencies(selected);
@@ -231,14 +251,30 @@ export async function runFromMetadata(opts: RunnerOptions): Promise<void> {
231
251
  if (opts.signal?.aborted) throw new RunCanceledError();
232
252
  };
233
253
 
254
+ const reported = [...notRunnable.map((u) => u.scenario), ...scenarios];
234
255
  reporter.onRunStart?.({
235
- total: scenarios.length,
256
+ total: reported.length,
236
257
  startedAt: new Date(startedAt).toISOString(),
237
- scenarioIds: scenarios.map((s) => s.id),
238
- scenarios: scenarios.map((s) => ({ id: s.id, name: s.name, type: s.type })),
258
+ scenarioIds: reported.map((s) => s.id),
259
+ scenarios: reported.map((s) => ({ id: s.id, name: s.name, type: s.type })),
239
260
  });
240
261
 
241
262
  try {
263
+ // Scenarios that cannot run fail (a broken reference) or are skipped (they need one that cannot run), and the run goes on.
264
+ for (const { scenario, error, blockedBy } of notRunnable) {
265
+ if (error) {
266
+ const failure = new Error(error);
267
+ reporter.onScenarioStart(scenario);
268
+ reporter.onScenarioEnd(scenario, { ok: false, error: failure, durationMs: 0 });
269
+ failed += 1;
270
+ runError = failure;
271
+ outcomes.set(scenario.id, "failed");
272
+ } else {
273
+ skipped += 1;
274
+ outcomes.set(scenario.id, "skipped");
275
+ reporter.onScenarioSkipped?.(scenario, { reason: "dependency_failed", dependency: String(blockedBy) });
276
+ }
277
+ }
242
278
  // Checked inside the try so a bad mobile setup still reports run.end.
243
279
  for (const scenario of scenarios) {
244
280
  const problem = mobileScenarioProblem(scenario);
@@ -362,16 +398,17 @@ export async function runFromMetadata(opts: RunnerOptions): Promise<void> {
362
398
  } finally {
363
399
  reporter.onRunEnd?.({
364
400
  ok: !runError,
365
- total: scenarios.length,
401
+ total: reported.length,
366
402
  passed,
367
403
  failed,
368
- ...(dependencyMode ? { skipped } : {}),
404
+ ...(dependencyMode || skipped > 0 ? { skipped } : {}),
369
405
  durationMs: Date.now() - startedAt,
370
406
  });
371
407
  opts.signal?.removeEventListener("abort", closeOnCancel);
372
408
  if (uiStarted.value && !uiClosedOnCancel) {
373
- // Only KEEP the whole-run video when the run FAILED — passing runs discard it unread.
374
- const keepVideo = !!runError;
409
+ // Only KEEP the whole-run video when the run FAILED in the browser — passing runs, and runs where only API
410
+ // scenarios failed (nothing of theirs is on screen), discard it unread.
411
+ const keepVideo = !!runError && scenarios.some((s) => scenarioNeedsUi(s) && outcomes.get(s.id) === "failed");
375
412
  await ui.stop({ keepVideo });
376
413
  // Video bytes are only finalized after ui.stop(); attach it as a run-level artifact so
377
414
  // the reporter uploads it and references it on run.end (queued before flushPending runs).
@@ -19,18 +19,9 @@ export function expandRestoreFrom(scenarios: ScenarioSpec[], resetId?: string):
19
19
  const sources = new Set<string>();
20
20
  const expanded = scenarios.map((scenario) => {
21
21
  if (scenario.restoreFrom === undefined) return scenario;
22
- const source = scenario.restoreFrom;
23
- if (typeof source !== "string" || !source.trim()) {
24
- throw new Error(`Scenario "${scenario.id}" has an invalid restoreFrom (expected one scenario id)`);
25
- }
26
- if (source === scenario.id) throw new Error(`Scenario "${scenario.id}" cannot restoreFrom itself`);
27
- if (resetId !== undefined && source === resetId) {
28
- throw new Error(`Scenario "${scenario.id}" restores from the reset scenario "${source}", which only runs as setup`);
29
- }
30
- if (!byId.has(source)) throw new Error(`Scenario "${scenario.id}" restores from unknown scenario "${source}"`);
31
- if (scenario.session !== undefined && scenario.session !== "restore") {
32
- throw new Error(`Scenario "${scenario.id}" has restoreFrom, which means session "restore", but its session is "${String(scenario.session)}"`);
33
- }
22
+ const problem = restoreFromProblem(scenario, byId, resetId);
23
+ if (problem) throw new Error(problem);
24
+ const source = scenario.restoreFrom as string;
34
25
  sources.add(source);
35
26
  const others = dependenciesOf(scenario).filter((id) => id !== source);
36
27
  const before = dependenciesOf(scenario);
@@ -40,6 +31,58 @@ export function expandRestoreFrom(scenarios: ScenarioSpec[], resetId?: string):
40
31
  return expanded.map((scenario) => (sources.has(scenario.id) && !scenario.saveSession ? { ...scenario, saveSession: true } : scenario));
41
32
  }
42
33
 
34
+ /** What is wrong with a scenario's `restoreFrom`, or undefined when it names another scenario it can restore from. */
35
+ function restoreFromProblem(scenario: ScenarioSpec, byId: Map<string, ScenarioSpec>, resetId?: string): string | undefined {
36
+ const source = scenario.restoreFrom;
37
+ if (source === undefined) return undefined;
38
+ if (typeof source !== "string" || !source.trim()) return `Scenario "${scenario.id}" has an invalid restoreFrom (expected one scenario id)`;
39
+ if (source === scenario.id) return `Scenario "${scenario.id}" cannot restoreFrom itself`;
40
+ if (resetId !== undefined && source === resetId) {
41
+ return `Scenario "${scenario.id}" restores from the reset scenario "${source}", which only runs as setup`;
42
+ }
43
+ if (!byId.has(source)) return `Scenario "${scenario.id}" restores from unknown scenario "${source}"`;
44
+ if (scenario.session !== undefined && scenario.session !== "restore") {
45
+ return `Scenario "${scenario.id}" has restoreFrom, which means session "restore", but its session is "${String(scenario.session)}"`;
46
+ }
47
+ return undefined;
48
+ }
49
+
50
+ /** A scenario that cannot run in this run: its own reference is broken (`error`), or one it needs cannot run (`blockedBy`). */
51
+ export interface UnrunnableScenario {
52
+ scenario: ScenarioSpec;
53
+ error?: string;
54
+ blockedBy?: string;
55
+ }
56
+
57
+ /**
58
+ * Sets aside the scenarios whose `restoreFrom` or `dependsOn` cannot be met — one naming a scenario that does not exist,
59
+ * itself, or the reset scenario — and, transitively, the scenarios that need them. A mistake in one scenario then fails
60
+ * that scenario instead of stopping the whole run before anything starts; the rest run as usual.
61
+ */
62
+ export function splitUnrunnable(scenarios: ScenarioSpec[], resetId?: string): { runnable: ScenarioSpec[]; unrunnable: UnrunnableScenario[] } {
63
+ const byId = new Map(scenarios.map((s) => [s.id, s]));
64
+ const unrunnable = new Map<string, UnrunnableScenario>();
65
+ for (const scenario of scenarios) {
66
+ const unknownDep = dependenciesOf(scenario).find((id) => !byId.has(id));
67
+ const error = restoreFromProblem(scenario, byId, resetId)
68
+ ?? (unknownDep !== undefined ? `Scenario "${scenario.id}" depends on unknown scenario "${unknownDep}"` : undefined);
69
+ if (error) unrunnable.set(scenario.id, { scenario, error });
70
+ }
71
+ for (let grew = unrunnable.size > 0; grew; ) {
72
+ grew = false;
73
+ for (const scenario of scenarios) {
74
+ if (unrunnable.has(scenario.id)) continue;
75
+ const needs = [...dependenciesOf(scenario), ...(typeof scenario.restoreFrom === "string" ? [scenario.restoreFrom] : [])];
76
+ const blockedBy = needs.find((id) => unrunnable.has(id));
77
+ if (blockedBy !== undefined) {
78
+ unrunnable.set(scenario.id, { scenario, blockedBy });
79
+ grew = true;
80
+ }
81
+ }
82
+ }
83
+ return { runnable: scenarios.filter((s) => !unrunnable.has(s.id)), unrunnable: [...unrunnable.values()] };
84
+ }
85
+
43
86
  function dependenciesOf(scenario: ScenarioSpec): string[] {
44
87
  return Array.isArray(scenario.dependsOn) ? scenario.dependsOn.map(String) : [];
45
88
  }
@@ -1,6 +1,7 @@
1
1
  import type { TestContext } from "../../contracts/runtime-context.types";
2
2
  import type { OpStep } from "../../contracts/testing-metadata.types";
3
3
  import { StepRegistry } from "../../core/step-registry";
4
+ import { recordStepData } from "../../core/step-data";
4
5
 
5
6
  type GotoInput = { url: string; timeoutMs?: number };
6
7
  type ExpectUrlInput = { equals?: string; contains?: string; timeoutMs?: number };
@@ -108,7 +109,9 @@ export function registerNavigationSteps(registry: StepRegistry): void {
108
109
  `ui.storeText: regex "${input.match}" found no match in text "${text.slice(0, 120)}"`,
109
110
  );
110
111
  }
111
- return m[1] !== undefined ? m[1] : m[0];
112
+ const value = m[1] !== undefined ? m[1] : m[0];
113
+ recordStepData(ctx, { kind: "match", source: `match:${input.match}`, value, ...(step.saveAs ? { saveAs: step.saveAs } : {}) });
114
+ return value;
112
115
  }
113
116
  return text;
114
117
  });
@@ -2,6 +2,7 @@ import type { TestContext } from "../../contracts/runtime-context.types";
2
2
  import type { OpStep } from "../../contracts/testing-metadata.types";
3
3
  import { randomDataFor } from "../../core/random-data";
4
4
  import { StepRegistry } from "../../core/step-registry";
5
+ import { recordStepData } from "../../core/step-data";
5
6
 
6
7
  type RandomInput = { generator: string; args?: Record<string, unknown> };
7
8
 
@@ -18,6 +19,8 @@ export function registerRandomStep(registry: StepRegistry): void {
18
19
  if (typeof args !== "object" || Array.isArray(args)) {
19
20
  throw new Error('"args" must be an object for op "util.random", e.g. { "domain": "acme.test" }');
20
21
  }
21
- return randomDataFor(ctx).generate(String(input.generator), args);
22
+ const value = randomDataFor(ctx).generate(String(input.generator), args);
23
+ recordStepData(ctx, { kind: "random", source: `random:${input.generator}`, value, ...(step.saveAs ? { saveAs: step.saveAs } : {}) });
24
+ return value;
22
25
  });
23
26
  }
@@ -1,20 +0,0 @@
1
- # Goal
2
- 1. In SolidX i have multiple media storage providers e.g file system, aws etc for handling media files
3
- 2. I want to add migration functionality to it i.e i want to be able to :
4
- - migrate media from 1 media provider to another
5
- - within a provider migrate media from 1 bucket to another
6
- - also within a particular media provider i want to be able to migrate the media from private to public media or vice versa (low)
7
- 3. i don't need a ui for it, i am if i can achieve this using postman endpoints
8
-
9
- # Why
10
- i have setup a solidx application and in the metadata i have selected against certain fields for e.g say filesystem. Now i want to change it to aws
11
- similarly i might want to change the bucket of an existing aws media storage provider to something else
12
-
13
- but doing above requires migration of existing media setup against the previous provider or bucket
14
-
15
- # Guardrails
16
- I should not lose any media files. In case any issues while migrating there should clean and user friendly error messages instead of failing silently. Media can sometimes be large so in a scalable manner i will want to achieve this
17
-
18
- # Done
19
- If i am able to migrate the existing media to a different provider e.g filesystem to s3
20
- If i am able to migrate the existing media to a different bucket e.g bucket A to bucket B. Bucket B may or not be private