@hira-core/sdk 1.0.1 → 1.0.3
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.
- package/README.md +57 -46
- package/dist/index.d.ts +455 -12
- package/dist/index.js +17194 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -30,8 +30,18 @@ import {
|
|
|
30
30
|
|
|
31
31
|
const config = {
|
|
32
32
|
globalInput: [
|
|
33
|
-
{
|
|
34
|
-
|
|
33
|
+
{
|
|
34
|
+
key: "targetUrl",
|
|
35
|
+
label: "Target URL",
|
|
36
|
+
type: "text" as const,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "delay",
|
|
41
|
+
label: "Delay (ms)",
|
|
42
|
+
type: "number" as const,
|
|
43
|
+
defaultValue: 2000,
|
|
44
|
+
},
|
|
35
45
|
],
|
|
36
46
|
profileInput: [
|
|
37
47
|
{ key: "username", label: "Username", type: "text" as const },
|
|
@@ -81,13 +91,16 @@ await flow.run(
|
|
|
81
91
|
antidetect: {
|
|
82
92
|
name: "GPM",
|
|
83
93
|
profileSettings: [
|
|
84
|
-
flow.createProfileSetting("ProfileA", {
|
|
94
|
+
flow.createProfileSetting("ProfileA", {
|
|
95
|
+
username: "user1",
|
|
96
|
+
password: "pass1",
|
|
97
|
+
}),
|
|
85
98
|
],
|
|
86
99
|
},
|
|
87
100
|
execution: { concurrency: 2, maxRetries: 1 },
|
|
88
101
|
globalInput: { targetUrl: "https://example.com", delay: 2000 },
|
|
89
102
|
window: { width: 1280, height: 720, scale: 1 },
|
|
90
|
-
})
|
|
103
|
+
}),
|
|
91
104
|
);
|
|
92
105
|
```
|
|
93
106
|
|
|
@@ -99,21 +112,21 @@ await flow.run(
|
|
|
99
112
|
|
|
100
113
|
Abstract base class for browser automation flows.
|
|
101
114
|
|
|
102
|
-
| Method / Property
|
|
103
|
-
|
|
104
|
-
| `abstract script(context)`
|
|
105
|
-
| `run(params)`
|
|
106
|
-
| `createRunParams(params)`
|
|
107
|
-
| `createProfileSetting(name, data?)` | Type-safe helper to build profile settings
|
|
108
|
-
| `flowConfig`
|
|
115
|
+
| Method / Property | Description |
|
|
116
|
+
| ----------------------------------- | ------------------------------------------------ |
|
|
117
|
+
| `abstract script(context)` | Your automation logic — implement this |
|
|
118
|
+
| `run(params)` | Start the flow (called by Hira Agent) |
|
|
119
|
+
| `createRunParams(params)` | Type-safe helper to build run params |
|
|
120
|
+
| `createProfileSetting(name, data?)` | Type-safe helper to build profile settings |
|
|
121
|
+
| `flowConfig` | The declared config schema (embedded in `.hira`) |
|
|
109
122
|
|
|
110
123
|
### `AntidetectProvider`
|
|
111
124
|
|
|
112
125
|
```typescript
|
|
113
126
|
enum AntidetectProvider {
|
|
114
|
-
GPM = "gpm",
|
|
115
|
-
HIDEMIUM = "hidemium",
|
|
116
|
-
GENLOGIN = "genlogin",
|
|
127
|
+
GPM = "gpm", // GPM Login antidetect browser
|
|
128
|
+
HIDEMIUM = "hidemium", // coming soon
|
|
129
|
+
GENLOGIN = "genlogin", // coming soon
|
|
117
130
|
}
|
|
118
131
|
```
|
|
119
132
|
|
|
@@ -121,15 +134,15 @@ enum AntidetectProvider {
|
|
|
121
134
|
|
|
122
135
|
Injected into `script()` by the runtime:
|
|
123
136
|
|
|
124
|
-
| Field
|
|
125
|
-
|
|
126
|
-
| `browser`
|
|
127
|
-
| `page`
|
|
128
|
-
| `profile`
|
|
129
|
-
| `index`
|
|
130
|
-
| `globalInput`
|
|
131
|
-
| `profileInput` | `InferProfileInput<TConfig>` | Typed per-profile inputs
|
|
132
|
-
| `logger`
|
|
137
|
+
| Field | Type | Description |
|
|
138
|
+
| -------------- | ---------------------------- | -------------------------------------------- |
|
|
139
|
+
| `browser` | `Browser` | Puppeteer browser instance |
|
|
140
|
+
| `page` | `Page` | Active page |
|
|
141
|
+
| `profile` | `IGpmProfile` | Current GPM profile info |
|
|
142
|
+
| `index` | `number` | Profile index in the batch |
|
|
143
|
+
| `globalInput` | `InferGlobalInput<TConfig>` | Typed global inputs |
|
|
144
|
+
| `profileInput` | `InferProfileInput<TConfig>` | Typed per-profile inputs |
|
|
145
|
+
| `logger` | `ILogger` | Bound logger (auto-tagged with profile name) |
|
|
133
146
|
|
|
134
147
|
### `BrowserUtils`
|
|
135
148
|
|
|
@@ -139,23 +152,23 @@ Helper class for common browser actions. All methods auto-log and respect the ab
|
|
|
139
152
|
const utils = new BrowserUtils(context);
|
|
140
153
|
```
|
|
141
154
|
|
|
142
|
-
| Method
|
|
143
|
-
|
|
144
|
-
| `utils.goto(url)`
|
|
145
|
-
| `utils.click(selector)`
|
|
146
|
-
| `utils.type(selector, text)`
|
|
147
|
-
| `utils.getText(selector)`
|
|
148
|
-
| `utils.exists(selector, timeout?)`
|
|
149
|
-
| `utils.waitForElement(selector, timeout?)` | Wait for element
|
|
150
|
-
| `utils.waitForNavigation()`
|
|
151
|
-
| `utils.screenshot(path?)`
|
|
152
|
-
| `utils.switchToPopup(matcher)`
|
|
153
|
-
| `utils.switchToTabIndex(index)`
|
|
154
|
-
| `utils.closeCurrentTab()`
|
|
155
|
-
| `utils.closeOtherTabs()`
|
|
156
|
-
| `utils.sleep(ms)`
|
|
157
|
-
| `utils.logGlobalInput()`
|
|
158
|
-
| `utils.logProfileInput()`
|
|
155
|
+
| Method | Description |
|
|
156
|
+
| ------------------------------------------ | ----------------------------- |
|
|
157
|
+
| `utils.goto(url)` | Navigate to URL |
|
|
158
|
+
| `utils.click(selector)` | Wait + scroll + click |
|
|
159
|
+
| `utils.type(selector, text)` | Wait + clear + type |
|
|
160
|
+
| `utils.getText(selector)` | Get text content |
|
|
161
|
+
| `utils.exists(selector, timeout?)` | Check element exists |
|
|
162
|
+
| `utils.waitForElement(selector, timeout?)` | Wait for element |
|
|
163
|
+
| `utils.waitForNavigation()` | Wait for page navigation |
|
|
164
|
+
| `utils.screenshot(path?)` | Take screenshot |
|
|
165
|
+
| `utils.switchToPopup(matcher)` | Switch to popup tab |
|
|
166
|
+
| `utils.switchToTabIndex(index)` | Switch to tab by index |
|
|
167
|
+
| `utils.closeCurrentTab()` | Close current tab |
|
|
168
|
+
| `utils.closeOtherTabs()` | Close all other tabs |
|
|
169
|
+
| `utils.sleep(ms)` | Delay (respects abort signal) |
|
|
170
|
+
| `utils.logGlobalInput()` | Log all global inputs |
|
|
171
|
+
| `utils.logProfileInput()` | Log all profile inputs |
|
|
159
172
|
|
|
160
173
|
### `FlowLogger`
|
|
161
174
|
|
|
@@ -177,8 +190,8 @@ Schema declaration for your flow's inputs:
|
|
|
177
190
|
|
|
178
191
|
```typescript
|
|
179
192
|
interface IFlowConfig {
|
|
180
|
-
globalInput: readonly IInputField[];
|
|
181
|
-
profileInput: readonly IInputField[];
|
|
193
|
+
globalInput: readonly IInputField[]; // shared across all profiles
|
|
194
|
+
profileInput: readonly IInputField[]; // per-profile data
|
|
182
195
|
}
|
|
183
196
|
|
|
184
197
|
interface IInputField {
|
|
@@ -201,12 +214,10 @@ The SDK automatically infers TypeScript types from your config at compile time:
|
|
|
201
214
|
```typescript
|
|
202
215
|
const config = {
|
|
203
216
|
globalInput: [
|
|
204
|
-
{ key: "url",
|
|
217
|
+
{ key: "url", type: "text" as const },
|
|
205
218
|
{ key: "count", type: "number" as const },
|
|
206
219
|
],
|
|
207
|
-
profileInput: [
|
|
208
|
-
{ key: "username", type: "text" as const },
|
|
209
|
-
],
|
|
220
|
+
profileInput: [{ key: "username", type: "text" as const }],
|
|
210
221
|
} as const satisfies IFlowConfig;
|
|
211
222
|
|
|
212
223
|
// Inside script():
|