gpt-driver-node 1.0.0-alpha.14 → 1.0.0-alpha.16

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/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ class GptDriver {
26
26
  driver;
27
27
  appiumSessionStarted;
28
28
  useGptDriverCloud;
29
- gptDriverCloudPlatform;
29
+ gptDriverCloudConfig;
30
30
  buildId;
31
31
  /**
32
32
  * Creates an instance of the GptDriver class.
@@ -55,7 +55,11 @@ class GptDriver {
55
55
  if (config.serverConfig?.device?.platform == null) {
56
56
  throw new Error("Platform is missing. Please specify the platform when using GPTDriver Cloud.");
57
57
  }
58
- this.gptDriverCloudPlatform = config.serverConfig.device?.platform;
58
+ this.gptDriverCloudConfig = {
59
+ platform: config.serverConfig.device?.platform,
60
+ deviceName: config.serverConfig.device?.deviceName,
61
+ platformVersion: config.serverConfig.device?.platformVersion
62
+ };
59
63
  } else {
60
64
  this.initializeDriver(config);
61
65
  this.initializeAppiumConfig(config);
@@ -160,9 +164,9 @@ class GptDriver {
160
164
  api_key: this.apiKey,
161
165
  appium_session_id: this.appiumSessionConfig?.id,
162
166
  device_config: {
163
- platform: this.appiumSessionConfig?.platform ?? this.gptDriverCloudPlatform,
164
- device: this.appiumSessionConfig?.deviceName,
165
- os: this.appiumSessionConfig?.platformVersion
167
+ platform: this.appiumSessionConfig?.platform ?? this.gptDriverCloudConfig?.platform,
168
+ device: this.appiumSessionConfig?.deviceName ?? this.gptDriverCloudConfig?.deviceName,
169
+ os: this.appiumSessionConfig?.platformVersion ?? this.gptDriverCloudConfig?.platformVersion
166
170
  },
167
171
  use_internal_virtual_device: this.useGptDriverCloud,
168
172
  build_id: this.buildId
@@ -404,6 +408,37 @@ class GptDriver {
404
408
  throw e;
405
409
  }
406
410
  }
411
+ /**
412
+ * Opens a deep link url in the Appium session.
413
+ *
414
+ * This method sends a request to the GPT Driver server to open a deep link url in the Appium session.
415
+ *
416
+ * @param {OpenDeepLinkUrlParams} params - The parameters for opening the deep link url.
417
+ * @returns {Promise<void>} A promise that resolves when the deep link url is opened.
418
+ */
419
+ async openDeepLinkUrl(params) {
420
+ if (!this.appiumSessionStarted) {
421
+ await this.startSession();
422
+ }
423
+ console.log("Opening deep link", params);
424
+ if (params.package == null && this.appiumSessionConfig?.platform === "Android") {
425
+ throw new Error("Package is required for Android platform");
426
+ }
427
+ await this.executeCommand(
428
+ {
429
+ url: `http://localhost:4723/session/${this.appiumSessionConfig?.id}/execute/sync`,
430
+ method: "POST",
431
+ data: {
432
+ "script": "mobile:deepLink",
433
+ "args": [{
434
+ url: params.url,
435
+ ...params.bundleId && { bundleId: params.bundleId },
436
+ ...params.package && { package: params.package }
437
+ }]
438
+ }
439
+ }
440
+ );
441
+ }
407
442
  async executeCommand(command) {
408
443
  const firstAction = command?.data?.actions?.at(0);
409
444
  if (firstAction?.type === "pause" && firstAction.duration != null) {
package/dist/index.d.cts CHANGED
@@ -20,6 +20,16 @@ interface GptDriverConfig {
20
20
  useGptDriverCloud?: boolean;
21
21
  buildId?: string;
22
22
  }
23
+ /**
24
+ * Parameters for opening a deep link url in the Appium session.
25
+ * Provide a package if the platform is Android.
26
+ * Provide a bundleId if the platform is iOS.
27
+ */
28
+ interface OpenDeepLinkUrlParams {
29
+ url: string;
30
+ package?: string;
31
+ bundleId?: string;
32
+ }
23
33
 
24
34
  declare class GptDriver {
25
35
  private apiKey;
@@ -29,7 +39,7 @@ declare class GptDriver {
29
39
  private driver?;
30
40
  private appiumSessionStarted?;
31
41
  private useGptDriverCloud?;
32
- private gptDriverCloudPlatform?;
42
+ private gptDriverCloudConfig?;
33
43
  private buildId?;
34
44
  /**
35
45
  * Creates an instance of the GptDriver class.
@@ -132,6 +142,15 @@ declare class GptDriver {
132
142
  */
133
143
  extract(extractions: string[]): Promise<any>;
134
144
  private gptHandler;
145
+ /**
146
+ * Opens a deep link url in the Appium session.
147
+ *
148
+ * This method sends a request to the GPT Driver server to open a deep link url in the Appium session.
149
+ *
150
+ * @param {OpenDeepLinkUrlParams} params - The parameters for opening the deep link url.
151
+ * @returns {Promise<void>} A promise that resolves when the deep link url is opened.
152
+ */
153
+ openDeepLinkUrl(params: OpenDeepLinkUrlParams): Promise<void>;
135
154
  private executeCommand;
136
155
  private getScreenshot;
137
156
  }
package/dist/index.mjs CHANGED
@@ -24,7 +24,7 @@ class GptDriver {
24
24
  driver;
25
25
  appiumSessionStarted;
26
26
  useGptDriverCloud;
27
- gptDriverCloudPlatform;
27
+ gptDriverCloudConfig;
28
28
  buildId;
29
29
  /**
30
30
  * Creates an instance of the GptDriver class.
@@ -53,7 +53,11 @@ class GptDriver {
53
53
  if (config.serverConfig?.device?.platform == null) {
54
54
  throw new Error("Platform is missing. Please specify the platform when using GPTDriver Cloud.");
55
55
  }
56
- this.gptDriverCloudPlatform = config.serverConfig.device?.platform;
56
+ this.gptDriverCloudConfig = {
57
+ platform: config.serverConfig.device?.platform,
58
+ deviceName: config.serverConfig.device?.deviceName,
59
+ platformVersion: config.serverConfig.device?.platformVersion
60
+ };
57
61
  } else {
58
62
  this.initializeDriver(config);
59
63
  this.initializeAppiumConfig(config);
@@ -158,9 +162,9 @@ class GptDriver {
158
162
  api_key: this.apiKey,
159
163
  appium_session_id: this.appiumSessionConfig?.id,
160
164
  device_config: {
161
- platform: this.appiumSessionConfig?.platform ?? this.gptDriverCloudPlatform,
162
- device: this.appiumSessionConfig?.deviceName,
163
- os: this.appiumSessionConfig?.platformVersion
165
+ platform: this.appiumSessionConfig?.platform ?? this.gptDriverCloudConfig?.platform,
166
+ device: this.appiumSessionConfig?.deviceName ?? this.gptDriverCloudConfig?.deviceName,
167
+ os: this.appiumSessionConfig?.platformVersion ?? this.gptDriverCloudConfig?.platformVersion
164
168
  },
165
169
  use_internal_virtual_device: this.useGptDriverCloud,
166
170
  build_id: this.buildId
@@ -402,6 +406,37 @@ class GptDriver {
402
406
  throw e;
403
407
  }
404
408
  }
409
+ /**
410
+ * Opens a deep link url in the Appium session.
411
+ *
412
+ * This method sends a request to the GPT Driver server to open a deep link url in the Appium session.
413
+ *
414
+ * @param {OpenDeepLinkUrlParams} params - The parameters for opening the deep link url.
415
+ * @returns {Promise<void>} A promise that resolves when the deep link url is opened.
416
+ */
417
+ async openDeepLinkUrl(params) {
418
+ if (!this.appiumSessionStarted) {
419
+ await this.startSession();
420
+ }
421
+ console.log("Opening deep link", params);
422
+ if (params.package == null && this.appiumSessionConfig?.platform === "Android") {
423
+ throw new Error("Package is required for Android platform");
424
+ }
425
+ await this.executeCommand(
426
+ {
427
+ url: `http://localhost:4723/session/${this.appiumSessionConfig?.id}/execute/sync`,
428
+ method: "POST",
429
+ data: {
430
+ "script": "mobile:deepLink",
431
+ "args": [{
432
+ url: params.url,
433
+ ...params.bundleId && { bundleId: params.bundleId },
434
+ ...params.package && { package: params.package }
435
+ }]
436
+ }
437
+ }
438
+ );
439
+ }
405
440
  async executeCommand(command) {
406
441
  const firstAction = command?.data?.actions?.at(0);
407
442
  if (firstAction?.type === "pause" && firstAction.duration != null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gpt-driver-node",
3
- "version": "1.0.0-alpha.14",
3
+ "version": "1.0.0-alpha.16",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.cts",