diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..eb4d9d5 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/.gitignore b/.gitignore index 8aa674e..61dbce3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules # local env files .env.local .env.*.local +.env.json # Log files npm-debug.log* @@ -42,3 +43,6 @@ amplifytools.xcconfig .secret-* **.sample #amplify-do-not-edit-end + +C:/Users/ZachEgner/Documents/MicroHealthRepo/chart-app-frontend/amplify/mock-data +amplify/mock-api-resources \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Channel.gauges.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Channel.gauges.auth.1.req.vtl new file mode 100644 index 0000000..8856d63 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Channel.gauges.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Channel.gauges.req.vtl b/amplify/backend/api/mrms/resolvers/Channel.gauges.req.vtl new file mode 100644 index 0000000..91e5fdd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Channel.gauges.req.vtl @@ -0,0 +1,68 @@ +#if( $ctx.source.deniedField ) + #return($util.toJson(null)) +#end +#if( $util.isNull($ctx.source.id) ) + #set( $result = { + "items": [] +} ) + #return($result) +#else + #set( $limit = $util.defaultIfNull($context.args.limit, 100) ) + #set( $query = { + "expression": "#partitionKey = :partitionKey", + "expressionNames": { + "#partitionKey": "channelId" + }, + "expressionValues": { + ":partitionKey": $util.dynamodb.toDynamoDB($context.source.id) + } +} ) + #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) + #if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + #set( $filter = $ctx.stash.authFilter ) + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = { + "and": [$filter, $args.filter] +} ) + #end + #else + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = $args.filter ) + #end + #end + #if( !$util.isNullOrEmpty($filter) ) + #set( $filterExpression = $util.parseJson($util.transform.toDynamoDBFilterExpression($filter)) ) + #if( !$util.isNullOrBlank($filterExpression.expression) ) + #if( $filterExpression.expressionValues.size() == 0 ) + $util.qr($filterExpression.remove("expressionValues")) + #end + #set( $filter = $filterExpression ) + #end + #end +{ + "version": "2018-05-29", + "operation": "Query", + "query": $util.toJson($query), + "scanIndexForward": #if( $context.args.sortDirection ) + #if( $context.args.sortDirection == "ASC" ) +true + #else +false + #end + #else +true + #end, + "filter": #if( $filter ) +$util.toJson($filter) + #else +null + #end, + "limit": $limit, + "nextToken": #if( $context.args.nextToken ) +$util.toJson($context.args.nextToken) + #else +null + #end, + "index": "byChannel" + } +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Channel.gauges.res.vtl b/amplify/backend/api/mrms/resolvers/Channel.gauges.res.vtl new file mode 100644 index 0000000..b8c6c7e --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Channel.gauges.res.vtl @@ -0,0 +1,8 @@ +#if( $ctx.error ) +$util.error($ctx.error.message, $ctx.error.type) +#else + #if( !$result ) + #set( $result = $ctx.result ) + #end + $util.toJson($result) +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Dashboard.gauges.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Dashboard.gauges.auth.1.req.vtl new file mode 100644 index 0000000..8856d63 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Dashboard.gauges.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Dashboard.gauges.req.vtl b/amplify/backend/api/mrms/resolvers/Dashboard.gauges.req.vtl new file mode 100644 index 0000000..91e5fdd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Dashboard.gauges.req.vtl @@ -0,0 +1,68 @@ +#if( $ctx.source.deniedField ) + #return($util.toJson(null)) +#end +#if( $util.isNull($ctx.source.id) ) + #set( $result = { + "items": [] +} ) + #return($result) +#else + #set( $limit = $util.defaultIfNull($context.args.limit, 100) ) + #set( $query = { + "expression": "#partitionKey = :partitionKey", + "expressionNames": { + "#partitionKey": "channelId" + }, + "expressionValues": { + ":partitionKey": $util.dynamodb.toDynamoDB($context.source.id) + } +} ) + #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) + #if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + #set( $filter = $ctx.stash.authFilter ) + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = { + "and": [$filter, $args.filter] +} ) + #end + #else + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = $args.filter ) + #end + #end + #if( !$util.isNullOrEmpty($filter) ) + #set( $filterExpression = $util.parseJson($util.transform.toDynamoDBFilterExpression($filter)) ) + #if( !$util.isNullOrBlank($filterExpression.expression) ) + #if( $filterExpression.expressionValues.size() == 0 ) + $util.qr($filterExpression.remove("expressionValues")) + #end + #set( $filter = $filterExpression ) + #end + #end +{ + "version": "2018-05-29", + "operation": "Query", + "query": $util.toJson($query), + "scanIndexForward": #if( $context.args.sortDirection ) + #if( $context.args.sortDirection == "ASC" ) +true + #else +false + #end + #else +true + #end, + "filter": #if( $filter ) +$util.toJson($filter) + #else +null + #end, + "limit": $limit, + "nextToken": #if( $context.args.nextToken ) +$util.toJson($context.args.nextToken) + #else +null + #end, + "index": "byChannel" + } +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Dashboard.gauges.res.vtl b/amplify/backend/api/mrms/resolvers/Dashboard.gauges.res.vtl new file mode 100644 index 0000000..b8c6c7e --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Dashboard.gauges.res.vtl @@ -0,0 +1,8 @@ +#if( $ctx.error ) +$util.error($ctx.error.message, $ctx.error.type) +#else + #if( !$result ) + #set( $result = $ctx.result ) + #end + $util.toJson($result) +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Dashboard.reports.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Dashboard.reports.auth.1.req.vtl new file mode 100644 index 0000000..8856d63 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Dashboard.reports.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Dashboard.reports.req.vtl b/amplify/backend/api/mrms/resolvers/Dashboard.reports.req.vtl new file mode 100644 index 0000000..91e5fdd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Dashboard.reports.req.vtl @@ -0,0 +1,68 @@ +#if( $ctx.source.deniedField ) + #return($util.toJson(null)) +#end +#if( $util.isNull($ctx.source.id) ) + #set( $result = { + "items": [] +} ) + #return($result) +#else + #set( $limit = $util.defaultIfNull($context.args.limit, 100) ) + #set( $query = { + "expression": "#partitionKey = :partitionKey", + "expressionNames": { + "#partitionKey": "channelId" + }, + "expressionValues": { + ":partitionKey": $util.dynamodb.toDynamoDB($context.source.id) + } +} ) + #set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) + #if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + #set( $filter = $ctx.stash.authFilter ) + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = { + "and": [$filter, $args.filter] +} ) + #end + #else + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = $args.filter ) + #end + #end + #if( !$util.isNullOrEmpty($filter) ) + #set( $filterExpression = $util.parseJson($util.transform.toDynamoDBFilterExpression($filter)) ) + #if( !$util.isNullOrBlank($filterExpression.expression) ) + #if( $filterExpression.expressionValues.size() == 0 ) + $util.qr($filterExpression.remove("expressionValues")) + #end + #set( $filter = $filterExpression ) + #end + #end +{ + "version": "2018-05-29", + "operation": "Query", + "query": $util.toJson($query), + "scanIndexForward": #if( $context.args.sortDirection ) + #if( $context.args.sortDirection == "ASC" ) +true + #else +false + #end + #else +true + #end, + "filter": #if( $filter ) +$util.toJson($filter) + #else +null + #end, + "limit": $limit, + "nextToken": #if( $context.args.nextToken ) +$util.toJson($context.args.nextToken) + #else +null + #end, + "index": "byChannel" + } +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Dashboard.reports.res.vtl b/amplify/backend/api/mrms/resolvers/Dashboard.reports.res.vtl new file mode 100644 index 0000000..b8c6c7e --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Dashboard.reports.res.vtl @@ -0,0 +1,8 @@ +#if( $ctx.error ) +$util.error($ctx.error.message, $ctx.error.type) +#else + #if( !$result ) + #set( $result = $ctx.result ) + #end + $util.toJson($result) +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Gauge.channel.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Gauge.channel.auth.1.req.vtl new file mode 100644 index 0000000..8856d63 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Gauge.channel.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Gauge.dashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Gauge.dashboard.auth.1.req.vtl new file mode 100644 index 0000000..8856d63 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Gauge.dashboard.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Gauge.dashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Gauge.dashboard.req.vtl new file mode 100644 index 0000000..1becec2 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Gauge.dashboard.req.vtl @@ -0,0 +1,24 @@ +#if( $ctx.source.deniedField ) + #return($util.toJson(null)) +#end +#if( $util.isNull($ctx.source.dashboardId) ) + #return +#else + #set( $GetRequest = { + "version": "2018-05-29", + "operation": "Query" +} ) + $util.qr($GetRequest.put("query", { + "expression": "#partitionKey = :partitionValue", + "expressionNames": { + "#partitionKey": "id" + }, + "expressionValues": { + ":partitionValue": $util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.dashboardId, "___xamznone____"))) + } +})) + #if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + $util.qr($GetRequest.put("filter", $util.parseJson($util.transform.toDynamoDBFilterExpression($ctx.stash.authFilter)))) + #end + $util.toJson($GetRequest) +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Gauge.dashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Gauge.dashboard.res.vtl new file mode 100644 index 0000000..5c6d459 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Gauge.dashboard.res.vtl @@ -0,0 +1,12 @@ +#if( $ctx.error ) +$util.error($ctx.error.message, $ctx.error.type) +#else + #if( !$ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) + $util.toJson($ctx.result.items[0]) + #else + #if( $ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) +$util.unauthorized() + #end + $util.toJson(null) + #end +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createChannelType.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createChannelType.req.vtl new file mode 100644 index 0000000..b02b5ef --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createChannelType.req.vtl @@ -0,0 +1,66 @@ +## [Start] Create Request template. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +## Set the default values to put request ** +#set( $mergedValues = $util.defaultIfNull($ctx.stash.defaultValues, {}) ) +## copy the values from input ** +$util.qr($mergedValues.putAll($util.defaultIfNull($args.input, {}))) +## set the typename ** +$util.qr($mergedValues.put("__typename", "ChannelType")) +#set( $PutObject = { + "version": "2018-05-29", + "operation": "PutItem", + "attributeValues": $util.dynamodb.toMapValues($mergedValues), + "condition": $condition +} ) +#if( $args.condition ) + $util.qr($ctx.stash.conditions.add($args.condition)) +#end +## Begin - key condition ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyConditionExpr = {} ) + #set( $keyConditionExprNames = {} ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyConditionExpr.put("keyCondition$velocityCount", { + "attributeExists": false +})) + $util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key")) + #end + $util.qr($ctx.stash.conditions.add($keyConditionExpr)) +#else + $util.qr($ctx.stash.conditions.add({ + "id": { + "attributeExists": false + } +})) +#end +## End - key condition ** +## Start condition block ** +#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 ) + #set( $mergedConditions = { + "and": $ctx.stash.conditions +} ) + #set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) ) + #if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 ) + #set( $Conditions = { + "expression": $Conditions.expression, + "expressionNames": $Conditions.expressionNames +} ) + #end + ## End condition block ** +#end +#if( $Conditions ) + #if( $keyConditionExprNames ) + $util.qr($Conditions.expressionNames.putAll($keyConditionExprNames)) + #end + $util.qr($PutObject.put("condition", $Conditions)) +#end +#if( $ctx.stash.metadata.modelObjectKey ) + $util.qr($PutObject.put("key", $ctx.stash.metadata.modelObjectKey)) +#else + #set( $Key = { + "id": $util.dynamodb.toDynamoDB($mergedValues.id) +} ) + $util.qr($PutObject.put("key", $Key)) +#end +$util.toJson($PutObject) +## [End] Create Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.auth.1.req.vtl new file mode 100644 index 0000000..f166a55 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.auth.1.req.vtl @@ -0,0 +1,19 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $inputFields = $util.parseJson($util.toJson($ctx.args.input.keySet())) ) +#set( $isAuthorized = false ) +#set( $allowedFields = [] ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $allowedFields.isEmpty() ) +$util.unauthorized() +#end +#if( !$isAuthorized ) + #set( $deniedFields = $util.list.copyAndRemoveAll($inputFields, $allowedFields) ) + #if( $deniedFields.size() > 0 ) + $util.error("Unauthorized on ${deniedFields}", "Unauthorized") + #end +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.init.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.init.1.req.vtl new file mode 100644 index 0000000..44dbbd2 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.init.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Initialization default values. ** +$util.qr($ctx.stash.put("defaultValues", $util.defaultIfNull($ctx.stash.defaultValues, {}))) +#set( $createdAt = $util.time.nowISO8601() ) +$util.qr($ctx.stash.defaultValues.put("id", $util.autoId())) +$util.qr($ctx.stash.defaultValues.put("createdAt", $createdAt)) +$util.qr($ctx.stash.defaultValues.put("updatedAt", $createdAt)) +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Initialization default values. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.req.vtl new file mode 100644 index 0000000..26d3cee --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.req.vtl @@ -0,0 +1,66 @@ +## [Start] Create Request template. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +## Set the default values to put request ** +#set( $mergedValues = $util.defaultIfNull($ctx.stash.defaultValues, {}) ) +## copy the values from input ** +$util.qr($mergedValues.putAll($util.defaultIfNull($args.input, {}))) +## set the typename ** +$util.qr($mergedValues.put("__typename", "Dashboard")) +#set( $PutObject = { + "version": "2018-05-29", + "operation": "PutItem", + "attributeValues": $util.dynamodb.toMapValues($mergedValues), + "condition": $condition +} ) +#if( $args.condition ) + $util.qr($ctx.stash.conditions.add($args.condition)) +#end +## Begin - key condition ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyConditionExpr = {} ) + #set( $keyConditionExprNames = {} ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyConditionExpr.put("keyCondition$velocityCount", { + "attributeExists": false +})) + $util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key")) + #end + $util.qr($ctx.stash.conditions.add($keyConditionExpr)) +#else + $util.qr($ctx.stash.conditions.add({ + "id": { + "attributeExists": false + } +})) +#end +## End - key condition ** +## Start condition block ** +#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 ) + #set( $mergedConditions = { + "and": $ctx.stash.conditions +} ) + #set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) ) + #if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 ) + #set( $Conditions = { + "expression": $Conditions.expression, + "expressionNames": $Conditions.expressionNames +} ) + #end + ## End condition block ** +#end +#if( $Conditions ) + #if( $keyConditionExprNames ) + $util.qr($Conditions.expressionNames.putAll($keyConditionExprNames)) + #end + $util.qr($PutObject.put("condition", $Conditions)) +#end +#if( $ctx.stash.metadata.modelObjectKey ) + $util.qr($PutObject.put("key", $ctx.stash.metadata.modelObjectKey)) +#else + #set( $Key = { + "id": $util.dynamodb.toDynamoDB($mergedValues.id) +} ) + $util.qr($PutObject.put("key", $Key)) +#end +$util.toJson($PutObject) +## [End] Create Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.res.vtl new file mode 100644 index 0000000..5119972 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createDashboard.res.vtl @@ -0,0 +1,8 @@ +## [Start] ResponseTemplate. ** +$util.qr($ctx.result.put("__operation", "Mutation")) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createGauge.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.auth.1.req.vtl new file mode 100644 index 0000000..f166a55 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.auth.1.req.vtl @@ -0,0 +1,19 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $inputFields = $util.parseJson($util.toJson($ctx.args.input.keySet())) ) +#set( $isAuthorized = false ) +#set( $allowedFields = [] ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $allowedFields.isEmpty() ) +$util.unauthorized() +#end +#if( !$isAuthorized ) + #set( $deniedFields = $util.list.copyAndRemoveAll($inputFields, $allowedFields) ) + #if( $deniedFields.size() > 0 ) + $util.error("Unauthorized on ${deniedFields}", "Unauthorized") + #end +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createGauge.init.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.init.1.req.vtl new file mode 100644 index 0000000..44dbbd2 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.init.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Initialization default values. ** +$util.qr($ctx.stash.put("defaultValues", $util.defaultIfNull($ctx.stash.defaultValues, {}))) +#set( $createdAt = $util.time.nowISO8601() ) +$util.qr($ctx.stash.defaultValues.put("id", $util.autoId())) +$util.qr($ctx.stash.defaultValues.put("createdAt", $createdAt)) +$util.qr($ctx.stash.defaultValues.put("updatedAt", $createdAt)) +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Initialization default values. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createGauge.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createGauge.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.req.vtl new file mode 100644 index 0000000..52f66d8 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.req.vtl @@ -0,0 +1,74 @@ +## [Start] Create Request template. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +## Set the default values to put request ** +#set( $mergedValues = $util.defaultIfNull($ctx.stash.defaultValues, {}) ) +## copy the values from input ** +$util.qr($mergedValues.putAll($util.defaultIfNull($args.input, {}))) +## set the typename ** +$util.qr($mergedValues.put("__typename", "Gauge")) +#set( $nullIndexFields = [] ) +#set( $indexFields = ["channelId"] ) +#foreach( $entry in $util.map.copyAndRetainAllKeys($mergedValues, $indexFields).entrySet() ) + #if( $util.isNull($entry.value) ) + $util.qr($nullIndexFields.add($entry.key)) + #end +#end +#set( $mergedValues = $util.map.copyAndRemoveAllKeys($mergedValues, $nullIndexFields) ) +#set( $PutObject = { + "version": "2018-05-29", + "operation": "PutItem", + "attributeValues": $util.dynamodb.toMapValues($mergedValues), + "condition": $condition +} ) +#if( $args.condition ) + $util.qr($ctx.stash.conditions.add($args.condition)) +#end +## Begin - key condition ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyConditionExpr = {} ) + #set( $keyConditionExprNames = {} ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyConditionExpr.put("keyCondition$velocityCount", { + "attributeExists": false +})) + $util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key")) + #end + $util.qr($ctx.stash.conditions.add($keyConditionExpr)) +#else + $util.qr($ctx.stash.conditions.add({ + "id": { + "attributeExists": false + } +})) +#end +## End - key condition ** +## Start condition block ** +#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 ) + #set( $mergedConditions = { + "and": $ctx.stash.conditions +} ) + #set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) ) + #if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 ) + #set( $Conditions = { + "expression": $Conditions.expression, + "expressionNames": $Conditions.expressionNames +} ) + #end + ## End condition block ** +#end +#if( $Conditions ) + #if( $keyConditionExprNames ) + $util.qr($Conditions.expressionNames.putAll($keyConditionExprNames)) + #end + $util.qr($PutObject.put("condition", $Conditions)) +#end +#if( $ctx.stash.metadata.modelObjectKey ) + $util.qr($PutObject.put("key", $ctx.stash.metadata.modelObjectKey)) +#else + #set( $Key = { + "id": $util.dynamodb.toDynamoDB($mergedValues.id) +} ) + $util.qr($PutObject.put("key", $Key)) +#end +$util.toJson($PutObject) +## [End] Create Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.createGauge.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.res.vtl new file mode 100644 index 0000000..5119972 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.createGauge.res.vtl @@ -0,0 +1,8 @@ +## [Start] ResponseTemplate. ** +$util.qr($ctx.result.put("__operation", "Mutation")) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.auth.1.req.vtl new file mode 100644 index 0000000..590632b --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.auth.1.req.vtl @@ -0,0 +1,15 @@ +## [Start] Get Request template. ** +#set( $GetRequest = { + "version": "2018-05-29", + "operation": "GetItem" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $key = { + "id": $util.dynamodb.toDynamoDB($ctx.args.input.id) +} ) +#end +$util.qr($GetRequest.put("key", $key)) +$util.toJson($GetRequest) +## [End] Get Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.auth.1.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.auth.1.res.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.auth.1.res.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.req.vtl new file mode 100644 index 0000000..ace459b --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.req.vtl @@ -0,0 +1,58 @@ +## [Start] Delete Request template. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +#set( $DeleteRequest = { + "version": "2018-05-29", + "operation": "DeleteItem" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $Key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $Key = { + "id": $util.dynamodb.toDynamoDB($args.input.id) +} ) +#end +$util.qr($DeleteRequest.put("key", $Key)) +## Begin - key condition ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyConditionExpr = {} ) + #set( $keyConditionExprNames = {} ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyConditionExpr.put("keyCondition$velocityCount", { + "attributeExists": true +})) + $util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key")) + #end + $util.qr($ctx.stash.conditions.add($keyConditionExpr)) +#else + $util.qr($ctx.stash.conditions.add({ + "id": { + "attributeExists": true + } +})) +#end +## End - key condition ** +#if( $args.condition ) + $util.qr($ctx.stash.conditions.add($args.condition)) +#end +## Start condition block ** +#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 ) + #set( $mergedConditions = { + "and": $ctx.stash.conditions +} ) + #set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) ) + #if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 ) + #set( $Conditions = { + "expression": $Conditions.expression, + "expressionNames": $Conditions.expressionNames +} ) + #end + ## End condition block ** +#end +#if( $Conditions ) + #if( $keyConditionExprNames ) + $util.qr($Conditions.expressionNames.putAll($keyConditionExprNames)) + #end + $util.qr($DeleteRequest.put("condition", $Conditions)) +#end +$util.toJson($DeleteRequest) +## [End] Delete Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.res.vtl new file mode 100644 index 0000000..5119972 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteDashboard.res.vtl @@ -0,0 +1,8 @@ +## [Start] ResponseTemplate. ** +$util.qr($ctx.result.put("__operation", "Mutation")) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.auth.1.req.vtl new file mode 100644 index 0000000..590632b --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.auth.1.req.vtl @@ -0,0 +1,15 @@ +## [Start] Get Request template. ** +#set( $GetRequest = { + "version": "2018-05-29", + "operation": "GetItem" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $key = { + "id": $util.dynamodb.toDynamoDB($ctx.args.input.id) +} ) +#end +$util.qr($GetRequest.put("key", $key)) +$util.toJson($GetRequest) +## [End] Get Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.auth.1.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.auth.1.res.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.auth.1.res.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.req.vtl new file mode 100644 index 0000000..ace459b --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.req.vtl @@ -0,0 +1,58 @@ +## [Start] Delete Request template. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +#set( $DeleteRequest = { + "version": "2018-05-29", + "operation": "DeleteItem" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $Key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $Key = { + "id": $util.dynamodb.toDynamoDB($args.input.id) +} ) +#end +$util.qr($DeleteRequest.put("key", $Key)) +## Begin - key condition ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyConditionExpr = {} ) + #set( $keyConditionExprNames = {} ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyConditionExpr.put("keyCondition$velocityCount", { + "attributeExists": true +})) + $util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key")) + #end + $util.qr($ctx.stash.conditions.add($keyConditionExpr)) +#else + $util.qr($ctx.stash.conditions.add({ + "id": { + "attributeExists": true + } +})) +#end +## End - key condition ** +#if( $args.condition ) + $util.qr($ctx.stash.conditions.add($args.condition)) +#end +## Start condition block ** +#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 ) + #set( $mergedConditions = { + "and": $ctx.stash.conditions +} ) + #set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) ) + #if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 ) + #set( $Conditions = { + "expression": $Conditions.expression, + "expressionNames": $Conditions.expressionNames +} ) + #end + ## End condition block ** +#end +#if( $Conditions ) + #if( $keyConditionExprNames ) + $util.qr($Conditions.expressionNames.putAll($keyConditionExprNames)) + #end + $util.qr($DeleteRequest.put("condition", $Conditions)) +#end +$util.toJson($DeleteRequest) +## [End] Delete Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.res.vtl new file mode 100644 index 0000000..5119972 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.deleteGauge.res.vtl @@ -0,0 +1,8 @@ +## [Start] ResponseTemplate. ** +$util.qr($ctx.result.put("__operation", "Mutation")) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.auth.1.req.vtl new file mode 100644 index 0000000..590632b --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.auth.1.req.vtl @@ -0,0 +1,15 @@ +## [Start] Get Request template. ** +#set( $GetRequest = { + "version": "2018-05-29", + "operation": "GetItem" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $key = { + "id": $util.dynamodb.toDynamoDB($ctx.args.input.id) +} ) +#end +$util.qr($GetRequest.put("key", $key)) +$util.toJson($GetRequest) +## [End] Get Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.auth.1.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.auth.1.res.vtl new file mode 100644 index 0000000..3e66c25 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.auth.1.res.vtl @@ -0,0 +1,31 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#end +#set( $inputFields = $util.parseJson($util.toJson($ctx.args.input.keySet())) ) +#set( $isAuthorized = false ) +#set( $allowedFields = [] ) +#set( $nullAllowedFields = [] ) +#set( $deniedFields = {} ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $allowedFields.isEmpty() && $nullAllowedFields.isEmpty() ) +$util.unauthorized() +#end +#if( !$isAuthorized ) + #foreach( $entry in $util.map.copyAndRetainAllKeys($ctx.args.input, $inputFields).entrySet() ) + #if( $util.isNull($entry.value) && !$nullAllowedFields.contains($entry.key) ) + $util.qr($deniedFields.put($entry.key, "")) + #end + #end + #foreach( $deniedField in $util.list.copyAndRemoveAll($inputFields, $allowedFields) ) + $util.qr($deniedFields.put($deniedField, "")) + #end +#end +#if( $deniedFields.keySet().size() > 0 ) + $util.error("Unauthorized on ${deniedFields.keySet()}", "Unauthorized") +#end +$util.toJson({}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.init.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.init.1.req.vtl new file mode 100644 index 0000000..ab5766f --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.init.1.req.vtl @@ -0,0 +1,9 @@ +## [Start] Initialization default values. ** +$util.qr($ctx.stash.put("defaultValues", $util.defaultIfNull($ctx.stash.defaultValues, {}))) +#set( $updatedAt = $util.time.nowISO8601() ) +$util.qr($ctx.stash.defaultValues.put("updatedAt", $updatedAt)) +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Initialization default values. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.req.vtl new file mode 100644 index 0000000..a1bd67d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.req.vtl @@ -0,0 +1,130 @@ +## [Start] Mutation Update resolver. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +## Set the default values to put request ** +#set( $mergedValues = $util.defaultIfNull($ctx.stash.defaultValues, {}) ) +## copy the values from input ** +$util.qr($mergedValues.putAll($util.defaultIfNull($args.input, {}))) +## set the typename ** +## Initialize the vars for creating ddb expression ** +#set( $expNames = {} ) +#set( $expValues = {} ) +#set( $expSet = {} ) +#set( $expAdd = {} ) +#set( $expRemove = [] ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $Key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $Key = { + "id": $util.dynamodb.toDynamoDB($args.input.id) +} ) +#end +## Model key ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyFields = [] ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyFields.add("$entry.key")) + #end +#else + #set( $keyFields = ["id"] ) +#end +#foreach( $entry in $util.map.copyAndRemoveAllKeys($mergedValues, $keyFields).entrySet() ) + #if( !$util.isNull($ctx.stash.metadata.dynamodbNameOverrideMap) && $ctx.stash.metadata.dynamodbNameOverrideMap.containsKey("$entry.key") ) + #set( $entryKeyAttributeName = $ctx.stash.metadata.dynamodbNameOverrideMap.get("$entry.key") ) + #else + #set( $entryKeyAttributeName = $entry.key ) + #end + #if( $util.isNull($entry.value) ) + #set( $discard = $expRemove.add("#$entryKeyAttributeName") ) + $util.qr($expNames.put("#$entryKeyAttributeName", "$entry.key")) + #else + $util.qr($expSet.put("#$entryKeyAttributeName", ":$entryKeyAttributeName")) + $util.qr($expNames.put("#$entryKeyAttributeName", "$entry.key")) + $util.qr($expValues.put(":$entryKeyAttributeName", $util.dynamodb.toDynamoDB($entry.value))) + #end +#end +#set( $expression = "" ) +#if( !$expSet.isEmpty() ) + #set( $expression = "SET" ) + #foreach( $entry in $expSet.entrySet() ) + #set( $expression = "$expression $entry.key = $entry.value" ) + #if( $foreach.hasNext() ) + #set( $expression = "$expression," ) + #end + #end +#end +#if( !$expAdd.isEmpty() ) + #set( $expression = "$expression ADD" ) + #foreach( $entry in $expAdd.entrySet() ) + #set( $expression = "$expression $entry.key $entry.value" ) + #if( $foreach.hasNext() ) + #set( $expression = "$expression," ) + #end + #end +#end +#if( !$expRemove.isEmpty() ) + #set( $expression = "$expression REMOVE" ) + #foreach( $entry in $expRemove ) + #set( $expression = "$expression $entry" ) + #if( $foreach.hasNext() ) + #set( $expression = "$expression," ) + #end + #end +#end +#set( $update = {} ) +$util.qr($update.put("expression", "$expression")) +#if( !$expNames.isEmpty() ) + $util.qr($update.put("expressionNames", $expNames)) +#end +#if( !$expValues.isEmpty() ) + $util.qr($update.put("expressionValues", $expValues)) +#end +## Begin - key condition ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyConditionExpr = {} ) + #set( $keyConditionExprNames = {} ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyConditionExpr.put("keyCondition$velocityCount", { + "attributeExists": true +})) + $util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key")) + #end + $util.qr($ctx.stash.conditions.add($keyConditionExpr)) +#else + $util.qr($ctx.stash.conditions.add({ + "id": { + "attributeExists": true + } +})) +#end +## End - key condition ** +#if( $args.condition ) + $util.qr($ctx.stash.conditions.add($args.condition)) +#end +## Start condition block ** +#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 ) + #set( $mergedConditions = { + "and": $ctx.stash.conditions +} ) + #set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) ) + #if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 ) + #set( $Conditions = { + "expression": $Conditions.expression, + "expressionNames": $Conditions.expressionNames +} ) + #end + ## End condition block ** +#end +#set( $UpdateItem = { + "version": "2018-05-29", + "operation": "UpdateItem", + "key": $Key, + "update": $update +} ) +#if( $Conditions ) + #if( $keyConditionExprNames ) + $util.qr($Conditions.expressionNames.putAll($keyConditionExprNames)) + #end + $util.qr($UpdateItem.put("condition", $Conditions)) +#end +$util.toJson($UpdateItem) +## [End] Mutation Update resolver. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.res.vtl new file mode 100644 index 0000000..5119972 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateDashboard.res.vtl @@ -0,0 +1,8 @@ +## [Start] ResponseTemplate. ** +$util.qr($ctx.result.put("__operation", "Mutation")) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.auth.1.req.vtl new file mode 100644 index 0000000..590632b --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.auth.1.req.vtl @@ -0,0 +1,15 @@ +## [Start] Get Request template. ** +#set( $GetRequest = { + "version": "2018-05-29", + "operation": "GetItem" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $key = { + "id": $util.dynamodb.toDynamoDB($ctx.args.input.id) +} ) +#end +$util.qr($GetRequest.put("key", $key)) +$util.toJson($GetRequest) +## [End] Get Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.auth.1.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.auth.1.res.vtl new file mode 100644 index 0000000..3e66c25 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.auth.1.res.vtl @@ -0,0 +1,31 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#end +#set( $inputFields = $util.parseJson($util.toJson($ctx.args.input.keySet())) ) +#set( $isAuthorized = false ) +#set( $allowedFields = [] ) +#set( $nullAllowedFields = [] ) +#set( $deniedFields = {} ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $allowedFields.isEmpty() && $nullAllowedFields.isEmpty() ) +$util.unauthorized() +#end +#if( !$isAuthorized ) + #foreach( $entry in $util.map.copyAndRetainAllKeys($ctx.args.input, $inputFields).entrySet() ) + #if( $util.isNull($entry.value) && !$nullAllowedFields.contains($entry.key) ) + $util.qr($deniedFields.put($entry.key, "")) + #end + #end + #foreach( $deniedField in $util.list.copyAndRemoveAll($inputFields, $allowedFields) ) + $util.qr($deniedFields.put($deniedField, "")) + #end +#end +#if( $deniedFields.keySet().size() > 0 ) + $util.error("Unauthorized on ${deniedFields.keySet()}", "Unauthorized") +#end +$util.toJson({}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.init.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.init.1.req.vtl new file mode 100644 index 0000000..ab5766f --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.init.1.req.vtl @@ -0,0 +1,9 @@ +## [Start] Initialization default values. ** +$util.qr($ctx.stash.put("defaultValues", $util.defaultIfNull($ctx.stash.defaultValues, {}))) +#set( $updatedAt = $util.time.nowISO8601() ) +$util.qr($ctx.stash.defaultValues.put("updatedAt", $updatedAt)) +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Initialization default values. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.req.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.req.vtl new file mode 100644 index 0000000..a1bd67d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.req.vtl @@ -0,0 +1,130 @@ +## [Start] Mutation Update resolver. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +## Set the default values to put request ** +#set( $mergedValues = $util.defaultIfNull($ctx.stash.defaultValues, {}) ) +## copy the values from input ** +$util.qr($mergedValues.putAll($util.defaultIfNull($args.input, {}))) +## set the typename ** +## Initialize the vars for creating ddb expression ** +#set( $expNames = {} ) +#set( $expValues = {} ) +#set( $expSet = {} ) +#set( $expAdd = {} ) +#set( $expRemove = [] ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $Key = $ctx.stash.metadata.modelObjectKey ) +#else + #set( $Key = { + "id": $util.dynamodb.toDynamoDB($args.input.id) +} ) +#end +## Model key ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyFields = [] ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyFields.add("$entry.key")) + #end +#else + #set( $keyFields = ["id"] ) +#end +#foreach( $entry in $util.map.copyAndRemoveAllKeys($mergedValues, $keyFields).entrySet() ) + #if( !$util.isNull($ctx.stash.metadata.dynamodbNameOverrideMap) && $ctx.stash.metadata.dynamodbNameOverrideMap.containsKey("$entry.key") ) + #set( $entryKeyAttributeName = $ctx.stash.metadata.dynamodbNameOverrideMap.get("$entry.key") ) + #else + #set( $entryKeyAttributeName = $entry.key ) + #end + #if( $util.isNull($entry.value) ) + #set( $discard = $expRemove.add("#$entryKeyAttributeName") ) + $util.qr($expNames.put("#$entryKeyAttributeName", "$entry.key")) + #else + $util.qr($expSet.put("#$entryKeyAttributeName", ":$entryKeyAttributeName")) + $util.qr($expNames.put("#$entryKeyAttributeName", "$entry.key")) + $util.qr($expValues.put(":$entryKeyAttributeName", $util.dynamodb.toDynamoDB($entry.value))) + #end +#end +#set( $expression = "" ) +#if( !$expSet.isEmpty() ) + #set( $expression = "SET" ) + #foreach( $entry in $expSet.entrySet() ) + #set( $expression = "$expression $entry.key = $entry.value" ) + #if( $foreach.hasNext() ) + #set( $expression = "$expression," ) + #end + #end +#end +#if( !$expAdd.isEmpty() ) + #set( $expression = "$expression ADD" ) + #foreach( $entry in $expAdd.entrySet() ) + #set( $expression = "$expression $entry.key $entry.value" ) + #if( $foreach.hasNext() ) + #set( $expression = "$expression," ) + #end + #end +#end +#if( !$expRemove.isEmpty() ) + #set( $expression = "$expression REMOVE" ) + #foreach( $entry in $expRemove ) + #set( $expression = "$expression $entry" ) + #if( $foreach.hasNext() ) + #set( $expression = "$expression," ) + #end + #end +#end +#set( $update = {} ) +$util.qr($update.put("expression", "$expression")) +#if( !$expNames.isEmpty() ) + $util.qr($update.put("expressionNames", $expNames)) +#end +#if( !$expValues.isEmpty() ) + $util.qr($update.put("expressionValues", $expValues)) +#end +## Begin - key condition ** +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $keyConditionExpr = {} ) + #set( $keyConditionExprNames = {} ) + #foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() ) + $util.qr($keyConditionExpr.put("keyCondition$velocityCount", { + "attributeExists": true +})) + $util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key")) + #end + $util.qr($ctx.stash.conditions.add($keyConditionExpr)) +#else + $util.qr($ctx.stash.conditions.add({ + "id": { + "attributeExists": true + } +})) +#end +## End - key condition ** +#if( $args.condition ) + $util.qr($ctx.stash.conditions.add($args.condition)) +#end +## Start condition block ** +#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 ) + #set( $mergedConditions = { + "and": $ctx.stash.conditions +} ) + #set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) ) + #if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 ) + #set( $Conditions = { + "expression": $Conditions.expression, + "expressionNames": $Conditions.expressionNames +} ) + #end + ## End condition block ** +#end +#set( $UpdateItem = { + "version": "2018-05-29", + "operation": "UpdateItem", + "key": $Key, + "update": $update +} ) +#if( $Conditions ) + #if( $keyConditionExprNames ) + $util.qr($Conditions.expressionNames.putAll($keyConditionExprNames)) + #end + $util.qr($UpdateItem.put("condition", $Conditions)) +#end +$util.toJson($UpdateItem) +## [End] Mutation Update resolver. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.res.vtl b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.res.vtl new file mode 100644 index 0000000..5119972 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Mutation.updateGauge.res.vtl @@ -0,0 +1,8 @@ +## [Start] ResponseTemplate. ** +$util.qr($ctx.result.put("__operation", "Mutation")) +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getDashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.getDashboard.auth.1.req.vtl new file mode 100644 index 0000000..6662446 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getDashboard.auth.1.req.vtl @@ -0,0 +1,12 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#set( $primaryFieldMap = {} ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getDashboard.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.getDashboard.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getDashboard.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getDashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Query.getDashboard.req.vtl new file mode 100644 index 0000000..a8d7811 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getDashboard.req.vtl @@ -0,0 +1,34 @@ +## [Start] Get Request template. ** +#set( $GetRequest = { + "version": "2018-05-29", + "operation": "Query" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $expression = "" ) + #set( $expressionNames = {} ) + #set( $expressionValues = {} ) + #foreach( $item in $ctx.stash.metadata.modelObjectKey.entrySet() ) + #set( $expression = "$expression#keyCount$velocityCount = :valueCount$velocityCount AND " ) + $util.qr($expressionNames.put("#keyCount$velocityCount", $item.key)) + $util.qr($expressionValues.put(":valueCount$velocityCount", $item.value)) + #end + #set( $expression = $expression.replaceAll("AND $", "") ) + #set( $query = { + "expression": $expression, + "expressionNames": $expressionNames, + "expressionValues": $expressionValues +} ) +#else + #set( $query = { + "expression": "id = :id", + "expressionValues": { + ":id": $util.parseJson($util.dynamodb.toDynamoDBJson($ctx.args.id)) + } +} ) +#end +$util.qr($GetRequest.put("query", $query)) +#if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + $util.qr($GetRequest.put("filter", $util.parseJson($util.transform.toDynamoDBFilterExpression($ctx.stash.authFilter)))) +#end +$util.toJson($GetRequest) +## [End] Get Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getDashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Query.getDashboard.res.vtl new file mode 100644 index 0000000..e9ef143 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getDashboard.res.vtl @@ -0,0 +1,13 @@ +## [Start] Get Response template. ** +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#end +#if( !$ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) + $util.toJson($ctx.result.items[0]) +#else + #if( $ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) +$util.unauthorized() + #end + $util.toJson(null) +#end +## [End] Get Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getGauge.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.getGauge.auth.1.req.vtl new file mode 100644 index 0000000..6662446 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getGauge.auth.1.req.vtl @@ -0,0 +1,12 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#set( $primaryFieldMap = {} ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getGauge.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.getGauge.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getGauge.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getGauge.req.vtl b/amplify/backend/api/mrms/resolvers/Query.getGauge.req.vtl new file mode 100644 index 0000000..a8d7811 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getGauge.req.vtl @@ -0,0 +1,34 @@ +## [Start] Get Request template. ** +#set( $GetRequest = { + "version": "2018-05-29", + "operation": "Query" +} ) +#if( $ctx.stash.metadata.modelObjectKey ) + #set( $expression = "" ) + #set( $expressionNames = {} ) + #set( $expressionValues = {} ) + #foreach( $item in $ctx.stash.metadata.modelObjectKey.entrySet() ) + #set( $expression = "$expression#keyCount$velocityCount = :valueCount$velocityCount AND " ) + $util.qr($expressionNames.put("#keyCount$velocityCount", $item.key)) + $util.qr($expressionValues.put(":valueCount$velocityCount", $item.value)) + #end + #set( $expression = $expression.replaceAll("AND $", "") ) + #set( $query = { + "expression": $expression, + "expressionNames": $expressionNames, + "expressionValues": $expressionValues +} ) +#else + #set( $query = { + "expression": "id = :id", + "expressionValues": { + ":id": $util.parseJson($util.dynamodb.toDynamoDBJson($ctx.args.id)) + } +} ) +#end +$util.qr($GetRequest.put("query", $query)) +#if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + $util.qr($GetRequest.put("filter", $util.parseJson($util.transform.toDynamoDBFilterExpression($ctx.stash.authFilter)))) +#end +$util.toJson($GetRequest) +## [End] Get Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.getGauge.res.vtl b/amplify/backend/api/mrms/resolvers/Query.getGauge.res.vtl new file mode 100644 index 0000000..e9ef143 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.getGauge.res.vtl @@ -0,0 +1,13 @@ +## [Start] Get Response template. ** +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#end +#if( !$ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) + $util.toJson($ctx.result.items[0]) +#else + #if( $ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) +$util.unauthorized() + #end + $util.toJson(null) +#end +## [End] Get Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listDashboards.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.listDashboards.auth.1.req.vtl new file mode 100644 index 0000000..6662446 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listDashboards.auth.1.req.vtl @@ -0,0 +1,12 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#set( $primaryFieldMap = {} ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listDashboards.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.listDashboards.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listDashboards.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listDashboards.req.vtl b/amplify/backend/api/mrms/resolvers/Query.listDashboards.req.vtl new file mode 100644 index 0000000..0142137 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listDashboards.req.vtl @@ -0,0 +1,50 @@ +## [Start] List Request. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +#set( $limit = $util.defaultIfNull($args.limit, 100) ) +#set( $ListRequest = { + "version": "2018-05-29", + "limit": $limit +} ) +#if( $args.nextToken ) + #set( $ListRequest.nextToken = $args.nextToken ) +#end +#if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + #set( $filter = $ctx.stash.authFilter ) + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = { + "and": [$filter, $args.filter] +} ) + #end +#else + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = $args.filter ) + #end +#end +#if( !$util.isNullOrEmpty($filter) ) + #set( $filterExpression = $util.parseJson($util.transform.toDynamoDBFilterExpression($filter)) ) + #if( $util.isNullOrEmpty($filterExpression) ) + $util.error("Unable to process the filter expression", "Unrecognized Filter") + #end + #if( !$util.isNullOrBlank($filterExpression.expression) ) + #if( $filterExpression.expressionValues.size() == 0 ) + $util.qr($filterExpression.remove("expressionValues")) + #end + #set( $ListRequest.filter = $filterExpression ) + #end +#end +#if( !$util.isNull($ctx.stash.modelQueryExpression) && !$util.isNullOrEmpty($ctx.stash.modelQueryExpression.expression) ) + $util.qr($ListRequest.put("operation", "Query")) + $util.qr($ListRequest.put("query", $ctx.stash.modelQueryExpression)) + #if( !$util.isNull($args.sortDirection) && $args.sortDirection == "DESC" ) + #set( $ListRequest.scanIndexForward = false ) + #else + #set( $ListRequest.scanIndexForward = true ) + #end +#else + $util.qr($ListRequest.put("operation", "Scan")) +#end +#if( !$util.isNull($ctx.stash.metadata.index) ) + #set( $ListRequest.IndexName = $ctx.stash.metadata.index ) +#end +$util.toJson($ListRequest) +## [End] List Request. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listDashboards.res.vtl b/amplify/backend/api/mrms/resolvers/Query.listDashboards.res.vtl new file mode 100644 index 0000000..ee8b667 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listDashboards.res.vtl @@ -0,0 +1,7 @@ +## [Start] ResponseTemplate. ** +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listGauges.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.listGauges.auth.1.req.vtl new file mode 100644 index 0000000..6662446 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listGauges.auth.1.req.vtl @@ -0,0 +1,12 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#set( $primaryFieldMap = {} ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listGauges.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Query.listGauges.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listGauges.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listGauges.req.vtl b/amplify/backend/api/mrms/resolvers/Query.listGauges.req.vtl new file mode 100644 index 0000000..0142137 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listGauges.req.vtl @@ -0,0 +1,50 @@ +## [Start] List Request. ** +#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) ) +#set( $limit = $util.defaultIfNull($args.limit, 100) ) +#set( $ListRequest = { + "version": "2018-05-29", + "limit": $limit +} ) +#if( $args.nextToken ) + #set( $ListRequest.nextToken = $args.nextToken ) +#end +#if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + #set( $filter = $ctx.stash.authFilter ) + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = { + "and": [$filter, $args.filter] +} ) + #end +#else + #if( !$util.isNullOrEmpty($args.filter) ) + #set( $filter = $args.filter ) + #end +#end +#if( !$util.isNullOrEmpty($filter) ) + #set( $filterExpression = $util.parseJson($util.transform.toDynamoDBFilterExpression($filter)) ) + #if( $util.isNullOrEmpty($filterExpression) ) + $util.error("Unable to process the filter expression", "Unrecognized Filter") + #end + #if( !$util.isNullOrBlank($filterExpression.expression) ) + #if( $filterExpression.expressionValues.size() == 0 ) + $util.qr($filterExpression.remove("expressionValues")) + #end + #set( $ListRequest.filter = $filterExpression ) + #end +#end +#if( !$util.isNull($ctx.stash.modelQueryExpression) && !$util.isNullOrEmpty($ctx.stash.modelQueryExpression.expression) ) + $util.qr($ListRequest.put("operation", "Query")) + $util.qr($ListRequest.put("query", $ctx.stash.modelQueryExpression)) + #if( !$util.isNull($args.sortDirection) && $args.sortDirection == "DESC" ) + #set( $ListRequest.scanIndexForward = false ) + #else + #set( $ListRequest.scanIndexForward = true ) + #end +#else + $util.qr($ListRequest.put("operation", "Scan")) +#end +#if( !$util.isNull($ctx.stash.metadata.index) ) + #set( $ListRequest.IndexName = $ctx.stash.metadata.index ) +#end +$util.toJson($ListRequest) +## [End] List Request. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Query.listGauges.res.vtl b/amplify/backend/api/mrms/resolvers/Query.listGauges.res.vtl new file mode 100644 index 0000000..ee8b667 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Query.listGauges.res.vtl @@ -0,0 +1,7 @@ +## [Start] ResponseTemplate. ** +#if( $ctx.error ) + $util.error($ctx.error.message, $ctx.error.type) +#else + $util.toJson($ctx.result) +#end +## [End] ResponseTemplate. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Report.dashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Report.dashboard.auth.1.req.vtl new file mode 100644 index 0000000..8856d63 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Report.dashboard.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Report.dashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Report.dashboard.req.vtl new file mode 100644 index 0000000..1becec2 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Report.dashboard.req.vtl @@ -0,0 +1,24 @@ +#if( $ctx.source.deniedField ) + #return($util.toJson(null)) +#end +#if( $util.isNull($ctx.source.dashboardId) ) + #return +#else + #set( $GetRequest = { + "version": "2018-05-29", + "operation": "Query" +} ) + $util.qr($GetRequest.put("query", { + "expression": "#partitionKey = :partitionValue", + "expressionNames": { + "#partitionKey": "id" + }, + "expressionValues": { + ":partitionValue": $util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.dashboardId, "___xamznone____"))) + } +})) + #if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) + $util.qr($GetRequest.put("filter", $util.parseJson($util.transform.toDynamoDBFilterExpression($ctx.stash.authFilter)))) + #end + $util.toJson($GetRequest) +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Report.dashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Report.dashboard.res.vtl new file mode 100644 index 0000000..5c6d459 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Report.dashboard.res.vtl @@ -0,0 +1,12 @@ +#if( $ctx.error ) +$util.error($ctx.error.message, $ctx.error.type) +#else + #if( !$ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) + $util.toJson($ctx.result.items[0]) + #else + #if( $ctx.result.items.isEmpty() && $ctx.result.scannedCount == 1 ) +$util.unauthorized() + #end + $util.toJson(null) + #end +#end \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.auth.1.req.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.req.vtl new file mode 100644 index 0000000..f64092d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.req.vtl @@ -0,0 +1,6 @@ +## [Start] Subscription Request template. ** +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Subscription Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.res.vtl new file mode 100644 index 0000000..e1548cd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateDashboard.res.vtl @@ -0,0 +1,3 @@ +## [Start] Subscription Response template. ** +$util.toJson(null) +## [End] Subscription Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.auth.1.req.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.req.vtl new file mode 100644 index 0000000..f64092d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.req.vtl @@ -0,0 +1,6 @@ +## [Start] Subscription Request template. ** +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Subscription Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.res.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.res.vtl new file mode 100644 index 0000000..e1548cd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onCreateGauge.res.vtl @@ -0,0 +1,3 @@ +## [Start] Subscription Response template. ** +$util.toJson(null) +## [End] Subscription Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.auth.1.req.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.req.vtl new file mode 100644 index 0000000..f64092d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.req.vtl @@ -0,0 +1,6 @@ +## [Start] Subscription Request template. ** +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Subscription Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.res.vtl new file mode 100644 index 0000000..e1548cd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteDashboard.res.vtl @@ -0,0 +1,3 @@ +## [Start] Subscription Response template. ** +$util.toJson(null) +## [End] Subscription Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.auth.1.req.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.req.vtl new file mode 100644 index 0000000..f64092d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.req.vtl @@ -0,0 +1,6 @@ +## [Start] Subscription Request template. ** +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Subscription Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.res.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.res.vtl new file mode 100644 index 0000000..e1548cd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onDeleteGauge.res.vtl @@ -0,0 +1,3 @@ +## [Start] Subscription Response template. ** +$util.toJson(null) +## [End] Subscription Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.auth.1.req.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.req.vtl new file mode 100644 index 0000000..f64092d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.req.vtl @@ -0,0 +1,6 @@ +## [Start] Subscription Request template. ** +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Subscription Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.res.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.res.vtl new file mode 100644 index 0000000..e1548cd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateDashboard.res.vtl @@ -0,0 +1,3 @@ +## [Start] Subscription Response template. ** +$util.toJson(null) +## [End] Subscription Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.auth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.auth.1.req.vtl new file mode 100644 index 0000000..5ebf1d5 --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.auth.1.req.vtl @@ -0,0 +1,11 @@ +## [Start] Authorization Steps. ** +$util.qr($ctx.stash.put("hasAuth", true)) +#set( $isAuthorized = false ) +#if( $util.authType() == "API Key Authorization" ) + #set( $isAuthorized = true ) +#end +#if( !$isAuthorized ) +$util.unauthorized() +#end +$util.toJson({"version":"2018-05-29","payload":{}}) +## [End] Authorization Steps. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.postAuth.1.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.postAuth.1.req.vtl new file mode 100644 index 0000000..0e07eff --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.postAuth.1.req.vtl @@ -0,0 +1,6 @@ +## [Start] Sandbox Mode Disabled. ** +#if( !$ctx.stash.get("hasAuth") ) + $util.unauthorized() +#end +$util.toJson({}) +## [End] Sandbox Mode Disabled. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.req.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.req.vtl new file mode 100644 index 0000000..f64092d --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.req.vtl @@ -0,0 +1,6 @@ +## [Start] Subscription Request template. ** +$util.toJson({ + "version": "2018-05-29", + "payload": {} +}) +## [End] Subscription Request template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.res.vtl b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.res.vtl new file mode 100644 index 0000000..e1548cd --- /dev/null +++ b/amplify/backend/api/mrms/resolvers/Subscription.onUpdateGauge.res.vtl @@ -0,0 +1,3 @@ +## [Start] Subscription Response template. ** +$util.toJson(null) +## [End] Subscription Response template. ** \ No newline at end of file diff --git a/amplify/backend/api/mrms/schema.graphql b/amplify/backend/api/mrms/schema.graphql index fc32527..6cddf62 100644 --- a/amplify/backend/api/mrms/schema.graphql +++ b/amplify/backend/api/mrms/schema.graphql @@ -4,11 +4,10 @@ type Report @model @auth(rules: [{ allow: public }]) { id: ID! title: String! - channel: Channel @belongsTo(fields: ["channelId"]) reportGroup: ReportGroup @belongsTo(fields: ["reportGroupId"]) description: String, reportGroupId: ID @index(name: "byReportGroup") - channelId: ID @index(name: "byChannel") + channelId: ID @index(name: "byChannel") colorSchemeId: Int chartType: String dataSet: DataSet @hasOne @@ -24,16 +23,55 @@ type ReportGroup @model @auth(rules: [{ allow: public }]) { title: String! reports:[Report] @hasMany(indexName: "byReportGroup", fields: ["id"]) reportIds: [String] + channelId: ID @index(name: "byChannel") createdBy: String - updatedBy: String - channelId: ID @index(name: "byChannel") + updatedBy: String +} + +type Gauge @model @auth(rules: [{ allow: public }]) { + id: ID! + title: String! + notes: String + value: Float! + segmentStops: String + chartType: String! + channelId: ID @index(name: "byChannel") + createdBy: String + updatedBy: String +} + +type HeatMap @model @auth(rules: [{ allow: public }]) { + id: ID! + title: String! + dataSet: DataSet @hasOne(fields: ["dataSetId"]) + dataSetId: ID + options: AWSJSON + leadCol: String + columns: String + channelId: ID @index(name: "byChannel") + createdBy: String + updatedBy: String +} + +type Dashboard @model @auth(rules: [{ allow: public }]) { + id: ID! + title: String! + description: String + cards: AWSJSON + channelId: ID @index(name: "byChannel") + createdBy: String + updatedBy: String } type Channel @model @auth(rules: [{ allow: public }]) { id: ID! - description: String, + description: String reports: [Report] @hasMany(indexName: "byChannel", fields: ["id"]) + reportGroups: [ReportGroup] @hasMany(indexName: "byChannel", fields: ["id"]) dataSets: [DataSet] @hasMany(indexName: "byChannel", fields: ["id"]) + gauges: [Gauge] @hasMany(indexName: "byChannel", fields: ["id"]) + heatMaps: [HeatMap] @hasMany(indexName: "byChannel", fields: ["id"]) + dashboards: [Dashboard] @hasMany(indexName: "byChannel", fields: ["id"]) # type: ChannelType @belongsTo(fields: ["channelTypeId"]) type: String title: String! @@ -44,10 +82,8 @@ type DataSet @model @auth(rules: [{ allow: public }]) { id: ID! title: String! description: String - channel: Channel @belongsTo(fields: ["channelId"]) channelId: ID @index(name: "byChannel") dataValues: [DataValue] @hasMany (indexName: "byDataSet", fields: ["id"]) - user: String } type DataValue @model @auth(rules: [{ allow: public }]) { diff --git a/amplify/backend/backend-config.json b/amplify/backend/backend-config.json index 5fee80a..f34f0a6 100644 --- a/amplify/backend/backend-config.json +++ b/amplify/backend/backend-config.json @@ -1,71 +1,89 @@ { "api": { "mrms": { - "service": "AppSync", - "providerPlugin": "awscloudformation", "dependsOn": [], "output": { "authConfig": { + "additionalAuthenticationProviders": [], "defaultAuthentication": { - "authenticationType": "API_KEY", "apiKeyConfig": { - "apiKeyExpirationDays": 365, "apiKeyExpirationDate": "2023-12-01T14:02:48.304Z", + "apiKeyExpirationDays": 365, "description": "mrmsapikey" - } - }, - "additionalAuthenticationProviders": [] + }, + "authenticationType": "API_KEY" + } } - } - } - }, - "hosting": { - "amplifyhosting": { - "service": "amplifyhosting", + }, "providerPlugin": "awscloudformation", - "type": "manual" + "service": "AppSync" } }, "auth": { "mrmsd8d7189c": { - "service": "Cognito", - "providerPlugin": "awscloudformation", - "dependsOn": [], "customAuth": false, + "dependsOn": [], "frontendAuthConfig": { - "socialProviders": [], - "usernameAttributes": [ - "EMAIL" + "mfaConfiguration": "OFF", + "mfaTypes": [ + "SMS" ], + "passwordProtectionSettings": { + "passwordPolicyCharacters": [], + "passwordPolicyMinLength": 8 + }, "signupAttributes": [ "EMAIL" ], - "passwordProtectionSettings": { - "passwordPolicyMinLength": 8, - "passwordPolicyCharacters": [] - }, - "mfaConfiguration": "OFF", - "mfaTypes": [ - "SMS" + "socialProviders": [], + "usernameAttributes": [ + "EMAIL" ], "verificationMechanisms": [ "EMAIL" ] - } + }, + "providerPlugin": "awscloudformation", + "service": "Cognito" }, "userPoolGroups": { - "service": "Cognito-UserPool-Groups", - "providerPlugin": "awscloudformation", "dependsOn": [ { - "category": "auth", - "resourceName": "mrmsd8d7189c", "attributes": [ "UserPoolId", "AppClientIDWeb", "AppClientID", "IdentityPoolId" - ] + ], + "category": "auth", + "resourceName": "mrmsd8d7189c" + } + ], + "providerPlugin": "awscloudformation", + "service": "Cognito-UserPool-Groups" + } + }, + "hosting": { + "amplifyhosting": { + "providerPlugin": "awscloudformation", + "service": "amplifyhosting", + "type": "manual" + } + }, + "parameters": { + "AMPLIFY_hosting_amplifyhosting_appId": { + "usedBy": [ + { + "category": "hosting", + "resourceName": "amplifyhosting" + } + ] + }, + "AMPLIFY_hosting_amplifyhosting_type": { + "usedBy": [ + { + "category": "hosting", + "resourceName": "amplifyhosting" } ] } diff --git a/amplify/backend/types/amplify-dependent-resources-ref.d.ts b/amplify/backend/types/amplify-dependent-resources-ref.d.ts index 9e39bcc..ab85f93 100644 --- a/amplify/backend/types/amplify-dependent-resources-ref.d.ts +++ b/amplify/backend/types/amplify-dependent-resources-ref.d.ts @@ -1,23 +1,23 @@ export type AmplifyDependentResourcesAttributes = { - "api": { - "mrms": { - "GraphQLAPIKeyOutput": "string", - "GraphQLAPIIdOutput": "string", - "GraphQLAPIEndpointOutput": "string" - } + "api": { + "mrms": { + "GraphQLAPIEndpointOutput": "string", + "GraphQLAPIIdOutput": "string", + "GraphQLAPIKeyOutput": "string" + } + }, + "auth": { + "mrmsd8d7189c": { + "AppClientID": "string", + "AppClientIDWeb": "string", + "IdentityPoolId": "string", + "IdentityPoolName": "string", + "UserPoolArn": "string", + "UserPoolId": "string", + "UserPoolName": "string" }, - "auth": { - "mrmsd8d7189c": { - "IdentityPoolId": "string", - "IdentityPoolName": "string", - "UserPoolId": "string", - "UserPoolArn": "string", - "UserPoolName": "string", - "AppClientIDWeb": "string", - "AppClientID": "string" - }, - "userPoolGroups": { - "mrmsawsGroupRole": "string" - } + "userPoolGroups": { + "mrmsawsGroupRole": "string" } + } } \ No newline at end of file diff --git a/cypress.config.js b/cypress.config.js new file mode 100644 index 0000000..959dc47 --- /dev/null +++ b/cypress.config.js @@ -0,0 +1,14 @@ +const { defineConfig } = require("cypress"); + +module.exports = defineConfig({ + e2e: { + setupNodeEvents(on, config) { + // implement node event listeners here + }, + "baseUrl": "http://localhost:8080/", + experimentalStudio: true, + viewportWidth: 1500, + viewportHeight: 900, + defaultCommandTimeout: 100000, + }, +}); diff --git a/cypress.env.json b/cypress.env.json new file mode 100644 index 0000000..02e78b8 --- /dev/null +++ b/cypress.env.json @@ -0,0 +1,4 @@ +{ + "username": "cypress.testing@microhealthllc.com", + "password": "MHtests1234$$" +} \ No newline at end of file diff --git a/cypress/e2e/1-getting-started/todo.cy.js b/cypress/e2e/1-getting-started/todo.cy.js new file mode 100644 index 0000000..4768ff9 --- /dev/null +++ b/cypress/e2e/1-getting-started/todo.cy.js @@ -0,0 +1,143 @@ +/// + +// Welcome to Cypress! +// +// This spec file contains a variety of sample tests +// for a todo list app that are designed to demonstrate +// the power of writing tests in Cypress. +// +// To learn more about how Cypress works and +// what makes it such an awesome testing tool, +// please read our getting started guide: +// https://on.cypress.io/introduction-to-cypress + +describe('example to-do app', () => { + beforeEach(() => { + // Cypress starts out with a blank slate for each test + // so we must tell it to visit our website with the `cy.visit()` command. + // Since we want to visit the same URL at the start of all our tests, + // we include it in our beforeEach function so that it runs before each test + cy.visit('https://example.cypress.io/todo') + }) + + it('displays two todo items by default', () => { + // We use the `cy.get()` command to get all elements that match the selector. + // Then, we use `should` to assert that there are two matched items, + // which are the two default items. + cy.get('.todo-list li').should('have.length', 2) + + // We can go even further and check that the default todos each contain + // the correct text. We use the `first` and `last` functions + // to get just the first and last matched elements individually, + // and then perform an assertion with `should`. + cy.get('.todo-list li').first().should('have.text', 'Pay electric bill') + cy.get('.todo-list li').last().should('have.text', 'Walk the dog') + }) + + it('can add new todo items', () => { + // We'll store our item text in a variable so we can reuse it + const newItem = 'Feed the cat' + + // Let's get the input element and use the `type` command to + // input our new list item. After typing the content of our item, + // we need to type the enter key as well in order to submit the input. + // This input has a data-test attribute so we'll use that to select the + // element in accordance with best practices: + // https://on.cypress.io/selecting-elements + cy.get('[data-test=new-todo]').type(`${newItem}{enter}`) + + // Now that we've typed our new item, let's check that it actually was added to the list. + // Since it's the newest item, it should exist as the last element in the list. + // In addition, with the two default items, we should have a total of 3 elements in the list. + // Since assertions yield the element that was asserted on, + // we can chain both of these assertions together into a single statement. + cy.get('.todo-list li') + .should('have.length', 3) + .last() + .should('have.text', newItem) + }) + + it('can check off an item as completed', () => { + // In addition to using the `get` command to get an element by selector, + // we can also use the `contains` command to get an element by its contents. + // However, this will yield the