@intuned/runner-types
Advanced tools
Comparing version 1.0.0-beta.27 to 1.0.0-beta.28
@@ -1,2 +0,2 @@ | ||
import { Locator } from "playwright-core"; | ||
import { Locator } from "@intuned/playwright-core"; | ||
@@ -174,1 +174,81 @@ export interface BasicSchema { | ||
): Promise<string>; | ||
export type ObjectExtractor = Record<string, AbsoluteValueSelector | null>; | ||
export interface AbsoluteElementSelector { | ||
value: string; | ||
type: "xpath" | "css"; | ||
backupSelectors?: AbsoluteElementSelector[]; | ||
} | ||
export interface AbsoluteValueSelector { | ||
value: string; | ||
type: "xpath" | "css"; | ||
property: | ||
| "direct-text" | ||
| "all-text" | ||
| { | ||
attribute: string; | ||
}; | ||
backupSelectors?: AbsoluteValueSelector[]; | ||
regex?: string; | ||
regexMatchIndex?: number; | ||
extractionType?: "string" | "string-list"; | ||
} | ||
export type RelativeValueSelector = { | ||
value: string; | ||
type: "relative-css" | "relative-xpath"; | ||
property: | ||
| "direct-text" | ||
| "all-text" | ||
| { | ||
attribute: string; | ||
}; | ||
regex?: string; | ||
regexMatchIndex?: number; | ||
backupSelectors?: RelativeValueSelector[]; | ||
extractionType?: "sting" | "string-list"; | ||
}; | ||
export interface BasicListInfo { | ||
containerSelector: AbsoluteElementSelector; | ||
nodeSplit: { | ||
itemTagsToBeFlitteredOut: string[]; | ||
numberOfElementsPerItem: number; | ||
}; | ||
} | ||
export interface ListStaticExtractor { | ||
containerSelector: AbsoluteElementSelector; | ||
nodeSplit?: BasicListInfo["nodeSplit"] & { | ||
numberOfElementsPerItem?: number; | ||
}; | ||
propertySelectors: Record< | ||
string, | ||
RelativeValueSelector & { | ||
indexOfNodeInsideListItem?: number; | ||
} | ||
>; | ||
} | ||
export type ExtractObjectUsingStaticSelectorsReturnType< | ||
T extends ObjectExtractor | ||
> = { | ||
[K in keyof T]: T[K] extends { | ||
extractionType?: "string-list"; | ||
} | ||
? string[] | null | ||
: string | null; | ||
}; | ||
export type ExtractListObjectsUsingStaticSelectorsReturnType< | ||
T extends ListStaticExtractor | ||
> = { | ||
[K in keyof T["propertySelectors"]]: T["propertySelectors"][K] extends { | ||
extractionType?: "string-list"; | ||
} | ||
? string[] | null | ||
: string | null; | ||
}[]; | ||
export declare function extractObjectUsingStaticSelectors< | ||
T extends ObjectExtractor | ||
>(extractor: T): Promise<ExtractObjectUsingStaticSelectorsReturnType<T>>; | ||
export declare function extractListObjectsUsingStaticSelectors< | ||
T extends ListStaticExtractor | ||
>( | ||
listExtractor: T | ||
): Promise<ExtractListObjectsUsingStaticSelectorsReturnType<T>>; |
380
index.d.ts
declare module '@intuned/runner' { | ||
// Generated by dts-bundle-generator v8.0.1 | ||
import { BrowserContext, Locator, Page } from '@intuned/playwright-core'; | ||
import * as z from 'zod'; | ||
export type ClassificationCategories = { | ||
categoryName: string; | ||
categoryDescription: string; | ||
}[]; | ||
export type ObjectExtractor = Record<string, AbsoluteValueSelector | null>; | ||
export interface AbsoluteValueSelector { | ||
value: string; | ||
type: "xpath" | "css"; | ||
property: "direct-text" | "all-text" | { | ||
attribute: string; | ||
}; | ||
backupSelectors?: AbsoluteValueSelector[]; | ||
regex?: string; | ||
regexMatchIndex?: number; | ||
extractionType?: "string" | "string-list"; | ||
} | ||
export interface AbsoluteElementSelector { | ||
value: string; | ||
type: "xpath" | "css"; | ||
backupSelectors?: AbsoluteElementSelector[]; | ||
} | ||
export type RelativeValueSelector = { | ||
value: string; | ||
type: "relative-css" | "relative-xpath"; | ||
property: "direct-text" | "all-text" | { | ||
attribute: string; | ||
}; | ||
regex?: string; | ||
regexMatchIndex?: number; | ||
backupSelectors?: RelativeValueSelector[]; | ||
extractionType?: "sting" | "string-list"; | ||
}; | ||
export interface BasicListInfo { | ||
containerSelector: AbsoluteElementSelector; | ||
nodeSplit: { | ||
itemTagsToBeFlitteredOut: string[]; | ||
numberOfElementsPerItem: number; | ||
}; | ||
} | ||
export interface ListStaticExtractor { | ||
containerSelector: AbsoluteElementSelector; | ||
nodeSplit?: BasicListInfo["nodeSplit"] & { | ||
numberOfElementsPerItem?: number; | ||
}; | ||
propertySelectors: Record<string, RelativeValueSelector & { | ||
indexOfNodeInsideListItem?: number; | ||
}>; | ||
} | ||
export type JSONSchemaType = "object" | "array" | "string" | "number" | "integer" | "boolean"; | ||
export interface JSONSchema { | ||
type: JSONSchemaType | JSONSchemaType[]; | ||
properties?: { | ||
[key: string]: JSONSchema; | ||
}; | ||
items?: JSONSchema | JSONSchema[]; | ||
required?: string[]; | ||
enum?: any[]; | ||
description?: string; | ||
} | ||
export type ObjectJSONSchema = { | ||
properties: Record<string, { | ||
description: string; | ||
primary?: boolean; | ||
}>; | ||
}; | ||
export type OpenAiModels = "gpt4" | "gpt4-turbo" | "gpt3.5-turbo"; | ||
export interface InputFieldsInfo { | ||
fieldType: "select" | "text-input" | "checkbox" | "radiogroup" | "submit-button"; | ||
ariaLabel: string | null; | ||
fieldLabelText: string | null; | ||
id: string | null; | ||
name: string | null; | ||
options?: { | ||
value: string | null; | ||
label: string | null; | ||
name?: string; | ||
id?: string; | ||
disabled?: boolean | null; | ||
visible?: boolean | null; | ||
}[]; | ||
visible?: boolean | null; | ||
disabled?: boolean | null; | ||
selector: AbsoluteElementSelector; | ||
} | ||
export type FieldSelector = { | ||
selector: string; | ||
type: "css" | "xpath"; | ||
}; | ||
export type InputFieldType = "text-input" | "select" | "checkbox" | "radiogroup" | "submit-button" | "auto-complete"; | ||
export type StaticFormDataItem = { | ||
fieldSelector: FieldSelector; | ||
fieldType: InputFieldType; | ||
value: { | ||
type: "static"; | ||
value: string | boolean | number; | ||
}; | ||
}; | ||
export type DynamicFormDataItem = { | ||
fieldSelector: FieldSelector; | ||
fieldType: InputFieldType; | ||
value: { | ||
type: "dynamic"; | ||
source: string | object; | ||
}; | ||
}; | ||
export type FormDataItem = DynamicFormDataItem | StaticFormDataItem; | ||
export interface FillFormConfigs { | ||
didFormSucceed: (formLocator: Locator, page: EnhancedPlaywrightPage) => Promise<boolean>; | ||
submitForm: (formLocator: Locator, page: EnhancedPlaywrightPage) => Promise<void>; | ||
autoRecovery?: { | ||
enabled: boolean; | ||
input: object; | ||
maskFields?: FieldSelector[]; | ||
maxRetries?: number; | ||
}; | ||
generateDataToUnblockForm?: { | ||
prompt: string; | ||
enabled: boolean; | ||
maxRetries?: number; | ||
maskFields?: FieldSelector[]; | ||
}; | ||
} | ||
export interface FillFormOptions { | ||
timeout?: number; | ||
fillFieldTimeout?: number; | ||
waitTimeBetweenFill?: number; | ||
} | ||
const strategySchema: z.ZodDefault<z.ZodOptional<z.ZodUnion<[ | ||
z.ZodObject<{ | ||
model: z.ZodEnum<[ | ||
"claude-3-opus", | ||
"claude-3-sonnet", | ||
"claude-3-haiku", | ||
"gpt4-turbo", | ||
"gpt3.5-turbo" | ||
]>; | ||
type: z.ZodLiteral<"HTML">; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "HTML"; | ||
model: "gpt4-turbo" | "gpt3.5-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}, { | ||
type: "HTML"; | ||
model: "gpt4-turbo" | "gpt3.5-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}>, | ||
z.ZodObject<{ | ||
model: z.ZodEnum<[ | ||
"claude-3-opus", | ||
"claude-3-sonnet", | ||
"claude-3-haiku", | ||
"gpt4-turbo" | ||
]>; | ||
type: z.ZodLiteral<"IMAGE">; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "IMAGE"; | ||
model: "gpt4-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}, { | ||
type: "IMAGE"; | ||
model: "gpt4-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}> | ||
]>>>; | ||
export type ExtractionStrategy = z.infer<typeof strategySchema>; | ||
export type ExtractionResultObject = Record<string, string | null> | null; | ||
export type InvalidatorFunction = (result: ExtractionResultObject) => string[]; | ||
export interface DynamicObjectExtractorOptions { | ||
entityName: string; | ||
entityDescription?: string; | ||
properties: Record<string, { | ||
description: string; | ||
required?: boolean; | ||
visible?: boolean; | ||
type?: "string"; | ||
}>; | ||
searchRegion?: Locator; | ||
optionalPropertiesInvalidator?: InvalidatorFunction; | ||
variantKey?: string; | ||
strategy?: ExtractionStrategy; | ||
} | ||
export type ExtractObjectUsingStaticSelectorsReturnType<T extends ObjectExtractor> = { | ||
[K in keyof T]: T[K] extends { | ||
extractionType?: "string-list"; | ||
} ? string[] | null : string | null; | ||
}; | ||
export type ExtractListObjectsUsingStaticSelectorsReturnType<T extends ListStaticExtractor> = { | ||
[K in keyof T["propertySelectors"]]: T["propertySelectors"][K] extends { | ||
extractionType?: "string-list"; | ||
} ? string[] | null : string | null; | ||
}[]; | ||
export type ExtractObjectDynamicExtractorReturnType<T extends ObjectJSONSchema> = Record<keyof T["properties"], string | null>; | ||
export type ExtractListDynamicExtractorReturnType<T extends ObjectJSONSchema> = Record<keyof T["properties"], string | null>[]; | ||
export type ExtractionResultList = Record<string, string>[]; | ||
export type ListInvalidatorFunction = (result: ExtractionResultList) => string[]; | ||
const listPropertiesInputSchema: z.ZodEffects<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{ | ||
primary: z.ZodOptional<z.ZodBoolean>; | ||
description: z.ZodString; | ||
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; | ||
visible: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; | ||
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"string">>>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "string"; | ||
visible: boolean; | ||
description: string; | ||
required: boolean; | ||
primary?: boolean | undefined; | ||
}, { | ||
description: string; | ||
primary?: boolean | undefined; | ||
required?: boolean | undefined; | ||
visible?: boolean | undefined; | ||
type?: "string" | undefined; | ||
}>>, Record<string, { | ||
type: "string"; | ||
visible: boolean; | ||
description: string; | ||
required: boolean; | ||
primary?: boolean | undefined; | ||
}>, Record<string, { | ||
description: string; | ||
primary?: boolean | undefined; | ||
required?: boolean | undefined; | ||
visible?: boolean | undefined; | ||
type?: "string" | undefined; | ||
}>>, Record<string, { | ||
type: "string"; | ||
visible: boolean; | ||
description: string; | ||
required: boolean; | ||
primary?: boolean | undefined; | ||
}>, Record<string, { | ||
description: string; | ||
primary?: boolean | undefined; | ||
required?: boolean | undefined; | ||
visible?: boolean | undefined; | ||
type?: "string" | undefined; | ||
}>>; | ||
const dynamicListExtractorOptionsSchema: z.ZodObject<{ | ||
listEntityName: z.ZodString; | ||
listEntityDescription: z.ZodOptional<z.ZodString>; | ||
variantKey: z.ZodOptional<z.ZodString>; | ||
optionalPropertiesInvalidator: z.ZodOptional<z.ZodFunction<z.ZodTuple<[ | ||
], z.ZodUnknown>, z.ZodUnknown>>; | ||
strategy: z.ZodDefault<z.ZodOptional<z.ZodUnion<[ | ||
z.ZodObject<{ | ||
model: z.ZodEnum<[ | ||
"claude-3-opus", | ||
"claude-3-sonnet", | ||
"claude-3-haiku", | ||
"gpt4-turbo", | ||
"gpt3.5-turbo" | ||
]>; | ||
type: z.ZodLiteral<"HTML">; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "HTML"; | ||
model: "gpt4-turbo" | "gpt3.5-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}, { | ||
type: "HTML"; | ||
model: "gpt4-turbo" | "gpt3.5-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}>, | ||
z.ZodObject<{ | ||
model: z.ZodEnum<[ | ||
"claude-3-opus", | ||
"claude-3-sonnet", | ||
"claude-3-haiku", | ||
"gpt4-turbo" | ||
]>; | ||
type: z.ZodLiteral<"IMAGE">; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "IMAGE"; | ||
model: "gpt4-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}, { | ||
type: "IMAGE"; | ||
model: "gpt4-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}> | ||
]>>>; | ||
}, "strip", z.ZodTypeAny, { | ||
strategy: { | ||
type: "HTML"; | ||
model: "gpt4-turbo" | "gpt3.5-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
} | { | ||
type: "IMAGE"; | ||
model: "gpt4-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
}; | ||
listEntityName: string; | ||
listEntityDescription?: string | undefined; | ||
variantKey?: string | undefined; | ||
optionalPropertiesInvalidator?: ((...args: unknown[]) => unknown) | undefined; | ||
}, { | ||
listEntityName: string; | ||
listEntityDescription?: string | undefined; | ||
variantKey?: string | undefined; | ||
optionalPropertiesInvalidator?: ((...args: unknown[]) => unknown) | undefined; | ||
strategy?: { | ||
type: "HTML"; | ||
model: "gpt4-turbo" | "gpt3.5-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
} | { | ||
type: "IMAGE"; | ||
model: "gpt4-turbo" | "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku"; | ||
} | undefined; | ||
}>; | ||
export interface DynamicListExtractorOptions extends Omit<z.infer<typeof dynamicListExtractorOptionsSchema>, "container" | "optionalPropertiesInvalidator"> { | ||
searchRegion?: Locator; | ||
optionalPropertiesInvalidator?: ListInvalidatorFunction; | ||
properties: z.input<typeof listPropertiesInputSchema>; | ||
} | ||
export type IntunedPageGoToOptions = Parameters<Page["goto"]>[1] & { | ||
/** | ||
* Whether to throw if the page.goto times out. Defaults to `false`. | ||
*/ | ||
throwOnTimeout?: boolean; | ||
}; | ||
class IntunedExtendedPage { | ||
private page; | ||
private constructor(); | ||
private getLocatorFromRegionElementSelector; | ||
convertToMarkdown(locator?: Locator | AbsoluteElementSelector): Promise<any>; | ||
/** | ||
* can be called like page['__saveSnapshotWithExamples']() | ||
* @param snapshotName | ||
* @param examples | ||
* @param s3Configs | ||
* @returns | ||
*/ | ||
private __saveSnapshotWithExamples; | ||
private ـgetVisiblePageHtml; | ||
private ـgetVisiblePageHtmlImpl; | ||
goto(url: string, options?: IntunedPageGoToOptions): ReturnType<Page["goto"]>; | ||
fillForm(formLocator: AbsoluteElementSelector | Locator, formFields: FormDataItem[], configs: FillFormConfigs, options?: FillFormOptions): Promise<boolean>; | ||
getFormFields(formLocator: Locator): Promise<InputFieldsInfo[]>; | ||
getAbsoluteElementReliableSelectors(element: Locator): Promise<string[]>; | ||
getRelativeElementReliableSelectors(anchorElement: Locator, relativeSelector: string): Promise<string[]>; | ||
extractDataUsingAiFromPage<T = any>(entityName: string, jsonSchema: JSONSchema, searchRegion?: AbsoluteElementSelector | Locator, model?: OpenAiModels): Promise<T>; | ||
classifyUsingAi(categories: ClassificationCategories): Promise<{ | ||
status: "failed" | "success"; | ||
result: any; | ||
}>; | ||
extractDataUsingAiFromImage<T = any>(entityName: string, jsonSchema: JSONSchema, searchRegion?: Locator): Promise<T>; | ||
dynamicObjectExtractor(identifier: string, options: DynamicObjectExtractorOptions): Promise<ExtractionResultObject | undefined>; | ||
dynamicListExtractor(identifier: string, options: DynamicListExtractorOptions): Promise<ExtractionResultList | undefined>; | ||
extractDataUsingAiFromText<T = any>(entityName: string, jsonSchema: JSONSchema, text: string, model?: OpenAiModels): Promise<T>; | ||
extractObjectDynamicExtractor<T extends ObjectJSONSchema>(entityName: string, jsonSchema: T, searchRegion?: AbsoluteElementSelector | Locator, InvalidatePropertyIfEmpty?: boolean): Promise<ExtractObjectDynamicExtractorReturnType<T>>; | ||
private findXpathForLocator; | ||
extractListDynamicExtractor<T extends ObjectJSONSchema>(entityName: string, jsonSchema: T, searchRegion?: AbsoluteElementSelector | Locator, InvalidatePropertyIfEmpty?: boolean): Promise<ExtractListDynamicExtractorReturnType<T>>; | ||
extractObjectUsingStaticSelectors<T extends ObjectExtractor>(extractor: T): Promise<ExtractObjectUsingStaticSelectorsReturnType<T>>; | ||
extractListObjectsUsingStaticSelectors<T extends ListStaticExtractor>(listExtractor: T): Promise<ExtractListObjectsUsingStaticSelectorsReturnType<T>>; | ||
static create(page: Page): EnhancedPlaywrightPage; | ||
} | ||
export type EnhancedPlaywrightPage = IntunedExtendedPage & Page; | ||
class IntunedExtendedBrowserContext { | ||
private context; | ||
constructor(context: BrowserContext); | ||
newPage(): Promise<EnhancedPlaywrightPage>; | ||
static create(context: BrowserContext): Promise<EnhancedPlaywrightBrowserContext>; | ||
} | ||
export type EnhancedPlaywrightBrowserContext = IntunedExtendedBrowserContext & BrowserContext; | ||
const PRIVATE_KEY: unique symbol; | ||
export interface RequestMoreInfoReturnTypeBase { | ||
[PRIVATE_KEY]: true; | ||
action: "request_more_info"; | ||
} | ||
export interface RequestMultipleChoiceReturnType extends RequestMoreInfoReturnTypeBase { | ||
messageToUser: string; | ||
choices: string[]; | ||
requestType: "multiple_choice"; | ||
} | ||
export interface RequestOtpReturnType extends RequestMoreInfoReturnTypeBase { | ||
messageToUser: string; | ||
requestType: "otp"; | ||
} | ||
export function requestOTP(messageToUser: string): RequestOtpReturnType; | ||
export function requestMultipleChoice(messageToUser: string, choices: string[]): RequestMultipleChoiceReturnType; | ||
export interface IntunedErrorOptions { | ||
retry: false; | ||
status_code?: number; | ||
error_code?: string; | ||
} | ||
export class IntunedError extends Error { | ||
options: IntunedErrorOptions; | ||
constructor(message: string, options?: IntunedErrorOptions); | ||
} | ||
export {}; | ||
} |
{ | ||
"name": "@intuned/runner-types", | ||
"version": "1.0.0-beta.27", | ||
"version": "1.0.0-beta.28", | ||
"description": "intuned runner types", | ||
@@ -5,0 +5,0 @@ "author": "Intuned Team", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
13231
486
1