Initial project source
这个提交包含在:
@@ -0,0 +1,84 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
CreatePolicyCommand,
|
||||
PolicyStatusCommand,
|
||||
PolicyVO,
|
||||
PurposeCommand,
|
||||
UpdatePolicyCommand,
|
||||
VerificationCommand,
|
||||
VerificationVO,
|
||||
WriteResult
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/governance/v1/access-controls';
|
||||
const writeHeaders = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
type RequestOptions = { suppressErrorToast?: boolean };
|
||||
|
||||
export const listAccessControlPolicies = (options: RequestOptions = {}): AxiosPromise<PolicyVO[]> =>
|
||||
request({ ...options, url: baseUrl, method: 'get' });
|
||||
|
||||
export const getAccessControlPolicy = (policyId: number, options: RequestOptions = {}): AxiosPromise<PolicyVO> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}`, method: 'get' });
|
||||
|
||||
export const createAccessControlPolicy = (
|
||||
data: CreatePolicyCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: baseUrl, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateAccessControlPolicy = (
|
||||
policyId: number,
|
||||
data: UpdatePolicyCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const deleteAccessControlPolicy = (policyId: number, version: number, key: string, options: RequestOptions = {}): AxiosPromise<void> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}`, method: 'delete', params: { version }, headers: writeHeaders(key) });
|
||||
|
||||
export const changeAccessControlPolicyStatus = (
|
||||
policyId: number,
|
||||
data: PolicyStatusCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/status`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateAccessControlPurpose = (
|
||||
policyId: number,
|
||||
data: PurposeCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/purpose`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const registerAccessControlEvidence = (
|
||||
policyId: number,
|
||||
data: VerificationCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<VerificationVO>> =>
|
||||
request({
|
||||
url: `${baseUrl}/${policyId}/enforcement-evidence`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(key)
|
||||
});
|
||||
|
||||
export const getAccessControlVerification = (
|
||||
policyId: number,
|
||||
verificationId: number,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<VerificationVO> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/verifications/${verificationId}`, method: 'get' });
|
||||
|
||||
export const listAccessControlVerifications = (policyId: number, options: RequestOptions = {}): AxiosPromise<VerificationVO[]> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/verifications`, method: 'get' });
|
||||
|
||||
export const searchAccessControlSubjects = (subjectType: import('./types').SubjectType, keyword?: string, options: RequestOptions = {}): AxiosPromise<import('./types').SubjectCandidate[]> =>
|
||||
request({ ...options, url: `${baseUrl}/subject-candidates`, method: 'get', params: { subjectType, keyword } });
|
||||
|
||||
export const searchAccessControlSources = (keyword?: string, options: RequestOptions = {}): AxiosPromise<import('./types').SecuritySourceCandidate[]> =>
|
||||
request({ ...options, url: `${baseUrl}/source-candidates`, method: 'get', params: { keyword } });
|
||||
@@ -0,0 +1,117 @@
|
||||
export type PolicyStatus = 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'ARCHIVED';
|
||||
export type ExecutionStatus = 'REGISTERED' | 'NOT_ENFORCED' | 'ENFORCED' | 'UNSUPPORTED';
|
||||
export type SubjectType = 'USER' | 'ROLE' | 'DEPARTMENT';
|
||||
export type EngineType = 'HIVE' | 'DORIS' | 'MYSQL' | 'MARIADB' | 'POSTGRESQL' | 'SQLSERVER' | 'DAMENG' | 'ORACLE';
|
||||
export type EnforcementUnit =
|
||||
| 'PLATFORM_QUERY'
|
||||
| 'HIVE_TABLE_SELECT'
|
||||
| 'HIVE_PROTECTED_EXPORT'
|
||||
| 'HIVE_COLUMN_SELECT'
|
||||
| 'HIVE_ROW_FILTER'
|
||||
| 'HIVE_MASKING'
|
||||
| 'DORIS_TENANT_ROW_POLICY'
|
||||
| 'DORIS_COLUMN_SELECT'
|
||||
| 'DORIS_MASKING';
|
||||
export type AccessAction = 'SELECT' | 'EXPORT';
|
||||
export type RowOperator = 'EQUALS' | 'NOT_EQUALS' | 'IN' | 'NOT_IN' | 'IS_NULL' | 'IS_NOT_NULL';
|
||||
export type EvidenceKind = 'DISPATCH' | 'READBACK' | 'ALLOW' | 'DENY';
|
||||
export type EvidenceOutcome = 'DISPATCHED' | 'MATCHED' | 'ALLOWED' | 'DENIED';
|
||||
|
||||
export interface RowCondition {
|
||||
fieldRef: string;
|
||||
operator: RowOperator;
|
||||
valueRef?: string;
|
||||
}
|
||||
|
||||
export interface PurposeConstraint {
|
||||
purposeCode: string;
|
||||
scenarioRef: string;
|
||||
scopeRef: string;
|
||||
validFrom: string;
|
||||
validUntil: string;
|
||||
allowedActions: AccessAction[];
|
||||
}
|
||||
|
||||
export interface CreatePolicyCommand {
|
||||
policyCode: string;
|
||||
policyName: string;
|
||||
subjectType: SubjectType;
|
||||
subjectRef: string;
|
||||
engineType: EngineType;
|
||||
enforcementUnit: EnforcementUnit;
|
||||
resourceRef: string;
|
||||
actions: AccessAction[];
|
||||
rowConditions: RowCondition[];
|
||||
columnRefs: string[];
|
||||
purpose: PurposeConstraint;
|
||||
}
|
||||
|
||||
export interface UpdatePolicyCommand extends Omit<CreatePolicyCommand, 'policyCode'> {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PolicyStatusCommand {
|
||||
targetStatus: PolicyStatus;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PurposeCommand {
|
||||
purpose: PurposeConstraint;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface EnforcementEvidence {
|
||||
kind: EvidenceKind;
|
||||
outcome: EvidenceOutcome;
|
||||
evidenceRef: string;
|
||||
externalPolicyRef: string;
|
||||
observedAt: string;
|
||||
reliable: boolean;
|
||||
snapshotSha256: string;
|
||||
}
|
||||
|
||||
export interface VerificationCommand {
|
||||
policyVersion: number;
|
||||
evidence: EnforcementEvidence[];
|
||||
}
|
||||
|
||||
export interface PolicyVO extends CreatePolicyCommand {
|
||||
policyId: number;
|
||||
policyStatus: PolicyStatus;
|
||||
executionStatus: ExecutionStatus;
|
||||
executionReason?: string;
|
||||
organizationId: number;
|
||||
departmentId: number;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface VerificationVO {
|
||||
verificationId: number;
|
||||
policyId: number;
|
||||
policyVersion: number;
|
||||
executionStatus: ExecutionStatus;
|
||||
reasonCode?: string;
|
||||
snapshotSha256?: string;
|
||||
evidence: EnforcementEvidence[];
|
||||
verifiedAt?: string;
|
||||
}
|
||||
|
||||
export interface WriteResult<T> {
|
||||
requestId: string;
|
||||
result: T;
|
||||
}
|
||||
|
||||
export interface SubjectCandidate { subjectRef: string; subjectType: SubjectType; label: string }
|
||||
|
||||
export interface SecuritySourceCandidate {
|
||||
reference: string;
|
||||
tableId: string;
|
||||
label: string;
|
||||
engineType: EngineType;
|
||||
sourceVersion: number;
|
||||
metadataRevision: number;
|
||||
fields: Array<{ reference: string; name: string; type: string; restricted: boolean }>;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const { request } = vi.hoisted(() => ({ request: vi.fn() }));
|
||||
vi.mock('@/utils/request', () => ({ default: request }));
|
||||
|
||||
import { listAiCandidates } from './index';
|
||||
|
||||
describe('AI governance candidate contract', () => {
|
||||
beforeEach(() => request.mockReset());
|
||||
|
||||
it('requests only the supported type with bounded search parameters', async () => {
|
||||
request.mockResolvedValue({ data: [{ label: '规则 · db.table', targetRef: 'quality-rule:7', objectType: 'QUALITY_RULE' }] });
|
||||
await listAiCandidates('QUALITY_RULE', 'table', 20);
|
||||
expect(request).toHaveBeenCalledWith(expect.objectContaining({
|
||||
url: '/api/governance/v1/ai-suggestions/candidates', method: 'get',
|
||||
params: { type: 'QUALITY_RULE', keyword: 'table', limit: 20 }, suppressErrorToast: true
|
||||
}));
|
||||
});
|
||||
|
||||
it('preserves the server targetRef instead of constructing an internal id', async () => {
|
||||
const response = { label: '可靠快照 · doris', targetRef: 'metadata:91', objectType: 'METADATA_ENRICHMENT' };
|
||||
request.mockResolvedValue({ data: [response] });
|
||||
const result = await listAiCandidates('METADATA_ENRICHMENT');
|
||||
expect(result.data[0]).toEqual(response);
|
||||
expect(result.data[0].targetRef).toBe('metadata:91');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface FormAssistField { key: string; label: string; maxLength: number }
|
||||
export interface FormAssistSchema { page: { id: string; title: string; fields: FormAssistField[] }; enabled: boolean }
|
||||
export interface FormAssistResult { requestId: string; state: string; answer?: string; candidate: Record<string, string>; code: string }
|
||||
const base = '/api/integration/v1/ai/form-assistance';
|
||||
export const formAssistSchema = (page: string): AxiosPromise<FormAssistSchema> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}`, method: 'get', suppressErrorToast: true });
|
||||
export const generateFormCandidate = (page: string, data: { requestId: string; prompt: string; values: Record<string, string> }, signal: AbortSignal): AxiosPromise<FormAssistResult> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}`, method: 'post', data, signal, timeout: 75000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,115 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const { request } = vi.hoisted(() => ({
|
||||
request: vi.fn((config: unknown) => Promise.resolve({ data: config }))
|
||||
}));
|
||||
vi.mock('@/utils/request', () => ({ default: request }));
|
||||
|
||||
import { generateAiSuggestion, listAiCandidates, listAiSuggestions, updateAiProvider } from './index';
|
||||
|
||||
describe('AI assistant request security', () => {
|
||||
beforeEach(() => request.mockClear());
|
||||
|
||||
it('never writes an API Key request into the repeat-submit session cache', async () => {
|
||||
await updateAiProvider({
|
||||
enabled: true,
|
||||
providerType: 'OPENAI_COMPATIBLE',
|
||||
model: 'model-1',
|
||||
endpoint: 'https://provider.example/v1',
|
||||
apiKey: 'temporary-test-key',
|
||||
revokeApiKey: false,
|
||||
timeoutSeconds: 20,
|
||||
version: 0
|
||||
});
|
||||
|
||||
expect(request).toHaveBeenCalledWith(expect.objectContaining({
|
||||
method: 'put',
|
||||
headers: { repeatSubmit: false }
|
||||
}));
|
||||
});
|
||||
|
||||
it('does not send client evidence authorization assertions to Governance', async () => {
|
||||
await generateAiSuggestion('quality-rule', {
|
||||
objectType: 'QUALITY_RULE',
|
||||
objectId: 'quality-rule:1',
|
||||
purpose: '生成审查建议',
|
||||
evidenceRefs: ['client-value-must-not-be-trusted']
|
||||
}, 'request-12345678');
|
||||
|
||||
const config = request.mock.calls[0][0] as { data: Record<string, unknown>; headers: Record<string, unknown> };
|
||||
expect(config.data).toEqual({
|
||||
requestId: 'request-12345678',
|
||||
type: 'QUALITY_RULE',
|
||||
targetRef: 'quality-rule:1',
|
||||
context: '生成审查建议'
|
||||
});
|
||||
expect(config.headers).toEqual({ repeatSubmit: false });
|
||||
});
|
||||
|
||||
it('loads standard governance workflow candidates from the server evidence owner', async () => {
|
||||
await listAiCandidates('GOVERNANCE_WORKFLOW', 'STD', 10);
|
||||
|
||||
expect(request).toHaveBeenCalledWith({
|
||||
url: '/api/governance/v1/ai-suggestions/candidates',
|
||||
method: 'get',
|
||||
params: { type: 'GOVERNANCE_WORKFLOW', keyword: 'STD', limit: 10 },
|
||||
suppressErrorToast: true
|
||||
});
|
||||
});
|
||||
|
||||
it('sends DataOps evidence references without client authorization or summary facts', async () => {
|
||||
await generateAiSuggestion('sql-processing', {
|
||||
objectType: 'TABLE',
|
||||
objectId: 'DORIS_SALES.product',
|
||||
purpose: '检查只读SQL',
|
||||
evidenceRefs: ['table-file:1'],
|
||||
tableFileId: 1,
|
||||
sqlDraft: 'SELECT * FROM DORIS_SALES.product',
|
||||
processingDraft: '只读检查'
|
||||
}, 'request-12345678');
|
||||
|
||||
const config = request.mock.calls[0][0] as { data: { evidence: Array<Record<string, unknown>> } };
|
||||
expect(config.data.evidence).toEqual([{ reference: 'table-file:1', kind: 'METADATA' }]);
|
||||
});
|
||||
|
||||
it('loads and normalizes persisted drafts from both business services', async () => {
|
||||
request
|
||||
.mockResolvedValueOnce({
|
||||
data: [{
|
||||
suggestionId: 1,
|
||||
type: 'QUALITY_RULE',
|
||||
proposal: '',
|
||||
rationale: '证据不足',
|
||||
failureCode: 'EVIDENCE_INSUFFICIENT',
|
||||
state: 'DRAFT',
|
||||
createTime: '2026-10-07T20:00:00'
|
||||
}]
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
data: {
|
||||
rows: [{
|
||||
suggestionId: 2,
|
||||
title: 'SQL建议',
|
||||
status: 'DRAFT',
|
||||
createdAt: '2026-10-07T20:01:00',
|
||||
evidence: [{ reference: 'table-file:1' }]
|
||||
}],
|
||||
total: 1
|
||||
}
|
||||
});
|
||||
|
||||
const rows = await listAiSuggestions();
|
||||
|
||||
expect(rows.map((item) => item.suggestionId)).toEqual([2, 1]);
|
||||
expect(rows[0]).toEqual(expect.objectContaining({
|
||||
assistantType: 'sql-processing',
|
||||
evidenceRefs: ['table-file:1']
|
||||
}));
|
||||
expect(rows[1]).toEqual(expect.objectContaining({
|
||||
assistantType: 'quality-rule',
|
||||
summary: '证据不足',
|
||||
status: 'FAILED',
|
||||
code: 'EVIDENCE_INSUFFICIENT'
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,148 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AiAssistantType,
|
||||
AiProviderCommand,
|
||||
AiProviderVerifyVO,
|
||||
AiProviderVO,
|
||||
AiSuggestionCommand,
|
||||
AiSuggestionPage,
|
||||
AiSuggestionVO,
|
||||
AiSuggestionCandidate
|
||||
} from './types';
|
||||
|
||||
const providerUrl = '/api/integration/v1/ai/providers/current';
|
||||
const governanceTypes: Record<Exclude<AiAssistantType, 'sql-processing'>, string> = {
|
||||
'governance-flow': 'GOVERNANCE_WORKFLOW',
|
||||
'fault-diagnosis': 'FAILURE_DIAGNOSIS',
|
||||
'metadata-enrichment': 'METADATA_ENRICHMENT',
|
||||
'standard-match': 'STANDARD_MATCH',
|
||||
'quality-rule': 'QUALITY_RULE'
|
||||
};
|
||||
const governanceAssistantTypes = Object.fromEntries(
|
||||
Object.entries(governanceTypes).map(([assistantType, suggestionType]) => [suggestionType, assistantType])
|
||||
) as Record<string, Exclude<AiAssistantType, 'sql-processing'>>;
|
||||
|
||||
const normalizeGovernanceSuggestion = (item: any): AiSuggestionVO => ({
|
||||
...item,
|
||||
assistantType: governanceAssistantTypes[item.type],
|
||||
title: item.proposal ? '治理辅助建议' : undefined,
|
||||
summary: item.proposal || item.rationale,
|
||||
impactScope: item.impact,
|
||||
status: item.failureCode ? 'FAILED' : item.state,
|
||||
code: item.failureCode,
|
||||
createTime: item.createTime
|
||||
});
|
||||
|
||||
const normalizeDataOpsSuggestion = (item: any): AiSuggestionVO => ({
|
||||
...item,
|
||||
assistantType: 'sql-processing',
|
||||
impactScope: item.impactSummary,
|
||||
status: item.status,
|
||||
code: item.errorCode,
|
||||
createTime: item.createdAt,
|
||||
evidenceRefs: item.evidence?.map((evidence: any) => evidence.reference) || []
|
||||
});
|
||||
|
||||
export const getAiProvider = (): AxiosPromise<AiProviderVO> => request({ url: providerUrl, method: 'get' });
|
||||
export const updateAiProvider = async (data: AiProviderCommand): AxiosPromise<AiProviderVO> => {
|
||||
const response = await request({ url: providerUrl, method: 'put', data, headers: { repeatSubmit: false } });
|
||||
window.dispatchEvent(new CustomEvent('datagov-ai-provider-changed', { detail: { enabled: response.data.enabled === true } }));
|
||||
return response;
|
||||
};
|
||||
export const verifyAiProvider = (): AxiosPromise<AiProviderVerifyVO> =>
|
||||
request({ url: `${providerUrl}/verify`, method: 'post', suppressErrorToast: true });
|
||||
export function listAiCandidates(type: 'QUALITY_RULE' | 'METADATA_ENRICHMENT' | 'GOVERNANCE_WORKFLOW', keyword = '', limit = 20): AxiosPromise<AiSuggestionCandidate[]> {
|
||||
return request({ url: '/api/governance/v1/ai-suggestions/candidates', method: 'get', params: { type, keyword, limit }, suppressErrorToast: true });
|
||||
}
|
||||
|
||||
export async function listAiSuggestions(): Promise<AiSuggestionVO[]> {
|
||||
const [governance, dataops] = await Promise.allSettled([
|
||||
request({ url: '/api/governance/v1/ai-suggestions', method: 'get', suppressErrorToast: true }) as AxiosPromise<any[]>,
|
||||
request({
|
||||
url: '/api/dataops/v1/ai-assistant/sql-processing/suggestions',
|
||||
method: 'get',
|
||||
params: { pageNum: 1, pageSize: 100 },
|
||||
suppressErrorToast: true
|
||||
}) as AxiosPromise<AiSuggestionPage>
|
||||
]);
|
||||
if (governance.status === 'rejected' && dataops.status === 'rejected') {
|
||||
throw new Error('AI_SUGGESTION_LIST_UNAVAILABLE');
|
||||
}
|
||||
const governanceRows = governance.status === 'fulfilled'
|
||||
? (governance.value.data || []).map(normalizeGovernanceSuggestion) : [];
|
||||
const dataOpsRows = dataops.status === 'fulfilled'
|
||||
? (dataops.value.data?.rows || []).map(normalizeDataOpsSuggestion) : [];
|
||||
return [...governanceRows, ...dataOpsRows].toSorted((left, right) =>
|
||||
(right.createTime || '').localeCompare(left.createTime || ''));
|
||||
}
|
||||
|
||||
export function generateAiSuggestion(
|
||||
type: AiAssistantType,
|
||||
data: AiSuggestionCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AiSuggestionVO> {
|
||||
if (type !== 'sql-processing') {
|
||||
return request({
|
||||
url: '/api/governance/v1/ai-suggestions',
|
||||
method: 'post',
|
||||
data: {
|
||||
requestId: idempotencyKey,
|
||||
type: governanceTypes[type],
|
||||
targetRef: data.objectId,
|
||||
context: data.purpose
|
||||
},
|
||||
headers: { repeatSubmit: false },
|
||||
suppressErrorToast: true
|
||||
}).then((response: any) => ({
|
||||
...response,
|
||||
data: normalizeGovernanceSuggestion(response.data)
|
||||
}));
|
||||
}
|
||||
return request({
|
||||
url: '/api/dataops/v1/ai-assistant/sql-processing/suggestions',
|
||||
method: 'post',
|
||||
data: {
|
||||
requestId: idempotencyKey,
|
||||
objectRef: data.objectId,
|
||||
objectType: data.objectType,
|
||||
instruction: data.purpose,
|
||||
sqlDraft: data.sqlDraft,
|
||||
processingDraft: data.processingDraft,
|
||||
tableFileId: data.tableFileId,
|
||||
evidence: data.evidenceRefs.map((reference) => ({
|
||||
reference,
|
||||
kind: 'METADATA'
|
||||
}))
|
||||
},
|
||||
headers: { 'Idempotency-Key': idempotencyKey, repeatSubmit: false },
|
||||
suppressErrorToast: true
|
||||
}).then((response: any) => ({
|
||||
...response,
|
||||
data: normalizeDataOpsSuggestion(response.data)
|
||||
}));
|
||||
}
|
||||
|
||||
export function adoptAiSuggestion(unit: 'governance' | 'dataops', id: number, version: number, idempotencyKey: string) {
|
||||
const url = unit === 'governance'
|
||||
? `/api/governance/v1/ai-suggestions/${id}/adopt`
|
||||
: `/api/dataops/v1/ai-assistant/sql-processing/suggestions/${id}/adopt`;
|
||||
return request({
|
||||
url,
|
||||
method: 'post',
|
||||
data: unit === 'governance' ? { version } : { version, reason: '用户在AI辅助建议页显式采纳' },
|
||||
headers: unit === 'dataops' ? { 'Idempotency-Key': idempotencyKey, repeatSubmit: false } : undefined
|
||||
});
|
||||
}
|
||||
|
||||
export function ignoreAiSuggestion(unit: 'governance' | 'dataops', id: number, version: number, idempotencyKey: string) {
|
||||
const url = unit === 'governance'
|
||||
? `/api/governance/v1/ai-suggestions/${id}/ignore`
|
||||
: `/api/dataops/v1/ai-assistant/sql-processing/suggestions/${id}/ignore`;
|
||||
return request({
|
||||
url,
|
||||
method: 'post',
|
||||
data: unit === 'governance' ? { version } : { version, reason: '用户在AI辅助建议页显式忽略' },
|
||||
headers: unit === 'dataops' ? { 'Idempotency-Key': idempotencyKey, repeatSubmit: false } : undefined
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface MetadataGraphSelection { pageId: 'P27' | 'P28'; snapshotId: string; mode: 'RELATIONS' | 'TRACE' | 'IMPACT'; fromId: string; toId?: string }
|
||||
export interface MetadataGraphNode { key: string; label: string; type: string }
|
||||
export interface MetadataGraphFact { key: string; kind: string; fromKey: string; toKey: string | null; fromField: string | null; toField: string | null; distance: number | null }
|
||||
export interface MetadataGraphContext { pageId: string; snapshotId: string; mode: string; observedAt: string | null; truncated: boolean; scopeNote: string; nodes: MetadataGraphNode[]; facts: MetadataGraphFact[]; contextSha256: string }
|
||||
export interface MetadataGraphFinding { explanation: string; evidenceKeys: string[]; reviewHint: string }
|
||||
export interface MetadataGraphResult { requestId: string; state: string; answer: string | null; findings: MetadataGraphFinding[]; code: string | null }
|
||||
export const metadataGraphContext = (data: MetadataGraphSelection, signal?: AbortSignal): AxiosPromise<MetadataGraphContext> => request({ url: '/api/governance/v1/metadata-graph-assist/context', method: 'post', data, signal });
|
||||
export const explainMetadataGraph = (data: { requestId: string; selection: MetadataGraphSelection; contextSha256: string; factKeys: string[]; prompt: string }, signal?: AbortSignal): AxiosPromise<MetadataGraphResult> => request({ url: '/api/integration/v1/ai/metadata-graph/explain', method: 'post', data, signal, timeout: 180000 });
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
|
||||
export interface AiProviderNetworkPolicy {
|
||||
publicEndpointsAllowed: boolean;
|
||||
privateEndpoints: string[];
|
||||
httpsRequired: boolean;
|
||||
}
|
||||
|
||||
export const getAiProviderNetworkPolicy = (): AxiosPromise<AiProviderNetworkPolicy> =>
|
||||
request({ url: '/api/integration/v1/ai/providers/current/network-policy', method: 'get' });
|
||||
@@ -0,0 +1,25 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface PageAssistField { key: string; label: string; kind: 'N' | 'T' | 'B' | 'CODE' | 'TEXT'; values: string[] }
|
||||
export interface PageAssistSchema {
|
||||
page: { id: string; title: string; permission: string; referencePath: string; referenceValues: string[]; guidance: string; fields: PageAssistField[] };
|
||||
enabled: boolean;
|
||||
code: string;
|
||||
}
|
||||
export type PageAssistValue = string | number | boolean | null;
|
||||
export interface PageAssistSnapshot { reference: string; facts: Record<string, PageAssistValue> }
|
||||
export interface PageAssistEvidence extends PageAssistSnapshot { inputSha256: string; origin: 'OWNER_READ' | 'DRAFT_INPUT' | 'NOT_READ'; sourceVersion: string; contextSha256: string }
|
||||
export interface PageAssistContextRequest { reference: string; qualifiers: Record<string, string>; draftFacts?: Record<string, PageAssistValue> }
|
||||
export interface PageAssistResult {
|
||||
requestId: string; state: string; answer?: string; code: string; model?: string;
|
||||
evidence: PageAssistEvidence;
|
||||
}
|
||||
const base = '/api/integration/v1/ai/page-assist';
|
||||
export const getPageAssistSchema = (page: string): AxiosPromise<PageAssistSchema> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}/schema`, method: 'get', suppressErrorToast: true });
|
||||
export const getPageAssistContext = (page: string, data: PageAssistContextRequest): AxiosPromise<PageAssistEvidence> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}/context`, method: 'post', data, timeout: 45000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const explainPageSelection = (page: string, data: PageAssistSnapshot & PageAssistContextRequest & { requestId: string; contextSha256: string }, signal: AbortSignal): AxiosPromise<PageAssistResult> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}/explanations`, method: 'post', data, signal, timeout: 75000,
|
||||
headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,31 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export type ProviderProbeState = 'IN_PROGRESS' | 'SUCCEEDED' | 'FAILED' | 'NOT_RUN' | 'UNKNOWN';
|
||||
export interface ProviderProbeRequest { requestId: string; expectedProviderVersion: number }
|
||||
export interface ProviderProbeReceipt {
|
||||
requestId: string;
|
||||
providerVersion: number;
|
||||
state: ProviderProbeState;
|
||||
code: string;
|
||||
startedAt: string;
|
||||
completedAt: string | null;
|
||||
expiresAt: string;
|
||||
elapsedMillis: number | null;
|
||||
fingerprint: string;
|
||||
}
|
||||
export interface ProviderProbeCandidate { items: { factKeys: string[]; explanation: string }[] }
|
||||
export interface ProviderProbeCandidateResult {
|
||||
state: string;
|
||||
code: string;
|
||||
fingerprint: string;
|
||||
candidate: ProviderProbeCandidate | null;
|
||||
}
|
||||
|
||||
const base = '/api/integration/v1/ai/providers/current/verification-evidence';
|
||||
export const verifyProviderEvidence = (data: ProviderProbeRequest): AxiosPromise<ProviderProbeReceipt> =>
|
||||
request({ url: base, method: 'post', data, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const readProviderEvidence = (requestId: string): AxiosPromise<ProviderProbeReceipt> =>
|
||||
request({ url: `${base}/${encodeURIComponent(requestId)}`, method: 'get', suppressErrorToast: true });
|
||||
export const explainProviderEvidence = (requestId: string, data: { fingerprint: string; prompt: string }): AxiosPromise<ProviderProbeCandidateResult> =>
|
||||
request({ url: `${base}/${encodeURIComponent(requestId)}/candidates`, method: 'post', data, suppressErrorToast: true });
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export interface ComparisonSelection { pageId: 'P37' | 'P39'; objectIds: number[]; publicationIds: number[] }
|
||||
export interface ComparisonSubject { key: string; objectId: number; version: number; label: string; attributes: Record<string, string> }
|
||||
export interface ComparisonFact { key: string; kind: string; leftKey: string | null; rightKey: string | null; details: string[] }
|
||||
export interface ComparisonContext { selection: ComparisonSelection; subjects: ComparisonSubject[]; facts: ComparisonFact[]; sourceLabel: string; sourceVersion: number; scopeNote: string; contextSha256: string }
|
||||
export interface ComparisonFinding { evidenceKeys: string[]; assessment: string; explanation: string; reviewHint: string }
|
||||
export interface ComparisonTermDraft { subjectKey: string; definition: string; businessDefinition: string }
|
||||
export interface ComparisonValueMatch { leftKey: string; rightKey: string; reason: string }
|
||||
export interface ComparisonResult { requestId: string; state: string; answer: string | null; findings: ComparisonFinding[]; termDrafts: ComparisonTermDraft[]; valueMatches: ComparisonValueMatch[]; code: string | null }
|
||||
export const readComparison = (data: ComparisonSelection, signal?: AbortSignal): AxiosPromise<ComparisonContext> => request({ url: '/api/governance/v1/record-comparison/context', method: 'post', data, signal });
|
||||
export const explainComparison = (data: { requestId: string; selection: ComparisonSelection; contextSha256: string; evidenceKeys: string[]; prompt: string }, signal?: AbortSignal): AxiosPromise<ComparisonResult> => request({ url: '/api/integration/v1/ai/record-comparison/candidates', method: 'post', data, signal });
|
||||
@@ -0,0 +1,73 @@
|
||||
export type AiProviderType = 'OPENAI_COMPATIBLE';
|
||||
export type AiAssistantType =
|
||||
| 'governance-flow'
|
||||
| 'fault-diagnosis'
|
||||
| 'metadata-enrichment'
|
||||
| 'standard-match'
|
||||
| 'quality-rule'
|
||||
| 'sql-processing';
|
||||
|
||||
export interface AiProviderVO {
|
||||
enabled: boolean;
|
||||
secretConfigured: boolean;
|
||||
providerType: AiProviderType;
|
||||
model: string;
|
||||
endpoint: string;
|
||||
secretFingerprint?: string;
|
||||
timeoutSeconds: number;
|
||||
status: 'ENABLED' | 'DISABLED';
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AiProviderCommand {
|
||||
enabled: boolean;
|
||||
providerType: AiProviderType;
|
||||
model: string;
|
||||
endpoint: string;
|
||||
apiKey?: string;
|
||||
revokeApiKey: boolean;
|
||||
timeoutSeconds: number;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AiProviderVerifyVO {
|
||||
enabled: boolean;
|
||||
available: boolean;
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface AiSuggestionCommand {
|
||||
objectType: string;
|
||||
objectId: string;
|
||||
purpose: string;
|
||||
evidenceRefs: string[];
|
||||
tableFileId?: string | number;
|
||||
sqlDraft?: string;
|
||||
processingDraft?: string;
|
||||
}
|
||||
export interface AiSuggestionCandidate { label: string; targetRef: string; objectType: string; version?: string; observedAt?: string; }
|
||||
|
||||
export interface AiSuggestionVO {
|
||||
suggestionId?: number;
|
||||
requestId?: string;
|
||||
assistantType?: AiAssistantType;
|
||||
title?: string;
|
||||
summary?: string;
|
||||
proposal?: string;
|
||||
rationale?: string;
|
||||
confidence?: number;
|
||||
impactScope?: string;
|
||||
evidenceRefs?: string[];
|
||||
status?: 'DRAFT' | 'ADOPTED' | 'IGNORED' | 'DISABLED' | 'FAILED' | 'NOT_RUN';
|
||||
code?: string;
|
||||
model?: string;
|
||||
providerVersion?: string;
|
||||
version?: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AiSuggestionPage {
|
||||
rows: AiSuggestionVO[];
|
||||
total: number;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { Attachment } from '@/api/datagov/workbench-knowledge/attachments';
|
||||
|
||||
export interface AttachmentReference { id: string; version: number; fragmentId: number; hash: string; source: 'SESSION_ATTACHMENT'; }
|
||||
export interface ChatAttachment { file: Attachment; sessionId: string; expiresAt: string; revoked: boolean; retained: boolean; contentVersion: number; }
|
||||
const root = (sessionId: string) => `/api/governance/v1/workbench-attachments/sessions/${sessionId}`;
|
||||
export const listChatAttachments = (sessionId: string): AxiosPromise<ChatAttachment[]> => request({ url: root(sessionId), suppressErrorToast: true });
|
||||
export const readChatAttachment = (sessionId: string, id: string): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}`, suppressErrorToast: true });
|
||||
export function uploadChatAttachment(sessionId: string, id: string, file: File): AxiosPromise<ChatAttachment> {
|
||||
const data = new FormData(); data.append('file', file);
|
||||
return request({ url: `${root(sessionId)}/${id}`, method: 'post', data, headers: { repeatSubmit: false }, timeout: 120000, suppressErrorToast: true });
|
||||
}
|
||||
export const retryChatAttachment = (sessionId: string, id: string, version: number): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}/retry`, method: 'post', data: { version }, timeout: 120000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const revokeChatAttachment = (sessionId: string, id: string, version: number): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}/revoke`, method: 'post', data: { version }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const retainChatAttachment = (sessionId: string, id: string, version: number): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}/retain`, method: 'post', data: { version }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const selectChatAttachment = (sessionId: string, id: string, version: number, fragmentIds: number[]): AxiosPromise<AttachmentReference[]> => request({ url: `${root(sessionId)}/${id}/selection`, method: 'post', data: { version, fragmentIds }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { Content } from './business';
|
||||
export interface Candidate { requestId: string; state: string; answer?: string; content?: Content; code?: string }
|
||||
export interface Draft { id: string; sessionId: string; type: string; title: string; version: number; pending: boolean; linked: boolean; candidates: Candidate[] }
|
||||
export interface Item { id: string; draftId: string; draftVersion: number; requestId: string; state: string; code?: string; candidateVersion?: number; adoptedVersion?: number }
|
||||
export interface Batch { id: string; sessionId: string; title: string; prompt: string; version: number; state: string; items: Item[]; updatedAt: string }
|
||||
export interface ItemView { item: Item; draft?: Draft; candidate?: Candidate; state: string; message: string }
|
||||
export interface View { batch: Batch; items: ItemView[] }
|
||||
export interface Create { id: string; title: string; prompt: string; items: { draftId: string; draftVersion: number }[] }
|
||||
const base = '/api/integration/v1/ai/workbench';
|
||||
const write = <T>(path: string, data: unknown): AxiosPromise<T> => request({ url: base + path, method: 'post', data, timeout: 85000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const candidates = (session: string): AxiosPromise<Draft[]> => request({ url: `${base}/sessions/${session}/batch-candidates` });
|
||||
export const list = (session: string): AxiosPromise<Batch[]> => request({ url: `${base}/sessions/${session}/suggestion-batches` });
|
||||
export const create = (session: string, data: Create) => write<View>(`/sessions/${session}/suggestion-batches`, data);
|
||||
export const get = (id: string): AxiosPromise<View> => request({ url: `${base}/suggestion-batches/${id}` });
|
||||
export const generate = (id: string, itemId: string, version: number) => write<View>(`/suggestion-batches/${id}/items/${itemId}/generate`, { version });
|
||||
export const adopt = (id: string, itemId: string, version: number, draftVersion: number) => write<View>(`/suggestion-batches/${id}/items/${itemId}/adopt`, { version, draftVersion });
|
||||
export const status = (id: string, version: number, stopped: boolean) => write<View>(`/suggestion-batches/${id}/${stopped ? 'stop' : 'resume'}`, { version });
|
||||
@@ -0,0 +1,35 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { EngineeringType } from '@/api/datagov/engineering-drafts/types';
|
||||
import type { ObjectReference } from './object-contexts';
|
||||
import type { RuleReference } from './rule-references';
|
||||
import type { GovernanceToolType } from '@/views/datagov/ai-workbench/governanceTools';
|
||||
import type { EngineeringBinding } from './engineering-context';
|
||||
export type BusinessType = GovernanceToolType | EngineeringType | 'MODEL_REPOSITORY' | 'MODEL_DESIGN' | 'BUSINESS_TERM' | 'DATA_ELEMENT' | 'STANDARD_SYSTEM' | 'REFERENCE_DATA' | 'DATASET' | 'METRIC' | 'SEMANTIC_MODEL' | 'API' | 'BI_DATASET' | 'BI_CHART' | 'BI_REPORT' | 'BI_SCREEN' | 'DATASET_SCHEMA' | 'DATASET_PUBLISH' | 'METRIC_SELF_SERVICE' | 'SELF_SERVICE_SHARE' | 'DATA_EXCHANGE' | 'DATA_EXCHANGE_READY';
|
||||
export type Content = Record<string, unknown>;
|
||||
export interface BusinessField { name: string; label: string; kind: 'TEXT' | 'LONG_TEXT' | 'SELECT' | 'ID' | 'NUMBER' | 'OBJECT' | 'ARRAY'; required: boolean; options: string[] }
|
||||
export interface BusinessTool { type: BusinessType; label: string; scenario: string; route: string; permission: string; effect: string; fields: BusinessField[] }
|
||||
export interface KnowledgeReference { id: string; version: number; fragmentId: number; hash: string; source?: 'SESSION_ATTACHMENT' }
|
||||
export interface KnowledgeFragment extends KnowledgeReference { title: string; kind: string; scope: string; documentHash: string; text: string }
|
||||
export interface BusinessTurn { id: string; hash: string; prompt: string; context: string; state: string; answer?: string; content?: Content; code?: string; model?: string; at: number; knowledgeRefs?: KnowledgeReference[]; objectRefs?: ObjectReference[]; ruleRefs?: RuleReference[]; usage?: import('./model-usage').ModelUsage; engineeringContext?: EngineeringBinding }
|
||||
export interface BusinessIntent { id: string; hash: string; content: Content; at: number; expiresAt: number; phase: 'READY' | 'SUBMITTED'; ruleRefs?: RuleReference[] }
|
||||
export interface BusinessReference { intentId: string; objectId: string; objectVersion?: number | null; nativeVersion?: string }
|
||||
export interface BusinessUpdateTarget { objectId: string; objectVersion: number; sourceHash: string; baselineContent: Content; editableFields: string[] }
|
||||
export interface BusinessDraft { id: string; sessionId: string; type: BusinessType; title: string; content: Content; version: number; createHash: string;
|
||||
revisions: { version: number; title: string; content: Content; at: number }[]; turns: BusinessTurn[]; intent?: BusinessIntent; reference?: BusinessReference;
|
||||
branchSource?: { draftId: string; sessionId: string; sourceVersion: number; revisionVersion: number }; updateTarget?: BusinessUpdateTarget }
|
||||
const base = '/api/integration/v1/ai/workbench';
|
||||
const write = <T>(path: string, data?: unknown, method = 'post'): AxiosPromise<T> => request({ url: base + path, method, data, timeout: 75000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const businessTools = (): AxiosPromise<BusinessTool[]> => request({ url: base + '/tools' });
|
||||
export const businessDrafts = (sessionId: string): AxiosPromise<BusinessDraft[]> => request({ url: `${base}/sessions/${sessionId}/artifacts` });
|
||||
export const getBusinessDraft = (id: string): AxiosPromise<BusinessDraft> => request({ url: `${base}/artifacts/${id}` });
|
||||
export const reviseOriginalBusinessDraft = (draftId: string, command: { id: string; version: number; title: string }) => write<BusinessDraft>(`/artifacts/${draftId}/revise-original`, command);
|
||||
export const createBusinessDraft = (sessionId: string, id: string, type: BusinessType, title: string, content: Content) => write<BusinessDraft>(`/sessions/${sessionId}/artifacts`, { id, type, title, content });
|
||||
export const editBusinessDraft = (draft: BusinessDraft, title: string, content: Content) => write<BusinessDraft>(`/artifacts/${draft.id}`, { version: draft.version, title, content }, 'put');
|
||||
export const generateBusinessDraft = (draft: BusinessDraft, requestId: string, prompt: string, context: string, knowledgeRefs: KnowledgeReference[] = [], objectRefs: ObjectReference[] = [], engineeringContext?: EngineeringBinding) => write<BusinessDraft>(`/artifacts/${draft.id}/turns`, { version: draft.version, requestId, prompt, context, knowledgeRefs, objectRefs, engineeringContext });
|
||||
export const stopBusinessDraft = (id: string, requestId: string) => write<BusinessDraft>(`/artifacts/${id}/turns/${requestId}/stop`);
|
||||
export const prepareBusinessDraft = (draft: BusinessDraft) => write<BusinessDraft>(`/artifacts/${draft.id}/save-intent`, { version: draft.version });
|
||||
export const claimBusinessIntent = (draft: BusinessDraft) => write<BusinessDraft>(`/artifacts/${draft.id}/save-intent/claim`, { version: draft.version, intentId: draft.intent?.id });
|
||||
export const releaseBusinessIntent = (draft: BusinessDraft) => write<BusinessDraft>(`/artifacts/${draft.id}/save-intent/release`, { version: draft.version, intentId: draft.intent?.id });
|
||||
export const linkBusinessDraft = (draft: BusinessDraft, reference: BusinessReference) => write<BusinessDraft>(`/artifacts/${draft.id}/reference`, reference);
|
||||
export const searchWorkbenchKnowledge = (q: string): AxiosPromise<KnowledgeFragment[]> => request({ url: `${base}/knowledge`, method: 'get', params: { q, limit: 10 } });
|
||||
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { Content } from './business';
|
||||
export interface EngineeringReference { kind: string; id: string; executionOptions?: Record<string, string> }
|
||||
export interface EngineeringEditedObject { id: string; version: number }
|
||||
export interface EngineeringBatchSelection { sourceId: string; sourceObject: string; resourceId: string; spaceId: string; targetObject: string }
|
||||
export interface EngineeringLayerSelection { resourceId: string; spaceId: string; layerType: string; admissionVersion?: number | null }
|
||||
export interface EngineeringVisualSelection { sourceId: string; sourceObject: string; resourceId: string; spaceId: string; targetObject: string }
|
||||
export interface EngineeringCleaningSelection { sourceTableId: string; outputTableId: string; publications: { id: string; version: number }[] }
|
||||
export interface EngineeringTableStructureSelection { resourceId: string; spaceId: string; layerId: string | null; sourceTableFileId: string }
|
||||
export interface EngineeringSelection { type: string; references: EngineeringReference[]; ingestion: { sources: { sourceId: string; sourceVersion: number; sourceName: string; sourceDatabase: string; table: string }[]; targetType: 'DORIS' | 'HIVE'; resourceId: string; spaceId: string } | null; editedObject: EngineeringEditedObject | null; batch?: EngineeringBatchSelection | null; layer?: EngineeringLayerSelection | null; visual?: EngineeringVisualSelection | null; cleaning?: EngineeringCleaningSelection | null; tableStructure?: EngineeringTableStructureSelection | null }
|
||||
export interface EngineeringBinding { selection: EngineeringSelection; contextSha256: string }
|
||||
export interface EngineeringField { name: string; type: string; nullable: boolean | null; precision?: number | null; scale?: number | null }
|
||||
export interface EngineeringLayerDefinition { key: string; id: string; name: string; layerType: string; version: number; admissionVersion: number; granularity: string; namingPattern: string; minimumQualityScore: number; lifecycleDays: number; upstreamIds: string[]; enabled: boolean; mappingStatus: string; definitionSha256: string }
|
||||
export interface EngineeringLayerContext { resourceId: string; resourceVersion: number; accessVersion: number | null; spaceId: string; spaceVersion: number; engineType: string; catalogName: string; namespaceName: string; mappingSha256: string; layers: EngineeringLayerDefinition[] }
|
||||
export interface EngineeringContext { selection: EngineeringSelection; contextSha256: string; scopeNote: string; facts: { key: string; kind: string; id: string; version: string; sha256: string; state: string; capability: string; fields: EngineeringField[] }[]; sources: { key: string; id: string; version: number; name: string; database: string; table: string; fingerprint: string; sourceFields: EngineeringField[]; proposedTargetFields: EngineeringField[] }[]; target: { resourceId: string; resourceVersion: number; accessVersion: number; spaceId: string; spaceVersion: number; type: string; namespace: string } | null; layer?: EngineeringLayerContext | null }
|
||||
const base = '/api/integration/v1/ai/engineering-context';
|
||||
export const inspectEngineeringContext = (selection: EngineeringSelection): AxiosPromise<EngineeringContext> => request({ url: base, method: 'post', data: selection, timeout: 65000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const validateEngineeringCandidate = (binding: EngineeringBinding, baseline: Content, candidate: Content): AxiosPromise<Content> => request({ url: `${base}/validate`, method: 'post', data: { binding, baseline, candidate }, timeout: 65000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,5 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { BusinessDraft } from './business';
|
||||
export interface BusinessForkCommand { id: string; version: number; revisionVersion?: number; title: string; targetSessionId: string; newSessionTitle?: string; }
|
||||
export const forkBusinessDraft = (sourceId: string, data: BusinessForkCommand): AxiosPromise<BusinessDraft> => request({ url: `/api/integration/v1/ai/workbench/artifacts/${sourceId}/fork`, method: 'post', data, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,31 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { AttachmentReference } from './attachments';
|
||||
import type { ObjectReference } from './object-contexts';
|
||||
import type { RuleReference } from './rule-references';
|
||||
import type { ModelUsage } from './model-usage';
|
||||
export interface Turn { id: string; prompt: string; state: string; answer?: string; name?: string; sql?: string; code?: string; model?: string; startedAt: number; knowledgeRefs?: AttachmentReference[]; objectRefs?: ObjectReference[]; ruleRefs?: RuleReference[]; usage?: ModelUsage; }
|
||||
export interface SaveIntent { id: string; name: string; sql: string; codeId?: string; codeVersion?: number; expiresAt: number; phase: 'READY' | 'SUBMITTED'; ruleRefs?: RuleReference[]; }
|
||||
export type Scenario = 'SQL' | 'ENGINEERING' | 'GOVERNANCE' | 'ANALYSIS';
|
||||
export type SessionStatus = 'ACTIVE' | 'ARCHIVED';
|
||||
export interface Feedback { rating: 'USEFUL' | 'NOT_USEFUL'; category: string; comment: string; at: number }
|
||||
export interface Session { id: string; title: string; name: string; sql: string; version: number; turns: Turn[]; saveIntent?: SaveIntent; codeReference?: { intentId: string; codeId: string; version: number }; scenario?: Scenario; status?: SessionStatus; feedback?: Record<string, Feedback>; }
|
||||
export interface Summary { id: string; title: string; version: number; updatedAt: string; scenario?: Scenario; status?: SessionStatus; artifactCount?: number; }
|
||||
const root = '/api/integration/v1/ai/workbench';
|
||||
const write = <T>(url: string, data?: unknown, method = 'post'): AxiosPromise<T> =>
|
||||
request({ url: root + url, method, data, timeout: 75000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const capability = (): AxiosPromise<{ enabled: boolean; model?: string }> => request({ url: root + '/capability', suppressErrorToast: true });
|
||||
export const sessions = (pageNum: number, keyword = '', scenario?: Scenario, status: SessionStatus = 'ACTIVE'): AxiosPromise<Summary[]> => request({ url: root + '/sessions', params: { pageNum, keyword, scenario, status } });
|
||||
export const session = (id: string): AxiosPromise<Session> => request({ url: root + '/sessions/' + id });
|
||||
export const createSession = (id: string, title: string) => write<Session>('/sessions', { id, title });
|
||||
export const saveDraft = (s: Session, name: string, sql: string) => write<Session>('/sessions/' + s.id + '/draft', { version: s.version, name, sql }, 'put');
|
||||
export const generate = (s: Session, requestId: string, prompt: string, knowledgeRefs: AttachmentReference[] = [], objectRefs: ObjectReference[] = []) => write<Session>('/sessions/' + s.id + '/turns', { version: s.version, requestId, prompt, knowledgeRefs, objectRefs });
|
||||
export const stop = (id: string, requestId: string) => write<Session>('/sessions/' + id + '/turns/' + requestId + '/stop');
|
||||
export const prepare = (s: Session) => write<Session>('/sessions/' + s.id + '/save-intent', { version: s.version });
|
||||
export const claim = (s: Session) => write<Session>(`/sessions/${s.id}/save-intent/claim`, { version: s.version, intentId: s.saveIntent?.id });
|
||||
export const release = (s: Session) => write<Session>(`/sessions/${s.id}/save-intent/release`, { version: s.version, intentId: s.saveIntent?.id });
|
||||
export const link = (id: string, intentId: string, codeId: string, codeVersion: number) =>
|
||||
write<Session>('/sessions/' + id + '/code-reference', { intentId, codeId, codeVersion });
|
||||
export const settings = (s: Session, title: string, scenario: Scenario, status: SessionStatus) => write<Session>(`/sessions/${s.id}/settings`, { version: s.version, title, scenario, status }, 'put');
|
||||
export const forkSession = (sourceId: string, version: number, id: string, title: string) => write<Session>(`/sessions/${sourceId}/fork`, { version, id, title });
|
||||
export const feedback = (s: Session, turnId: string, rating: Feedback['rating'], category: string, comment: string) => write<Session>(`/sessions/${s.id}/turns/${turnId}/feedback`, { version: s.version, rating, category, comment });
|
||||
@@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface MemoryEntry { id: string; category: 'TERM' | 'DISPLAY' | 'PREFERENCE'; title: string; content: string; version: number; updatedAt: string }
|
||||
export interface MemoryState { enabled: boolean; version: number; entries: MemoryEntry[] }
|
||||
export interface MemoryWrite { requestId: string; id: string; version: number; category: MemoryEntry['category']; title: string; content: string }
|
||||
const base = '/api/integration/v1/ai/workbench/memories';
|
||||
export const memoryState = (): AxiosPromise<MemoryState> => request({ url: base });
|
||||
export const memorySettings = (data: { requestId: string; version: number; enabled: boolean }): AxiosPromise<MemoryState> => request({ url: `${base}/settings`, method: 'put', data, headers: { repeatSubmit: false } });
|
||||
export const writeMemory = (data: MemoryWrite, create: boolean): AxiosPromise<MemoryState> => request({ url: create ? base : `${base}/${data.id}`, method: create ? 'post' : 'put', data, headers: { repeatSubmit: false } });
|
||||
export const deleteMemory = (id: string, data: { requestId: string; version: number }): AxiosPromise<MemoryState> => request({ url: `${base}/${id}`, method: 'delete', data, headers: { repeatSubmit: false } });
|
||||
@@ -0,0 +1,17 @@
|
||||
export interface ModelUsage {
|
||||
providerVersion?: number | string;
|
||||
requestedModel?: string;
|
||||
reportedModel?: string;
|
||||
inputTokens?: number;
|
||||
outputTokens?: number;
|
||||
totalTokens?: number;
|
||||
tokenStatus: 'PROVIDER_REPORTED' | 'PARTIAL' | 'NOT_REPORTED' | 'INVALID';
|
||||
durationMillis?: number;
|
||||
completedAt?: number;
|
||||
}
|
||||
export function measuredCount(value?: number | null) { return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value.toLocaleString('zh-CN') : '未观测'; }
|
||||
export function usageStatus(value?: ModelUsage) {
|
||||
if(!value) return '未记录模型用量';
|
||||
return ({PROVIDER_REPORTED:'提供方返回',PARTIAL:'提供方仅返回部分用量',NOT_REPORTED:'提供方未返回用量',INVALID:'提供方用量字段无效,未采信'})[value.tokenStatus] || '用量状态未知';
|
||||
}
|
||||
export function observationTime(value?: number) { return typeof value === 'number' && Number.isSafeInteger(value) && value>0 && value<=8.64e15 ? new Date(value).toLocaleString('zh-CN',{hour12:false}) : '未观测'; }
|
||||
@@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface ObjectReference { type: string; objectId: string; version: number; hash: string; fields: string[]; reason: string }
|
||||
export interface Choice { type: string; objectId: string; fields?: string[]; reason: string }
|
||||
export interface Resolved { reference: ObjectReference; name: string; status: string; path: string; updatedAt?: string; checkedAt: string; availableFields: string[]; content: Record<string, unknown> }
|
||||
export interface Verification { reference: ObjectReference; state: 'CURRENT' | 'STALE' | 'UNAVAILABLE'; current?: Resolved }
|
||||
const base = '/api/integration/v1/ai/workbench/object-contexts';
|
||||
export const readObjectContext = (data: Choice): AxiosPromise<Resolved> => request({ url: base + '/read', method: 'post', data, suppressErrorToast: true });
|
||||
export const verifyObjectContexts = (data: ObjectReference[]): AxiosPromise<Verification[]> => request({ url: base + '/verify', method: 'post', data, suppressErrorToast: true });
|
||||
@@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { BusinessType } from './business';
|
||||
|
||||
export type OriginType = BusinessType | 'SQL';
|
||||
export interface WorkbenchOrigin { sessionId: string; title: string; status: string; draftId?: string; type: OriginType; objectId: string; linkedVersion?: number | null; nativeVersion?: string; linkedAt: string }
|
||||
export function workbenchOrigins(type: OriginType, objectId: string): AxiosPromise<WorkbenchOrigin[]> {
|
||||
return request({ url: '/api/integration/v1/ai/workbench/origins', params: { type, objectId } });
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { ModelUsage } from './model-usage';
|
||||
|
||||
export interface Question { id: string; fieldPath: string; question: string; options: string[]; required: boolean; answer: string; }
|
||||
export interface Step { id: string; title: string; draftId: string; draftVersion: number; dependsOn: string[]; inputSummary: string; impactSummary: string; budgetTokens: number; }
|
||||
export interface Definition { title: string; intent: string; questions: Question[]; steps: Step[]; maxTokens: number; }
|
||||
export interface Reference { objectId: string; objectVersion?: number | null; nativeVersion?: string; }
|
||||
export interface Artifact { draftId: string; sessionId: string; version: number; type: string; title: string; requiredPermission: string; pending: boolean; reference?: Reference; }
|
||||
export interface Dependency { draftId: string; draftVersion: number; type: string; reference?: Reference; }
|
||||
export interface Confirmation { id: string; planId: string; planVersion: number; planHash: string; stepId: string; draftId: string; draftVersion: number; type: string; phase: 'READY' | 'SUBMITTED' | 'VOID'; expiresAt: string; dependencies: Dependency[]; }
|
||||
export interface Generation { id: string; inputHash: string; state: 'PENDING' | 'DRAFT' | 'FAILED' | 'DISABLED' | 'STALE' | 'STOPPED' | 'UNKNOWN'; prompt: string; explanation?: string; candidate?: Definition; model?: string; code?: string; startedAt: string; usage?: ModelUsage; }
|
||||
export interface Plan { id: string; sessionId: string; version: number; status: 'DRAFT' | 'STOPPED'; hash: string; definition: Definition; revisions: { version: number; hash: string; definition: Definition; at: string }[]; confirmations: Confirmation[]; generations: Generation[]; updatedAt: string; }
|
||||
export type StepState = 'REFERENCE_RECORDED' | 'OUTCOME_PENDING' | 'DRAFT_STALE' | 'STOPPED' | 'WAITING_INPUT' | 'WAITING_DEPENDENCY' | 'READY';
|
||||
export interface View { plan: Plan; steps: { step: Step; state: StepState; message: string; artifact: Artifact }[]; unanswered: string[]; }
|
||||
export interface ExecuteStep { planId: string; stepId: string; draftId: string; draftVersion: number; confirmationId: string; dependencies: Dependency[]; }
|
||||
export interface Pending { key: string; path: string; method: 'post' | 'put'; data: unknown; kind: 'VIEW' | 'CONFIRMATION'; }
|
||||
const root = '/api/integration/v1/ai/workbench';
|
||||
export const list = (sessionId: string): AxiosPromise<View[]> => request({ url: `${root}/sessions/${sessionId}/plans` });
|
||||
export const artifacts = (sessionId: string): AxiosPromise<Artifact[]> => request({ url: `${root}/sessions/${sessionId}/plan-artifacts` });
|
||||
export const get = (id: string): AxiosPromise<View> => request({ url: `${root}/plans/${id}`, suppressErrorToast: true });
|
||||
export const write = (command: Pending): AxiosPromise<View | Confirmation> => request({ url: root + command.path, method: command.method, data: command.data, headers: { 'Idempotency-Key': command.key, repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const claim = (command: ExecuteStep): AxiosPromise<Confirmation> => request({ url: `${root}/plans/${command.planId}/steps/${command.stepId}/claim`, method: 'post', data: { confirmationId: command.confirmationId, draftId: command.draftId, draftVersion: command.draftVersion }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { Fragment } from '@/api/datagov/workbench-knowledge';
|
||||
|
||||
export interface RuleReference { id: string; version: number; hash: string }
|
||||
|
||||
export function matchesRuleReference(reference: RuleReference, fragment: Fragment): boolean {
|
||||
return fragment.id === reference.id && fragment.version === reference.version && fragment.kind === 'RULE'
|
||||
&& fragment.documentHash === reference.hash && fragment.fragmentId === 1;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { AlertSource, AlertMetric, AlertOperator, AlertSeverity } from './types';
|
||||
|
||||
export type EvidenceId = string | number;
|
||||
export interface OccurrenceReference { eventId: string; occurrenceId: string; eventVersion: number; payloadSha256?: string }
|
||||
export interface FrozenAlertRule {
|
||||
ruleId: string; version: number; source: AlertSource; metric: AlertMetric; operator: AlertOperator;
|
||||
threshold: string; severity: AlertSeverity; observationMinutes: number; triggerCount: number;
|
||||
recoveryCount: number; aggregateMinutes: number; silenceMinutes: number; enabled: boolean;
|
||||
}
|
||||
export interface FrozenAlertRun {
|
||||
key: string; runId: string; source: AlertSource; ownerObjectId: string; orgId: string;
|
||||
projectRef?: string; dataDomainCode?: string; status: string; startedAt?: string; completedAt?: string;
|
||||
createdAt: string; updatedAt?: string; windowTime: string; timeBasis: string; metricRoles: string[];
|
||||
}
|
||||
export interface OccurrencePayload {
|
||||
formatVersion: number; state: 'BOUND' | 'REFERENCE_LIMIT' | 'OWNER_CHANGED'; rule: FrozenAlertRule;
|
||||
orgId: string; ownerObjectId: string; projectRef?: string; dataDomainCode?: string;
|
||||
appliedFrom: string; appliedTo: string; zoneId: string; timeBasis: string; sampleMinCreatedAt: string;
|
||||
ownerRowCount: number; metricSampleCount: number; unknownStatusCount: number; metricValue: string;
|
||||
breached: boolean; originalEvidenceSha256: string; streakEvidenceState: 'UNBOUND'; runs: FrozenAlertRun[];
|
||||
}
|
||||
export interface OccurrenceEvidence {
|
||||
reference: OccurrenceReference; state: 'BOUND' | 'REFERENCE_LIMIT' | 'OWNER_CHANGED' | 'LEGACY_UNBOUND';
|
||||
source: AlertSource; eventStatus: string; payload?: OccurrencePayload; scopeNote: string;
|
||||
}
|
||||
export interface OccurrenceSelection { references: OccurrenceReference[] }
|
||||
export interface OccurrenceFinding { occurrenceKeys: string[]; explanation: string; checks: string[] }
|
||||
export interface OccurrenceExplanation { requestId: string; state: string; fingerprint?: string; findings: OccurrenceFinding[]; code?: string }
|
||||
|
||||
export const readOccurrenceEvidence = (eventId: string, occurrenceId: string): AxiosPromise<OccurrenceEvidence> =>
|
||||
request({ url: `/api/dataops/v1/alert-events/${eventId}/occurrences/${occurrenceId}/evidence`, method: 'get' });
|
||||
export const explainOccurrenceEvidence = (requestId: string, selection: OccurrenceSelection, prompt: string): AxiosPromise<OccurrenceExplanation> =>
|
||||
request({ url: '/api/integration/v1/ai/alert-occurrence-evidence', method: 'post', data: { requestId, selection, prompt, consent: true } });
|
||||
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface DeliveryChannel { id: string; label: string; type: 'SMTP' | 'WEBHOOK'; targets: { key: string; label: string }[] }
|
||||
export interface DeliveryReceipt {
|
||||
requestKey: string; eventId: string | number; channelId: string; channelLabel: string;
|
||||
targetKey: string; targetLabel: string; state: 'ACCEPTED' | 'UNKNOWN' | 'CANCELLED'; safeCode: string;
|
||||
startedAt: string; completedAt: string | null;
|
||||
}
|
||||
export interface ExternalDeliveryRequest { channelId: string; targetKey: string; eventVersion: number }
|
||||
const base = (id: string | number) => `/api/dataops/v1/alert-events/${encodeURIComponent(String(id))}/external-deliveries`;
|
||||
export const deliveryChannels = (id: string | number): AxiosPromise<DeliveryChannel[]> => request({ url: `${base(id)}/channels` });
|
||||
export const deliveryHistory = (id: string | number): AxiosPromise<DeliveryReceipt[]> => request({ url: base(id) });
|
||||
export const deliveryReceipt = (id: string | number, key: string): AxiosPromise<DeliveryReceipt | null> =>
|
||||
request({ url: `${base(id)}/${encodeURIComponent(key)}` });
|
||||
export const cancelUnsubmittedDelivery = (id: string | number, key: string): AxiosPromise<DeliveryReceipt> =>
|
||||
request({ url: `${base(id)}/${encodeURIComponent(key)}/cancellation`, method: 'post' });
|
||||
export const sendExternalAlert = (id: string | number, data: ExternalDeliveryRequest, key: string): AxiosPromise<DeliveryReceipt> =>
|
||||
request({ url: base(id), method: 'post', data, headers: { 'Idempotency-Key': key, repeatSubmit: false } });
|
||||
@@ -0,0 +1,88 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AssignRequest,
|
||||
EventDetailView,
|
||||
EventQuery,
|
||||
EventSummary,
|
||||
IdentityCandidate,
|
||||
NotifyRequest,
|
||||
PageView,
|
||||
PostmortemRequest,
|
||||
ProcessRequest,
|
||||
RuleQuery,
|
||||
RuleSaveRequest,
|
||||
RuleView,
|
||||
VerifyRequest,
|
||||
WriteView
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/dataops/v1/alert-events';
|
||||
const writeHeaders = (idempotencyKey: string) => ({
|
||||
'Idempotency-Key': idempotencyKey,
|
||||
repeatSubmit: false
|
||||
});
|
||||
|
||||
export const listAlertEvents = (params: EventQuery): AxiosPromise<PageView<EventSummary>> =>
|
||||
request({ url: baseUrl, method: 'get', params });
|
||||
|
||||
export const getAlertEvent = (eventId: number | string): AxiosPromise<EventDetailView> =>
|
||||
request({ url: `${baseUrl}/${eventId}`, method: 'get' });
|
||||
|
||||
export const listAlertRules = (params: RuleQuery): AxiosPromise<PageView<RuleView>> =>
|
||||
request({ url: `${baseUrl}/rules`, method: 'get', params });
|
||||
|
||||
export const listAlertIdentityCandidates = (keyword: string, limit = 20): AxiosPromise<IdentityCandidate[]> =>
|
||||
request({ url: `${baseUrl}/identity-candidates`, method: 'get', params: { keyword, limit } });
|
||||
|
||||
export const createAlertRule = (data: RuleSaveRequest, idempotencyKey: string): AxiosPromise<WriteView<RuleView>> =>
|
||||
request({ url: `${baseUrl}/rules`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const updateAlertRule = (
|
||||
ruleId: number,
|
||||
data: RuleSaveRequest,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<WriteView<RuleView>> =>
|
||||
request({ url: `${baseUrl}/rules/${ruleId}`, method: 'put', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const updateAlertRuleStatus = (
|
||||
ruleId: number,
|
||||
enabled: boolean,
|
||||
version: number,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<WriteView<RuleView>> =>
|
||||
request({
|
||||
url: `${baseUrl}/rules/${ruleId}/status`,
|
||||
method: 'put',
|
||||
data: { enabled, version },
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
const eventWrite = <T>(
|
||||
eventId: number,
|
||||
action: string,
|
||||
method: 'post' | 'put',
|
||||
data: T,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<WriteView<EventDetailView>> =>
|
||||
request({
|
||||
url: `${baseUrl}/${eventId}/${action}`,
|
||||
method,
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const notifyAlertEvent = (eventId: number, data: NotifyRequest, key: string) =>
|
||||
eventWrite(eventId, 'notifications', 'post', data, key);
|
||||
|
||||
export const assignAlertEvent = (eventId: number, data: AssignRequest, key: string) =>
|
||||
eventWrite(eventId, 'assignment', 'post', data, key);
|
||||
|
||||
export const processAlertEvent = (eventId: number, data: ProcessRequest, key: string) =>
|
||||
eventWrite(eventId, 'processing', 'post', data, key);
|
||||
|
||||
export const verifyAlertEvent = (eventId: number, data: VerifyRequest, key: string) =>
|
||||
eventWrite(eventId, 'verification', 'post', data, key);
|
||||
|
||||
export const saveAlertPostmortem = (eventId: number, data: PostmortemRequest, key: string) =>
|
||||
eventWrite(eventId, 'postmortem', 'put', data, key);
|
||||
@@ -0,0 +1,206 @@
|
||||
export type AlertSource = 'SCHEDULING' | 'BATCH_INGESTION' | 'FILE_INGESTION';
|
||||
export type AlertMetric = 'FAILED_COUNT' | 'FAILURE_RATE_PERCENT' | 'BACKLOG_COUNT' | 'MAX_DURATION_MS';
|
||||
export type AlertOperator = 'GT' | 'GTE' | 'LT' | 'LTE';
|
||||
export type AlertSeverity = 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW';
|
||||
export type AlertEventStatus = 'OPEN' | 'ASSIGNED' | 'PROCESSING' | 'RESOLVED' | 'VERIFIED' | 'CLOSED';
|
||||
export type AlertNotificationType = 'OPEN' | 'MANUAL' | 'RECOVERY' | 'ESCALATION';
|
||||
export type ProcessAction = 'START_PROCESSING' | 'RESOLVE';
|
||||
export type VerifyAction = 'VERIFY' | 'CLOSE';
|
||||
|
||||
export interface PageView<T> {
|
||||
rows: T[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface WriteView<T> {
|
||||
requestId: string;
|
||||
result: T;
|
||||
}
|
||||
|
||||
export interface RuleView {
|
||||
ruleId: number;
|
||||
orgId: number;
|
||||
name: string;
|
||||
source: AlertSource;
|
||||
metric: AlertMetric;
|
||||
operator: AlertOperator;
|
||||
threshold: number;
|
||||
severity: AlertSeverity;
|
||||
observationMinutes: number;
|
||||
triggerCount: number;
|
||||
recoveryCount: number;
|
||||
aggregateMinutes: number;
|
||||
silenceMinutes: number;
|
||||
dataDomainCode?: string;
|
||||
primaryUserId: number;
|
||||
primaryUserName: string;
|
||||
escalationUserId?: number;
|
||||
escalationUserName?: string;
|
||||
escalationWaitMinutes: number;
|
||||
enabled: boolean;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface RuleSaveRequest {
|
||||
name: string;
|
||||
source: AlertSource;
|
||||
metric: AlertMetric;
|
||||
operator: AlertOperator;
|
||||
threshold: number;
|
||||
severity: AlertSeverity;
|
||||
observationMinutes: number;
|
||||
triggerCount: number;
|
||||
recoveryCount: number;
|
||||
aggregateMinutes: number;
|
||||
silenceMinutes: number;
|
||||
dataDomainCode?: string;
|
||||
primaryUserId?: number;
|
||||
escalationUserId?: number;
|
||||
escalationWaitMinutes: number;
|
||||
enabled: boolean;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface RuleQuery {
|
||||
keyword?: string;
|
||||
source?: AlertSource;
|
||||
enabled?: boolean;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export interface EventSummary {
|
||||
eventId: number;
|
||||
ruleId: number;
|
||||
ruleName: string;
|
||||
source: AlertSource;
|
||||
ownerObjectId: number;
|
||||
ownerObjectName: string;
|
||||
dataDomainCode?: string;
|
||||
metric: AlertMetric;
|
||||
operator: AlertOperator;
|
||||
threshold: number;
|
||||
currentValue: number;
|
||||
severity: AlertSeverity;
|
||||
status: AlertEventStatus;
|
||||
occurrenceCount: number;
|
||||
primaryUserId: number;
|
||||
primaryUserName: string;
|
||||
assigneeUserId?: number;
|
||||
assigneeUserName?: string;
|
||||
openedAt: string;
|
||||
lastOccurredAt: string;
|
||||
resolvedAt?: string;
|
||||
verifiedAt?: string;
|
||||
closedAt?: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface EventQuery {
|
||||
keyword?: string;
|
||||
source?: AlertSource;
|
||||
severity?: AlertSeverity;
|
||||
status?: AlertEventStatus;
|
||||
dataDomainCode?: string;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export interface OccurrenceView {
|
||||
occurrenceId: number;
|
||||
metricValue: number;
|
||||
sampleCount: number;
|
||||
evidenceSha256: string;
|
||||
observedFrom: string;
|
||||
observedTo: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface NotificationView {
|
||||
notificationId: number;
|
||||
type: AlertNotificationType;
|
||||
status: 'RECORDED';
|
||||
recipientUserId: number;
|
||||
recipientUserName: string;
|
||||
contentSummary: string;
|
||||
recordedAt: string;
|
||||
mailboxState?: 'RECORDED' | 'SUBMITTING' | 'STORED' | 'UNKNOWN';
|
||||
mailboxMessageId?: string | number;
|
||||
mailboxAttemptedAt?: string;
|
||||
}
|
||||
|
||||
export interface TimelineView {
|
||||
timelineId: number;
|
||||
action: string;
|
||||
fromStatus?: AlertEventStatus;
|
||||
toStatus: AlertEventStatus;
|
||||
actorUserId?: number;
|
||||
actorName: string;
|
||||
requestId: string;
|
||||
reasonSummary: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface PostmortemView {
|
||||
postmortemId: number;
|
||||
summary: string;
|
||||
rootCause: string;
|
||||
impact: string;
|
||||
correctiveActions: string;
|
||||
evidenceRefs: string[];
|
||||
authorUserId: number;
|
||||
authorName: string;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface EventDetailView {
|
||||
summary: EventSummary;
|
||||
occurrences: OccurrenceView[];
|
||||
notifications: NotificationView[];
|
||||
timeline: TimelineView[];
|
||||
postmortem?: PostmortemView;
|
||||
}
|
||||
|
||||
export interface IdentityCandidate {
|
||||
userId: number;
|
||||
userName: string;
|
||||
nickName: string;
|
||||
}
|
||||
|
||||
export interface NotifyRequest {
|
||||
recipientUserId?: number;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssignRequest {
|
||||
assigneeUserId?: number;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface ProcessRequest {
|
||||
action: ProcessAction;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface VerifyRequest {
|
||||
action: VerifyAction;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PostmortemRequest {
|
||||
summary: string;
|
||||
rootCause: string;
|
||||
impact: string;
|
||||
correctiveActions: string;
|
||||
evidenceRefs: string[];
|
||||
eventVersion: number;
|
||||
postmortemVersion?: number;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export interface AnomalySeriesSelection { detectionId: string; version: number; snapshotIds: string[]; windowStart: string; windowEnd: string }
|
||||
export interface AnomalyProfileChoice { snapshotId: string; observedAt: string; sourceLabel: string }
|
||||
export interface AnomalyThresholdOption { key: string; lower: string | null; upper: string | null; sampleCount: number; fallbackReason: string | null }
|
||||
export interface AnomalySeriesContext {
|
||||
selection: AnomalySeriesSelection; fingerprint: string; sourceLabel: string; observationScope: string;
|
||||
points: { key: string; observedAt: string; rowCount: string }[];
|
||||
evaluation: { verdict: string; reasonCode: string; algorithm: string; algorithmVersion: string; lower: string | null; upper: string | null };
|
||||
thresholdOptions: AnomalyThresholdOption[];
|
||||
}
|
||||
export interface AnomalySeriesCandidate { hypotheses: { text: string; evidenceKeys: string[] }[]; thresholdOptionId: string; reviewNotes: string }
|
||||
export interface AnomalySeriesResult { requestId: string; state: string; fingerprint: string; candidate?: AnomalySeriesCandidate; code?: string }
|
||||
export const anomalyProfileChoices = (id: string, version: number): AxiosPromise<AnomalyProfileChoice[]> => request({ url: `/api/governance/v1/anomaly-detections/assist/${id}/profiles`, params: { version } });
|
||||
export const anomalySeriesContext = (selection: AnomalySeriesSelection): AxiosPromise<AnomalySeriesContext> => request({ url: '/api/governance/v1/anomaly-detections/assist/context', method: 'post', data: selection });
|
||||
export const anomalySeriesCandidate = (data: { requestId: string; selection: AnomalySeriesSelection; fingerprint: string; prompt: string }): AxiosPromise<AnomalySeriesResult> => request({ url: '/api/integration/v1/ai/anomaly-detection/candidates', method: 'post', data, timeout: 120000 });
|
||||
export interface AnomalyStoredEvaluation { resultId: string; detectionId: string; configVersion: number; targetLogicalId: string; targetFqn: string; name: string; verdict: string; observedValue: number; observedAt: string; evaluatedAt: string; evidenceSha: string; samplingStartedAt: string }
|
||||
export const saveAnomalySeriesEvaluation = (data: { selection: AnomalySeriesSelection; fingerprint: string }, key: string): AxiosPromise<AnomalyStoredEvaluation> => request({ url: '/api/governance/v1/anomaly-detections/assist/evaluations', method: 'post', data, headers: { 'Idempotency-Key': key, repeatSubmit: false } });
|
||||
export const readAnomalySeriesEvaluation = (key: string): AxiosPromise<AnomalyStoredEvaluation | null> => request({ url: `/api/governance/v1/anomaly-detections/assist/evaluations/requests/${encodeURIComponent(key)}`, method: 'get' });
|
||||
@@ -0,0 +1,4 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface TargetCandidate { id: string; label: string }
|
||||
export const targetCandidates = (): AxiosPromise<TargetCandidate[]> => request({url:'/api/governance/v1/anomaly-detections/candidates/targets',method:'get'});
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types'; import request from '@/utils/request';
|
||||
interface PageResult<T> { rows: T[]; total: number }
|
||||
import type { BaselineVO, DetectionCommand, DetectionQuery, DetectionStatus, DetectionVO, ObservationCommand, ObservationVO, ResultVO } from './types';
|
||||
const base = '/api/governance/v1/anomaly-detections'; const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const pageDetections = (params: DetectionQuery): AxiosPromise<PageResult<DetectionVO>> => request({ url: base, method: 'get', params });
|
||||
export const getDetection = (id: number | string): AxiosPromise<DetectionVO> => request({ url: `${base}/${id}`, method: 'get' });
|
||||
export const createDetection = (data: DetectionCommand, key: string) => request({ url: base, method: 'post', data, headers: headers(key) });
|
||||
export const updateDetection = (id: number, data: DetectionCommand, key: string) => request({ url: `${base}/${id}`, method: 'put', data, headers: headers(key) });
|
||||
export const changeDetectionStatus = (id: number, data: { targetStatus: DetectionStatus; reason: string; version: number }, key: string) => request({ url: `${base}/${id}/status`, method: 'post', data, headers: headers(key) });
|
||||
export const pageObservations = (id: number, params: PageQuery): AxiosPromise<PageResult<ObservationVO>> => request({ url: `${base}/${id}/observations`, method: 'get', params });
|
||||
export const createObservation = (id: number, data: ObservationCommand, key: string) => request({ url: `${base}/${id}/observations`, method: 'post', data, headers: headers(key) });
|
||||
export const evaluateDetection = (id: number, data: { observationId: number; version: number }, key: string) => request({ url: `${base}/${id}/evaluate`, method: 'post', data, headers: headers(key) });
|
||||
export const pageDetectionResults = (id: number, params: PageQuery): AxiosPromise<PageResult<ResultVO>> => request({ url: `${base}/${id}/results`, method: 'get', params });
|
||||
export const createBaseline = (id: number, data: { sampleCount?: number; version: number }, key: string) => request({ url: `${base}/${id}/baselines`, method: 'post', data, headers: headers(key) });
|
||||
export const pageBaselines = (id: number, params: PageQuery): AxiosPromise<PageResult<BaselineVO>> => request({ url: `${base}/${id}/baselines`, method: 'get', params });
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { AnomalyProfileChoice } from './assist';
|
||||
export interface AnomalyProfileTarget { snapshotId: string; targetLogicalId: string; targetFqn: string; fingerprint: string }
|
||||
export const anomalyTargetProfiles = (): AxiosPromise<AnomalyProfileChoice[]> => request({ url: '/api/governance/v1/anomaly-detections/assist/target-profiles' });
|
||||
export const anomalyProfileTarget = (snapshotId: string): AxiosPromise<AnomalyProfileTarget> => request({ url: '/api/governance/v1/anomaly-detections/assist/target', method: 'post', data: { snapshotId } });
|
||||
@@ -0,0 +1,13 @@
|
||||
export type DetectionType = 'SCHEMA' | 'VOLUME' | 'DISTRIBUTION' | 'FRESHNESS';
|
||||
export type DetectionStatus = 'ENABLED' | 'DISABLED';
|
||||
export type Verdict = 'NORMAL' | 'ANOMALY' | 'UNKNOWN';
|
||||
export type DetectionSeverity = 'INFO' | 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
||||
export type ObservationSource = 'OPENMETADATA' | 'DORIS' | 'HIVE' | 'DOLPHINSCHEDULER' | 'DATAGOV';
|
||||
export interface DetectionProfileTarget { snapshotId: string; fingerprint: string }
|
||||
export interface DetectionQuery extends PageQuery { keyword?: string; type?: DetectionType; status?: DetectionStatus }
|
||||
export interface DetectionVO { detectionId: number; detectionCode: string; detectionName: string; detectionType: DetectionType; targetLogicalId: string; targetFqn: string; expectedSchemaFingerprint?: string; severity: DetectionSeverity; thresholdStrategy: 'FIXED' | 'BASELINE'; fixedLower?: number; fixedUpper?: number; minimumSamples: number; historyLimit: number; deviationMultiplier: number; allowedSources: ObservationSource[]; status: DetectionStatus; version: number; createTime?: string; updateTime?: string }
|
||||
export interface DetectionCommand { detectionCode?: string; detectionName: string; detectionType?: DetectionType; targetLogicalId: string; targetFqn: string; expectedSchemaFingerprint?: string; severity: DetectionSeverity; thresholdStrategy: 'FIXED' | 'BASELINE'; fixedLower?: number; fixedUpper?: number; minimumSamples: number; historyLimit: number; deviationMultiplier: number; allowedSources: ObservationSource[]; version?: number; profileTarget?: DetectionProfileTarget }
|
||||
export interface ObservationCommand { sourceType: ObservationSource; externalRef: string; observedAt: string; payloadSha: string; reliable: boolean; unreliableReason?: string; schemaFingerprint?: string; rowCount?: number; emptyBatch?: boolean; interrupted?: boolean; mean?: number; standardDeviation?: number; minimum?: number; maximum?: number; nullRatio?: number; dataUpdatedAt?: string; arrivedAt?: string; processingDelaySeconds?: number; version: number }
|
||||
export interface ObservationVO extends ObservationCommand { observationId: number; detectionId: number; createTime?: string }
|
||||
export interface ResultVO { resultId: number; detectionId: number; observationId: number; verdict: Verdict; reasonCode: string; reasonSummary?: string; algorithm: string; algorithmVersion: string; sampleCount?: number; lowerBound?: number; upperBound?: number; fallbackReason?: string; evaluatedAt?: string }
|
||||
export interface BaselineVO { baselineId: number; detectionId: number; algorithm: string; algorithmVersion: string; sampleCount: number; lowerBound?: number; upperBound?: number; fallbackReason?: string; createTime?: string }
|
||||
@@ -0,0 +1,14 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { ModelCommand, RequestParameter, ValueType } from './types';
|
||||
export type ApiModelDraft = Omit<ModelCommand, 'version' | 'assistBinding'>;
|
||||
export interface ApiModelSelection { apiId: string; version: number }
|
||||
export interface ApiModelContext { selection: ApiModelSelection; fingerprint: string; method: string; relativePath: string; fields: { name: string; valueType: ValueType; nullable: boolean }[]; pathParameters: RequestParameter[] }
|
||||
export interface ApiModelValidation { selection: ApiModelSelection; fingerprint: string; draft: ApiModelDraft }
|
||||
export interface ApiModelCandidate { requestId: string; state: string; fingerprint: string; candidate: ApiModelDraft | null; code: string }
|
||||
export const getApiModelContext = (data: ApiModelSelection): AxiosPromise<ApiModelContext> => request({ url: '/api/dataproduct/v1/api-model-assist/context', method: 'post', data });
|
||||
export const validateApiModel = (data: ApiModelValidation): AxiosPromise<ApiModelDraft> => request({ url: '/api/dataproduct/v1/api-model-assist/validate', method: 'post', data });
|
||||
export const generateApiModel = (data: ApiModelSelection & { requestId: string; fingerprint: string; fields: string[]; prompt: string }): AxiosPromise<ApiModelCandidate> => {
|
||||
const { apiId, version, ...rest } = data;
|
||||
return request({ url: '/api/integration/v1/ai/api-model/candidates', method: 'post', data: { ...rest, selection: { apiId, version } } });
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
ApiCommand,
|
||||
ApiDevelopmentDetail,
|
||||
ApiDevelopmentPage,
|
||||
ApiDevelopmentQuery,
|
||||
ApiStatusAction,
|
||||
DatasetCandidatePage,
|
||||
DatasetCandidateQuery,
|
||||
DebugCommand,
|
||||
DebugView,
|
||||
DocumentCommand,
|
||||
DocumentView,
|
||||
EntityId,
|
||||
ModelCommand,
|
||||
StatusCommand,
|
||||
WriteResult
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/dataproduct/v1/api-developments';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export const pageApiDevelopments = (params: ApiDevelopmentQuery): AxiosPromise<ApiDevelopmentPage> =>
|
||||
request({ url: baseUrl, method: 'get', params });
|
||||
|
||||
export const pageDatasetCandidates = (params: DatasetCandidateQuery): AxiosPromise<DatasetCandidatePage> =>
|
||||
request({ url: `${baseUrl}/dataset-candidates`, method: 'get', params });
|
||||
|
||||
export const getApiDevelopment = (apiId: EntityId): AxiosPromise<ApiDevelopmentDetail> =>
|
||||
request({ url: `${baseUrl}/${apiId}`, method: 'get' });
|
||||
|
||||
export const listApiDocuments = (apiId: EntityId): AxiosPromise<DocumentView[]> =>
|
||||
request({ url: `${baseUrl}/${apiId}/documents`, method: 'get' });
|
||||
|
||||
export const createApiDevelopment = (data: ApiCommand, key: string): AxiosPromise<WriteResult<ApiDevelopmentDetail>> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateApiDevelopment = (
|
||||
apiId: EntityId,
|
||||
data: ApiCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ApiDevelopmentDetail>> =>
|
||||
request({ url: `${baseUrl}/${apiId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const replaceApiModel = (
|
||||
apiId: EntityId,
|
||||
data: ModelCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ApiDevelopmentDetail>> =>
|
||||
request({ url: `${baseUrl}/${apiId}/model`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const runApiDebug = (
|
||||
apiId: EntityId,
|
||||
data: DebugCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<DebugView>> =>
|
||||
request({ url: `${baseUrl}/${apiId}/debug-runs`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const generateApiDocument = (
|
||||
apiId: EntityId,
|
||||
data: DocumentCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ApiDevelopmentDetail>> =>
|
||||
request({ url: `${baseUrl}/${apiId}/documents`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const changeApiStatus = (
|
||||
apiId: EntityId,
|
||||
action: ApiStatusAction,
|
||||
data: StatusCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ApiDevelopmentDetail>> =>
|
||||
request({ url: `${baseUrl}/${apiId}/status/${action}`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const deleteApiDevelopment = (
|
||||
apiId: EntityId,
|
||||
version: number,
|
||||
key: string
|
||||
): AxiosPromise<void> =>
|
||||
request({ url: `${baseUrl}/${apiId}`, method: 'delete', params: { version }, headers: writeHeaders(key) });
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export interface ProductionParameter { name: string; location: 'PATH' | 'QUERY' | 'BODY'; valueType: string; required: boolean; maxLength: number; description: string }
|
||||
export interface ProductionReadiness { apiId: string; apiVersion: number; method: 'GET' | 'POST'; endpoint: string; ready: boolean; code: string; parameters: ProductionParameter[]; pagination?: { enabled: boolean; pageParameter: string; sizeParameter: string; defaultPageSize: number; maxPageSize: number } }
|
||||
export interface ProductionReceipt { invocationId: string; requestKey: string; apiId: string; apiVersion: number; status: string; outcomeCode: string; executed: boolean; rowCount: number | null; byteCount: number | null; latencyMillis: number | null; authorizationSha256: string | null; createdAt: string; finishedAt: string | null }
|
||||
export interface ProductionResult { receipt: ProductionReceipt; columns: string[]; rows: Record<string, string | null>[]; truncated: boolean; replay: boolean }
|
||||
export interface ProductionCounts { requests: number; succeeded: number; rejected: number; unknown: number; pending: number; latencySamples: number; averageLatencyMillis: string | null; p95LatencyMillis: string | null; returnedRows: string; returnedBytes: string }
|
||||
export interface ProductionUsage { source: 'PUBLISHED_API_REQUEST_LEDGER'; from: string; to: string; hours: number; bucketUnit: 'HOUR' | 'DAY'; limit: number; truncated: boolean; summary: ProductionCounts; buckets: { start: string; counts: ProductionCounts }[]; recent: ProductionReceipt[] }
|
||||
const base = (id: string | number) => `/api/dataproduct/v1/api-developments/${id}/production`;
|
||||
export const productionReadiness = (id: string | number): AxiosPromise<ProductionReadiness> => request({ url: base(id), method: 'get' });
|
||||
export const productionUsage = (id: string | number, hours: number): AxiosPromise<ProductionUsage> => request({ url: `${base(id)}/usage`, method: 'get', params: { hours } });
|
||||
export const productionReceipt = (id: string | number, key: string): AxiosPromise<ProductionReceipt> => request({ url: `${base(id)}/requests/${encodeURIComponent(key)}`, method: 'get', suppressErrorToast: true });
|
||||
export function invocationRequest(view: ProductionReadiness, values: Record<string, string>) {
|
||||
if (!/^\d+$/.test(String(view.apiId)) || !view.endpoint.startsWith(`/api/dataproduct/v1/published-apis/${view.apiId}/`)) throw new Error('调用入口无效');
|
||||
let url = view.endpoint;
|
||||
const params: Record<string, string> = {}, data: Record<string, string> = {};
|
||||
for (const parameter of view.parameters) {
|
||||
const value = values[parameter.name];
|
||||
if (value === undefined || value === '') { if (parameter.required) throw new Error(`请填写${parameter.name}`); continue; }
|
||||
if (value.length > parameter.maxLength) throw new Error(`${parameter.name}超过长度限制`);
|
||||
if (parameter.location === 'PATH') {
|
||||
if (value === '.' || value === '..' || /[\\/]/.test(value)) throw new Error('路径参数不能包含目录跳转或分隔符');
|
||||
url = url.replace(`{${parameter.name}}`, encodeURIComponent(value));
|
||||
}
|
||||
else if (parameter.location === 'QUERY') params[parameter.name] = value;
|
||||
else data[parameter.name] = value;
|
||||
}
|
||||
if (/[{}]/.test(url) || (view.method === 'GET' && Object.keys(data).length)) throw new Error('参数与调用入口不一致');
|
||||
return { url, method: view.method.toLowerCase(), params, ...(view.method === 'POST' ? { data } : {}) };
|
||||
}
|
||||
export const invokeProduction = (view: ProductionReadiness, values: Record<string, string>, key: string): AxiosPromise<ProductionResult> =>
|
||||
request({ ...invocationRequest(view, values), headers: { 'Idempotency-Key': key, repeatSubmit: false }, timeout: 60000, suppressErrorToast: true });
|
||||
@@ -0,0 +1,174 @@
|
||||
export type EntityId = string | number;
|
||||
export type ApiMethod = 'GET' | 'POST';
|
||||
export type ApiStatus = 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'ARCHIVED';
|
||||
export type ApiStatusAction = 'ACTIVATE' | 'DEPRECATE' | 'ARCHIVE';
|
||||
export type ParameterLocation = 'PATH' | 'QUERY' | 'BODY';
|
||||
export type ValueType = 'STRING' | 'INTEGER' | 'DECIMAL' | 'BOOLEAN' | 'DATE' | 'DATETIME';
|
||||
export type DebugStatus = 'IN_PROGRESS' | 'UNKNOWN' | 'SUCCEEDED' | 'CANCELLED' | 'LIMIT_EXCEEDED';
|
||||
|
||||
export interface ApiDevelopmentQuery extends PageQuery {
|
||||
keyword?: string;
|
||||
method?: ApiMethod;
|
||||
status?: ApiStatus;
|
||||
}
|
||||
|
||||
export interface DatasetCandidateQuery extends PageQuery { keyword?: string }
|
||||
|
||||
export interface PublishedDatasetCandidate {
|
||||
datasetId: EntityId;
|
||||
datasetCode: string;
|
||||
datasetName: string;
|
||||
schemaVersionId: EntityId;
|
||||
schemaSha256: string;
|
||||
releaseId: EntityId;
|
||||
datasetVersion: number;
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
sourcePayloadSha256: string;
|
||||
}
|
||||
|
||||
export interface ApiView {
|
||||
apiId: EntityId;
|
||||
apiCode: string;
|
||||
apiName: string;
|
||||
description: string;
|
||||
relativePath: string;
|
||||
method: ApiMethod;
|
||||
status: ApiStatus;
|
||||
datasetId: EntityId;
|
||||
datasetSchemaVersionId: EntityId;
|
||||
datasetSchemaSha256: string;
|
||||
datasetReleaseId: EntityId;
|
||||
datasetVersion: number;
|
||||
organizationId: EntityId;
|
||||
departmentId: EntityId;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface RequestParameter {
|
||||
name: string;
|
||||
location: ParameterLocation;
|
||||
valueType: ValueType;
|
||||
required: boolean;
|
||||
maxLength: number;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface ResponseField {
|
||||
ordinal: number;
|
||||
name: string;
|
||||
valueType: ValueType;
|
||||
nullable: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface PaginationModel {
|
||||
enabled: boolean;
|
||||
pageParameter?: string;
|
||||
sizeParameter?: string;
|
||||
defaultPageSize: number;
|
||||
maxPageSize: number;
|
||||
}
|
||||
|
||||
export interface ErrorModel { code: string; httpStatus: number; description: string }
|
||||
|
||||
export interface ModelView {
|
||||
modelId: EntityId;
|
||||
apiId: EntityId;
|
||||
modelVersion: number;
|
||||
requestParameters: RequestParameter[];
|
||||
responseFields: ResponseField[];
|
||||
pagination: PaginationModel;
|
||||
errors: ErrorModel[];
|
||||
modelSha256: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface DocumentView {
|
||||
documentId: EntityId;
|
||||
apiId: EntityId;
|
||||
documentVersion: number;
|
||||
definitionSha256: string;
|
||||
documentSha256: string;
|
||||
mediaType: string;
|
||||
content: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface DebugView {
|
||||
debugId: EntityId;
|
||||
apiId: EntityId;
|
||||
requestId: string;
|
||||
requestSha256: string;
|
||||
objectSha256: string;
|
||||
boundsSha256: string;
|
||||
datasetId: EntityId;
|
||||
datasetSchemaVersionId: EntityId;
|
||||
datasetSchemaSha256: string;
|
||||
maxRows: number;
|
||||
maxBytes: number;
|
||||
timeoutMillis: number;
|
||||
maxPageSize: number;
|
||||
status: DebugStatus;
|
||||
outcomeCode?: string;
|
||||
outcomeSummary?: string;
|
||||
rowCount: number;
|
||||
byteCount: number;
|
||||
latencyMillis?: number;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
finishTime?: string;
|
||||
}
|
||||
|
||||
export interface TrajectoryView {
|
||||
trajectoryId: EntityId;
|
||||
apiId: EntityId;
|
||||
action: string;
|
||||
beforeStatus: ApiStatus;
|
||||
afterStatus: ApiStatus;
|
||||
requestId: string;
|
||||
evidenceSha256: string;
|
||||
reason: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface ApiDevelopmentDetail {
|
||||
api: ApiView;
|
||||
currentModel?: ModelView;
|
||||
documents: DocumentView[];
|
||||
debugRuns: DebugView[];
|
||||
trajectories: TrajectoryView[];
|
||||
}
|
||||
|
||||
export interface ApiCommand {
|
||||
apiCode: string;
|
||||
apiName: string;
|
||||
description: string;
|
||||
relativePath: string;
|
||||
method: ApiMethod;
|
||||
datasetId: EntityId;
|
||||
datasetSchemaVersionId: EntityId;
|
||||
datasetSchemaSha256: string;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface ModelCommand {
|
||||
assistBinding?: { fingerprint: string };
|
||||
requestParameters: RequestParameter[];
|
||||
responseFields: ResponseField[];
|
||||
pagination: PaginationModel;
|
||||
errors: ErrorModel[];
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface DebugCommand { requestValues: Record<string, string>; reason: string; version: number }
|
||||
export interface DocumentCommand { version: number }
|
||||
export interface StatusCommand { reason: string; version: number }
|
||||
export interface WriteResult<T> { requestId: string; result: T }
|
||||
export interface ApiDevelopmentPage { rows: ApiView[]; total: number }
|
||||
export interface DatasetCandidatePage { rows: PublishedDatasetCandidate[]; total: number }
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export interface ApiUsageCounts {
|
||||
requests: number; succeeded: number; pending: number; unknown: number; cancelled: number; limited: number;
|
||||
latencySamples: number; averageLatencyMillis: string | null; p95LatencyMillis: string | null;
|
||||
returnedRows: string; returnedBytes: string; consumers: number;
|
||||
}
|
||||
export interface ApiUsageView {
|
||||
apiId: string; apiVersion: number; source: 'API_DEBUG_REQUEST_LEDGER'; productionTraffic: 'NOT_CONNECTED';
|
||||
hours: number; from: string; to: string; timeBasis: 'PLATFORM_RECORDED_LOCAL_TIME'; bucketUnit: 'HOUR' | 'DAY';
|
||||
limit: number; truncated: boolean; summary: ApiUsageCounts;
|
||||
buckets: { start: string; counts: ApiUsageCounts }[];
|
||||
datasets: { datasetId: string; schemaVersionId: string; successfulRequests: number; returnedRows: string; returnedBytes: string }[];
|
||||
}
|
||||
export const getApiUsage = (apiId: string | number, hours: number): AxiosPromise<ApiUsageView> =>
|
||||
request({ url: `/api/dataproduct/v1/api-developments/${apiId}/usage`, method: 'get', params: { hours } });
|
||||
@@ -0,0 +1,78 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
ApiManagementDetail,
|
||||
DependencyCommand,
|
||||
DependencyView,
|
||||
DeprecationCommand,
|
||||
DeprecationView,
|
||||
EntityId,
|
||||
LifecycleCommand,
|
||||
LifecycleView,
|
||||
ManagementView,
|
||||
ReviewCommand,
|
||||
ReviewView,
|
||||
VersionCommand,
|
||||
VersionView,
|
||||
WriteResult
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/dataproduct/v1/api-managements';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export const listApiManagements = (): AxiosPromise<ManagementView[]> =>
|
||||
request({ url: baseUrl, method: 'get' });
|
||||
|
||||
export const getApiManagement = (managementId: EntityId): AxiosPromise<ApiManagementDetail> =>
|
||||
request({ url: `${baseUrl}/${managementId}`, method: 'get' });
|
||||
|
||||
export const getApiManagementHistory = (managementId: EntityId): AxiosPromise<ApiManagementDetail> =>
|
||||
request({ url: `${baseUrl}/${managementId}/history`, method: 'get' });
|
||||
|
||||
export const createApiManagement = (
|
||||
data: VersionCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ApiManagementDetail>> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const appendApiManagementVersion = (
|
||||
managementId: EntityId,
|
||||
data: VersionCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<VersionView>> =>
|
||||
request({ url: `${baseUrl}/${managementId}/versions`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const reviewApiManagement = (
|
||||
managementId: EntityId,
|
||||
data: ReviewCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ReviewView>> =>
|
||||
request({ url: `${baseUrl}/${managementId}/reviews`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const applyApiManagementLifecycle = (
|
||||
managementId: EntityId,
|
||||
data: LifecycleCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<LifecycleView>> =>
|
||||
request({ url: `${baseUrl}/${managementId}/lifecycle-actions`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const offlineApiManagement = (
|
||||
managementId: EntityId,
|
||||
data: LifecycleCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<LifecycleView>> =>
|
||||
request({ url: `${baseUrl}/${managementId}/offline-actions`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const deprecateApiManagement = (
|
||||
managementId: EntityId,
|
||||
data: DeprecationCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<DeprecationView>> =>
|
||||
request({ url: `${baseUrl}/${managementId}/deprecations`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const refreshApiManagementDependencies = (
|
||||
managementId: EntityId,
|
||||
data: DependencyCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<DependencyView>> =>
|
||||
request({ url: `${baseUrl}/${managementId}/dependency-snapshots`, method: 'post', data, headers: writeHeaders(key) });
|
||||
@@ -0,0 +1,155 @@
|
||||
export type EntityId = string | number;
|
||||
export type Compatibility = 'COMPATIBLE' | 'REQUIRES_MIGRATION' | 'BREAKING' | 'UNKNOWN';
|
||||
export type ReviewConclusion = 'APPROVED' | 'REJECTED' | 'COMMENTED';
|
||||
export type LifecycleAction = 'PUBLISH' | 'PAUSE' | 'RESUME' | 'OFFLINE';
|
||||
export type LifecycleStatus = 'NOT_CONFIGURED' | 'UNKNOWN' | 'PUBLISHED' | 'PAUSED' | 'OFFLINE';
|
||||
export type DependencyStatus = 'UNKNOWN' | 'RELIABLE';
|
||||
export type DeliveryStatus = 'PENDING_DELIVERY';
|
||||
|
||||
export interface ApiManagementQuery extends PageQuery {
|
||||
keyword?: string;
|
||||
lifecycleStatus?: LifecycleStatus;
|
||||
}
|
||||
|
||||
export interface ManagementView {
|
||||
managementId: EntityId;
|
||||
apiId: EntityId;
|
||||
apiVersion: number;
|
||||
modelSha256: string;
|
||||
datasetSchemaSha256: string;
|
||||
relativePath: string;
|
||||
method: string;
|
||||
majorVersion: number;
|
||||
minorVersion: number;
|
||||
compatibility: Compatibility;
|
||||
changeSummary: string;
|
||||
lifecycleStatus: LifecycleStatus;
|
||||
externalId?: string;
|
||||
appliedAt?: string;
|
||||
lifecycleEvidenceSha256?: string;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface VersionView {
|
||||
snapshotId: EntityId;
|
||||
managementId: EntityId;
|
||||
majorVersion: number;
|
||||
minorVersion: number;
|
||||
compatibility: Compatibility;
|
||||
changeSummary: string;
|
||||
apiVersion: number;
|
||||
modelSha256: string;
|
||||
datasetSchemaSha256: string;
|
||||
relativePath: string;
|
||||
method: string;
|
||||
snapshotSha256: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface ReviewView {
|
||||
reviewId: EntityId;
|
||||
managementId: EntityId;
|
||||
snapshotId: EntityId;
|
||||
conclusion: ReviewConclusion;
|
||||
summary: string;
|
||||
evidenceSha256: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface LifecycleView {
|
||||
requestRecordId: EntityId;
|
||||
managementId: EntityId;
|
||||
snapshotId: EntityId;
|
||||
action: LifecycleAction;
|
||||
status: LifecycleStatus;
|
||||
outcomeCode?: string;
|
||||
outcomeSummary?: string;
|
||||
externalId?: string;
|
||||
appliedAt?: string;
|
||||
evidenceSha256?: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface NotificationView {
|
||||
notificationId: EntityId;
|
||||
callerId: string;
|
||||
status: DeliveryStatus;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface DeprecationView {
|
||||
deprecationId: EntityId;
|
||||
managementId: EntityId;
|
||||
snapshotId: EntityId;
|
||||
deadline: string;
|
||||
reason: string;
|
||||
migrationGuide: string;
|
||||
notifications: NotificationView[];
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface DependencyView {
|
||||
dependencyId: EntityId;
|
||||
managementId: EntityId;
|
||||
snapshotId: EntityId;
|
||||
status: DependencyStatus;
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
sourceSha256: string;
|
||||
observedAt: string;
|
||||
expiresAt: string;
|
||||
callers: string[];
|
||||
downstreamSystems: string[];
|
||||
impacts: string[];
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface ApiManagementDetail {
|
||||
management: ManagementView;
|
||||
versions: VersionView[];
|
||||
reviews: ReviewView[];
|
||||
lifecycleRequests: LifecycleView[];
|
||||
deprecations: DeprecationView[];
|
||||
dependencies: DependencyView[];
|
||||
trajectoryActions: string[];
|
||||
}
|
||||
|
||||
export interface VersionCommand {
|
||||
apiId: EntityId;
|
||||
apiVersion: number;
|
||||
modelSha256: string;
|
||||
datasetSchemaSha256: string;
|
||||
relativePath: string;
|
||||
method: string;
|
||||
majorVersion: number;
|
||||
minorVersion: number;
|
||||
compatibility: Compatibility;
|
||||
changeSummary: string;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface ReviewCommand {
|
||||
conclusion: ReviewConclusion;
|
||||
summary: string;
|
||||
evidenceSha256: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface LifecycleCommand { action: LifecycleAction; reason: string; version: number }
|
||||
export interface DeprecationCommand { deadline: string; reason: string; migrationGuide: string; version: number }
|
||||
export interface DependencyCommand {
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
sourceSha256: string;
|
||||
observedAt: string;
|
||||
expiresAt: string;
|
||||
version: number;
|
||||
}
|
||||
export interface WriteResult<T> { requestId: string; result: T }
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { PageResult } from '@/api/types';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { AttachmentView, CheckRunView, CommentView, ConclusionType, ConclusionView, EntityId, ModelSourceCandidate, ProposalCommand, ProposalStatus, ProposalView, ReviewView, RuleSnapshotCommand, RuleSnapshotView, TimelineView, WriteView } from './types';
|
||||
const baseUrl = '/api/governance/v1/architecture-governance';
|
||||
const headers = () => ({ 'Idempotency-Key': crypto.randomUUID(), repeatSubmit: false });
|
||||
const page = <T>(url: string, params: PageQuery): AxiosPromise<PageResult<T>> => request({ url, method: 'get', params });
|
||||
export const pageArchitectureProposals = (params: PageQuery & { keyword?: string; status?: ProposalStatus }): AxiosPromise<PageResult<ProposalView>> => request({ url: baseUrl, method: 'get', params });
|
||||
export const getArchitectureProposal = (id: EntityId): AxiosPromise<ProposalView> => request({ url: `${baseUrl}/${id}`, method: 'get' });
|
||||
export const pageModelSourceCandidates = (params: PageQuery & { keyword?: string }): AxiosPromise<PageResult<ModelSourceCandidate>> => request({ url: `${baseUrl}/model-sources`, method: 'get', params });
|
||||
export const createArchitectureProposal = (data: ProposalCommand): AxiosPromise<WriteView<ProposalView>> => request({ url: baseUrl, method: 'post', data, headers: headers() });
|
||||
export const createRuleSnapshot = (id: EntityId, data: RuleSnapshotCommand): AxiosPromise<WriteView<RuleSnapshotView>> => request({ url: `${baseUrl}/${id}/rule-snapshots`, method: 'post', data, headers: headers() });
|
||||
export const pageRuleSnapshots = (id: EntityId, params: PageQuery) => page<RuleSnapshotView>(`${baseUrl}/${id}/rule-snapshots`, params);
|
||||
export const executeArchitectureCheck = (id: EntityId, ruleSnapshotId: EntityId, inputSha256: string, version: number): AxiosPromise<WriteView<CheckRunView>> => request({ url: `${baseUrl}/${id}/checks`, method: 'post', data: { ruleSnapshotId, inputSha256, version }, headers: headers() });
|
||||
export const pageArchitectureChecks = (id: EntityId, params: PageQuery) => page<CheckRunView>(`${baseUrl}/${id}/checks`, params);
|
||||
export const openArchitectureReview = (id: EntityId, reviewTitle: string, reviewBasis: string, version: number): AxiosPromise<WriteView<ReviewView>> => request({ url: `${baseUrl}/${id}/reviews`, method: 'post', data: { reviewTitle, reviewBasis, version }, headers: headers() });
|
||||
export const getArchitectureReview = (id: EntityId, reviewId: EntityId): AxiosPromise<ReviewView> => request({ url: `${baseUrl}/${id}/reviews/${reviewId}`, method: 'get' });
|
||||
export const addReviewComment = (id: EntityId, reviewId: EntityId, content: string, version: number): AxiosPromise<WriteView<CommentView>> => request({ url: `${baseUrl}/${id}/reviews/${reviewId}/comments`, method: 'post', data: { content, version }, headers: headers() });
|
||||
export const pageReviewComments = (id: EntityId, reviewId: EntityId, params: PageQuery) => page<CommentView>(`${baseUrl}/${id}/reviews/${reviewId}/comments`, params);
|
||||
export const concludeArchitectureReview = (id: EntityId, reviewId: EntityId, conclusion: ConclusionType, checkRunId: EntityId, basis: string, version: number): AxiosPromise<WriteView<ConclusionView>> => request({ url: `${baseUrl}/${id}/reviews/${reviewId}/conclusion`, method: 'post', data: { conclusion, checkRunId, basis, version }, headers: headers() });
|
||||
export const getReviewConclusion = (id: EntityId, reviewId: EntityId): AxiosPromise<ConclusionView> => request({ url: `${baseUrl}/${id}/reviews/${reviewId}/conclusion`, method: 'get' });
|
||||
export const addReviewAttachment = (id: EntityId, reviewId: EntityId, data: { fileRef: string; fileName: string; fileSize: number; fileSha256: string; version: number }): AxiosPromise<WriteView<AttachmentView>> => request({ url: `${baseUrl}/${id}/reviews/${reviewId}/attachments`, method: 'post', data, headers: headers() });
|
||||
export const pageReviewAttachments = (id: EntityId, reviewId: EntityId, params: PageQuery) => page<AttachmentView>(`${baseUrl}/${id}/reviews/${reviewId}/attachments`, params);
|
||||
export const pageArchitectureTimeline = (id: EntityId, params: PageQuery) => page<TimelineView>(`${baseUrl}/${id}/timeline`, params);
|
||||
export const getArchitectureStatus = (id: EntityId): AxiosPromise<ProposalStatus> => request({ url: `${baseUrl}/${id}/status`, method: 'get' });
|
||||
@@ -0,0 +1,22 @@
|
||||
export type EntityId = string | number;
|
||||
export type ProposalType = 'NEW' | 'CHANGE';
|
||||
export type ProposalStatus = 'OPEN' | 'IN_REVIEW' | 'CONCLUDED';
|
||||
export type RuleType = 'NAMING' | 'LAYERING' | 'DATA_TYPE' | 'COMMON_FIELD' | 'SECURITY';
|
||||
export type CheckStatus = 'PASS' | 'FAIL' | 'UNKNOWN';
|
||||
export type ConclusionType = 'APPROVED' | 'CONDITIONAL' | 'REJECTED';
|
||||
export type TimelineType = 'CREATED' | 'RULES_SNAPSHOTTED' | 'CHECKED' | 'REVIEW_OPENED' | 'COMMENTED' | 'ATTACHED' | 'CONCLUDED';
|
||||
export interface StructuredPlan { objectName: string; layerCode: string; dataType: string; commonFields: string[]; securityTags: string[] }
|
||||
export interface ModelSourceCandidate { sourceRef: string; modelLogicalId: string; modelDisplayName: string; sourceVersion: string }
|
||||
export interface ProposalCommand { proposalCode: string; proposalName: string; proposalType: ProposalType; modelLogicalId: string; modelDisplayName: string; impactStatement: string; sourceRef: string; sourceVersion: string; payloadSha256?: string; plan: StructuredPlan }
|
||||
export interface RuleDefinition { ruleCode: string; ruleType: RuleType; expectedValue: string; required: boolean; rationale: string }
|
||||
export interface RuleSnapshotCommand { sourceRef: string; sourceVersion: string; payloadSha256?: string; rules: RuleDefinition[]; version: number }
|
||||
export interface ProposalView extends ProposalCommand { payloadSha256: string; sourceDisplayName?: string; proposalId: EntityId; status: ProposalStatus; organizationId: EntityId; departmentId: EntityId; version: number; createTime?: string; updateTime?: string }
|
||||
export interface RuleSnapshotView { ruleSnapshotId: EntityId; proposalId: EntityId; sourceRef: string; sourceDisplayName?: string; sourceVersion: string; payloadSha256: string; rulesSha256: string; rules: RuleDefinition[]; createTime?: string }
|
||||
export interface CheckItemView { checkItemId: EntityId; checkRunId: EntityId; ruleCode: string; ruleType: RuleType; status: CheckStatus; reason: string; expectedValue: string }
|
||||
export interface CheckRunView { checkRunId: EntityId; proposalId: EntityId; ruleSnapshotId: EntityId; inputSha256: string; rulesSha256: string; overallStatus: CheckStatus; items: CheckItemView[]; createTime?: string }
|
||||
export interface ReviewView { reviewId: EntityId; proposalId: EntityId; reviewTitle: string; reviewBasis: string; openedBy: EntityId; openedByName?: string; createTime?: string }
|
||||
export interface CommentView { commentId: EntityId; reviewId: EntityId; content: string; actorId: EntityId; actorName?: string; createTime?: string }
|
||||
export interface ConclusionView { conclusionId: EntityId; reviewId: EntityId; conclusion: ConclusionType; checkRunId: EntityId; basis: string; actorId: EntityId; actorName?: string; createTime?: string }
|
||||
export interface AttachmentView { attachmentId: EntityId; reviewId: EntityId; fileRef: string; fileName: string; fileSize: number; fileSha256: string; actorId: EntityId; actorName?: string; createTime?: string }
|
||||
export interface TimelineView { timelineId: EntityId; proposalId: EntityId; eventType: TimelineType; eventSummary: string; requestId: string; actorId: EntityId; actorName?: string; createTime?: string }
|
||||
export interface WriteView<T> { requestId: string; result: T }
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export type CatalogId = number | string;
|
||||
export type CatalogAssistMode = 'CREATE' | 'UPDATE' | 'MOVE';
|
||||
export interface CatalogAssistSelection { mode: CatalogAssistMode; objectId: CatalogId | null; nodeIds: CatalogId[] }
|
||||
export interface CatalogAssistNode { key: string; catalogId: CatalogId; version: CatalogId; name: string; description: string | null; parentKey: string | null; parentVisible: boolean; eligibleParent: boolean }
|
||||
export interface CatalogAssistContext { selection: CatalogAssistSelection; nodes: CatalogAssistNode[]; collisions: Array<{ leftKey: string; rightKey: string; kind: string }>; rootAllowed: boolean; scopeNote: string; contextSha256: string }
|
||||
export interface CatalogAssistCandidate { parentKey: string | null; catalogName: string | null; description: string | null; reason: string; nodeKeys: string[] }
|
||||
export interface CatalogAssistResult { requestId: string; state: string; answer: string | null; candidates: CatalogAssistCandidate[]; code: string | null }
|
||||
export const readCatalogContext = (data: CatalogAssistSelection, signal?: AbortSignal): AxiosPromise<CatalogAssistContext> => request({ url: '/api/governance/v1/asset-catalogs/assist/context', method: 'post', data, signal });
|
||||
export const generateCatalogCandidates = (data: { requestId: string; selection: CatalogAssistSelection; contextSha256: string; catalogName: string; description: string; prompt: string }, signal?: AbortSignal): AxiosPromise<CatalogAssistResult> => request({ url: '/api/integration/v1/ai/asset-catalog', method: 'post', data, signal });
|
||||
@@ -0,0 +1,29 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface CatalogIdentityLink {
|
||||
linkId: string; registrationId: string; version: string; assetId: string; businessVersion: string;
|
||||
evidenceSha256: string; expiresAt: string; linkedAt: string; requestId: string;
|
||||
}
|
||||
export interface CatalogIdentityInspection {
|
||||
registrationId: string; registrationVersion: string; assetRef: string; readAt: string;
|
||||
resolutionState: 'MAPPED' | 'UNMAPPED' | 'AMBIGUOUS' | 'UNKNOWN';
|
||||
associationState: 'UNLINKED' | 'CURRENT' | 'STALE' | 'UNKNOWN';
|
||||
candidate: { assetId: string; businessVersion: string; evidenceSha256: string; expiresAt: string } | null;
|
||||
link: CatalogIdentityLink | null;
|
||||
unavailableReason?: string;
|
||||
}
|
||||
export interface CatalogIdentityCommand {
|
||||
registrationVersion: string; expectedLinkVersion: string; assetId: string; businessVersion: string; evidenceSha256: string;
|
||||
}
|
||||
export interface CatalogIdentityRequestReceipt {
|
||||
state: 'NOT_OBSERVED' | 'COMPLETED' | 'CANCELED_NO_WRITE' | 'PROCESSING' | 'UNKNOWN';
|
||||
registrationId: string; requestKey: string; link: CatalogIdentityLink | null;
|
||||
}
|
||||
const base = (id: string) => `/api/governance/v1/asset-catalogs/registrations/${encodeURIComponent(id)}/identity-link`;
|
||||
export const inspectCatalogIdentity = (id: string): AxiosPromise<CatalogIdentityInspection> => request({ url: base(id), method: 'get', suppressErrorToast: true });
|
||||
export const saveCatalogIdentity = (id: string, data: CatalogIdentityCommand, key: string): AxiosPromise<CatalogIdentityLink> =>
|
||||
request({ url: base(id), method: 'post', data, headers: { 'Idempotency-Key': key }, suppressErrorToast: true });
|
||||
export const readCatalogIdentityRequest = (id: string, key: string): AxiosPromise<CatalogIdentityRequestReceipt> =>
|
||||
request({ url: `${base(id)}/requests/${encodeURIComponent(key)}`, method: 'get', suppressErrorToast: true });
|
||||
export const cancelCatalogIdentityRequest = (id: string, key: string): AxiosPromise<CatalogIdentityRequestReceipt> =>
|
||||
request({ url: `${base(id)}/requests/${encodeURIComponent(key)}/cancel`, method: 'post', headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AssetCatalogDetail,
|
||||
AssetCatalogNode,
|
||||
AssetCatalogWriteResult,
|
||||
CatalogAssetCommand,
|
||||
InventoryCatalogCommand,
|
||||
CatalogPermission,
|
||||
CatalogPermissionCommand,
|
||||
CatalogPublication,
|
||||
CatalogStatusCommand,
|
||||
CreateCatalogCommand,
|
||||
MoveCatalogCommand,
|
||||
PublishCatalogCommand,
|
||||
UpdateCatalogCommand
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/governance/v1/asset-catalogs';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export const listAssetCatalogTree = (): AxiosPromise<AssetCatalogNode[]> =>
|
||||
request({ url: baseUrl, method: 'get' });
|
||||
|
||||
export const getAssetCatalog = (catalogId: number): AxiosPromise<AssetCatalogDetail> =>
|
||||
request({ url: `${baseUrl}/${catalogId}`, method: 'get' });
|
||||
|
||||
export const createAssetCatalog = (
|
||||
data: CreateCatalogCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<AssetCatalogDetail>> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const updateAssetCatalog = (
|
||||
catalogId: number,
|
||||
data: UpdateCatalogCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<AssetCatalogDetail>> =>
|
||||
request({ url: `${baseUrl}/${catalogId}`, method: 'patch', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const moveAssetCatalog = (
|
||||
catalogId: number,
|
||||
data: MoveCatalogCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<AssetCatalogDetail>> =>
|
||||
request({ url: `${baseUrl}/${catalogId}/parent`, method: 'put', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const catalogAsset = (
|
||||
catalogId: number,
|
||||
data: CatalogAssetCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<AssetCatalogDetail>> =>
|
||||
request({ url: `${baseUrl}/${catalogId}/assets`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const catalogInventoryAsset = (
|
||||
catalogId: number,
|
||||
data: InventoryCatalogCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<AssetCatalogDetail>> =>
|
||||
request({ url: `${baseUrl}/${catalogId}/inventory-assets`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const publishAssetCatalog = (
|
||||
catalogId: number,
|
||||
data: PublishCatalogCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<CatalogPublication>> =>
|
||||
request({ url: `${baseUrl}/${catalogId}/publications`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const grantAssetCatalogPermission = (
|
||||
catalogId: number,
|
||||
data: CatalogPermissionCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<CatalogPermission>> =>
|
||||
request({ url: `${baseUrl}/${catalogId}/permissions`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const changeAssetCatalogStatus = (
|
||||
catalogId: number,
|
||||
data: CatalogStatusCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetCatalogWriteResult<AssetCatalogDetail>> =>
|
||||
request({ url: `${baseUrl}/${catalogId}/status`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
@@ -0,0 +1,14 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface CatalogOverviewData {
|
||||
scopeHash: string; readAt: string; lastRegistrationUpdate?: string; countKind: 'REGISTRATION'; truncated: boolean;
|
||||
groups: { catalogId: string; name: string; status: string; types: { type: string; reliable: number | string; uncertain: number | string }[] }[];
|
||||
}
|
||||
export const getCatalogOverview = (): AxiosPromise<CatalogOverviewData> => request({ url: '/api/governance/v1/asset-catalogs/overview', method: 'get' });
|
||||
export interface CatalogRegistrations {
|
||||
scopeHash: string; readAt: string;
|
||||
catalogs: { catalogId: string; name: string; status: string }[];
|
||||
rows: { registrationId: string; catalogId: string; assetRef: string | null; name: string | null; type: string | null; reliable: boolean; version: number | string }[];
|
||||
}
|
||||
export const getCatalogRegistrations = (catalogId?: string): AxiosPromise<CatalogRegistrations> =>
|
||||
request({ url: '/api/governance/v1/asset-catalogs/registrations', method: 'get', params: { catalogId }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export type CatalogSourceType = 'MODEL' | 'DATASET' | 'FILE' | 'API' | 'REPORT';
|
||||
export type CatalogSourceOwner = 'MODEL_DESIGN' | 'DATASET_DEFINITION' | 'DATASET_INPUT_FILE' | 'API_DEVELOPMENT' | 'BI_REPORT';
|
||||
export interface CatalogIdentitySource { sourceRef: string; sourceCode: string; sourceName: string; sourceVersion: string }
|
||||
export interface CatalogSourcePreview { registrationId: string; registrationVersion: string; type: CatalogSourceType; owner: CatalogSourceOwner; source: CatalogIdentitySource; evidenceSha256: string; expiresAt: string }
|
||||
export interface CatalogSourceLink { linkId: string; registrationId: string; version: string; type: CatalogSourceType; owner: CatalogSourceOwner; sourceRef: string;
|
||||
sourceVersion: string; sourceCode: string; sourceName: string; evidenceSha256: string; expiresAt: string; linkedAt: string; requestId: string }
|
||||
export interface CatalogSourceInspection { registrationId: string; registrationVersion: string; assetRef: string;
|
||||
associationState: 'UNLINKED' | 'CURRENT' | 'STALE' | 'UNKNOWN'; link: CatalogSourceLink | null; current: CatalogSourcePreview | null; readAt: string }
|
||||
export interface CatalogSourceCommand { registrationVersion: string; expectedLinkVersion: string; sourceRef: string; sourceVersion: string; evidenceSha256: string }
|
||||
export interface CatalogSourceReceipt { state: 'NOT_OBSERVED' | 'COMPLETED' | 'CANCELED_NO_WRITE' | 'PROCESSING' | 'UNKNOWN'; registrationId: string; requestKey: string; link: CatalogSourceLink | null }
|
||||
const base = (id: string) => `/api/governance/v1/asset-catalogs/registrations/${encodeURIComponent(id)}/source-identity`;
|
||||
export const inspectCatalogSource = (id: string): AxiosPromise<CatalogSourceInspection> => request({ url: base(id), method: 'get', suppressErrorToast: true });
|
||||
export const catalogSourceCandidates = (id: string, keyword: string, pageNum: number): AxiosPromise<{ rows: CatalogIdentitySource[]; total: number }> => request({ url: `${base(id)}/candidates`, method: 'get', params: { keyword, pageNum, pageSize: 10 }, suppressErrorToast: true });
|
||||
export const previewCatalogSource = (id: string, sourceRef: string): AxiosPromise<CatalogSourcePreview> => request({ url: `${base(id)}/preview`, method: 'get', params: { sourceRef }, suppressErrorToast: true });
|
||||
export const linkCatalogSource = (id: string, data: CatalogSourceCommand, key: string): AxiosPromise<CatalogSourceLink> => request({ url: base(id), method: 'post', data, headers: { 'Idempotency-Key': key }, suppressErrorToast: true });
|
||||
export const readCatalogSourceRequest = (id: string, key: string): AxiosPromise<CatalogSourceReceipt> => request({ url: `${base(id)}/requests/${encodeURIComponent(key)}`, method: 'get', suppressErrorToast: true });
|
||||
export const cancelCatalogSourceRequest = (id: string, key: string): AxiosPromise<CatalogSourceReceipt> => request({ url: `${base(id)}/requests/${encodeURIComponent(key)}/cancel`, method: 'post', headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,12 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface CatalogIdentitySummary {
|
||||
scopeHash: string; readAt: string; expiresAt?: string; countKind: 'DISTINCT_CURRENT_LINKED_TABLE_IDENTITY' | 'DISTINCT_CURRENT_TYPED_SOURCE_IDENTITY';
|
||||
registrations: number; tableRegistrations: number; verifiedRegistrations: number; distinctIdentities: number;
|
||||
duplicateRegistrations: number; unlinked: number; stale: number; unknown: number; unsupported: number;
|
||||
supportedRegistrations?: number;
|
||||
types?: { type: string; registrations: number; reliableRegistrations: number;
|
||||
verification: 'SUPPORTED' | 'NOT_CONNECTED'; verifiedRegistrations: number | null; distinctIdentities: number | null }[];
|
||||
}
|
||||
export const getCatalogIdentitySummary = (catalogId?: string): AxiosPromise<CatalogIdentitySummary> =>
|
||||
request({ url: '/api/governance/v1/asset-catalogs/identity-summary', method: 'get', params: { catalogId }, timeout: 45000, suppressErrorToast: true });
|
||||
@@ -0,0 +1,159 @@
|
||||
export type CatalogStatus = 'DRAFT' | 'PUBLISHED' | 'UNPUBLISHED';
|
||||
export type CatalogAssetType = 'TABLE' | 'DATASET' | 'FILE' | 'REPORT' | 'API' | 'MODEL';
|
||||
export type CatalogSubjectType = 'USER' | 'ROLE' | 'ORGANIZATION' | 'DEPARTMENT';
|
||||
export type CatalogAction = 'VIEW' | 'MAINTAIN' | 'PUBLISH' | 'PERMISSION';
|
||||
|
||||
export interface AssetCatalogNode {
|
||||
catalogId: number;
|
||||
catalogCode: string;
|
||||
catalogName: string;
|
||||
parentId?: number;
|
||||
description?: string;
|
||||
sortOrder: number;
|
||||
status: CatalogStatus;
|
||||
organizationId: number;
|
||||
departmentId: number;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetCatalogTreeNode extends AssetCatalogNode {
|
||||
children?: AssetCatalogTreeNode[];
|
||||
}
|
||||
|
||||
export interface CatalogAsset {
|
||||
catalogAssetId: number;
|
||||
catalogId: number;
|
||||
assetRef: string;
|
||||
assetFqn: string;
|
||||
assetType: CatalogAssetType;
|
||||
assetName: string;
|
||||
description?: string;
|
||||
tags: string[];
|
||||
ownerType: CatalogSubjectType;
|
||||
ownerRef: string;
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
observedAt: string;
|
||||
reliable: boolean;
|
||||
payloadSha256: string;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface CatalogPublication {
|
||||
publicationId: number;
|
||||
catalogId: number;
|
||||
publicationVersion: number;
|
||||
snapshotSha256: string;
|
||||
itemCount: number;
|
||||
reason: string;
|
||||
actorId: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface CatalogPermission {
|
||||
permissionId: number;
|
||||
catalogId: number;
|
||||
subjectType: CatalogSubjectType;
|
||||
subjectRef: string;
|
||||
actions: CatalogAction[];
|
||||
includeDescendants: boolean;
|
||||
effectiveFrom?: string;
|
||||
effectiveTo?: string;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface CatalogTrajectory {
|
||||
trajectoryId: number;
|
||||
catalogId: number;
|
||||
actionType: string;
|
||||
beforeStatus?: string;
|
||||
afterStatus?: string;
|
||||
requestId: string;
|
||||
actorId: number;
|
||||
summary?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetCatalogDetail {
|
||||
node: AssetCatalogNode;
|
||||
assets: CatalogAsset[];
|
||||
publications: CatalogPublication[];
|
||||
permissions: CatalogPermission[];
|
||||
trajectories: CatalogTrajectory[];
|
||||
}
|
||||
|
||||
export interface AssetCatalogWriteResult<T> {
|
||||
requestId: string;
|
||||
result: T;
|
||||
}
|
||||
|
||||
export interface CreateCatalogCommand {
|
||||
catalogCode: string;
|
||||
catalogName: string;
|
||||
parentId?: number;
|
||||
description?: string;
|
||||
sortOrder: number;
|
||||
}
|
||||
|
||||
export interface UpdateCatalogCommand {
|
||||
catalogName: string;
|
||||
description?: string;
|
||||
sortOrder: number;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface MoveCatalogCommand {
|
||||
parentId?: number;
|
||||
sortOrder: number;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface CatalogAssetCommand {
|
||||
assetRef: string;
|
||||
assetFqn: string;
|
||||
assetType: CatalogAssetType;
|
||||
assetName: string;
|
||||
description?: string;
|
||||
tags: string[];
|
||||
ownerType: CatalogSubjectType;
|
||||
ownerRef: string;
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
observedAt: string;
|
||||
reliable: true;
|
||||
payloadSha256: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface InventoryCatalogCommand {
|
||||
taskId: number;
|
||||
candidateId: number;
|
||||
candidateVersion: number;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PublishCatalogCommand {
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface CatalogPermissionCommand {
|
||||
subjectType: CatalogSubjectType;
|
||||
subjectRef: string;
|
||||
actions: CatalogAction[];
|
||||
includeDescendants: boolean;
|
||||
effectiveFrom?: string;
|
||||
effectiveTo?: string;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface CatalogStatusCommand {
|
||||
targetStatus: 'UNPUBLISHED';
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { MaterialRef, ReferenceId, ReviewContent, ScopeSelection, VerificationState } from './types';
|
||||
|
||||
export interface ComplianceAssistSelection { reviewId: ReferenceId | null; version: number; scope: ScopeSelection; materials: MaterialRef[] }
|
||||
export interface ComplianceMaterialFact { key: string; label: string; kind: string; version: ReferenceId; state: VerificationState; validUntil: string }
|
||||
export interface ComplianceAuthorizationFact { key: string; rightType: string | null; state: VerificationState; validFrom: string | null; validUntil: string | null; restrictionsDeclared: boolean }
|
||||
export interface ComplianceGap { field: keyof ReviewContent; code: string; message: string; evidenceKeys: string[] }
|
||||
export interface ComplianceAssistContext {
|
||||
selection: ComplianceAssistSelection; objectLabel: string; purposeLabel: string; fieldCount: number;
|
||||
ownerState: VerificationState; materials: ComplianceMaterialFact[]; authorizations: ComplianceAuthorizationFact[];
|
||||
gaps: ComplianceGap[]; scopeNote: string; contextSha256: string;
|
||||
}
|
||||
export interface ComplianceAssistCandidate { field: keyof ReviewContent; text: string; reason: string; evidenceKeys: string[]; questions: string[] }
|
||||
export interface ComplianceAssistResult { requestId: string; state: string; answer: string | null; candidates: ComplianceAssistCandidate[]; code: string | null }
|
||||
export const readComplianceContext = (data: ComplianceAssistSelection, signal?: AbortSignal): AxiosPromise<ComplianceAssistContext> => request({ url: '/api/governance/v1/asset-compliance/assist/context', method: 'post', data, signal });
|
||||
export const generateComplianceCandidates = (data: { requestId: string; selection: ComplianceAssistSelection; contextSha256: string; content: Partial<ReviewContent>; prompt: string }, signal?: AbortSignal): AxiosPromise<ComplianceAssistResult> => request({ url: '/api/integration/v1/ai/asset-compliance', method: 'post', data, signal });
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { Candidate, Page, ReviewRecord, SaveCommand, ScopeSelection, ScopeView, VerificationView, ReferenceId } from './types';
|
||||
|
||||
const base = '/api/governance/v1/asset-compliance';
|
||||
const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const listReviews = (params: { keyword?: string; page: number; size: number }): AxiosPromise<Page<ReviewRecord>> => request({ url: base, method: 'get', params });
|
||||
export const getReview = (id: ReferenceId): AxiosPromise<ReviewRecord> => request({ url: `${base}/${encodeURIComponent(id)}`, method: 'get' });
|
||||
export const listCandidates = (params: { keyword?: string; page: number; size: number }): AxiosPromise<Page<Candidate>> => request({ url: `${base}/candidates`, method: 'get', params });
|
||||
export const readMaterials = (data: ScopeSelection): AxiosPromise<ScopeView> => request({ url: `${base}/materials`, method: 'post', data });
|
||||
export const saveReview = (data: SaveCommand, key: string): AxiosPromise<ReviewRecord> => request({ url: data.id === null ? base : `${base}/${encodeURIComponent(data.id)}`, method: data.id === null ? 'post' : 'put', headers: headers(key), data });
|
||||
export const submitReview = (id: ReferenceId, version: number, key: string): AxiosPromise<ReviewRecord> => request({ url: `${base}/${encodeURIComponent(id)}/submit`, method: 'post', headers: headers(key), data: { version, opinion: '' } });
|
||||
export const decideReview = (id: ReferenceId, version: number, decision: 'APPROVE' | 'NEEDS_MATERIAL' | 'REJECT', opinion: string, key: string): AxiosPromise<ReviewRecord> => request({ url: `${base}/${encodeURIComponent(id)}/review/${decision}`, method: 'post', headers: headers(key), data: { version, opinion } });
|
||||
export const verifyReview = (id: ReferenceId): AxiosPromise<VerificationView> => request({ url: `${base}/${encodeURIComponent(id)}/verify`, method: 'post' });
|
||||
@@ -0,0 +1,29 @@
|
||||
export type ReferenceId = string | number;
|
||||
export type VerificationState = 'VERIFIED' | 'UNRESOLVED' | 'REVOKED' | 'EXPIRED' | 'DENIED';
|
||||
export type ReviewStatus = 'DRAFT' | 'SUBMITTED' | 'NEEDS_MATERIAL' | 'APPROVED' | 'REJECTED';
|
||||
export interface Option { reference: string; label: string }
|
||||
export interface Candidate {
|
||||
reference: string; label: string;
|
||||
object: { owner: string; objectType: string; objectId: string; resourceVersion: ReferenceId; versionKind: 'DRAFT' | 'FROZEN' };
|
||||
contentSha256: string | null; purposes: Option[]; recipients: Option[]; fields: Option[];
|
||||
}
|
||||
export interface Page<T> { rows: T[]; total: number; page: number; size: number }
|
||||
export interface ScopeSelection {
|
||||
candidateRef: string; purposeRef: string; recipientRef: string; fields: string[]; requestedExpiresAt: string;
|
||||
}
|
||||
export interface MaterialRef { owner: string; reference: string; version: ReferenceId }
|
||||
export interface MaterialOption { reference: MaterialRef; label: string; evidenceKind: string; state: VerificationState }
|
||||
export interface ScopeView { objectLabel: string; purposeLabel: string; recipientLabel: string; state: VerificationState; materials: MaterialOption[] }
|
||||
export interface ReviewContent {
|
||||
sourceLegality: string; rightsChain: string; personalInformation: string;
|
||||
sensitiveInformation: string; tradeSecrets: string; deliveryRestrictions: string;
|
||||
}
|
||||
export interface ReviewRecord {
|
||||
id: ReferenceId; version: number; status: ReviewStatus; selection: ScopeSelection;
|
||||
objectLabel: string; purposeLabel: string; recipientLabel: string;
|
||||
materials: MaterialOption[]; content: ReviewContent; submittedBy: ReferenceId | null;
|
||||
reviewedBy: ReferenceId | null; opinion: string | null; createdAt: string; updatedAt: string;
|
||||
validFrom: string | null; expiresAt: string | null;
|
||||
}
|
||||
export interface SaveCommand { id: ReferenceId | null; version: number; selection: ScopeSelection; materials: MaterialRef[]; content: ReviewContent }
|
||||
export interface VerificationView { state: VerificationState; message: string; expiresAt: string | null }
|
||||
@@ -0,0 +1,83 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AssetDetail,
|
||||
AssetDetailCreateCommand,
|
||||
AssetDetailItem,
|
||||
AssetDetailWriteResult,
|
||||
AssetGovernanceCommand,
|
||||
AssetOwnerCommand,
|
||||
AssetRelationCommand,
|
||||
AssetSnapshotCommand,
|
||||
AssetStatusCommand,
|
||||
GovernanceCandidate,
|
||||
RelationCandidatePage,
|
||||
RelationType,
|
||||
SourceCandidateDetail,
|
||||
SourceCandidatePage
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/governance/v1/asset-details';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export const listAssetDetails = (): AxiosPromise<AssetDetailItem[]> =>
|
||||
request({ url: baseUrl, method: 'get' });
|
||||
|
||||
export const getAssetDetail = (assetDetailId: number): AxiosPromise<AssetDetail> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}`, method: 'get' });
|
||||
|
||||
export const listAssetSourceCandidates = (params: { limit?: number; after?: string; keyword?: string }): AxiosPromise<SourceCandidatePage> =>
|
||||
request({ url: `${baseUrl}/candidates/sources`, method: 'get', params });
|
||||
|
||||
export const getAssetSourceCandidate = (entityId: string): AxiosPromise<SourceCandidateDetail> =>
|
||||
request({ url: `${baseUrl}/candidates/sources/${encodeURIComponent(entityId)}`, method: 'get' });
|
||||
|
||||
export const listAssetGovernanceCandidates = (assetDetailId: number): AxiosPromise<GovernanceCandidate[]> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}/candidates/governance`, method: 'get' });
|
||||
|
||||
export const listAssetRelationCandidates = (
|
||||
assetDetailId: number,
|
||||
params: { relationType: RelationType; limit?: number; after?: string; keyword?: string }
|
||||
): AxiosPromise<RelationCandidatePage> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}/candidates/relations`, method: 'get', params });
|
||||
|
||||
export const createAssetDetail = (
|
||||
data: AssetDetailCreateCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetDetailWriteResult> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const appendAssetSnapshot = (
|
||||
assetDetailId: number,
|
||||
data: AssetSnapshotCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetDetailWriteResult> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}/snapshots`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const appendAssetOwner = (
|
||||
assetDetailId: number,
|
||||
data: AssetOwnerCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetDetailWriteResult> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}/owners`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const appendAssetGovernance = (
|
||||
assetDetailId: number,
|
||||
data: AssetGovernanceCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetDetailWriteResult> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}/governance`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const appendAssetRelation = (
|
||||
assetDetailId: number,
|
||||
data: AssetRelationCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetDetailWriteResult> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}/relations`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const changeAssetDetailStatus = (
|
||||
assetDetailId: number,
|
||||
data: AssetStatusCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetDetailWriteResult> =>
|
||||
request({ url: `${baseUrl}/${assetDetailId}/status`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
@@ -0,0 +1,206 @@
|
||||
export type AssetStatus = 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'ARCHIVED';
|
||||
export type SectionType = 'DEFINITION' | 'SCHEMA' | 'SOURCE' | 'LINEAGE' | 'QUALITY' | 'SECURITY' | 'USAGE';
|
||||
export type EvidenceState = 'KNOWN' | 'UNKNOWN';
|
||||
export type OwnerType = 'OWNER' | 'STEWARD' | 'BUSINESS_OWNER' | 'TECHNICAL_OWNER';
|
||||
export type SubjectType = 'USER' | 'ROLE' | 'ORGANIZATION' | 'DEPARTMENT';
|
||||
export type GovernanceType = 'STANDARD' | 'QUALITY' | 'SECURITY' | 'COMPLIANCE' | 'CERTIFICATION' | 'REMEDIATION';
|
||||
export type RelationType = 'METRIC' | 'TERM' | 'MODEL' | 'TASK' | 'PRODUCT' | 'APPLICATION';
|
||||
export type CandidateAvailability = 'AVAILABLE' | 'UNAVAILABLE';
|
||||
|
||||
export interface SectionCommand {
|
||||
sectionType: SectionType;
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
observedAt?: string;
|
||||
reliable: boolean;
|
||||
payloadSha256: string;
|
||||
value?: string;
|
||||
}
|
||||
|
||||
export interface AssetDetailCreateCommand {
|
||||
assetRef: string;
|
||||
assetFqn: string;
|
||||
entityId: string;
|
||||
sections: SectionCommand[];
|
||||
}
|
||||
|
||||
export interface AssetSnapshotCommand {
|
||||
sections: SectionCommand[];
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetOwnerCommand {
|
||||
ownerType: OwnerType;
|
||||
subjectType: SubjectType;
|
||||
subjectRef: string;
|
||||
effectiveFrom?: string;
|
||||
effectiveTo?: string;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetGovernanceCommand {
|
||||
governanceType: GovernanceType;
|
||||
evidenceRef: string;
|
||||
observedAt?: string;
|
||||
reliable: boolean;
|
||||
evidenceSha256: string;
|
||||
value?: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetRelationCommand {
|
||||
relationType: RelationType;
|
||||
targetRef: string;
|
||||
evidenceRef: string;
|
||||
observedAt?: string;
|
||||
reliable: boolean;
|
||||
evidenceSha256: string;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetStatusCommand {
|
||||
targetStatus: AssetStatus;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetDetailItem {
|
||||
assetDetailId: number;
|
||||
assetRef: string;
|
||||
assetFqn: string;
|
||||
entityId: string;
|
||||
status: AssetStatus;
|
||||
organizationId: number;
|
||||
departmentId: number;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetSectionSnapshot {
|
||||
sectionSnapshotId: number;
|
||||
assetDetailId: number;
|
||||
snapshotVersion: number;
|
||||
sectionType: SectionType;
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
observedAt?: string;
|
||||
reliable: boolean;
|
||||
payloadSha256: string;
|
||||
evidenceState: EvidenceState;
|
||||
value?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetOwnerRecord {
|
||||
ownerRecordId: number;
|
||||
assetDetailId: number;
|
||||
ownerType: OwnerType;
|
||||
subjectType: SubjectType;
|
||||
subjectRef: string;
|
||||
effectiveFrom?: string;
|
||||
effectiveTo?: string;
|
||||
reason?: string;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetGovernanceRecord {
|
||||
governanceRecordId: number;
|
||||
assetDetailId: number;
|
||||
governanceType: GovernanceType;
|
||||
evidenceRef: string;
|
||||
observedAt?: string;
|
||||
reliable: boolean;
|
||||
evidenceSha256: string;
|
||||
evidenceState: EvidenceState;
|
||||
value?: string;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetRelationRecord {
|
||||
relationRecordId: number;
|
||||
assetDetailId: number;
|
||||
relationType: RelationType;
|
||||
targetRef: string;
|
||||
evidenceRef: string;
|
||||
observedAt?: string;
|
||||
evidenceSha256: string;
|
||||
reason?: string;
|
||||
actorId: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetTrajectory {
|
||||
trajectoryId: number;
|
||||
assetDetailId: number;
|
||||
actionType: string;
|
||||
beforeStatus?: string;
|
||||
afterStatus?: string;
|
||||
requestId?: string;
|
||||
actorId: number;
|
||||
summary?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetDetail {
|
||||
asset: AssetDetailItem;
|
||||
sections: AssetSectionSnapshot[];
|
||||
owners: AssetOwnerRecord[];
|
||||
governance: AssetGovernanceRecord[];
|
||||
relations: AssetRelationRecord[];
|
||||
trajectories: AssetTrajectory[];
|
||||
}
|
||||
|
||||
export interface AssetDetailWriteResult {
|
||||
requestId: string;
|
||||
result: AssetDetail;
|
||||
}
|
||||
|
||||
export interface SourceCandidate {
|
||||
entityId: string;
|
||||
assetRef: string;
|
||||
assetFqn: string;
|
||||
name: string;
|
||||
displayName: string;
|
||||
observedAt: string;
|
||||
}
|
||||
|
||||
export interface SourceCandidatePage {
|
||||
items: SourceCandidate[];
|
||||
before?: string;
|
||||
after?: string;
|
||||
}
|
||||
|
||||
export interface SourceCandidateDetail {
|
||||
source: SourceCandidate;
|
||||
sections: SectionCommand[];
|
||||
}
|
||||
|
||||
export interface GovernanceCandidate {
|
||||
governanceType: GovernanceType;
|
||||
label: string;
|
||||
command: AssetGovernanceCommand;
|
||||
}
|
||||
|
||||
export interface RelationCandidate {
|
||||
relationType: RelationType;
|
||||
targetRef: string;
|
||||
label: string;
|
||||
evidenceRef: string;
|
||||
observedAt: string;
|
||||
evidenceSha256: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface RelationCandidatePage {
|
||||
relationType: RelationType;
|
||||
availability: CandidateAvailability;
|
||||
message?: string;
|
||||
items: RelationCandidate[];
|
||||
before?: string;
|
||||
after?: string;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type {
|
||||
AssetResolution, BindCommand, BindingContext, BindingView, CandidatePage, IdentityId,
|
||||
IdentityResult, RevokeCommand, VerificationView, VerifyCommand
|
||||
} from './types';
|
||||
|
||||
const base = '/api/governance/v1/asset-identities';
|
||||
const pathId = (id: IdentityId) => encodeURIComponent(String(id));
|
||||
const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const getBindingContext = (id: IdentityId): AxiosPromise<BindingContext> =>
|
||||
request({ url: `${base}/binding-context/${pathId(id)}`, method: 'get', suppressErrorToast: true });
|
||||
export const getIdentityBinding = (id: string): AxiosPromise<BindingView> =>
|
||||
request({ url: `${base}/bindings/${pathId(id)}`, method: 'get', suppressErrorToast: true });
|
||||
export const listIdentityLifecycles = (params: { keyword?: string; page: number; size: number }): AxiosPromise<CandidatePage> =>
|
||||
request({ url: `${base}/candidates/lifecycles`, method: 'get', params, suppressErrorToast: true });
|
||||
export const registerIdentityBinding = (data: BindCommand, key: string): AxiosPromise<IdentityResult<BindingView>> =>
|
||||
request({ url: `${base}/bindings`, method: 'post', data, headers: headers(key), suppressErrorToast: true });
|
||||
export const editIdentityBinding = (id: string, data: BindCommand, key: string): AxiosPromise<IdentityResult<BindingView>> =>
|
||||
request({ url: `${base}/bindings/${pathId(id)}`, method: 'put', data, headers: headers(key), suppressErrorToast: true });
|
||||
export const verifyIdentityBinding = (id: string, data: VerifyCommand, key: string): AxiosPromise<IdentityResult<VerificationView>> =>
|
||||
request({ url: `${base}/bindings/${pathId(id)}/verify`, method: 'post', data, headers: headers(key), suppressErrorToast: true });
|
||||
export const revokeIdentityBinding = (id: string, data: RevokeCommand, key: string): AxiosPromise<IdentityResult<BindingView>> =>
|
||||
request({ url: `${base}/bindings/${pathId(id)}/revoke`, method: 'post', data, headers: headers(key), suppressErrorToast: true });
|
||||
export const resolveIdentity = (id: IdentityId): AxiosPromise<AssetResolution> =>
|
||||
request({ url: `${base}/resolve`, method: 'get', params: { legacyDetailId: id }, suppressErrorToast: true });
|
||||
export const resolveIdentityReference = (assetRef: string): AxiosPromise<AssetResolution> =>
|
||||
request({ url: `${base}/resolve`, method: 'get', params: { assetRef }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,65 @@
|
||||
/** IDs are opaque wire values. Never coerce a long identifier through Number(). */
|
||||
export type IdentityId = string | number;
|
||||
export type BindingState = 'DRAFT' | 'VERIFIED' | 'REVOKED';
|
||||
export interface IdentityCandidate {
|
||||
id: IdentityId;
|
||||
label: string | null;
|
||||
rowVersion: IdentityId;
|
||||
sourceEntityId: string | null;
|
||||
businessVersion: IdentityId;
|
||||
state: string;
|
||||
}
|
||||
export interface CandidatePage {
|
||||
items: IdentityCandidate[];
|
||||
page: number;
|
||||
size: number;
|
||||
hasMore: boolean;
|
||||
}
|
||||
export interface BindingView {
|
||||
bindingId: string;
|
||||
state: BindingState;
|
||||
rowVersion: IdentityId;
|
||||
detail: IdentityCandidate;
|
||||
lifecycle: IdentityCandidate;
|
||||
sourceLabel: string;
|
||||
verificationState: 'DRAFT_READY' | 'REVOKED' | 'RECHECK_REQUIRED';
|
||||
observation: null | {
|
||||
observationId: IdentityId;
|
||||
bindingRowVersion: IdentityId;
|
||||
action: string;
|
||||
result: string;
|
||||
observedAt: string;
|
||||
expiresAt: string | null;
|
||||
reasonCode: string;
|
||||
};
|
||||
}
|
||||
export interface BindingContext {
|
||||
detail: IdentityCandidate;
|
||||
binding: BindingView | null;
|
||||
capabilities: { canDraft: boolean; canVerify: boolean; canRevoke: boolean };
|
||||
}
|
||||
export interface BindCommand {
|
||||
detailId: IdentityId;
|
||||
lifecycleId: IdentityId;
|
||||
expectedDetailRowVersion: IdentityId;
|
||||
expectedLifecycleRowVersion: IdentityId;
|
||||
expectedBindingRowVersion?: IdentityId;
|
||||
action: 'REGISTER' | 'EDIT' | 'REGISTER_AGAIN';
|
||||
}
|
||||
export interface VerifyCommand {
|
||||
expectedBindingRowVersion: IdentityId;
|
||||
expectedDetailRowVersion: IdentityId;
|
||||
expectedLifecycleRowVersion: IdentityId;
|
||||
}
|
||||
export interface RevokeCommand { expectedBindingRowVersion: IdentityId; reason: string }
|
||||
export interface IdentityResult<T> { requestId: string; value: T; replay: boolean }
|
||||
export interface VerificationView {
|
||||
mapping: { detailId: IdentityId; lifecycleId: IdentityId; mappingRowVersion: IdentityId; state: string };
|
||||
binding: BindingView;
|
||||
}
|
||||
export interface AssetResolution {
|
||||
state: 'MAPPED' | 'UNMAPPED' | 'AMBIGUOUS' | 'UNKNOWN';
|
||||
identity: null | { assetId: IdentityId; assetRef: string; businessVersion: IdentityId;
|
||||
sourceEvidence?: { observedAt: string; expiresAt: string }[] };
|
||||
error: string | null;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface InventoryAssistRef { id: string; version: number }
|
||||
export interface InventoryAssistSelection { taskId: string; taskVersion: number; candidates: InventoryAssistRef[]; differences: InventoryAssistRef[] }
|
||||
export interface InventoryAssistFact { key: string; kind: 'CANDIDATE' | 'DIFFERENCE'; targetId: string; version: number; resourceType: string; confirmed: boolean; ownerMatchesTask: boolean; differenceType: string | null; status: string | null; candidateKey: string | null }
|
||||
export interface InventoryAssistContext { selection: InventoryAssistSelection; fingerprint: string; taskStatus: string; summary: { selectedCandidates: number; selectedDifferences: number; unconfirmedCandidates: number; openDifferences: number; differenceTypes: Record<string, number> }; facts: InventoryAssistFact[]; boundary: string }
|
||||
export interface InventoryAssistItem { targetKey: string; factKeys: string[]; reason: string }
|
||||
export interface InventoryAssistDraft { items: InventoryAssistItem[] }
|
||||
export interface InventoryReasonApply { selection: InventoryAssistSelection; fingerprint: string; fact: InventoryAssistFact; reason: string }
|
||||
export const getInventoryAssistContext = (data: InventoryAssistSelection): AxiosPromise<InventoryAssistContext> => request({ url: '/api/governance/v1/asset-inventory-assist/context', method: 'post', data });
|
||||
export const generateInventoryAssist = (data: { requestId: string; selection: InventoryAssistSelection; fingerprint: string; prompt: string }): AxiosPromise<{ requestId: string; state: string; fingerprint: string; candidate: InventoryAssistDraft | null; code: string }> => request({ url: '/api/integration/v1/ai/asset-inventory/candidates', method: 'post', data });
|
||||
@@ -0,0 +1,92 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AssetCandidate,
|
||||
AssetConfirmation,
|
||||
AssetConfirmationCommand,
|
||||
AssetDifference,
|
||||
AssetDiscoveryCommand,
|
||||
AssetInventoryCreateCommand,
|
||||
AssetInventoryQuery,
|
||||
AssetInventoryTask,
|
||||
AssetInventoryTaskPage,
|
||||
AssetInventoryUpdateCommand,
|
||||
AssetInventoryWriteResult,
|
||||
AssetResolution,
|
||||
AssetResolutionCommand,
|
||||
AssetSourceSnapshotCommand
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/governance/v1/asset-inventories';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export const pageAssetInventories = (params: AssetInventoryQuery): AxiosPromise<AssetInventoryTaskPage> =>
|
||||
request({ url: baseUrl, method: 'get', params });
|
||||
|
||||
export const getAssetInventory = (taskId: string | number): AxiosPromise<AssetInventoryTask> =>
|
||||
request({ url: `${baseUrl}/${taskId}`, method: 'get' });
|
||||
|
||||
export const createAssetInventory = (
|
||||
data: AssetInventoryCreateCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetInventoryWriteResult> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const updateAssetInventory = (
|
||||
taskId: number,
|
||||
data: AssetInventoryUpdateCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetInventoryWriteResult> =>
|
||||
request({ url: `${baseUrl}/${taskId}`, method: 'patch', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const discoverAssetInventory = (
|
||||
taskId: number,
|
||||
data: AssetDiscoveryCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetInventoryWriteResult> =>
|
||||
request({ url: `${baseUrl}/${taskId}/discovery`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const runAssetInventory = (
|
||||
taskId: number,
|
||||
data: AssetSourceSnapshotCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetInventoryWriteResult> =>
|
||||
request({ url: `${baseUrl}/${taskId}/runs`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const listAssetCandidates = (taskId: string | number): AxiosPromise<AssetCandidate[]> =>
|
||||
request({ url: `${baseUrl}/${taskId}/candidates`, method: 'get' });
|
||||
|
||||
export const confirmAssetCandidate = (
|
||||
taskId: number,
|
||||
candidateId: number,
|
||||
data: AssetConfirmationCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetInventoryWriteResult> =>
|
||||
request({
|
||||
url: `${baseUrl}/${taskId}/candidates/${candidateId}/confirmations`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const listAssetConfirmations = (taskId: string | number): AxiosPromise<AssetConfirmation[]> =>
|
||||
request({ url: `${baseUrl}/${taskId}/confirmations`, method: 'get' });
|
||||
|
||||
export const listAssetDifferences = (taskId: number): AxiosPromise<AssetDifference[]> =>
|
||||
request({ url: `${baseUrl}/${taskId}/differences`, method: 'get' });
|
||||
|
||||
export const resolveAssetDifference = (
|
||||
taskId: number,
|
||||
differenceId: number,
|
||||
data: AssetResolutionCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetInventoryWriteResult> =>
|
||||
request({
|
||||
url: `${baseUrl}/${taskId}/differences/${differenceId}/resolutions`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const listAssetResolutions = (taskId: number): AxiosPromise<AssetResolution[]> =>
|
||||
request({ url: `${baseUrl}/${taskId}/resolutions`, method: 'get' });
|
||||
@@ -0,0 +1,160 @@
|
||||
export type AssetInventoryTaskStatus =
|
||||
| 'DRAFT'
|
||||
| 'PENDING_SOURCE'
|
||||
| 'RUNNING'
|
||||
| 'AWAITING_CONFIRMATION'
|
||||
| 'COMPLETED'
|
||||
| 'UNKNOWN'
|
||||
| 'FAILED';
|
||||
|
||||
export type AssetResourceType = 'TABLE' | 'FILE' | 'REPORT' | 'API' | 'MODEL';
|
||||
export type AssetDifferenceType = 'NEW' | 'MISSING' | 'INVALID' | 'DUPLICATE' | 'OWNER_CONFLICT';
|
||||
export type AssetDifferenceStatus = 'OPEN' | 'RESOLVED';
|
||||
export type AssetResolutionAction = 'ACCEPT' | 'REGISTER' | 'IGNORE' | 'RETIRE' | 'MERGE' | 'REASSIGN';
|
||||
|
||||
export interface AssetInventoryQuery extends PageQuery {
|
||||
keyword?: string;
|
||||
status?: AssetInventoryTaskStatus;
|
||||
}
|
||||
|
||||
export interface AssetInventoryTask {
|
||||
taskId: number;
|
||||
taskNo: string;
|
||||
name: string;
|
||||
systemRef: string;
|
||||
businessDomainId: string;
|
||||
resourceTypes: AssetResourceType[];
|
||||
ownerUserId: string;
|
||||
status: AssetInventoryTaskStatus;
|
||||
statusReason?: string;
|
||||
organizationId: number;
|
||||
departmentId: number;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetInventoryTaskPage {
|
||||
rows: AssetInventoryTask[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface AssetInventoryCreateCommand {
|
||||
name: string;
|
||||
systemRef: string;
|
||||
businessDomainId: string;
|
||||
resourceTypes: AssetResourceType[];
|
||||
ownerUserId: string;
|
||||
}
|
||||
|
||||
export interface AssetInventoryUpdateCommand extends AssetInventoryCreateCommand {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetDiscoveryCommand {
|
||||
version: number;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface AssetCandidateCommand {
|
||||
stableAssetKey: string;
|
||||
resourceType: AssetResourceType;
|
||||
fqn: string;
|
||||
externalId: string;
|
||||
ownerUserId: string;
|
||||
definition: string;
|
||||
differenceType: AssetDifferenceType;
|
||||
evidenceSha: string;
|
||||
}
|
||||
|
||||
export interface AssetSourceSnapshotCommand {
|
||||
sourceType: string;
|
||||
sourceRef: string;
|
||||
observedAt?: string;
|
||||
available: boolean;
|
||||
reliable: boolean;
|
||||
emptySetProven: boolean;
|
||||
payloadSha?: string;
|
||||
candidates: AssetCandidateCommand[];
|
||||
failureReason?: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetCandidate {
|
||||
candidateId: number;
|
||||
taskId: number;
|
||||
snapshotId: number;
|
||||
stableAssetKey: string;
|
||||
resourceType: AssetResourceType;
|
||||
fqn: string;
|
||||
externalId: string;
|
||||
ownerUserId: string;
|
||||
definition: string;
|
||||
payloadSha: string;
|
||||
confirmed: boolean;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetConfirmationCommand {
|
||||
valid: boolean;
|
||||
definition: string;
|
||||
ownerUserId: string;
|
||||
inScope: boolean;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetConfirmation {
|
||||
confirmationId: number;
|
||||
taskId: number;
|
||||
candidateId: number;
|
||||
valid: boolean;
|
||||
definition: string;
|
||||
ownerUserId: string;
|
||||
inScope: boolean;
|
||||
reason: string;
|
||||
requestId: string;
|
||||
actorId: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetDifference {
|
||||
differenceId: number;
|
||||
taskId: number;
|
||||
candidateId: number;
|
||||
differenceType: AssetDifferenceType;
|
||||
status: AssetDifferenceStatus;
|
||||
evidenceSha: string;
|
||||
resolutionAction?: AssetResolutionAction;
|
||||
resolutionReason?: string;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
resolvedAt?: string;
|
||||
}
|
||||
|
||||
export interface AssetResolutionCommand {
|
||||
action?: AssetResolutionAction;
|
||||
reason: string;
|
||||
beforeEvidenceSha: string;
|
||||
afterEvidenceSha: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetResolution {
|
||||
resolutionId: number;
|
||||
taskId: number;
|
||||
differenceId: number;
|
||||
action: AssetResolutionAction;
|
||||
reason: string;
|
||||
beforeEvidenceSha: string;
|
||||
afterEvidenceSha: string;
|
||||
requestId: string;
|
||||
actorId: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetInventoryWriteResult {
|
||||
requestId: string;
|
||||
result: AssetInventoryTask;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AssetLifecycleChangeCommand,
|
||||
AssetLifecycleCreateCommand,
|
||||
AssetLifecycleCurrent,
|
||||
AssetLifecycleDetail,
|
||||
AssetLifecycleImpactCommand,
|
||||
AssetLifecycleItem,
|
||||
AssetLifecyclePublishCommand,
|
||||
AssetLifecycleUpdateCommand,
|
||||
AssetLifecycleWriteResult,
|
||||
EntityId
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/governance/v1/asset-lifecycles';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export const listAssetLifecycles = (): AxiosPromise<AssetLifecycleItem[]> =>
|
||||
request({ url: baseUrl, method: 'get' });
|
||||
|
||||
export const listLifecycleConsumerCandidates = (keyword: string): AxiosPromise<Array<{ id: string; label: string }>> =>
|
||||
request({ url: `${baseUrl}/consumer-candidates`, method: 'get', params: { keyword } });
|
||||
|
||||
export const getAssetLifecycle = (lifecycleId: EntityId): AxiosPromise<AssetLifecycleCurrent> =>
|
||||
request({ url: `${baseUrl}/${lifecycleId}`, method: 'get' });
|
||||
|
||||
export const getAssetLifecycleHistory = (lifecycleId: EntityId): AxiosPromise<AssetLifecycleDetail> =>
|
||||
request({ url: `${baseUrl}/${lifecycleId}/history`, method: 'get' });
|
||||
|
||||
export const createAssetLifecycle = (
|
||||
data: AssetLifecycleCreateCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetLifecycleWriteResult> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const updateAssetLifecycle = (
|
||||
lifecycleId: EntityId,
|
||||
data: AssetLifecycleUpdateCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetLifecycleWriteResult> =>
|
||||
request({ url: `${baseUrl}/${lifecycleId}`, method: 'put', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const publishAssetLifecycle = (
|
||||
lifecycleId: EntityId,
|
||||
data: AssetLifecyclePublishCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetLifecycleWriteResult> =>
|
||||
request({ url: `${baseUrl}/${lifecycleId}/publish`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const changeAssetLifecycle = (
|
||||
lifecycleId: EntityId,
|
||||
data: AssetLifecycleChangeCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetLifecycleWriteResult> =>
|
||||
request({ url: `${baseUrl}/${lifecycleId}/change`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const deprecateAssetLifecycle = (
|
||||
lifecycleId: EntityId,
|
||||
data: AssetLifecycleImpactCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetLifecycleWriteResult> =>
|
||||
request({ url: `${baseUrl}/${lifecycleId}/deprecate`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const archiveAssetLifecycle = (
|
||||
lifecycleId: EntityId,
|
||||
data: AssetLifecycleImpactCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AssetLifecycleWriteResult> =>
|
||||
request({ url: `${baseUrl}/${lifecycleId}/archive`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
@@ -0,0 +1,169 @@
|
||||
export type EntityId = string | number;
|
||||
export type AssetStatus = 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'ARCHIVED';
|
||||
export type ReviewDecision = 'APPROVED' | 'REJECTED';
|
||||
export type ReviewType = 'PUBLISH' | 'CHANGE';
|
||||
export type ResponsibilityType = 'OWNER' | 'STEWARD' | 'BUSINESS_OWNER' | 'TECHNICAL_OWNER';
|
||||
export type SubjectType = 'USER' | 'ROLE' | 'ORGANIZATION' | 'DEPARTMENT';
|
||||
export type GovernanceAttributeType = 'STANDARD' | 'QUALITY' | 'SECURITY' | 'COMPLIANCE' | 'CERTIFICATION' | 'REMEDIATION';
|
||||
export type ImpactType = 'DEPRECATE' | 'ARCHIVE';
|
||||
export type NotificationStatus = 'PENDING_DELIVERY';
|
||||
|
||||
export interface ResponsibilityCommand {
|
||||
responsibilityType: ResponsibilityType;
|
||||
subjectType: SubjectType;
|
||||
subjectRef: string;
|
||||
}
|
||||
|
||||
export interface GovernanceAttributeCommand {
|
||||
attributeType: GovernanceAttributeType;
|
||||
attributeRef: string;
|
||||
}
|
||||
|
||||
export interface ConsumerCommand {
|
||||
subjectType: SubjectType;
|
||||
subjectRef: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleCreateCommand {
|
||||
assetRef: string;
|
||||
catalogRef: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
responsibilities: ResponsibilityCommand[];
|
||||
governanceAttributes: GovernanceAttributeCommand[];
|
||||
}
|
||||
|
||||
export interface AssetLifecycleUpdateCommand extends AssetLifecycleCreateCommand {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetLifecyclePublishCommand {
|
||||
decision: ReviewDecision;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleChangeCommand extends AssetLifecycleUpdateCommand {
|
||||
decision: ReviewDecision;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleImpactCommand {
|
||||
reason: string;
|
||||
impactSummary: string;
|
||||
consumers: ConsumerCommand[];
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleItem {
|
||||
lifecycleId: EntityId;
|
||||
assetRef: string;
|
||||
catalogRef: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
status: AssetStatus;
|
||||
currentBusinessVersion: number;
|
||||
organizationId: EntityId;
|
||||
departmentId: EntityId;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface ResponsibilityView extends ResponsibilityCommand {}
|
||||
|
||||
export interface GovernanceAttributeView extends GovernanceAttributeCommand {}
|
||||
|
||||
export interface AssetLifecycleSnapshot {
|
||||
snapshotId: EntityId;
|
||||
lifecycleId: EntityId;
|
||||
snapshotType: string;
|
||||
assetRef: string;
|
||||
catalogRef: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
responsibilities: ResponsibilityView[];
|
||||
governanceAttributes: GovernanceAttributeView[];
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleVersion {
|
||||
versionId: EntityId;
|
||||
lifecycleId: EntityId;
|
||||
businessVersion: number;
|
||||
sourceSnapshotId: EntityId;
|
||||
assetRef: string;
|
||||
catalogRef: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
responsibilities: ResponsibilityView[];
|
||||
governanceAttributes: GovernanceAttributeView[];
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleReview {
|
||||
reviewId: EntityId;
|
||||
lifecycleId: EntityId;
|
||||
reviewType: ReviewType;
|
||||
decision: ReviewDecision;
|
||||
reason: string;
|
||||
snapshotId: EntityId;
|
||||
snapshot: AssetLifecycleSnapshot;
|
||||
producedBusinessVersion?: number;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleImpact {
|
||||
impactId: EntityId;
|
||||
lifecycleId: EntityId;
|
||||
impactType: ImpactType;
|
||||
reason: string;
|
||||
impactSummary: string;
|
||||
consumers: ConsumerCommand[];
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleNotification {
|
||||
notificationId: EntityId;
|
||||
lifecycleId: EntityId;
|
||||
impactId: EntityId;
|
||||
subjectType: SubjectType;
|
||||
subjectRef: string;
|
||||
status: NotificationStatus;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleTrajectory {
|
||||
trajectoryId: EntityId;
|
||||
lifecycleId: EntityId;
|
||||
actionType: string;
|
||||
beforeStatus?: string;
|
||||
afterStatus?: string;
|
||||
requestId?: string;
|
||||
actorId: EntityId;
|
||||
summary?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleCurrent {
|
||||
asset: AssetLifecycleItem;
|
||||
currentSnapshot: AssetLifecycleSnapshot;
|
||||
}
|
||||
|
||||
export interface AssetLifecycleDetail extends AssetLifecycleCurrent {
|
||||
snapshots: AssetLifecycleSnapshot[];
|
||||
versions: AssetLifecycleVersion[];
|
||||
reviews: AssetLifecycleReview[];
|
||||
impacts: AssetLifecycleImpact[];
|
||||
notifications: AssetLifecycleNotification[];
|
||||
trajectories: AssetLifecycleTrajectory[];
|
||||
}
|
||||
|
||||
export interface AssetLifecycleWriteResult {
|
||||
requestId: string;
|
||||
result: AssetLifecycleCurrent;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
BatchArrivalValidationVO,
|
||||
BatchCheckpointVO,
|
||||
BatchId,
|
||||
BatchObservationForm,
|
||||
BatchRunVO,
|
||||
BatchSubmissionRecoveryVO,
|
||||
BatchTaskForm,
|
||||
BatchTaskPage,
|
||||
BatchTaskQuery,
|
||||
BatchTaskUpdateForm,
|
||||
BatchTaskVO
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/dataops/v1/batch-ingestions';
|
||||
|
||||
export function getBatchSubmission(runId: BatchId): AxiosPromise<BatchSubmissionRecoveryVO> {
|
||||
return request({ url: `${baseUrl}/runs/${runId}/submission`, method: 'get' });
|
||||
}
|
||||
|
||||
export function closeBatchSubmission(runId: BatchId, data: { version: number; taskVersion: number; reason: string },
|
||||
key: string): AxiosPromise<BatchTaskVO> {
|
||||
return request({ url: `${baseUrl}/runs/${runId}/close-not-sent`, method: 'post', data, headers: writeHeaders(key) });
|
||||
}
|
||||
|
||||
const writeHeaders = (idempotencyKey: string) => ({
|
||||
'Idempotency-Key': idempotencyKey,
|
||||
repeatSubmit: false
|
||||
});
|
||||
|
||||
export function pageBatchTasks(params: BatchTaskQuery): AxiosPromise<BatchTaskPage> {
|
||||
return request({ url: baseUrl, method: 'get', params });
|
||||
}
|
||||
|
||||
export function getBatchTask(taskId: BatchId): AxiosPromise<BatchTaskVO> {
|
||||
return request({ url: `${baseUrl}/${taskId}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function createBatchTask(data: BatchTaskForm, key: string): AxiosPromise<BatchTaskVO> {
|
||||
return request({ url: baseUrl, method: 'post', data, headers: writeHeaders(key) });
|
||||
}
|
||||
|
||||
export function updateBatchTask(
|
||||
taskId: BatchId,
|
||||
data: BatchTaskUpdateForm,
|
||||
key: string
|
||||
): AxiosPromise<BatchTaskVO> {
|
||||
return request({ url: `${baseUrl}/${taskId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
}
|
||||
|
||||
export function deleteBatchTask(taskId: BatchId, version: number, key: string): AxiosPromise<void> {
|
||||
return request({ url: `${baseUrl}/${taskId}`, method: 'delete', params: { version }, headers: writeHeaders(key) });
|
||||
}
|
||||
|
||||
export function readyBatchTask(taskId: BatchId, version: number, key: string): AxiosPromise<BatchTaskVO> {
|
||||
return request({ url: `${baseUrl}/${taskId}/ready`, method: 'post', data: { version }, headers: writeHeaders(key) });
|
||||
}
|
||||
|
||||
export function submitBatchTask(taskId: BatchId, version: number, key: string): AxiosPromise<BatchRunVO> {
|
||||
return request({ url: `${baseUrl}/${taskId}/submit`, method: 'post', data: { version }, headers: writeHeaders(key) });
|
||||
}
|
||||
|
||||
export function listBatchRuns(taskId: BatchId): AxiosPromise<BatchRunVO[]> {
|
||||
return request({ url: `${baseUrl}/${taskId}/runs`, method: 'get' });
|
||||
}
|
||||
|
||||
export function observeBatchRun(runId: BatchId, data: BatchObservationForm): AxiosPromise<BatchRunVO> {
|
||||
return request({ url: `${baseUrl}/runs/${runId}/observe`, method: 'post', data,
|
||||
timeout: 45000, headers: { repeatSubmit: false } });
|
||||
}
|
||||
|
||||
export function resumeBatchRun(runId: BatchId, reason: string, key: string): AxiosPromise<BatchRunVO> {
|
||||
return request({ url: `${baseUrl}/runs/${runId}/resume`, method: 'post', data: { reason }, headers: writeHeaders(key) });
|
||||
}
|
||||
|
||||
export function listBatchCheckpoints(runId: BatchId): AxiosPromise<BatchCheckpointVO[]> {
|
||||
return request({ url: `${baseUrl}/runs/${runId}/checkpoints`, method: 'get' });
|
||||
}
|
||||
|
||||
export function listArrivalValidations(runId: BatchId): AxiosPromise<BatchArrivalValidationVO[]> {
|
||||
return request({ url: `${baseUrl}/runs/${runId}/arrival-validations`, method: 'get' });
|
||||
}
|
||||
|
||||
export function validateBatchArrival(
|
||||
runId: BatchId,
|
||||
reason: string,
|
||||
key: string
|
||||
): AxiosPromise<BatchArrivalValidationVO> {
|
||||
return request({
|
||||
url: `${baseUrl}/runs/${runId}/arrival-validations`,
|
||||
method: 'post',
|
||||
data: { reason },
|
||||
headers: writeHeaders(key)
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { BatchId, BatchFieldMappingForm } from './types';
|
||||
import type { SourceColumn } from '@/api/datagov/data-sources/types';
|
||||
|
||||
export interface WizardContext { sourceId: BatchId; sourceObject: string; resourceId: BatchId; spaceId: BatchId }
|
||||
export interface TargetColumn { name: string; type: string; nullable: boolean; precision: number | null; scale: number | null; comment?: string | null }
|
||||
export interface WizardDraft { sourceFingerprint: string; fields: { source: SourceColumn; target: TargetColumn | null; issue: string | null }[] }
|
||||
export interface TargetDirectory { state: string; tables: string[]; columns: { name: string; nativeType: string; precision: number; scale: number; nullable: boolean | null }[]; total: number; errorSummary?: string }
|
||||
export interface WizardConfirm { context: WizardContext; sourceFingerprint: string; name: string; columns: TargetColumn[] }
|
||||
export interface WizardCreated { operation: { requestId: string; replayed: boolean; result: { tableFile: { tableFileId: BatchId; executionState: string; errorSummary?: string } } }; mappings: BatchFieldMappingForm[] }
|
||||
export type TargetExistenceState = 'EXISTS' | 'MISSING' | 'UNKNOWN';
|
||||
export interface TargetExistenceItem { table: string; state: TargetExistenceState; reason: string }
|
||||
const base = '/api/dataops/v1/batch-ingestions/target-wizard';
|
||||
export function targetTables(params: { resourceId: BatchId; spaceId: BatchId; table?: string; keyword?: string; pageNum: number; pageSize: number }): AxiosPromise<TargetDirectory> {
|
||||
return request({ url: `${base}/tables`, method: 'get', params });
|
||||
}
|
||||
export function targetDraft(data: WizardContext): AxiosPromise<WizardDraft> {
|
||||
return request({ url: `${base}/draft`, method: 'post', data, headers: { repeatSubmit: false } });
|
||||
}
|
||||
export function matchTarget(data: { context: WizardContext; name: string; selectedColumns: string[] }): AxiosPromise<{ mappings: BatchFieldMappingForm[] }> {
|
||||
return request({ url: `${base}/match`, method: 'post', data, headers: { repeatSubmit: false } });
|
||||
}
|
||||
export function createTarget(data: WizardConfirm, key: string): AxiosPromise<WizardCreated> {
|
||||
return request({ url: `${base}/create`, method: 'post', data, headers: { 'Idempotency-Key': key, repeatSubmit: false } });
|
||||
}
|
||||
export function checkTargetTables(data: { resourceId: BatchId; spaceId: BatchId; tables: string[] }): AxiosPromise<{ items: TargetExistenceItem[] }> {
|
||||
return request({ url: `${base}/target-existence`, method: 'post', data, headers: { repeatSubmit: false } });
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
export type BatchId = string | number;
|
||||
export type BatchMode = 'FULL' | 'INCREMENTAL';
|
||||
export type BatchStatus =
|
||||
| 'DRAFT'
|
||||
| 'READY'
|
||||
| 'SUBMITTED'
|
||||
| 'RUNNING'
|
||||
| 'SUCCEEDED'
|
||||
| 'FAILED'
|
||||
| 'CANCELED'
|
||||
| 'UNKNOWN';
|
||||
export type BatchTransform = 'NONE' | 'CAST' | 'TRIM' | 'UPPER' | 'LOWER' | 'DEFAULT_IF_NULL';
|
||||
export type BatchFilterOperator =
|
||||
| 'EQUALS'
|
||||
| 'NOT_EQUALS'
|
||||
| 'GREATER_THAN'
|
||||
| 'GREATER_OR_EQUALS'
|
||||
| 'LESS_THAN'
|
||||
| 'LESS_OR_EQUALS'
|
||||
| 'IN'
|
||||
| 'NOT_IN'
|
||||
| 'BETWEEN'
|
||||
| 'IS_NULL'
|
||||
| 'IS_NOT_NULL';
|
||||
|
||||
export interface BatchFieldMappingForm {
|
||||
sourceField: string;
|
||||
targetField: string;
|
||||
sourceType: string;
|
||||
targetType: string;
|
||||
transform: BatchTransform;
|
||||
defaultValue?: string;
|
||||
filterOperator?: BatchFilterOperator;
|
||||
filterValues: string[];
|
||||
}
|
||||
|
||||
export interface BatchFieldMappingVO extends BatchFieldMappingForm {
|
||||
mappingId: BatchId;
|
||||
mappingOrder: number;
|
||||
}
|
||||
|
||||
export interface BatchTaskForm {
|
||||
name: string;
|
||||
dataDomainCode: string;
|
||||
sourceRefId: BatchId | '';
|
||||
targetRefId: BatchId | '';
|
||||
sourceConnector: 'JDBC' | 'MYSQL';
|
||||
targetConnector: 'HIVE' | 'DORIS';
|
||||
sourceObject: string;
|
||||
targetObject: string;
|
||||
mode: BatchMode;
|
||||
incrementalField?: string;
|
||||
partitionField?: string;
|
||||
parallelism: number;
|
||||
checkpointEnabled: boolean;
|
||||
checkpointIntervalSeconds?: number;
|
||||
mappings: BatchFieldMappingForm[];
|
||||
}
|
||||
|
||||
export interface BatchTaskUpdateForm extends BatchTaskForm {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface BatchTaskVO extends BatchTaskForm {
|
||||
taskId: BatchId;
|
||||
definitionId: BatchId;
|
||||
currentSnapshotId: BatchId;
|
||||
taskCode: string;
|
||||
orgScopeId: BatchId;
|
||||
status: BatchStatus;
|
||||
version: number;
|
||||
capabilityCheckedAt?: string;
|
||||
capabilityExpiresAt?: string;
|
||||
mappings: BatchFieldMappingVO[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BatchTaskQuery {
|
||||
keyword?: string;
|
||||
dataDomainCode?: string;
|
||||
status?: BatchStatus;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export interface BatchTaskPage {
|
||||
rows: BatchTaskVO[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface BatchRunVO {
|
||||
runId: BatchId;
|
||||
taskId: BatchId;
|
||||
definitionId: BatchId;
|
||||
snapshotId: BatchId;
|
||||
parentRunId?: BatchId;
|
||||
runType: 'NORMAL' | 'RETRY';
|
||||
batchNo: string;
|
||||
requestId: string;
|
||||
status: BatchStatus;
|
||||
sourceStatus: string;
|
||||
externalJobId?: string;
|
||||
retryable: boolean;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
startedAt?: string;
|
||||
completedAt?: string;
|
||||
createdAt: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface BatchObservationForm {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface BatchCheckpointVO {
|
||||
checkpointRecordId: BatchId;
|
||||
taskId: BatchId;
|
||||
runId: BatchId;
|
||||
externalJobId: string;
|
||||
checkpointId: string;
|
||||
checkpointSequence: number;
|
||||
status: string;
|
||||
evidenceAt: string;
|
||||
evidenceRef: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface BatchArrivalValidationVO {
|
||||
validationId: BatchId;
|
||||
taskId: BatchId;
|
||||
runId: BatchId;
|
||||
batchNo?: string;
|
||||
sourceCount?: BatchId;
|
||||
targetCount?: BatchId;
|
||||
checksum?: string;
|
||||
duplicateCount?: BatchId;
|
||||
status: 'PASS' | 'FAIL' | 'UNKNOWN';
|
||||
evidenceAt?: string;
|
||||
evidenceRef?: string;
|
||||
retryable: boolean;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
createdAt: string;
|
||||
}
|
||||
export interface BatchSubmissionRecoveryVO {
|
||||
runId: BatchId;
|
||||
taskId: BatchId;
|
||||
runVersion: number;
|
||||
taskVersion: number;
|
||||
phase: 'PREPARED' | 'DISPATCHING' | 'UNCERTAIN' | 'NOT_SENT' | 'VERIFIED' | 'CLOSED' | 'LEGACY_UNKNOWN';
|
||||
plannedJobId?: string;
|
||||
initialErrorCode?: string;
|
||||
initialErrorSummary?: string;
|
||||
canObserve: boolean;
|
||||
canClose: boolean;
|
||||
guidance: string;
|
||||
events: { sequence: number; status: string; sourceStatus?: string; externalJobId?: string; summary?: string; createdAt?: string }[];
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import type { PageResult } from '@/api/types';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
BatchJobCreateRequest,
|
||||
BatchJobId,
|
||||
BatchJobQuery,
|
||||
BatchJobUpdateRequest,
|
||||
BatchJobVO,
|
||||
JobParameters,
|
||||
MySqlSource
|
||||
} from './types';
|
||||
|
||||
const writeHeaders = (idempotencyKey: string) => ({
|
||||
'Idempotency-Key': idempotencyKey,
|
||||
repeatSubmit: false
|
||||
});
|
||||
|
||||
export interface BatchJobExecution {
|
||||
executionId: string; jobId: string; ownerVersion: string; status: string;
|
||||
externalJobId?: string; errorCode?: string; observedAt?: string;
|
||||
}
|
||||
export const listBatchJobExecutions = (jobId: BatchJobId): AxiosPromise<BatchJobExecution[]> =>
|
||||
request({ url: `/api/dataops/v1/batch-jobs/${jobId}/executions`, method: 'get' });
|
||||
|
||||
export const getBatchJobSourceFields = (params: MySqlSource): AxiosPromise<string[]> =>
|
||||
request({ url: '/api/dataops/v1/batch-jobs/source-fields', method: 'get', params });
|
||||
|
||||
export const listBatchJobs = (params: BatchJobQuery): AxiosPromise<PageResult<BatchJobVO>> =>
|
||||
request({ url: '/api/dataops/v1/batch-jobs', method: 'get', params });
|
||||
|
||||
export const getBatchJob = (jobId: BatchJobId): AxiosPromise<BatchJobVO> =>
|
||||
request({ url: `/api/dataops/v1/batch-jobs/${jobId}`, method: 'get' });
|
||||
|
||||
export const createBatchJob = (
|
||||
data: BatchJobCreateRequest,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<BatchJobVO> =>
|
||||
request({
|
||||
url: '/api/dataops/v1/batch-jobs',
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const updateBatchJob = (
|
||||
jobId: BatchJobId,
|
||||
data: BatchJobUpdateRequest,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<BatchJobVO> =>
|
||||
request({
|
||||
url: `/api/dataops/v1/batch-jobs/${jobId}`,
|
||||
method: 'put',
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const updateBatchJobParameters = (
|
||||
jobId: BatchJobId,
|
||||
parameters: JobParameters,
|
||||
version: number,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<BatchJobVO> =>
|
||||
request({
|
||||
url: `/api/dataops/v1/batch-jobs/${jobId}/parameters`,
|
||||
method: 'put',
|
||||
data: { parameters, version },
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const validateBatchJob = (
|
||||
jobId: BatchJobId,
|
||||
version: number,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<BatchJobVO> =>
|
||||
request({
|
||||
url: `/api/dataops/v1/batch-jobs/${jobId}/validate`,
|
||||
method: 'post',
|
||||
data: { version },
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const deleteBatchJob = (
|
||||
jobId: BatchJobId,
|
||||
version: number,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<BatchJobVO> =>
|
||||
request({
|
||||
url: `/api/dataops/v1/batch-jobs/${jobId}`,
|
||||
method: 'delete',
|
||||
data: { version },
|
||||
headers: writeHeaders(idempotencyKey),
|
||||
suppressErrorToast: true
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface BatchRunSelection { jobId: string; jobVersion: number; runId: string; evidenceId: string; evidenceVersion: number }
|
||||
export interface BatchRunCandidate { runId: string; scheduleId: string; nodeKey: string; evidenceId: string; evidenceVersion: number; kind: string; status: string; observedAt: string | null }
|
||||
export interface BatchRunFact { key: string; kind: string; value: string; observedAt: string | null }
|
||||
export interface BatchRunContext { selection: BatchRunSelection; fingerprint: string; scheduleId: string; nodeKey: string; facts: BatchRunFact[]; checks: { key: string; satisfied: boolean; factKeys: string[] }[]; boundary: string }
|
||||
export interface BatchRunDraft { items: { check: string; factKeys: string[]; explanation: string }[] }
|
||||
export const listBatchRunEvidence = (jobId: string, version: number): AxiosPromise<BatchRunCandidate[]> => request({ url: '/api/dataops/v1/batch-job-run-assist/candidates', method: 'get', params: { jobId, version } });
|
||||
export const getBatchRunContext = (data: BatchRunSelection): AxiosPromise<BatchRunContext> => request({ url: '/api/dataops/v1/batch-job-run-assist/context', method: 'post', data });
|
||||
export const explainBatchRun = (data: { requestId: string; selection: BatchRunSelection; fingerprint: string; prompt: string }): AxiosPromise<{ requestId: string; state: string; fingerprint: string; candidate: BatchRunDraft | null; code: string }> => request({ url: '/api/integration/v1/ai/batch-job-runs/candidates', method: 'post', data });
|
||||
@@ -0,0 +1,101 @@
|
||||
export type BatchJobId = string | number;
|
||||
export type BatchJobStatus = 'DRAFT' | 'READY';
|
||||
export type ExecutionEngine = 'SEATUNNEL';
|
||||
export type ReadMode = 'SNAPSHOT';
|
||||
export type WriteMode = 'APPEND' | 'OVERWRITE';
|
||||
export type TransformOperation = 'COPY' | 'TRIM' | 'UPPER' | 'LOWER' | 'CAST';
|
||||
export type FilterOperator = 'EQ' | 'NE' | 'GT' | 'GTE' | 'LT' | 'LTE' | 'IS_NULL' | 'NOT_NULL';
|
||||
export type FaultTolerance = 'FAIL_FAST' | 'SKIP_BAD_RECORDS';
|
||||
export type DataType =
|
||||
| 'BOOLEAN'
|
||||
| 'TINYINT'
|
||||
| 'SMALLINT'
|
||||
| 'INT'
|
||||
| 'BIGINT'
|
||||
| 'FLOAT'
|
||||
| 'DOUBLE'
|
||||
| 'DECIMAL'
|
||||
| 'STRING'
|
||||
| 'VARCHAR'
|
||||
| 'CHAR'
|
||||
| 'DATE'
|
||||
| 'TIMESTAMP'
|
||||
| 'DATETIME';
|
||||
|
||||
export interface SourceDefinition {
|
||||
inputTableFileIds: BatchJobId[];
|
||||
readMode: ReadMode;
|
||||
mysqlSource?: MySqlSource | null;
|
||||
}
|
||||
|
||||
export interface MySqlSource {
|
||||
dataSourceId: BatchJobId;
|
||||
sourceVersion: number;
|
||||
database: string;
|
||||
table: string;
|
||||
}
|
||||
|
||||
export interface FieldMapping {
|
||||
sourceField: string;
|
||||
targetField: string;
|
||||
operation: TransformOperation;
|
||||
targetType?: DataType;
|
||||
}
|
||||
|
||||
export interface FilterRule {
|
||||
field: string;
|
||||
operator: FilterOperator;
|
||||
value?: string;
|
||||
}
|
||||
|
||||
export interface TransformDefinition {
|
||||
fieldMappings: FieldMapping[];
|
||||
filters: FilterRule[];
|
||||
}
|
||||
|
||||
export interface SinkDefinition {
|
||||
outputTableFileIds: BatchJobId[];
|
||||
writeMode: WriteMode;
|
||||
}
|
||||
|
||||
export interface JobParameters {
|
||||
parallelism: number;
|
||||
coordinatorMemoryMb: number;
|
||||
workerMemoryMb: number;
|
||||
workerCpuMillicores: number;
|
||||
timeoutSeconds: number;
|
||||
retryCount: number;
|
||||
retryIntervalSeconds: number;
|
||||
faultTolerance: FaultTolerance;
|
||||
}
|
||||
|
||||
export interface BatchJobDefinition {
|
||||
name: string;
|
||||
executionEngine: ExecutionEngine;
|
||||
source: SourceDefinition;
|
||||
transform: TransformDefinition;
|
||||
sink: SinkDefinition;
|
||||
parameters: JobParameters;
|
||||
}
|
||||
|
||||
export type BatchJobCreateRequest = BatchJobDefinition;
|
||||
|
||||
export interface BatchJobUpdateRequest extends BatchJobDefinition {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface BatchJobVO extends BatchJobDefinition {
|
||||
jobId: BatchJobId;
|
||||
orgId: BatchJobId;
|
||||
dataDomainCode: string;
|
||||
definitionSha256: string;
|
||||
status: BatchJobStatus;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BatchJobQuery extends PageQuery {
|
||||
keyword?: string;
|
||||
status?: BatchJobStatus;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface BiPatchChange { field: string; value: unknown }
|
||||
export interface BiPatchResult { requestId: string; state: 'DRAFT' | 'DISABLED' | 'FAILED'; code: string; targetHash: string; changes: BiPatchChange[]; explanation: string | null }
|
||||
export const generateBiPatch = (id: string, data: { requestId: string; version: number; widgetId?: string; prompt: string }, signal: AbortSignal): AxiosPromise<BiPatchResult> =>
|
||||
request({ url: `/api/dataproduct/v1/bi/objects/${encodeURIComponent(id)}/ai-patch`, method: 'post', data, signal, timeout: 70000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { cancellationMessage, executionHeaders } from './executions';
|
||||
const request = vi.hoisted(() => vi.fn());
|
||||
vi.mock('@/utils/request', () => ({ default: request }));
|
||||
import { cancelExecution, previewObject } from './index';
|
||||
const id='bb79cd45-33f6-4ab4-92c7-5b940a006b9c';
|
||||
describe('BI execution cancellation', () => {
|
||||
it('preserves a traditional query without cancellation and validates UUID scope', () => {
|
||||
expect(executionHeaders()).toEqual({ repeatSubmit: false });
|
||||
expect(()=>executionHeaders('../other')).toThrow('查询标识无效');
|
||||
expect(()=>executionHeaders('bb79cd45-33f6-1ab4-92c7-5b940a006b9c')).toThrow();
|
||||
});
|
||||
it('sends the query identity separately from runtime data and permission context', () => {
|
||||
previewObject({id:'object',version:2},{parameters:{p:['3']}},id);
|
||||
expect(request).toHaveBeenLastCalledWith(expect.objectContaining({headers:{repeatSubmit:false,'X-BI-Execution-Id':id},data:{version:2,parameters:{p:['3']}}}));
|
||||
cancelExecution(id);
|
||||
expect(request).toHaveBeenLastCalledWith(expect.objectContaining({url:`/api/dataproduct/v1/bi/executions/${id}/cancel`,method:'post'}));
|
||||
});
|
||||
it('never equates cancellation acknowledgement with a database terminal state', () => {
|
||||
expect(cancellationMessage(id,{executionId:id,state:'CANCEL_REQUESTED'})).toContain('停止状态尚未确认');
|
||||
expect(cancellationMessage(id,{executionId:id,state:'FINISHED'})).toContain('结果已丢弃');
|
||||
});
|
||||
it('keeps mismatched or unknown responses recoverable with the same identity', () => {
|
||||
expect(()=>cancellationMessage(id,{executionId:'another',state:'FINISHED'})).toThrow('匹配');
|
||||
expect(()=>cancellationMessage(id,{executionId:id,state:'UNKNOWN'})).toThrow('重试');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
export function executionHeaders(id?: string): { repeatSubmit: false; 'X-BI-Execution-Id'?: string } {
|
||||
if (id === undefined) return { repeatSubmit: false };
|
||||
requireExecutionId(id);
|
||||
return { repeatSubmit: false, 'X-BI-Execution-Id': id };
|
||||
}
|
||||
export function requireExecutionId(id: string) {
|
||||
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(id)) throw new Error('查询标识无效');
|
||||
}
|
||||
export interface ExecutionState { executionId: string; state: string }
|
||||
export function cancellationMessage(id: string, result?: ExecutionState) {
|
||||
if (!result || result.executionId !== id) throw new Error('取消请求未返回匹配的查询标识,请重试取消');
|
||||
if (result.state === 'CANCEL_REQUESTED') return '已请求取消,本次结果不再显示;数据库停止状态尚未确认。自动刷新已暂停。';
|
||||
if (result.state === 'FINISHED') return '查询已结束,本次结果已丢弃。自动刷新已暂停。';
|
||||
if (result.state === 'FAILED') return '查询未完成,本次结果已丢弃。自动刷新已暂停。';
|
||||
throw new Error('取消状态尚未确认,请重试取消');
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { RuntimeControls } from './types';
|
||||
import type { DataExportBlob } from './index';
|
||||
|
||||
export type ExportJobState='QUEUED'|'RUNNING'|'READY'|'FAILED'|'UNKNOWN'|'EXPIRED'|'REVOKED';
|
||||
export interface ExportJob {id:string;objectId:string;objectVersion:number;format:'CSV'|'XLSX';rowCount:number;truncated:boolean;watermark:string;state:ExportJobState;safeCode?:string;expiresAt:string;version:number;createdAt:string;updatedAt:string}
|
||||
export interface ExportJobCommand extends RuntimeControls {version:number;datasetId:string;widgetId?:string;format:'CSV'|'XLSX'}
|
||||
const base='/api/dataproduct/v1/bi';
|
||||
const headers=(key:string)=>({'Idempotency-Key':key,repeatSubmit:false});
|
||||
export const listExportJobs=(id:string):AxiosPromise<ExportJob[]>=>request({url:`${base}/objects/${encodeURIComponent(id)}/export-jobs`,method:'get',suppressErrorToast:true});
|
||||
export const createExportJob=(id:string,command:ExportJobCommand,key:string):AxiosPromise<ExportJob>=>request({url:`${base}/objects/${encodeURIComponent(id)}/export-jobs`,method:'post',data:command,headers:headers(key),timeout:60000,suppressErrorToast:true});
|
||||
export const changeExportJob=(job:ExportJob,action:'revoke'|'retry',key:string):AxiosPromise<ExportJob>=>request({url:`${base}/export-jobs/${encodeURIComponent(job.id)}/${action}`,method:'post',data:{version:job.version},headers:headers(key),suppressErrorToast:true});
|
||||
export const downloadExportJob=(id:string):Promise<DataExportBlob>=>request({url:`${base}/export-jobs/${encodeURIComponent(id)}/download`,method:'get',responseType:'blob',timeout:120000,suppressErrorToast:true,transformResponse:[(data:Blob,headers)=>{const count=Number(headers['x-bi-row-count']);if(data instanceof Blob&&Number.isInteger(count)&&count>=0&&count<=1000)Object.assign(data,{rowCount:count,truncated:headers['x-bi-truncated']==='true'});return data;}]});
|
||||
@@ -0,0 +1,16 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { BiKind } from './types';
|
||||
|
||||
export interface BiImpactNode {
|
||||
key: string; id: string; version: number; kind: BiKind; name: string; status: string;
|
||||
current: boolean; published: boolean; relation: 'ROOT' | 'DEPENDENCY' | 'IMPACT';
|
||||
}
|
||||
export interface BiImpactEdge { from: string; to: string }
|
||||
export interface BiImpactGraph {
|
||||
rootId: string; currentVersion: number; scope: 'VISIBLE_CURRENT_PUBLISHED_AND_PINNED';
|
||||
partial: boolean; limitations: string[]; scannedObjects: number; objectLimit: number; versionLimit: number;
|
||||
nodes: BiImpactNode[]; edges: BiImpactEdge[]; checkedAt: string;
|
||||
}
|
||||
export const getBiImpact = (id: string): AxiosPromise<BiImpactGraph> =>
|
||||
request({ url: `/api/dataproduct/v1/bi/objects/${encodeURIComponent(id)}/impact`, method: 'get' });
|
||||
@@ -0,0 +1,52 @@
|
||||
import request from '@/utils/request';
|
||||
import { executionHeaders, requireExecutionId, type ExecutionState } from './executions';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { BiDefinition, BiKind, BiManagement, BiObject, BiPage, BiPreview, BiSpec, DefinitionPackage, QueryResult, RuntimeControls, SemanticCandidate, ShareCandidate, ShareView, SourceCandidate, Validation } from './types';
|
||||
const base = '/api/dataproduct/v1/bi';
|
||||
const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const listObjects = (kind: BiKind, keyword = '', pageNum = 1, pageSize = 20,folderPath?:string): AxiosPromise<BiPage> =>
|
||||
request({ url: `${base}/objects`, method: 'get', params: { kind, keyword, pageNum, pageSize,folderPath } });
|
||||
export const listFolders=(kind:BiKind):AxiosPromise<{paths:string[];truncated:boolean}>=>request({url:`${base}/folders`,method:'get',params:{kind}});
|
||||
export const getObject = (id: string): AxiosPromise<BiObject> => request({ url: `${base}/objects/${encodeURIComponent(id)}`, method: 'get' });
|
||||
export const recoveryContext=(id:string):AxiosPromise<{state:'OWNED'|'LOCAL_DRAFT_ONLY';object?:BiObject|null}>=>request({url:`${base}/objects/${encodeURIComponent(id)}/recovery-context`,method:'get'});
|
||||
export const listSources = (): AxiosPromise<SourceCandidate[]> => request({ url: `${base}/sources`, method: 'get' });
|
||||
export const listSemanticModels = (keyword = ''): AxiosPromise<SemanticCandidate[]> => request({ url: `${base}/semantic-models`, method: 'get', params: { keyword } });
|
||||
export const createObject = (data: { id: string; kind: BiKind; name: string; description: string; spec: BiSpec; management?:BiManagement }, key: string): AxiosPromise<BiObject> =>
|
||||
request({ url: `${base}/objects`, method: 'post', data, headers: headers(key), suppressErrorToast: true });
|
||||
export const updateObject = (id: string, data: { version: number; name: string; description: string; spec: BiSpec; management?:BiManagement }, key: string): AxiosPromise<BiObject> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(id)}`, method: 'put', data, headers: headers(key), suppressErrorToast: true });
|
||||
export const validateObject = (id: string): AxiosPromise<Validation> => request({ url: `${base}/objects/${encodeURIComponent(id)}/validate`, method: 'post', headers: { repeatSubmit: false } });
|
||||
export const publishObject = (object: BiObject, key: string): AxiosPromise<BiObject> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/publish`, method: 'post', data: { version: object.version }, headers: headers(key) });
|
||||
export const archiveObject = (object: BiObject, key: string): AxiosPromise<BiObject> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/archive`, method: 'post', data: { version: object.version }, headers: headers(key) });
|
||||
export const listVersions = (id: string): AxiosPromise<BiObject[]> => request({ url: `${base}/objects/${encodeURIComponent(id)}/versions`, method: 'get' });
|
||||
export const restoreVersion = (object: BiObject, restoreVersion: number, key: string): AxiosPromise<BiObject> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/restore`, method: 'post', data: { version: object.version, restoreVersion }, headers: headers(key) });
|
||||
export const queryDataset = (object: Pick<BiObject, 'id' | 'version'>, executionId?: string): AxiosPromise<QueryResult> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/query`, method: 'post', data: { version: object.version }, headers: executionHeaders(executionId) });
|
||||
export const previewObject = (object: Pick<BiObject, 'id' | 'version'>, controls: RuntimeControls = {}, executionId?: string): AxiosPromise<BiPreview> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/preview`, method: 'post', data: { version: object.version, ...controls }, headers: executionHeaders(executionId) });
|
||||
export const exportSnapshot = (object: Pick<BiObject, 'id' | 'version'>, controls: RuntimeControls = {}, executionId?: string): AxiosPromise<BiPreview> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/export-snapshot`, method: 'post', data: { version: object.version, ...controls }, headers: executionHeaders(executionId) });
|
||||
export const cancelExecution = (executionId: string): AxiosPromise<ExecutionState> => {
|
||||
requireExecutionId(executionId);
|
||||
return request({ url: `${base}/executions/${executionId}/cancel`, method: 'post', headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
};
|
||||
export interface DataExportBlob extends Blob { rowCount?: number; truncated?: boolean }
|
||||
export const exportData = (object: Pick<BiObject, 'id' | 'version'>, datasetId: string, format: 'CSV' | 'XLSX', controls: RuntimeControls = {}, widgetId?:string): Promise<DataExportBlob> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/export`, method: 'post', data: { version: object.version, datasetId, widgetId, format, ...controls }, responseType: 'blob', headers: { repeatSubmit: false }, transformResponse: [(data: Blob, headers) => { const count = Number(headers['x-bi-row-count']); if (data instanceof Blob && Number.isInteger(count) && count >= 0 && count <= 1000) { Object.assign(data, { rowCount: count, truncated: headers['x-bi-truncated'] === 'true' }); } return data; }] });
|
||||
export const managedImage = (id: string): Promise<Blob> => {
|
||||
if (!/^[1-9]\d{0,18}$/.test(id)) return Promise.reject(new Error('受管文件ID无效'));
|
||||
return request({ url: `/resource/oss/download/${id}`, method: 'get', responseType: 'blob' });
|
||||
};
|
||||
export const exportDefinition = (object: Pick<BiObject, 'id' | 'version'>): AxiosPromise<DefinitionPackage> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/export-definition`, method: 'post', data: { version: object.version }, headers: { repeatSubmit: false } });
|
||||
export const validateDefinition = (definition: BiDefinition): AxiosPromise<BiDefinition> =>
|
||||
request({ url: `${base}/definition/validate`, method: 'post', data: definition, headers: { repeatSubmit: false } });
|
||||
export const listShares = (id: string): AxiosPromise<ShareView[]> => request({ url: `${base}/objects/${encodeURIComponent(id)}/shares`, method: 'get' });
|
||||
export const shareCandidates = (type: 'USER' | 'ROLE', keyword = ''): AxiosPromise<ShareCandidate[]> => request({ url: `${base}/share-candidates`, method: 'get', params: { type, keyword } });
|
||||
export const createShare = (object: BiObject, subjectType: 'USER' | 'ROLE', subjectId: string, expiresAt: string, key: string): AxiosPromise<BiObject> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/shares`, method: 'post', data: { version: object.version, subjectType, subjectId, expiresAt }, headers: headers(key) });
|
||||
export const revokeShare = (object: BiObject, shareId: string, key: string): AxiosPromise<BiObject> =>
|
||||
request({ url: `${base}/objects/${encodeURIComponent(object.id)}/shares/revoke`, method: 'post', data: { version: object.version, shareId }, headers: headers(key) });
|
||||
@@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { CategoryRemainder,RuntimeControls,TimeBucket,PeriodComparison,ResolvedRelativeWindow } from './types';
|
||||
export interface NarrativeScope { widgetId?:string|null;datasetId:string;datasetName:string;version:number;observedAt:string;returnedRows:number;truncated:boolean;categoryRemainder?:CategoryRemainder|null;timeBucket?:TimeBucket|null;comparison?:PeriodComparison|null;relativeWindow?:ResolvedRelativeWindow|null }
|
||||
export interface NarrativeReference { widgetId?:string|null;datasetId:string;version:number;observedAt:string;rowIndex:number;field:string;rawValue:string }
|
||||
export interface NarrativeFact { widgetId?:string|null;id:string;datasetId:string;datasetName:string;field:string;label:string;unit:string;kind:'SINGLE'|'RANGE'|'NO_VALUES';comparedRows:number;excludedRows:number;references:NarrativeReference[] }
|
||||
export interface NarrativeParagraph { topic:'OVERVIEW'|'RANGES'|'MISSING_VALUES';factIds:string[] }
|
||||
export interface NarrativeResult { requestId:string;state:'DRAFT'|'DISABLED'|'FAILED';code:string;snapshotHash:string;scopes:NarrativeScope[];facts:NarrativeFact[];paragraphs:NarrativeParagraph[];factsLimited:boolean }
|
||||
export const generateNarrative=(id:string,data:RuntimeControls&{requestId:string;version:number;focus:string},signal:AbortSignal):AxiosPromise<NarrativeResult>=>request({url:`/api/dataproduct/v1/bi/objects/${encodeURIComponent(id)}/ai-narrative`,method:'post',data,signal,timeout:180000,headers:{repeatSubmit:false},suppressErrorToast:true});
|
||||
@@ -0,0 +1,5 @@
|
||||
import request from '@/utils/request';
|
||||
import type {AxiosPromise} from '@/utils/api-types';
|
||||
export interface BiPageChange {id:string;widgetId?:string|null;field:'title'|'appearance'|'style';value:unknown}
|
||||
export interface BiPagePatchResult {requestId:string;state:'DRAFT'|'DISABLED'|'FAILED';code:string;targetHash:string;changes:BiPageChange[];explanation:string|null}
|
||||
export const generateBiPagePatch=(id:string,data:{requestId:string;version:number;pageId:string;prompt:string},signal:AbortSignal):AxiosPromise<BiPagePatchResult>=>request({url:`/api/dataproduct/v1/bi/objects/${encodeURIComponent(id)}/ai-page-patch`,method:'post',data,signal,timeout:70000,headers:{repeatSubmit:false},suppressErrorToast:true});
|
||||
@@ -0,0 +1,6 @@
|
||||
import request from '@/utils/request';
|
||||
import type {AxiosPromise} from '@/utils/api-types';
|
||||
import type {BiObject,CategoryRemainder,RuntimeControls,TimeBucket,PeriodComparison,ResolvedRelativeWindow} from './types';
|
||||
export interface BiResultPage { state:'SUCCEEDED'|'FAILED'|'UNAVAILABLE';columns:string[];rows:Record<string,string|null>[];pageNum:number;pageSize:number;boundedTotal:number;sourceTruncated:boolean;observedAt:string|null;snapshotHash:string|null;message:string|null;categoryRemainder?:CategoryRemainder|null;executionMillis?:number|string|null;executionBudgetSeconds?:number|null;timeBucket?:TimeBucket|null;authorizationSha256?:string|null;comparison?:PeriodComparison|null;relativeWindow?:ResolvedRelativeWindow|null }
|
||||
export const readResultPage=(object:Pick<BiObject,'id'|'version'>,datasetId:string,pageNum:number,pageSize:number,snapshotHash:string|undefined,controls:RuntimeControls,signal:AbortSignal,widgetId?:string):AxiosPromise<BiResultPage>=>
|
||||
request({url:`/api/dataproduct/v1/bi/objects/${encodeURIComponent(object.id)}/result-pages`,method:'post',data:{version:object.version,datasetId,widgetId,pageNum,pageSize,snapshotHash,...controls},signal,headers:{repeatSubmit:false},suppressErrorToast:true});
|
||||
@@ -0,0 +1,104 @@
|
||||
export type BiKind = 'DATASET' | 'CHART' | 'REPORT' | 'SCREEN';
|
||||
export interface BiReference { id: string; version: number }
|
||||
export interface ValueFormat { type: 'RAW' | 'NUMBER' | 'PERCENT' | 'DATE' | 'DATETIME'; precision: number; thousands: boolean; unit: string; timeZone: string }
|
||||
export interface BiField { name: string; label: string; role: 'DIMENSION' | 'MEASURE' | 'TIME'; unit?: string; format?: ValueFormat }
|
||||
export interface TimeBucket {field:string;unit:'DAY'|'WEEK'|'MONTH'|'QUARTER'|'YEAR'|'FISCAL_QUARTER'|'FISCAL_YEAR';fiscalStartMonth?:number}
|
||||
export interface PeriodComparison {mode:'PREVIOUS_YEAR';startDate:string;endDateExclusive:string;outputs:{measureAlias:string;baselineAlias:string;differenceAlias:string;rateAlias:string}[]}
|
||||
export interface RelativeWindow {field:string;unit:'DAY'|'WEEK'|'MONTH'|'QUARTER'|'YEAR';count:number;timeZone:string}
|
||||
export interface ResolvedRelativeWindow extends RelativeWindow {referenceDate:string;startDate:string;endDateExclusive:string}
|
||||
export interface DatasetQuery {
|
||||
pivotTotals?: boolean;
|
||||
categoryRemainder?: {top:number};
|
||||
timeBucket?:TimeBucket;
|
||||
comparison?:PeriodComparison;
|
||||
relativeWindow?:RelativeWindow;
|
||||
maxExecutionSeconds?:number;
|
||||
dimensions: string[];
|
||||
measures: { field: string; aggregate: 'SUM' | 'COUNT' | 'COUNT_DISTINCT' | 'AVG' | 'MIN' | 'MAX'; alias: string }[];
|
||||
filters: { field: string; operator: 'EQ' | 'NE' | 'GT' | 'GE' | 'LT' | 'LE' | 'IN' | 'IS_NULL' | 'IS_NOT_NULL'; values: string[] }[];
|
||||
sort: { field: string; direction: 'ASC' | 'DESC' }[];
|
||||
}
|
||||
export interface SemanticBinding {
|
||||
modelId: string; modelVersion: number; modelHash: string; factCode: string;
|
||||
dimensions: { code: string; dimensionId: string; dimensionVersion: number; sourceDatasetId: string; sourceReleaseId: string; joinType: 'LEFT' | 'INNER'; keys: { factField: string; dimensionField: string }[] }[];
|
||||
fields: { name: string; table: string; column: string }[];
|
||||
metrics: { measureCode: string; metricId: string; version: number; hash: string; field: string;unit?:string }[];
|
||||
}
|
||||
export interface SemanticCandidate {
|
||||
model: { id: string; version: number; hash: string; name: string; factCode: string; factSourceRef: string; dimensions: { code: string; id: string; name: string; version: number }[]; measures: { code: string; metricRef: string; name: string; unit: string }[] };
|
||||
metrics: { measureCode: string; unavailableReason?: string; metric: { id: string; version: number; hash: string; code: string; name: string; unit: string; aggregate: DatasetQuery['measures'][number]['aggregate']; field: string; businessDefinition: string; applicableScope: string; statisticalCycle: string } | null }[];
|
||||
}
|
||||
export interface DatasetSpec { schemaVersion: 1; sourceDatasetId: string; sourceReleaseId: string; fields: BiField[]; limit: number; query?: DatasetQuery; semantic?: SemanticBinding }
|
||||
export type ChartType = 'TABLE' | 'KPI' | 'BAR' | 'HORIZONTAL_BAR' | 'STACKED_BAR' | 'LINE' | 'AREA' | 'PIE' | 'DONUT' | 'SCATTER' | 'COMBO' | 'PIVOT';
|
||||
export interface ValueAxis { unit: string; zeroBaseline: boolean; min?: number; max?: number }
|
||||
export interface ChartAxes { left: ValueAxis; right?: ValueAxis; rightFields: string[] }
|
||||
export interface ChartGrid {top:number;right:number;bottom:number;left:number;show:boolean}
|
||||
export interface ChartStyle { theme: 'LIGHT' | 'DARK'; legend: boolean; palette?: 'DEFAULT' | 'OCEAN' | 'FOREST' | 'WARM' | 'ACCESSIBLE'; font?: 'SANS' | 'SERIF' | 'MONO'; labels?: boolean; labelMode?: 'VALUE' | 'CATEGORY' | 'BOTH'; maxSymbolSize?: number;grid?:ChartGrid }
|
||||
export interface KpiComparison { baselineField?: string; targetField?: string; baselineLabel?: string; targetLabel?: string }
|
||||
export interface CalendarAxis { unit: 'DAY' | 'WEEK' | 'MONTH' }
|
||||
export interface ChartSpec {
|
||||
schemaVersion: 1; datasetRef: BiReference; chartType: ChartType; title?: string; subtitle?: string;
|
||||
encoding: { x?: string; y: string[]; series?: string; size?: string; tooltip?: string[] };
|
||||
format: { precision: number; unit: string }; style: ChartStyle;
|
||||
fieldFormats?: Record<string, ValueFormat>;
|
||||
axes?: ChartAxes;
|
||||
comparison?: KpiComparison;
|
||||
calendarAxis?: CalendarAxis;
|
||||
}
|
||||
export interface Widget {
|
||||
id: string; type: 'CHART' | 'TEXT' | 'CLOCK' | 'IMAGE' | 'CONTAINER'; chartRef?: BiReference; text?: string; parentId?:string;
|
||||
fileId?: string; imageFit?: 'CONTAIN' | 'COVER' | 'STRETCH'; filterId?: string; drillFields?: string[];
|
||||
style?: { fontSize: number; color: string; background: string; borderColor: string; borderWidth: number; radius: number; padding: number; align: 'LEFT' | 'CENTER' | 'RIGHT' };
|
||||
x: number; y: number; width: number; height: number; zIndex: number; locked?: boolean; hidden?: boolean; rotation?: number; groupId?: string;
|
||||
}
|
||||
export interface PageAppearance { theme: 'LIGHT' | 'DARK'; palette: NonNullable<ChartStyle['palette']>; font: NonNullable<ChartStyle['font']> }
|
||||
export interface LayoutPage { id: string; title: string; widgets: Widget[]; hidden?: boolean; appearance?: PageAppearance }
|
||||
export interface LayoutSpec {
|
||||
filters?: FilterBinding[];
|
||||
schemaVersion: 1; pages: LayoutPage[]; theme: 'LIGHT' | 'DARK'; refreshSeconds: number;
|
||||
canvas: { width: number; height: number; fit: 'CONTAIN' | 'COVER' | 'STRETCH' };
|
||||
playback: { intervalSeconds: number };
|
||||
}
|
||||
export type ParameterScope = {kind:'GLOBAL'} | {kind:'PAGE';pageId:string} | {kind:'WIDGET';pageId:string;widgetId:string};
|
||||
export interface FilterBinding { id: string; label: string; datasetId: string; field: string; operator: 'EQ' | 'IN' | 'GE' | 'LE' | 'BETWEEN'; control: 'TEXT' | 'SELECT' | 'MULTI' | 'NUMBER' | 'DATE' | 'NUMBER_RANGE' | 'DATE_RANGE'; parentId?: string; required?: boolean; defaultValues?: string[]; allowedValues?: string[]; targets?: { datasetId:string;field:string }[]; scope?:ParameterScope }
|
||||
export interface RuntimeFilter { datasetId: string; field: string; operator: DatasetQuery['filters'][number]['operator']; values: string[] }
|
||||
export interface RuntimeDrill { datasetId: string; dimensions: string[] }
|
||||
export interface RuntimeControls { filters?: RuntimeFilter[]; drills?: RuntimeDrill[]; parameters?: Record<string, string[]> }
|
||||
export type BiSpec = DatasetSpec | ChartSpec | LayoutSpec;
|
||||
export interface BiManagement {folderPath:string;publishNote:string;expiresAt:string;exportWatermark:string}
|
||||
export interface BiObject {
|
||||
management?:BiManagement|null;
|
||||
id: string; kind: BiKind; name: string; description: string; status: 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
|
||||
version: number; publishedVersion: number | null; ownerId: string; spec: BiSpec; updatedAt: string;
|
||||
}
|
||||
export interface SourceCandidate {
|
||||
datasetId: string; name: string; releaseId: string;
|
||||
fields: { name: string; dataType: string; nullable: boolean; sensitivity: string }[];
|
||||
}
|
||||
export interface QueryResult {
|
||||
state: 'SUCCEEDED' | 'UNAVAILABLE' | 'FAILED'; columns: string[]; rows: Record<string, string | null>[];
|
||||
truncated: boolean; observedAt: string | null; message: string;
|
||||
/** Server-measured JDBC execution and bounded result reading; absent means unknown. */
|
||||
executionMillis?: number | string | null;
|
||||
executionBudgetSeconds?:number|null;
|
||||
timeBucket?:TimeBucket|null;
|
||||
comparison?:PeriodComparison|null;
|
||||
relativeWindow?:ResolvedRelativeWindow|null;
|
||||
authorizationSha256?:string|null;
|
||||
pivotTotals?: PivotTotals | null;
|
||||
fieldUnits?: Record<string,string>;
|
||||
categoryRemainder?:CategoryRemainder|null;
|
||||
}
|
||||
export interface CategoryRemainder {field:string;measure:string;top:number;scope:'ALL_FILTERED';otherRowIndex?:number|null}
|
||||
/** Totals are produced by the source query; consumers only place the returned values. */
|
||||
export interface PivotTotals {
|
||||
rowField: string; columnField: string; measure: string; scope: 'ALL_FILTERED';
|
||||
rowTotals: Record<string, string | null>[]; columnTotals: Record<string, string | null>[]; grandTotal: string | null;
|
||||
}
|
||||
export interface BiPage { rows: BiObject[]; total: number }
|
||||
export interface Validation { valid: boolean; issues: string[] }
|
||||
export interface BiPreview { object: BiObject; dependencies: BiObject[]; results: Record<string, QueryResult>; widgetResults?:Record<string,QueryResult> }
|
||||
export interface BiDefinition { kind: BiKind; name: string; description: string; spec: BiSpec }
|
||||
export interface DefinitionPackage { schemaVersion: 1; object: BiDefinition; dependencies: { id: string; version: number; kind: BiKind; name: string }[] }
|
||||
export interface ShareView { id: string; subjectType: 'USER' | 'ROLE'; subjectId: string; subjectName: string; expiresAt: string; revoked: boolean }
|
||||
export interface ShareCandidate { subjectType: 'USER' | 'ROLE'; subjectId: string; name: string }
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { AssociationsCommand, CreateTermCommand, LexiconsCommand, PageResult, RelationsCommand, StatusCommand, TermDetail, TermQuery, TermView, UpdateTermCommand, WriteResult } from './types';
|
||||
const baseUrl = '/api/governance/v1/business-terms';
|
||||
const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const pageTerms = (params: TermQuery): AxiosPromise<PageResult<TermView>> => request({ url: baseUrl, method: 'get', params });
|
||||
export const getTerm = (id: number): AxiosPromise<TermDetail> => request({ url: `${baseUrl}/${id}`, method: 'get' });
|
||||
export const createTerm = (data: CreateTermCommand, key: string): AxiosPromise<WriteResult<TermDetail>> => request({ url: baseUrl, method: 'post', data, headers: headers(key) });
|
||||
export const updateTerm = (id: number, data: UpdateTermCommand, key: string): AxiosPromise<WriteResult<TermDetail>> => request({ url: `${baseUrl}/${id}`, method: 'put', data, headers: headers(key) });
|
||||
export const changeTermStatus = (id: number, data: StatusCommand, key: string): AxiosPromise<WriteResult<TermDetail>> => request({ url: `${baseUrl}/${id}/status`, method: 'post', data, headers: headers(key) });
|
||||
export const replaceTermLexicons = (id: number, data: LexiconsCommand, key: string): AxiosPromise<WriteResult<TermDetail>> => request({ url: `${baseUrl}/${id}/lexicons`, method: 'put', data, headers: headers(key) });
|
||||
export const replaceTermRelations = (id: number, data: RelationsCommand, key: string): AxiosPromise<WriteResult<TermDetail>> => request({ url: `${baseUrl}/${id}/relations`, method: 'put', data, headers: headers(key) });
|
||||
export const replaceTermAssociations = (id: number, data: AssociationsCommand, key: string): AxiosPromise<WriteResult<TermDetail>> => request({ url: `${baseUrl}/${id}/associations`, method: 'put', data, headers: headers(key) });
|
||||
@@ -0,0 +1,18 @@
|
||||
export type TermStatus = 'ENABLED' | 'DISABLED';
|
||||
export type LexiconType = 'SYNONYM' | 'ALIAS' | 'ABBREVIATION' | 'AMBIGUOUS' | 'PROHIBITED';
|
||||
export type RelationType = 'PARENT_CHILD' | 'RELATED' | 'REPLACEMENT' | 'CONFLICT';
|
||||
export type AssociationType = 'DATA_ELEMENT' | 'MODEL_FIELD' | 'METRIC' | 'ASSET' | 'DATA_PRODUCT';
|
||||
export interface PageResult<T> { rows: T[]; total: number }
|
||||
export interface TermQuery { keyword?: string; status?: TermStatus; pageNum: number; pageSize: number }
|
||||
export interface TermView { termId: number; termCode: string; termName: string; definition: string; businessDefinition?: string; ownerId?: number; status: TermStatus; organizationId: number; departmentId: number; version: number; createTime: string; updateTime?: string }
|
||||
export interface LexiconView { lexiconId: number; lexiconType: LexiconType; value: string; description?: string; sortOrder: number }
|
||||
export interface RelationView { relationId: number; relationType: RelationType; targetTermId: number; description?: string; sortOrder: number }
|
||||
export interface AssociationView { associationId: number; targetType: AssociationType; targetId: string; targetFqn?: string; targetDisplayName?: string; sortOrder: number }
|
||||
export interface TermDetail { term: TermView; lexicons: LexiconView[]; relations: RelationView[]; associations: AssociationView[] }
|
||||
export interface CreateTermCommand { termCode: string; termName: string; definition: string; businessDefinition?: string; ownerId?: number }
|
||||
export interface UpdateTermCommand { termName: string; definition: string; businessDefinition?: string; ownerId?: number; version: number }
|
||||
export interface StatusCommand { targetStatus: TermStatus; reason: string; version: number }
|
||||
export interface LexiconsCommand { lexicons: Array<Omit<LexiconView, 'lexiconId'>>; version: number }
|
||||
export interface RelationsCommand { relations: Array<Omit<RelationView, 'relationId'>>; version: number }
|
||||
export interface AssociationsCommand { associations: Array<Omit<AssociationView, 'associationId'>>; version: number }
|
||||
export interface WriteResult<T> { requestId: string; result: T }
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
ChainMetricQuery,
|
||||
Identifier,
|
||||
OverviewView,
|
||||
RefreshRequest,
|
||||
RefreshView,
|
||||
SnapshotDetailView,
|
||||
SnapshotPageView,
|
||||
TopologyView
|
||||
} from './types';
|
||||
|
||||
const writeHeaders = (idempotencyKey: string) => ({
|
||||
'Idempotency-Key': idempotencyKey,
|
||||
repeatSubmit: false
|
||||
});
|
||||
|
||||
export const getChainMetricOverview = (params: ChainMetricQuery): AxiosPromise<OverviewView> =>
|
||||
request({ url: '/api/dataops/v1/chain-metrics/overview', method: 'get', params });
|
||||
|
||||
export const listChainMetricSnapshots = (params: ChainMetricQuery): AxiosPromise<SnapshotPageView> =>
|
||||
request({ url: '/api/dataops/v1/chain-metrics', method: 'get', params });
|
||||
|
||||
export const getChainMetricSnapshot = (snapshotId: Identifier): AxiosPromise<SnapshotDetailView> =>
|
||||
request({ url: `/api/dataops/v1/chain-metrics/${snapshotId}`, method: 'get' });
|
||||
|
||||
export const getChainMetricTopology = (snapshotId: Identifier): AxiosPromise<TopologyView> =>
|
||||
request({ url: `/api/dataops/v1/chain-metrics/${snapshotId}/topology`, method: 'get' });
|
||||
|
||||
export const refreshChainMetrics = (
|
||||
data: RefreshRequest,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<RefreshView> =>
|
||||
request({
|
||||
url: '/api/dataops/v1/chain-metrics/refresh',
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface StageScope { source: string | null; status: string | null; projectRef: string | null; taskType: string | null; startedFrom: string; startedTo: string }
|
||||
export interface StageReference { runId: string; fingerprint: string }
|
||||
export interface StageSelection { scope: StageScope; references: StageReference[] }
|
||||
export interface StageBinding { selection: StageSelection; fingerprint: string }
|
||||
export interface StageRun { key: string; runId: string; runType: string; status: string; startedAt?: string; completedAt?: string; createdAt?: string; updatedAt?: string; windowTime: string; fingerprint: string }
|
||||
export interface StageContext { selection: StageSelection; state: string; candidates: StageRun[]; selected: StageRun[]; total: number; truncated: boolean; fingerprint: string; boundary: string }
|
||||
export interface SavedStage { key: string; stage: string; status: string; attempts?: number; startedAt?: string; completedAt?: string; recordedAt?: string; recordedSpanMs?: number; spanState: string; errorClass: string }
|
||||
export interface RunStages { key: string; runId: string; runType: string; status: string; stages: SavedStage[] }
|
||||
export interface StageEvidence { binding: StageBinding; fingerprint: string; runs: RunStages[]; boundary: string; watermarkState: string }
|
||||
export interface StageNote { stageKeys: string[]; direction: string; explanation: string; checks: string[] }
|
||||
export interface StageExplanation { requestId: string; state: string; fingerprint: string; candidate?: { notes: StageNote[]; watermarkState: string }; code?: string }
|
||||
export const getStageCandidates = (data: StageSelection): AxiosPromise<StageContext> => request({ url: '/api/dataops/v1/chain-metrics/stage-evidence', method: 'post', data, timeout: 30000 });
|
||||
export const getStageEvidence = (data: StageBinding): AxiosPromise<StageEvidence> => request({ url: '/api/integration/v1/ai/chain-stages/context', method: 'post', data, timeout: 120000 });
|
||||
export const explainStageEvidence = (data: { requestId: string; binding: StageBinding; fingerprint: string; prompt: string; consent: boolean }): AxiosPromise<StageExplanation> => request({ url: '/api/integration/v1/ai/chain-stages/explain', method: 'post', data, timeout: 120000, headers: { repeatSubmit: false } });
|
||||
@@ -0,0 +1,123 @@
|
||||
export type Identifier = string | number;
|
||||
export type TaskSource = 'SCHEDULING' | 'BATCH_INGESTION' | 'FILE_INGESTION' | 'M2_GOLDEN';
|
||||
export type TaskStatus = 'PENDING' | 'SUBMITTED' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'CANCELED' | 'UNKNOWN';
|
||||
export type SnapshotState = 'PENDING' | 'AVAILABLE' | 'UNKNOWN' | 'UNSUPPORTED';
|
||||
export type MetricCategory = 'RESOURCE' | 'COST';
|
||||
|
||||
export interface ChainMetricQuery {
|
||||
source?: TaskSource;
|
||||
status?: TaskStatus;
|
||||
taskType?: string;
|
||||
startedFrom?: string;
|
||||
startedTo?: string;
|
||||
pageNum?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
export interface QueryView {
|
||||
source?: TaskSource;
|
||||
status?: TaskStatus;
|
||||
taskType?: string;
|
||||
startedFrom: string;
|
||||
startedTo: string;
|
||||
}
|
||||
|
||||
export interface LatencyStats {
|
||||
sampleCount: number;
|
||||
minimumMs: number;
|
||||
averageMs: number;
|
||||
maximumMs: number;
|
||||
}
|
||||
|
||||
export interface BaseMetrics {
|
||||
runCount: number;
|
||||
terminalCount: number;
|
||||
failedCount: number;
|
||||
backlogCount: number;
|
||||
latency?: LatencyStats;
|
||||
throughputPerHour: number;
|
||||
errorRate?: number;
|
||||
}
|
||||
|
||||
export interface OverviewView {
|
||||
query: QueryView;
|
||||
metrics: BaseMetrics;
|
||||
calculatedAt: string;
|
||||
}
|
||||
|
||||
export type RefreshRequest = Omit<ChainMetricQuery, 'pageNum' | 'pageSize'>;
|
||||
|
||||
export interface RefreshView {
|
||||
observationRequestId: Identifier;
|
||||
snapshotId?: Identifier;
|
||||
state: SnapshotState;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
observedAt?: string;
|
||||
createdAt: string;
|
||||
truncated: boolean;
|
||||
}
|
||||
|
||||
export interface SnapshotSummary {
|
||||
snapshotId: Identifier;
|
||||
state: SnapshotState;
|
||||
query: QueryView;
|
||||
metrics: BaseMetrics;
|
||||
externalSource?: string;
|
||||
evidenceRef?: string;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
observedAt: string;
|
||||
createdAt: string;
|
||||
truncated: boolean;
|
||||
}
|
||||
|
||||
export interface SnapshotPageView {
|
||||
rows: SnapshotSummary[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ObservedMetric {
|
||||
metricKey: string;
|
||||
category: MetricCategory;
|
||||
value: number;
|
||||
unit: string;
|
||||
observedAt: string;
|
||||
source: string;
|
||||
evidenceRef: string;
|
||||
}
|
||||
|
||||
export interface SnapshotDetailView {
|
||||
summary: SnapshotSummary;
|
||||
observedMetrics: ObservedMetric[];
|
||||
}
|
||||
|
||||
export interface TopologyNode {
|
||||
nodeId: string;
|
||||
nodeType: string;
|
||||
displayName: string;
|
||||
ownerReference?: string;
|
||||
externalReference?: string;
|
||||
observedAt: string;
|
||||
evidenceRef: string;
|
||||
internalPath?: string;
|
||||
}
|
||||
|
||||
export interface TopologyEdge {
|
||||
sourceNodeId: string;
|
||||
targetNodeId: string;
|
||||
relationType: string;
|
||||
evidenceRef: string;
|
||||
}
|
||||
|
||||
export interface TopologyView {
|
||||
state: SnapshotState;
|
||||
nodes: TopologyNode[];
|
||||
edges: TopologyEdge[];
|
||||
truncated: boolean;
|
||||
observedAt?: string;
|
||||
source?: string;
|
||||
evidenceRef?: string;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import type { PageResult } from '@/api/types';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { TableCandidate, TableCandidateScope, TableCandidateQuery } from './types';
|
||||
import type {
|
||||
CancelVO,
|
||||
CodeDetailVO,
|
||||
CodeForm,
|
||||
CodeId,
|
||||
CodeQuery,
|
||||
CodeSummaryVO,
|
||||
CodeUpdateForm,
|
||||
DebugCommand,
|
||||
DebugVO,
|
||||
MaterializationCommand,
|
||||
MaterializationVO,
|
||||
SnippetForm,
|
||||
SnippetUpdateForm,
|
||||
SnippetVO
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/dataops/v1/code-developments';
|
||||
|
||||
export const previewUnsavedSql = (data: import('./types').SqlPreviewCommand): AxiosPromise<import('./types').SqlPreviewView> =>
|
||||
request({ url: `${baseUrl}/sql-previews`, method: 'post', data, timeout: 10000,
|
||||
headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
const writeHeaders = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
|
||||
export const listCodeTableCandidates = (codeId: CodeId, params: TableCandidateQuery): AxiosPromise<PageResult<TableCandidate>> =>
|
||||
request({ url: `${baseUrl}/${codeId}/table-candidates`, method: 'get', params, suppressErrorToast: true });
|
||||
export const listCodeTableScopes = (codeId: CodeId, params: TableCandidateQuery): AxiosPromise<PageResult<TableCandidateScope>> =>
|
||||
request({ url: `${baseUrl}/${codeId}/table-candidate-scopes`, method: 'get', params, suppressErrorToast: true });
|
||||
export const getCodeSelectedTables = (codeId: CodeId, params: TableCandidateQuery, ids: Array<string | number>): AxiosPromise<TableCandidate[]> =>
|
||||
request({ url: `${baseUrl}/${codeId}/selected-tables`, method: 'get', params: { ...params, tableFileIds: ids.join(',') }, suppressErrorToast: true });
|
||||
|
||||
export const listCodeDevelopments = (params: CodeQuery): AxiosPromise<PageResult<CodeSummaryVO>> =>
|
||||
request({ url: baseUrl, method: 'get', params });
|
||||
|
||||
export const getCodeDevelopment = (codeId: CodeId): AxiosPromise<CodeDetailVO> =>
|
||||
request({ url: `${baseUrl}/${codeId}`, method: 'get' });
|
||||
|
||||
export const createCodeDevelopment = (data: CodeForm, key: string): AxiosPromise<CodeDetailVO> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateCodeDevelopment = (
|
||||
codeId: CodeId,
|
||||
data: CodeUpdateForm,
|
||||
key: string
|
||||
): AxiosPromise<CodeDetailVO> =>
|
||||
request({ url: `${baseUrl}/${codeId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const deleteCodeDevelopment = (codeId: CodeId, version: number, key: string): AxiosPromise<void> =>
|
||||
request({ url: `${baseUrl}/${codeId}`, method: 'delete', params: { version }, headers: writeHeaders(key) });
|
||||
|
||||
export const listCodeSnippets = (params: PageQuery & { keyword?: string }): AxiosPromise<PageResult<SnippetVO>> =>
|
||||
request({ url: `${baseUrl}/snippets`, method: 'get', params });
|
||||
|
||||
export const createCodeSnippet = (data: SnippetForm, key: string): AxiosPromise<SnippetVO> =>
|
||||
request({ url: `${baseUrl}/snippets`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateCodeSnippet = (snippetId: CodeId, data: SnippetUpdateForm, key: string): AxiosPromise<SnippetVO> =>
|
||||
request({ url: `${baseUrl}/snippets/${snippetId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const deleteCodeSnippet = (snippetId: CodeId, version: number, key: string): AxiosPromise<void> =>
|
||||
request({
|
||||
url: `${baseUrl}/snippets/${snippetId}`,
|
||||
method: 'delete',
|
||||
params: { version },
|
||||
headers: writeHeaders(key)
|
||||
});
|
||||
|
||||
export const debugCodeDevelopment = (
|
||||
codeId: CodeId,
|
||||
data: DebugCommand,
|
||||
key: string,
|
||||
options: { signal?: AbortSignal; timeout?: number } = {}
|
||||
): AxiosPromise<DebugVO> =>
|
||||
request({
|
||||
url: `${baseUrl}/${codeId}/debug-runs`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(key),
|
||||
timeout: options.timeout ?? 7000,
|
||||
signal: options.signal,
|
||||
suppressErrorToast: true
|
||||
});
|
||||
|
||||
export const getCodeDebugSummary = (requestId: string, options: { signal?: AbortSignal; timeout?: number } = {}): AxiosPromise<DebugVO> =>
|
||||
request({ url: `${baseUrl}/debug-runs/${requestId}`, method: 'get', timeout: options.timeout ?? 7000,
|
||||
signal: options.signal, suppressErrorToast: true });
|
||||
|
||||
export const cancelCodeDebug = (requestId: string): AxiosPromise<CancelVO> =>
|
||||
request({ url: `${baseUrl}/debug-runs/${requestId}/cancel`, method: 'post' });
|
||||
|
||||
export const preflightCodeMaterialization = (
|
||||
codeId: CodeId, data: MaterializationCommand, key: string
|
||||
): AxiosPromise<MaterializationVO> =>
|
||||
request({ url: `${baseUrl}/${codeId}/materialization-preflights`, method: 'post', data,
|
||||
headers: writeHeaders(key), timeout: 10000, suppressErrorToast: true });
|
||||
|
||||
export const executeCodeMaterialization = (
|
||||
requestId: string, requestVersion: number, parameters: Record<string, unknown>
|
||||
): AxiosPromise<MaterializationVO> =>
|
||||
request({ url: `${baseUrl}/materializations/${requestId}/execute`, method: 'post',
|
||||
data: { requestVersion, parameters }, timeout: 20000, suppressErrorToast: true });
|
||||
|
||||
export const getCodeMaterialization = (requestId: string): AxiosPromise<MaterializationVO> =>
|
||||
request({ url: `${baseUrl}/materializations/${requestId}`, method: 'get', suppressErrorToast: true });
|
||||
@@ -0,0 +1,195 @@
|
||||
export type CodeId = string | number;
|
||||
export type CodeLanguage = 'SQL' | 'SHELL' | 'PYTHON';
|
||||
export type ObjectStatus = 'ENABLED' | 'DISABLED';
|
||||
export type SnippetScope = 'GLOBAL';
|
||||
export type DebugState = 'SUBMITTED' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'UNKNOWN' | 'CANCELED';
|
||||
export type MaterializationState = 'SUBMITTED' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'UNKNOWN';
|
||||
export type MaterializationTargetMode = 'NEW_TABLE' | 'EXISTING_TABLE';
|
||||
|
||||
export interface ParameterDefinition {
|
||||
name: string;
|
||||
valueType: 'STRING' | 'LONG' | 'DECIMAL' | 'BOOLEAN' | 'DATE' | 'TIMESTAMP';
|
||||
required: boolean;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface CodeForm {
|
||||
name: string;
|
||||
language: CodeLanguage;
|
||||
body: string;
|
||||
parameters: ParameterDefinition[];
|
||||
status?: ObjectStatus;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface CodeUpdateForm {
|
||||
name: string;
|
||||
body: string;
|
||||
parameters: ParameterDefinition[];
|
||||
status: ObjectStatus;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface CodeSummaryVO {
|
||||
codeId: CodeId;
|
||||
name: string;
|
||||
language: CodeLanguage;
|
||||
orgId: CodeId;
|
||||
bodySha256: string;
|
||||
status: ObjectStatus;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface CodeVersionVO {
|
||||
versionId: CodeId;
|
||||
codeId: CodeId;
|
||||
objectVersion: number;
|
||||
bodySha256: string;
|
||||
snapshotSha256: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface CodeDetailVO {
|
||||
summary: CodeSummaryVO;
|
||||
body: string;
|
||||
parameters: ParameterDefinition[];
|
||||
versions: CodeVersionVO[];
|
||||
}
|
||||
|
||||
export interface CodeQuery extends PageQuery {
|
||||
keyword?: string;
|
||||
language?: CodeLanguage;
|
||||
status?: ObjectStatus;
|
||||
}
|
||||
|
||||
export interface SnippetForm {
|
||||
name: string;
|
||||
language: CodeLanguage;
|
||||
scope: SnippetScope;
|
||||
body: string;
|
||||
description?: string;
|
||||
status?: ObjectStatus;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface SnippetUpdateForm {
|
||||
name: string;
|
||||
body: string;
|
||||
description?: string;
|
||||
status: ObjectStatus;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface SnippetVO extends Required<Pick<SnippetForm, 'name' | 'language' | 'scope' | 'body'>> {
|
||||
snippetId: CodeId;
|
||||
orgId: CodeId;
|
||||
bodySha256: string;
|
||||
description?: string;
|
||||
status: ObjectStatus;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface DebugCommand {
|
||||
version: number;
|
||||
parameters: Record<string, unknown>;
|
||||
tableFileIds: CodeId[];
|
||||
}
|
||||
|
||||
export interface DebugVO {
|
||||
requestId: string;
|
||||
codeId: CodeId;
|
||||
objectVersion: number;
|
||||
state: DebugState;
|
||||
columns: string[];
|
||||
rows: Array<Record<string, string | null>>;
|
||||
rowCount: number;
|
||||
byteCount: number;
|
||||
truncated: boolean;
|
||||
sqlSha256: string;
|
||||
parameterDigestSha256: string;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
replayed: boolean;
|
||||
createdAt: string;
|
||||
completedAt?: string;
|
||||
}
|
||||
|
||||
export interface CancelVO {
|
||||
requestId: string;
|
||||
state: DebugState;
|
||||
cancelRequested: boolean;
|
||||
}
|
||||
|
||||
export interface MaterializationCommand {
|
||||
version: number;
|
||||
parameters: Record<string, unknown>;
|
||||
sourceTableFileIds: CodeId[];
|
||||
targetMode: MaterializationTargetMode;
|
||||
targetResourceId: CodeId;
|
||||
targetSpaceId: CodeId;
|
||||
targetLayerId: CodeId;
|
||||
targetTableFileId?: CodeId;
|
||||
targetTableName?: string;
|
||||
targetTableComment?: string;
|
||||
}
|
||||
|
||||
export interface MaterializationColumn {
|
||||
name: string;
|
||||
sourceAlias?: string;
|
||||
comment?: string;
|
||||
nativeType: string;
|
||||
nullable: boolean;
|
||||
precision?: number;
|
||||
scale?: number;
|
||||
}
|
||||
|
||||
export interface MaterializationVO {
|
||||
requestId: string;
|
||||
codeId: CodeId;
|
||||
objectVersion: number;
|
||||
state: MaterializationState;
|
||||
targetMode: MaterializationTargetMode;
|
||||
targetResourceId: CodeId;
|
||||
targetSpaceId: CodeId;
|
||||
targetLayerId: CodeId;
|
||||
targetTableFileId?: CodeId;
|
||||
targetTableName: string;
|
||||
targetTableComment?: string;
|
||||
outputColumns: MaterializationColumn[];
|
||||
targetColumns: MaterializationColumn[];
|
||||
compatible: boolean;
|
||||
affectedRows?: number;
|
||||
externalObjectId?: string;
|
||||
externalEvidenceSha256?: string;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
requestVersion: number;
|
||||
replayed: boolean;
|
||||
createdAt: string;
|
||||
completedAt?: string;
|
||||
}
|
||||
export interface TableCandidate { tableFileId: string | number; storageResourceId: string | number; storageSpaceId: string | number; engineType: string; catalogName: string; namespaceName: string; name: string; resourceName?: string; spaceName?: string; availability: 'ENABLED' | 'DISABLED' | 'UNAVAILABLE' }
|
||||
export interface TableCandidateScope { storageResourceId: string | number; storageSpaceId: string | number; resourceName?: string; spaceName?: string; availability: 'ENABLED' | 'DISABLED' | 'UNAVAILABLE' }
|
||||
export interface TableCandidateQuery { keyword?: string; storageResourceId?: string | number; storageSpaceId?: string | number; pageNum?: number; pageSize?: number }
|
||||
export interface SqlPreviewCommand {
|
||||
previewSql: string;
|
||||
resourceId: string | number;
|
||||
spaceId: string | number;
|
||||
}
|
||||
|
||||
export interface SqlPreviewView {
|
||||
generatedSql?: string;
|
||||
requestId: string;
|
||||
state: 'SUCCEEDED' | 'FAILED' | 'UNKNOWN' | 'CANCELED';
|
||||
columns: string[];
|
||||
rows: Record<string, string | null>[];
|
||||
rowCount: number;
|
||||
byteCount: number;
|
||||
truncated: boolean;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AuthorizationCommand,
|
||||
AuthorizationVO,
|
||||
CollectionNodeDetailVO,
|
||||
CollectionNodePage,
|
||||
CollectionNodeQuery,
|
||||
CollectionNodeRegistration,
|
||||
CollectionNodeUpdate,
|
||||
CollectionNodeVO,
|
||||
NodeObservationHistory,
|
||||
PlatformStatus,
|
||||
RoleCandidateVO
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/integration/v1/collection-nodes';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export function listCollectionNodes(params: CollectionNodeQuery): AxiosPromise<CollectionNodePage> {
|
||||
return request({ url: baseUrl, method: 'get', params });
|
||||
}
|
||||
|
||||
export function getCollectionNode(nodeId: string | number): AxiosPromise<CollectionNodeDetailVO> {
|
||||
return request({ url: `${baseUrl}/${nodeId}`, method: 'get' });
|
||||
}
|
||||
|
||||
export function getCollectionNodeHistory(nodeId: number, nodeVersion: number, hours: number): AxiosPromise<NodeObservationHistory> {
|
||||
return request({ url: `${baseUrl}/${nodeId}/observations`, method: 'get', params: { nodeVersion, hours } });
|
||||
}
|
||||
|
||||
export function createCollectionNode(
|
||||
data: CollectionNodeRegistration,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<CollectionNodeVO> {
|
||||
return request({ url: baseUrl, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
}
|
||||
|
||||
export function updateCollectionNode(
|
||||
nodeId: number,
|
||||
data: CollectionNodeUpdate,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<CollectionNodeVO> {
|
||||
return request({ url: `${baseUrl}/${nodeId}`, method: 'put', data, headers: writeHeaders(idempotencyKey) });
|
||||
}
|
||||
|
||||
export function deleteCollectionNode(
|
||||
nodeId: number,
|
||||
version: number,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<void> {
|
||||
return request({
|
||||
url: `${baseUrl}/${nodeId}`,
|
||||
method: 'delete',
|
||||
params: { version },
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
}
|
||||
|
||||
export function changeCollectionNodeStatus(
|
||||
nodeId: number,
|
||||
version: number,
|
||||
status: PlatformStatus,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<CollectionNodeVO> {
|
||||
return request({
|
||||
url: `${baseUrl}/${nodeId}/platform-status`,
|
||||
method: 'put',
|
||||
data: { version, status },
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
}
|
||||
|
||||
export function refreshCollectionNode(
|
||||
nodeId: number,
|
||||
version: number,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<CollectionNodeDetailVO> {
|
||||
return request({
|
||||
url: `${baseUrl}/${nodeId}/observations`,
|
||||
method: 'post',
|
||||
data: { version },
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
}
|
||||
|
||||
export function saveCollectionNodeAuthorization(
|
||||
nodeId: number,
|
||||
data: AuthorizationCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AuthorizationVO> {
|
||||
return request({
|
||||
url: `${baseUrl}/${nodeId}/authorizations`,
|
||||
method: 'put',
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
}
|
||||
|
||||
export function listCollectionNodeRoleCandidates(keyword?: string): AxiosPromise<RoleCandidateVO[]> {
|
||||
return request({ url: `${baseUrl}/role-candidates`, method: 'get', params: { keyword } });
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface NodeTaskSelection { nodeId: string; nodeVersion: number; taskId: string; taskVersion: number }
|
||||
export interface NodeTaskFact { key: string; kind: string; required: string | null; recorded: string | null; state: string; observedAt: string | null }
|
||||
export interface NodeTaskContext { selection: NodeTaskSelection; fingerprint: string; facts: NodeTaskFact[]; conclusion: 'NOT_CONFIRMED' }
|
||||
export interface NodeTaskDraft { items: { factKeys: string[]; explanation: string }[]; conclusion: 'NOT_CONFIRMED' }
|
||||
export const readNodeTaskContext = (data: NodeTaskSelection): AxiosPromise<NodeTaskContext> => request({ url: '/api/integration/v1/collection-node-task-assist/context', method: 'post', data });
|
||||
export const explainNodeTask = (data: { requestId: string; selection: NodeTaskSelection; fingerprint: string; prompt: string }): AxiosPromise<{ state: string; fingerprint: string; candidate: NodeTaskDraft | null; code: string }> => request({ url: '/api/integration/v1/ai/collection-node-tasks/candidates', method: 'post', data });
|
||||
@@ -0,0 +1,131 @@
|
||||
export type DeclaredRole = 'MASTER' | 'WORKER';
|
||||
export type PlatformStatus = 'ENABLED' | 'DISABLED';
|
||||
export type ObservationStatus = 'ONLINE' | 'UNKNOWN' | 'UNREACHABLE';
|
||||
export type CapabilityStatus = 'SUPPORTED' | 'UNSUPPORTED' | 'UNKNOWN';
|
||||
export type PlatformAction = 'VIEW' | 'USE_FOR_JOB' | 'REFRESH' | 'MANAGE_REGISTRY';
|
||||
export type AuthorizationStatus = 'ENABLED' | 'DISABLED';
|
||||
|
||||
export interface CollectionNodeRegistration {
|
||||
name: string;
|
||||
clusterCode: string;
|
||||
entryUrl: string;
|
||||
declaredRole: DeclaredRole;
|
||||
servicePrincipal: string;
|
||||
password: string;
|
||||
orgScopeId?: number;
|
||||
labels: Record<string, string>;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface CollectionNodeUpdate extends Omit<CollectionNodeRegistration, 'orgScopeId'> {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface CollectionNodeVO extends Omit<CollectionNodeRegistration, 'password' | 'orgScopeId'> {
|
||||
id: number;
|
||||
orgScopeId: number;
|
||||
platformStatus: PlatformStatus;
|
||||
observationStatus: ObservationStatus;
|
||||
observationStale: boolean;
|
||||
version: number;
|
||||
lastObservedAt?: string;
|
||||
lastSuccessfulAt?: string;
|
||||
}
|
||||
|
||||
export interface ObservationVO {
|
||||
status: ObservationStatus;
|
||||
stale: boolean;
|
||||
projectVersion?: string;
|
||||
totalSlot?: number;
|
||||
unassignedSlot?: number;
|
||||
runningJobs?: number;
|
||||
finishedJobs?: number;
|
||||
failedJobs?: number;
|
||||
pendingJobs?: number;
|
||||
cancelledJobs?: number;
|
||||
workers?: number;
|
||||
errorCode?: string;
|
||||
errorSummary?: string;
|
||||
observedAt: string;
|
||||
completedAt?: string;
|
||||
}
|
||||
|
||||
export interface NodeHistoryPoint {
|
||||
observationId: string;
|
||||
observedAt: string;
|
||||
completedAt?: string;
|
||||
status: ObservationStatus | 'IN_PROGRESS';
|
||||
verified: boolean;
|
||||
currentEndpoint: boolean;
|
||||
totalSlot?: number | string | null;
|
||||
unassignedSlot?: number | string | null;
|
||||
runningJobs?: number | string | null;
|
||||
workers?: number | string | null;
|
||||
}
|
||||
|
||||
export interface NodeObservationHistory {
|
||||
nodeId: string;
|
||||
nodeVersion: number;
|
||||
hours: number;
|
||||
from: string;
|
||||
to: string;
|
||||
timeBasis: 'PLATFORM_RECORDED_LOCAL_TIME';
|
||||
truncated: boolean;
|
||||
limit: number;
|
||||
points: NodeHistoryPoint[];
|
||||
}
|
||||
|
||||
export interface CapabilityVO {
|
||||
capabilityKey: string;
|
||||
connectorType: string;
|
||||
direction: 'SOURCE' | 'SINK';
|
||||
runMode: string;
|
||||
status: CapabilityStatus;
|
||||
stale: boolean;
|
||||
observedAt: string;
|
||||
}
|
||||
|
||||
export interface AuthorizationVO {
|
||||
id: number;
|
||||
roleId: number;
|
||||
roleName: string;
|
||||
orgScopeId: number;
|
||||
capabilityKey?: string;
|
||||
actions: PlatformAction[];
|
||||
status: AuthorizationStatus;
|
||||
version: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface CollectionNodeDetailVO {
|
||||
node: CollectionNodeVO;
|
||||
latestObservation?: ObservationVO;
|
||||
capabilities: CapabilityVO[];
|
||||
authorizations: AuthorizationVO[];
|
||||
}
|
||||
|
||||
export interface RoleCandidateVO {
|
||||
roleId: number;
|
||||
roleName: string;
|
||||
}
|
||||
|
||||
export interface CollectionNodePage {
|
||||
total: number;
|
||||
items: CollectionNodeVO[];
|
||||
}
|
||||
|
||||
export interface CollectionNodeQuery {
|
||||
keyword?: string;
|
||||
platformStatus?: PlatformStatus;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export interface AuthorizationCommand {
|
||||
version: number;
|
||||
roleId: number;
|
||||
orgScopeId: number;
|
||||
capabilityKey?: string;
|
||||
actions: PlatformAction[];
|
||||
status: AuthorizationStatus;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { ConstraintsCommand, CreateElementCommand, ElementDetail, ElementQuery, ElementView, NamingStandardsCommand, PageResult, ReferenceAnalysis, ReferencesCommand, ReferenceType, StatusCommand, UpdateElementCommand, WriteResult } from './types';
|
||||
const baseUrl = '/api/governance/v1/data-elements';
|
||||
const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const pageElements = (params: ElementQuery): AxiosPromise<PageResult<ElementView>> => request({ url: baseUrl, method: 'get', params });
|
||||
export const getElement = (id: number): AxiosPromise<ElementDetail> => request({ url: `${baseUrl}/${id}`, method: 'get' });
|
||||
export const pageElementReferences = (id: number, params: { targetType?: ReferenceType; pageNum: number; pageSize: number }): AxiosPromise<ReferenceAnalysis> => request({ url: `${baseUrl}/${id}/references`, method: 'get', params });
|
||||
export const createElement = (data: CreateElementCommand, key: string): AxiosPromise<WriteResult<ElementDetail>> => request({ url: baseUrl, method: 'post', data, headers: headers(key) });
|
||||
export const updateElement = (id: number, data: UpdateElementCommand, key: string): AxiosPromise<WriteResult<ElementDetail>> => request({ url: `${baseUrl}/${id}`, method: 'put', data, headers: headers(key) });
|
||||
export const changeElementStatus = (id: number, data: StatusCommand, key: string): AxiosPromise<WriteResult<ElementDetail>> => request({ url: `${baseUrl}/${id}/status`, method: 'post', data, headers: headers(key) });
|
||||
export const replaceElementConstraints = (id: number, data: ConstraintsCommand, key: string): AxiosPromise<WriteResult<ElementDetail>> => request({ url: `${baseUrl}/${id}/constraints`, method: 'put', data, headers: headers(key) });
|
||||
export const replaceElementNamingStandards = (id: number, data: NamingStandardsCommand, key: string): AxiosPromise<WriteResult<ElementDetail>> => request({ url: `${baseUrl}/${id}/naming-standards`, method: 'put', data, headers: headers(key) });
|
||||
export const replaceElementReferences = (id: number, data: ReferencesCommand, key: string): AxiosPromise<WriteResult<ElementDetail>> => request({ url: `${baseUrl}/${id}/references`, method: 'put', data, headers: headers(key) });
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { CandidateId } from '@/api/datagov/quality-rule/candidates';
|
||||
import type { ElementMappingReference, ElementMappingSelection, ElementMappingCandidate } from '@/views/datagov/governance/data-element/fieldMappingReview';
|
||||
export interface NativeMappingTable { tableId: string; label: string; fields: string[] }
|
||||
export interface NativeMappingContext {
|
||||
reference: ElementMappingReference;
|
||||
sourceId: CandidateId; sourceVersion: CandidateId; metadataRevision: CandidateId; scanJobId: string; observedAt?: string;
|
||||
objectReference: string; ownerId: CandidateId;
|
||||
element: { id: CandidateId; version: CandidateId; code: string; name: string; dataType: string; constraintsSha256: string; constraintKinds: string[] };
|
||||
fields: { name: string; dataType: string; nativeType?: string | null; length?: number | null; precision?: number | null; scale?: number | null; nullable?: boolean | null }[];
|
||||
facts: { key: string; fieldName: string; dimension: string; result: string; actual?: string | null; expected?: string | null }[];
|
||||
scopeNote: string;
|
||||
}
|
||||
export interface NativeMappingBinding { mappingId: CandidateId; tableId: string; fieldName: string; sourceVersion: CandidateId; elementVersion: CandidateId; contextSha256: string; physicalSnapshotId: CandidateId; standardSnapshotId: CandidateId }
|
||||
export interface NativeMappingDraft { requestId: string; state: string; contextSha256: string; candidates: ElementMappingCandidate[]; code: string }
|
||||
const base = '/api/governance/v1/standard-adoptions';
|
||||
export const nativeMappingTables = (keyword?: string): AxiosPromise<NativeMappingTable[]> => request({ url: `${base}/native-mapping/tables`, method: 'get', params: { keyword } });
|
||||
export const nativeMappingContext = (selection: ElementMappingSelection): AxiosPromise<NativeMappingContext> => request({ url: `${base}/native-mapping/context`, method: 'post', data: selection });
|
||||
export const nativeMappingBinding = (id: CandidateId): AxiosPromise<NativeMappingBinding> => request({ url: `${base}/${encodeURIComponent(String(id))}/native-binding`, method: 'get' });
|
||||
export const nativeMappingDraft = (requestId: string, reference: ElementMappingReference, prompt: string): AxiosPromise<NativeMappingDraft> => request({ url: '/api/integration/v1/ai/data-element-mapping', method: 'post', data: { requestId, reference, prompt } });
|
||||
@@ -0,0 +1,23 @@
|
||||
export type ElementStatus = 'ENABLED' | 'DISABLED';
|
||||
export type DataType = 'STRING' | 'INTEGER' | 'DECIMAL' | 'BOOLEAN' | 'DATE' | 'DATETIME' | 'BINARY';
|
||||
export type ConstraintType = 'ENUM' | 'RANGE' | 'REGEX' | 'DATE' | 'ADDRESS' | 'FORMAT';
|
||||
export type AddressLevel = 'COUNTRY' | 'PROVINCE' | 'CITY' | 'DISTRICT' | 'STREET';
|
||||
export type NamingObjectType = 'TABLE' | 'FIELD' | 'API' | 'FILE';
|
||||
export type Separator = 'NONE' | 'UNDERSCORE' | 'HYPHEN' | 'DOT';
|
||||
export type CaseRule = 'UPPER' | 'LOWER' | 'PRESERVE';
|
||||
export type ReferenceType = 'MODEL' | 'API' | 'METRIC' | 'ASSET';
|
||||
export interface PageResult<T> { rows: T[]; total: number }
|
||||
export interface ElementQuery { keyword?: string; status?: ElementStatus; pageNum: number; pageSize: number }
|
||||
export interface ElementView { elementId: number; elementCode: string; elementName: string; definition: string; dataType: DataType; dataLength?: number; precisionValue?: number; scaleValue?: number; measurementUnit?: string; status: ElementStatus; organizationId: number; departmentId: number; version: number; createTime: string; updateTime?: string }
|
||||
export interface ConstraintView { constraintId: number; constraintType: ConstraintType; enumValues?: string[]; minimumValue?: string; maximumValue?: string; regexPattern?: string; dateFormat?: string; addressLevel?: AddressLevel; formatCode?: string; sortOrder: number }
|
||||
export interface NamingStandardView { namingStandardId: number; objectType: NamingObjectType; prefix?: string; suffix?: string; separator: Separator; caseRule: CaseRule; template?: string; sortOrder: number }
|
||||
export interface ReferenceView { referenceId: number; targetType: ReferenceType; targetId: string; targetFqn?: string; targetDisplayName?: string; sortOrder: number }
|
||||
export interface ReferenceAnalysis { rows: ReferenceView[]; total: number; counts: Partial<Record<ReferenceType, number>>; pageNum: number; pageSize: number }
|
||||
export interface ElementDetail { element: ElementView; constraints: ConstraintView[]; namingStandards: NamingStandardView[]; references: ReferenceView[] }
|
||||
export interface CreateElementCommand { elementCode: string; elementName: string; definition: string; dataType: DataType; dataLength?: number; precisionValue?: number; scaleValue?: number; measurementUnit?: string }
|
||||
export interface UpdateElementCommand extends Omit<CreateElementCommand, 'elementCode'> { version: number }
|
||||
export interface StatusCommand { targetStatus: ElementStatus; reason: string; version: number }
|
||||
export interface ConstraintsCommand { constraints: Array<Omit<ConstraintView, 'constraintId'>>; version: number }
|
||||
export interface NamingStandardsCommand { namingStandards: Array<Omit<NamingStandardView, 'namingStandardId'>>; version: number }
|
||||
export interface ReferencesCommand { references: Array<Omit<ReferenceView, 'referenceId'>>; version: number }
|
||||
export interface WriteResult<T> { requestId: string; result: T }
|
||||
@@ -0,0 +1,85 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
CandidateSetView,
|
||||
CompensateCommand,
|
||||
CompensationView,
|
||||
DataExchangeDetail,
|
||||
DefinitionCommand,
|
||||
DefinitionView,
|
||||
EntityId,
|
||||
ExecuteCommand,
|
||||
ReadyCommand,
|
||||
ReconcileCommand,
|
||||
ReconciliationView,
|
||||
RunView,
|
||||
SourceKind,
|
||||
StatusCommand,
|
||||
WriteResult
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/dataproduct/v1/data-exchanges';
|
||||
const writeHeaders = (idempotencyKey: string) => ({ 'Idempotency-Key': idempotencyKey, repeatSubmit: false });
|
||||
|
||||
export const listDataExchanges = (): AxiosPromise<DefinitionView[]> =>
|
||||
request({ url: baseUrl, method: 'get' });
|
||||
|
||||
export const getDataExchange = (exchangeId: EntityId): AxiosPromise<DataExchangeDetail> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}`, method: 'get' });
|
||||
|
||||
export const getDataExchangeHistory = (exchangeId: EntityId): AxiosPromise<DataExchangeDetail> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}/history`, method: 'get' });
|
||||
|
||||
export const getDataExchangeCandidates = (
|
||||
sourceKind: SourceKind,
|
||||
sourceId: EntityId
|
||||
): AxiosPromise<CandidateSetView> =>
|
||||
request({ url: `${baseUrl}/source-candidates`, method: 'get', params: { sourceKind, sourceId } });
|
||||
|
||||
export const createDataExchange = (
|
||||
data: DefinitionCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<DataExchangeDetail>> =>
|
||||
request({ url: baseUrl, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateDataExchange = (
|
||||
exchangeId: EntityId,
|
||||
data: DefinitionCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<DataExchangeDetail>> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const readyDataExchange = (
|
||||
exchangeId: EntityId,
|
||||
data: ReadyCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<DataExchangeDetail['snapshots'][number]>> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}/ready`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const executeDataExchange = (
|
||||
exchangeId: EntityId,
|
||||
data: ExecuteCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<RunView>> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}/runs`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const syncDataExchangeStatus = (
|
||||
exchangeId: EntityId,
|
||||
data: StatusCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<RunView>> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}/status-syncs`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const reconcileDataExchange = (
|
||||
exchangeId: EntityId,
|
||||
data: ReconcileCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ReconciliationView>> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}/reconciliations`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const compensateDataExchange = (
|
||||
exchangeId: EntityId,
|
||||
data: CompensateCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<CompensationView>> =>
|
||||
request({ url: `${baseUrl}/${exchangeId}/compensations`, method: 'post', data, headers: writeHeaders(key) });
|
||||
@@ -0,0 +1,177 @@
|
||||
export type EntityId = string | number;
|
||||
export type SourceKind = 'DATASET' | 'API';
|
||||
export type DefinitionStatus = 'DRAFT' | 'READY';
|
||||
export type SubscriptionFrequency = 'ONCE' | 'DAILY' | 'WEEKLY' | 'MONTHLY';
|
||||
export type ExecutionState =
|
||||
| 'REQUESTED'
|
||||
| 'SUBMITTED'
|
||||
| 'RUNNING'
|
||||
| 'SUCCEEDED'
|
||||
| 'FAILED'
|
||||
| 'CANCELED'
|
||||
| 'UNKNOWN'
|
||||
| 'NOT_CONFIGURED';
|
||||
export type ReconciliationStatus = 'RECONCILED' | 'MISMATCH' | 'UNKNOWN';
|
||||
export type DeliveryStatus = 'PENDING_DELIVERY';
|
||||
export type CompensationStatus = 'REQUESTED' | 'SUBMITTED' | 'UNKNOWN' | 'NOT_CONFIGURED';
|
||||
export type CandidateState = 'CONFIGURED' | 'NOT_CONFIGURED' | string;
|
||||
|
||||
export interface DataExchangeQuery extends PageQuery {
|
||||
keyword?: string;
|
||||
sourceKind?: SourceKind;
|
||||
status?: DefinitionStatus;
|
||||
}
|
||||
|
||||
export interface CandidateView {
|
||||
candidateId: string;
|
||||
displayName: string;
|
||||
candidateType: string;
|
||||
sourceRef: string;
|
||||
sourceSha256: string;
|
||||
}
|
||||
|
||||
export interface CandidateSetView {
|
||||
state: CandidateState;
|
||||
executionCandidates: CandidateView[];
|
||||
targetCandidates: CandidateView[];
|
||||
}
|
||||
|
||||
export interface DefinitionView {
|
||||
exchangeId: EntityId;
|
||||
name: string;
|
||||
sourceKind: SourceKind;
|
||||
sourceId: EntityId;
|
||||
sourceVersion: string;
|
||||
sourceSha256: string;
|
||||
executionCandidateId: string;
|
||||
targetCandidateId: string;
|
||||
frequency: SubscriptionFrequency;
|
||||
timeZone: string;
|
||||
startsAt: string;
|
||||
endsAt?: string;
|
||||
notifyOnUpdate: boolean;
|
||||
status: DefinitionStatus;
|
||||
organizationId: EntityId;
|
||||
departmentId: EntityId;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface SnapshotView {
|
||||
snapshotId: EntityId;
|
||||
exchangeId: EntityId;
|
||||
snapshotSha256: string;
|
||||
sourceVersion: string;
|
||||
sourceSha256: string;
|
||||
payloadJson: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface RunView {
|
||||
runId: EntityId;
|
||||
exchangeId: EntityId;
|
||||
snapshotId: EntityId;
|
||||
requestId: string;
|
||||
state: ExecutionState;
|
||||
externalId?: string;
|
||||
externalBatchId?: string;
|
||||
sourceStatus?: string;
|
||||
evidenceRef?: string;
|
||||
evidenceSha256?: string;
|
||||
executionSourceSha256?: string;
|
||||
observedAt?: string;
|
||||
outcomeCode?: string;
|
||||
outcomeSummary?: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface ReconciliationView {
|
||||
reconciliationId: EntityId;
|
||||
exchangeId: EntityId;
|
||||
runId: EntityId;
|
||||
snapshotId: EntityId;
|
||||
status: ReconciliationStatus;
|
||||
batchId?: string;
|
||||
sourceRowCount?: number;
|
||||
targetRowCount?: number;
|
||||
checksumAlgorithm?: string;
|
||||
sourceChecksum?: string;
|
||||
targetChecksum?: string;
|
||||
receiptRef?: string;
|
||||
receiptSha256?: string;
|
||||
observedAt?: string;
|
||||
sourceSha256?: string;
|
||||
reliable: boolean;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface CompensationView {
|
||||
compensationId: EntityId;
|
||||
exchangeId: EntityId;
|
||||
originalRunId: EntityId;
|
||||
reconciliationId?: EntityId;
|
||||
status: CompensationStatus;
|
||||
externalId?: string;
|
||||
outcomeCode?: string;
|
||||
outcomeSummary?: string;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface NotificationView {
|
||||
notificationId: EntityId;
|
||||
exchangeId: EntityId;
|
||||
snapshotId: EntityId;
|
||||
status: DeliveryStatus;
|
||||
actorId: EntityId;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface DataExchangeDetail {
|
||||
definition: DefinitionView;
|
||||
snapshots: SnapshotView[];
|
||||
runs: RunView[];
|
||||
reconciliations: ReconciliationView[];
|
||||
compensations: CompensationView[];
|
||||
notifications: NotificationView[];
|
||||
trajectoryActions: string[];
|
||||
}
|
||||
|
||||
export interface DefinitionCommand {
|
||||
name: string;
|
||||
sourceKind: SourceKind;
|
||||
sourceId: EntityId;
|
||||
executionCandidateId: string;
|
||||
targetCandidateId: string;
|
||||
frequency: SubscriptionFrequency;
|
||||
timeZone: string;
|
||||
startsAt: string;
|
||||
endsAt?: string;
|
||||
notifyOnUpdate: boolean;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface ReadyCommand { version: number }
|
||||
export interface ExecuteCommand { reason: string; version: number }
|
||||
export interface StatusCommand { runId: EntityId; reason: string; version: number }
|
||||
export interface ReconcileCommand { runId: EntityId; reason: string; version: number }
|
||||
export interface CompensateCommand {
|
||||
runId: EntityId;
|
||||
reconciliationId?: EntityId;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
export interface WriteResult<T> { requestId: string; result: T }
|
||||
|
||||
export interface SourceOption {
|
||||
key: string;
|
||||
sourceKind: SourceKind;
|
||||
sourceId: EntityId;
|
||||
label: string;
|
||||
status: string;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface SourceCandidate { id: number; name: string; type: string }
|
||||
export interface TargetCandidate { snapshotId: number; catalog: string; schema: string; table: string; observedAt: string }
|
||||
export interface FieldCandidate { name: string; dataType: string }
|
||||
export interface PhysicalTargetCandidate { reference: string; sourceId: number; sourceVersion: number; catalog: string; schema: string; table: string; observedAt: string; fields: PhysicalFieldCandidate[] }
|
||||
export interface PhysicalFieldCandidate { name: string; dataType: string }
|
||||
const base = '/api/governance/v1/data-profiles/candidates';
|
||||
export const sourceCandidates = (): AxiosPromise<SourceCandidate[]> => request({ url: `${base}/sources`, method: 'get' });
|
||||
export const targetCandidates = (sourceId: number): AxiosPromise<TargetCandidate[]> => request({ url: `${base}/targets`, method: 'get', params: { sourceId } });
|
||||
export const fieldCandidates = (sourceId: number, snapshotId: number): AxiosPromise<FieldCandidate[]> => request({ url: `${base}/fields`, method: 'get', params: { sourceId, snapshotId } });
|
||||
export const physicalTargetCandidates = (sourceId: number): AxiosPromise<PhysicalTargetCandidate[]> => request({ url: `${base}/physical-targets`, method: 'get', params: { sourceId, pageNum: 1, pageSize: 100 } });
|
||||
export const physicalFieldCandidates = (sourceId: number, reference: string, sourceVersion: number): AxiosPromise<PhysicalFieldCandidate[]> => request({ url: `${base}/physical-fields`, method: 'get', params: { sourceId, reference, sourceVersion } });
|
||||
|
||||
// Dedicated display pages; all legacy candidates and execution contracts above stay unchanged.
|
||||
export interface BrowseSource extends SourceCandidate { version: number; status: string }
|
||||
export interface BrowseObject { catalog: string; schema: string | null; name: string; kind: 'CATALOG' | 'SCHEMA' | 'TABLE' | 'VIEW' }
|
||||
export interface BrowsePage<T> { rows: T[]; nextCursor: string | null; hasMore: boolean; observedAt: string }
|
||||
export interface BrowseObjectPage extends BrowsePage<BrowseObject> { sourceId: number; sourceVersion: number }
|
||||
export interface BrowseObjectQuery { sourceId: number; sourceVersion: number; level: 'CATALOG' | 'SCHEMA' | 'TABLE'; catalog?: string; schema?: string; keyword?: string; cursor?: string; pageSize: number }
|
||||
const browse = '/api/governance/v1/data-profiles/browse';
|
||||
export const browseProfileSources = (params: { keyword?: string; cursor?: string; pageSize: number }): AxiosPromise<BrowsePage<BrowseSource>> => request({ url: `${browse}/sources`, method: 'get', params });
|
||||
export const browseProfileObjects = (params: BrowseObjectQuery): AxiosPromise<BrowseObjectPage> => request({ url: `${browse}/objects`, method: 'get', params });
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { CandidateId } from '@/api/datagov/quality-rule/candidates';
|
||||
import request from '@/utils/request';
|
||||
export interface ProfileEvidenceSelection { snapshotId: CandidateId; columns: string[] }
|
||||
export interface ProfileEvidenceColumn { key: string; name: string; dataType: string; nullCount: string; nullRate: string; distinctCount: string; distinctRate: string }
|
||||
export interface ProfileEvidenceContext { selection: ProfileEvidenceSelection; rowCount: string; observedAt: string; sourceLabel: string; observationScope: string; columns: ProfileEvidenceColumn[]; contextSha256: string }
|
||||
export interface ProfileEvidenceResult { requestId: string; state: string; answer?: string; code?: string; findings: Array<{ columnKey: string; explanation: string; reviewHint: string }> }
|
||||
export const readProfileEvidence = (data: ProfileEvidenceSelection, signal?: AbortSignal): AxiosPromise<ProfileEvidenceContext> => request({ url: '/api/governance/v1/data-profiles/evidence', method: 'post', data, signal });
|
||||
export const explainProfileEvidence = (data: { requestId: string; selection: ProfileEvidenceSelection; contextSha256: string; prompt: string }, signal?: AbortSignal): AxiosPromise<ProfileEvidenceResult> => request({ url: '/api/integration/v1/ai/profile-evidence', method: 'post', data, signal });
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { PageResult } from '@/api/types';
|
||||
import request from '@/utils/request';
|
||||
import type { ProfileCommand, ProfileDetail, ProfileExecution, ProfileQuery, ProfileRequest } from './types';
|
||||
const base = '/api/governance/v1/data-profiles';
|
||||
const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const pageProfiles = (params: ProfileQuery): AxiosPromise<PageResult<ProfileRequest>> => request({ url: base, method: 'get', params });
|
||||
export const getProfile = (id: string | number): AxiosPromise<ProfileDetail> => request({ url: `${base}/${id}`, method: 'get' });
|
||||
export const runProfile = (data: ProfileCommand, key: string): AxiosPromise<ProfileExecution> => request({ url: base, method: 'post', data, headers: headers(key) });
|
||||
export const retryProfile = (id: number): AxiosPromise<ProfileExecution> => request({ url: `${base}/${id}/retry`, method: 'post' });
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { ProfileRuleReference, ProfileRuleSeed } from '@/views/datagov/governance/data-profile/profileRuleSeed';
|
||||
|
||||
export const readProfileRuleSeed = (data: ProfileRuleReference, signal?: AbortSignal): AxiosPromise<ProfileRuleSeed> => request({
|
||||
url: '/api/governance/v1/data-profiles/rule-seed', method: 'post', data, signal, suppressErrorToast: true
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
export type ProfileStatus = 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'UNKNOWN';
|
||||
export type ProfileNumeric = number | string;
|
||||
export interface ProfileQuery extends PageQuery { status?: ProfileStatus }
|
||||
export interface ProfileCommand { dataSourceId: number; catalog: string; schema: string; table: string; columns: string[]; physicalReference: string; physicalSourceVersion: number }
|
||||
export interface ProfileHistogramBin { lower: string; upper: string; upperInclusive: boolean; count: ProfileNumeric }
|
||||
export interface NumericDistribution {
|
||||
version: number; status: 'AVAILABLE' | 'NO_VALID_NUMERIC'; samplingMethod: 'LIMIT_UNORDERED'; sampleLimit: number;
|
||||
sampleCount: ProfileNumeric; validCount: ProfileNumeric; nullCount: ProfileNumeric; invalidCount: ProfileNumeric;
|
||||
histogramMethod: 'EQUAL_WIDTH_10'; bins: ProfileHistogramBin[];
|
||||
minimum: string | null; maximum: string | null; q1: string | null; median: string | null; q3: string | null;
|
||||
lowerWhisker: string | null; upperWhisker: string | null; lowerOutlierCount: ProfileNumeric; upperOutlierCount: ProfileNumeric;
|
||||
quantileMethod: 'TYPE_7_LINEAR'; whiskerMethod: 'OBSERVED_WITHIN_1_5_IQR';
|
||||
}
|
||||
export interface ColumnProfile { column: string; dataType: string; nullCount: ProfileNumeric; nullRate: ProfileNumeric; distinctCount: ProfileNumeric; distinctRate: ProfileNumeric; minimum?: string; maximum?: string; average?: ProfileNumeric; standardDeviation?: ProfileNumeric; topValues: Array<{ value: string; count: ProfileNumeric }>; patterns: Array<{ pattern: string; count: ProfileNumeric }>; numericDistribution?: NumericDistribution | null }
|
||||
export interface ProfileRequest { requestId: number; dataSourceId: number; catalog: string; schema: string; table: string; columns: string[]; status: ProfileStatus; latestAttemptNo: number; errorCode?: string; errorSummary?: string; createTime?: string; updateTime?: string; physicalReference?: string; physicalSourceVersion?: number }
|
||||
export interface ProfileDetail { request: ProfileRequest; attempts: Array<{ attemptId: number; attemptNo: number; status: ProfileStatus; errorCode?: string; errorSummary?: string; startedAt?: string; completedAt?: string }>; snapshot?: { snapshotId: number; requestId: number; attemptId: number; rowCount: ProfileNumeric; columns: ColumnProfile[]; observedAt?: string; createTime?: string } }
|
||||
export interface ProfileExecution { requestToken: string; replayed: boolean; detail: ProfileDetail }
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export interface MaskingPlan {
|
||||
planId: string;
|
||||
name: string;
|
||||
version: string;
|
||||
snapshotSha256: string;
|
||||
status: 'DRAFT' | 'ACTIVE';
|
||||
sourceTableFileId: string;
|
||||
sourceTableName: string;
|
||||
outputTableFileId: string;
|
||||
outputTableName: string;
|
||||
}
|
||||
export interface MaskingDraftCommand { policyVersion: number; name: string; sourceTableFileId: string; outputTableFileId: string }
|
||||
const base = (policyId: string) => `/api/governance/v1/data-protections/policies/${policyId}`;
|
||||
export const listMaskingPlans = (policyId: string): AxiosPromise<MaskingPlan[]> => request({ url: `${base(policyId)}/batch-candidates`, method: 'get' });
|
||||
export const createMaskingPlan = (policyId: string, data: MaskingDraftCommand, key: string): AxiosPromise<MaskingPlan> =>
|
||||
request({ url: `${base(policyId)}/batch-plans`, method: 'post', data, headers: { 'Idempotency-Key': key, repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const readMaskingPlanRequest = (policyId: string, key: string): AxiosPromise<MaskingPlan | null> =>
|
||||
request({ url: `${base(policyId)}/batch-plans/requests/${encodeURIComponent(key)}`, method: 'get' });
|
||||
@@ -0,0 +1,104 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
BindFileCommand,
|
||||
CreateExportCommand,
|
||||
CreatePolicyCommand,
|
||||
EntityId,
|
||||
ExportVO,
|
||||
PolicyStatusCommand,
|
||||
PolicyVO,
|
||||
TrailVO,
|
||||
UpdatePolicyCommand,
|
||||
VerificationCommand,
|
||||
VerificationVO,
|
||||
WriteResult
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/governance/v1/data-protections';
|
||||
const writeHeaders = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
type RequestOptions = { suppressErrorToast?: boolean };
|
||||
|
||||
export const listDataProtectionPolicies = (options: RequestOptions = {}): AxiosPromise<PolicyVO[]> =>
|
||||
request({ ...options, url: `${baseUrl}/policies`, method: 'get' });
|
||||
|
||||
export const getDataProtectionPolicy = (policyId: EntityId, options: RequestOptions = {}): AxiosPromise<PolicyVO> =>
|
||||
request({ ...options, url: `${baseUrl}/policies/${policyId}`, method: 'get' });
|
||||
|
||||
export const createDataProtectionPolicy = (
|
||||
data: CreatePolicyCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/policies`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateDataProtectionPolicy = (
|
||||
policyId: EntityId,
|
||||
data: UpdatePolicyCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/policies/${policyId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const deleteDataProtectionPolicy = (policyId: EntityId, version: number, key: string, options: RequestOptions = {}): AxiosPromise<void> =>
|
||||
request({ ...options, url: `${baseUrl}/policies/${policyId}`, method: 'delete', params: { version }, headers: writeHeaders(key) });
|
||||
|
||||
export const changeDataProtectionPolicyStatus = (
|
||||
policyId: EntityId,
|
||||
data: PolicyStatusCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/policies/${policyId}/status`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const registerDataProtectionVerification = (
|
||||
policyId: EntityId,
|
||||
data: VerificationCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<VerificationVO>> =>
|
||||
request({
|
||||
url: `${baseUrl}/policies/${policyId}/verifications`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(key)
|
||||
});
|
||||
|
||||
export const getDataProtectionVerification = (
|
||||
policyId: EntityId,
|
||||
verificationId: EntityId,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<VerificationVO> =>
|
||||
request({ ...options, url: `${baseUrl}/policies/${policyId}/verifications/${verificationId}`, method: 'get' });
|
||||
|
||||
export const createDataProtectionExport = (
|
||||
data: CreateExportCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ExportVO>> =>
|
||||
request({ url: `${baseUrl}/exports`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const getDataProtectionExport = (exportId: EntityId, options: RequestOptions = {}): AxiosPromise<ExportVO> =>
|
||||
request({ ...options, url: `${baseUrl}/exports/${exportId}`, method: 'get' });
|
||||
|
||||
export const bindDataProtectionFileReference = (
|
||||
exportId: EntityId,
|
||||
data: BindFileCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<ExportVO>> =>
|
||||
request({
|
||||
url: `${baseUrl}/exports/${exportId}/file-reference`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(key)
|
||||
});
|
||||
|
||||
export const listDataProtectionHistory = (options: RequestOptions = {}): AxiosPromise<TrailVO[]> =>
|
||||
request({ ...options, url: `${baseUrl}/history`, method: 'get' });
|
||||
|
||||
export const listDataProtectionVerifications = (policyId: EntityId, options: RequestOptions = {}): AxiosPromise<VerificationVO[]> =>
|
||||
request({ ...options, url: `${baseUrl}/policies/${policyId}/verifications`, method: 'get' });
|
||||
|
||||
export const listDataProtectionExports = (policyId: EntityId, options: RequestOptions = {}): AxiosPromise<ExportVO[]> =>
|
||||
request({ ...options, url: `${baseUrl}/policies/${policyId}/exports`, method: 'get' });
|
||||
|
||||
export const searchDataProtectionSources = (keyword?: string, options: RequestOptions = {}): AxiosPromise<import('../access-control/types').SecuritySourceCandidate[]> =>
|
||||
request({ ...options, url: `${baseUrl}/source-candidates`, method: 'get', params: { keyword } });
|
||||
@@ -0,0 +1,131 @@
|
||||
export type PolicyStatus = 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'ARCHIVED';
|
||||
export type ExecutionStatus = 'REGISTERED' | 'NOT_ENFORCED' | 'ENFORCED' | 'UNSUPPORTED';
|
||||
export type StrategyType = 'MASK' | 'REPLACE' | 'GENERALIZE' | 'PERTURB' | 'PRESERVE_FORMAT';
|
||||
export type ProtectionTarget = 'PLATFORM_DTO' | 'AIXUN_EXPORT' | 'HIVE_MASKING' | 'DORIS_MASKING';
|
||||
export type EvidenceKind = 'DISPATCH' | 'READBACK' | 'ALLOW' | 'DENY';
|
||||
export type EvidenceOutcome = 'DISPATCHED' | 'MATCHED' | 'ALLOWED' | 'DENIED';
|
||||
export type DownloadSubjectType = 'USER' | 'ROLE' | 'DEPARTMENT';
|
||||
export type ExportStatus = 'FILE_PENDING' | 'DOWNLOAD_READY' | 'EXPIRED';
|
||||
export type EntityId = string;
|
||||
|
||||
export interface StrategyConfig {
|
||||
prefixKeep?: number;
|
||||
suffixKeep?: number;
|
||||
replacement?: string;
|
||||
generalizationLevel?: number;
|
||||
perturbationPercent?: number;
|
||||
maskCharacter?: string;
|
||||
}
|
||||
|
||||
export interface CreatePolicyCommand {
|
||||
policyCode: string;
|
||||
policyName: string;
|
||||
strategyType: StrategyType;
|
||||
strategyConfig: StrategyConfig;
|
||||
protectionTarget: ProtectionTarget;
|
||||
resourceRef: string;
|
||||
fieldRefs: string[];
|
||||
}
|
||||
|
||||
export interface UpdatePolicyCommand extends Omit<CreatePolicyCommand, 'policyCode'> {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PolicyStatusCommand {
|
||||
targetStatus: PolicyStatus;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface EnforcementEvidence {
|
||||
kind: EvidenceKind;
|
||||
outcome: EvidenceOutcome;
|
||||
evidenceRef: string;
|
||||
externalPolicyRef: string;
|
||||
observedAt: string;
|
||||
reliable: boolean;
|
||||
snapshotSha256: string;
|
||||
}
|
||||
|
||||
export interface VerificationCommand {
|
||||
policyVersion: number;
|
||||
evidence: EnforcementEvidence[];
|
||||
}
|
||||
|
||||
export interface FieldTreatment {
|
||||
fieldRef: string;
|
||||
strategyType: StrategyType;
|
||||
strategyConfig: StrategyConfig;
|
||||
}
|
||||
|
||||
export interface DownloadSubject {
|
||||
subjectType: DownloadSubjectType;
|
||||
subjectRef: string;
|
||||
}
|
||||
|
||||
export interface CreateExportCommand {
|
||||
resourceRef: string;
|
||||
requestedRows: number;
|
||||
maximumRows: number;
|
||||
fieldTreatments: FieldTreatment[];
|
||||
fileTtlMinutes: number;
|
||||
downloadSubjects: DownloadSubject[];
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface BindFileCommand {
|
||||
fileRef: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PolicyVO extends CreatePolicyCommand {
|
||||
policyId: EntityId;
|
||||
policyStatus: PolicyStatus;
|
||||
executionStatus: ExecutionStatus;
|
||||
executionReason?: string;
|
||||
organizationId: EntityId;
|
||||
departmentId: EntityId;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface VerificationVO {
|
||||
verificationId: EntityId;
|
||||
policyId: EntityId;
|
||||
policyVersion: number;
|
||||
executionStatus: ExecutionStatus;
|
||||
reasonCode?: string;
|
||||
snapshotSha256?: string;
|
||||
evidence: EnforcementEvidence[];
|
||||
verifiedAt?: string;
|
||||
}
|
||||
|
||||
export interface ExportVO extends CreateExportCommand {
|
||||
exportId: EntityId;
|
||||
decisionSha256: string;
|
||||
status: ExportStatus;
|
||||
fileRef?: string;
|
||||
expiresAt?: string;
|
||||
organizationId: EntityId;
|
||||
departmentId: EntityId;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface TrailVO {
|
||||
trailId: EntityId;
|
||||
objectType: string;
|
||||
objectId: EntityId;
|
||||
actionType: string;
|
||||
requestId: string;
|
||||
beforeStatus?: string;
|
||||
afterStatus?: string;
|
||||
summary?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface WriteResult<T> {
|
||||
requestId: string;
|
||||
result: T;
|
||||
}
|
||||
某些文件未显示,因为此 diff 中更改的文件太多 显示更多
在新工单中引用
屏蔽一个用户