Skip to main content

platform_admin_data/
dto.rs

1//! Generic container DTOs for schema-admin endpoints. The record shape is
2//! `serde_json::Value` because the renderer is generic across arbitrary modules.
3
4use platform_core::{StoryDisplayDescriptor, StoryDisplaySource};
5use platform_module::{
6    AdminSchema, AdminSurface, ConsoleContribution, ConsoleSlot, ConsoleSurface, EventSurface,
7    LifecycleSurface, ModuleHttpRoute, ModuleManifestLint, ModuleSource, RuntimeSurface,
8};
9use serde::{Deserialize, Serialize};
10use utoipa::ToSchema;
11
12/// Response for `GET /admin/data/schema`: every admin-capable module's schema.
13#[derive(Debug, Serialize, ToSchema)]
14pub struct AdminSchemaListResponse {
15    pub modules: Vec<AdminModuleSchema>,
16}
17
18/// Response for `POST /admin/data/schema/refresh`.
19#[derive(Debug, Serialize, ToSchema)]
20pub struct AdminSchemaRefreshResponse {
21    pub modules: Vec<AdminModuleSchema>,
22}
23
24/// Response for `GET /admin/data/modules`: every registered module's metadata,
25/// including modules without admin surfaces.
26#[derive(Debug, Serialize, ToSchema)]
27pub struct AdminModuleMetadataListResponse {
28    pub modules: Vec<AdminModuleMetadataDto>,
29    pub refreshed_at: Option<String>,
30    pub refresh_error: Option<String>,
31    pub refresh_history: Vec<AdminModuleRefreshRecordDto>,
32}
33
34/// Response for `GET /admin/data/available-modules`: a read-only list of
35/// catalog entries that can be installed from their manifest URL.
36#[derive(Debug, Serialize, ToSchema)]
37pub struct AdminModuleRegistrySnapshotResponse {
38    pub version: u8,
39    pub status: AdminModuleRegistrySnapshotStatus,
40    pub catalog: AdminModuleRegistrySnapshotCatalogDto,
41    pub issues: Vec<AdminModuleRegistrySnapshotIssueDto>,
42    pub modules: Vec<AdminModuleRegistrySnapshotModuleDto>,
43}
44
45#[derive(Debug, Serialize, ToSchema)]
46#[serde(rename_all = "snake_case")]
47pub enum AdminModuleRegistrySnapshotStatus {
48    Passed,
49    Failed,
50}
51
52#[derive(Debug, Serialize, ToSchema)]
53#[serde(rename_all = "camelCase")]
54pub struct AdminModuleRegistrySnapshotCatalogDto {
55    pub modules: usize,
56    pub registry_file: String,
57    pub version: u8,
58}
59
60#[derive(Debug, Serialize, ToSchema)]
61pub struct AdminModuleRegistrySnapshotIssueDto {
62    pub group: String,
63    pub message: String,
64    pub fix: String,
65}
66
67#[derive(Debug, Serialize, ToSchema)]
68#[serde(rename_all = "camelCase")]
69pub struct AdminModuleRegistrySnapshotModuleDto {
70    pub name: String,
71    pub source: ModuleSource,
72    pub catalog_version: String,
73    pub manifest_reference: String,
74    #[serde(default, rename = "providedBy")]
75    pub provided_by: Option<String>,
76    #[serde(default, rename = "serviceManifest")]
77    pub service_manifest: Option<String>,
78    #[serde(default, rename = "moduleRelease")]
79    pub module_release: Option<AdminModuleReleaseDto>,
80    pub summary: Option<String>,
81    pub base_url: Option<String>,
82    pub capabilities: Vec<String>,
83    pub console_package_hints: usize,
84    pub compatibility: Option<AdminModuleCompatibilityDto>,
85    pub host_compatibility: AdminModuleHostCompatibilityDto,
86    pub archived_at: Option<String>,
87    pub archive_reason: Option<String>,
88    pub manifest_name: Option<String>,
89    pub manifest_status: AdminModuleRegistrySnapshotManifestStatus,
90    pub manifest_version: Option<String>,
91    pub install_state: AdminModuleInstallStateDto,
92    pub status: AdminModuleRegistrySnapshotModuleStatus,
93}
94
95#[derive(Debug, Serialize, ToSchema)]
96#[serde(rename_all = "camelCase")]
97pub struct AdminModuleInstallStateDto {
98    pub module_registered: bool,
99    pub linked_source: Option<AdminModuleLinkedSourceInstallStateDto>,
100    pub remote_source: Option<AdminModuleRemoteSourceInstallStateDto>,
101    pub console_plan: AdminModuleConsolePackagePlanStateDto,
102}
103
104#[derive(Debug, Clone, Serialize, ToSchema)]
105#[serde(rename_all = "camelCase")]
106pub struct AdminModuleReleaseDto {
107    pub manifest_reference: String,
108    pub name: Option<String>,
109    pub version: Option<String>,
110    pub source: Option<String>,
111    pub provider_name: Option<String>,
112    pub service_package: Option<String>,
113    pub service_manifest: Option<String>,
114}
115
116#[derive(Debug, Serialize, ToSchema)]
117#[serde(rename_all = "camelCase")]
118pub struct AdminServiceModuleLifecycleResponse {
119    pub version: u8,
120    pub status: AdminServiceModuleLifecycleStatus,
121    pub modules: Vec<AdminServiceModuleLifecycleModuleDto>,
122}
123
124#[derive(Debug, Serialize, ToSchema)]
125#[serde(rename_all = "camelCase")]
126pub struct AdminServiceSystemResponse {
127    pub version: u8,
128    pub status: AdminServiceSystemStatus,
129    pub system_file: String,
130    pub name: Option<String>,
131    pub environments: Vec<String>,
132    pub services: Vec<AdminServiceSystemServiceDto>,
133    pub modules: Vec<AdminServiceSystemModuleDto>,
134    pub dependencies: Vec<AdminServiceSystemDependencyDto>,
135    pub issues: Vec<AdminServiceSystemIssueDto>,
136    pub protocol_version: Option<String>,
137    pub semantic_kind: Option<String>,
138    pub nodes: Vec<AdminServiceSystemNodeDto>,
139    pub relationships: Vec<AdminServiceSystemRelationshipDto>,
140    pub compatibility_results: Vec<AdminContractCompatibilityResultDto>,
141}
142
143#[derive(Debug, Serialize, ToSchema)]
144#[serde(rename_all = "camelCase")]
145pub struct AdminServiceSystemNodeDto {
146    pub id: String,
147    pub kind: String,
148    pub owner: Option<String>,
149}
150
151#[derive(Debug, Serialize, ToSchema)]
152#[serde(rename_all = "camelCase")]
153pub struct AdminServiceSystemRelationshipDto {
154    pub kind: String,
155    pub from: String,
156    pub to: String,
157    pub contract_id: Option<String>,
158    pub contract_version: Option<String>,
159}
160
161#[derive(Debug, Serialize, ToSchema)]
162#[serde(rename_all = "camelCase")]
163pub struct AdminContractCompatibilityResultDto {
164    pub category: String,
165    pub contract_kind: String,
166    pub contract_id: String,
167    pub changed_version: String,
168    pub affected_references: Vec<String>,
169    pub reasons: Vec<AdminContractCompatibilityReasonDto>,
170}
171
172#[derive(Debug, Serialize, ToSchema)]
173#[serde(rename_all = "camelCase")]
174pub struct AdminContractCompatibilityReasonDto {
175    pub code: String,
176    pub path: String,
177    pub message: String,
178    pub next_action: String,
179}
180
181#[derive(Debug, Serialize, ToSchema)]
182#[serde(rename_all = "snake_case")]
183pub enum AdminServiceSystemStatus {
184    Ready,
185    NeedsAttention,
186    Empty,
187}
188
189#[derive(Debug, Serialize, ToSchema)]
190#[serde(rename_all = "camelCase")]
191pub struct AdminServiceSystemServiceDto {
192    pub name: String,
193    pub target: String,
194    pub modules: Vec<String>,
195}
196
197#[derive(Debug, Serialize, ToSchema)]
198#[serde(rename_all = "camelCase")]
199pub struct AdminServiceSystemModuleDto {
200    pub name: String,
201    pub owner: String,
202    pub capabilities: Vec<String>,
203    pub dependencies: Vec<String>,
204}
205
206#[derive(Debug, Serialize, ToSchema)]
207#[serde(rename_all = "camelCase")]
208pub struct AdminServiceSystemDependencyDto {
209    pub from: String,
210    pub capability: String,
211    pub state: String,
212    pub to: Option<String>,
213}
214
215#[derive(Debug, Serialize, ToSchema)]
216#[serde(rename_all = "camelCase")]
217pub struct AdminServiceSystemIssueDto {
218    pub code: String,
219    pub message: String,
220}
221
222#[derive(Debug, Serialize, ToSchema)]
223#[serde(rename_all = "camelCase")]
224pub struct AdminServiceSystemDriftResponse {
225    pub version: u8,
226    pub status: AdminServiceSystemDriftStatus,
227    pub system_file: String,
228    pub graph_issues: Vec<AdminServiceSystemIssueDto>,
229    pub drifts: Vec<AdminServiceSystemDriftDto>,
230    pub commands: Vec<String>,
231}
232
233#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
234#[serde(rename_all = "snake_case")]
235pub enum AdminServiceSystemDriftStatus {
236    Ready,
237    Drifted,
238    NeedsAttention,
239    Empty,
240}
241
242#[derive(Debug, Serialize, ToSchema)]
243#[serde(rename_all = "camelCase")]
244pub struct AdminServiceSystemDriftDto {
245    pub code: String,
246    pub severity: String,
247    pub resource: String,
248    pub name: String,
249    pub message: String,
250    pub command: Option<String>,
251}
252
253#[derive(Debug, Serialize, ToSchema)]
254#[serde(rename_all = "camelCase")]
255pub struct AdminServiceSystemReleaseTrainResponse {
256    pub version: u8,
257    pub status: AdminServiceSystemReleaseTrainStatus,
258    pub releases: Vec<AdminServiceSystemReleaseRecordDto>,
259    pub commands: Vec<String>,
260}
261
262#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
263#[serde(rename_all = "snake_case")]
264pub enum AdminServiceSystemReleaseTrainStatus {
265    Ready,
266    NeedsAttention,
267    Empty,
268}
269
270#[derive(Debug, Serialize, ToSchema)]
271#[serde(rename_all = "camelCase")]
272pub struct AdminServiceSystemReleaseRecordDto {
273    pub id: String,
274    pub kind: String,
275    pub system_name: String,
276    pub environment: String,
277    pub status: String,
278    pub policy_risk: String,
279    pub applied_at_unix_ms: Option<u64>,
280    pub services: usize,
281    pub modules: usize,
282    pub rollback_available: bool,
283}
284
285#[derive(Debug, Serialize, ToSchema)]
286#[serde(rename_all = "camelCase")]
287pub struct AdminServiceSystemRunbooksResponse {
288    pub version: u8,
289    pub status: AdminServiceSystemRunbooksStatus,
290    pub runbooks: Vec<AdminServiceSystemRunbookDto>,
291    pub commands: Vec<String>,
292}
293
294#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
295#[serde(rename_all = "snake_case")]
296pub enum AdminServiceSystemRunbooksStatus {
297    Ready,
298    NeedsAttention,
299    Empty,
300}
301
302#[derive(Debug, Serialize, ToSchema)]
303#[serde(rename_all = "camelCase")]
304pub struct AdminServiceSystemRunbookDto {
305    pub id: String,
306    pub release_id: String,
307    pub system_name: String,
308    pub environment: String,
309    pub status: String,
310    pub active: bool,
311    pub recorded_at_unix_ms: Option<u64>,
312    pub steps: usize,
313    pub current_step: Option<String>,
314}
315
316/// Response for `GET /admin/data/launchpad`: generated first-run app state.
317#[derive(Debug, Serialize, ToSchema)]
318#[serde(rename_all = "camelCase")]
319pub struct AdminLaunchpadResponse {
320    pub version: u8,
321    pub status: AdminLaunchpadStatus,
322    pub launchpad_file: String,
323    pub project_name: Option<String>,
324    pub blueprint: Option<String>,
325    pub summary: Option<String>,
326    pub services: Vec<AdminLaunchpadServiceDto>,
327    pub modules: Vec<AdminLaunchpadModuleDto>,
328    pub checklist: Vec<AdminLaunchpadChecklistItemDto>,
329    pub addons: Vec<AdminLaunchpadAddonDto>,
330    pub supported_addons: Vec<String>,
331    pub commands: Vec<String>,
332    pub next_command: Option<String>,
333    pub issues: Vec<AdminLaunchpadIssueDto>,
334}
335
336#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
337#[serde(rename_all = "snake_case")]
338pub enum AdminLaunchpadStatus {
339    Ready,
340    NeedsAttention,
341    Empty,
342}
343
344#[derive(Debug, Serialize, ToSchema)]
345#[serde(rename_all = "camelCase")]
346pub struct AdminLaunchpadServiceDto {
347    pub name: String,
348    pub role: Option<String>,
349    pub language: Option<String>,
350    pub cwd: Option<String>,
351    pub command: Option<String>,
352    pub ready_url: Option<String>,
353    pub modules: Vec<String>,
354}
355
356#[derive(Debug, Serialize, ToSchema)]
357#[serde(rename_all = "camelCase")]
358pub struct AdminLaunchpadModuleDto {
359    pub name: String,
360    pub owner_service: Option<String>,
361    pub capability: Option<String>,
362}
363
364#[derive(Debug, Serialize, ToSchema)]
365#[serde(rename_all = "camelCase")]
366pub struct AdminLaunchpadChecklistItemDto {
367    pub id: String,
368    pub label: String,
369    pub status: String,
370    pub next_command: Option<String>,
371}
372
373#[derive(Debug, Serialize, ToSchema)]
374#[serde(rename_all = "camelCase")]
375pub struct AdminLaunchpadIssueDto {
376    pub code: String,
377    pub message: String,
378    pub command: Option<String>,
379}
380
381#[derive(Debug, Serialize, ToSchema)]
382#[serde(rename_all = "camelCase")]
383pub struct AdminLaunchpadAddonDto {
384    pub name: String,
385    pub label: String,
386    pub status: String,
387    pub services: Vec<String>,
388    pub modules: Vec<String>,
389}
390
391/// Response for `GET /admin/data/launchpad/doctor`: latest local developer doctor snapshot.
392#[derive(Debug, Serialize, ToSchema)]
393#[serde(rename_all = "camelCase")]
394pub struct AdminLaunchpadDoctorResponse {
395    pub version: u8,
396    pub status: AdminLaunchpadDoctorStatus,
397    pub doctor_file: String,
398    pub checked_at_unix_ms: Option<u64>,
399    pub live: bool,
400    pub checks: Vec<AdminLaunchpadDoctorCheckDto>,
401    pub next_command: Option<String>,
402}
403
404#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
405#[serde(rename_all = "snake_case")]
406pub enum AdminLaunchpadDoctorStatus {
407    Ready,
408    NeedsAttention,
409    Failed,
410    Empty,
411}
412
413#[derive(Debug, Serialize, ToSchema)]
414#[serde(rename_all = "camelCase")]
415pub struct AdminLaunchpadDoctorCheckDto {
416    pub id: String,
417    pub label: String,
418    pub status: String,
419    pub message: String,
420    pub command: Option<String>,
421}
422
423/// Response for `GET /admin/data/launchpad/proof`: latest generated App Proof snapshot.
424#[derive(Debug, Serialize, ToSchema)]
425#[serde(rename_all = "camelCase")]
426pub struct AdminLaunchpadProofResponse {
427    pub version: u8,
428    pub status: AdminLaunchpadProofStatus,
429    pub proof_file: String,
430    pub checked_at_unix_ms: Option<u64>,
431    pub project_name: Option<String>,
432    pub blueprint: Option<String>,
433    pub addons: Vec<String>,
434    pub checks: Vec<AdminLaunchpadProofCheckDto>,
435    pub drifts: Vec<AdminLaunchpadProofDriftDto>,
436    pub next_command: Option<String>,
437}
438
439#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
440#[serde(rename_all = "snake_case")]
441pub enum AdminLaunchpadProofStatus {
442    Ready,
443    Drifted,
444    NeedsAttention,
445    Failed,
446    Empty,
447}
448
449#[derive(Debug, Serialize, ToSchema)]
450#[serde(rename_all = "camelCase")]
451pub struct AdminLaunchpadProofCheckDto {
452    pub id: String,
453    pub label: String,
454    pub status: String,
455    pub message: String,
456    pub command: Option<String>,
457}
458
459#[derive(Debug, Serialize, ToSchema)]
460#[serde(rename_all = "camelCase")]
461pub struct AdminLaunchpadProofDriftDto {
462    pub resource: String,
463    pub name: String,
464    pub message: String,
465    pub command: Option<String>,
466}
467
468/// Response for `GET /admin/data/launchpad/change-plan`: latest generated app change plan.
469#[derive(Debug, Serialize, ToSchema)]
470#[serde(rename_all = "camelCase")]
471pub struct AdminLaunchpadChangePlanResponse {
472    pub version: u8,
473    pub status: AdminLaunchpadChangePlanStatus,
474    pub plan_file: String,
475    pub generated_at_unix_ms: Option<u64>,
476    pub project_name: Option<String>,
477    pub blueprint: Option<String>,
478    pub addons: Vec<String>,
479    pub proof_status: Option<String>,
480    pub changes: Vec<AdminLaunchpadChangePlanItemDto>,
481    pub blocked: Vec<AdminLaunchpadChangePlanItemDto>,
482    pub next_command: Option<String>,
483    pub composition: Option<AdminLaunchpadCompositionDto>,
484    pub issues: Vec<AdminLaunchpadIssueDto>,
485}
486
487#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
488#[serde(rename_all = "snake_case")]
489pub enum AdminLaunchpadChangePlanStatus {
490    Ready,
491    Changes,
492    Blocked,
493    NeedsSetup,
494    Failed,
495    Empty,
496}
497
498#[derive(Debug, Serialize, ToSchema)]
499#[serde(rename_all = "camelCase")]
500pub struct AdminLaunchpadChangePlanItemDto {
501    pub id: String,
502    pub kind: String,
503    pub name: String,
504    pub action: String,
505    pub safe: bool,
506    pub message: String,
507    pub command: Option<String>,
508}
509
510#[derive(Debug, Serialize, ToSchema)]
511#[serde(rename_all = "camelCase")]
512pub struct AdminLaunchpadCompositionDto {
513    pub protocol: String,
514    pub intent: Option<String>,
515    pub requested_addons: Vec<String>,
516    pub applied_addons: Vec<String>,
517    pub pending_addons: Vec<String>,
518    pub requested_packs: Vec<String>,
519    pub applied_packs: Vec<String>,
520    pub pending_packs: Vec<String>,
521    pub capability_packs: Vec<AdminLaunchpadCapabilityPackDto>,
522    pub pack_fit: Vec<AdminLaunchpadPackFitDto>,
523    pub service_actions: Vec<AdminLaunchpadCompositionActionDto>,
524    pub agent_actions: Vec<AdminLaunchpadCompositionActionDto>,
525}
526
527#[derive(Debug, Serialize, ToSchema)]
528#[serde(rename_all = "camelCase")]
529pub struct AdminLaunchpadCapabilityPackDto {
530    pub name: String,
531    pub path: String,
532    pub status: String,
533    pub modules: Vec<String>,
534    pub services: Vec<String>,
535    pub next_command: Option<String>,
536}
537
538#[derive(Debug, Serialize, ToSchema)]
539#[serde(rename_all = "camelCase")]
540pub struct AdminLaunchpadPackFitDto {
541    pub name: String,
542    pub path: String,
543    pub status: String,
544    pub issues: Vec<String>,
545    pub command: Option<String>,
546}
547
548#[derive(Debug, Serialize, ToSchema)]
549#[serde(rename_all = "camelCase")]
550pub struct AdminLaunchpadCompositionActionDto {
551    pub id: String,
552    pub kind: String,
553    pub label: String,
554    pub command: Option<String>,
555    pub status: String,
556}
557
558#[derive(Debug, Serialize, ToSchema)]
559#[serde(rename_all = "snake_case")]
560pub enum AdminServiceModuleLifecycleStatus {
561    Ready,
562    NeedsAttention,
563    Empty,
564}
565
566#[derive(Debug, Serialize, ToSchema)]
567#[serde(rename_all = "camelCase")]
568pub struct AdminServiceModuleLifecycleModuleDto {
569    pub module_name: String,
570    pub provider_name: Option<String>,
571    pub status: AdminServiceModuleLifecycleModuleStatus,
572    pub installed: bool,
573    pub configured: bool,
574    pub loaded: bool,
575    pub restart_pending: bool,
576    pub base_url: Option<String>,
577    pub manifest_url: Option<String>,
578    pub manifest_status: AdminServiceModuleManifestStatus,
579    pub status_url: Option<String>,
580    pub service_status: AdminServiceModuleServiceStatusDto,
581    pub health_history: Vec<AdminServiceModuleHealthCheckDto>,
582    pub compatibility: AdminServiceModuleCompatibilityDto,
583    pub config: AdminServiceModuleConfigDto,
584    pub deployment: Option<AdminServiceModuleDeploymentDto>,
585    pub environments: Vec<AdminServiceEnvironmentDto>,
586    pub deployments: Vec<AdminServiceDeploymentObservationDto>,
587    pub deployment_history: Vec<AdminServiceDeploymentObservationDto>,
588    pub deployment_drift: Option<String>,
589    pub deployment_next_action: Option<String>,
590    pub services: Vec<AdminServiceModuleLifecycleServiceDto>,
591    pub operations: Vec<AdminServiceOperationDto>,
592    pub module_release: Option<AdminModuleReleaseDto>,
593    pub latest_release: Option<AdminServiceReleaseRecordDto>,
594    pub release_history: Vec<AdminServiceReleaseRecordDto>,
595    pub fixes: Vec<String>,
596}
597
598#[derive(Clone, Debug, Serialize, ToSchema)]
599#[serde(rename_all = "camelCase")]
600pub struct AdminServiceReleaseRecordDto {
601    pub id: Option<String>,
602    pub service_name: String,
603    #[serde(skip_serializing_if = "Option::is_none")]
604    pub environment: Option<String>,
605    #[serde(skip_serializing_if = "Option::is_none")]
606    pub target: Option<String>,
607    pub applied_at_unix_ms: Option<u64>,
608    pub risk: String,
609    pub current_version: Option<String>,
610    pub candidate_version: Option<String>,
611    pub current_manifest_reference: Option<String>,
612    pub candidate_manifest_reference: Option<String>,
613    pub candidate_package_reference: Option<String>,
614    pub rollback_target: Option<String>,
615}
616
617#[derive(Clone, Debug, Serialize, ToSchema)]
618#[serde(rename_all = "camelCase")]
619pub struct AdminServiceEnvironmentDto {
620    pub name: String,
621    pub service_name: String,
622    pub target: String,
623    pub namespace: Option<String>,
624    pub kube_context: Option<String>,
625    pub image: Option<String>,
626    pub public_base_url: Option<String>,
627    pub manifest_reference: Option<String>,
628    pub release_track: Option<String>,
629}
630
631#[derive(Clone, Debug, Serialize, ToSchema)]
632#[serde(rename_all = "camelCase")]
633pub struct AdminServiceDeploymentObservationDto {
634    pub service_name: String,
635    pub environment: String,
636    pub target: String,
637    pub observed_at_unix_ms: Option<u64>,
638    pub state: String,
639    pub drift: String,
640    pub operator: Option<AdminServiceDeploymentOperatorObservationDto>,
641    pub cluster: Option<AdminKubernetesDeploymentObservationDto>,
642    pub host: Option<AdminServiceDeploymentHostObservationDto>,
643    pub checks: Vec<AdminServiceDeploymentCheckDto>,
644    pub next_action: Option<String>,
645}
646
647#[derive(Clone, Debug, Serialize, ToSchema)]
648#[serde(rename_all = "camelCase")]
649pub struct AdminServiceDeploymentOperatorObservationDto {
650    pub resource: Option<String>,
651    pub namespace: Option<String>,
652    pub observed_generation: Option<u64>,
653    pub conditions: Vec<AdminServiceDeploymentOperatorConditionDto>,
654}
655
656#[derive(Clone, Debug, Serialize, ToSchema)]
657#[serde(rename_all = "camelCase")]
658pub struct AdminServiceDeploymentOperatorConditionDto {
659    #[serde(rename = "type")]
660    pub type_: Option<String>,
661    pub status: Option<String>,
662    pub reason: Option<String>,
663    pub message: Option<String>,
664    pub last_transition_time: Option<String>,
665}
666
667#[derive(Clone, Debug, Serialize, ToSchema)]
668#[serde(rename_all = "camelCase")]
669pub struct AdminKubernetesDeploymentObservationDto {
670    pub namespace: Option<String>,
671    pub deployment: Option<String>,
672    pub ready_replicas: Option<u32>,
673    pub desired_replicas: Option<u32>,
674    pub available_replicas: Option<u32>,
675    pub image: Option<String>,
676    pub release_id: Option<String>,
677    pub manifest_reference: Option<String>,
678    pub service_endpoint: Option<String>,
679    pub ingress_host: Option<String>,
680}
681
682#[derive(Clone, Debug, Serialize, ToSchema)]
683#[serde(rename_all = "camelCase")]
684pub struct AdminServiceDeploymentHostObservationDto {
685    pub release_id: Option<String>,
686    pub candidate_version: Option<String>,
687}
688
689#[derive(Clone, Debug, Serialize, ToSchema)]
690#[serde(rename_all = "camelCase")]
691pub struct AdminServiceDeploymentCheckDto {
692    pub name: String,
693    pub status: String,
694    pub detail: Option<String>,
695}
696
697#[derive(Debug, Serialize, ToSchema)]
698#[serde(rename_all = "snake_case")]
699pub enum AdminServiceOperationKindDto {
700    HttpRoute,
701    RuntimeFunction,
702    EventHandler,
703    AdminAction,
704}
705
706#[derive(Debug, Serialize, ToSchema)]
707#[serde(rename_all = "camelCase")]
708pub struct AdminServiceOperationLinksDto {
709    pub remote_calls: Option<String>,
710    pub runtime: Option<String>,
711    pub story: String,
712    pub technical_operations: String,
713}
714
715#[derive(Debug, Serialize, ToSchema)]
716#[serde(rename_all = "camelCase")]
717pub struct AdminServiceOperationDto {
718    pub operation_id: String,
719    pub provider_name: Option<String>,
720    pub module_name: String,
721    pub kind: AdminServiceOperationKindDto,
722    pub name: String,
723    pub method: Option<String>,
724    pub path: Option<String>,
725    pub capability: Option<String>,
726    pub summary: Option<String>,
727    pub safe_probe: bool,
728    pub links: AdminServiceOperationLinksDto,
729    pub next_action: String,
730}
731
732#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
733#[serde(rename_all = "camelCase")]
734pub struct AdminServiceModuleHealthCheckDto {
735    pub module_name: String,
736    pub checked_at_unix_ms: u64,
737    pub status_url: String,
738    pub state: String,
739    pub error: Option<String>,
740}
741
742#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
743#[serde(rename_all = "snake_case")]
744pub enum AdminServiceModuleLifecycleModuleStatus {
745    Ready,
746    MissingConfig,
747    RestartPending,
748    ConfiguredNotLoaded,
749    ManifestUnreachable,
750    ServiceNotReady,
751    StaleState,
752    NotConfigured,
753}
754
755#[derive(Debug, Serialize, ToSchema)]
756#[serde(rename_all = "camelCase")]
757pub struct AdminServiceModuleConfigDto {
758    pub env_file: String,
759    pub required_env: Vec<String>,
760    pub configured_env: Vec<String>,
761    pub missing_env: Vec<String>,
762}
763
764#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
765#[serde(rename_all = "snake_case")]
766pub enum AdminServiceModuleManifestStatus {
767    Reachable,
768    Unreachable,
769    Skipped,
770    NotConfigured,
771}
772
773#[derive(Debug, Serialize, ToSchema)]
774#[serde(rename_all = "camelCase")]
775pub struct AdminServiceModuleLifecycleServiceDto {
776    pub name: String,
777    pub ready_url: String,
778    pub ready: bool,
779    pub auto_start: bool,
780    pub lock_file: Option<String>,
781    pub pid_file: Option<String>,
782}
783
784#[derive(Debug, Serialize, ToSchema)]
785#[serde(rename_all = "camelCase")]
786pub struct AdminServiceModuleServiceStatusDto {
787    pub checked: bool,
788    pub state: AdminServiceModuleServiceStatusState,
789    pub error: Option<String>,
790    pub checks: Vec<AdminServiceModuleServiceStatusCheckDto>,
791}
792
793#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
794#[serde(rename_all = "snake_case")]
795pub enum AdminServiceModuleServiceStatusState {
796    Ready,
797    Degraded,
798    Starting,
799    Unreachable,
800    Unknown,
801}
802
803#[derive(Debug, Serialize, ToSchema)]
804#[serde(rename_all = "camelCase")]
805pub struct AdminServiceModuleServiceStatusCheckDto {
806    pub name: String,
807    pub status: String,
808    pub detail: Option<String>,
809}
810
811#[derive(Debug, Serialize, ToSchema)]
812#[serde(rename_all = "camelCase")]
813pub struct AdminServiceModuleCompatibilityDto {
814    pub state: AdminServiceModuleCompatibilityState,
815    pub declared: Option<AdminModuleCompatibilityDto>,
816    pub host: AdminModuleHostCompatibilityDto,
817    pub issue: Option<String>,
818    pub fix: Option<String>,
819    pub override_allowed: bool,
820}
821
822#[derive(Debug, Serialize, ToSchema, PartialEq, Eq)]
823#[serde(rename_all = "snake_case")]
824pub enum AdminServiceModuleCompatibilityState {
825    Compatible,
826    Blocked,
827    Unknown,
828}
829
830#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
831#[serde(rename_all = "camelCase")]
832pub struct AdminServiceModuleDeploymentDto {
833    pub target: Option<String>,
834    #[serde(default)]
835    pub commands: Vec<String>,
836    pub compose_service: Option<String>,
837}
838
839#[derive(Debug, Serialize, ToSchema)]
840#[serde(rename_all = "camelCase")]
841pub struct AdminModuleLinkedSourceInstallStateDto {
842    pub env_file: String,
843    pub configured: bool,
844    pub desired_enabled: Option<bool>,
845    pub running_enabled: bool,
846    pub restart_pending: bool,
847    pub restart_reason: Option<String>,
848    pub error: Option<String>,
849}
850
851#[derive(Debug, Serialize, ToSchema)]
852#[serde(rename_all = "camelCase")]
853pub struct AdminModuleRemoteSourceInstallStateDto {
854    pub env_file: String,
855    pub configured: bool,
856    pub desired_base_url: Option<String>,
857    pub running_base_url: Option<String>,
858    pub restart_pending: bool,
859    pub restart_reason: Option<String>,
860    pub error: Option<String>,
861}
862
863#[derive(Debug, Serialize, ToSchema)]
864#[serde(rename_all = "camelCase")]
865pub struct AdminModuleConsolePackagePlanStateDto {
866    pub plan_file: String,
867    pub exists: bool,
868    pub readable: bool,
869    pub error: Option<String>,
870    pub module_entry_present: bool,
871    pub package_count: usize,
872    pub restart_required: Option<bool>,
873    pub packages: Vec<AdminModuleConsolePackagePlanPackageDto>,
874}
875
876/// Response for visually installing an available service or linked module from
877/// the curated catalog.
878#[derive(Debug, Serialize, ToSchema)]
879#[serde(rename_all = "camelCase")]
880pub struct AdminModuleInstallResponse {
881    pub module_name: String,
882    pub manifest_reference: String,
883    pub module_release: Option<AdminModuleReleaseDto>,
884    pub linked_source: Option<AdminModuleLinkedSourceInstallStateDto>,
885    pub remote_source: Option<AdminModuleRemoteSourceInstallStateDto>,
886    pub console_plan: AdminModuleConsolePackagePlanStateDto,
887    pub restart_required: bool,
888}
889
890#[derive(Debug, Serialize, ToSchema)]
891#[serde(rename_all = "camelCase")]
892pub struct AdminModuleConsolePackagePlanPackageDto {
893    pub key: Option<String>,
894    pub package_name: String,
895    pub export_name: String,
896    pub command: Option<String>,
897    pub route: Option<String>,
898    pub status: Option<String>,
899}
900
901#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
902#[serde(rename_all = "camelCase")]
903pub struct AdminModuleCompatibilityDto {
904    #[serde(alias = "console_package_api")]
905    pub console_package_api: Option<String>,
906    pub lenso: Option<AdminModuleLensoCompatibilityDto>,
907    #[serde(alias = "remote_protocol_version")]
908    pub remote_protocol_version: Option<String>,
909    #[serde(default, alias = "required_host_features")]
910    pub required_host_features: Vec<String>,
911}
912
913#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
914#[serde(rename_all = "camelCase")]
915pub struct AdminModuleLensoCompatibilityDto {
916    #[serde(alias = "min_version")]
917    pub min_version: Option<String>,
918    #[serde(alias = "max_version")]
919    pub max_version: Option<String>,
920}
921
922#[derive(Clone, Debug, Serialize, ToSchema)]
923#[serde(rename_all = "camelCase")]
924pub struct AdminModuleHostCompatibilityDto {
925    pub console_package_api: String,
926    pub lenso_version: String,
927}
928
929#[derive(Debug, Serialize, ToSchema)]
930#[serde(rename_all = "snake_case")]
931pub enum AdminModuleRegistrySnapshotManifestStatus {
932    Ok,
933    Invalid,
934    Unreadable,
935    Archived,
936}
937
938#[derive(Debug, Serialize, ToSchema)]
939#[serde(rename_all = "snake_case")]
940pub enum AdminModuleRegistrySnapshotModuleStatus {
941    Ready,
942    NeedsAttention,
943    Archived,
944}
945
946#[derive(Debug, Serialize, ToSchema)]
947pub struct AdminModuleRefreshRecordDto {
948    pub id: String,
949    pub status: AdminModuleRefreshStatusDto,
950    pub started_at: String,
951    pub completed_at: String,
952    pub duration_ms: u64,
953    pub module_count: usize,
954    pub error: Option<String>,
955    pub module_results: Vec<AdminModuleRefreshModuleResultDto>,
956}
957
958#[derive(Debug, Serialize, ToSchema)]
959#[serde(rename_all = "snake_case")]
960pub enum AdminModuleRefreshStatusDto {
961    Success,
962    Error,
963}
964
965#[derive(Debug, Serialize, ToSchema)]
966pub struct AdminModuleRefreshModuleResultDto {
967    pub module_name: String,
968    pub source: ModuleSource,
969    pub status: AdminModuleRefreshModuleStatusDto,
970    pub duration_ms: Option<u64>,
971    pub endpoint: Option<String>,
972    pub error: Option<String>,
973}
974
975#[derive(Debug, Serialize, ToSchema)]
976#[serde(rename_all = "snake_case")]
977pub enum AdminModuleRefreshModuleStatusDto {
978    Loaded,
979    Error,
980}
981
982#[derive(Debug, Serialize, ToSchema)]
983pub struct AdminModuleMetadataDto {
984    pub module_name: String,
985    pub source: ModuleSource,
986    pub status: AdminModuleStatus,
987    pub error: Option<String>,
988    pub source_diagnostics: Option<AdminModuleSourceDiagnosticsDto>,
989    pub http_routes: Vec<ModuleHttpRoute>,
990    pub runtime: Option<RuntimeSurface>,
991    pub events: Option<EventSurface>,
992    pub lifecycle: Option<LifecycleSurface>,
993    pub console: Vec<ConsoleSurface>,
994    pub console_slots: Vec<ConsoleSlot>,
995    pub console_contributions: Vec<ConsoleContribution>,
996    pub governance: AdminModuleGovernanceDto,
997    pub manifest_lints: Vec<ModuleManifestLint>,
998    pub story_display: Vec<StoryDisplayDescriptorDto>,
999    pub capabilities: Vec<String>,
1000    pub dependencies: Vec<String>,
1001    pub admin: Option<AdminSurface>,
1002}
1003
1004#[derive(Debug, Serialize, ToSchema)]
1005#[serde(tag = "kind", rename_all = "snake_case")]
1006pub enum AdminModuleSourceDiagnosticsDto {
1007    Remote(AdminRemoteModuleDiagnosticsDto),
1008}
1009
1010#[derive(Debug, Serialize, ToSchema)]
1011pub struct AdminRemoteModuleDiagnosticsDto {
1012    pub transport: String,
1013    pub base_url: String,
1014    pub manifest_url: String,
1015    pub timeout_ms: u64,
1016    pub auth_configured: bool,
1017    pub load_duration_ms: Option<u64>,
1018    pub last_checked_at: Option<String>,
1019    pub last_load_error: Option<String>,
1020}
1021
1022#[derive(Debug, Serialize, ToSchema)]
1023pub struct AdminModuleGovernanceDto {
1024    pub activation_state: AdminModuleActivationState,
1025    pub activation_reasons: Vec<String>,
1026    pub capability_summary: AdminCapabilitySummaryDto,
1027    pub capability_issues: Vec<AdminCapabilityIssueDto>,
1028}
1029
1030#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, ToSchema)]
1031#[serde(rename_all = "snake_case")]
1032pub enum AdminModuleActivationState {
1033    Active,
1034    NeedsAttention,
1035    Blocked,
1036}
1037
1038#[derive(Debug, Serialize, ToSchema)]
1039pub struct AdminCapabilitySummaryDto {
1040    pub declared_count: usize,
1041    pub referenced_count: usize,
1042    pub missing_count: usize,
1043    pub unused_count: usize,
1044}
1045
1046#[derive(Debug, Serialize, ToSchema)]
1047pub struct AdminCapabilityIssueDto {
1048    pub capability: String,
1049    pub subject: String,
1050    pub message: String,
1051    pub suggestion: String,
1052}
1053
1054#[derive(Debug, Serialize, ToSchema)]
1055pub struct StoryDisplayDescriptorDto {
1056    pub source: StoryDisplaySourceDto,
1057    pub display_name: String,
1058    pub story_title: Option<String>,
1059}
1060
1061#[derive(Debug, Serialize, ToSchema)]
1062#[serde(tag = "kind", rename_all = "snake_case")]
1063pub enum StoryDisplaySourceDto {
1064    ExecutionName { name: String },
1065    HttpRequest { method: String, path: String },
1066}
1067
1068impl From<StoryDisplayDescriptor> for StoryDisplayDescriptorDto {
1069    fn from(descriptor: StoryDisplayDescriptor) -> Self {
1070        Self {
1071            source: descriptor.source.into(),
1072            display_name: descriptor.display_name,
1073            story_title: descriptor.story_title,
1074        }
1075    }
1076}
1077
1078impl From<StoryDisplaySource> for StoryDisplaySourceDto {
1079    fn from(source: StoryDisplaySource) -> Self {
1080        match source {
1081            StoryDisplaySource::ExecutionName { name } => Self::ExecutionName { name },
1082            StoryDisplaySource::HttpRequest { method, path } => Self::HttpRequest { method, path },
1083        }
1084    }
1085}
1086
1087#[derive(Debug, Serialize, ToSchema)]
1088pub struct AdminModuleSchema {
1089    pub module_name: String,
1090    pub source: ModuleSource,
1091    pub status: AdminModuleStatus,
1092    pub error: Option<String>,
1093    pub schema: AdminSchema,
1094}
1095
1096#[derive(Debug, Clone, Copy, Serialize, ToSchema)]
1097#[serde(rename_all = "snake_case")]
1098pub enum AdminModuleStatus {
1099    Loaded,
1100    Error,
1101}
1102
1103/// Response for `GET /admin/data/{module}/{entity}`: a page of records.
1104#[derive(Debug, Serialize, ToSchema)]
1105pub struct AdminDataListResponse {
1106    /// Each record is an arbitrary JSON object whose keys match the entity schema.
1107    pub data: Vec<serde_json::Value>,
1108    pub page: AdminDataPageInfo,
1109}
1110
1111/// Pagination info. `next_cursor` is an opaque token (not a timestamp like
1112/// platform-admin's PageInfo) so it makes no assumption about entity shape.
1113#[derive(Debug, Serialize, ToSchema)]
1114pub struct AdminDataPageInfo {
1115    pub limit: i64,
1116    pub next_cursor: Option<String>,
1117}
1118
1119/// Response for `GET /admin/data/{module}/{entity}/{id}`.
1120#[derive(Debug, Serialize, ToSchema)]
1121pub struct AdminDataDetailResponse {
1122    pub data: serde_json::Value,
1123}
1124
1125/// Response for `GET /admin/data/{module}/queries/{query}`.
1126#[derive(Debug, Serialize, ToSchema)]
1127pub struct AdminQueryResponse {
1128    pub data: serde_json::Value,
1129}
1130
1131/// Request body for `POST /admin/data/{module}/actions/{action}`.
1132#[derive(Debug, Clone, Deserialize, ToSchema)]
1133pub struct AdminActionInvokeRequest {
1134    #[serde(default)]
1135    pub input: serde_json::Value,
1136    #[serde(default)]
1137    pub confirmation_phrase: Option<String>,
1138}
1139
1140/// Response for `POST /admin/data/{module}/actions/{action}`.
1141#[derive(Debug, Serialize, ToSchema)]
1142pub struct AdminActionInvokeResponse {
1143    pub data: serde_json::Value,
1144    pub invocation: AdminActionInvocationDto,
1145}
1146
1147#[derive(Debug, Serialize, ToSchema)]
1148pub struct AdminActionInvocationDto {
1149    pub request_id: String,
1150    pub correlation_id: String,
1151    pub story_node_id: String,
1152}