phonesinc 1.1.0 → 2.0.1
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.d.ts +30 -2
- package/dist/index.js +25 -2
- package/dist/types.d.ts +52 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiResponse, App, AppiumRequest, AppRequest, ClientOptions, Endpoint, FileExport, Identity, KeyRequest, Media, MediaSource, MediaUploadRequest, OptionalEndpoint, Phone, PhoneFile, PhoneResult, PhoneSelection, PhoneTargets, RequestOptions, ScreenRequest, Screenshot, Session, Stream, TouchRequest, TypeRequest } from "./types.js";
|
|
1
|
+
import type { VirtualPhone, VirtualPhoneHost, VirtualPhoneTarget, ApiResponse, App, AppiumRequest, AppRequest, ClientOptions, Endpoint, FileExport, Identity, KeyRequest, Media, MediaImported, MediaImportFailed, MediaImporting, MediaImportStatusRequest, MediaSource, MediaUploadRequest, OptionalEndpoint, Phone, PhoneFile, PhoneResult, PhoneSelection, PhoneTargets, RequestOptions, ScreenRequest, Screenshot, Session, Stream, TouchRequest, TypeRequest } from "./types.js";
|
|
2
2
|
export type * from "./types.js";
|
|
3
3
|
/** Public phone operations. A request is sent once; actions are never replayed. */
|
|
4
4
|
export declare class PhonesInc {
|
|
@@ -12,6 +12,23 @@ export declare class PhonesInc {
|
|
|
12
12
|
private required;
|
|
13
13
|
private optional;
|
|
14
14
|
private custom;
|
|
15
|
+
/** Requires an administrator login token. Creation is idempotent by key. */
|
|
16
|
+
readonly virtualPhones: {
|
|
17
|
+
hosts: OptionalEndpoint<Record<never, never>, VirtualPhoneHost[]>;
|
|
18
|
+
get: Endpoint<{
|
|
19
|
+
provider: string;
|
|
20
|
+
}, {
|
|
21
|
+
machines: VirtualPhone[];
|
|
22
|
+
runningLimit: number;
|
|
23
|
+
}>;
|
|
24
|
+
create: Endpoint<{
|
|
25
|
+
provider: string;
|
|
26
|
+
name: string;
|
|
27
|
+
idempotencyKey: string;
|
|
28
|
+
}, VirtualPhone>;
|
|
29
|
+
start: Endpoint<VirtualPhoneTarget, VirtualPhone>;
|
|
30
|
+
stop: Endpoint<VirtualPhoneTarget, VirtualPhone>;
|
|
31
|
+
};
|
|
15
32
|
readonly me: OptionalEndpoint<Record<never, never>, Identity>;
|
|
16
33
|
readonly phones: {
|
|
17
34
|
get: OptionalEndpoint<PhoneSelection, Phone[]>;
|
|
@@ -87,7 +104,18 @@ export declare class PhonesInc {
|
|
|
87
104
|
}, {
|
|
88
105
|
deleted: string[];
|
|
89
106
|
}>;
|
|
90
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Adds the item to each phone's photo library. `status: "imported"`: it is there;
|
|
109
|
+
* `status: "importing"`: not finished (still running near the request's time limit, or an
|
|
110
|
+
* outcome the provider's answer left unknown); read it with `importStatus`.
|
|
111
|
+
* A file over 1 GiB is refused with `file_too_large`.
|
|
112
|
+
*/
|
|
113
|
+
import: Endpoint<PhoneTargets & MediaSource, PhoneResult<MediaImported | MediaImporting>[]>;
|
|
114
|
+
/**
|
|
115
|
+
* How each phone's import stands: `importing` (ask again), `imported` or `failed` (with `failure`).
|
|
116
|
+
* `ok: false` means the status could not be read on that phone (`not_found`, `phone_offline`, `timeout`).
|
|
117
|
+
*/
|
|
118
|
+
importStatus: Endpoint<MediaImportStatusRequest, PhoneResult<MediaImported | MediaImporting | MediaImportFailed>[]>;
|
|
91
119
|
};
|
|
92
120
|
readonly clipboard: {
|
|
93
121
|
get: OptionalEndpoint<PhoneSelection, PhoneResult<{
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,14 @@ export class PhonesInc {
|
|
|
83
83
|
custom(path, run) {
|
|
84
84
|
return named(path, (body, options = {}) => run(path, body, options));
|
|
85
85
|
}
|
|
86
|
+
/** Requires an administrator login token. Creation is idempotent by key. */
|
|
87
|
+
virtualPhones = {
|
|
88
|
+
hosts: this.optional("/v1/virtual-phones/hosts"),
|
|
89
|
+
get: this.required("/v1/virtual-phones"),
|
|
90
|
+
create: this.required("/v1/virtual-phones/create"),
|
|
91
|
+
start: this.required("/v1/virtual-phones/start"),
|
|
92
|
+
stop: this.required("/v1/virtual-phones/stop"),
|
|
93
|
+
};
|
|
86
94
|
me = this.optional("/v1/me");
|
|
87
95
|
phones = {
|
|
88
96
|
get: this.optional("/v1/phones"),
|
|
@@ -111,8 +119,12 @@ export class PhonesInc {
|
|
|
111
119
|
return;
|
|
112
120
|
}
|
|
113
121
|
const organizationId = options.organizationId === undefined ? this.organizationId : options.organizationId;
|
|
114
|
-
socket.send(JSON.stringify({
|
|
115
|
-
|
|
122
|
+
socket.send(JSON.stringify({
|
|
123
|
+
type: "attach",
|
|
124
|
+
token,
|
|
125
|
+
...view,
|
|
126
|
+
...(organizationId == null ? {} : { organizationId }),
|
|
127
|
+
}));
|
|
116
128
|
}, { once: true });
|
|
117
129
|
return socket;
|
|
118
130
|
}),
|
|
@@ -156,7 +168,18 @@ export class PhonesInc {
|
|
|
156
168
|
return this.request(path, body, options);
|
|
157
169
|
}),
|
|
158
170
|
delete: this.required("/v1/media/delete"),
|
|
171
|
+
/**
|
|
172
|
+
* Adds the item to each phone's photo library. `status: "imported"`: it is there;
|
|
173
|
+
* `status: "importing"`: not finished (still running near the request's time limit, or an
|
|
174
|
+
* outcome the provider's answer left unknown); read it with `importStatus`.
|
|
175
|
+
* A file over 1 GiB is refused with `file_too_large`.
|
|
176
|
+
*/
|
|
159
177
|
import: this.required("/v1/media/import"),
|
|
178
|
+
/**
|
|
179
|
+
* How each phone's import stands: `importing` (ask again), `imported` or `failed` (with `failure`).
|
|
180
|
+
* `ok: false` means the status could not be read on that phone (`not_found`, `phone_offline`, `timeout`).
|
|
181
|
+
*/
|
|
182
|
+
importStatus: this.required("/v1/media/import/status"),
|
|
160
183
|
};
|
|
161
184
|
clipboard = {
|
|
162
185
|
get: this.optional("/v1/clipboard"),
|
package/dist/types.d.ts
CHANGED
|
@@ -146,6 +146,40 @@ export type MediaSource = {
|
|
|
146
146
|
url: string;
|
|
147
147
|
mediaId?: never;
|
|
148
148
|
};
|
|
149
|
+
/** A media import's stage while it runs. */
|
|
150
|
+
export type ImportPhase = "queued" | "downloading" | "transferring" | "syncing" | "confirming";
|
|
151
|
+
/** Why an import failed: the phone error `media.import` answered for it. */
|
|
152
|
+
export type ImportFailureCode = "unsupported" | "storage_full" | "file_too_large" | "file_not_found" | "phone_offline" | "internal_error";
|
|
153
|
+
/** The item is in the phone's photo library. */
|
|
154
|
+
export type MediaImported = {
|
|
155
|
+
status: "imported";
|
|
156
|
+
importId: string;
|
|
157
|
+
};
|
|
158
|
+
/** The import is still running; `totalBytes` is 0 until known. */
|
|
159
|
+
export type MediaImporting = {
|
|
160
|
+
status: "importing";
|
|
161
|
+
importId: string;
|
|
162
|
+
phase: ImportPhase;
|
|
163
|
+
bytesTransferred: number;
|
|
164
|
+
totalBytes: number;
|
|
165
|
+
};
|
|
166
|
+
/** The import ended without the item. */
|
|
167
|
+
export type MediaImportFailed = {
|
|
168
|
+
status: "failed";
|
|
169
|
+
importId: string;
|
|
170
|
+
failure: {
|
|
171
|
+
code: ImportFailureCode;
|
|
172
|
+
message: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
/** One import by the media item imported (the phone's latest) or by its `importId`. */
|
|
176
|
+
export type MediaImportStatusRequest = PhoneTargets & ({
|
|
177
|
+
mediaId: string;
|
|
178
|
+
importId?: never;
|
|
179
|
+
} | {
|
|
180
|
+
importId: string;
|
|
181
|
+
mediaId?: never;
|
|
182
|
+
});
|
|
149
183
|
export type AppRequest = PhoneTargets & {
|
|
150
184
|
appId: string;
|
|
151
185
|
};
|
|
@@ -210,3 +244,21 @@ export type AppiumRequest = {
|
|
|
210
244
|
path: string;
|
|
211
245
|
body?: unknown;
|
|
212
246
|
};
|
|
247
|
+
/** Administrator-only Mac VM lifecycle; normal sessions authorize input. */
|
|
248
|
+
export type VirtualPhone = {
|
|
249
|
+
id: string;
|
|
250
|
+
name: string;
|
|
251
|
+
state: "creating" | "starting" | "running" | "stopping" | "stopped" | "error";
|
|
252
|
+
error: string | null;
|
|
253
|
+
createdAt: number;
|
|
254
|
+
updatedAt: number;
|
|
255
|
+
};
|
|
256
|
+
export type VirtualPhoneTarget = {
|
|
257
|
+
provider: string;
|
|
258
|
+
phoneId: string;
|
|
259
|
+
};
|
|
260
|
+
export type VirtualPhoneHost = {
|
|
261
|
+
provider: string;
|
|
262
|
+
connected: boolean;
|
|
263
|
+
runningLimit: number;
|
|
264
|
+
};
|