From a5a48e78cffcf22ab97ef8934a62ea0944338788 Mon Sep 17 00:00:00 2001 From: Miroir Framework Date: Tue, 14 May 2024 11:07:46 +0200 Subject: [PATCH] EXPERIMENT: create basic elements for Miroir Action Script (MAS), migrate Tools.submit to MAS #28. Migrate all Tools.submit actions to use only Action Templates. --- .../getMiroirFundamentalJzodSchema.ts | 2 + .../miroirFundamentalJzodSchema.ts | 201 +++++++ .../miroirFundamentalType.ts | 27 +- .../src/3_controllers/DomainController.ts | 108 +++- .../bbd08cbb-79ff-4539-b91f-7a14f15ac55f.json | 43 +- .../tests/1_core/jzod.unit.test.ts | 3 + .../miroir-core/tools/generate-ts-types.mjs | 2 + .../4_view/components/RootComponent.tsx | 2 + .../src/miroir-fwk/4_view/routes/Tools.tsx | 499 ++++++++++++++---- 9 files changed, 768 insertions(+), 119 deletions(-) diff --git a/packages/miroir-core/src/0_interfaces/1_core/bootstrapJzodSchemas/getMiroirFundamentalJzodSchema.ts b/packages/miroir-core/src/0_interfaces/1_core/bootstrapJzodSchemas/getMiroirFundamentalJzodSchema.ts index 68123659..f5cc500c 100644 --- a/packages/miroir-core/src/0_interfaces/1_core/bootstrapJzodSchemas/getMiroirFundamentalJzodSchema.ts +++ b/packages/miroir-core/src/0_interfaces/1_core/bootstrapJzodSchemas/getMiroirFundamentalJzodSchema.ts @@ -123,6 +123,7 @@ export function getMiroirFundamentalJzodSchema( jzodSchemajzodMiroirBootstrapSchema: JzodSchema, entityDefinitionApplicationV1 : EntityDefinition, entityDefinitionApplicationVersionV1 : EntityDefinition, + entityDefinitionDeployment : EntityDefinition, entityDefinitionEntity : EntityDefinition, entityDefinitionEntityDefinitionV1 : EntityDefinition, entityDefinitionJzodSchemaV1 : EntityDefinition, @@ -495,6 +496,7 @@ export function getMiroirFundamentalJzodSchema( "application": entityDefinitionApplicationV1.jzodSchema as JzodObject, "applicationVersion": entityDefinitionApplicationVersionV1.jzodSchema as JzodObject, "bundle": entityDefinitionBundleV1.jzodSchema as JzodObject, + "deployment": entityDefinitionDeployment.jzodSchema as JzodObject, "entity": entityDefinitionEntity.jzodSchema as JzodObject, "entityDefinition": entityDefinitionEntityDefinitionV1.jzodSchema as JzodObject, ...(entityDefinitionMenu.jzodSchema.definition.definition as any).context, diff --git a/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalJzodSchema.ts b/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalJzodSchema.ts index b95d2041..103516b7 100644 --- a/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalJzodSchema.ts +++ b/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalJzodSchema.ts @@ -1714,6 +1714,163 @@ export const miroirFundamentalJzodSchema = { } } }, + "deployment": { + "type": "object", + "definition": { + "uuid": { + "type": "simpleType", + "definition": "string", + "validations": [ + { + "type": "uuid" + } + ], + "extra": { + "id": 1, + "defaultLabel": "Uuid", + "editable": false + } + }, + "parentName": { + "type": "simpleType", + "definition": "string", + "optional": true, + "extra": { + "id": 2, + "defaultLabel": "Entity Name", + "editable": false + } + }, + "parentUuid": { + "type": "simpleType", + "definition": "string", + "validations": [ + { + "type": "uuid" + } + ], + "extra": { + "id": 3, + "defaultLabel": "Entity Uuid", + "editable": false + } + }, + "parentDefinitionVersionUuid": { + "type": "simpleType", + "definition": "string", + "optional": true, + "validations": [ + { + "type": "uuid" + } + ], + "extra": { + "id": 4, + "defaultLabel": "Entity Definition Version Uuid", + "editable": false + } + }, + "name": { + "type": "simpleType", + "definition": "string", + "extra": { + "id": 5, + "defaultLabel": "Name", + "editable": true + } + }, + "defaultLabel": { + "type": "simpleType", + "definition": "string", + "extra": { + "id": 6, + "defaultLabel": "Default Label", + "editable": true + } + }, + "description": { + "type": "simpleType", + "definition": "string", + "optional": true, + "extra": { + "id": 7, + "defaultLabel": "Description", + "editable": true + } + }, + "application": { + "type": "simpleType", + "definition": "string", + "validations": [ + { + "type": "uuid" + } + ], + "extra": { + "id": 8, + "defaultLabel": "Application", + "description": "The Application of the Branch.", + "targetEntity": "25d935e7-9e93-42c2-aade-0472b883492b", + "editable": false + } + }, + "bundle": { + "type": "simpleType", + "definition": "string", + "validations": [ + { + "type": "uuid" + } + ], + "extra": { + "id": 8, + "defaultLabel": "Bundle", + "description": "The deployed bundle.", + "targetEntity": "", + "editable": false + } + }, + "configuration": { + "type": "schemaReference", + "optional": true, + "extra": { + "id": 9, + "defaultLabel": "Deployment Configuration", + "editable": true + }, + "definition": { + "absolutePath": "fe9b7d99-f216-44de-bb6e-60e1a1ebb739", + "relativePath": "storeUnitConfiguration" + } + }, + "model": { + "type": "schemaReference", + "optional": true, + "extra": { + "id": 9, + "defaultLabel": "Application Deployment Model", + "editable": true + }, + "definition": { + "absolutePath": "1e8dab4b-65a3-4686-922e-ce89a2d62aa9", + "relativePath": "jzodObject" + } + }, + "data": { + "type": "schemaReference", + "optional": true, + "extra": { + "id": 10, + "defaultLabel": "Application Deployment Data", + "editable": true + }, + "definition": { + "absolutePath": "1e8dab4b-65a3-4686-922e-ce89a2d62aa9", + "relativePath": "jzodObject" + } + } + } + }, "entity": { "type": "object", "definition": { @@ -5258,6 +5415,10 @@ export const miroirFundamentalJzodSchema = { "type": "literal", "definition": "FailedToDeleteStore" }, + { + "type": "literal", + "definition": "FailedToResetAndInitMiroirAndApplicationDatabase" + }, { "type": "literal", "definition": "FailedToOpenStore" @@ -7332,6 +7493,46 @@ export const miroirFundamentalJzodSchema = { } } }, + { + "type": "object", + "definition": { + "actionType": { + "type": "literal", + "definition": "storeManagementAction" + }, + "actionName": { + "type": "literal", + "definition": "resetAndInitMiroirAndApplicationDatabase" + }, + "endpoint": { + "type": "literal", + "definition": "bbd08cbb-79ff-4539-b91f-7a14f15ac55f" + }, + "deployments": { + "type": "array", + "definition": { + "type": "schemaReference", + "definition": { + "absolutePath": "fe9b7d99-f216-44de-bb6e-60e1a1ebb739", + "relativePath": "deployment" + } + } + }, + "deploymentUuid": { + "type": "simpleType", + "definition": "string", + "validations": [ + { + "type": "uuid" + } + ], + "extra": { + "defaultLabel": "Module Deployment Uuid", + "editable": false + } + } + } + }, { "type": "object", "definition": { diff --git a/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalType.ts b/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalType.ts index 8f6d5614..228d0f51 100644 --- a/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalType.ts +++ b/packages/miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalType.ts @@ -400,6 +400,20 @@ export type Bundle = { applicationVersion: ApplicationVersion; }; }; +export type Deployment = { + uuid: string; + parentName?: string | undefined; + parentUuid: string; + parentDefinitionVersionUuid?: string | undefined; + name: string; + defaultLabel: string; + description?: string | undefined; + application: string; + bundle: string; + configuration?: StoreUnitConfiguration | undefined; + model?: JzodObject | undefined; + data?: JzodObject | undefined; +}; export type Entity = { uuid: string; parentName?: string | undefined; @@ -875,7 +889,7 @@ export type ______________________________________________actions_______________ export type ActionError = { status: "error"; error: { - errorType: ("FailedToCreateStore" | "FailedToDeployModule") | "FailedToDeleteStore" | "FailedToOpenStore" | "FailedToCloseStore" | "FailedToCreateInstance" | "FailedToGetInstance" | "FailedToGetInstances"; + errorType: ("FailedToCreateStore" | "FailedToDeployModule") | "FailedToDeleteStore" | "FailedToResetAndInitMiroirAndApplicationDatabase" | "FailedToOpenStore" | "FailedToCloseStore" | "FailedToCreateInstance" | "FailedToGetInstance" | "FailedToGetInstances"; errorMessage?: string | undefined; error?: { errorMessage?: string | undefined; @@ -1192,6 +1206,12 @@ export type StoreManagementAction = { endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f"; deploymentUuid: string; configuration: StoreUnitConfiguration; +} | { + actionType: "storeManagementAction"; + actionName: "resetAndInitMiroirAndApplicationDatabase"; + endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f"; + deployments: Deployment[]; + deploymentUuid: string; } | { actionType: "storeManagementAction"; actionName: "openStore"; @@ -1302,6 +1322,7 @@ export const ______________________________________________entities_____________ export const application: z.ZodType = z.object({uuid:z.string().uuid(), parentName:z.string().optional(), parentUuid:z.string().uuid(), parentDefinitionVersionUuid:z.string().uuid().optional(), name:z.string(), defaultLabel:z.string(), description:z.string().optional(), selfApplication:z.string().uuid()}).strict(); export const applicationVersion: z.ZodType = z.object({uuid:z.string().uuid(), parentName:z.string().optional(), parentUuid:z.string().uuid(), parentDefinitionVersionUuid:z.string().uuid().optional(), name:z.string(), defaultLabel:z.string().optional(), description:z.string().optional(), type:z.string().optional(), application:z.string().uuid(), branch:z.string().uuid(), previousVersion:z.string().uuid().optional(), modelStructureMigration:z.array(z.record(z.string(),z.any())).optional(), modelCUDMigration:z.array(z.record(z.string(),z.any())).optional()}).strict(); export const bundle: z.ZodType = z.object({uuid:z.string().uuid(), parentName:z.string().optional(), parentUuid:z.string().uuid(), parentDefinitionVersionUuid:z.string().uuid(), name:z.string(), contents:z.union([z.object({type:z.literal("runtime")}).strict(), z.object({type:z.literal("development"), applicationVersion:z.lazy(() =>applicationVersion)}).strict()])}).strict(); +export const deployment: z.ZodType = z.object({uuid:z.string().uuid(), parentName:z.string().optional(), parentUuid:z.string().uuid(), parentDefinitionVersionUuid:z.string().uuid().optional(), name:z.string(), defaultLabel:z.string(), description:z.string().optional(), application:z.string().uuid(), bundle:z.string().uuid(), configuration:z.lazy(() =>storeUnitConfiguration).optional(), model:z.lazy(() =>jzodObject).optional(), data:z.lazy(() =>jzodObject).optional()}).strict(); export const entity: z.ZodType = z.object({uuid:z.string().uuid(), parentName:z.string().optional(), parentUuid:z.string().uuid(), parentDefinitionVersionUuid:z.string().uuid().optional(), conceptLevel:z.enum(["MetaModel","Model","Data"]).optional(), application:z.string().uuid().optional(), name:z.string(), author:z.string().uuid().optional(), description:z.string().optional()}).strict(); export const entityDefinition: z.ZodType = z.object({uuid:z.string().uuid(), parentName:z.string(), parentUuid:z.string().uuid(), parentDefinitionVersionUuid:z.string().uuid().optional(), name:z.string(), entityUuid:z.string().uuid(), conceptLevel:z.enum(["MetaModel","Model","Data"]).optional(), description:z.string().optional(), defaultInstanceDetailsReportUuid:z.string().uuid().optional(), viewAttributes:z.array(z.string()).optional(), jzodSchema:z.lazy(() =>jzodObject)}).strict(); export const miroirMenuItem: z.ZodType = z.object({label:z.string(), section:z.lazy(() =>applicationSection), application:z.string().uuid(), reportUuid:z.string().uuid(), instanceUuid:z.string().uuid().optional(), icon:z.string().uuid()}).strict(); @@ -1379,7 +1400,7 @@ export const domainModelGetSingleSelectQueryJzodSchemaQueryParams: z.ZodType = z.union([z.lazy(() =>domainModelGetEntityDefinitionQueryParams), z.lazy(() =>domainModelGetFetchParamJzodSchemaQueryParams), z.lazy(() =>domainModelGetSingleSelectQueryJzodSchemaQueryParams)]); export const miroirSelectorQueryParams: z.ZodType = z.union([z.lazy(() =>domainSingleSelectQueryWithDeployment), z.lazy(() =>domainModelGetSingleSelectQueryQueryParams), z.lazy(() =>domainModelGetSingleSelectObjectListQueryQueryParams), z.lazy(() =>domainManyQueriesWithDeploymentUuid), z.lazy(() =>localCacheQueryParams), z.lazy(() =>miroirCustomQueryParams), z.lazy(() =>domainModelGetEntityDefinitionQueryParams), z.lazy(() =>domainModelGetFetchParamJzodSchemaQueryParams), z.lazy(() =>domainModelGetSingleSelectQueryJzodSchemaQueryParams)]); export const ______________________________________________actions_____________________________________________: z.ZodType<______________________________________________actions_____________________________________________> = z.never(); -export const actionError: z.ZodType = z.object({status:z.literal("error"), error:z.object({errorType:z.union([z.enum(["FailedToCreateStore","FailedToDeployModule"]), z.literal("FailedToDeleteStore"), z.literal("FailedToOpenStore"), z.literal("FailedToCloseStore"), z.literal("FailedToCreateInstance"), z.literal("FailedToGetInstance"), z.literal("FailedToGetInstances")]), errorMessage:z.string().optional(), error:z.object({errorMessage:z.string().optional(), stack:z.array(z.string().optional())}).strict().optional()}).strict()}).strict(); +export const actionError: z.ZodType = z.object({status:z.literal("error"), error:z.object({errorType:z.union([z.enum(["FailedToCreateStore","FailedToDeployModule"]), z.literal("FailedToDeleteStore"), z.literal("FailedToResetAndInitMiroirAndApplicationDatabase"), z.literal("FailedToOpenStore"), z.literal("FailedToCloseStore"), z.literal("FailedToCreateInstance"), z.literal("FailedToGetInstance"), z.literal("FailedToGetInstances")]), errorMessage:z.string().optional(), error:z.object({errorMessage:z.string().optional(), stack:z.array(z.string().optional())}).strict().optional()}).strict()}).strict(); export const actionVoidSuccess: z.ZodType = z.object({status:z.literal("ok"), returnedDomainElement:z.lazy(() =>domainElementVoid)}).strict(); export const actionVoidReturnType: z.ZodType = z.union([z.lazy(() =>actionError), z.lazy(() =>actionVoidSuccess)]); export const actionEntityInstanceSuccess: z.ZodType = z.object({status:z.literal("ok"), returnedDomainElement:z.lazy(() =>domainElementEntityInstance)}).strict(); @@ -1405,7 +1426,7 @@ export const undoRedoAction: z.ZodType = z.union([z.object({acti export const transactionalInstanceAction: z.ZodType = z.object({actionType:z.literal("transactionalInstanceAction"), deploymentUuid:z.string().uuid().optional(), instanceAction:z.lazy(() =>instanceCUDAction)}).strict(); export const domainAction: z.ZodType = z.union([z.lazy(() =>undoRedoAction), z.lazy(() =>storeOrBundleAction), z.lazy(() =>modelAction), z.lazy(() =>instanceAction), z.object({actionType:z.literal("transactionalInstanceAction"), deploymentUuid:z.string().uuid().optional(), instanceAction:z.lazy(() =>instanceCUDAction)}).strict()]); export const localCacheAction: z.ZodType = z.union([z.lazy(() =>undoRedoAction), z.lazy(() =>modelAction), z.lazy(() =>instanceAction), z.lazy(() =>transactionalInstanceAction)]); -export const storeManagementAction: z.ZodType = z.union([z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("createStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), configuration:z.lazy(() =>storeUnitConfiguration), deploymentUuid:z.string().uuid()}).strict(), z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("deleteStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), deploymentUuid:z.string().uuid(), configuration:z.lazy(() =>storeUnitConfiguration)}).strict(), z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("openStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), configuration:z.record(z.string(),z.lazy(() =>storeUnitConfiguration)), deploymentUuid:z.string().uuid()}).strict(), z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("closeStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), deploymentUuid:z.string().uuid()}).strict()]); +export const storeManagementAction: z.ZodType = z.union([z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("createStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), configuration:z.lazy(() =>storeUnitConfiguration), deploymentUuid:z.string().uuid()}).strict(), z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("deleteStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), deploymentUuid:z.string().uuid(), configuration:z.lazy(() =>storeUnitConfiguration)}).strict(), z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("resetAndInitMiroirAndApplicationDatabase"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), deployments:z.array(z.lazy(() =>deployment)), deploymentUuid:z.string().uuid()}).strict(), z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("openStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), configuration:z.record(z.string(),z.lazy(() =>storeUnitConfiguration)), deploymentUuid:z.string().uuid()}).strict(), z.object({actionType:z.literal("storeManagementAction"), actionName:z.literal("closeStore"), endpoint:z.literal("bbd08cbb-79ff-4539-b91f-7a14f15ac55f"), deploymentUuid:z.string().uuid()}).strict()]); export const persistenceAction: z.ZodType = z.union([z.object({actionType:z.literal("RestPersistenceAction"), actionName:z.enum(["create","read","update","delete"]), endpoint:z.literal("a93598b3-19b6-42e8-828c-f02042d212d4"), section:z.lazy(() =>applicationSection), deploymentUuid:z.string().uuid(), parentName:z.string().optional(), parentUuid:z.string().uuid().optional(), uuid:z.string().uuid().optional(), objects:z.array(z.lazy(() =>entityInstance).optional()).optional()}).strict(), z.lazy(() =>queryAction), z.lazy(() =>bundleAction), z.lazy(() =>instanceAction), z.lazy(() =>modelAction), z.lazy(() =>storeManagementAction)]); export const restPersistenceAction: z.ZodType = z.object({actionType:z.literal("RestPersistenceAction"), actionName:z.enum(["create","read","update","delete"]), endpoint:z.literal("a93598b3-19b6-42e8-828c-f02042d212d4"), section:z.lazy(() =>applicationSection), deploymentUuid:z.string().uuid(), parentName:z.string().optional(), parentUuid:z.string().uuid().optional(), uuid:z.string().uuid().optional(), objects:z.array(z.lazy(() =>entityInstance).optional()).optional()}).strict(); export const queryAction: z.ZodType = z.object({actionType:z.literal("queryAction"), actionName:z.literal("runQuery"), endpoint:z.literal("9e404b3c-368c-40cb-be8b-e3c28550c25e"), deploymentUuid:z.string().uuid(), query:z.lazy(() =>domainManyQueriesWithDeploymentUuid)}).strict(); diff --git a/packages/miroir-core/src/3_controllers/DomainController.ts b/packages/miroir-core/src/3_controllers/DomainController.ts index 3e5c21c0..23359b1e 100644 --- a/packages/miroir-core/src/3_controllers/DomainController.ts +++ b/packages/miroir-core/src/3_controllers/DomainController.ts @@ -41,10 +41,11 @@ import { packageName } from '../constants.js'; import { getLoggerName } from '../tools'; import { Endpoint } from './Endpoint.js'; import { CallUtils } from './ErrorHandling/CallUtils.js'; -import { metaModelEntities, miroirModelEntities } from '../1_core/Model.js'; +import { defaultMiroirMetaModel, metaModelEntities, miroirModelEntities } from '../1_core/Model.js'; import { cleanLevel } from './constants.js'; import { ACTION_OK } from '../1_core/constants.js'; import { resolveContextReference } from '../2_domain/QuerySelectors.js'; +import { applicationMiroir, applicationModelBranchMiroirMasterBranch, applicationStoreBasedConfigurationMiroir, applicationVersionInitialMiroirVersion } from '../index.js'; const loggerName: string = getLoggerName(packageName, cleanLevel,"DomainController"); let log:LoggerInterface = console as any as LoggerInterface; @@ -55,6 +56,55 @@ MiroirLoggerFactory.asyncCreateLogger(loggerName).then( ); +// ################################################################################################ +async function resetAndInitMiroirAndApplicationDatabase( + domainController: DomainControllerInterface, + deployments: any[] // TODO: use Deployment Entity Type! +) { + // const deployments = [adminConfigurationDeploymentLibrary, adminConfigurationDeploymentMiroir]; + + for (const d of deployments) { + await domainController.handleAction({ + actionType: "modelAction", + actionName: "resetModel", + endpoint: "7947ae40-eb34-4149-887b-15a9021e714e", + deploymentUuid: d.uuid, + }); + } + for (const d of deployments) { + await domainController.handleAction({ + actionType: "modelAction", + actionName: "initModel", + endpoint: "7947ae40-eb34-4149-887b-15a9021e714e", + deploymentUuid: d.uuid, + params: { + dataStoreType: d.uuid == adminConfigurationDeploymentMiroir.uuid?"miroir":"app", + metaModel: defaultMiroirMetaModel, + application: applicationMiroir, + applicationDeploymentConfiguration: d, + applicationModelBranch: applicationModelBranchMiroirMasterBranch, + applicationStoreBasedConfiguration: applicationStoreBasedConfigurationMiroir, + applicationVersion: applicationVersionInitialMiroirVersion, + }, + }); + } + log.info( + "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ resetAndInitMiroirAndApplicationDatabase APPLICATION DONE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" + ); + for (const d of deployments) { + await domainController.handleAction({ + actionType: "modelAction", + actionName: "rollback", + endpoint: "7947ae40-eb34-4149-887b-15a9021e714e", + deploymentUuid: d.uuid, + }); + } +} + +// ################################################################################################ +// ################################################################################################ +// ################################################################################################ +// ################################################################################################ /** * domain level contains "business" logic related to concepts defined whithin the * application: entities, reports, reducers, users, etc. @@ -713,7 +763,33 @@ export class DomainController implements DomainControllerInterface { domainAction ); } - case 'storeManagementAction': + case 'storeManagementAction': { + if (domainAction.actionName == "resetAndInitMiroirAndApplicationDatabase") { + await resetAndInitMiroirAndApplicationDatabase(this,domainAction.deployments) + } else { + try { + await this.callUtil.callPersistenceAction( + {}, // context + {}, // context update + // deploymentUuid, + domainAction + ); + } catch (error) { + log.warn( + "DomainController handleAction caught exception when handling", + domainAction.actionType, + "deployment", + domainAction.deploymentUuid, + "action", + domainAction, + "exception", + error + ); + } + } + return Promise.resolve(ACTION_OK); + break; + } case 'bundleAction': { try { await this.callUtil.callPersistenceAction( @@ -722,20 +798,20 @@ export class DomainController implements DomainControllerInterface { // deploymentUuid, domainAction ); - } catch (error) { - log.warn( - "DomainController handleAction caught exception when handling", - domainAction.actionType, - "deployment", - domainAction.deploymentUuid, - "action", - domainAction, - "exception", - error - ); - } - return Promise.resolve(ACTION_OK); - break; + } catch (error) { + log.warn( + "DomainController handleAction caught exception when handling", + domainAction.actionType, + "deployment", + domainAction.deploymentUuid, + "action", + domainAction, + "exception", + error + ); + } + return Promise.resolve(ACTION_OK); + break; } case "undoRedoAction": { return this.handleDomainUndoRedoAction( diff --git a/packages/miroir-core/src/assets/miroir_data/3d8da4d4-8f76-4bb4-9212-14869d81c00c/bbd08cbb-79ff-4539-b91f-7a14f15ac55f.json b/packages/miroir-core/src/assets/miroir_data/3d8da4d4-8f76-4bb4-9212-14869d81c00c/bbd08cbb-79ff-4539-b91f-7a14f15ac55f.json index 796ae2e9..13ff27f6 100644 --- a/packages/miroir-core/src/assets/miroir_data/3d8da4d4-8f76-4bb4-9212-14869d81c00c/bbd08cbb-79ff-4539-b91f-7a14f15ac55f.json +++ b/packages/miroir-core/src/assets/miroir_data/3d8da4d4-8f76-4bb4-9212-14869d81c00c/bbd08cbb-79ff-4539-b91f-7a14f15ac55f.json @@ -31,22 +31,57 @@ "actionParameters": { "type": "object", "definition": { - "actionType": {"type": "literal", "definition":"storeManagementAction"}, - "actionName": {"type": "literal", "definition":"deleteStore"}, - "endpoint": {"type": "literal", "definition":"bbd08cbb-79ff-4539-b91f-7a14f15ac55f"}, + "actionType": { "type": "literal", "definition": "storeManagementAction" }, + "actionName": { "type": "literal", "definition": "deleteStore" }, + "endpoint": { "type": "literal", "definition": "bbd08cbb-79ff-4539-b91f-7a14f15ac55f" }, "deploymentUuid": { "type": "simpleType", "definition": "string", "validations": [{ "type": "uuid" }], "extra": { "defaultLabel": "Module Deployment Uuid", "editable": false } }, - "configuration": { "type":"schemaReference", "definition": { "absolutePath": "fe9b7d99-f216-44de-bb6e-60e1a1ebb739", "relativePath": "storeUnitConfiguration" } } + "configuration": { + "type": "schemaReference", + "definition": { + "absolutePath": "fe9b7d99-f216-44de-bb6e-60e1a1ebb739", + "relativePath": "storeUnitConfiguration" + } + } } }, "actionErrors": { "type":"literal", "definition": "FailedToDeleteStore" } }, + { + "actionParameters" : { + "type": "object", + "definition": { + "actionType": { "type": "literal", "definition": "storeManagementAction" }, + "actionName": { "type": "literal", "definition": "resetAndInitMiroirAndApplicationDatabase" }, + "endpoint": { "type": "literal", "definition": "bbd08cbb-79ff-4539-b91f-7a14f15ac55f" }, + "deployments": { + "type": "array", + "definition": { + "type": "schemaReference", + "definition": { + "absolutePath": "fe9b7d99-f216-44de-bb6e-60e1a1ebb739", + "relativePath": "deployment" + } + } + }, + "deploymentUuid": { + "type": "simpleType", + "definition": "string", + "validations": [{ "type": "uuid" }], + "extra": { "defaultLabel": "Module Deployment Uuid", "editable": false } + } + } + }, + "actionErrors": { + "type":"literal", "definition": "FailedToResetAndInitMiroirAndApplicationDatabase" + } + }, { "actionParameters" : { "type": "object", diff --git a/packages/miroir-core/tests/1_core/jzod.unit.test.ts b/packages/miroir-core/tests/1_core/jzod.unit.test.ts index b0d7856c..52fb12d2 100644 --- a/packages/miroir-core/tests/1_core/jzod.unit.test.ts +++ b/packages/miroir-core/tests/1_core/jzod.unit.test.ts @@ -129,6 +129,8 @@ import entityDefinitionQueryVersionV1 from "../../src/assets/miroir_model/54b9c7 import entityDefinitionReportV1 from "../../src/assets/miroir_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/952d2c65-4da2-45c2-9394-a0920ceedfb6.json"; +import entityDefinitionDeployment from "../../src/assets/admin_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/c50240e7-c451-46c2-b60a-07b3172a5ef9.json" assert { type: "json" }; + export const defaultMiroirMetaModel: MetaModel = { configuration: [instanceConfigurationReference], entities: [ @@ -209,6 +211,7 @@ const miroirFundamentalJzodSchema: JzodSchema = getMiroirFundamentalJzodSchema( jzodSchemajzodMiroirBootstrapSchema as JzodSchema, entityDefinitionApplication as EntityDefinition, entityDefinitionApplicationVersion as EntityDefinition, + entityDefinitionDeployment as EntityDefinition, entityDefinitionEntity as EntityDefinition, entityDefinitionEntityDefinition as EntityDefinition, entityDefinitionJzodSchema as EntityDefinition, diff --git a/packages/miroir-core/tools/generate-ts-types.mjs b/packages/miroir-core/tools/generate-ts-types.mjs index d296b0b7..376738bc 100644 --- a/packages/miroir-core/tools/generate-ts-types.mjs +++ b/packages/miroir-core/tools/generate-ts-types.mjs @@ -37,6 +37,7 @@ import persistenceEndpointVersionV1 from "../src/assets/miroir_data/3d8da4d4-8f7 import jzodSchemajzodMiroirBootstrapSchema from "../src/assets/miroir_data/5e81e1b9-38be-487c-b3e5-53796c57fccf/1e8dab4b-65a3-4686-922e-ce89a2d62aa9.json" assert { type: "json" }; import entityDefinitionApplicationV1 from "../src/assets/miroir_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/9460420b-f176-4918-bd45-894ab195ffe9.json" assert { type: "json" }; import entityDefinitionApplicationVersionV1 from "../src/assets/miroir_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/27046fce-742f-4cc4-bb95-76b271f490a5.json" assert { type: "json" }; +import entityDefinitionDeployment from "../src/assets/admin_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/c50240e7-c451-46c2-b60a-07b3172a5ef9.json" assert { type: "json" }; import entityDefinitionEntity from "../src/assets/miroir_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/381ab1be-337f-4198-b1d3-f686867fc1dd.json" assert { type: "json" }; import entityDefinitionEntityDefinitionV1 from "../src/assets/miroir_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/bdd7ad43-f0fc-4716-90c1-87454c40dd95.json" assert { type: "json" }; import entityDefinitionJzodSchemaV1 from "../src/assets/miroir_model/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd/15407b85-f2c8-4a34-bfa7-89f044ba2407.json" assert { type: "json" }; @@ -61,6 +62,7 @@ const miroirFundamentalJzodSchema = jzodSchemajzodMiroirBootstrapSchema, entityDefinitionApplicationV1, entityDefinitionApplicationVersionV1, + entityDefinitionDeployment, entityDefinitionEntity, entityDefinitionEntityDefinitionV1, entityDefinitionJzodSchemaV1, diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/components/RootComponent.tsx b/packages/miroir-standalone-app/src/miroir-fwk/4_view/components/RootComponent.tsx index 67400e56..96086400 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/components/RootComponent.tsx +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/components/RootComponent.tsx @@ -23,6 +23,7 @@ import { entityDefinitionApplicationVersion, entityDefinitionBundleV1, entityDefinitionCommit, + entityDefinitionDeployment, entityDefinitionEntity, entityDefinitionEntityDefinition, entityDefinitionJzodSchema, @@ -169,6 +170,7 @@ export const RootComponent = (props: RootComponentProps) => { jzodSchemajzodMiroirBootstrapSchema as JzodSchema, entityDefinitionApplication as EntityDefinition, entityDefinitionApplicationVersion as EntityDefinition, + entityDefinitionDeployment as EntityDefinition, entityDefinitionEntity as EntityDefinition, entityDefinitionEntityDefinition as EntityDefinition, entityDefinitionJzodSchema as EntityDefinition, diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/routes/Tools.tsx b/packages/miroir-standalone-app/src/miroir-fwk/4_view/routes/Tools.tsx index e6c31020..e0a53fef 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/routes/Tools.tsx +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/routes/Tools.tsx @@ -16,6 +16,7 @@ import { MiroirConfigClient, MiroirConfigForRestClient, MiroirLoggerFactory, + ObjectTemplate, QueryObjectReference, StoreUnitConfiguration, adminConfigurationDeploymentAdmin, @@ -43,6 +44,7 @@ import { import { JzodElementEditor } from "../components/JzodElementEditor"; import { cleanLevel } from "../constants"; import { adminConfigurationDeploymentParis, applicationParis } from './ReportPage'; +import { Deployment } from 'miroir-core/src/0_interfaces/1_core/preprocessor-generated/miroirFundamentalType'; const loggerName: string = getLoggerName(packageName, cleanLevel,"ToolsPage"); @@ -253,18 +255,8 @@ export const ToolsPage: React.FC = ( async (values: any /* actually follows formJzodSchema */, formikFunctions:{ setSubmitting:any, setErrors:any }) => { try { // Send values somehow - // if (props.onCreateFormObject) { - // log.info("onSubmit formik onCreateFormObject", values) - // await props.onCreateFormObject(values) - // await props.onSubmit(values); - // } else { - // log.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ onSubmit formik", values) setformHelperState(values); - // setdialogOuterFormObject(values) - // await handleAddObjectDialogFormSubmit(values,"param") - // } - // } as MiroirConfig; // create new Application // deploy new Application const newApplicationName = values.applicationName; @@ -281,7 +273,7 @@ export const ToolsPage: React.FC = ( "emulatedServerType": "sql", "connectionString":"postgres://postgres:postgres@localhost:5432/postgres", "schema": { - templateType: "queryParameterReference", + templateType: "parameterReference", referenceName: "newApplicationName", applyFunction: (a:string) => (a + "Model") } @@ -290,7 +282,7 @@ export const ToolsPage: React.FC = ( "emulatedServerType": "sql", "connectionString":"postgres://postgres:postgres@localhost:5432/postgres", "schema": { - templateType: "queryParameterReference", + templateType: "parameterReference", referenceName: "newApplicationName", applyFunction: (a:string) => (a + "Data") } @@ -328,12 +320,17 @@ export const ToolsPage: React.FC = ( }; const actionParams = { + adminConfigurationDeploymentAdmin, newApplicationName, newAdminAppApplicationUuid, newSelfApplicationUuid, newDeploymentUuid, newDeploymentStoreConfiguration, submitMiroirConfig, + entityApplication, + entityApplicationForAdmin, + entityDeployment, + entityMenu, } @@ -346,13 +343,12 @@ export const ToolsPage: React.FC = ( submitMiroirConfig ); // await runActionTemplate(domainController, undefined, actionParams); - await runActionTemplate(domainController, + await runActionTemplate(domainController, { actionType: "storeManagementAction", actionName: "openStore", endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f", configuration: { - // [newDeploymentUuid]: newDeploymentStoreConfiguration templateType: "fullObjectTemplate", definition: [ [ @@ -360,142 +356,295 @@ export const ToolsPage: React.FC = ( templateType: "parameterReference", referenceName: "newDeploymentUuid" }, - { - templateType: "parameterReference", - referenceName: "newDeploymentStoreConfigurationTemplate" - }, + newDeploymentStoreConfigurationTemplate, ] ] - // [newDeploymentUuid]: newDeploymentStoreConfigurationTemplate }, - // configuration: { - // // [newDeploymentUuid]: newDeploymentStoreConfiguration - // [newDeploymentUuid]: newDeploymentStoreConfigurationTemplate - // }, - // configuration: (actionParams.submitMiroirConfig.client as MiroirConfigForRestClient).serverConfig - // .storeSectionConfiguration, - // deploymentUuid: actionParams.newDeploymentUuid, deploymentUuid: { - templateType: "queryParameterReference", + templateType: "parameterReference", referenceName: "newDeploymentUuid" } } , actionParams); - // await domainController.handleAction({ - // actionType: "storeManagementAction", - // actionName: "openStore", - // endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f", - // configuration: (submitMiroirConfig.client as MiroirConfigForRestClient).serverConfig.storeSectionConfiguration, - // deploymentUuid: newDeploymentUuid, - // }); log.info("store opened with uuid", newDeploymentUuid) - const createdApplicationStore = await domainController?.handleAction( + const createdApplicationStore = await runActionTemplate(domainController, { actionType: "storeManagementAction", actionName: "createStore", endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f", - deploymentUuid: newDeploymentUuid, - configuration: (submitMiroirConfig.client as MiroirConfigForRestClient).serverConfig.storeSectionConfiguration[newDeploymentUuid] + deploymentUuid: { + templateType: "parameterReference", + referenceName: "newDeploymentUuid" + }, + configuration: newDeploymentStoreConfigurationTemplate } - ) + , actionParams); + if (createdApplicationStore?.status != "ok") { log.error('Error afterEach',JSON.stringify(createdApplicationStore, null, 2)); } log.info("application store created with uuid", newDeploymentUuid) - const newApplicationForAdmin: Application = { - "uuid": newAdminAppApplicationUuid, - "parentName": entityApplicationForAdmin.name, - "parentUuid": entityApplicationForAdmin.uuid, - "name": newApplicationName, - "defaultLabel": `The ${newApplicationName} application.`, - "description": `This application contains the ${newApplicationName} model and data`, - "selfApplication": newSelfApplicationUuid, - } - const newSelfApplication: Application = { - "uuid": newSelfApplicationUuid, + const newApplicationForAdminTemplate: any = { + "uuid": { + templateType: "parameterReference", + referenceName: "newAdminAppApplicationUuid" + }, + "parentName": { + templateType: "mustacheStringTemplate", + definition: "{{entityApplicationForAdmin.name}}" + }, + "parentUuid": { + templateType: "mustacheStringTemplate", + definition: "{{entityApplicationForAdmin.uuid}}" + }, + "name": { + templateType: "parameterReference", + referenceName: "newApplicationName" + }, + "defaultLabel": { + templateType: "mustacheStringTemplate", + definition: "The {{newApplicationName}} application." + }, + "description": { + templateType: "mustacheStringTemplate", + definition: "This application contains the {{newApplicationName}} model and data" + }, + "selfApplication": { + templateType: "parameterReference", + referenceName: "newSelfApplicationUuid" + }, + }; + + const newApplicationForAdmin: Application = objectTemplateToObject( + "ROOT", + newApplicationForAdminTemplate, + actionParams, + undefined + ) + // const newApplicationForAdmin: Application = { + // "uuid": newAdminAppApplicationUuid, + // "parentName": entityApplicationForAdmin.name, + // "parentUuid": entityApplicationForAdmin.uuid, + // "name": newApplicationName, + // "defaultLabel": `The ${newApplicationName} application.`, + // "description": `This application contains the ${newApplicationName} model and data`, + // "selfApplication": newSelfApplicationUuid, + // } + log.info("newApplicationForAdmin", newApplicationForAdmin); + const newSelfApplicationTemplate: any = { + "uuid": { + templateType: "parameterReference", + referenceName: "newSelfApplicationUuid" + }, "parentName": "Application", "parentUuid": "a659d350-dd97-4da9-91de-524fa01745dc", - "name": newApplicationName, - "defaultLabel": `The ${newApplicationName} application.`, - "description": `This application contains the ${newApplicationName} model and data`, - "selfApplication": newSelfApplicationUuid, + "name": { + templateType: "parameterReference", + referenceName: "newApplicationName" + }, + "defaultLabel": { + templateType: "mustacheStringTemplate", + definition: "The {{newApplicationName}} application." + }, + "description": { + templateType: "mustacheStringTemplate", + definition: "This application contains the {{newApplicationName}} model and data" + }, + "selfApplication": { + templateType: "parameterReference", + referenceName: "newSelfApplicationUuid" + }, + }; + + const newSelfApplication: Application = objectTemplateToObject( + "ROOT", + newSelfApplicationTemplate, + actionParams, + undefined + ) + log.info("newSelfApplication", newSelfApplication); + + const newDeploymentTemplate: any = { + "uuid": { + templateType: "parameterReference", + referenceName: "newDeploymentUuid" + }, + "parentName": { + templateType: "mustacheStringTemplate", + definition: "{{entityDeployment.name}}" + }, + "parentUuid": { + templateType: "mustacheStringTemplate", + definition: "{{entityDeployment.uuid}}" + }, + "name": { + templateType: "mustacheStringTemplate", + definition: "{{newApplicationName}}ApplicationSqlDeployment" + }, + "defaultLabel": { + templateType: "mustacheStringTemplate", + definition: "{{newApplicationName}}ApplicationSqlDeployment" + }, + "application": { + templateType: "mustacheStringTemplate", + definition: "{{newApplicationForAdmin.uuid}}" + }, + "description": { + templateType: "mustacheStringTemplate", + definition: "The default Sql Deployment for Application {{newApplicationName}}" + }, + "configuration": { + templateType: "parameterReference", + referenceName: "newSelfApplicationUuid" + }, } - const newDeployment = { - parentName:entityDeployment.name, - parentUuid:entityDeployment.uuid, - uuid: newDeploymentUuid, - "name": newApplicationName + "ApplicationSqlDeployment", - "defaultLabel": newApplicationName + "ApplicationSqlDeployment", - "application": newApplicationForAdmin.uuid, - "description": "The default Sql Deployment for Application " + newApplicationName, - "configuration": newDeploymentStoreConfiguration - } as EntityInstance + const newDeployment = objectTemplateToObject( + "ROOT", + newDeploymentTemplate, + {...actionParams, newApplicationForAdmin}, + undefined + ) as EntityInstance + log.info("found newDeployment", newDeployment); + + const resetAndInitActionTemplate: any = { + endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f", + actionType: "storeManagementAction", + actionName: "resetAndInitMiroirAndApplicationDatabase", + deploymentUuid: "", + deployments: [ + { + templateType: "parameterReference", + referenceName: "newDeployment" + } + ], + } + + const resetAndInitAction: DomainAction = objectTemplateToObject( + "ROOT", + resetAndInitActionTemplate, + {...actionParams, newDeployment}, + undefined + ) + log.info("found resetAndInitAction", resetAndInitAction); // create storage structures for Miroir metamodel Entities in new application deployment - await resetAndInitMiroirAndApplicationDatabase(domainController, [ newDeployment ]) + await domainController.handleAction(resetAndInitAction); + // await resetAndInitMiroirAndApplicationDatabase(domainController, [ newDeployment ]) log.info("application store initialized, deployment uuid", newDeploymentUuid) // create self Application in new Application model // TODO: do it in a transaction?? - const createSelfApplicationAction: InstanceAction = { + const createSelfApplicationActionTemplate: any = { actionType: 'instanceAction', actionName: "createInstance", applicationSection: "model", - deploymentUuid: newDeploymentUuid, + deploymentUuid: { + templateType: "parameterReference", + referenceName: "newDeploymentUuid" + }, endpoint: "ed520de4-55a9-4550-ac50-b1b713b72a89", objects:[ { - parentName:entityApplication.name, - parentUuid:entityApplication.uuid, + parentName: { + templateType: "mustacheStringTemplate", + definition: "{{entityApplication.name}}" + }, + parentUuid: { + templateType: "mustacheStringTemplate", + definition: "{{entityApplication.uuid}}" + }, applicationSection:'model', - instances: [ newSelfApplication ], + instances: [ + { + templateType: "parameterReference", + referenceName: "newSelfApplication" + } + ], } ] - }; + } + + const createSelfApplicationAction: InstanceAction = objectTemplateToObject( + "ROOT", + createSelfApplicationActionTemplate, + {...actionParams, newSelfApplication}, + undefined + ) + log.info("found createSelfApplicationAction", createSelfApplicationAction); await domainController.handleAction(createSelfApplicationAction); log.info("application self Application instance created for deployment uuid", newDeploymentUuid, createSelfApplicationAction) // create new Application default Menu - const newApplicationMenu: Menu = { + const newApplicationMenuTemplate: any = { "uuid": "84c178cc-1b1b-497a-a035-9b3d756bb085", "parentName": "Menu", "parentUuid": "dde4c883-ae6d-47c3-b6df-26bc6e3c1842", - "name": newApplicationName + "Menu", + "name": { + templateType: "mustacheStringTemplate", + definition: "{{newApplicationName}}Menu" + }, "defaultLabel": "Meta-Model", - "description": `This is the default menu allowing to explore the ${newApplicationName} Application.`, + "description": { + templateType: "mustacheStringTemplate", + definition: "This is the default menu allowing to explore the {{newApplicationName}} Application" + }, "definition": { "menuType": "complexMenu", "definition": [ { - "title": newApplicationName, - "label": newApplicationName, + "title": { + templateType: "parameterReference", + referenceName: "newApplicationName" + }, + "label": { + templateType: "parameterReference", + referenceName: "newApplicationName" + }, "items": [ { - "label": newApplicationName + " Entities", + "label": { + templateType: "mustacheStringTemplate", + definition: "{{newApplicationName}} Entities" + }, "section": "model", - "application": newDeploymentUuid, + "application": { + templateType: "parameterReference", + referenceName: "newDeploymentUuid" + }, "reportUuid": "c9ea3359-690c-4620-9603-b5b402e4a2b9", "icon": "category" }, { - "label": newApplicationName + " Entity Definitions", + "label": { + templateType: "mustacheStringTemplate", + definition: "{{newApplicationName}} Entity Definitions" + }, "section": "model", - "application": newDeploymentUuid, + "application": { + templateType: "parameterReference", + referenceName: "newDeploymentUuid" + }, "reportUuid": "f9aff35d-8636-4519-8361-c7648e0ddc68", "icon": "category" }, { - "label": newApplicationName + " Reports", + "label": { + templateType: "mustacheStringTemplate", + definition: "{{newApplicationName}} Reports" + }, "section": "model", - "application": newDeploymentUuid, + "application": { + templateType: "parameterReference", + referenceName: "newDeploymentUuid" + }, "reportUuid": "1fc7e12e-90f2-4c0a-8ed9-ed35ce3a7855", "icon": "list" } @@ -504,42 +653,164 @@ export const ToolsPage: React.FC = ( ] } } + const newApplicationMenu: Menu = objectTemplateToObject( + "ROOT", + newApplicationMenuTemplate, + actionParams, + undefined + ) + log.info("found newApplicationMenu", newApplicationMenu); + + // const newApplicationMenu: Menu = { + // "uuid": "84c178cc-1b1b-497a-a035-9b3d756bb085", + // "parentName": "Menu", + // "parentUuid": "dde4c883-ae6d-47c3-b6df-26bc6e3c1842", + // "name": newApplicationName + "Menu", + // "defaultLabel": "Meta-Model", + // "description": `This is the default menu allowing to explore the ${newApplicationName} Application.`, + // "definition": { + // "menuType": "complexMenu", + // "definition": [ + // { + // "title": newApplicationName, + // "label": newApplicationName, + // "items": [ + // { + // "label": newApplicationName + " Entities", + // "section": "model", + // "application": newDeploymentUuid, + // "reportUuid": "c9ea3359-690c-4620-9603-b5b402e4a2b9", + // "icon": "category" + // }, + // { + // "label": newApplicationName + " Entity Definitions", + // "section": "model", + // "application": newDeploymentUuid, + // "reportUuid": "f9aff35d-8636-4519-8361-c7648e0ddc68", + // "icon": "category" + // }, + // { + // "label": newApplicationName + " Reports", + // "section": "model", + // "application": newDeploymentUuid, + // "reportUuid": "1fc7e12e-90f2-4c0a-8ed9-ed35ce3a7855", + // "icon": "list" + // } + // ] + // } + // ] + // } + // } // TODO: do it in a transaction?? - const createNewApplicationMenuAction: InstanceAction = { + const createNewApplicationMenuActionTemplate: any = { actionType: 'instanceAction', actionName: "createInstance", applicationSection: "model", - deploymentUuid: newDeploymentUuid, + deploymentUuid: { + templateType: "parameterReference", + referenceName: "newDeploymentUuid" + }, endpoint: "ed520de4-55a9-4550-ac50-b1b713b72a89", objects:[ { - parentName:entityMenu.name, - parentUuid:entityMenu.uuid, + parentName: { + templateType: "mustacheStringTemplate", + definition: "{{entityMenu.name}}" + }, + parentUuid: { + templateType: "mustacheStringTemplate", + definition: "{{entityMenu.uuid}}" + }, applicationSection:'model', - instances: [ newApplicationMenu ], + instances: [ + { + templateType: "parameterReference", + referenceName: "newApplicationMenu" + } + ], } ] }; + const createNewApplicationMenuAction: InstanceAction = objectTemplateToObject( + "ROOT", + createNewApplicationMenuActionTemplate, + {...actionParams, newApplicationMenu}, + undefined + ) + log.info("found newApplicationMenu", newApplicationMenu); + + // const createNewApplicationMenuAction: InstanceAction = { + // actionType: 'instanceAction', + // actionName: "createInstance", + // applicationSection: "model", + // deploymentUuid: newDeploymentUuid, + // endpoint: "ed520de4-55a9-4550-ac50-b1b713b72a89", + // objects:[ + // { + // parentName:entityMenu.name, + // parentUuid:entityMenu.uuid, + // applicationSection:'model', + // instances: [ newApplicationMenu ], + // } + // ] + // }; await domainController.handleAction(createNewApplicationMenuAction); // #################### ADMIN // create application in Admin application deployment - const createApplicationForAdminAction: InstanceAction = { + const createApplicationForAdminActionTemplate: any = { actionType: 'instanceAction', actionName: "createInstance", applicationSection: "data", - deploymentUuid: adminConfigurationDeploymentAdmin.uuid, + deploymentUuid: { + templateType: "mustacheStringTemplate", + definition: "{{adminConfigurationDeploymentAdmin.uuid}}" + }, endpoint: "ed520de4-55a9-4550-ac50-b1b713b72a89", objects:[ { - parentName:entityApplicationForAdmin.name, - parentUuid:entityApplicationForAdmin.uuid, + parentName: { + templateType: "mustacheStringTemplate", + definition: "{{entityApplicationForAdmin.name}}" + }, + parentUuid: { + templateType: "mustacheStringTemplate", + definition: "{{entityApplicationForAdmin.uuid}}" + }, applicationSection:'data', - instances: [ newApplicationForAdmin ], + instances: [ + { + templateType: "parameterReference", + referenceName: "newApplicationForAdmin" + } + ], } ] }; + const createApplicationForAdminAction: InstanceAction = objectTemplateToObject( + "ROOT", + createApplicationForAdminActionTemplate, + {...actionParams, newApplicationForAdmin}, + undefined + ) + log.info("found createApplicationForAdminAction", createApplicationForAdminAction); + + // const createApplicationForAdminAction: InstanceAction = { + // actionType: 'instanceAction', + // actionName: "createInstance", + // applicationSection: "data", + // deploymentUuid: adminConfigurationDeploymentAdmin.uuid, + // endpoint: "ed520de4-55a9-4550-ac50-b1b713b72a89", + // objects:[ + // { + // parentName:entityApplicationForAdmin.name, + // parentUuid:entityApplicationForAdmin.uuid, + // applicationSection:'data', + // instances: [ newApplicationForAdmin ], + // } + // ] + // }; await domainController.handleAction(createApplicationForAdminAction); @@ -547,21 +818,57 @@ export const ToolsPage: React.FC = ( // add Deployment to Admin application deployment - const createAdminDeploymentAction: InstanceAction = { + const createAdminDeploymentActionTemplate: any = { actionType: 'instanceAction', actionName: "createInstance", applicationSection: "data", - deploymentUuid: adminConfigurationDeploymentAdmin.uuid, + deploymentUuid: { + templateType: "mustacheStringTemplate", + definition: "{{adminConfigurationDeploymentAdmin.uuid}}" + }, endpoint: "ed520de4-55a9-4550-ac50-b1b713b72a89", objects:[ { - parentName:entityDeployment.name, - parentUuid:entityDeployment.uuid, + parentName: { + templateType: "mustacheStringTemplate", + definition: "{{entityDeployment.name}}" + }, + parentUuid: { + templateType: "mustacheStringTemplate", + definition: "{{entityDeployment.uuid}}" + }, applicationSection:'data', - instances: [ newDeployment ], + instances: [ + { + templateType: "parameterReference", + referenceName: "newDeployment" + } + ], } ] }; + const createAdminDeploymentAction: InstanceAction = objectTemplateToObject( + "ROOT", + createAdminDeploymentActionTemplate, + {...actionParams, newDeployment}, + undefined + ) + log.info("found createAdminDeploymentAction", createAdminDeploymentAction); + // const createAdminDeploymentAction: InstanceAction = { + // actionType: 'instanceAction', + // actionName: "createInstance", + // applicationSection: "data", + // deploymentUuid: adminConfigurationDeploymentAdmin.uuid, + // endpoint: "ed520de4-55a9-4550-ac50-b1b713b72a89", + // objects:[ + // { + // parentName:entityDeployment.name, + // parentUuid:entityDeployment.uuid, + // applicationSection:'data', + // instances: [ newDeployment ], + // } + // ] + // }; await domainController.handleAction(createAdminDeploymentAction); log.info("created Deployment instance in Admin App deployment", createAdminDeploymentAction)