diff --git a/app/web/src/api/sdf/dal/action.ts b/app/web/src/api/sdf/dal/action.ts new file mode 100644 index 0000000000..f7ab1a69a0 --- /dev/null +++ b/app/web/src/api/sdf/dal/action.ts @@ -0,0 +1,30 @@ +export type ActionPrototypeId = string; +export type ActionId = string; + +export enum ActionState { + Dispatched = "Dispatched", + Failed = "Failed", + OnHold = "OnHold", + Queued = "Queued", + Running = "Running", +} + +export enum ActionKind { + Create = "Create", + Destroy = "Destroy", + Refresh = "Refresh", + Manual = "Manual", + Update = "Update", +} + +export interface ActionPrototype { + id: ActionPrototypeId; + name: string; + displayName: string; +} + +export enum ActionResultState { + Success = "Success", + Failure = "Failure", + Unknown = "Unknown", +} diff --git a/app/web/src/api/sdf/dal/func.ts b/app/web/src/api/sdf/dal/func.ts index b6d1c9fe6e..c2c84add20 100644 --- a/app/web/src/api/sdf/dal/func.ts +++ b/app/web/src/api/sdf/dal/func.ts @@ -1,5 +1,12 @@ +import { ActionKind, ActionPrototypeId } from "@/api/sdf/dal/action"; +import { InputSocketId, OutputSocketId, SchemaVariantId } from "./schema"; +import { ComponentId } from "./component"; +import { PropId } from "./prop"; + export type FuncArgumentId = string; export type FuncId = string; +export type AttributePrototypeArgumentId = string; +export type AttributePrototypeId = string; export enum FuncKind { Action = "Action", @@ -9,7 +16,7 @@ export enum FuncKind { Intrinsic = "Intrinsic", Qualification = "Qualification", SchemaVariantDefinition = "SchemaVariantDefinition", - Unknwon = "Unknown", + Unknown = "Unknown", } export enum CustomizableFuncKind { @@ -69,14 +76,14 @@ export const isCustomizableFuncKind = (f: FuncKind) => f in CUSTOMIZABLE_FUNC_TYPES; export enum FuncArgumentKind { - Array = "Array", - Boolean = "Boolean", - Integer = "Integer", - Json = "Json", - Object = "Object", - String = "String", - Map = "Map", - Any = "Any", + Array = "array", + Boolean = "boolean", + Integer = "integer", + Json = "json", + Object = "object", + String = "string", + Map = "map", + Any = "any", } export interface FuncArgument { @@ -84,4 +91,102 @@ export interface FuncArgument { name: string; kind: FuncArgumentKind; elementKind?: FuncArgumentKind; + created_at: IsoDateString; + updated_at: IsoDateString; +} + +export interface FuncSummary { + funcId: FuncId; + kind: FuncKind; + name: string; + displayName: string | null; + description: string | null; + isLocked: boolean; + arguments: FuncArgument[]; + bindings: FuncBinding[]; +} + +export interface FuncCode { + funcId: FuncId; + code: string; + types: string; +} + +export interface AttributeArgumentBinding { + funcArgumentId: FuncArgumentId; + attributePrototypeArgumentId: AttributePrototypeArgumentId | null; + propId: PropId | null; + inputSocketId: InputSocketId | null; +} + +export enum FuncBindingKind { + Action = "action", + Attribute = "attribute", + Authentication = "authentication", + CodeGeneration = "codeGeneration", + Qualification = "qualification", +} + +export interface Action { + bindingKind: FuncBindingKind.Action; + // uneditable + funcId: FuncId | null; + schemaVariantId: SchemaVariantId | null; + actionPrototypeId: ActionPrototypeId | null; + // editable + kind: ActionKind | null; +} + +export interface Attribute { + bindingKind: FuncBindingKind.Attribute; + // uneditable + funcId: FuncId | null; + attributePrototypeId: AttributePrototypeId | null; + // needed on create + schemaVariantId: SchemaVariantId | null; + componentId: ComponentId | null; + // editable + propId: PropId | null; + outputSocketId: OutputSocketId | null; + argumentBindings: AttributeArgumentBinding[]; } + +export interface Authentication { + bindingKind: FuncBindingKind.Authentication; + funcId: FuncId; + schemaVariantId: SchemaVariantId; +} + +export interface CodeGeneration { + bindingKind: FuncBindingKind.CodeGeneration; + funcId: FuncId | null; + schemaVariantId: SchemaVariantId | null; + attributePrototypeId: AttributePrototypeId | null; + componentId: ComponentId | null; + // editable + inputs: LeafInputLocation[]; +} + +export interface Qualification { + bindingKind: FuncBindingKind.Qualification; + funcId: FuncId | null; + schemaVariantId: SchemaVariantId | null; + attributePrototypeId: AttributePrototypeId | null; + componentId: ComponentId | null; + // editable + inputs: LeafInputLocation[]; +} + +export type FuncBinding = + | Action + | Attribute + | Authentication + | CodeGeneration + | Qualification; + +export type LeafInputLocation = + | "code" + | "deletedAt" + | "domain" + | "resource" + | "secrets"; diff --git a/app/web/src/api/sdf/dal/prop.ts b/app/web/src/api/sdf/dal/prop.ts index eda846538f..d88707b97d 100644 --- a/app/web/src/api/sdf/dal/prop.ts +++ b/app/web/src/api/sdf/dal/prop.ts @@ -9,3 +9,14 @@ export enum PropKind { String = "string", Map = "map", } + +export interface Prop { + id: PropId; + kind: PropKind; + name: string; + path: string; + // this is for output sources + eligibleToReceiveData: boolean; + // this is for input sources + eligibleToSendData: boolean; +} diff --git a/app/web/src/api/sdf/dal/schema.ts b/app/web/src/api/sdf/dal/schema.ts index 0bb0763d50..c84e428920 100644 --- a/app/web/src/api/sdf/dal/schema.ts +++ b/app/web/src/api/sdf/dal/schema.ts @@ -1,5 +1,6 @@ import { StandardModel } from "@/api/sdf/dal/standard_model"; import { FuncId } from "@/api/sdf/dal/func"; +import { Prop, PropId } from "@/api/sdf/dal/prop"; export enum SchemaKind { Concept = "concept", @@ -30,6 +31,7 @@ export type OutputSocketId = string; export interface OutputSocket { id: OutputSocketId; name: string; + eligibleToReceiveData: boolean; } export type InputSocketId = string; @@ -37,6 +39,7 @@ export type InputSocketId = string; export interface InputSocket { id: InputSocketId; name: string; + eligibleToSendData: boolean; } export interface SchemaVariant { @@ -61,4 +64,55 @@ export interface SchemaVariant { inputSockets: InputSocket[]; outputSockets: OutputSocket[]; + props: Prop[]; } + +export const outputSocketsAndPropsFor = (schemaVariant: SchemaVariant) => { + const socketOptions = schemaVariant.outputSockets.map((socket) => ({ + label: `Output Socket: ${socket.name}`, + value: `s_${socket.id}`, + })); + + // output + const propOptions = schemaVariant.props + .filter((p) => p.eligibleToReceiveData) + .map((p) => ({ + label: `Attribute: ${p.path}`, + value: `p_${p.id}`, + })); + return { socketOptions, propOptions }; +}; + +export const inputSocketsAndPropsFor = (schemaVariant: SchemaVariant) => { + const socketOptions = schemaVariant.inputSockets.map((socket) => ({ + label: `Input Socket: ${socket.name}`, + value: `s_${socket.id}`, + })); + + const propOptions = schemaVariant.props + .filter((p) => p.eligibleToSendData) + .map((p) => ({ + label: `Attribute: ${p.path}`, + value: `p_${p.id}`, + })); + + return { socketOptions, propOptions }; +}; + +export const findSchemaVariantForPropOrSocketId = ( + schemaVariants: SchemaVariant[], + propId: PropId | null | undefined, + outputSocketId: OutputSocketId | null | undefined, +) => { + if (propId && outputSocketId) throw new Error("Either prop or output socket"); + + return schemaVariants.find((sv) => { + if (propId && sv.props.map((p) => p.id).includes(propId)) return sv; + if ( + outputSocketId && + sv.outputSockets.map((o) => o.id).includes(outputSocketId) + ) + return sv; + return undefined; + }); +}; diff --git a/app/web/src/components/Actions/ActionCard.vue b/app/web/src/components/Actions/ActionCard.vue index 9ea8652b95..1f7aef836a 100644 --- a/app/web/src/components/Actions/ActionCard.vue +++ b/app/web/src/components/Actions/ActionCard.vue @@ -246,12 +246,10 @@ import { } from "@si/vue-lib/design-system"; import clsx from "clsx"; import { FullComponent, useComponentsStore } from "@/store/components.store"; +import { ActionKind, ActionState, ActionId } from "@/api/sdf/dal/action"; import { - ActionKind, - ActionState, ActionView, useActionsStore, - ActionId, ActionProposedView, ActionHistoryView, } from "@/store/actions.store"; diff --git a/app/web/src/components/Actions/ActionWidget.vue b/app/web/src/components/Actions/ActionWidget.vue index 854f6fb7f6..f21898ea48 100644 --- a/app/web/src/components/Actions/ActionWidget.vue +++ b/app/web/src/components/Actions/ActionWidget.vue @@ -28,7 +28,8 @@ import * as _ from "lodash-es"; import clsx from "clsx"; import { PropType, computed } from "vue"; import { Icon, themeClasses } from "@si/vue-lib/design-system"; -import { ActionPrototypeId, useActionsStore } from "@/store/actions.store"; +import { useActionsStore } from "@/store/actions.store"; +import { ActionPrototypeId } from "@/api/sdf/dal/action"; import { ComponentId } from "@/api/sdf/dal/component"; import StatusIndicatorIcon from "../StatusIndicatorIcon.vue"; import Toggle from "./Toggle.vue"; diff --git a/app/web/src/components/AssetCard.vue b/app/web/src/components/AssetCard.vue index e1d6aa4a79..753c39b698 100644 --- a/app/web/src/components/AssetCard.vue +++ b/app/web/src/components/AssetCard.vue @@ -149,7 +149,7 @@ const unlock = async () => { asset.value.schemaVariantId, ); if (resp.result.success) { - assetStore.setSchemaVariantSelection(resp.result.data?.id); + assetStore.setSchemaVariantSelection(resp.result.data?.id, true); } } }; diff --git a/app/web/src/components/AssetDetailsPanel.vue b/app/web/src/components/AssetDetailsPanel.vue index 3fb2245141..7d1598d6c5 100644 --- a/app/web/src/components/AssetDetailsPanel.vue +++ b/app/web/src/components/AssetDetailsPanel.vue @@ -181,7 +181,6 @@ import * as _ from "lodash-es"; import { FuncKind, FuncId } from "@/api/sdf/dal/func"; import { useAssetStore } from "@/store/asset.store"; import { useFeatureFlagsStore } from "@/store/feature_flags.store"; -import { useFuncStore } from "@/store/func/funcs.store"; import { ComponentType } from "@/api/sdf/dal/schema"; import ColorPicker from "./ColorPicker.vue"; import AssetFuncAttachModal from "./AssetFuncAttachModal.vue"; @@ -193,7 +192,6 @@ const props = defineProps<{ const ffStore = useFeatureFlagsStore(); const assetStore = useAssetStore(); -const funcStore = useFuncStore(); const loadAssetReqStatus = assetStore.getRequestStatus( "LOAD_SCHEMA_VARIANT", props.assetId, @@ -238,13 +236,13 @@ const updateAsset = async () => { editingAsset.value && !_.isEqual(editingAsset.value, assetStore.selectedSchemaVariant) ) { - const code = - funcStore.funcDetailsById[editingAsset.value.assetFuncId]?.code; - if (code) await assetStore.SAVE_SCHEMA_VARIANT(editingAsset.value); - else + // const code = funcStore.funcCodeById[editingAsset.value.assetFuncId]?.code; + // if (code) + await assetStore.SAVE_SCHEMA_VARIANT(editingAsset.value); + /* else throw new Error( `${editingAsset.value.assetFuncId} Func not found on Variant ${editingAsset.value.schemaVariantId}. This should not happen.`, - ); + ); */ } }; @@ -274,7 +272,7 @@ const cloneAsset = async (name: string) => { ); if (result.result.success) { cloneAssetModalRef.value?.modal?.close(); - await assetStore.setSchemaVariantSelection(result.result.data.id); + await assetStore.setSchemaVariantSelection(result.result.data.id, true); } } }; diff --git a/app/web/src/components/AssetEditor.vue b/app/web/src/components/AssetEditor.vue index 0ee8df4c59..41df4fc3fa 100644 --- a/app/web/src/components/AssetEditor.vue +++ b/app/web/src/components/AssetEditor.vue @@ -93,7 +93,7 @@ const selectedAsset = computed(() => const selectedAssetFuncCode = computed(() => { const fId = selectedAsset.value?.assetFuncId; if (!fId) return null; - return funcStore.funcDetailsById[fId]?.code; + return funcStore.funcCodeById[fId]?.code; }); const isReadOnly = computed(() => { diff --git a/app/web/src/components/AssetFuncAttachModal.vue b/app/web/src/components/AssetFuncAttachModal.vue index 372c706446..e336c68f23 100644 --- a/app/web/src/components/AssetFuncAttachModal.vue +++ b/app/web/src/components/AssetFuncAttachModal.vue @@ -35,7 +35,7 @@ required :options="existingFuncOptions" /> -