UNPKG

@eastsideco/escshopify

Version:

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

1,420 lines 173 kB
{ "type": "File", "start": 0, "end": 3122, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 138, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 3122, "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": 3121, "loc": { "start": { "line": 86, "column": 0 }, "end": { "line": 137, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 2015, "end": 3121, "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": 3121, "loc": { "start": { "line": 86, "column": 45 }, "end": { "line": 137, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 2112, "end": 2376, "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": 2376, "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/geoservice/API.js~API} ", "start": 2155, "end": 2195, "loc": { "start": { "line": 95, "column": 8 }, "end": { "line": 95, "column": 48 } } } ] }, { "type": "ExpressionStatement", "start": 2204, "end": 2225, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 29 } }, "expression": { "type": "AssignmentExpression", "start": 2204, "end": 2224, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 28 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2204, "end": 2212, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 16 } }, "object": { "type": "ThisExpression", "start": 2204, "end": 2208, "loc": { "start": { "line": 96, "column": 8 }, "end": { "line": 96, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2209, "end": 2212, "loc": { "start": { "line": 96, "column": 13 }, "end": { "line": 96, "column": 16 }, "identifierName": "api" }, "name": "api" }, "computed": false, "leadingComments": null }, "right": { "type": "NewExpression", "start": 2215, "end": 2224, "loc": { "start": { "line": 96, "column": 19 }, "end": { "line": 96, "column": 28 } }, "callee": { "type": "Identifier", "start": 2219, "end": 2222, "loc": { "start": { "line": 96, "column": 23 }, "end": { "line": 96, "column": 26 }, "identifierName": "API" }, "name": "API" }, "arguments": [] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {src/geoservice/API.js~API} ", "start": 2155, "end": 2195, "loc": { "start": { "line": 95, "column": 8 }, "end": { "line": 95, "column": 48 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 2234, "end": 2256, "loc": { "start": { "line": 97, "column": 8 }, "end": { "line": 97, "column": 30 } } } ] }, { "type": "ExpressionStatement", "start": 2265, "end": 2290, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 33 } }, "expression": { "type": "AssignmentExpression", "start": 2265, "end": 2289, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 32 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2265, "end": 2282, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 25 } }, "object": { "type": "ThisExpression", "start": 2265, "end": 2269, "loc": { "start": { "line": 98, "column": 8 }, "end": { "line": 98, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2270, "end": 2282, "loc": { "start": { "line": 98, "column": 13 }, "end": { "line": 98, "column": 25 }, "identifierName": "cacheLookups" }, "name": "cacheLookups" }, "computed": false, "leadingComments": null }, "right": { "type": "BooleanLiteral", "start": 2285, "end": 2289, "loc": { "start": { "line": 98, "column": 28 }, "end": { "line": 98, "column": 32 } }, "value": true }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Boolean} ", "start": 2234, "end": 2256, "loc": { "start": { "line": 97, "column": 8 }, "end": { "line": 97, "column": 30 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Object<String, Object>} ", "start": 2299, "end": 2336, "loc": { "start": { "line": 99, "column": 8 }, "end": { "line": 99, "column": 45 } } } ] }, { "type": "ExpressionStatement", "start": 2345, "end": 2370, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 33 } }, "expression": { "type": "AssignmentExpression", "start": 2345, "end": 2369, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 32 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2345, "end": 2364, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 27 } }, "object": { "type": "ThisExpression", "start": 2345, "end": 2349, "loc": { "start": { "line": 100, "column": 8 }, "end": { "line": 100, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2350, "end": 2364, "loc": { "start": { "line": 100, "column": 13 }, "end": { "line": 100, "column": 27 }, "identifierName": "_cachedLookups" }, "name": "_cachedLookups" }, "computed": false, "leadingComments": null }, "right": { "type": "ObjectExpression", "start": 2367, "end": 2369, "loc": { "start": { "line": 100, "column": 30 }, "end": { "line": 100, "column": 32 } }, "properties": [] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Object<String, Object>} ", "start": 2299, "end": 2336, "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": 2383, "end": 2578, "loc": { "start": { "line": 104, "column": 4 }, "end": { "line": 108, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 2583, "end": 2935, "loc": { "start": { "line": 109, "column": 4 }, "end": { "line": 123, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 2589, "end": 2598, "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": 2599, "end": 2601, "loc": { "start": { "line": 109, "column": 20 }, "end": { "line": 109, "column": 22 }, "identifierName": "ip" }, "name": "ip" } ], "body": { "type": "BlockStatement", "start": 2603, "end": 2935, "loc": { "start": { "line": 109, "column": 24 }, "end": { "line": 123, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 2613, "end": 2654, "loc": { "start": { "line": 110, "column": 8 }, "end": { "line": 112, "column": 9 } }, "test": { "type": "UnaryExpression", "start": 2617, "end": 2620, "loc": { "start": { "line": 110, "column": 12 }, "end": { "line": 110, "column": 15 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 2618, "end": 2620, "loc": { "start": { "line": 110, "column": 13 }, "end": { "line": 110, "column": 15 }, "identifierName": "ip" }, "name": "ip" }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 2622, "end": 2654, "loc": { "start": { "line": 110, "column": 17 }, "end": { "line": 112, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 2636, "end": 2644, "loc": { "start": { "line": 111, "column": 12 }, "end": { "line": 111, "column": 20 } }, "expression": { "type": "AssignmentExpression", "start": 2636, "end": 2643, "loc": { "start": { "line": 111, "column": 12 }, "end": { "line": 111, "column": 19 } }, "operator": "=", "left": { "type": "Identifier", "start": 2636, "end": 2638, "loc": { "start": { "line": 111, "column": 12 }, "end": { "line": 111, "column": 14 }, "identifierName": "ip" }, "name": "ip" }, "right": { "type": "StringLiteral", "start": 2641, "end": 2643, "loc": { "start": { "line": 111, "column": 17 }, "end": { "line": 111, "column": 19 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 2664, "end": 2769, "loc": { "start": { "line": 114, "column": 8 }, "end": { "line": 116, "column": 9 } }, "test": { "type": "LogicalExpression", "start": 2668, "end": 2712, "loc": { "start": { "line": 114, "column": 12 }, "end": { "line": 114, "column": 56 } }, "left": { "type": "MemberExpression", "start": 2668, "end": 2685, "loc": { "start": { "line": 114, "column": 12 }, "end": { "line": 114, "column": 29 } }, "object": { "type": "ThisExpression", "start": 2668, "end": 2672, "loc": { "start": { "line": 114, "column": 12 }, "end": { "line": 114, "column": 16 } } }, "property": { "type": "Identifier", "start": 2673, "end": 2685, "loc": { "start": { "line": 114, "column": 17 }, "end": { "line": 114, "column": 29 }, "identifierName": "cacheLookups" }, "name": "cacheLookups" }, "computed": false }, "operator": "&&", "right": { "type": "MemberExpression", "start": 2689, "end": 2712, "loc": { "start": { "line": 114, "column": 33 }, "end": { "line": 114, "column": 56 } }, "object": { "type": "MemberExpression", "start": 2689, "end": 2708, "loc": { "start": { "line": 114, "column": 33 }, "end": { "line": 114, "column": 52 } }, "object": { "type": "ThisExpression", "start": 2689, "end": 2693, "loc": { "start": { "line": 114, "column": 33 }, "end": { "line": 114, "column": 37 } } }, "property": { "type": "Identifier", "start": 2694, "end": 2708, "loc": { "start": { "line": 114, "column": 38 }, "end": { "line": 114, "column": 52 }, "identifierName": "_cachedLookups" }, "name": "_cachedLookups" }, "computed": false }, "property": { "type": "Identifier", "start": 2709, "end": 2711, "loc": { "start": { "line": 114, "column": 53 }, "end": { "line": 114, "column": 55 }, "identifierName": "ip" }, "name": "ip" }, "computed": true } }, "consequent": { "type": "BlockStatement", "start": 2714, "end": 2769, "loc": { "start": { "line": 114, "column": 58 }, "end": { "line": 116, "column": 9 } }, "body": [ { "type": "ReturnStatement", "start": 2728, "end": 2759, "loc": { "start": { "line": 115, "column": 12 }, "end": { "line": 115, "column": 43 } }, "argument": { "type": "MemberExpression", "start": 2735, "end": 2758, "loc": { "start": { "line": 115, "column": 19 }, "end": { "line": 115, "column": 42 } }, "object": { "type": "MemberExpression", "start": 2735, "end": 2754, "loc": { "start": { "line": 115, "column": 19 }, "end": { "line": 115, "column": 38 } }, "object": { "type": "ThisExpression", "start": 2735, "end": 2739, "loc": { "start": { "line": 115, "column": 19 }, "end": { "line": 115, "column": 23 } } }, "property": { "type": "Identifier", "start": 2740, "end": 2754, "loc": { "start": { "line": 115, "column": 24 }, "end": { "line": 115, "column": 38 }, "identifierName": "_cachedLookups" }, "name": "_cachedLookups" }, "computed": false }, "property": { "type": "Identifier", "start": 2755, "end": 2757, "loc": { "start": { "line": 115, "column": 39 }, "end": { "line": 115, "column": 41 }, "identifierName": "ip" }, "name": "ip" }, "computed": true } } ], "direct