@limrun/api 0.69.3 → 0.70.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/device-detach.d.mts +6 -0
  3. package/device-detach.d.mts.map +1 -0
  4. package/device-detach.d.ts +6 -0
  5. package/device-detach.d.ts.map +1 -0
  6. package/device-detach.js +13 -0
  7. package/device-detach.js.map +1 -0
  8. package/device-detach.mjs +9 -0
  9. package/device-detach.mjs.map +1 -0
  10. package/index.d.mts +1 -0
  11. package/index.d.mts.map +1 -1
  12. package/index.d.ts +1 -0
  13. package/index.d.ts.map +1 -1
  14. package/index.js +4 -2
  15. package/index.js.map +1 -1
  16. package/index.mjs +1 -0
  17. package/index.mjs.map +1 -1
  18. package/instance-client.d.mts +11 -0
  19. package/instance-client.d.mts.map +1 -1
  20. package/instance-client.d.ts +11 -0
  21. package/instance-client.d.ts.map +1 -1
  22. package/instance-client.js +5 -0
  23. package/instance-client.js.map +1 -1
  24. package/instance-client.mjs +5 -0
  25. package/instance-client.mjs.map +1 -1
  26. package/internal/blocked-domains.d.mts +9 -0
  27. package/internal/blocked-domains.d.mts.map +1 -0
  28. package/internal/blocked-domains.d.ts +9 -0
  29. package/internal/blocked-domains.d.ts.map +1 -0
  30. package/internal/blocked-domains.js +32 -0
  31. package/internal/blocked-domains.js.map +1 -0
  32. package/internal/blocked-domains.mjs +28 -0
  33. package/internal/blocked-domains.mjs.map +1 -0
  34. package/internal/direct-instance-errors.d.mts +5 -0
  35. package/internal/direct-instance-errors.d.mts.map +1 -1
  36. package/internal/direct-instance-errors.d.ts +5 -0
  37. package/internal/direct-instance-errors.d.ts.map +1 -1
  38. package/internal/direct-instance-errors.js +15 -0
  39. package/internal/direct-instance-errors.js.map +1 -1
  40. package/internal/direct-instance-errors.mjs +14 -0
  41. package/internal/direct-instance-errors.mjs.map +1 -1
  42. package/internal/trusted-ca.d.mts.map +1 -1
  43. package/internal/trusted-ca.d.ts.map +1 -1
  44. package/internal/trusted-ca.js +2 -10
  45. package/internal/trusted-ca.js.map +1 -1
  46. package/internal/trusted-ca.mjs +2 -10
  47. package/internal/trusted-ca.mjs.map +1 -1
  48. package/ios-client.d.mts +11 -0
  49. package/ios-client.d.mts.map +1 -1
  50. package/ios-client.d.ts +11 -0
  51. package/ios-client.d.ts.map +1 -1
  52. package/ios-client.js +5 -0
  53. package/ios-client.js.map +1 -1
  54. package/ios-client.mjs +5 -0
  55. package/ios-client.mjs.map +1 -1
  56. package/package.json +11 -1
  57. package/resources/access-tokens.d.mts +2 -1
  58. package/resources/access-tokens.d.mts.map +1 -1
  59. package/resources/access-tokens.d.ts +2 -1
  60. package/resources/access-tokens.d.ts.map +1 -1
  61. package/resources/android-instances.d.mts +8 -0
  62. package/resources/android-instances.d.mts.map +1 -1
  63. package/resources/android-instances.d.ts +8 -0
  64. package/resources/android-instances.d.ts.map +1 -1
  65. package/resources/gradle-instances-helpers.d.mts +2 -0
  66. package/resources/gradle-instances-helpers.d.mts.map +1 -1
  67. package/resources/gradle-instances-helpers.d.ts +2 -0
  68. package/resources/gradle-instances-helpers.d.ts.map +1 -1
  69. package/resources/gradle-instances-helpers.js +8 -2
  70. package/resources/gradle-instances-helpers.js.map +1 -1
  71. package/resources/gradle-instances-helpers.mjs +8 -2
  72. package/resources/gradle-instances-helpers.mjs.map +1 -1
  73. package/resources/ios-instances.d.mts +8 -0
  74. package/resources/ios-instances.d.mts.map +1 -1
  75. package/resources/ios-instances.d.ts +8 -0
  76. package/resources/ios-instances.d.ts.map +1 -1
  77. package/resources/xcode-instances-helpers.d.mts +2 -0
  78. package/resources/xcode-instances-helpers.d.mts.map +1 -1
  79. package/resources/xcode-instances-helpers.d.ts +2 -0
  80. package/resources/xcode-instances-helpers.d.ts.map +1 -1
  81. package/resources/xcode-instances-helpers.js +8 -0
  82. package/resources/xcode-instances-helpers.js.map +1 -1
  83. package/resources/xcode-instances-helpers.mjs +8 -0
  84. package/resources/xcode-instances-helpers.mjs.map +1 -1
  85. package/src/device-detach.ts +9 -0
  86. package/src/index.ts +1 -0
  87. package/src/instance-client.ts +22 -0
  88. package/src/internal/blocked-domains.ts +37 -0
  89. package/src/internal/direct-instance-errors.ts +14 -0
  90. package/src/internal/trusted-ca.ts +2 -9
  91. package/src/ios-client.ts +22 -0
  92. package/src/resources/access-tokens.ts +2 -1
  93. package/src/resources/android-instances.ts +9 -0
  94. package/src/resources/gradle-instances-helpers.ts +13 -2
  95. package/src/resources/ios-instances.ts +9 -0
  96. package/src/resources/xcode-instances-helpers.ts +16 -0
  97. package/src/version.ts +1 -1
  98. package/version.d.mts +1 -1
  99. package/version.d.ts +1 -1
  100. package/version.js +1 -1
  101. package/version.mjs +1 -1
package/src/ios-client.ts CHANGED
@@ -17,6 +17,7 @@ import { prepareAppBundlePath, watchAppArchive } from './app-archive';
17
17
  import { downloadFileToLocalPath } from './internal/download-file';
18
18
  import { sleep } from './internal/utils/sleep';
19
19
  import { nodeProxyTransport } from './internal/proxy-transport';
20
+ import { requestBlockedDomains } from './internal/blocked-domains';
20
21
  import { postTrustedCaCertificate } from './internal/trusted-ca';
21
22
  import {
22
23
  getDestinationTunnelStatus,
@@ -1144,6 +1145,19 @@ export type InstanceClient = {
1144
1145
  */
1145
1146
  addCaCertificate: (pem: string) => Promise<TrustedCaCertificate>;
1146
1147
 
1148
+ /**
1149
+ * Replace the names the simulator cannot resolve, so its apps and browser never
1150
+ * reach them, and return the list in force. Each entry is an exact name, or a
1151
+ * `*.` wildcard that covers every subdomain but not the name itself: blocking a
1152
+ * whole site takes both `example.com` and `*.example.com`. An empty list
1153
+ * unblocks everything. Connections an app already holds stay open until it
1154
+ * reconnects, so relaunch the app after blocking a site it has open.
1155
+ */
1156
+ setBlockedDomains: (domains: string[]) => Promise<string[]>;
1157
+
1158
+ /** The names the simulator cannot resolve. */
1159
+ getBlockedDomains: () => Promise<string[]>;
1160
+
1147
1161
  /**
1148
1162
  * Clear the registered StoreKit configuration for `bundleId` and
1149
1163
  * remove the app's Octane file so subsequent StoreKit requests fall
@@ -2338,6 +2352,8 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2338
2352
  syncApp,
2339
2353
  setStoreKitConfig,
2340
2354
  addCaCertificate,
2355
+ setBlockedDomains,
2356
+ getBlockedDomains,
2341
2357
  clearStoreKitConfig,
2342
2358
  discoverStoreKitConfig,
2343
2359
  softReset,
@@ -3228,6 +3244,12 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
3228
3244
  const addCaCertificate = (pem: string): Promise<TrustedCaCertificate> =>
3229
3245
  postTrustedCaCertificate(`${options.apiUrl}/trusted-cas`, options.token, pem);
3230
3246
 
3247
+ const setBlockedDomains = (domains: string[]): Promise<string[]> =>
3248
+ requestBlockedDomains(`${options.apiUrl}/blocked-domains`, options.token, domains);
3249
+
3250
+ const getBlockedDomains = (): Promise<string[]> =>
3251
+ requestBlockedDomains(`${options.apiUrl}/blocked-domains`, options.token);
3252
+
3231
3253
  const clearStoreKitConfig = async (bundleId: string): Promise<void> => {
3232
3254
  const url = `${options.apiUrl}/payments/storeKitConfigs/${encodeURIComponent(bundleId)}`;
3233
3255
  const response = await nodeProxyTransport.fetch(url, {
@@ -29,7 +29,8 @@ export interface AccessTokenCreateParams {
29
29
  * `asset:asset_01h455vb4pex5vsknk084sn02q:read` or `applerelay:*:connect`.
30
30
  * Instance control accepts `ios:<id>:all`, `android:<id>:all`, `xcode:<id>:all`,
31
31
  * and `gradle:<id>:all`. Use the returned instance ID, including `sandbox_` for Xcode.
32
- * iOS and Android also accept `ios:<id>:stream` and `android:<id>:stream` for
32
+ * iOS and Android accept `ios:<id>:watch` and `android:<id>:watch` for watch-only
33
+ * streaming, or `ios:<id>:stream` and `android:<id>:stream` for
33
34
  * interactive streaming without device API or app-management access.
34
35
  * Instance wildcards and other instance actions are not accepted.
35
36
  * See https://docs.limrun.com/docs/reference/permissions for targets and actions.
@@ -281,6 +281,15 @@ export namespace AndroidInstanceCreateParams {
281
281
 
282
282
  sandbox?: Spec.Sandbox;
283
283
 
284
+ /**
285
+ * Names the device cannot resolve, so its apps and browser never reach them.
286
+ * Each entry is an exact name, or a `*.` wildcard that covers every subdomain
287
+ * but not the name itself: blocking a whole site takes both `example.com` and
288
+ * `*.example.com`. The list is in force before the instance becomes ready;
289
+ * change it later with the instance client's `setBlockedDomains`.
290
+ */
291
+ blockedDomains?: Array<string>;
292
+
284
293
  /**
285
294
  * Names a private tunnel, created in the console (Network) or the API, that
286
295
  * serves this instance. Creation fails while no connector (`lim tunnel run`)
@@ -1,3 +1,4 @@
1
+ import { DeviceDetachUnavailableError } from '../device-detach';
1
2
  import { nodeProxyTransport } from '../internal/proxy-transport';
2
3
  import type { AndroidInstance } from './android-instances';
3
4
  import { pullBuildFile } from '../internal/build-pull-file';
@@ -102,6 +103,8 @@ export type GradleClient = {
102
103
  /** Attach an emulator, install the latest retained APK, and auto-install future builds. */
103
104
  attachEmulator(emulator: AndroidInstance | { apiUrl: string; token: string }): Promise<EmulatorStatus>;
104
105
  getEmulator(): Promise<EmulatorStatus>;
106
+ /** Disconnect the emulator, keeping both instances and installed apps. */
107
+ detachEmulator(): Promise<EmulatorStatus>;
105
108
  /** Stream a regular file to disk. Paths may be absolute or relative to the synced project root. */
106
109
  pullFile(remotePath: string, localPath: string): Promise<void>;
107
110
  sync(localCodePath: string, opts?: GradleSyncOptions): Promise<SyncResult>;
@@ -170,12 +173,19 @@ class GradleInstancesHelpers extends GradleInstances {
170
173
  const log = createDaemonLogger('[GradleInstance]', params.logLevel ?? 'info');
171
174
  const client = this._client;
172
175
 
173
- async function emulatorRequest(body?: { apiUrl: string; token: string }): Promise<EmulatorStatus> {
176
+ async function emulatorRequest(
177
+ body?: { apiUrl: string; token: string },
178
+ method = body ? 'POST' : 'GET',
179
+ ): Promise<EmulatorStatus> {
174
180
  const response = await nodeProxyTransport.fetch(`${apiUrl}/emulator`, {
175
- method: body ? 'POST' : 'GET',
181
+ method,
176
182
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
177
183
  ...(body ? { body: JSON.stringify(body) } : {}),
178
184
  });
185
+ if (method === 'DELETE' && response.status === 404) {
186
+ await response.text().catch(() => undefined);
187
+ throw new DeviceDetachUnavailableError('DELETE /emulator');
188
+ }
179
189
  if (!response.ok)
180
190
  throw new Error(`Emulator attachment returned HTTP ${response.status}: ${await response.text()}`);
181
191
  return (await response.json()) as EmulatorStatus;
@@ -183,6 +193,7 @@ class GradleInstancesHelpers extends GradleInstances {
183
193
 
184
194
  return {
185
195
  getEmulator: () => emulatorRequest(),
196
+ detachEmulator: () => emulatorRequest(undefined, 'DELETE'),
186
197
  async attachEmulator(emulator) {
187
198
  if ('status' in emulator) {
188
199
  if (!emulator.status.apiUrl) throw new Error('Emulator is not ready: apiUrl is unavailable');
@@ -271,6 +271,15 @@ export namespace IosInstanceCreateParams {
271
271
  */
272
272
  region?: string;
273
273
 
274
+ /**
275
+ * Names the device cannot resolve, so its apps and browser never reach them.
276
+ * Each entry is an exact name, or a `*.` wildcard that covers every subdomain
277
+ * but not the name itself: blocking a whole site takes both `example.com` and
278
+ * `*.example.com`. The list is in force before the instance becomes ready;
279
+ * change it later with the instance client's `setBlockedDomains`.
280
+ */
281
+ blockedDomains?: Array<string>;
282
+
274
283
  /**
275
284
  * Names a private tunnel, created in the console (Network) or the API, that
276
285
  * serves this instance. Creation fails while no connector (`lim tunnel run`)
@@ -1,3 +1,4 @@
1
+ import { DeviceDetachUnavailableError } from '../device-detach';
1
2
  import { pullBuildFile } from '../internal/build-pull-file';
2
3
  import { normalizeAssetUpload, type BuildUpload } from '../lib/asset-permissions';
3
4
  import {
@@ -524,6 +525,9 @@ export type XcodeClient = {
524
525
  */
525
526
  getSimulator: () => Promise<SimulatorStatus>;
526
527
 
528
+ /** Disconnect the simulator, keeping both instances and installed apps. */
529
+ detachSimulator: () => Promise<SimulatorStatus>;
530
+
527
531
  /**
528
532
  * Return the Xcode this sandbox builds with and the Xcodes installed on its node.
529
533
  * Throws XcodeSelectionUnsupportedError on a sandbox whose daemon predates selection.
@@ -1061,6 +1065,18 @@ export class XcodeInstances extends GeneratedXcodeInstances {
1061
1065
  return readJsonResponse<SimulatorStatus>(res, 'GET /simulator');
1062
1066
  },
1063
1067
 
1068
+ async detachSimulator(): Promise<SimulatorStatus> {
1069
+ const res = await nodeProxyTransport.fetch(`${apiUrl}/simulator`, {
1070
+ method: 'DELETE',
1071
+ headers: { Authorization: `Bearer ${token}` },
1072
+ });
1073
+ return readOrUnsupported<SimulatorStatus>(
1074
+ res,
1075
+ 'DELETE /simulator',
1076
+ (op) => new DeviceDetachUnavailableError(op),
1077
+ );
1078
+ },
1079
+
1064
1080
  attachSimulator: attachSimulatorImpl,
1065
1081
  attachNewSimulator: attachNewSimulatorImpl,
1066
1082
  deleteSimulator: deleteSimulatorImpl,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.69.3'; // x-release-please-version
1
+ export const VERSION = '0.70.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.69.3";
1
+ export declare const VERSION = "0.70.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.69.3";
1
+ export declare const VERSION = "0.70.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.69.3'; // x-release-please-version
4
+ exports.VERSION = '0.70.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.69.3'; // x-release-please-version
1
+ export const VERSION = '0.70.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map