UNPKG

@eastsideco/escshopify

Version:

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

1,420 lines (1,419 loc) 173 kB
{ "type": "File", "start": 0, "end": 3130, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 138, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 3130, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 138, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 24, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 24 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 11, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 11 } }, "local": { "type": "Identifier", "start": 7, "end": 11, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 11 }, "identifierName": "Evee" }, "name": "Evee" } } ], "source": { "type": "StringLiteral", "start": 17, "end": 23, "loc": { "start": { "line": 1, "column": 17 }, "end": { "line": 1, "column": 23 } }, "extra": { "rawValue": "evee", "raw": "'evee'" }, "value": "evee" } }, { "type": "ImportDeclaration", "start": 25, "end": 49, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 24 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 32, "end": 35, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 10 } }, "local": { "type": "Identifier", "start": 32, "end": 35, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 10 }, "identifierName": "API" }, "name": "API" } } ], "source": { "type": "StringLiteral", "start": 41, "end": 48, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 23 } }, "extra": { "rawValue": "./API", "raw": "'./API'" }, "value": "./API" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @typedef {Object} GSGeoResponse\n * @property {GSContinent} continent\n * @property {GSCountry} country\n * @property {GSLocation} location\n * @property {GSCountry} registered_country\n * @property {String} currency\n ", "start": 51, "end": 273, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 11, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * @typedef {Object} GSTranslatedString\n * @property {String} de\n * @property {String} en\n * @property {String} es\n * @property {String} fr\n * @property {String} ja\n * @property {String} pt-BR\n * @property {String} ru\n * @property {String} zh-CN\n ", "start": 274, "end": 527, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 22, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * @typedef {Object} GSContinent\n * @property {String} code\n * @property {Number} geoname_id\n * @property {GSTranslatedString} names\n ", "start": 528, "end": 668, "loc": { "start": { "line": 23, "column": 0 }, "end": { "line": 28, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * @typedef {Object} GSCountry\n * @property {Number} geoname_id\n * @property {String} iso_code\n * @property {GSTranslatedString} names\n ", "start": 669, "end": 811, "loc": { "start": { "line": 29, "column": 0 }, "end": { "line": 34, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * @typedef {Object} GSLocation\n * @property {Number} accuracy_radius\n * @property {Number} latitude\n * @property {Number} longitude\n ", "start": 812, "end": 952, "loc": { "start": { "line": 35, "column": 0 }, "end": { "line": 40, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * @typedef {Object} GSCurrencyResponse\n * @property {String} base\n * @property {String} date - Update date in Y-M-D format\n * @property {GSCurrencyRates} rates\n ", "start": 954, "end": 1122, "loc": { "start": { "line": 42, "column": 0 }, "end": { "line": 47, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * @typedef {Object} GSCurrencyRates\n * @property {Number} AUD\n * @property {Number} BGN\n * @property {Number} BRL\n * @property {Number} CAD\n * @property {Number} CHF\n * @property {Number} CNY\n * @property {Number} CZK\n * @property {Number} DKK\n * @property {Number} GBP\n * @property {Number} HKD\n * @property {Number} HUF\n * @property {Number} IDR\n * @property {Number} ILD\n * @property {Number} INR\n * @property {Number} JPY\n * @property {Number} KRW\n * @property {Number} MXN\n * @property {Number} MYR\n * @property {Number} NOK\n * @property {Number} NZD\n * @property {Number} PHP\n * @property {Number} PLN\n * @property {Number} RON\n * @property {Number} RUB\n * @property {Number} SEK\n * @property {Number} SGD\n * @property {Number} THB\n * @property {Number} TRY\n * @property {Number} ZAR\n * @property {Number} EUR\n ", "start": 1123, "end": 1947, "loc": { "start": { "line": 48, "column": 0 }, "end": { "line": 80, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * Provides access to the ESC Geoservice.\n ", "start": 1950, "end": 1999, "loc": { "start": { "line": 83, "column": 0 }, "end": { "line": 85, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 2000, "end": 3129, "loc": { "start": { "line": 86, "column": 0 }, "end": { "line": 137, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 2015, "end": 3129, "loc": { "start": { "line": 86, "column": 15 }, "end": { "line": 137, "column": 1 } }, "id": { "type": "Identifier", "start": 2021, "end": 2031, "loc": { "start": { "line": 86, "column": 21 }, "end": { "line": 86, "column": 31 }, "identifierName": "GeoService" }, "name": "GeoService", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 2040, "end": 2044, "loc": { "start": { "line": 86, "column": 40 }, "end": { "line": 86, "column": 44 }, "identifierName": "Evee" }, "name": "Evee" }, "body": { "type": "ClassBody", "start": 2045, "end": 3129, "loc": { "start": { "line": 86, "column": 45 }, "end": { "line": 137, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 2112, "end": 2384, "loc": { "start": { "line": 91, "column": 4 }, "end": { "line": 101, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 2112, "end": 2123, "loc": { "start": { "line": 91, "column": 4 }, "end": { "line": 91, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 2126, "end": 2384, "loc": { "start": { "line": 91, "column": 18 }, "end": { "line": 101, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 2136, "end": 2144, "loc": { "start": { "line": 92, "column": 8 }, "end": { "line": 92, "column": 16 } }, "expression": { "type": "CallExpression", "start": 2136, "end": 2143, "loc": { "start": { "line": 92, "column": 8 }, "end": { "line": 92, "column": 15 } }, "callee": { "type": "Super", "start": 2136, "end": 2141, "loc": { "start": { "line": 92, "column": 8 }, "end": { "line": 92, "column": 13 } } }, "arguments": [] }, "trailingComments": [ { "type": "CommentBlock", "value": "* @type {src/plugins/geoservice/API.js~API} ", "start": 2155, "end": 2203, "loc": { "start": { "line": 95, "column": 8 }, "end": { "line": 95, "column": 56 } } } ] }, { "type": "ExpressionStatement", "start": 2212, "end": 2233, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 29 } }, "expression": { "type": "AssignmentExpression", "start": 2212, "end": 2232, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 28 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2212, "end": 2220, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 16 } }, "object": { "type": "ThisExpression", "start": 2212, "end": 2216, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2217, "end": 2220, "loc": { "start": { "line": 96, "column": 13 }, "end": { "line": 96, "column": 16 }, "identifierName": "api" }, "name": "api" }, "computed": false, "leadingComments": null }, "right": { "type": "NewExpression", "start": 2223, "end": 2232, "loc": { "start": { "line": 96, "column": 19 }, "end": { "line": 96, "column": 28 } }, "callee": { "type": "Identifier", "start": 2227, "end": 2230, "loc": { "start": { "line": 96, "column": 23 }, "end": { "line": 96, "column": 26 }, "identifierName": "API" }, "name": "API" }, "arguments": [] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {src/plugins/geoservice/API.js~API} ", "start": 2155, "end": 2203, "loc": { "start": { "line": 95, "column": 8 }, "end": { "line": 95, "column": 56 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 2242, "end": 2264, "loc": { "start": { "line": 97, "column": 8 }, "end": { "line": 97, "column": 30 } } } ] }, { "type": "ExpressionStatement", "start": 2273, "end": 2298, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 33 } }, "expression": { "type": "AssignmentExpression", "start": 2273, "end": 2297, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 32 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2273, "end": 2290, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 25 } }, "object": { "type": "ThisExpression", "start": 2273, "end": 2277, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2278, "end": 2290, "loc": { "start": { "line": 98, "column": 13 }, "end": { "line": 98, "column": 25 }, "identifierName": "cacheLookups" }, "name": "cacheLookups" }, "computed": false, "leadingComments": null }, "right": { "type": "BooleanLiteral", "start": 2293, "end": 2297, "loc": { "start": { "line": 98, "column": 28 }, "end": { "line": 98, "column": 32 } }, "value": true }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 2242, "end": 2264, "loc": { "start": { "line": 97, "column": 8 }, "end": { "line": 97, "column": 30 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Object<String, Object>} ", "start": 2307, "end": 2344, "loc": { "start": { "line": 99, "column": 8 }, "end": { "line": 99, "column": 45 } } } ] }, { "type": "ExpressionStatement", "start": 2353, "end": 2378, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 33 } }, "expression": { "type": "AssignmentExpression", "start": 2353, "end": 2377, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 32 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2353, "end": 2372, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 27 } }, "object": { "type": "ThisExpression", "start": 2353, "end": 2357, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2358, "end": 2372, "loc": { "start": { "line": 100, "column": 13 }, "end": { "line": 100, "column": 27 }, "identifierName": "_cachedLookups" }, "name": "_cachedLookups" }, "computed": false, "leadingComments": null }, "right": { "type": "ObjectExpression", "start": 2375, "end": 2377, "loc": { "start": { "line": 100, "column": 30 }, "end": { "line": 100, "column": 32 } }, "properties": [] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Object<String, Object>} ", "start": 2307, "end": 2344, "loc": { "start": { "line": 99, "column": 8 }, "end": { "line": 99, "column": 45 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Create a new instance of GeoService.\n ", "start": 2052, "end": 2107, "loc": { "start": { "line": 88, "column": 4 }, "end": { "line": 90, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Retrieves geolocation information.\n * @param {String}\t[ip] - IP address to get information on. If not supplied, uses local IP.\n * @return {Promise<GSGeoResponse|Error>}\n ", "start": 2391, "end": 2586, "loc": { "start": { "line": 104, "column": 4 }, "end": { "line": 108, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 2591, "end": 2943, "loc": { "start": { "line": 109, "column": 4 }, "end": { "line": 123, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 2597, "end": 2606, "loc": { "start": { "line": 109, "column": 10 }, "end": { "line": 109, "column": 19 }, "identifierName": "lookupGeo" }, "name": "lookupGeo" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": true, "params": [ { "type": "Identifier", "start": 2607, "end": 2609, "loc": { "start": { "line": 109, "column": 20 }, "end": { "line": 109, "column": 22 }, "identifierName": "ip" }, "name": "ip" } ], "body": { "type": "BlockStatement", "start": 2611, "end": 2943, "loc": { "start": { "line": 109, "column": 24 }, "end": { "line": 123, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 2621, "end": 2662, "loc": { "start": { "line": 110, "column": 8 }, "end": { "line": 112, "column": 9 } }, "test": { "type": "UnaryExpression", "start": 2625, "end": 2628, "loc": { "start": { "line": 110, "column": 12 }, "end": { "line": 110, "column": 15 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 2626, "end": 2628, "loc": { "start": { "line": 110, "column": 13 }, "end": { "line": 110, "column": 15 }, "identifierName": "ip" }, "name": "ip" }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 2630, "end": 2662, "loc": { "start": { "line": 110, "column": 17 }, "end": { "line": 112, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 2644, "end": 2652, "loc": { "start": { "line": 111, "column": 12 }, "end": { "line": 111, "column": 20 } }, "expression": { "type": "AssignmentExpression", "start": 2644, "end": 2651, "loc": { "start": { "line": 111, "column": 12 }, "end": { "line": 111, "column": 19 } }, "operator": "=", "left": { "type": "Identifier", "start": 2644, "end": 2646, "loc": { "start": { "line": 111, "column": 12 }, "end": { "line": 111, "column": 14 }, "identifierName": "ip" }, "name": "ip" }, "right": { "type": "StringLiteral", "start": 2649, "end": 2651, "loc": { "start": { "line": 111, "column": 17 }, "end": { "line": 111, "column": 19 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 2672, "end": 2777, "loc": { "start": { "line": 114, "column": 8 }, "end": { "line": 116, "column": 9 } }, "test": { "type": "LogicalExpression", "start": 2676, "end": 2720, "loc": { "start": { "line": 114, "column": 12 }, "end": { "line": 114, "column": 56 } }, "left": { "type": "MemberExpression", "start": 2676, "end": 2693, "loc": { "start": { "line": 114, "column": 12 }, "end": { "line": 114, "column": 29 } }, "object": { "type": "ThisExpression", "start": 2676, "end": 2680, "loc": { "start": { "line": 114, "column": 12 }, "end": { "line": 114, "column": 16 } } }, "property": { "type": "Identifier", "start": 2681, "end": 2693, "loc": { "start": { "line": 114, "column": 17 }, "end": { "line": 114, "column": 29 }, "identifierName": "cacheLookups" }, "name": "cacheLookups" }, "computed": false }, "operator": "&&", "right": { "type": "MemberExpression", "start": 2697, "end": 2720, "loc": { "start": { "line": 114, "column": 33 }, "end": { "line": 114, "column": 56 } }, "object": { "type": "MemberExpression", "start": 2697, "end": 2716, "loc": { "start": { "line": 114, "column": 33 }, "end": { "line": 114, "column": 52 } }, "object": { "type": "ThisExpression", "start": 2697, "end": 2701, "loc": { "start": { "line": 114, "column": 33 }, "end": { "line": 114, "column": 37 } } }, "property": { "type": "Identifier", "start": 2702, "end": 2716, "loc": { "start": { "line": 114, "column": 38 }, "end": { "line": 114, "column": 52 }, "identifierName": "_cachedLookups" }, "name": "_cachedLookups" }, "computed": false }, "property": { "type": "Identifier", "start": 2717, "end": 2719, "loc": { "start": { "line": 114, "column": 53 }, "end": { "line": 114, "column": 55 }, "identifierName": "ip" }, "name": "ip" }, "computed": true } }, "consequent": { "type": "BlockStatement", "start": 2722, "end": 2777, "loc": { "start": { "line": 114, "column": 58 }, "end": { "line": 116, "column": 9 } }, "body": [ { "type": "ReturnStatement", "start": 2736, "end": 2767, "loc": { "start": { "line": 115, "column": 12 }, "end": { "line": 115, "column": 43 } }, "argument": { "type": "MemberExpression", "start": 2743, "end": 2766, "loc": { "start": { "line": 115, "column": 19 }, "end": { "line": 115, "column": 42 } }, "object": { "type": "MemberExpression", "start": 2743, "end": 2762, "loc": { "start": { "line": 115, "column": 19 }, "end": { "line": 115, "column": 38 } }, "object": { "type": "ThisExpression", "start": 2743, "end": 2747, "loc": { "start": { "line": 115, "column": 19 }, "end": { "line": 115, "column": 23 } } }, "property": { "type": "Identifier", "start": 2748, "end": 2762, "loc": { "start": { "line": 115, "column": 24 }, "end": { "line": 115, "column": 38 }, "identifierName": "_cachedLookups" }, "name": "_cachedLookups" }, "computed": false }, "property": { "type": "Identifier", "start": 2763, "end": 2765, "loc": { "start": { "line": 115, "column": 39 }, "end": { "line": 115, "column": 41 }, "identifierName": "ip" }, "name": "ip" }, "computed": true } } ],