@typeship-ax/cli 0.6.0 → 0.9.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.
Files changed (121) hide show
  1. package/AGENTS.md +31 -0
  2. package/README.md +26 -9
  3. package/api.json +6861 -3083
  4. package/api.md +508 -277
  5. package/dist/api-identity.d.ts +40 -0
  6. package/dist/api-identity.d.ts.map +1 -0
  7. package/dist/api-identity.js +128 -0
  8. package/dist/auth-profiles.d.ts +30 -0
  9. package/dist/auth-profiles.d.ts.map +1 -0
  10. package/dist/auth-profiles.js +138 -0
  11. package/dist/cli-agent.d.ts +9 -1
  12. package/dist/cli-agent.d.ts.map +1 -1
  13. package/dist/cli-agent.js +26 -9
  14. package/dist/cli.js +600 -582
  15. package/dist/console-login-check.d.ts +21 -0
  16. package/dist/console-login-check.d.ts.map +1 -0
  17. package/dist/console-login-check.js +107 -0
  18. package/dist/console-login-contract.d.ts +45 -0
  19. package/dist/console-login-contract.d.ts.map +1 -0
  20. package/dist/console-login-contract.js +40 -0
  21. package/dist/core/http.d.ts +21 -92
  22. package/dist/core/http.d.ts.map +1 -1
  23. package/dist/core/http.js +143 -221
  24. package/dist/core/pagination.d.ts.map +1 -1
  25. package/dist/core/pagination.js +6 -34
  26. package/dist/credential-storage.d.ts +24 -0
  27. package/dist/credential-storage.d.ts.map +1 -0
  28. package/dist/credential-storage.js +207 -0
  29. package/dist/dates.d.ts +0 -2
  30. package/dist/dates.d.ts.map +1 -1
  31. package/dist/dates.js +0 -1
  32. package/dist/docs.d.ts +36 -0
  33. package/dist/docs.d.ts.map +1 -0
  34. package/dist/docs.js +258 -0
  35. package/dist/errors.d.ts +42 -34
  36. package/dist/errors.d.ts.map +1 -1
  37. package/dist/errors.js +30 -20
  38. package/dist/index.d.ts +27 -12
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +40 -14
  41. package/dist/named-credentials.d.ts +21 -0
  42. package/dist/named-credentials.d.ts.map +1 -0
  43. package/dist/named-credentials.js +86 -0
  44. package/dist/oauth-login.d.ts +39 -0
  45. package/dist/oauth-login.d.ts.map +1 -0
  46. package/dist/oauth-login.js +171 -0
  47. package/dist/oauth-request.d.ts +21 -0
  48. package/dist/oauth-request.d.ts.map +1 -0
  49. package/dist/oauth-request.js +119 -0
  50. package/dist/oauth-session.d.ts +106 -0
  51. package/dist/oauth-session.d.ts.map +1 -0
  52. package/dist/oauth-session.js +244 -0
  53. package/dist/ops.d.ts +18 -0
  54. package/dist/ops.d.ts.map +1 -1
  55. package/dist/ops.js +31 -17
  56. package/dist/polling-login.d.ts +57 -0
  57. package/dist/polling-login.d.ts.map +1 -0
  58. package/dist/polling-login.js +204 -0
  59. package/dist/resources/account.d.ts +4 -4
  60. package/dist/resources/account.d.ts.map +1 -1
  61. package/dist/resources/account.js +1 -0
  62. package/dist/resources/api-keys.d.ts +13 -8
  63. package/dist/resources/api-keys.d.ts.map +1 -1
  64. package/dist/resources/api-keys.js +5 -1
  65. package/dist/resources/definition-revisions.d.ts +58 -0
  66. package/dist/resources/definition-revisions.d.ts.map +1 -0
  67. package/dist/resources/definition-revisions.js +114 -0
  68. package/dist/resources/definitions.d.ts +35 -0
  69. package/dist/resources/definitions.d.ts.map +1 -0
  70. package/dist/resources/definitions.js +60 -0
  71. package/dist/resources/generate.d.ts +18 -7
  72. package/dist/resources/generate.d.ts.map +1 -1
  73. package/dist/resources/generate.js +13 -5
  74. package/dist/resources/generations.d.ts +6 -6
  75. package/dist/resources/generations.d.ts.map +1 -1
  76. package/dist/resources/generations.js +3 -1
  77. package/dist/resources/projects.d.ts +111 -35
  78. package/dist/resources/projects.d.ts.map +1 -1
  79. package/dist/resources/projects.js +125 -15
  80. package/dist/resources/targets.d.ts +97 -0
  81. package/dist/resources/targets.d.ts.map +1 -0
  82. package/dist/resources/targets.js +197 -0
  83. package/dist/schemas.d.ts.map +1 -1
  84. package/dist/schemas.js +135 -62
  85. package/dist/types.d.ts +2072 -267
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/types.js +20 -3
  88. package/package.json +2 -1
  89. package/src/api-identity.ts +98 -0
  90. package/src/auth-profiles.ts +114 -0
  91. package/src/cli-agent.ts +28 -11
  92. package/src/cli.ts +528 -560
  93. package/src/console-login-check.ts +88 -0
  94. package/src/console-login-contract.ts +65 -0
  95. package/src/core/http.ts +156 -305
  96. package/src/core/pagination.ts +6 -30
  97. package/src/credential-storage.ts +183 -0
  98. package/src/dates.ts +0 -1
  99. package/src/docs.ts +239 -0
  100. package/src/errors.ts +52 -41
  101. package/src/index.ts +49 -14
  102. package/src/named-credentials.ts +74 -0
  103. package/src/oauth-login.ts +184 -0
  104. package/src/oauth-request.ts +90 -0
  105. package/src/oauth-session.ts +258 -0
  106. package/src/ops.ts +56 -17
  107. package/src/polling-login.ts +165 -0
  108. package/src/resources/account.ts +6 -3
  109. package/src/resources/api-keys.ts +27 -7
  110. package/src/resources/definition-revisions.ts +207 -0
  111. package/src/resources/definitions.ts +122 -0
  112. package/src/resources/generate.ts +29 -6
  113. package/src/resources/generations.ts +9 -4
  114. package/src/resources/projects.ts +274 -41
  115. package/src/resources/targets.ts +378 -0
  116. package/src/schemas.ts +135 -62
  117. package/src/types.ts +2273 -322
  118. package/dist/resources/spec-revisions.d.ts +0 -47
  119. package/dist/resources/spec-revisions.d.ts.map +0 -1
  120. package/dist/resources/spec-revisions.js +0 -90
  121. package/src/resources/spec-revisions.ts +0 -150
@@ -0,0 +1,57 @@
1
+ export declare class LoginPollingError extends Error {
2
+ readonly code: "cancelled" | "expired" | "denied" | "invalid_response" | "request_failed";
3
+ constructor(code: "cancelled" | "expired" | "denied" | "invalid_response" | "request_failed");
4
+ }
5
+ export declare function loginEndpoint(value: string): URL;
6
+ export interface DeviceLoginConfig {
7
+ clientId: string;
8
+ issuer?: string | null;
9
+ discoveryUrls: string[];
10
+ deviceUrl?: string | null;
11
+ tokenUrl?: string | null;
12
+ scopes: string[];
13
+ audience?: string;
14
+ resource?: string;
15
+ }
16
+ export interface DeviceLoginSession {
17
+ accessToken: string;
18
+ refreshToken?: string;
19
+ expiresAt?: number;
20
+ tokenUrl: string;
21
+ issuer?: string;
22
+ clientId: string;
23
+ revocationUrl?: string;
24
+ scopes?: string[];
25
+ }
26
+ /** RFC 8628: pending and slow_down are the only responses that keep polling.
27
+ * All deadlines include response bodies; cancellation also interrupts waits. */
28
+ export declare function oauthDeviceLogin(config: DeviceLoginConfig, interaction: {
29
+ authorize(value: {
30
+ verificationUri: string;
31
+ userCode: string;
32
+ expiresIn: number;
33
+ }): void;
34
+ signal?: AbortSignal;
35
+ timeoutMs?: number;
36
+ }): Promise<DeviceLoginSession>;
37
+ export interface ApprovedCredential {
38
+ api_key: string;
39
+ key_name: string;
40
+ org_id?: string;
41
+ revocationUrl: string;
42
+ }
43
+ /** This is the owner's custom approval contract, not an OAuth grant. A failed
44
+ * poll is not replayed: its one-use credential may already have been consumed. */
45
+ export declare function customBrowserApproval(config: {
46
+ authUrl: string;
47
+ name: string;
48
+ source: "agent" | "cli";
49
+ }, interaction: {
50
+ authorize(value: {
51
+ verificationUrl: string;
52
+ expiresIn: number;
53
+ }): void;
54
+ signal?: AbortSignal;
55
+ timeoutMs?: number;
56
+ }): Promise<ApprovedCredential>;
57
+ //# sourceMappingURL=polling-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling-login.d.ts","sourceRoot":"","sources":["../src/polling-login.ts"],"names":[],"mappings":"AAGA,qBAAa,iBAAkB,SAAQ,KAAK;IAC9B,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,kBAAkB,GAAG,gBAAgB;gBAAhF,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,kBAAkB,GAAG,gBAAgB;CAItG;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAQhD;AAkCD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IAAC,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AAM,EAAE,OAAO,GAAG,KAAK,CAAA;CAAE,EAAE,WAAW,EAAE;IAC3H,SAAS,CAAC,KAAK,EAAE;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC1C,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkC9B"}
@@ -0,0 +1,204 @@
1
+ import { createHash, randomBytes } from "node:crypto";
2
+ import { oauthJsonRequest, oauthDeviceRequest, OAuthResponseError } from "./oauth-request.js";
3
+ export class LoginPollingError extends Error {
4
+ code;
5
+ constructor(code) {
6
+ super({ cancelled: "Login was cancelled.", expired: "Login expired. Run login again and approve the new request.", denied: "Login was denied. Run login again if you want to retry.", invalid_response: "The login service returned an invalid response. Check its configuration.", request_failed: "The login request failed. Check the service and start a new login." }[code]);
7
+ this.code = code;
8
+ this.name = "LoginPollingError";
9
+ }
10
+ }
11
+ export function loginEndpoint(value) {
12
+ try {
13
+ if (typeof value !== "string" || /[\x00-\x20\x7f]/.test(value))
14
+ throw new Error();
15
+ const url = new URL(value);
16
+ const local = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
17
+ if ((url.protocol !== "https:" && !(url.protocol === "http:" && local)) || url.username || url.password || url.hash)
18
+ throw new Error();
19
+ return url;
20
+ }
21
+ catch {
22
+ throw new LoginPollingError("invalid_response");
23
+ }
24
+ }
25
+ function text(value, limit = 65_536) {
26
+ return typeof value === "string" && value.trim().length > 0 && value.length <= limit && !/[\x00-\x1f\x7f]/.test(value);
27
+ }
28
+ function seconds(value) {
29
+ return typeof value === "number" && Number.isFinite(value) && value > 0 && Number.isSafeInteger(Math.ceil(value * 1000));
30
+ }
31
+ function interval(value, fallback) {
32
+ if (value === undefined)
33
+ return fallback * 1000;
34
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || !Number.isSafeInteger(Math.ceil(value * 1000)))
35
+ throw new LoginPollingError("invalid_response");
36
+ return Math.max(1, value) * 1000;
37
+ }
38
+ function lifetime(signal, timeoutMs, maximum) {
39
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > maximum)
40
+ throw new LoginPollingError("invalid_response");
41
+ const controller = new AbortController();
42
+ let expired = false;
43
+ const cancel = () => controller.abort();
44
+ const timer = setTimeout(() => { expired = true; controller.abort(); }, timeoutMs);
45
+ signal?.addEventListener("abort", cancel, { once: true });
46
+ if (signal?.aborted)
47
+ cancel();
48
+ const check = () => { if (controller.signal.aborted)
49
+ throw new LoginPollingError(expired ? "expired" : "cancelled"); };
50
+ return { signal: controller.signal, check, close() { clearTimeout(timer); signal?.removeEventListener("abort", cancel); } };
51
+ }
52
+ async function pause(ms, signal) {
53
+ if (signal.aborted)
54
+ throw new LoginPollingError("cancelled");
55
+ await new Promise((resolve, reject) => {
56
+ const done = () => { clearTimeout(timer); signal.removeEventListener("abort", abort); resolve(); };
57
+ const abort = () => { clearTimeout(timer); signal.removeEventListener("abort", abort); reject(new LoginPollingError("cancelled")); };
58
+ const timer = setTimeout(done, Math.min(ms, 2_147_483_647));
59
+ signal.addEventListener("abort", abort, { once: true });
60
+ });
61
+ }
62
+ const form = (params, signal) => ({ method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" }, body: new URLSearchParams(params), signal });
63
+ /** RFC 8628: pending and slow_down are the only responses that keep polling.
64
+ * All deadlines include response bodies; cancellation also interrupts waits. */
65
+ export async function oauthDeviceLogin(config, interaction) {
66
+ const flow = lifetime(interaction.signal, interaction.timeoutMs ?? 900_000, 900_000);
67
+ try {
68
+ flow.check();
69
+ if (!text(config.clientId))
70
+ throw new LoginPollingError("invalid_response");
71
+ if (config.issuer && loginEndpoint(config.issuer).search)
72
+ throw new LoginPollingError("invalid_response");
73
+ let deviceUrl = config.deviceUrl ? loginEndpoint(config.deviceUrl).href : undefined;
74
+ let tokenUrl = config.tokenUrl ? loginEndpoint(config.tokenUrl).href : undefined;
75
+ let revocationUrl;
76
+ for (const url of config.discoveryUrls) {
77
+ if (deviceUrl && tokenUrl)
78
+ break;
79
+ const response = await oauthJsonRequest(loginEndpoint(url), { headers: { Accept: "application/json" }, signal: flow.signal }, 10_000);
80
+ if (response.status !== 200)
81
+ continue;
82
+ const data = response.data;
83
+ if (config.issuer && data.issuer !== config.issuer)
84
+ throw new LoginPollingError("invalid_response");
85
+ if (!deviceUrl && typeof data.device_authorization_endpoint === "string")
86
+ deviceUrl = loginEndpoint(data.device_authorization_endpoint).href;
87
+ if (!tokenUrl && typeof data.token_endpoint === "string")
88
+ tokenUrl = loginEndpoint(data.token_endpoint).href;
89
+ if (data.revocation_endpoint !== undefined)
90
+ revocationUrl = loginEndpoint(data.revocation_endpoint).href;
91
+ }
92
+ if (!deviceUrl || !tokenUrl)
93
+ throw new LoginPollingError("invalid_response");
94
+ const params = { ...(config.audience ? { audience: config.audience } : {}), ...(config.resource ? { resource: config.resource } : {}) };
95
+ const start = await oauthJsonRequest(deviceUrl, form({ client_id: config.clientId, ...(config.scopes.length ? { scope: config.scopes.join(" ") } : {}), ...params }, flow.signal));
96
+ const data = start.data;
97
+ if (start.status !== 200)
98
+ throw new LoginPollingError("request_failed");
99
+ if (!data || !text(data.device_code) || !text(data.user_code, 512) || !text(data.verification_uri, 8192) || !seconds(data.expires_in))
100
+ throw new LoginPollingError("invalid_response");
101
+ loginEndpoint(data.verification_uri);
102
+ const verificationUri = loginEndpoint((data.verification_uri_complete ?? data.verification_uri)).href;
103
+ let intervalMs = interval(data.interval, 5);
104
+ const expiresIn = Math.min(data.expires_in, 900), deadline = Date.now() + expiresIn * 1000;
105
+ interaction.authorize({ verificationUri, userCode: data.user_code, expiresIn });
106
+ while (true) {
107
+ await pause(Math.min(intervalMs, Math.max(0, deadline - Date.now())), flow.signal);
108
+ flow.check();
109
+ if (Date.now() >= deadline)
110
+ throw new LoginPollingError("expired");
111
+ let response;
112
+ try {
113
+ response = await oauthDeviceRequest(tokenUrl, form({ ...params, grant_type: "urn:ietf:params:oauth:grant-type:device_code", device_code: data.device_code, client_id: config.clientId }, flow.signal), Math.min(30_000, deadline - Date.now()));
114
+ }
115
+ catch (error) {
116
+ flow.check();
117
+ if (error instanceof OAuthResponseError && error.code === "timed_out") {
118
+ intervalMs *= 2;
119
+ continue;
120
+ }
121
+ throw error;
122
+ }
123
+ flow.check();
124
+ if (Date.now() >= deadline)
125
+ throw new LoginPollingError("expired");
126
+ if (response.status === 400 && response.error === "authorization_pending")
127
+ continue;
128
+ if (response.status === 400 && response.error === "slow_down") {
129
+ intervalMs += 5000;
130
+ continue;
131
+ }
132
+ if (response.status === 400 && response.error === "access_denied")
133
+ throw new LoginPollingError("denied");
134
+ if (response.status === 400 && response.error === "expired_token")
135
+ throw new LoginPollingError("expired");
136
+ if (response.status !== 200)
137
+ throw new LoginPollingError("request_failed");
138
+ const token = response.data;
139
+ if (!text(token.access_token) || typeof token.token_type !== "string" || token.token_type.toLowerCase() !== "bearer" || token.error !== undefined || token.refresh_token !== undefined && !text(token.refresh_token) || token.expires_in !== undefined && !seconds(token.expires_in) || token.scope !== undefined && typeof token.scope !== "string")
140
+ throw new LoginPollingError("invalid_response");
141
+ return { accessToken: token.access_token, ...(typeof token.refresh_token === "string" ? { refreshToken: token.refresh_token } : {}), ...(typeof token.expires_in === "number" ? { expiresAt: Date.now() + token.expires_in * 1000 } : {}), clientId: config.clientId, tokenUrl, ...(config.issuer ? { issuer: config.issuer } : {}), ...(revocationUrl ? { revocationUrl } : {}), ...(typeof token.scope === "string" ? { scopes: token.scope.split(/\s+/).filter(Boolean) } : {}) };
142
+ }
143
+ }
144
+ catch (error) {
145
+ flow.check();
146
+ throw error;
147
+ }
148
+ finally {
149
+ flow.close();
150
+ }
151
+ }
152
+ /** This is the owner's custom approval contract, not an OAuth grant. A failed
153
+ * poll is not replayed: its one-use credential may already have been consumed. */
154
+ export async function customBrowserApproval(config, interaction) {
155
+ const flow = lifetime(interaction.signal, interaction.timeoutMs ?? 600_000, 600_000);
156
+ try {
157
+ flow.check();
158
+ const base = loginEndpoint(config.authUrl);
159
+ if (base.search)
160
+ throw new LoginPollingError("invalid_response");
161
+ const url = base.href.replace(/\/$/, "");
162
+ const verifier = randomBytes(32).toString("base64url"), challenge = createHash("sha256").update(verifier).digest("base64url");
163
+ const post = (body) => ({ method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, body: JSON.stringify(body), signal: flow.signal });
164
+ const response = await oauthJsonRequest(url + "/start", post({ code_challenge: challenge, name: config.name, source: config.source }), 15_000);
165
+ if (response.status !== 200)
166
+ throw new LoginPollingError("request_failed");
167
+ const start = response.data;
168
+ if (!text(start.session) || !text(start.verification_url, 8192) || start.expires_in !== undefined && !seconds(start.expires_in))
169
+ throw new LoginPollingError("invalid_response");
170
+ const verificationUrl = loginEndpoint(start.verification_url).href;
171
+ const expiresIn = Math.min(typeof start.expires_in === "number" ? start.expires_in : 600, 600);
172
+ const intervalMs = interval(start.interval, 3), deadline = Date.now() + expiresIn * 1000;
173
+ interaction.authorize({ verificationUrl, expiresIn });
174
+ while (true) {
175
+ await pause(Math.min(intervalMs, Math.max(0, deadline - Date.now())), flow.signal);
176
+ flow.check();
177
+ if (Date.now() >= deadline)
178
+ throw new LoginPollingError("expired");
179
+ const result = await oauthJsonRequest(url + "/status", post({ session: start.session, code_verifier: verifier }), Math.min(15_000, deadline - Date.now()));
180
+ flow.check();
181
+ if (Date.now() >= deadline)
182
+ throw new LoginPollingError("expired");
183
+ if (result.status !== 200)
184
+ throw new LoginPollingError("request_failed");
185
+ const poll = result.data;
186
+ if (poll.status === "pending")
187
+ continue;
188
+ if (poll.status === "denied")
189
+ throw new LoginPollingError("denied");
190
+ if (poll.status === "expired")
191
+ throw new LoginPollingError("expired");
192
+ if (poll.status !== "complete" || !text(poll.api_key) || poll.key_name !== undefined && !text(poll.key_name, 1024) || poll.org_id !== undefined && !text(poll.org_id, 1024))
193
+ throw new LoginPollingError("invalid_response");
194
+ return { api_key: poll.api_key, key_name: typeof poll.key_name === "string" ? poll.key_name : config.name, ...(typeof poll.org_id === "string" ? { org_id: poll.org_id } : {}), revocationUrl: url + "/revoke" };
195
+ }
196
+ }
197
+ catch (error) {
198
+ flow.check();
199
+ throw error;
200
+ }
201
+ finally {
202
+ flow.close();
203
+ }
204
+ }
@@ -1,6 +1,6 @@
1
1
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
2
- import { TransportError, UnexpectedApiError, ValidationError, ForbiddenError, RateLimitedError, UnauthorizedError } from "../errors.js";
3
- import type { Account } from "../types.js";
2
+ import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, ForbiddenError, RateLimitedError, UnauthorizedError } from "../errors.js";
3
+ import type { AccountRead } from "../types.js";
4
4
  export declare class AccountResource {
5
5
  private readonly _core;
6
6
  constructor(_core: HttpCore);
@@ -11,8 +11,8 @@ export declare class AccountResource {
11
11
  * identity endpoint the generated typeship CLI's `whoami` calls.
12
12
  * `GET /me`
13
13
  */
14
- retrieve(options?: RequestOptions): Promise<ApiResult<Account, AccountRetrieveError>>;
14
+ retrieve(options?: RequestOptions): Promise<ApiResult<AccountRead, AccountRetrieveError>>;
15
15
  }
16
16
  /** Every error `retrieve` can produce, as a discriminated union. */
17
- export type AccountRetrieveError = UnauthorizedError | ForbiddenError | RateLimitedError | UnexpectedApiError | TransportError | ValidationError;
17
+ export type AccountRetrieveError = UnauthorizedError | ForbiddenError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
18
18
  //# sourceMappingURL=account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/resources/account.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,QAAQ;IAC5C;;;;;;OAMG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;CAU5F;AAED,oEAAoE;AACpE,MAAM,MAAM,oBAAoB,GAC5B,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC"}
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/resources/account.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAW,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,QAAQ;IAC5C;;;;;;OAMG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;CAWhG;AAED,oEAAoE;AACpE,MAAM,MAAM,oBAAoB,GAC5B,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC"}
@@ -17,6 +17,7 @@ export class AccountResource {
17
17
  return this._core.request({
18
18
  method: "GET",
19
19
  path: "/me",
20
+ security: [{ "apiKey": [] }],
20
21
  errors: { "401": UnauthorizedError, "403": ForbiddenError, "429": RateLimitedError },
21
22
  idempotent: true,
22
23
  schemaKey: "account.retrieve",
@@ -1,7 +1,7 @@
1
1
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
2
2
  import { PagePromise } from "../core/pagination.js";
3
- import { TransportError, UnexpectedApiError, ValidationError, BadRequestError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError } from "../errors.js";
4
- import type { ApiKey } from "../types.js";
3
+ import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, BadRequestError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError } from "../errors.js";
4
+ import type { ApiKeyRead, ApiKeyResponseRead } from "../types.js";
5
5
  export declare class ApiKeysResource {
6
6
  private readonly _core;
7
7
  constructor(_core: HttpCore);
@@ -14,24 +14,29 @@ export declare class ApiKeysResource {
14
14
  * Auto-paginates: `for await (const item of …)` walks every page.
15
15
  * `GET /api_keys`
16
16
  */
17
- list(params?: ApiKeysListParams, options?: RequestOptions): PagePromise<ApiKey, ApiKeysListError>;
17
+ list(params?: ApiKeysListParams, options?: RequestOptions): PagePromise<ApiKeyRead, ApiKeysListError>;
18
18
  /**
19
19
  * Revoke an API key
20
20
  *
21
21
  * Idempotent: revoking an already-revoked key returns the same body, so a rotation script that
22
- * re-runs does not have to special-case having already succeeded.
22
+ * re-runs does not have to special-case having already succeeded. An OAuth member may revoke a
23
+ * key they created; an organization admin may revoke any key. Organization API keys retain
24
+ * account-wide authority.
23
25
  * `DELETE /api_keys/{api_key_id}`
24
26
  */
25
- revoke(apiKeyId: string, options?: RequestOptions): Promise<ApiResult<ApiKey, ApiKeysRevokeError>>;
27
+ revoke(apiKeyId: string, options?: RequestOptions): Promise<ApiResult<ApiKeyResponseRead, ApiKeysRevokeError>>;
26
28
  }
27
29
  export interface ApiKeysListParams {
28
30
  /** Maximum number of resources to return. */
29
31
  limit?: number;
30
- /** Opaque cursor from the preceding page's next_cursor. */
32
+ /**
33
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same account,
34
+ * operation, filters, and ordering that issued it.
35
+ */
31
36
  cursor?: string;
32
37
  }
33
38
  /** Every error `list` can produce, as a discriminated union. */
34
- export type ApiKeysListError = BadRequestError | UnauthorizedError | ForbiddenError | RateLimitedError | UnexpectedApiError | TransportError | ValidationError;
39
+ export type ApiKeysListError = BadRequestError | UnauthorizedError | ForbiddenError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
35
40
  /** Every error `revoke` can produce, as a discriminated union. */
36
- export type ApiKeysRevokeError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | TransportError | ValidationError;
41
+ export type ApiKeysRevokeError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
37
42
  //# sourceMappingURL=api-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAY,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAEtD,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,QAAQ;IAC5C;;;;;;;;OAQG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC;IA2BjG;;;;;;OAMG;IACG,MAAM,CAAC,QAAQ,EAAE,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O,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;CAgB9D;AAED,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GACxB,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;AAEpB,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAC1B,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC"}
@@ -20,6 +20,7 @@ export class ApiKeysResource {
20
20
  return paginate(this._core, {
21
21
  method: "GET",
22
22
  path: "/api_keys",
23
+ security: [{ "apiKey": [] }],
23
24
  query: {
24
25
  limit: params?.limit,
25
26
  cursor: params?.cursor,
@@ -46,13 +47,16 @@ export class ApiKeysResource {
46
47
  * Revoke an API key
47
48
  *
48
49
  * Idempotent: revoking an already-revoked key returns the same body, so a rotation script that
49
- * re-runs does not have to special-case having already succeeded.
50
+ * re-runs does not have to special-case having already succeeded. An OAuth member may revoke a
51
+ * key they created; an organization admin may revoke any key. Organization API keys retain
52
+ * account-wide authority.
50
53
  * `DELETE /api_keys/{api_key_id}`
51
54
  */
52
55
  async revoke(apiKeyId, options) {
53
56
  return this._core.request({
54
57
  method: "DELETE",
55
58
  path: `/api_keys/${encodeURIComponent(String(apiKeyId))}`,
59
+ security: [{ "apiKey": [] }],
56
60
  errors: {
57
61
  "401": UnauthorizedError,
58
62
  "403": ForbiddenError,
@@ -0,0 +1,58 @@
1
+ import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
2
+ import { PagePromise } from "../core/pagination.js";
3
+ import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, BadRequestError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError } from "../errors.js";
4
+ import type { DefinitionDocumentId, DefinitionId, DefinitionRevisionId, DefinitionRevisionRead, DefinitionRevisionResponseRead } from "../types.js";
5
+ export declare class DefinitionRevisionsResource {
6
+ private readonly _core;
7
+ constructor(_core: HttpCore);
8
+ /**
9
+ * List Definition Revisions
10
+ *
11
+ * Immutable snapshots of the complete resolved document graph this Definition observed, newest
12
+ * first. Content is available from the revision and document endpoints and is never embedded in a
13
+ * list response.
14
+ *
15
+ * Auto-paginates: `for await (const item of …)` walks every page.
16
+ * `GET /definitions/{definition_id}/revisions`
17
+ */
18
+ list(definitionId: DefinitionId, params?: DefinitionRevisionsListParams, options?: RequestOptions): PagePromise<DefinitionRevisionRead, DefinitionRevisionsListError>;
19
+ /**
20
+ * Retrieve a Definition Revision
21
+ *
22
+ * Metadata for one immutable resolved document graph. Fetch its canonical content or individual
23
+ * source documents from the content endpoints.
24
+ * `GET /definition_revisions/{definition_revision_id}`
25
+ */
26
+ retrieve(definitionRevisionId: DefinitionRevisionId, options?: RequestOptions): Promise<ApiResult<DefinitionRevisionResponseRead, DefinitionRevisionsRetrieveError>>;
27
+ /**
28
+ * Retrieve a Definition Revision's canonical content
29
+ *
30
+ * Returns the exact canonical resolved content identified by the revision's graph digest,
31
+ * suitable for saving or piping into a diff.
32
+ * `GET /definition_revisions/{definition_revision_id}/content`
33
+ */
34
+ retrieveContent(definitionRevisionId: DefinitionRevisionId, options?: RequestOptions): Promise<ApiResult<string, DefinitionRevisionsRetrieveContentError>>;
35
+ /**
36
+ * Retrieve one source document from a Definition Revision
37
+ * `GET /definition_revisions/{definition_revision_id}/documents/{document_id}/content`
38
+ */
39
+ retrieveDocumentContent(definitionRevisionId: DefinitionRevisionId, documentId: DefinitionDocumentId, options?: RequestOptions): Promise<ApiResult<string, DefinitionRevisionsRetrieveDocumentContentError>>;
40
+ }
41
+ export interface DefinitionRevisionsListParams {
42
+ /** Maximum number of resources to return. */
43
+ limit?: number;
44
+ /**
45
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same account,
46
+ * operation, filters, and ordering that issued it.
47
+ */
48
+ cursor?: string;
49
+ }
50
+ /** Every error `list` can produce, as a discriminated union. */
51
+ export type DefinitionRevisionsListError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
52
+ /** Every error `retrieve` can produce, as a discriminated union. */
53
+ export type DefinitionRevisionsRetrieveError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
54
+ /** Every error `retrieveContent` can produce, as a discriminated union. */
55
+ export type DefinitionRevisionsRetrieveContentError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
56
+ /** Every error `retrieveDocumentContent` can produce, as a discriminated union. */
57
+ export type DefinitionRevisionsRetrieveDocumentContentError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
58
+ //# sourceMappingURL=definition-revisions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition-revisions.d.ts","sourceRoot":"","sources":["../../src/resources/definition-revisions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAY,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EAEZ,oBAAoB,EAGpB,sBAAsB,EAEtB,8BAA8B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A2E;AAC3E,MAAM,MAAM,uCAAuC,GAC/C,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;AAEpB,mFAAmF;AACnF,MAAM,MAAM,+CAA+C,GACvD,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC"}
@@ -0,0 +1,114 @@
1
+ // typeship — definitionRevisions resource.
2
+ // Generated by typeship — https://typeship.dev — do not edit by hand.
3
+ import { paginate } from "../core/pagination.js";
4
+ import { BadRequestError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError, } from "../errors.js";
5
+ export class DefinitionRevisionsResource {
6
+ _core;
7
+ constructor(_core) {
8
+ this._core = _core;
9
+ }
10
+ /**
11
+ * List Definition Revisions
12
+ *
13
+ * Immutable snapshots of the complete resolved document graph this Definition observed, newest
14
+ * first. Content is available from the revision and document endpoints and is never embedded in a
15
+ * list response.
16
+ *
17
+ * Auto-paginates: `for await (const item of …)` walks every page.
18
+ * `GET /definitions/{definition_id}/revisions`
19
+ */
20
+ list(definitionId, params, options) {
21
+ return paginate(this._core, {
22
+ method: "GET",
23
+ path: `/definitions/${encodeURIComponent(String(definitionId))}/revisions`,
24
+ security: [{ "apiKey": [] }],
25
+ query: {
26
+ limit: params?.limit,
27
+ cursor: params?.cursor,
28
+ },
29
+ errors: {
30
+ "400": BadRequestError,
31
+ "401": UnauthorizedError,
32
+ "403": ForbiddenError,
33
+ "404": NotFoundError,
34
+ "429": RateLimitedError,
35
+ },
36
+ idempotent: true,
37
+ schemaKey: "definitionRevisions.list",
38
+ options,
39
+ }, {
40
+ style: "cursor",
41
+ itemsField: "data",
42
+ cursorParam: "cursor",
43
+ nextCursorField: "next_cursor",
44
+ hasMoreField: "has_more",
45
+ limitParam: "limit",
46
+ });
47
+ }
48
+ /**
49
+ * Retrieve a Definition Revision
50
+ *
51
+ * Metadata for one immutable resolved document graph. Fetch its canonical content or individual
52
+ * source documents from the content endpoints.
53
+ * `GET /definition_revisions/{definition_revision_id}`
54
+ */
55
+ async retrieve(definitionRevisionId, options) {
56
+ return this._core.request({
57
+ method: "GET",
58
+ path: `/definition_revisions/${encodeURIComponent(String(definitionRevisionId))}`,
59
+ security: [{ "apiKey": [] }],
60
+ errors: {
61
+ "401": UnauthorizedError,
62
+ "403": ForbiddenError,
63
+ "404": NotFoundError,
64
+ "429": RateLimitedError,
65
+ },
66
+ idempotent: true,
67
+ schemaKey: "definitionRevisions.retrieve",
68
+ options,
69
+ });
70
+ }
71
+ /**
72
+ * Retrieve a Definition Revision's canonical content
73
+ *
74
+ * Returns the exact canonical resolved content identified by the revision's graph digest,
75
+ * suitable for saving or piping into a diff.
76
+ * `GET /definition_revisions/{definition_revision_id}/content`
77
+ */
78
+ async retrieveContent(definitionRevisionId, options) {
79
+ return this._core.request({
80
+ method: "GET",
81
+ path: `/definition_revisions/${encodeURIComponent(String(definitionRevisionId))}/content`,
82
+ security: [{ "apiKey": [] }],
83
+ errors: {
84
+ "401": UnauthorizedError,
85
+ "403": ForbiddenError,
86
+ "404": NotFoundError,
87
+ "429": RateLimitedError,
88
+ },
89
+ idempotent: true,
90
+ schemaKey: "definitionRevisions.retrieveContent",
91
+ options,
92
+ });
93
+ }
94
+ /**
95
+ * Retrieve one source document from a Definition Revision
96
+ * `GET /definition_revisions/{definition_revision_id}/documents/{document_id}/content`
97
+ */
98
+ async retrieveDocumentContent(definitionRevisionId, documentId, options) {
99
+ return this._core.request({
100
+ method: "GET",
101
+ path: `/definition_revisions/${encodeURIComponent(String(definitionRevisionId))}/documents/${encodeURIComponent(String(documentId))}/content`,
102
+ security: [{ "apiKey": [] }],
103
+ errors: {
104
+ "401": UnauthorizedError,
105
+ "403": ForbiddenError,
106
+ "404": NotFoundError,
107
+ "429": RateLimitedError,
108
+ },
109
+ idempotent: true,
110
+ schemaKey: "definitionRevisions.retrieveDocumentContent",
111
+ options,
112
+ });
113
+ }
114
+ }
@@ -0,0 +1,35 @@
1
+ import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
2
+ import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, BadRequestError, ConflictError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError, UnprocessableEntityError } from "../errors.js";
3
+ import type { DefinitionId, DefinitionRead, DefinitionUpdateRequest } from "../types.js";
4
+ export declare class DefinitionsResource {
5
+ private readonly _core;
6
+ constructor(_core: HttpCore);
7
+ /**
8
+ * Retrieve a Definition
9
+ * `GET /definitions/{definition_id}`
10
+ */
11
+ retrieve(definitionId: DefinitionId, options?: RequestOptions): Promise<ApiResult<DefinitionRead, DefinitionsRetrieveError>>;
12
+ /**
13
+ * Update and resolve a Definition
14
+ *
15
+ * Resolves the complete document graph and records a new immutable revision before saving.
16
+ *
17
+ * A `Idempotency-Key` UUID is generated per call (stable across retries) unless you pass one.
18
+ * `PATCH /definitions/{definition_id}`
19
+ */
20
+ update(definitionId: DefinitionId, body: DefinitionUpdateRequest, params?: DefinitionsUpdateParams, options?: RequestOptions): Promise<ApiResult<DefinitionRead, DefinitionsUpdateError>>;
21
+ }
22
+ /** Every error `retrieve` can produce, as a discriminated union. */
23
+ export type DefinitionsRetrieveError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
24
+ export interface DefinitionsUpdateParams {
25
+ /**
26
+ * Identifies one logical write for 24 hours. The key is scoped to the authenticated account and
27
+ * operation; account-less generation uses a hashed network identity. Retrying the same method,
28
+ * path, query, and JSON body replays the original response. Reusing the key with changed intent
29
+ * returns 409. After expiry the key starts a new write.
30
+ */
31
+ idempotencyKey?: string;
32
+ }
33
+ /** Every error `update` can produce, as a discriminated union. */
34
+ export type DefinitionsUpdateError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | ConflictError | UnprocessableEntityError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
35
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/resources/definitions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAEV,YAAY,EACZ,cAAc,EACd,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAErB,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,QAAQ;IAC5C;;;OAGG;IACG,QAAQ,CACZ,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC;IAiB/D;;;;;;;OAOG;IACG,MAAM,CACV,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,uBAAuB,EAC7B,MAAM,CAAC,EAAE,uBAAuB,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;CAuB9D;AAED,oEAAoE;AACpE,MAAM,MAAM,wBAAwB,GAChC,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,kEAAkE;AAClE,MAAM,MAAM,sBAAsB,GAC9B,eAAe,GACf,iBAA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