@azrico/webobject 1.4.59 → 1.4.61
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.
- package/dist/src/WebObjects/FormatHelper.d.ts +17 -0
- package/dist/src/WebObjects/FormatHelper.js +144 -0
- package/dist/src/WebObjects/WebObject.d.ts +2 -2
- package/dist/src/WebObjects/WebObject.js +149 -199
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +11 -0
- package/dist/src/structs/SimpleObject.d.ts +2 -4
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { strAction } from "@azrico/string";
|
|
2
|
+
export type formatObject = {
|
|
3
|
+
[Property in fromatType]?: string[];
|
|
4
|
+
};
|
|
5
|
+
export type fromatType = "array" | "number" | "number" | "removeblank" | strAction;
|
|
6
|
+
export declare class FormatHelper {
|
|
7
|
+
static readonly __defaultFormatList: formatObject;
|
|
8
|
+
static applyFormats(inputobject: any, formats: formatObject, changableKeys?: string[], applyDefaults?: boolean): Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* apply the given format on key of given object
|
|
11
|
+
* @param obj
|
|
12
|
+
* @param key
|
|
13
|
+
* @param formatname
|
|
14
|
+
*/
|
|
15
|
+
static applyFormat(obj: any, key: string, formatname: fromatType, changableKeys: string[]): boolean | undefined;
|
|
16
|
+
}
|
|
17
|
+
export default FormatHelper;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.FormatHelper = void 0;
|
|
7
|
+
var _string = require("@azrico/string");
|
|
8
|
+
var _object = require("@azrico/object");
|
|
9
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
+
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); } }
|
|
14
|
+
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); }); }; }
|
|
15
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
17
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
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); }
|
|
21
|
+
var FormatHelper = /*#__PURE__*/function () {
|
|
22
|
+
function FormatHelper() {
|
|
23
|
+
_classCallCheck(this, FormatHelper);
|
|
24
|
+
}
|
|
25
|
+
_createClass(FormatHelper, null, [{
|
|
26
|
+
key: "applyFormats",
|
|
27
|
+
value: function () {
|
|
28
|
+
var _applyFormats = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(inputobject, formats) {
|
|
29
|
+
var _this = this;
|
|
30
|
+
var changableKeys,
|
|
31
|
+
applyDefaults,
|
|
32
|
+
use_formats,
|
|
33
|
+
simpleProps,
|
|
34
|
+
_loop,
|
|
35
|
+
formatname,
|
|
36
|
+
_args2 = arguments;
|
|
37
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
38
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
changableKeys = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [];
|
|
41
|
+
applyDefaults = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : true;
|
|
42
|
+
if (applyDefaults) this.applyFormats(inputobject, this.__defaultFormatList, changableKeys, false);
|
|
43
|
+
/* -------------------------------------------------------------------------- */
|
|
44
|
+
/* __formatList */
|
|
45
|
+
/* -------------------------------------------------------------------------- */
|
|
46
|
+
if (!formats) {
|
|
47
|
+
_context2.next = 15;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
use_formats = _objectSpread({}, formats);
|
|
51
|
+
simpleProps = (0, _object.wrap_array)(use_formats.simple);
|
|
52
|
+
delete use_formats.simple;
|
|
53
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(formatname) {
|
|
54
|
+
var formatKeys;
|
|
55
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
56
|
+
while (1) switch (_context.prev = _context.next) {
|
|
57
|
+
case 0:
|
|
58
|
+
formatKeys = use_formats[formatname];
|
|
59
|
+
if (Array.isArray(formatKeys)) {
|
|
60
|
+
formatKeys.forEach(function (fk) {
|
|
61
|
+
if (typeof inputobject[fk] === "number") inputobject[fk] = String(inputobject[fk]);
|
|
62
|
+
if (typeof inputobject[fk] !== "string") return;
|
|
63
|
+
_this.applyFormat(inputobject, fk, formatname, changableKeys);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
case 2:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context.stop();
|
|
69
|
+
}
|
|
70
|
+
}, _loop);
|
|
71
|
+
});
|
|
72
|
+
_context2.t0 = _regeneratorRuntime().keys(use_formats);
|
|
73
|
+
case 9:
|
|
74
|
+
if ((_context2.t1 = _context2.t0()).done) {
|
|
75
|
+
_context2.next = 14;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
formatname = _context2.t1.value;
|
|
79
|
+
return _context2.delegateYield(_loop(formatname), "t2", 12);
|
|
80
|
+
case 12:
|
|
81
|
+
_context2.next = 9;
|
|
82
|
+
break;
|
|
83
|
+
case 14:
|
|
84
|
+
/* -------------------------------------------------------------------------- */
|
|
85
|
+
/* __simpleProperties */
|
|
86
|
+
/* -------------------------------------------------------------------------- */
|
|
87
|
+
if (Array.isArray(simpleProps)) {
|
|
88
|
+
simpleProps.forEach(function (sp) {
|
|
89
|
+
if (inputobject[sp] == null) return;
|
|
90
|
+
_this.applyFormat(inputobject, sp, "simple", changableKeys);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
case 15:
|
|
94
|
+
return _context2.abrupt("return", inputobject);
|
|
95
|
+
case 16:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context2.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee, this);
|
|
100
|
+
}));
|
|
101
|
+
function applyFormats(_x, _x2) {
|
|
102
|
+
return _applyFormats.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
return applyFormats;
|
|
105
|
+
}()
|
|
106
|
+
/**
|
|
107
|
+
* apply the given format on key of given object
|
|
108
|
+
* @param obj
|
|
109
|
+
* @param key
|
|
110
|
+
* @param formatname
|
|
111
|
+
*/
|
|
112
|
+
}, {
|
|
113
|
+
key: "applyFormat",
|
|
114
|
+
value: function applyFormat(obj, key, formatname, changableKeys) {
|
|
115
|
+
switch (formatname) {
|
|
116
|
+
case "array":
|
|
117
|
+
obj[key] = (0, _object.to_array)(obj[key], ",");
|
|
118
|
+
return;
|
|
119
|
+
case "number":
|
|
120
|
+
return (0, _object.object_conv_prop)(obj, key, "number");
|
|
121
|
+
case "removeblank":
|
|
122
|
+
return (0, _object.object_delete_empty_prop)(obj, key);
|
|
123
|
+
case "simple":
|
|
124
|
+
var oldValue = obj[key];
|
|
125
|
+
var newKey = "simple_" + key;
|
|
126
|
+
var newValue = typeof oldValue === "string" ? (0, _string.convert_to_simple_string)(oldValue) : undefined;
|
|
127
|
+
obj[newKey] = newValue;
|
|
128
|
+
//make sure we include this key in delta!
|
|
129
|
+
changableKeys.push(newKey);
|
|
130
|
+
return;
|
|
131
|
+
default:
|
|
132
|
+
obj[key] = (0, _string.string_do)(formatname, obj[key]);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}]);
|
|
137
|
+
return FormatHelper;
|
|
138
|
+
}();
|
|
139
|
+
exports.FormatHelper = FormatHelper;
|
|
140
|
+
_defineProperty(FormatHelper, "__defaultFormatList", {
|
|
141
|
+
array: ["_users", "meta_data"]
|
|
142
|
+
});
|
|
143
|
+
var _default = FormatHelper;
|
|
144
|
+
exports["default"] = _default;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import SimpleObject, { sendChangesType } from "../structs/SimpleObject";
|
|
2
|
-
import MetaObject from "../
|
|
3
|
-
import WebObjectManager from "./WebObjectManager";
|
|
2
|
+
import { MetaObject, WebObjectManager } from "../index";
|
|
4
3
|
export type deltaParams = {
|
|
5
4
|
type?: string;
|
|
6
5
|
isChild?: boolean;
|
|
7
6
|
useDelta?: boolean;
|
|
8
7
|
allProperties?: boolean;
|
|
9
8
|
extraProperties?: boolean;
|
|
9
|
+
applyFilter?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare class WebObject extends SimpleObject {
|
|
12
12
|
static readonly __web_path: string;
|
|
@@ -7,6 +7,7 @@ exports["default"] = exports.WebObject = void 0;
|
|
|
7
7
|
var _SimpleObject2 = _interopRequireDefault(require("../structs/SimpleObject"));
|
|
8
8
|
var _object = require("@azrico/object");
|
|
9
9
|
var _string = require("@azrico/string");
|
|
10
|
+
var _index3 = require("../index");
|
|
10
11
|
var _global = require("@azrico/global");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
13
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
@@ -206,39 +207,39 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
206
207
|
value: function () {
|
|
207
208
|
var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(p) {
|
|
208
209
|
var _this2 = this;
|
|
209
|
-
var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp,
|
|
210
|
-
return _regeneratorRuntime().wrap(function _callee5$(
|
|
211
|
-
while (1) switch (
|
|
210
|
+
var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp, parseObj, _parseObj, _iterator, _step, key, tempusers;
|
|
211
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
212
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
212
213
|
case 0:
|
|
213
214
|
_parseObj = function _parseObj3() {
|
|
214
215
|
_parseObj = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(obj) {
|
|
215
216
|
var newobj_dlt;
|
|
216
|
-
return _regeneratorRuntime().wrap(function _callee4$(
|
|
217
|
-
while (1) switch (
|
|
217
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
218
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
218
219
|
case 0:
|
|
219
220
|
if (!(obj == null)) {
|
|
220
|
-
|
|
221
|
+
_context4.next = 2;
|
|
221
222
|
break;
|
|
222
223
|
}
|
|
223
|
-
return
|
|
224
|
+
return _context4.abrupt("return", undefined);
|
|
224
225
|
case 2:
|
|
225
226
|
if (!Array.isArray(obj)) {
|
|
226
|
-
|
|
227
|
+
_context4.next = 6;
|
|
227
228
|
break;
|
|
228
229
|
}
|
|
229
|
-
|
|
230
|
+
_context4.next = 5;
|
|
230
231
|
return Promise.all(obj.map( /*#__PURE__*/function () {
|
|
231
232
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(r) {
|
|
232
|
-
return _regeneratorRuntime().wrap(function _callee3$(
|
|
233
|
-
while (1) switch (
|
|
233
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
234
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
234
235
|
case 0:
|
|
235
|
-
|
|
236
|
+
_context3.next = 2;
|
|
236
237
|
return parseObj(r);
|
|
237
238
|
case 2:
|
|
238
|
-
return
|
|
239
|
+
return _context3.abrupt("return", _context3.sent);
|
|
239
240
|
case 3:
|
|
240
241
|
case "end":
|
|
241
|
-
return
|
|
242
|
+
return _context3.stop();
|
|
242
243
|
}
|
|
243
244
|
}, _callee3);
|
|
244
245
|
}));
|
|
@@ -247,30 +248,30 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
247
248
|
};
|
|
248
249
|
}()));
|
|
249
250
|
case 5:
|
|
250
|
-
return
|
|
251
|
+
return _context4.abrupt("return", _context4.sent);
|
|
251
252
|
case 6:
|
|
252
253
|
if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
|
|
253
|
-
|
|
254
|
+
_context4.next = 15;
|
|
254
255
|
break;
|
|
255
256
|
}
|
|
256
|
-
|
|
257
|
+
_context4.next = 9;
|
|
257
258
|
return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
|
|
258
259
|
isChild: true
|
|
259
260
|
}));
|
|
260
261
|
case 9:
|
|
261
|
-
newobj_dlt =
|
|
262
|
+
newobj_dlt = _context4.sent;
|
|
262
263
|
if ((0, _object.object_isEmpty)(newobj_dlt)) {
|
|
263
|
-
|
|
264
|
+
_context4.next = 14;
|
|
264
265
|
break;
|
|
265
266
|
}
|
|
266
|
-
return
|
|
267
|
+
return _context4.abrupt("return", newobj_dlt);
|
|
267
268
|
case 14:
|
|
268
|
-
return
|
|
269
|
+
return _context4.abrupt("return", obj);
|
|
269
270
|
case 15:
|
|
270
|
-
return
|
|
271
|
+
return _context4.abrupt("return", obj);
|
|
271
272
|
case 16:
|
|
272
273
|
case "end":
|
|
273
|
-
return
|
|
274
|
+
return _context4.stop();
|
|
274
275
|
}
|
|
275
276
|
}, _callee4);
|
|
276
277
|
}));
|
|
@@ -294,6 +295,9 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
294
295
|
ignoreProtected: allProperties
|
|
295
296
|
});
|
|
296
297
|
}) : allkeys;
|
|
298
|
+
_context5.next = 14;
|
|
299
|
+
return _index3.FormatHelper.applyFormats(dlt, (0, _object.object_getStatic)(this, "__formatList"), changableKeys);
|
|
300
|
+
case 14:
|
|
297
301
|
/* -------------------------------------------------------------------------- */
|
|
298
302
|
/* __functionProperties */
|
|
299
303
|
/* -------------------------------------------------------------------------- */
|
|
@@ -305,90 +309,36 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
305
309
|
}
|
|
306
310
|
}
|
|
307
311
|
/* -------------------------------------------------------------------------- */
|
|
308
|
-
/*
|
|
309
|
-
/* -------------------------------------------------------------------------- */
|
|
310
|
-
formats = (0, _object.object_getStatic)(this, "__formatList");
|
|
311
|
-
if (!formats) {
|
|
312
|
-
_context6.next = 27;
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
use_formats = _objectSpread({}, formats);
|
|
316
|
-
simpleProps = (0, _object.wrap_array)(use_formats.simple);
|
|
317
|
-
delete use_formats.simple;
|
|
318
|
-
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(formatname) {
|
|
319
|
-
var formatKeys;
|
|
320
|
-
return _regeneratorRuntime().wrap(function _loop$(_context3) {
|
|
321
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
322
|
-
case 0:
|
|
323
|
-
formatKeys = use_formats[formatname];
|
|
324
|
-
if (Array.isArray(formatKeys)) {
|
|
325
|
-
formatKeys.forEach(function (fk) {
|
|
326
|
-
if (typeof dlt[fk] === "number") dlt[fk] = String(dlt[fk]);
|
|
327
|
-
if (typeof dlt[fk] !== "string") return;
|
|
328
|
-
dlt[fk] = (0, _string.string_do)(formatname, dlt[fk]);
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
case 2:
|
|
332
|
-
case "end":
|
|
333
|
-
return _context3.stop();
|
|
334
|
-
}
|
|
335
|
-
}, _loop);
|
|
336
|
-
});
|
|
337
|
-
_context6.t0 = _regeneratorRuntime().keys(use_formats);
|
|
338
|
-
case 21:
|
|
339
|
-
if ((_context6.t1 = _context6.t0()).done) {
|
|
340
|
-
_context6.next = 26;
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
formatname = _context6.t1.value;
|
|
344
|
-
return _context6.delegateYield(_loop(formatname), "t2", 24);
|
|
345
|
-
case 24:
|
|
346
|
-
_context6.next = 21;
|
|
347
|
-
break;
|
|
348
|
-
case 26:
|
|
349
|
-
/* -------------------------------------------------------------------------- */
|
|
350
|
-
/* __simpleProperties */
|
|
312
|
+
/* parse all changableKeys */
|
|
351
313
|
/* -------------------------------------------------------------------------- */
|
|
352
|
-
if (Array.isArray(simpleProps)) {
|
|
353
|
-
simpleProps.forEach(function (sp) {
|
|
354
|
-
if (dlt[sp] == null) return;
|
|
355
|
-
var oldValue = dlt[sp];
|
|
356
|
-
var newKey = "simple_" + sp;
|
|
357
|
-
var newValue = typeof oldValue === "string" ? (0, _string.convert_to_simple_string)(oldValue) : undefined;
|
|
358
|
-
dlt[newKey] = newValue;
|
|
359
|
-
//make sure we include this key in delta!
|
|
360
|
-
changableKeys.push(newKey);
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
case 27:
|
|
364
314
|
_iterator = _createForOfIteratorHelper(changableKeys);
|
|
365
|
-
|
|
315
|
+
_context5.prev = 17;
|
|
366
316
|
_iterator.s();
|
|
367
|
-
case
|
|
317
|
+
case 19:
|
|
368
318
|
if ((_step = _iterator.n()).done) {
|
|
369
|
-
|
|
319
|
+
_context5.next = 26;
|
|
370
320
|
break;
|
|
371
321
|
}
|
|
372
322
|
key = _step.value;
|
|
373
|
-
|
|
323
|
+
_context5.next = 23;
|
|
374
324
|
return parseObj(dlt[key]);
|
|
375
|
-
case
|
|
376
|
-
final_object[key] =
|
|
377
|
-
case
|
|
378
|
-
|
|
325
|
+
case 23:
|
|
326
|
+
final_object[key] = _context5.sent;
|
|
327
|
+
case 24:
|
|
328
|
+
_context5.next = 19;
|
|
379
329
|
break;
|
|
380
|
-
case
|
|
381
|
-
|
|
330
|
+
case 26:
|
|
331
|
+
_context5.next = 31;
|
|
382
332
|
break;
|
|
383
|
-
case
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
_iterator.e(
|
|
387
|
-
case
|
|
388
|
-
|
|
333
|
+
case 28:
|
|
334
|
+
_context5.prev = 28;
|
|
335
|
+
_context5.t0 = _context5["catch"](17);
|
|
336
|
+
_iterator.e(_context5.t0);
|
|
337
|
+
case 31:
|
|
338
|
+
_context5.prev = 31;
|
|
389
339
|
_iterator.f();
|
|
390
|
-
return
|
|
391
|
-
case
|
|
340
|
+
return _context5.finish(31);
|
|
341
|
+
case 34:
|
|
392
342
|
/* -------------------------------------------------------------------------- */
|
|
393
343
|
/* add id properties */
|
|
394
344
|
/* -------------------------------------------------------------------------- */
|
|
@@ -408,12 +358,12 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
408
358
|
});
|
|
409
359
|
final_object["_users"] = (0, _object.wrap_array)(tempusers);
|
|
410
360
|
}
|
|
411
|
-
return
|
|
412
|
-
case
|
|
361
|
+
return _context5.abrupt("return", final_object);
|
|
362
|
+
case 37:
|
|
413
363
|
case "end":
|
|
414
|
-
return
|
|
364
|
+
return _context5.stop();
|
|
415
365
|
}
|
|
416
|
-
}, _callee5, this, [[
|
|
366
|
+
}, _callee5, this, [[17, 28, 31, 34]]);
|
|
417
367
|
}));
|
|
418
368
|
function get_deltaObject(_x) {
|
|
419
369
|
return _get_deltaObject.apply(this, arguments);
|
|
@@ -444,21 +394,21 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
444
394
|
var _len,
|
|
445
395
|
p,
|
|
446
396
|
_key,
|
|
447
|
-
|
|
448
|
-
return _regeneratorRuntime().wrap(function _callee6$(
|
|
449
|
-
while (1) switch (
|
|
397
|
+
_args6 = arguments;
|
|
398
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
399
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
450
400
|
case 0:
|
|
451
401
|
this.isDeleted = true;
|
|
452
|
-
for (_len =
|
|
453
|
-
p[_key] =
|
|
402
|
+
for (_len = _args6.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
403
|
+
p[_key] = _args6[_key];
|
|
454
404
|
}
|
|
455
|
-
|
|
405
|
+
_context6.next = 4;
|
|
456
406
|
return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
|
|
457
407
|
case 4:
|
|
458
|
-
return
|
|
408
|
+
return _context6.abrupt("return", _context6.sent);
|
|
459
409
|
case 5:
|
|
460
410
|
case "end":
|
|
461
|
-
return
|
|
411
|
+
return _context6.stop();
|
|
462
412
|
}
|
|
463
413
|
}, _callee6, this);
|
|
464
414
|
}));
|
|
@@ -475,21 +425,21 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
475
425
|
var _len2,
|
|
476
426
|
p,
|
|
477
427
|
_key2,
|
|
478
|
-
|
|
479
|
-
return _regeneratorRuntime().wrap(function _callee7$(
|
|
480
|
-
while (1) switch (
|
|
428
|
+
_args7 = arguments;
|
|
429
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
430
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
481
431
|
case 0:
|
|
482
432
|
this.isDeleted = false;
|
|
483
|
-
for (_len2 =
|
|
484
|
-
p[_key2] =
|
|
433
|
+
for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
434
|
+
p[_key2] = _args7[_key2];
|
|
485
435
|
}
|
|
486
|
-
|
|
436
|
+
_context7.next = 4;
|
|
487
437
|
return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
|
|
488
438
|
case 4:
|
|
489
|
-
return
|
|
439
|
+
return _context7.abrupt("return", _context7.sent);
|
|
490
440
|
case 5:
|
|
491
441
|
case "end":
|
|
492
|
-
return
|
|
442
|
+
return _context7.stop();
|
|
493
443
|
}
|
|
494
444
|
}, _callee7, this);
|
|
495
445
|
}));
|
|
@@ -508,38 +458,38 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
508
458
|
_len3,
|
|
509
459
|
p,
|
|
510
460
|
_key3,
|
|
511
|
-
|
|
512
|
-
return _regeneratorRuntime().wrap(function _callee8$(
|
|
513
|
-
while (1) switch (
|
|
461
|
+
_args8 = arguments;
|
|
462
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
463
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
514
464
|
case 0:
|
|
515
465
|
if (!this.isSaved) {
|
|
516
|
-
|
|
466
|
+
_context8.next = 7;
|
|
517
467
|
break;
|
|
518
468
|
}
|
|
519
469
|
this.apply_changes();
|
|
520
470
|
srObject = this.getSaveResult(true);
|
|
521
471
|
if (!this.saveResultHasID(srObject)) {
|
|
522
|
-
|
|
472
|
+
_context8.next = 7;
|
|
523
473
|
break;
|
|
524
474
|
}
|
|
525
475
|
/* -------------------------------------------------------------------------- */
|
|
526
476
|
WebObject.LoadIdsFromSaveResult(this, srObject);
|
|
527
|
-
|
|
477
|
+
_context8.next = 7;
|
|
528
478
|
return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
|
|
529
479
|
case 7:
|
|
530
|
-
for (_len3 =
|
|
531
|
-
p[_key3] =
|
|
480
|
+
for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
481
|
+
p[_key3] = _args8[_key3];
|
|
532
482
|
}
|
|
533
|
-
|
|
483
|
+
_context8.next = 10;
|
|
534
484
|
return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
|
|
535
485
|
case 10:
|
|
536
|
-
|
|
486
|
+
_context8.next = 12;
|
|
537
487
|
return this.onAfterSave();
|
|
538
488
|
case 12:
|
|
539
|
-
return
|
|
489
|
+
return _context8.abrupt("return", true);
|
|
540
490
|
case 13:
|
|
541
491
|
case "end":
|
|
542
|
-
return
|
|
492
|
+
return _context8.stop();
|
|
543
493
|
}
|
|
544
494
|
}, _callee8, this);
|
|
545
495
|
}));
|
|
@@ -556,20 +506,20 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
556
506
|
var _len4,
|
|
557
507
|
p,
|
|
558
508
|
_key4,
|
|
559
|
-
|
|
560
|
-
return _regeneratorRuntime().wrap(function _callee9$(
|
|
561
|
-
while (1) switch (
|
|
509
|
+
_args9 = arguments;
|
|
510
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
511
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
562
512
|
case 0:
|
|
563
|
-
for (_len4 =
|
|
564
|
-
p[_key4] =
|
|
513
|
+
for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
514
|
+
p[_key4] = _args9[_key4];
|
|
565
515
|
}
|
|
566
|
-
|
|
516
|
+
_context9.next = 3;
|
|
567
517
|
return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onAfterSave.apply(_this$manager5, p);
|
|
568
518
|
case 3:
|
|
569
|
-
return
|
|
519
|
+
return _context9.abrupt("return", true);
|
|
570
520
|
case 4:
|
|
571
521
|
case "end":
|
|
572
|
-
return
|
|
522
|
+
return _context9.stop();
|
|
573
523
|
}
|
|
574
524
|
}, _callee9, this);
|
|
575
525
|
}));
|
|
@@ -601,20 +551,20 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
601
551
|
var _len5,
|
|
602
552
|
p,
|
|
603
553
|
_key5,
|
|
604
|
-
|
|
605
|
-
return _regeneratorRuntime().wrap(function _callee10$(
|
|
606
|
-
while (1) switch (
|
|
554
|
+
_args10 = arguments;
|
|
555
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
556
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
607
557
|
case 0:
|
|
608
|
-
for (_len5 =
|
|
609
|
-
p[_key5] =
|
|
558
|
+
for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
559
|
+
p[_key5] = _args10[_key5];
|
|
610
560
|
}
|
|
611
|
-
|
|
561
|
+
_context10.next = 3;
|
|
612
562
|
return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onNew.apply(_this$manager6, p);
|
|
613
563
|
case 3:
|
|
614
|
-
return
|
|
564
|
+
return _context10.abrupt("return", _context10.sent);
|
|
615
565
|
case 4:
|
|
616
566
|
case "end":
|
|
617
|
-
return
|
|
567
|
+
return _context10.stop();
|
|
618
568
|
}
|
|
619
569
|
}, _callee10, this);
|
|
620
570
|
}));
|
|
@@ -696,11 +646,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
696
646
|
_item,
|
|
697
647
|
_index2,
|
|
698
648
|
_item2,
|
|
699
|
-
|
|
700
|
-
return _regeneratorRuntime().wrap(function _callee11$(
|
|
701
|
-
while (1) switch (
|
|
649
|
+
_args11 = arguments;
|
|
650
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
651
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
702
652
|
case 0:
|
|
703
|
-
extraOptions =
|
|
653
|
+
extraOptions = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
704
654
|
if (!extraOptions) extraOptions = {};
|
|
705
655
|
chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
|
|
706
656
|
delete extraOptions.chunksize;
|
|
@@ -708,7 +658,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
708
658
|
index = 0;
|
|
709
659
|
case 6:
|
|
710
660
|
if (!(index < chunks.length)) {
|
|
711
|
-
|
|
661
|
+
_context11.next = 36;
|
|
712
662
|
break;
|
|
713
663
|
}
|
|
714
664
|
items_to_save = chunks[index];
|
|
@@ -716,79 +666,79 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
716
666
|
k = 0;
|
|
717
667
|
case 10:
|
|
718
668
|
if (!(k < items_to_save.length)) {
|
|
719
|
-
|
|
669
|
+
_context11.next = 19;
|
|
720
670
|
break;
|
|
721
671
|
}
|
|
722
672
|
item = items_to_save[k];
|
|
723
|
-
|
|
673
|
+
_context11.next = 14;
|
|
724
674
|
return item.get_deltaObject();
|
|
725
675
|
case 14:
|
|
726
|
-
dlt =
|
|
676
|
+
dlt = _context11.sent;
|
|
727
677
|
save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
|
|
728
678
|
_id: item.getID()
|
|
729
679
|
}, dlt));
|
|
730
680
|
case 16:
|
|
731
681
|
k++;
|
|
732
|
-
|
|
682
|
+
_context11.next = 10;
|
|
733
683
|
break;
|
|
734
684
|
case 19:
|
|
735
|
-
|
|
685
|
+
_context11.next = 21;
|
|
736
686
|
return _global.gfunc.run_action("post", putAddress, _objectSpread({
|
|
737
687
|
__save_list: WebObject.zipSaveList(save_array)
|
|
738
688
|
}, extraOptions));
|
|
739
689
|
case 21:
|
|
740
|
-
resultObject =
|
|
690
|
+
resultObject = _context11.sent;
|
|
741
691
|
if (!Array.isArray(resultObject)) {
|
|
742
|
-
|
|
692
|
+
_context11.next = 33;
|
|
743
693
|
break;
|
|
744
694
|
}
|
|
745
695
|
_index = 0;
|
|
746
696
|
case 24:
|
|
747
697
|
if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
|
|
748
|
-
|
|
698
|
+
_context11.next = 33;
|
|
749
699
|
break;
|
|
750
700
|
}
|
|
751
701
|
res = resultObject[_index];
|
|
752
702
|
_item = items_to_save[_index];
|
|
753
703
|
_item.setSaveResult(res);
|
|
754
|
-
|
|
704
|
+
_context11.next = 30;
|
|
755
705
|
return _item.onSave();
|
|
756
706
|
case 30:
|
|
757
707
|
_index++;
|
|
758
|
-
|
|
708
|
+
_context11.next = 24;
|
|
759
709
|
break;
|
|
760
710
|
case 33:
|
|
761
711
|
index++;
|
|
762
|
-
|
|
712
|
+
_context11.next = 6;
|
|
763
713
|
break;
|
|
764
714
|
case 36:
|
|
765
715
|
_index2 = 0;
|
|
766
716
|
case 37:
|
|
767
717
|
if (!(_index2 < itemList.length)) {
|
|
768
|
-
|
|
718
|
+
_context11.next = 46;
|
|
769
719
|
break;
|
|
770
720
|
}
|
|
771
721
|
_item2 = itemList[_index2];
|
|
772
722
|
if (_item2.isSaved) {
|
|
773
|
-
|
|
723
|
+
_context11.next = 41;
|
|
774
724
|
break;
|
|
775
725
|
}
|
|
776
|
-
return
|
|
726
|
+
return _context11.abrupt("return", false);
|
|
777
727
|
case 41:
|
|
778
728
|
if (!(_item2.getSaveResultType() != "normal")) {
|
|
779
|
-
|
|
729
|
+
_context11.next = 43;
|
|
780
730
|
break;
|
|
781
731
|
}
|
|
782
|
-
return
|
|
732
|
+
return _context11.abrupt("return", false);
|
|
783
733
|
case 43:
|
|
784
734
|
_index2++;
|
|
785
|
-
|
|
735
|
+
_context11.next = 37;
|
|
786
736
|
break;
|
|
787
737
|
case 46:
|
|
788
|
-
return
|
|
738
|
+
return _context11.abrupt("return", true);
|
|
789
739
|
case 47:
|
|
790
740
|
case "end":
|
|
791
|
-
return
|
|
741
|
+
return _context11.stop();
|
|
792
742
|
}
|
|
793
743
|
}, _callee11, this);
|
|
794
744
|
}));
|
|
@@ -849,53 +799,53 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
849
799
|
fetchID,
|
|
850
800
|
res,
|
|
851
801
|
params,
|
|
852
|
-
|
|
853
|
-
return _regeneratorRuntime().wrap(function _callee12$(
|
|
854
|
-
while (1) switch (
|
|
802
|
+
_args12 = arguments;
|
|
803
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
804
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
855
805
|
case 0:
|
|
856
|
-
for (_len6 =
|
|
857
|
-
p[_key6] =
|
|
806
|
+
for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
807
|
+
p[_key6] = _args12[_key6];
|
|
858
808
|
}
|
|
859
809
|
search = p.shift();
|
|
860
810
|
readonly = p.shift();
|
|
861
811
|
fetchID = p.shift();
|
|
862
812
|
if (!(0, _object.object_isEmpty)(search)) {
|
|
863
|
-
|
|
813
|
+
_context12.next = 6;
|
|
864
814
|
break;
|
|
865
815
|
}
|
|
866
|
-
return
|
|
816
|
+
return _context12.abrupt("return", undefined);
|
|
867
817
|
case 6:
|
|
868
818
|
params = {};
|
|
869
819
|
params.context = readonly ? "view" : "edit";
|
|
870
|
-
|
|
871
|
-
|
|
820
|
+
_context12.t0 = _typeof(search);
|
|
821
|
+
_context12.next = _context12.t0 === "string" ? 11 : _context12.t0 === "number" ? 11 : _context12.t0 === "object" ? 19 : 19;
|
|
872
822
|
break;
|
|
873
823
|
case 11:
|
|
874
824
|
search = String(search);
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
825
|
+
_context12.t1 = this;
|
|
826
|
+
_context12.t2 = this;
|
|
827
|
+
_context12.next = 16;
|
|
878
828
|
return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
|
|
879
829
|
fetchID: fetchID
|
|
880
830
|
});
|
|
881
831
|
case 16:
|
|
882
|
-
|
|
883
|
-
res =
|
|
884
|
-
return
|
|
832
|
+
_context12.t3 = _context12.sent;
|
|
833
|
+
res = _context12.t1.ensure.call(_context12.t1, _context12.t2, _context12.t3);
|
|
834
|
+
return _context12.abrupt("break", 25);
|
|
885
835
|
case 19:
|
|
886
|
-
|
|
887
|
-
|
|
836
|
+
_context12.t4 = _object.object_first;
|
|
837
|
+
_context12.next = 22;
|
|
888
838
|
return this.get_list(search, readonly, fetchID);
|
|
889
839
|
case 22:
|
|
890
|
-
|
|
891
|
-
res = (0,
|
|
892
|
-
return
|
|
840
|
+
_context12.t5 = _context12.sent;
|
|
841
|
+
res = (0, _context12.t4)(_context12.t5);
|
|
842
|
+
return _context12.abrupt("break", 25);
|
|
893
843
|
case 25:
|
|
894
844
|
WebObject.setReadonly(res, readonly);
|
|
895
|
-
return
|
|
845
|
+
return _context12.abrupt("return", res);
|
|
896
846
|
case 27:
|
|
897
847
|
case "end":
|
|
898
|
-
return
|
|
848
|
+
return _context12.stop();
|
|
899
849
|
}
|
|
900
850
|
}, _callee12, this);
|
|
901
851
|
}));
|
|
@@ -921,30 +871,30 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
921
871
|
result_items,
|
|
922
872
|
selftype,
|
|
923
873
|
res,
|
|
924
|
-
|
|
925
|
-
return _regeneratorRuntime().wrap(function _callee13$(
|
|
926
|
-
while (1) switch (
|
|
874
|
+
_args13 = arguments;
|
|
875
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
876
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
927
877
|
case 0:
|
|
928
|
-
for (_len7 =
|
|
929
|
-
p[_key7] =
|
|
878
|
+
for (_len7 = _args13.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
879
|
+
p[_key7] = _args13[_key7];
|
|
930
880
|
}
|
|
931
881
|
search = p.shift();
|
|
932
882
|
readonly = p.shift();
|
|
933
883
|
fetchID = p.shift();
|
|
934
884
|
if (!search) search = {};
|
|
935
|
-
|
|
885
|
+
_context13.next = 7;
|
|
936
886
|
return _global.gfunc.run_action("get", this.__web_path, search, {
|
|
937
887
|
fetchID: fetchID
|
|
938
888
|
});
|
|
939
889
|
case 7:
|
|
940
|
-
result_items =
|
|
890
|
+
result_items = _context13.sent;
|
|
941
891
|
selftype = this.prototype;
|
|
942
892
|
res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
|
|
943
893
|
WebObject.setReadonly(res, readonly);
|
|
944
|
-
return
|
|
894
|
+
return _context13.abrupt("return", res);
|
|
945
895
|
case 12:
|
|
946
896
|
case "end":
|
|
947
|
-
return
|
|
897
|
+
return _context13.stop();
|
|
948
898
|
}
|
|
949
899
|
}, _callee13, this);
|
|
950
900
|
}));
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -91,6 +91,17 @@ Object.keys(_WebObject).forEach(function (key) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
var _FormatHelper = require("./WebObjects/FormatHelper");
|
|
95
|
+
Object.keys(_FormatHelper).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _FormatHelper[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function get() {
|
|
101
|
+
return _FormatHelper[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
94
105
|
var _ParentWebObject = require("./WebObjects/ParentWebObject");
|
|
95
106
|
Object.keys(_ParentWebObject).forEach(function (key) {
|
|
96
107
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatObject } from "../WebObjects/FormatHelper";
|
|
2
2
|
import { MapableObject } from "./MapableObject";
|
|
3
3
|
import ObjectManager from "./ObjectManager";
|
|
4
4
|
export type saveResultType = "normal" | "nothing" | "error" | "canceled";
|
|
@@ -14,9 +14,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
14
14
|
static readonly __changeables?: string[];
|
|
15
15
|
static readonly __protectedProperties?: string[];
|
|
16
16
|
static readonly __functionProperties?: string[];
|
|
17
|
-
static readonly __formatList?:
|
|
18
|
-
[Property in strAction]?: string[];
|
|
19
|
-
};
|
|
17
|
+
static readonly __formatList?: formatObject;
|
|
20
18
|
static readonly __extraProperties?: string[];
|
|
21
19
|
static readonly __childTypes?: any[];
|
|
22
20
|
static readonly __importColumns?: string[];
|