Skip to content

Commit

Permalink
EXPERIMENT: create & deploy a new Application #26. Added "Admin" appl…
Browse files Browse the repository at this point in the history
…ication, renamed Meta-model "Application" to "SelfApplication"
  • Loading branch information
miroir-framework committed Apr 22, 2024
1 parent 3a1bf03 commit e45e1c5
Show file tree
Hide file tree
Showing 34 changed files with 664 additions and 72 deletions.
15 changes: 14 additions & 1 deletion packages/miroir-core/src/1_core/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import instanceConfigurationReference from '../assets/miroir_data/7990c0c9-86c3-
// import { Report, } from "../0_interfaces/1_core/Report.js";
import { JzodSchemaDefinition } from "../0_interfaces/1_core/JzodSchemaDefinition.js";
import { Entity, EntityDefinition, JzodSchema, Menu, MetaModel, Report } from "../0_interfaces/1_core/preprocessor-generated/miroirFundamentalType";
import { applicationDeploymentLibrary, applicationDeploymentMiroir, entityDefinitionMenu, entityMenu, menuDefaultMiroir, reportMenuList } from '..';
import { applicationDeploymentAdmin, applicationDeploymentLibrary, applicationDeploymentMiroir, entityDefinitionMenu, entityMenu, menuDefaultMiroir, reportMenuList } from '..';
import { DeploymentUuidToReportsEntitiesDefinitionsMapping } from '../0_interfaces/1_core/Model';

// TODO: define current configuration!
Expand Down Expand Up @@ -173,6 +173,7 @@ const metaModelReports = [reportEntityList.uuid, reportEntityDefinitionList.uuid
export function getDeploymentUuidToReportsEntitiesDefinitionsMapping(
miroirMetaModel: MetaModel,
libraryAppModel: MetaModel,
adminAppModel: MetaModel,
):DeploymentUuidToReportsEntitiesDefinitionsMapping {
return { // displayedDeploymentDefinition, displayedApplicationSection
[applicationDeploymentMiroir.uuid]: {
Expand Down Expand Up @@ -203,5 +204,17 @@ export function getDeploymentUuidToReportsEntitiesDefinitionsMapping(
entityDefinitions: libraryAppModel.entityDefinitions,
},
},
[applicationDeploymentAdmin.uuid]: {
"model": {
availableReports: miroirMetaModel.reports,
entities: miroirMetaModel.entities,
entityDefinitions: miroirMetaModel.entityDefinitions,
},
"data": {
availableReports: adminAppModel.reports,
entities: adminAppModel.entities,
entityDefinitions: adminAppModel.entityDefinitions,
},
},
}
}
10 changes: 7 additions & 3 deletions packages/miroir-core/src/2_domain/DomainDataAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ export function selectCurrentDeploymentModel(
):DomainStateMetaModelSelector {
return (domainState:DomainState):MetaModel => {
log.info('selectCurrentDeploymentModel for deploymentUuid', deploymentUuid, 'existing entities:', Object.keys(domainState))
if (deploymentUuid == applicationDeploymentLibrary.uuid) {
if (!deploymentUuid) {
throw new Error("selectCurrentDeploymentModel for deploymentUuid undefined");

}
if (deploymentUuid == applicationDeploymentMiroir.uuid) {
return defaultMiroirMetaModel;
} else {
// log.info('selectEntityInstances for entityUuid', parentUuid, 'existing instances:', Object.keys(domainState[parentUuid]))
return ({
entities: (
Expand Down Expand Up @@ -122,8 +128,6 @@ export function selectCurrentDeploymentModel(
),
applicationVersionCrossEntityDefinition: [],
})
} else {
return defaultMiroirMetaModel;
}
}
}
Expand Down
47 changes: 31 additions & 16 deletions packages/miroir-core/src/3_controllers/ActionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import applicationDeploymentMiroir from "../assets/miroir_data/35c5608a-7678-4f0

import { startLocalPersistenceStoreControllers } from "../4_services/PersistenceStoreControllerTools.js";
import { ACTION_OK } from "../1_core/constants.js";
import { defaultMiroirMetaModel } from "../1_core/Model.js";

const loggerName: string = getLoggerName(packageName, cleanLevel, "ActionRunner");
let log: LoggerInterface = console as any as LoggerInterface;
Expand Down Expand Up @@ -190,24 +191,38 @@ export async function storeActionOrBundleActionStoreRunner(

// TODO: NOT CLEAN, IMPLEMENTATION-DEPENDENT, METHOD SHOULD BE INJECTED
// TODO: addPersistenceStoreController takes deploymentUuid, not ApplicationSection as 1st parameter!
await persistenceStoreControllerManager.deletePersistenceStoreController(applicationDeploymentMiroir.uuid);
await persistenceStoreControllerManager.deletePersistenceStoreController(applicationDeploymentLibrary.uuid);
await persistenceStoreControllerManager.addPersistenceStoreController(
applicationDeploymentMiroir.uuid,
action.configuration[applicationDeploymentMiroir.uuid]
);
await persistenceStoreControllerManager.addPersistenceStoreController(
applicationDeploymentLibrary.uuid,
action.configuration[applicationDeploymentLibrary.uuid]
);
// }
const localMiroirPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentMiroir.uuid);
const localAppPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentLibrary.uuid);
if (!localMiroirPersistenceStoreController || !localAppPersistenceStoreController) {
throw new Error("could not find controller:" + localMiroirPersistenceStoreController + " " + localAppPersistenceStoreController);
for (const deployment of Object.entries(action.configuration)) {
await persistenceStoreControllerManager.deletePersistenceStoreController(deployment[0]);
await persistenceStoreControllerManager.addPersistenceStoreController(
deployment[0],
deployment[1]
);

const localPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(deployment[0]);
// await startLocalPersistenceStoreControllers(localMiroirPersistenceStoreController, localAppPersistenceStoreController);
await localPersistenceStoreController?.open();
await localPersistenceStoreController?.bootFromPersistedState(defaultMiroirMetaModel.entities,defaultMiroirMetaModel.entityDefinitions);

log.info("storeActionOrBundleActionStoreRunner openStore for deployment",deployment[0], "DONE!", persistenceStoreControllerManager.getPersistenceStoreControllers());
}
// await persistenceStoreControllerManager.deletePersistenceStoreController(applicationDeploymentMiroir.uuid);
// await persistenceStoreControllerManager.deletePersistenceStoreController(applicationDeploymentLibrary.uuid);
// await persistenceStoreControllerManager.addPersistenceStoreController(
// applicationDeploymentMiroir.uuid,
// action.configuration[applicationDeploymentMiroir.uuid]
// );
// await persistenceStoreControllerManager.addPersistenceStoreController(
// applicationDeploymentLibrary.uuid,
// action.configuration[applicationDeploymentLibrary.uuid]
// );
// // }
// const localMiroirPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentMiroir.uuid);
// const localAppPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentLibrary.uuid);
// if (!localMiroirPersistenceStoreController || !localAppPersistenceStoreController) {
// throw new Error("could not find controller:" + localMiroirPersistenceStoreController + " " + localAppPersistenceStoreController);
// }

await startLocalPersistenceStoreControllers(localMiroirPersistenceStoreController, localAppPersistenceStoreController);
// await startLocalPersistenceStoreControllers(localMiroirPersistenceStoreController, localAppPersistenceStoreController);

log.info("storeActionOrBundleActionStoreRunner openStore DONE!", persistenceStoreControllerManager.getPersistenceStoreControllers());

Expand Down
65 changes: 37 additions & 28 deletions packages/miroir-core/src/4_services/RestServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ export async function restMethodGetHandler
const parentUuid: string =
typeof params["parentUuid"] == "string" ? params["parentUuid"] : params["parentUuid"][0];

const localMiroirPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentMiroir.uuid);
const localAppPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentLibrary.uuid);
if (!localMiroirPersistenceStoreController || !localAppPersistenceStoreController) {
throw new Error("restMethodGetHandler could not find controller:" + localMiroirPersistenceStoreController + " " + localAppPersistenceStoreController);
}

const targetPersistenceStoreController =
deploymentUuid == applicationDeploymentLibrary.uuid ? localAppPersistenceStoreController : localMiroirPersistenceStoreController;
// const targetProxy = deploymentUuid == applicationDeploymentLibrary.uuid?libraryAppFileSystemDataStore:miroirAppSqlServerProxy;
const localPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(
deploymentUuid
);
// const domainController = persistenceStoreControllerManager.getDomainController();
if (!localPersistenceStoreController) {
throw new Error("restMethodGetHandler could not find controller for deployment:" + deploymentUuid);
}

const targetPersistenceStoreController = localPersistenceStoreController
log.info(
"restMethodGetHandler get CRUD/ using",
// (targetPersistenceStoreController as any)["applicationName"],
Expand Down Expand Up @@ -315,32 +315,41 @@ export async function queryHandler(
// const query: DomainManyQueriesWithDeploymentUuid = body.query as DomainManyQueriesWithDeploymentUuid ;
const queryAction: QueryAction = body as QueryAction ;

const localMiroirPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentMiroir.uuid);
const localAppPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(applicationDeploymentLibrary.uuid);
const deploymentUuid = params.deploymentUuid
const localPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(
deploymentUuid
);
// const localMiroirPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(
// applicationDeploymentMiroir.uuid
// );
// const localAppPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(
// applicationDeploymentLibrary.uuid
// );
const domainController = persistenceStoreControllerManager.getDomainController();
if (!localMiroirPersistenceStoreController || !localAppPersistenceStoreController) {
throw new Error("RestServer could not find controller:" + localMiroirPersistenceStoreController + " " + localAppPersistenceStoreController);
// if (!localMiroirPersistenceStoreController || !localAppPersistenceStoreController) {
if (!localPersistenceStoreController) {
throw new Error("RestServer could not find controller for deployment:" + deploymentUuid);
}
if (useDomainControllerToHandleModelAndInstanceActions) {
// we are on the server, the action has been received from remote client
switch (queryAction.deploymentUuid) {
case applicationDeploymentMiroir.uuid: {
// switch (queryAction.deploymentUuid) {
// case applicationDeploymentMiroir.uuid: {
const result = await domainController.handleQuery(queryAction)
log.info("RestServer queryHandler used applicationDeploymentMiroir domainController result=", JSON.stringify(result, undefined,2))
return continuationFunction(response)(result)
break;
}
case applicationDeploymentLibrary.uuid: {
const result = await domainController.handleQuery(queryAction)
log.info("RestServer queryHandler used applicationDeploymentLibrary domainController result=", JSON.stringify(result, undefined,2))
return continuationFunction(response)(result)
break;
}
default: {
throw new Error("RestServer queryHandler could not handle query " + queryAction + " unknown deployment uuid=" + queryAction.deploymentUuid);
break;
}
}
// break;
// }
// case applicationDeploymentLibrary.uuid: {
// const result = await domainController.handleQuery(queryAction)
// log.info("RestServer queryHandler used applicationDeploymentLibrary domainController result=", JSON.stringify(result, undefined,2))
// return continuationFunction(response)(result)
// break;
// }
// default: {
// throw new Error("RestServer queryHandler could not handle query " + queryAction + " unknown deployment uuid=" + queryAction.deploymentUuid);
// break;
// }
// }
} else {
// we're on the client, called by RestServerStub
// uses the local cache, needs to have done a Model "rollback" action on the client//, or a Model "remoteLocalCacheRollback" action on the server
Expand Down
39 changes: 39 additions & 0 deletions packages/miroir-core/src/ApplicationDeploymentAdmin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ApplicationDeploymentConfiguration } from "./0_interfaces/1_core/StorageConfiguration";

// duplicated from server!!!!!!!!
// TODO: REMOVE!!!!!
export const applicationDeploymentAdmin: ApplicationDeploymentConfiguration = {
"uuid":"18db21bf-f8d3-4f6a-8296-84b69f6dc48b",
"parentName":"ApplicationDeploymentConfiguration",
"parentUuid":"7959d814-400c-4e80-988f-a00fe582ab98",
"type":"singleNode",
"name":"AmdinApplicationPostgresDeployment",
"defaultLabel":"AdminApplicationPostgresDeployment",
"application":"f3e04bb2-005f-484b-aaf2-072232f60f2c",
"description": "The default Postgres Deployment for Application Admin",
"applicationModelLevel": "model",
// "admin": {
// "location": {
// "type": "sql",
// "side":"server",
// "connectionString": "postgres://postgres:postgres@localhost:5432/postgres",
// "schema": "library"
// }
// },
"model": {
"location": {
"type": "sql",
"side":"server",
"connectionString": "postgres://postgres:postgres@localhost:5432/postgres",
"schema": "admin"
}
},
"data": {
"location": {
"type": "sql",
"side":"server",
"connectionString": "postgres://postgres:postgres@localhost:5432/postgres",
"schema": "admin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"uuid": "f3e04bb2-005f-484b-aaf2-072232f60f2c",
"parentName":"Application",
"parentUuid":"25d935e7-9e93-42c2-aade-0472b883492b",
"name":"Admin",
"defaultLabel": "The Admin application.",
"description": "The model and data of the Admin application."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"uuid":"18db21bf-f8d3-4f6a-8296-84b69f6dc48b",
"parentName":"ApplicationDeployment",
"parentUuid":"7959d814-400c-4e80-988f-a00fe582ab98",
"type":"singleNode",
"name":"AmdinApplicationPostgresDeployment",
"defaultLabel":"AdminApplicationPostgresDeployment",
"application":"f3e04bb2-005f-484b-aaf2-072232f60f2c",
"description": "The default Postgres Deployment for Application Admin",
"applicationModelLevel": "model",
"model": {
"location": {
"type": "sql",
"side":"server",
"connectionString": "postgres://postgres:postgres@localhost:5432/postgres",
"schema": "admin"
}
},
"data": {
"location": {
"type": "sql",
"side":"server",
"connectionString": "postgres://postgres:postgres@localhost:5432/postgres",
"schema": "admin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"uuid": "ae552546-915e-410c-995b-b2451354d771",
"parentName":"ApplicationVersion",
"parentUuid":"ff3d211b-7eb6-473a-afbf-503bb70a5c26",
"name":"Initial",
"application":"55af124e-8c05-4bae-a3ef-0933d41daa92",
"branch":"",
"description": "Initial Admin application version",
"previousVersion": "",
"modelStructureMigration":[],
"modelCUDMigration":[]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid":"25d935e7-9e93-42c2-aade-0472b883492b",
"parentName":"Entity",
"parentUuid":"16dbfe28-e1d7-4f20-9ba4-c1a9873202ad",
"parentDefinitionVersionUuid": "381ab1be-337f-4198-b1d3-f686867fc1dd",
"name":"Application",
"application": "18db21bf-f8d3-4f6a-8296-84b69f6dc48b",
"conceptLevel":"Model",
"description": "An Application"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid":"7959d814-400c-4e80-988f-a00fe582ab98",
"parentName":"Entity",
"parentUuid":"16dbfe28-e1d7-4f20-9ba4-c1a9873202ad",
"parentDefinitionVersionUuid": "381ab1be-337f-4198-b1d3-f686867fc1dd",
"name":"ApplicationDeployment",
"application": "18db21bf-f8d3-4f6a-8296-84b69f6dc48b",
"conceptLevel":"Model",
"description": "An Application Deployment"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid":"ff3d211b-7eb6-473a-afbf-503bb70a5c26",
"parentName":"Entity",
"parentUuid":"16dbfe28-e1d7-4f20-9ba4-c1a9873202ad",
"parentDefinitionVersionUuid": "381ab1be-337f-4198-b1d3-f686867fc1dd",
"name":"ApplicationVersion",
"application": "18db21bf-f8d3-4f6a-8296-84b69f6dc48b",
"conceptLevel":"Model",
"description": "A Version of an Application"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"uuid": "e4488cba-b743-4b46-80e5-18c441c9882c",
"application": "f3e04bb2-005f-484b-aaf2-072232f60f2c",
"parentName":"Report",
"parentUuid":"3f2baa83-3ef7-45ce-82ea-6a43f7a8c916",
"name":"ApplicationDeploymentList",
"defaultLabel": "Application Deployments",
"definition": {
"reportParameters": {},
"fetchQuery": {
"select": {
"ApplicationDeployments": {
"queryType": "selectObjectListByEntity",
"parentName": "ApplicationDeployment",
"parentUuid": {
"referenceType": "constant",
"referenceUuid": "7959d814-400c-4e80-988f-a00fe582ab98"
}
}
}
},
"section": {
"type":"objectListReportSection",
"definition": {
"label": "Application Deployments",
"parentName": "ApplicationDeployment",
"parentUuid": "7959d814-400c-4e80-988f-a00fe582ab98",
"fetchedDataReference": "ApplicationDeployments",
"sortByAttribute": "name"
}
}
}
}
Loading

0 comments on commit e45e1c5

Please sign in to comment.