@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.
- package/LICENSE +201 -0
- package/README.md +85 -2
- package/cordis.patch.yml +21 -0
- package/knowledge/account-qualification.md +128 -0
- package/knowledge/blueprints/_base/blueprint.json +481 -0
- package/knowledge/blueprints/_base/defaults.json +127 -0
- package/knowledge/blueprints/foundation-lz/blueprint.json +43 -0
- package/knowledge/blueprints/foundation-lz/defaults.json +47 -0
- package/knowledge/blueprints/full-lz/blueprint.json +11 -0
- package/knowledge/blueprints/full-lz/defaults.json +8 -0
- package/knowledge/config.json +43 -0
- package/knowledge/error-rules.json +14 -0
- package/knowledge/ic-policies.json +21 -0
- package/knowledge/modules/account-structure.md +101 -0
- package/knowledge/modules/compliance/config-rms.md +212 -0
- package/knowledge/modules/compliance/cts.md +179 -0
- package/knowledge/modules/compliance/obs-lts.md +155 -0
- package/knowledge/modules/ic-policies.json +21 -0
- package/knowledge/modules/identity-center.md +603 -0
- package/knowledge/modules/module-layers.md +169 -0
- package/knowledge/modules/network/er.md +222 -0
- package/knowledge/modules/network/nat-eip.md +123 -0
- package/knowledge/modules/network/ram-share.md +92 -0
- package/knowledge/modules/network/vpc-subnet.md +142 -0
- package/knowledge/modules/organization-security/scp.md +122 -0
- package/knowledge/modules/organizations.md +212 -0
- package/knowledge/modules/recommended-config.md +157 -0
- package/knowledge/modules/recommended-rules.json +175 -0
- package/knowledge/modules/scp-policies.json +111 -0
- package/knowledge/modules/security/aad.md +94 -0
- package/knowledge/modules/security/cfw.md +105 -0
- package/knowledge/modules/security/waf.md +110 -0
- package/knowledge/param-mappings.json +133 -0
- package/knowledge/prompts.md +83 -0
- package/knowledge/resource-types.json +1162 -0
- package/knowledge/scp-policies.json +111 -0
- package/knowledge/state-machine.md +33 -0
- package/lib/client.js +21 -0
- package/lib/index.js +28592 -0
- package/lib/types/account-role.d.ts +19 -0
- package/lib/types/account-scope.d.ts +10 -0
- package/lib/types/agency.d.ts +38 -0
- package/lib/types/client/DropdownSelect.d.ts +49 -0
- package/lib/types/client/LoginGate.d.ts +20 -0
- package/lib/types/client/PanelIcon.d.ts +11 -0
- package/lib/types/client/WorkbenchShell.d.ts +21 -0
- package/lib/types/client/account-role.d.ts +15 -0
- package/lib/types/client/credential-status.d.ts +15 -0
- package/lib/types/client/huawei-mark.d.ts +37 -0
- package/lib/types/client/index.d.ts +26 -0
- package/lib/types/client/layout-ref.d.ts +23 -0
- package/lib/types/client/pages/ConfigPage/AdviceCard.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/AuditBar.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/ChangeSummaryCard.d.ts +22 -0
- package/lib/types/client/pages/ConfigPage/ChangesCard.d.ts +27 -0
- package/lib/types/client/pages/ConfigPage/ComplianceDetail.d.ts +25 -0
- package/lib/types/client/pages/ConfigPage/ComplianceSummaryCard.d.ts +31 -0
- package/lib/types/client/pages/ConfigPage/FindingsCard.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/GlossaryDrawer.d.ts +17 -0
- package/lib/types/client/pages/ConfigPage/OrgComplianceDetail.d.ts +15 -0
- package/lib/types/client/pages/ConfigPage/Pager.d.ts +32 -0
- package/lib/types/client/pages/ConfigPage/ResourceDrawer.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/ResourcesTable.d.ts +35 -0
- package/lib/types/client/pages/ConfigPage/RollupPanel.d.ts +17 -0
- package/lib/types/client/pages/ConfigPage/RuleDetailDrawer.d.ts +23 -0
- package/lib/types/client/pages/ConfigPage/StatusCards.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/UncoveredDialog.d.ts +22 -0
- package/lib/types/client/pages/ConfigPage/config-api.d.ts +101 -0
- package/lib/types/client/pages/ConfigPage/config-store.d.ts +57 -0
- package/lib/types/client/pages/ConfigPage/index.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/paging.d.ts +46 -0
- package/lib/types/client/pages/ConfigPage/scope-options.d.ts +51 -0
- package/lib/types/client/pages/CostPage/AccountAllocation.d.ts +24 -0
- package/lib/types/client/pages/CostPage/AccountBars.d.ts +20 -0
- package/lib/types/client/pages/CostPage/AccountColumns.d.ts +24 -0
- package/lib/types/client/pages/CostPage/AccountDonut.d.ts +18 -0
- package/lib/types/client/pages/CostPage/AccountSwitcher.d.ts +25 -0
- package/lib/types/client/pages/CostPage/AdviceCard.d.ts +43 -0
- package/lib/types/client/pages/CostPage/AdviceFindings.d.ts +43 -0
- package/lib/types/client/pages/CostPage/BillingPanels.d.ts +23 -0
- package/lib/types/client/pages/CostPage/BudgetCard.d.ts +36 -0
- package/lib/types/client/pages/CostPage/GlossaryDrawer.d.ts +16 -0
- package/lib/types/client/pages/CostPage/KpiRow.d.ts +23 -0
- package/lib/types/client/pages/CostPage/MarkdownBlock.d.ts +16 -0
- package/lib/types/client/pages/CostPage/ReportView.d.ts +17 -0
- package/lib/types/client/pages/CostPage/ResourceColumns.d.ts +19 -0
- package/lib/types/client/pages/CostPage/ResourceDonut.d.ts +18 -0
- package/lib/types/client/pages/CostPage/ResourcesCard.d.ts +40 -0
- package/lib/types/client/pages/CostPage/RuleDetailDrawer.d.ts +23 -0
- package/lib/types/client/pages/CostPage/SavingView.d.ts +38 -0
- package/lib/types/client/pages/CostPage/ServiceDonut.d.ts +17 -0
- package/lib/types/client/pages/CostPage/TrendChart.d.ts +24 -0
- package/lib/types/client/pages/CostPage/budget-input.d.ts +30 -0
- package/lib/types/client/pages/CostPage/cost-api.d.ts +266 -0
- package/lib/types/client/pages/CostPage/cost-store.d.ts +25 -0
- package/lib/types/client/pages/CostPage/format.d.ts +37 -0
- package/lib/types/client/pages/CostPage/index.d.ts +34 -0
- package/lib/types/client/pages/CostPage/trend-fold.d.ts +32 -0
- package/lib/types/client/pages/CostPage/useEcharts.d.ts +70 -0
- package/lib/types/client/pages/OrgStructurePage/AccountStatsCard.d.ts +22 -0
- package/lib/types/client/pages/OrgStructurePage/CoreAccountsCard.d.ts +18 -0
- package/lib/types/client/pages/OrgStructurePage/CreateAccountDialog.d.ts +28 -0
- package/lib/types/client/pages/OrgStructurePage/ManageUsersDialog.d.ts +28 -0
- package/lib/types/client/pages/OrgStructurePage/MemberAccountsTable.d.ts +32 -0
- package/lib/types/client/pages/OrgStructurePage/MoveAccountDialog.d.ts +29 -0
- package/lib/types/client/pages/OrgStructurePage/OrgGlossaryDrawer.d.ts +13 -0
- package/lib/types/client/pages/OrgStructurePage/OrgTreeCard.d.ts +31 -0
- package/lib/types/client/pages/OrgStructurePage/index.d.ts +21 -0
- package/lib/types/client/pages/OrgStructurePage/org-api.d.ts +166 -0
- package/lib/types/client/pages/OverviewPage/AnchorRow.d.ts +24 -0
- package/lib/types/client/pages/OverviewPage/AttentionList.d.ts +29 -0
- package/lib/types/client/pages/OverviewPage/OverviewCharts.d.ts +79 -0
- package/lib/types/client/pages/OverviewPage/OverviewGlossaryDrawer.d.ts +15 -0
- package/lib/types/client/pages/OverviewPage/index.d.ts +22 -0
- package/lib/types/client/pages/OverviewPage/overview-api.d.ts +115 -0
- package/lib/types/client/pages/ResourcePage/AccountResourceList.d.ts +21 -0
- package/lib/types/client/pages/ResourcePage/components/GlossaryDrawer.d.ts +20 -0
- package/lib/types/client/pages/ResourcePage/components/MetricCards.d.ts +19 -0
- package/lib/types/client/pages/ResourcePage/components/MultiSelect.d.ts +27 -0
- package/lib/types/client/pages/ResourcePage/components/PanelPager.d.ts +26 -0
- package/lib/types/client/pages/ResourcePage/components/RankBars.d.ts +25 -0
- package/lib/types/client/pages/ResourcePage/components/ScopeSelect.d.ts +27 -0
- package/lib/types/client/pages/ResourcePage/components/SourceConfigModal.d.ts +21 -0
- package/lib/types/client/pages/ResourcePage/components/SyncControls.d.ts +18 -0
- package/lib/types/client/pages/ResourcePage/components/TrendChart.d.ts +14 -0
- package/lib/types/client/pages/ResourcePage/components/useColumnWidths.d.ts +12 -0
- package/lib/types/client/pages/ResourcePage/format.d.ts +9 -0
- package/lib/types/client/pages/ResourcePage/index.d.ts +20 -0
- package/lib/types/client/pages/ResourcePage/summary-api.d.ts +205 -0
- package/lib/types/client/pages/SetupPage/AskPanel.d.ts +21 -0
- package/lib/types/client/pages/SetupPage/ChatEmbed.d.ts +40 -0
- package/lib/types/client/pages/SetupPage/ChatTab.d.ts +17 -0
- package/lib/types/client/pages/SetupPage/FormTab.d.ts +12 -0
- package/lib/types/client/pages/SetupPage/FormTabV2.d.ts +14 -0
- package/lib/types/client/pages/SetupPage/ProgressTreeView.d.ts +15 -0
- package/lib/types/client/pages/SetupPage/StageFlow.d.ts +16 -0
- package/lib/types/client/pages/SetupPage/index.d.ts +10 -0
- package/lib/types/client/pages/SetupPage/progress-types.d.ts +36 -0
- package/lib/types/client/pages/SetupPage/session-binding.d.ts +38 -0
- package/lib/types/client/pages/SetupPage/session-store.d.ts +57 -0
- package/lib/types/client/pages/SetupPage/sessions-ref.d.ts +5 -0
- package/lib/types/client/pages/SetupPage/setup-replan.d.ts +13 -0
- package/lib/types/client/pages/SetupPage/wb-api.d.ts +192 -0
- package/lib/types/client/pages/list-preview.d.ts +36 -0
- package/lib/types/client/permission-mode.d.ts +53 -0
- package/lib/types/client/store.d.ts +22 -0
- package/lib/types/collect.d.ts +78 -0
- package/lib/types/config/account-scope.d.ts +61 -0
- package/lib/types/config/advice-findings.d.ts +31 -0
- package/lib/types/config/advice-prompt.d.ts +60 -0
- package/lib/types/config/advice.d.ts +116 -0
- package/lib/types/config/cts.d.ts +30 -0
- package/lib/types/config/evidence/rules.d.ts +31 -0
- package/lib/types/config/evidence/types.d.ts +103 -0
- package/lib/types/config/failure-note.d.ts +46 -0
- package/lib/types/config/fingerprint-cache.d.ts +45 -0
- package/lib/types/config/identity.d.ts +67 -0
- package/lib/types/config/query.d.ts +49 -0
- package/lib/types/config/rms.d.ts +412 -0
- package/lib/types/config/routes.d.ts +32 -0
- package/lib/types/config/types.d.ts +785 -0
- package/lib/types/config/views.d.ts +158 -0
- package/lib/types/cost/accounts.d.ts +29 -0
- package/lib/types/cost/advice-findings.d.ts +77 -0
- package/lib/types/cost/advice-model.d.ts +19 -0
- package/lib/types/cost/advice-prompt.d.ts +73 -0
- package/lib/types/cost/advice-subagent-types.d.ts +6 -0
- package/lib/types/cost/advice-subagent.d.ts +116 -0
- package/lib/types/cost/advice-types.d.ts +63 -0
- package/lib/types/cost/advice.d.ts +125 -0
- package/lib/types/cost/aggregate.d.ts +157 -0
- package/lib/types/cost/assume.d.ts +43 -0
- package/lib/types/cost/bss.d.ts +166 -0
- package/lib/types/cost/budget-overview.d.ts +38 -0
- package/lib/types/cost/budget.d.ts +56 -0
- package/lib/types/cost/cache.d.ts +58 -0
- package/lib/types/cost/caliber.d.ts +40 -0
- package/lib/types/cost/console-links.d.ts +27 -0
- package/lib/types/cost/credentials.d.ts +38 -0
- package/lib/types/cost/data-window.d.ts +38 -0
- package/lib/types/cost/evidence/catalog.d.ts +35 -0
- package/lib/types/cost/evidence/index.d.ts +70 -0
- package/lib/types/cost/evidence/inventory.d.ts +44 -0
- package/lib/types/cost/evidence/pricing.d.ts +72 -0
- package/lib/types/cost/evidence/projects.d.ts +18 -0
- package/lib/types/cost/evidence/rules.d.ts +66 -0
- package/lib/types/cost/evidence/state.d.ts +38 -0
- package/lib/types/cost/evidence/thresholds.d.ts +68 -0
- package/lib/types/cost/evidence/types.d.ts +288 -0
- package/lib/types/cost/evidence/utilization.d.ts +37 -0
- package/lib/types/cost/history.d.ts +36 -0
- package/lib/types/cost/ledger.d.ts +97 -0
- package/lib/types/cost/normalize.d.ts +37 -0
- package/lib/types/cost/period-projection.d.ts +57 -0
- package/lib/types/cost/plan-check.d.ts +102 -0
- package/lib/types/cost/plan-db.d.ts +73 -0
- package/lib/types/cost/plan-types.d.ts +183 -0
- package/lib/types/cost/plan.d.ts +63 -0
- package/lib/types/cost/quote.d.ts +45 -0
- package/lib/types/cost/report.d.ts +136 -0
- package/lib/types/cost/resources.d.ts +108 -0
- package/lib/types/cost/routes.d.ts +38 -0
- package/lib/types/cost/scope.d.ts +42 -0
- package/lib/types/cost/types.d.ts +335 -0
- package/lib/types/cost/unit-prices-derive.d.ts +19 -0
- package/lib/types/cost/unit-prices.d.ts +23 -0
- package/lib/types/db.d.ts +228 -0
- package/lib/types/host-log.d.ts +7 -0
- package/lib/types/http.d.ts +42 -0
- package/lib/types/index.d.ts +30 -0
- package/lib/types/inventory.d.ts +286 -0
- package/lib/types/obs.d.ts +16 -0
- package/lib/types/org/aggregate.d.ts +36 -0
- package/lib/types/org/churn.d.ts +10 -0
- package/lib/types/org/orgs.d.ts +258 -0
- package/lib/types/org/routes.d.ts +28 -0
- package/lib/types/org-types.d.ts +156 -0
- package/lib/types/per-service.d.ts +39 -0
- package/lib/types/setup/blueprint-loader.d.ts +81 -0
- package/lib/types/setup/caller.d.ts +105 -0
- package/lib/types/setup/engine.d.ts +41 -0
- package/lib/types/setup/form-store.d.ts +13 -0
- package/lib/types/setup/nodes/n1-check.d.ts +14 -0
- package/lib/types/setup/nodes/n10-governance.d.ts +6 -0
- package/lib/types/setup/nodes/n11-infra.d.ts +6 -0
- package/lib/types/setup/nodes/n12-reconcile.d.ts +6 -0
- package/lib/types/setup/nodes/n2-region.d.ts +6 -0
- package/lib/types/setup/nodes/n3-blueprint.d.ts +6 -0
- package/lib/types/setup/nodes/n4-modules.d.ts +6 -0
- package/lib/types/setup/nodes/n5-details.d.ts +6 -0
- package/lib/types/setup/nodes/n6-plan.d.ts +6 -0
- package/lib/types/setup/nodes/n7-verify.d.ts +6 -0
- package/lib/types/setup/nodes/n8-approve.d.ts +6 -0
- package/lib/types/setup/nodes/n9-buildmode.d.ts +6 -0
- package/lib/types/setup/plan-state.d.ts +10 -0
- package/lib/types/setup/prompt-loader.d.ts +16 -0
- package/lib/types/setup/routes.d.ts +22 -0
- package/lib/types/setup/session-notify.d.ts +30 -0
- package/lib/types/setup/tools.d.ts +19 -0
- package/lib/types/setup/types.d.ts +157 -0
- package/lib/types/sse-bus.d.ts +23 -0
- package/lib/types/tools/config-facts.d.ts +16 -0
- package/lib/types/tools/cost-facts.d.ts +10 -0
- package/lib/types/tools/register.d.ts +18 -0
- package/lib/types/wb-conventions.d.ts +140 -0
- package/package.json +77 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** 一次查询的作用域。 */
|
|
2
|
+
export interface CostScope {
|
|
3
|
+
/** 当前凭据的账号角色。 */
|
|
4
|
+
readonly role: 'management' | 'member';
|
|
5
|
+
/** 当前凭据自身的 domain id(IAM 校验所得)。 */
|
|
6
|
+
readonly ownAccountId: string;
|
|
7
|
+
/** 作用域:null = 组织视角(只有已确认的主账号拿得到);否则就是那个账号。 */
|
|
8
|
+
readonly scope: string | null;
|
|
9
|
+
/** 角色是否由 ShowOrganization(或第二信号)确认。 */
|
|
10
|
+
readonly confirmed: boolean;
|
|
11
|
+
/** 给页面的附注(例如"本账号视角:账号身份未确认")。 */
|
|
12
|
+
readonly note?: string;
|
|
13
|
+
}
|
|
14
|
+
/** 解析结果:拒绝时给一句可直接展示的原因。 */
|
|
15
|
+
export type ScopeResolution = {
|
|
16
|
+
readonly ok: true;
|
|
17
|
+
readonly value: CostScope;
|
|
18
|
+
} | {
|
|
19
|
+
readonly ok: false;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 解析并强制作用域。
|
|
24
|
+
*
|
|
25
|
+
* @param requested 客户端请求的账号('' = 组织视角 / 本账号,由角色决定)。
|
|
26
|
+
* @throws NotAuthenticatedError 无凭据(路由的登录守卫先行,正常走不到)。
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveCostScope(requested: string): Promise<ScopeResolution>;
|
|
29
|
+
/**
|
|
30
|
+
* 调用者能不能动某个口径下的数据。
|
|
31
|
+
*
|
|
32
|
+
* 读的时候 scope 就是"看哪一份";**写**(改状态/删除)却是按 id 操作,而页面此刻
|
|
33
|
+
* 可能停在别的视角里 —— 组织视角看到的一条可能属于某个账号。所以写之前先按 id
|
|
34
|
+
* 找到它所在的口径,再用这里判断有没有资格动它:
|
|
35
|
+
* · 成员:只有自己那一份
|
|
36
|
+
* · 主账号:全部(组织视角 + 任一账号);身份未确认时退回本账号
|
|
37
|
+
*
|
|
38
|
+
* @param caller 解析出的调用者作用域。
|
|
39
|
+
* @param scope 数据所在口径('' = 组织视角)。
|
|
40
|
+
*/
|
|
41
|
+
export declare function canTouchScope(caller: CostScope, scope: string): boolean;
|
|
42
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 费用域的数据契约。
|
|
3
|
+
*
|
|
4
|
+
* 三件事在这里定死,避免以后各处自己发明:
|
|
5
|
+
* · 信封形态(data + meta),meta 里必须有数据的"截止时间/新鲜度";
|
|
6
|
+
* · 能力模型(capabilities)—— 没权限不是错误,是一种可展示的状态;
|
|
7
|
+
* · 口径常量(cost_type / amount_type / 币种),不散落在调用点。
|
|
8
|
+
*
|
|
9
|
+
* 口径原则沿用看板:成本口径、账单口径、账户口径各算各的,绝不混加。
|
|
10
|
+
*
|
|
11
|
+
* @module @huaweidevtools/landingzone-workbench/cost/types
|
|
12
|
+
*/
|
|
13
|
+
/** 数据超过这个年龄就不算"新"(与看板同一个阈值:36 小时)。 */
|
|
14
|
+
export declare const STALE_AFTER_SECONDS: number;
|
|
15
|
+
/**
|
|
16
|
+
* 成本口径(对应 ListCosts 的 `cost_type`)。
|
|
17
|
+
*
|
|
18
|
+
* - `ORIGINAL_COST` 原始成本:官网价折后的成本,约 1 小时时延,**能到当天**;
|
|
19
|
+
* - `AMORTIZED_COST` 摊销成本:包周期预付费按天摊,每 24 小时刷新、延迟 24~48 小时。
|
|
20
|
+
*
|
|
21
|
+
* 这两个口径的数**不可相加也不可互换**:同一个账期、同一个账号,原始成本 ≈ 账单消费,
|
|
22
|
+
* 摊销成本会因为"预付费按天摊"而与账单产生月中差异。页面上必须始终标清楚看的是哪一个。
|
|
23
|
+
*/
|
|
24
|
+
export type CostType = 'ORIGINAL_COST' | 'AMORTIZED_COST';
|
|
25
|
+
/** 页面/接口的默认口径:原始成本(能看到当天,且与账单消费接近)。 */
|
|
26
|
+
export declare const DEFAULT_COST_TYPE: CostType;
|
|
27
|
+
/** 界面上的名字(服务端与客户端共用,避免两处各写一份中文)。 */
|
|
28
|
+
export declare const COST_TYPE_LABEL: Readonly<Record<CostType, string>>;
|
|
29
|
+
/** 口径的一句话时延说明,直接用在卡片副标题/术语里。 */
|
|
30
|
+
export declare const COST_TYPE_LATENCY: Readonly<Record<CostType, string>>;
|
|
31
|
+
/** 金额口径:支付金额。 */
|
|
32
|
+
export declare const AMOUNT_TYPE = "PAYMENT_AMOUNT";
|
|
33
|
+
/** 缺省币种(接口按币种分块返回,这里是回落到的主币种)。 */
|
|
34
|
+
export declare const DEFAULT_CURRENCY = "CNY";
|
|
35
|
+
/**
|
|
36
|
+
* 一个能力的状态。
|
|
37
|
+
*
|
|
38
|
+
* `permission` 与 `account_type` 必须分开:前者补权限就好,后者补权限也没用。
|
|
39
|
+
* `auth` 表示签名/凭据本身不对(401 但不是账号类型问题)。
|
|
40
|
+
*/
|
|
41
|
+
export type CostCapability = {
|
|
42
|
+
readonly ok: true;
|
|
43
|
+
} | {
|
|
44
|
+
readonly ok: false;
|
|
45
|
+
readonly reason: 'permission';
|
|
46
|
+
readonly needs: readonly string[];
|
|
47
|
+
readonly message: string;
|
|
48
|
+
} | {
|
|
49
|
+
readonly ok: false;
|
|
50
|
+
readonly reason: 'account_type';
|
|
51
|
+
readonly message: string;
|
|
52
|
+
} | {
|
|
53
|
+
readonly ok: false;
|
|
54
|
+
readonly reason: 'not_configured';
|
|
55
|
+
readonly message: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly ok: false;
|
|
58
|
+
readonly reason: 'auth';
|
|
59
|
+
readonly message: string;
|
|
60
|
+
} | {
|
|
61
|
+
readonly ok: false;
|
|
62
|
+
readonly reason: 'transient';
|
|
63
|
+
readonly message: string;
|
|
64
|
+
}
|
|
65
|
+
/** 需要 assume(临时凭据)才能取数,而当前换不到(缺权限或委托)。needs 给出具体权限码。 */
|
|
66
|
+
| {
|
|
67
|
+
readonly ok: false;
|
|
68
|
+
readonly reason: 'assume_required';
|
|
69
|
+
readonly needs?: readonly string[];
|
|
70
|
+
readonly message: string;
|
|
71
|
+
};
|
|
72
|
+
/** 能力矩阵里每一项的名字。 */
|
|
73
|
+
export type CostCapabilityKey = 'costCenter' | 'balance' | 'monthlySum' | 'subCustomerBills' | 'enterpriseSubCustomers' | 'enterpriseOrganizations';
|
|
74
|
+
/** 一次查询的元信息。 */
|
|
75
|
+
export interface EnvelopeMeta {
|
|
76
|
+
/** 数据截止时间(不是请求时间)。null = 没有数据。 */
|
|
77
|
+
readonly data_as_of: string | null;
|
|
78
|
+
/** 距 data_as_of 的秒数。 */
|
|
79
|
+
readonly freshness_seconds: number | null;
|
|
80
|
+
/** 是否超过 STALE_AFTER_SECONDS。 */
|
|
81
|
+
readonly is_stale: boolean;
|
|
82
|
+
/** 这份数据来自实时请求还是本地缓存。 */
|
|
83
|
+
readonly source: 'live' | 'cache';
|
|
84
|
+
readonly cycle?: string;
|
|
85
|
+
/** 视图所属账号;null/缺省表示主账号(全组织)视角。 */
|
|
86
|
+
readonly account_id?: string | null;
|
|
87
|
+
readonly cost_type: string;
|
|
88
|
+
readonly amount_type: string;
|
|
89
|
+
readonly currency: string;
|
|
90
|
+
}
|
|
91
|
+
/** 统一响应信封。`unavailable` 只在该路由的依赖能力缺失时出现,此时 data 为空。 */
|
|
92
|
+
export interface Envelope<T> {
|
|
93
|
+
readonly data: T;
|
|
94
|
+
readonly meta: EnvelopeMeta;
|
|
95
|
+
readonly unavailable?: CostCapability;
|
|
96
|
+
}
|
|
97
|
+
/** 拍平后的一行成本事实(日粒度)。 */
|
|
98
|
+
export interface CostRow {
|
|
99
|
+
readonly date: string;
|
|
100
|
+
readonly accountId: string;
|
|
101
|
+
readonly serviceCode: string;
|
|
102
|
+
readonly amount: number;
|
|
103
|
+
readonly officialAmount: number | null;
|
|
104
|
+
}
|
|
105
|
+
/** 拍平后的一行成本事实(月粒度)。 */
|
|
106
|
+
export interface CostMonthRow {
|
|
107
|
+
readonly cycle: string;
|
|
108
|
+
readonly accountId: string;
|
|
109
|
+
readonly serviceCode: string;
|
|
110
|
+
readonly amount: number;
|
|
111
|
+
}
|
|
112
|
+
/** /api/wb/cost/meta 的载荷。 */
|
|
113
|
+
export interface CostMeta {
|
|
114
|
+
readonly as_of: string;
|
|
115
|
+
readonly currency: string;
|
|
116
|
+
readonly cycles: readonly string[];
|
|
117
|
+
readonly latest_cycle: string;
|
|
118
|
+
readonly today: string;
|
|
119
|
+
readonly capabilities: Readonly<Record<CostCapabilityKey, CostCapability>>;
|
|
120
|
+
}
|
|
121
|
+
/** 总览 KPI。金额单位:元;比率:0~1。 */
|
|
122
|
+
export interface CostOverview {
|
|
123
|
+
readonly cycle: string;
|
|
124
|
+
readonly cost_type: CostType;
|
|
125
|
+
readonly amount_type: string;
|
|
126
|
+
readonly total: number;
|
|
127
|
+
/** 有数据的天数(含"今天"这个尚未走完的日子)。 */
|
|
128
|
+
readonly elapsed_days: number;
|
|
129
|
+
readonly days_in_month: number;
|
|
130
|
+
/**
|
|
131
|
+
* 日均。**分母是"完整的天数"**:原始成本口径下今天有实时累计,但这一天还没走完,
|
|
132
|
+
* 把它算进分母会把日均压低、把月底推演压低(见 complete_days)。
|
|
133
|
+
*/
|
|
134
|
+
readonly daily_avg: number;
|
|
135
|
+
/** 完整的天数(从 elapsed_days 里剔掉"今天")。 */
|
|
136
|
+
readonly complete_days: number;
|
|
137
|
+
/**
|
|
138
|
+
* 今天的实时累计金额。null = 这一天没有数据(口径滞后,还没到今天就止步了)。
|
|
139
|
+
*
|
|
140
|
+
* 为什么单列:这个数**只是一天的一部分**,不能当"一天的花费"去比、去外推。
|
|
141
|
+
*/
|
|
142
|
+
readonly today_amount: number | null;
|
|
143
|
+
/** 推演到月底的金额;可用天数不足时为 null(不拿两天数据外推一个月)。 */
|
|
144
|
+
readonly forecast_month_end: number | null;
|
|
145
|
+
readonly prev_cycle: string;
|
|
146
|
+
/** 上月整月金额(成本口径)。 */
|
|
147
|
+
readonly prev_total: number;
|
|
148
|
+
/** 上月同期(1 日到本月的 elapsed_days 日)金额;无数据时为 null。 */
|
|
149
|
+
readonly prev_same_period: number | null;
|
|
150
|
+
/**
|
|
151
|
+
* 环比。当月未走完时按**同期**比(上月同样天数),走完时按整月比 ——
|
|
152
|
+
* 否则会出现"2 天 vs 30 天 → 环比 -94%"这种看着像暴跌的误导数字。
|
|
153
|
+
*/
|
|
154
|
+
readonly mom_ratio: number | null;
|
|
155
|
+
/** 环比口径,页面必须显示,避免读者自己猜。 */
|
|
156
|
+
readonly mom_basis: 'same_days' | 'full_month';
|
|
157
|
+
readonly service_count: number;
|
|
158
|
+
readonly account_count: number;
|
|
159
|
+
readonly last_stat_date: string | null;
|
|
160
|
+
}
|
|
161
|
+
/** 趋势点。`forecast` 为 true 的点是推演值,不是账单事实。 */
|
|
162
|
+
export interface TrendPoint {
|
|
163
|
+
readonly label: string;
|
|
164
|
+
readonly amount: number;
|
|
165
|
+
readonly forecast?: true;
|
|
166
|
+
/**
|
|
167
|
+
* 这一档**没有数据**(不是花了 0)。
|
|
168
|
+
*
|
|
169
|
+
* 为什么必须区分:成本数据通常滞后一两天,日历上"最近两天"其实是还没出数的日子。
|
|
170
|
+
* 把它们画成 0,趋势图末尾就会出现一个"断崖式下跌",看起来像费用突然停了。
|
|
171
|
+
*/
|
|
172
|
+
readonly missing?: true;
|
|
173
|
+
}
|
|
174
|
+
export type TrendGranularity = 'day' | 'week' | 'month' | 'year';
|
|
175
|
+
export interface CostTrend {
|
|
176
|
+
readonly granularity: TrendGranularity;
|
|
177
|
+
readonly points: readonly TrendPoint[];
|
|
178
|
+
readonly unit: string;
|
|
179
|
+
/** 覆盖说明:日粒度下"数据截至哪天、还有几天没出数"。 */
|
|
180
|
+
readonly coverage_note?: string;
|
|
181
|
+
/**
|
|
182
|
+
* 为什么没有推演柱的一句话(只在"本该有、但数据不够"时出现)。
|
|
183
|
+
*
|
|
184
|
+
* 有了它,页面就不用自己猜:以前的说明是"粒度是月就说最后一个柱为推演值",
|
|
185
|
+
* 而本月只有一天数据时后端根本不推演 —— 文案于是在骗人。
|
|
186
|
+
*/
|
|
187
|
+
readonly forecast_note?: string;
|
|
188
|
+
}
|
|
189
|
+
/** 服务构成的一块。 */
|
|
190
|
+
export interface ServiceSlice {
|
|
191
|
+
readonly service_code: string;
|
|
192
|
+
readonly amount: number;
|
|
193
|
+
readonly ratio: number;
|
|
194
|
+
}
|
|
195
|
+
export interface CostByService {
|
|
196
|
+
readonly cycle: string;
|
|
197
|
+
readonly total: number;
|
|
198
|
+
readonly top: readonly ServiceSlice[];
|
|
199
|
+
readonly other: number;
|
|
200
|
+
readonly service_count: number;
|
|
201
|
+
/**
|
|
202
|
+
* 统计窗口的人话描述,例:`2026-11 全月` / `最近一天(2026-11-02)` / `本周(2026-W45)`。
|
|
203
|
+
*
|
|
204
|
+
* 为什么要有这个字段:服务构成会跟随趋势图的日/周/月切换改变统计窗口,
|
|
205
|
+
* 窗口变了金额就变。不把它写出来,用户切一下粒度就会以为数据错了。
|
|
206
|
+
*/
|
|
207
|
+
readonly window_label: string;
|
|
208
|
+
}
|
|
209
|
+
/** 按账号分摊的一行。 */
|
|
210
|
+
export interface AccountSlice {
|
|
211
|
+
readonly account_id: string;
|
|
212
|
+
readonly account_name: string;
|
|
213
|
+
readonly amount: number;
|
|
214
|
+
readonly ratio: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 费用分摊(**按账号**)。
|
|
218
|
+
*
|
|
219
|
+
* 2026-11-23 用户定稿:分摊只按账号,不再有 OU 维度 —— OU 树要在页面里另外维护,
|
|
220
|
+
* 而账号维度已经能回答"钱是哪个账号花的"。`/api/wb/cost/by-ou` 这个路径名是历史
|
|
221
|
+
* 遗留(客户端与宿主进程各自更新,改路径会让新页面在老宿主上直接 404),
|
|
222
|
+
* 返回的内容已经是纯账号行。
|
|
223
|
+
*/
|
|
224
|
+
export interface CostByAccount {
|
|
225
|
+
readonly cycle: string;
|
|
226
|
+
/** 统计窗口描述("2026 全年(截至 11-05)" / "最近一周(2026-W45)" 等)。 */
|
|
227
|
+
readonly window_label?: string;
|
|
228
|
+
readonly total: number;
|
|
229
|
+
readonly rows: readonly AccountSlice[];
|
|
230
|
+
}
|
|
231
|
+
/** 账户余额(账户口径,与成本口径不可相加)。 */
|
|
232
|
+
export interface AccountBalanceView {
|
|
233
|
+
readonly currency: string;
|
|
234
|
+
readonly balance: number;
|
|
235
|
+
readonly debt_amount: number;
|
|
236
|
+
readonly measure_id: number | null;
|
|
237
|
+
}
|
|
238
|
+
/** 月度汇总(账单口径,与成本口径不可相加)。 */
|
|
239
|
+
export interface MonthlySumView {
|
|
240
|
+
readonly cycle: string;
|
|
241
|
+
readonly total_count: number;
|
|
242
|
+
readonly consume_amount: number;
|
|
243
|
+
readonly cash_amount: number;
|
|
244
|
+
readonly debt_amount: number;
|
|
245
|
+
readonly coupon_amount: number;
|
|
246
|
+
readonly currency: string;
|
|
247
|
+
/** 按服务聚合后的前 8 项(不是接口原始行——原始行是账号×资源类型×计费模式)。 */
|
|
248
|
+
readonly services: readonly {
|
|
249
|
+
service_type_code: string;
|
|
250
|
+
amount: number;
|
|
251
|
+
}[];
|
|
252
|
+
/** 服务总数(去重后)。 */
|
|
253
|
+
readonly service_count: number;
|
|
254
|
+
/** 未列出的服务合计金额。 */
|
|
255
|
+
readonly other_amount: number;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* 年视图下 KPI 用的数字(与月度概览分开,不共用字段名)。
|
|
259
|
+
*
|
|
260
|
+
* 为什么不用 CostOverview 复用:那里的 elapsed_days / forecast_month_end 都是"月"的语义,
|
|
261
|
+
* 年视图里套用会让"月底推算"这种字眼出现在年度卡上,属于自相矛盾。
|
|
262
|
+
*/
|
|
263
|
+
export interface YearOverview {
|
|
264
|
+
readonly year: number;
|
|
265
|
+
/** 本年累计(截至最后有数据的一天)。 */
|
|
266
|
+
readonly total: number;
|
|
267
|
+
/** 有数据的天数(不是日历天数:本组织 2026 只有 8 月起有数据)。 */
|
|
268
|
+
readonly data_days: number;
|
|
269
|
+
/** 本年第一天有数据的日期;null = 本年还没有数据。 */
|
|
270
|
+
readonly first_data_date: string | null;
|
|
271
|
+
readonly last_stat_date: string | null;
|
|
272
|
+
/** 日均(按**完整**有数据的天数平均;今天未走完不计入分母)。 */
|
|
273
|
+
readonly daily_avg: number;
|
|
274
|
+
/** 完整的天数(剔掉"今天"这个未走完的日子)。 */
|
|
275
|
+
readonly complete_days: number;
|
|
276
|
+
/** 今天的实时累计;null = 数据没覆盖到今天。 */
|
|
277
|
+
readonly today_amount: number | null;
|
|
278
|
+
/** 年末推算(按有数据以来的速度外推);数据不足时 null。 */
|
|
279
|
+
readonly forecast_year_end: number | null;
|
|
280
|
+
/** 去年整年合计;去年取不到或为 0 时 null。 */
|
|
281
|
+
readonly prev_year_total: number | null;
|
|
282
|
+
/** 同比(相对去年整年);去年无数据时 null。 */
|
|
283
|
+
readonly yoy_ratio: number | null;
|
|
284
|
+
readonly currency: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* 日 / 周粒度的 KPI("最近一天""最近一周")。
|
|
288
|
+
*
|
|
289
|
+
* 为什么不复用月概览:切到「日」时如果 KPI 还写着"本月累计",同一屏就有两套时间口径。
|
|
290
|
+
* 这里只放"这一档"的数,以及它与前一档的环比、它占本月的比例。
|
|
291
|
+
*/
|
|
292
|
+
export interface PeriodOverview {
|
|
293
|
+
readonly granularity: 'day' | 'week';
|
|
294
|
+
/** 期间标签,例如 `最近一天(2026-11-04)` / `最近一周(2026-W45)`。 */
|
|
295
|
+
readonly label: string;
|
|
296
|
+
/** 该期间合计。 */
|
|
297
|
+
readonly total: number;
|
|
298
|
+
/** 期间内有数据的天数。 */
|
|
299
|
+
readonly days: number;
|
|
300
|
+
readonly daily_avg: number;
|
|
301
|
+
/**
|
|
302
|
+
* 是否包含"今天"这个还没走完的日子。
|
|
303
|
+
*
|
|
304
|
+
* 原始成本口径下锚点就是今天,这一档的合计会明显低于往常 —— 不标出来,
|
|
305
|
+
* 用户看到的就是「费用突然跌了一半」。
|
|
306
|
+
*/
|
|
307
|
+
readonly partial_today: boolean;
|
|
308
|
+
/** 对比的上一档标签,例如 `2026-11-03` / `2026-W44`。 */
|
|
309
|
+
readonly prev_label: string | null;
|
|
310
|
+
readonly prev_total: number | null;
|
|
311
|
+
/**
|
|
312
|
+
* 环比。
|
|
313
|
+
*
|
|
314
|
+
* 两套口径,由 `ratio_basis` 区分:
|
|
315
|
+
* - `full`:当期与上一档都完整,直接比(例如看的是 11-22 这一整天);
|
|
316
|
+
* - `projected`:当期还没走完(今天 / 本周),把上一档折算到**同样的时间进度**再比。
|
|
317
|
+
* 这不是"同一时刻的实测",是速率环比 —— 卡片必须写明"折算预期"与已过时间。
|
|
318
|
+
*/
|
|
319
|
+
readonly ratio: number | null;
|
|
320
|
+
/** 环比口径。 */
|
|
321
|
+
readonly ratio_basis: 'full' | 'projected';
|
|
322
|
+
/** 折算时的"今日已过分钟"(扣掉计量时延);不可折算为 null。 */
|
|
323
|
+
readonly elapsed_minutes: number | null;
|
|
324
|
+
/** 折算预期(与 `total` 同时间窗);不可折算为 null。 */
|
|
325
|
+
readonly expected_total: number | null;
|
|
326
|
+
/** 折算用的基准金额:日 = 基准日均;周 = 上周同期整日合计(含今日对应日整天)。 */
|
|
327
|
+
readonly baseline_total: number | null;
|
|
328
|
+
/** 基准说明,例如 `前一日` / `上周同期(2 个完整日 + 今日折算)`。 */
|
|
329
|
+
readonly baseline_label: string | null;
|
|
330
|
+
/** 该期间合计占本月(所选账期)的比例。 */
|
|
331
|
+
readonly month_share: number;
|
|
332
|
+
readonly month_total: number;
|
|
333
|
+
readonly currency: string;
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从「有账单的资源」推导官网单价(精确除法,不是估计)。
|
|
3
|
+
*
|
|
4
|
+
* 单价 = `official_amount ÷ 用量 ÷ (有量天数 / 30)`:
|
|
5
|
+
* · 云硬盘:用量 = size(GB) → ¥/GB/月
|
|
6
|
+
* · EIP 带宽:用量 = size(Mbps) → ¥/Mbps/月(钱在带宽 id 上,IP 上的行也可以)
|
|
7
|
+
*
|
|
8
|
+
* 同一 (种类, 区域, 规格) 取中位数,并把样本数写进表里 —— 单价可复核。
|
|
9
|
+
*
|
|
10
|
+
* @module @huaweidevtools/landingzone-workbench/cost/unit-prices-derive
|
|
11
|
+
*/
|
|
12
|
+
import type { CloudResource } from './evidence/inventory.ts';
|
|
13
|
+
import { readUnitPrices, type UnitPrice } from './unit-prices.ts';
|
|
14
|
+
/** 本账号能推导出来的单价(按种类/区域/规格聚合成一行)。 */
|
|
15
|
+
export declare function deriveUnitPricesForAccount(resources: readonly CloudResource[], officials: ReadonlyMap<string, number> | undefined, days: ReadonlyMap<string, number> | undefined): UnitPrice[];
|
|
16
|
+
export { readUnitPrices };
|
|
17
|
+
/** 回写(库不可用就静默跳过)。 */
|
|
18
|
+
export declare function writeUnitPricesSafely(rows: readonly UnitPrice[]): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=unit-prices-derive.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** 单价种类。 */
|
|
2
|
+
export type UnitKind = 'disk_gb' | 'bandwidth_mbps';
|
|
3
|
+
/** 一行单价。 */
|
|
4
|
+
export interface UnitPrice {
|
|
5
|
+
readonly kind: UnitKind;
|
|
6
|
+
readonly region: string;
|
|
7
|
+
/** 规格:盘类型(`SAS`)或带宽档(`5`)。 */
|
|
8
|
+
readonly spec: string;
|
|
9
|
+
/** 每单位每月(¥/GB/月、¥/Mbps/月)。 */
|
|
10
|
+
readonly value: number;
|
|
11
|
+
/** 这个单价由几个资源的官网价算出。 */
|
|
12
|
+
readonly samples: number;
|
|
13
|
+
/** 来源说明(resource_id 前缀 + 天数)。 */
|
|
14
|
+
readonly derived_from: string;
|
|
15
|
+
readonly updated_at: string;
|
|
16
|
+
}
|
|
17
|
+
/** 读全表(量很小,几十行,一次读进内存)。 */
|
|
18
|
+
export declare function readUnitPrices(): Promise<readonly UnitPrice[]>;
|
|
19
|
+
/** 写一批单价(同 (kind, region, spec) 覆盖;样本数变多才覆盖,避免被单次采集的坏样本冲掉)。 */
|
|
20
|
+
export declare function writeUnitPrices(rows: readonly UnitPrice[]): Promise<void>;
|
|
21
|
+
/** 查一个单价。 */
|
|
22
|
+
export declare function lookupUnitPrice(prices: readonly UnitPrice[], kind: UnitKind, region: string, spec: string): UnitPrice | null;
|
|
23
|
+
//# sourceMappingURL=unit-prices.d.ts.map
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
export interface WorkbenchDb {
|
|
3
|
+
readonly db: DatabaseSync;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
}
|
|
6
|
+
/** 打开(并缓存)当前登录账号的工作台库;首次调用执行迁移。 */
|
|
7
|
+
export declare function openWorkbenchDb(): Promise<WorkbenchDb>;
|
|
8
|
+
export interface SyncRunRow {
|
|
9
|
+
readonly run_id: number;
|
|
10
|
+
readonly status: 'running' | 'ok' | 'error';
|
|
11
|
+
readonly trigger: string;
|
|
12
|
+
readonly started_at: string;
|
|
13
|
+
readonly finished_at: string | null;
|
|
14
|
+
readonly error: string | null;
|
|
15
|
+
readonly stats: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** 写入 resources 的一行(入库前的内存形态)。 */
|
|
18
|
+
export interface ResourceRow {
|
|
19
|
+
readonly account_id: string;
|
|
20
|
+
readonly resource_id: string;
|
|
21
|
+
readonly provider: string;
|
|
22
|
+
readonly type: string;
|
|
23
|
+
readonly region_id: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly ep_id: string;
|
|
26
|
+
readonly created: string;
|
|
27
|
+
readonly tags_json: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SnapshotRow {
|
|
30
|
+
readonly account_id: string;
|
|
31
|
+
readonly total: number;
|
|
32
|
+
readonly managed: number;
|
|
33
|
+
readonly ep_total: number;
|
|
34
|
+
readonly ep_attributed: number;
|
|
35
|
+
}
|
|
36
|
+
/** 当天快照日期(本地时区 YYYY-MM-DD)。 */
|
|
37
|
+
export declare function todaySnap(): string;
|
|
38
|
+
/** 事务包装:fn 抛错则 ROLLBACK 并继续抛出。 */
|
|
39
|
+
export declare function withTransaction<T>(wb: WorkbenchDb, fn: () => T): T;
|
|
40
|
+
export declare function startRun(wb: WorkbenchDb, trigger: 'manual' | 'auto'): number;
|
|
41
|
+
export declare function finishRun(wb: WorkbenchDb, runId: number, status: 'ok' | 'error', statsJson: string, error?: string): void;
|
|
42
|
+
/** 上次成功同步存的探测标记(云上指纹 + 源代数;旧 stats 无指纹 → undefined)。 */
|
|
43
|
+
export interface StoredSyncMark {
|
|
44
|
+
readonly total: number;
|
|
45
|
+
readonly maxUpdated: string;
|
|
46
|
+
readonly sourcesGeneration: number;
|
|
47
|
+
}
|
|
48
|
+
export declare function readSyncFingerprint(wb: WorkbenchDb): StoredSyncMark | undefined;
|
|
49
|
+
export declare function queryLatestRun(wb: WorkbenchDb): SyncRunRow | null;
|
|
50
|
+
/** accounts 表的一行(last_seen_in_sync = 最近一次见到时的 run id)。 */
|
|
51
|
+
export interface AccountBookRow {
|
|
52
|
+
readonly account_id: string;
|
|
53
|
+
readonly account_name: string;
|
|
54
|
+
readonly ou_path: string;
|
|
55
|
+
readonly last_seen_in_sync: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 某次同步"在册"的账号(last_seen_in_sync = 该 run id)。
|
|
59
|
+
*
|
|
60
|
+
* churn(已删除账号对比)的基线用它而不是全表:同步覆盖范围会变(聚合器只盖部分
|
|
61
|
+
* 账号),老 run 见过、新 run 没见的账号多半是覆盖变化而非删除 —— 全表对比
|
|
62
|
+
* 会把它们误判成已删除。口径是"上次同步在册、当前名册没有"。
|
|
63
|
+
*/
|
|
64
|
+
export declare function queryAccountsSeenInRun(wb: WorkbenchDb, runId: number): readonly AccountBookRow[];
|
|
65
|
+
/** 最近一次成功 run 的 id;无则 null(churn 无基线)。 */
|
|
66
|
+
export declare function queryLatestOkRunId(wb: WorkbenchDb): number | null;
|
|
67
|
+
/** run id → 完成时间(把"最后在册于 run N"翻成人话时间用)。 */
|
|
68
|
+
export declare function queryRunFinishTimes(wb: WorkbenchDb): ReadonlyMap<number, string | null>;
|
|
69
|
+
/** 最近一次成功同步的完成时间(对比基线的时间锚);从未成功同步则 null。 */
|
|
70
|
+
export declare function queryLatestOkRunFinishedAt(wb: WorkbenchDb): string | null;
|
|
71
|
+
export declare function upsertAccount(wb: WorkbenchDb, accountId: string, accountName: string, runId: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* 就地补账号名(读路径自愈)。只补空名行,不触碰 last_seen_in_sync——那是
|
|
74
|
+
* 同步链路的语义,页面加载无权改写。场景:成员登录的 resource-accounts 轮
|
|
75
|
+
* 发现自己账号行空名(聚合器时代写入,聚合表无账号名),而 IAM 登录名就在
|
|
76
|
+
* 手里——落库后任何读取方都不再见空名。幂等:名字非空即短路。
|
|
77
|
+
*/
|
|
78
|
+
export declare function backfillAccountName(wb: WorkbenchDb, accountId: string, accountName: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* 幂等 upsert 资源行。字段按"非空才覆盖"合并;ep_id 例外:'0'(未归集)
|
|
81
|
+
* 是有效覆盖值(直查/委托行视为"归属已核对"),空串(聚合器行)不覆盖。
|
|
82
|
+
* managed 每轮先归零,随后由 markManaged 回填。
|
|
83
|
+
*/
|
|
84
|
+
export declare function upsertResources(wb: WorkbenchDb, rows: readonly ResourceRow[], runId: number): void;
|
|
85
|
+
export declare function upsertTfEntries(wb: WorkbenchDb, entries: readonly {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly tf_type: string;
|
|
88
|
+
readonly tf_name: string;
|
|
89
|
+
readonly file: string;
|
|
90
|
+
}[], runId: number): void;
|
|
91
|
+
/** 回填 managed:本轮现存(last_seen = runId)且 ID 在 tfstate 中的资源置 1。 */
|
|
92
|
+
export declare function markManaged(wb: WorkbenchDb, tfIds: ReadonlySet<string>, runId: number): void;
|
|
93
|
+
export declare function writeSnapshots(wb: WorkbenchDb, snapDate: string, rows: readonly SnapshotRow[]): void;
|
|
94
|
+
/** 本轮现存的按账号合计(写快照与 stats 的统一出处;focused=关注服务过滤,口径与页面一致)。 */
|
|
95
|
+
export declare function queryPerAccountTotals(wb: WorkbenchDb, runId: number, focused?: readonly string[]): {
|
|
96
|
+
account_id: string;
|
|
97
|
+
total: number;
|
|
98
|
+
managed: number;
|
|
99
|
+
}[];
|
|
100
|
+
/** 归集分子分母:ep_id != '' 即"归属数据已覆盖"的行(主账号/委托直查行);
|
|
101
|
+
* 聚合器标识行 ep_id 为空串自动排除——未接通委托的账号不进分母也不拉低比率。
|
|
102
|
+
* accountId 省略 = 全部已覆盖账号。 */
|
|
103
|
+
export declare function queryEpStats(wb: WorkbenchDb, runId: number, accountId?: string, focused?: readonly string[]): {
|
|
104
|
+
ep_total: number;
|
|
105
|
+
ep_attributed: number;
|
|
106
|
+
};
|
|
107
|
+
/** 关注服务列表(统计范围);空数组 = 不过滤(计入全部服务)。 */
|
|
108
|
+
export declare function getFocusedProviders(wb: WorkbenchDb): string[];
|
|
109
|
+
export declare function setFocusedProviders(wb: WorkbenchDb, providers: readonly string[]): void;
|
|
110
|
+
/**
|
|
111
|
+
* 读排名图目标参考线(1~100 整数)。库内未配置或值脏时回
|
|
112
|
+
* DEFAULT_* 常量——读到缺省即"还没改过",无需迁移种子。
|
|
113
|
+
*/
|
|
114
|
+
export declare function getMetricTargets(wb: WorkbenchDb): {
|
|
115
|
+
coverage_target: number;
|
|
116
|
+
ep_target: number;
|
|
117
|
+
};
|
|
118
|
+
/** 写目标线(入参须为 1~100 整数;校验在路由层)。 */
|
|
119
|
+
export declare function setMetricTargets(wb: WorkbenchDb, coverage: number, ep: number): void;
|
|
120
|
+
/** 当前本地源代数:数据源 add/delete/toggle 都 +1,纳入刷新指纹
|
|
121
|
+
* (2026-11-10 修复:删源后点刷新因云上指纹未变而被探测跳过,managed 未重算)。 */
|
|
122
|
+
export declare function readSourcesGeneration(wb: WorkbenchDb): number;
|
|
123
|
+
export declare function bumpSourcesGeneration(wb: WorkbenchDb): void;
|
|
124
|
+
/** tfstate 数据源一行。 */
|
|
125
|
+
export interface TfSource {
|
|
126
|
+
readonly id: number;
|
|
127
|
+
readonly kind: 'local' | 'obs';
|
|
128
|
+
readonly path: string;
|
|
129
|
+
readonly account_id: string;
|
|
130
|
+
readonly label: string;
|
|
131
|
+
readonly enabled: boolean;
|
|
132
|
+
}
|
|
133
|
+
export declare function listTfSources(wb: WorkbenchDb): TfSource[];
|
|
134
|
+
export declare function addTfSource(wb: WorkbenchDb, kind: 'local' | 'obs', path: string, accountId: string, label: string): number;
|
|
135
|
+
export declare function deleteTfSource(wb: WorkbenchDb, id: number): void;
|
|
136
|
+
export declare function setTfSourceEnabled(wb: WorkbenchDb, id: number, enabled: boolean): void;
|
|
137
|
+
export declare function upsertEpProjects(wb: WorkbenchDb, list: readonly {
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
}[]): void;
|
|
141
|
+
export interface SummaryData {
|
|
142
|
+
readonly has_data: boolean;
|
|
143
|
+
readonly latest_run: SyncRunRow | null;
|
|
144
|
+
/** 查看范围:'*' = 组织聚合;否则为账号 domain_id(口径切换)。 */
|
|
145
|
+
readonly account_id: string;
|
|
146
|
+
/** 范围为具体账号时的账号名(组织聚合为空串)。 */
|
|
147
|
+
readonly account_name: string;
|
|
148
|
+
readonly total: number;
|
|
149
|
+
readonly managed: number;
|
|
150
|
+
readonly unmanaged: number;
|
|
151
|
+
readonly coverage: number | null;
|
|
152
|
+
readonly account_count: number;
|
|
153
|
+
readonly ep_total: number;
|
|
154
|
+
readonly ep_attributed: number;
|
|
155
|
+
readonly ep_rate: number | null;
|
|
156
|
+
readonly delta_total: number | null;
|
|
157
|
+
readonly snap_date: string | null;
|
|
158
|
+
}
|
|
159
|
+
/** 汇总三指标:数据锚定最近一次成功 run;delta 取前一个快照日。
|
|
160
|
+
* scopeAccountId='*' 组织聚合;传账号 id 则按该账号口径(快照/资源均按账号存)。 */
|
|
161
|
+
export declare function querySummary(wb: WorkbenchDb, scopeAccountId?: string): SummaryData;
|
|
162
|
+
export interface AccountStat {
|
|
163
|
+
readonly account_id: string;
|
|
164
|
+
readonly account_name: string;
|
|
165
|
+
readonly total: number;
|
|
166
|
+
readonly managed: number;
|
|
167
|
+
readonly coverage: number | null;
|
|
168
|
+
readonly ep_total: number;
|
|
169
|
+
readonly ep_attributed: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 账号维度合计(排名柱状图数据源;纳管率在侧计算)。
|
|
173
|
+
* 归集分子分母按"归属数据已覆盖"聚合(ep_id != '':主账号/委托直查行);
|
|
174
|
+
* 未接通委托的账号 ep_total=0 → ep_rate 为 null,不拉低比率。
|
|
175
|
+
*/
|
|
176
|
+
export declare function queryAccounts(wb: WorkbenchDb, focused?: readonly string[]): AccountStat[];
|
|
177
|
+
export interface TrendPoint {
|
|
178
|
+
readonly snap_date: string;
|
|
179
|
+
readonly total: number;
|
|
180
|
+
readonly managed: number;
|
|
181
|
+
readonly ep_rate: number | null;
|
|
182
|
+
}
|
|
183
|
+
/** 近 N 天快照序列(指定账号或 '*' 汇总行,升序)。 */
|
|
184
|
+
export declare function queryTrend(wb: WorkbenchDb, days: number, scopeAccountId?: string): TrendPoint[];
|
|
185
|
+
export interface ResourceListParams {
|
|
186
|
+
readonly account_id: string;
|
|
187
|
+
/** true = 应用关注服务过滤(与汇总口径一致);默认 false = 全量。 */
|
|
188
|
+
readonly focused?: boolean;
|
|
189
|
+
/** 多选:provider IN;空/缺省 = 不筛。 */
|
|
190
|
+
readonly providers?: readonly string[];
|
|
191
|
+
/** 多选:资源类型 IN;空/缺省 = 不筛。 */
|
|
192
|
+
readonly types?: readonly string[];
|
|
193
|
+
/** 多选:区域 IN;空/缺省 = 不筛。 */
|
|
194
|
+
readonly regions?: readonly string[];
|
|
195
|
+
readonly managed?: boolean;
|
|
196
|
+
/** 多选:'none' = 未归集,其余为 ep_id 精确匹配;空/缺省 = 不筛。 */
|
|
197
|
+
readonly eps?: readonly string[];
|
|
198
|
+
readonly q?: string;
|
|
199
|
+
readonly page: number;
|
|
200
|
+
readonly page_size: number;
|
|
201
|
+
}
|
|
202
|
+
export interface ResourceListResult {
|
|
203
|
+
readonly total: number;
|
|
204
|
+
readonly page: number;
|
|
205
|
+
readonly page_size: number;
|
|
206
|
+
readonly rows: readonly {
|
|
207
|
+
readonly account_id: string;
|
|
208
|
+
readonly resource_id: string;
|
|
209
|
+
readonly provider: string;
|
|
210
|
+
readonly type: string;
|
|
211
|
+
readonly region_id: string;
|
|
212
|
+
readonly name: string;
|
|
213
|
+
readonly ep_id: string;
|
|
214
|
+
/** 企业项目名(ep_projects join;缺失 = 空串,前端回退显示 id)。 */
|
|
215
|
+
readonly ep_name: string;
|
|
216
|
+
readonly created: string;
|
|
217
|
+
readonly managed: boolean;
|
|
218
|
+
}[];
|
|
219
|
+
readonly facets: {
|
|
220
|
+
readonly providers: string[];
|
|
221
|
+
readonly types: string[];
|
|
222
|
+
readonly regions: string[];
|
|
223
|
+
readonly eps: string[];
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/** 子账号明细(M2):服务端分页 + 筛选取值。 */
|
|
227
|
+
export declare function queryResourceList(wb: WorkbenchDb, p: ResourceListParams): ResourceListResult;
|
|
228
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** WARN 级运行期告警(可恢复的失败:回源失败、缓存写失败、能力降级)。 */
|
|
2
|
+
export declare function hostWarn(message: string): void;
|
|
3
|
+
/** ERROR 级运行期错误(用户操作失败:写路由失败、同步失败)。 */
|
|
4
|
+
export declare function hostError(message: string): void;
|
|
5
|
+
/** 截断工具:错误原文只记前 n 字符,防单条日志吞掉整个文件。 */
|
|
6
|
+
export declare function brief(err: unknown, n?: number): string;
|
|
7
|
+
//# sourceMappingURL=host-log.d.ts.map
|