@azrico/webobject 1.4.137 → 1.4.139
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/WebObject.js +63 -40
- package/dist/src/WebObjects/WebObjectPathHelper.d.ts +28 -0
- package/dist/src/WebObjects/WebObjectPathHelper.js +138 -0
- package/dist/src/WebObjects/WebObjectPathHelper.test.d.ts +1 -0
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +101 -0
- package/package.json +5 -5
|
@@ -9,6 +9,7 @@ var _object = require("@azrico/object");
|
|
|
9
9
|
var _string = require("@azrico/string");
|
|
10
10
|
var _global = require("@azrico/global");
|
|
11
11
|
var _convert = _interopRequireDefault(require("@azrico/convert"));
|
|
12
|
+
var _WebObjectPathHelper = _interopRequireDefault(require("./WebObjectPathHelper"));
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
14
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
15
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
@@ -168,7 +169,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
168
169
|
key: "Save",
|
|
169
170
|
value: function () {
|
|
170
171
|
var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
171
|
-
var deltaObject, putAction,
|
|
172
|
+
var deltaObject, putAction, usepath, canSaveResult, resultObject;
|
|
172
173
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
173
174
|
while (1) switch (_context2.prev = _context2.next) {
|
|
174
175
|
case 0:
|
|
@@ -177,44 +178,47 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
177
178
|
case 2:
|
|
178
179
|
deltaObject = _context2.sent;
|
|
179
180
|
putAction = "post";
|
|
180
|
-
|
|
181
|
+
_context2.next = 6;
|
|
182
|
+
return _WebObjectPathHelper["default"].get_path(this, this.isNew ? "new" : "save");
|
|
183
|
+
case 6:
|
|
184
|
+
usepath = _context2.sent;
|
|
181
185
|
if ((0, _object.object_isEmpty)(deltaObject)) {
|
|
182
|
-
_context2.next =
|
|
186
|
+
_context2.next = 20;
|
|
183
187
|
break;
|
|
184
188
|
}
|
|
185
189
|
canSaveResult = this.canSave(deltaObject);
|
|
186
190
|
if (!(canSaveResult !== true)) {
|
|
187
|
-
_context2.next =
|
|
191
|
+
_context2.next = 13;
|
|
188
192
|
break;
|
|
189
193
|
}
|
|
190
194
|
WebObject.addError(this, "Save not allowed", String(canSaveResult), true);
|
|
191
195
|
this.setSaveResult(false, "canceled");
|
|
192
196
|
return _context2.abrupt("return", false);
|
|
193
|
-
case 11:
|
|
194
|
-
_context2.next = 13;
|
|
195
|
-
return _global.gfunc.run_action(putAction, putAddress, deltaObject);
|
|
196
197
|
case 13:
|
|
198
|
+
_context2.next = 15;
|
|
199
|
+
return _global.gfunc.run_action(putAction, usepath, deltaObject);
|
|
200
|
+
case 15:
|
|
197
201
|
resultObject = _context2.sent;
|
|
198
202
|
this.setSaveResult(resultObject, "auto");
|
|
199
203
|
if (!this.__saveResultIsSuccess) {
|
|
200
204
|
console.error("bad save result : ", resultObject);
|
|
201
205
|
WebObject.addError(this, "Save result is not valid", "the response from server was not a valid saveresult object !", true);
|
|
202
206
|
}
|
|
203
|
-
_context2.next =
|
|
207
|
+
_context2.next = 21;
|
|
204
208
|
break;
|
|
205
|
-
case
|
|
209
|
+
case 20:
|
|
206
210
|
/* nothing to save */
|
|
207
211
|
this.setSaveResult(null, "nothing");
|
|
208
|
-
case
|
|
212
|
+
case 21:
|
|
209
213
|
if (!this.isSaved) {
|
|
210
|
-
_context2.next =
|
|
214
|
+
_context2.next = 25;
|
|
211
215
|
break;
|
|
212
216
|
}
|
|
213
|
-
_context2.next =
|
|
217
|
+
_context2.next = 24;
|
|
214
218
|
return this.onSave();
|
|
215
|
-
case
|
|
219
|
+
case 24:
|
|
216
220
|
return _context2.abrupt("return", this.getSaveResult());
|
|
217
|
-
case
|
|
221
|
+
case 25:
|
|
218
222
|
case "end":
|
|
219
223
|
return _context2.stop();
|
|
220
224
|
}
|
|
@@ -229,7 +233,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
229
233
|
key: "Delete",
|
|
230
234
|
value: function () {
|
|
231
235
|
var _Delete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
232
|
-
var resultObject;
|
|
236
|
+
var usepath, resultObject;
|
|
233
237
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
234
238
|
while (1) switch (_context3.prev = _context3.next) {
|
|
235
239
|
case 0:
|
|
@@ -240,15 +244,19 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
240
244
|
return _context3.abrupt("return");
|
|
241
245
|
case 2:
|
|
242
246
|
_context3.next = 4;
|
|
243
|
-
return
|
|
247
|
+
return _WebObjectPathHelper["default"].get_path(this, "delete");
|
|
244
248
|
case 4:
|
|
249
|
+
usepath = _context3.sent;
|
|
250
|
+
_context3.next = 7;
|
|
251
|
+
return _global.gfunc.run_action("delete", usepath);
|
|
252
|
+
case 7:
|
|
245
253
|
resultObject = _context3.sent;
|
|
246
254
|
this.setSaveResult(resultObject, "auto", true);
|
|
247
|
-
_context3.next =
|
|
255
|
+
_context3.next = 11;
|
|
248
256
|
return this.onDelete();
|
|
249
|
-
case
|
|
257
|
+
case 11:
|
|
250
258
|
return _context3.abrupt("return", resultObject);
|
|
251
|
-
case
|
|
259
|
+
case 12:
|
|
252
260
|
case "end":
|
|
253
261
|
return _context3.stop();
|
|
254
262
|
}
|
|
@@ -263,7 +271,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
263
271
|
key: "Lock",
|
|
264
272
|
value: function () {
|
|
265
273
|
var _Lock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
266
|
-
var resultObject;
|
|
274
|
+
var usepath, resultObject;
|
|
267
275
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
268
276
|
while (1) switch (_context4.prev = _context4.next) {
|
|
269
277
|
case 0:
|
|
@@ -274,15 +282,19 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
274
282
|
return _context4.abrupt("return");
|
|
275
283
|
case 2:
|
|
276
284
|
_context4.next = 4;
|
|
277
|
-
return
|
|
285
|
+
return _WebObjectPathHelper["default"].get_path(this, "lock");
|
|
278
286
|
case 4:
|
|
287
|
+
usepath = _context4.sent;
|
|
288
|
+
_context4.next = 7;
|
|
289
|
+
return _global.gfunc.run_action("post", usepath);
|
|
290
|
+
case 7:
|
|
279
291
|
resultObject = _context4.sent;
|
|
280
292
|
this.setSaveResult(resultObject, "auto", true);
|
|
281
|
-
_context4.next =
|
|
293
|
+
_context4.next = 11;
|
|
282
294
|
return this.onLock();
|
|
283
|
-
case
|
|
295
|
+
case 11:
|
|
284
296
|
return _context4.abrupt("return", resultObject);
|
|
285
|
-
case
|
|
297
|
+
case 12:
|
|
286
298
|
case "end":
|
|
287
299
|
return _context4.stop();
|
|
288
300
|
}
|
|
@@ -297,7 +309,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
297
309
|
key: "UnLock",
|
|
298
310
|
value: function () {
|
|
299
311
|
var _UnLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
300
|
-
var resultObject;
|
|
312
|
+
var usepath, resultObject;
|
|
301
313
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
302
314
|
while (1) switch (_context5.prev = _context5.next) {
|
|
303
315
|
case 0:
|
|
@@ -308,15 +320,19 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
308
320
|
return _context5.abrupt("return");
|
|
309
321
|
case 2:
|
|
310
322
|
_context5.next = 4;
|
|
311
|
-
return
|
|
323
|
+
return _WebObjectPathHelper["default"].get_path(this, "unlock");
|
|
312
324
|
case 4:
|
|
325
|
+
usepath = _context5.sent;
|
|
326
|
+
_context5.next = 7;
|
|
327
|
+
return _global.gfunc.run_action("post", usepath);
|
|
328
|
+
case 7:
|
|
313
329
|
resultObject = _context5.sent;
|
|
314
330
|
this.setSaveResult(resultObject, "auto", true);
|
|
315
|
-
_context5.next =
|
|
331
|
+
_context5.next = 11;
|
|
316
332
|
return this.onUnLock();
|
|
317
|
-
case
|
|
333
|
+
case 11:
|
|
318
334
|
return _context5.abrupt("return", resultObject);
|
|
319
|
-
case
|
|
335
|
+
case 12:
|
|
320
336
|
case "end":
|
|
321
337
|
return _context5.stop();
|
|
322
338
|
}
|
|
@@ -331,7 +347,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
331
347
|
key: "Archive",
|
|
332
348
|
value: function () {
|
|
333
349
|
var _Archive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
334
|
-
var resultObject;
|
|
350
|
+
var usepath, resultObject;
|
|
335
351
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
336
352
|
while (1) switch (_context6.prev = _context6.next) {
|
|
337
353
|
case 0:
|
|
@@ -342,15 +358,19 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
342
358
|
return _context6.abrupt("return");
|
|
343
359
|
case 2:
|
|
344
360
|
_context6.next = 4;
|
|
345
|
-
return
|
|
361
|
+
return _WebObjectPathHelper["default"].get_path(this, "archive");
|
|
346
362
|
case 4:
|
|
363
|
+
usepath = _context6.sent;
|
|
364
|
+
_context6.next = 7;
|
|
365
|
+
return _global.gfunc.run_action("post", usepath);
|
|
366
|
+
case 7:
|
|
347
367
|
resultObject = _context6.sent;
|
|
348
368
|
this.setSaveResult(resultObject, "auto", true);
|
|
349
|
-
_context6.next =
|
|
369
|
+
_context6.next = 11;
|
|
350
370
|
return this.onArchive();
|
|
351
|
-
case
|
|
371
|
+
case 11:
|
|
352
372
|
return _context6.abrupt("return", resultObject);
|
|
353
|
-
case
|
|
373
|
+
case 12:
|
|
354
374
|
case "end":
|
|
355
375
|
return _context6.stop();
|
|
356
376
|
}
|
|
@@ -365,7 +385,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
365
385
|
key: "UnArchive",
|
|
366
386
|
value: function () {
|
|
367
387
|
var _UnArchive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
368
|
-
var resultObject;
|
|
388
|
+
var usepath, resultObject;
|
|
369
389
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
370
390
|
while (1) switch (_context7.prev = _context7.next) {
|
|
371
391
|
case 0:
|
|
@@ -376,15 +396,18 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
376
396
|
return _context7.abrupt("return");
|
|
377
397
|
case 2:
|
|
378
398
|
_context7.next = 4;
|
|
379
|
-
return
|
|
399
|
+
return _WebObjectPathHelper["default"].get_path(this, "unarchive");
|
|
380
400
|
case 4:
|
|
401
|
+
usepath = _context7.sent;
|
|
402
|
+
_context7.next = 7;
|
|
403
|
+
return _global.gfunc.run_action("post", usepath);
|
|
404
|
+
case 7:
|
|
381
405
|
resultObject = _context7.sent;
|
|
382
|
-
|
|
383
|
-
_context7.next = 8;
|
|
406
|
+
_context7.next = 10;
|
|
384
407
|
return this.onUnArchive();
|
|
385
|
-
case
|
|
408
|
+
case 10:
|
|
386
409
|
return _context7.abrupt("return", resultObject);
|
|
387
|
-
case
|
|
410
|
+
case 11:
|
|
388
411
|
case "end":
|
|
389
412
|
return _context7.stop();
|
|
390
413
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ClassType } from "@azrico/types";
|
|
2
|
+
import WebObject from "./WebObject";
|
|
3
|
+
export declare class WebObjectPathHelper {
|
|
4
|
+
static readonly defaultPaths: {
|
|
5
|
+
lock: string;
|
|
6
|
+
unlock: string;
|
|
7
|
+
archive: string;
|
|
8
|
+
unarchive: string;
|
|
9
|
+
delete: string;
|
|
10
|
+
new: string;
|
|
11
|
+
save: string;
|
|
12
|
+
};
|
|
13
|
+
static readonly pathOverrides: {};
|
|
14
|
+
static get_path(obj: WebObject, pn: string): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* clear all paths that are override by `override_path`
|
|
17
|
+
*/
|
|
18
|
+
static clear_overrides(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* override a save path for the gievn webobject
|
|
21
|
+
* @param obj
|
|
22
|
+
* @param pn
|
|
23
|
+
* @param override
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
static override_path(obj: ClassType<WebObject> | string, pn: string, override: string): Promise<string | false>;
|
|
27
|
+
}
|
|
28
|
+
export default WebObjectPathHelper;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.WebObjectPathHelper = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
+
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); } }
|
|
10
|
+
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); }); }; }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
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); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
var WebObjectPathHelper = exports.WebObjectPathHelper = /*#__PURE__*/function () {
|
|
18
|
+
function WebObjectPathHelper() {
|
|
19
|
+
_classCallCheck(this, WebObjectPathHelper);
|
|
20
|
+
}
|
|
21
|
+
_createClass(WebObjectPathHelper, null, [{
|
|
22
|
+
key: "get_path",
|
|
23
|
+
value: function () {
|
|
24
|
+
var _get_path = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(obj, pn) {
|
|
25
|
+
var wn, usepath;
|
|
26
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
27
|
+
while (1) switch (_context.prev = _context.next) {
|
|
28
|
+
case 0:
|
|
29
|
+
pn = String(pn).toLowerCase();
|
|
30
|
+
wn = obj.get_webname();
|
|
31
|
+
usepath = "";
|
|
32
|
+
if (WebObjectPathHelper.pathOverrides[wn] && WebObjectPathHelper.pathOverrides[wn][pn]) {
|
|
33
|
+
usepath = WebObjectPathHelper.pathOverrides[wn][pn];
|
|
34
|
+
} else {
|
|
35
|
+
usepath = WebObjectPathHelper.defaultPaths[pn];
|
|
36
|
+
}
|
|
37
|
+
if (!usepath) usepath = WebObjectPathHelper.defaultPaths["save"];
|
|
38
|
+
usepath = usepath.replaceAll("{wn}", obj.get_webname());
|
|
39
|
+
usepath = usepath.replaceAll("{wp}", obj.__web_path);
|
|
40
|
+
usepath = usepath.replaceAll("{id}", obj.getID());
|
|
41
|
+
return _context.abrupt("return", usepath);
|
|
42
|
+
case 9:
|
|
43
|
+
case "end":
|
|
44
|
+
return _context.stop();
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
function get_path(_x, _x2) {
|
|
49
|
+
return _get_path.apply(this, arguments);
|
|
50
|
+
}
|
|
51
|
+
return get_path;
|
|
52
|
+
}()
|
|
53
|
+
/**
|
|
54
|
+
* clear all paths that are override by `override_path`
|
|
55
|
+
*/
|
|
56
|
+
}, {
|
|
57
|
+
key: "clear_overrides",
|
|
58
|
+
value: (function () {
|
|
59
|
+
var _clear_overrides = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
60
|
+
var key;
|
|
61
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
62
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
for (key in this.pathOverrides) {
|
|
65
|
+
this.pathOverrides[key] = {};
|
|
66
|
+
}
|
|
67
|
+
case 1:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context2.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee2, this);
|
|
72
|
+
}));
|
|
73
|
+
function clear_overrides() {
|
|
74
|
+
return _clear_overrides.apply(this, arguments);
|
|
75
|
+
}
|
|
76
|
+
return clear_overrides;
|
|
77
|
+
}()
|
|
78
|
+
/**
|
|
79
|
+
* override a save path for the gievn webobject
|
|
80
|
+
* @param obj
|
|
81
|
+
* @param pn
|
|
82
|
+
* @param override
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
)
|
|
86
|
+
}, {
|
|
87
|
+
key: "override_path",
|
|
88
|
+
value: (function () {
|
|
89
|
+
var _override_path = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(obj, pn, override) {
|
|
90
|
+
var wn;
|
|
91
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
92
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
93
|
+
case 0:
|
|
94
|
+
pn = String(pn).toLowerCase();
|
|
95
|
+
wn = "";
|
|
96
|
+
if (typeof obj === "string") {
|
|
97
|
+
wn = obj;
|
|
98
|
+
} else if (typeof obj.get_webname === "function") {
|
|
99
|
+
wn = obj.get_webname();
|
|
100
|
+
} else {
|
|
101
|
+
console.error("[override_path]", "given object has no get_webname");
|
|
102
|
+
wn = obj.__web_path || obj.__web_type;
|
|
103
|
+
}
|
|
104
|
+
if (wn) {
|
|
105
|
+
_context3.next = 6;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
console.error("[override_path]", "bad webname");
|
|
109
|
+
return _context3.abrupt("return", false);
|
|
110
|
+
case 6:
|
|
111
|
+
if (!WebObjectPathHelper.pathOverrides[wn]) WebObjectPathHelper.pathOverrides[wn] = {};
|
|
112
|
+
WebObjectPathHelper.pathOverrides[wn][pn] = override;
|
|
113
|
+
return _context3.abrupt("return", override);
|
|
114
|
+
case 9:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context3.stop();
|
|
117
|
+
}
|
|
118
|
+
}, _callee3);
|
|
119
|
+
}));
|
|
120
|
+
function override_path(_x3, _x4, _x5) {
|
|
121
|
+
return _override_path.apply(this, arguments);
|
|
122
|
+
}
|
|
123
|
+
return override_path;
|
|
124
|
+
}())
|
|
125
|
+
}]);
|
|
126
|
+
return WebObjectPathHelper;
|
|
127
|
+
}();
|
|
128
|
+
_defineProperty(WebObjectPathHelper, "defaultPaths", {
|
|
129
|
+
lock: "{wn}/{id}/lock",
|
|
130
|
+
unlock: "{wn}/{id}/unlock",
|
|
131
|
+
archive: "{wn}/{id}/archive",
|
|
132
|
+
unarchive: "{wn}/{id}/unarchive",
|
|
133
|
+
"delete": "{wn}/{id}",
|
|
134
|
+
"new": "{wn}",
|
|
135
|
+
save: "{wn}/{id}"
|
|
136
|
+
});
|
|
137
|
+
_defineProperty(WebObjectPathHelper, "pathOverrides", {});
|
|
138
|
+
var _default = exports["default"] = WebObjectPathHelper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _index = require("../index");
|
|
4
|
+
var _WebObjectPathHelper = _interopRequireDefault(require("./WebObjectPathHelper"));
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
|
+
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); } }
|
|
9
|
+
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); }); }; }
|
|
10
|
+
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); } }
|
|
11
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
14
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
15
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
+
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
+
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; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
var TestWebObject = /*#__PURE__*/function (_WebObject) {
|
|
24
|
+
_inherits(TestWebObject, _WebObject);
|
|
25
|
+
function TestWebObject() {
|
|
26
|
+
_classCallCheck(this, TestWebObject);
|
|
27
|
+
return _callSuper(this, TestWebObject, arguments);
|
|
28
|
+
}
|
|
29
|
+
return _createClass(TestWebObject);
|
|
30
|
+
}(_index.WebObject);
|
|
31
|
+
_defineProperty(TestWebObject, "__web_path", "test-wp");
|
|
32
|
+
describe("WebObjectPathHelper", function () {
|
|
33
|
+
var wobj;
|
|
34
|
+
beforeEach(function () {
|
|
35
|
+
_WebObjectPathHelper["default"].clear_overrides();
|
|
36
|
+
wobj = new TestWebObject();
|
|
37
|
+
wobj._id = "test";
|
|
38
|
+
});
|
|
39
|
+
it("get_path", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
40
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
41
|
+
while (1) switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
_context.t0 = expect;
|
|
44
|
+
_context.next = 3;
|
|
45
|
+
return _WebObjectPathHelper["default"].get_path(wobj, "save");
|
|
46
|
+
case 3:
|
|
47
|
+
_context.t1 = _context.sent;
|
|
48
|
+
(0, _context.t0)(_context.t1).toBe(wobj.get_webname() + "/" + wobj.getID());
|
|
49
|
+
_context.t2 = expect;
|
|
50
|
+
_context.next = 8;
|
|
51
|
+
return _WebObjectPathHelper["default"].get_path(wobj, "new");
|
|
52
|
+
case 8:
|
|
53
|
+
_context.t3 = _context.sent;
|
|
54
|
+
(0, _context.t2)(_context.t3).toBe(wobj.get_webname());
|
|
55
|
+
_context.t4 = expect;
|
|
56
|
+
_context.next = 13;
|
|
57
|
+
return _WebObjectPathHelper["default"].get_path(wobj, "lock");
|
|
58
|
+
case 13:
|
|
59
|
+
_context.t5 = _context.sent;
|
|
60
|
+
(0, _context.t4)(_context.t5).toBe("".concat(wobj.get_webname(), "/").concat(wobj.getID(), "/lock"));
|
|
61
|
+
case 15:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
64
|
+
}
|
|
65
|
+
}, _callee);
|
|
66
|
+
})));
|
|
67
|
+
it("override_path", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
68
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
69
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
_context2.next = 2;
|
|
72
|
+
return _WebObjectPathHelper["default"].override_path(wobj.get_webname(), "save", "blah");
|
|
73
|
+
case 2:
|
|
74
|
+
_context2.t0 = expect;
|
|
75
|
+
_context2.next = 5;
|
|
76
|
+
return _WebObjectPathHelper["default"].get_path(wobj, "save");
|
|
77
|
+
case 5:
|
|
78
|
+
_context2.t1 = _context2.sent;
|
|
79
|
+
(0, _context2.t0)(_context2.t1).toBe("blah");
|
|
80
|
+
_context2.next = 9;
|
|
81
|
+
return _WebObjectPathHelper["default"].override_path(wobj.get_webname(), "save", "{id}");
|
|
82
|
+
case 9:
|
|
83
|
+
_context2.t2 = expect;
|
|
84
|
+
_context2.next = 12;
|
|
85
|
+
return _WebObjectPathHelper["default"].get_path(wobj, "save");
|
|
86
|
+
case 12:
|
|
87
|
+
_context2.t3 = _context2.sent;
|
|
88
|
+
(0, _context2.t2)(_context2.t3).toBe(wobj.getID());
|
|
89
|
+
_context2.t4 = expect;
|
|
90
|
+
_context2.next = 17;
|
|
91
|
+
return _WebObjectPathHelper["default"].get_path(wobj, "new");
|
|
92
|
+
case 17:
|
|
93
|
+
_context2.t5 = _context2.sent;
|
|
94
|
+
(0, _context2.t4)(_context2.t5).toBe(wobj.get_webname());
|
|
95
|
+
case 19:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context2.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee2);
|
|
100
|
+
})));
|
|
101
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azrico/webobject",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.139",
|
|
4
4
|
"description": "Stateful object",
|
|
5
5
|
"author": "Azrideus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@azrico/convert": "^1.0.5",
|
|
73
|
-
"@azrico/event": "^1.2.
|
|
74
|
-
"@azrico/global": "^1.3.
|
|
73
|
+
"@azrico/event": "^1.2.34",
|
|
74
|
+
"@azrico/global": "^1.3.76",
|
|
75
75
|
"@azrico/math": "^1.0.5",
|
|
76
76
|
"@azrico/object": "^1.4.101",
|
|
77
|
-
"@azrico/string": "^1.2.
|
|
78
|
-
"@azrico/types": "^1.0.
|
|
77
|
+
"@azrico/string": "^1.2.95",
|
|
78
|
+
"@azrico/types": "^1.0.9",
|
|
79
79
|
"@azrico/uid": "^1.0.8"
|
|
80
80
|
},
|
|
81
81
|
"packageManager": "yarn@3.5.0"
|