@aws-amplify/graphql-model-transformer
Advanced tools
Comparing version 2.10.0 to 2.10.1
@@ -6,2 +6,8 @@ # Change Log | ||
## [2.10.1](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-model-transformer@2.10.0...@aws-amplify/graphql-model-transformer@2.10.1) (2024-05-15) | ||
### Bug Fixes | ||
- **api:** handle attribute type change on gsi ([#2542](https://github.com/aws-amplify/amplify-category-api/issues/2542)) ([f0a4709](https://github.com/aws-amplify/amplify-category-api/commit/f0a470990dd41966f802bb6ecb7b7ffa41a5c7d5)) | ||
# [2.10.0](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-model-transformer@2.9.1...@aws-amplify/graphql-model-transformer@2.10.0) (2024-05-10) | ||
@@ -8,0 +14,0 @@ |
@@ -373,2 +373,4 @@ "use strict"; | ||
const endStateGSINames = endStateGSIs.map((gsi) => gsi.indexName); | ||
const modifiedAttributes = getTypeModifiedAttributes(currentState.AttributeDefinitions, endState.attributeDefinitions); | ||
const indexesWithModifiedAttributeType = getIndexesContainingAttributes(currentState.GlobalSecondaryIndexes, modifiedAttributes); | ||
const currentStateGSIs = currentState.GlobalSecondaryIndexes || []; | ||
@@ -379,2 +381,4 @@ const currentStateGSINames = currentStateGSIs.map((gsi) => gsi.IndexName); | ||
return true; | ||
if (indexesWithModifiedAttributeType.includes(currentGSI.IndexName)) | ||
return true; | ||
const respectiveEndStateGSI = endStateGSIs.find((endStateGSI) => endStateGSI.indexName === currentGSI.IndexName); | ||
@@ -769,2 +773,25 @@ if (isProjectionModified(currentGSI.Projection, respectiveEndStateGSI.projection)) | ||
}; | ||
const getTypeModifiedAttributes = (currentSchema, endSchema) => { | ||
const result = []; | ||
if (!currentSchema || !endSchema) | ||
return result; | ||
for (const attribute of currentSchema) { | ||
const endAttribute = endSchema.find((endAttr) => endAttr.attributeName === attribute.AttributeName); | ||
if (!endAttribute) | ||
continue; | ||
if (attribute.AttributeType !== endAttribute.attributeType) { | ||
result.push(attribute.AttributeName); | ||
} | ||
} | ||
return result; | ||
}; | ||
const getIndexesContainingAttributes = (currentSchema, attributes) => { | ||
if (!currentSchema) | ||
return []; | ||
const result = currentSchema | ||
.filter((index) => index.IndexStatus === 'ACTIVE') | ||
.filter((index) => { var _a; return (_a = index.KeySchema) === null || _a === void 0 ? void 0 : _a.some((key) => attributes.includes(key.AttributeName)); }) | ||
.map((index) => index.IndexName); | ||
return result !== null && result !== void 0 ? result : []; | ||
}; | ||
const isTtlModified = (oldTtl, endTtl) => { | ||
@@ -771,0 +798,0 @@ if (oldTtl === undefined && endTtl === undefined) { |
{ | ||
"name": "@aws-amplify/graphql-model-transformer", | ||
"version": "2.10.0", | ||
"version": "2.10.1", | ||
"description": "Amplify graphql @model transformer", | ||
@@ -91,3 +91,3 @@ "repository": { | ||
}, | ||
"gitHead": "a6bd979529c1c7686ae3e9ad928f232d181114ab" | ||
"gitHead": "ae27c5cbeb0bce24a4fe91ea958123a897a7e72c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50239690
5244