@detergent-software/atk 8.0.2 → 8.0.3-dev.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 (281) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/commands/freeze.js +1 -1
  3. package/build/commands/freeze.js.map +1 -1
  4. package/build/commands/info.js +1 -1
  5. package/build/commands/info.js.map +1 -1
  6. package/build/commands/list.js +1 -1
  7. package/build/commands/list.js.map +1 -1
  8. package/build/commands/login.d.ts +1 -1
  9. package/build/commands/login.d.ts.map +1 -1
  10. package/build/commands/login.js +2 -4
  11. package/build/commands/login.js.map +1 -1
  12. package/build/commands/outdated.js +1 -1
  13. package/build/commands/outdated.js.map +1 -1
  14. package/build/commands/pin.js +1 -1
  15. package/build/commands/pin.js.map +1 -1
  16. package/build/commands/promote.js +1 -1
  17. package/build/commands/promote.js.map +1 -1
  18. package/build/commands/register.js +1 -1
  19. package/build/commands/register.js.map +1 -1
  20. package/build/commands/schema.d.ts +1 -1
  21. package/build/commands/schema.js +3 -3
  22. package/build/commands/schema.js.map +1 -1
  23. package/build/commands/thaw.js +1 -1
  24. package/build/commands/thaw.js.map +1 -1
  25. package/build/commands/unpin.js +1 -1
  26. package/build/commands/unpin.js.map +1 -1
  27. package/build/commands/unpublish.js +1 -1
  28. package/build/commands/unpublish.js.map +1 -1
  29. package/build/commands/whoami.d.ts.map +1 -1
  30. package/build/commands/whoami.js +2 -4
  31. package/build/commands/whoami.js.map +1 -1
  32. package/build/commands/why.js +1 -1
  33. package/build/commands/why.js.map +1 -1
  34. package/build/components/AssetDetail.d.ts +1 -1
  35. package/build/components/AssetDetail.d.ts.map +1 -1
  36. package/build/components/BrowseExpandedBundle.d.ts +2 -2
  37. package/build/components/BrowseExpandedBundle.d.ts.map +1 -1
  38. package/build/components/BrowseExpandedRow.d.ts +1 -1
  39. package/build/components/BrowseExpandedRow.d.ts.map +1 -1
  40. package/build/components/BrowseList.d.ts +1 -1
  41. package/build/components/BrowseList.d.ts.map +1 -1
  42. package/build/components/BundleDetail.d.ts +1 -1
  43. package/build/components/BundleDetail.d.ts.map +1 -1
  44. package/build/components/RegistryChangeSummary.d.ts +2 -2
  45. package/build/components/RegistryChangeSummary.d.ts.map +1 -1
  46. package/build/hooks/useBrowseState.d.ts +2 -2
  47. package/build/hooks/useBrowseState.d.ts.map +1 -1
  48. package/build/hooks/useListState.d.ts +2 -2
  49. package/build/hooks/useListState.d.ts.map +1 -1
  50. package/build/hooks/usePublishState.d.ts.map +1 -1
  51. package/build/hooks/usePublishState.js +3 -1
  52. package/build/hooks/usePublishState.js.map +1 -1
  53. package/build/hooks/useRegistryChangeState.d.ts +4 -4
  54. package/build/hooks/useRegistryChangeState.d.ts.map +1 -1
  55. package/build/lib/adapter.d.ts +1 -1
  56. package/build/lib/adapter.d.ts.map +1 -1
  57. package/build/lib/api-client.d.ts +38 -47
  58. package/build/lib/api-client.d.ts.map +1 -1
  59. package/build/lib/api-client.js +127 -173
  60. package/build/lib/api-client.js.map +1 -1
  61. package/build/lib/atk-api/client.d.ts +148 -0
  62. package/build/lib/atk-api/client.d.ts.map +1 -0
  63. package/build/lib/atk-api/client.js +336 -0
  64. package/build/lib/atk-api/client.js.map +1 -0
  65. package/build/lib/atk-api/domain.d.ts +162 -0
  66. package/build/lib/atk-api/domain.d.ts.map +1 -0
  67. package/build/lib/atk-api/domain.js +54 -0
  68. package/build/lib/atk-api/domain.js.map +1 -0
  69. package/build/lib/atk-api/errors.d.ts +142 -0
  70. package/build/lib/atk-api/errors.d.ts.map +1 -0
  71. package/build/lib/atk-api/errors.js +148 -0
  72. package/build/lib/atk-api/errors.js.map +1 -0
  73. package/build/lib/atk-api/generated/client/client.gen.d.ts +3 -0
  74. package/build/lib/atk-api/generated/client/client.gen.d.ts.map +1 -0
  75. package/build/lib/{api → atk-api/generated}/client/client.gen.js +4 -3
  76. package/build/lib/atk-api/generated/client/client.gen.js.map +1 -0
  77. package/build/lib/atk-api/generated/client/index.d.ts +11 -0
  78. package/build/lib/atk-api/generated/client/index.d.ts.map +1 -0
  79. package/build/lib/atk-api/generated/client/index.js +8 -0
  80. package/build/lib/atk-api/generated/client/index.js.map +1 -0
  81. package/build/lib/{api → atk-api/generated}/client/types.gen.d.ts +4 -4
  82. package/build/lib/atk-api/generated/client/types.gen.d.ts.map +1 -0
  83. package/build/lib/atk-api/generated/client/types.gen.js +4 -0
  84. package/build/lib/atk-api/generated/client/types.gen.js.map +1 -0
  85. package/build/lib/{api → atk-api/generated}/client/utils.gen.d.ts +2 -2
  86. package/build/lib/atk-api/generated/client/utils.gen.d.ts.map +1 -0
  87. package/build/lib/{api → atk-api/generated}/client/utils.gen.js +5 -4
  88. package/build/lib/atk-api/generated/client/utils.gen.js.map +1 -0
  89. package/build/lib/{api → atk-api/generated}/client.gen.d.ts +2 -2
  90. package/build/lib/atk-api/generated/client.gen.d.ts.map +1 -0
  91. package/build/lib/atk-api/generated/client.gen.js +5 -0
  92. package/build/lib/atk-api/generated/client.gen.js.map +1 -0
  93. package/build/lib/atk-api/generated/core/auth.gen.d.ts.map +1 -0
  94. package/build/lib/{api → atk-api/generated}/core/auth.gen.js +1 -0
  95. package/build/lib/atk-api/generated/core/auth.gen.js.map +1 -0
  96. package/build/lib/{api → atk-api/generated}/core/bodySerializer.gen.d.ts +1 -1
  97. package/build/lib/atk-api/generated/core/bodySerializer.gen.d.ts.map +1 -0
  98. package/build/lib/{api → atk-api/generated}/core/bodySerializer.gen.js +1 -0
  99. package/build/lib/atk-api/generated/core/bodySerializer.gen.js.map +1 -0
  100. package/build/lib/atk-api/generated/core/params.gen.d.ts.map +1 -0
  101. package/build/lib/{api → atk-api/generated}/core/params.gen.js +1 -0
  102. package/build/lib/atk-api/generated/core/params.gen.js.map +1 -0
  103. package/build/lib/atk-api/generated/core/pathSerializer.gen.d.ts.map +1 -0
  104. package/build/lib/{api → atk-api/generated}/core/pathSerializer.gen.js +1 -0
  105. package/build/lib/atk-api/generated/core/pathSerializer.gen.js.map +1 -0
  106. package/build/lib/atk-api/generated/core/queryKeySerializer.gen.d.ts.map +1 -0
  107. package/build/lib/{api → atk-api/generated}/core/queryKeySerializer.gen.js +1 -0
  108. package/build/lib/atk-api/generated/core/queryKeySerializer.gen.js.map +1 -0
  109. package/build/lib/{api → atk-api/generated}/core/serverSentEvents.gen.d.ts +1 -1
  110. package/build/lib/atk-api/generated/core/serverSentEvents.gen.d.ts.map +1 -0
  111. package/build/lib/{api → atk-api/generated}/core/serverSentEvents.gen.js +1 -0
  112. package/build/lib/atk-api/generated/core/serverSentEvents.gen.js.map +1 -0
  113. package/build/lib/{api → atk-api/generated}/core/types.gen.d.ts +2 -2
  114. package/build/lib/atk-api/generated/core/types.gen.d.ts.map +1 -0
  115. package/build/lib/atk-api/generated/core/types.gen.js +4 -0
  116. package/build/lib/atk-api/generated/core/types.gen.js.map +1 -0
  117. package/build/lib/{api → atk-api/generated}/core/utils.gen.d.ts +1 -1
  118. package/build/lib/atk-api/generated/core/utils.gen.d.ts.map +1 -0
  119. package/build/lib/{api → atk-api/generated}/core/utils.gen.js +2 -1
  120. package/build/lib/atk-api/generated/core/utils.gen.js.map +1 -0
  121. package/build/lib/{api → atk-api/generated}/index.d.ts +2 -2
  122. package/build/lib/atk-api/generated/index.d.ts.map +1 -0
  123. package/build/lib/atk-api/generated/index.js +4 -0
  124. package/build/lib/atk-api/generated/index.js.map +1 -0
  125. package/build/lib/{api → atk-api/generated}/sdk.gen.d.ts +6 -2
  126. package/build/lib/atk-api/generated/sdk.gen.d.ts.map +1 -0
  127. package/build/lib/{api → atk-api/generated}/sdk.gen.js +6 -1
  128. package/build/lib/atk-api/generated/sdk.gen.js.map +1 -0
  129. package/build/lib/{api → atk-api/generated}/types.gen.d.ts +27 -0
  130. package/build/lib/atk-api/generated/types.gen.d.ts.map +1 -0
  131. package/build/lib/atk-api/generated/types.gen.js +4 -0
  132. package/build/lib/atk-api/generated/types.gen.js.map +1 -0
  133. package/build/lib/atk-api/index.d.ts +29 -0
  134. package/build/lib/atk-api/index.d.ts.map +1 -0
  135. package/build/lib/atk-api/index.js +27 -0
  136. package/build/lib/atk-api/index.js.map +1 -0
  137. package/build/lib/atk-api/limits.d.ts +16 -0
  138. package/build/lib/atk-api/limits.d.ts.map +1 -0
  139. package/build/lib/atk-api/limits.js +17 -0
  140. package/build/lib/atk-api/limits.js.map +1 -0
  141. package/build/lib/atk-api/schemas/bundle.d.ts.map +1 -0
  142. package/build/lib/{schemas → atk-api/schemas}/bundle.js +2 -1
  143. package/build/lib/atk-api/schemas/bundle.js.map +1 -0
  144. package/build/lib/atk-api/schemas/index.d.ts +14 -0
  145. package/build/lib/atk-api/schemas/index.d.ts.map +1 -0
  146. package/build/lib/atk-api/schemas/index.js +15 -0
  147. package/build/lib/atk-api/schemas/index.js.map +1 -0
  148. package/build/lib/atk-api/schemas/manifest.d.ts.map +1 -0
  149. package/build/lib/{schemas → atk-api/schemas}/manifest.js +1 -0
  150. package/build/lib/atk-api/schemas/manifest.js.map +1 -0
  151. package/build/lib/atk-api/schemas/registry.d.ts.map +1 -0
  152. package/build/lib/{schemas → atk-api/schemas}/registry.js +3 -2
  153. package/build/lib/atk-api/schemas/registry.js.map +1 -0
  154. package/build/lib/atk-api/testing.d.ts +47 -0
  155. package/build/lib/atk-api/testing.d.ts.map +1 -0
  156. package/build/lib/atk-api/testing.js +88 -0
  157. package/build/lib/atk-api/testing.js.map +1 -0
  158. package/build/lib/atk-api/transport.d.ts +27 -0
  159. package/build/lib/atk-api/transport.d.ts.map +1 -0
  160. package/build/lib/atk-api/transport.js +84 -0
  161. package/build/lib/atk-api/transport.js.map +1 -0
  162. package/build/lib/atk-api/web-routes.d.ts +125 -0
  163. package/build/lib/atk-api/web-routes.d.ts.map +1 -0
  164. package/build/lib/atk-api/web-routes.js +199 -0
  165. package/build/lib/atk-api/web-routes.js.map +1 -0
  166. package/build/lib/auth.d.ts +1 -1
  167. package/build/lib/auth.d.ts.map +1 -1
  168. package/build/lib/auth.js +7 -13
  169. package/build/lib/auth.js.map +1 -1
  170. package/build/lib/config.d.ts +1 -1
  171. package/build/lib/config.d.ts.map +1 -1
  172. package/build/lib/diff-command.d.ts +1 -1
  173. package/build/lib/diff-command.d.ts.map +1 -1
  174. package/build/lib/hook-config.d.ts +1 -1
  175. package/build/lib/hook-config.d.ts.map +1 -1
  176. package/build/lib/init.d.ts +1 -1
  177. package/build/lib/init.d.ts.map +1 -1
  178. package/build/lib/init.js +2 -4
  179. package/build/lib/init.js.map +1 -1
  180. package/build/lib/lockfile.d.ts +1 -1
  181. package/build/lib/lockfile.d.ts.map +1 -1
  182. package/build/lib/manifest-diff.d.ts +2 -2
  183. package/build/lib/manifest-diff.d.ts.map +1 -1
  184. package/build/lib/manifest-diff.js +2 -2
  185. package/build/lib/manifest-diff.js.map +1 -1
  186. package/build/lib/publisher.d.ts +13 -14
  187. package/build/lib/publisher.d.ts.map +1 -1
  188. package/build/lib/publisher.js +55 -84
  189. package/build/lib/publisher.js.map +1 -1
  190. package/build/lib/registrar.d.ts +1 -1
  191. package/build/lib/registrar.d.ts.map +1 -1
  192. package/build/lib/registrar.js +1 -1
  193. package/build/lib/registrar.js.map +1 -1
  194. package/build/lib/registry-mutate.d.ts +11 -5
  195. package/build/lib/registry-mutate.d.ts.map +1 -1
  196. package/build/lib/registry-mutate.js +17 -25
  197. package/build/lib/registry-mutate.js.map +1 -1
  198. package/build/lib/registry.d.ts +6 -4
  199. package/build/lib/registry.d.ts.map +1 -1
  200. package/build/lib/registry.js +84 -101
  201. package/build/lib/registry.js.map +1 -1
  202. package/build/lib/release-notes.d.ts +1 -1
  203. package/build/lib/release-notes.d.ts.map +1 -1
  204. package/build/lib/release-notes.js +2 -4
  205. package/build/lib/release-notes.js.map +1 -1
  206. package/build/lib/resolver.d.ts +1 -1
  207. package/build/lib/resolver.d.ts.map +1 -1
  208. package/build/lib/sanitize.d.ts +1 -1
  209. package/build/lib/sanitize.d.ts.map +1 -1
  210. package/build/lib/schemas/adapter.js +1 -1
  211. package/build/lib/schemas/adapter.js.map +1 -1
  212. package/build/lib/schemas/config.js +1 -1
  213. package/build/lib/schemas/config.js.map +1 -1
  214. package/build/lib/schemas/index.d.ts +1 -3
  215. package/build/lib/schemas/index.d.ts.map +1 -1
  216. package/build/lib/schemas/index.js +2 -3
  217. package/build/lib/schemas/index.js.map +1 -1
  218. package/build/lib/schemas/lockfile.js +1 -1
  219. package/build/lib/schemas/lockfile.js.map +1 -1
  220. package/build/lib/search.d.ts +2 -2
  221. package/build/lib/search.d.ts.map +1 -1
  222. package/build/lib/search.js +1 -1
  223. package/build/lib/search.js.map +1 -1
  224. package/build/lib/sync.d.ts +1 -1
  225. package/build/lib/sync.d.ts.map +1 -1
  226. package/build/lib/updater.d.ts +2 -2
  227. package/build/lib/updater.d.ts.map +1 -1
  228. package/package.json +2 -4
  229. package/build/lib/api/client/client.gen.d.ts +0 -3
  230. package/build/lib/api/client/client.gen.d.ts.map +0 -1
  231. package/build/lib/api/client/client.gen.js.map +0 -1
  232. package/build/lib/api/client/index.d.ts +0 -11
  233. package/build/lib/api/client/index.d.ts.map +0 -1
  234. package/build/lib/api/client/index.js +0 -7
  235. package/build/lib/api/client/index.js.map +0 -1
  236. package/build/lib/api/client/types.gen.d.ts.map +0 -1
  237. package/build/lib/api/client/types.gen.js +0 -3
  238. package/build/lib/api/client/types.gen.js.map +0 -1
  239. package/build/lib/api/client/utils.gen.d.ts.map +0 -1
  240. package/build/lib/api/client/utils.gen.js.map +0 -1
  241. package/build/lib/api/client.gen.d.ts.map +0 -1
  242. package/build/lib/api/client.gen.js +0 -4
  243. package/build/lib/api/client.gen.js.map +0 -1
  244. package/build/lib/api/core/auth.gen.d.ts.map +0 -1
  245. package/build/lib/api/core/auth.gen.js.map +0 -1
  246. package/build/lib/api/core/bodySerializer.gen.d.ts.map +0 -1
  247. package/build/lib/api/core/bodySerializer.gen.js.map +0 -1
  248. package/build/lib/api/core/params.gen.d.ts.map +0 -1
  249. package/build/lib/api/core/params.gen.js.map +0 -1
  250. package/build/lib/api/core/pathSerializer.gen.d.ts.map +0 -1
  251. package/build/lib/api/core/pathSerializer.gen.js.map +0 -1
  252. package/build/lib/api/core/queryKeySerializer.gen.d.ts.map +0 -1
  253. package/build/lib/api/core/queryKeySerializer.gen.js.map +0 -1
  254. package/build/lib/api/core/serverSentEvents.gen.d.ts.map +0 -1
  255. package/build/lib/api/core/serverSentEvents.gen.js.map +0 -1
  256. package/build/lib/api/core/types.gen.d.ts.map +0 -1
  257. package/build/lib/api/core/types.gen.js +0 -3
  258. package/build/lib/api/core/types.gen.js.map +0 -1
  259. package/build/lib/api/core/utils.gen.d.ts.map +0 -1
  260. package/build/lib/api/core/utils.gen.js.map +0 -1
  261. package/build/lib/api/index.d.ts.map +0 -1
  262. package/build/lib/api/index.js +0 -3
  263. package/build/lib/api/index.js.map +0 -1
  264. package/build/lib/api/sdk.gen.d.ts.map +0 -1
  265. package/build/lib/api/sdk.gen.js.map +0 -1
  266. package/build/lib/api/types.gen.d.ts.map +0 -1
  267. package/build/lib/api/types.gen.js +0 -3
  268. package/build/lib/api/types.gen.js.map +0 -1
  269. package/build/lib/schemas/bundle.d.ts.map +0 -1
  270. package/build/lib/schemas/bundle.js.map +0 -1
  271. package/build/lib/schemas/manifest.d.ts.map +0 -1
  272. package/build/lib/schemas/manifest.js.map +0 -1
  273. package/build/lib/schemas/registry.d.ts.map +0 -1
  274. package/build/lib/schemas/registry.js.map +0 -1
  275. /package/build/lib/{api → atk-api/generated}/core/auth.gen.d.ts +0 -0
  276. /package/build/lib/{api → atk-api/generated}/core/params.gen.d.ts +0 -0
  277. /package/build/lib/{api → atk-api/generated}/core/pathSerializer.gen.d.ts +0 -0
  278. /package/build/lib/{api → atk-api/generated}/core/queryKeySerializer.gen.d.ts +0 -0
  279. /package/build/lib/{schemas → atk-api/schemas}/bundle.d.ts +0 -0
  280. /package/build/lib/{schemas → atk-api/schemas}/manifest.d.ts +0 -0
  281. /package/build/lib/{schemas → atk-api/schemas}/registry.d.ts +0 -0
@@ -1,79 +1,76 @@
1
1
  /**
2
- * Hand-written wrapper around the generated ATK API client (`src/lib/api/`).
2
+ * CLI wiring for the shared ATK API client (`./atk-api`, vendored from
3
+ * packages/api-client). Owns only what is CLI-specific:
4
+ * - base URL resolution (`ATK_API_URL` env > `apiUrl` config > production);
5
+ * - the credential chain (`getCredential`) as the client's `getToken`;
6
+ * - the Sunset-observing base fetch (deleted in step 5d);
7
+ * - the CLI's words for a failed call: {@link presentProblem} turns an
8
+ * AtkError into the message, hint and command the CLI has always shown, and
9
+ * {@link callApi} throws them as an {@link ApiRequestError}.
3
10
  *
4
- * Owns three concerns the generated code does not:
5
- * - Base URL resolution (`ATK_API_URL` env > `apiUrl` config > production).
6
- * - Wiring: bearer auth from the credential chain (`getCredential`) and
7
- * retries through {@link fetchWithRetry}; `Sunset` headers become notices.
8
- * - Error mapping: every non-2xx result becomes an {@link ApiRequestError}
9
- * with a stable `code`, an HTTP `status`, and CLI-friendly message/hint text.
10
- *
11
- * Nothing outside this module may import the generated default client in
12
- * `api/client.gen.ts`; it is generated without a base URL or auth, and an
13
- * ESLint `no-restricted-imports` rule enforces this.
11
+ * Call sites read as `await callApi('your identity', (atk) => atk.me())`.
14
12
  */
15
- import type { ApiErrorDetail } from './api/types.gen.js';
16
- import { type Client } from './api/client/index.js';
17
- export type { ApiErrorDetail } from './api/types.gen.js';
13
+ import { type AtkClient, type AtkError } from './atk-api/index.js';
18
14
  /** Production ATK API. Used when neither `ATK_API_URL` nor `apiUrl` is set. */
19
15
  export declare const DEFAULT_API_URL = "https://func-atk-prod.azurewebsites.net";
20
16
  /** Environment variable that overrides the configured API base URL. */
21
17
  export declare const API_URL_ENV_VAR = "ATK_API_URL";
22
- /** Shape of a generated SDK call result with `throwOnError: false` and `responseStyle: 'fields'`. */
23
- export interface ApiResult<T> {
24
- data?: T;
25
- error?: unknown;
26
- response?: Response;
27
- }
28
18
  /**
29
- * Thrown by {@link unwrap} for any failed ATK API call.
19
+ * Thrown by {@link callApi} for any failed ATK API call.
30
20
  *
31
21
  * `status` is the HTTP status (0 for a network failure). `code` is the API's
32
22
  * machine-readable error code (`not_found`, `version_not_bumped`, ...), or a
33
23
  * synthetic one (`network_error`, `http_error`) when the API did not send an
34
- * envelope. `details` carries per-item validation problems when present.
24
+ * envelope.
35
25
  */
36
26
  export declare class ApiRequestError extends Error {
37
27
  code: string;
38
28
  command?: string;
39
- details?: ApiErrorDetail[];
40
29
  hint?: string;
41
30
  status: number;
42
31
  constructor(message: string, options: {
43
32
  code: string;
44
33
  command?: string;
45
- details?: ApiErrorDetail[];
46
34
  hint?: string;
47
35
  status: number;
48
36
  });
49
37
  }
50
38
  /**
51
- * Build an ATK API client for a specific token (no process-wide caching).
39
+ * Run one API call, turning an AtkError into an {@link ApiRequestError}
40
+ * worded for `resource`. Anything else (an AuthError from the credential
41
+ * chain, a config error) propagates unchanged.
52
42
  *
53
- * Used where the token must be the one given rather than the resolved one,
54
- * e.g. `validateToken` in `atk doctor`.
43
+ * @param resource - Human-readable name of what was requested (used in messages)
44
+ * @param client - A specific client ({@link getAtkForToken}); the process-wide one by default
55
45
  */
56
- export declare function createApiClientForToken(token: string, baseUrl: string): Client;
46
+ export declare function callApi<T>(resource: string, call: (atk: AtkClient) => Promise<T>, client?: AtkClient): Promise<T>;
57
47
  /**
58
- * The API error code (`branch_exists`, `not_found`, ...) of a raw generated-client
59
- * `error`, or undefined when the error is not the API's envelope.
48
+ * The process-wide client. Built once: base URL from {@link resolveApiUrl},
49
+ * bearer token resolved per request through `getCredential()`.
60
50
  */
61
- export declare function errorCodeOf(error: unknown): string | undefined;
51
+ export declare function getAtk(): Promise<AtkClient>;
62
52
  /**
63
- * Get the process-wide ATK API client.
64
- *
65
- * Built once: base URL from {@link resolveApiUrl}, bearer auth resolved
66
- * lazily per request via `getCredential()`, and every request routed
67
- * through {@link fetchWithRetry}.
53
+ * A client bound to one explicit token, never the process-cached one
54
+ * (`atk login` confirming a fresh session, `atk doctor` validating a token).
68
55
  */
69
- export declare function getApiClient(): Promise<Client>;
56
+ export declare function getAtkForToken(token: string, baseUrl: string): AtkClient;
70
57
  /**
71
58
  * Type guard for {@link ApiRequestError}, optionally narrowed by API error
72
59
  * code and/or HTTP status.
73
60
  */
74
61
  export declare function isApiError(err: unknown, code?: string, status?: number): err is ApiRequestError;
75
62
  /**
76
- * Drop the memoised client so the next {@link getApiClient} call rebuilds it.
63
+ * The CLI's words for a failed call: the message (matching what the CLI
64
+ * showed before the API existed, where such a message existed), plus the hint
65
+ * and command that go with it. Exhaustive over the problem kinds.
66
+ */
67
+ export declare function presentProblem(error: AtkError, resource: string): {
68
+ command?: string;
69
+ hint?: string;
70
+ message: string;
71
+ };
72
+ /**
73
+ * Drop the memoised client so the next {@link getAtk} call rebuilds it.
77
74
  * Intended for tests and for commands that change `apiUrl` mid-process.
78
75
  */
79
76
  export declare function resetApiClient(): void;
@@ -81,17 +78,11 @@ export declare function resetApiClient(): void;
81
78
  * Resolve the ATK API base URL.
82
79
  *
83
80
  * Precedence: `ATK_API_URL` env var > `apiUrl` from `~/.atkrc.json` > production.
84
- * A trailing slash is stripped so the generated client can append paths.
81
+ * A trailing slash is stripped so paths can be appended.
85
82
  */
86
83
  export declare function resolveApiUrl(config?: {
87
84
  apiUrl?: string;
88
85
  }): string;
89
- /**
90
- * Convert a generated-client result into its `data`, or throw an
91
- * {@link ApiRequestError} describing why the call failed.
92
- *
93
- * @param result - The `{ data, error, response }` object returned by an SDK function
94
- * @param resource - Human-readable name of what was requested (used in messages)
95
- */
96
- export declare function unwrap<T>(result: ApiResult<T>, resource: string): T;
86
+ /** An AtkError as the {@link ApiRequestError} the CLI shows for `resource`. */
87
+ export declare function toApiRequestError(error: AtkError, resource: string): ApiRequestError;
97
88
  //# sourceMappingURL=api-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;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AE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAOZ;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,CAS3C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAExE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,IAAI,eAAe,CAW/F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,MAAM,GACf;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA+DtD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAIlE;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAIpF"}
@@ -1,38 +1,34 @@
1
1
  /**
2
- * Hand-written wrapper around the generated ATK API client (`src/lib/api/`).
2
+ * CLI wiring for the shared ATK API client (`./atk-api`, vendored from
3
+ * packages/api-client). Owns only what is CLI-specific:
4
+ * - base URL resolution (`ATK_API_URL` env > `apiUrl` config > production);
5
+ * - the credential chain (`getCredential`) as the client's `getToken`;
6
+ * - the Sunset-observing base fetch (deleted in step 5d);
7
+ * - the CLI's words for a failed call: {@link presentProblem} turns an
8
+ * AtkError into the message, hint and command the CLI has always shown, and
9
+ * {@link callApi} throws them as an {@link ApiRequestError}.
3
10
  *
4
- * Owns three concerns the generated code does not:
5
- * - Base URL resolution (`ATK_API_URL` env > `apiUrl` config > production).
6
- * - Wiring: bearer auth from the credential chain (`getCredential`) and
7
- * retries through {@link fetchWithRetry}; `Sunset` headers become notices.
8
- * - Error mapping: every non-2xx result becomes an {@link ApiRequestError}
9
- * with a stable `code`, an HTTP `status`, and CLI-friendly message/hint text.
10
- *
11
- * Nothing outside this module may import the generated default client in
12
- * `api/client.gen.ts`; it is generated without a base URL or auth, and an
13
- * ESLint `no-restricted-imports` rule enforces this.
11
+ * Call sites read as `await callApi('your identity', (atk) => atk.me())`.
14
12
  */
15
- import { createClient } from './api/client/index.js';
13
+ import { createAtkClient, isAtkError } from './atk-api/index.js';
16
14
  import { getCredential } from './auth.js';
17
15
  import { loadConfig } from './config.js';
18
- import { fetchWithRetry } from './fetch-retry.js';
19
16
  import { addNotice } from './notices.js';
20
17
  /** Production ATK API. Used when neither `ATK_API_URL` nor `apiUrl` is set. */
21
18
  export const DEFAULT_API_URL = 'https://func-atk-prod.azurewebsites.net';
22
19
  /** Environment variable that overrides the configured API base URL. */
23
20
  export const API_URL_ENV_VAR = 'ATK_API_URL';
24
21
  /**
25
- * Thrown by {@link unwrap} for any failed ATK API call.
22
+ * Thrown by {@link callApi} for any failed ATK API call.
26
23
  *
27
24
  * `status` is the HTTP status (0 for a network failure). `code` is the API's
28
25
  * machine-readable error code (`not_found`, `version_not_bumped`, ...), or a
29
26
  * synthetic one (`network_error`, `http_error`) when the API did not send an
30
- * envelope. `details` carries per-item validation problems when present.
27
+ * envelope.
31
28
  */
32
29
  export class ApiRequestError extends Error {
33
30
  code;
34
31
  command;
35
- details;
36
32
  hint;
37
33
  status;
38
34
  constructor(message, options) {
@@ -40,7 +36,6 @@ export class ApiRequestError extends Error {
40
36
  this.name = 'ApiRequestError';
41
37
  this.status = options.status;
42
38
  this.code = options.code;
43
- this.details = options.details;
44
39
  this.hint = options.hint;
45
40
  this.command = options.command;
46
41
  }
@@ -54,43 +49,49 @@ const NOT_MEMBER_HINT = 'Ask an org admin to add you, or re-authorise your token
54
49
  const UNAVAILABLE_HINT = 'The registry may be temporarily unavailable. Retry in a moment.';
55
50
  const AMBIGUOUS_NAME_HINT = 'Pass `--type <type>` (or `--type bundle`) to choose one.';
56
51
  const REGISTRY_CHANGED_HINT = 'The registry changed while the pull request was being prepared. Retry the command.';
57
- /** Error codes whose `details` list the items the message refers to (one per line). */
58
- const LISTING_CODES = new Set(['ambiguous_name', 'bundle_scope_invalid', 'referenced_by_bundles']);
59
- let clientPromise;
52
+ /** `ApiRequestError.code` for problems the client made itself (no API code to carry). */
53
+ const SYNTHETIC_CODES = {
54
+ invalid_input: 'invalid_input',
55
+ network: 'network_error',
56
+ unexpected_response: 'unexpected_response',
57
+ };
58
+ let atkPromise;
60
59
  /**
61
- * Build an ATK API client for a specific token (no process-wide caching).
60
+ * Run one API call, turning an AtkError into an {@link ApiRequestError}
61
+ * worded for `resource`. Anything else (an AuthError from the credential
62
+ * chain, a config error) propagates unchanged.
62
63
  *
63
- * Used where the token must be the one given rather than the resolved one,
64
- * e.g. `validateToken` in `atk doctor`.
64
+ * @param resource - Human-readable name of what was requested (used in messages)
65
+ * @param client - A specific client ({@link getAtkForToken}); the process-wide one by default
65
66
  */
66
- export function createApiClientForToken(token, baseUrl) {
67
- return createClient({
68
- auth: () => token,
69
- baseUrl,
70
- fetch: observingFetch,
71
- throwOnError: false,
72
- });
67
+ export async function callApi(resource, call, client) {
68
+ const atk = client ?? (await getAtk());
69
+ try {
70
+ return await call(atk);
71
+ }
72
+ catch (err) {
73
+ throw isAtkError(err) ? toApiRequestError(err, resource) : err;
74
+ }
73
75
  }
74
76
  /**
75
- * The API error code (`branch_exists`, `not_found`, ...) of a raw generated-client
76
- * `error`, or undefined when the error is not the API's envelope.
77
+ * The process-wide client. Built once: base URL from {@link resolveApiUrl},
78
+ * bearer token resolved per request through `getCredential()`.
77
79
  */
78
- export function errorCodeOf(error) {
79
- if (typeof error === 'object' && error !== null && typeof error.error === 'string') {
80
- return error.error;
81
- }
82
- return undefined;
80
+ export function getAtk() {
81
+ atkPromise ??= (async () => createAtkClient({
82
+ app: 'cli',
83
+ baseUrl: resolveApiUrl(await loadConfig()),
84
+ fetch: observingFetch,
85
+ getToken: async () => (await getCredential()).token,
86
+ }))();
87
+ return atkPromise;
83
88
  }
84
89
  /**
85
- * Get the process-wide ATK API client.
86
- *
87
- * Built once: base URL from {@link resolveApiUrl}, bearer auth resolved
88
- * lazily per request via `getCredential()`, and every request routed
89
- * through {@link fetchWithRetry}.
90
+ * A client bound to one explicit token, never the process-cached one
91
+ * (`atk login` confirming a fresh session, `atk doctor` validating a token).
90
92
  */
91
- export function getApiClient() {
92
- clientPromise ??= buildClient();
93
- return clientPromise;
93
+ export function getAtkForToken(token, baseUrl) {
94
+ return createAtkClient({ app: 'cli', baseUrl, fetch: observingFetch, getToken: async () => token });
94
95
  }
95
96
  /**
96
97
  * Type guard for {@link ApiRequestError}, optionally narrowed by API error
@@ -109,59 +110,96 @@ export function isApiError(err, code, status) {
109
110
  return true;
110
111
  }
111
112
  /**
112
- * Drop the memoised client so the next {@link getApiClient} call rebuilds it.
113
+ * The CLI's words for a failed call: the message (matching what the CLI
114
+ * showed before the API existed, where such a message existed), plus the hint
115
+ * and command that go with it. Exhaustive over the problem kinds.
116
+ */
117
+ export function presentProblem(error, resource) {
118
+ const { apiCode, apiMessage, problem, status } = error;
119
+ const fallback = { message: apiMessage ?? `Failed to fetch ${resource}: HTTP ${status}` };
120
+ const listing = (lines) => [apiMessage, ...lines.map((line) => ` - ${line}`)].join('\n');
121
+ switch (problem.kind) {
122
+ case 'ambiguous':
123
+ return apiMessage ? { hint: AMBIGUOUS_NAME_HINT, message: listing(problem.candidates) } : fallback;
124
+ case 'auth_retired':
125
+ // The API's message names the date and the upgrade path; show it as-is.
126
+ return apiMessage
127
+ ? { command: AUTH_COMMAND, message: apiMessage }
128
+ : { command: AUTH_COMMAND, hint: AUTH_HINT, message: AUTH_MESSAGE };
129
+ case 'conflict':
130
+ if ((problem.code === 'referenced_by_bundles' || problem.code === 'bundle_scope_invalid') && apiMessage) {
131
+ return { message: listing(problem.items) };
132
+ }
133
+ if (problem.code === 'registry_changed') {
134
+ return { hint: REGISTRY_CHANGED_HINT, message: apiMessage ?? 'The registry changed.' };
135
+ }
136
+ return fallback;
137
+ case 'forbidden':
138
+ if (problem.code === 'not_org_member' || problem.code === 'org_membership_unverifiable') {
139
+ return { hint: NOT_MEMBER_HINT, message: NOT_MEMBER_MESSAGE };
140
+ }
141
+ if (problem.code === 'guest_not_allowed' && apiMessage) {
142
+ return { hint: GUEST_HINT, message: apiMessage };
143
+ }
144
+ return { message: apiMessage ?? `Access denied while fetching ${resource}.` };
145
+ case 'invalid':
146
+ if ((problem.code === 'validation_failed' || problem.code === 'schema_invalid') && problem.issues.length > 0) {
147
+ const lines = problem.issues.map((issue) => ` ${issue.path ?? '-'}: ${issue.message}`);
148
+ return { message: [apiMessage ?? 'Validation failed.', ...lines].join('\n') };
149
+ }
150
+ return fallback;
151
+ case 'invalid_input':
152
+ return { message: problem.message };
153
+ case 'network':
154
+ return { hint: 'Check your internet connection.', message: `Failed to fetch ${resource}: ${problem.message}` };
155
+ case 'not_found':
156
+ return { message: apiMessage ?? `${resource} not found.` };
157
+ case 'rate_limited':
158
+ return {
159
+ hint: 'Wait a minute and retry.',
160
+ message: apiMessage ?? 'Too many requests to the ATK API. Try again later.',
161
+ };
162
+ case 'server_error':
163
+ case 'unavailable': {
164
+ if (status < 500) {
165
+ return fallback;
166
+ }
167
+ const detail = apiMessage ? ` (${apiCode ?? 'http_error'}: ${apiMessage})` : '';
168
+ return { hint: UNAVAILABLE_HINT, message: `Failed to fetch ${resource}: HTTP ${status}${detail}` };
169
+ }
170
+ case 'unauthenticated':
171
+ return { command: AUTH_COMMAND, hint: AUTH_HINT, message: AUTH_MESSAGE };
172
+ case 'unexpected_response':
173
+ return { message: `Unexpected response for ${resource}: ${problem.message}` };
174
+ default: {
175
+ const unhandled = problem;
176
+ return unhandled;
177
+ }
178
+ }
179
+ }
180
+ /**
181
+ * Drop the memoised client so the next {@link getAtk} call rebuilds it.
113
182
  * Intended for tests and for commands that change `apiUrl` mid-process.
114
183
  */
115
184
  export function resetApiClient() {
116
- clientPromise = undefined;
185
+ atkPromise = undefined;
117
186
  }
118
187
  /**
119
188
  * Resolve the ATK API base URL.
120
189
  *
121
190
  * Precedence: `ATK_API_URL` env var > `apiUrl` from `~/.atkrc.json` > production.
122
- * A trailing slash is stripped so the generated client can append paths.
191
+ * A trailing slash is stripped so paths can be appended.
123
192
  */
124
193
  export function resolveApiUrl(config) {
125
194
  const envUrl = process.env[API_URL_ENV_VAR]?.trim();
126
195
  const raw = envUrl || config?.apiUrl?.trim() || DEFAULT_API_URL;
127
196
  return raw.replace(/\/+$/, '');
128
197
  }
129
- /**
130
- * Convert a generated-client result into its `data`, or throw an
131
- * {@link ApiRequestError} describing why the call failed.
132
- *
133
- * @param result - The `{ data, error, response }` object returned by an SDK function
134
- * @param resource - Human-readable name of what was requested (used in messages)
135
- */
136
- export function unwrap(result, resource) {
137
- const { data, error, response } = result;
138
- if (response === undefined) {
139
- // The client's auth hook (getCredential) threw before any request was
140
- // sent: surface it as the auth problem it is, hint and command intact.
141
- if (isAuthError(error)) {
142
- throw error;
143
- }
144
- // The fetch itself threw (DNS, connection refused, abort, ...).
145
- const cause = error instanceof Error ? error.message : error ? String(error) : 'Network request failed';
146
- throw new ApiRequestError(`Failed to fetch ${resource}: ${cause}`, {
147
- code: 'network_error',
148
- hint: 'Check your internet connection.',
149
- status: 0,
150
- });
151
- }
152
- if (response.ok && error === undefined) {
153
- return data;
154
- }
155
- throw toApiRequestError(response.status, error, resource);
156
- }
157
- async function buildClient() {
158
- const config = await loadConfig();
159
- return createClient({
160
- auth: async () => (await getCredential()).token,
161
- baseUrl: resolveApiUrl(config),
162
- fetch: observingFetch,
163
- throwOnError: false,
164
- });
198
+ /** An AtkError as the {@link ApiRequestError} the CLI shows for `resource`. */
199
+ export function toApiRequestError(error, resource) {
200
+ const { message, ...guidance } = presentProblem(error, resource);
201
+ const code = error.apiCode ?? SYNTHETIC_CODES[error.problem.kind] ?? 'http_error';
202
+ return new ApiRequestError(message, { code, ...guidance, status: error.status });
165
203
  }
166
204
  /** `Sunset` is an HTTP-date; show it as `YYYY-MM-DD`, or verbatim if unparseable. */
167
205
  function formatSunsetDate(headerValue) {
@@ -169,101 +207,17 @@ function formatSunsetDate(headerValue) {
169
207
  return Number.isNaN(parsed.getTime()) ? headerValue : parsed.toISOString().slice(0, 10);
170
208
  }
171
209
  /**
172
- * Recognise an {@link AuthError} by name rather than by `instanceof` so the
173
- * check holds even when `./auth.js` is module-mocked (as most command tests do).
174
- */
175
- function isAuthError(err) {
176
- return err instanceof Error && err.name === 'AuthError';
177
- }
178
- function isErrorEnvelope(value) {
179
- return (typeof value === 'object' &&
180
- value !== null &&
181
- typeof value.error === 'string' &&
182
- typeof value.message === 'string');
183
- }
184
- /**
185
- * {@link fetchWithRetry} plus response observation: a `Sunset` header (sent
186
- * on GitHub-authenticated requests while a GitHub sign-in cutoff is
187
- * scheduled) records a once-per-run notice for the App shell.
210
+ * The client's base fetch: `globalThis.fetch` (looked up per request) plus
211
+ * response observation. A `Sunset` header (sent on GitHub-authenticated
212
+ * requests while a GitHub sign-in cutoff is scheduled) records a once-per-run
213
+ * notice for the App shell. It must not retry: the client retries around it.
188
214
  */
189
215
  async function observingFetch(input, init) {
190
- const response = await fetchWithRetry(input, init);
216
+ const response = await globalThis.fetch(input, init);
191
217
  const sunset = response.headers.get('Sunset');
192
218
  if (sunset) {
193
219
  addNotice({ date: formatSunsetDate(sunset), kind: 'github-sunset' });
194
220
  }
195
221
  return response;
196
222
  }
197
- /**
198
- * Map an HTTP status plus the API's error envelope (when present) to an
199
- * {@link ApiRequestError} whose message matches what the CLI showed before
200
- * the API existed, where such a message existed.
201
- */
202
- function toApiRequestError(status, error, resource) {
203
- const envelope = isErrorEnvelope(error) ? error : undefined;
204
- const code = envelope?.error ?? 'http_error';
205
- const apiMessage = envelope?.message ?? (typeof error === 'string' && error ? error : undefined);
206
- const details = envelope?.details ?? undefined;
207
- if (status === 401) {
208
- if (code === 'github_auth_retired' && apiMessage) {
209
- // The API's message names the date and the upgrade path; show it as-is.
210
- return new ApiRequestError(apiMessage, { code, command: AUTH_COMMAND, status });
211
- }
212
- return new ApiRequestError(AUTH_MESSAGE, { code, command: AUTH_COMMAND, hint: AUTH_HINT, status });
213
- }
214
- if (status === 403) {
215
- if (code === 'not_org_member' || code === 'org_membership_unverifiable') {
216
- return new ApiRequestError(NOT_MEMBER_MESSAGE, { code, hint: NOT_MEMBER_HINT, status });
217
- }
218
- if (code === 'guest_not_allowed' && apiMessage) {
219
- return new ApiRequestError(apiMessage, { code, hint: GUEST_HINT, status });
220
- }
221
- return new ApiRequestError(apiMessage ?? `Access denied while fetching ${resource}.`, { code, status });
222
- }
223
- if (status === 404) {
224
- return new ApiRequestError(apiMessage ?? `${resource} not found.`, { code, status });
225
- }
226
- if (status === 429) {
227
- return new ApiRequestError(apiMessage ?? 'Too many requests to the ATK API. Try again later.', {
228
- code,
229
- hint: 'Wait a minute and retry.',
230
- status,
231
- });
232
- }
233
- if (status === 400 && (code === 'validation_failed' || code === 'schema_invalid') && details?.length) {
234
- const lines = details.map((d) => ` ${d.path ?? '-'}: ${d.message}`);
235
- return new ApiRequestError([apiMessage ?? 'Validation failed.', ...lines].join('\n'), { code, details, status });
236
- }
237
- if (LISTING_CODES.has(code) && apiMessage) {
238
- // The message is one sentence; the candidates / bundles / refs are in details.
239
- const lines = (details ?? []).map((d) => ` - ${d.message}`);
240
- return new ApiRequestError([apiMessage, ...lines].join('\n'), {
241
- code,
242
- details,
243
- ...(code === 'ambiguous_name' ? { hint: AMBIGUOUS_NAME_HINT } : {}),
244
- status,
245
- });
246
- }
247
- if (code === 'registry_changed') {
248
- return new ApiRequestError(apiMessage ?? 'The registry changed.', {
249
- code,
250
- hint: REGISTRY_CHANGED_HINT,
251
- status,
252
- });
253
- }
254
- if (status >= 500) {
255
- const detail = apiMessage ? ` (${code}: ${apiMessage})` : '';
256
- return new ApiRequestError(`Failed to fetch ${resource}: HTTP ${status}${detail}`, {
257
- code,
258
- hint: UNAVAILABLE_HINT,
259
- status,
260
- });
261
- }
262
- // 400/409 and anything else: the API message is the best text we have.
263
- return new ApiRequestError(apiMessage ?? `Failed to fetch ${resource}: HTTP ${status}`, {
264
- code,
265
- details,
266
- status,
267
- });
268
- }
269
223
  //# sourceMappingURL=api-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAe,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,yCAAyC,CAAC;AAEzE,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAgB7C;;;;;;;GAOG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,IAAI,CAAS;IACb,OAAO,CAAU;IACjB,OAAO,CAAoB;IAC3B,IAAI,CAAU;IACd,MAAM,CAAS;IAEf,YACE,OAAe,EACf,OAAsG;QAEtG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OA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