phonesinc 2.0.0 → 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 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
@@ -1,4 +1,4 @@
1
- import type { 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";
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,28 @@ export declare class PhonesInc {
12
12
  private required;
13
13
  private optional;
14
14
  private custom;
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
+ */
21
+ readonly virtualPhones: {
22
+ hosts: OptionalEndpoint<Record<never, never>, VirtualPhoneHost[]>;
23
+ get: OptionalEndpoint<{
24
+ provider?: string;
25
+ }, {
26
+ machines: VirtualPhone[];
27
+ runningLimit: number;
28
+ }>;
29
+ create: Endpoint<{
30
+ provider?: string;
31
+ name: string;
32
+ idempotencyKey: string;
33
+ }, VirtualPhone>;
34
+ start: Endpoint<VirtualPhoneTarget, VirtualPhone>;
35
+ stop: Endpoint<VirtualPhoneTarget, VirtualPhone>;
36
+ };
15
37
  readonly me: OptionalEndpoint<Record<never, never>, Identity>;
16
38
  readonly phones: {
17
39
  get: OptionalEndpoint<PhoneSelection, Phone[]>;
package/dist/index.js CHANGED
@@ -83,6 +83,19 @@ export class PhonesInc {
83
83
  custom(path, run) {
84
84
  return named(path, (body, options = {}) => run(path, body, options));
85
85
  }
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
+ */
92
+ virtualPhones = {
93
+ hosts: this.optional("/v1/virtual-phones/hosts"),
94
+ get: this.optional("/v1/virtual-phones"),
95
+ create: this.required("/v1/virtual-phones/create"),
96
+ start: this.required("/v1/virtual-phones/start"),
97
+ stop: this.required("/v1/virtual-phones/stop"),
98
+ };
86
99
  me = this.optional("/v1/me");
87
100
  phones = {
88
101
  get: this.optional("/v1/phones"),
@@ -111,8 +124,12 @@ export class PhonesInc {
111
124
  return;
112
125
  }
113
126
  const organizationId = options.organizationId === undefined ? this.organizationId : options.organizationId;
114
- socket.send(JSON.stringify({ type: "attach", token, ...view,
115
- ...(organizationId == null ? {} : { organizationId }) }));
127
+ socket.send(JSON.stringify({
128
+ type: "attach",
129
+ token,
130
+ ...view,
131
+ ...(organizationId == null ? {} : { organizationId }),
132
+ }));
116
133
  }, { once: true });
117
134
  return socket;
118
135
  }),
package/dist/types.d.ts CHANGED
@@ -244,3 +244,22 @@ export type AppiumRequest = {
244
244
  path: string;
245
245
  body?: unknown;
246
246
  };
247
+ /** An organization's Mac VM; 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
+ /** `provider` is optional: the phone's own record names its Mac. */
257
+ export type VirtualPhoneTarget = {
258
+ provider?: string;
259
+ phoneId: string;
260
+ };
261
+ export type VirtualPhoneHost = {
262
+ provider: string;
263
+ connected: boolean;
264
+ runningLimit: number;
265
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonesinc",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "The public Phones Inc API client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",