phonesinc 1.1.0 → 2.0.0

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 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 { 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 {
@@ -87,7 +87,18 @@ export declare class PhonesInc {
87
87
  }, {
88
88
  deleted: string[];
89
89
  }>;
90
- import: Endpoint<PhoneTargets & MediaSource, PhoneResult[]>;
90
+ /**
91
+ * Adds the item to each phone's photo library. `status: "imported"`: it is there;
92
+ * `status: "importing"`: not finished (still running near the request's time limit, or an
93
+ * outcome the provider's answer left unknown); read it with `importStatus`.
94
+ * A file over 1 GiB is refused with `file_too_large`.
95
+ */
96
+ import: Endpoint<PhoneTargets & MediaSource, PhoneResult<MediaImported | MediaImporting>[]>;
97
+ /**
98
+ * How each phone's import stands: `importing` (ask again), `imported` or `failed` (with `failure`).
99
+ * `ok: false` means the status could not be read on that phone (`not_found`, `phone_offline`, `timeout`).
100
+ */
101
+ importStatus: Endpoint<MediaImportStatusRequest, PhoneResult<MediaImported | MediaImporting | MediaImportFailed>[]>;
91
102
  };
92
103
  readonly clipboard: {
93
104
  get: OptionalEndpoint<PhoneSelection, PhoneResult<{
package/dist/index.js CHANGED
@@ -156,7 +156,18 @@ export class PhonesInc {
156
156
  return this.request(path, body, options);
157
157
  }),
158
158
  delete: this.required("/v1/media/delete"),
159
+ /**
160
+ * Adds the item to each phone's photo library. `status: "imported"`: it is there;
161
+ * `status: "importing"`: not finished (still running near the request's time limit, or an
162
+ * outcome the provider's answer left unknown); read it with `importStatus`.
163
+ * A file over 1 GiB is refused with `file_too_large`.
164
+ */
159
165
  import: this.required("/v1/media/import"),
166
+ /**
167
+ * How each phone's import stands: `importing` (ask again), `imported` or `failed` (with `failure`).
168
+ * `ok: false` means the status could not be read on that phone (`not_found`, `phone_offline`, `timeout`).
169
+ */
170
+ importStatus: this.required("/v1/media/import/status"),
160
171
  };
161
172
  clipboard = {
162
173
  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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonesinc",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "The public Phones Inc API client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",