UNPKG

@eastsideco/escshopify

Version:

WIP JS library for Shopify, containing a variety of useful functionality.

1,437 lines (1,436 loc) 237 kB
{ "type": "File", "start": 0, "end": 1992, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 75, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1992, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 75, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 50, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 50 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 23, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 23 } }, "local": { "type": "Identifier", "start": 7, "end": 23, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 23 }, "identifierName": "CurrencyResolver" }, "name": "CurrencyResolver" } } ], "source": { "type": "StringLiteral", "start": 29, "end": 49, "loc": { "start": { "line": 1, "column": 29 }, "end": { "line": 1, "column": 49 } }, "extra": { "rawValue": "./CurrencyResolver", "raw": "'./CurrencyResolver'" }, "value": "./CurrencyResolver" } }, { "type": "ImportDeclaration", "start": 51, "end": 108, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 57 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 58, "end": 68, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 17 } }, "local": { "type": "Identifier", "start": 58, "end": 68, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 17 }, "identifierName": "GeoService" }, "name": "GeoService" } } ], "source": { "type": "StringLiteral", "start": 74, "end": 107, "loc": { "start": { "line": 2, "column": 23 }, "end": { "line": 2, "column": 56 } }, "extra": { "rawValue": "~/plugins/geoservice/GeoService", "raw": "'~/plugins/geoservice/GeoService'" }, "value": "~/plugins/geoservice/GeoService" } }, { "type": "ImportDeclaration", "start": 110, "end": 165, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 55 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", "start": 117, "end": 132, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 22 } }, "local": { "type": "Identifier", "start": 122, "end": 132, "loc": { "start": { "line": 4, "column": 12 }, "end": { "line": 4, "column": 22 }, "identifierName": "currencies" }, "name": "currencies" } } ], "source": { "type": "StringLiteral", "start": 138, "end": 164, "loc": { "start": { "line": 4, "column": 28 }, "end": { "line": 4, "column": 54 } }, "extra": { "rawValue": "js-money/lib/currency.js", "raw": "'js-money/lib/currency.js'" }, "value": "js-money/lib/currency.js" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Gets currency information from the ESC Geoservice.\n * @private\n ", "start": 167, "end": 240, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 9, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 241, "end": 1991, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 74, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 256, "end": 1991, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 74, "column": 1 } }, "id": { "type": "Identifier", "start": 262, "end": 280, "loc": { "start": { "line": 10, "column": 21 }, "end": { "line": 10, "column": 39 }, "identifierName": "GeoserviceResolver" }, "name": "GeoserviceResolver", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 289, "end": 305, "loc": { "start": { "line": 10, "column": 48 }, "end": { "line": 10, "column": 64 }, "identifierName": "CurrencyResolver" }, "name": "CurrencyResolver" }, "body": { "type": "ClassBody", "start": 306, "end": 1991, "loc": { "start": { "line": 10, "column": 65 }, "end": { "line": 74, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 378, "end": 663, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 25, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 378, "end": 389, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 392, "end": 663, "loc": { "start": { "line": 14, "column": 18 }, "end": { "line": 25, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 402, "end": 410, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 16 } }, "expression": { "type": "CallExpression", "start": 402, "end": 409, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 15 } }, "callee": { "type": "Super", "start": 402, "end": 407, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 13 } } }, "arguments": [] }, "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Object} ", "start": 420, "end": 441, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 29 } } } ] }, { "type": "ExpressionStatement", "start": 450, "end": 469, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 27 } }, "expression": { "type": "AssignmentExpression", "start": 450, "end": 468, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 26 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 450, "end": 461, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 19 } }, "object": { "type": "ThisExpression", "start": 450, "end": 454, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 455, "end": 461, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 19 }, "identifierName": "_rates" }, "name": "_rates" }, "computed": false, "leadingComments": null }, "right": { "type": "NullLiteral", "start": 464, "end": 468, "loc": { "start": { "line": 18, "column": 22 }, "end": { "line": 18, "column": 26 } } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Object} ", "start": 420, "end": 441, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 29 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 478, "end": 500, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 30 } } } ] }, { "type": "ExpressionStatement", "start": 509, "end": 533, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 32 } }, "expression": { "type": "AssignmentExpression", "start": 509, "end": 532, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 31 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 509, "end": 524, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 23 } }, "object": { "type": "ThisExpression", "start": 509, "end": 513, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 514, "end": 524, "loc": { "start": { "line": 20, "column": 13 }, "end": { "line": 20, "column": 23 }, "identifierName": "_requested" }, "name": "_requested" }, "computed": false, "leadingComments": null }, "right": { "type": "BooleanLiteral", "start": 527, "end": 532, "loc": { "start": { "line": 20, "column": 26 }, "end": { "line": 20, "column": 31 } }, "value": false }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 478, "end": 500, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 30 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Promise<Object, Error} ", "start": 542, "end": 578, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 44 } } } ] }, { "type": "ExpressionStatement", "start": 587, "end": 613, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 587, "end": 612, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 33 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 587, "end": 605, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 26 } }, "object": { "type": "ThisExpression", "start": 587, "end": 591, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 592, "end": 605, "loc": { "start": { "line": 22, "column": 13 }, "end": { "line": 22, "column": 26 }, "identifierName": "_ratesPromise" }, "name": "_ratesPromise" }, "computed": false, "leadingComments": null }, "right": { "type": "NullLiteral", "start": 608, "end": 612, "loc": { "start": { "line": 22, "column": 29 }, "end": { "line": 22, "column": 33 } } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Promise<Object, Error} ", "start": 542, "end": 578, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 44 } } } ] }, { "type": "ExpressionStatement", "start": 623, "end": 657, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 42 } }, "expression": { "type": "AssignmentExpression", "start": 623, "end": 656, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 41 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 623, "end": 639, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 24 } }, "object": { "type": "ThisExpression", "start": 623, "end": 627, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 12 } } }, "property": { "type": "Identifier", "start": 628, "end": 639, "loc": { "start": { "line": 24, "column": 13 }, "end": { "line": 24, "column": 24 }, "identifierName": "_geoService" }, "name": "_geoService" }, "computed": false }, "right": { "type": "NewExpression", "start": 642, "end": 656, "loc": { "start": { "line": 24, "column": 27 }, "end": { "line": 24, "column": 41 } }, "callee": { "type": "Identifier", "start": 646, "end": 656, "loc": { "start": { "line": 24, "column": 31 }, "end": { "line": 24, "column": 41 }, "identifierName": "GeoService" }, "name": "GeoService" }, "arguments": [] } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Create new instance of GeoserviceResolver.\n ", "start": 312, "end": 373, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 13, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Retrieves rates from the server.\n * Rates are cached in memory.\n * @return {Promise<Object, Error>}\n ", "start": 670, "end": 796, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 32, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 801, "end": 1185, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 46, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 807, "end": 816, "loc": { "start": { "line": 33, "column": 10 }, "end": { "line": 33, "column": 19 }, "identifierName": "_getRates" }, "name": "_getRates" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": true, "params": [], "body": { "type": "BlockStatement", "start": 819, "end": 1185, "loc": { "start": { "line": 33, "column": 22 }, "end": { "line": 46, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 829, "end": 889, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 36, "column": 9 } }, "test": { "type": "MemberExpression", "start": 833, "end": 844, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 23 } }, "object": { "type": "ThisExpression", "start": 833, "end": 837, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 16 } } }, "property": { "type": "Identifier", "start": 838, "end": 844, "loc": { "start": { "line": 34, "column": 17 }, "end": { "line": 34, "column": 23 }, "identifierName": "_rates" }, "name": "_rates" }, "computed": false }, "consequent": { "type": "BlockStatement", "start": 846, "end": 889, "loc": { "start": { "line": 34, "column": 25 }, "end": { "line": 36, "column": 9 } }, "body": [ { "type": "ReturnStatement", "start": 860, "end": 879, "loc": { "start": { "line": 35, "column": 12 }, "end": { "line": 35, "column": 31 } }, "argument": { "type": "MemberExpression", "start": 867, "end": 878, "loc": { "start": { "line": 35, "column": 19 }, "end": { "line": 35, "column": 30 } }, "object": { "type": "ThisExpression", "start": 867, "end": 871, "loc": { "start": { "line": 35, "column": 19 }, "end": { "line": 35, "column": 23 } } }, "property": { "type": "Identifier", "start": 872, "end": 878, "loc": { "start": { "line": 35, "column": 24 }, "end": { "line": 35, "column": 30 }, "identifierName": "_rates" }, "name": "_rates" }, "computed": false } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 899, "end": 1138, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 44, "column": 9 } }, "test": { "type": "UnaryExpression", "start": 903, "end": 922, "loc": { "start": { "line": 38, "column": 12 }, "end": { "line": 38, "column": 31 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 904, "end": 922, "loc": { "start": { "line": 38, "column": 13 }, "end": { "line": 38, "column": 31 } }, "object": { "type": "ThisExpression", "start": 904, "end": 908, "loc": { "start": { "line": 38, "column": 13 }, "end": { "line": 38, "column": 17 } } }, "property": { "type": "Identifier", "start": 909, "end": 922, "loc": { "start": { "line": 38, "column": 18 }, "end": { "line": 38, "column": 31 }, "identifierName": "_ratesPromise" }, "name": "_ratesPromise" }, "computed": false }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 924, "end": 1138, "loc": { "start": { "line": 38, "column": 33 }, "end": { "line": 44, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 938, "end": 1128, "loc": { "start": { "line": 39, "column": 12 }, "end": { "line": 43, "column": 17 } }, "expression": { "type": "AssignmentExpression", "start": 938, "end": 1127, "loc": { "start": { "line": 39, "column": 12 }, "end": { "line": 43, "column": 16 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 938, "end": 956, "loc": { "start": { "line": 39, "column": 12 }, "end": { "line": 39, "column": 30 } }, "object": { "type": "ThisExpression", "start": 938, "end": 942, "loc": { "start": { "line": 39, "column": 12 }, "end": { "line": 39, "column": 16 } } }, "property": { "type": "Identifier", "start": 943, "end": 956, "loc": { "start": { "line": 39, "column": 17 }, "end": { "line": 39, "column": 30 }, "identifierName": "_ratesPromise" }, "name": "_ratesPromise" }, "computed": false }, "right": { "type": "CallExpression", "start": 959, "end": 1127, "loc": { "start": { "line": 39, "column": 33 }, "end": { "line": 43, "column": 16 } }, "callee": { "type": "ArrowFunctionExpression", "start": 960, "end": 1124, "loc": { "start": { "line": 39, "column": 34 }, "end": { "line": 43, "column": 13 } }, "id": null, "generator": false, "expression": false, "async": true, "params": [], "body": { "type": "BlockStatement", "start": 972, "end": 1124, "loc": { "start": { "line": 39, "column": 46 }, "end": { "line": 43, "column": 13 } }, "body": [ { "type": "VariableDeclaration", "start": 990, "end": 1043, "loc": { "start": { "line": 40, "column": 16 }, "end": { "line": 40, "column": 69 } }, "declarations": [ { "type": "VariableDeclarator", "start": 994, "end": 1042, "loc": { "start": { "line": 40, "column": 20 }, "end": { "line": 40, "column": 68 }