@limrun/api 0.82.0 → 0.83.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/CHANGELOG.md +31 -0
- package/README.md +4 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts.map +1 -1
- package/core/api-promise.js +0 -1
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs +0 -1
- package/core/api-promise.mjs.map +1 -1
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts.map +1 -1
- package/core/error.js +0 -1
- package/core/error.js.map +1 -1
- package/core/error.mjs +0 -1
- package/core/error.mjs.map +1 -1
- package/core/pagination.d.mts.map +1 -1
- package/core/pagination.d.ts.map +1 -1
- package/core/pagination.js +0 -1
- package/core/pagination.js.map +1 -1
- package/core/pagination.mjs +0 -1
- package/core/pagination.mjs.map +1 -1
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js +0 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs +0 -1
- package/core/resource.mjs.map +1 -1
- package/exec-client.d.mts +3 -3
- package/exec-client.d.ts +3 -3
- package/gradle-snapshot.d.mts +9 -1
- package/gradle-snapshot.d.mts.map +1 -1
- package/gradle-snapshot.d.ts +9 -1
- package/gradle-snapshot.d.ts.map +1 -1
- package/gradle-snapshot.js.map +1 -1
- package/gradle-snapshot.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +4 -3
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/internal/builtin-types.d.mts.map +1 -1
- package/internal/builtin-types.d.ts.map +1 -1
- package/internal/builtin-types.js +0 -1
- package/internal/builtin-types.js.map +1 -1
- package/internal/builtin-types.mjs +0 -1
- package/internal/builtin-types.mjs.map +1 -1
- package/internal/daemon-snapshot.d.mts +29 -0
- package/internal/daemon-snapshot.d.mts.map +1 -0
- package/internal/daemon-snapshot.d.ts +29 -0
- package/internal/daemon-snapshot.d.ts.map +1 -0
- package/internal/daemon-snapshot.js +137 -0
- package/internal/daemon-snapshot.js.map +1 -0
- package/internal/daemon-snapshot.mjs +134 -0
- package/internal/daemon-snapshot.mjs.map +1 -0
- package/internal/detect-platform.d.mts.map +1 -1
- package/internal/detect-platform.d.ts.map +1 -1
- package/internal/detect-platform.js +0 -1
- package/internal/detect-platform.js.map +1 -1
- package/internal/detect-platform.mjs +0 -1
- package/internal/detect-platform.mjs.map +1 -1
- package/internal/errors.d.mts.map +1 -1
- package/internal/errors.d.ts.map +1 -1
- package/internal/errors.js +0 -1
- package/internal/errors.js.map +1 -1
- package/internal/errors.mjs +0 -1
- package/internal/errors.mjs.map +1 -1
- package/internal/headers.d.mts.map +1 -1
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +0 -1
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +0 -1
- package/internal/headers.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +0 -1
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +0 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js +0 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs +0 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/shim-types.d.mts.map +1 -1
- package/internal/shim-types.d.ts.map +1 -1
- package/internal/shim-types.js +6 -1
- package/internal/shim-types.js.map +1 -1
- package/internal/shim-types.mjs +6 -1
- package/internal/shim-types.mjs.map +1 -1
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts.map +1 -1
- package/internal/shims.js +6 -1
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +6 -1
- package/internal/shims.mjs.map +1 -1
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts.map +1 -1
- package/internal/types.js +0 -1
- package/internal/types.js.map +1 -1
- package/internal/types.mjs +0 -1
- package/internal/types.mjs.map +1 -1
- package/internal/utils/base64.d.mts.map +1 -1
- package/internal/utils/base64.d.ts.map +1 -1
- package/internal/utils/base64.js +0 -1
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +0 -1
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/env.d.mts.map +1 -1
- package/internal/utils/env.d.ts.map +1 -1
- package/internal/utils/env.js +0 -1
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +0 -1
- package/internal/utils/env.mjs.map +1 -1
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +0 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +0 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/query.d.mts.map +1 -1
- package/internal/utils/query.d.ts.map +1 -1
- package/internal/utils/query.js +0 -1
- package/internal/utils/query.js.map +1 -1
- package/internal/utils/query.mjs +0 -1
- package/internal/utils/query.mjs.map +1 -1
- package/internal/utils/sleep.d.mts.map +1 -1
- package/internal/utils/sleep.d.ts.map +1 -1
- package/internal/utils/sleep.js +0 -1
- package/internal/utils/sleep.js.map +1 -1
- package/internal/utils/sleep.mjs +0 -1
- package/internal/utils/sleep.mjs.map +1 -1
- package/internal/utils/uuid.d.mts.map +1 -1
- package/internal/utils/uuid.d.ts.map +1 -1
- package/internal/utils/uuid.js +0 -1
- package/internal/utils/uuid.js.map +1 -1
- package/internal/utils/uuid.mjs +0 -1
- package/internal/utils/uuid.mjs.map +1 -1
- package/internal/utils/values.d.mts.map +1 -1
- package/internal/utils/values.d.ts.map +1 -1
- package/internal/utils/values.js +0 -1
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +0 -1
- package/internal/utils/values.mjs.map +1 -1
- package/internal/utils.d.mts.map +1 -1
- package/internal/utils.d.ts.map +1 -1
- package/internal/utils.js +0 -1
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +0 -1
- package/internal/utils.mjs.map +1 -1
- package/package.json +2 -2
- package/resources/analytics.d.mts.map +1 -1
- package/resources/analytics.d.ts.map +1 -1
- package/resources/analytics.js +0 -1
- package/resources/analytics.js.map +1 -1
- package/resources/analytics.mjs +0 -1
- package/resources/analytics.mjs.map +1 -1
- package/resources/android-instances.d.mts.map +1 -1
- package/resources/android-instances.d.ts.map +1 -1
- package/resources/android-instances.js +0 -1
- package/resources/android-instances.js.map +1 -1
- package/resources/android-instances.mjs +0 -1
- package/resources/android-instances.mjs.map +1 -1
- package/resources/assets.d.mts.map +1 -1
- package/resources/assets.d.ts.map +1 -1
- package/resources/assets.js +0 -1
- package/resources/assets.js.map +1 -1
- package/resources/assets.mjs +0 -1
- package/resources/assets.mjs.map +1 -1
- package/resources/daemon-client-shared.d.mts.map +1 -1
- package/resources/daemon-client-shared.d.ts.map +1 -1
- package/resources/daemon-client-shared.js.map +1 -1
- package/resources/daemon-client-shared.mjs.map +1 -1
- package/resources/gradle-instances-helpers.d.mts.map +1 -1
- package/resources/gradle-instances-helpers.d.ts.map +1 -1
- package/resources/gradle-instances-helpers.js +25 -37
- package/resources/gradle-instances-helpers.js.map +1 -1
- package/resources/gradle-instances-helpers.mjs +25 -37
- package/resources/gradle-instances-helpers.mjs.map +1 -1
- package/resources/gradle-instances.d.mts.map +1 -1
- package/resources/gradle-instances.d.ts.map +1 -1
- package/resources/gradle-instances.js +0 -2
- package/resources/gradle-instances.js.map +1 -1
- package/resources/gradle-instances.mjs +0 -2
- package/resources/gradle-instances.mjs.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/ios-instances.d.mts.map +1 -1
- package/resources/ios-instances.d.ts.map +1 -1
- package/resources/ios-instances.js +0 -1
- package/resources/ios-instances.js.map +1 -1
- package/resources/ios-instances.mjs +0 -1
- package/resources/ios-instances.mjs.map +1 -1
- package/resources/macos-instances-helpers.d.mts +27 -3
- package/resources/macos-instances-helpers.d.mts.map +1 -1
- package/resources/macos-instances-helpers.d.ts +27 -3
- package/resources/macos-instances-helpers.d.ts.map +1 -1
- package/resources/macos-instances-helpers.js +111 -25
- package/resources/macos-instances-helpers.js.map +1 -1
- package/resources/macos-instances-helpers.mjs +109 -25
- package/resources/macos-instances-helpers.mjs.map +1 -1
- package/resources/macos-instances.d.mts.map +1 -1
- package/resources/macos-instances.d.ts.map +1 -1
- package/resources/macos-instances.js +0 -2
- package/resources/macos-instances.js.map +1 -1
- package/resources/macos-instances.mjs +0 -2
- package/resources/macos-instances.mjs.map +1 -1
- package/resources/scoped-tokens.d.mts.map +1 -1
- package/resources/scoped-tokens.d.ts.map +1 -1
- package/resources/scoped-tokens.js +0 -1
- package/resources/scoped-tokens.js.map +1 -1
- package/resources/scoped-tokens.mjs +0 -1
- package/resources/scoped-tokens.mjs.map +1 -1
- package/resources/xcode-instances-helpers.d.mts +3 -4
- package/resources/xcode-instances-helpers.d.mts.map +1 -1
- package/resources/xcode-instances-helpers.d.ts +3 -4
- package/resources/xcode-instances-helpers.d.ts.map +1 -1
- package/resources/xcode-instances-helpers.js.map +1 -1
- package/resources/xcode-instances-helpers.mjs.map +1 -1
- package/resources/xcode-instances.d.mts.map +1 -1
- package/resources/xcode-instances.d.ts.map +1 -1
- package/resources/xcode-instances.js +0 -1
- package/resources/xcode-instances.js.map +1 -1
- package/resources/xcode-instances.mjs +0 -1
- package/resources/xcode-instances.mjs.map +1 -1
- package/src/client.ts +0 -2
- package/src/core/api-promise.ts +0 -2
- package/src/core/error.ts +0 -2
- package/src/core/pagination.ts +0 -2
- package/src/core/resource.ts +0 -2
- package/src/exec-client.ts +3 -3
- package/src/gradle-snapshot.ts +9 -1
- package/src/index.ts +1 -2
- package/src/internal/builtin-types.ts +0 -2
- package/src/internal/daemon-snapshot.ts +144 -0
- package/src/internal/detect-platform.ts +0 -2
- package/src/internal/errors.ts +0 -2
- package/src/internal/headers.ts +0 -2
- package/src/internal/parse.ts +0 -2
- package/src/internal/request-options.ts +0 -2
- package/src/internal/shim-types.ts +0 -2
- package/src/internal/shims.ts +0 -2
- package/src/internal/types.ts +0 -2
- package/src/internal/utils/base64.ts +0 -2
- package/src/internal/utils/env.ts +0 -2
- package/src/internal/utils/log.ts +0 -2
- package/src/internal/utils/query.ts +0 -2
- package/src/internal/utils/sleep.ts +0 -2
- package/src/internal/utils/uuid.ts +0 -2
- package/src/internal/utils/values.ts +0 -2
- package/src/internal/utils.ts +0 -2
- package/src/resources/analytics.ts +0 -2
- package/src/resources/android-instances.ts +0 -2
- package/src/resources/assets.ts +0 -2
- package/src/resources/daemon-client-shared.ts +2 -4
- package/src/resources/gradle-instances-helpers.ts +27 -41
- package/src/resources/gradle-instances.ts +0 -3
- package/src/resources/index.ts +1 -2
- package/src/resources/ios-instances.ts +0 -2
- package/src/resources/macos-instances-helpers.ts +160 -29
- package/src/resources/macos-instances.ts +0 -3
- package/src/resources/scoped-tokens.ts +0 -2
- package/src/resources/xcode-instances-helpers.ts +3 -4
- package/src/resources/xcode-instances.ts +0 -2
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/src/lib/.keep +0 -4
package/src/internal/shims.ts
CHANGED
package/src/internal/types.ts
CHANGED
package/src/internal/utils.ts
CHANGED
package/src/resources/assets.ts
CHANGED
|
@@ -13,10 +13,8 @@ export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
|
13
13
|
// gradle responses share this exact shape (their OpenAPI schemas are
|
|
14
14
|
// structurally identical), so it is defined once here and aliased per
|
|
15
15
|
// resource; a platform gaining a field of its own is the signal to split the
|
|
16
|
-
// aliases back into real interfaces.
|
|
17
|
-
// api/public/director/openapiv3.yaml
|
|
18
|
-
// those paths up, reconcile with the generated surface instead of
|
|
19
|
-
// duplicating it.
|
|
16
|
+
// aliases back into real interfaces. Written against
|
|
17
|
+
// api/public/director/openapiv3.yaml.
|
|
20
18
|
export interface BuildLog {
|
|
21
19
|
/** Exec ID assigned by the build daemon, e.g. build-1776140344112378000. */
|
|
22
20
|
id: string;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { DeviceDetachUnavailableError } from '../device-detach';
|
|
2
|
-
import {
|
|
2
|
+
import { followDaemonSnapshot } from '../internal/daemon-snapshot';
|
|
3
3
|
import { nodeProxyTransport } from '../internal/proxy-transport';
|
|
4
4
|
import {
|
|
5
5
|
GradleSnapshotRequestUnavailableError,
|
|
6
6
|
GradleSnapshotTimeoutError,
|
|
7
7
|
isGradleRestoreTerminal,
|
|
8
8
|
type GradleInstanceSnapshot,
|
|
9
|
-
type GradleSnapshotRequest,
|
|
10
9
|
type GradleSnapshotRestoreOptions,
|
|
11
10
|
} from '../gradle-snapshot';
|
|
12
|
-
import { sleep } from '../internal/utils/sleep';
|
|
13
11
|
import type { AndroidInstance } from './android-instances';
|
|
14
12
|
import { pullBuildFile } from '../internal/build-pull-file';
|
|
15
13
|
import { normalizeAssetUpload, type BuildUpload } from '../lib/asset-permissions';
|
|
@@ -315,45 +313,33 @@ class GradleInstancesHelpers extends GradleInstances {
|
|
|
315
313
|
},
|
|
316
314
|
|
|
317
315
|
async restoreSnapshot({ onUpdate, timeoutMs = RESTORE_TIMEOUT_MS, key, restoreKeys, encryptionKey }) {
|
|
318
|
-
const snapshotRequest = async (body?: GradleSnapshotRequest): Promise<GradleInstanceSnapshot> => {
|
|
319
|
-
const response = await nodeProxyTransport.fetch(`${apiUrl}/snapshot`, {
|
|
320
|
-
method: body ? 'POST' : 'GET',
|
|
321
|
-
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
|
|
322
|
-
...(body ? { body: JSON.stringify(body) } : {}),
|
|
323
|
-
});
|
|
324
|
-
if (response.status === 404) {
|
|
325
|
-
await response.text().catch(() => undefined);
|
|
326
|
-
throw new GradleSnapshotRequestUnavailableError();
|
|
327
|
-
}
|
|
328
|
-
if (!response.ok) {
|
|
329
|
-
// The body is the daemon's reason, which never repeats the encryption key.
|
|
330
|
-
throw directInstanceHttpError(
|
|
331
|
-
'Disk snapshot request',
|
|
332
|
-
response.status,
|
|
333
|
-
(await response.text()).trim(),
|
|
334
|
-
response.headers,
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
return instanceSnapshot((await response.json()) as InstanceSnapshotReport);
|
|
338
|
-
};
|
|
339
|
-
const deadline = Date.now() + timeoutMs;
|
|
340
|
-
let state = await snapshotRequest({
|
|
341
|
-
...(key !== undefined && { key }),
|
|
342
|
-
...(restoreKeys !== undefined && { restoreKeys }),
|
|
343
|
-
...(encryptionKey !== undefined && { encryptionKey }),
|
|
344
|
-
});
|
|
345
316
|
let reported = '';
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
317
|
+
let state: GradleInstanceSnapshot | undefined;
|
|
318
|
+
await followDaemonSnapshot<InstanceSnapshotReport>({
|
|
319
|
+
apiUrl,
|
|
320
|
+
token,
|
|
321
|
+
request: {
|
|
322
|
+
...(key !== undefined && { key }),
|
|
323
|
+
...(restoreKeys !== undefined && { restoreKeys }),
|
|
324
|
+
...(encryptionKey !== undefined && { encryptionKey }),
|
|
325
|
+
},
|
|
326
|
+
timeoutMs,
|
|
327
|
+
onStatus: (report) => {
|
|
328
|
+
const current = instanceSnapshot(report);
|
|
329
|
+
state = current;
|
|
330
|
+
const seen = `${current.restore.phase}/${current.restore.reason ?? ''}/${
|
|
331
|
+
current.restore.doneBytes ?? ''
|
|
332
|
+
}`;
|
|
333
|
+
if (seen !== reported) {
|
|
334
|
+
reported = seen;
|
|
335
|
+
onUpdate?.(current);
|
|
336
|
+
}
|
|
337
|
+
return isGradleRestoreTerminal(current.restore.phase);
|
|
338
|
+
},
|
|
339
|
+
unavailableError: () => new GradleSnapshotRequestUnavailableError(),
|
|
340
|
+
timeoutError: () => new GradleSnapshotTimeoutError('restore', timeoutMs, state),
|
|
341
|
+
});
|
|
342
|
+
return state!;
|
|
357
343
|
},
|
|
358
344
|
};
|
|
359
345
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Hand-written following the Stainless resource pattern; a future generation
|
|
2
|
-
// from the OpenAPI spec reconciles with this file.
|
|
3
|
-
|
|
4
1
|
import { APIResource } from '../core/resource';
|
|
5
2
|
import { APIPromise } from '../core/api-promise';
|
|
6
3
|
import { Items, type ItemsParams, PagePromise } from '../core/pagination';
|
package/src/resources/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
|
|
3
1
|
export {
|
|
4
2
|
XcodeSnapshots,
|
|
5
3
|
IOSSnapshots,
|
|
@@ -140,6 +138,7 @@ export {
|
|
|
140
138
|
type MacosSyncResult,
|
|
141
139
|
type MacosFileEntry,
|
|
142
140
|
type PullResult,
|
|
141
|
+
MacosSnapshotEncryptionUnsupportedError,
|
|
143
142
|
} from './macos-instances-helpers';
|
|
144
143
|
|
|
145
144
|
export {
|
|
@@ -52,6 +52,8 @@ import {
|
|
|
52
52
|
pushFile as pushLocalFile,
|
|
53
53
|
type PullResult,
|
|
54
54
|
} from '../internal/file-transfer';
|
|
55
|
+
import { LimrunError } from '../core/error';
|
|
56
|
+
import { followDaemonSnapshot } from '../internal/daemon-snapshot';
|
|
55
57
|
import { nodeProxyTransport } from '../internal/proxy-transport';
|
|
56
58
|
import nodePath from 'path';
|
|
57
59
|
import { createHash } from 'crypto';
|
|
@@ -318,9 +320,10 @@ export interface MacosClient {
|
|
|
318
320
|
*
|
|
319
321
|
* Each restore key is tried in order: its exact name first, then the newest asset whose name
|
|
320
322
|
* starts with it, skipping snapshots saved on another macOS build. Without `restoreKeys`,
|
|
321
|
-
* `key` is restored. Without either, nothing is restored
|
|
322
|
-
* and before using the guest; asking again joins the restore
|
|
323
|
-
* final progress event; `onProgress` sees every event, with
|
|
323
|
+
* `key` is restored. Without either, nothing is restored and it resolves with the save's state.
|
|
324
|
+
* Call it once the instance is ready and before using the guest; asking again joins the restore
|
|
325
|
+
* already running. Resolves with the final progress event; `onProgress` sees every event, with
|
|
326
|
+
* byte counts while downloading.
|
|
324
327
|
*/
|
|
325
328
|
restoreSnapshot(options: MacosSnapshotRestoreOptions): Promise<MacosSnapshotProgress>;
|
|
326
329
|
|
|
@@ -460,11 +463,26 @@ export interface MacosSnapshotRestoreOptions {
|
|
|
460
463
|
key?: string;
|
|
461
464
|
/** Asset names, or name prefixes, to restore from, in order. Defaults to `key`. */
|
|
462
465
|
restoreKeys?: string[];
|
|
466
|
+
/**
|
|
467
|
+
* A base64 AES-256 key, 32 random bytes, that encrypts the save and decrypts the restore. Limrun
|
|
468
|
+
* stores no copy, so a lost key makes the snapshot unreadable. Generate one with
|
|
469
|
+
* `openssl rand -base64 32`. An instance from before encrypted snapshots rejects it with
|
|
470
|
+
* `MacosSnapshotEncryptionUnsupportedError` and restores nothing.
|
|
471
|
+
*/
|
|
472
|
+
encryptionKey?: string;
|
|
473
|
+
/** Called once per distinct state, and again as the download progresses. */
|
|
463
474
|
onProgress?: (progress: MacosSnapshotProgress) => void;
|
|
475
|
+
/** How long to wait for the restore to end. Defaults to twenty minutes. */
|
|
476
|
+
timeoutMs?: number;
|
|
464
477
|
}
|
|
465
478
|
|
|
466
479
|
/** A restore's progress, as the instance reports it. */
|
|
467
480
|
export interface MacosSnapshotProgress {
|
|
481
|
+
/**
|
|
482
|
+
* The restore's phase. A request with neither `key` nor `restoreKeys` restores nothing and
|
|
483
|
+
* reports the save the instance runs when it terminates instead: the phase is then the save's,
|
|
484
|
+
* such as `idle`.
|
|
485
|
+
*/
|
|
468
486
|
phase: 'resolving' | 'downloading' | 'extracting' | 'restored' | 'skipped' | 'failed' | string;
|
|
469
487
|
/** The asset name the restore matched. */
|
|
470
488
|
key?: string;
|
|
@@ -547,6 +565,42 @@ class MacosInstancesHelpers extends MacosInstances {
|
|
|
547
565
|
return true;
|
|
548
566
|
},
|
|
549
567
|
});
|
|
568
|
+
// limacvm's restoreSnapshot over signaling, which every limacvm takes. Progress arrives as
|
|
569
|
+
// restoreSnapshotProgress before the result.
|
|
570
|
+
const restoreOverSignaling = async (
|
|
571
|
+
request: Record<string, unknown>,
|
|
572
|
+
onProgress: MacosSnapshotRestoreOptions['onProgress'],
|
|
573
|
+
): Promise<MacosSnapshotProgress> => {
|
|
574
|
+
const id = transport.nextId();
|
|
575
|
+
let last: MacosSnapshotProgress | undefined;
|
|
576
|
+
restoreProgress.set(id, (progress) => {
|
|
577
|
+
last = progress;
|
|
578
|
+
onProgress?.(progress);
|
|
579
|
+
});
|
|
580
|
+
try {
|
|
581
|
+
// A restore downloads the whole disk, so it waits as long as the connection lasts.
|
|
582
|
+
let final: MacosSnapshotProgress | undefined;
|
|
583
|
+
try {
|
|
584
|
+
final = await transport.request<MacosSnapshotProgress | undefined>(
|
|
585
|
+
'restoreSnapshot',
|
|
586
|
+
request,
|
|
587
|
+
(msg) => msg['progress'] as MacosSnapshotProgress | undefined,
|
|
588
|
+
0,
|
|
589
|
+
id,
|
|
590
|
+
);
|
|
591
|
+
} catch (error) {
|
|
592
|
+
// A failed restore is an outcome, as it was reported in its progress, not an error.
|
|
593
|
+
if (last?.phase === 'failed') return last;
|
|
594
|
+
throw error;
|
|
595
|
+
}
|
|
596
|
+
if (final && final !== last) onProgress?.(final);
|
|
597
|
+
const result = final ?? last;
|
|
598
|
+
if (!result) throw new Error('the instance finished the restore without reporting its progress');
|
|
599
|
+
return result;
|
|
600
|
+
} finally {
|
|
601
|
+
restoreProgress.delete(id);
|
|
602
|
+
}
|
|
603
|
+
};
|
|
550
604
|
const send = <T = void>(
|
|
551
605
|
type: string,
|
|
552
606
|
params: Record<string, unknown> = {},
|
|
@@ -882,36 +936,51 @@ class MacosInstancesHelpers extends MacosInstances {
|
|
|
882
936
|
onProgress,
|
|
883
937
|
key,
|
|
884
938
|
restoreKeys,
|
|
939
|
+
encryptionKey,
|
|
940
|
+
timeoutMs = MACOS_RESTORE_TIMEOUT_MS,
|
|
885
941
|
}: MacosSnapshotRestoreOptions): Promise<MacosSnapshotProgress> {
|
|
886
|
-
const
|
|
942
|
+
const request = {
|
|
943
|
+
...(key !== undefined && { key }),
|
|
944
|
+
...(restoreKeys !== undefined && { restoreKeys }),
|
|
945
|
+
...(encryptionKey !== undefined && { encryptionKey }),
|
|
946
|
+
};
|
|
947
|
+
// A request for no restore reports the save, as signaling does.
|
|
948
|
+
const restores = (restoreKeys ?? (key !== undefined ? [key] : [])).length > 0;
|
|
887
949
|
let last: MacosSnapshotProgress | undefined;
|
|
888
|
-
|
|
889
|
-
last = progress;
|
|
890
|
-
onProgress?.(progress);
|
|
891
|
-
});
|
|
950
|
+
let reported = '';
|
|
892
951
|
try {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
952
|
+
await followDaemonSnapshot<MacosSnapshotReport>({
|
|
953
|
+
apiUrl,
|
|
954
|
+
token,
|
|
955
|
+
request,
|
|
956
|
+
timeoutMs,
|
|
957
|
+
onStatus: (report) => {
|
|
958
|
+
last = macosSnapshotProgress(report, restores);
|
|
959
|
+
const seen = `${last.phase}/${last.reason ?? ''}/${last.doneBytes ?? ''}`;
|
|
960
|
+
if (seen !== reported) {
|
|
961
|
+
reported = seen;
|
|
962
|
+
onProgress?.(last);
|
|
963
|
+
}
|
|
964
|
+
return !restores || MACOS_RESTORE_TERMINAL.has(report.restore.phase);
|
|
965
|
+
},
|
|
966
|
+
unavailableError: () => new MacosSnapshotRequestUnavailableError(),
|
|
967
|
+
timeoutError: () =>
|
|
968
|
+
new Error(
|
|
969
|
+
`Timed out after ${Math.round(
|
|
970
|
+
timeoutMs / 1000,
|
|
971
|
+
)}s waiting for the disk snapshot restore to finish` +
|
|
972
|
+
(last ? ` (last phase: ${last.phase})` : ''),
|
|
973
|
+
),
|
|
974
|
+
});
|
|
975
|
+
return last!;
|
|
976
|
+
} catch (error) {
|
|
977
|
+
// An instance from before POST /snapshot takes the request over signaling only.
|
|
978
|
+
if (!(error instanceof MacosSnapshotRequestUnavailableError)) throw error;
|
|
914
979
|
}
|
|
980
|
+
// Every instance that encrypts snapshots takes POST /snapshot. An older one would ignore
|
|
981
|
+
// the key and save the guest unencrypted, so it gets no request at all.
|
|
982
|
+
if (encryptionKey !== undefined) throw new MacosSnapshotEncryptionUnsupportedError();
|
|
983
|
+
return restoreOverSignaling(request, onProgress);
|
|
915
984
|
},
|
|
916
985
|
|
|
917
986
|
async drag(from, to, options) {
|
|
@@ -966,3 +1035,65 @@ function validateRecordingId(recordingId: string): void {
|
|
|
966
1035
|
throw new Error('recordingId must match ^[a-z0-9][a-z0-9_-]{0,63}$');
|
|
967
1036
|
}
|
|
968
1037
|
}
|
|
1038
|
+
|
|
1039
|
+
/** Waits past the instance's own fifteen-minute bound on a restore before giving up on it. */
|
|
1040
|
+
const MACOS_RESTORE_TIMEOUT_MS = 20 * 60 * 1000;
|
|
1041
|
+
|
|
1042
|
+
const MACOS_RESTORE_TERMINAL = new Set(['disabled', 'restored', 'skipped', 'failed']);
|
|
1043
|
+
|
|
1044
|
+
/** POST /snapshot answered 404, so the instance predates it or keeps no snapshots. */
|
|
1045
|
+
class MacosSnapshotRequestUnavailableError extends Error {}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* `restoreSnapshot` was given an `encryptionKey` and the instance predates encrypted snapshots.
|
|
1049
|
+
* Nothing was restored, and the instance saves nothing. A new instance takes the key.
|
|
1050
|
+
*/
|
|
1051
|
+
export class MacosSnapshotEncryptionUnsupportedError extends LimrunError {
|
|
1052
|
+
constructor() {
|
|
1053
|
+
super(
|
|
1054
|
+
'This instance predates encrypted disk snapshots, so it cannot take an encryption key; create a new instance.',
|
|
1055
|
+
);
|
|
1056
|
+
this.name = 'MacosSnapshotEncryptionUnsupportedError';
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/** The status limacvm answers POST and GET /snapshot with. */
|
|
1061
|
+
type MacosSnapshotReport = {
|
|
1062
|
+
restore: {
|
|
1063
|
+
phase: string;
|
|
1064
|
+
key?: string;
|
|
1065
|
+
matchKind?: string;
|
|
1066
|
+
source?: string;
|
|
1067
|
+
bytes?: number;
|
|
1068
|
+
doneBytes?: number;
|
|
1069
|
+
reason?: string;
|
|
1070
|
+
message?: string;
|
|
1071
|
+
};
|
|
1072
|
+
save: { phase: string; key?: string; reason?: string; message?: string };
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
/** The report in the shape signaling's progress events have, which `restoreSnapshot` returns. */
|
|
1076
|
+
function macosSnapshotProgress(
|
|
1077
|
+
{ restore, save }: MacosSnapshotReport,
|
|
1078
|
+
restores: boolean,
|
|
1079
|
+
): MacosSnapshotProgress {
|
|
1080
|
+
if (!restores) {
|
|
1081
|
+
return {
|
|
1082
|
+
phase: save.phase,
|
|
1083
|
+
...(save.key && { key: save.key }),
|
|
1084
|
+
...(save.reason && { reason: save.reason }),
|
|
1085
|
+
...(save.message && { message: save.message }),
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
return {
|
|
1089
|
+
phase: restore.phase,
|
|
1090
|
+
...(restore.key && { key: restore.key }),
|
|
1091
|
+
...(restore.matchKind && { matchKind: restore.matchKind }),
|
|
1092
|
+
...(restore.source && { source: restore.source }),
|
|
1093
|
+
...(restore.bytes && { totalBytes: restore.bytes, doneBytes: restore.doneBytes ?? 0 }),
|
|
1094
|
+
// A download that has not learned its total yet still reports its progress.
|
|
1095
|
+
...(!restore.bytes && restore.doneBytes && { doneBytes: restore.doneBytes }),
|
|
1096
|
+
...(restore.reason && { reason: restore.reason }),
|
|
1097
|
+
...(restore.message && { message: restore.message }),
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Hand-written following the Stainless resource pattern; a future generation
|
|
2
|
-
// from the OpenAPI spec reconciles with this file.
|
|
3
|
-
|
|
4
1
|
import { APIResource } from '../core/resource';
|
|
5
2
|
import { APIPromise } from '../core/api-promise';
|
|
6
3
|
import { Items, type ItemsParams, PagePromise } from '../core/pagination';
|
|
@@ -181,10 +181,9 @@ export type XcodeProjectConfig = {
|
|
|
181
181
|
*/
|
|
182
182
|
runTests?: boolean;
|
|
183
183
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* test run.
|
|
184
|
+
* Keep the test run's result bundle, reported as
|
|
185
|
+
* ExecResult.xctest.resultBundle; fetch it with XcodeClient.pullResultBundle.
|
|
186
|
+
* Needs a testing action and a test run.
|
|
188
187
|
*/
|
|
189
188
|
resultBundle?: boolean;
|
|
190
189
|
/**
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.83.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.83.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.83.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.83.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|
package/src/lib/.keep
DELETED