@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.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createClient } from '@supabase/supabase-js';
|
|
|
2
2
|
import * as jwt from 'jsonwebtoken';
|
|
3
3
|
import * as bcrypt from 'bcryptjs';
|
|
4
4
|
|
|
5
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
5
|
+
function asyncGeneratorStep$1(n, t, e, r, o, a, c) {
|
|
6
6
|
try {
|
|
7
7
|
var i = n[a](c),
|
|
8
8
|
u = i.value;
|
|
@@ -11,391 +11,390 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
|
11
11
|
}
|
|
12
12
|
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
13
13
|
}
|
|
14
|
-
function _asyncToGenerator(n) {
|
|
14
|
+
function _asyncToGenerator$1(n) {
|
|
15
15
|
return function () {
|
|
16
16
|
var t = this,
|
|
17
17
|
e = arguments;
|
|
18
18
|
return new Promise(function (r, o) {
|
|
19
19
|
var a = n.apply(t, e);
|
|
20
20
|
function _next(n) {
|
|
21
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
21
|
+
asyncGeneratorStep$1(a, r, o, _next, _throw, "next", n);
|
|
22
22
|
}
|
|
23
23
|
function _throw(n) {
|
|
24
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
24
|
+
asyncGeneratorStep$1(a, r, o, _next, _throw, "throw", n);
|
|
25
25
|
}
|
|
26
26
|
_next(void 0);
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
function _typeof$3(o) {
|
|
32
|
+
"@babel/helpers - typeof";
|
|
33
|
+
|
|
34
|
+
return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
35
|
+
return typeof o;
|
|
36
|
+
} : function (o) {
|
|
37
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
38
|
+
}, _typeof$3(o);
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
function getDefaultExportFromCjs (x) {
|
|
32
42
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
|
-
var regeneratorRuntime$
|
|
45
|
+
var regeneratorRuntime$2 = {exports: {}};
|
|
36
46
|
|
|
37
|
-
var OverloadYield = {exports: {}};
|
|
47
|
+
var OverloadYield$1 = {exports: {}};
|
|
38
48
|
|
|
39
49
|
(function (module) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
50
|
+
function _OverloadYield(e, d) {
|
|
51
|
+
this.v = e, this.k = d;
|
|
52
|
+
}
|
|
53
|
+
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
54
|
+
})(OverloadYield$1);
|
|
55
|
+
var OverloadYieldExports$1 = OverloadYield$1.exports;
|
|
45
56
|
|
|
46
|
-
var
|
|
57
|
+
var regenerator$3 = {exports: {}};
|
|
47
58
|
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
var regeneratorDefine = {exports: {}};
|
|
59
|
+
var regeneratorDefine$1 = {exports: {}};
|
|
51
60
|
|
|
52
61
|
(function (module) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var regeneratorDefineExports = regeneratorDefine.exports;
|
|
62
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
63
|
+
var i = Object.defineProperty;
|
|
64
|
+
try {
|
|
65
|
+
i({}, "", {});
|
|
66
|
+
} catch (e) {
|
|
67
|
+
i = 0;
|
|
68
|
+
}
|
|
69
|
+
module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
|
|
70
|
+
function o(r, n) {
|
|
71
|
+
_regeneratorDefine(e, r, function (e) {
|
|
72
|
+
return this._invoke(r, n, e);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
r ? i ? i(e, r, {
|
|
76
|
+
value: n,
|
|
77
|
+
enumerable: !t,
|
|
78
|
+
configurable: !t,
|
|
79
|
+
writable: !t
|
|
80
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
81
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
|
|
82
|
+
}
|
|
83
|
+
module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
84
|
+
})(regeneratorDefine$1);
|
|
85
|
+
var regeneratorDefineExports$1 = regeneratorDefine$1.exports;
|
|
78
86
|
|
|
79
87
|
(function (module) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
var regeneratorExports = regenerator$1.exports;
|
|
88
|
+
var regeneratorDefine = regeneratorDefineExports$1;
|
|
89
|
+
function _regenerator() {
|
|
90
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
91
|
+
var e,
|
|
92
|
+
t,
|
|
93
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
94
|
+
n = r.iterator || "@@iterator",
|
|
95
|
+
o = r.toStringTag || "@@toStringTag";
|
|
96
|
+
function i(r, n, o, i) {
|
|
97
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
98
|
+
u = Object.create(c.prototype);
|
|
99
|
+
return regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
100
|
+
var i,
|
|
101
|
+
c,
|
|
102
|
+
u,
|
|
103
|
+
f = 0,
|
|
104
|
+
p = o || [],
|
|
105
|
+
y = !1,
|
|
106
|
+
G = {
|
|
107
|
+
p: 0,
|
|
108
|
+
n: 0,
|
|
109
|
+
v: e,
|
|
110
|
+
a: d,
|
|
111
|
+
f: d.bind(e, 4),
|
|
112
|
+
d: function d(t, r) {
|
|
113
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function d(r, n) {
|
|
117
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
118
|
+
var o,
|
|
119
|
+
i = p[t],
|
|
120
|
+
d = G.p,
|
|
121
|
+
l = i[2];
|
|
122
|
+
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));
|
|
123
|
+
}
|
|
124
|
+
if (o || r > 1) return a;
|
|
125
|
+
throw y = !0, n;
|
|
126
|
+
}
|
|
127
|
+
return function (o, p, l) {
|
|
128
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
129
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
130
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
131
|
+
try {
|
|
132
|
+
if (f = 2, i) {
|
|
133
|
+
if (c || (o = "next"), t = i[o]) {
|
|
134
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
135
|
+
if (!t.done) return t;
|
|
136
|
+
u = t.value, c < 2 && (c = 0);
|
|
137
|
+
} else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
138
|
+
i = e;
|
|
139
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
140
|
+
} catch (t) {
|
|
141
|
+
i = e, c = 1, u = t;
|
|
142
|
+
} finally {
|
|
143
|
+
f = 1;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
value: t,
|
|
148
|
+
done: y
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
}(r, o, i), !0), u;
|
|
152
|
+
}
|
|
153
|
+
var a = {};
|
|
154
|
+
function Generator() {}
|
|
155
|
+
function GeneratorFunction() {}
|
|
156
|
+
function GeneratorFunctionPrototype() {}
|
|
157
|
+
t = Object.getPrototypeOf;
|
|
158
|
+
var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
|
|
159
|
+
return this;
|
|
160
|
+
}), t),
|
|
161
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
162
|
+
function f(e) {
|
|
163
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
164
|
+
}
|
|
165
|
+
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 () {
|
|
166
|
+
return this;
|
|
167
|
+
}), regeneratorDefine(u, "toString", function () {
|
|
168
|
+
return "[object Generator]";
|
|
169
|
+
}), (module.exports = _regenerator = function _regenerator() {
|
|
170
|
+
return {
|
|
171
|
+
w: i,
|
|
172
|
+
m: f
|
|
173
|
+
};
|
|
174
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
175
|
+
}
|
|
176
|
+
module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
177
|
+
})(regenerator$3);
|
|
178
|
+
var regeneratorExports$1 = regenerator$3.exports;
|
|
172
179
|
|
|
173
|
-
var regeneratorAsync = {exports: {}};
|
|
180
|
+
var regeneratorAsync$1 = {exports: {}};
|
|
174
181
|
|
|
175
|
-
var regeneratorAsyncGen = {exports: {}};
|
|
182
|
+
var regeneratorAsyncGen$1 = {exports: {}};
|
|
176
183
|
|
|
177
|
-
var regeneratorAsyncIterator = {exports: {}};
|
|
184
|
+
var regeneratorAsyncIterator$1 = {exports: {}};
|
|
178
185
|
|
|
179
186
|
(function (module) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var regeneratorAsyncIteratorExports = regeneratorAsyncIterator.exports;
|
|
187
|
+
var OverloadYield = OverloadYieldExports$1;
|
|
188
|
+
var regeneratorDefine = regeneratorDefineExports$1;
|
|
189
|
+
function AsyncIterator(t, e) {
|
|
190
|
+
function n(r, o, i, f) {
|
|
191
|
+
try {
|
|
192
|
+
var c = t[r](o),
|
|
193
|
+
u = c.value;
|
|
194
|
+
return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
|
|
195
|
+
n("next", t, i, f);
|
|
196
|
+
}, function (t) {
|
|
197
|
+
n("throw", t, i, f);
|
|
198
|
+
}) : e.resolve(u).then(function (t) {
|
|
199
|
+
c.value = t, i(c);
|
|
200
|
+
}, function (t) {
|
|
201
|
+
return n("throw", t, i, f);
|
|
202
|
+
});
|
|
203
|
+
} catch (t) {
|
|
204
|
+
f(t);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
var r;
|
|
208
|
+
this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
|
|
209
|
+
return this;
|
|
210
|
+
})), regeneratorDefine(this, "_invoke", function (t, o, i) {
|
|
211
|
+
function f() {
|
|
212
|
+
return new e(function (e, r) {
|
|
213
|
+
n(t, i, e, r);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return r = r ? r.then(f, f) : f();
|
|
217
|
+
}, !0);
|
|
218
|
+
}
|
|
219
|
+
module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
220
|
+
})(regeneratorAsyncIterator$1);
|
|
221
|
+
var regeneratorAsyncIteratorExports$1 = regeneratorAsyncIterator$1.exports;
|
|
216
222
|
|
|
217
223
|
(function (module) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
var regeneratorAsyncGenExports = regeneratorAsyncGen.exports;
|
|
224
|
+
var regenerator = regeneratorExports$1;
|
|
225
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports$1;
|
|
226
|
+
function _regeneratorAsyncGen(r, e, t, o, n) {
|
|
227
|
+
return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
|
|
228
|
+
}
|
|
229
|
+
module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
230
|
+
})(regeneratorAsyncGen$1);
|
|
231
|
+
var regeneratorAsyncGenExports$1 = regeneratorAsyncGen$1.exports;
|
|
227
232
|
|
|
228
233
|
(function (module) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
var regeneratorAsyncExports = regeneratorAsync.exports;
|
|
234
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports$1;
|
|
235
|
+
function _regeneratorAsync(n, e, r, t, o) {
|
|
236
|
+
var a = regeneratorAsyncGen(n, e, r, t, o);
|
|
237
|
+
return a.next().then(function (n) {
|
|
238
|
+
return n.done ? n.value : a.next();
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
242
|
+
})(regeneratorAsync$1);
|
|
243
|
+
var regeneratorAsyncExports$1 = regeneratorAsync$1.exports;
|
|
240
244
|
|
|
241
|
-
var regeneratorKeys = {exports: {}};
|
|
245
|
+
var regeneratorKeys$1 = {exports: {}};
|
|
242
246
|
|
|
243
247
|
(function (module) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
248
|
+
function _regeneratorKeys(e) {
|
|
249
|
+
var n = Object(e),
|
|
250
|
+
r = [];
|
|
251
|
+
for (var t in n) r.unshift(t);
|
|
252
|
+
return function e() {
|
|
253
|
+
for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
|
|
254
|
+
return e.done = !0, e;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
258
|
+
})(regeneratorKeys$1);
|
|
259
|
+
var regeneratorKeysExports$1 = regeneratorKeys$1.exports;
|
|
255
260
|
|
|
256
|
-
var
|
|
261
|
+
var regeneratorValues$1 = {exports: {}};
|
|
257
262
|
|
|
258
|
-
var
|
|
259
|
-
|
|
260
|
-
var _typeof$1 = {exports: {}};
|
|
263
|
+
var _typeof$2 = {exports: {}};
|
|
261
264
|
|
|
262
265
|
(function (module) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
267
|
-
return typeof o;
|
|
268
|
-
} : function (o) {
|
|
269
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
270
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
271
|
-
}
|
|
272
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
273
|
-
} (_typeof$1));
|
|
266
|
+
function _typeof(o) {
|
|
267
|
+
"@babel/helpers - typeof";
|
|
274
268
|
|
|
275
|
-
|
|
269
|
+
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
270
|
+
return typeof o;
|
|
271
|
+
} : function (o) {
|
|
272
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
273
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
274
|
+
}
|
|
275
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
276
|
+
})(_typeof$2);
|
|
277
|
+
var _typeofExports$1 = _typeof$2.exports;
|
|
276
278
|
|
|
277
279
|
(function (module) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
var regeneratorValuesExports = regeneratorValues.exports;
|
|
280
|
+
var _typeof = _typeofExports$1["default"];
|
|
281
|
+
function _regeneratorValues(e) {
|
|
282
|
+
if (null != e) {
|
|
283
|
+
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
284
|
+
r = 0;
|
|
285
|
+
if (t) return t.call(e);
|
|
286
|
+
if ("function" == typeof e.next) return e;
|
|
287
|
+
if (!isNaN(e.length)) return {
|
|
288
|
+
next: function next() {
|
|
289
|
+
return e && r >= e.length && (e = void 0), {
|
|
290
|
+
value: e && e[r++],
|
|
291
|
+
done: !e
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
297
|
+
}
|
|
298
|
+
module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
299
|
+
})(regeneratorValues$1);
|
|
300
|
+
var regeneratorValuesExports$1 = regeneratorValues$1.exports;
|
|
300
301
|
|
|
301
302
|
(function (module) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
var r = regenerator(),
|
|
312
|
-
e = r.m(_regeneratorRuntime),
|
|
313
|
-
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
314
|
-
function n(r) {
|
|
315
|
-
var e = "function" == typeof r && r.constructor;
|
|
316
|
-
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
317
|
-
}
|
|
318
|
-
var o = {
|
|
319
|
-
"throw": 1,
|
|
320
|
-
"return": 2,
|
|
321
|
-
"break": 3,
|
|
322
|
-
"continue": 3
|
|
323
|
-
};
|
|
324
|
-
function a(r) {
|
|
325
|
-
var e, t;
|
|
326
|
-
return function (n) {
|
|
327
|
-
e || (e = {
|
|
328
|
-
stop: function stop() {
|
|
329
|
-
return t(n.a, 2);
|
|
330
|
-
},
|
|
331
|
-
"catch": function _catch() {
|
|
332
|
-
return n.v;
|
|
333
|
-
},
|
|
334
|
-
abrupt: function abrupt(r, e) {
|
|
335
|
-
return t(n.a, o[r], e);
|
|
336
|
-
},
|
|
337
|
-
delegateYield: function delegateYield(r, o, a) {
|
|
338
|
-
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
339
|
-
},
|
|
340
|
-
finish: function finish(r) {
|
|
341
|
-
return t(n.f, r);
|
|
342
|
-
}
|
|
343
|
-
}, t = function t(r, _t, o) {
|
|
344
|
-
n.p = e.prev, n.n = e.next;
|
|
345
|
-
try {
|
|
346
|
-
return r(_t, o);
|
|
347
|
-
} finally {
|
|
348
|
-
e.next = n.n;
|
|
349
|
-
}
|
|
350
|
-
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
351
|
-
try {
|
|
352
|
-
return r.call(this, e);
|
|
353
|
-
} finally {
|
|
354
|
-
n.p = e.prev, n.n = e.next;
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
359
|
-
return {
|
|
360
|
-
wrap: function wrap(e, t, n, o) {
|
|
361
|
-
return r.w(a(e), t, n, o && o.reverse());
|
|
362
|
-
},
|
|
363
|
-
isGeneratorFunction: n,
|
|
364
|
-
mark: r.m,
|
|
365
|
-
awrap: function awrap(r, e) {
|
|
366
|
-
return new OverloadYield(r, e);
|
|
367
|
-
},
|
|
368
|
-
AsyncIterator: regeneratorAsyncIterator,
|
|
369
|
-
async: function async(r, e, t, o, u) {
|
|
370
|
-
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
371
|
-
},
|
|
372
|
-
keys: regeneratorKeys,
|
|
373
|
-
values: regeneratorValues
|
|
374
|
-
};
|
|
375
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
376
|
-
}
|
|
377
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
378
|
-
} (regeneratorRuntime$1));
|
|
303
|
+
var OverloadYield = OverloadYieldExports$1;
|
|
304
|
+
var regenerator = regeneratorExports$1;
|
|
305
|
+
var regeneratorAsync = regeneratorAsyncExports$1;
|
|
306
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports$1;
|
|
307
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports$1;
|
|
308
|
+
var regeneratorKeys = regeneratorKeysExports$1;
|
|
309
|
+
var regeneratorValues = regeneratorValuesExports$1;
|
|
310
|
+
function _regeneratorRuntime() {
|
|
379
311
|
|
|
380
|
-
var
|
|
312
|
+
var r = regenerator(),
|
|
313
|
+
e = r.m(_regeneratorRuntime),
|
|
314
|
+
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
315
|
+
function n(r) {
|
|
316
|
+
var e = "function" == typeof r && r.constructor;
|
|
317
|
+
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
318
|
+
}
|
|
319
|
+
var o = {
|
|
320
|
+
"throw": 1,
|
|
321
|
+
"return": 2,
|
|
322
|
+
"break": 3,
|
|
323
|
+
"continue": 3
|
|
324
|
+
};
|
|
325
|
+
function a(r) {
|
|
326
|
+
var e, t;
|
|
327
|
+
return function (n) {
|
|
328
|
+
e || (e = {
|
|
329
|
+
stop: function stop() {
|
|
330
|
+
return t(n.a, 2);
|
|
331
|
+
},
|
|
332
|
+
"catch": function _catch() {
|
|
333
|
+
return n.v;
|
|
334
|
+
},
|
|
335
|
+
abrupt: function abrupt(r, e) {
|
|
336
|
+
return t(n.a, o[r], e);
|
|
337
|
+
},
|
|
338
|
+
delegateYield: function delegateYield(r, o, a) {
|
|
339
|
+
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
340
|
+
},
|
|
341
|
+
finish: function finish(r) {
|
|
342
|
+
return t(n.f, r);
|
|
343
|
+
}
|
|
344
|
+
}, t = function t(r, _t, o) {
|
|
345
|
+
n.p = e.prev, n.n = e.next;
|
|
346
|
+
try {
|
|
347
|
+
return r(_t, o);
|
|
348
|
+
} finally {
|
|
349
|
+
e.next = n.n;
|
|
350
|
+
}
|
|
351
|
+
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
352
|
+
try {
|
|
353
|
+
return r.call(this, e);
|
|
354
|
+
} finally {
|
|
355
|
+
n.p = e.prev, n.n = e.next;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
360
|
+
return {
|
|
361
|
+
wrap: function wrap(e, t, n, o) {
|
|
362
|
+
return r.w(a(e), t, n, o && o.reverse());
|
|
363
|
+
},
|
|
364
|
+
isGeneratorFunction: n,
|
|
365
|
+
mark: r.m,
|
|
366
|
+
awrap: function awrap(r, e) {
|
|
367
|
+
return new OverloadYield(r, e);
|
|
368
|
+
},
|
|
369
|
+
AsyncIterator: regeneratorAsyncIterator,
|
|
370
|
+
async: function async(r, e, t, o, u) {
|
|
371
|
+
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
372
|
+
},
|
|
373
|
+
keys: regeneratorKeys,
|
|
374
|
+
values: regeneratorValues
|
|
375
|
+
};
|
|
376
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
377
|
+
}
|
|
378
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
379
|
+
})(regeneratorRuntime$2);
|
|
380
|
+
var regeneratorRuntimeExports$1 = regeneratorRuntime$2.exports;
|
|
381
381
|
|
|
382
382
|
// TODO(Babel 8): Remove this file.
|
|
383
383
|
|
|
384
|
-
var runtime = regeneratorRuntimeExports();
|
|
385
|
-
var regenerator = runtime;
|
|
384
|
+
var runtime$1 = regeneratorRuntimeExports$1();
|
|
385
|
+
var regenerator$2 = runtime$1;
|
|
386
386
|
|
|
387
387
|
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
388
388
|
try {
|
|
389
|
-
regeneratorRuntime = runtime;
|
|
389
|
+
regeneratorRuntime = runtime$1;
|
|
390
390
|
} catch (accidentalStrictMode) {
|
|
391
|
-
if (typeof globalThis === "object") {
|
|
392
|
-
globalThis.regeneratorRuntime = runtime;
|
|
391
|
+
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$3(globalThis)) === "object") {
|
|
392
|
+
globalThis.regeneratorRuntime = runtime$1;
|
|
393
393
|
} else {
|
|
394
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
394
|
+
Function("r", "regeneratorRuntime = r")(runtime$1);
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
|
|
398
|
-
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
397
|
+
var _regeneratorRuntime$1 = /*@__PURE__*/getDefaultExportFromCjs(regenerator$2);
|
|
399
398
|
|
|
400
399
|
var supabaseInstance = null;
|
|
401
400
|
/**
|
|
@@ -435,9 +434,9 @@ function testConnection() {
|
|
|
435
434
|
* 通过直接创建表和函数来避免手动执行 SQL 文件
|
|
436
435
|
*/
|
|
437
436
|
function _testConnection() {
|
|
438
|
-
_testConnection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
437
|
+
_testConnection = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee() {
|
|
439
438
|
var supabase, _yield$supabase$from$, error, _t;
|
|
440
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
439
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
441
440
|
while (1) switch (_context.prev = _context.next) {
|
|
442
441
|
case 0:
|
|
443
442
|
_context.prev = 0;
|
|
@@ -476,9 +475,9 @@ function executeSupabaseSetup() {
|
|
|
476
475
|
* 初始化CMS系统表
|
|
477
476
|
*/
|
|
478
477
|
function _executeSupabaseSetup() {
|
|
479
|
-
_executeSupabaseSetup = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
478
|
+
_executeSupabaseSetup = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2() {
|
|
480
479
|
var supabase, createTableSQL, _yield$supabase$from$2, tableError, fullSetupSQL, functionsToCheck, missingFunctions, _i, _functionsToCheck, funcName, _t3;
|
|
481
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
480
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
482
481
|
while (1) switch (_context2.prev = _context2.next) {
|
|
483
482
|
case 0:
|
|
484
483
|
_context2.prev = 0;
|
|
@@ -608,9 +607,9 @@ function initializeCmsSystem() {
|
|
|
608
607
|
* 关闭Supabase连接(实际上Supabase客户端不需要显式关闭)
|
|
609
608
|
*/
|
|
610
609
|
function _initializeCmsSystem() {
|
|
611
|
-
_initializeCmsSystem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
610
|
+
_initializeCmsSystem = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3() {
|
|
612
611
|
var setupSuccess, supabase, _yield$supabase$rpc, error, _t4;
|
|
613
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
612
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
614
613
|
while (1) switch (_context3.prev = _context3.next) {
|
|
615
614
|
case 0:
|
|
616
615
|
_context3.prev = 0;
|
|
@@ -657,8 +656,8 @@ function closeSupabase() {
|
|
|
657
656
|
* 用户可以复制此脚本到 Supabase SQL 编辑器中执行
|
|
658
657
|
*/
|
|
659
658
|
function _closeSupabase() {
|
|
660
|
-
_closeSupabase = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
661
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
659
|
+
_closeSupabase = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4() {
|
|
660
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
662
661
|
while (1) switch (_context4.prev = _context4.next) {
|
|
663
662
|
case 0:
|
|
664
663
|
supabaseInstance = null;
|
|
@@ -674,44 +673,34 @@ function getSupabaseSetupSQL() {
|
|
|
674
673
|
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';";
|
|
675
674
|
}
|
|
676
675
|
|
|
677
|
-
function _classCallCheck(a, n) {
|
|
676
|
+
function _classCallCheck$1(a, n) {
|
|
678
677
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
679
678
|
}
|
|
680
679
|
|
|
681
|
-
function
|
|
682
|
-
"
|
|
683
|
-
|
|
684
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
685
|
-
return typeof o;
|
|
686
|
-
} : function (o) {
|
|
687
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
688
|
-
}, _typeof(o);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function toPrimitive(t, r) {
|
|
692
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
680
|
+
function toPrimitive$1(t, r) {
|
|
681
|
+
if ("object" != _typeof$3(t) || !t) return t;
|
|
693
682
|
var e = t[Symbol.toPrimitive];
|
|
694
683
|
if (void 0 !== e) {
|
|
695
684
|
var i = e.call(t, r || "default");
|
|
696
|
-
if ("object" != _typeof(i)) return i;
|
|
685
|
+
if ("object" != _typeof$3(i)) return i;
|
|
697
686
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
698
687
|
}
|
|
699
688
|
return ("string" === r ? String : Number)(t);
|
|
700
689
|
}
|
|
701
690
|
|
|
702
|
-
function toPropertyKey(t) {
|
|
703
|
-
var i = toPrimitive(t, "string");
|
|
704
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
691
|
+
function toPropertyKey$1(t) {
|
|
692
|
+
var i = toPrimitive$1(t, "string");
|
|
693
|
+
return "symbol" == _typeof$3(i) ? i : i + "";
|
|
705
694
|
}
|
|
706
695
|
|
|
707
|
-
function _defineProperties(e, r) {
|
|
696
|
+
function _defineProperties$1(e, r) {
|
|
708
697
|
for (var t = 0; t < r.length; t++) {
|
|
709
698
|
var o = r[t];
|
|
710
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
|
|
699
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey$1(o.key), o);
|
|
711
700
|
}
|
|
712
701
|
}
|
|
713
|
-
function _createClass(e, r, t) {
|
|
714
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
702
|
+
function _createClass$1(e, r, t) {
|
|
703
|
+
return r && _defineProperties$1(e.prototype, r), t && _defineProperties$1(e, t), Object.defineProperty(e, "prototype", {
|
|
715
704
|
writable: !1
|
|
716
705
|
}), e;
|
|
717
706
|
}
|
|
@@ -719,19 +708,19 @@ function _createClass(e, r, t) {
|
|
|
719
708
|
// CMS 模型服务类
|
|
720
709
|
var CmsModelService = /*#__PURE__*/function () {
|
|
721
710
|
function CmsModelService() {
|
|
722
|
-
_classCallCheck(this, CmsModelService);
|
|
711
|
+
_classCallCheck$1(this, CmsModelService);
|
|
723
712
|
this.tableName = "_cms_models";
|
|
724
713
|
this.supabase = getSupabase();
|
|
725
714
|
}
|
|
726
715
|
/**
|
|
727
716
|
* 创建新的CMS模型
|
|
728
717
|
*/
|
|
729
|
-
return _createClass(CmsModelService, [{
|
|
718
|
+
return _createClass$1(CmsModelService, [{
|
|
730
719
|
key: "create",
|
|
731
720
|
value: (function () {
|
|
732
|
-
var _create = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
|
|
721
|
+
var _create = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(data) {
|
|
733
722
|
var _yield$this$supabase$, result, error;
|
|
734
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
723
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
735
724
|
while (1) switch (_context.prev = _context.next) {
|
|
736
725
|
case 0:
|
|
737
726
|
_context.next = 1;
|
|
@@ -765,9 +754,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
765
754
|
}, {
|
|
766
755
|
key: "findById",
|
|
767
756
|
value: (function () {
|
|
768
|
-
var _findById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id) {
|
|
757
|
+
var _findById = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(id) {
|
|
769
758
|
var _yield$this$supabase$2, data, error;
|
|
770
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
759
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
771
760
|
while (1) switch (_context2.prev = _context2.next) {
|
|
772
761
|
case 0:
|
|
773
762
|
_context2.next = 1;
|
|
@@ -807,9 +796,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
807
796
|
}, {
|
|
808
797
|
key: "findByTableName",
|
|
809
798
|
value: (function () {
|
|
810
|
-
var _findByTableName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(tableName) {
|
|
799
|
+
var _findByTableName = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(tableName) {
|
|
811
800
|
var _yield$this$supabase$3, data, error;
|
|
812
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
801
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
813
802
|
while (1) switch (_context3.prev = _context3.next) {
|
|
814
803
|
case 0:
|
|
815
804
|
_context3.next = 1;
|
|
@@ -849,9 +838,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
849
838
|
}, {
|
|
850
839
|
key: "findAll",
|
|
851
840
|
value: (function () {
|
|
852
|
-
var _findAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
841
|
+
var _findAll = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4() {
|
|
853
842
|
var _yield$this$supabase$4, data, error;
|
|
854
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
843
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
855
844
|
while (1) switch (_context4.prev = _context4.next) {
|
|
856
845
|
case 0:
|
|
857
846
|
_context4.next = 1;
|
|
@@ -887,9 +876,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
887
876
|
}, {
|
|
888
877
|
key: "update",
|
|
889
878
|
value: (function () {
|
|
890
|
-
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, data) {
|
|
879
|
+
var _update = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(id, data) {
|
|
891
880
|
var _yield$this$supabase$5, result, error;
|
|
892
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
881
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
893
882
|
while (1) switch (_context5.prev = _context5.next) {
|
|
894
883
|
case 0:
|
|
895
884
|
_context5.next = 1;
|
|
@@ -923,9 +912,9 @@ var CmsModelService = /*#__PURE__*/function () {
|
|
|
923
912
|
}, {
|
|
924
913
|
key: "delete",
|
|
925
914
|
value: (function () {
|
|
926
|
-
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id) {
|
|
915
|
+
var _delete2 = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(id) {
|
|
927
916
|
var _yield$this$supabase$6, error;
|
|
928
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
917
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
929
918
|
while (1) switch (_context6.prev = _context6.next) {
|
|
930
919
|
case 0:
|
|
931
920
|
_context6.next = 1;
|
|
@@ -971,9 +960,9 @@ function initializeCmsModel() {
|
|
|
971
960
|
}
|
|
972
961
|
// 为了向后兼容,导出服务类作为默认导出
|
|
973
962
|
function _initializeCmsModel() {
|
|
974
|
-
_initializeCmsModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
963
|
+
_initializeCmsModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7() {
|
|
975
964
|
var supabase, createTableSQL, _yield$supabase$rpc, error, _t;
|
|
976
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
965
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
977
966
|
while (1) switch (_context7.prev = _context7.next) {
|
|
978
967
|
case 0:
|
|
979
968
|
_context7.prev = 0;
|
|
@@ -1009,8 +998,8 @@ function _initializeCmsModel() {
|
|
|
1009
998
|
return _initializeCmsModel.apply(this, arguments);
|
|
1010
999
|
}
|
|
1011
1000
|
|
|
1012
|
-
function _defineProperty(e, r, t) {
|
|
1013
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1001
|
+
function _defineProperty$1(e, r, t) {
|
|
1002
|
+
return (r = toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, {
|
|
1014
1003
|
value: t,
|
|
1015
1004
|
enumerable: !0,
|
|
1016
1005
|
configurable: !0,
|
|
@@ -1018,11 +1007,11 @@ function _defineProperty(e, r, t) {
|
|
|
1018
1007
|
}) : e[r] = t, e;
|
|
1019
1008
|
}
|
|
1020
1009
|
|
|
1021
|
-
function ownKeys$
|
|
1022
|
-
function _objectSpread$
|
|
1023
|
-
function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$
|
|
1024
|
-
function _unsupportedIterableToArray$
|
|
1025
|
-
function _arrayLikeToArray$
|
|
1010
|
+
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; }
|
|
1011
|
+
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; }
|
|
1012
|
+
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; } } }; }
|
|
1013
|
+
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; } }
|
|
1014
|
+
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; }
|
|
1026
1015
|
// 字段类型映射到PostgreSQL类型
|
|
1027
1016
|
var fieldTypeMapping = {
|
|
1028
1017
|
string: "text",
|
|
@@ -1039,20 +1028,20 @@ var fieldTypeMapping = {
|
|
|
1039
1028
|
};
|
|
1040
1029
|
var DynamicTableService = /*#__PURE__*/function () {
|
|
1041
1030
|
function DynamicTableService() {
|
|
1042
|
-
_classCallCheck(this, DynamicTableService);
|
|
1031
|
+
_classCallCheck$1(this, DynamicTableService);
|
|
1043
1032
|
this.supabase = getSupabase();
|
|
1044
1033
|
}
|
|
1045
1034
|
/**
|
|
1046
1035
|
* 默认按 created_at 倒序(新数据在前)。
|
|
1047
1036
|
* 兼容:如果表不存在 created_at 字段,则回退按 id 倒序。
|
|
1048
1037
|
*/
|
|
1049
|
-
return _createClass(DynamicTableService, [{
|
|
1038
|
+
return _createClass$1(DynamicTableService, [{
|
|
1050
1039
|
key: "orderByCreatedAtOrFallback",
|
|
1051
1040
|
value: (function () {
|
|
1052
|
-
var _orderByCreatedAtOrFallback = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(buildQuery, offset, limit) {
|
|
1041
|
+
var _orderByCreatedAtOrFallback = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(buildQuery, offset, limit) {
|
|
1053
1042
|
var _first$error;
|
|
1054
1043
|
var first, msg, isMissingCreatedAt, second;
|
|
1055
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
1044
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
1056
1045
|
while (1) switch (_context.prev = _context.next) {
|
|
1057
1046
|
case 0:
|
|
1058
1047
|
_context.next = 1;
|
|
@@ -1183,9 +1172,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1183
1172
|
}, {
|
|
1184
1173
|
key: "createTable",
|
|
1185
1174
|
value: (function () {
|
|
1186
|
-
var _createTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(tableName, schema, baseTableName) {
|
|
1175
|
+
var _createTable = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(tableName, schema, baseTableName) {
|
|
1187
1176
|
var tablePrefix, createTableSQL, foreignKeys, _yield$this$supabase$, error, _t;
|
|
1188
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
1177
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
1189
1178
|
while (1) switch (_context2.prev = _context2.next) {
|
|
1190
1179
|
case 0:
|
|
1191
1180
|
_context2.prev = 0;
|
|
@@ -1279,9 +1268,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1279
1268
|
}, {
|
|
1280
1269
|
key: "dropTable",
|
|
1281
1270
|
value: (function () {
|
|
1282
|
-
var _dropTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(tableName) {
|
|
1271
|
+
var _dropTable = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(tableName) {
|
|
1283
1272
|
var _yield$this$supabase$2, error, _t2;
|
|
1284
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
1273
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
1285
1274
|
while (1) switch (_context3.prev = _context3.next) {
|
|
1286
1275
|
case 0:
|
|
1287
1276
|
_context3.prev = 0;
|
|
@@ -1324,9 +1313,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1324
1313
|
}, {
|
|
1325
1314
|
key: "dropAllForeignKeys",
|
|
1326
1315
|
value: (function () {
|
|
1327
|
-
var _dropAllForeignKeys = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(tableName) {
|
|
1316
|
+
var _dropAllForeignKeys = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(tableName) {
|
|
1328
1317
|
var parts, baseTableName, dropFKSQL, _yield$this$supabase$3, error, _t3;
|
|
1329
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
1318
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
1330
1319
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1331
1320
|
case 0:
|
|
1332
1321
|
_context4.prev = 0;
|
|
@@ -1376,9 +1365,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1376
1365
|
}, {
|
|
1377
1366
|
key: "dropForeignKeyByName",
|
|
1378
1367
|
value: (function () {
|
|
1379
|
-
var _dropForeignKeyByName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(tableName, constraintName) {
|
|
1368
|
+
var _dropForeignKeyByName = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(tableName, constraintName) {
|
|
1380
1369
|
var dropSQL, _yield$this$supabase$4, error, _t4;
|
|
1381
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
1370
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
1382
1371
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1383
1372
|
case 0:
|
|
1384
1373
|
_context5.prev = 0;
|
|
@@ -1422,9 +1411,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1422
1411
|
}, {
|
|
1423
1412
|
key: "dropForeignKey",
|
|
1424
1413
|
value: (function () {
|
|
1425
|
-
var _dropForeignKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(tableName, constraintName) {
|
|
1414
|
+
var _dropForeignKey = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(tableName, constraintName) {
|
|
1426
1415
|
var _yield$this$supabase$5, error, _t5;
|
|
1427
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
1416
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
1428
1417
|
while (1) switch (_context6.prev = _context6.next) {
|
|
1429
1418
|
case 0:
|
|
1430
1419
|
_context6.prev = 0;
|
|
@@ -1466,9 +1455,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1466
1455
|
}, {
|
|
1467
1456
|
key: "tableExists",
|
|
1468
1457
|
value: (function () {
|
|
1469
|
-
var _tableExists = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(tableName) {
|
|
1458
|
+
var _tableExists = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7(tableName) {
|
|
1470
1459
|
var _yield$this$supabase$6, data, error, _t6;
|
|
1471
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
1460
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
1472
1461
|
while (1) switch (_context7.prev = _context7.next) {
|
|
1473
1462
|
case 0:
|
|
1474
1463
|
_context7.prev = 0;
|
|
@@ -1510,9 +1499,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1510
1499
|
}, {
|
|
1511
1500
|
key: "getTableStructure",
|
|
1512
1501
|
value: (function () {
|
|
1513
|
-
var _getTableStructure = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(tableName) {
|
|
1502
|
+
var _getTableStructure = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee8(tableName) {
|
|
1514
1503
|
var _yield$this$supabase$7, data, error, _t7;
|
|
1515
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
1504
|
+
return _regeneratorRuntime$1.wrap(function (_context8) {
|
|
1516
1505
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1517
1506
|
case 0:
|
|
1518
1507
|
_context8.prev = 0;
|
|
@@ -1554,9 +1543,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1554
1543
|
}, {
|
|
1555
1544
|
key: "executeQuery",
|
|
1556
1545
|
value: (function () {
|
|
1557
|
-
var _executeQuery = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(sql, values) {
|
|
1546
|
+
var _executeQuery = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee9(sql, values) {
|
|
1558
1547
|
var finalSql, _yield$this$supabase$8, data, error, _t8;
|
|
1559
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
1548
|
+
return _regeneratorRuntime$1.wrap(function (_context9) {
|
|
1560
1549
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1561
1550
|
case 0:
|
|
1562
1551
|
_context9.prev = 0;
|
|
@@ -1607,7 +1596,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1607
1596
|
}, {
|
|
1608
1597
|
key: "getTableData",
|
|
1609
1598
|
value: (function () {
|
|
1610
|
-
var _getTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(tableName) {
|
|
1599
|
+
var _getTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee0(tableName) {
|
|
1611
1600
|
var _this = this;
|
|
1612
1601
|
var page,
|
|
1613
1602
|
limit,
|
|
@@ -1620,7 +1609,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1620
1609
|
count,
|
|
1621
1610
|
_args0 = arguments,
|
|
1622
1611
|
_t9;
|
|
1623
|
-
return _regeneratorRuntime.wrap(function (_context0) {
|
|
1612
|
+
return _regeneratorRuntime$1.wrap(function (_context0) {
|
|
1624
1613
|
while (1) switch (_context0.prev = _context0.next) {
|
|
1625
1614
|
case 0:
|
|
1626
1615
|
page = _args0.length > 1 && _args0[1] !== undefined ? _args0[1] : 1;
|
|
@@ -1679,7 +1668,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1679
1668
|
}, {
|
|
1680
1669
|
key: "getTableDataWithSearch",
|
|
1681
1670
|
value: (function () {
|
|
1682
|
-
var _getTableDataWithSearch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(tableName) {
|
|
1671
|
+
var _getTableDataWithSearch = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee1(tableName) {
|
|
1683
1672
|
var _this2 = this;
|
|
1684
1673
|
var page,
|
|
1685
1674
|
limit,
|
|
@@ -1693,7 +1682,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1693
1682
|
count,
|
|
1694
1683
|
_args1 = arguments,
|
|
1695
1684
|
_t0;
|
|
1696
|
-
return _regeneratorRuntime.wrap(function (_context1) {
|
|
1685
|
+
return _regeneratorRuntime$1.wrap(function (_context1) {
|
|
1697
1686
|
while (1) switch (_context1.prev = _context1.next) {
|
|
1698
1687
|
case 0:
|
|
1699
1688
|
page = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 1;
|
|
@@ -1755,7 +1744,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1755
1744
|
}, {
|
|
1756
1745
|
key: "insertData",
|
|
1757
1746
|
value: (function () {
|
|
1758
|
-
var _insertData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(tableName, data) {
|
|
1747
|
+
var _insertData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee10(tableName, data) {
|
|
1759
1748
|
var autoFixForeignKey,
|
|
1760
1749
|
_yield$this$supabase$9,
|
|
1761
1750
|
result,
|
|
@@ -1767,7 +1756,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1767
1756
|
_dropResult,
|
|
1768
1757
|
_args10 = arguments,
|
|
1769
1758
|
_t1;
|
|
1770
|
-
return _regeneratorRuntime.wrap(function (_context10) {
|
|
1759
|
+
return _regeneratorRuntime$1.wrap(function (_context10) {
|
|
1771
1760
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1772
1761
|
case 0:
|
|
1773
1762
|
autoFixForeignKey = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : true;
|
|
@@ -1857,7 +1846,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1857
1846
|
}, {
|
|
1858
1847
|
key: "updateData",
|
|
1859
1848
|
value: (function () {
|
|
1860
|
-
var _updateData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(tableName, id, data) {
|
|
1849
|
+
var _updateData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee11(tableName, id, data) {
|
|
1861
1850
|
var autoFixForeignKey,
|
|
1862
1851
|
_yield$this$supabase$0,
|
|
1863
1852
|
result,
|
|
@@ -1869,7 +1858,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1869
1858
|
_dropResult2,
|
|
1870
1859
|
_args11 = arguments,
|
|
1871
1860
|
_t10;
|
|
1872
|
-
return _regeneratorRuntime.wrap(function (_context11) {
|
|
1861
|
+
return _regeneratorRuntime$1.wrap(function (_context11) {
|
|
1873
1862
|
while (1) switch (_context11.prev = _context11.next) {
|
|
1874
1863
|
case 0:
|
|
1875
1864
|
autoFixForeignKey = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : true;
|
|
@@ -1957,9 +1946,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
1957
1946
|
}, {
|
|
1958
1947
|
key: "deleteData",
|
|
1959
1948
|
value: (function () {
|
|
1960
|
-
var _deleteData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(tableName, id) {
|
|
1949
|
+
var _deleteData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee12(tableName, id) {
|
|
1961
1950
|
var _yield$this$supabase$1, result, error, _t11;
|
|
1962
|
-
return _regeneratorRuntime.wrap(function (_context12) {
|
|
1951
|
+
return _regeneratorRuntime$1.wrap(function (_context12) {
|
|
1963
1952
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1964
1953
|
case 0:
|
|
1965
1954
|
_context12.prev = 0;
|
|
@@ -2000,9 +1989,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2000
1989
|
}, {
|
|
2001
1990
|
key: "getDataById",
|
|
2002
1991
|
value: (function () {
|
|
2003
|
-
var _getDataById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(tableName, id) {
|
|
1992
|
+
var _getDataById = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee13(tableName, id) {
|
|
2004
1993
|
var _yield$this$supabase$10, data, error, _t12;
|
|
2005
|
-
return _regeneratorRuntime.wrap(function (_context13) {
|
|
1994
|
+
return _regeneratorRuntime$1.wrap(function (_context13) {
|
|
2006
1995
|
while (1) switch (_context13.prev = _context13.next) {
|
|
2007
1996
|
case 0:
|
|
2008
1997
|
_context13.prev = 0;
|
|
@@ -2050,9 +2039,9 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2050
2039
|
}, {
|
|
2051
2040
|
key: "getRelationOptions",
|
|
2052
2041
|
value: (function () {
|
|
2053
|
-
var _getRelationOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(params) {
|
|
2042
|
+
var _getRelationOptions = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee14(params) {
|
|
2054
2043
|
var tableName, _params$displayField, displayField, _params$limit, limit, search, query, _yield$query, data, error, _t13;
|
|
2055
|
-
return _regeneratorRuntime.wrap(function (_context14) {
|
|
2044
|
+
return _regeneratorRuntime$1.wrap(function (_context14) {
|
|
2056
2045
|
while (1) switch (_context14.prev = _context14.next) {
|
|
2057
2046
|
case 0:
|
|
2058
2047
|
_context14.prev = 0;
|
|
@@ -2074,7 +2063,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2074
2063
|
throw error;
|
|
2075
2064
|
case 2:
|
|
2076
2065
|
return _context14.abrupt("return", (data || []).map(function (item) {
|
|
2077
|
-
return _objectSpread$
|
|
2066
|
+
return _objectSpread$4({
|
|
2078
2067
|
id: item.id,
|
|
2079
2068
|
label: item[displayField] || "ID: ".concat(item.id)
|
|
2080
2069
|
}, item);
|
|
@@ -2107,7 +2096,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2107
2096
|
}, {
|
|
2108
2097
|
key: "getTableDataWithRelations",
|
|
2109
2098
|
value: (function () {
|
|
2110
|
-
var _getTableDataWithRelations = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(tableName, schema) {
|
|
2099
|
+
var _getTableDataWithRelations = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee15(tableName, schema) {
|
|
2111
2100
|
var _this3 = this;
|
|
2112
2101
|
var page,
|
|
2113
2102
|
limit,
|
|
@@ -2121,7 +2110,7 @@ var DynamicTableService = /*#__PURE__*/function () {
|
|
|
2121
2110
|
count,
|
|
2122
2111
|
_args15 = arguments,
|
|
2123
2112
|
_t14;
|
|
2124
|
-
return _regeneratorRuntime.wrap(function (_context15) {
|
|
2113
|
+
return _regeneratorRuntime$1.wrap(function (_context15) {
|
|
2125
2114
|
while (1) switch (_context15.prev = _context15.next) {
|
|
2126
2115
|
case 0:
|
|
2127
2116
|
page = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : 1;
|
|
@@ -2187,28 +2176,28 @@ function getDynamicTableService() {
|
|
|
2187
2176
|
return defaultService$1;
|
|
2188
2177
|
}
|
|
2189
2178
|
|
|
2190
|
-
function ownKeys$
|
|
2191
|
-
function _objectSpread$
|
|
2179
|
+
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; }
|
|
2180
|
+
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; }
|
|
2192
2181
|
var AuthService = /*#__PURE__*/function () {
|
|
2193
2182
|
function AuthService() {
|
|
2194
|
-
_classCallCheck(this, AuthService);
|
|
2183
|
+
_classCallCheck$1(this, AuthService);
|
|
2195
2184
|
this.supabase = getSupabase();
|
|
2196
2185
|
this.defaultTableName = 'cms_users';
|
|
2197
2186
|
}
|
|
2198
2187
|
/**
|
|
2199
2188
|
* 根据用户名查询用户
|
|
2200
2189
|
*/
|
|
2201
|
-
return _createClass(AuthService, [{
|
|
2190
|
+
return _createClass$1(AuthService, [{
|
|
2202
2191
|
key: "findUserByUsername",
|
|
2203
2192
|
value: (function () {
|
|
2204
|
-
var _findUserByUsername = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(username) {
|
|
2193
|
+
var _findUserByUsername = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(username) {
|
|
2205
2194
|
var tableName,
|
|
2206
2195
|
_yield$this$supabase$,
|
|
2207
2196
|
users,
|
|
2208
2197
|
error,
|
|
2209
2198
|
_args = arguments,
|
|
2210
2199
|
_t;
|
|
2211
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
2200
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
2212
2201
|
while (1) switch (_context.prev = _context.next) {
|
|
2213
2202
|
case 0:
|
|
2214
2203
|
tableName = _args.length > 1 && _args[1] !== undefined ? _args[1] : this.defaultTableName;
|
|
@@ -2256,14 +2245,14 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2256
2245
|
}, {
|
|
2257
2246
|
key: "findUserById",
|
|
2258
2247
|
value: (function () {
|
|
2259
|
-
var _findUserById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(userId) {
|
|
2248
|
+
var _findUserById = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(userId) {
|
|
2260
2249
|
var tableName,
|
|
2261
2250
|
_yield$this$supabase$2,
|
|
2262
2251
|
users,
|
|
2263
2252
|
error,
|
|
2264
2253
|
_args2 = arguments,
|
|
2265
2254
|
_t2;
|
|
2266
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
2255
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
2267
2256
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2268
2257
|
case 0:
|
|
2269
2258
|
tableName = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : this.defaultTableName;
|
|
@@ -2311,14 +2300,14 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2311
2300
|
}, {
|
|
2312
2301
|
key: "checkUsernameExists",
|
|
2313
2302
|
value: (function () {
|
|
2314
|
-
var _checkUsernameExists = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(username) {
|
|
2303
|
+
var _checkUsernameExists = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(username) {
|
|
2315
2304
|
var tableName,
|
|
2316
2305
|
_yield$this$supabase$3,
|
|
2317
2306
|
users,
|
|
2318
2307
|
error,
|
|
2319
2308
|
_args3 = arguments,
|
|
2320
2309
|
_t3;
|
|
2321
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
2310
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
2322
2311
|
while (1) switch (_context3.prev = _context3.next) {
|
|
2323
2312
|
case 0:
|
|
2324
2313
|
tableName = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : this.defaultTableName;
|
|
@@ -2360,12 +2349,12 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2360
2349
|
}, {
|
|
2361
2350
|
key: "createUser",
|
|
2362
2351
|
value: (function () {
|
|
2363
|
-
var _createUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(userData) {
|
|
2352
|
+
var _createUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(userData) {
|
|
2364
2353
|
var finalUserData, _yield$this$supabase$4, result, error, _t4;
|
|
2365
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
2354
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
2366
2355
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2367
2356
|
case 0:
|
|
2368
|
-
finalUserData = _objectSpread$
|
|
2357
|
+
finalUserData = _objectSpread$3({
|
|
2369
2358
|
tableName: this.defaultTableName
|
|
2370
2359
|
}, userData);
|
|
2371
2360
|
_context4.prev = 1;
|
|
@@ -2410,7 +2399,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2410
2399
|
}, {
|
|
2411
2400
|
key: "updateUser",
|
|
2412
2401
|
value: (function () {
|
|
2413
|
-
var _updateUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(userId) {
|
|
2402
|
+
var _updateUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(userId) {
|
|
2414
2403
|
var updateData,
|
|
2415
2404
|
finalUpdateData,
|
|
2416
2405
|
_yield$this$supabase$5,
|
|
@@ -2418,12 +2407,12 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2418
2407
|
error,
|
|
2419
2408
|
_args5 = arguments,
|
|
2420
2409
|
_t5;
|
|
2421
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
2410
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
2422
2411
|
while (1) switch (_context5.prev = _context5.next) {
|
|
2423
2412
|
case 0:
|
|
2424
2413
|
updateData = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
2425
2414
|
// 设置默认值
|
|
2426
|
-
finalUpdateData = _objectSpread$
|
|
2415
|
+
finalUpdateData = _objectSpread$3({
|
|
2427
2416
|
tableName: this.defaultTableName
|
|
2428
2417
|
}, updateData);
|
|
2429
2418
|
_context5.prev = 1;
|
|
@@ -2464,13 +2453,13 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2464
2453
|
}, {
|
|
2465
2454
|
key: "deleteUser",
|
|
2466
2455
|
value: (function () {
|
|
2467
|
-
var _deleteUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(userId) {
|
|
2456
|
+
var _deleteUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(userId) {
|
|
2468
2457
|
var tableName,
|
|
2469
2458
|
_yield$this$supabase$6,
|
|
2470
2459
|
error,
|
|
2471
2460
|
_args6 = arguments,
|
|
2472
2461
|
_t6;
|
|
2473
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
2462
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
2474
2463
|
while (1) switch (_context6.prev = _context6.next) {
|
|
2475
2464
|
case 0:
|
|
2476
2465
|
tableName = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : this.defaultTableName;
|
|
@@ -2511,7 +2500,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2511
2500
|
}, {
|
|
2512
2501
|
key: "getUserList",
|
|
2513
2502
|
value: (function () {
|
|
2514
|
-
var _getUserList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
2503
|
+
var _getUserList = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7() {
|
|
2515
2504
|
var page,
|
|
2516
2505
|
limit,
|
|
2517
2506
|
tableName,
|
|
@@ -2522,7 +2511,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2522
2511
|
count,
|
|
2523
2512
|
_args7 = arguments,
|
|
2524
2513
|
_t7;
|
|
2525
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
2514
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
2526
2515
|
while (1) switch (_context7.prev = _context7.next) {
|
|
2527
2516
|
case 0:
|
|
2528
2517
|
page = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : 1;
|
|
@@ -2578,7 +2567,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2578
2567
|
}, {
|
|
2579
2568
|
key: "searchUsers",
|
|
2580
2569
|
value: (function () {
|
|
2581
|
-
var _searchUsers = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(searchValue) {
|
|
2570
|
+
var _searchUsers = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee8(searchValue) {
|
|
2582
2571
|
var page,
|
|
2583
2572
|
limit,
|
|
2584
2573
|
tableName,
|
|
@@ -2589,7 +2578,7 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2589
2578
|
count,
|
|
2590
2579
|
_args8 = arguments,
|
|
2591
2580
|
_t8;
|
|
2592
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
2581
|
+
return _regeneratorRuntime$1.wrap(function (_context8) {
|
|
2593
2582
|
while (1) switch (_context8.prev = _context8.next) {
|
|
2594
2583
|
case 0:
|
|
2595
2584
|
page = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : 1;
|
|
@@ -2645,13 +2634,13 @@ var AuthService = /*#__PURE__*/function () {
|
|
|
2645
2634
|
}, {
|
|
2646
2635
|
key: "updateLastLogin",
|
|
2647
2636
|
value: (function () {
|
|
2648
|
-
var _updateLastLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(userId) {
|
|
2637
|
+
var _updateLastLogin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee9(userId) {
|
|
2649
2638
|
var tableName,
|
|
2650
2639
|
_yield$this$supabase$9,
|
|
2651
2640
|
error,
|
|
2652
2641
|
_args9 = arguments,
|
|
2653
2642
|
_t9;
|
|
2654
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
2643
|
+
return _regeneratorRuntime$1.wrap(function (_context9) {
|
|
2655
2644
|
while (1) switch (_context9.prev = _context9.next) {
|
|
2656
2645
|
case 0:
|
|
2657
2646
|
tableName = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : this.defaultTableName;
|
|
@@ -2717,13 +2706,204 @@ function _objectWithoutProperties(e, t) {
|
|
|
2717
2706
|
return i;
|
|
2718
2707
|
}
|
|
2719
2708
|
|
|
2709
|
+
function _assertThisInitialized$1(e) {
|
|
2710
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2711
|
+
return e;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
function _possibleConstructorReturn$1(t, e) {
|
|
2715
|
+
if (e && ("object" == _typeof$3(e) || "function" == typeof e)) return e;
|
|
2716
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2717
|
+
return _assertThisInitialized$1(t);
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
function _getPrototypeOf$1(t) {
|
|
2721
|
+
return _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
2722
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
2723
|
+
}, _getPrototypeOf$1(t);
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
function _setPrototypeOf$1(t, e) {
|
|
2727
|
+
return _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
2728
|
+
return t.__proto__ = e, t;
|
|
2729
|
+
}, _setPrototypeOf$1(t, e);
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
function _inherits$1(t, e) {
|
|
2733
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
2734
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
2735
|
+
constructor: {
|
|
2736
|
+
value: t,
|
|
2737
|
+
writable: !0,
|
|
2738
|
+
configurable: !0
|
|
2739
|
+
}
|
|
2740
|
+
}), Object.defineProperty(t, "prototype", {
|
|
2741
|
+
writable: !1
|
|
2742
|
+
}), e && _setPrototypeOf$1(t, e);
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
function _isNativeFunction$1(t) {
|
|
2746
|
+
try {
|
|
2747
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
2748
|
+
} catch (n) {
|
|
2749
|
+
return "function" == typeof t;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
function _isNativeReflectConstruct$3() {
|
|
2754
|
+
try {
|
|
2755
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2756
|
+
} catch (t) {}
|
|
2757
|
+
return (_isNativeReflectConstruct$3 = function _isNativeReflectConstruct() {
|
|
2758
|
+
return !!t;
|
|
2759
|
+
})();
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
function _construct$1(t, e, r) {
|
|
2763
|
+
if (_isNativeReflectConstruct$3()) return Reflect.construct.apply(null, arguments);
|
|
2764
|
+
var o = [null];
|
|
2765
|
+
o.push.apply(o, e);
|
|
2766
|
+
var p = new (t.bind.apply(t, o))();
|
|
2767
|
+
return r && _setPrototypeOf$1(p, r.prototype), p;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
function _wrapNativeSuper$1(t) {
|
|
2771
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
2772
|
+
return _wrapNativeSuper$1 = function _wrapNativeSuper(t) {
|
|
2773
|
+
if (null === t || !_isNativeFunction$1(t)) return t;
|
|
2774
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
2775
|
+
if (void 0 !== r) {
|
|
2776
|
+
if (r.has(t)) return r.get(t);
|
|
2777
|
+
r.set(t, Wrapper);
|
|
2778
|
+
}
|
|
2779
|
+
function Wrapper() {
|
|
2780
|
+
return _construct$1(t, arguments, _getPrototypeOf$1(this).constructor);
|
|
2781
|
+
}
|
|
2782
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
2783
|
+
constructor: {
|
|
2784
|
+
value: Wrapper,
|
|
2785
|
+
enumerable: !1,
|
|
2786
|
+
writable: !0,
|
|
2787
|
+
configurable: !0
|
|
2788
|
+
}
|
|
2789
|
+
}), _setPrototypeOf$1(Wrapper, t);
|
|
2790
|
+
}, _wrapNativeSuper$1(t);
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
function _typeof$1(o) {
|
|
2794
|
+
"@babel/helpers - typeof";
|
|
2795
|
+
|
|
2796
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
2797
|
+
return typeof o;
|
|
2798
|
+
} : function (o) {
|
|
2799
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
2800
|
+
}, _typeof$1(o);
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
function toPrimitive(t, r) {
|
|
2804
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
2805
|
+
var e = t[Symbol.toPrimitive];
|
|
2806
|
+
if (void 0 !== e) {
|
|
2807
|
+
var i = e.call(t, r || "default");
|
|
2808
|
+
if ("object" != _typeof$1(i)) return i;
|
|
2809
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2810
|
+
}
|
|
2811
|
+
return ("string" === r ? String : Number)(t);
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
function toPropertyKey(t) {
|
|
2815
|
+
var i = toPrimitive(t, "string");
|
|
2816
|
+
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
function _defineProperty(e, r, t) {
|
|
2820
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2821
|
+
value: t,
|
|
2822
|
+
enumerable: !0,
|
|
2823
|
+
configurable: !0,
|
|
2824
|
+
writable: !0
|
|
2825
|
+
}) : e[r] = t, e;
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
2829
|
+
try {
|
|
2830
|
+
var i = n[a](c),
|
|
2831
|
+
u = i.value;
|
|
2832
|
+
} catch (n) {
|
|
2833
|
+
return void e(n);
|
|
2834
|
+
}
|
|
2835
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
2836
|
+
}
|
|
2837
|
+
function _asyncToGenerator(n) {
|
|
2838
|
+
return function () {
|
|
2839
|
+
var t = this,
|
|
2840
|
+
e = arguments;
|
|
2841
|
+
return new Promise(function (r, o) {
|
|
2842
|
+
var a = n.apply(t, e);
|
|
2843
|
+
function _next(n) {
|
|
2844
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
2845
|
+
}
|
|
2846
|
+
function _throw(n) {
|
|
2847
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
2848
|
+
}
|
|
2849
|
+
_next(void 0);
|
|
2850
|
+
});
|
|
2851
|
+
};
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
function _arrayLikeToArray$3(r, a) {
|
|
2855
|
+
(null == a || a > r.length) && (a = r.length);
|
|
2856
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
2857
|
+
return n;
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
function _arrayWithoutHoles(r) {
|
|
2861
|
+
if (Array.isArray(r)) return _arrayLikeToArray$3(r);
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
function _iterableToArray(r) {
|
|
2865
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
function _unsupportedIterableToArray$3(r, a) {
|
|
2869
|
+
if (r) {
|
|
2870
|
+
if ("string" == typeof r) return _arrayLikeToArray$3(r, a);
|
|
2871
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
2872
|
+
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;
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
function _nonIterableSpread() {
|
|
2877
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
function _toConsumableArray(r) {
|
|
2881
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$3(r) || _nonIterableSpread();
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
function _defineProperties(e, r) {
|
|
2885
|
+
for (var t = 0; t < r.length; t++) {
|
|
2886
|
+
var o = r[t];
|
|
2887
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
function _createClass(e, r, t) {
|
|
2891
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
2892
|
+
writable: !1
|
|
2893
|
+
}), e;
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
function _classCallCheck(a, n) {
|
|
2897
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2720
2900
|
function _assertThisInitialized(e) {
|
|
2721
2901
|
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2722
2902
|
return e;
|
|
2723
2903
|
}
|
|
2724
2904
|
|
|
2725
2905
|
function _possibleConstructorReturn(t, e) {
|
|
2726
|
-
if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
|
|
2906
|
+
if (e && ("object" == _typeof$1(e) || "function" == typeof e)) return e;
|
|
2727
2907
|
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2728
2908
|
return _assertThisInitialized(t);
|
|
2729
2909
|
}
|
|
@@ -2761,17 +2941,17 @@ function _isNativeFunction(t) {
|
|
|
2761
2941
|
}
|
|
2762
2942
|
}
|
|
2763
2943
|
|
|
2764
|
-
function _isNativeReflectConstruct$
|
|
2944
|
+
function _isNativeReflectConstruct$2() {
|
|
2765
2945
|
try {
|
|
2766
2946
|
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
2767
2947
|
} catch (t) {}
|
|
2768
|
-
return (_isNativeReflectConstruct$
|
|
2948
|
+
return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() {
|
|
2769
2949
|
return !!t;
|
|
2770
2950
|
})();
|
|
2771
2951
|
}
|
|
2772
2952
|
|
|
2773
2953
|
function _construct(t, e, r) {
|
|
2774
|
-
if (_isNativeReflectConstruct$
|
|
2954
|
+
if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments);
|
|
2775
2955
|
var o = [null];
|
|
2776
2956
|
o.push.apply(o, e);
|
|
2777
2957
|
var p = new (t.bind.apply(t, o))();
|
|
@@ -2801,6 +2981,364 @@ function _wrapNativeSuper(t) {
|
|
|
2801
2981
|
}, _wrapNativeSuper(t);
|
|
2802
2982
|
}
|
|
2803
2983
|
|
|
2984
|
+
var regeneratorRuntime$1 = {exports: {}};
|
|
2985
|
+
|
|
2986
|
+
var OverloadYield = {exports: {}};
|
|
2987
|
+
|
|
2988
|
+
(function (module) {
|
|
2989
|
+
function _OverloadYield(e, d) {
|
|
2990
|
+
this.v = e, this.k = d;
|
|
2991
|
+
}
|
|
2992
|
+
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
2993
|
+
})(OverloadYield);
|
|
2994
|
+
var OverloadYieldExports = OverloadYield.exports;
|
|
2995
|
+
|
|
2996
|
+
var regenerator$1 = {exports: {}};
|
|
2997
|
+
|
|
2998
|
+
var regeneratorDefine = {exports: {}};
|
|
2999
|
+
|
|
3000
|
+
(function (module) {
|
|
3001
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
3002
|
+
var i = Object.defineProperty;
|
|
3003
|
+
try {
|
|
3004
|
+
i({}, "", {});
|
|
3005
|
+
} catch (e) {
|
|
3006
|
+
i = 0;
|
|
3007
|
+
}
|
|
3008
|
+
module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
|
|
3009
|
+
function o(r, n) {
|
|
3010
|
+
_regeneratorDefine(e, r, function (e) {
|
|
3011
|
+
return this._invoke(r, n, e);
|
|
3012
|
+
});
|
|
3013
|
+
}
|
|
3014
|
+
r ? i ? i(e, r, {
|
|
3015
|
+
value: n,
|
|
3016
|
+
enumerable: !t,
|
|
3017
|
+
configurable: !t,
|
|
3018
|
+
writable: !t
|
|
3019
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
3020
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
|
|
3021
|
+
}
|
|
3022
|
+
module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3023
|
+
})(regeneratorDefine);
|
|
3024
|
+
var regeneratorDefineExports = regeneratorDefine.exports;
|
|
3025
|
+
|
|
3026
|
+
(function (module) {
|
|
3027
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
3028
|
+
function _regenerator() {
|
|
3029
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3030
|
+
var e,
|
|
3031
|
+
t,
|
|
3032
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
3033
|
+
n = r.iterator || "@@iterator",
|
|
3034
|
+
o = r.toStringTag || "@@toStringTag";
|
|
3035
|
+
function i(r, n, o, i) {
|
|
3036
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
3037
|
+
u = Object.create(c.prototype);
|
|
3038
|
+
return regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
3039
|
+
var i,
|
|
3040
|
+
c,
|
|
3041
|
+
u,
|
|
3042
|
+
f = 0,
|
|
3043
|
+
p = o || [],
|
|
3044
|
+
y = !1,
|
|
3045
|
+
G = {
|
|
3046
|
+
p: 0,
|
|
3047
|
+
n: 0,
|
|
3048
|
+
v: e,
|
|
3049
|
+
a: d,
|
|
3050
|
+
f: d.bind(e, 4),
|
|
3051
|
+
d: function d(t, r) {
|
|
3052
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
3053
|
+
}
|
|
3054
|
+
};
|
|
3055
|
+
function d(r, n) {
|
|
3056
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
3057
|
+
var o,
|
|
3058
|
+
i = p[t],
|
|
3059
|
+
d = G.p,
|
|
3060
|
+
l = i[2];
|
|
3061
|
+
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));
|
|
3062
|
+
}
|
|
3063
|
+
if (o || r > 1) return a;
|
|
3064
|
+
throw y = !0, n;
|
|
3065
|
+
}
|
|
3066
|
+
return function (o, p, l) {
|
|
3067
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
3068
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
3069
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
3070
|
+
try {
|
|
3071
|
+
if (f = 2, i) {
|
|
3072
|
+
if (c || (o = "next"), t = i[o]) {
|
|
3073
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
3074
|
+
if (!t.done) return t;
|
|
3075
|
+
u = t.value, c < 2 && (c = 0);
|
|
3076
|
+
} else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
3077
|
+
i = e;
|
|
3078
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
3079
|
+
} catch (t) {
|
|
3080
|
+
i = e, c = 1, u = t;
|
|
3081
|
+
} finally {
|
|
3082
|
+
f = 1;
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
return {
|
|
3086
|
+
value: t,
|
|
3087
|
+
done: y
|
|
3088
|
+
};
|
|
3089
|
+
};
|
|
3090
|
+
}(r, o, i), !0), u;
|
|
3091
|
+
}
|
|
3092
|
+
var a = {};
|
|
3093
|
+
function Generator() {}
|
|
3094
|
+
function GeneratorFunction() {}
|
|
3095
|
+
function GeneratorFunctionPrototype() {}
|
|
3096
|
+
t = Object.getPrototypeOf;
|
|
3097
|
+
var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
|
|
3098
|
+
return this;
|
|
3099
|
+
}), t),
|
|
3100
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
3101
|
+
function f(e) {
|
|
3102
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
3103
|
+
}
|
|
3104
|
+
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 () {
|
|
3105
|
+
return this;
|
|
3106
|
+
}), regeneratorDefine(u, "toString", function () {
|
|
3107
|
+
return "[object Generator]";
|
|
3108
|
+
}), (module.exports = _regenerator = function _regenerator() {
|
|
3109
|
+
return {
|
|
3110
|
+
w: i,
|
|
3111
|
+
m: f
|
|
3112
|
+
};
|
|
3113
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
3114
|
+
}
|
|
3115
|
+
module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3116
|
+
})(regenerator$1);
|
|
3117
|
+
var regeneratorExports = regenerator$1.exports;
|
|
3118
|
+
|
|
3119
|
+
var regeneratorAsync = {exports: {}};
|
|
3120
|
+
|
|
3121
|
+
var regeneratorAsyncGen = {exports: {}};
|
|
3122
|
+
|
|
3123
|
+
var regeneratorAsyncIterator = {exports: {}};
|
|
3124
|
+
|
|
3125
|
+
(function (module) {
|
|
3126
|
+
var OverloadYield = OverloadYieldExports;
|
|
3127
|
+
var regeneratorDefine = regeneratorDefineExports;
|
|
3128
|
+
function AsyncIterator(t, e) {
|
|
3129
|
+
function n(r, o, i, f) {
|
|
3130
|
+
try {
|
|
3131
|
+
var c = t[r](o),
|
|
3132
|
+
u = c.value;
|
|
3133
|
+
return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
|
|
3134
|
+
n("next", t, i, f);
|
|
3135
|
+
}, function (t) {
|
|
3136
|
+
n("throw", t, i, f);
|
|
3137
|
+
}) : e.resolve(u).then(function (t) {
|
|
3138
|
+
c.value = t, i(c);
|
|
3139
|
+
}, function (t) {
|
|
3140
|
+
return n("throw", t, i, f);
|
|
3141
|
+
});
|
|
3142
|
+
} catch (t) {
|
|
3143
|
+
f(t);
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
var r;
|
|
3147
|
+
this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
|
|
3148
|
+
return this;
|
|
3149
|
+
})), regeneratorDefine(this, "_invoke", function (t, o, i) {
|
|
3150
|
+
function f() {
|
|
3151
|
+
return new e(function (e, r) {
|
|
3152
|
+
n(t, i, e, r);
|
|
3153
|
+
});
|
|
3154
|
+
}
|
|
3155
|
+
return r = r ? r.then(f, f) : f();
|
|
3156
|
+
}, !0);
|
|
3157
|
+
}
|
|
3158
|
+
module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3159
|
+
})(regeneratorAsyncIterator);
|
|
3160
|
+
var regeneratorAsyncIteratorExports = regeneratorAsyncIterator.exports;
|
|
3161
|
+
|
|
3162
|
+
(function (module) {
|
|
3163
|
+
var regenerator = regeneratorExports;
|
|
3164
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
3165
|
+
function _regeneratorAsyncGen(r, e, t, o, n) {
|
|
3166
|
+
return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
|
|
3167
|
+
}
|
|
3168
|
+
module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3169
|
+
})(regeneratorAsyncGen);
|
|
3170
|
+
var regeneratorAsyncGenExports = regeneratorAsyncGen.exports;
|
|
3171
|
+
|
|
3172
|
+
(function (module) {
|
|
3173
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
3174
|
+
function _regeneratorAsync(n, e, r, t, o) {
|
|
3175
|
+
var a = regeneratorAsyncGen(n, e, r, t, o);
|
|
3176
|
+
return a.next().then(function (n) {
|
|
3177
|
+
return n.done ? n.value : a.next();
|
|
3178
|
+
});
|
|
3179
|
+
}
|
|
3180
|
+
module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3181
|
+
})(regeneratorAsync);
|
|
3182
|
+
var regeneratorAsyncExports = regeneratorAsync.exports;
|
|
3183
|
+
|
|
3184
|
+
var regeneratorKeys = {exports: {}};
|
|
3185
|
+
|
|
3186
|
+
(function (module) {
|
|
3187
|
+
function _regeneratorKeys(e) {
|
|
3188
|
+
var n = Object(e),
|
|
3189
|
+
r = [];
|
|
3190
|
+
for (var t in n) r.unshift(t);
|
|
3191
|
+
return function e() {
|
|
3192
|
+
for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
|
|
3193
|
+
return e.done = !0, e;
|
|
3194
|
+
};
|
|
3195
|
+
}
|
|
3196
|
+
module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3197
|
+
})(regeneratorKeys);
|
|
3198
|
+
var regeneratorKeysExports = regeneratorKeys.exports;
|
|
3199
|
+
|
|
3200
|
+
var regeneratorValues = {exports: {}};
|
|
3201
|
+
|
|
3202
|
+
var _typeof = {exports: {}};
|
|
3203
|
+
|
|
3204
|
+
(function (module) {
|
|
3205
|
+
function _typeof(o) {
|
|
3206
|
+
"@babel/helpers - typeof";
|
|
3207
|
+
|
|
3208
|
+
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
3209
|
+
return typeof o;
|
|
3210
|
+
} : function (o) {
|
|
3211
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3212
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
|
|
3213
|
+
}
|
|
3214
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3215
|
+
})(_typeof);
|
|
3216
|
+
var _typeofExports = _typeof.exports;
|
|
3217
|
+
|
|
3218
|
+
(function (module) {
|
|
3219
|
+
var _typeof = _typeofExports["default"];
|
|
3220
|
+
function _regeneratorValues(e) {
|
|
3221
|
+
if (null != e) {
|
|
3222
|
+
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
3223
|
+
r = 0;
|
|
3224
|
+
if (t) return t.call(e);
|
|
3225
|
+
if ("function" == typeof e.next) return e;
|
|
3226
|
+
if (!isNaN(e.length)) return {
|
|
3227
|
+
next: function next() {
|
|
3228
|
+
return e && r >= e.length && (e = void 0), {
|
|
3229
|
+
value: e && e[r++],
|
|
3230
|
+
done: !e
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
3236
|
+
}
|
|
3237
|
+
module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3238
|
+
})(regeneratorValues);
|
|
3239
|
+
var regeneratorValuesExports = regeneratorValues.exports;
|
|
3240
|
+
|
|
3241
|
+
(function (module) {
|
|
3242
|
+
var OverloadYield = OverloadYieldExports;
|
|
3243
|
+
var regenerator = regeneratorExports;
|
|
3244
|
+
var regeneratorAsync = regeneratorAsyncExports;
|
|
3245
|
+
var regeneratorAsyncGen = regeneratorAsyncGenExports;
|
|
3246
|
+
var regeneratorAsyncIterator = regeneratorAsyncIteratorExports;
|
|
3247
|
+
var regeneratorKeys = regeneratorKeysExports;
|
|
3248
|
+
var regeneratorValues = regeneratorValuesExports;
|
|
3249
|
+
function _regeneratorRuntime() {
|
|
3250
|
+
|
|
3251
|
+
var r = regenerator(),
|
|
3252
|
+
e = r.m(_regeneratorRuntime),
|
|
3253
|
+
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
|
|
3254
|
+
function n(r) {
|
|
3255
|
+
var e = "function" == typeof r && r.constructor;
|
|
3256
|
+
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
|
|
3257
|
+
}
|
|
3258
|
+
var o = {
|
|
3259
|
+
"throw": 1,
|
|
3260
|
+
"return": 2,
|
|
3261
|
+
"break": 3,
|
|
3262
|
+
"continue": 3
|
|
3263
|
+
};
|
|
3264
|
+
function a(r) {
|
|
3265
|
+
var e, t;
|
|
3266
|
+
return function (n) {
|
|
3267
|
+
e || (e = {
|
|
3268
|
+
stop: function stop() {
|
|
3269
|
+
return t(n.a, 2);
|
|
3270
|
+
},
|
|
3271
|
+
"catch": function _catch() {
|
|
3272
|
+
return n.v;
|
|
3273
|
+
},
|
|
3274
|
+
abrupt: function abrupt(r, e) {
|
|
3275
|
+
return t(n.a, o[r], e);
|
|
3276
|
+
},
|
|
3277
|
+
delegateYield: function delegateYield(r, o, a) {
|
|
3278
|
+
return e.resultName = o, t(n.d, regeneratorValues(r), a);
|
|
3279
|
+
},
|
|
3280
|
+
finish: function finish(r) {
|
|
3281
|
+
return t(n.f, r);
|
|
3282
|
+
}
|
|
3283
|
+
}, t = function t(r, _t, o) {
|
|
3284
|
+
n.p = e.prev, n.n = e.next;
|
|
3285
|
+
try {
|
|
3286
|
+
return r(_t, o);
|
|
3287
|
+
} finally {
|
|
3288
|
+
e.next = n.n;
|
|
3289
|
+
}
|
|
3290
|
+
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
|
|
3291
|
+
try {
|
|
3292
|
+
return r.call(this, e);
|
|
3293
|
+
} finally {
|
|
3294
|
+
n.p = e.prev, n.n = e.next;
|
|
3295
|
+
}
|
|
3296
|
+
};
|
|
3297
|
+
}
|
|
3298
|
+
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
3299
|
+
return {
|
|
3300
|
+
wrap: function wrap(e, t, n, o) {
|
|
3301
|
+
return r.w(a(e), t, n, o && o.reverse());
|
|
3302
|
+
},
|
|
3303
|
+
isGeneratorFunction: n,
|
|
3304
|
+
mark: r.m,
|
|
3305
|
+
awrap: function awrap(r, e) {
|
|
3306
|
+
return new OverloadYield(r, e);
|
|
3307
|
+
},
|
|
3308
|
+
AsyncIterator: regeneratorAsyncIterator,
|
|
3309
|
+
async: function async(r, e, t, o, u) {
|
|
3310
|
+
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
|
|
3311
|
+
},
|
|
3312
|
+
keys: regeneratorKeys,
|
|
3313
|
+
values: regeneratorValues
|
|
3314
|
+
};
|
|
3315
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
|
|
3316
|
+
}
|
|
3317
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3318
|
+
})(regeneratorRuntime$1);
|
|
3319
|
+
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
3320
|
+
|
|
3321
|
+
// TODO(Babel 8): Remove this file.
|
|
3322
|
+
|
|
3323
|
+
var runtime = regeneratorRuntimeExports();
|
|
3324
|
+
var regenerator = runtime;
|
|
3325
|
+
|
|
3326
|
+
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
3327
|
+
try {
|
|
3328
|
+
regeneratorRuntime = runtime;
|
|
3329
|
+
} catch (accidentalStrictMode) {
|
|
3330
|
+
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$1(globalThis)) === "object") {
|
|
3331
|
+
globalThis.regeneratorRuntime = runtime;
|
|
3332
|
+
} else {
|
|
3333
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
3337
|
+
|
|
3338
|
+
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; }
|
|
3339
|
+
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; }
|
|
3340
|
+
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)); }
|
|
3341
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
2804
3342
|
// src/error.ts
|
|
2805
3343
|
var ErrorCode = {
|
|
2806
3344
|
/** 网络错误(断网、DNS 解析失败等) */
|
|
@@ -2816,278 +3354,498 @@ var ErrorCode = {
|
|
|
2816
3354
|
/** 存储服务未启用 */
|
|
2817
3355
|
STORAGE_DISABLED: 503
|
|
2818
3356
|
};
|
|
2819
|
-
var OssError =
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
this
|
|
2823
|
-
|
|
2824
|
-
|
|
3357
|
+
var OssError = /*#__PURE__*/function (_Error) {
|
|
3358
|
+
function OssError(code, message) {
|
|
3359
|
+
var _this;
|
|
3360
|
+
_classCallCheck(this, OssError);
|
|
3361
|
+
_this = _callSuper$1(this, OssError, [message]);
|
|
3362
|
+
_this.name = "OssError";
|
|
3363
|
+
_this.code = code;
|
|
3364
|
+
_this.isRetryable = code === ErrorCode.NETWORK || code === ErrorCode.TIMEOUT || code >= 500;
|
|
3365
|
+
return _this;
|
|
2825
3366
|
}
|
|
2826
|
-
|
|
3367
|
+
_inherits(OssError, _Error);
|
|
3368
|
+
return _createClass(OssError);
|
|
3369
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
2827
3370
|
|
|
2828
3371
|
// src/validate.ts
|
|
2829
3372
|
var MAGIC_BYTES = [
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
]
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
"
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
"
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
"webm",
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
"
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
"
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
"
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
"
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
"
|
|
2880
|
-
]
|
|
3373
|
+
// 图片
|
|
3374
|
+
{
|
|
3375
|
+
ext: ["jpg", "jpeg"],
|
|
3376
|
+
bytes: [255, 216, 255]
|
|
3377
|
+
}, {
|
|
3378
|
+
ext: ["png"],
|
|
3379
|
+
bytes: [137, 80, 78, 71, 13, 10, 26, 10]
|
|
3380
|
+
}, {
|
|
3381
|
+
ext: ["gif"],
|
|
3382
|
+
bytes: [71, 73, 70, 56]
|
|
3383
|
+
}, {
|
|
3384
|
+
ext: ["bmp"],
|
|
3385
|
+
bytes: [66, 77]
|
|
3386
|
+
}, {
|
|
3387
|
+
ext: ["webp"],
|
|
3388
|
+
bytes: [87, 69, 66, 80],
|
|
3389
|
+
offset: 8
|
|
3390
|
+
}, {
|
|
3391
|
+
ext: ["ico"],
|
|
3392
|
+
bytes: [0, 0, 1, 0]
|
|
3393
|
+
}, {
|
|
3394
|
+
ext: ["svg"],
|
|
3395
|
+
bytes: []
|
|
3396
|
+
},
|
|
3397
|
+
// SVG 是文本,单独处理
|
|
3398
|
+
// 视频
|
|
3399
|
+
{
|
|
3400
|
+
ext: ["mp4", "m4v"],
|
|
3401
|
+
bytes: [102, 116, 121, 112],
|
|
3402
|
+
offset: 4
|
|
3403
|
+
}, {
|
|
3404
|
+
ext: ["webm"],
|
|
3405
|
+
bytes: [26, 69, 223, 163]
|
|
3406
|
+
}, {
|
|
3407
|
+
ext: ["avi"],
|
|
3408
|
+
bytes: [82, 73, 70, 70]
|
|
3409
|
+
}, {
|
|
3410
|
+
ext: ["mov"],
|
|
3411
|
+
bytes: [102, 116, 121, 112],
|
|
3412
|
+
offset: 4
|
|
3413
|
+
}, {
|
|
3414
|
+
ext: ["flv"],
|
|
3415
|
+
bytes: [70, 76, 86]
|
|
3416
|
+
}, {
|
|
3417
|
+
ext: ["mkv"],
|
|
3418
|
+
bytes: [26, 69, 223, 163]
|
|
3419
|
+
},
|
|
3420
|
+
// 文档
|
|
3421
|
+
{
|
|
3422
|
+
ext: ["pdf"],
|
|
3423
|
+
bytes: [37, 80, 68, 70]
|
|
3424
|
+
}];
|
|
3425
|
+
var DEFAULT_ALLOWED_EXTENSIONS = /* @__PURE__ */new Set([
|
|
3426
|
+
// 图片
|
|
3427
|
+
"jpg", "jpeg", "png", "gif", "webp", "bmp", "ico", "svg",
|
|
3428
|
+
// 视频
|
|
3429
|
+
"mp4", "webm", "mov", "avi", "mkv", "flv", "wmv", "m4v",
|
|
3430
|
+
// 文档
|
|
3431
|
+
"pdf",
|
|
3432
|
+
// 代码/文本
|
|
3433
|
+
"html", "css", "js", "ts", "json", "xml", "txt", "md", "csv"]);
|
|
2881
3434
|
function getExt(fileName) {
|
|
2882
3435
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
2883
3436
|
}
|
|
2884
3437
|
function validateExtension(fileName, allowedExtensions) {
|
|
2885
|
-
|
|
2886
|
-
|
|
3438
|
+
var ext = getExt(fileName);
|
|
3439
|
+
var whitelist = allowedExtensions !== null && allowedExtensions !== void 0 ? allowedExtensions : DEFAULT_ALLOWED_EXTENSIONS;
|
|
2887
3440
|
if (!ext) {
|
|
2888
|
-
throw new OssError(ErrorCode.INVALID_PARAMS,
|
|
3441
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u7F3A\u5C11\u6269\u5C55\u540D"));
|
|
2889
3442
|
}
|
|
2890
3443
|
if (!whitelist.has(ext)) {
|
|
2891
|
-
throw new OssError(
|
|
2892
|
-
ErrorCode.INVALID_PARAMS,
|
|
2893
|
-
`\u6587\u4EF6\u7C7B\u578B ".${ext}" \u4E0D\u5728\u5141\u8BB8\u5217\u8868\u4E2D\uFF0C\u5141\u8BB8\u7684\u7C7B\u578B\uFF1A${[...whitelist].join(", ")}`
|
|
2894
|
-
);
|
|
3444
|
+
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(", ")));
|
|
2895
3445
|
}
|
|
2896
3446
|
}
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
3447
|
+
function validateMagicBytes(_x, _x2) {
|
|
3448
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
3449
|
+
} // src/request.ts
|
|
3450
|
+
function _validateMagicBytes() {
|
|
3451
|
+
_validateMagicBytes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, fileName) {
|
|
3452
|
+
var _rule$offset;
|
|
3453
|
+
var ext, textExts, text, rule, offset, needed, headerBuf, header, matched;
|
|
3454
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
3455
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
3456
|
+
case 0:
|
|
3457
|
+
ext = getExt(fileName);
|
|
3458
|
+
textExts = /* @__PURE__ */new Set(["html", "css", "js", "ts", "json", "xml", "txt", "md", "csv", "svg"]);
|
|
3459
|
+
if (!textExts.has(ext)) {
|
|
3460
|
+
_context6.next = 3;
|
|
3461
|
+
break;
|
|
3462
|
+
}
|
|
3463
|
+
if (!(ext === "svg")) {
|
|
3464
|
+
_context6.next = 2;
|
|
3465
|
+
break;
|
|
3466
|
+
}
|
|
3467
|
+
_context6.next = 1;
|
|
3468
|
+
return blob.slice(0, 1024).text();
|
|
3469
|
+
case 1:
|
|
3470
|
+
text = _context6.sent;
|
|
3471
|
+
if (!(!text.includes("<svg") && !text.includes("<?xml"))) {
|
|
3472
|
+
_context6.next = 2;
|
|
3473
|
+
break;
|
|
3474
|
+
}
|
|
3475
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u4E0D\u662F\u6709\u6548\u7684 SVG \u6587\u4EF6"));
|
|
3476
|
+
case 2:
|
|
3477
|
+
return _context6.abrupt("return");
|
|
3478
|
+
case 3:
|
|
3479
|
+
rule = MAGIC_BYTES.find(function (r) {
|
|
3480
|
+
return r.ext.includes(ext);
|
|
3481
|
+
});
|
|
3482
|
+
if (!(!rule || rule.bytes.length === 0)) {
|
|
3483
|
+
_context6.next = 4;
|
|
3484
|
+
break;
|
|
3485
|
+
}
|
|
3486
|
+
return _context6.abrupt("return");
|
|
3487
|
+
case 4:
|
|
3488
|
+
offset = (_rule$offset = rule.offset) !== null && _rule$offset !== void 0 ? _rule$offset : 0;
|
|
3489
|
+
needed = offset + rule.bytes.length;
|
|
3490
|
+
if (!(blob.size < needed)) {
|
|
3491
|
+
_context6.next = 5;
|
|
3492
|
+
break;
|
|
3493
|
+
}
|
|
3494
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "\u6587\u4EF6 \"".concat(fileName, "\" \u5185\u5BB9\u8FC7\u77ED\uFF0C\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B"));
|
|
3495
|
+
case 5:
|
|
3496
|
+
_context6.next = 6;
|
|
3497
|
+
return blob.slice(0, needed).arrayBuffer();
|
|
3498
|
+
case 6:
|
|
3499
|
+
headerBuf = _context6.sent;
|
|
3500
|
+
header = new Uint8Array(headerBuf);
|
|
3501
|
+
matched = rule.bytes.every(function (_byte, i) {
|
|
3502
|
+
return header[offset + i] === _byte;
|
|
3503
|
+
});
|
|
3504
|
+
if (matched) {
|
|
3505
|
+
_context6.next = 7;
|
|
3506
|
+
break;
|
|
3507
|
+
}
|
|
3508
|
+
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"));
|
|
3509
|
+
case 7:
|
|
3510
|
+
case "end":
|
|
3511
|
+
return _context6.stop();
|
|
3512
|
+
}
|
|
3513
|
+
}, _callee6);
|
|
3514
|
+
}));
|
|
3515
|
+
return _validateMagicBytes.apply(this, arguments);
|
|
3516
|
+
}
|
|
3517
|
+
function sleep(ms) {
|
|
3518
|
+
return new Promise(function (resolve) {
|
|
3519
|
+
return setTimeout(resolve, ms);
|
|
3520
|
+
});
|
|
3521
|
+
}
|
|
3522
|
+
function parseJson(json) {
|
|
3523
|
+
if (json.code !== 200) {
|
|
3524
|
+
throw new OssError(json.code, json.message || json.error || "Unknown error");
|
|
3525
|
+
}
|
|
3526
|
+
return json.data;
|
|
3527
|
+
}
|
|
3528
|
+
function fetchJson(_x3, _x4, _x5, _x6) {
|
|
3529
|
+
return _fetchJson.apply(this, arguments);
|
|
3530
|
+
}
|
|
3531
|
+
function _fetchJson() {
|
|
3532
|
+
_fetchJson = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(baseURL, timeout, path, body) {
|
|
3533
|
+
var url, controller, timer, res, json, _t;
|
|
3534
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
3535
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
3536
|
+
case 0:
|
|
3537
|
+
url = "".concat(baseURL).concat(path);
|
|
3538
|
+
controller = new AbortController();
|
|
3539
|
+
timer = setTimeout(function () {
|
|
3540
|
+
return controller.abort();
|
|
3541
|
+
}, timeout);
|
|
3542
|
+
_context7.prev = 1;
|
|
3543
|
+
_context7.next = 2;
|
|
3544
|
+
return fetch(url, {
|
|
3545
|
+
method: "POST",
|
|
3546
|
+
headers: {
|
|
3547
|
+
"Content-Type": "application/json"
|
|
3548
|
+
},
|
|
3549
|
+
body: JSON.stringify(body),
|
|
3550
|
+
signal: controller.signal
|
|
3551
|
+
});
|
|
3552
|
+
case 2:
|
|
3553
|
+
res = _context7.sent;
|
|
3554
|
+
_context7.next = 5;
|
|
3555
|
+
break;
|
|
3556
|
+
case 3:
|
|
3557
|
+
_context7.prev = 3;
|
|
3558
|
+
_t = _context7["catch"](1);
|
|
3559
|
+
if (!(_t instanceof DOMException && _t.name === "AbortError")) {
|
|
3560
|
+
_context7.next = 4;
|
|
3561
|
+
break;
|
|
3562
|
+
}
|
|
3563
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3564
|
+
case 4:
|
|
3565
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t instanceof Error ? _t.message : String(_t)));
|
|
3566
|
+
case 5:
|
|
3567
|
+
_context7.prev = 5;
|
|
3568
|
+
clearTimeout(timer);
|
|
3569
|
+
return _context7.finish(5);
|
|
3570
|
+
case 6:
|
|
3571
|
+
_context7.prev = 6;
|
|
3572
|
+
_context7.next = 7;
|
|
3573
|
+
return res.json();
|
|
3574
|
+
case 7:
|
|
3575
|
+
json = _context7.sent;
|
|
3576
|
+
_context7.next = 9;
|
|
3577
|
+
break;
|
|
3578
|
+
case 8:
|
|
3579
|
+
_context7.prev = 8;
|
|
3580
|
+
_context7["catch"](6);
|
|
3581
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3582
|
+
case 9:
|
|
3583
|
+
return _context7.abrupt("return", parseJson(json));
|
|
3584
|
+
case 10:
|
|
3585
|
+
case "end":
|
|
3586
|
+
return _context7.stop();
|
|
3587
|
+
}
|
|
3588
|
+
}, _callee7, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3589
|
+
}));
|
|
3590
|
+
return _fetchJson.apply(this, arguments);
|
|
3591
|
+
}
|
|
3592
|
+
function fetchFormData(_x7, _x8, _x9, _x0) {
|
|
3593
|
+
return _fetchFormData.apply(this, arguments);
|
|
3594
|
+
}
|
|
3595
|
+
function _fetchFormData() {
|
|
3596
|
+
_fetchFormData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(baseURL, timeout, path, formData) {
|
|
3597
|
+
var url, controller, timer, res, json, _t3;
|
|
3598
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
3599
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3600
|
+
case 0:
|
|
3601
|
+
url = "".concat(baseURL).concat(path);
|
|
3602
|
+
controller = new AbortController();
|
|
3603
|
+
timer = setTimeout(function () {
|
|
3604
|
+
return controller.abort();
|
|
3605
|
+
}, timeout);
|
|
3606
|
+
_context8.prev = 1;
|
|
3607
|
+
_context8.next = 2;
|
|
3608
|
+
return fetch(url, {
|
|
3609
|
+
method: "POST",
|
|
3610
|
+
body: formData,
|
|
3611
|
+
signal: controller.signal
|
|
3612
|
+
});
|
|
3613
|
+
case 2:
|
|
3614
|
+
res = _context8.sent;
|
|
3615
|
+
_context8.next = 5;
|
|
3616
|
+
break;
|
|
3617
|
+
case 3:
|
|
3618
|
+
_context8.prev = 3;
|
|
3619
|
+
_t3 = _context8["catch"](1);
|
|
3620
|
+
if (!(_t3 instanceof DOMException && _t3.name === "AbortError")) {
|
|
3621
|
+
_context8.next = 4;
|
|
3622
|
+
break;
|
|
3623
|
+
}
|
|
3624
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3625
|
+
case 4:
|
|
3626
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t3 instanceof Error ? _t3.message : String(_t3)));
|
|
3627
|
+
case 5:
|
|
3628
|
+
_context8.prev = 5;
|
|
3629
|
+
clearTimeout(timer);
|
|
3630
|
+
return _context8.finish(5);
|
|
3631
|
+
case 6:
|
|
3632
|
+
_context8.prev = 6;
|
|
3633
|
+
_context8.next = 7;
|
|
3634
|
+
return res.json();
|
|
3635
|
+
case 7:
|
|
3636
|
+
json = _context8.sent;
|
|
3637
|
+
_context8.next = 9;
|
|
3638
|
+
break;
|
|
3639
|
+
case 8:
|
|
3640
|
+
_context8.prev = 8;
|
|
3641
|
+
_context8["catch"](6);
|
|
3642
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3643
|
+
case 9:
|
|
3644
|
+
return _context8.abrupt("return", parseJson(json));
|
|
3645
|
+
case 10:
|
|
3646
|
+
case "end":
|
|
3647
|
+
return _context8.stop();
|
|
3648
|
+
}
|
|
3649
|
+
}, _callee8, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3650
|
+
}));
|
|
3651
|
+
return _fetchFormData.apply(this, arguments);
|
|
3652
|
+
}
|
|
3653
|
+
function fetchFormDataWithProgress(_x1, _x10, _x11, _x12, _x13) {
|
|
3654
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
3655
|
+
}
|
|
3656
|
+
function _fetchFormDataWithProgress() {
|
|
3657
|
+
_fetchFormDataWithProgress = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(baseURL, timeout, path, formData, onProgress) {
|
|
3658
|
+
var url;
|
|
3659
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
3660
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
3661
|
+
case 0:
|
|
3662
|
+
if (!(typeof XMLHttpRequest === "undefined")) {
|
|
3663
|
+
_context9.next = 1;
|
|
3664
|
+
break;
|
|
3665
|
+
}
|
|
3666
|
+
return _context9.abrupt("return", fetchFormData(baseURL, timeout, path, formData));
|
|
3667
|
+
case 1:
|
|
3668
|
+
url = "".concat(baseURL).concat(path);
|
|
3669
|
+
return _context9.abrupt("return", new Promise(function (resolve, reject) {
|
|
3670
|
+
var xhr = new XMLHttpRequest();
|
|
3671
|
+
xhr.open("POST", url, true);
|
|
3672
|
+
xhr.timeout = timeout;
|
|
3673
|
+
xhr.upload.onprogress = function (e) {
|
|
3674
|
+
if (e.lengthComputable) {
|
|
3675
|
+
onProgress({
|
|
3676
|
+
loaded: e.loaded,
|
|
3677
|
+
total: e.total,
|
|
3678
|
+
percent: Math.round(e.loaded / e.total * 100)
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
xhr.onload = function () {
|
|
3683
|
+
try {
|
|
3684
|
+
var json = JSON.parse(xhr.responseText);
|
|
3685
|
+
if (json.code !== 200) {
|
|
3686
|
+
reject(new OssError(json.code, json.message || json.error || "Unknown error"));
|
|
3687
|
+
} else {
|
|
3688
|
+
resolve(json.data);
|
|
3689
|
+
}
|
|
3690
|
+
} catch (_unused3) {
|
|
3691
|
+
reject(new OssError(xhr.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(xhr.status, "\uFF09")));
|
|
3692
|
+
}
|
|
3693
|
+
};
|
|
3694
|
+
xhr.onerror = function () {
|
|
3695
|
+
reject(new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25"));
|
|
3696
|
+
};
|
|
3697
|
+
xhr.ontimeout = function () {
|
|
3698
|
+
reject(new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09")));
|
|
3699
|
+
};
|
|
3700
|
+
xhr.send(formData);
|
|
3701
|
+
}));
|
|
3702
|
+
case 2:
|
|
3703
|
+
case "end":
|
|
3704
|
+
return _context9.stop();
|
|
2905
3705
|
}
|
|
2906
|
-
}
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
const rule = MAGIC_BYTES.find((r) => r.ext.includes(ext));
|
|
2910
|
-
if (!rule || rule.bytes.length === 0) return;
|
|
2911
|
-
const offset = rule.offset ?? 0;
|
|
2912
|
-
const needed = offset + rule.bytes.length;
|
|
2913
|
-
if (blob.size < needed) {
|
|
2914
|
-
throw new OssError(ErrorCode.INVALID_PARAMS, `\u6587\u4EF6 "${fileName}" \u5185\u5BB9\u8FC7\u77ED\uFF0C\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B`);
|
|
2915
|
-
}
|
|
2916
|
-
const headerBuf = await blob.slice(0, needed).arrayBuffer();
|
|
2917
|
-
const header = new Uint8Array(headerBuf);
|
|
2918
|
-
const matched = rule.bytes.every((byte, i) => header[offset + i] === byte);
|
|
2919
|
-
if (!matched) {
|
|
2920
|
-
throw new OssError(
|
|
2921
|
-
ErrorCode.INVALID_PARAMS,
|
|
2922
|
-
`\u6587\u4EF6 "${fileName}" \u5B9E\u9645\u5185\u5BB9\u4E0E\u6269\u5C55\u540D ".${ext}" \u4E0D\u5339\u914D\uFF0C\u7591\u4F3C\u4F2A\u9020\u6587\u4EF6`
|
|
2923
|
-
);
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
|
|
2927
|
-
// src/request.ts
|
|
2928
|
-
function sleep(ms) {
|
|
2929
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3706
|
+
}, _callee9);
|
|
3707
|
+
}));
|
|
3708
|
+
return _fetchFormDataWithProgress.apply(this, arguments);
|
|
2930
3709
|
}
|
|
2931
|
-
function
|
|
2932
|
-
|
|
2933
|
-
throw new OssError(json.code, json.message || json.error || "Unknown error");
|
|
2934
|
-
}
|
|
2935
|
-
return json.data;
|
|
3710
|
+
function fetchGet(_x14, _x15, _x16) {
|
|
3711
|
+
return _fetchGet.apply(this, arguments);
|
|
2936
3712
|
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
3713
|
+
function _fetchGet() {
|
|
3714
|
+
_fetchGet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(baseURL, timeout, path) {
|
|
3715
|
+
var url, controller, timer, res, json, _t5;
|
|
3716
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
3717
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
3718
|
+
case 0:
|
|
3719
|
+
url = "".concat(baseURL).concat(path);
|
|
3720
|
+
controller = new AbortController();
|
|
3721
|
+
timer = setTimeout(function () {
|
|
3722
|
+
return controller.abort();
|
|
3723
|
+
}, timeout);
|
|
3724
|
+
_context0.prev = 1;
|
|
3725
|
+
_context0.next = 2;
|
|
3726
|
+
return fetch(url, {
|
|
3727
|
+
method: "GET",
|
|
3728
|
+
signal: controller.signal
|
|
3729
|
+
});
|
|
3730
|
+
case 2:
|
|
3731
|
+
res = _context0.sent;
|
|
3732
|
+
_context0.next = 5;
|
|
3733
|
+
break;
|
|
3734
|
+
case 3:
|
|
3735
|
+
_context0.prev = 3;
|
|
3736
|
+
_t5 = _context0["catch"](1);
|
|
3737
|
+
if (!(_t5 instanceof DOMException && _t5.name === "AbortError")) {
|
|
3738
|
+
_context0.next = 4;
|
|
3739
|
+
break;
|
|
3740
|
+
}
|
|
3741
|
+
throw new OssError(ErrorCode.TIMEOUT, "\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
|
|
3742
|
+
case 4:
|
|
3743
|
+
throw new OssError(ErrorCode.NETWORK, "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ".concat(_t5 instanceof Error ? _t5.message : String(_t5)));
|
|
3744
|
+
case 5:
|
|
3745
|
+
_context0.prev = 5;
|
|
3746
|
+
clearTimeout(timer);
|
|
3747
|
+
return _context0.finish(5);
|
|
3748
|
+
case 6:
|
|
3749
|
+
_context0.prev = 6;
|
|
3750
|
+
_context0.next = 7;
|
|
3751
|
+
return res.json();
|
|
3752
|
+
case 7:
|
|
3753
|
+
json = _context0.sent;
|
|
3754
|
+
_context0.next = 9;
|
|
3755
|
+
break;
|
|
3756
|
+
case 8:
|
|
3757
|
+
_context0.prev = 8;
|
|
3758
|
+
_context0["catch"](6);
|
|
3759
|
+
throw new OssError(res.status, "\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ".concat(res.status, "\uFF09"));
|
|
3760
|
+
case 9:
|
|
3761
|
+
return _context0.abrupt("return", parseJson(json));
|
|
3762
|
+
case 10:
|
|
3763
|
+
case "end":
|
|
3764
|
+
return _context0.stop();
|
|
3765
|
+
}
|
|
3766
|
+
}, _callee0, null, [[1, 3, 5, 6], [6, 8]]);
|
|
3767
|
+
}));
|
|
3768
|
+
return _fetchGet.apply(this, arguments);
|
|
2964
3769
|
}
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
const controller = new AbortController();
|
|
2968
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
2969
|
-
let res;
|
|
2970
|
-
try {
|
|
2971
|
-
res = await fetch(url, {
|
|
2972
|
-
method: "POST",
|
|
2973
|
-
body: formData,
|
|
2974
|
-
signal: controller.signal
|
|
2975
|
-
});
|
|
2976
|
-
} catch (err) {
|
|
2977
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
2978
|
-
throw new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`);
|
|
2979
|
-
}
|
|
2980
|
-
throw new OssError(ErrorCode.NETWORK, `\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
2981
|
-
} finally {
|
|
2982
|
-
clearTimeout(timer);
|
|
2983
|
-
}
|
|
2984
|
-
let json;
|
|
2985
|
-
try {
|
|
2986
|
-
json = await res.json();
|
|
2987
|
-
} catch {
|
|
2988
|
-
throw new OssError(res.status, `\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ${res.status}\uFF09`);
|
|
2989
|
-
}
|
|
2990
|
-
return parseJson(json);
|
|
3770
|
+
function withRetry(_x17, _x18) {
|
|
3771
|
+
return _withRetry.apply(this, arguments);
|
|
2991
3772
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3773
|
+
function _withRetry() {
|
|
3774
|
+
_withRetry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(fn, retry) {
|
|
3775
|
+
var _retry$retries, _retry$delay, _retry$backoff;
|
|
3776
|
+
var maxRetries, baseDelay, backoff, lastError, attempt, waitMs, _t7;
|
|
3777
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
3778
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
3779
|
+
case 0:
|
|
3780
|
+
maxRetries = (_retry$retries = retry === null || retry === void 0 ? void 0 : retry.retries) !== null && _retry$retries !== void 0 ? _retry$retries : 2;
|
|
3781
|
+
baseDelay = (_retry$delay = retry === null || retry === void 0 ? void 0 : retry.delay) !== null && _retry$delay !== void 0 ? _retry$delay : 1e3;
|
|
3782
|
+
backoff = (_retry$backoff = retry === null || retry === void 0 ? void 0 : retry.backoff) !== null && _retry$backoff !== void 0 ? _retry$backoff : 2;
|
|
3783
|
+
attempt = 0;
|
|
3784
|
+
case 1:
|
|
3785
|
+
if (!(attempt <= maxRetries)) {
|
|
3786
|
+
_context1.next = 8;
|
|
3787
|
+
break;
|
|
3788
|
+
}
|
|
3789
|
+
_context1.prev = 2;
|
|
3790
|
+
_context1.next = 3;
|
|
3791
|
+
return fn();
|
|
3792
|
+
case 3:
|
|
3793
|
+
return _context1.abrupt("return", _context1.sent);
|
|
3794
|
+
case 4:
|
|
3795
|
+
_context1.prev = 4;
|
|
3796
|
+
_t7 = _context1["catch"](2);
|
|
3797
|
+
lastError = _t7;
|
|
3798
|
+
if (lastError.isRetryable) {
|
|
3799
|
+
_context1.next = 5;
|
|
3800
|
+
break;
|
|
3801
|
+
}
|
|
3802
|
+
throw lastError;
|
|
3803
|
+
case 5:
|
|
3804
|
+
if (!(attempt >= maxRetries)) {
|
|
3805
|
+
_context1.next = 6;
|
|
3806
|
+
break;
|
|
3807
|
+
}
|
|
3808
|
+
return _context1.abrupt("continue", 8);
|
|
3809
|
+
case 6:
|
|
3810
|
+
waitMs = baseDelay * Math.pow(backoff, attempt);
|
|
3811
|
+
_context1.next = 7;
|
|
3812
|
+
return sleep(waitMs);
|
|
3813
|
+
case 7:
|
|
3814
|
+
attempt++;
|
|
3815
|
+
_context1.next = 1;
|
|
3816
|
+
break;
|
|
3817
|
+
case 8:
|
|
3818
|
+
throw lastError;
|
|
3819
|
+
case 9:
|
|
3820
|
+
case "end":
|
|
3821
|
+
return _context1.stop();
|
|
3020
3822
|
}
|
|
3021
|
-
};
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
};
|
|
3025
|
-
xhr.ontimeout = () => {
|
|
3026
|
-
reject(new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`));
|
|
3027
|
-
};
|
|
3028
|
-
xhr.send(formData);
|
|
3029
|
-
});
|
|
3030
|
-
}
|
|
3031
|
-
async function fetchGet(baseURL, timeout, path) {
|
|
3032
|
-
const url = `${baseURL}${path}`;
|
|
3033
|
-
const controller = new AbortController();
|
|
3034
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
3035
|
-
let res;
|
|
3036
|
-
try {
|
|
3037
|
-
res = await fetch(url, {
|
|
3038
|
-
method: "GET",
|
|
3039
|
-
signal: controller.signal
|
|
3040
|
-
});
|
|
3041
|
-
} catch (err) {
|
|
3042
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
3043
|
-
throw new OssError(ErrorCode.TIMEOUT, `\u8BF7\u6C42\u8D85\u65F6\uFF08${timeout}ms\uFF09`);
|
|
3044
|
-
}
|
|
3045
|
-
throw new OssError(ErrorCode.NETWORK, `\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
3046
|
-
} finally {
|
|
3047
|
-
clearTimeout(timer);
|
|
3048
|
-
}
|
|
3049
|
-
let json;
|
|
3050
|
-
try {
|
|
3051
|
-
json = await res.json();
|
|
3052
|
-
} catch {
|
|
3053
|
-
throw new OssError(res.status, `\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94\uFF08HTTP ${res.status}\uFF09`);
|
|
3054
|
-
}
|
|
3055
|
-
return parseJson(json);
|
|
3056
|
-
}
|
|
3057
|
-
async function withRetry(fn, retry) {
|
|
3058
|
-
const maxRetries = retry?.retries ?? 2;
|
|
3059
|
-
const baseDelay = retry?.delay ?? 1e3;
|
|
3060
|
-
const backoff = retry?.backoff ?? 2;
|
|
3061
|
-
let lastError;
|
|
3062
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
3063
|
-
try {
|
|
3064
|
-
return await fn();
|
|
3065
|
-
} catch (err) {
|
|
3066
|
-
lastError = err;
|
|
3067
|
-
if (!lastError.isRetryable) throw lastError;
|
|
3068
|
-
if (attempt >= maxRetries) break;
|
|
3069
|
-
const waitMs = baseDelay * backoff ** attempt;
|
|
3070
|
-
await sleep(waitMs);
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
throw lastError;
|
|
3823
|
+
}, _callee1, null, [[2, 4]]);
|
|
3824
|
+
}));
|
|
3825
|
+
return _withRetry.apply(this, arguments);
|
|
3074
3826
|
}
|
|
3075
3827
|
function requestJsonWithRetry(baseURL, timeout, path, body, retry) {
|
|
3076
|
-
return withRetry(
|
|
3828
|
+
return withRetry(function () {
|
|
3829
|
+
return fetchJson(baseURL, timeout, path, body);
|
|
3830
|
+
}, retry);
|
|
3077
3831
|
}
|
|
3078
3832
|
function requestFormDataWithRetry(baseURL, timeout, path, formData, retry, onProgress) {
|
|
3079
3833
|
if (onProgress) {
|
|
3080
3834
|
return fetchFormDataWithProgress(baseURL, timeout, path, formData, onProgress);
|
|
3081
3835
|
}
|
|
3082
|
-
return withRetry(
|
|
3836
|
+
return withRetry(function () {
|
|
3837
|
+
return fetchFormData(baseURL, timeout, path, formData);
|
|
3838
|
+
}, retry);
|
|
3083
3839
|
}
|
|
3084
3840
|
function requestGetWithRetry(baseURL, timeout, path, retry) {
|
|
3085
|
-
return withRetry(
|
|
3841
|
+
return withRetry(function () {
|
|
3842
|
+
return fetchGet(baseURL, timeout, path);
|
|
3843
|
+
}, retry);
|
|
3086
3844
|
}
|
|
3087
3845
|
|
|
3088
3846
|
// src/compress.ts
|
|
3089
|
-
var IMAGE_EXTENSIONS = /* @__PURE__ */
|
|
3090
|
-
var VIDEO_EXTENSIONS = /* @__PURE__ */
|
|
3847
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */new Set(["jpg", "jpeg", "png", "webp", "bmp"]);
|
|
3848
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */new Set(["mp4", "webm", "mov", "avi", "mkv", "flv", "wmv"]);
|
|
3091
3849
|
function getExtension(fileName) {
|
|
3092
3850
|
return (fileName.split(".").pop() || "").toLowerCase();
|
|
3093
3851
|
}
|
|
@@ -3106,19 +3864,17 @@ var DEFAULT_LIMITS = {
|
|
|
3106
3864
|
other: 10 * 1024 * 1024
|
|
3107
3865
|
};
|
|
3108
3866
|
function getSizeLimit(fileName, limits) {
|
|
3109
|
-
|
|
3867
|
+
var merged = _objectSpread$2(_objectSpread$2({}, DEFAULT_LIMITS), limits);
|
|
3110
3868
|
if (isImage(fileName)) return merged.image;
|
|
3111
3869
|
if (isVideo(fileName)) return merged.video;
|
|
3112
3870
|
return merged.other;
|
|
3113
3871
|
}
|
|
3114
3872
|
function validateFileSize(blob, fileName, limits) {
|
|
3115
|
-
|
|
3873
|
+
var maxSize = getSizeLimit(fileName, limits);
|
|
3116
3874
|
if (blob.size > maxSize) {
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
throw new Error(
|
|
3120
|
-
`\u6587\u4EF6 "${fileName}" \u5927\u5C0F ${sizeMB}MB \u8D85\u8FC7\u9650\u5236 ${limitMB}MB`
|
|
3121
|
-
);
|
|
3875
|
+
var sizeMB = (blob.size / 1024 / 1024).toFixed(1);
|
|
3876
|
+
var limitMB = (maxSize / 1024 / 1024).toFixed(1);
|
|
3877
|
+
throw new Error("\u6587\u4EF6 \"".concat(fileName, "\" \u5927\u5C0F ").concat(sizeMB, "MB \u8D85\u8FC7\u9650\u5236 ").concat(limitMB, "MB"));
|
|
3122
3878
|
}
|
|
3123
3879
|
}
|
|
3124
3880
|
var DEFAULT_COMPRESS = {
|
|
@@ -3127,71 +3883,119 @@ var DEFAULT_COMPRESS = {
|
|
|
3127
3883
|
imageMaxWidth: 1920,
|
|
3128
3884
|
imageMaxHeight: 1080
|
|
3129
3885
|
};
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3886
|
+
function compressImageBlob(_x19, _x20) {
|
|
3887
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3888
|
+
}
|
|
3889
|
+
function _compressImageBlob() {
|
|
3890
|
+
_compressImageBlob = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(blob, options) {
|
|
3891
|
+
var opts, bitmap, srcW, srcH, targetW, targetH, canvas, ctx, ext, outputType, compressed;
|
|
3892
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
3893
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
3894
|
+
case 0:
|
|
3895
|
+
opts = _objectSpread$2(_objectSpread$2({}, DEFAULT_COMPRESS), options);
|
|
3896
|
+
if (!(typeof createImageBitmap === "undefined" || typeof OffscreenCanvas === "undefined")) {
|
|
3897
|
+
_context10.next = 1;
|
|
3898
|
+
break;
|
|
3899
|
+
}
|
|
3900
|
+
return _context10.abrupt("return", blob);
|
|
3901
|
+
case 1:
|
|
3902
|
+
_context10.prev = 1;
|
|
3903
|
+
_context10.next = 2;
|
|
3904
|
+
return createImageBitmap(blob);
|
|
3905
|
+
case 2:
|
|
3906
|
+
bitmap = _context10.sent;
|
|
3907
|
+
srcW = bitmap.width, srcH = bitmap.height;
|
|
3908
|
+
targetW = srcW;
|
|
3909
|
+
targetH = srcH;
|
|
3910
|
+
if (targetW > opts.imageMaxWidth) {
|
|
3911
|
+
targetH = Math.round(targetH * (opts.imageMaxWidth / targetW));
|
|
3912
|
+
targetW = opts.imageMaxWidth;
|
|
3913
|
+
}
|
|
3914
|
+
if (targetH > opts.imageMaxHeight) {
|
|
3915
|
+
targetW = Math.round(targetW * (opts.imageMaxHeight / targetH));
|
|
3916
|
+
targetH = opts.imageMaxHeight;
|
|
3917
|
+
}
|
|
3918
|
+
canvas = new OffscreenCanvas(targetW, targetH);
|
|
3919
|
+
ctx = canvas.getContext("2d");
|
|
3920
|
+
if (ctx) {
|
|
3921
|
+
_context10.next = 3;
|
|
3922
|
+
break;
|
|
3923
|
+
}
|
|
3924
|
+
bitmap.close();
|
|
3925
|
+
return _context10.abrupt("return", blob);
|
|
3926
|
+
case 3:
|
|
3927
|
+
ctx.drawImage(bitmap, 0, 0, targetW, targetH);
|
|
3928
|
+
bitmap.close();
|
|
3929
|
+
ext = getExtension(blob.name || "");
|
|
3930
|
+
outputType = "image/webp";
|
|
3931
|
+
if (ext === "png") outputType = "image/png";else if (ext === "jpg" || ext === "jpeg") outputType = "image/jpeg";
|
|
3932
|
+
_context10.next = 4;
|
|
3933
|
+
return canvas.convertToBlob({
|
|
3934
|
+
type: outputType,
|
|
3935
|
+
quality: opts.imageQuality
|
|
3936
|
+
});
|
|
3937
|
+
case 4:
|
|
3938
|
+
compressed = _context10.sent;
|
|
3939
|
+
return _context10.abrupt("return", compressed.size < blob.size ? compressed : blob);
|
|
3940
|
+
case 5:
|
|
3941
|
+
_context10.prev = 5;
|
|
3942
|
+
_context10["catch"](1);
|
|
3943
|
+
return _context10.abrupt("return", blob);
|
|
3944
|
+
case 6:
|
|
3945
|
+
case "end":
|
|
3946
|
+
return _context10.stop();
|
|
3947
|
+
}
|
|
3948
|
+
}, _callee10, null, [[1, 5]]);
|
|
3949
|
+
}));
|
|
3950
|
+
return _compressImageBlob.apply(this, arguments);
|
|
3951
|
+
}
|
|
3952
|
+
function processFile(_x21, _x22, _x23, _x24) {
|
|
3953
|
+
return _processFile.apply(this, arguments);
|
|
3954
|
+
} // src/client.ts
|
|
3955
|
+
function _processFile() {
|
|
3956
|
+
_processFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(blob, fileName, compress, limits) {
|
|
3957
|
+
var opts;
|
|
3958
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
3959
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
3960
|
+
case 0:
|
|
3961
|
+
opts = _objectSpread$2(_objectSpread$2({}, DEFAULT_COMPRESS), compress);
|
|
3962
|
+
if (!(opts.enabled && isImage(fileName))) {
|
|
3963
|
+
_context11.next = 2;
|
|
3964
|
+
break;
|
|
3965
|
+
}
|
|
3966
|
+
_context11.next = 1;
|
|
3967
|
+
return compressImageBlob(blob, opts);
|
|
3968
|
+
case 1:
|
|
3969
|
+
blob = _context11.sent;
|
|
3970
|
+
case 2:
|
|
3971
|
+
validateFileSize(blob, fileName, limits);
|
|
3972
|
+
return _context11.abrupt("return", blob);
|
|
3973
|
+
case 3:
|
|
3974
|
+
case "end":
|
|
3975
|
+
return _context11.stop();
|
|
3976
|
+
}
|
|
3977
|
+
}, _callee11);
|
|
3978
|
+
}));
|
|
3979
|
+
return _processFile.apply(this, arguments);
|
|
3176
3980
|
}
|
|
3177
|
-
|
|
3178
|
-
// src/client.ts
|
|
3179
3981
|
var DEFAULT_BASE_URL = "https://we0.ai";
|
|
3180
3982
|
var DEFAULT_TIMEOUT = 3e4;
|
|
3181
3983
|
function uuid() {
|
|
3182
3984
|
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
3183
3985
|
return crypto.randomUUID();
|
|
3184
3986
|
}
|
|
3185
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c)
|
|
3186
|
-
|
|
3987
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
3988
|
+
var r = Math.random() * 16 | 0;
|
|
3187
3989
|
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
3188
3990
|
});
|
|
3189
3991
|
}
|
|
3190
3992
|
function toBlob(input) {
|
|
3191
3993
|
if (input instanceof Blob) return input;
|
|
3192
|
-
if (typeof input === "string") return new Blob([input], {
|
|
3994
|
+
if (typeof input === "string") return new Blob([input], {
|
|
3995
|
+
type: "text/plain"
|
|
3996
|
+
});
|
|
3193
3997
|
if (input instanceof ArrayBuffer) return new Blob([input]);
|
|
3194
|
-
|
|
3998
|
+
var copy = input.slice().buffer;
|
|
3195
3999
|
return new Blob([copy]);
|
|
3196
4000
|
}
|
|
3197
4001
|
function getExt2(fileName) {
|
|
@@ -3200,150 +4004,252 @@ function getExt2(fileName) {
|
|
|
3200
4004
|
function resolveFileName(originalName, rename) {
|
|
3201
4005
|
if (!rename) return originalName;
|
|
3202
4006
|
if (rename === true) {
|
|
3203
|
-
|
|
3204
|
-
return ext ?
|
|
4007
|
+
var ext = getExt2(originalName);
|
|
4008
|
+
return ext ? "".concat(uuid(), ".").concat(ext) : uuid();
|
|
3205
4009
|
}
|
|
3206
4010
|
if (typeof rename === "string") return rename;
|
|
3207
4011
|
if (typeof rename === "function") return rename(originalName);
|
|
3208
4012
|
return originalName;
|
|
3209
4013
|
}
|
|
3210
|
-
function createOssClient(
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
4014
|
+
function createOssClient() {
|
|
4015
|
+
var _options$baseURL, _options$timeout;
|
|
4016
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4017
|
+
var baseURL = (_options$baseURL = options.baseURL) !== null && _options$baseURL !== void 0 ? _options$baseURL : DEFAULT_BASE_URL;
|
|
4018
|
+
var timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : DEFAULT_TIMEOUT;
|
|
4019
|
+
var defaultRetry = options.retry;
|
|
4020
|
+
var defaultCompress = options.compress;
|
|
4021
|
+
var defaultLimits = options.limits;
|
|
4022
|
+
var allowedExtensions = options.allowedExtensions;
|
|
3217
4023
|
function mergeRetry(override) {
|
|
3218
4024
|
if (!defaultRetry && !override) return void 0;
|
|
3219
|
-
return {
|
|
4025
|
+
return _objectSpread$2(_objectSpread$2({}, defaultRetry), override);
|
|
3220
4026
|
}
|
|
3221
4027
|
function resolveCompress(override) {
|
|
3222
|
-
if (override === false) return {
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
4028
|
+
if (override === false) return {
|
|
4029
|
+
enabled: false
|
|
4030
|
+
};
|
|
4031
|
+
if (defaultCompress === false && override === void 0) return {
|
|
4032
|
+
enabled: false
|
|
4033
|
+
};
|
|
4034
|
+
var base = _typeof$1(defaultCompress) === "object" ? defaultCompress : {};
|
|
4035
|
+
return override ? _objectSpread$2(_objectSpread$2({}, base), override) : Object.keys(base).length ? base : void 0;
|
|
3226
4036
|
}
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
4037
|
+
function uploadOne(_x25, _x26, _x27, _x28) {
|
|
4038
|
+
return _uploadOne.apply(this, arguments);
|
|
4039
|
+
}
|
|
4040
|
+
function _uploadOne() {
|
|
4041
|
+
_uploadOne = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(sessionId, file, fileName, opts) {
|
|
4042
|
+
var finalName, blob, compress, formData;
|
|
4043
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
4044
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
4045
|
+
case 0:
|
|
4046
|
+
if (sessionId) {
|
|
4047
|
+
_context5.next = 1;
|
|
4048
|
+
break;
|
|
4049
|
+
}
|
|
4050
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4051
|
+
case 1:
|
|
4052
|
+
if (fileName) {
|
|
4053
|
+
_context5.next = 2;
|
|
4054
|
+
break;
|
|
4055
|
+
}
|
|
4056
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4057
|
+
case 2:
|
|
4058
|
+
finalName = resolveFileName(fileName, opts === null || opts === void 0 ? void 0 : opts.rename);
|
|
4059
|
+
blob = toBlob(file);
|
|
4060
|
+
if (opts !== null && opts !== void 0 && opts.skipValidation) {
|
|
4061
|
+
_context5.next = 3;
|
|
4062
|
+
break;
|
|
4063
|
+
}
|
|
4064
|
+
validateExtension(finalName, allowedExtensions);
|
|
4065
|
+
_context5.next = 3;
|
|
4066
|
+
return validateMagicBytes(blob, finalName);
|
|
4067
|
+
case 3:
|
|
4068
|
+
compress = resolveCompress(opts === null || opts === void 0 ? void 0 : opts.compress);
|
|
4069
|
+
_context5.next = 4;
|
|
4070
|
+
return processFile(blob, finalName, compress, defaultLimits);
|
|
4071
|
+
case 4:
|
|
4072
|
+
blob = _context5.sent;
|
|
4073
|
+
formData = new FormData();
|
|
4074
|
+
formData.append("file", blob, finalName);
|
|
4075
|
+
formData.append("sessionId", sessionId);
|
|
4076
|
+
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));
|
|
4077
|
+
case 5:
|
|
4078
|
+
case "end":
|
|
4079
|
+
return _context5.stop();
|
|
4080
|
+
}
|
|
4081
|
+
}, _callee5);
|
|
4082
|
+
}));
|
|
4083
|
+
return _uploadOne.apply(this, arguments);
|
|
3253
4084
|
}
|
|
3254
4085
|
return {
|
|
3255
4086
|
upload: uploadOne,
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
return new Promise((resolve, reject) => {
|
|
3267
|
-
function next() {
|
|
3268
|
-
if (results.length === files.length) {
|
|
3269
|
-
resolve(results);
|
|
3270
|
-
return;
|
|
3271
|
-
}
|
|
3272
|
-
while (running < concurrency && index < files.length) {
|
|
3273
|
-
const i = index++;
|
|
3274
|
-
const item = files[i];
|
|
3275
|
-
running++;
|
|
3276
|
-
const fileOpts = {
|
|
3277
|
-
retry: opts?.retry,
|
|
3278
|
-
compress: opts?.compress,
|
|
3279
|
-
...item.options
|
|
3280
|
-
};
|
|
3281
|
-
uploadOne(sessionId, item.file, item.fileName, fileOpts).then((result) => {
|
|
3282
|
-
results[i] = { fileName: item.fileName, success: true, result };
|
|
3283
|
-
}).catch((error) => {
|
|
3284
|
-
results[i] = { fileName: item.fileName, success: false, error };
|
|
3285
|
-
if (!continueOnError) {
|
|
3286
|
-
reject(error);
|
|
3287
|
-
return;
|
|
4087
|
+
uploadBatch: function uploadBatch(sessionId, files, opts) {
|
|
4088
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
4089
|
+
var _opts$concurrency, _opts$continueOnError;
|
|
4090
|
+
var concurrency, continueOnError, results, running, index;
|
|
4091
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
4092
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4093
|
+
case 0:
|
|
4094
|
+
if (sessionId) {
|
|
4095
|
+
_context.next = 1;
|
|
4096
|
+
break;
|
|
3288
4097
|
}
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
4098
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4099
|
+
case 1:
|
|
4100
|
+
if (files.length) {
|
|
4101
|
+
_context.next = 2;
|
|
4102
|
+
break;
|
|
4103
|
+
}
|
|
4104
|
+
return _context.abrupt("return", []);
|
|
4105
|
+
case 2:
|
|
4106
|
+
concurrency = (_opts$concurrency = opts === null || opts === void 0 ? void 0 : opts.concurrency) !== null && _opts$concurrency !== void 0 ? _opts$concurrency : 3;
|
|
4107
|
+
continueOnError = (_opts$continueOnError = opts === null || opts === void 0 ? void 0 : opts.continueOnError) !== null && _opts$continueOnError !== void 0 ? _opts$continueOnError : true;
|
|
4108
|
+
results = [];
|
|
4109
|
+
running = 0;
|
|
4110
|
+
index = 0;
|
|
4111
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
4112
|
+
function next() {
|
|
4113
|
+
if (results.length === files.length) {
|
|
4114
|
+
resolve(results);
|
|
4115
|
+
return;
|
|
4116
|
+
}
|
|
4117
|
+
var _loop = function _loop() {
|
|
4118
|
+
var i = index++;
|
|
4119
|
+
var item = files[i];
|
|
4120
|
+
running++;
|
|
4121
|
+
var fileOpts = _objectSpread$2({
|
|
4122
|
+
retry: opts === null || opts === void 0 ? void 0 : opts.retry,
|
|
4123
|
+
compress: opts === null || opts === void 0 ? void 0 : opts.compress
|
|
4124
|
+
}, item.options);
|
|
4125
|
+
uploadOne(sessionId, item.file, item.fileName, fileOpts).then(function (result) {
|
|
4126
|
+
results[i] = {
|
|
4127
|
+
fileName: item.fileName,
|
|
4128
|
+
success: true,
|
|
4129
|
+
result: result
|
|
4130
|
+
};
|
|
4131
|
+
})["catch"](function (error) {
|
|
4132
|
+
results[i] = {
|
|
4133
|
+
fileName: item.fileName,
|
|
4134
|
+
success: false,
|
|
4135
|
+
error: error
|
|
4136
|
+
};
|
|
4137
|
+
if (!continueOnError) {
|
|
4138
|
+
reject(error);
|
|
4139
|
+
return;
|
|
4140
|
+
}
|
|
4141
|
+
})["finally"](function () {
|
|
4142
|
+
running--;
|
|
4143
|
+
next();
|
|
4144
|
+
});
|
|
4145
|
+
};
|
|
4146
|
+
while (running < concurrency && index < files.length) {
|
|
4147
|
+
_loop();
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
next();
|
|
4151
|
+
}));
|
|
4152
|
+
case 3:
|
|
4153
|
+
case "end":
|
|
4154
|
+
return _context.stop();
|
|
3293
4155
|
}
|
|
3294
|
-
}
|
|
3295
|
-
|
|
3296
|
-
});
|
|
4156
|
+
}, _callee);
|
|
4157
|
+
}))();
|
|
3297
4158
|
},
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
4159
|
+
"delete": function _delete(sessionId, fileName, opts) {
|
|
4160
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
4161
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
4162
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4163
|
+
case 0:
|
|
4164
|
+
if (sessionId) {
|
|
4165
|
+
_context2.next = 1;
|
|
4166
|
+
break;
|
|
4167
|
+
}
|
|
4168
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4169
|
+
case 1:
|
|
4170
|
+
if (fileName) {
|
|
4171
|
+
_context2.next = 2;
|
|
4172
|
+
break;
|
|
4173
|
+
}
|
|
4174
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4175
|
+
case 2:
|
|
4176
|
+
return _context2.abrupt("return", requestJsonWithRetry(baseURL, timeout, "/api/oss/delete", {
|
|
4177
|
+
sessionId: sessionId,
|
|
4178
|
+
fileName: fileName
|
|
4179
|
+
}, mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry)));
|
|
4180
|
+
case 3:
|
|
4181
|
+
case "end":
|
|
4182
|
+
return _context2.stop();
|
|
4183
|
+
}
|
|
4184
|
+
}, _callee2);
|
|
4185
|
+
}))();
|
|
3312
4186
|
},
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
4187
|
+
getFileUrl: function getFileUrl(sessionId, fileName, opts) {
|
|
4188
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
4189
|
+
var params, result;
|
|
4190
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
4191
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4192
|
+
case 0:
|
|
4193
|
+
if (sessionId) {
|
|
4194
|
+
_context3.next = 1;
|
|
4195
|
+
break;
|
|
4196
|
+
}
|
|
4197
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4198
|
+
case 1:
|
|
4199
|
+
if (fileName) {
|
|
4200
|
+
_context3.next = 2;
|
|
4201
|
+
break;
|
|
4202
|
+
}
|
|
4203
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "fileName \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4204
|
+
case 2:
|
|
4205
|
+
params = new URLSearchParams({
|
|
4206
|
+
sessionId: sessionId,
|
|
4207
|
+
fileName: fileName
|
|
4208
|
+
});
|
|
4209
|
+
_context3.next = 3;
|
|
4210
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
4211
|
+
case 3:
|
|
4212
|
+
result = _context3.sent;
|
|
4213
|
+
return _context3.abrupt("return", result.url || "");
|
|
4214
|
+
case 4:
|
|
4215
|
+
case "end":
|
|
4216
|
+
return _context3.stop();
|
|
4217
|
+
}
|
|
4218
|
+
}, _callee3);
|
|
4219
|
+
}))();
|
|
3328
4220
|
},
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
4221
|
+
listFiles: function listFiles(sessionId, opts) {
|
|
4222
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
4223
|
+
var params, result;
|
|
4224
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
4225
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4226
|
+
case 0:
|
|
4227
|
+
if (sessionId) {
|
|
4228
|
+
_context4.next = 1;
|
|
4229
|
+
break;
|
|
4230
|
+
}
|
|
4231
|
+
throw new OssError(ErrorCode.INVALID_PARAMS, "sessionId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
4232
|
+
case 1:
|
|
4233
|
+
params = new URLSearchParams({
|
|
4234
|
+
sessionId: sessionId
|
|
4235
|
+
});
|
|
4236
|
+
_context4.next = 2;
|
|
4237
|
+
return requestGetWithRetry(baseURL, timeout, "/api/oss/file?".concat(params), mergeRetry(opts === null || opts === void 0 ? void 0 : opts.retry));
|
|
4238
|
+
case 2:
|
|
4239
|
+
result = _context4.sent;
|
|
4240
|
+
return _context4.abrupt("return", result.files);
|
|
4241
|
+
case 3:
|
|
4242
|
+
case "end":
|
|
4243
|
+
return _context4.stop();
|
|
4244
|
+
}
|
|
4245
|
+
}, _callee4);
|
|
4246
|
+
}))();
|
|
3341
4247
|
}
|
|
3342
4248
|
};
|
|
3343
4249
|
}
|
|
3344
4250
|
|
|
3345
4251
|
var _excluded$1 = ["accessKeyId", "accessKeySecret"];
|
|
3346
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
4252
|
+
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)); }
|
|
3347
4253
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
3348
4254
|
var DEFAULT_MAX_SIZE = 2 * 1024 * 1024;
|
|
3349
4255
|
var DEFAULT_SIGNED_URL_EXPIRES_IN = 60 * 60;
|
|
@@ -3351,15 +4257,15 @@ var OssUploadError = /*#__PURE__*/function (_Error) {
|
|
|
3351
4257
|
function OssUploadError(message) {
|
|
3352
4258
|
var _this;
|
|
3353
4259
|
var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
|
|
3354
|
-
_classCallCheck(this, OssUploadError);
|
|
4260
|
+
_classCallCheck$1(this, OssUploadError);
|
|
3355
4261
|
_this = _callSuper(this, OssUploadError, [message]);
|
|
3356
4262
|
_this.name = "OssUploadError";
|
|
3357
4263
|
_this.status = status;
|
|
3358
4264
|
return _this;
|
|
3359
4265
|
}
|
|
3360
|
-
_inherits(OssUploadError, _Error);
|
|
3361
|
-
return _createClass(OssUploadError);
|
|
3362
|
-
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
4266
|
+
_inherits$1(OssUploadError, _Error);
|
|
4267
|
+
return _createClass$1(OssUploadError);
|
|
4268
|
+
}(/*#__PURE__*/_wrapNativeSuper$1(Error));
|
|
3363
4269
|
function sanitizePathSegment(value) {
|
|
3364
4270
|
return String(value || "").trim().replace(/[^a-zA-Z0-9/_-]+/g, "-").replace(/\/{2,}/g, "/").replace(/^\/+|\/+$/g, "");
|
|
3365
4271
|
}
|
|
@@ -3424,7 +4330,7 @@ function normalizeSdkError(error) {
|
|
|
3424
4330
|
}
|
|
3425
4331
|
var OssUploadService = /*#__PURE__*/function () {
|
|
3426
4332
|
function OssUploadService(config) {
|
|
3427
|
-
_classCallCheck(this, OssUploadService);
|
|
4333
|
+
_classCallCheck$1(this, OssUploadService);
|
|
3428
4334
|
this.config = normalizeConfig(config);
|
|
3429
4335
|
this.client = createOssClient({
|
|
3430
4336
|
baseURL: this.config.baseURL,
|
|
@@ -3432,7 +4338,7 @@ var OssUploadService = /*#__PURE__*/function () {
|
|
|
3432
4338
|
retry: this.config.retry
|
|
3433
4339
|
});
|
|
3434
4340
|
}
|
|
3435
|
-
return _createClass(OssUploadService, [{
|
|
4341
|
+
return _createClass$1(OssUploadService, [{
|
|
3436
4342
|
key: "getConfig",
|
|
3437
4343
|
value: function getConfig() {
|
|
3438
4344
|
var _this$config = this.config;
|
|
@@ -3444,9 +4350,9 @@ var OssUploadService = /*#__PURE__*/function () {
|
|
|
3444
4350
|
}, {
|
|
3445
4351
|
key: "upload",
|
|
3446
4352
|
value: function () {
|
|
3447
|
-
var _upload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(input) {
|
|
4353
|
+
var _upload = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(input) {
|
|
3448
4354
|
var sessionId, maxSize, objectKey, result, url, resolvedUrl, _t;
|
|
3449
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
4355
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
3450
4356
|
while (1) switch (_context.prev = _context.next) {
|
|
3451
4357
|
case 0:
|
|
3452
4358
|
sessionId = String(input.sessionId || "").trim();
|
|
@@ -3558,9 +4464,9 @@ function ensureAdminRegistryTable(_x) {
|
|
|
3558
4464
|
return _ensureAdminRegistryTable.apply(this, arguments);
|
|
3559
4465
|
}
|
|
3560
4466
|
function _ensureAdminRegistryTable() {
|
|
3561
|
-
_ensureAdminRegistryTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(supabase) {
|
|
4467
|
+
_ensureAdminRegistryTable = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(supabase) {
|
|
3562
4468
|
var _yield$supabase$from$, error;
|
|
3563
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
4469
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
3564
4470
|
while (1) switch (_context.prev = _context.next) {
|
|
3565
4471
|
case 0:
|
|
3566
4472
|
if (!ensured) {
|
|
@@ -3601,9 +4507,9 @@ function getSessionAdminRow(_x2, _x3) {
|
|
|
3601
4507
|
return _getSessionAdminRow.apply(this, arguments);
|
|
3602
4508
|
}
|
|
3603
4509
|
function _getSessionAdminRow() {
|
|
3604
|
-
_getSessionAdminRow = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(supabase, sessionId) {
|
|
4510
|
+
_getSessionAdminRow = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(supabase, sessionId) {
|
|
3605
4511
|
var sid, _yield$supabase$from$2, data, error;
|
|
3606
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
4512
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
3607
4513
|
while (1) switch (_context2.prev = _context2.next) {
|
|
3608
4514
|
case 0:
|
|
3609
4515
|
sid = normalizeSessionId(sessionId);
|
|
@@ -3632,9 +4538,9 @@ function isUserSessionAdmin(_x4, _x5, _x6) {
|
|
|
3632
4538
|
return _isUserSessionAdmin.apply(this, arguments);
|
|
3633
4539
|
}
|
|
3634
4540
|
function _isUserSessionAdmin() {
|
|
3635
|
-
_isUserSessionAdmin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(supabase, sessionId, userId) {
|
|
4541
|
+
_isUserSessionAdmin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(supabase, sessionId, userId) {
|
|
3636
4542
|
var row;
|
|
3637
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
4543
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
3638
4544
|
while (1) switch (_context3.prev = _context3.next) {
|
|
3639
4545
|
case 0:
|
|
3640
4546
|
_context3.next = 1;
|
|
@@ -3667,9 +4573,9 @@ function initializeSystem() {
|
|
|
3667
4573
|
return _initializeSystem.apply(this, arguments);
|
|
3668
4574
|
}
|
|
3669
4575
|
function _initializeSystem() {
|
|
3670
|
-
_initializeSystem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
4576
|
+
_initializeSystem = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee() {
|
|
3671
4577
|
var _t;
|
|
3672
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
4578
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
3673
4579
|
while (1) switch (_context.prev = _context.next) {
|
|
3674
4580
|
case 0:
|
|
3675
4581
|
_context.prev = 0;
|
|
@@ -3760,9 +4666,9 @@ function getModels(_x) {
|
|
|
3760
4666
|
}
|
|
3761
4667
|
// POST - 创建新模型
|
|
3762
4668
|
function _getModels() {
|
|
3763
|
-
_getModels = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
4669
|
+
_getModels = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c) {
|
|
3764
4670
|
var cmsModelService, page, limit, name, sessionId, models, tablePrefix, total, offset, paginatedModels, response, _response, _t2;
|
|
3765
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
4671
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
3766
4672
|
while (1) switch (_context2.prev = _context2.next) {
|
|
3767
4673
|
case 0:
|
|
3768
4674
|
_context2.prev = 0;
|
|
@@ -3831,9 +4737,9 @@ function createModel(_x2) {
|
|
|
3831
4737
|
}
|
|
3832
4738
|
// PUT - 更新模型
|
|
3833
4739
|
function _createModel() {
|
|
3834
|
-
_createModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c) {
|
|
4740
|
+
_createModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(c) {
|
|
3835
4741
|
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;
|
|
3836
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
4742
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
3837
4743
|
while (1) switch (_context3.prev = _context3.next) {
|
|
3838
4744
|
case 0:
|
|
3839
4745
|
_context3.prev = 0;
|
|
@@ -3977,9 +4883,9 @@ function updateModel(_x3) {
|
|
|
3977
4883
|
}
|
|
3978
4884
|
// DELETE - 删除模型
|
|
3979
4885
|
function _updateModel() {
|
|
3980
|
-
_updateModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(c) {
|
|
4886
|
+
_updateModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(c) {
|
|
3981
4887
|
var cmsModelService, body, id, name, json_schema, _response0, model, _response1, schemaValidationError, _response10, updateData, updatedModel, response, _response11, _t4;
|
|
3982
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
4888
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
3983
4889
|
while (1) switch (_context4.prev = _context4.next) {
|
|
3984
4890
|
case 0:
|
|
3985
4891
|
_context4.prev = 0;
|
|
@@ -4067,9 +4973,9 @@ function deleteModel(_x4) {
|
|
|
4067
4973
|
return _deleteModel.apply(this, arguments);
|
|
4068
4974
|
}
|
|
4069
4975
|
function _deleteModel() {
|
|
4070
|
-
_deleteModel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(c) {
|
|
4976
|
+
_deleteModel = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(c) {
|
|
4071
4977
|
var cmsModelService, dynamicTableService, idStr, _response12, id, model, _response13, tableDropped, _response14, response, _response15, _t5;
|
|
4072
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
4978
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
4073
4979
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4074
4980
|
case 0:
|
|
4075
4981
|
_context5.prev = 0;
|
|
@@ -4206,7 +5112,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
4206
5112
|
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; } }
|
|
4207
5113
|
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; }
|
|
4208
5114
|
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; }
|
|
4209
|
-
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; }
|
|
5115
|
+
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; }
|
|
4210
5116
|
function normalizeJsonLikeFields(schemaFields, payload) {
|
|
4211
5117
|
if (!schemaFields || schemaFields.length === 0) return payload;
|
|
4212
5118
|
var jsonLikeFieldNames = new Set(schemaFields.filter(function (f) {
|
|
@@ -4432,9 +5338,9 @@ function getTableData(_x, _x2) {
|
|
|
4432
5338
|
}
|
|
4433
5339
|
// POST - 创建新数据
|
|
4434
5340
|
function _getTableData() {
|
|
4435
|
-
_getTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c, tableName) {
|
|
5341
|
+
_getTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c, tableName) {
|
|
4436
5342
|
var _model$json_schema, validationResponse, dynamicTableService, cmsModelService, page, limit, search, filtersStr, model, schemaFields, filters, _response, parsed, normalized, _response2, result, searchableFields, response, _response3, _t, _t2;
|
|
4437
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
5343
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
4438
5344
|
while (1) switch (_context.prev = _context.next) {
|
|
4439
5345
|
case 0:
|
|
4440
5346
|
_context.prev = 0;
|
|
@@ -4574,9 +5480,9 @@ function createTableData(_x3, _x4) {
|
|
|
4574
5480
|
}
|
|
4575
5481
|
// PUT - 更新数据
|
|
4576
5482
|
function _createTableData() {
|
|
4577
|
-
_createTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c, tableName) {
|
|
5483
|
+
_createTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c, tableName) {
|
|
4578
5484
|
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;
|
|
4579
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
5485
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
4580
5486
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4581
5487
|
case 0:
|
|
4582
5488
|
_context2.prev = 0;
|
|
@@ -4660,9 +5566,9 @@ function updateTableData(_x5, _x6) {
|
|
|
4660
5566
|
}
|
|
4661
5567
|
// DELETE - 删除数据
|
|
4662
5568
|
function _updateTableData() {
|
|
4663
|
-
_updateTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c, tableName) {
|
|
5569
|
+
_updateTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(c, tableName) {
|
|
4664
5570
|
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;
|
|
4665
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
5571
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
4666
5572
|
while (1) switch (_context3.prev = _context3.next) {
|
|
4667
5573
|
case 0:
|
|
4668
5574
|
_context3.prev = 0;
|
|
@@ -4791,9 +5697,9 @@ function deleteTableData(_x7, _x8) {
|
|
|
4791
5697
|
}
|
|
4792
5698
|
// GET - 获取关联表选项列表 (用于下拉选择)
|
|
4793
5699
|
function _deleteTableData() {
|
|
4794
|
-
_deleteTableData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(c, tableName) {
|
|
5700
|
+
_deleteTableData = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(c, tableName) {
|
|
4795
5701
|
var validationResponse, dynamicTableService, id, _response10, recordId, _response11, existingData, _response12, result, response, _response13, _t7;
|
|
4796
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
5702
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
4797
5703
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4798
5704
|
case 0:
|
|
4799
5705
|
_context4.prev = 0;
|
|
@@ -4874,9 +5780,9 @@ function getRelationOptions(_x9, _x0) {
|
|
|
4874
5780
|
}
|
|
4875
5781
|
// GET - 获取表数据(带关联数据)
|
|
4876
5782
|
function _getRelationOptions() {
|
|
4877
|
-
_getRelationOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(c, tableName) {
|
|
5783
|
+
_getRelationOptions = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(c, tableName) {
|
|
4878
5784
|
var validationResponse, dynamicTableService, displayField, limit, search, params, options, response, _response14, _t8;
|
|
4879
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
5785
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
4880
5786
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4881
5787
|
case 0:
|
|
4882
5788
|
_context5.prev = 0;
|
|
@@ -4930,9 +5836,9 @@ function getTableDataWithRelations(_x1, _x10) {
|
|
|
4930
5836
|
// DELETE - 删除表的所有外键约束
|
|
4931
5837
|
// 用于解决外键约束引用错误表的问题
|
|
4932
5838
|
function _getTableDataWithRelations() {
|
|
4933
|
-
_getTableDataWithRelations = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(c, tableName) {
|
|
5839
|
+
_getTableDataWithRelations = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(c, tableName) {
|
|
4934
5840
|
var validationResponse, dynamicTableService, cmsModelService, page, limit, model, result, response, hasRelations, _result, _response15, _result2, _response16, _response17, _t9;
|
|
4935
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
5841
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
4936
5842
|
while (1) switch (_context6.prev = _context6.next) {
|
|
4937
5843
|
case 0:
|
|
4938
5844
|
_context6.prev = 0;
|
|
@@ -5017,9 +5923,9 @@ function dropForeignKeys(_x11, _x12) {
|
|
|
5017
5923
|
return _dropForeignKeys.apply(this, arguments);
|
|
5018
5924
|
}
|
|
5019
5925
|
function _dropForeignKeys() {
|
|
5020
|
-
_dropForeignKeys = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(c, tableName) {
|
|
5926
|
+
_dropForeignKeys = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7(c, tableName) {
|
|
5021
5927
|
var validationResponse, dynamicTableService, result, response, _response18, _response19, _t0;
|
|
5022
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
5928
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
5023
5929
|
while (1) switch (_context7.prev = _context7.next) {
|
|
5024
5930
|
case 0:
|
|
5025
5931
|
_context7.prev = 0;
|
|
@@ -5080,9 +5986,9 @@ var JWT_EXPIRES_IN = '24h';
|
|
|
5080
5986
|
*/
|
|
5081
5987
|
var AuthUtils = /*#__PURE__*/function () {
|
|
5082
5988
|
function AuthUtils() {
|
|
5083
|
-
_classCallCheck(this, AuthUtils);
|
|
5989
|
+
_classCallCheck$1(this, AuthUtils);
|
|
5084
5990
|
}
|
|
5085
|
-
return _createClass(AuthUtils, null, [{
|
|
5991
|
+
return _createClass$1(AuthUtils, null, [{
|
|
5086
5992
|
key: "generateToken",
|
|
5087
5993
|
value:
|
|
5088
5994
|
/**
|
|
@@ -5118,8 +6024,8 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5118
6024
|
}, {
|
|
5119
6025
|
key: "validatePassword",
|
|
5120
6026
|
value: (function () {
|
|
5121
|
-
var _validatePassword = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(plainPassword, hashedPassword) {
|
|
5122
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
6027
|
+
var _validatePassword = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(plainPassword, hashedPassword) {
|
|
6028
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
5123
6029
|
while (1) switch (_context.prev = _context.next) {
|
|
5124
6030
|
case 0:
|
|
5125
6031
|
return _context.abrupt("return", bcrypt.compare(plainPassword, hashedPassword));
|
|
@@ -5141,8 +6047,8 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5141
6047
|
}, {
|
|
5142
6048
|
key: "hashPassword",
|
|
5143
6049
|
value: (function () {
|
|
5144
|
-
var _hashPassword = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(password) {
|
|
5145
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
6050
|
+
var _hashPassword = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(password) {
|
|
6051
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
5146
6052
|
while (1) switch (_context2.prev = _context2.next) {
|
|
5147
6053
|
case 0:
|
|
5148
6054
|
return _context2.abrupt("return", bcrypt.hash(password, 10));
|
|
@@ -5183,9 +6089,9 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5183
6089
|
}, {
|
|
5184
6090
|
key: "authenticateUser",
|
|
5185
6091
|
value: (function () {
|
|
5186
|
-
var _authenticateUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(username, password, tableName) {
|
|
6092
|
+
var _authenticateUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(username, password, tableName) {
|
|
5187
6093
|
var authService, user, isPasswordValid, _t;
|
|
5188
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
6094
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
5189
6095
|
while (1) switch (_context3.prev = _context3.next) {
|
|
5190
6096
|
case 0:
|
|
5191
6097
|
authService = this.getAuthService(); // 查询用户
|
|
@@ -5254,9 +6160,9 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5254
6160
|
}, {
|
|
5255
6161
|
key: "verifyTokenAndGetUser",
|
|
5256
6162
|
value: (function () {
|
|
5257
|
-
var _verifyTokenAndGetUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(token, tableName) {
|
|
6163
|
+
var _verifyTokenAndGetUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(token, tableName) {
|
|
5258
6164
|
var decoded, authService, userInfo, message, _t2;
|
|
5259
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
6165
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
5260
6166
|
while (1) switch (_context4.prev = _context4.next) {
|
|
5261
6167
|
case 0:
|
|
5262
6168
|
_context4.prev = 0;
|
|
@@ -5312,7 +6218,7 @@ var AuthUtils = /*#__PURE__*/function () {
|
|
|
5312
6218
|
}();
|
|
5313
6219
|
|
|
5314
6220
|
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; }
|
|
5315
|
-
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; }
|
|
6221
|
+
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; }
|
|
5316
6222
|
function getRoleFromSupabaseUser$2(user) {
|
|
5317
6223
|
var _user$app_metadata, _user$user_metadata;
|
|
5318
6224
|
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;
|
|
@@ -5348,9 +6254,9 @@ function findAuthUserByEmail(_x, _x2) {
|
|
|
5348
6254
|
return _findAuthUserByEmail.apply(this, arguments);
|
|
5349
6255
|
}
|
|
5350
6256
|
function _findAuthUserByEmail() {
|
|
5351
|
-
_findAuthUserByEmail = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(supabase, email) {
|
|
6257
|
+
_findAuthUserByEmail = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(supabase, email) {
|
|
5352
6258
|
var normalizedEmail, page, _yield$supabase$auth$2, data, error, users, matchedUser;
|
|
5353
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
6259
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
5354
6260
|
while (1) switch (_context2.prev = _context2.next) {
|
|
5355
6261
|
case 0:
|
|
5356
6262
|
normalizedEmail = email.trim().toLowerCase();
|
|
@@ -5409,8 +6315,8 @@ function insertAdminRegistryRow(_x3, _x4, _x5, _x6) {
|
|
|
5409
6315
|
return _insertAdminRegistryRow.apply(this, arguments);
|
|
5410
6316
|
}
|
|
5411
6317
|
function _insertAdminRegistryRow() {
|
|
5412
|
-
_insertAdminRegistryRow = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(supabase, sessionId, userId, account) {
|
|
5413
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
6318
|
+
_insertAdminRegistryRow = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(supabase, sessionId, userId, account) {
|
|
6319
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
5414
6320
|
while (1) switch (_context3.prev = _context3.next) {
|
|
5415
6321
|
case 0:
|
|
5416
6322
|
_context3.next = 1;
|
|
@@ -5433,9 +6339,9 @@ function promoteExistingUserToSessionAdmin(_x7, _x8, _x9, _x0) {
|
|
|
5433
6339
|
return _promoteExistingUserToSessionAdmin.apply(this, arguments);
|
|
5434
6340
|
}
|
|
5435
6341
|
function _promoteExistingUserToSessionAdmin() {
|
|
5436
|
-
_promoteExistingUserToSessionAdmin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(supabase, email, sessionId, account) {
|
|
6342
|
+
_promoteExistingUserToSessionAdmin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(supabase, email, sessionId, account) {
|
|
5437
6343
|
var existingUser, _yield$supabase$auth$3, updatedData, updateError, insertRes;
|
|
5438
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
6344
|
+
return _regeneratorRuntime$1.wrap(function (_context4) {
|
|
5439
6345
|
while (1) switch (_context4.prev = _context4.next) {
|
|
5440
6346
|
case 0:
|
|
5441
6347
|
_context4.next = 1;
|
|
@@ -5502,9 +6408,9 @@ function getEffectiveRoleForSession(_x1, _x10) {
|
|
|
5502
6408
|
return _getEffectiveRoleForSession.apply(this, arguments);
|
|
5503
6409
|
} // POST - 用户登录
|
|
5504
6410
|
function _getEffectiveRoleForSession() {
|
|
5505
|
-
_getEffectiveRoleForSession = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(user, sessionId) {
|
|
6411
|
+
_getEffectiveRoleForSession = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(user, sessionId) {
|
|
5506
6412
|
var supabase, sid, role, ok;
|
|
5507
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
6413
|
+
return _regeneratorRuntime$1.wrap(function (_context5) {
|
|
5508
6414
|
while (1) switch (_context5.prev = _context5.next) {
|
|
5509
6415
|
case 0:
|
|
5510
6416
|
supabase = getSupabase();
|
|
@@ -5540,9 +6446,9 @@ function login(_x11, _x12) {
|
|
|
5540
6446
|
}
|
|
5541
6447
|
// GET - 是否允许注册(首次进入需要创建管理员账号)
|
|
5542
6448
|
function _login() {
|
|
5543
|
-
_login = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(c, tableName) {
|
|
6449
|
+
_login = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(c, tableName) {
|
|
5544
6450
|
var _data$session, body, username, password, supabase, sessionId, email, _yield$supabase$auth$4, data, error, token, user, role, _t3;
|
|
5545
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
6451
|
+
return _regeneratorRuntime$1.wrap(function (_context6) {
|
|
5546
6452
|
while (1) switch (_context6.prev = _context6.next) {
|
|
5547
6453
|
case 0:
|
|
5548
6454
|
_context6.prev = 0;
|
|
@@ -5635,9 +6541,9 @@ function signupStatus(_x13, _x14) {
|
|
|
5635
6541
|
}
|
|
5636
6542
|
// POST - 首次注册管理员(每个 session_id 只允许一个)
|
|
5637
6543
|
function _signupStatus() {
|
|
5638
|
-
_signupStatus = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(c, tableName) {
|
|
6544
|
+
_signupStatus = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee7(c, tableName) {
|
|
5639
6545
|
var supabase, sessionId, ok, row, data, _t4;
|
|
5640
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
6546
|
+
return _regeneratorRuntime$1.wrap(function (_context7) {
|
|
5641
6547
|
while (1) switch (_context7.prev = _context7.next) {
|
|
5642
6548
|
case 0:
|
|
5643
6549
|
_context7.prev = 0;
|
|
@@ -5694,9 +6600,9 @@ function signup(_x15, _x16) {
|
|
|
5694
6600
|
}
|
|
5695
6601
|
// POST - 验证token
|
|
5696
6602
|
function _signup() {
|
|
5697
|
-
_signup = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(c, tableName) {
|
|
6603
|
+
_signup = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee8(c, tableName) {
|
|
5698
6604
|
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;
|
|
5699
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
6605
|
+
return _regeneratorRuntime$1.wrap(function (_context8) {
|
|
5700
6606
|
while (1) switch (_context8.prev = _context8.next) {
|
|
5701
6607
|
case 0:
|
|
5702
6608
|
_context8.prev = 0;
|
|
@@ -5867,9 +6773,9 @@ function verifyAuth(_x17, _x18) {
|
|
|
5867
6773
|
}
|
|
5868
6774
|
// GET - 获取当前用户信息
|
|
5869
6775
|
function _verifyAuth() {
|
|
5870
|
-
_verifyAuth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(c, tableName) {
|
|
6776
|
+
_verifyAuth = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee9(c, tableName) {
|
|
5871
6777
|
var authHeader, token, supabase, _yield$supabase$auth$6, data, error, sessionId, role, decoded, message, responseMessage, _t6, _t7;
|
|
5872
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
6778
|
+
return _regeneratorRuntime$1.wrap(function (_context9) {
|
|
5873
6779
|
while (1) switch (_context9.prev = _context9.next) {
|
|
5874
6780
|
case 0:
|
|
5875
6781
|
_context9.prev = 0;
|
|
@@ -5947,9 +6853,9 @@ function getCurrentUser(_x19, _x20) {
|
|
|
5947
6853
|
}
|
|
5948
6854
|
// 中间件:验证 Supabase JWT token
|
|
5949
6855
|
function _getCurrentUser() {
|
|
5950
|
-
_getCurrentUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(c, tableName) {
|
|
6856
|
+
_getCurrentUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee0(c, tableName) {
|
|
5951
6857
|
var authHeader, token, supabase, _yield$supabase$auth$7, data, error, user, sessionId, role, _t8;
|
|
5952
|
-
return _regeneratorRuntime.wrap(function (_context0) {
|
|
6858
|
+
return _regeneratorRuntime$1.wrap(function (_context0) {
|
|
5953
6859
|
while (1) switch (_context0.prev = _context0.next) {
|
|
5954
6860
|
case 0:
|
|
5955
6861
|
_context0.prev = 0;
|
|
@@ -6020,7 +6926,7 @@ function _getCurrentUser() {
|
|
|
6020
6926
|
}
|
|
6021
6927
|
function requireAuth(handler) {
|
|
6022
6928
|
return /*#__PURE__*/function () {
|
|
6023
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c) {
|
|
6929
|
+
var _ref = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c) {
|
|
6024
6930
|
var authHeader,
|
|
6025
6931
|
token,
|
|
6026
6932
|
supabase,
|
|
@@ -6032,7 +6938,7 @@ function requireAuth(handler) {
|
|
|
6032
6938
|
_key,
|
|
6033
6939
|
_args = arguments,
|
|
6034
6940
|
_t2;
|
|
6035
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
6941
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6036
6942
|
while (1) switch (_context.prev = _context.next) {
|
|
6037
6943
|
case 0:
|
|
6038
6944
|
_context.prev = 0;
|
|
@@ -6114,10 +7020,10 @@ function resolveUploadMaxSize(_x, _x2) {
|
|
|
6114
7020
|
return _resolveUploadMaxSize.apply(this, arguments);
|
|
6115
7021
|
}
|
|
6116
7022
|
function _resolveUploadMaxSize() {
|
|
6117
|
-
_resolveUploadMaxSize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(tableName, fieldName) {
|
|
7023
|
+
_resolveUploadMaxSize = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(tableName, fieldName) {
|
|
6118
7024
|
var _model$json_schema;
|
|
6119
7025
|
var cmsModelService, model;
|
|
6120
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
7026
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6121
7027
|
while (1) switch (_context.prev = _context.next) {
|
|
6122
7028
|
case 0:
|
|
6123
7029
|
if (!(!tableName || !fieldName)) {
|
|
@@ -6147,9 +7053,9 @@ function uploadToOss(_x3) {
|
|
|
6147
7053
|
return _uploadToOss.apply(this, arguments);
|
|
6148
7054
|
}
|
|
6149
7055
|
function _uploadToOss() {
|
|
6150
|
-
_uploadToOss = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
7056
|
+
_uploadToOss = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c) {
|
|
6151
7057
|
var formData, file, fieldName, tableName, uploadService, result, status, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8;
|
|
6152
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7058
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
6153
7059
|
while (1) switch (_context2.prev = _context2.next) {
|
|
6154
7060
|
case 0:
|
|
6155
7061
|
_context2.prev = 0;
|
|
@@ -6231,9 +7137,9 @@ function getRoleFromSupabaseUser$1(user) {
|
|
|
6231
7137
|
return appRole !== null && appRole !== void 0 ? appRole : userRole;
|
|
6232
7138
|
}
|
|
6233
7139
|
var requireJwtAuth = /*#__PURE__*/function () {
|
|
6234
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c, next) {
|
|
7140
|
+
var _ref = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c, next) {
|
|
6235
7141
|
var authHeader, token, supabase, _yield$supabase$auth$, data, error, auth;
|
|
6236
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
7142
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6237
7143
|
while (1) switch (_context.prev = _context.next) {
|
|
6238
7144
|
case 0:
|
|
6239
7145
|
authHeader = c.req.header("Authorization") || null;
|
|
@@ -6295,10 +7201,10 @@ var requireJwtAuth = /*#__PURE__*/function () {
|
|
|
6295
7201
|
};
|
|
6296
7202
|
}();
|
|
6297
7203
|
var requireAdminRole = /*#__PURE__*/function () {
|
|
6298
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c, next) {
|
|
7204
|
+
var _ref2 = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c, next) {
|
|
6299
7205
|
var _user$user_metadata2;
|
|
6300
7206
|
var auth, role, sessionId, user, userSessionId, supabase, ok, isAdmin;
|
|
6301
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7207
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
6302
7208
|
while (1) switch (_context2.prev = _context2.next) {
|
|
6303
7209
|
case 0:
|
|
6304
7210
|
auth = c.auth;
|
|
@@ -6394,9 +7300,9 @@ function supabaseLogin(_x) {
|
|
|
6394
7300
|
}
|
|
6395
7301
|
// POST - 校验 Supabase JWT(需要 Authorization: Bearer <token>)
|
|
6396
7302
|
function _supabaseLogin() {
|
|
6397
|
-
_supabaseLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(c) {
|
|
7303
|
+
_supabaseLogin = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee(c) {
|
|
6398
7304
|
var _body$email, _data$session, body, email, password, supabase, _yield$supabase$auth$, data, error, token, user, role, _t;
|
|
6399
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
7305
|
+
return _regeneratorRuntime$1.wrap(function (_context) {
|
|
6400
7306
|
while (1) switch (_context.prev = _context.next) {
|
|
6401
7307
|
case 0:
|
|
6402
7308
|
_context.prev = 0;
|
|
@@ -6471,9 +7377,9 @@ function supabaseVerify(_x2) {
|
|
|
6471
7377
|
}
|
|
6472
7378
|
// GET - 当前用户(需要 Authorization: Bearer <token>)
|
|
6473
7379
|
function _supabaseVerify() {
|
|
6474
|
-
_supabaseVerify = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(c) {
|
|
7380
|
+
_supabaseVerify = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee2(c) {
|
|
6475
7381
|
var token, supabase, _yield$supabase$auth$2, data, error, _t2;
|
|
6476
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
7382
|
+
return _regeneratorRuntime$1.wrap(function (_context2) {
|
|
6477
7383
|
while (1) switch (_context2.prev = _context2.next) {
|
|
6478
7384
|
case 0:
|
|
6479
7385
|
_context2.prev = 0;
|
|
@@ -6528,9 +7434,9 @@ function supabaseCurrentUser(_x3) {
|
|
|
6528
7434
|
return _supabaseCurrentUser.apply(this, arguments);
|
|
6529
7435
|
}
|
|
6530
7436
|
function _supabaseCurrentUser() {
|
|
6531
|
-
_supabaseCurrentUser = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(c) {
|
|
7437
|
+
_supabaseCurrentUser = _asyncToGenerator$1(/*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3(c) {
|
|
6532
7438
|
var token, supabase, _yield$supabase$auth$3, data, error, user, role, _t3;
|
|
6533
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
7439
|
+
return _regeneratorRuntime$1.wrap(function (_context3) {
|
|
6534
7440
|
while (1) switch (_context3.prev = _context3.next) {
|
|
6535
7441
|
case 0:
|
|
6536
7442
|
_context3.prev = 0;
|