@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.esm.js
CHANGED
|
@@ -1012,8 +1012,8 @@ function _defineProperty(e, r, t) {
|
|
|
1012
1012
|
}) : e[r] = t, e;
|
|
1013
1013
|
}
|
|
1014
1014
|
|
|
1015
|
-
function ownKeys$
|
|
1016
|
-
function _objectSpread$
|
|
1015
|
+
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; }
|
|
1016
|
+
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; }
|
|
1017
1017
|
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; } } }; }
|
|
1018
1018
|
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; } }
|
|
1019
1019
|
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; }
|
|
@@ -2069,7 +2069,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2069
2069
|
throw error;
|
|
2070
2070
|
case 2:
|
|
2071
2071
|
return _context14.abrupt("return", (data || []).map(function (item) {
|
|
2072
|
-
return _objectSpread$
|
|
2072
|
+
return _objectSpread$5({
|
|
2073
2073
|
id: item.id,
|
|
2074
2074
|
label: item[displayField] || "ID: ".concat(item.id)
|
|
2075
2075
|
}, item);
|
|
@@ -2182,8 +2182,8 @@ function getDynamicTableService() {
|
|
|
2182
2182
|
return defaultService$1;
|
|
2183
2183
|
}
|
|
2184
2184
|
|
|
2185
|
-
function ownKeys$
|
|
2186
|
-
function _objectSpread$
|
|
2185
|
+
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; }
|
|
2186
|
+
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; }
|
|
2187
2187
|
var AuthService = /*#__PURE__*/function () {
|
|
2188
2188
|
function AuthService() {
|
|
2189
2189
|
_classCallCheck(this, AuthService);
|
|
@@ -2360,7 +2360,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2360
2360
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
2361
2361
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2362
2362
|
case 0:
|
|
2363
|
-
finalUserData = _objectSpread$
|
|
2363
|
+
finalUserData = _objectSpread$4({
|
|
2364
2364
|
tableName: this.defaultTableName
|
|
2365
2365
|
}, userData);
|
|
2366
2366
|
_context4.prev = 1;
|
|
@@ -2418,7 +2418,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2418
2418
|
case 0:
|
|
2419
2419
|
updateData = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
2420
2420
|
// 设置默认值
|
|
2421
|
-
finalUpdateData = _objectSpread$
|
|
2421
|
+
finalUpdateData = _objectSpread$4({
|
|
2422
2422
|
tableName: this.defaultTableName
|
|
2423
2423
|
}, updateData);
|
|
2424
2424
|
_context5.prev = 1;
|
|
@@ -2826,8 +2826,8 @@ function _toConsumableArray(r) {
|
|
|
2826
2826
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread();
|
|
2827
2827
|
}
|
|
2828
2828
|
|
|
2829
|
-
function ownKeys$
|
|
2830
|
-
function _objectSpread$
|
|
2829
|
+
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; }
|
|
2830
|
+
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; }
|
|
2831
2831
|
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)); }
|
|
2832
2832
|
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
2833
2833
|
// src/error.ts
|
|
@@ -3355,7 +3355,7 @@ var DEFAULT_LIMITS = {
|
|
|
3355
3355
|
other: 10 * 1024 * 1024
|
|
3356
3356
|
};
|
|
3357
3357
|
function getSizeLimit(fileName, limits) {
|
|
3358
|
-
var merged = _objectSpread$
|
|
3358
|
+
var merged = _objectSpread$3(_objectSpread$3({}, DEFAULT_LIMITS), limits);
|
|
3359
3359
|
if (isImage(fileName)) return merged.image;
|
|
3360
3360
|
if (isVideo(fileName)) return merged.video;
|
|
3361
3361
|
return merged.other;
|
|
@@ -3383,7 +3383,7 @@ function _compressImageBlob() {
|
|
|
3383
3383
|
return _regeneratorRuntime.wrap(function (_context10) {
|
|
3384
3384
|
while (1) switch (_context10.prev = _context10.next) {
|
|
3385
3385
|
case 0:
|
|
3386
|
-
opts = _objectSpread$
|
|
3386
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), options);
|
|
3387
3387
|
if (!(typeof createImageBitmap === "undefined" || typeof OffscreenCanvas === "undefined")) {
|
|
3388
3388
|
_context10.next = 1;
|
|
3389
3389
|
break;
|
|
@@ -3449,7 +3449,7 @@ function _processFile() {
|
|
|
3449
3449
|
return _regeneratorRuntime.wrap(function (_context11) {
|
|
3450
3450
|
while (1) switch (_context11.prev = _context11.next) {
|
|
3451
3451
|
case 0:
|
|
3452
|
-
opts = _objectSpread$
|
|
3452
|
+
opts = _objectSpread$3(_objectSpread$3({}, DEFAULT_COMPRESS), compress);
|
|
3453
3453
|
if (!(opts.enabled && isImage(fileName))) {
|
|
3454
3454
|
_context11.next = 2;
|
|
3455
3455
|
break;
|
|
@@ -3513,7 +3513,7 @@ function createOssClient() {
|
|
|
3513
3513
|
var allowedExtensions = options.allowedExtensions;
|
|
3514
3514
|
function mergeRetry(override) {
|
|
3515
3515
|
if (!defaultRetry && !override) return void 0;
|
|
3516
|
-
return _objectSpread$
|
|
3516
|
+
return _objectSpread$3(_objectSpread$3({}, defaultRetry), override);
|
|
3517
3517
|
}
|
|
3518
3518
|
function resolveCompress(override) {
|
|
3519
3519
|
if (override === false) return {
|
|
@@ -3523,7 +3523,7 @@ function createOssClient() {
|
|
|
3523
3523
|
enabled: false
|
|
3524
3524
|
};
|
|
3525
3525
|
var base = _typeof$1(defaultCompress) === "object" ? defaultCompress : {};
|
|
3526
|
-
return override ? _objectSpread$
|
|
3526
|
+
return override ? _objectSpread$3(_objectSpread$3({}, base), override) : Object.keys(base).length ? base : void 0;
|
|
3527
3527
|
}
|
|
3528
3528
|
function uploadOne(_x25, _x26, _x27, _x28) {
|
|
3529
3529
|
return _uploadOne.apply(this, arguments);
|
|
@@ -3609,7 +3609,7 @@ function createOssClient() {
|
|
|
3609
3609
|
var i = index++;
|
|
3610
3610
|
var item = files[i];
|
|
3611
3611
|
running++;
|
|
3612
|
-
var fileOpts = _objectSpread$
|
|
3612
|
+
var fileOpts = _objectSpread$3({
|
|
3613
3613
|
retry: opts === null || opts === void 0 ? void 0 : opts.retry,
|
|
3614
3614
|
compress: opts === null || opts === void 0 ? void 0 : opts.compress
|
|
3615
3615
|
}, item.options);
|
|
@@ -4090,6 +4090,48 @@ function _isUserSessionAdmin() {
|
|
|
4090
4090
|
return _isUserSessionAdmin.apply(this, arguments);
|
|
4091
4091
|
}
|
|
4092
4092
|
|
|
4093
|
+
function _arrayWithHoles(r) {
|
|
4094
|
+
if (Array.isArray(r)) return r;
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
function _iterableToArrayLimit(r, l) {
|
|
4098
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
4099
|
+
if (null != t) {
|
|
4100
|
+
var e,
|
|
4101
|
+
n,
|
|
4102
|
+
i,
|
|
4103
|
+
u,
|
|
4104
|
+
a = [],
|
|
4105
|
+
f = !0,
|
|
4106
|
+
o = !1;
|
|
4107
|
+
try {
|
|
4108
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
4109
|
+
if (Object(t) !== t) return;
|
|
4110
|
+
f = !1;
|
|
4111
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
4112
|
+
} catch (r) {
|
|
4113
|
+
o = !0, n = r;
|
|
4114
|
+
} finally {
|
|
4115
|
+
try {
|
|
4116
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
4117
|
+
} finally {
|
|
4118
|
+
if (o) throw n;
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
4121
|
+
return a;
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
function _nonIterableRest() {
|
|
4126
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
function _slicedToArray(r, e) {
|
|
4130
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
|
|
4131
|
+
}
|
|
4132
|
+
|
|
4133
|
+
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; }
|
|
4134
|
+
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; }
|
|
4093
4135
|
var ACTION_LABELS = {
|
|
4094
4136
|
create: "创建",
|
|
4095
4137
|
read: "查询",
|
|
@@ -4105,9 +4147,44 @@ function getWebhookUrls() {
|
|
|
4105
4147
|
return item.trim();
|
|
4106
4148
|
}).filter(Boolean);
|
|
4107
4149
|
}
|
|
4150
|
+
function safeJsonStringify(value) {
|
|
4151
|
+
var seen = new WeakSet();
|
|
4152
|
+
try {
|
|
4153
|
+
return JSON.stringify(value, function (_key, currentValue) {
|
|
4154
|
+
if (typeof currentValue === "bigint") {
|
|
4155
|
+
return currentValue.toString();
|
|
4156
|
+
}
|
|
4157
|
+
if (_typeof$1(currentValue) === "object" && currentValue !== null) {
|
|
4158
|
+
if (seen.has(currentValue)) {
|
|
4159
|
+
return "[Circular]";
|
|
4160
|
+
}
|
|
4161
|
+
seen.add(currentValue);
|
|
4162
|
+
}
|
|
4163
|
+
return currentValue;
|
|
4164
|
+
}, 2);
|
|
4165
|
+
} catch (_unused) {
|
|
4166
|
+
return "";
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
function serializeError(error) {
|
|
4170
|
+
var extraFields = Object.fromEntries(Object.entries(error).filter(function (_ref) {
|
|
4171
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
4172
|
+
value = _ref2[1];
|
|
4173
|
+
return value !== undefined;
|
|
4174
|
+
}));
|
|
4175
|
+
return _objectSpread$2({
|
|
4176
|
+
name: error.name,
|
|
4177
|
+
message: error.message
|
|
4178
|
+
}, extraFields);
|
|
4179
|
+
}
|
|
4108
4180
|
function getErrorMessage(error) {
|
|
4109
4181
|
if (error instanceof Error) {
|
|
4110
|
-
|
|
4182
|
+
var serializedError = safeJsonStringify(serializeError(error));
|
|
4183
|
+
return serializedError || error.message;
|
|
4184
|
+
}
|
|
4185
|
+
if (_typeof$1(error) === "object" && error !== null) {
|
|
4186
|
+
var _serializedError = safeJsonStringify(error);
|
|
4187
|
+
return _serializedError || String(error);
|
|
4111
4188
|
}
|
|
4112
4189
|
return String(error);
|
|
4113
4190
|
}
|
|
@@ -4127,8 +4204,8 @@ function getSessionId(c) {
|
|
|
4127
4204
|
function buildAlertText(c, options) {
|
|
4128
4205
|
var _options$modelId, _options$recordId;
|
|
4129
4206
|
var actionLabel = ACTION_LABELS[options.action];
|
|
4130
|
-
|
|
4131
|
-
var lines = ["\u5305\u540D: @wecode-team/cms-supabase-api", "\u5BBF\u4E3B\u9879\u76EE\u6807\u8BC6(sessionId): ".concat(getSessionId(c)), "\u64CD\u4F5C\
|
|
4207
|
+
TARGET_LABELS[options.target];
|
|
4208
|
+
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))];
|
|
4132
4209
|
var stack = getErrorStack(options.error);
|
|
4133
4210
|
if (stack) {
|
|
4134
4211
|
lines.push("\u9519\u8BEF\u5806\u6808:\n".concat(stack));
|
|
@@ -4728,46 +4805,6 @@ function _deleteModel() {
|
|
|
4728
4805
|
return _deleteModel.apply(this, arguments);
|
|
4729
4806
|
}
|
|
4730
4807
|
|
|
4731
|
-
function _arrayWithHoles(r) {
|
|
4732
|
-
if (Array.isArray(r)) return r;
|
|
4733
|
-
}
|
|
4734
|
-
|
|
4735
|
-
function _iterableToArrayLimit(r, l) {
|
|
4736
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
4737
|
-
if (null != t) {
|
|
4738
|
-
var e,
|
|
4739
|
-
n,
|
|
4740
|
-
i,
|
|
4741
|
-
u,
|
|
4742
|
-
a = [],
|
|
4743
|
-
f = !0,
|
|
4744
|
-
o = !1;
|
|
4745
|
-
try {
|
|
4746
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
4747
|
-
if (Object(t) !== t) return;
|
|
4748
|
-
f = !1;
|
|
4749
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
4750
|
-
} catch (r) {
|
|
4751
|
-
o = !0, n = r;
|
|
4752
|
-
} finally {
|
|
4753
|
-
try {
|
|
4754
|
-
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
4755
|
-
} finally {
|
|
4756
|
-
if (o) throw n;
|
|
4757
|
-
}
|
|
4758
|
-
}
|
|
4759
|
-
return a;
|
|
4760
|
-
}
|
|
4761
|
-
}
|
|
4762
|
-
|
|
4763
|
-
function _nonIterableRest() {
|
|
4764
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4765
|
-
}
|
|
4766
|
-
|
|
4767
|
-
function _slicedToArray(r, e) {
|
|
4768
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
|
|
4769
|
-
}
|
|
4770
|
-
|
|
4771
4808
|
var _excluded = ["id", "created_at", "updated_at"],
|
|
4772
4809
|
_excluded2 = ["id"],
|
|
4773
4810
|
_excluded3 = ["created_at", "updated_at"];
|
|
@@ -6923,7 +6960,7 @@ function validateConfigSessionId(sessionId) {
|
|
|
6923
6960
|
return null;
|
|
6924
6961
|
}
|
|
6925
6962
|
function getConfigsTableName(sessionId) {
|
|
6926
|
-
return "".concat(sessionId, "__config__");
|
|
6963
|
+
return "".concat(sessionId.replace(/-/g, '_'), "__config__");
|
|
6927
6964
|
}
|
|
6928
6965
|
function normalizeValues(values) {
|
|
6929
6966
|
if (!values || _typeof$1(values) !== "object" || Array.isArray(values)) {
|
|
@@ -6959,50 +6996,50 @@ function toConfigResponse(row, fallbackNamespace) {
|
|
|
6959
6996
|
updated_at: row === null || row === void 0 ? void 0 : row.updated_at
|
|
6960
6997
|
};
|
|
6961
6998
|
}
|
|
6962
|
-
function getConfig(
|
|
6999
|
+
function getConfig(_x) {
|
|
6963
7000
|
return _getConfig.apply(this, arguments);
|
|
6964
7001
|
}
|
|
6965
7002
|
function _getConfig() {
|
|
6966
|
-
_getConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
7003
|
+
_getConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c) {
|
|
6967
7004
|
var namespace, namespaceError, _response, sessionId, sessionError, _response2, tableName, supabase, _yield$supabase$from$, data, error, response, _response3, _t;
|
|
6968
|
-
return _regeneratorRuntime.wrap(function (
|
|
6969
|
-
while (1) switch (
|
|
7005
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
7006
|
+
while (1) switch (_context.prev = _context.next) {
|
|
6970
7007
|
case 0:
|
|
6971
|
-
|
|
7008
|
+
_context.prev = 0;
|
|
6972
7009
|
namespace = (c.req.query("namespace") || "").trim();
|
|
6973
7010
|
namespaceError = validateNamespace(namespace);
|
|
6974
7011
|
if (!namespaceError) {
|
|
6975
|
-
|
|
7012
|
+
_context.next = 1;
|
|
6976
7013
|
break;
|
|
6977
7014
|
}
|
|
6978
7015
|
_response = {
|
|
6979
7016
|
success: false,
|
|
6980
7017
|
message: namespaceError
|
|
6981
7018
|
};
|
|
6982
|
-
return
|
|
7019
|
+
return _context.abrupt("return", c.json(_response, 200));
|
|
6983
7020
|
case 1:
|
|
6984
7021
|
sessionId = getConfigSessionId(c);
|
|
6985
7022
|
sessionError = validateConfigSessionId(sessionId);
|
|
6986
7023
|
if (!sessionError) {
|
|
6987
|
-
|
|
7024
|
+
_context.next = 2;
|
|
6988
7025
|
break;
|
|
6989
7026
|
}
|
|
6990
7027
|
_response2 = {
|
|
6991
7028
|
success: false,
|
|
6992
7029
|
message: sessionError
|
|
6993
7030
|
};
|
|
6994
|
-
return
|
|
7031
|
+
return _context.abrupt("return", c.json(_response2, 200));
|
|
6995
7032
|
case 2:
|
|
6996
7033
|
tableName = getConfigsTableName(sessionId);
|
|
6997
7034
|
supabase = getSupabase();
|
|
6998
|
-
|
|
7035
|
+
_context.next = 3;
|
|
6999
7036
|
return supabase.from(tableName).select("*").eq("namespace", namespace).maybeSingle();
|
|
7000
7037
|
case 3:
|
|
7001
|
-
_yield$supabase$from$ =
|
|
7038
|
+
_yield$supabase$from$ = _context.sent;
|
|
7002
7039
|
data = _yield$supabase$from$.data;
|
|
7003
7040
|
error = _yield$supabase$from$.error;
|
|
7004
7041
|
if (!error) {
|
|
7005
|
-
|
|
7042
|
+
_context.next = 4;
|
|
7006
7043
|
break;
|
|
7007
7044
|
}
|
|
7008
7045
|
throw error;
|
|
@@ -7011,80 +7048,80 @@ function _getConfig() {
|
|
|
7011
7048
|
success: true,
|
|
7012
7049
|
data: toConfigResponse(data, namespace)
|
|
7013
7050
|
};
|
|
7014
|
-
return
|
|
7051
|
+
return _context.abrupt("return", c.json(response, 200));
|
|
7015
7052
|
case 5:
|
|
7016
|
-
|
|
7017
|
-
_t =
|
|
7053
|
+
_context.prev = 5;
|
|
7054
|
+
_t = _context["catch"](0);
|
|
7018
7055
|
console.error("获取配置失败:", _t);
|
|
7019
7056
|
_response3 = {
|
|
7020
7057
|
success: false,
|
|
7021
7058
|
message: "获取配置失败",
|
|
7022
7059
|
error: _t.message
|
|
7023
7060
|
};
|
|
7024
|
-
return
|
|
7061
|
+
return _context.abrupt("return", c.json(_response3, 500));
|
|
7025
7062
|
case 6:
|
|
7026
7063
|
case "end":
|
|
7027
|
-
return
|
|
7064
|
+
return _context.stop();
|
|
7028
7065
|
}
|
|
7029
|
-
},
|
|
7066
|
+
}, _callee, null, [[0, 5]]);
|
|
7030
7067
|
}));
|
|
7031
7068
|
return _getConfig.apply(this, arguments);
|
|
7032
7069
|
}
|
|
7033
|
-
function updateConfig(
|
|
7070
|
+
function updateConfig(_x2) {
|
|
7034
7071
|
return _updateConfig.apply(this, arguments);
|
|
7035
7072
|
}
|
|
7036
7073
|
function _updateConfig() {
|
|
7037
|
-
_updateConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
7074
|
+
_updateConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
7038
7075
|
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;
|
|
7039
|
-
return _regeneratorRuntime.wrap(function (
|
|
7040
|
-
while (1) switch (
|
|
7076
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7077
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
7041
7078
|
case 0:
|
|
7042
|
-
|
|
7079
|
+
_context2.prev = 0;
|
|
7043
7080
|
namespace = (c.req.param("namespace") || "").trim();
|
|
7044
7081
|
namespaceError = validateNamespace(namespace);
|
|
7045
7082
|
if (!namespaceError) {
|
|
7046
|
-
|
|
7083
|
+
_context2.next = 1;
|
|
7047
7084
|
break;
|
|
7048
7085
|
}
|
|
7049
7086
|
_response4 = {
|
|
7050
7087
|
success: false,
|
|
7051
7088
|
message: namespaceError
|
|
7052
7089
|
};
|
|
7053
|
-
return
|
|
7090
|
+
return _context2.abrupt("return", c.json(_response4, 200));
|
|
7054
7091
|
case 1:
|
|
7055
|
-
|
|
7092
|
+
_context2.next = 2;
|
|
7056
7093
|
return c.req.json();
|
|
7057
7094
|
case 2:
|
|
7058
|
-
body =
|
|
7095
|
+
body = _context2.sent;
|
|
7059
7096
|
values = normalizeValues(body === null || body === void 0 ? void 0 : body.values);
|
|
7060
7097
|
sessionId = getConfigSessionId(c);
|
|
7061
7098
|
sessionError = validateConfigSessionId(sessionId);
|
|
7062
7099
|
if (!sessionError) {
|
|
7063
|
-
|
|
7100
|
+
_context2.next = 3;
|
|
7064
7101
|
break;
|
|
7065
7102
|
}
|
|
7066
7103
|
_response5 = {
|
|
7067
7104
|
success: false,
|
|
7068
7105
|
message: sessionError
|
|
7069
7106
|
};
|
|
7070
|
-
return
|
|
7107
|
+
return _context2.abrupt("return", c.json(_response5, 200));
|
|
7071
7108
|
case 3:
|
|
7072
7109
|
tableName = getConfigsTableName(sessionId);
|
|
7073
7110
|
supabase = getSupabase();
|
|
7074
|
-
|
|
7111
|
+
_context2.next = 4;
|
|
7075
7112
|
return supabase.from(tableName).select("values").eq("namespace", namespace).maybeSingle();
|
|
7076
7113
|
case 4:
|
|
7077
|
-
_yield$supabase$from$2 =
|
|
7114
|
+
_yield$supabase$from$2 = _context2.sent;
|
|
7078
7115
|
existing = _yield$supabase$from$2.data;
|
|
7079
7116
|
existingError = _yield$supabase$from$2.error;
|
|
7080
7117
|
if (!existingError) {
|
|
7081
|
-
|
|
7118
|
+
_context2.next = 5;
|
|
7082
7119
|
break;
|
|
7083
7120
|
}
|
|
7084
7121
|
throw existingError;
|
|
7085
7122
|
case 5:
|
|
7086
7123
|
nextValues = _objectSpread(_objectSpread({}, normalizeValues(existing === null || existing === void 0 ? void 0 : existing.values)), values);
|
|
7087
|
-
|
|
7124
|
+
_context2.next = 6;
|
|
7088
7125
|
return supabase.from(tableName).upsert({
|
|
7089
7126
|
namespace: namespace,
|
|
7090
7127
|
values: nextValues,
|
|
@@ -7093,11 +7130,11 @@ function _updateConfig() {
|
|
|
7093
7130
|
onConflict: "namespace"
|
|
7094
7131
|
}).select("*").single();
|
|
7095
7132
|
case 6:
|
|
7096
|
-
_yield$supabase$from$3 =
|
|
7133
|
+
_yield$supabase$from$3 = _context2.sent;
|
|
7097
7134
|
data = _yield$supabase$from$3.data;
|
|
7098
7135
|
error = _yield$supabase$from$3.error;
|
|
7099
7136
|
if (!error) {
|
|
7100
|
-
|
|
7137
|
+
_context2.next = 7;
|
|
7101
7138
|
break;
|
|
7102
7139
|
}
|
|
7103
7140
|
throw error;
|
|
@@ -7107,22 +7144,22 @@ function _updateConfig() {
|
|
|
7107
7144
|
message: "配置保存成功",
|
|
7108
7145
|
data: toConfigResponse(data, namespace)
|
|
7109
7146
|
};
|
|
7110
|
-
return
|
|
7147
|
+
return _context2.abrupt("return", c.json(response, 200));
|
|
7111
7148
|
case 8:
|
|
7112
|
-
|
|
7113
|
-
_t2 =
|
|
7149
|
+
_context2.prev = 8;
|
|
7150
|
+
_t2 = _context2["catch"](0);
|
|
7114
7151
|
console.error("保存配置失败:", _t2);
|
|
7115
7152
|
_response6 = {
|
|
7116
7153
|
success: false,
|
|
7117
7154
|
message: "保存配置失败",
|
|
7118
7155
|
error: _t2.message
|
|
7119
7156
|
};
|
|
7120
|
-
return
|
|
7157
|
+
return _context2.abrupt("return", c.json(_response6, 500));
|
|
7121
7158
|
case 9:
|
|
7122
7159
|
case "end":
|
|
7123
|
-
return
|
|
7160
|
+
return _context2.stop();
|
|
7124
7161
|
}
|
|
7125
|
-
},
|
|
7162
|
+
}, _callee2, null, [[0, 8]]);
|
|
7126
7163
|
}));
|
|
7127
7164
|
return _updateConfig.apply(this, arguments);
|
|
7128
7165
|
}
|