From d7544bd6eb1b0726d461b501242d9a93340878d6 Mon Sep 17 00:00:00 2001 From: Hein Jeong Date: Wed, 4 Jan 2023 18:33:26 +0000 Subject: [PATCH] fix: remove functions imported from devDep --- package-lock.json | 5 ++--- packages/codegen-ui-golden-files/package-lock.json | 2 +- .../lib/forms/form-renderer-helper/model-values.ts | 5 ++--- .../lib/forms/form-renderer-helper/render-checkers.ts | 8 ++++++-- packages/codegen-ui-react/package-lock.json | 2 +- packages/codegen-ui/lib/utils/form-component-metadata.ts | 7 +++++-- packages/codegen-ui/package-lock.json | 2 +- packages/test-generator/package-lock.json | 2 +- 8 files changed, 19 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 123deb614..e88ee18c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18460,7 +18460,7 @@ "dev": true, "requires": { "is-ssh": "^1.3.0", - "parse-url": ">=6.0.1" + "parse-url": "^6.0.0" } }, "git-url-parse": { @@ -21457,8 +21457,7 @@ } }, "parse-url": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", + "version": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==", "dev": true, "requires": { diff --git a/packages/codegen-ui-golden-files/package-lock.json b/packages/codegen-ui-golden-files/package-lock.json index 92ef297f3..e055da805 100644 --- a/packages/codegen-ui-golden-files/package-lock.json +++ b/packages/codegen-ui-golden-files/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@aws-amplify/codegen-ui-golden-files", - "version": "2.7.0", + "version": "2.7.1", "license": "Apache-2.0", "dependencies": { "@aws-amplify/datastore": "^3.12.12", diff --git a/packages/codegen-ui-react/lib/forms/form-renderer-helper/model-values.ts b/packages/codegen-ui-react/lib/forms/form-renderer-helper/model-values.ts index 72fcb03dc..2ad584877 100644 --- a/packages/codegen-ui-react/lib/forms/form-renderer-helper/model-values.ts +++ b/packages/codegen-ui-react/lib/forms/form-renderer-helper/model-values.ts @@ -21,7 +21,6 @@ import { ConcatenatedStudioComponentProperty, } from '@aws-amplify/codegen-ui'; import { StudioFormInputFieldProperty } from '@aws-amplify/codegen-ui/lib/types/form/input-config'; -import { isEnumFieldType } from '@aws-amplify/datastore'; import { Expression, factory, @@ -44,7 +43,7 @@ import { } from '../../react-component-render-helper'; import { buildAccessChain, getRecordsName } from './form-state'; import { getElementAccessExpression, getValidProperty } from './invalid-variable-helpers'; -import { isModelDataType } from './render-checkers'; +import { isEnumDataType, isModelDataType } from './render-checkers'; export const getDisplayValueObjectName = 'getDisplayValue'; @@ -450,7 +449,7 @@ export function buildDisplayValueFunction(fieldName: string, fieldConfig: FieldC } } - if (isEnumFieldType(fieldConfig.dataType) && fieldConfig.valueMappings && fieldConfig.isArray) { + if (isEnumDataType(fieldConfig) && fieldConfig.valueMappings && fieldConfig.isArray) { const displayValueMapName = `enumDisplayValueMap`; additionalStatements = [ factory.createVariableStatement( diff --git a/packages/codegen-ui-react/lib/forms/form-renderer-helper/render-checkers.ts b/packages/codegen-ui-react/lib/forms/form-renderer-helper/render-checkers.ts index cffaba05e..cc4dc2dc2 100644 --- a/packages/codegen-ui-react/lib/forms/form-renderer-helper/render-checkers.ts +++ b/packages/codegen-ui-react/lib/forms/form-renderer-helper/render-checkers.ts @@ -14,7 +14,6 @@ limitations under the License. */ import { FieldConfigMetadata } from '@aws-amplify/codegen-ui'; -import { isEnumFieldType } from '@aws-amplify/datastore'; export const shouldWrapInArrayField = (config: FieldConfigMetadata): boolean => config.isArray || !!config.relationship; @@ -23,8 +22,13 @@ export const isModelDataType = ( ): config is FieldConfigMetadata & { dataType: { model: string } } => !!(config.dataType && typeof config.dataType === 'object' && 'model' in config.dataType); +export const isEnumDataType = ( + config: FieldConfigMetadata, +): config is FieldConfigMetadata & { dataType: { enum: string } } => + !!(config.dataType && typeof config.dataType === 'object' && 'enum' in config.dataType); + export const shouldImplementDisplayValueFunction = (config: FieldConfigMetadata): boolean => { - return isModelDataType(config) || (isEnumFieldType(config.dataType) && shouldWrapInArrayField(config)); + return isModelDataType(config) || (isEnumDataType(config) && shouldWrapInArrayField(config)); }; export const shouldImplementIDValueFunction = (config: FieldConfigMetadata): boolean => { diff --git a/packages/codegen-ui-react/package-lock.json b/packages/codegen-ui-react/package-lock.json index bdc017dd3..924cc3b6f 100644 --- a/packages/codegen-ui-react/package-lock.json +++ b/packages/codegen-ui-react/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@aws-amplify/codegen-ui-react", - "version": "2.7.0", + "version": "2.7.1", "license": "Apache-2.0", "dependencies": { "@typescript/vfs": "~1.3.5", diff --git a/packages/codegen-ui/lib/utils/form-component-metadata.ts b/packages/codegen-ui/lib/utils/form-component-metadata.ts index 0fe4280fa..d70c063b5 100644 --- a/packages/codegen-ui/lib/utils/form-component-metadata.ts +++ b/packages/codegen-ui/lib/utils/form-component-metadata.ts @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { isEnumFieldType } from '@aws-amplify/datastore'; import { camelCase } from 'change-case'; import { @@ -93,7 +92,11 @@ export const mapFormMetadata = (form: StudioForm, formDefinition: FormDefinition }); } - if ((element.relationship || isEnumFieldType(element.dataType)) && 'valueMappings' in element) { + if ( + (element.relationship || + (element.dataType && typeof element.dataType === 'object' && 'enum' in element.dataType)) && + 'valueMappings' in element + ) { metadata.valueMappings = element.valueMappings; } diff --git a/packages/codegen-ui/package-lock.json b/packages/codegen-ui/package-lock.json index c6f875e3b..d020549c2 100644 --- a/packages/codegen-ui/package-lock.json +++ b/packages/codegen-ui/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@aws-amplify/codegen-ui", - "version": "2.7.0", + "version": "2.7.1", "license": "Apache-2.0", "dependencies": { "change-case": "^4.1.2", diff --git a/packages/test-generator/package-lock.json b/packages/test-generator/package-lock.json index 7fc99fe39..a342aa3f4 100644 --- a/packages/test-generator/package-lock.json +++ b/packages/test-generator/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@aws-amplify/codegen-ui-test-generator", - "version": "2.7.0", + "version": "2.7.1", "license": "Apache-2.0", "dependencies": { "@types/node": "^15.12.1",