@limrun/api 0.49.0 → 0.49.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build-settings.d.mts.map +1 -1
  3. package/build-settings.d.ts.map +1 -1
  4. package/build-settings.js +4 -5
  5. package/build-settings.js.map +1 -1
  6. package/build-settings.mjs +4 -5
  7. package/build-settings.mjs.map +1 -1
  8. package/client.d.mts +2 -2
  9. package/client.d.mts.map +1 -1
  10. package/client.d.ts +2 -2
  11. package/client.d.ts.map +1 -1
  12. package/client.js.map +1 -1
  13. package/client.mjs.map +1 -1
  14. package/exec-client.d.mts +9 -0
  15. package/exec-client.d.mts.map +1 -1
  16. package/exec-client.d.ts +9 -0
  17. package/exec-client.d.ts.map +1 -1
  18. package/exec-client.js.map +1 -1
  19. package/exec-client.mjs.map +1 -1
  20. package/index.d.mts +2 -1
  21. package/index.d.mts.map +1 -1
  22. package/index.d.ts +2 -1
  23. package/index.d.ts.map +1 -1
  24. package/index.js +5 -2
  25. package/index.js.map +1 -1
  26. package/index.mjs +2 -1
  27. package/index.mjs.map +1 -1
  28. package/instance-client.d.mts +2 -0
  29. package/instance-client.d.mts.map +1 -1
  30. package/instance-client.d.ts +2 -0
  31. package/instance-client.d.ts.map +1 -1
  32. package/instance-client.js.map +1 -1
  33. package/instance-client.mjs.map +1 -1
  34. package/ios-client.d.mts +3 -1
  35. package/ios-client.d.mts.map +1 -1
  36. package/ios-client.d.ts +3 -1
  37. package/ios-client.d.ts.map +1 -1
  38. package/ios-client.js.map +1 -1
  39. package/ios-client.mjs.map +1 -1
  40. package/package.json +1 -1
  41. package/resources/index.d.mts +1 -1
  42. package/resources/index.d.mts.map +1 -1
  43. package/resources/index.d.ts +1 -1
  44. package/resources/index.d.ts.map +1 -1
  45. package/resources/index.js +2 -1
  46. package/resources/index.js.map +1 -1
  47. package/resources/index.mjs +1 -1
  48. package/resources/index.mjs.map +1 -1
  49. package/resources/xcode-instances-helpers.d.mts +57 -0
  50. package/resources/xcode-instances-helpers.d.mts.map +1 -1
  51. package/resources/xcode-instances-helpers.d.ts +57 -0
  52. package/resources/xcode-instances-helpers.d.ts.map +1 -1
  53. package/resources/xcode-instances-helpers.js +49 -3
  54. package/resources/xcode-instances-helpers.js.map +1 -1
  55. package/resources/xcode-instances-helpers.mjs +47 -2
  56. package/resources/xcode-instances-helpers.mjs.map +1 -1
  57. package/src/build-settings.ts +4 -5
  58. package/src/client.ts +8 -0
  59. package/src/exec-client.ts +9 -0
  60. package/src/index.ts +6 -0
  61. package/src/instance-client.ts +2 -0
  62. package/src/ios-client.ts +3 -1
  63. package/src/resources/index.ts +5 -0
  64. package/src/resources/xcode-instances-helpers.ts +118 -5
  65. package/src/version.ts +1 -1
  66. package/version.d.mts +1 -1
  67. package/version.d.ts +1 -1
  68. package/version.js +1 -1
  69. package/version.mjs +1 -1
package/src/index.ts CHANGED
@@ -103,8 +103,13 @@ export {
103
103
  type RbeBuildSummary,
104
104
  type Tunnel,
105
105
  RbeUnsupportedError,
106
+ XcodeSelectionUnsupportedError,
106
107
  deriveRbeTunnelUrl,
107
108
  DEFAULT_RBE_TUNNEL_PORT,
109
+ type XcodeInfo,
110
+ type XcodeStatus,
111
+ type XcodeSelectResult,
112
+ type SandboxInfo,
108
113
  type XcodeProjectConfig,
109
114
  type XcodeBuildOptions,
110
115
  type XcodeRunOptions,
@@ -195,3 +200,4 @@ export {
195
200
  PermissionDeniedError,
196
201
  UnprocessableEntityError,
197
202
  } from './core/error';
203
+ export { isDirectInstanceHttpError, type DirectInstanceHttpError } from './internal/direct-instance-errors';
@@ -629,6 +629,8 @@ export type InstalledApp = {
629
629
  installType: string;
630
630
  /** App icon as a base64-encoded 64px PNG; absent when the runtime could not extract one. */
631
631
  icon?: string;
632
+ /** Install time as epoch milliseconds; absent when the runtime cannot tell. */
633
+ installedAt?: number;
632
634
  };
633
635
 
634
636
  /** Handle for an app watch registered via {@link InstanceClient.watchApp}. */
package/src/ios-client.ts CHANGED
@@ -70,7 +70,7 @@ export function deriveReverseTunnelUrl(apiUrl: string, remotePort: number): stri
70
70
  export type { ReverseTunnel } from './tunnel';
71
71
  export type Tunnel = DestinationTcpTunnel;
72
72
  export type TunnelOptions = {
73
- /** Exact endpoint selector values that the server may ask this client to dial. */
73
+ /** Exact endpoint (host:port) and domain selector values; the server asks this client to dial exact endpoints and intercepted domains. */
74
74
  selectors: DestinationTunnelSelectors;
75
75
  /** Controls tunnel logging verbosity. Defaults to the instance client's log level. */
76
76
  logLevel?: LogLevel;
@@ -243,6 +243,8 @@ export type InstalledApp = {
243
243
  installType: string;
244
244
  /** App icon as a base64-encoded 64px PNG; absent when the runtime could not extract one. */
245
245
  icon?: string;
246
+ /** Install time as epoch milliseconds; absent when the runtime cannot tell (e.g. iOS system apps). */
247
+ installedAt?: number;
246
248
  };
247
249
 
248
250
  export type LsofEntry = {
@@ -56,7 +56,12 @@ export {
56
56
  export {
57
57
  XcodeInstances,
58
58
  RbeUnsupportedError,
59
+ XcodeSelectionUnsupportedError,
59
60
  DEFAULT_RBE_TUNNEL_PORT,
61
+ type XcodeInfo,
62
+ type XcodeStatus,
63
+ type XcodeSelectResult,
64
+ type SandboxInfo,
60
65
  type XcodeCreateClientParams,
61
66
  type XcodeClient,
62
67
  type XcodeProjectConfig,
@@ -373,6 +373,46 @@ export type RbeStatus = {
373
373
  /** Default local TCP port the RBE tunnel listens on. */
374
374
  export const DEFAULT_RBE_TUNNEL_PORT = 8980;
375
375
 
376
+ /** One Xcode installed on the sandbox's node, as reported by limbuild's /xcode. */
377
+ export type XcodeInfo = {
378
+ /** Major version, e.g. "27". Empty on nodes that predate the Xcode inventory. */
379
+ major: string;
380
+ /** Short version, e.g. "27.0". */
381
+ version: string;
382
+ /** Build, e.g. "27A5252f". */
383
+ build: string;
384
+ /**
385
+ * The version key builds and caches are stamped with (major.minor.patch.build,
386
+ * e.g. 27.0.0.27A5252f). Empty until resolved on a cold node.
387
+ */
388
+ versionKey: string;
389
+ developerDir: string;
390
+ /** Apple's seed number when this Xcode is a beta ("6" for beta 6). Absent for a release. */
391
+ betaSeed?: string;
392
+ /** Whether this is the Xcode the sandbox binds to when nothing was selected. */
393
+ nodeDefault: boolean;
394
+ };
395
+
396
+ /** The sandbox's Xcode binding and the Xcodes it can switch to. */
397
+ export type XcodeStatus = {
398
+ bound: XcodeInfo;
399
+ installed: XcodeInfo[];
400
+ };
401
+
402
+ /** Result of binding the sandbox to an Xcode major. */
403
+ export type XcodeSelectResult = {
404
+ bound: XcodeInfo;
405
+ alreadyBound: boolean;
406
+ /** Whether synced projects lost their DerivedData because the Xcode changed. */
407
+ derivedDataReset: boolean;
408
+ };
409
+
410
+ /** limbuild's GET /info: the sandbox home and, on daemons that support selection, its Xcode. */
411
+ export type SandboxInfo = {
412
+ homeDir: string;
413
+ xcode?: XcodeInfo;
414
+ };
415
+
376
416
  export type RbeStartOptions = {
377
417
  /** Max size of the content-addressable store (CAS), in bytes. */
378
418
  casMaxBytes?: number;
@@ -498,6 +538,22 @@ export type XcodeClient = {
498
538
  */
499
539
  getSimulator: () => Promise<SimulatorStatus>;
500
540
 
541
+ /**
542
+ * Return the Xcode this sandbox builds with and the Xcodes installed on its node.
543
+ * Throws XcodeSelectionUnsupportedError on a sandbox whose daemon predates selection.
544
+ */
545
+ getXcode: () => Promise<XcodeStatus>;
546
+
547
+ /**
548
+ * Bind the sandbox to an installed Xcode major (e.g. "27"). Switching resets every
549
+ * synced project's DerivedData. Refused (HTTP 409) while a build, command, sync, or
550
+ * the RBE stack is running, and (HTTP 400) when the major is not installed.
551
+ */
552
+ setXcode: (major: string) => Promise<XcodeSelectResult>;
553
+
554
+ /** Return the sandbox's home directory and, when the daemon reports it, its Xcode. */
555
+ getInfo: () => Promise<SandboxInfo>;
556
+
501
557
  /**
502
558
  * Start the instance's embedded Bazel Remote Build Execution stack.
503
559
  * Idempotent: returns the running status when already up.
@@ -591,19 +647,20 @@ function normalizeWorkspaceRelativePath(remotePath: string): string {
591
647
  return parts.join('/');
592
648
  }
593
649
 
594
- async function fetchSandboxInfo(apiUrl: string, token: string): Promise<{ homeDir: string }> {
650
+ async function fetchSandboxInfo(apiUrl: string, token: string): Promise<SandboxInfo> {
595
651
  const res = await nodeProxyTransport.fetch(`${apiUrl}/info`, {
596
652
  method: 'GET',
597
653
  headers: {
598
654
  Authorization: `Bearer ${token}`,
599
655
  },
600
656
  });
601
- const body = await readJsonResponse<{ homeDir?: string }>(res, 'GET /info');
657
+ const body = await readJsonResponse<{ homeDir?: string; xcode?: XcodeInfo }>(res, 'GET /info');
602
658
  if (!body.homeDir) {
603
659
  throw new Error('GET /info response is missing homeDir');
604
660
  }
605
661
  return {
606
662
  homeDir: normalizeWorkspaceRelativePath(body.homeDir),
663
+ ...(body.xcode ? { xcode: body.xcode } : {}),
607
664
  };
608
665
  }
609
666
 
@@ -646,14 +703,46 @@ export class RbeUnsupportedError extends LimrunError {
646
703
  }
647
704
  }
648
705
 
706
+ /**
707
+ * Raised when an `/xcode` request returns 404: the sandbox's daemon predates Xcode
708
+ * version selection. Distinct from NotFoundError for the same reason as
709
+ * RbeUnsupportedError: the instance exists, only the feature is missing.
710
+ */
711
+ export class XcodeSelectionUnsupportedError extends LimrunError {
712
+ constructor(operation: string) {
713
+ super(
714
+ `Xcode version selection is not available on this sandbox (${operation} returned 404): ` +
715
+ 'its daemon predates Xcode selection. Create a new sandbox, or omit the Xcode version to build with its default.',
716
+ );
717
+ this.name = 'XcodeSelectionUnsupportedError';
718
+ }
719
+ }
720
+
721
+ /** Reads an `/xcode` JSON response, mapping a 404 to XcodeSelectionUnsupportedError. */
722
+ function readXcodeResponse<T>(res: Response, operation: string): Promise<T> {
723
+ return readOrUnsupported<T>(res, operation, (op) => new XcodeSelectionUnsupportedError(op));
724
+ }
725
+
649
726
  /**
650
727
  * Reads an `/rbe` JSON response, mapping a 404 to RbeUnsupportedError (a route
651
728
  * 404 means RBE is not supported here, never a missing instance).
652
729
  */
653
- async function readRbeResponse<T>(res: Response, operation: string): Promise<T> {
730
+ function readRbeResponse<T>(res: Response, operation: string): Promise<T> {
731
+ return readOrUnsupported<T>(res, operation, (op) => new RbeUnsupportedError(op));
732
+ }
733
+
734
+ /**
735
+ * Reads a JSON response from a limbuild route that only newer daemons serve: a 404 there means
736
+ * the feature is missing, never that the instance is (the caller's error class says which).
737
+ */
738
+ async function readOrUnsupported<T>(
739
+ res: Response,
740
+ operation: string,
741
+ unsupported: (operation: string) => Error,
742
+ ): Promise<T> {
654
743
  if (res.status === 404) {
655
744
  await res.text().catch(() => undefined);
656
- throw new RbeUnsupportedError(operation);
745
+ throw unsupported(operation);
657
746
  }
658
747
  return readJsonResponse<T>(res, operation);
659
748
  }
@@ -777,7 +866,7 @@ export class XcodeInstances extends GeneratedXcodeInstances {
777
866
 
778
867
  const log = createDaemonLogger('[XcodeInstance]', params.logLevel ?? 'info');
779
868
  const client = this._client;
780
- let sandboxInfoPromise: Promise<{ homeDir: string }> | undefined;
869
+ let sandboxInfoPromise: Promise<SandboxInfo> | undefined;
781
870
  const getSandboxInfo = () => {
782
871
  sandboxInfoPromise ??= fetchSandboxInfo(apiUrl, token);
783
872
  return sandboxInfoPromise;
@@ -996,6 +1085,30 @@ export class XcodeInstances extends GeneratedXcodeInstances {
996
1085
  attachNewSimulator: attachNewSimulatorImpl,
997
1086
  deleteSimulator: deleteSimulatorImpl,
998
1087
 
1088
+ async getXcode(): Promise<XcodeStatus> {
1089
+ const res = await nodeProxyTransport.fetch(`${apiUrl}/xcode`, {
1090
+ method: 'GET',
1091
+ headers: {
1092
+ Authorization: `Bearer ${token}`,
1093
+ },
1094
+ });
1095
+ return readXcodeResponse<XcodeStatus>(res, 'GET /xcode');
1096
+ },
1097
+
1098
+ async setXcode(major: string): Promise<XcodeSelectResult> {
1099
+ const res = await nodeProxyTransport.fetch(`${apiUrl}/xcode`, {
1100
+ method: 'POST',
1101
+ headers: {
1102
+ 'Content-Type': 'application/json',
1103
+ Authorization: `Bearer ${token}`,
1104
+ },
1105
+ body: JSON.stringify({ version: major }),
1106
+ });
1107
+ return readXcodeResponse<XcodeSelectResult>(res, 'POST /xcode');
1108
+ },
1109
+
1110
+ getInfo: () => fetchSandboxInfo(apiUrl, token),
1111
+
999
1112
  async startRbe(opts?: RbeStartOptions): Promise<RbeStatus> {
1000
1113
  const res = await nodeProxyTransport.fetch(`${apiUrl}/rbe`, {
1001
1114
  method: 'POST',
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.49.0'; // x-release-please-version
1
+ export const VERSION = '0.49.2'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.49.0";
1
+ export declare const VERSION = "0.49.2";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.49.0";
1
+ export declare const VERSION = "0.49.2";
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.49.0'; // x-release-please-version
4
+ exports.VERSION = '0.49.2'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.49.0'; // x-release-please-version
1
+ export const VERSION = '0.49.2'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map