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

graphql-mapping-template

Package Overview
Dependencies
Maintainers
2
Versions
636
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-mapping-template - npm Package Compare versions

Comparing version 1.1.0-alpha.0fe7fa01 to 1.1.0-alpha.114e0b6e

40

CHANGELOG.md

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

<a name="1.0.31"></a>
## [1.0.31](https://github.com/aws-amplify/amplify-cli/compare/graphql-mapping-template@1.0.12...graphql-mapping-template@1.0.31) (2018-11-02)
**Note:** Version bump only for package graphql-mapping-template
<a name="1.0.30"></a>
## [1.0.30](https://github.com/aws-amplify/amplify-cli/compare/graphql-mapping-template@1.0.30-beta.0...graphql-mapping-template@1.0.30) (2018-11-02)
**Note:** Version bump only for package graphql-mapping-template
<a name="1.0.30-beta.0"></a>
## [1.0.30-beta.0](https://github.com/aws-amplify/amplify-cli/compare/graphql-mapping-template@1.0.12...graphql-mapping-template@1.0.30-beta.0) (2018-11-02)
**Note:** Version bump only for package graphql-mapping-template
<a name="1.0.29"></a>
## [1.0.29](https://github.com/aws-amplify/amplify-cli/compare/graphql-mapping-template@1.0.29-beta.0...graphql-mapping-template@1.0.29) (2018-10-23)
**Note:** Version bump only for package graphql-mapping-template
<a name="1.0.29-beta.0"></a>
## [1.0.29-beta.0](https://github.com/aws-amplify/amplify-cli/compare/graphql-mapping-template@1.0.12...graphql-mapping-template@1.0.29-beta.0) (2018-10-23)
**Note:** Version bump only for package graphql-mapping-template
<a name="1.0.28"></a>

@@ -8,0 +48,0 @@ ## [1.0.28](https://github.com/aws-amplify/amplify-cli/compare/graphql-mapping-template@1.0.28-beta.0...graphql-mapping-template@1.0.28) (2018-10-18)

15

lib/ast.d.ts

@@ -65,2 +65,10 @@ /**

/**
* Compares two expressions for unequality.
*/
export interface NotNode {
kind: 'Not';
expr: Expression;
}
export declare function not(expr: Expression): NotNode;
/**
* Iterates through a collection.

@@ -190,5 +198,10 @@ */

export declare function toJson(expr: Expression): ToJsonNode;
export declare type NewLineNode = {
kind: 'NewLine';
};
export declare function newline(): NewLineNode;
export declare function block(name: string, exprs: Expression[]): CompoundExpressionNode;
/**
* A flow expression is one that dictates program flow e.g. if, ifelse, for, while, etc.
*/
export declare type Expression = IfNode | IfElseNode | AndNode | OrNode | ParensNode | EqualsNode | NotEqualsNode | ForEachNode | StringNode | RawNode | QuotesNode | FloatNode | IntNode | BooleanNode | NullNode | ReferenceNode | QuietReferenceNode | ObjectNode | ListNode | SetNode | CommentNode | CompoundExpressionNode | ToJsonNode;
export declare type Expression = IfNode | IfElseNode | AndNode | OrNode | ParensNode | EqualsNode | NotEqualsNode | ForEachNode | StringNode | RawNode | QuotesNode | FloatNode | IntNode | BooleanNode | NullNode | ReferenceNode | QuietReferenceNode | ObjectNode | ListNode | SetNode | CommentNode | CompoundExpressionNode | ToJsonNode | NotNode | NewLineNode;

@@ -59,2 +59,9 @@ "use strict";

exports.notEquals = notEquals;
function not(expr) {
return {
kind: 'Not',
expr: expr,
};
}
exports.not = not;
function forEach(key, collection, expressions) {

@@ -176,2 +183,16 @@ return {

exports.toJson = toJson;
function newline() {
return {
kind: 'NewLine',
};
}
exports.newline = newline;
function block(name, exprs) {
return compoundExpression([
comment("[Start] " + name)
].concat(exprs, [
comment("[End] " + name)
]));
}
exports.block = block;
//# sourceMappingURL=ast.js.map

43

lib/print.js

@@ -8,5 +8,5 @@ "use strict";

if (node.inline) {
return "#if( " + printExpr(node.predicate) + " ) " + printExpr(node.expr) + " #end";
return "#if( " + printExpr(node.predicate, '') + " ) " + printExpr(node.expr, '') + " #end";
}
return indent + "#if( " + printExpr(node.predicate) + " )\n" + printExpr(node.expr, indent + TAB) + "\n" + indent + "#end";
return indent + "#if( " + printExpr(node.predicate, '') + " )\n" + printExpr(node.expr, indent + TAB) + "\n" + indent + "#end";
}

@@ -23,5 +23,5 @@ function printIfElse(node, indent) {

return indent + "#if( " + printExpr(node.predicate) + " )\n" +
("" + indent + TAB + printExpr(node.ifExpr) + "\n") +
(printExpr(node.ifExpr, indent + TAB) + "\n") +
(indent + "#else\n") +
("" + indent + TAB + printExpr(node.elseExpr) + "\n") +
(printExpr(node.elseExpr, indent + TAB) + "\n") +
(indent + "#end");

@@ -61,4 +61,5 @@ }

}
function printRaw(node) {
return "" + node.value;
function printRaw(node, indent) {
if (indent === void 0) { indent = ''; }
return "" + indent + node.value;
}

@@ -80,4 +81,5 @@ function printQuotes(node) {

}
function printQuietReference(node) {
return "$util.qr(" + node.value + ")";
function printQuietReference(node, indent) {
if (indent === void 0) { indent = ''; }
return indent + "$util.qr(" + node.value + ")";
}

@@ -95,3 +97,3 @@ function printObject(node, indent) {

if (indent === void 0) { indent = ''; }
var values = node.expressions.map(function (e) { return printExpr(e, indent); }).join(', ');
var values = node.expressions.map(function (e) { return printExpr(e, ''); }).join(', ');
return indent + "[" + values + "]";

@@ -101,3 +103,3 @@ }

if (indent === void 0) { indent = ''; }
return indent + "#set( " + printReference(node.key) + " = " + printExpr(node.value) + " )";
return indent + "#set( " + printReference(node.key) + " = " + printExpr(node.value, '') + " )";
}

@@ -110,3 +112,3 @@ function printComment(node, indent) {

if (indent === void 0) { indent = ''; }
return node.expressions.map(function (node) { return indent + printExpr(node, indent); }).join("\n" + indent);
return node.expressions.map(function (node) { return printExpr(node, indent); }).join("\n");
}

@@ -117,2 +119,9 @@ function printToJson(node, indent) {

}
function printNot(node, indent) {
if (indent === void 0) { indent = ''; }
return indent + "!" + printExpr(node.expr, '');
}
function printNewLine(node) {
return '\n';
}
function printExpr(expr, indent) {

@@ -143,3 +152,3 @@ if (indent === void 0) { indent = ''; }

case 'Raw':
return printRaw(expr);
return printRaw(expr, indent);
case 'Quotes':

@@ -158,3 +167,3 @@ return printQuotes(expr);

case 'QuietReference':
return printQuietReference(expr);
return printQuietReference(expr, indent);
case 'Object':

@@ -172,2 +181,6 @@ return printObject(expr, indent);

return printToJson(expr, indent);
case 'Not':
return printNot(expr, indent);
case 'NewLine':
return printNewLine(expr);
default:

@@ -184,5 +197,5 @@ return '';

var wrappedExpr = ast_1.compoundExpression([
ast_1.comment("START: " + name + "."),
ast_1.comment("[Start] " + name + "."),
expr,
ast_1.comment("END: " + name + ".")
ast_1.comment("[End] " + name + ".")
]);

@@ -189,0 +202,0 @@ return printExpr(wrappedExpr);

{
"name": "graphql-mapping-template",
"version": "1.1.0-alpha.0fe7fa01",
"version": "1.1.0-alpha.114e0b6e",
"description": "An AST wrapper around AWS AppSync resolvers",

@@ -8,2 +8,3 @@ "main": "lib/index.js",

"test": "jest",
"test-ci": "jest --ci -i",
"build": "tsc",

@@ -10,0 +11,0 @@ "clean": "rm -rf ./lib"

@@ -114,2 +114,16 @@ /**

/**
* Compares two expressions for unequality.
*/
export interface NotNode {
kind: 'Not';
expr: Expression;
}
export function not(expr: Expression): NotNode {
return {
kind: 'Not',
expr,
}
}
/**
* Iterates through a collection.

@@ -341,2 +355,19 @@ */

export type NewLineNode = {
kind: 'NewLine'
}
export function newline(): NewLineNode {
return {
kind: 'NewLine',
}
}
export function block(name: string, exprs: Expression[]): CompoundExpressionNode {
return compoundExpression([
comment(`[Start] ${name}`),
...exprs,
comment(`[End] ${name}`)
])
}
/**

@@ -368,2 +399,4 @@ * A flow expression is one that dictates program flow e.g. if, ifelse, for, while, etc.

| CompoundExpressionNode
| ToJsonNode;
| ToJsonNode
| NotNode
| NewLineNode;

@@ -6,3 +6,3 @@ import {

ObjectNode, ListNode, FloatNode, QuotesNode, RawNode, SetNode, CompoundExpressionNode,
CommentNode, ToJsonNode, BooleanNode, compoundExpression, comment
CommentNode, ToJsonNode, BooleanNode, compoundExpression, comment, NotNode, NewLineNode
} from './ast';

@@ -14,5 +14,5 @@

if (node.inline) {
return `#if( ${printExpr(node.predicate)} ) ${printExpr(node.expr)} #end`;
return `#if( ${printExpr(node.predicate, '')} ) ${printExpr(node.expr, '')} #end`;
}
return `${indent}#if( ${printExpr(node.predicate)} )\n${printExpr(node.expr, indent + TAB)}\n${indent}#end`;
return `${indent}#if( ${printExpr(node.predicate, '')} )\n${printExpr(node.expr, indent + TAB)}\n${indent}#end`;
}

@@ -29,5 +29,5 @@

return `${indent}#if( ${printExpr(node.predicate)} )\n` +
`${indent}${TAB}${printExpr(node.ifExpr)}\n` +
`${printExpr(node.ifExpr, indent + TAB)}\n` +
`${indent}#else\n` +
`${indent}${TAB}${printExpr(node.elseExpr)}\n` +
`${printExpr(node.elseExpr, indent + TAB)}\n` +
`${indent}#end`;

@@ -70,4 +70,4 @@ }

function printRaw(node: RawNode): string {
return `${node.value}`;
function printRaw(node: RawNode, indent: string = ''): string {
return `${indent}${node.value}`;
}

@@ -95,4 +95,4 @@

function printQuietReference(node: QuietReferenceNode): string {
return `$util.qr(${node.value})`;
function printQuietReference(node: QuietReferenceNode, indent: string = ''): string {
return `${indent}$util.qr(${node.value})`;
}

@@ -109,3 +109,3 @@

function printList(node: ListNode, indent: string = ''): string {
const values = node.expressions.map((e: Expression) => printExpr(e, indent)).join(', ');
const values = node.expressions.map((e: Expression) => printExpr(e, '')).join(', ');
return `${indent}[${values}]`;

@@ -115,3 +115,3 @@ }

function printSet(node: SetNode, indent: string = ''): string {
return `${indent}#set( ${printReference(node.key)} = ${printExpr(node.value)} )`
return `${indent}#set( ${printReference(node.key)} = ${printExpr(node.value, '')} )`
}

@@ -124,3 +124,3 @@

function printCompoundExpression(node: CompoundExpressionNode, indent: string = ''): string {
return node.expressions.map((node: Expression) => indent + printExpr(node, indent)).join(`\n${indent}`)
return node.expressions.map((node: Expression) => printExpr(node, indent)).join(`\n`)
}

@@ -132,2 +132,10 @@

function printNot(node: NotNode, indent: string = ''): string {
return `${indent}!${printExpr(node.expr, '')}`
}
function printNewLine(node: NewLineNode): string {
return '\n'
}
function printExpr(expr: Expression, indent: string = ''): string {

@@ -155,3 +163,3 @@ if (!expr) { return ''; }

case 'Raw':
return printRaw(expr);
return printRaw(expr, indent);
case 'Quotes':

@@ -170,3 +178,3 @@ return printQuotes(expr);

case 'QuietReference':
return printQuietReference(expr);
return printQuietReference(expr, indent);
case 'Object':

@@ -184,2 +192,6 @@ return printObject(expr, indent);

return printToJson(expr, indent)
case 'Not':
return printNot(expr, indent)
case 'NewLine':
return printNewLine(expr)
default:

@@ -197,5 +209,5 @@ return '';

const wrappedExpr = compoundExpression([
comment(`START: ${name}.`),
comment(`[Start] ${name}.`),
expr,
comment(`END: ${name}.`)
comment(`[End] ${name}.`)
])

@@ -202,0 +214,0 @@ return printExpr(wrappedExpr);

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