@limrun/api 0.70.1 → 0.71.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 +34 -0
- package/client.d.mts +1 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -0
- package/client.d.ts.map +1 -1
- package/client.js +1 -0
- package/client.js.map +1 -1
- package/client.mjs +1 -0
- package/client.mjs.map +1 -1
- package/exec-client.d.mts +9 -0
- package/exec-client.d.mts.map +1 -1
- package/exec-client.d.ts +9 -0
- package/exec-client.d.ts.map +1 -1
- package/exec-client.js.map +1 -1
- package/exec-client.mjs.map +1 -1
- 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 +1 -0
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/instance-client.d.mts +2 -0
- package/instance-client.d.mts.map +1 -1
- package/instance-client.d.ts +2 -0
- package/instance-client.d.ts.map +1 -1
- package/instance-client.js +6 -2
- package/instance-client.js.map +1 -1
- package/instance-client.mjs +6 -2
- package/instance-client.mjs.map +1 -1
- package/internal/persist-option.d.mts +4 -0
- package/internal/persist-option.d.mts.map +1 -1
- package/internal/persist-option.d.ts +4 -0
- package/internal/persist-option.d.ts.map +1 -1
- package/internal/persist-option.js +10 -3
- package/internal/persist-option.js.map +1 -1
- package/internal/persist-option.mjs +9 -3
- package/internal/persist-option.mjs.map +1 -1
- package/internal/session-stream.d.mts +6 -5
- package/internal/session-stream.d.mts.map +1 -1
- package/internal/session-stream.d.ts +6 -5
- package/internal/session-stream.d.ts.map +1 -1
- package/internal/session-stream.js +6 -5
- package/internal/session-stream.js.map +1 -1
- package/internal/session-stream.mjs +6 -5
- package/internal/session-stream.mjs.map +1 -1
- package/ios-client.d.mts +28 -1
- package/ios-client.d.mts.map +1 -1
- package/ios-client.d.ts +28 -1
- package/ios-client.d.ts.map +1 -1
- package/ios-client.js +27 -14
- package/ios-client.js.map +1 -1
- package/ios-client.mjs +28 -15
- package/ios-client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/android-instances.d.mts +18 -5
- package/resources/android-instances.d.mts.map +1 -1
- package/resources/android-instances.d.ts +18 -5
- package/resources/android-instances.d.ts.map +1 -1
- package/resources/daemon-client-shared.d.mts +3 -0
- package/resources/daemon-client-shared.d.mts.map +1 -1
- package/resources/daemon-client-shared.d.ts +3 -0
- package/resources/daemon-client-shared.d.ts.map +1 -1
- package/resources/daemon-client-shared.js +2 -0
- package/resources/daemon-client-shared.js.map +1 -1
- package/resources/daemon-client-shared.mjs +2 -0
- package/resources/daemon-client-shared.mjs.map +1 -1
- package/resources/gradle-instances-helpers.d.mts +3 -0
- package/resources/gradle-instances-helpers.d.mts.map +1 -1
- package/resources/gradle-instances-helpers.d.ts +3 -0
- package/resources/gradle-instances-helpers.d.ts.map +1 -1
- package/resources/gradle-instances-helpers.js +2 -0
- package/resources/gradle-instances-helpers.js.map +1 -1
- package/resources/gradle-instances-helpers.mjs +2 -0
- package/resources/gradle-instances-helpers.mjs.map +1 -1
- package/resources/gradle-instances.d.mts +21 -5
- package/resources/gradle-instances.d.mts.map +1 -1
- package/resources/gradle-instances.d.ts +21 -5
- package/resources/gradle-instances.d.ts.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 +2 -0
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/ios-instances-helpers.d.mts +4 -0
- package/resources/ios-instances-helpers.d.mts.map +1 -1
- package/resources/ios-instances-helpers.d.ts +4 -0
- package/resources/ios-instances-helpers.d.ts.map +1 -1
- package/resources/ios-instances-helpers.js +6 -0
- package/resources/ios-instances-helpers.js.map +1 -1
- package/resources/ios-instances-helpers.mjs +6 -0
- package/resources/ios-instances-helpers.mjs.map +1 -1
- package/resources/ios-instances.d.mts +18 -5
- package/resources/ios-instances.d.mts.map +1 -1
- package/resources/ios-instances.d.ts +18 -5
- package/resources/ios-instances.d.ts.map +1 -1
- package/resources/secrets.d.mts +66 -0
- package/resources/secrets.d.mts.map +1 -0
- package/resources/secrets.d.ts +66 -0
- package/resources/secrets.d.ts.map +1 -0
- package/resources/secrets.js +141 -0
- package/resources/secrets.js.map +1 -0
- package/resources/secrets.mjs +137 -0
- package/resources/secrets.mjs.map +1 -0
- package/resources/session-artifacts.d.mts +46 -5
- package/resources/session-artifacts.d.mts.map +1 -1
- package/resources/session-artifacts.d.ts +46 -5
- package/resources/session-artifacts.d.ts.map +1 -1
- package/resources/session-artifacts.js +3 -3
- package/resources/session-artifacts.js.map +1 -1
- package/resources/session-artifacts.mjs +3 -3
- package/resources/session-artifacts.mjs.map +1 -1
- package/resources/xcode-instances-helpers.d.mts +3 -0
- package/resources/xcode-instances-helpers.d.mts.map +1 -1
- package/resources/xcode-instances-helpers.d.ts +3 -0
- package/resources/xcode-instances-helpers.d.ts.map +1 -1
- package/resources/xcode-instances-helpers.js +2 -0
- package/resources/xcode-instances-helpers.js.map +1 -1
- package/resources/xcode-instances-helpers.mjs +2 -0
- package/resources/xcode-instances-helpers.mjs.map +1 -1
- package/resources/xcode-instances.d.mts +21 -5
- package/resources/xcode-instances.d.mts.map +1 -1
- package/resources/xcode-instances.d.ts +21 -5
- package/resources/xcode-instances.d.ts.map +1 -1
- package/src/client.ts +1 -0
- package/src/exec-client.ts +9 -0
- package/src/index.ts +4 -0
- package/src/instance-client.ts +9 -3
- package/src/internal/persist-option.ts +10 -5
- package/src/internal/session-stream.ts +6 -5
- package/src/ios-client.ts +87 -28
- package/src/resources/android-instances.ts +19 -5
- package/src/resources/daemon-client-shared.ts +5 -0
- package/src/resources/gradle-instances-helpers.ts +5 -0
- package/src/resources/gradle-instances.ts +22 -5
- package/src/resources/index.ts +4 -0
- package/src/resources/ios-instances-helpers.ts +7 -0
- package/src/resources/ios-instances.ts +19 -5
- package/src/resources/secrets.ts +210 -0
- package/src/resources/session-artifacts.ts +63 -8
- package/src/resources/xcode-instances-helpers.ts +5 -0
- package/src/resources/xcode-instances.ts +22 -5
- 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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { APIResource } from "../core/resource.mjs";
|
|
2
|
+
import { APIPromise } from "../core/api-promise.mjs";
|
|
3
|
+
import { RequestOptions } from "../internal/request-options.mjs";
|
|
4
|
+
/** Descriptive data stored by Limrun. Never put credentials in metadata. */
|
|
5
|
+
export interface SecretMetadata {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
organizationId: string;
|
|
10
|
+
metadata: Record<string, unknown>;
|
|
11
|
+
storageLocation: 'us' | 'eu';
|
|
12
|
+
state: 'pending' | 'ready' | 'deleting';
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SecretCreateParams {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface SecretUpdateParams {
|
|
21
|
+
/** Replaces descriptive metadata; does not change the name, type, or value. */
|
|
22
|
+
metadata: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface SecretListParams {
|
|
25
|
+
nameFilter?: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface SecretListResponse {
|
|
30
|
+
secrets: SecretMetadata[];
|
|
31
|
+
}
|
|
32
|
+
export interface SecretAccessToken {
|
|
33
|
+
accessToken: string;
|
|
34
|
+
expiresAt: string;
|
|
35
|
+
resource: string;
|
|
36
|
+
action: 'read' | 'write';
|
|
37
|
+
}
|
|
38
|
+
export interface SecretRequestOptions extends RequestOptions {
|
|
39
|
+
/** Defaults to the organization returned by whoami. */
|
|
40
|
+
organizationId?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SecretValueOptions extends RequestOptions {
|
|
43
|
+
/** Transport for direct Google requests, separate from the authenticated Limrun transport. */
|
|
44
|
+
storageFetch?: typeof fetch;
|
|
45
|
+
}
|
|
46
|
+
export declare class Secrets extends APIResource {
|
|
47
|
+
/** Create a container. Duplicate names return 409; values are written separately. */
|
|
48
|
+
create(body: SecretCreateParams, options?: RequestOptions): APIPromise<SecretMetadata>;
|
|
49
|
+
/** Update descriptive metadata by TID or name/<exact name>, without accessing its value. */
|
|
50
|
+
update(target: string, body: SecretUpdateParams, options?: RequestOptions): APIPromise<SecretMetadata>;
|
|
51
|
+
private collection;
|
|
52
|
+
/** List metadata visible to this credential. Values are never included. */
|
|
53
|
+
list(query?: SecretListParams, options?: SecretRequestOptions): Promise<SecretListResponse>;
|
|
54
|
+
/** Fetch metadata by TID or name/<exact name>. */
|
|
55
|
+
get(target: string, options?: SecretRequestOptions): Promise<SecretMetadata>;
|
|
56
|
+
/** Delete the container and all its versions. */
|
|
57
|
+
delete(target: string, options?: SecretRequestOptions): Promise<void>;
|
|
58
|
+
/** Mint access to one secret; no metadata-read permission is needed. */
|
|
59
|
+
createAccessToken(target: string, action: 'read' | 'write', options?: RequestOptions): APIPromise<SecretAccessToken>;
|
|
60
|
+
private transfer;
|
|
61
|
+
/** Read bytes directly from Google. Does not fetch or cache metadata. */
|
|
62
|
+
read(target: string, options?: SecretValueOptions): Promise<Uint8Array>;
|
|
63
|
+
/** Add a version directly in Google. Accepts UTF-8 text or binary data, up to 64 KiB. */
|
|
64
|
+
write(target: string, value: string | Uint8Array, options?: SecretValueOptions): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=secrets.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.mts","sourceRoot":"","sources":["../src/resources/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAA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core/api-promise.js";
|
|
3
|
+
import { RequestOptions } from "../internal/request-options.js";
|
|
4
|
+
/** Descriptive data stored by Limrun. Never put credentials in metadata. */
|
|
5
|
+
export interface SecretMetadata {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
organizationId: string;
|
|
10
|
+
metadata: Record<string, unknown>;
|
|
11
|
+
storageLocation: 'us' | 'eu';
|
|
12
|
+
state: 'pending' | 'ready' | 'deleting';
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SecretCreateParams {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface SecretUpdateParams {
|
|
21
|
+
/** Replaces descriptive metadata; does not change the name, type, or value. */
|
|
22
|
+
metadata: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface SecretListParams {
|
|
25
|
+
nameFilter?: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface SecretListResponse {
|
|
30
|
+
secrets: SecretMetadata[];
|
|
31
|
+
}
|
|
32
|
+
export interface SecretAccessToken {
|
|
33
|
+
accessToken: string;
|
|
34
|
+
expiresAt: string;
|
|
35
|
+
resource: string;
|
|
36
|
+
action: 'read' | 'write';
|
|
37
|
+
}
|
|
38
|
+
export interface SecretRequestOptions extends RequestOptions {
|
|
39
|
+
/** Defaults to the organization returned by whoami. */
|
|
40
|
+
organizationId?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SecretValueOptions extends RequestOptions {
|
|
43
|
+
/** Transport for direct Google requests, separate from the authenticated Limrun transport. */
|
|
44
|
+
storageFetch?: typeof fetch;
|
|
45
|
+
}
|
|
46
|
+
export declare class Secrets extends APIResource {
|
|
47
|
+
/** Create a container. Duplicate names return 409; values are written separately. */
|
|
48
|
+
create(body: SecretCreateParams, options?: RequestOptions): APIPromise<SecretMetadata>;
|
|
49
|
+
/** Update descriptive metadata by TID or name/<exact name>, without accessing its value. */
|
|
50
|
+
update(target: string, body: SecretUpdateParams, options?: RequestOptions): APIPromise<SecretMetadata>;
|
|
51
|
+
private collection;
|
|
52
|
+
/** List metadata visible to this credential. Values are never included. */
|
|
53
|
+
list(query?: SecretListParams, options?: SecretRequestOptions): Promise<SecretListResponse>;
|
|
54
|
+
/** Fetch metadata by TID or name/<exact name>. */
|
|
55
|
+
get(target: string, options?: SecretRequestOptions): Promise<SecretMetadata>;
|
|
56
|
+
/** Delete the container and all its versions. */
|
|
57
|
+
delete(target: string, options?: SecretRequestOptions): Promise<void>;
|
|
58
|
+
/** Mint access to one secret; no metadata-read permission is needed. */
|
|
59
|
+
createAccessToken(target: string, action: 'read' | 'write', options?: RequestOptions): APIPromise<SecretAccessToken>;
|
|
60
|
+
private transfer;
|
|
61
|
+
/** Read bytes directly from Google. Does not fetch or cache metadata. */
|
|
62
|
+
read(target: string, options?: SecretValueOptions): Promise<Uint8Array>;
|
|
63
|
+
/** Add a version directly in Google. Accepts UTF-8 text or binary data, up to 64 KiB. */
|
|
64
|
+
write(target: string, value: string | Uint8Array, options?: SecretValueOptions): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/resources/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,EAAE,UAAU,EAAE,+BAA4B;AACjD,OAAO,EAAE,cAAc,EAAE,uCAAoC;AAI7D,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO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E,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;YAIxF,UAAU;IAgBxB,2EAA2E;IACrE,IAAI,CAAC,KAAK,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAKrG,kDAAkD;IAC5C,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IAUlF,iDAAiD;IAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3E,wEAAwE;IACxE,iBAAiB,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,OAAO,EACxB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,iBAAiB,CAAC;YAQlB,QAAQ;IAwDtB,yEAAyE;IACnE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IAiB7E,yFAAyF;IACnF,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAMrG"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Secrets = void 0;
|
|
4
|
+
const resource_1 = require("../core/resource.js");
|
|
5
|
+
const headers_1 = require("../internal/headers.js");
|
|
6
|
+
const shims_1 = require("../internal/shims.js");
|
|
7
|
+
const resourcePattern = /^projects\/[a-zA-Z0-9-]+\/secrets\/secret_[0-7][0-9a-hjkmnp-tv-z]{25}$/;
|
|
8
|
+
const maxBytes = 65536;
|
|
9
|
+
function checksum(bytes) {
|
|
10
|
+
let crc = 0xffffffff;
|
|
11
|
+
for (const byte of bytes) {
|
|
12
|
+
crc ^= byte;
|
|
13
|
+
for (let bit = 0; bit < 8; bit++)
|
|
14
|
+
crc = (crc >>> 1) ^ (crc & 1 ? 0x82f63b78 : 0);
|
|
15
|
+
}
|
|
16
|
+
return String((crc ^ 0xffffffff) >>> 0);
|
|
17
|
+
}
|
|
18
|
+
class Secrets extends resource_1.APIResource {
|
|
19
|
+
/** Create a container. Duplicate names return 409; values are written separately. */
|
|
20
|
+
create(body, options) {
|
|
21
|
+
return this._client.post('/v1/secrets', { body, ...options });
|
|
22
|
+
}
|
|
23
|
+
/** Update descriptive metadata by TID or name/<exact name>, without accessing its value. */
|
|
24
|
+
update(target, body, options) {
|
|
25
|
+
return this._client.patch(`/v1/secrets/${encodeURIComponent(target)}`, { body, ...options });
|
|
26
|
+
}
|
|
27
|
+
async collection(options = {}) {
|
|
28
|
+
const { organizationId, ...request } = options;
|
|
29
|
+
let org = organizationId;
|
|
30
|
+
if (!org) {
|
|
31
|
+
const identity = await this._client.get('/v1/whoami', request);
|
|
32
|
+
org = identity.organization?.id ?? identity.user?.defaultOrganization?.id;
|
|
33
|
+
}
|
|
34
|
+
if (!org)
|
|
35
|
+
throw new Error('No organization found. Provide organizationId explicitly.');
|
|
36
|
+
return { path: `/v1/organizations/${encodeURIComponent(org)}/secrets`, options: request };
|
|
37
|
+
}
|
|
38
|
+
/** List metadata visible to this credential. Values are never included. */
|
|
39
|
+
async list(query = {}, options) {
|
|
40
|
+
const collection = await this.collection(options);
|
|
41
|
+
return this._client.get(collection.path, { ...collection.options, query });
|
|
42
|
+
}
|
|
43
|
+
/** Fetch metadata by TID or name/<exact name>. */
|
|
44
|
+
async get(target, options) {
|
|
45
|
+
if (target.startsWith('name/')) {
|
|
46
|
+
const result = await this.list({ nameFilter: target.slice(5), limit: 1 }, options);
|
|
47
|
+
if (!result.secrets[0])
|
|
48
|
+
throw new Error('Secret not found.');
|
|
49
|
+
return result.secrets[0];
|
|
50
|
+
}
|
|
51
|
+
const collection = await this.collection(options);
|
|
52
|
+
return this._client.get(`${collection.path}/${encodeURIComponent(target)}`, collection.options);
|
|
53
|
+
}
|
|
54
|
+
/** Delete the container and all its versions. */
|
|
55
|
+
async delete(target, options) {
|
|
56
|
+
const id = target.startsWith('name/') ? (await this.get(target, options)).id : target;
|
|
57
|
+
const collection = await this.collection(options);
|
|
58
|
+
await this._client.delete(`${collection.path}/${encodeURIComponent(id)}`, {
|
|
59
|
+
...collection.options,
|
|
60
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, collection.options.headers]),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Mint access to one secret; no metadata-read permission is needed. */
|
|
64
|
+
createAccessToken(target, action, options) {
|
|
65
|
+
// Debug logging must not expose the provider bearer credential.
|
|
66
|
+
return this._client.withOptions({ logLevel: 'off' }).post('/v1/secrets/access_tokens', {
|
|
67
|
+
...options,
|
|
68
|
+
body: { target, action },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async transfer(target, action, bytes, options = {}) {
|
|
72
|
+
const { storageFetch = (0, shims_1.getDefaultFetch)(), ...request } = options;
|
|
73
|
+
const timeout = AbortSignal.timeout(options.timeout ?? this._client.timeout);
|
|
74
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
|
|
75
|
+
const grant = await this.createAccessToken(target, action, { ...request, signal });
|
|
76
|
+
if (grant.action !== action ||
|
|
77
|
+
!resourcePattern.test(grant.resource) ||
|
|
78
|
+
(!target.startsWith('name/') && !grant.resource.endsWith(`/${target}`))) {
|
|
79
|
+
throw new Error('Invalid secret access grant.');
|
|
80
|
+
}
|
|
81
|
+
signal.throwIfAborted();
|
|
82
|
+
let response;
|
|
83
|
+
try {
|
|
84
|
+
response = await storageFetch(`https://secretmanager.googleapis.com/v1/${grant.resource}${action === 'read' ? '/versions/latest:access' : ':addVersion'}`, {
|
|
85
|
+
method: action === 'read' ? 'GET' : 'POST',
|
|
86
|
+
credentials: 'omit',
|
|
87
|
+
...{ cache: 'no-store', referrerPolicy: 'no-referrer' },
|
|
88
|
+
redirect: 'error',
|
|
89
|
+
signal,
|
|
90
|
+
headers: {
|
|
91
|
+
Authorization: `Bearer ${grant.accessToken}`,
|
|
92
|
+
...(bytes ? { 'Content-Type': 'application/json' } : {}),
|
|
93
|
+
},
|
|
94
|
+
...(bytes ?
|
|
95
|
+
{
|
|
96
|
+
body: JSON.stringify({
|
|
97
|
+
payload: {
|
|
98
|
+
data: btoa(Array.from(bytes, (b) => String.fromCharCode(b)).join('')),
|
|
99
|
+
dataCrc32c: checksum(bytes),
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
}
|
|
103
|
+
: {}),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
throw new Error(signal.aborted ? 'Secret storage request was aborted.' : 'Secret storage request failed.');
|
|
108
|
+
}
|
|
109
|
+
// Provider error bodies may echo secret material. Never include them in errors or logs.
|
|
110
|
+
if (!response.ok)
|
|
111
|
+
throw new Error(`Secret storage request failed (HTTP ${response.status}).`);
|
|
112
|
+
return response;
|
|
113
|
+
}
|
|
114
|
+
/** Read bytes directly from Google. Does not fetch or cache metadata. */
|
|
115
|
+
async read(target, options) {
|
|
116
|
+
const response = await this.transfer(target, 'read', undefined, options);
|
|
117
|
+
let value;
|
|
118
|
+
let bytes;
|
|
119
|
+
try {
|
|
120
|
+
value = (await response.json());
|
|
121
|
+
if (typeof value.payload?.data !== 'string' || value.payload.data.length > Math.ceil(maxBytes / 3) * 4)
|
|
122
|
+
throw new Error();
|
|
123
|
+
bytes = Uint8Array.from(atob(value.payload.data), (c) => c.charCodeAt(0));
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
throw new Error('Secret storage returned an invalid value.');
|
|
127
|
+
}
|
|
128
|
+
if (bytes.length > maxBytes || checksum(bytes) !== String(value.payload?.dataCrc32c))
|
|
129
|
+
throw new Error('Secret integrity check failed.');
|
|
130
|
+
return bytes;
|
|
131
|
+
}
|
|
132
|
+
/** Add a version directly in Google. Accepts UTF-8 text or binary data, up to 64 KiB. */
|
|
133
|
+
async write(target, value, options) {
|
|
134
|
+
const bytes = typeof value === 'string' ? new TextEncoder().encode(value) : value;
|
|
135
|
+
if (!bytes.length || bytes.length > maxBytes)
|
|
136
|
+
throw new Error('Secret values must contain between 1 byte and 64 KiB.');
|
|
137
|
+
await this.transfer(target, 'write', bytes, options);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.Secrets = Secrets;
|
|
141
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/resources/secrets.ts"],"names":[],"mappings":";;;AAAA,kDAA+C;AAG/C,oDAAmD;AACnD,gDAAoD;AA6CpD,MAAM,eAAe,GAAG,wEAAwE,CAAC;AACjG,MAAM,QAAQ,GAAG,KAAK,CAAC;AAEvB,SAAS,QAAQ,CAAC,KAAiB;IACjC,IAAI,GAAG,GAAG,UAAU,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,GAAG,IAAI,IAAI,CAAC;QACZ,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE;YAAE,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,MAAa,OAAQ,SAAQ,sBAAW;IACtC,qFAAqF;IACrF,MAAM,CAAC,IAAwB,EAAE,OAAwB;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI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M,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAClF,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ;YAC1C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC3E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF;AApJD,0BAoJC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { APIResource } from "../core/resource.mjs";
|
|
2
|
+
import { buildHeaders } from "../internal/headers.mjs";
|
|
3
|
+
import { getDefaultFetch } from "../internal/shims.mjs";
|
|
4
|
+
const resourcePattern = /^projects\/[a-zA-Z0-9-]+\/secrets\/secret_[0-7][0-9a-hjkmnp-tv-z]{25}$/;
|
|
5
|
+
const maxBytes = 65536;
|
|
6
|
+
function checksum(bytes) {
|
|
7
|
+
let crc = 0xffffffff;
|
|
8
|
+
for (const byte of bytes) {
|
|
9
|
+
crc ^= byte;
|
|
10
|
+
for (let bit = 0; bit < 8; bit++)
|
|
11
|
+
crc = (crc >>> 1) ^ (crc & 1 ? 0x82f63b78 : 0);
|
|
12
|
+
}
|
|
13
|
+
return String((crc ^ 0xffffffff) >>> 0);
|
|
14
|
+
}
|
|
15
|
+
export class Secrets extends APIResource {
|
|
16
|
+
/** Create a container. Duplicate names return 409; values are written separately. */
|
|
17
|
+
create(body, options) {
|
|
18
|
+
return this._client.post('/v1/secrets', { body, ...options });
|
|
19
|
+
}
|
|
20
|
+
/** Update descriptive metadata by TID or name/<exact name>, without accessing its value. */
|
|
21
|
+
update(target, body, options) {
|
|
22
|
+
return this._client.patch(`/v1/secrets/${encodeURIComponent(target)}`, { body, ...options });
|
|
23
|
+
}
|
|
24
|
+
async collection(options = {}) {
|
|
25
|
+
const { organizationId, ...request } = options;
|
|
26
|
+
let org = organizationId;
|
|
27
|
+
if (!org) {
|
|
28
|
+
const identity = await this._client.get('/v1/whoami', request);
|
|
29
|
+
org = identity.organization?.id ?? identity.user?.defaultOrganization?.id;
|
|
30
|
+
}
|
|
31
|
+
if (!org)
|
|
32
|
+
throw new Error('No organization found. Provide organizationId explicitly.');
|
|
33
|
+
return { path: `/v1/organizations/${encodeURIComponent(org)}/secrets`, options: request };
|
|
34
|
+
}
|
|
35
|
+
/** List metadata visible to this credential. Values are never included. */
|
|
36
|
+
async list(query = {}, options) {
|
|
37
|
+
const collection = await this.collection(options);
|
|
38
|
+
return this._client.get(collection.path, { ...collection.options, query });
|
|
39
|
+
}
|
|
40
|
+
/** Fetch metadata by TID or name/<exact name>. */
|
|
41
|
+
async get(target, options) {
|
|
42
|
+
if (target.startsWith('name/')) {
|
|
43
|
+
const result = await this.list({ nameFilter: target.slice(5), limit: 1 }, options);
|
|
44
|
+
if (!result.secrets[0])
|
|
45
|
+
throw new Error('Secret not found.');
|
|
46
|
+
return result.secrets[0];
|
|
47
|
+
}
|
|
48
|
+
const collection = await this.collection(options);
|
|
49
|
+
return this._client.get(`${collection.path}/${encodeURIComponent(target)}`, collection.options);
|
|
50
|
+
}
|
|
51
|
+
/** Delete the container and all its versions. */
|
|
52
|
+
async delete(target, options) {
|
|
53
|
+
const id = target.startsWith('name/') ? (await this.get(target, options)).id : target;
|
|
54
|
+
const collection = await this.collection(options);
|
|
55
|
+
await this._client.delete(`${collection.path}/${encodeURIComponent(id)}`, {
|
|
56
|
+
...collection.options,
|
|
57
|
+
headers: buildHeaders([{ Accept: '*/*' }, collection.options.headers]),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Mint access to one secret; no metadata-read permission is needed. */
|
|
61
|
+
createAccessToken(target, action, options) {
|
|
62
|
+
// Debug logging must not expose the provider bearer credential.
|
|
63
|
+
return this._client.withOptions({ logLevel: 'off' }).post('/v1/secrets/access_tokens', {
|
|
64
|
+
...options,
|
|
65
|
+
body: { target, action },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async transfer(target, action, bytes, options = {}) {
|
|
69
|
+
const { storageFetch = getDefaultFetch(), ...request } = options;
|
|
70
|
+
const timeout = AbortSignal.timeout(options.timeout ?? this._client.timeout);
|
|
71
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
|
|
72
|
+
const grant = await this.createAccessToken(target, action, { ...request, signal });
|
|
73
|
+
if (grant.action !== action ||
|
|
74
|
+
!resourcePattern.test(grant.resource) ||
|
|
75
|
+
(!target.startsWith('name/') && !grant.resource.endsWith(`/${target}`))) {
|
|
76
|
+
throw new Error('Invalid secret access grant.');
|
|
77
|
+
}
|
|
78
|
+
signal.throwIfAborted();
|
|
79
|
+
let response;
|
|
80
|
+
try {
|
|
81
|
+
response = await storageFetch(`https://secretmanager.googleapis.com/v1/${grant.resource}${action === 'read' ? '/versions/latest:access' : ':addVersion'}`, {
|
|
82
|
+
method: action === 'read' ? 'GET' : 'POST',
|
|
83
|
+
credentials: 'omit',
|
|
84
|
+
...{ cache: 'no-store', referrerPolicy: 'no-referrer' },
|
|
85
|
+
redirect: 'error',
|
|
86
|
+
signal,
|
|
87
|
+
headers: {
|
|
88
|
+
Authorization: `Bearer ${grant.accessToken}`,
|
|
89
|
+
...(bytes ? { 'Content-Type': 'application/json' } : {}),
|
|
90
|
+
},
|
|
91
|
+
...(bytes ?
|
|
92
|
+
{
|
|
93
|
+
body: JSON.stringify({
|
|
94
|
+
payload: {
|
|
95
|
+
data: btoa(Array.from(bytes, (b) => String.fromCharCode(b)).join('')),
|
|
96
|
+
dataCrc32c: checksum(bytes),
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
}
|
|
100
|
+
: {}),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
throw new Error(signal.aborted ? 'Secret storage request was aborted.' : 'Secret storage request failed.');
|
|
105
|
+
}
|
|
106
|
+
// Provider error bodies may echo secret material. Never include them in errors or logs.
|
|
107
|
+
if (!response.ok)
|
|
108
|
+
throw new Error(`Secret storage request failed (HTTP ${response.status}).`);
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
/** Read bytes directly from Google. Does not fetch or cache metadata. */
|
|
112
|
+
async read(target, options) {
|
|
113
|
+
const response = await this.transfer(target, 'read', undefined, options);
|
|
114
|
+
let value;
|
|
115
|
+
let bytes;
|
|
116
|
+
try {
|
|
117
|
+
value = (await response.json());
|
|
118
|
+
if (typeof value.payload?.data !== 'string' || value.payload.data.length > Math.ceil(maxBytes / 3) * 4)
|
|
119
|
+
throw new Error();
|
|
120
|
+
bytes = Uint8Array.from(atob(value.payload.data), (c) => c.charCodeAt(0));
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
throw new Error('Secret storage returned an invalid value.');
|
|
124
|
+
}
|
|
125
|
+
if (bytes.length > maxBytes || checksum(bytes) !== String(value.payload?.dataCrc32c))
|
|
126
|
+
throw new Error('Secret integrity check failed.');
|
|
127
|
+
return bytes;
|
|
128
|
+
}
|
|
129
|
+
/** Add a version directly in Google. Accepts UTF-8 text or binary data, up to 64 KiB. */
|
|
130
|
+
async write(target, value, options) {
|
|
131
|
+
const bytes = typeof value === 'string' ? new TextEncoder().encode(value) : value;
|
|
132
|
+
if (!bytes.length || bytes.length > maxBytes)
|
|
133
|
+
throw new Error('Secret values must contain between 1 byte and 64 KiB.');
|
|
134
|
+
await this.transfer(target, 'write', bytes, options);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=secrets.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.mjs","sourceRoot":"","sources":["../src/resources/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAG/C,OAAO,EAAE,YAAY,EAAE,gCAA4B;AACnD,OAAO,EAAE,eAAe,EAAE,8BAA0B;AA6CpD,MAAM,eAAe,GAAG,wEAAwE,CAAC;AACjG,MAAM,QAAQ,GAAG,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AC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC;YAClF,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yFAAyF;IACzF,KAAK,CAAC,KAAK,CAAC,MAAc,EAAE,KAA0B,EAAE,OAA4B;QAClF,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAClF,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ;YAC1C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC3E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/** The kind of a persisted session capture. */
|
|
2
|
-
export type SessionArtifactKind = 'recording' | 'appLog' | 'eventLog' | 'networkLog';
|
|
2
|
+
export type SessionArtifactKind = 'recording' | 'appLog' | 'eventLog' | 'networkLog' | 'performance';
|
|
3
3
|
/**
|
|
4
4
|
* One persisted session capture of an instance: a video recording, an app log
|
|
5
|
-
* capture, a coalesced event log,
|
|
6
|
-
* director's
|
|
7
|
-
*
|
|
5
|
+
* capture, a coalesced event log, a HAR network log, or iOS app performance
|
|
6
|
+
* samples. Returned by the director's
|
|
7
|
+
* GET /v1/{ios,android}_instances/{id}/session_artifacts endpoint, optionally
|
|
8
|
+
* narrowed with its kind query parameter.
|
|
8
9
|
*/
|
|
9
10
|
export interface SessionArtifact {
|
|
10
11
|
id: string;
|
|
@@ -22,7 +23,8 @@ export interface SessionArtifact {
|
|
|
22
23
|
sizeBytes?: number;
|
|
23
24
|
/**
|
|
24
25
|
* Short-lived presigned GET URL for the raw artifact: MP4 for recordings,
|
|
25
|
-
* JSONL for app logs and
|
|
26
|
+
* JSONL for app logs, event logs and performance samples, HAR for network
|
|
27
|
+
* logs.
|
|
26
28
|
*/
|
|
27
29
|
downloadUrl: string;
|
|
28
30
|
}
|
|
@@ -67,4 +69,43 @@ export interface SessionEvent {
|
|
|
67
69
|
*/
|
|
68
70
|
summary?: string;
|
|
69
71
|
}
|
|
72
|
+
/** One thread's share of an app's CPU in a {@link PerformanceSample}. */
|
|
73
|
+
export interface PerformanceThread {
|
|
74
|
+
/** The thread's name, `main` for the main thread, or empty. */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Share of one core; 100 is one fully busy core. */
|
|
77
|
+
cpuPercent: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* One running app's resource use at one moment, the figures Xcode's debug
|
|
81
|
+
* gauges show. iOS instances sample every running app they installed once a
|
|
82
|
+
* second, delivered live by `streamPerformance` and stored one-per-line in
|
|
83
|
+
* `performance` artifacts. Rates cover the second since the previous sample of
|
|
84
|
+
* the same process, so a process's first sample has none.
|
|
85
|
+
*/
|
|
86
|
+
export interface PerformanceSample {
|
|
87
|
+
/** Epoch milliseconds, same clock as SessionLogLine. */
|
|
88
|
+
ts: number;
|
|
89
|
+
bundleId: string;
|
|
90
|
+
/** Changes when the app relaunches. */
|
|
91
|
+
pid: number;
|
|
92
|
+
/** The process start in epoch milliseconds. */
|
|
93
|
+
startedAt: number;
|
|
94
|
+
/** Set for XCTest runners such as WebDriverAgent. */
|
|
95
|
+
testRunner?: boolean;
|
|
96
|
+
/** One fully busy core is 100, so a multithreaded app can exceed it. */
|
|
97
|
+
cpuPercent?: number;
|
|
98
|
+
/** Physical footprint, the figure Xcode's memory gauge and iOS's memory limit use. */
|
|
99
|
+
footprintBytes: number;
|
|
100
|
+
/** The highest footprint over the process lifetime. */
|
|
101
|
+
peakFootprintBytes: number;
|
|
102
|
+
threadCount: number;
|
|
103
|
+
diskReadBytesPerSecond?: number;
|
|
104
|
+
diskWriteBytesPerSecond?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Up to five threads using at least 0.1% of a core, busiest first. They add
|
|
107
|
+
* up to roughly, not exactly, the app's `cpuPercent`.
|
|
108
|
+
*/
|
|
109
|
+
topThreads?: PerformanceThread[];
|
|
110
|
+
}
|
|
70
111
|
//# sourceMappingURL=session-artifacts.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-artifacts.d.mts","sourceRoot":"","sources":["../src/resources/session-artifacts.ts"],"names":[],"mappings":"AAMA,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"session-artifacts.d.mts","sourceRoot":"","sources":["../src/resources/session-artifacts.ts"],"names":[],"mappings":"AAMA,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;AAErG;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,mBAAmB,CAAC;IAE1B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB,SAAS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qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,sFAAsF;IACtF,cAAc,EAAE,MAAM,CAAC;IAEvB,uDAAuD;IACvD,kBAAkB,EAAE,MAAM,CAAC;IAE3B,WAAW,EAAE,MAAM,CAAC;IAEpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC;;;OAGG;IACH,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAClC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/** The kind of a persisted session capture. */
|
|
2
|
-
export type SessionArtifactKind = 'recording' | 'appLog' | 'eventLog' | 'networkLog';
|
|
2
|
+
export type SessionArtifactKind = 'recording' | 'appLog' | 'eventLog' | 'networkLog' | 'performance';
|
|
3
3
|
/**
|
|
4
4
|
* One persisted session capture of an instance: a video recording, an app log
|
|
5
|
-
* capture, a coalesced event log,
|
|
6
|
-
* director's
|
|
7
|
-
*
|
|
5
|
+
* capture, a coalesced event log, a HAR network log, or iOS app performance
|
|
6
|
+
* samples. Returned by the director's
|
|
7
|
+
* GET /v1/{ios,android}_instances/{id}/session_artifacts endpoint, optionally
|
|
8
|
+
* narrowed with its kind query parameter.
|
|
8
9
|
*/
|
|
9
10
|
export interface SessionArtifact {
|
|
10
11
|
id: string;
|
|
@@ -22,7 +23,8 @@ export interface SessionArtifact {
|
|
|
22
23
|
sizeBytes?: number;
|
|
23
24
|
/**
|
|
24
25
|
* Short-lived presigned GET URL for the raw artifact: MP4 for recordings,
|
|
25
|
-
* JSONL for app logs and
|
|
26
|
+
* JSONL for app logs, event logs and performance samples, HAR for network
|
|
27
|
+
* logs.
|
|
26
28
|
*/
|
|
27
29
|
downloadUrl: string;
|
|
28
30
|
}
|
|
@@ -67,4 +69,43 @@ export interface SessionEvent {
|
|
|
67
69
|
*/
|
|
68
70
|
summary?: string;
|
|
69
71
|
}
|
|
72
|
+
/** One thread's share of an app's CPU in a {@link PerformanceSample}. */
|
|
73
|
+
export interface PerformanceThread {
|
|
74
|
+
/** The thread's name, `main` for the main thread, or empty. */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Share of one core; 100 is one fully busy core. */
|
|
77
|
+
cpuPercent: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* One running app's resource use at one moment, the figures Xcode's debug
|
|
81
|
+
* gauges show. iOS instances sample every running app they installed once a
|
|
82
|
+
* second, delivered live by `streamPerformance` and stored one-per-line in
|
|
83
|
+
* `performance` artifacts. Rates cover the second since the previous sample of
|
|
84
|
+
* the same process, so a process's first sample has none.
|
|
85
|
+
*/
|
|
86
|
+
export interface PerformanceSample {
|
|
87
|
+
/** Epoch milliseconds, same clock as SessionLogLine. */
|
|
88
|
+
ts: number;
|
|
89
|
+
bundleId: string;
|
|
90
|
+
/** Changes when the app relaunches. */
|
|
91
|
+
pid: number;
|
|
92
|
+
/** The process start in epoch milliseconds. */
|
|
93
|
+
startedAt: number;
|
|
94
|
+
/** Set for XCTest runners such as WebDriverAgent. */
|
|
95
|
+
testRunner?: boolean;
|
|
96
|
+
/** One fully busy core is 100, so a multithreaded app can exceed it. */
|
|
97
|
+
cpuPercent?: number;
|
|
98
|
+
/** Physical footprint, the figure Xcode's memory gauge and iOS's memory limit use. */
|
|
99
|
+
footprintBytes: number;
|
|
100
|
+
/** The highest footprint over the process lifetime. */
|
|
101
|
+
peakFootprintBytes: number;
|
|
102
|
+
threadCount: number;
|
|
103
|
+
diskReadBytesPerSecond?: number;
|
|
104
|
+
diskWriteBytesPerSecond?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Up to five threads using at least 0.1% of a core, busiest first. They add
|
|
107
|
+
* up to roughly, not exactly, the app's `cpuPercent`.
|
|
108
|
+
*/
|
|
109
|
+
topThreads?: PerformanceThread[];
|
|
110
|
+
}
|
|
70
111
|
//# sourceMappingURL=session-artifacts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-artifacts.d.ts","sourceRoot":"","sources":["../src/resources/session-artifacts.ts"],"names":[],"mappings":"AAMA,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"session-artifacts.d.ts","sourceRoot":"","sources":["../src/resources/session-artifacts.ts"],"names":[],"mappings":"AAMA,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;AAErG;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,mBAAmB,CAAC;IAE1B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,gBAAgB,CAAC;IAEvB,oEAAoE;IACpE,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IAEb,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAC;IAEX,QAAQ,EAAE,MAAM,CAAC;IAEjB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IAEZ,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAElB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,sFAAsF;IACtF,cAAc,EAAE,MAAM,CAAC;IAEvB,uDAAuD;IACvD,kBAAkB,EAAE,MAAM,CAAC;IAE3B,WAAW,EAAE,MAAM,CAAC;IAEpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC;;;OAGG;IACH,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAClC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Hand-written: the session-artifact list endpoint is not in the generated
|
|
3
3
|
// OpenAPI surface yet. Shared by the iOS and Android instance helpers.
|
|
4
|
-
// SessionLogLine and
|
|
5
|
-
// limrun repo; the runtimes emit the same JSON
|
|
6
|
-
// persisted JSONL artifacts.
|
|
4
|
+
// SessionLogLine, SessionEvent and PerformanceSample mirror
|
|
5
|
+
// pkg/artifacts/contract.go in the limrun repo; the runtimes emit the same JSON
|
|
6
|
+
// over live SSE and into the persisted JSONL artifacts.
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
//# sourceMappingURL=session-artifacts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-artifacts.js","sourceRoot":"","sources":["../src/resources/session-artifacts.ts"],"names":[],"mappings":";AAAA,2EAA2E;AAC3E,uEAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"session-artifacts.js","sourceRoot":"","sources":["../src/resources/session-artifacts.ts"],"names":[],"mappings":";AAAA,2EAA2E;AAC3E,uEAAuE;AACvE,4DAA4D;AAC5D,gFAAgF;AAChF,wDAAwD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Hand-written: the session-artifact list endpoint is not in the generated
|
|
2
2
|
// OpenAPI surface yet. Shared by the iOS and Android instance helpers.
|
|
3
|
-
// SessionLogLine and
|
|
4
|
-
// limrun repo; the runtimes emit the same JSON
|
|
5
|
-
// persisted JSONL artifacts.
|
|
3
|
+
// SessionLogLine, SessionEvent and PerformanceSample mirror
|
|
4
|
+
// pkg/artifacts/contract.go in the limrun repo; the runtimes emit the same JSON
|
|
5
|
+
// over live SSE and into the persisted JSONL artifacts.
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=session-artifacts.mjs.map
|