UNPKG

spx-com

Version:

Sharepoint 2013 Client Object Model Library

1,481 lines (1,353 loc) 408 kB
var spx = (function (cryptoJs, axios) { 'use strict'; axios = axios && axios.hasOwnProperty('default') ? axios['default'] : axios; function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } // ======= ==== === ======= == == ==== ==== ======= = == ====== // ====== === == == == ====== = ==== ==== ====== === ====== ==== ==== ==== ===== // ===== ======= ==== = ===== = ==== ==== ===== == == ===== ==== ==== ==== ===== // ===== ======= ==== = == === == ========= ==== ==== = == === ==== ===== ========== // ===== ======= ==== = === == ==== ======= ==== ==== = === == ==== ======= ======== // ===== ======= ==== = ==== = ====== ===== ==== = ==== = ==== ========= ====== // ===== ======= ==== = ===== = ==== ==== ==== ==== = ===== ==== ==== ==== ===== // ====== === == == == ====== = ==== ==== ==== ==== = ====== ==== ==== ==== ===== // ======= ==== === ======= == ===== ==== ==== = ======= ==== ===== ====== // ================================================================================================ var REQUEST_TIMEOUT = 3600000; var MAX_ITEMS_LIMIT = 100000; var REQUEST_BUNDLE_MAX_SIZE = 252; var REQUEST_LIST_FOLDER_UPDATE_BUNDLE_MAX_SIZE = 82; var REQUEST_LIST_FOLDER_DELETE_BUNDLE_MAX_SIZE = 240; var ACTION_TYPES = { create: 'created', update: 'updated', delete: 'deleted', recycle: 'recycled', get: 'get', copy: 'copied', move: 'moved', restore: 'restored', clear: 'cleared', erase: 'erased', send: 'sent' }; var FILE_LIST_TEMPLATES = { 101: true, 109: true, 110: true, 113: true, 114: true, 116: true, 119: true, 121: true, 122: true, 123: true, 175: true, 851: true, 10102: true }; var LIBRARY_STANDART_COLUMN_NAMES = { AppAuthor: true, AppEditor: true, Author: true, CheckedOutTitle: true, CheckedOutUserId: true, CheckoutUser: true, ContentTypeId: true, Created: true, Created_x0020_By: true, Created_x0020_Date: true, DocConcurrencyNumber: true, Editor: true, FSObjType: true, FileDirRef: true, FileLeafRef: true, FileRef: true, File_x0020_Size: true, File_x0020_Type: true, FolderChildCount: true, GUID: true, HTML_x0020_File_x0020_Type: true, ID: true, InstanceID: true, IsCheckedoutToLocal: true, ItemChildCount: true, Last_x0020_Modified: true, MetaInfo: true, Modified: true, Modified_x0020_By: true, Order: true, ParentLeafName: true, ParentVersionString: true, ProgId: true, ScopeId: true, SortBehavior: true, SyncClientId: true, TemplateUrl: true, UniqueId: true, VirusStatus: true, WorkflowInstanceID: true, WorkflowVersion: true, owshiddenversion: true, xd_ProgID: true, xd_Signature: true, _CheckinComment: true, _CopySource: true, _HasCopyDestinations: true, _IsCurrentVersion: true, _Level: true, _ModerationComments: true, _ModerationStatus: true, _SharedFileIndex: true, _SourceUrl: true, _UIVersion: true, _UIVersionString: true, ImageHeight: true, ImageWidth: true, PreviewExists: true, ThumbnailExists: true }; // ===== = ==== = == ===== // ======== ==== == = ==== = =========== // ======== ===== == == ==== = =========== // ======== ===== == == ==== = =========== // ======== ====== === == ======= // ======== ======= ==== ======= =========== // ======== ======= ==== ======= =========== // ======== ======= ==== ======= =========== // ======== ======= ==== ======= ===== // ============================================= var typeOf = function typeOf(variable) { return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); }; // =================================================================================================== // ======= ==== === ===== = === = ======= ==== ==== === === ====== // ====== === == == == === = === === == ====== === ====== ===== == == ==== ===== // ===== ======= ==== = = = = ==== == == ===== == == ===== ==== ==== = ==== ===== // ===== ======= ==== = == == = === === == == === = ==== ==== ==== ==== = === ===== // ===== ======= ==== = ===== = ==== == === == = ==== ==== ==== ==== = ======= // ===== ======= ==== = ===== = === === == ==== = = ==== ==== ==== = ==== ===== // ===== ======= ==== = ===== = ==== == == ===== = ==== ==== ==== ==== = ==== ===== // ====== === == == == ===== = === === == ====== = ==== ==== ===== == == ==== ===== // ======= ==== === ===== = === = ======= = ==== ==== ====== === ==== ===== // =================================================================================================== var COMBINATOR = { /** * I :: a → a * * identity * * @param {*} a * @returns {*} a */ I: function I(x) { return x; }, /** * K :: a → b → a * * constant * * @param {*} a * @returns {*} a */ K: function K(x) { return function () { return x; }; }, /** * A :: (a → b) → a → b * * apply * @param {Function} f * @returns {Function} f */ A: function A(f) { return function (x) { return f(x); }; }, /** * U :: (a → a) → a * * universal * @param {Function} f * @returns {Function} f */ U: function U(f) { return f(f); }, /** * Y :: (a → a) → a * * fixed-point * @param {Function} f * @returns {Function} f */ Y: function Y(f) { return COMBINATOR.U(function (g) { return f(function (x) { return g(g)(x); }); }); }, /** * C :: (a → b → c) → b → a → c * * flip * @param {Function} f * @returns {Function} f */ C: function C(f) { return function (x) { return function (y) { return f(y)(x); }; }; }, /** * S :: (a → b → c) → (a → b) → a → c * * substitution * @param {Function} f * @returns {Function} f */ S: function S(f) { return function (g) { return function (x) { return f(x)(g(x)); }; }; }, /** * SI :: (a → b) → (a → b → c) → a → c * * inverted S * @param {Function} f * @returns {Function} f */ SI: function SI(f) { return function (g) { return function (x) { return g(x)(f(x)); }; }; }, /** * SA :: (a → b) → (a → b → c) → a → c * * async S * @param {Function} f * @returns {Function} f */ SA: function SA(f) { return function (g) { return ( /*#__PURE__*/ function () { var _ref = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee(x) { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.t0 = f(x); _context.next = 3; return g(x); case 3: _context.t1 = _context.sent; return _context.abrupt("return", (0, _context.t0)(_context.t1)); case 5: case "end": return _context.stop(); } } }, _callee); })); return function (_x) { return _ref.apply(this, arguments); }; }() ); }; }, /** * SIA :: (a → b) → (a → b → c) → a → c * * async SI * @param {Function} f * @returns {Function} f */ SIA: function SIA(f) { return function (g) { return ( /*#__PURE__*/ function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee2(x) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.t0 = g(x); _context2.next = 3; return f(x); case 3: _context2.t1 = _context2.sent; return _context2.abrupt("return", (0, _context2.t0)(_context2.t1)); case 5: case "end": return _context2.stop(); } } }, _callee2); })); return function (_x2) { return _ref2.apply(this, arguments); }; }() ); }; } }; var identity = COMBINATOR.I; var constant = COMBINATOR.K; var fix = COMBINATOR.Y; var flip = COMBINATOR.C; var overstep = function overstep(f) { return function (x) { f(x); return x; }; }; var functionSum = function functionSum(f) { return function (x) { return function (y) { return x + f(y); }; }; }; // ====================================================== // ======= == ==== = == == ==== ===== // ====== === = ==== = ==== = ==== = == ===== // ===== ======= ==== = ==== = ==== == == ====== // ===== ======= ==== = === = === == == ====== // ===== ======= ==== = === ===== ======= // ===== ======= ==== = ==== = ==== ==== ======== // ===== ======= ==== = ==== = ==== ==== ======== // ====== === = == = ==== = ==== ==== ======== // ======= === == ==== = ==== ==== ======== // ====================================================== /** * curry2 :: f → g * * 2-args currying * * @param {Function} f * @returns {Function} */ var curry2 = function curry2(f) { return function (x, y) { return f(x)(y); }; }; // ======= ==== === ======= = == = = === === ======= ===== // ====== === == == == ====== = ==== == ===== ===== === == == ====== ===== // ===== ======= ==== = ===== = ==== == ===== ===== == ==== = ===== ===== // ===== ======= ==== = == === = ==== == ===== ===== == ==== = == === ===== // ===== ======= ==== = === == = ==== == ===== ===== == ==== = === == ===== // ===== ======= ==== = ==== = = ==== == ===== ===== == ==== = ==== = ===== // ===== ======= ==== = ===== = ==== == ===== ===== == ==== = ===== ===== // ====== === == == == ====== = ==== == ===== ===== === == == ====== ===== // ======= ==== === ======= = == ==== ==== === === ======= ===== // ======================================================================================== var ifThen = function ifThen(predicate) { return function (_ref7) { var _ref8 = _slicedToArray(_ref7, 2), onTrue = _ref8[0], onFalse = _ref8[1]; return function (x) { return predicate(x) ? onTrue(x) : onFalse ? onFalse(x) : x; }; }; }; var switchCase = function switchCase(condition) { return function (cases) { return function (x) { var caseF = cases[condition(x)]; return caseF ? caseF(x) : cases.default ? cases.default(x) : undefined; }; }; }; var switchType = switchCase(typeOf); // =================================================================== // ===== ======= = ==== = ===== = === = ====== // ===== ====== = ==== = === = === == ======= ==== ===== // ===== ===== = ==== = = = = ==== = ======= ==== ===== // ===== == === = ==== = == == = === == ======= === ===== // ===== === == = ==== = ===== = === === ======= // ===== ==== = = ==== = ===== = === == ======= ==== ===== // ===== ===== = ==== = ===== = ==== = ======= ==== ===== // ===== ====== = == = ===== = === == ======= ==== ===== // ===== ======= == == ===== = === = ==== ===== // =================================================================== var sum = function sum(x) { return function (y) { return x + y; }; }; var gt = function gt(x) { return function (y) { return x < y; }; }; // ============================================================== // ====== == = == = ======= == ====== // ===== ==== ==== ==== ==== == == ====== = == ===== // ===== ==== ==== ==== ==== == == ===== = ==== ===== // ====== ========= ==== === == == == === = =========== // ======== ======= ==== ==== == === == = =========== // ========== ===== ==== ==== == == ==== = = === ===== // ===== ==== ==== ==== ==== == == ===== = ==== ===== // ===== ==== ==== ==== ==== == == ====== = == ===== // ====== ===== ==== ==== = = ======= == ====== // ============================================================== var stringTest = function stringTest(re) { return function (str) { return re.test(str); }; }; var stringReplace = function stringReplace(re) { return function (to) { return function (str) { return str.replace(re, to); }; }; }; var stringMatch = function stringMatch(re) { return function (str) { return str.match(re) || []; }; }; var stringCut = function stringCut(re) { return stringReplace(re)(''); }; var stringSplit = function stringSplit(re) { return function (str) { return str.split(re); }; }; var stringTrim = function stringTrim(str) { return str.trim(); }; // ====================================================== // ======== ==== == ===== ==== ==== ===== // ======= === ==== = ==== === === == ===== // ====== == == ==== = ==== == == === == ====== // ===== ==== = === = === = ==== == == ====== // ===== ==== = === === ==== === ======= // ===== = ==== = ==== = ==== ======== // ===== ==== = ==== = ==== = ==== ==== ======== // ===== ==== = ==== = ==== = ==== ==== ======== // ===== ==== = ==== = ==== = ==== ==== ======== // ====================================================== var getArray = function getArray(x) { return typeOf(x) === 'array' ? x : x ? [x] : []; }; var map = function map(f) { return function (xs) { return xs.map(f); }; }; var filter = function filter(f) { return function (xs) { return xs.filter(f); }; }; var slice = function slice(from, to) { return function (xs) { return xs.slice(from, to); }; }; var _join = function join(delim) { return function (xs) { return xs.join(delim); }; }; var removeUndefineds = filter(function (x) { return x !== undefined; }); var concat = function concat(array) { return function (x) { return array.concat(x); }; }; var _reduce = function reduce(f) { return function (init) { return function (xs) { return xs.reduce(curry2(f), switchType({ object: constant({}), array: constant([]), default: identity })(init)); }; }; }; var reduceDirty = function reduceDirty(f) { return function (init) { return function (xs) { return getArray(xs).reduce(curry2(flip(f)), getArray(init)); }; }; }; var flatten = _reduce(function (acc) { return pipe([ifThen(_isArray)([flatten, identity]), concat(acc)]); })([]); var arrayHead = function arrayHead(xs) { return xs[0]; }; var arrayTail = function arrayTail(_ref9) { var _ref10 = _toArray(_ref9), t = _ref10.slice(1); return t; }; var arrayLast = function arrayLast(xs) { return xs[xs.length - 1]; }; var arrayInit = slice(0, -1); var EMPTY_ARRAY = function EMPTY_ARRAY() { return []; }; var chunkArrayFrom = function chunkArrayFrom() { var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; return function (size) { return function (value) { var i = start; return _reduce(function (acc) { return function (x) { if (acc[i] === undefined) acc[i] = []; var chunk = acc[i]; chunk.push(x); if (chunk.length === size) i += 1; return acc; }; })([])(value); }; }; }; var chunkArray = chunkArrayFrom(); var removeEmptiesByProp = function removeEmptiesByProp(property) { return filter(function (x) { return !!x[property]; }); }; var removeDuplicatedProp = function removeDuplicatedProp(property) { return pipe([_reduce(function (acc) { return function (x) { acc[x[property]] = x; return acc; }; })({}), Object.values]); }; // =============================================================== var methodEmpty = function methodEmpty(m) { return function (o) { return o[m] ? o[m]() : o; }; }; var method = function method(m) { return function (arg) { return function (o) { return o[m] ? o[m](arg) : o; }; }; }; var methodI = function methodI(m) { return function (o) { return function (arg) { return o[m] ? o[m](arg) : o; }; }; }; var apply = function apply(m) { return function (o) { return function (args) { return o[m].apply(o, _toConsumableArray(args)); }; }; }; var prop = function prop(name) { return function (o) { return o[name]; }; }; var keys = function keys(o) { return Object.keys(o); }; var getInstance = function getInstance(constructor) { return function () { for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { args[_key5] = arguments[_key5]; } return _construct(constructor, args); }; }; var getInstanceEmpty = function getInstanceEmpty(constructor) { return new constructor(); }; var switchProp = function switchProp(o) { return function (x) { var props = Reflect.ownKeys(o); for (var i = 0; i < props.length; i += 1) { var property = props[i]; if (x[property]) return o[property](x); if (x.default) return x.default(x); } return undefined; }; }; var NULL = function NULL() { return null; }; var climb = function climb(f) { return fix(function (fr) { return function (_ref11) { var _ref12 = _toArray(_ref11), h = _ref12[0], t = _ref12.slice(1); return function (o) { return t.length ? fr(t)(f(h)(o)) : f(h)(o); }; }; }); }; // ========================================================================= // ======= ==== === ===== = ==== ==== == ===== // ====== === == == == === = ==== == == == ==== = =========== // ===== ======= ==== = = = = ==== = ==== = ==== = =========== // ===== ======= ==== = == == = ==== = ==== == ====== =========== // ===== ======= ==== = ===== = == ==== ==== ==== ======= // ===== ======= ==== = ===== = ======= ==== ====== == =========== // ===== ======= ==== = ===== = ======= ==== = ==== = =========== // ====== === == == == ===== = ======== == == ==== = =========== // ======= ==== === ===== = ========= ==== == ===== // ========================================================================= var pipe = _reduce(function (acc) { return function (f) { return function (x) { return f(acc(x)); }; }; })(identity); // ===== ========= ==== == === ====== // ===== ======== == == == == === === ===== // ===== ======= ==== = ==== == == =========== // ===== ======= ==== = ======== == =========== // ===== ======= ==== = ======== == =========== // ===== ======= ==== = === == == =========== // ===== ======= ==== = ==== == == =========== // ===== ======== == == == == === === ===== // ===== === ==== == === ====== // ================================================== var toBoolean = function toBoolean(x) { return !!x; }; var not = function not(x) { return !x; }; var and = function and(x) { return function (y) { return toBoolean(x && y); }; }; var TRUE = function TRUE() { return true; }; var FALSE = function FALSE() { return false; }; var isEqual = function isEqual(sample) { return function (x) { return x === sample; }; }; var isNotEqual = pipe([isEqual, not]); var isNumber = function isNumber(x) { return typeOf(x) === 'number'; }; var isString = function isString(x) { return typeOf(x) === 'string'; }; var _isArray = function isArray(x) { return typeOf(x) === 'array'; }; var isObject = function isObject(x) { return typeOf(x) === 'object'; }; var isBlob = function isBlob(x) { var type = typeOf(x); return type === 'blob' || type === 'file'; }; var isGUID = stringTest(/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/); // ========================================================================================= // ===== = == = == == ==== ==== ======= === == ===== // ===== ======== == === == ==== ==== ====== === ====== == === = =========== // ===== ======== == === == ==== ==== ===== == == ===== = ======= =========== // ===== ========= ==== === ========= ==== ==== = == === = ======= =========== // ===== ====== ===== ===== ======= ==== ==== = === == = ======= ======= // ===== ========= ==== ======= ===== ==== = ==== = = ======= =========== // ===== ======== == === == ==== ==== ==== ==== = ===== = ======= =========== // ===== ======== == === == ==== ==== ==== ==== = ====== == === = =========== // ===== = ==== = == ===== ==== ==== = ======= === == ===== // ========================================================================================= var isNull = function isNull(x) { return x === null; }; var isNotNull = pipe([isNull, not]); var isUndefined = function isUndefined(x) { return x === undefined; }; var isDefined = pipe([isUndefined, not]); var isZero = function isZero(x) { return x === 0; }; var isNotZero = pipe([isZero, not]); var isNaN = function isNaN(x) { return typeOf(x) === 'number' && x.toString() === 'NaN'; }; var isNotNaN = pipe([isNaN, not]); var isNumberFilled = function isNumberFilled(x) { return isNumber(x) && isNotZero(x) && isNotNaN(x); }; var isStringEmpty = function isStringEmpty(x) { return x === ''; }; var isStringFilled = pipe([isStringEmpty, not]); var isArrayFilled = pipe([filter(isDefined), prop('length'), toBoolean]); var isArrayEmpty = pipe([isArrayFilled, not]); var isObjectFilled = ifThen(isObject)([pipe([keys, isArrayFilled]), FALSE]); var isObjectEmpty = pipe([keys, isArrayEmpty]); var isNotError = function isNotError(x) { return typeOf(x) !== 'error'; }; var isExists = function isExists(x) { return isDefined(x) && isNotNull(x); }; var isNotExists = pipe([isExists, not]); var isFilled = ifThen(isExists)([switchType({ number: isNumberFilled, string: isStringFilled, array: isArrayFilled, object: isObjectFilled, null: FALSE, default: TRUE }), toBoolean]); var isNotFilled = pipe([isFilled, not]); var hasProp = function hasProp(name) { return function (o) { return o[name]; }; }; var isPropExists = function isPropExists(name) { return pipe([prop(name), isExists]); }; var isPropFilled = function isPropFilled(name) { return pipe([prop(name), isFilled]); }; // ==================================== // ===== = == ==== ===== // ======== ==== ==== = == ===== // ======== ==== ==== == == ====== // ======== ==== === == == ====== // ======== ==== ===== ======= // ======== ==== ==== ==== ======== // ======== ==== ==== ==== ======== // ======== ==== ==== ==== ======== // ======== ==== ==== ==== ======== // ==================================== var tryCatch = function tryCatch(tryer) { return function (catcher) { return function (data) { try { return tryer(data); } catch (err) { return catcher(err)(data); } }; }; }; var throwError = function throwError(msg) { throw new Error(msg); }; var report = function report(msg) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (!opts.silent && !opts.silentInfo) console.log(msg); }; var rootReport = function rootReport(actionType) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var box = opts.box, name = opts.name, detailed = opts.detailed; var count = box.getCount(); report("".concat(ACTION_TYPES[actionType], " ").concat(count, " ").concat(name).concat(count > 1 ? 's' : '').concat(detailed ? ": ".concat(box.join()) : '', " "), opts); }; var webReport = function webReport(actionType) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var box = opts.box, name = opts.name, detailed = opts.detailed, contextUrl = opts.contextUrl; var count = box.getCount(actionType); report("".concat(ACTION_TYPES[actionType], " ").concat(count, " ").concat(name).concat(count > 1 ? 's' : '', " at ").concat(contextUrl || '/').concat(detailed ? ": ".concat(box.join()) : ''), opts); }; var listReport = function listReport(actionType) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var box = opts.box, name = opts.name, detailed = opts.detailed, contextUrl = opts.contextUrl, listUrl = opts.listUrl; var count = box.getCount(actionType); report("".concat(ACTION_TYPES[actionType], " ").concat(count, " ").concat(name).concat(count > 1 ? 's' : '', " in ").concat(listUrl, " at ").concat(contextUrl || '/').concat(detailed ? ": ".concat(box.join()) : ''), opts); }; // ======================================================================== // ====== == ==== === ==== = == = ====== // ===== == = ==== == == == ==== = ==== = ======= ==== ===== // ===== ==== = ==== = ==== = ==== = ==== = ======= ==== ===== // ===== ======= === = ==== = ==== = ==== = ======= === ===== // ===== ======= === ==== = ==== = == === ======= // ===== === = ==== = ==== = ==== = ======= ======= ==== ===== // ===== ==== = ==== = ==== = ==== = ======= ======= ==== ===== // ===== == = ==== == == == == = ======= ======= ==== ===== // ====== == ==== === ==== == ======= = ==== ===== // ======================================================================== var groupSimple = function groupSimple(by) { return _reduce(function (acc) { return function (el) { var elValue = el[by]; var trueValue = isExists(elValue) && elValue.get_lookupId ? elValue.get_lookupId() : elValue; var groupValue = acc[trueValue]; acc[trueValue] = isUndefined(groupValue) ? [el] : _isArray(groupValue) ? concat(groupValue)(el) : [groupValue, el]; return acc; }; })({}); }; var groupMapper = function groupMapper(f) { return fix(function (fR) { return function (acc) { return switchType({ array: f, object: function object(el) { var props = Reflect.ownKeys(el); for (var i = 0; i < props.length; i += 1) { var property = props[i]; var childEl = el[property]; acc[property] = _isArray(childEl) ? f(childEl) : fR({})(childEl); } return acc; }, default: identity }); }; })({}); }; // const grouper = pipe([getArray, flip(pipe([getArray, reduceDirty(pipe([groupSimple, groupMapper]))]))]); var grouper = flip(reduceDirty(pipe([groupSimple, groupMapper]))); var mapper = function mapper(by) { return function (xs) { return _reduce(function (acc) { return function (el) { var elValue = el[by]; acc[isExists(elValue) && elValue.get_lookupId ? elValue.get_lookupId() : elValue] = el; return acc; }; })({})(getArray(xs)); }; }; // ==================================== // ===== ==== = == =========== // ===== ==== = ==== = =========== // ===== ==== = ==== = =========== // ===== ==== = === = =========== // ===== ==== = === =========== // ===== ==== = ==== = =========== // ===== ==== = ==== = =========== // ===== == = ==== = =========== // ====== == ==== = ===== // ==================================== var hasUrlTailSlash = stringTest(/\/$/); var hasUrlFilename = stringTest(/\.[^/]+$/); var removeEmptyUrls = removeEmptiesByProp('Url'); var removeEmptyIDs = filter(pipe([prop('ID'), isNumberFilled])); var removeEmptyFilenames = filter(function (x) { return x.Url && hasUrlFilename(x.Url); }); var removeDuplicatedUrls = removeDuplicatedProp('Url'); var prependSlash = ifThen(stringTest(/^\//))([identity, sum('/')]); var popSlash = stringCut(/\/$/); var shiftSlash = stringCut(/^\//); var mergeSlashes = stringReplace(/\/\/+/g)('/'); var urlSplit = stringSplit('/'); var getTitleFromUrl = pipe([popSlash, urlSplit, arrayLast]); var urlJoin = _join('/'); var getParentUrl = pipe([popSlash, urlSplit, arrayInit, urlJoin]); var getFolderFromUrl = ifThen(stringTest(/\./))([getParentUrl, popSlash]); var getFilenameFromUrl = ifThen(stringTest(/\./))([getTitleFromUrl, NULL]); var isStrictUrl = function isStrictUrl(url) { return isStringFilled(url) && !hasUrlTailSlash(url); }; var getListRelativeUrl = function getListRelativeUrl(webUrl) { return function (listUrl) { return function () { var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var Url = element.Url, Folder = element.Folder; if (Folder) { var folder = shiftSlash(Folder); return Url ? "".concat(folder, "/").concat(getTitleFromUrl(Url)) : folder; } return Url && stringTest(/\//)(Url) ? Url === '/' ? '/' : shiftSlash(arrayLast(stringSplit('@list@')(stringReplace(listUrl)('@list@')(stringReplace(shiftSlash(webUrl))('@web@')(Url))))) : Url; }; }; }; var getWebRelativeUrl = function getWebRelativeUrl(webUrl) { return function () { var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var Url = element.Url, Folder = element.Folder; if (Folder) { var folder = shiftSlash(Folder); return Url ? "".concat(folder, "/").concat(getTitleFromUrl(Url)) : folder; } return Url && stringTest(/\//)(Url) ? Url === '/' ? '/' : shiftSlash(arrayLast(stringSplit('@web@')(stringReplace(shiftSlash(webUrl))('@web@')(Url)))) : Url; }; }; var AbstractBox = /*#__PURE__*/ function () { function AbstractBox(value, lifter) { var arrayValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : identity; _classCallCheck(this, AbstractBox); this.prop = 'Url'; this.joinProp = 'Url'; this.value = _isArray(value) ? ifThen(isArrayFilled)([pipe([map(lifter), arrayValidator]), constant([lifter()])])(value) : lifter(value); } _createClass(AbstractBox, [{ key: "reduce", value: function reduce(f) { var init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; return _isArray(this.value) ? _reduce(f)(init)(this.value) : f(init)(this.value); } }, { key: "some", value: function some(f) { return _isArray(this.value) ? this.value.some(f) : f(this.value); } }, { key: "chain", value: function chain(f) { return _isArray(this.value) ? Promise.all(map(f)(this.value)) : f(this.value); } }, { key: "join", value: function join() { return _isArray(this.value) ? _join(', ')(map(prop(this.joinProp))(this.value)) : this.value[this.joinProp]; } }, { key: "getCount", value: function getCount() { var _this = this; return _isArray(this.value) ? this.value.filter(function (el) { return isDefined(el[_this.prop]); }).length : isDefined(this.value[this.prop]) ? 1 : 0; } }, { key: "getHead", value: function getHead() { return _isArray(this.value) ? this.value[0] : this.value; } }, { key: "getHeadPropValue", value: function getHeadPropValue() { return _isArray(this.value) ? this.value[0] ? this.value[0][this.prop] : undefined : this.value[this.prop]; } }, { key: "getIterable", value: function getIterable() { return _isArray(this.value) ? this.value : [this.value]; } }, { key: "isArray", value: function isArray() { return _isArray(this.value); } }]); return AbstractBox; }(); // ============================================================================= // ===== = = = ===== ==== === === ====== // ====== ===== ==== ======= ==== === ====== ===== == == ==== ===== // ====== ===== ==== ======= ==== == == ===== ==== ==== = ==== ===== // ====== ===== ==== ======= === = ==== ==== ==== ==== = === ===== // ====== ===== ==== === === ==== ==== ==== ==== = ======= // ====== ===== ==== ======= ==== = ==== ==== ==== = ==== ===== // ====== ===== ==== ======= ==== = ==== ==== ==== ==== = ==== ===== // ====== ===== ==== ======= ==== = ==== ==== ===== == == ==== ===== // ===== ==== ==== = ==== = ==== ==== ====== === ==== ===== // ============================================================================= var deep1Iterator = function deep1Iterator(_ref14) { var _ref14$contextUrl = _ref14.contextUrl, contextUrl = _ref14$contextUrl === void 0 ? '/' : _ref14$contextUrl, elementBox = _ref14.elementBox, _ref14$bundleSize = _ref14.bundleSize, bundleSize = _ref14$bundleSize === void 0 ? REQUEST_BUNDLE_MAX_SIZE : _ref14$bundleSize; return ( /*#__PURE__*/ function () { var _ref15 = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee4(f) { var totalElements, clientContext, clientContexts, result; return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: totalElements = 0; clientContext = getClientContext(contextUrl); clientContexts = [clientContext]; _context4.next = 5; return elementBox.chain(function (element) { totalElements += 1; if (totalElements >= bundleSize) { clientContext = getClientContext(contextUrl); clientContexts.push(clientContext); totalElements = 0; } return f({ clientContext: clientContext, element: element }); }); case 5: result = _context4.sent; return _context4.abrupt("return", { clientContexts: clientContexts, result: result }); case 7: case "end": return _context4.stop(); } } }, _callee4); })); return function (_x4) { return _ref15.apply(this, arguments); }; }() ); }; var deep1IteratorREST = function deep1IteratorREST(_ref16) { var elementBox = _ref16.elementBox; return function (f) { return elementBox.chain( /*#__PURE__*/ function () { var _ref17 = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee5(element) { return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: return _context5.abrupt("return", f({ element: element })); case 1: case "end": return _context5.stop(); } } }, _callee5); })); return function (_x5) { return _ref17.apply(this, arguments); }; }()); }; }; // =========================================================================== // ======= ==== === ======= = = = == = ===== // ====== === == == == ====== ==== ==== ======== == ===== ======== // ===== ======= ==== = ===== ==== ==== ======== == ===== ======== // ===== ======= ==== = == === ==== ==== ========= ====== ======== // ===== ======= ==== = === == ==== ==== ====== ======= ======== // ===== ======= ==== = ==== = ==== ==== ========= ====== ======== // ===== ======= ==== = ===== ==== ==== ======== == ===== ======== // ====== === == == == ====== ==== ==== ======== == ===== ======== // ======= ==== === ======= ==== ==== = ==== ==== ======== // =========================================================================== var newClientContext = getInstance(SP.ClientContext); var getClientContext = function getClientContext(url) { var normalizedUrl = url; if (!/^https?:/.test(url) && !/^\//.test(url)) { normalizedUrl = prependSlash(url); } if (/\.\/$/.test(normalizedUrl)) { normalizedUrl = popSlash(normalizedUrl); } var clientContext = newClientContext(normalizedUrl); clientContext.set_requestTimeout(REQUEST_TIMEOUT); return clientContext; }; // ==================================================================================== // ===== == == == ==== === ======= == == ===== // ===== ==== = ======= ==== = ==== == == == ====== = ==== = =========== // ===== ==== = ======= ==== = ==== = ==== = ===== = ==== = =========== // ===== === = ======== ====== ==== = ==== = == === == ====== =========== // ===== === ====== ==== == ==== = === == ==== ==== ======= // ===== ==== = ============ == ======= ==== = ==== = ====== == =========== // ===== ==== = ======= ==== = ======= ==== = ===== = ==== = =========== // ===== ==== = ======= ==== = ======== == == ====== = ==== = =========== // ===== ==== = == == ========= === ======= == == ===== // ==================================================================================== var getSPObjectValues = function getSPObjectValues(asItem) { return ifThen(isExists)([pipe([ifThen(constant(asItem))([methodEmpty('get_listItemAllFields')]), ifThen(isObject)([switchProp({ get_fieldValues: methodEmpty('get_fieldValues'), get_objectData: pipe([methodEmpty('get_objectData'), methodEmpty('get_properties')]), default: tryCatch(pipe([JSON.stringify, sum('Wrong spObject: '), throwError]))(throwError) })])])]); }; var getRESTValues = pipe([ifThen(hasProp('body'))([pipe([prop('body'), ifThen(isString)([JSON.parse])]), prop('data')]), ifThen(hasProp('d'))([pipe([prop('d'), ifThen(hasProp('results'))([prop('results')])])])]); var prepareResponseJSOM = function prepareResponseJSOM(results) { var opts = arguments.leng