@wecode-team/cms-supabase-api 0.1.51 → 0.1.53
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.esm.js +137 -100
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +137 -100
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/supabase-setup.sql +25 -0
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"];
|
|
@@ -6945,7 +6982,7 @@ function validateConfigSessionId(sessionId) {
|
|
|
6945
6982
|
return null;
|
|
6946
6983
|
}
|
|
6947
6984
|
function getConfigsTableName(sessionId) {
|
|
6948
|
-
return "".concat(sessionId, "__config__");
|
|
6985
|
+
return "".concat(sessionId.replace(/-/g, '_'), "__config__");
|
|
6949
6986
|
}
|
|
6950
6987
|
function normalizeValues(values) {
|
|
6951
6988
|
if (!values || _typeof$1(values) !== "object" || Array.isArray(values)) {
|
|
@@ -6981,50 +7018,50 @@ function toConfigResponse(row, fallbackNamespace) {
|
|
|
6981
7018
|
updated_at: row === null || row === void 0 ? void 0 : row.updated_at
|
|
6982
7019
|
};
|
|
6983
7020
|
}
|
|
6984
|
-
function getConfig(
|
|
7021
|
+
function getConfig(_x) {
|
|
6985
7022
|
return _getConfig.apply(this, arguments);
|
|
6986
7023
|
}
|
|
6987
7024
|
function _getConfig() {
|
|
6988
|
-
_getConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
7025
|
+
_getConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c) {
|
|
6989
7026
|
var namespace, namespaceError, _response, sessionId, sessionError, _response2, tableName, supabase, _yield$supabase$from$, data, error, response, _response3, _t;
|
|
6990
|
-
return _regeneratorRuntime.wrap(function (
|
|
6991
|
-
while (1) switch (
|
|
7027
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
7028
|
+
while (1) switch (_context.prev = _context.next) {
|
|
6992
7029
|
case 0:
|
|
6993
|
-
|
|
7030
|
+
_context.prev = 0;
|
|
6994
7031
|
namespace = (c.req.query("namespace") || "").trim();
|
|
6995
7032
|
namespaceError = validateNamespace(namespace);
|
|
6996
7033
|
if (!namespaceError) {
|
|
6997
|
-
|
|
7034
|
+
_context.next = 1;
|
|
6998
7035
|
break;
|
|
6999
7036
|
}
|
|
7000
7037
|
_response = {
|
|
7001
7038
|
success: false,
|
|
7002
7039
|
message: namespaceError
|
|
7003
7040
|
};
|
|
7004
|
-
return
|
|
7041
|
+
return _context.abrupt("return", c.json(_response, 200));
|
|
7005
7042
|
case 1:
|
|
7006
7043
|
sessionId = getConfigSessionId(c);
|
|
7007
7044
|
sessionError = validateConfigSessionId(sessionId);
|
|
7008
7045
|
if (!sessionError) {
|
|
7009
|
-
|
|
7046
|
+
_context.next = 2;
|
|
7010
7047
|
break;
|
|
7011
7048
|
}
|
|
7012
7049
|
_response2 = {
|
|
7013
7050
|
success: false,
|
|
7014
7051
|
message: sessionError
|
|
7015
7052
|
};
|
|
7016
|
-
return
|
|
7053
|
+
return _context.abrupt("return", c.json(_response2, 200));
|
|
7017
7054
|
case 2:
|
|
7018
7055
|
tableName = getConfigsTableName(sessionId);
|
|
7019
7056
|
supabase = getSupabase();
|
|
7020
|
-
|
|
7057
|
+
_context.next = 3;
|
|
7021
7058
|
return supabase.from(tableName).select("*").eq("namespace", namespace).maybeSingle();
|
|
7022
7059
|
case 3:
|
|
7023
|
-
_yield$supabase$from$ =
|
|
7060
|
+
_yield$supabase$from$ = _context.sent;
|
|
7024
7061
|
data = _yield$supabase$from$.data;
|
|
7025
7062
|
error = _yield$supabase$from$.error;
|
|
7026
7063
|
if (!error) {
|
|
7027
|
-
|
|
7064
|
+
_context.next = 4;
|
|
7028
7065
|
break;
|
|
7029
7066
|
}
|
|
7030
7067
|
throw error;
|
|
@@ -7033,80 +7070,80 @@ function _getConfig() {
|
|
|
7033
7070
|
success: true,
|
|
7034
7071
|
data: toConfigResponse(data, namespace)
|
|
7035
7072
|
};
|
|
7036
|
-
return
|
|
7073
|
+
return _context.abrupt("return", c.json(response, 200));
|
|
7037
7074
|
case 5:
|
|
7038
|
-
|
|
7039
|
-
_t =
|
|
7075
|
+
_context.prev = 5;
|
|
7076
|
+
_t = _context["catch"](0);
|
|
7040
7077
|
console.error("获取配置失败:", _t);
|
|
7041
7078
|
_response3 = {
|
|
7042
7079
|
success: false,
|
|
7043
7080
|
message: "获取配置失败",
|
|
7044
7081
|
error: _t.message
|
|
7045
7082
|
};
|
|
7046
|
-
return
|
|
7083
|
+
return _context.abrupt("return", c.json(_response3, 500));
|
|
7047
7084
|
case 6:
|
|
7048
7085
|
case "end":
|
|
7049
|
-
return
|
|
7086
|
+
return _context.stop();
|
|
7050
7087
|
}
|
|
7051
|
-
},
|
|
7088
|
+
}, _callee, null, [[0, 5]]);
|
|
7052
7089
|
}));
|
|
7053
7090
|
return _getConfig.apply(this, arguments);
|
|
7054
7091
|
}
|
|
7055
|
-
function updateConfig(
|
|
7092
|
+
function updateConfig(_x2) {
|
|
7056
7093
|
return _updateConfig.apply(this, arguments);
|
|
7057
7094
|
}
|
|
7058
7095
|
function _updateConfig() {
|
|
7059
|
-
_updateConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
7096
|
+
_updateConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
7060
7097
|
var namespace, namespaceError, _response4, body, values, sessionId, sessionError, _response5, tableName, supabase, _yield$supabase$from$2, existing, existingError, nextValues, _yield$supabase$from$3, data, error, response, _response6, _t2;
|
|
7061
|
-
return _regeneratorRuntime.wrap(function (
|
|
7062
|
-
while (1) switch (
|
|
7098
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7099
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
7063
7100
|
case 0:
|
|
7064
|
-
|
|
7101
|
+
_context2.prev = 0;
|
|
7065
7102
|
namespace = (c.req.param("namespace") || "").trim();
|
|
7066
7103
|
namespaceError = validateNamespace(namespace);
|
|
7067
7104
|
if (!namespaceError) {
|
|
7068
|
-
|
|
7105
|
+
_context2.next = 1;
|
|
7069
7106
|
break;
|
|
7070
7107
|
}
|
|
7071
7108
|
_response4 = {
|
|
7072
7109
|
success: false,
|
|
7073
7110
|
message: namespaceError
|
|
7074
7111
|
};
|
|
7075
|
-
return
|
|
7112
|
+
return _context2.abrupt("return", c.json(_response4, 200));
|
|
7076
7113
|
case 1:
|
|
7077
|
-
|
|
7114
|
+
_context2.next = 2;
|
|
7078
7115
|
return c.req.json();
|
|
7079
7116
|
case 2:
|
|
7080
|
-
body =
|
|
7117
|
+
body = _context2.sent;
|
|
7081
7118
|
values = normalizeValues(body === null || body === void 0 ? void 0 : body.values);
|
|
7082
7119
|
sessionId = getConfigSessionId(c);
|
|
7083
7120
|
sessionError = validateConfigSessionId(sessionId);
|
|
7084
7121
|
if (!sessionError) {
|
|
7085
|
-
|
|
7122
|
+
_context2.next = 3;
|
|
7086
7123
|
break;
|
|
7087
7124
|
}
|
|
7088
7125
|
_response5 = {
|
|
7089
7126
|
success: false,
|
|
7090
7127
|
message: sessionError
|
|
7091
7128
|
};
|
|
7092
|
-
return
|
|
7129
|
+
return _context2.abrupt("return", c.json(_response5, 200));
|
|
7093
7130
|
case 3:
|
|
7094
7131
|
tableName = getConfigsTableName(sessionId);
|
|
7095
7132
|
supabase = getSupabase();
|
|
7096
|
-
|
|
7133
|
+
_context2.next = 4;
|
|
7097
7134
|
return supabase.from(tableName).select("values").eq("namespace", namespace).maybeSingle();
|
|
7098
7135
|
case 4:
|
|
7099
|
-
_yield$supabase$from$2 =
|
|
7136
|
+
_yield$supabase$from$2 = _context2.sent;
|
|
7100
7137
|
existing = _yield$supabase$from$2.data;
|
|
7101
7138
|
existingError = _yield$supabase$from$2.error;
|
|
7102
7139
|
if (!existingError) {
|
|
7103
|
-
|
|
7140
|
+
_context2.next = 5;
|
|
7104
7141
|
break;
|
|
7105
7142
|
}
|
|
7106
7143
|
throw existingError;
|
|
7107
7144
|
case 5:
|
|
7108
7145
|
nextValues = _objectSpread(_objectSpread({}, normalizeValues(existing === null || existing === void 0 ? void 0 : existing.values)), values);
|
|
7109
|
-
|
|
7146
|
+
_context2.next = 6;
|
|
7110
7147
|
return supabase.from(tableName).upsert({
|
|
7111
7148
|
namespace: namespace,
|
|
7112
7149
|
values: nextValues,
|
|
@@ -7115,11 +7152,11 @@ function _updateConfig() {
|
|
|
7115
7152
|
onConflict: "namespace"
|
|
7116
7153
|
}).select("*").single();
|
|
7117
7154
|
case 6:
|
|
7118
|
-
_yield$supabase$from$3 =
|
|
7155
|
+
_yield$supabase$from$3 = _context2.sent;
|
|
7119
7156
|
data = _yield$supabase$from$3.data;
|
|
7120
7157
|
error = _yield$supabase$from$3.error;
|
|
7121
7158
|
if (!error) {
|
|
7122
|
-
|
|
7159
|
+
_context2.next = 7;
|
|
7123
7160
|
break;
|
|
7124
7161
|
}
|
|
7125
7162
|
throw error;
|
|
@@ -7129,22 +7166,22 @@ function _updateConfig() {
|
|
|
7129
7166
|
message: "配置保存成功",
|
|
7130
7167
|
data: toConfigResponse(data, namespace)
|
|
7131
7168
|
};
|
|
7132
|
-
return
|
|
7169
|
+
return _context2.abrupt("return", c.json(response, 200));
|
|
7133
7170
|
case 8:
|
|
7134
|
-
|
|
7135
|
-
_t2 =
|
|
7171
|
+
_context2.prev = 8;
|
|
7172
|
+
_t2 = _context2["catch"](0);
|
|
7136
7173
|
console.error("保存配置失败:", _t2);
|
|
7137
7174
|
_response6 = {
|
|
7138
7175
|
success: false,
|
|
7139
7176
|
message: "保存配置失败",
|
|
7140
7177
|
error: _t2.message
|
|
7141
7178
|
};
|
|
7142
|
-
return
|
|
7179
|
+
return _context2.abrupt("return", c.json(_response6, 500));
|
|
7143
7180
|
case 9:
|
|
7144
7181
|
case "end":
|
|
7145
|
-
return
|
|
7182
|
+
return _context2.stop();
|
|
7146
7183
|
}
|
|
7147
|
-
},
|
|
7184
|
+
}, _callee2, null, [[0, 8]]);
|
|
7148
7185
|
}));
|
|
7149
7186
|
return _updateConfig.apply(this, arguments);
|
|
7150
7187
|
}
|