@huawei-iac-tools/landingzone-workbench 0.0.0-stage → 0.0.2

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 (246) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +85 -2
  3. package/cordis.patch.yml +21 -0
  4. package/knowledge/account-qualification.md +128 -0
  5. package/knowledge/blueprints/_base/blueprint.json +481 -0
  6. package/knowledge/blueprints/_base/defaults.json +127 -0
  7. package/knowledge/blueprints/foundation-lz/blueprint.json +43 -0
  8. package/knowledge/blueprints/foundation-lz/defaults.json +47 -0
  9. package/knowledge/blueprints/full-lz/blueprint.json +11 -0
  10. package/knowledge/blueprints/full-lz/defaults.json +8 -0
  11. package/knowledge/config.json +43 -0
  12. package/knowledge/error-rules.json +14 -0
  13. package/knowledge/ic-policies.json +21 -0
  14. package/knowledge/modules/account-structure.md +101 -0
  15. package/knowledge/modules/compliance/config-rms.md +212 -0
  16. package/knowledge/modules/compliance/cts.md +179 -0
  17. package/knowledge/modules/compliance/obs-lts.md +155 -0
  18. package/knowledge/modules/ic-policies.json +21 -0
  19. package/knowledge/modules/identity-center.md +603 -0
  20. package/knowledge/modules/module-layers.md +169 -0
  21. package/knowledge/modules/network/er.md +222 -0
  22. package/knowledge/modules/network/nat-eip.md +123 -0
  23. package/knowledge/modules/network/ram-share.md +92 -0
  24. package/knowledge/modules/network/vpc-subnet.md +142 -0
  25. package/knowledge/modules/organization-security/scp.md +122 -0
  26. package/knowledge/modules/organizations.md +212 -0
  27. package/knowledge/modules/recommended-config.md +157 -0
  28. package/knowledge/modules/recommended-rules.json +175 -0
  29. package/knowledge/modules/scp-policies.json +111 -0
  30. package/knowledge/modules/security/aad.md +94 -0
  31. package/knowledge/modules/security/cfw.md +105 -0
  32. package/knowledge/modules/security/waf.md +110 -0
  33. package/knowledge/param-mappings.json +133 -0
  34. package/knowledge/prompts.md +83 -0
  35. package/knowledge/resource-types.json +1162 -0
  36. package/knowledge/scp-policies.json +111 -0
  37. package/knowledge/state-machine.md +33 -0
  38. package/lib/client.js +21 -0
  39. package/lib/index.js +28592 -0
  40. package/lib/types/account-role.d.ts +19 -0
  41. package/lib/types/account-scope.d.ts +10 -0
  42. package/lib/types/agency.d.ts +38 -0
  43. package/lib/types/client/DropdownSelect.d.ts +49 -0
  44. package/lib/types/client/LoginGate.d.ts +20 -0
  45. package/lib/types/client/PanelIcon.d.ts +11 -0
  46. package/lib/types/client/WorkbenchShell.d.ts +21 -0
  47. package/lib/types/client/account-role.d.ts +15 -0
  48. package/lib/types/client/credential-status.d.ts +15 -0
  49. package/lib/types/client/huawei-mark.d.ts +37 -0
  50. package/lib/types/client/index.d.ts +26 -0
  51. package/lib/types/client/layout-ref.d.ts +23 -0
  52. package/lib/types/client/pages/ConfigPage/AdviceCard.d.ts +26 -0
  53. package/lib/types/client/pages/ConfigPage/AuditBar.d.ts +21 -0
  54. package/lib/types/client/pages/ConfigPage/ChangeSummaryCard.d.ts +22 -0
  55. package/lib/types/client/pages/ConfigPage/ChangesCard.d.ts +27 -0
  56. package/lib/types/client/pages/ConfigPage/ComplianceDetail.d.ts +25 -0
  57. package/lib/types/client/pages/ConfigPage/ComplianceSummaryCard.d.ts +31 -0
  58. package/lib/types/client/pages/ConfigPage/FindingsCard.d.ts +21 -0
  59. package/lib/types/client/pages/ConfigPage/GlossaryDrawer.d.ts +17 -0
  60. package/lib/types/client/pages/ConfigPage/OrgComplianceDetail.d.ts +15 -0
  61. package/lib/types/client/pages/ConfigPage/Pager.d.ts +32 -0
  62. package/lib/types/client/pages/ConfigPage/ResourceDrawer.d.ts +26 -0
  63. package/lib/types/client/pages/ConfigPage/ResourcesTable.d.ts +35 -0
  64. package/lib/types/client/pages/ConfigPage/RollupPanel.d.ts +17 -0
  65. package/lib/types/client/pages/ConfigPage/RuleDetailDrawer.d.ts +23 -0
  66. package/lib/types/client/pages/ConfigPage/StatusCards.d.ts +26 -0
  67. package/lib/types/client/pages/ConfigPage/UncoveredDialog.d.ts +22 -0
  68. package/lib/types/client/pages/ConfigPage/config-api.d.ts +101 -0
  69. package/lib/types/client/pages/ConfigPage/config-store.d.ts +57 -0
  70. package/lib/types/client/pages/ConfigPage/index.d.ts +21 -0
  71. package/lib/types/client/pages/ConfigPage/paging.d.ts +46 -0
  72. package/lib/types/client/pages/ConfigPage/scope-options.d.ts +51 -0
  73. package/lib/types/client/pages/CostPage/AccountAllocation.d.ts +24 -0
  74. package/lib/types/client/pages/CostPage/AccountBars.d.ts +20 -0
  75. package/lib/types/client/pages/CostPage/AccountColumns.d.ts +24 -0
  76. package/lib/types/client/pages/CostPage/AccountDonut.d.ts +18 -0
  77. package/lib/types/client/pages/CostPage/AccountSwitcher.d.ts +25 -0
  78. package/lib/types/client/pages/CostPage/AdviceCard.d.ts +43 -0
  79. package/lib/types/client/pages/CostPage/AdviceFindings.d.ts +43 -0
  80. package/lib/types/client/pages/CostPage/BillingPanels.d.ts +23 -0
  81. package/lib/types/client/pages/CostPage/BudgetCard.d.ts +36 -0
  82. package/lib/types/client/pages/CostPage/GlossaryDrawer.d.ts +16 -0
  83. package/lib/types/client/pages/CostPage/KpiRow.d.ts +23 -0
  84. package/lib/types/client/pages/CostPage/MarkdownBlock.d.ts +16 -0
  85. package/lib/types/client/pages/CostPage/ReportView.d.ts +17 -0
  86. package/lib/types/client/pages/CostPage/ResourceColumns.d.ts +19 -0
  87. package/lib/types/client/pages/CostPage/ResourceDonut.d.ts +18 -0
  88. package/lib/types/client/pages/CostPage/ResourcesCard.d.ts +40 -0
  89. package/lib/types/client/pages/CostPage/RuleDetailDrawer.d.ts +23 -0
  90. package/lib/types/client/pages/CostPage/SavingView.d.ts +38 -0
  91. package/lib/types/client/pages/CostPage/ServiceDonut.d.ts +17 -0
  92. package/lib/types/client/pages/CostPage/TrendChart.d.ts +24 -0
  93. package/lib/types/client/pages/CostPage/budget-input.d.ts +30 -0
  94. package/lib/types/client/pages/CostPage/cost-api.d.ts +266 -0
  95. package/lib/types/client/pages/CostPage/cost-store.d.ts +25 -0
  96. package/lib/types/client/pages/CostPage/format.d.ts +37 -0
  97. package/lib/types/client/pages/CostPage/index.d.ts +34 -0
  98. package/lib/types/client/pages/CostPage/trend-fold.d.ts +32 -0
  99. package/lib/types/client/pages/CostPage/useEcharts.d.ts +70 -0
  100. package/lib/types/client/pages/OrgStructurePage/AccountStatsCard.d.ts +22 -0
  101. package/lib/types/client/pages/OrgStructurePage/CoreAccountsCard.d.ts +18 -0
  102. package/lib/types/client/pages/OrgStructurePage/CreateAccountDialog.d.ts +28 -0
  103. package/lib/types/client/pages/OrgStructurePage/ManageUsersDialog.d.ts +28 -0
  104. package/lib/types/client/pages/OrgStructurePage/MemberAccountsTable.d.ts +32 -0
  105. package/lib/types/client/pages/OrgStructurePage/MoveAccountDialog.d.ts +29 -0
  106. package/lib/types/client/pages/OrgStructurePage/OrgGlossaryDrawer.d.ts +13 -0
  107. package/lib/types/client/pages/OrgStructurePage/OrgTreeCard.d.ts +31 -0
  108. package/lib/types/client/pages/OrgStructurePage/index.d.ts +21 -0
  109. package/lib/types/client/pages/OrgStructurePage/org-api.d.ts +166 -0
  110. package/lib/types/client/pages/OverviewPage/AnchorRow.d.ts +24 -0
  111. package/lib/types/client/pages/OverviewPage/AttentionList.d.ts +29 -0
  112. package/lib/types/client/pages/OverviewPage/OverviewCharts.d.ts +79 -0
  113. package/lib/types/client/pages/OverviewPage/OverviewGlossaryDrawer.d.ts +15 -0
  114. package/lib/types/client/pages/OverviewPage/index.d.ts +22 -0
  115. package/lib/types/client/pages/OverviewPage/overview-api.d.ts +115 -0
  116. package/lib/types/client/pages/ResourcePage/AccountResourceList.d.ts +21 -0
  117. package/lib/types/client/pages/ResourcePage/components/GlossaryDrawer.d.ts +20 -0
  118. package/lib/types/client/pages/ResourcePage/components/MetricCards.d.ts +19 -0
  119. package/lib/types/client/pages/ResourcePage/components/MultiSelect.d.ts +27 -0
  120. package/lib/types/client/pages/ResourcePage/components/PanelPager.d.ts +26 -0
  121. package/lib/types/client/pages/ResourcePage/components/RankBars.d.ts +25 -0
  122. package/lib/types/client/pages/ResourcePage/components/ScopeSelect.d.ts +27 -0
  123. package/lib/types/client/pages/ResourcePage/components/SourceConfigModal.d.ts +21 -0
  124. package/lib/types/client/pages/ResourcePage/components/SyncControls.d.ts +18 -0
  125. package/lib/types/client/pages/ResourcePage/components/TrendChart.d.ts +14 -0
  126. package/lib/types/client/pages/ResourcePage/components/useColumnWidths.d.ts +12 -0
  127. package/lib/types/client/pages/ResourcePage/format.d.ts +9 -0
  128. package/lib/types/client/pages/ResourcePage/index.d.ts +20 -0
  129. package/lib/types/client/pages/ResourcePage/summary-api.d.ts +205 -0
  130. package/lib/types/client/pages/SetupPage/AskPanel.d.ts +21 -0
  131. package/lib/types/client/pages/SetupPage/ChatEmbed.d.ts +40 -0
  132. package/lib/types/client/pages/SetupPage/ChatTab.d.ts +17 -0
  133. package/lib/types/client/pages/SetupPage/FormTab.d.ts +12 -0
  134. package/lib/types/client/pages/SetupPage/FormTabV2.d.ts +14 -0
  135. package/lib/types/client/pages/SetupPage/ProgressTreeView.d.ts +15 -0
  136. package/lib/types/client/pages/SetupPage/StageFlow.d.ts +16 -0
  137. package/lib/types/client/pages/SetupPage/index.d.ts +10 -0
  138. package/lib/types/client/pages/SetupPage/progress-types.d.ts +36 -0
  139. package/lib/types/client/pages/SetupPage/session-binding.d.ts +38 -0
  140. package/lib/types/client/pages/SetupPage/session-store.d.ts +57 -0
  141. package/lib/types/client/pages/SetupPage/sessions-ref.d.ts +5 -0
  142. package/lib/types/client/pages/SetupPage/setup-replan.d.ts +13 -0
  143. package/lib/types/client/pages/SetupPage/wb-api.d.ts +192 -0
  144. package/lib/types/client/pages/list-preview.d.ts +36 -0
  145. package/lib/types/client/permission-mode.d.ts +53 -0
  146. package/lib/types/client/store.d.ts +22 -0
  147. package/lib/types/collect.d.ts +78 -0
  148. package/lib/types/config/account-scope.d.ts +61 -0
  149. package/lib/types/config/advice-findings.d.ts +31 -0
  150. package/lib/types/config/advice-prompt.d.ts +60 -0
  151. package/lib/types/config/advice.d.ts +116 -0
  152. package/lib/types/config/cts.d.ts +30 -0
  153. package/lib/types/config/evidence/rules.d.ts +31 -0
  154. package/lib/types/config/evidence/types.d.ts +103 -0
  155. package/lib/types/config/failure-note.d.ts +46 -0
  156. package/lib/types/config/fingerprint-cache.d.ts +45 -0
  157. package/lib/types/config/identity.d.ts +67 -0
  158. package/lib/types/config/query.d.ts +49 -0
  159. package/lib/types/config/rms.d.ts +412 -0
  160. package/lib/types/config/routes.d.ts +32 -0
  161. package/lib/types/config/types.d.ts +785 -0
  162. package/lib/types/config/views.d.ts +158 -0
  163. package/lib/types/cost/accounts.d.ts +29 -0
  164. package/lib/types/cost/advice-findings.d.ts +77 -0
  165. package/lib/types/cost/advice-model.d.ts +19 -0
  166. package/lib/types/cost/advice-prompt.d.ts +73 -0
  167. package/lib/types/cost/advice-subagent-types.d.ts +6 -0
  168. package/lib/types/cost/advice-subagent.d.ts +116 -0
  169. package/lib/types/cost/advice-types.d.ts +63 -0
  170. package/lib/types/cost/advice.d.ts +125 -0
  171. package/lib/types/cost/aggregate.d.ts +157 -0
  172. package/lib/types/cost/assume.d.ts +43 -0
  173. package/lib/types/cost/bss.d.ts +166 -0
  174. package/lib/types/cost/budget-overview.d.ts +38 -0
  175. package/lib/types/cost/budget.d.ts +56 -0
  176. package/lib/types/cost/cache.d.ts +58 -0
  177. package/lib/types/cost/caliber.d.ts +40 -0
  178. package/lib/types/cost/console-links.d.ts +27 -0
  179. package/lib/types/cost/credentials.d.ts +38 -0
  180. package/lib/types/cost/data-window.d.ts +38 -0
  181. package/lib/types/cost/evidence/catalog.d.ts +35 -0
  182. package/lib/types/cost/evidence/index.d.ts +70 -0
  183. package/lib/types/cost/evidence/inventory.d.ts +44 -0
  184. package/lib/types/cost/evidence/pricing.d.ts +72 -0
  185. package/lib/types/cost/evidence/projects.d.ts +18 -0
  186. package/lib/types/cost/evidence/rules.d.ts +66 -0
  187. package/lib/types/cost/evidence/state.d.ts +38 -0
  188. package/lib/types/cost/evidence/thresholds.d.ts +68 -0
  189. package/lib/types/cost/evidence/types.d.ts +288 -0
  190. package/lib/types/cost/evidence/utilization.d.ts +37 -0
  191. package/lib/types/cost/history.d.ts +36 -0
  192. package/lib/types/cost/ledger.d.ts +97 -0
  193. package/lib/types/cost/normalize.d.ts +37 -0
  194. package/lib/types/cost/period-projection.d.ts +57 -0
  195. package/lib/types/cost/plan-check.d.ts +102 -0
  196. package/lib/types/cost/plan-db.d.ts +73 -0
  197. package/lib/types/cost/plan-types.d.ts +183 -0
  198. package/lib/types/cost/plan.d.ts +63 -0
  199. package/lib/types/cost/quote.d.ts +45 -0
  200. package/lib/types/cost/report.d.ts +136 -0
  201. package/lib/types/cost/resources.d.ts +108 -0
  202. package/lib/types/cost/routes.d.ts +38 -0
  203. package/lib/types/cost/scope.d.ts +42 -0
  204. package/lib/types/cost/types.d.ts +335 -0
  205. package/lib/types/cost/unit-prices-derive.d.ts +19 -0
  206. package/lib/types/cost/unit-prices.d.ts +23 -0
  207. package/lib/types/db.d.ts +228 -0
  208. package/lib/types/host-log.d.ts +7 -0
  209. package/lib/types/http.d.ts +42 -0
  210. package/lib/types/index.d.ts +30 -0
  211. package/lib/types/inventory.d.ts +286 -0
  212. package/lib/types/obs.d.ts +16 -0
  213. package/lib/types/org/aggregate.d.ts +36 -0
  214. package/lib/types/org/churn.d.ts +10 -0
  215. package/lib/types/org/orgs.d.ts +258 -0
  216. package/lib/types/org/routes.d.ts +28 -0
  217. package/lib/types/org-types.d.ts +156 -0
  218. package/lib/types/per-service.d.ts +39 -0
  219. package/lib/types/setup/blueprint-loader.d.ts +81 -0
  220. package/lib/types/setup/caller.d.ts +105 -0
  221. package/lib/types/setup/engine.d.ts +41 -0
  222. package/lib/types/setup/form-store.d.ts +13 -0
  223. package/lib/types/setup/nodes/n1-check.d.ts +14 -0
  224. package/lib/types/setup/nodes/n10-governance.d.ts +6 -0
  225. package/lib/types/setup/nodes/n11-infra.d.ts +6 -0
  226. package/lib/types/setup/nodes/n12-reconcile.d.ts +6 -0
  227. package/lib/types/setup/nodes/n2-region.d.ts +6 -0
  228. package/lib/types/setup/nodes/n3-blueprint.d.ts +6 -0
  229. package/lib/types/setup/nodes/n4-modules.d.ts +6 -0
  230. package/lib/types/setup/nodes/n5-details.d.ts +6 -0
  231. package/lib/types/setup/nodes/n6-plan.d.ts +6 -0
  232. package/lib/types/setup/nodes/n7-verify.d.ts +6 -0
  233. package/lib/types/setup/nodes/n8-approve.d.ts +6 -0
  234. package/lib/types/setup/nodes/n9-buildmode.d.ts +6 -0
  235. package/lib/types/setup/plan-state.d.ts +10 -0
  236. package/lib/types/setup/prompt-loader.d.ts +16 -0
  237. package/lib/types/setup/routes.d.ts +22 -0
  238. package/lib/types/setup/session-notify.d.ts +30 -0
  239. package/lib/types/setup/tools.d.ts +19 -0
  240. package/lib/types/setup/types.d.ts +157 -0
  241. package/lib/types/sse-bus.d.ts +23 -0
  242. package/lib/types/tools/config-facts.d.ts +16 -0
  243. package/lib/types/tools/cost-facts.d.ts +10 -0
  244. package/lib/types/tools/register.d.ts +18 -0
  245. package/lib/types/wb-conventions.d.ts +140 -0
  246. package/package.json +77 -4
@@ -0,0 +1,42 @@
1
+ /**
2
+ * host 侧 HTTP 小工具:读 body、发 JSON、以及 webServer 的最小形状。
3
+ *
4
+ * 抽出来的理由:`index.ts` 和 `cost/routes.ts` 都要用,而 webServer 的注册
5
+ * 契约(`kind: 'exact'` + `path` + `handler`)必须两处一致 —— 复制两份迟早漂移。
6
+ *
7
+ * 另含登录守卫 assertHuaweiLogin(闸 2):工作台「未登录完全不给用」的路由侧
8
+ * 硬闸,一处实现、处处复用。守卫只查凭据库——「已存储」即放行;有效性由
9
+ * 各路由自己的上游调用兜底(与 DSH 其它工具口径一致)。
10
+ *
11
+ * @module @huaweidevtools/landingzone-workbench/http
12
+ */
13
+ import type { IncomingMessage, ServerResponse } from 'node:http';
14
+ /** webServer 服务的最小形状(真实实现在 dsh-host-webserver)。 */
15
+ export interface WebServerLike {
16
+ register: (route: {
17
+ kind: 'exact';
18
+ path: string;
19
+ handler: (req: IncomingMessage, res: ServerResponse) => void;
20
+ }) => () => void;
21
+ }
22
+ /** 读 request body 为 JSON;空 body 或坏 JSON 都退回空对象。 */
23
+ export declare function readJsonBody(req: IncomingMessage): Promise<Record<string, unknown>>;
24
+ /** 发 JSON 响应。 */
25
+ export declare function sendJson(res: ServerResponse, code: number, body: unknown): void;
26
+ /** 把 `req.url` 的 query 取成普通对象。 */
27
+ export declare function queryOf(req: IncomingMessage): Record<string, string>;
28
+ /**
29
+ * 登录守卫(闸 2):未检测到华为云凭据时统一回 401。
30
+ *
31
+ * 用法:handler 首行 `if (!(await assertHuaweiLogin(res))) return`。
32
+ * 返回 false 时响应已写好,调用方直接 return,不要再碰 res。
33
+ *
34
+ * 口径与面板门禁屏(闸 1)、wb_lz_* 工具的 NOT_AUTHENTICATED(闸 3)一致:
35
+ * 话术统一指向会话页面的账号 chip。凭据库键值现读——用户配好凭据后的
36
+ * 下一次请求即刻放行,无需重启。
37
+ *
38
+ * 凭据库本身不可用(插件缺失/损坏)同样按未登录处理:这不是「登录了但
39
+ * 暂时读不出来」,是这台宿主上根本没有可用凭据,放行只会换来上游连环 403。
40
+ */
41
+ export declare function assertHuaweiLogin(res: ServerResponse): Promise<boolean>;
42
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * landingzone-workbench host half.
3
+ *
4
+ * 提供以下 REST 路由给 client 半调用:
5
+ * POST /api/wb/create-session — 建会话 + 建 plan-{ts} + 写 session.json
6
+ * GET /api/wb/latest-session — 读最新会话(扫 plan-* 目录,按 mtime 倒序)
7
+ * GET /api/wb/org-structure — 组织架构页数据(实现见 org/routes.ts:host
8
+ * 读 AI Shell 凭据库 → 官方签名 → 直连
9
+ * Organizations 只读接口,聚合后带缓存返回)
10
+ * /api/wb/cost/* — 费用管理页数据(实现见 cost/routes.ts:host
11
+ * 读 AI Shell 凭据库 → 官方签名 → 直连 BSS
12
+ * 费用中心,聚合后带缓存返回)
13
+ * /api/wb/resource-* 等 — 资源管理页数据(实现见 db.ts / collect.ts /
14
+ * inventory.ts:SQLite 落库 + RMS 清单同步)
15
+ *
16
+ * 会话创建用 host 侧 ctx.sessions(不是 client 的 remote.session),因为 host
17
+ * 直接持有 SessionStore,能同步建会话拿 sessionId。会话不挂 workspaceId(不进
18
+ * 侧栏),只传 cwd(决定会话文件落盘位置 + Host 冷会话列表收录)。
19
+ *
20
+ * planDir 命名:方案 B(plan-{ts},内部存 session.json 记 sessionId)。
21
+ * 一个会话只有一个 plan 文件夹(1:1)。
22
+ *
23
+ * @module @huaweidevtools/landingzone-workbench
24
+ */
25
+ import type { Context } from '@deepseek-ai/cordis';
26
+ export declare const name = "landingzone-workbench";
27
+ /** host 半需要 webServer(REST 路由)。会话由 client 侧 sessions.create 建。 */
28
+ export declare const inject: string[];
29
+ export declare function apply(ctx: Context): void;
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,286 @@
1
+ import type { SignCredentials } from '@huaweidevtools/aishell-dsh-credentials-store/signer';
2
+ /** One resource from the cloud inventory (flattened for the page). */
3
+ export interface CloudResource {
4
+ readonly id: string;
5
+ readonly name: string;
6
+ readonly provider: string;
7
+ readonly type: string;
8
+ readonly region_id: string;
9
+ /** 聚合器模式下无此数据,为空串。 */
10
+ readonly status: string;
11
+ readonly created: string;
12
+ readonly updated: string;
13
+ /** 企业项目 id(RMS 字符串);ResourceQL 高级查询与逐服务采集携带,'0'/'' = 未归集;旧聚合标识面不带(空串)。 */
14
+ readonly ep_id: string;
15
+ /** 聚合器模式下为空对象(聚合面不带标签)。 */
16
+ readonly tags: Record<string, unknown>;
17
+ readonly properties: Record<string, unknown>;
18
+ /** 聚合器标识行携带;ResourceQL 高级查询与逐服务采集时为空串。 */
19
+ readonly source_account_name: string;
20
+ }
21
+ /** Result of a full cloud inventory pull. */
22
+ export interface CloudInventory {
23
+ readonly account: {
24
+ readonly id: string;
25
+ readonly name: string;
26
+ };
27
+ readonly source: string;
28
+ readonly fetched_at: string;
29
+ readonly total: number;
30
+ readonly resources: readonly CloudResource[];
31
+ }
32
+ /** One managed resource instance found in a tfstate file. */
33
+ export interface TfStateEntry {
34
+ /** tfstate file path relative to the scan root. */
35
+ readonly file: string;
36
+ /** TF resource type, e.g. `huaweicloud_vpc`. */
37
+ readonly tf_type: string;
38
+ readonly tf_name: string;
39
+ readonly module: string;
40
+ /** Cloud resource id from `instances[].attributes.id` — the alignment key. */
41
+ readonly id: string;
42
+ readonly name: string;
43
+ }
44
+ /** Result of one tfstate scan. */
45
+ export interface TfStateScan {
46
+ readonly scanned_at: string;
47
+ readonly root: string;
48
+ readonly files: number;
49
+ readonly resources: readonly TfStateEntry[];
50
+ readonly errors: readonly {
51
+ readonly file: string;
52
+ readonly message: string;
53
+ }[];
54
+ }
55
+ /** Thrown when no usable AK/SK pair is stored. */
56
+ export declare class NotAuthenticatedError extends Error {
57
+ constructor();
58
+ }
59
+ /** HTTP error carrying the upstream status + body excerpt. */
60
+ export declare class UpstreamHttpError extends Error {
61
+ readonly status: number;
62
+ readonly excerpt: string;
63
+ constructor(status: number, excerpt: string);
64
+ }
65
+ /**
66
+ * 当前存储的签名凭据(AK/SK/STS);agency 模块复用同一凭据源。
67
+ *
68
+ * 为什么走 cost/credentials.ts 而不是自己开一个凭据库句柄:凭据库包在机器上
69
+ * 有多份(profile 里装的那份、插件 node_modules 里可能还有别的版本),各份的
70
+ * 存储定位/scope 不保证一致;且工作台凭据配置写入的是 KV 键
71
+ * (HW_ACCESS_KEY/HW_SECRET_KEY),不是 `readStoredPair` 读的 pair 记录。
72
+ * 费用页/组织架构页都从这条链路读(实测可用),资源侧对齐同一来源。
73
+ */
74
+ export declare function getStoredPair(): Promise<SignCredentials>;
75
+ /**
76
+ * Resolve the account identity (== RMS domain_id) for the stored credentials.
77
+ * Verified through IAM `/v3/projects` — the same call the credential form
78
+ * uses — so "which account" always reflects the credentials in hand.
79
+ */
80
+ export declare function loadAccount(): Promise<{
81
+ id: string;
82
+ name: string;
83
+ }>;
84
+ /** 通道:组织聚合(主账号/委托管理员) or 逐服务采集(成员,拍板①一律)。 */
85
+ export type SyncChannel = 'aggregator' | 'per-service';
86
+ /**
87
+ * 运行时通道决策:拿当前凭据试一次聚合器指纹查询——通 → 组织聚合;
88
+ * 401/403(成员凭据无聚合器权限)或 404(成员账号无聚合器实例,
89
+ * "aggregator is not existed"——DSH 重启后首次探测实测)→ 逐服务采集。
90
+ * 其他失败(网络/5xx)**不静默降级**,原样抛出:同步侧让本次 run 失败待重试,
91
+ * 路由侧保持组织视角缺省,不能因一次瞬时故障把主账号悄悄锁进单账号口径。
92
+ *
93
+ * 结果按 AK 指纹缓存:凭据不变期间一次探测多处复用(同步主链路、页面
94
+ * scope_default、刷新探测),换凭据即时失效重探。注意:缓存只救得了同一
95
+ * 进程的后续调用,救不了重启后的首次探测——404 分支必须显式覆盖。
96
+ */
97
+ export declare function resolveChannel(): Promise<SyncChannel>;
98
+ /**
99
+ * Signed request against a HuaweiCloud IAM-style endpoint; returns parsed JSON.
100
+ *
101
+ * 请求 URL 与签名必须携带同一份 query,且编码一致:这里用 encodeURIComponent
102
+ * 拼接(与 signer 的 RFC3986 urlEncode 在 base64 marker 字符集上等价),
103
+ * signer 内部对同一 map 排序规范化,两侧字节一致才不会 400。
104
+ */
105
+ /** signedRequest 的凭据可覆盖:agency 模块用委托换来的子账号临时凭据签名。 */
106
+ /** extraHeaders:签名外追加的请求头(如 iam 域级读的 X-Domain-Id——不参与签名,
107
+ * 网关按它把 AK/SK 换算成域级 token 再转给全局服务;实测缺头 ListAgencies 403)。 */
108
+ export declare function signedRequest<T>(method: 'GET' | 'POST', url: string, query: Record<string, string>, body: string, credsOverride?: SignCredentials, extraHeaders?: Record<string, string>): Promise<T>;
109
+ /**
110
+ * 云上清单(聚合器标识行)——仅 /api/wb/cloud-inventory 预览路由消费(客户端
111
+ * 无调用方,M0 遗留);同步主链路不经此(聚合通道走 fetchOrgInventoryAdvanced,
112
+ * 成员走 per-service.ts 逐服务采集)。成员凭据调用会在聚合器接口上 403。
113
+ */
114
+ export declare function fetchCloudInventory(): Promise<CloudInventory>;
115
+ /**
116
+ * Scan `root`(default: the DSH workspace)for tfstate files and extract the
117
+ * managed resource IDs. Bounded by depth + file count so a large workspace
118
+ * cannot hang the route.
119
+ */
120
+ /** 解析 tfstate 文本为纳管条目(本地文件与 OBS 对象共用)。 */
121
+ export declare function parseTfStateJson(text: string, label: string): TfStateEntry[];
122
+ /** 解析单个 tfstate 文件为纳管条目(label 作为 tf_file 标识)。 */
123
+ export declare function readTfstateEntries(absPath: string, label: string): Promise<TfStateEntry[]>;
124
+ export declare function scanTfstate(rootOverride?: string): Promise<TfStateScan>;
125
+ /** summary(count)接口的一行:provider.type 计数。 */
126
+ export interface TypeCount {
127
+ readonly provider: string;
128
+ readonly type: string;
129
+ readonly count: number;
130
+ /** 该类型涉及的 region 计数明细(直查模式携带)。 */
131
+ readonly regions?: readonly {
132
+ readonly region_id: string;
133
+ readonly count: number;
134
+ }[];
135
+ }
136
+ /** 单个 tfstate 条目的对齐结果。 */
137
+ export interface TfCheck {
138
+ readonly file: string;
139
+ readonly tf_type: string;
140
+ readonly tf_name: string;
141
+ readonly module: string;
142
+ readonly id: string;
143
+ /** tf 类型映射到的 RMS provider.type;未映射为空串。 */
144
+ readonly rms_type: string;
145
+ /** 云上是否存在(在对应类型的名单里);未映射类型为 null。对齐阶段回填。 */
146
+ exists: boolean | null;
147
+ }
148
+ /** /api/wb/coverage 的响应:三桶 + 明细 + 对齐细节。 */
149
+ export interface CoverageReport {
150
+ readonly account: {
151
+ readonly id: string;
152
+ readonly name: string;
153
+ };
154
+ readonly source: string;
155
+ readonly fetched_at: string;
156
+ /** 云上存量总数(count 口径)。 */
157
+ readonly total: number;
158
+ readonly managed: number;
159
+ readonly unmanaged: number;
160
+ readonly drifted: number;
161
+ readonly coverage: number | null;
162
+ /** 按服务明细(count 口径):全类型计数 + 该类型命中的 tfstate 数。 */
163
+ readonly byProvider: readonly {
164
+ readonly provider: string;
165
+ readonly total: number;
166
+ readonly managed: number;
167
+ }[];
168
+ readonly byType: readonly TypeCount[];
169
+ /** 聚合器口径:贡献账号计数;直查为空数组。 */
170
+ readonly byAccount: readonly {
171
+ readonly account_id: string;
172
+ readonly count: number;
173
+ }[];
174
+ readonly tf_files: number;
175
+ readonly checks: readonly TfCheck[];
176
+ /** 对齐时发现的错误(如某类型名单拉取失败)。 */
177
+ readonly errors: readonly string[];
178
+ }
179
+ /** 拉取全类型计数。直查用 summary 接口(一次调用三级计数);聚合器用 count 接口 TYPE 分组。 */
180
+ export declare function fetchTypeCounts(domainId: string): Promise<{
181
+ total: number;
182
+ byType: TypeCount[];
183
+ errors: string[];
184
+ }>;
185
+ /** 聚合器贡献账号列表(DOMAIN 分组计数)。 */
186
+ export declare function fetchAggregatorAccounts(domainId: string, aggregatorId: string): Promise<{
187
+ account_id: string;
188
+ count: number;
189
+ }[]>;
190
+ /** 聚合器按类型拉全量标识行(入库用,带账号归属;同步编排消费)。 */
191
+ export interface AggResourceRow {
192
+ readonly id: string;
193
+ readonly name: string;
194
+ readonly provider: string;
195
+ readonly type: string;
196
+ readonly region_id: string;
197
+ readonly account_id: string;
198
+ readonly account_name: string;
199
+ }
200
+ /**
201
+ * 聚合器 ⑤:按 provider+resource_type 拉全组织资源行(分页有界)。
202
+ * 参数位置陷阱见 RMS-API-REFERENCE ⑤:limit/marker 是 QUERY 参数,
203
+ * provider/resource_type 是 body 顶层字段。
204
+ */
205
+ export declare function fetchAggregatorTypeRows(domainId: string, aggregatorId: string, provider: string, type: string): Promise<AggResourceRow[]>;
206
+ /** 明细下钻响应。 */
207
+ export interface ProviderResourceReport {
208
+ readonly provider: string;
209
+ readonly total: number;
210
+ readonly managed: number;
211
+ readonly resources: readonly {
212
+ readonly id: string;
213
+ readonly name: string;
214
+ readonly type: string;
215
+ readonly region_id: string;
216
+ readonly account_id: string;
217
+ readonly managed: boolean;
218
+ }[];
219
+ /** tfstate 里映射到该 provider 的条目(含未命中的,供"已纳管"核对)。 */
220
+ readonly tf_entries: readonly {
221
+ readonly file: string;
222
+ readonly tf_type: string;
223
+ readonly tf_name: string;
224
+ readonly id: string;
225
+ }[];
226
+ readonly errors: readonly string[];
227
+ }
228
+ /**
229
+ * 明细下钻:某 provider 的云上资源名单 + 每条是否被 tfstate 纳管。
230
+ * 聚合器口径;直查模式下页面应使用已加载的 cloud-inventory 本地过滤。
231
+ */
232
+ export declare function fetchProviderResources(provider: string): Promise<ProviderResourceReport>;
233
+ /**
234
+ * 纳管率报表(count 口径,不拉全量名单):
235
+ * 分母 = summary/count 接口的类型计数;分子 = tfstate 条目按 TF_TO_RMS_TYPE
236
+ * 映射后,只拉对应类型的小名单做 ID 对齐。单类型拉取次数 = tfstate 涉及的
237
+ * 类型数(通常个位数),总量与云上规模无关。
238
+ */
239
+ export declare function fetchCoverageReport(rootOverride?: string): Promise<CoverageReport>;
240
+ /** 高级查询返回的资源行(聚合器全组织口径,含归属)。 */
241
+ export interface AdvancedResourceRow {
242
+ readonly account_id: string;
243
+ readonly id: string;
244
+ readonly name: string;
245
+ readonly provider: string;
246
+ readonly type: string;
247
+ readonly region_id: string;
248
+ readonly ep_id: string;
249
+ readonly created: string;
250
+ readonly tags_json: string;
251
+ }
252
+ /**
253
+ * 一条 ResourceQL 拉全组织资源清单(含 ep_id)——替代 ④计数+⑤逐类型+②主账号直查
254
+ * +委托直查的合并通道(实测 842 行 0.7s;依赖各账号开启资源记录器)。
255
+ * 结果 ≥4000(单次上限)时自动按账号分批重拉;0 行视为异常(记录器未完成首采)。
256
+ */
257
+ /** 组织清单指纹:count + max(updated),一条 QL 聚合(实测可用,2026-11-10 spike)。 */
258
+ export interface OrgFingerprint {
259
+ readonly total: number;
260
+ readonly maxUpdated: string;
261
+ }
262
+ /**
263
+ * 拉云上指纹——刷新前的"要不要重跑全量"探测(count 变 = 有增删;max(updated)
264
+ * 变 = 有任何修改)。返回 0 行/缺 max 视为探测失败抛错,由调用方走全量兜底。
265
+ */
266
+ export declare function fetchOrgFingerprint(domainId: string, aggregatorId: string): Promise<OrgFingerprint>;
267
+ export declare function fetchOrgInventoryAdvanced(domainId: string, aggregatorId: string): Promise<AdvancedResourceRow[]>;
268
+ export interface EpEntry {
269
+ readonly id: string;
270
+ readonly name: string;
271
+ }
272
+ /** 列举某账号域的企业项目(EPS)。domainId 需以 X-Domain-Id 头传递(EPS 实测要求);
273
+ * creds 缺省用本地凭据(主账号),可传委托换来的子账号临时凭据查团队账号的 EPS。
274
+ * 调用者需 EPS 只读权限;失败由调用方按告警降级。 */
275
+ export declare function fetchEnterpriseProjects(domainId: string, creds?: SignCredentials): Promise<EpEntry[]>;
276
+ /**
277
+ * 列出某企业项目下的 OBS 桶名(resources/filter,只读;2026-11-17)。
278
+ * OBS 的 XML list-buckets 不带企业项目字段,采集恒置 0——桶的真实归属
279
+ * 只能从 EPS 按项目反查(与迁移功能无关的口径修复)。bucket 是 global
280
+ * 类型,但后端(TMS)要求 projects 非空,按桶所在区域集换算 IAM 项目 id
281
+ * 传入(项目名单即区域名,华为云默认命名约定)。
282
+ * @param domainId X-Domain-Id;@param epId 企业项目 id(0 = default)
283
+ * @param regions 桶所在区域名集合(去重)
284
+ */
285
+ export declare function listEpBuckets(domainId: string, epId: string, regions: readonly string[]): Promise<readonly string[]>;
286
+ //# sourceMappingURL=inventory.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { SignCredentials } from '@huaweidevtools/aishell-dsh-credentials-store/signer';
2
+ /** "obs://桶名/前缀" → { bucket, prefix };不合法返回 undefined。 */
3
+ export declare function parseObsPath(path: string): {
4
+ bucket: string;
5
+ prefix: string;
6
+ } | undefined;
7
+ /**
8
+ * 列举账号全部桶(服务级 GET /,响应为 XML)——逐服务采集的 obs.buckets 条目用
9
+ * (per-service.ts 解析桶名与区域)。非 200 抛 UpstreamHttpError。
10
+ */
11
+ export declare function listBucketsRaw(creds: SignCredentials): Promise<string>;
12
+ /** 列举桶内对象(按前缀过滤),返回对象 key 列表。非 200 抛 UpstreamHttpError。 */
13
+ export declare function listObjects(creds: SignCredentials, bucket: string, prefix: string): Promise<string[]>;
14
+ /** 读取对象内容;404 返回 null,其他非 200 抛 UpstreamHttpError。 */
15
+ export declare function getObject(creds: SignCredentials, bucket: string, key: string): Promise<string | null>;
16
+ //# sourceMappingURL=obs.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 组织结构聚合 — 把 Organizations 的几个只读接口拼成页面要的一份载荷。
3
+ *
4
+ * 聚合顺序(hwstaff_ldz_test 租户实测对账:37 账号 = 根 31 + a 2 + c 1 + b 2 + d 1):
5
+ * 1. ShowOrganization → 组织 id + 管理账号 id
6
+ * 2. ListRoots → 组织根(树的根节点)
7
+ * 3. ListAccounts → 全量账号(状态/加入时间/方式)
8
+ * 4. ListEntities → 从根递归下钻建 OU 树 + 账号落位
9
+ * 5. ListDelegatedAdministrators → 委托管理员(失败只影响角色标注,不致命)
10
+ *
11
+ * 核心账号识别:委托管理员以 API 结果优先;LZ 标准命名
12
+ * (es_SharedServices_*、es_LogArchive_*、es_SecurityServices_*)
13
+ * 按名字归类为治理、审计账号。
14
+ *
15
+ * @module @huaweidevtools/landingzone-workbench/org/aggregate
16
+ */
17
+ import type { OrgStructurePayload } from '../org-types.ts';
18
+ import { type OrgContext } from './orgs.ts';
19
+ /** 取数失败时抛给 routes 层的信号(携带可直接展示的能力状态)。 */
20
+ export declare class OrgCapabilityError extends Error {
21
+ readonly capability: {
22
+ ok: false;
23
+ reason: 'not_configured' | 'auth' | 'permission' | 'account_type' | 'transient';
24
+ needs?: readonly string[];
25
+ message: string;
26
+ };
27
+ constructor(capability: {
28
+ ok: false;
29
+ reason: 'not_configured' | 'auth' | 'permission' | 'account_type' | 'transient';
30
+ needs?: readonly string[];
31
+ message: string;
32
+ });
33
+ }
34
+ /** 聚合组织结构载荷。任何关键步骤失败都抛 OrgCapabilityError(由 routes 转 200+unavailable)。 */
35
+ export declare function buildOrgStructure(ctx: OrgContext): Promise<OrgStructurePayload>;
36
+ //# sourceMappingURL=aggregate.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { AccountChurnView, ChurnDeletedAccount, OrgCapability } from '../org-types.ts';
2
+ import { type OrgContext } from './orgs.ts';
3
+ export type { AccountChurnView, ChurnDeletedAccount };
4
+ export interface AccountChurnResult {
5
+ readonly view: AccountChurnView | null;
6
+ readonly capability?: OrgCapability;
7
+ }
8
+ /** 关闭系状态(2026-11-10 拆分):pending_closure=关闭流程中;suspended=已关闭,名册仍可见。 */
9
+ export declare function computeAccountChurn(ctx: OrgContext): Promise<AccountChurnResult>;
10
+ //# sourceMappingURL=churn.d.ts.map