Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bzsurbhi committed Nov 27, 2024
1 parent 3d61929 commit dc5f7b0
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions packages/amplify-gen2-codegen/src/backend/synthesizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,8 @@ export class BackendSynthesizer {
throw new TypeError(`Unrecognized type: ${typeof value}`);
}

private createBooleanPropertyAssignment(identifier: string, condition: any) {
return factory.createPropertyAssignment(
factory.createIdentifier(identifier),
condition ?? null ? factory.createTrue() : factory.createFalse(),
);
private createBooleanPropertyAssignment(identifier: string, condition: boolean) {
return factory.createPropertyAssignment(factory.createIdentifier(identifier), condition ? factory.createTrue() : factory.createFalse());
}

private createListPropertyAssignment(identifier: string, listAttribute: string[]) {
Expand Down Expand Up @@ -242,7 +239,7 @@ export class BackendSynthesizer {
this.oAuthFlag = true;
objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
} else if (key == 'ClientSecret') {
objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, value));
objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, true));
} else if (key != 'DefaultRedirectURI') {
objectLiterals.push(this.createStringPropertyAssignment(mappedProperty, value));
}
Expand Down Expand Up @@ -335,9 +332,12 @@ export class BackendSynthesizer {
const standardAttributesLiterals: ts.PropertyAssignment[] = [];
standardAttributes.forEach((attribute) => {
if (standardAttrMap.has(attribute)) {
standardAttributesLiterals.push(
factory.createPropertyAssignment(factory.createIdentifier(standardAttrMap.get(attribute)!), factory.createTrue()),
);
const mappedAttribute = standardAttrMap.get(attribute);
if (mappedAttribute) {
standardAttributesLiterals.push(
factory.createPropertyAssignment(factory.createIdentifier(mappedAttribute), factory.createTrue()),
);
}
}
});

Expand Down Expand Up @@ -373,7 +373,10 @@ export class BackendSynthesizer {
const scopesList: string[] = [];
scopes.forEach((scope) => {
if (scopeMap.has(scope)) {
scopesList.push(scopeMap.get(scope)!);
const scopeValue = scopeMap.get(scope);
if (scopeValue) {
scopesList.push(scopeValue);
}
}
});
return scopesList;
Expand All @@ -390,9 +393,15 @@ export class BackendSynthesizer {
} else if (key == 'AllowedOAuthScopes') {
oAuthLiterals.push(this.createEnumListPropertyAssignment('scopes', 'OAuthScope', this.mapOAuthScopes(value)));
} else if (key == 'CallbackURLs' || key == 'LogoutURLs') {
oAuthLiterals.push(this.createListPropertyAssignment(map.get(key)!, value));
const urlValue = map.get(key);
if (urlValue) {
oAuthLiterals.push(this.createListPropertyAssignment(urlValue, value));
}
} else if (key == 'DefaultRedirectURI') {
oAuthLiterals.push(this.createStringPropertyAssignment(map.get(key)!, value));
const redirectUriValue = map.get(key);
if (redirectUriValue) {
oAuthLiterals.push(this.createStringPropertyAssignment(redirectUriValue, value));
}
}
}
return factory.createPropertyAssignment(factory.createIdentifier('oAuth'), factory.createObjectLiteralExpression(oAuthLiterals, true));
Expand Down

0 comments on commit dc5f7b0

Please sign in to comment.