@aws-amplify/data-schema 0.14.12 → 0.14.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaProcessor.d.ts","sourceRoot":"","sources":["../../src/SchemaProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAsBzE,OAAO,EACL,oBAAoB,EAMrB,MAAM,gCAAgC,CAAC;AA8nDxC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE;IACjC,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG,oBAAoB,CAiBvB"}
1
+ {"version":3,"file":"SchemaProcessor.d.ts","sourceRoot":"","sources":["../../src/SchemaProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAsBzE,OAAO,EACL,oBAAoB,EAMrB,MAAM,gCAAgC,CAAC;AA4nDxC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE;IACjC,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG,oBAAoB,CAiBvB"}
@@ -155,7 +155,7 @@ function refFieldToGql(fieldDef) {
155
155
  }
156
156
  return field;
157
157
  }
158
- function transformFunctionHandler(handlers, callSignature) {
158
+ function transformFunctionHandler(handlers, functionFieldName) {
159
159
  let gqlHandlerContent = '';
160
160
  const lambdaFunctionDefinition = {};
161
161
  handlers.forEach((handler, idx) => {
@@ -164,14 +164,12 @@ function transformFunctionHandler(handlers, callSignature) {
164
164
  gqlHandlerContent += `@function(name: "${handlerData}") `;
165
165
  }
166
166
  else if (typeof handlerData.getInstance === 'function') {
167
- const fnBaseName = `Fn${capitalize(callSignature)}`;
168
- const fnNameSuffix = idx === 0 ? '' : `${idx + 1}`;
169
- const fnName = fnBaseName + fnNameSuffix;
167
+ const fnName = `Fn${capitalize(functionFieldName)}${idx === 0 ? '' : `${idx + 1}`}`;
170
168
  lambdaFunctionDefinition[fnName] = handlerData;
171
169
  gqlHandlerContent += `@function(name: "${fnName}") `;
172
170
  }
173
171
  else {
174
- throw new Error(`Invalid value specified for ${callSignature} handler.function(). Expected: defineFunction or string.`);
172
+ throw new Error(`Invalid value specified for ${functionFieldName} handler.function(). Expected: defineFunction or string.`);
175
173
  }
176
174
  });
177
175
  return { gqlHandlerContent, lambdaFunctionDefinition };
@@ -240,7 +238,7 @@ function customOperationToGql(typeName, typeDef, authorization, isCustom = false
240
238
  let lambdaFunctionDefinition = {};
241
239
  let customSqlDataSourceStrategy;
242
240
  if (isFunctionHandler(handlers)) {
243
- ({ gqlHandlerContent, lambdaFunctionDefinition } = transformFunctionHandler(handlers, callSignature));
241
+ ({ gqlHandlerContent, lambdaFunctionDefinition } = transformFunctionHandler(handlers, typeName));
244
242
  }
245
243
  else if (functionRef) {
246
244
  gqlHandlerContent = `@function(name: "${functionRef}") `;
@@ -821,7 +819,7 @@ const schemaPreprocessor = (schema) => {
821
819
  const customMutations = [];
822
820
  const customSubscriptions = [];
823
821
  const jsFunctions = [];
824
- let lambdaFunctions = {};
822
+ const lambdaFunctions = {};
825
823
  const customSqlDataSourceStrategies = [];
826
824
  const databaseType = schema.data.configuration.database.engine === 'dynamodb'
827
825
  ? 'dynamodb'
@@ -859,7 +857,7 @@ const schemaPreprocessor = (schema) => {
859
857
  else if (isCustomOperation(typeDef)) {
860
858
  const { typeName: opType } = typeDef.data;
861
859
  const { gqlField, models, jsFunctionForField, lambdaFunctionDefinition, customSqlDataSourceStrategy, } = transformCustomOperations(typeDef, typeName, mostRelevantAuthRules, databaseType, getRefType);
862
- lambdaFunctions = lambdaFunctionDefinition;
860
+ Object.assign(lambdaFunctions, lambdaFunctionDefinition);
863
861
  topLevelTypes.push(...models);
864
862
  if (jsFunctionForField) {
865
863
  jsFunctions.push(jsFunctionForField);