feat(schema): Phase 1 schema templates + Nexus DevOps runbook
## AI Schema Assist Phase 1 (steps 1-2)
Approach A core (templates only, no LLM) — admin начинает создание нового
справочника с curated skeleton вместо пустого Monaco. Approach C (per-field
LLM suggest) — Phase 2 на этом фундаменте.
### Backend
- `templates/*.template.json` в ordinis-cuod-bundle resources — 6 шаблонов
(blank/spacecraft/ground-station/antenna/frequency-band/operator)
- `SchemaTemplateRegistry` (rest-api) — classpath scan at startup, strip
x-template-* metadata, expose canonical JSON Schema
- `SchemaTemplatesController` — GET /api/v1/dictionaries/templates (list)
+ /{id} (detail с schemaJson)
- Cross-bundle support: scanner matches classpath*:templates/*.template.json
— другие bundles могут shippит свои templates через те же conventions
### Frontend
- types: SchemaTemplateSummary + SchemaTemplateDetail
- queries: schemaTemplatesQuery + lazy detail query
- TemplatePicker.tsx — grid of cards (icon + name + description + tags),
click → fetch detail → fire onPick(detail)
- Integrated в DictionaryEditorDialog (create mode, properties.length===0
visible — после первой property picker исчезает чтобы не перезатереть)
## Nexus DevOps handoff
`docs-internal/ops/nexus-alpine-mirror.md` — runbook про APKINDEX vs file
inventory drift на v3.23 mirror. Includes:
- Verification commands
- 3 fix options (invalidate cache / scheduled refresh / self-host)
- Prometheus alert proposal
- Current workaround (node:22-alpine3.20 pin) reference
Active issue paired с CI saga !227/!229/!230 — нужен DevOps action.
This commit is contained in:
@@ -19,6 +19,7 @@ import { useCreateDictionary, useUpdateDictionary } from '@/api/mutations'
|
||||
import { dictionaryDetailQuery, useDictionaries } from '@/api/queries'
|
||||
import type { CreateDictionaryRequest, DataScope, DictionaryDetail } from '@/api/client'
|
||||
import { SchemaBuilder } from './SchemaBuilder'
|
||||
import { TemplatePicker } from './TemplatePicker'
|
||||
import { EventsPreviewTab } from './EventsPreviewTab'
|
||||
import { CreateSchemaDraftModal } from '@/components/workflow/CreateSchemaDraftModal'
|
||||
import {
|
||||
@@ -420,6 +421,23 @@ export const DictionaryEditorDialog = ({ open, mode, onClose, onSuccess }: Props
|
||||
</div>
|
||||
|
||||
<div className={activeTab === 'schema' ? 'block' : 'hidden'}>
|
||||
{/* AI Schema Assist Phase 1: template picker visible только в create-mode
|
||||
* И только пока пользователь не начал заполнять properties (чтобы не
|
||||
* перезатереть его работу одним кликом). После первой property —
|
||||
* picker исчезает (можно reset через template via existing dict templ
|
||||
* UI выше или вручную clear). */}
|
||||
{!isEdit && properties.length === 0 && (
|
||||
<div className="mb-4">
|
||||
<TemplatePicker
|
||||
disabled={loadingTemplate || createMut.isPending}
|
||||
onPick={(template) => {
|
||||
const tplParsed = parseSchemaJson(template.schemaJson)
|
||||
setProperties(tplParsed.properties)
|
||||
setIdSource(tplParsed.idSource ?? '')
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<SchemaBuilder properties={properties} onChange={setProperties} />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
BroadcastIcon,
|
||||
BuildingsIcon,
|
||||
FileDashedIcon,
|
||||
RocketIcon,
|
||||
WaveformIcon,
|
||||
WifiHighIcon,
|
||||
type Icon,
|
||||
} from '@phosphor-icons/react'
|
||||
import { LoadingBlock } from '@/ui'
|
||||
import {
|
||||
schemaTemplateDetailQuery,
|
||||
useSchemaTemplates,
|
||||
} from '@/api/queries'
|
||||
import type { SchemaTemplateDetail, SchemaTemplateSummary } from '@/api/client'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
/**
|
||||
* AI Schema Assist Phase 1 step 2 — curated template chooser.
|
||||
*
|
||||
* <p>Render'ит grid of template cards. Click card → fetch full schema lazy →
|
||||
* fire {@code onPick(detail)}. Caller (DictionaryEditorDialog) применяет
|
||||
* schemaJson через parseSchemaJson + setProperties.
|
||||
*
|
||||
* <p>Approach A (templates only) — works без LLM. Approach C upgrade
|
||||
* (per-field AI suggest) — Phase 2, отдельный UI elsewhere.
|
||||
*
|
||||
* <p>Icon name из template metadata → resolved через {@link ICON_MAP}.
|
||||
* Unknown icon → FileBlankIcon fallback.
|
||||
*/
|
||||
|
||||
const ICON_MAP: Record<string, Icon> = {
|
||||
// Template metadata icons mapped к phosphor-icons available в bundle.
|
||||
// SatelliteIcon отсутствует в @phosphor-icons/react@2.1.10 → RocketIcon
|
||||
// используется как proxy для space-domain templates.
|
||||
SatelliteIcon: RocketIcon,
|
||||
RocketIcon,
|
||||
BroadcastIcon,
|
||||
WifiHighIcon,
|
||||
WaveformIcon,
|
||||
BuildingsIcon,
|
||||
FileBlankIcon: FileDashedIcon,
|
||||
FileDashedIcon,
|
||||
}
|
||||
|
||||
const resolveIcon = (name: string | null): Icon => {
|
||||
if (!name) return FileDashedIcon
|
||||
return ICON_MAP[name] ?? FileDashedIcon
|
||||
}
|
||||
|
||||
type Props = {
|
||||
/** Called когда юзер выбрал template — caller получает full detail с schemaJson. */
|
||||
onPick: (template: SchemaTemplateDetail) => void
|
||||
/** Disable picker когда parent занят (mutation в полёте). */
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
export function TemplatePicker({ onPick, disabled }: Props) {
|
||||
const { t } = useTranslation()
|
||||
const queryClient = useQueryClient()
|
||||
const { data: templates, isLoading, isError } = useSchemaTemplates()
|
||||
|
||||
const handlePick = async (template: SchemaTemplateSummary) => {
|
||||
if (disabled) return
|
||||
try {
|
||||
const detail = await queryClient.fetchQuery(
|
||||
schemaTemplateDetailQuery(template.id),
|
||||
)
|
||||
onPick(detail)
|
||||
} catch {
|
||||
// Quiet fail — caller ничего не получает, юзер видит no change.
|
||||
// Real error случится только если template исчез между list и detail
|
||||
// fetch (deploy в гонке). Caller справится через retry.
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoading) return <LoadingBlock size="sm" label={t('loading')} />
|
||||
if (isError || !templates || templates.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-cap text-mute uppercase tracking-wider">
|
||||
{t('schemaTemplates.label', { defaultValue: 'Начать с шаблона' })}
|
||||
</div>
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 gap-2">
|
||||
{templates.map((template) => {
|
||||
const IconComp = resolveIcon(template.icon)
|
||||
return (
|
||||
<button
|
||||
key={template.id}
|
||||
type="button"
|
||||
onClick={() => void handlePick(template)}
|
||||
disabled={disabled}
|
||||
title={template.description}
|
||||
className={cn(
|
||||
'flex flex-col items-start gap-1 p-3 rounded-md border border-line bg-surface',
|
||||
'hover:border-line-2 hover:bg-surface-2 transition-colors text-left',
|
||||
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||
disabled && 'opacity-50 cursor-not-allowed hover:bg-surface hover:border-line',
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-2 w-full">
|
||||
<IconComp size={18} weight="regular" className="shrink-0 text-accent" />
|
||||
<span className="text-body font-semibold text-ink truncate">
|
||||
{template.name}
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-cell text-ink-2 line-clamp-2">
|
||||
{template.description}
|
||||
</span>
|
||||
{template.tags.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1 mt-0.5">
|
||||
{template.tags.slice(0, 3).map((tag) => (
|
||||
<span
|
||||
key={tag}
|
||||
className="text-[10px] text-mute uppercase tracking-wider"
|
||||
>
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div className="text-cell text-mute">
|
||||
{t('schemaTemplates.hint', {
|
||||
defaultValue: 'Шаблон загрузит начальные поля. Дополни их вручную.',
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user