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
7
Versions
443
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.9.5 to 0.9.6-apiext5.0

src/__tests__/__snapshots__/amplify-graphql-searchable-transformer.test.ts.snap

8

CHANGELOG.md

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

## [0.9.6-apiext5.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-searchable-transformer@0.9.5...@aws-amplify/graphql-searchable-transformer@0.9.6-apiext5.0) (2021-11-22)
**Note:** Version bump only for package @aws-amplify/graphql-searchable-transformer
## [0.9.5](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-searchable-transformer@0.9.4...@aws-amplify/graphql-searchable-transformer@0.9.5) (2021-11-21)

@@ -8,0 +16,0 @@

2

lib/cdk/create-searchable-datasource.js

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

const { OpenSearchDataSourceLogicalID } = graphql_transformer_common_1.ResourceConstants.RESOURCES;
assert_1.default(region);
(0, assert_1.default)(region);
const dsEndpoint = 'https://' + domainEndpoint;

@@ -14,0 +14,0 @@ return graphqlApiProvider.host.addSearchableDataSource(OpenSearchDataSourceLogicalID, region, dsEndpoint, {

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

const createLambda = (stack, apiGraphql, parameterMap, lambdaRole, endpoint, isProjectUsingDataStore, region) => {
assert_1.default(region);
(0, assert_1.default)(region);
const { OpenSearchStreamingLambdaFunctionLogicalID } = graphql_transformer_common_1.ResourceConstants.RESOURCES;

@@ -70,3 +70,3 @@ const { OpenSearchStreamingLambdaHandlerName, OpenSearchDebugStreamingLambda } = graphql_transformer_common_1.ResourceConstants.PARAMETERS;

const { OpenSearchStreamBatchSize, OpenSearchStreamMaximumBatchingWindowInSeconds } = graphql_transformer_common_1.ResourceConstants.PARAMETERS;
assert_1.default(tableStreamArn);
(0, assert_1.default)(tableStreamArn);
return new aws_lambda_1.EventSourceMapping(stack, graphql_transformer_common_1.SearchableResourceIDs.SearchableEventSourceMappingID(type), {

@@ -73,0 +73,0 @@ eventSourceArn: tableStreamArn,

@@ -58,17 +58,17 @@ "use strict";

const name = graphql_transformer_common_1.SearchableResourceIDs.SearchableFilterInputTypeName(obj.name.value);
assert_1.default(obj.fields);
(0, assert_1.default)(obj.fields);
const fields = obj.fields
.filter((field) => graphql_transformer_common_1.isScalar(field.type))
.filter((field) => (0, graphql_transformer_common_1.isScalar)(field.type))
.map((field) => ({
kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,
name: field.name,
type: graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.SearchableResourceIDs.SearchableFilterInputTypeName(graphql_transformer_common_1.getBaseType(field.type))),
type: (0, graphql_transformer_common_1.makeNamedType)(graphql_transformer_common_1.SearchableResourceIDs.SearchableFilterInputTypeName((0, graphql_transformer_common_1.getBaseType)(field.type))),
directives: [],
}));
fields.push(...obj.fields
.filter((field) => graphql_transformer_common_1.isEnum(field.type, document))
.filter((field) => (0, graphql_transformer_common_1.isEnum)(field.type, document))
.map((field) => ({
kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,
name: field.name,
type: graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.SearchableResourceIDs.SearchableFilterInputTypeName('String')),
type: (0, graphql_transformer_common_1.makeNamedType)(graphql_transformer_common_1.SearchableResourceIDs.SearchableFilterInputTypeName('String')),
directives: [],

@@ -82,3 +82,3 @@ })));

},
type: graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(name)),
type: (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)(name)),
directives: [],

@@ -91,3 +91,3 @@ }, {

},
type: graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(name)),
type: (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)(name)),
directives: [],

@@ -100,3 +100,3 @@ }, {

},
type: graphql_transformer_common_1.makeNamedType(name),
type: (0, graphql_transformer_common_1.makeNamedType)(name),
directives: [],

@@ -116,3 +116,3 @@ });

function makeSearchableSortDirectionEnumObject() {
const name = graphql_transformer_common_1.graphqlName(`SearchableSortDirection`);
const name = (0, graphql_transformer_common_1.graphqlName)(`SearchableSortDirection`);
return {

@@ -141,6 +141,6 @@ kind: graphql_1.Kind.ENUM_TYPE_DEFINITION,

function makeSearchableXSortableFieldsEnumObject(obj) {
const name = graphql_transformer_common_1.graphqlName(`Searchable${obj.name.value}SortableFields`);
assert_1.default(obj.fields);
const name = (0, graphql_transformer_common_1.graphqlName)(`Searchable${obj.name.value}SortableFields`);
(0, assert_1.default)(obj.fields);
const values = obj.fields
.filter((field) => graphql_transformer_common_1.isScalar(field.type))
.filter((field) => (0, graphql_transformer_common_1.isScalar)(field.type))
.map((field) => ({

@@ -163,6 +163,6 @@ kind: graphql_1.Kind.ENUM_VALUE_DEFINITION,

function makeSearchableXAggregateFieldEnumObject(obj, document) {
const name = graphql_transformer_common_1.graphqlName(`Searchable${obj.name.value}AggregateField`);
assert_1.default(obj.fields);
const name = (0, graphql_transformer_common_1.graphqlName)(`Searchable${obj.name.value}AggregateField`);
(0, assert_1.default)(obj.fields);
const values = obj.fields
.filter((field) => graphql_transformer_common_1.isScalar(field.type) || graphql_transformer_common_1.isEnum(field.type, document))
.filter((field) => (0, graphql_transformer_common_1.isScalar)(field.type) || (0, graphql_transformer_common_1.isEnum)(field.type, document))
.map((field) => ({

@@ -185,3 +185,3 @@ kind: graphql_1.Kind.ENUM_VALUE_DEFINITION,

function makeSearchableXSortInputObject(obj) {
const name = graphql_transformer_common_1.graphqlName(`Searchable${obj.name.value}SortInput`);
const name = (0, graphql_transformer_common_1.graphqlName)(`Searchable${obj.name.value}SortInput`);
return {

@@ -197,3 +197,3 @@ kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,

name: { kind: 'Name', value: 'field' },
type: graphql_transformer_common_1.makeNamedType(`Searchable${obj.name.value}SortableFields`),
type: (0, graphql_transformer_common_1.makeNamedType)(`Searchable${obj.name.value}SortableFields`),
directives: [],

@@ -204,3 +204,3 @@ },

name: { kind: 'Name', value: 'direction' },
type: graphql_transformer_common_1.makeNamedType('SearchableSortDirection'),
type: (0, graphql_transformer_common_1.makeNamedType)('SearchableSortDirection'),
directives: [],

@@ -214,3 +214,3 @@ },

function makeSearchableAggregateTypeEnumObject() {
const name = graphql_transformer_common_1.graphqlName('SearchableAggregateType');
const name = (0, graphql_transformer_common_1.graphqlName)('SearchableAggregateType');
const values = ['terms', 'avg', 'min', 'max', 'sum'].map((type) => ({

@@ -233,3 +233,3 @@ kind: graphql_1.Kind.ENUM_VALUE_DEFINITION,

function makeSearchableXAggregationInputObject(obj) {
const name = graphql_transformer_common_1.graphqlName(`Searchable${obj.name.value}AggregationInput`);
const name = (0, graphql_transformer_common_1.graphqlName)(`Searchable${obj.name.value}AggregationInput`);
return {

@@ -245,3 +245,3 @@ kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,

name: { kind: 'Name', value: 'name' },
type: graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('String')),
type: (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('String')),
directives: [],

@@ -252,3 +252,3 @@ },

name: { kind: 'Name', value: 'type' },
type: graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('SearchableAggregateType')),
type: (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('SearchableAggregateType')),
directives: [],

@@ -259,3 +259,3 @@ },

name: { kind: 'Name', value: 'field' },
type: graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType(`Searchable${obj.name.value}AggregateField`)),
type: (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)(`Searchable${obj.name.value}AggregateField`)),
directives: [],

@@ -271,7 +271,7 @@ },

case 'range':
return graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(type));
return (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)(type));
case 'exists':
return graphql_transformer_common_1.makeNamedType('Boolean');
return (0, graphql_transformer_common_1.makeNamedType)('Boolean');
default:
return graphql_transformer_common_1.makeNamedType(type);
return (0, graphql_transformer_common_1.makeNamedType)(type);
}

@@ -296,4 +296,4 @@ }

const extendTypeWithDirectives = (ctx, typeName, directives) => {
let objectTypeExtension = graphql_transformer_common_1.blankObjectExtension(typeName);
objectTypeExtension = graphql_transformer_common_1.extensionWithDirectives(objectTypeExtension, directives);
let objectTypeExtension = (0, graphql_transformer_common_1.blankObjectExtension)(typeName);
objectTypeExtension = (0, graphql_transformer_common_1.extensionWithDirectives)(objectTypeExtension, directives);
ctx.output.addObjectExtension(objectTypeExtension);

@@ -308,3 +308,3 @@ };

if (field) {
const newFields = [...type.fields.filter(f => f.name.value !== field.name.value), graphql_transformer_common_1.extendFieldWithDirectives(field, directives)];
const newFields = [...type.fields.filter(f => f.name.value !== field.name.value), (0, graphql_transformer_common_1.extendFieldWithDirectives)(field, directives)];
const newType = {

@@ -320,3 +320,3 @@ ...type,

const addDirectivesToOperation = (ctx, typeName, operationName, directives) => {
exports.addDirectivesToField(ctx, typeName, operationName, directives);
(0, exports.addDirectivesToField)(ctx, typeName, operationName, directives);
const type = ctx.output.getType(typeName);

@@ -329,3 +329,3 @@ if (type) {

const returnTypeName = returnFieldType.name.value;
exports.extendTypeWithDirectives(ctx, returnTypeName, directives);
(0, exports.extendTypeWithDirectives)(ctx, returnTypeName, directives);
}

@@ -332,0 +332,0 @@ }

@@ -6,33 +6,33 @@ "use strict";

const graphql_transformer_common_1 = require("graphql-transformer-common");
const authFilter = graphql_mapping_template_1.ref('ctx.stash.authFilter');
const authFilter = (0, graphql_mapping_template_1.ref)('ctx.stash.authFilter');
const API_KEY = 'API Key Authorization';
const allowedAggFieldsList = 'allowedAggFields';
function requestTemplate(primaryKey, nonKeywordFields, includeVersion = false, type, keyFields = []) {
return graphql_mapping_template_1.print(graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('indexPath'), graphql_mapping_template_1.str(`/${type.toLowerCase()}/doc/_search`)),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('allowedAggFields'), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.defaultIfNull'), graphql_mapping_template_1.ref('ctx.stash.allowedAggFields'), graphql_mapping_template_1.list([]))),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('aggFieldsFilterMap'), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.defaultIfNull'), graphql_mapping_template_1.ref('ctx.stash.aggFieldsFilterMap'), graphql_mapping_template_1.obj({}))),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('nonKeywordFields'), graphql_mapping_template_1.list(nonKeywordFields)),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('keyFields'), graphql_mapping_template_1.list(keyFields)),
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('sortFields'), graphql_mapping_template_1.list([])),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('aggregateValues'), graphql_mapping_template_1.obj({})),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('primaryKey'), graphql_mapping_template_1.str(primaryKey)),
graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.ref('util.isNullOrEmpty($context.args.sort)')), graphql_mapping_template_1.compoundExpression([
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.qref('$sortFields.add($primaryKey)'), graphql_mapping_template_1.qref('$sortFields.add($sortItem.field)')),
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.ifElse(graphql_mapping_template_1.ref('util.isNullOrEmpty($sortItem.direction)'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortDirection'), graphql_mapping_template_1.ref('util.toJson({"order": "desc"})')), 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}")'),
return (0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('indexPath'), (0, graphql_mapping_template_1.str)(`/${type.toLowerCase()}/doc/_search`)),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('allowedAggFields'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.defaultIfNull'), (0, graphql_mapping_template_1.ref)('ctx.stash.allowedAggFields'), (0, graphql_mapping_template_1.list)([]))),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('aggFieldsFilterMap'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.defaultIfNull'), (0, graphql_mapping_template_1.ref)('ctx.stash.aggFieldsFilterMap'), (0, graphql_mapping_template_1.obj)({}))),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('nonKeywordFields'), (0, graphql_mapping_template_1.list)(nonKeywordFields)),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('keyFields'), (0, graphql_mapping_template_1.list)(keyFields)),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortValues'), (0, graphql_mapping_template_1.list)([])),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortFields'), (0, graphql_mapping_template_1.list)([])),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('aggregateValues'), (0, graphql_mapping_template_1.obj)({})),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('primaryKey'), (0, graphql_mapping_template_1.str)(primaryKey)),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.ref)('util.isNullOrEmpty($context.args.sort)')), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.forEach)((0, graphql_mapping_template_1.ref)('sortItem'), (0, graphql_mapping_template_1.ref)('context.args.sort'), [
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('util.isNullOrEmpty($sortItem.field)'), (0, graphql_mapping_template_1.qref)('$sortFields.add($primaryKey)'), (0, graphql_mapping_template_1.qref)('$sortFields.add($sortItem.field)')),
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('util.isNullOrEmpty($sortItem.field)'), (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('nonKeywordFields.contains($primaryKey)'), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortField'), (0, graphql_mapping_template_1.ref)('util.toJson($primaryKey)')), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortField'), (0, graphql_mapping_template_1.ref)('util.toJson("${primaryKey}.keyword")'))), (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('nonKeywordFields.contains($sortItem.field)'), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortField'), (0, graphql_mapping_template_1.ref)('util.toJson($sortItem.field)')), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortField'), (0, graphql_mapping_template_1.ref)('util.toJson("${sortItem.field}.keyword")')))),
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('util.isNullOrEmpty($sortItem.direction)'), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortDirection'), (0, graphql_mapping_template_1.ref)('util.toJson({"order": "desc"})')), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortDirection'), (0, graphql_mapping_template_1.ref)('util.toJson({"order": $sortItem.direction})'))),
(0, graphql_mapping_template_1.qref)('$sortValues.add("{$sortField: $sortDirection}")'),
]),
])),
graphql_mapping_template_1.forEach(graphql_mapping_template_1.ref('keyItem'), graphql_mapping_template_1.ref('keyFields'), [
graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.ref('sortFields.contains($keyItem)')), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('nonKeywordFields.contains($keyItem)'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson($keyItem)')), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('sortField'), graphql_mapping_template_1.ref('util.toJson("${keyItem}.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}")'),
(0, graphql_mapping_template_1.forEach)((0, graphql_mapping_template_1.ref)('keyItem'), (0, graphql_mapping_template_1.ref)('keyFields'), [
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.ref)('sortFields.contains($keyItem)')), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('nonKeywordFields.contains($keyItem)'), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortField'), (0, graphql_mapping_template_1.ref)('util.toJson($keyItem)')), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortField'), (0, graphql_mapping_template_1.ref)('util.toJson("${keyItem}.keyword")'))),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('sortDirection'), (0, graphql_mapping_template_1.ref)('util.toJson({"order": "desc"})')),
(0, graphql_mapping_template_1.qref)('$sortValues.add("{$sortField: $sortDirection}")'),
])),
]),
graphql_mapping_template_1.forEach(graphql_mapping_template_1.ref('aggItem'), graphql_mapping_template_1.ref('context.args.aggregates'), [
graphql_mapping_template_1.raw('#if( $allowedAggFields.contains($aggItem.field) )\n' +
(0, graphql_mapping_template_1.forEach)((0, graphql_mapping_template_1.ref)('aggItem'), (0, graphql_mapping_template_1.ref)('context.args.aggregates'), [
(0, graphql_mapping_template_1.raw)('#if( $allowedAggFields.contains($aggItem.field) )\n' +
' #set( $aggFilter = { "match_all": {} } )\n' +

@@ -44,25 +44,25 @@ ' #elseif( $aggFieldsFilterMap.containsKey($aggItem.field) )\n' +

' #end'),
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('nonKeywordFields.contains($aggItem.field)'), graphql_mapping_template_1.qref('$aggregateValues.put("$aggItem.name", { "filter": $aggFilter, "aggs": { "$aggItem.name": { "$aggItem.type": { "field": "$aggItem.field" }}} })'), graphql_mapping_template_1.qref('$aggregateValues.put("$aggItem.name", { "filter": $aggFilter, "aggs": { "$aggItem.name": { "$aggItem.type": { "field": "${aggItem.field}.keyword" }}} })')),
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('nonKeywordFields.contains($aggItem.field)'), (0, graphql_mapping_template_1.qref)('$aggregateValues.put("$aggItem.name", { "filter": $aggFilter, "aggs": { "$aggItem.name": { "$aggItem.type": { "field": "$aggItem.field" }}} })'), (0, graphql_mapping_template_1.qref)('$aggregateValues.put("$aggItem.name", { "filter": $aggFilter, "aggs": { "$aggItem.name": { "$aggItem.type": { "field": "${aggItem.field}.keyword" }}} })')),
]),
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(authFilter)), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), authFilter),
graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(graphql_mapping_template_1.ref('ctx.args.filter'))), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.obj({
bool: graphql_mapping_template_1.obj({
must: graphql_mapping_template_1.list([
graphql_mapping_template_1.ref('ctx.stash.authFilter'),
graphql_mapping_template_1.ref('util.parseJson($util.transform.toElasticsearchQueryDSL($ctx.args.filter))'),
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)(authFilter)), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), authFilter),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('ctx.args.filter'))), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.obj)({
bool: (0, graphql_mapping_template_1.obj)({
must: (0, graphql_mapping_template_1.list)([
(0, graphql_mapping_template_1.ref)('ctx.stash.authFilter'),
(0, graphql_mapping_template_1.ref)('util.parseJson($util.transform.toElasticsearchQueryDSL($ctx.args.filter))'),
]),
}),
}))),
]), graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(graphql_mapping_template_1.ref('ctx.args.filter'))), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.ref('util.parseJson($util.transform.toElasticsearchQueryDSL($ctx.args.filter))')))),
graphql_mapping_template_1.iff(graphql_mapping_template_1.isNullOrEmpty(graphql_mapping_template_1.ref('filter')), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.obj({ match_all: graphql_mapping_template_1.obj({}) }))),
]), (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('ctx.args.filter'))), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('util.parseJson($util.transform.toElasticsearchQueryDSL($ctx.args.filter))')))),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('filter')), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.obj)({ match_all: (0, graphql_mapping_template_1.obj)({}) }))),
graphql_mapping_template_1.SearchableMappingTemplate.searchTemplate({
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.ref('util.base64Decode($context.args.nextToken)'),
from: graphql_mapping_template_1.ref('context.args.from'),
version: graphql_mapping_template_1.bool(includeVersion),
query: graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.toJson'), graphql_mapping_template_1.ref('filter')),
sort: graphql_mapping_template_1.ref('sortValues'),
aggs: graphql_mapping_template_1.ref('util.toJson($aggregateValues)'),
path: (0, graphql_mapping_template_1.str)('$indexPath'),
size: (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('context.args.limit'), (0, graphql_mapping_template_1.ref)('context.args.limit'), (0, graphql_mapping_template_1.int)(graphql_transformer_common_1.ResourceConstants.DEFAULT_SEARCHABLE_PAGE_LIMIT), true),
search_after: (0, graphql_mapping_template_1.ref)('util.base64Decode($context.args.nextToken)'),
from: (0, graphql_mapping_template_1.ref)('context.args.from'),
version: (0, graphql_mapping_template_1.bool)(includeVersion),
query: (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.toJson'), (0, graphql_mapping_template_1.ref)('filter')),
sort: (0, graphql_mapping_template_1.ref)('sortValues'),
aggs: (0, graphql_mapping_template_1.ref)('util.toJson($aggregateValues)'),
}),

@@ -73,32 +73,32 @@ ]));

function responseTemplate(includeVersion = false) {
return graphql_mapping_template_1.print(graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('es_items'), graphql_mapping_template_1.list([])),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('aggregateValues'), graphql_mapping_template_1.list([])),
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('util.base64Encode($util.toJson($entry.sort))'))),
return (0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('es_items'), (0, graphql_mapping_template_1.list)([])),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('aggregateValues'), (0, graphql_mapping_template_1.list)([])),
(0, graphql_mapping_template_1.forEach)((0, graphql_mapping_template_1.ref)('entry'), (0, graphql_mapping_template_1.ref)('context.result.hits.hits'), [
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.raw)('!$foreach.hasNext'), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('nextToken'), (0, graphql_mapping_template_1.ref)('util.base64Encode($util.toJson($entry.sort))'))),
...getSourceMapper(includeVersion),
]),
graphql_mapping_template_1.forEach(graphql_mapping_template_1.ref('aggItem'), graphql_mapping_template_1.ref('context.result.aggregations.keySet()'), [
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('aggResult'), graphql_mapping_template_1.obj({})),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('aggResultValue'), graphql_mapping_template_1.obj({})),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('currentAggItem'), graphql_mapping_template_1.ref('ctx.result.aggregations.get($aggItem)')),
graphql_mapping_template_1.qref('$aggResult.put("name", $aggItem)'),
graphql_mapping_template_1.iff(graphql_mapping_template_1.raw('!$util.isNullOrEmpty($currentAggItem)'), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.iff(graphql_mapping_template_1.raw('!$util.isNullOrEmpty($currentAggItem.get($aggItem).buckets)'), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.qref('$aggResultValue.put("__typename", "SearchableAggregateBucketResult")'),
graphql_mapping_template_1.qref('$aggResultValue.put("buckets", $currentAggItem.get($aggItem).buckets)'),
(0, graphql_mapping_template_1.forEach)((0, graphql_mapping_template_1.ref)('aggItem'), (0, graphql_mapping_template_1.ref)('context.result.aggregations.keySet()'), [
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('aggResult'), (0, graphql_mapping_template_1.obj)({})),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('aggResultValue'), (0, graphql_mapping_template_1.obj)({})),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('currentAggItem'), (0, graphql_mapping_template_1.ref)('ctx.result.aggregations.get($aggItem)')),
(0, graphql_mapping_template_1.qref)('$aggResult.put("name", $aggItem)'),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.raw)('!$util.isNullOrEmpty($currentAggItem)'), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.raw)('!$util.isNullOrEmpty($currentAggItem.get($aggItem).buckets)'), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.qref)('$aggResultValue.put("__typename", "SearchableAggregateBucketResult")'),
(0, graphql_mapping_template_1.qref)('$aggResultValue.put("buckets", $currentAggItem.get($aggItem).buckets)'),
])),
graphql_mapping_template_1.iff(graphql_mapping_template_1.raw('!$util.isNullOrEmpty($currentAggItem.get($aggItem).value)'), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.qref('$aggResultValue.put("__typename", "SearchableAggregateScalarResult")'),
graphql_mapping_template_1.qref('$aggResultValue.put("value", $currentAggItem.get($aggItem).value)'),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.raw)('!$util.isNullOrEmpty($currentAggItem.get($aggItem).value)'), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.qref)('$aggResultValue.put("__typename", "SearchableAggregateScalarResult")'),
(0, graphql_mapping_template_1.qref)('$aggResultValue.put("value", $currentAggItem.get($aggItem).value)'),
])),
])),
graphql_mapping_template_1.qref('$aggResult.put("result", $aggResultValue)'),
graphql_mapping_template_1.qref('$aggregateValues.add($aggResult)'),
(0, graphql_mapping_template_1.qref)('$aggResult.put("result", $aggResultValue)'),
(0, graphql_mapping_template_1.qref)('$aggregateValues.add($aggResult)'),
]),
graphql_mapping_template_1.toJson(graphql_mapping_template_1.obj({
items: graphql_mapping_template_1.ref('es_items'),
total: graphql_mapping_template_1.ref('ctx.result.hits.total.value'),
nextToken: graphql_mapping_template_1.ref('nextToken'),
aggregateItems: graphql_mapping_template_1.ref('aggregateValues'),
(0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.obj)({
items: (0, graphql_mapping_template_1.ref)('es_items'),
total: (0, graphql_mapping_template_1.ref)('ctx.result.hits.total.value'),
nextToken: (0, graphql_mapping_template_1.ref)('nextToken'),
aggregateItems: (0, graphql_mapping_template_1.ref)('aggregateValues'),
})),

@@ -111,8 +111,8 @@ ]));

if (enabled) {
sandboxExp = graphql_mapping_template_1.ifElse(graphql_mapping_template_1.notEquals(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.authType')), graphql_mapping_template_1.str(API_KEY)), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.unauthorized')), graphql_mapping_template_1.qref(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('ctx.stash.put'), graphql_mapping_template_1.str(allowedAggFieldsList), graphql_mapping_template_1.raw(JSON.stringify(fields)))));
sandboxExp = (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.notEquals)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.authType')), (0, graphql_mapping_template_1.str)(API_KEY)), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.unauthorized')), (0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('ctx.stash.put'), (0, graphql_mapping_template_1.str)(allowedAggFieldsList), (0, graphql_mapping_template_1.raw)(JSON.stringify(fields)))));
}
else {
sandboxExp = graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.unauthorized'));
sandboxExp = (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.unauthorized'));
}
return graphql_mapping_template_1.printBlock(`Sandbox Mode ${enabled ? 'Enabled' : 'Disabled'}`)(graphql_mapping_template_1.compoundExpression([graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.ref('ctx.stash.get("hasAuth")')), sandboxExp), graphql_mapping_template_1.toJson(graphql_mapping_template_1.obj({}))]));
return (0, graphql_mapping_template_1.printBlock)(`Sandbox Mode ${enabled ? 'Enabled' : 'Disabled'}`)((0, graphql_mapping_template_1.compoundExpression)([(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.ref)('ctx.stash.get("hasAuth")')), sandboxExp), (0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.obj)({}))]));
}

@@ -123,9 +123,9 @@ exports.sandboxMappingTemplate = sandboxMappingTemplate;

return [
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('row'), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('entry.get'), graphql_mapping_template_1.str('_source'))),
graphql_mapping_template_1.qref('$row.put("_version", $entry.get("_version"))'),
graphql_mapping_template_1.qref('$es_items.add($row)'),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('row'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('entry.get'), (0, graphql_mapping_template_1.str)('_source'))),
(0, graphql_mapping_template_1.qref)('$row.put("_version", $entry.get("_version"))'),
(0, graphql_mapping_template_1.qref)('$es_items.add($row)'),
];
}
return [graphql_mapping_template_1.qref('$es_items.add($entry.get("_source"))')];
return [(0, graphql_mapping_template_1.qref)('$es_items.add($entry.get("_source"))')];
}
//# sourceMappingURL=generate-resolver-vtl.js.map

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

const stack = context.stackManager.createStack(STACK_NAME);
create_layer_cfnMapping_1.setMappings(stack);
(0, create_layer_cfnMapping_1.setMappings)(stack);
const envParam = context.stackManager.getParameter(Env);

@@ -44,10 +44,10 @@ new core_1.CfnCondition(stack, HasEnvironmentParameter, {

stack.templateOptions.templateFormatVersion = '2010-09-09';
const parameterMap = create_cfnParameters_1.createParametersStack(stack);
const domain = create_searchable_domain_1.createSearchableDomain(stack, parameterMap, context.api.apiId);
const openSearchRole = create_searchable_domain_1.createSearchableDomainRole(context, stack, parameterMap);
const parameterMap = (0, create_cfnParameters_1.createParametersStack)(stack);
const domain = (0, create_searchable_domain_1.createSearchableDomain)(stack, parameterMap, context.api.apiId);
const openSearchRole = (0, create_searchable_domain_1.createSearchableDomainRole)(context, stack, parameterMap);
domain.grantReadWrite(openSearchRole);
const datasource = create_searchable_datasource_1.createSearchableDataSource(stack, context.api, domain.domainEndpoint, openSearchRole, stack.parseArn(domain.domainArn).region);
const lambdaRole = create_streaming_lambda_1.createLambdaRole(context, stack, parameterMap);
const datasource = (0, create_searchable_datasource_1.createSearchableDataSource)(stack, context.api, domain.domainEndpoint, openSearchRole, stack.parseArn(domain.domainArn).region);
const lambdaRole = (0, create_streaming_lambda_1.createLambdaRole)(context, stack, parameterMap);
domain.grantWrite(lambdaRole);
const lambda = create_streaming_lambda_1.createLambda(stack, context.api, parameterMap, lambdaRole, domain.domainEndpoint, isProjectUsingDataStore, stack.parseArn(domain.domainArn).region);
const lambda = (0, create_streaming_lambda_1.createLambda)(stack, context.api, parameterMap, lambdaRole, domain.domainEndpoint, isProjectUsingDataStore, stack.parseArn(domain.domainArn).region);
for (const def of this.searchableObjectTypeDefinitions) {

@@ -59,14 +59,14 @@ const type = def.node.name.value;

const ddbTable = table;
assert_1.default(ddbTable);
(0, assert_1.default)(ddbTable);
ddbTable.grantStreamRead(lambdaRole);
create_streaming_lambda_1.createEventSourceMapping(stack, type, lambda, parameterMap, ddbTable.tableStreamArn);
(0, create_streaming_lambda_1.createEventSourceMapping)(stack, type, lambda, parameterMap, ddbTable.tableStreamArn);
const { attributeName } = table.keySchema.find((att) => att.keyType === 'HASH');
const keyFields = getKeyFields(attributeName, table);
assert_1.default(typeName);
const resolver = context.resolvers.generateQueryResolver(typeName, def.fieldName, graphql_transformer_common_1.ResolverResourceIDs.ElasticsearchSearchResolverResourceID(type), datasource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(generate_resolver_vtl_1.requestTemplate(attributeName, getNonKeywordFields(def.node), context.isProjectUsingDataStore(), type, keyFields), `${typeName}.${def.fieldName}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(generate_resolver_vtl_1.responseTemplate(false), `${typeName}.${def.fieldName}.res.vtl`));
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(generate_resolver_vtl_1.sandboxMappingTemplate(context.sandboxModeEnabled, fields), `${typeName}.${def.fieldName}.{slotName}.{slotIndex}.res.vtl`));
(0, assert_1.default)(typeName);
const resolver = context.resolvers.generateQueryResolver(typeName, def.fieldName, graphql_transformer_common_1.ResolverResourceIDs.ElasticsearchSearchResolverResourceID(type), datasource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, generate_resolver_vtl_1.requestTemplate)(attributeName, getNonKeywordFields(def.node), context.isProjectUsingDataStore(), type, keyFields), `${typeName}.${def.fieldName}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, generate_resolver_vtl_1.responseTemplate)(false), `${typeName}.${def.fieldName}.res.vtl`));
resolver.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, generate_resolver_vtl_1.sandboxMappingTemplate)(context.sandboxModeEnabled, fields), `${typeName}.${def.fieldName}.{slotName}.{slotIndex}.res.vtl`));
resolver.mapToStack(stack);
context.resolvers.addResolver('Search', graphql_transformer_common_1.toUpper(type), resolver);
context.resolvers.addResolver('Search', (0, graphql_transformer_common_1.toUpper)(type), resolver);
}
create_cfnOutput_1.createStackOutputs(stack, domain.domainEndpoint, context.api.apiId, domain.domainArn);
(0, create_cfnOutput_1.createStackOutputs)(stack, domain.domainEndpoint, context.api.apiId, domain.domainArn);
};

@@ -94,3 +94,3 @@ this.object = (definition, directive, ctx) => {

? searchFieldNameOverride
: graphql_transformer_common_1.graphqlName(`search${graphql_transformer_common_1.plurality(graphql_transformer_common_1.toUpper(definition.name.value), true)}`);
: (0, graphql_transformer_common_1.graphqlName)(`search${(0, graphql_transformer_common_1.plurality)((0, graphql_transformer_common_1.toUpper)(definition.name.value), true)}`);
this.searchableObjectTypeDefinitions.push({

@@ -106,12 +106,12 @@ node: definition,

if (!hasAuth && ctx.sandboxModeEnabled && ctx.authConfig.defaultAuthentication.authenticationType !== 'API_KEY') {
directives.push(graphql_transformer_common_1.makeDirective('aws_api_key', []));
directives.push((0, graphql_transformer_common_1.makeDirective)('aws_api_key', []));
}
const queryField = graphql_transformer_common_1.makeField(fieldName, [
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.makeListType(graphql_transformer_common_1.makeNamedType(`Searchable${definition.name.value}SortInput`))),
graphql_transformer_common_1.makeInputValueDefinition('limit', graphql_transformer_common_1.makeNamedType('Int')),
graphql_transformer_common_1.makeInputValueDefinition('nextToken', graphql_transformer_common_1.makeNamedType('String')),
graphql_transformer_common_1.makeInputValueDefinition('from', graphql_transformer_common_1.makeNamedType('Int')),
graphql_transformer_common_1.makeInputValueDefinition('aggregates', graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(`Searchable${definition.name.value}AggregationInput`))),
], graphql_transformer_common_1.makeNamedType(`Searchable${definition.name.value}Connection`), directives);
const queryField = (0, graphql_transformer_common_1.makeField)(fieldName, [
(0, graphql_transformer_common_1.makeInputValueDefinition)('filter', (0, graphql_transformer_common_1.makeNamedType)(`Searchable${definition.name.value}FilterInput`)),
(0, graphql_transformer_common_1.makeInputValueDefinition)('sort', (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)(`Searchable${definition.name.value}SortInput`))),
(0, graphql_transformer_common_1.makeInputValueDefinition)('limit', (0, graphql_transformer_common_1.makeNamedType)('Int')),
(0, graphql_transformer_common_1.makeInputValueDefinition)('nextToken', (0, graphql_transformer_common_1.makeNamedType)('String')),
(0, graphql_transformer_common_1.makeInputValueDefinition)('from', (0, graphql_transformer_common_1.makeNamedType)('Int')),
(0, graphql_transformer_common_1.makeInputValueDefinition)('aggregates', (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)(`Searchable${definition.name.value}AggregationInput`))),
], (0, graphql_transformer_common_1.makeNamedType)(`Searchable${definition.name.value}Connection`), directives);
ctx.output.addQueryFields([queryField]);

@@ -131,3 +131,3 @@ }

if (!hasApiKey) {
definitions_1.extendTypeWithDirectives(ctx, aggType, [graphql_transformer_common_1.makeDirective('aws_api_key', [])]);
(0, definitions_1.extendTypeWithDirectives)(ctx, aggType, [(0, graphql_transformer_common_1.makeDirective)('aws_api_key', [])]);
}

@@ -145,12 +145,12 @@ }

}
const connectionType = graphql_transformer_common_1.blankObject(searchableXConnectionName);
const connectionType = (0, graphql_transformer_common_1.blankObject)(searchableXConnectionName);
ctx.output.addObject(connectionType);
let connectionTypeExtension = graphql_transformer_common_1.blankObjectExtension(searchableXConnectionName);
connectionTypeExtension = graphql_transformer_common_1.extensionWithFields(connectionTypeExtension, [
graphql_transformer_common_1.makeField('items', [], graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType(definition.name.value))))),
let connectionTypeExtension = (0, graphql_transformer_common_1.blankObjectExtension)(searchableXConnectionName);
connectionTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(connectionTypeExtension, [
(0, graphql_transformer_common_1.makeField)('items', [], (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)(definition.name.value))))),
]);
connectionTypeExtension = graphql_transformer_common_1.extensionWithFields(connectionTypeExtension, [
graphql_transformer_common_1.makeField('nextToken', [], graphql_transformer_common_1.makeNamedType('String')),
graphql_transformer_common_1.makeField('total', [], graphql_transformer_common_1.makeNamedType('Int')),
graphql_transformer_common_1.makeField('aggregateItems', [], graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType(`SearchableAggregateResult`))))),
connectionTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(connectionTypeExtension, [
(0, graphql_transformer_common_1.makeField)('nextToken', [], (0, graphql_transformer_common_1.makeNamedType)('String')),
(0, graphql_transformer_common_1.makeField)('total', [], (0, graphql_transformer_common_1.makeNamedType)('Int')),
(0, graphql_transformer_common_1.makeField)('aggregateItems', [], (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)(`SearchableAggregateResult`))))),
]);

@@ -168,5 +168,5 @@ ctx.output.addObjectExtension(connectionTypeExtension);

}
let searchableAggregateGenericResultNode = graphql_transformer_common_1.defineUnionType(searchableAggregateGenericResult, [
graphql_transformer_common_1.makeNamedType(this.generateSearchableAggregateScalarResultType(ctx)),
graphql_transformer_common_1.makeNamedType(this.generateSearchableAggregateBucketResultType(ctx)),
let searchableAggregateGenericResultNode = (0, graphql_transformer_common_1.defineUnionType)(searchableAggregateGenericResult, [
(0, graphql_transformer_common_1.makeNamedType)(this.generateSearchableAggregateScalarResultType(ctx)),
(0, graphql_transformer_common_1.makeNamedType)(this.generateSearchableAggregateBucketResultType(ctx)),
]);

@@ -180,7 +180,7 @@ ctx.output.addUnion(searchableAggregateGenericResultNode);

}
const aggregateScalarType = graphql_transformer_common_1.blankObject(searchableAggregateScalarResult);
const aggregateScalarType = (0, graphql_transformer_common_1.blankObject)(searchableAggregateScalarResult);
ctx.output.addObject(aggregateScalarType);
let aggregateScalarTypeExtension = graphql_transformer_common_1.blankObjectExtension(searchableAggregateScalarResult);
aggregateScalarTypeExtension = graphql_transformer_common_1.extensionWithFields(aggregateScalarTypeExtension, [
graphql_transformer_common_1.makeField('value', [], graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('Float'))),
let aggregateScalarTypeExtension = (0, graphql_transformer_common_1.blankObjectExtension)(searchableAggregateScalarResult);
aggregateScalarTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(aggregateScalarTypeExtension, [
(0, graphql_transformer_common_1.makeField)('value', [], (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('Float'))),
]);

@@ -195,8 +195,8 @@ ctx.output.addObjectExtension(aggregateScalarTypeExtension);

}
const aggregateBucketResultItemType = graphql_transformer_common_1.blankObject(searchableAggregateBucketResultItem);
const aggregateBucketResultItemType = (0, graphql_transformer_common_1.blankObject)(searchableAggregateBucketResultItem);
ctx.output.addObject(aggregateBucketResultItemType);
let aggregateBucketResultItemTypeExtension = graphql_transformer_common_1.blankObjectExtension(searchableAggregateBucketResultItem);
aggregateBucketResultItemTypeExtension = graphql_transformer_common_1.extensionWithFields(aggregateBucketResultItemTypeExtension, [
graphql_transformer_common_1.makeField('key', [], graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('String'))),
graphql_transformer_common_1.makeField('doc_count', [], graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('Int'))),
let aggregateBucketResultItemTypeExtension = (0, graphql_transformer_common_1.blankObjectExtension)(searchableAggregateBucketResultItem);
aggregateBucketResultItemTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(aggregateBucketResultItemTypeExtension, [
(0, graphql_transformer_common_1.makeField)('key', [], (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('String'))),
(0, graphql_transformer_common_1.makeField)('doc_count', [], (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('Int'))),
]);

@@ -211,8 +211,8 @@ ctx.output.addObjectExtension(aggregateBucketResultItemTypeExtension);

}
const aggregateBucketResultType = graphql_transformer_common_1.blankObject(searchableAggregateBucketResult);
const aggregateBucketResultType = (0, graphql_transformer_common_1.blankObject)(searchableAggregateBucketResult);
ctx.output.addObject(aggregateBucketResultType);
this.generateSearchableAggregateBucketResultItemType(ctx);
let aggregateBucketResultTypeExtension = graphql_transformer_common_1.blankObjectExtension(searchableAggregateBucketResult);
aggregateBucketResultTypeExtension = graphql_transformer_common_1.extensionWithFields(aggregateBucketResultTypeExtension, [
graphql_transformer_common_1.makeField('buckets', [], graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType('SearchableAggregateBucketResultItem'))),
let aggregateBucketResultTypeExtension = (0, graphql_transformer_common_1.blankObjectExtension)(searchableAggregateBucketResult);
aggregateBucketResultTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(aggregateBucketResultTypeExtension, [
(0, graphql_transformer_common_1.makeField)('buckets', [], (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)('SearchableAggregateBucketResultItem'))),
]);

@@ -227,8 +227,8 @@ ctx.output.addObjectExtension(aggregateBucketResultTypeExtension);

}
const aggregateResultType = graphql_transformer_common_1.blankObject(searchableAggregateResult);
const aggregateResultType = (0, graphql_transformer_common_1.blankObject)(searchableAggregateResult);
ctx.output.addObject(aggregateResultType);
let aggregateResultTypeExtension = graphql_transformer_common_1.blankObjectExtension(searchableAggregateResult);
aggregateResultTypeExtension = graphql_transformer_common_1.extensionWithFields(aggregateResultTypeExtension, [
graphql_transformer_common_1.makeField('name', [], graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('String'))),
graphql_transformer_common_1.makeField('result', [], graphql_transformer_common_1.makeNamedType('SearchableAggregateGenericResult')),
let aggregateResultTypeExtension = (0, graphql_transformer_common_1.blankObjectExtension)(searchableAggregateResult);
aggregateResultTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(aggregateResultTypeExtension, [
(0, graphql_transformer_common_1.makeField)('name', [], (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('String'))),
(0, graphql_transformer_common_1.makeField)('result', [], (0, graphql_transformer_common_1.makeNamedType)('SearchableAggregateGenericResult')),
]);

@@ -244,3 +244,3 @@ ctx.output.addObjectExtension(aggregateResultTypeExtension);

.forEach((node) => ctx.output.addInput(node));
const searchableXQueryFilterInput = definitions_1.makeSearchableXFilterInputObject(definition, ctx.inputDocument);
const searchableXQueryFilterInput = (0, definitions_1.makeSearchableXFilterInputObject)(definition, ctx.inputDocument);
if (!ctx.output.hasType(searchableXQueryFilterInput.name.value)) {

@@ -250,23 +250,23 @@ ctx.output.addInput(searchableXQueryFilterInput);

if (!ctx.output.hasType('SearchableSortDirection')) {
const searchableSortDirection = definitions_1.makeSearchableSortDirectionEnumObject();
const searchableSortDirection = (0, definitions_1.makeSearchableSortDirectionEnumObject)();
ctx.output.addEnum(searchableSortDirection);
}
if (!ctx.output.hasType(`Searchable${definition.name.value}SortableFields`)) {
const searchableXSortableFieldsDirection = definitions_1.makeSearchableXSortableFieldsEnumObject(definition);
const searchableXSortableFieldsDirection = (0, definitions_1.makeSearchableXSortableFieldsEnumObject)(definition);
ctx.output.addEnum(searchableXSortableFieldsDirection);
}
if (!ctx.output.hasType(`Searchable${definition.name.value}SortInput`)) {
const searchableXSortableInputDirection = definitions_1.makeSearchableXSortInputObject(definition);
const searchableXSortableInputDirection = (0, definitions_1.makeSearchableXSortInputObject)(definition);
ctx.output.addInput(searchableXSortableInputDirection);
}
if (!ctx.output.hasType('SearchableAggregateType')) {
const searchableAggregateTypeEnum = definitions_1.makeSearchableAggregateTypeEnumObject();
const searchableAggregateTypeEnum = (0, definitions_1.makeSearchableAggregateTypeEnumObject)();
ctx.output.addEnum(searchableAggregateTypeEnum);
}
if (!ctx.output.hasType(`Searchable${definition.name.value}AggregateField`)) {
const searchableXAggregationField = definitions_1.makeSearchableXAggregateFieldEnumObject(definition, ctx.inputDocument);
const searchableXAggregationField = (0, definitions_1.makeSearchableXAggregateFieldEnumObject)(definition, ctx.inputDocument);
ctx.output.addEnum(searchableXAggregationField);
}
if (!ctx.output.hasType(`Searchable${definition.name.value}AggregationInput`)) {
const searchableXAggregationInput = definitions_1.makeSearchableXAggregationInputObject(definition);
const searchableXAggregationInput = (0, definitions_1.makeSearchableXAggregationInputObject)(definition);
ctx.output.addInput(searchableXAggregationInput);

@@ -286,3 +286,3 @@ }

const nonKeywordTypeSet = new Set(nonKeywordTypes);
return ((_a = def.fields) === null || _a === void 0 ? void 0 : _a.filter(field => nonKeywordTypeSet.has(graphql_transformer_common_1.getBaseType(field.type))).map(field => graphql_mapping_template_1.str(field.name.value))) || [];
return ((_a = def.fields) === null || _a === void 0 ? void 0 : _a.filter(field => nonKeywordTypeSet.has((0, graphql_transformer_common_1.getBaseType)(field.type))).map(field => (0, graphql_mapping_template_1.str)(field.name.value))) || [];
}

@@ -296,4 +296,4 @@ function getKeyFields(primaryKey, table) {

}
return keyFields.map(key => graphql_mapping_template_1.str(key));
return keyFields.map(key => (0, graphql_mapping_template_1.str)(key));
}
//# sourceMappingURL=graphql-searchable-transformer.js.map
{
"name": "@aws-amplify/graphql-searchable-transformer",
"version": "0.9.5",
"version": "0.9.6-apiext5.0",
"description": "Amplfy GraphQL @searchable transformer",

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

"dependencies": {
"@aws-amplify/graphql-transformer-core": "0.13.2",
"@aws-amplify/graphql-transformer-core": "0.13.3-apiext5.0",
"@aws-amplify/graphql-transformer-interfaces": "1.12.3",

@@ -63,5 +63,8 @@ "@aws-cdk/aws-appsync": "~1.124.0",

],
"collectCoverage": true
"collectCoverage": true,
"modulePathIgnorePatterns": [
"overrides"
]
},
"gitHead": "8a18fcbdf12deeaf4f6d11c6b0baef8b9011167d"
"gitHead": "5cb3a127872e34ba86995cd23e44b2264817526f"
}

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