UNPKG

@eastsideco/escshopify

Version:

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

1,407 lines (1,406 loc) 222 kB
{ "type": "File", "start": 0, "end": 1903, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 72, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1903, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 72, "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": 84, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 33 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 59, "end": 69, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 18 } }, "imported": { "type": "Identifier", "start": 59, "end": 69, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 18 }, "identifierName": "geoService" }, "name": "geoService" }, "local": { "type": "Identifier", "start": 59, "end": 69, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 18 }, "identifierName": "geoService" }, "name": "geoService" } } ], "source": { "type": "StringLiteral", "start": 76, "end": 83, "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 32 } }, "extra": { "rawValue": "index", "raw": "'index'" }, "value": "index" } }, { "type": "ImportDeclaration", "start": 85, "end": 140, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 55 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", "start": 92, "end": 107, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 22 } }, "local": { "type": "Identifier", "start": 97, "end": 107, "loc": { "start": { "line": 3, "column": 12 }, "end": { "line": 3, "column": 22 }, "identifierName": "currencies" }, "name": "currencies" } } ], "source": { "type": "StringLiteral", "start": 113, "end": 139, "loc": { "start": { "line": 3, "column": 28 }, "end": { "line": 3, "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": 142, "end": 215, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 8, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 216, "end": 1902, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 71, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 231, "end": 1902, "loc": { "start": { "line": 9, "column": 15 }, "end": { "line": 71, "column": 1 } }, "id": { "type": "Identifier", "start": 237, "end": 255, "loc": { "start": { "line": 9, "column": 21 }, "end": { "line": 9, "column": 39 }, "identifierName": "GeoserviceResolver" }, "name": "GeoserviceResolver", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 264, "end": 280, "loc": { "start": { "line": 9, "column": 48 }, "end": { "line": 9, "column": 64 }, "identifierName": "CurrencyResolver" }, "name": "CurrencyResolver" }, "body": { "type": "ClassBody", "start": 281, "end": 1902, "loc": { "start": { "line": 9, "column": 65 }, "end": { "line": 71, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 353, "end": 594, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 22, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 353, "end": 364, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 367, "end": 594, "loc": { "start": { "line": 13, "column": 18 }, "end": { "line": 22, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 377, "end": 385, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 16 } }, "expression": { "type": "CallExpression", "start": 377, "end": 384, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 15 } }, "callee": { "type": "Super", "start": 377, "end": 382, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 13 } } }, "arguments": [] }, "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Object} ", "start": 395, "end": 416, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 29 } } } ] }, { "type": "ExpressionStatement", "start": 425, "end": 444, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 27 } }, "expression": { "type": "AssignmentExpression", "start": 425, "end": 443, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 26 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 425, "end": 436, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 19 } }, "object": { "type": "ThisExpression", "start": 425, "end": 429, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 430, "end": 436, "loc": { "start": { "line": 17, "column": 13 }, "end": { "line": 17, "column": 19 }, "identifierName": "_rates" }, "name": "_rates" }, "computed": false, "leadingComments": null }, "right": { "type": "NullLiteral", "start": 439, "end": 443, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 26 } } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Object} ", "start": 395, "end": 416, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 29 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 453, "end": 475, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 30 } } } ] }, { "type": "ExpressionStatement", "start": 484, "end": 508, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 32 } }, "expression": { "type": "AssignmentExpression", "start": 484, "end": 507, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 31 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 484, "end": 499, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 23 } }, "object": { "type": "ThisExpression", "start": 484, "end": 488, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 489, "end": 499, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 23 }, "identifierName": "_requested" }, "name": "_requested" }, "computed": false, "leadingComments": null }, "right": { "type": "BooleanLiteral", "start": 502, "end": 507, "loc": { "start": { "line": 19, "column": 26 }, "end": { "line": 19, "column": 31 } }, "value": false }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 453, "end": 475, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 30 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Promise<Object, Error} ", "start": 517, "end": 553, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 44 } } } ] }, { "type": "ExpressionStatement", "start": 562, "end": 588, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 562, "end": 587, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 33 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 562, "end": 580, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 26 } }, "object": { "type": "ThisExpression", "start": 562, "end": 566, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 567, "end": 580, "loc": { "start": { "line": 21, "column": 13 }, "end": { "line": 21, "column": 26 }, "identifierName": "_ratesPromise" }, "name": "_ratesPromise" }, "computed": false, "leadingComments": null }, "right": { "type": "NullLiteral", "start": 583, "end": 587, "loc": { "start": { "line": 21, "column": 29 }, "end": { "line": 21, "column": 33 } } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Promise<Object, Error} ", "start": 517, "end": 553, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 44 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Create new instance of GeoserviceResolver.\n ", "start": 287, "end": 348, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 12, "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": 601, "end": 727, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 29, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 732, "end": 1110, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 43, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 738, "end": 747, "loc": { "start": { "line": 30, "column": 10 }, "end": { "line": 30, "column": 19 }, "identifierName": "_getRates" }, "name": "_getRates" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": true, "params": [], "body": { "type": "BlockStatement", "start": 750, "end": 1110, "loc": { "start": { "line": 30, "column": 22 }, "end": { "line": 43, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 760, "end": 820, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 33, "column": 9 } }, "test": { "type": "MemberExpression", "start": 764, "end": 775, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 23 } }, "object": { "type": "ThisExpression", "start": 764, "end": 768, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 16 } } }, "property": { "type": "Identifier", "start": 769, "end": 775, "loc": { "start": { "line": 31, "column": 17 }, "end": { "line": 31, "column": 23 }, "identifierName": "_rates" }, "name": "_rates" }, "computed": false }, "consequent": { "type": "BlockStatement", "start": 777, "end": 820, "loc": { "start": { "line": 31, "column": 25 }, "end": { "line": 33, "column": 9 } }, "body": [ { "type": "ReturnStatement", "start": 791, "end": 810, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 31 } }, "argument": { "type": "MemberExpression", "start": 798, "end": 809, "loc": { "start": { "line": 32, "column": 19 }, "end": { "line": 32, "column": 30 } }, "object": { "type": "ThisExpression", "start": 798, "end": 802, "loc": { "start": { "line": 32, "column": 19 }, "end": { "line": 32, "column": 23 } } }, "property": { "type": "Identifier", "start": 803, "end": 809, "loc": { "start": { "line": 32, "column": 24 }, "end": { "line": 32, "column": 30 }, "identifierName": "_rates" }, "name": "_rates" }, "computed": false } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 830, "end": 1063, "loc": { "start": { "line": 35, "column": 8 }, "end": { "line": 41, "column": 9 } }, "test": { "type": "UnaryExpression", "start": 834, "end": 853, "loc": { "start": { "line": 35, "column": 12 }, "end": { "line": 35, "column": 31 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 835, "end": 853, "loc": { "start": { "line": 35, "column": 13 }, "end": { "line": 35, "column": 31 } }, "object": { "type": "ThisExpression", "start": 835, "end": 839, "loc": { "start": { "line": 35, "column": 13 }, "end": { "line": 35, "column": 17 } } }, "property": { "type": "Identifier", "start": 840, "end": 853, "loc": { "start": { "line": 35, "column": 18 }, "end": { "line": 35, "column": 31 }, "identifierName": "_ratesPromise" }, "name": "_ratesPromise" }, "computed": false }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 855, "end": 1063, "loc": { "start": { "line": 35, "column": 33 }, "end": { "line": 41, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 869, "end": 1053, "loc": { "start": { "line": 36, "column": 12 }, "end": { "line": 40, "column": 17 } }, "expression": { "type": "AssignmentExpression", "start": 869, "end": 1052, "loc": { "start": { "line": 36, "column": 12 }, "end": { "line": 40, "column": 16 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 869, "end": 887, "loc": { "start": { "line": 36, "column": 12 }, "end": { "line": 36, "column": 30 } }, "object": { "type": "ThisExpression", "start": 869, "end": 873, "loc": { "start": { "line": 36, "column": 12 }, "end": { "line": 36, "column": 16 } } }, "property": { "type": "Identifier", "start": 874, "end": 887, "loc": { "start": { "line": 36, "column": 17 }, "end": { "line": 36, "column": 30 }, "identifierName": "_ratesPromise" }, "name": "_ratesPromise" }, "computed": false }, "right": { "type": "CallExpression", "start": 890, "end": 1052, "loc": { "start": { "line": 36, "column": 33 }, "end": { "line": 40, "column": 16 } }, "callee": { "type": "ArrowFunctionExpression", "start": 891, "end": 1049, "loc": { "start": { "line": 36, "column": 34 }, "end": { "line": 40, "column": 13 } }, "id": null, "generator": false, "expression": false, "async": true, "params": [], "body": { "type": "BlockStatement", "start": 903, "end": 1049, "loc": { "start": { "line": 36, "column": 46 }, "end": { "line": 40, "column": 13 } }, "body": [ { "type": "VariableDeclaration", "start": 921, "end": 968, "loc": { "start": { "line": 37, "column": 16 }, "end": { "line": 37, "column": 63 } }, "declarations": [ { "type": "VariableDeclarator", "start": 925, "end": 967, "loc": { "start": { "line": 37, "column": 20 }, "end": { "line": 37, "column": 62 } }, "id": { "type": "Identifier", "start": 925, "end": 930, "loc": { "start": { "line": 37, "column": 20 }, "end": { "line": 37, "column": 25 }, "identifierName": "rates" }, "name": "rates" }, "init": { "type": "AwaitExpression", "start": 933, "end": 967, "loc": { "start": { "line": 37, "column": 28 }, "end": { "line": 37, "column": 62 } }, "argument": { "type": "CallExpression", "start": 939, "end": 967, "loc": { "start": { "line": 37, "column": 34 }, "end": { "line": 37, "column": 62 } }, "callee": { "type": "MemberExpression", "start": 939, "end": 965, "loc": { "start": { "line": 37, "column": 34 }, "end": { "line": 37, "column": 60 } }, "object": { "type": "Identifier", "start": 939, "end": 949, "loc": {