Skip to content

Commit

Permalink
EXPERIMENT: create & deploy a new Application #26. StoreAction "openS…
Browse files Browse the repository at this point in the history
…tore" only opens one store, given by action.deploymentUuid.
  • Loading branch information
miroir-framework committed Apr 25, 2024
1 parent da62a14 commit 401162d
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ export const miroirFundamentalJzodSchema = {
],
"extra": {
"id": 8,
"defaultLabel": "Description",
"defaultLabel": "Self Application",
"editable": true
}
}
Expand Down Expand Up @@ -5258,6 +5258,14 @@ export const miroirFundamentalJzodSchema = {
"type": "literal",
"definition": "FailedToDeleteStore"
},
{
"type": "literal",
"definition": "FailedToOpenStore"
},
{
"type": "literal",
"definition": "FailedToCloseStore"
},
{
"type": "literal",
"definition": "FailedToCreateInstance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ export type ______________________________________________actions_______________
export type ActionError = {
status: "error";
error: {
errorType: ("FailedToCreateStore" | "FailedToDeployModule") | "FailedToDeleteStore" | "FailedToCreateInstance" | "FailedToGetInstance" | "FailedToGetInstances";
errorType: ("FailedToCreateStore" | "FailedToDeployModule") | "FailedToDeleteStore" | "FailedToOpenStore" | "FailedToCloseStore" | "FailedToCreateInstance" | "FailedToGetInstance" | "FailedToGetInstances";
errorMessage?: string | undefined;
error?: {
errorMessage?: string | undefined;
Expand Down Expand Up @@ -1379,7 +1379,7 @@ export const domainModelGetSingleSelectQueryJzodSchemaQueryParams: z.ZodType<Dom
export const domainModelQueryJzodSchemaParams: z.ZodType<DomainModelQueryJzodSchemaParams> = z.union([z.lazy(() =>domainModelGetEntityDefinitionQueryParams), z.lazy(() =>domainModelGetFetchParamJzodSchemaQueryParams), z.lazy(() =>domainModelGetSingleSelectQueryJzodSchemaQueryParams)]);
export const miroirSelectorQueryParams: z.ZodType<MiroirSelectorQueryParams> = 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<ActionError> = z.object({status:z.literal("error"), error:z.object({errorType:z.union([z.enum(["FailedToCreateStore","FailedToDeployModule"]), z.literal("FailedToDeleteStore"), 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<ActionError> = 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 actionVoidSuccess: z.ZodType<ActionVoidSuccess> = z.object({status:z.literal("ok"), returnedDomainElement:z.lazy(() =>domainElementVoid)}).strict();
export const actionVoidReturnType: z.ZodType<ActionVoidReturnType> = z.union([z.lazy(() =>actionError), z.lazy(() =>actionVoidSuccess)]);
export const actionEntityInstanceSuccess: z.ZodType<ActionEntityInstanceSuccess> = z.object({status:z.literal("ok"), returnedDomainElement:z.lazy(() =>domainElementEntityInstance)}).strict();
Expand Down
69 changes: 32 additions & 37 deletions packages/miroir-core/src/3_controllers/ActionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ export async function storeActionOrBundleActionStoreRunner(
}

// await persistenceStoreControllerManager.addPersistenceStoreController(action.deploymentUuid, action.configuration)
const miroirModelStoreCreated: ActionReturnType = await localAppPersistenceStoreController.createStore(action.configuration.model)
const miroirDataStoreCreated: ActionReturnType = await localAppPersistenceStoreController.createStore(action.configuration.data)
const appModelStoreCreated: ActionReturnType = await localAppPersistenceStoreController.createStore(action.configuration.model)
const appDataStoreCreated: ActionReturnType = await localAppPersistenceStoreController.createStore(action.configuration.data)

if (miroirModelStoreCreated.status != "ok" || miroirDataStoreCreated.status != "ok") {
if (appModelStoreCreated.status != "ok" || appDataStoreCreated.status != "ok") {
return {
status: "error",
error: {
errorType: "FailedToCreateStore",
errorMessage:
(miroirModelStoreCreated.status != "ok" ? miroirModelStoreCreated.error : "model store created OK") +
(appModelStoreCreated.status != "ok" ? appModelStoreCreated.error : "model store created OK") +
" --- " +
(miroirDataStoreCreated.status != "ok" ? miroirDataStoreCreated.error : "data store created OK"),
(appDataStoreCreated.status != "ok" ? appDataStoreCreated.error : "data store created OK"),
},
};
}
Expand All @@ -167,18 +167,18 @@ export async function storeActionOrBundleActionStoreRunner(
}

// await persistenceStoreControllerManager.addPersistenceStoreController(action.deploymentUuid, action.configuration)
const miroirModelStoreDeleted: ActionReturnType = await localAppPersistenceStoreController.deleteStore(action.configuration.model)
const miroirDataStoreDeleted: ActionReturnType = await localAppPersistenceStoreController.deleteStore(action.configuration.data)
const appModelStoreDeleted: ActionReturnType = await localAppPersistenceStoreController.deleteStore(action.configuration.model)
const appDataStoreDeleted: ActionReturnType = await localAppPersistenceStoreController.deleteStore(action.configuration.data)

if (miroirModelStoreDeleted.status != "ok" || miroirDataStoreDeleted.status != "ok") {
if (appModelStoreDeleted.status != "ok" || appDataStoreDeleted.status != "ok") {
return {
status: "error",
error: {
errorType: "FailedToDeleteStore",
errorMessage:
(miroirModelStoreDeleted.status != "ok" ? miroirModelStoreDeleted.error : "model store deleted OK") +
(appModelStoreDeleted.status != "ok" ? appModelStoreDeleted.error : "model store deleted OK") +
" --- " +
(miroirDataStoreDeleted.status != "ok" ? miroirDataStoreDeleted.error : "data store deleted OK"),
(appDataStoreDeleted.status != "ok" ? appDataStoreDeleted.error : "data store deleted OK"),
},
};
}
Expand All @@ -189,20 +189,30 @@ export async function storeActionOrBundleActionStoreRunner(

// TODO: NOT CLEAN, IMPLEMENTATION-DEPENDENT, METHOD SHOULD BE INJECTED
// TODO: addPersistenceStoreController takes deploymentUuid, not ApplicationSection as 1st parameter!
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 localPersistenceStoreController?.open();
await localPersistenceStoreController?.bootFromPersistedState(defaultMiroirMetaModel.entities,defaultMiroirMetaModel.entityDefinitions);

log.info("storeActionOrBundleActionStoreRunner openStore for deployment",deployment[0], "DONE!", persistenceStoreControllerManager.getPersistenceStoreControllers());
// for (const deployment of Object.entries(action.configuration)) {
if (!action.configuration[action.deploymentUuid]) {
return {
status: "error",
error: {
errorType: "FailedToOpenStore",
errorMessage:"no configuration entry found for deployment uuid " + action.deploymentUuid + " configuration: " + JSON.stringify(action.configuration, null, 2)
},
};
}

await persistenceStoreControllerManager.deletePersistenceStoreController(action.deploymentUuid);
await persistenceStoreControllerManager.addPersistenceStoreController(
action.deploymentUuid,
action.configuration[action.deploymentUuid]
);

const localPersistenceStoreController = persistenceStoreControllerManager.getPersistenceStoreController(action.deploymentUuid);
await localPersistenceStoreController?.open();
await localPersistenceStoreController?.bootFromPersistedState(defaultMiroirMetaModel.entities,defaultMiroirMetaModel.entityDefinitions);

log.info("storeActionOrBundleActionStoreRunner openStore for deployment",action.deploymentUuid, "DONE!", persistenceStoreControllerManager.getPersistenceStoreControllers());
// }

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

break;
Expand All @@ -211,21 +221,6 @@ export async function storeActionOrBundleActionStoreRunner(
log.info("storeActionOrBundleActionStoreRunner closeStore");
// NOT CLEAN, IMPLEMENTATION-DEPENDENT, METHOD SHOULD BE INJECTED
await persistenceStoreControllerManager.deletePersistenceStoreController(action.deploymentUuid);
// await persistenceStoreControllerManager.deletePersistenceStoreController(adminConfigurationDeploymentMiroir.uuid);
// 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 localPersistenceStoreController?.open();
// // await localPersistenceStoreController?.bootFromPersistedState(defaultMiroirMetaModel.entities,defaultMiroirMetaModel.entityDefinitions);

// log.info("storeActionOrBundleActionStoreRunner openStore for deployment",deployment[0], "DONE!", persistenceStoreControllerManager.getPersistenceStoreControllers());
// }

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

break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"uuid":"18db21bf-f8d3-4f6a-8296-84b69f6dc48b",
"parentName":"Deployment",
"parentUuid":"7959d814-400c-4e80-988f-a00fe582ab98",
"type":"singleNode",
"name":"AmdinApplicationFilesystemDeployment",
"defaultLabel":"AdminApplicationFilesystemDeployment",
"application":"f3e04bb2-005f-484b-aaf2-072232f60f2c",
"uuid": "18db21bf-f8d3-4f6a-8296-84b69f6dc48b",
"parentName": "Deployment",
"parentUuid": "7959d814-400c-4e80-988f-a00fe582ab98",
"type": "singleNode",
"name": "AdminApplicationFilesystemDeployment",
"defaultLabel": "AdminApplicationFilesystemDeployment",
"application": "f3e04bb2-005f-484b-aaf2-072232f60f2c",
"description": "The default Filesystem Deployment for Application Admin",
"configuration": {
"admin": {
"emulatedServerType": "filesystem",
"directory":"../miroir-core/src/assets/admin"
"directory": "../miroir-core/src/assets/admin"
},
"model": {
"emulatedServerType": "filesystem",
"directory":"../miroir-core/src/assets/admin_model"
"directory": "../miroir-core/src/assets/admin_model"
},
"data": {
"emulatedServerType": "filesystem",
"directory":"../miroir-core/src/assets/admin_data"
"directory": "../miroir-core/src/assets/admin_data"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
"extra": { "defaultLabel": "Module Deployment Uuid", "editable": false }
}
}
},
"actionErrors": {
"type":"literal", "definition": "FailedToOpenStore"
}
},
{
Expand All @@ -87,6 +90,9 @@
"extra": { "defaultLabel": "Module Deployment Uuid", "editable": false }
}
}
},
"actionErrors": {
"type":"literal", "definition": "FailedToCloseStore"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion packages/miroir-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ persistenceSaga.run(localCache)
persistenceStoreControllerManager.setPersistenceStore(persistenceSaga); // useless?
persistenceStoreControllerManager.setLocalCache(localCache);


// open all configured stores
for (const c of Object.entries(configurations)) {
const openStoreAction: StoreOrBundleAction = {
actionType: "storeManagementAction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@
"directory":"../miroir-core/src/assets/admin_data"
}
},
"15e2004a-e7a0-4b9e-8acd-6d3500a6c9ad": {
"admin": {
"emulatedServerType": "filesystem",
"directory":"../miroir-core/src/assets/admin"
},
"model": {
"emulatedServerType": "filesystem",
"directory":"../miroir-core/src/assets/test1_model"
},
"data": {
"emulatedServerType": "filesystem",
"directory":"../miroir-core/src/assets/test1_data"
}
},
"10ff36f2-50a3-48d8-b80f-e48e5d13af8e":{
"admin": {
"emulatedServerType": "filesystem",
Expand Down
21 changes: 12 additions & 9 deletions packages/miroir-standalone-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,18 @@ async function start(root:Root) {

}

const persistenceStore:PersistenceInterface = domainController.getRemoteStore();
const openStoreAction: StoreOrBundleAction = {
actionType: "storeManagementAction",
actionName: "openStore",
endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f",
configuration: currentMiroirConfig.client.deploymentStorageConfig,
deploymentUuid: adminConfigurationDeploymentMiroir.uuid,
};
await persistenceStore.handlePersistenceAction(openStoreAction)
for (const c of Object.entries(currentMiroirConfig.client.deploymentStorageConfig)) {
const openStoreAction: StoreOrBundleAction = {
actionType: "storeManagementAction",
actionName: "openStore",
endpoint: "bbd08cbb-79ff-4539-b91f-7a14f15ac55f",
configuration: {
[c[0]]: c[1] as StoreUnitConfiguration,
},
deploymentUuid: c[0],
};
await domainController.handleAction(openStoreAction)
}
}

const theme = createTheme(themeParams);
Expand Down
Loading

0 comments on commit 401162d

Please sign in to comment.