@stablyai/playwright-base 0.1.0 → 0.1.2

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.
@@ -1,48 +0,0 @@
1
- import type { Locator, Page } from 'playwright';
2
- import {
3
- type ExtractSchema,
4
- type SchemaOutput,
5
- extract,
6
- } from '../../ai/extract';
7
-
8
- type ExtractOptions<T extends ExtractSchema> = {
9
- schema: T;
10
- };
11
-
12
- type ExtractMethod = {
13
- (prompt: string): Promise<string>;
14
- <T extends ExtractSchema>(
15
- prompt: string,
16
- options: ExtractOptions<T>,
17
- ): Promise<SchemaOutput<T>>;
18
- };
19
-
20
- type LocatorExtract = ExtractMethod;
21
- type PageExtract = ExtractMethod;
22
-
23
- type ExtractSubject = Locator | Page;
24
-
25
- function createExtract(pageOrLocator: ExtractSubject): ExtractMethod {
26
- const impl = (async (
27
- prompt: string,
28
- options?: ExtractOptions<ExtractSchema>,
29
- ) => {
30
- if (options?.schema) {
31
- return extract({
32
- prompt,
33
- schema: options.schema,
34
- pageOrLocator,
35
- });
36
- }
37
-
38
- return extract({ prompt, pageOrLocator });
39
- }) as ExtractMethod;
40
-
41
- return impl;
42
- }
43
-
44
- export const createLocatorExtract = (locator: Locator): LocatorExtract =>
45
- createExtract(locator);
46
-
47
- export const createPageExtract = (page: Page): PageExtract =>
48
- createExtract(page);
@@ -1,19 +0,0 @@
1
- import { Page, Locator } from 'playwright';
2
-
3
- export function isPage(candidate: unknown): candidate is Page {
4
- return (
5
- typeof candidate === 'object' &&
6
- candidate !== null &&
7
- typeof (candidate as Page).screenshot === 'function' &&
8
- typeof (candidate as Page).goto === 'function'
9
- );
10
- }
11
-
12
- export function isLocator(candidate: unknown): candidate is Locator {
13
- return (
14
- typeof candidate === 'object' &&
15
- candidate !== null &&
16
- typeof (candidate as Locator).screenshot === 'function' &&
17
- typeof (candidate as Locator).nth === 'function'
18
- );
19
- }
package/src/runtime.ts DELETED
@@ -1,19 +0,0 @@
1
- let configuredApiKey: string | undefined = process.env.STABLY_API_KEY;
2
-
3
- export function setApiKey(apiKey: string): void {
4
- configuredApiKey = apiKey;
5
- }
6
-
7
- export function getApiKey(): string | undefined {
8
- return configuredApiKey;
9
- }
10
-
11
- export function requireApiKey(): string {
12
- const apiKey = getApiKey();
13
- if (!apiKey) {
14
- throw new Error(
15
- 'Missing Stably API key. Call setApiKey(apiKey) or set the STABLY_API_KEY environment variable.',
16
- );
17
- }
18
- return apiKey;
19
- }
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "noEmit": false
5
- }
6
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist"
6
- },
7
- "include": ["src"],
8
- "exclude": ["dist", "node_modules"]
9
- }