import type { BlockApiV1 } from "./block_api_v1"; import type { BlockApiV2 } from "./block_api_v2"; import type { BlockApiV3 } from "./block_api_v3"; import type { BlockCodeKnownFeatureFlags, BlockOutputsBase, BlockStateV3, DriverKit, OutputWithStatus, UiServices as AllUiServices, } from "@milaboratories/pl-model-common"; import type { SdkInfo } from "./version"; import type { ServiceDispatch } from "@milaboratories/pl-model-common"; import type { BlockStatePatch } from "./block_state_patch"; import type { PluginRecord } from "./block_model"; import type { PluginHandle, PluginFactoryLike } from "./plugin_handle"; import type { PublicOutputFieldDef } from "./plugin_model"; /** Defines all methods to interact with the platform environment from within a block UI. @deprecated */ export interface PlatformaV1< Args = unknown, Outputs extends Record> = Record< string, OutputWithStatus >, UiState = unknown, Href extends `/${string}` = `/${string}`, > extends BlockApiV1, DriverKit { /** Information about SDK version current platforma environment was compiled with. */ readonly sdkInfo: SdkInfo; readonly apiVersion?: 1; } /** V2 version based on effective json patches pulling API */ export interface PlatformaV2< Args = unknown, Outputs extends Record> = Record< string, OutputWithStatus >, UiState = unknown, Href extends `/${string}` = `/${string}`, > extends BlockApiV2, DriverKit { /** Information about SDK version current platforma environment was compiled with. */ readonly sdkInfo: SdkInfo; readonly apiVersion: 2; } export interface PlatformaV3< Data = unknown, Args = unknown, Outputs extends Record> = Record< string, OutputWithStatus >, Href extends `/${string}` = `/${string}`, Plugins extends Record = Record, UiServices extends Partial = Partial, > extends BlockApiV3, DriverKit { /** Information about SDK version current platforma environment was compiled with. */ readonly sdkInfo: SdkInfo; readonly apiVersion: 3; /** Service dispatch — lists available services, their methods, and invokes them. */ readonly serviceDispatch: ServiceDispatch; /** @internal Type brand for plugin type inference. Not used at runtime. */ readonly __pluginsBrand?: Plugins; /** @internal Type brand for UI service type inference. Not used at runtime. */ readonly __uiServicesBrand?: UiServices; } export type Platforma< Args = unknown, Outputs extends Record> = Record< string, OutputWithStatus >, UiStateOrData = unknown, Href extends `/${string}` = `/${string}`, > = | PlatformaV1 | PlatformaV2 | PlatformaV3; export type PlatformaExtended = Pl & { blockModelInfo: BlockModelInfo; }; export type BlockModelInfo = { outputs: Record< string, { withStatus: boolean; } >; pluginIds: PluginHandle[]; featureFlags: BlockCodeKnownFeatureFlags; pluginPublicOutputs: Record>; }; export type PlatformaApiVersion = Platforma["apiVersion"]; export type InferArgsType = Pl extends Platforma ? Args : never; export type InferOutputsType = Pl extends Platforma ? Outputs : never; export type InferUiState = Pl extends Platforma>, infer UiState> ? UiState : never; export type InferDataType = Pl extends Platforma>, infer Data> ? Data : never; export type InferHrefType = Pl extends Platforma ? Href : never; export type PlatformaFactory = (config: { sdkVersion: string }) => Platforma; export type InferBlockState = BlockStateV3< InferDataType, InferOutputsType, InferHrefType >; export type InferBlockStatePatch = BlockStatePatch< InferArgsType, InferOutputsType, InferUiState, InferHrefType >; /** Extract plugin IDs as a string literal union from a Platforma type. */ export type InferPluginNames = Pl extends PlatformaV3 ? string & keyof P : never; /** Extract the Data type for a specific plugin by its ID. */ export type InferPluginData = Pl extends PlatformaV3 ? PluginId extends keyof P ? P[PluginId] extends PluginRecord ? D : never : never : never; /** * Derives the UI-facing entry map for a plugin registry. * For each plugin instance, produces a typed handle and its public outputs — * the subset of plugin state accessible to block UI without usePlugin(). */ export type InferPluginUiEntries> = { readonly [K in keyof T]: T[K] extends PluginRecord< infer Data, infer Params, infer Outputs, infer PublicOutputs, infer ModelServices, infer UiServices > ? { handle: PluginHandle>; publicOutputs: PublicOutputs; } : never; };