@wecode-team/cms-supabase-api 0.1.52 → 0.1.53-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +186 -96
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +186 -96
- package/dist/index.js.map +1 -1
- package/dist/utils/route-helpers.d.ts +9 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1034,8 +1034,8 @@ function _defineProperty(e, r, t) {
|
|
|
1034
1034
|
}) : e[r] = t, e;
|
|
1035
1035
|
}
|
|
1036
1036
|
|
|
1037
|
-
function ownKeys$
|
|
1038
|
-
function _objectSpread$
|
|
1037
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1038
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1039
1039
|
function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
1040
1040
|
function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
|
|
1041
1041
|
function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -2091,7 +2091,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2091
2091
|
throw error;
|
|
2092
2092
|
case 2:
|
|
2093
2093
|
return _context14.abrupt("return", (data || []).map(function (item) {
|
|
2094
|
-
return _objectSpread$
|
|
2094
|
+
return _objectSpread$5({
|
|
2095
2095
|
id: item.id,
|
|
2096
2096
|
label: item[displayField] || "ID: ".concat(item.id)
|
|
2097
2097
|
}, item);
|
|
@@ -2204,8 +2204,8 @@ function getDynamicTableService() {
|
|
|
2204
2204
|
return defaultService$1;
|
|
2205
2205
|
}
|
|
2206
2206
|
|
|
2207
|
-
function ownKeys$
|
|
2208
|
-
function _objectSpread$
|
|
2207
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2208
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2209
2209
|
var AuthService = /*#__PURE__*/function () {
|
|
2210
2210
|
function AuthService() {
|
|
2211
2211
|
_classCallCheck(this, AuthService);
|
|
@@ -2382,7 +2382,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2382
2382
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
2383
2383
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2384
2384
|
case 0:
|
|
2385
|
-
finalUserData = _objectSpread$
|
|
2385
|
+
finalUserData = _objectSpread$4({
|
|
2386
2386
|
tableName: this.defaultTableName
|
|
2387
2387
|
}, userData);
|
|
2388
2388
|
_context4.prev = 1;
|
|
@@ -2440,7 +2440,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2440
2440
|
case 0:
|
|
2441
2441
|
updateData = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
2442
2442
|
// 设置默认值
|
|
2443
|
-
finalUpdateData = _objectSpread$
|
|
2443
|
+
finalUpdateData = _objectSpread$4({
|
|
2444
2444
|
tableName: this.defaultTableName
|
|
2445
2445
|
}, updateData);
|
|
2446
2446
|
_context5.prev = 1;
|
|
@@ -2848,8 +2848,8 @@ function _toConsumableArray(r) {
|
|
|
2848
2848
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread();
|
|
2849
2849
|
}
|
|
2850
2850
|
|
|
2851
|
-
function ownKeys$
|
|
2852
|
-
function _objectSpread$
|
|
2851
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2852
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2853
2853
|
function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
2854
2854
|
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
2855
2855
|
// src/error.ts
|
|
@@ -3377,7 +3377,7 @@ var DEFAULT_LIMITS = {
|
|
|
3377
3377
|
other: 10 * 1024 * 1024
|
|
3378
3378
|
};
|
|
3379
3379
|
function getSizeLimit(fileName, limits) {
|
|
3380
|
-
var merged = _objectSpread$
|
|
3380
|
+
var merged = _objectSpread$3(_objectSpread$3({}, DEFAULT_LIMITS), limits);
|
|
3381
3381
|
if (isImage(fileName)) return merged.image;
|
|
3382
3382
|
if (isVideo(fileName)) return merged.video;
|
|
3383
3383
|
return merged.other;
|
|
@@ -3405,7 +3405,7 @@ function _compressImageBlob() {
|
|
|
3405
3405
|
return _regeneratorRuntime.wrap(function (_context10) {
|
|
3406
3406
|
while (1) switch (_context10.prev = _context10.next) {
|
|
3407
3407
|
case 0:
|
|
3408
|
-
opts = _objectSpread$
|
|
3408
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), options);
|
|
3409
3409
|
if (!(typeof createImageBitmap === "undefined" || typeof OffscreenCanvas === "undefined")) {
|
|
3410
3410
|
_context10.next = 1;
|
|
3411
3411
|
break;
|
|
@@ -3471,7 +3471,7 @@ function _processFile() {
|
|
|
3471
3471
|
return _regeneratorRuntime.wrap(function (_context11) {
|
|
3472
3472
|
while (1) switch (_context11.prev = _context11.next) {
|
|
3473
3473
|
case 0:
|
|
3474
|
-
opts = _objectSpread$
|
|
3474
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), compress);
|
|
3475
3475
|
if (!(opts.enabled && isImage(fileName))) {
|
|
3476
3476
|
_context11.next = 2;
|
|
3477
3477
|
break;
|
|
@@ -3535,7 +3535,7 @@ function createOssClient() {
|
|
|
3535
3535
|
var allowedExtensions = options.allowedExtensions;
|
|
3536
3536
|
function mergeRetry(override) {
|
|
3537
3537
|
if (!defaultRetry && !override) return void 0;
|
|
3538
|
-
return _objectSpread$
|
|
3538
|
+
return _objectSpread$3(_objectSpread$3({}, defaultRetry), override);
|
|
3539
3539
|
}
|
|
3540
3540
|
function resolveCompress(override) {
|
|
3541
3541
|
if (override === false) return {
|
|
@@ -3545,7 +3545,7 @@ function createOssClient() {
|
|
|
3545
3545
|
enabled: false
|
|
3546
3546
|
};
|
|
3547
3547
|
var base = _typeof$1(defaultCompress) === "object" ? defaultCompress : {};
|
|
3548
|
-
return override ? _objectSpread$
|
|
3548
|
+
return override ? _objectSpread$3(_objectSpread$3({}, base), override) : Object.keys(base).length ? base : void 0;
|
|
3549
3549
|
}
|
|
3550
3550
|
function uploadOne(_x25, _x26, _x27, _x28) {
|
|
3551
3551
|
return _uploadOne.apply(this, arguments);
|
|
@@ -3631,7 +3631,7 @@ function createOssClient() {
|
|
|
3631
3631
|
var i = index++;
|
|
3632
3632
|
var item = files[i];
|
|
3633
3633
|
running++;
|
|
3634
|
-
var fileOpts = _objectSpread$
|
|
3634
|
+
var fileOpts = _objectSpread$3({
|
|
3635
3635
|
retry: opts === null || opts === void 0 ? void 0 : opts.retry,
|
|
3636
3636
|
compress: opts === null || opts === void 0 ? void 0 : opts.compress
|
|
3637
3637
|
}, item.options);
|
|
@@ -4112,6 +4112,48 @@ function _isUserSessionAdmin() {
|
|
|
4112
4112
|
return _isUserSessionAdmin.apply(this, arguments);
|
|
4113
4113
|
}
|
|
4114
4114
|
|
|
4115
|
+
function _arrayWithHoles(r) {
|
|
4116
|
+
if (Array.isArray(r)) return r;
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
function _iterableToArrayLimit(r, l) {
|
|
4120
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
4121
|
+
if (null != t) {
|
|
4122
|
+
var e,
|
|
4123
|
+
n,
|
|
4124
|
+
i,
|
|
4125
|
+
u,
|
|
4126
|
+
a = [],
|
|
4127
|
+
f = !0,
|
|
4128
|
+
o = !1;
|
|
4129
|
+
try {
|
|
4130
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
4131
|
+
if (Object(t) !== t) return;
|
|
4132
|
+
f = !1;
|
|
4133
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
4134
|
+
} catch (r) {
|
|
4135
|
+
o = !0, n = r;
|
|
4136
|
+
} finally {
|
|
4137
|
+
try {
|
|
4138
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
4139
|
+
} finally {
|
|
4140
|
+
if (o) throw n;
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
return a;
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
function _nonIterableRest() {
|
|
4148
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
function _slicedToArray(r, e) {
|
|
4152
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
|
|
4153
|
+
}
|
|
4154
|
+
|
|
4155
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4156
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4115
4157
|
var ACTION_LABELS = {
|
|
4116
4158
|
create: "创建",
|
|
4117
4159
|
read: "查询",
|
|
@@ -4127,9 +4169,44 @@ function getWebhookUrls() {
|
|
|
4127
4169
|
return item.trim();
|
|
4128
4170
|
}).filter(Boolean);
|
|
4129
4171
|
}
|
|
4172
|
+
function safeJsonStringify(value) {
|
|
4173
|
+
var seen = new WeakSet();
|
|
4174
|
+
try {
|
|
4175
|
+
return JSON.stringify(value, function (_key, currentValue) {
|
|
4176
|
+
if (typeof currentValue === "bigint") {
|
|
4177
|
+
return currentValue.toString();
|
|
4178
|
+
}
|
|
4179
|
+
if (_typeof$1(currentValue) === "object" && currentValue !== null) {
|
|
4180
|
+
if (seen.has(currentValue)) {
|
|
4181
|
+
return "[Circular]";
|
|
4182
|
+
}
|
|
4183
|
+
seen.add(currentValue);
|
|
4184
|
+
}
|
|
4185
|
+
return currentValue;
|
|
4186
|
+
}, 2);
|
|
4187
|
+
} catch (_unused) {
|
|
4188
|
+
return "";
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
function serializeError(error) {
|
|
4192
|
+
var extraFields = Object.fromEntries(Object.entries(error).filter(function (_ref) {
|
|
4193
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
4194
|
+
value = _ref2[1];
|
|
4195
|
+
return value !== undefined;
|
|
4196
|
+
}));
|
|
4197
|
+
return _objectSpread$2({
|
|
4198
|
+
name: error.name,
|
|
4199
|
+
message: error.message
|
|
4200
|
+
}, extraFields);
|
|
4201
|
+
}
|
|
4130
4202
|
function getErrorMessage(error) {
|
|
4131
4203
|
if (error instanceof Error) {
|
|
4132
|
-
|
|
4204
|
+
var serializedError = safeJsonStringify(serializeError(error));
|
|
4205
|
+
return serializedError || error.message;
|
|
4206
|
+
}
|
|
4207
|
+
if (_typeof$1(error) === "object" && error !== null) {
|
|
4208
|
+
var _serializedError = safeJsonStringify(error);
|
|
4209
|
+
return _serializedError || String(error);
|
|
4133
4210
|
}
|
|
4134
4211
|
return String(error);
|
|
4135
4212
|
}
|
|
@@ -4149,8 +4226,8 @@ function getSessionId(c) {
|
|
|
4149
4226
|
function buildAlertText(c, options) {
|
|
4150
4227
|
var _options$modelId, _options$recordId;
|
|
4151
4228
|
var actionLabel = ACTION_LABELS[options.action];
|
|
4152
|
-
|
|
4153
|
-
var lines = ["\u5305\u540D: @wecode-team/cms-supabase-api", "\u5BBF\u4E3B\u9879\u76EE\u6807\u8BC6(sessionId): ".concat(getSessionId(c)), "\u64CD\u4F5C\
|
|
4229
|
+
TARGET_LABELS[options.target];
|
|
4230
|
+
var lines = ["\u5305\u540D: @wecode-team/cms-supabase-api", "\u5BBF\u4E3B\u9879\u76EE\u6807\u8BC6(sessionId): ".concat(getSessionId(c)), "\u64CD\u4F5C\u7C7B\u578B: ".concat(actionLabel), "\u6570\u636E\u8868\u540D: ".concat(options.tableName || "-"), "\u6A21\u578B ID: ".concat((_options$modelId = options.modelId) !== null && _options$modelId !== void 0 ? _options$modelId : "-"), "\u8BB0\u5F55 ID: ".concat((_options$recordId = options.recordId) !== null && _options$recordId !== void 0 ? _options$recordId : "-"), "\u65F6\u95F4: ".concat(new Date().toISOString()), "\u9519\u8BEF\u4FE1\u606F: ".concat(getErrorMessage(options.error)), "\u8BF7\u6C42\u4FE1\u606F:\n".concat(buildRequestSummary(c))];
|
|
4154
4231
|
var stack = getErrorStack(options.error);
|
|
4155
4232
|
if (stack) {
|
|
4156
4233
|
lines.push("\u9519\u8BEF\u5806\u6808:\n".concat(stack));
|
|
@@ -4750,46 +4827,6 @@ function _deleteModel() {
|
|
|
4750
4827
|
return _deleteModel.apply(this, arguments);
|
|
4751
4828
|
}
|
|
4752
4829
|
|
|
4753
|
-
function _arrayWithHoles(r) {
|
|
4754
|
-
if (Array.isArray(r)) return r;
|
|
4755
|
-
}
|
|
4756
|
-
|
|
4757
|
-
function _iterableToArrayLimit(r, l) {
|
|
4758
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
4759
|
-
if (null != t) {
|
|
4760
|
-
var e,
|
|
4761
|
-
n,
|
|
4762
|
-
i,
|
|
4763
|
-
u,
|
|
4764
|
-
a = [],
|
|
4765
|
-
f = !0,
|
|
4766
|
-
o = !1;
|
|
4767
|
-
try {
|
|
4768
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
4769
|
-
if (Object(t) !== t) return;
|
|
4770
|
-
f = !1;
|
|
4771
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
4772
|
-
} catch (r) {
|
|
4773
|
-
o = !0, n = r;
|
|
4774
|
-
} finally {
|
|
4775
|
-
try {
|
|
4776
|
-
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
4777
|
-
} finally {
|
|
4778
|
-
if (o) throw n;
|
|
4779
|
-
}
|
|
4780
|
-
}
|
|
4781
|
-
return a;
|
|
4782
|
-
}
|
|
4783
|
-
}
|
|
4784
|
-
|
|
4785
|
-
function _nonIterableRest() {
|
|
4786
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4787
|
-
}
|
|
4788
|
-
|
|
4789
|
-
function _slicedToArray(r, e) {
|
|
4790
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
|
|
4791
|
-
}
|
|
4792
|
-
|
|
4793
4830
|
var _excluded = ["id", "created_at", "updated_at"],
|
|
4794
4831
|
_excluded2 = ["id"],
|
|
4795
4832
|
_excluded3 = ["created_at", "updated_at"];
|
|
@@ -7517,64 +7554,117 @@ function _supabaseCurrentUser() {
|
|
|
7517
7554
|
return _supabaseCurrentUser.apply(this, arguments);
|
|
7518
7555
|
}
|
|
7519
7556
|
|
|
7557
|
+
function isSkipAuthRequest(c) {
|
|
7558
|
+
return c.req.header("X-CMS-Skip-Auth") === "true";
|
|
7559
|
+
}
|
|
7560
|
+
function withAdmin() {
|
|
7561
|
+
return [(/*#__PURE__*/function () {
|
|
7562
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c, next) {
|
|
7563
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
7564
|
+
while (1) switch (_context.prev = _context.next) {
|
|
7565
|
+
case 0:
|
|
7566
|
+
if (!isSkipAuthRequest(c)) {
|
|
7567
|
+
_context.next = 2;
|
|
7568
|
+
break;
|
|
7569
|
+
}
|
|
7570
|
+
_context.next = 1;
|
|
7571
|
+
return next();
|
|
7572
|
+
case 1:
|
|
7573
|
+
return _context.abrupt("return");
|
|
7574
|
+
case 2:
|
|
7575
|
+
return _context.abrupt("return", requireJwtAuth(c, next));
|
|
7576
|
+
case 3:
|
|
7577
|
+
case "end":
|
|
7578
|
+
return _context.stop();
|
|
7579
|
+
}
|
|
7580
|
+
}, _callee);
|
|
7581
|
+
}));
|
|
7582
|
+
return function (_x, _x2) {
|
|
7583
|
+
return _ref.apply(this, arguments);
|
|
7584
|
+
};
|
|
7585
|
+
}()), (/*#__PURE__*/function () {
|
|
7586
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c, next) {
|
|
7587
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7588
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
7589
|
+
case 0:
|
|
7590
|
+
if (!isSkipAuthRequest(c)) {
|
|
7591
|
+
_context2.next = 2;
|
|
7592
|
+
break;
|
|
7593
|
+
}
|
|
7594
|
+
_context2.next = 1;
|
|
7595
|
+
return next();
|
|
7596
|
+
case 1:
|
|
7597
|
+
return _context2.abrupt("return");
|
|
7598
|
+
case 2:
|
|
7599
|
+
return _context2.abrupt("return", requireAdminRole(c, next));
|
|
7600
|
+
case 3:
|
|
7601
|
+
case "end":
|
|
7602
|
+
return _context2.stop();
|
|
7603
|
+
}
|
|
7604
|
+
}, _callee2);
|
|
7605
|
+
}));
|
|
7606
|
+
return function (_x3, _x4) {
|
|
7607
|
+
return _ref2.apply(this, arguments);
|
|
7608
|
+
};
|
|
7609
|
+
}())];
|
|
7610
|
+
}
|
|
7520
7611
|
// 创建模型路由处理器
|
|
7521
7612
|
function createModelRoute(app) {
|
|
7522
|
-
|
|
7523
|
-
app.
|
|
7524
|
-
app.
|
|
7525
|
-
app.
|
|
7526
|
-
app["delete"]("/models", requireJwtAuth, requireAdminRole, deleteModel);
|
|
7613
|
+
app.get.apply(app, ["/models"].concat(_toConsumableArray(withAdmin()), [getModels]));
|
|
7614
|
+
app.post.apply(app, ["/models"].concat(_toConsumableArray(withAdmin()), [createModel]));
|
|
7615
|
+
app.put.apply(app, ["/models"].concat(_toConsumableArray(withAdmin()), [updateModel]));
|
|
7616
|
+
app["delete"].apply(app, ["/models"].concat(_toConsumableArray(withAdmin()), [deleteModel]));
|
|
7527
7617
|
return app;
|
|
7528
7618
|
}
|
|
7529
7619
|
// 创建数据表路由处理器(固定表名)
|
|
7530
7620
|
function createDataRoute(app, tableName) {
|
|
7531
|
-
app.get("/data/".concat(tableName),
|
|
7621
|
+
app.get.apply(app, ["/data/".concat(tableName)].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7532
7622
|
return getTableData(c, tableName);
|
|
7533
|
-
});
|
|
7534
|
-
app.post("/data/".concat(tableName),
|
|
7623
|
+
}]));
|
|
7624
|
+
app.post.apply(app, ["/data/".concat(tableName)].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7535
7625
|
return createTableData(c, tableName);
|
|
7536
|
-
});
|
|
7537
|
-
app.put("/data/".concat(tableName),
|
|
7626
|
+
}]));
|
|
7627
|
+
app.put.apply(app, ["/data/".concat(tableName)].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7538
7628
|
return updateTableData(c, tableName);
|
|
7539
|
-
});
|
|
7540
|
-
app["delete"]("/data/".concat(tableName),
|
|
7629
|
+
}]));
|
|
7630
|
+
app["delete"].apply(app, ["/data/".concat(tableName)].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7541
7631
|
return deleteTableData(c, tableName);
|
|
7542
|
-
});
|
|
7632
|
+
}]));
|
|
7543
7633
|
return app;
|
|
7544
7634
|
}
|
|
7545
7635
|
// 动态创建数据表路由处理器(从URL参数获取表名)
|
|
7546
7636
|
function createDynamicDataRoute(app) {
|
|
7547
7637
|
// 获取关联表选项(放在 :tableName 路由之前,避免被匹配)
|
|
7548
|
-
app.get("/relation/:tableName/options",
|
|
7549
|
-
var tableName = c.req.param("tableName");
|
|
7638
|
+
app.get.apply(app, ["/relation/:tableName/options"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7639
|
+
var tableName = c.req.param("tableName") || "";
|
|
7550
7640
|
return getRelationOptions(c, tableName);
|
|
7551
|
-
});
|
|
7641
|
+
}]));
|
|
7552
7642
|
// 获取带关联数据的表数据
|
|
7553
|
-
app.get("/data/:tableName/with-relations",
|
|
7554
|
-
var tableName = c.req.param("tableName");
|
|
7643
|
+
app.get.apply(app, ["/data/:tableName/with-relations"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7644
|
+
var tableName = c.req.param("tableName") || "";
|
|
7555
7645
|
return getTableDataWithRelations(c, tableName);
|
|
7556
|
-
});
|
|
7557
|
-
app.get("/data/:tableName",
|
|
7558
|
-
var tableName = c.req.param("tableName");
|
|
7646
|
+
}]));
|
|
7647
|
+
app.get.apply(app, ["/data/:tableName"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7648
|
+
var tableName = c.req.param("tableName") || "";
|
|
7559
7649
|
return getTableData(c, tableName);
|
|
7560
|
-
});
|
|
7561
|
-
app.post("/data/:tableName",
|
|
7562
|
-
var tableName = c.req.param("tableName");
|
|
7650
|
+
}]));
|
|
7651
|
+
app.post.apply(app, ["/data/:tableName"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7652
|
+
var tableName = c.req.param("tableName") || "";
|
|
7563
7653
|
return createTableData(c, tableName);
|
|
7564
|
-
});
|
|
7565
|
-
app.put("/data/:tableName",
|
|
7566
|
-
var tableName = c.req.param("tableName");
|
|
7654
|
+
}]));
|
|
7655
|
+
app.put.apply(app, ["/data/:tableName"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7656
|
+
var tableName = c.req.param("tableName") || "";
|
|
7567
7657
|
return updateTableData(c, tableName);
|
|
7568
|
-
});
|
|
7569
|
-
app["delete"]("/data/:tableName",
|
|
7570
|
-
var tableName = c.req.param("tableName");
|
|
7658
|
+
}]));
|
|
7659
|
+
app["delete"].apply(app, ["/data/:tableName"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7660
|
+
var tableName = c.req.param("tableName") || "";
|
|
7571
7661
|
return deleteTableData(c, tableName);
|
|
7572
|
-
});
|
|
7662
|
+
}]));
|
|
7573
7663
|
// 删除表的所有外键约束(用于解决外键引用错误表的问题)
|
|
7574
|
-
app["delete"]("/data/:tableName/foreign-keys",
|
|
7575
|
-
var tableName = c.req.param("tableName");
|
|
7664
|
+
app["delete"].apply(app, ["/data/:tableName/foreign-keys"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7665
|
+
var tableName = c.req.param("tableName") || "";
|
|
7576
7666
|
return dropForeignKeys(c, tableName);
|
|
7577
|
-
});
|
|
7667
|
+
}]));
|
|
7578
7668
|
return app;
|
|
7579
7669
|
}
|
|
7580
7670
|
// 动态创建认证路由处理器(从URL参数获取表名)
|
|
@@ -7657,14 +7747,14 @@ function createAuthRoute(app, tableName) {
|
|
|
7657
7747
|
return app;
|
|
7658
7748
|
}
|
|
7659
7749
|
function createOssUploadRoute(app) {
|
|
7660
|
-
app.post("/upload",
|
|
7750
|
+
app.post.apply(app, ["/upload"].concat(_toConsumableArray(withAdmin()), [uploadToOss]));
|
|
7661
7751
|
return app;
|
|
7662
7752
|
}
|
|
7663
7753
|
function createConfigRoute(app) {
|
|
7664
|
-
app.get("/configs",
|
|
7665
|
-
app.put("/configs/:namespace",
|
|
7754
|
+
app.get.apply(app, ["/configs"].concat(_toConsumableArray(withAdmin()), [getConfig]));
|
|
7755
|
+
app.put.apply(app, ["/configs/:namespace"].concat(_toConsumableArray(withAdmin()), [function (c) {
|
|
7666
7756
|
return updateConfig(c);
|
|
7667
|
-
});
|
|
7757
|
+
}]));
|
|
7668
7758
|
return app;
|
|
7669
7759
|
}
|
|
7670
7760
|
// 一键创建所有CMS路由
|