Comparing version 0.24.9 to 0.25.0
@@ -17,3 +17,4 @@ declare const SimpleSchema: any; | ||
parsedField: any; | ||
constructor(input: (schema: any, model: any) => void, output: (model: any, schema: any) => void, modelFields: string[], schemaField?: string); | ||
schemaType: any; | ||
constructor(input: (schema: any, model: any) => void, output: (model: any, schema: any) => void, modelFields: string[], schemaType: any, schemaField?: string); | ||
setSchemaField(field: string): void; | ||
@@ -20,0 +21,0 @@ } |
@@ -23,3 +23,3 @@ "use strict"; | ||
class ApiEdgeSchemaTransformation { | ||
constructor(input, output, modelFields, schemaField = "") { | ||
constructor(input, output, modelFields, schemaType, schemaField = "") { | ||
this.applyToInput = input; | ||
@@ -30,2 +30,3 @@ this.applyToOutput = output; | ||
this.parsedField = parse(schemaField); | ||
this.schemaType = schemaType; | ||
} | ||
@@ -89,3 +90,3 @@ setSchemaField(field) { | ||
for (let i = 0; i < this.fields.length; ++i) { | ||
const transform = this.createTransformation(this.fields[i], schema); | ||
const transform = this.createTransformation(this.fields[i], schema, typedSchema); | ||
if (transform) | ||
@@ -118,3 +119,3 @@ this.transformations.push(transform); | ||
} | ||
createTransformation(schemaField, schema) { | ||
createTransformation(schemaField, schema, typedSchema) { | ||
const parsedSchemaField = parse(schemaField), transform = parsedSchemaField(schema); | ||
@@ -136,3 +137,3 @@ if (transform instanceof ApiEdgeSchemaTransformation) { | ||
this.renameMatrix[schemaField] = transform.substring(1); | ||
return new ApiEdgeSchemaTransformation(this.createInputTransformer(parsedSchemaField, transform), ApiEdgeSchema.createOutputTransformer(parsedSchemaField, transform), [schemaField], schemaField); | ||
return new ApiEdgeSchemaTransformation(this.createInputTransformer(parsedSchemaField, transform), ApiEdgeSchema.createOutputTransformer(parsedSchemaField, transform), [schemaField], typedSchema ? typedSchema[schemaField] : Mixed, schemaField); | ||
} | ||
@@ -139,0 +140,0 @@ } |
@@ -28,3 +28,3 @@ "use strict"; | ||
schema.fullName = [model.firstName, model.lastName].join(' '); | ||
}, ["firstName", "lastName"]), | ||
}, ["firstName", "lastName"], String), | ||
email: "=", | ||
@@ -31,0 +31,0 @@ schoolId: "=", |
{ | ||
"name": "api-core", | ||
"version": "0.24.9", | ||
"version": "0.25.0", | ||
"description": "Model-based dynamic multi-level APIs for any provider, plus multiple consumption channels", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -33,2 +33,3 @@ const parse = require('obj-parse'), | ||
parsedField: any; | ||
schemaType: any; | ||
@@ -38,2 +39,3 @@ constructor(input: (schema: any, model: any) => void, | ||
modelFields: string[], | ||
schemaType: any, | ||
schemaField: string = "") { | ||
@@ -45,2 +47,3 @@ this.applyToInput = input; | ||
this.parsedField = parse(schemaField); | ||
this.schemaType = schemaType | ||
} | ||
@@ -136,3 +139,3 @@ | ||
private createTransformation(schemaField: string, schema: any): ApiEdgeSchemaTransformation|undefined { | ||
private createTransformation(schemaField: string, schema: any, typedSchema: any): ApiEdgeSchemaTransformation|undefined { | ||
const parsedSchemaField = parse(schemaField), | ||
@@ -164,2 +167,3 @@ transform: string|ApiEdgeSchemaTransformation = parsedSchemaField(schema); | ||
[ schemaField ], | ||
typedSchema ? typedSchema[schemaField] : Mixed, | ||
schemaField | ||
@@ -183,3 +187,3 @@ ); | ||
for(let i = 0; i < this.fields.length; ++i) { | ||
const transform = this.createTransformation(this.fields[i], schema); | ||
const transform = this.createTransformation(this.fields[i], schema, typedSchema); | ||
if(transform) | ||
@@ -186,0 +190,0 @@ this.transformations.push(transform) |
@@ -28,3 +28,4 @@ import {RawDataProvider} from "../data/RawDataProvider"; | ||
}, | ||
[ "firstName", "lastName" ] | ||
[ "firstName", "lastName" ], | ||
String | ||
), | ||
@@ -31,0 +32,0 @@ email: "=", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
698156
8522