Socket
Socket
Sign inDemoInstall

@aws-amplify/graphql-model-transformer

Package Overview
Dependencies
57
Maintainers
10
Versions
408
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.8.0 to 2.9.0-0411-gen2.0

6

API.md

@@ -84,6 +84,6 @@ ## API Report File for "@aws-amplify/graphql-model-transformer"

// @public (undocumented)
export const generateAuthExpressionForSandboxMode: (enabled: boolean) => string;
export function generateModelScalarFilterInputName(typeName: string, includeFilter: boolean, isSubscriptionFilter?: boolean): string;
// @public (undocumented)
export function generateModelScalarFilterInputName(typeName: string, includeFilter: boolean, isSubscriptionFilter?: boolean): string;
export const generatePostAuthExpression: (isSandboxModeEnabled: boolean, genericIamAccessEnabled: boolean | undefined) => string;

@@ -317,3 +317,3 @@ // @public (undocumented)

// @public (undocumented)
export const propagateApiKeyToNestedTypes: (ctx: TransformerContextProvider, def: ObjectTypeDefinitionNode, seenNonModelTypes: Set<string>) => void;
export const propagateDirectivesToNestedTypes: (ctx: TransformerContextProvider, def: ObjectTypeDefinitionNode, seenNonModelTypes: Set<string>, serviceDirectives: DirectiveNode[]) => void;

@@ -320,0 +320,0 @@ // Warning: (ae-forgotten-export) The symbol "ModelResourceGenerator" needs to be exported by the entry point index.d.ts

@@ -6,2 +6,8 @@ # Change Log

# [2.9.0-0411-gen2.0](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-model-transformer@2.8.0...@aws-amplify/graphql-model-transformer@2.9.0-0411-gen2.0) (2024-04-11)
### Features
- generic iam authorization ([#2385](https://github.com/aws-amplify/amplify-category-api/issues/2385)) ([550ee80](https://github.com/aws-amplify/amplify-category-api/commit/550ee803275817d25447ff1400d55eb1ad4cd0c2))
# [2.8.0](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-model-transformer@2.7.0...@aws-amplify/graphql-model-transformer@2.8.0) (2024-04-11)

@@ -8,0 +14,0 @@

@@ -20,2 +20,3 @@ export declare const STRING_CONDITIONS: string[];

export declare const API_KEY_DIRECTIVE = "aws_api_key";
export declare const AWS_IAM_DIRECTIVE = "aws_iam";
//# sourceMappingURL=definitions.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.API_KEY_DIRECTIVE = exports.OPERATION_KEY = exports.ATTRIBUTE_TYPES = exports.BOOLEAN_FUNCTIONS = exports.FLOAT_FUNCTIONS = exports.INT_FUNCTIONS = exports.ID_FUNCTIONS = exports.STRING_FUNCTIONS = exports.SUBSCRIPTION_BOOLEAN_CONDITIONS = exports.SUBSCRIPTION_FLOAT_CONDITIONS = exports.SUBSCRIPTION_INT_CONDITIONS = exports.SUBSCRIPTION_ID_CONDITIONS = exports.SUBSCRIPTION_STRING_CONDITIONS = exports.SIZE_CONDITIONS = exports.BOOLEAN_CONDITIONS = exports.FLOAT_CONDITIONS = exports.INT_CONDITIONS = exports.ID_CONDITIONS = exports.STRING_CONDITIONS = void 0;
exports.AWS_IAM_DIRECTIVE = exports.API_KEY_DIRECTIVE = exports.OPERATION_KEY = exports.ATTRIBUTE_TYPES = exports.BOOLEAN_FUNCTIONS = exports.FLOAT_FUNCTIONS = exports.INT_FUNCTIONS = exports.ID_FUNCTIONS = exports.STRING_FUNCTIONS = exports.SUBSCRIPTION_BOOLEAN_CONDITIONS = exports.SUBSCRIPTION_FLOAT_CONDITIONS = exports.SUBSCRIPTION_INT_CONDITIONS = exports.SUBSCRIPTION_ID_CONDITIONS = exports.SUBSCRIPTION_STRING_CONDITIONS = exports.SIZE_CONDITIONS = exports.BOOLEAN_CONDITIONS = exports.FLOAT_CONDITIONS = exports.INT_CONDITIONS = exports.ID_CONDITIONS = exports.STRING_CONDITIONS = void 0;
exports.STRING_CONDITIONS = ['ne', 'eq', 'le', 'lt', 'ge', 'gt', 'contains', 'notContains', 'between', 'beginsWith'];

@@ -49,2 +49,3 @@ exports.ID_CONDITIONS = ['ne', 'eq', 'le', 'lt', 'ge', 'gt', 'contains', 'notContains', 'between', 'beginsWith'];

exports.API_KEY_DIRECTIVE = 'aws_api_key';
exports.AWS_IAM_DIRECTIVE = 'aws_iam';
//# sourceMappingURL=definitions.js.map

@@ -158,18 +158,31 @@ "use strict";

}
if (!hasAuth && ctx.transformParameters.sandboxModeEnabled && ctx.authConfig.defaultAuthentication.authenticationType !== 'API_KEY') {
const apiKeyDirArray = [(0, graphql_transformer_common_1.makeDirective)(definitions_1.API_KEY_DIRECTIVE, [])];
(0, graphql_types_1.extendTypeWithDirectives)(ctx, def.name.value, apiKeyDirArray);
(0, graphql_types_1.propagateApiKeyToNestedTypes)(ctx, def, new Set());
queryFields.forEach((operationField) => {
const operationName = operationField.name.value;
(0, graphql_types_1.addDirectivesToOperation)(ctx, ctx.output.getQueryTypeName(), operationName, apiKeyDirArray);
});
mutationFields.forEach((operationField) => {
const operationName = operationField.name.value;
(0, graphql_types_1.addDirectivesToOperation)(ctx, ctx.output.getMutationTypeName(), operationName, apiKeyDirArray);
});
subscriptionsFields.forEach((operationField) => {
const operationName = operationField.name.value;
(0, graphql_types_1.addDirectivesToOperation)(ctx, ctx.output.getSubscriptionTypeName(), operationName, apiKeyDirArray);
});
if (!hasAuth) {
const serviceDirectiveNames = new Set();
if (ctx.transformParameters.sandboxModeEnabled && ctx.synthParameters.enableIamAccess) {
serviceDirectiveNames.add(definitions_1.API_KEY_DIRECTIVE);
serviceDirectiveNames.add(definitions_1.AWS_IAM_DIRECTIVE);
}
else if (ctx.transformParameters.sandboxModeEnabled && ctx.authConfig.defaultAuthentication.authenticationType !== 'API_KEY') {
serviceDirectiveNames.add(definitions_1.API_KEY_DIRECTIVE);
}
else if (ctx.synthParameters.enableIamAccess && ctx.authConfig.defaultAuthentication.authenticationType !== 'AWS_IAM') {
serviceDirectiveNames.add(definitions_1.AWS_IAM_DIRECTIVE);
}
const serviceDirectives = [...serviceDirectiveNames].map((directiveName) => (0, graphql_transformer_common_1.makeDirective)(directiveName, []));
if (serviceDirectives.length > 0) {
(0, graphql_types_1.extendTypeWithDirectives)(ctx, def.name.value, serviceDirectives);
(0, graphql_types_1.propagateDirectivesToNestedTypes)(ctx, def, new Set(), serviceDirectives);
queryFields.forEach((operationField) => {
const operationName = operationField.name.value;
(0, graphql_types_1.addDirectivesToOperation)(ctx, ctx.output.getQueryTypeName(), operationName, serviceDirectives);
});
mutationFields.forEach((operationField) => {
const operationName = operationField.name.value;
(0, graphql_types_1.addDirectivesToOperation)(ctx, ctx.output.getMutationTypeName(), operationName, serviceDirectives);
});
subscriptionsFields.forEach((operationField) => {
const operationName = operationField.name.value;
(0, graphql_types_1.addDirectivesToOperation)(ctx, ctx.output.getSubscriptionTypeName(), operationName, serviceDirectives);
});
}
}

@@ -176,0 +189,0 @@ });

@@ -20,3 +20,3 @@ import { TransformerContextProvider, TransformerTransformSchemaStepContextProvider } from '@aws-amplify/graphql-transformer-interfaces';

export declare const makeModelSortDirectionEnumObject: () => EnumTypeDefinitionNode;
export declare const propagateApiKeyToNestedTypes: (ctx: TransformerContextProvider, def: ObjectTypeDefinitionNode, seenNonModelTypes: Set<string>) => void;
export declare const propagateDirectivesToNestedTypes: (ctx: TransformerContextProvider, def: ObjectTypeDefinitionNode, seenNonModelTypes: Set<string>, serviceDirectives: DirectiveNode[]) => void;
//# sourceMappingURL=common.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.propagateApiKeyToNestedTypes = exports.makeModelSortDirectionEnumObject = exports.extendTypeWithDirectives = exports.addDirectivesToOperation = exports.addDirectivesToField = exports.makeEnumFilterInput = exports.makeSizeInputType = exports.makeSubscriptionField = exports.makeAttributeTypeEnum = exports.makeModelScalarFilterInputObject = exports.createEnumModelFilters = exports.generateModelScalarFilterInputName = exports.addModelConditionInputs = exports.removeSubscriptionFilterInputAttribute = exports.getSubscriptionFilterInputName = exports.makeSubscriptionFilterInput = exports.makeConditionFilterInput = void 0;
exports.propagateDirectivesToNestedTypes = exports.makeModelSortDirectionEnumObject = exports.extendTypeWithDirectives = exports.addDirectivesToOperation = exports.addDirectivesToField = exports.makeEnumFilterInput = exports.makeSizeInputType = exports.makeSubscriptionField = exports.makeAttributeTypeEnum = exports.makeModelScalarFilterInputObject = exports.createEnumModelFilters = exports.generateModelScalarFilterInputName = exports.addModelConditionInputs = exports.removeSubscriptionFilterInputAttribute = exports.getSubscriptionFilterInputName = exports.makeSubscriptionFilterInput = exports.makeConditionFilterInput = void 0;
const graphql_1 = require("graphql");

@@ -290,3 +290,3 @@ const graphql_transformer_common_1 = require("graphql-transformer-common");

exports.makeModelSortDirectionEnumObject = makeModelSortDirectionEnumObject;
const propagateApiKeyToNestedTypes = (ctx, def, seenNonModelTypes) => {
const propagateDirectivesToNestedTypes = (ctx, def, seenNonModelTypes, serviceDirectives) => {
var _a, _b;

@@ -309,11 +309,15 @@ const nonModelTypePredicate = (fieldType) => {

const hasSeenType = seenNonModelTypes.has(nonModelName);
const hasApiKey = (_b = (_a = nonModelFieldType.directives) === null || _a === void 0 ? void 0 : _a.some((dir) => dir.name.value === definitions_1.API_KEY_DIRECTIVE)) !== null && _b !== void 0 ? _b : false;
if (!hasSeenType && !hasApiKey) {
if (!hasSeenType) {
for (const serviceDirective of serviceDirectives) {
const hasDirective = (_b = (_a = nonModelFieldType.directives) === null || _a === void 0 ? void 0 : _a.some((dir) => dir.name.value === serviceDirective.name.value)) !== null && _b !== void 0 ? _b : false;
if (!hasDirective) {
(0, exports.extendTypeWithDirectives)(ctx, nonModelName, [serviceDirective]);
}
}
seenNonModelTypes.add(nonModelName);
(0, exports.extendTypeWithDirectives)(ctx, nonModelName, [(0, graphql_transformer_common_1.makeDirective)(definitions_1.API_KEY_DIRECTIVE, [])]);
(0, exports.propagateApiKeyToNestedTypes)(ctx, nonModelFieldType, seenNonModelTypes);
(0, exports.propagateDirectivesToNestedTypes)(ctx, nonModelFieldType, seenNonModelTypes, serviceDirectives);
}
}
};
exports.propagateApiKeyToNestedTypes = propagateApiKeyToNestedTypes;
exports.propagateDirectivesToNestedTypes = propagateDirectivesToNestedTypes;
//# sourceMappingURL=common.js.map

@@ -1,3 +0,3 @@

export declare const generateAuthExpressionForSandboxMode: (enabled: boolean) => string;
export declare const generatePostAuthExpression: (isSandboxModeEnabled: boolean, genericIamAccessEnabled: boolean | undefined) => string;
export declare const generateResolverKey: (typeName: string, fieldName: string) => string;
//# sourceMappingURL=common.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateResolverKey = exports.generateAuthExpressionForSandboxMode = void 0;
exports.generateResolverKey = exports.generatePostAuthExpression = void 0;
const graphql_mapping_template_1 = require("graphql-mapping-template");
const API_KEY = 'API Key Authorization';
const generateAuthExpressionForSandboxMode = (enabled) => {
let exp;
if (enabled)
exp = (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.notEquals)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.authType')), (0, graphql_mapping_template_1.str)(API_KEY)), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.unauthorized')));
else
exp = (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.unauthorized'));
return (0, graphql_mapping_template_1.printBlock)(`Sandbox Mode ${enabled ? 'Enabled' : 'Disabled'}`)((0, graphql_mapping_template_1.compoundExpression)([(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.ref)('ctx.stash.get("hasAuth")')), exp), (0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.obj)({}))]));
const IAM_AUTH_TYPE = 'IAM Authorization';
const generatePostAuthExpression = (isSandboxModeEnabled, genericIamAccessEnabled) => {
const expressions = [];
if (isSandboxModeEnabled) {
expressions.push((0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.authType')), (0, graphql_mapping_template_1.str)(API_KEY)), (0, graphql_mapping_template_1.ret)((0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.obj)({})))));
}
if (genericIamAccessEnabled) {
const isNonCognitoIAMPrincipal = (0, graphql_mapping_template_1.and)([
(0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('util.authType()'), (0, graphql_mapping_template_1.str)(IAM_AUTH_TYPE)),
(0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.isNull'), (0, graphql_mapping_template_1.ref)('ctx.identity.cognitoIdentityPoolId')),
(0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.isNull'), (0, graphql_mapping_template_1.ref)('ctx.identity.cognitoIdentityId')),
]);
expressions.push((0, graphql_mapping_template_1.iff)(isNonCognitoIAMPrincipal, (0, graphql_mapping_template_1.ret)((0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.obj)({})))));
}
expressions.push((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.unauthorized')));
return (0, graphql_mapping_template_1.printBlock)(`Sandbox Mode ${isSandboxModeEnabled ? 'Enabled' : 'Disabled'}, IAM Access ${genericIamAccessEnabled ? 'Enabled' : 'Disabled'}`)((0, graphql_mapping_template_1.compoundExpression)([(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.ref)('ctx.stash.get("hasAuth")')), (0, graphql_mapping_template_1.compoundExpression)(expressions)), (0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.obj)({}))]));
};
exports.generateAuthExpressionForSandboxMode = generateAuthExpressionForSandboxMode;
exports.generatePostAuthExpression = generatePostAuthExpression;
const generateResolverKey = (typeName, fieldName) => {

@@ -16,0 +25,0 @@ return `${typeName}.${fieldName}`;

@@ -358,3 +358,3 @@ "use strict";

}
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, resolvers_1.generateAuthExpressionForSandboxMode)(context.transformParameters.sandboxModeEnabled), `${query.typeName}.${query.fieldName}.{slotName}.{slotIndex}.req.vtl`));
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, resolvers_1.generatePostAuthExpression)(context.transformParameters.sandboxModeEnabled, context.synthParameters.enableIamAccess), `${query.typeName}.${query.fieldName}.{slotName}.{slotIndex}.req.vtl`));
resolver.setScope(context.stackManager.getScopeFor(query.resolverLogicalId, def.name.value));

@@ -379,3 +379,3 @@ context.resolvers.addResolver(query.typeName, query.fieldName, resolver);

}
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, resolvers_1.generateAuthExpressionForSandboxMode)(context.transformParameters.sandboxModeEnabled), `${mutation.typeName}.${mutation.fieldName}.{slotName}.{slotIndex}.req.vtl`));
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, resolvers_1.generatePostAuthExpression)(context.transformParameters.sandboxModeEnabled, context.synthParameters.enableIamAccess), `${mutation.typeName}.${mutation.fieldName}.{slotName}.{slotIndex}.req.vtl`));
resolver.setScope(context.stackManager.getScopeFor(mutation.resolverLogicalId, def.name.value));

@@ -403,3 +403,3 @@ context.resolvers.addResolver(mutation.typeName, mutation.fieldName, resolver);

if (subscriptionLevel === directive_1.SubscriptionLevel.on) {
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, resolvers_1.generateAuthExpressionForSandboxMode)(context.transformParameters.sandboxModeEnabled), `${subscription.typeName}.${subscription.fieldName}.{slotName}.{slotIndex}.req.vtl`));
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, resolvers_1.generatePostAuthExpression)(context.transformParameters.sandboxModeEnabled, context.synthParameters.enableIamAccess), `${subscription.typeName}.${subscription.fieldName}.{slotName}.{slotIndex}.req.vtl`));
}

@@ -406,0 +406,0 @@ resolver.setScope(context.stackManager.getScopeFor(subscription.resolverLogicalId, def.name.value));

{
"name": "@aws-amplify/graphql-model-transformer",
"version": "2.8.0",
"version": "2.9.0-0411-gen2.0",
"description": "Amplify graphql @model transformer",

@@ -35,8 +35,8 @@ "repository": {

"dependencies": {
"@aws-amplify/graphql-directives": "1.0.1",
"@aws-amplify/graphql-transformer-core": "2.6.0",
"@aws-amplify/graphql-transformer-interfaces": "3.6.0",
"@aws-amplify/graphql-directives": "1.1.0-0411-gen2.0",
"@aws-amplify/graphql-transformer-core": "2.6.1-0411-gen2.0",
"@aws-amplify/graphql-transformer-interfaces": "3.7.0-0411-gen2.0",
"graphql": "^15.5.0",
"graphql-mapping-template": "4.20.15",
"graphql-transformer-common": "4.30.0"
"graphql-transformer-common": "4.30.1-0411-gen2.0"
},

@@ -48,3 +48,3 @@ "peerDependencies": {

"devDependencies": {
"@aws-amplify/graphql-transformer-test-utils": "0.5.0",
"@aws-amplify/graphql-transformer-test-utils": "0.5.1-0411-gen2.0",
"@aws-sdk/client-dynamodb": "^3.431.0",

@@ -92,3 +92,3 @@ "@types/aws-lambda": "8.10.119",

},
"gitHead": "1f63fca870b3485093cbb62ef3b5e4923455b0c1"
"gitHead": "b0c2902888a00f94d789a3b42619f5f9f4bb5a39"
}

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc