Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/graphql-searchable-transformer

Package Overview
Dependencies
Maintainers
6
Versions
440
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/graphql-searchable-transformer - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0-beta.0

18

CHANGELOG.md

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

# [0.3.0-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-searchable-transformer@0.2.3...@aws-amplify/graphql-searchable-transformer@0.3.0-beta.0) (2021-07-06)
### Bug Fixes
* get mock working with gql transformer v2 ([#7574](https://github.com/aws-amplify/amplify-cli/issues/7574)) ([4fa2900](https://github.com/aws-amplify/amplify-cli/commit/4fa2900d6b9ca515677d06bdffe29f56401b9c86))
### Features
* category graphql/searchable sort multiple fields ([#7553](https://github.com/aws-amplify/amplify-cli/issues/7553)) ([03973ee](https://github.com/aws-amplify/amplify-cli/commit/03973eedbb5e4d755609b56b7bebf937783d5a67))
* **cli:** upgrade elastic search version to 7.x ([#7556](https://github.com/aws-amplify/amplify-cli/issues/7556)) ([3b46e2a](https://github.com/aws-amplify/amplify-cli/commit/3b46e2a1313b3092109a2c356b9a73e23439f4f2))
* port [@predictions](https://github.com/predictions) to GraphQL Transformer v2 ([#7387](https://github.com/aws-amplify/amplify-cli/issues/7387)) ([3f2e647](https://github.com/aws-amplify/amplify-cli/commit/3f2e647b9dfe14aa5919b46f53342937dd0c7fa9))
## [0.2.3](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-searchable-transformer@0.2.2...@aws-amplify/graphql-searchable-transformer@0.2.3) (2021-06-30)

@@ -8,0 +26,0 @@

2

lib/cdk/create-es-domain.js

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

const domain = new aws_elasticsearch_1.Domain(stack, ElasticsearchDomainLogicalID, {
version: aws_elasticsearch_1.ElasticsearchVersion.V6_2,
version: { version: "7.10" },
ebs: {

@@ -18,0 +18,0 @@ enabled: true,

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

aws_lambda_1.LayerVersion.fromLayerVersionArn(stack, 'LambdaLayerVersion', core_1.Fn.findInMap('LayerResourceMapping', core_1.Fn.ref('AWS::Region'), 'layerRegion')),
], lambdaRole, enviroment, stack);
], lambdaRole, enviroment, undefined, stack);
};

@@ -47,0 +47,0 @@ exports.createLambda = createLambda;

@@ -10,11 +10,17 @@ "use strict";

graphql_mapping_template_1.set(graphql_mapping_template_1.ref('nonKeywordFields'), graphql_mapping_template_1.list(nonKeywordFields)),
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('util.isNullOrEmpty($context.args.sort)'), graphql_mapping_template_1.compoundExpression([graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortDirection'), graphql_mapping_template_1.str('desc')), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.str(primaryKey))]), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortDirection'), graphql_mapping_template_1.ref('util.defaultIfNull($context.args.sort.direction, "desc")')),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref(`util.defaultIfNull($context.args.sort.field, "${primaryKey}")`)),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortValues'), graphql_mapping_template_1.list([])),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('primaryKey'), graphql_mapping_template_1.str(primaryKey)),
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('util.isNullOrEmpty($context.args.sort)'), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('nonKeywordFields.contains($primaryKey)'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson($primaryKey)')), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson("${primaryKey}.keyword")'))),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortDirection'), graphql_mapping_template_1.ref('util.toJson({"order": "desc"})')),
graphql_mapping_template_1.qref('$sortValues.add("{$sortField: $sortDirection}")'),
]), graphql_mapping_template_1.forEach(graphql_mapping_template_1.ref('sortItem'), graphql_mapping_template_1.ref('context.args.sort'), [
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('util.isNullOrEmpty($sortItem.field)'), graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('nonKeywordFields.contains($primaryKey)'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson($primaryKey)')), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson("${primaryKey}.keyword")'))), graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('nonKeywordFields.contains($sortItem.field)'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson($sortItem.field)')), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson("${sortItem.field}.keyword")')))),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortDirection'), graphql_mapping_template_1.ref('util.toJson({"order": $sortItem.direction})')),
graphql_mapping_template_1.qref('$sortValues.add("{$sortField: $sortDirection}")'),
])),
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('nonKeywordFields.contains($sortField)'), graphql_mapping_template_1.compoundExpression([graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField0'), graphql_mapping_template_1.ref('util.toJson($sortField)'))]), graphql_mapping_template_1.compoundExpression([graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField0'), graphql_mapping_template_1.ref('util.toJson("${sortField}.keyword")'))])),
graphql_mapping_template_1.ElasticsearchMappingTemplate.searchItem({
path: graphql_mapping_template_1.str('$indexPath'),
size: graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('context.args.limit'), graphql_mapping_template_1.ref('context.args.limit'), graphql_mapping_template_1.int(graphql_transformer_common_1.ResourceConstants.DEFAULT_SEARCHABLE_PAGE_LIMIT), true),
search_after: graphql_mapping_template_1.list([graphql_mapping_template_1.ref('util.toJson($context.args.nextToken)')]),
search_after: graphql_mapping_template_1.ref('util.base64Decode($context.args.nextToken)'),
from: graphql_mapping_template_1.ref('context.args.from'),

@@ -25,3 +31,3 @@ version: graphql_mapping_template_1.bool(includeVersion),

})),
sort: graphql_mapping_template_1.list([graphql_mapping_template_1.raw('{$sortField0: { "order" : $util.toJson($sortDirection) }}')]),
sort: graphql_mapping_template_1.ref('sortValues'),
}),

@@ -35,3 +41,3 @@ ]));

graphql_mapping_template_1.forEach(graphql_mapping_template_1.ref('entry'), graphql_mapping_template_1.ref('context.result.hits.hits'), [
graphql_mapping_template_1.iff(graphql_mapping_template_1.raw('!$foreach.hasNext'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('nextToken'), graphql_mapping_template_1.ref('entry.sort.get(0)'))),
graphql_mapping_template_1.iff(graphql_mapping_template_1.raw('!$foreach.hasNext'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('nextToken'), graphql_mapping_template_1.ref('util.base64Encode($util.toJson($entry.sort))'))),
...getSourceMapper(includeVersion),

@@ -38,0 +44,0 @@ ]),

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

graphql_transformer_common_1.makeInputValueDefinition('filter', graphql_transformer_common_1.makeNamedType(`Searchable${definition.name.value}FilterInput`)),
graphql_transformer_common_1.makeInputValueDefinition('sort', graphql_transformer_common_1.makeNamedType(`Searchable${definition.name.value}SortInput`)),
graphql_transformer_common_1.makeInputValueDefinition('sort', graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(`Searchable${definition.name.value}SortInput`))),
graphql_transformer_common_1.makeInputValueDefinition('limit', graphql_transformer_common_1.makeNamedType('Int')),

@@ -99,0 +99,0 @@ graphql_transformer_common_1.makeInputValueDefinition('nextToken', graphql_transformer_common_1.makeNamedType('String')),

{
"name": "@aws-amplify/graphql-searchable-transformer",
"version": "0.2.3",
"version": "0.3.0-beta.0",
"description": "Amplfy GraphQL @searchable transformer",

@@ -30,4 +30,4 @@ "repository": {

"dependencies": {
"@aws-amplify/graphql-transformer-core": "0.6.3",
"@aws-amplify/graphql-transformer-interfaces": "1.6.1",
"@aws-amplify/graphql-transformer-core": "0.7.0-beta.0",
"@aws-amplify/graphql-transformer-interfaces": "1.7.0-beta.0",
"@aws-cdk/aws-appsync": "~1.72.0",

@@ -65,3 +65,3 @@ "@aws-cdk/aws-dynamodb": "~1.72.0",

},
"gitHead": "28d5a4797b556eb6ae15cb3e6682420d20b1b283"
"gitHead": "a4fd5c2e0d7ffb91bfecf60785422c0c18329837"
}

@@ -194,4 +194,11 @@ import { GraphQLTransform } from '@aws-amplify/graphql-transformer-core';

);
cdkExpect(searchableStack).to(
haveResource('AWS::Elasticsearch::Domain', {
DomainName: anything(),
EBSOptions: anything(),
ElasticsearchClusterConfig: anything(),
ElasticsearchVersion: '7.10',
})
);
cdkExpect(searchableStack).to(
haveResource('AWS::AppSync::DataSource', {

@@ -198,0 +205,0 @@ ApiId: {

@@ -13,3 +13,3 @@ import { EbsDeviceVolumeType } from '@aws-cdk/aws-ec2';

const domain = new Domain(stack, ElasticsearchDomainLogicalID, {
version: ElasticsearchVersion.V6_2,
version: { version: "7.10" } as ElasticsearchVersion,
ebs: {

@@ -16,0 +16,0 @@ enabled: true,

@@ -43,2 +43,3 @@ import { GraphQLAPIProvider } from '@aws-amplify/graphql-transformer-interfaces';

enviroment,
undefined,
stack,

@@ -45,0 +46,0 @@ );

@@ -28,19 +28,41 @@ import {

set(ref('nonKeywordFields'), list(nonKeywordFields)),
set(ref('sortValues'), list([])),
set(ref('primaryKey'), str(primaryKey)),
ifElse(
ref('util.isNullOrEmpty($context.args.sort)'),
compoundExpression([set(ref('sortDirection'), str('desc')), set(ref('sortField'), str(primaryKey))]),
compoundExpression([
set(ref('sortDirection'), ref('util.defaultIfNull($context.args.sort.direction, "desc")')),
set(ref('sortField'), ref(`util.defaultIfNull($context.args.sort.field, "${primaryKey}")`)),
ifElse(
ref('nonKeywordFields.contains($primaryKey)'),
set(ref('sortField'), ref('util.toJson($primaryKey)')),
set(ref('sortField'), ref('util.toJson("${primaryKey}.keyword")')),
),
set(ref('sortDirection'), ref('util.toJson({"order": "desc"})')),
qref('$sortValues.add("{$sortField: $sortDirection}")'),
]),
forEach(
ref('sortItem'),
ref('context.args.sort'),
[
ifElse(
ref('util.isNullOrEmpty($sortItem.field)'),
ifElse(
ref('nonKeywordFields.contains($primaryKey)'),
set(ref('sortField'), ref('util.toJson($primaryKey)')),
set(ref('sortField'), ref('util.toJson("${primaryKey}.keyword")')),
),
ifElse(
ref('nonKeywordFields.contains($sortItem.field)'),
set(ref('sortField'), ref('util.toJson($sortItem.field)')),
set(ref('sortField'), ref('util.toJson("${sortItem.field}.keyword")')),
),
),
set(ref('sortDirection'), ref('util.toJson({"order": $sortItem.direction})')),
qref('$sortValues.add("{$sortField: $sortDirection}")'),
],
),
),
ifElse(
ref('nonKeywordFields.contains($sortField)'),
compoundExpression([set(ref('sortField0'), ref('util.toJson($sortField)'))]),
compoundExpression([set(ref('sortField0'), ref('util.toJson("${sortField}.keyword")'))]),
),
ElasticsearchMappingTemplate.searchItem({
path: str('$indexPath'),
size: ifElse(ref('context.args.limit'), ref('context.args.limit'), int(ResourceConstants.DEFAULT_SEARCHABLE_PAGE_LIMIT), true),
search_after: list([ref('util.toJson($context.args.nextToken)')]),
search_after: ref('util.base64Decode($context.args.nextToken)'),
from: ref('context.args.from'),

@@ -55,3 +77,3 @@ version: bool(includeVersion),

),
sort: list([raw('{$sortField0: { "order" : $util.toJson($sortDirection) }}')]),
sort: ref('sortValues'),
}),

@@ -67,3 +89,3 @@ ]),

forEach(ref('entry'), ref('context.result.hits.hits'), [
iff(raw('!$foreach.hasNext'), set(ref('nextToken'), ref('entry.sort.get(0)'))),
iff(raw('!$foreach.hasNext'), set(ref('nextToken'), ref('util.base64Encode($util.toJson($entry.sort))'))),
...getSourceMapper(includeVersion),

@@ -70,0 +92,0 @@ ]),

@@ -176,3 +176,3 @@ import { TransformerPluginBase, InvalidDirectiveError, MappingTemplate, DirectiveWrapper } from '@aws-amplify/graphql-transformer-core';

makeInputValueDefinition('filter', makeNamedType(`Searchable${definition.name.value}FilterInput`)),
makeInputValueDefinition('sort', makeNamedType(`Searchable${definition.name.value}SortInput`)),
makeInputValueDefinition('sort', makeListType(makeNamedType(`Searchable${definition.name.value}SortInput`))),
makeInputValueDefinition('limit', makeNamedType('Int')),

@@ -179,0 +179,0 @@ makeInputValueDefinition('nextToken', makeNamedType('String')),

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc