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 02699802..2e20f57e 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 @@ -2493,6 +2493,7 @@ export function getMiroirFundamentalJzodSchema( queryTemplate: (miroirFundamentalJzodSchema as any).definition.context.queryTemplate, queryTemplateRecord: (miroirFundamentalJzodSchema as any).definition.context.queryTemplateRecord, transformer_constantUuid: (transformerJzodSchema as any).definition.context.transformer_constantUuid, + transformer_constantObject: (transformerJzodSchema as any).definition.context.transformer_constantObject, transformer_constantString: (transformerJzodSchema as any).definition.context.transformer_constantString, transformer_newUuid: (transformerJzodSchema as any).definition.context.transformer_newUuid, transformer_parameterReference: (transformerJzodSchema as any).definition.context.transformer_parameterReference, 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 a0900084..5cdb8db5 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 @@ -1083,6 +1083,21 @@ export const miroirFundamentalJzodSchema = { } } }, + "transformer_constantObject": { + "type": "object", + "definition": { + "templateType": { + "type": "literal", + "definition": "constantObject" + }, + "constantObjectValue": { + "type": "record", + "definition": { + "type": "any" + } + } + } + }, "transformer_constantString": { "type": "object", "definition": { @@ -1178,6 +1193,14 @@ export const miroirFundamentalJzodSchema = { }, "context": {} }, + { + "type": "schemaReference", + "definition": { + "relativePath": "transformer_constantObject", + "absolutePath": "fe9b7d99-f216-44de-bb6e-60e1a1ebb739" + }, + "context": {} + }, { "type": "schemaReference", "definition": { @@ -25723,6 +25746,65 @@ export const miroirFundamentalJzodSchema = { } ] }, + "carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantObject": { + "type": "union", + "definition": [ + { + "type": "schemaReference", + "definition": { + "relativePath": "carryOnObject" + } + }, + { + "type": "object", + "definition": { + "templateType": { + "type": "union", + "definition": [ + { + "type": "literal", + "definition": "constantObject" + }, + { + "type": "schemaReference", + "definition": { + "relativePath": "carryOnObject" + } + } + ] + }, + "constantObjectValue": { + "type": "union", + "definition": [ + { + "type": "record", + "definition": { + "type": "union", + "definition": [ + { + "type": "any" + }, + { + "type": "schemaReference", + "definition": { + "relativePath": "carryOnObject" + } + } + ] + } + }, + { + "type": "schemaReference", + "definition": { + "relativePath": "carryOnObject" + } + } + ] + } + } + } + ] + }, "carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantString": { "type": "union", "definition": [ @@ -25990,6 +26072,13 @@ export const miroirFundamentalJzodSchema = { }, "context": {} }, + { + "type": "schemaReference", + "definition": { + "relativePath": "carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantObject" + }, + "context": {} + }, { "type": "schemaReference", "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 e4af8e39..50e5df64 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 @@ -463,6 +463,12 @@ export type Transformer_constantUuid = { templateType: "constantUuid"; constantUuidValue: string; }; +export type Transformer_constantObject = { + templateType: "constantObject"; + constantObjectValue: { + [x: string]: any; + }; +}; export type Transformer_constantString = { templateType: "constantString"; constantStringValue: string; @@ -481,7 +487,7 @@ export type Transformer_parameterReference = { referencePath?: string[] | undefined; }; export type Transformer_contextOrParameterReference = Transformer_contextReference | Transformer_parameterReference; -export type Transformer_InnerReference = Transformer_constantUuid | Transformer_constantString | Transformer_newUuid | Transformer_contextOrParameterReference; +export type Transformer_InnerReference = Transformer_constantUuid | Transformer_constantObject | Transformer_constantString | Transformer_newUuid | Transformer_contextOrParameterReference; export type TransformerForBuild_AbstractForCountAndUnique = { orderBy?: string | undefined; }; @@ -3221,6 +3227,12 @@ export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantUui templateType: "constantUuid" | CarryOnObject; constantUuidValue: string | CarryOnObject; }; +export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantObject = CarryOnObject | { + templateType: "constantObject" | CarryOnObject; + constantObjectValue: { + [x: string]: any | CarryOnObject; + } | CarryOnObject; +}; export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantString = CarryOnObject | { templateType: "constantString" | CarryOnObject; constantStringValue: string | CarryOnObject; @@ -3239,7 +3251,7 @@ export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextRefe referencePath?: (((string | CarryOnObject)[] | undefined) | CarryOnObject) | undefined; }; export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextOrParameterReference = CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextReference | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_parameterReference | CarryOnObject; -export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_InnerReference = CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantUuid | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantString | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_newUuid | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextOrParameterReference | CarryOnObject; +export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_InnerReference = CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantUuid | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantObject | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantString | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_newUuid | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextOrParameterReference | CarryOnObject; export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild = CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_InnerReference | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_fullObjectTemplate | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_freeObjectTemplate | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_listMapper | CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_mustacheStringTemplate | CarryOnObject; export type CarryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_mustacheStringTemplate = CarryOnObject | { templateType: "mustacheStringTemplate" | CarryOnObject; @@ -3466,12 +3478,13 @@ export const ______________________________________________templates____________ export const recordOfTransformers: z.ZodType = z.object({transformerType:z.literal("recordOfTransformers"), definition:z.record(z.string(),z.lazy(() =>transformer))}).strict(); export const transformer: z.ZodType = z.union([z.object({transformerType:z.literal("objectTransformer"), attributeName:z.string()}).strict(), z.lazy(() =>recordOfTransformers)]); export const transformer_constantUuid: z.ZodType = z.object({templateType:z.literal("constantUuid"), constantUuidValue:z.string()}).strict(); +export const transformer_constantObject: z.ZodType = z.object({templateType:z.literal("constantObject"), constantObjectValue:z.record(z.string(),z.any())}).strict(); export const transformer_constantString: z.ZodType = z.object({templateType:z.literal("constantString"), constantStringValue:z.string()}).strict(); export const transformer_newUuid: z.ZodType = z.object({templateType:z.literal("newUuid")}).strict(); export const transformer_contextReference: z.ZodType = z.object({templateType:z.literal("contextReference"), referenceName:z.string().optional(), referencePath:z.array(z.string()).optional()}).strict(); export const transformer_parameterReference: z.ZodType = z.object({templateType:z.literal("parameterReference"), referenceName:z.string().optional(), referencePath:z.array(z.string()).optional()}).strict(); export const transformer_contextOrParameterReference: z.ZodType = z.union([z.lazy(() =>transformer_contextReference), z.lazy(() =>transformer_parameterReference)]); -export const transformer_InnerReference: z.ZodType = z.union([z.lazy(() =>transformer_constantUuid), z.lazy(() =>transformer_constantString), z.lazy(() =>transformer_newUuid), z.lazy(() =>transformer_contextOrParameterReference)]); +export const transformer_InnerReference: z.ZodType = z.union([z.lazy(() =>transformer_constantUuid), z.lazy(() =>transformer_constantObject), z.lazy(() =>transformer_constantString), z.lazy(() =>transformer_newUuid), z.lazy(() =>transformer_contextOrParameterReference)]); export const transformerForBuild_AbstractForCountAndUnique: z.ZodType = z.object({orderBy:z.string().optional()}).strict(); export const transformerForBuild_Count: z.ZodType = z.object({orderBy:z.string().optional()}).strict().extend({queryName:z.literal("count"), groupBy:z.string().optional()}).strict(); export const transformerForBuild_fullObjectTemplate: z.ZodType = z.object({orderBy:z.string().optional()}).strict().extend({templateType:z.literal("fullObjectTemplate"), referencedExtractor:z.string(), definition:z.array(z.object({attributeKey:z.lazy(() =>transformer_InnerReference), attributeValue:z.lazy(() =>transformerForBuild)}).strict())}).strict(); @@ -3786,12 +3799,13 @@ export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateSelectByQ export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplate: z.ZodType = z.union([z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateSelectExtractorWrapper), z.object({queryType:z.union([z.literal("wrapperReturningObject"), z.lazy(() =>carryOnObject)]), definition:z.union([z.record(z.string(),z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplate)), z.lazy(() =>carryOnObject)])}).strict(), z.object({queryType:z.union([z.literal("wrapperReturningList"), z.lazy(() =>carryOnObject)]), definition:z.union([z.array(z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplate)), z.lazy(() =>carryOnObject)])}).strict(), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateExtractObjectByDirectReference), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateSelectObjectList), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateSelectObjectByRelation), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateSelectObjectListByRelation), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateSelectObjectListByManyToManyRelation), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateSelectByQueryCombiner), z.object({queryType:z.union([z.literal("literal"), z.lazy(() =>carryOnObject)]), definition:z.union([z.string(), z.lazy(() =>carryOnObject)])}).strict(), z.object({queryType:z.union([z.literal("queryContextReference"), z.lazy(() =>carryOnObject)]), queryReference:z.union([z.string(), z.lazy(() =>carryOnObject)])}).strict(), z.lazy(() =>carryOnObject)]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplateRecord: z.ZodType = z.union([z.record(z.string(),z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_queryTemplate)), z.lazy(() =>carryOnObject)]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantUuid: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({templateType:z.union([z.literal("constantUuid"), z.lazy(() =>carryOnObject)]), constantUuidValue:z.union([z.string(), z.lazy(() =>carryOnObject)])}).strict()]); +export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantObject: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({templateType:z.union([z.literal("constantObject"), z.lazy(() =>carryOnObject)]), constantObjectValue:z.union([z.record(z.string(),z.union([z.any(), z.lazy(() =>carryOnObject)])), z.lazy(() =>carryOnObject)])}).strict()]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantString: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({templateType:z.union([z.literal("constantString"), z.lazy(() =>carryOnObject)]), constantStringValue:z.union([z.string(), z.lazy(() =>carryOnObject)])}).strict()]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_newUuid: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({templateType:z.union([z.literal("newUuid"), z.lazy(() =>carryOnObject)])}).strict()]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_parameterReference: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({templateType:z.union([z.literal("parameterReference"), z.lazy(() =>carryOnObject)]), referenceName:z.union([z.string().optional(), z.lazy(() =>carryOnObject)]).optional(), referencePath:z.union([z.array(z.union([z.string(), z.lazy(() =>carryOnObject)])).optional(), z.lazy(() =>carryOnObject)]).optional()}).strict()]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextReference: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({templateType:z.union([z.literal("contextReference"), z.lazy(() =>carryOnObject)]), referenceName:z.union([z.string().optional(), z.lazy(() =>carryOnObject)]).optional(), referencePath:z.union([z.array(z.union([z.string(), z.lazy(() =>carryOnObject)])).optional(), z.lazy(() =>carryOnObject)]).optional()}).strict()]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextOrParameterReference: z.ZodType = z.union([z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextReference), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_parameterReference), z.lazy(() =>carryOnObject)]); -export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_InnerReference: z.ZodType = z.union([z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantUuid), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantString), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_newUuid), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextOrParameterReference), z.lazy(() =>carryOnObject)]); +export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_InnerReference: z.ZodType = z.union([z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantUuid), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantObject), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_constantString), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_newUuid), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_contextOrParameterReference), z.lazy(() =>carryOnObject)]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild: z.ZodType = z.union([z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformer_InnerReference), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_fullObjectTemplate), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_freeObjectTemplate), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_listMapper), z.lazy(() =>carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_mustacheStringTemplate), z.lazy(() =>carryOnObject)]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_mustacheStringTemplate: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({templateType:z.union([z.literal("mustacheStringTemplate"), z.lazy(() =>carryOnObject)]), definition:z.union([z.string(), z.lazy(() =>carryOnObject)])}).strict()]); export const carryOn_fe9b7d99$f216$44de$bb6e$60e1a1ebb739_transformerForBuild_AbstractForCountAndUnique: z.ZodType = z.union([z.lazy(() =>carryOnObject), z.object({orderBy:z.union([z.string().optional(), z.lazy(() =>carryOnObject)]).optional()}).strict()]); diff --git a/packages/miroir-core/src/2_domain/QuerySelectors.ts b/packages/miroir-core/src/2_domain/QuerySelectors.ts index 7be34a3e..5b297fba 100644 --- a/packages/miroir-core/src/2_domain/QuerySelectors.ts +++ b/packages/miroir-core/src/2_domain/QuerySelectors.ts @@ -269,7 +269,7 @@ export const applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemo ? new RegExp((localQuery.filter.value as any).constantStringValue, "i") // TODO: check for correct type : undefined; // log.info( - // "applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory queryTemplateExtractObjectListByEntity filter", + // "applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory filter", // JSON.stringify(localQuery.filter) // ); const result:DomainElementInstanceUuidIndexOrFailed = localQuery.filter @@ -281,7 +281,7 @@ export const applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemo (i as any)[1][localQuery.filter?.attributeName??""] ) // log.info( - // "applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory queryTemplateExtractObjectListByEntity filter", + // "applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory filter", // JSON.stringify(i[1]), // "matchResult", // matchResult @@ -294,7 +294,7 @@ export const applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemo : selectedInstancesUuidIndex; ; // log.info( - // "applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory queryTemplateExtractObjectListByEntity result", + // "applyExtractorForSingleObjectListToSelectedInstancesUuidIndexInMemory result", // JSON.stringify(result, undefined, 2) // ); return result; diff --git a/packages/miroir-core/src/2_domain/Templates.ts b/packages/miroir-core/src/2_domain/Templates.ts index 89830239..f477c918 100644 --- a/packages/miroir-core/src/2_domain/Templates.ts +++ b/packages/miroir-core/src/2_domain/Templates.ts @@ -202,6 +202,7 @@ export function resolveQueryTemplate( } } +// ################################################################################################ export function resolveQueryTemplateSelectExtractorWrapper( queryTemplate: QueryTemplateSelectExtractorWrapper, queryParams: Record, @@ -224,16 +225,18 @@ export function resolveExtractorTemplateForRecordOfExtractors( log.info("resolveExtractorTemplateForRecordOfExtractors converting extractorTemplates:", recordOfExtractorTemplate.extractorTemplates); const queries = Object.fromEntries( - Object.entries(recordOfExtractorTemplate.extractorTemplates??{}).map((e: [string, QueryTemplateSelectExtractorWrapper]) => [ - e[0], - resolveQueryTemplateSelectExtractorWrapper(e[1], params, recordOfExtractorTemplate.contextResults), // TODO: generalize to MiroirQuery & check for failure! - ]) + Object.entries(recordOfExtractorTemplate.extractorTemplates ?? {}).map( + (e: [string, QueryTemplateSelectExtractorWrapper]) => [ + e[0], + resolveQueryTemplateSelectExtractorWrapper(e[1], params, recordOfExtractorTemplate.contextResults), // TODO: generalize to MiroirQuery & check for failure! + ] + ) ); log.info("resolveExtractorTemplateForRecordOfExtractors converted extractorTemplates, result:", queries); log.info("resolveExtractorTemplateForRecordOfExtractors converting combinerTemplates:", recordOfExtractorTemplate.combinerTemplates); const combiners = Object.fromEntries( - Object.entries(recordOfExtractorTemplate.combinerTemplates??{}).map((e: [string, QueryTemplate]) => [ + Object.entries(recordOfExtractorTemplate.combinerTemplates ?? {}).map((e: [string, QueryTemplate]) => [ e[0], resolveQueryTemplate(e[1], params, recordOfExtractorTemplate.contextResults), // TODO: generalize to MiroirQuery & check for failure! ]) diff --git a/packages/miroir-core/src/2_domain/Transformers.ts b/packages/miroir-core/src/2_domain/Transformers.ts index a4278941..0f6fac6e 100644 --- a/packages/miroir-core/src/2_domain/Transformers.ts +++ b/packages/miroir-core/src/2_domain/Transformers.ts @@ -330,7 +330,7 @@ export function transformer_InnerReference_resolve ( // ) ) { // checking that given reference does exist - log.warn( + log.error( "transformer_InnerReference_resolve failed, reference not found for step", step, "reference=", @@ -533,16 +533,16 @@ function mustacheStringTemplate_apply( // ? domainElementToPlainObject(contextResults) // : domainElementToPlainObject(queryParams); // TODO: highly inefficient & buggy!! const result = Mustache.render(transformer.definition, {...queryParams, ...contextResults}); - log.info( - "mustacheStringTemplate_apply for", - transformer, - "queryParams", - JSON.stringify(queryParams, null, 2), - "contextResults", - JSON.stringify(contextResults, null, 2), - "result", - result - ); + // log.info( + // "mustacheStringTemplate_apply for", + // transformer, + // "queryParams", + // JSON.stringify(queryParams, null, 2), + // "contextResults", + // JSON.stringify(contextResults, null, 2), + // "result", + // result + // ); return { elementType: "string", elementValue: result }; } @@ -592,16 +592,26 @@ export function transformer_apply( elementValue: subObject.map((e) => e.elementValue), // TODO: clean result instead? (deep!) } } else { + log.error( + "transformer_apply failed converting array", + transformer, + "with params", + queryParams, + "error in", + JSON.stringify(subObject[failureIndex], null, 2) + ); return { elementType: "failure", elementValue: { queryFailure: "ReferenceNotFound", failureOrigin: ["transformer_apply"], queryContext: - "failed to transform object attribute for object " + - objectName + - " transformer" + - transformer[failureIndex], + "failed to transform object attribute for array index " + + failureIndex + + " failure " + + JSON.stringify(subObject[failureIndex]) + + " in transformer " + + JSON.stringify(transformer[failureIndex]), }, }; } @@ -750,6 +760,11 @@ export function transformer_apply( return { elementType: "object", elementValue: result}; break; } + case "constantObject": { + log.info("transformer_apply constantObject", transformer.constantObjectValue); + return { elementType: "object", elementValue: transformer.constantObjectValue }; + break; + } case "newUuid": case "constantString": case "constantUuid": diff --git a/packages/miroir-core/src/3_controllers/DomainController.ts b/packages/miroir-core/src/3_controllers/DomainController.ts index a2b8fd5a..5d4b858c 100644 --- a/packages/miroir-core/src/3_controllers/DomainController.ts +++ b/packages/miroir-core/src/3_controllers/DomainController.ts @@ -758,7 +758,7 @@ export class DomainController implements DomainControllerInterface { switch (currentAction.compositeActionType) { case 'action': { const resolvedActionTemplate: InstanceAction = transformer_apply( - "runtime", + "build", "NO NAME", currentAction.action as TransformerForBuild, actionParamsAndTemplates, diff --git a/packages/miroir-core/src/assets/miroir_data/5e81e1b9-38be-487c-b3e5-53796c57fccf/a97756cf-dd93-42b9-a021-91a629b187b9.json b/packages/miroir-core/src/assets/miroir_data/5e81e1b9-38be-487c-b3e5-53796c57fccf/a97756cf-dd93-42b9-a021-91a629b187b9.json index 0e981762..56591604 100644 --- a/packages/miroir-core/src/assets/miroir_data/5e81e1b9-38be-487c-b3e5-53796c57fccf/a97756cf-dd93-42b9-a021-91a629b187b9.json +++ b/packages/miroir-core/src/assets/miroir_data/5e81e1b9-38be-487c-b3e5-53796c57fccf/a97756cf-dd93-42b9-a021-91a629b187b9.json @@ -62,6 +62,19 @@ } } }, + "transformer_constantObject":{ + "type": "object", + "definition": { + "templateType": { + "type": "literal", + "definition": "constantObject" + }, + "constantObjectValue": { + "type": "record", + "definition": { "type": "any" } + } + } + }, "transformer_constantString":{ "type": "object", "definition": { @@ -151,6 +164,12 @@ "relativePath": "transformer_constantUuid" } }, + { + "type": "schemaReference", + "definition": { + "relativePath": "transformer_constantObject" + } + }, { "type": "schemaReference", "definition": { diff --git a/packages/miroir-core/src/tests/2_domain/queryTemplates.unit.test.ts b/packages/miroir-core/src/tests/2_domain/queryTemplates.unit.test.ts index c157a33b..982315c4 100644 --- a/packages/miroir-core/src/tests/2_domain/queryTemplates.unit.test.ts +++ b/packages/miroir-core/src/tests/2_domain/queryTemplates.unit.test.ts @@ -12,7 +12,21 @@ import { TransformerForRuntime_InnerReference, ExtractorTemplateForRecordOfExtractors, } from "../../0_interfaces/1_core/preprocessor-generated/miroirFundamentalType.js"; -import { book1, book2, book3, book4, book5, book6, Country1, Country2, Country3, Country4, ignorePostgresExtraAttributesOnList, ignorePostgresExtraAttributesOnRecord, resolveExtractorTemplateForRecordOfExtractors } from '../../index.js'; +import { + book1, + book2, + book3, + book4, + book5, + book6, + Country1, + Country2, + Country3, + Country4, + ignorePostgresExtraAttributesOnList, + ignorePostgresExtraAttributesOnRecord, + resolveExtractorTemplateForRecordOfExtractors, +} from "../../index.js"; import { object } from 'zod'; // const env:any = (import.meta as any).env // console.log("@@@@@@@@@@@@@@@@@@ env", env); @@ -49,6 +63,21 @@ describe("queryTemplates.unit.test", () => { referenceName: "instanceUuid", }, }, + fountain: { + queryType: "selectObjectByDirectReference", + parentName: "Fountain", + parentUuid: { + templateType: "mustacheStringTemplate", + definition: "{{newEntity.uuid}}", + }, + instanceUuid: { + templateType: "constantObject", + constantObjectValue: { + templateType: "parameterReference", + referenceName: "instanceUuid", + } + }, + }, }, combinerTemplates: { publisher: { @@ -109,27 +138,6 @@ describe("queryTemplates.unit.test", () => { }, }; - // const preTestResult: {[k: string]: {[l:string]: any}} = transformer_apply( - // const preTestResult: {[k: string]: {[l:string]: any}} = transformer_apply( - // "runtime", - // "ROOT", - // // uniqueRuntimeTemplate, - // uniqueRuntimeTemplate as any, - // { - // newUuid: newUuid , - // }, // queryParams - // { - // countries: [ - // Country1 as EntityInstance, - // Country2 as EntityInstance, - // Country3 as EntityInstance, - // Country4 as EntityInstance, - // ], - // } // context - // ).elementValue; - - // console.log("################################ convert queryTemplate to query with resolveExtractorTemplateForRecordOfExtractors preTestResult", preTestResult) - // const testResult = ignorePostgresExtraAttributesOnList(preTestResult as any,["uuid"]); // uuid value is ignored const testResult = resolveExtractorTemplateForRecordOfExtractors(uniqueRuntimeTemplate); // uuid value is ignored console.log("################################ converted queryTemplate to query with resolveExtractorTemplateForRecordOfExtractors", JSON.stringify(testResult, null, 2)) expect(testResult).toEqual( diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/Importer.tsx b/packages/miroir-standalone-app/src/miroir-fwk/4_view/Importer.tsx index 2649c599..09e526c5 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/Importer.tsx +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/Importer.tsx @@ -267,6 +267,10 @@ export const Importer:FC = (props:ImporterCoreProps) => { templateType: "parameterReference", referenceName: "newEntityListReportUuid", }, + application: { + templateType: "parameterReference", + referenceName: "currentApplicationUuid", + }, parentName: "Report", parentUuid: { templateType: "mustacheStringTemplate", @@ -283,19 +287,16 @@ export const Importer:FC = (props:ImporterCoreProps) => { }, type: "list", definition: { - extractorTemplatess: { + extractors: { instanceList: { - queryType: "queryTemplateExtractObjectListByEntity", + queryType: "queryExtractObjectListByEntity", parentName: { templateType: "parameterReference", referenceName: "newEntityName", }, parentUuid: { - templateType: "constantUuid", - constantUuidValue: { - templateType: "mustacheStringTemplate", - definition: "{{newEntity.uuid}}", - }, + templateType: "mustacheStringTemplate", + definition: "{{newEntity.uuid}}", }, }, }, @@ -322,6 +323,10 @@ export const Importer:FC = (props:ImporterCoreProps) => { templateType: "parameterReference", referenceName: "newEntityDetailsReportUuid", }, + application: { + templateType: "parameterReference", + referenceName: "currentApplicationUuid", + }, parentName: { templateType: "mustacheStringTemplate", definition: "{{entityReport.name}}", @@ -348,15 +353,15 @@ export const Importer:FC = (props:ImporterCoreProps) => { referenceName: "newEntityName", }, parentUuid: { - templateType: "constantUuid", - constantUuidValue: { - templateType: "mustacheStringTemplate", - definition: "{{newEntity.uuid}}", - }, + templateType: "mustacheStringTemplate", + definition: "{{newEntity.uuid}}", }, instanceUuid: { - queryTemplateType: "queryParameterReference", - referenceName: "instanceUuid", + templateType: "constantObject", + constantObjectValue: { + templateType: "parameterReference", + referenceName: "instanceUuid", + } }, }, }, @@ -691,7 +696,7 @@ export const Importer:FC = (props:ImporterCoreProps) => { log.info("createEntity found miroirMenuInstances", JSON.stringify(miroirMenuInstances)); const oldMenu: Menu | undefined = (Object.values( - miroirMenuInstances.returnedDomainElement.elementValue["menus"].elementValue + miroirMenuInstances.returnedDomainElement.elementValue["menus"] ) as Menu[]).find((e: Menu) => e.name == actionEffectiveParamsCreateEntity.currentApplicationName + "Menu"); if (!oldMenu) { @@ -902,7 +907,7 @@ export const Importer:FC = (props:ImporterCoreProps) => { }, type: "list", definition: { - extractorTemplates: { + extractors: { listReportSectionElements: { queryType: "queryTemplateExtractObjectListByEntity", parentName: { @@ -910,11 +915,8 @@ export const Importer:FC = (props:ImporterCoreProps) => { referenceName: "newEntityName", }, parentUuid: { - templateType: "constantUuid", - constantUuidValue: { - templateType: "mustacheStringTemplate", - definition: "{{newEntity.uuid}}", - }, + templateType: "mustacheStringTemplate", + definition: "{{newEntity.uuid}}", }, }, }, @@ -1588,7 +1590,7 @@ export const Importer:FC = (props:ImporterCoreProps) => { interpolation: "runtime", referencedExtractor: "uniqueSplittedEntityInstances", elementTransformer: { - templateType: "fullObjectTemplate", + templateType: "fullObjectTemplate", // TODO: fullObjectTemplate is not needed, all attributeKeys are constantString, objectTemplate should be enough interpolation: "runtime", referencedExtractor: "municipality", definition: [ @@ -1617,8 +1619,8 @@ export const Importer:FC = (props:ImporterCoreProps) => { { attributeKey: { interpolation: "runtime", - templateType: "constantUuid", - constantUuidValue: "name" + templateType: "constantString", + constantStringValue: "name" }, attributeValue: { interpolation: "runtime", @@ -1958,6 +1960,9 @@ export const Importer:FC = (props:ImporterCoreProps) => {

: null } found row A:{JSON.stringify(fileData?fileData[0]:'')} +

+ importer props: application={JSON.stringify(props.currentApplicationUuid)} deployment={JSON.stringify(props.currentDeploymentUuid)} filename={JSON.stringify(props.filename)} +

create Entity from Excel File: