@livepreso/api 6.52.0 → 6.53.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.rush/temp/chunked-rush-logs/api.build.chunks.jsonl +5 -2
  2. package/.rush/temp/operation/build/all.log +5 -2
  3. package/.rush/temp/operation/build/error.log +3 -0
  4. package/.rush/temp/operation/build/log-chunks.jsonl +5 -2
  5. package/.rush/temp/operation/build/state.json +1 -1
  6. package/.rush/temp/shrinkwrap-deps.json +11 -2
  7. package/CHANGELOG.json +32 -0
  8. package/CHANGELOG.md +20 -1
  9. package/cjs/collections/base.js +15 -1
  10. package/cjs/collections/base.js.map +1 -1
  11. package/cjs/collections/base.spec.js +61 -0
  12. package/cjs/collections/base.spec.js.map +1 -1
  13. package/cjs/models/base.js +54 -12
  14. package/cjs/models/base.js.map +1 -1
  15. package/cjs/models/base.spec.js +28 -0
  16. package/cjs/models/base.spec.js.map +1 -1
  17. package/cjs/models/deck-version.js +14 -5
  18. package/cjs/models/deck-version.js.map +1 -1
  19. package/cjs/presentation/presentation-deck.js +28 -15
  20. package/cjs/presentation/presentation-deck.js.map +1 -1
  21. package/cjs/presentation/presentation-section.js +19 -9
  22. package/cjs/presentation/presentation-section.js.map +1 -1
  23. package/cjs/presentation/presentation-section.spec.js +3 -3
  24. package/cjs/presentation/presentation-section.spec.js.map +1 -1
  25. package/cjs/presentation/presentation-slide.js +22 -5
  26. package/cjs/presentation/presentation-slide.js.map +1 -1
  27. package/cjs/presentation/presentation.js +2 -2
  28. package/cjs/presentation/presentation.js.map +1 -1
  29. package/package.json +3 -3
  30. package/rush-logs/api.build.error.log +3 -0
  31. package/rush-logs/api.build.log +5 -2
  32. package/src/collections/base.js +13 -2
  33. package/src/collections/base.spec.js +37 -0
  34. package/src/models/base.js +38 -11
  35. package/src/models/base.spec.js +18 -0
  36. package/src/models/deck-version.js +7 -4
  37. package/src/presentation/presentation-deck.js +34 -17
  38. package/src/presentation/presentation-section.js +15 -3
  39. package/src/presentation/presentation-section.spec.js +2 -6
  40. package/src/presentation/presentation-slide.js +17 -2
  41. package/src/presentation/presentation.js +2 -2
  42. package/.rush/temp/1aebf46f78ad5c45f82f8147751890adb37bef9d.log +0 -10
  43. package/.rush/temp/256021b5963b4c0221d3dec247b697b9691a9b2c.log +0 -10
  44. package/.rush/temp/2a322f00f12cf9d1e64afe81275cc78d01c49050.log +0 -10
  45. package/.rush/temp/30061f1865447dcbb3f20a305061205f3dbe6091.log +0 -10
  46. package/.rush/temp/3cdc82c352e8ed90607952873f3aa4c200490874.log +0 -10
  47. package/.rush/temp/45522aea0dee8cb2be1a53248ba45bd235743b43.log +0 -10
  48. package/.rush/temp/5489ab737e406518983c16c57fc3e1edc07c0341.log +0 -10
  49. package/.rush/temp/58fcbb7f15a76326d40e0839ab179755da82a891.log +0 -10
  50. package/.rush/temp/5bc0bba70b733baa4dd976667ba0a1386e516186.log +0 -10
  51. package/.rush/temp/64f1bb696f8d7d7e72907b80df316b127f72e23e.log +0 -10
  52. package/.rush/temp/6f640f951414ea68adb65c17e4ed7527cde54faf.log +0 -10
  53. package/.rush/temp/7c7b958682d4ab5697530be47d0aac62efe1adf1.log +0 -10
  54. package/.rush/temp/82bfb987463fbcfebf04022e6ed00015c73879c8.log +0 -10
  55. package/.rush/temp/844034aa6e542115075e8f3dc5ffc640973e0064.log +0 -10
  56. package/.rush/temp/8b42957a7c15da1f29cb57bee125f13affa70dca.log +0 -10
  57. package/.rush/temp/924652444ab5a6063f328a2217123a2227058896.log +0 -10
  58. package/.rush/temp/9f2030f96d62f3e38052e35201819a216566f14f.log +0 -10
  59. package/.rush/temp/a769db9d81a23000c0e9b1bf4f1a9a9e721d0d7c.log +0 -10
  60. package/.rush/temp/a87d3a8b4ece87ec66f27c86226a9f205617681f.log +0 -10
  61. package/.rush/temp/bb7a5bdcc4af4ad1507f81f33774b31f5b4e4fb7.log +0 -10
  62. package/.rush/temp/build-cache-tar.log +0 -7
  63. package/.rush/temp/c20e29ccaaa9231b38a28bb24451b4ce7562cdc0.log +0 -10
  64. package/.rush/temp/chunked-rush-logs/api.test.chunks.jsonl +0 -1
  65. package/.rush/temp/e21303db8f59b4625fd184c9114377d781fd24f8.log +0 -10
  66. package/.rush/temp/e6d303862765b6a5f41dd483d0f9ae083a1fae10.log +0 -10
  67. package/.rush/temp/eaf69fbc059d2f1258d7569136180d4a1d3c7072.log +0 -10
  68. package/.rush/temp/f85d279e2674966daaec83e1c3986a96f86ef304.log +0 -10
  69. package/.rush/temp/fc0a332c5b34c6b90006850cf2d93a48fb4b9a6e.log +0 -10
  70. package/.rush/temp/operation/test/all.log +0 -19
  71. package/.rush/temp/operation/test/state.json +0 -3
  72. package/.rush/temp/package-deps_build.json +0 -185
  73. package/api.build.log +0 -9
  74. package/api.test.cache.log +0 -1
  75. package/api.test.log +0 -19
  76. package/rush-logs/api.test.cache.log +0 -1
  77. package/rush-logs/api.test.log +0 -1
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.BaseModel = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
12
13
  var _utils = require("../utils.js");
@@ -224,7 +225,7 @@ var BaseModel = exports.BaseModel = _ampersandModel.default.extend(/** @lends mo
224
225
  getIDFromURL: function getIDFromURL(url) {
225
226
  var resource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
226
227
  var resourceURL = resource || this.getResourceURL();
227
- if (!url || !resourceURL) {
228
+ if (typeof url !== "string" || !resourceURL) {
228
229
  return null;
229
230
  }
230
231
  var urlPath = _url.default.parse(url).path;
@@ -630,7 +631,6 @@ var BaseModel = exports.BaseModel = _ampersandModel.default.extend(/** @lends mo
630
631
  return _sync2.sync.apply(this, arguments);
631
632
  },
632
633
  serialize: function serialize() {
633
- var _this9 = this;
634
634
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
635
635
  derived: true
636
636
  };
@@ -639,6 +639,12 @@ var BaseModel = exports.BaseModel = _ampersandModel.default.extend(/** @lends mo
639
639
  if (!this._data) {
640
640
  return {};
641
641
  }
642
+
643
+ // Urls only will build a model without its children/collections expanded -
644
+ // it will return urls instead of the full model.
645
+ var _ref = opts !== null && opts !== void 0 ? opts : {},
646
+ _ref$urlsOnly = _ref.urlsOnly,
647
+ urlsOnly = _ref$urlsOnly === void 0 ? false : _ref$urlsOnly;
642
648
  var data = _ampersandModel.default.prototype.serialize.apply(this, arguments);
643
649
  data.url = this.url();
644
650
  var derived = this.getAttributes(opts);
@@ -650,22 +656,58 @@ var BaseModel = exports.BaseModel = _ampersandModel.default.extend(/** @lends mo
650
656
  object[key] = value;
651
657
  return object;
652
658
  }, {});
653
- Object.keys(this._unsetCollections).forEach(function (key) {
654
- if (_this9._unsetCollections[key].canBeEmpty && !_this9._values[key]) {
655
- derived[key] = [];
659
+ var allCollectionKeys = [].concat((0, _toConsumableArray2.default)(Object.keys(this._unsetCollections)), (0, _toConsumableArray2.default)(Object.keys(this._collections)));
660
+ var _iterator2 = _createForOfIteratorHelper(allCollectionKeys),
661
+ _step2;
662
+ try {
663
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
664
+ var key = _step2.value;
665
+ var constructor = this._unsetCollections[key];
666
+ if (urlsOnly && this[key]) {
667
+ if (typeof this._values[key] === "string") {
668
+ derived[key] = this._values[key];
669
+ } else {
670
+ derived[key] = this[key].map(function (m) {
671
+ return m.url();
672
+ });
673
+ }
674
+ } else if (!constructor) {
675
+ continue;
676
+ } else if (constructor.canBeEmpty && !this._values[key]) {
677
+ derived[key] = [];
678
+ }
656
679
  }
657
- });
658
- Object.keys(this._unsetChildren).forEach(function (key) {
659
- if (_this9._unsetChildren[key].canBeEmpty && !_this9._values[key] && _this9[key]) {
660
- derived[key] = _this9[key].url();
680
+ } catch (err) {
681
+ _iterator2.e(err);
682
+ } finally {
683
+ _iterator2.f();
684
+ }
685
+ var allChildrenKeys = [].concat((0, _toConsumableArray2.default)(Object.keys(this._unsetChildren)), (0, _toConsumableArray2.default)(urlsOnly ? Object.keys(this._children) : []));
686
+ var _iterator3 = _createForOfIteratorHelper(allChildrenKeys),
687
+ _step3;
688
+ try {
689
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
690
+ var _key = _step3.value;
691
+ var _constructor = this._unsetChildren[_key];
692
+ if (urlsOnly && this[_key]) {
693
+ derived[_key] = this[_key].url();
694
+ } else if (!_constructor) {
695
+ continue;
696
+ } else if (_constructor.canBeEmpty && !this._values[_key] && this[_key]) {
697
+ derived[_key] = this[_key].url();
698
+ }
661
699
  }
662
- });
700
+ } catch (err) {
701
+ _iterator3.e(err);
702
+ } finally {
703
+ _iterator3.f();
704
+ }
663
705
  return _lodash.default.extend(data, derived);
664
706
  },
665
707
  // Safely retrieve the url from a child or collection that may or may not
666
708
  // be hydrated
667
709
  _retrieveURL: function _retrieveURL(item) {
668
- var _this10 = this;
710
+ var _this9 = this;
669
711
  if (_lodash.default.isUndefined(item) || item === null) {
670
712
  return item;
671
713
  } else if (typeof item === "string") {
@@ -678,7 +720,7 @@ var BaseModel = exports.BaseModel = _ampersandModel.default.extend(/** @lends mo
678
720
  } else if (_lodash.default.isArray(item)) {
679
721
  // It's an array of urls or objects
680
722
  return item.map(function (child) {
681
- return _this10._retrieveURL(child);
723
+ return _this9._retrieveURL(child);
682
724
  });
683
725
  } else if ((0, _typeof2.default)(item) === "object" && item !== null) {
684
726
  return typeof item.url === "function" ? item.url() : item.url;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["_utils","require","_api","_ampersandRestCollection","_interopRequireDefault","_ampersandModel","_bluebird","_superagentBluebirdPromise","_lodash","_dedentJs","_log","_moment","_qs","_stateRegister","_sync2","_url","_templateObject","_createForOfIteratorHelper","r","e","t","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","_n","F","s","n","done","value","f","TypeError","o","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","from","test","BaseModel","exports","Model","extend","modelName","queryData","detailType","isFetching","_isFetched","urlMatchKeys","_data","arguments","undefined","opts","options","_","defaults","data","_unsetChildren","_unsetCollections","_expandedValues","toJSON","isString","url","isNumber","id","dataCopy","_options","_children","clone","_collections","_definition","key","def","isState","Collection","map","obj","registerStates","_convertToValues","getIDFromURL","prototype","_setDerived","_initUnsetValues","_i","_Object$keys","Object","keys","_derived","derivedKey","_i2","_Object$keys2","derivedProp","set","_matchesURL","matchesDetail","urlRoot","Api","getURL","replacements","detailKey","regexes","reduce","result","type","replace","Error","concat","urlWithoutRoot","urlStructure","split","argIndex","findIndex","val","indexOf","attemptedURLWithoutRoot","partial","join","interpolatedString","template","interpolate","log","error","dedent","_taggedTemplateLiteral2","default","baseString","re","RegExp","resource","resourceURL","getResourceURL","urlPath","url2","parse","path","resourceURLPath","resourceEnd","urlEnd","idStr","match","parseInt","matchesURL","dataTypes","date","newVal","moment","utc","format","DATE_FORMAT_T","compare","currentVal","isSame","stringSanitized","removeMultiByteChars","get","any","props","required","toServer","serialize","_registerChildModel","states","prop","model","registeredStates","_registerCollection","state","collection","_this","each","parent","_registerName","_updateResponse","response","_this2","forEach","save","_this3","apply","tap","fetch","_this4","SuperAgentRequest","Auth","headers","then","res","body","isFetched","getSafeAttrs","_this5","isUndefined","_values","attrs","uniq","_this6","_initChildren","child","_safeSet","listenTo","_getCachedEventBubblingHandler","_initCollections","coll","_this7","tmpValue","replacePropertyDefinition","safeSet","property","getFullURLPath","qs","stringify","arrayFormat","isNew","getPlainURL","resp","includes","matches","_iterator","_step","replacement","err","resources","waitForReady","_arguments","_this8","_asyncToGenerator2","_regenerator","mark","_callee","attempts","wrap","_callee$","_context","prev","abrupt","Promise","reject","creation_status","resolve","delay","stop","sync","_this9","derived","getAttributes","object","canBeEmpty","_retrieveURL","item","_this10","_typeof2","addCollection","addChild","expandCollection","expandChild","defineProperty","configurable","_this$prototype"],"sources":["../../src/models/base.js"],"sourcesContent":["import { DATE_FORMAT_T, removeMultiByteChars } from \"../utils.js\";\n\nimport { Api } from \"../api.js\";\nimport Collection from \"ampersand-rest-collection\";\nimport Model from \"ampersand-model\";\nimport Promise from \"bluebird\";\nimport SuperAgentRequest from \"superagent-bluebird-promise\";\nimport _ from \"lodash\";\nimport dedent from \"dedent-js\";\nimport log from \"../log.js\";\nimport moment from \"moment\";\nimport qs from \"qs\";\nimport { registeredStates } from \"../state-register.js\";\nimport { sync } from \"../sync.js\";\nimport url2 from \"url\";\n\n/**\n * @constructor\n * @alias models.BaseModel\n */\nexport const BaseModel = Model.extend(\n\t/** @lends models.BaseModel# */ {\n\t\tmodelName: null,\n\t\tqueryData: {},\n\t\tdetailType: \"number\",\n\n\t\t// This is unfortunately necessary to avoid the default ampersand model/state\n\t\t// behaviour from automatically hydrating all children and collections on a fetch.\n\t\tisFetching: false,\n\n\t\t// Useful to figure out whether the model is just a URL (unfetched), or has been\n\t\t// fetched from the server (an object).\n\t\t_isFetched: true,\n\n\t\t// Object of regexes that should be used to match a url in `matchesURL`\n\t\t// For example the URL: /api/foo/{pk}/bar/ might have the following:\n\t\t//\n\t\t// Example:\n\t\t//\n\t\t// ```\n\t\t// {\n\t\t// pk: \"number\"\n\t\t// }\n\t\t// ```\n\t\turlMatchKeys: {},\n\n\t\tconstructor(_data = {}, opts = {}) {\n\t\t\tconst options = _.defaults(opts, {\n\t\t\t\tdata: {},\n\t\t\t});\n\n\t\t\tlet data = _data;\n\n\t\t\tthis._unsetChildren = {};\n\t\t\tthis._unsetCollections = {};\n\t\t\tthis._expandedValues = {};\n\n\t\t\tif (data === null) {\n\t\t\t\tdata = {};\n\t\t\t}\n\n\t\t\t// Allow passing in models\n\t\t\tif (data instanceof Model) {\n\t\t\t\tdata = data.toJSON();\n\t\t\t}\n\n\t\t\tthis.queryData = options.data;\n\n\t\t\t// Convert any strings into a url format we can understand\n\t\t\tif (_.isString(data)) {\n\t\t\t\tdata = { url: data };\n\t\t\t\tthis._isFetched = false;\n\t\t\t}\n\n\t\t\t// Convert model ids into a format we can understand\n\t\t\tif (_.isNumber(data)) {\n\t\t\t\tdata = { id: data };\n\t\t\t\tthis._isFetched = false;\n\t\t\t}\n\n\t\t\tconst dataCopy = _.extend({}, data);\n\n\t\t\tthis._data = dataCopy;\n\t\t\tthis._options = options;\n\n\t\t\t// Stop making edits to these affect other models\n\t\t\tthis._children = _.clone(this._children);\n\t\t\tthis._collections = _.clone(this._collections);\n\t\t\tthis._definition = _.clone(this._definition);\n\n\t\t\t// Check for specialized url returns from the server. This is for when the\n\t\t\t// server responds with an array of urls rather than object data.\n\t\t\tif (dataCopy && typeof dataCopy.url === \"string\") {\n\t\t\t\tthis._url = dataCopy.url;\n\t\t\t}\n\n\t\t\tfor (const key in dataCopy) {\n\t\t\t\tconst def = dataCopy[key];\n\t\t\t\t// Any models/collections passed into the constructor should be\n\t\t\t\t// converted to JSON so that it can be parsed\n\t\t\t\tif (def && (def.isState || def instanceof Collection)) {\n\t\t\t\t\tdataCopy[key] = def.toJSON();\n\t\t\t\t}\n\n\t\t\t\tif (def && Array.isArray(def)) {\n\t\t\t\t\tdataCopy[key] = def.map((obj) => {\n\t\t\t\t\t\tif (obj instanceof Model) {\n\t\t\t\t\t\t\treturn obj.toJSON();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.registerStates();\n\n\t\t\tthis._convertToValues();\n\n\t\t\tconst id = this.getIDFromURL(this._url);\n\n\t\t\tif (!dataCopy.id && id) {\n\t\t\t\tdataCopy.id = id;\n\t\t\t}\n\n\t\t\tModel.prototype.constructor.call(this, dataCopy, options);\n\n\t\t\tthis._setDerived();\n\n\t\t\t// Re-set the values that were previously children or collections\n\t\t\tthis._initUnsetValues();\n\t\t},\n\n\t\t// If there is a model returned from a derived property, and the model\n\t\t// has been initialzied with model data, we manually set the values on it.\n\t\t_setDerived() {\n\t\t\tfor (const derivedKey of Object.keys(this._derived)) {\n\t\t\t\tif (!this._data[derivedKey]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (this[derivedKey] instanceof Model) {\n\t\t\t\t\tfor (const derivedProp of Object.keys(this._data[derivedKey])) {\n\t\t\t\t\t\tthis[derivedKey].set(\n\t\t\t\t\t\t\tderivedProp,\n\t\t\t\t\t\t\tthis._data[derivedKey][derivedProp],\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If it's a collection, we can just pass the data straight in\n\t\t\t\tif (this[derivedKey] instanceof Collection) {\n\t\t\t\t\tthis[derivedKey].set(this._data[derivedKey]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Internal function. Used by collection as well.\n\t\t_matchesURL(url, matchesDetail = true) {\n\t\t\tif (!this.modelName || this.urlRoot() === Api.getURL()) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst replacements = _.extend(\n\t\t\t\t{},\n\t\t\t\t{\n\t\t\t\t\tdetailKey: this.detailType,\n\t\t\t\t},\n\t\t\t\tthis.urlMatchKeys,\n\t\t\t);\n\n\t\t\tconst regexes = Object.keys(replacements).reduce((result, key) => {\n\t\t\t\tconst type = replacements[key];\n\t\t\t\tconst name = key.replace(/\\./g, \"_\");\n\t\t\t\tif (type === \"number\") {\n\t\t\t\t\tresult[name] = \"\\\\d+\";\n\t\t\t\t} else if (type === \"uuid\") {\n\t\t\t\t\tresult[name] = \"([a-z]|[0-9]|-)+\";\n\t\t\t\t} else if (type === \"string\") {\n\t\t\t\t\tresult[name] = \"\\\\w+\";\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Unknown regex type '${type}'.`);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}, {});\n\n\t\t\t// Create a starting regex string with variables. Strips the root url so that it could\n\t\t\t// be read from any server.\n\t\t\tconst urlWithoutRoot = this.urlRoot().replace(Api.getURL(), \"\");\n\t\t\tlet urlStructure = urlWithoutRoot.slice();\n\t\t\tif (matchesDetail) {\n\t\t\t\turlStructure += \"{detailKey}/\";\n\t\t\t}\n\n\t\t\t// Let's test if the url has even a remote chance of matching\n\t\t\t// the url (like a partial match, any part without variables).\n\t\t\t// If that doesn't match, we can sometimes prevent a nasty log\n\t\t\t// error from being thrown.\n\t\t\tconst split = urlStructure.split(\"/\");\n\t\t\tconst argIndex = split.findIndex((val) => {\n\t\t\t\treturn val.indexOf(\"{\") === 0;\n\t\t\t});\n\n\t\t\tif (argIndex >= 0) {\n\t\t\t\tconst attemptedURLWithoutRoot = url.replace(Api.getURL(), \"\");\n\n\t\t\t\tconst partial = split.slice(0, argIndex).join(\"/\");\n\t\t\t\tif (attemptedURLWithoutRoot.indexOf(partial) !== 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Replace keys with regexes\n\t\t\tlet interpolatedString;\n\t\t\ttry {\n\t\t\t\tinterpolatedString = _.template(urlStructure.replace(/\\./g, \"_\"), {\n\t\t\t\t\tinterpolate: /{([\\s\\S\\.]+?)}/g,\n\t\t\t\t})(regexes);\n\t\t\t} catch (e) {\n\t\t\t\tlog.error(\n\t\t\t\t\tdedent`\n\t\t\t\tFailed to match URL '${url}' for model '${this.modelName}'.\n\t\t\t\tThis is usually because the regex type for a key hasn't been set.\n\t\t\t\tError: `,\n\t\t\t\t\te,\n\t\t\t\t);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Convert into a regex and test if url matches\n\t\t\tconst baseString = `.*${interpolatedString.replace(/\\//m, \"/\")}$`;\n\t\t\tconst re = new RegExp(baseString);\n\t\t\treturn re.test(url);\n\t\t},\n\n\t\t// Retrieve the id from the url (if present) without caring about\n\t\t// the hostname.\n\t\t// The url will have a structure like\n\t\t// https://staging-demo.salespreso.com/api/users/1/\n\t\t// and we want to ignore the hostname (https://staging-demo.salespreso.com)\n\t\t// and strip out the '/api' from both the resource url and the variable url\n\t\t// so that we can use the remaining part to isolate the id\n\t\tgetIDFromURL(url, resource = \"\") {\n\t\t\tconst resourceURL = resource || this.getResourceURL();\n\n\t\t\tif (!url || !resourceURL) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst urlPath = url2.parse(url).path;\n\t\t\tconst resourceURLPath = url2.parse(resourceURL).path;\n\n\t\t\t// Remove the '/api' if present\n\t\t\tconst resourceEnd = resourceURLPath.split(\"/api\").join(\"\");\n\t\t\tconst urlEnd = urlPath.split(\"/api\").join(\"\");\n\n\t\t\t// If they are the same, there is no id at the end\n\t\t\tif (!urlEnd || urlEnd === resourceEnd) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst idStr = urlEnd.split(resourceEnd).join(\"\");\n\n\t\t\tif ((idStr.match(/\\//g) || []).length === 1) {\n\t\t\t\treturn parseInt(idStr.slice(0, -1), 10);\n\t\t\t}\n\n\t\t\treturn null;\n\t\t},\n\n\t\t// Public version for details only\n\t\tmatchesURL(url) {\n\t\t\treturn this._matchesURL(url, true);\n\t\t},\n\n\t\tdataTypes: {\n\t\t\tdate: {\n\t\t\t\tset: (newVal) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tval: newVal ? moment.utc(newVal).format(DATE_FORMAT_T) : null,\n\t\t\t\t\t\ttype: \"date\",\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tcompare: (currentVal, newVal) => {\n\t\t\t\t\tif (typeof currentVal === \"undefined\") {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (currentVal || newVal) {\n\t\t\t\t\t\treturn moment(currentVal).isSame(moment(newVal));\n\t\t\t\t\t}\n\t\t\t\t\treturn currentVal !== newVal;\n\t\t\t\t},\n\t\t\t},\n\t\t\tstringSanitized: {\n\t\t\t\tset: (newVal) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tval: newVal ? removeMultiByteChars(newVal) : newVal,\n\t\t\t\t\t\ttype: \"stringSanitized\",\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tcompare: (currentVal, newVal) => {\n\t\t\t\t\treturn currentVal === newVal;\n\t\t\t\t},\n\t\t\t\tget: (val) => {\n\t\t\t\t\treturn val;\n\t\t\t\t},\n\t\t\t},\n\t\t\tany: {\n\t\t\t\tdefault: () => {\n\t\t\t\t\treturn null;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\n\t\t/**\n\t\t * @property {number} [id]\n\t\t */\n\t\tprops: {\n\t\t\tid: { type: \"any\", required: false },\n\t\t},\n\n\t\t/*\n\t\t * Overridable serialization for sending data to\n\t\t * the server\n\t\t */\n\t\ttoServer() {\n\t\t\treturn this.serialize();\n\t\t},\n\n\t\t_registerChildModel(states, prop, model) {\n\t\t\tconst Model = registeredStates[model];\n\t\t\tif (!Model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`'${model}' not found! Did you forget to import it on the '${this.modelName}' model?`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._children[prop] = Model;\n\t\t},\n\n\t\t_registerCollection(state, prop, collection) {\n\t\t\tconst Collection = state[collection];\n\t\t\tif (!Collection) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`'${collection}' not found! Did you forget to import it on the '${this.modelName}' model?`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._collections[prop] = Collection;\n\t\t},\n\n\t\t/*\n\t\t * Replace strings respresenting a registered model/collection the function\n\t\t */\n\t\tregisterStates() {\n\t\t\t// Loop through children and replace any parent objects directly to stop\n\t\t\t// maximum stack overflows\n\t\t\t_.each(\n\t\t\t\tthis._children,\n\t\t\t\t(model, prop) => {\n\t\t\t\t\tif (typeof model === \"string\") {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis._options.parent &&\n\t\t\t\t\t\t\tmodel === this._options.parent._registerName\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// This part is important, if the link stays when there's a circular dependency,\n\t\t\t\t\t\t\t// this will continue forever.\n\t\t\t\t\t\t\tdelete this._children[prop];\n\n\t\t\t\t\t\t\t// Can be a string or an object so we use \"any\". We add the definition\n\t\t\t\t\t\t\t// so that we can retrieve this value later.\n\t\t\t\t\t\t\tthis._definition[prop] = { type: \"any\" };\n\n\t\t\t\t\t\t\tthis[prop] = this._options.parent;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._registerChildModel(registeredStates, prop, model);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tthis,\n\t\t\t);\n\n\t\t\t// Loop throught the collections and replace with the registered collection\n\t\t\t_.each(\n\t\t\t\tthis._collections,\n\t\t\t\t(collection, prop) => {\n\t\t\t\t\tif (typeof collection === \"string\") {\n\t\t\t\t\t\tthis._registerCollection(registeredStates, prop, collection);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tthis,\n\t\t\t);\n\t\t},\n\n\t\t_updateResponse(response) {\n\t\t\tthis._data = response || {};\n\n\t\t\tif (!response) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set previously-initialised children & collections with new\n\t\t\t// data retrieved during the fetch\n\n\t\t\tObject.keys(this._children).forEach((key) => {\n\t\t\t\tif (response[key]) {\n\t\t\t\t\tthis[key] = response[key];\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tObject.keys(this._collections).forEach((key) => {\n\t\t\t\tif (response[key]) {\n\t\t\t\t\tthis[key] = response[key];\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tsave() {\n\t\t\treturn Model.prototype.save.apply(this, arguments).tap((response) => {\n\t\t\t\tthis._updateResponse(response);\n\t\t\t});\n\t\t},\n\n\t\tfetch(options = {}) {\n\t\t\tif (options.url) {\n\t\t\t\tthis._url = options.url;\n\t\t\t}\n\n\t\t\tthis._options = _.extend({}, this._options, options);\n\n\t\t\tthis.isFetching = true;\n\t\t\treturn Model.prototype.fetch.apply(this, arguments).tap((response) => {\n\t\t\t\tthis._isFetched = true;\n\t\t\t\tthis.isFetching = false;\n\t\t\t\tthis._updateResponse(response);\n\t\t\t});\n\t\t},\n\n\t\toptions(options = {}) {\n\t\t\tif (options.url) {\n\t\t\t\tthis._url = options.url;\n\t\t\t}\n\t\t\treturn SuperAgentRequest(\"OPTIONS\", this.url())\n\t\t\t\t.set(BaseModel.Auth.headers)\n\t\t\t\t.then((res) => {\n\t\t\t\t\treturn res.body;\n\t\t\t\t});\n\t\t},\n\n\t\tisFetched() {\n\t\t\treturn this._isFetched;\n\t\t},\n\n\t\tgetSafeAttrs(key) {\n\t\t\tif (!_.isUndefined(key)) {\n\t\t\t\treturn !_.isUndefined(this._expandedValues[key])\n\t\t\t\t\t? this._expandedValues[key]\n\t\t\t\t\t: this._values[key];\n\t\t\t}\n\n\t\t\tconst attrs = {};\n\n\t\t\tconst keys = _.uniq(\n\t\t\t\t_.concat(\n\t\t\t\t\t_.concat(\n\t\t\t\t\t\tObject.keys(this._unsetChildren),\n\t\t\t\t\t\tObject.keys(this._unsetCollections),\n\t\t\t\t\t),\n\t\t\t\t\tObject.keys(this._values),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tkeys.forEach((key) => {\n\t\t\t\tif (!_.isUndefined(this._values[key])) {\n\t\t\t\t\tattrs[key] = this._values[key];\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tObject.keys(this._expandedValues).forEach((key) => {\n\t\t\t\tattrs[key] = this[key];\n\t\t\t});\n\n\t\t\treturn attrs;\n\t\t},\n\n\t\t// Unset all specified children and collection constructors and insert value\n\t\t// definitions for them (necessary for Ampersand State to treat them as values)\n\t\t_convertToValues() {\n\t\t\tObject.keys(this._children).forEach((key) => {\n\t\t\t\tthis._definition[key] = { type: \"any\" };\n\t\t\t\tthis._unsetChildren[key] = this._children[key];\n\t\t\t\tdelete this._children[key];\n\t\t\t});\n\n\t\t\tObject.keys(this._collections).forEach((key) => {\n\t\t\t\tthis._definition[key] = { type: \"any\" };\n\t\t\t\tthis._unsetCollections[key] = this._collections[key];\n\t\t\t\tdelete this._collections[key];\n\t\t\t});\n\t\t},\n\n\t\t// Override the initialization of children to pass in data to the constructor.\n\t\t// The default version always creates an empty model\n\t\t_initChildren() {\n\t\t\tlet child;\n\t\t\tif (!this._children) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (child in this._children) {\n\t\t\t\tlet val = this._data[child];\n\t\t\t\tif (val) {\n\t\t\t\t\t// Assume here that if it's a string, it's a url.\n\t\t\t\t\tif (typeof val === \"string\") {\n\t\t\t\t\t\tval = { url: val };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If hydrate is set to false, this will be the name of the child and\n\t\t\t\t// not the constructor. We want to add the non-hydrated url if so.\n\t\t\t\tif (typeof this._children[child] === \"function\") {\n\t\t\t\t\tthis._safeSet(\n\t\t\t\t\t\tchild,\n\t\t\t\t\t\tnew this._children[child](val, { parent: this }),\n\t\t\t\t\t);\n\t\t\t\t\tthis.listenTo(\n\t\t\t\t\t\tthis[child],\n\t\t\t\t\t\t\"all\",\n\t\t\t\t\t\tthis._getCachedEventBubblingHandler(child),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis._safeSet(child, val);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Override the initialization of collections to pass in data to the constructor.\n\t\t_initCollections() {\n\t\t\tlet coll;\n\t\t\tif (!this._collections) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (coll in this._collections) {\n\t\t\t\tlet val = this._data[coll];\n\t\t\t\tif (val) {\n\t\t\t\t\tif (typeof val === \"string\") {\n\t\t\t\t\t\tval = { url: val };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If hydrate is set to false, this will be the name of the collection and\n\t\t\t\t// not the constructor. We want to add the non-hydrated array if so.\n\t\t\t\tif (typeof this._collections[coll] === \"function\") {\n\t\t\t\t\tthis._safeSet(\n\t\t\t\t\t\tcoll,\n\t\t\t\t\t\tnew this._collections[coll](val, { parent: this }),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis._safeSet(coll, val);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t_initUnsetValues() {\n\t\t\t_.each(this._unsetChildren, (child, key) => {\n\t\t\t\tconst tmpValue = this._values[key];\n\n\t\t\t\treplacePropertyDefinition(this, key);\n\n\t\t\t\tthis[key] = tmpValue;\n\t\t\t});\n\n\t\t\t_.each(this._unsetCollections, (child, key) => {\n\t\t\t\tconst tmpValue = this._values[key];\n\n\t\t\t\treplacePropertyDefinition(this, key);\n\n\t\t\t\tthis[key] = tmpValue;\n\t\t\t});\n\t\t},\n\n\t\t// Make safeSet less safe... as we do need to run this twice\n\t\t_safeSet: function safeSet(property, value) {\n\t\t\tthis[property] = value;\n\t\t\treturn this;\n\t\t},\n\n\t\turlRoot() {\n\t\t\treturn this.getResourceURL();\n\t\t},\n\n\t\tgetFullURLPath(path) {\n\t\t\tif (path === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tlet url = path;\n\t\t\tif (url.slice(-1) !== \"/\" && url.indexOf(\"?\") === -1) {\n\t\t\t\turl += \"/\";\n\t\t\t}\n\n\t\t\tif (Object.keys(this.queryData).length) {\n\t\t\t\turl += `?${qs.stringify(this.queryData, { arrayFormat: \"repeat\" })}`;\n\t\t\t}\n\t\t\treturn url;\n\t\t},\n\n\t\t/*\n\t\t * Get url\n\t\t * @return {String}\n\t\t */\n\t\turl() {\n\t\t\tif (this._url && this.isNew()) {\n\t\t\t\treturn this.getFullURLPath(this._url);\n\t\t\t}\n\t\t\treturn this.getFullURLPath(this.getPlainURL());\n\t\t},\n\n\t\t// Returns url without query data\n\t\tgetPlainURL() {\n\t\t\tif (!this.modelName) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tlet resp = Model.prototype.url.call(this);\n\n\t\t\tif (resp.slice(-1) !== \"/\" && resp.indexOf(\"?\") === -1) {\n\t\t\t\tresp += \"/\";\n\t\t\t}\n\n\t\t\tif (!resp.includes(\"{\") || !resp.includes(\"}\")) {\n\t\t\t\treturn resp;\n\t\t\t}\n\n\t\t\t// Replace any values in a url with one from the model.\n\t\t\t// So if you have /path/to/{model.id}/\n\t\t\t// It will check the model from \"this.model.id\" and replace\n\t\t\t// it in the url\n\t\t\tconst re = /(\\{(?:\\w+\\.?)+\\})/g;\n\t\t\tconst matches = resp.match(re) || [];\n\t\t\tfor (const match of matches) {\n\t\t\t\tconst path = match.slice(1, -1);\n\t\t\t\tconst replacement = _.get(this, path);\n\t\t\t\tif (replacement) {\n\t\t\t\t\tresp = resp.replace(match, replacement);\n\t\t\t\t} else if (!this.isNew()) {\n\t\t\t\t\tlog.error(`Model ${this.modelName} is missing value ${path}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn resp;\n\t\t},\n\n\t\tgetResourceURL() {\n\t\t\tif (this.modelName === null && !Object.keys(Api.resources).length) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (!Object.keys(Api.resources).length) {\n\t\t\t\treturn `/${this.modelName}/`;\n\t\t\t}\n\n\t\t\tif (this.modelName === null) {\n\t\t\t\treturn Api.getURL();\n\t\t\t}\n\t\t\treturn Api.getResourceURL(this.modelName);\n\t\t},\n\n\t\tasync waitForReady(opts = {}, attempts = 20) {\n\t\t\tif (attempts === 0) {\n\t\t\t\treturn Promise.reject();\n\t\t\t}\n\t\t\treturn this.fetch(opts).then(() => {\n\t\t\t\tif (!this.creation_status) {\n\t\t\t\t\treturn Promise.reject(new Error(\"No creation_status key found\"));\n\t\t\t\t}\n\n\t\t\t\tif ([\"ready\", \"failed\"].indexOf(this.creation_status) > -1) {\n\t\t\t\t\treturn Promise.resolve();\n\t\t\t\t}\n\t\t\t\treturn Promise.delay(1000).then(() =>\n\t\t\t\t\tthis.waitForReady(opts, attempts - 1),\n\t\t\t\t);\n\t\t\t});\n\t\t},\n\n\t\tsync() {\n\t\t\treturn sync.apply(this, arguments);\n\t\t},\n\n\t\tserialize(opts = { derived: true }) {\n\t\t\t// Return nothing if data passed is falsy. More than likely this is\n\t\t\t// a null value\n\t\t\tif (!this._data) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst data = Model.prototype.serialize.apply(this, arguments);\n\t\t\tdata.url = this.url();\n\n\t\t\tlet derived = this.getAttributes(opts);\n\t\t\tderived = Object.keys(derived).reduce((object, key) => {\n\t\t\t\tlet value = derived[key];\n\t\t\t\tif (value instanceof Collection || value instanceof Model) {\n\t\t\t\t\tvalue = value.toJSON();\n\t\t\t\t}\n\t\t\t\tobject[key] = value;\n\t\t\t\treturn object;\n\t\t\t}, {});\n\n\t\t\tObject.keys(this._unsetCollections).forEach((key) => {\n\t\t\t\tif (this._unsetCollections[key].canBeEmpty && !this._values[key]) {\n\t\t\t\t\tderived[key] = [];\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tObject.keys(this._unsetChildren).forEach((key) => {\n\t\t\t\tif (\n\t\t\t\t\tthis._unsetChildren[key].canBeEmpty &&\n\t\t\t\t\t!this._values[key] &&\n\t\t\t\t\tthis[key]\n\t\t\t\t) {\n\t\t\t\t\tderived[key] = this[key].url();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn _.extend(data, derived);\n\t\t},\n\t\t// Safely retrieve the url from a child or collection that may or may not\n\t\t// be hydrated\n\t\t_retrieveURL(item) {\n\t\t\tif (_.isUndefined(item) || item === null) {\n\t\t\t\treturn item;\n\t\t\t} else if (typeof item === \"string\") {\n\t\t\t\t// It's just a url string\n\t\t\t\treturn item;\n\t\t\t} else if (item instanceof Model) {\n\t\t\t\treturn item.isNew() && !item._url ? null : item.url();\n\t\t\t} else if (item instanceof Collection) {\n\t\t\t\treturn _.map(item.toJSON(), \"url\");\n\t\t\t} else if (_.isArray(item)) {\n\t\t\t\t// It's an array of urls or objects\n\t\t\t\treturn item.map((child) => {\n\t\t\t\t\treturn this._retrieveURL(child);\n\t\t\t\t});\n\t\t\t} else if (typeof item === \"object\" && item !== null) {\n\t\t\t\treturn typeof item.url === \"function\" ? item.url() : item.url;\n\t\t\t}\n\n\t\t\treturn null;\n\t\t},\n\t},\n);\n\nfunction replacePropertyDefinition(object, name) {\n\tfunction addCollection(value) {\n\t\tconst data = typeof value === \"string\" ? { url: value } : value;\n\n\t\tconst collection = new object._collections[name](data, { parent: object });\n\t\tobject._expandedValues[name] = collection;\n\n\t\treturn object._expandedValues[name];\n\t}\n\n\tfunction addChild(value) {\n\t\tconst data = typeof value === \"string\" ? { url: value } : value;\n\n\t\tconst child = new object._children[name](data, { parent: object });\n\t\tobject._expandedValues[name] = child;\n\n\t\treturn object._expandedValues[name];\n\t}\n\n\tfunction expandCollection(value) {\n\t\tobject._collections[name] = object._unsetCollections[name];\n\t\tdelete object._unsetCollections[name];\n\n\t\treturn addCollection(value);\n\t}\n\n\tfunction expandChild(value) {\n\t\tobject._children[name] = object._unsetChildren[name];\n\t\tdelete object._unsetChildren[name];\n\n\t\treturn addChild(value);\n\t}\n\n\tObject.defineProperty(object, name, {\n\t\tset(val) {\n\t\t\tif (_.includes(Object.keys(object._children), name)) {\n\t\t\t\tif (val instanceof Model) {\n\t\t\t\t\tobject._expandedValues[name] = val;\n\t\t\t\t} else if (val !== this[name].url()) {\n\t\t\t\t\taddChild(val);\n\t\t\t\t}\n\t\t\t} else if (_.includes(Object.keys(object._collections), name)) {\n\t\t\t\tif (val instanceof Collection) {\n\t\t\t\t\tobject._expandedValues[name] = val;\n\t\t\t\t} else if (this[name].length || val !== this[name].url()) {\n\t\t\t\t\taddCollection(val);\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tval &&\n\t\t\t\tval instanceof Model &&\n\t\t\t\t_.includes(Object.keys(object._unsetChildren), name)\n\t\t\t) {\n\t\t\t\tobject._expandedValues[name] = expandChild(val.toJSON());\n\t\t\t} else if (\n\t\t\t\tval &&\n\t\t\t\tval instanceof Collection &&\n\t\t\t\t_.includes(Object.keys(object._unsetCollections), name)\n\t\t\t) {\n\t\t\t\tobject._expandedValues[name] = expandCollection(val.toJSON());\n\t\t\t} else {\n\t\t\t\tobject._values[name] = val;\n\t\t\t}\n\t\t},\n\t\tget() {\n\t\t\tif (!this._values) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Trying to retrieve value ${name} of model ${object.modelName} during constructor`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(_.includes(Object.keys(object._collections), name) ||\n\t\t\t\t\t_.includes(Object.keys(object._children), name)) &&\n\t\t\t\t_.includes(Object.keys(object._expandedValues), name)\n\t\t\t) {\n\t\t\t\treturn object._expandedValues[name];\n\t\t\t}\n\n\t\t\tconst value = object._values[name];\n\n\t\t\tif (this.isFetching) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(_.isUndefined(value) || value === null) &&\n\t\t\t\t!(\n\t\t\t\t\tobject._unsetChildren[name] && object._unsetChildren[name].canBeEmpty\n\t\t\t\t) &&\n\t\t\t\t!(\n\t\t\t\t\tobject._unsetCollections[name] &&\n\t\t\t\t\tobject._unsetCollections[name].canBeEmpty\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (_.includes(Object.keys(object._unsetCollections), name)) {\n\t\t\t\treturn expandCollection(value);\n\t\t\t} else if (_.includes(Object.keys(object._unsetChildren), name)) {\n\t\t\t\treturn expandChild(value);\n\t\t\t}\n\n\t\t\treturn value;\n\t\t},\n\t\tconfigurable: true,\n\t});\n}\n\n// Make matchesURL available as a static method\nBaseModel.matchesURL = function (url) {\n\treturn this.prototype.matchesURL(url);\n};\n\nBaseModel.getIDFromURL = function (...args) {\n\treturn this.prototype.getIDFromURL(...args);\n};\n"],"mappings":";;;;;;;;;;;AAAA,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,OAAOyN,gBAAgB,CAACtO,KAAK,CAAC;MAC/B,CAAC,MAAM,IAAI+B,eAAC,CAACiK,QAAQ,CAAClI,MAAM,CAACC,IAAI,CAAC+J,MAAM,CAAC5L,cAAc,CAAC,EAAErB,IAAI,CAAC,EAAE;QAChE,OAAO0N,WAAW,CAACvO,KAAK,CAAC;MAC1B;MAEA,OAAOA,KAAK;IACb,CAAC;IACDyO,YAAY,EAAE;EACf,CAAC,CAAC;AACH;;AAEA;AACAzN,SAAS,CAACsG,UAAU,GAAG,UAAU/E,GAAG,EAAE;EACrC,OAAO,IAAI,CAACkB,SAAS,CAAC6D,UAAU,CAAC/E,GAAG,CAAC;AACtC,CAAC;AAEDvB,SAAS,CAACwC,YAAY,GAAG,YAAmB;EAAA,IAAAkL,eAAA;EAC3C,OAAO,CAAAA,eAAA,OAAI,CAACjL,SAAS,EAACD,YAAY,CAAAmG,KAAA,CAAA+E,eAAA,EAAA/M,SAAQ,CAAC;AAC5C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"base.js","names":["_utils","require","_api","_ampersandRestCollection","_interopRequireDefault","_ampersandModel","_bluebird","_superagentBluebirdPromise","_lodash","_dedentJs","_log","_moment","_qs","_stateRegister","_sync2","_url","_templateObject","_createForOfIteratorHelper","r","e","t","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","_n","F","s","n","done","value","f","TypeError","o","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","from","test","BaseModel","exports","Model","extend","modelName","queryData","detailType","isFetching","_isFetched","urlMatchKeys","_data","arguments","undefined","opts","options","_","defaults","data","_unsetChildren","_unsetCollections","_expandedValues","toJSON","isString","url","isNumber","id","dataCopy","_options","_children","clone","_collections","_definition","key","def","isState","Collection","map","obj","registerStates","_convertToValues","getIDFromURL","prototype","_setDerived","_initUnsetValues","_i","_Object$keys","Object","keys","_derived","derivedKey","_i2","_Object$keys2","derivedProp","set","_matchesURL","matchesDetail","urlRoot","Api","getURL","replacements","detailKey","regexes","reduce","result","type","replace","Error","concat","urlWithoutRoot","urlStructure","split","argIndex","findIndex","val","indexOf","attemptedURLWithoutRoot","partial","join","interpolatedString","template","interpolate","log","error","dedent","_taggedTemplateLiteral2","default","baseString","re","RegExp","resource","resourceURL","getResourceURL","urlPath","url2","parse","path","resourceURLPath","resourceEnd","urlEnd","idStr","match","parseInt","matchesURL","dataTypes","date","newVal","moment","utc","format","DATE_FORMAT_T","compare","currentVal","isSame","stringSanitized","removeMultiByteChars","get","any","props","required","toServer","serialize","_registerChildModel","states","prop","model","registeredStates","_registerCollection","state","collection","_this","each","parent","_registerName","_updateResponse","response","_this2","forEach","save","_this3","apply","tap","fetch","_this4","SuperAgentRequest","Auth","headers","then","res","body","isFetched","getSafeAttrs","_this5","isUndefined","_values","attrs","uniq","_this6","_initChildren","child","_safeSet","listenTo","_getCachedEventBubblingHandler","_initCollections","coll","_this7","tmpValue","replacePropertyDefinition","safeSet","property","getFullURLPath","qs","stringify","arrayFormat","isNew","getPlainURL","resp","includes","matches","_iterator","_step","replacement","err","resources","waitForReady","_arguments","_this8","_asyncToGenerator2","_regenerator","mark","_callee","attempts","wrap","_callee$","_context","prev","abrupt","Promise","reject","creation_status","resolve","delay","stop","sync","derived","_ref","_ref$urlsOnly","urlsOnly","getAttributes","object","allCollectionKeys","_toConsumableArray2","_iterator2","_step2","m","canBeEmpty","allChildrenKeys","_iterator3","_step3","_retrieveURL","item","_this9","_typeof2","addCollection","addChild","expandCollection","expandChild","defineProperty","configurable","_this$prototype"],"sources":["../../src/models/base.js"],"sourcesContent":["import { DATE_FORMAT_T, removeMultiByteChars } from \"../utils.js\";\n\nimport { Api } from \"../api.js\";\nimport Collection from \"ampersand-rest-collection\";\nimport Model from \"ampersand-model\";\nimport Promise from \"bluebird\";\nimport SuperAgentRequest from \"superagent-bluebird-promise\";\nimport _ from \"lodash\";\nimport dedent from \"dedent-js\";\nimport log from \"../log.js\";\nimport moment from \"moment\";\nimport qs from \"qs\";\nimport { registeredStates } from \"../state-register.js\";\nimport { sync } from \"../sync.js\";\nimport url2 from \"url\";\n\n/**\n * @constructor\n * @alias models.BaseModel\n */\nexport const BaseModel = Model.extend(\n\t/** @lends models.BaseModel# */ {\n\t\tmodelName: null,\n\t\tqueryData: {},\n\t\tdetailType: \"number\",\n\n\t\t// This is unfortunately necessary to avoid the default ampersand model/state\n\t\t// behaviour from automatically hydrating all children and collections on a fetch.\n\t\tisFetching: false,\n\n\t\t// Useful to figure out whether the model is just a URL (unfetched), or has been\n\t\t// fetched from the server (an object).\n\t\t_isFetched: true,\n\n\t\t// Object of regexes that should be used to match a url in `matchesURL`\n\t\t// For example the URL: /api/foo/{pk}/bar/ might have the following:\n\t\t//\n\t\t// Example:\n\t\t//\n\t\t// ```\n\t\t// {\n\t\t// pk: \"number\"\n\t\t// }\n\t\t// ```\n\t\turlMatchKeys: {},\n\n\t\tconstructor(_data = {}, opts = {}) {\n\t\t\tconst options = _.defaults(opts, {\n\t\t\t\tdata: {},\n\t\t\t});\n\n\t\t\tlet data = _data;\n\n\t\t\tthis._unsetChildren = {};\n\t\t\tthis._unsetCollections = {};\n\t\t\tthis._expandedValues = {};\n\n\t\t\tif (data === null) {\n\t\t\t\tdata = {};\n\t\t\t}\n\n\t\t\t// Allow passing in models\n\t\t\tif (data instanceof Model) {\n\t\t\t\tdata = data.toJSON();\n\t\t\t}\n\n\t\t\tthis.queryData = options.data;\n\n\t\t\t// Convert any strings into a url format we can understand\n\t\t\tif (_.isString(data)) {\n\t\t\t\tdata = { url: data };\n\t\t\t\tthis._isFetched = false;\n\t\t\t}\n\n\t\t\t// Convert model ids into a format we can understand\n\t\t\tif (_.isNumber(data)) {\n\t\t\t\tdata = { id: data };\n\t\t\t\tthis._isFetched = false;\n\t\t\t}\n\n\t\t\tconst dataCopy = _.extend({}, data);\n\n\t\t\tthis._data = dataCopy;\n\t\t\tthis._options = options;\n\n\t\t\t// Stop making edits to these affect other models\n\t\t\tthis._children = _.clone(this._children);\n\t\t\tthis._collections = _.clone(this._collections);\n\t\t\tthis._definition = _.clone(this._definition);\n\n\t\t\t// Check for specialized url returns from the server. This is for when the\n\t\t\t// server responds with an array of urls rather than object data.\n\t\t\tif (dataCopy && typeof dataCopy.url === \"string\") {\n\t\t\t\tthis._url = dataCopy.url;\n\t\t\t}\n\n\t\t\tfor (const key in dataCopy) {\n\t\t\t\tconst def = dataCopy[key];\n\t\t\t\t// Any models/collections passed into the constructor should be\n\t\t\t\t// converted to JSON so that it can be parsed\n\t\t\t\tif (def && (def.isState || def instanceof Collection)) {\n\t\t\t\t\tdataCopy[key] = def.toJSON();\n\t\t\t\t}\n\n\t\t\t\tif (def && Array.isArray(def)) {\n\t\t\t\t\tdataCopy[key] = def.map((obj) => {\n\t\t\t\t\t\tif (obj instanceof Model) {\n\t\t\t\t\t\t\treturn obj.toJSON();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.registerStates();\n\n\t\t\tthis._convertToValues();\n\n\t\t\tconst id = this.getIDFromURL(this._url);\n\n\t\t\tif (!dataCopy.id && id) {\n\t\t\t\tdataCopy.id = id;\n\t\t\t}\n\n\t\t\tModel.prototype.constructor.call(this, dataCopy, options);\n\n\t\t\tthis._setDerived();\n\n\t\t\t// Re-set the values that were previously children or collections\n\t\t\tthis._initUnsetValues();\n\t\t},\n\n\t\t// If there is a model returned from a derived property, and the model\n\t\t// has been initialzied with model data, we manually set the values on it.\n\t\t_setDerived() {\n\t\t\tfor (const derivedKey of Object.keys(this._derived)) {\n\t\t\t\tif (!this._data[derivedKey]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (this[derivedKey] instanceof Model) {\n\t\t\t\t\tfor (const derivedProp of Object.keys(this._data[derivedKey])) {\n\t\t\t\t\t\tthis[derivedKey].set(\n\t\t\t\t\t\t\tderivedProp,\n\t\t\t\t\t\t\tthis._data[derivedKey][derivedProp],\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If it's a collection, we can just pass the data straight in\n\t\t\t\tif (this[derivedKey] instanceof Collection) {\n\t\t\t\t\tthis[derivedKey].set(this._data[derivedKey]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Internal function. Used by collection as well.\n\t\t_matchesURL(url, matchesDetail = true) {\n\t\t\tif (!this.modelName || this.urlRoot() === Api.getURL()) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst replacements = _.extend(\n\t\t\t\t{},\n\t\t\t\t{\n\t\t\t\t\tdetailKey: this.detailType,\n\t\t\t\t},\n\t\t\t\tthis.urlMatchKeys,\n\t\t\t);\n\n\t\t\tconst regexes = Object.keys(replacements).reduce((result, key) => {\n\t\t\t\tconst type = replacements[key];\n\t\t\t\tconst name = key.replace(/\\./g, \"_\");\n\t\t\t\tif (type === \"number\") {\n\t\t\t\t\tresult[name] = \"\\\\d+\";\n\t\t\t\t} else if (type === \"uuid\") {\n\t\t\t\t\tresult[name] = \"([a-z]|[0-9]|-)+\";\n\t\t\t\t} else if (type === \"string\") {\n\t\t\t\t\tresult[name] = \"\\\\w+\";\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Unknown regex type '${type}'.`);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}, {});\n\n\t\t\t// Create a starting regex string with variables. Strips the root url so that it could\n\t\t\t// be read from any server.\n\t\t\tconst urlWithoutRoot = this.urlRoot().replace(Api.getURL(), \"\");\n\t\t\tlet urlStructure = urlWithoutRoot.slice();\n\t\t\tif (matchesDetail) {\n\t\t\t\turlStructure += \"{detailKey}/\";\n\t\t\t}\n\n\t\t\t// Let's test if the url has even a remote chance of matching\n\t\t\t// the url (like a partial match, any part without variables).\n\t\t\t// If that doesn't match, we can sometimes prevent a nasty log\n\t\t\t// error from being thrown.\n\t\t\tconst split = urlStructure.split(\"/\");\n\t\t\tconst argIndex = split.findIndex((val) => {\n\t\t\t\treturn val.indexOf(\"{\") === 0;\n\t\t\t});\n\n\t\t\tif (argIndex >= 0) {\n\t\t\t\tconst attemptedURLWithoutRoot = url.replace(Api.getURL(), \"\");\n\n\t\t\t\tconst partial = split.slice(0, argIndex).join(\"/\");\n\t\t\t\tif (attemptedURLWithoutRoot.indexOf(partial) !== 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Replace keys with regexes\n\t\t\tlet interpolatedString;\n\t\t\ttry {\n\t\t\t\tinterpolatedString = _.template(urlStructure.replace(/\\./g, \"_\"), {\n\t\t\t\t\tinterpolate: /{([\\s\\S\\.]+?)}/g,\n\t\t\t\t})(regexes);\n\t\t\t} catch (e) {\n\t\t\t\tlog.error(\n\t\t\t\t\tdedent`\n\t\t\t\tFailed to match URL '${url}' for model '${this.modelName}'.\n\t\t\t\tThis is usually because the regex type for a key hasn't been set.\n\t\t\t\tError: `,\n\t\t\t\t\te,\n\t\t\t\t);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Convert into a regex and test if url matches\n\t\t\tconst baseString = `.*${interpolatedString.replace(/\\//m, \"/\")}$`;\n\t\t\tconst re = new RegExp(baseString);\n\t\t\treturn re.test(url);\n\t\t},\n\n\t\t// Retrieve the id from the url (if present) without caring about\n\t\t// the hostname.\n\t\t// The url will have a structure like\n\t\t// https://staging-demo.salespreso.com/api/users/1/\n\t\t// and we want to ignore the hostname (https://staging-demo.salespreso.com)\n\t\t// and strip out the '/api' from both the resource url and the variable url\n\t\t// so that we can use the remaining part to isolate the id\n\t\tgetIDFromURL(url, resource = \"\") {\n\t\t\tconst resourceURL = resource || this.getResourceURL();\n\n\t\t\tif (typeof url !== \"string\" || !resourceURL) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst urlPath = url2.parse(url).path;\n\t\t\tconst resourceURLPath = url2.parse(resourceURL).path;\n\n\t\t\t// Remove the '/api' if present\n\t\t\tconst resourceEnd = resourceURLPath.split(\"/api\").join(\"\");\n\t\t\tconst urlEnd = urlPath.split(\"/api\").join(\"\");\n\n\t\t\t// If they are the same, there is no id at the end\n\t\t\tif (!urlEnd || urlEnd === resourceEnd) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst idStr = urlEnd.split(resourceEnd).join(\"\");\n\n\t\t\tif ((idStr.match(/\\//g) || []).length === 1) {\n\t\t\t\treturn parseInt(idStr.slice(0, -1), 10);\n\t\t\t}\n\n\t\t\treturn null;\n\t\t},\n\n\t\t// Public version for details only\n\t\tmatchesURL(url) {\n\t\t\treturn this._matchesURL(url, true);\n\t\t},\n\n\t\tdataTypes: {\n\t\t\tdate: {\n\t\t\t\tset: (newVal) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tval: newVal ? moment.utc(newVal).format(DATE_FORMAT_T) : null,\n\t\t\t\t\t\ttype: \"date\",\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tcompare: (currentVal, newVal) => {\n\t\t\t\t\tif (typeof currentVal === \"undefined\") {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (currentVal || newVal) {\n\t\t\t\t\t\treturn moment(currentVal).isSame(moment(newVal));\n\t\t\t\t\t}\n\t\t\t\t\treturn currentVal !== newVal;\n\t\t\t\t},\n\t\t\t},\n\t\t\tstringSanitized: {\n\t\t\t\tset: (newVal) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tval: newVal ? removeMultiByteChars(newVal) : newVal,\n\t\t\t\t\t\ttype: \"stringSanitized\",\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tcompare: (currentVal, newVal) => {\n\t\t\t\t\treturn currentVal === newVal;\n\t\t\t\t},\n\t\t\t\tget: (val) => {\n\t\t\t\t\treturn val;\n\t\t\t\t},\n\t\t\t},\n\t\t\tany: {\n\t\t\t\tdefault: () => {\n\t\t\t\t\treturn null;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\n\t\t/**\n\t\t * @property {number} [id]\n\t\t */\n\t\tprops: {\n\t\t\tid: { type: \"any\", required: false },\n\t\t},\n\n\t\t/*\n\t\t * Overridable serialization for sending data to\n\t\t * the server\n\t\t */\n\t\ttoServer() {\n\t\t\treturn this.serialize();\n\t\t},\n\n\t\t_registerChildModel(states, prop, model) {\n\t\t\tconst Model = registeredStates[model];\n\t\t\tif (!Model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`'${model}' not found! Did you forget to import it on the '${this.modelName}' model?`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._children[prop] = Model;\n\t\t},\n\n\t\t_registerCollection(state, prop, collection) {\n\t\t\tconst Collection = state[collection];\n\t\t\tif (!Collection) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`'${collection}' not found! Did you forget to import it on the '${this.modelName}' model?`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._collections[prop] = Collection;\n\t\t},\n\n\t\t/*\n\t\t * Replace strings respresenting a registered model/collection the function\n\t\t */\n\t\tregisterStates() {\n\t\t\t// Loop through children and replace any parent objects directly to stop\n\t\t\t// maximum stack overflows\n\t\t\t_.each(\n\t\t\t\tthis._children,\n\t\t\t\t(model, prop) => {\n\t\t\t\t\tif (typeof model === \"string\") {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis._options.parent &&\n\t\t\t\t\t\t\tmodel === this._options.parent._registerName\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// This part is important, if the link stays when there's a circular dependency,\n\t\t\t\t\t\t\t// this will continue forever.\n\t\t\t\t\t\t\tdelete this._children[prop];\n\n\t\t\t\t\t\t\t// Can be a string or an object so we use \"any\". We add the definition\n\t\t\t\t\t\t\t// so that we can retrieve this value later.\n\t\t\t\t\t\t\tthis._definition[prop] = { type: \"any\" };\n\n\t\t\t\t\t\t\tthis[prop] = this._options.parent;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._registerChildModel(registeredStates, prop, model);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tthis,\n\t\t\t);\n\n\t\t\t// Loop throught the collections and replace with the registered collection\n\t\t\t_.each(\n\t\t\t\tthis._collections,\n\t\t\t\t(collection, prop) => {\n\t\t\t\t\tif (typeof collection === \"string\") {\n\t\t\t\t\t\tthis._registerCollection(registeredStates, prop, collection);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tthis,\n\t\t\t);\n\t\t},\n\n\t\t_updateResponse(response) {\n\t\t\tthis._data = response || {};\n\n\t\t\tif (!response) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set previously-initialised children & collections with new\n\t\t\t// data retrieved during the fetch\n\n\t\t\tObject.keys(this._children).forEach((key) => {\n\t\t\t\tif (response[key]) {\n\t\t\t\t\tthis[key] = response[key];\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tObject.keys(this._collections).forEach((key) => {\n\t\t\t\tif (response[key]) {\n\t\t\t\t\tthis[key] = response[key];\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tsave() {\n\t\t\treturn Model.prototype.save.apply(this, arguments).tap((response) => {\n\t\t\t\tthis._updateResponse(response);\n\t\t\t});\n\t\t},\n\n\t\tfetch(options = {}) {\n\t\t\tif (options.url) {\n\t\t\t\tthis._url = options.url;\n\t\t\t}\n\n\t\t\tthis._options = _.extend({}, this._options, options);\n\n\t\t\tthis.isFetching = true;\n\t\t\treturn Model.prototype.fetch.apply(this, arguments).tap((response) => {\n\t\t\t\tthis._isFetched = true;\n\t\t\t\tthis.isFetching = false;\n\t\t\t\tthis._updateResponse(response);\n\t\t\t});\n\t\t},\n\n\t\toptions(options = {}) {\n\t\t\tif (options.url) {\n\t\t\t\tthis._url = options.url;\n\t\t\t}\n\t\t\treturn SuperAgentRequest(\"OPTIONS\", this.url())\n\t\t\t\t.set(BaseModel.Auth.headers)\n\t\t\t\t.then((res) => {\n\t\t\t\t\treturn res.body;\n\t\t\t\t});\n\t\t},\n\n\t\tisFetched() {\n\t\t\treturn this._isFetched;\n\t\t},\n\n\t\tgetSafeAttrs(key) {\n\t\t\tif (!_.isUndefined(key)) {\n\t\t\t\treturn !_.isUndefined(this._expandedValues[key])\n\t\t\t\t\t? this._expandedValues[key]\n\t\t\t\t\t: this._values[key];\n\t\t\t}\n\n\t\t\tconst attrs = {};\n\n\t\t\tconst keys = _.uniq(\n\t\t\t\t_.concat(\n\t\t\t\t\t_.concat(\n\t\t\t\t\t\tObject.keys(this._unsetChildren),\n\t\t\t\t\t\tObject.keys(this._unsetCollections),\n\t\t\t\t\t),\n\t\t\t\t\tObject.keys(this._values),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tkeys.forEach((key) => {\n\t\t\t\tif (!_.isUndefined(this._values[key])) {\n\t\t\t\t\tattrs[key] = this._values[key];\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tObject.keys(this._expandedValues).forEach((key) => {\n\t\t\t\tattrs[key] = this[key];\n\t\t\t});\n\n\t\t\treturn attrs;\n\t\t},\n\n\t\t// Unset all specified children and collection constructors and insert value\n\t\t// definitions for them (necessary for Ampersand State to treat them as values)\n\t\t_convertToValues() {\n\t\t\tObject.keys(this._children).forEach((key) => {\n\t\t\t\tthis._definition[key] = { type: \"any\" };\n\t\t\t\tthis._unsetChildren[key] = this._children[key];\n\t\t\t\tdelete this._children[key];\n\t\t\t});\n\n\t\t\tObject.keys(this._collections).forEach((key) => {\n\t\t\t\tthis._definition[key] = { type: \"any\" };\n\t\t\t\tthis._unsetCollections[key] = this._collections[key];\n\t\t\t\tdelete this._collections[key];\n\t\t\t});\n\t\t},\n\n\t\t// Override the initialization of children to pass in data to the constructor.\n\t\t// The default version always creates an empty model\n\t\t_initChildren() {\n\t\t\tlet child;\n\t\t\tif (!this._children) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (child in this._children) {\n\t\t\t\tlet val = this._data[child];\n\t\t\t\tif (val) {\n\t\t\t\t\t// Assume here that if it's a string, it's a url.\n\t\t\t\t\tif (typeof val === \"string\") {\n\t\t\t\t\t\tval = { url: val };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If hydrate is set to false, this will be the name of the child and\n\t\t\t\t// not the constructor. We want to add the non-hydrated url if so.\n\t\t\t\tif (typeof this._children[child] === \"function\") {\n\t\t\t\t\tthis._safeSet(\n\t\t\t\t\t\tchild,\n\t\t\t\t\t\tnew this._children[child](val, { parent: this }),\n\t\t\t\t\t);\n\t\t\t\t\tthis.listenTo(\n\t\t\t\t\t\tthis[child],\n\t\t\t\t\t\t\"all\",\n\t\t\t\t\t\tthis._getCachedEventBubblingHandler(child),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis._safeSet(child, val);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Override the initialization of collections to pass in data to the constructor.\n\t\t_initCollections() {\n\t\t\tlet coll;\n\t\t\tif (!this._collections) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (coll in this._collections) {\n\t\t\t\tlet val = this._data[coll];\n\t\t\t\tif (val) {\n\t\t\t\t\tif (typeof val === \"string\") {\n\t\t\t\t\t\tval = { url: val };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If hydrate is set to false, this will be the name of the collection and\n\t\t\t\t// not the constructor. We want to add the non-hydrated array if so.\n\t\t\t\tif (typeof this._collections[coll] === \"function\") {\n\t\t\t\t\tthis._safeSet(\n\t\t\t\t\t\tcoll,\n\t\t\t\t\t\tnew this._collections[coll](val, { parent: this }),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis._safeSet(coll, val);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t_initUnsetValues() {\n\t\t\t_.each(this._unsetChildren, (child, key) => {\n\t\t\t\tconst tmpValue = this._values[key];\n\n\t\t\t\treplacePropertyDefinition(this, key);\n\n\t\t\t\tthis[key] = tmpValue;\n\t\t\t});\n\n\t\t\t_.each(this._unsetCollections, (child, key) => {\n\t\t\t\tconst tmpValue = this._values[key];\n\n\t\t\t\treplacePropertyDefinition(this, key);\n\n\t\t\t\tthis[key] = tmpValue;\n\t\t\t});\n\t\t},\n\n\t\t// Make safeSet less safe... as we do need to run this twice\n\t\t_safeSet: function safeSet(property, value) {\n\t\t\tthis[property] = value;\n\t\t\treturn this;\n\t\t},\n\n\t\turlRoot() {\n\t\t\treturn this.getResourceURL();\n\t\t},\n\n\t\tgetFullURLPath(path) {\n\t\t\tif (path === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tlet url = path;\n\t\t\tif (url.slice(-1) !== \"/\" && url.indexOf(\"?\") === -1) {\n\t\t\t\turl += \"/\";\n\t\t\t}\n\n\t\t\tif (Object.keys(this.queryData).length) {\n\t\t\t\turl += `?${qs.stringify(this.queryData, { arrayFormat: \"repeat\" })}`;\n\t\t\t}\n\t\t\treturn url;\n\t\t},\n\n\t\t/*\n\t\t * Get url\n\t\t * @return {String}\n\t\t */\n\t\turl() {\n\t\t\tif (this._url && this.isNew()) {\n\t\t\t\treturn this.getFullURLPath(this._url);\n\t\t\t}\n\t\t\treturn this.getFullURLPath(this.getPlainURL());\n\t\t},\n\n\t\t// Returns url without query data\n\t\tgetPlainURL() {\n\t\t\tif (!this.modelName) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tlet resp = Model.prototype.url.call(this);\n\n\t\t\tif (resp.slice(-1) !== \"/\" && resp.indexOf(\"?\") === -1) {\n\t\t\t\tresp += \"/\";\n\t\t\t}\n\n\t\t\tif (!resp.includes(\"{\") || !resp.includes(\"}\")) {\n\t\t\t\treturn resp;\n\t\t\t}\n\n\t\t\t// Replace any values in a url with one from the model.\n\t\t\t// So if you have /path/to/{model.id}/\n\t\t\t// It will check the model from \"this.model.id\" and replace\n\t\t\t// it in the url\n\t\t\tconst re = /(\\{(?:\\w+\\.?)+\\})/g;\n\t\t\tconst matches = resp.match(re) || [];\n\t\t\tfor (const match of matches) {\n\t\t\t\tconst path = match.slice(1, -1);\n\t\t\t\tconst replacement = _.get(this, path);\n\t\t\t\tif (replacement) {\n\t\t\t\t\tresp = resp.replace(match, replacement);\n\t\t\t\t} else if (!this.isNew()) {\n\t\t\t\t\tlog.error(`Model ${this.modelName} is missing value ${path}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn resp;\n\t\t},\n\n\t\tgetResourceURL() {\n\t\t\tif (this.modelName === null && !Object.keys(Api.resources).length) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (!Object.keys(Api.resources).length) {\n\t\t\t\treturn `/${this.modelName}/`;\n\t\t\t}\n\n\t\t\tif (this.modelName === null) {\n\t\t\t\treturn Api.getURL();\n\t\t\t}\n\t\t\treturn Api.getResourceURL(this.modelName);\n\t\t},\n\n\t\tasync waitForReady(opts = {}, attempts = 20) {\n\t\t\tif (attempts === 0) {\n\t\t\t\treturn Promise.reject();\n\t\t\t}\n\t\t\treturn this.fetch(opts).then(() => {\n\t\t\t\tif (!this.creation_status) {\n\t\t\t\t\treturn Promise.reject(new Error(\"No creation_status key found\"));\n\t\t\t\t}\n\n\t\t\t\tif ([\"ready\", \"failed\"].indexOf(this.creation_status) > -1) {\n\t\t\t\t\treturn Promise.resolve();\n\t\t\t\t}\n\t\t\t\treturn Promise.delay(1000).then(() =>\n\t\t\t\t\tthis.waitForReady(opts, attempts - 1),\n\t\t\t\t);\n\t\t\t});\n\t\t},\n\n\t\tsync() {\n\t\t\treturn sync.apply(this, arguments);\n\t\t},\n\n\t\tserialize(opts = { derived: true }) {\n\t\t\t// Return nothing if data passed is falsy. More than likely this is\n\t\t\t// a null value\n\t\t\tif (!this._data) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\t// Urls only will build a model without its children/collections expanded -\n\t\t\t// it will return urls instead of the full model.\n\t\t\tconst { urlsOnly = false } = opts ?? {};\n\n\t\t\tconst data = Model.prototype.serialize.apply(this, arguments);\n\t\t\tdata.url = this.url();\n\n\t\t\tlet derived = this.getAttributes(opts);\n\t\t\tderived = Object.keys(derived).reduce((object, key) => {\n\t\t\t\tlet value = derived[key];\n\t\t\t\tif (value instanceof Collection || value instanceof Model) {\n\t\t\t\t\tvalue = value.toJSON();\n\t\t\t\t}\n\t\t\t\tobject[key] = value;\n\t\t\t\treturn object;\n\t\t\t}, {});\n\n\t\t\tconst allCollectionKeys = [\n\t\t\t\t...Object.keys(this._unsetCollections),\n\t\t\t\t...Object.keys(this._collections),\n\t\t\t];\n\n\t\t\tfor (const key of allCollectionKeys) {\n\t\t\t\tconst constructor = this._unsetCollections[key];\n\n\t\t\t\tif (urlsOnly && this[key]) {\n\t\t\t\t\tif (typeof this._values[key] === \"string\") {\n\t\t\t\t\t\tderived[key] = this._values[key];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tderived[key] = this[key].map((m) => m.url());\n\t\t\t\t\t}\n\t\t\t\t} else if (!constructor) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (constructor.canBeEmpty && !this._values[key]) {\n\t\t\t\t\tderived[key] = [];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst allChildrenKeys = [\n\t\t\t\t...Object.keys(this._unsetChildren),\n\t\t\t\t...(urlsOnly ? Object.keys(this._children) : []),\n\t\t\t];\n\n\t\t\tfor (const key of allChildrenKeys) {\n\t\t\t\tconst constructor = this._unsetChildren[key];\n\n\t\t\t\tif (urlsOnly && this[key]) {\n\t\t\t\t\tderived[key] = this[key].url();\n\t\t\t\t} else if (!constructor) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (constructor.canBeEmpty && !this._values[key] && this[key]) {\n\t\t\t\t\tderived[key] = this[key].url();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn _.extend(data, derived);\n\t\t},\n\n\t\t// Safely retrieve the url from a child or collection that may or may not\n\t\t// be hydrated\n\t\t_retrieveURL(item) {\n\t\t\tif (_.isUndefined(item) || item === null) {\n\t\t\t\treturn item;\n\t\t\t} else if (typeof item === \"string\") {\n\t\t\t\t// It's just a url string\n\t\t\t\treturn item;\n\t\t\t} else if (item instanceof Model) {\n\t\t\t\treturn item.isNew() && !item._url ? null : item.url();\n\t\t\t} else if (item instanceof Collection) {\n\t\t\t\treturn _.map(item.toJSON(), \"url\");\n\t\t\t} else if (_.isArray(item)) {\n\t\t\t\t// It's an array of urls or objects\n\t\t\t\treturn item.map((child) => {\n\t\t\t\t\treturn this._retrieveURL(child);\n\t\t\t\t});\n\t\t\t} else if (typeof item === \"object\" && item !== null) {\n\t\t\t\treturn typeof item.url === \"function\" ? item.url() : item.url;\n\t\t\t}\n\n\t\t\treturn null;\n\t\t},\n\t},\n);\n\nfunction replacePropertyDefinition(object, name) {\n\tfunction addCollection(value) {\n\t\tconst data = typeof value === \"string\" ? { url: value } : value;\n\n\t\tconst collection = new object._collections[name](data, { parent: object });\n\t\tobject._expandedValues[name] = collection;\n\n\t\treturn object._expandedValues[name];\n\t}\n\n\tfunction addChild(value) {\n\t\tconst data = typeof value === \"string\" ? { url: value } : value;\n\n\t\tconst child = new object._children[name](data, { parent: object });\n\t\tobject._expandedValues[name] = child;\n\n\t\treturn object._expandedValues[name];\n\t}\n\n\tfunction expandCollection(value) {\n\t\tobject._collections[name] = object._unsetCollections[name];\n\t\tdelete object._unsetCollections[name];\n\n\t\treturn addCollection(value);\n\t}\n\n\tfunction expandChild(value) {\n\t\tobject._children[name] = object._unsetChildren[name];\n\t\tdelete object._unsetChildren[name];\n\n\t\treturn addChild(value);\n\t}\n\n\tObject.defineProperty(object, name, {\n\t\tset(val) {\n\t\t\tif (_.includes(Object.keys(object._children), name)) {\n\t\t\t\tif (val instanceof Model) {\n\t\t\t\t\tobject._expandedValues[name] = val;\n\t\t\t\t} else if (val !== this[name].url()) {\n\t\t\t\t\taddChild(val);\n\t\t\t\t}\n\t\t\t} else if (_.includes(Object.keys(object._collections), name)) {\n\t\t\t\tif (val instanceof Collection) {\n\t\t\t\t\tobject._expandedValues[name] = val;\n\t\t\t\t} else if (this[name].length || val !== this[name].url()) {\n\t\t\t\t\taddCollection(val);\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tval &&\n\t\t\t\tval instanceof Model &&\n\t\t\t\t_.includes(Object.keys(object._unsetChildren), name)\n\t\t\t) {\n\t\t\t\tobject._expandedValues[name] = expandChild(val.toJSON());\n\t\t\t} else if (\n\t\t\t\tval &&\n\t\t\t\tval instanceof Collection &&\n\t\t\t\t_.includes(Object.keys(object._unsetCollections), name)\n\t\t\t) {\n\t\t\t\tobject._expandedValues[name] = expandCollection(val.toJSON());\n\t\t\t} else {\n\t\t\t\tobject._values[name] = val;\n\t\t\t}\n\t\t},\n\t\tget() {\n\t\t\tif (!this._values) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Trying to retrieve value ${name} of model ${object.modelName} during constructor`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(_.includes(Object.keys(object._collections), name) ||\n\t\t\t\t\t_.includes(Object.keys(object._children), name)) &&\n\t\t\t\t_.includes(Object.keys(object._expandedValues), name)\n\t\t\t) {\n\t\t\t\treturn object._expandedValues[name];\n\t\t\t}\n\n\t\t\tconst value = object._values[name];\n\n\t\t\tif (this.isFetching) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(_.isUndefined(value) || value === null) &&\n\t\t\t\t!(\n\t\t\t\t\tobject._unsetChildren[name] && object._unsetChildren[name].canBeEmpty\n\t\t\t\t) &&\n\t\t\t\t!(\n\t\t\t\t\tobject._unsetCollections[name] &&\n\t\t\t\t\tobject._unsetCollections[name].canBeEmpty\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (_.includes(Object.keys(object._unsetCollections), name)) {\n\t\t\t\treturn expandCollection(value);\n\t\t\t} else if (_.includes(Object.keys(object._unsetChildren), name)) {\n\t\t\t\treturn expandChild(value);\n\t\t\t}\n\n\t\t\treturn value;\n\t\t},\n\t\tconfigurable: true,\n\t});\n}\n\n// Make matchesURL available as a static method\nBaseModel.matchesURL = function (url) {\n\treturn this.prototype.matchesURL(url);\n};\n\nBaseModel.getIDFromURL = function (...args) {\n\treturn this.prototype.getIDFromURL(...args);\n};\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,SAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,0BAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,OAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,SAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,IAAA,GAAAN,sBAAA,CAAAH,OAAA;AACA,IAAAU,OAAA,GAAAP,sBAAA,CAAAH,OAAA;AACA,IAAAW,GAAA,GAAAR,sBAAA,CAAAH,OAAA;AACA,IAAAY,cAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,IAAA,GAAAX,sBAAA,CAAAH,OAAA;AAAuB,IAAAe,eAAA;AAAA,SAAAC,2BAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,yBAAAC,MAAA,IAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,CAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,CAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,CAAA,IAAAD,CAAA,uBAAAA,CAAA,CAAAQ,MAAA,IAAAN,CAAA,KAAAF,CAAA,GAAAE,CAAA,OAAAO,EAAA,MAAAC,CAAA,YAAAA,EAAA,eAAAC,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAA,EAAA,WAAAH,EAAA,IAAAT,CAAA,CAAAQ,MAAA,KAAAK,IAAA,WAAAA,IAAA,MAAAC,KAAA,EAAAd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AACD,YAAY,CAAAmG,KAAA,CAAAyF,eAAA,EAAAzN,SAAQ,CAAC;AAC5C,CAAC","ignoreList":[]}
@@ -433,4 +433,32 @@ describe(".matchesURL", function () {
433
433
  expect(ActivityModel.matchesURL(url)).toEqual(true);
434
434
  });
435
435
  });
436
+ it("should allow serializing collections with urls only", function () {
437
+ (0, _api2.G)(_base2.BaseModel.extend({
438
+ modelName: "baz"
439
+ }), "TestModel");
440
+ (0, _api2.G)(_base.BaseCollection.extend({
441
+ model: "TestModel"
442
+ }), "TestCollection");
443
+ var Model = (0, _api2.G)(_base2.BaseModel.extend({
444
+ collections: {
445
+ tests: "TestCollection"
446
+ }
447
+ }));
448
+ var model = new Model({
449
+ tests: [{
450
+ id: 1,
451
+ url: "/api/baz/1/"
452
+ }, {
453
+ id: 2,
454
+ url: "/api/baz/2/"
455
+ }]
456
+ });
457
+ expect(model.serialize({
458
+ urlsOnly: true
459
+ })).toEqual({
460
+ url: null,
461
+ tests: ["/api/baz/1/", "/api/baz/2/"]
462
+ });
463
+ });
436
464
  //# sourceMappingURL=base.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.spec.js","names":["_api","require","_base","_base2","_utils","_api2","_log","_interopRequireDefault","_moment","_testdouble","it","TestModel","BaseModel","extend","props","testDate","model","date","moment","utc","expect","toEqual","format","DATE_FORMAT_T","model2","date2","Model","begin","URL","url","G","modelName","children","test","toBeInstanceOf","id","parent","toThrow","testModel","TestCollection","BaseCollection","collections","tests","first","mustFail","at","normalString","control","withSpace","withoutSpace","withSpecialCharacters","foo","firstModel","secondModel","testURL","getResourceURL","prototype","jest","fn","DerivedModel","name","derived","myDerivedModel","DerivedCollection","myDerivedCollection","describe","matchesURL","errorFn","spyOn","log","mockImplementation","not","toBeCalled","urlMatchKeys","bar","endpoint","td","replace","Api","ActivityModel","concat"],"sources":["../../src/models/base.spec.js"],"sourcesContent":["import { Api } from \"../api.js\";\nimport { BaseCollection } from \"../collections/base.js\";\nimport { BaseModel } from \"./base.js\";\nimport { DATE_FORMAT_T } from \"../utils.js\";\nimport { G } from \"sp-test/api\";\nimport log from \"../log.js\";\nimport moment from \"moment\";\nimport td from \"testdouble\";\n\nit(\"should set date types correctly (SP-2698)\", () => {\n\tconst TestModel = BaseModel.extend({ props: { testDate: \"date\" } });\n\n\tconst model = new TestModel();\n\tconst date = moment.utc();\n\tmodel.testDate = date;\n\n\texpect(model.testDate).toEqual(date.format(DATE_FORMAT_T));\n\n\tconst model2 = new TestModel();\n\tconst date2 = moment.utc();\n\tmodel2.testDate = date2;\n\n\texpect(model2.testDate).toEqual(date2.format(DATE_FORMAT_T));\n});\n\nit(\"should accept moment object for date types\", () => {\n\tconst Model = BaseModel.extend({ props: { begin: \"date\" } });\n\tconst model = new Model({ begin: moment(\"2014-04-25T01:32:21.196000Z\") });\n\texpect(model.begin).toEqual(\"2014-04-25T01:32:21.196000Z\");\n});\n\nit(\"should override url if passed to constructor\", () => {\n\tconst URL = \"path/to/api/\";\n\tconst Model = BaseModel.extend();\n\tconst model = new Model({ url: URL });\n\texpect(URL).toEqual(model.url());\n});\n\nit(\"should append a trailing slash to urls if not there\", () => {\n\tconst Model = G(BaseModel.extend({ modelName: \"tests\" }));\n\tconst model = new Model({ url: \"/api/tests\" });\n\texpect(model.url()).toEqual(\"/api/tests/\");\n});\n\nit(\"should not append a slash to a get query\", () => {\n\tconst Model = G(BaseModel.extend({ modelName: \"tests\" }));\n\tconst model = new Model({ url: \"/api/tests/?foo=bar\" });\n\texpect(model.url()).toEqual(\"/api/tests/?foo=bar\");\n});\n\nit(\"should replace child model strings with the registered model\", () => {\n\tconst TestModel = G(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: 1 });\n\texpect(model.test).toBeInstanceOf(TestModel);\n});\n\nit(\"should allow the model to be passed in\", () => {\n\tconst TestModel = G(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: new TestModel({ id: 1 }) });\n\texpect(model.test.id).toEqual(1);\n\texpect(model.test).toBeInstanceOf(TestModel);\n});\n\nit(\"should reference parent model if foreign key exists\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: 1 });\n\texpect(model).toEqual(model.test.parent);\n});\n\nit(\"should throw an error if the child model doesn't exist\", () => {\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"DoesntExist\" },\n\t\t}),\n\t);\n\n\texpect(() => new Model()).toThrow();\n});\n\nit(\"should convert a url into a model\", () => {\n\tG(BaseModel.extend({ modelName: \"tests\" }), \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: \"/api/tests/1/\" });\n\texpect(model.test.id).toEqual(1);\n});\n\nit(\"should convert an id into a model\", () => {\n\tconst TestModel = BaseModel.extend({ modelName: \"test\" });\n\tconst testModel = new TestModel(1);\n\texpect(testModel.id).toEqual(1);\n\texpect(testModel.url()).toEqual(\"/test/1/\");\n});\n\nit(\"should convert an object into a model\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: { id: 1 } });\n\texpect(model.test.id).toEqual(1);\n});\n\nit(\"should replace collection strings with their registered state\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst TestCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({\n\t\ttests: [{ id: 1 }],\n\t});\n\texpect(model.tests).toBeInstanceOf(TestCollection);\n});\n\nit(\"should allow a list of models to be passed into a collection\", () => {\n\tconst TestModel = G(BaseModel, \"TestModel\");\n\tG(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst test = new TestModel({ id: 1 });\n\tconst model = new Model({\n\t\ttests: [test],\n\t});\n\texpect(model.tests.first().id).toEqual(1);\n});\n\nit(\"should allow a collection to be passed in directly\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst TestCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({\n\t\ttests: new TestCollection([{ id: 1 }]),\n\t});\n\texpect(model.tests).toBeInstanceOf(TestCollection);\n});\n\nit(\"should throw an error if the child collection doesn't exist\", () => {\n\tconst Model = BaseModel.extend({\n\t\tcollections: { mustFail: \"DoesntExist\" },\n\t});\n\texpect(() => new Model()).toThrow();\n});\n\nit(\"should convert a url into a collection\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst TestCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({ tests: \"/api/tests/\" });\n\texpect(model.tests).toBeInstanceOf(TestCollection);\n});\n\nit(\"should convert an array of objects into a collection\", () => {\n\tG(BaseModel, \"TestModel\");\n\tG(BaseCollection.extend({ model: \"TestModel\" }), \"TestCollection\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({\n\t\ttests: [{ id: 1 }, { id: 2 }],\n\t});\n\texpect(model.tests.at(0).id).toEqual(1);\n\texpect(model.tests.at(1).id).toEqual(2);\n});\n\nit(\"should correctly sanitize strings of multibyte characters (preserving spaces)\", () => {\n\tconst TestModel = BaseModel.extend({\n\t\tprops: {\n\t\t\tnormalString: \"string\",\n\t\t\tcontrol: \"stringSanitized\",\n\t\t\twithSpace: \"stringSanitized\",\n\t\t\twithoutSpace: \"stringSanitized\",\n\t\t\twithSpecialCharacters: \"stringSanitized\",\n\t\t},\n\t});\n\n\tconst model = new TestModel({\n\t\tnormalString: \"A’ B Cç\",\n\t\tcontrol: \"ABC\",\n\t\twithSpace: \"A’ B Cç\",\n\t\twithoutSpace: \"AãB®C\",\n\t\twithSpecialCharacters: \"!@#$%^&*()_+\",\n\t});\n\n\texpect(model.normalString).toEqual(\"A’ B Cç\");\n\texpect(model.control).toEqual(\"ABC\");\n\texpect(model.withSpace).toEqual(\"A B C\");\n\texpect(model.withoutSpace).toEqual(\"ABC\");\n\texpect(model.withSpecialCharacters).toEqual(\"!@#$%^&*()_+\");\n});\n\nit(\"should allow passing in another model into a model\", () => {\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t\tprops: {\n\t\t\tfoo: \"string\",\n\t\t},\n\t});\n\n\tconst firstModel = new TestModel({ foo: \"bar\" });\n\tconst secondModel = new TestModel(firstModel);\n\n\texpect(secondModel.foo).toEqual(\"bar\");\n});\n\nit(\"should retrieve the ID when there is no resource URL\", () => {\n\tconst testURL = \"http://localhost:9980/api/test/34/\";\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t});\n\n\tconst testModel = new TestModel({ url: testURL });\n\n\texpect(testModel.getResourceURL()).toEqual(\"/test/\");\n\texpect(testModel.id).toEqual(34);\n});\n\nit(\"should retrieve the ID when the resource URL is the same as the hostname\", () => {\n\tconst testURL = \"http://localhost:9980/api/test/34/\";\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t});\n\n\tTestModel.prototype.getResourceURL = jest.fn(() => {\n\t\treturn \"http://localhost:9980/api/test/\";\n\t});\n\n\tconst testModel = new TestModel({ url: testURL });\n\n\texpect(testModel.id).toEqual(34);\n});\n\nit(\"should retrieve the ID when the resource hostname is different to the URL hostname\", () => {\n\tconst testURL = \"http://some-hostname/api/test/34/\";\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t});\n\n\tTestModel.prototype.getResourceURL = jest.fn(() => {\n\t\treturn \"http://localhost:9980/api/test/\";\n\t});\n\n\tconst testModel = new TestModel({ url: testURL });\n\n\texpect(testModel.id).toEqual(34);\n});\n\nit(\"should pass through values into a derived model\", () => {\n\tconst DerivedModel = BaseModel.extend({\n\t\tmodelName: \"derived\",\n\t\tprops: {\n\t\t\tname: \"string\",\n\t\t},\n\t});\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t\tderived: {\n\t\t\tmyDerivedModel: {\n\t\t\t\tfn() {\n\t\t\t\t\treturn new DerivedModel();\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\tconst model = new TestModel({ myDerivedModel: { id: 1, name: \"foo\" } });\n\texpect(model.myDerivedModel.id).toEqual(1);\n\texpect(model.myDerivedModel.name).toEqual(\"foo\");\n});\n\nit(\"should pass through values into a derived collection\", () => {\n\tG(\n\t\tBaseModel.extend({\n\t\t\tmodelName: \"derived\",\n\t\t\tprops: {\n\t\t\t\tname: \"string\",\n\t\t\t},\n\t\t}),\n\t\t\"DerivedModel\",\n\t);\n\n\tconst DerivedCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"DerivedModel\",\n\t\t}),\n\t);\n\n\tconst TestModel = G(\n\t\tBaseModel.extend({\n\t\t\tmodelName: \"test\",\n\t\t\tderived: {\n\t\t\t\tmyDerivedCollection: {\n\t\t\t\t\tfn() {\n\t\t\t\t\t\treturn new DerivedCollection();\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t\t\"TestModel\",\n\t);\n\n\tconst model = new TestModel({\n\t\tmyDerivedCollection: [{ id: 1, name: \"foo\" }],\n\t});\n\texpect(model.myDerivedCollection.first().id).toEqual(1);\n\texpect(model.myDerivedCollection.first().name).toEqual(\"foo\");\n});\n\ndescribe(\".matchesURL\", () => {\n\tit(\"should have a model match the right url\", () => {\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"foo\",\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/foo/1/\")).toEqual(true);\n\t});\n\n\tit(\"should have a model not match the wrong url\", () => {\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"foo\",\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/bar/1/\")).toEqual(false);\n\t});\n\n\tit(\"should not throw a nasty error when url isn't even close\", () => {\n\t\tconst errorFn = jest.spyOn(log, \"error\").mockImplementation(jest.fn());\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"bar\",\n\t\t\tgetResourceURL() {\n\t\t\t\treturn \"/api/bar/{foo}/\";\n\t\t\t},\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/foo/1/\")).toEqual(false);\n\t\texpect(errorFn).not.toBeCalled();\n\t});\n\n\tit(\"should throw an error if url matches, but it isn't set up right\", () => {\n\t\tconst errorFn = jest.spyOn(log, \"error\").mockImplementation(jest.fn());\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"bar\",\n\t\t\tgetResourceURL() {\n\t\t\t\treturn \"/api/bar/{foo}/\";\n\t\t\t},\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/bar/1/\")).toEqual(false);\n\t\texpect(errorFn).toBeCalled();\n\t});\n\n\tit(\"should expect values passed in through url match keys\", () => {\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"bar\",\n\t\t\turlMatchKeys: {\n\t\t\t\tfoo: \"string\",\n\t\t\t\tbar: \"number\",\n\t\t\t},\n\t\t\tgetResourceURL() {\n\t\t\t\treturn \"/api/bar/{bar}/{foo}/\";\n\t\t\t},\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/bar/1/hello/1/\")).toEqual(true);\n\t});\n\n\tit(\"should match with the full server endpoint included\", () => {\n\t\tconst endpoint = \"http://localhost:8000/api/\";\n\t\ttd.replace(Api, \"getURL\", () => endpoint);\n\t\tconst url = \"http://localhost:8000/api/activities/2719/\";\n\t\tconst ActivityModel = G(\"ActivityItemModel\").extend({\n\t\t\tgetResourceURL() {\n\t\t\t\treturn `${endpoint}activities/`;\n\t\t\t},\n\t\t});\n\t\texpect(ActivityModel.matchesURL(url)).toEqual(true);\n\t});\n});\n"],"mappings":";;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,OAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,WAAA,GAAAF,sBAAA,CAAAN,OAAA;AAEAS,EAAE,CAAC,2CAA2C,EAAE,YAAM;EACrD,IAAMC,SAAS,GAAGC,gBAAS,CAACC,MAAM,CAAC;IAAEC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAO;EAAE,CAAC,CAAC;EAEnE,IAAMC,KAAK,GAAG,IAAIL,SAAS,CAAC,CAAC;EAC7B,IAAMM,IAAI,GAAGC,eAAM,CAACC,GAAG,CAAC,CAAC;EACzBH,KAAK,CAACD,QAAQ,GAAGE,IAAI;EAErBG,MAAM,CAACJ,KAAK,CAACD,QAAQ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4BAA4B;IAC7CC,mBAAE,CAACC,OAAO,CAACC,QAAG,EAAE,QAAQ,EAAE;MAAA,OAAMH,QAAQ;IAAA,EAAC;IACzC,IAAM9C,GAAG,GAAG,4CAA4C;IACxD,IAAMkD,aAAa,GAAG,IAAAjD,OAAC,EAAC,mBAAmB,CAAC,CAACjB,MAAM,CAAC;MACnD0C,cAAc,WAAdA,cAAcA,CAAA,EAAG;QAChB,UAAAyB,MAAA,CAAUL,QAAQ;MACnB;IACD,CAAC,CAAC;IACFvD,MAAM,CAAC2D,aAAa,CAACb,UAAU,CAACrC,GAAG,CAAC,CAAC,CAACR,OAAO,CAAC,IAAI,CAAC;EACpD,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"base.spec.js","names":["_api","require","_base","_base2","_utils","_api2","_log","_interopRequireDefault","_moment","_testdouble","it","TestModel","BaseModel","extend","props","testDate","model","date","moment","utc","expect","toEqual","format","DATE_FORMAT_T","model2","date2","Model","begin","URL","url","G","modelName","children","test","toBeInstanceOf","id","parent","toThrow","testModel","TestCollection","BaseCollection","collections","tests","first","mustFail","at","normalString","control","withSpace","withoutSpace","withSpecialCharacters","foo","firstModel","secondModel","testURL","getResourceURL","prototype","jest","fn","DerivedModel","name","derived","myDerivedModel","DerivedCollection","myDerivedCollection","describe","matchesURL","errorFn","spyOn","log","mockImplementation","not","toBeCalled","urlMatchKeys","bar","endpoint","td","replace","Api","ActivityModel","concat","serialize","urlsOnly"],"sources":["../../src/models/base.spec.js"],"sourcesContent":["import { Api } from \"../api.js\";\nimport { BaseCollection } from \"../collections/base.js\";\nimport { BaseModel } from \"./base.js\";\nimport { DATE_FORMAT_T } from \"../utils.js\";\nimport { G } from \"sp-test/api\";\nimport log from \"../log.js\";\nimport moment from \"moment\";\nimport td from \"testdouble\";\n\nit(\"should set date types correctly (SP-2698)\", () => {\n\tconst TestModel = BaseModel.extend({ props: { testDate: \"date\" } });\n\n\tconst model = new TestModel();\n\tconst date = moment.utc();\n\tmodel.testDate = date;\n\n\texpect(model.testDate).toEqual(date.format(DATE_FORMAT_T));\n\n\tconst model2 = new TestModel();\n\tconst date2 = moment.utc();\n\tmodel2.testDate = date2;\n\n\texpect(model2.testDate).toEqual(date2.format(DATE_FORMAT_T));\n});\n\nit(\"should accept moment object for date types\", () => {\n\tconst Model = BaseModel.extend({ props: { begin: \"date\" } });\n\tconst model = new Model({ begin: moment(\"2014-04-25T01:32:21.196000Z\") });\n\texpect(model.begin).toEqual(\"2014-04-25T01:32:21.196000Z\");\n});\n\nit(\"should override url if passed to constructor\", () => {\n\tconst URL = \"path/to/api/\";\n\tconst Model = BaseModel.extend();\n\tconst model = new Model({ url: URL });\n\texpect(URL).toEqual(model.url());\n});\n\nit(\"should append a trailing slash to urls if not there\", () => {\n\tconst Model = G(BaseModel.extend({ modelName: \"tests\" }));\n\tconst model = new Model({ url: \"/api/tests\" });\n\texpect(model.url()).toEqual(\"/api/tests/\");\n});\n\nit(\"should not append a slash to a get query\", () => {\n\tconst Model = G(BaseModel.extend({ modelName: \"tests\" }));\n\tconst model = new Model({ url: \"/api/tests/?foo=bar\" });\n\texpect(model.url()).toEqual(\"/api/tests/?foo=bar\");\n});\n\nit(\"should replace child model strings with the registered model\", () => {\n\tconst TestModel = G(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: 1 });\n\texpect(model.test).toBeInstanceOf(TestModel);\n});\n\nit(\"should allow the model to be passed in\", () => {\n\tconst TestModel = G(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: new TestModel({ id: 1 }) });\n\texpect(model.test.id).toEqual(1);\n\texpect(model.test).toBeInstanceOf(TestModel);\n});\n\nit(\"should reference parent model if foreign key exists\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: 1 });\n\texpect(model).toEqual(model.test.parent);\n});\n\nit(\"should throw an error if the child model doesn't exist\", () => {\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"DoesntExist\" },\n\t\t}),\n\t);\n\n\texpect(() => new Model()).toThrow();\n});\n\nit(\"should convert a url into a model\", () => {\n\tG(BaseModel.extend({ modelName: \"tests\" }), \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: \"/api/tests/1/\" });\n\texpect(model.test.id).toEqual(1);\n});\n\nit(\"should convert an id into a model\", () => {\n\tconst TestModel = BaseModel.extend({ modelName: \"test\" });\n\tconst testModel = new TestModel(1);\n\texpect(testModel.id).toEqual(1);\n\texpect(testModel.url()).toEqual(\"/test/1/\");\n});\n\nit(\"should convert an object into a model\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tchildren: { test: \"TestModel\" },\n\t\t}),\n\t);\n\tconst model = new Model({ test: { id: 1 } });\n\texpect(model.test.id).toEqual(1);\n});\n\nit(\"should replace collection strings with their registered state\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst TestCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({\n\t\ttests: [{ id: 1 }],\n\t});\n\texpect(model.tests).toBeInstanceOf(TestCollection);\n});\n\nit(\"should allow a list of models to be passed into a collection\", () => {\n\tconst TestModel = G(BaseModel, \"TestModel\");\n\tG(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst test = new TestModel({ id: 1 });\n\tconst model = new Model({\n\t\ttests: [test],\n\t});\n\texpect(model.tests.first().id).toEqual(1);\n});\n\nit(\"should allow a collection to be passed in directly\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst TestCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({\n\t\ttests: new TestCollection([{ id: 1 }]),\n\t});\n\texpect(model.tests).toBeInstanceOf(TestCollection);\n});\n\nit(\"should throw an error if the child collection doesn't exist\", () => {\n\tconst Model = BaseModel.extend({\n\t\tcollections: { mustFail: \"DoesntExist\" },\n\t});\n\texpect(() => new Model()).toThrow();\n});\n\nit(\"should convert a url into a collection\", () => {\n\tG(BaseModel, \"TestModel\");\n\tconst TestCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"TestModel\",\n\t\t}),\n\t\t\"TestCollection\",\n\t);\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({ tests: \"/api/tests/\" });\n\texpect(model.tests).toBeInstanceOf(TestCollection);\n});\n\nit(\"should convert an array of objects into a collection\", () => {\n\tG(BaseModel, \"TestModel\");\n\tG(BaseCollection.extend({ model: \"TestModel\" }), \"TestCollection\");\n\tconst Model = G(\n\t\tBaseModel.extend({\n\t\t\tcollections: { tests: \"TestCollection\" },\n\t\t}),\n\t);\n\tconst model = new Model({\n\t\ttests: [{ id: 1 }, { id: 2 }],\n\t});\n\texpect(model.tests.at(0).id).toEqual(1);\n\texpect(model.tests.at(1).id).toEqual(2);\n});\n\nit(\"should correctly sanitize strings of multibyte characters (preserving spaces)\", () => {\n\tconst TestModel = BaseModel.extend({\n\t\tprops: {\n\t\t\tnormalString: \"string\",\n\t\t\tcontrol: \"stringSanitized\",\n\t\t\twithSpace: \"stringSanitized\",\n\t\t\twithoutSpace: \"stringSanitized\",\n\t\t\twithSpecialCharacters: \"stringSanitized\",\n\t\t},\n\t});\n\n\tconst model = new TestModel({\n\t\tnormalString: \"A’ B Cç\",\n\t\tcontrol: \"ABC\",\n\t\twithSpace: \"A’ B Cç\",\n\t\twithoutSpace: \"AãB®C\",\n\t\twithSpecialCharacters: \"!@#$%^&*()_+\",\n\t});\n\n\texpect(model.normalString).toEqual(\"A’ B Cç\");\n\texpect(model.control).toEqual(\"ABC\");\n\texpect(model.withSpace).toEqual(\"A B C\");\n\texpect(model.withoutSpace).toEqual(\"ABC\");\n\texpect(model.withSpecialCharacters).toEqual(\"!@#$%^&*()_+\");\n});\n\nit(\"should allow passing in another model into a model\", () => {\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t\tprops: {\n\t\t\tfoo: \"string\",\n\t\t},\n\t});\n\n\tconst firstModel = new TestModel({ foo: \"bar\" });\n\tconst secondModel = new TestModel(firstModel);\n\n\texpect(secondModel.foo).toEqual(\"bar\");\n});\n\nit(\"should retrieve the ID when there is no resource URL\", () => {\n\tconst testURL = \"http://localhost:9980/api/test/34/\";\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t});\n\n\tconst testModel = new TestModel({ url: testURL });\n\n\texpect(testModel.getResourceURL()).toEqual(\"/test/\");\n\texpect(testModel.id).toEqual(34);\n});\n\nit(\"should retrieve the ID when the resource URL is the same as the hostname\", () => {\n\tconst testURL = \"http://localhost:9980/api/test/34/\";\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t});\n\n\tTestModel.prototype.getResourceURL = jest.fn(() => {\n\t\treturn \"http://localhost:9980/api/test/\";\n\t});\n\n\tconst testModel = new TestModel({ url: testURL });\n\n\texpect(testModel.id).toEqual(34);\n});\n\nit(\"should retrieve the ID when the resource hostname is different to the URL hostname\", () => {\n\tconst testURL = \"http://some-hostname/api/test/34/\";\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t});\n\n\tTestModel.prototype.getResourceURL = jest.fn(() => {\n\t\treturn \"http://localhost:9980/api/test/\";\n\t});\n\n\tconst testModel = new TestModel({ url: testURL });\n\n\texpect(testModel.id).toEqual(34);\n});\n\nit(\"should pass through values into a derived model\", () => {\n\tconst DerivedModel = BaseModel.extend({\n\t\tmodelName: \"derived\",\n\t\tprops: {\n\t\t\tname: \"string\",\n\t\t},\n\t});\n\tconst TestModel = BaseModel.extend({\n\t\tmodelName: \"test\",\n\t\tderived: {\n\t\t\tmyDerivedModel: {\n\t\t\t\tfn() {\n\t\t\t\t\treturn new DerivedModel();\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\tconst model = new TestModel({ myDerivedModel: { id: 1, name: \"foo\" } });\n\texpect(model.myDerivedModel.id).toEqual(1);\n\texpect(model.myDerivedModel.name).toEqual(\"foo\");\n});\n\nit(\"should pass through values into a derived collection\", () => {\n\tG(\n\t\tBaseModel.extend({\n\t\t\tmodelName: \"derived\",\n\t\t\tprops: {\n\t\t\t\tname: \"string\",\n\t\t\t},\n\t\t}),\n\t\t\"DerivedModel\",\n\t);\n\n\tconst DerivedCollection = G(\n\t\tBaseCollection.extend({\n\t\t\tmodel: \"DerivedModel\",\n\t\t}),\n\t);\n\n\tconst TestModel = G(\n\t\tBaseModel.extend({\n\t\t\tmodelName: \"test\",\n\t\t\tderived: {\n\t\t\t\tmyDerivedCollection: {\n\t\t\t\t\tfn() {\n\t\t\t\t\t\treturn new DerivedCollection();\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t\t\"TestModel\",\n\t);\n\n\tconst model = new TestModel({\n\t\tmyDerivedCollection: [{ id: 1, name: \"foo\" }],\n\t});\n\texpect(model.myDerivedCollection.first().id).toEqual(1);\n\texpect(model.myDerivedCollection.first().name).toEqual(\"foo\");\n});\n\ndescribe(\".matchesURL\", () => {\n\tit(\"should have a model match the right url\", () => {\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"foo\",\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/foo/1/\")).toEqual(true);\n\t});\n\n\tit(\"should have a model not match the wrong url\", () => {\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"foo\",\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/bar/1/\")).toEqual(false);\n\t});\n\n\tit(\"should not throw a nasty error when url isn't even close\", () => {\n\t\tconst errorFn = jest.spyOn(log, \"error\").mockImplementation(jest.fn());\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"bar\",\n\t\t\tgetResourceURL() {\n\t\t\t\treturn \"/api/bar/{foo}/\";\n\t\t\t},\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/foo/1/\")).toEqual(false);\n\t\texpect(errorFn).not.toBeCalled();\n\t});\n\n\tit(\"should throw an error if url matches, but it isn't set up right\", () => {\n\t\tconst errorFn = jest.spyOn(log, \"error\").mockImplementation(jest.fn());\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"bar\",\n\t\t\tgetResourceURL() {\n\t\t\t\treturn \"/api/bar/{foo}/\";\n\t\t\t},\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/bar/1/\")).toEqual(false);\n\t\texpect(errorFn).toBeCalled();\n\t});\n\n\tit(\"should expect values passed in through url match keys\", () => {\n\t\tconst TestModel = G(BaseModel, \"TestModel\").extend({\n\t\t\tmodelName: \"bar\",\n\t\t\turlMatchKeys: {\n\t\t\t\tfoo: \"string\",\n\t\t\t\tbar: \"number\",\n\t\t\t},\n\t\t\tgetResourceURL() {\n\t\t\t\treturn \"/api/bar/{bar}/{foo}/\";\n\t\t\t},\n\t\t});\n\t\texpect(TestModel.matchesURL(\"/api/bar/1/hello/1/\")).toEqual(true);\n\t});\n\n\tit(\"should match with the full server endpoint included\", () => {\n\t\tconst endpoint = \"http://localhost:8000/api/\";\n\t\ttd.replace(Api, \"getURL\", () => endpoint);\n\t\tconst url = \"http://localhost:8000/api/activities/2719/\";\n\t\tconst ActivityModel = G(\"ActivityItemModel\").extend({\n\t\t\tgetResourceURL() {\n\t\t\t\treturn `${endpoint}activities/`;\n\t\t\t},\n\t\t});\n\t\texpect(ActivityModel.matchesURL(url)).toEqual(true);\n\t});\n});\n\nit(\"should allow serializing collections with urls only\", () => {\n\tG(BaseModel.extend({ modelName: \"baz\" }), \"TestModel\");\n\tG(BaseCollection.extend({ model: \"TestModel\" }), \"TestCollection\");\n\tconst Model = G(\n\t\tBaseModel.extend({ collections: { tests: \"TestCollection\" } }),\n\t);\n\tconst model = new Model({\n\t\ttests: [\n\t\t\t{ id: 1, url: \"/api/baz/1/\" },\n\t\t\t{ id: 2, url: \"/api/baz/2/\" },\n\t\t],\n\t});\n\texpect(model.serialize({ urlsOnly: true })).toEqual({\n\t\turl: null,\n\t\ttests: [\"/api/baz/1/\", \"/api/baz/2/\"],\n\t});\n});\n"],"mappings":";;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,OAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,WAAA,GAAAF,sBAAA,CAAAN,OAAA;AAEAS,EAAE,CAAC,2CAA2C,EAAE,YAAM;EACrD,IAAMC,SAAS,GAAGC,gBAAS,CAACC,MAAM,CAAC;IAAEC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAO;EAAE,CAAC,CAAC;EAEnE,IAAMC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