@limrun/api 0.74.0 → 0.76.0-rc.1
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 +7 -0
- package/client.d.mts +4 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +4 -0
- package/client.d.ts.map +1 -1
- package/client.js +4 -0
- package/client.js.map +1 -1
- package/client.mjs +4 -0
- package/client.mjs.map +1 -1
- package/gradle-snapshot.d.mts +105 -0
- package/gradle-snapshot.d.mts.map +1 -0
- package/gradle-snapshot.d.ts +105 -0
- package/gradle-snapshot.d.ts.map +1 -0
- package/gradle-snapshot.js +73 -0
- package/gradle-snapshot.js.map +1 -0
- package/gradle-snapshot.mjs +64 -0
- package/gradle-snapshot.mjs.map +1 -0
- package/index.d.mts +2 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +10 -2
- package/index.js.map +1 -1
- package/index.mjs +2 -1
- package/index.mjs.map +1 -1
- package/internal/instance-phase-stream.d.mts +34 -0
- package/internal/instance-phase-stream.d.mts.map +1 -0
- package/internal/instance-phase-stream.d.ts +34 -0
- package/internal/instance-phase-stream.d.ts.map +1 -0
- package/internal/instance-phase-stream.js +109 -0
- package/internal/instance-phase-stream.js.map +1 -0
- package/internal/instance-phase-stream.mjs +106 -0
- package/internal/instance-phase-stream.mjs.map +1 -0
- package/package.json +11 -1
- package/resources/analytics.d.mts +22 -2
- package/resources/analytics.d.mts.map +1 -1
- package/resources/analytics.d.ts +22 -2
- package/resources/analytics.d.ts.map +1 -1
- package/resources/analytics.js.map +1 -1
- package/resources/analytics.mjs.map +1 -1
- package/resources/gradle-instances.d.mts +27 -0
- package/resources/gradle-instances.d.mts.map +1 -1
- package/resources/gradle-instances.d.ts +27 -0
- package/resources/gradle-instances.d.ts.map +1 -1
- package/resources/gradle-instances.js +19 -0
- package/resources/gradle-instances.js.map +1 -1
- package/resources/gradle-instances.mjs +19 -0
- package/resources/gradle-instances.mjs.map +1 -1
- package/resources/index.d.mts +2 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +4 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -1
- package/resources/index.mjs.map +1 -1
- package/resources/macos-instances.d.mts +224 -0
- package/resources/macos-instances.d.mts.map +1 -0
- package/resources/macos-instances.d.ts +224 -0
- package/resources/macos-instances.d.ts.map +1 -0
- package/resources/macos-instances.js +51 -0
- package/resources/macos-instances.js.map +1 -0
- package/resources/macos-instances.mjs +47 -0
- package/resources/macos-instances.mjs.map +1 -0
- package/resources/snapshots.d.mts +19 -1
- package/resources/snapshots.d.mts.map +1 -1
- package/resources/snapshots.d.ts +19 -1
- package/resources/snapshots.d.ts.map +1 -1
- package/resources/snapshots.js +21 -1
- package/resources/snapshots.js.map +1 -1
- package/resources/snapshots.mjs +19 -0
- package/resources/snapshots.mjs.map +1 -1
- package/src/client.ts +20 -0
- package/src/gradle-snapshot.ts +194 -0
- package/src/index.ts +21 -0
- package/src/internal/instance-phase-stream.ts +138 -0
- package/src/resources/analytics.ts +22 -2
- package/src/resources/gradle-instances.ts +43 -0
- package/src/resources/index.ts +10 -0
- package/src/resources/macos-instances.ts +296 -0
- package/src/resources/snapshots.ts +39 -1
- package/src/version.ts +1 -1
- package/src/xcode-cache.ts +18 -111
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/xcode-cache.d.mts.map +1 -1
- package/xcode-cache.d.ts.map +1 -1
- package/xcode-cache.js +17 -99
- package/xcode-cache.js.map +1 -1
- package/xcode-cache.mjs +17 -99
- package/xcode-cache.mjs.map +1 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// Hand-written following the Stainless resource pattern; a future generation
|
|
2
|
+
// from the OpenAPI spec reconciles with this file.
|
|
3
|
+
|
|
4
|
+
import { APIResource } from '../core/resource';
|
|
5
|
+
import { APIPromise } from '../core/api-promise';
|
|
6
|
+
import { Items, type ItemsParams, PagePromise } from '../core/pagination';
|
|
7
|
+
import { buildHeaders } from '../internal/headers';
|
|
8
|
+
import { RequestOptions } from '../internal/request-options';
|
|
9
|
+
import { path } from '../internal/utils/path';
|
|
10
|
+
|
|
11
|
+
/** A macOS virtual machine, streamed to the browser like a simulator. */
|
|
12
|
+
export class MacosInstances extends APIResource {
|
|
13
|
+
/**
|
|
14
|
+
* Create a macOS instance
|
|
15
|
+
*/
|
|
16
|
+
create(params: MacosInstanceCreateParams, options?: RequestOptions): APIPromise<MacosInstance> {
|
|
17
|
+
const { reuseIfExists, wait, ...body } = params;
|
|
18
|
+
return this._client.post('/v1/macos_instances', { query: { reuseIfExists, wait }, body, ...options });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* List macOS instances
|
|
23
|
+
*/
|
|
24
|
+
list(
|
|
25
|
+
query: MacosInstanceListParams | null | undefined = {},
|
|
26
|
+
options?: RequestOptions,
|
|
27
|
+
): PagePromise<MacosInstancesItems, MacosInstance> {
|
|
28
|
+
return this._client.getAPIList('/v1/macos_instances', Items<MacosInstance>, { query, ...options });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Delete macOS instance with given ID
|
|
33
|
+
*/
|
|
34
|
+
delete(id: string, options?: RequestOptions): APIPromise<void> {
|
|
35
|
+
return this._client.delete(path`/v1/macos_instances/${id}`, {
|
|
36
|
+
...options,
|
|
37
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Update a live instance's labels or role using the ETag returned by get().withResponse(). */
|
|
42
|
+
update(id: string, params: MacosInstanceUpdateParams, options?: RequestOptions): APIPromise<void> {
|
|
43
|
+
const { ifMatch, ...body } = params;
|
|
44
|
+
return this._client.patch(path`/v1/macos_instances/${id}`, {
|
|
45
|
+
...options,
|
|
46
|
+
body,
|
|
47
|
+
headers: buildHeaders([options?.headers, { 'If-Match': ifMatch, Accept: '*/*' }]),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get macOS instance with given ID
|
|
53
|
+
*/
|
|
54
|
+
get(id: string, options?: RequestOptions): APIPromise<MacosInstance> {
|
|
55
|
+
return this._client.get(path`/v1/macos_instances/${id}`, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type MacosInstancesItems = Items<MacosInstance>;
|
|
60
|
+
|
|
61
|
+
export interface MacosInstance {
|
|
62
|
+
metadata: MacosInstance.Metadata;
|
|
63
|
+
|
|
64
|
+
spec: MacosInstance.Spec;
|
|
65
|
+
|
|
66
|
+
status: MacosInstance.Status;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export namespace MacosInstance {
|
|
70
|
+
export interface Metadata {
|
|
71
|
+
id: string;
|
|
72
|
+
|
|
73
|
+
createdAt: string;
|
|
74
|
+
|
|
75
|
+
organizationId: string;
|
|
76
|
+
|
|
77
|
+
displayName?: string;
|
|
78
|
+
|
|
79
|
+
labels?: { [key: string]: string };
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Immutable name that works like a folder path. Absent for an instance created
|
|
83
|
+
* before names existed.
|
|
84
|
+
*/
|
|
85
|
+
name?: string;
|
|
86
|
+
|
|
87
|
+
/** Time of the controller's termination event. Physical cleanup may follow. */
|
|
88
|
+
terminatedAt?: string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Billing cutoff for a deletion requested while the region is unavailable.
|
|
92
|
+
* Absent for normal regional deletions.
|
|
93
|
+
*/
|
|
94
|
+
terminatingAt?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface Spec {
|
|
98
|
+
inactivityTimeout: string;
|
|
99
|
+
|
|
100
|
+
region: string;
|
|
101
|
+
|
|
102
|
+
/** Maximum runtime regardless of activity. */
|
|
103
|
+
hardTimeout?: string;
|
|
104
|
+
|
|
105
|
+
/** Current effective permissions. Present on live GETs; historical records may omit it. */
|
|
106
|
+
role?: { permissions: string[] };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface Status {
|
|
110
|
+
state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminating' | 'terminated';
|
|
111
|
+
|
|
112
|
+
apiUrl?: string;
|
|
113
|
+
|
|
114
|
+
/** The screen-streaming WebSocket. Pass it to RemoteControl from @limrun/ui. */
|
|
115
|
+
endpointWebSocketUrl?: string;
|
|
116
|
+
|
|
117
|
+
errorMessage?: string;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A control token for this instance. Grants runtime access and reads, but cannot
|
|
121
|
+
* create, update, or delete instance records.
|
|
122
|
+
*/
|
|
123
|
+
token?: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A signed token that grants only streaming on this instance: it opens the
|
|
127
|
+
* screen-streaming WebSocket and nothing else, so a browser can hold it while
|
|
128
|
+
* `token` stays on your backend. Create, get and list return it to callers with
|
|
129
|
+
* full control of the instance; get and list only while the instance runs.
|
|
130
|
+
*/
|
|
131
|
+
streamToken?: string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Machine-readable reason for instance termination. Present when state is
|
|
135
|
+
* "terminating" or "terminated". New values may be added over time, so treat any
|
|
136
|
+
* unrecognized value as "Unknown". Known values:
|
|
137
|
+
*
|
|
138
|
+
* - "UserRequested": terminated by a delete request to the API.
|
|
139
|
+
* - "InactivityTimeout": the timeout given in spec.inactivityTimeout elapsed.
|
|
140
|
+
* - "HardTimeout": the timeout given in spec.hardTimeout elapsed.
|
|
141
|
+
* - "CapacityTimeout": no instance was free when it was created, and none freed
|
|
142
|
+
* up before its wait for capacity ended.
|
|
143
|
+
* - "Unknown": terminated for a cause the platform did not attribute, including
|
|
144
|
+
* instances that failed to get ready during creation. See errorMessage for
|
|
145
|
+
* details when available.
|
|
146
|
+
*/
|
|
147
|
+
terminationReason?: string;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface MacosInstanceUpdateParams {
|
|
152
|
+
/** Quoted ETag from a live GET. A concurrent change returns HTTP 412. */
|
|
153
|
+
ifMatch: string;
|
|
154
|
+
/** Replaces all customer labels. Use {} to clear them. Omission preserves labels. */
|
|
155
|
+
metadata?: { labels: { [key: string]: string } };
|
|
156
|
+
spec?: {
|
|
157
|
+
role?: {
|
|
158
|
+
/** Replaces the complete list. Use [] to remove delegated permissions. */
|
|
159
|
+
permissions: string[];
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface MacosInstanceCreateParams {
|
|
165
|
+
/**
|
|
166
|
+
* Query param: If there is another instance with given labels and region, return
|
|
167
|
+
* that one instead of creating a new instance. Reusing it requires control
|
|
168
|
+
* permission on that instance.
|
|
169
|
+
*/
|
|
170
|
+
reuseIfExists?: boolean;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Query param: Return after the instance is ready to connect.
|
|
174
|
+
*/
|
|
175
|
+
wait?: boolean;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Body param
|
|
179
|
+
*/
|
|
180
|
+
metadata?: MacosInstanceCreateParams.Metadata;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Body param
|
|
184
|
+
*/
|
|
185
|
+
spec?: MacosInstanceCreateParams.Spec;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export namespace MacosInstanceCreateParams {
|
|
189
|
+
export interface Metadata {
|
|
190
|
+
displayName?: string;
|
|
191
|
+
|
|
192
|
+
labels?: { [key: string]: string };
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Immutable name that works like a folder path, for example u/u123/preview. A
|
|
196
|
+
* permission can target the name or a folder it lies in. Without one, the
|
|
197
|
+
* instance is named after its ID inside the caller's default folder.
|
|
198
|
+
*/
|
|
199
|
+
name?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface Spec {
|
|
203
|
+
/**
|
|
204
|
+
* ClientLocation takes precedence over ClientIP regardless of clue order. Without
|
|
205
|
+
* either clue, routing uses Cloudflare visitor coordinates, then its client IP.
|
|
206
|
+
*/
|
|
207
|
+
clues?: Array<Spec.Clue>;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Maximum runtime regardless of activity. Omit to use the organization's macOS
|
|
211
|
+
* default. Set to "0" to disable the hard timeout.
|
|
212
|
+
*/
|
|
213
|
+
hardTimeout?: string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* After how long without input or API calls the instance is terminated, counted
|
|
217
|
+
* from when it becomes ready. Example values 1m, 10m, 3h. Omitting it, or passing
|
|
218
|
+
* a non-positive duration, uses the organization's macOS default.
|
|
219
|
+
*/
|
|
220
|
+
inactivityTimeout?: string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Restricts scheduling to regions in the given jurisdiction. Unlike region, this
|
|
224
|
+
* is a hard constraint: the request never overflows to a region outside the
|
|
225
|
+
* jurisdiction and fails when no region in the jurisdiction has capacity.
|
|
226
|
+
*/
|
|
227
|
+
jurisdiction?: 'us' | 'eu' | 'as';
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated A region is only a preference, not a hard pin; use jurisdiction to
|
|
231
|
+
* constrain where the instance runs.
|
|
232
|
+
*/
|
|
233
|
+
region?: string;
|
|
234
|
+
|
|
235
|
+
/** Inline instance role. Omit for the organization's compatibility default. */
|
|
236
|
+
role?: {
|
|
237
|
+
/** Asset permissions delegated by the creator. An empty array grants nothing. */
|
|
238
|
+
permissions: Array<string>;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export namespace Spec {
|
|
243
|
+
export interface Clue {
|
|
244
|
+
kind: 'ClientIP' | 'ClientLocation';
|
|
245
|
+
|
|
246
|
+
clientIp?: string;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Required for ClientLocation. Both coordinates must be finite and within their
|
|
250
|
+
* ranges. This location takes precedence over ClientIP.
|
|
251
|
+
*/
|
|
252
|
+
clientLocation?: Clue.ClientLocation;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export namespace Clue {
|
|
256
|
+
export interface ClientLocation {
|
|
257
|
+
/**
|
|
258
|
+
* Latitude in decimal degrees, from -90 to 90 inclusive. Zero is valid.
|
|
259
|
+
*/
|
|
260
|
+
latitude: number;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Longitude in decimal degrees, from -180 to 180 inclusive. Zero is valid.
|
|
264
|
+
*/
|
|
265
|
+
longitude: number;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface MacosInstanceListParams extends ItemsParams {
|
|
272
|
+
/**
|
|
273
|
+
* Labels filter to apply to instances to return. Expects a comma-separated list of
|
|
274
|
+
* key=value pairs (e.g., env=prod,region=us-west).
|
|
275
|
+
*/
|
|
276
|
+
labelSelector?: string;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* State filter to apply to macOS instances to return. Each comma-separated state
|
|
280
|
+
* will be used as part of an OR clause, e.g. "assigned,ready" will return all
|
|
281
|
+
* instances that are either assigned or ready.
|
|
282
|
+
*
|
|
283
|
+
* Valid states: creating, assigned, ready, terminating, terminated, unknown
|
|
284
|
+
*/
|
|
285
|
+
state?: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export declare namespace MacosInstances {
|
|
289
|
+
export {
|
|
290
|
+
type MacosInstance as MacosInstance,
|
|
291
|
+
type MacosInstancesItems as MacosInstancesItems,
|
|
292
|
+
type MacosInstanceUpdateParams as MacosInstanceUpdateParams,
|
|
293
|
+
type MacosInstanceCreateParams as MacosInstanceCreateParams,
|
|
294
|
+
type MacosInstanceListParams as MacosInstanceListParams,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
@@ -7,7 +7,7 @@ import { path } from '../internal/utils/path';
|
|
|
7
7
|
export interface SnapshotListParams {
|
|
8
8
|
/** Literal key prefix. Omit to list all keys. */
|
|
9
9
|
prefix?: string;
|
|
10
|
-
/** Page size: 1–500 for Xcode, 1–100 for iOS. */
|
|
10
|
+
/** Page size: 1–500 for Xcode and Gradle, 1–100 for iOS. */
|
|
11
11
|
limit?: number;
|
|
12
12
|
offset?: number;
|
|
13
13
|
}
|
|
@@ -31,6 +31,18 @@ export interface XcodeSnapshot {
|
|
|
31
31
|
sourceInstanceId?: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
export interface GradleSnapshot {
|
|
35
|
+
key: string;
|
|
36
|
+
/** Toolchains label of the image that saved it. An instance with another label tries its next restore key. */
|
|
37
|
+
compatKey: string;
|
|
38
|
+
archiveFormat: string;
|
|
39
|
+
archiveSizeBytes: number;
|
|
40
|
+
uncompressedSizeBytes: number;
|
|
41
|
+
sha256: string;
|
|
42
|
+
publishedAt: string;
|
|
43
|
+
sourceInstanceId: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
export interface IOSSnapshot {
|
|
35
47
|
key: string;
|
|
36
48
|
saved: boolean;
|
|
@@ -86,3 +98,29 @@ export class IOSSnapshots extends APIResource {
|
|
|
86
98
|
});
|
|
87
99
|
}
|
|
88
100
|
}
|
|
101
|
+
|
|
102
|
+
export class GradleSnapshots extends APIResource {
|
|
103
|
+
/** List saved Gradle snapshots, newest publication first. */
|
|
104
|
+
list(
|
|
105
|
+
organizationId: string,
|
|
106
|
+
query: SnapshotListParams = {},
|
|
107
|
+
options?: RequestOptions,
|
|
108
|
+
): APIPromise<SnapshotList<GradleSnapshot>> {
|
|
109
|
+
return this._client.get(path`/v1/organizations/${organizationId}/gradle_snapshots`, {
|
|
110
|
+
query,
|
|
111
|
+
...options,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get(organizationId: string, key: string, options?: RequestOptions): APIPromise<GradleSnapshot> {
|
|
116
|
+
return this._client.get(path`/v1/organizations/${organizationId}/gradle_snapshots/${key}`, options);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Delete the archive and its record. Running instances can save this key again. */
|
|
120
|
+
delete(organizationId: string, key: string, options?: RequestOptions): APIPromise<void> {
|
|
121
|
+
return this._client.delete(path`/v1/organizations/${organizationId}/gradle_snapshots/${key}`, {
|
|
122
|
+
...options,
|
|
123
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.76.0-rc.1'; // x-release-please-version
|
package/src/xcode-cache.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { nodeProxyTransport } from './internal/proxy-transport';
|
|
1
|
+
import { followPhaseStream } from './internal/instance-phase-stream';
|
|
4
2
|
|
|
5
3
|
/** @deprecated Use XcodeSnapshotConfig instead. */
|
|
6
4
|
export type XcodeCacheConfig = import('./xcode-snapshot').XcodeSnapshotConfig;
|
|
@@ -185,7 +183,7 @@ export type XcodeCacheFollowTarget = {
|
|
|
185
183
|
* The transport is the same endpoint that serves a JSON snapshot, asked for as an event
|
|
186
184
|
* stream. The server emits on phase change only, so every callback is a real transition.
|
|
187
185
|
*/
|
|
188
|
-
export function followXcodeCache(
|
|
186
|
+
export async function followXcodeCache(
|
|
189
187
|
target: XcodeCacheFollowTarget,
|
|
190
188
|
options: XcodeCacheFollowOptions = {},
|
|
191
189
|
): Promise<XcodeCacheFollowResult> {
|
|
@@ -193,112 +191,21 @@ export function followXcodeCache(
|
|
|
193
191
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS[side];
|
|
194
192
|
let base = target.baseURL;
|
|
195
193
|
while (base.endsWith('/')) base = base.slice(0, -1);
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// A stream that never opened has nothing to close.
|
|
212
|
-
}
|
|
213
|
-
fn();
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const timer = setTimeout(
|
|
217
|
-
() => finish(() => reject(new XcodeCacheTimeoutError(side, timeoutMs, last))),
|
|
218
|
-
timeoutMs,
|
|
219
|
-
);
|
|
220
|
-
const onAbort = () => finish(() => reject(options.signal?.reason ?? new Error('aborted')));
|
|
221
|
-
|
|
222
|
-
let confirming = false;
|
|
223
|
-
const confirmGone = () => {
|
|
224
|
-
if (confirming || settled) return;
|
|
225
|
-
confirming = true;
|
|
226
|
-
nodeProxyTransport
|
|
227
|
-
.fetch(url, {
|
|
228
|
-
headers: { Authorization: `Bearer ${target.apiKey}`, Accept: 'application/json' },
|
|
229
|
-
})
|
|
230
|
-
.then(async (res) => {
|
|
231
|
-
confirming = false;
|
|
232
|
-
if (res.status !== 404) {
|
|
233
|
-
await res.text().catch(() => undefined);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
finish(() =>
|
|
237
|
-
last ? resolve({ cache: last, gone: true }) : reject(new XcodeCacheGoneError(target.instanceId)),
|
|
238
|
-
);
|
|
239
|
-
})
|
|
240
|
-
.catch(() => {
|
|
241
|
-
confirming = false;
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
// The endpoint answers from the region, which keeps the instance while it terminates and
|
|
246
|
-
// drops it once it is collected, so a 404 is the instance being over rather than a fault.
|
|
247
|
-
// Without this the client treats it as a connection to retry and follows a gone instance
|
|
248
|
-
// until the timeout, which is minutes of a command that looks hung and says nothing.
|
|
249
|
-
const fetchOrGone: typeof nodeProxyTransport.fetch = async (input, init) => {
|
|
250
|
-
const res = await nodeProxyTransport.fetch(input, init);
|
|
251
|
-
if (res.status === 404) {
|
|
252
|
-
finish(() =>
|
|
253
|
-
last ? resolve({ cache: last, gone: true }) : reject(new XcodeCacheGoneError(target.instanceId)),
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
return res;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const source = createEventSource({
|
|
260
|
-
url,
|
|
261
|
-
fetch: fetchOrGone,
|
|
262
|
-
onConnect: () => options.onOpen?.(),
|
|
263
|
-
headers: {
|
|
264
|
-
Authorization: `Bearer ${target.apiKey}`,
|
|
265
|
-
Accept: 'text/event-stream',
|
|
266
|
-
},
|
|
267
|
-
onMessage: (message: EventSourceMessage) => {
|
|
268
|
-
if (message.event !== 'cache' && message.event !== 'gone') return;
|
|
269
|
-
let cache: XcodeInstanceCache;
|
|
270
|
-
try {
|
|
271
|
-
cache = JSON.parse(typeof message.data === 'string' ? message.data : String(message.data));
|
|
272
|
-
} catch (err) {
|
|
273
|
-
finish(() => reject(new Error(`Cache stream sent unreadable data: ${err}`)));
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
last = cache;
|
|
277
|
-
if (message.event === 'gone') {
|
|
278
|
-
// The server also ends the stream this way when its own watch is cut short, which
|
|
279
|
-
// Kubernetes does routinely on a long one, so a snapshot decides which it was. The
|
|
280
|
-
// client library reconnects on its own when the instance is in fact still there.
|
|
281
|
-
confirmGone();
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
// A reconnect replays the current state, which is not a transition.
|
|
285
|
-
const key = `${cache.restore.phase}/${cache.restore.reason ?? ''}|${cache.save.phase}/${
|
|
286
|
-
cache.save.reason ?? ''
|
|
287
|
-
}`;
|
|
288
|
-
if (key !== lastKey) {
|
|
289
|
-
lastKey = key;
|
|
290
|
-
options.onUpdate?.(cache);
|
|
291
|
-
}
|
|
292
|
-
if (isCacheTerminal(cache, side)) {
|
|
293
|
-
finish(() => resolve({ cache, gone: false }));
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
if (options.signal?.aborted) {
|
|
299
|
-
onAbort();
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
194
|
+
const result = await followPhaseStream<XcodeInstanceCache>({
|
|
195
|
+
url: `${base}/v1/xcode_instances/${encodeURIComponent(target.instanceId)}/cache`,
|
|
196
|
+
apiKey: target.apiKey,
|
|
197
|
+
instanceId: target.instanceId,
|
|
198
|
+
eventName: 'cache',
|
|
199
|
+
timeoutMs,
|
|
200
|
+
signal: options.signal,
|
|
201
|
+
onOpen: options.onOpen,
|
|
202
|
+
onUpdate: options.onUpdate,
|
|
203
|
+
transitionKey: (cache) =>
|
|
204
|
+
`${cache.restore.phase}/${cache.restore.reason ?? ''}|${cache.save.phase}/${cache.save.reason ?? ''}`,
|
|
205
|
+
isTerminal: (cache) => isCacheTerminal(cache, side),
|
|
206
|
+
goneError: () => new XcodeCacheGoneError(target.instanceId),
|
|
207
|
+
timeoutError: (last) => new XcodeCacheTimeoutError(side, timeoutMs, last),
|
|
208
|
+
unreadableError: (err) => new Error(`Cache stream sent unreadable data: ${err}`),
|
|
303
209
|
});
|
|
210
|
+
return { cache: result.state, gone: result.gone };
|
|
304
211
|
}
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.76.0-rc.1";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,gBAAgB,CAAC"}
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.76.0-rc.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,gBAAgB,CAAC"}
|
package/version.js
CHANGED
package/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,aAAa,CAAC,CAAC,2BAA2B"}
|
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.76.0-rc.1'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|
package/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC,CAAC,2BAA2B"}
|
package/xcode-cache.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xcode-cache.d.mts","sourceRoot":"","sources":["src/xcode-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xcode-cache.d.mts","sourceRoot":"","sources":["src/xcode-cache.ts"],"names":[],"mappings":"AAEA,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,+BAA2B,mBAAmB,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAC9B,UAAU,GACV,aAAa,GACb,SAAS,GACT,aAAa,GACb,eAAe,GACf,UAAU,GACV,SAAS,GACT,QAAQ,CAAC;AAEb,+BAA+B;AAC/B,MAAM,MAAM,mBAAmB,GAC3B,UAAU,GACV,MAAM,GACN,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,GACR,WAAW,CAAC;AAEhB,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;IACvC,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,C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7C,QAAQ,CAAC,IAAI,EAAE,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS;gBAFrC,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,kBAAkB,GAAG,SAAS;CAQjD;AAOD,kDAAkD;AAClD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAQxE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAEvE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAQlE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAExF;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,sBAAsB,EAC9B,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAsBjC"}
|
package/xcode-cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xcode-cache.d.ts","sourceRoot":"","sources":["src/xcode-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xcode-cache.d.ts","sourceRoot":"","sources":["src/xcode-cache.ts"],"names":[],"mappings":"AAEA,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,8BAA2B,mBAAmB,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAC9B,UAAU,GACV,aAAa,GACb,SAAS,GACT,aAAa,GACb,eAAe,GACf,UAAU,GACV,SAAS,GACT,QAAQ,CAAC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