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