@onkernel/sdk 0.80.0 → 0.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs +1 -1
  8. package/client.mjs.map +1 -1
  9. package/index.d.mts +1 -0
  10. package/index.d.mts.map +1 -1
  11. package/index.d.ts +1 -0
  12. package/index.d.ts.map +1 -1
  13. package/index.js +3 -1
  14. package/index.js.map +1 -1
  15. package/index.mjs +1 -0
  16. package/index.mjs.map +1 -1
  17. package/lib/audit-log-download.d.mts +28 -0
  18. package/lib/audit-log-download.d.mts.map +1 -0
  19. package/lib/audit-log-download.d.ts +28 -0
  20. package/lib/audit-log-download.d.ts.map +1 -0
  21. package/lib/audit-log-download.js +176 -0
  22. package/lib/audit-log-download.js.map +1 -0
  23. package/lib/audit-log-download.mjs +171 -0
  24. package/lib/audit-log-download.mjs.map +1 -0
  25. package/package.json +1 -1
  26. package/resources/audit-logs.d.mts +11 -1
  27. package/resources/audit-logs.d.mts.map +1 -1
  28. package/resources/audit-logs.d.ts +11 -1
  29. package/resources/audit-logs.d.ts.map +1 -1
  30. package/resources/audit-logs.js +11 -0
  31. package/resources/audit-logs.js.map +1 -1
  32. package/resources/audit-logs.mjs +11 -0
  33. package/resources/audit-logs.mjs.map +1 -1
  34. package/resources/index.d.mts +1 -1
  35. package/resources/index.d.mts.map +1 -1
  36. package/resources/index.d.ts +1 -1
  37. package/resources/index.d.ts.map +1 -1
  38. package/resources/index.js.map +1 -1
  39. package/resources/index.mjs.map +1 -1
  40. package/resources/profiles.d.mts +13 -3
  41. package/resources/profiles.d.mts.map +1 -1
  42. package/resources/profiles.d.ts +13 -3
  43. package/resources/profiles.d.ts.map +1 -1
  44. package/resources/profiles.js +6 -2
  45. package/resources/profiles.js.map +1 -1
  46. package/resources/profiles.mjs +6 -2
  47. package/resources/profiles.mjs.map +1 -1
  48. package/resources/projects/projects.d.mts +4 -4
  49. package/resources/projects/projects.d.ts +4 -4
  50. package/src/client.ts +8 -1
  51. package/src/index.ts +9 -0
  52. package/src/lib/audit-log-download.ts +234 -0
  53. package/src/resources/audit-logs.ts +42 -0
  54. package/src/resources/index.ts +1 -0
  55. package/src/resources/profiles.ts +19 -2
  56. package/src/resources/projects/projects.ts +4 -4
  57. package/src/version.ts +1 -1
  58. package/version.d.mts +1 -1
  59. package/version.d.ts +1 -1
  60. package/version.js +1 -1
  61. package/version.mjs +1 -1
@@ -68,7 +68,10 @@ export declare class Profiles extends APIResource {
68
68
  */
69
69
  delete(idOrName: string, options?: RequestOptions): APIPromise<void>;
70
70
  /**
71
- * Returns a zstd-compressed tar file of the full user-data directory.
71
+ * Downloads the profile in its stored format by default. Current profiles are
72
+ * returned as zstd-compressed tar archives, while legacy profiles remain JSON. Set
73
+ * `format=tar` to decompress current profiles during download; legacy profiles
74
+ * remain JSON.
72
75
  *
73
76
  * @example
74
77
  * ```ts
@@ -80,7 +83,7 @@ export declare class Profiles extends APIResource {
80
83
  * console.log(content);
81
84
  * ```
82
85
  */
83
- download(idOrName: string, options?: RequestOptions): APIPromise<Response>;
86
+ download(idOrName: string, query?: ProfileDownloadParams | null | undefined, options?: RequestOptions): APIPromise<Response>;
84
87
  }
85
88
  export interface ProfileCreateParams {
86
89
  /**
@@ -111,8 +114,15 @@ export interface ProfileListParams extends OffsetPaginationParams {
111
114
  */
112
115
  query?: string;
113
116
  }
117
+ export interface ProfileDownloadParams {
118
+ /**
119
+ * Response format for current profile archives. Legacy profiles are always
120
+ * returned as JSON.
121
+ */
122
+ format?: 'tar.zst' | 'tar';
123
+ }
114
124
  export declare namespace Profiles {
115
- export { type ProfileCreateParams as ProfileCreateParams, type ProfileUpdateParams as ProfileUpdateParams, type ProfileListParams as ProfileListParams, };
125
+ export { type ProfileCreateParams as ProfileCreateParams, type ProfileUpdateParams as ProfileUpdateParams, type ProfileListParams as ProfileListParams, type ProfileDownloadParams as ProfileDownloadParams, };
116
126
  }
117
127
  export { type ProfilesOffsetPagination };
118
128
  //# sourceMappingURL=profiles.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.d.mts","sourceRoot":"","sources":["../src/resources/profiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAC/C,OAAO,KAAK,WAAW,gCAA4B;AACnD,OAAO,EAAE,wBAAwB,EAAE,gCAA4B;AAC/D,OAAO,EAAE,UAAU,EAAE,gCAA4B;AACjD,OAAO,EAAoB,KAAK,sBAAsB,EAAE,WAAW,EAAE,+BAA2B;AAEhG,OAAO,EAAE,cAAc,EAAE,wCAAoC;AAG7D;;GAEG;AACH,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC;IAI5F;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC;IAIrF;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,mBAAmB,EACzB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC;IAIlC;;;;;;;;;;OAUG;IACH,IAAI,CACF,KAAK,GAAE,iBAAiB,GAAG,IAAI,GAAG,SAAc,EAChD,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,wBAAwB,EAAE,WAAW,CAAC,OAAO,CAAC;IAI7D;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc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mB,IAAI,mBAAmB,EAC/C,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH;AAED,OAAO,EAAE,KAAK,wBAAwB,EAAE,CAAC"}
@@ -68,7 +68,10 @@ export declare class Profiles extends APIResource {
68
68
  */
69
69
  delete(idOrName: string, options?: RequestOptions): APIPromise<void>;
70
70
  /**
71
- * Returns a zstd-compressed tar file of the full user-data directory.
71
+ * Downloads the profile in its stored format by default. Current profiles are
72
+ * returned as zstd-compressed tar archives, while legacy profiles remain JSON. Set
73
+ * `format=tar` to decompress current profiles during download; legacy profiles
74
+ * remain JSON.
72
75
  *
73
76
  * @example
74
77
  * ```ts
@@ -80,7 +83,7 @@ export declare class Profiles extends APIResource {
80
83
  * console.log(content);
81
84
  * ```
82
85
  */
83
- download(idOrName: string, options?: RequestOptions): APIPromise<Response>;
86
+ download(idOrName: string, query?: ProfileDownloadParams | null | undefined, options?: RequestOptions): APIPromise<Response>;
84
87
  }
85
88
  export interface ProfileCreateParams {
86
89
  /**
@@ -111,8 +114,15 @@ export interface ProfileListParams extends OffsetPaginationParams {
111
114
  */
112
115
  query?: string;
113
116
  }
117
+ export interface ProfileDownloadParams {
118
+ /**
119
+ * Response format for current profile archives. Legacy profiles are always
120
+ * returned as JSON.
121
+ */
122
+ format?: 'tar.zst' | 'tar';
123
+ }
114
124
  export declare namespace Profiles {
115
- export { type ProfileCreateParams as ProfileCreateParams, type ProfileUpdateParams as ProfileUpdateParams, type ProfileListParams as ProfileListParams, };
125
+ export { type ProfileCreateParams as ProfileCreateParams, type ProfileUpdateParams as ProfileUpdateParams, type ProfileListParams as ProfileListParams, type ProfileDownloadParams as ProfileDownloadParams, };
116
126
  }
117
127
  export { type ProfilesOffsetPagination };
118
128
  //# sourceMappingURL=profiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/resources/profiles.ts"],"names":[],"mappings":"AAEA,O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IlC;;;;;;;;;;OAUG;IACH,IAAI,CACF,KAAK,GAAE,iBAAiB,GAAG,IAAI,GAAG,SAAc,EAChD,OAAO,CAAC,EAAE,cAAc,GACvB,WAAW,CAAC,wBAAwB,EAAE,WAAW,CAAC,OAAO,CAAC;IAI7D;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAOpE;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,qBAAqB,GAAG,IAAI,GAAG,SAAc,EACpD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,QAAQ,CAAC;CAQxB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC/D;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EACL,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH;AAED,OAAO,EAAE,KAAK,wBAAwB,EAAE,CAAC"}
@@ -83,7 +83,10 @@ class Profiles extends resource_1.APIResource {
83
83
  });
84
84
  }
85
85
  /**
86
- * Returns a zstd-compressed tar file of the full user-data directory.
86
+ * Downloads the profile in its stored format by default. Current profiles are
87
+ * returned as zstd-compressed tar archives, while legacy profiles remain JSON. Set
88
+ * `format=tar` to decompress current profiles during download; legacy profiles
89
+ * remain JSON.
87
90
  *
88
91
  * @example
89
92
  * ```ts
@@ -95,8 +98,9 @@ class Profiles extends resource_1.APIResource {
95
98
  * console.log(content);
96
99
  * ```
97
100
  */
98
- download(idOrName, options) {
101
+ download(idOrName, query = {}, options) {
99
102
  return this._client.get((0, path_1.path) `/profiles/${idOrName}/download`, {
103
+ query,
100
104
  ...options,
101
105
  headers: (0, headers_1.buildHeaders)([{ Accept: 'application/octet-stream' }, options?.headers]),
102
106
  __binaryResponse: true,
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.js","sourceRoot":"","sources":["../src/resources/profiles.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,sDAAgG;AAChG,oDAAmD;AAEnD,oDAA8C;AAE9C;;GAEG;AACH,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,aAAa,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CACJ,QAAgB,EAChB,IAAyB,EACzB,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAA,WAAI,EAAA,aAAa,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;OAUG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AC,CAAC;YACjF,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;CACF;AAjHD,4BAiHC"}
@@ -80,7 +80,10 @@ export class Profiles extends APIResource {
80
80
  });
81
81
  }
82
82
  /**
83
- * Returns a zstd-compressed tar file of the full user-data directory.
83
+ * Downloads the profile in its stored format by default. Current profiles are
84
+ * returned as zstd-compressed tar archives, while legacy profiles remain JSON. Set
85
+ * `format=tar` to decompress current profiles during download; legacy profiles
86
+ * remain JSON.
84
87
  *
85
88
  * @example
86
89
  * ```ts
@@ -92,8 +95,9 @@ export class Profiles extends APIResource {
92
95
  * console.log(content);
93
96
  * ```
94
97
  */
95
- download(idOrName, options) {
98
+ download(idOrName, query = {}, options) {
96
99
  return this._client.get(path `/profiles/${idOrName}/download`, {
100
+ query,
97
101
  ...options,
98
102
  headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
99
103
  __binaryResponse: true,
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.mjs","sourceRoot":"","sources":["../src/resources/profiles.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAI/C,OAAO,EAAE,gBAAgB,EAA4C,+BAA2B;AAChG,OAAO,EAAE,YAAY,EAAE,gCAA4B;AAEnD,OAAO,EAAE,IAAI,EAAE,mCAA+B;AAE9C;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,aAAa,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;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;;;;;;;;OAeG;IACH,QAAQ,CACN,QAAgB,EAChB,QAAkD,EAAE,EACpD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,aAAa,QAAQ,WAAW,EAAE;YAC5D,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,0BAA0B,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACjF,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -63,7 +63,7 @@ export declare class Projects extends APIResource {
63
63
  export type ProjectsOffsetPagination = OffsetPagination<Project>;
64
64
  export interface CreateProjectRequest {
65
65
  /**
66
- * Project name (1-255 characters)
66
+ * Project name (1-255 Unicode code points)
67
67
  */
68
68
  name: string;
69
69
  }
@@ -91,7 +91,7 @@ export interface Project {
91
91
  }
92
92
  export interface UpdateProjectRequest {
93
93
  /**
94
- * New project name
94
+ * New project name (1-255 Unicode code points)
95
95
  */
96
96
  name?: string;
97
97
  /**
@@ -101,13 +101,13 @@ export interface UpdateProjectRequest {
101
101
  }
102
102
  export interface ProjectCreateParams {
103
103
  /**
104
- * Project name (1-255 characters)
104
+ * Project name (1-255 Unicode code points)
105
105
  */
106
106
  name: string;
107
107
  }
108
108
  export interface ProjectUpdateParams {
109
109
  /**
110
- * New project name
110
+ * New project name (1-255 Unicode code points)
111
111
  */
112
112
  name?: string;
113
113
  /**
@@ -63,7 +63,7 @@ export declare class Projects extends APIResource {
63
63
  export type ProjectsOffsetPagination = OffsetPagination<Project>;
64
64
  export interface CreateProjectRequest {
65
65
  /**
66
- * Project name (1-255 characters)
66
+ * Project name (1-255 Unicode code points)
67
67
  */
68
68
  name: string;
69
69
  }
@@ -91,7 +91,7 @@ export interface Project {
91
91
  }
92
92
  export interface UpdateProjectRequest {
93
93
  /**
94
- * New project name
94
+ * New project name (1-255 Unicode code points)
95
95
  */
96
96
  name?: string;
97
97
  /**
@@ -101,13 +101,13 @@ export interface UpdateProjectRequest {
101
101
  }
102
102
  export interface ProjectCreateParams {
103
103
  /**
104
- * Project name (1-255 characters)
104
+ * Project name (1-255 Unicode code points)
105
105
  */
106
106
  name: string;
107
107
  }
108
108
  export interface ProjectUpdateParams {
109
109
  /**
110
- * New project name
110
+ * New project name (1-255 Unicode code points)
111
111
  */
112
112
  name?: string;
113
113
  /**
package/src/client.ts CHANGED
@@ -123,7 +123,13 @@ import {
123
123
  InvocationUpdateResponse,
124
124
  Invocations,
125
125
  } from './resources/invocations';
126
- import { ProfileCreateParams, ProfileListParams, ProfileUpdateParams, Profiles } from './resources/profiles';
126
+ import {
127
+ ProfileCreateParams,
128
+ ProfileDownloadParams,
129
+ ProfileListParams,
130
+ ProfileUpdateParams,
131
+ Profiles,
132
+ } from './resources/profiles';
127
133
  import {
128
134
  Proxies,
129
135
  ProxyCheckParams,
@@ -1126,6 +1132,7 @@ export declare namespace Kernel {
1126
1132
  type ProfileCreateParams as ProfileCreateParams,
1127
1133
  type ProfileUpdateParams as ProfileUpdateParams,
1128
1134
  type ProfileListParams as ProfileListParams,
1135
+ type ProfileDownloadParams as ProfileDownloadParams,
1129
1136
  };
1130
1137
 
1131
1138
  export { Auth as Auth };
package/src/index.ts CHANGED
@@ -6,6 +6,15 @@ export { type Uploadable, toFile } from './core/uploads';
6
6
  export { APIPromise } from './core/api-promise';
7
7
  export { Kernel, type ClientOptions } from './client';
8
8
  export { type BrowserFetchInit } from './lib/browser-fetch';
9
+ export {
10
+ AuditLogDownloadError,
11
+ type AuditLogDownloadDestination,
12
+ type AuditLogDownloadOptions,
13
+ type AuditLogDownloadParams,
14
+ type AuditLogDownloadProgress,
15
+ type AuditLogDownloadResult,
16
+ type AuditLogDownloadWriteResult,
17
+ } from './lib/audit-log-download';
9
18
  export { BrowserRouteCache, type BrowserRoute } from './lib/browser-routing';
10
19
  export { PagePromise } from './core/pagination';
11
20
  export {
@@ -0,0 +1,234 @@
1
+ import { APIConnectionTimeoutError, APIUserAbortError, KernelError } from '../core/error';
2
+ import type { RequestOptions } from '../internal/request-options';
3
+ import type { AuditLogExportChunkParams } from '../resources/audit-logs';
4
+
5
+ const DEFAULT_MAX_TRANSFER_RETRIES = 6;
6
+ const MAX_CHUNK_ROWS = 50_000;
7
+ const MAX_RETRY_DELAY_MS = 8_000;
8
+
9
+ export class AuditLogDownloadError extends KernelError {}
10
+
11
+ export type AuditLogDownloadParams = Omit<AuditLogExportChunkParams, 'cursor' | 'format'>;
12
+
13
+ export interface AuditLogDownloadResult {
14
+ bytesWritten: number;
15
+ chunks: number;
16
+ rows: number;
17
+ }
18
+
19
+ export interface AuditLogDownloadProgress extends AuditLogDownloadResult {
20
+ chunkRows: number;
21
+ }
22
+
23
+ export type AuditLogDownloadWriteResult = void | number | { bytesWritten: number };
24
+
25
+ export interface AuditLogDownloadDestination {
26
+ write(chunk: Uint8Array): AuditLogDownloadWriteResult | Promise<AuditLogDownloadWriteResult>;
27
+ }
28
+
29
+ export interface AuditLogDownloadOptions
30
+ extends Omit<
31
+ RequestOptions,
32
+ 'method' | 'path' | 'query' | 'body' | 'stream' | '__binaryResponse' | '__streamClass'
33
+ > {
34
+ onProgress?(progress: AuditLogDownloadProgress): void | Promise<void>;
35
+ maxTransferRetries?: number;
36
+ }
37
+
38
+ type FetchChunk = (query: AuditLogExportChunkParams, options?: RequestOptions) => Promise<Response>;
39
+
40
+ export async function downloadAuditLogs(
41
+ fetchChunk: FetchChunk,
42
+ query: AuditLogDownloadParams,
43
+ destination: AuditLogDownloadDestination,
44
+ defaultTimeout: number,
45
+ options: AuditLogDownloadOptions = {},
46
+ ): Promise<AuditLogDownloadResult> {
47
+ if (!destination || typeof destination.write !== 'function') {
48
+ throw new TypeError('audit log download destination must provide write()');
49
+ }
50
+
51
+ const { onProgress, maxTransferRetries = DEFAULT_MAX_TRANSFER_RETRIES, ...requestOptions } = options;
52
+ if (!Number.isInteger(maxTransferRetries) || maxTransferRetries < 0) {
53
+ throw new TypeError('maxTransferRetries must be a non-negative integer');
54
+ }
55
+ const timeout = requestOptions.timeout ?? defaultTimeout;
56
+ let cursor: string | undefined;
57
+ const result: AuditLogDownloadResult = { bytesWritten: 0, chunks: 0, rows: 0 };
58
+ const seenCursors = new Set<string>();
59
+
60
+ while (true) {
61
+ const chunk = await fetchVerifiedChunk(
62
+ fetchChunk,
63
+ cursor ? { ...query, cursor } : query,
64
+ requestOptions,
65
+ maxTransferRetries,
66
+ timeout,
67
+ );
68
+ const { nextCursor, hasMore, rows } = parseChunkHeaders(chunk.headers, cursor);
69
+ if (hasMore && nextCursor) {
70
+ if (seenCursors.has(nextCursor)) {
71
+ throw new AuditLogDownloadError('response repeated X-Next-Cursor header');
72
+ }
73
+ seenCursors.add(nextCursor);
74
+ }
75
+ await writeChunk(destination, chunk.body);
76
+
77
+ cursor = nextCursor;
78
+ result.bytesWritten += chunk.body.byteLength;
79
+ result.chunks += 1;
80
+ result.rows += rows;
81
+ if (onProgress) {
82
+ await onProgress({ ...result, chunkRows: rows });
83
+ }
84
+ if (!hasMore) {
85
+ return result;
86
+ }
87
+ }
88
+ }
89
+
90
+ async function fetchVerifiedChunk(
91
+ fetchChunk: FetchChunk,
92
+ query: AuditLogExportChunkParams,
93
+ options: RequestOptions,
94
+ maxTransferRetries: number,
95
+ timeout: number,
96
+ ): Promise<{ body: Uint8Array; headers: Headers }> {
97
+ for (let retries = 0; ; retries += 1) {
98
+ const controller = new AbortController();
99
+ const onAbort = () => controller.abort();
100
+ if (options.signal?.aborted) {
101
+ controller.abort();
102
+ } else {
103
+ options.signal?.addEventListener('abort', onAbort, { once: true });
104
+ }
105
+
106
+ let response: Response;
107
+ try {
108
+ response = await fetchChunk(query, { ...options, signal: controller.signal });
109
+ } catch (error) {
110
+ options.signal?.removeEventListener('abort', onAbort);
111
+ throw error;
112
+ }
113
+
114
+ let bodyTimedOut = false;
115
+ const timer = setTimeout(() => {
116
+ bodyTimedOut = true;
117
+ controller.abort();
118
+ }, timeout);
119
+ try {
120
+ const body = new Uint8Array(await response.arrayBuffer());
121
+ clearTimeout(timer);
122
+ if (options.signal?.aborted) {
123
+ throw new APIUserAbortError();
124
+ }
125
+ if (bodyTimedOut) {
126
+ throw new APIConnectionTimeoutError();
127
+ }
128
+ const expected = response.headers.get('x-content-sha256');
129
+ if (!expected) {
130
+ throw new AuditLogDownloadError('response missing X-Content-Sha256 header');
131
+ }
132
+ const actual = await sha256Hex(body);
133
+ if (options.signal?.aborted) {
134
+ throw new APIUserAbortError();
135
+ }
136
+ if (actual !== expected) {
137
+ throw new AuditLogDownloadError(
138
+ `audit log chunk checksum mismatch (got ${actual}, want ${expected})`,
139
+ );
140
+ }
141
+ return { body, headers: response.headers };
142
+ } catch (error) {
143
+ if (options.signal?.aborted && !(error instanceof APIUserAbortError)) {
144
+ error = new APIUserAbortError();
145
+ } else if (bodyTimedOut) {
146
+ error = new APIConnectionTimeoutError();
147
+ }
148
+ if (retries === maxTransferRetries || error instanceof APIUserAbortError) {
149
+ throw error;
150
+ }
151
+ await retryDelay(retries + 1, options.signal);
152
+ } finally {
153
+ clearTimeout(timer);
154
+ options.signal?.removeEventListener('abort', onAbort);
155
+ }
156
+ }
157
+ }
158
+
159
+ function parseChunkHeaders(
160
+ headers: Headers,
161
+ currentCursor: string | undefined,
162
+ ): { rows: number; nextCursor: string | undefined; hasMore: boolean } {
163
+ const hasMoreValue = headers.get('x-has-more');
164
+ if (hasMoreValue !== 'true' && hasMoreValue !== 'false') {
165
+ throw new AuditLogDownloadError('response missing or invalid X-Has-More header');
166
+ }
167
+ const hasMore = hasMoreValue === 'true';
168
+
169
+ const rowCount = headers.get('x-row-count');
170
+ if (rowCount === null || !/^[0-9]+$/.test(rowCount)) {
171
+ throw new AuditLogDownloadError('response missing or invalid X-Row-Count header');
172
+ }
173
+ const rows = Number(rowCount);
174
+ if (!Number.isSafeInteger(rows) || rows > MAX_CHUNK_ROWS) {
175
+ throw new AuditLogDownloadError('response missing or invalid X-Row-Count header');
176
+ }
177
+
178
+ const nextCursor = headers.get('x-next-cursor') || undefined;
179
+ if (hasMore && (!nextCursor || nextCursor === currentCursor)) {
180
+ throw new AuditLogDownloadError('response has invalid X-Next-Cursor header');
181
+ }
182
+ if (!hasMore && nextCursor) {
183
+ throw new AuditLogDownloadError('response returned a cursor after the final chunk');
184
+ }
185
+ return { rows, nextCursor, hasMore };
186
+ }
187
+
188
+ async function sha256Hex(body: Uint8Array): Promise<string> {
189
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', body);
190
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
191
+ }
192
+
193
+ async function retryDelay(attempt: number, signal: AbortSignal | null | undefined): Promise<void> {
194
+ const delay = Math.min(1_000 * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
195
+ await new Promise<void>((resolve, reject) => {
196
+ if (signal?.aborted) {
197
+ reject(new APIUserAbortError());
198
+ return;
199
+ }
200
+ const onAbort = () => {
201
+ clearTimeout(timer);
202
+ reject(new APIUserAbortError());
203
+ };
204
+ const timer = setTimeout(() => {
205
+ signal?.removeEventListener('abort', onAbort);
206
+ resolve();
207
+ }, delay);
208
+ signal?.addEventListener('abort', onAbort, { once: true });
209
+ });
210
+ }
211
+
212
+ async function writeChunk(destination: AuditLogDownloadDestination, body: Uint8Array): Promise<void> {
213
+ let offset = 0;
214
+ while (offset < body.byteLength) {
215
+ const result = await destination.write(offset === 0 ? body : body.subarray(offset));
216
+ if (typeof result === 'number') {
217
+ offset += validateWriteCount(result, body.byteLength - offset);
218
+ continue;
219
+ }
220
+ if (result && typeof result === 'object' && 'bytesWritten' in result) {
221
+ const bytesWritten = (result as { bytesWritten: number }).bytesWritten;
222
+ offset += validateWriteCount(bytesWritten, body.byteLength - offset);
223
+ continue;
224
+ }
225
+ return;
226
+ }
227
+ }
228
+
229
+ function validateWriteCount(value: number, remaining: number): number {
230
+ if (!Number.isSafeInteger(value) || value <= 0 || value > remaining) {
231
+ throw new AuditLogDownloadError('audit log download destination performed a short write');
232
+ }
233
+ return value;
234
+ }
@@ -5,6 +5,22 @@ import { APIPromise } from '../core/api-promise';
5
5
  import { PagePromise, PageTokenPagination, type PageTokenPaginationParams } from '../core/pagination';
6
6
  import { buildHeaders } from '../internal/headers';
7
7
  import { RequestOptions } from '../internal/request-options';
8
+ import {
9
+ downloadAuditLogs,
10
+ type AuditLogDownloadDestination,
11
+ type AuditLogDownloadOptions,
12
+ type AuditLogDownloadParams,
13
+ type AuditLogDownloadProgress,
14
+ type AuditLogDownloadResult,
15
+ } from '../lib/audit-log-download';
16
+
17
+ export type {
18
+ AuditLogDownloadDestination,
19
+ AuditLogDownloadOptions,
20
+ AuditLogDownloadParams,
21
+ AuditLogDownloadProgress,
22
+ AuditLogDownloadResult,
23
+ } from '../lib/audit-log-download';
8
24
 
9
25
  /**
10
26
  * Read audit log records for the authenticated organization.
@@ -34,6 +50,27 @@ export class AuditLogs extends APIResource {
34
50
  __binaryResponse: true,
35
51
  });
36
52
  }
53
+
54
+ /**
55
+ * Download a complete gzip-compressed JSON Lines audit log export to a writable
56
+ * destination. The SDK verifies every chunk and retries transient transfer
57
+ * failures. It does not close the destination. If the download fails, the
58
+ * destination may contain a partial export; use a temporary file and atomic
59
+ * rename when the completed export must be published atomically.
60
+ */
61
+ download(
62
+ query: AuditLogDownloadParams,
63
+ destination: AuditLogDownloadDestination,
64
+ options?: AuditLogDownloadOptions,
65
+ ): Promise<AuditLogDownloadResult> {
66
+ return downloadAuditLogs(
67
+ (chunkQuery, chunkOptions) => this.exportChunk(chunkQuery, chunkOptions),
68
+ query,
69
+ destination,
70
+ this._client.timeout,
71
+ options,
72
+ );
73
+ }
37
74
  }
38
75
 
39
76
  export type AuditLogEntriesPageTokenPagination = PageTokenPagination<AuditLogEntry>;
@@ -205,5 +242,10 @@ export declare namespace AuditLogs {
205
242
  type AuditLogEntriesPageTokenPagination as AuditLogEntriesPageTokenPagination,
206
243
  type AuditLogListParams as AuditLogListParams,
207
244
  type AuditLogExportChunkParams as AuditLogExportChunkParams,
245
+ type AuditLogDownloadDestination as AuditLogDownloadDestination,
246
+ type AuditLogDownloadOptions as AuditLogDownloadOptions,
247
+ type AuditLogDownloadParams as AuditLogDownloadParams,
248
+ type AuditLogDownloadProgress as AuditLogDownloadProgress,
249
+ type AuditLogDownloadResult as AuditLogDownloadResult,
208
250
  };
209
251
  }
@@ -125,6 +125,7 @@ export {
125
125
  type ProfileCreateParams,
126
126
  type ProfileUpdateParams,
127
127
  type ProfileListParams,
128
+ type ProfileDownloadParams,
128
129
  } from './profiles';
129
130
  export {
130
131
  Projects,
@@ -98,7 +98,10 @@ export class Profiles extends APIResource {
98
98
  }
99
99
 
100
100
  /**
101
- * Returns a zstd-compressed tar file of the full user-data directory.
101
+ * Downloads the profile in its stored format by default. Current profiles are
102
+ * returned as zstd-compressed tar archives, while legacy profiles remain JSON. Set
103
+ * `format=tar` to decompress current profiles during download; legacy profiles
104
+ * remain JSON.
102
105
  *
103
106
  * @example
104
107
  * ```ts
@@ -110,8 +113,13 @@ export class Profiles extends APIResource {
110
113
  * console.log(content);
111
114
  * ```
112
115
  */
113
- download(idOrName: string, options?: RequestOptions): APIPromise<Response> {
116
+ download(
117
+ idOrName: string,
118
+ query: ProfileDownloadParams | null | undefined = {},
119
+ options?: RequestOptions,
120
+ ): APIPromise<Response> {
114
121
  return this._client.get(path`/profiles/${idOrName}/download`, {
122
+ query,
115
123
  ...options,
116
124
  headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
117
125
  __binaryResponse: true,
@@ -152,11 +160,20 @@ export interface ProfileListParams extends OffsetPaginationParams {
152
160
  query?: string;
153
161
  }
154
162
 
163
+ export interface ProfileDownloadParams {
164
+ /**
165
+ * Response format for current profile archives. Legacy profiles are always
166
+ * returned as JSON.
167
+ */
168
+ format?: 'tar.zst' | 'tar';
169
+ }
170
+
155
171
  export declare namespace Profiles {
156
172
  export {
157
173
  type ProfileCreateParams as ProfileCreateParams,
158
174
  type ProfileUpdateParams as ProfileUpdateParams,
159
175
  type ProfileListParams as ProfileListParams,
176
+ type ProfileDownloadParams as ProfileDownloadParams,
160
177
  };
161
178
  }
162
179
 
@@ -91,7 +91,7 @@ export type ProjectsOffsetPagination = OffsetPagination<Project>;
91
91
 
92
92
  export interface CreateProjectRequest {
93
93
  /**
94
- * Project name (1-255 characters)
94
+ * Project name (1-255 Unicode code points)
95
95
  */
96
96
  name: string;
97
97
  }
@@ -125,7 +125,7 @@ export interface Project {
125
125
 
126
126
  export interface UpdateProjectRequest {
127
127
  /**
128
- * New project name
128
+ * New project name (1-255 Unicode code points)
129
129
  */
130
130
  name?: string;
131
131
 
@@ -137,14 +137,14 @@ export interface UpdateProjectRequest {
137
137
 
138
138
  export interface ProjectCreateParams {
139
139
  /**
140
- * Project name (1-255 characters)
140
+ * Project name (1-255 Unicode code points)
141
141
  */
142
142
  name: string;
143
143
  }
144
144
 
145
145
  export interface ProjectUpdateParams {
146
146
  /**
147
- * New project name
147
+ * New project name (1-255 Unicode code points)
148
148
  */
149
149
  name?: string;
150
150
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.80.0'; // x-release-please-version
1
+ export const VERSION = '0.82.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.80.0";
1
+ export declare const VERSION = "0.82.0";
2
2
  //# sourceMappingURL=version.d.mts.map