@dev-blinq/bvt-playwright-js 1.0.0-dev.3 → 1.0.0-dev.4

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 (4) hide show
  1. package/index.d.mts +182 -14
  2. package/index.mjs +2939 -137
  3. package/index.mjs.map +1 -1
  4. package/package.json +1 -1
package/index.d.mts CHANGED
@@ -13,6 +13,85 @@ declare const apiResponseSnapshotSchema: z.ZodObject<{
13
13
  bodyJson: z.ZodOptional<z.ZodUnknown>;
14
14
  }, z.core.$strict>;
15
15
  type ApiResponseSnapshot = z.infer<typeof apiResponseSnapshotSchema>;
16
+ declare const apiRequestSchema: z.ZodObject<{
17
+ method: z.ZodEnum<{
18
+ GET: "GET";
19
+ POST: "POST";
20
+ PUT: "PUT";
21
+ PATCH: "PATCH";
22
+ DELETE: "DELETE";
23
+ }>;
24
+ url: z.ZodString;
25
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
26
+ body: z.ZodOptional<z.ZodString>;
27
+ saveAs: z.ZodOptional<z.ZodString>;
28
+ capturedResponse: z.ZodOptional<z.ZodObject<{
29
+ status: z.ZodNumber;
30
+ statusText: z.ZodString;
31
+ timeMs: z.ZodNumber;
32
+ sizeBytes: z.ZodNumber;
33
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
34
+ bodyText: z.ZodString;
35
+ bodyJson: z.ZodOptional<z.ZodUnknown>;
36
+ }, z.core.$strict>>;
37
+ options: z.ZodOptional<z.ZodObject<{
38
+ timeout: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
39
+ }, z.core.$strict>>;
40
+ }, z.core.$strict>;
41
+ type ApiRequest = z.infer<typeof apiRequestSchema>;
42
+ declare const apiResponseAssertionCommandData: z.ZodDiscriminatedUnion<[
43
+ z.ZodObject<{
44
+ operator: z.ZodEnum<{
45
+ equals: "equals";
46
+ notEquals: "notEquals";
47
+ contains: "contains";
48
+ lessThan: "lessThan";
49
+ greaterThan: "greaterThan";
50
+ exists: "exists";
51
+ }>;
52
+ target: z.ZodLiteral<"status">;
53
+ expected: z.ZodString;
54
+ }, z.core.$strict>,
55
+ z.ZodObject<{
56
+ operator: z.ZodEnum<{
57
+ equals: "equals";
58
+ notEquals: "notEquals";
59
+ contains: "contains";
60
+ lessThan: "lessThan";
61
+ greaterThan: "greaterThan";
62
+ exists: "exists";
63
+ }>;
64
+ target: z.ZodLiteral<"responseTime">;
65
+ expected: z.ZodString;
66
+ }, z.core.$strict>,
67
+ z.ZodObject<{
68
+ operator: z.ZodEnum<{
69
+ equals: "equals";
70
+ notEquals: "notEquals";
71
+ contains: "contains";
72
+ lessThan: "lessThan";
73
+ greaterThan: "greaterThan";
74
+ exists: "exists";
75
+ }>;
76
+ expected: z.ZodDefault<z.ZodOptional<z.ZodString>>;
77
+ target: z.ZodLiteral<"header">;
78
+ path: z.ZodString;
79
+ }, z.core.$strict>,
80
+ z.ZodObject<{
81
+ operator: z.ZodEnum<{
82
+ equals: "equals";
83
+ notEquals: "notEquals";
84
+ contains: "contains";
85
+ lessThan: "lessThan";
86
+ greaterThan: "greaterThan";
87
+ exists: "exists";
88
+ }>;
89
+ expected: z.ZodDefault<z.ZodOptional<z.ZodString>>;
90
+ target: z.ZodLiteral<"bodyField">;
91
+ path: z.ZodString;
92
+ }, z.core.$strict>
93
+ ], "target">;
94
+ type ApiResponseAssertionCommandData = z.infer<typeof apiResponseAssertionCommandData>;
16
95
  declare const elementActionSchema: z.ZodDiscriminatedUnion<[
17
96
  z.ZodObject<{
18
97
  type: z.ZodLiteral<"click">;
@@ -1797,9 +1876,9 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
1797
1876
  ], "type">;
1798
1877
  score: z.ZodNumber;
1799
1878
  source: z.ZodEnum<{
1879
+ role: "role";
1800
1880
  xpath: "xpath";
1801
1881
  testId: "testId";
1802
- role: "role";
1803
1882
  accessibleName: "accessibleName";
1804
1883
  visibleText: "visibleText";
1805
1884
  stableAttribute: "stableAttribute";
@@ -2557,9 +2636,9 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
2557
2636
  ], "type">;
2558
2637
  score: z.ZodNumber;
2559
2638
  source: z.ZodEnum<{
2639
+ role: "role";
2560
2640
  xpath: "xpath";
2561
2641
  testId: "testId";
2562
- role: "role";
2563
2642
  accessibleName: "accessibleName";
2564
2643
  visibleText: "visibleText";
2565
2644
  stableAttribute: "stableAttribute";
@@ -3201,9 +3280,9 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
3201
3280
  ], "type">;
3202
3281
  score: z.ZodNumber;
3203
3282
  source: z.ZodEnum<{
3283
+ role: "role";
3204
3284
  xpath: "xpath";
3205
3285
  testId: "testId";
3206
- role: "role";
3207
3286
  accessibleName: "accessibleName";
3208
3287
  visibleText: "visibleText";
3209
3288
  stableAttribute: "stableAttribute";
@@ -4796,9 +4875,9 @@ declare const StepDefinitionSchema: z.ZodObject<{
4796
4875
  ], "type">;
4797
4876
  score: z.ZodNumber;
4798
4877
  source: z.ZodEnum<{
4878
+ role: "role";
4799
4879
  xpath: "xpath";
4800
4880
  testId: "testId";
4801
- role: "role";
4802
4881
  accessibleName: "accessibleName";
4803
4882
  visibleText: "visibleText";
4804
4883
  stableAttribute: "stableAttribute";
@@ -5556,9 +5635,9 @@ declare const StepDefinitionSchema: z.ZodObject<{
5556
5635
  ], "type">;
5557
5636
  score: z.ZodNumber;
5558
5637
  source: z.ZodEnum<{
5638
+ role: "role";
5559
5639
  xpath: "xpath";
5560
5640
  testId: "testId";
5561
- role: "role";
5562
5641
  accessibleName: "accessibleName";
5563
5642
  visibleText: "visibleText";
5564
5643
  stableAttribute: "stableAttribute";
@@ -6200,9 +6279,9 @@ declare const StepDefinitionSchema: z.ZodObject<{
6200
6279
  ], "type">;
6201
6280
  score: z.ZodNumber;
6202
6281
  source: z.ZodEnum<{
6282
+ role: "role";
6203
6283
  xpath: "xpath";
6204
6284
  testId: "testId";
6205
- role: "role";
6206
6285
  accessibleName: "accessibleName";
6207
6286
  visibleText: "visibleText";
6208
6287
  stableAttribute: "stableAttribute";
@@ -6799,9 +6878,9 @@ declare const ReplayLocatorCandidateSchema: z.ZodObject<{
6799
6878
  ], "type">;
6800
6879
  score: z.ZodNumber;
6801
6880
  source: z.ZodEnum<{
6881
+ role: "role";
6802
6882
  xpath: "xpath";
6803
6883
  testId: "testId";
6804
- role: "role";
6805
6884
  accessibleName: "accessibleName";
6806
6885
  visibleText: "visibleText";
6807
6886
  stableAttribute: "stableAttribute";
@@ -7081,9 +7160,9 @@ declare const StepReplayTelemetrySchema: z.ZodObject<{
7081
7160
  ], "type">;
7082
7161
  score: z.ZodNumber;
7083
7162
  source: z.ZodEnum<{
7163
+ role: "role";
7084
7164
  xpath: "xpath";
7085
7165
  testId: "testId";
7086
- role: "role";
7087
7166
  accessibleName: "accessibleName";
7088
7167
  visibleText: "visibleText";
7089
7168
  stableAttribute: "stableAttribute";
@@ -7285,8 +7364,8 @@ declare const RecoveryDecisionSchema: z.ZodDiscriminatedUnion<[
7285
7364
  }, z.core.$strip>
7286
7365
  ], "type">;
7287
7366
  repairContext: z.ZodEnum<{
7288
- "local-run": "local-run";
7289
7367
  "recorder-replay": "recorder-replay";
7368
+ "local-run": "local-run";
7290
7369
  "execution-planner": "execution-planner";
7291
7370
  }>;
7292
7371
  rcaLabel: z.ZodOptional<z.ZodString>;
@@ -7341,8 +7420,8 @@ type ExecutionStartedEventData = {
7341
7420
  type: "execution_started";
7342
7421
  };
7343
7422
  declare const ScopeTypeSchema: z.ZodEnum<{
7344
- runtime: "runtime";
7345
7423
  environment: "environment";
7424
+ runtime: "runtime";
7346
7425
  global: "global";
7347
7426
  feature: "feature";
7348
7427
  scenario: "scenario";
@@ -7376,8 +7455,8 @@ declare const TestDataEntrySchema: z.ZodObject<{
7376
7455
  }>;
7377
7456
  scope: z.ZodObject<{
7378
7457
  type: z.ZodEnum<{
7379
- runtime: "runtime";
7380
7458
  environment: "environment";
7459
+ runtime: "runtime";
7381
7460
  global: "global";
7382
7461
  feature: "feature";
7383
7462
  scenario: "scenario";
@@ -7410,8 +7489,8 @@ declare const BrowserObserverStateKSchema: z.ZodUnion<readonly [
7410
7489
  input: "input";
7411
7490
  text: "text";
7412
7491
  context: "context";
7413
- hover: "hover";
7414
7492
  ai: "ai";
7493
+ hover: "hover";
7415
7494
  none: "none";
7416
7495
  snapshot: "snapshot";
7417
7496
  element: "element";
@@ -7766,9 +7845,9 @@ declare const PickedElementSchema: z.ZodObject<{
7766
7845
  ], "type">;
7767
7846
  score: z.ZodNumber;
7768
7847
  source: z.ZodEnum<{
7848
+ role: "role";
7769
7849
  xpath: "xpath";
7770
7850
  testId: "testId";
7771
- role: "role";
7772
7851
  accessibleName: "accessibleName";
7773
7852
  visibleText: "visibleText";
7774
7853
  stableAttribute: "stableAttribute";
@@ -7942,7 +8021,7 @@ declare class DownloadStore {
7942
8021
  cancelAll(): void;
7943
8022
  }
7944
8023
  type CustomCodeAllowedHost = {
7945
- readonly protocol: "http:" | "https:";
8024
+ readonly protocol: "http:" | "https:" | "pg:";
7946
8025
  readonly hostname: string;
7947
8026
  };
7948
8027
  type CustomCodePolicy = {
@@ -7957,6 +8036,7 @@ type CustomCodePolicy = {
7957
8036
  readonly network: {
7958
8037
  readonly allowedHosts: readonly CustomCodeAllowedHost[];
7959
8038
  readonly blockPrivateIpRanges: boolean;
8039
+ readonly requirePgTls: boolean;
7960
8040
  };
7961
8041
  readonly filesystem: {
7962
8042
  readonly root: string;
@@ -9361,6 +9441,67 @@ export declare function toMatcherValue(value: MatcherValueInput): string | numbe
9361
9441
  export declare function toMatcherValue(value: undefined): undefined;
9362
9442
  export declare function toMatcherValue(value: MatcherValueInput | undefined): string | number | boolean | RegExp | undefined;
9363
9443
  type GeneratedCommand = Command;
9444
+ /**
9445
+ * Stateful API helper for generated `api.action` / `api.assertion` steps.
9446
+ * Mirrors the Tester's runtime: a request stores its response as `lastResponse`
9447
+ * (and writes `saveAs` to runtime test data), and an assertion runs against
9448
+ * that stored response. The shared state lives here because the request and
9449
+ * assertion are emitted as separate `test.step` blocks with no shared scope.
9450
+ */
9451
+ export type BlinqApi = {
9452
+ /** Run the request, store it as `lastResponse`, and persist `saveAs` if set. */
9453
+ request(request: ApiRequest): Promise<ApiResponseSnapshot>;
9454
+ /** Assert against `lastResponse`; throws if no request has run yet. */
9455
+ assert(assertion: ApiResponseAssertionCommandData): Promise<void>;
9456
+ readonly lastResponse: ApiResponseSnapshot | undefined;
9457
+ };
9458
+ /**
9459
+ * The `context` object AI-chat (`custom`) command code receives. Mirrors the
9460
+ * recorder sandbox's `context`: the resolution-scope fields plus a `testData`
9461
+ * accessor (which is the runner's `TestDataApi`, exposing
9462
+ * `set`/`get`/`setRuntime`/`getRuntime`).
9463
+ */
9464
+ export type AiChatContext = {
9465
+ readonly testData: TestDataApi;
9466
+ readonly projectId?: string;
9467
+ readonly environmentId?: string;
9468
+ readonly featureId?: string;
9469
+ readonly scenarioId?: string;
9470
+ readonly executionId?: string;
9471
+ };
9472
+ /**
9473
+ * The globals AI-chat custom code expects beyond `page` / `expect` / `console`.
9474
+ * Generated specs declare `context`, `checkpoint`, `onCommandStart`, and
9475
+ * `onCommandPass` above the inlined code, sourced from the bvt fixture.
9476
+ *
9477
+ * Recovery helpers (`helpers.getPreferredInteractiveTarget`, etc.) are
9478
+ * intentionally NOT provided — they depend on bvt-agent's runtime recovery and
9479
+ * have no standalone equivalent.
9480
+ */
9481
+ export type AiChatGlobals = {
9482
+ readonly context: AiChatContext;
9483
+ checkpoint(label: string, data?: unknown): void;
9484
+ onCommandStart(label: string): Promise<void>;
9485
+ onCommandPass(opts?: {
9486
+ delayMs?: number;
9487
+ }): Promise<void>;
9488
+ };
9489
+ /**
9490
+ * Build the AI-chat command globals. Mirrors the recorder sandbox:
9491
+ * `onCommandStart` waits the watch-delay then records the command boundary,
9492
+ * `onCommandPass` waits the (overridable) watch-delay, and `checkpoint`
9493
+ * records a labelled marker. In a standalone Playwright run the sandbox's
9494
+ * live-timeline bridge is replaced by Playwright test annotations (via the
9495
+ * injected `annotate` callback).
9496
+ */
9497
+ export declare function createAiChatGlobals(input: {
9498
+ testDataApi: TestDataApi;
9499
+ parameters: PlaywrightRunnerParameters;
9500
+ annotate: (annotation: {
9501
+ type: string;
9502
+ description: string;
9503
+ }) => void;
9504
+ }): AiChatGlobals;
9364
9505
  export declare class TempFileTestDataProvider implements ITestDataProvider {
9365
9506
  readonly filePath: string;
9366
9507
  readonly seedFilePath?: string | undefined;
@@ -9392,6 +9533,7 @@ export declare class PlaywrightRunner {
9392
9533
  private readonly scopeManager?;
9393
9534
  private readonly preprocessors;
9394
9535
  private resolutionContext;
9536
+ private apiRuntime?;
9395
9537
  constructor(options?: PlaywrightRunnerOptions, dependencies?: PlaywrightRunnerDependencies);
9396
9538
  private applyResolutionContext;
9397
9539
  /**
@@ -9400,6 +9542,13 @@ export declare class PlaywrightRunner {
9400
9542
  */
9401
9543
  attach(page: Page): void;
9402
9544
  detach(): void;
9545
+ /**
9546
+ * Stateful API helper for `api.action` / `api.assertion` steps. Lazily built
9547
+ * and held for the runner's lifetime so a request and its following assertion
9548
+ * share `lastResponse`. Throws if no test-data provider/context is available
9549
+ * (the `saveAs` path needs it).
9550
+ */
9551
+ get api(): BlinqApi;
9403
9552
  executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9404
9553
  /**
9405
9554
  * Run the preprocessor pipeline (step parameters, data-resolver tokens,
@@ -9472,6 +9621,25 @@ export type BlinqTestRuntime = {
9472
9621
  * `{{key}}` in later steps.
9473
9622
  */
9474
9623
  readonly testDataApi: TestDataApi;
9624
+ /**
9625
+ * Stateful API helper. `api.action` steps call `bvt.api.request(...)` and
9626
+ * `api.assertion` steps call `bvt.api.assert(...)`; the request's response is
9627
+ * shared with the following assertion via `bvt.api.lastResponse`.
9628
+ */
9629
+ readonly api: BlinqApi;
9630
+ /**
9631
+ * The `context` object AI-chat (`custom`) command code receives; generated
9632
+ * specs declare `const context = bvt.aiChatContext` above the inlined code.
9633
+ */
9634
+ readonly aiChatContext: AiChatContext;
9635
+ /** AI-chat `checkpoint(label, data?)` global — records a Playwright annotation. */
9636
+ checkpoint(label: string, data?: unknown): void;
9637
+ /** AI-chat `onCommandStart(label)` global — watch-delay then a boundary annotation. */
9638
+ onCommandStart(label: string): Promise<void>;
9639
+ /** AI-chat `onCommandPass(opts?)` global — watch-delay (overridable via `delayMs`). */
9640
+ onCommandPass(opts?: {
9641
+ delayMs?: number;
9642
+ }): Promise<void>;
9475
9643
  executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9476
9644
  resolveCommand(command: unknown, parameters?: Record<string, string>): Promise<Command>;
9477
9645
  find(command: Command): Promise<Locator | Page | FrameLocator | null>;