@wecode-team/cms-supabase-api 0.1.43 → 0.1.44
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 +1855 -949
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1855 -949
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ function _interopNamespaceDefault(e) {
|
|
|
24
24
|
var jwt__namespace = /*#__PURE__*/_interopNamespaceDefault(jwt);
|
|
25
25
|
var bcrypt__namespace = /*#__PURE__*/_interopNamespaceDefault(bcrypt);
|
|
26
26
|
|
|
27
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
27
|
+
function asyncGeneratorStep$1(n, t, e, r, o, a, c) {
|
|
28
28
|
try {
|
|
29
29
|
var i = n[a](c),
|
|
30
30
|
u = i.value;
|
|
@@ -33,391 +33,390 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
|
33
33
|
}
|
|
34
34
|
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
35
35
|
}
|
|
36
|
-
function _asyncToGenerator(n) {
|
|
36
|
+
function _asyncToGenerator$1(n) {
|
|
37
37
|
return function () {
|
|
38
38
|
var t = this,
|
|
39
39
|
e = arguments;
|
|
40
40
|
return new Promise(function (r, o) {
|
|
41
41
|
var a = n.apply(t, e);
|
|
42
42
|
function _next(n) {
|
|
43
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
43
|
+
asyncGeneratorStep$1(a, r, o, _next, _throw, "next", n);
|
|
44
44
|
}
|
|
45
45
|
function _throw(n) {
|
|
46
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
46
|
+
asyncGeneratorStep$1(a, r, o, _next, _throw, "throw", n);
|
|
47
47
|
}
|
|
48
48
|
_next(void 0);
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function _typeof$3(o) {
|
|
54
|
+
"@babel/helpers - typeof";
|
|
55
|
+
|
|
56
|
+
return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
57
|
+
return typeof o;
|
|
58
|
+
} : function (o) {
|
|
59
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
60
|
+
}, _typeof$3(o);
|
|
61
|
+
}
|
|
62
|
+
|
|
53
63
|
function getDefaultExportFromCjs (x) {
|
|
54
64
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
55
65
|
}
|
|
56
66
|
|
|
57
|
-
var regeneratorRuntime$
|
|
67
|
+
var regeneratorRuntime$2 = {exports: {}};
|
|
58
68
|
|
|
59
|
-
var OverloadYield = {exports: {}};
|
|
69
|
+
var OverloadYield$1 = {exports: {}};
|
|
60
70
|
|
|
61
71
|
(function (module) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
72
|
+
function _OverloadYield(e, d) {
|
|
73
|
+
this.v = e, this.k = d;
|
|
74
|
+
}
|
|
75
|
+
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
76
|
+
})(OverloadYield$1);
|
|
77
|
+
var OverloadYieldExports$1 = OverloadYield$1.exports;
|
|
67
78
|
|
|
68
|
-
var
|
|
79
|
+
var regenerator$3 = {exports: {}};
|
|
69
80
|
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
var regeneratorDefine = {exports: {}};
|
|
81
|
+
var regeneratorDefine$1 = {exports: {}};
|
|
73
82
|
|
|
74
83
|
(function (module) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var regeneratorDefineExports = regeneratorDefine.exports;
|
|
84
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
85
|
+
var i = Object.defineProperty;
|
|
86
|
+
try {
|
|
87
|
+
i({}, "", {});
|
|
88
|
+
} catch (e) {
|
|
89
|
+
i = 0;
|
|
90
|
+
}
|
|
91
|
+
module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
|
|
92
|
+
function o(r, n) {
|
|
93
|
+
_regeneratorDefine(e, r, function (e) {
|
|
94
|
+
return this._invoke(r, n, e);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
r ? i ? i(e, r, {
|
|
98
|
+
value: n,
|
|
99
|
+
enumerable: !t,
|
|
100
|
+
configurable: !t,
|
|
101
|
+
writable: !t
|
|
102
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
103
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
|
|
104
|
+
}
|
|
105
|
+
module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
106
|
+
})(regeneratorDefine$1);
|
|
107
|
+
var regeneratorDefineExports$1 = regeneratorDefine$1.exports;
|
|
100
108
|
|
|
101
109
|
(function (module) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
var regeneratorExports = regenerator$1.exports;
|
|
110
|
+
var regeneratorDefine = regeneratorDefineExports$1;
|
|
111
|
+
function _regenerator() {
|
|
112
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
113
|
+
var e,
|
|
114
|
+
t,
|
|
115
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
116
|
+
n = r.iterator || "@@iterator",
|
|
117
|
+
o = r.toStringTag || "@@toStringTag";
|
|
118
|
+
function i(r, n, o, i) {
|
|
119
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
120
|
+
u = Object.create(c.prototype);
|
|
121
|
+
return regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
122
|
+
var i,
|
|
123
|
+
c,
|
|
124
|
+
u,
|
|
125
|
+
f = 0,
|
|
126
|
+
p = o || [],
|
|
127
|
+
y = !1,
|
|
128
|
+
G = {
|
|
129
|
+
p: 0,
|
|
130
|
+
n: 0,
|
|
131
|
+
v: e,
|
|
132
|
+
a: d,
|
|
133
|
+
f: d.bind(e, 4),
|
|
134
|
+
d: function d(t, r) {
|
|
135
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
function d(r, n) {
|
|
139
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
140
|
+
var o,
|
|
141
|
+
i = p[t],
|
|
142
|
+
d = G.p,
|
|
143
|
+
l = i[2];
|
|
144
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
145
|
+
}
|
|
146
|
+
if (o || r > 1) return a;
|
|
147
|
+
throw y = !0, n;
|
|
148
|
+
}
|
|
149
|
+
return function (o, p, l) {
|
|
150
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
151
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
152
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
153
|
+
try {
|
|
154
|
+
if (f = 2, i) {
|
|
155
|
+
if (c || (o = "next"), t = i[o]) {
|
|
156
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
157
|
+
if (!t.done) return t;
|
|
158
|
+
u = t.value, c < 2 && (c = 0);
|
|
159
|
+
} else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
160
|
+
i = e;
|
|
161
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
162
|
+
} catch (t) {
|
|
163
|
+
i = e, c = 1, u = t;
|
|
164
|
+
} finally {
|
|
165
|
+
f = 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
value: t,
|
|
170
|
+
done: y
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
}(r, o, i), !0), u;
|
|
174
|
+
}
|
|
175
|
+
var a = {};
|
|
176
|
+
function Generator() {}
|
|
177
|
+
function GeneratorFunction() {}
|
|
178
|
+
function GeneratorFunctionPrototype() {}
|
|
179
|
+
t = Object.getPrototypeOf;
|
|
180
|
+
var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
|
|
181
|
+
return this;
|
|
182
|
+
}), t),
|
|
183
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
184
|
+
function f(e) {
|
|
185
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
186
|
+
}
|
|
187
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function () {
|
|
188
|
+
return this;
|
|
189
|
+
}), regeneratorDefine(u, "toString", function () {
|
|
190
|
+
return "[object Generator]";
|
|
191
|
+
}), (module.exports = _regenerator = function _regenerator() {
|
|
192
|
+
return {
|
|
193
|
+
w: i,
|
|
194
|
+
m: f
|
|
195
|
+
};
|
|
196
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
197
|
+
}
|
|
198
|
+
module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
199
|
+
})(regenerator$3);
|
|
200
|
+
var regeneratorExports$1 = regenerator$3.exports;
|
|
194
201
|
|
|
195
|
-
var regeneratorAsync = {exports: {}};
|
|
202
|
+
var regeneratorAsync$1 = {exports: {}};
|
|
196
203
|
|
|
197
|
-
var regeneratorAsyncGen = {exports: {}};
|
|
204
|
+
var regeneratorAsyncGen$1 = {exports: {}};
|
|
198
205
|
|
|
199
|
-
var regeneratorAsyncIterator = {exports: {}};
|
|
206
|
+
var regeneratorAsyncIterator$1 = {exports: {}};
|
|
200
207
|
|
|
201
208
|
(function (module) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
var regeneratorAsyncIteratorExports = regeneratorAsyncIterator.exports;
|
|
209
|
+
var OverloadYield = OverloadYieldExports$1;
|
|
210
|
+
var regeneratorDefine = regeneratorDefineExports$1;
|
|
211
|
+
function AsyncIterator(t, e) {
|
|
212
|
+
function n(r, o, i, f) {
|
|
213
|
+
try {
|
|
214
|
+
var c = t[r](o),
|
|
215
|
+
u = c.value;
|
|
216
|
+
return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
|
|
217
|
+
n("next", t, i, f);
|
|
218
|
+
}, function (t) {
|
|
219
|
+
n("throw", t, i, f);
|
|
220
|
+
}) : e.resolve(u).then(function (t) {
|
|
221
|
+
c.value = t, i(c);
|
|
222
|
+
}, function (t) {
|
|
223
|
+
return n("throw", t, i, f);
|
|
224
|
+
});
|
|
225
|
+
} catch (t) {
|
|
226
|
+
f(t);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
var r;
|
|
230
|
+
this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
|
|
231
|
+
return this;
|
|
232
|
+
})), regeneratorDefine(this, "_invoke", function (t, o, i) {
|
|
233
|
+
function f() {
|
|
234
|
+
return new e(function (e, r) {
|
|
235
|
+
n(t, i, e, r);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return r = r ? r.then(f, f) : f();
|
|
239
|
+
}, !0);
|
|
240
|
+
}
|
|
241
|
+
module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
242
|
+
})(regeneratorAsyncIterator$1);
|
|
243
|
+
var regeneratorAsyncIteratorExports$1 = regeneratorAsyncIterator$1.exports;
|
|
238
244
|
|
|
239
245
|
(function (module) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
var regeneratorAsyncGenExports = regeneratorAsyncGen.exports;
|
|
246
|
+
var regenerator = regeneratorExports$1;
|
|
247
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports$1;
|
|
248
|
+
function _regeneratorAsyncGen(r, e, t, o, n) {
|
|
249
|
+
return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
|
|
250
|
+
}
|
|
251
|
+
module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
252
|
+
})(regeneratorAsyncGen$1);
|
|
253
|
+
var regeneratorAsyncGenExports$1 = regeneratorAsyncGen$1.exports;
|
|
249
254
|
|
|
250
255
|
(function (module) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
var regeneratorAsyncExports = regeneratorAsync.exports;
|
|
256
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports$1;
|
|
257
|
+
function _regeneratorAsync(n, e, r, t, o) {
|
|
258
|
+
var a = regeneratorAsyncGen(n, e, r, t, o);
|
|
259
|
+
return a.next().then(function (n) {
|
|
260
|
+
return n.done ? n.value : a.next();
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
264
|
+
})(regeneratorAsync$1);
|
|
265
|
+
var regeneratorAsyncExports$1 = regeneratorAsync$1.exports;
|
|
262
266
|
|
|
263
|
-
var regeneratorKeys = {exports: {}};
|
|
267
|
+
var regeneratorKeys$1 = {exports: {}};
|
|
264
268
|
|
|
265
269
|
(function (module) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
270
|
+
function _regeneratorKeys(e) {
|
|
271
|
+
var n = Object(e),
|
|
272
|
+
r = [];
|
|
273
|
+
for (var t in n) r.unshift(t);
|
|
274
|
+
return function e() {
|
|
275
|
+
for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
|
|
276
|
+
return e.done = !0, e;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
280
|
+
})(regeneratorKeys$1);
|
|
281
|
+
var regeneratorKeysExports$1 = regeneratorKeys$1.exports;
|
|
277
282
|
|
|
278
|
-
var
|
|
283
|
+
var regeneratorValues$1 = {exports: {}};
|
|
279
284
|
|
|
280
|
-
var
|
|
281
|
-
|
|
282
|
-
var _typeof$1 = {exports: {}};
|
|
285
|
+
var _typeof$2 = {exports: {}};
|
|
283
286
|
|
|
284
287
|
(function (module) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
289
|
-
return typeof o;
|
|
290
|
-
} : function (o) {
|
|
291
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
292
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
293
|
-
}
|
|
294
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
295
|
-
} (_typeof$1));
|
|
288
|
+
function _typeof(o) {
|
|
289
|
+
"@babel/helpers - typeof";
|
|
296
290
|
|
|
297
|
-
|
|
291
|
+
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
292
|
+
return typeof o;
|
|
293
|
+
} : function (o) {
|
|
294
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
295
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
296
|
+
}
|
|
297
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
298
|
+
})(_typeof$2);
|
|
299
|
+
var _typeofExports$1 = _typeof$2.exports;
|
|
298
300
|
|
|
299
301
|
(function (module) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
var regeneratorValuesExports = regeneratorValues.exports;
|
|
302
|
+
var _typeof = _typeofExports$1["default"];
|
|
303
|
+
function _regeneratorValues(e) {
|
|
304
|
+
if (null != e) {
|
|
305
|
+
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
306
|
+
r = 0;
|
|
307
|
+
if (t) return t.call(e);
|
|
308
|
+
if ("function" == typeof e.next) return e;
|
|
309
|
+
if (!isNaN(e.length)) return {
|
|
310
|
+
next: function next() {
|
|
311
|
+
return e && r >= e.length && (e = void 0), {
|
|
312
|
+
value: e && e[r++],
|
|
313
|
+
done: !e
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
319
|
+
}
|
|
320
|
+
module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
321
|
+
})(regeneratorValues$1);
|
|
322
|
+
var regeneratorValuesExports$1 = regeneratorValues$1.exports;
|
|
322
323
|
|
|
323
324
|
(function (module) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var r = regenerator(),
|
|
334
|
-
e = r.m(_regeneratorRuntime),
|
|
335
|
-
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
336
|
-
function n(r) {
|
|
337
|
-
var e = "function" == typeof r && r.constructor;
|
|
338
|
-
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
339
|
-
}
|
|
340
|
-
var o = {
|
|
341
|
-
"throw": 1,
|
|
342
|
-
"return": 2,
|
|
343
|
-
"break": 3,
|
|
344
|
-
"continue": 3
|
|
345
|
-
};
|
|
346
|
-
function a(r) {
|
|
347
|
-
var e, t;
|
|
348
|
-
return function (n) {
|
|
349
|
-
e || (e = {
|
|
350
|
-
stop: function stop() {
|
|
351
|
-
return t(n.a, 2);
|
|
352
|
-
},
|
|
353
|
-
"catch": function _catch() {
|
|
354
|
-
return n.v;
|
|
355
|
-
},
|
|
356
|
-
abrupt: function abrupt(r, e) {
|
|
357
|
-
return t(n.a, o[r], e);
|
|
358
|
-
},
|
|
359
|
-
delegateYield: function delegateYield(r, o, a) {
|
|
360
|
-
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
361
|
-
},
|
|
362
|
-
finish: function finish(r) {
|
|
363
|
-
return t(n.f, r);
|
|
364
|
-
}
|
|
365
|
-
}, t = function t(r, _t, o) {
|
|
366
|
-
n.p = e.prev, n.n = e.next;
|
|
367
|
-
try {
|
|
368
|
-
return r(_t, o);
|
|
369
|
-
} finally {
|
|
370
|
-
e.next = n.n;
|
|
371
|
-
}
|
|
372
|
-
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
373
|
-
try {
|
|
374
|
-
return r.call(this, e);
|
|
375
|
-
} finally {
|
|
376
|
-
n.p = e.prev, n.n = e.next;
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
381
|
-
return {
|
|
382
|
-
wrap: function wrap(e, t, n, o) {
|
|
383
|
-
return r.w(a(e), t, n, o && o.reverse());
|
|
384
|
-
},
|
|
385
|
-
isGeneratorFunction: n,
|
|
386
|
-
mark: r.m,
|
|
387
|
-
awrap: function awrap(r, e) {
|
|
388
|
-
return new OverloadYield(r, e);
|
|
389
|
-
},
|
|
390
|
-
AsyncIterator: regeneratorAsyncIterator,
|
|
391
|
-
async: function async(r, e, t, o, u) {
|
|
392
|
-
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
393
|
-
},
|
|
394
|
-
keys: regeneratorKeys,
|
|
395
|
-
values: regeneratorValues
|
|
396
|
-
};
|
|
397
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
398
|
-
}
|
|
399
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
400
|
-
} (regeneratorRuntime$1));
|
|
325
|
+
var OverloadYield = OverloadYieldExports$1;
|
|
326
|
+
var regenerator = regeneratorExports$1;
|
|
327
|
+
var regeneratorAsync = regeneratorAsyncExports$1;
|
|
328
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports$1;
|
|
329
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports$1;
|
|
330
|
+
var regeneratorKeys = regeneratorKeysExports$1;
|
|
331
|
+
var regeneratorValues = regeneratorValuesExports$1;
|
|
332
|
+
function _regeneratorRuntime() {
|
|
401
333
|
|
|
402
|
-
var
|
|
334
|
+
var r = regenerator(),
|
|
335
|
+
e = r.m(_regeneratorRuntime),
|
|
336
|
+
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
337
|
+
function n(r) {
|
|
338
|
+
var e = "function" == typeof r && r.constructor;
|
|
339
|
+
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
340
|
+
}
|
|
341
|
+
var o = {
|
|
342
|
+
"throw": 1,
|
|
343
|
+
"return": 2,
|
|
344
|
+
"break": 3,
|
|
345
|
+
"continue": 3
|
|
346
|
+
};
|
|
347
|
+
function a(r) {
|
|
348
|
+
var e, t;
|
|
349
|
+
return function (n) {
|
|
350
|
+
e || (e = {
|
|
351
|
+
stop: function stop() {
|
|
352
|
+
return t(n.a, 2);
|
|
353
|
+
},
|
|
354
|
+
"catch": function _catch() {
|
|
355
|
+
return n.v;
|
|
356
|
+
},
|
|
357
|
+
abrupt: function abrupt(r, e) {
|
|
358
|
+
return t(n.a, o[r], e);
|
|
359
|
+
},
|
|
360
|
+
delegateYield: function delegateYield(r, o, a) {
|
|
361
|
+
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
362
|
+
},
|
|
363
|
+
finish: function finish(r) {
|
|
364
|
+
return t(n.f, r);
|
|
365
|
+
}
|
|
366
|
+
}, t = function t(r, _t, o) {
|
|
367
|
+
n.p = e.prev, n.n = e.next;
|
|
368
|
+
try {
|
|
369
|
+
return r(_t, o);
|
|
370
|
+
} finally {
|
|
371
|
+
e.next = n.n;
|
|
372
|
+
}
|
|
373
|
+
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
374
|
+
try {
|
|
375
|
+
return r.call(this, e);
|
|
376
|
+
} finally {
|
|
377
|
+
n.p = e.prev, n.n = e.next;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
382
|
+
return {
|
|
383
|
+
wrap: function wrap(e, t, n, o) {
|
|
384
|
+
return r.w(a(e), t, n, o && o.reverse());
|
|
385
|
+
},
|
|
386
|
+
isGeneratorFunction: n,
|
|
387
|
+
mark: r.m,
|
|
388
|
+
awrap: function awrap(r, e) {
|
|
389
|
+
return new OverloadYield(r, e);
|
|
390
|
+
},
|
|
391
|
+
AsyncIterator: regeneratorAsyncIterator,
|
|
392
|
+
async: function async(r, e, t, o, u) {
|
|
393
|
+
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
394
|
+
},
|
|
395
|
+
keys: regeneratorKeys,
|
|
396
|
+
values: regeneratorValues
|
|
397
|
+
};
|
|
398
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
399
|
+
}
|
|
400
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
401
|
+
})(regeneratorRuntime$2);
|
|
402
|
+
var regeneratorRuntimeExports$1 = regeneratorRuntime$2.exports;
|
|
403
403
|
|
|
404
404
|
// TODO(Babel 8): Remove this file.
|
|
405
405
|
|
|
406
|
-
var runtime = regeneratorRuntimeExports();
|
|
407
|
-
var regenerator = runtime;
|
|
406
|
+
var runtime$1 = regeneratorRuntimeExports$1();
|
|
407
|
+
var regenerator$2 = runtime$1;
|
|
408
408
|
|
|
409
409
|
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
410
410
|
try {
|
|
411
|
-
regeneratorRuntime = runtime;
|
|
411
|
+
regeneratorRuntime = runtime$1;
|
|
412
412
|
} catch (accidentalStrictMode) {
|
|
413
|
-
if (typeof globalThis === "object") {
|
|
414
|
-
globalThis.regeneratorRuntime = runtime;
|
|
413
|
+
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$3(globalThis)) === "object") {
|
|
414
|
+
globalThis.regeneratorRuntime = runtime$1;
|
|
415
415
|
} else {
|
|
416
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
416
|
+
Function("r", "regeneratorRuntime = r")(runtime$1);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
|
|
420
|
-
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
419
|
+
var _regeneratorRuntime$1 = /*@__PURE__*/getDefaultExportFromCjs(regenerator$2);
|
|
421
420
|
|
|
422
421
|
var supabaseInstance = null;
|
|
423
422
|
/**
|
|
@@ -457,9 +456,9 @@ function testConnection() {
|
|
|
457
456
|
* 通过直接创建表和函数来避免手动执行 SQL 文件
|
|
458
457
|
*/
|
|
459
458
|
function _testConnection() {
|
|
460
|
-
_testConnection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
459
|
+
_testConnection = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee() {
|
|
461
460
|
var supabase, _yield$supabase$from$, error, _t;
|
|
462
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
461
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
463
462
|
while (1) switch (_context.prev = _context.next) {
|
|
464
463
|
case 0:
|
|
465
464
|
_context.prev = 0;
|
|
@@ -498,9 +497,9 @@ function executeSupabaseSetup() {
|
|
|
498
497
|
* 初始化CMS系统表
|
|
499
498
|
*/
|
|
500
499
|
function _executeSupabaseSetup() {
|
|
501
|
-
_executeSupabaseSetup = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
500
|
+
_executeSupabaseSetup = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2() {
|
|
502
501
|
var supabase, createTableSQL, _yield$supabase$from$2, tableError, fullSetupSQL, functionsToCheck, missingFunctions, _i, _functionsToCheck, funcName, _t3;
|
|
503
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
502
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
504
503
|
while (1) switch (_context2.prev = _context2.next) {
|
|
505
504
|
case 0:
|
|
506
505
|
_context2.prev = 0;
|
|
@@ -630,9 +629,9 @@ function initializeCmsSystem() {
|
|
|
630
629
|
* 关闭Supabase连接(实际上Supabase客户端不需要显式关闭)
|
|
631
630
|
*/
|
|
632
631
|
function _initializeCmsSystem() {
|
|
633
|
-
_initializeCmsSystem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
632
|
+
_initializeCmsSystem = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3() {
|
|
634
633
|
var setupSuccess, supabase, _yield$supabase$rpc, error, _t4;
|
|
635
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
634
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
636
635
|
while (1) switch (_context3.prev = _context3.next) {
|
|
637
636
|
case 0:
|
|
638
637
|
_context3.prev = 0;
|
|
@@ -679,8 +678,8 @@ function closeSupabase() {
|
|
|
679
678
|
* 用户可以复制此脚本到 Supabase SQL 编辑器中执行
|
|
680
679
|
*/
|
|
681
680
|
function _closeSupabase() {
|
|
682
|
-
_closeSupabase = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
683
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
681
|
+
_closeSupabase = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4() {
|
|
682
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
684
683
|
while (1) switch (_context4.prev = _context4.next) {
|
|
685
684
|
case 0:
|
|
686
685
|
supabaseInstance = null;
|
|
@@ -696,44 +695,34 @@ function getSupabaseSetupSQL() {
|
|
|
696
695
|
return "-- Supabase Setup SQL for we0-cms-supabase-hono-api\n-- \u8BF7\u5728 Supabase SQL \u7F16\u8F91\u5668\u4E2D\u6267\u884C\u4EE5\u4E0B\u5B8C\u6574\u811A\u672C\n\n-- Function to execute SQL queries\nCREATE OR REPLACE FUNCTION execute_sql(sql_query text)\nRETURNS json\nLANGUAGE plpgsql\nSECURITY DEFINER\nAS $$\nDECLARE\n result json;\n row_count integer;\nBEGIN\n EXECUTE sql_query;\n GET DIAGNOSTICS row_count = ROW_COUNT;\n RETURN json_build_object('success', true, 'rows_affected', row_count);\nEXCEPTION\n WHEN OTHERS THEN\n RETURN json_build_object('success', false, 'error', SQLERRM);\nEND;\n$$;\n\n-- Function to execute SQL with parameters (simplified version)\nCREATE OR REPLACE FUNCTION execute_sql_with_params(sql_query text, params json)\nRETURNS json\nLANGUAGE plpgsql\nSECURITY DEFINER\nAS $$\nDECLARE\n result json;\n row_count integer;\nBEGIN\n -- Note: This is a simplified version for basic use cases\n -- In production, you might want more sophisticated parameter binding\n EXECUTE sql_query;\n GET DIAGNOSTICS row_count = ROW_COUNT;\n RETURN json_build_object('success', true, 'rows_affected', row_count);\nEXCEPTION\n WHEN OTHERS THEN\n RETURN json_build_object('success', false, 'error', SQLERRM);\nEND;\n$$;\n\n-- Function to check if table exists\nCREATE OR REPLACE FUNCTION check_table_exists(input_table_name text)\nRETURNS boolean\nLANGUAGE plpgsql\nSECURITY DEFINER\nAS $$\nBEGIN\n RETURN EXISTS (\n SELECT 1 FROM information_schema.tables\n WHERE table_schema = 'public' \n AND table_name = input_table_name\n );\nEND;\n$$;\n\n-- Function to get table structure\nCREATE OR REPLACE FUNCTION get_table_structure(table_name text)\nRETURNS json\nLANGUAGE plpgsql\nSECURITY DEFINER\nAS $$\nDECLARE\n result json;\nBEGIN\n SELECT json_agg(\n json_build_object(\n 'column_name', column_name,\n 'data_type', data_type,\n 'is_nullable', is_nullable,\n 'column_default', column_default,\n 'character_maximum_length', character_maximum_length\n )\n ) INTO result\n FROM information_schema.columns\n WHERE table_schema = 'public' AND table_name = $1\n ORDER BY ordinal_position;\n \n RETURN COALESCE(result, '[]'::json);\nEND;\n$$;\n\n-- Function to create CMS models table if not exists\nCREATE OR REPLACE FUNCTION create_cms_models_table_if_not_exists()\nRETURNS json\nLANGUAGE plpgsql\nSECURITY DEFINER\nAS $$\nBEGIN\n -- Create the CMS models table\n CREATE TABLE IF NOT EXISTS \"_cms_models\" (\n id SERIAL PRIMARY KEY,\n name VARCHAR(100) NOT NULL,\n table_name VARCHAR(100) NOT NULL UNIQUE,\n json_schema JSONB NOT NULL,\n created_at TIMESTAMPTZ DEFAULT NOW(),\n updated_at TIMESTAMPTZ DEFAULT NOW()\n );\n \n -- Create or replace the trigger function for updating timestamps\n CREATE OR REPLACE FUNCTION update_updated_at_column()\n RETURNS TRIGGER AS $trigger$\n BEGIN\n NEW.updated_at = NOW();\n RETURN NEW;\n END;\n $trigger$ language 'plpgsql';\n \n -- Drop existing trigger if it exists and create new one\n DROP TRIGGER IF EXISTS update_cms_models_updated_at ON \"_cms_models\";\n CREATE TRIGGER update_cms_models_updated_at\n BEFORE UPDATE ON \"_cms_models\"\n FOR EACH ROW\n EXECUTE FUNCTION update_updated_at_column();\n \n RETURN json_build_object('success', true, 'message', 'CMS models table created successfully');\nEXCEPTION\n WHEN OTHERS THEN\n RETURN json_build_object('success', false, 'error', SQLERRM);\nEND;\n$$;\n\n-- Initialize the CMS models table\nSELECT create_cms_models_table_if_not_exists();\n\n-- Grant necessary permissions (adjust as needed for your security requirements)\n-- Note: Be careful with these permissions in production\nGRANT USAGE ON SCHEMA public TO anon, authenticated;\nGRANT ALL ON ALL TABLES IN SCHEMA public TO anon, authenticated;\nGRANT ALL ON ALL SEQUENCES IN SCHEMA public TO anon, authenticated;\nGRANT ALL ON ALL FUNCTIONS IN SCHEMA public TO anon, authenticated;\n\n-- Create RLS policies for the CMS models table (optional, adjust as needed)\nALTER TABLE \"_cms_models\" ENABLE ROW LEVEL SECURITY;\n\n-- Allow all operations for all users (development environment)\nCREATE POLICY \"Allow all operations\" ON \"_cms_models\"\n FOR ALL USING (true);\n\nCOMMENT ON TABLE \"_cms_models\" IS 'CMS models configuration table for we0-cms-supabase-hono-api';\nCOMMENT ON FUNCTION execute_sql(text) IS 'Execute SQL queries for dynamic table management';\nCOMMENT ON FUNCTION check_table_exists(text) IS 'Check if a table exists in the public schema';\nCOMMENT ON FUNCTION get_table_structure(text) IS 'Get the structure of a table';";
|
|
697
696
|
}
|
|
698
697
|
|
|
699
|
-
function _classCallCheck(a, n) {
|
|
698
|
+
function _classCallCheck$1(a, n) {
|
|
700
699
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
701
700
|
}
|
|
702
701
|
|
|
703
|
-
function
|
|
704
|
-
"
|
|
705
|
-
|
|
706
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
707
|
-
return typeof o;
|
|
708
|
-
} : function (o) {
|
|
709
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
710
|
-
}, _typeof(o);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
function toPrimitive(t, r) {
|
|
714
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
702
|
+
function toPrimitive$1(t, r) {
|
|
703
|
+
if ("object" != _typeof$3(t) || !t) return t;
|
|
715
704
|
var e = t[Symbol.toPrimitive];
|
|
716
705
|
if (void 0 !== e) {
|
|
717
706
|
var i = e.call(t, r || "default");
|
|
718
|
-
if ("object" != _typeof(i)) return i;
|
|
707
|
+
if ("object" != _typeof$3(i)) return i;
|
|
719
708
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
720
709
|
}
|
|
721
710
|
return ("string" === r ? String : Number)(t);
|
|
722
711
|
}
|
|
723
712
|
|
|
724
|
-
function toPropertyKey(t) {
|
|
725
|
-
var i = toPrimitive(t, "string");
|
|
726
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
713
|
+
function toPropertyKey$1(t) {
|
|
714
|
+
var i = toPrimitive$1(t, "string");
|
|
715
|
+
return "symbol" == _typeof$3(i) ? i : i + "";
|
|
727
716
|
}
|
|
728
717
|
|
|
729
|
-
function _defineProperties(e, r) {
|
|
718
|
+
function _defineProperties$1(e, r) {
|
|
730
719
|
for (var t = 0; t < r.length; t++) {
|
|
731
720
|
var o = r[t];
|
|
732
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
|
|
721
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey$1(o.key), o);
|
|
733
722
|
}
|
|
734
723
|
}
|
|
735
|
-
function _createClass(e, r, t) {
|
|
736
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
724
|
+
function _createClass$1(e, r, t) {
|
|
725
|
+
return r && _defineProperties$1(e.prototype, r), t && _defineProperties$1(e, t), Object.defineProperty(e, "prototype", {
|
|
737
726
|
writable: !1
|
|
738
727
|
}), e;
|
|
739
728
|
}
|
|
@@ -741,19 +730,19 @@ function _createClass(e, r, t) {
|
|
|
741
730
|
// CMS 模型服务类
|
|
742
731
|
var CmsModelService = /*#__PURE__*/function () {
|
|
743
732
|
function CmsModelService() {
|
|
744
|
-
_classCallCheck(this, CmsModelService);
|
|
733
|
+
_classCallCheck$1(this, CmsModelService);
|
|
745
734
|
this.tableName = "_cms_models";
|
|
746
735
|
this.supabase = getSupabase();
|
|
747
736
|
}
|
|
748
737
|
/**
|
|
749
738
|
* 创建新的CMS模型
|
|
750
739
|
*/
|
|
751
|
-
return _createClass(CmsModelService, [{
|
|
740
|
+
return _createClass$1(CmsModelService, [{
|
|
752
741
|
key: "create",
|
|
753
742
|
value: (function () {
|
|
754
|
-
var _create = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
|
|
743
|
+
var _create = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(data) {
|
|
755
744
|
var _yield$this$supabase$, result, error;
|
|
756
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
745
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
757
746
|
while (1) switch (_context.prev = _context.next) {
|
|
758
747
|
case 0:
|
|
759
748
|
_context.next = 1;
|
|
@@ -787,9 +776,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
787
776
|
}, {
|
|
788
777
|
key: "findById",
|
|
789
778
|
value: (function () {
|
|
790
|
-
var _findById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id) {
|
|
779
|
+
var _findById = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(id) {
|
|
791
780
|
var _yield$this$supabase$2, data, error;
|
|
792
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
781
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
793
782
|
while (1) switch (_context2.prev = _context2.next) {
|
|
794
783
|
case 0:
|
|
795
784
|
_context2.next = 1;
|
|
@@ -829,9 +818,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
829
818
|
}, {
|
|
830
819
|
key: "findByTableName",
|
|
831
820
|
value: (function () {
|
|
832
|
-
var _findByTableName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(tableName) {
|
|
821
|
+
var _findByTableName = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(tableName) {
|
|
833
822
|
var _yield$this$supabase$3, data, error;
|
|
834
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
823
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
835
824
|
while (1) switch (_context3.prev = _context3.next) {
|
|
836
825
|
case 0:
|
|
837
826
|
_context3.next = 1;
|
|
@@ -871,9 +860,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
871
860
|
}, {
|
|
872
861
|
key: "findAll",
|
|
873
862
|
value: (function () {
|
|
874
|
-
var _findAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
863
|
+
var _findAll = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4() {
|
|
875
864
|
var _yield$this$supabase$4, data, error;
|
|
876
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
865
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
877
866
|
while (1) switch (_context4.prev = _context4.next) {
|
|
878
867
|
case 0:
|
|
879
868
|
_context4.next = 1;
|
|
@@ -909,9 +898,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
909
898
|
}, {
|
|
910
899
|
key: "update",
|
|
911
900
|
value: (function () {
|
|
912
|
-
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, data) {
|
|
901
|
+
var _update = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(id, data) {
|
|
913
902
|
var _yield$this$supabase$5, result, error;
|
|
914
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
903
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
915
904
|
while (1) switch (_context5.prev = _context5.next) {
|
|
916
905
|
case 0:
|
|
917
906
|
_context5.next = 1;
|
|
@@ -945,9 +934,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
945
934
|
}, {
|
|
946
935
|
key: "delete",
|
|
947
936
|
value: (function () {
|
|
948
|
-
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id) {
|
|
937
|
+
var _delete2 = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(id) {
|
|
949
938
|
var _yield$this$supabase$6, error;
|
|
950
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
939
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
951
940
|
while (1) switch (_context6.prev = _context6.next) {
|
|
952
941
|
case 0:
|
|
953
942
|
_context6.next = 1;
|
|
@@ -993,9 +982,9 @@ function initializeCmsModel() {
|
|
|
993
982
|
}
|
|
994
983
|
// 为了向后兼容,导出服务类作为默认导出
|
|
995
984
|
function _initializeCmsModel() {
|
|
996
|
-
_initializeCmsModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
985
|
+
_initializeCmsModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7() {
|
|
997
986
|
var supabase, createTableSQL, _yield$supabase$rpc, error, _t;
|
|
998
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
987
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
999
988
|
while (1) switch (_context7.prev = _context7.next) {
|
|
1000
989
|
case 0:
|
|
1001
990
|
_context7.prev = 0;
|
|
@@ -1031,8 +1020,8 @@ function _initializeCmsModel() {
|
|
|
1031
1020
|
return _initializeCmsModel.apply(this, arguments);
|
|
1032
1021
|
}
|
|
1033
1022
|
|
|
1034
|
-
function _defineProperty(e, r, t) {
|
|
1035
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1023
|
+
function _defineProperty$1(e, r, t) {
|
|
1024
|
+
return (r = toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, {
|
|
1036
1025
|
value: t,
|
|
1037
1026
|
enumerable: !0,
|
|
1038
1027
|
configurable: !0,
|
|
@@ -1040,11 +1029,11 @@ function _defineProperty(e, r, t) {
|
|
|
1040
1029
|
}) : e[r] = t, e;
|
|
1041
1030
|
}
|
|
1042
1031
|
|
|
1043
|
-
function ownKeys$
|
|
1044
|
-
function _objectSpread$
|
|
1045
|
-
function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$
|
|
1046
|
-
function _unsupportedIterableToArray$
|
|
1047
|
-
function _arrayLikeToArray$
|
|
1032
|
+
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; }
|
|
1033
|
+
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$1(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; }
|
|
1034
|
+
function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$4(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; } } }; }
|
|
1035
|
+
function _unsupportedIterableToArray$4(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$4(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$4(r, a) : void 0; } }
|
|
1036
|
+
function _arrayLikeToArray$4(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; }
|
|
1048
1037
|
// 字段类型映射到PostgreSQL类型
|
|
1049
1038
|
var fieldTypeMapping = {
|
|
1050
1039
|
string: "text",
|
|
@@ -1061,20 +1050,20 @@ var fieldTypeMapping = {
|
|
|
1061
1050
|
};
|
|
1062
1051
|
var DynamicTableService = /*#__PURE__*/function () {
|
|
1063
1052
|
function DynamicTableService() {
|
|
1064
|
-
_classCallCheck(this, DynamicTableService);
|
|
1053
|
+
_classCallCheck$1(this, DynamicTableService);
|
|
1065
1054
|
this.supabase = getSupabase();
|
|
1066
1055
|
}
|
|
1067
1056
|
/**
|
|
1068
1057
|
* 默认按 created_at 倒序(新数据在前)。
|
|
1069
1058
|
* 兼容:如果表不存在 created_at 字段,则回退按 id 倒序。
|
|
1070
1059
|
*/
|
|
1071
|
-
return _createClass(DynamicTableService, [{
|
|
1060
|
+
return _createClass$1(DynamicTableService, [{
|
|
1072
1061
|
key: "orderByCreatedAtOrFallback",
|
|
1073
1062
|
value: (function () {
|
|
1074
|
-
var _orderByCreatedAtOrFallback = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(buildQuery, offset, limit) {
|
|
1063
|
+
var _orderByCreatedAtOrFallback = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(buildQuery, offset, limit) {
|
|
1075
1064
|
var _first$error;
|
|
1076
1065
|
var first, msg, isMissingCreatedAt, second;
|
|
1077
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
1066
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
1078
1067
|
while (1) switch (_context.prev = _context.next) {
|
|
1079
1068
|
case 0:
|
|
1080
1069
|
_context.next = 1;
|
|
@@ -1205,9 +1194,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1205
1194
|
}, {
|
|
1206
1195
|
key: "createTable",
|
|
1207
1196
|
value: (function () {
|
|
1208
|
-
var _createTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(tableName, schema, baseTableName) {
|
|
1197
|
+
var _createTable = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(tableName, schema, baseTableName) {
|
|
1209
1198
|
var tablePrefix, createTableSQL, foreignKeys, _yield$this$supabase$, error, _t;
|
|
1210
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
1199
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
1211
1200
|
while (1) switch (_context2.prev = _context2.next) {
|
|
1212
1201
|
case 0:
|
|
1213
1202
|
_context2.prev = 0;
|
|
@@ -1301,9 +1290,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1301
1290
|
}, {
|
|
1302
1291
|
key: "dropTable",
|
|
1303
1292
|
value: (function () {
|
|
1304
|
-
var _dropTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(tableName) {
|
|
1293
|
+
var _dropTable = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(tableName) {
|
|
1305
1294
|
var _yield$this$supabase$2, error, _t2;
|
|
1306
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
1295
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
1307
1296
|
while (1) switch (_context3.prev = _context3.next) {
|
|
1308
1297
|
case 0:
|
|
1309
1298
|
_context3.prev = 0;
|
|
@@ -1346,9 +1335,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1346
1335
|
}, {
|
|
1347
1336
|
key: "dropAllForeignKeys",
|
|
1348
1337
|
value: (function () {
|
|
1349
|
-
var _dropAllForeignKeys = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(tableName) {
|
|
1338
|
+
var _dropAllForeignKeys = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(tableName) {
|
|
1350
1339
|
var parts, baseTableName, dropFKSQL, _yield$this$supabase$3, error, _t3;
|
|
1351
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
1340
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
1352
1341
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1353
1342
|
case 0:
|
|
1354
1343
|
_context4.prev = 0;
|
|
@@ -1398,9 +1387,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1398
1387
|
}, {
|
|
1399
1388
|
key: "dropForeignKeyByName",
|
|
1400
1389
|
value: (function () {
|
|
1401
|
-
var _dropForeignKeyByName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(tableName, constraintName) {
|
|
1390
|
+
var _dropForeignKeyByName = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(tableName, constraintName) {
|
|
1402
1391
|
var dropSQL, _yield$this$supabase$4, error, _t4;
|
|
1403
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
1392
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
1404
1393
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1405
1394
|
case 0:
|
|
1406
1395
|
_context5.prev = 0;
|
|
@@ -1444,9 +1433,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1444
1433
|
}, {
|
|
1445
1434
|
key: "dropForeignKey",
|
|
1446
1435
|
value: (function () {
|
|
1447
|
-
var _dropForeignKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(tableName, constraintName) {
|
|
1436
|
+
var _dropForeignKey = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(tableName, constraintName) {
|
|
1448
1437
|
var _yield$this$supabase$5, error, _t5;
|
|
1449
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
1438
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
1450
1439
|
while (1) switch (_context6.prev = _context6.next) {
|
|
1451
1440
|
case 0:
|
|
1452
1441
|
_context6.prev = 0;
|
|
@@ -1488,9 +1477,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1488
1477
|
}, {
|
|
1489
1478
|
key: "tableExists",
|
|
1490
1479
|
value: (function () {
|
|
1491
|
-
var _tableExists = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(tableName) {
|
|
1480
|
+
var _tableExists = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7(tableName) {
|
|
1492
1481
|
var _yield$this$supabase$6, data, error, _t6;
|
|
1493
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
1482
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
1494
1483
|
while (1) switch (_context7.prev = _context7.next) {
|
|
1495
1484
|
case 0:
|
|
1496
1485
|
_context7.prev = 0;
|
|
@@ -1532,9 +1521,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1532
1521
|
}, {
|
|
1533
1522
|
key: "getTableStructure",
|
|
1534
1523
|
value: (function () {
|
|
1535
|
-
var _getTableStructure = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(tableName) {
|
|
1524
|
+
var _getTableStructure = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee8(tableName) {
|
|
1536
1525
|
var _yield$this$supabase$7, data, error, _t7;
|
|
1537
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
1526
|
+
return _regeneratorRuntime$1.wrap(function (_context8) {
|
|
1538
1527
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1539
1528
|
case 0:
|
|
1540
1529
|
_context8.prev = 0;
|
|
@@ -1576,9 +1565,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1576
1565
|
}, {
|
|
1577
1566
|
key: "executeQuery",
|
|
1578
1567
|
value: (function () {
|
|
1579
|
-
var _executeQuery = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(sql, values) {
|
|
1568
|
+
var _executeQuery = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee9(sql, values) {
|
|
1580
1569
|
var finalSql, _yield$this$supabase$8, data, error, _t8;
|
|
1581
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
1570
|
+
return _regeneratorRuntime$1.wrap(function (_context9) {
|
|
1582
1571
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1583
1572
|
case 0:
|
|
1584
1573
|
_context9.prev = 0;
|
|
@@ -1629,7 +1618,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1629
1618
|
}, {
|
|
1630
1619
|
key: "getTableData",
|
|
1631
1620
|
value: (function () {
|
|
1632
|
-
var _getTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(tableName) {
|
|
1621
|
+
var _getTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee0(tableName) {
|
|
1633
1622
|
var _this = this;
|
|
1634
1623
|
var page,
|
|
1635
1624
|
limit,
|
|
@@ -1642,7 +1631,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1642
1631
|
count,
|
|
1643
1632
|
_args0 = arguments,
|
|
1644
1633
|
_t9;
|
|
1645
|
-
return _regeneratorRuntime.wrap(function (_context0) {
|
|
1634
|
+
return _regeneratorRuntime$1.wrap(function (_context0) {
|
|
1646
1635
|
while (1) switch (_context0.prev = _context0.next) {
|
|
1647
1636
|
case 0:
|
|
1648
1637
|
page = _args0.length > 1 && _args0[1] !== undefined ? _args0[1] : 1;
|
|
@@ -1701,7 +1690,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1701
1690
|
}, {
|
|
1702
1691
|
key: "getTableDataWithSearch",
|
|
1703
1692
|
value: (function () {
|
|
1704
|
-
var _getTableDataWithSearch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(tableName) {
|
|
1693
|
+
var _getTableDataWithSearch = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee1(tableName) {
|
|
1705
1694
|
var _this2 = this;
|
|
1706
1695
|
var page,
|
|
1707
1696
|
limit,
|
|
@@ -1715,7 +1704,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1715
1704
|
count,
|
|
1716
1705
|
_args1 = arguments,
|
|
1717
1706
|
_t0;
|
|
1718
|
-
return _regeneratorRuntime.wrap(function (_context1) {
|
|
1707
|
+
return _regeneratorRuntime$1.wrap(function (_context1) {
|
|
1719
1708
|
while (1) switch (_context1.prev = _context1.next) {
|
|
1720
1709
|
case 0:
|
|
1721
1710
|
page = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 1;
|
|
@@ -1777,7 +1766,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1777
1766
|
}, {
|
|
1778
1767
|
key: "insertData",
|
|
1779
1768
|
value: (function () {
|
|
1780
|
-
var _insertData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(tableName, data) {
|
|
1769
|
+
var _insertData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee10(tableName, data) {
|
|
1781
1770
|
var autoFixForeignKey,
|
|
1782
1771
|
_yield$this$supabase$9,
|
|
1783
1772
|
result,
|
|
@@ -1789,7 +1778,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1789
1778
|
_dropResult,
|
|
1790
1779
|
_args10 = arguments,
|
|
1791
1780
|
_t1;
|
|
1792
|
-
return _regeneratorRuntime.wrap(function (_context10) {
|
|
1781
|
+
return _regeneratorRuntime$1.wrap(function (_context10) {
|
|
1793
1782
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1794
1783
|
case 0:
|
|
1795
1784
|
autoFixForeignKey = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : true;
|
|
@@ -1879,7 +1868,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1879
1868
|
}, {
|
|
1880
1869
|
key: "updateData",
|
|
1881
1870
|
value: (function () {
|
|
1882
|
-
var _updateData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(tableName, id, data) {
|
|
1871
|
+
var _updateData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee11(tableName, id, data) {
|
|
1883
1872
|
var autoFixForeignKey,
|
|
1884
1873
|
_yield$this$supabase$0,
|
|
1885
1874
|
result,
|
|
@@ -1891,7 +1880,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1891
1880
|
_dropResult2,
|
|
1892
1881
|
_args11 = arguments,
|
|
1893
1882
|
_t10;
|
|
1894
|
-
return _regeneratorRuntime.wrap(function (_context11) {
|
|
1883
|
+
return _regeneratorRuntime$1.wrap(function (_context11) {
|
|
1895
1884
|
while (1) switch (_context11.prev = _context11.next) {
|
|
1896
1885
|
case 0:
|
|
1897
1886
|
autoFixForeignKey = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : true;
|
|
@@ -1979,9 +1968,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1979
1968
|
}, {
|
|
1980
1969
|
key: "deleteData",
|
|
1981
1970
|
value: (function () {
|
|
1982
|
-
var _deleteData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(tableName, id) {
|
|
1971
|
+
var _deleteData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee12(tableName, id) {
|
|
1983
1972
|
var _yield$this$supabase$1, result, error, _t11;
|
|
1984
|
-
return _regeneratorRuntime.wrap(function (_context12) {
|
|
1973
|
+
return _regeneratorRuntime$1.wrap(function (_context12) {
|
|
1985
1974
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1986
1975
|
case 0:
|
|
1987
1976
|
_context12.prev = 0;
|
|
@@ -2022,9 +2011,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2022
2011
|
}, {
|
|
2023
2012
|
key: "getDataById",
|
|
2024
2013
|
value: (function () {
|
|
2025
|
-
var _getDataById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(tableName, id) {
|
|
2014
|
+
var _getDataById = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee13(tableName, id) {
|
|
2026
2015
|
var _yield$this$supabase$10, data, error, _t12;
|
|
2027
|
-
return _regeneratorRuntime.wrap(function (_context13) {
|
|
2016
|
+
return _regeneratorRuntime$1.wrap(function (_context13) {
|
|
2028
2017
|
while (1) switch (_context13.prev = _context13.next) {
|
|
2029
2018
|
case 0:
|
|
2030
2019
|
_context13.prev = 0;
|
|
@@ -2072,9 +2061,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2072
2061
|
}, {
|
|
2073
2062
|
key: "getRelationOptions",
|
|
2074
2063
|
value: (function () {
|
|
2075
|
-
var _getRelationOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(params) {
|
|
2064
|
+
var _getRelationOptions = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee14(params) {
|
|
2076
2065
|
var tableName, _params$displayField, displayField, _params$limit, limit, search, query, _yield$query, data, error, _t13;
|
|
2077
|
-
return _regeneratorRuntime.wrap(function (_context14) {
|
|
2066
|
+
return _regeneratorRuntime$1.wrap(function (_context14) {
|
|
2078
2067
|
while (1) switch (_context14.prev = _context14.next) {
|
|
2079
2068
|
case 0:
|
|
2080
2069
|
_context14.prev = 0;
|
|
@@ -2096,7 +2085,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2096
2085
|
throw error;
|
|
2097
2086
|
case 2:
|
|
2098
2087
|
return _context14.abrupt("return", (data || []).map(function (item) {
|
|
2099
|
-
return _objectSpread$
|
|
2088
|
+
return _objectSpread$4({
|
|
2100
2089
|
id: item.id,
|
|
2101
2090
|
label: item[displayField] || "ID: ".concat(item.id)
|
|
2102
2091
|
}, item);
|
|
@@ -2129,7 +2118,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2129
2118
|
}, {
|
|
2130
2119
|
key: "getTableDataWithRelations",
|
|
2131
2120
|
value: (function () {
|
|
2132
|
-
var _getTableDataWithRelations = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(tableName, schema) {
|
|
2121
|
+
var _getTableDataWithRelations = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee15(tableName, schema) {
|
|
2133
2122
|
var _this3 = this;
|
|
2134
2123
|
var page,
|
|
2135
2124
|
limit,
|
|
@@ -2143,7 +2132,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2143
2132
|
count,
|
|
2144
2133
|
_args15 = arguments,
|
|
2145
2134
|
_t14;
|
|
2146
|
-
return _regeneratorRuntime.wrap(function (_context15) {
|
|
2135
|
+
return _regeneratorRuntime$1.wrap(function (_context15) {
|
|
2147
2136
|
while (1) switch (_context15.prev = _context15.next) {
|
|
2148
2137
|
case 0:
|
|
2149
2138
|
page = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : 1;
|
|
@@ -2209,28 +2198,28 @@ function getDynamicTableService() {
|
|
|
2209
2198
|
return defaultService$1;
|
|
2210
2199
|
}
|
|
2211
2200
|
|
|
2212
|
-
function ownKeys$
|
|
2213
|
-
function _objectSpread$
|
|
2201
|
+
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; }
|
|
2202
|
+
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$1(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; }
|
|
2214
2203
|
var AuthService = /*#__PURE__*/function () {
|
|
2215
2204
|
function AuthService() {
|
|
2216
|
-
_classCallCheck(this, AuthService);
|
|
2205
|
+
_classCallCheck$1(this, AuthService);
|
|
2217
2206
|
this.supabase = getSupabase();
|
|
2218
2207
|
this.defaultTableName = 'cms_users';
|
|
2219
2208
|
}
|
|
2220
2209
|
/**
|
|
2221
2210
|
* 根据用户名查询用户
|
|
2222
2211
|
*/
|
|
2223
|
-
return _createClass(AuthService, [{
|
|
2212
|
+
return _createClass$1(AuthService, [{
|
|
2224
2213
|
key: "findUserByUsername",
|
|
2225
2214
|
value: (function () {
|
|
2226
|
-
var _findUserByUsername = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(username) {
|
|
2215
|
+
var _findUserByUsername = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(username) {
|
|
2227
2216
|
var tableName,
|
|
2228
2217
|
_yield$this$supabase$,
|
|
2229
2218
|
users,
|
|
2230
2219
|
error,
|
|
2231
2220
|
_args = arguments,
|
|
2232
2221
|
_t;
|
|
2233
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
2222
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
2234
2223
|
while (1) switch (_context.prev = _context.next) {
|
|
2235
2224
|
case 0:
|
|
2236
2225
|
tableName = _args.length > 1 && _args[1] !== undefined ? _args[1] : this.defaultTableName;
|
|
@@ -2278,14 +2267,14 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2278
2267
|
}, {
|
|
2279
2268
|
key: "findUserById",
|
|
2280
2269
|
value: (function () {
|
|
2281
|
-
var _findUserById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(userId) {
|
|
2270
|
+
var _findUserById = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(userId) {
|
|
2282
2271
|
var tableName,
|
|
2283
2272
|
_yield$this$supabase$2,
|
|
2284
2273
|
users,
|
|
2285
2274
|
error,
|
|
2286
2275
|
_args2 = arguments,
|
|
2287
2276
|
_t2;
|
|
2288
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
2277
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
2289
2278
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2290
2279
|
case 0:
|
|
2291
2280
|
tableName = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : this.defaultTableName;
|
|
@@ -2333,14 +2322,14 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2333
2322
|
}, {
|
|
2334
2323
|
key: "checkUsernameExists",
|
|
2335
2324
|
value: (function () {
|
|
2336
|
-
var _checkUsernameExists = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(username) {
|
|
2325
|
+
var _checkUsernameExists = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(username) {
|
|
2337
2326
|
var tableName,
|
|
2338
2327
|
_yield$this$supabase$3,
|
|
2339
2328
|
users,
|
|
2340
2329
|
error,
|
|
2341
2330
|
_args3 = arguments,
|
|
2342
2331
|
_t3;
|
|
2343
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
2332
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
2344
2333
|
while (1) switch (_context3.prev = _context3.next) {
|
|
2345
2334
|
case 0:
|
|
2346
2335
|
tableName = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : this.defaultTableName;
|
|
@@ -2382,12 +2371,12 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2382
2371
|
}, {
|
|
2383
2372
|
key: "createUser",
|
|
2384
2373
|
value: (function () {
|
|
2385
|
-
var _createUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(userData) {
|
|
2374
|
+
var _createUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(userData) {
|
|
2386
2375
|
var finalUserData, _yield$this$supabase$4, result, error, _t4;
|
|
2387
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
2376
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
2388
2377
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2389
2378
|
case 0:
|
|
2390
|
-
finalUserData = _objectSpread$
|
|
2379
|
+
finalUserData = _objectSpread$3({
|
|
2391
2380
|
tableName: this.defaultTableName
|
|
2392
2381
|
}, userData);
|
|
2393
2382
|
_context4.prev = 1;
|
|
@@ -2432,7 +2421,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2432
2421
|
}, {
|
|
2433
2422
|
key: "updateUser",
|
|
2434
2423
|
value: (function () {
|
|
2435
|
-
var _updateUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(userId) {
|
|
2424
|
+
var _updateUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(userId) {
|
|
2436
2425
|
var updateData,
|
|
2437
2426
|
finalUpdateData,
|
|
2438
2427
|
_yield$this$supabase$5,
|
|
@@ -2440,12 +2429,12 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2440
2429
|
error,
|
|
2441
2430
|
_args5 = arguments,
|
|
2442
2431
|
_t5;
|
|
2443
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
2432
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
2444
2433
|
while (1) switch (_context5.prev = _context5.next) {
|
|
2445
2434
|
case 0:
|
|
2446
2435
|
updateData = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
2447
2436
|
// 设置默认值
|
|
2448
|
-
finalUpdateData = _objectSpread$
|
|
2437
|
+
finalUpdateData = _objectSpread$3({
|
|
2449
2438
|
tableName: this.defaultTableName
|
|
2450
2439
|
}, updateData);
|
|
2451
2440
|
_context5.prev = 1;
|
|
@@ -2486,13 +2475,13 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2486
2475
|
}, {
|
|
2487
2476
|
key: "deleteUser",
|
|
2488
2477
|
value: (function () {
|
|
2489
|
-
var _deleteUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(userId) {
|
|
2478
|
+
var _deleteUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(userId) {
|
|
2490
2479
|
var tableName,
|
|
2491
2480
|
_yield$this$supabase$6,
|
|
2492
2481
|
error,
|
|
2493
2482
|
_args6 = arguments,
|
|
2494
2483
|
_t6;
|
|
2495
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
2484
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
2496
2485
|
while (1) switch (_context6.prev = _context6.next) {
|
|
2497
2486
|
case 0:
|
|
2498
2487
|
tableName = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : this.defaultTableName;
|
|
@@ -2533,7 +2522,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2533
2522
|
}, {
|
|
2534
2523
|
key: "getUserList",
|
|
2535
2524
|
value: (function () {
|
|
2536
|
-
var _getUserList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
2525
|
+
var _getUserList = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7() {
|
|
2537
2526
|
var page,
|
|
2538
2527
|
limit,
|
|
2539
2528
|
tableName,
|
|
@@ -2544,7 +2533,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2544
2533
|
count,
|
|
2545
2534
|
_args7 = arguments,
|
|
2546
2535
|
_t7;
|
|
2547
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
2536
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
2548
2537
|
while (1) switch (_context7.prev = _context7.next) {
|
|
2549
2538
|
case 0:
|
|
2550
2539
|
page = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : 1;
|
|
@@ -2600,7 +2589,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2600
2589
|
}, {
|
|
2601
2590
|
key: "searchUsers",
|
|
2602
2591
|
value: (function () {
|
|
2603
|
-
var _searchUsers = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(searchValue) {
|
|
2592
|
+
var _searchUsers = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee8(searchValue) {
|
|
2604
2593
|
var page,
|
|
2605
2594
|
limit,
|
|
2606
2595
|
tableName,
|
|
@@ -2611,7 +2600,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2611
2600
|
count,
|
|
2612
2601
|
_args8 = arguments,
|
|
2613
2602
|
_t8;
|
|
2614
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
2603
|
+
return _regeneratorRuntime$1.wrap(function (_context8) {
|
|
2615
2604
|
while (1) switch (_context8.prev = _context8.next) {
|
|
2616
2605
|
case 0:
|
|
2617
2606
|
page = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : 1;
|
|
@@ -2667,13 +2656,13 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2667
2656
|
}, {
|
|
2668
2657
|
key: "updateLastLogin",
|
|
2669
2658
|
value: (function () {
|
|
2670
|
-
var _updateLastLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(userId) {
|
|
2659
|
+
var _updateLastLogin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee9(userId) {
|
|
2671
2660
|
var tableName,
|
|
2672
2661
|
_yield$this$supabase$9,
|
|
2673
2662
|
error,
|
|
2674
2663
|
_args9 = arguments,
|
|
2675
2664
|
_t9;
|
|
2676
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
2665
|
+
return _regeneratorRuntime$1.wrap(function (_context9) {
|
|
2677
2666
|
while (1) switch (_context9.prev = _context9.next) {
|
|
2678
2667
|
case 0:
|
|
2679
2668
|
tableName = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : this.defaultTableName;
|
|
@@ -2739,13 +2728,204 @@ function _objectWithoutProperties(e, t) {
|
|
|
2739
2728
|
return i;
|
|
2740
2729
|
}
|
|
2741
2730
|
|
|
2731
|
+
function _assertThisInitialized$1(e) {
|
|
2732
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2733
|
+
return e;
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
function _possibleConstructorReturn$1(t, e) {
|
|
2737
|
+
if (e && ("object" == _typeof$3(e) || "function" == typeof e)) return e;
|
|
2738
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2739
|
+
return _assertThisInitialized$1(t);
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
function _getPrototypeOf$1(t) {
|
|
2743
|
+
return _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
2744
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
2745
|
+
}, _getPrototypeOf$1(t);
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
function _setPrototypeOf$1(t, e) {
|
|
2749
|
+
return _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
2750
|
+
return t.__proto__ = e, t;
|
|
2751
|
+
}, _setPrototypeOf$1(t, e);
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
function _inherits$1(t, e) {
|
|
2755
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
2756
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
2757
|
+
constructor: {
|
|
2758
|
+
value: t,
|
|
2759
|
+
writable: !0,
|
|
2760
|
+
configurable: !0
|
|
2761
|
+
}
|
|
2762
|
+
}), Object.defineProperty(t, "prototype", {
|
|
2763
|
+
writable: !1
|
|
2764
|
+
}), e && _setPrototypeOf$1(t, e);
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
function _isNativeFunction$1(t) {
|
|
2768
|
+
try {
|
|
2769
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
2770
|
+
} catch (n) {
|
|
2771
|
+
return "function" == typeof t;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
function _isNativeReflectConstruct$3() {
|
|
2776
|
+
try {
|
|
2777
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2778
|
+
} catch (t) {}
|
|
2779
|
+
return (_isNativeReflectConstruct$3 = function _isNativeReflectConstruct() {
|
|
2780
|
+
return !!t;
|
|
2781
|
+
})();
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
function _construct$1(t, e, r) {
|
|
2785
|
+
if (_isNativeReflectConstruct$3()) return Reflect.construct.apply(null, arguments);
|
|
2786
|
+
var o = [null];
|
|
2787
|
+
o.push.apply(o, e);
|
|
2788
|
+
var p = new (t.bind.apply(t, o))();
|
|
2789
|
+
return r && _setPrototypeOf$1(p, r.prototype), p;
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
function _wrapNativeSuper$1(t) {
|
|
2793
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
2794
|
+
return _wrapNativeSuper$1 = function _wrapNativeSuper(t) {
|
|
2795
|
+
if (null === t || !_isNativeFunction$1(t)) return t;
|
|
2796
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
2797
|
+
if (void 0 !== r) {
|
|
2798
|
+
if (r.has(t)) return r.get(t);
|
|
2799
|
+
r.set(t, Wrapper);
|
|
2800
|
+
}
|
|
2801
|
+
function Wrapper() {
|
|
2802
|
+
return _construct$1(t, arguments, _getPrototypeOf$1(this).constructor);
|
|
2803
|
+
}
|
|
2804
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
2805
|
+
constructor: {
|
|
2806
|
+
value: Wrapper,
|
|
2807
|
+
enumerable: !1,
|
|
2808
|
+
writable: !0,
|
|
2809
|
+
configurable: !0
|
|
2810
|
+
}
|
|
2811
|
+
}), _setPrototypeOf$1(Wrapper, t);
|
|
2812
|
+
}, _wrapNativeSuper$1(t);
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
function _typeof$1(o) {
|
|
2816
|
+
"@babel/helpers - typeof";
|
|
2817
|
+
|
|
2818
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
2819
|
+
return typeof o;
|
|
2820
|
+
} : function (o) {
|
|
2821
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
2822
|
+
}, _typeof$1(o);
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
function toPrimitive(t, r) {
|
|
2826
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
2827
|
+
var e = t[Symbol.toPrimitive];
|
|
2828
|
+
if (void 0 !== e) {
|
|
2829
|
+
var i = e.call(t, r || "default");
|
|
2830
|
+
if ("object" != _typeof$1(i)) return i;
|
|
2831
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2832
|
+
}
|
|
2833
|
+
return ("string" === r ? String : Number)(t);
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
function toPropertyKey(t) {
|
|
2837
|
+
var i = toPrimitive(t, "string");
|
|
2838
|
+
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
function _defineProperty(e, r, t) {
|
|
2842
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2843
|
+
value: t,
|
|
2844
|
+
enumerable: !0,
|
|
2845
|
+
configurable: !0,
|
|
2846
|
+
writable: !0
|
|
2847
|
+
}) : e[r] = t, e;
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
2851
|
+
try {
|
|
2852
|
+
var i = n[a](c),
|
|
2853
|
+
u = i.value;
|
|
2854
|
+
} catch (n) {
|
|
2855
|
+
return void e(n);
|
|
2856
|
+
}
|
|
2857
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
2858
|
+
}
|
|
2859
|
+
function _asyncToGenerator(n) {
|
|
2860
|
+
return function () {
|
|
2861
|
+
var t = this,
|
|
2862
|
+
e = arguments;
|
|
2863
|
+
return new Promise(function (r, o) {
|
|
2864
|
+
var a = n.apply(t, e);
|
|
2865
|
+
function _next(n) {
|
|
2866
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
2867
|
+
}
|
|
2868
|
+
function _throw(n) {
|
|
2869
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
2870
|
+
}
|
|
2871
|
+
_next(void 0);
|
|
2872
|
+
});
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
function _arrayLikeToArray$3(r, a) {
|
|
2877
|
+
(null == a || a > r.length) && (a = r.length);
|
|
2878
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
2879
|
+
return n;
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
function _arrayWithoutHoles(r) {
|
|
2883
|
+
if (Array.isArray(r)) return _arrayLikeToArray$3(r);
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
function _iterableToArray(r) {
|
|
2887
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
function _unsupportedIterableToArray$3(r, a) {
|
|
2891
|
+
if (r) {
|
|
2892
|
+
if ("string" == typeof r) return _arrayLikeToArray$3(r, a);
|
|
2893
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
2894
|
+
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;
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
function _nonIterableSpread() {
|
|
2899
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
function _toConsumableArray(r) {
|
|
2903
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$3(r) || _nonIterableSpread();
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
function _defineProperties(e, r) {
|
|
2907
|
+
for (var t = 0; t < r.length; t++) {
|
|
2908
|
+
var o = r[t];
|
|
2909
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
function _createClass(e, r, t) {
|
|
2913
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
2914
|
+
writable: !1
|
|
2915
|
+
}), e;
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
function _classCallCheck(a, n) {
|
|
2919
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2742
2922
|
function _assertThisInitialized(e) {
|
|
2743
2923
|
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2744
2924
|
return e;
|
|
2745
2925
|
}
|
|
2746
2926
|
|
|
2747
2927
|
function _possibleConstructorReturn(t, e) {
|
|
2748
|
-
if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
|
|
2928
|
+
if (e && ("object" == _typeof$1(e) || "function" == typeof e)) return e;
|
|
2749
2929
|
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2750
2930
|
return _assertThisInitialized(t);
|
|
2751
2931
|
}
|
|
@@ -2783,17 +2963,17 @@ function _isNativeFunction(t) {
|
|
|
2783
2963
|
}
|
|
2784
2964
|
}
|
|
2785
2965
|
|
|
2786
|
-
function _isNativeReflectConstruct$
|
|
2966
|
+
function _isNativeReflectConstruct$2() {
|
|
2787
2967
|
try {
|
|
2788
2968
|
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2789
2969
|
} catch (t) {}
|
|
2790
|
-
return (_isNativeReflectConstruct$
|
|
2970
|
+
return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() {
|
|
2791
2971
|
return !!t;
|
|
2792
2972
|
})();
|
|
2793
2973
|
}
|
|
2794
2974
|
|
|
2795
2975
|
function _construct(t, e, r) {
|
|
2796
|
-
if (_isNativeReflectConstruct$
|
|
2976
|
+
if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments);
|
|
2797
2977
|
var o = [null];
|
|
2798
2978
|
o.push.apply(o, e);
|
|
2799
2979
|
var p = new (t.bind.apply(t, o))();
|
|
@@ -2823,6 +3003,364 @@ function _wrapNativeSuper(t) {
|
|
|
2823
3003
|
}, _wrapNativeSuper(t);
|
|
2824
3004
|
}
|
|
2825
3005
|
|
|
3006
|
+
var regeneratorRuntime$1 = {exports: {}};
|
|
3007
|
+
|
|
3008
|
+
var OverloadYield = {exports: {}};
|
|
3009
|
+
|
|
3010
|
+
(function (module) {
|
|
3011
|
+
function _OverloadYield(e, d) {
|
|
3012
|
+
this.v = e, this.k = d;
|
|
3013
|
+
}
|
|
3014
|
+
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3015
|
+
})(OverloadYield);
|
|
3016
|
+
var OverloadYieldExports = OverloadYield.exports;
|
|
3017
|
+
|
|
3018
|
+
var regenerator$1 = {exports: {}};
|
|
3019
|
+
|
|
3020
|
+
var regeneratorDefine = {exports: {}};
|
|
3021
|
+
|
|
3022
|
+
(function (module) {
|
|
3023
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
3024
|
+
var i = Object.defineProperty;
|
|
3025
|
+
try {
|
|
3026
|
+
i({}, "", {});
|
|
3027
|
+
} catch (e) {
|
|
3028
|
+
i = 0;
|
|
3029
|
+
}
|
|
3030
|
+
module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
|
|
3031
|
+
function o(r, n) {
|
|
3032
|
+
_regeneratorDefine(e, r, function (e) {
|
|
3033
|
+
return this._invoke(r, n, e);
|
|
3034
|
+
});
|
|
3035
|
+
}
|
|
3036
|
+
r ? i ? i(e, r, {
|
|
3037
|
+
value: n,
|
|
3038
|
+
enumerable: !t,
|
|
3039
|
+
configurable: !t,
|
|
3040
|
+
writable: !t
|
|
3041
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
3042
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
|
|
3043
|
+
}
|
|
3044
|
+
module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3045
|
+
})(regeneratorDefine);
|
|
3046
|
+
var regeneratorDefineExports = regeneratorDefine.exports;
|
|
3047
|
+
|
|
3048
|
+
(function (module) {
|
|
3049
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
3050
|
+
function _regenerator() {
|
|
3051
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3052
|
+
var e,
|
|
3053
|
+
t,
|
|
3054
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
3055
|
+
n = r.iterator || "@@iterator",
|
|
3056
|
+
o = r.toStringTag || "@@toStringTag";
|
|
3057
|
+
function i(r, n, o, i) {
|
|
3058
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
3059
|
+
u = Object.create(c.prototype);
|
|
3060
|
+
return regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
3061
|
+
var i,
|
|
3062
|
+
c,
|
|
3063
|
+
u,
|
|
3064
|
+
f = 0,
|
|
3065
|
+
p = o || [],
|
|
3066
|
+
y = !1,
|
|
3067
|
+
G = {
|
|
3068
|
+
p: 0,
|
|
3069
|
+
n: 0,
|
|
3070
|
+
v: e,
|
|
3071
|
+
a: d,
|
|
3072
|
+
f: d.bind(e, 4),
|
|
3073
|
+
d: function d(t, r) {
|
|
3074
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
function d(r, n) {
|
|
3078
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
3079
|
+
var o,
|
|
3080
|
+
i = p[t],
|
|
3081
|
+
d = G.p,
|
|
3082
|
+
l = i[2];
|
|
3083
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
3084
|
+
}
|
|
3085
|
+
if (o || r > 1) return a;
|
|
3086
|
+
throw y = !0, n;
|
|
3087
|
+
}
|
|
3088
|
+
return function (o, p, l) {
|
|
3089
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
3090
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
3091
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
3092
|
+
try {
|
|
3093
|
+
if (f = 2, i) {
|
|
3094
|
+
if (c || (o = "next"), t = i[o]) {
|
|
3095
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
3096
|
+
if (!t.done) return t;
|
|
3097
|
+
u = t.value, c < 2 && (c = 0);
|
|
3098
|
+
} else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
3099
|
+
i = e;
|
|
3100
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
3101
|
+
} catch (t) {
|
|
3102
|
+
i = e, c = 1, u = t;
|
|
3103
|
+
} finally {
|
|
3104
|
+
f = 1;
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
return {
|
|
3108
|
+
value: t,
|
|
3109
|
+
done: y
|
|
3110
|
+
};
|
|
3111
|
+
};
|
|
3112
|
+
}(r, o, i), !0), u;
|
|
3113
|
+
}
|
|
3114
|
+
var a = {};
|
|
3115
|
+
function Generator() {}
|
|
3116
|
+
function GeneratorFunction() {}
|
|
3117
|
+
function GeneratorFunctionPrototype() {}
|
|
3118
|
+
t = Object.getPrototypeOf;
|
|
3119
|
+
var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
|
|
3120
|
+
return this;
|
|
3121
|
+
}), t),
|
|
3122
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
3123
|
+
function f(e) {
|
|
3124
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
3125
|
+
}
|
|
3126
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function () {
|
|
3127
|
+
return this;
|
|
3128
|
+
}), regeneratorDefine(u, "toString", function () {
|
|
3129
|
+
return "[object Generator]";
|
|
3130
|
+
}), (module.exports = _regenerator = function _regenerator() {
|
|
3131
|
+
return {
|
|
3132
|
+
w: i,
|
|
3133
|
+
m: f
|
|
3134
|
+
};
|
|
3135
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
3136
|
+
}
|
|
3137
|
+
module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3138
|
+
})(regenerator$1);
|
|
3139
|
+
var regeneratorExports = regenerator$1.exports;
|
|
3140
|
+
|
|
3141
|
+
var regeneratorAsync = {exports: {}};
|
|
3142
|
+
|
|
3143
|
+
var regeneratorAsyncGen = {exports: {}};
|
|
3144
|
+
|
|
3145
|
+
var regeneratorAsyncIterator = {exports: {}};
|
|
3146
|
+
|
|
3147
|
+
(function (module) {
|
|
3148
|
+
var OverloadYield = OverloadYieldExports;
|
|
3149
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
3150
|
+
function AsyncIterator(t, e) {
|
|
3151
|
+
function n(r, o, i, f) {
|
|
3152
|
+
try {
|
|
3153
|
+
var c = t[r](o),
|
|
3154
|
+
u = c.value;
|
|
3155
|
+
return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
|
|
3156
|
+
n("next", t, i, f);
|
|
3157
|
+
}, function (t) {
|
|
3158
|
+
n("throw", t, i, f);
|
|
3159
|
+
}) : e.resolve(u).then(function (t) {
|
|
3160
|
+
c.value = t, i(c);
|
|
3161
|
+
}, function (t) {
|
|
3162
|
+
return n("throw", t, i, f);
|
|
3163
|
+
});
|
|
3164
|
+
} catch (t) {
|
|
3165
|
+
f(t);
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
var r;
|
|
3169
|
+
this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
|
|
3170
|
+
return this;
|
|
3171
|
+
})), regeneratorDefine(this, "_invoke", function (t, o, i) {
|
|
3172
|
+
function f() {
|
|
3173
|
+
return new e(function (e, r) {
|
|
3174
|
+
n(t, i, e, r);
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
return r = r ? r.then(f, f) : f();
|
|
3178
|
+
}, !0);
|
|
3179
|
+
}
|
|
3180
|
+
module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3181
|
+
})(regeneratorAsyncIterator);
|
|
3182
|
+
var regeneratorAsyncIteratorExports = regeneratorAsyncIterator.exports;
|
|
3183
|
+
|
|
3184
|
+
(function (module) {
|
|
3185
|
+
var regenerator = regeneratorExports;
|
|
3186
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
3187
|
+
function _regeneratorAsyncGen(r, e, t, o, n) {
|
|
3188
|
+
return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
|
|
3189
|
+
}
|
|
3190
|
+
module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3191
|
+
})(regeneratorAsyncGen);
|
|
3192
|
+
var regeneratorAsyncGenExports = regeneratorAsyncGen.exports;
|
|
3193
|
+
|
|
3194
|
+
(function (module) {
|
|
3195
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
3196
|
+
function _regeneratorAsync(n, e, r, t, o) {
|
|
3197
|
+
var a = regeneratorAsyncGen(n, e, r, t, o);
|
|
3198
|
+
return a.next().then(function (n) {
|
|
3199
|
+
return n.done ? n.value : a.next();
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3203
|
+
})(regeneratorAsync);
|
|
3204
|
+
var regeneratorAsyncExports = regeneratorAsync.exports;
|
|
3205
|
+
|
|
3206
|
+
var regeneratorKeys = {exports: {}};
|
|
3207
|
+
|
|
3208
|
+
(function (module) {
|
|
3209
|
+
function _regeneratorKeys(e) {
|
|
3210
|
+
var n = Object(e),
|
|
3211
|
+
r = [];
|
|
3212
|
+
for (var t in n) r.unshift(t);
|
|
3213
|
+
return function e() {
|
|
3214
|
+
for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
|
|
3215
|
+
return e.done = !0, e;
|
|
3216
|
+
};
|
|
3217
|
+
}
|
|
3218
|
+
module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3219
|
+
})(regeneratorKeys);
|
|
3220
|
+
var regeneratorKeysExports = regeneratorKeys.exports;
|
|
3221
|
+
|
|
3222
|
+
var regeneratorValues = {exports: {}};
|
|
3223
|
+
|
|
3224
|
+
var _typeof = {exports: {}};
|
|
3225
|
+
|
|
3226
|
+
(function (module) {
|
|
3227
|
+
function _typeof(o) {
|
|
3228
|
+
"@babel/helpers - typeof";
|
|
3229
|
+
|
|
3230
|
+
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
3231
|
+
return typeof o;
|
|
3232
|
+
} : function (o) {
|
|
3233
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3234
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
3235
|
+
}
|
|
3236
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3237
|
+
})(_typeof);
|
|
3238
|
+
var _typeofExports = _typeof.exports;
|
|
3239
|
+
|
|
3240
|
+
(function (module) {
|
|
3241
|
+
var _typeof = _typeofExports["default"];
|
|
3242
|
+
function _regeneratorValues(e) {
|
|
3243
|
+
if (null != e) {
|
|
3244
|
+
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
3245
|
+
r = 0;
|
|
3246
|
+
if (t) return t.call(e);
|
|
3247
|
+
if ("function" == typeof e.next) return e;
|
|
3248
|
+
if (!isNaN(e.length)) return {
|
|
3249
|
+
next: function next() {
|
|
3250
|
+
return e && r >= e.length && (e = void 0), {
|
|
3251
|
+
value: e && e[r++],
|
|
3252
|
+
done: !e
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
};
|
|
3256
|
+
}
|
|
3257
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
3258
|
+
}
|
|
3259
|
+
module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3260
|
+
})(regeneratorValues);
|
|
3261
|
+
var regeneratorValuesExports = regeneratorValues.exports;
|
|
3262
|
+
|
|
3263
|
+
(function (module) {
|
|
3264
|
+
var OverloadYield = OverloadYieldExports;
|
|
3265
|
+
var regenerator = regeneratorExports;
|
|
3266
|
+
var regeneratorAsync = regeneratorAsyncExports;
|
|
3267
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
3268
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
3269
|
+
var regeneratorKeys = regeneratorKeysExports;
|
|
3270
|
+
var regeneratorValues = regeneratorValuesExports;
|
|
3271
|
+
function _regeneratorRuntime() {
|
|
3272
|
+
|
|
3273
|
+
var r = regenerator(),
|
|
3274
|
+
e = r.m(_regeneratorRuntime),
|
|
3275
|
+
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
3276
|
+
function n(r) {
|
|
3277
|
+
var e = "function" == typeof r && r.constructor;
|
|
3278
|
+
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
3279
|
+
}
|
|
3280
|
+
var o = {
|
|
3281
|
+
"throw": 1,
|
|
3282
|
+
"return": 2,
|
|
3283
|
+
"break": 3,
|
|
3284
|
+
"continue": 3
|
|
3285
|
+
};
|
|
3286
|
+
function a(r) {
|
|
3287
|
+
var e, t;
|
|
3288
|
+
return function (n) {
|
|
3289
|
+
e || (e = {
|
|
3290
|
+
stop: function stop() {
|
|
3291
|
+
return t(n.a, 2);
|
|
3292
|
+
},
|
|
3293
|
+
"catch": function _catch() {
|
|
3294
|
+
return n.v;
|
|
3295
|
+
},
|
|
3296
|
+
abrupt: function abrupt(r, e) {
|
|
3297
|
+
return t(n.a, o[r], e);
|
|
3298
|
+
},
|
|
3299
|
+
delegateYield: function delegateYield(r, o, a) {
|
|
3300
|
+
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
3301
|
+
},
|
|
3302
|
+
finish: function finish(r) {
|
|
3303
|
+
return t(n.f, r);
|
|
3304
|
+
}
|
|
3305
|
+
}, t = function t(r, _t, o) {
|
|
3306
|
+
n.p = e.prev, n.n = e.next;
|
|
3307
|
+
try {
|
|
3308
|
+
return r(_t, o);
|
|
3309
|
+
} finally {
|
|
3310
|
+
e.next = n.n;
|
|
3311
|
+
}
|
|
3312
|
+
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
3313
|
+
try {
|
|
3314
|
+
return r.call(this, e);
|
|
3315
|
+
} finally {
|
|
3316
|
+
n.p = e.prev, n.n = e.next;
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
}
|
|
3320
|
+
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
3321
|
+
return {
|
|
3322
|
+
wrap: function wrap(e, t, n, o) {
|
|
3323
|
+
return r.w(a(e), t, n, o && o.reverse());
|
|
3324
|
+
},
|
|
3325
|
+
isGeneratorFunction: n,
|
|
3326
|
+
mark: r.m,
|
|
3327
|
+
awrap: function awrap(r, e) {
|
|
3328
|
+
return new OverloadYield(r, e);
|
|
3329
|
+
},
|
|
3330
|
+
AsyncIterator: regeneratorAsyncIterator,
|
|
3331
|
+
async: function async(r, e, t, o, u) {
|
|
3332
|
+
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
3333
|
+
},
|
|
3334
|
+
keys: regeneratorKeys,
|
|
3335
|
+
values: regeneratorValues
|
|
3336
|
+
};
|
|
3337
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
3338
|
+
}
|
|
3339
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3340
|
+
})(regeneratorRuntime$1);
|
|
3341
|
+
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
3342
|
+
|
|
3343
|
+
// TODO(Babel 8): Remove this file.
|
|
3344
|
+
|
|
3345
|
+
var runtime = regeneratorRuntimeExports();
|
|
3346
|
+
var regenerator = runtime;
|
|
3347
|
+
|
|
3348
|
+
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
3349
|
+
try {
|
|
3350
|
+
regeneratorRuntime = runtime;
|
|
3351
|
+
} catch (accidentalStrictMode) {
|
|
3352
|
+
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$1(globalThis)) === "object") {
|
|
3353
|
+
globalThis.regeneratorRuntime = runtime;
|
|
3354
|
+
} else {
|
|
3355
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
3359
|
+
|
|
3360
|
+
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; }
|
|
3361
|
+
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; }
|
|
3362
|
+
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)); }
|
|
3363
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
2826
3364
|
// src/error.ts
|
|
2827
3365
|
var ErrorCode = {
|
|
2828
3366
|
/** 网络错误(断网、DNS 解析失败等) */
|
|
@@ -2838,278 +3376,498 @@ var ErrorCode = {
|
|
|
2838
3376
|
/** 存储服务未启用 */
|
|
2839
3377
|
STORAGE_DISABLED: 503
|
|
2840
3378
|
};
|
|
2841
|
-
var OssError =
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
this
|
|
2845
|
-
|
|
2846
|
-
|
|
3379
|
+
var OssError = /*#__PURE__*/function (_Error) {
|
|
3380
|
+
function OssError(code, message) {
|
|
3381
|
+
var _this;
|
|
3382
|
+
_classCallCheck(this, OssError);
|
|
3383
|
+
_this = _callSuper$1(this, OssError, [message]);
|
|
3384
|
+
_this.name = "OssError";
|
|
3385
|
+
_this.code = code;
|
|
3386
|
+
_this.isRetryable = code === ErrorCode.NETWORK || code === ErrorCode.TIMEOUT || code >= 500;
|
|
3387
|
+
return _this;
|
|
2847
3388
|
}
|
|
2848
|
-
|
|
3389
|
+
_inherits(OssError, _Error);
|
|
3390
|
+
return _createClass(OssError);
|
|
3391
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
2849
3392
|
|
|
2850
3393
|
// src/validate.ts
|
|
2851
3394
|
var MAGIC_BYTES = [
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
]
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
"
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
"
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
"webm",
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
"
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
"
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
"
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
"
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
"
|
|
2902
|
-
]
|
|
3395
|
+
// 图片
|
|
3396
|
+
{
|
|
3397
|
+
ext: ["jpg", "jpeg"],
|
|
3398
|
+
bytes: [255, 216, 255]
|
|
3399
|
+
}, {
|
|
3400
|
+
ext: ["png"],
|
|
3401
|
+
bytes: [137, 80, 78, 71, 13, 10, 26, 10]
|
|
3402
|
+
}, {
|
|
3403
|
+
ext: ["gif"],
|
|
3404
|
+
bytes: [71, 73, 70, 56]
|
|
3405
|
+
}, {
|
|
3406
|
+
ext: ["bmp"],
|
|
3407
|
+
bytes: [66, 77]
|
|
3408
|
+
}, {
|
|
3409
|
+
ext: ["webp"],
|
|
3410
|
+
bytes: [87, 69, 66, 80],
|
|
3411
|
+
offset: 8
|
|
3412
|
+
}, {
|
|
3413
|
+
ext: ["ico"],
|
|
3414
|
+
bytes: [0, 0, 1, 0]
|
|
3415
|
+
}, {
|
|
3416
|
+
ext: ["svg"],
|
|
3417
|
+
bytes: []
|
|
3418
|
+
},
|
|
3419
|
+
// SVG 是文本,单独处理
|
|
3420
|
+
// 视频
|
|
3421
|
+
{
|
|
3422
|
+
ext: ["mp4", "m4v"],
|
|
3423
|
+
bytes: [102, 116, 121, 112],
|
|
3424
|
+
offset: 4
|
|
3425
|
+
}, {
|
|
3426
|
+
ext: ["webm"],
|
|
3427
|
+
bytes: [26, 69, 223, 163]
|
|
3428
|
+
}, {
|
|
3429
|
+
ext: ["avi"],
|
|
3430
|
+
bytes: [82, 73, 70, 70]
|
|
3431
|
+
}, {
|
|
3432
|
+
ext: ["mov"],
|
|
3433
|
+
bytes: [102, 116, 121, 112],
|
|
3434
|
+
offset: 4
|
|
3435
|
+
}, {
|
|
3436
|
+
ext: ["flv"],
|
|
3437
|
+
bytes: [70, 76, 86]
|
|
3438
|
+
}, {
|
|
3439
|
+
ext: ["mkv"],
|
|
3440
|
+
bytes: [26, 69, 223, 163]
|
|
3441
|
+
},
|
|
3442
|
+
// 文档
|
|
3443
|
+
{
|
|
3444
|
+
ext: ["pdf"],
|
|
3445
|
+
bytes: [37, 80, 68, 70]
|
|
3446
|
+
}];
|
|
3447
|
+
var DEFAULT_ALLOWED_EXTENSIONS = /* @__PURE__ */new Set([
|
|
3448
|
+
// 图片
|
|
3449
|
+
"jpg", "jpeg", "png", "gif", "webp", "bmp", "ico", "svg",
|
|
3450
|
+
// 视频
|
|
3451
|
+
"mp4", "webm", "mov", "avi", "mkv", "flv", "wmv", "m4v",
|
|
3452
|
+
// 文档
|
|
3453
|
+
"pdf",
|
|
3454
|
+
// 代码/文本
|
|
3455
|
+
"html", "css", "js", "ts", "json", "xml", "txt", "md", "csv"]);
|
|
2903
3456
|
function getExt(fileName) {
|
|
2904
3457
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
2905
3458
|
}
|
|
2906
3459
|
function validateExtension(fileName, allowedExtensions) {
|
|
2907
|
-
|
|
2908
|
-
|
|
3460
|
+
var ext = getExt(fileName);
|
|
3461
|
+
var whitelist = allowedExtensions !== null && allowedExtensions !== void 0 ? allowedExtensions : DEFAULT_ALLOWED_EXTENSIONS;
|
|
2909
3462
|
if (!ext) {
|
|
2910
|
-
throw new OssError(ErrorCode.INVALID_PARAMS,
|
|
3463
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u7F3A\u5C11\u6269\u5C55\u540D"));
|
|
2911
3464
|
}
|
|
2912
3465
|
if (!whitelist.has(ext)) {
|
|
2913
|
-
throw new OssError(
|
|
2914
|
-
ErrorCode.INVALID_PARAMS,
|
|
2915
|
-
`\u6587\u4EF6\u7C7B\u578B ".${ext}" \u4E0D\u5728\u5141\u8BB8\u5217\u8868\u4E2D\uFF0C\u5141\u8BB8\u7684\u7C7B\u578B\uFF1A${[...whitelist].join(", ")}`
|
|
2916
|
-
);
|
|
3466
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6\u7C7B\u578B \".".concat(ext, "\" \u4E0D\u5728\u5141\u8BB8\u5217\u8868\u4E2D\uFF0C\u5141\u8BB8\u7684\u7C7B\u578B\uFF1A").concat(_toConsumableArray(whitelist).join(", ")));
|
|
2917
3467
|
}
|
|
2918
3468
|
}
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
3469
|
+
function validateMagicBytes(_x, _x2) {
|
|
3470
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
3471
|
+
} // src/request.ts
|
|
3472
|
+
function _validateMagicBytes() {
|
|
3473
|
+
_validateMagicBytes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, fileName) {
|
|
3474
|
+
var _rule$offset;
|
|
3475
|
+
var ext, textExts, text, rule, offset, needed, headerBuf, header, matched;
|
|
3476
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
3477
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
3478
|
+
case 0:
|
|
3479
|
+
ext = getExt(fileName);
|
|
3480
|
+
textExts = /* @__PURE__ */new Set(["html", "css", "js", "ts", "json", "xml", "txt", "md", "csv", "svg"]);
|
|
3481
|
+
if (!textExts.has(ext)) {
|
|
3482
|
+
_context6.next = 3;
|
|
3483
|
+
break;
|
|
3484
|
+
}
|
|
3485
|
+
if (!(ext === "svg")) {
|
|
3486
|
+
_context6.next = 2;
|
|
3487
|
+
break;
|
|
3488
|
+
}
|
|
3489
|
+
_context6.next = 1;
|
|
3490
|
+
return blob.slice(0, 1024).text();
|
|
3491
|
+
case 1:
|
|
3492
|
+
text = _context6.sent;
|
|
3493
|
+
if (!(!text.includes("<svg") && !text.includes("<?xml"))) {
|
|
3494
|
+
_context6.next = 2;
|
|
3495
|
+
break;
|
|
3496
|
+
}
|
|
3497
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u4E0D\u662F\u6709\u6548\u7684 SVG \u6587\u4EF6"));
|
|
3498
|
+
case 2:
|
|
3499
|
+
return _context6.abrupt("return");
|
|
3500
|
+
case 3:
|
|
3501
|
+
rule = MAGIC_BYTES.find(function (r) {
|
|
3502
|
+
return r.ext.includes(ext);
|
|
3503
|
+
});
|
|
3504
|
+
if (!(!rule || rule.bytes.length === 0)) {
|
|
3505
|
+
_context6.next = 4;
|
|
3506
|
+
break;
|
|
3507
|
+
}
|
|
3508
|
+
return _context6.abrupt("return");
|
|
3509
|
+
case 4:
|
|
3510
|
+
offset = (_rule$offset = rule.offset) !== null && _rule$offset !== void 0 ? _rule$offset : 0;
|
|
3511
|
+
needed = offset + rule.bytes.length;
|
|
3512
|
+
if (!(blob.size < needed)) {
|
|
3513
|
+
_context6.next = 5;
|
|
3514
|
+
break;
|
|
3515
|
+
}
|
|
3516
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u5185\u5BB9\u8FC7\u77ED\uFF0C\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B"));
|
|
3517
|
+
case 5:
|
|
3518
|
+
_context6.next = 6;
|
|
3519
|
+
return blob.slice(0, needed).arrayBuffer();
|
|
3520
|
+
case 6:
|
|
3521
|
+
headerBuf = _context6.sent;
|
|
3522
|
+
header = new Uint8Array(headerBuf);
|
|
3523
|
+
matched = rule.bytes.every(function (_byte, i) {
|
|
3524
|
+
return header[offset + i] === _byte;
|
|
3525
|
+
});
|
|
3526
|
+
if (matched) {
|
|
3527
|
+
_context6.next = 7;
|
|
3528
|
+
break;
|
|
3529
|
+
}
|
|
3530
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u5B9E\u9645\u5185\u5BB9\u4E0E\u6269\u5C55\u540D \".").concat(ext, "\" \u4E0D\u5339\u914D\uFF0C\u7591\u4F3C\u4F2A\u9020\u6587\u4EF6"));
|
|
3531
|
+
case 7:
|
|
3532
|
+
case "end":
|
|
3533
|
+
return _context6.stop();
|
|
3534
|
+
}
|
|
3535
|
+
}, _callee6);
|
|
3536
|
+
}));
|
|
3537
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
3538
|
+
}
|
|
3539
|
+
function sleep(ms) {
|
|
3540
|
+
return new Promise(function (resolve) {
|
|
3541
|
+
return setTimeout(resolve, ms);
|
|
3542
|
+
});
|
|
3543
|
+
}
|
|
3544
|
+
function parseJson(json) {
|
|
3545
|
+
if (json.code !== 200) {
|
|
3546
|
+
throw new OssError(json.code, json.message || json.error || "Unknown error");
|
|
3547
|
+
}
|
|
3548
|
+
return json.data;
|
|
3549
|
+
}
|
|
3550
|
+
function fetchJson(_x3, _x4, _x5, _x6) {
|
|
3551
|
+
return _fetchJson.apply(this, arguments);
|
|
3552
|
+
}
|
|
3553
|
+
function _fetchJson() {
|
|
3554
|
+
_fetchJson = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(baseURL, timeout, path, body) {
|
|
3555
|
+
var url, controller, timer, res, json, _t;
|
|
3556
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
3557
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
3558
|
+
case 0:
|
|
3559
|
+
url = "".concat(baseURL).concat(path);
|
|
3560
|
+
controller = new AbortController();
|
|
3561
|
+
timer = setTimeout(function () {
|
|
3562
|
+
return controller.abort();
|
|
3563
|
+
}, timeout);
|
|
3564
|
+
_context7.prev = 1;
|
|
3565
|
+
_context7.next = 2;
|
|
3566
|
+
return fetch(url, {
|
|
3567
|
+
method: "POST",
|
|
3568
|
+
headers: {
|
|
3569
|
+
"Content-Type": "application/json"
|
|
3570
|
+
},
|
|
3571
|
+
body: JSON.stringify(body),
|
|
3572
|
+
signal: controller.signal
|
|
3573
|
+
});
|
|
3574
|
+
case 2:
|
|
3575
|
+
res = _context7.sent;
|
|
3576
|
+
_context7.next = 5;
|
|
3577
|
+
break;
|
|
3578
|
+
case 3:
|
|
3579
|
+
_context7.prev = 3;
|
|
3580
|
+
_t = _context7["catch"](1);
|
|
3581
|
+
if (!(_t instanceof DOMException && _t.name === "AbortError")) {
|
|
3582
|
+
_context7.next = 4;
|
|
3583
|
+
break;
|
|
3584
|
+
}
|
|
3585
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3586
|
+
case 4:
|
|
3587
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t instanceof Error ? _t.message : String(_t)));
|
|
3588
|
+
case 5:
|
|
3589
|
+
_context7.prev = 5;
|
|
3590
|
+
clearTimeout(timer);
|
|
3591
|
+
return _context7.finish(5);
|
|
3592
|
+
case 6:
|
|
3593
|
+
_context7.prev = 6;
|
|
3594
|
+
_context7.next = 7;
|
|
3595
|
+
return res.json();
|
|
3596
|
+
case 7:
|
|
3597
|
+
json = _context7.sent;
|
|
3598
|
+
_context7.next = 9;
|
|
3599
|
+
break;
|
|
3600
|
+
case 8:
|
|
3601
|
+
_context7.prev = 8;
|
|
3602
|
+
_context7["catch"](6);
|
|
3603
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3604
|
+
case 9:
|
|
3605
|
+
return _context7.abrupt("return", parseJson(json));
|
|
3606
|
+
case 10:
|
|
3607
|
+
case "end":
|
|
3608
|
+
return _context7.stop();
|
|
3609
|
+
}
|
|
3610
|
+
}, _callee7, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3611
|
+
}));
|
|
3612
|
+
return _fetchJson.apply(this, arguments);
|
|
3613
|
+
}
|
|
3614
|
+
function fetchFormData(_x7, _x8, _x9, _x0) {
|
|
3615
|
+
return _fetchFormData.apply(this, arguments);
|
|
3616
|
+
}
|
|
3617
|
+
function _fetchFormData() {
|
|
3618
|
+
_fetchFormData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(baseURL, timeout, path, formData) {
|
|
3619
|
+
var url, controller, timer, res, json, _t3;
|
|
3620
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
3621
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3622
|
+
case 0:
|
|
3623
|
+
url = "".concat(baseURL).concat(path);
|
|
3624
|
+
controller = new AbortController();
|
|
3625
|
+
timer = setTimeout(function () {
|
|
3626
|
+
return controller.abort();
|
|
3627
|
+
}, timeout);
|
|
3628
|
+
_context8.prev = 1;
|
|
3629
|
+
_context8.next = 2;
|
|
3630
|
+
return fetch(url, {
|
|
3631
|
+
method: "POST",
|
|
3632
|
+
body: formData,
|
|
3633
|
+
signal: controller.signal
|
|
3634
|
+
});
|
|
3635
|
+
case 2:
|
|
3636
|
+
res = _context8.sent;
|
|
3637
|
+
_context8.next = 5;
|
|
3638
|
+
break;
|
|
3639
|
+
case 3:
|
|
3640
|
+
_context8.prev = 3;
|
|
3641
|
+
_t3 = _context8["catch"](1);
|
|
3642
|
+
if (!(_t3 instanceof DOMException && _t3.name === "AbortError")) {
|
|
3643
|
+
_context8.next = 4;
|
|
3644
|
+
break;
|
|
3645
|
+
}
|
|
3646
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3647
|
+
case 4:
|
|
3648
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t3 instanceof Error ? _t3.message : String(_t3)));
|
|
3649
|
+
case 5:
|
|
3650
|
+
_context8.prev = 5;
|
|
3651
|
+
clearTimeout(timer);
|
|
3652
|
+
return _context8.finish(5);
|
|
3653
|
+
case 6:
|
|
3654
|
+
_context8.prev = 6;
|
|
3655
|
+
_context8.next = 7;
|
|
3656
|
+
return res.json();
|
|
3657
|
+
case 7:
|
|
3658
|
+
json = _context8.sent;
|
|
3659
|
+
_context8.next = 9;
|
|
3660
|
+
break;
|
|
3661
|
+
case 8:
|
|
3662
|
+
_context8.prev = 8;
|
|
3663
|
+
_context8["catch"](6);
|
|
3664
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3665
|
+
case 9:
|
|
3666
|
+
return _context8.abrupt("return", parseJson(json));
|
|
3667
|
+
case 10:
|
|
3668
|
+
case "end":
|
|
3669
|
+
return _context8.stop();
|
|
3670
|
+
}
|
|
3671
|
+
}, _callee8, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3672
|
+
}));
|
|
3673
|
+
return _fetchFormData.apply(this, arguments);
|
|
3674
|
+
}
|
|
3675
|
+
function fetchFormDataWithProgress(_x1, _x10, _x11, _x12, _x13) {
|
|
3676
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
3677
|
+
}
|
|
3678
|
+
function _fetchFormDataWithProgress() {
|
|
3679
|
+
_fetchFormDataWithProgress = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(baseURL, timeout, path, formData, onProgress) {
|
|
3680
|
+
var url;
|
|
3681
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
3682
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
3683
|
+
case 0:
|
|
3684
|
+
if (!(typeof XMLHttpRequest === "undefined")) {
|
|
3685
|
+
_context9.next = 1;
|
|
3686
|
+
break;
|
|
3687
|
+
}
|
|
3688
|
+
return _context9.abrupt("return", fetchFormData(baseURL, timeout, path, formData));
|
|
3689
|
+
case 1:
|
|
3690
|
+
url = "".concat(baseURL).concat(path);
|
|
3691
|
+
return _context9.abrupt("return", new Promise(function (resolve, reject) {
|
|
3692
|
+
var xhr = new XMLHttpRequest();
|
|
3693
|
+
xhr.open("POST", url, true);
|
|
3694
|
+
xhr.timeout = timeout;
|
|
3695
|
+
xhr.upload.onprogress = function (e) {
|
|
3696
|
+
if (e.lengthComputable) {
|
|
3697
|
+
onProgress({
|
|
3698
|
+
loaded: e.loaded,
|
|
3699
|
+
total: e.total,
|
|
3700
|
+
percent: Math.round(e.loaded / e.total * 100)
|
|
3701
|
+
});
|
|
3702
|
+
}
|
|
3703
|
+
};
|
|
3704
|
+
xhr.onload = function () {
|
|
3705
|
+
try {
|
|
3706
|
+
var json = JSON.parse(xhr.responseText);
|
|
3707
|
+
if (json.code !== 200) {
|
|
3708
|
+
reject(new OssError(json.code, json.message || json.error || "Unknown error"));
|
|
3709
|
+
} else {
|
|
3710
|
+
resolve(json.data);
|
|
3711
|
+
}
|
|
3712
|
+
} catch (_unused3) {
|
|
3713
|
+
reject(new OssError(xhr.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(xhr.status, "\uFF09")));
|
|
3714
|
+
}
|
|
3715
|
+
};
|
|
3716
|
+
xhr.onerror = function () {
|
|
3717
|
+
reject(new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25"));
|
|
3718
|
+
};
|
|
3719
|
+
xhr.ontimeout = function () {
|
|
3720
|
+
reject(new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09")));
|
|
3721
|
+
};
|
|
3722
|
+
xhr.send(formData);
|
|
3723
|
+
}));
|
|
3724
|
+
case 2:
|
|
3725
|
+
case "end":
|
|
3726
|
+
return _context9.stop();
|
|
2927
3727
|
}
|
|
2928
|
-
}
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
const rule = MAGIC_BYTES.find((r) => r.ext.includes(ext));
|
|
2932
|
-
if (!rule || rule.bytes.length === 0) return;
|
|
2933
|
-
const offset = rule.offset ?? 0;
|
|
2934
|
-
const needed = offset + rule.bytes.length;
|
|
2935
|
-
if (blob.size < needed) {
|
|
2936
|
-
throw new OssError(ErrorCode.INVALID_PARAMS, `\u6587\u4EF6 "${fileName}" \u5185\u5BB9\u8FC7\u77ED\uFF0C\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B`);
|
|
2937
|
-
}
|
|
2938
|
-
const headerBuf = await blob.slice(0, needed).arrayBuffer();
|
|
2939
|
-
const header = new Uint8Array(headerBuf);
|
|
2940
|
-
const matched = rule.bytes.every((byte, i) => header[offset + i] === byte);
|
|
2941
|
-
if (!matched) {
|
|
2942
|
-
throw new OssError(
|
|
2943
|
-
ErrorCode.INVALID_PARAMS,
|
|
2944
|
-
`\u6587\u4EF6 "${fileName}" \u5B9E\u9645\u5185\u5BB9\u4E0E\u6269\u5C55\u540D ".${ext}" \u4E0D\u5339\u914D\uFF0C\u7591\u4F3C\u4F2A\u9020\u6587\u4EF6`
|
|
2945
|
-
);
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2948
|
-
|
|
2949
|
-
// src/request.ts
|
|
2950
|
-
function sleep(ms) {
|
|
2951
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3728
|
+
}, _callee9);
|
|
3729
|
+
}));
|
|
3730
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
2952
3731
|
}
|
|
2953
|
-
function
|
|
2954
|
-
|
|
2955
|
-
throw new OssError(json.code, json.message || json.error || "Unknown error");
|
|
2956
|
-
}
|
|
2957
|
-
return json.data;
|
|
3732
|
+
function fetchGet(_x14, _x15, _x16) {
|
|
3733
|
+
return _fetchGet.apply(this, arguments);
|
|
2958
3734
|
}
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
3735
|
+
function _fetchGet() {
|
|
3736
|
+
_fetchGet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(baseURL, timeout, path) {
|
|
3737
|
+
var url, controller, timer, res, json, _t5;
|
|
3738
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
3739
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
3740
|
+
case 0:
|
|
3741
|
+
url = "".concat(baseURL).concat(path);
|
|
3742
|
+
controller = new AbortController();
|
|
3743
|
+
timer = setTimeout(function () {
|
|
3744
|
+
return controller.abort();
|
|
3745
|
+
}, timeout);
|
|
3746
|
+
_context0.prev = 1;
|
|
3747
|
+
_context0.next = 2;
|
|
3748
|
+
return fetch(url, {
|
|
3749
|
+
method: "GET",
|
|
3750
|
+
signal: controller.signal
|
|
3751
|
+
});
|
|
3752
|
+
case 2:
|
|
3753
|
+
res = _context0.sent;
|
|
3754
|
+
_context0.next = 5;
|
|
3755
|
+
break;
|
|
3756
|
+
case 3:
|
|
3757
|
+
_context0.prev = 3;
|
|
3758
|
+
_t5 = _context0["catch"](1);
|
|
3759
|
+
if (!(_t5 instanceof DOMException && _t5.name === "AbortError")) {
|
|
3760
|
+
_context0.next = 4;
|
|
3761
|
+
break;
|
|
3762
|
+
}
|
|
3763
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3764
|
+
case 4:
|
|
3765
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t5 instanceof Error ? _t5.message : String(_t5)));
|
|
3766
|
+
case 5:
|
|
3767
|
+
_context0.prev = 5;
|
|
3768
|
+
clearTimeout(timer);
|
|
3769
|
+
return _context0.finish(5);
|
|
3770
|
+
case 6:
|
|
3771
|
+
_context0.prev = 6;
|
|
3772
|
+
_context0.next = 7;
|
|
3773
|
+
return res.json();
|
|
3774
|
+
case 7:
|
|
3775
|
+
json = _context0.sent;
|
|
3776
|
+
_context0.next = 9;
|
|
3777
|
+
break;
|
|
3778
|
+
case 8:
|
|
3779
|
+
_context0.prev = 8;
|
|
3780
|
+
_context0["catch"](6);
|
|
3781
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3782
|
+
case 9:
|
|
3783
|
+
return _context0.abrupt("return", parseJson(json));
|
|
3784
|
+
case 10:
|
|
3785
|
+
case "end":
|
|
3786
|
+
return _context0.stop();
|
|
3787
|
+
}
|
|
3788
|
+
}, _callee0, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3789
|
+
}));
|
|
3790
|
+
return _fetchGet.apply(this, arguments);
|
|
2986
3791
|
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
const controller = new AbortController();
|
|
2990
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
2991
|
-
let res;
|
|
2992
|
-
try {
|
|
2993
|
-
res = await fetch(url, {
|
|
2994
|
-
method: "POST",
|
|
2995
|
-
body: formData,
|
|
2996
|
-
signal: controller.signal
|
|
2997
|
-
});
|
|
2998
|
-
} catch (err) {
|
|
2999
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
3000
|
-
throw new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`);
|
|
3001
|
-
}
|
|
3002
|
-
throw new OssError(ErrorCode.NETWORK, `\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
3003
|
-
} finally {
|
|
3004
|
-
clearTimeout(timer);
|
|
3005
|
-
}
|
|
3006
|
-
let json;
|
|
3007
|
-
try {
|
|
3008
|
-
json = await res.json();
|
|
3009
|
-
} catch {
|
|
3010
|
-
throw new OssError(res.status, `\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ${res.status}\uFF09`);
|
|
3011
|
-
}
|
|
3012
|
-
return parseJson(json);
|
|
3792
|
+
function withRetry(_x17, _x18) {
|
|
3793
|
+
return _withRetry.apply(this, arguments);
|
|
3013
3794
|
}
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3795
|
+
function _withRetry() {
|
|
3796
|
+
_withRetry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(fn, retry) {
|
|
3797
|
+
var _retry$retries, _retry$delay, _retry$backoff;
|
|
3798
|
+
var maxRetries, baseDelay, backoff, lastError, attempt, waitMs, _t7;
|
|
3799
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
3800
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
3801
|
+
case 0:
|
|
3802
|
+
maxRetries = (_retry$retries = retry === null || retry === void 0 ? void 0 : retry.retries) !== null && _retry$retries !== void 0 ? _retry$retries : 2;
|
|
3803
|
+
baseDelay = (_retry$delay = retry === null || retry === void 0 ? void 0 : retry.delay) !== null && _retry$delay !== void 0 ? _retry$delay : 1e3;
|
|
3804
|
+
backoff = (_retry$backoff = retry === null || retry === void 0 ? void 0 : retry.backoff) !== null && _retry$backoff !== void 0 ? _retry$backoff : 2;
|
|
3805
|
+
attempt = 0;
|
|
3806
|
+
case 1:
|
|
3807
|
+
if (!(attempt <= maxRetries)) {
|
|
3808
|
+
_context1.next = 8;
|
|
3809
|
+
break;
|
|
3810
|
+
}
|
|
3811
|
+
_context1.prev = 2;
|
|
3812
|
+
_context1.next = 3;
|
|
3813
|
+
return fn();
|
|
3814
|
+
case 3:
|
|
3815
|
+
return _context1.abrupt("return", _context1.sent);
|
|
3816
|
+
case 4:
|
|
3817
|
+
_context1.prev = 4;
|
|
3818
|
+
_t7 = _context1["catch"](2);
|
|
3819
|
+
lastError = _t7;
|
|
3820
|
+
if (lastError.isRetryable) {
|
|
3821
|
+
_context1.next = 5;
|
|
3822
|
+
break;
|
|
3823
|
+
}
|
|
3824
|
+
throw lastError;
|
|
3825
|
+
case 5:
|
|
3826
|
+
if (!(attempt >= maxRetries)) {
|
|
3827
|
+
_context1.next = 6;
|
|
3828
|
+
break;
|
|
3829
|
+
}
|
|
3830
|
+
return _context1.abrupt("continue", 8);
|
|
3831
|
+
case 6:
|
|
3832
|
+
waitMs = baseDelay * Math.pow(backoff, attempt);
|
|
3833
|
+
_context1.next = 7;
|
|
3834
|
+
return sleep(waitMs);
|
|
3835
|
+
case 7:
|
|
3836
|
+
attempt++;
|
|
3837
|
+
_context1.next = 1;
|
|
3838
|
+
break;
|
|
3839
|
+
case 8:
|
|
3840
|
+
throw lastError;
|
|
3841
|
+
case 9:
|
|
3842
|
+
case "end":
|
|
3843
|
+
return _context1.stop();
|
|
3042
3844
|
}
|
|
3043
|
-
};
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
};
|
|
3047
|
-
xhr.ontimeout = () => {
|
|
3048
|
-
reject(new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`));
|
|
3049
|
-
};
|
|
3050
|
-
xhr.send(formData);
|
|
3051
|
-
});
|
|
3052
|
-
}
|
|
3053
|
-
async function fetchGet(baseURL, timeout, path) {
|
|
3054
|
-
const url = `${baseURL}${path}`;
|
|
3055
|
-
const controller = new AbortController();
|
|
3056
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
3057
|
-
let res;
|
|
3058
|
-
try {
|
|
3059
|
-
res = await fetch(url, {
|
|
3060
|
-
method: "GET",
|
|
3061
|
-
signal: controller.signal
|
|
3062
|
-
});
|
|
3063
|
-
} catch (err) {
|
|
3064
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
3065
|
-
throw new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`);
|
|
3066
|
-
}
|
|
3067
|
-
throw new OssError(ErrorCode.NETWORK, `\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
3068
|
-
} finally {
|
|
3069
|
-
clearTimeout(timer);
|
|
3070
|
-
}
|
|
3071
|
-
let json;
|
|
3072
|
-
try {
|
|
3073
|
-
json = await res.json();
|
|
3074
|
-
} catch {
|
|
3075
|
-
throw new OssError(res.status, `\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ${res.status}\uFF09`);
|
|
3076
|
-
}
|
|
3077
|
-
return parseJson(json);
|
|
3078
|
-
}
|
|
3079
|
-
async function withRetry(fn, retry) {
|
|
3080
|
-
const maxRetries = retry?.retries ?? 2;
|
|
3081
|
-
const baseDelay = retry?.delay ?? 1e3;
|
|
3082
|
-
const backoff = retry?.backoff ?? 2;
|
|
3083
|
-
let lastError;
|
|
3084
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
3085
|
-
try {
|
|
3086
|
-
return await fn();
|
|
3087
|
-
} catch (err) {
|
|
3088
|
-
lastError = err;
|
|
3089
|
-
if (!lastError.isRetryable) throw lastError;
|
|
3090
|
-
if (attempt >= maxRetries) break;
|
|
3091
|
-
const waitMs = baseDelay * backoff ** attempt;
|
|
3092
|
-
await sleep(waitMs);
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
throw lastError;
|
|
3845
|
+
}, _callee1, null, [[2, 4]]);
|
|
3846
|
+
}));
|
|
3847
|
+
return _withRetry.apply(this, arguments);
|
|
3096
3848
|
}
|
|
3097
3849
|
function requestJsonWithRetry(baseURL, timeout, path, body, retry) {
|
|
3098
|
-
return withRetry(
|
|
3850
|
+
return withRetry(function () {
|
|
3851
|
+
return fetchJson(baseURL, timeout, path, body);
|
|
3852
|
+
}, retry);
|
|
3099
3853
|
}
|
|
3100
3854
|
function requestFormDataWithRetry(baseURL, timeout, path, formData, retry, onProgress) {
|
|
3101
3855
|
if (onProgress) {
|
|
3102
3856
|
return fetchFormDataWithProgress(baseURL, timeout, path, formData, onProgress);
|
|
3103
3857
|
}
|
|
3104
|
-
return withRetry(
|
|
3858
|
+
return withRetry(function () {
|
|
3859
|
+
return fetchFormData(baseURL, timeout, path, formData);
|
|
3860
|
+
}, retry);
|
|
3105
3861
|
}
|
|
3106
3862
|
function requestGetWithRetry(baseURL, timeout, path, retry) {
|
|
3107
|
-
return withRetry(
|
|
3863
|
+
return withRetry(function () {
|
|
3864
|
+
return fetchGet(baseURL, timeout, path);
|
|
3865
|
+
}, retry);
|
|
3108
3866
|
}
|
|
3109
3867
|
|
|
3110
3868
|
// src/compress.ts
|
|
3111
|
-
var IMAGE_EXTENSIONS = /* @__PURE__ */
|
|
3112
|
-
var VIDEO_EXTENSIONS = /* @__PURE__ */
|
|
3869
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */new Set(["jpg", "jpeg", "png", "webp", "bmp"]);
|
|
3870
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */new Set(["mp4", "webm", "mov", "avi", "mkv", "flv", "wmv"]);
|
|
3113
3871
|
function getExtension(fileName) {
|
|
3114
3872
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
3115
3873
|
}
|
|
@@ -3128,19 +3886,17 @@ var DEFAULT_LIMITS = {
|
|
|
3128
3886
|
other: 10 * 1024 * 1024
|
|
3129
3887
|
};
|
|
3130
3888
|
function getSizeLimit(fileName, limits) {
|
|
3131
|
-
|
|
3889
|
+
var merged = _objectSpread$2(_objectSpread$2({}, DEFAULT_LIMITS), limits);
|
|
3132
3890
|
if (isImage(fileName)) return merged.image;
|
|
3133
3891
|
if (isVideo(fileName)) return merged.video;
|
|
3134
3892
|
return merged.other;
|
|
3135
3893
|
}
|
|
3136
3894
|
function validateFileSize(blob, fileName, limits) {
|
|
3137
|
-
|
|
3895
|
+
var maxSize = getSizeLimit(fileName, limits);
|
|
3138
3896
|
if (blob.size > maxSize) {
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
throw new Error(
|
|
3142
|
-
`\u6587\u4EF6 "${fileName}" \u5927\u5C0F ${sizeMB}MB \u8D85\u8FC7\u9650\u5236 ${limitMB}MB`
|
|
3143
|
-
);
|
|
3897
|
+
var sizeMB = (blob.size / 1024 / 1024).toFixed(1);
|
|
3898
|
+
var limitMB = (maxSize / 1024 / 1024).toFixed(1);
|
|
3899
|
+
throw new Error("\u6587\u4EF6 \"".concat(fileName, "\" \u5927\u5C0F ").concat(sizeMB, "MB \u8D85\u8FC7\u9650\u5236 ").concat(limitMB, "MB"));
|
|
3144
3900
|
}
|
|
3145
3901
|
}
|
|
3146
3902
|
var DEFAULT_COMPRESS = {
|
|
@@ -3149,71 +3905,119 @@ var DEFAULT_COMPRESS = {
|
|
|
3149
3905
|
imageMaxWidth: 1920,
|
|
3150
3906
|
imageMaxHeight: 1080
|
|
3151
3907
|
};
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3908
|
+
function compressImageBlob(_x19, _x20) {
|
|
3909
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3910
|
+
}
|
|
3911
|
+
function _compressImageBlob() {
|
|
3912
|
+
_compressImageBlob = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(blob, options) {
|
|
3913
|
+
var opts, bitmap, srcW, srcH, targetW, targetH, canvas, ctx, ext, outputType, compressed;
|
|
3914
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
3915
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
3916
|
+
case 0:
|
|
3917
|
+
opts = _objectSpread$2(_objectSpread$2({}, DEFAULT_COMPRESS), options);
|
|
3918
|
+
if (!(typeof createImageBitmap === "undefined" || typeof OffscreenCanvas === "undefined")) {
|
|
3919
|
+
_context10.next = 1;
|
|
3920
|
+
break;
|
|
3921
|
+
}
|
|
3922
|
+
return _context10.abrupt("return", blob);
|
|
3923
|
+
case 1:
|
|
3924
|
+
_context10.prev = 1;
|
|
3925
|
+
_context10.next = 2;
|
|
3926
|
+
return createImageBitmap(blob);
|
|
3927
|
+
case 2:
|
|
3928
|
+
bitmap = _context10.sent;
|
|
3929
|
+
srcW = bitmap.width, srcH = bitmap.height;
|
|
3930
|
+
targetW = srcW;
|
|
3931
|
+
targetH = srcH;
|
|
3932
|
+
if (targetW > opts.imageMaxWidth) {
|
|
3933
|
+
targetH = Math.round(targetH * (opts.imageMaxWidth / targetW));
|
|
3934
|
+
targetW = opts.imageMaxWidth;
|
|
3935
|
+
}
|
|
3936
|
+
if (targetH > opts.imageMaxHeight) {
|
|
3937
|
+
targetW = Math.round(targetW * (opts.imageMaxHeight / targetH));
|
|
3938
|
+
targetH = opts.imageMaxHeight;
|
|
3939
|
+
}
|
|
3940
|
+
canvas = new OffscreenCanvas(targetW, targetH);
|
|
3941
|
+
ctx = canvas.getContext("2d");
|
|
3942
|
+
if (ctx) {
|
|
3943
|
+
_context10.next = 3;
|
|
3944
|
+
break;
|
|
3945
|
+
}
|
|
3946
|
+
bitmap.close();
|
|
3947
|
+
return _context10.abrupt("return", blob);
|
|
3948
|
+
case 3:
|
|
3949
|
+
ctx.drawImage(bitmap, 0, 0, targetW, targetH);
|
|
3950
|
+
bitmap.close();
|
|
3951
|
+
ext = getExtension(blob.name || "");
|
|
3952
|
+
outputType = "image/webp";
|
|
3953
|
+
if (ext === "png") outputType = "image/png";else if (ext === "jpg" || ext === "jpeg") outputType = "image/jpeg";
|
|
3954
|
+
_context10.next = 4;
|
|
3955
|
+
return canvas.convertToBlob({
|
|
3956
|
+
type: outputType,
|
|
3957
|
+
quality: opts.imageQuality
|
|
3958
|
+
});
|
|
3959
|
+
case 4:
|
|
3960
|
+
compressed = _context10.sent;
|
|
3961
|
+
return _context10.abrupt("return", compressed.size < blob.size ? compressed : blob);
|
|
3962
|
+
case 5:
|
|
3963
|
+
_context10.prev = 5;
|
|
3964
|
+
_context10["catch"](1);
|
|
3965
|
+
return _context10.abrupt("return", blob);
|
|
3966
|
+
case 6:
|
|
3967
|
+
case "end":
|
|
3968
|
+
return _context10.stop();
|
|
3969
|
+
}
|
|
3970
|
+
}, _callee10, null, [[1, 5]]);
|
|
3971
|
+
}));
|
|
3972
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3973
|
+
}
|
|
3974
|
+
function processFile(_x21, _x22, _x23, _x24) {
|
|
3975
|
+
return _processFile.apply(this, arguments);
|
|
3976
|
+
} // src/client.ts
|
|
3977
|
+
function _processFile() {
|
|
3978
|
+
_processFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(blob, fileName, compress, limits) {
|
|
3979
|
+
var opts;
|
|
3980
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
3981
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
3982
|
+
case 0:
|
|
3983
|
+
opts = _objectSpread$2(_objectSpread$2({}, DEFAULT_COMPRESS), compress);
|
|
3984
|
+
if (!(opts.enabled && isImage(fileName))) {
|
|
3985
|
+
_context11.next = 2;
|
|
3986
|
+
break;
|
|
3987
|
+
}
|
|
3988
|
+
_context11.next = 1;
|
|
3989
|
+
return compressImageBlob(blob, opts);
|
|
3990
|
+
case 1:
|
|
3991
|
+
blob = _context11.sent;
|
|
3992
|
+
case 2:
|
|
3993
|
+
validateFileSize(blob, fileName, limits);
|
|
3994
|
+
return _context11.abrupt("return", blob);
|
|
3995
|
+
case 3:
|
|
3996
|
+
case "end":
|
|
3997
|
+
return _context11.stop();
|
|
3998
|
+
}
|
|
3999
|
+
}, _callee11);
|
|
4000
|
+
}));
|
|
4001
|
+
return _processFile.apply(this, arguments);
|
|
3198
4002
|
}
|
|
3199
|
-
|
|
3200
|
-
// src/client.ts
|
|
3201
4003
|
var DEFAULT_BASE_URL = "https://we0.ai";
|
|
3202
4004
|
var DEFAULT_TIMEOUT = 3e4;
|
|
3203
4005
|
function uuid() {
|
|
3204
4006
|
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
3205
4007
|
return crypto.randomUUID();
|
|
3206
4008
|
}
|
|
3207
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c)
|
|
3208
|
-
|
|
4009
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
4010
|
+
var r = Math.random() * 16 | 0;
|
|
3209
4011
|
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
3210
4012
|
});
|
|
3211
4013
|
}
|
|
3212
4014
|
function toBlob(input) {
|
|
3213
4015
|
if (input instanceof Blob) return input;
|
|
3214
|
-
if (typeof input === "string") return new Blob([input], {
|
|
4016
|
+
if (typeof input === "string") return new Blob([input], {
|
|
4017
|
+
type: "text/plain"
|
|
4018
|
+
});
|
|
3215
4019
|
if (input instanceof ArrayBuffer) return new Blob([input]);
|
|
3216
|
-
|
|
4020
|
+
var copy = input.slice().buffer;
|
|
3217
4021
|
return new Blob([copy]);
|
|
3218
4022
|
}
|
|
3219
4023
|
function getExt2(fileName) {
|
|
@@ -3222,150 +4026,252 @@ function getExt2(fileName) {
|
|
|
3222
4026
|
function resolveFileName(originalName, rename) {
|
|
3223
4027
|
if (!rename) return originalName;
|
|
3224
4028
|
if (rename === true) {
|
|
3225
|
-
|
|
3226
|
-
return ext ?
|
|
4029
|
+
var ext = getExt2(originalName);
|
|
4030
|
+
return ext ? "".concat(uuid(), ".").concat(ext) : uuid();
|
|
3227
4031
|
}
|
|
3228
4032
|
if (typeof rename === "string") return rename;
|
|
3229
4033
|
if (typeof rename === "function") return rename(originalName);
|
|
3230
4034
|
return originalName;
|
|
3231
4035
|
}
|
|
3232
|
-
function createOssClient(
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
4036
|
+
function createOssClient() {
|
|
4037
|
+
var _options$baseURL, _options$timeout;
|
|
4038
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4039
|
+
var baseURL = (_options$baseURL = options.baseURL) !== null && _options$baseURL !== void 0 ? _options$baseURL : DEFAULT_BASE_URL;
|
|
4040
|
+
var timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : DEFAULT_TIMEOUT;
|
|
4041
|
+
var defaultRetry = options.retry;
|
|
4042
|
+
var defaultCompress = options.compress;
|
|
4043
|
+
var defaultLimits = options.limits;
|
|
4044
|
+
var allowedExtensions = options.allowedExtensions;
|
|
3239
4045
|
function mergeRetry(override) {
|
|
3240
4046
|
if (!defaultRetry && !override) return void 0;
|
|
3241
|
-
return {
|
|
4047
|
+
return _objectSpread$2(_objectSpread$2({}, defaultRetry), override);
|
|
3242
4048
|
}
|
|
3243
4049
|
function resolveCompress(override) {
|
|
3244
|
-
if (override === false) return {
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
4050
|
+
if (override === false) return {
|
|
4051
|
+
enabled: false
|
|
4052
|
+
};
|
|
4053
|
+
if (defaultCompress === false && override === void 0) return {
|
|
4054
|
+
enabled: false
|
|
4055
|
+
};
|
|
4056
|
+
var base = _typeof$1(defaultCompress) === "object" ? defaultCompress : {};
|
|
4057
|
+
return override ? _objectSpread$2(_objectSpread$2({}, base), override) : Object.keys(base).length ? base : void 0;
|
|
3248
4058
|
}
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
4059
|
+
function uploadOne(_x25, _x26, _x27, _x28) {
|
|
4060
|
+
return _uploadOne.apply(this, arguments);
|
|
4061
|
+
}
|
|
4062
|
+
function _uploadOne() {
|
|
4063
|
+
_uploadOne = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(sessionId, file, fileName, opts) {
|
|
4064
|
+
var finalName, blob, compress, formData;
|
|
4065
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
4066
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
4067
|
+
case 0:
|
|
4068
|
+
if (sessionId) {
|
|
4069
|
+
_context5.next = 1;
|
|
4070
|
+
break;
|
|
4071
|
+
}
|
|
4072
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4073
|
+
case 1:
|
|
4074
|
+
if (fileName) {
|
|
4075
|
+
_context5.next = 2;
|
|
4076
|
+
break;
|
|
4077
|
+
}
|
|
4078
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4079
|
+
case 2:
|
|
4080
|
+
finalName = resolveFileName(fileName, opts === null || opts === void 0 ? void 0 : opts.rename);
|
|
4081
|
+
blob = toBlob(file);
|
|
4082
|
+
if (opts !== null && opts !== void 0 && opts.skipValidation) {
|
|
4083
|
+
_context5.next = 3;
|
|
4084
|
+
break;
|
|
4085
|
+
}
|
|
4086
|
+
validateExtension(finalName, allowedExtensions);
|
|
4087
|
+
_context5.next = 3;
|
|
4088
|
+
return validateMagicBytes(blob, finalName);
|
|
4089
|
+
case 3:
|
|
4090
|
+
compress = resolveCompress(opts === null || opts === void 0 ? void 0 : opts.compress);
|
|
4091
|
+
_context5.next = 4;
|
|
4092
|
+
return processFile(blob, finalName, compress, defaultLimits);
|
|
4093
|
+
case 4:
|
|
4094
|
+
blob = _context5.sent;
|
|
4095
|
+
formData = new FormData();
|
|
4096
|
+
formData.append("file", blob, finalName);
|
|
4097
|
+
formData.append("sessionId", sessionId);
|
|
4098
|
+
return _context5.abrupt("return", requestFormDataWithRetry(baseURL, timeout, "/api/oss/upload", formData, mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry), opts === null || opts === void 0 ? void 0 : opts.onProgress));
|
|
4099
|
+
case 5:
|
|
4100
|
+
case "end":
|
|
4101
|
+
return _context5.stop();
|
|
4102
|
+
}
|
|
4103
|
+
}, _callee5);
|
|
4104
|
+
}));
|
|
4105
|
+
return _uploadOne.apply(this, arguments);
|
|
3275
4106
|
}
|
|
3276
4107
|
return {
|
|
3277
4108
|
upload: uploadOne,
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
return new Promise((resolve, reject) => {
|
|
3289
|
-
function next() {
|
|
3290
|
-
if (results.length === files.length) {
|
|
3291
|
-
resolve(results);
|
|
3292
|
-
return;
|
|
3293
|
-
}
|
|
3294
|
-
while (running < concurrency && index < files.length) {
|
|
3295
|
-
const i = index++;
|
|
3296
|
-
const item = files[i];
|
|
3297
|
-
running++;
|
|
3298
|
-
const fileOpts = {
|
|
3299
|
-
retry: opts?.retry,
|
|
3300
|
-
compress: opts?.compress,
|
|
3301
|
-
...item.options
|
|
3302
|
-
};
|
|
3303
|
-
uploadOne(sessionId, item.file, item.fileName, fileOpts).then((result) => {
|
|
3304
|
-
results[i] = { fileName: item.fileName, success: true, result };
|
|
3305
|
-
}).catch((error) => {
|
|
3306
|
-
results[i] = { fileName: item.fileName, success: false, error };
|
|
3307
|
-
if (!continueOnError) {
|
|
3308
|
-
reject(error);
|
|
3309
|
-
return;
|
|
4109
|
+
uploadBatch: function uploadBatch(sessionId, files, opts) {
|
|
4110
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
4111
|
+
var _opts$concurrency, _opts$continueOnError;
|
|
4112
|
+
var concurrency, continueOnError, results, running, index;
|
|
4113
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
4114
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4115
|
+
case 0:
|
|
4116
|
+
if (sessionId) {
|
|
4117
|
+
_context.next = 1;
|
|
4118
|
+
break;
|
|
3310
4119
|
}
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
4120
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4121
|
+
case 1:
|
|
4122
|
+
if (files.length) {
|
|
4123
|
+
_context.next = 2;
|
|
4124
|
+
break;
|
|
4125
|
+
}
|
|
4126
|
+
return _context.abrupt("return", []);
|
|
4127
|
+
case 2:
|
|
4128
|
+
concurrency = (_opts$concurrency = opts === null || opts === void 0 ? void 0 : opts.concurrency) !== null && _opts$concurrency !== void 0 ? _opts$concurrency : 3;
|
|
4129
|
+
continueOnError = (_opts$continueOnError = opts === null || opts === void 0 ? void 0 : opts.continueOnError) !== null && _opts$continueOnError !== void 0 ? _opts$continueOnError : true;
|
|
4130
|
+
results = [];
|
|
4131
|
+
running = 0;
|
|
4132
|
+
index = 0;
|
|
4133
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
4134
|
+
function next() {
|
|
4135
|
+
if (results.length === files.length) {
|
|
4136
|
+
resolve(results);
|
|
4137
|
+
return;
|
|
4138
|
+
}
|
|
4139
|
+
var _loop = function _loop() {
|
|
4140
|
+
var i = index++;
|
|
4141
|
+
var item = files[i];
|
|
4142
|
+
running++;
|
|
4143
|
+
var fileOpts = _objectSpread$2({
|
|
4144
|
+
retry: opts === null || opts === void 0 ? void 0 : opts.retry,
|
|
4145
|
+
compress: opts === null || opts === void 0 ? void 0 : opts.compress
|
|
4146
|
+
}, item.options);
|
|
4147
|
+
uploadOne(sessionId, item.file, item.fileName, fileOpts).then(function (result) {
|
|
4148
|
+
results[i] = {
|
|
4149
|
+
fileName: item.fileName,
|
|
4150
|
+
success: true,
|
|
4151
|
+
result: result
|
|
4152
|
+
};
|
|
4153
|
+
})["catch"](function (error) {
|
|
4154
|
+
results[i] = {
|
|
4155
|
+
fileName: item.fileName,
|
|
4156
|
+
success: false,
|
|
4157
|
+
error: error
|
|
4158
|
+
};
|
|
4159
|
+
if (!continueOnError) {
|
|
4160
|
+
reject(error);
|
|
4161
|
+
return;
|
|
4162
|
+
}
|
|
4163
|
+
})["finally"](function () {
|
|
4164
|
+
running--;
|
|
4165
|
+
next();
|
|
4166
|
+
});
|
|
4167
|
+
};
|
|
4168
|
+
while (running < concurrency && index < files.length) {
|
|
4169
|
+
_loop();
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
next();
|
|
4173
|
+
}));
|
|
4174
|
+
case 3:
|
|
4175
|
+
case "end":
|
|
4176
|
+
return _context.stop();
|
|
3315
4177
|
}
|
|
3316
|
-
}
|
|
3317
|
-
|
|
3318
|
-
});
|
|
4178
|
+
}, _callee);
|
|
4179
|
+
}))();
|
|
3319
4180
|
},
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
4181
|
+
"delete": function _delete(sessionId, fileName, opts) {
|
|
4182
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
4183
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
4184
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4185
|
+
case 0:
|
|
4186
|
+
if (sessionId) {
|
|
4187
|
+
_context2.next = 1;
|
|
4188
|
+
break;
|
|
4189
|
+
}
|
|
4190
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4191
|
+
case 1:
|
|
4192
|
+
if (fileName) {
|
|
4193
|
+
_context2.next = 2;
|
|
4194
|
+
break;
|
|
4195
|
+
}
|
|
4196
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4197
|
+
case 2:
|
|
4198
|
+
return _context2.abrupt("return", requestJsonWithRetry(baseURL, timeout, "/api/oss/delete", {
|
|
4199
|
+
sessionId: sessionId,
|
|
4200
|
+
fileName: fileName
|
|
4201
|
+
}, mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry)));
|
|
4202
|
+
case 3:
|
|
4203
|
+
case "end":
|
|
4204
|
+
return _context2.stop();
|
|
4205
|
+
}
|
|
4206
|
+
}, _callee2);
|
|
4207
|
+
}))();
|
|
3334
4208
|
},
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
4209
|
+
getFileUrl: function getFileUrl(sessionId, fileName, opts) {
|
|
4210
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
4211
|
+
var params, result;
|
|
4212
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
4213
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4214
|
+
case 0:
|
|
4215
|
+
if (sessionId) {
|
|
4216
|
+
_context3.next = 1;
|
|
4217
|
+
break;
|
|
4218
|
+
}
|
|
4219
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4220
|
+
case 1:
|
|
4221
|
+
if (fileName) {
|
|
4222
|
+
_context3.next = 2;
|
|
4223
|
+
break;
|
|
4224
|
+
}
|
|
4225
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4226
|
+
case 2:
|
|
4227
|
+
params = new URLSearchParams({
|
|
4228
|
+
sessionId: sessionId,
|
|
4229
|
+
fileName: fileName
|
|
4230
|
+
});
|
|
4231
|
+
_context3.next = 3;
|
|
4232
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
4233
|
+
case 3:
|
|
4234
|
+
result = _context3.sent;
|
|
4235
|
+
return _context3.abrupt("return", result.url || "");
|
|
4236
|
+
case 4:
|
|
4237
|
+
case "end":
|
|
4238
|
+
return _context3.stop();
|
|
4239
|
+
}
|
|
4240
|
+
}, _callee3);
|
|
4241
|
+
}))();
|
|
3350
4242
|
},
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
4243
|
+
listFiles: function listFiles(sessionId, opts) {
|
|
4244
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
4245
|
+
var params, result;
|
|
4246
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
4247
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4248
|
+
case 0:
|
|
4249
|
+
if (sessionId) {
|
|
4250
|
+
_context4.next = 1;
|
|
4251
|
+
break;
|
|
4252
|
+
}
|
|
4253
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4254
|
+
case 1:
|
|
4255
|
+
params = new URLSearchParams({
|
|
4256
|
+
sessionId: sessionId
|
|
4257
|
+
});
|
|
4258
|
+
_context4.next = 2;
|
|
4259
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
4260
|
+
case 2:
|
|
4261
|
+
result = _context4.sent;
|
|
4262
|
+
return _context4.abrupt("return", result.files);
|
|
4263
|
+
case 3:
|
|
4264
|
+
case "end":
|
|
4265
|
+
return _context4.stop();
|
|
4266
|
+
}
|
|
4267
|
+
}, _callee4);
|
|
4268
|
+
}))();
|
|
3363
4269
|
}
|
|
3364
4270
|
};
|
|
3365
4271
|
}
|
|
3366
4272
|
|
|
3367
4273
|
var _excluded$1 = ["accessKeyId", "accessKeySecret"];
|
|
3368
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
4274
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf$1(o), _possibleConstructorReturn$1(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf$1(t).constructor) : o.apply(t, e)); }
|
|
3369
4275
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
3370
4276
|
var DEFAULT_MAX_SIZE = 2 * 1024 * 1024;
|
|
3371
4277
|
var DEFAULT_SIGNED_URL_EXPIRES_IN = 60 * 60;
|
|
@@ -3373,15 +4279,15 @@ var OssUploadError = /*#__PURE__*/function (_Error) {
|
|
|
3373
4279
|
function OssUploadError(message) {
|
|
3374
4280
|
var _this;
|
|
3375
4281
|
var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
|
|
3376
|
-
_classCallCheck(this, OssUploadError);
|
|
4282
|
+
_classCallCheck$1(this, OssUploadError);
|
|
3377
4283
|
_this = _callSuper(this, OssUploadError, [message]);
|
|
3378
4284
|
_this.name = "OssUploadError";
|
|
3379
4285
|
_this.status = status;
|
|
3380
4286
|
return _this;
|
|
3381
4287
|
}
|
|
3382
|
-
_inherits(OssUploadError, _Error);
|
|
3383
|
-
return _createClass(OssUploadError);
|
|
3384
|
-
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
4288
|
+
_inherits$1(OssUploadError, _Error);
|
|
4289
|
+
return _createClass$1(OssUploadError);
|
|
4290
|
+
}(/*#__PURE__*/_wrapNativeSuper$1(Error));
|
|
3385
4291
|
function sanitizePathSegment(value) {
|
|
3386
4292
|
return String(value || "").trim().replace(/[^a-zA-Z0-9/_-]+/g, "-").replace(/\/{2,}/g, "/").replace(/^\/+|\/+$/g, "");
|
|
3387
4293
|
}
|
|
@@ -3446,7 +4352,7 @@ function normalizeSdkError(error) {
|
|
|
3446
4352
|
}
|
|
3447
4353
|
var OssUploadService = /*#__PURE__*/function () {
|
|
3448
4354
|
function OssUploadService(config) {
|
|
3449
|
-
_classCallCheck(this, OssUploadService);
|
|
4355
|
+
_classCallCheck$1(this, OssUploadService);
|
|
3450
4356
|
this.config = normalizeConfig(config);
|
|
3451
4357
|
this.client = createOssClient({
|
|
3452
4358
|
baseURL: this.config.baseURL,
|
|
@@ -3454,7 +4360,7 @@ var OssUploadService = /*#__PURE__*/function () {
|
|
|
3454
4360
|
retry: this.config.retry
|
|
3455
4361
|
});
|
|
3456
4362
|
}
|
|
3457
|
-
return _createClass(OssUploadService, [{
|
|
4363
|
+
return _createClass$1(OssUploadService, [{
|
|
3458
4364
|
key: "getConfig",
|
|
3459
4365
|
value: function getConfig() {
|
|
3460
4366
|
var _this$config = this.config;
|
|
@@ -3466,9 +4372,9 @@ var OssUploadService = /*#__PURE__*/function () {
|
|
|
3466
4372
|
}, {
|
|
3467
4373
|
key: "upload",
|
|
3468
4374
|
value: function () {
|
|
3469
|
-
var _upload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(input) {
|
|
4375
|
+
var _upload = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(input) {
|
|
3470
4376
|
var sessionId, maxSize, objectKey, result, url, resolvedUrl, _t;
|
|
3471
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
4377
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
3472
4378
|
while (1) switch (_context.prev = _context.next) {
|
|
3473
4379
|
case 0:
|
|
3474
4380
|
sessionId = String(input.sessionId || "").trim();
|
|
@@ -3580,9 +4486,9 @@ function ensureAdminRegistryTable(_x) {
|
|
|
3580
4486
|
return _ensureAdminRegistryTable.apply(this, arguments);
|
|
3581
4487
|
}
|
|
3582
4488
|
function _ensureAdminRegistryTable() {
|
|
3583
|
-
_ensureAdminRegistryTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(supabase) {
|
|
4489
|
+
_ensureAdminRegistryTable = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(supabase) {
|
|
3584
4490
|
var _yield$supabase$from$, error;
|
|
3585
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
4491
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
3586
4492
|
while (1) switch (_context.prev = _context.next) {
|
|
3587
4493
|
case 0:
|
|
3588
4494
|
if (!ensured) {
|
|
@@ -3623,9 +4529,9 @@ function getSessionAdminRow(_x2, _x3) {
|
|
|
3623
4529
|
return _getSessionAdminRow.apply(this, arguments);
|
|
3624
4530
|
}
|
|
3625
4531
|
function _getSessionAdminRow() {
|
|
3626
|
-
_getSessionAdminRow = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(supabase, sessionId) {
|
|
4532
|
+
_getSessionAdminRow = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(supabase, sessionId) {
|
|
3627
4533
|
var sid, _yield$supabase$from$2, data, error;
|
|
3628
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
4534
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
3629
4535
|
while (1) switch (_context2.prev = _context2.next) {
|
|
3630
4536
|
case 0:
|
|
3631
4537
|
sid = normalizeSessionId(sessionId);
|
|
@@ -3654,9 +4560,9 @@ function isUserSessionAdmin(_x4, _x5, _x6) {
|
|
|
3654
4560
|
return _isUserSessionAdmin.apply(this, arguments);
|
|
3655
4561
|
}
|
|
3656
4562
|
function _isUserSessionAdmin() {
|
|
3657
|
-
_isUserSessionAdmin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(supabase, sessionId, userId) {
|
|
4563
|
+
_isUserSessionAdmin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(supabase, sessionId, userId) {
|
|
3658
4564
|
var row;
|
|
3659
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
4565
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
3660
4566
|
while (1) switch (_context3.prev = _context3.next) {
|
|
3661
4567
|
case 0:
|
|
3662
4568
|
_context3.next = 1;
|
|
@@ -3689,9 +4595,9 @@ function initializeSystem() {
|
|
|
3689
4595
|
return _initializeSystem.apply(this, arguments);
|
|
3690
4596
|
}
|
|
3691
4597
|
function _initializeSystem() {
|
|
3692
|
-
_initializeSystem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
4598
|
+
_initializeSystem = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee() {
|
|
3693
4599
|
var _t;
|
|
3694
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
4600
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
3695
4601
|
while (1) switch (_context.prev = _context.next) {
|
|
3696
4602
|
case 0:
|
|
3697
4603
|
_context.prev = 0;
|
|
@@ -3782,9 +4688,9 @@ function getModels(_x) {
|
|
|
3782
4688
|
}
|
|
3783
4689
|
// POST - 创建新模型
|
|
3784
4690
|
function _getModels() {
|
|
3785
|
-
_getModels = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
4691
|
+
_getModels = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c) {
|
|
3786
4692
|
var cmsModelService, page, limit, name, sessionId, models, tablePrefix, total, offset, paginatedModels, response, _response, _t2;
|
|
3787
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
4693
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
3788
4694
|
while (1) switch (_context2.prev = _context2.next) {
|
|
3789
4695
|
case 0:
|
|
3790
4696
|
_context2.prev = 0;
|
|
@@ -3853,9 +4759,9 @@ function createModel(_x2) {
|
|
|
3853
4759
|
}
|
|
3854
4760
|
// PUT - 更新模型
|
|
3855
4761
|
function _createModel() {
|
|
3856
|
-
_createModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c) {
|
|
4762
|
+
_createModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(c) {
|
|
3857
4763
|
var cmsModelService, dynamicTableService, body, name, table_name, json_schema, _response2, sessionId, tableNameError, _response3, schemaValidationError, _response4, existingModel, _response5, allModels, nameExists, _response6, tableExists, _response7, tableCreated, _response8, newModel, response, _response9, _t3;
|
|
3858
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
4764
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
3859
4765
|
while (1) switch (_context3.prev = _context3.next) {
|
|
3860
4766
|
case 0:
|
|
3861
4767
|
_context3.prev = 0;
|
|
@@ -3999,9 +4905,9 @@ function updateModel(_x3) {
|
|
|
3999
4905
|
}
|
|
4000
4906
|
// DELETE - 删除模型
|
|
4001
4907
|
function _updateModel() {
|
|
4002
|
-
_updateModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(c) {
|
|
4908
|
+
_updateModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(c) {
|
|
4003
4909
|
var cmsModelService, body, id, name, json_schema, _response0, model, _response1, schemaValidationError, _response10, updateData, updatedModel, response, _response11, _t4;
|
|
4004
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
4910
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
4005
4911
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4006
4912
|
case 0:
|
|
4007
4913
|
_context4.prev = 0;
|
|
@@ -4089,9 +4995,9 @@ function deleteModel(_x4) {
|
|
|
4089
4995
|
return _deleteModel.apply(this, arguments);
|
|
4090
4996
|
}
|
|
4091
4997
|
function _deleteModel() {
|
|
4092
|
-
_deleteModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(c) {
|
|
4998
|
+
_deleteModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(c) {
|
|
4093
4999
|
var cmsModelService, dynamicTableService, idStr, _response12, id, model, _response13, tableDropped, _response14, response, _response15, _t5;
|
|
4094
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
5000
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
4095
5001
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4096
5002
|
case 0:
|
|
4097
5003
|
_context5.prev = 0;
|
|
@@ -4228,7 +5134,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
4228
5134
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(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(r, a) : void 0; } }
|
|
4229
5135
|
function _arrayLikeToArray(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; }
|
|
4230
5136
|
function ownKeys$1(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; }
|
|
4231
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5137
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4232
5138
|
function normalizeJsonLikeFields(schemaFields, payload) {
|
|
4233
5139
|
if (!schemaFields || schemaFields.length === 0) return payload;
|
|
4234
5140
|
var jsonLikeFieldNames = new Set(schemaFields.filter(function (f) {
|
|
@@ -4454,9 +5360,9 @@ function getTableData(_x, _x2) {
|
|
|
4454
5360
|
}
|
|
4455
5361
|
// POST - 创建新数据
|
|
4456
5362
|
function _getTableData() {
|
|
4457
|
-
_getTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c, tableName) {
|
|
5363
|
+
_getTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c, tableName) {
|
|
4458
5364
|
var _model$json_schema, validationResponse, dynamicTableService, cmsModelService, page, limit, search, filtersStr, model, schemaFields, filters, _response, parsed, normalized, _response2, result, searchableFields, response, _response3, _t, _t2;
|
|
4459
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
5365
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
4460
5366
|
while (1) switch (_context.prev = _context.next) {
|
|
4461
5367
|
case 0:
|
|
4462
5368
|
_context.prev = 0;
|
|
@@ -4596,9 +5502,9 @@ function createTableData(_x3, _x4) {
|
|
|
4596
5502
|
}
|
|
4597
5503
|
// PUT - 更新数据
|
|
4598
5504
|
function _createTableData() {
|
|
4599
|
-
_createTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c, tableName) {
|
|
5505
|
+
_createTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c, tableName) {
|
|
4600
5506
|
var _model$json_schema2, validationResponse, dynamicTableService, cmsModelService, body, rawData, data, _i2, _Object$entries2, _Object$entries2$_i, key, value, model, normalizedData, _response4, result, response, _response5, _t3, _t4;
|
|
4601
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
5507
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
4602
5508
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4603
5509
|
case 0:
|
|
4604
5510
|
_context2.prev = 0;
|
|
@@ -4682,9 +5588,9 @@ function updateTableData(_x5, _x6) {
|
|
|
4682
5588
|
}
|
|
4683
5589
|
// DELETE - 删除数据
|
|
4684
5590
|
function _updateTableData() {
|
|
4685
|
-
_updateTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c, tableName) {
|
|
5591
|
+
_updateTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(c, tableName) {
|
|
4686
5592
|
var _model$json_schema3, validationResponse, dynamicTableService, cmsModelService, body, id, data, recordId, _response6, _response7, existingData, _response8, rawUpdateData, updateData, _i3, _Object$entries3, _Object$entries3$_i, key, value, model, _response9, result, _response0, response, _response1, _t5, _t6;
|
|
4687
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
5593
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
4688
5594
|
while (1) switch (_context3.prev = _context3.next) {
|
|
4689
5595
|
case 0:
|
|
4690
5596
|
_context3.prev = 0;
|
|
@@ -4813,9 +5719,9 @@ function deleteTableData(_x7, _x8) {
|
|
|
4813
5719
|
}
|
|
4814
5720
|
// GET - 获取关联表选项列表 (用于下拉选择)
|
|
4815
5721
|
function _deleteTableData() {
|
|
4816
|
-
_deleteTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(c, tableName) {
|
|
5722
|
+
_deleteTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(c, tableName) {
|
|
4817
5723
|
var validationResponse, dynamicTableService, id, _response10, recordId, _response11, existingData, _response12, result, response, _response13, _t7;
|
|
4818
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
5724
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
4819
5725
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4820
5726
|
case 0:
|
|
4821
5727
|
_context4.prev = 0;
|
|
@@ -4896,9 +5802,9 @@ function getRelationOptions(_x9, _x0) {
|
|
|
4896
5802
|
}
|
|
4897
5803
|
// GET - 获取表数据(带关联数据)
|
|
4898
5804
|
function _getRelationOptions() {
|
|
4899
|
-
_getRelationOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(c, tableName) {
|
|
5805
|
+
_getRelationOptions = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(c, tableName) {
|
|
4900
5806
|
var validationResponse, dynamicTableService, displayField, limit, search, params, options, response, _response14, _t8;
|
|
4901
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
5807
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
4902
5808
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4903
5809
|
case 0:
|
|
4904
5810
|
_context5.prev = 0;
|
|
@@ -4952,9 +5858,9 @@ function getTableDataWithRelations(_x1, _x10) {
|
|
|
4952
5858
|
// DELETE - 删除表的所有外键约束
|
|
4953
5859
|
// 用于解决外键约束引用错误表的问题
|
|
4954
5860
|
function _getTableDataWithRelations() {
|
|
4955
|
-
_getTableDataWithRelations = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(c, tableName) {
|
|
5861
|
+
_getTableDataWithRelations = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(c, tableName) {
|
|
4956
5862
|
var validationResponse, dynamicTableService, cmsModelService, page, limit, model, result, response, hasRelations, _result, _response15, _result2, _response16, _response17, _t9;
|
|
4957
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
5863
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
4958
5864
|
while (1) switch (_context6.prev = _context6.next) {
|
|
4959
5865
|
case 0:
|
|
4960
5866
|
_context6.prev = 0;
|
|
@@ -5039,9 +5945,9 @@ function dropForeignKeys(_x11, _x12) {
|
|
|
5039
5945
|
return _dropForeignKeys.apply(this, arguments);
|
|
5040
5946
|
}
|
|
5041
5947
|
function _dropForeignKeys() {
|
|
5042
|
-
_dropForeignKeys = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(c, tableName) {
|
|
5948
|
+
_dropForeignKeys = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7(c, tableName) {
|
|
5043
5949
|
var validationResponse, dynamicTableService, result, response, _response18, _response19, _t0;
|
|
5044
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
5950
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
5045
5951
|
while (1) switch (_context7.prev = _context7.next) {
|
|
5046
5952
|
case 0:
|
|
5047
5953
|
_context7.prev = 0;
|
|
@@ -5102,9 +6008,9 @@ var JWT_EXPIRES_IN = '24h';
|
|
|
5102
6008
|
*/
|
|
5103
6009
|
var AuthUtils = /*#__PURE__*/function () {
|
|
5104
6010
|
function AuthUtils() {
|
|
5105
|
-
_classCallCheck(this, AuthUtils);
|
|
6011
|
+
_classCallCheck$1(this, AuthUtils);
|
|
5106
6012
|
}
|
|
5107
|
-
return _createClass(AuthUtils, null, [{
|
|
6013
|
+
return _createClass$1(AuthUtils, null, [{
|
|
5108
6014
|
key: "generateToken",
|
|
5109
6015
|
value:
|
|
5110
6016
|
/**
|
|
@@ -5140,8 +6046,8 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5140
6046
|
}, {
|
|
5141
6047
|
key: "validatePassword",
|
|
5142
6048
|
value: (function () {
|
|
5143
|
-
var _validatePassword = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(plainPassword, hashedPassword) {
|
|
5144
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
6049
|
+
var _validatePassword = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(plainPassword, hashedPassword) {
|
|
6050
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
5145
6051
|
while (1) switch (_context.prev = _context.next) {
|
|
5146
6052
|
case 0:
|
|
5147
6053
|
return _context.abrupt("return", bcrypt__namespace.compare(plainPassword, hashedPassword));
|
|
@@ -5163,8 +6069,8 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5163
6069
|
}, {
|
|
5164
6070
|
key: "hashPassword",
|
|
5165
6071
|
value: (function () {
|
|
5166
|
-
var _hashPassword = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(password) {
|
|
5167
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
6072
|
+
var _hashPassword = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(password) {
|
|
6073
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
5168
6074
|
while (1) switch (_context2.prev = _context2.next) {
|
|
5169
6075
|
case 0:
|
|
5170
6076
|
return _context2.abrupt("return", bcrypt__namespace.hash(password, 10));
|
|
@@ -5205,9 +6111,9 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5205
6111
|
}, {
|
|
5206
6112
|
key: "authenticateUser",
|
|
5207
6113
|
value: (function () {
|
|
5208
|
-
var _authenticateUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(username, password, tableName) {
|
|
6114
|
+
var _authenticateUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(username, password, tableName) {
|
|
5209
6115
|
var authService, user, isPasswordValid, _t;
|
|
5210
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
6116
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
5211
6117
|
while (1) switch (_context3.prev = _context3.next) {
|
|
5212
6118
|
case 0:
|
|
5213
6119
|
authService = this.getAuthService(); // 查询用户
|
|
@@ -5276,9 +6182,9 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5276
6182
|
}, {
|
|
5277
6183
|
key: "verifyTokenAndGetUser",
|
|
5278
6184
|
value: (function () {
|
|
5279
|
-
var _verifyTokenAndGetUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(token, tableName) {
|
|
6185
|
+
var _verifyTokenAndGetUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(token, tableName) {
|
|
5280
6186
|
var decoded, authService, userInfo, message, _t2;
|
|
5281
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
6187
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
5282
6188
|
while (1) switch (_context4.prev = _context4.next) {
|
|
5283
6189
|
case 0:
|
|
5284
6190
|
_context4.prev = 0;
|
|
@@ -5334,7 +6240,7 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5334
6240
|
}();
|
|
5335
6241
|
|
|
5336
6242
|
function ownKeys(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; }
|
|
5337
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6243
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5338
6244
|
function getRoleFromSupabaseUser$2(user) {
|
|
5339
6245
|
var _user$app_metadata, _user$user_metadata;
|
|
5340
6246
|
var appRole = user === null || user === void 0 || (_user$app_metadata = user.app_metadata) === null || _user$app_metadata === void 0 ? void 0 : _user$app_metadata.role;
|
|
@@ -5370,9 +6276,9 @@ function findAuthUserByEmail(_x, _x2) {
|
|
|
5370
6276
|
return _findAuthUserByEmail.apply(this, arguments);
|
|
5371
6277
|
}
|
|
5372
6278
|
function _findAuthUserByEmail() {
|
|
5373
|
-
_findAuthUserByEmail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(supabase, email) {
|
|
6279
|
+
_findAuthUserByEmail = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(supabase, email) {
|
|
5374
6280
|
var normalizedEmail, page, _yield$supabase$auth$2, data, error, users, matchedUser;
|
|
5375
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
6281
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
5376
6282
|
while (1) switch (_context2.prev = _context2.next) {
|
|
5377
6283
|
case 0:
|
|
5378
6284
|
normalizedEmail = email.trim().toLowerCase();
|
|
@@ -5431,8 +6337,8 @@ function insertAdminRegistryRow(_x3, _x4, _x5, _x6) {
|
|
|
5431
6337
|
return _insertAdminRegistryRow.apply(this, arguments);
|
|
5432
6338
|
}
|
|
5433
6339
|
function _insertAdminRegistryRow() {
|
|
5434
|
-
_insertAdminRegistryRow = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(supabase, sessionId, userId, account) {
|
|
5435
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
6340
|
+
_insertAdminRegistryRow = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(supabase, sessionId, userId, account) {
|
|
6341
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
5436
6342
|
while (1) switch (_context3.prev = _context3.next) {
|
|
5437
6343
|
case 0:
|
|
5438
6344
|
_context3.next = 1;
|
|
@@ -5455,9 +6361,9 @@ function promoteExistingUserToSessionAdmin(_x7, _x8, _x9, _x0) {
|
|
|
5455
6361
|
return _promoteExistingUserToSessionAdmin.apply(this, arguments);
|
|
5456
6362
|
}
|
|
5457
6363
|
function _promoteExistingUserToSessionAdmin() {
|
|
5458
|
-
_promoteExistingUserToSessionAdmin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(supabase, email, sessionId, account) {
|
|
6364
|
+
_promoteExistingUserToSessionAdmin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(supabase, email, sessionId, account) {
|
|
5459
6365
|
var existingUser, _yield$supabase$auth$3, updatedData, updateError, insertRes;
|
|
5460
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
6366
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
5461
6367
|
while (1) switch (_context4.prev = _context4.next) {
|
|
5462
6368
|
case 0:
|
|
5463
6369
|
_context4.next = 1;
|
|
@@ -5524,9 +6430,9 @@ function getEffectiveRoleForSession(_x1, _x10) {
|
|
|
5524
6430
|
return _getEffectiveRoleForSession.apply(this, arguments);
|
|
5525
6431
|
} // POST - 用户登录
|
|
5526
6432
|
function _getEffectiveRoleForSession() {
|
|
5527
|
-
_getEffectiveRoleForSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(user, sessionId) {
|
|
6433
|
+
_getEffectiveRoleForSession = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(user, sessionId) {
|
|
5528
6434
|
var supabase, sid, role, ok;
|
|
5529
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
6435
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
5530
6436
|
while (1) switch (_context5.prev = _context5.next) {
|
|
5531
6437
|
case 0:
|
|
5532
6438
|
supabase = getSupabase();
|
|
@@ -5562,9 +6468,9 @@ function login(_x11, _x12) {
|
|
|
5562
6468
|
}
|
|
5563
6469
|
// GET - 是否允许注册(首次进入需要创建管理员账号)
|
|
5564
6470
|
function _login() {
|
|
5565
|
-
_login = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(c, tableName) {
|
|
6471
|
+
_login = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(c, tableName) {
|
|
5566
6472
|
var _data$session, body, username, password, supabase, sessionId, email, _yield$supabase$auth$4, data, error, token, user, role, _t3;
|
|
5567
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
6473
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
5568
6474
|
while (1) switch (_context6.prev = _context6.next) {
|
|
5569
6475
|
case 0:
|
|
5570
6476
|
_context6.prev = 0;
|
|
@@ -5657,9 +6563,9 @@ function signupStatus(_x13, _x14) {
|
|
|
5657
6563
|
}
|
|
5658
6564
|
// POST - 首次注册管理员(每个 session_id 只允许一个)
|
|
5659
6565
|
function _signupStatus() {
|
|
5660
|
-
_signupStatus = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(c, tableName) {
|
|
6566
|
+
_signupStatus = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7(c, tableName) {
|
|
5661
6567
|
var supabase, sessionId, ok, row, data, _t4;
|
|
5662
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
6568
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
5663
6569
|
while (1) switch (_context7.prev = _context7.next) {
|
|
5664
6570
|
case 0:
|
|
5665
6571
|
_context7.prev = 0;
|
|
@@ -5716,9 +6622,9 @@ function signup(_x15, _x16) {
|
|
|
5716
6622
|
}
|
|
5717
6623
|
// POST - 验证token
|
|
5718
6624
|
function _signup() {
|
|
5719
|
-
_signup = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(c, tableName) {
|
|
6625
|
+
_signup = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee8(c, tableName) {
|
|
5720
6626
|
var _body$username, _data$session2, body, account, password, supabase, sessionId, email, ok, existing, _yield$supabase$auth$5, data, error, promoted, insertRes, token, user, role, _t5;
|
|
5721
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
6627
|
+
return _regeneratorRuntime$1.wrap(function (_context8) {
|
|
5722
6628
|
while (1) switch (_context8.prev = _context8.next) {
|
|
5723
6629
|
case 0:
|
|
5724
6630
|
_context8.prev = 0;
|
|
@@ -5889,9 +6795,9 @@ function verifyAuth(_x17, _x18) {
|
|
|
5889
6795
|
}
|
|
5890
6796
|
// GET - 获取当前用户信息
|
|
5891
6797
|
function _verifyAuth() {
|
|
5892
|
-
_verifyAuth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(c, tableName) {
|
|
6798
|
+
_verifyAuth = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee9(c, tableName) {
|
|
5893
6799
|
var authHeader, token, supabase, _yield$supabase$auth$6, data, error, sessionId, role, decoded, message, responseMessage, _t6, _t7;
|
|
5894
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
6800
|
+
return _regeneratorRuntime$1.wrap(function (_context9) {
|
|
5895
6801
|
while (1) switch (_context9.prev = _context9.next) {
|
|
5896
6802
|
case 0:
|
|
5897
6803
|
_context9.prev = 0;
|
|
@@ -5969,9 +6875,9 @@ function getCurrentUser(_x19, _x20) {
|
|
|
5969
6875
|
}
|
|
5970
6876
|
// 中间件:验证 Supabase JWT token
|
|
5971
6877
|
function _getCurrentUser() {
|
|
5972
|
-
_getCurrentUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(c, tableName) {
|
|
6878
|
+
_getCurrentUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee0(c, tableName) {
|
|
5973
6879
|
var authHeader, token, supabase, _yield$supabase$auth$7, data, error, user, sessionId, role, _t8;
|
|
5974
|
-
return _regeneratorRuntime.wrap(function (_context0) {
|
|
6880
|
+
return _regeneratorRuntime$1.wrap(function (_context0) {
|
|
5975
6881
|
while (1) switch (_context0.prev = _context0.next) {
|
|
5976
6882
|
case 0:
|
|
5977
6883
|
_context0.prev = 0;
|
|
@@ -6042,7 +6948,7 @@ function _getCurrentUser() {
|
|
|
6042
6948
|
}
|
|
6043
6949
|
function requireAuth(handler) {
|
|
6044
6950
|
return /*#__PURE__*/function () {
|
|
6045
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c) {
|
|
6951
|
+
var _ref = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c) {
|
|
6046
6952
|
var authHeader,
|
|
6047
6953
|
token,
|
|
6048
6954
|
supabase,
|
|
@@ -6054,7 +6960,7 @@ function requireAuth(handler) {
|
|
|
6054
6960
|
_key,
|
|
6055
6961
|
_args = arguments,
|
|
6056
6962
|
_t2;
|
|
6057
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
6963
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6058
6964
|
while (1) switch (_context.prev = _context.next) {
|
|
6059
6965
|
case 0:
|
|
6060
6966
|
_context.prev = 0;
|
|
@@ -6136,10 +7042,10 @@ function resolveUploadMaxSize(_x, _x2) {
|
|
|
6136
7042
|
return _resolveUploadMaxSize.apply(this, arguments);
|
|
6137
7043
|
}
|
|
6138
7044
|
function _resolveUploadMaxSize() {
|
|
6139
|
-
_resolveUploadMaxSize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(tableName, fieldName) {
|
|
7045
|
+
_resolveUploadMaxSize = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(tableName, fieldName) {
|
|
6140
7046
|
var _model$json_schema;
|
|
6141
7047
|
var cmsModelService, model;
|
|
6142
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
7048
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6143
7049
|
while (1) switch (_context.prev = _context.next) {
|
|
6144
7050
|
case 0:
|
|
6145
7051
|
if (!(!tableName || !fieldName)) {
|
|
@@ -6169,9 +7075,9 @@ function uploadToOss(_x3) {
|
|
|
6169
7075
|
return _uploadToOss.apply(this, arguments);
|
|
6170
7076
|
}
|
|
6171
7077
|
function _uploadToOss() {
|
|
6172
|
-
_uploadToOss = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
7078
|
+
_uploadToOss = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c) {
|
|
6173
7079
|
var formData, file, fieldName, tableName, uploadService, result, status, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8;
|
|
6174
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7080
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
6175
7081
|
while (1) switch (_context2.prev = _context2.next) {
|
|
6176
7082
|
case 0:
|
|
6177
7083
|
_context2.prev = 0;
|
|
@@ -6253,9 +7159,9 @@ function getRoleFromSupabaseUser$1(user) {
|
|
|
6253
7159
|
return appRole !== null && appRole !== void 0 ? appRole : userRole;
|
|
6254
7160
|
}
|
|
6255
7161
|
var requireJwtAuth = /*#__PURE__*/function () {
|
|
6256
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c, next) {
|
|
7162
|
+
var _ref = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c, next) {
|
|
6257
7163
|
var authHeader, token, supabase, _yield$supabase$auth$, data, error, auth;
|
|
6258
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
7164
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6259
7165
|
while (1) switch (_context.prev = _context.next) {
|
|
6260
7166
|
case 0:
|
|
6261
7167
|
authHeader = c.req.header("Authorization") || null;
|
|
@@ -6317,10 +7223,10 @@ var requireJwtAuth = /*#__PURE__*/function () {
|
|
|
6317
7223
|
};
|
|
6318
7224
|
}();
|
|
6319
7225
|
var requireAdminRole = /*#__PURE__*/function () {
|
|
6320
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c, next) {
|
|
7226
|
+
var _ref2 = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c, next) {
|
|
6321
7227
|
var _user$user_metadata2;
|
|
6322
7228
|
var auth, role, sessionId, user, userSessionId, supabase, ok, isAdmin;
|
|
6323
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7229
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
6324
7230
|
while (1) switch (_context2.prev = _context2.next) {
|
|
6325
7231
|
case 0:
|
|
6326
7232
|
auth = c.auth;
|
|
@@ -6416,9 +7322,9 @@ function supabaseLogin(_x) {
|
|
|
6416
7322
|
}
|
|
6417
7323
|
// POST - 校验 Supabase JWT(需要 Authorization: Bearer <token>)
|
|
6418
7324
|
function _supabaseLogin() {
|
|
6419
|
-
_supabaseLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c) {
|
|
7325
|
+
_supabaseLogin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c) {
|
|
6420
7326
|
var _body$email, _data$session, body, email, password, supabase, _yield$supabase$auth$, data, error, token, user, role, _t;
|
|
6421
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
7327
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6422
7328
|
while (1) switch (_context.prev = _context.next) {
|
|
6423
7329
|
case 0:
|
|
6424
7330
|
_context.prev = 0;
|
|
@@ -6493,9 +7399,9 @@ function supabaseVerify(_x2) {
|
|
|
6493
7399
|
}
|
|
6494
7400
|
// GET - 当前用户(需要 Authorization: Bearer <token>)
|
|
6495
7401
|
function _supabaseVerify() {
|
|
6496
|
-
_supabaseVerify = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
7402
|
+
_supabaseVerify = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c) {
|
|
6497
7403
|
var token, supabase, _yield$supabase$auth$2, data, error, _t2;
|
|
6498
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7404
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
6499
7405
|
while (1) switch (_context2.prev = _context2.next) {
|
|
6500
7406
|
case 0:
|
|
6501
7407
|
_context2.prev = 0;
|
|
@@ -6550,9 +7456,9 @@ function supabaseCurrentUser(_x3) {
|
|
|
6550
7456
|
return _supabaseCurrentUser.apply(this, arguments);
|
|
6551
7457
|
}
|
|
6552
7458
|
function _supabaseCurrentUser() {
|
|
6553
|
-
_supabaseCurrentUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c) {
|
|
7459
|
+
_supabaseCurrentUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(c) {
|
|
6554
7460
|
var token, supabase, _yield$supabase$auth$3, data, error, user, role, _t3;
|
|
6555
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
7461
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
6556
7462
|
while (1) switch (_context3.prev = _context3.next) {
|
|
6557
7463
|
case 0:
|
|
6558
7464
|
_context3.prev = 0;
|