UNPKG

@eastsideco/escshopify

Version:

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

1,597 lines (1,596 loc) 1.24 MB
{ "type": "File", "start": 0, "end": 8629, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 340, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 8629, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 340, "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": 59, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 34 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 32, "end": 37, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 12 } }, "local": { "type": "Identifier", "start": 32, "end": 37, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 12 }, "identifierName": "Queue" }, "name": "Queue" } } ], "source": { "type": "StringLiteral", "start": 43, "end": 58, "loc": { "start": { "line": 2, "column": 18 }, "end": { "line": 2, "column": 33 } }, "extra": { "rawValue": "promise-queue", "raw": "'promise-queue'" }, "value": "promise-queue" } }, { "type": "ImportDeclaration", "start": 60, "end": 95, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 35 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 67, "end": 76, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 16 } }, "local": { "type": "Identifier", "start": 67, "end": 76, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 16 }, "identifierName": "deepEqual" }, "name": "deepEqual" } } ], "source": { "type": "StringLiteral", "start": 82, "end": 94, "loc": { "start": { "line": 3, "column": 22 }, "end": { "line": 3, "column": 34 } }, "extra": { "rawValue": "deep-equal", "raw": "'deep-equal'" }, "value": "deep-equal" } }, { "type": "ImportDeclaration", "start": 96, "end": 119, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 23 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 103, "end": 104, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 8 } }, "local": { "type": "Identifier", "start": 103, "end": 104, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 8 }, "identifierName": "_" }, "name": "_" } } ], "source": { "type": "StringLiteral", "start": 110, "end": 118, "loc": { "start": { "line": 4, "column": 14 }, "end": { "line": 4, "column": 22 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } }, { "type": "ImportDeclaration", "start": 121, "end": 149, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 28 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 128, "end": 134, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 13 } }, "local": { "type": "Identifier", "start": 128, "end": 134, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 13 }, "identifierName": "config" }, "name": "config" } } ], "source": { "type": "StringLiteral", "start": 140, "end": 148, "loc": { "start": { "line": 6, "column": 19 }, "end": { "line": 6, "column": 27 } }, "extra": { "rawValue": "config", "raw": "'config'" }, "value": "config" } }, { "type": "ImportDeclaration", "start": 150, "end": 172, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 22 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 157, "end": 160, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 10 } }, "local": { "type": "Identifier", "start": 157, "end": 160, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 10 }, "identifierName": "log" }, "name": "log" } } ], "source": { "type": "StringLiteral", "start": 166, "end": 171, "loc": { "start": { "line": 7, "column": 16 }, "end": { "line": 7, "column": 21 } }, "extra": { "rawValue": "log", "raw": "'log'" }, "value": "log" } }, { "type": "ImportDeclaration", "start": 173, "end": 215, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 42 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 180, "end": 187, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 14 } }, "local": { "type": "Identifier", "start": 180, "end": 187, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 14 }, "identifierName": "ajaxApi" }, "name": "ajaxApi" } } ], "source": { "type": "StringLiteral", "start": 193, "end": 214, "loc": { "start": { "line": 8, "column": 20 }, "end": { "line": 8, "column": 41 } }, "extra": { "rawValue": "http/shopifyAJAXAPI", "raw": "'http/shopifyAJAXAPI'" }, "value": "http/shopifyAJAXAPI" } }, { "type": "VariableDeclaration", "start": 217, "end": 236, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 19 } }, "declarations": [ { "type": "VariableDeclarator", "start": 223, "end": 235, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 10, "column": 18 } }, "id": { "type": "Identifier", "start": 223, "end": 226, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 10, "column": 9 }, "identifierName": "TAG" }, "name": "TAG" }, "init": { "type": "StringLiteral", "start": 229, "end": 235, "loc": { "start": { "line": 10, "column": 12 }, "end": { "line": 10, "column": 18 } }, "extra": { "rawValue": "Cart", "raw": "'Cart'" }, "value": "Cart" } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @typedef {Object} ShopifyCartLineItem\n * @property {Number} id\n * @property {Object|null} properties\n * @property {Number} quantity\n * @property {Number} variant_id\n * @property {String} key\n * @property {String} title\n * @property {Number} price\n * @property {Number} original_price\n * @property {Number} discounted_price\n * @property {Number} original_line_price\n * @property {Number} line_price\n * @property {Number} total_discount\n * @property {Object[]} discounts\n * @property {String|null} sku\n * @property {Number} grams\n * @property {String} vendor\n * @property {Boolean} taxable\n * @property {Number} product_id\n * @property {Boolean} gift_card\n * @property {String} url\n * @property {String|null} image\n * @property {String} handle\n * @property {Boolean} requires_shipping\n * @property {String|null} product_type\n * @property {String} product_title\n * @property {String|null} product_description\n * @property {String} variant_title\n * @property {String[]} variant_options\n ", "start": 239, "end": 1232, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 43, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * @typedef {Object} ShopifyCart\n * @property {String} token\n * @property {String} note\n * @property {Object} attributes\n * @property {Number} total_price\n * @property {Number} total_weight\n * @property {ShopifyCartLineItem[]} items\n * @property {Boolean} requires_shipping\n ", "start": 1234, "end": 1515, "loc": { "start": { "line": 45, "column": 0 }, "end": { "line": 54, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * Shopify Cart entity.\n * @extends {evee}\n ", "start": 1517, "end": 1567, "loc": { "start": { "line": 56, "column": 0 }, "end": { "line": 59, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 1568, "end": 8628, "loc": { "start": { "line": 60, "column": 0 }, "end": { "line": 339, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 1583, "end": 8628, "loc": { "start": { "line": 60, "column": 15 }, "end": { "line": 339, "column": 1 } }, "id": { "type": "Identifier", "start": 1589, "end": 1593, "loc": { "start": { "line": 60, "column": 21 }, "end": { "line": 60, "column": 25 }, "identifierName": "Cart" }, "name": "Cart", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 1602, "end": 1606, "loc": { "start": { "line": 60, "column": 34 }, "end": { "line": 60, "column": 38 }, "identifierName": "Evee" }, "name": "Evee" }, "body": { "type": "ClassBody", "start": 1607, "end": 8628, "loc": { "start": { "line": 60, "column": 39 }, "end": { "line": 339, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 1681, "end": 1953, "loc": { "start": { "line": 64, "column": 4 }, "end": { "line": 75, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1681, "end": 1692, "loc": { "start": { "line": 64, "column": 4 }, "end": { "line": 64, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1695, "end": 1953, "loc": { "start": { "line": 64, "column": 18 }, "end": { "line": 75, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1705, "end": 1713, "loc": { "start": { "line": 65, "column": 8 }, "end": { "line": 65, "column": 16 } }, "expression": { "type": "CallExpression", "start": 1705, "end": 1712, "loc": { "start": { "line": 65, "column": 8 }, "end": { "line": 65, "column": 15 } }, "callee": { "type": "Super", "start": 1705, "end": 1710, "loc": { "start": { "line": 65, "column": 8 }, "end": { "line": 65, "column": 13 } } }, "arguments": [] }, "trailingComments": [ { "type": "CommentBlock", "value": "* @type {promise-queue} ", "start": 1723, "end": 1751, "loc": { "start": { "line": 67, "column": 8 }, "end": { "line": 67, "column": 36 } } } ] }, { "type": "ExpressionStatement", "start": 1760, "end": 1797, "loc": { "start": { "line": 68, "column": 8 }, "end": { "line": 68, "column": 45 } }, "expression": { "type": "AssignmentExpression", "start": 1760, "end": 1796, "loc": { "start": { "line": 68, "column": 8 }, "end": { "line": 68, "column": 44 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1760, "end": 1771, "loc": { "start": { "line": 68, "column": 8 }, "end": { "line": 68, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1760, "end": 1764, "loc": { "start": { "line": 68, "column": 8 }, "end": { "line": 68, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 1765, "end": 1771, "loc": { "start": { "line": 68, "column": 13 }, "end": { "line": 68, "column": 19 }, "identifierName": "_queue" }, "name": "_queue" }, "computed": false, "leadingComments": null }, "right": { "type": "NewExpression", "start": 1774, "end": 1796, "loc": { "start": { "line": 68, "column": 22 }, "end": { "line": 68, "column": 44 } }, "callee": { "type": "Identifier", "start": 1778, "end": 1783, "loc": { "start": { "line": 68, "column": 26 }, "end": { "line": 68, "column": 31 }, "identifierName": "Queue" }, "name": "Queue" }, "arguments": [ { "type": "NumericLiteral", "start": 1784, "end": 1785, "loc": { "start": { "line": 68, "column": 32 }, "end": { "line": 68, "column": 33 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, { "type": "Identifier", "start": 1787, "end": 1795, "loc": { "start": { "line": 68, "column": 35 }, "end": { "line": 68, "column": 43 }, "identifierName": "Infinity" }, "name": "Infinity" } ] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {promise-queue} ", "start": 1723, "end": 1751, "loc": { "start": { "line": 67, "column": 8 }, "end": { "line": 67, "column": 36 } } } ] }, { "type": "ExpressionStatement", "start": 1806, "end": 1828, "loc": { "start": { "line": 69, "column": 8 }, "end": { "line": 69, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 1806, "end": 1827, "loc": { "start": { "line": 69, "column": 8 }, "end": { "line": 69, "column": 29 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1806, "end": 1822, "loc": { "start": { "line": 69, "column": 8 }, "end": { "line": 69, "column": 24 } }, "object": { "type": "ThisExpression", "start": 1806, "end": 1810, "loc": { "start": { "line": 69, "column": 8 }, "end": { "line": 69, "column": 12 } } }, "property": { "type": "Identifier", "start": 1811, "end": 1822, "loc": { "start": { "line": 69, "column": 13 }, "end": { "line": 69, "column": 24 }, "identifierName": "_attributes" }, "name": "_attributes" }, "computed": false }, "right": { "type": "ObjectExpression", "start": 1825, "end": 1827, "loc": { "start": { "line": 69, "column": 27 }, "end": { "line": 69, "column": 29 } }, "properties": [] } } }, { "type": "ExpressionStatement", "start": 1837, "end": 1857, "loc": { "start": { "line": 70, "column": 8 }, "end": { "line": 70, "column": 28 } }, "expression": { "type": "AssignmentExpression", "start": 1837, "end": 1856, "loc": { "start": { "line": 70, "column": 8 }, "end": { "line": 70, "column": 27 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1837, "end": 1848, "loc": { "start": { "line": 70, "column": 8 }, "end": { "line": 70, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1837, "end": 1841, "loc": { "start": { "line": 70, "column": 8 }, "end": { "line": 70, "column": 12 } } }, "property": { "type": "Identifier", "start": 1842, "end": 1848, "loc": { "start": { "line": 70, "column": 13 }, "end": { "line": 70, "column": 19 }, "identifierName": "_ready" }, "name": "_ready" }, "computed": false }, "right": { "type": "BooleanLiteral", "start": 1851, "end": 1856, "loc": { "start": { "line": 70, "column": 22 }, "end": { "line": 70, "column": 27 } }, "value": false } }, "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Object[]} ", "start": 1867, "end": 1890, "loc": { "start": { "line": 72, "column": 8 }, "end": { "line": 72, "column": 31 } } } ] }, { "type": "ExpressionStatement", "start": 1899, "end": 1916, "loc": { "start": { "line": 73, "column": 8 }, "end": { "line": 73, "column": 25 } }, "expression": { "type": "AssignmentExpression", "start": 1899, "end": 1915, "loc": { "start": { "line": 73, "column": 8 }, "end": { "line": 73, "column": 24 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1899, "end": 1910, "loc": { "start": { "line": 73, "column": 8 }, "end": { "line": 73, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1899, "end": 1903, "loc": { "start": { "line": 73, "column": 8 }, "end": { "line": 73, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 1904, "end": 1910, "loc": { "start": { "line": 73, "column": 13 }, "end": { "line": 73, "column": 19 }, "identifierName": "_items" }, "name": "_items" }, "computed": false, "leadingComments": null }, "right": { "type": "ArrayExpression", "start": 1913, "end": 1915, "loc": { "start": { "line": 73, "column": 22 }, "end": { "line": 73, "column": 24 } }, "elements": [] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Object[]} ", "start": 1867, "end": 1890, "loc": { "start": { "line": 72, "column": 8 }, "end": { "line": 72, "column": 31 } } } ] }, { "type": "ExpressionStatement", "start": 1925, "end": 1947, "loc": { "start": { "line": 74, "column": 8 }, "end": { "line": 74, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 1925, "end": 1946, "loc": { "start": { "line": 74, "column": 8 }, "end": { "line": 74, "column": 29 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1925, "end": 1941, "loc": { "start": { "line": 74, "column": 8 }, "end": { "line": 74, "column": 24 } }, "object": { "type": "ThisExpression", "start": 1925, "end": 1929, "loc": { "start": { "line": 74, "column": 8 }, "end": { "line": 74, "column": 12 } } }, "property": { "type": "Identifier", "start": 1930, "end": 1941, "loc": { "start": { "line": 74, "column": 13 }, "end": { "line": 74, "column": 24 }, "identifierName": "_attributes" }, "name": "_attributes" }, "computed": false }, "right": { "type": "ObjectExpression", "start": 1944, "end": 1946, "loc": { "start": { "line": 74, "column": 27 }, "end": { "line": 74, "column": 29 } }, "properties": [] } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Construct a new instance of the cart entity.\n ", "start": 1613, "end": 1676, "loc": { "start": { "line": 61, "column": 4 }, "end": { "line": 63, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Initialize the cart entity with the current state of the visitor's cart.\n * @param {ShopifyCart} cartData - Shopify Cart object.\n ", "start": 1959, "end": 2110, "loc": { "start": { "line": 77, "column": 4 }, "end": { "line": 80, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 2115, "end": 2356, "loc": { "start": { "line": 81, "column": 4 }, "end": { "line": 90, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 2115, "end": 2125, "loc": { "start": { "line": 81, "column": 4 }, "end": { "line": 81, "column": 14 }, "identifierName": "initialize" }, "name": "initialize", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 2126, "end": 2134, "loc": { "start": { "line": 81, "column": 15 }, "end": { "line": 81, "column": 23 }, "identifierName": "cartData" }, "name": "cartData" } ], "body": { "type": "BlockStatement", "start": 2136, "end": 2356, "loc": { "start": { "line": 81, "column": 25 }, "end": { "line": 90, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 2146, "end": 2182, "loc": { "start": { "line": 82, "column": 8 }, "end": { "line": 82, "column": 44 } }, "expression": { "type": "CallExpression", "start": 2146, "end": 2181, "loc": { "start": { "line": 82, "column": 8 }, "end": { "line": 82, "column": 43 } }, "callee": { "type": "MemberExpression", "start": 2146, "end": 2171, "loc": { "start": { "line": 82, "column": 8 }, "end": { "line": 82, "column": 33 } }, "object": { "type": "ThisExpression", "start": 2146, "end": 2150, "loc": { "start": { "line": 82, "column": 8 }, "end": { "line": 82, "column": 12 } } }, "property": { "type": "Identifier", "start": 2151, "end": 2171, "loc": {