Skip to content

Commit

Permalink
create basic elements for Miroir Action Script (MAS), migrate Tools.s…
Browse files Browse the repository at this point in the history
…ubmit to MAS #28. Cleanup: remove native interpretation of Templates in miroir-store-sql.
  • Loading branch information
miroir-framework committed Oct 15, 2024
1 parent 35efa8d commit 2db6724
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 21 deletions.
8 changes: 4 additions & 4 deletions packages/miroir-core/src/2_domain/QuerySelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ export const applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemo
const filterTest = localQuery.filter
? new RegExp(localQuery.filter.value??"", "i") // TODO: check for correct type
: undefined;
log.info(
"applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory filter",
JSON.stringify(localQuery.filter)
);
// log.info(
// "applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory filter",
// JSON.stringify(localQuery.filter)
// );
const result:DomainElementInstanceUuidIndexOrFailed = localQuery.filter
? {
elementType: "instanceUuidIndex",
Expand Down
8 changes: 4 additions & 4 deletions packages/miroir-core/src/2_domain/QueryTemplateSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ export const applyExtractorTemplateForSingleObjectListToSelectedInstancesUuidInd
const filterTest = localQuery.filter
? new RegExp((localQuery.filter.value as any).constantStringValue, "i") // TODO: check for correct type
: undefined;
log.info(
"applyExtractorTemplateForSingleObjectListToSelectedInstancesUuidIndexInMemory queryTemplateExtractObjectListByEntity filter",
JSON.stringify(localQuery.filter)
);
// log.info(
// "applyExtractorTemplateForSingleObjectListToSelectedInstancesUuidIndexInMemory queryTemplateExtractObjectListByEntity filter",
// JSON.stringify(localQuery.filter)
// );
const result:DomainElementInstanceUuidIndexOrFailed = localQuery.filter
? {
elementType: "instanceUuidIndex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class SqlDbExtractRunner {
) // private persistenceStoreController: typeof MixedSqlDbInstanceStoreSection // does not work
{
this.logHeader = "PersistenceStoreController " + persistenceStoreController.getStoreName();
this.sqlDbExtractTemplateRunner = new SqlDbExtractTemplateRunner(persistenceStoreController);
this.sqlDbExtractTemplateRunner = new SqlDbExtractTemplateRunner(persistenceStoreController, this);
const InMemoryImplementationExtractorRunnerMap: AsyncExtractorRunnerMap = {
extractorType: "async",
extractEntityInstanceUuidIndex: this.extractEntityInstanceUuidIndex.bind(this),
Expand Down Expand Up @@ -97,6 +97,7 @@ export class SqlDbExtractRunner {
applyExtractorTemplateTransformer: this.sqlDbExtractTemplateRunner.applyExtractorTemplateTransformerSql.bind(this.sqlDbExtractTemplateRunner),
};

// TODO: design error: this has to be kept consistent with SqlDbExtractTemplateRunner
this.extractorRunnerMap = InMemoryImplementationExtractorRunnerMap;
// this.extractorRunnerMap = dbImplementationExtractorRunnerMap;
}
Expand Down Expand Up @@ -218,7 +219,7 @@ export class SqlDbExtractRunner {
* @param selectorParams
* @returns
*/
private asyncSqlDbExtractEntityInstanceUuidIndexWithObjectListExtractor = (
public asyncSqlDbExtractEntityInstanceUuidIndexWithObjectListExtractor = (
selectorParams: AsyncExtractorRunnerParams<ExtractorForSingleObjectList>
): Promise<DomainElementInstanceUuidIndexOrFailed> => {
// (
Expand Down Expand Up @@ -518,7 +519,7 @@ export class SqlDbExtractRunner {
entityUuid,
{
attribute: extractorRunnerParams.extractor.select.filter.attributeName,
value: extractorRunnerParams.extractor.select.filter.value.constantStringValue,
value: extractorRunnerParams.extractor.select.filter.value,
}
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import {
ActionReturnType,
ApplicationSection,
asyncApplyExtractorTemplateTransformerInMemory,
asyncApplyExtractorTransformerInMemory,
asyncExtractEntityInstanceUuidIndexWithObjectListExtractor,
asyncExtractEntityInstanceUuidIndexWithObjectListExtractorTemplate,
AsyncExtractorRunnerMap,
AsyncExtractorTemplateRunner,
AsyncExtractorTemplateRunnerMap,
AsyncExtractorTemplateRunnerParams,
asyncExtractWithExtractor,
asyncExtractWithExtractorTemplate,
asyncExtractWithManyExtractors,
asyncExtractWithManyExtractorTemplates,
DomainElement,
DomainElementEntityInstanceOrFailed,
Expand All @@ -34,6 +39,7 @@ import { packageName } from "../constants.js";
import { cleanLevel } from "./constants.js";
import { SqlDbDataStoreSection } from "./SqlDbDataStoreSection.js";
import { SqlDbModelStoreSection } from "./SqlDbModelStoreSection.js";
import { SqlDbExtractRunner } from "./SqlDbExtractorRunner.js";

const loggerName: string = getLoggerName(packageName, cleanLevel, "PostgresExtractorRunner");
let log: LoggerInterface = console as any as LoggerInterface;
Expand All @@ -45,16 +51,54 @@ export type RecursiveStringRecords = string | { [x: string]: RecursiveStringReco

export class SqlDbExtractTemplateRunner {
private logHeader: string;
private extractorRunnerMap: AsyncExtractorTemplateRunnerMap;
private extractorRunnerMap: AsyncExtractorRunnerMap;
private extractorTemplateRunnerMap: AsyncExtractorTemplateRunnerMap;

constructor(
private persistenceStoreController:
| SqlDbDataStoreSection
| SqlDbModelStoreSection /* concrete types for MixedSqlDbInstanceStoreSection */
| SqlDbModelStoreSection, /* concrete types for MixedSqlDbInstanceStoreSection */
private sqlDbExtractorRunner: SqlDbExtractRunner
) // private persistenceStoreController: typeof MixedSqlDbInstanceStoreSection // does not work
{
this.logHeader = "SqlDbExtractTemplateRunner " + persistenceStoreController.getStoreName();
const InMemoryImplementationExtractorRunnerMap: AsyncExtractorTemplateRunnerMap = {
const InMemoryImplementationExtractorRunnerMap: AsyncExtractorRunnerMap = {
extractorType: "async",
extractEntityInstanceUuidIndex: this.sqlDbExtractorRunner.extractEntityInstanceUuidIndex.bind(this.sqlDbExtractorRunner),
extractEntityInstance: this.sqlDbExtractorRunner.extractEntityInstance.bind(this.sqlDbExtractorRunner),
extractEntityInstanceUuidIndexWithObjectListExtractorInMemory: asyncExtractEntityInstanceUuidIndexWithObjectListExtractor,
extractWithManyExtractors: asyncExtractWithManyExtractors,
extractWithExtractor: asyncExtractWithExtractor,
applyExtractorTransformer: asyncApplyExtractorTransformerInMemory,
//
extractEntityInstanceUuidIndexForTemplate: this.extractEntityInstanceUuidIndex,
extractEntityInstanceForTemplate: this.extractEntityInstanceForTemplate,
extractEntityInstanceUuidIndexWithObjectListExtractorTemplateInMemory: asyncExtractEntityInstanceUuidIndexWithObjectListExtractorTemplate,
extractWithManyExtractorTemplates: asyncExtractWithManyExtractorTemplates,
extractWithExtractorTemplate: asyncExtractWithExtractorTemplate,
applyExtractorTemplateTransformer: asyncApplyExtractorTemplateTransformerInMemory

};
const dbImplementationExtractorRunnerMap: AsyncExtractorRunnerMap = {
extractorType: "async",
extractEntityInstanceUuidIndex: this.sqlDbExtractorRunner.extractEntityInstanceUuidIndex.bind(this.sqlDbExtractorRunner),
extractEntityInstance: this.sqlDbExtractorRunner.extractEntityInstance.bind(this.sqlDbExtractorRunner),
extractEntityInstanceUuidIndexWithObjectListExtractorInMemory:
this.sqlDbExtractorRunner.asyncSqlDbExtractEntityInstanceUuidIndexWithObjectListExtractor.bind(this.sqlDbExtractorRunner),
extractWithManyExtractors: asyncExtractWithManyExtractors,
extractWithExtractor: asyncExtractWithExtractor,
applyExtractorTransformer: this.sqlDbExtractorRunner.applyExtractorTransformerSql.bind(this.sqlDbExtractorRunner),
//
extractEntityInstanceUuidIndexForTemplate: this.extractEntityInstanceUuidIndex.bind(this),
extractEntityInstanceForTemplate: this.extractEntityInstanceForTemplate.bind(this),
extractEntityInstanceUuidIndexWithObjectListExtractorTemplateInMemory:
this.asyncSqlDbExtractEntityInstanceUuidIndexWithObjectListExtractorForTemplate.bind(this),
extractWithManyExtractorTemplates: asyncExtractWithManyExtractorTemplates,
extractWithExtractorTemplate: asyncExtractWithExtractorTemplate,
applyExtractorTemplateTransformer: this.applyExtractorTemplateTransformerSql.bind(this),
};

const InMemoryImplementationExtractorTemplateRunnerMap: AsyncExtractorTemplateRunnerMap = {
extractorType: "async",
extractEntityInstanceUuidIndex: this.extractEntityInstanceUuidIndex.bind(this),
extractEntityInstance: this.extractEntityInstanceForTemplate.bind(this),
Expand All @@ -63,7 +107,7 @@ export class SqlDbExtractTemplateRunner {
extractWithExtractorTemplate: asyncExtractWithExtractorTemplate,
applyExtractorTransformer: asyncApplyExtractorTemplateTransformerInMemory,
};
const dbImplementationExtractorRunnerMap: AsyncExtractorTemplateRunnerMap = {
const dbImplementationExtractorTemplateRunnerMap: AsyncExtractorTemplateRunnerMap = {
extractorType: "async",
extractEntityInstanceUuidIndex: this.extractEntityInstanceUuidIndex.bind(this),
extractEntityInstance: this.extractEntityInstanceForTemplate.bind(this),
Expand All @@ -74,8 +118,10 @@ export class SqlDbExtractTemplateRunner {
applyExtractorTransformer: this.applyExtractorTemplateTransformerSql.bind(this),
};

this.extractorRunnerMap = InMemoryImplementationExtractorRunnerMap;
// this.extractorRunnerMap = dbImplementationExtractorRunnerMap;
this.extractorRunnerMap = InMemoryImplementationExtractorRunnerMap;
this.extractorTemplateRunnerMap = InMemoryImplementationExtractorTemplateRunnerMap;
// this.extractorTemplateRunnerMap = dbImplementationExtractorTemplateRunnerMap;
}

// ################################################################################################
Expand Down Expand Up @@ -206,7 +252,7 @@ export class SqlDbExtractTemplateRunner {
case "selectObjectListByRelation":
case "selectObjectListByManyToManyRelation": {
return this.extractorRunnerMap.extractEntityInstanceUuidIndexWithObjectListExtractorTemplateInMemory({
extractorRunnerMap: this.extractorRunnerMap,
extractorRunnerMap: this.extractorTemplateRunnerMap,
extractorTemplate: {
queryType: "extractorTemplateForDomainModelObjects",
deploymentUuid: selectorParams.extractorTemplate.deploymentUuid,
Expand Down Expand Up @@ -246,14 +292,14 @@ export class SqlDbExtractTemplateRunner {
case "extractorTemplateForDomainModelObjects": {
queryResult = await this.extractorRunnerMap.extractWithExtractorTemplate({
extractorTemplate: queryTemplateAction.query,
extractorRunnerMap: this.extractorRunnerMap,
extractorRunnerMap: this.extractorTemplateRunnerMap,
});
break;
}
case "extractorTemplateForRecordOfExtractors": {
queryResult = await this.extractorRunnerMap.extractWithManyExtractorTemplates({
extractorTemplate: queryTemplateAction.query,
extractorRunnerMap: this.extractorRunnerMap,
extractorRunnerMap: this.extractorTemplateRunnerMap,
});
break;
}
Expand Down Expand Up @@ -681,7 +727,7 @@ export class SqlDbExtractTemplateRunner {

// ##############################################################################################
public getSelectorMap(): AsyncExtractorTemplateRunnerMap {
return this.extractorRunnerMap;
return this.extractorTemplateRunnerMap;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export function SqlDbInstanceStoreSectionMixin<TBase extends MixableSqlDbStoreSe
...args: any[]
) {
super(...args);
this.extractorTemplateRunner = new SqlDbExtractTemplateRunner(this as any /*SqlDbExtractTemplateRunner takes a concrete implementation*/);
this.extractorRunner = new SqlDbExtractRunner(this as any /*SqlDbExtractRunner takes a concrete implementation*/);
this.extractorTemplateRunner = new SqlDbExtractTemplateRunner(this as any /*SqlDbExtractTemplateRunner takes a concrete implementation*/, this.extractorRunner);
}

async executeRawQuery(query: string): Promise<ActionReturnType> {
Expand Down

0 comments on commit 2db6724

Please sign in to comment.