phonesinc 2.0.1 → 2.0.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.
- package/README.md +29 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +7 -2
- package/dist/types.d.ts +3 -2
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Phones Inc public SDK
|
|
2
|
+
|
|
3
|
+
`phonesinc@2.0.2` lets a member login or organization API key manage its organization's virtual phones without naming a Mac: `provider` is optional in `virtualPhones.get`, `create`, `start` and `stop`. Calls that pass `provider` work as in 2.0.1. Public SDK source was restored from the published 2.0.0 source commit `f4565a2433497d77255193411d5f85c70602eb07` before the 2.0.1 change.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { PhonesInc } from "phonesinc";
|
|
7
|
+
const api = new PhonesInc({ token: process.env.PHONESINC_LOGIN_TOKEN! });
|
|
8
|
+
const created = await api.virtualPhones.create({
|
|
9
|
+
name: "My iPhone", idempotencyKey: "one-stable-request-key",
|
|
10
|
+
});
|
|
11
|
+
const inventory = await api.virtualPhones.get();
|
|
12
|
+
// Wait for state=running before starting an ordinary control session.
|
|
13
|
+
const session = await api.session.start({ phoneIds: ["<returned phone id>"] });
|
|
14
|
+
await api.key({ phoneIds: ["<returned phone id>"], key: "home" });
|
|
15
|
+
await api.session.end({ phoneIds: ["<returned phone id>"] });
|
|
16
|
+
await api.virtualPhones.stop({ phoneId: "<returned phone id>" });
|
|
17
|
+
await api.virtualPhones.start({ phoneId: "<returned phone id>" });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
An administrator login can also list the Macs and name one:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
const hosts = await api.virtualPhones.hosts();
|
|
24
|
+
const onMac = await api.virtualPhones.get({ provider: "VPhoneMacT0432" });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Every call returns `{ok:true,data}` or `{ok:false,error}`. Check this before using `data`. Creation and start return durable operation state; poll inventory until `running` or `error`. Reuse the same creation key after an uncertain response: the phone keeps its organization, and the retry returns it. A key reused with another name fails. Mutations are never automatically replayed.
|
|
28
|
+
|
|
29
|
+
Virtual phones belong to an organization. A member login or organization API key lists, creates, starts and stops only its own organizations' virtual phones. A new phone belongs to the caller's organization. A member of several organizations selects one with the `organizationId` client or request option. Creation keys are separate per organization: the same key in two organizations makes two phones. An administrator's new phone belongs to the default organization. Listing hosts requires an administrator login. Ordinary sessions, screenshots, touch, text and key calls retain their existing organization and session-holder checks. End the active session before starting or stopping a phone. The Mac admits one running VM and preserves stopped phones.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,17 +12,22 @@ export declare class PhonesInc {
|
|
|
12
12
|
private required;
|
|
13
13
|
private optional;
|
|
14
14
|
private custom;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* An organization's virtual phones: a member login or organization API key
|
|
17
|
+
* lists, creates, starts and stops its own; `provider` may be omitted (the
|
|
18
|
+
* API picks the Mac). `hosts` requires an administrator login. Creation is
|
|
19
|
+
* idempotent by key within the organization.
|
|
20
|
+
*/
|
|
16
21
|
readonly virtualPhones: {
|
|
17
22
|
hosts: OptionalEndpoint<Record<never, never>, VirtualPhoneHost[]>;
|
|
18
|
-
get:
|
|
19
|
-
provider
|
|
23
|
+
get: OptionalEndpoint<{
|
|
24
|
+
provider?: string;
|
|
20
25
|
}, {
|
|
21
26
|
machines: VirtualPhone[];
|
|
22
27
|
runningLimit: number;
|
|
23
28
|
}>;
|
|
24
29
|
create: Endpoint<{
|
|
25
|
-
provider
|
|
30
|
+
provider?: string;
|
|
26
31
|
name: string;
|
|
27
32
|
idempotencyKey: string;
|
|
28
33
|
}, VirtualPhone>;
|
package/dist/index.js
CHANGED
|
@@ -83,10 +83,15 @@ export class PhonesInc {
|
|
|
83
83
|
custom(path, run) {
|
|
84
84
|
return named(path, (body, options = {}) => run(path, body, options));
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* An organization's virtual phones: a member login or organization API key
|
|
88
|
+
* lists, creates, starts and stops its own; `provider` may be omitted (the
|
|
89
|
+
* API picks the Mac). `hosts` requires an administrator login. Creation is
|
|
90
|
+
* idempotent by key within the organization.
|
|
91
|
+
*/
|
|
87
92
|
virtualPhones = {
|
|
88
93
|
hosts: this.optional("/v1/virtual-phones/hosts"),
|
|
89
|
-
get: this.
|
|
94
|
+
get: this.optional("/v1/virtual-phones"),
|
|
90
95
|
create: this.required("/v1/virtual-phones/create"),
|
|
91
96
|
start: this.required("/v1/virtual-phones/start"),
|
|
92
97
|
stop: this.required("/v1/virtual-phones/stop"),
|
package/dist/types.d.ts
CHANGED
|
@@ -244,7 +244,7 @@ export type AppiumRequest = {
|
|
|
244
244
|
path: string;
|
|
245
245
|
body?: unknown;
|
|
246
246
|
};
|
|
247
|
-
/**
|
|
247
|
+
/** An organization's Mac VM; normal sessions authorize input. */
|
|
248
248
|
export type VirtualPhone = {
|
|
249
249
|
id: string;
|
|
250
250
|
name: string;
|
|
@@ -253,8 +253,9 @@ export type VirtualPhone = {
|
|
|
253
253
|
createdAt: number;
|
|
254
254
|
updatedAt: number;
|
|
255
255
|
};
|
|
256
|
+
/** `provider` is optional: the phone's own record names its Mac. */
|
|
256
257
|
export type VirtualPhoneTarget = {
|
|
257
|
-
provider
|
|
258
|
+
provider?: string;
|
|
258
259
|
phoneId: string;
|
|
259
260
|
};
|
|
260
261
|
export type VirtualPhoneHost = {
|